diff --git a/config/build-server.ts b/config/build-server.ts index c2d9659e..0a85b27c 100644 --- a/config/build-server.ts +++ b/config/build-server.ts @@ -31,16 +31,27 @@ async function buildPierreEmbedModalCss(): Promise { .replaceAll('__SHADOW_REST__', PIERRE_MODAL_SHADOW_REST) } +function assertPierreIife(path: string, code: string): void { + const trimmed = code.trimStart() + // Host/embed scripts run on third-party pages (jQuery, etc.). Minified top-level + // `var $` / short globals must stay inside an IIFE — never leak to window. + if (!/^\(?function\b|^!\s*function\b|^\(\s*\(\s*\)\s*=>/.test(trimmed)) { + throw new Error(`${path} must be an IIFE (--format=iife) to avoid host global clashes`) + } +} + function assertPierreHostMinified(pierrePath: string, pierre: string): void { if (pierre.includes('pierre_is_open') || pierre.includes('pierre-embed-modal')) { throw new Error(`${pierrePath} was not minified — check oxfmt/format-on-save`) } + assertPierreIife(pierrePath, pierre) } function assertPierreEmbedMinified(pierreEmbedPath: string, pierreEmbed: string): void { if (pierreEmbed.includes('\nconst MODAL_ID')) { throw new Error(`${pierreEmbedPath} was not minified — check oxfmt/format-on-save`) } + assertPierreIife(pierreEmbedPath, pierreEmbed) } // A timestamp used in filename to avoid caching issue (CSS + JS) @@ -76,9 +87,6 @@ for (const mdRoot of mdRoots) { } } -await $`bun lint` -await $`bun format` - // Compile production CSS file await $`bunx @tailwindcss/cli@latest -i ${SERVER}/assets/tailwind/style.css -o ${SERVER}/assets/dist/css/style.${timestamp}.css --minify` @@ -92,9 +100,9 @@ await Bun.write( ) // Transpile and minify .ts/.tsx scripts into .js to work in browser. -await $`bun build ${SERVER}/assets/scripts/ai.tsx --outfile ${SERVER}/assets/dist/js/ai.${timestamp}.js --minify --target browser` -await $`bun build ${PIERRE_HOST}/pierre.ts --outfile ${SERVER}/assets/dist/js/pierre.js --minify --target browser` -await $`bun build ${PIERRE_EMBED}/pierre-embed.ts --outfile ${SERVER}/assets/dist/js/pierre-embed.js --minify --target browser` +await $`bun build ${SERVER}/assets/scripts/ai.tsx --outfile ${SERVER}/assets/dist/js/ai.${timestamp}.js --minify --target browser --production` +await $`bun build ${PIERRE_HOST}/pierre.ts --outfile ${SERVER}/assets/dist/js/pierre.js --minify --target browser --format=iife` +await $`bun build ${PIERRE_EMBED}/pierre-embed.ts --outfile ${SERVER}/assets/dist/js/pierre-embed.js --minify --target browser --format=iife` const pierreDistPath = join(SERVER, 'assets/dist/js/pierre.js') assertPierreHostMinified(pierreDistPath, await Bun.file(pierreDistPath).text()) diff --git a/docs/assets/pierre.js b/docs/assets/pierre.js index 930c9183..ceee5f37 100644 --- a/docs/assets/pierre.js +++ b/docs/assets/pierre.js @@ -1 +1 @@ -var $=new Set(["pierre:ready","pierre:closing","pierre:closed","pierre:open-cancelled"]);var I={open:{scrim:300,launcher:160,launcherDelay:40},close:{scrim:220,launcher:180,launcherDelay:0}};var h=document.currentScript??document.querySelector("script[data-pierre-config]")??document.querySelector('script[src$="/pierre.js"]'),U=()=>{let e=h?.src??"";return{url:(e?new URL(e):null)?.origin??"",configuration:h?.dataset.pierreConfig??"default"}},E=(e)=>["position:fixed","inset:0","width:100%","height:100%","border:0",`z-index:${e?"2147483647":"-1"}`,"background:transparent",`pointer-events:${e?"auto":"none"}`,"color-scheme:normal"].join(";"),A="",B="",C="",u=[],c=[],g=new WeakMap,m=null,y=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,G=()=>window.matchMedia("(max-width: 600px)").matches,_=(e)=>e.finished.catch(()=>{return}),D=()=>document.querySelectorAll("[data-pierre-open]"),V=(e)=>{let t=e.style.transform;if(t&&t!=="none")return t;let n=getComputedStyle(e).transform;return n!=="none"?n:""},p=(e,t)=>{let n=`scale(${t})`;if(!e||e==="none")return n;return`${e} ${n}`},S=(e)=>{if(!e.dataset.pierreBaseTransform)e.dataset.pierreBaseTransform=V(e)},W=(e)=>{e.style.opacity="",e.style.transform=e.dataset.pierreBaseTransform??"",e.style.pointerEvents="",e.removeAttribute("aria-hidden")},F=(e)=>{D().forEach((t)=>{if(t===e)return;t.style.opacity="0",t.style.pointerEvents="none",t.setAttribute("aria-hidden","true")})},M=()=>{D().forEach(W)},R=(e,t,n,s)=>{S(e);let i=e.dataset.pierreBaseTransform??"",o=t==="in"?"cubic-bezier(0.34, 1.28, 0.64, 1)":"cubic-bezier(0.4, 0, 0.2, 1)";if(y())return e.animate([],{duration:0});if(t==="in")return e.animate([{opacity:1,transform:i||"none"},{opacity:0,transform:p(i,0.92),offset:0.7},{opacity:0,transform:p(i,0.92)}],{duration:n,delay:s,easing:o,fill:"forwards"});return e.animate([{opacity:0,transform:p(i,0.92)},{opacity:1,transform:i||"none"}],{duration:n,delay:s,easing:o,fill:"forwards"})},X=(e,t)=>{if(e===t)return!0;return e.matches("[data-pierre-open]")},q=(e)=>{c.length=0;for(let t of document.body.children){if(X(t,e))continue;let n=t;if(g.set(n,{transform:n.style.transform,filter:n.style.filter,transformOrigin:n.style.transformOrigin,willChange:n.style.willChange}),c.push(n),c.length>=12)break}},v=async(e,t,n)=>{if(y()||c.length===0)return;let s=e==="in"?"cubic-bezier(0.34, 1.28, 0.64, 1)":"cubic-bezier(0.4, 0, 0.2, 1)",i="scale(0.97)",o="blur(2px)",l=G();await Promise.all(c.map((d)=>{d.style.transformOrigin="center center",d.style.willChange=l?"transform":"transform, filter";let f=e==="in"?l?[{transform:"scale(1)"},{transform:i}]:[{transform:"scale(1)",filter:"blur(0px)"},{transform:i,filter:o}]:l?[{transform:i},{transform:"scale(1)"}]:[{transform:i,filter:o},{transform:"scale(1)",filter:"blur(0px)"}];return _(d.animate(f,{duration:t,delay:n,easing:s,fill:"forwards"}))}))},O=()=>{for(let e of c)e.style.willChange=""},T=()=>{for(let e of c){let t=g.get(e);if(t)e.style.transform=t.transform,e.style.filter=t.filter,e.style.transformOrigin=t.transformOrigin,e.style.willChange=t.willChange,g.delete(e);else e.style.transform="",e.style.filter="",e.style.transformOrigin="",e.style.willChange=""}c.length=0},K=async(e)=>{let t=I.open;await Promise.all([v("in",t.scrim,0),_(R(e,"in",t.launcher,t.launcherDelay))]),O()},Z=async(e)=>{let t=I.close;await Promise.all([v("out",t.scrim,0),_(R(e,"out",t.launcher,t.launcherDelay))]),O()},z=()=>{if(y())return;if("vibrate"in navigator)navigator.vibrate(5)},j=(e)=>{u.length=0;for(let t of document.body.children){if(t===e)continue;let n={node:t,hadInert:"inert"in t,inertValue:"inert"in t?t.inert:!1,hadAriaHidden:t.hasAttribute("aria-hidden"),ariaHiddenValue:t.getAttribute("aria-hidden")};if(u.push(n),n.hadInert)t.inert=!0;else t.setAttribute("aria-hidden","true")}},Y=()=>{for(let e of u)if(e.hadInert)e.node.inert=e.inertValue;else if(e.hadAriaHidden)if(e.ariaHiddenValue===null)e.node.setAttribute("aria-hidden","");else e.node.setAttribute("aria-hidden",e.ariaHiddenValue);else e.node.removeAttribute("aria-hidden");u.length=0},J=()=>{let e=window.innerWidth-document.documentElement.clientWidth;if(A=document.body.style.paddingRight,B=document.body.style.overflow,C=document.documentElement.style.overscrollBehavior,document.body.style.overflow="hidden",document.documentElement.style.overscrollBehavior="none",e>0)document.body.style.paddingRight=`${e}px`},Q=()=>{document.body.style.overflow=B,document.body.style.paddingRight=A,document.documentElement.style.overscrollBehavior=C},ee=(e,t)=>{let n=h?.dataset.pierreEmbedTarget??"#pierre-embed",s=document.querySelector(n);if(s)return s;let i=encodeURIComponent(window.location.origin),o=document.createElement("iframe");return o.id="pierre-embed",o.title="PIERRE — assistant IA",o.src=`${e.replace(/\/$/,"")}/embed?config=${encodeURIComponent(t)}&host=${i}`,o.setAttribute("sandbox","allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-forms"),o.style.cssText=E(!1),document.body.appendChild(o),o},H=()=>{let{url:e,configuration:t}=U();if(!e){console.warn("[PIERRE] Impossible de déterminer l’URL du serveur (attribut src manquant sur le ",V=V.removeChild(V.firstChild);break;case"select":V=typeof K.is==="string"?V.createElement("select",{is:K.is}):V.createElement("select"),K.multiple?V.multiple=!0:K.size&&(V.size=K.size);break;default:V=typeof K.is==="string"?V.createElement(w,{is:K.is}):V.createElement(w),w.indexOf("-")===-1&&(w!==w.toLowerCase()&&console.error("<%s /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.",w),Object.prototype.toString.call(V)!=="[object HTMLUnknownElement]"||O3.call(SP,w)||(SP[w]=!0,console.error("The tag <%s> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.",w)))}}V[r5]=X,V[W2]=K;H:for(z=X.child;z!==null;){if(z.tag===5||z.tag===6)V.appendChild(z.stateNode);else if(z.tag!==4&&z.tag!==27&&z.child!==null){z.child.return=z,z=z.child;continue}if(z===X)break H;for(;z.sibling===null;){if(z.return===null||z.return===X)break H;z=z.return}z.sibling.return=z.return,z=z.sibling}X.stateNode=V;H:switch(p5(V,w,K),w){case"button":case"input":case"select":case"textarea":K=!!K.autoFocus;break H;case"img":K=!0;break H;default:K=!1}K&&g6(X)}}return p0(X),kK(X,X.type,Z===null?null:Z.memoizedProps,X.pendingProps,J),null;case 6:if(Z&&X.stateNode!=null)Z.memoizedProps!==K&&g6(X);else{if(typeof K!=="string"&&X.stateNode===null)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");if(Z=g1(O9.current),J=O1(),$7(X)){if(Z=X.stateNode,J=X.memoizedProps,w=!Q6,K=null,V=i5,V!==null)switch(V.tag){case 3:w&&(w=aR(Z,J,K),w!==null&&(U4(X,0).serverProps=w));break;case 27:case 5:K=V.memoizedProps,w&&(w=aR(Z,J,K),w!==null&&(U4(X,0).serverProps=w))}Z[r5]=X,Z=Z.nodeValue===J||K!==null&&K.suppressHydrationWarning===!0||yR(Z.nodeValue,J)?!0:!1,Z||Y9(X,!0)}else w=J.ancestorInfo.current,w!=null&&xX(K,w.tag,J.ancestorInfo.implicitRootScope),Z=$q(Z).createTextNode(K),Z[r5]=X,X.stateNode=Z}return p0(X),null;case 31:if(J=X.memoizedState,Z===null||Z.memoizedState!==null){if(K=$7(X),J!==null){if(Z===null){if(!K)throw Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");if(Z=X.memoizedState,Z=Z!==null?Z.dehydrated:null,!Z)throw Error("Expected to have a hydrated activity instance. This error is likely caused by a bug in React. Please file an issue.");Z[r5]=X,p0(X),(X.mode&L0)!==n1&&J!==null&&(Z=X.child,Z!==null&&(X.treeBaseDuration-=Z.treeBaseDuration))}else fY(),B4(),(X.flags&128)===0&&(J=X.memoizedState=null),X.flags|=4,p0(X),(X.mode&L0)!==n1&&J!==null&&(Z=X.child,Z!==null&&(X.treeBaseDuration-=Z.treeBaseDuration));Z=!1}else J=kY(),Z!==null&&Z.memoizedState!==null&&(Z.memoizedState.hydrationErrors=J),Z=!0;if(!Z){if(X.flags&256)return A2(X),X;return A2(X),null}if((X.flags&128)!==0)throw Error("Client rendering an Activity suspended it again. This is a bug in React.")}return p0(X),null;case 13:if(K=X.memoizedState,Z===null||Z.memoizedState!==null&&Z.memoizedState.dehydrated!==null){if(w=K,V=$7(X),w!==null&&w.dehydrated!==null){if(Z===null){if(!V)throw Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");if(V=X.memoizedState,V=V!==null?V.dehydrated:null,!V)throw Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.");V[r5]=X,p0(X),(X.mode&L0)!==n1&&w!==null&&(w=X.child,w!==null&&(X.treeBaseDuration-=w.treeBaseDuration))}else fY(),B4(),(X.flags&128)===0&&(w=X.memoizedState=null),X.flags|=4,p0(X),(X.mode&L0)!==n1&&w!==null&&(w=X.child,w!==null&&(X.treeBaseDuration-=w.treeBaseDuration));w=!1}else w=kY(),Z!==null&&Z.memoizedState!==null&&(Z.memoizedState.hydrationErrors=w),w=!0;if(!w){if(X.flags&256)return A2(X),X;return A2(X),null}}if(A2(X),(X.flags&128)!==0)return X.lanes=J,(X.mode&L0)!==n1&&UH(X),X;return J=K!==null,Z=Z!==null&&Z.memoizedState!==null,J&&(K=X.child,w=null,K.alternate!==null&&K.alternate.memoizedState!==null&&K.alternate.memoizedState.cachePool!==null&&(w=K.alternate.memoizedState.cachePool.pool),V=null,K.memoizedState!==null&&K.memoizedState.cachePool!==null&&(V=K.memoizedState.cachePool.pool),V!==w&&(K.flags|=2048)),J!==Z&&J&&(X.child.flags|=8192),zq(X,X.updateQueue),p0(X),(X.mode&L0)!==n1&&J&&(Z=X.child,Z!==null&&(X.treeBaseDuration-=Z.treeBaseDuration)),null;case 4:return W1(X),Z===null&&qW(X.stateNode.containerInfo),p0(X),null;case 10:return $6(X.type,X),p0(X),null;case 19:if(G1(F5,X),K=X.memoizedState,K===null)return p0(X),null;if(w=(X.flags&128)!==0,V=K.rendering,V===null)if(w)CH(K,!1);else{if(Z5!==l6||Z!==null&&(Z.flags&128)!==0)for(Z=X.child;Z!==null;){if(V=tX(Z),V!==null){X.flags|=128,CH(K,!1),Z=V.updateQueue,X.updateQueue=Z,zq(X,Z),X.subtreeFlags=0,Z=J;for(J=X.child;J!==null;)wB(J,Z),J=J.sibling;return w1(F5,F5.current&W8|VZ,X),P0&&b6(X,K.treeForkCount),X.child}Z=Z.sibling}K.tail!==null&&v5()>PJ&&(X.flags|=128,w=!0,CH(K,!1),X.lanes=4194304)}else{if(!w)if(Z=tX(V),Z!==null){if(X.flags|=128,w=!0,Z=Z.updateQueue,X.updateQueue=Z,zq(X,Z),CH(K,!0),K.tail===null&&K.tailMode==="hidden"&&!V.alternate&&!P0)return p0(X),null}else 2*v5()-K.renderingStartTime>PJ&&J!==536870912&&(X.flags|=128,w=!0,CH(K,!1),X.lanes=4194304);K.isBackwards?(V.sibling=X.child,X.child=V):(Z=K.last,Z!==null?Z.sibling=V:X.child=V,K.last=V)}if(K.tail!==null)return Z=K.tail,K.rendering=Z,K.tail=Z.sibling,K.renderingStartTime=v5(),Z.sibling=null,J=F5.current,J=w?J&W8|VZ:J&W8,w1(F5,J,X),P0&&b6(X,K.treeForkCount),Z;return p0(X),null;case 22:case 23:return A2(X),tY(X),K=X.memoizedState!==null,Z!==null?Z.memoizedState!==null!==K&&(X.flags|=8192):K&&(X.flags|=8192),K?(J&536870912)!==0&&(X.flags&128)===0&&(p0(X),X.subtreeFlags&6&&(X.flags|=8192)):p0(X),J=X.updateQueue,J!==null&&zq(X,J.retryQueue),J=null,Z!==null&&Z.memoizedState!==null&&Z.memoizedState.cachePool!==null&&(J=Z.memoizedState.cachePool.pool),K=null,X.memoizedState!==null&&X.memoizedState.cachePool!==null&&(K=X.memoizedState.cachePool.pool),K!==J&&(X.flags|=2048),Z!==null&&G1(h4,X),null;case 24:return J=null,Z!==null&&(J=Z.memoizedState.cache),X.memoizedState.cache!==J&&(X.flags|=2048),$6(j5,X),p0(X),null;case 25:return null;case 30:return null}throw Error("Unknown unit of work tag ("+X.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function Rh(Z,X){switch(uY(X),X.tag){case 1:return Z=X.flags,Z&65536?(X.flags=Z&-65537|128,(X.mode&L0)!==n1&&UH(X),X):null;case 3:return $6(j5,X),W1(X),Z=X.flags,(Z&65536)!==0&&(Z&128)===0?(X.flags=Z&-65537|128,X):null;case 26:case 27:case 5:return c1(X),null;case 31:if(X.memoizedState!==null){if(A2(X),X.alternate===null)throw Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");B4()}return Z=X.flags,Z&65536?(X.flags=Z&-65537|128,(X.mode&L0)!==n1&&UH(X),X):null;case 13:if(A2(X),Z=X.memoizedState,Z!==null&&Z.dehydrated!==null){if(X.alternate===null)throw Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");B4()}return Z=X.flags,Z&65536?(X.flags=Z&-65537|128,(X.mode&L0)!==n1&&UH(X),X):null;case 19:return G1(F5,X),null;case 4:return W1(X),null;case 10:return $6(X.type,X),null;case 22:case 23:return A2(X),tY(X),Z!==null&&G1(h4,X),Z=X.flags,Z&65536?(X.flags=Z&-65537|128,(X.mode&L0)!==n1&&UH(X),X):null;case 24:return $6(j5,X),null;case 25:return null;default:return null}}function Ez(Z,X){switch(uY(X),X.tag){case 3:$6(j5,X),W1(X);break;case 26:case 27:case 5:c1(X);break;case 4:W1(X);break;case 31:X.memoizedState!==null&&A2(X);break;case 13:A2(X);break;case 19:G1(F5,X);break;case 10:$6(X.type,X);break;case 22:case 23:A2(X),tY(X),Z!==null&&G1(h4,X);break;case 24:$6(j5,X)}}function d3(Z){return(Z.mode&L0)!==n1}function xz(Z,X){d3(Z)?(i3(),bH(X,Z),r3()):bH(X,Z)}function fK(Z,X,J){d3(Z)?(i3(),h7(J,Z,X),r3()):h7(J,Z,X)}function bH(Z,X){try{var J=X.updateQueue,K=J!==null?J.lastEffect:null;if(K!==null){var w=K.next;J=w;do{if((J.tag&Z)===Z&&(K=void 0,(Z&F2)!==WJ&&(j8=!0),K=$1(X,uy,J),(Z&F2)!==WJ&&(j8=!1),K!==void 0&&typeof K!=="function")){var V=void 0;V=(J.tag&i2)!==0?"useLayoutEffect":(J.tag&F2)!==0?"useInsertionEffect":"useEffect";var z=void 0;z=K===null?" You returned null. If your effect does not require clean up, return undefined (or nothing).":typeof K.then==="function"?` - -It looks like you wrote `+V+`(async () => ...) or returned a Promise. Instead, write the async function inside your effect and call it immediately: - -`+V+`(() => { - async function fetchData() { - // You can await here - const response = await MyAPI.getData(someId); - // ... - } - fetchData(); -}, [someId]); // Or [] if effect doesn't need props or state - -Learn more about data fetching with Hooks: https://react.dev/link/hooks-data-fetching`:" You returned: "+K,$1(X,function(N,D){console.error("%s must not return anything besides a function, which is used for clean-up.%s",N,D)},V,z)}J=J.next}while(J!==w)}}catch(N){v0(X,X.return,N)}}function h7(Z,X,J){try{var K=X.updateQueue,w=K!==null?K.lastEffect:null;if(w!==null){var V=w.next;K=V;do{if((K.tag&Z)===Z){var z=K.inst,N=z.destroy;N!==void 0&&(z.destroy=void 0,(Z&F2)!==WJ&&(j8=!0),w=X,$1(w,ky,w,J,N),(Z&F2)!==WJ&&(j8=!1))}K=K.next}while(K!==V)}}catch(D){v0(X,X.return,D)}}function hz(Z,X){d3(Z)?(i3(),bH(X,Z),r3()):bH(X,Z)}function lK(Z,X,J){d3(Z)?(i3(),h7(J,Z,X),r3()):h7(J,Z,X)}function _z(Z){var X=Z.updateQueue;if(X!==null){var J=Z.stateNode;Z.type.defaultProps||"ref"in Z.memoizedProps||F8||(J.props!==Z.memoizedProps&&console.error("Expected %s props to match memoized props before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.",k(Z)||"instance"),J.state!==Z.memoizedState&&console.error("Expected %s state to match memoized state before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.",k(Z)||"instance"));try{$1(Z,IB,X,J)}catch(K){v0(Z,Z.return,K)}}}function jh(Z,X,J){return Z.getSnapshotBeforeUpdate(X,J)}function Oh(Z,X){var{memoizedProps:J,memoizedState:K}=X;X=Z.stateNode,Z.type.defaultProps||"ref"in Z.memoizedProps||F8||(X.props!==Z.memoizedProps&&console.error("Expected %s props to match memoized props before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.",k(Z)||"instance"),X.state!==Z.memoizedState&&console.error("Expected %s state to match memoized state before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.",k(Z)||"instance"));try{var w=N4(Z.type,J),V=$1(Z,jh,X,w,K);J=FP,V!==void 0||J.has(Z.type)||(J.add(Z.type),$1(Z,function(){console.error("%s.getSnapshotBeforeUpdate(): A snapshot value (or null) must be returned. You have returned undefined.",k(Z))})),X.__reactInternalSnapshotBeforeUpdate=V}catch(z){v0(Z,Z.return,z)}}function yz(Z,X,J){J.props=N4(Z.type,Z.memoizedProps),J.state=Z.memoizedState,d3(Z)?(i3(),$1(Z,_O,Z,X,J),r3()):$1(Z,_O,Z,X,J)}function Ph(Z){var X=Z.ref;if(X!==null){switch(Z.tag){case 26:case 27:case 5:var J=Z.stateNode;break;case 30:J=Z.stateNode;break;default:J=Z.stateNode}if(typeof X==="function")if(d3(Z))try{i3(),Z.refCleanup=X(J)}finally{r3()}else Z.refCleanup=X(J);else typeof X==="string"?console.error("String refs are no longer supported."):X.hasOwnProperty("current")||console.error("Unexpected ref object provided for %s. Use either a ref-setter function or React.createRef().",k(Z)),X.current=J}}function $H(Z,X){try{$1(Z,Ph,Z)}catch(J){v0(Z,X,J)}}function a3(Z,X){var{ref:J,refCleanup:K}=Z;if(J!==null)if(typeof K==="function")try{if(d3(Z))try{i3(),$1(Z,K)}finally{r3(Z)}else $1(Z,K)}catch(w){v0(Z,X,w)}finally{Z.refCleanup=null,Z=Z.alternate,Z!=null&&(Z.refCleanup=null)}else if(typeof J==="function")try{if(d3(Z))try{i3(),$1(Z,J,null)}finally{r3(Z)}else $1(Z,J,null)}catch(w){v0(Z,X,w)}else J.current=null}function Iz(Z,X,J,K){var w=Z.memoizedProps,V=w.id,z=w.onCommit;w=w.onRender,X=X===null?"mount":"update",XJ&&(X="nested-update"),typeof w==="function"&&w(V,X,Z.actualDuration,Z.treeBaseDuration,Z.actualStartTime,J),typeof z==="function"&&z(V,X,K,J)}function Nh(Z,X,J,K){var w=Z.memoizedProps;Z=w.id,w=w.onPostCommit,X=X===null?"mount":"update",XJ&&(X="nested-update"),typeof w==="function"&&w(Z,X,K,J)}function vz(Z){var{type:X,memoizedProps:J,stateNode:K}=Z;try{$1(Z,rh,K,X,J,Z)}catch(w){v0(Z,Z.return,w)}}function pK(Z,X,J){try{$1(Z,dh,Z.stateNode,Z.type,J,X,Z)}catch(K){v0(Z,Z.return,K)}}function Sz(Z){return Z.tag===5||Z.tag===3||Z.tag===26||Z.tag===27&&R9(Z.type)||Z.tag===4}function rK(Z){H:for(;;){for(;Z.sibling===null;){if(Z.return===null||Sz(Z.return))return null;Z=Z.return}Z.sibling.return=Z.return;for(Z=Z.sibling;Z.tag!==5&&Z.tag!==6&&Z.tag!==18;){if(Z.tag===27&&R9(Z.type))continue H;if(Z.flags&2)continue H;if(Z.child===null||Z.tag===4)continue H;else Z.child.return=Z,Z=Z.child}if(!(Z.flags&2))return Z.stateNode}}function iK(Z,X,J){var K=Z.tag;if(K===5||K===6)Z=Z.stateNode,X?(lR(J),(J.nodeType===9?J.body:J.nodeName==="HTML"?J.ownerDocument.body:J).insertBefore(Z,X)):(lR(J),X=J.nodeType===9?J.body:J.nodeName==="HTML"?J.ownerDocument.body:J,X.appendChild(Z),J=J._reactRootContainer,J!==null&&J!==void 0||X.onclick!==null||(X.onclick=M6));else if(K!==4&&(K===27&&R9(Z.type)&&(J=Z.stateNode,X=null),Z=Z.child,Z!==null))for(iK(Z,X,J),Z=Z.sibling;Z!==null;)iK(Z,X,J),Z=Z.sibling}function Rq(Z,X,J){var K=Z.tag;if(K===5||K===6)Z=Z.stateNode,X?J.insertBefore(Z,X):J.appendChild(Z);else if(K!==4&&(K===27&&R9(Z.type)&&(J=Z.stateNode),Z=Z.child,Z!==null))for(Rq(Z,X,J),Z=Z.sibling;Z!==null;)Rq(Z,X,J),Z=Z.sibling}function Mh(Z){for(var X,J=Z.return;J!==null;){if(Sz(J)){X=J;break}J=J.return}if(X==null)throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");switch(X.tag){case 27:X=X.stateNode,J=rK(Z),Rq(Z,J,X);break;case 5:J=X.stateNode,X.flags&32&&(fR(J),X.flags&=-33),X=rK(Z),Rq(Z,X,J);break;case 3:case 4:X=X.stateNode.containerInfo,J=rK(Z),iK(Z,J,X);break;default:throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.")}}function Tz(Z){var{stateNode:X,memoizedProps:J}=Z;try{$1(Z,W_,Z.type,J,X,Z)}catch(K){v0(Z,Z.return,K)}}function Az(Z,X){return X.tag===31?(X=X.memoizedState,Z.memoizedState!==null&&X===null):X.tag===13?(Z=Z.memoizedState,X=X.memoizedState,Z!==null&&Z.dehydrated!==null&&(X===null||X.dehydrated===null)):X.tag===3?Z.memoizedState.isDehydrated&&(X.flags&256)===0:!1}function Ch(Z,X){if(Z=Z.containerInfo,rw=TJ,Z=eU(Z),EY(Z)){if("selectionStart"in Z)var J={start:Z.selectionStart,end:Z.selectionEnd};else H:{J=(J=Z.ownerDocument)&&J.defaultView||window;var K=J.getSelection&&J.getSelection();if(K&&K.rangeCount!==0){J=K.anchorNode;var{anchorOffset:w,focusNode:V}=K;K=K.focusOffset;try{J.nodeType,V.nodeType}catch(D1){J=null;break H}var z=0,N=-1,D=-1,g=0,i=0,d=Z,T=null;Z:for(;;){for(var e;;){if(d!==J||w!==0&&d.nodeType!==3||(N=z+w),d!==V||K!==0&&d.nodeType!==3||(D=z+K),d.nodeType===3&&(z+=d.nodeValue.length),(e=d.firstChild)===null)break;T=d,d=e}for(;;){if(d===Z)break Z;if(T===J&&++g===w&&(N=z),T===V&&++i===K&&(D=z),(e=d.nextSibling)!==null)break;d=T,T=d.parentNode}d=e}J=N===-1||D===-1?null:{start:N,end:D}}else J=null}J=J||{start:0,end:0}}else J=null;iw={focusedElem:Z,selectionRange:J},TJ=!1;for(T5=X;T5!==null;)if(X=T5,Z=X.child,(X.subtreeFlags&1028)!==0&&Z!==null)Z.return=X,T5=Z;else for(;T5!==null;){switch(Z=X=T5,J=Z.alternate,w=Z.flags,Z.tag){case 0:if((w&4)!==0&&(Z=Z.updateQueue,Z=Z!==null?Z.events:null,Z!==null))for(J=0;J title"));p5(g,N,z),g[r5]=Z,p1(g),N=g;break H;case"link":var i=Hj("link","href",D).get(N+(z.href||""));if(i){for(var d=0;dK||console.timeStamp("Blocked",ZZ,w,t2,void 0,5>K?"primary-light":10>K?"primary":100>K?"primary-dark":"error"))}}V=(J=!J&&(X&127)===0&&(X&Z.expiredLanes)===0||P6(Z,X))?Gh(Z,X):sK(Z,X,!0);var z=J;do{if(V===l6){z8&&!J&&B9(Z,X,0,!1),X=A0,ZZ=O5(),NO=X;break}else{if(K=v5(),w=Z.current.alternate,z&&!Dh(w)){I2(X),w=S5,V=K,!i0||V<=w||(K5?K5.run(console.timeStamp.bind(console,"Teared Render",w,V,j0,R0,"error")):console.timeStamp("Teared Render",w,V,j0,R0,"error")),C4(X,K),V=sK(Z,X,!1),z=!1;continue}if(V===S4){if(z=X,Z.errorRecoveryDisabledLanes&z)var N=0;else N=Z.pendingLanes&-536870913,N=N!==0?N:N&536870912?536870912:0;if(N!==0){I2(X),_Y(S5,K,X,K5),C4(X,K),X=N;H:{K=Z,V=z,z=NZ;var D=K.current.memoizedState.isDehydrated;if(D&&(v7(K,N).flags|=256),N=sK(K,N,!1),N!==S4){if(Ew&&!D){K.errorRecoveryDisabledLanes|=V,S9|=V,V=y9;break H}K=B2,B2=z,K!==null&&(B2===null?B2=K:B2.push.apply(B2,K))}V=N}if(z=!1,V!==S4)continue;else K=v5()}}if(V===jZ){I2(X),_Y(S5,K,X,K5),C4(X,K),v7(Z,0),B9(Z,X,0,!0);break}H:{switch(J=Z,V){case l6:case jZ:throw Error("Root did not complete. This is a bug in React.");case y9:if((X&4194048)!==X)break;case BJ:I2(X),XB(S5,K,X,K5),C4(X,K),w=X,(w&127)!==0?eq=K:(w&4194048)!==0&&(HJ=K),B9(J,X,E2,!I9);break H;case S4:B2=null;break;case UJ:case BP:break;default:throw Error("Unknown root exit status.")}if(X1.actQueue!==null)nK(J,w,X,B2,MZ,jJ,E2,S9,m4,V,null,null,S5,K);else{if((X&62914560)===X&&(z=OJ+jP-v5(),10w&&(J=w):J=w,0J&&(N=J):N=J,D!==null&&J>N){var T=g?"secondary-light":"warning";K?K.run(console.timeStamp.bind(console,g?"Consecutive":"Event: "+D,N,J,j0,R0,T)):console.timeStamp(g?"Consecutive":"Event: "+D,N,J,j0,R0,T)}w>J&&(N=i?"error":(X&738197653)===X?"tertiary-light":"primary-light",i=d?"Promise Resolved":i?"Cascading Update":5V&&(J=V):J=V,0J&&(w=J):w=J,0w&&(d=w):d=w,w>d&&N!==null&&(T=D?"secondary-light":"warning",K?K.run(console.timeStamp.bind(console,D?"Consecutive":"Event: "+N,d,w,j0,R0,T)):console.timeStamp(D?"Consecutive":"Event: "+N,d,w,j0,R0,T)),J>w&&(K?K.run(console.timeStamp.bind(console,"Action",w,J,j0,R0,"primary-dark")):console.timeStamp("Action",w,J,j0,R0,"primary-dark")),V>J&&(w=g?"Promise Resolved":5r0&&(z=r0,r0=_1,_1=z);var $0=oU(N,_1),S=oU(N,r0);if($0&&S&&(e.rangeCount!==1||e.anchorNode!==$0.node||e.anchorOffset!==$0.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)){var u=d.createRange();u.setStart($0.node,$0.offset),e.removeAllRanges(),_1>r0?(e.addRange(u),e.extend(S.node,S.offset)):(u.setEnd(S.node,S.offset),e.addRange(u))}}}}d=[];for(e=N;e=e.parentNode;)e.nodeType===1&&d.push({element:e,left:e.scrollLeft,top:e.scrollTop});typeof N.focus==="function"&&N.focus();for(N=0;NJ?q6:J;J=X1.T;var w=S0.p;try{S0.p=K,X1.T=null;var V=vw;vw=null,K=m9;var z=$3;if(b5=A9,R8=m9=null,$3=0,(E0&(g5|d2))!==A5)throw Error("Cannot flush passive effects while already rendering.");I2(z),Tw=!0,CJ=!1;var N=0;if(S6=null,N=v5(),D3===PP)wH(v6,N,A6);else{var D=v6,g=N,i=D3===_w;!i0||g<=D||(K5?K5.run(console.timeStamp.bind(console,i?"Waiting for Paint":"Waiting",D,g,j0,R0,"secondary-light")):console.timeStamp(i?"Waiting for Paint":"Waiting",D,g,j0,R0,"secondary-light"))}D=E0,E0|=d2;var d=K.current;rX(),oz(d);var T=K.current;d=Iw,rX(),az(K,T,z,V,d),NR(K),E0=D;var e=v5();if(T=N,d=K5,S6!==null?JB(T,e,S6,!0,d):!i0||e<=T||(d?d.run(console.timeStamp.bind(console,"Remaining Effects",T,e,j0,R0,"secondary-dark")):console.timeStamp("Remaining Effects",T,e,j0,R0,"secondary-dark")),C4(z,e),xH(0,!1),CJ?K===bZ?u4++:(u4=0,bZ=K):u4=0,CJ=Tw=!1,s5&&typeof s5.onPostCommitFiberRoot==="function")try{s5.onPostCommitFiberRoot(l7,K)}catch(_1){Z6||(Z6=!0,console.error("React instrumentation encountered an error: %o",_1))}var D1=K.current.stateNode;return D1.effectDuration=0,D1.passiveEffectDuration=0,!0}finally{S0.p=w,X1.T=J,zR(Z,X)}}function jR(Z,X,J){X=v2(J,X),PB(X),X=EK(Z.stateNode,X,2),Z=L9(Z,X,2),Z!==null&&(y1(Z,2),n3(Z))}function v0(Z,X,J){if(j8=!1,Z.tag===3)jR(Z,Z,J);else{for(;X!==null;){if(X.tag===3){jR(X,Z,J);return}if(X.tag===1){var K=X.stateNode;if(typeof X.type.getDerivedStateFromError==="function"||typeof K.componentDidCatch==="function"&&(T9===null||!T9.has(K))){Z=v2(J,Z),PB(Z),J=xK(2),K=L9(X,J,2),K!==null&&(hK(J,K,X,Z),y1(K,2),n3(K));return}}X=X.return}console.error(`Internal React error: Attempted to capture a commit phase error inside a detached tree. This indicates a bug in React. Potential causes include deleting the same fiber more than once, committing an already-finished tree, or an inconsistent return pointer. - -Error message: - -%s`,J)}}function oK(Z,X,J){var K=Z.pingCache;if(K===null){K=Z.pingCache=new dy;var w=new Set;K.set(X,w)}else w=K.get(X),w===void 0&&(w=new Set,K.set(X,w));w.has(J)||(Ew=!0,w.add(J),K=hh.bind(null,Z,X,J),X6&&EH(Z,J),X.then(K,K))}function hh(Z,X,J){var K=Z.pingCache;K!==null&&K.delete(X),Z.pingedLanes|=Z.suspendedLanes&J,Z.warmLanes&=~J,(J&127)!==0?0>Y6&&(g9=Y6=O5(),tH=oq("Promise Resolved"),E9=tq):(J&4194048)!==0&&0>J3&&(K6=J3=O5(),HZ=oq("Promise Resolved"),ww=tq),HR()&&X1.actQueue===null&&console.error(`A suspended resource finished loading inside a test, but the event was not wrapped in act(...). - -When testing, code that resolves suspended data should be wrapped into act(...): - -act(() => { - /* finish loading suspended data */ -}); -/* assert on the output */ - -This ensures that you're testing the behavior the user would see in the browser. Learn more at https://react.dev/link/wrap-tests-with-act`),f0===Z&&(F0&J)===J&&(Z5===y9||Z5===UJ&&(F0&62914560)===F0&&v5()-OJ { - /* fire events that update state */ -}); -/* assert on the output */ - -This ensures that you're testing the behavior the user would see in the browser. Learn more at https://react.dev/link/wrap-tests-with-act`,k(Z))})}function n3(Z){Z!==O8&&Z.next===null&&(O8===null?$J=O8=Z:O8=O8.next=Z),DJ=!0,X1.actQueue!==null?mw||(mw=!0,DR()):Aw||(Aw=!0,DR())}function xH(Z,X){if(!uw&&DJ){uw=!0;do{var J=!1;for(var K=$J;K!==null;){if(!X)if(Z!==0){var w=K.pendingLanes;if(w===0)var V=0;else{var{suspendedLanes:z,pingedLanes:N}=K;V=(1<<31-K2(42|Z)+1)-1,V&=w&~(z&~N),V=V&201326741?V&201326741|1:V?V|2:0}V!==0&&(J=!0,$R(K,V))}else V=F0,V=O6(K,K===f0?V:0,K.cancelPendingCommit!==null||K.timeoutHandle!==p4),(V&3)===0||P6(K,V)||(J=!0,$R(K,V));K=K.next}}while(J);uw=!1}}function Sh(){gZ=window.event,eK()}function eK(){DJ=mw=Aw=!1;var Z=0;u9!==0&&lh()&&(Z=u9);for(var X=v5(),J=null,K=$J;K!==null;){var w=K.next,V=CR(K,X);if(V===0)K.next=null,J===null?$J=w:J.next=w,w===null&&(O8=J);else if(J=K,Z!==0||(V&3)!==0)DJ=!0;K=w}b5!==A9&&b5!==MJ||xH(Z,!1),u9!==0&&(u9=0)}function CR(Z,X){for(var{suspendedLanes:J,pingedLanes:K,expirationTimes:w}=Z,V=Z.pendingLanes&-62914561;0 or