@descix/frqtl-web 0.7.0-p2 → 0.7.0-p3

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.
@@ -0,0 +1,173 @@
1
+ var _O=Object.defineProperty;var kO=(e,t,n)=>t in e?_O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Z=(e,t,n)=>kO(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function SO(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var d0={exports:{}},Id={},f0={exports:{}},ze={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Yl=Symbol.for("react.element"),EO=Symbol.for("react.portal"),OO=Symbol.for("react.fragment"),CO=Symbol.for("react.strict_mode"),jO=Symbol.for("react.profiler"),RO=Symbol.for("react.provider"),LO=Symbol.for("react.context"),AO=Symbol.for("react.forward_ref"),PO=Symbol.for("react.suspense"),MO=Symbol.for("react.memo"),TO=Symbol.for("react.lazy"),fy=Symbol.iterator;function DO(e){return e===null||typeof e!="object"?null:(e=fy&&e[fy]||e["@@iterator"],typeof e=="function"?e:null)}var h0={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},p0=Object.assign,m0={};function sa(e,t,n){this.props=e,this.context=t,this.refs=m0,this.updater=n||h0}sa.prototype.isReactComponent={};sa.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};sa.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function g0(){}g0.prototype=sa.prototype;function Nm(e,t,n){this.props=e,this.context=t,this.refs=m0,this.updater=n||h0}var zm=Nm.prototype=new g0;zm.constructor=Nm;p0(zm,sa.prototype);zm.isPureReactComponent=!0;var hy=Array.isArray,v0=Object.prototype.hasOwnProperty,Bm={current:null},y0={key:!0,ref:!0,__self:!0,__source:!0};function b0(e,t,n){var r,i={},o=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(o=""+t.key),t)v0.call(t,r)&&!y0.hasOwnProperty(r)&&(i[r]=t[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];i.children=l}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)i[r]===void 0&&(i[r]=a[r]);return{$$typeof:Yl,type:e,key:o,ref:s,props:i,_owner:Bm.current}}function IO(e,t){return{$$typeof:Yl,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Um(e){return typeof e=="object"&&e!==null&&e.$$typeof===Yl}function FO(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var py=/\/+/g;function Uf(e,t){return typeof e=="object"&&e!==null&&e.key!=null?FO(""+e.key):t.toString(36)}function uu(e,t,n,r,i){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(o){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case Yl:case EO:s=!0}}if(s)return s=e,i=i(s),e=r===""?"."+Uf(s,0):r,hy(i)?(n="",e!=null&&(n=e.replace(py,"$&/")+"/"),uu(i,t,n,"",function(c){return c})):i!=null&&(Um(i)&&(i=IO(i,n+(!i.key||s&&s.key===i.key?"":(""+i.key).replace(py,"$&/")+"/")+e)),t.push(i)),1;if(s=0,r=r===""?".":r+":",hy(e))for(var a=0;a<e.length;a++){o=e[a];var l=r+Uf(o,a);s+=uu(o,t,n,l,i)}else if(l=DO(e),typeof l=="function")for(e=l.call(e),a=0;!(o=e.next()).done;)o=o.value,l=r+Uf(o,a++),s+=uu(o,t,n,l,i);else if(o==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return s}function yc(e,t,n){if(e==null)return e;var r=[],i=0;return uu(e,r,"","",function(o){return t.call(n,o,i++)}),r}function NO(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Rn={current:null},du={transition:null},zO={ReactCurrentDispatcher:Rn,ReactCurrentBatchConfig:du,ReactCurrentOwner:Bm};function x0(){throw Error("act(...) is not supported in production builds of React.")}ze.Children={map:yc,forEach:function(e,t,n){yc(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return yc(e,function(){t++}),t},toArray:function(e){return yc(e,function(t){return t})||[]},only:function(e){if(!Um(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ze.Component=sa;ze.Fragment=OO;ze.Profiler=jO;ze.PureComponent=Nm;ze.StrictMode=CO;ze.Suspense=PO;ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zO;ze.act=x0;ze.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=p0({},e.props),i=e.key,o=e.ref,s=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,s=Bm.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(l in t)v0.call(t,l)&&!y0.hasOwnProperty(l)&&(r[l]=t[l]===void 0&&a!==void 0?a[l]:t[l])}var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];r.children=a}return{$$typeof:Yl,type:e.type,key:i,ref:o,props:r,_owner:s}};ze.createContext=function(e){return e={$$typeof:LO,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:RO,_context:e},e.Consumer=e};ze.createElement=b0;ze.createFactory=function(e){var t=b0.bind(null,e);return t.type=e,t};ze.createRef=function(){return{current:null}};ze.forwardRef=function(e){return{$$typeof:AO,render:e}};ze.isValidElement=Um;ze.lazy=function(e){return{$$typeof:TO,_payload:{_status:-1,_result:e},_init:NO}};ze.memo=function(e,t){return{$$typeof:MO,type:e,compare:t===void 0?null:t}};ze.startTransition=function(e){var t=du.transition;du.transition={};try{e()}finally{du.transition=t}};ze.unstable_act=x0;ze.useCallback=function(e,t){return Rn.current.useCallback(e,t)};ze.useContext=function(e){return Rn.current.useContext(e)};ze.useDebugValue=function(){};ze.useDeferredValue=function(e){return Rn.current.useDeferredValue(e)};ze.useEffect=function(e,t){return Rn.current.useEffect(e,t)};ze.useId=function(){return Rn.current.useId()};ze.useImperativeHandle=function(e,t,n){return Rn.current.useImperativeHandle(e,t,n)};ze.useInsertionEffect=function(e,t){return Rn.current.useInsertionEffect(e,t)};ze.useLayoutEffect=function(e,t){return Rn.current.useLayoutEffect(e,t)};ze.useMemo=function(e,t){return Rn.current.useMemo(e,t)};ze.useReducer=function(e,t,n){return Rn.current.useReducer(e,t,n)};ze.useRef=function(e){return Rn.current.useRef(e)};ze.useState=function(e){return Rn.current.useState(e)};ze.useSyncExternalStore=function(e,t,n){return Rn.current.useSyncExternalStore(e,t,n)};ze.useTransition=function(){return Rn.current.useTransition()};ze.version="18.3.1";f0.exports=ze;var j=f0.exports;const Ze=SO(j);/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var BO=j,UO=Symbol.for("react.element"),HO=Symbol.for("react.fragment"),WO=Object.prototype.hasOwnProperty,VO=BO.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,qO={key:!0,ref:!0,__self:!0,__source:!0};function w0(e,t,n){var r,i={},o=null,s=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(s=t.ref);for(r in t)WO.call(t,r)&&!qO.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:UO,type:e,key:o,ref:s,props:i,_owner:VO.current}}Id.Fragment=HO;Id.jsx=w0;Id.jsxs=w0;d0.exports=Id;var v=d0.exports,_0={exports:{}},nr={},k0={exports:{}},S0={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */(function(e){function t(B,ee){var ce=B.length;B.push(ee);e:for(;0<ce;){var ve=ce-1>>>1,ke=B[ve];if(0<i(ke,ee))B[ve]=ee,B[ce]=ke,ce=ve;else break e}}function n(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var ee=B[0],ce=B.pop();if(ce!==ee){B[0]=ce;e:for(var ve=0,ke=B.length,je=ke>>>1;ve<je;){var ie=2*(ve+1)-1,me=B[ie],xe=ie+1,ge=B[xe];if(0>i(me,ce))xe<ke&&0>i(ge,me)?(B[ve]=ge,B[xe]=ce,ve=xe):(B[ve]=me,B[ie]=ce,ve=ie);else if(xe<ke&&0>i(ge,ce))B[ve]=ge,B[xe]=ce,ve=xe;else break e}}return ee}function i(B,ee){var ce=B.sortIndex-ee.sortIndex;return ce!==0?ce:B.id-ee.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var s=Date,a=s.now();e.unstable_now=function(){return s.now()-a}}var l=[],c=[],u=1,d=null,f=3,h=!1,g=!1,m=!1,x=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(B){for(var ee=n(c);ee!==null;){if(ee.callback===null)r(c);else if(ee.startTime<=B)r(c),ee.sortIndex=ee.expirationTime,t(l,ee);else break;ee=n(c)}}function E(B){if(m=!1,w(B),!g)if(n(l)!==null)g=!0,re(C);else{var ee=n(c);ee!==null&&pe(E,ee.startTime-B)}}function C(B,ee){g=!1,m&&(m=!1,y(L),L=-1),h=!0;var ce=f;try{for(w(ee),d=n(l);d!==null&&(!(d.expirationTime>ee)||B&&!G());){var ve=d.callback;if(typeof ve=="function"){d.callback=null,f=d.priorityLevel;var ke=ve(d.expirationTime<=ee);ee=e.unstable_now(),typeof ke=="function"?d.callback=ke:d===n(l)&&r(l),w(ee)}else r(l);d=n(l)}if(d!==null)var je=!0;else{var ie=n(c);ie!==null&&pe(E,ie.startTime-ee),je=!1}return je}finally{d=null,f=ce,h=!1}}var S=!1,M=null,L=-1,T=5,V=-1;function G(){return!(e.unstable_now()-V<T)}function F(){if(M!==null){var B=e.unstable_now();V=B;var ee=!0;try{ee=M(!0,B)}finally{ee?te():(S=!1,M=null)}}else S=!1}var te;if(typeof b=="function")te=function(){b(F)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,Y=W.port2;W.port1.onmessage=F,te=function(){Y.postMessage(null)}}else te=function(){x(F,0)};function re(B){M=B,S||(S=!0,te())}function pe(B,ee){L=x(function(){B(e.unstable_now())},ee)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_continueExecution=function(){g||h||(g=!0,re(C))},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(l)},e.unstable_next=function(B){switch(f){case 1:case 2:case 3:var ee=3;break;default:ee=f}var ce=f;f=ee;try{return B()}finally{f=ce}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(B,ee){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var ce=f;f=B;try{return ee()}finally{f=ce}},e.unstable_scheduleCallback=function(B,ee,ce){var ve=e.unstable_now();switch(typeof ce=="object"&&ce!==null?(ce=ce.delay,ce=typeof ce=="number"&&0<ce?ve+ce:ve):ce=ve,B){case 1:var ke=-1;break;case 2:ke=250;break;case 5:ke=1073741823;break;case 4:ke=1e4;break;default:ke=5e3}return ke=ce+ke,B={id:u++,callback:ee,priorityLevel:B,startTime:ce,expirationTime:ke,sortIndex:-1},ce>ve?(B.sortIndex=ce,t(c,B),n(l)===null&&B===n(c)&&(m?(y(L),L=-1):m=!0,pe(E,ce-ve))):(B.sortIndex=ke,t(l,B),g||h||(g=!0,re(C))),B},e.unstable_shouldYield=G,e.unstable_wrapCallback=function(B){var ee=f;return function(){var ce=f;f=ee;try{return B.apply(this,arguments)}finally{f=ce}}}})(S0);k0.exports=S0;var $O=k0.exports;/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var KO=j,tr=$O;function q(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var E0=new Set,ml={};function Qo(e,t){$s(e,t),$s(e+"Capture",t)}function $s(e,t){for(ml[e]=t,e=0;e<t.length;e++)E0.add(t[e])}var pi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Zh=Object.prototype.hasOwnProperty,YO=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,my={},gy={};function GO(e){return Zh.call(gy,e)?!0:Zh.call(my,e)?!1:YO.test(e)?gy[e]=!0:(my[e]=!0,!1)}function JO(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function XO(e,t,n,r){if(t===null||typeof t>"u"||JO(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ln(e,t,n,r,i,o,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=s}var sn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){sn[e]=new Ln(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];sn[t]=new Ln(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){sn[e]=new Ln(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){sn[e]=new Ln(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){sn[e]=new Ln(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){sn[e]=new Ln(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){sn[e]=new Ln(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){sn[e]=new Ln(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){sn[e]=new Ln(e,5,!1,e.toLowerCase(),null,!1,!1)});var Hm=/[\-:]([a-z])/g;function Wm(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Hm,Wm);sn[t]=new Ln(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Hm,Wm);sn[t]=new Ln(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Hm,Wm);sn[t]=new Ln(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){sn[e]=new Ln(e,1,!1,e.toLowerCase(),null,!1,!1)});sn.xlinkHref=new Ln("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){sn[e]=new Ln(e,1,!1,e.toLowerCase(),null,!0,!0)});function Vm(e,t,n,r){var i=sn.hasOwnProperty(t)?sn[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(XO(t,n,i,r)&&(n=null),r||i===null?GO(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var xi=KO.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,bc=Symbol.for("react.element"),ys=Symbol.for("react.portal"),bs=Symbol.for("react.fragment"),qm=Symbol.for("react.strict_mode"),ep=Symbol.for("react.profiler"),O0=Symbol.for("react.provider"),C0=Symbol.for("react.context"),$m=Symbol.for("react.forward_ref"),tp=Symbol.for("react.suspense"),np=Symbol.for("react.suspense_list"),Km=Symbol.for("react.memo"),Ci=Symbol.for("react.lazy"),j0=Symbol.for("react.offscreen"),vy=Symbol.iterator;function ga(e){return e===null||typeof e!="object"?null:(e=vy&&e[vy]||e["@@iterator"],typeof e=="function"?e:null)}var Lt=Object.assign,Hf;function Da(e){if(Hf===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Hf=t&&t[1]||""}return`
34
+ `+Hf+e}var Wf=!1;function Vf(e,t){if(!e||Wf)return"";Wf=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(c){var r=c}Reflect.construct(e,[],t)}else{try{t.call()}catch(c){r=c}e.call(t.prototype)}else{try{throw Error()}catch(c){r=c}e()}}catch(c){if(c&&r&&typeof c.stack=="string"){for(var i=c.stack.split(`
35
+ `),o=r.stack.split(`
36
+ `),s=i.length-1,a=o.length-1;1<=s&&0<=a&&i[s]!==o[a];)a--;for(;1<=s&&0<=a;s--,a--)if(i[s]!==o[a]){if(s!==1||a!==1)do if(s--,a--,0>a||i[s]!==o[a]){var l=`
37
+ `+i[s].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}while(1<=s&&0<=a);break}}}finally{Wf=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Da(e):""}function QO(e){switch(e.tag){case 5:return Da(e.type);case 16:return Da("Lazy");case 13:return Da("Suspense");case 19:return Da("SuspenseList");case 0:case 2:case 15:return e=Vf(e.type,!1),e;case 11:return e=Vf(e.type.render,!1),e;case 1:return e=Vf(e.type,!0),e;default:return""}}function rp(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case bs:return"Fragment";case ys:return"Portal";case ep:return"Profiler";case qm:return"StrictMode";case tp:return"Suspense";case np:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case C0:return(e.displayName||"Context")+".Consumer";case O0:return(e._context.displayName||"Context")+".Provider";case $m:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Km:return t=e.displayName||null,t!==null?t:rp(e.type)||"Memo";case Ci:t=e._payload,e=e._init;try{return rp(e(t))}catch{}}return null}function ZO(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return rp(t);case 8:return t===qm?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Xi(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function R0(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function eC(e){var t=R0(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function xc(e){e._valueTracker||(e._valueTracker=eC(e))}function L0(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=R0(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Nu(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function ip(e,t){var n=t.checked;return Lt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function yy(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Xi(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function A0(e,t){t=t.checked,t!=null&&Vm(e,"checked",t,!1)}function op(e,t){A0(e,t);var n=Xi(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?sp(e,t.type,n):t.hasOwnProperty("defaultValue")&&sp(e,t.type,Xi(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function by(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function sp(e,t,n){(t!=="number"||Nu(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ia=Array.isArray;function Is(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+Xi(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function ap(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(q(91));return Lt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function xy(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(q(92));if(Ia(n)){if(1<n.length)throw Error(q(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Xi(n)}}function P0(e,t){var n=Xi(t.value),r=Xi(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function wy(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function M0(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function lp(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?M0(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var wc,T0=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(wc=wc||document.createElement("div"),wc.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=wc.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function gl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ja={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},tC=["Webkit","ms","Moz","O"];Object.keys(Ja).forEach(function(e){tC.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ja[t]=Ja[e]})});function D0(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ja.hasOwnProperty(e)&&Ja[e]?(""+t).trim():t+"px"}function I0(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=D0(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var nC=Lt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function cp(e,t){if(t){if(nC[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(q(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(q(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(q(61))}if(t.style!=null&&typeof t.style!="object")throw Error(q(62))}}function up(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var dp=null;function Ym(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var fp=null,Fs=null,Ns=null;function _y(e){if(e=Xl(e)){if(typeof fp!="function")throw Error(q(280));var t=e.stateNode;t&&(t=Ud(t),fp(e.stateNode,e.type,t))}}function F0(e){Fs?Ns?Ns.push(e):Ns=[e]:Fs=e}function N0(){if(Fs){var e=Fs,t=Ns;if(Ns=Fs=null,_y(e),t)for(e=0;e<t.length;e++)_y(t[e])}}function z0(e,t){return e(t)}function B0(){}var qf=!1;function U0(e,t,n){if(qf)return e(t,n);qf=!0;try{return z0(e,t,n)}finally{qf=!1,(Fs!==null||Ns!==null)&&(B0(),N0())}}function vl(e,t){var n=e.stateNode;if(n===null)return null;var r=Ud(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(q(231,t,typeof n));return n}var hp=!1;if(pi)try{var va={};Object.defineProperty(va,"passive",{get:function(){hp=!0}}),window.addEventListener("test",va,va),window.removeEventListener("test",va,va)}catch{hp=!1}function rC(e,t,n,r,i,o,s,a,l){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(u){this.onError(u)}}var Xa=!1,zu=null,Bu=!1,pp=null,iC={onError:function(e){Xa=!0,zu=e}};function oC(e,t,n,r,i,o,s,a,l){Xa=!1,zu=null,rC.apply(iC,arguments)}function sC(e,t,n,r,i,o,s,a,l){if(oC.apply(this,arguments),Xa){if(Xa){var c=zu;Xa=!1,zu=null}else throw Error(q(198));Bu||(Bu=!0,pp=c)}}function Zo(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function H0(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function ky(e){if(Zo(e)!==e)throw Error(q(188))}function aC(e){var t=e.alternate;if(!t){if(t=Zo(e),t===null)throw Error(q(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return ky(i),e;if(o===r)return ky(i),t;o=o.sibling}throw Error(q(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,a=i.child;a;){if(a===n){s=!0,n=i,r=o;break}if(a===r){s=!0,r=i,n=o;break}a=a.sibling}if(!s){for(a=o.child;a;){if(a===n){s=!0,n=o,r=i;break}if(a===r){s=!0,r=o,n=i;break}a=a.sibling}if(!s)throw Error(q(189))}}if(n.alternate!==r)throw Error(q(190))}if(n.tag!==3)throw Error(q(188));return n.stateNode.current===n?e:t}function W0(e){return e=aC(e),e!==null?V0(e):null}function V0(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=V0(e);if(t!==null)return t;e=e.sibling}return null}var q0=tr.unstable_scheduleCallback,Sy=tr.unstable_cancelCallback,lC=tr.unstable_shouldYield,cC=tr.unstable_requestPaint,zt=tr.unstable_now,uC=tr.unstable_getCurrentPriorityLevel,Gm=tr.unstable_ImmediatePriority,$0=tr.unstable_UserBlockingPriority,Uu=tr.unstable_NormalPriority,dC=tr.unstable_LowPriority,K0=tr.unstable_IdlePriority,Fd=null,Hr=null;function fC(e){if(Hr&&typeof Hr.onCommitFiberRoot=="function")try{Hr.onCommitFiberRoot(Fd,e,void 0,(e.current.flags&128)===128)}catch{}}var Or=Math.clz32?Math.clz32:mC,hC=Math.log,pC=Math.LN2;function mC(e){return e>>>=0,e===0?32:31-(hC(e)/pC|0)|0}var _c=64,kc=4194304;function Fa(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Hu(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,s=n&268435455;if(s!==0){var a=s&~i;a!==0?r=Fa(a):(o&=s,o!==0&&(r=Fa(o)))}else s=n&~i,s!==0?r=Fa(s):o!==0&&(r=Fa(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Or(t),i=1<<n,r|=e[n],t&=~i;return r}function gC(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function vC(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes;0<o;){var s=31-Or(o),a=1<<s,l=i[s];l===-1?(!(a&n)||a&r)&&(i[s]=gC(a,t)):l<=t&&(e.expiredLanes|=a),o&=~a}}function mp(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Y0(){var e=_c;return _c<<=1,!(_c&4194240)&&(_c=64),e}function $f(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Gl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Or(t),e[t]=n}function yC(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-Or(n),o=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~o}}function Jm(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Or(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var nt=0;function G0(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var J0,Xm,X0,Q0,Z0,gp=!1,Sc=[],Ui=null,Hi=null,Wi=null,yl=new Map,bl=new Map,Ri=[],bC="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Ey(e,t){switch(e){case"focusin":case"focusout":Ui=null;break;case"dragenter":case"dragleave":Hi=null;break;case"mouseover":case"mouseout":Wi=null;break;case"pointerover":case"pointerout":yl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":bl.delete(t.pointerId)}}function ya(e,t,n,r,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[i]},t!==null&&(t=Xl(t),t!==null&&Xm(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function xC(e,t,n,r,i){switch(t){case"focusin":return Ui=ya(Ui,e,t,n,r,i),!0;case"dragenter":return Hi=ya(Hi,e,t,n,r,i),!0;case"mouseover":return Wi=ya(Wi,e,t,n,r,i),!0;case"pointerover":var o=i.pointerId;return yl.set(o,ya(yl.get(o)||null,e,t,n,r,i)),!0;case"gotpointercapture":return o=i.pointerId,bl.set(o,ya(bl.get(o)||null,e,t,n,r,i)),!0}return!1}function e_(e){var t=Co(e.target);if(t!==null){var n=Zo(t);if(n!==null){if(t=n.tag,t===13){if(t=H0(n),t!==null){e.blockedOn=t,Z0(e.priority,function(){X0(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function fu(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=vp(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);dp=r,n.target.dispatchEvent(r),dp=null}else return t=Xl(n),t!==null&&Xm(t),e.blockedOn=n,!1;t.shift()}return!0}function Oy(e,t,n){fu(e)&&n.delete(t)}function wC(){gp=!1,Ui!==null&&fu(Ui)&&(Ui=null),Hi!==null&&fu(Hi)&&(Hi=null),Wi!==null&&fu(Wi)&&(Wi=null),yl.forEach(Oy),bl.forEach(Oy)}function ba(e,t){e.blockedOn===t&&(e.blockedOn=null,gp||(gp=!0,tr.unstable_scheduleCallback(tr.unstable_NormalPriority,wC)))}function xl(e){function t(i){return ba(i,e)}if(0<Sc.length){ba(Sc[0],e);for(var n=1;n<Sc.length;n++){var r=Sc[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Ui!==null&&ba(Ui,e),Hi!==null&&ba(Hi,e),Wi!==null&&ba(Wi,e),yl.forEach(t),bl.forEach(t),n=0;n<Ri.length;n++)r=Ri[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Ri.length&&(n=Ri[0],n.blockedOn===null);)e_(n),n.blockedOn===null&&Ri.shift()}var zs=xi.ReactCurrentBatchConfig,Wu=!0;function _C(e,t,n,r){var i=nt,o=zs.transition;zs.transition=null;try{nt=1,Qm(e,t,n,r)}finally{nt=i,zs.transition=o}}function kC(e,t,n,r){var i=nt,o=zs.transition;zs.transition=null;try{nt=4,Qm(e,t,n,r)}finally{nt=i,zs.transition=o}}function Qm(e,t,n,r){if(Wu){var i=vp(e,t,n,r);if(i===null)nh(e,t,r,Vu,n),Ey(e,r);else if(xC(i,e,t,n,r))r.stopPropagation();else if(Ey(e,r),t&4&&-1<bC.indexOf(e)){for(;i!==null;){var o=Xl(i);if(o!==null&&J0(o),o=vp(e,t,n,r),o===null&&nh(e,t,r,Vu,n),o===i)break;i=o}i!==null&&r.stopPropagation()}else nh(e,t,r,null,n)}}var Vu=null;function vp(e,t,n,r){if(Vu=null,e=Ym(r),e=Co(e),e!==null)if(t=Zo(e),t===null)e=null;else if(n=t.tag,n===13){if(e=H0(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Vu=e,null}function t_(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(uC()){case Gm:return 1;case $0:return 4;case Uu:case dC:return 16;case K0:return 536870912;default:return 16}default:return 16}}var Pi=null,Zm=null,hu=null;function n_(){if(hu)return hu;var e,t=Zm,n=t.length,r,i="value"in Pi?Pi.value:Pi.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var s=n-e;for(r=1;r<=s&&t[n-r]===i[o-r];r++);return hu=i.slice(e,1<r?1-r:void 0)}function pu(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Ec(){return!0}function Cy(){return!1}function rr(e){function t(n,r,i,o,s){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=o,this.target=s,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(o):o[a]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Ec:Cy,this.isPropagationStopped=Cy,this}return Lt(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Ec)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Ec)},persist:function(){},isPersistent:Ec}),t}var aa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},eg=rr(aa),Jl=Lt({},aa,{view:0,detail:0}),SC=rr(Jl),Kf,Yf,xa,Nd=Lt({},Jl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:tg,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==xa&&(xa&&e.type==="mousemove"?(Kf=e.screenX-xa.screenX,Yf=e.screenY-xa.screenY):Yf=Kf=0,xa=e),Kf)},movementY:function(e){return"movementY"in e?e.movementY:Yf}}),jy=rr(Nd),EC=Lt({},Nd,{dataTransfer:0}),OC=rr(EC),CC=Lt({},Jl,{relatedTarget:0}),Gf=rr(CC),jC=Lt({},aa,{animationName:0,elapsedTime:0,pseudoElement:0}),RC=rr(jC),LC=Lt({},aa,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),AC=rr(LC),PC=Lt({},aa,{data:0}),Ry=rr(PC),MC={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},TC={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},DC={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function IC(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=DC[e])?!!t[e]:!1}function tg(){return IC}var FC=Lt({},Jl,{key:function(e){if(e.key){var t=MC[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=pu(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?TC[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:tg,charCode:function(e){return e.type==="keypress"?pu(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?pu(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),NC=rr(FC),zC=Lt({},Nd,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ly=rr(zC),BC=Lt({},Jl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:tg}),UC=rr(BC),HC=Lt({},aa,{propertyName:0,elapsedTime:0,pseudoElement:0}),WC=rr(HC),VC=Lt({},Nd,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),qC=rr(VC),$C=[9,13,27,32],ng=pi&&"CompositionEvent"in window,Qa=null;pi&&"documentMode"in document&&(Qa=document.documentMode);var KC=pi&&"TextEvent"in window&&!Qa,r_=pi&&(!ng||Qa&&8<Qa&&11>=Qa),Ay=" ",Py=!1;function i_(e,t){switch(e){case"keyup":return $C.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function o_(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var xs=!1;function YC(e,t){switch(e){case"compositionend":return o_(t);case"keypress":return t.which!==32?null:(Py=!0,Ay);case"textInput":return e=t.data,e===Ay&&Py?null:e;default:return null}}function GC(e,t){if(xs)return e==="compositionend"||!ng&&i_(e,t)?(e=n_(),hu=Zm=Pi=null,xs=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return r_&&t.locale!=="ko"?null:t.data;default:return null}}var JC={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function My(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!JC[e.type]:t==="textarea"}function s_(e,t,n,r){F0(r),t=qu(t,"onChange"),0<t.length&&(n=new eg("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Za=null,wl=null;function XC(e){v_(e,0)}function zd(e){var t=ks(e);if(L0(t))return e}function QC(e,t){if(e==="change")return t}var a_=!1;if(pi){var Jf;if(pi){var Xf="oninput"in document;if(!Xf){var Ty=document.createElement("div");Ty.setAttribute("oninput","return;"),Xf=typeof Ty.oninput=="function"}Jf=Xf}else Jf=!1;a_=Jf&&(!document.documentMode||9<document.documentMode)}function Dy(){Za&&(Za.detachEvent("onpropertychange",l_),wl=Za=null)}function l_(e){if(e.propertyName==="value"&&zd(wl)){var t=[];s_(t,wl,e,Ym(e)),U0(XC,t)}}function ZC(e,t,n){e==="focusin"?(Dy(),Za=t,wl=n,Za.attachEvent("onpropertychange",l_)):e==="focusout"&&Dy()}function ej(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return zd(wl)}function tj(e,t){if(e==="click")return zd(t)}function nj(e,t){if(e==="input"||e==="change")return zd(t)}function rj(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Lr=typeof Object.is=="function"?Object.is:rj;function _l(e,t){if(Lr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Zh.call(t,i)||!Lr(e[i],t[i]))return!1}return!0}function Iy(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Fy(e,t){var n=Iy(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Iy(n)}}function c_(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?c_(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function u_(){for(var e=window,t=Nu();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Nu(e.document)}return t}function rg(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function ij(e){var t=u_(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&c_(n.ownerDocument.documentElement,n)){if(r!==null&&rg(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!e.extend&&o>r&&(i=r,r=o,o=i),i=Fy(n,o);var s=Fy(n,r);i&&s&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var oj=pi&&"documentMode"in document&&11>=document.documentMode,ws=null,yp=null,el=null,bp=!1;function Ny(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;bp||ws==null||ws!==Nu(r)||(r=ws,"selectionStart"in r&&rg(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),el&&_l(el,r)||(el=r,r=qu(yp,"onSelect"),0<r.length&&(t=new eg("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ws)))}function Oc(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var _s={animationend:Oc("Animation","AnimationEnd"),animationiteration:Oc("Animation","AnimationIteration"),animationstart:Oc("Animation","AnimationStart"),transitionend:Oc("Transition","TransitionEnd")},Qf={},d_={};pi&&(d_=document.createElement("div").style,"AnimationEvent"in window||(delete _s.animationend.animation,delete _s.animationiteration.animation,delete _s.animationstart.animation),"TransitionEvent"in window||delete _s.transitionend.transition);function Bd(e){if(Qf[e])return Qf[e];if(!_s[e])return e;var t=_s[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in d_)return Qf[e]=t[n];return e}var f_=Bd("animationend"),h_=Bd("animationiteration"),p_=Bd("animationstart"),m_=Bd("transitionend"),g_=new Map,zy="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function io(e,t){g_.set(e,t),Qo(t,[e])}for(var Zf=0;Zf<zy.length;Zf++){var eh=zy[Zf],sj=eh.toLowerCase(),aj=eh[0].toUpperCase()+eh.slice(1);io(sj,"on"+aj)}io(f_,"onAnimationEnd");io(h_,"onAnimationIteration");io(p_,"onAnimationStart");io("dblclick","onDoubleClick");io("focusin","onFocus");io("focusout","onBlur");io(m_,"onTransitionEnd");$s("onMouseEnter",["mouseout","mouseover"]);$s("onMouseLeave",["mouseout","mouseover"]);$s("onPointerEnter",["pointerout","pointerover"]);$s("onPointerLeave",["pointerout","pointerover"]);Qo("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Qo("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Qo("onBeforeInput",["compositionend","keypress","textInput","paste"]);Qo("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Qo("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Qo("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Na="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),lj=new Set("cancel close invalid load scroll toggle".split(" ").concat(Na));function By(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,sC(r,t,void 0,e),e.currentTarget=null}function v_(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var s=r.length-1;0<=s;s--){var a=r[s],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==o&&i.isPropagationStopped())break e;By(i,a,c),o=l}else for(s=0;s<r.length;s++){if(a=r[s],l=a.instance,c=a.currentTarget,a=a.listener,l!==o&&i.isPropagationStopped())break e;By(i,a,c),o=l}}}if(Bu)throw e=pp,Bu=!1,pp=null,e}function gt(e,t){var n=t[Sp];n===void 0&&(n=t[Sp]=new Set);var r=e+"__bubble";n.has(r)||(y_(t,e,2,!1),n.add(r))}function th(e,t,n){var r=0;t&&(r|=4),y_(n,e,r,t)}var Cc="_reactListening"+Math.random().toString(36).slice(2);function kl(e){if(!e[Cc]){e[Cc]=!0,E0.forEach(function(n){n!=="selectionchange"&&(lj.has(n)||th(n,!1,e),th(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Cc]||(t[Cc]=!0,th("selectionchange",!1,t))}}function y_(e,t,n,r){switch(t_(t)){case 1:var i=_C;break;case 4:i=kC;break;default:i=Qm}n=i.bind(null,t,n,e),i=void 0,!hp||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function nh(e,t,n,r,i){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var a=r.stateNode.containerInfo;if(a===i||a.nodeType===8&&a.parentNode===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&(l=s.stateNode.containerInfo,l===i||l.nodeType===8&&l.parentNode===i))return;s=s.return}for(;a!==null;){if(s=Co(a),s===null)return;if(l=s.tag,l===5||l===6){r=o=s;continue e}a=a.parentNode}}r=r.return}U0(function(){var c=o,u=Ym(n),d=[];e:{var f=g_.get(e);if(f!==void 0){var h=eg,g=e;switch(e){case"keypress":if(pu(n)===0)break e;case"keydown":case"keyup":h=NC;break;case"focusin":g="focus",h=Gf;break;case"focusout":g="blur",h=Gf;break;case"beforeblur":case"afterblur":h=Gf;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=jy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=OC;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=UC;break;case f_:case h_:case p_:h=RC;break;case m_:h=WC;break;case"scroll":h=SC;break;case"wheel":h=qC;break;case"copy":case"cut":case"paste":h=AC;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=Ly}var m=(t&4)!==0,x=!m&&e==="scroll",y=m?f!==null?f+"Capture":null:f;m=[];for(var b=c,w;b!==null;){w=b;var E=w.stateNode;if(w.tag===5&&E!==null&&(w=E,y!==null&&(E=vl(b,y),E!=null&&m.push(Sl(b,E,w)))),x)break;b=b.return}0<m.length&&(f=new h(f,g,null,n,u),d.push({event:f,listeners:m}))}}if(!(t&7)){e:{if(f=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",f&&n!==dp&&(g=n.relatedTarget||n.fromElement)&&(Co(g)||g[mi]))break e;if((h||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,h?(g=n.relatedTarget||n.toElement,h=c,g=g?Co(g):null,g!==null&&(x=Zo(g),g!==x||g.tag!==5&&g.tag!==6)&&(g=null)):(h=null,g=c),h!==g)){if(m=jy,E="onMouseLeave",y="onMouseEnter",b="mouse",(e==="pointerout"||e==="pointerover")&&(m=Ly,E="onPointerLeave",y="onPointerEnter",b="pointer"),x=h==null?f:ks(h),w=g==null?f:ks(g),f=new m(E,b+"leave",h,n,u),f.target=x,f.relatedTarget=w,E=null,Co(u)===c&&(m=new m(y,b+"enter",g,n,u),m.target=w,m.relatedTarget=x,E=m),x=E,h&&g)t:{for(m=h,y=g,b=0,w=m;w;w=cs(w))b++;for(w=0,E=y;E;E=cs(E))w++;for(;0<b-w;)m=cs(m),b--;for(;0<w-b;)y=cs(y),w--;for(;b--;){if(m===y||y!==null&&m===y.alternate)break t;m=cs(m),y=cs(y)}m=null}else m=null;h!==null&&Uy(d,f,h,m,!1),g!==null&&x!==null&&Uy(d,x,g,m,!0)}}e:{if(f=c?ks(c):window,h=f.nodeName&&f.nodeName.toLowerCase(),h==="select"||h==="input"&&f.type==="file")var C=QC;else if(My(f))if(a_)C=nj;else{C=ej;var S=ZC}else(h=f.nodeName)&&h.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(C=tj);if(C&&(C=C(e,c))){s_(d,C,n,u);break e}S&&S(e,f,c),e==="focusout"&&(S=f._wrapperState)&&S.controlled&&f.type==="number"&&sp(f,"number",f.value)}switch(S=c?ks(c):window,e){case"focusin":(My(S)||S.contentEditable==="true")&&(ws=S,yp=c,el=null);break;case"focusout":el=yp=ws=null;break;case"mousedown":bp=!0;break;case"contextmenu":case"mouseup":case"dragend":bp=!1,Ny(d,n,u);break;case"selectionchange":if(oj)break;case"keydown":case"keyup":Ny(d,n,u)}var M;if(ng)e:{switch(e){case"compositionstart":var L="onCompositionStart";break e;case"compositionend":L="onCompositionEnd";break e;case"compositionupdate":L="onCompositionUpdate";break e}L=void 0}else xs?i_(e,n)&&(L="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(L="onCompositionStart");L&&(r_&&n.locale!=="ko"&&(xs||L!=="onCompositionStart"?L==="onCompositionEnd"&&xs&&(M=n_()):(Pi=u,Zm="value"in Pi?Pi.value:Pi.textContent,xs=!0)),S=qu(c,L),0<S.length&&(L=new Ry(L,e,null,n,u),d.push({event:L,listeners:S}),M?L.data=M:(M=o_(n),M!==null&&(L.data=M)))),(M=KC?YC(e,n):GC(e,n))&&(c=qu(c,"onBeforeInput"),0<c.length&&(u=new Ry("onBeforeInput","beforeinput",null,n,u),d.push({event:u,listeners:c}),u.data=M))}v_(d,t)})}function Sl(e,t,n){return{instance:e,listener:t,currentTarget:n}}function qu(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,o=i.stateNode;i.tag===5&&o!==null&&(i=o,o=vl(e,n),o!=null&&r.unshift(Sl(e,o,i)),o=vl(e,t),o!=null&&r.push(Sl(e,o,i))),e=e.return}return r}function cs(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Uy(e,t,n,r,i){for(var o=t._reactName,s=[];n!==null&&n!==r;){var a=n,l=a.alternate,c=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&c!==null&&(a=c,i?(l=vl(n,o),l!=null&&s.unshift(Sl(n,l,a))):i||(l=vl(n,o),l!=null&&s.push(Sl(n,l,a)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var cj=/\r\n?/g,uj=/\u0000|\uFFFD/g;function Hy(e){return(typeof e=="string"?e:""+e).replace(cj,`
38
+ `).replace(uj,"")}function jc(e,t,n){if(t=Hy(t),Hy(e)!==t&&n)throw Error(q(425))}function $u(){}var xp=null,wp=null;function _p(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var kp=typeof setTimeout=="function"?setTimeout:void 0,dj=typeof clearTimeout=="function"?clearTimeout:void 0,Wy=typeof Promise=="function"?Promise:void 0,fj=typeof queueMicrotask=="function"?queueMicrotask:typeof Wy<"u"?function(e){return Wy.resolve(null).then(e).catch(hj)}:kp;function hj(e){setTimeout(function(){throw e})}function rh(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),xl(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);xl(t)}function Vi(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Vy(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var la=Math.random().toString(36).slice(2),Ur="__reactFiber$"+la,El="__reactProps$"+la,mi="__reactContainer$"+la,Sp="__reactEvents$"+la,pj="__reactListeners$"+la,mj="__reactHandles$"+la;function Co(e){var t=e[Ur];if(t)return t;for(var n=e.parentNode;n;){if(t=n[mi]||n[Ur]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Vy(e);e!==null;){if(n=e[Ur])return n;e=Vy(e)}return t}e=n,n=e.parentNode}return null}function Xl(e){return e=e[Ur]||e[mi],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ks(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(q(33))}function Ud(e){return e[El]||null}var Ep=[],Ss=-1;function oo(e){return{current:e}}function vt(e){0>Ss||(e.current=Ep[Ss],Ep[Ss]=null,Ss--)}function ft(e,t){Ss++,Ep[Ss]=e.current,e.current=t}var Qi={},xn=oo(Qi),Bn=oo(!1),Uo=Qi;function Ks(e,t){var n=e.type.contextTypes;if(!n)return Qi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Un(e){return e=e.childContextTypes,e!=null}function Ku(){vt(Bn),vt(xn)}function qy(e,t,n){if(xn.current!==Qi)throw Error(q(168));ft(xn,t),ft(Bn,n)}function b_(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(q(108,ZO(e)||"Unknown",i));return Lt({},n,r)}function Yu(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Qi,Uo=xn.current,ft(xn,e),ft(Bn,Bn.current),!0}function $y(e,t,n){var r=e.stateNode;if(!r)throw Error(q(169));n?(e=b_(e,t,Uo),r.__reactInternalMemoizedMergedChildContext=e,vt(Bn),vt(xn),ft(xn,e)):vt(Bn),ft(Bn,n)}var ei=null,Hd=!1,ih=!1;function x_(e){ei===null?ei=[e]:ei.push(e)}function gj(e){Hd=!0,x_(e)}function so(){if(!ih&&ei!==null){ih=!0;var e=0,t=nt;try{var n=ei;for(nt=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}ei=null,Hd=!1}catch(i){throw ei!==null&&(ei=ei.slice(e+1)),q0(Gm,so),i}finally{nt=t,ih=!1}}return null}var Es=[],Os=0,Gu=null,Ju=0,ur=[],dr=0,Ho=null,ri=1,ii="";function ko(e,t){Es[Os++]=Ju,Es[Os++]=Gu,Gu=e,Ju=t}function w_(e,t,n){ur[dr++]=ri,ur[dr++]=ii,ur[dr++]=Ho,Ho=e;var r=ri;e=ii;var i=32-Or(r)-1;r&=~(1<<i),n+=1;var o=32-Or(t)+i;if(30<o){var s=i-i%5;o=(r&(1<<s)-1).toString(32),r>>=s,i-=s,ri=1<<32-Or(t)+i|n<<i|r,ii=o+e}else ri=1<<o|n<<i|r,ii=e}function ig(e){e.return!==null&&(ko(e,1),w_(e,1,0))}function og(e){for(;e===Gu;)Gu=Es[--Os],Es[Os]=null,Ju=Es[--Os],Es[Os]=null;for(;e===Ho;)Ho=ur[--dr],ur[dr]=null,ii=ur[--dr],ur[dr]=null,ri=ur[--dr],ur[dr]=null}var er=null,Zn=null,xt=!1,_r=null;function __(e,t){var n=fr(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Ky(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,er=e,Zn=Vi(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,er=e,Zn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ho!==null?{id:ri,overflow:ii}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=fr(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,er=e,Zn=null,!0):!1;default:return!1}}function Op(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Cp(e){if(xt){var t=Zn;if(t){var n=t;if(!Ky(e,t)){if(Op(e))throw Error(q(418));t=Vi(n.nextSibling);var r=er;t&&Ky(e,t)?__(r,n):(e.flags=e.flags&-4097|2,xt=!1,er=e)}}else{if(Op(e))throw Error(q(418));e.flags=e.flags&-4097|2,xt=!1,er=e}}}function Yy(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;er=e}function Rc(e){if(e!==er)return!1;if(!xt)return Yy(e),xt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!_p(e.type,e.memoizedProps)),t&&(t=Zn)){if(Op(e))throw k_(),Error(q(418));for(;t;)__(e,t),t=Vi(t.nextSibling)}if(Yy(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(q(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Zn=Vi(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Zn=null}}else Zn=er?Vi(e.stateNode.nextSibling):null;return!0}function k_(){for(var e=Zn;e;)e=Vi(e.nextSibling)}function Ys(){Zn=er=null,xt=!1}function sg(e){_r===null?_r=[e]:_r.push(e)}var vj=xi.ReactCurrentBatchConfig;function wa(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(q(309));var r=n.stateNode}if(!r)throw Error(q(147,e));var i=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(s){var a=i.refs;s===null?delete a[o]:a[o]=s},t._stringRef=o,t)}if(typeof e!="string")throw Error(q(284));if(!n._owner)throw Error(q(290,e))}return e}function Lc(e,t){throw e=Object.prototype.toString.call(t),Error(q(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Gy(e){var t=e._init;return t(e._payload)}function S_(e){function t(y,b){if(e){var w=y.deletions;w===null?(y.deletions=[b],y.flags|=16):w.push(b)}}function n(y,b){if(!e)return null;for(;b!==null;)t(y,b),b=b.sibling;return null}function r(y,b){for(y=new Map;b!==null;)b.key!==null?y.set(b.key,b):y.set(b.index,b),b=b.sibling;return y}function i(y,b){return y=Yi(y,b),y.index=0,y.sibling=null,y}function o(y,b,w){return y.index=w,e?(w=y.alternate,w!==null?(w=w.index,w<b?(y.flags|=2,b):w):(y.flags|=2,b)):(y.flags|=1048576,b)}function s(y){return e&&y.alternate===null&&(y.flags|=2),y}function a(y,b,w,E){return b===null||b.tag!==6?(b=dh(w,y.mode,E),b.return=y,b):(b=i(b,w),b.return=y,b)}function l(y,b,w,E){var C=w.type;return C===bs?u(y,b,w.props.children,E,w.key):b!==null&&(b.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Ci&&Gy(C)===b.type)?(E=i(b,w.props),E.ref=wa(y,b,w),E.return=y,E):(E=wu(w.type,w.key,w.props,null,y.mode,E),E.ref=wa(y,b,w),E.return=y,E)}function c(y,b,w,E){return b===null||b.tag!==4||b.stateNode.containerInfo!==w.containerInfo||b.stateNode.implementation!==w.implementation?(b=fh(w,y.mode,E),b.return=y,b):(b=i(b,w.children||[]),b.return=y,b)}function u(y,b,w,E,C){return b===null||b.tag!==7?(b=Do(w,y.mode,E,C),b.return=y,b):(b=i(b,w),b.return=y,b)}function d(y,b,w){if(typeof b=="string"&&b!==""||typeof b=="number")return b=dh(""+b,y.mode,w),b.return=y,b;if(typeof b=="object"&&b!==null){switch(b.$$typeof){case bc:return w=wu(b.type,b.key,b.props,null,y.mode,w),w.ref=wa(y,null,b),w.return=y,w;case ys:return b=fh(b,y.mode,w),b.return=y,b;case Ci:var E=b._init;return d(y,E(b._payload),w)}if(Ia(b)||ga(b))return b=Do(b,y.mode,w,null),b.return=y,b;Lc(y,b)}return null}function f(y,b,w,E){var C=b!==null?b.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return C!==null?null:a(y,b,""+w,E);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case bc:return w.key===C?l(y,b,w,E):null;case ys:return w.key===C?c(y,b,w,E):null;case Ci:return C=w._init,f(y,b,C(w._payload),E)}if(Ia(w)||ga(w))return C!==null?null:u(y,b,w,E,null);Lc(y,w)}return null}function h(y,b,w,E,C){if(typeof E=="string"&&E!==""||typeof E=="number")return y=y.get(w)||null,a(b,y,""+E,C);if(typeof E=="object"&&E!==null){switch(E.$$typeof){case bc:return y=y.get(E.key===null?w:E.key)||null,l(b,y,E,C);case ys:return y=y.get(E.key===null?w:E.key)||null,c(b,y,E,C);case Ci:var S=E._init;return h(y,b,w,S(E._payload),C)}if(Ia(E)||ga(E))return y=y.get(w)||null,u(b,y,E,C,null);Lc(b,E)}return null}function g(y,b,w,E){for(var C=null,S=null,M=b,L=b=0,T=null;M!==null&&L<w.length;L++){M.index>L?(T=M,M=null):T=M.sibling;var V=f(y,M,w[L],E);if(V===null){M===null&&(M=T);break}e&&M&&V.alternate===null&&t(y,M),b=o(V,b,L),S===null?C=V:S.sibling=V,S=V,M=T}if(L===w.length)return n(y,M),xt&&ko(y,L),C;if(M===null){for(;L<w.length;L++)M=d(y,w[L],E),M!==null&&(b=o(M,b,L),S===null?C=M:S.sibling=M,S=M);return xt&&ko(y,L),C}for(M=r(y,M);L<w.length;L++)T=h(M,y,L,w[L],E),T!==null&&(e&&T.alternate!==null&&M.delete(T.key===null?L:T.key),b=o(T,b,L),S===null?C=T:S.sibling=T,S=T);return e&&M.forEach(function(G){return t(y,G)}),xt&&ko(y,L),C}function m(y,b,w,E){var C=ga(w);if(typeof C!="function")throw Error(q(150));if(w=C.call(w),w==null)throw Error(q(151));for(var S=C=null,M=b,L=b=0,T=null,V=w.next();M!==null&&!V.done;L++,V=w.next()){M.index>L?(T=M,M=null):T=M.sibling;var G=f(y,M,V.value,E);if(G===null){M===null&&(M=T);break}e&&M&&G.alternate===null&&t(y,M),b=o(G,b,L),S===null?C=G:S.sibling=G,S=G,M=T}if(V.done)return n(y,M),xt&&ko(y,L),C;if(M===null){for(;!V.done;L++,V=w.next())V=d(y,V.value,E),V!==null&&(b=o(V,b,L),S===null?C=V:S.sibling=V,S=V);return xt&&ko(y,L),C}for(M=r(y,M);!V.done;L++,V=w.next())V=h(M,y,L,V.value,E),V!==null&&(e&&V.alternate!==null&&M.delete(V.key===null?L:V.key),b=o(V,b,L),S===null?C=V:S.sibling=V,S=V);return e&&M.forEach(function(F){return t(y,F)}),xt&&ko(y,L),C}function x(y,b,w,E){if(typeof w=="object"&&w!==null&&w.type===bs&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case bc:e:{for(var C=w.key,S=b;S!==null;){if(S.key===C){if(C=w.type,C===bs){if(S.tag===7){n(y,S.sibling),b=i(S,w.props.children),b.return=y,y=b;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Ci&&Gy(C)===S.type){n(y,S.sibling),b=i(S,w.props),b.ref=wa(y,S,w),b.return=y,y=b;break e}n(y,S);break}else t(y,S);S=S.sibling}w.type===bs?(b=Do(w.props.children,y.mode,E,w.key),b.return=y,y=b):(E=wu(w.type,w.key,w.props,null,y.mode,E),E.ref=wa(y,b,w),E.return=y,y=E)}return s(y);case ys:e:{for(S=w.key;b!==null;){if(b.key===S)if(b.tag===4&&b.stateNode.containerInfo===w.containerInfo&&b.stateNode.implementation===w.implementation){n(y,b.sibling),b=i(b,w.children||[]),b.return=y,y=b;break e}else{n(y,b);break}else t(y,b);b=b.sibling}b=fh(w,y.mode,E),b.return=y,y=b}return s(y);case Ci:return S=w._init,x(y,b,S(w._payload),E)}if(Ia(w))return g(y,b,w,E);if(ga(w))return m(y,b,w,E);Lc(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,b!==null&&b.tag===6?(n(y,b.sibling),b=i(b,w),b.return=y,y=b):(n(y,b),b=dh(w,y.mode,E),b.return=y,y=b),s(y)):n(y,b)}return x}var Gs=S_(!0),E_=S_(!1),Xu=oo(null),Qu=null,Cs=null,ag=null;function lg(){ag=Cs=Qu=null}function cg(e){var t=Xu.current;vt(Xu),e._currentValue=t}function jp(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Bs(e,t){Qu=e,ag=Cs=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(zn=!0),e.firstContext=null)}function mr(e){var t=e._currentValue;if(ag!==e)if(e={context:e,memoizedValue:t,next:null},Cs===null){if(Qu===null)throw Error(q(308));Cs=e,Qu.dependencies={lanes:0,firstContext:e}}else Cs=Cs.next=e;return t}var jo=null;function ug(e){jo===null?jo=[e]:jo.push(e)}function O_(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,ug(t)):(n.next=i.next,i.next=n),t.interleaved=n,gi(e,r)}function gi(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var ji=!1;function dg(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function C_(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function ci(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function qi(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ke&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,gi(e,n)}return i=r.interleaved,i===null?(t.next=t,ug(r)):(t.next=i.next,i.next=t),r.interleaved=t,gi(e,n)}function mu(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Jm(e,n)}}function Jy(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?i=o=s:o=o.next=s,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Zu(e,t,n,r){var i=e.updateQueue;ji=!1;var o=i.firstBaseUpdate,s=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,c=l.next;l.next=null,s===null?o=c:s.next=c,s=l;var u=e.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==s&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(o!==null){var d=i.baseState;s=0,u=c=l=null,a=o;do{var f=a.lane,h=a.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:h,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var g=e,m=a;switch(f=t,h=n,m.tag){case 1:if(g=m.payload,typeof g=="function"){d=g.call(h,d,f);break e}d=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=m.payload,f=typeof g=="function"?g.call(h,d,f):g,f==null)break e;d=Lt({},d,f);break e;case 2:ji=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[a]:f.push(a))}else h={eventTime:h,lane:f,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=h,l=d):u=u.next=h,s|=f;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;f=a,a=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(!0);if(u===null&&(l=d),i.baseState=l,i.firstBaseUpdate=c,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do s|=i.lane,i=i.next;while(i!==t)}else o===null&&(i.shared.lanes=0);Vo|=s,e.lanes=s,e.memoizedState=d}}function Xy(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(q(191,i));i.call(r)}}}var Ql={},Wr=oo(Ql),Ol=oo(Ql),Cl=oo(Ql);function Ro(e){if(e===Ql)throw Error(q(174));return e}function fg(e,t){switch(ft(Cl,t),ft(Ol,e),ft(Wr,Ql),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:lp(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=lp(t,e)}vt(Wr),ft(Wr,t)}function Js(){vt(Wr),vt(Ol),vt(Cl)}function j_(e){Ro(Cl.current);var t=Ro(Wr.current),n=lp(t,e.type);t!==n&&(ft(Ol,e),ft(Wr,n))}function hg(e){Ol.current===e&&(vt(Wr),vt(Ol))}var Ct=oo(0);function ed(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var oh=[];function pg(){for(var e=0;e<oh.length;e++)oh[e]._workInProgressVersionPrimary=null;oh.length=0}var gu=xi.ReactCurrentDispatcher,sh=xi.ReactCurrentBatchConfig,Wo=0,Rt=null,$t=null,Qt=null,td=!1,tl=!1,jl=0,yj=0;function dn(){throw Error(q(321))}function mg(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Lr(e[n],t[n]))return!1;return!0}function gg(e,t,n,r,i,o){if(Wo=o,Rt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,gu.current=e===null||e.memoizedState===null?_j:kj,e=n(r,i),tl){o=0;do{if(tl=!1,jl=0,25<=o)throw Error(q(301));o+=1,Qt=$t=null,t.updateQueue=null,gu.current=Sj,e=n(r,i)}while(tl)}if(gu.current=nd,t=$t!==null&&$t.next!==null,Wo=0,Qt=$t=Rt=null,td=!1,t)throw Error(q(300));return e}function vg(){var e=jl!==0;return jl=0,e}function Nr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Qt===null?Rt.memoizedState=Qt=e:Qt=Qt.next=e,Qt}function gr(){if($t===null){var e=Rt.alternate;e=e!==null?e.memoizedState:null}else e=$t.next;var t=Qt===null?Rt.memoizedState:Qt.next;if(t!==null)Qt=t,$t=e;else{if(e===null)throw Error(q(310));$t=e,e={memoizedState:$t.memoizedState,baseState:$t.baseState,baseQueue:$t.baseQueue,queue:$t.queue,next:null},Qt===null?Rt.memoizedState=Qt=e:Qt=Qt.next=e}return Qt}function Rl(e,t){return typeof t=="function"?t(e):t}function ah(e){var t=gr(),n=t.queue;if(n===null)throw Error(q(311));n.lastRenderedReducer=e;var r=$t,i=r.baseQueue,o=n.pending;if(o!==null){if(i!==null){var s=i.next;i.next=o.next,o.next=s}r.baseQueue=i=o,n.pending=null}if(i!==null){o=i.next,r=r.baseState;var a=s=null,l=null,c=o;do{var u=c.lane;if((Wo&u)===u)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:e(r,c.action);else{var d={lane:u,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=d,s=r):l=l.next=d,Rt.lanes|=u,Vo|=u}c=c.next}while(c!==null&&c!==o);l===null?s=r:l.next=a,Lr(r,t.memoizedState)||(zn=!0),t.memoizedState=r,t.baseState=s,t.baseQueue=l,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do o=i.lane,Rt.lanes|=o,Vo|=o,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function lh(e){var t=gr(),n=t.queue;if(n===null)throw Error(q(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do o=e(o,s.action),s=s.next;while(s!==i);Lr(o,t.memoizedState)||(zn=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function R_(){}function L_(e,t){var n=Rt,r=gr(),i=t(),o=!Lr(r.memoizedState,i);if(o&&(r.memoizedState=i,zn=!0),r=r.queue,yg(M_.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||Qt!==null&&Qt.memoizedState.tag&1){if(n.flags|=2048,Ll(9,P_.bind(null,n,r,i,t),void 0,null),en===null)throw Error(q(349));Wo&30||A_(n,t,i)}return i}function A_(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Rt.updateQueue,t===null?(t={lastEffect:null,stores:null},Rt.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function P_(e,t,n,r){t.value=n,t.getSnapshot=r,T_(t)&&D_(e)}function M_(e,t,n){return n(function(){T_(t)&&D_(e)})}function T_(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Lr(e,n)}catch{return!0}}function D_(e){var t=gi(e,1);t!==null&&Cr(t,e,1,-1)}function Qy(e){var t=Nr();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Rl,lastRenderedState:e},t.queue=e,e=e.dispatch=wj.bind(null,Rt,e),[t.memoizedState,e]}function Ll(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Rt.updateQueue,t===null?(t={lastEffect:null,stores:null},Rt.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function I_(){return gr().memoizedState}function vu(e,t,n,r){var i=Nr();Rt.flags|=e,i.memoizedState=Ll(1|t,n,void 0,r===void 0?null:r)}function Wd(e,t,n,r){var i=gr();r=r===void 0?null:r;var o=void 0;if($t!==null){var s=$t.memoizedState;if(o=s.destroy,r!==null&&mg(r,s.deps)){i.memoizedState=Ll(t,n,o,r);return}}Rt.flags|=e,i.memoizedState=Ll(1|t,n,o,r)}function Zy(e,t){return vu(8390656,8,e,t)}function yg(e,t){return Wd(2048,8,e,t)}function F_(e,t){return Wd(4,2,e,t)}function N_(e,t){return Wd(4,4,e,t)}function z_(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function B_(e,t,n){return n=n!=null?n.concat([e]):null,Wd(4,4,z_.bind(null,t,e),n)}function bg(){}function U_(e,t){var n=gr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&mg(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function H_(e,t){var n=gr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&mg(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function W_(e,t,n){return Wo&21?(Lr(n,t)||(n=Y0(),Rt.lanes|=n,Vo|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,zn=!0),e.memoizedState=n)}function bj(e,t){var n=nt;nt=n!==0&&4>n?n:4,e(!0);var r=sh.transition;sh.transition={};try{e(!1),t()}finally{nt=n,sh.transition=r}}function V_(){return gr().memoizedState}function xj(e,t,n){var r=Ki(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},q_(e))$_(t,n);else if(n=O_(e,t,n,r),n!==null){var i=jn();Cr(n,e,r,i),K_(n,t,r)}}function wj(e,t,n){var r=Ki(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(q_(e))$_(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var s=t.lastRenderedState,a=o(s,n);if(i.hasEagerState=!0,i.eagerState=a,Lr(a,s)){var l=t.interleaved;l===null?(i.next=i,ug(t)):(i.next=l.next,l.next=i),t.interleaved=i;return}}catch{}finally{}n=O_(e,t,i,r),n!==null&&(i=jn(),Cr(n,e,r,i),K_(n,t,r))}}function q_(e){var t=e.alternate;return e===Rt||t!==null&&t===Rt}function $_(e,t){tl=td=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function K_(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Jm(e,n)}}var nd={readContext:mr,useCallback:dn,useContext:dn,useEffect:dn,useImperativeHandle:dn,useInsertionEffect:dn,useLayoutEffect:dn,useMemo:dn,useReducer:dn,useRef:dn,useState:dn,useDebugValue:dn,useDeferredValue:dn,useTransition:dn,useMutableSource:dn,useSyncExternalStore:dn,useId:dn,unstable_isNewReconciler:!1},_j={readContext:mr,useCallback:function(e,t){return Nr().memoizedState=[e,t===void 0?null:t],e},useContext:mr,useEffect:Zy,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,vu(4194308,4,z_.bind(null,t,e),n)},useLayoutEffect:function(e,t){return vu(4194308,4,e,t)},useInsertionEffect:function(e,t){return vu(4,2,e,t)},useMemo:function(e,t){var n=Nr();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Nr();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=xj.bind(null,Rt,e),[r.memoizedState,e]},useRef:function(e){var t=Nr();return e={current:e},t.memoizedState=e},useState:Qy,useDebugValue:bg,useDeferredValue:function(e){return Nr().memoizedState=e},useTransition:function(){var e=Qy(!1),t=e[0];return e=bj.bind(null,e[1]),Nr().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Rt,i=Nr();if(xt){if(n===void 0)throw Error(q(407));n=n()}else{if(n=t(),en===null)throw Error(q(349));Wo&30||A_(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Zy(M_.bind(null,r,o,e),[e]),r.flags|=2048,Ll(9,P_.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Nr(),t=en.identifierPrefix;if(xt){var n=ii,r=ri;n=(r&~(1<<32-Or(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=jl++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=yj++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},kj={readContext:mr,useCallback:U_,useContext:mr,useEffect:yg,useImperativeHandle:B_,useInsertionEffect:F_,useLayoutEffect:N_,useMemo:H_,useReducer:ah,useRef:I_,useState:function(){return ah(Rl)},useDebugValue:bg,useDeferredValue:function(e){var t=gr();return W_(t,$t.memoizedState,e)},useTransition:function(){var e=ah(Rl)[0],t=gr().memoizedState;return[e,t]},useMutableSource:R_,useSyncExternalStore:L_,useId:V_,unstable_isNewReconciler:!1},Sj={readContext:mr,useCallback:U_,useContext:mr,useEffect:yg,useImperativeHandle:B_,useInsertionEffect:F_,useLayoutEffect:N_,useMemo:H_,useReducer:lh,useRef:I_,useState:function(){return lh(Rl)},useDebugValue:bg,useDeferredValue:function(e){var t=gr();return $t===null?t.memoizedState=e:W_(t,$t.memoizedState,e)},useTransition:function(){var e=lh(Rl)[0],t=gr().memoizedState;return[e,t]},useMutableSource:R_,useSyncExternalStore:L_,useId:V_,unstable_isNewReconciler:!1};function xr(e,t){if(e&&e.defaultProps){t=Lt({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Rp(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Lt({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Vd={isMounted:function(e){return(e=e._reactInternals)?Zo(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=jn(),i=Ki(e),o=ci(r,i);o.payload=t,n!=null&&(o.callback=n),t=qi(e,o,i),t!==null&&(Cr(t,e,i,r),mu(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=jn(),i=Ki(e),o=ci(r,i);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=qi(e,o,i),t!==null&&(Cr(t,e,i,r),mu(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=jn(),r=Ki(e),i=ci(n,r);i.tag=2,t!=null&&(i.callback=t),t=qi(e,i,r),t!==null&&(Cr(t,e,r,n),mu(t,e,r))}};function eb(e,t,n,r,i,o,s){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,s):t.prototype&&t.prototype.isPureReactComponent?!_l(n,r)||!_l(i,o):!0}function Y_(e,t,n){var r=!1,i=Qi,o=t.contextType;return typeof o=="object"&&o!==null?o=mr(o):(i=Un(t)?Uo:xn.current,r=t.contextTypes,o=(r=r!=null)?Ks(e,i):Qi),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Vd,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=o),t}function tb(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Vd.enqueueReplaceState(t,t.state,null)}function Lp(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},dg(e);var o=t.contextType;typeof o=="object"&&o!==null?i.context=mr(o):(o=Un(t)?Uo:xn.current,i.context=Ks(e,o)),i.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(Rp(e,t,o,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&Vd.enqueueReplaceState(i,i.state,null),Zu(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Xs(e,t){try{var n="",r=t;do n+=QO(r),r=r.return;while(r);var i=n}catch(o){i=`
39
+ Error generating stack: `+o.message+`
40
+ `+o.stack}return{value:e,source:t,stack:i,digest:null}}function ch(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Ap(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Ej=typeof WeakMap=="function"?WeakMap:Map;function G_(e,t,n){n=ci(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){id||(id=!0,Up=r),Ap(e,t)},n}function J_(e,t,n){n=ci(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Ap(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){Ap(e,t),typeof r!="function"&&($i===null?$i=new Set([this]):$i.add(this));var s=t.stack;this.componentDidCatch(t.value,{componentStack:s!==null?s:""})}),n}function nb(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ej;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=zj.bind(null,e,t,n),t.then(e,e))}function rb(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function ib(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=ci(-1,1),t.tag=2,qi(n,t,1))),n.lanes|=1),e)}var Oj=xi.ReactCurrentOwner,zn=!1;function Cn(e,t,n,r){t.child=e===null?E_(t,null,n,r):Gs(t,e.child,n,r)}function ob(e,t,n,r,i){n=n.render;var o=t.ref;return Bs(t,i),r=gg(e,t,n,r,o,i),n=vg(),e!==null&&!zn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,vi(e,t,i)):(xt&&n&&ig(t),t.flags|=1,Cn(e,t,r,i),t.child)}function sb(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!Cg(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,X_(e,t,o,r,i)):(e=wu(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&i)){var s=o.memoizedProps;if(n=n.compare,n=n!==null?n:_l,n(s,r)&&e.ref===t.ref)return vi(e,t,i)}return t.flags|=1,e=Yi(o,r),e.ref=t.ref,e.return=t,t.child=e}function X_(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(_l(o,r)&&e.ref===t.ref)if(zn=!1,t.pendingProps=r=o,(e.lanes&i)!==0)e.flags&131072&&(zn=!0);else return t.lanes=e.lanes,vi(e,t,i)}return Pp(e,t,n,r,i)}function Q_(e,t,n){var r=t.pendingProps,i=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ft(Rs,Gn),Gn|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ft(Rs,Gn),Gn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,ft(Rs,Gn),Gn|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,ft(Rs,Gn),Gn|=r;return Cn(e,t,i,n),t.child}function Z_(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Pp(e,t,n,r,i){var o=Un(n)?Uo:xn.current;return o=Ks(t,o),Bs(t,i),n=gg(e,t,n,r,o,i),r=vg(),e!==null&&!zn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,vi(e,t,i)):(xt&&r&&ig(t),t.flags|=1,Cn(e,t,n,i),t.child)}function ab(e,t,n,r,i){if(Un(n)){var o=!0;Yu(t)}else o=!1;if(Bs(t,i),t.stateNode===null)yu(e,t),Y_(t,n,r),Lp(t,n,r,i),r=!0;else if(e===null){var s=t.stateNode,a=t.memoizedProps;s.props=a;var l=s.context,c=n.contextType;typeof c=="object"&&c!==null?c=mr(c):(c=Un(n)?Uo:xn.current,c=Ks(t,c));var u=n.getDerivedStateFromProps,d=typeof u=="function"||typeof s.getSnapshotBeforeUpdate=="function";d||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(a!==r||l!==c)&&tb(t,s,r,c),ji=!1;var f=t.memoizedState;s.state=f,Zu(t,r,s,i),l=t.memoizedState,a!==r||f!==l||Bn.current||ji?(typeof u=="function"&&(Rp(t,n,u,r),l=t.memoizedState),(a=ji||eb(t,n,a,r,f,l,c))?(d||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount()),typeof s.componentDidMount=="function"&&(t.flags|=4194308)):(typeof s.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),s.props=r,s.state=l,s.context=c,r=a):(typeof s.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{s=t.stateNode,C_(e,t),a=t.memoizedProps,c=t.type===t.elementType?a:xr(t.type,a),s.props=c,d=t.pendingProps,f=s.context,l=n.contextType,typeof l=="object"&&l!==null?l=mr(l):(l=Un(n)?Uo:xn.current,l=Ks(t,l));var h=n.getDerivedStateFromProps;(u=typeof h=="function"||typeof s.getSnapshotBeforeUpdate=="function")||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(a!==d||f!==l)&&tb(t,s,r,l),ji=!1,f=t.memoizedState,s.state=f,Zu(t,r,s,i);var g=t.memoizedState;a!==d||f!==g||Bn.current||ji?(typeof h=="function"&&(Rp(t,n,h,r),g=t.memoizedState),(c=ji||eb(t,n,c,r,f,g,l)||!1)?(u||typeof s.UNSAFE_componentWillUpdate!="function"&&typeof s.componentWillUpdate!="function"||(typeof s.componentWillUpdate=="function"&&s.componentWillUpdate(r,g,l),typeof s.UNSAFE_componentWillUpdate=="function"&&s.UNSAFE_componentWillUpdate(r,g,l)),typeof s.componentDidUpdate=="function"&&(t.flags|=4),typeof s.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof s.componentDidUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),s.props=r,s.state=g,s.context=l,r=c):(typeof s.componentDidUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Mp(e,t,n,r,o,i)}function Mp(e,t,n,r,i,o){Z_(e,t);var s=(t.flags&128)!==0;if(!r&&!s)return i&&$y(t,n,!1),vi(e,t,o);r=t.stateNode,Oj.current=t;var a=s&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&s?(t.child=Gs(t,e.child,null,o),t.child=Gs(t,null,a,o)):Cn(e,t,a,o),t.memoizedState=r.state,i&&$y(t,n,!0),t.child}function ek(e){var t=e.stateNode;t.pendingContext?qy(e,t.pendingContext,t.pendingContext!==t.context):t.context&&qy(e,t.context,!1),fg(e,t.containerInfo)}function lb(e,t,n,r,i){return Ys(),sg(i),t.flags|=256,Cn(e,t,n,r),t.child}var Tp={dehydrated:null,treeContext:null,retryLane:0};function Dp(e){return{baseLanes:e,cachePool:null,transitions:null}}function tk(e,t,n){var r=t.pendingProps,i=Ct.current,o=!1,s=(t.flags&128)!==0,a;if((a=s)||(a=e!==null&&e.memoizedState===null?!1:(i&2)!==0),a?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),ft(Ct,i&1),e===null)return Cp(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(s=r.children,e=r.fallback,o?(r=t.mode,o=t.child,s={mode:"hidden",children:s},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=s):o=Kd(s,r,0,null),e=Do(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Dp(n),t.memoizedState=Tp,e):xg(t,s));if(i=e.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return Cj(e,t,s,r,a,i,n);if(o){o=r.fallback,s=t.mode,i=e.child,a=i.sibling;var l={mode:"hidden",children:r.children};return!(s&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=Yi(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?o=Yi(a,o):(o=Do(o,s,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,s=e.child.memoizedState,s=s===null?Dp(n):{baseLanes:s.baseLanes|n,cachePool:null,transitions:s.transitions},o.memoizedState=s,o.childLanes=e.childLanes&~n,t.memoizedState=Tp,r}return o=e.child,e=o.sibling,r=Yi(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function xg(e,t){return t=Kd({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ac(e,t,n,r){return r!==null&&sg(r),Gs(t,e.child,null,n),e=xg(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Cj(e,t,n,r,i,o,s){if(n)return t.flags&256?(t.flags&=-257,r=ch(Error(q(422))),Ac(e,t,s,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,i=t.mode,r=Kd({mode:"visible",children:r.children},i,0,null),o=Do(o,i,s,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Gs(t,e.child,null,s),t.child.memoizedState=Dp(s),t.memoizedState=Tp,o);if(!(t.mode&1))return Ac(e,t,s,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,o=Error(q(419)),r=ch(o,r,void 0),Ac(e,t,s,r)}if(a=(s&e.childLanes)!==0,zn||a){if(r=en,r!==null){switch(s&-s){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|s)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,gi(e,i),Cr(r,e,i,-1))}return Og(),r=ch(Error(q(421))),Ac(e,t,s,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=Bj.bind(null,e),i._reactRetry=t,null):(e=o.treeContext,Zn=Vi(i.nextSibling),er=t,xt=!0,_r=null,e!==null&&(ur[dr++]=ri,ur[dr++]=ii,ur[dr++]=Ho,ri=e.id,ii=e.overflow,Ho=t),t=xg(t,r.children),t.flags|=4096,t)}function cb(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),jp(e.return,t,n)}function uh(e,t,n,r,i){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function nk(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;if(Cn(e,t,r.children,n),r=Ct.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&cb(e,n,t);else if(e.tag===19)cb(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(ft(Ct,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&ed(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),uh(t,!1,i,n,o);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&ed(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}uh(t,!0,n,null,o);break;case"together":uh(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function yu(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function vi(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Vo|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(q(153));if(t.child!==null){for(e=t.child,n=Yi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Yi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function jj(e,t,n){switch(t.tag){case 3:ek(t),Ys();break;case 5:j_(t);break;case 1:Un(t.type)&&Yu(t);break;case 4:fg(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;ft(Xu,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ft(Ct,Ct.current&1),t.flags|=128,null):n&t.child.childLanes?tk(e,t,n):(ft(Ct,Ct.current&1),e=vi(e,t,n),e!==null?e.sibling:null);ft(Ct,Ct.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return nk(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ft(Ct,Ct.current),r)break;return null;case 22:case 23:return t.lanes=0,Q_(e,t,n)}return vi(e,t,n)}var rk,Ip,ik,ok;rk=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Ip=function(){};ik=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Ro(Wr.current);var o=null;switch(n){case"input":i=ip(e,i),r=ip(e,r),o=[];break;case"select":i=Lt({},i,{value:void 0}),r=Lt({},r,{value:void 0}),o=[];break;case"textarea":i=ap(e,i),r=ap(e,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=$u)}cp(n,r);var s;n=null;for(c in i)if(!r.hasOwnProperty(c)&&i.hasOwnProperty(c)&&i[c]!=null)if(c==="style"){var a=i[c];for(s in a)a.hasOwnProperty(s)&&(n||(n={}),n[s]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(ml.hasOwnProperty(c)?o||(o=[]):(o=o||[]).push(c,null));for(c in r){var l=r[c];if(a=i!=null?i[c]:void 0,r.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(s in a)!a.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||(n={}),n[s]="");for(s in l)l.hasOwnProperty(s)&&a[s]!==l[s]&&(n||(n={}),n[s]=l[s])}else n||(o||(o=[]),o.push(c,n)),n=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(o=o||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(o=o||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(ml.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&gt("scroll",e),o||a===l||(o=[])):(o=o||[]).push(c,l))}n&&(o=o||[]).push("style",n);var c=o;(t.updateQueue=c)&&(t.flags|=4)}};ok=function(e,t,n,r){n!==r&&(t.flags|=4)};function _a(e,t){if(!xt)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function fn(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Rj(e,t,n){var r=t.pendingProps;switch(og(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return fn(t),null;case 1:return Un(t.type)&&Ku(),fn(t),null;case 3:return r=t.stateNode,Js(),vt(Bn),vt(xn),pg(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Rc(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,_r!==null&&(Vp(_r),_r=null))),Ip(e,t),fn(t),null;case 5:hg(t);var i=Ro(Cl.current);if(n=t.type,e!==null&&t.stateNode!=null)ik(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(q(166));return fn(t),null}if(e=Ro(Wr.current),Rc(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Ur]=t,r[El]=o,e=(t.mode&1)!==0,n){case"dialog":gt("cancel",r),gt("close",r);break;case"iframe":case"object":case"embed":gt("load",r);break;case"video":case"audio":for(i=0;i<Na.length;i++)gt(Na[i],r);break;case"source":gt("error",r);break;case"img":case"image":case"link":gt("error",r),gt("load",r);break;case"details":gt("toggle",r);break;case"input":yy(r,o),gt("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},gt("invalid",r);break;case"textarea":xy(r,o),gt("invalid",r)}cp(n,o),i=null;for(var s in o)if(o.hasOwnProperty(s)){var a=o[s];s==="children"?typeof a=="string"?r.textContent!==a&&(o.suppressHydrationWarning!==!0&&jc(r.textContent,a,e),i=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(o.suppressHydrationWarning!==!0&&jc(r.textContent,a,e),i=["children",""+a]):ml.hasOwnProperty(s)&&a!=null&&s==="onScroll"&&gt("scroll",r)}switch(n){case"input":xc(r),by(r,o,!0);break;case"textarea":xc(r),wy(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=$u)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{s=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=M0(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=s.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[Ur]=t,e[El]=r,rk(e,t,!1,!1),t.stateNode=e;e:{switch(s=up(n,r),n){case"dialog":gt("cancel",e),gt("close",e),i=r;break;case"iframe":case"object":case"embed":gt("load",e),i=r;break;case"video":case"audio":for(i=0;i<Na.length;i++)gt(Na[i],e);i=r;break;case"source":gt("error",e),i=r;break;case"img":case"image":case"link":gt("error",e),gt("load",e),i=r;break;case"details":gt("toggle",e),i=r;break;case"input":yy(e,r),i=ip(e,r),gt("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=Lt({},r,{value:void 0}),gt("invalid",e);break;case"textarea":xy(e,r),i=ap(e,r),gt("invalid",e);break;default:i=r}cp(n,i),a=i;for(o in a)if(a.hasOwnProperty(o)){var l=a[o];o==="style"?I0(e,l):o==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&T0(e,l)):o==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&gl(e,l):typeof l=="number"&&gl(e,""+l):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(ml.hasOwnProperty(o)?l!=null&&o==="onScroll"&&gt("scroll",e):l!=null&&Vm(e,o,l,s))}switch(n){case"input":xc(e),by(e,r,!1);break;case"textarea":xc(e),wy(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Xi(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?Is(e,!!r.multiple,o,!1):r.defaultValue!=null&&Is(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=$u)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return fn(t),null;case 6:if(e&&t.stateNode!=null)ok(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(q(166));if(n=Ro(Cl.current),Ro(Wr.current),Rc(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ur]=t,(o=r.nodeValue!==n)&&(e=er,e!==null))switch(e.tag){case 3:jc(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&jc(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ur]=t,t.stateNode=r}return fn(t),null;case 13:if(vt(Ct),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(xt&&Zn!==null&&t.mode&1&&!(t.flags&128))k_(),Ys(),t.flags|=98560,o=!1;else if(o=Rc(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(q(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(q(317));o[Ur]=t}else Ys(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;fn(t),o=!1}else _r!==null&&(Vp(_r),_r=null),o=!0;if(!o)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Ct.current&1?Yt===0&&(Yt=3):Og())),t.updateQueue!==null&&(t.flags|=4),fn(t),null);case 4:return Js(),Ip(e,t),e===null&&kl(t.stateNode.containerInfo),fn(t),null;case 10:return cg(t.type._context),fn(t),null;case 17:return Un(t.type)&&Ku(),fn(t),null;case 19:if(vt(Ct),o=t.memoizedState,o===null)return fn(t),null;if(r=(t.flags&128)!==0,s=o.rendering,s===null)if(r)_a(o,!1);else{if(Yt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(s=ed(e),s!==null){for(t.flags|=128,_a(o,!1),r=s.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,s=o.alternate,s===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=s.childLanes,o.lanes=s.lanes,o.child=s.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=s.memoizedProps,o.memoizedState=s.memoizedState,o.updateQueue=s.updateQueue,o.type=s.type,e=s.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return ft(Ct,Ct.current&1|2),t.child}e=e.sibling}o.tail!==null&&zt()>Qs&&(t.flags|=128,r=!0,_a(o,!1),t.lanes=4194304)}else{if(!r)if(e=ed(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),_a(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!xt)return fn(t),null}else 2*zt()-o.renderingStartTime>Qs&&n!==1073741824&&(t.flags|=128,r=!0,_a(o,!1),t.lanes=4194304);o.isBackwards?(s.sibling=t.child,t.child=s):(n=o.last,n!==null?n.sibling=s:t.child=s,o.last=s)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=zt(),t.sibling=null,n=Ct.current,ft(Ct,r?n&1|2:n&1),t):(fn(t),null);case 22:case 23:return Eg(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Gn&1073741824&&(fn(t),t.subtreeFlags&6&&(t.flags|=8192)):fn(t),null;case 24:return null;case 25:return null}throw Error(q(156,t.tag))}function Lj(e,t){switch(og(t),t.tag){case 1:return Un(t.type)&&Ku(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Js(),vt(Bn),vt(xn),pg(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return hg(t),null;case 13:if(vt(Ct),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(q(340));Ys()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return vt(Ct),null;case 4:return Js(),null;case 10:return cg(t.type._context),null;case 22:case 23:return Eg(),null;case 24:return null;default:return null}}var Pc=!1,yn=!1,Aj=typeof WeakSet=="function"?WeakSet:Set,ue=null;function js(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Tt(e,t,r)}else n.current=null}function Fp(e,t,n){try{n()}catch(r){Tt(e,t,r)}}var ub=!1;function Pj(e,t){if(xp=Wu,e=u_(),rg(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var s=0,a=-1,l=-1,c=0,u=0,d=e,f=null;t:for(;;){for(var h;d!==n||i!==0&&d.nodeType!==3||(a=s+i),d!==o||r!==0&&d.nodeType!==3||(l=s+r),d.nodeType===3&&(s+=d.nodeValue.length),(h=d.firstChild)!==null;)f=d,d=h;for(;;){if(d===e)break t;if(f===n&&++c===i&&(a=s),f===o&&++u===r&&(l=s),(h=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=h}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(wp={focusedElem:e,selectionRange:n},Wu=!1,ue=t;ue!==null;)if(t=ue,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ue=e;else for(;ue!==null;){t=ue;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var m=g.memoizedProps,x=g.memoizedState,y=t.stateNode,b=y.getSnapshotBeforeUpdate(t.elementType===t.type?m:xr(t.type,m),x);y.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(q(163))}}catch(E){Tt(t,t.return,E)}if(e=t.sibling,e!==null){e.return=t.return,ue=e;break}ue=t.return}return g=ub,ub=!1,g}function nl(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var o=i.destroy;i.destroy=void 0,o!==void 0&&Fp(t,n,o)}i=i.next}while(i!==r)}}function qd(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Np(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function sk(e){var t=e.alternate;t!==null&&(e.alternate=null,sk(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ur],delete t[El],delete t[Sp],delete t[pj],delete t[mj])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function ak(e){return e.tag===5||e.tag===3||e.tag===4}function db(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ak(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function zp(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=$u));else if(r!==4&&(e=e.child,e!==null))for(zp(e,t,n),e=e.sibling;e!==null;)zp(e,t,n),e=e.sibling}function Bp(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Bp(e,t,n),e=e.sibling;e!==null;)Bp(e,t,n),e=e.sibling}var rn=null,wr=!1;function ki(e,t,n){for(n=n.child;n!==null;)lk(e,t,n),n=n.sibling}function lk(e,t,n){if(Hr&&typeof Hr.onCommitFiberUnmount=="function")try{Hr.onCommitFiberUnmount(Fd,n)}catch{}switch(n.tag){case 5:yn||js(n,t);case 6:var r=rn,i=wr;rn=null,ki(e,t,n),rn=r,wr=i,rn!==null&&(wr?(e=rn,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):rn.removeChild(n.stateNode));break;case 18:rn!==null&&(wr?(e=rn,n=n.stateNode,e.nodeType===8?rh(e.parentNode,n):e.nodeType===1&&rh(e,n),xl(e)):rh(rn,n.stateNode));break;case 4:r=rn,i=wr,rn=n.stateNode.containerInfo,wr=!0,ki(e,t,n),rn=r,wr=i;break;case 0:case 11:case 14:case 15:if(!yn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,s=o.destroy;o=o.tag,s!==void 0&&(o&2||o&4)&&Fp(n,t,s),i=i.next}while(i!==r)}ki(e,t,n);break;case 1:if(!yn&&(js(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Tt(n,t,a)}ki(e,t,n);break;case 21:ki(e,t,n);break;case 22:n.mode&1?(yn=(r=yn)||n.memoizedState!==null,ki(e,t,n),yn=r):ki(e,t,n);break;default:ki(e,t,n)}}function fb(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Aj),t.forEach(function(r){var i=Uj.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function yr(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var o=e,s=t,a=s;e:for(;a!==null;){switch(a.tag){case 5:rn=a.stateNode,wr=!1;break e;case 3:rn=a.stateNode.containerInfo,wr=!0;break e;case 4:rn=a.stateNode.containerInfo,wr=!0;break e}a=a.return}if(rn===null)throw Error(q(160));lk(o,s,i),rn=null,wr=!1;var l=i.alternate;l!==null&&(l.return=null),i.return=null}catch(c){Tt(i,t,c)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)ck(t,e),t=t.sibling}function ck(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(yr(t,e),Tr(e),r&4){try{nl(3,e,e.return),qd(3,e)}catch(m){Tt(e,e.return,m)}try{nl(5,e,e.return)}catch(m){Tt(e,e.return,m)}}break;case 1:yr(t,e),Tr(e),r&512&&n!==null&&js(n,n.return);break;case 5:if(yr(t,e),Tr(e),r&512&&n!==null&&js(n,n.return),e.flags&32){var i=e.stateNode;try{gl(i,"")}catch(m){Tt(e,e.return,m)}}if(r&4&&(i=e.stateNode,i!=null)){var o=e.memoizedProps,s=n!==null?n.memoizedProps:o,a=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{a==="input"&&o.type==="radio"&&o.name!=null&&A0(i,o),up(a,s);var c=up(a,o);for(s=0;s<l.length;s+=2){var u=l[s],d=l[s+1];u==="style"?I0(i,d):u==="dangerouslySetInnerHTML"?T0(i,d):u==="children"?gl(i,d):Vm(i,u,d,c)}switch(a){case"input":op(i,o);break;case"textarea":P0(i,o);break;case"select":var f=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!o.multiple;var h=o.value;h!=null?Is(i,!!o.multiple,h,!1):f!==!!o.multiple&&(o.defaultValue!=null?Is(i,!!o.multiple,o.defaultValue,!0):Is(i,!!o.multiple,o.multiple?[]:"",!1))}i[El]=o}catch(m){Tt(e,e.return,m)}}break;case 6:if(yr(t,e),Tr(e),r&4){if(e.stateNode===null)throw Error(q(162));i=e.stateNode,o=e.memoizedProps;try{i.nodeValue=o}catch(m){Tt(e,e.return,m)}}break;case 3:if(yr(t,e),Tr(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{xl(t.containerInfo)}catch(m){Tt(e,e.return,m)}break;case 4:yr(t,e),Tr(e);break;case 13:yr(t,e),Tr(e),i=e.child,i.flags&8192&&(o=i.memoizedState!==null,i.stateNode.isHidden=o,!o||i.alternate!==null&&i.alternate.memoizedState!==null||(kg=zt())),r&4&&fb(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(yn=(c=yn)||u,yr(t,e),yn=c):yr(t,e),Tr(e),r&8192){if(c=e.memoizedState!==null,(e.stateNode.isHidden=c)&&!u&&e.mode&1)for(ue=e,u=e.child;u!==null;){for(d=ue=u;ue!==null;){switch(f=ue,h=f.child,f.tag){case 0:case 11:case 14:case 15:nl(4,f,f.return);break;case 1:js(f,f.return);var g=f.stateNode;if(typeof g.componentWillUnmount=="function"){r=f,n=f.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(m){Tt(r,n,m)}}break;case 5:js(f,f.return);break;case 22:if(f.memoizedState!==null){pb(d);continue}}h!==null?(h.return=f,ue=h):pb(d)}u=u.sibling}e:for(u=null,d=e;;){if(d.tag===5){if(u===null){u=d;try{i=d.stateNode,c?(o=i.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(a=d.stateNode,l=d.memoizedProps.style,s=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=D0("display",s))}catch(m){Tt(e,e.return,m)}}}else if(d.tag===6){if(u===null)try{d.stateNode.nodeValue=c?"":d.memoizedProps}catch(m){Tt(e,e.return,m)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;u===d&&(u=null),d=d.return}u===d&&(u=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:yr(t,e),Tr(e),r&4&&fb(e);break;case 21:break;default:yr(t,e),Tr(e)}}function Tr(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(ak(n)){var r=n;break e}n=n.return}throw Error(q(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(gl(i,""),r.flags&=-33);var o=db(e);Bp(e,o,i);break;case 3:case 4:var s=r.stateNode.containerInfo,a=db(e);zp(e,a,s);break;default:throw Error(q(161))}}catch(l){Tt(e,e.return,l)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Mj(e,t,n){ue=e,uk(e)}function uk(e,t,n){for(var r=(e.mode&1)!==0;ue!==null;){var i=ue,o=i.child;if(i.tag===22&&r){var s=i.memoizedState!==null||Pc;if(!s){var a=i.alternate,l=a!==null&&a.memoizedState!==null||yn;a=Pc;var c=yn;if(Pc=s,(yn=l)&&!c)for(ue=i;ue!==null;)s=ue,l=s.child,s.tag===22&&s.memoizedState!==null?mb(i):l!==null?(l.return=s,ue=l):mb(i);for(;o!==null;)ue=o,uk(o),o=o.sibling;ue=i,Pc=a,yn=c}hb(e)}else i.subtreeFlags&8772&&o!==null?(o.return=i,ue=o):hb(e)}}function hb(e){for(;ue!==null;){var t=ue;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:yn||qd(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!yn)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:xr(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&Xy(t,o,r);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Xy(t,s,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var l=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var c=t.alternate;if(c!==null){var u=c.memoizedState;if(u!==null){var d=u.dehydrated;d!==null&&xl(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(q(163))}yn||t.flags&512&&Np(t)}catch(f){Tt(t,t.return,f)}}if(t===e){ue=null;break}if(n=t.sibling,n!==null){n.return=t.return,ue=n;break}ue=t.return}}function pb(e){for(;ue!==null;){var t=ue;if(t===e){ue=null;break}var n=t.sibling;if(n!==null){n.return=t.return,ue=n;break}ue=t.return}}function mb(e){for(;ue!==null;){var t=ue;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{qd(4,t)}catch(l){Tt(t,n,l)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(l){Tt(t,i,l)}}var o=t.return;try{Np(t)}catch(l){Tt(t,o,l)}break;case 5:var s=t.return;try{Np(t)}catch(l){Tt(t,s,l)}}}catch(l){Tt(t,t.return,l)}if(t===e){ue=null;break}var a=t.sibling;if(a!==null){a.return=t.return,ue=a;break}ue=t.return}}var Tj=Math.ceil,rd=xi.ReactCurrentDispatcher,wg=xi.ReactCurrentOwner,pr=xi.ReactCurrentBatchConfig,Ke=0,en=null,Ht=null,on=0,Gn=0,Rs=oo(0),Yt=0,Al=null,Vo=0,$d=0,_g=0,rl=null,Fn=null,kg=0,Qs=1/0,Zr=null,id=!1,Up=null,$i=null,Mc=!1,Mi=null,od=0,il=0,Hp=null,bu=-1,xu=0;function jn(){return Ke&6?zt():bu!==-1?bu:bu=zt()}function Ki(e){return e.mode&1?Ke&2&&on!==0?on&-on:vj.transition!==null?(xu===0&&(xu=Y0()),xu):(e=nt,e!==0||(e=window.event,e=e===void 0?16:t_(e.type)),e):1}function Cr(e,t,n,r){if(50<il)throw il=0,Hp=null,Error(q(185));Gl(e,n,r),(!(Ke&2)||e!==en)&&(e===en&&(!(Ke&2)&&($d|=n),Yt===4&&Li(e,on)),Hn(e,r),n===1&&Ke===0&&!(t.mode&1)&&(Qs=zt()+500,Hd&&so()))}function Hn(e,t){var n=e.callbackNode;vC(e,t);var r=Hu(e,e===en?on:0);if(r===0)n!==null&&Sy(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Sy(n),t===1)e.tag===0?gj(gb.bind(null,e)):x_(gb.bind(null,e)),fj(function(){!(Ke&6)&&so()}),n=null;else{switch(G0(r)){case 1:n=Gm;break;case 4:n=$0;break;case 16:n=Uu;break;case 536870912:n=K0;break;default:n=Uu}n=yk(n,dk.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function dk(e,t){if(bu=-1,xu=0,Ke&6)throw Error(q(327));var n=e.callbackNode;if(Us()&&e.callbackNode!==n)return null;var r=Hu(e,e===en?on:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=sd(e,r);else{t=r;var i=Ke;Ke|=2;var o=hk();(en!==e||on!==t)&&(Zr=null,Qs=zt()+500,To(e,t));do try{Fj();break}catch(a){fk(e,a)}while(!0);lg(),rd.current=o,Ke=i,Ht!==null?t=0:(en=null,on=0,t=Yt)}if(t!==0){if(t===2&&(i=mp(e),i!==0&&(r=i,t=Wp(e,i))),t===1)throw n=Al,To(e,0),Li(e,r),Hn(e,zt()),n;if(t===6)Li(e,r);else{if(i=e.current.alternate,!(r&30)&&!Dj(i)&&(t=sd(e,r),t===2&&(o=mp(e),o!==0&&(r=o,t=Wp(e,o))),t===1))throw n=Al,To(e,0),Li(e,r),Hn(e,zt()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(q(345));case 2:So(e,Fn,Zr);break;case 3:if(Li(e,r),(r&130023424)===r&&(t=kg+500-zt(),10<t)){if(Hu(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){jn(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=kp(So.bind(null,e,Fn,Zr),t);break}So(e,Fn,Zr);break;case 4:if(Li(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var s=31-Or(r);o=1<<s,s=t[s],s>i&&(i=s),r&=~o}if(r=i,r=zt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Tj(r/1960))-r,10<r){e.timeoutHandle=kp(So.bind(null,e,Fn,Zr),r);break}So(e,Fn,Zr);break;case 5:So(e,Fn,Zr);break;default:throw Error(q(329))}}}return Hn(e,zt()),e.callbackNode===n?dk.bind(null,e):null}function Wp(e,t){var n=rl;return e.current.memoizedState.isDehydrated&&(To(e,t).flags|=256),e=sd(e,t),e!==2&&(t=Fn,Fn=n,t!==null&&Vp(t)),e}function Vp(e){Fn===null?Fn=e:Fn.push.apply(Fn,e)}function Dj(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],o=i.getSnapshot;i=i.value;try{if(!Lr(o(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Li(e,t){for(t&=~_g,t&=~$d,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Or(t),r=1<<n;e[n]=-1,t&=~r}}function gb(e){if(Ke&6)throw Error(q(327));Us();var t=Hu(e,0);if(!(t&1))return Hn(e,zt()),null;var n=sd(e,t);if(e.tag!==0&&n===2){var r=mp(e);r!==0&&(t=r,n=Wp(e,r))}if(n===1)throw n=Al,To(e,0),Li(e,t),Hn(e,zt()),n;if(n===6)throw Error(q(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,So(e,Fn,Zr),Hn(e,zt()),null}function Sg(e,t){var n=Ke;Ke|=1;try{return e(t)}finally{Ke=n,Ke===0&&(Qs=zt()+500,Hd&&so())}}function qo(e){Mi!==null&&Mi.tag===0&&!(Ke&6)&&Us();var t=Ke;Ke|=1;var n=pr.transition,r=nt;try{if(pr.transition=null,nt=1,e)return e()}finally{nt=r,pr.transition=n,Ke=t,!(Ke&6)&&so()}}function Eg(){Gn=Rs.current,vt(Rs)}function To(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,dj(n)),Ht!==null)for(n=Ht.return;n!==null;){var r=n;switch(og(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Ku();break;case 3:Js(),vt(Bn),vt(xn),pg();break;case 5:hg(r);break;case 4:Js();break;case 13:vt(Ct);break;case 19:vt(Ct);break;case 10:cg(r.type._context);break;case 22:case 23:Eg()}n=n.return}if(en=e,Ht=e=Yi(e.current,null),on=Gn=t,Yt=0,Al=null,_g=$d=Vo=0,Fn=rl=null,jo!==null){for(t=0;t<jo.length;t++)if(n=jo[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,o=n.pending;if(o!==null){var s=o.next;o.next=i,r.next=s}n.pending=r}jo=null}return e}function fk(e,t){do{var n=Ht;try{if(lg(),gu.current=nd,td){for(var r=Rt.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}td=!1}if(Wo=0,Qt=$t=Rt=null,tl=!1,jl=0,wg.current=null,n===null||n.return===null){Yt=1,Al=t,Ht=null;break}e:{var o=e,s=n.return,a=n,l=t;if(t=on,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,u=a,d=u.tag;if(!(u.mode&1)&&(d===0||d===11||d===15)){var f=u.alternate;f?(u.updateQueue=f.updateQueue,u.memoizedState=f.memoizedState,u.lanes=f.lanes):(u.updateQueue=null,u.memoizedState=null)}var h=rb(s);if(h!==null){h.flags&=-257,ib(h,s,a,o,t),h.mode&1&&nb(o,c,t),t=h,l=c;var g=t.updateQueue;if(g===null){var m=new Set;m.add(l),t.updateQueue=m}else g.add(l);break e}else{if(!(t&1)){nb(o,c,t),Og();break e}l=Error(q(426))}}else if(xt&&a.mode&1){var x=rb(s);if(x!==null){!(x.flags&65536)&&(x.flags|=256),ib(x,s,a,o,t),sg(Xs(l,a));break e}}o=l=Xs(l,a),Yt!==4&&(Yt=2),rl===null?rl=[o]:rl.push(o),o=s;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var y=G_(o,l,t);Jy(o,y);break e;case 1:a=l;var b=o.type,w=o.stateNode;if(!(o.flags&128)&&(typeof b.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&($i===null||!$i.has(w)))){o.flags|=65536,t&=-t,o.lanes|=t;var E=J_(o,a,t);Jy(o,E);break e}}o=o.return}while(o!==null)}mk(n)}catch(C){t=C,Ht===n&&n!==null&&(Ht=n=n.return);continue}break}while(!0)}function hk(){var e=rd.current;return rd.current=nd,e===null?nd:e}function Og(){(Yt===0||Yt===3||Yt===2)&&(Yt=4),en===null||!(Vo&268435455)&&!($d&268435455)||Li(en,on)}function sd(e,t){var n=Ke;Ke|=2;var r=hk();(en!==e||on!==t)&&(Zr=null,To(e,t));do try{Ij();break}catch(i){fk(e,i)}while(!0);if(lg(),Ke=n,rd.current=r,Ht!==null)throw Error(q(261));return en=null,on=0,Yt}function Ij(){for(;Ht!==null;)pk(Ht)}function Fj(){for(;Ht!==null&&!lC();)pk(Ht)}function pk(e){var t=vk(e.alternate,e,Gn);e.memoizedProps=e.pendingProps,t===null?mk(e):Ht=t,wg.current=null}function mk(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=Lj(n,t),n!==null){n.flags&=32767,Ht=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Yt=6,Ht=null;return}}else if(n=Rj(n,t,Gn),n!==null){Ht=n;return}if(t=t.sibling,t!==null){Ht=t;return}Ht=t=e}while(t!==null);Yt===0&&(Yt=5)}function So(e,t,n){var r=nt,i=pr.transition;try{pr.transition=null,nt=1,Nj(e,t,n,r)}finally{pr.transition=i,nt=r}return null}function Nj(e,t,n,r){do Us();while(Mi!==null);if(Ke&6)throw Error(q(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(q(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(yC(e,o),e===en&&(Ht=en=null,on=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Mc||(Mc=!0,yk(Uu,function(){return Us(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=pr.transition,pr.transition=null;var s=nt;nt=1;var a=Ke;Ke|=4,wg.current=null,Pj(e,n),ck(n,e),ij(wp),Wu=!!xp,wp=xp=null,e.current=n,Mj(n),cC(),Ke=a,nt=s,pr.transition=o}else e.current=n;if(Mc&&(Mc=!1,Mi=e,od=i),o=e.pendingLanes,o===0&&($i=null),fC(n.stateNode),Hn(e,zt()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(id)throw id=!1,e=Up,Up=null,e;return od&1&&e.tag!==0&&Us(),o=e.pendingLanes,o&1?e===Hp?il++:(il=0,Hp=e):il=0,so(),null}function Us(){if(Mi!==null){var e=G0(od),t=pr.transition,n=nt;try{if(pr.transition=null,nt=16>e?16:e,Mi===null)var r=!1;else{if(e=Mi,Mi=null,od=0,Ke&6)throw Error(q(331));var i=Ke;for(Ke|=4,ue=e.current;ue!==null;){var o=ue,s=o.child;if(ue.flags&16){var a=o.deletions;if(a!==null){for(var l=0;l<a.length;l++){var c=a[l];for(ue=c;ue!==null;){var u=ue;switch(u.tag){case 0:case 11:case 15:nl(8,u,o)}var d=u.child;if(d!==null)d.return=u,ue=d;else for(;ue!==null;){u=ue;var f=u.sibling,h=u.return;if(sk(u),u===c){ue=null;break}if(f!==null){f.return=h,ue=f;break}ue=h}}}var g=o.alternate;if(g!==null){var m=g.child;if(m!==null){g.child=null;do{var x=m.sibling;m.sibling=null,m=x}while(m!==null)}}ue=o}}if(o.subtreeFlags&2064&&s!==null)s.return=o,ue=s;else e:for(;ue!==null;){if(o=ue,o.flags&2048)switch(o.tag){case 0:case 11:case 15:nl(9,o,o.return)}var y=o.sibling;if(y!==null){y.return=o.return,ue=y;break e}ue=o.return}}var b=e.current;for(ue=b;ue!==null;){s=ue;var w=s.child;if(s.subtreeFlags&2064&&w!==null)w.return=s,ue=w;else e:for(s=b;ue!==null;){if(a=ue,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:qd(9,a)}}catch(C){Tt(a,a.return,C)}if(a===s){ue=null;break e}var E=a.sibling;if(E!==null){E.return=a.return,ue=E;break e}ue=a.return}}if(Ke=i,so(),Hr&&typeof Hr.onPostCommitFiberRoot=="function")try{Hr.onPostCommitFiberRoot(Fd,e)}catch{}r=!0}return r}finally{nt=n,pr.transition=t}}return!1}function vb(e,t,n){t=Xs(n,t),t=G_(e,t,1),e=qi(e,t,1),t=jn(),e!==null&&(Gl(e,1,t),Hn(e,t))}function Tt(e,t,n){if(e.tag===3)vb(e,e,n);else for(;t!==null;){if(t.tag===3){vb(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&($i===null||!$i.has(r))){e=Xs(n,e),e=J_(t,e,1),t=qi(t,e,1),e=jn(),t!==null&&(Gl(t,1,e),Hn(t,e));break}}t=t.return}}function zj(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=jn(),e.pingedLanes|=e.suspendedLanes&n,en===e&&(on&n)===n&&(Yt===4||Yt===3&&(on&130023424)===on&&500>zt()-kg?To(e,0):_g|=n),Hn(e,t)}function gk(e,t){t===0&&(e.mode&1?(t=kc,kc<<=1,!(kc&130023424)&&(kc=4194304)):t=1);var n=jn();e=gi(e,t),e!==null&&(Gl(e,t,n),Hn(e,n))}function Bj(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gk(e,n)}function Uj(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(q(314))}r!==null&&r.delete(t),gk(e,n)}var vk;vk=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Bn.current)zn=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return zn=!1,jj(e,t,n);zn=!!(e.flags&131072)}else zn=!1,xt&&t.flags&1048576&&w_(t,Ju,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;yu(e,t),e=t.pendingProps;var i=Ks(t,xn.current);Bs(t,n),i=gg(null,t,r,e,i,n);var o=vg();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Un(r)?(o=!0,Yu(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,dg(t),i.updater=Vd,t.stateNode=i,i._reactInternals=t,Lp(t,r,e,n),t=Mp(null,t,r,!0,o,n)):(t.tag=0,xt&&o&&ig(t),Cn(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(yu(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=Wj(r),e=xr(r,e),i){case 0:t=Pp(null,t,r,e,n);break e;case 1:t=ab(null,t,r,e,n);break e;case 11:t=ob(null,t,r,e,n);break e;case 14:t=sb(null,t,r,xr(r.type,e),n);break e}throw Error(q(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:xr(r,i),Pp(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:xr(r,i),ab(e,t,r,i,n);case 3:e:{if(ek(t),e===null)throw Error(q(387));r=t.pendingProps,o=t.memoizedState,i=o.element,C_(e,t),Zu(t,r,null,n);var s=t.memoizedState;if(r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=Xs(Error(q(423)),t),t=lb(e,t,r,n,i);break e}else if(r!==i){i=Xs(Error(q(424)),t),t=lb(e,t,r,n,i);break e}else for(Zn=Vi(t.stateNode.containerInfo.firstChild),er=t,xt=!0,_r=null,n=E_(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ys(),r===i){t=vi(e,t,n);break e}Cn(e,t,r,n)}t=t.child}return t;case 5:return j_(t),e===null&&Cp(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,s=i.children,_p(r,i)?s=null:o!==null&&_p(r,o)&&(t.flags|=32),Z_(e,t),Cn(e,t,s,n),t.child;case 6:return e===null&&Cp(t),null;case 13:return tk(e,t,n);case 4:return fg(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Gs(t,null,r,n):Cn(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:xr(r,i),ob(e,t,r,i,n);case 7:return Cn(e,t,t.pendingProps,n),t.child;case 8:return Cn(e,t,t.pendingProps.children,n),t.child;case 12:return Cn(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,s=i.value,ft(Xu,r._currentValue),r._currentValue=s,o!==null)if(Lr(o.value,s)){if(o.children===i.children&&!Bn.current){t=vi(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var a=o.dependencies;if(a!==null){s=o.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(o.tag===1){l=ci(-1,n&-n),l.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),jp(o.return,n,t),a.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(q(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),jp(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Cn(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Bs(t,n),i=mr(i),r=r(i),t.flags|=1,Cn(e,t,r,n),t.child;case 14:return r=t.type,i=xr(r,t.pendingProps),i=xr(r.type,i),sb(e,t,r,i,n);case 15:return X_(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:xr(r,i),yu(e,t),t.tag=1,Un(r)?(e=!0,Yu(t)):e=!1,Bs(t,n),Y_(t,r,i),Lp(t,r,i,n),Mp(null,t,r,!0,e,n);case 19:return nk(e,t,n);case 22:return Q_(e,t,n)}throw Error(q(156,t.tag))};function yk(e,t){return q0(e,t)}function Hj(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fr(e,t,n,r){return new Hj(e,t,n,r)}function Cg(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wj(e){if(typeof e=="function")return Cg(e)?1:0;if(e!=null){if(e=e.$$typeof,e===$m)return 11;if(e===Km)return 14}return 2}function Yi(e,t){var n=e.alternate;return n===null?(n=fr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function wu(e,t,n,r,i,o){var s=2;if(r=e,typeof e=="function")Cg(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case bs:return Do(n.children,i,o,t);case qm:s=8,i|=8;break;case ep:return e=fr(12,n,t,i|2),e.elementType=ep,e.lanes=o,e;case tp:return e=fr(13,n,t,i),e.elementType=tp,e.lanes=o,e;case np:return e=fr(19,n,t,i),e.elementType=np,e.lanes=o,e;case j0:return Kd(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case O0:s=10;break e;case C0:s=9;break e;case $m:s=11;break e;case Km:s=14;break e;case Ci:s=16,r=null;break e}throw Error(q(130,e==null?e:typeof e,""))}return t=fr(s,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function Do(e,t,n,r){return e=fr(7,e,r,t),e.lanes=n,e}function Kd(e,t,n,r){return e=fr(22,e,r,t),e.elementType=j0,e.lanes=n,e.stateNode={isHidden:!1},e}function dh(e,t,n){return e=fr(6,e,null,t),e.lanes=n,e}function fh(e,t,n){return t=fr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Vj(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=$f(0),this.expirationTimes=$f(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$f(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function jg(e,t,n,r,i,o,s,a,l){return e=new Vj(e,t,n,a,l),t===1?(t=1,o===!0&&(t|=8)):t=0,o=fr(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},dg(o),e}function qj(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ys,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function bk(e){if(!e)return Qi;e=e._reactInternals;e:{if(Zo(e)!==e||e.tag!==1)throw Error(q(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Un(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(q(171))}if(e.tag===1){var n=e.type;if(Un(n))return b_(e,n,t)}return t}function xk(e,t,n,r,i,o,s,a,l){return e=jg(n,r,!0,e,i,o,s,a,l),e.context=bk(null),n=e.current,r=jn(),i=Ki(n),o=ci(r,i),o.callback=t??null,qi(n,o,i),e.current.lanes=i,Gl(e,i,r),Hn(e,r),e}function Yd(e,t,n,r){var i=t.current,o=jn(),s=Ki(i);return n=bk(n),t.context===null?t.context=n:t.pendingContext=n,t=ci(o,s),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=qi(i,t,s),e!==null&&(Cr(e,i,s,o),mu(e,i,s)),s}function ad(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function yb(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Rg(e,t){yb(e,t),(e=e.alternate)&&yb(e,t)}function $j(){return null}var wk=typeof reportError=="function"?reportError:function(e){console.error(e)};function Lg(e){this._internalRoot=e}Gd.prototype.render=Lg.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(q(409));Yd(e,t,null,null)};Gd.prototype.unmount=Lg.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;qo(function(){Yd(null,e,null,null)}),t[mi]=null}};function Gd(e){this._internalRoot=e}Gd.prototype.unstable_scheduleHydration=function(e){if(e){var t=Q0();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ri.length&&t!==0&&t<Ri[n].priority;n++);Ri.splice(n,0,e),n===0&&e_(e)}};function Ag(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Jd(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function bb(){}function Kj(e,t,n,r,i){if(i){if(typeof r=="function"){var o=r;r=function(){var c=ad(s);o.call(c)}}var s=xk(t,r,e,0,null,!1,!1,"",bb);return e._reactRootContainer=s,e[mi]=s.current,kl(e.nodeType===8?e.parentNode:e),qo(),s}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var a=r;r=function(){var c=ad(l);a.call(c)}}var l=jg(e,0,!1,null,null,!1,!1,"",bb);return e._reactRootContainer=l,e[mi]=l.current,kl(e.nodeType===8?e.parentNode:e),qo(function(){Yd(t,l,n,r)}),l}function Xd(e,t,n,r,i){var o=n._reactRootContainer;if(o){var s=o;if(typeof i=="function"){var a=i;i=function(){var l=ad(s);a.call(l)}}Yd(t,s,e,i)}else s=Kj(n,t,e,i,r);return ad(s)}J0=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Fa(t.pendingLanes);n!==0&&(Jm(t,n|1),Hn(t,zt()),!(Ke&6)&&(Qs=zt()+500,so()))}break;case 13:qo(function(){var r=gi(e,1);if(r!==null){var i=jn();Cr(r,e,1,i)}}),Rg(e,1)}};Xm=function(e){if(e.tag===13){var t=gi(e,134217728);if(t!==null){var n=jn();Cr(t,e,134217728,n)}Rg(e,134217728)}};X0=function(e){if(e.tag===13){var t=Ki(e),n=gi(e,t);if(n!==null){var r=jn();Cr(n,e,t,r)}Rg(e,t)}};Q0=function(){return nt};Z0=function(e,t){var n=nt;try{return nt=e,t()}finally{nt=n}};fp=function(e,t,n){switch(t){case"input":if(op(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=Ud(r);if(!i)throw Error(q(90));L0(r),op(r,i)}}}break;case"textarea":P0(e,n);break;case"select":t=n.value,t!=null&&Is(e,!!n.multiple,t,!1)}};z0=Sg;B0=qo;var Yj={usingClientEntryPoint:!1,Events:[Xl,ks,Ud,F0,N0,Sg]},ka={findFiberByHostInstance:Co,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Gj={bundleType:ka.bundleType,version:ka.version,rendererPackageName:ka.rendererPackageName,rendererConfig:ka.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:xi.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=W0(e),e===null?null:e.stateNode},findFiberByHostInstance:ka.findFiberByHostInstance||$j,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Tc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Tc.isDisabled&&Tc.supportsFiber)try{Fd=Tc.inject(Gj),Hr=Tc}catch{}}nr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Yj;nr.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ag(t))throw Error(q(200));return qj(e,t,null,n)};nr.createRoot=function(e,t){if(!Ag(e))throw Error(q(299));var n=!1,r="",i=wk;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=jg(e,1,!1,null,null,n,!1,r,i),e[mi]=t.current,kl(e.nodeType===8?e.parentNode:e),new Lg(t)};nr.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(q(188)):(e=Object.keys(e).join(","),Error(q(268,e)));return e=W0(t),e=e===null?null:e.stateNode,e};nr.flushSync=function(e){return qo(e)};nr.hydrate=function(e,t,n){if(!Jd(t))throw Error(q(200));return Xd(null,e,t,!0,n)};nr.hydrateRoot=function(e,t,n){if(!Ag(e))throw Error(q(405));var r=n!=null&&n.hydratedSources||null,i=!1,o="",s=wk;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=xk(t,null,e,1,n??null,i,!1,o,s),e[mi]=t.current,kl(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new Gd(t)};nr.render=function(e,t,n){if(!Jd(t))throw Error(q(200));return Xd(null,e,t,!1,n)};nr.unmountComponentAtNode=function(e){if(!Jd(e))throw Error(q(40));return e._reactRootContainer?(qo(function(){Xd(null,null,e,!1,function(){e._reactRootContainer=null,e[mi]=null})}),!0):!1};nr.unstable_batchedUpdates=Sg;nr.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Jd(n))throw Error(q(200));if(e==null||e._reactInternals===void 0)throw Error(q(38));return Xd(e,t,n,!1,r)};nr.version="18.3.1-next-f1338f8080-20240426";function _k(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_k)}catch(e){console.error(e)}}_k(),_0.exports=nr;var Jj=_0.exports,Pg,xb=Jj;Pg=xb.createRoot,xb.hydrateRoot;var mo=Object.create(null);const Ee={on:function(e,t){mo[e]||(mo[e]=[]),mo[e].push(t)},off:function(e,t){mo[e]&&(mo[e]=mo[e].filter(function(n){return n!==t}))},emit:function(e,t){var n=mo[e];if(!(!n||!n.length))for(var r=n.slice(),i=0;i<r.length;i++)try{r[i](t)}catch(o){typeof console<"u"&&console.error&&console.error('[Bus] handler error on "'+e+'":',o)}},once:function(e,t){var n=this,r=function(i){n.off(e,r),t(i)};this.on(e,r)}},Xj=Object.freeze(["id","fromBigInt","fromRational","fromRationalStr","toCanonicalStr","add","subtract","multiply","divide","normalDivide","mod","equals","compare","pow","sqrt","exp2","log2","ppfEncodeInteger","ppfDecodeInteger","fromPPF","getIntegerBitLength","breakSymbolicToApproximateBigInt","breakSymbolicToApproximateJSNumber","breakSymbolicToString","toPrimeAtoms","fromAtomVec","toAtomRoot","fromAtomRoot","gcd","lcm","modPow","polyAdd","polyMul","polyDiv","polyForwardTransform","polyInverseTransform","polyEvaluateAt","polyGcd","isHandle"]);class Dc extends Error{constructor(t){super(t),this.name="MathBackendRegistrationError"}}class Qj extends Error{constructor(t){super(`MathBackendProvider: '${t}' is not registered. Load the provider module before calling select(). Do not fall back to js-reference — request wasm explicitly only when wasm is loaded.`),this.name="MathBackendNotAvailableError",this.requestedId=t}}class Zj{constructor(){this._providers=new Map,this._activeId=null,this._listeners=new Set}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_notify(){for(const t of this._listeners)try{t()}catch(n){console.error("[MathBackendRegistry] subscriber threw:",n)}}register(t){if(!t||typeof t!="object")throw new Dc("MathBackendProvider.register: provider must be a plain object.");const n=t.id;if(typeof n!="string"||!n)throw new Dc("MathBackendProvider.register: provider.id must be a non-empty string.");const r=[];for(const i of Xj)i!=="id"&&typeof t[i]!="function"&&r.push(i);if(r.length>0)throw new Dc(`MathBackendProvider.register('${n}'): missing required method(s): ${r.join(", ")}. Every provider must implement the full op surface (README.md §1).`);if(this._providers.has(n)){if(this._providers.get(n)===t)return;throw new Dc(`MathBackendProvider.register('${n}'): a DIFFERENT provider object is already registered under '${n}' — two math provider bundles were evaluated in one realm. One realm holds one provider per id: find the second module instance (a second bundle of the provider module, or a second copy of the registry it was built against).`)}this._providers.set(n,t),this._activeId===null&&(this._activeId=n),this._notify()}select(t){if(!this._providers.has(t))throw new Qj(t);this._activeId=t,this._notify()}active(){if(this._activeId===null||!this._providers.has(this._activeId))throw new Error("MathBackendProvider: no active provider. Two doors: import the JS reference barrel (lib/egpt/js/model/index.browser.js, which registers js-reference — or, below the barrel, lib/egpt/js/model/backend/JsReferenceMathBackendProvider.js), or register a provider (MathBackendRegistry.register; in a realm, Runtime.ensureMath registers the math sdk's sdk.mathBackendProvider).");return this._providers.get(this._activeId)}activeId(){return this.active().id}registeredIds(){return[...this._providers.keys()]}resetScope(){if(this._activeId!==null&&this._providers.has(this._activeId)){const t=this._providers.get(this._activeId);typeof t.resetScope=="function"&&t.resetScope()}}}const st=new Zj,wb=Object.freeze({parts:"parts/index.js",app:"objects/FrqtlApp.js",recipe:"objects/RecipeContext.js",engine:"compat/engine.js",display:"compat/renderer/display-slot.js",QuantumEmitter:"objects/objects/QuantumEmitter.js",Box:"objects/objects/Box.js",CircuitGate:"objects/objects/CircuitGate.js",CircuitProbe:"objects/objects/CircuitProbe.js"});function kk(e){if(!e||typeof e.resolve!="function")return Promise.reject(new Error("[engine-stack-boot] ensureEngineStack requires a router (an engineRouter() instance with .resolve, not a bare resolve function). (FAIL-LOUD.)"));function t(n){return new URL(e.resolve(n),document.baseURI).href}return Promise.all([import(t("experiments/_shared/boot.js")),import(t("experiments/_shared/page-door.js"))]).then(function(n){return n[1].refuseRetiredGlobals(),n[0].bootRealm()}).then(function(){var n=Object.keys(wb);return Promise.all(n.map(function(r){return import(t(wb[r]))})).then(function(r){var i={};return n.forEach(function(o,s){i[o]=r[s]}),Object.freeze(i)})})}const _b={"gallery-wave-interference":{spec:"setupWaveInterference",knob:{label:"Particles",param:"quanta",min:100,max:2e3,step:100,defaultValue:800}}};var eR={quanta:"quantumLimit"},tR=function(){for(var e=Object.create(null),t=Object.keys(_b),n=0;n<t.length;n++){var r=_b[t[n]];if(!(!r||!r.spec||!r.knob)){if(e[r.spec])throw new Error('[notebook/knob] duplicate knob spec "'+r.spec+'" across notebooks ('+t[n]+" collides with an earlier entry). (FAIL-LOUD.)");e[r.spec]=r.knob}}return e}();function nR(e){if(!e)return null;var t=String(e).split(",").pop().trim();return tR[t]||null}function rR(e,t){var n=t?Object.keys(t):[];if(n.length===0)return{};var r=nR(e);if(!r)throw new Error('[notebook/knob] cell spec "'+e+'" defines NO knob, but opts declares '+JSON.stringify(n)+". (FAIL-LOUD — no silent ignore.)");for(var i={},o=0;o<n.length;o++){var s=n[o];if(s!==r.param)throw new Error('[notebook/knob] unknown knob key "'+s+'" for spec "'+e+'" — the only knob is "'+r.param+'". (FAIL-LOUD; not silently ignored.)');var a=t[s];if(typeof a!="number"||!isFinite(a))throw new Error('[notebook/knob] knob "'+s+'" value is not a finite number: '+JSON.stringify(a)+". (FAIL-LOUD.)");if(a<r.min||a>r.max)throw new Error('[notebook/knob] knob "'+s+'"='+a+" is out of range ["+r.min+", "+r.max+'] for spec "'+e+'". (FAIL-LOUD.)');var l=eR[s];if(!l)throw new Error('[notebook/knob] knob param "'+s+'" has NO factory-option wire in PARAM_TO_FACTORY_OPTION — a hint-only knob is forbidden. (FAIL-LOUD.)');i[l]=a}return i}function $o(e){for(var t=String(e).split("/"),n=[],r=0;r<t.length;r++){var i=t[r];if(!(i===""||i===".")){if(i===".."){n.pop();continue}n.push(i)}}return n.join("/")}function Sk(e,t){var n=$o(t).split("/");n.pop();var r=n.join("/"),i=r?r+"/"+e:e;return $o(i)}function iR(e){return/(^|\n)\s*import\s/.test(String(e))}function oR(e){for(var t=String(e).split(`
41
+ `),n=[],r=0,i=!1,o=0;o<t.length;o++){var s=t[o].replace(/^\s+/,"");if(i){n.push(t[o]),r=o+1,(/from\s+['"][^'"]+['"]/.test(t[o])||/;\s*$/.test(t[o]))&&(i=!1);continue}if(s===""){n.push(t[o]),r=o+1;continue}if(/^\/\//.test(s)||/^\/\*.*\*\/\s*$/.test(s)){n.push(t[o]),r=o+1;continue}if(/^import\s/.test(s)){n.push(t[o]),r=o+1,!/from\s+['"][^'"]+['"]/.test(t[o])&&!/;\s*$/.test(t[o])&&(i=!0);continue}break}return{imports:n.join(`
42
+ `),body:t.slice(r).join(`
43
+ `)}}function Ek(e,t,n){function r(o){var s=Sk(o,t),a=n[s];if(!a)throw new Error('[module-resolver] relative import "'+o+'" (from "'+t+'") resolves to "'+s+'", which is NOT a notebook-local module cell. Add a <cell type="module" name="'+o+'">, or fix the path. (FAIL-LOUD — never an HTTP sibling fetch.)');return a}var i=String(e).replace(/from\s+(['"])([^'"]+)\1/g,function(o,s,a){return a.charAt(0)!=="."?o:"from "+s+r(a)+s});return i=i.replace(/import\(\s*(['"])([^'"]+)\1\s*\)/g,function(o,s,a){return a.charAt(0)!=="."?o:"import("+s+r(a)+s+")"}),i}function sR(e,t){var n=[];return String(t).replace(/from\s+(['"])([^'"]+)\1/g,function(r,i,o){return o.charAt(0)==="."&&n.push(Sk(o,e)),r}),n}function aR(e,t){if(typeof t!="function")throw new Error("[module-resolver] buildModuleClosure requires a mintBlobUrl(source) function.");for(var n=Object.create(null),r=Object.keys(e||{}),i=0;i<r.length;i++)n[$o(r[i])]={name:r[i],source:e[r[i]]};for(var o=Object.create(null),s=[],a=Object.keys(n),l=0;a.length>0;){if(l++>1e5)throw new Error("[module-resolver] module closure did not converge (cycle?). (FAIL-LOUD.)");for(var c=!1,u=[],d=0;d<a.length;d++){for(var f=a[d],h=n[f],g=sR(h.name,h.source),m=!0,x=0;x<g.length;x++)if(!o[g[x]]){if(!n[g[x]])throw new Error('[module-resolver] module "'+h.name+'" imports "'+g[x]+'" which is not in the notebook module set. (FAIL-LOUD.)');m=!1;break}if(!m){u.push(f);continue}var y=Ek(h.source,h.name,o),b=t(y);o[f]=b,s.push(b),c=!0}if(a=u,!c&&a.length>0)throw new Error("[module-resolver] unresolvable module closure (dependency cycle among "+a.join(", ")+"). (FAIL-LOUD.)")}return{blobUrlByKey:o,created:s}}function lR(e,t,n){var r=Ek(e,t,n),i=oR(r);return i.imports+`
44
+ export default async (caps, inputs) => {
45
+ `+i.body+`
46
+ };
47
+ `}var oi=null,Ls=null,Ai="",za="",As="",Ps=null,qp=null,_u=null,Ic=null,jt={log:function(e,t){Ee.emit("console:write",{level:e||"info",text:String(t)})},print:function(e){Ee.emit("console:write",{level:"info",text:String(e)})},warn:function(e){Ee.emit("console:write",{level:"warn",text:String(e)})},error:function(e){Ee.emit("console:write",{level:"error",text:String(e)})},clear:function(){Ee.emit("console:clear",{})}},Qd={frame:function(e){Ee.emit("render:frame",{universe:e,tickData:e})},start:function(){Ee.emit("render:frame",{cmd:"start"})},stop:function(){Ee.emit("render:frame",{cmd:"stop"})}},Ok=Object.freeze({FrqtlApp:["app","FrqtlApp"],RecipeContext:["recipe","RecipeContext"],PointSource:["parts","PointSource"],LargeObject:["parts","LargeObject"],Wall:["parts","Wall"],SlitScreen:["parts","SlitScreen"],SlitLightSource:["parts","SlitLightSource"],DetectorWall:["parts","DetectorWall"],OvenBox:["parts","OvenBox"],Rectangle:["parts","Rectangle"],CollisionTypes:["parts","CollisionTypes"],CollisionActions:["parts","CollisionActions"],QuantumEmitter:["QuantumEmitter","QuantumEmitter"],Box:["Box","Box"],CircuitGate:["CircuitGate","CircuitGate"],CircuitProbe:["CircuitProbe","CircuitProbe"],Frame:["engine","Frame"],Charge:["engine","Charge"],Universe:["engine","EGPTUniverse"]});function ku(e){var t=Ok[e];if(!t)throw new Error('[frqtl] caps.frqtl has no member "'+e+'". (FAIL-LOUD.)');if(!_u)throw new Error('[frqtl] "'+e+'" is not available — the engine/game layer is not booted yet. A builder cell must `await frqtl.ensureEngine()` before it reads caps.frqtl (or before it calls a setup module that does). (FAIL-LOUD.)');var n=t[0]==="engine"?_u.engine.engine()[t[1]]:_u[t[0]][t[1]];if(n==null)throw new Error('[frqtl] the realm module for "'+e+'" exports no '+t[1]+". (FAIL-LOUD.)");return n}var Zs={FrqtlApp:function(e){return new(ku("FrqtlApp"))(e)},carryFactoryStatics:function(e,t){return ku("FrqtlApp").carryFactoryStatics(e,t)},RecipeContext:function(e){return new(ku("RecipeContext"))(e)},ensureEngine:function(){return qp?kk(qp).then(function(e){_u=e}):Promise.reject(new Error("[frqtl] ensureEngine unavailable: Runtime.init did not thread a router (_router). (FAIL-LOUD.)"))},knob:function(e,t){return rR(e,t||{})}};Object.keys(Ok).forEach(function(e){Object.prototype.hasOwnProperty.call(Zs,e)||Object.defineProperty(Zs,e,{enumerable:!0,get:function(){return ku(e)}})});function cR(e){e=e||{},Ai=e.mathSdkUrl||typeof window<"u"&&window._egptMathSdkUrl||e._routerMathSdkUrl||"",za=e.mathWasmUrl||e._routerMathWasmUrl||"",As=e.mathWasmModuleUrl||e._routerMathWasmModuleUrl||"",e.engine;var t=e.mathBackend||e._routerMathBackend||null;t==="wasm"&&(t="wasm-math"),Ps=t,e._router&&typeof e._router.resolve=="function"&&(qp=e._router);var n=null,r=null;if(oi)try{Rk(oi)}catch(o){xR(o),n=o}else Ps&&Ps!=="js-reference"&&(r=Zd());Ic&&Ee.off("run:request",Ic),Ic=function(o){Ck({source:o.source,code:o.code,fileId:o.fileId,sourceUrl:o.sourceUrl||null})},Ee.on("run:request",Ic);var i=n?Promise.reject(n):Promise.resolve();return r?Promise.all([i,r.catch(function(o){throw console.error('[Runtime] eager math SDK load for backend "'+Ps+'" failed:',o),o})]).then(function(){}):i}function Ck(e){e=e||{};var t=e.source||"frqtl",n=e.code||"",r=e.fileId||"_editor",i=e.sourceUrl||null;jt.clear(),jt.log("info","--- run:"+t+" ("+r+") ---"),t==="math"?dR(n,r,i):($p(),uR(n))}function $p(){var e;try{e=st.active().id}catch{e="none"}jt.log("info","backend: "+e)}function uR(e,t){try{var n=new Function("frqtl","math","console","render",e);n(Zs,oi,jt,Qd),Ee.emit("run:result",{source:"frqtl",ok:!0})}catch(i){var r=i&&i.message?i.message:String(i);jt.error(r),Ee.emit("run:result",{source:"frqtl",ok:!1,error:r})}}function dR(e,t,n){Zd().then(function(r){if($p(),fR(e))return pR(e,r,n).then(function(){Ee.emit("run:result",{source:"math",ok:!0})}).catch(function(s){var a=s&&s.message?s.message:String(s);jt.error(a),Ee.emit("run:result",{source:"math",ok:!1,error:a})});try{var i=new Function("frqtl","math","console","render",e);i(Zs,r,jt,Qd),Ee.emit("run:result",{source:"math",ok:!0})}catch(s){var o=s&&s.message?s.message:String(s);jt.error(o),Ee.emit("run:result",{source:"math",ok:!1,error:o})}},function(r){$p();var i="Math SDK init failed: "+(r&&r.message?r.message:String(r));jt.error(i),Ee.emit("run:result",{source:"math",ok:!1,error:i})}).finally(function(){jk()})}function jk(){st.resetScope()}function fR(e){return/^\s*(import|export)\s/m.test(e)}function hR(e,t,n,r){return e.replace(/from\s+(['"])([^'"]+)\1/g,function(i,o,s){return/^(https?:|blob:|data:)/.test(s)?i:s==="node:test"?"from '"+new URL("./shims/node-test.js",n).toString()+"'":s==="node:assert"?"from '"+new URL("./shims/node-assert.js",n).toString()+"'":s==="./EGPTTestSuite.js"?"from '"+new URL("./shims/test-framework.js",n).toString()+"'":s.indexOf("/core/")!==-1||s.indexOf("/stat/")!==-1||s.indexOf("/spaces/log/")!==-1||s.indexOf("/translators/")!==-1||/\/index\.js$/.test(s)?"from '"+t+"'":s.indexOf("./")===0&&r?"from '"+new URL(s,r).toString()+"'":"from '"+new URL(s,n).toString()+"'"})}function pR(e,t,n){var r=new URL(Ai,window.location.href).toString(),i=new URL(Ai.replace(/\/index\.js$/,"/editor/"),window.location.href).toString(),o=n?new URL("./",new URL(n,window.location.href)).toString():null,s=hR(e,r,i,o),a=new Blob([s],{type:"application/javascript"}),l=URL.createObjectURL(a),c=console.log,u=!1;return console.log=function(){if(u){c.apply(console,arguments);return}u=!0;try{var d=Array.prototype.map.call(arguments,function(f){try{return typeof f=="object"?JSON.stringify(f):String(f)}catch{return String(f)}});jt.print(d.join(" "))}finally{u=!1}c.apply(console,arguments)},import(l).then(function(d){if(typeof d.run!="function"){jt.print("(module executed on import — no run(sdk) export)");return}return d.run(t)}).then(function(d){d!==void 0&&jt.print(typeof d=="object"?JSON.stringify(d,null,2):String(d))}).finally(function(){console.log=c,URL.revokeObjectURL(l)})}function mR(e,t,n){var r={};if(!n||!n.length)return r;for(var i=t&&typeof t=="object"?t:{},o=0;o<n.length;o++){var s=n[o];if(!Object.prototype.hasOwnProperty.call(i,s))throw new Error('[Runtime.runCell] cell "'+e+'" declares output "'+s+'" but its returned object does not contain that key. A js cell must `return { '+s+": …, … }` for every declared out — never silently write undefined into a binding (FAIL-LOUD).");r[s]=i[s]}return r}function gR(e,t,n){var r=n||function(i){try{jt.print(typeof i=="object"?JSON.stringify(i,null,2):String(i))}catch{jt.print(String(i))}};return e==="frqtl"?{frqtl:Zs,render:Qd,math:t,console:jt,display:r}:{math:t,console:jt,display:r}}function vR(){var e={log:console.log,warn:console.warn,error:console.error},t=!1;function n(i){return Array.prototype.map.call(i,function(o){try{return typeof o=="object"?JSON.stringify(o):String(o)}catch{return String(o)}}).join(" ")}function r(i,o){return function(){if(t){e[i].apply(console,arguments);return}t=!0;try{o(n(arguments))}finally{t=!1}e[i].apply(console,arguments)}}return console.log=r("log",function(i){jt.print(i)}),console.warn=r("warn",function(i){jt.warn(i)}),console.error=r("error",function(i){jt.error(i)}),function(){console.log=e.log,console.warn=e.warn,console.error=e.error}}function kb(e){var t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function yR(e,t,n,r,i){var o=aR(n,kb),s="__cell__-"+t+".js",a=lR(e,s,o.blobUrlByKey),l=kb(a),c=o.created.concat([l]);function u(){for(var d=0;d<c.length;d++)try{URL.revokeObjectURL(c[d])}catch{}}return import(l).then(function(d){if(typeof d.default!="function")throw new Error('[Runtime.runCell] cell-as-module: compiled entry for cell "'+t+'" has no default export wrapper (internal). (FAIL-LOUD.)');return d.default(r,i)}).finally(u)}function bR(e){e=e||{};var t=e.lane||"math",n=e.code||"",r=e.id||"_cell",i=e.inputs||{},o=e.declaredOutputs||[],s=e.display||null,a=e.modules||{},l=!!e.forceModulePath;return Zd().then(function(c){var u=vR();return Promise.resolve().then(function(){var d=gR(t,c,s);if(l||iR(n))return yR(n,r,a,d,i);var f=`return (async (caps, inputs) => {
48
+ `+n+`
49
+ })(caps, inputs);`,h=new Function("caps","inputs",f);return h(d,i)}).then(function(d){var f=mR(r,d,o);return{outputs:f,ok:!0,error:null}}).catch(function(d){var f=d&&d.message?d.message:String(d);return jt.error(f),{outputs:{},ok:!1,error:f}}).finally(function(){u()})}).catch(function(c){var u="Math SDK init failed: "+(c&&c.message?c.message:String(c));return jt.error(u),{outputs:{},ok:!1,error:u}})}function Zd(e){if(e=e||{},oi)return Promise.resolve(oi);if(!Ai&&e.mathSdkUrl&&(Ai=e.mathSdkUrl),!za&&e.mathWasmUrl&&(za=e.mathWasmUrl),!As&&e.mathWasmModuleUrl&&(As=e.mathWasmModuleUrl),!oi&&e.mathBackend){var t=e.mathBackend;t==="wasm"&&(t="wasm-math"),Ps=t}if(Ls)return Ls;if(!Ai&&(typeof window>"u"||!window.createEgptMathSdk))return Promise.reject(new Error("[Runtime] Math SDK unavailable: no mathSdkUrl resolved from engineRouter profile or window._egptMathSdkUrl, and no window.createEgptMathSdk. Ensure Runtime.init() is called with a router that defines __mathSdkUrl."));var n=typeof window<"u"&&window.createEgptMathSdk?window.createEgptMathSdk({wasmUrl:za||void 0,wasmModuleUrl:As||void 0}):import(Ai).then(function(r){var i=r.createEgptMathSdk;if(typeof i!="function")throw new Error("createEgptMathSdk not exported from "+Ai);return i({wasmUrl:za||void 0,wasmModuleUrl:As||void 0})});return Ls=n.then(function(r){return wR(r),Rk(),oi=r,r}),Ls}function xR(e){oi=null,Ls=Promise.reject(e),Ls.catch(function(){})}function wR(e){var t=e&&e.mathBackendProvider;!t||typeof t!="object"||typeof t.id!="string"||st.register(t)}function Rk(e){var t=Ps;if(t)try{st.select(t),console.log("[Runtime] Math backend selected: "+t)}catch(i){var n="";t==="wasm-math"&&!As&&(n=" No wasmModuleUrl was configured — the engineRouter profile __mathWasmModuleUrl is empty or was not threaded into Runtime.");var r='[Runtime] Math backend selection FAILED for id="'+t+'": '+(i&&i.message?i.message:String(i))+"."+n+" Never falls back silently to js-reference (FAIL-LOUD).";throw jt.error(r),new Error(r,{cause:i})}}const ui={init:cR,run:Ck,runCell:bR,resetMathScope:jk,ensureMath:Zd,get frqtl(){return Zs},get math(){return oi},get console(){return jt},get render(){return Qd}};var Su=Object.freeze(["data-egpt-boot-phase","data-egpt-boot-progress"]),Lk="#root",Ms=Object.freeze({OK:"ok",PENDING:"pending",CROSS_ORIGIN:"cross-origin",SPA_SHELL:"spa-shell",NOT_EXPERIMENT:"not-an-experiment-page"}),Ak=1e4;function _R(e){var t=e||{},n=t.src||"(unknown src)",r=typeof t.href=="string"?t.href:"",i=Array.isArray(t.markers)?t.markers:[],o=typeof t.timeoutMs=="number"?t.timeoutMs:Ak,s=typeof t.elapsedMs=="number"?t.elapsedMs:0;if(t.sameOrigin===!1)return Ts(Ms.CROSS_ORIGIN,!1,!0,`the experiment frame is CROSS-ORIGIN, so the host cannot verify what loaded.
50
+ requested: `+n+`
51
+ Experiment pages must be served from the host's own origin (the /frqtl mount).`);if(r===""||r==="about:blank")return Sb(s,o,n,"the frame is still on about:blank — it never navigated to the requested URL.");var a=Su.filter(function(l){return i.indexOf(l)===-1});return a.length===0?Ts(Ms.OK,!0,!0,"experiment page booted: "+n):t.hasHostShellRoot===!0?Ts(Ms.SPA_SHELL,!1,!0,`THE FALSE-200 TRAP: the request returned HTTP 200 text/html, but the document is the
52
+ HOST'S OWN SPA SHELL (it has `+Lk+` and none of the experiment-page
53
+ boot markers [`+Su.join(", ")+`]).
54
+ requested: `+n+`
55
+ loaded: `+r+`
56
+ The dev server answers an UNKNOWN path with its SPA fallback, so a MISSING experiment id
57
+ looks like a successful load and this host ends up embedding ITSELF, recursively.
58
+ Fix the id at its single declaration site — do not add a fallback id here.`):t.readyState==="complete"?Ts(Ms.NOT_EXPERIMENT,!1,!0,`the frame finished loading but it is NOT a canonical experiment page.
59
+ requested: `+n+`
60
+ loaded: `+r+`
61
+ missing boot markers: [`+a.join(", ")+`]
62
+ A canonical experiment page boots through _shared/boot.js, whose boot record writes all of
63
+ [`+Su.join(", ")+"] on its <html> as the boot begins."):Sb(s,o,n,"missing boot markers: ["+a.join(", ")+"] (document readyState="+(t.readyState||"unknown")+").")}function Ts(e,t,n,r){return{verdict:e,ok:t,done:n,message:"[experiment-frame] "+r}}function Sb(e,t,n,r){return e>=t?Ts(Ms.NOT_EXPERIMENT,!1,!0,"the frame never became a canonical experiment page within "+t+`ms.
64
+ requested: `+n+`
65
+ `+r):Ts(Ms.PENDING,!1,!1,"waiting for "+n+" — "+r)}function kR(e,t){var n=t||{},r={src:e&&e.src?e.src:"",href:"",sameOrigin:!0,readyState:void 0,markers:[],hasHostShellRoot:!1,elapsedMs:n.elapsedMs,timeoutMs:n.timeoutMs},i=null;try{if(i=e&&e.contentWindow,!i)return r;r.href=i.location&&i.location.href||"";var o=i.document;r.readyState=o?o.readyState:void 0;var s=o&&o.documentElement;r.markers=Su.filter(function(a){return!!(s&&s.hasAttribute&&s.hasAttribute(a))}),r.hasHostShellRoot=!!(o&&o.querySelector&&o.querySelector(Lk))}catch{r.sameOrigin=!1}return r}function SR(e,t){var n=e||(typeof document<"u"?document.body:null);if(!n)return null;var r=n.querySelector&&n.querySelector('[data-role="experiment-frame-error"]');r&&r.parentNode.removeChild(r);var i=n.ownerDocument.createElement("div");return i.setAttribute("data-role","experiment-frame-error"),i.style.cssText="position:absolute;inset:0;z-index:9999;padding:16px;overflow:auto;white-space:pre-wrap;background:#1a0000;color:#ff6b6b;border:2px solid #b6161c;font:12px/1.55 ui-monospace,Menlo,Consolas,monospace;",i.textContent=t,n.style&&(!n.style.position||n.style.position==="static")&&(n.style.position="relative"),n.appendChild(i),i}function ER(e,t){var n=t||{},r=typeof n.timeoutMs=="number"?n.timeoutMs:Ak,i=typeof n.pollMs=="number"?n.pollMs:150,o=Date.now(),s=!1,a=setInterval(l,i);l();function l(){if(!s){var u=kR(e,{elapsedMs:Date.now()-o,timeoutMs:r}),d=_R(u);if(d.done){if(c(),d.ok){typeof n.onOk=="function"&&n.onOk(e.contentWindow);return}typeof console<"u"&&console.error&&console.error(d.message),SR(n.overlayHost||e&&e.parentNode,d.message),typeof n.onError=="function"&&n.onError(d)}}}function c(){s||(s=!0,clearInterval(a))}return c}const OR="pub",ld="data-frqtl-site-build",Eb=/^[0-9a-f]{8}$/,Ob=Object.freeze([Object.freeze({package:"@descix/frqtl-web",dir:""}),Object.freeze({package:"@descix/egpt-math-sdk",dir:"egpt-math-sdk"})]);var cd={__frqtlRoot:"/","assets/models/":"/frqtl/assets/models/","experiments/":"/frqtl/experiments/",__mathSdkUrl:"/egpt-src/index.js",__mathWasmUrl:"/egpt-src/wasm/egpt_math_sdk_wasm_bg.wasm",__mathWasmModuleUrl:"/egpt-src/wasm/egpt_math_sdk_wasm.js",__mathBackend:"js-reference",__notebookBase:"/notebooks",__vendorBase:"/vendor"};function CR(e){if(/\/$/.test(e))throw new Error('[engineRouter] buildDistProfile(base) takes a relative dist-root path with no trailing slash (e.g. "../.."), got '+JSON.stringify(e)+".");return{__frqtlRoot:e+"/","assets/models/":e+"/js/models/","experiments/":e+"/experiments/",__mathSdkUrl:e+"/../egpt-math-sdk/index.js",__mathWasmUrl:e+"/../egpt-math-sdk/wasm/egpt_math_sdk_wasm_bg.wasm",__mathWasmModuleUrl:e+"/../egpt-math-sdk/wasm/egpt_math_sdk_wasm.js",__mathBackend:"wasm-math",__notebookBase:e+"/../egpt-math-sdk/notebooks",__vendorBase:e+"/../egpt-math-sdk/vendor"}}var Kp=CR("../.."),Yp="0.7.0-p3",jR="0.3.3-p2.1";function Pk(e){if(typeof e!="string"||!e)throw new Error("[engineRouter] cdnDistBaseFor(version): a published @descix/frqtl-web version (got "+JSON.stringify(e)+").");return"https://cdn.jsdelivr.net/npm/@descix/frqtl-web@"+e+"/dist"}var Mk=Pk(Yp),Fc="https://cdn.jsdelivr.net/npm/@descix/egpt-math-sdk@"+jR+"/dist";function RR(e){var t=typeof e=="string"&&e!==""&&!/\/$/.test(e);if(t)try{new URL(e)}catch{t=!1}if(!t)throw new Error(`[engineRouter] mode:"cdn" opts.base must be the absolute URL of a copy of the package's dist/ directory, with no trailing slash (e.g. "https://example.org/vendor/frqtl-web/dist"); got `+JSON.stringify(e)+". From a page: new URL('./vendor/frqtl-web/dist', location.href).href. (FAIL-LOUD.)");return e}function Tk(e){return RR(e),{__frqtlRoot:e+"/","assets/models/":e+"/js/models/","experiments/":e+"/experiments/",__mathSdkUrl:Fc+"/index.js",__mathWasmUrl:Fc+"/wasm/egpt_math_sdk_wasm_bg.wasm",__mathWasmModuleUrl:Fc+"/wasm/egpt_math_sdk_wasm.js",__mathBackend:"wasm-math",__notebookBase:Fc+"/notebooks",__vendorBase:e+"/vendor"}}var Gp=Tk(Mk),LR="@descix/frqtl-web",AR="@descix/egpt-math-sdk";function Cb(e,t){var n=Ob.find(function(r){return r.package===t});if(!n)throw new Error("[engineRouter] no site-graph.js::SITE_PLACEMENTS row places "+t+" (rows: "+Ob.map(function(r){return r.package}).join(", ")+").");return n.dir?e+"/"+n.dir:e}function Jp(e,t){if(!e||!t)throw new Error("[engineRouter] buildStaticProfile(graphBase, entryBase) needs both bases (got "+JSON.stringify(e)+", "+JSON.stringify(t)+") — the graph and the entry pages are anchored separately; a co-served host passes the same base twice.");var n=Cb(e,LR),r=Cb(e,AR);return{__frqtlRoot:n+"/","assets/models/":n+"/js/models/","experiments/":t+"/experiments/",__mathSdkUrl:r+"/index.js",__mathWasmUrl:r+"/wasm/egpt_math_sdk_wasm_bg.wasm",__mathWasmModuleUrl:r+"/wasm/egpt_math_sdk_wasm.js",__mathBackend:"wasm-math",__notebookBase:n+"/notebooks",__vendorBase:n+"/vendor"}}var ef="./"+OR;function Dk(e){if(typeof e!="string"||!Eb.test(e))throw new Error("[engineRouter] the static site build id must match "+Eb+" (the bundle's <html "+ld+">), got "+JSON.stringify(e)+".");return e}function Mg(e){return ef+"/"+Dk(e)}function Tg(e){if(!e)throw new Error('[engineRouter] mode:"static" resolves against the document — no document.baseURI here. Outside a browser pass opts.documentBaseURI (the URL of the directory serving the static site).');return e}function PR(e,t){return new URL(Mg(t),Tg(e)).href}function MR(e){return new URL(ef,Tg(e)).href}function TR(){var e=typeof document<"u"&&document.documentElement&&typeof document.documentElement.getAttribute=="function"?document.documentElement.getAttribute(ld):null;if(!e)throw new Error('[engineRouter] mode:"static": this document carries no build stamp (<html '+ld+">) — only the assembled bundle's pages can resolve the stamped graph (make static-deploy).");return Dk(e)}var DR="app-assets",IR=DR+"/host-view.js";(function(){var e=Jp(Mg("00000000"),ef),t=Object.keys(cd).filter(function(o){return o.indexOf("__")!==0}).sort(),n=Object.keys(Kp).filter(function(o){return o.indexOf("__")!==0}).sort(),r=Object.keys(Gp).filter(function(o){return o.indexOf("__")!==0}).sort(),i=Object.keys(e).filter(function(o){return o.indexOf("__")!==0}).sort();if(t.join(",")!==n.join(",")||t.join(",")!==r.join(",")||t.join(",")!==i.join(","))throw new Error(`[engineRouter] Profile parity FAIL: dev/dist/cdn/static profiles have different path keys.
66
+ dev: `+t.join(", ")+`
67
+ dist: `+n.join(", ")+`
68
+ cdn: `+r.join(", ")+`
69
+ static: `+i.join(", "));if(!cd.__vendorBase||!Kp.__vendorBase||!Gp.__vendorBase||!e.__vendorBase)throw new Error("[engineRouter] Profile parity FAIL: __vendorBase must be defined in ALL FOUR profiles.");return!0})();function FR(e){var t=!!(e.documentRelative||e.documentBaseURI);if(t&&e.build===void 0)throw new Error('[engineRouter] mode:"static" outside a browser needs opts.build — the site build id the stamped graph directory is named by (scripts/site-build.mjs siteBuildId()).');if(!t&&e.build!==void 0)throw new Error('[engineRouter] mode:"static" in a browser reads the build from <html '+ld+">; remove opts.build:"+JSON.stringify(e.build)+".");if(e.documentRelative)return Jp(Mg(e.build),ef);var n=Tg(e.documentBaseURI||(typeof document<"u"?document.baseURI:"")),r=t?e.build:TR();return Jp(PR(n,r),MR(n))}var jb=Object.freeze(["assets/vendor/","compat/","objects/","parts/","experiments/_shared/","shim/"]),Rb=Object.freeze({"scenes/":"a scene is a roster row, not a package path: its URL is sceneUrlOf(roster, row) (lib/shim/registry/roster.js) on the roster a host loads"});function NR(e,t){Object.keys(Rb).forEach(function(s){if(t.indexOf(s)===0)throw new Error('[engineRouter] "'+t+'" is under the retired prefix "'+s+'": '+Rb[s]+". (FAIL-LOUD.)")});for(var n=0;n<jb.length;n++)if(t.indexOf(jb[n])===0)return e.__frqtlRoot+(t.indexOf("shim/")===0?t:"frqtl/"+t);for(var r=Object.keys(e).filter(function(s){return s.indexOf("__")!==0}),i=0;i<r.length;i++){var o=r[i];if(t===o||t.indexOf(o)===0)return e[o]+t.slice(o.length)}return null}function Dg(e){e=e||{};var t=e.mode||"dev-core",n=e.engine||"wasm";if(n==="js")throw new Error('[engineRouter] JS reference engine archived — FRQTL is WASM-only. Remove engine:"js"; the only FRQTL physics engine is the compiled Rust/WASM engine.');if(t==="static"&&e.base)throw new Error('[engineRouter] mode:"static" takes no opts.base — the static base is derived from the document (STATIC_SDK_DIR against document.baseURI). Remove base:'+JSON.stringify(e.base)+".");if(e.documentRelative&&t!=="static")throw new Error('[engineRouter] opts.documentRelative applies only to mode:"static" (got mode:"'+t+'").');if(e.documentRelative&&e.documentBaseURI)throw new Error("[engineRouter] opts.documentRelative and opts.documentBaseURI are exclusive — a document-relative router is anchored at no document.");if(e.build!==void 0&&t!=="static")throw new Error('[engineRouter] opts.build applies only to mode:"static" (got mode:"'+t+'").');var r=t==="dist"?Kp:t==="cdn"?e.base!==void 0?Tk(e.base):Gp:t==="static"?FR(e):cd;function i(f){var h=r.__distOmit;if(h&&Array.isArray(h)){for(var g=0;g<h.length;g++)if(f===h[g])return""}var m=NR(r,f);if(m!==null)return m;if(r!==cd)throw new Error('[engineRouter] mode:"'+t+'" has no profile prefix for "'+f+'". Add the prefix to every profile in lib/shim/engine/router.js (profile parity).');return"/frqtl/"+f}var o=e.mathSdkUrl||typeof window<"u"&&window._egptMathSdkUrl||r.__mathSdkUrl||"",s=e.mathWasmUrl||typeof window<"u"&&window._egptMathWasmUrl||r.__mathWasmUrl||"",a=e.mathWasmModuleUrl||typeof window<"u"&&window._egptMathWasmModuleUrl||r.__mathWasmModuleUrl||"",l="";if(typeof window<"u"&&typeof URLSearchParams<"u")try{l=new URLSearchParams(window.location.search).get("mathBackend")||""}catch{}var c=e.mathBackend||l||r.__mathBackend;c==="wasm"&&(c="wasm-math");var u=r.__notebookBase||"/notebooks",d=r.__vendorBase||"/vendor";return{resolve:i,frqtlRoot:function(){return r.__frqtlRoot},engine:n,mathSdkUrl:o,mathWasmUrl:s,mathWasmModuleUrl:a,mathBackend:c,notebookBase:u,vendorBase:d,distBase:t==="cdn"?e.base||Mk:null}}const Lb=Object.freeze(["markdown","js","module","canvas","chart","view"]),Ig="</cell>",Ik="&lt;/cell&gt;";function zR(e){return String(e).split(Ig).join(Ik)}function BR(e){return String(e).split(Ik).join(Ig)}function Xp(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function UR(e){return String(e).replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function Ab(e){const t=Object.create(null);if(!e)return t;const n=/([a-zA-Z_][\w-]*)\s*=\s*("([^"]*)"|'([^']*)')/g;let r;for(;(r=n.exec(e))!==null;){const i=r[1],o=r[3]!==void 0?r[3]:r[4]!==void 0?r[4]:"";t[i]=UR(o)}return t}function hh(e){return e?String(e).split(",").map(function(t){return t.trim()}).filter(function(t){return t.length>0}):[]}function HR(e){return!e||!e.length?"":e.join(", ")}function Pb(e){var t={};return e&&String(e).split(",").forEach(function(n){var r=n.trim();if(r){var i=r.indexOf("=");if(i!==-1){var o=r.slice(0,i).trim(),s=r.slice(i+1).trim();if(o){var a=Number(s);t[o]=s!==""&&isFinite(a)?a:s}}}}),t}function WR(e){if(!e)return"";var t=Object.keys(e);return t.length?t.map(function(n){return n+"="+e[n]}).join(","):""}const Eu=[{key:"type",kind:"string"},{key:"lane",kind:"string"},{key:"id",kind:"string"},{key:"name",kind:"string"},{key:"in",kind:"names"},{key:"out",kind:"names"},{key:"bind",kind:"string"},{key:"spec",kind:"string"},{key:"realm",kind:"string"},{key:"module",kind:"string"},{key:"subscribe",kind:"string"},{key:"setup",kind:"string"},{key:"shape",kind:"string"},{key:"stage",kind:"string"},{key:"seed",kind:"string"},{key:"render3d",kind:"bool"},{key:"renderOptions",kind:"opts"},{key:"cameraPreset",kind:"string"},{key:"produces",kind:"names"},{key:"produceVia",kind:"string"},{key:"produceAfter",kind:"string"},{key:"liveChart",kind:"string"},{key:"liveChartKind",kind:"string"},{key:"opts",kind:"opts"},{key:"collapsed",kind:"bool"}];function VR(e){const t=e||{},n={};for(const{key:r,kind:i}of Eu){const o=t[r];i==="names"?n[r]=Array.isArray(o)?o.slice():[]:i==="opts"?n[r]=o&&typeof o=="object"&&!Array.isArray(o)?o:{}:i==="bool"?n[r]=!!o:n[r]=typeof o=="string"?o:o==null?"":String(o)}return n}function qR(e,t){const n=(Array.isArray(e)?e:[]).slice(),r=Array.isArray(t)?t:[];for(let i=0;i<r.length;i++)n.indexOf(r[i])===-1&&n.push(r[i]);return n}function Nc(e){return e.title?'notebook "'+e.title+'"':"untitled notebook"}function $R(e){if(typeof e!="string")throw new Error("[notebook/format] parse() requires an HTML string; got "+typeof e);const t=/<frqtl-notebook\b([^>]*)>([\s\S]*?)<\/frqtl-notebook>/i.exec(e);if(!t)throw new Error("[notebook/format] no <frqtl-notebook>…</frqtl-notebook> root found — not a FRQTL native notebook (FAIL-LOUD).");const n=Ab(t[1]),r=t[2],i=[],o=/<cell\b/gi,s=/<\/cell>/gi;let a;for(;(a=o.exec(r))!==null;){const l=i.length,c=r.indexOf(">",a.index);if(c===-1)throw new Error("[notebook/format] "+Nc(n)+": cell #"+l+" open tag `<cell` has no closing `>` (FAIL-LOUD).");const u=r.slice(a.index,c+1);s.lastIndex=c+1;const d=s.exec(r);if(d===null)throw new Error("[notebook/format] "+Nc(n)+": cell #"+l+" "+u+" has no </cell> closer — the rest of the notebook would be one cell body (FAIL-LOUD).");o.lastIndex=d.index+d[0].length;const f=Ab(r.slice(a.index+a[0].length,c)),h=r.slice(c+1,d.index);if(Lb.indexOf(f.type)===-1)throw new Error("[notebook/format] "+Nc(n)+": cell #"+l+" has "+(f.type===void 0?"no type attribute":'unknown type="'+f.type+'"')+" — legal types (CELL_TYPES): "+Lb.join(", ")+" (FAIL-LOUD).");const g=hh(f.produces),m=qR(hh(f.out),g),x={type:f.type,lane:f.lane||"",id:f.id||"",name:f.name||"",in:hh(f.in),out:m,bind:f.bind||"",spec:f.spec||"",realm:f.realm||"",module:f.module||"",subscribe:f.subscribe||"",setup:f.setup||"",shape:f.shape||"",stage:f.stage||"",seed:f.seed||"",render3d:f.render3d==="true",renderOptions:Pb(f.renderOptions),cameraPreset:f.cameraPreset||"",produces:g,produceVia:f.produceVia||"",produceAfter:f.produceAfter||"",liveChart:f.liveChart||"",liveChartKind:f.liveChartKind||"",opts:Pb(f.opts),collapsed:f.collapsed==="true"};i.push({...VR(x),body:BR(h)})}if(i.length===0)throw new Error("[notebook/format] "+Nc(n)+" has zero <cell> elements — nothing to render, run or scan (FAIL-LOUD).");return{title:n.title||"",version:n.version||"1",cells:i}}function KR(e){const t=Array.isArray(e.produces)?e.produces:[],r=(Array.isArray(e.out)?e.out:[]).filter(function(o){return t.indexOf(o)===-1});let i="<cell";for(let o=0;o<Eu.length;o++){const s=Eu[o].key,a=Eu[o].kind;if(a==="bool"){e[s]&&(i+=" "+s+'="true"');continue}let l;a==="names"?l=HR(s==="out"?r:s==="produces"?t:e[s]):a==="opts"?l=WR(e[s]):l=typeof e[s]=="string"?e[s]:"",l&&(i+=" "+s+'="'+Xp(l)+'"')}return i+=">",i}function YR(e){if(!e||typeof e!="object")throw new Error("[notebook/format] serialize() requires a notebook object.");if(!Array.isArray(e.cells))throw new Error("[notebook/format] notebook.cells must be an array.");const t=e.version||"1",n=e.title||"",r=[];r.push('<frqtl-notebook version="'+Xp(t)+'"'+(n?' title="'+Xp(n)+'"':"")+">"),r.push("");for(let i=0;i<e.cells.length;i++){const o=e.cells[i],s=zR(o.body==null?"":o.body);r.push(KR(o)+s+Ig),r.push("")}return r.push("</frqtl-notebook>"),r.push(""),r.join(`
70
+ `)}var Ir={IDLE:"idle",RUNNING:"running",OK:"ok",ERROR:"error",STALE:"stale"};class GR{constructor(t,n){if(n=n||{},!t||!Array.isArray(t.cells))throw new Error("[NotebookKernel] requires a notebook object with a cells[] array.");this._runtime=n.runtime||ui,this._bus=n.bus||Ee;var r=["runCell","resetMathScope"].filter(function(f){return typeof this._runtime[f]!="function"},this);if(r.length)throw new Error("[NotebookKernel] the injected runtime does not satisfy the kernel's contract — missing: "+r.join(", ")+". Pass lib/shim/runtime/index.js's `Runtime` (Runtime.runCell, Runtime.resetMathScope), or a stub that implements both.");this._disposed=!1,this._cells=t.cells.slice(),this._cellById=new Map;for(var i=0;i<this._cells.length;i++){var o=this._cells[i];o.id&&this._cellById.set(o.id,o)}this.bindings=new Map,this.cellState=new Map;for(var s=0;s<this._cells.length;s++){var a=this._cells[s];a.id&&this.cellState.set(a.id,{status:Ir.IDLE,lastRunInputVersions:{},outputs:{}})}this._consumersOfName=new Map;for(var l=0;l<this._cells.length;l++){var c=this._cells[l];if(!(!c.id||!Array.isArray(c.in)))for(var u=0;u<c.in.length;u++){var d=c.in[u];this._consumersOfName.has(d)||this._consumersOfName.set(d,new Set),this._consumersOfName.get(d).add(c.id)}}}resetScope(){this.bindings.clear(),this._runtime.resetMathScope()}moduleSet(){for(var t={},n=0;n<this._cells.length;n++){var r=this._cells[n];r.type==="module"&&r.name&&(t[r.name]=r.body==null?"":String(r.body))}return t}_setStatus(t,n){if(!this._disposed){var r=this.cellState.get(t);r&&(r.status=n,this._bus.emit("notebook:cellstate",{cellId:t,status:n}))}}runCell(t,n){if(n=n||{},this._disposed)return Promise.reject(new Error('[NotebookKernel] disposed; cannot run cell "'+t+'".'));var r=this._cellById.get(t);if(!r)return Promise.reject(new Error('[NotebookKernel] no cell with id "'+t+'".'));for(var i=this,o={},s=Array.isArray(r.in)?r.in:[],a={},l=0;l<s.length;l++){var c=s[l];if(!i.bindings.has(c)){var u=i._findProducerCellId(c),d=u?"run cell "+u+" first.":"no cell in this notebook declares it as an output.",f=new Error('[NotebookKernel] cell "'+t+'" declares input "'+c+'", not yet produced — '+d+" (FAIL-LOUD; upstream is NOT auto-run.)");i._setStatus(t,Ir.ERROR);var h=i.cellState.get(t);return h&&(h.outputs={}),Promise.reject(f)}var g=i.bindings.get(c);o[c]=g.value,a[c]=g.version}return i._setStatus(t,Ir.RUNNING),i._runtime.runCell({lane:r.lane||"math",code:r.body||"",id:t,inputs:o,modules:i.moduleSet(),declaredOutputs:Array.isArray(r.out)?r.out:[],display:n.display||null}).then(function(m){if(i._disposed)return m;var x=i.cellState.get(t);if(m&&m.ok){for(var y=Array.isArray(r.out)?r.out:[],b=0;b<y.length;b++){var w=y[b],E=i.bindings.get(w),C=E?E.version+1:1;i.bindings.set(w,{value:m.outputs[w],version:C,producerCellId:t}),i._markConsumersStale(w,t)}x&&(x.outputs=m.outputs||{},x.lastRunInputVersions=a),i._setStatus(t,Ir.OK)}else x&&(x.outputs={}),i._setStatus(t,Ir.ERROR);return m})}commitViewOutputs(t,n){if(!this._disposed){for(var r=this.cellState.get(t),i=n&&typeof n=="object"?n:{},o=Object.keys(i),s=0;s<o.length;s++){var a=o[s],l=this.bindings.get(a),c=l?l.version+1:1;this.bindings.set(a,{value:i[a],version:c,producerCellId:t}),this._markConsumersStale(a,t)}r&&(r.outputs=i),this._setStatus(t,Ir.OK)}}runOrder(){for(var t={js:!0,canvas:!0,chart:!0,view:!0},n=[],r=0;r<this._cells.length;r++){var i=this._cells[r];i.id&&t[i.type]&&n.push(i)}for(var o=new Map,s=new Map,a=new Map,l=0;l<n.length;l++)o.set(n[l].id,l),s.set(n[l].id,0),a.set(n[l].id,new Set);for(var c=0;c<n.length;c++)for(var u=n[c],d=Array.isArray(u.in)?u.in:[],f=0;f<d.length;f++){var h=this._findProducerCellId(d[f]);if(h&&h!==u.id&&s.has(h)){var g=a.get(h);g.has(u.id)||(g.add(u.id),s.set(u.id,s.get(u.id)+1))}}for(var m=[],x=0;x<n.length;x++)s.get(n[x].id)===0&&m.push(n[x].id);for(var y=[],b=this._cellById;m.length>0;){m.sort(function(E,C){return o.get(E)-o.get(C)});var w=m.shift();y.push(b.get(w)),a.get(w).forEach(function(E){s.set(E,s.get(E)-1),s.get(E)===0&&m.push(E)})}if(y.length!==n.length)throw new Error("[NotebookKernel] runAll cannot order cells: a dependency CYCLE exists among declared in/out bindings. (FAIL-LOUD — no safe linear run order.)");return y}runAll(t){if(t=t||{},this._disposed)return Promise.reject(new Error("[NotebookKernel] disposed; cannot runAll."));var n=this,r;try{r=n.runOrder()}catch(f){return Promise.reject(f)}n.resetScope();var i=r.length,o=typeof t.displayFor=="function"?t.displayFor:null,s=typeof t.onProgress=="function"?t.onProgress:null,a=typeof t.runner=="function"?t.runner:null,l=[];function c(f,h,g){var m={index:f,total:i,cellId:h,phase:g};n._disposed||n._bus.emit("notebook:runall",m),s&&s(m)}var u=Promise.resolve(),d={ok:!0,failedCellId:null,error:null,ran:0};return r.forEach(function(f,h){u=u.then(function(){if(!(n._disposed||!d.ok)){c(h+1,f.id,"running");var g=a?a(f):null;if(g&&typeof g.then=="function")return g.then(function(x){l.push({cellId:f.id,result:x}),d.ran+=1,!x||!x.ok?(d.ok=!1,d.failedCellId=f.id,d.error=x&&x.error?x.error:'cell "'+f.id+'" did not complete ok.',c(h+1,f.id,"error")):c(h+1,f.id,"ok")},function(x){l.push({cellId:f.id,result:{ok:!1,error:x&&x.message?x.message:String(x)}}),d.ran+=1,d.ok=!1,d.failedCellId=f.id,d.error=x&&x.message?x.message:String(x),c(h+1,f.id,"error")});var m=o?{display:o(f.id)}:{};return n.runCell(f.id,m).then(function(x){l.push({cellId:f.id,result:x}),d.ran+=1,!x||!x.ok?(d.ok=!1,d.failedCellId=f.id,d.error=x&&x.error?x.error:'cell "'+f.id+'" did not complete ok.',c(h+1,f.id,"error")):c(h+1,f.id,"ok")},function(x){l.push({cellId:f.id,result:{ok:!1,error:x&&x.message?x.message:String(x)}}),d.ran+=1,d.ok=!1,d.failedCellId=f.id,d.error=x&&x.message?x.message:String(x),c(h+1,f.id,"error")})}})}),u.then(function(){return{total:i,ran:d.ran,ok:d.ok,failedCellId:d.failedCellId,error:d.error,results:l}})}_markConsumersStale(t,n){var r=this._consumersOfName.get(t);if(r){var i=this;r.forEach(function(o){if(o!==n){var s=i.cellState.get(o);s&&(s.status===Ir.OK||s.status===Ir.ERROR)&&i._setStatus(o,Ir.STALE)}})}}_findProducerCellId(t){for(var n=0;n<this._cells.length;n++){var r=this._cells[n];if(r.id&&Array.isArray(r.out)&&r.out.indexOf(t)!==-1)return r.id}return null}getCellState(t){return this.cellState.get(t)||null}getBinding(t){return this.bindings.get(t)||null}dispose(){this._disposed=!0,this.resetScope(),this.cellState.clear(),this._cellById.clear(),this._consumersOfName.clear(),this._cells=[]}}var Fg=Object.create(null);function JR(e){return typeof e=="string"&&e.length>0&&/^[a-z][a-z0-9-]*$/.test(e)}function Fk(e,t){if(!JR(e))throw new Error('[realm-registry] register: invalid realm name "'+String(e)+'" (expect lowercase-kebab, e.g. "frqtl"). (FAIL-LOUD.)');if(!t||typeof t.boot!="function")throw new Error('[realm-registry] register("'+e+'"): descriptor must have a boot(hostEl, transport) function. (FAIL-LOUD.)');Fg[e]=t}function XR(e){var t=Fg[e];if(!t)throw new Error('[realm-registry] get: no realm registered for "'+String(e)+'". Registered: ['+QR().join(", ")+"]. (Blessed realms register at import; a BYO realm must register() first.) (FAIL-LOUD.)");return t}function QR(){return Object.keys(Fg)}function ud(e,t){var n=t||"data-plane payload";if(typeof structuredClone!="function"){try{JSON.parse(JSON.stringify(e))}catch(r){throw new TypeError("[view-handle] "+n+" is not serializable (JSON fallback): "+(r&&r.message?r.message:String(r))+" (VETO-CLASS #1 — the data plane must be structured-clone-serializable so a marshalling host is not a fork.)")}return e}try{structuredClone(e)}catch(r){throw new TypeError("[view-handle] "+n+" is not structured-clone-serializable: "+(r&&r.message?r.message:String(r))+" (VETO-CLASS #1 — never pass a live object ref/function/DOM node across the handle data plane; a marshalling host cannot carry it.)")}return e}function us(e,t){try{return Promise.resolve(e.apply(null,t))}catch(n){return Promise.reject(n)}}function Nk(e){if(!e||typeof e.inject!="function"||typeof e.call!="function"||typeof e.on!="function"||typeof e.dispose!="function")throw new Error("[view-handle] makeViewHandle requires an impl with inject/call/on/dispose (start/stop/step optional but recommended). (FAIL-LOUD.)");var t={transport:e._transport||"in-app",inject:function(n,r){if(typeof n!="string"||!n)return Promise.reject(new Error("[view-handle] inject: name must be a non-empty string."));try{ud(r,'inject("'+n+'") payload')}catch(i){return Promise.reject(i)}return us(e.inject,[n,r])},call:function(n,r){return us(e.call,[n,r])},on:function(n,r){if(typeof r!="function")throw new Error('[view-handle] on("'+String(n)+'"): cb must be a function.');var i=function(s){ud(s,'on("'+String(n)+'") event payload'),r(s)},o=e.on(n,i);return typeof o=="function"?o:function(){}},start:function(){return e.start?us(e.start,[]):Promise.resolve()},stop:function(){return e.stop?us(e.stop,[]):Promise.resolve()},step:function(){return e.step?us(e.step,[]):Promise.resolve()},dispose:function(){return us(e.dispose,[])}};return Object.freeze(t)}function ZR(){var e=[];return{kind:"in-app",isInApp:function(){return!0},post:function(t){for(var n=0;n<e.length;n++)try{e[n](t)}catch{}},subscribe:function(t){if(typeof t!="function")throw new Error("[realm-transport:in-app] subscribe requires a function.");return e.push(t),function(){var n=e.indexOf(t);n!==-1&&e.splice(n,1)}}}}const eL=Object.freeze([Object.freeze({specifier:"@descix/frqtl-web/parts",libPath:"frqtl/parts/index.js",why:"the parts barrel",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/parts/",libPath:"frqtl/parts/",why:"one part = one file",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/shim/controls/registry.js",libPath:"shim/controls/registry.js",why:"knob registration (registerControls): a scene declares its own sliders and toggles",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/shim/render/sun-look.js",libPath:"shim/render/sun-look.js",why:"the one owner of the sun's FX bag (SunLook)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/compat/renderer/display-slot.js",libPath:"frqtl/compat/renderer/display-slot.js",why:"the booted display name a dual-mode scene reads before its co-init call",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/compat/renderer/orbit-bag.js",libPath:"frqtl/compat/renderer/orbit-bag.js",why:"hasAngularPose, THE 3D-ness predicate of a camera pose",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/objects/setup/_collisionMatrixLanes.js",libPath:"frqtl/objects/setup/_collisionMatrixLanes.js",why:"the one collision-lane table (density lanes of a collision scene)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/compat/engine.js",libPath:"frqtl/compat/engine.js",why:"the engine accessor (a scene that builds its frames by hand)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/kinds",libPath:"frqtl/objects/kinds-entry.js",why:"the kind registry: a composed fork registers its renamed class (registerKind, kindNamed, kindOf, registeredKinds)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/tagger.js",libPath:"frqtl/objects/objects/tagger.js",why:"imported by DetectorWall — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/schema/index.js",libPath:"frqtl/objects/schema/index.js",why:"imported by DetectorWall, SlitScreen, Wall — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/shim/render/heat-colormap.js",libPath:"shim/render/heat-colormap.js",why:"imported by GraphingDetectorWall — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/schema/valueNormalizer.js",libPath:"frqtl/objects/schema/valueNormalizer.js",why:"imported by LiveChart, Wall — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/Box.js",libPath:"frqtl/objects/objects/Box.js",why:"imported by OvenBox — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/QuantumEmitter.js",libPath:"frqtl/objects/objects/QuantumEmitter.js",why:"imported by OvenBox — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/shim/expr/ast-schema.js",libPath:"shim/expr/ast-schema.js",why:"imported by OvenBox, Tunnel — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/actionCompiler.js",libPath:"frqtl/objects/objects/actionCompiler.js",why:"imported by OvenBox, Tunnel — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/v1-replacements.js",libPath:"frqtl/objects/v1-replacements.js",why:"imported by SlitLightSource — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/slitLinerScatter.js",libPath:"frqtl/objects/objects/slitLinerScatter.js",why:"imported by SlitScreen, Tunnel — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/setup/setupSphereEmitter3D.js",libPath:"frqtl/objects/setup/setupSphereEmitter3D.js",why:"imported by SphereEmitter — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/directedRedirectProgram.js",libPath:"frqtl/objects/objects/directedRedirectProgram.js",why:"imported by Tunnel — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/compat/renderer/lo-drawn-center.js",libPath:"frqtl/compat/renderer/lo-drawn-center.js",why:"imported by Tunnel — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/setup/setupTunnelPointExit.js",libPath:"frqtl/objects/setup/setupTunnelPointExit.js",why:"imported by Tunnel — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/constants/WallBehaviors.js",libPath:"frqtl/objects/constants/WallBehaviors.js",why:"imported by Wall — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/absorbRadiation.js",libPath:"frqtl/objects/objects/absorbRadiation.js",why:"imported by Wall — a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/geometry/SlabFace.js",libPath:"frqtl/objects/geometry/SlabFace.js",why:"imported by Wall — a forked copy imports it",tier:"part-internal"})]),zk=Object.freeze({specifier:"@descix/frqtl-web/boot",libPath:"frqtl/experiments/_shared/doors.js",why:"the scene doors (bootScene, bootProject)"}),tL=Object.freeze([zk,Object.freeze({specifier:"@descix/frqtl-web/registry",libPath:"shim/registry/index.js",why:"the roster contract and its readers (normalizeRoster, sceneGroups, showcaseCard, showcaseHref), the roster loader (loadRoster), projectOf + emptyProjectOf, STUDIO's deep-link landing record"}),Object.freeze({specifier:"@descix/frqtl-web/project",libPath:"shim/project/index.js",why:"the specifier table, the link site, sketchProject and the project identity"}),Object.freeze({specifier:"@descix/frqtl-web/host-view",libPath:"shim/host/index.js",why:"the DeSciX host-view declarer: a page declares its own view"}),Object.freeze({specifier:"@descix/frqtl-web/site-graph",libPath:"shim/engine/site-graph.js",why:"the static site's shape: the graph directory, the build-stamp attribute, the build id pattern, the IDE entry page, the host-provided attribute"})]);function nL(e){if(/^(\/|\.\/|\.\.\/)/.test(e))return!0;try{return new URL(e),!0}catch{return!1}}function rL(e){if(typeof e!="string"||!e.endsWith("/"))throw new TypeError('[specifiers] importMapFor(libRootUrl): the lib-identity root URL as seen from the page, ending in "/" (got '+JSON.stringify(e)+"). (FAIL-LOUD.)");if(!nL(e))throw new TypeError("[specifiers] importMapFor(libRootUrl): "+JSON.stringify(e)+' is neither an absolute URL nor a path starting with "/", "./" or "../", so a browser reads every row built on it as a bare specifier and ignores it. Write it as '+JSON.stringify("./"+e)+" (relative to the page) or "+JSON.stringify("/"+e)+" (from the origin root). (FAIL-LOUD.)");const t={};for(const n of eL)t[n.specifier]=e+n.libPath;return{imports:t}}function iL(e){const t=rL(e);for(const n of tL)t.imports[n.specifier]=e+n.libPath;return t}var ph=Object.freeze({SEED:"seed",RENDERER:"renderer",ENGINE:"engine"}),Bk=Object.freeze([Object.freeze({key:ph.SEED,reader:"lib/frqtl/experiments/empty/index.html",forward:!0}),Object.freeze({key:ph.RENDERER,reader:"lib/frqtl/experiments/_shared/boot.js",forward:!0}),Object.freeze({key:ph.ENGINE,reader:"lib/frqtl/experiments/_shared/boot.js",forward:!1,why:"the host's own physics-engine selector (e.g. the GYM's Benchmark/Compare engine dropdown) is the SOLE authority for this axis; forwarding an outer ?engine= would let it silently override an explicit host choice, which is exactly the engine-sniffing-from-above-the-shim class of bug this codebase forbids elsewhere"})]),oL=Object.freeze([Object.freeze({key:"chrome",appliedBy:"lib/frqtl/experiments/_shared/boot.js",forward:!1,acceptedValues:Object.freeze(["canvas"]),why:`chrome is a HOST-COMPOSITION decision (whether the experiment's own control chrome DOM renders), never a per-experiment physics/render parameter; forwarding it from an outer host URL into an embedded iframe would reintroduce the hidden-experiment-chrome bug (the GYM must always show the experiment's own full chrome, never chrome=canvas — see the "WHEN should a host set chrome=canvas" doc above for the general criterion, not just the GYM's specific answer to it)`})]),sL=Object.freeze(Bk.filter(function(e){return e.forward}).map(function(e){return e.key}));const Uk=/\b(TODO|TBD|FIXME|XXX|placeholder|lorem)\b/i,aL=/^(#|$)|example\.(com|org|net)|localhost|127\.0\.0\.1/i,Qp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function ea(e,t){if(typeof e!="string"||e.trim()==="")throw new Error(t+" must be non-empty text (got "+JSON.stringify(e)+").");if(Uk.test(e))throw new Error(t+": placeholder text in shipped copy: "+JSON.stringify(e));return e}function lL(e,t){if(typeof e=="string"){ea(e,t);return}if(!e||typeof e!="object"||typeof e.text!="string")throw new Error(t+": a segment is neither a string nor { text, href } (got "+JSON.stringify(e)+").");if(ea(e.text,t),!Qp(e,"href")||e.href!==null&&typeof e.href!="string")throw new Error(t+": link segment "+JSON.stringify(e.text)+" must declare href as a URL or null (not-yet-known link), got "+JSON.stringify(e.href)+".");if(Qp(e,"em")&&e.em!==!0)throw new Error(t+": segment "+JSON.stringify(e.text)+" declares em as "+JSON.stringify(e.em)+" — em is true (emphasis) or absent.");if(typeof e.href=="string"&&(aL.test(e.href)||!/^https:\/\//.test(e.href)))throw new Error(t+": placeholder or non-https href "+JSON.stringify(e.href)+" — a link not yet known is declared null, never a stand-in URL.")}function Hk(e,t){if(typeof e=="string"){if(Uk.test(e))throw new Error(t+": placeholder text in shipped copy: "+JSON.stringify(e));return}e&&typeof e=="object"&&Object.keys(e).forEach(n=>Hk(e[n],t))}function Io(e,t,n){if(!n||typeof n.table!="boolean")throw new TypeError("copy-gate: assertCopyParagraphs("+t+") needs { table: true|false }.");if(!Array.isArray(e)||e.length===0)throw new Error(t+" must be a non-empty array of paragraphs (got "+JSON.stringify(e)+").");return e.forEach((r,i)=>{const o=t+" paragraph "+i;if(Array.isArray(r)){if(r.length===0)throw new Error(o+" is an empty segment array.");r.forEach(s=>lL(s,o));return}if(r&&typeof r=="object"&&Qp(r,"table")){if(!n.table)throw new Error(o+" is a table paragraph — a table is allowed only in a showcase intro (roster.js ROSTER_KEYS.intro); this copy is plain paragraphs.");Hk(r.table,o);return}throw new Error(o+" is neither a segment array nor a table paragraph (got "+JSON.stringify(r)+").")}),e}const at={compare:"compare",author:"author",ide:"ide",codec:"codec",bench:"bench"},cL=Object.freeze([at.author,at.compare]);function Wk(e){if(!Object.prototype.hasOwnProperty.call(at,e)||at[e]!==e)throw new Error("[presets] readsRoster(preset): "+JSON.stringify(e)+" is not a live preset — PRESETS: "+Object.keys(at).join(", ")+". (FAIL-LOUD.)");return cL.indexOf(e)!==-1}const Mb={notebooks:"ide",notebook:"ide",sim:"ide"};function uL(e){return e?Mb[e]?Mb[e]:at[e]?e:"ide":"ide"}const Vk=["bench"],Tb=Object.freeze(["internal","public"]);function tf(e){if(e===void 0)return"internal";if(Tb.indexOf(e)===-1)throw new Error("[presets] unknown audience "+JSON.stringify(e)+" — AUDIENCES: "+Tb.join(", ")+".");return e}function Ng(e){return tf(e)==="internal"?Object.keys(at):Object.keys(at).filter(function(t){return Vk.indexOf(t)===-1})}function qk(e,t){var n=uL(e);return tf(t)==="public"&&Vk.indexOf(n)!==-1?"ide":n}const dL=at.author;function fL(e,t){return qk(e===void 0?dL:e,t)}function zg(e,t,n,r){var i=e+"/"+encodeURIComponent(t)+"/index.html?engine="+encodeURIComponent(n),o=new URLSearchParams(r||"");return sL.forEach(function(s){var a=o.get(s);a!==null&&a!==""&&(i+="&"+s+"="+encodeURIComponent(a))}),i}function hL(e,t){var n=oL.filter(function(i){return i.key==="chrome"})[0];if(!n||!Array.isArray(n.acceptedValues))throw new Error('[presets] withHostChrome: lib/shim/page-params HOST_TOKENS has no "chrome" entry with acceptedValues — contract module out of date. (FAIL-LOUD.)');if(n.acceptedValues.indexOf(t)===-1)throw new Error("[presets] withHostChrome: invalid chrome token "+JSON.stringify(t)+" — accepted values: ["+n.acceptedValues.join(", ")+"]. (FAIL-LOUD.)");var r=typeof e=="string"&&e.indexOf("?")===-1?"?":"&";return e+r+"chrome="+encodeURIComponent(t)}const Pl={ide:"FAT",compare:"Gym",bench:"Math Bench",author:"Studio",codec:"Rosetta"},pL="https://godsworld.ai",mL=null,gL=null,vL="https://github.com/Jolieabadir/workshop",mh="https://egpt.descix.net/prod/egpt/site/10_PAPERS/Address_Is_The_Map/Address_Is_The_Map.pdf",yL=null,dd=Object.freeze(["This is a work in development: developers are encouraged to contribute at the ",Object.freeze({text:"EGPT FRQTL SDK repo",href:mL}),", check out the ",Object.freeze({text:"GitHub issues",href:gL}),", and earn EGPT tokens for accepted PRs."]);function Bg(e){return"preset-"+e}function bL(e){return tf(e)==="public"}function zc(e,t){return Object.freeze({title:Pl[e],seenKey:Bg(e),paragraphs:Object.freeze(t.map(Object.freeze).concat([dd]))})}const Ug=Object.freeze({compare:zc("compare",[['GYM is a testing ground for new "sugar" objects. Think of FRQTL experiments like actual fractals: you can start a Koch Snowflake at iteration 0 and wait a long time to get to 1 million, or you can build composite sugar objects in FRQTL that start the emergent physics at later iterations by doing a statistical packaging of the earlier iterations into sugar objects (like 3DEmitter, which can be turned into a Laser, etc.). GYM is where you test your proposed sugar object.']]),author:zc("author",[["STUDIO is the basis of the Tony Stark JARVIS-like interface that Maxi (",{text:"GodsWorld.ai",href:pL},") embodies."],["The designer explores 3D drag-and-drop as a human-machine interface and is a follow-up to ",{text:"Jolie's workshop repo",href:vL},"."]]),ide:zc("ide",[['FAT provides a notebook programming environment in which both the FRQTL (frame and quantum language) non-algebraic language and the traditionally understood transform approach can be used by way of FAT, the "Faster Abadir Transform" (compare the fast Fourier transform).'],["FAT is built on an algebraic mathematical language, EGPT Math (compare Matlab, Mathematica, or Lean), but the native mathematical objects like EGPTReal are strictly constructive. That is, EGPT Math's EGPTReal is constructively bijective to standard mathematical Real numbers."]]),codec:zc("codec",[[`ROSETTA is the mathematical formalization of the AS operator (not just AND, OR, and NOT) per Rota's "Barrier of Meaning" and Ulam's concept. At an intuitive level, "AS" is formalized in the concept of "`,{text:"The Address ",href:mh},{text:"is",href:mh,em:!0},{text:" The Map",href:mh},'", or the address ',{text:"as",href:null,em:!0}," the map. It is formalized in the canonical bijections of the EGPT number hierarchy to the Lean Standard types of Nat, Rat, Real and beth staircase, and also in the Lean translation bijections for N to GEMM and CNF, etc."],["ROSETTA is an exploration of a completely new approach to building transform codecs. In EGPT, which is bijectively equivalent to standard mathematics, ",{text:'there is no "proving"; there is only translating a mathematical object from one form to another',href:yL},"."],["The EGPT Lean proofs show bijective equivalence between a number N and GEMM, and CNF form, etc. With that in place, entirely new and exponentially more efficient approaches to LLMs are possible: for example, deterministic and lossless Strassen can be used at any floating-point precision, and all calculations can be kept on low-energy integer units in the CPU or deterministically reconstructibly parallelized on GPUs."]])});function xL(e){var t=Ng("public");t.forEach(function(n){if(!Object.prototype.hasOwnProperty.call(e,n))throw new Error('[presets] PRESET_EXPLAINERS has no explainer for public preset "'+n+'".')}),Object.keys(e).forEach(function(n){if(t.indexOf(n)===-1)throw new Error('[presets] PRESET_EXPLAINERS names "'+n+'", which is not a public preset ('+t.join(", ")+").");var r=e[n];if(r.title!==Pl[n])throw new Error("[presets] PRESET_EXPLAINERS."+n+".title must be PRESET_LABELS."+n+".");if(r.seenKey!==Bg(n))throw new Error("[presets] PRESET_EXPLAINERS."+n+'.seenKey must be presetExplainerKey("'+n+'").');if(!Array.isArray(r.paragraphs)||r.paragraphs.length<2)throw new Error("[presets] PRESET_EXPLAINERS."+n+" needs its own copy followed by DEVELOPER_NOTICE.");var i=r.paragraphs.length-1;if(r.paragraphs[i]!==dd)throw new Error("[presets] PRESET_EXPLAINERS."+n+" must END with the shared DEVELOPER_NOTICE (by reference — a pasted copy drifts).");r.paragraphs.forEach(function(o,s){if(s!==i&&o===dd)throw new Error("[presets] PRESET_EXPLAINERS."+n+" repeats DEVELOPER_NOTICE.");if(!Array.isArray(o)||o.length===0)throw new Error("[presets] PRESET_EXPLAINERS."+n+": paragraph "+s+" is not a non-empty segment array.")}),Io(r.paragraphs,"[presets] PRESET_EXPLAINERS."+n,{table:!1})})}xL(Ug);const Zp=Object.freeze({desktop:Object.freeze([Object.freeze(["The controls, from the top: Run and Pause start and stop the scene, Restart builds it again from its first tick, and Rec records what you see as a video."]),Object.freeze(["The tools on the left: the Hand picks up an object and moves it, the Dropper places a new object from the Palette, and the Pencil lets you edit all of an object's settings."]),Object.freeze(["The camera: drag the scene with the mouse to turn a 3D scene (with the Hand on, drag where there is no object) and turn the wheel to zoom. The sliders at the top left turn it and set its distance too, and in a 3D scene the MOVE and LOOK pads at the bottom steer it."])]),phone:Object.freeze([Object.freeze(["The controls at the top: Run and Pause start and stop the scene, Restart builds it again from its first tick, and Rec records what you see as a video."]),Object.freeze(["On the scene: drag one finger to turn a 3D scene, pinch to zoom, twist two fingers to roll it, drag two fingers to slide it, and double tap to put the camera back."]),Object.freeze(["HAND, at the bottom, picks up objects: with it on, one finger moves an object, and two fingers on it twist it or resize it. In a 3D scene the MOVE and LOOK pads on either side of it steer the camera."])])});Object.keys(Zp).forEach(function(e){Io(Zp[e],"[presets] STUDIO_CONTROLS."+e,{table:!1})});function wL(e,t){var n=Ug[e];if(!n)throw new Error('[presets] presetExplainerFor: "'+e+'" has no PRESET_EXPLAINERS row (public presets: '+Ng("public").join(", ")+").");if(!t||typeof t.onPhone!="boolean")throw new TypeError("[presets] presetExplainerFor(id, { onPhone }): onPhone is isMobileDevice(window) (lib/shim/host/device.js), a boolean (got "+JSON.stringify(t)+").");if(e!==at.author)return n;var r=n.paragraphs.slice(0,n.paragraphs.length-1);return Object.freeze({title:n.title,seenKey:n.seenKey,paragraphs:Object.freeze(r.concat(Zp[t.onPhone?"phone":"desktop"],[dd]))})}const _L="(pointer: coarse) and (max-width: 932px)";function Hg(e){if(!e||typeof e.matchMedia!="function")throw new TypeError("[device] isMobileDevice(win) needs the window the page is laid out in (a matchMedia function); got "+(e===null?"null":typeof e)+". (FAIL-LOUD.)");return e.matchMedia(_L).matches===!0}var $k=null,Wg=null,fd=Object.freeze(["files","projects"]),kL=Object.freeze({files:'the project folder (lib/shim/storage/folders.js, namespace "project-folders") for a STUDIO save, the codec chain (lib/shim/storage/codec-chains.js, namespace "codec-chains") for a ROSETTA save',projects:'the project folder (lib/shim/storage/folders.js, namespace "project-folders")'});function ca(e,t){if(typeof e!="string"||e.length===0)throw new Error("[StorageProvider] "+t+" is a non-empty string (got "+JSON.stringify(e)+"). (FAIL-LOUD.)");if(e.indexOf("/")!==-1)throw new Error("[StorageProvider] "+t+" "+JSON.stringify(e)+' contains "/" — "/" is reserved in a storage key; name it without one. (FAIL-LOUD.)')}function SL(e){return Object.freeze({get:function(t,n){return e.get(t,n)},put:function(t,n,r){if(fd.indexOf(t)!==-1)throw new Error('[StorageProvider] a write into the retired namespace "'+t+'" (key '+JSON.stringify(n)+") is refused — that save format is retired; "+kL[t]+" replaced it. (FAIL-LOUD.)");return e.put(t,n,r)},delete:function(t,n){return e.delete(t,n)},list:function(t){return e.list(t)}})}var Db=["get","put","delete","list"];function EL(e){if(!e||typeof e!="object")throw new Error("[StorageProvider] provider must be a non-null object; got "+typeof e);for(var t=0;t<Db.length;t++){var n=Db[t];if(typeof e[n]!="function")throw new Error('[StorageProvider] provider is missing required method "'+n+'"')}}function OL(e){EL(e),$k=e,Wg=SL(e)}function gn(){if(!$k)throw new Error("[StorageProvider] no active provider has been set. Call bootLocalStorage() (lib/shim/storage/boot.js) during app boot, or setActiveProvider(<provider>) for a non-browser driver.");return Wg}function CL(){return Wg}const Kk="explainers",Yk=Object.freeze([{id:"shown-first-visit",shows:!0,means:"storage answered and holds no seen record for this key: the card shows; Continue writes the record"},{id:"suppressed-seen",shows:!1,means:"storage holds a seen record for this key: the card does not show"},{id:"storage-unavailable-shown",shows:!0,means:"no storage provider, or the provider threw on read or on the Continue write: the card shows and nothing is remembered; data-run-once-detail names what failed"},{id:"not-offered-audience",shows:!1,notOffered:!0,means:"the host does not offer this card to its audience: nothing is read, written or shown; data-run-once-detail names the audience (recordRunOnceNotOffered)"},{id:"not-offered-no-roster-row",shows:!1,notOffered:!0,means:"the scene has no showcase-roster row, so it has no card: nothing is read, written or shown; data-run-once-detail names the scene (recordRunOnceNotOffered)"}].map(Object.freeze)),Gk=new Map(Yk.map(e=>[e.id,e]));function jL(){return{seenAt:new Date().toISOString()}}function em(e){return e&&e.message?String(e.message):String(e)}function Ds(e,t){const n=Gk.get(e);if(!n)throw new Error(`run-once-card: '${e}' is not a RUN_ONCE_OUTCOMES row`);return t===void 0?{row:e,shows:n.shows}:{row:e,shows:n.shows,detail:t}}function nf(e){if(typeof e!="string"||e==="")throw new TypeError(`run-once-card: seenKey must be a non-empty string (got ${JSON.stringify(e)})`)}async function Jk(e){nf(e);let t;try{t=gn()}catch(r){return Ds("storage-unavailable-shown",`no storage provider: ${em(r)}`)}let n;try{n=await t.get(Kk,e)}catch(r){return Ds("storage-unavailable-shown",`read failed: ${em(r)}`)}return n==null?Ds("shown-first-visit"):Ds("suppressed-seen")}async function Xk(e,t){if(nf(e),t.row==="storage-unavailable-shown")return t;try{await gn().put(Kk,e,jL())}catch(n){return Ds("storage-unavailable-shown",`write failed: ${em(n)}`)}return t}function Fo(e,t,n){e.dataset.runOnceKey=t,e.dataset.runOnceOutcome=n.row,n.detail===void 0?delete e.dataset.runOnceDetail:e.dataset.runOnceDetail=n.detail}function Vg(e){delete e.dataset.runOnceKey,delete e.dataset.runOnceOutcome,delete e.dataset.runOnceDetail}function hd(e,t){if(!e||!e.dataset||!e.ownerDocument)throw new TypeError("run-once-card: hostEl must be a DOM element");if(!t||typeof t!="object")throw new TypeError("run-once-card: spec bag required");if(nf(t.seenKey),typeof t.title!="string"||t.title==="")throw new TypeError(`run-once-card: title must be a non-empty string (${t.seenKey})`);if(!Array.isArray(t.paragraphs)||t.paragraphs.length===0)throw new TypeError(`run-once-card: paragraphs must be a non-empty array (${t.seenKey})`);if(t.paragraphs.forEach(n=>{if(n&&!Array.isArray(n)&&typeof n=="object"&&Object.prototype.hasOwnProperty.call(n,"table")){RL(n,t.seenKey);return}if(!Array.isArray(n))throw new TypeError(`run-once-card: a paragraph is neither a segment array nor { table } (${t.seenKey})`);n.forEach(r=>{if(typeof r!="string"&&(!r||typeof r.text!="string"||!Object.prototype.hasOwnProperty.call(r,"href")||r.href!==null&&typeof r.href!="string"||Object.prototype.hasOwnProperty.call(r,"em")&&r.em!==!0))throw new TypeError(`run-once-card: segment ${JSON.stringify(r)} is neither a string nor { text, href: string|null, em?: true } (${t.seenKey})`)})}),t.onContinue!==void 0&&typeof t.onContinue!="function")throw new TypeError(`run-once-card: onContinue must be a function when given (${t.seenKey})`);t.progress!==void 0&&LL(t.progress,t.seenKey)}function RL(e,t){const n=o=>{throw new TypeError(`run-once-card: table paragraph ${o} (${t})`)};Object.keys(e).length!==1&&n("has fields beside table: "+Object.keys(e).join(", "));const r=e.table;(!r||typeof r!="object"||Array.isArray(r))&&n("needs table: { caption, head, rows }");const i=Object.keys(r).filter(o=>o!=="caption"&&o!=="head"&&o!=="rows");i.length&&n("has unknown field(s) "+i.join(", ")+" — fields: caption, head, rows"),(typeof r.caption!="string"||r.caption.trim()==="")&&n("needs a non-empty caption"),(!Array.isArray(r.head)||r.head.length===0)&&n("needs a non-empty head"),(!Array.isArray(r.rows)||r.rows.length===0)&&n("needs a non-empty rows array"),r.head.forEach(o=>{typeof o!="string"&&n("head cell "+JSON.stringify(o)+" is not a string")}),r.rows.forEach((o,s)=>{(!Array.isArray(o)||o.length!==r.head.length)&&n("row "+s+" is not "+r.head.length+" cells long (the head's length)"),o.forEach(a=>{typeof a!="string"&&n("row "+s+" cell "+JSON.stringify(a)+" is not a string")})})}function LL(e,t){if(!e||typeof e!="object")throw new TypeError(`run-once-card: progress must be a { phases, current, subscribe } bag (${t})`);const{phases:n}=e;if(!Array.isArray(n)||n.length===0)throw new TypeError(`run-once-card: progress.phases must be a non-empty array (${t})`);const r=new Set;if(n.forEach(i=>{if(!i||typeof i.id!="string"||i.id===""||typeof i.means!="string"||r.has(i.id))throw new TypeError(`run-once-card: progress phase ${JSON.stringify(i)} is not a unique { id, means } (${t})`);r.add(i.id)}),typeof e.current!="function"||typeof e.subscribe!="function")throw new TypeError(`run-once-card: progress needs current() and subscribe(cb) functions (${t})`);Qk(e.current(),n)}function Qk(e,t){const n=t.map(i=>i.id),r=(i,o)=>{throw new Error(`run-once-card: progress ${o} '${i}' is not one of its phases — ${n.join(", ")}`)};if(!e||typeof e!="object")throw new TypeError("run-once-card: progress snapshot must be an object");return n.includes(e.phase)||r(e.phase,"phase"),e.failed!==null&&e.failed!==void 0&&!n.includes(e.failed)&&r(e.failed,"failed"),Object.keys(e.phases||{}).forEach(i=>{n.includes(i)||r(i,"phases key")}),e}function AL(e,t){const n=e.phases&&e.phases[t];return n?n.complete?1:n.total>0?Math.min(1,n.done/n.total):0:0}function PL({scrollHeight:e,clientHeight:t,scrollTop:n}){return e-t>1&&n+t<e-1}function ML(e,t){const n=e.createElement("div");n.dataset.runOnceProgress="",n.style.cssText="flex:none;margin:0 0 12px;";const r=e.createElement("div");r.style.cssText="display:flex;gap:3px;height:4px;";const i=new Map;t.phases.forEach(l=>{const c=e.createElement("div");c.dataset.bootPhase=l.id,c.title=l.means,c.style.cssText="flex:1 1 0;background:#262a33;border-radius:2px;overflow:hidden;";const u=e.createElement("div");u.style.cssText="height:100%;width:0%;background:#2d6cdf;",c.appendChild(u),r.appendChild(c),i.set(l.id,{seg:c,fill:u})});const o=e.createElement("div");o.dataset.runOnceProgressCaption="",o.style.cssText="margin-top:6px;font-size:12px;color:#8a919c;",n.appendChild(r),n.appendChild(o);function s(l){Qk(l,t.phases),t.phases.forEach(u=>{const d=AL(l,u.id),{seg:f,fill:h}=i.get(u.id);h.style.width=(d*100).toFixed(1)+"%",f.dataset.fill=String(d),l.failed===u.id&&(f.dataset.failed="",h.style.background="#b6161c",h.style.width="100%")});const c=t.phases.find(u=>u.id===(l.failed||l.phase));o.textContent=l.failed?`Failed: ${c.means}`:c.means,n.dataset.runOnceProgressPhase=l.failed||l.phase}s(t.current());const a=t.subscribe(s);if(typeof a!="function")throw new TypeError("run-once-card: progress.subscribe(cb) must return an unsubscribe function");return{el:n,unsubscribe:a}}function TL(e,t){const n=e.createElement("div");n.style.cssText="margin:0 0 12px;overflow-x:auto;";const r=e.createElement("table");r.dataset.runOnceTable="",r.style.cssText="border-collapse:collapse;width:100%;font-size:12px;line-height:1.4;";const i=e.createElement("caption");i.appendChild(e.createTextNode(t.caption)),i.style.cssText="caption-side:top;text-align:left;font-weight:700;margin:0 0 6px;color:#d8dbe0;",r.appendChild(i);const o=(c,u)=>{const d=e.createElement(c);return d.appendChild(e.createTextNode(u)),d.style.cssText="border:1px solid #2c313a;padding:4px 6px;text-align:left;vertical-align:top;"+(c==="th"?"color:#8fb8ff;font-weight:600;":""),d},s=e.createElement("thead"),a=e.createElement("tr");t.head.forEach(c=>a.appendChild(o("th",c))),s.appendChild(a),r.appendChild(s);const l=e.createElement("tbody");return t.rows.forEach(c=>{const u=e.createElement("tr");c.forEach(d=>u.appendChild(o("td",d))),l.appendChild(u)}),r.appendChild(l),n.appendChild(r),n}function Zk(e,t,n){for(;t.firstChild;)t.removeChild(t.firstChild);n.forEach(r=>{if(!Array.isArray(r)){t.appendChild(TL(e,r.table));return}const i=e.createElement("p");i.style.cssText="margin:0 0 12px;",r.forEach(o=>{if(typeof o=="string"){i.appendChild(e.createTextNode(o));return}let s=e.createTextNode(o.text);if(o.em===!0){const l=e.createElement("em");l.appendChild(s),s=l}if(o.href===null){i.appendChild(s);return}const a=e.createElement("a");a.href=o.href,a.target="_blank",a.rel="noopener noreferrer",a.appendChild(s),a.style.cssText="color:#7cc4ff;",i.appendChild(a)}),t.appendChild(i)})}function eS(e,t,n,r,i){const o=e.ownerDocument,s=o.defaultView;if(!s||!s.ResizeObserver)throw new Error(`run-once-card: the host window has no ResizeObserver (the scroll cue re-measures on resize) (${t.seenKey})`);const a="run-once-title-"+t.seenKey,l=o.createElement("div");l.dataset.runOnceCard=t.seenKey,l.style.cssText=i===null?"position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:12px;box-sizing:border-box;background:rgba(0,0,0,0.6);pointer-events:auto;":(i==="flow"?"position:relative;":"position:absolute;left:0;right:0;top:0;")+"display:flex;justify-content:center;padding:8px;box-sizing:border-box;pointer-events:none;";const c=o.createElement("div");c.setAttribute("role","dialog"),c.setAttribute("aria-modal",i===null?"true":"false"),c.setAttribute("aria-labelledby",a),c.style.cssText="box-sizing:border-box;width:100%;max-width:"+(i===null?"560px;max-height:100%;":"440px;max-height:45vh;pointer-events:auto;")+'overflow:hidden;display:flex;flex-direction:column;background:#15171c;color:#d8dbe0;border:1px solid #2c313a;border-radius:8px;padding:20px 22px 16px;box-shadow:0 12px 40px rgba(0,0,0,0.5);font:14px/1.55 system-ui,-apple-system,"Segoe UI",sans-serif;';const u=o.createElement("h2");u.id=a,u.textContent=t.title,u.style.cssText="margin:0 0 12px;font-size:13px;font-weight:700;letter-spacing:2px;text-transform:uppercase;color:#8fb8ff;flex:none;",c.appendChild(u);let d=null;t.progress&&(d=ML(o,t.progress),c.appendChild(d.el));const f=o.createElement("div");f.style.cssText="position:relative;flex:1 1 auto;min-height:0;display:flex;flex-direction:column;";const h=o.createElement("div");h.dataset.runOnceText="",h.style.cssText="flex:1 1 auto;min-height:0;overflow:auto;",h.tabIndex=0,f.appendChild(h);const g=o.createElement("div");g.dataset.runOnceScrollCue="",g.setAttribute("aria-hidden","true"),g.style.cssText="position:absolute;left:0;right:0;bottom:0;height:44px;box-sizing:border-box;padding-top:24px;text-align:center;font-size:12px;line-height:18px;color:#8a919c;pointer-events:none;background:linear-gradient(to bottom, rgba(21,23,28,0), #15171c 70%);",g.textContent="Scroll for more ↓",g.hidden=!0,f.appendChild(g),c.appendChild(f),Zk(o,h,t.paragraphs);const m=o.createElement("div");m.style.cssText="display:flex;justify-content:flex-end;margin-top:4px;flex:none;";const x=o.createElement("button");x.type="button",x.dataset.runOnceContinue="",x.textContent=n,x.style.cssText="background:#2d6cdf;color:#fff;border:0;border-radius:5px;padding:8px 18px;font:600 13px system-ui,sans-serif;cursor:pointer;",x.addEventListener("click",r),m.appendChild(x),c.appendChild(m),l.addEventListener("keydown",C=>{if(i!==null||C.key!=="Tab")return;const S=o.activeElement;!C.shiftKey&&S===x?(C.preventDefault(),h.focus({preventScroll:!0})):C.shiftKey&&S===h&&(C.preventDefault(),x.focus({preventScroll:!0}))}),l.appendChild(c),e.appendChild(l);const y=()=>{g.hidden=!PL({scrollHeight:h.scrollHeight,clientHeight:h.clientHeight,scrollTop:h.scrollTop})};y(),h.addEventListener("scroll",y,{passive:!0});const b=new s.ResizeObserver(y);b.observe(h);const w=d?d.unsubscribe:null;function E(){w&&w(),b.disconnect()}return{overlay:l,panel:c,body:h,row:m,continueBtn:x,teardown:E,measure:y}}function Hs(e,t,n,r){if(!e||!e.dataset)throw new TypeError("run-once-card: hostEl must be a DOM element");nf(t);const i=Gk.get(n);if(!i||i.notOffered!==!0)throw new Error(`run-once-card: recordRunOnceNotOffered row ${JSON.stringify(n)} is not a not-offered row — `+Yk.filter(o=>o.notOffered).map(o=>o.id).join(", ")+".");if(typeof r!="string"||r==="")throw new TypeError(`run-once-card: recordRunOnceNotOffered needs a non-empty reason (${t})`);return Fo(e,t,Ds(n,r)),{close(){Vg(e)}}}const tm=new Set;function nm(e){for(let t=e;t;t=t.parentNode)if(t.inert===!0)return!0;return!1}const Ib=["covers"];function tS(e,t,n){if(t===void 0)return{};if(!t||typeof t!="object")throw new TypeError(`run-once-card: options must be a { covers } bag when given (${n})`);const r=Object.keys(t).filter(o=>!Ib.includes(o));if(r.length)throw new TypeError(`run-once-card: unknown option(s) ${r.join(", ")} — options: ${Ib.join(", ")} (${n})`);const i=t.covers;if(i!==void 0){if(!i||i.ownerDocument!==e.ownerDocument||!("inert"in i))throw new TypeError(`run-once-card: covers must be an element of the host's document (${n})`);if(i===e||nS(i,e))throw new Error(`run-once-card: covers contains the card's own host — the card would cover itself (${n})`)}return{covers:i}}function nS(e,t){for(let n=t.parentNode;n;n=n.parentNode)if(n===e)return!0;return!1}function rS(e,t,n,r){const i=e.ownerDocument,o=i.defaultView;if(n&&n.inert===!0)throw new Error(`run-once-card: '${t.seenKey}' covers an element that is already inert — one cover has one owner (another card, or the host, already holds it)`);let s=null,a=null,l=null;const c={seenKey:t.seenKey,doc:i,btn:null};function u(){a&&!nm(a)&&a.focus({preventScroll:!0})}const d=()=>{o.setTimeout(u,0)};function f(){if(s===null)return;const g=i.activeElement===null||i.activeElement===i.body||nS(s,i.activeElement);if(l&&(l(),l=null),s.parentNode&&s.parentNode.removeChild(s),n&&(n.inert=!1,o.removeEventListener("blur",d)),tm.delete(c),s=null,a=null,g&&!IL(i)){const m=r.returnFocusTo;m&&m!==i.body&&m.isConnected!==!1&&typeof m.focus=="function"&&!nm(m)&&m.focus({preventScroll:!0})}}const h=eS(e,t,r.dismissLabel,r.onDismiss,null);return s=h.overlay,r.reopened&&(s.dataset.runOnceReopened=""),a=h.continueBtn,l=h.teardown,c.btn=a,tm.add(c),n&&(n.inert=!0,o.addEventListener("blur",d)),u(),{remove:f,focus:u}}function iS(e,t,n){const r=e.ownerDocument.defaultView;if(t&&(!r||typeof r.addEventListener!="function"))throw new Error(`run-once-card: covers needs the host document's window for the blur reclaim (${n})`)}function Ml(e,t,n){hd(e,t);const{covers:r}=tS(e,n,t.seenKey);iS(e,r,t.seenKey);let i=!1,o=null;return{ready:Jk(t.seenKey).then(a=>i?a:a.shows?(o=rS(e,t,r,{dismissLabel:"Continue",reopened:!1,returnFocusTo:null,onDismiss:()=>{o.remove(),Xk(t.seenKey,a).then(l=>{i||Fo(e,t.seenKey,l)}),t.onContinue&&t.onContinue()}}),Fo(e,t.seenKey,a),a):(Fo(e,t.seenKey,a),a)),close(){i=!0,o&&o.remove(),Vg(e)},focus(){o&&o.focus()}}}function DL(e,t,n){hd(e,t);for(const s of["onContinue","progress"])if(t[s]!==void 0)throw new TypeError(`run-once-card: a reopened card gates nothing — '${s}' is refused (${t.seenKey})`);const{covers:r}=tS(e,n,t.seenKey);iS(e,r,t.seenKey);const i=e.ownerDocument;let o=null;return o=rS(e,t,r,{dismissLabel:"Close",reopened:!0,returnFocusTo:i.activeElement,onDismiss:()=>{o.remove()}}),{close(){o.remove()},focus:o.focus}}function IL(e){const t=[...tm].filter(n=>n.doc===e&&!nm(n.btn));if(t.length>1)throw new Error("run-once-card: "+t.length+" cards show uncovered at once ("+t.map(n=>n.seenKey).join(", ")+") — a stacked card must cover the one beneath it");return t.length===1?(t[0].btn.focus({preventScroll:!0}),!0):!1}const Fb=Object.freeze(["top","flow"]),FL=4e3;function NL(e,t,n){hd(e,t);for(const m of["onContinue","progress"])if(t[m]!==void 0)throw new TypeError(`run-once-card: a task is ended by the act or by Skip — '${m}' is refused (${t.seenKey})`);const r=n&&typeof n=="object"?Object.keys(n).filter(m=>m!=="dock"):[];if(!n||typeof n!="object"||r.length||Fb.indexOf(n.dock)===-1)throw new TypeError(`run-once-card: openRunOnceTask options are { dock: ${Fb.join(" | ")} } (got ${JSON.stringify(n)}) (${t.seenKey})`);const i=e.ownerDocument,o=i.defaultView;let s=!1,a=null,l=null,c=!1,u=null,d=null;function f(){u!==null&&(o.clearTimeout(u),u=null),a!==null&&(a.teardown(),a.overlay.parentNode&&a.overlay.parentNode.removeChild(a.overlay),a=null,l=null)}function h(){return Xk(t.seenKey,d).then(m=>(s||Fo(e,t.seenKey,m),m))}return{ready:Jk(t.seenKey).then(m=>(d=m,s?m:m.shows?(a=eS(e,t,"Skip",()=>{const x=c;f(),x||h()},n.dock),a.overlay.dataset.runOnceTask="asked",l=i.createElement("div"),l.dataset.runOnceTaskStatus="",l.style.cssText="flex:none;margin:0 0 8px;font-size:13px;color:#9ad0a0;",l.hidden=!0,a.panel.insertBefore(l,a.row),Fo(e,t.seenKey,m),m):(Fo(e,t.seenKey,m),m))),status(m){if(typeof m!="string")throw new TypeError(`run-once-card: task status(text) takes a string (${t.seenKey})`);l===null||c||(l.textContent=m,l.hidden=m==="")},complete(m){if(a===null)throw new Error(`run-once-card: complete() on the task '${t.seenKey}', which is not showing (never shown, skipped or closed) — the host watches only a task that shows. (FAIL-LOUD.)`);return hd(e,{seenKey:t.seenKey,title:t.title,paragraphs:m}),c?Promise.resolve(d):(c=!0,Zk(i,a.body,m),a.measure(),l.hidden=!0,a.continueBtn.textContent="Close",a.overlay.dataset.runOnceTask="done",u=o.setTimeout(f,FL),h())},showing(){return a!==null},close(){s=!0,f(),Vg(e)}}}var oS="frqtl";function gh(e,t){return oS+":"+e+":"+t}function zL(e){return oS+":"+e+":"}function go(e,t){if(typeof e!="string"||e.length===0)throw new Error("[LocalStorageProvider] "+t+" must be a non-empty string; got: "+JSON.stringify(e));if(e.indexOf("/")!==-1)throw new Error("[LocalStorageProvider] "+t+' must not contain "/"; got: '+JSON.stringify(e))}class BL{constructor(){if(typeof window>"u"||typeof window.localStorage>"u"||window.localStorage===null)throw new Error("[LocalStorageProvider] window.localStorage is not available in this environment. Use a different StorageProvider (e.g. a server-backed RemoteStorageProvider) or ensure the page is served in a context where localStorage is permitted.");try{var t="__frqtl_storage_probe__";window.localStorage.setItem(t,"1"),window.localStorage.removeItem(t)}catch(n){throw new Error("[LocalStorageProvider] window.localStorage is present but write-blocked (private browsing with strict storage restrictions?). Error: "+(n&&n.message?n.message:String(n)))}this._ls=window.localStorage}get(t,n){go(t,"namespace"),go(n,"key");var r=this._ls.getItem(gh(t,n));if(r===null)return null;try{return JSON.parse(r)}catch(i){throw new Error('[LocalStorageProvider] stored value for "'+t+"/"+n+'" is not valid JSON. Storage may be corrupted. Error: '+(i&&i.message?i.message:String(i)))}}put(t,n,r){go(t,"namespace"),go(n,"key");var i;try{i=JSON.stringify(r)}catch(o){throw new Error('[LocalStorageProvider] value for "'+t+"/"+n+'" is not JSON-serialisable: '+(o&&o.message?o.message:String(o)))}try{this._ls.setItem(gh(t,n),i)}catch(o){throw new Error('[LocalStorageProvider] localStorage.setItem failed for "'+t+"/"+n+'" — storage may be full (QuotaExceededError) or blocked. Error: '+(o&&o.message?o.message:String(o)))}}delete(t,n){go(t,"namespace"),go(n,"key"),this._ls.removeItem(gh(t,n))}list(t){go(t,"namespace");for(var n=zL(t),r=[],i=this._ls,o=i.length,s=0;s<o;s++){var a=i.key(s);if(a!==null&&a.indexOf(n)===0){var l=a.slice(n.length),c=i.getItem(a),u=null;try{u=JSON.parse(c)}catch(h){console.warn('[LocalStorageProvider] skipping malformed entry "'+a+'": '+(h&&h.message?h.message:String(h)));continue}var d={key:l};if(u!==null&&typeof u=="object"&&!Array.isArray(u))for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&f!=="key"&&(d[f]=u[f]);r.push(d)}}return r}}const UL=Object.freeze([{id:"installed",means:"a LocalStorageProvider was constructed and is now the active provider"},{id:"already-active",means:"a provider was already active (a host set its own, or boot ran before); left as is"},{id:"unavailable",means:"localStorage is absent or write-blocked: no provider is set; detail is the reason"}].map(Object.freeze));function HL(){if(CL())return{row:"already-active"};let e;try{e=new BL}catch(t){return{row:"unavailable",detail:t&&t.message?String(t.message):String(t)}}return OL(e),{row:"installed"}}const vh=Object.freeze({row:"data-storage-boot",detail:"data-storage-boot-detail"}),WL=new Set(UL.map(e=>e.id));function VL(e,t){if(!e||typeof e.setAttribute!="function"||typeof e.removeAttribute!="function")throw new TypeError("storage boot: recordStorageBoot needs a DOM element");if(!t||!WL.has(t.row))throw new Error("storage boot: "+JSON.stringify(t&&t.row)+" is not a STORAGE_BOOT_OUTCOMES row");e.setAttribute(vh.row,t.row),t.detail===void 0?e.removeAttribute(vh.detail):e.setAttribute(vh.detail,t.detail)}const yi=Object.freeze([Object.freeze({key:"preset",prop:"initialPreset"}),Object.freeze({key:"module",prop:"initialModule",surfaces:Object.freeze([at.codec]),remedy:"a saved STUDIO project is ?project=<name>"}),Object.freeze({key:"project",prop:"initialProject",surfaces:Object.freeze([at.author])}),Object.freeze({key:"notebook",prop:"initialNotebook",surfaces:Object.freeze([at.ide])}),Object.freeze({key:"walkthrough",prop:"initialWalkthrough",surfaces:Object.freeze([at.author,at.compare])}),Object.freeze({key:"mode",prop:"initialWalkthroughMode",surfaces:Object.freeze([at.author,at.compare])}),Object.freeze({key:"scene",prop:"initialScene",surfaces:Object.freeze([at.author])}),Object.freeze({key:"renderer",prop:"initialSceneRenderer",surfaces:Object.freeze([at.author])})]);var qL=Bk.map(function(e){return e.key});function sS(e,t){return qL.indexOf(e.key)!==-1&&e.surfaces.indexOf(t)===-1}const rf=Object.freeze([Object.freeze({key:"experiment",prop:"refusedExperiment",refusal:"?experiment= is gone: the experiment pages were deleted — a scene opens by ?walkthrough=<id> (a saved one by ?project=<name>)"})]);function $L(e){return rf.some(function(t){return t.prop===e})}function aS(e){var t=e instanceof URLSearchParams?e:new URLSearchParams(e||""),n={};return yi.concat(rf).forEach(function(r){var i=t.get(r.key);i&&(n[r.prop]=i)}),n}function KL(e){if(!e)return"";var t=yi.map(function(r){return r.key});Object.keys(e).forEach(function(r){if(t.indexOf(r)===-1)throw new Error('[deep-link] unknown deep-link key "'+r+'" — DEEP_LINK_PARAMS declares: ['+t.join(", ")+"].")});var n=new URLSearchParams;return yi.forEach(function(r){e[r.key]&&n.set(r.key,e[r.key])}),n.toString()}var lS=yi.filter(function(e){return e.key==="preset"})[0].prop;function pd(e,t){return fL(e?e[lS]:void 0,t)}function cS(e,t){var n=Object.assign({},e||{});return n[lS]=t,n}function yh(e){if(!e)return"";var t={};yi.forEach(function(r){t[r.prop]=r.key});var n={};return Object.keys(e).forEach(function(r){if(!$L(r)){if(!Object.prototype.hasOwnProperty.call(t,r))throw new Error('[deep-link] unknown deep-link prop "'+r+'" — DEEP_LINK_PARAMS declares: ['+Object.keys(t).join(", ")+"].");n[t[r]]=e[r]}}),KL(n)}function YL(e){var t=yi.concat(rf).map(function(r){return r.prop}),n={};return Object.keys(e||{}).forEach(function(r){if(t.indexOf(r)===-1)throw new Error('[deep-link] unknown FraqtlIde prop "'+r+'" — neither a named FraqtlIde prop nor a DEEP_LINK_PARAMS prop: ['+t.join(", ")+"].");e[r]&&(n[r]=e[r])}),n}function Tl(e){return yi.filter(function(t){return t.surfaces&&t.surfaces.indexOf(e)!==-1})}function uS(e){var t={};return Object.keys(at).forEach(function(n){var r={};Tl(at[n]).forEach(function(i){e&&e[i.prop]&&(r[i.prop]=e[i.prop])}),t[at[n]]=r}),t}function GL(e,t){if(!e)return null;var n=function(o){return(Pl[o]||o)+" ("+o+")"},r=rf.filter(function(o){return e[o.prop]}).map(function(o){return o.refusal}),i=r.concat(yi.filter(function(o){return o.surfaces&&e[o.prop]&&o.surfaces.indexOf(t)===-1&&!sS(o,t)}).map(function(o){return o.key+'="'+e[o.prop]+'" is not a deep-link key of '+n(t)+" — it belongs to "+o.surfaces.map(n).join(", ")+(o.remedy?"; "+o.remedy:"")}));return i.length?"Deep link error: "+i.join(" · ")+".":null}function JL(e,t,n,r){var i=Tl(t).filter(function(a){return a.key===n})[0];if(!i)throw new Error('[deep-link] surface "'+t+'" has no deep-link key "'+n+'" — DEEP_LINK_PARAMS gives it: ['+Tl(t).map(function(a){return a.key}).join(", ")+"].");var o=Object.assign({},e&&e[t]||{});r?o[i.prop]=String(r):delete o[i.prop];var s=Object.assign({},e||{});return s[t]=o,s}function XL(e,t){var n=Tl(e);return Object.keys(t||{}).forEach(function(r){if(!n.some(function(i){return i.key===r}))throw new Error('[deep-link] surface "'+e+'" has no deep-link key "'+r+'" — DEEP_LINK_PARAMS gives it: ['+n.map(function(i){return i.key}).join(", ")+"].")}),n.map(function(r){var i=t&&t[r.key];return[r.key,i?String(i):""]})}function QL(e,t,n){var r=Tl(t).filter(function(a){return a.surfaces.indexOf(n)!==-1});if(!r.length)throw new Error('[deep-link] surfaces "'+t+'" and "'+n+'" share no deep-link key — DEEP_LINK_PARAMS gives no selection to hand off.');var i=e&&e[t]||{},o={};r.forEach(function(a){i[a.prop]&&(o[a.prop]=i[a.prop])});var s=Object.assign({},e||{});return s[n]=o,s}function ZL(e,t,n){var r=new URLSearchParams(e instanceof URLSearchParams?e:String(e||"").replace(/^\?/,"")),i=yh(t);if(yh(Nb(aS(r),n))===yh(Nb(t,n)))return null;var o=pd(t,n);yi.forEach(function(a){a.surfaces&&sS(a,o)||r.delete(a.key)});var s=r.toString();return i+(i&&s?"&":"")+s}function Nb(e,t){var n=pd(e,t);return cS(uS(e)[n],n)}function ol(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var bh=1,zb=Object.freeze([{key:"version",normalize:function(e){if(e===void 0||e===bh)return bh;throw new Error("[render-state] renderState.version "+JSON.stringify(e)+" — this owner reads version "+bh+" only. (FAIL-LOUD.)")}},{key:"renderer",normalize:function(e){return typeof e=="string"&&e.length>0?e:null}},{key:"engine",normalize:function(e){return typeof e=="string"&&e.length>0?e:null}},{key:"seed",normalize:function(e){return e!=null&&e!==""?String(e):null}},{key:"backdropVisible",normalize:function(e){return typeof e=="boolean"?e:null}},{key:"camera",normalize:function(e){return ol(e)?{orbit:ol(e.orbit)?e.orbit:null,preset:typeof e.preset=="string"?e.preset:null}:null}},{key:"render",normalize:function(e){return Array.isArray(e)?e.filter(function(t){return ol(t)&&typeof t.key=="string"&&t.key.length>0}):[]}}].map(Object.freeze));function bi(e){if(e!==null&&!ol(e))throw new Error("[render-state] a renderState is a bag (a plain object) or null for none — got "+(e===void 0?"undefined":Array.isArray(e)?"an array":typeof e)+". (FAIL-LOUD.)");var t=e||{};if(Object.prototype.hasOwnProperty.call(t,"pageControls")){var n=Array.isArray(t.pageControls)?t.pageControls:[];throw new Error("[render-state] this saved project carries page controls (renderState.pageControls: "+(n.map(function(o){return ol(o)?String(o.id):"?"}).join(", ")||"an empty list")+") — page controls are declared in the sketch's own code; move them into the sketch and save again. (FAIL-LOUD.)")}var r=zb.map(function(o){return o.key});Object.keys(t).forEach(function(o){if(r.indexOf(o)===-1)throw new Error('[render-state] renderState has no key "'+o+'" — its keys (RENDER_STATE_KEYS): '+r.join(", ")+". (FAIL-LOUD.)")});var i={};return zb.forEach(function(o){i[o.key]=o.normalize(t[o.key])}),i}function dS(e,t){if(typeof e!="string"||!t)return e;if(Object.prototype.hasOwnProperty.call(t,"egpt3D"))throw new Error("[render-state] applySavedUrlOverrides: `egpt3D` is DELETED — 3D-ness is the scene's co-init call (exp.createScene), and the display is `renderer` (three IS the 3D display). (FAIL-LOUD.)");var n=e.indexOf("?"),r=n===-1?e:e.slice(0,n),i=n===-1?"":e.slice(n+1),o=new URLSearchParams(i);t.renderer&&o.set("renderer",t.renderer),t.seed!==void 0&&t.seed!==null&&t.seed!==""&&o.set("seed",String(t.seed));var s=o.toString();return s?r+"?"+s:r}const rm=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),qg=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null),Bc=e=>e.map(t=>typeof t=="string"?t:t.text).join("");function Zl(e){return e&&typeof e=="object"&&!Object.isFrozen(e)&&(Object.freeze(e),Object.keys(e).forEach(t=>Zl(e[t]))),e}const of=e=>Zl(structuredClone(e));function Dt(e,t){throw new Error("[roster] "+e+" "+t+" (FAIL-LOUD.)")}function lr(e,t){return(typeof e!="string"||e.trim()==="")&&Dt(t,"must be non-empty text (got "+JSON.stringify(e)+")."),e}const Si=e=>(t,n,r)=>t===null?null:e(t,n,r),Ei=(e,t)=>ea(e,"[roster] "+t);function Bb(e,t){return Io([e],"[roster] "+t,{table:!1}),e.every(n=>typeof n=="string")||Dt(t,"is a plain paragraph: strings only (no links)."),of(e)}function eA(e,t){return(!qg(e)||Object.keys(e).length===0)&&Dt(t,"must be a non-empty setOrbit patch (got "+JSON.stringify(e)+")."),Object.keys(e).forEach(n=>{(typeof e[n]!="number"||!Number.isFinite(e[n]))&&Dt(t+"."+n,"must be a finite number (got "+String(e[n])+").")}),of(e)}function tA(e,t){return(!Number.isInteger(e)||e<1)&&Dt(t,"must be an integer >= 1 (got "+JSON.stringify(e)+")."),e}function fS(e,t){qg(e)||Dt(t,"must be a renderState bag (got "+JSON.stringify(e)+").");try{return Zl(bi(structuredClone(e)))}catch(n){throw new Error("[roster] "+t+": "+n.message)}}function nA(e,t){return fS(e,t),of(e)}function rA(e,t){lr(e,t);let n=null;try{n=new URL(e)}catch{Dt(t,"must be an absolute origin such as https://host (got "+JSON.stringify(e)+").")}return(n.protocol!=="https:"&&n.protocol!=="http:"||n.origin!==e)&&Dt(t,"must be an absolute http(s) origin with no path and no trailing slash (got "+JSON.stringify(e)+"; its origin is "+JSON.stringify(n.origin)+")."),e}function iA(e,t){return Io(e,"[roster] "+t,{table:!0}),of(e)}function oA(e,t){if(typeof e!="string"||e==="")return"must be a relative URL ending .js (got "+JSON.stringify(e)+")";if(/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e))return JSON.stringify(e)+" is absolute; a scene source is relative to the roster, so every scene sits under its directory";if(e[0]==="/"||e[0]==="\\")return JSON.stringify(e)+" starts with a slash; a scene source is relative to the roster's directory";if(e.split(/[/\\]/).indexOf("..")!==-1)return JSON.stringify(e)+` has a ".." segment; a scene source never leaves the roster's directory`;if(!/\.js$/.test(e))return JSON.stringify(e)+" does not end .js; a scene is one sketch file";const n=new URL("./",t).href,r=new URL(e,t);return r.href.indexOf(n)!==0||r.search||r.hash?JSON.stringify(e)+" resolves to "+r.href+", outside the roster's directory "+n:null}function sA(e,t,n){const r=oA(e,n.href);return r&&Dt(t,r+"."),e}function qt(e,t,n,r){return Object.freeze(Object.assign({key:e,type:t,required:!0,default:void 0,child:null,many:!1,check:n},r))}function Yr(e,t,n,r){return Object.freeze({key:e,type:t,required:!1,default:Zl(n),child:null,many:!1,check:r})}function ds(e,t,n,r,i){return Object.freeze({key:e,type:t+(r?"[]":" | null"),required:n,default:Zl(i),child:t,many:r,check:null})}const aA=Object.freeze({roster:Object.freeze([ds("rows","scene",!0,!0,void 0),Yr("firstContact","scene id | null (null: the Empty Universe)",null,Si(lr)),ds("showcase","showcase",!1,!1,null)]),scene:Object.freeze([qt("id","id (unique)",lr),qt("title","text",lr),qt("group","text",lr,{missing:"every scene names its group; the package owns no default group"}),qt("source","relative URL ending .js (no scheme, no leading /, no ..)",sA),Yr("prose","text | null",null,Si(lr)),Yr("renderState","renderState bag",bi({}),fS),ds("modes","mode",!1,!0,[])]),mode:Object.freeze([qt("id","id (unique in its scene)",lr),qt("label","text",lr),Yr("renderState","renderState delta | null",null,Si(nA))]),showcase:Object.freeze([qt("group","text",lr),qt("siteOrigin","absolute http(s) origin, no path",rA),ds("rows","card",!0,!0,void 0),ds("intro","intro",!1,!1,null),Yr("invite","plain paragraph | null",null,Si(Bb)),Yr("throughLine","plain paragraph | null",null,Si(Bb))]),card:Object.freeze([qt("id","scene id",lr),Yr("mode","mode id | null (null: the scene's default mode)",null,Si(lr)),qt("title","copy text",Ei),qt("tile","copy text",Ei),qt("what","copy text",Ei),qt("why","copy text",Ei),qt("how","copy text",Ei),Yr("controls","copy text | null",null,Si(Ei)),ds("still","still",!1,!1,null)]),still:Object.freeze([qt("tick","integer >= 1",tA),qt("alt","copy text",Ei),Yr("pose","setOrbit patch | null",null,Si(eA))]),intro:Object.freeze([qt("seenKey","text",lr),qt("title","copy text",Ei),qt("paragraphs","copy paragraphs (table paragraphs allowed)",iA)])}),xh=Object.freeze({roster:{href:"href is a load fact: pass it as normalizeRoster(json, href), never in the JSON"},scene:{is3D:"is3D is derived: walkthroughIs3D(roster, id, mode)",kind:"a scene has no kind",order:"the order is the array index"},card:{kind:"a card names its scene row by id; it has no kind",order:"the order is the array index",is3D:"is3D is derived: walkthroughIs3D(roster, id, mode)"},showcase:{app:"the app serving a site is the host's fact, not the roster's"}}),hS=new WeakSet,pS=new WeakMap;function im(e,t,n,r){const i=aA[e],o=i.map(a=>a.key);qg(t)||Dt(n,"is a "+e+": a JSON object (got "+JSON.stringify(t)+")."),Object.keys(t).forEach(a=>{if(o.indexOf(a)!==-1)return;const l=xh[e]&&rm(xh[e],a)?xh[e][a]+". ":"";Dt(n,'has no key "'+a+'" — '+l+e+" keys (ROSTER_KEYS."+e+"): "+o.join(", ")+".")});const s={};return i.forEach(a=>{const l=n+"."+a.key;if(!rm(t,a.key)){a.required&&Dt(n,'is missing required key "'+a.key+'" ('+a.type+")"+(a.missing?": "+a.missing:"")+" — "+e+" keys (ROSTER_KEYS."+e+"): "+o.join(", ")+"."),s[a.key]=a.default;return}const c=t[a.key];if(!a.child){s[a.key]=a.check(c,l,r);return}a.many?(Array.isArray(c)||Dt(l,"must be a list of "+a.child+" (got "+JSON.stringify(c)+")."),s[a.key]=Object.freeze(c.map((u,d)=>im(a.child,u,l+"["+d+"]",r)))):s[a.key]=c===null?null:im(a.child,c,l,r)}),Object.freeze(s)}function mS(e,t,n){const r=e.modes.map(o=>o.id),i=t??(r.length>0?r[0]:null);return i!==null&&r.indexOf(i)===-1&&Dt(n,'names mode "'+i+'" of scene "'+e.id+'", which declares ['+r.join(", ")+"]."),r.length>1?i:null}function lA(e,t){const n=Kg(t);if(n)throw new Error("[roster] normalizeRoster(json, href): "+n+" (FAIL-LOUD.)");const r=im("roster",e,"roster",{href:t}),i=new Map;r.rows.forEach((a,l)=>{i.has(a.id)&&Dt("roster.rows["+l+"].id",'"'+a.id+'" is declared twice; a scene id is unique.'),i.set(a.id,a);const c=new Set;a.modes.forEach((u,d)=>{c.has(u.id)&&Dt("roster.rows["+l+"].modes["+d+"].id",'"'+u.id+'" is declared twice in scene "'+a.id+'".'),c.add(u.id)})}),r.firstContact!==null&&!i.has(r.firstContact)&&Dt("roster.firstContact",'"'+r.firstContact+'" is not a declared scene id — declared: ['+[...i.keys()].join(", ")+"].");let o=r.showcase;if(o!==null){const a=new Set,l=o.invite===null?null:Bc(o.invite),c=o.intro===null?[]:o.intro.paragraphs;if(o.throughLine!==null){const d=Bc(o.throughLine);c.forEach((f,h)=>{Array.isArray(f)&&Bc(f).indexOf(d)!==-1&&Dt("roster.showcase.intro.paragraphs["+h+"]","pastes showcase.throughLine — the through-line has one place.")})}const u=o.rows.map((d,f)=>{const h="roster.showcase.rows["+f+"]",g=i.get(d.id);g||Dt(h+".id",'"'+d.id+'" is not a declared scene id — declared: ['+[...i.keys()].join(", ")+"].");const m=mS(g,d.mode,h+".mode"),x=d.id+":"+m;return a.has(x)&&Dt(h,"repeats the card "+x+"; a scene and mode have one card."),a.add(x),["what","why","how","controls"].forEach(y=>{const b=d[y];b!==null&&(l!==null&&b.indexOf(l)!==-1&&Dt(h+"."+y,"pastes showcase.invite — the card appends it by reference."),c.forEach((w,E)=>{Array.isArray(w)&&b.indexOf(Bc(w))!==-1&&Dt(h+"."+y,"pastes showcase.intro paragraph "+E+" — the intro's text has one place.")}))}),Object.freeze(Object.assign({},d,{mode:m}))});o=Object.freeze(Object.assign({},o,{rows:Object.freeze(u)}))}const s=Object.freeze(Object.assign({},r,{showcase:o,href:t}));return hS.add(s),s.rows.forEach(a=>pS.set(a,s)),s}function $g(e){return e===void 0?"undefined":typeof e=="string"?"the string "+JSON.stringify(e):e===null||typeof e!="object"?String(e):"an object that normalizeRoster did not return"}function Jt(e,t){if(!hS.has(e))throw new Error("[roster] "+t+" takes a roster bag first (normalizeRoster(json, href), or loadRoster from roster-link.js); got "+$g(e)+". (FAIL-LOUD.)");return e}function sf(e,t,n){const r=pS.get(e);if(!r||r.rows.indexOf(e)===-1||n&&r!==n)throw new Error("[roster] "+t+" takes a scene row of "+(n?"that":"a normalized")+" roster bag (walkthroughById(roster, id)); got "+$g(e)+". (FAIL-LOUD.)");return e}function cA(e,t,n){if(e.showcase===null||e.showcase.rows.indexOf(t)===-1)throw new Error("[roster] "+n+" takes a card of roster.showcase.rows from the same bag (exhibitFor(roster, scene)); got "+JSON.stringify(t&&{id:t.id,mode:t.mode})+". (FAIL-LOUD.)");return t}function Kg(e){if(typeof e!="string"||e==="")return"a roster href is an absolute URL string (got "+JSON.stringify(e)+").";let t=null;try{t=new URL(e)}catch{t=null}return t===null?"roster href "+JSON.stringify(e)+" is relative; it must be absolute (https://…): inside the DeSciX store shell (descix.net) a relative or root-relative href such as /assets/… resolves against the daita app, not this app's media.":t.protocol!=="https:"&&t.protocol!=="http:"&&t.protocol!=="file:"?"roster href "+JSON.stringify(e)+" has scheme "+t.protocol+"; a roster is read over http(s), or file: in node.":e.indexOf("?")!==-1||e.indexOf("#")!==-1?"roster href "+JSON.stringify(e)+" carries a query or a hash; a roster URL is a plain file URL.":null}function uA(e,t){return Jt(e,"sceneUrlOf(roster, row)"),sf(t,"sceneUrlOf(roster, row)",e),new URL(t.source,e.href).href}function Kt(e,t){Jt(e,"walkthroughById(roster, id)");for(let n=0;n<e.rows.length;n++)if(e.rows[n].id===t)return e.rows[n];return null}function Dl(e){return sf(e,"walkthroughModes(row)").modes}function Lo(e){const t=sf(e,"defaultWalkthroughModeId(row)").modes;return t.length>0?t[0].id:null}function Zi(e,t){const n=sf(e,"effectiveRenderState(row, modeId)").modes;let r=null;if(t==null)r=n.length>0?n[0]:null;else if(r=n.find(a=>a.id===t)||null,!r)throw new Error('[roster] scene "'+e.id+'" has no mode "'+t+'" — declared modes: ['+n.map(a=>a.id).join(", ")+"]. (FAIL-LOUD.)");const i=e.renderState,o=r&&r.renderState||{},s=Object.assign({},i,o);return s.render=i.render.concat(Array.isArray(o.render)?o.render:[]),bi(s)}function dA(e,t,n){Jt(e,"walkthroughIs3D(roster, id, modeId)");const r=Kt(e,t);return r===null?!1:Zi(r,n).renderer==="three"}function fA(e){return Jt(e,"firstContactOf(roster)"),e.firstContact===null?null:Kt(e,e.firstContact)}function gS(e){Jt(e,"sceneGroups(roster)");const t=[];e.showcase!==null&&t.push({label:e.showcase.group,rows:e.showcase.rows.map(r=>({id:r.id,title:r.title}))});const n=t.length;return e.rows.forEach(r=>{let i=t[t.length-1];(t.length===n||i.label!==r.group)&&(t.push({label:r.group,rows:[]}),i=t[t.length-1]),i.rows.push({id:r.id,title:r.title})}),t}const hA=Object.freeze([Object.freeze(["Move and Look: this scene is 3D. Drag the MOVE pad (bottom left) to walk the camera forward, back and sideways, and the LOOK pad (bottom right) to turn it. Both pads take a finger on a phone or the mouse on a desktop; on a keyboard, W/A/S/D move and the arrow keys look."])]);function vS(e,t,n){if(Jt(e,n),!t||typeof t!="object")throw new Error("[roster] "+n+" takes a scene { id, modeId? }; got "+$g(t)+". (FAIL-LOUD.)");if(rm(t,"kind"))throw new Error("[roster] "+n+": a scene has no kind — pass { id, modeId? }. (FAIL-LOUD.)");const r=Kt(e,t.id);if(!r)throw new Error("[roster] "+n+': "'+t.id+'" is not a declared scene — declared: ['+e.rows.map(i=>i.id).join(", ")+"]. (FAIL-LOUD.)");return mS(r,t.modeId,n+" modeId")}function yS(e,t){const n=vS(e,t,"exhibitFor(roster, scene)");return e.showcase===null?null:e.showcase.rows.find(r=>r.id===t.id&&r.mode===n)||null}function ta(e,t){const n=vS(e,t,"sceneKey(roster, scene)");return"scene-rung-"+t.id+(n?"-"+n:"")}function bS(e,t){Jt(e,"showcaseCard(roster, card)"),cA(e,t,"showcaseCard(roster, card)");const n=dA(e,t.id,t.mode);let r=["what","why","how"].map(i=>Object.freeze([t[i]]));return t.controls!==null&&(r=r.concat([Object.freeze([t.controls])])),n&&(r=r.concat(hA)),e.showcase.invite!==null&&(r=r.concat([e.showcase.invite])),Object.freeze({id:t.id,modeId:t.mode,seenKey:ta(e,{id:t.id,modeId:t.mode}),title:t.title,paragraphs:Object.freeze(r),is3D:n})}function xS(e){return Jt(e,"showcaseIntro(roster)"),e.showcase===null?null:e.showcase.intro}new TextEncoder;function Sa(e){throw new Error("[identity] "+e+" (FAIL-LOUD.)")}function wS(e){e||Sa("a project file has an empty path."),(e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e))&&Sa('"'+e+'" is absolute — a project path is root-relative.'),e.startsWith("./")&&Sa('"'+e+'" starts with "./" — a project path carries no leading "./".'),e.indexOf("\\")!==-1&&Sa('"'+e+'" uses "\\" — a project path is "/"-separated.'),e.split("/").some(t=>t===""||t==="."||t==="..")&&Sa('"'+e+'" has an empty, "." or ".." segment — a project path names one file under the root.')}const Ge="frqtl.json";function Qn(e){throw new Error("["+Ge+"] "+e+" (FAIL-LOUD.)")}function Ub(){return md.map(function(e){return e.key}).join(", ")}const md=Object.freeze([Object.freeze({key:"name",type:"string",required:!0,rule:"a non-empty string — the project's name",check:function(e){e.length===0&&Qn(`"name" is empty — a project's name is a non-empty string.`)}}),Object.freeze({key:"kind",type:"string",required:!0,rule:'"scene" (a notebook project, "notebook", comes with P5)',check:function(e){e==="notebook"&&Qn('"kind": "notebook" — a notebook project comes with P5 (notebooks on projects); a project today is "kind": "scene".'),e!=="scene"&&Qn('"kind": '+JSON.stringify(e)+' is not a project kind — "scene", or "notebook" (P5).')}}),Object.freeze({key:"entry",type:"string",required:!0,rule:'a root-relative project path ending ".js" — the module whose default export is buildExperiment(exp)',check:function(e){try{wS(e)}catch(t){Qn('"entry": '+String(t&&t.message||t))}e.endsWith(".js")||Qn('"entry": '+JSON.stringify(e)+' does not end ".js" — the entry is the project module whose default export is buildExperiment(exp).')}}),Object.freeze({key:"version",type:"string",required:!1,rule:"the author's own string, never interpreted (optional)",check:function(){}})]);function Yg(e){(!e||typeof e!="object"||Array.isArray(e))&&Qn("a manifest is an object { "+Ub()+" } (got "+(Array.isArray(e)?"an array":e===null?"null":typeof e)+").");const t=md.map(function(i){return i.key}),n=Object.keys(e).filter(function(i){return t.indexOf(i)===-1});n.length&&Qn("unknown key"+(n.length>1?"s ":" ")+n.map(function(i){return JSON.stringify(i)}).join(", ")+" — a manifest holds exactly MANIFEST_KEYS (lib/shim/project/manifest.js): "+Ub()+". How a host boots the folder (display, seed, camera, render rows) is its renderState, kept beside the folder.");const r={};for(const i of md){const o=e[i.key];if(o===void 0){i.required&&Qn('"'+i.key+'" is REQUIRED — '+i.rule+".");continue}typeof o!==i.type&&Qn('"'+i.key+'" is '+(o===null?"null":typeof o)+" — "+i.rule+"."),i.check(o),r[i.key]=o}return Object.freeze(r)}function es(e){typeof e!="string"&&Qn("parseManifest(text): the text of "+Ge+" (got "+typeof e+").");let t;try{t=JSON.parse(e)}catch(n){Qn("is not valid JSON: "+String(n&&n.message||n)+".")}return Yg(t)}function Gg(e){return JSON.stringify(Yg(e),null,2)+`
71
+ `}function _S(e){(!e||typeof e!="object")&&Qn("manifestFor({ name, entry }) (got "+(e===null?"null":typeof e)+").");const t=Object.keys(e).filter(function(n){return n!=="name"&&n!=="entry"});return t.length&&Qn("manifestFor({ name, entry }) takes the name and the entry only (got "+t.join(", ")+') — a fresh project is kind "scene" with no version; any other bag goes through normalizeManifest.'),Yg({name:e.name,kind:"scene",entry:e.entry})}new URL("../../",import.meta.url).href;new TextDecoder("utf-8",{fatal:!0});function pA(e){throw new Error("[link] "+e+" (FAIL-LOUD.)")}function mA(e,t){return t?t.entry:(pA("entryOf: no entry — the project carries no "+Ge+' (manifest.js; manifestFor({ name, entry }) writes one) and no `entry` was given (a one-string sketch: { files: { "sketch.js": text }, entry: "sketch.js" }).'),e)}function Ko(e,t){const n=e&&Object.prototype.hasOwnProperty.call(e,Ge);return mA(t,n?es(e[Ge]):null)}const Hb="sketch.js";function Jg(e,t){return Promise.resolve().then(function(){if(typeof e!="string"||!e)throw new TypeError("readText(url): a URL string (got "+JSON.stringify(e)+")");if(e.indexOf("file:")===0){var n=typeof process<"u"&&process.getBuiltinModule?process.getBuiltinModule:null;if(typeof n!="function")throw new Error(e+" is a file: URL; reading one needs node's process.getBuiltinModule (Node 20.16+ / 22.3+). In a page, serve the package over http");var r=n("node:fs"),i=n("node:url").fileURLToPath;return r.promises.readFile(i(e),"utf8").catch(function(s){throw new Error("reading "+e+" failed: "+(s&&s.message))})}var o=t&&t.fetch||(typeof fetch=="function"?fetch:null);if(!o)throw new Error("no fetch available to load "+e);return Promise.resolve(o(e)).then(function(s){if(!s||!s.ok)throw new Error("GET "+e+" answered "+(s?s.status:"nothing"));return s.text()})})}const af="empty",Wb="experiments/_shared/empty-sketch.js",Uc="projectOf(roster, id, { fetch, mode })",Vb="emptyProjectOf({ router, fetch })";function kS(e,t,n){const r=e===void 0?{}:e;if(r===null||typeof r!="object"||Array.isArray(r))throw new Error("[scene-source] "+n+": options are an object (got "+JSON.stringify(e)+"). (FAIL-LOUD.)");return Object.keys(r).forEach(i=>{if(t.indexOf(i)===-1)throw new Error("[scene-source] "+n+' has no option "'+i+'" — options: '+t.join(", ")+(i==="router"?"; a roster scene's URL is sceneUrlOf(roster, row), not a router path":"")+". (FAIL-LOUD.)")}),r}function SS(e,t,n,r,i){return Jg(t,{fetch:r.fetch}).catch(o=>{throw new Error("[scene-source] "+n+" — "+(o&&o.message||o)+". (FAIL-LOUD.)")}).then(o=>{if(typeof o!="string"||!o.trim())throw new Error("[scene-source] "+n+" — "+t+" has an empty body. (FAIL-LOUD.)");const s=_S({name:e,entry:Hb}),a={};return a[Ge]=Gg(s),a[Hb]=o,{manifest:s,files:a,renderState:i}})}function gd(e,t,n){return Promise.resolve().then(()=>{Jt(e,Uc);const r=kS(n,["fetch","mode"],Uc);if(typeof t!="string"||t==="")throw new Error("[scene-source] "+Uc+" takes a scene id string (got "+JSON.stringify(t)+"). (FAIL-LOUD.)");const i=Kt(e,t);if(!i)throw new Error("[scene-source] "+Uc+': "'+t+'" is not a declared scene — declared: ['+e.rows.map(s=>s.id).join(", ")+"]. (FAIL-LOUD.)");const o=Zi(i,r.mode);return SS(i.id,uA(e,i),'scene "'+i.id+'"',r,o)})}function ES(e){return Promise.resolve().then(()=>{const t=kS(e,["router","fetch"],Vb);if(!t.router||typeof t.router.resolve!="function")throw new Error("[scene-source] "+Vb+" needs the host's engineRouter (lib/shim/engine/router.js) to resolve "+Wb+". (FAIL-LOUD.)");const n=t.router.resolve(Wb);return SS(af,n,"the Empty Universe",t,bi({}))})}var qb=Object.freeze({roster:"roster",edited:"edited"});function ec(e,t){if(typeof e!="string")throw new Error("[scene-buffer] "+t+" must be the scene text (a string), got "+typeof e+". (FAIL-LOUD.)");return e}function ts(e){if(!e||typeof e.file!="string"||typeof e.text!="string"||!("override"in e))throw new Error("[scene-buffer] not a scene buffer — make one with seedBuffer(fileText). (FAIL-LOUD.)");return e}function lf(e,t,n){return Object.freeze({file:e,text:t,override:n})}function Il(e){if(arguments.length>1)throw new Error("[scene-buffer] seedBuffer(fileText) takes the text only — the scene's text is its sketch file. (FAIL-LOUD.)");var t=ec(e,"seedBuffer(fileText)");return lf(t,t,null)}function om(e,t){return ts(e),lf(e.file,ec(t,"editBuffer(b, text)"),e.override)}function OS(e,t){ts(e);var n=ec(t,"runBuffer(b, text)");return lf(e.file,n,n===e.file?null:n)}var sm="Run your code edits first — the editor holds text the canvas has not run, and a hand edit is written into the code the canvas runs (the writer never merges a text edit).";function gA(e,t){ts(e);var n=ec(t,"adoptSketch(b, text)");if(Xg(e))throw new Error("[scene-buffer] adoptSketch: "+sm+" (FAIL-LOUD.)");return lf(e.file,n,n===e.file?null:n)}function CS(e){return e?ts(e).override:null}function cf(e){return ts(e),e.override!==null?e.override:e.file}function vA(e){return CS(e)!==null?qb.edited:qb.roster}function Xg(e){return ts(e).text!==cf(e)}function yA(e){return e?(ts(e),e.override!==null||e.text!==e.file?"Open in STUDIO opens the roster scene file, not these edits — Reset to the file first (edits in this editor live for this session only).":null):null}function jS(e){var t=e&&typeof e.stack=="string"?e.stack:"",n=/(?:blob:|data:text\/javascript)[^\n]*?:(\d+):(\d+)\)?[ \t]*$/m.exec(t);return n?{line:Number(n[1]),col:Number(n[2])}:null}function uf(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("[scene-buffer] "+t+" takes the folder's files ({ path: text }). (FAIL-LOUD.)");return Object.keys(e).forEach(function(n){ec(e[n],t+' — files["'+n+'"]')}),e}function wi(e){if(!e||typeof e.entry!="string"||typeof e.active!="string"||!e.files||typeof e.files!="object")throw new Error("[scene-buffer] not a project buffer — make one with seedProject(files). (FAIL-LOUD.)");return e}function tc(e,t,n){return Object.freeze({entry:e,active:t,files:Object.freeze(n)})}function Qg(e,t,n){if(!Object.prototype.hasOwnProperty.call(e.files,t))throw new Error("[scene-buffer] "+n+': "'+t+'" is not a file of this project (files: '+Object.keys(e.files).join(", ")+"). (FAIL-LOUD.)");return t}function gs(e){return!(e===Ge||/\.m?js$/.test(e))}function bA(e){uf(e,"seedProject(files)");var t=Ko(e),n={};return Object.keys(e).forEach(function(r){n[r]=Il(e[r])}),tc(t,t,n)}function RS(e){wi(e);function t(n){return n===e.entry?0:n===Ge?1:n.indexOf("parts/")===0?2:3}return Object.keys(e.files).sort(function(n,r){return t(n)-t(r)||(n<r?-1:n>r?1:0)})}function Dr(e){return wi(e).active}function $b(e,t){return wi(e),tc(e.entry,Qg(e,t,"selectFile"),Object.assign({},e.files))}function Ea(e,t){return wi(e),e.files[Qg(e,t,"bufferOf")]}function Kb(e,t,n){if(wi(e),Qg(e,t,"editFile"),gs(t))throw new Error('[scene-buffer] editFile: "'+t+'" is read-only in the drawer (a module or '+Ge+" is editable). (FAIL-LOUD.)");var r=Object.assign({},e.files);return r[t]=om(e.files[t],n),tc(e.entry,e.active,r)}function xA(e,t){wi(e),uf(t,"runProject(p, files)");var n={};Object.keys(t).forEach(function(i){n[i]=Object.prototype.hasOwnProperty.call(e.files,i)?OS(e.files[i],t[i]):Il(t[i])});var r=Ko(t);return tc(r,Object.prototype.hasOwnProperty.call(n,e.active)?e.active:r,n)}function LS(e,t){wi(e),uf(t,"adoptFiles(p, files)");var n=Object.assign({},e.files);return Object.keys(t).forEach(function(r){n[r]=Object.prototype.hasOwnProperty.call(e.files,r)?gA(e.files[r],t[r]):Il(t[r])}),tc(e.entry,e.active,n)}function Yb(e,t){uf(t,"adoptWritten(p, files)");var n={};return Object.keys(t).forEach(function(r){r!==Ge&&(n[r]=t[r])}),LS(e,n)}function wA(e){wi(e);var t={};return Object.keys(e.files).forEach(function(n){t[n]=cf(e.files[n])}),t}function wh(e){wi(e);var t={};return Object.keys(e.files).forEach(function(n){t[n]=e.files[n].text}),t}function Ou(e){return RS(e).filter(function(t){return Xg(e.files[t])})}function _h(e){return Ou(e).length>0}const _A="modulepreload",kA=function(e,t){return new URL(e,t).href},Gb={},AS=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const s=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=Promise.allSettled(n.map(c=>{if(c=kA(c,r),c in Gb)return;Gb[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!r)for(let g=s.length-1;g>=0;g--){const m=s[g];if(m.href===c&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${d}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":_A,u||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),u)return new Promise((g,m)=>{h.addEventListener("load",g),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};var PS=j.lazy(function(){return AS(()=>import("./SceneCodeEditor-DnAM0Uhi.js"),[],import.meta.url)});const nc=Object.freeze([{id:"modules",means:"Loading the scene objects"},{id:"engine-ready",means:"Starting the WASM engine"},{id:"renderer",means:"Loading the renderer"},{id:"sketch",means:"Building the scene"}].map(Object.freeze)),SA=Object.freeze(nc.map(e=>e.id)),sl="frqtl:boot-phase";function vd(e){const t=nc.find(n=>n.id===e);if(!t)throw new Error(`boot-phases: "${e}" is not a boot phase — ${SA.join(", ")}.`);return t}const EA=Object.freeze(nc.map(({id:e,means:t})=>Object.freeze({id:e,means:t}))),OA=nc[0].id;function am(){return{phase:OA,done:0,total:0,phases:{},failed:null}}function lm(e){const t=e&&e.documentElement,n=t&&t.getAttribute("data-egpt-boot-progress");if(!n)return am();const r=JSON.parse(n),i=t.getAttribute("data-egpt-boot-phase");vd(i);const o=t.getAttribute("data-egpt-boot-failed")||null;o&&vd(o);const s=r[i]||{done:0,total:0};return{phase:i,done:s.done,total:s.total,phases:r,failed:o}}function Jb(e){return e.failed?"Failed: "+vd(e.failed).means:nc.every(n=>e.phases[n.id]&&e.phases[n.id].complete)?null:vd(e.phase).means}function Xb(e){let t;try{t=e.contentDocument}catch(n){throw new Error("watchFrameBootPhases: the frame's document is not readable ("+n.message+") — the boot record is a same-origin contract.")}if(t===null)throw new Error("watchFrameBootPhases: frame.contentDocument is null — the frame is cross-origin or detached; the boot record is a same-origin contract.");return t}function CA(e){if(!e||typeof e.addEventListener!="function")throw new TypeError("watchFrameBootPhases(frameEl): frameEl must be an <iframe> element");let t=lm(Xb(e));const n=new Set,r=()=>{n.forEach(s=>s(t))};function i(s){t=s.detail,r()}function o(){t=lm(Xb(e)),r()}return e.addEventListener(sl,i),e.addEventListener("load",o),{phases:EA,current:()=>t,subscribe(s){if(typeof s!="function")throw new TypeError("watchFrameBootPhases: subscribe(cb) needs a function");return n.add(s),()=>{n.delete(s)}},close(){n.clear(),e.removeEventListener(sl,i),e.removeEventListener("load",o)}}}var Fl="project-folders",kh=Object.freeze(["files","renderState"]),yd="index.html";function kr(e){throw new Error("[folders] "+e+" (FAIL-LOUD.)")}function Sh(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function eo(e){Sh(e)||kr("a project folder row is { "+kh.join(", ")+" } (got "+(e===null?"null":Array.isArray(e)?"an array":typeof e)+").");var t=Object.keys(e).filter(function(o){return kh.indexOf(o)===-1});t.length&&kr("unknown key "+t.map(function(o){return JSON.stringify(o)}).join(", ")+" — a project folder row holds exactly FOLDER_ROW_KEYS (lib/shim/storage/folders.js): "+kh.join(", ")+".");var n=e.files;(!Sh(n)||Object.keys(n).length===0)&&kr('"files" is the folder { path: text } with at least '+Ge+" (got "+(Sh(n)?"an empty map":typeof n)+").");var r={};Object.keys(n).forEach(function(o){wS(o),o===yd&&kr('"'+yd+'" at the folder root is reserved — the Export generates it (the host page that carries the boot bag); a project folder never holds one.'),typeof n[o]!="string"&&kr('"'+o+'" is not text (got '+(n[o]instanceof Uint8Array?"bytes":typeof n[o])+") — a project folder holds text files only."),r[o]=n[o]}),typeof r[Ge]!="string"&&kr("the folder carries no "+Ge+" — a project folder is named and entered by its manifest (lib/shim/project/manifest.js manifestFor({ name, entry }) writes one).");var i=es(r[Ge]).name;return ca(i,'a project folder name (frqtl.json "name")'),Object.freeze({files:Object.freeze(r),renderState:bi(e.renderState)})}function Qb(e){return es(eo(e).files[Ge]).name}function MS(e){return{files:Object.assign({},e.files),renderState:e.renderState}}function Zb(e,t){var n=eo(t),r=es(n.files[Ge]).name;return e.put(Fl,r,MS(n)),r}function cm(e,t,n){ca(n,"a project folder name");var r=eo(t);e.get(Fl,n)!==null&&kr('a project named "'+n+'" is already saved — Save As takes a name no saved project has (choose another, or delete the saved one first).');var i=Object.assign({},r.files);i[Ge]=Gg(Object.assign({},es(r.files[Ge]),{name:n}));var o=eo({files:i,renderState:r.renderState});return e.put(Fl,n,MS(o)),n}function Eh(e,t){ca(t,"a project folder name");var n=e.get(Fl,t);if(n==null)return null;var r;try{r=eo(n)}catch(o){kr('the saved project "'+t+'" is not a project folder row: '+(o&&o.message||o))}var i=es(r.files[Ge]).name;return i!==t&&kr('the saved project under "'+t+'" names itself "'+i+'" in '+Ge+" — a folder is keyed by its manifest name."),r}function jA(e){return e.list(Fl).map(function(t){return t.key}).sort().map(function(t){return{name:t}})}function RA(e){var t=[];return fd.forEach(function(n){e.list(n).forEach(function(r){t.push({namespace:n,key:r.key})})}),t}function LA(e,t){return Array.isArray(t)||kr("deleteRetiredSaves(provider, saves): saves is retiredSaves(provider)'s list."),t.forEach(function(n){(!n||fd.indexOf(n.namespace)===-1||typeof n.key!="string")&&kr("deleteRetiredSaves deletes only retired saves ({ namespace in ["+fd.join(", ")+"], key }) — got "+JSON.stringify(n)+".")}),t.forEach(function(n){e.delete(n.namespace,n.key)}),t.length}const al=Object.freeze({parts:Object.freeze({path:"parts/index.js",name:null}),ObjectSchema:Object.freeze({path:"objects/schema/index.js",name:"ObjectSchema"}),ObjectFactory:Object.freeze({path:"objects/ObjectFactory.js",name:"ObjectFactory"}),MakeControlsForObject:Object.freeze({path:"objects/objects/makeControlsForObject.js",name:"MakeControlsForObject"}),MakeControlsForRenderSurface:Object.freeze({path:"objects/objects/makeControlsForRenderSurface.js",name:"MakeControlsForRenderSurface"}),ControlBind:Object.freeze({path:"objects/objects/controlBind.js",name:"ControlBind"}),FrqtlControlSlider:Object.freeze({path:"objects/objects/frqtl-control-slider.js",name:"FrqtlControlSlider"}),FrqtlControlWriteQueue:Object.freeze({path:"objects/objects/frqtl-control-write-queue.js",name:"FrqtlControlWriteQueue"}),FrqtlControlsPanel:Object.freeze({path:"parts/FrqtlControlsPanel.js",name:"FrqtlControlsPanel"}),CameraControls:Object.freeze({path:"parts/CameraControls.js",name:"CameraControls"}),Filters:Object.freeze({path:"compat/renderer/Filters.js",name:"Filters"}),OrbitBag:Object.freeze({path:"compat/renderer/orbit-bag.js",name:null}),LoDrawnCenter:Object.freeze({path:"compat/renderer/lo-drawn-center.js",name:null}),ShimRpc:Object.freeze({path:"shim/rpc/index.js",name:null}),ControlRegistry:Object.freeze({path:"shim/controls/registry.js",name:null}),RenderState:Object.freeze({path:"shim/render-state/apply.js",name:null})}),ex=Object.keys(al).map(function(e){return al[e].path}),Oa=new WeakMap,TS=new WeakMap;function AA(e){if(!e||typeof e.resolve!="function")throw new TypeError("[frame-modules] a router (engineRouter() instance) is required — the frame's module URLs come from the ONE path authority. (FAIL-LOUD.)")}function PA(e,t,n){return new Promise(function(r,i){if(!e||!e.document)throw new TypeError("[frame-modules] frameImport(cw, …): cw is the frame's contentWindow. (FAIL-LOUD.)");if(ex.indexOf(t)===-1)throw new Error('[frame-modules] "'+t+'" is not a frame module — the table is lib/features/ide/frame-modules.js FRAME_MODULES ('+ex.join(", ")+"). (FAIL-LOUD.)");AA(n);const o=new URL(n.resolve(t),document.baseURI).href;let s;try{s=new e.Function("u","return import(u)")}catch(a){throw new Error("[frame-modules] the frame refused to evaluate its module-import door ("+(a&&a.message||a)+") — a content-security policy without 'unsafe-eval' blocks frameImport (lib/features/ide/frame-modules.js); this host cannot drive a frame's modules. (FAIL-LOUD.)")}r(s(o).catch(function(a){throw new Error("[frame-modules] the frame could not import "+t+" from "+o+" (frame "+e.location.href+"): "+(a&&a.message||a)+". (FAIL-LOUD.)")}))})}function MA(e,t){const n=e&&e.document;if(!n)return Promise.reject(new TypeError("[frame-modules] loadFrameModules(cw, router): cw is the frame's contentWindow. (FAIL-LOUD.)"));if(Oa.has(n))return Oa.get(n);const r=Object.keys(al),i=Promise.all(r.map(function(o){return PA(e,al[o].path,t)})).then(function(o){const s={};r.forEach(function(l,c){const u=al[l],d=u.name===null?o[c]:o[c][u.name];if(d===void 0)throw new Error("[frame-modules] "+u.path+" exports no "+u.name+". (FAIL-LOUD.)");s[l]=d});const a=Object.freeze(s);return TS.set(n,a),a});return Oa.set(n,i),i.catch(function(){Oa.get(n)===i&&Oa.delete(n)}),i}function rc(e){const t=e&&e.document;return t&&TS.get(t)||null}function TA(e,t){if(!t||typeof t.envelopeOf!="function")throw new Error("[project-design] computeEntityBboxForDesign needs the live runner (its envelopeOf is the ONE envelope of a declared object). (FAIL-LOUD.)");var n=t.envelopeOf(e);return n?{left:Math.round(n.left),top:Math.round(n.top),width:Math.round(n.w),height:Math.round(n.h)}:null}function DA(e,t,n,r,i,o){if(arguments.length>6)throw new Error('[project-design] buildObject("'+e+`"): takes (kind, runner, cw, x, y, overrideProps) — a world size is not an argument; the builder reads runner.canvas_rect, written by the scene's exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg). (FAIL-LOUD.)`);if(!t||!n)throw new Error('[project-design] buildObject("'+e+'"): '+(t?"no iframe scope (cw)":"no runner")+" — a palette drop needs the live runner and the canvas iframe window. (FAIL-LOUD.)");var s=rc(n);if(!s)throw new Error('[project-design] buildObject("'+e+`"): the frame's modules are not loaded — loadFrameModules(cw, router) (lib/features/ide/frame-modules.js) runs before a runner is taken. (FAIL-LOUD.)`);var a=s.ObjectFactory;return a.create(e,o,{runner:t,cw:n,x:r,y:i,fromPalette:!0})}const IA="data-frqtl-studio-landing",DS=Object.freeze([{id:"refused-key",runs:!1,cards:!1,means:"the link carries a key STUDIO does not own, or a deleted key (deep-link.js deepLinkRefusalOf): the refusal is on the deep-link strip and the opening scene opens"},{id:"conflict",runs:!1,cards:!1,means:"the link names more than one scene source (two of walkthrough, project and scene), or a renderer beside a walkthrough or a project, which carry their own: nothing opens"},{id:"mode-without-walkthrough",runs:!1,cards:!1,means:"the link names a mode and no walkthrough: nothing opens"},{id:"renderer-without-scene",runs:!1,cards:!1,means:"the link names a renderer and no scene; a renderer is chosen only for a scene link: nothing opens"},{id:"unknown-walkthrough",runs:!1,cards:!1,means:"the linked walkthrough is not a scene of the loaded roster (walkthroughById(roster, id)): nothing opens"},{id:"unknown-mode",runs:!1,cards:!1,means:"the linked mode is not one the linked scene declares (walkthroughModes): nothing opens"},{id:"scene-refused-origin",runs:!1,cards:!1,means:"the linked scene URL is on neither the page's origin nor the roster's (roster-link.js sceneOriginRefusalOf): the strip names the rule and both origins; nothing opens"},{id:"scene-unreadable",runs:!1,cards:!1,means:"the linked scene URL is allowed but its read failed (a non-200, an empty body, or not a .js sketch): nothing opens"},{id:"project-unreadable",runs:!1,cards:!1,means:"the linked saved project is present but its folder is refused by the load: nothing opens"},{id:"project-not-found",runs:!1,cards:!1,means:"no saved project of the linked name in this browser: nothing opens"},{id:"ok",runs:!0,cards:!0,means:"the linked walkthrough (in the linked mode, else its default), saved project or scene resolved and was handed to STUDIO's selection path; the scene starts on load"},{id:"first-contact",runs:!1,cards:!0,means:"no STUDIO deep link: the roster's first-contact scene (firstContactOf(roster)) opens, offering its showcase cards and try-it as its deep link does"},{id:"first-contact-empty",runs:!1,cards:!1,means:"no STUDIO deep link and the roster declares no first contact: the Empty Universe opens"}].map(Object.freeze)),tx=new Set(DS.map(e=>e.id));function IS(e,t){if(!tx.has(t))throw new Error("[studio-landing] '"+t+"' is not a STUDIO_LANDING_OUTCOMES row — declared: ["+[...tx].join(", ")+"]. (FAIL-LOUD.)");return e&&e.setAttribute(IA,t),t}const FS="frqtl-roster",FA=3e5,Oh='<link rel="'+FS+'" href="https://…">';function NA(e){if(!e||typeof e.querySelectorAll!="function")throw new Error("[roster-link] rosterHrefOf(doc) takes a document; got "+String(e)+". (FAIL-LOUD.)");const t=Array.from(e.querySelectorAll('link[rel~="'+FS+'"]'));if(t.length===0)throw new Error("[roster-link] this document has no "+Oh+" — STUDIO and the GYM read their scene list from the roster it names; the host writes the link into the page. (FAIL-LOUD.)");if(t.length>1)throw new Error("[roster-link] this document has "+t.length+" "+Oh+" links; a document names exactly one roster. (FAIL-LOUD.)");const n=t[0].getAttribute("href"),r=Kg(n);if(r)throw new Error("[roster-link] "+Oh+": "+r+" (FAIL-LOUD.)");return n}function zA(e,t){const n=Kg(e);if(n)throw new Error("[roster-link] rosterRequestUrl(href, now): "+n+" (FAIL-LOUD.)");if(!Number.isFinite(t))throw new Error("[roster-link] rosterRequestUrl(href, now): now is epoch milliseconds (got "+String(t)+"). (FAIL-LOUD.)");return new URL(e).protocol==="file:"?e:e+"?b="+Math.floor(t/FA)}function BA(e,t){return Promise.resolve().then(()=>{const n=t||{},r=zA(e,n.now===void 0?Date.now():n.now);return Jg(r,{fetch:n.fetch}).then(i=>{if(i.trim()==="")throw new Error("[roster-link] roster "+r+" is empty. (FAIL-LOUD.)");let o=null;try{o=JSON.parse(i)}catch(s){throw new Error("[roster-link] roster "+r+" is not JSON: "+s.message+" (FAIL-LOUD.)")}return lA(o,e)},i=>{throw new Error("[roster-link] loading the roster failed: "+i.message+" (FAIL-LOUD.)")})})}function UA(e,t){const n=t||{};if(Jt(n.roster,"sceneOriginRefusalOf(url, { pageOrigin, roster })"),typeof n.pageOrigin!="string"||n.pageOrigin==="")throw new Error("[roster-link] sceneOriginRefusalOf(url, { pageOrigin, roster }): pageOrigin is the page's location.origin (got "+JSON.stringify(n.pageOrigin)+"). (FAIL-LOUD.)");const r=new URL(n.roster.href).origin;let i=null;try{i=new URL(e).origin}catch{i=null}return i!==null&&i!=="null"&&(i===n.pageOrigin||i===r)?null:"a scene opens from this page's origin ("+n.pageOrigin+") or its roster's origin ("+r+"); "+JSON.stringify(e)+" is "+(i===null?"not an absolute URL":"on "+i)+"."}var HA=new TextEncoder,WA=new TextDecoder;function um(e){return HA.encode(e==null?"":String(e))}function VA(e){return WA.decode(e)}var qA=function(){for(var e=new Uint32Array(256),t=0;t<256;t++){for(var n=t,r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e}();function NS(e){for(var t=4294967295,n=0;n<e.length;n++)t=t>>>8^qA[(t^e[n])&255];return(t^4294967295)>>>0}function Ot(e){return[e&255,e>>>8&255]}function Kn(e){return e=e>>>0,[e&255,e>>>8&255,e>>>16&255,e>>>24&255]}function fs(e){var t=0,n;for(n=0;n<e.length;n++)t+=e[n].length;var r=new Uint8Array(t),i=0;for(n=0;n<e.length;n++)r.set(e[n],i),i+=e[n].length;return r}function vo(e,t){return e[t]|e[t+1]<<8}function yo(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}var zS=67324752,BS=33639248,US=101010256;function $A(e){if(!Array.isArray(e))throw new Error("[bundle/zip] zipStore(entries): entries must be an array.");for(var t=[],n=[],r=0,i=0;i<e.length;i++){var o=e[i];if(!o||typeof o.name!="string"||!(o.bytes instanceof Uint8Array))throw new Error("[bundle/zip] zipStore: entry "+i+" must be {name:string, bytes:Uint8Array}.");var s=um(o.name),a=o.bytes,l=NS(a),c=a.length,u=fs([new Uint8Array(Kn(zS)),new Uint8Array(Ot(20)),new Uint8Array(Ot(0)),new Uint8Array(Ot(0)),new Uint8Array(Ot(0)),new Uint8Array(Ot(0)),new Uint8Array(Kn(l)),new Uint8Array(Kn(c)),new Uint8Array(Kn(c)),new Uint8Array(Ot(s.length)),new Uint8Array(Ot(0)),s,a]);t.push(u);var d=fs([new Uint8Array(Kn(BS)),new Uint8Array(Ot(20)),new Uint8Array(Ot(20)),new Uint8Array(Ot(0)),new Uint8Array(Ot(0)),new Uint8Array(Ot(0)),new Uint8Array(Ot(0)),new Uint8Array(Kn(l)),new Uint8Array(Kn(c)),new Uint8Array(Kn(c)),new Uint8Array(Ot(s.length)),new Uint8Array(Ot(0)),new Uint8Array(Ot(0)),new Uint8Array(Ot(0)),new Uint8Array(Ot(0)),new Uint8Array(Kn(0)),new Uint8Array(Kn(r)),s]);n.push(d),r+=u.length}var f=fs(t),h=fs(n),g=fs([new Uint8Array(Kn(US)),new Uint8Array(Ot(0)),new Uint8Array(Ot(0)),new Uint8Array(Ot(e.length)),new Uint8Array(Ot(e.length)),new Uint8Array(Kn(h.length)),new Uint8Array(Kn(f.length)),new Uint8Array(Ot(0))]);return fs([f,h,g])}function KA(e){if(!(e instanceof Uint8Array))throw new Error("[bundle/zip] unzipStore(bytes): bytes must be a Uint8Array.");for(var t=-1,n=e.length-22;n>=0;n--)if(yo(e,n)===US){t=n;break}if(t===-1)throw new Error("[bundle/zip] unzipStore: End Of Central Directory record not found (not a ZIP).");for(var r=vo(e,t+10),i=yo(e,t+16),o=[],s=i,a=0;a<r;a++){if(yo(e,s)!==BS)throw new Error("[bundle/zip] unzipStore: bad central directory signature at record "+a+".");var l=vo(e,s+10),c=yo(e,s+16),u=yo(e,s+20),d=vo(e,s+28),f=vo(e,s+30),h=vo(e,s+32),g=yo(e,s+42),m=VA(e.subarray(s+46,s+46+d));if(l!==0)throw new Error('[bundle/zip] unzipStore: entry "'+m+'" uses compression method '+l+" — this reader is STORE-only (method 0).");if(yo(e,g)!==zS)throw new Error('[bundle/zip] unzipStore: bad local header signature for "'+m+'".');var x=vo(e,g+26),y=vo(e,g+28),b=g+30+x+y,w=e.slice(b,b+u),E=NS(w);if(E!==c)throw new Error('[bundle/zip] unzipStore: CRC-32 mismatch for "'+m+'" (stored '+c+", computed "+E+").");o.push({name:m,bytes:w}),s+=46+d+f+h}return o}var Zg="frqtl-boot",Cu='<script type="application/json" id="'+Zg+'">',HS="<\/script>";function YA(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function nx(e){return JSON.stringify(e??null).replace(/</g,"\\u003c")}function GA(e){if(e=e||{},typeof e.sdkVersion!="string"||e.sdkVersion.length===0)throw new Error("[bundle/indexHtml] buildIndexHtml: args.sdkVersion is REQUIRED (the CDN pin). (FAIL-LOUD.)");if(typeof e.name!="string"||e.name.length===0)throw new Error("[bundle/indexHtml] buildIndexHtml: args.name is the project's frqtl.json name. (FAIL-LOUD.)");var t=nx(iL(Pk(e.sdkVersion)+"/"));return["<!DOCTYPE html>",'<html lang="en">',"<head>",' <meta charset="UTF-8">',' <meta name="viewport" content="width=device-width, initial-scale=1">'," <title>"+YA(e.name)+" — FRQTL</title>"," <style>"," html,body{margin:0;height:100%;background:#0b0b0f;color:#ddd;"," font:14px/1.5 ui-sans-serif,system-ui,sans-serif;}"," #frqtl-mount{position:relative;width:100vw;height:100vh;}"," #frqtl-err{position:absolute;inset:0;padding:16px;white-space:pre-wrap;"," font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;color:#ff6b6b;"," background:#1a0000;display:none;overflow:auto;}"," </style>","</head>","<body>",' <div id="frqtl-mount"></div>',' <pre id="frqtl-err"></pre>'," "+Cu+nx(e.renderState)+HS,' <script type="importmap">'+t+"<\/script>",' <script type="module">'," import { bootProject } from "+JSON.stringify(zk.specifier)+";"," const renderState = JSON.parse(document.getElementById("+JSON.stringify(Zg)+").textContent);",' const mount = document.getElementById("frqtl-mount");',' const errBox = document.getElementById("frqtl-err");'," function fail(title, detail){",' errBox.style.display = "block";',' errBox.textContent = title + "\\n\\n" + detail;'," }",' if (location.protocol === "file:") {',' fail("Serve this folder over http", "e.g. `npx serve` — a file:// page cannot fetch the project files.");'," } else {",' bootProject(mount, { url: new URL("./", location.href).href }, { renderState: renderState })',' .catch((e) => fail("FRQTL project boot failed", String(e && e.stack || e)));'," }"," <\/script>","</body>","</html>",""].join(`
72
+ `)}function JA(e){if(typeof e!="string")throw new Error("[bundle/indexHtml] readBootBag(html): the page text (got "+typeof e+"). (FAIL-LOUD.)");var t=e.indexOf(Cu);if(t===-1)throw new Error('[bundle/indexHtml] the index.html carries no boot bag (<script type="application/json" id="'+Zg+'">) — it is not the page an Export writes. (FAIL-LOUD.)');if(e.indexOf(Cu,t+1)!==-1)throw new Error("[bundle/indexHtml] the index.html carries two boot bags — an Export writes one. (FAIL-LOUD.)");var n=t+Cu.length,r=e.indexOf(HS,n);if(r===-1)throw new Error("[bundle/indexHtml] the boot bag element is not closed. (FAIL-LOUD.)");try{return JSON.parse(e.slice(n,r))}catch(i){throw new Error("[bundle/indexHtml] the boot bag is not valid JSON: "+(i&&i.message||i)+". (FAIL-LOUD.)")}}var XA=Object.freeze(["experiment.js","manifest.json"]),WS="this is the retired export format; the project folder replaced it (frqtl.json + sketch.js)",rx="sketch.js",QA=new TextDecoder("utf-8",{fatal:!0});function hr(e){throw new Error("[bundle] "+e+" (FAIL-LOUD.)")}function ZA(e,t,n){var r=eo({files:e,renderState:t}),i=n&&n.sdkVersion,o=es(r.files[Ge]).name,s=Object.keys(r.files).map(function(a){return{name:a,bytes:um(r.files[a])}});return s.push({name:yd,bytes:um(GA({name:o,sdkVersion:i,renderState:r.renderState}))}),$A(s)}function eP(e){return e.length>=4&&e[0]===80&&e[1]===75&&(e[2]===3&&e[3]===4||e[2]===5&&e[3]===6)}function VS(e,t){try{return QA.decode(e)}catch{hr(t+" is not UTF-8 text — a project folder holds text files only.")}}function qS(e){var t=String(e).split(/[\\/]/).pop();return t}function tP(e){var t=KA(e).filter(function(a){return!/\/$/.test(a.name)}),n=t.map(function(a){return a.name}),r=XA.filter(function(a){return n.indexOf(a)!==-1});if(r.length&&hr("the archive carries "+r.join(" and ")+": "+WS+"."),n.indexOf(Ge)===-1){var i=n.map(function(a){return a.split("/")[0]}).filter(function(a,l,c){return c.indexOf(a)===l});i.length===1&&n.indexOf(i[0]+"/"+Ge)!==-1&&n.every(function(a){return a.indexOf(i[0]+"/")===0})&&hr("the archive carries no "+Ge+" at its root — the archive holds the folder `"+i[0]+"/` rather than its contents — zip the folder's CONTENTS ("+Ge+" at the root), as an Export writes it."),hr("the archive carries no "+Ge+" at its root — a project archive is the folder zipped (frqtl.json + sketch.js + …), as an Export writes it.")}var o={},s=null;return t.forEach(function(a){var l=VS(a.bytes,'"'+a.name+'"');if(a.name===yd){s=JA(l);return}o[a.name]=l}),eo({files:o,renderState:s})}function nP(e){var t;try{t=JSON.parse(e)}catch{hr("the file is neither a project archive (.zip) nor a sketch (.js), and not valid JSON either.")}t&&typeof t=="object"&&("schemaVersion"in t||"scripts"in t)&&"source"in t&&hr("the file is a v4 module envelope: "+WS+"."),hr("the JSON file is not a project — Import takes a project archive (.zip) or one sketch (.js).")}function rP(e,t){var n=qS(t),r=n.replace(/\.js$/,"");r||hr('the sketch file "'+n+'" has no name before ".js".');var i={};return i[Ge]=Gg(_S({name:r,entry:rx})),i[rx]=e,eo({files:i,renderState:null})}function $S(e,t){if(e instanceof Uint8Array||hr("importArchive(bytes, fileName): bytes is a Uint8Array."),(typeof t!="string"||t.length===0)&&hr("importArchive(bytes, fileName): the file's name."),eP(e))return tP(e);var n=qS(t);if(/\.mjs$/i.test(n)){var r=md.filter(function(o){return o.key==="entry"})[0].rule;hr('"'+n+`" is a .mjs module — a one-file Import takes a .js sketch, because a project's entry is `+r+" (frqtl.json, lib/shim/project/manifest.js MANIFEST_KEYS). Rename it to .js and import it again.")}var i=VS(e,'"'+n+'"');if(/\.js$/.test(n))return rP(i,n);if(/\.json$/i.test(n)||/^\s*\{/.test(i))return nP(i);hr('"'+n+'" is not a project — Import takes a project archive (.zip, as an Export writes it) or one sketch (.js).')}var Ti="_empty",Ao="scene:";function iP(e,t,n){if(!e||e===Ti)return"Empty Universe (New)";if(e.indexOf(Ao)===0){var r=e.slice(Ao.length);return"Scene draft: "+decodeURIComponent(r.split("?")[0].split("/").pop()||r)}if(e.indexOf("walkthrough:")===0){var i=e.slice(12),o=n&&n.find(function(l){return l.id===i});return o?o.title:i}if(e.indexOf("project:")===0){var s=e.slice(8),a=t&&t.find(function(l){return l.id===s});return a?a.name:s}return e}function KS(e){return e&&typeof e.label=="string"&&e.label?e.label:e.name}function YS(e){if(!e||e.type!=="number")return null;var t=e.constraint||{},n=e.widgetConfig||{},r=function(i){return typeof i=="number"&&isFinite(i)};return!r(t.min)||!r(t.max)||!r(n.step)||n.step<=0||t.max<=t.min?null:{min:t.min,max:t.max,step:n.step}}function Ch(e){if(!Array.isArray(e))throw new TypeError("[author-ux-utils] declaredLayerRows takes runner.declared (an array). (FAIL-LOUD.)");return e.map(function(t){return{ref:t,name:t.name||t._schemaKind,schemaKind:t._schemaKind,visible:t.visible!==!1}})}var Ca="studioLandingOf(link, { roster, loadProject, pageOrigin, baseURI, fetch? })",bd="walkthrough:";function On(e,t,n){var r=DS.find(function(s){return s.id===IS(null,e)}),i=!!(n&&n.value.indexOf(bd)===0),o=r.cards&&i?{id:n.value.slice(bd.length),modeId:n.mode}:null;return{id:e,err:t||null,select:n||null,run:r.runs,cards:o}}function ix(e){var t=fA(e);return t?{value:bd+t.id,mode:null,opts:{quiet:!0}}:{value:Ti,mode:null,opts:{quiet:!0}}}function oP(e){if(!e||typeof e!="object")throw new Error("[studio-landing-of] "+Ca+": deps is an object. (FAIL-LOUD.)");if(typeof e.walkthroughById=="function"||typeof e.walkthroughModes=="function")throw new Error("[studio-landing-of] "+Ca+": deps carry the loaded roster bag, never the registry readers (walkthroughById/walkthroughModes) — the resolver reads the roster itself. (FAIL-LOUD.)");if(Jt(e.roster,Ca),typeof e.loadProject!="function")throw new Error("[studio-landing-of] "+Ca+": deps.loadProject is the saved-project loader. (FAIL-LOUD.)");["pageOrigin","baseURI"].forEach(function(t){if(typeof e[t]!="string"||e[t]==="")throw new Error("[studio-landing-of] "+Ca+": deps."+t+" is the page's "+(t==="pageOrigin"?"location.origin":"document.baseURI")+" (got "+JSON.stringify(e[t])+"). (FAIL-LOUD.)")})}function sP(e,t){var n=null;try{n=new URL(e.scene,t.baseURI).href}catch{n=null}var r=n===null?JSON.stringify(e.scene)+" is not a URL":UA(n,{pageOrigin:t.pageOrigin,roster:t.roster});if(r)return Promise.resolve(On("scene-refused-origin","Deep link error: scene refused — "+r));var i=null;e.renderer&&(i=bi({renderer:e.renderer}).renderer);var o=function(s){return On("scene-unreadable",'Deep link error: scene "'+e.scene+'" — '+s)};return Jg(n,{fetch:t.fetch}).then(function(s){if(!s.trim())return o(n+" has an empty body.");var a=decodeURIComponent(new URL(n).pathname.split("/").pop()||""),l;try{l=$S(new TextEncoder().encode(s),a)}catch(d){return o(d&&d.message?d.message:String(d))}var c=i===null?l.renderState:bi(Object.assign({},l.renderState,{renderer:i})),u={scene:e.scene};return e.renderer&&(u.renderer=e.renderer),On("ok",null,{value:Ao+n,mode:null,opts:{folder:{files:Object.assign({},l.files),renderState:c},link:u}})},function(s){return o(s&&s.message?s.message:String(s))})}function aP(e,t){return Promise.resolve().then(function(){oP(t);var n=e||{},r=t.roster;if(n.refusal)return On("refused-key",n.refusal,ix(r));var i=["walkthrough","project","scene"].filter(function(c){return n[c]});if(i.length>1)return On("conflict","Deep link error: "+i.map(function(c){return c+'="'+n[c]+'"'}).join(" conflicts with ")+" — a deep link selects ONE scene; keep one of them.");if(n.renderer&&(n.walkthrough||n.project))return On("conflict",'Deep link error: renderer="'+n.renderer+'" conflicts with '+(n.walkthrough?'walkthrough="'+n.walkthrough+'"':'project="'+n.project+'"')+" — that scene carries its own renderer; renderer= is for a ?scene= draft only.");if(n.mode&&!n.walkthrough)return On("mode-without-walkthrough",'Deep link error: mode="'+n.mode+'" needs walkthrough=<scene id> — a mode belongs to a roster scene.');if(n.renderer&&!n.scene)return On("renderer-without-scene",'Deep link error: renderer="'+n.renderer+'" needs scene=<url> — a renderer is chosen only for a scene draft.');if(n.walkthrough){var o=Kt(r,n.walkthrough);if(!o)return On("unknown-walkthrough",'Deep link error: unknown walkthrough "'+n.walkthrough+`" — not a scene of this site's roster.`);if(n.mode){var s=Dl(o).map(function(c){return c.id});if(s.indexOf(n.mode)===-1)return On("unknown-mode",'Deep link error: unknown mode "'+n.mode+'" for walkthrough "'+o.id+'" — declared modes: ['+s.join(", ")+"].")}return On("ok",null,{value:bd+o.id,mode:n.mode||null})}if(n.scene)return sP(n,t);if(n.project){var a;try{a=t.loadProject(n.project)}catch(c){return On("project-unreadable",'Deep link error: saved project "'+n.project+'" — '+(c&&c.message?c.message:c))}return a?On("ok",null,{value:"project:"+n.project,mode:null}):On("project-not-found",'Deep link error: saved project "'+n.project+'" not found.')}var l=ix(r);return On(l.value===Ti?"first-contact-empty":"first-contact",null,l)})}const lP=4,cP=200,uP=[{scene:{id:"cl1d-mirror-route",modeId:"3d"},part:"m6",homes:"starPoints",title:"Try it: put the mirror back",ask:{desktop:[["One mirror is out of place: the cyan one, standing inside the ring. Pick the Hand (the hand icon under Tools, on the left), then drag the cyan mirror out into its empty slot in the ring."]],phone:[["One mirror is out of place: the cyan one, standing inside the ring. Tap HAND at the bottom, then drag the cyan mirror with one finger out into its empty slot in the ring."]]},done:[["Done: the cyan mirror is back in its slot."]],status:function(e){return"It is "+e+" px from its slot."}}];function dP(e,t){var n="[studio-try-it] row "+t;if(!e.scene||typeof e.scene.id!="string"||e.scene.id==="")throw new Error(n+": scene is { id, modeId }.");if(["part","homes"].forEach(function(r){if(typeof e[r]!="string"||e[r]==="")throw new Error(n+": "+r+" is a non-empty name.")}),ea(e.title,n+".title"),Io(e.ask.desktop,n+".ask.desktop",{table:!1}),Io(e.ask.phone,n+".ask.phone",{table:!1}),Io(e.done,n+".done",{table:!1}),typeof e.status!="function")throw new Error(n+": status(px) words the live distance.");return ea(e.status(67),n+".status"),Object.freeze(e)}const Ba=Object.freeze(uP.map(dP));function fP(e,t){Jt(e,"tryItFor(roster, scene)");for(var n=ta(e,t),r=0;r<Ba.length;r++)if(Kt(e,Ba[r].scene.id)&&ta(e,Ba[r].scene)===n)return Ba[r];return null}function df(e){if(Ba.indexOf(e)===-1)throw new Error("[studio-try-it] not a try-it row — pass tryItFor(scene)'s answer. (FAIL-LOUD.)")}function hP(e,t){return Jt(e,"tryItKey(roster, row)"),df(t),"tryit-"+ta(e,t.scene)}function pP(e,t,n){if(Jt(e,"tryItBag(roster, row, { onPhone })"),df(t),!n||typeof n.onPhone!="boolean")throw new TypeError("[studio-try-it] tryItBag(roster, row, { onPhone }): onPhone is isMobileDevice(window) (lib/shim/host/device.js). (FAIL-LOUD.)");return{seenKey:hP(e,t),title:t.title,paragraphs:t.ask[n.onPhone?"phone":"desktop"]}}function mP(e,t){df(e);var n=t&&t[e.homes],r=n&&n[e.part];if(!Array.isArray(r)||typeof r[0]!="number"||typeof r[1]!="number")throw new Error("[studio-try-it] the scene "+e.scene.id+" does not export "+e.homes+"."+e.part+" as [x, y] — the try-it reads where "+e.part+" belongs from the scene file. (FAIL-LOUD.)");return r}function gP(e,t){return Math.hypot(e.left+e.w/2-t[0],e.top+e.h/2-t[1])}function vP(e,t,n,r){Jt(t,"watchTryIt(hostEl, roster, row, how)"),df(n),["runnerOf","exportsOf","onError"].forEach(function(d){if(!r||typeof r[d]!="function")throw new TypeError("[studio-try-it] watchTryIt(hostEl, roster, row, how): how."+d+" is a function. (FAIL-LOUD.)")});var i=NL(e,pP(t,n,{onPhone:r.onPhone}),{dock:r.dock}),o=e.ownerDocument.defaultView,s=null,a=!1,l=!1;function c(){s!==null&&(o.clearInterval(s),s=null)}function u(){if(!i.showing()){c();return}var d;try{var f=r.runnerOf(),h=r.exportsOf();if(!f||!h)return;var g=f.declared.find(function(x){return x.name===n.part});if(!g)throw new Error('[studio-try-it] the running scene declares no "'+n.part+'" — the try-it has nothing to watch. (FAIL-LOUD.)');var m=f.envelopeOf(g);if(!m)throw new Error('[studio-try-it] "'+n.part+'" has no envelope to read. (FAIL-LOUD.)');d=gP(m,mP(n,h))}catch(x){l=!0,c(),i.status(""),r.onError(x&&x.message?x.message:String(x));return}if(d<=lP){l=!0,c(),e.dataset.tryItOffPx=d.toFixed(2),i.complete(n.done);return}e.dataset.tryItOffPx=d.toFixed(2),i.status(ea(n.status(Math.round(d)),"[studio-try-it] status"))}return i.ready.then(function(d){a||!d.shows||(u(),l||(s=o.setInterval(u,cP)))}),{ready:i.ready,close:function(){a=!0,c(),delete e.dataset.tryItOffPx,i.close()}}}const ev=Object.freeze({slopPx:8,longPressMs:500,doubleTapMs:350,doubleTapPx:32,pinchOn:.06,twistOnDeg:8,panOnPx:12,orbitDegPerView:180,wheelZoomPerPx:.001,wheelMaxPx:500});function yP(e,t){if(typeof e!="number"||!isFinite(e))throw new Error("[canvas-gestures] wheelDeltaPx needs a finite deltaY (got "+String(e)+"). (FAIL-LOUD.)");var n=t===1?16:t===2?800:1;return e*n}function bP(e,t,n){var r=n||ev,i=Math.max(-r.wheelMaxPx,Math.min(r.wheelMaxPx,yP(e,t)));return Math.exp(-i*r.wheelZoomPerPx)}const xP=Object.freeze({orbit:Object.freeze(["azimuth","elevation"]),zoom:Object.freeze(["distance"]),roll:Object.freeze(["roll"]),pan:Object.freeze(["target"])});function tv(e){var t=(e%360+360)%360;return t>180?t-360:t}function wP(e,t,n,r){var i=Math.hypot(t.x-e.x,t.y-e.y),o=Math.hypot(r.x-n.x,r.y-n.y),s=Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI,a=Math.atan2(r.y-n.y,r.x-n.x)*180/Math.PI;return{scale:i>0?o/i:1,twistDeg:tv(a-s),centroid:{x:(n.x+r.x)/2,y:(n.y+r.y)/2}}}function _P(e,t,n,r){if(!(n>0))throw new Error("[canvas-gestures] orbitDelta needs the canvas width (got "+String(n)+"). (FAIL-LOUD.)");var i=(r||0)*Math.PI/180,o=e*Math.cos(i)-t*Math.sin(i),s=e*Math.sin(i)+t*Math.cos(i),a=ev.orbitDegPerView/n;return{dAz:a*o,dEl:-a*s}}function Ua(e,t){if(!Array.isArray(e))throw new Error("[canvas-gestures] the camera publishes no poseFields array — every camera handle declares its axes (RENDERER_CONTRACT §1a.2). (FAIL-LOUD.)");for(var n=0;n<e.length;n++){var r=e[n];if(r&&r.name===t){var i=r.constraint||{};return{min:typeof i.min=="number"?i.min:-1/0,max:typeof i.max=="number"?i.max:1/0,wrap:typeof i.wrap=="number"?i.wrap:null}}}return null}function GS(e,t){return Math.min(t.max,Math.max(t.min,e))}function jh(e,t){if(!t.wrap)return GS(e,t);var n=isFinite(t.min)?t.min:-t.wrap/2;return((e-n)%t.wrap+t.wrap)%t.wrap+n}function kP(e,t){return xP[t].filter(function(n){return!Ua(e,n)})}function SP(e,t,n,r){var i={},o=[];function s(c){var u=kP(n,c);return u.length?(o.push({gesture:c,axes:u}),!1):!0}if(t.fingers===1){if((t.dx||t.dy)&&s("orbit")){var a=_P(t.dx,t.dy,r,e.roll);i.azimuth=jh(e.azimuth+a.dAz,Ua(n,"azimuth")),i.elevation=jh(e.elevation+a.dEl,Ua(n,"elevation"))}return{patch:i,refused:o}}var l=t.active||{};return l.zoom&&s("zoom")&&(i.distance=GS(e.distance/t.scale,Ua(n,"distance"))),l.roll&&s("roll")&&(i.roll=jh(e.roll-t.twistDeg,Ua(n,"roll"))),l.pan&&s("pan"),{patch:i,refused:o}}function EP(e,t,n){var r=50;function i(a){var l=a*Math.PI/180,c=e([t[0],t[1],t[2]||0]),u=e([t[0]+r*Math.cos(l),t[1]+r*Math.sin(l),t[2]||0]);return!c||!u?null:Math.atan2(u[1]-c[1],u[0]-c[0])*180/Math.PI}var o=i(n),s=i(n+5);if(o===null||s===null)throw new Error("[canvas-gestures] the object's centre is not on screen from this view, so its turning sense cannot be read. (FAIL-LOUD.)");return tv(s-o)>=0?1:-1}function OP(e,t,n){var r=e+n*t;return(r%360+360)%360}function CP(e){if(!e||typeof e.hitTest!="function"||typeof e.handArmed!="function"||typeof e.emit!="function")throw new Error("[canvas-gestures] createGestureReader({ hitTest, handArmed, emit }) needs all three functions. (FAIL-LOUD.)");var t=Object.assign({},ev,e.tuning||{}),n=e.timers||{set:function(w,E){return setTimeout(w,E)},clear:function(w){clearTimeout(w)}},r=e.emit,i=new Map,o=null,s=null,a=null,l=null,c=null;function u(){l!==null&&(n.clear(l),l=null)}function d(w){var E=[];i.forEach(function(M,L){E.length<2&&E.push(L)});var C=i.get(E[0]),S=i.get(E[1]);a={ids:E,a0:{x:C.x,y:C.y},b0:{x:S.x,y:S.y},lastCentroid:{x:(C.x+S.x)/2,y:(C.y+S.y)/2},base:{scale:1,twist:0,centroid:{x:(C.x+S.x)/2,y:(C.y+S.y)/2}},active:w?{resize:!1,rotate:!1}:{zoom:!1,roll:!1,pan:!1},target:w||null},r(w?{kind:"object",phase:"begin",target:w}:{kind:"world",phase:"begin",fingers:2})}function f(){var w=i.get(a.ids[0]),E=i.get(a.ids[1]);if(!(!w||!E)){var C=wP(a.a0,a.b0,w,E),S=a.active,M=a.base,L=a.target?"resize":"zoom",T=a.target?"rotate":"roll";!S[L]&&Math.abs(C.scale-1)>t.pinchOn&&(S[L]=!0,M.scale=C.scale),!S[T]&&Math.abs(C.twistDeg)>t.twistOnDeg&&(S[T]=!0,M.twist=C.twistDeg);var V=S[L]?C.scale/M.scale:1,G=S[T]?tv(C.twistDeg-M.twist):0;if(a.target){r({kind:"object",phase:"update",target:a.target,scale:V,twistDeg:G,active:{resize:S.resize,rotate:S.rotate}});return}var F=null;!S.pan&&Math.hypot(C.centroid.x-M.centroid.x,C.centroid.y-M.centroid.y)>t.panOnPx&&(S.pan=!0,a.lastCentroid={x:M.centroid.x,y:M.centroid.y}),S.pan&&(F={from:a.lastCentroid,to:{x:C.centroid.x,y:C.centroid.y}},a.lastCentroid={x:C.centroid.x,y:C.centroid.y}),r({kind:"world",phase:"update",fingers:2,scale:V,twistDeg:G,pan:F,active:{zoom:S.zoom,roll:S.roll,pan:S.pan}})}}function h(){a&&(a.target?r({kind:"object",phase:"end",target:a.target}):r({kind:"world",phase:"end",fingers:2}),a=null)}function g(w){if(w.type==="mouse"){if(w.button!==void 0&&w.button!==0)return;var E=e.hitTest(w.x,w.y)||null;E&&e.handArmed()?(o="mouse",r({kind:"press",x:w.x,y:w.y})):(o="mouse-pending",s={id:w.id,x0:w.x,y0:w.y,t0:w.t,hit:E});return}if(i.set(w.id,{x:w.x,y:w.y}),i.size===1){var C=e.hitTest(w.x,w.y)||null;s={id:w.id,x0:w.x,y0:w.y,t0:w.t,hit:C},C&&e.handArmed()?(o="pending-object",l=n.set(function(){l=null,o==="pending-object"&&(o="held",r({kind:"hold",x:s.x0,y:s.y0}))},t.longPressMs)):o="pending-world";return}if(i.size===2&&(o==="pending-object"||o==="object-drag"||o==="pending-world"||o==="world-1")){u();var S=e.hitTest(w.x,w.y)||null,M=o==="pending-object"||o==="object-drag";o==="object-drag"&&r({kind:"release"}),o==="world-1"&&r({kind:"world",phase:"end",fingers:1}),M&&S&&S===s.hit?(o="object-2",d(s.hit)):(o="world-2",d(null));return}}function m(w){if(w.type==="mouse"){o==="mouse"?r({kind:"drag",x:w.x,y:w.y}):o==="mouse-pending"?Math.hypot(w.x-s.x0,w.y-s.y0)>t.slopPx&&(o="mouse-world",r({kind:"world",phase:"begin",fingers:1}),r({kind:"world",phase:"update",fingers:1,dx:w.x-s.x0,dy:w.y-s.y0})):r(o==="mouse-world"?{kind:"world",phase:"update",fingers:1,dx:w.x-s.x0,dy:w.y-s.y0}:{kind:"hover",x:w.x,y:w.y});return}if(i.has(w.id)){if(i.set(w.id,{x:w.x,y:w.y}),o==="world-2"||o==="object-2"){f();return}if(!(!s||w.id!==s.id)){var E=Math.hypot(w.x-s.x0,w.y-s.y0)>t.slopPx,C=o==="held"&&E&&typeof w.t=="number"&&typeof s.t0=="number"&&w.t-s.t0<t.longPressMs;(o==="pending-object"||C)&&E?(u(),o="object-drag",r({kind:"press",x:s.x0,y:s.y0}),r({kind:"drag",x:w.x,y:w.y})):o==="object-drag"?r({kind:"drag",x:w.x,y:w.y}):o==="pending-world"&&E?(o="world-1",r({kind:"world",phase:"begin",fingers:1}),r({kind:"world",phase:"update",fingers:1,dx:w.x-s.x0,dy:w.y-s.y0})):o==="world-1"&&r({kind:"world",phase:"update",fingers:1,dx:w.x-s.x0,dy:w.y-s.y0})}}}function x(w,E){if(w.type==="mouse"){o==="mouse"?r({kind:"release"}):o==="mouse-pending"&&!E?(r({kind:"press",x:s.x0,y:s.y0}),r({kind:"release"})):o==="mouse-world"&&r({kind:"world",phase:"end",fingers:1}),(o==="mouse"||o==="mouse-pending"||o==="mouse-world")&&(o=null,s=null);return}if(i.has(w.id)){if(i.delete(w.id),u(),o==="pending-object")E||(r({kind:"press",x:s.x0,y:s.y0}),r({kind:"release"})),o=null;else if(o==="pending-world"){if(!E){var C=!s.hit,S=C&&c&&s.t0-c.t<=t.doubleTapMs&&Math.hypot(s.x0-c.x,s.y0-c.y)<=t.doubleTapPx;S?(c=null,r({kind:"reset",x:s.x0,y:s.y0})):(r({kind:"press",x:s.x0,y:s.y0}),r({kind:"release"}),c=C?{t:w.t,x:s.x0,y:s.y0}:null)}o=null}else o==="object-drag"?(r({kind:"release"}),o=null):o==="world-1"?(r({kind:"world",phase:"end",fingers:1}),o=null):o==="world-2"||o==="object-2"?(h(),o="spent"):o==="held"&&(o="spent");i.size===0&&(o=null,s=null,a=null)}}function y(){u(),(o==="mouse"||o==="object-drag")&&r({kind:"release"}),(o==="world-1"||o==="mouse-world")&&r({kind:"world",phase:"end",fingers:1}),(o==="world-2"||o==="object-2")&&h(),i.clear(),o=null,s=null,a=null}function b(w){if(!w||typeof w.deltaY!="number")throw new Error("[canvas-gestures] reader.wheel({ deltaY, deltaMode }) needs the WheelEvent's deltaY. (FAIL-LOUD.)");if(!(o!==null||w.deltaY===0)){var E=bP(w.deltaY,w.deltaMode,t);r({kind:"world",phase:"begin",fingers:2}),r({kind:"world",phase:"update",fingers:2,scale:E,twistDeg:0,pan:null,active:{zoom:!0,roll:!1,pan:!1}}),r({kind:"world",phase:"end",fingers:2})}}return{down:g,wheel:b,move:m,up:function(w){x(w,!1)},cancel:function(w){x(w,!0)},reset:y,mode:function(){return o}}}function jP(e,t){if(!e||typeof e.addEventListener!="function")throw new Error("[canvas-gestures] bindCanvasGestures(el, reader) needs an element. (FAIL-LOUD.)");e.style.touchAction="none";function n(c){var u=e.getBoundingClientRect();return{id:c.pointerId,type:c.pointerType||"mouse",x:c.clientX-u.left,y:c.clientY-u.top,t:typeof c.timeStamp=="number"?c.timeStamp:Date.now(),button:c.button}}function r(c){c.pointerType==="mouse"&&c.button!==0||(t.down(n(c)),c.preventDefault())}function i(c){t.move(n(c)),t.mode()!==null&&c.preventDefault()}function o(c){t.up(n(c)),c.preventDefault()}function s(c){t.cancel(n(c))}function a(c){c.pointerType==="mouse"&&t.cancel(n(c))}function l(c){t.wheel({deltaY:c.deltaY,deltaMode:c.deltaMode}),c.preventDefault()}return e.addEventListener("pointerdown",r),e.addEventListener("pointermove",i),e.addEventListener("pointerup",o),e.addEventListener("pointercancel",s),e.addEventListener("pointerleave",a),e.addEventListener("wheel",l,{passive:!1}),function(){e.removeEventListener("pointerdown",r),e.removeEventListener("pointermove",i),e.removeEventListener("pointerup",o),e.removeEventListener("pointercancel",s),e.removeEventListener("pointerleave",a),e.removeEventListener("wheel",l,{passive:!1}),t.reset()}}function RP(e,t){var n=rc(e);if(!n)throw new Error("[save-state] the STUDIO frame's modules are not loaded — loadFrameModules(cw, router) (lib/features/ide/frame-modules.js) runs before a runner is taken. (FAIL-LOUD.)");return n.RenderState.backdropOf(t)}function LP(e){return e?e.visible!==!1:null}function AP(e){if(!Array.isArray(e))return[];for(var t=[],n=0;n<e.length;n++){var r=e[n];r&&r.bind&&typeof r.bind.prop=="string"&&r.bind.prop.length>0&&t.push({key:r.bind.prop,value:r.value})}return t}function PP(e,t){return e!==t}function JS(e,t){if(typeof e!="string"||!e)throw new TypeError("[share-file] downloadBlob(filename, blob): filename must be a non-empty string. (FAIL-LOUD.)");if(!t||typeof t.size!="number"||typeof t.type!="string")throw new TypeError("[share-file] downloadBlob(filename, blob): blob must be a Blob. (FAIL-LOUD.)");var n=URL.createObjectURL(t);try{var r=document.createElement("a");r.href=n,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r)}finally{setTimeout(function(){URL.revokeObjectURL(n)},0)}}function XS(e,t){if(!e||typeof e!="object")throw new TypeError("[share-file] "+t+"(nav, …): nav is the window's navigator. (FAIL-LOUD.)")}function QS(e,t){return XS(e,"canShareFile"),typeof e.canShare!="function"||typeof e.share!="function"?!1:e.canShare({files:[t]})===!0}function MP(e,t,n){if(XS(e,"shareFile"),!QS(e,t))throw new Error("[share-file] shareFile: this browser's Web Share does not take this file ("+(t&&t.type)+") — offer the download instead (canShareFile gates the Share action). (FAIL-LOUD.)");return e.share({files:[t],title:n})}function TP(e,t,n){JS(e,new Blob([t],{type:"application/zip"}))}function DP(e){return e.arrayBuffer().then(function(t){return new Uint8Array(t)})}function IP(e){return typeof window<"u"&&typeof window.__FRQTL_SDK_VERSION__=="string"&&window.__FRQTL_SDK_VERSION__.length>0?Promise.resolve(window.__FRQTL_SDK_VERSION__):Yp.length>0?Promise.resolve(Yp):Promise.reject(new Error("[bundle-export] deriveSdkVersion: the router CDN_SDK_VERSION authority is empty — pass an explicit version or set window.__FRQTL_SDK_VERSION__. (Never fabricate a CDN pin.)"))}function ox(e){throw new Error("[capture-envelope] "+e+" (FAIL-LOUD.)")}function FP(e){typeof e!="string"&&ox("base64ToBytes expects the base64 string of encoded.bytes, got "+typeof e),typeof atob!="function"&&ox("base64ToBytes needs a global atob (every browser, and node >= 16)");for(var t=atob(e),n=new Uint8Array(t.length),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function NP(e){if(!e||typeof e!="object")throw new TypeError("[studio-recorder] recordUnavailableReason(win): win is the experiment frame's window. (FAIL-LOUD.)");return typeof e.VideoEncoder!="function"?"this browser has no WebCodecs VideoEncoder (or the page is not a secure context), and the one recorder, FrqtlVision.record (lib/frqtl/parts/FrqtlVision.js), encodes with it — the Record button is hidden":null}var sx=Object.freeze({"video/mp4":"mp4","video/webm":"webm"});function Hc(e){return(e<10?"0":"")+e}function zP(e,t,n){var r=sx[n];if(!r)throw new Error("[studio-recorder] recordingFileName: no file extension for mime "+JSON.stringify(n)+" (known: "+Object.keys(sx).join(", ")+"). (FAIL-LOUD.)");var i=String(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(!i)throw new Error("[studio-recorder] recordingFileName: the scene has no name to put in the file name (got "+JSON.stringify(e)+"). (FAIL-LOUD.)");var o=t.getFullYear()+Hc(t.getMonth()+1)+Hc(t.getDate())+"-"+Hc(t.getHours())+Hc(t.getMinutes());return"frqtl-"+i+"-"+o+"."+r}function BP(e,t,n){var r=e.encoded.mime;return new File([FP(e.encoded.bytes)],zP(t,n,r),{type:r})}var ax="#6a9ad0",lx="#cfcfcf",cx="#a08060";function UP({value:e,roster:t,savedProjects:n,onChange:r,disabled:i}){Jt(t,"ExperimentDropdown({ value, roster, savedProjects, onChange, disabled })");var[o,s]=j.useState(!1),a=j.useRef(null);j.useEffect(function(){if(!o)return;function f(h){a.current&&!a.current.contains(h.target)&&s(!1)}return document.addEventListener("mousedown",f),function(){document.removeEventListener("mousedown",f)}},[o]),j.useEffect(function(){if(!o)return;function f(h){h.key==="Escape"&&s(!1)}return document.addEventListener("keydown",f),function(){document.removeEventListener("keydown",f)}},[o]);function l(f){s(!1),f!==e&&r&&r(f)}var c=iP(e,n,t.rows),u=!e||e===Ti?cx:e.indexOf("walkthrough:")===0?ax:lx,d=!e||e===Ti;return v.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[v.jsxs("button",{disabled:!!i,style:HP(!!i),onClick:function(){i||s(function(f){return!f})},title:"Switch experiment or open saved project","aria-haspopup":"listbox","aria-expanded":o,children:[v.jsx("span",{style:{color:u,fontStyle:d?"italic":"normal",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:c}),v.jsx("span",{style:{color:"#555",marginLeft:"5px",fontSize:"0.55rem",flexShrink:0},children:o?"▲":"▼"})]}),o&&v.jsxs("div",{style:WP,role:"listbox","aria-label":"Select experiment",children:[v.jsx(Rh,{val:Ti,selected:e===Ti,onSelect:l,hoverBg:"#2a2200",children:v.jsx("span",{style:{fontStyle:"italic",color:cx},children:"Empty Universe (New)"})}),gS(t).map(function(f,h){return v.jsxs(Ze.Fragment,{children:[v.jsx(ux,{scene:!0,children:f.label}),f.rows.map(function(g){var m="walkthrough:"+g.id,x=Kt(t,g.id);return v.jsx(Rh,{val:m,selected:e===m,onSelect:l,hoverBg:"#16222f",title:x?x.prose:void 0,children:v.jsx("span",{style:{color:ax},children:g.title})},h+":"+m)})]},h+":"+f.label)}),n&&n.length>0&&v.jsxs(v.Fragment,{children:[v.jsx(ux,{children:"Saved Projects"}),n.map(function(f){var h="project:"+f.id;return v.jsx(Rh,{val:h,selected:e===h,onSelect:l,hoverBg:"#1e1e1e",children:v.jsx("span",{style:{color:lx},children:f.name})},h)})]})]})]})}function ux({children:e,scene:t}){return v.jsx("div",{"data-scene-group":t?"":void 0,style:{fontSize:"0.55rem",letterSpacing:"1px",textTransform:"uppercase",color:"#444",padding:"5px 8px 2px",borderTop:"1px solid #222",userSelect:"none"},children:e})}function Rh({val:e,selected:t,onSelect:n,hoverBg:r,children:i,title:o}){var[s,a]=j.useState(!1);return v.jsx("div",{role:"option","data-value":e,"aria-selected":t,title:o||void 0,style:{padding:"5px 8px",cursor:"pointer",fontSize:"0.62rem",fontFamily:"ui-monospace,Menlo,Consolas,monospace",background:s?r:t?"#26323f":"transparent",userSelect:"none",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},onClick:function(){n(e)},onMouseEnter:function(){a(!0)},onMouseLeave:function(){a(!1)},children:i})}function HP(e){return{display:"flex",alignItems:"center",gap:"4px",maxWidth:"200px",minWidth:"120px",background:"#1a1a1a",border:"1px solid #333",color:"#ccc",padding:"3px 6px",fontSize:"0.62rem",fontFamily:"ui-monospace,Menlo,Consolas,monospace",cursor:e?"not-allowed":"pointer",borderRadius:"3px",opacity:e?.5:1,outline:"none"}}var WP={position:"absolute",top:"100%",left:0,zIndex:9999,background:"#151515",border:"1px solid #333",borderRadius:"3px",minWidth:"200px",maxWidth:"300px",maxHeight:"320px",overflowY:"auto",boxShadow:"0 4px 16px rgba(0,0,0,0.6)",marginTop:"2px"};function dm(e){var t=j.useRef(null),[n,r]=j.useState(null);j.useLayoutEffect(function(){var o=t.current;if(o){for(var s=0,a=0;a<o.children.length;a++)s=Math.max(s,o.children[a].getBoundingClientRect().width);var l=Math.ceil(s);l>0&&l!==n&&r(l)}});var i=Object.assign({},e);return delete i.labels,delete i.style,delete i.children,v.jsxs(Ze.Fragment,{children:[v.jsx("button",{...i,style:Object.assign({},e.style,n?{width:n+"px",boxSizing:"border-box",textAlign:"center",whiteSpace:"nowrap"}:null),children:e.children}),v.jsx("span",{ref:t,"aria-hidden":"true",style:{position:"absolute",left:"-10000px",top:0,visibility:"hidden",pointerEvents:"none"},children:e.labels.map(function(o){return v.jsx("span",{className:e.className,style:Object.assign({},e.style,{display:"inline-block",boxSizing:"border-box",whiteSpace:"nowrap",width:"auto"}),children:o},o)})})]})}function Yo(e){return!e||typeof e!="object"?!1:Object.prototype.toString.call(e)==="[object Map]"?!0:typeof e.get=="function"&&typeof e.entries=="function"&&typeof e.forEach=="function"&&typeof e.size=="number"}function ZS(e){var t=[],n=[];if(e&&typeof e=="object"&&Array.isArray(e.cells)){for(var r=0;r<e.cells.length;r++)n.push(Number(e.cells[r].v)||0);return{labels:t,values:n,cells:e.cells,maxV:Number(e.maxV)||0}}if(Yo(e)){var i=Array.from(e.entries());i.sort(function(l,c){return Number(l[0])-Number(c[0])});for(var o=0;o<i.length;o++)t.push(String(i[o][0])),n.push(Number(i[o][1]))}else if(Array.isArray(e))for(var s=0;s<e.length;s++){var a=e[s];a&&typeof a=="object"?(t.push(String(a.x!=null?a.x:s)),n.push(Number(a.y!=null?a.y:a.count!=null?a.count:0))):(t.push(String(s)),n.push(Number(a)))}else e&&typeof e=="object"&&Object.keys(e).forEach(function(l){t.push(l),n.push(Number(e[l]))});return{labels:t,values:n}}function VP(e,t){if(!e||typeof e.render!="function"||typeof e.destroy!="function")throw new Error("[realm-chart] makeChartHandle requires a chart-env with render()/destroy(). (FAIL-LOUD.)");var n=null;function r(o){var s=o&&o.kind||"bar",a=o&&o.label||"series",l=ZS(o&&o.data);return n=Object.assign({kind:s,label:a},l),e.render(n),n}var i={_transport:t&&t.kind||"in-app",inject:function(o,s){return o==="chart"?!s||typeof s.data>"u"||s.data===null?Promise.reject(new Error('[realm-chart] inject("chart") needs { data } (the bound value to plot) — binding not yet produced. (FAIL-LOUD.)')):(r(s),Promise.resolve()):Promise.reject(new Error('[realm-chart] inject: unknown name "'+o+'" (expect "chart"). (FAIL-LOUD.)'))},call:function(o){if(o==="lastData")return n;throw new Error('[realm-chart] call: unknown fn "'+o+'" (expect "lastData"). (FAIL-LOUD.)')},on:function(){return function(){}},start:function(){n&&e.render(n)},stop:function(){},step:function(){return n&&e.render(n),n},dispose:function(){n=null,e.destroy()},_chartEnv:e};return{handle:Nk(i),impl:i}}const xd=["detectorHistogram","absorberStats","liveCount","detectorSurface"],nv=100;function qP(e,t,n){var r=typeof n=="number"?n:nv;return t-e>=r}function fm(e){e=e||{};var t=e.handle,n=e.chartEnv,r=e.projector||"detectorHistogram",i=e.kind==="line"?"line":"bar",o=e.label||r;function s(){var x=typeof o=="function"?o():o;return x==null||x===""?r:String(x)}var a=typeof e.now=="function"?e.now:function(){return Date.now()},l=typeof e.throttleMs=="number"?e.throttleMs:nv,c=e.orientation;function u(){var x=typeof c=="function"?c():c;if(x!=null)return String(x)==="90"?90:0}if(!t||typeof t.on!="function"||typeof t.call!="function")throw new Error("[live-chart-controller] requires a view-handle with on()/call(). (FAIL-LOUD.)");if(!n||typeof n.render!="function"||typeof n.destroy!="function")throw new Error("[live-chart-controller] requires a chart-env with render()/destroy(). (FAIL-LOUD.)");if(xd.indexOf(r)===-1)throw new Error('[live-chart-controller] unknown liveChart projector "'+r+'" (expect one of ['+xd.join(", ")+"]). (FAIL-LOUD.)");var d=-1/0,f=null,h=!1;function g(){var x;try{x=Promise.resolve(t.call(r))}catch(y){return Promise.reject(y)}return x.then(function(y){var b=ZS(y);n.render({kind:i,label:s(),labels:b.labels,values:b.values,cells:b.cells,maxV:b.maxV,orientation:u()})})}function m(){qP(d,a(),l)&&(d=a(),g())}return{start:function(){h||f||(f=t.on("tick",m))},stop:function(){if(!h){if(f){try{f()}catch{}f=null}return g()}},dispose:function(){if(!h){if(f){try{f()}catch{}f=null}try{g().catch(function(){})}catch{}h=!0,n.destroy()}}}}var Lh=null;function dx(){return Lh||(Lh=AS(()=>Promise.resolve().then(()=>wz),void 0,import.meta.url).then(function(e){return e.makeChartEnv})),Lh}function $P(e){return e?Yo(e.combined)?e.combined:(Yo(e),e):{}}var fx={detectorHistogram:{method:"getCollisionHistogram",drain:!0,project:function(e){return $P(e.getCollisionHistogram())}},absorberStats:{method:"getAbsorbStats",drain:!1,project:function(e){var t=e.getAbsorbStats()||{};return{stored:Number(t.stored)||0,absorbed:Number(t.absorbedTotal)||0,radiated:Number(t.radiatedTotal)||0}}},liveCount:{method:"getLiveCount",drain:!0,project:function(e){return{live:Number(e.getLiveCount())||0}}},detectorSurface:{method:"getCollisionHistogram",drain:!0,project:function(e){return KP(e.getCollisionHistogram())}}},Wc=12;function KP(e){var t=[],n=0,r=e&&e.grid;if(!Yo(r))return{cells:t,maxV:n};var i=new Map;return r.forEach(function(o,s){if(Yo(o)){var a=Math.floor(Number(s)/Wc)*Wc;o.forEach(function(l,c){var u=Math.floor(Number(c)/Wc)*Wc,d=a+","+u;i.set(d,(i.get(d)||0)+(Number(l)||0))})}}),i.forEach(function(o,s){var a=s.split(",");o>n&&(n=o),t.push({x:Number(a[1]),y:Number(a[0]),v:o})}),{cells:t,maxV:n}}function e1(e){var t=e||"detectorHistogram",n=fx[t];if(!n)throw new Error('[live-chart-wiring] unknown liveChart projector "'+t+'" — must be one of ['+Object.keys(fx).join(", ")+"]. (FAIL-LOUD.)");return n}function YP(e,t){var n=e1(t.projector).method;return t.sourceHandle&&typeof t.sourceHandle[n]=="function"?t.sourceHandle:typeof t.source=="string"&&t.source&&e?e.getObjectByName(t.source,function(r){return typeof r[n]=="function"}):null}function t1(e,t){if(!e||!t||typeof t.name!="string"||!t.name)return null;function n(o){return!!(o&&o.gateCounter===t.name&&typeof o.emissionCap=="number")}for(var r=e.declared||[],i=0;i<r.length;i++)if(n(r[i]))return r[i];return null}function GP(e,t){var n=t1(e,t);return n?n.emissionCap:null}function JP(e,t){var n=[];return{on:function(r,i){if(r!=="tick")throw new Error('[live-chart-wiring] adapter only supports the "tick" event. (FAIL-LOUD.)');return n.push(i),function(){var o=n.indexOf(i);o!==-1&&n.splice(o,1)}},call:function(){return t.project(e)},_emitTick:function(){for(var r=0;r<n.length;r++)try{n[r]({})}catch{}}}}function XP(e,t){var n=e.createElement("div"),r=t.rect&&t.rect.w||200,i=t.rect&&t.rect.h||140;n.style&&(n.style.position="absolute",n.style.left="-100000px",n.style.top="0",n.style.width=r+"px",n.style.height=i+"px",n.style.pointerEvents="none"),n.setAttribute("data-role","live-chart-offscreen");var o=e.body||e.documentElement||null;return o&&typeof o.appendChild=="function"&&o.appendChild(n),n}async function n1(e,t){if(t=t||{},!e||!Array.isArray(e.largeObjects)||typeof e.addTickListener!="function")throw new Error("[live-chart-wiring] mountLiveCharts requires a runner with largeObjects and addTickListener(). (FAIL-LOUD.)");var n=t.document||(typeof document<"u"?document:null),r=typeof t.now=="function"?t.now:typeof performance<"u"&&performance.now?function(){return performance.now()}:function(){return Date.now()},i=typeof t.makeChartEnv=="function"?t.makeChartEnv:null,o=!1;function s(){i||o||(o=!0,dx().then(function(f){i=f}).catch(function(f){o=!1,typeof console<"u"&&console.error&&console.error("[live-chart-wiring] chart-env factory load failed:",f)}))}var a=[];function l(f,h,g){if(!n||typeof n.createElement!="function")throw new Error("[live-chart-wiring] a DOM document is required to host the offscreen chart canvas. (FAIL-LOUD.)");var m=f.chartSpec,x=XP(n,f),y=i(x),b=JP(h,g),w=fm({handle:b,chartEnv:y,projector:m.projector||"detectorHistogram",kind:m.kind||"bar",label:function(){var E=f.label!=null&&f.label!==""?f.label:m.label||"detector",C=GP(e,h);return C!=null?E+" (cap "+C+")":E},now:r,throttleMs:typeof m.refreshMs=="number"?m.refreshMs:100,orientation:function(){var E=f.orientation!=null?f.orientation:m.orientation;return String(E)==="90"?90:0}});(function(E){f.liveCanvas=function(){return E&&typeof E.querySelector=="function"?E.querySelector("canvas"):null}})(x),w.start(),a.push({lo:f,source:h,desc:g,controller:w,host:x,adapter:b})}function c(){for(var f=0,h=e.largeObjects||[],g=0;g<h.length;g++){var m=h[g];if(!(!m||!m.chartSpec||m._liveChartWired||m._liveChartWireFailed)){var x=e1(m.chartSpec.projector),y=YP(e,m.chartSpec);if(y){try{y[x.method]()}catch(b){throw m._liveChartWireFailed=!0,b}if(!i){s();continue}l(m,y,x),m._liveChartWired=!0,f++}}}return f}var u=function(f){c();for(var h=0;h<a.length;h++){var g=a[h];g.desc.drain&&g.source[g.desc.method](f),g.adapter._emitTick()}},d=e.addTickListener(u);return c(),o&&!i&&(i=await dx(),o=!1,c()),{charts:a,rescan:c,dispose:function(){try{d&&d()}catch{}for(var f=0;f<a.length;f++){var h=a[f];try{h.controller.dispose()}catch{}try{h.host&&h.host.parentNode&&typeof h.host.parentNode.removeChild=="function"&&h.host.parentNode.removeChild(h.host)}catch{}try{h.lo._liveChartWired=!1}catch{}try{h.lo.liveCanvas=null}catch{}}a.length=0}}}function hx(e){var t=e.field||{},n=t.widgetConfig||{},r=t.constraint||{},i=n.min!=null?n.min:r.min!=null?r.min:0,o=n.max!=null?n.max:r.max!=null?r.max:100,s=n.step!=null?n.step:r.integer?1:.1,a=e.value!=null&&e.value!==""?e.value:i;function l(c){var u=r.integer?parseInt(c.target.value,10):parseFloat(c.target.value);isNaN(u)||e.commit(u)}return Ze.createElement("div",{style:{display:"flex",alignItems:"center",gap:"6px",flex:1}},Ze.createElement("input",{type:"range",min:i,max:o,step:s,value:a,style:{flex:1,accentColor:"#7ec8e3"},onChange:l}),Ze.createElement("span",{style:{minWidth:"42px",textAlign:"right",color:"#7ec8e3",font:"11px ui-monospace,Menlo,Consolas,monospace"}},String(a)))}function QP(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function ZP(e){if(!e||!Array.isArray(e))return"#888888";function t(n){return("0"+Math.max(0,Math.min(255,Math.round(n))).toString(16)).slice(-2)}return"#"+t(e[0])+t(e[1])+t(e[2])}function eM(e){return Ze.createElement("input",{type:"color",value:ZP(Array.isArray(e.value)?e.value:null),style:{width:44,height:22,border:"none",background:"none",cursor:"pointer",padding:0},onChange:function(t){e.commit(QP(t.target.value))}})}var tM={width:"100%",background:"#1a1a1a",color:"#ccc",border:"1px solid #333",padding:"4px",fontSize:"0.62rem"};function nM(e){var t=e.obj||{},n=e.value!=null&&e.value!==""?Math.round(Number(e.value)):0,r=typeof t.getFundamentalDimension=="function"?t.getFundamentalDimension():n;(typeof r!="number"||isNaN(r))&&(r=n);for(var i=Math.max(n,r)+4,o=[],s=0;s<=i;s++)o.push(s);o.indexOf(n)===-1&&(o.push(n),o.sort(function(l,c){return l-c}));function a(l){var c=l===r?" — fundamental":l<r?" — below floor (ratchet)":" — above (slower/redder)";return"Dim "+l+c}return Ze.createElement("select",{value:String(n),style:tM,onChange:function(l){e.commit(parseInt(l.target.value,10))}},o.map(function(l){return Ze.createElement("option",{key:l,value:String(l)},a(l))}))}function rM(e){return Ze.createElement("input",{type:"checkbox",checked:!!e.value,style:{accentColor:"#7ec8e3",cursor:"pointer"},onChange:function(t){e.commit(t.target.checked)}})}var Ah=[{id:"dimension-select",match:function(e,t){return t.widgetHint==="dimension-select"},Component:nM},{id:"oven-temperature",match:function(e,t){return e==="OvenBox"&&t.name==="temperature"},Component:hx},{id:"slider",match:function(e,t){return t.type==="number"&&t.widgetHint==="slider"},Component:hx},{id:"rgb-color-picker",match:function(e,t){return t.type==="rgb"},Component:eM},{id:"boolean-checkbox",match:function(e,t){return t.type==="boolean"},Component:rM}];function iM(e,t){if(!t)return null;for(var n=0;n<Ah.length;n++)if(Ah[n].match(e,t))return Ah[n];return null}var ja=8,oM=10,sM="rgba(74, 122, 191, 0.85)",aM="rgba(74, 122, 191, 0.30)",lM="rgba(138, 180, 248, 0.90)",cM="rgba(255, 255, 255, 0.95)",uM="rgba(74, 122, 191, 1.0)";function Ha(e,t){return TA(e,t)}function dM(e,t,n,r,i){if(e){if(typeof i!="function")throw new Error("[author-bbox-overlay] paintAuthorOverlay needs the host's world→overlay map (toOverlay) — there is no camera-blind default. (FAIL-LOUD.)");e.clearRect(0,0,e.canvas.width,e.canvas.height);for(var o=0;o<t.length;o++){var s=t[o],a=s.ref;if(a){var l=Ha(a,r);if(l){var c=i(l);if(!(!c||c.width<=0||c.height<=0)){var u=a===n;e.fillStyle=aM,e.fillRect(c.left,c.top,c.width,c.height),e.strokeStyle=u?lM:sM,e.lineWidth=u?2:1,e.setLineDash([4,3]),e.strokeRect(c.left,c.top,c.width,c.height),e.setLineDash([]),u&&fM(e,c)}}}}}}function fM(e,t){var n=oM,r=n/2,i=t.left+t.width/2,o=t.top+t.height/2,s=[{x:t.left,y:t.top},{x:t.left+t.width,y:t.top},{x:t.left,y:t.top+t.height},{x:t.left+t.width,y:t.top+t.height},{x:i,y:t.top},{x:i,y:t.top+t.height},{x:t.left,y:o},{x:t.left+t.width,y:o}];e.fillStyle=cM,e.strokeStyle=uM,e.lineWidth=1.5;for(var a=0;a<s.length;a++){var l=s[a];e.fillRect(l.x-r,l.y-r,n,n),e.strokeRect(l.x-r,l.y-r,n,n)}}function Ph(e,t){if(!e)return null;var n=e,r=t.x,i=t.y;if(r<n.left-ja||r>n.left+n.width+ja||i<n.top-ja||i>n.top+n.height+ja)return null;var o=ja,s=n.left+n.width/2,a=n.top+n.height/2,l=n.width<2*o||n.height<2*o;if(!l){if(hn(r,n.left,o)&&hn(i,n.top,o))return"scale-tl";if(hn(r,n.left+n.width,o)&&hn(i,n.top,o))return"scale-tr";if(hn(r,n.left,o)&&hn(i,n.top+n.height,o))return"scale-bl";if(hn(r,n.left+n.width,o)&&hn(i,n.top+n.height,o))return"scale-br";if(hn(r,s,o)&&hn(i,n.top,o))return"scale-t";if(hn(r,s,o)&&hn(i,n.top+n.height,o))return"scale-b";if(hn(r,n.left,o)&&hn(i,a,o))return"scale-l";if(hn(r,n.left+n.width,o)&&hn(i,a,o))return"scale-r"}return r>=n.left&&r<=n.left+n.width&&i>=n.top&&i<=n.top+n.height?"move":null}function hn(e,t,n){return Math.abs(e-t)<=n}function px(e){return!e||e==="move"?"grab":e==="scale-tl"||e==="scale-br"?"nwse-resize":e==="scale-tr"||e==="scale-bl"?"nesw-resize":e==="scale-t"||e==="scale-b"?"ns-resize":e==="scale-l"||e==="scale-r"?"ew-resize":"default"}function hM(e,t,n){var r=Object.assign({},e),i=n.x,o=n.y;return t==="scale-tl"?(r.left+=i,r.top+=o,r.width-=i,r.height-=o):t==="scale-tr"?(r.top+=o,r.width+=i,r.height-=o):t==="scale-bl"?(r.left+=i,r.width-=i,r.height+=o):t==="scale-br"?(r.width+=i,r.height+=o):t==="scale-t"?(r.top+=o,r.height-=o):t==="scale-b"?r.height+=o:t==="scale-l"?(r.left+=i,r.width-=i):t==="scale-r"&&(r.width+=i),r.width<4&&(r.width=4),r.height<4&&(r.height=4),r}var pM={loading:"The scene is loading",paused:"Run the scene to record it","rate-unmeasured":"Record waits for the scene's measured tick rate (about a second after Run)"};function mM(e){var t=pM[e.reason];if(!t)throw new Error('[AuthorView] FrqtlVision.recordRefusal gave reason "'+e.reason+'", which the Record button has no title for — add it to REC_REFUSAL_TITLES. (FAIL-LOUD.)');return t}function ot(e){var t=rc(e);if(!t)throw new Error("[AuthorView] the STUDIO frame's modules are not loaded — loadFrameModules(cw, router) (lib/features/ide/frame-modules.js) runs in grab() before a runner is taken. (FAIL-LOUD.)");return t}function cr(e){return!!(e&&rc(e))}function Wa(e,t){return e&&e.FrqtlPage?e.FrqtlPage[t]:null}var Vc=Ti,r1="empty",gM="data-frqtl-renderer";function mx(e){var t=e&&e.document&&e.document.documentElement;return t&&t.getAttribute(gM)||null}function vM(e,t){var n=function(o){return!!(o&&o.phases&&o.phases.renderer&&o.phases.renderer.complete)};if(n(lm(e.document)))return t(),function(){};var r=e.frameElement;if(!r)return function(){};var i=function(o){n(o.detail)&&(r.removeEventListener(sl,i),t())};return r.addEventListener(sl,i),function(){r.removeEventListener(sl,i)}}function gx(e){return e&&Array.isArray(e.presets)?e.presets:[]}function vx(e){return e&&Array.isArray(e.poseFields)?e.poseFields:[]}var yx="▶ Run",bx="▌▌ Pause",xx="● Rec",wx="Saving…";function yM(e){var t=Math.max(0,Math.floor(e/1e3));return Math.floor(t/60)+":"+(t%60<10?"0":"")+t%60}function _x(e){return"■ Stop ● "+yM(e)}var qc={hand:"grab",dropper:"crosshair",pencil:"default"},bM=4,or="design",sr="run";function $c(e){var t=e.kind,n={width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"0 0 auto"}};return t==="hand"?v.jsxs("svg",{...n,children:[v.jsx("path",{d:"M18 11V6a2 2 0 0 0-4 0v5"}),v.jsx("path",{d:"M14 10V4a2 2 0 0 0-4 0v6"}),v.jsx("path",{d:"M10 10.5V6a2 2 0 0 0-4 0v8"}),v.jsx("path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"})]}):t==="dropper"?v.jsxs("svg",{...n,children:[v.jsx("path",{d:"m2 22 1-4 11-11 3 3L6 21z"}),v.jsx("path",{d:"m14 7 3 3"}),v.jsx("path",{d:"M17 4a2.83 2.83 0 0 1 4 4l-2 2-4-4z"})]}):v.jsxs("svg",{...n,children:[v.jsx("path",{d:"M12 20h9"}),v.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"})]})}var xM=["emitter","boundary","composite","measurement","circuit"],wM={emitter:"Emitters",boundary:"Boundaries",composite:"Composite",measurement:"Measurement",circuit:"Circuit"};function hs(e,t){var n=r1,r=typeof window<"u"&&window.location?window.location.search:"",i=zg(e,n,"wasm",r);return i=dS(i,t),hL(i,"canvas")}function _M(e){var t=j.useRef(null),n=j.useRef(null),r=j.useRef(e.onChange);return r.current=e.onChange,j.useEffect(function(){var i=e.cw,o=t.current;if(!(!cr(i)||!o)){var s=Object.assign({},e.control,{onChange:function(l){r.current(l)}}),a=ot(i).FrqtlControlSlider.mount(o,{descriptor:s});return n.current=a,function(){a.dispose(),n.current=null}}},[e.cw,e.control.id]),j.useEffect(function(){if(n.current){var i=typeof e.control.fmt=="function"?e.control.fmt(e.control.value):String(e.control.value);n.current.setValue(e.control.value,i)}},[e.control.value]),v.jsx("div",{ref:t,style:{flex:1}})}function kM(e){var t=e.ready,n=e.ctxRef,r=e.reloadKey,[i,o]=j.useState(null),[s,a]=j.useState(null),l=j.useRef(null);j.useEffect(function(){if(o(null),a(null),l.current&&(l.current.dispose(),l.current=null),!!t){var u=n.current.cw;if(!cr(u)){o([]);return}var d=Wa(u,"controls"),f=d&&typeof d.controlNames=="function"?d.controlNames():[];if(f.length===0){o([]);return}var h=f[0];a(h);var g=ot(u).ShimRpc.makeInAppRpc(function(m,x){return ot(u).FrqtlControlsPanel.dispatch(d,m,x)});return l.current=g,g.call("listControls",[h]).then(function(m){o(m)}).catch(function(){o([])}),function(){g.dispose()}}},[t,r]);function c(u,d){if(!(!l.current||!s)){var f=n.current.writeQueue,h=function(){l.current.call("setControlValue",[s,u,d]).then(function(g){o(function(m){return(m||[]).map(function(x){return x.id===u?Object.assign({},x,g):x})})}).catch(function(g){window.console&&console.error&&console.error("[AuthorView PageControls] setControlValue failed:",g)})};f&&typeof f.write=="function"?f.write(s+"."+u,h):h()}}return i===null?v.jsx("div",{style:wd,children:"Loading page controls…"}):i.length===0?v.jsx("div",{style:wd,children:"No page-level controls declared by this experiment."}):v.jsx("div",{children:i.map(function(u){var d=typeof u.min=="number"&&typeof u.max=="number";return v.jsxs("div",{style:hm,"data-page-control":u.id,children:[v.jsx("div",{style:pm,title:u.label,children:u.label}),d?v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flex:1},children:[v.jsx("input",{type:"range",min:u.min,max:u.max,step:u.step,value:u.value,style:{flex:1,accentColor:"#7ec8e3"},onChange:function(f){c(u.id,parseFloat(f.target.value))}}),v.jsx("span",{style:{minWidth:42,textAlign:"right",color:"#7ec8e3",font:"11px ui-monospace,Menlo,Consolas,monospace"},children:u.valueText})]}):v.jsx("span",{style:mm,children:u.valueText})]},u.id)})})}var wd={color:"#6a6a6a",fontSize:"0.62rem"},hm={display:"flex",alignItems:"center",gap:"6px",padding:"3px 0"},pm={flex:"0 0 40%",color:"#9a9a9a",fontSize:"0.64rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},mm={color:"#ccc",fontSize:"0.64rem"};function SM(e){var t=e.ready,n=e.ctxRef,r=e.reloadKey,[i,o]=j.useState(null),s=e.retained||[];function a(){var u=n.current.cw,d=n.current.runner;if(!cr(u)||!d){o([]);return}var f;try{f=ot(u).MakeControlsForRenderSurface.makeControlsForRenderSurface({runner:d})}catch(h){window.console&&console.error&&console.error("[AuthorView RenderControls] makeControlsForRenderSurface failed:",h),o([]);return}o(f.controls.map(function(h){return Object.assign({},h,{valueText:typeof h.fmt=="function"?h.fmt(h.value):String(h.value)})}))}j.useEffect(function(){if(o(null),!!t){a();var u=n.current.runner;if(!u||typeof u.addRenderOptionsListener!="function")throw new Error("[AuthorView RenderControls] runner.addRenderOptionsListener is missing — the runner announces every applied render-option write; the panel reads back on it. (FAIL-LOUD.)");return u.addRenderOptionsListener(function(){a()})}},[t,r]);function l(u,d){var f=n.current.cw,h=n.current.runner;if(!(!f||!h)){var g=n.current.writeQueue,m=function(){try{ot(f).ControlBind.resolveBind(u.bind,{runner:h},"render").set(d)}catch(x){window.console&&console.error&&console.error("[AuthorView RenderControls] write failed:",x)}};g&&typeof g.write=="function"?g.write("render."+u.id,m):m()}}if(i===null)return v.jsx("div",{style:wd,children:"Loading render controls…"});var c=s.map(function(u){return v.jsxs("div",{style:hm,"data-role":"studio-render-retained",children:[v.jsx("div",{style:pm,title:u.key,children:u.key}),v.jsxs("span",{style:mm,children:[String(u.value)," — not available on ",e.rendererName||"this renderer"]})]},"retained:"+u.key)});return i.length===0?v.jsxs("div",{children:[v.jsx("div",{style:wd,children:"The active renderer declares no render controls."}),c]}):v.jsxs("div",{children:[i.map(function(u){var d=u.kind==="scalar"&&u.min===0&&u.max===1&&u.step===1,f=u.kind==="scalar"&&!d;return v.jsxs("div",{style:hm,"data-render-row":u.id,children:[v.jsx("div",{style:pm,title:u.label,children:u.label}),d?v.jsx("input",{type:"checkbox",checked:!!u.value,onChange:function(h){l(u,h.target.checked?1:0)},style:{accentColor:"#7ec8e3"}}):f?v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flex:1},children:[v.jsx("input",{type:"range",min:u.min,max:u.max,step:u.step,value:u.value,style:{flex:1,accentColor:"#7ec8e3"},onChange:function(h){l(u,parseFloat(h.target.value))}}),v.jsx("span",{style:{minWidth:42,textAlign:"right",color:"#7ec8e3",font:"11px ui-monospace,Menlo,Consolas,monospace"},children:u.valueText})]}):u.kind==="enum"?v.jsx("select",{value:u.value,style:{flex:1,background:"#1a1a1a",color:"#ccc",border:"1px solid #2a2a2a",borderRadius:"2px",font:"11px ui-monospace,Menlo,Consolas,monospace"},onChange:function(h){l(u,h.target.value)},children:u.values.map(function(h){return v.jsx("option",{value:h,children:h},h)})}):v.jsx("span",{style:mm,children:u.valueText})]},u.id)}),c]})}function EM({experimentBase:e,monacoBaseUrl:t,initialProject:n,deepLinkRefusal:r,roster:i,initialWalkthrough:o,initialWalkthroughMode:s,initialScene:a,initialSceneRenderer:l,resolveScript:c,onLinkSelect:u}){if(!e||typeof c!="function")throw new Error("[AuthorView] experimentBase and resolveScript are required — mount AuthorView through FraqtlIde (lib/features/ide/index.jsx), the only mounter, which derives both from its engineRouter.");Jt(i,"AuthorView({ experimentBase, roster, resolveScript, … })");var d=j.useRef(null),f=j.useRef(null),h=j.useRef(null),g=j.useRef(null),m=j.useRef(null),x=j.useRef(null),y=j.useRef(null),b=j.useRef(null),w=j.useRef(null),E=j.useRef(null),C=j.useRef(null),S=j.useRef({runner:null,backdrop:null,Filters:null,cw:null,tool:null,dropType:null,controlsRegistry:null,controlsNameByObject:null,controlsNameCounters:null}),M=j.useRef({active:!1,lo:null,startX:0,startY:0,zone:null,origBbox:null}),[L,T]=j.useState({projectId:null,name:Vc,dirty:!1}),[V,G]=j.useState([]),[F,te]=j.useState([]),[W,Y]=j.useState(null),[re,pe]=j.useState([]),B=j.useRef([]),[ee,ce]=j.useState(null),ve=j.useRef(null),[ke,je]=j.useState(function(){return hs(e)}),[ie,me]=j.useState(or),xe=j.useRef(or),[ge,kt]=j.useState(!1),[ut,_n]=j.useState(null),[tn,ir]=j.useState(null),ht=tn?tn.text:null;function ye(p,_){ir(p==null?null:{source:_||"general",text:String(p)})}function St(p){ir(function(_){return _&&_.source===p?null:_})}var[ln,Wn]=j.useState(null),An=j.useRef(!1),Pn=j.useRef(null),[Mn,vr]=j.useState({particles:!0,backdrop:!1}),[Xt,Pt]=j.useState([]),[Ut,Et]=j.useState(null),De=j.useRef(null),Tn=j.useRef(null),[I,de]=j.useState(null),[fe,Ie]=j.useState({fpsLimit:0,tpsLimit:0}),[Ft,cn]=j.useState(null),[Xe,un]=j.useState(null),[Pe,Mt]=j.useState({phase:"idle"}),[Wt,Dn]=j.useState(0),lt=j.useRef(null),we=j.useRef(null),[pt,k]=j.useState(null),[R,P]=j.useState(null),$=j.useRef(null),U=j.useRef(null),[H,he]=j.useState(null),[Ae,Ve]=j.useState(0),[Qe]=j.useState(function(){return Hg(window)}),[Be,Ce]=j.useState(!Qe),[qe,nn]=j.useState(!Qe),[N,K]=j.useState(null),[We,kn]=j.useState({}),[Nt,Sn]=j.useState(null),[bt,ct]=j.useState(null),[$r,co]=j.useState([]),[CE,Sv]=j.useState([]),[jE,Ev]=j.useState(null),[Pr,RE]=j.useState(null),[LE,lc]=j.useState(!1),[wf,Ov]=j.useState(""),[uo,da]=j.useState(null),[fo,_f]=j.useState(!1),Cv=j.useRef(null),[jv,AE]=j.useState(0);j.useEffect(function(){var p=Cv.current,_=p?p.offsetWidth:0;_!==jv&&AE(_)});var cc=j.useRef({host:null,frame:null,frameCw:null});function uc(){var p=S.current.cw,_=S.current.runner;_&&p&&Wa(p,"runner")===_?Vt(_,S.current.backdrop,De.current):Cf()}j.useEffect(function(){var p=f.current&&f.current.parentElement;if(!p||typeof ResizeObserver!="function")throw new Error("[AuthorView] the canvas region (or ResizeObserver) is missing — the overlay is re-measured when the region's box changes. (FAIL-LOUD.)");var _=new ResizeObserver(function(){uc()});return _.observe(p),window.addEventListener("resize",uc),cc.current.host=_,function(){_.disconnect(),window.removeEventListener("resize",uc);var O=cc.current.frame;if(O)try{O.disconnect()}catch{}cc.current={host:null,frame:null,frameCw:null}}},[]);function Rv(p){var _=cc.current;if(_.frameCw!==p){if(_.frame)try{_.frame.disconnect()}catch{}if(typeof p.ResizeObserver!="function")throw new Error("[AuthorView] the experiment frame has no ResizeObserver — the overlay follows the frame's canvas box through it. (FAIL-LOUD.)");_.frame=new p.ResizeObserver(function(){uc()}),_.frameCw=p}var O=p.document.getElementById("canvas-wrapper");O&&_.frame.observe(O);for(var A=p.document.querySelectorAll("canvas"),D=0;D<A.length;D++)_.frame.observe(A[D])}var[kf,Lv]=j.useState(!1),[Vn,PE]=j.useState(null),rt=j.useRef(null),[ME,dc]=j.useState(null),rs=j.useRef("seed"),Sf=j.useRef(!1);function Mr(p){var _=typeof p=="function"?p(rt.current):p;rt.current=_,PE(_)}function fa(){var p=Wa(S.current.cw,"experiment");return p&&typeof p.toSketch=="function"?p:null}function ha(){return rt.current?wA(rt.current):null}function Av(p){if(typeof p[Ko(ha())]!="string")throw new Error("the facade wrote no entry sketch (files: "+Object.keys(p).join(", ")+")");Mr(Yb(rt.current,p))}function Ef(p){return sm+" (unrun: "+Ou(p).join(", ")+")"}function Pv(p){Mr(function(_){var O=Dr(_);return gs(O)||Ea(_,O).text===p?_:Kb(_,O,p)})}function TE(p){var _=Ou(p);return v.jsx("div",{style:_e.filePickerRow,children:v.jsx("select",{"data-role":"studio-file-picker",value:Dr(p),style:_e.filePicker,onChange:function(O){var A=O.target.value;Mr(function(D){return $b(D,A)})},children:RS(p).map(function(O){return v.jsx("option",{value:O,children:O+(gs(O)?" (read-only)":"")+(_.indexOf(O)!==-1?" (edited)":"")},O)})})})}function Kr(p){var _=rt.current,O=fa();return!_||!O?(ye(p+" is not written into code — the scene's sketch text has not loaded, so a hand moves the running scene only.","hand"),Promise.resolve()):_h(_)?(ye(p+" refused — "+Ef(_),"hand"),Promise.resolve()):O.toSketch().then(function(A){Av(A.files),A.refused.length?ye(p+" — not written: "+A.refused.map(function(D){return D.reason}).join(" "),"hand"):St("hand")}).catch(function(A){ye(p+" could not be written into the code: "+(A&&A.message?A.message:A),"hand")})}j.useEffect(function(){xe.current=ie},[ie]),j.useEffect(function(){S.current.tool=pt,Fv()},[pt]),j.useEffect(function(){S.current.dropType=R},[R]),j.useEffect(function(){De.current=Ut},[Ut]),j.useEffect(function(){is()},[]),j.useEffect(function(){var p=!0;return aP({refusal:r,walkthrough:o,mode:s,project:n,scene:a,renderer:l},{roster:i,pageOrigin:window.location.origin,baseURI:document.baseURI,loadProject:function(_){return Eh(gn(),_)}}).then(function(_){p&&(_.select&&po(_.select.value,_.select.mode,_.select.opts),An.current=_.run,_.err&&Wn(_.err),IS(document.documentElement,_.id),_.cards&&_n(_.cards))},function(_){p&&ye("STUDIO could not resolve its deep link: "+(_&&_.message?_.message:_))}),function(){p=!1}},[]),j.useEffect(function(){var p=b.current,_=y.current;if(!ut||!p||!_)return;var O=yS(i,ut),A=xS(i);if(!O){var D=ta(i,ut),z=D+" has no showcase-roster row",oe=Hs(p,D,"not-offered-no-roster-row",z),Q=Hs(_,A?A.seenKey:D,"not-offered-no-roster-row",z);return function(){oe.close(),Q.close()}}var J=bS(i,O),ne=fP(i,ut),Fe=null;function Me(){Fe||(Fe=vP(C.current,i,ne,{onPhone:Qe,dock:Qe?"top":"flow",runnerOf:function(){return S.current.runner},exportsOf:function(){var Ue=fa();return Ue&&Ue.world?Ue.sceneExports:null},onError:function(Ue){ye(Ue,"tryit")}}))}var it={seenKey:J.seenKey,title:J.title,paragraphs:J.paragraphs};ne&&(it.onContinue=Me);var le=Ml(p,it,{covers:E.current});ne&&le.ready.then(function(Ue){Ue.shows||Me()});var Oe=A?Ml(_,A,{covers:w.current}):Hs(_,J.seenKey,"not-offered-no-roster-row",J.seenKey+": the roster has no showcase intro");return function(){Oe.close(),le.close(),Fe&&Fe.close()}},[ut]),j.useEffect(function(){!ge||!An.current||(An.current=!1,Xv())},[ge]);function is(){var p;try{p=gn()}catch{G([]),te([]);return}G(jA(p).map(function(_){return{id:_.name,name:_.name}})),te(RA(p))}function DE(){var p=F;if(p.length&&window.confirm("Delete "+p.length+" save"+(p.length===1?"":"s")+" in the retired project format? They cannot be opened, and this cannot be undone.")){try{LA(gn(),p)}catch(_){ye("Delete retired saves failed: "+(_&&_.message?_.message:_),"retired")}is()}}function Mv(){var p=S.current.runner,_=S.current.cw,O=S.current.backdrop;if(!p||!_)return null;var A=mx(_),D=null,z=null;try{var oe=new URLSearchParams(_.location.search);D=oe.get("engine"),z=oe.get("seed")}catch{}var Q=ot(_).MakeControlsForRenderSurface.makeControlsForRenderSurface({runner:p}),J=AP(Q.controls).concat(B.current),ne=p.cameraControl||null,Fe=ne?{orbit:ne.getOrbit(),preset:bt||ve.current||null}:null,Me=LP(O);return bi({version:1,renderer:A,engine:D,seed:z,backdropVisible:Me,camera:Fe,render:J})}function IE(p,_,O){if(!(!O||!p||!_)){if(!p.FrqtlPage||typeof p.FrqtlPage.applyRenderState!="function")throw new Error("the STUDIO frame has no FrqtlPage.applyRenderState — a saved render state is replayed only on the blank universe page (experiments/empty/index.html). (FAIL-LOUD.)");var A=p.FrqtlPage.applyRenderState(O);B.current=A.retained,pe(A.retained);var D=A.camera==="retained"?A.preset:null;return ve.current=D,ce(D),(A.camera==="preset"||A.camera==="orbit")&&(Sn(_.cameraControl.getOrbit()),ct(A.preset),Mf(_)),A.backdrop!==null&&vr(function(z){return Object.assign({},z,{backdrop:A.backdrop})}),A}}function Tv(p){var _;try{_=Mv()}catch(O){return ye(p+" refused — "+(O&&O.message?O.message:O)),{ok:!1}}return!_&&L.walkthroughId&&(_=Zi(Kt(i,L.walkthroughId),L.walkthroughMode)),{ok:!0,state:_}}function Dv(p,_){window._egptPendingFolder=Object.assign({},p),Y(null),rs.current="run",window._egptPendingRenderState=_;var O=_?{renderer:_.renderer,seed:_.seed}:null;dc(null),kt(!1),ye(null),Et(null),De.current=null,Pt([]),me(or),je(hs(e,O)+"&_r="+Date.now())}function FE(p){if(!(typeof p!="string"||!rt.current)){var _=Dr(rt.current);!gs(_)&&p!==Ea(rt.current,_).text&&Mr(Kb(rt.current,_,p));var O=Tv("Run");O.ok&&(T(function(A){return Object.assign({},A,{dirty:!0})}),Dv(wh(rt.current),O.state))}}function Iv(){var p=rt.current?Dr(rt.current):null,_=rt.current?Ko(ha()):null;return L.walkthroughId?p===_?Kt(i,L.walkthroughId).source:L.walkthroughId+"/"+p:L.projectId&&p?L.projectId+"/"+p:L.sceneUrl?L.name+"/"+(p||_):af+"/"+(p||_)}function NE(){if(dc(null),L.walkthroughId){po("walkthrough:"+L.walkthroughId,L.walkthroughMode);return}if(L.projectId){po("project:"+L.projectId);return}if(L.sceneUrl&&Pn.current){po(Ao+L.sceneUrl,null,{quiet:!0,folder:Pn.current.folder,link:Pn.current.link});return}po(Vc)}function fc(p){return rt.current?!1:(ye(p+" refused — this scene has no sketch text (the scene has not finished loading)."),!0)}function Fv(){var p=S.current.cw;try{var _=p&&p.document.querySelector("canvas");_&&(_.style.cursor=qc[S.current.tool]||"default")}catch{}}var qn=j.useCallback(function(p){Pt(p?Ch(p.declared):[])},[]),Vt=j.useCallback(function(p,_,O,A){var D=f.current;if(D){var z=D.getContext("2d");if(z){var oe=A??xe.current;if(Cf(),!p){z.clearRect(0,0,D.width,D.height);return}if(os(p)){z.clearRect(0,0,D.width,D.height);return}var Q=Ch(p.declared);if(oe===sr){if(!O){z.clearRect(0,0,D.width,D.height);return}Q=Q.filter(function(J){return J&&J.ref===O})}dM(z,Q,O||null,p,hc)}}},[]);function os(p){var _=S.current.cw;if(!_)throw new Error("[AuthorView] no experiment frame is grabbed — OrbitBag.hasAngularPose, the ONE 3D-ness predicate (lib/frqtl/compat/renderer/orbit-bag.js), is read off the frame's modules. (FAIL-LOUD.)");return ot(_).OrbitBag.hasAngularPose(p?p.cameraControl:null)}function ss(p,_,O){var A=S.current.runner,D=A&&A.renderer;if(!D||typeof D.screenToWorld!="function")throw new Error("[AuthorView] the active renderer provider has no screenToWorld capability (RENDERER_CONTRACT) — STUDIO maps the canvas only through the camera's own screenToWorld. (FAIL-LOUD.)");var z=f.current;return D.screenToWorld(p,_,z.width,z.height,O)}function zE(p,_){return ot(S.current.cw).LoDrawnCenter.drawnCenter(p.envelopeOf(_))[2]}function Nv(p,_){var O=f.current,A=S.current.runner.screenPointOf([p,_,0],O.width,O.height);return A?{x:A[0],y:A[1]}:null}function hc(p){if(!p)return null;var _=Nv(p.left,p.top),O=Nv(p.left+p.width,p.top+p.height);return!_||!O?null:{left:_.x,top:_.y,width:O.x-_.x,height:O.y-_.y}}function Of(){if(Qe){var p=d.current,_=f.current,O=_&&_.parentElement,A=null;try{A=p&&p.contentDocument}catch{A=null}var D=A?A.querySelectorAll('[data-role="camera-joystick"]'):[],z=null;if(O&&D.length===2){var oe=D[0].getBoundingClientRect(),Q=D[1].getBoundingClientRect(),J=p.getBoundingClientRect(),ne=O.getBoundingClientRect(),Fe=oe.left<Q.left?oe:Q,Me=oe.left<Q.left?Q:oe;z={x:J.left-ne.left+(Fe.right+Me.left)/2,y:J.top-ne.top+(Fe.top+Fe.bottom)/2}}K(function(it){return it===z||it&&z&&it.x===z.x&&it.y===z.y?it:z})}}function Cf(){Of();var p=f.current;if(p){var _=d.current,O=null;try{if(_&&_.contentDocument){for(var A=_.contentDocument.querySelectorAll("canvas"),D=0;D<A.length;D++){var z=A[D].getBoundingClientRect();if(z.width>0&&z.height>0){O=A[D];break}}!O&&A.length&&(O=A[0])}}catch{}if(!O){var oe=p.parentElement;oe&&(p.style.left="0",p.style.top="0",p.style.width="100%",p.style.height="100%",p.style.right="",p.style.bottom="",p.width=oe.clientWidth,p.height=oe.clientHeight);return}var Q=O.getBoundingClientRect(),J=_.getBoundingClientRect(),ne=p.parentElement?p.parentElement.getBoundingClientRect():J,Fe=J.left-ne.left+Q.left,Me=J.top-ne.top+Q.top,it=Q.width,le=Q.height,Oe=Math.round(it),Ue=Math.round(le);p.width!==Oe&&(p.width=Oe),p.height!==Ue&&(p.height=Ue),RE(function(X){return X&&X.left===Fe&&X.top===Me&&X.width===it&&X.height===le?X:{left:Fe,top:Me,width:it,height:le}})}}function jf(p,_,O){if(p.controlsNameByObject||(p.controlsNameByObject=new WeakMap),p.controlsNameByObject.has(O))return p.controlsNameByObject.get(O);p.controlsNameCounters||(p.controlsNameCounters={}),p.controlsNameCounters[_]=(p.controlsNameCounters[_]||0)+1;for(var A=O&&typeof O.name=="string"&&O.name?O.name:_+"#"+p.controlsNameCounters[_],D=A,z=1;p.controlsRegistry&&p.controlsRegistry.hasObject(D);)D=A+"_"+ ++z;return p.controlsNameByObject.set(O,D),D}function zv(p,_){var O=S.current.cw,A=S.current.runner,D=S.current.controlsRegistry;if(!(!O||!A||!D||!p)){var z=jf(S.current,_,p);if(!D.hasObject(z)){var oe;try{oe=ot(O).MakeControlsForObject.makeControlsForObject(p,{},{kind:_,name:z})}catch(J){window.console&&console.error&&console.error("[AuthorView] makeControlsForObject failed for "+_+' "'+z+'":',J);return}var Q=oe.controls.map(function(J){return Object.assign({},J,{onChange:function(ne){A.updateObjectProperty(p,J.bind.prop,ne),Kr("Knob")}})});D.registerObject(z,p,_),D.registerControls(z,Q)}}}function BE(p){var _=S.current.controlsRegistry;if(!(!_||!p||!S.current.controlsNameByObject)){var O=S.current.controlsNameByObject.get(p);O&&(_.hasControls(O)&&_.unregisterControls(O),_.hasObject(O)&&_.unregisterObject(O))}}function Rf(){var p=S.current.runner;p&&p.declared.forEach(function(_){zv(_,_._schemaKind)})}function Lf(p,_,O,A,D,z){p.updateObjectProperty(_,"rect",ot(S.current.cw).LoDrawnCenter.snapRectPosition([O,A,D,z]))}function Bv(p){var _=S.current.cw;if(!cr(_)||!p)return null;var O=ot(_).ObjectSchema;try{return O.ux(p._schemaKind)}catch{return null}}function Uv(p,_){if(!_||_==="move")return _;var O=Bv(p);return O&&(O.resizable===!1||Array.isArray(O.handles)&&O.handles.indexOf(_)===-1)?"move":_}function UE(p,_,O){for(var A=ot(p).ObjectSchema.placeableCatalog(),D=0;D<A.length;D++)if(A[D].kind===_&&A[D].defaultProps&&Object.prototype.hasOwnProperty.call(A[D].defaultProps,"is2D"))return{is2D:!O};return null}function Hv(p,_,O){var A=S.current.cw,D=S.current.runner,z=S.current.backdrop,oe,Q;Promise.resolve().then(function(){if(!A||!D)throw new Error("the canvas frame has no "+[!A&&"window (ctx.cw)",!D&&"experiment runner (FrqtlPage.runner)"].filter(Boolean).join(" and no ")+" — nothing to place into.");var J=HE(_,O);oe=J.x,Q=J.y;var ne=UE(A,p,os(D));return ne}).then(function(J){var ne=DA(p,D,A,oe,Q,J);zv(ne,ne._schemaKind),qn(D,z),Et(ne),De.current=ne,ho(D),Vt(D,z,ne),T(function(Fe){return Object.assign({},Fe,{dirty:!0})}),Kr("Drop"),Wv(),St("drop")}).catch(function(J){window.console&&console.error&&console.error("[AuthorView] place "+p+" failed:",J),Wv(),ye("Place "+p+" failed: "+(J&&J.message?J.message:J),"drop")})}function HE(p,_){var O=ss(p,_,0);if(!O)throw new Error("that canvas point does not meet the drop plane (z = 0) from this camera view — drop where the scene is visible.");return O}function Wv(){k("hand"),P(null),S.current.tool="hand",S.current.dropType=null}function WE(){var p=f.current;if(!p||p.__egptOverlayHandlers)return;p.__egptOverlayHandlers=!0;var _=CP({hitTest:function(X,Se){var se=S.current.runner,ae=se?Af(se,X,Se):null;return ae?ae.ref:null},handArmed:function(){return S.current.tool==="hand"},emit:function(X){X.kind==="press"?O(X.x,X.y):X.kind==="drag"?D(X.x,X.y):X.kind==="hover"?oe(X.x,X.y):X.kind==="release"?Q():X.kind==="hold"?J(X.x,X.y):X.kind==="reset"?JE():X.kind==="world"?Fe(X):X.kind==="object"&&Ue(X)}});jP(p,_);function O(X,Se){var se=S.current.runner;if(se){var ae=S.current.backdrop,be=S.current.tool;if(be){if(be==="dropper"){S.current.dropType&&Hv(S.current.dropType,X,Se);return}var $e=os(se),Je=Af(se,X,Se);if(Je){var mt=Je.ref;if(Et(mt),De.current=mt,qn(se,ae),Vt(se,ae,mt),be==="pencil"){$e&&(p.style.cursor="default");return}A(se,mt,Je.zone,X,Se)}else Et(null),De.current=null,Vt(se,ae,null),M.current.active=!1,$e&&(p.style.cursor="default")}}}function A(X,Se,se,ae,be){if(!X.positionAuthorityOf(Se)){ye("Not moved: "+X.noPositionAuthorityMessage(Se),"drag"),p.style.cursor="not-allowed";return}St("drag");var $e=Ha(Se,X),Je=zE(X,Se),mt=ss(ae,be,Je);if(!mt){p.style.cursor="not-allowed";return}M.current={active:!0,lo:Se,startX:mt.x,startY:mt.y,planeZ:Je,zone:se,origBbox:$e?Object.assign({},$e):null},p.style.cursor=px(se)}function D(X,Se){var se=S.current.runner;if(se){var ae=S.current.backdrop,be=M.current;if(!(!be.active||!be.lo)){var $e=ss(X,Se,be.planeZ);if($e){var Je={x:$e.x-be.startX,y:$e.y-be.startY};if(be.moved=!0,be.origBbox){var mt=be.origBbox;if(be.zone==="move"||!be.zone){var vc=se.envelopeOf(be.lo);Lf(se,be.lo,mt.left+Je.x,mt.top+Je.y,vc.w,vc.h)}else{var _i=hM(mt,be.zone,Je);Lf(se,be.lo,_i.left,_i.top,_i.width,_i.height)}}z(se,ae,be.lo)}}}}function z(X,Se,se){qn(X,Se),Vt(X,Se,se);try{X.repaint()}catch(ae){window.console&&console.warn&&console.warn("[AuthorView] hand: repaint() failed:",ae)}T(function(ae){return Object.assign({},ae,{dirty:!0})})}function oe(X,Se){var se=S.current.runner;if(se){var ae=De.current;if(ae&&!os(se)){var be=Ha(ae,se);if(be){var $e=hc(be),Je=Uv(ae,Ph($e,{x:X,y:Se}));p.style.cursor=Je?px(Je):qc[S.current.tool]||"default";return}}p.style.cursor=qc[S.current.tool]||"default"}}function Q(){if(M.current.active){var X=!!M.current.moved;M.current={active:!1,lo:null,startX:0,startY:0,zone:null,origBbox:null},p&&(p.style.cursor=qc[S.current.tool]||"default"),X&&Kr("Move")}}function J(X,Se){var se=S.current.runner;if(se){var ae=Af(se,X,Se);ae&&(Et(ae.ref),De.current=ae.ref,qn(se,S.current.backdrop),Vt(se,S.current.backdrop,ae.ref))}}var ne=null;function Fe(X){var Se=S.current.runner,se=Se&&Se.cameraControl;if(X.phase==="begin"){ne=se?{pose:se.getOrbit(),refusedSaid:{}}:{pose:null,refusedSaid:{}},se||Me(ne,"camera","this scene's renderer publishes no camera handle (getCameraControl).");return}if(X.phase==="end"){ne=null;return}if(!(!ne||!ne.pose||!se)){var ae=SP(ne.pose,X,se.poseFields,p.width);ae.refused.forEach(function(Je){Me(ne,Je.gesture,"this camera declares no "+Je.axes.join("/")+" axis (its poseFields: "+se.poseFields.map(function(mt){return mt.name}).join(", ")+").")});var be=ae.patch;if(X.fingers===2&&X.pan&&!ae.refused.some(function(Je){return Je.gesture==="pan"})){var $e=it(Se,se,X.pan.from,X.pan.to);$e&&(be.target=$e)}Object.keys(be).length&&Pf(be)}}function Me(X,Se,se){X.refusedSaid[Se]||(X.refusedSaid[Se]=!0,console.error("[AuthorView] "+Se+" gesture refused: "+se+" (FAIL-LOUD.)"))}function it(X,Se,se,ae){var be=le(Se),$e=ss(se.x,se.y,be.z),Je=ss(ae.x,ae.y,be.z);return!$e||!Je?null:{x:be.x-(Je.x-$e.x),y:be.y-(Je.y-$e.y),z:be.z}}function le(X){var Se=X.getOrbit();if(Se.target)return{x:Se.target.x,y:Se.target.y,z:Se.target.z||0};if(typeof X.worldFromCameraOffset=="function"){var se=X.worldFromCameraOffset({right:0,up:0,forward:Se.distance});return{x:se[0],y:se[1],z:se[2]}}if(os(S.current.runner))throw new Error("[AuthorView] the angular camera has no worldFromCameraOffset, so its orbit centre cannot be read for a pan. (FAIL-LOUD.)");var ae=ss(p.width/2,p.height/2,0);return{x:ae.x,y:ae.y,z:0}}var Oe=null;function Ue(X){var Se=S.current.runner;if(Se){if(X.phase==="begin"){var se=X.target;Et(se),De.current=se;var ae=Se.envelopeOf(se),be=Bv(se),$e=ot(S.current.cw).ObjectSchema.get(se._schemaKind).fields,Je=$e.some(function(Bf){return Bf.name==="orientationDeg"}),mt=Je?typeof se.orientationDeg=="number"?se.orientationDeg:0:null,vc=ot(S.current.cw).LoDrawnCenter.drawnCenter(ae);Oe={handle:se,env:Object.assign({},ae),orientation:mt,resizable:!!(be&&be.resizable===!0),handedness:Je?EP(function(Bf){return Se.screenPointOf(Bf,p.width,p.height)},vc,mt):null,refusedSaid:{}};return}if(X.phase==="end"){Oe&&Oe.wrote&&Kr(Oe.wrote),Oe=null;return}if(Oe){var _i=!1;if(X.active.rotate&&(Oe.orientation===null?Me(Oe,"rotate",Oe.handle._schemaKind+" declares no orientationDeg field."):(Se.updateObjectProperty(Oe.handle,"orientationDeg",OP(Oe.orientation,X.twistDeg,Oe.handedness)),_i=!0,Oe.wrote="Rotate")),X.active.resize)if(!Oe.resizable)Me(Oe,"resize",Oe.handle._schemaKind+" does not declare itself resizable (ux.resizable).");else{var ls=Oe.env,uy=Math.max(1,ls.w*X.scale),dy=Math.max(1,ls.h*X.scale);Lf(Se,Oe.handle,ls.left+(ls.w-uy)/2,ls.top+(ls.h-dy)/2,uy,dy),_i=!0,Oe.wrote=Oe.wrote==="Rotate"?"Rotate":"Resize"}_i&&z(Se,S.current.backdrop,Oe.handle)}}}}function Af(p,_,O){if(os(p)){var A=f.current,D=typeof p.pickObjectAtScreen=="function"?p.pickObjectAtScreen(_,O,A.width,A.height):null;return D?{ref:D,zone:"move"}:null}var z=De.current;if(z){var oe=Ha(z,p);if(oe){var Q=Uv(z,Ph(hc(oe),{x:_,y:O}));if(Q)return{ref:z,zone:Q}}}for(var J=Ch(p.declared),ne=J.length-1;ne>=0;ne--)if(p.isPointable(J[ne].ref)){var Fe=Ha(J[ne].ref,p);if(Fe&&Ph(hc(Fe),{x:_,y:O}))return{ref:J[ne].ref,zone:"move"}}return null}function VE(p){typeof p.setDesignMode=="function"&&p.setDesignMode(!0),p.stop(),p.step()}function ho(p){if(!(!p||typeof p.repaint!="function"))try{p.repaint()}catch(_){window.console&&console.warn&&console.warn("[AuthorView] repaint() after a scene mutation failed:",_)}}function qE(p,_,O){if(O.__studioScenePreApplied){O.__studioScenePreApplied=!1;try{Rf(),qn(p,_),Vt(p,_,null),ho(p)}catch(A){ye("Recipe load failed: "+(A&&A.message?A.message:A)),window.console&&console.error&&console.error("[AuthorView] _consumePendingModule failed:",A)}}}function $E(p){if(!(!p||!p.FrqtlPage||typeof p.FrqtlPage.isReady!="function"||!p.FrqtlPage.isReady())&&!p.__studioSceneApplying){p.__studioSceneApplying=!0;var _=window._egptPendingFolder;window._egptPendingFolder=void 0;var O=rs.current;rs.current="seed";var A=_||ES({router:{resolve:c}}).then(function(z){return z.files}),D=null;Promise.resolve(A).then(function(z){return D=z,O==="seed"||!rt.current?Mr(bA(z)):O==="run"&&Mr(xA(rt.current,z)),p.FrqtlPage.applyModuleSource({files:z})}).then(function(){p.__studioScenePreApplied=!0}).catch(function(z){var oe=z&&z.message?z.message:String(z);if(ye("Scene load failed: "+oe),O==="run"&&D!==null){var Q=jS(z);dc({message:oe,line:Q?Q.line:void 0,col:Q?Q.col:void 0}),Lv(!0),_f(!0)}})}}var Vv=j.useCallback(function(){var p=d.current,_=p&&p.contentWindow;if(!_)return!1;if(!Wa(_,"runner")){try{(!p.src||!_.location||_.location.href===p.src)&&$E(_)}catch{}return!1}try{if(p.src&&_.location&&_.location.href!==p.src)return!1}catch{}if(!rc(_))return MA(_,{resolve:c}).catch(function(le){ye("STUDIO cannot drive this frame: "+(le&&le.message?le.message:le)),window.console&&console.error&&console.error("[AuthorView] frame modules not loaded:",le)}),!1;var O=Wa(_,"runner"),A=RP(_,O),D=ot(_).Filters,z=PP(S.current.runner,O);if(S.current.writeQueue&&typeof S.current.writeQueue.dispose=="function"&&S.current.writeQueue.dispose(),S.current={runner:O,backdrop:A,Filters:D,cw:_,tool:S.current.tool,dropType:S.current.dropType,controlsRegistry:ot(_).ControlRegistry.makeControlRegistry(),controlsNameByObject:new WeakMap,controlsNameCounters:{},writeQueue:ot(_).FrqtlControlWriteQueue.makeControlWriteQueue()},typeof O=="object"&&O&&(O._onObjectMoved=function(){var le=S.current.runner;le&&(typeof le.getGrabbedObject=="function"&&le.getGrabbedObject()&&(Sf.current=!0),qn(le,S.current.backdrop),Vt(le,S.current.backdrop,De.current))}),Promise.resolve().then(Rf).catch(function(le){window.console&&console.error&&console.error("[AuthorView] scene controls not registered:",le),ye("Scene controls not registered: "+(le&&le.message?le.message:le))}),z&&O&&!O._liveChartsMounted){O._liveChartsMounted=!0;var oe=!1;_.addEventListener("pagehide",function(){oe=!0,O._liveChartsMount&&(O._liveChartsMount.dispose(),O._liveChartsMount=null)},{once:!0});try{n1(O,{document:_.document}).then(function(le){if(oe){le.dispose();return}O._liveChartsMount=le}).catch(function(le){window.console&&console.error&&console.error("[AuthorView] mountLiveCharts failed:",le)})}catch(le){window.console&&console.error&&console.error("[AuthorView] mountLiveCharts threw:",le)}}var Q=O._renderOptions||{};vr({particles:Q.renderBaseCanvas!==!1,backdrop:A?A.visible!==!1:!1}),typeof O.getRateLimits=="function"&&Ie(O.getRateLimits());var J=O.cameraControl||null;if(z&&ct(null),Sn(J?J.getOrbit():null),co(gx(J)),Sv(vx(J)),Ev(!!(O.renderer&&typeof O.renderer.screenToWorld=="function")),z&&Yv(),J||vM(_,function(){var le=S.current.runner;if(le===O){var Oe=le.cameraControl||null;Oe&&(Sn(Oe.getOrbit()),co(gx(Oe)),Sv(vx(Oe)),Ev(!!(le.renderer&&typeof le.renderer.screenToWorld=="function")),Kv(_,le),Tf(le,xe.current,S.current.tool),m.current||(m.current={orbit:Oe.getOrbit(),preset:null}),Rv(_),Of())}}),qn(O,A),Cf(),Rv(_),WE(),Fv(),z){VE(O),me(or);var ne=x.current;if(!ne)throw new Error("[AuthorView] the control host element is not mounted — STUDIO hands it to the runner (runner.controlHost) so a scene knob is reachable above the overlay. (FAIL-LOUD.)");for(;ne.firstChild;)ne.removeChild(ne.firstChild);O.controlHost=ne}if(qE(O,A,_),Kv(_,O),Of(),z&&typeof O.addAimListener=="function"){Tn.current&&Tn.current();var Fe=null;Tn.current=O.addAimListener(function(le){if(S.current.runner===O){if(le.state!=="grabbed"&&Sf.current&&(Sf.current=!1,Kr("Carry")),le.state==="grabbed"){var Oe=O.getGrabbedObject();Oe&&Oe!==De.current&&(De.current=Oe,Et(Oe),qn(O,S.current.backdrop))}le.error&&le.error!==Fe&&ye("Not held: "+le.error,"aim"),le.error||St("aim"),Fe=le.error}})}z&&(B.current=[],pe([]),ve.current=null,ce(null)),z&&(m.current=null);var Me=null;if(window._egptPendingRenderState!==void 0){var it=window._egptPendingRenderState;window._egptPendingRenderState=void 0;try{Me=IE(_,O,it)}catch(le){throw ye("Saved render state could not be applied: "+(le&&le.message?le.message:le)),le}}return z&&O.cameraControl&&(m.current={orbit:O.cameraControl.getOrbit(),preset:Me&&Me.camera==="preset"?Me.preset:null}),Vt(O,A,De.current,z?or:xe.current),kt(!0),!0},[qn,Vt]);j.useEffect(function(){var p=0,_=null,O=!1;function A(){if(!O&&!Vv()){if(++p>120){ye("Timed out waiting for the experiment runner.");return}_=setTimeout(A,150)}}var D=d.current;function z(){p=0,kt(!1),ye(null),A()}return D&&D.addEventListener("load",z),A(),function(){O=!0,D&&D.removeEventListener("load",z),_&&clearTimeout(_)}},[Vv,ke]),j.useEffect(function(){return function(){Yv(),Tn.current&&(Tn.current(),Tn.current=null)}},[]),j.useEffect(function(){if(ge){var p=setInterval(function(){var _=S.current.runner;if(_){typeof _.getRates=="function"&&de(_.getRates()),typeof _.getRateLimits=="function"&&Ie(_.getRateLimits());var O=_.isRunning?sr:or;xe.current!==O&&me(O)}},1e3);return function(){clearInterval(p)}}},[ge]);function qv(p,_){var O=S.current.runner;if(!(!O||typeof O.setRateLimits!="function")){var A=_==="Inf"?1/0:Number(_);if(!(isNaN(A)||A<0))try{var D={};D[p]=A,O.setRateLimits(D),Ie(O.getRateLimits())}catch(z){window.console&&console.warn&&console.warn("[AuthorView] setRateLimits failed:",z&&z.message?z.message:z)}}}function KE(p){var _=S.current.runner;_&&_.setRenderOption("renderBaseCanvas",p),vr(function(O){return Object.assign({},O,{particles:p})}),T(function(O){return Object.assign({},O,{dirty:!0})})}function $v(p){var _=S.current.runner,O=S.current.backdrop;_&&O&&_.updateObjectProperty(O,"visible",p),vr(function(A){return Object.assign({},A,{backdrop:p})}),T(function(A){return Object.assign({},A,{dirty:!0})})}function YE(p,_){var O=S.current.runner;try{O.updateObjectProperty(p.ref,"visible",_)}catch(A){ye("Visibility not changed: "+(A&&A.message?A.message:A));return}qn(O),ho(O),Kr("Visibility")}function GE(p){var _=cr(S.current.cw)?ot(S.current.cw).ObjectSchema.get(p):null;return!!(_&&_.fields.some(function(O){return O.name==="visible"}))}function Kv(p,_){if(!(!p||!_)&&!(g.current&&g.current.cw===p)){var O=p.document&&p.document.getElementById("canvas-wrapper");if(O&&!p.document.querySelector('[data-role="camera-joystick"]')){var A=ot(p).CameraControls.attach(_,O);A&&A.mounted&&(g.current={handle:A,cw:p})}}}function Yv(){var p=g.current;if(p&&p.handle&&typeof p.handle.dispose=="function")try{p.handle.dispose()}catch{}g.current=null}function Pf(p){var _=S.current.runner;!_||!_.cameraControl||(_.cameraControl.setOrbit(p),Sn(_.cameraControl.getOrbit()),ct(null),Mf(_))}function Mf(p){ho(p),Vt(p,S.current.backdrop,De.current)}function JE(){var p=S.current.runner;if(!p||!p.cameraControl){console.error("[AuthorView] touch reset refused: this scene's renderer publishes no camera handle (getCameraControl). (FAIL-LOUD.)");return}var _=m.current;if(!_)throw new Error("[AuthorView] the scene's opening camera was never read, so a double tap has no view to return to. (FAIL-LOUD.)");_.preset?Gv(_.preset):Pf(_.orbit)}function Gv(p){var _=S.current.runner;!_||!_.cameraControl||typeof _.cameraControl.setPreset!="function"||(_.cameraControl.setPreset(p),Sn(_.cameraControl.getOrbit()),ct(p),ve.current=null,ce(null),Mf(_))}function Jv(){var p=S.current.runner,_=De.current;!p||!_||(BE(_),p.removeObject(_),Et(null),De.current=null,qn(p,S.current.backdrop),Vt(p,S.current.backdrop,null),T(function(O){return Object.assign({},O,{dirty:!0})}),Kr("Delete"))}j.useEffect(function(){var p=S.current.runner;p&&typeof p.setSelectHighlight=="function"&&(p.setSelectHighlight(Ut||null),ho(p))},[Ut]);function Tf(p,_,O){if(!(!p||typeof p.setAimArmed!="function")){var A=_===or&&!!O;A!==p.isAimArmed()&&(p.setAimArmed(A),ho(p))}}j.useEffect(function(){ge&&Tf(S.current.runner,ie,pt)},[ge,ie,pt]),j.useEffect(function(){function p(_){if(De.current){var O=_.target;if(!(O&&O.closest&&O.closest("[data-selection-safe]"))){Et(null),De.current=null;var A=S.current.runner;A&&Vt(A,S.current.backdrop,null)}}}return document.addEventListener("mousedown",p,!0),function(){document.removeEventListener("mousedown",p,!0)}},[]),j.useEffect(function(){function p(_){if(!(_.key!=="Delete"&&_.key!=="Backspace")&&De.current){var O=S.current.cw,A=cr(O)?ot(O).CameraControls:null;if(!A)throw new Error("[AuthorView] CameraControls.isTypingTarget is unreachable in the experiment frame — it is the ONE typing predicate (lib/frqtl/parts/CameraControls.js). (FAIL-LOUD.)");A.isTypingTarget(_,document)||(_.preventDefault(),Jv())}}return window.addEventListener("keydown",p),function(){window.removeEventListener("keydown",p)}},[]);function XE(p,_){if(p.button!==0||!ge)return;var O=p.currentTarget,A=p.pointerId,D={kind:_.kind,label:_.displayName,x0:p.clientX,y0:p.clientY,dragging:!1,suppressClick:!1};$.current=D;try{O.setPointerCapture(A)}catch{}function z(ne){if(!D.dragging){if(Math.abs(ne.clientX-D.x0)+Math.abs(ne.clientY-D.y0)<bM)return;D.dragging=!0,D.prevCursor=document.body.style.cursor,D.prevSelect=document.body.style.userSelect,document.body.style.cursor="copy",document.body.style.userSelect="none",he({label:D.label,x:ne.clientX,y:ne.clientY})}var Fe=U.current;Fe&&(Fe.style.left=ne.clientX+12+"px",Fe.style.top=ne.clientY+12+"px")}function oe(ne,Fe){O.removeEventListener("pointermove",z),O.removeEventListener("pointerup",Q),O.removeEventListener("pointercancel",J);try{O.releasePointerCapture(A)}catch{}if(D.dragging&&(D.suppressClick=!0,setTimeout(function(){D.suppressClick=!1},0),document.body.style.cursor=D.prevCursor||"",document.body.style.userSelect=D.prevSelect||"",he(null),!!Fe)){var Me=f.current;if(!(!Me||document.elementFromPoint(ne.clientX,ne.clientY)!==Me)){var it=Me.getBoundingClientRect();Hv(D.kind,ne.clientX-it.left,ne.clientY-it.top)}}}function Q(ne){oe(ne,!0)}function J(ne){oe(ne,!1)}O.addEventListener("pointermove",z),O.addEventListener("pointerup",Q),O.addEventListener("pointercancel",J)}function QE(p){var _=$.current;_&&_.kind===p.kind&&_.suppressClick||ZE(p.kind)}function ZE(p){St("drop"),P(p),k("dropper")}function pc(p){if(St("drop"),pt===p){k(null),P(null),Et(null),De.current=null;var _=S.current.runner;_&&Vt(_,S.current.backdrop,null);return}k(p),p!=="dropper"&&P(null)}function eO(){var p=S.current.runner;p&&(p.stop(),typeof p.setDesignMode=="function"&&p.setDesignMode(!0),p.step(),me(or),Vt(p,S.current.backdrop,De.current,or))}function Xv(){var p=S.current.runner;p&&(typeof p.setDesignMode=="function"&&p.setDesignMode(!1),Tf(p,sr,S.current.tool),p.start(),me(sr),Vt(p,S.current.backdrop,De.current,sr))}function tO(){xe.current===sr?eO():Xv()}function nO(){if(!fc("Restart")){var p=wh(rt.current),_=Tv("Restart");if(_.ok){var O=_.state;if(L.projectId)try{Zb(gn(),{files:p,renderState:O}),T(function(A){return Object.assign({},A,{dirty:!1})}),is()}catch(A){ye("Restart: the save failed — "+(A&&A.message?A.message:A),"save")}Dv(p,O)}}}function Qv(p,_,O){T({projectId:null,walkthroughId:p.id,walkthroughMode:_||null,name:p.title,dirty:!1}),O?(window._egptPendingFolder=Object.assign({},O),rs.current="keep"):(window._egptPendingFolder=gd(i,p.id).then(function(z){return z.files}),rs.current="seed",Mr(null));var A=Zi(p,_);window._egptPendingRenderState=A;var D={renderer:A.renderer,seed:A.seed};je(hs(e,D)+"&_r="+Date.now())}function rO(p){var _=Kt(i,L.walkthroughId);if(_&&p!==(L.walkthroughMode||Lo(_))&&!fc("Switching mode")){var O=ha();window._egptPendingFolder=void 0,window._egptPendingRenderState=void 0,kt(!1),ye(null),Et(null),De.current=null,Pt([]),me(or),Qv(_,p,O),as(Zv(_,p))}}function as(p){typeof u=="function"&&XL(at.author,p).forEach(function(_){u(_[0],_[1])})}function Zv(p,_){return{walkthrough:p.id,mode:Dl(p).length>1?_||Lo(p):""}}function po(p,_,O){var A=!!(O&&O.quiet);if(An.current=!1,window._egptPendingFolder=void 0,Y(null),window._egptPendingRenderState=void 0,rs.current="seed",Mr(null),dc(null),kt(!1),ye(null),Wn(null),Et(null),De.current=null,Pt([]),me(or),p===Vc){T({projectId:null,name:"Empty Universe",dirty:!1}),A||as({}),je(hs(e)+"&_r="+Date.now());return}if(p.indexOf("walkthrough:")===0){var D=p.slice(12),z=Kt(i,D);if(!z){ye("Walk-through rung not found: "+D);return}Qv(z,_||Lo(z)),A||as(Zv(z,_));return}if(p.indexOf(Ao)===0){var oe=O&&O.folder;if(!oe||!oe.files||!oe.renderState){ye("Scene draft refused — a scene: selection carries its folder (studio-landing-of.js). (FAIL-LOUD.)");return}var Q=p.slice(Ao.length);Pn.current={folder:oe,link:O&&O.link||{scene:Q}},T({projectId:null,sceneUrl:Q,name:decodeURIComponent(Q.split("/").pop()),dirty:!1}),A||as(Pn.current.link),window._egptPendingFolder=Object.assign({},oe.files),window._egptPendingRenderState=oe.renderState,je(hs(e,{renderer:oe.renderState.renderer,seed:oe.renderState.seed})+"&_r="+Date.now());return}if(p.indexOf("project:")===0){var J=p.slice(8);try{var ne=Eh(gn(),J);if(!ne){ye("Project not found: "+J);return}T({projectId:J,name:J,dirty:!1}),A||as({project:J}),window._egptPendingFolder=Object.assign({},ne.files),window._egptPendingRenderState=ne.renderState;var Fe={renderer:ne.renderState.renderer,seed:ne.renderState.seed};je(hs(e,Fe)+"&_r="+Date.now())}catch(Me){ye("Load project failed: "+(Me&&Me.message?Me.message:Me))}return}}function Df(p,_,O){if(fc(p))return Promise.resolve(null);if(!ha())return ye(p+" refused — the canvas has no project folder yet (it has not finished loading).",_),Promise.resolve(null);var A;try{A=Mv()}catch(z){return ye(p+" refused — "+(z&&z.message?z.message:z),_),Promise.resolve(null)}if(_h(rt.current))return O?Promise.resolve({files:wh(rt.current),renderState:A,unrun:!0}):(ye(p+" refused — "+Ef(rt.current),_),Promise.resolve(null));var D=fa();return D?D.toSketch().then(function(z){return z.refused.length&&ye(p+" — hands not written: "+z.refused.map(function(oe){return oe.reason}).join(" "),"hand"),Av(z.files),{files:ha(),renderState:A,unrun:!1}}):(ye(p+" refused — the canvas has no scene facade to write the sketch from (it has not finished loading).",_),Promise.resolve(null))}var ey="Saved your code; the canvas still runs the previous text — Run to see it.";function ty(p){if(!(!p||!p.trim())){lc(!1);var _=p.trim();if(rt.current&&Ou(rt.current).indexOf(Ge)!==-1){ye("Save As refused — "+sm+" (unrun: "+Ge+", which Save As renames)","save");return}Df("Save As","save",!0).then(function(O){if(O){var A=gn();cm(A,{files:O.files,renderState:O.renderState},_);var D={};D[Ge]=Eh(A,_).files[Ge],Mr(LS(rt.current,D)),St("save"),Y(O.unrun?ey:'Saved as "'+_+'".'),T({projectId:_,name:_,dirty:!1}),as({project:_}),is()}}).catch(function(O){ye("Save As failed: "+(O&&O.message?O.message:O),"save")})}}function If(p){fc("Save As")||(Ov(p),lc(!0))}function iO(){if(!L.projectId){If(L.name||"");return}Df("Save","save",!0).then(function(p){p&&(Zb(gn(),{files:p.files,renderState:p.renderState}),St("save"),Y(p.unrun?ey:'Saved "'+L.projectId+'".'),T(function(_){return Object.assign({},_,{dirty:!1})}),is())}).catch(function(p){ye("Save failed: "+(p&&p.message?p.message:p),"save")})}j.useEffect(function(){if(!(!ge||!S.current.cw)){var p=NP(S.current.cw);p&&we.current!==p&&(we.current=p,console.error("[AuthorView] Record unavailable: "+p+". (FAIL-LOUD.)")),p||un(ot(S.current.cw).parts.FrqtlVision.RECORD_DEFAULTS.seconds),cn(p||!1)}},[ge]),j.useEffect(function(){ge||!lt.current||(lt.current.stop(),lt.current=null,Mt({phase:"idle"}))},[ge]),j.useEffect(function(){if(Pe.phase==="recording"){Dn(Date.now());var p=setInterval(function(){Dn(Date.now())},250);return function(){clearInterval(p)}}},[Pe.phase]);var pa=ge&&S.current.runner&&cr(S.current.cw)?ot(S.current.cw).parts.FrqtlVision.recordRefusal(S.current.runner):{reason:"loading"},ny=Pe.phase==="encoding"||Pe.phase!=="recording"&&!!pa;function oO(){return L.walkthroughId||L.name||r1}function sO(){if(Pe.phase==="recording"){lt.current&&lt.current.stop(),Mt({phase:"encoding"});return}var p=S.current.cw,_=S.current.runner,O=new AbortController,A,D=oO(),z=new Date;try{A=ot(p).parts.FrqtlVision.attach(_).record({signal:O.signal})}catch(Q){ye("Record failed: "+(Q&&Q.message?Q.message:Q),"record"),console.error("[AuthorView] Record failed to start:",Q);return}var oe={};lt.current={stop:function(){O.abort()},token:oe},St("record"),Mt({phase:"recording",startedMs:Date.now()}),A.then(function(Q){if(!(!lt.current||lt.current.token!==oe)){var J=BP(Q,D,z);lt.current=null,Mt({phase:"ready",file:J,frames:Q.track.frames.length,everyTicks:Q.track.ticksPerFrame,atLimit:!Q.truncated,canShare:QS(navigator,J)})}}).catch(function(Q){!lt.current||lt.current.token!==oe||(lt.current=null,Mt({phase:"idle"}),ye("Recording failed: "+(Q&&Q.message?Q.message:Q),"record"),console.error("[AuthorView] Recording failed:",Q))})}function aO(){MP(navigator,Pe.file,Pe.file.name).then(function(){St("record")},function(p){p&&p.name==="AbortError"||(ye("Share failed: "+(p&&p.message?p.message:p)+" — use Save instead.","record"),console.error("[AuthorView] Share failed:",p))})}function lO(){JS(Pe.file.name,Pe.file),St("record")}var Ff=j.useRef(null);function cO(){Df("Export","export",!1).then(function(p){return p?IP().then(function(_){var O=ZA(p.files,p.renderState,{sdkVersion:_});TP(Qb({files:p.files,renderState:p.renderState})+".zip",O),St("export")}):null}).catch(function(p){ye("Export failed: "+(p&&p.message?p.message:p),"export")})}function uO(p){var _=p.target.files&&p.target.files[0];p.target.value="",_&&DP(_).then(function(O){var A=$S(O,_.name),D=Qb(A);cm(gn(),A,D),St("import"),is(),po("project:"+D)}).catch(function(O){ye("Import failed: "+(O&&O.message?O.message:O),"import")})}function ry(p){var _=fa();return!_||!rt.current?"the scene's sketch text has not loaded":typeof _.forkRefusal!="function"?"this page's facade has no fork door":_h(rt.current)?Ef(rt.current):_.forkRefusal(p)}function iy(p,_){da(null);var O=(_||"").trim();if(O){var A=ry(p);if(A){ye("Fork refused — "+A,"fork");return}fa().fork(p,O,{by:"human"}).then(function(D){Mr($b(Yb(rt.current,D.files),D.file)),T(function(Q){return Object.assign({},Q,{dirty:!0})}),St("fork"),Y("Forked "+D.from+" into "+D.file+" — edit it in the code drawer, then Run.");var z=S.current.runner;Rf(),qn(z,S.current.backdrop);var oe=z.declared.filter(function(Q){return Q.name===p})[0]||null;Et(oe),De.current=oe,Vt(z,S.current.backdrop,oe),ho(z)}).catch(function(D){ye("Fork failed: "+(D&&D.message?D.message:D),"fork")})}}function oy(p,_,O,A){if(!cr(p)||!_)return null;var D;try{D=ot(p).MakeControlsForObject.makeControlsForObject(_,{},{kind:O,name:A})}catch(Q){return window.console&&console.error&&console.error("[AuthorView Inspector] makeControlsForObject failed:",Q),null}var z={},oe={};return D.controls.forEach(function(Q){z[Q.id]=Q}),D.display.forEach(function(Q){oe[Q.id]=Q}),{objectName:A,display:D.display,controlsById:z,displayById:oe}}function sy(p,_,O,A,D,z){function oe(Ue){z(O.name,Ue)}var Q=A?A.objectName+"."+O.name:null,J=A&&Q?A.controlsById[Q]:null,ne=A&&Q?A.displayById[Q]:null,Fe=iM(p,O);if(Fe){var Me=J?J.value:ne?ne.value:_?_[O.name]:void 0;return Ze.createElement(Fe.Component,{obj:_,field:O,value:Me,commit:oe})}if(J){if(J.kind==="scalar")return v.jsx(_M,{cw:D,control:J,onChange:oe});if(J.kind==="enum")return v.jsx("select",{value:J.value,style:_e.select,onChange:function(Ue){oe(Ue.target.value)},children:J.values.map(function(Ue){return v.jsx("option",{value:Ue,children:Ue},Ue)})});if(J.kind==="flags")return v.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:J.values.map(function(Ue){var X=J.value.indexOf(Ue)!==-1;return v.jsxs("label",{style:Object.assign({},_e.sub,{display:"flex",gap:"5px",cursor:"pointer"}),children:[v.jsx("input",{type:"checkbox",checked:X,onChange:function(Se){var se=J.value.slice();Se.target.checked?se.indexOf(Ue)===-1&&se.push(Ue):se=se.filter(function(ae){return ae!==Ue}),oe(se)}})," ",Ue]},Ue)})});if(J.kind==="vector"){var it=J.value.length===4?["left","top","w","h"]:J.value.length===6?["left","top","z","w","h","d"]:J.value.map(function(Ue,X){return String(X)});return v.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"3px"},children:it.map(function(Ue,X){return v.jsxs("label",{style:Object.assign({},_e.sub,{display:"flex",gap:"3px",alignItems:"center"}),children:[Ue,v.jsx("input",{type:"number",value:Math.round(J.value[X]||0),step:"1",style:Object.assign({},_e.numInput,{width:48}),onChange:function(Se){var se=parseInt(Se.target.value,10);if(!isNaN(se)){var ae=J.value.slice();ae[X]=se,oe(ae)}}})]},Ue)})})}}if(O.type==="rect-array"){var le=A&&A.display?A.display.filter(function(Ue){return Ue.id.indexOf(Q+"[")===0}):[];return v.jsx("span",{style:_e.fieldVal,children:le.length?le.length+" rect(s)":"—"})}if(ne){var Oe=ne.value;return v.jsx("span",{style:_e.fieldVal,children:Oe!=null?typeof Oe=="object"?JSON.stringify(Oe):String(Oe):"—"})}return v.jsx("span",{style:_e.fieldVal,children:"—"})}function ma(p){return!We[p]}function dO(p){kn(function(_){var O=Object.assign({},_);return O[p]=!_[p],O})}function mc(p){var _=ma(p);return v.jsxs("div",{style:Object.assign({},_e.h,{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",userSelect:"none"}),"data-selection-safe":!0,title:_?"Collapse section":"Expand section",onClick:function(){dO(p)},children:[v.jsx("span",{children:p}),v.jsx("span",{style:{color:"#6a7a8a",fontSize:"0.6rem"},children:_?"▾":"▸"})]})}function fO(){if(!Ut)return v.jsx("div",{style:_e.sub,children:"Select an object (Pencil) to edit."});var p=S.current.cw,_=S.current.runner,O=cr(p)?ot(p).ObjectSchema:null,A=Ut,D=A._schemaKind,z=O?O.get(D):null;if(!z)return v.jsxs("div",{children:[v.jsx("div",{style:{marginBottom:"6px",color:"#ccc",fontSize:"0.68rem"},children:Ut.name||D}),v.jsx("div",{style:Object.assign({},_e.sub,{marginTop:"6px"}),children:"Schema loading — try again in a moment."})]});function oe(ae,be,$e){var Je=S.current.writeQueue,mt=ae+"."+be;Je&&typeof Je.write=="function"?Je.write(mt,$e):$e()}function Q(ae){var be=cr(p)?ot(p).MakeControlsForObject.NULL_ENUM_SENTINEL:void 0;return be!==void 0&&ae===be?null:ae}var J=jf(S.current,D,A),ne=oy(p,A,D,J);function Fe(ae,be){if(_){if(be=Q(be),ae==="leafDimension"&&typeof A.getFundamentalDimension=="function"){var $e=A.getFundamentalDimension();if(typeof $e=="number"&&typeof be=="number"&&be<$e&&typeof window<"u"&&typeof window.confirm=="function"){var Je=window.confirm("Emit Dimension "+be+" is BELOW the current fundamental ("+$e+"). This self-lowers the universe floor GLOBALLY and is a ONE-WAY RATCHET (there is no removeDimension). Continue?");if(!Je)return}}oe(J,ae,function(){try{_.updateObjectProperty(A,ae,be),Ve(function(mt){return mt+1}),Kr("Inspector edit"),qn(_,S.current.backdrop),Vt(_,S.current.backdrop,De.current),T(function(mt){return Object.assign({},mt,{dirty:!0})})}catch(mt){console.error("[AuthorView inspector] "+mt.message)}})}}var Me=_?t1(_,A):null,it=Me?Me._schemaKind||"QuantumEmitter":null,le=null;if(Me&&O){var Oe=null;try{Oe=O.get(it)}catch{Oe=null}le=(Oe&&Oe.fields||[]).filter(function(ae){return ae.name==="emissionCap"})[0]||null}var Ue=Me?jf(S.current,it,Me):null,X=Me&&le?oy(p,Me,it,Ue):null;function Se(ae,be){!_||!Me||oe(Ue,ae,function(){try{_.updateObjectProperty(Me,ae,be),Ve(function($e){return $e+1}),Kr("Inspector edit"),T(function($e){return Object.assign({},$e,{dirty:!0})})}catch($e){console.error("[AuthorView inspector] "+$e.message)}})}var se=ry(A.name);return v.jsxs("div",{children:[v.jsx("div",{style:{marginBottom:"6px"},children:v.jsx("button",{"data-role":"studio-fork-part",disabled:!!se,title:se||"Copy "+D+"'s part file into this project as parts/My"+D+".js and use it here",style:Object.assign({},$n(!1),se?{opacity:.45,cursor:"not-allowed"}:null),onClick:function(){se||da({name:A.name,value:"My"+D})},children:"Fork into project"})}),z.description&&v.jsx("div",{style:{marginBottom:"8px",color:"#7a8a9a",fontSize:"0.62rem",lineHeight:1.5,borderBottom:"1px solid #1c1c1c",paddingBottom:"6px"},children:z.description}),v.jsxs("div",{style:{marginBottom:"6px",color:"#ccc",fontSize:"0.68rem",display:"flex",alignItems:"center",gap:"6px"},children:[v.jsxs("span",{style:{flex:1},children:[A.name||D,v.jsxs("span",{style:Object.assign({},_e.sub,{marginLeft:"6px"}),children:["(",D,")"]})]}),v.jsx("button",{type:"button",title:"Delete (Del/Backspace)",onClick:Jv,style:{background:"#2a1414",border:"1px solid #5a2a2a",color:"#e08080",borderRadius:"3px",fontSize:"0.62rem",padding:"2px 7px",cursor:"pointer"},children:"Delete"})]}),z.fields.filter(function(ae){if(ae.internal===!0)return!1;var be=cr(p)?ot(p).MakeControlsForObject.evalVisibleWhen:null;return!(ae.visibleWhen&&be&&!be(ae,A))}).map(function(ae){return v.jsxs("div",{style:_e.fieldRow,"data-role":"studio-inspector-field","data-field":ae.name,children:[v.jsxs("div",{style:_e.fieldLabel,title:ae.description||ae.name,children:[ae.label||ae.name,ae.description&&v.jsx("span",{style:{color:"#4a5a6a",marginLeft:"3px"},title:ae.description,children:"?"})]}),v.jsx("div",{style:{flex:1,minWidth:0},children:sy(D,A,ae,ne,p,Fe)})]},ae.name)}),Me&&le&&v.jsxs("div",{"data-role":"population-gate",style:{marginTop:"10px",borderTop:"1px solid #2a2a2a",paddingTop:"8px"},children:[v.jsx("div",{style:_e.h,children:"Population Gate"}),v.jsx("div",{style:{marginBottom:"6px",color:"#7a8a9a",fontSize:"0.62rem",lineHeight:1.5},children:"This counter is the population authority for an emission gate — the knob writes the gating emitter's live emission cap (applies next tick; emission pauses at the limit and resumes below it)."}),v.jsxs("div",{"data-role":"population-gate-cap",style:_e.fieldRow,children:[v.jsx("div",{style:_e.fieldLabel,title:le.description||le.name,children:le.label||le.name}),v.jsx("div",{style:{flex:1,minWidth:0},children:sy(it,Me,le,X,p,Se)})]})]})]})}function hO(){var p=S.current.cw,_=cr(p)?ot(p).ObjectSchema:null,O=_?_.placeableCatalog():[];if(O.length===0)return v.jsx("span",{style:{opacity:.6,fontSize:11},children:"palette unavailable — ObjectSchema not loaded in the canvas frame"});for(var A={},D=0;D<O.length;D++){var z=O[D],oe=z.category||"other";A[oe]||(A[oe]=[]),A[oe].push(z)}var Q=[];return xM.forEach(function(J){!A[J]||A[J].length===0||(Q.push(v.jsx("div",{style:Object.assign({},_e.h,{marginTop:"8px"}),children:wM[J]||J},J)),A[J].forEach(function(ne){Q.push(v.jsx("button",{style:pO(ne.kind),disabled:!ge,onPointerDown:function(Fe){XE(Fe,ne)},onClick:function(){QE(ne)},title:ne.description,children:ne.displayName},ne.kind))}))}),Q}var _e={root:{display:"flex",flexDirection:"column",height:"100%",background:"#0d0d0d",color:"#cfcfcf",font:"12px ui-monospace,Menlo,Consolas,monospace"},topbar:{display:"flex",alignItems:"center",gap:"6px",padding:"5px 8px",background:"#111",borderBottom:"1px solid #222",flexShrink:0,flexWrap:"wrap"},body:{display:"flex",flex:1,minHeight:0},col:{display:"flex",flexDirection:"column",minWidth:0},palette:{width:172,borderRight:"1px solid #222",padding:"8px",flex:"0 0 auto",overflowY:"auto"},center:{flex:1,display:"flex",flexDirection:"column",background:"#000",minWidth:0,minHeight:0},canvasRegion:{position:"relative",flex:"1 1 0",minHeight:0},filePickerRow:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 12px",background:"#111",borderBottom:"1px solid #222",flexShrink:0},filePicker:{background:"#1a1a1a",color:"#7ec8e3",border:"1px solid #333",borderRadius:"3px",font:"11px ui-monospace,Menlo,Consolas,monospace",padding:"2px 4px"},readOnlyFile:{flex:1,margin:0,padding:"8px 12px",overflow:"auto",color:"#aaa",font:"11px ui-monospace,Menlo,Consolas,monospace",whiteSpace:"pre-wrap"},right:{width:240,borderLeft:"1px solid #222",display:"flex",flexDirection:"column",flex:"0 0 auto",overflowY:"auto"},h:{fontSize:"0.62rem",letterSpacing:"1px",color:"#5a5a5a",textTransform:"uppercase",margin:"4px 0 6px"},toolRow:{display:"flex",gap:"6px",marginBottom:"8px"},chip:{display:"flex",alignItems:"center",gap:"6px",width:"100%",textAlign:"left",background:"#1a1a1a",border:"1px solid #333",color:"#ccc",padding:"6px 8px",marginBottom:"4px",cursor:"pointer",borderRadius:"3px",fontSize:"0.62rem"},row:{display:"flex",alignItems:"center",gap:"7px",padding:"4px 2px"},sect:{padding:"10px",borderBottom:"1px solid #1c1c1c"},iframe:{position:"absolute",inset:0,width:"100%",height:"100%",border:0},overlay:{position:"absolute",left:0,top:0,pointerEvents:"auto",background:"transparent"},sel:{background:"#26323f"},sub:{color:"#7a7a7a",fontSize:"0.62rem"},fieldRow:{display:"flex",alignItems:"flex-start",gap:"5px",padding:"3px 0",borderBottom:"1px solid #141414"},fieldLabel:{color:"#7a7a7a",fontSize:"0.6rem",flex:"0 0 80px",paddingTop:"3px",wordBreak:"break-all"},fieldVal:{color:"#aaa",fontSize:"0.62rem"},numInput:{width:60,background:"#1a1a1a",color:"#ccc",border:"1px solid #333",padding:"2px 4px",fontSize:"0.62rem"},textInput:{width:"100%",background:"#1a1a1a",color:"#ccc",border:"1px solid #333",padding:"2px 4px",fontSize:"0.62rem"},select:{width:"100%",background:"#1a1a1a",color:"#ccc",border:"1px solid #333",padding:"4px",fontSize:"0.62rem"},hint:{color:"#4a4a4a",fontSize:"0.6rem",lineHeight:1.5,marginTop:"10px",whiteSpace:"pre-wrap"}};function Nf(p){var _=pt===p;return{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0",cursor:"pointer",borderRadius:"4px",background:_?"#2a3a4a":"#1a1a1a",border:"1px solid "+(_?"#4a7abf":"#333"),boxShadow:_?"inset 0 -3px 0 #8ab4f8":"none",color:_?"#8ab4f8":"#777"}}function zf(p,_){return{role:"button","aria-label":_,"aria-pressed":pt===p?"true":"false","data-tool":p}}function pO(p){var _=R===p;return Object.assign({},_e.chip,_?{borderColor:"#4a7abf",color:"#8ab4f8",background:"#22303f"}:null)}function mO(p){var _=ie===p,O={design:{bg:"#2a2a18",border:"#8a8a30",text:"#c8c84a"},run:{bg:"#182a18",border:"#308a30",text:"#4ac84a"},pause:{bg:"#2a1818",border:"#8a3030",text:"#c84a4a"}},A=O[p]||{};return{padding:"3px 9px",cursor:"pointer",borderRadius:"3px",fontSize:"0.62rem",fontFamily:"ui-monospace,Menlo,Consolas,monospace",letterSpacing:"0.5px",background:_?A.bg:"#1a1a1a",border:"1px solid "+(_?A.border:"#333"),color:_?A.text:"#999"}}function ay(){return{padding:"3px 9px",cursor:"pointer",borderRadius:"3px",fontSize:"0.62rem",fontFamily:"ui-monospace,Menlo,Consolas,monospace",letterSpacing:"0.5px",background:"#1a1a1a",border:"1px solid #333",color:"#999"}}function $n(p){return{padding:"3px 9px",cursor:"pointer",borderRadius:"3px",fontSize:"0.62rem",fontFamily:"ui-monospace,Menlo,Consolas,monospace",background:p?"#1a2a1a":"#1a1a1a",border:"1px solid "+(p?"#4a8a4a":"#333"),color:p?"#6aaa6a":"#888"}}function ly(p,_,O,A){return v.jsxs("label",{style:_e.row,children:[v.jsx("input",{type:"checkbox",checked:_,onChange:function(D){O(D.target.checked)},style:{accentColor:A},disabled:!ge}),p]})}var gO=L.projectId?"project:"+L.projectId:L.walkthroughId?"walkthrough:"+L.walkthroughId:L.sceneUrl?Ao+L.sceneUrl:Vc,vO=ie===sr?"running":"design",yO=ie===sr?"#6aaa6a":"#c8c84a",gc=L.walkthroughId?Kt(i,L.walkthroughId):null,cy=gc?Dl(gc):[],bO=gc?L.walkthroughMode||Lo(gc):null,xO=Object.assign({position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1},Pr?{left:Pr.left+"px",top:Pr.top+"px",width:Pr.width+"px",height:Pr.height+"px"}:{}),wO=Object.assign({},_e.overlay,Pr?{left:Pr.left+"px",top:Pr.top+"px",width:Pr.width+"px",height:Pr.height+"px"}:{},{pointerEvents:"auto"});return v.jsxs("div",{style:_e.root,children:[v.jsxs("div",{ref:w,"data-role":"studio-showcase-covered",style:{display:"contents"},children:[v.jsxs("div",{ref:E,"data-role":"studio-scene-covered",style:{display:"contents"},children:[H&&v.jsx("div",{ref:U,"data-role":"palette-drag-ghost","aria-hidden":"true",style:Object.assign({},_e.chip,{position:"fixed",left:H.x+12+"px",top:H.y+12+"px",width:"auto",zIndex:1e3,pointerEvents:"none",opacity:.9,borderColor:"#4a7abf",color:"#8ab4f8",background:"#22303f"}),children:H.label}),uo&&v.jsx("div",{"data-role":"studio-fork-prompt",style:{position:"absolute",inset:0,zIndex:999,background:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center"},children:v.jsxs("div",{style:{background:"#1a1a1a",border:"1px solid #333",borderRadius:"6px",padding:"20px",minWidth:"280px"},children:[v.jsxs("div",{style:{marginBottom:"10px",fontSize:"0.75rem",color:"#ccc"},children:['Fork "',uo.name,'" into a new part class (parts/<Name>.js):']}),v.jsx("input",{type:"text",value:uo.value,autoFocus:!0,"data-role":"studio-fork-name",style:Object.assign({},_e.textInput,{marginBottom:"12px",display:"block"}),onChange:function(p){var _=p.target.value;da(function(O){return O&&Object.assign({},O,{value:_})})},onKeyDown:function(p){p.key==="Enter"&&iy(uo.name,uo.value),p.key==="Escape"&&da(null)}}),v.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[v.jsx("button",{style:$n(!1),onClick:function(){da(null)},children:"Cancel"}),v.jsx("button",{style:$n(!0),"data-role":"studio-fork-commit",onClick:function(){iy(uo.name,uo.value)},children:"Fork"})]})]})}),LE&&v.jsx("div",{"data-role":"studio-save-as-prompt",style:{position:"absolute",inset:0,zIndex:999,background:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center"},children:v.jsxs("div",{style:{background:"#1a1a1a",border:"1px solid #333",borderRadius:"6px",padding:"20px",minWidth:"280px"},children:[v.jsx("div",{style:{marginBottom:"10px",fontSize:"0.75rem",color:"#ccc"},children:"Save project as:"}),v.jsx("input",{type:"text",value:wf,autoFocus:!0,style:Object.assign({},_e.textInput,{marginBottom:"12px",display:"block"}),onChange:function(p){Ov(p.target.value)},onKeyDown:function(p){p.key==="Enter"&&ty(wf),p.key==="Escape"&&lc(!1)}}),v.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[v.jsx("button",{style:$n(!1),onClick:function(){lc(!1)},children:"Cancel"}),v.jsx("button",{style:$n(!0),onClick:function(){ty(wf)},children:"Save"})]})]})}),v.jsxs("div",{style:_e.topbar,children:[v.jsx("span",{style:{color:"#5a5a5a",fontSize:"0.62rem",letterSpacing:"0.5px",textTransform:"uppercase"},children:"Experiment"}),v.jsx(UP,{value:gO,roster:i,savedProjects:V,onChange:po,disabled:!ge&&!ht}),cy.length>1&&v.jsx("div",{"data-role":"studio-mode-strip",style:{display:"inline-flex",alignItems:"center",gap:"0",border:"1px solid #333",borderRadius:"4px",overflow:"hidden"},title:"Switch this walk-through between its declared modes (reloads the scene)",children:cy.map(function(p,_){var O=p.id===bO;return v.jsx("button",{"data-role":"studio-mode-segment","data-mode-id":p.id,"data-active":O?"true":"false",disabled:!ge&&!ht,onClick:function(){rO(p.id)},style:{padding:"3px 10px",cursor:"pointer",fontSize:"0.62rem",fontFamily:"ui-monospace,Menlo,Consolas,monospace",border:"none",borderLeft:_===0?"none":"1px solid #333",background:O?"#16323c":"#141414",color:O?"#7ec8e3":"#777"},children:p.label},p.id)})}),v.jsxs("span",{style:{color:"#5a5a5a",fontSize:"0.62rem",maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[L.name,L.dirty?" *":""]}),v.jsx("div",{style:{flex:"0 0 6px"}}),v.jsxs("span",{"data-role":"studio-scene-controls",style:{display:"inline-flex",alignItems:"center",gap:"6px",flexWrap:"nowrap"},children:[v.jsx("span",{style:{color:"#5a5a5a",fontSize:"0.62rem",letterSpacing:"0.5px",textTransform:"uppercase"},children:"Mode"}),v.jsx(dm,{style:mO(ie===sr?or:sr),disabled:!ge,labels:[yx,bx],onClick:tO,"data-selection-safe":!0,title:ie===sr?"Pause — freeze the field, edit objects (Design)":"Run the simulation",children:ie===sr?bx:yx}),v.jsx("button",{style:ay(),disabled:!ge&&!ht,onClick:nO,"data-selection-safe":!0,title:"Restart — save current design, reload from tick 0",children:"↻ Restart"}),Ft===!1&&v.jsx("span",{"data-role":"studio-record","data-phase":Pe.phase,style:{display:"inline-flex",alignItems:"center",gap:"4px"},children:v.jsx(dm,{"data-role":"studio-record-toggle","data-selection-safe":!0,labels:[xx,wx,_x((Xe||0)*1e3)],style:Object.assign(ay(),Pe.phase==="recording"?{background:"#2a1414",border:"1px solid #c84a4a",color:"#ff6a6a"}:{color:"#d88"},ny?{opacity:.45,cursor:"not-allowed"}:null),disabled:ny,"data-refusal":Pe.phase!=="recording"&&pa?pa.reason:void 0,onClick:sO,title:Pe.phase==="recording"?"Stop recording":pa?mM(pa):"Record the scene as a video (up to "+Xe+" s)",children:Pe.phase==="recording"?_x(Wt-Pe.startedMs):Pe.phase==="encoding"?wx:xx})})]}),Ft===!1&&Pe.phase==="ready"&&v.jsxs("span",{"data-role":"studio-record-result","data-name":Pe.file.name,"data-mime":Pe.file.type,"data-bytes":Pe.file.size,"data-frames":Pe.frames,"data-at-limit":Pe.atLimit?"true":"false","data-can-share":Pe.canShare?"true":"false",style:{display:"inline-flex",alignItems:"center",gap:"4px"},children:[Pe.atLimit&&v.jsx("span",{style:{color:"#c8c84a",fontSize:"0.6rem"},title:"The recording stopped itself at the "+Xe+" s limit",children:Xe+" s limit"}),Pe.canShare&&v.jsx("button",{"data-role":"studio-record-share","data-selection-safe":!0,style:$n(!0),onClick:aO,title:"Share the recording — save it to Photos or post it",children:"Share video"}),v.jsx("button",{"data-role":"studio-record-save","data-selection-safe":!0,style:$n(!Pe.canShare),onClick:lO,title:"Download "+Pe.file.name,children:"Save video"})]}),v.jsx("div",{style:{flex:"0 0 6px"}}),v.jsx("button",{style:{padding:"3px 9px",fontSize:"0.66rem",cursor:"pointer",borderRadius:"4px",border:"1px solid "+(fo?"#7ec8e3":"#333"),background:fo?"#16323c":"#1a1a1a",color:fo?"#7ec8e3":"#bbb"},"data-role":"studio-scene-code",onClick:function(){Lv(!0),_f(function(p){return!p})},title:"Show the scene's code — the file it was built from (Cmd/Ctrl+Enter runs it)",children:"</> Code"}),v.jsx("div",{style:{flex:"0 0 6px"}}),L.projectId?v.jsxs(v.Fragment,{children:[v.jsx("button",{style:$n(!0),disabled:!ge,onClick:iO,title:"Save — overwrite current project",children:"Save"}),v.jsx("button",{style:$n(!1),disabled:!ge,onClick:function(){If(L.name+" copy")},title:"Save As — create a new project",children:"Save As"})]}):v.jsx("button",{style:$n(!0),disabled:!ge,onClick:function(){If(L.name||"")},title:"Save As — name and save a new project",children:"Save As"}),v.jsx("button",{style:$n(!1),disabled:!ge,onClick:cO,title:"Export — download this project's folder as a .zip (its files + an index.html that boots it)",children:"Export"}),v.jsx("button",{style:$n(!1),onClick:function(){Ff.current&&Ff.current.click()},title:"Import — a project .zip (as Export writes it) or one sketch .js, saved and opened",children:"Import"}),v.jsx("input",{ref:Ff,type:"file",accept:".zip,application/zip,.js,text/javascript",style:{display:"none"},onChange:uO,"data-role":"bundle-import-input"}),v.jsx("div",{style:{flex:1}}),ge&&v.jsx("span",{style:{fontSize:"0.6rem",color:yO,letterSpacing:"0.5px"},children:vO})]}),F.length>0&&v.jsxs("div",{"data-role":"studio-retired-saves","data-count":F.length,style:{display:"flex",alignItems:"center",gap:"10px",padding:"4px 10px",background:"#2a2410",color:"#d8c070",fontSize:"0.66rem",borderBottom:"1px solid #3a3418",flexShrink:0},children:[v.jsx("span",{children:F.length+" save"+(F.length===1?"":"s")+" in the retired project format cannot be opened (the project folder replaced it)."}),v.jsx("button",{style:$n(!1),onClick:DE,"data-role":"studio-delete-retired",title:"Delete exactly these retired saves (asks first)",children:"Delete retired saves"})]}),v.jsxs("div",{style:_e.body,children:[v.jsxs("div",{style:Object.assign({},_e.col,_e.palette,Be?null:{width:20,minWidth:20,padding:"4px 2px"}),children:[v.jsx("div",{"data-selection-safe":!0,title:Be?"Hide panel":"Show Tools / Palette",onClick:function(){Ce(!Be)},style:{cursor:"pointer",textAlign:Be?"right":"center",color:"#6a7a8a",fontSize:"0.72rem",marginBottom:"4px",userSelect:"none"},children:Be?"◂":"▸"}),Be&&v.jsxs(Ze.Fragment,{children:[v.jsx("div",{style:_e.h,children:"Tools"}),v.jsxs("div",{style:_e.toolRow,children:[v.jsx("div",{style:Nf("hand"),...zf("hand","Hand"),"data-selection-safe":!0,title:"Hand — drag to move (click again for unobstructed view)",onClick:function(){pc("hand")},children:v.jsx($c,{kind:"hand"})}),v.jsx("div",{style:Nf("dropper"),...zf("dropper","Dropper"),"data-selection-safe":!0,title:"Dropper — click canvas to place (click again for unobstructed view)",onClick:function(){pc("dropper")},children:v.jsx($c,{kind:"dropper"})}),v.jsx("div",{style:Nf("pencil"),...zf("pencil","Pencil"),"data-selection-safe":!0,title:"Pencil — click object to edit (click again for unobstructed view)",onClick:function(){pc("pencil")},children:v.jsx($c,{kind:"pencil"})})]}),v.jsx("div",{style:_e.h,children:"Palette"}),hO(),v.jsx("div",{style:Object.assign({},_e.h,{marginTop:"10px"}),children:"Effects"}),v.jsxs("button",{style:_e.chip,onClick:function(){$v(!Mn.backdrop)},disabled:!ge,title:"Toggle pond backdrop",children:["□ Backdrop ",v.jsx("span",{style:_e.sub,children:"(pond)"})]}),v.jsxs("div",{style:_e.hint,children:[!pt&&`Unobstructed running view.
73
+ Pick a tool to edit.`,pt==="hand"&&`Drag bbox interior to move.
74
+ Drag edge/corner to scale.`,pt==="dropper"&&(R?`Click canvas to place:
75
+ `+R+".":`Pick a palette item,
76
+ then click the canvas.`),pt==="pencil"&&`Click an object to edit
77
+ all its fields.`]})]})]}),v.jsxs("div",{style:_e.center,children:[v.jsxs("div",{"data-role":"studio-canvas-region",style:_e.canvasRegion,children:[v.jsx("iframe",{ref:d,src:ke,style:_e.iframe,title:"frqtl-canvas"}),v.jsx("canvas",{ref:f,style:wO,"data-selection-safe":!0,title:jE===!1?"Canvas editing unavailable — the active renderer has no screenToWorld capability (the Layers panel still selects).":void 0}),v.jsx("div",{ref:x,"data-role":"studio-control-host","data-selection-safe":!0,style:xO}),Qe&&ge&&v.jsxs("div",{"data-role":"studio-phone-hand","data-selection-safe":!0,"aria-pressed":pt==="hand",role:"button",title:"Hand — touch an object to move it (tap again for unobstructed view)",onClick:function(){pc("hand")},style:Object.assign({position:"absolute",zIndex:3,width:"64px",height:"64px",borderRadius:"50%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"2px",cursor:"pointer",userSelect:"none",touchAction:"manipulation",font:"10px sans-serif",boxSizing:"border-box",border:"2px solid "+(pt==="hand"?"#7ec8e3":"rgba(126,200,227,0.35)"),background:pt==="hand"?"rgba(39,66,79,0.92)":"rgba(10,20,30,0.75)",color:pt==="hand"?"#7ec8e3":"rgba(126,200,227,0.85)"},N?{left:N.x+"px",top:N.y+"px",transform:"translate(-50%, -50%)"}:{left:"50%",bottom:"16px",transform:"translateX(-50%)"}),children:[v.jsx($c,{kind:"hand"}),v.jsx("span",{children:"HAND"})]}),Nt&&v.jsxs("div",{"data-role":"studio-camera-controls","data-selection-safe":!0,style:{position:"absolute",top:"6px",left:"8px",maxWidth:"calc(100% - "+(jv+24)+"px)",flexWrap:"wrap",background:"rgba(0,0,0,0.72)",color:"#7ec8e3",font:"11px ui-monospace,Menlo,Consolas,monospace",padding:"4px 8px",borderRadius:"4px",display:"flex",alignItems:"center",gap:"8px",zIndex:2,pointerEvents:"auto"},children:[v.jsx("span",{title:"Camera — driven via the experiment's sugar cameraControl handle (BYO renderer capability); the sliders are the axes the camera declares",children:"📷"}),CE.map(function(p){var _=YS(p);return _?v.jsxs(Ze.Fragment,{children:[v.jsx("span",{style:{color:"#557"},title:p.description,children:KS(p)}),v.jsx("input",{style:{width:"64px",cursor:"pointer",accentColor:"#7ec8e3"},type:"range",min:_.min,max:_.max,step:_.step,value:Math.round(Nt[p.name]),onChange:function(O){var A={};A[p.name]=Number(O.target.value),Pf(A)}})]},p.name):null}),ee&&v.jsx("span",{"data-role":"studio-camera-retained",style:{color:"#a88"},title:"A saved camera preset this camera does not offer — kept in the project, not applied",children:"preset "+ee+" — not offered by this camera"}),$r.map(function(p){var _=bt===p;return v.jsx("button",{style:{padding:"1px 6px",fontSize:"0.62rem",cursor:"pointer",borderRadius:"2px",border:"1px solid "+(_?"#7ec8e3":"#2a3a4a"),background:_?"#27424f":"#1a2a3a",color:_?"#7ec8e3":"#8af"},onClick:function(){Gv(p)},children:p},p)})]}),ge&&v.jsxs("div",{ref:Cv,"data-role":"studio-rate-panel",style:{position:"absolute",top:"6px",right:"8px",background:"rgba(0,0,0,0.72)",color:"#8ab4f8",font:"11px ui-monospace,Menlo,Consolas,monospace",padding:"4px 8px",borderRadius:"4px",pointerEvents:"auto",userSelect:"none",letterSpacing:"0.5px",zIndex:2,display:"flex",flexDirection:"column",gap:"4px"},children:[v.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center"},children:[v.jsxs("span",{title:"Frames per second: actual / limit (0 = display refresh)",children:["FPS ",v.jsx("span",{style:{color:I&&I.fps>0?"#8ab4f8":"#555"},children:I&&I.fps>0?I.fps:"—"}),v.jsx("span",{style:{color:"#4a5a6a"},children:"/"+(fe.fpsLimit>0?fe.fpsLimit:"∞")})]}),v.jsxs("span",{title:"Ticks per second: actual / limit",children:["TPS ",v.jsx("span",{style:{color:I&&I.tps>0?"#8ab4f8":"#555"},children:I&&I.tps>0?I.tps:"—"}),v.jsx("span",{style:{color:"#4a5a6a"},children:"/"+(fe.tpsLimit===1/0?"∞":fe.tpsLimit>0?fe.tpsLimit:"1:1")})]})]}),v.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[v.jsx("label",{style:{color:"#4a5a6a",fontSize:"10px"},children:"FPS cap"}),v.jsxs("select",{value:fe.fpsLimit>0?String(fe.fpsLimit):"0",style:{background:"#1a1a1a",color:"#8ab4f8",border:"1px solid #333",borderRadius:"2px",padding:"1px 3px",fontSize:"10px",fontFamily:"ui-monospace,Menlo,Consolas,monospace"},onChange:function(p){qv("fpsLimit",p.target.value)},children:[v.jsx("option",{value:"0",children:"display"}),v.jsx("option",{value:"60",children:"60"}),v.jsx("option",{value:"30",children:"30"}),v.jsx("option",{value:"24",children:"24"})]}),v.jsx("label",{style:{color:"#4a5a6a",fontSize:"10px"},children:"TPS cap"}),v.jsxs("select",{value:fe.tpsLimit===1/0?"Inf":fe.tpsLimit>0?String(fe.tpsLimit):"0",style:{background:"#1a1a1a",color:"#8ab4f8",border:"1px solid #333",borderRadius:"2px",padding:"1px 3px",fontSize:"10px",fontFamily:"ui-monospace,Menlo,Consolas,monospace"},onChange:function(p){qv("tpsLimit",p.target.value)},children:[v.jsx("option",{value:"0",children:"1:1 (lock)"}),v.jsx("option",{value:"60",children:"60"}),v.jsx("option",{value:"120",children:"120"}),v.jsx("option",{value:"240",children:"240"}),v.jsx("option",{value:"Inf",children:"unbounded"})]})]})]}),!ge&&!ht&&v.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"#555",pointerEvents:"none",zIndex:1},children:"booting canvas…"}),Qe&&v.jsx("div",{ref:C,"data-role":"studio-tryit-host",style:{position:"absolute",inset:0,zIndex:4,pointerEvents:"none"}}),(W||ht||ln)&&v.jsxs("div",{style:{position:"absolute",left:0,right:0,bottom:0,zIndex:3,display:"flex",flexDirection:"column"},children:[W&&v.jsx("div",{"data-studio-notice":!0,style:{background:"#0f1a12",color:"#9ad0a0",padding:"8px"},children:W}),(ht||ln)&&v.jsx("div",{"data-studio-error":!0,style:{background:"#1a0000",color:"#ff8080",padding:"8px"},children:[ht,ln].filter(Boolean).join(" — ")})]})]}),!Qe&&v.jsx("div",{ref:C,"data-role":"studio-tryit-host",style:{flex:"0 0 auto"}}),v.jsxs("div",{"data-role":"studio-scene-editor","data-open":fo?"1":"0",style:{position:"relative",flex:fo?"0 0 45%":"0 0 0px",visibility:fo?"visible":"hidden",background:"#1e1e1e",borderTop:fo?"1px solid #333":0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[kf&&Vn&&TE(Vn),kf&&Vn&&gs(Dr(Vn))&&v.jsx("pre",{"data-role":"studio-readonly-file",style:_e.readOnlyFile,children:Ea(Vn,Dr(Vn)).text}),kf&&Vn&&!gs(Dr(Vn))&&v.jsx(j.Suspense,{fallback:v.jsx("div",{style:{padding:"8px",color:"#886",font:"11px ui-monospace,Menlo,Consolas,monospace"},children:"Loading the editor…"}),children:v.jsx(PS,{fileName:Iv(),language:Dr(Vn)===Ge?"json":"javascript",source:Ea(Vn,Dr(Vn)).text,appliedSource:cf(Ea(Vn,Dr(Vn))),monacoBaseUrl:t,onRun:FE,onReset:NE,onClose:function(p){Pv(p),_f(!1)},onChange:Pv,error:ME},Iv())})]})]}),v.jsxs("div",{ref:h,"data-selection-safe":!0,style:Object.assign({},_e.col,_e.right,qe?null:{width:20,minWidth:20}),children:[v.jsx("div",{"data-selection-safe":!0,title:qe?"Hide panel":"Show Layers / Inspector",onClick:function(){nn(!qe)},style:{cursor:"pointer",textAlign:qe?"left":"center",color:"#6a7a8a",fontSize:"0.72rem",padding:"4px",userSelect:"none"},children:qe?"▸":"◂"}),qe&&v.jsxs(Ze.Fragment,{children:[v.jsxs("div",{style:_e.sect,children:[mc("Layers"),ma("Layers")&&v.jsxs(Ze.Fragment,{children:[ly("Particles",Mn.particles,KE,"#c586c0"),ly("Backdrop",Mn.backdrop,$v,"#6a8caa"),Xt.map(function(p,_){return v.jsxs("div",{"data-role":"studio-layer-row","data-name":p.name,style:Object.assign({},_e.row,Ut===p.ref?_e.sel:null),children:[v.jsx("input",{type:"checkbox",checked:p.visible,disabled:!GE(p.schemaKind),onChange:function(O){YE(p,O.target.checked)},style:{accentColor:"#d08a4a"}}),v.jsx("span",{style:{flex:1,cursor:"pointer"},onClick:function(){Et(p.ref),De.current=p.ref,k("pencil"),Vt(S.current.runner,S.current.backdrop,p.ref)},children:p.name}),v.jsx("span",{style:_e.sub,children:p.schemaKind})]},_)})]})]}),v.jsxs("div",{style:_e.sect,children:[mc("Page Controls"),ma("Page Controls")&&v.jsx(kM,{ready:ge,ctxRef:S,reloadKey:ke})]}),v.jsxs("div",{style:_e.sect,"data-role":"studio-render-controls",children:[mc("Render Controls"),ma("Render Controls")&&v.jsx(SM,{ready:ge,ctxRef:S,reloadKey:ke,retained:re,rendererName:mx(S.current.cw)})]}),v.jsxs("div",{style:_e.sect,children:[mc("Inspector"),ma("Inspector")&&v.jsx("div",{children:fO()},Ae+"_"+(Ut?Ut.name||"":"none"))]})]})]})]})]}),v.jsx("div",{ref:b,"data-role":"studio-scene-card-host",style:{position:"absolute",inset:0,zIndex:1e4,pointerEvents:"none"}})]}),v.jsx("div",{ref:y,"data-role":"studio-intro-host",style:{position:"absolute",inset:0,zIndex:1e4,pointerEvents:"none"}})]})}var OM="/editor/examples-manifest.json";function CM(e){if(!e)throw new Error("[math-sdk-utils] mathSdkUrl is required — ensure FraqtlIde threads the router profile mathSdkUrl (DEV_CORE_PROFILE.__mathSdkUrl or DIST_PROFILE.__mathSdkUrl) into the mathSdkUrl prop.");if(!e.endsWith("/index.js"))throw new Error('[math-sdk-utils] mathSdkUrl must end with /index.js — got: "'+e+'"');return e.slice(0,-9)}function jM(e,t){var n=new URL(e+"/editor/",window.location.href);return new URL(t,n).href}function RM(e){var t=e+OM;return fetch(t).then(function(n){if(!n.ok)throw new Error("[math-sdk-utils] examples-manifest.json fetch failed ("+n.status+"): "+t);return n.json()}).then(function(n){if(!n||!Array.isArray(n.examples))throw new Error("[math-sdk-utils] examples-manifest.json has unexpected shape (no .examples array): "+t);return n})}async function kx(e){const t=[],n={active:!0};function r(s){n.active&&t.push(String(s.text||""))}Ee.on("console:write",r);let i="unknown",o=null;try{try{i=st.active().id}catch{}o=await e()}finally{n.active=!1,Ee.off("console:write",r)}return{lines:t,backendId:i,ok:!(o&&o.ok===!1)}}function Sx(e,t){return new Promise(function(n,r){var i;try{i=jM(e,t.path)}catch(o){r(new Error('[BenchView] cannot resolve URL for "'+t.path+'": '+o.message));return}fetch(i).then(function(o){if(!o.ok)throw new Error("[BenchView] source fetch failed ("+o.status+"): "+i);return o.text()}).then(function(o){function s(a){Ee.off("run:result",s),n(a)}Ee.on("run:result",s),Ee.emit("run:request",{source:"math",code:o,fileId:t.id+".js",sourceUrl:i})}).catch(function(o){r(o)})})}function Ex(e,t){var n=!1,r=e.map(function(i){var o=i;return t.forEach(function(s){s&&o.indexOf(s)!==-1&&(n=!0,o=o.split(s).join("«backend»"))}),o});return{lines:r,normalized:n}}function Ox(e){var t=!1,n=e.map(function(r){if(r.indexOf("TIMING:")===0)return t=!0,"«timing-excluded»";var i=r.replace(/elapsed_ms\s*=\s*\d+/g,function(){return t=!0,"elapsed_ms = «ms»"});return i=i.replace(/"elapsed_ms"\s*:\s*\d+/g,function(){return t=!0,'"elapsed_ms": «ms»'}),i=i.replace(/\b(\d+)ms\b/g,function(){return t=!0,"«ms»ms"}),i});return{lines:n,normalized:t}}function LM(e,t){for(var n=Math.max(e.length,t.length),r=0;r<n;r++){var i=e[r]!==void 0?e[r]:"<missing>",o=t[r]!==void 0?t[r]:"<missing>";if(i!==o)return{match:!1,firstDiffLine:r,jsLine:i,wasmLine:o}}return{match:!0}}function AM({mathSdkUrl:e,mathWasmUrl:t,mathWasmModuleUrl:n,mathBackend:r,deepLinkRefusal:i}){const[o,s]=j.useState(null),[a,l]=j.useState(null),[c,u]=j.useState({}),[d,f]=j.useState(null),[h,g]=j.useState(!1),[m,x]=j.useState(null),y=j.useRef(null);j.useEffect(function(){if(!e){l("[BenchView] mathSdkUrl not provided — cannot load catalog");return}var W;try{W=CM(e)}catch(Y){l(Y.message);return}y.current=W,RM(W).then(function(Y){s(Y);var re={};Y&&Array.isArray(Y.examples)&&Y.examples.forEach(function(pe){re[pe.id]=!0}),u(re)}).catch(function(Y){l(Y.message)})},[]),j.useSyncExternalStore(j.useCallback(function(W){return st.subscribe(W)},[]),j.useCallback(function(){let W="none";try{W=st.active().id}catch{}return st.registeredIds().join("|")+"@"+W},[]),j.useCallback(function(){let W="none";try{W=st.active().id}catch{}return st.registeredIds().join("|")+"@"+W},[]));const w=st.registeredIds().includes("wasm-math"),E=function(){try{return st.active().id}catch{return"none"}}(),C=j.useCallback(async function(){if(!y.current){x("SDK base not initialized — wait for catalog load");return}if(!o||!Array.isArray(o.examples)){x("Catalog not loaded");return}g(!0),x(null),f(null);try{await ui.ensureMath({mathSdkUrl:e,mathWasmUrl:t,mathWasmModuleUrl:n,mathBackend:r})}catch(pe){x("Math SDK unavailable: "+String(pe)),g(!1);return}if(!st.registeredIds().includes("wasm-math")){x("wasm-math provider not registered: no math WASM bridge URL reached the SDK (engineRouter __mathWasmUrl / __mathWasmModuleUrl). This bench requires both providers."),g(!1);return}const W=o.examples.filter(function(pe){return c[pe.id]});if(W.length===0){x("No entries selected"),g(!1);return}const Y=function(){try{return st.active().id}catch{return"js-reference"}}(),re=[];try{for(const pe of W){st.select("js-reference");let B;try{B=await kx(function(){return Sx(y.current,pe)})}catch(tn){B={lines:["[FETCH ERROR] "+String(tn)],backendId:"js-reference",ok:!1}}st.select("wasm-math");let ee;try{ee=await kx(function(){return Sx(y.current,pe)})}catch(tn){ee={lines:["[FETCH ERROR] "+String(tn)],backendId:"wasm-math",ok:!1}}const ce=B.backendId!==ee.backendId,ve=!ce&&B.backendId==="js-reference"&&ee.backendId==="js-reference",ke=st.registeredIds(),je=Ex(B.lines,ke),ie=Ex(ee.lines,ke),me=je.normalized||ie.normalized,xe=Ox(je.lines),ge=Ox(ie.lines),kt=xe.normalized||ge.normalized,ut=B.ok===!1&&ee.ok===!1,_n=ce?LM(xe.lines,ge.lines):{match:!1,firstDiffLine:-1,jsLine:"STAMP SAME: "+B.backendId,wasmLine:ee.backendId};re.push({entry:pe,jsLines:B.lines,wasmLines:ee.lines,jsBackendId:B.backendId,wasmBackendId:ee.backendId,stampsDiffer:ce,coveragePartial:ve,stampsNormalized:me,timingNormalized:kt,bothFailed:ut,cmp:_n})}}finally{try{st.select(Y)}catch{}g(!1)}f(re)},[o,c,e,t,n,r]);function S(W){u(function(Y){var re=Object.assign({},Y);return re[W]=!Y[W],re})}function M(){if(o){var W={};o.examples.forEach(function(Y){W[Y.id]=!0}),u(W)}}function L(){u({})}const T={root:{display:"flex",flexDirection:"row",height:"100%",overflow:"hidden",background:"#111",fontFamily:"ui-monospace,Menlo,Consolas,monospace",fontSize:"0.75rem",color:"#ccc"},sidebar:{width:"220px",flexShrink:0,borderRight:"1px solid #222",display:"flex",flexDirection:"column",overflowY:"auto"},sideTop:{padding:"8px",borderBottom:"1px solid #1a1a1a",flexShrink:0},sideTitle:{font:"700 10px ui-monospace,Menlo,Consolas,monospace",color:"#555",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"6px"},selBtn:{padding:"2px 6px",font:"9px ui-monospace,Menlo,Consolas,monospace",background:"#1a1a1a",border:"1px solid #2a2a2a",color:"#666",borderRadius:"2px",cursor:"pointer",marginRight:"4px"},entryList:{flex:1,overflowY:"auto"},entryItem:{display:"flex",alignItems:"center",padding:"3px 8px",borderBottom:"1px solid #1a1a1a",cursor:"pointer",userSelect:"none"},entryChk:{marginRight:"6px",flexShrink:0},entryLbl:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#777"},main:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},header:{padding:"8px 12px",borderBottom:"1px solid #222",flexShrink:0},title:{fontSize:"0.85rem",fontWeight:700,color:"#eee",marginBottom:"4px"},subtitle:{color:"#555",marginBottom:"8px",fontSize:"0.7rem"},badge:{display:"inline-block",padding:"2px 6px",borderRadius:"3px",fontSize:"0.65rem",background:"#1a2a3a",color:"#4af",marginRight:"6px"},badgeOff:{background:"#2a1a1a",color:"#a44"},runBtn:{padding:"4px 12px",background:"#1a2a3a",color:"#8af",border:"1px solid #2a3a4a",borderRadius:"3px",cursor:"pointer",fontSize:"0.75rem",marginTop:"8px"},results:{flex:1,overflowY:"auto"},table:{width:"100%",borderCollapse:"collapse"},th:{textAlign:"left",padding:"4px 8px",color:"#555",borderBottom:"1px solid #222",fontSize:"0.65rem",position:"sticky",top:0,background:"#111"},td:{padding:"4px 8px",borderBottom:"1px solid #1a1a1a",verticalAlign:"top",fontSize:"0.7rem"},match:{color:"#4a8",fontWeight:600},partial:{color:"#aa6",fontWeight:600},diverge:{color:"#a44",fontWeight:600},stampBad:{color:"#f84",fontWeight:600},diffLine:{color:"#f84",fontStyle:"italic",fontSize:"0.65rem"},errBanner:{background:"#2a1111",color:"#cc4444",padding:"6px 12px",borderBottom:"1px solid #3a1111",fontSize:"0.7rem",flexShrink:0}};var V=[];if(o&&Array.isArray(o.examples)){var G={},F=[];o.examples.forEach(function(W){var Y=W.group||"Other";G[Y]||(G[Y]=[],F.push(Y)),G[Y].push(W)}),V=F.map(function(W){return{name:W,entries:G[W]}})}const te=Object.values(c).filter(Boolean).length;return v.jsxs("div",{style:T.root,children:[v.jsxs("div",{style:T.sidebar,children:[v.jsxs("div",{style:T.sideTop,children:[v.jsx("div",{style:T.sideTitle,children:"Catalog"}),i&&v.jsx("div",{"data-role":"bench-deep-link-error",style:{color:"#a44",fontSize:"0.65rem",marginBottom:"4px"},children:i}),a&&v.jsx("div",{style:{color:"#a44",fontSize:"0.65rem",marginBottom:"4px"},children:a}),!o&&!a&&v.jsx("div",{style:{color:"#444",fontSize:"0.65rem"},children:"loading…"}),v.jsxs("div",{children:[v.jsx("button",{style:T.selBtn,onClick:M,children:"All"}),v.jsx("button",{style:T.selBtn,onClick:L,children:"None"})]})]}),v.jsx("div",{style:T.entryList,children:V.map(function(W){return v.jsxs("div",{children:[v.jsx("div",{style:{font:"9px ui-monospace",color:"#444",padding:"4px 8px 2px",textTransform:"uppercase",letterSpacing:"0.3px"},children:W.name}),W.entries.map(function(Y){return v.jsxs("div",{style:T.entryItem,onClick:function(){S(Y.id)},children:[v.jsx("input",{type:"checkbox",style:T.entryChk,checked:!!c[Y.id],onChange:function(){S(Y.id)},onClick:function(re){re.stopPropagation()}}),v.jsx("span",{style:T.entryLbl,title:Y.id,children:Y.title||Y.id})]},Y.id)})]},W.name)})})]}),v.jsxs("div",{style:T.main,children:[v.jsxs("div",{style:T.header,children:[v.jsx("div",{style:T.title,children:"Math Twin-Engines Bench"}),v.jsx("div",{style:T.subtitle,children:"Runs catalog entries under js-reference then wasm-math via the canonical runtime lane. Comparator = exact Bus console:write output equality. coverage:partial = both legs ran js-reference (pre-M5 op routing)."}),v.jsxs("div",{children:[v.jsxs("span",{style:Object.assign({},T.badge,{background:"#1a3a1a",color:"#4a8"}),children:["js-reference",E==="js-reference"?" (active)":""]}),v.jsxs("span",{style:Object.assign({},T.badge,w?{}:T.badgeOff),children:["wasm-math",w?E==="wasm-math"?" (active)":" (registered)":" (not loaded)"]}),!w&&v.jsx("span",{style:{color:"#555",marginLeft:"6px",fontSize:"0.65rem"},children:"— run Math SDK first or use ?mathBackend=wasm"})]}),v.jsx("div",{children:v.jsx("button",{style:T.runBtn,onClick:C,disabled:h||!o||te===0,children:h?"Running…":"Run "+(te>0?te+" selected":"(select entries)")})})]}),m&&v.jsxs("div",{style:T.errBanner,children:["BENCH ERROR: ",m]}),v.jsxs("div",{style:T.results,children:[d&&v.jsxs("table",{style:T.table,children:[v.jsx("thead",{children:v.jsxs("tr",{children:[v.jsx("th",{style:T.th,children:"Entry"}),v.jsx("th",{style:T.th,children:"JS stamp"}),v.jsx("th",{style:T.th,children:"WASM stamp"}),v.jsx("th",{style:T.th,children:"Result"})]})}),v.jsx("tbody",{children:d.map(function(W,Y){var re=W.stampsNormalized||W.timingNormalized?v.jsxs("span",{style:{color:"#667",fontStyle:"italic",fontSize:"0.6rem"},children:[" ","—",W.stampsNormalized?" backend-stamps normalized":"",W.timingNormalized?" timing normalized":""]}):null,pe;return W.stampsDiffer?W.cmp.match&&W.bothFailed?pe=v.jsxs("span",{children:[v.jsx("span",{style:T.partial,children:"MATCH (both legs failed)"}),re]}):W.cmp.match?pe=v.jsxs("span",{children:[v.jsx("span",{style:T.match,children:"MATCH"}),re]}):pe=v.jsxs("span",{children:[v.jsx("span",{style:T.diverge,children:"DIVERGENCE"}),re,v.jsx("br",{}),v.jsxs("span",{style:T.diffLine,children:["line ",W.cmp.firstDiffLine,': js="',W.cmp.jsLine,'"']}),v.jsx("br",{}),v.jsxs("span",{style:T.diffLine,children:["line ",W.cmp.firstDiffLine,': wasm="',W.cmp.wasmLine,'"']})]}):pe=v.jsx("span",{style:W.coveragePartial?T.partial:T.stampBad,children:W.coveragePartial?"coverage:partial (both js-reference, pre-M5)":"STAMP SAME: "+W.jsBackendId+" — wasm-math select had no effect"}),v.jsxs("tr",{children:[v.jsx("td",{style:T.td,title:W.entry.id,children:W.entry.title||W.entry.id}),v.jsx("td",{style:Object.assign({},T.td,{color:"#4a8",fontSize:"0.65rem"}),children:W.jsBackendId}),v.jsx("td",{style:Object.assign({},T.td,{color:"#4af",fontSize:"0.65rem"}),children:W.wasmBackendId}),v.jsx("td",{style:T.td,children:pe})]},Y)})})]}),d&&d.length>0&&function(){var W=d.filter(function(B){return B.cmp.match&&B.stampsDiffer&&!B.bothFailed}).length,Y=d.filter(function(B){return B.cmp.match&&B.stampsDiffer&&B.bothFailed}).length,re=d.filter(function(B){return B.coveragePartial}).length,pe=d.filter(function(B){return!B.cmp.match&&B.stampsDiffer&&!B.coveragePartial}).length;return v.jsxs("div",{style:{padding:"8px 12px",fontSize:"0.7rem"},children:[W>0&&v.jsxs("span",{style:T.match,children:[W," MATCH "]}),Y>0&&v.jsxs("span",{style:T.partial,children:[Y," MATCH (both legs failed) "]}),re>0&&v.jsxs("span",{style:T.partial,children:[re," partial "]}),pe>0&&v.jsxs("span",{style:T.diverge,children:[pe," DIVERGENCE — wasm bugs to fix, not tolerances to add"]})]})}()]})]})]})}var Nl="codec-chains",Mh=Object.freeze(["name","source"]);function Ws(e){throw new Error("[codec-chains] "+e+" (FAIL-LOUD.)")}function rv(e){(!e||typeof e!="object"||Array.isArray(e))&&Ws("a codec chain row is { "+Mh.join(", ")+" } (got "+(e===null?"null":typeof e)+").");var t=Object.keys(e).filter(function(n){return Mh.indexOf(n)===-1});return t.length&&Ws("unknown key "+t.map(function(n){return JSON.stringify(n)}).join(", ")+" — a codec chain row holds exactly CODEC_CHAIN_KEYS: "+Mh.join(", ")+"."),ca(e.name,"a codec chain name"),(typeof e.source!="string"||e.source.length===0)&&Ws(`"source" is the chain's module text, a non-empty string.`),Object.freeze({name:e.name,source:e.source})}function PM(e,t){var n=rv(t);return e.put(Nl,n.name,{name:n.name,source:n.source}),n.name}function MM(e,t,n){ca(n,"a codec chain name");var r=rv(Object.assign({},t,{name:n}));return e.get(Nl,n)!==null&&Ws('a codec chain named "'+n+'" is already saved — Save As takes a name no saved chain has.'),e.put(Nl,r.name,{name:r.name,source:r.source}),r.name}function i1(e,t){ca(t,"a codec chain name");var n=e.get(Nl,t);if(n==null)return null;var r;try{r=rv(n)}catch(i){Ws('the saved chain "'+t+'" is not a codec chain row: '+(i&&i.message||i))}return r.name!==t&&Ws('the saved chain under "'+t+'" names itself "'+r.name+'".'),r}function TM(e){return e.list(Nl).map(function(t){return t.key}).sort().map(function(t){return{name:t}})}const DM={};var IM="../../assets/vendor/monaco/vs",Kc=null,ic=!1;function FM(e){return ic?Promise.resolve(!0):Kc||(Kc=new Promise(function(t,n){var r=e+"/loader.js";if(typeof require=="function"&&typeof require.config=="function"){Cx(e,t,n);return}var i=document.createElement("script");i.src=r,i.onload=function(){Cx(e,t,n)},i.onerror=function(){var o="[CodeEditorPane] Failed to load Monaco loader from: "+r;console.error(o),n(new Error(o))},document.head.appendChild(i)}),Kc)}function Cx(e,t,n){try{require.config({paths:{vs:e}}),require(["vs/editor/editor.main"],function(){if(typeof monaco>"u"||!monaco.editor){n(new Error("[CodeEditorPane] monaco.editor not available after require"));return}ic=!0,t(!0)})}catch(r){n(r)}}var jx=!1;function NM(e){if(!jx&&(jx=!0,!(import.meta&&DM))){var t=zM(),n=document.createElement("link");n.rel="stylesheet",n.href=t,document.head.appendChild(n)}}function zM(){for(var e=document.querySelectorAll("script[src]"),t=0;t<e.length;t++){var n=e[t].getAttribute("src");if(n&&n.indexOf("code-editor")!==-1&&n.indexOf("index.js")!==-1)return n.replace("index.js","code-editor.css")}return"/lib/components/code-editor/code-editor.css"}function BM(e){if(typeof e=="number")return e===1||e===2||e===4||e===8?e:e<=1?1:e<=2?4:8;if(typeof e=="string"){var t=e.toLowerCase();if(t==="error")return 8;if(t==="warning"||t==="warn")return 4;if(t==="info")return 2;if(t==="hint")return 1}return 8}var UM='<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><polygon points="5 3 19 12 5 21 5 3"/></svg>';function At(e){e=e||{},this._mountEl=e.mountEl||null,this._monacoBaseUrl=e.monacoBaseUrl||IM,this._emitBusRun=e.emitBusRun!==!1,this._showRun=e.showRun!==!1,this._fileMap=Object.create(null),this._activeId=null,this._runCb=null,this._runAdvanceCb=null,this._runAdvanceChordsRegistered=!1,this._editor=null,this._resizeObserver=null,this._pendingMarkers=[],NM(this._monacoBaseUrl),this._buildDom();var t=this;FM(this._monacoBaseUrl).then(function(){t._onMonacoReady()}).catch(function(n){t._showError("Monaco failed to load: "+(n&&n.message?n.message:String(n)))})}At.prototype._buildDom=function(){var e=this._mountEl;if(e){var t=document.createElement("div");t.className="cep-root",e.appendChild(t),this._rootEl=t;var n=document.createElement("div");n.className="cep-toolbar",t.appendChild(n),this._toolbarEl=n;var r=document.createElement("div");r.className="cep-tabs",n.appendChild(r),this._tabsEl=r;var i=this;if(this._showRun){var o=document.createElement("div");o.className="cep-run-area",n.appendChild(o);var s=document.createElement("span");s.className="cep-run-hint",s.textContent=navigator.platform&&navigator.platform.indexOf("Mac")!==-1?"⌘↩":"Ctrl+↩",o.appendChild(s);var a=document.createElement("button");a.className="cep-run-btn",a.type="button",a.innerHTML=UM+" Run",a.title="Run current file (Cmd/Ctrl+Enter)",a.disabled=!0,a.addEventListener("click",function(){i._triggerRun()}),o.appendChild(a),this._runBtnEl=a}var l=document.createElement("div");l.className="cep-editor-host",t.appendChild(l),this._hostEl=l;var c=document.createElement("div");c.className="cep-loading",c.innerHTML='<div class="cep-loading-spinner"></div><span>Loading Monaco editor…</span>',l.appendChild(c),this._loadingEl=c;var u=document.createElement("div");u.className="cep-empty hidden",u.textContent="No file open — call openFile() to begin.",l.appendChild(u),this._emptyEl=u}};At.prototype._onMonacoReady=function(){if(this._hostEl){this._loadingEl.classList.add("hidden");var e=this;if(this._editor=monaco.editor.create(this._hostEl,{model:null,theme:"vs-dark",language:"javascript",minimap:{enabled:!1},automaticLayout:!1,fontSize:13,lineHeight:20,scrollBeyondLastLine:!1,tabSize:4,renderWhitespace:"selection",wordWrap:"off",folding:!0,glyphMargin:!0,renderValidationDecorations:"on"}),this._editor.addCommand(monaco.KeyMod.CtrlCmd|monaco.KeyCode.Enter,function(){e._triggerRun()}),this._runAdvanceCb&&this._registerRunAdvanceChords(),this._editor.onDidChangeModelContent(function(){var a=e._activeId;if(!(!a||!e._fileMap[a])){var l=e._fileMap[a],c=e._editor.getValue();l.dirty=c!==l._initialValue,e._refreshTabs()}}),this._contentChangeCbs&&this._contentChangeCbs.length){for(var t=0;t<this._contentChangeCbs.length;t++)this._editor.onDidChangeModelContent(this._contentChangeCbs[t]);this._contentChangeCbs=[]}for(var n=Object.keys(this._fileMap),r=0;r<n.length;r++){var i=this._fileMap[n[r]];i.model||(i.model=monaco.editor.createModel(i._pendValue!==void 0?i._pendValue:"",i.language),delete i._pendValue)}for(var o=0;o<this._pendingMarkers.length;o++){var s=this._pendingMarkers[o];this._applyMarkers(s.fileId,s.markers)}this._pendingMarkers=[],this._activeId&&this._fileMap[this._activeId]?(this._editor.setModel(this._fileMap[this._activeId].model),this._runBtnEl&&(this._runBtnEl.disabled=!1),this._emptyEl.classList.add("hidden")):this._emptyEl.classList.remove("hidden"),this._editor.layout(),this._installResizeObserver(),console.log("[CodeEditorPane] Monaco ready, base:",this._monacoBaseUrl)}};At.prototype._installResizeObserver=function(){if(!(this._resizeObserver||typeof ResizeObserver>"u"||!this._hostEl)){var e=this;this._resizeObserver=new ResizeObserver(function(){e._editor&&e._editor.layout()}),this._resizeObserver.observe(this._hostEl)}};At.prototype._showError=function(e){console.error("[CodeEditorPane]",e),this._loadingEl&&(this._loadingEl.innerHTML='<span style="color:#f44336;padding:8px;">'+HM(e)+"</span>")};At.prototype._refreshTabs=function(){if(this._tabsEl){var e=this;this._tabsEl.innerHTML="";for(var t=Object.keys(this._fileMap),n=0;n<t.length;n++)(function(r){var i=e._fileMap[r],o=document.createElement("div");o.className="cep-tab"+(r===e._activeId?" active":""),o.title=r;var s=document.createElement("span");s.className="cep-tab-kind cep-tab-kind-"+i.kind,s.textContent=i.kind==="frqtl"?"F":"M",o.appendChild(s);var a=document.createElement("span");if(a.textContent=r,o.appendChild(a),i.dirty){var l=document.createElement("span");l.className="cep-tab-dirty",l.title="Unsaved changes",o.appendChild(l)}o.addEventListener("click",function(){e._activateFile(r)}),e._tabsEl.appendChild(o)})(t[n])}};At.prototype._activateFile=function(e){this._fileMap[e]&&(this._activeId=e,this._editor&&(this._editor.setModel(this._fileMap[e].model),this._runBtnEl&&(this._runBtnEl.disabled=!1),this._emptyEl.classList.add("hidden")),this._refreshTabs())};At.prototype._applyMarkers=function(e,t){if(!(!ic||!this._fileMap[e])){var n=this._fileMap[e].model;if(n){var r=(t||[]).map(function(i){return{startLineNumber:i.startLineNumber||1,startColumn:i.startColumn||1,endLineNumber:i.endLineNumber||i.startLineNumber||1,endColumn:i.endColumn||i.startColumn||1,message:i.message||"",severity:BM(i.severity)}});monaco.editor.setModelMarkers(n,"cep-owner",r)}}};At.prototype.openFile=function(e){if(!e||!e.id)throw new Error("[CodeEditorPane] openFile: id is required");var t=e.id,n=e.language||"javascript",r=e.kind||"frqtl",i=e.value!==void 0?e.value:"";if(this._fileMap[t]){this._activateFile(t);return}var o={id:t,language:n,kind:r,model:null,dirty:!1,_initialValue:i,_pendValue:i};ic&&(o.model=monaco.editor.createModel(i,n),delete o._pendValue),this._fileMap[t]=o,this._activateFile(t),this._refreshTabs()};At.prototype.setFileValue=function(e,t){var n=this._fileMap[e];return n?(n.model?n.model.getValue()!==t&&n.model.setValue(t):(n._pendValue=t,n._initialValue=t),!0):!1};At.prototype.setBaseline=function(e,t){var n=this._fileMap[e];if(!n)return!1;if(typeof t!="string")throw new Error("[CodeEditorPane] setBaseline("+e+"): value must be a string. (FAIL-LOUD.)");n._initialValue=t;var r=n.model?n.model.getValue():n._pendValue,i=r!==t;return i!==n.dirty&&(n.dirty=i,this._refreshTabs()),!0};At.prototype.activeFile=function(){var e=this._activeId;if(!e||!this._fileMap[e])return null;var t=this._fileMap[e],n;return this._editor&&t.model?n=this._editor.getValue():n=t._pendValue!==void 0?t._pendValue:"",{id:e,value:n,kind:t.kind}};At.prototype.files=function(){return Object.keys(this._fileMap).map(function(e){var t=this._fileMap[e];return{id:t.id,kind:t.kind,dirty:t.dirty}},this)};At.prototype.onRun=function(e){this._runCb=typeof e=="function"?e:null};At.prototype.onRunAdvance=function(e){this._runAdvanceCb=typeof e=="function"?e:null,this._runAdvanceCb&&this._editor&&this._registerRunAdvanceChords()};At.prototype._registerRunAdvanceChords=function(){if(!(this._runAdvanceChordsRegistered||!this._editor)){var e=this,t=window.monaco;t&&(this._editor.addCommand(t.KeyMod.Shift|t.KeyCode.Enter,function(){e._triggerRunAdvance("advance")}),this._editor.addCommand(t.KeyMod.Alt|t.KeyCode.Enter,function(){e._triggerRunAdvance("insert")}),this._runAdvanceChordsRegistered=!0)}};At.prototype._triggerRunAdvance=function(e){var t=this.activeFile();if(t){if(typeof this._runAdvanceCb=="function"){try{this._runAdvanceCb(t,e)}catch(n){console.error("[CodeEditorPane] onRunAdvance callback threw:",n)}return}this._triggerRun()}};At.prototype._triggerRun=function(){var e=this.activeFile();if(e){if(typeof this._runCb=="function")try{this._runCb(e)}catch(t){console.error("[CodeEditorPane] onRun callback threw:",t)}this._emitBusRun&&Ee&&typeof Ee.emit=="function"&&Ee.emit("run:request",{source:e.kind,code:e.value,fileId:e.id})}};At.prototype.setMarkers=function(e,t){if(e){if(!ic){this._pendingMarkers.push({fileId:e,markers:t||[]});return}this._applyMarkers(e,t)}};At.prototype.layout=function(){this._editor&&this._editor.layout()};At.prototype.dispose=function(){if(this._resizeObserver){try{this._resizeObserver.disconnect()}catch{}this._resizeObserver=null}for(var e=Object.keys(this._fileMap),t=0;t<e.length;t++){var n=this._fileMap[e[t]];if(n&&n.model&&typeof n.model.dispose=="function")try{n.model.dispose()}catch{}}if(this._fileMap=Object.create(null),this._editor&&typeof this._editor.dispose=="function")try{this._editor.dispose()}catch{}this._editor=null};At.prototype.onContentChange=function(e){typeof e=="function"&&(this._editor?this._editor.onDidChangeModelContent(e):(this._contentChangeCbs||(this._contentChangeCbs=[]),this._contentChangeCbs.push(e)))};function HM(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}typeof window<"u"&&(window.CodeEditorPane=At);var zl=220,_d=96,WM=64;function VM(e,t){return t?t.ok?"verified":"failed":(e&&e.invertible===!0,"pending")}function qM(e,t,n){if(!e||!t)return{nodes:[],edges:[]};n=n||{};var r=e.snapshots||[],i=e.trace?e.trace.entries||[]:[],o=t.steps||[],s=n.roundTrips||[],a=r.map(function(c,u){var d=c&&c.constructor&&c.constructor.kind?c.constructor.kind:"?",f=u===0?"input":u===r.length-1?"output":"intermediate";return{id:"card-"+u,type:"card",position:{x:u*(zl+WM),y:0},data:{index:u,kind:d,encoding:c,describe:c&&typeof c.describe=="function"?c.describe():null,role:f},width:zl,height:_d}}),l=o.map(function(c,u){var d=c.constructor,f=i[u]||{};return{id:"edge-"+u,source:"card-"+u,target:"card-"+(u+1),type:"connector",data:{transformName:d.name,transformUiLabel:d.uiLabel||d.name,transformLetterCode:d.letterCode||"?",provenance:d.provenance||{tier:"structural",claim:"",leanCitation:""},opCount:f.opCount||0,elapsedMs:f.elapsedMs||0,bijection:VM(d,s[u]),inputKind:d.inputKind,outputKind:d.outputKind}}});return{nodes:a,edges:l}}function $M(e){if(!e.length)return{x:0,y:0,width:zl,height:_d};for(var t=1/0,n=1/0,r=-1/0,i=-1/0,o=0;o<e.length;o++){var s=e[o],a=s.width||zl,l=s.height||_d;s.position.x<t&&(t=s.position.x),s.position.y<n&&(n=s.position.y),s.position.x+a>r&&(r=s.position.x+a),s.position.y+l>i&&(i=s.position.y+l)}return{x:t,y:n,width:r-t,height:i-n}}var o1=Object.freeze({width:zl,height:_d}),ju=o1.width,gm=o1.height,KM={input:"#3a8a3a",output:"#3a5a8a",intermediate:"#4a3a5a"},YM={"lean-backed":"#7ec8e3",structural:"#a0a070",classical:"#888"},GM={verified:"#3a8a3a",pending:"#888",failed:"#cc4444"};function JM(e){return KM[e]||"#4a4a4a"}function XM(e){return YM[e]||"#888"}function QM(e){return GM[e]||"#888"}function ZM(e){var t=e.node,n=t.data||{},r=JM(n.role),i=n.describe?String(n.describe).slice(0,80):"";return Ze.createElement("div",{key:t.id,style:{position:"absolute",left:t.position.x+"px",top:t.position.y+"px",width:ju+"px",height:gm+"px",boxSizing:"border-box",border:"1px solid "+r,borderRadius:"4px",background:"#1a1a1a",padding:"6px 8px",cursor:e.onSelect?"pointer":"default",userSelect:"none"},onClick:e.onSelect?function(){e.onSelect(t.id)}:void 0},[Ze.createElement("div",{key:"kind",style:{font:"700 11px ui-monospace,Menlo,Consolas,monospace",color:"#ccc",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},n.kind||"?"),i?Ze.createElement("div",{key:"desc",style:{font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#666",marginTop:"3px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},i):null,Ze.createElement("div",{key:"role",style:{position:"absolute",right:"6px",bottom:"5px",font:"9px ui-monospace,Menlo,Consolas,monospace",color:r,textTransform:"uppercase",letterSpacing:"0.5px"}},n.role||"")])}function eT(e){var t=e.x,n=e.y,r=e.data||{},i=QM(r.bijection),o=XM(r.provenance&&r.provenance.tier);return Ze.createElement("div",{style:{position:"absolute",left:t-56+"px",top:n-22+"px",width:"112px",textAlign:"center",pointerEvents:"none",userSelect:"none"}},[Ze.createElement("div",{key:"lbl",style:{font:"700 9px ui-monospace,Menlo,Consolas,monospace",color:"#aaa",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:"1.2"}},(r.transformLetterCode||"?")+" "+(r.transformUiLabel||"")),Ze.createElement("div",{key:"chips",style:{display:"flex",justifyContent:"center",gap:"3px",marginTop:"2px"}},[Ze.createElement("span",{key:"bij",style:{font:"8px ui-monospace,Menlo,Consolas,monospace",color:i,border:"1px solid "+i,borderRadius:"2px",padding:"0 3px",lineHeight:"1.4"}},r.bijection||"pending"),r.provenance&&r.provenance.tier?Ze.createElement("span",{key:"tier",style:{font:"8px ui-monospace,Menlo,Consolas,monospace",color:o,border:"1px solid "+o,borderRadius:"2px",padding:"0 3px",lineHeight:"1.4"}},r.provenance.tier):null])])}function tT(e){var t=e.nodes||[],n=e.edges||[],r=e.onSelect||null;if(!t.length)return Ze.createElement("div",{style:{flex:"1",display:"flex",alignItems:"center",justifyContent:"center",color:"#444",font:"11px ui-monospace,Menlo,Consolas,monospace"}},"No chain to display.");for(var i=$M(t),o=80,s=60+gm,a=i.width+2*o,l=i.height+2*s,c=o-i.x,u=s-i.y,d={},f=0;f<t.length;f++){var h=t[f];d[h.id]={x:h.position.x+c+ju/2,y:h.position.y+u+gm/2}}for(var g=[],m=[],x=0;x<n.length;x++){var y=n[x],b=d[y.source],w=d[y.target];if(!(!b||!w)){var E=b.x+ju/2,C=b.y,S=w.x-ju/2,M=w.y,L=(E+S)/2,T="M "+E+" "+C+" C "+L+" "+C+", "+L+" "+M+", "+S+" "+M,V=y.data&&y.data.bijection==="failed"?"#cc4444":"#3a3a5a";g.push(Ze.createElement("path",{key:"p-"+y.id,d:T,stroke:V,strokeWidth:1.5,fill:"none"})),m.push({x:L,y:(C+M)/2,data:y.data})}}var G=t.map(function(F){return Object.assign({},F,{position:{x:F.position.x+c,y:F.position.y+u}})});return Ze.createElement("div",{style:{flex:"1",overflow:"auto",position:"relative",minHeight:"0"}},Ze.createElement("svg",{width:a,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},xmlns:"http://www.w3.org/2000/svg"},g),G.map(function(F){return Ze.createElement(ZM,{key:F.id,node:F,onSelect:r})}),m.map(function(F,te){return Ze.createElement(eT,{key:"el-"+te,x:F.x,y:F.y,data:F.data})}))}function Th(e,t){if(!e||typeof e!="object")return"null";var n=Object.keys(e);if(!n.length)return"{}";for(var r=[],i=0;i<n.length;i++){var o=n[i],s=e[o],a=i<n.length-1?",":"";r.push(t+" "+JSON.stringify(o)+": "+JSON.stringify(s)+a)}return`{
78
+ `+r.join(`
79
+ `)+`
80
+ `+t+"}"}function nT(e){if(!e||!e.constructor)return null;var t=e.constructor.kind||"?",n={format:e.format||void 0};Array.isArray(e.payload)&&(n.payload=e.payload),Array.isArray(e.samples)&&(n.samples=e.samples),Array.isArray(e.values)&&(n.values=e.values);for(var r={},i=Object.keys(n),o=0;o<i.length;o++)n[i[o]]!==void 0&&(r[i[o]]=n[i[o]]);return{kind:t,config:r}}function rT(e,t){if(!e)throw new Error("[chainToModule] codec is required");var n=[],r=" ";n.push("// Generated by FRQTL codec codegen — "+new Date().toISOString()),n.push("// Edit this file to customise the chain."),n.push("export function buildCodec(cdc) {");var i=t&&t.snapshots&&t.snapshots[0]?t.snapshots[0]:null,o=i||e._inputEncoding||null;if(o){var s=nT(o);if(s){var a=Object.keys(s.config).length?", "+Th(s.config,r):"";n.push(r+"cdc.input("+JSON.stringify(s.kind)+a+");")}}for(var l=e.steps||[],c=0;c<l.length;c++){var u=l[c],d=u.constructor,f=d.name||"?",h=u.params&&Object.keys(u.params).length?u.params:null;h?n.push(r+"cdc.push("+JSON.stringify(f)+", "+Th(h,r)+");"):n.push(r+"cdc.push("+JSON.stringify(f)+");")}for(var g=e._claims||[],m=0;m<g.length;m++){var x=g[m],y=x.name||"?",b=x.config&&Object.keys(x.config).length?x.config:null;b?n.push(r+"cdc.claim("+JSON.stringify(y)+", "+Th(b,r)+");"):n.push(r+"cdc.claim("+JSON.stringify(y)+");")}return n.push("}"),n.join(`
81
+ `)+`
82
+ `}const iT=`// QFT order finding — the quantum benchmark's computation as a lens-train.
83
+ // Signal: f(k) = 2^k mod 15 for k = 0..7. Its period IS the order r = 4
84
+ // (2^4 = 16 ≡ 1 mod 15) — the value the #quantum benchmark reports.
85
+ // Edit this file to customise the chain.
86
+ export function buildCodec(cdc) {
87
+ cdc.input("HostFloats", {
88
+ "format": "fp64",
89
+ "payload": [1, 2, 4, 8, 1, 2, 4, 8]
90
+ });
91
+ cdc.push("HostFloatsToEGPTReal");
92
+ cdc.push("EGPTRealToPolynomial");
93
+ cdc.push("PolynomialToFFT");
94
+ cdc.push("FFTToPolynomial");
95
+ cdc.push("PolynomialToEGPTReal");
96
+ cdc.push("EGPTRealToHostFloats", {
97
+ "format": "fp64"
98
+ });
99
+ cdc.claim("round-trip-exact", {
100
+ "tolerance": "exact"
101
+ });
102
+ }
103
+ `,Vs=[{id:"qft-order-finding",name:"QFT order finding (2 mod 15)",kind:"math",builtin:!0,language:"javascript",source:iT}],s1=`// No chain defined yet.
104
+ // Use the palette to add transforms.
105
+ export function buildCodec(cdc) {
106
+ }
107
+ `,Rx=Object.freeze({name:"New chain",source:s1});function iv(e){if(typeof e!="string"||!e)return null;for(let t=0;t<Vs.length;t++)if(Vs[t].id===e)return Vs[t];return null}const vm="qft-order-finding";if(!iv(vm))throw new Error('[codec-recipes] FIRST_CONTACT_CODEC_RECIPE_ID "'+vm+'" is not a built-in recipe — declared ids: ['+Vs.map(function(e){return e.id}).join(", ")+"]. (FAIL-LOUD.)");function oT(e){var t=iv(e);if(t)return{source:t.source,project:{projectId:null,builtinId:t.id,name:t.name,dirty:!1}};try{var n=i1(gn(),e);if(n)return{source:n.source,project:{projectId:n.name,builtinId:null,name:n.name,dirty:!1}}}catch(r){return{error:'[CodecView] Failed to load module "'+e+'": '+(r&&r.message?r.message:String(r))}}return{error:'[CodecView] Unknown module id "'+e+'" — not a built-in recipe and not in saved chains. Known built-ins: '+Vs.map(function(r){return r.id}).join(", ")}}function Lx(e){return e.builtinId||e.projectId||""}function sT({mathSdkUrl:e,mathWasmUrl:t,mathWasmModuleUrl:n,mathBackend:r,monacoBaseUrl:i,initialModule:o,onLinkSelect:s,deepLinkRefusal:a}){var[l,c]=j.useState(!1),[u,d]=j.useState(null),f=j.useRef(null),[h,g]=j.useState([]),[m,x]=j.useState(null),[y,b]=j.useState([]),[w,E]=j.useState(null),[C,S]=j.useState([]),[M,L]=j.useState([]),[T,V]=j.useState([]),[G,F]=j.useState(!1),[te,W]=j.useState(""),[Y,re]=j.useState(!1),[pe,B]=j.useState(""),[ee,ce]=j.useState(0);function ve(){ce(function(I){return I+1})}var ke=j.useRef(null),je=j.useRef(null),ie=j.useRef(null);j.useEffect(function(){ui.ensureMath({mathSdkUrl:e,mathWasmUrl:t,mathWasmModuleUrl:n,mathBackend:r}).then(function(I){if(!I.codec){d("[CodecView] Math SDK loaded but sdk.codec is missing. Ensure the SDK bundle was built with the V1 codec surface.");return}f.current=I.codec,c(!0)}).catch(function(I){var de="[CodecView] Math SDK unavailable: "+(I&&I.message?I.message:String(I));d(de),Ee.emit("console:write",{level:"error",text:de})})},[]),j.useEffect(function(){ir()},[]),j.useEffect(function(){function I(fe){fe&&fe.source==="math"&&fe.code&&ln(fe.code)}function de(fe){fe&&fe.source==="math"&&fe.ok===!1&&fe.error&&ut("Run failed: "+fe.error)}return Ee.on("run:request",I),Ee.on("run:result",de),function(){Ee.off("run:request",I),Ee.off("run:result",de)}},[]);var me=j.useRef(null);me.current===null&&(me.current=oT(o||vm));var[xe,ge]=j.useState(function(){return me.current.project||{projectId:null,builtinId:null,name:"",dirty:!1}}),[kt,ut]=j.useState(function(){return a||me.current.error||null}),_n=j.useRef(!1);j.useEffect(function(){var I=me.current.project;I&&typeof s=="function"&&s("module",Lx(I))},[]),j.useEffect(function(){var I=me.current;!I.source||!l||_n.current||(_n.current=!0,ln(I.source),ie.current=I.source,ge(I.project))},[l]);function tn(I,de){ln(I),ie.current=I,ge(de),typeof s=="function"&&s("module",Lx(de))}function ir(){try{V(TM(gn()).map(function(I){return{id:I.name,name:I.name}}))}catch{V([])}}var ht=j.useCallback(function(I,de,fe){if(!de||!I.length){E(null),S([]),L([]),ut(null);return}var Ie=f.current;if(!Ie){ut("[CodecView] Math SDK not yet acquired — try again in a moment.");return}try{var Ft=Ie.buildCodecDsl(Ie.registry,Ie.Codec,Ie.EncodingClasses),cn=Ft.dsl;cn.input(de.kind,de.payload);for(var Xe=0;Xe<I.length;Xe++)cn.push(I[Xe].name,I[Xe].opts);for(var un=fe||[],Pe=0;Pe<un.length;Pe++)cn.claim(un[Pe].name,un[Pe].opts);var Mt=cn.build(),Wt=Mt.codec;Wt.claimMeta==null&&Wt.claim("round-trip-exact",{reference:"round-trip-exact",tolerance:"exact"});var Dn=Mt.headEncoding,lt=Wt.run(Dn);E(lt),ut(null);for(var we=[],pt=lt.snapshots||[],k=Wt.steps||[],R=0;R<k.length;R++){var P=k[R].constructor;if(!P.invertible||!pt[R]){we.push(null);continue}try{var $=new Ie.Codec(P.inputKind).push(k[R]),U=$.roundTripCheck(pt[R]);we.push({ok:U.ok===!0})}catch(he){window.console&&console.error&&console.error("[CodecView] round-trip check failed at step "+R+":",he),we.push({ok:!1})}}var H=qM(lt,Wt,{roundTrips:we});S(H.nodes),L(H.edges)}catch(he){ut(he&&he.message?he.message:String(he)),E(null),S([]),L([])}},[]);function ye(){if(!m||!h.length)return s1;var I=f.current;if(!I)return`// Math SDK not yet acquired.
108
+ export function buildCodec(cdc) {
109
+ }
110
+ `;try{var de=I.buildCodecDsl(I.registry,I.Codec,I.EncodingClasses),fe=de.dsl;fe.input(m.kind,m.payload);for(var Ie=0;Ie<h.length;Ie++)fe.push(h[Ie].name,h[Ie].opts);for(var Ft=0;Ft<y.length;Ft++)fe.claim(y[Ft].name,y[Ft].opts);var cn=fe.build();return rT(cn.codec,w)}catch(Xe){return"// codegen error: "+(Xe&&Xe.message?Xe.message:String(Xe))+`
111
+ export function buildCodec(cdc) {
112
+ }
113
+ `}}function St(I){var de=je.current;!de||typeof I!="string"||de.setFileValue&&de.setFileValue("chain.js",I)||de.openFile({id:"chain.js",language:"javascript",value:I,kind:"math"})}function ln(I){if(!(typeof I!="string"||!I.trim())){var de=f.current;if(!de){ut("[CodecView] Math SDK not yet acquired — cannot apply code.");return}try{var fe=I.replace(/^export\s+/m,""),Ie=new Function(fe+`
114
+ return buildCodec;`),Ft=Ie();if(typeof Ft!="function"){ut("Recipe must define `export function buildCodec(cdc) { ... }`");return}var cn=de.buildCodecDsl(de.registry,de.Codec,de.EncodingClasses),Xe=cn.dsl,un=!1,Pe=Object.assign({},Xe,{input:function(){return un=!0,Xe.input.apply(Xe,arguments)}});if(Ft(Pe),!un){g([]),x(null),b([]),ge(function(k){return Object.assign({},k,{dirty:!0})}),ht([],null,[]);return}var Mt=Xe.build(),Wt=(Mt.codec.steps||[]).map(function(k){return{name:k.constructor.name,opts:k.params||{}}}),Dn=(Mt.codec._claims||[]).map(function(k){return{name:k.name,opts:k.config||{}}}),lt=Mt.headEncoding,we=Mt.headKind||(lt&&lt.constructor&&lt.constructor.kind?lt.constructor.kind:"?"),pt={kind:we,payload:Mt.headPayload||{}};g(Wt),x(pt),b(Dn),ge(function(k){return Object.assign({},k,{dirty:!0})}),ht(Wt,pt,Dn)}catch(k){ut("Apply failed: "+(k&&k.message?k.message:String(k)))}}}j.useEffect(function(){if(G){var I=ke.current;if(I){je.current||(je.current=new At({mountEl:I,monacoBaseUrl:i}),je.current.onRun(function(Xe){var un=Xe&&Xe.value,Pe=Xe&&Xe.id||"chain.js";typeof un=="string"&&un.trim()&&Ee.emit("run:request",{source:"math",code:un,fileId:Pe})}));var de=null;try{var fe=je.current.activeFile();de=fe&&fe.value}catch{}var Ie=ie.current;ie.current=null;var Ft=Ie&&Ie.trim()?Ie:de&&de.trim()?de:ye();St(Ft);var cn=setTimeout(function(){try{je.current.layout()}catch{}},60);return function(){clearTimeout(cn)}}}},[G]),j.useEffect(function(){if(!(!G||!je.current)){var I=ye(),de=null;try{var fe=je.current.activeFile();de=fe&&fe.value}catch{}de!==I&&St(I)}},[h,m,y,w,ee]);function Wn(I){var de=f.current;if(de){var fe=de.registry.byName(I);if(!fe){ut('[CodecView] dropTransform: no transform "'+I+'" in registry');return}var Ie=h.concat([{name:I,opts:{}}]);g(Ie),ge(function(Ft){return Object.assign({},Ft,{dirty:!0})}),ht(Ie,m,y),ve()}}function An(I){var de=h.filter(function(fe,Ie){return Ie!==I});g(de),ge(function(fe){return Object.assign({},fe,{dirty:!0})}),ht(de,m,y),ve()}function Pn(I,de){var fe={kind:I,payload:de||{}};x(fe),ge(function(Ie){return Object.assign({},Ie,{dirty:!0})}),ht(h,fe,y),ve()}function Mn(I){if(!(!I||!I.trim())){re(!1);var de=I.trim();try{if(iv(de))throw new Error('"'+de+'" is a built-in recipe id — a saved chain takes another name.');MM(gn(),{name:de,source:ye()},de),ge({projectId:de,builtinId:null,name:de,dirty:!1}),ir(),typeof s=="function"&&s("module",de)}catch(fe){ut("Save failed: "+(fe&&fe.message?fe.message:String(fe)))}}}function vr(){if(!xe.projectId){re(!0),B(xe.name||"");return}try{PM(gn(),{name:xe.projectId,source:ye()}),ge(function(I){return Object.assign({},I,{dirty:!1})}),ir()}catch(I){ut("Save failed: "+(I&&I.message?I.message:String(I)))}}var Xt=f.current&&f.current.registry,Pt=null;if(Xt&&m&&m.kind&&(Pt=m.kind,h.length>0)){var Ut=h[h.length-1],Et=Xt.byName(Ut.name);Et&&Et.outputKind&&(Pt=Et.outputKind)}var De=Xt?Pt?Xt.outgoing?Xt.outgoing(Pt):Xt.allTransforms():Xt.allTransforms?Xt.allTransforms():[]:[],Tn=te?De.filter(function(I){return I.name.toLowerCase().indexOf(te.toLowerCase())!==-1}):De;return v.jsxs("div",{style:Te.root,children:[u&&v.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"#111",zIndex:10},children:v.jsx("div",{style:Te.errBanner,children:u})}),!l&&!u&&v.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"#111",zIndex:10},children:v.jsx("div",{style:Te.emptyMsg,children:"Acquiring Math SDK…"})}),v.jsxs("div",{style:Te.palette,children:[v.jsx("div",{style:Te.panelTitle,children:"Transforms"}),v.jsx("input",{type:"text",placeholder:"filter…",value:te,onChange:function(I){W(I.target.value)},style:Te.filterInput}),v.jsxs("div",{style:Te.paletteSection,children:[v.jsx("div",{style:Te.sectionLabel,children:"Input"}),v.jsx("button",{style:Object.assign({},Te.paletteItem,m?Te.paletteItemActive:{}),onClick:function(){Pn("HostFloats",{format:"fp64",payload:[1,.5,.25,.125]})},title:"Set HostFloats input",children:"HostFloats (sample)"})]}),v.jsxs("div",{style:Te.paletteSection,children:[v.jsx("div",{style:Te.sectionLabel,children:"Add Transform"}),Tn.length===0?v.jsx("div",{style:Te.emptyMsg,children:"no matches"}):Tn.map(function(I){return v.jsx("button",{style:Te.paletteItem,onClick:function(){Wn(I.name)},title:I.provenance&&I.provenance.claim?I.provenance.claim:I.name,children:I.uiLabel||I.name},I.name)})]})]}),v.jsxs("div",{style:Te.center,children:[v.jsxs("div",{style:Te.centerToolbar,children:[v.jsxs("span",{style:Te.projectName,"data-role":"codec-chain-name",children:[xe.name||"Untitled chain",xe.dirty?" *":""]}),v.jsx("button",{style:Te.toolBtn,onClick:function(){re(!0),B(xe.name||"")},children:"Save As"}),xe.projectId&&v.jsx("button",{style:Te.toolBtn,onClick:vr,children:"Save"}),v.jsxs("button",{style:Object.assign({},Te.toolBtn,G?Te.toolBtnActive:{}),onClick:function(){F(function(I){return!I})},children:["</>"," Code"]})]}),kt&&v.jsx("div",{style:Te.errBanner,children:kt}),h.length>0&&v.jsxs("div",{style:Te.stepsList,children:[m&&v.jsx("span",{style:Te.stepChip,children:m.kind}),h.map(function(I,de){return v.jsxs("span",{style:Te.stepChip,"data-role":"codec-step",children:["→ ",I.name,v.jsx("button",{style:Te.removeBtn,onClick:function(){An(de)},title:"Remove",children:"×"})]},de)})]}),v.jsx("div",{style:Te.flowArea,children:v.jsx(tT,{nodes:C,edges:M})}),G&&v.jsx("div",{style:Te.codeDrawer,ref:ke})]}),v.jsxs("div",{style:Te.rightPanel,children:[v.jsx("div",{style:Te.panelTitle,children:"Built-in recipes"}),v.jsx("button",{style:Te.projectItem,onClick:function(){tn(Rx.source,{projectId:null,builtinId:null,name:"",dirty:!1})},title:"Start an empty chain","data-role":"codec-new-chain",children:Rx.name}),Vs.map(function(I){return v.jsx("button",{style:Object.assign({},Te.projectItem,I.id===xe.builtinId?Te.projectItemActive:{}),onClick:function(){tn(I.source,{projectId:null,builtinId:I.id,name:I.name,dirty:!1})},title:I.id,"data-role":"codec-module","data-active":I.id===xe.builtinId?"1":void 0,children:I.name},I.id)}),v.jsx("div",{style:Te.panelTitle,children:"Saved chains"}),T.length===0?v.jsx("div",{style:Te.emptyMsg,children:"none saved"}):T.map(function(I){return v.jsx("button",{style:Object.assign({},Te.projectItem,I.id===xe.projectId?Te.projectItemActive:{}),title:I.id,"data-role":"codec-module","data-active":I.id===xe.projectId?"1":void 0,onClick:function(){try{var de=i1(gn(),I.id);de&&tn(de.source,{projectId:de.name,builtinId:null,name:de.name,dirty:!1})}catch(fe){ut("Load failed: "+(fe&&fe.message?fe.message:String(fe)))}},children:I.name},I.id)})]}),Y&&v.jsx("div",{style:Te.dialogOverlay,children:v.jsxs("div",{style:Te.dialog,children:[v.jsx("div",{style:{color:"#ccc",marginBottom:"8px",font:"12px sans-serif"},children:"Save chain as:"}),v.jsx("input",{autoFocus:!0,type:"text",value:pe,onChange:function(I){B(I.target.value)},onKeyDown:function(I){I.key==="Enter"&&Mn(pe),I.key==="Escape"&&re(!1)},style:Te.saveAsInput}),v.jsxs("div",{style:{display:"flex",gap:"6px",marginTop:"8px"},children:[v.jsx("button",{style:Te.toolBtn,onClick:function(){Mn(pe)},children:"Save"}),v.jsx("button",{style:Te.toolBtn,onClick:function(){re(!1)},children:"Cancel"})]})]})})]})}var Te={root:{display:"flex",flexDirection:"row",height:"100%",overflow:"hidden",background:"#111",color:"#aaa",fontFamily:"ui-monospace,Menlo,Consolas,monospace"},palette:{width:"180px",flexShrink:0,borderRight:"1px solid #222",display:"flex",flexDirection:"column",overflow:"hidden"},panelTitle:{font:"700 10px ui-monospace,Menlo,Consolas,monospace",color:"#555",padding:"8px 8px 4px",textTransform:"uppercase",letterSpacing:"0.5px"},filterInput:{margin:"0 6px 4px",padding:"3px 5px",font:"10px ui-monospace,Menlo,Consolas,monospace",background:"#181818",border:"1px solid #2a2a2a",color:"#aaa",borderRadius:"2px",outline:"none"},paletteSection:{flex:1,overflowY:"auto",padding:"0 0 4px"},sectionLabel:{font:"9px ui-monospace,Menlo,Consolas,monospace",color:"#444",padding:"4px 8px 2px",textTransform:"uppercase"},paletteItem:{display:"block",width:"100%",textAlign:"left",padding:"4px 8px",font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#888",background:"none",border:"none",borderBottom:"1px solid #1a1a1a",cursor:"pointer",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},paletteItemActive:{color:"#7ec8e3"},center:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},centerToolbar:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",borderBottom:"1px solid #222",flexShrink:0,background:"#111"},projectName:{font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#555",flex:1},toolBtn:{padding:"2px 8px",font:"10px ui-monospace,Menlo,Consolas,monospace",background:"#1a1a1a",border:"1px solid #2a2a2a",color:"#888",borderRadius:"2px",cursor:"pointer"},toolBtnActive:{color:"#7ec8e3",borderColor:"#3a3a5a"},errBanner:{background:"#2a1111",color:"#cc4444",font:"10px ui-monospace,Menlo,Consolas,monospace",padding:"4px 8px",borderBottom:"1px solid #3a1111",flexShrink:0},stepsList:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"3px",padding:"4px 8px",borderBottom:"1px solid #1a1a1a",flexShrink:0,overflowX:"auto"},stepChip:{font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#888",background:"#1a1a1a",border:"1px solid #2a2a2a",borderRadius:"2px",padding:"1px 5px",display:"inline-flex",alignItems:"center",gap:"3px"},removeBtn:{font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#555",background:"none",border:"none",cursor:"pointer",padding:"0 1px",lineHeight:1},flowArea:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},codeDrawer:{height:"200px",flexShrink:0,borderTop:"1px solid #222"},rightPanel:{width:"160px",flexShrink:0,borderLeft:"1px solid #222",display:"flex",flexDirection:"column",overflow:"hidden"},emptyMsg:{font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#333",padding:"6px 8px",fontStyle:"italic"},projectItem:{display:"block",width:"100%",textAlign:"left",padding:"4px 8px",font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#666",background:"none",border:"none",borderBottom:"1px solid #1a1a1a",cursor:"pointer",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},projectItemActive:{color:"#7ec8e3"},dialogOverlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},dialog:{background:"#1a1a1a",border:"1px solid #333",borderRadius:"4px",padding:"16px",minWidth:"260px"},saveAsInput:{width:"100%",padding:"4px 6px",boxSizing:"border-box",font:"11px ui-monospace,Menlo,Consolas,monospace",background:"#111",border:"1px solid #333",color:"#ccc",borderRadius:"2px",outline:"none"}},ff="empty";function kd(e,t){return t??Lo(e)}function aT(e,t,n,r){var i=Zi(t,kd(t,n)),o=zg(e,ff,"wasm",r);return dS(o,{renderer:i.renderer,seed:i.seed})}function ov(e){var t=e&&e.FrqtlPage;if(!t||typeof t.applyModuleSource!="function")throw new Error("[rung-frame] the frame has no FrqtlPage.applyModuleSource — it is not the blank-universe page (experiments/"+ff+"/index.html). (FAIL-LOUD.)");return t}function lT(e,t,n,r,i){return Promise.resolve().then(function(){return Jt(t,"applyRungSource(frameWindow, roster, rung, modeId, override)"),Zi(n,kd(n,r)),ov(e),gd(t,n.id,{mode:kd(n,r)})}).then(function(o){var s=Object.assign({},o.files);return i!=null&&(s[Ko(s)]=i),cT(e,s,n,r)})}function cT(e,t,n,r){return Promise.resolve().then(function(){var i=Zi(n,kd(n,r));return a1(e,t,i,'scene "'+n.id+'"')})}function uT(e,t){return zg(e,ff,"wasm",t)}function dT(e,t){return Promise.resolve().then(function(){return ov(e),ES({router:t})}).then(function(n){return a1(e,n.files,bi(n.renderState),"the Empty Universe")})}function a1(e,t,n,r){return Promise.resolve(ov(e).applyModuleSource({files:t})).then(function(){var i=e.FrqtlPage.runner;if(!i)throw new Error("[rung-frame] "+r+" applied but the frame has no FrqtlPage.runner. (FAIL-LOUD.)");i.stop();var o=e.FrqtlPage;if(typeof o.applyRenderState!="function")throw new Error("[rung-frame] the frame has no FrqtlPage.applyRenderState — it is not the blank-universe page (experiments/"+ff+"/index.html). (FAIL-LOUD.)");var s=o.applyRenderState(n);if(s.camera==="retained")throw new Error("[rung-frame] "+r+' declares camera preset "'+s.preset+'", which the booted camera does not offer. (FAIL-LOUD.)');return i})}const fT=Object.freeze([{id:"unsupported",means:'document.fullscreenEnabled is not true or the element has no requestFullscreen (iOS Safari; a frame without allow="fullscreen"): nothing is requested, the control is disabled with the reason as its title'},{id:"entered",means:"requestFullscreen() resolved: the element fills the screen"},{id:"exited",means:"the element left fullscreen — exitFullscreen() resolved, or the viewer/browser ended it"},{id:"denied",means:"requestFullscreen() or exitFullscreen() rejected; recorded as denied:<DOMException.name>"}].map(Object.freeze)),hT=new Set(fT.map(e=>e.id));function vs(e,t,{suffix:n="",detail:r}={}){if(!hT.has(t))throw new Error(`fullscreen: '${t}' is not a FULLSCREEN_OUTCOMES row`);const i=t+n;return e.dataset.frqtlFullscreen=i,r===void 0?delete e.dataset.frqtlFullscreenDetail:e.dataset.frqtlFullscreenDetail=r,r===void 0?{row:t,record:i}:{row:t,record:i,detail:r}}function l1(e){if(!e)return{supported:!1,reason:"no document"};if(e.fullscreenEnabled!==!0)return{supported:!1,reason:"Fullscreen is not available here (document.fullscreenEnabled is "+String(e.fullscreenEnabled)+' — an embedding frame without allow="fullscreen", or a browser without element fullscreen)'};const t=e.documentElement;return!t||typeof t.requestFullscreen!="function"?{supported:!1,reason:"Fullscreen is not available here (no Element.requestFullscreen)"}:{supported:!0,reason:null}}function c1(e){if(!e||!e.dataset||!e.ownerDocument)throw new TypeError("fullscreen: the target must be a DOM element")}async function pT(e){c1(e);const t=e.ownerDocument,n=l1(t);if(!n.supported)return vs(e,"unsupported",{detail:n.reason});if(t.fullscreenElement===e){try{await t.exitFullscreen()}catch(r){return vs(e,"denied",{suffix:":"+(r&&r.name||"Error"),detail:r&&r.message||String(r)})}return vs(e,"exited")}try{await e.requestFullscreen()}catch(r){return vs(e,"denied",{suffix:":"+(r&&r.name||"Error"),detail:r&&r.message||String(r)})}return vs(e,"entered")}function mT(e){return c1(e),e.ownerDocument.fullscreenElement!==e&&e.dataset.frqtlFullscreen==="entered"?vs(e,"exited"):null}const ym='[data-role="gym-root"]',Ax="frqtl-gym-fullscreen-css",gT=ym+":fullscreen{background:#0b0d10;width:100%;height:100%;overflow:auto;}";function vT(e){if(e.getElementById(Ax))return;const t=e.createElement("style");t.id=Ax,t.textContent=gT,e.head.appendChild(t)}function Px(e){const t=e&&e.closest(ym);if(!t)throw new Error("GymFullscreenButton: no ancestor matches "+ym+' — put data-role="gym-root" on the element the GYM puts in fullscreen.');return t}function yT({style:e}){const t=j.useRef(null),[n,r]=j.useState({supported:!1,reason:"checking"}),[i,o]=j.useState(null);j.useEffect(function(){const u=t.current,d=Px(u),f=u.ownerDocument;vT(f),r(l1(f));function h(){const g=mT(d);g&&o(g)}return f.addEventListener("fullscreenchange",h),function(){f.removeEventListener("fullscreenchange",h)}},[]);function s(){pT(Px(t.current)).then(o)}const a=i&&i.row==="entered",l=i&&i.row==="denied",c=n.supported?l?"Fullscreen was refused: "+i.record+(i.detail?" — "+i.detail:""):a?"Leave fullscreen":"Fullscreen":n.reason;return v.jsx("button",{ref:t,type:"button","data-role":"gym-fullscreen","data-fullscreen-record":i?i.record:void 0,style:e,title:c,disabled:!n.supported,onClick:s,children:a?"Exit fullscreen":l?"Fullscreen (refused)":"Fullscreen"})}function Mx(e,t){const n=j.useRef(null),r=j.useCallback(function(){const o=n.current;n.current=null,o&&o.close()},[]),i=j.useCallback(function(o){n.current=DL(e.current,{seenKey:o.seenKey,title:o.title,paragraphs:o.paragraphs},{covers:t.current})},[e,t]);return j.useEffect(function(){return r},[r]),{open:i,close:r}}var hf="walkthrough:",bT=Object.freeze({kind:"empty",id:af,mode:null});function Tx(e){return e&&e.kind==="rung"?hf+e.id:""}function xT(e,t){for(var n=e.showcase?e.showcase.rows:[],r=0;r<n.length;r++)if(hf+n[r].id===t)return n[r];return null}function u1(e,t){var n=xT(e,t),r=Kt(e,t.slice(hf.length));return{kind:"rung",id:r.id,mode:n&&n.mode||Lo(r)}}function d1(e){return gS(e).map(function(t){return{label:t.label,rows:t.rows.map(function(n){return{value:hf+n.id,title:n.title}})}})}function wT(e,t,n){if(n&&!t)return{scene:null,error:"Deep link error: ?mode="+n+" without a ?walkthrough= — a mode belongs to a roster scene. (FAIL-LOUD.)"};if(t){var r=Kt(e,t);if(!r)return{scene:null,error:'Deep link error: unknown walkthrough "'+t+`" — this site's roster declares: `+e.rows.map(function(s){return s.id}).join(", ")+"."};var i=n||Lo(r);try{Zi(r,i)}catch(s){return{scene:null,error:"Deep link error: "+(s&&s.message?s.message:String(s))}}return{scene:{kind:"rung",id:r.id,mode:i},error:null}}var o=d1(e);return{scene:o.length>0?u1(e,o[0].rows[0].value):bT,error:null}}var Dx=45e3,_T=250;function kT({experimentBase:e,router:t,roster:n,initialWalkthrough:r,initialWalkthroughMode:i,onLinkSelect:o,monacoBaseUrl:s,onOpenInStudio:a,deepLinkRefusal:l}){if(Jt(n,"CompareView({ experimentBase, router, roster, … })"),!e)throw new Error("[CompareView] experimentBase is required — mount CompareView through FraqtlIde (lib/features/ide/index.jsx), the only mounter, which derives it from its engineRouter.");if(!s)throw new Error("[CompareView] monacoBaseUrl is required — FraqtlIde ferries its router-resolved Monaco base (the code editor's); mount CompareView through lib/features/ide/index.jsx.");var c=e;const[u]=j.useState(function(){return l?{scene:null,error:l}:wT(n,r,i)}),[d,f]=j.useState(u.scene),[h,g]=j.useState(0),[m,x]=j.useState(null),[y,b]=j.useState(!1),[w,E]=j.useState(null),[C,S]=j.useState(null),[M,L]=j.useState(null),T=j.useRef(null);T.current=CS(m);var V=d?d.id:null,G=d?d.kind+":"+d.id+":"+d.mode:null,F=j.useMemo(function(){return d&&d.kind==="rung"?{id:d.id,modeId:d.mode}:null},[G]),te=j.useMemo(function(){return F?yS(n,F):null},[F]),W=j.useMemo(function(){return te?bS(n,te):null},[te]),Y=xS(n),re=F?ta(n,F):"scene-"+af;function pe(){return d.kind==="empty"?uT(c,window.location.search):aT(c,Kt(n,d.id),d.mode,window.location.search)}function B(N){var K=N&&N.contentWindow;if(!K)return null;try{if(N.src&&K.location&&K.location.href!==N.src)return null}catch{}return K}function ee(N){var K=B(N);return!!(K&&K.FrqtlPage&&typeof K.FrqtlPage.isReady=="function"&&K.FrqtlPage.isReady())}const ce=j.useRef(null),ve=j.useRef(null),ke=j.useRef(null),[je,ie]=j.useState(""),[me,xe]=j.useState("60"),[ge,kt]=j.useState({fps:0,tps:0,tick:0,alive:0}),[ut,_n]=j.useState(!1),tn=j.useRef(!1),ir=j.useRef(null),ht=j.useRef(null),ye=j.useRef(null),St=j.useRef(null),ln=j.useRef(null),Wn=j.useRef(null),An=Mx(ht,ye),Pn=Mx(ir,St),[Mn,vr]=j.useState(!1),[Xt,Pt]=j.useState(null),Ut=j.useRef(null),[Et,De]=j.useState(am()),[Tn,I]=j.useState(null),[de,fe]=j.useState(null),[Ie,Ft]=j.useState([]),[cn,Xe]=j.useState([]),un=j.useCallback(function(N){var K=ve.current;!K||!K.cameraControl||(K.cameraControl.setOrbit(N),I(K.cameraControl.getOrbit()),fe(null))},[]),Pe=j.useCallback(function(N){var K=ve.current;!K||!K.cameraControl||typeof K.cameraControl.setPreset!="function"||(K.cameraControl.setPreset(N),I(K.cameraControl.getOrbit()),fe(N))},[]),Mt=j.useCallback(function(){var N=je===""||je==null?0:Number(je),K=me===""||me==null?1/0:Number(me);return(isNaN(N)||N<0)&&(N=0),(typeof K!="number"||isNaN(K)||K<0)&&(K=1/0),{fpsLimit:N,tpsLimit:K}},[je,me]),Wt=j.useCallback(function(){var N=ve.current;if(N){var K=N.isRunning,We=N.getRates();_n(K),kt({fps:K?We.fps:0,tps:K?We.tps:0,tick:N.worldTick,alive:N.universe.activeQuanta})}},[]);function Dn(){var N=ve.current;N&&(tn.current=N.isRunning),g(function(K){return K+1})}j.useEffect(function(){if(vr(!1),Pt(null),kt({fps:0,tps:0,tick:0,alive:0}),_n(!1),I(null),ve.current=null,ke.current&&(clearInterval(ke.current),ke.current=null),!V)return;var N=ER(ce.current,{onError:function(bt){Pt(bt.message)}}),K=!1,We=!1,kn=Date.now(),Nt=setInterval(function(){if(!K){if(!We&&ee(ce.current)){We=!0,clearInterval(Nt);var bt=T.current;(d.kind==="empty"?dT(ce.current.contentWindow,t):lT(ce.current.contentWindow,n,Kt(n,d.id),d.mode,bt)).then(function(ct){K||Sn(ct)},function(ct){if(!K){var $r=ct&&ct.message?ct.message:String(ct);if(Pt('[GYM] scene "'+d.id+'" failed to load'+(bt!==null?" (edited code)":"")+": "+$r),bt!==null){var co=jS(ct);E({message:$r,line:co?co.line:void 0,col:co?co.col:void 0}),b(!0)}}});return}Date.now()-kn>Dx&&(clearInterval(Nt),Pt("[Benchmark] Boot timeout — the WASM frame was not ready after "+Dx/1e3+"s (see the pane for a fail-loud overlay)."))}},100);function Sn(bt){ve.current=bt,fe(null);try{if(typeof bt.isRunning!="boolean"||typeof bt.getRates!="function"||!bt.universe||!("worldTick"in bt))throw new Error("the runner does not publish the readout contract — a boolean isRunning (FrqtlApp.prototype.isRunning), getRates() (FrqtlApp.prototype.getRates), worldTick (FrqtlApp.prototype.worldTick) and its universe (FrqtlApp.universe: activeQuanta). The GYM reads the run state and the readout from the runner, never from a copy or a guess.");var ct=bt.cameraControl||null;ct&&(me===""||me==null)?bt.setRateLimits({fpsLimit:Mt().fpsLimit,tpsLimit:120}):bt.setRateLimits(Mt()),tn.current?bt.start():bt.stop(),vr(!0),I(ct?ct.getOrbit():null),Ft(ct&&Array.isArray(ct.presets)?ct.presets:[]),Xe(ct&&Array.isArray(ct.poseFields)?ct.poseFields:[])}catch($r){Pt("[Benchmark] "+($r&&$r.message?$r.message:String($r)));return}Wt(),ke.current=setInterval(Wt,_T)}return function(){K=!0,N(),clearInterval(Nt),ke.current&&(clearInterval(ke.current),ke.current=null),ve.current=null}},[G,h]),j.useEffect(function(){var N=ce.current;if(De(am()),!N){Ut.current=null;return}var K=CA(N);Ut.current=K,De(K.current());var We=K.subscribe(De);return function(){We(),K.close(),Ut.current===K&&(Ut.current=null)}},[G,h]),j.useEffect(function(){var N=ve.current;if(N&&typeof N.setRateLimits=="function")try{N.setRateLimits(Mt())}catch{}},[je,me,Mt]),j.useEffect(function(){var N=ir.current;if(!(!d||!N)){if(!te){var K=re,We=Hs(N,K,"not-offered-no-roster-row",K+" has no showcase-roster row");return function(){Pn.close(),We.close()}}var kn=function(){tn.current=!0;var bt=ve.current;if(bt)try{bt.start(),Wt()}catch(ct){Pt("[GYM] "+(ct&&ct.message?ct.message:String(ct)))}},Nt=W,Sn=Ml(N,{seenKey:Nt.seenKey,title:Nt.title,paragraphs:Nt.paragraphs,onContinue:kn,progress:Ut.current||void 0},{covers:St.current});return ln.current=Sn,Sn.ready.then(function(bt){bt.shows||kn()}),function(){Pn.close(),ln.current=null,Sn.close()}}},[G]),j.useEffect(function(){var N=ht.current;if(!(!d||!N)){if(!te||!Y){var K=Hs(N,Y?Y.seenKey:re,"not-offered-no-roster-row",re+(te?": the roster has no showcase intro":" has no showcase-roster row"));return function(){An.close(),K.close()}}var We=Ml(N,Y,{covers:ye.current});return Wn.current=We,function(){An.close(),Wn.current=null,We.close()}}},[G]),j.useEffect(function(){Xt&&(Pn.close(),An.close(),ln.current&&(ln.current.close(),ln.current=null),Wn.current&&(Wn.current.close(),Wn.current=null))},[Xt]);const lt=j.useCallback(function(){var N=ve.current;if(N)try{N.isRunning?N.stop():N.start(),Wt()}catch(K){Pt("[Benchmark] "+(K&&K.message?K.message:String(K)))}},[]),we={root:{position:"relative",display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",background:"#111",fontFamily:"ui-monospace,Menlo,Consolas,monospace",fontSize:"0.75rem",color:"#ccc"},toolbar:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",borderBottom:"1px solid #222",flexShrink:0,flexWrap:"wrap"},label:{color:"#555",fontSize:"0.65rem"},select:{padding:"2px 6px",background:"#1a1a1a",border:"1px solid #2a2a2a",color:"#ccc",borderRadius:"2px",font:"11px ui-monospace",outline:"none"},num:{width:"52px",padding:"2px 6px",background:"#1a1a1a",border:"1px solid #2a2a2a",color:"#ccc",borderRadius:"2px",font:"11px ui-monospace",outline:"none"},btn:{padding:"2px 10px",background:"#1a2a3a",color:"#8af",border:"1px solid #2a3a4a",borderRadius:"3px",cursor:"pointer",fontSize:"0.7rem"},btnStop:{background:"#2a1a1a",color:"#f84",border:"1px solid #3a2a2a"},readBar:{display:"flex",alignItems:"center",gap:"18px",padding:"4px 12px",borderBottom:"1px solid #1a1a1a",flexShrink:0,fontSize:"0.7rem"},metric:{color:"#888"},metricBig:{color:"#6c9",fontWeight:700,fontSize:"0.95rem"},paneRow:{display:"flex",flex:1,overflow:"hidden",gap:"1px",background:"#222"},paneWrap:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",background:"#111"},paneTitle:{padding:"3px 8px",borderBottom:"1px solid #1a1a1a",flexShrink:0,fontSize:"0.65rem",color:"#555",textTransform:"uppercase",letterSpacing:"0.5px"},frame:{flex:1,border:0,width:"100%",height:"100%",background:"#000"},errBanner:{background:"#2a1111",color:"#cc4444",padding:"6px 12px",fontSize:"0.7rem",flexShrink:0},hint:{padding:"2px 12px",fontSize:"0.6rem",color:"#333",flexShrink:0}};function pt(N){typeof o=="function"&&(o("walkthrough",N.id),o("mode",Dl(Kt(n,N.id)).length>1?N.mode:""))}function k(N){tn.current=!1;var K=!!(d&&N&&N.id===d.id);K||(x(null),b(!1),E(null),S(null),L(null)),f(N),pt(N)}var R=d&&d.kind==="rung"?Kt(n,d.id):null;function P(){return gd(n,R.id).then(function(N){return N.files[Ko(N.files)]}).catch(function(N){throw Pt("[GYM] the code behind could not be read: "+(N&&N.message?N.message:String(N))),N})}function $(N){var K=(N||"").trim();if(K){var We=Xg(m),kn=m.text;gd(n,R.id,{mode:d.mode}).then(function(Nt){var Sn=Object.assign({},Nt.files);Sn[Ko(Sn)]=kn,cm(gn(),{files:Sn,renderState:Nt.renderState},K),S(null),L({ok:!0,text:We?'Saved your code as "'+K+'"; the frame still runs the previous text — Run to see it.':'Saved as "'+K+'" — it opens in STUDIO under Saved projects.'})}).catch(function(Nt){L({ok:!1,text:"Save As failed: "+(Nt&&Nt.message?Nt.message:String(Nt))})})}}function U(){if(m){b(!0);return}P().then(function(N){x(Il(N)),b(!0)},function(){})}function H(N){x(OS(m,N)),E(null),Pt(null),b(!1),Dn()}function he(){P().then(function(N){x(Il(N)),E(null),Pt(null),Dn()},function(){})}function Ae(N){x(om(m,N)),b(!1)}var Ve=yA(m),Qe=d1(n),Be=v.jsxs("select",{style:we.select,value:Tx(d),disabled:Qe.length===0,"data-role":"gym-experiment-select",onChange:function(N){k(u1(n,N.target.value))},children:[(!d||d.kind==="empty")&&v.jsx("option",{value:"",disabled:!0,children:d?"Empty Universe":"— pick a scene —"}),Qe.map(function(N,K){return v.jsx("optgroup",{label:N.label,children:N.rows.map(function(We){return v.jsx("option",{value:We.value,children:We.title},K+":"+We.value)})},K+":"+N.label)})]}),Ce=d&&d.kind==="rung"?Dl(Kt(n,d.id)):[],qe=Ce.length>1?v.jsx("span",{"data-role":"gym-mode-strip",style:{display:"inline-flex",gap:"4px"},children:Ce.map(function(N){var K=N.id===d.mode;return v.jsx("button",{"data-mode":N.id,"data-active":K?"1":"0",style:Object.assign({},we.btn,K?{background:"#27424f",color:"#7ec8e3",borderColor:"#7ec8e3"}:{}),onClick:function(){K||k({kind:"rung",id:d.id,mode:N.id})},children:N.label},N.id)})}):null,nn=d?null:u.error;return v.jsxs("div",{style:we.root,"data-role":"gym-root","data-scene":Tx(d),"data-scene-source":vA(m),"data-scene-mode":d&&d.mode||"","data-booted":Mn?"1":"0",children:[v.jsxs("div",{ref:ye,"data-role":"gym-covered",style:{display:"contents"},children:[v.jsxs("div",{ref:St,"data-role":"gym-scene-covered",style:{display:"contents"},children:[v.jsxs("div",{style:we.toolbar,children:[v.jsx("span",{style:we.label,children:"Scene:"}),Be,qe,v.jsx("span",{style:we.label,title:"Render frames/sec cap. Blank = display refresh (draw every animation frame).",children:"FPS:"}),v.jsx("input",{style:we.num,type:"number",min:"0",placeholder:"max",value:je,onChange:function(N){ie(N.target.value)}}),v.jsx("span",{style:we.label,title:"Physics ticks/sec cap. Blank = unbounded (as many ticks per frame as the budget allows).",children:"TPS:"}),v.jsx("input",{style:we.num,type:"number",min:"0",placeholder:"∞",value:me,onChange:function(N){xe(N.target.value)}}),ut?v.jsx("button",{style:Object.assign({},we.btn,we.btnStop),onClick:lt,disabled:!Mn,children:"Pause"}):v.jsx("button",{style:we.btn,onClick:lt,disabled:!Mn,children:"Run"}),v.jsx("button",{style:we.btn,onClick:Dn,children:"Reset"}),v.jsx(yT,{style:we.btn}),v.jsx("button",{style:Object.assign({},we.btn,R?{}:{opacity:.45,cursor:"not-allowed"}),"data-role":"gym-scene-code",disabled:!R,title:R?"See and edit this scene's code — "+R.source:"No scene is showing.",onClick:U,children:"Code behind"}),v.jsxs("span",{"data-role":"gym-reopen",style:{display:"inline-flex",gap:"4px"},children:[v.jsx("button",{type:"button",style:Object.assign({},we.btn,Y?{}:{opacity:.45,cursor:"not-allowed"}),"data-role":"gym-reopen-intro",disabled:!Y,title:Y?Y.title:"This site's roster has no showcase intro.",onClick:function(){An.open(Y)},children:"Why impossible"}),v.jsx("button",{type:"button",style:Object.assign({},we.btn,W?{}:{opacity:.45,cursor:"not-allowed"}),"data-role":"gym-reopen-scene",disabled:!W,title:W?W.title:"This scene has no showcase card.",onClick:function(){Pn.open(W)},children:"About this scene"})]}),!Mn&&!Xt&&Jb(Et)&&v.jsx("span",{"data-role":"gym-boot-caption",style:{color:"#886",fontSize:"0.65rem"},children:Jb(Et)})]}),v.jsxs("div",{style:we.readBar,children:[v.jsxs("span",{style:we.metric,children:["TPS ",v.jsx("span",{style:we.metricBig,"data-gym-metric":"tps",children:ge.tps})]}),v.jsxs("span",{style:we.metric,children:["FPS ",v.jsx("span",{style:we.metricBig,"data-gym-metric":"fps",children:ge.fps})]}),v.jsxs("span",{style:we.metric,children:["tick ",v.jsx("code",{style:{color:"#aaa"},"data-gym-metric":"tick",children:ge.tick})]}),v.jsxs("span",{style:we.metric,children:["alive ",v.jsx("code",{style:{color:"#aaa"},"data-gym-metric":"alive",children:ge.alive})]}),v.jsxs("span",{style:{color:"#445"},children:[me===""||me==null?"TPS unbounded":"TPS≤"+me," ·",je===""||je==null?" FPS=display-refresh":" FPS≤"+je]})]}),Tn&&v.jsxs("div",{style:we.toolbar,"data-role":"bench-camera-controls",children:[v.jsx("span",{style:we.label,title:"3D orbit camera — driven via the experiment's sugar cameraControl handle (BYO renderer capability)",children:"📷 camera"}),cn.map(function(N){var K=YS(N);return K?v.jsxs(Ze.Fragment,{children:[v.jsx("span",{style:we.label,title:N.description,children:KS(N)}),v.jsx("input",{style:{width:"90px",cursor:"pointer",accentColor:"#7ec8e3"},type:"range",min:K.min,max:K.max,step:K.step,value:Math.round(Tn[N.name]),onChange:function(We){var kn={};kn[N.name]=Number(We.target.value),un(kn)}})]},N.name):null}),v.jsx("span",{style:we.label,children:"view"}),Ie.map(function(N){var K=de===N;return v.jsx("button",{style:Object.assign({},we.btn,K?{background:"#27424f",color:"#7ec8e3",borderColor:"#7ec8e3"}:{}),onClick:function(){Pe(N)},children:N},N)})]}),v.jsx("div",{style:we.hint,children:"Single-engine (WASM) throughput. Cadence owned by the sugar FrqtlApp (decoupled _tickHz/_drawHz via a fixed-timestep accumulator); the engine just runs doTick(). Cap FPS to paint slower than physics ticks; leave blank for max."}),(nn||Xt)&&v.jsx("div",{style:Object.assign({},we.errBanner,{whiteSpace:"pre-wrap"}),children:nn||Xt}),v.jsx("div",{style:we.paneRow,children:v.jsxs("div",{style:we.paneWrap,children:[v.jsx("div",{style:we.paneTitle,children:"WASM engine — benchmark"}),V&&v.jsx("iframe",{ref:ce,style:we.frame,title:"WASM Engine",src:pe()},"bench-wasm-"+G+"-"+h)]})}),m&&R&&v.jsxs("div",{"data-role":"gym-scene-editor","data-open":y?"1":"0",style:{position:"absolute",inset:0,zIndex:9e3,display:y?"block":"none"},children:[v.jsx(j.Suspense,{fallback:v.jsx("div",{style:{padding:"12px",color:"#886"},children:"Loading the editor…"}),children:v.jsx(PS,{fileName:R.source,source:m.text,appliedSource:cf(m),monacoBaseUrl:s,onRun:H,onReset:he,onClose:Ae,onChange:function(N){x(function(K){return om(K,N)})},error:w,extraActions:[{id:"save-as",label:"Save As",title:"Save this code as a project (it opens in STUDIO)",onClick:function(){L(null),S(R.id+" copy")}},{id:"open-in-studio",label:"Open in STUDIO",disabled:!!Ve||typeof a!="function",title:Ve||"Open this scene in STUDIO (palette, inspector, Save)",onClick:function(){a()}}]})}),C!==null&&v.jsxs("form",{"data-role":"gym-save-as-prompt",style:{position:"absolute",top:"40px",right:"12px",zIndex:2,display:"flex",gap:"6px",padding:"8px",background:"#1a1a1a",border:"1px solid #333",borderRadius:"4px"},onSubmit:function(N){N.preventDefault(),$(C)},children:[v.jsx("input",{type:"text",value:C,autoFocus:!0,"aria-label":"Project name",onChange:function(N){S(N.target.value)},style:we.select}),v.jsx("button",{type:"submit",style:we.btn,children:"Save"}),v.jsx("button",{type:"button",style:we.btn,onClick:function(){S(null)},children:"Cancel"})]}),M&&v.jsx("div",{"data-role":"gym-save-notice","data-ok":M.ok?"1":"0",style:{position:"absolute",left:0,right:0,bottom:0,zIndex:2,padding:"6px 12px",fontSize:"0.7rem",background:M.ok?"#0f1a12":"#2a1111",color:M.ok?"#9ad0a0":"#cc4444"},children:M.text})]})]}),v.jsx("div",{ref:ir,"data-role":"gym-scene-card-host",style:{position:"absolute",inset:0,zIndex:1e4,pointerEvents:"none"}})]}),v.jsx("div",{ref:ht,"data-role":"gym-intro-host",style:{position:"absolute",inset:0,zIndex:1e4,pointerEvents:"none"}})]})}function ST(e,t){var n={},r=null;return{load:function(i){return Wk(i)?(r===null&&(r=Promise.resolve().then(function(){return BA(NA(e),{fetch:n.fetch})})),r):null}}}function ET(e){const t=e&&typeof e.querySelector=="function"?e.querySelector('link[rel="home"]'):null;if(!t)return null;const n=t.getAttribute("href");if(!n)throw new Error('home-link: <link rel="home"> carries no href — the declaration is malformed');return n}const f1='@descix/app-sdk 0.8.0 APP_SHELL_API.md §"DeSciX.powch — identity and wallet"',OT=Object.freeze([{id:"pending",session:!1,means:"awaiting DeSciX.ready()"},{id:"sdk-absent",session:!1,means:"window.DeSciX is undefined: no publisher-provided DeSciXAppSDK.js beside this page (dev, a plain static host)"},{id:"unmanaged",session:!1,means:"ready() resolved standalone or embedded-no-bridge: no readable shell above this page, nothing to sign into"},{id:"powch-unpublished",session:!1,means:"the shell resolved, but its members do not include powch"},{id:"signed-out",session:!0,means:"powch.on(auth) reported signedIn false"},{id:"signed-in",session:!0,means:"powch.on(auth) reported signedIn true"},{id:"contract-violated",session:!1,means:"the SDK or shell broke the published shape; the edge is in dataset.descixAuthDetail and a TypeError was thrown"}].map(Object.freeze)),CT=new Set(OT.map(e=>e.id));function jT(){return typeof document<"u"?document.documentElement:null}function h1(e,t,n){if(!CT.has(t))throw new Error(`host-auth: '${t}' is not a HOST_AUTH_STATES row`);return e&&(e.dataset.descixAuth=t,n===void 0?delete e.dataset.descixAuthDetail:e.dataset.descixAuthDetail=n),t}function Gr(e,t){return h1(e,"contract-violated",t),new TypeError(`host-auth: ${t} — the published contract is ${f1}. (FAIL-LOUD.)`)}function Ix(e){try{return e.mode}catch{return}}function RT(e){return!e||typeof e!="object"||typeof e.signedIn!="boolean"?{edge:"powch.on(auth) delivered "+JSON.stringify(e)+", not { signedIn: boolean, address: string|null }"}:e.address===null||typeof e.address=="string"?{signedIn:e.signedIn,address:e.address}:{edge:"powch.on(auth) delivered address "+JSON.stringify(e.address)+", not a string or null"}}function LT({sdk:e,onState:t,root:n}={}){if(typeof t!="function")throw new TypeError("host-auth: followHostAuth needs an onState(id, session) function");const r=n||jT();let i=!1,o=null;const s=(c,u=null,d)=>{i||t(h1(r,c,d),u)},a=()=>{if(!i&&(i=!0,o)){const c=o;o=null,c()}};if(e==null)return s("sdk-absent"),{stop:a,settled:Promise.resolve("sdk-absent")};if(typeof e.ready!="function"){const c=Gr(r,"window.DeSciX is a "+typeof e+" without ready()");return{stop:a,settled:Promise.reject(c)}}s("pending");const l=(async()=>{let c;try{c=await e.ready()}catch(x){if(Ix(e)==="embedded-no-bridge")return s("unmanaged",null,"ready() rejected: "+(x&&x.message)),"unmanaged";throw Gr(r,"ready() rejected while the SDK reports mode "+JSON.stringify(Ix(e))+": "+(x&&x.message))}const u=c&&c.mode;if(u==="standalone"||u==="embedded-no-bridge")return s("unmanaged",null,"ready() resolved "+u),"unmanaged";if(u!=="shell")throw Gr(r,"ready() resolved mode "+JSON.stringify(u));if(!Array.isArray(c.members))throw Gr(r,"ready() resolved shell without a members array");if(!c.members.includes("powch"))return s("powch-unpublished",null,"members: "+c.members.join(",")),"powch-unpublished";if(i)return"pending";const d=e.powch;if(!d)throw Gr(r,"members names powch; the getter returned "+String(d));if(typeof d.on!="function")throw Gr(r,"powch.on is "+typeof d.on);let f=null,h=null;const g=x=>{const y=RT(x);if(y.edge){if(f=Gr(r,y.edge),o){const w=o;o=null,w()}throw i||t("contract-violated",null),f}const b=y.signedIn?"signed-in":"signed-out";h===null&&(h=b),s(b,y)};let m;try{m=d.on("auth",g)}catch(x){throw f||Gr(r,"powch.on(auth) threw: "+(x&&x.message))}if(typeof m!="function")throw Gr(r,"powch.on(auth) returned "+typeof m+", not the unsubscribe function");if(o=m,f){const x=o;throw o=null,x(),f}if(i){const x=o;o=null,x()}return h||"pending"})();return{stop:a,settled:l}}function AT(e){const t=e&&e.powch;if(!t||typeof t.login!="function")throw new TypeError("host-auth: hostSignIn found no DeSciX.powch.login function at the tap — the published contract is "+f1+". (FAIL-LOUD.)");return t.login()}const Dh=Object.freeze({"signed-out":"Sign In","signed-in":"Logged In"});function PT({onPhone:e,state:t}){return Object.prototype.hasOwnProperty.call(Dh,t)?{label:Dh[t],labels:Object.values(Dh),signedIn:t==="signed-in"}:null}function MT({win:e,sdk:t,onView:n,root:r}){if(typeof n!="function")throw new TypeError("sign-in: startSignIn needs an onView(view) function");return Hg(e)?LT({sdk:t,root:r,onState:i=>n(PT({onPhone:!0,state:i}))}):(n(null),{stop(){},settled:Promise.resolve(null)})}const TT={flex:"0 0 auto",padding:"2px 4px",fontSize:"0.62rem",letterSpacing:"0.3px"};function DT(){const[e,t]=j.useState(null);return j.useEffect(function(){const n=MT({win:window,sdk:window.DeSciX,onView:t});return n.settled.catch(function(r){throw t(null),r}),n.stop},[]),e?v.jsx(dm,{className:"ph-toolbar-btn",type:"button","data-role":"frqtl-sign-in","data-signed-in":e.signedIn?"true":"false",labels:e.labels,disabled:e.signedIn,title:e.signedIn?"Signed in to DeSciX":"Sign in to DeSciX",style:Object.assign({cursor:e.signedIn?"default":"pointer"},TT),onClick:function(){e.signedIn||AT(window.DeSciX)},children:e.label}):null}function IT(e){if(!e||!Array.isArray(e.notebooks))throw new Error("[notebook catalog] no notebooks[] array — cannot resolve the first-contact notebook.");var t=e.firstContact;if(typeof t!="string"||t==="")throw new Error('[notebook catalog] notebooks.json declares no "firstContact" notebook id — FAT has nothing to open with no ?notebook= (lib/notebooks/notebooks.json).');for(var n=0;n<e.notebooks.length;n++)if(e.notebooks[n].id===t)return e.notebooks[n];throw new Error('[notebook catalog] firstContact "'+t+'" is not in the catalog — listed ids: ['+e.notebooks.map(function(r){return r.id}).join(", ")+"].")}function FT(e,t){if(t!=="factory"&&t!=="recipe")throw new Error('[setup-builder] parseSetupDeclaration(setup, shape): shape is "factory" or "recipe" (got '+JSON.stringify(t)+") — the `setup` grammar depends on it. (FAIL-LOUD.)");if(typeof e!="string"||!e.trim())throw new Error("[setup-builder] a declared canvas requires a `setup` attribute — "+(t==="recipe"?'`setup="<module-name>"`':'`setup="<module-name>#<factoryName>"`')+" (got: "+JSON.stringify(e)+"). (FAIL-LOUD.)");var n=e.trim(),r=n.indexOf("#"),i=r===-1?n:n.slice(0,r),o=r===-1?"":n.slice(r+1);if(i=i.trim(),o=o.trim(),!i)throw new Error('[setup-builder] `setup` declaration "'+e+'" has no module name before the "#". Expected "<module-name>#<exportName>". (FAIL-LOUD.)');if(t==="recipe"&&r!==-1)throw new Error('[setup-builder] a recipe canvas names no export: `setup="'+e+'"` carries "#'+o+'", but a recipe is the module\'s DEFAULT export (`export default function buildExperiment(exp)`) — write setup="'+i+'". (FAIL-LOUD.)');if(t==="factory"&&!o)throw new Error('[setup-builder] a factory canvas names its factory: `setup="'+e+'"` has no "#<factoryName>" — a setup module exports its factory by name; write setup="'+i+'#<factoryName>". (FAIL-LOUD.)');return{moduleName:i,exportName:o}}function p1(e){for(var t=String(e??"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/[^\n]*/g,"$1"),n=[],r=/\bexport\s+(?:async\s+)?(?:function\*?|const|let|var|class)\s+([A-Za-z_$][\w$]*)/g,i;(i=r.exec(t))!==null;)n.push(i[1]);for(var o=/\bexport\s*\{([^}]*)\}/g,s;(s=o.exec(t))!==null;){var a=s[1];a.split(",").forEach(function(d){var f=d.trim();if(f){var h=/\bas\s+([A-Za-z_$][\w$]*)\s*$/.exec(f);if(h){n.push(h[1]);return}var g=/^([A-Za-z_$][\w$]*)$/.exec(f);g&&n.push(g[1])}})}for(var l=Object.create(null),c=[],u=0;u<n.length;u++)n[u]!=="default"&&(l[n[u]]||(l[n[u]]=!0,c.push(n[u])));return c}function NT(e,t){var n=t||{};if(Object.prototype.hasOwnProperty.call(n,e))return n[e];for(var r=$o(e),i=Object.keys(n),o=0;o<i.length;o++)if($o(i[o])===r)return n[i[o]];throw new Error('[setup-builder] declared setup module "'+e+'" is not a `type="module"` cell in this notebook (known modules: ['+i.join(", ")+"]). (FAIL-LOUD — the declared canvas references an editable in-notebook module cell, never an opaque by-name load.)")}function zT(e,t,n){var r=p1(n);if(r.indexOf(t)===-1)throw new Error('[setup-builder] declared setup export "'+t+'" is not exported by module "'+e+'" (its exports: ['+r.join(", ")+"]). (FAIL-LOUD.)");return t}function BT(e){if(e==null||e==="")return null;var t=/^(\d+)\s*[x×]\s*(\d+)$/.exec(String(e).trim());if(!t)throw new Error('[setup-builder] `stage` must be "<W>x<H>" (e.g. "480x480"); got '+JSON.stringify(e)+". (FAIL-LOUD.)");return{canvasW:parseInt(t[1],10),canvasH:parseInt(t[2],10)}}function UT(e){if(e==null||e==="")return null;var t=Number(String(e).trim());if(!Number.isInteger(t))throw new Error("[setup-builder] `seed` must be an integer; got "+JSON.stringify(e)+". (FAIL-LOUD.)");return t}function HT(e){e=e||{};var t=e.shape==null||e.shape===""?"factory":String(e.shape).trim();if(t!=="factory"&&t!=="recipe")throw new Error('[setup-builder] unknown canvas `shape` "'+e.shape+'" — expected "factory" (a `fn(frqtl, universe, options)` setup export) or "recipe" (a `buildExperiment(exp)` RecipeContext recipe). (FAIL-LOUD — never guess.)');var n=FT(e.setup,t),r=NT(n.moduleName,e.modules),i=BT(e.stage),o=UT(e.seed),s=e.outName||"_run",a=String(s).replace(/[^A-Za-z0-9_$]/g,"_");/^[0-9]/.test(a)&&(a="_"+a);var l=JSON.stringify(e.opts||{}),c=[];i&&(c.push("canvasW: "+i.canvasW),c.push("canvasH: "+i.canvasH)),o!==null&&c.push("seed: "+o);var u=e.render3d?c.concat(["is3D: true"]):c,d="{ "+u.join(", ")+" }",f="",h=e.renderOptions||{};Object.keys(h).forEach(function(w){f+="runner.setRenderOption("+JSON.stringify(w)+", "+JSON.stringify(h[w])+`);
115
+ `});var g="";e.cameraPreset&&(g=`if (runner.cameraControl && typeof runner.cameraControl.setPreset === 'function') {
116
+ runner.cameraControl.setPreset(`+JSON.stringify(e.cameraPreset)+`);
117
+ }
118
+ `);var m,x;if(t==="recipe"){if(m="default",e.opts&&Object.keys(e.opts).length>0)throw new Error('[setup-builder] a recipe-shape canvas ("'+n.moduleName+'") takes NO `opts` — `buildExperiment(exp)` receives a single RecipeContext, not a knob bag (got opts '+JSON.stringify(e.opts)+'). Remove the `opts` attr or use shape="factory". (FAIL-LOUD.)');if(i)throw new Error('[setup-builder] a recipe-shape canvas ("'+n.moduleName+'") takes NO `stage` — the recipe states its world, size included, in its exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg) call; a stage here would be a second size. (FAIL-LOUD.)');var y=c.slice();y.push("deferCanvas: true");var b="{ "+y.join(", ")+" }";x=`const { frqtl } = caps;
119
+ await frqtl.ensureEngine();
120
+ const buildExperiment = (await import('`+n.moduleName+`')).default;
121
+ if (typeof buildExperiment !== 'function') {
122
+ throw new Error('[setup-builder] recipe module "`+n.moduleName+"\" has no default export function — a recipe-shape canvas runs `export default function buildExperiment(exp)` (a classic `window.buildExperiment` tail defines no export). (FAIL-LOUD.)');\n}\nconst exp = frqtl.RecipeContext("+b+`);
123
+ exp.build(buildExperiment);
124
+ const runner = exp.runner;
125
+ `+f+g+"return { "+a+`: runner };
126
+ `}else{if(m=zT(n.moduleName,n.exportName,r),!i)throw new Error('[setup-builder] a factory-shape canvas ("'+n.moduleName+'") needs `stage="<W>x<H>"` — the runner has no default world size. (FAIL-LOUD.)');x=`const { frqtl } = caps;
127
+ await frqtl.ensureEngine();
128
+ const { `+m+" } = await import('"+n.moduleName+`');
129
+ const opts = frqtl.knob('`+m+"', "+l+`);
130
+ const runner = frqtl.FrqtlApp(`+d+`);
131
+ runner.setup(frqtl.carryFactoryStatics((universe, o) => `+m+"(frqtl, universe, o), "+m+`), opts);
132
+ `+f+g+"return { "+a+`: runner };
133
+ `}return{builderCode:x,outName:a,moduleName:n.moduleName,exportName:m,shape:t,usesModulePath:!0}}function WT(e){if(typeof e!="string"||!e.trim())throw new Error('[view-builder] a `view` cell requires a `module="<module-name>#<exportName>"` attribute (got: '+JSON.stringify(e)+"). (FAIL-LOUD.)");var t=e.trim(),n=t.indexOf("#"),r=n===-1?t:t.slice(0,n),i=n===-1?"":t.slice(n+1);if(r=r.trim(),i=i.trim(),!r)throw new Error('[view-builder] `module` declaration "'+e+'" has no module name before the "#". Expected "<module-name>#<exportName>". (FAIL-LOUD.)');return{moduleName:r,exportName:i}}function VT(e,t){var n=t||{};if(Object.prototype.hasOwnProperty.call(n,e))return n[e];for(var r=$o(e),i=Object.keys(n),o=0;o<i.length;o++)if($o(i[o])===r)return n[i[o]];throw new Error('[view-builder] declared view module "'+e+'" is not a `type="module"` cell in this notebook (known modules: ['+i.join(", ")+"]). (FAIL-LOUD — the `view` cell references an editable in-notebook module cell, never an opaque by-name load.)")}function qT(e,t,n){var r=p1(n);if(t){if(r.indexOf(t)===-1)throw new Error('[view-builder] declared view export "'+t+'" is not exported by module "'+e+'" (its exports: ['+r.join(", ")+"]). (FAIL-LOUD.)");return t}if(r.length===1)return r[0];throw r.length===0?new Error('[view-builder] view module "'+e+'" has NO named export — declare `module="'+e+'#<exportName>"` once the module exports a render function. (FAIL-LOUD — never guess.)'):new Error('[view-builder] view module "'+e+'" has MULTIPLE exports ['+r.join(", ")+'] — the `#export` part of `module` is required to pick one (e.g. module="'+e+"#"+r[0]+'"). (FAIL-LOUD — never guess.)')}function $T(e){e=e||{};var t=WT(e.module),n=VT(t.moduleName,e.modules),r=qT(t.moduleName,t.exportName,n),i=e.outName||"_view",o=String(i).replace(/[^A-Za-z0-9_$]/g,"_");/^[0-9]/.test(o)&&(o="_"+o);var s="import { "+r+" } from '"+t.moduleName+`';
134
+ return { `+o+": "+r+` };
135
+ `;return{entryCode:s,outName:o,moduleName:t.moduleName,exportName:r}}function KT(e){e=e||{};var t=e.mount,n=e.handle;if(!n||typeof n.on!="function"||typeof n.call!="function")throw new Error("[view-ctx] requires a frozen ViewHandle with on()/call(). (FAIL-LOUD.)");var r=e.bindings||{},i=typeof e.getBinding=="function"?e.getBinding:function(a){return Object.prototype.hasOwnProperty.call(r,a)?r[a]:void 0},o=typeof e.commit=="function"?e.commit:null;function s(a,l){if(typeof a!="string"||!a)throw new Error("[view-ctx] commit: name must be a non-empty string. (FAIL-LOUD.)");if(!o)throw new Error('[view-ctx] commit("'+a+'"): no commit sink wired for this view (declare a `produces` binding + supply a host commit callback). (FAIL-LOUD.)');ud(l,'view commit("'+a+'") value'),o(a,l)}return{mount:t,handle:n,on:function(a,l){return n.on(a,l)},call:function(a,l){return n.call(a,l)},getBinding:i,commit:s,imports:e.imports||{}}}function YT(e){e=e||{};var t=e.id||"(unnamed)",n=Array.isArray(e.produces)?e.produces:[],r=Array.isArray(e.out)?e.out:[],i=Array.isArray(e.in)?e.in:[];if(e.spec)throw new Error('[frqtl] canvas cell "'+t+'" carries a `spec` ("'+e.spec+'", an opaque factory name) — that path is RETIRED. Declare `setup="<module>#<export>"` on the canvas instead. (FAIL-LOUD.)');var o=r.filter(function(a){return n.indexOf(a)===-1}),s=!!e.bind||i.length>0||o.length>0;if(!e.setup)throw new Error('[frqtl] canvas cell "'+t+'" declares no `setup="<module>#<export>"` '+(s?"but carries a legacy `bind=`/`in=`/`out=` runner reference — that authored builder path is DELETED. Convert it to a declarative canvas. ":"— nothing to render. ")+"(FAIL-LOUD — one developer-facing way: module + declarative canvas.)");if(s)throw new Error('[frqtl] canvas cell "'+t+'" declares `setup` AND carries a legacy `bind=`/`in=`/`out=` runner reference ('+(e.bind?'bind="'+e.bind+'" ':"")+(i.length?"in=["+i.join(", ")+"] ":"")+(o.length?"out=["+o.join(", ")+"] not in produces ":"")+"). A declared canvas needs ONLY `setup`/`opts`/`stage`/`seed` (+ optional `produces`/`produceVia`). The authored runner-building builder is RETIRED. (FAIL-LOUD — never silently prefer one authority.)");return{produces:n.slice()}}var GT="detectorHistogram";async function JT(e,t,n){var r=Array.isArray(t)?t:[];if(!r.length)return[];if(!e||typeof e.call!="function")throw new Error("[produced-bindings] deriveProducedBindings requires a frozen view-handle with call(). (FAIL-LOUD.)");for(var i=typeof n=="string"&&n?n:GT,o=[],s=0;s<r.length;s++){var a=r[s],l=await e.call(i,[]);ud(l,'produces("'+a+'") from realm canvas'),o.push({name:a,value:l})}return o}var XT=600,QT=1e5;function ZT(e,t){if(e==null||e==="")return t;var n=typeof e=="number"?e:Number(String(e).trim());if(!Number.isInteger(n)||n<0)throw new Error('[warmup] produceAfter must be a non-negative integer tick count; got "'+e+'". (FAIL-LOUD — a malformed warmup count would silently empty the produced histogram.)');return n}async function eD(e,t,n,r){if(!e||typeof e.step!="function")throw new Error("[warmup] warmUpRealm requires a frozen view-handle with step(). (FAIL-LOUD.)");for(var i=ZT(t,n),o=isFinite(r)?r:1/0,s=Math.min(i,o),a=0;a<s;a++)await e.step();return s}function tD(e){return!!(e&&e.querySelector&&e.querySelector("[data-egpt-boot-error]"))}function Fx(e){var t=String(e??"").replace(/\r\n/g,`
136
+ `).split(`
137
+ `),n=[],r=!1;function i(f){return f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function o(f){return f=i(f),f=f.replace(/\[([^\]]+)\]\((https?:\/\/[^\s)"<>]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),f=f.replace(/`([^`]+)`/g,"<code>$1</code>"),f=f.replace(/\*\*([^*]+)\*\*/g,"<b>$1</b>"),f=f.replace(/\*([^*]+)\*/g,"<i>$1</i>"),f}for(var s=0;s<t.length;s++){var a=t[s].replace(/^\s+/,function(f){return f.length>8?f.slice(0,8):f}),l=a.trim();if(!l){r&&(n.push("</ul>"),r=!1);continue}var c=/^(#{1,6})\s+(.*)$/.exec(l);if(c){r&&(n.push("</ul>"),r=!1);var u=c[1].length;n.push("<h"+u+">"+o(c[2])+"</h"+u+">");continue}var d=/^[-*]\s+(.*)$/.exec(l);if(d){r||(n.push("<ul>"),r=!0),n.push("<li>"+o(d[1])+"</li>");continue}r&&(n.push("</ul>"),r=!1),n.push("<p>"+o(l)+"</p>")}return r&&n.push("</ul>"),n.join(`
138
+ `)}var Jn={EDIT:"edit",COMMAND_MODE:"command-mode",SELECT_PREV:"select-prev",SELECT_NEXT:"select-next",RUN_ADVANCE:"run-advance",RUN_INPLACE:"run-inplace"};function nD(e,t){if(!e||typeof e.key!="string")return null;var n=e.key,r=!!e.shiftKey,i=!!(e.metaKey||e.ctrlKey);return t?n==="Escape"?Jn.COMMAND_MODE:null:n==="Enter"?i?Jn.RUN_INPLACE:r?Jn.RUN_ADVANCE:Jn.EDIT:n==="Escape"?Jn.COMMAND_MODE:n==="ArrowUp"?Jn.SELECT_PREV:n==="ArrowDown"?Jn.SELECT_NEXT:null}function rD(e,t,n){if(typeof e!="number"||e<0)return 0;if(n==="inplace")return e;var r=e+1;return r>=t?Math.max(0,t-1):r}var Di={JS:"js",REALM:"realm",MARKDOWN_RENDER:"markdown-render",MODULE_ADVANCE:"module-advance"};function iD(e){return e==="markdown"?{leaf:Di.MARKDOWN_RENDER,executes:!1}:e==="module"?{leaf:Di.MODULE_ADVANCE,executes:!1}:e==="canvas"||e==="chart"||e==="view"?{leaf:Di.REALM,executes:!0}:{leaf:Di.JS,executes:!0}}var oD=2e3,bm=["info","warn","error","pass","fail"],xm={info:"log-info",warn:"log-warn",error:"log-error",pass:"log-test-pass",fail:"log-test-fail"},m1={info:"INFO",warn:"WARN",error:"ERR",pass:"PASS",fail:"FAIL"},Ih=typeof window<"u"&&window.console?{log:window.console.log.bind(window.console),warn:window.console.warn.bind(window.console),error:window.console.error.bind(window.console)}:null,Nx=!1;function sD(){if(!Nx){Nx=!0;var e=aD("console.css");if(e){var t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}else{var n=document.createElement("style");n.textContent=lD,document.head.appendChild(n)}}}function aD(e){for(var t=document.querySelectorAll("script[src]"),n=0;n<t.length;n++){var r=t[n].getAttribute("src")||"";if(r.indexOf("console-output/index.js")!==-1||r.indexOf("console-output\\index.js")!==-1){var i=r.substring(0,r.lastIndexOf("/")+1);return i+e}}return null}var lD=[".egpt-console{display:flex;flex-direction:column;height:100%;background:#1e1e1e;","color:#d4d4d4;font-family:ui-monospace,Menlo,Consolas,monospace;overflow:hidden}",".egpt-console__toolbar{flex:0 0 auto;display:flex;align-items:center;gap:4px;","padding:4px 8px;background:#2d2d2d;border-bottom:1px solid #444}",".egpt-console__title{font-size:11px;font-weight:bold;text-transform:uppercase;","color:#aaa;margin-right:8px}",".egpt-console__logs{flex:1 1 auto;overflow-y:auto;padding:8px 12px;","font-size:13px;line-height:1.55}",".log-line{display:flex;gap:8px;margin-bottom:3px;white-space:pre-wrap;word-break:break-all}",".log-line.egpt-hidden{display:none}",".log-line__ts{flex:0 0 auto;color:#555;font-size:11px;line-height:1.7}",".log-line__badge{flex:0 0 auto;font-size:10px;font-weight:bold;padding:1px 4px;","border-radius:2px;line-height:1.9;text-transform:uppercase}",".log-line__text{flex:1 1 auto}",".log-info .log-line__text{color:#d4d4d4}",".log-warn .log-line__text{color:#cca700}",".log-error .log-line__text,.log-test-fail .log-line__text{color:#f44336;font-weight:bold}",".log-test-pass .log-line__text{color:#4caf50;font-weight:bold}",".egpt-console__filter-btn,.egpt-console__clear-btn{padding:1px 7px;font-size:11px;","border:1px solid #555;border-radius:3px;background:transparent;color:#aaa;","cursor:pointer;font-family:inherit;line-height:1.6}",".egpt-console__filter-btn.active,.egpt-console__filter-btn:hover,",".egpt-console__clear-btn:hover{background:#3a3a3a;color:#d4d4d4}"].join("");function cD(){var e=new Date,t=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),r=String(e.getSeconds()).padStart(2,"0");return t+":"+n+":"+r}function ao(e){e=e||{},this._mountEl=e.mountEl||null,this._logsEl=null,this._lineCount=0,this._domLineCount=0,this._busHandlers=null,this._activeFilters={};for(var t=0;t<bm.length;t++)this._activeFilters[bm[t]]=!0;sD(),this._build()}ao.prototype._build=function(){var e=this._mountEl;if(e){e.innerHTML="",e.className=(e.className?e.className+" ":"")+"egpt-console";var t=document.createElement("div");t.className="egpt-console__toolbar";var n=document.createElement("span");n.className="egpt-console__title",n.textContent="Output / Console",t.appendChild(n);var r=document.createElement("div");r.className="egpt-console__filters";var i=this;bm.forEach(function(d){var f=document.createElement("button");f.className="egpt-console__filter-btn active",f.setAttribute("data-level",d),f.setAttribute("title","Toggle "+d+" messages"),f.textContent=m1[d]||d.toUpperCase(),f.addEventListener("click",function(){i._toggleFilter(d,f)}),r.appendChild(f)}),t.appendChild(r);var o=document.createElement("span");o.className="egpt-console__spacer",t.appendChild(o);var s=document.createElement("button");s.className="egpt-console__clear-btn",s.setAttribute("title","Clear console"),s.textContent="Clear",s.addEventListener("click",function(){i.clear()}),t.appendChild(s),e.appendChild(t);var a=document.createElement("div");a.className="egpt-console__logs",e.appendChild(a),this._logsEl=a,this._toolbar=t,this._filterBtns={};for(var l=r.querySelectorAll(".egpt-console__filter-btn"),c=0;c<l.length;c++){var u=l[c].getAttribute("data-level");this._filterBtns[u]=l[c]}}};ao.prototype._toggleFilter=function(e,t){var n=!this._activeFilters[e];this._activeFilters[e]=n,n?t.classList.add("active"):t.classList.remove("active");for(var r=xm[e]||"log-"+e,i=this._logsEl?this._logsEl.querySelectorAll("."+r):[],o=0;o<i.length;o++)n?i[o].classList.remove("egpt-hidden"):i[o].classList.add("egpt-hidden")};ao.prototype._pruneIfNeeded=function(){if(this._logsEl)for(;this._domLineCount>oD;){var e=this._logsEl.firstChild;if(!e)break;this._logsEl.removeChild(e),this._domLineCount--}};ao.prototype.log=function(e,t){typeof e!="string"&&(e="info"),typeof t!="string"&&(t=String(t));var n=xm[e]?e:"info",r=xm[n];this._lineCount++;var i=document.createElement("div");i.className="log-line "+r;var o=document.createElement("span");o.className="log-line__ts",o.textContent=cD(),i.appendChild(o);var s=document.createElement("span");s.className="log-line__badge",s.textContent=m1[n]||n.toUpperCase(),i.appendChild(s);var a=document.createElement("span");if(a.className="log-line__text",a.textContent=t,i.appendChild(a),this._activeFilters[n]||i.classList.add("egpt-hidden"),this._logsEl){this._logsEl.appendChild(i),this._domLineCount++,this._pruneIfNeeded();var l=this._logsEl,c=l.scrollHeight-l.scrollTop-l.clientHeight<40;c&&(l.scrollTop=l.scrollHeight)}var u=n==="error"||n==="fail"?"error":n==="warn"?"warn":"log";Ih&&Ih[u]&&Ih[u]("[ConsolePane]["+n+"]",t)};ao.prototype.clear=function(){this._logsEl&&(this._logsEl.innerHTML="",this._domLineCount=0),this._lineCount=0};ao.prototype.subscribe=function(e){var t=e||Ee,n=this;if(!t){window.console&&window.console.warn&&window.console.warn("[ConsolePane] subscribe() called but no bus available");return}this._busHandlers&&(t.off("console:write",this._busHandlers.write),t.off("console:clear",this._busHandlers.clear),t.off("run:result",this._busHandlers.result),t.off("engine:error",this._busHandlers.engErr)),this._busHandlers={write:function(r){var i=r&&r.level?r.level:"info",o=r&&r.text!=null?String(r.text):"";n.log(i,o)},clear:function(){n.clear()},result:function(r){var i=r&&r.source?r.source:"?";if(r&&r.ok)n.log("pass","["+i+"] Run completed OK.");else{var o=r&&r.error?r.error:"unknown error";n.log("fail","["+i+"] Run failed: "+o)}},engErr:function(r){var i=r&&r.message?r.message:String(r);n.log("error","[engine] "+i)}},t.on("console:write",this._busHandlers.write),t.on("console:clear",this._busHandlers.clear),t.on("run:result",this._busHandlers.result),t.on("engine:error",this._busHandlers.engErr)};typeof window<"u"&&(window.ConsolePane=ao);/*!
139
+ * @kurkle/color v0.3.4
140
+ * https://github.com/kurkle/color#readme
141
+ * (c) 2024 Jukka Kurkela
142
+ * Released under the MIT License
143
+ */function oc(e){return e+.5|0}const Ii=(e,t,n)=>Math.max(Math.min(e,n),t);function Va(e){return Ii(oc(e*2.55),0,255)}function Gi(e){return Ii(oc(e*255),0,255)}function ti(e){return Ii(oc(e/2.55)/100,0,1)}function zx(e){return Ii(oc(e*100),0,100)}const ar={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},wm=[..."0123456789ABCDEF"],uD=e=>wm[e&15],dD=e=>wm[(e&240)>>4]+wm[e&15],Yc=e=>(e&240)>>4===(e&15),fD=e=>Yc(e.r)&&Yc(e.g)&&Yc(e.b)&&Yc(e.a);function hD(e){var t=e.length,n;return e[0]==="#"&&(t===4||t===5?n={r:255&ar[e[1]]*17,g:255&ar[e[2]]*17,b:255&ar[e[3]]*17,a:t===5?ar[e[4]]*17:255}:(t===7||t===9)&&(n={r:ar[e[1]]<<4|ar[e[2]],g:ar[e[3]]<<4|ar[e[4]],b:ar[e[5]]<<4|ar[e[6]],a:t===9?ar[e[7]]<<4|ar[e[8]]:255})),n}const pD=(e,t)=>e<255?t(e):"";function mD(e){var t=fD(e)?uD:dD;return e?"#"+t(e.r)+t(e.g)+t(e.b)+pD(e.a,t):void 0}const gD=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function g1(e,t,n){const r=t*Math.min(n,1-n),i=(o,s=(o+e/30)%12)=>n-r*Math.max(Math.min(s-3,9-s,1),-1);return[i(0),i(8),i(4)]}function vD(e,t,n){const r=(i,o=(i+e/60)%6)=>n-n*t*Math.max(Math.min(o,4-o,1),0);return[r(5),r(3),r(1)]}function yD(e,t,n){const r=g1(e,1,.5);let i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function bD(e,t,n,r,i){return e===i?(t-n)/r+(t<n?6:0):t===i?(n-e)/r+2:(e-t)/r+4}function sv(e){const n=e.r/255,r=e.g/255,i=e.b/255,o=Math.max(n,r,i),s=Math.min(n,r,i),a=(o+s)/2;let l,c,u;return o!==s&&(u=o-s,c=a>.5?u/(2-o-s):u/(o+s),l=bD(n,r,i,u,o),l=l*60+.5),[l|0,c||0,a]}function av(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(Gi)}function lv(e,t,n){return av(g1,e,t,n)}function xD(e,t,n){return av(yD,e,t,n)}function wD(e,t,n){return av(vD,e,t,n)}function v1(e){return(e%360+360)%360}function _D(e){const t=gD.exec(e);let n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?Va(+t[5]):Gi(+t[5]));const i=v1(+t[2]),o=+t[3]/100,s=+t[4]/100;return t[1]==="hwb"?r=xD(i,o,s):t[1]==="hsv"?r=wD(i,o,s):r=lv(i,o,s),{r:r[0],g:r[1],b:r[2],a:n}}function kD(e,t){var n=sv(e);n[0]=v1(n[0]+t),n=lv(n),e.r=n[0],e.g=n[1],e.b=n[2]}function SD(e){if(!e)return;const t=sv(e),n=t[0],r=zx(t[1]),i=zx(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${ti(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}const Bx={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},Ux={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function ED(){const e={},t=Object.keys(Ux),n=Object.keys(Bx);let r,i,o,s,a;for(r=0;r<t.length;r++){for(s=a=t[r],i=0;i<n.length;i++)o=n[i],a=a.replace(o,Bx[o]);o=parseInt(Ux[s],16),e[a]=[o>>16&255,o>>8&255,o&255]}return e}let Gc;function OD(e){Gc||(Gc=ED(),Gc.transparent=[0,0,0,0]);const t=Gc[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const CD=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function jD(e){const t=CD.exec(e);let n=255,r,i,o;if(t){if(t[7]!==r){const s=+t[7];n=t[8]?Va(s):Ii(s*255,0,255)}return r=+t[1],i=+t[3],o=+t[5],r=255&(t[2]?Va(r):Ii(r,0,255)),i=255&(t[4]?Va(i):Ii(i,0,255)),o=255&(t[6]?Va(o):Ii(o,0,255)),{r,g:i,b:o,a:n}}}function RD(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${ti(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}const Fh=e=>e<=.0031308?e*12.92:Math.pow(e,1/2.4)*1.055-.055,ps=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4);function LD(e,t,n){const r=ps(ti(e.r)),i=ps(ti(e.g)),o=ps(ti(e.b));return{r:Gi(Fh(r+n*(ps(ti(t.r))-r))),g:Gi(Fh(i+n*(ps(ti(t.g))-i))),b:Gi(Fh(o+n*(ps(ti(t.b))-o))),a:e.a+n*(t.a-e.a)}}function Jc(e,t,n){if(e){let r=sv(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=lv(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function y1(e,t){return e&&Object.assign(t||{},e)}function Hx(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=Gi(e[3]))):(t=y1(e,{r:0,g:0,b:0,a:1}),t.a=Gi(t.a)),t}function AD(e){return e.charAt(0)==="r"?jD(e):_D(e)}class Bl{constructor(t){if(t instanceof Bl)return t;const n=typeof t;let r;n==="object"?r=Hx(t):n==="string"&&(r=hD(t)||OD(t)||AD(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var t=y1(this._rgb);return t&&(t.a=ti(t.a)),t}set rgb(t){this._rgb=Hx(t)}rgbString(){return this._valid?RD(this._rgb):void 0}hexString(){return this._valid?mD(this._rgb):void 0}hslString(){return this._valid?SD(this._rgb):void 0}mix(t,n){if(t){const r=this.rgb,i=t.rgb;let o;const s=n===o?.5:n,a=2*s-1,l=r.a-i.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-c,r.r=255&c*r.r+o*i.r+.5,r.g=255&c*r.g+o*i.g+.5,r.b=255&c*r.b+o*i.b+.5,r.a=s*r.a+(1-s)*i.a,this.rgb=r}return this}interpolate(t,n){return t&&(this._rgb=LD(this._rgb,t._rgb,n)),this}clone(){return new Bl(this.rgb)}alpha(t){return this._rgb.a=Gi(t),this}clearer(t){const n=this._rgb;return n.a*=1-t,this}greyscale(){const t=this._rgb,n=oc(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=n,this}opaquer(t){const n=this._rgb;return n.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return Jc(this._rgb,2,t),this}darken(t){return Jc(this._rgb,2,-t),this}saturate(t){return Jc(this._rgb,1,t),this}desaturate(t){return Jc(this._rgb,1,-t),this}rotate(t){return kD(this._rgb,t),this}}/*!
144
+ * Chart.js v4.5.1
145
+ * https://www.chartjs.org
146
+ * (c) 2025 Chart.js Contributors
147
+ * Released under the MIT License
148
+ */function Jr(){}const PD=(()=>{let e=0;return()=>e++})();function Ne(e){return e==null}function wt(e){if(Array.isArray&&Array.isArray(e))return!0;const t=Object.prototype.toString.call(e);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function He(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function It(e){return(typeof e=="number"||e instanceof Number)&&isFinite(+e)}function Yn(e,t){return It(e)?e:t}function Le(e,t){return typeof e>"u"?t:e}const MD=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100:+e/t,b1=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100*t:+e;function dt(e,t,n){if(e&&typeof e.call=="function")return e.apply(n,t)}function tt(e,t,n,r){let i,o,s;if(wt(e))for(o=e.length,i=0;i<o;i++)t.call(n,e[i],i);else if(He(e))for(s=Object.keys(e),o=s.length,i=0;i<o;i++)t.call(n,e[s[i]],s[i])}function Sd(e,t){let n,r,i,o;if(!e||!t||e.length!==t.length)return!1;for(n=0,r=e.length;n<r;++n)if(i=e[n],o=t[n],i.datasetIndex!==o.datasetIndex||i.index!==o.index)return!1;return!0}function Ed(e){if(wt(e))return e.map(Ed);if(He(e)){const t=Object.create(null),n=Object.keys(e),r=n.length;let i=0;for(;i<r;++i)t[n[i]]=Ed(e[n[i]]);return t}return e}function x1(e){return["__proto__","prototype","constructor"].indexOf(e)===-1}function TD(e,t,n,r){if(!x1(e))return;const i=t[e],o=n[e];He(i)&&He(o)?Ul(i,o,r):t[e]=Ed(o)}function Ul(e,t,n){const r=wt(t)?t:[t],i=r.length;if(!He(e))return e;n=n||{};const o=n.merger||TD;let s;for(let a=0;a<i;++a){if(s=r[a],!He(s))continue;const l=Object.keys(s);for(let c=0,u=l.length;c<u;++c)o(l[c],e,s,n)}return e}function ll(e,t){return Ul(e,t,{merger:DD})}function DD(e,t,n){if(!x1(e))return;const r=t[e],i=n[e];He(r)&&He(i)?ll(r,i):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=Ed(i))}const Wx={"":e=>e,x:e=>e.x,y:e=>e.y};function ID(e){const t=e.split("."),n=[];let r="";for(const i of t)r+=i,r.endsWith("\\")?r=r.slice(0,-1)+".":(n.push(r),r="");return n}function FD(e){const t=ID(e);return n=>{for(const r of t){if(r==="")break;n=n&&n[r]}return n}}function to(e,t){return(Wx[t]||(Wx[t]=FD(t)))(e)}function cv(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Hl=e=>typeof e<"u",no=e=>typeof e=="function",Vx=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0};function ND(e){return e.type==="mouseup"||e.type==="click"||e.type==="contextmenu"}const Ye=Math.PI,yt=2*Ye,zD=yt+Ye,Od=Number.POSITIVE_INFINITY,BD=Ye/180,Bt=Ye/2,bo=Ye/4,qx=Ye*2/3,Fi=Math.log10,Vr=Math.sign;function cl(e,t,n){return Math.abs(e-t)<n}function $x(e){const t=Math.round(e);e=cl(e,t,e/1e3)?t:e;const n=Math.pow(10,Math.floor(Fi(e))),r=e/n;return(r<=1?1:r<=2?2:r<=5?5:10)*n}function UD(e){const t=[],n=Math.sqrt(e);let r;for(r=1;r<n;r++)e%r===0&&(t.push(r),t.push(e/r));return n===(n|0)&&t.push(n),t.sort((i,o)=>i-o).pop(),t}function HD(e){return typeof e=="symbol"||typeof e=="object"&&e!==null&&!(Symbol.toPrimitive in e||"toString"in e||"valueOf"in e)}function na(e){return!HD(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function WD(e,t){const n=Math.round(e);return n-t<=e&&n+t>=e}function w1(e,t,n){let r,i,o;for(r=0,i=e.length;r<i;r++)o=e[r][n],isNaN(o)||(t.min=Math.min(t.min,o),t.max=Math.max(t.max,o))}function Er(e){return e*(Ye/180)}function uv(e){return e*(180/Ye)}function Kx(e){if(!It(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function _1(e,t){const n=t.x-e.x,r=t.y-e.y,i=Math.sqrt(n*n+r*r);let o=Math.atan2(r,n);return o<-.5*Ye&&(o+=yt),{angle:o,distance:i}}function _m(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function VD(e,t){return(e-t+zD)%yt-Ye}function vn(e){return(e%yt+yt)%yt}function Wl(e,t,n,r){const i=vn(e),o=vn(t),s=vn(n),a=vn(o-i),l=vn(s-i),c=vn(i-o),u=vn(i-s);return i===o||i===s||r&&o===s||a>l&&c<u}function Zt(e,t,n){return Math.max(t,Math.min(n,e))}function qD(e){return Zt(e,-32768,32767)}function si(e,t,n,r=1e-6){return e>=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function dv(e,t,n){n=n||(s=>e[s]<t);let r=e.length-1,i=0,o;for(;r-i>1;)o=i+r>>1,n(o)?i=o:r=o;return{lo:i,hi:r}}const ai=(e,t,n,r)=>dv(e,n,r?i=>{const o=e[i][t];return o<n||o===n&&e[i+1][t]===n}:i=>e[i][t]<n),$D=(e,t,n)=>dv(e,n,r=>e[r][t]>=n);function KD(e,t,n){let r=0,i=e.length;for(;r<i&&e[r]<t;)r++;for(;i>r&&e[i-1]>n;)i--;return r>0||i<e.length?e.slice(r,i):e}const k1=["push","pop","shift","splice","unshift"];function YD(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),k1.forEach(n=>{const r="_onData"+cv(n),i=e[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value(...o){const s=i.apply(this,o);return e._chartjs.listeners.forEach(a=>{typeof a[r]=="function"&&a[r](...o)}),s}})})}function Yx(e,t){const n=e._chartjs;if(!n)return;const r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&(k1.forEach(o=>{delete e[o]}),delete e._chartjs)}function S1(e){const t=new Set(e);return t.size===e.length?e:Array.from(t)}const E1=function(){return typeof window>"u"?function(e){return e()}:window.requestAnimationFrame}();function O1(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,E1.call(window,()=>{r=!1,e.apply(t,n)}))}}function GD(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}const fv=e=>e==="start"?"left":e==="end"?"right":"center",pn=(e,t,n)=>e==="start"?t:e==="end"?n:(t+n)/2,JD=(e,t,n,r)=>e===(r?"left":"right")?n:e==="center"?(t+n)/2:t;function C1(e,t,n){const r=t.length;let i=0,o=r;if(e._sorted){const{iScale:s,vScale:a,_parsed:l}=e,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=s.axis,{min:d,max:f,minDefined:h,maxDefined:g}=s.getUserBounds();if(h){if(i=Math.min(ai(l,u,d).lo,n?r:ai(t,u,s.getPixelForValue(d)).lo),c){const m=l.slice(0,i+1).reverse().findIndex(x=>!Ne(x[a.axis]));i-=Math.max(0,m)}i=Zt(i,0,r-1)}if(g){let m=Math.max(ai(l,s.axis,f,!0).hi+1,n?0:ai(t,u,s.getPixelForValue(f),!0).hi+1);if(c){const x=l.slice(m-1).findIndex(y=>!Ne(y[a.axis]));m+=Math.max(0,x)}o=Zt(m,i,r)-i}else o=r-i}return{start:i,count:o}}function j1(e){const{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;const o=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),o}const Xc=e=>e===0||e===1,Gx=(e,t,n)=>-(Math.pow(2,10*(e-=1))*Math.sin((e-t)*yt/n)),Jx=(e,t,n)=>Math.pow(2,-10*e)*Math.sin((e-t)*yt/n)+1,ul={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>(e-=1)*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-((e-=1)*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>(e-=1)*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*Bt)+1,easeOutSine:e=>Math.sin(e*Bt),easeInOutSine:e=>-.5*(Math.cos(Ye*e)-1),easeInExpo:e=>e===0?0:Math.pow(2,10*(e-1)),easeOutExpo:e=>e===1?1:-Math.pow(2,-10*e)+1,easeInOutExpo:e=>Xc(e)?e:e<.5?.5*Math.pow(2,10*(e*2-1)):.5*(-Math.pow(2,-10*(e*2-1))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1-(e-=1)*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>Xc(e)?e:Gx(e,.075,.3),easeOutElastic:e=>Xc(e)?e:Jx(e,.075,.3),easeInOutElastic(e){return Xc(e)?e:e<.5?.5*Gx(e*2,.1125,.45):.5+.5*Jx(e*2-1,.1125,.45)},easeInBack(e){return e*e*((1.70158+1)*e-1.70158)},easeOutBack(e){return(e-=1)*e*((1.70158+1)*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-ul.easeOutBounce(1-e),easeOutBounce(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},easeInOutBounce:e=>e<.5?ul.easeInBounce(e*2)*.5:ul.easeOutBounce(e*2-1)*.5+.5};function hv(e){if(e&&typeof e=="object"){const t=e.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Xx(e){return hv(e)?e:new Bl(e)}function Nh(e){return hv(e)?e:new Bl(e).saturate(.5).darken(.1).hexString()}const XD=["x","y","borderWidth","radius","tension"],QD=["color","borderColor","backgroundColor"];function ZD(e){e.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),e.set("animations",{colors:{type:"color",properties:QD},numbers:{type:"number",properties:XD}}),e.describe("animations",{_fallback:"animation"}),e.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>t|0}}}})}function eI(e){e.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const Qx=new Map;function tI(e,t){t=t||{};const n=e+JSON.stringify(t);let r=Qx.get(n);return r||(r=new Intl.NumberFormat(e,t),Qx.set(n,r)),r}function sc(e,t,n){return tI(t,n).format(e)}const R1={values(e){return wt(e)?e:""+e},numeric(e,t,n){if(e===0)return"0";const r=this.chart.options.locale;let i,o=e;if(n.length>1){const c=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(c<1e-4||c>1e15)&&(i="scientific"),o=nI(e,n)}const s=Fi(Math.abs(o)),a=isNaN(s)?1:Math.max(Math.min(-1*Math.floor(s),20),0),l={notation:i,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),sc(e,r,l)},logarithmic(e,t,n){if(e===0)return"0";const r=n[t].significand||e/Math.pow(10,Math.floor(Fi(e)));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?R1.numeric.call(this,e,t,n):""}};function nI(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var pf={formatters:R1};function rI(e){e.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,n)=>n.lineWidth,tickColor:(t,n)=>n.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:pf.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),e.route("scale.ticks","color","","color"),e.route("scale.grid","color","","borderColor"),e.route("scale.border","color","","borderColor"),e.route("scale.title","color","","color"),e.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),e.describe("scales",{_fallback:"scale"}),e.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}const Go=Object.create(null),km=Object.create(null);function dl(e,t){if(!t)return e;const n=t.split(".");for(let r=0,i=n.length;r<i;++r){const o=n[r];e=e[o]||(e[o]=Object.create(null))}return e}function zh(e,t,n){return typeof t=="string"?Ul(dl(e,t),n):Ul(dl(e,""),t)}class iI{constructor(t,n){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=r=>r.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(r,i)=>Nh(i.backgroundColor),this.hoverBorderColor=(r,i)=>Nh(i.borderColor),this.hoverColor=(r,i)=>Nh(i.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(n)}set(t,n){return zh(this,t,n)}get(t){return dl(this,t)}describe(t,n){return zh(km,t,n)}override(t,n){return zh(Go,t,n)}route(t,n,r,i){const o=dl(this,t),s=dl(this,r),a="_"+n;Object.defineProperties(o,{[a]:{value:o[n],writable:!0},[n]:{enumerable:!0,get(){const l=this[a],c=s[i];return He(l)?Object.assign({},c,l):Le(l,c)},set(l){this[a]=l}}})}apply(t){t.forEach(n=>n(this))}}var _t=new iI({_scriptable:e=>!e.startsWith("on"),_indexable:e=>e!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[ZD,eI,rI]);function oI(e){return!e||Ne(e.size)||Ne(e.family)?null:(e.style?e.style+" ":"")+(e.weight?e.weight+" ":"")+e.size+"px "+e.family}function Cd(e,t,n,r,i){let o=t[i];return o||(o=t[i]=e.measureText(i).width,n.push(i)),o>r&&(r=o),r}function sI(e,t,n,r){r=r||{};let i=r.data=r.data||{},o=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},o=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let s=0;const a=n.length;let l,c,u,d,f;for(l=0;l<a;l++)if(d=n[l],d!=null&&!wt(d))s=Cd(e,i,o,s,d);else if(wt(d))for(c=0,u=d.length;c<u;c++)f=d[c],f!=null&&!wt(f)&&(s=Cd(e,i,o,s,f));e.restore();const h=o.length/2;if(h>n.length){for(l=0;l<h;l++)delete i[o[l]];o.splice(0,h)}return s}function xo(e,t,n){const r=e.currentDevicePixelRatio,i=n!==0?Math.max(n/2,.5):0;return Math.round((t-i)*r)/r+i}function Zx(e,t){!t&&!e||(t=t||e.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function Sm(e,t,n,r){L1(e,t,n,r,null)}function L1(e,t,n,r,i){let o,s,a,l,c,u,d,f;const h=t.pointStyle,g=t.rotation,m=t.radius;let x=(g||0)*BD;if(h&&typeof h=="object"&&(o=h.toString(),o==="[object HTMLImageElement]"||o==="[object HTMLCanvasElement]")){e.save(),e.translate(n,r),e.rotate(x),e.drawImage(h,-h.width/2,-h.height/2,h.width,h.height),e.restore();return}if(!(isNaN(m)||m<=0)){switch(e.beginPath(),h){default:i?e.ellipse(n,r,i/2,m,0,0,yt):e.arc(n,r,m,0,yt),e.closePath();break;case"triangle":u=i?i/2:m,e.moveTo(n+Math.sin(x)*u,r-Math.cos(x)*m),x+=qx,e.lineTo(n+Math.sin(x)*u,r-Math.cos(x)*m),x+=qx,e.lineTo(n+Math.sin(x)*u,r-Math.cos(x)*m),e.closePath();break;case"rectRounded":c=m*.516,l=m-c,s=Math.cos(x+bo)*l,d=Math.cos(x+bo)*(i?i/2-c:l),a=Math.sin(x+bo)*l,f=Math.sin(x+bo)*(i?i/2-c:l),e.arc(n-d,r-a,c,x-Ye,x-Bt),e.arc(n+f,r-s,c,x-Bt,x),e.arc(n+d,r+a,c,x,x+Bt),e.arc(n-f,r+s,c,x+Bt,x+Ye),e.closePath();break;case"rect":if(!g){l=Math.SQRT1_2*m,u=i?i/2:l,e.rect(n-u,r-l,2*u,2*l);break}x+=bo;case"rectRot":d=Math.cos(x)*(i?i/2:m),s=Math.cos(x)*m,a=Math.sin(x)*m,f=Math.sin(x)*(i?i/2:m),e.moveTo(n-d,r-a),e.lineTo(n+f,r-s),e.lineTo(n+d,r+a),e.lineTo(n-f,r+s),e.closePath();break;case"crossRot":x+=bo;case"cross":d=Math.cos(x)*(i?i/2:m),s=Math.cos(x)*m,a=Math.sin(x)*m,f=Math.sin(x)*(i?i/2:m),e.moveTo(n-d,r-a),e.lineTo(n+d,r+a),e.moveTo(n+f,r-s),e.lineTo(n-f,r+s);break;case"star":d=Math.cos(x)*(i?i/2:m),s=Math.cos(x)*m,a=Math.sin(x)*m,f=Math.sin(x)*(i?i/2:m),e.moveTo(n-d,r-a),e.lineTo(n+d,r+a),e.moveTo(n+f,r-s),e.lineTo(n-f,r+s),x+=bo,d=Math.cos(x)*(i?i/2:m),s=Math.cos(x)*m,a=Math.sin(x)*m,f=Math.sin(x)*(i?i/2:m),e.moveTo(n-d,r-a),e.lineTo(n+d,r+a),e.moveTo(n+f,r-s),e.lineTo(n-f,r+s);break;case"line":s=i?i/2:Math.cos(x)*m,a=Math.sin(x)*m,e.moveTo(n-s,r-a),e.lineTo(n+s,r+a);break;case"dash":e.moveTo(n,r),e.lineTo(n+Math.cos(x)*(i?i/2:m),r+Math.sin(x)*m);break;case!1:e.closePath();break}e.fill(),t.borderWidth>0&&e.stroke()}}function li(e,t,n){return n=n||.5,!t||e&&e.x>t.left-n&&e.x<t.right+n&&e.y>t.top-n&&e.y<t.bottom+n}function mf(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function gf(e){e.restore()}function aI(e,t,n,r,i){if(!t)return e.lineTo(n.x,n.y);if(i==="middle"){const o=(t.x+n.x)/2;e.lineTo(o,t.y),e.lineTo(o,n.y)}else i==="after"!=!!r?e.lineTo(t.x,n.y):e.lineTo(n.x,t.y);e.lineTo(n.x,n.y)}function lI(e,t,n,r){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(r?t.cp1x:t.cp2x,r?t.cp1y:t.cp2y,r?n.cp2x:n.cp1x,r?n.cp2y:n.cp1y,n.x,n.y)}function cI(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),Ne(t.rotation)||e.rotate(t.rotation),t.color&&(e.fillStyle=t.color),t.textAlign&&(e.textAlign=t.textAlign),t.textBaseline&&(e.textBaseline=t.textBaseline)}function uI(e,t,n,r,i){if(i.strikethrough||i.underline){const o=e.measureText(r),s=t-o.actualBoundingBoxLeft,a=t+o.actualBoundingBoxRight,l=n-o.actualBoundingBoxAscent,c=n+o.actualBoundingBoxDescent,u=i.strikethrough?(l+c)/2:c;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=i.decorationWidth||2,e.moveTo(s,u),e.lineTo(a,u),e.stroke()}}function dI(e,t){const n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function Jo(e,t,n,r,i,o={}){const s=wt(t)?t:[t],a=o.strokeWidth>0&&o.strokeColor!=="";let l,c;for(e.save(),e.font=i.string,cI(e,o),l=0;l<s.length;++l)c=s[l],o.backdrop&&dI(e,o.backdrop),a&&(o.strokeColor&&(e.strokeStyle=o.strokeColor),Ne(o.strokeWidth)||(e.lineWidth=o.strokeWidth),e.strokeText(c,n,r,o.maxWidth)),e.fillText(c,n,r,o.maxWidth),uI(e,n,r,c,o),r+=Number(i.lineHeight);e.restore()}function Vl(e,t){const{x:n,y:r,w:i,h:o,radius:s}=t;e.arc(n+s.topLeft,r+s.topLeft,s.topLeft,1.5*Ye,Ye,!0),e.lineTo(n,r+o-s.bottomLeft),e.arc(n+s.bottomLeft,r+o-s.bottomLeft,s.bottomLeft,Ye,Bt,!0),e.lineTo(n+i-s.bottomRight,r+o),e.arc(n+i-s.bottomRight,r+o-s.bottomRight,s.bottomRight,Bt,0,!0),e.lineTo(n+i,r+s.topRight),e.arc(n+i-s.topRight,r+s.topRight,s.topRight,0,-Bt,!0),e.lineTo(n+s.topLeft,r)}const fI=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,hI=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function pI(e,t){const n=(""+e).match(fI);if(!n||n[1]==="normal")return t*1.2;switch(e=+n[2],n[3]){case"px":return e;case"%":e/=100;break}return t*e}const mI=e=>+e||0;function pv(e,t){const n={},r=He(t),i=r?Object.keys(t):t,o=He(e)?r?s=>Le(e[s],e[t[s]]):s=>e[s]:()=>e;for(const s of i)n[s]=mI(o(s));return n}function A1(e){return pv(e,{top:"y",right:"x",bottom:"y",left:"x"})}function No(e){return pv(e,["topLeft","topRight","bottomLeft","bottomRight"])}function wn(e){const t=A1(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function Gt(e,t){e=e||{},t=t||_t.font;let n=Le(e.size,t.size);typeof n=="string"&&(n=parseInt(n,10));let r=Le(e.style,t.style);r&&!(""+r).match(hI)&&(console.warn('Invalid font style specified: "'+r+'"'),r=void 0);const i={family:Le(e.family,t.family),lineHeight:pI(Le(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:Le(e.weight,t.weight),string:""};return i.string=oI(i),i}function qa(e,t,n,r){let i,o,s;for(i=0,o=e.length;i<o;++i)if(s=e[i],s!==void 0&&s!==void 0)return s}function gI(e,t,n){const{min:r,max:i}=e,o=b1(t,(i-r)/2),s=(a,l)=>n&&a===0?0:a+l;return{min:s(r,-Math.abs(o)),max:s(i,o)}}function lo(e,t){return Object.assign(Object.create(e),t)}function mv(e,t=[""],n,r,i=()=>e[0]){const o=n||e;typeof r>"u"&&(r=D1("_fallback",e));const s={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:e,_rootScopes:o,_fallback:r,_getTarget:i,override:a=>mv([a,...e],t,o,r)};return new Proxy(s,{deleteProperty(a,l){return delete a[l],delete a._keys,delete e[0][l],!0},get(a,l){return M1(a,l,()=>SI(l,t,e,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(a,l){return tw(a).includes(l)},ownKeys(a){return tw(a)},set(a,l,c){const u=a._storage||(a._storage=i());return a[l]=u[l]=c,delete a._keys,!0}})}function ra(e,t,n,r){const i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:P1(e,r),setContext:o=>ra(e,o,n,r),override:o=>ra(e.override(o),t,n,r)};return new Proxy(i,{deleteProperty(o,s){return delete o[s],delete e[s],!0},get(o,s,a){return M1(o,s,()=>yI(o,s,a))},getOwnPropertyDescriptor(o,s){return o._descriptors.allKeys?Reflect.has(e,s)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,s)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(o,s){return Reflect.has(e,s)},ownKeys(){return Reflect.ownKeys(e)},set(o,s,a){return e[s]=a,delete o[s],!0}})}function P1(e,t={scriptable:!0,indexable:!0}){const{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:no(n)?n:()=>n,isIndexable:no(r)?r:()=>r}}const vI=(e,t)=>e?e+cv(t):t,gv=(e,t)=>He(t)&&e!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function M1(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t==="constructor")return e[t];const r=n();return e[t]=r,r}function yI(e,t,n){const{_proxy:r,_context:i,_subProxy:o,_descriptors:s}=e;let a=r[t];return no(a)&&s.isScriptable(t)&&(a=bI(t,a,e,n)),wt(a)&&a.length&&(a=xI(t,a,e,s.isIndexable)),gv(t,a)&&(a=ra(a,i,o&&o[t],s)),a}function bI(e,t,n,r){const{_proxy:i,_context:o,_subProxy:s,_stack:a}=n;if(a.has(e))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+e);a.add(e);let l=t(o,s||r);return a.delete(e),gv(e,l)&&(l=vv(i._scopes,i,e,l)),l}function xI(e,t,n,r){const{_proxy:i,_context:o,_subProxy:s,_descriptors:a}=n;if(typeof o.index<"u"&&r(e))return t[o.index%t.length];if(He(t[0])){const l=t,c=i._scopes.filter(u=>u!==l);t=[];for(const u of l){const d=vv(c,i,e,u);t.push(ra(d,o,s&&s[e],a))}}return t}function T1(e,t,n){return no(e)?e(t,n):e}const wI=(e,t)=>e===!0?t:typeof e=="string"?to(t,e):void 0;function _I(e,t,n,r,i){for(const o of t){const s=wI(n,o);if(s){e.add(s);const a=T1(s._fallback,n,i);if(typeof a<"u"&&a!==n&&a!==r)return a}else if(s===!1&&typeof r<"u"&&n!==r)return null}return!1}function vv(e,t,n,r){const i=t._rootScopes,o=T1(t._fallback,n,r),s=[...e,...i],a=new Set;a.add(r);let l=ew(a,s,n,o||n,r);return l===null||typeof o<"u"&&o!==n&&(l=ew(a,s,o,l,r),l===null)?!1:mv(Array.from(a),[""],i,o,()=>kI(t,n,r))}function ew(e,t,n,r,i){for(;n;)n=_I(e,t,n,r,i);return n}function kI(e,t,n){const r=e._getTarget();t in r||(r[t]={});const i=r[t];return wt(i)&&He(n)?n:i||{}}function SI(e,t,n,r){let i;for(const o of t)if(i=D1(vI(o,e),n),typeof i<"u")return gv(e,i)?vv(n,r,e,i):i}function D1(e,t){for(const n of t){if(!n)continue;const r=n[e];if(typeof r<"u")return r}}function tw(e){let t=e._keys;return t||(t=e._keys=EI(e._scopes)),t}function EI(e){const t=new Set;for(const n of e)for(const r of Object.keys(n).filter(i=>!i.startsWith("_")))t.add(r);return Array.from(t)}function I1(e,t,n,r){const{iScale:i}=e,{key:o="r"}=this._parsing,s=new Array(r);let a,l,c,u;for(a=0,l=r;a<l;++a)c=a+n,u=t[c],s[a]={r:i.parse(to(u,o),c)};return s}const OI=Number.EPSILON||1e-14,ia=(e,t)=>t<e.length&&!e[t].skip&&e[t],F1=e=>e==="x"?"y":"x";function CI(e,t,n,r){const i=e.skip?t:e,o=t,s=n.skip?t:n,a=_m(o,i),l=_m(s,o);let c=a/(a+l),u=l/(a+l);c=isNaN(c)?0:c,u=isNaN(u)?0:u;const d=r*c,f=r*u;return{previous:{x:o.x-d*(s.x-i.x),y:o.y-d*(s.y-i.y)},next:{x:o.x+f*(s.x-i.x),y:o.y+f*(s.y-i.y)}}}function jI(e,t,n){const r=e.length;let i,o,s,a,l,c=ia(e,0);for(let u=0;u<r-1;++u)if(l=c,c=ia(e,u+1),!(!l||!c)){if(cl(t[u],0,OI)){n[u]=n[u+1]=0;continue}i=n[u]/t[u],o=n[u+1]/t[u],a=Math.pow(i,2)+Math.pow(o,2),!(a<=9)&&(s=3/Math.sqrt(a),n[u]=i*s*t[u],n[u+1]=o*s*t[u])}}function RI(e,t,n="x"){const r=F1(n),i=e.length;let o,s,a,l=ia(e,0);for(let c=0;c<i;++c){if(s=a,a=l,l=ia(e,c+1),!a)continue;const u=a[n],d=a[r];s&&(o=(u-s[n])/3,a[`cp1${n}`]=u-o,a[`cp1${r}`]=d-o*t[c]),l&&(o=(l[n]-u)/3,a[`cp2${n}`]=u+o,a[`cp2${r}`]=d+o*t[c])}}function LI(e,t="x"){const n=F1(t),r=e.length,i=Array(r).fill(0),o=Array(r);let s,a,l,c=ia(e,0);for(s=0;s<r;++s)if(a=l,l=c,c=ia(e,s+1),!!l){if(c){const u=c[t]-l[t];i[s]=u!==0?(c[n]-l[n])/u:0}o[s]=a?c?Vr(i[s-1])!==Vr(i[s])?0:(i[s-1]+i[s])/2:i[s-1]:i[s]}jI(e,i,o),RI(e,o,t)}function Qc(e,t,n){return Math.max(Math.min(e,n),t)}function AI(e,t){let n,r,i,o,s,a=li(e[0],t);for(n=0,r=e.length;n<r;++n)s=o,o=a,a=n<r-1&&li(e[n+1],t),o&&(i=e[n],s&&(i.cp1x=Qc(i.cp1x,t.left,t.right),i.cp1y=Qc(i.cp1y,t.top,t.bottom)),a&&(i.cp2x=Qc(i.cp2x,t.left,t.right),i.cp2y=Qc(i.cp2y,t.top,t.bottom)))}function PI(e,t,n,r,i){let o,s,a,l;if(t.spanGaps&&(e=e.filter(c=>!c.skip)),t.cubicInterpolationMode==="monotone")LI(e,i);else{let c=r?e[e.length-1]:e[0];for(o=0,s=e.length;o<s;++o)a=e[o],l=CI(c,a,e[Math.min(o+1,s-(r?0:1))%s],t.tension),a.cp1x=l.previous.x,a.cp1y=l.previous.y,a.cp2x=l.next.x,a.cp2y=l.next.y,c=a}t.capBezierPoints&&AI(e,n)}function yv(){return typeof window<"u"&&typeof document<"u"}function bv(e){let t=e.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function jd(e,t,n){let r;return typeof e=="string"?(r=parseInt(e,10),e.indexOf("%")!==-1&&(r=r/100*t.parentNode[n])):r=e,r}const vf=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function MI(e,t){return vf(e).getPropertyValue(t)}const TI=["top","right","bottom","left"];function zo(e,t,n){const r={};n=n?"-"+n:"";for(let i=0;i<4;i++){const o=TI[i];r[o]=parseFloat(e[t+"-"+o+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}const DI=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function II(e,t){const n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:o}=r;let s=!1,a,l;if(DI(i,o,e.target))a=i,l=o;else{const c=t.getBoundingClientRect();a=r.clientX-c.left,l=r.clientY-c.top,s=!0}return{x:a,y:l,box:s}}function Eo(e,t){if("native"in e)return e;const{canvas:n,currentDevicePixelRatio:r}=t,i=vf(n),o=i.boxSizing==="border-box",s=zo(i,"padding"),a=zo(i,"border","width"),{x:l,y:c,box:u}=II(e,n),d=s.left+(u&&a.left),f=s.top+(u&&a.top);let{width:h,height:g}=t;return o&&(h-=s.width+a.width,g-=s.height+a.height),{x:Math.round((l-d)/h*n.width/r),y:Math.round((c-f)/g*n.height/r)}}function FI(e,t,n){let r,i;if(t===void 0||n===void 0){const o=e&&bv(e);if(!o)t=e.clientWidth,n=e.clientHeight;else{const s=o.getBoundingClientRect(),a=vf(o),l=zo(a,"border","width"),c=zo(a,"padding");t=s.width-c.width-l.width,n=s.height-c.height-l.height,r=jd(a.maxWidth,o,"clientWidth"),i=jd(a.maxHeight,o,"clientHeight")}}return{width:t,height:n,maxWidth:r||Od,maxHeight:i||Od}}const Ni=e=>Math.round(e*10)/10;function NI(e,t,n,r){const i=vf(e),o=zo(i,"margin"),s=jd(i.maxWidth,e,"clientWidth")||Od,a=jd(i.maxHeight,e,"clientHeight")||Od,l=FI(e,t,n);let{width:c,height:u}=l;if(i.boxSizing==="content-box"){const f=zo(i,"border","width"),h=zo(i,"padding");c-=h.width+f.width,u-=h.height+f.height}return c=Math.max(0,c-o.width),u=Math.max(0,r?c/r:u-o.height),c=Ni(Math.min(c,s,l.maxWidth)),u=Ni(Math.min(u,a,l.maxHeight)),c&&!u&&(u=Ni(c/2)),(t!==void 0||n!==void 0)&&r&&l.height&&u>l.height&&(u=l.height,c=Ni(Math.floor(u*r))),{width:c,height:u}}function nw(e,t,n){const r=t||1,i=Ni(e.height*r),o=Ni(e.width*r);e.height=Ni(e.height),e.width=Ni(e.width);const s=e.canvas;return s.style&&(n||!s.style.height&&!s.style.width)&&(s.style.height=`${e.height}px`,s.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||s.height!==i||s.width!==o?(e.currentDevicePixelRatio=r,s.height=i,s.width=o,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}const zI=function(){let e=!1;try{const t={get passive(){return e=!0,!1}};yv()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return e}();function rw(e,t){const n=MI(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function Oo(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function BI(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r==="middle"?n<.5?e.y:t.y:r==="after"?n<1?e.y:t.y:n>0?t.y:e.y}}function UI(e,t,n,r){const i={x:e.cp2x,y:e.cp2y},o={x:t.cp1x,y:t.cp1y},s=Oo(e,i,n),a=Oo(i,o,n),l=Oo(o,t,n),c=Oo(s,a,n),u=Oo(a,l,n);return Oo(c,u,n)}const HI=function(e,t){return{x(n){return e+e+t-n},setWidth(n){t=n},textAlign(n){return n==="center"?n:n==="right"?"left":"right"},xPlus(n,r){return n-r},leftForLtr(n,r){return n-r}}},WI=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function qs(e,t,n){return e?HI(t,n):WI()}function N1(e,t){let n,r;(t==="ltr"||t==="rtl")&&(n=e.canvas.style,r=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",t,"important"),e.prevTextDirection=r)}function z1(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty("direction",t[0],t[1]))}function B1(e){return e==="angle"?{between:Wl,compare:VD,normalize:vn}:{between:si,compare:(t,n)=>t-n,normalize:t=>t}}function iw({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function VI(e,t,n){const{property:r,start:i,end:o}=n,{between:s,normalize:a}=B1(r),l=t.length;let{start:c,end:u,loop:d}=e,f,h;if(d){for(c+=l,u+=l,f=0,h=l;f<h&&s(a(t[c%l][r]),i,o);++f)c--,u--;c%=l,u%=l}return u<c&&(u+=l),{start:c,end:u,loop:d,style:e.style}}function U1(e,t,n){if(!n)return[e];const{property:r,start:i,end:o}=n,s=t.length,{compare:a,between:l,normalize:c}=B1(r),{start:u,end:d,loop:f,style:h}=VI(e,t,n),g=[];let m=!1,x=null,y,b,w;const E=()=>l(i,w,y)&&a(i,w)!==0,C=()=>a(o,y)===0||l(o,w,y),S=()=>m||E(),M=()=>!m||C();for(let L=u,T=u;L<=d;++L)b=t[L%s],!b.skip&&(y=c(b[r]),y!==w&&(m=l(y,i,o),x===null&&S()&&(x=a(y,i)===0?L:T),x!==null&&M()&&(g.push(iw({start:x,end:L,loop:f,count:s,style:h})),x=null),T=L,w=y));return x!==null&&g.push(iw({start:x,end:d,loop:f,count:s,style:h})),g}function H1(e,t){const n=[],r=e.segments;for(let i=0;i<r.length;i++){const o=U1(r[i],e.points,t);o.length&&n.push(...o)}return n}function qI(e,t,n,r){let i=0,o=t-1;if(n&&!r)for(;i<t&&!e[i].skip;)i++;for(;i<t&&e[i].skip;)i++;for(i%=t,n&&(o+=i);o>i&&e[o%t].skip;)o--;return o%=t,{start:i,end:o}}function $I(e,t,n,r){const i=e.length,o=[];let s=t,a=e[t],l;for(l=t+1;l<=n;++l){const c=e[l%i];c.skip||c.stop?a.skip||(r=!1,o.push({start:t%i,end:(l-1)%i,loop:r}),t=s=c.stop?l:null):(s=l,a.skip&&(t=l)),a=c}return s!==null&&o.push({start:t%i,end:s%i,loop:r}),o}function KI(e,t){const n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];const o=!!e._loop,{start:s,end:a}=qI(n,i,o,r);if(r===!0)return ow(e,[{start:s,end:a,loop:o}],n,t);const l=a<s?a+i:a,c=!!e._fullLoop&&s===0&&a===i-1;return ow(e,$I(n,s,l,c),n,t)}function ow(e,t,n,r){return!r||!r.setContext||!n?t:YI(e,t,n,r)}function YI(e,t,n,r){const i=e._chart.getContext(),o=sw(e.options),{_datasetIndex:s,options:{spanGaps:a}}=e,l=n.length,c=[];let u=o,d=t[0].start,f=d;function h(g,m,x,y){const b=a?-1:1;if(g!==m){for(g+=l;n[g%l].skip;)g-=b;for(;n[m%l].skip;)m+=b;g%l!==m%l&&(c.push({start:g%l,end:m%l,loop:x,style:y}),u=y,d=m%l)}}for(const g of t){d=a?d:g.start;let m=n[d%l],x;for(f=d+1;f<=g.end;f++){const y=n[f%l];x=sw(r.setContext(lo(i,{type:"segment",p0:m,p1:y,p0DataIndex:(f-1)%l,p1DataIndex:f%l,datasetIndex:s}))),GI(x,u)&&h(d,f-1,g.loop,u),m=y,u=x}d<f-1&&h(d,f-1,g.loop,u)}return c}function sw(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function GI(e,t){if(!t)return!1;const n=[],r=function(i,o){return hv(o)?(n.includes(o)||n.push(o),n.indexOf(o)):o};return JSON.stringify(e,r)!==JSON.stringify(t,r)}function Zc(e,t,n){return e.options.clip?e[n]:t[n]}function JI(e,t){const{xScale:n,yScale:r}=e;return n&&r?{left:Zc(n,t,"left"),right:Zc(n,t,"right"),top:Zc(r,t,"top"),bottom:Zc(r,t,"bottom")}:t}function W1(e,t){const n=t._clip;if(n.disabled)return!1;const r=JI(t,e.chartArea);return{left:n.left===!1?0:r.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:r.right+(n.right===!0?0:n.right),top:n.top===!1?0:r.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:r.bottom+(n.bottom===!0?0:n.bottom)}}/*!
149
+ * Chart.js v4.5.1
150
+ * https://www.chartjs.org
151
+ * (c) 2025 Chart.js Contributors
152
+ * Released under the MIT License
153
+ */class XI{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,r,i){const o=n.listeners[i],s=n.duration;o.forEach(a=>a({chart:t,initial:n.initial,numSteps:s,currentStep:Math.min(r-n.start,s)}))}_refresh(){this._request||(this._running=!0,this._request=E1.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((r,i)=>{if(!r.running||!r.items.length)return;const o=r.items;let s=o.length-1,a=!1,l;for(;s>=0;--s)l=o[s],l._active?(l._total>r.duration&&(r.duration=l._total),l.tick(t),a=!0):(o[s]=o[o.length-1],o.pop());a&&(i.draw(),this._notify(i,r,t,"progress")),o.length||(r.running=!1,this._notify(i,r,t,"complete"),r.initial=!1),n+=o.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){const n=this._charts;let r=n.get(t);return r||(r={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,r)),r}listen(t,n,r){this._getAnims(t).listeners[n].push(r)}add(t,n){!n||!n.length||this._getAnims(t).items.push(...n)}has(t){return this._getAnims(t).items.length>0}start(t){const n=this._charts.get(t);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((r,i)=>Math.max(r,i._duration),0),this._refresh())}running(t){if(!this._running)return!1;const n=this._charts.get(t);return!(!n||!n.running||!n.items.length)}stop(t){const n=this._charts.get(t);if(!n||!n.items.length)return;const r=n.items;let i=r.length-1;for(;i>=0;--i)r[i].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var Xr=new XI;const aw="transparent",QI={boolean(e,t,n){return n>.5?t:e},color(e,t,n){const r=Xx(e||aw),i=r.valid&&Xx(t||aw);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}};class ZI{constructor(t,n,r,i){const o=n[r];i=qa([t.to,i,o,t.from]);const s=qa([t.from,o,i]);this._active=!0,this._fn=t.fn||QI[t.type||typeof s],this._easing=ul[t.easing]||ul.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=n,this._prop=r,this._from=s,this._to=i,this._promises=void 0}active(){return this._active}update(t,n,r){if(this._active){this._notify(!1);const i=this._target[this._prop],o=r-this._start,s=this._duration-o;this._start=r,this._duration=Math.floor(Math.max(s,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=qa([t.to,n,i,t.from]),this._from=qa([t.from,i,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const n=t-this._start,r=this._duration,i=this._prop,o=this._from,s=this._loop,a=this._to;let l;if(this._active=o!==a&&(s||n<r),!this._active){this._target[i]=a,this._notify(!0);return}if(n<0){this._target[i]=o;return}l=n/r%2,l=s&&l>1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[i]=this._fn(o,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((n,r)=>{t.push({res:n,rej:r})})}_notify(t){const n=t?"res":"rej",r=this._promises||[];for(let i=0;i<r.length;i++)r[i][n]()}}class V1{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!He(t))return;const n=Object.keys(_t.animation),r=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{const o=t[i];if(!He(o))return;const s={};for(const a of n)s[a]=o[a];(wt(o.properties)&&o.properties||[i]).forEach(a=>{(a===i||!r.has(a))&&r.set(a,s)})})}_animateOptions(t,n){const r=n.options,i=t2(t,r);if(!i)return[];const o=this._createAnimations(i,r);return r.$shared&&e2(t.options.$animations,r).then(()=>{t.options=r},()=>{}),o}_createAnimations(t,n){const r=this._properties,i=[],o=t.$animations||(t.$animations={}),s=Object.keys(n),a=Date.now();let l;for(l=s.length-1;l>=0;--l){const c=s[l];if(c.charAt(0)==="$")continue;if(c==="options"){i.push(...this._animateOptions(t,n));continue}const u=n[c];let d=o[c];const f=r.get(c);if(d)if(f&&d.active()){d.update(f,u,a);continue}else d.cancel();if(!f||!f.duration){t[c]=u;continue}o[c]=d=new ZI(f,t,c,u),i.push(d)}return i}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}const r=this._createAnimations(t,n);if(r.length)return Xr.add(this._chart,r),!0}}function e2(e,t){const n=[],r=Object.keys(t);for(let i=0;i<r.length;i++){const o=e[r[i]];o&&o.active()&&n.push(o.wait())}return Promise.all(n)}function t2(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function lw(e,t){const n=e&&e.options||{},r=n.reverse,i=n.min===void 0?t:0,o=n.max===void 0?t:0;return{start:r?o:i,end:r?i:o}}function n2(e,t,n){if(n===!1)return!1;const r=lw(e,n),i=lw(t,n);return{top:i.end,right:r.end,bottom:i.start,left:r.start}}function r2(e){let t,n,r,i;return He(e)?(t=e.top,n=e.right,r=e.bottom,i=e.left):t=n=r=i=e,{top:t,right:n,bottom:r,left:i,disabled:e===!1}}function q1(e,t){const n=[],r=e._getSortedDatasetMetas(t);let i,o;for(i=0,o=r.length;i<o;++i)n.push(r[i].index);return n}function cw(e,t,n,r={}){const i=e.keys,o=r.mode==="single";let s,a,l,c;if(t===null)return;let u=!1;for(s=0,a=i.length;s<a;++s){if(l=+i[s],l===n){if(u=!0,r.all)continue;break}c=e.values[l],It(c)&&(o||t===0||Vr(t)===Vr(c))&&(t+=c)}return!u&&!r.all?0:t}function i2(e,t){const{iScale:n,vScale:r}=t,i=n.axis==="x"?"x":"y",o=r.axis==="x"?"x":"y",s=Object.keys(e),a=new Array(s.length);let l,c,u;for(l=0,c=s.length;l<c;++l)u=s[l],a[l]={[i]:u,[o]:e[u]};return a}function Bh(e,t){const n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function o2(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function s2(e){const{min:t,max:n,minDefined:r,maxDefined:i}=e.getUserBounds();return{min:r?t:Number.NEGATIVE_INFINITY,max:i?n:Number.POSITIVE_INFINITY}}function a2(e,t,n){const r=e[t]||(e[t]={});return r[n]||(r[n]={})}function uw(e,t,n,r){for(const i of t.getMatchingVisibleMetas(r).reverse()){const o=e[i.index];if(n&&o>0||!n&&o<0)return i.index}return null}function dw(e,t){const{chart:n,_cachedMeta:r}=e,i=n._stacks||(n._stacks={}),{iScale:o,vScale:s,index:a}=r,l=o.axis,c=s.axis,u=o2(o,s,r),d=t.length;let f;for(let h=0;h<d;++h){const g=t[h],{[l]:m,[c]:x}=g,y=g._stacks||(g._stacks={});f=y[c]=a2(i,u,m),f[a]=x,f._top=uw(f,s,!0,r.type),f._bottom=uw(f,s,!1,r.type);const b=f._visualValues||(f._visualValues={});b[a]=x}}function Uh(e,t){const n=e.scales;return Object.keys(n).filter(r=>n[r].axis===t).shift()}function l2(e,t){return lo(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function c2(e,t,n){return lo(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function Ra(e,t){const n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t=t||e._parsed;for(const i of t){const o=i._stacks;if(!o||o[r]===void 0||o[r][n]===void 0)return;delete o[r][n],o[r]._visualValues!==void 0&&o[r]._visualValues[n]!==void 0&&delete o[r]._visualValues[n]}}}const Hh=e=>e==="reset"||e==="none",fw=(e,t)=>t?e:Object.assign({},e),u2=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:q1(n,!0),values:null};class jr{constructor(t,n){this.chart=t,this._ctx=t.ctx,this.index=n,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=Bh(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&Ra(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,n=this._cachedMeta,r=this.getDataset(),i=(d,f,h,g)=>d==="x"?f:d==="r"?g:h,o=n.xAxisID=Le(r.xAxisID,Uh(t,"x")),s=n.yAxisID=Le(r.yAxisID,Uh(t,"y")),a=n.rAxisID=Le(r.rAxisID,Uh(t,"r")),l=n.indexAxis,c=n.iAxisID=i(l,o,s,a),u=n.vAxisID=i(l,s,o,a);n.xScale=this.getScaleForId(o),n.yScale=this.getScaleForId(s),n.rScale=this.getScaleForId(a),n.iScale=this.getScaleForId(c),n.vScale=this.getScaleForId(u)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const n=this._cachedMeta;return t===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&Yx(this._data,this),t._stacked&&Ra(t)}_dataCheck(){const t=this.getDataset(),n=t.data||(t.data=[]),r=this._data;if(He(n)){const i=this._cachedMeta;this._data=i2(n,i)}else if(r!==n){if(r){Yx(r,this);const i=this._cachedMeta;Ra(i),i._parsed=[]}n&&Object.isExtensible(n)&&YD(n,this),this._syncList=[],this._data=n}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const n=this._cachedMeta,r=this.getDataset();let i=!1;this._dataCheck();const o=n._stacked;n._stacked=Bh(n.vScale,n),n.stack!==r.stack&&(i=!0,Ra(n),n.stack=r.stack),this._resyncElements(t),(i||o!==n._stacked)&&(dw(this,n._parsed),n._stacked=Bh(n.vScale,n))}configure(){const t=this.chart.config,n=t.datasetScopeKeys(this._type),r=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(r,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){const{_cachedMeta:r,_data:i}=this,{iScale:o,_stacked:s}=r,a=o.axis;let l=t===0&&n===i.length?!0:r._sorted,c=t>0&&r._parsed[t-1],u,d,f;if(this._parsing===!1)r._parsed=i,r._sorted=!0,f=i;else{wt(i[t])?f=this.parseArrayData(r,i,t,n):He(i[t])?f=this.parseObjectData(r,i,t,n):f=this.parsePrimitiveData(r,i,t,n);const h=()=>d[a]===null||c&&d[a]<c[a];for(u=0;u<n;++u)r._parsed[u+t]=d=f[u],l&&(h()&&(l=!1),c=d);r._sorted=l}s&&dw(this,f)}parsePrimitiveData(t,n,r,i){const{iScale:o,vScale:s}=t,a=o.axis,l=s.axis,c=o.getLabels(),u=o===s,d=new Array(i);let f,h,g;for(f=0,h=i;f<h;++f)g=f+r,d[f]={[a]:u||o.parse(c[g],g),[l]:s.parse(n[g],g)};return d}parseArrayData(t,n,r,i){const{xScale:o,yScale:s}=t,a=new Array(i);let l,c,u,d;for(l=0,c=i;l<c;++l)u=l+r,d=n[u],a[l]={x:o.parse(d[0],u),y:s.parse(d[1],u)};return a}parseObjectData(t,n,r,i){const{xScale:o,yScale:s}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=new Array(i);let u,d,f,h;for(u=0,d=i;u<d;++u)f=u+r,h=n[f],c[u]={x:o.parse(to(h,a),f),y:s.parse(to(h,l),f)};return c}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,r){const i=this.chart,o=this._cachedMeta,s=n[t.axis],a={keys:q1(i,!0),values:n._stacks[t.axis]._visualValues};return cw(a,s,o.index,{mode:r})}updateRangeFromParsed(t,n,r,i){const o=r[n.axis];let s=o===null?NaN:o;const a=i&&r._stacks[n.axis];i&&a&&(i.values=a,s=cw(i,o,this._cachedMeta.index)),t.min=Math.min(t.min,s),t.max=Math.max(t.max,s)}getMinMax(t,n){const r=this._cachedMeta,i=r._parsed,o=r._sorted&&t===r.iScale,s=i.length,a=this._getOtherScale(t),l=u2(n,r,this.chart),c={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:u,max:d}=s2(a);let f,h;function g(){h=i[f];const m=h[a.axis];return!It(h[t.axis])||u>m||d<m}for(f=0;f<s&&!(!g()&&(this.updateRangeFromParsed(c,t,h,l),o));++f);if(o){for(f=s-1;f>=0;--f)if(!g()){this.updateRangeFromParsed(c,t,h,l);break}}return c}getAllParsedValues(t){const n=this._cachedMeta._parsed,r=[];let i,o,s;for(i=0,o=n.length;i<o;++i)s=n[i][t.axis],It(s)&&r.push(s);return r}getMaxOverflow(){return!1}getLabelAndValue(t){const n=this._cachedMeta,r=n.iScale,i=n.vScale,o=this.getParsed(t);return{label:r?""+r.getLabelForValue(o[r.axis]):"",value:i?""+i.getLabelForValue(o[i.axis]):""}}_update(t){const n=this._cachedMeta;this.update(t||"default"),n._clip=r2(Le(this.options.clip,n2(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,n=this.chart,r=this._cachedMeta,i=r.data||[],o=n.chartArea,s=[],a=this._drawStart||0,l=this._drawCount||i.length-a,c=this.options.drawActiveElementsOnTop;let u;for(r.dataset&&r.dataset.draw(t,o,a,l),u=a;u<a+l;++u){const d=i[u];d.hidden||(d.active&&c?s.push(d):d.draw(t,o))}for(u=0;u<s.length;++u)s[u].draw(t,o)}getStyle(t,n){const r=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(r):this.resolveDataElementOptions(t||0,r)}getContext(t,n,r){const i=this.getDataset();let o;if(t>=0&&t<this._cachedMeta.data.length){const s=this._cachedMeta.data[t];o=s.$context||(s.$context=c2(this.getContext(),t,s)),o.parsed=this.getParsed(t),o.raw=i.data[t],o.index=o.dataIndex=t}else o=this.$context||(this.$context=l2(this.chart.getContext(),this.index)),o.dataset=i,o.index=o.datasetIndex=this.index;return o.active=!!n,o.mode=r,o}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,n){return this._resolveElementOptions(this.dataElementType.id,n,t)}_resolveElementOptions(t,n="default",r){const i=n==="active",o=this._cachedDataOpts,s=t+"-"+n,a=o[s],l=this.enableOptionSharing&&Hl(r);if(a)return fw(a,l);const c=this.chart.config,u=c.datasetElementScopeKeys(this._type,t),d=i?[`${t}Hover`,"hover",t,""]:[t,""],f=c.getOptionScopes(this.getDataset(),u),h=Object.keys(_t.elements[t]),g=()=>this.getContext(r,i,n),m=c.resolveNamedOptions(f,h,g,d);return m.$shared&&(m.$shared=l,o[s]=Object.freeze(fw(m,l))),m}_resolveAnimations(t,n,r){const i=this.chart,o=this._cachedDataOpts,s=`animation-${n}`,a=o[s];if(a)return a;let l;if(i.options.animation!==!1){const u=this.chart.config,d=u.datasetAnimationScopeKeys(this._type,n),f=u.getOptionScopes(this.getDataset(),d);l=u.createResolver(f,this.getContext(t,r,n))}const c=new V1(i,l&&l.animations);return l&&l._cacheable&&(o[s]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,n){return!n||Hh(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){const r=this.resolveDataElementOptions(t,n),i=this._sharedOptions,o=this.getSharedOptions(r),s=this.includeOptions(n,o)||o!==i;return this.updateSharedOptions(o,n,r),{sharedOptions:o,includeOptions:s}}updateElement(t,n,r,i){Hh(i)?Object.assign(t,r):this._resolveAnimations(n,i).update(t,r)}updateSharedOptions(t,n,r){t&&!Hh(n)&&this._resolveAnimations(void 0,n).update(t,r)}_setStyle(t,n,r,i){t.active=i;const o=this.getStyle(n,i);this._resolveAnimations(n,r,i).update(t,{options:!i&&this.getSharedOptions(o)||o})}removeHoverStyle(t,n,r){this._setStyle(t,r,"active",!1)}setHoverStyle(t,n,r){this._setStyle(t,r,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const n=this._data,r=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const i=r.length,o=n.length,s=Math.min(o,i);s&&this.parse(0,s),o>i?this._insertElements(i,o-i,t):o<i&&this._removeElements(o,i-o)}_insertElements(t,n,r=!0){const i=this._cachedMeta,o=i.data,s=t+n;let a;const l=c=>{for(c.length+=n,a=c.length-1;a>=s;a--)c[a]=c[a-n]};for(l(o),a=t;a<s;++a)o[a]=new this.dataElementType;this._parsing&&l(i._parsed),this.parse(t,n),r&&this.updateElements(o,t,n,"reset")}updateElements(t,n,r,i){}_removeElements(t,n){const r=this._cachedMeta;if(this._parsing){const i=r._parsed.splice(t,n);r._stacked&&Ra(r,i)}r.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[n,r,i]=t;this[n](r,i)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,n){n&&this._sync(["_removeElements",t,n]);const r=arguments.length-2;r&&this._sync(["_insertElements",t,r])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}Z(jr,"defaults",{}),Z(jr,"datasetElementType",null),Z(jr,"dataElementType",null);function d2(e,t){if(!e._cache.$bar){const n=e.getMatchingVisibleMetas(t);let r=[];for(let i=0,o=n.length;i<o;i++)r=r.concat(n[i].controller.getAllParsedValues(e));e._cache.$bar=S1(r.sort((i,o)=>i-o))}return e._cache.$bar}function f2(e){const t=e.iScale,n=d2(t,e.type);let r=t._length,i,o,s,a;const l=()=>{s===32767||s===-32768||(Hl(a)&&(r=Math.min(r,Math.abs(s-a)||r)),a=s)};for(i=0,o=n.length;i<o;++i)s=t.getPixelForValue(n[i]),l();for(a=void 0,i=0,o=t.ticks.length;i<o;++i)s=t.getPixelForTick(i),l();return r}function h2(e,t,n,r){const i=n.barThickness;let o,s;return Ne(i)?(o=t.min*n.categoryPercentage,s=n.barPercentage):(o=i*r,s=1),{chunk:o/r,ratio:s,start:t.pixels[e]-o/2}}function p2(e,t,n,r){const i=t.pixels,o=i[e];let s=e>0?i[e-1]:null,a=e<i.length-1?i[e+1]:null;const l=n.categoryPercentage;s===null&&(s=o-(a===null?t.end-t.start:a-o)),a===null&&(a=o+o-s);const c=o-(o-Math.min(s,a))/2*l;return{chunk:Math.abs(a-s)/2*l/r,ratio:n.barPercentage,start:c}}function m2(e,t,n,r){const i=n.parse(e[0],r),o=n.parse(e[1],r),s=Math.min(i,o),a=Math.max(i,o);let l=s,c=a;Math.abs(s)>Math.abs(a)&&(l=a,c=s),t[n.axis]=c,t._custom={barStart:l,barEnd:c,start:i,end:o,min:s,max:a}}function $1(e,t,n,r){return wt(e)?m2(e,t,n,r):t[n.axis]=n.parse(e,r),t}function hw(e,t,n,r){const i=e.iScale,o=e.vScale,s=i.getLabels(),a=i===o,l=[];let c,u,d,f;for(c=n,u=n+r;c<u;++c)f=t[c],d={},d[i.axis]=a||i.parse(s[c],c),l.push($1(f,d,o,c));return l}function Wh(e){return e&&e.barStart!==void 0&&e.barEnd!==void 0}function g2(e,t,n){return e!==0?Vr(e):(t.isHorizontal()?1:-1)*(t.min>=n?1:-1)}function v2(e){let t,n,r,i,o;return e.horizontal?(t=e.base>e.x,n="left",r="right"):(t=e.base<e.y,n="bottom",r="top"),t?(i="end",o="start"):(i="start",o="end"),{start:n,end:r,reverse:t,top:i,bottom:o}}function y2(e,t,n,r){let i=t.borderSkipped;const o={};if(!i){e.borderSkipped=o;return}if(i===!0){e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}const{start:s,end:a,reverse:l,top:c,bottom:u}=v2(e);i==="middle"&&n&&(e.enableBorderRadius=!0,(n._top||0)===r?i=c:(n._bottom||0)===r?i=u:(o[pw(u,s,a,l)]=!0,i=c)),o[pw(i,s,a,l)]=!0,e.borderSkipped=o}function pw(e,t,n,r){return r?(e=b2(e,t,n),e=mw(e,n,t)):e=mw(e,t,n),e}function b2(e,t,n){return e===t?n:e===n?t:e}function mw(e,t,n){return e==="start"?t:e==="end"?n:e}function x2(e,{inflateAmount:t},n){e.inflateAmount=t==="auto"?n===1?.33:0:t}class Ru extends jr{parsePrimitiveData(t,n,r,i){return hw(t,n,r,i)}parseArrayData(t,n,r,i){return hw(t,n,r,i)}parseObjectData(t,n,r,i){const{iScale:o,vScale:s}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=o.axis==="x"?a:l,u=s.axis==="x"?a:l,d=[];let f,h,g,m;for(f=r,h=r+i;f<h;++f)m=n[f],g={},g[o.axis]=o.parse(to(m,c),f),d.push($1(to(m,u),g,s,f));return d}updateRangeFromParsed(t,n,r,i){super.updateRangeFromParsed(t,n,r,i);const o=r._custom;o&&n===this._cachedMeta.vScale&&(t.min=Math.min(t.min,o.min),t.max=Math.max(t.max,o.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const n=this._cachedMeta,{iScale:r,vScale:i}=n,o=this.getParsed(t),s=o._custom,a=Wh(s)?"["+s.start+", "+s.end+"]":""+i.getLabelForValue(o[i.axis]);return{label:""+r.getLabelForValue(o[r.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();const t=this._cachedMeta;t.stack=this.getDataset().stack}update(t){const n=this._cachedMeta;this.updateElements(n.data,0,n.data.length,t)}updateElements(t,n,r,i){const o=i==="reset",{index:s,_cachedMeta:{vScale:a}}=this,l=a.getBasePixel(),c=a.isHorizontal(),u=this._getRuler(),{sharedOptions:d,includeOptions:f}=this._getSharedOptions(n,i);for(let h=n;h<n+r;h++){const g=this.getParsed(h),m=o||Ne(g[a.axis])?{base:l,head:l}:this._calculateBarValuePixels(h),x=this._calculateBarIndexPixels(h,u),y=(g._stacks||{})[a.axis],b={horizontal:c,base:m.base,enableBorderRadius:!y||Wh(g._custom)||s===y._top||s===y._bottom,x:c?m.head:x.center,y:c?x.center:m.head,height:c?x.size:Math.abs(m.size),width:c?Math.abs(m.size):x.size};f&&(b.options=d||this.resolveDataElementOptions(h,t[h].active?"active":i));const w=b.options||t[h].options;y2(b,w,y,s),x2(b,w,u.ratio),this.updateElement(t[h],h,b,i)}}_getStacks(t,n){const{iScale:r}=this._cachedMeta,i=r.getMatchingVisibleMetas(this._type).filter(u=>u.controller.options.grouped),o=r.options.stacked,s=[],a=this._cachedMeta.controller.getParsed(n),l=a&&a[r.axis],c=u=>{const d=u._parsed.find(h=>h[r.axis]===l),f=d&&d[u.vScale.axis];if(Ne(f)||isNaN(f))return!0};for(const u of i)if(!(n!==void 0&&c(u))&&((o===!1||s.indexOf(u.stack)===-1||o===void 0&&u.stack===void 0)&&s.push(u.stack),u.index===t))break;return s.length||s.push(void 0),s}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,n=this.chart.options.indexAxis;return Object.keys(t).filter(r=>t[r].axis===n).shift()}_getAxis(){const t={},n=this.getFirstScaleIdForIndexAxis();for(const r of this.chart.data.datasets)t[Le(this.chart.options.indexAxis==="x"?r.xAxisID:r.yAxisID,n)]=!0;return Object.keys(t)}_getStackIndex(t,n,r){const i=this._getStacks(t,r),o=n!==void 0?i.indexOf(n):-1;return o===-1?i.length-1:o}_getRuler(){const t=this.options,n=this._cachedMeta,r=n.iScale,i=[];let o,s;for(o=0,s=n.data.length;o<s;++o)i.push(r.getPixelForValue(this.getParsed(o)[r.axis],o));const a=t.barThickness;return{min:a||f2(n),pixels:i,start:r._startPixel,end:r._endPixel,stackCount:this._getStackCount(),scale:r,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:n,_stacked:r,index:i},options:{base:o,minBarLength:s}}=this,a=o||0,l=this.getParsed(t),c=l._custom,u=Wh(c);let d=l[n.axis],f=0,h=r?this.applyStack(n,l,r):d,g,m;h!==d&&(f=h-d,h=d),u&&(d=c.barStart,h=c.barEnd-c.barStart,d!==0&&Vr(d)!==Vr(c.barEnd)&&(f=0),f+=d);const x=!Ne(o)&&!u?o:f;let y=n.getPixelForValue(x);if(this.chart.getDataVisibility(t)?g=n.getPixelForValue(f+h):g=y,m=g-y,Math.abs(m)<s){m=g2(m,n,a)*s,d===a&&(y-=m/2);const b=n.getPixelForDecimal(0),w=n.getPixelForDecimal(1),E=Math.min(b,w),C=Math.max(b,w);y=Math.max(Math.min(y,C),E),g=y+m,r&&!u&&(l._stacks[n.axis]._visualValues[i]=n.getValueForPixel(g)-n.getValueForPixel(y))}if(y===n.getPixelForValue(a)){const b=Vr(m)*n.getLineWidthForValue(a)/2;y+=b,m-=b}return{size:m,base:y,head:g,center:g+m/2}}_calculateBarIndexPixels(t,n){const r=n.scale,i=this.options,o=i.skipNull,s=Le(i.maxBarThickness,1/0);let a,l;const c=this._getAxisCount();if(n.grouped){const u=o?this._getStackCount(t):n.stackCount,d=i.barThickness==="flex"?p2(t,n,i,u*c):h2(t,n,i,u*c),f=this.chart.options.indexAxis==="x"?this.getDataset().xAxisID:this.getDataset().yAxisID,h=this._getAxis().indexOf(Le(f,this.getFirstScaleIdForIndexAxis())),g=this._getStackIndex(this.index,this._cachedMeta.stack,o?t:void 0)+h;a=d.start+d.chunk*g+d.chunk/2,l=Math.min(s,d.chunk*d.ratio)}else a=r.getPixelForValue(this.getParsed(t)[r.axis],t),l=Math.min(s,n.min*n.ratio);return{base:a-l/2,head:a+l/2,center:a,size:l}}draw(){const t=this._cachedMeta,n=t.vScale,r=t.data,i=r.length;let o=0;for(;o<i;++o)this.getParsed(o)[n.axis]!==null&&!r[o].hidden&&r[o].draw(this._ctx)}}Z(Ru,"id","bar"),Z(Ru,"defaults",{datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}}),Z(Ru,"overrides",{scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}});class Lu extends jr{initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,n,r,i){const o=super.parsePrimitiveData(t,n,r,i);for(let s=0;s<o.length;s++)o[s]._custom=this.resolveDataElementOptions(s+r).radius;return o}parseArrayData(t,n,r,i){const o=super.parseArrayData(t,n,r,i);for(let s=0;s<o.length;s++){const a=n[r+s];o[s]._custom=Le(a[2],this.resolveDataElementOptions(s+r).radius)}return o}parseObjectData(t,n,r,i){const o=super.parseObjectData(t,n,r,i);for(let s=0;s<o.length;s++){const a=n[r+s];o[s]._custom=Le(a&&a.r&&+a.r,this.resolveDataElementOptions(s+r).radius)}return o}getMaxOverflow(){const t=this._cachedMeta.data;let n=0;for(let r=t.length-1;r>=0;--r)n=Math.max(n,t[r].size(this.resolveDataElementOptions(r))/2);return n>0&&n}getLabelAndValue(t){const n=this._cachedMeta,r=this.chart.data.labels||[],{xScale:i,yScale:o}=n,s=this.getParsed(t),a=i.getLabelForValue(s.x),l=o.getLabelForValue(s.y),c=s._custom;return{label:r[t]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(t){const n=this._cachedMeta.data;this.updateElements(n,0,n.length,t)}updateElements(t,n,r,i){const o=i==="reset",{iScale:s,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(n,i),u=s.axis,d=a.axis;for(let f=n;f<n+r;f++){const h=t[f],g=!o&&this.getParsed(f),m={},x=m[u]=o?s.getPixelForDecimal(.5):s.getPixelForValue(g[u]),y=m[d]=o?a.getBasePixel():a.getPixelForValue(g[d]);m.skip=isNaN(x)||isNaN(y),c&&(m.options=l||this.resolveDataElementOptions(f,h.active?"active":i),o&&(m.options.radius=0)),this.updateElement(h,f,m,i)}}resolveDataElementOptions(t,n){const r=this.getParsed(t);let i=super.resolveDataElementOptions(t,n);i.$shared&&(i=Object.assign({},i,{$shared:!1}));const o=i.radius;return n!=="active"&&(i.radius=0),i.radius+=Le(r&&r._custom,o),i}}Z(Lu,"id","bubble"),Z(Lu,"defaults",{datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}}),Z(Lu,"overrides",{scales:{x:{type:"linear"},y:{type:"linear"}}});function w2(e,t,n){let r=1,i=1,o=0,s=0;if(t<yt){const a=e,l=a+t,c=Math.cos(a),u=Math.sin(a),d=Math.cos(l),f=Math.sin(l),h=(w,E,C)=>Wl(w,a,l,!0)?1:Math.max(E,E*n,C,C*n),g=(w,E,C)=>Wl(w,a,l,!0)?-1:Math.min(E,E*n,C,C*n),m=h(0,c,d),x=h(Bt,u,f),y=g(Ye,c,d),b=g(Ye+Bt,u,f);r=(m-y)/2,i=(x-b)/2,o=-(m+y)/2,s=-(x+b)/2}return{ratioX:r,ratioY:i,offsetX:o,offsetY:s}}class Po extends jr{constructor(t,n){super(t,n),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,n){const r=this.getDataset().data,i=this._cachedMeta;if(this._parsing===!1)i._parsed=r;else{let o=l=>+r[l];if(He(r[t])){const{key:l="value"}=this._parsing;o=c=>+to(r[c],l)}let s,a;for(s=t,a=t+n;s<a;++s)i._parsed[s]=o(s)}}_getRotation(){return Er(this.options.rotation-90)}_getCircumference(){return Er(this.options.circumference)}_getRotationExtents(){let t=yt,n=-yt;for(let r=0;r<this.chart.data.datasets.length;++r)if(this.chart.isDatasetVisible(r)&&this.chart.getDatasetMeta(r).type===this._type){const i=this.chart.getDatasetMeta(r).controller,o=i._getRotation(),s=i._getCircumference();t=Math.min(t,o),n=Math.max(n,o+s)}return{rotation:t,circumference:n-t}}update(t){const n=this.chart,{chartArea:r}=n,i=this._cachedMeta,o=i.data,s=this.getMaxBorderWidth()+this.getMaxOffset(o)+this.options.spacing,a=Math.max((Math.min(r.width,r.height)-s)/2,0),l=Math.min(MD(this.options.cutout,a),1),c=this._getRingWeight(this.index),{circumference:u,rotation:d}=this._getRotationExtents(),{ratioX:f,ratioY:h,offsetX:g,offsetY:m}=w2(d,u,l),x=(r.width-s)/f,y=(r.height-s)/h,b=Math.max(Math.min(x,y)/2,0),w=b1(this.options.radius,b),E=Math.max(w*l,0),C=(w-E)/this._getVisibleDatasetWeightTotal();this.offsetX=g*w,this.offsetY=m*w,i.total=this.calculateTotal(),this.outerRadius=w-C*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-C*c,0),this.updateElements(o,0,o.length,t)}_circumference(t,n){const r=this.options,i=this._cachedMeta,o=this._getCircumference();return n&&r.animation.animateRotate||!this.chart.getDataVisibility(t)||i._parsed[t]===null||i.data[t].hidden?0:this.calculateCircumference(i._parsed[t]*o/yt)}updateElements(t,n,r,i){const o=i==="reset",s=this.chart,a=s.chartArea,c=s.options.animation,u=(a.left+a.right)/2,d=(a.top+a.bottom)/2,f=o&&c.animateScale,h=f?0:this.innerRadius,g=f?0:this.outerRadius,{sharedOptions:m,includeOptions:x}=this._getSharedOptions(n,i);let y=this._getRotation(),b;for(b=0;b<n;++b)y+=this._circumference(b,o);for(b=n;b<n+r;++b){const w=this._circumference(b,o),E=t[b],C={x:u+this.offsetX,y:d+this.offsetY,startAngle:y,endAngle:y+w,circumference:w,outerRadius:g,innerRadius:h};x&&(C.options=m||this.resolveDataElementOptions(b,E.active?"active":i)),y+=w,this.updateElement(E,b,C,i)}}calculateTotal(){const t=this._cachedMeta,n=t.data;let r=0,i;for(i=0;i<n.length;i++){const o=t._parsed[i];o!==null&&!isNaN(o)&&this.chart.getDataVisibility(i)&&!n[i].hidden&&(r+=Math.abs(o))}return r}calculateCircumference(t){const n=this._cachedMeta.total;return n>0&&!isNaN(t)?yt*(Math.abs(t)/n):0}getLabelAndValue(t){const n=this._cachedMeta,r=this.chart,i=r.data.labels||[],o=sc(n._parsed[t],r.options.locale);return{label:i[t]||"",value:o}}getMaxBorderWidth(t){let n=0;const r=this.chart;let i,o,s,a,l;if(!t){for(i=0,o=r.data.datasets.length;i<o;++i)if(r.isDatasetVisible(i)){s=r.getDatasetMeta(i),t=s.data,a=s.controller;break}}if(!t)return 0;for(i=0,o=t.length;i<o;++i)l=a.resolveDataElementOptions(i),l.borderAlign!=="inner"&&(n=Math.max(n,l.borderWidth||0,l.hoverBorderWidth||0));return n}getMaxOffset(t){let n=0;for(let r=0,i=t.length;r<i;++r){const o=this.resolveDataElementOptions(r);n=Math.max(n,o.offset||0,o.hoverOffset||0)}return n}_getRingWeightOffset(t){let n=0;for(let r=0;r<t;++r)this.chart.isDatasetVisible(r)&&(n+=this._getRingWeight(r));return n}_getRingWeight(t){return Math.max(Le(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}Z(Po,"id","doughnut"),Z(Po,"defaults",{datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"}),Z(Po,"descriptors",{_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),Z(Po,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data,{labels:{pointStyle:r,textAlign:i,color:o,useBorderRadius:s,borderRadius:a}}=t.legend.options;return n.labels.length&&n.datasets.length?n.labels.map((l,c)=>{const d=t.getDatasetMeta(0).controller.getStyle(c);return{text:l,fillStyle:d.backgroundColor,fontColor:o,hidden:!t.getDataVisibility(c),lineDash:d.borderDash,lineDashOffset:d.borderDashOffset,lineJoin:d.borderJoinStyle,lineWidth:d.borderWidth,strokeStyle:d.borderColor,textAlign:i,pointStyle:r,borderRadius:s&&(a||d.borderRadius),index:c}}):[]}},onClick(t,n,r){r.chart.toggleDataVisibility(n.index),r.chart.update()}}}});class Au extends jr{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const n=this._cachedMeta,{dataset:r,data:i=[],_dataset:o}=n,s=this.chart._animationsDisabled;let{start:a,count:l}=C1(n,i,s);this._drawStart=a,this._drawCount=l,j1(n)&&(a=0,l=i.length),r._chart=this.chart,r._datasetIndex=this.index,r._decimated=!!o._decimated,r.points=i;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(r,void 0,{animated:!s,options:c},t),this.updateElements(i,a,l,t)}updateElements(t,n,r,i){const o=i==="reset",{iScale:s,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:u,includeOptions:d}=this._getSharedOptions(n,i),f=s.axis,h=a.axis,{spanGaps:g,segment:m}=this.options,x=na(g)?g:Number.POSITIVE_INFINITY,y=this.chart._animationsDisabled||o||i==="none",b=n+r,w=t.length;let E=n>0&&this.getParsed(n-1);for(let C=0;C<w;++C){const S=t[C],M=y?S:{};if(C<n||C>=b){M.skip=!0;continue}const L=this.getParsed(C),T=Ne(L[h]),V=M[f]=s.getPixelForValue(L[f],C),G=M[h]=o||T?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,L,l):L[h],C);M.skip=isNaN(V)||isNaN(G)||T,M.stop=C>0&&Math.abs(L[f]-E[f])>x,m&&(M.parsed=L,M.raw=c.data[C]),d&&(M.options=u||this.resolveDataElementOptions(C,S.active?"active":i)),y||this.updateElement(S,C,M,i),E=L}}getMaxOverflow(){const t=this._cachedMeta,n=t.dataset,r=n.options&&n.options.borderWidth||0,i=t.data||[];if(!i.length)return r;const o=i[0].size(this.resolveDataElementOptions(0)),s=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(r,o,s)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}Z(Au,"id","line"),Z(Au,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),Z(Au,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class fl extends jr{constructor(t,n){super(t,n),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const n=this._cachedMeta,r=this.chart,i=r.data.labels||[],o=sc(n._parsed[t].r,r.options.locale);return{label:i[t]||"",value:o}}parseObjectData(t,n,r,i){return I1.bind(this)(t,n,r,i)}update(t){const n=this._cachedMeta.data;this._updateRadius(),this.updateElements(n,0,n.length,t)}getMinMax(){const t=this._cachedMeta,n={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((r,i)=>{const o=this.getParsed(i).r;!isNaN(o)&&this.chart.getDataVisibility(i)&&(o<n.min&&(n.min=o),o>n.max&&(n.max=o))}),n}_updateRadius(){const t=this.chart,n=t.chartArea,r=t.options,i=Math.min(n.right-n.left,n.bottom-n.top),o=Math.max(i/2,0),s=Math.max(r.cutoutPercentage?o/100*r.cutoutPercentage:1,0),a=(o-s)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,n,r,i){const o=i==="reset",s=this.chart,l=s.options.animation,c=this._cachedMeta.rScale,u=c.xCenter,d=c.yCenter,f=c.getIndexAngle(0)-.5*Ye;let h=f,g;const m=360/this.countVisibleElements();for(g=0;g<n;++g)h+=this._computeAngle(g,i,m);for(g=n;g<n+r;g++){const x=t[g];let y=h,b=h+this._computeAngle(g,i,m),w=s.getDataVisibility(g)?c.getDistanceFromCenterForValue(this.getParsed(g).r):0;h=b,o&&(l.animateScale&&(w=0),l.animateRotate&&(y=b=f));const E={x:u,y:d,innerRadius:0,outerRadius:w,startAngle:y,endAngle:b,options:this.resolveDataElementOptions(g,x.active?"active":i)};this.updateElement(x,g,E,i)}}countVisibleElements(){const t=this._cachedMeta;let n=0;return t.data.forEach((r,i)=>{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&n++}),n}_computeAngle(t,n,r){return this.chart.getDataVisibility(t)?Er(this.resolveDataElementOptions(t,n).angle||r):0}}Z(fl,"id","polarArea"),Z(fl,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),Z(fl,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data;if(n.labels.length&&n.datasets.length){const{labels:{pointStyle:r,color:i}}=t.legend.options;return n.labels.map((o,s)=>{const l=t.getDatasetMeta(0).controller.getStyle(s);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:i,lineWidth:l.borderWidth,pointStyle:r,hidden:!t.getDataVisibility(s),index:s}})}return[]}},onClick(t,n,r){r.chart.toggleDataVisibility(n.index),r.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class Em extends Po{}Z(Em,"id","pie"),Z(Em,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});class Pu extends jr{getLabelAndValue(t){const n=this._cachedMeta.vScale,r=this.getParsed(t);return{label:n.getLabels()[t],value:""+n.getLabelForValue(r[n.axis])}}parseObjectData(t,n,r,i){return I1.bind(this)(t,n,r,i)}update(t){const n=this._cachedMeta,r=n.dataset,i=n.data||[],o=n.iScale.getLabels();if(r.points=i,t!=="resize"){const s=this.resolveDatasetElementOptions(t);this.options.showLine||(s.borderWidth=0);const a={_loop:!0,_fullLoop:o.length===i.length,options:s};this.updateElement(r,void 0,a,t)}this.updateElements(i,0,i.length,t)}updateElements(t,n,r,i){const o=this._cachedMeta.rScale,s=i==="reset";for(let a=n;a<n+r;a++){const l=t[a],c=this.resolveDataElementOptions(a,l.active?"active":i),u=o.getPointPositionForValue(a,this.getParsed(a).r),d=s?o.xCenter:u.x,f=s?o.yCenter:u.y,h={x:d,y:f,angle:u.angle,skip:isNaN(d)||isNaN(f),options:c};this.updateElement(l,a,h,i)}}}Z(Pu,"id","radar"),Z(Pu,"defaults",{datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}}),Z(Pu,"overrides",{aspectRatio:1,scales:{r:{type:"radialLinear"}}});class Mu extends jr{getLabelAndValue(t){const n=this._cachedMeta,r=this.chart.data.labels||[],{xScale:i,yScale:o}=n,s=this.getParsed(t),a=i.getLabelForValue(s.x),l=o.getLabelForValue(s.y);return{label:r[t]||"",value:"("+a+", "+l+")"}}update(t){const n=this._cachedMeta,{data:r=[]}=n,i=this.chart._animationsDisabled;let{start:o,count:s}=C1(n,r,i);if(this._drawStart=o,this._drawCount=s,j1(n)&&(o=0,s=r.length),this.options.showLine){this.datasetElementType||this.addElements();const{dataset:a,_dataset:l}=n;a._chart=this.chart,a._datasetIndex=this.index,a._decimated=!!l._decimated,a.points=r;const c=this.resolveDatasetElementOptions(t);c.segment=this.options.segment,this.updateElement(a,void 0,{animated:!i,options:c},t)}else this.datasetElementType&&(delete n.dataset,this.datasetElementType=!1);this.updateElements(r,o,s,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,n,r,i){const o=i==="reset",{iScale:s,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,u=this.resolveDataElementOptions(n,i),d=this.getSharedOptions(u),f=this.includeOptions(i,d),h=s.axis,g=a.axis,{spanGaps:m,segment:x}=this.options,y=na(m)?m:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||i==="none";let w=n>0&&this.getParsed(n-1);for(let E=n;E<n+r;++E){const C=t[E],S=this.getParsed(E),M=b?C:{},L=Ne(S[g]),T=M[h]=s.getPixelForValue(S[h],E),V=M[g]=o||L?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,S,l):S[g],E);M.skip=isNaN(T)||isNaN(V)||L,M.stop=E>0&&Math.abs(S[h]-w[h])>y,x&&(M.parsed=S,M.raw=c.data[E]),f&&(M.options=d||this.resolveDataElementOptions(E,C.active?"active":i)),b||this.updateElement(C,E,M,i),w=S}this.updateSharedOptions(d,i,u)}getMaxOverflow(){const t=this._cachedMeta,n=t.data||[];if(!this.options.showLine){let a=0;for(let l=n.length-1;l>=0;--l)a=Math.max(a,n[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}const r=t.dataset,i=r.options&&r.options.borderWidth||0;if(!n.length)return i;const o=n[0].size(this.resolveDataElementOptions(0)),s=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(i,o,s)/2}}Z(Mu,"id","scatter"),Z(Mu,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),Z(Mu,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});var _2=Object.freeze({__proto__:null,BarController:Ru,BubbleController:Lu,DoughnutController:Po,LineController:Au,PieController:Em,PolarAreaController:fl,RadarController:Pu,ScatterController:Mu});function wo(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class xv{constructor(t){Z(this,"options");this.options=t||{}}static override(t){Object.assign(xv.prototype,t)}init(){}formats(){return wo()}parse(){return wo()}format(){return wo()}add(){return wo()}diff(){return wo()}startOf(){return wo()}endOf(){return wo()}}var k2={_date:xv};function S2(e,t,n,r){const{controller:i,data:o,_sorted:s}=e,a=i._cachedMeta.iScale,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&s&&o.length){const c=a._reversePixels?$D:ai;if(r){if(i._sharedOptions){const u=o[0],d=typeof u.getRange=="function"&&u.getRange(t);if(d){const f=c(o,t,n-d),h=c(o,t,n+d);return{lo:f.lo,hi:h.hi}}}}else{const u=c(o,t,n);if(l){const{vScale:d}=i._cachedMeta,{_parsed:f}=e,h=f.slice(0,u.lo+1).reverse().findIndex(m=>!Ne(m[d.axis]));u.lo-=Math.max(0,h);const g=f.slice(u.hi).findIndex(m=>!Ne(m[d.axis]));u.hi+=Math.max(0,g)}return u}}return{lo:0,hi:o.length-1}}function yf(e,t,n,r,i){const o=e.getSortedVisibleDatasetMetas(),s=n[t];for(let a=0,l=o.length;a<l;++a){const{index:c,data:u}=o[a],{lo:d,hi:f}=S2(o[a],t,s,i);for(let h=d;h<=f;++h){const g=u[h];g.skip||r(g,c,h)}}}function E2(e){const t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(r,i){const o=t?Math.abs(r.x-i.x):0,s=n?Math.abs(r.y-i.y):0;return Math.sqrt(Math.pow(o,2)+Math.pow(s,2))}}function Vh(e,t,n,r,i){const o=[];return!i&&!e.isPointInArea(t)||yf(e,n,t,function(a,l,c){!i&&!li(a,e.chartArea,0)||a.inRange(t.x,t.y,r)&&o.push({element:a,datasetIndex:l,index:c})},!0),o}function O2(e,t,n,r){let i=[];function o(s,a,l){const{startAngle:c,endAngle:u}=s.getProps(["startAngle","endAngle"],r),{angle:d}=_1(s,{x:t.x,y:t.y});Wl(d,c,u)&&i.push({element:s,datasetIndex:a,index:l})}return yf(e,n,t,o),i}function C2(e,t,n,r,i,o){let s=[];const a=E2(n);let l=Number.POSITIVE_INFINITY;function c(u,d,f){const h=u.inRange(t.x,t.y,i);if(r&&!h)return;const g=u.getCenterPoint(i);if(!(!!o||e.isPointInArea(g))&&!h)return;const x=a(t,g);x<l?(s=[{element:u,datasetIndex:d,index:f}],l=x):x===l&&s.push({element:u,datasetIndex:d,index:f})}return yf(e,n,t,c),s}function qh(e,t,n,r,i,o){return!o&&!e.isPointInArea(t)?[]:n==="r"&&!r?O2(e,t,n,i):C2(e,t,n,r,i,o)}function gw(e,t,n,r,i){const o=[],s=n==="x"?"inXRange":"inYRange";let a=!1;return yf(e,n,t,(l,c,u)=>{l[s]&&l[s](t[n],i)&&(o.push({element:l,datasetIndex:c,index:u}),a=a||l.inRange(t.x,t.y,i))}),r&&!a?[]:o}var j2={modes:{index(e,t,n,r){const i=Eo(t,e),o=n.axis||"x",s=n.includeInvisible||!1,a=n.intersect?Vh(e,i,o,r,s):qh(e,i,o,!1,r,s),l=[];return a.length?(e.getSortedVisibleDatasetMetas().forEach(c=>{const u=a[0].index,d=c.data[u];d&&!d.skip&&l.push({element:d,datasetIndex:c.index,index:u})}),l):[]},dataset(e,t,n,r){const i=Eo(t,e),o=n.axis||"xy",s=n.includeInvisible||!1;let a=n.intersect?Vh(e,i,o,r,s):qh(e,i,o,!1,r,s);if(a.length>0){const l=a[0].datasetIndex,c=e.getDatasetMeta(l).data;a=[];for(let u=0;u<c.length;++u)a.push({element:c[u],datasetIndex:l,index:u})}return a},point(e,t,n,r){const i=Eo(t,e),o=n.axis||"xy",s=n.includeInvisible||!1;return Vh(e,i,o,r,s)},nearest(e,t,n,r){const i=Eo(t,e),o=n.axis||"xy",s=n.includeInvisible||!1;return qh(e,i,o,n.intersect,r,s)},x(e,t,n,r){const i=Eo(t,e);return gw(e,i,"x",n.intersect,r)},y(e,t,n,r){const i=Eo(t,e);return gw(e,i,"y",n.intersect,r)}}};const K1=["left","top","right","bottom"];function La(e,t){return e.filter(n=>n.pos===t)}function vw(e,t){return e.filter(n=>K1.indexOf(n.pos)===-1&&n.box.axis===t)}function Aa(e,t){return e.sort((n,r)=>{const i=t?r:n,o=t?n:r;return i.weight===o.weight?i.index-o.index:i.weight-o.weight})}function R2(e){const t=[];let n,r,i,o,s,a;for(n=0,r=(e||[]).length;n<r;++n)i=e[n],{position:o,options:{stack:s,stackWeight:a=1}}=i,t.push({index:n,box:i,pos:o,horizontal:i.isHorizontal(),weight:i.weight,stack:s&&o+s,stackWeight:a});return t}function L2(e){const t={};for(const n of e){const{stack:r,pos:i,stackWeight:o}=n;if(!r||!K1.includes(i))continue;const s=t[r]||(t[r]={count:0,placed:0,weight:0,size:0});s.count++,s.weight+=o}return t}function A2(e,t){const n=L2(e),{vBoxMaxWidth:r,hBoxMaxHeight:i}=t;let o,s,a;for(o=0,s=e.length;o<s;++o){a=e[o];const{fullSize:l}=a.box,c=n[a.stack],u=c&&a.stackWeight/c.weight;a.horizontal?(a.width=u?u*r:l&&t.availableWidth,a.height=i):(a.width=r,a.height=u?u*i:l&&t.availableHeight)}return n}function P2(e){const t=R2(e),n=Aa(t.filter(c=>c.box.fullSize),!0),r=Aa(La(t,"left"),!0),i=Aa(La(t,"right")),o=Aa(La(t,"top"),!0),s=Aa(La(t,"bottom")),a=vw(t,"x"),l=vw(t,"y");return{fullSize:n,leftAndTop:r.concat(o),rightAndBottom:i.concat(l).concat(s).concat(a),chartArea:La(t,"chartArea"),vertical:r.concat(i).concat(l),horizontal:o.concat(s).concat(a)}}function yw(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function Y1(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function M2(e,t,n,r){const{pos:i,box:o}=n,s=e.maxPadding;if(!He(i)){n.size&&(e[i]-=n.size);const d=r[n.stack]||{size:0,count:1};d.size=Math.max(d.size,n.horizontal?o.height:o.width),n.size=d.size/d.count,e[i]+=n.size}o.getPadding&&Y1(s,o.getPadding());const a=Math.max(0,t.outerWidth-yw(s,e,"left","right")),l=Math.max(0,t.outerHeight-yw(s,e,"top","bottom")),c=a!==e.w,u=l!==e.h;return e.w=a,e.h=l,n.horizontal?{same:c,other:u}:{same:u,other:c}}function T2(e){const t=e.maxPadding;function n(r){const i=Math.max(t[r]-e[r],0);return e[r]+=i,i}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function D2(e,t){const n=t.maxPadding;function r(i){const o={left:0,top:0,right:0,bottom:0};return i.forEach(s=>{o[s]=Math.max(t[s],n[s])}),o}return r(e?["left","right"]:["top","bottom"])}function $a(e,t,n,r){const i=[];let o,s,a,l,c,u;for(o=0,s=e.length,c=0;o<s;++o){a=e[o],l=a.box,l.update(a.width||t.w,a.height||t.h,D2(a.horizontal,t));const{same:d,other:f}=M2(t,n,a,r);c|=d&&i.length,u=u||f,l.fullSize||i.push(a)}return c&&$a(i,t,n,r)||u}function eu(e,t,n,r,i){e.top=n,e.left=t,e.right=t+r,e.bottom=n+i,e.width=r,e.height=i}function bw(e,t,n,r){const i=n.padding;let{x:o,y:s}=t;for(const a of e){const l=a.box,c=r[a.stack]||{placed:0,weight:1},u=a.stackWeight/c.weight||1;if(a.horizontal){const d=t.w*u,f=c.size||l.height;Hl(c.start)&&(s=c.start),l.fullSize?eu(l,i.left,s,n.outerWidth-i.right-i.left,f):eu(l,t.left+c.placed,s,d,f),c.start=s,c.placed+=d,s=l.bottom}else{const d=t.h*u,f=c.size||l.width;Hl(c.start)&&(o=c.start),l.fullSize?eu(l,o,i.top,f,n.outerHeight-i.bottom-i.top):eu(l,o,t.top+c.placed,f,d),c.start=o,c.placed+=d,o=l.right}}t.x=o,t.y=s}var bn={addBox(e,t){e.boxes||(e.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(n){t.draw(n)}}]},e.boxes.push(t)},removeBox(e,t){const n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,r){if(!e)return;const i=wn(e.options.layout.padding),o=Math.max(t-i.width,0),s=Math.max(n-i.height,0),a=P2(e.boxes),l=a.vertical,c=a.horizontal;tt(e.boxes,m=>{typeof m.beforeLayout=="function"&&m.beforeLayout()});const u=l.reduce((m,x)=>x.box.options&&x.box.options.display===!1?m:m+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:o,availableHeight:s,vBoxMaxWidth:o/2/u,hBoxMaxHeight:s/2}),f=Object.assign({},i);Y1(f,wn(r));const h=Object.assign({maxPadding:f,w:o,h:s,x:i.left,y:i.top},i),g=A2(l.concat(c),d);$a(a.fullSize,h,d,g),$a(l,h,d,g),$a(c,h,d,g)&&$a(l,h,d,g),T2(h),bw(a.leftAndTop,h,d,g),h.x+=h.w,h.y+=h.h,bw(a.rightAndBottom,h,d,g),e.chartArea={left:h.left,top:h.top,right:h.left+h.w,bottom:h.top+h.h,height:h.h,width:h.w},tt(a.chartArea,m=>{const x=m.box;Object.assign(x,e.chartArea),x.update(h.w,h.h,{left:0,top:0,right:0,bottom:0})})}};class G1{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,r){}removeEventListener(t,n,r){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,r,i){return n=Math.max(0,n||t.width),r=r||t.height,{width:n,height:Math.max(0,i?Math.floor(n/i):r)}}isAttached(t){return!0}updateConfig(t){}}class I2 extends G1{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const Tu="$chartjs",F2={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},xw=e=>e===null||e==="";function N2(e,t){const n=e.style,r=e.getAttribute("height"),i=e.getAttribute("width");if(e[Tu]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",xw(i)){const o=rw(e,"width");o!==void 0&&(e.width=o)}if(xw(r))if(e.style.height==="")e.height=e.width/(t||2);else{const o=rw(e,"height");o!==void 0&&(e.height=o)}return e}const J1=zI?{passive:!0}:!1;function z2(e,t,n){e&&e.addEventListener(t,n,J1)}function B2(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,J1)}function U2(e,t){const n=F2[e.type]||e.type,{x:r,y:i}=Eo(e,t);return{type:n,chart:t,native:e,x:r!==void 0?r:null,y:i!==void 0?i:null}}function Rd(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function H2(e,t,n){const r=e.canvas,i=new MutationObserver(o=>{let s=!1;for(const a of o)s=s||Rd(a.addedNodes,r),s=s&&!Rd(a.removedNodes,r);s&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function W2(e,t,n){const r=e.canvas,i=new MutationObserver(o=>{let s=!1;for(const a of o)s=s||Rd(a.removedNodes,r),s=s&&!Rd(a.addedNodes,r);s&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}const ql=new Map;let ww=0;function X1(){const e=window.devicePixelRatio;e!==ww&&(ww=e,ql.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function V2(e,t){ql.size||window.addEventListener("resize",X1),ql.set(e,t)}function q2(e){ql.delete(e),ql.size||window.removeEventListener("resize",X1)}function $2(e,t,n){const r=e.canvas,i=r&&bv(r);if(!i)return;const o=O1((a,l)=>{const c=i.clientWidth;n(a,l),c<i.clientWidth&&n()},window),s=new ResizeObserver(a=>{const l=a[0],c=l.contentRect.width,u=l.contentRect.height;c===0&&u===0||o(c,u)});return s.observe(i),V2(e,o),s}function $h(e,t,n){n&&n.disconnect(),t==="resize"&&q2(e)}function K2(e,t,n){const r=e.canvas,i=O1(o=>{e.ctx!==null&&n(U2(o,e))},e);return z2(r,t,i),i}class Y2 extends G1{acquireContext(t,n){const r=t&&t.getContext&&t.getContext("2d");return r&&r.canvas===t?(N2(t,n),r):null}releaseContext(t){const n=t.canvas;if(!n[Tu])return!1;const r=n[Tu].initial;["height","width"].forEach(o=>{const s=r[o];Ne(s)?n.removeAttribute(o):n.setAttribute(o,s)});const i=r.style||{};return Object.keys(i).forEach(o=>{n.style[o]=i[o]}),n.width=n.width,delete n[Tu],!0}addEventListener(t,n,r){this.removeEventListener(t,n);const i=t.$proxies||(t.$proxies={}),s={attach:H2,detach:W2,resize:$2}[n]||K2;i[n]=s(t,n,r)}removeEventListener(t,n){const r=t.$proxies||(t.$proxies={}),i=r[n];if(!i)return;({attach:$h,detach:$h,resize:$h}[n]||B2)(t,n,i),r[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,r,i){return NI(t,n,r,i)}isAttached(t){const n=t&&bv(t);return!!(n&&n.isConnected)}}function G2(e){return!yv()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?I2:Y2}class Ar{constructor(){Z(this,"x");Z(this,"y");Z(this,"active",!1);Z(this,"options");Z(this,"$animations")}tooltipPosition(t){const{x:n,y:r}=this.getProps(["x","y"],t);return{x:n,y:r}}hasValue(){return na(this.x)&&na(this.y)}getProps(t,n){const r=this.$animations;if(!n||!r)return this;const i={};return t.forEach(o=>{i[o]=r[o]&&r[o].active()?r[o]._to:this[o]}),i}}Z(Ar,"defaults",{}),Z(Ar,"defaultRoutes");function J2(e,t){const n=e.options.ticks,r=X2(e),i=Math.min(n.maxTicksLimit||r,r),o=n.major.enabled?Z2(t):[],s=o.length,a=o[0],l=o[s-1],c=[];if(s>i)return eF(t,c,o,s/i),c;const u=Q2(o,t,i);if(s>0){let d,f;const h=s>1?Math.round((l-a)/(s-1)):null;for(tu(t,c,u,Ne(h)?0:a-h,a),d=0,f=s-1;d<f;d++)tu(t,c,u,o[d],o[d+1]);return tu(t,c,u,l,Ne(h)?t.length:l+h),c}return tu(t,c,u),c}function X2(e){const t=e.options.offset,n=e._tickSize(),r=e._length/n+(t?0:1),i=e._maxLength/n;return Math.floor(Math.min(r,i))}function Q2(e,t,n){const r=tF(e),i=t.length/n;if(!r)return Math.max(i,1);const o=UD(r);for(let s=0,a=o.length-1;s<a;s++){const l=o[s];if(l>i)return l}return Math.max(i,1)}function Z2(e){const t=[];let n,r;for(n=0,r=e.length;n<r;n++)e[n].major&&t.push(n);return t}function eF(e,t,n,r){let i=0,o=n[0],s;for(r=Math.ceil(r),s=0;s<e.length;s++)s===o&&(t.push(e[s]),i++,o=n[i*r])}function tu(e,t,n,r,i){const o=Le(r,0),s=Math.min(Le(i,e.length),e.length);let a=0,l,c,u;for(n=Math.ceil(n),i&&(l=i-r,n=l/Math.floor(l/n)),u=o;u<0;)a++,u=Math.round(o+a*n);for(c=Math.max(o,0);c<s;c++)c===u&&(t.push(e[c]),a++,u=Math.round(o+a*n))}function tF(e){const t=e.length;let n,r;if(t<2)return!1;for(r=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==r)return!1;return r}const nF=e=>e==="left"?"right":e==="right"?"left":e,_w=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,kw=(e,t)=>Math.min(t||e,e);function Sw(e,t){const n=[],r=e.length/t,i=e.length;let o=0;for(;o<i;o+=r)n.push(e[Math.floor(o)]);return n}function rF(e,t,n){const r=e.ticks.length,i=Math.min(t,r-1),o=e._startPixel,s=e._endPixel,a=1e-6;let l=e.getPixelForTick(i),c;if(!(n&&(r===1?c=Math.max(l-o,s-l):t===0?c=(e.getPixelForTick(1)-l)/2:c=(l-e.getPixelForTick(i-1))/2,l+=i<t?c:-c,l<o-a||l>s+a)))return l}function iF(e,t){tt(e,n=>{const r=n.gc,i=r.length/2;let o;if(i>t){for(o=0;o<i;++o)delete n.data[r[o]];r.splice(0,i)}})}function Pa(e){return e.drawTicks?e.tickLength:0}function Ew(e,t){if(!e.display)return 0;const n=Gt(e.font,t),r=wn(e.padding);return(wt(e.text)?e.text.length:1)*n.lineHeight+r.height}function oF(e,t){return lo(e,{scale:t,type:"scale"})}function sF(e,t,n){return lo(e,{tick:n,index:t,type:"tick"})}function aF(e,t,n){let r=fv(e);return(n&&t!=="right"||!n&&t==="right")&&(r=nF(r)),r}function lF(e,t,n,r){const{top:i,left:o,bottom:s,right:a,chart:l}=e,{chartArea:c,scales:u}=l;let d=0,f,h,g;const m=s-i,x=a-o;if(e.isHorizontal()){if(h=pn(r,o,a),He(n)){const y=Object.keys(n)[0],b=n[y];g=u[y].getPixelForValue(b)+m-t}else n==="center"?g=(c.bottom+c.top)/2+m-t:g=_w(e,n,t);f=a-o}else{if(He(n)){const y=Object.keys(n)[0],b=n[y];h=u[y].getPixelForValue(b)-x+t}else n==="center"?h=(c.left+c.right)/2-x+t:h=_w(e,n,t);g=pn(r,s,i),d=n==="left"?-Bt:Bt}return{titleX:h,titleY:g,maxWidth:f,rotation:d}}class ns extends Ar{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,n){return t}getUserBounds(){let{_userMin:t,_userMax:n,_suggestedMin:r,_suggestedMax:i}=this;return t=Yn(t,Number.POSITIVE_INFINITY),n=Yn(n,Number.NEGATIVE_INFINITY),r=Yn(r,Number.POSITIVE_INFINITY),i=Yn(i,Number.NEGATIVE_INFINITY),{min:Yn(t,r),max:Yn(n,i),minDefined:It(t),maxDefined:It(n)}}getMinMax(t){let{min:n,max:r,minDefined:i,maxDefined:o}=this.getUserBounds(),s;if(i&&o)return{min:n,max:r};const a=this.getMatchingVisibleMetas();for(let l=0,c=a.length;l<c;++l)s=a[l].controller.getMinMax(this,t),i||(n=Math.min(n,s.min)),o||(r=Math.max(r,s.max));return n=o&&n>r?r:n,r=i&&n>r?n:r,{min:Yn(n,Yn(r,n)),max:Yn(r,Yn(n,r))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){dt(this.options.beforeUpdate,[this])}update(t,n,r){const{beginAtZero:i,grace:o,ticks:s}=this.options,a=s.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=r=Object.assign({left:0,right:0,top:0,bottom:0},r),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+r.left+r.right:this.height+r.top+r.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=gI(this,o,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a<this.ticks.length;this._convertTicksToLabels(l?Sw(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),s.display&&(s.autoSkip||s.source==="auto")&&(this.ticks=J2(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),l&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,n,r;this.isHorizontal()?(n=this.left,r=this.right):(n=this.top,r=this.bottom,t=!t),this._startPixel=n,this._endPixel=r,this._reversePixels=t,this._length=r-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){dt(this.options.afterUpdate,[this])}beforeSetDimensions(){dt(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){dt(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),dt(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){dt(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const n=this.options.ticks;let r,i,o;for(r=0,i=t.length;r<i;r++)o=t[r],o.label=dt(n.callback,[o.value,r,t],this)}afterTickToLabelConversion(){dt(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){dt(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,n=t.ticks,r=kw(this.ticks.length,t.ticks.maxTicksLimit),i=n.minRotation||0,o=n.maxRotation;let s=i,a,l,c;if(!this._isVisible()||!n.display||i>=o||r<=1||!this.isHorizontal()){this.labelRotation=i;return}const u=this._getLabelSizes(),d=u.widest.width,f=u.highest.height,h=Zt(this.chart.width-d,0,this.maxWidth);a=t.offset?this.maxWidth/r:h/(r-1),d+6>a&&(a=h/(r-(t.offset?.5:1)),l=this.maxHeight-Pa(t.grid)-n.padding-Ew(t.title,this.chart.options.font),c=Math.sqrt(d*d+f*f),s=uv(Math.min(Math.asin(Zt((u.highest.height+6)/a,-1,1)),Math.asin(Zt(l/c,-1,1))-Math.asin(Zt(f/c,-1,1)))),s=Math.max(i,Math.min(o,s))),this.labelRotation=s}afterCalculateLabelRotation(){dt(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){dt(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:n,options:{ticks:r,title:i,grid:o}}=this,s=this._isVisible(),a=this.isHorizontal();if(s){const l=Ew(i,n.options.font);if(a?(t.width=this.maxWidth,t.height=Pa(o)+l):(t.height=this.maxHeight,t.width=Pa(o)+l),r.display&&this.ticks.length){const{first:c,last:u,widest:d,highest:f}=this._getLabelSizes(),h=r.padding*2,g=Er(this.labelRotation),m=Math.cos(g),x=Math.sin(g);if(a){const y=r.mirror?0:x*d.width+m*f.height;t.height=Math.min(this.maxHeight,t.height+y+h)}else{const y=r.mirror?0:m*d.width+x*f.height;t.width=Math.min(this.maxWidth,t.width+y+h)}this._calculatePadding(c,u,x,m)}}this._handleMargins(),a?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,n,r,i){const{ticks:{align:o,padding:s},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const u=this.getPixelForTick(0)-this.left,d=this.right-this.getPixelForTick(this.ticks.length-1);let f=0,h=0;l?c?(f=i*t.width,h=r*n.height):(f=r*t.height,h=i*n.width):o==="start"?h=n.width:o==="end"?f=t.width:o!=="inner"&&(f=t.width/2,h=n.width/2),this.paddingLeft=Math.max((f-u+s)*this.width/(this.width-u),0),this.paddingRight=Math.max((h-d+s)*this.width/(this.width-d),0)}else{let u=n.height/2,d=t.height/2;o==="start"?(u=0,d=t.height):o==="end"&&(u=n.height,d=0),this.paddingTop=u+s,this.paddingBottom=d+s}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){dt(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:n}=this.options;return n==="top"||n==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let n,r;for(n=0,r=t.length;n<r;n++)Ne(t[n].label)&&(t.splice(n,1),r--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const n=this.options.ticks.sampleSize;let r=this.ticks;n<r.length&&(r=Sw(r,n)),this._labelSizes=t=this._computeLabelSizes(r,r.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,r){const{ctx:i,_longestTextCache:o}=this,s=[],a=[],l=Math.floor(n/kw(n,r));let c=0,u=0,d,f,h,g,m,x,y,b,w,E,C;for(d=0;d<n;d+=l){if(g=t[d].label,m=this._resolveTickFontOptions(d),i.font=x=m.string,y=o[x]=o[x]||{data:{},gc:[]},b=m.lineHeight,w=E=0,!Ne(g)&&!wt(g))w=Cd(i,y.data,y.gc,w,g),E=b;else if(wt(g))for(f=0,h=g.length;f<h;++f)C=g[f],!Ne(C)&&!wt(C)&&(w=Cd(i,y.data,y.gc,w,C),E+=b);s.push(w),a.push(E),c=Math.max(w,c),u=Math.max(E,u)}iF(o,n);const S=s.indexOf(c),M=a.indexOf(u),L=T=>({width:s[T]||0,height:a[T]||0});return{first:L(0),last:L(n-1),widest:L(S),highest:L(M),widths:s,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,n){return NaN}getValueForPixel(t){}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const n=this._startPixel+t*this._length;return qD(this._alignToPixels?xo(this.chart,n,0):n)}getDecimalForPixel(t){const n=(t-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:n}=this;return t<0&&n<0?n:t>0&&n>0?t:0}getContext(t){const n=this.ticks||[];if(t>=0&&t<n.length){const r=n[t];return r.$context||(r.$context=sF(this.getContext(),t,r))}return this.$context||(this.$context=oF(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,n=Er(this.labelRotation),r=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n)),o=this._getLabelSizes(),s=t.autoSkipPadding||0,a=o?o.widest.width+s:0,l=o?o.highest.height+s:0;return this.isHorizontal()?l*r>a*i?a/r:l/i:l*i<a*r?l/r:a/i}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const n=this.axis,r=this.chart,i=this.options,{grid:o,position:s,border:a}=i,l=o.offset,c=this.isHorizontal(),d=this.ticks.length+(l?1:0),f=Pa(o),h=[],g=a.setContext(this.getContext()),m=g.display?g.width:0,x=m/2,y=function(re){return xo(r,re,m)};let b,w,E,C,S,M,L,T,V,G,F,te;if(s==="top")b=y(this.bottom),M=this.bottom-f,T=b-x,G=y(t.top)+x,te=t.bottom;else if(s==="bottom")b=y(this.top),G=t.top,te=y(t.bottom)-x,M=b+x,T=this.top+f;else if(s==="left")b=y(this.right),S=this.right-f,L=b-x,V=y(t.left)+x,F=t.right;else if(s==="right")b=y(this.left),V=t.left,F=y(t.right)-x,S=b+x,L=this.left+f;else if(n==="x"){if(s==="center")b=y((t.top+t.bottom)/2+.5);else if(He(s)){const re=Object.keys(s)[0],pe=s[re];b=y(this.chart.scales[re].getPixelForValue(pe))}G=t.top,te=t.bottom,M=b+x,T=M+f}else if(n==="y"){if(s==="center")b=y((t.left+t.right)/2);else if(He(s)){const re=Object.keys(s)[0],pe=s[re];b=y(this.chart.scales[re].getPixelForValue(pe))}S=b-x,L=S-f,V=t.left,F=t.right}const W=Le(i.ticks.maxTicksLimit,d),Y=Math.max(1,Math.ceil(d/W));for(w=0;w<d;w+=Y){const re=this.getContext(w),pe=o.setContext(re),B=a.setContext(re),ee=pe.lineWidth,ce=pe.color,ve=B.dash||[],ke=B.dashOffset,je=pe.tickWidth,ie=pe.tickColor,me=pe.tickBorderDash||[],xe=pe.tickBorderDashOffset;E=rF(this,w,l),E!==void 0&&(C=xo(r,E,ee),c?S=L=V=F=C:M=T=G=te=C,h.push({tx1:S,ty1:M,tx2:L,ty2:T,x1:V,y1:G,x2:F,y2:te,width:ee,color:ce,borderDash:ve,borderDashOffset:ke,tickWidth:je,tickColor:ie,tickBorderDash:me,tickBorderDashOffset:xe}))}return this._ticksLength=d,this._borderValue=b,h}_computeLabelItems(t){const n=this.axis,r=this.options,{position:i,ticks:o}=r,s=this.isHorizontal(),a=this.ticks,{align:l,crossAlign:c,padding:u,mirror:d}=o,f=Pa(r.grid),h=f+u,g=d?-u:h,m=-Er(this.labelRotation),x=[];let y,b,w,E,C,S,M,L,T,V,G,F,te="middle";if(i==="top")S=this.bottom-g,M=this._getXAxisLabelAlignment();else if(i==="bottom")S=this.top+g,M=this._getXAxisLabelAlignment();else if(i==="left"){const Y=this._getYAxisLabelAlignment(f);M=Y.textAlign,C=Y.x}else if(i==="right"){const Y=this._getYAxisLabelAlignment(f);M=Y.textAlign,C=Y.x}else if(n==="x"){if(i==="center")S=(t.top+t.bottom)/2+h;else if(He(i)){const Y=Object.keys(i)[0],re=i[Y];S=this.chart.scales[Y].getPixelForValue(re)+h}M=this._getXAxisLabelAlignment()}else if(n==="y"){if(i==="center")C=(t.left+t.right)/2-h;else if(He(i)){const Y=Object.keys(i)[0],re=i[Y];C=this.chart.scales[Y].getPixelForValue(re)}M=this._getYAxisLabelAlignment(f).textAlign}n==="y"&&(l==="start"?te="top":l==="end"&&(te="bottom"));const W=this._getLabelSizes();for(y=0,b=a.length;y<b;++y){w=a[y],E=w.label;const Y=o.setContext(this.getContext(y));L=this.getPixelForTick(y)+o.labelOffset,T=this._resolveTickFontOptions(y),V=T.lineHeight,G=wt(E)?E.length:1;const re=G/2,pe=Y.color,B=Y.textStrokeColor,ee=Y.textStrokeWidth;let ce=M;s?(C=L,M==="inner"&&(y===b-1?ce=this.options.reverse?"left":"right":y===0?ce=this.options.reverse?"right":"left":ce="center"),i==="top"?c==="near"||m!==0?F=-G*V+V/2:c==="center"?F=-W.highest.height/2-re*V+V:F=-W.highest.height+V/2:c==="near"||m!==0?F=V/2:c==="center"?F=W.highest.height/2-re*V:F=W.highest.height-G*V,d&&(F*=-1),m!==0&&!Y.showLabelBackdrop&&(C+=V/2*Math.sin(m))):(S=L,F=(1-G)*V/2);let ve;if(Y.showLabelBackdrop){const ke=wn(Y.backdropPadding),je=W.heights[y],ie=W.widths[y];let me=F-ke.top,xe=0-ke.left;switch(te){case"middle":me-=je/2;break;case"bottom":me-=je;break}switch(M){case"center":xe-=ie/2;break;case"right":xe-=ie;break;case"inner":y===b-1?xe-=ie:y>0&&(xe-=ie/2);break}ve={left:xe,top:me,width:ie+ke.width,height:je+ke.height,color:Y.backdropColor}}x.push({label:E,font:T,textOffset:F,options:{rotation:m,color:pe,strokeColor:B,strokeWidth:ee,textAlign:ce,textBaseline:te,translation:[C,S],backdrop:ve}})}return x}_getXAxisLabelAlignment(){const{position:t,ticks:n}=this.options;if(-Er(this.labelRotation))return t==="top"?"left":"right";let i="center";return n.align==="start"?i="left":n.align==="end"?i="right":n.align==="inner"&&(i="inner"),i}_getYAxisLabelAlignment(t){const{position:n,ticks:{crossAlign:r,mirror:i,padding:o}}=this.options,s=this._getLabelSizes(),a=t+o,l=s.widest.width;let c,u;return n==="left"?i?(u=this.right+o,r==="near"?c="left":r==="center"?(c="center",u+=l/2):(c="right",u+=l)):(u=this.right-a,r==="near"?c="right":r==="center"?(c="center",u-=l/2):(c="left",u=this.left)):n==="right"?i?(u=this.left+o,r==="near"?c="right":r==="center"?(c="center",u-=l/2):(c="left",u-=l)):(u=this.left+a,r==="near"?c="left":r==="center"?(c="center",u+=l/2):(c="right",u=this.right)):c="right",{textAlign:c,x:u}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:n},left:r,top:i,width:o,height:s}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(r,i,o,s),t.restore())}getLineWidthForValue(t){const n=this.options.grid;if(!this._isVisible()||!n.display)return 0;const i=this.ticks.findIndex(o=>o.value===t);return i>=0?n.setContext(this.getContext(i)).lineWidth:0}drawGrid(t){const n=this.options.grid,r=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,s;const a=(l,c,u)=>{!u.width||!u.color||(r.save(),r.lineWidth=u.width,r.strokeStyle=u.color,r.setLineDash(u.borderDash||[]),r.lineDashOffset=u.borderDashOffset,r.beginPath(),r.moveTo(l.x,l.y),r.lineTo(c.x,c.y),r.stroke(),r.restore())};if(n.display)for(o=0,s=i.length;o<s;++o){const l=i[o];n.drawOnChartArea&&a({x:l.x1,y:l.y1},{x:l.x2,y:l.y2},l),n.drawTicks&&a({x:l.tx1,y:l.ty1},{x:l.tx2,y:l.ty2},{color:l.tickColor,width:l.tickWidth,borderDash:l.tickBorderDash,borderDashOffset:l.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:n,options:{border:r,grid:i}}=this,o=r.setContext(this.getContext()),s=r.display?o.width:0;if(!s)return;const a=i.setContext(this.getContext(0)).lineWidth,l=this._borderValue;let c,u,d,f;this.isHorizontal()?(c=xo(t,this.left,s)-s/2,u=xo(t,this.right,a)+a/2,d=f=l):(d=xo(t,this.top,s)-s/2,f=xo(t,this.bottom,a)+a/2,c=u=l),n.save(),n.lineWidth=o.width,n.strokeStyle=o.color,n.beginPath(),n.moveTo(c,d),n.lineTo(u,f),n.stroke(),n.restore()}drawLabels(t){if(!this.options.ticks.display)return;const r=this.ctx,i=this._computeLabelArea();i&&mf(r,i);const o=this.getLabelItems(t);for(const s of o){const a=s.options,l=s.font,c=s.label,u=s.textOffset;Jo(r,c,0,u,l,a)}i&&gf(r)}drawTitle(){const{ctx:t,options:{position:n,title:r,reverse:i}}=this;if(!r.display)return;const o=Gt(r.font),s=wn(r.padding),a=r.align;let l=o.lineHeight/2;n==="bottom"||n==="center"||He(n)?(l+=s.bottom,wt(r.text)&&(l+=o.lineHeight*(r.text.length-1))):l+=s.top;const{titleX:c,titleY:u,maxWidth:d,rotation:f}=lF(this,l,n,a);Jo(t,r.text,0,0,o,{color:r.color,maxWidth:d,rotation:f,textAlign:aF(a,n,i),textBaseline:"middle",translation:[c,u]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,n=t.ticks&&t.ticks.z||0,r=Le(t.grid&&t.grid.z,-1),i=Le(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==ns.prototype.draw?[{z:n,draw:o=>{this.draw(o)}}]:[{z:r,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),r=this.axis+"AxisID",i=[];let o,s;for(o=0,s=n.length;o<s;++o){const a=n[o];a[r]===this.id&&(!t||a.type===t)&&i.push(a)}return i}_resolveTickFontOptions(t){const n=this.options.ticks.setContext(this.getContext(t));return Gt(n.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class nu{constructor(t,n,r){this.type=t,this.scope=n,this.override=r,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const n=Object.getPrototypeOf(t);let r;dF(n)&&(r=this.register(n));const i=this.items,o=t.id,s=this.scope+"."+o;if(!o)throw new Error("class does not have id: "+t);return o in i||(i[o]=t,cF(t,s,r),this.override&&_t.override(t.id,t.overrides)),s}get(t){return this.items[t]}unregister(t){const n=this.items,r=t.id,i=this.scope;r in n&&delete n[r],i&&r in _t[i]&&(delete _t[i][r],this.override&&delete Go[r])}}function cF(e,t,n){const r=Ul(Object.create(null),[n?_t.get(n):{},_t.get(t),e.defaults]);_t.set(t,r),e.defaultRoutes&&uF(t,e.defaultRoutes),e.descriptors&&_t.describe(t,e.descriptors)}function uF(e,t){Object.keys(t).forEach(n=>{const r=n.split("."),i=r.pop(),o=[e].concat(r).join("."),s=t[n].split("."),a=s.pop(),l=s.join(".");_t.route(o,i,l,a)})}function dF(e){return"id"in e&&"defaults"in e}class fF{constructor(){this.controllers=new nu(jr,"datasets",!0),this.elements=new nu(Ar,"elements"),this.plugins=new nu(Object,"plugins"),this.scales=new nu(ns,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,n,r){[...n].forEach(i=>{const o=r||this._getRegistryForType(i);r||o.isForType(i)||o===this.plugins&&i.id?this._exec(t,o,i):tt(i,s=>{const a=r||this._getRegistryForType(s);this._exec(t,a,s)})})}_exec(t,n,r){const i=cv(t);dt(r["before"+i],[],r),n[t](r),dt(r["after"+i],[],r)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){const r=this._typedRegistries[n];if(r.isForType(t))return r}return this.plugins}_get(t,n,r){const i=n.get(t);if(i===void 0)throw new Error('"'+t+'" is not a registered '+r+".");return i}}var zr=new fF;class hF{constructor(){this._init=void 0}notify(t,n,r,i){if(n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),this._init===void 0)return;const o=i?this._descriptors(t).filter(i):this._descriptors(t),s=this._notify(o,t,n,r);return n==="afterDestroy"&&(this._notify(o,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),s}_notify(t,n,r,i){i=i||{};for(const o of t){const s=o.plugin,a=s[r],l=[n,i,o.options];if(dt(a,l,s)===!1&&i.cancelable)return!1}return!0}invalidate(){Ne(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const n=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),n}_createDescriptors(t,n){const r=t&&t.config,i=Le(r.options&&r.options.plugins,{}),o=pF(r);return i===!1&&!n?[]:gF(t,o,i,n)}_notifyStateChanges(t){const n=this._oldCache||[],r=this._cache,i=(o,s)=>o.filter(a=>!s.some(l=>a.plugin.id===l.plugin.id));this._notify(i(n,r),t,"stop"),this._notify(i(r,n),t,"start")}}function pF(e){const t={},n=[],r=Object.keys(zr.plugins.items);for(let o=0;o<r.length;o++)n.push(zr.getPlugin(r[o]));const i=e.plugins||[];for(let o=0;o<i.length;o++){const s=i[o];n.indexOf(s)===-1&&(n.push(s),t[s.id]=!0)}return{plugins:n,localIds:t}}function mF(e,t){return!t&&e===!1?null:e===!0?{}:e}function gF(e,{plugins:t,localIds:n},r,i){const o=[],s=e.getContext();for(const a of t){const l=a.id,c=mF(r[l],i);c!==null&&o.push({plugin:a,options:vF(e.config,{plugin:a,local:n[l]},c,s)})}return o}function vF(e,{plugin:t,local:n},r,i){const o=e.pluginScopeKeys(t),s=e.getOptionScopes(r,o);return n&&t.defaults&&s.push(t.defaults),e.createResolver(s,i,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Om(e,t){const n=_t.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function yF(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function bF(e,t){return e===t?"_index_":"_value_"}function Ow(e){if(e==="x"||e==="y"||e==="r")return e}function xF(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function Cm(e,...t){if(Ow(e))return e;for(const n of t){const r=n.axis||xF(n.position)||e.length>1&&Ow(e[0].toLowerCase());if(r)return r}throw new Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function Cw(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function wF(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(r=>r.xAxisID===e||r.yAxisID===e);if(n.length)return Cw(e,"x",n[0])||Cw(e,"y",n[0])}return{}}function _F(e,t){const n=Go[e.type]||{scales:{}},r=t.scales||{},i=Om(e.type,t),o=Object.create(null);return Object.keys(r).forEach(s=>{const a=r[s];if(!He(a))return console.error(`Invalid scale configuration for scale: ${s}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${s}`);const l=Cm(s,a,wF(s,e),_t.scales[a.type]),c=bF(l,i),u=n.scales||{};o[s]=ll(Object.create(null),[{axis:l},a,u[l],u[c]])}),e.data.datasets.forEach(s=>{const a=s.type||e.type,l=s.indexAxis||Om(a,t),u=(Go[a]||{}).scales||{};Object.keys(u).forEach(d=>{const f=yF(d,l),h=s[f+"AxisID"]||f;o[h]=o[h]||Object.create(null),ll(o[h],[{axis:f},r[h],u[d]])})}),Object.keys(o).forEach(s=>{const a=o[s];ll(a,[_t.scales[a.type],_t.scale])}),o}function Q1(e){const t=e.options||(e.options={});t.plugins=Le(t.plugins,{}),t.scales=_F(e,t)}function Z1(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function kF(e){return e=e||{},e.data=Z1(e.data),Q1(e),e}const jw=new Map,eE=new Set;function ru(e,t){let n=jw.get(e);return n||(n=t(),jw.set(e,n),eE.add(n)),n}const Ma=(e,t,n)=>{const r=to(t,n);r!==void 0&&e.add(r)};class SF{constructor(t){this._config=kF(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Z1(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Q1(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return ru(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,n){return ru(`${t}.transition.${n}`,()=>[[`datasets.${t}.transitions.${n}`,`transitions.${n}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,n){return ru(`${t}-${n}`,()=>[[`datasets.${t}.elements.${n}`,`datasets.${t}`,`elements.${n}`,""]])}pluginScopeKeys(t){const n=t.id,r=this.type;return ru(`${r}-plugin-${n}`,()=>[[`plugins.${n}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const r=this._scopeCache;let i=r.get(t);return(!i||n)&&(i=new Map,r.set(t,i)),i}getOptionScopes(t,n,r){const{options:i,type:o}=this,s=this._cachedScopes(t,r),a=s.get(n);if(a)return a;const l=new Set;n.forEach(u=>{t&&(l.add(t),u.forEach(d=>Ma(l,t,d))),u.forEach(d=>Ma(l,i,d)),u.forEach(d=>Ma(l,Go[o]||{},d)),u.forEach(d=>Ma(l,_t,d)),u.forEach(d=>Ma(l,km,d))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),eE.has(n)&&s.set(n,c),c}chartOptionScopes(){const{options:t,type:n}=this;return[t,Go[n]||{},_t.datasets[n]||{},{type:n},_t,km]}resolveNamedOptions(t,n,r,i=[""]){const o={$shared:!0},{resolver:s,subPrefixes:a}=Rw(this._resolverCache,t,i);let l=s;if(OF(s,n)){o.$shared=!1,r=no(r)?r():r;const c=this.createResolver(t,r,a);l=ra(s,r,c)}for(const c of n)o[c]=l[c];return o}createResolver(t,n,r=[""],i){const{resolver:o}=Rw(this._resolverCache,t,r);return He(n)?ra(o,n,void 0,i):o}}function Rw(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));const i=n.join();let o=r.get(i);return o||(o={resolver:mv(t,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},r.set(i,o)),o}const EF=e=>He(e)&&Object.getOwnPropertyNames(e).some(t=>no(e[t]));function OF(e,t){const{isScriptable:n,isIndexable:r}=P1(e);for(const i of t){const o=n(i),s=r(i),a=(s||o)&&e[i];if(o&&(no(a)||EF(a))||s&&wt(a))return!0}return!1}var CF="4.5.1";const jF=["top","bottom","left","right","chartArea"];function Lw(e,t){return e==="top"||e==="bottom"||jF.indexOf(e)===-1&&t==="x"}function Aw(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function Pw(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),dt(n&&n.onComplete,[e],t)}function RF(e){const t=e.chart,n=t.options.animation;dt(n&&n.onProgress,[e],t)}function tE(e){return yv()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const Du={},Mw=e=>{const t=tE(e);return Object.values(Du).filter(n=>n.canvas===t).pop()};function LF(e,t,n){const r=Object.keys(e);for(const i of r){const o=+i;if(o>=t){const s=e[i];delete e[i],(n>0||o>t)&&(e[o+n]=s)}}}function AF(e,t,n,r){return!n||e.type==="mouseout"?null:r?t:e}class Sr{static register(...t){zr.add(...t),Tw()}static unregister(...t){zr.remove(...t),Tw()}constructor(t,n){const r=this.config=new SF(n),i=tE(t),o=Mw(i);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const s=r.createResolver(r.chartOptionScopes(),this.getContext());this.platform=new(r.platform||G2(i)),this.platform.updateConfig(r);const a=this.platform.acquireContext(i,s.aspectRatio),l=a&&a.canvas,c=l&&l.height,u=l&&l.width;if(this.id=PD(),this.ctx=a,this.canvas=l,this.width=u,this.height=c,this._options=s,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new hF,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=GD(d=>this.update(d),s.resizeDelay||0),this._dataChanges=[],Du[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}Xr.listen(this,"complete",Pw),Xr.listen(this,"progress",RF),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:r,height:i,_aspectRatio:o}=this;return Ne(t)?n&&o?o:i?r/i:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return zr}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():nw(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Zx(this.canvas,this.ctx),this}stop(){return Xr.stop(this),this}resize(t,n){Xr.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const r=this.options,i=this.canvas,o=r.maintainAspectRatio&&this.aspectRatio,s=this.platform.getMaximumSize(i,t,n,o),a=r.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=s.width,this.height=s.height,this._aspectRatio=this.aspectRatio,nw(this,a,!0)&&(this.notifyPlugins("resize",{size:s}),dt(r.onResize,[this,s],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};tt(n,(r,i)=>{r.id=i})}buildOrUpdateScales(){const t=this.options,n=t.scales,r=this.scales,i=Object.keys(r).reduce((s,a)=>(s[a]=!1,s),{});let o=[];n&&(o=o.concat(Object.keys(n).map(s=>{const a=n[s],l=Cm(s,a),c=l==="r",u=l==="x";return{options:a,dposition:c?"chartArea":u?"bottom":"left",dtype:c?"radialLinear":u?"category":"linear"}}))),tt(o,s=>{const a=s.options,l=a.id,c=Cm(l,a),u=Le(a.type,s.dtype);(a.position===void 0||Lw(a.position,c)!==Lw(s.dposition))&&(a.position=s.dposition),i[l]=!0;let d=null;if(l in r&&r[l].type===u)d=r[l];else{const f=zr.getScale(u);d=new f({id:l,type:u,ctx:this.ctx,chart:this}),r[d.id]=d}d.init(a,t)}),tt(i,(s,a)=>{s||delete r[a]}),tt(r,s=>{bn.configure(this,s,s.options),bn.addBox(this,s)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,r=t.length;if(t.sort((i,o)=>i.index-o.index),r>n){for(let i=n;i<r;++i)this._destroyDatasetMeta(i);t.splice(n,r-n)}this._sortedMetasets=t.slice(0).sort(Aw("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((r,i)=>{n.filter(o=>o===r._dataset).length===0&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let r,i;for(this._removeUnreferencedMetasets(),r=0,i=n.length;r<i;r++){const o=n[r];let s=this.getDatasetMeta(r);const a=o.type||this.config.type;if(s.type&&s.type!==a&&(this._destroyDatasetMeta(r),s=this.getDatasetMeta(r)),s.type=a,s.indexAxis=o.indexAxis||Om(a,this.options),s.order=o.order||0,s.index=r,s.label=""+o.label,s.visible=this.isDatasetVisible(r),s.controller)s.controller.updateIndex(r),s.controller.linkScales();else{const l=zr.getController(a),{datasetElementType:c,dataElementType:u}=_t.datasets[a];Object.assign(l,{dataElementType:zr.getElement(u),datasetElementType:c&&zr.getElement(c)}),s.controller=new l(this,r),t.push(s.controller)}}return this._updateMetasets(),t}_resetElements(){tt(this.data.datasets,(t,n)=>{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const n=this.config;n.update();const r=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!r.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let s=0;for(let c=0,u=this.data.datasets.length;c<u;c++){const{controller:d}=this.getDatasetMeta(c),f=!i&&o.indexOf(d)===-1;d.buildOrUpdateElements(f),s=Math.max(+d.getMaxOverflow(),s)}s=this._minPadding=r.layout.autoPadding?s:0,this._updateLayout(s),i||tt(o,c=>{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Aw("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){tt(this.scales,t=>{bn.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),r=new Set(t.events);(!Vx(n,r)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:r,start:i,count:o}of n){const s=r==="_removeElements"?-o:o;LF(t,i,s)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,r=o=>new Set(t.filter(s=>s[0]===o).map((s,a)=>a+","+s.splice(1).join(","))),i=r(0);for(let o=1;o<n;o++)if(!Vx(i,r(o)))return;return Array.from(i).map(o=>o.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;bn.update(this,this.width,this.height,t);const n=this.chartArea,r=n.width<=0||n.height<=0;this._layers=[],tt(this.boxes,i=>{r&&i.position==="chartArea"||(i.configure&&i.configure(),this._layers.push(...i._layers()))},this),this._layers.forEach((i,o)=>{i._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,r=this.data.datasets.length;n<r;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,r=this.data.datasets.length;n<r;++n)this._updateDataset(n,no(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){const r=this.getDatasetMeta(t),i={meta:r,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",i)!==!1&&(r.controller._update(n),i.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",i))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(Xr.has(this)?this.attached&&!Xr.running(this)&&Xr.start(this):(this.draw(),Pw({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:r,height:i}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(r,i)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;const n=this._layers;for(t=0;t<n.length&&n[t].z<=0;++t)n[t].draw(this.chartArea);for(this._drawDatasets();t<n.length;++t)n[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const n=this._sortedMetasets,r=[];let i,o;for(i=0,o=n.length;i<o;++i){const s=n[i];(!t||s.visible)&&r.push(s)}return r}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;const t=this.getSortedVisibleDatasetMetas();for(let n=t.length-1;n>=0;--n)this._drawDataset(t[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const n=this.ctx,r={meta:t,index:t.index,cancelable:!0},i=W1(this,t);this.notifyPlugins("beforeDatasetDraw",r)!==!1&&(i&&mf(n,i),t.controller.draw(),i&&gf(n),r.cancelable=!1,this.notifyPlugins("afterDatasetDraw",r))}isPointInArea(t){return li(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,r,i){const o=j2.modes[n];return typeof o=="function"?o(this,t,r,i):[]}getDatasetMeta(t){const n=this.data.datasets[t],r=this._metasets;let i=r.filter(o=>o&&o._dataset===n).pop();return i||(i={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:t,_dataset:n,_parsed:[],_sorted:!1},r.push(i)),i}getContext(){return this.$context||(this.$context=lo(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const r=this.getDatasetMeta(t);return typeof r.hidden=="boolean"?!r.hidden:!n.hidden}setDatasetVisibility(t,n){const r=this.getDatasetMeta(t);r.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,r){const i=r?"show":"hide",o=this.getDatasetMeta(t),s=o.controller._resolveAnimations(void 0,i);Hl(n)?(o.data[n].hidden=!r,this.update()):(this.setDatasetVisibility(t,r),s.update(o,{visible:r}),this.update(a=>a.datasetIndex===t?i:void 0))}hide(t,n){this._updateVisibility(t,n,!1)}show(t,n){this._updateVisibility(t,n,!0)}_destroyDatasetMeta(t){const n=this._metasets[t];n&&n.controller&&n.controller._destroy(),delete this._metasets[t]}_stop(){let t,n;for(this.stop(),Xr.remove(this),t=0,n=this.data.datasets.length;t<n;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:n}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),Zx(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete Du[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,n=this.platform,r=(o,s)=>{n.addEventListener(this,o,s),t[o]=s},i=(o,s,a)=>{o.offsetX=s,o.offsetY=a,this._eventHandler(o)};tt(this.options.events,o=>r(o,i))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,n=this.platform,r=(l,c)=>{n.addEventListener(this,l,c),t[l]=c},i=(l,c)=>{t[l]&&(n.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)};let s;const a=()=>{i("attach",a),this.attached=!0,this.resize(),r("resize",o),r("detach",s)};s=()=>{this.attached=!1,i("resize",o),this._stop(),this._resize(0,0),r("attach",a)},n.isAttached(this.canvas)?a():s()}unbindEvents(){tt(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},tt(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,r){const i=r?"set":"remove";let o,s,a,l;for(n==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+i+"DatasetHoverStyle"]()),a=0,l=t.length;a<l;++a){s=t[a];const c=s&&this.getDatasetMeta(s.datasetIndex).controller;c&&c[i+"HoverStyle"](s.element,s.datasetIndex,s.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const n=this._active||[],r=t.map(({datasetIndex:o,index:s})=>{const a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[s],index:s}});!Sd(r,n)&&(this._active=r,this._lastEvent=null,this._updateHoverStyles(r,n))}notifyPlugins(t,n,r){return this._plugins.notify(this,t,n,r)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,r){const i=this.options.hover,o=(l,c)=>l.filter(u=>!c.some(d=>u.datasetIndex===d.datasetIndex&&u.index===d.index)),s=o(n,t),a=r?t:o(t,n);s.length&&this.updateHoverStyle(s,i.mode,!1),a.length&&i.mode&&this.updateHoverStyle(a,i.mode,!0)}_eventHandler(t,n){const r={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},i=s=>(s.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",r,i)===!1)return;const o=this._handleEvent(t,n,r.inChartArea);return r.cancelable=!1,this.notifyPlugins("afterEvent",r,i),(o||r.changed)&&this.render(),this}_handleEvent(t,n,r){const{_active:i=[],options:o}=this,s=n,a=this._getActiveElements(t,i,r,s),l=ND(t),c=AF(t,this._lastEvent,r,l);r&&(this._lastEvent=null,dt(o.onHover,[t,a,this],this),l&&dt(o.onClick,[t,a,this],this));const u=!Sd(a,i);return(u||n)&&(this._active=a,this._updateHoverStyles(a,i,n)),this._lastEvent=c,u}_getActiveElements(t,n,r,i){if(t.type==="mouseout")return[];if(!r)return n;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,i)}}Z(Sr,"defaults",_t),Z(Sr,"instances",Du),Z(Sr,"overrides",Go),Z(Sr,"registry",zr),Z(Sr,"version",CF),Z(Sr,"getChart",Mw);function Tw(){return tt(Sr.instances,e=>e._plugins.invalidate())}function PF(e,t,n){const{startAngle:r,x:i,y:o,outerRadius:s,innerRadius:a,options:l}=t,{borderWidth:c,borderJoinStyle:u}=l,d=Math.min(c/s,vn(r-n));if(e.beginPath(),e.arc(i,o,s-c/2,r+d/2,n-d/2),a>0){const f=Math.min(c/a,vn(r-n));e.arc(i,o,a+c/2,n-f/2,r+f/2,!0)}else{const f=Math.min(c/2,s*vn(r-n));if(u==="round")e.arc(i,o,f,n-Ye/2,r+Ye/2,!0);else if(u==="bevel"){const h=2*f*f,g=-h*Math.cos(n+Ye/2)+i,m=-h*Math.sin(n+Ye/2)+o,x=h*Math.cos(r+Ye/2)+i,y=h*Math.sin(r+Ye/2)+o;e.lineTo(g,m),e.lineTo(x,y)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip("evenodd")}function MF(e,t,n){const{startAngle:r,pixelMargin:i,x:o,y:s,outerRadius:a,innerRadius:l}=t;let c=i/a;e.beginPath(),e.arc(o,s,a,r-c,n+c),l>i?(c=i/l,e.arc(o,s,l,n+c,r-c,!0)):e.arc(o,s,i,n+Bt,r-Bt),e.closePath(),e.clip()}function TF(e){return pv(e,["outerStart","outerEnd","innerStart","innerEnd"])}function DF(e,t,n,r){const i=TF(e.options.borderRadius),o=(n-t)/2,s=Math.min(o,r*t/2),a=l=>{const c=(n-Math.min(o,l))*r/2;return Zt(l,0,Math.min(o,c))};return{outerStart:a(i.outerStart),outerEnd:a(i.outerEnd),innerStart:Zt(i.innerStart,0,s),innerEnd:Zt(i.innerEnd,0,s)}}function ms(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function Ld(e,t,n,r,i,o){const{x:s,y:a,startAngle:l,pixelMargin:c,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-c,0),f=u>0?u+r+n+c:0;let h=0;const g=i-l;if(r){const Y=u>0?u-r:0,re=d>0?d-r:0,pe=(Y+re)/2,B=pe!==0?g*pe/(pe+r):g;h=(g-B)/2}const m=Math.max(.001,g*d-n/Ye)/d,x=(g-m)/2,y=l+x+h,b=i-x-h,{outerStart:w,outerEnd:E,innerStart:C,innerEnd:S}=DF(t,f,d,b-y),M=d-w,L=d-E,T=y+w/M,V=b-E/L,G=f+C,F=f+S,te=y+C/G,W=b-S/F;if(e.beginPath(),o){const Y=(T+V)/2;if(e.arc(s,a,d,T,Y),e.arc(s,a,d,Y,V),E>0){const ee=ms(L,V,s,a);e.arc(ee.x,ee.y,E,V,b+Bt)}const re=ms(F,b,s,a);if(e.lineTo(re.x,re.y),S>0){const ee=ms(F,W,s,a);e.arc(ee.x,ee.y,S,b+Bt,W+Math.PI)}const pe=(b-S/f+(y+C/f))/2;if(e.arc(s,a,f,b-S/f,pe,!0),e.arc(s,a,f,pe,y+C/f,!0),C>0){const ee=ms(G,te,s,a);e.arc(ee.x,ee.y,C,te+Math.PI,y-Bt)}const B=ms(M,y,s,a);if(e.lineTo(B.x,B.y),w>0){const ee=ms(M,T,s,a);e.arc(ee.x,ee.y,w,y-Bt,T)}}else{e.moveTo(s,a);const Y=Math.cos(T)*d+s,re=Math.sin(T)*d+a;e.lineTo(Y,re);const pe=Math.cos(V)*d+s,B=Math.sin(V)*d+a;e.lineTo(pe,B)}e.closePath()}function IF(e,t,n,r,i){const{fullCircles:o,startAngle:s,circumference:a}=t;let l=t.endAngle;if(o){Ld(e,t,n,r,l,i);for(let c=0;c<o;++c)e.fill();isNaN(a)||(l=s+(a%yt||yt))}return Ld(e,t,n,r,l,i),e.fill(),l}function FF(e,t,n,r,i){const{fullCircles:o,startAngle:s,circumference:a,options:l}=t,{borderWidth:c,borderJoinStyle:u,borderDash:d,borderDashOffset:f,borderRadius:h}=l,g=l.borderAlign==="inner";if(!c)return;e.setLineDash(d||[]),e.lineDashOffset=f,g?(e.lineWidth=c*2,e.lineJoin=u||"round"):(e.lineWidth=c,e.lineJoin=u||"bevel");let m=t.endAngle;if(o){Ld(e,t,n,r,m,i);for(let x=0;x<o;++x)e.stroke();isNaN(a)||(m=s+(a%yt||yt))}g&&MF(e,t,m),l.selfJoin&&m-s>=Ye&&h===0&&u!=="miter"&&PF(e,t,m),o||(Ld(e,t,n,r,m,i),e.stroke())}class Ka extends Ar{constructor(n){super();Z(this,"circumference");Z(this,"endAngle");Z(this,"fullCircles");Z(this,"innerRadius");Z(this,"outerRadius");Z(this,"pixelMargin");Z(this,"startAngle");this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,n&&Object.assign(this,n)}inRange(n,r,i){const o=this.getProps(["x","y"],i),{angle:s,distance:a}=_1(o,{x:n,y:r}),{startAngle:l,endAngle:c,innerRadius:u,outerRadius:d,circumference:f}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),h=(this.options.spacing+this.options.borderWidth)/2,g=Le(f,c-l),m=Wl(s,l,c)&&l!==c,x=g>=yt||m,y=si(a,u+h,d+h);return x&&y}getCenterPoint(n){const{x:r,y:i,startAngle:o,endAngle:s,innerRadius:a,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],n),{offset:c,spacing:u}=this.options,d=(o+s)/2,f=(a+l+u+c)/2;return{x:r+Math.cos(d)*f,y:i+Math.sin(d)*f}}tooltipPosition(n){return this.getCenterPoint(n)}draw(n){const{options:r,circumference:i}=this,o=(r.offset||0)/4,s=(r.spacing||0)/2,a=r.circular;if(this.pixelMargin=r.borderAlign==="inner"?.33:0,this.fullCircles=i>yt?Math.floor(i/yt):0,i===0||this.innerRadius<0||this.outerRadius<0)return;n.save();const l=(this.startAngle+this.endAngle)/2;n.translate(Math.cos(l)*o,Math.sin(l)*o);const c=1-Math.sin(Math.min(Ye,i||0)),u=o*c;n.fillStyle=r.backgroundColor,n.strokeStyle=r.borderColor,IF(n,this,u,s,a),FF(n,this,u,s,a),n.restore()}}Z(Ka,"id","arc"),Z(Ka,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1}),Z(Ka,"defaultRoutes",{backgroundColor:"backgroundColor"}),Z(Ka,"descriptors",{_scriptable:!0,_indexable:n=>n!=="borderDash"});function nE(e,t,n=t){e.lineCap=Le(n.borderCapStyle,t.borderCapStyle),e.setLineDash(Le(n.borderDash,t.borderDash)),e.lineDashOffset=Le(n.borderDashOffset,t.borderDashOffset),e.lineJoin=Le(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=Le(n.borderWidth,t.borderWidth),e.strokeStyle=Le(n.borderColor,t.borderColor)}function NF(e,t,n){e.lineTo(n.x,n.y)}function zF(e){return e.stepped?aI:e.tension||e.cubicInterpolationMode==="monotone"?lI:NF}function rE(e,t,n={}){const r=e.length,{start:i=0,end:o=r-1}=n,{start:s,end:a}=t,l=Math.max(i,s),c=Math.min(o,a),u=i<s&&o<s||i>a&&o>a;return{count:r,start:l,loop:t.loop,ilen:c<l&&!u?r+c-l:c-l}}function BF(e,t,n,r){const{points:i,options:o}=t,{count:s,start:a,loop:l,ilen:c}=rE(i,n,r),u=zF(o);let{move:d=!0,reverse:f}=r||{},h,g,m;for(h=0;h<=c;++h)g=i[(a+(f?c-h:h))%s],!g.skip&&(d?(e.moveTo(g.x,g.y),d=!1):u(e,m,g,f,o.stepped),m=g);return l&&(g=i[(a+(f?c:0))%s],u(e,m,g,f,o.stepped)),!!l}function UF(e,t,n,r){const i=t.points,{count:o,start:s,ilen:a}=rE(i,n,r),{move:l=!0,reverse:c}=r||{};let u=0,d=0,f,h,g,m,x,y;const b=E=>(s+(c?a-E:E))%o,w=()=>{m!==x&&(e.lineTo(u,x),e.lineTo(u,m),e.lineTo(u,y))};for(l&&(h=i[b(0)],e.moveTo(h.x,h.y)),f=0;f<=a;++f){if(h=i[b(f)],h.skip)continue;const E=h.x,C=h.y,S=E|0;S===g?(C<m?m=C:C>x&&(x=C),u=(d*u+E)/++d):(w(),e.lineTo(E,C),g=S,d=0,m=x=C),y=C}w()}function jm(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?UF:BF}function HF(e){return e.stepped?BI:e.tension||e.cubicInterpolationMode==="monotone"?UI:Oo}function WF(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),nE(e,t.options),e.stroke(i)}function VF(e,t,n,r){const{segments:i,options:o}=t,s=jm(t);for(const a of i)nE(e,o,a.style),e.beginPath(),s(e,t,a,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}const qF=typeof Path2D=="function";function $F(e,t,n,r){qF&&!t.options.segment?WF(e,t,n,r):VF(e,t,n,r)}class zi extends Ar{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,n){const r=this.options;if((r.tension||r.cubicInterpolationMode==="monotone")&&!r.stepped&&!this._pointsUpdated){const i=r.spanGaps?this._loop:this._fullLoop;PI(this._points,r,t,i,n),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=KI(this,this.options.segment))}first(){const t=this.segments,n=this.points;return t.length&&n[t[0].start]}last(){const t=this.segments,n=this.points,r=t.length;return r&&n[t[r-1].end]}interpolate(t,n){const r=this.options,i=t[n],o=this.points,s=H1(this,{property:n,start:i,end:i});if(!s.length)return;const a=[],l=HF(r);let c,u;for(c=0,u=s.length;c<u;++c){const{start:d,end:f}=s[c],h=o[d],g=o[f];if(h===g){a.push(h);continue}const m=Math.abs((i-h[n])/(g[n]-h[n])),x=l(h,g,m,r.stepped);x[n]=t[n],a.push(x)}return a.length===1?a[0]:a}pathSegment(t,n,r){return jm(this)(t,this,n,r)}path(t,n,r){const i=this.segments,o=jm(this);let s=this._loop;n=n||0,r=r||this.points.length-n;for(const a of i)s&=o(t,this,a,{start:n,end:n+r-1});return!!s}draw(t,n,r,i){const o=this.options||{};(this.points||[]).length&&o.borderWidth&&(t.save(),$F(t,this,r,i),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}Z(zi,"id","line"),Z(zi,"defaults",{borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0}),Z(zi,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"}),Z(zi,"descriptors",{_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"});function Dw(e,t,n,r){const i=e.options,{[n]:o}=e.getProps([n],r);return Math.abs(t-o)<i.radius+i.hitRadius}class Iu extends Ar{constructor(n){super();Z(this,"parsed");Z(this,"skip");Z(this,"stop");this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,n&&Object.assign(this,n)}inRange(n,r,i){const o=this.options,{x:s,y:a}=this.getProps(["x","y"],i);return Math.pow(n-s,2)+Math.pow(r-a,2)<Math.pow(o.hitRadius+o.radius,2)}inXRange(n,r){return Dw(this,n,"x",r)}inYRange(n,r){return Dw(this,n,"y",r)}getCenterPoint(n){const{x:r,y:i}=this.getProps(["x","y"],n);return{x:r,y:i}}size(n){n=n||this.options||{};let r=n.radius||0;r=Math.max(r,r&&n.hoverRadius||0);const i=r&&n.borderWidth||0;return(r+i)*2}draw(n,r){const i=this.options;this.skip||i.radius<.1||!li(this,r,this.size(i)/2)||(n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.fillStyle=i.backgroundColor,Sm(n,i,this.x,this.y))}getRange(){const n=this.options||{};return n.radius+n.hitRadius}}Z(Iu,"id","point"),Z(Iu,"defaults",{borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0}),Z(Iu,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});function iE(e,t){const{x:n,y:r,base:i,width:o,height:s}=e.getProps(["x","y","base","width","height"],t);let a,l,c,u,d;return e.horizontal?(d=s/2,a=Math.min(n,i),l=Math.max(n,i),c=r-d,u=r+d):(d=o/2,a=n-d,l=n+d,c=Math.min(r,i),u=Math.max(r,i)),{left:a,top:c,right:l,bottom:u}}function Bi(e,t,n,r){return e?0:Zt(t,n,r)}function KF(e,t,n){const r=e.options.borderWidth,i=e.borderSkipped,o=A1(r);return{t:Bi(i.top,o.top,0,n),r:Bi(i.right,o.right,0,t),b:Bi(i.bottom,o.bottom,0,n),l:Bi(i.left,o.left,0,t)}}function YF(e,t,n){const{enableBorderRadius:r}=e.getProps(["enableBorderRadius"]),i=e.options.borderRadius,o=No(i),s=Math.min(t,n),a=e.borderSkipped,l=r||He(i);return{topLeft:Bi(!l||a.top||a.left,o.topLeft,0,s),topRight:Bi(!l||a.top||a.right,o.topRight,0,s),bottomLeft:Bi(!l||a.bottom||a.left,o.bottomLeft,0,s),bottomRight:Bi(!l||a.bottom||a.right,o.bottomRight,0,s)}}function GF(e){const t=iE(e),n=t.right-t.left,r=t.bottom-t.top,i=KF(e,n/2,r/2),o=YF(e,n/2,r/2);return{outer:{x:t.left,y:t.top,w:n,h:r,radius:o},inner:{x:t.left+i.l,y:t.top+i.t,w:n-i.l-i.r,h:r-i.t-i.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(i.t,i.l)),topRight:Math.max(0,o.topRight-Math.max(i.t,i.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(i.b,i.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(i.b,i.r))}}}}function Kh(e,t,n,r){const i=t===null,o=n===null,a=e&&!(i&&o)&&iE(e,r);return a&&(i||si(t,a.left,a.right))&&(o||si(n,a.top,a.bottom))}function JF(e){return e.topLeft||e.topRight||e.bottomLeft||e.bottomRight}function XF(e,t){e.rect(t.x,t.y,t.w,t.h)}function Yh(e,t,n={}){const r=e.x!==n.x?-t:0,i=e.y!==n.y?-t:0,o=(e.x+e.w!==n.x+n.w?t:0)-r,s=(e.y+e.h!==n.y+n.h?t:0)-i;return{x:e.x+r,y:e.y+i,w:e.w+o,h:e.h+s,radius:e.radius}}class Fu extends Ar{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:n,options:{borderColor:r,backgroundColor:i}}=this,{inner:o,outer:s}=GF(this),a=JF(s.radius)?Vl:XF;t.save(),(s.w!==o.w||s.h!==o.h)&&(t.beginPath(),a(t,Yh(s,n,o)),t.clip(),a(t,Yh(o,-n,s)),t.fillStyle=r,t.fill("evenodd")),t.beginPath(),a(t,Yh(o,n)),t.fillStyle=i,t.fill(),t.restore()}inRange(t,n,r){return Kh(this,t,n,r)}inXRange(t,n){return Kh(this,t,null,n)}inYRange(t,n){return Kh(this,null,t,n)}getCenterPoint(t){const{x:n,y:r,base:i,horizontal:o}=this.getProps(["x","y","base","horizontal"],t);return{x:o?(n+i)/2:n,y:o?r:(r+i)/2}}getRange(t){return t==="x"?this.width/2:this.height/2}}Z(Fu,"id","bar"),Z(Fu,"defaults",{borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0}),Z(Fu,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});var QF=Object.freeze({__proto__:null,ArcElement:Ka,BarElement:Fu,LineElement:zi,PointElement:Iu});const Rm=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],Iw=Rm.map(e=>e.replace("rgb(","rgba(").replace(")",", 0.5)"));function oE(e){return Rm[e%Rm.length]}function sE(e){return Iw[e%Iw.length]}function ZF(e,t){return e.borderColor=oE(t),e.backgroundColor=sE(t),++t}function eN(e,t){return e.backgroundColor=e.data.map(()=>oE(t++)),t}function tN(e,t){return e.backgroundColor=e.data.map(()=>sE(t++)),t}function nN(e){let t=0;return(n,r)=>{const i=e.getDatasetMeta(r).controller;i instanceof Po?t=eN(n,t):i instanceof fl?t=tN(n,t):i&&(t=ZF(n,t))}}function Fw(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function rN(e){return e&&(e.borderColor||e.backgroundColor)}function iN(){return _t.borderColor!=="rgba(0,0,0,0.1)"||_t.backgroundColor!=="rgba(0,0,0,0.1)"}var oN={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;const{data:{datasets:r},options:i}=e.config,{elements:o}=i,s=Fw(r)||rN(i)||o&&Fw(o)||iN();if(!n.forceOverride&&s)return;const a=nN(e);r.forEach(a)}};function sN(e,t,n,r,i){const o=i.samples||r;if(o>=n)return e.slice(t,t+n);const s=[],a=(n-2)/(o-2);let l=0;const c=t+n-1;let u=t,d,f,h,g,m;for(s[l++]=e[u],d=0;d<o-2;d++){let x=0,y=0,b;const w=Math.floor((d+1)*a)+1+t,E=Math.min(Math.floor((d+2)*a)+1,n)+t,C=E-w;for(b=w;b<E;b++)x+=e[b].x,y+=e[b].y;x/=C,y/=C;const S=Math.floor(d*a)+1+t,M=Math.min(Math.floor((d+1)*a)+1,n)+t,{x:L,y:T}=e[u];for(h=g=-1,b=S;b<M;b++)g=.5*Math.abs((L-x)*(e[b].y-T)-(L-e[b].x)*(y-T)),g>h&&(h=g,f=e[b],m=b);s[l++]=f,u=m}return s[l++]=e[c],s}function aN(e,t,n,r){let i=0,o=0,s,a,l,c,u,d,f,h,g,m;const x=[],y=t+n-1,b=e[t].x,E=e[y].x-b;for(s=t;s<t+n;++s){a=e[s],l=(a.x-b)/E*r,c=a.y;const C=l|0;if(C===u)c<g?(g=c,d=s):c>m&&(m=c,f=s),i=(o*i+a.x)/++o;else{const S=s-1;if(!Ne(d)&&!Ne(f)){const M=Math.min(d,f),L=Math.max(d,f);M!==h&&M!==S&&x.push({...e[M],x:i}),L!==h&&L!==S&&x.push({...e[L],x:i})}s>0&&S!==h&&x.push(e[S]),x.push(a),u=C,o=0,g=m=c,d=f=h=s}}return x}function aE(e){if(e._decimated){const t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function Nw(e){e.data.datasets.forEach(t=>{aE(t)})}function lN(e,t){const n=t.length;let r=0,i;const{iScale:o}=e,{min:s,max:a,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(r=Zt(ai(t,o.axis,s).lo,0,n-1)),c?i=Zt(ai(t,o.axis,a).hi+1,r,n)-r:i=n-r,{start:r,count:i}}var cN={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){Nw(e);return}const r=e.width;e.data.datasets.forEach((i,o)=>{const{_data:s,indexAxis:a}=i,l=e.getDatasetMeta(o),c=s||i.data;if(qa([a,e.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;const u=e.scales[l.xAxisID];if(u.type!=="linear"&&u.type!=="time"||e.options.parsing)return;let{start:d,count:f}=lN(l,c);const h=n.threshold||4*r;if(f<=h){aE(i);return}Ne(s)&&(i._data=c,delete i.data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(m){this._data=m}}));let g;switch(n.algorithm){case"lttb":g=sN(c,d,f,r,n);break;case"min-max":g=aN(c,d,f,r);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}i._decimated=g})},destroy(e){Nw(e)}};function uN(e,t,n){const r=e.segments,i=e.points,o=t.points,s=[];for(const a of r){let{start:l,end:c}=a;c=bf(l,c,i);const u=Lm(n,i[l],i[c],a.loop);if(!t.segments){s.push({source:a,target:u,start:i[l],end:i[c]});continue}const d=H1(t,u);for(const f of d){const h=Lm(n,o[f.start],o[f.end],f.loop),g=U1(a,i,h);for(const m of g)s.push({source:m,target:f,start:{[n]:zw(u,h,"start",Math.max)},end:{[n]:zw(u,h,"end",Math.min)}})}}return s}function Lm(e,t,n,r){if(r)return;let i=t[e],o=n[e];return e==="angle"&&(i=vn(i),o=vn(o)),{property:e,start:i,end:o}}function dN(e,t){const{x:n=null,y:r=null}=e||{},i=t.points,o=[];return t.segments.forEach(({start:s,end:a})=>{a=bf(s,a,i);const l=i[s],c=i[a];r!==null?(o.push({x:l.x,y:r}),o.push({x:c.x,y:r})):n!==null&&(o.push({x:n,y:l.y}),o.push({x:n,y:c.y}))}),o}function bf(e,t,n){for(;t>e;t--){const r=n[t];if(!isNaN(r.x)&&!isNaN(r.y))break}return t}function zw(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function lE(e,t){let n=[],r=!1;return wt(e)?(r=!0,n=e):n=dN(e,t),n.length?new zi({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function Bw(e){return e&&e.fill!==!1}function fN(e,t,n){let i=e[t].fill;const o=[t];let s;if(!n)return i;for(;i!==!1&&o.indexOf(i)===-1;){if(!It(i))return i;if(s=e[i],!s)return!1;if(s.visible)return i;o.push(i),i=s.fill}return!1}function hN(e,t,n){const r=vN(e);if(He(r))return isNaN(r.value)?!1:r;let i=parseFloat(r);return It(i)&&Math.floor(i)===i?pN(r[0],t,i,n):["origin","start","end","stack","shape"].indexOf(r)>=0&&r}function pN(e,t,n,r){return(e==="-"||e==="+")&&(n=t+n),n===t||n<0||n>=r?!1:n}function mN(e,t){let n=null;return e==="start"?n=t.bottom:e==="end"?n=t.top:He(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function gN(e,t,n){let r;return e==="start"?r=n:e==="end"?r=t.options.reverse?t.min:t.max:He(e)?r=e.value:r=t.getBaseValue(),r}function vN(e){const t=e.options,n=t.fill;let r=Le(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?"origin":r}function yN(e){const{scale:t,index:n,line:r}=e,i=[],o=r.segments,s=r.points,a=bN(t,n);a.push(lE({x:null,y:t.bottom},r));for(let l=0;l<o.length;l++){const c=o[l];for(let u=c.start;u<=c.end;u++)xN(i,s[u],a)}return new zi({points:i,options:{}})}function bN(e,t){const n=[],r=e.getMatchingVisibleMetas("line");for(let i=0;i<r.length;i++){const o=r[i];if(o.index===t)break;o.hidden||n.unshift(o.dataset)}return n}function xN(e,t,n){const r=[];for(let i=0;i<n.length;i++){const o=n[i],{first:s,last:a,point:l}=wN(o,t,"x");if(!(!l||s&&a)){if(s)r.unshift(l);else if(e.push(l),!a)break}}e.push(...r)}function wN(e,t,n){const r=e.interpolate(t,n);if(!r)return{};const i=r[n],o=e.segments,s=e.points;let a=!1,l=!1;for(let c=0;c<o.length;c++){const u=o[c],d=s[u.start][n],f=s[u.end][n];if(si(i,d,f)){a=i===d,l=i===f;break}}return{first:a,last:l,point:r}}class cE{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,n,r){const{x:i,y:o,radius:s}=this;return n=n||{start:0,end:yt},t.arc(i,o,s,n.end,n.start,!0),!r.bounds}interpolate(t){const{x:n,y:r,radius:i}=this,o=t.angle;return{x:n+Math.cos(o)*i,y:r+Math.sin(o)*i,angle:o}}}function _N(e){const{chart:t,fill:n,line:r}=e;if(It(n))return kN(t,n);if(n==="stack")return yN(e);if(n==="shape")return!0;const i=SN(e);return i instanceof cE?i:lE(i,r)}function kN(e,t){const n=e.getDatasetMeta(t);return n&&e.isDatasetVisible(t)?n.dataset:null}function SN(e){return(e.scale||{}).getPointPositionForValue?ON(e):EN(e)}function EN(e){const{scale:t={},fill:n}=e,r=mN(n,t);if(It(r)){const i=t.isHorizontal();return{x:i?r:null,y:i?null:r}}return null}function ON(e){const{scale:t,fill:n}=e,r=t.options,i=t.getLabels().length,o=r.reverse?t.max:t.min,s=gN(n,t,o),a=[];if(r.grid.circular){const l=t.getPointPositionForValue(0,o);return new cE({x:l.x,y:l.y,radius:t.getDistanceFromCenterForValue(s)})}for(let l=0;l<i;++l)a.push(t.getPointPositionForValue(l,s));return a}function Gh(e,t,n){const r=_N(t),{chart:i,index:o,line:s,scale:a,axis:l}=t,c=s.options,u=c.fill,d=c.backgroundColor,{above:f=d,below:h=d}=u||{},g=i.getDatasetMeta(o),m=W1(i,g);r&&s.points.length&&(mf(e,n),CN(e,{line:s,target:r,above:f,below:h,area:n,scale:a,axis:l,clip:m}),gf(e))}function CN(e,t){const{line:n,target:r,above:i,below:o,area:s,scale:a,clip:l}=t,c=n._loop?"angle":t.axis;e.save();let u=o;o!==i&&(c==="x"?(Uw(e,r,s.top),Jh(e,{line:n,target:r,color:i,scale:a,property:c,clip:l}),e.restore(),e.save(),Uw(e,r,s.bottom)):c==="y"&&(Hw(e,r,s.left),Jh(e,{line:n,target:r,color:o,scale:a,property:c,clip:l}),e.restore(),e.save(),Hw(e,r,s.right),u=i)),Jh(e,{line:n,target:r,color:u,scale:a,property:c,clip:l}),e.restore()}function Uw(e,t,n){const{segments:r,points:i}=t;let o=!0,s=!1;e.beginPath();for(const a of r){const{start:l,end:c}=a,u=i[l],d=i[bf(l,c,i)];o?(e.moveTo(u.x,u.y),o=!1):(e.lineTo(u.x,n),e.lineTo(u.x,u.y)),s=!!t.pathSegment(e,a,{move:s}),s?e.closePath():e.lineTo(d.x,n)}e.lineTo(t.first().x,n),e.closePath(),e.clip()}function Hw(e,t,n){const{segments:r,points:i}=t;let o=!0,s=!1;e.beginPath();for(const a of r){const{start:l,end:c}=a,u=i[l],d=i[bf(l,c,i)];o?(e.moveTo(u.x,u.y),o=!1):(e.lineTo(n,u.y),e.lineTo(u.x,u.y)),s=!!t.pathSegment(e,a,{move:s}),s?e.closePath():e.lineTo(n,d.y)}e.lineTo(n,t.first().y),e.closePath(),e.clip()}function Jh(e,t){const{line:n,target:r,property:i,color:o,scale:s,clip:a}=t,l=uN(n,r,i);for(const{source:c,target:u,start:d,end:f}of l){const{style:{backgroundColor:h=o}={}}=c,g=r!==!0;e.save(),e.fillStyle=h,jN(e,s,a,g&&Lm(i,d,f)),e.beginPath();const m=!!n.pathSegment(e,c);let x;if(g){m?e.closePath():Ww(e,r,f,i);const y=!!r.pathSegment(e,u,{move:m,reverse:!0});x=m&&y,x||Ww(e,r,d,i)}e.closePath(),e.fill(x?"evenodd":"nonzero"),e.restore()}}function jN(e,t,n,r){const i=t.chart.chartArea,{property:o,start:s,end:a}=r||{};if(o==="x"||o==="y"){let l,c,u,d;o==="x"?(l=s,c=i.top,u=a,d=i.bottom):(l=i.left,c=s,u=i.right,d=a),e.beginPath(),n&&(l=Math.max(l,n.left),u=Math.min(u,n.right),c=Math.max(c,n.top),d=Math.min(d,n.bottom)),e.rect(l,c,u-l,d-c),e.clip()}}function Ww(e,t,n,r){const i=t.interpolate(n,r);i&&e.lineTo(i.x,i.y)}var RN={id:"filler",afterDatasetsUpdate(e,t,n){const r=(e.data.datasets||[]).length,i=[];let o,s,a,l;for(s=0;s<r;++s)o=e.getDatasetMeta(s),a=o.dataset,l=null,a&&a.options&&a instanceof zi&&(l={visible:e.isDatasetVisible(s),index:s,fill:hN(a,s,r),chart:e,axis:o.controller.options.indexAxis,scale:o.vScale,line:a}),o.$filler=l,i.push(l);for(s=0;s<r;++s)l=i[s],!(!l||l.fill===!1)&&(l.fill=fN(i,s,n.propagate))},beforeDraw(e,t,n){const r=n.drawTime==="beforeDraw",i=e.getSortedVisibleDatasetMetas(),o=e.chartArea;for(let s=i.length-1;s>=0;--s){const a=i[s].$filler;a&&(a.line.updateControlPoints(o,a.axis),r&&a.fill&&Gh(e.ctx,a,o))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!=="beforeDatasetsDraw")return;const r=e.getSortedVisibleDatasetMetas();for(let i=r.length-1;i>=0;--i){const o=r[i].$filler;Bw(o)&&Gh(e.ctx,o,e.chartArea)}},beforeDatasetDraw(e,t,n){const r=t.meta.$filler;!Bw(r)||n.drawTime!=="beforeDatasetDraw"||Gh(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Vw=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},LN=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index;class qw extends Ar{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n,r){this.maxWidth=t,this.maxHeight=n,this._margins=r,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let n=dt(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(r=>t.filter(r,this.chart.data))),t.sort&&(n=n.sort((r,i)=>t.sort(r,i,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){const{options:t,ctx:n}=this;if(!t.display){this.width=this.height=0;return}const r=t.labels,i=Gt(r.font),o=i.size,s=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=Vw(r,o);let c,u;n.font=i.string,this.isHorizontal()?(c=this.maxWidth,u=this._fitRows(s,o,a,l)+10):(u=this.maxHeight,c=this._fitCols(s,i,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,n,r,i){const{ctx:o,maxWidth:s,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],u=i+a;let d=t;o.textAlign="left",o.textBaseline="middle";let f=-1,h=-u;return this.legendItems.forEach((g,m)=>{const x=r+n/2+o.measureText(g.text).width;(m===0||c[c.length-1]+x+2*a>s)&&(d+=u,c[c.length-(m>0?0:1)]=0,h+=u,f++),l[m]={left:0,top:h,row:f,width:x,height:i},c[c.length-1]+=x+a}),d}_fitCols(t,n,r,i){const{ctx:o,maxHeight:s,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],u=s-t;let d=a,f=0,h=0,g=0,m=0;return this.legendItems.forEach((x,y)=>{const{itemWidth:b,itemHeight:w}=AN(r,n,o,x,i);y>0&&h+w+2*a>u&&(d+=f+a,c.push({width:f,height:h}),g+=f+a,m++,f=h=0),l[y]={left:g,top:h,col:m,width:b,height:w},f=Math.max(f,b),h+=w+a}),d+=f,c.push({width:f,height:h}),d}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:r,labels:{padding:i},rtl:o}}=this,s=qs(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=pn(r,this.left+i,this.right-this.lineWidths[a]);for(const c of n)a!==c.row&&(a=c.row,l=pn(r,this.left+i,this.right-this.lineWidths[a])),c.top+=this.top+t+i,c.left=s.leftForLtr(s.x(l),c.width),l+=c.width+i}else{let a=0,l=pn(r,this.top+t+i,this.bottom-this.columnSizes[a].height);for(const c of n)c.col!==a&&(a=c.col,l=pn(r,this.top+t+i,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+i,c.left=s.leftForLtr(s.x(c.left),c.width),l+=c.height+i}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;mf(t,this),this._draw(),gf(t)}}_draw(){const{options:t,columnSizes:n,lineWidths:r,ctx:i}=this,{align:o,labels:s}=t,a=_t.color,l=qs(t.rtl,this.left,this.width),c=Gt(s.font),{padding:u}=s,d=c.size,f=d/2;let h;this.drawTitle(),i.textAlign=l.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=c.string;const{boxWidth:g,boxHeight:m,itemHeight:x}=Vw(s,d),y=function(S,M,L){if(isNaN(g)||g<=0||isNaN(m)||m<0)return;i.save();const T=Le(L.lineWidth,1);if(i.fillStyle=Le(L.fillStyle,a),i.lineCap=Le(L.lineCap,"butt"),i.lineDashOffset=Le(L.lineDashOffset,0),i.lineJoin=Le(L.lineJoin,"miter"),i.lineWidth=T,i.strokeStyle=Le(L.strokeStyle,a),i.setLineDash(Le(L.lineDash,[])),s.usePointStyle){const V={radius:m*Math.SQRT2/2,pointStyle:L.pointStyle,rotation:L.rotation,borderWidth:T},G=l.xPlus(S,g/2),F=M+f;L1(i,V,G,F,s.pointStyleWidth&&g)}else{const V=M+Math.max((d-m)/2,0),G=l.leftForLtr(S,g),F=No(L.borderRadius);i.beginPath(),Object.values(F).some(te=>te!==0)?Vl(i,{x:G,y:V,w:g,h:m,radius:F}):i.rect(G,V,g,m),i.fill(),T!==0&&i.stroke()}i.restore()},b=function(S,M,L){Jo(i,L.text,S,M+x/2,c,{strikethrough:L.hidden,textAlign:l.textAlign(L.textAlign)})},w=this.isHorizontal(),E=this._computeTitleHeight();w?h={x:pn(o,this.left+u,this.right-r[0]),y:this.top+u+E,line:0}:h={x:this.left+u,y:pn(o,this.top+E+u,this.bottom-n[0].height),line:0},N1(this.ctx,t.textDirection);const C=x+u;this.legendItems.forEach((S,M)=>{i.strokeStyle=S.fontColor,i.fillStyle=S.fontColor;const L=i.measureText(S.text).width,T=l.textAlign(S.textAlign||(S.textAlign=s.textAlign)),V=g+f+L;let G=h.x,F=h.y;l.setWidth(this.width),w?M>0&&G+V+u>this.right&&(F=h.y+=C,h.line++,G=h.x=pn(o,this.left+u,this.right-r[h.line])):M>0&&F+C>this.bottom&&(G=h.x=G+n[h.line].width+u,h.line++,F=h.y=pn(o,this.top+E+u,this.bottom-n[h.line].height));const te=l.x(G);if(y(te,F,S),G=JD(T,G+g+f,w?G+V:this.right,t.rtl),b(l.x(G),F,S),w)h.x+=V+u;else if(typeof S.text!="string"){const W=c.lineHeight;h.y+=uE(S,W)+u}else h.y+=C}),z1(this.ctx,t.textDirection)}drawTitle(){const t=this.options,n=t.title,r=Gt(n.font),i=wn(n.padding);if(!n.display)return;const o=qs(t.rtl,this.left,this.width),s=this.ctx,a=n.position,l=r.size/2,c=i.top+l;let u,d=this.left,f=this.width;if(this.isHorizontal())f=Math.max(...this.lineWidths),u=this.top+c,d=pn(t.align,d,this.right-f);else{const g=this.columnSizes.reduce((m,x)=>Math.max(m,x.height),0);u=c+pn(t.align,this.top,this.bottom-g-t.labels.padding-this._computeTitleHeight())}const h=pn(a,d,d+f);s.textAlign=o.textAlign(fv(a)),s.textBaseline="middle",s.strokeStyle=n.color,s.fillStyle=n.color,s.font=r.string,Jo(s,n.text,h,u,r)}_computeTitleHeight(){const t=this.options.title,n=Gt(t.font),r=wn(t.padding);return t.display?n.lineHeight+r.height:0}_getLegendItemAt(t,n){let r,i,o;if(si(t,this.left,this.right)&&si(n,this.top,this.bottom)){for(o=this.legendHitBoxes,r=0;r<o.length;++r)if(i=o[r],si(t,i.left,i.left+i.width)&&si(n,i.top,i.top+i.height))return this.legendItems[r]}return null}handleEvent(t){const n=this.options;if(!TN(t.type,n))return;const r=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const i=this._hoveredItem,o=LN(i,r);i&&!o&&dt(n.onLeave,[t,i,this],this),this._hoveredItem=r,r&&!o&&dt(n.onHover,[t,r,this],this)}else r&&dt(n.onClick,[t,r,this],this)}}function AN(e,t,n,r,i){const o=PN(r,e,t,n),s=MN(i,r,t.lineHeight);return{itemWidth:o,itemHeight:s}}function PN(e,t,n,r){let i=e.text;return i&&typeof i!="string"&&(i=i.reduce((o,s)=>o.length>s.length?o:s)),t+n.size/2+r.measureText(i).width}function MN(e,t,n){let r=e;return typeof t.text!="string"&&(r=uE(t,n)),r}function uE(e,t){const n=e.text?e.text.length:0;return t*n}function TN(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var DN={id:"legend",_element:qw,start(e,t,n){const r=e.legend=new qw({ctx:e.ctx,options:n,chart:e});bn.configure(e,r,n),bn.addBox(e,r)},stop(e){bn.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const r=e.legend;bn.configure(e,r,n),r.options=n},afterUpdate(e){const t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){const r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){const t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:o,useBorderRadius:s,borderRadius:a}}=e.legend.options;return e._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(n?0:void 0),u=wn(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(u.width+u.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:s&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:e=>!e.startsWith("on"),labels:{_scriptable:e=>!["generateLabels","filter","sort"].includes(e)}}};class wv extends Ar{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n){const r=this.options;if(this.left=0,this.top=0,!r.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=n;const i=wt(r.text)?r.text.length:1;this._padding=wn(r.padding);const o=i*Gt(r.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:n,left:r,bottom:i,right:o,options:s}=this,a=s.align;let l=0,c,u,d;return this.isHorizontal()?(u=pn(a,r,o),d=n+t,c=o-r):(s.position==="left"?(u=r+t,d=pn(a,i,n),l=Ye*-.5):(u=o-t,d=pn(a,n,i),l=Ye*.5),c=i-n),{titleX:u,titleY:d,maxWidth:c,rotation:l}}draw(){const t=this.ctx,n=this.options;if(!n.display)return;const r=Gt(n.font),o=r.lineHeight/2+this._padding.top,{titleX:s,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(o);Jo(t,n.text,0,0,r,{color:n.color,maxWidth:l,rotation:c,textAlign:fv(n.align),textBaseline:"middle",translation:[s,a]})}}function IN(e,t){const n=new wv({ctx:e.ctx,options:t,chart:e});bn.configure(e,n,t),bn.addBox(e,n),e.titleBlock=n}var FN={id:"title",_element:wv,start(e,t,n){IN(e,n)},stop(e){const t=e.titleBlock;bn.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){const r=e.titleBlock;bn.configure(e,r,n),r.options=n},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const iu=new WeakMap;var NN={id:"subtitle",start(e,t,n){const r=new wv({ctx:e.ctx,options:n,chart:e});bn.configure(e,r,n),bn.addBox(e,r),iu.set(e,r)},stop(e){bn.removeBox(e,iu.get(e)),iu.delete(e)},beforeUpdate(e,t,n){const r=iu.get(e);bn.configure(e,r,n),r.options=n},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Ya={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,o=0;for(t=0,n=e.length;t<n;++t){const a=e[t].element;if(a&&a.hasValue()){const l=a.tooltipPosition();r.add(l.x),i+=l.y,++o}}return o===0||r.size===0?!1:{x:[...r].reduce((a,l)=>a+l)/r.size,y:i/o}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=Number.POSITIVE_INFINITY,o,s,a;for(o=0,s=e.length;o<s;++o){const l=e[o].element;if(l&&l.hasValue()){const c=l.getCenterPoint(),u=_m(t,c);u<i&&(i=u,a=l)}}if(a){const l=a.tooltipPosition();n=l.x,r=l.y}return{x:n,y:r}}};function Fr(e,t){return t&&(wt(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function Qr(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(`
154
+ `)>-1?e.split(`
155
+ `):e}function zN(e,t){const{element:n,datasetIndex:r,index:i}=t,o=e.getDatasetMeta(r).controller,{label:s,value:a}=o.getLabelAndValue(i);return{chart:e,label:s,parsed:o.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:a,dataset:o.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function $w(e,t){const n=e.chart.ctx,{body:r,footer:i,title:o}=e,{boxWidth:s,boxHeight:a}=t,l=Gt(t.bodyFont),c=Gt(t.titleFont),u=Gt(t.footerFont),d=o.length,f=i.length,h=r.length,g=wn(t.padding);let m=g.height,x=0,y=r.reduce((E,C)=>E+C.before.length+C.lines.length+C.after.length,0);if(y+=e.beforeBody.length+e.afterBody.length,d&&(m+=d*c.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),y){const E=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;m+=h*E+(y-h)*l.lineHeight+(y-1)*t.bodySpacing}f&&(m+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let b=0;const w=function(E){x=Math.max(x,n.measureText(E).width+b)};return n.save(),n.font=c.string,tt(e.title,w),n.font=l.string,tt(e.beforeBody.concat(e.afterBody),w),b=t.displayColors?s+2+t.boxPadding:0,tt(r,E=>{tt(E.before,w),tt(E.lines,w),tt(E.after,w)}),b=0,n.font=u.string,tt(e.footer,w),n.restore(),x+=g.width,{width:x,height:m}}function BN(e,t){const{y:n,height:r}=t;return n<r/2?"top":n>e.height-r/2?"bottom":"center"}function UN(e,t,n,r){const{x:i,width:o}=r,s=n.caretSize+n.caretPadding;if(e==="left"&&i+o+s>t.width||e==="right"&&i-o-s<0)return!0}function HN(e,t,n,r){const{x:i,width:o}=n,{width:s,chartArea:{left:a,right:l}}=e;let c="center";return r==="center"?c=i<=(a+l)/2?"left":"right":i<=o/2?c="left":i>=s-o/2&&(c="right"),UN(c,e,t,n)&&(c="center"),c}function Kw(e,t,n){const r=n.yAlign||t.yAlign||BN(e,n);return{xAlign:n.xAlign||t.xAlign||HN(e,t,n,r),yAlign:r}}function WN(e,t){let{x:n,width:r}=e;return t==="right"?n-=r:t==="center"&&(n-=r/2),n}function VN(e,t,n){let{y:r,height:i}=e;return t==="top"?r+=n:t==="bottom"?r-=i+n:r-=i/2,r}function Yw(e,t,n,r){const{caretSize:i,caretPadding:o,cornerRadius:s}=e,{xAlign:a,yAlign:l}=n,c=i+o,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:h}=No(s);let g=WN(t,a);const m=VN(t,l,c);return l==="center"?a==="left"?g+=c:a==="right"&&(g-=c):a==="left"?g-=Math.max(u,f)+i:a==="right"&&(g+=Math.max(d,h)+i),{x:Zt(g,0,r.width-t.width),y:Zt(m,0,r.height-t.height)}}function ou(e,t,n){const r=wn(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-r.right:e.x+r.left}function Gw(e){return Fr([],Qr(e))}function qN(e,t,n){return lo(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function Jw(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const dE={beforeTitle:Jr,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(r>0&&t.dataIndex<r)return n[t.dataIndex]}return""},afterTitle:Jr,beforeBody:Jr,beforeLabel:Jr,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return Ne(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:Jr,afterBody:Jr,beforeFooter:Jr,footer:Jr,afterFooter:Jr};function In(e,t,n,r){const i=e[t].call(n,r);return typeof i>"u"?dE[t].call(n,r):i}class Am extends Ar{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,r=this.options.setContext(this.getContext()),i=r.enabled&&n.options.animation&&r.animations,o=new V1(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=qN(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:r}=n,i=In(r,"beforeTitle",this,t),o=In(r,"title",this,t),s=In(r,"afterTitle",this,t);let a=[];return a=Fr(a,Qr(i)),a=Fr(a,Qr(o)),a=Fr(a,Qr(s)),a}getBeforeBody(t,n){return Gw(In(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:r}=n,i=[];return tt(t,o=>{const s={before:[],lines:[],after:[]},a=Jw(r,o);Fr(s.before,Qr(In(a,"beforeLabel",this,o))),Fr(s.lines,In(a,"label",this,o)),Fr(s.after,Qr(In(a,"afterLabel",this,o))),i.push(s)}),i}getAfterBody(t,n){return Gw(In(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:r}=n,i=In(r,"beforeFooter",this,t),o=In(r,"footer",this,t),s=In(r,"afterFooter",this,t);let a=[];return a=Fr(a,Qr(i)),a=Fr(a,Qr(o)),a=Fr(a,Qr(s)),a}_createItems(t){const n=this._active,r=this.chart.data,i=[],o=[],s=[];let a=[],l,c;for(l=0,c=n.length;l<c;++l)a.push(zN(this.chart,n[l]));return t.filter&&(a=a.filter((u,d,f)=>t.filter(u,d,f,r))),t.itemSort&&(a=a.sort((u,d)=>t.itemSort(u,d,r))),tt(a,u=>{const d=Jw(t.callbacks,u);i.push(In(d,"labelColor",this,u)),o.push(In(d,"labelPointStyle",this,u)),s.push(In(d,"labelTextColor",this,u))}),this.labelColors=i,this.labelPointStyles=o,this.labelTextColors=s,this.dataPoints=a,a}update(t,n){const r=this.options.setContext(this.getContext()),i=this._active;let o,s=[];if(!i.length)this.opacity!==0&&(o={opacity:0});else{const a=Ya[r.position].call(this,i,this._eventPosition);s=this._createItems(r),this.title=this.getTitle(s,r),this.beforeBody=this.getBeforeBody(s,r),this.body=this.getBody(s,r),this.afterBody=this.getAfterBody(s,r),this.footer=this.getFooter(s,r);const l=this._size=$w(this,r),c=Object.assign({},a,l),u=Kw(this.chart,r,c),d=Yw(r,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,o={opacity:1,x:d.x,y:d.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=s,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&r.external&&r.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,r,i){const o=this.getCaretPosition(t,r,i);n.lineTo(o.x1,o.y1),n.lineTo(o.x2,o.y2),n.lineTo(o.x3,o.y3)}getCaretPosition(t,n,r){const{xAlign:i,yAlign:o}=this,{caretSize:s,cornerRadius:a}=r,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:d}=No(a),{x:f,y:h}=t,{width:g,height:m}=n;let x,y,b,w,E,C;return o==="center"?(E=h+m/2,i==="left"?(x=f,y=x-s,w=E+s,C=E-s):(x=f+g,y=x+s,w=E-s,C=E+s),b=x):(i==="left"?y=f+Math.max(l,u)+s:i==="right"?y=f+g-Math.max(c,d)-s:y=this.caretX,o==="top"?(w=h,E=w-s,x=y-s,b=y+s):(w=h+m,E=w+s,x=y+s,b=y-s),C=w),{x1:x,x2:y,x3:b,y1:w,y2:E,y3:C}}drawTitle(t,n,r){const i=this.title,o=i.length;let s,a,l;if(o){const c=qs(r.rtl,this.x,this.width);for(t.x=ou(this,r.titleAlign,r),n.textAlign=c.textAlign(r.titleAlign),n.textBaseline="middle",s=Gt(r.titleFont),a=r.titleSpacing,n.fillStyle=r.titleColor,n.font=s.string,l=0;l<o;++l)n.fillText(i[l],c.x(t.x),t.y+s.lineHeight/2),t.y+=s.lineHeight+a,l+1===o&&(t.y+=r.titleMarginBottom-a)}}_drawColorBox(t,n,r,i,o){const s=this.labelColors[r],a=this.labelPointStyles[r],{boxHeight:l,boxWidth:c}=o,u=Gt(o.bodyFont),d=ou(this,"left",o),f=i.x(d),h=l<u.lineHeight?(u.lineHeight-l)/2:0,g=n.y+h;if(o.usePointStyle){const m={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},x=i.leftForLtr(f,c)+c/2,y=g+l/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,Sm(t,m,x,y),t.strokeStyle=s.borderColor,t.fillStyle=s.backgroundColor,Sm(t,m,x,y)}else{t.lineWidth=He(s.borderWidth)?Math.max(...Object.values(s.borderWidth)):s.borderWidth||1,t.strokeStyle=s.borderColor,t.setLineDash(s.borderDash||[]),t.lineDashOffset=s.borderDashOffset||0;const m=i.leftForLtr(f,c),x=i.leftForLtr(i.xPlus(f,1),c-2),y=No(s.borderRadius);Object.values(y).some(b=>b!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,Vl(t,{x:m,y:g,w:c,h:l,radius:y}),t.fill(),t.stroke(),t.fillStyle=s.backgroundColor,t.beginPath(),Vl(t,{x,y:g+1,w:c-2,h:l-2,radius:y}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(m,g,c,l),t.strokeRect(m,g,c,l),t.fillStyle=s.backgroundColor,t.fillRect(x,g+1,c-2,l-2))}t.fillStyle=this.labelTextColors[r]}drawBody(t,n,r){const{body:i}=this,{bodySpacing:o,bodyAlign:s,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=r,d=Gt(r.bodyFont);let f=d.lineHeight,h=0;const g=qs(r.rtl,this.x,this.width),m=function(L){n.fillText(L,g.x(t.x+h),t.y+f/2),t.y+=f+o},x=g.textAlign(s);let y,b,w,E,C,S,M;for(n.textAlign=s,n.textBaseline="middle",n.font=d.string,t.x=ou(this,x,r),n.fillStyle=r.bodyColor,tt(this.beforeBody,m),h=a&&x!=="right"?s==="center"?c/2+u:c+2+u:0,E=0,S=i.length;E<S;++E){for(y=i[E],b=this.labelTextColors[E],n.fillStyle=b,tt(y.before,m),w=y.lines,a&&w.length&&(this._drawColorBox(n,t,E,g,r),f=Math.max(d.lineHeight,l)),C=0,M=w.length;C<M;++C)m(w[C]),f=d.lineHeight;tt(y.after,m)}h=0,f=d.lineHeight,tt(this.afterBody,m),t.y-=o}drawFooter(t,n,r){const i=this.footer,o=i.length;let s,a;if(o){const l=qs(r.rtl,this.x,this.width);for(t.x=ou(this,r.footerAlign,r),t.y+=r.footerMarginTop,n.textAlign=l.textAlign(r.footerAlign),n.textBaseline="middle",s=Gt(r.footerFont),n.fillStyle=r.footerColor,n.font=s.string,a=0;a<o;++a)n.fillText(i[a],l.x(t.x),t.y+s.lineHeight/2),t.y+=s.lineHeight+r.footerSpacing}}drawBackground(t,n,r,i){const{xAlign:o,yAlign:s}=this,{x:a,y:l}=t,{width:c,height:u}=r,{topLeft:d,topRight:f,bottomLeft:h,bottomRight:g}=No(i.cornerRadius);n.fillStyle=i.backgroundColor,n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.beginPath(),n.moveTo(a+d,l),s==="top"&&this.drawCaret(t,n,r,i),n.lineTo(a+c-f,l),n.quadraticCurveTo(a+c,l,a+c,l+f),s==="center"&&o==="right"&&this.drawCaret(t,n,r,i),n.lineTo(a+c,l+u-g),n.quadraticCurveTo(a+c,l+u,a+c-g,l+u),s==="bottom"&&this.drawCaret(t,n,r,i),n.lineTo(a+h,l+u),n.quadraticCurveTo(a,l+u,a,l+u-h),s==="center"&&o==="left"&&this.drawCaret(t,n,r,i),n.lineTo(a,l+d),n.quadraticCurveTo(a,l,a+d,l),n.closePath(),n.fill(),i.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,r=this.$animations,i=r&&r.x,o=r&&r.y;if(i||o){const s=Ya[t.position].call(this,this._active,this._eventPosition);if(!s)return;const a=this._size=$w(this,t),l=Object.assign({},s,this._size),c=Kw(n,t,l),u=Yw(t,l,c,n);(i._to!==u.x||o._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=s.x,this.caretY=s.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let r=this.opacity;if(!r)return;this._updateAnimationTarget(n);const i={width:this.width,height:this.height},o={x:this.x,y:this.y};r=Math.abs(r)<.001?0:r;const s=wn(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=r,this.drawBackground(o,t,i,n),N1(t,n.textDirection),o.y+=s.top,this.drawTitle(o,t,n),this.drawBody(o,t,n),this.drawFooter(o,t,n),z1(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const r=this._active,i=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!Sd(r,i),s=this._positionChanged(i,n);(o||s)&&(this._active=i,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,r=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,o=this._active||[],s=this._getActiveElements(t,o,n,r),a=this._positionChanged(s,t),l=n||!Sd(s,o)||a;return l&&(this._active=s,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),l}_getActiveElements(t,n,r,i){const o=this.options;if(t.type==="mouseout")return[];if(!i)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const s=this.chart.getElementsAtEventForMode(t,o.mode,o,r);return o.reverse&&s.reverse(),s}_positionChanged(t,n){const{caretX:r,caretY:i,options:o}=this,s=Ya[o.position].call(this,t,n);return s!==!1&&(r!==s.x||i!==s.y)}}Z(Am,"positioners",Ya);var $N={id:"tooltip",_element:Am,positioners:Ya,afterInit(e,t,n){n&&(e.tooltip=new Am({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:dE},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},KN=Object.freeze({__proto__:null,Colors:oN,Decimation:cN,Filler:RN,Legend:DN,SubTitle:NN,Title:FN,Tooltip:$N});const YN=(e,t,n,r)=>(typeof t=="string"?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function GN(e,t,n,r){const i=e.indexOf(t);if(i===-1)return YN(e,t,n,r);const o=e.lastIndexOf(t);return i!==o?n:i}const JN=(e,t)=>e===null?null:Zt(Math.round(e),0,t);function Xw(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class Pm extends ns{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const r=this.getLabels();for(const{index:i,label:o}of n)r[i]===o&&r.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(Ne(t))return null;const r=this.getLabels();return n=isFinite(n)&&r[n]===t?n:GN(r,t,Le(n,t),this._addedLabels),JN(n,r.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:r,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(r=0),n||(i=this.getLabels().length-1)),this.min=r,this.max=i}buildTicks(){const t=this.min,n=this.max,r=this.options.offset,i=[];let o=this.getLabels();o=t===0&&n===o.length-1?o:o.slice(t,n+1),this._valueRange=Math.max(o.length-(r?0:1),1),this._startValue=this.min-(r?.5:0);for(let s=t;s<=n;s++)i.push({value:s});return i}getLabelForValue(t){return Xw.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}Z(Pm,"id","category"),Z(Pm,"defaults",{ticks:{callback:Xw}});function XN(e,t){const n=[],{bounds:i,step:o,min:s,max:a,precision:l,count:c,maxTicks:u,maxDigits:d,includeBounds:f}=e,h=o||1,g=u-1,{min:m,max:x}=t,y=!Ne(s),b=!Ne(a),w=!Ne(c),E=(x-m)/(d+1);let C=$x((x-m)/g/h)*h,S,M,L,T;if(C<1e-14&&!y&&!b)return[{value:m},{value:x}];T=Math.ceil(x/C)-Math.floor(m/C),T>g&&(C=$x(T*C/g/h)*h),Ne(l)||(S=Math.pow(10,l),C=Math.ceil(C*S)/S),i==="ticks"?(M=Math.floor(m/C)*C,L=Math.ceil(x/C)*C):(M=m,L=x),y&&b&&o&&WD((a-s)/o,C/1e3)?(T=Math.round(Math.min((a-s)/C,u)),C=(a-s)/T,M=s,L=a):w?(M=y?s:M,L=b?a:L,T=c-1,C=(L-M)/T):(T=(L-M)/C,cl(T,Math.round(T),C/1e3)?T=Math.round(T):T=Math.ceil(T));const V=Math.max(Kx(C),Kx(M));S=Math.pow(10,Ne(l)?V:l),M=Math.round(M*S)/S,L=Math.round(L*S)/S;let G=0;for(y&&(f&&M!==s?(n.push({value:s}),M<s&&G++,cl(Math.round((M+G*C)*S)/S,s,Qw(s,E,e))&&G++):M<s&&G++);G<T;++G){const F=Math.round((M+G*C)*S)/S;if(b&&F>a)break;n.push({value:F})}return b&&f&&L!==a?n.length&&cl(n[n.length-1].value,a,Qw(a,E,e))?n[n.length-1].value=a:n.push({value:a}):(!b||L===a)&&n.push({value:L}),n}function Qw(e,t,{horizontal:n,minRotation:r}){const i=Er(r),o=(n?Math.sin(i):Math.cos(i))||.001,s=.75*t*(""+e).length;return Math.min(t/o,s)}class Ad extends ns{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return Ne(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:r}=this.getUserBounds();let{min:i,max:o}=this;const s=l=>i=n?i:l,a=l=>o=r?o:l;if(t){const l=Vr(i),c=Vr(o);l<0&&c<0?a(0):l>0&&c>0&&s(0)}if(i===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||s(i-l)}this.min=i,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:r}=t,i;return r?(i=Math.ceil(this.max/r)-Math.floor(this.min/r)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${r} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let r=this.getTickLimit();r=Math.max(2,r);const i={maxTicks:r,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},o=this._range||this,s=XN(i,o);return t.bounds==="ticks"&&w1(s,this,"value"),t.reverse?(s.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),s}configure(){const t=this.ticks;let n=this.min,r=this.max;if(super.configure(),this.options.offset&&t.length){const i=(r-n)/Math.max(t.length-1,1)/2;n-=i,r+=i}this._startValue=n,this._endValue=r,this._valueRange=r-n}getLabelForValue(t){return sc(t,this.chart.options.locale,this.options.ticks.format)}}class Mm extends Ad{determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=It(t)?t:0,this.max=It(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,r=Er(this.options.ticks.minRotation),i=(t?Math.sin(r):Math.cos(r))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,o.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}Z(Mm,"id","linear"),Z(Mm,"defaults",{ticks:{callback:pf.formatters.numeric}});const $l=e=>Math.floor(Fi(e)),_o=(e,t)=>Math.pow(10,$l(e)+t);function Zw(e){return e/Math.pow(10,$l(e))===1}function e0(e,t,n){const r=Math.pow(10,n),i=Math.floor(e/r);return Math.ceil(t/r)-i}function QN(e,t){const n=t-e;let r=$l(n);for(;e0(e,t,r)>10;)r++;for(;e0(e,t,r)<10;)r--;return Math.min(r,$l(e))}function ZN(e,{min:t,max:n}){t=Yn(e.min,t);const r=[],i=$l(t);let o=QN(t,n),s=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),l=i>o?Math.pow(10,i):0,c=Math.round((t-l)*s)/s,u=Math.floor((t-l)/a/10)*a*10;let d=Math.floor((c-u)/Math.pow(10,o)),f=Yn(e.min,Math.round((l+u+d*Math.pow(10,o))*s)/s);for(;f<n;)r.push({value:f,major:Zw(f),significand:d}),d>=10?d=d<15?15:20:d++,d>=20&&(o++,d=2,s=o>=0?1:s),f=Math.round((l+u+d*Math.pow(10,o))*s)/s;const h=Yn(e.max,f);return r.push({value:h,major:Zw(h),significand:d}),r}class Tm extends ns{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,n){const r=Ad.prototype.parse.apply(this,[t,n]);if(r===0){this._zero=!0;return}return It(r)&&r>0?r:null}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=It(t)?Math.max(0,t):null,this.max=It(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!It(this._userMin)&&(this.min=t===_o(this.min,0)?_o(this.min,-1):_o(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let r=this.min,i=this.max;const o=a=>r=t?r:a,s=a=>i=n?i:a;r===i&&(r<=0?(o(1),s(10)):(o(_o(r,-1)),s(_o(i,1)))),r<=0&&o(_o(i,-1)),i<=0&&s(_o(r,1)),this.min=r,this.max=i}buildTicks(){const t=this.options,n={min:this._userMin,max:this._userMax},r=ZN(n,this);return t.bounds==="ticks"&&w1(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}getLabelForValue(t){return t===void 0?"0":sc(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Fi(t),this._valueRange=Fi(this.max)-Fi(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Fi(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const n=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+n*this._valueRange)}}Z(Tm,"id","logarithmic"),Z(Tm,"defaults",{ticks:{callback:pf.formatters.logarithmic,major:{enabled:!0}}});function Dm(e){const t=e.ticks;if(t.display&&e.display){const n=wn(t.backdropPadding);return Le(t.font&&t.font.size,_t.font.size)+n.height}return 0}function ez(e,t,n){return n=wt(n)?n:[n],{w:sI(e,t.string,n),h:n.length*t.lineHeight}}function t0(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:e<r||e>i?{start:t-n,end:t}:{start:t,end:t+n}}function tz(e){const t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],o=e._pointLabels.length,s=e.options.pointLabels,a=s.centerPointLabels?Ye/o:0;for(let l=0;l<o;l++){const c=s.setContext(e.getPointLabelContext(l));i[l]=c.padding;const u=e.getPointPosition(l,e.drawingArea+i[l],a),d=Gt(c.font),f=ez(e.ctx,d,e._pointLabels[l]);r[l]=f;const h=vn(e.getIndexAngle(l)+a),g=Math.round(uv(h)),m=t0(g,u.x,f.w,0,180),x=t0(g,u.y,f.h,90,270);nz(n,t,h,m,x)}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=oz(e,r,i)}function nz(e,t,n,r,i){const o=Math.abs(Math.sin(n)),s=Math.abs(Math.cos(n));let a=0,l=0;r.start<t.l?(a=(t.l-r.start)/o,e.l=Math.min(e.l,t.l-a)):r.end>t.r&&(a=(r.end-t.r)/o,e.r=Math.max(e.r,t.r+a)),i.start<t.t?(l=(t.t-i.start)/s,e.t=Math.min(e.t,t.t-l)):i.end>t.b&&(l=(i.end-t.b)/s,e.b=Math.max(e.b,t.b+l))}function rz(e,t,n){const r=e.drawingArea,{extra:i,additionalAngle:o,padding:s,size:a}=n,l=e.getPointPosition(t,r+i+s,o),c=Math.round(uv(vn(l.angle+Bt))),u=lz(l.y,a.h,c),d=sz(c),f=az(l.x,a.w,d);return{visible:!0,x:l.x,y:u,textAlign:d,left:f,top:u,right:f+a.w,bottom:u+a.h}}function iz(e,t){if(!t)return!0;const{left:n,top:r,right:i,bottom:o}=e;return!(li({x:n,y:r},t)||li({x:n,y:o},t)||li({x:i,y:r},t)||li({x:i,y:o},t))}function oz(e,t,n){const r=[],i=e._pointLabels.length,o=e.options,{centerPointLabels:s,display:a}=o.pointLabels,l={extra:Dm(o)/2,additionalAngle:s?Ye/i:0};let c;for(let u=0;u<i;u++){l.padding=n[u],l.size=t[u];const d=rz(e,u,l);r.push(d),a==="auto"&&(d.visible=iz(d,c),d.visible&&(c=d))}return r}function sz(e){return e===0||e===180?"center":e<180?"left":"right"}function az(e,t,n){return n==="right"?e-=t:n==="center"&&(e-=t/2),e}function lz(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function cz(e,t,n){const{left:r,top:i,right:o,bottom:s}=n,{backdropColor:a}=t;if(!Ne(a)){const l=No(t.borderRadius),c=wn(t.backdropPadding);e.fillStyle=a;const u=r-c.left,d=i-c.top,f=o-r+c.width,h=s-i+c.height;Object.values(l).some(g=>g!==0)?(e.beginPath(),Vl(e,{x:u,y:d,w:f,h,radius:l}),e.fill()):e.fillRect(u,d,f,h)}}function uz(e,t){const{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){const o=e._pointLabelItems[i];if(!o.visible)continue;const s=r.setContext(e.getPointLabelContext(i));cz(n,s,o);const a=Gt(s.font),{x:l,y:c,textAlign:u}=o;Jo(n,e._pointLabels[i],l,c+a.lineHeight/2,a,{color:s.color,textAlign:u,textBaseline:"middle"})}}function fE(e,t,n,r){const{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,yt);else{let o=e.getPointPosition(0,t);i.moveTo(o.x,o.y);for(let s=1;s<r;s++)o=e.getPointPosition(s,t),i.lineTo(o.x,o.y)}}function dz(e,t,n,r,i){const o=e.ctx,s=t.circular,{color:a,lineWidth:l}=t;!s&&!r||!a||!l||n<0||(o.save(),o.strokeStyle=a,o.lineWidth=l,o.setLineDash(i.dash||[]),o.lineDashOffset=i.dashOffset,o.beginPath(),fE(e,n,s,r),o.closePath(),o.stroke(),o.restore())}function fz(e,t,n){return lo(e,{label:n,index:t,type:"pointLabel"})}class Ga extends Ad{constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=wn(Dm(this.options)/2),n=this.width=this.maxWidth-t.width,r=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+n/2+t.left),this.yCenter=Math.floor(this.top+r/2+t.top),this.drawingArea=Math.floor(Math.min(n,r)/2)}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!1);this.min=It(t)&&!isNaN(t)?t:0,this.max=It(n)&&!isNaN(n)?n:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/Dm(this.options))}generateTickLabels(t){Ad.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((n,r)=>{const i=dt(this.options.pointLabels.callback,[n,r],this);return i||i===0?i:""}).filter((n,r)=>this.chart.getDataVisibility(r))}fit(){const t=this.options;t.display&&t.pointLabels.display?tz(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,n,r,i){this.xCenter+=Math.floor((t-n)/2),this.yCenter+=Math.floor((r-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,n,r,i))}getIndexAngle(t){const n=yt/(this._pointLabels.length||1),r=this.options.startAngle||0;return vn(t*n+Er(r))}getDistanceFromCenterForValue(t){if(Ne(t))return NaN;const n=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*n:(t-this.min)*n}getValueForDistanceFromCenter(t){if(Ne(t))return NaN;const n=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-n:this.min+n}getPointLabelContext(t){const n=this._pointLabels||[];if(t>=0&&t<n.length){const r=n[t];return fz(this.getContext(),t,r)}}getPointPosition(t,n,r=0){const i=this.getIndexAngle(t)-Bt+r;return{x:Math.cos(i)*n+this.xCenter,y:Math.sin(i)*n+this.yCenter,angle:i}}getPointPositionForValue(t,n){return this.getPointPosition(t,this.getDistanceFromCenterForValue(n))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){const{left:n,top:r,right:i,bottom:o}=this._pointLabelItems[t];return{left:n,top:r,right:i,bottom:o}}drawBackground(){const{backgroundColor:t,grid:{circular:n}}=this.options;if(t){const r=this.ctx;r.save(),r.beginPath(),fE(this,this.getDistanceFromCenterForValue(this._endValue),n,this._pointLabels.length),r.closePath(),r.fillStyle=t,r.fill(),r.restore()}}drawGrid(){const t=this.ctx,n=this.options,{angleLines:r,grid:i,border:o}=n,s=this._pointLabels.length;let a,l,c;if(n.pointLabels.display&&uz(this,s),i.display&&this.ticks.forEach((u,d)=>{if(d!==0||d===0&&this.min<0){l=this.getDistanceFromCenterForValue(u.value);const f=this.getContext(d),h=i.setContext(f),g=o.setContext(f);dz(this,h,l,s,g)}}),r.display){for(t.save(),a=s-1;a>=0;a--){const u=r.setContext(this.getPointLabelContext(a)),{color:d,lineWidth:f}=u;!f||!d||(t.lineWidth=f,t.strokeStyle=d,t.setLineDash(u.borderDash),t.lineDashOffset=u.borderDashOffset,l=this.getDistanceFromCenterForValue(n.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,n=this.options,r=n.ticks;if(!r.display)return;const i=this.getIndexAngle(0);let o,s;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!n.reverse)return;const c=r.setContext(this.getContext(l)),u=Gt(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=u.string,s=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const d=wn(c.backdropPadding);t.fillRect(-s/2-d.left,-o-u.size/2-d.top,s+d.width,u.size+d.height)}Jo(t,a.label,0,-o,u,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}Z(Ga,"id","radialLinear"),Z(Ga,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:pf.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),Z(Ga,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),Z(Ga,"descriptors",{angleLines:{_fallback:"grid"}});const xf={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Nn=Object.keys(xf);function n0(e,t){return e-t}function r0(e,t){if(Ne(t))return null;const n=e._adapter,{parser:r,round:i,isoWeekday:o}=e._parseOpts;let s=t;return typeof r=="function"&&(s=r(s)),It(s)||(s=typeof r=="string"?n.parse(s,r):n.parse(s)),s===null?null:(i&&(s=i==="week"&&(na(o)||o===!0)?n.startOf(s,"isoWeek",o):n.startOf(s,i)),+s)}function i0(e,t,n,r){const i=Nn.length;for(let o=Nn.indexOf(e);o<i-1;++o){const s=xf[Nn[o]],a=s.steps?s.steps:Number.MAX_SAFE_INTEGER;if(s.common&&Math.ceil((n-t)/(a*s.size))<=r)return Nn[o]}return Nn[i-1]}function hz(e,t,n,r,i){for(let o=Nn.length-1;o>=Nn.indexOf(n);o--){const s=Nn[o];if(xf[s].common&&e._adapter.diff(i,r,s)>=t-1)return s}return Nn[n?Nn.indexOf(n):0]}function pz(e){for(let t=Nn.indexOf(e)+1,n=Nn.length;t<n;++t)if(xf[Nn[t]].common)return Nn[t]}function o0(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:r,hi:i}=dv(n,t),o=n[r]>=t?n[r]:n[i];e[o]=!0}}function mz(e,t,n,r){const i=e._adapter,o=+i.startOf(t[0].value,r),s=t[t.length-1].value;let a,l;for(a=o;a<=s;a=+i.add(a,1,r))l=n[a],l>=0&&(t[l].major=!0);return t}function s0(e,t,n){const r=[],i={},o=t.length;let s,a;for(s=0;s<o;++s)a=t[s],i[a]=s,r.push({value:a,major:!1});return o===0||!n?r:mz(e,r,i,n)}class Kl extends ns{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const r=t.time||(t.time={}),i=this._adapter=new k2._date(t.adapters.date);i.init(n),ll(r.displayFormats,i.formats()),this._parseOpts={parser:r.parser,round:r.round,isoWeekday:r.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:r0(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,r=t.time.unit||"day";let{min:i,max:o,minDefined:s,maxDefined:a}=this.getUserBounds();function l(c){!s&&!isNaN(c.min)&&(i=Math.min(i,c.min)),!a&&!isNaN(c.max)&&(o=Math.max(o,c.max))}(!s||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),i=It(i)&&!isNaN(i)?i:+n.startOf(Date.now(),r),o=It(o)&&!isNaN(o)?o:+n.endOf(Date.now(),r)+1,this.min=Math.min(i,o-1),this.max=Math.max(i+1,o)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],r=t[t.length-1]),{min:n,max:r}}buildTicks(){const t=this.options,n=t.time,r=t.ticks,i=r.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const o=this.min,s=this.max,a=KD(i,o,s);return this._unit=n.unit||(r.autoSkip?i0(n.minUnit,this.min,this.max,this._getLabelCapacity(o)):hz(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!r.major.enabled||this._unit==="year"?void 0:pz(this._unit),this.initOffsets(i),t.reverse&&a.reverse(),s0(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,r=0,i,o;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?n=1-i:n=(this.getDecimalForValue(t[1])-i)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?r=o:r=(o-this.getDecimalForValue(t[t.length-2]))/2);const s=t.length<3?.5:.25;n=Zt(n,0,s),r=Zt(r,0,s),this._offsets={start:n,end:r,factor:1/(n+1+r)}}_generate(){const t=this._adapter,n=this.min,r=this.max,i=this.options,o=i.time,s=o.unit||i0(o.minUnit,n,r,this._getLabelCapacity(n)),a=Le(i.ticks.stepSize,1),l=s==="week"?o.isoWeekday:!1,c=na(l)||l===!0,u={};let d=n,f,h;if(c&&(d=+t.startOf(d,"isoWeek",l)),d=+t.startOf(d,c?"day":s),t.diff(r,n,s)>1e5*a)throw new Error(n+" and "+r+" are too far apart with stepSize of "+a+" "+s);const g=i.ticks.source==="data"&&this.getDataTimestamps();for(f=d,h=0;f<r;f=+t.add(f,a,s),h++)o0(u,f,g);return(f===r||i.bounds==="ticks"||h===1)&&o0(u,f,g),Object.keys(u).sort(n0).map(m=>+m)}getLabelForValue(t){const n=this._adapter,r=this.options.time;return r.tooltipFormat?n.format(t,r.tooltipFormat):n.format(t,r.displayFormats.datetime)}format(t,n){const i=this.options.time.displayFormats,o=this._unit,s=n||i[o];return this._adapter.format(t,s)}_tickFormatFunction(t,n,r,i){const o=this.options,s=o.ticks.callback;if(s)return dt(s,[t,n,r],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],d=c&&a[c],f=r[n],h=c&&d&&f&&f.major;return this._adapter.format(t,i||(h?d:u))}generateTickLabels(t){let n,r,i;for(n=0,r=t.length;n<r;++n)i=t[n],i.label=this._tickFormatFunction(i.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,r=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+r)*n.factor)}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+r*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,r=this.ctx.measureText(t).width,i=Er(this.isHorizontal()?n.maxRotation:n.minRotation),o=Math.cos(i),s=Math.sin(i),a=this._resolveTickFontOptions(0).size;return{w:r*o+a*s,h:r*s+a*o}}_getLabelCapacity(t){const n=this.options.time,r=n.displayFormats,i=r[n.unit]||r.millisecond,o=this._tickFormatFunction(t,0,s0(this,[t],this._majorUnit),i),s=this._getLabelSize(o),a=Math.floor(this.isHorizontal()?this.width/s.w:this.height/s.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,r;if(t.length)return t;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(n=0,r=i.length;n<r;++n)t=t.concat(i[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,r;if(t.length)return t;const i=this.getLabels();for(n=0,r=i.length;n<r;++n)t.push(r0(this,i[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return S1(t.sort(n0))}}Z(Kl,"id","time"),Z(Kl,"defaults",{bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}});function su(e,t,n){let r=0,i=e.length-1,o,s,a,l;n?(t>=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=ai(e,"pos",t)),{pos:o,time:a}=e[r],{pos:s,time:l}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=ai(e,"time",t)),{time:o,pos:a}=e[r],{time:s,pos:l}=e[i]);const c=s-o;return c?a+(l-a)*(t-o)/c:a}class Im extends Kl{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=su(n,this.min),this._tableRange=su(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:r}=this,i=[],o=[];let s,a,l,c,u;for(s=0,a=t.length;s<a;++s)c=t[s],c>=n&&c<=r&&i.push(c);if(i.length<2)return[{time:n,pos:0},{time:r,pos:1}];for(s=0,a=i.length;s<a;++s)u=i[s+1],l=i[s-1],c=i[s],Math.round((u+l)/2)!==c&&o.push({time:c,pos:s/(a-1)});return o}_generate(){const t=this.min,n=this.max;let r=super.getDataTimestamps();return(!r.includes(t)||!r.length)&&r.splice(0,0,t),(!r.includes(n)||r.length===1)&&r.push(n),r.sort((i,o)=>i-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),r=this.getLabelTimestamps();return n.length&&r.length?t=this.normalize(n.concat(r)):t=n.length?n:r,t=this._cache.all=t,t}getDecimalForValue(t){return(su(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return su(this._table,r*this._tableRange+this._minPos,!0)}}Z(Im,"id","timeseries"),Z(Im,"defaults",Kl.defaults);var gz=Object.freeze({__proto__:null,CategoryScale:Pm,LinearScale:Mm,LogarithmicScale:Tm,RadialLinearScale:Ga,TimeScale:Kl,TimeSeriesScale:Im});const vz=[_2,QF,KN,gz];var au=Object.freeze([Object.freeze([12,24,70]),Object.freeze([20,130,190]),Object.freeze([40,190,120]),Object.freeze([235,210,60]),Object.freeze([235,70,45])]);function yz(e){var t=Number(e);isFinite(t)||(t=0);var n=t<0?0:t>1?1:t,r=n*(au.length-1),i=Math.min(au.length-2,Math.floor(r)),o=r-i,s=au[i],a=au[i+1];return[Math.round(s[0]+(a[0]-s[0])*o),Math.round(s[1]+(a[1]-s[1])*o),Math.round(s[2]+(a[2]-s[2])*o)]}function bz(e){var t=yz(e);return"rgb("+t[0]+","+t[1]+","+t[2]+")"}Sr.register.apply(Sr,vz);function xz(e){for(var t=e.cells||[],n=Number(e.maxV)||0,r=[],i=[],o=0;o<t.length;o++)r.push({x:t[o].x,y:t[o].y}),i.push(bz(n>0?(Number(t[o].v)||0)/n:0));var s={color:"#9bb",font:{size:8},maxRotation:0,autoSkip:!0,maxTicksLimit:6},a={color:"#1c2836"};return{type:"scatter",data:{datasets:[{label:e.label||"topology",data:r,backgroundColor:i,borderWidth:0,pointStyle:"rect",pointRadius:7,hoverRadius:7}]},options:{responsive:!0,maintainAspectRatio:!1,animation:!1,plugins:{legend:{display:!0,labels:{color:"#cdd",font:{size:9},boxWidth:10}}},scales:{x:{ticks:s,grid:a,title:{display:!0,text:"z",color:"#7a8fa0",font:{size:8}}},y:{ticks:s,grid:a,reverse:!0,title:{display:!0,text:"y",color:"#7a8fa0",font:{size:8}}}}}}}function Pd(e){var t=null;return{render:function(n){e.innerHTML="";try{var r=(n.values||[]).reduce(function(u,d){return u+(Number(d)||0)},0);e.setAttribute("data-chart-sum",String(r))}catch{}var i=typeof document<"u"?document.createElement("canvas"):null;if(!i)throw new Error("[realm-chart] render requires a DOM (document) to host the canvas. (FAIL-LOUD.)");if(i.style.cssText="max-height:300px;",e.appendChild(i),t){try{t.destroy()}catch{}t=null}if(Array.isArray(n.cells)){t=new Sr(i,xz(n));return}var o=n.orientation===0||n.orientation===90,s=n.orientation===90,a;if(o){var l={color:"#9bb",font:{size:8},maxRotation:0,autoSkip:!0,maxTicksLimit:8},c={color:"#20303a"};a={responsive:!0,maintainAspectRatio:!1,indexAxis:s?"y":"x",plugins:{legend:{display:!0,labels:{color:"#cdd",font:{size:9},boxWidth:10}}},scales:{x:{ticks:l,grid:c},y:{ticks:l,grid:c,reverse:s}}}}else a={responsive:!0,plugins:{legend:{labels:{color:"#ccc"}}},scales:{x:{ticks:{color:"#888"},grid:{color:"#222"}},y:{ticks:{color:"#888"},grid:{color:"#222"}}}};t=new Sr(i,{type:n.kind==="line"?"line":"bar",data:{labels:n.labels,datasets:[{label:n.label,data:n.values,backgroundColor:"rgba(79,159,192,0.55)",borderColor:"rgba(79,159,192,1)",borderWidth:1}]},options:a})},destroy:function(){if(t){try{t.destroy()}catch{}t=null}e&&(e.innerHTML="")}}}function hE(e,t){if(!e)return Promise.reject(new Error("[realm-chart] boot requires a host element. (FAIL-LOUD.)"));var n=t&&t.kind||"in-app";if(n!=="in-app")return Promise.reject(new Error('[realm-chart] transport "'+n+'" is not supported by the chart realm (expect "in-app"). (FAIL-LOUD.)'));var r=Pd(e),i=VP(r,t||{kind:"in-app"});return Promise.resolve({handle:i.handle,impl:i.impl})}Fk("chart",{boot:hE});const wz=Object.freeze(Object.defineProperty({__proto__:null,bootChartRealm:hE,makeChartEnv:Pd},Symbol.toStringTag,{value:"Module"}));var _z=Dg({mode:"dev-core"});function an(e){e=e||{},this._mountEl=e.mountEl||null,this._engine=e.engine||"wasm",this._renderer=e.renderer||"p5",this._overlayHost=e.overlayHost||null,this._onTick=e.onTick||null,this._router=e.router||_z,this._runner=null,this._booted=!1,this._disposed=!1,this._tickCount=0,this._onRenderFrame=null,this._canvasWrapper=null,this._mountEl&&(this._mountEl.style.position="relative",this._mountEl.style.width="100%",this._mountEl.style.height="100%",this._mountEl.style.background="#0d0d0d",this._canvasWrapper=document.createElement("div"),this._canvasWrapper.id="gfx-canvas-wrapper-"+(Math.random()*1e9|0),this._canvasWrapper.style.cssText="width:100%;height:100%;",this._mountEl.appendChild(this._canvasWrapper),this._statusEl=document.createElement("div"),this._statusEl.style.cssText="position:absolute;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center;color:#555;font:13px ui-monospace,monospace;pointer-events:none;",this._statusEl.textContent="Booting engine ("+this._engine+")…",this._mountEl.appendChild(this._statusEl)),console.log("[GraphicsPane] constructed, engine:",this._engine)}an.prototype.boot=function(){var e=this;if(e._booted)return Promise.resolve();var t=new URL(e._router.resolve("experiments/_shared/boot.js"),document.baseURI).href,n=new URL(e._router.resolve("experiments/_shared/page-door.js"),document.baseURI).href;return Promise.all([import(t),import(n)]).then(function(r){var i=r[0];return r[1].refuseRetiredGlobals(),e._bootModule=i,i.bootPage({p5:"always",engine:e._engine,renderer:e._renderer,overlayHost:e._overlayHost,setup:function(){e._dispatchSetup()}}).ready.then(function(){return kk(e._router).then(function(o){e._realm=o})})},function(r){throw r.axis="engine",r}).then(function(){e._booted=!0,e._wireRenderFrameSubscription(),e._statusEl&&e._statusEl.parentNode&&(e._statusEl.parentNode.removeChild(e._statusEl),e._statusEl=null),console.log("[GraphicsPane] boot complete, engine:",e._engine)}).catch(function(r){var i=r&&r.message?r.message:String(r),o=r&&r.frqtlBootPainted?null:e._failLoud(i,r&&r.axis||"engine");return e._statusEl&&(e._statusEl.textContent="Engine boot failed.",e._statusEl.style.color="#ff6b6b"),Ee&&Ee.emit("engine:error",{message:i}),Promise.resolve(o).then(function(){throw r})})};an.prototype._failLoud=function(e,t){var n=t==="renderer"?"RENDERER":"ENGINE",r=n+` BOOT FAILED
156
+
157
+ `+e+`
158
+
159
+ The requested `+n.toLowerCase()+" is unavailable. No silent fallback.",i=this,o=t==="renderer"?"renderer":"engine";if(console.error("[GraphicsPane] FAIL-LOUD:",e),i._bootModule)return i._bootModule.paintBootFailure(o,r),Promise.resolve();var s=new URL(i._router.resolve("experiments/_shared/boot-failure.js"),document.baseURI).href;return import(s).then(function(a){i._overlayHost&&a.setBootOverlayHost(i._overlayHost),a.paintBootFailure(o,r)},function(a){console.error("[GraphicsPane] the boot-failure painter did not load either ("+s+"): "+String(a&&a.message||a))})};an.prototype._wireRenderFrameSubscription=function(){var e=this;e._onRenderFrame=function(t){if(t){if(t.cmd==="start"){e.start();return}if(t.cmd==="stop"){e.stop();return}if((t.universe||t.tickData)&&e._runner){var n=t.tickData||t.universe,r=e._runner.renderer;r&&r.renderTick&&r.renderTick(n,e._runner.largeObjects||[],e._runner._renderOptions)}}},Ee&&Ee.on("render:frame",e._onRenderFrame)};an.prototype.prepareExperiment=function(e,t){this._pendingExperiment={setupFn:e,opts:t||{}}};an.prototype._makePaneOnTick=function(e){var t=this;return function(n,r){t._tickCount++;var i=kz(n);Ee&&Ee.emit("engine:tick",{tick:t._tickCount,metrics:i}),t._onTick&&t._onTick(n,r),typeof e=="function"&&e(n,r)}};an.prototype._dispatchSetup=function(){var e=this;if(e._pendingMountRunner){var t=e._pendingMountRunner;if(e._pendingMountRunner=null,e._runner&&e._runner!==t&&e._runner.isRunning&&e._runner.stop(),e._canvasWrapper&&(t._canvasParentId=e._canvasWrapper.id),t._onTick=e._makePaneOnTick(t._onTick),e._runner=t,t.createCanvas(),t.start(),typeof e._setupResolve=="function"){var n=e._setupResolve;e._setupResolve=null,n(e._runner)}return}var r=e._pendingExperiment;if(!r||typeof r.setupFn!="function"){try{if(typeof createCanvas=="function"){var i=createCanvas(1,1);i&&i.elt&&i.elt.style&&(i.elt.style.display="none")}typeof noLoop=="function"&&noLoop()}catch{}return}if(!e._realm){var o="the realm modules (FrqtlApp, the display slot) are not loaded at p5 setup dispatch — boot() loads them (lib/shim/engine/engine-stack-boot.js) before it resolves; an experiment registered ahead of that must wait on boot() too.";throw e._failLoud(o,"engine"),new Error("[GraphicsPane] "+o)}var s=r.opts||{};e._runner&&e._runner.isRunning&&e._runner.stop();try{e._runner=new e._realm.app.FrqtlApp({canvasParentId:e._canvasWrapper?e._canvasWrapper.id:null,canvasW:s.canvasW,canvasH:s.canvasH,is3D:e._realm.display.name()==="three",seed:s.seed||42,stepsPerFrame:s.stepsPerFrame||1,onTick:e._makePaneOnTick(null)})}catch(c){if(e._failLoud(c.message,"engine"),typeof e._setupReject=="function"){var a=e._setupReject;e._setupResolve=null,e._setupReject=null,a(c)}throw c}if(e._runner.createCanvas(),e._runner.setup(r.setupFn,s),e._runner.start(),typeof e._setupResolve=="function"){var l=e._setupResolve;e._setupResolve=null,l(e._runner)}};an.prototype.loadExperiment=function(e,t){var n=this;return this._booted?typeof window.p5>"u"?(console.error("[GraphicsPane] p5 not available."),Promise.reject(new Error("[GraphicsPane] p5 not available"))):(n.prepareExperiment(e,t),n._driveP5Setup()):(console.warn("[GraphicsPane] loadExperiment called before boot() resolved. Call boot() first."),Promise.reject(new Error("[GraphicsPane] not booted")))};an.prototype.mountRunner=function(e){var t=this;return this._booted?typeof window.p5>"u"?(console.error("[GraphicsPane] p5 not available."),Promise.reject(new Error("[GraphicsPane] p5 not available"))):!e||typeof e.createCanvas!="function"||typeof e.start!="function"?Promise.reject(new Error("[GraphicsPane] mountRunner requires an FrqtlApp (got "+(e===null?"null":typeof e)+"). (FAIL-LOUD.)")):(t._pendingExperiment=null,t._pendingMountRunner=e,t._driveP5Setup()):(console.warn("[GraphicsPane] mountRunner called before boot() resolved. Call boot() first."),Promise.reject(new Error("[GraphicsPane] not booted")))};an.prototype._driveP5Setup=function(){var e=this;return new Promise(function(t,n){e._setupResolve=t,e._setupReject=n;try{e._p5Instance&&typeof e._p5Instance.remove=="function"&&e._p5Instance.remove()}catch{}try{e._p5Instance=new window.p5}catch(r){e._setupResolve=null,n(r);return}setTimeout(function(){e._setupResolve===t&&(e._setupResolve=null,n(new Error("[GraphicsPane] p5 setup did not fire within 8s")))},8e3)})};an.prototype.start=function(){if(!this._disposed){if(!this._runner){console.warn("[GraphicsPane] start() called with no experiment loaded.");return}this._runner.start()}};an.prototype.stop=function(){this._runner&&this._runner.stop()};an.prototype.step=function(){return this._disposed?null:this._runner?this._runner.step():(console.warn("[GraphicsPane] step() called with no experiment loaded."),null)};an.prototype.getRunner=function(){return this._runner};an.prototype.runFrqtlCode=function(e){ui.run({source:"frqtl",code:e,fileId:"_gfx-editor"})};an.prototype.dispose=function(){this.stop(),this._disposed=!0,this._onRenderFrame&&Ee&&(Ee.off("render:frame",this._onRenderFrame),this._onRenderFrame=null);try{this._p5Instance&&typeof this._p5Instance.remove=="function"&&this._p5Instance.remove()}catch{}this._p5Instance=null,this._runner&&this._runner.dispose(),this._runner=null,console.log("[GraphicsPane] disposed")};function kz(e,t){var n={};if(!e)return n;if(typeof e.tick_count=="number"&&(n.Tick=e.tick_count),e.dimensionData&&Array.isArray(e.dimensionData)){for(var r=0,i=0;i<e.dimensionData.length;i++){var o=e.dimensionData[i];o&&typeof o.frameCount=="number"&&(r+=o.frameCount)}n["Active Quanta"]=r}else e.frameData&&Array.isArray(e.frameData)&&(n["Active Quanta"]=e.frameData.length);return n}typeof window<"u"&&(window.GraphicsPane=an);function pE(e){var t=[];if(!e)return t;if(e.detectorWall&&typeof e.detectorWall.getCollisionHistogram=="function"&&t.push(e.detectorWall),Array.isArray(e.largeObjects))for(var n=0;n<e.largeObjects.length;n++){var r=e.largeObjects[n];r&&typeof r.getCollisionHistogram=="function"&&t.indexOf(r)===-1&&t.push(r)}return t}function Sz(e,t){for(var n=pE(e),r=0;r<n.length;r++)n[r].getCollisionHistogram(t)}function Ez(e,t){e&&(Yo(e)?e.forEach(function(n,r){t[String(r)]=Number(n)}):Yo(e.combined)?e.combined.forEach(function(n,r){t[String(r)]=Number(n)}):typeof e=="object"&&Object.keys(e).forEach(function(n){t[String(n)]=Number(e[n])}))}function Xh(e){var t={};if(!e)return t;var n=typeof e.setupResult<"u"?e.setupResult:e._setupResult||null;if(!n)return t;for(var r=pE(n),i=0;i<r.length;i++)Ez(r[i].getCollisionHistogram(),t);return t}function Oz(e,t){if(!e||typeof e.start!="function"||typeof e.dispose!="function")throw new Error("[realm-frqtl] makeFrqtlHandle requires a GraphicsPane-like object. (FAIL-LOUD.)");var n=[];e._onTick=function(i,o){if(Sz(o,i),!!n.length)for(var s={tick:e._tickCount||0,detector:Xh(e.getRunner())},a=0;a<n.length;a++)try{n[a](s)}catch{}};var r={_transport:t&&t.kind||"in-app",inject:function(i){return Promise.reject(new Error('[realm-frqtl] inject("'+i+'") is retired — the opaque setup-factory recipe path was removed. Bind a lane=frqtl builder that `import`s an editable setup module; its live runner mounts via the host-side fast path, not the data plane. (FAIL-LOUD — no opaque setup-script load.)'))},call:function(i){if(i==="detectorHistogram")return Xh(e.getRunner());if(i==="tickCount")return e._tickCount||0;throw new Error('[realm-frqtl] call: unknown fn "'+i+'" (expect "detectorHistogram" | "tickCount"). (FAIL-LOUD.)')},on:function(i,o){if(i!=="tick")throw new Error('[realm-frqtl] on: unknown event "'+i+'" (expect "tick"). (FAIL-LOUD.)');return n.push(o),function(){var s=n.indexOf(o);s!==-1&&n.splice(s,1)}},start:function(){e.start()},stop:function(){e.stop()},step:function(){return e.step(),{tick:e._tickCount||0,detector:Xh(e.getRunner())}},dispose:function(){n.length=0,e._onTick=null,e.dispose()},_mountRunnerInProcess:function(i){return e.mountRunner(i)},_graphicsPane:e};return{handle:Nk(r),impl:r}}function Cz(e,t,n){if(!e)return Promise.reject(new Error("[realm-frqtl] boot requires a host element. (FAIL-LOUD.)"));var r=t&&t.kind||"in-app";if(r!=="in-app")return Promise.reject(new Error('[realm-frqtl] transport "'+r+'" is not supported by the frqtl realm (expect "in-app"). (FAIL-LOUD.)'));var i=n&&n.engine||"wasm",o=n&&n.mode||"dev-core",s=Dg({mode:o,engine:i}),a=n&&n.render3d?"three":"p5",l=new an({mountEl:e,engine:s.engine,router:s,renderer:a,overlayHost:e});return l.boot().then(function(){var c=Oz(l,t||{kind:"in-app"});return{handle:c.handle,impl:c.impl,pane:l}})}Fk("frqtl",{boot:Cz});var jz=typeof window<"u"&&window.console?{log:window.console.log.bind(window.console),warn:window.console.warn.bind(window.console),error:window.console.error.bind(window.console)}:{log:function(){},warn:function(){},error:function(){}},br=Ir;function Re(e,t,n){var r=document.createElement(e);return t&&(r.style.cssText=t),n!=null&&(r.textContent=n),r}function Rz(e){e=e||{};var t=e.mountEl;if(!t)throw new Error("[NotebookPane] mountEl is required");e.math;var n=e.frqtl||null,r=typeof e.onConsole=="function"?e.onConsole:null,i=e.monacoBaseUrl||null,o=e.markdownCssUrl||null,s=null,a=null,l=[],c=Object.create(null),u=null,d=!1,f=null,h=!1,g=[];function m(){if(!h){h=!0;for(var k=0;k<g.length;k++)try{g[k](!0)}catch{}}}var x=null,y=null,b=null,w=null,E=null,C=null,S=!1,M=null,L=null;function T(k,R){var P={mountEl:k,emitBusRun:!1};if(i&&(P.monacoBaseUrl=i),R)for(var $ in R)Object.prototype.hasOwnProperty.call(R,$)&&(P[$]=R[$]);return new window.CodeEditorPane(P)}function V(){if(!(typeof document>"u")){if(o&&!document.getElementById("frqtl-md-github-css")){var k=document.createElement("link");k.id="frqtl-md-github-css",k.rel="stylesheet",k.href=o,document.head.appendChild(k)}if(!document.getElementById("frqtl-md-overlay")){var R=document.createElement("style");R.id="frqtl-md-overlay",R.textContent=".markdown-body.frqtl-md{background:transparent;color:#cfcfcf;font-size:0.92rem;}.markdown-body.frqtl-md a{color:#7fc4ff;}.markdown-body.frqtl-md h1,.markdown-body.frqtl-md h2{border-bottom-color:#2a2a2a;}.markdown-body.frqtl-md code{background:#1c1c1c;padding:1px 5px;border-radius:3px;font-size:0.85em;}.markdown-body.frqtl-md h1{font-size:1.5rem;color:#fff;}.markdown-body.frqtl-md h2{font-size:1.25rem;color:#fff;}.markdown-body.frqtl-md h3{font-size:1.1rem;color:#fff;}.markdown-body.frqtl-md ul{padding-left:1.3em;}",document.head.appendChild(R)}}}V(),t.innerHTML="",t.style.cssText="display:flex;flex-direction:column;height:100%;overflow:auto;background:#0d0d0d;color:#ddd;";var G=Re("div","position:sticky;top:0;z-index:5;display:flex;align-items:center;gap:10px;padding:8px 20px;background:#141414;border-bottom:1px solid #1d1d1d;");G.setAttribute("data-role","notebook-toolbar"),E=Re("button","padding:6px 16px;background:#1f6f3f;color:#fff;border:none;border-radius:4px;cursor:pointer;font:600 0.8rem/1 system-ui,sans-serif;","Run All"),E.setAttribute("data-role","notebook-run-all"),E.addEventListener("click",function(){Mt()}),G.appendChild(E),C=Re("span","font:0.72rem/1 ui-monospace,monospace;color:#888;",""),C.setAttribute("data-role","notebook-run-all-status"),G.appendChild(C),t.appendChild(G);var F=Re("div","flex:1;padding:16px 20px;font-size:0.9rem;line-height:1.5;max-width:960px;margin:0 auto;width:100%;box-sizing:border-box;");F.className="frqtl-notebook",t.appendChild(F);function te(){try{return st.active().id}catch{return null}}function W(){for(var k=te(),R=0;R<l.length;R++){var P=l[R];P.els&&P.els.backendBadge&&(k?(P.els.backendBadge.textContent=k,P.els.backendBadge.style.background="#13202b",P.els.backendBadge.style.color="#7fc4ff",P.els.backendBadge.style.display=""):(P.els.backendBadge.textContent="no backend",P.els.backendBadge.style.background="#3a1a1a",P.els.backendBadge.style.color="#ff8a8a",P.els.backendBadge.style.display=""))}}var Y={idle:"background:#222;color:#888;",running:"background:#1c3a55;color:#7fc4ff;",ok:"background:#0f2417;color:#7ee2a8;",error:"background:#2a0c0c;color:#ff8a8a;",stale:"background:#3a2c08;color:#ffd27f;"};function re(k,R){var P=c[k];if(!(!P||!P.els||!P.els.statusBadge)){var $=P.els.statusBadge;$.textContent=R,$.style.cssText="font:600 0.65rem/1 ui-monospace,monospace;padding:3px 7px;border-radius:3px;text-transform:uppercase;letter-spacing:0.04em;"+(Y[R]||Y.idle),P.els.runBtn&&(P.els.runBtn.style.outline=R===br.STALE?"1px solid #ffd27f":"none")}}var pe={CONSOLE:"console"};function B(k){var R=Re("div","min-height:8px;"),P=Re("div","padding:8px 10px;display:none;");k.appendChild(R),k.appendChild(P);var $=new ao({mountEl:R}),U=!1;return{type:pe.CONSOLE,consoleHost:R,htmlHost:P,pane:$,line:function(H,he){var Ae=he==="error"?"error":he==="warn"?"warn":he==="log"||!he?"info":he;$.log(Ae,String(H)),U=!0},node:function(H){P.style.display="",P.appendChild(H)},hasOutput:function(){return U||P.childNodes.length>0},clear:function(){$.clear(),U=!1,P.innerHTML="",P.style.display="none"},dispose:function(){try{$.clear()}catch{}k.innerHTML=""}}}function ee(){b||(b=function(k){if(k){var R=L?c[L]:null;R&&R.output&&typeof R.output.line=="function"&&R.output.line(String(k.text),k.level)}},Ee.on("console:write",b))}function ce(){b&&(Ee.off("console:write",b),b=null)}function ve(k){if(k&&k.liveChart){try{k.liveChart.dispose()}catch{}k.liveChart=null}if(k&&k.viewController){try{k.viewController.dispose()}catch{}k.viewController=null}if(k&&k.realm&&k.realm.impl&&k.realm.impl._graphicsPane&&typeof k.realm.impl._graphicsPane.getRunner=="function")try{var R=k.realm.impl._graphicsPane.getRunner();R&&R._liveChartsMount&&(R._liveChartsMount.dispose(),R._liveChartsMount=null,R._liveChartsMounted=!1)}catch{}if(k&&k.realm){try{k.realm.handle.dispose()}catch{}k.realm=null}}function ke(){for(var k=0;k<l.length;k++)l[k].realm&&ve(l[k]);M=null}function je(){for(var k=0;k<l.length;k++){var R=l[k];if(R.cell&&R.cell.type==="module"&&R.editor){var P=R.editor.activeFile();P&&typeof P.value=="string"&&(R.cell.body=P.value)}}}function ie(k){if(!s)return Promise.resolve();var R=k.cell.id;if(k.editor){var P=k.editor.activeFile();P&&typeof P.value=="string"&&(k.cell.body=P.value)}je(),k.output&&k.output.clear(),L=R,ee();var $=function(U){k.output&&(U&&typeof U=="object"&&typeof U.nodeType=="number"?k.output.node(U):typeof U=="string"?k.output.line(U,"log"):k.output.line(me(U),"log"))};return s.runCell(R,{display:$}).then(function(U){if(U&&U.ok&&U.outputs&&k.output&&!k.output.hasOutput())for(var H=Object.keys(U.outputs),he=0;he<H.length;he++){var Ae=U.outputs[H[he]];k.output.line(H[he]+" = "+me(Ae),"log")}return U}).catch(function(U){k.output&&k.output.line(U&&U.message?U.message:String(U),"error"),re(R,br.ERROR)}).finally(function(){ce(),L=null})}function me(k){try{return typeof k=="object"?JSON.stringify(k):String(k)}catch{return String(k)}}var xe="2px solid #2d6cff";function ge(k){for(var R=0;R<l.length;R++)if(l[R].cell&&l[R].cell.id===k)return R;return-1}function kt(k){if(u!==k){var R=u?c[u]:null;R&&R.els&&R.els.card&&(R.els.card.style.outline="none"),u=k||null;var P=k?c[k]:null;if(P&&P.els&&P.els.card&&(P.els.card.style.outline=xe,P.els.card.style.outlineOffset="-1px",typeof P.els.card.scrollIntoView=="function"))try{P.els.card.scrollIntoView({block:"nearest"})}catch{}}}function ut(k){if(l.length){var R=Math.max(0,Math.min(l.length-1,k)),P=l[R];P&&P.cell&&kt(P.cell.id)}}function _n(k){var R=k&&k.els&&k.els.card;R&&(R.hasAttribute("tabindex")||R.setAttribute("tabindex","-1"),R.style.outline="none",R.addEventListener("mousedown",function(){k.cell&&kt(k.cell.id)}))}function tn(){var k=u?c[u]:null;if(!(!k||!k.cell)){if(k.cell.type==="markdown"){typeof k.openEditor=="function"&&k.openEditor();return}if(k.editor&&(d=!0,typeof k.editor.focus=="function"))try{k.editor.focus()}catch{}}}function ir(){var k=u?c[u]:null;if(d=!1,k&&k.cell&&k.cell.type==="markdown"&&typeof k.closeEditor=="function"&&k.closeEditor(),k&&k.els&&k.els.card&&typeof k.els.card.focus=="function")try{k.els.card.focus()}catch{}}function ht(k,R){if(!k||!k.cell)return Promise.resolve();R=R||"inplace";var P=k.cell,$=ge(P.id);function U(){d=!1;var Ae=rD($,l.length,R);ut(Ae)}var H=iD(P.type);function he(){R!=="inplace"&&U()}switch(H.leaf){case Di.MARKDOWN_RENDER:return typeof k.closeEditor=="function"&&k.closeEditor(),he(),Promise.resolve();case Di.MODULE_ADVANCE:return he(),Promise.resolve();case Di.REALM:return Promise.resolve(Mn(k)).then(he);case Di.JS:default:return Promise.resolve(ie(k)).then(he)}}function ye(){f||typeof document>"u"||(f=function(k){if(u){var R=c[u];if(R){var P=nD(k,d);if(P)switch(P){case Jn.EDIT:k.preventDefault(),tn();break;case Jn.COMMAND_MODE:k.preventDefault(),ir();break;case Jn.SELECT_PREV:k.preventDefault(),ut(ge(u)-1);break;case Jn.SELECT_NEXT:k.preventDefault(),ut(ge(u)+1);break;case Jn.RUN_ADVANCE:k.preventDefault(),ht(R,"advance");break;case Jn.RUN_INPLACE:k.preventDefault(),ht(R,"inplace");break}}}},document.addEventListener("keydown",f,!0))}function St(){f&&typeof document<"u"&&document.removeEventListener("keydown",f,!0),f=null}function ln(k){return k&&k.realm?k.realm:k&&k.type==="chart"?"chart":"frqtl"}function Wn(k){return ln(k)==="chart"}function An(k){return!!(k&&k.type==="view")}function Pn(k){var R=k.spec||"bar",P=R.split(":"),$=(P[0]||"bar").trim(),U=(P[1]||k.in&&k.in[0]||"").trim();if(!U)throw new Error('[chart] no binding name in spec ("'+R+'") or `in` — nothing to plot.');if(!s)throw new Error('[chart] no kernel — cannot resolve binding "'+U+'".');var H=s.getBinding(U);if(!H){var he=I(U),Ae=he?'run cell "'+he+'" first.':"no cell produces it.";throw new Error('[chart] input "'+U+'" not yet produced — '+Ae+" (FAIL-LOUD)")}var Ve=H.value;if(Ve instanceof Map){var Qe={};Ve.forEach(function(Be,Ce){Qe[String(Ce)]=Be}),Ve=Qe}return{kind:$,label:U,data:Ve}}function Mn(k){var R=k.cell.id,P=Wn(k.cell),$=An(k.cell);if(M&&M!==R){var U=c[M];U&&(ve(U),re(U.cell.id,br.IDLE))}ve(k);var H=null,he=null,Ae=null;if(P)try{he=Pn(k.cell)}catch(Ce){return De(k,Ce&&Ce.message?Ce.message:String(Ce)),re(R,br.ERROR),Promise.resolve()}else if($)try{Ae=Pt(k.cell)}catch(Ce){return De(k,Ce&&Ce.message?Ce.message:String(Ce)),re(R,br.ERROR),Promise.resolve()}else try{H=vr(k.cell)}catch(Ce){return De(k,Ce&&Ce.message?Ce.message:String(Ce)),re(R,br.ERROR),Promise.resolve()}re(R,br.RUNNING);var Ve=k.els.gfxHost||k.els.realmHost;Ve.innerHTML="";var Qe;try{Qe=XR(ln(k.cell))}catch(Ce){return De(k,Ce&&Ce.message?Ce.message:String(Ce)),re(R,br.ERROR),Promise.resolve()}var Be;return(n&&(n.engine||n.mode)||k.cell.render3d)&&(Be={},n&&n.engine&&(Be.engine=n.engine),n&&n.mode&&(Be.mode=n.mode),k.cell.render3d&&(Be.render3d=!0)),Promise.resolve(Qe.boot(Ve,ZR(),Be)).then(function(Ce){return k.realm=Ce,M=R,P?Ce.handle.inject("chart",he):$?Ut(k,Ce,Ae):Xt(Ce,H)}).then(async function(){if(!P&&!$&&k.realm&&k.realm.handle&&s){var Ce=Array.isArray(k.cell.produces)?k.cell.produces:[];if(Ce.length){await Et(k.realm.handle,k.cell.produceAfter);for(var qe=await JT(k.realm.handle,Ce,k.cell.produceVia),nn=0;nn<qe.length;nn++){var N={};N[qe[nn].name]=qe[nn].value,s.commitViewOutputs(R,N)}}}if(!P&&!$&&k.cell.liveChart&&k.realm&&k.realm.handle&&k.els.liveChartHost){var K=k.cell.liveChart,We=k.cell.liveChartKind||"bar";if(xd.indexOf(K)===-1)throw new Error('[notebook-pane] liveChart="'+K+'" is not a blessed projector (expect one of ['+xd.join(", ")+"]). (FAIL-LOUD.)");if(We!=="bar"&&We!=="line")throw new Error('[notebook-pane] liveChartKind="'+We+'" must be "bar" | "line". (FAIL-LOUD.)');var kn=Pd(k.els.liveChartHost);k.liveChart=fm({handle:k.realm.handle,chartEnv:kn,projector:K,kind:We,label:K,now:function(){return typeof performance<"u"&&performance.now?performance.now():Date.now()},throttleMs:nv}),k.liveChart.start()}re(R,br.OK),Tn(k)}).catch(function(Ce){var qe=Ce&&Ce.message?Ce.message:String(Ce);tD(Ve)||(Ve.innerHTML="",De(k,qe)),re(R,br.ERROR)})}function vr(k){return YT(k),HT({setup:k.setup,modules:s?s.moduleSet():{},opts:k.opts||{},shape:k.shape||"",stage:k.stage||"",seed:k.seed||"",render3d:!!k.render3d,renderOptions:k.renderOptions||{},cameraPreset:k.cameraPreset||"",outName:k.id+"_run"})}function Xt(k,R){if(!k||!k.impl||typeof k.impl._mountRunnerInProcess!="function")return Promise.reject(new Error("[frqtl] declared canvas requires the frqtl realm host-side mount seam (impl._mountRunnerInProcess). (FAIL-LOUD.)"));var P=R.outName;return ui.runCell({lane:"frqtl",code:R.builderCode,id:"_declared_synth",forceModulePath:R.usesModulePath,modules:s?s.moduleSet():{},inputs:{},declaredOutputs:[P]}).then(function($){if(!$||!$.ok)throw new Error("[frqtl] synthesized builder failed: "+($&&$.error?$.error:"unknown error")+" (FAIL-LOUD.)");var U=$.outputs?$.outputs[P]:null;if(!U)throw new Error('[frqtl] synthesized builder returned no runner for "'+P+'". (FAIL-LOUD.)');return Promise.resolve(k.impl._mountRunnerInProcess(U)).then(function(H){return U&&typeof U.addTickListener=="function"&&!U._liveChartsMounted&&(U._liveChartsMounted=!0,n1(U,{}).then(function(he){U._liveChartsMount=he}).catch(function(he){typeof console<"u"&&console.error&&console.error("[frqtl] mountLiveCharts failed:",he)})),H})})}function Pt(k){return $T({module:k.module,modules:s?s.moduleSet():{},outName:k.id+"_view"})}function Ut(k,R,P){var $=k.cell,U=P.outName;return ui.runCell({lane:"frqtl",code:P.entryCode,id:"_view_synth",modules:s?s.moduleSet():{},inputs:{},declaredOutputs:[U]}).then(function(H){if(!H||!H.ok)throw new Error("[view] view module failed: "+(H&&H.error?H.error:"unknown error")+" (FAIL-LOUD.)");var he=H.outputs?H.outputs[U]:null;if(typeof he!="function")throw new Error('[view] view module export "'+P.exportName+'" is not a function (got '+(he===null?"null":typeof he)+"). A view export must be `render(ctx)`. (FAIL-LOUD.)");for(var Ae={},Ve=Array.isArray($.in)?$.in:[],Qe=0;Qe<Ve.length;Qe++){var Be=Ve[Qe],Ce=s?s.getBinding(Be):null;if(!Ce){var qe=I(Be),nn=qe?'run cell "'+qe+'" first.':"no cell produces it.";throw new Error('[view] input "'+Be+'" not yet produced — '+nn+" (FAIL-LOUD)")}Ae[Be]=Ce.value}var N=k.els.viewMount||k.els.realmHost,K=KT({mount:N,handle:R.handle,bindings:Ae,commit:s?function(We,kn){var Nt={};Nt[We]=kn,s.commitViewOutputs($.id,Nt)}:void 0,imports:{makeChartEnv:Pd,makeLiveChartController:fm}});return Promise.resolve(he(K)).then(function(We){We&&typeof We.dispose=="function"&&(k.viewController=We)})})}function Et(k,R){return eD(k,R,XT,QT)}function De(k,R){var P=Re("pre","color:#ff6b6b;background:#1a0c0c;border:1px solid #3a1a1a;padding:8px 10px;border-radius:4px;font-size:0.8rem;white-space:pre-wrap;",R);k.els.realmHost&&k.els.realmHost.appendChild(P)}function Tn(k,R){k.els.stopBtn&&(k.els.stopBtn.disabled=!1),k.els.stepBtn&&(k.els.stepBtn.disabled=!1)}function I(k){for(var R=0;R<l.length;R++){var P=l[R].cell;if(P.out&&P.out.indexOf(k)!==-1||P.bind===k)return P.id}return null}function de(k){var R=Re("div","margin:14px 0;border:1px solid #1d1d1d;border-radius:6px;background:#111;overflow:hidden;");R.setAttribute("data-cell-id",k.id||""),R.setAttribute("data-cell-type",k.type||""),k.lane&&R.setAttribute("data-cell-lane",k.lane);var P=Re("div","display:flex;align-items:center;gap:8px;padding:6px 10px;background:#161616;border-bottom:1px solid #1d1d1d;"),$=Re("span","font:600 0.62rem/1 ui-monospace,monospace;color:#777;text-transform:uppercase;letter-spacing:0.06em;",k.type+(k.lane?"·"+k.lane:""));P.appendChild($),k.id&&P.appendChild(Re("span","font:0.62rem/1 ui-monospace,monospace;color:#555;",k.id));var U=Re("div","flex:1;");P.appendChild(U);var H=Re("span","","idle");return H.setAttribute("data-role","status-badge"),P.appendChild(H),R.appendChild(P),{card:R,header:P,statusBadge:H}}function fe(k,R){k._collapsibleEls=R||[];var P=Re("button","flex:0 0 auto;width:18px;height:18px;padding:0;line-height:1;background:transparent;border:none;color:#888;cursor:pointer;font:0.8rem/1 ui-monospace,monospace;","");return P.setAttribute("data-role","collapse-toggle"),P.title="collapse / expand cell",k.els.collapseBtn=P,P.addEventListener("click",function($){$.stopPropagation(),k.cell.collapsed=!k.cell.collapsed,Ie(k),m()}),P}function Ie(k){for(var R=!!k.cell.collapsed,P=k._collapsibleEls||[],$=0;$<P.length;$++)P[$]&&(P[$].style.display=R?"none":"");k.els.collapseBtn&&(k.els.collapseBtn.textContent=R?"▸":"▾"),k.els.card&&k.els.card.setAttribute("data-collapsed",R?"true":"false")}function Ft(k){var R=Re("button","padding:5px 14px;background:#1f6f3f;color:#fff;border:none;border-radius:4px;cursor:pointer;font:600 0.78rem/1 system-ui,sans-serif;",k);return R.setAttribute("data-role","cell-run"),R}function cn(k){var R={cell:k,els:{},editor:null,canvas:null,chart:null},P=Re("div","margin:10px 0;border:1px solid #1b1b1b;border-radius:6px;overflow:hidden;");P.setAttribute("data-cell-id",k.id||""),P.setAttribute("data-cell-type","markdown"),R.els.card=P;var $=Re("div","padding:2px 10px;");$.className="markdown-body frqtl-md",$.setAttribute("data-theme","dark"),$.setAttribute("data-role","md-view"),$.innerHTML=Fx(k.body),$.title="click or press Enter to edit",$.style.cursor="text";var U=Re("div","display:none;height:180px;margin:8px 10px;border:1px solid #222;border-radius:4px;overflow:hidden;"),H;function he(){if(R.editor){var qe=R.editor.activeFile();if(qe){var nn=k.body;k.body=qe.value,$.innerHTML=Fx(k.body),k.body!==nn&&m()}try{U.innerHTML=""}catch{}R.editor=null,U.style.display="none",$.style.display="",d=!1,H&&(H.innerHTML="✎ Edit",H.title="edit this markdown cell")}}function Ae(){if(!R.editor){R.cell.collapsed&&(R.cell.collapsed=!1,Ie(R)),kt(k.id),d=!0,$.style.display="none",U.style.display="",R.editor=T(U,{showRun:!1}),R.editor.openFile({id:k.id||"md-"+Math.random(),language:"markdown",kind:"math",value:k.body}),R.editor.onRunAdvance(function(qe,nn){if(qe){var N=k.body;k.body=qe.value,k.body!==N&&m()}ht(R,nn||"advance")});try{U.addEventListener("keydown",function(qe){qe.key==="Escape"&&(qe.stopPropagation(),he())})}catch{}H&&(H.innerHTML="✓ Done",H.title="finish editing (Esc)")}}R.openEditor=Ae,R.closeEditor=he,$.addEventListener("click",Ae),$.addEventListener("dblclick",Ae);var Ve=Re("div","display:flex;align-items:center;gap:8px;padding:5px 10px;background:#141414;border-bottom:1px solid #1b1b1b;"),Qe=Re("div","");Qe.appendChild($),Qe.appendChild(U);var Be=fe(R,[Qe]);Ve.appendChild(Be),Ve.appendChild(Re("span","font:600 0.62rem/1 ui-monospace,monospace;color:#777;text-transform:uppercase;letter-spacing:0.06em;","markdown"));var Ce=Re("div","flex:1;");return Ve.appendChild(Ce),H=Re("button","flex:0 0 auto;padding:3px 9px;background:#1e1e1e;color:#bbb;border:1px solid #333;border-radius:4px;cursor:pointer;font:0.7rem/1 system-ui,sans-serif;","✎ Edit"),H.setAttribute("data-role","md-edit"),H.title="edit this markdown cell",H.addEventListener("click",function(qe){qe.stopPropagation(),R.editor?he():Ae()}),Ve.appendChild(H),P.appendChild(Ve),P.appendChild(Qe),Ie(R),_n(R),R}function Xe(k){var R=de(k),P={cell:k,els:{card:R.card,statusBadge:R.statusBadge},editor:null,canvas:null,chart:null},$=Re("span","font:600 0.6rem/1 ui-monospace,monospace;padding:3px 7px;border-radius:3px;background:#13202b;color:#7fc4ff;display:none;");$.setAttribute("data-role","backend-badge"),R.header.insertBefore($,R.statusBadge),P.els.backendBadge=$;var U=Re("div","height:150px;border-bottom:1px solid #1d1d1d;");R.card.appendChild(U),P.editor=T(U),P.editor.openFile({id:k.id,language:"javascript",kind:k.lane==="frqtl"?"frqtl":"math",value:k.body});var H=Re("div","display:flex;align-items:center;gap:8px;padding:6px 10px;background:#0e0e0e;"),he=Ft("Run");he.addEventListener("click",function(){kt(k.id),ht(P,"inplace")}),H.appendChild(he),P.els.runBtn=he,k.in&&k.in.length&&H.appendChild(Re("span","font:0.68rem/1 ui-monospace,monospace;color:#777;","in: "+k.in.join(", "))),k.out&&k.out.length&&H.appendChild(Re("span","font:0.68rem/1 ui-monospace,monospace;color:#777;","out: "+k.out.join(", "))),R.card.appendChild(H);var Ae=Re("div","max-height:320px;overflow:auto;background:#0b0b0b;border-top:1px solid #1d1d1d;");P.els.output=Ae,R.card.appendChild(Ae),P.output=B(Ae),P.editor.onRun(function(){kt(k.id),ht(P,"inplace")}),P.editor.onRunAdvance(function(Ve,Qe){kt(k.id),ht(P,Qe||"advance")}),P.editor.onContentChange(m);try{U.addEventListener("focusin",function(){kt(k.id),d=!0}),U.addEventListener("focusout",function(){u===k.id&&(d=!1)})}catch{}return R.header.insertBefore(fe(P,[U,H,Ae]),R.header.firstChild),Ie(P),_n(P),P}function un(k){var R=de(k),P={cell:k,els:{card:R.card,statusBadge:R.statusBadge},editor:null,canvas:null,chart:null};if(k.name){var $=Re("span","font:0.62rem/1 ui-monospace,monospace;color:#7fc4ff;",k.name);R.header.insertBefore($,R.statusBadge)}R.statusBadge.textContent="module";var U=Re("div","height:220px;border-top:1px solid #1d1d1d;");return R.card.appendChild(U),P.editor=T(U),P.editor.openFile({id:k.name||k.id||"mod-"+Math.random(),language:"javascript",kind:"frqtl",value:k.body}),P.editor.onContentChange(m),R.header.insertBefore(fe(P,[U]),R.header.firstChild),Ie(P),_n(P),P}function Pe(k){var R=de(k),P={cell:k,els:{card:R.card,statusBadge:R.statusBadge},editor:null,realm:null,chart:null,liveChart:null,viewController:null},$=Wn(k),U=An(k),H=Re("div","display:flex;align-items:center;gap:8px;padding:6px 10px;background:#0e0e0e;"),he=Ft($||U?"Render":"Run");if(he.addEventListener("click",function(){kt(k.id),ht(P,"inplace")}),P.els.runBtn=he,H.appendChild(he),!$&&!U){var Ae=Re("button","padding:5px 14px;background:#2a2a2a;color:#ddd;border:1px solid #333;border-radius:4px;cursor:pointer;font:600 0.78rem/1 system-ui,sans-serif;","Stop");Ae.disabled=!0,Ae.addEventListener("click",function(){P.realm&&P.realm.handle.stop()}),P.els.stopBtn=Ae;var Ve=Re("button","padding:5px 14px;background:#2a2a2a;color:#ddd;border:1px solid #333;border-radius:4px;cursor:pointer;font:600 0.78rem/1 system-ui,sans-serif;","Step");Ve.disabled=!0,Ve.addEventListener("click",function(){P.realm&&P.realm.handle.step()}),P.els.stepBtn=Ve,H.appendChild(Ae),H.appendChild(Ve)}else $&&k.spec?H.appendChild(Re("span","font:0.68rem/1 ui-monospace,monospace;color:#777;","spec: "+k.spec)):U&&k.module&&H.appendChild(Re("span","font:0.68rem/1 ui-monospace,monospace;color:#777;","view: "+k.module));k.bind&&H.appendChild(Re("span","font:0.68rem/1 ui-monospace,monospace;color:#777;","binds: "+k.bind)),U&&k.in&&k.in.length&&H.appendChild(Re("span","font:0.68rem/1 ui-monospace,monospace;color:#777;","in: "+k.in.join(", "))),R.card.appendChild(H);var Qe=$||U?"padding:10px;background:#0b0b0b;":"width:480px;max-width:100%;height:480px;margin:0 auto;background:#000;",Be=Re("div",Qe);if(P.els.realmHost=Be,U){Be.setAttribute("style","display:flex;flex-direction:column;gap:6px;padding:10px;background:#0b0b0b;");var Ce=Re("div","width:100%;min-height:0;"),qe=Re("div","min-height:48px;background:#0b0b0b;");return qe.setAttribute("data-role","view-mount"),Be.appendChild(Ce),Be.appendChild(qe),P.els.gfxHost=Ce,P.els.viewMount=qe,R.card.appendChild(Be),R.header.insertBefore(fe(P,[H,Be]),R.header.firstChild),Ie(P),_n(P),P}var nn=!$&&!!k.liveChart;if(nn){Be.setAttribute("style","width:480px;max-width:100%;margin:0 auto;display:flex;flex-direction:column;background:#000;");var N=Re("div","width:480px;max-width:100%;height:480px;background:#000;"),K=Re("div","max-height:240px;padding:8px;background:#0b0b0b;");K.setAttribute("data-role","live-chart-host"),Be.appendChild(N),Be.appendChild(K),P.els.gfxHost=N,P.els.liveChartHost=K}else P.els.gfxHost=Be;return R.card.appendChild(Be),R.header.insertBefore(fe(P,[H,Be]),R.header.firstChild),Ie(P),_n(P),P}function Mt(){if(!s||S)return Promise.resolve(null);S=!0,E&&(E.disabled=!0),C&&(C.style.color="#888",C.textContent="running…");for(var k=0;k<l.length;k++){var R=l[k];if(R.editor&&R.cell&&R.cell.type==="js"){var P=R.editor.activeFile();P&&typeof P.value=="string"&&(R.cell.body=P.value)}}je();var $=function(H){var he=c[H];return function(Ae){!he||!he.output||(Ae&&typeof Ae=="object"&&typeof Ae.nodeType=="number"?he.output.node(Ae):typeof Ae=="string"?he.output.line(Ae,"log"):he.output.line(me(Ae),"log"))}},U=function(H){if(!H||H.type!=="canvas"&&H.type!=="chart"&&H.type!=="view")return null;var he=c[H.id];return he?Mn(he).then(function(){var Ae=s?s.getCellState(H.id):null,Ve=!Ae||Ae.status!==br.ERROR;return Ve?{ok:!0}:{ok:!1,error:'realm cell "'+H.id+'" failed to start.'}}):Promise.resolve({ok:!1,error:'no render record for realm cell "'+H.id+'"'})};return ee(),s.runAll({displayFor:$,runner:U}).then(function(H){return C&&(H&&H.ok?(C.style.color="#7ee2a8",C.textContent="all "+H.total+" cells OK"):H&&(C.style.color="#ff8a8a",C.textContent='STOPPED at cell "'+H.failedCellId+'" ('+H.ran+" of "+H.total+") — "+(H.error||"error"))),H}).catch(function(H){return C&&(C.style.color="#ff8a8a",C.textContent="Run All failed: "+(H&&H.message?H.message:String(H))),null}).finally(function(){ce(),L=null,S=!1,E&&(E.disabled=!1)})}function Wt(){ke(),ce(),St(),u=null,d=!1;var k=h;if(h=!1,k)for(var R=0;R<g.length;R++)try{g[R](!1)}catch{}if(x&&(Ee.off("notebook:cellstate",x),x=null),w&&(Ee.off("notebook:runall",w),w=null),y){try{y()}catch{}y=null}for(var P=0;P<l.length;P++){var $=l[P];if($.editor){if(typeof $.editor.dispose=="function")try{$.editor.dispose()}catch{}$.editor=null}if($.output&&typeof $.output.dispose=="function"){try{$.output.dispose()}catch{}$.output=null}}s&&(s.dispose(),s=null),a=null,l=[],c=Object.create(null),L=null,S=!1,E&&(E.disabled=!1),C&&(C.textContent=""),F.innerHTML=""}function Dn(k){var R=k&&k.message?k.message:String(k);jz.error("[NotebookPane] load failed: "+R),r&&r("error","notebook load failed: "+R),Wt();var P=Re("pre","margin:0;padding:12px 14px;background:#2a0c0c;color:#ff8a8a;border:1px solid #5a1a1a;border-radius:4px;font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;white-space:pre-wrap;word-break:break-word;",`Notebook load failed — nothing from this document is shown.
160
+
161
+ `+R);return P.setAttribute("data-role","notebook-load-error"),F.appendChild(P),k}function lt(k){return new Promise(function(R,P){try{Wt();var $=$R(k);a=$,s=new GR($,{runtime:ui,bus:Ee}),$.cells.forEach(function(U){var H;switch(U.type){case"markdown":H=cn(U);break;case"js":H=Xe(U);break;case"module":H=un(U);break;case"canvas":H=Pe(U);break;case"chart":H=Pe(U);break;case"view":H=Pe(U);break;default:H={cell:U,els:{},editor:null,canvas:null,chart:null},H.els.card=Re("pre","color:#ff8a8a;padding:8px;",'[unknown cell type "'+U.type+'"]')}l.push(H),U.id&&(c[U.id]=H),F.appendChild(H.els.card)}),x=function(U){U&&U.cellId&&re(U.cellId,U.status)},Ee.on("notebook:cellstate",x),w=function(U){if(U&&U.phase==="running"){L=U.cellId;var H=c[U.cellId];H&&H.output&&typeof H.output.clear=="function"&&H.output.clear(),C&&S&&(C.style.color="#7fc4ff",C.textContent="running cell "+U.index+" of "+U.total+" ("+U.cellId+")")}},Ee.on("notebook:runall",w),y=st.subscribe(function(){W()}),W(),ye(),d=!1,l.length&&l[0].cell&&kt(l[0].cell.id),R()}catch(U){P(Dn(U))}})}function we(k){return fetch(k).then(function(R){if(!R.ok)throw new Error("[NotebookPane] failed to fetch notebook "+k+": HTTP "+R.status);return R.text()}).catch(function(R){throw Dn(R)}).then(function(R){return lt(R)})}function pt(){Wt(),g=[]}return{load:lt,loadUrl:we,destroy:pt,runAll:Mt,setMath:function(k){W()},getBinding:function(k){return s?s.getBinding(k):null},serialize:function(){if(!a)throw new Error("[NotebookPane] serialize() called before any notebook was loaded.");for(var k=0;k<l.length;k++){var R=l[k];if(R.editor){var P=R.editor.activeFile();P&&typeof P.value=="string"&&(R.cell.body=P.value)}}return YR(a)},isDirty:function(){return h},onDirtyChange:function(k){typeof k=="function"&&g.push(k)}}}typeof window<"u"&&(window.NotebookPane=Rz);function Lz({notebookBase:e,monacoBaseUrl:t,markdownCssUrl:n,mathUrls:r,initialNotebook:i,onLinkSelect:o,frqtlEngine:s,frqtlMode:a,audience:l,deepLinkRefusal:c}){var[u,d]=j.useState(null),[f,h]=j.useState(null),[g,m]=j.useState(null),[x,y]=j.useState(c||null),[b,w]=j.useState(""),E=j.useRef(null),C=j.useRef(null),S=j.useRef(null),M=j.useRef(e||"/notebooks");j.useEffect(function(){var F=e||"/notebooks";M.current=F;var te=F+"/notebooks.json";fetch(te).then(function(W){if(!W.ok)throw new Error("[NotebookBrowser] notebook index fetch failed ("+W.status+"): "+te);return W.json()}).then(function(W){if(!W||!Array.isArray(W.notebooks))throw new Error("[NotebookBrowser] notebooks.json has no notebooks[] array (FAIL-LOUD): "+te);d(W)}).catch(function(W){h(W.message)})},[]),j.useEffect(function(){var F=E.current;if(!(!F||C.current)){if(typeof window.NotebookPane>"u"){y("[NotebookBrowser] NotebookPane not loaded.");return}return C.current=new window.NotebookPane({mountEl:F,monacoBaseUrl:t,markdownCssUrl:n,frqtl:{engine:s||"wasm",mode:a},onConsole:function(te,W){w((te==="error"?"⚠ ":"")+W)}}),typeof window<"u"&&l!=="public"&&(window.__frqtlNotebookPane=C.current),ui.ensureMath({mathSdkUrl:r&&r.mathSdkUrl,mathWasmUrl:r&&r.mathWasmUrl,mathWasmModuleUrl:r&&r.mathWasmModuleUrl,mathBackend:r&&r.mathBackend}).then(function(te){S.current=te,C.current&&C.current.setMath(te)}).catch(function(te){y("[NotebookBrowser] math seam init failed: "+(te&&te.message?te.message:String(te)))}),function(){try{C.current&&C.current.destroy&&C.current.destroy()}catch{}C.current=null}}},[]),j.useEffect(function(){if(!(!u||g)&&!c){if(i){var F=u.notebooks.find(function(W){return W.id===i});if(F){L(F);return}y('Deep link error: unknown notebook "'+i+'" — not in the served notebook catalog (notebooks.json). Pick one from the sidebar.');return}var te;try{te=IT(u)}catch(W){console.error(W),y(W.message);return}L(te)}},[u]);function L(F){if(C.current){m(F.id),typeof o=="function"&&o("notebook",F.id),y(null),w(""),S.current&&C.current.setMath(S.current);var te=M.current+"/"+F.file;C.current.loadUrl(te)}}var T=[];if(u&&Array.isArray(u.notebooks)){var V={},G=[];u.notebooks.forEach(function(F){var te=F.group||"Other";V[te]||(V[te]=[],G.push(te)),V[te].push(F)}),T=G.map(function(F){return{name:F,entries:V[F]}})}return v.jsxs("div",{style:En.root,children:[v.jsxs("div",{style:En.sidebar,children:[v.jsx("div",{style:En.panelTitle,children:"Notebooks"}),f&&v.jsx("div",{style:En.errBanner,children:f}),!u&&!f&&v.jsx("div",{style:En.emptyMsg,children:"loading…"}),u&&T.map(function(F){return v.jsxs("div",{children:[v.jsx("div",{style:En.groupLabel,children:F.name}),F.entries.map(function(te){return v.jsx("button",{style:Object.assign({},En.catalogItem,te.id===g?En.catalogItemActive:{}),onClick:function(){L(te)},title:te.id,children:te.title},te.id)})]},F.name)})]}),v.jsxs("div",{style:En.notebookCol,children:[v.jsxs("div",{style:En.toolbar,children:[v.jsx("span",{style:En.projectName,children:g?(u&&u.notebooks.find(function(F){return F.id===g})||{}).title||g:"Select a notebook"}),b&&v.jsx("span",{style:En.statusLine,children:b})]}),x&&v.jsx("div",{style:En.errBanner,children:x}),!g&&!x&&v.jsx("div",{style:En.placeholder,children:"Pick a notebook from the sidebar. Each cell runs on demand — nothing auto-triggers on load."}),v.jsx("div",{style:En.paneHost,ref:E})]})]})}var En={root:{display:"flex",flexDirection:"row",height:"100%",overflow:"hidden",background:"#111",color:"#aaa",fontFamily:"ui-monospace,Menlo,Consolas,monospace"},sidebar:{width:"220px",flexShrink:0,borderRight:"1px solid #222",display:"flex",flexDirection:"column",overflowY:"auto"},panelTitle:{font:"700 10px ui-monospace,Menlo,Consolas,monospace",color:"#555",padding:"8px 8px 4px",textTransform:"uppercase",letterSpacing:"0.5px",flexShrink:0},groupLabel:{font:"9px ui-monospace,Menlo,Consolas,monospace",color:"#444",padding:"6px 8px 2px",textTransform:"uppercase",letterSpacing:"0.3px"},catalogItem:{display:"block",width:"100%",textAlign:"left",padding:"4px 8px",font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#777",background:"none",border:"none",borderBottom:"1px solid #1a1a1a",cursor:"pointer",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},catalogItemActive:{color:"#7ec8e3",background:"#161622"},notebookCol:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},toolbar:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",borderBottom:"1px solid #222",flexShrink:0,background:"#111"},projectName:{font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#888",flexShrink:0},statusLine:{font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#555",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},errBanner:{background:"#2a1111",color:"#cc4444",font:"10px ui-monospace,Menlo,Consolas,monospace",padding:"4px 8px",borderBottom:"1px solid #3a1111",flexShrink:0},placeholder:{font:"11px ui-monospace,Menlo,Consolas,monospace",color:"#444",padding:"16px",fontStyle:"italic"},paneHost:{flex:1,overflow:"auto",minHeight:0},emptyMsg:{font:"10px ui-monospace,Menlo,Consolas,monospace",color:"#333",padding:"6px 8px",fontStyle:"italic"}},Mo={TABS:"tabs",STACK:"stack",SPLIT2:"split-2",SPLIT3:"split-3"},lu={IDE:"ide",SIM:"sim",NOTEBOOK:"notebook"},a0={ide:{editor:"left-top",console:"left-bot",graphics:"right-top",data:"right-bot"},sim:{"sim-nav":"full",graphics:"right-top",console:"right-bot",data:"right-bot",editor:"sidebar"},notebook:{notebook:"full",graphics:"right-top",console:"right-bot",data:"right-bot",editor:"sidebar"}},et=Object.create(null),mn=null,Oi=null,qr=null,ac=Mo.TABS,_v=null,Ta=null,hl=null,Xn=null,Br=null,di=null,ni=null,pl=null,fi=null,Bo=null,Ji=null,Rr=null,hi=null;function Az(e){if(mn&&mn.parentNode&&mn.parentNode.removeChild(mn),et=Object.create(null),hl=null,mn=document.createElement("div"),mn.id="pane-host-root",qr=document.createElement("div"),qr.className="ph-tabbar",mn.appendChild(qr),Oi=document.createElement("div"),Oi.className="ph-body",mn.appendChild(Oi),Xn=l0("left"),pl=cu("left-top"),Bo=c0(),fi=cu("left-bot"),Xn.appendChild(pl),Xn.appendChild(Bo),Xn.appendChild(fi),di=Pz(),Br=l0("right"),Ji=cu("right-top"),hi=c0(),Rr=cu("right-bot"),Br.appendChild(Ji),Br.appendChild(hi),Br.appendChild(Rr),Oi.appendChild(Xn),Oi.appendChild(di),Oi.appendChild(Br),ni=document.createElement("div"),ni.className="ph-fs-overlay",ni.style.display="none",mn.appendChild(ni),e.appendChild(mn),Qh(di,"horizontal",Xn,Br),Qh(Bo,"vertical",pl,fi),Qh(hi,"vertical",Ji,Rr),typeof ResizeObserver<"u"){var t=new ResizeObserver(zz);t.observe(Oi)}}function l0(e){var t=document.createElement("div");return t.className="ph-col ph-col--"+e,t}function cu(e){var t=document.createElement("div");return t.className="ph-row ph-row--"+e,t}function Pz(){var e=document.createElement("div");return e.className="ph-divider ph-divider--v",e.setAttribute("role","separator"),e.setAttribute("aria-orientation","vertical"),e}function c0(){var e=document.createElement("div");return e.className="ph-divider ph-divider--h",e.setAttribute("role","separator"),e.setAttribute("aria-orientation","horizontal"),e}function Mz(e){if(!e||!e.id)throw new Error("[PaneHost] register: opts.id required");if(!e.mount)throw new Error("[PaneHost] register: opts.mount required");if(et[e.id])throw new Error('[PaneHost] register: duplicate id "'+e.id+'"');var t=document.createElement("div");t.className="ph-pane-content ph-pane-content--"+e.id,t.setAttribute("data-pane-id",e.id);var n=document.createElement("div");n.className="ph-slot ph-slot--"+e.id,n.setAttribute("data-slot-pane-id",e.id),n.appendChild(t);var r={show:function(){ro(e.id)},hide:function(){Md(e.id)},resize:function(o,s){_E(e.id,o,s)}},i={id:e.id,title:e.title,kind:e.kind||null,opts:e,el:t,slotEl:n,tabBtn:null,handle:r,mounted:!1};et[e.id]=i,Xo(i,"right-top");try{e.mount(t),i.mounted=!0}catch(o){console.error('[PaneHost] mount("'+e.id+'") threw:',o)}return Tz(i),r}function Tz(e){var t=document.createElement("button");t.className="ph-tab",t.textContent=e.title,t.setAttribute("data-pane-id",e.id),t.setAttribute("type","button"),t.addEventListener("click",function(){bE(e.id)}),qr.appendChild(t),e.tabBtn=t}function mE(e){for(var t=Object.keys(et),n=0;n<t.length;n++){var r=et[t[n]];r.tabBtn&&r.tabBtn.classList.toggle("active",t[n]===e)}var i=document.getElementById("pane-host-tabbar");i&&i.querySelectorAll("[data-pane-id]").forEach(function(o){o.classList.toggle("active",o.getAttribute("data-pane-id")===e)})}function Xo(e,t){var n=Dz(t);n&&e.slotEl.parentNode!==n&&n.appendChild(e.slotEl)}function Dz(e){switch(e){case"left-top":return pl;case"left-bot":return fi;case"right-top":return Ji;case"right-bot":return Rr;case"sidebar":return Xn;case"full":return Oi;default:return Ji}}function ro(e){var t=et[e];t&&(t.slotEl.style.display="",_v=e,Dd(t.opts.onShow),ua("pane:show",{paneId:e}),kv(e))}function Md(e){var t=et[e];t&&(t.slotEl.style.display="none",Dd(t.opts.onHide),ua("pane:hide",{paneId:e}))}function Iz(e){ac=e,gE(),ua("pane:layout",{mode:e}),oa()}function gE(){switch(ac){case Mo.TABS:u0();break;case Mo.STACK:Fz();break;case Mo.SPLIT2:Nz();break;case Mo.SPLIT3:yE();break;default:u0()}}function u0(){mn.className="ph-mode-tabs",qr.style.display="",Xn.style.display="none",di.style.display="none",Br.style.cssText="flex:1;",Rr.style.display="none",hi.style.display="none",Ji.style.cssText="flex:1;";for(var e=Object.keys(et),t=0;t<e.length;t++)Xo(et[e[t]],"right-top");var n=_v||(e.length?e[0]:null);n&&vE(n)}function vE(e){for(var t=Object.keys(et),n=0;n<t.length;n++)t[n]===e?ro(t[n]):Md(t[n]);_v=e,mE(e)}function Fz(){mn.className="ph-mode-stack",qr.style.display="none",Xn.style.display="none",di.style.display="none",Br.style.cssText="flex:1;flex-direction:column;",Ji.style.cssText="flex:1;",Rr.style.display="",hi.style.display="";for(var e=Object.keys(et),t=0;t<e.length;t++)Xo(et[e[t]],t<Math.ceil(e.length/2)?"right-top":"right-bot"),ro(e[t])}function Nz(){mn.className="ph-mode-split-2",qr.style.display="none",Xn.style.display="",Xn.style.cssText="flex:1;",di.style.display="",Br.style.cssText="flex:1;",fi.style.display="",Bo.style.display="",Rr.style.display="",hi.style.display="";for(var e=Object.keys(et),t=0;t<e.length;t++){var n=Td(e[t])||(t%2===0?"left-top":"right-top");Xo(et[e[t]],n),ro(e[t])}}function yE(){mn.className="ph-mode-split-3",qr.style.display="none",Xn.style.display="",Xn.style.cssText="flex:0 0 38%;",di.style.display="",Br.style.cssText="flex:1;",pl.style.cssText="flex:2;",fi.style.display="",fi.style.cssText="flex:1;max-height:220px;",Bo.style.display="",Ji.style.cssText="flex:3;",Rr.style.display="",Rr.style.cssText="flex:1;max-height:200px;",hi.style.display="";for(var e=Object.keys(et),t=0;t<e.length;t++){var n=Td(e[t])||"right-top";Xo(et[e[t]],n),ro(e[t])}}function bE(e){et[e]&&(ac===Mo.TABS?vE(e):(ro(e),mE(e)),ua("pane:focus",{paneId:e}))}function xE(e,t){var n=et[e];if(n)if(t){Ta&&xE(Ta,!1),Ta=e;for(var r=Object.keys(et),i=0;i<r.length;i++)r[i]!==e&&(et[r[i]].slotEl.style.display="none");ni.innerHTML="",ni.appendChild(n.el),ni.style.display="",n.slotEl.style.display="none",Dd(n.opts.onFullscreen,!0),kv(e)}else{if(Ta!==e)return;Ta=null,n.slotEl.appendChild(n.el),ni.style.display="none",ni.innerHTML="",gE(),Dd(n.opts.onFullscreen,!1),oa()}}function wE(e){switch(hl=e,e){case lu.IDE:ac=Mo.SPLIT3,yE();break;case lu.SIM:mn.className="ph-mode-sim",di.style.display="none",fi.style.display="none",Bo.style.display="none",Rr.style.display="none",hi.style.display="none",qr.style.display="none";for(var t=Object.keys(et),n=0;n<t.length;n++){var r=t[n],i=Td(r)||"right-top";Xo(et[r],i),i==="full"?(ro(r),et[r].slotEl.style.cssText="position:absolute;inset:0;overflow:hidden;"):Md(r)}break;case lu.NOTEBOOK:mn.className="ph-mode-sim",di.style.display="none",fi.style.display="none",Bo.style.display="none",Rr.style.display="none",hi.style.display="none",qr.style.display="none";for(var o=Object.keys(et),s=0;s<o.length;s++){var a=o[s],l=Td(a)||"right-top";Xo(et[a],l),l==="full"?(ro(a),et[a].slotEl.style.cssText="position:absolute;inset:0;overflow:hidden;"):Md(a)}break;default:console.warn('[PaneHost] unknown preset "'+e+'" — using ide'),wE(lu.IDE);return}ua("pane:layout",{mode:e}),oa()}function Td(e){return!hl||!a0[hl]?null:a0[hl][e]||null}function _E(e,t,n){var r=et[e];if(r){if(typeof r.opts.onResize=="function")try{r.opts.onResize(t,n)}catch{}ua("pane:resize",{paneId:e,w:t,h:n})}}function kv(e){var t=et[e];if(!(!t||t.slotEl.style.display==="none")){var n=t.el.getBoundingClientRect();_E(e,Math.round(n.width),Math.round(n.height))}}function oa(){requestAnimationFrame(function(){for(var e=Object.keys(et),t=0;t<e.length;t++)kv(e[t])})}function zz(){oa()}function Qh(e,t,n,r){var i=!1,o=0,s=0,a=80;e.addEventListener("pointerdown",function(l){i=!0,o=t==="horizontal"?l.clientX:l.clientY,s=t==="horizontal"?n.getBoundingClientRect().width:n.getBoundingClientRect().height,e.setPointerCapture(l.pointerId),e.classList.add("dragging"),l.preventDefault()}),e.addEventListener("pointermove",function(l){if(i){var c=(t==="horizontal"?l.clientX:l.clientY)-o,u=Math.max(a,s+c),d=t==="horizontal"?"width":"height",f=n.parentNode,h=f?f.getBoundingClientRect():null;if(h){var g=t==="horizontal"?h.width:h.height,m=Math.max(a,g-u-e.getBoundingClientRect()[t==="horizontal"?"width":"height"]);n.style.flex="none",n.style[d]=u+"px",r.style.flex="none",r.style[d]=m+"px"}}}),e.addEventListener("pointerup",function(l){i&&(i=!1,e.classList.remove("dragging"),e.releasePointerCapture(l.pointerId),oa())}),e.addEventListener("pointercancel",function(){i=!1,e.classList.remove("dragging"),oa()})}function Dd(e){if(typeof e=="function"){var t=Array.prototype.slice.call(arguments,1);try{e.apply(null,t)}catch{}}}function ua(e,t){Ee.emit(e,t)}var Bz={_init:Az,register:Mz,layout:Iz,focus:bE,fullscreen:xE,preset:wE,_panes:function(){return et},_mode:function(){return ac}};typeof window<"u"&&(window.PaneHost=Bz);function kE(){const e=j.useCallback(n=>st.subscribe(n),[]),t=j.useCallback(()=>{let n="none";try{n=st.active().id}catch{}return st.registeredIds().join("|")+"@"+n},[]);j.useSyncExternalStore(e,t,t)}function Uz({onClick:e}){kE();const t=st.registeredIds(),n=(()=>{try{return st.active().id}catch{return"none"}})(),r=t.length>=2?t.map(i=>i===n?`[${i}]`:i).join(" | "):n;return v.jsx("button",{id:"frqtl-ide-engine-badge",className:"ph-toolbar-btn",type:"button",title:"Math backends: "+t.join(", ")+" — active: "+n+". Click to open Math Bench.",onClick:e,style:{fontSize:"0.62rem",color:"#3a3a3a",letterSpacing:"0.3px",cursor:"pointer"},children:r})}function Hz(){kE();const e=st.registeredIds(),t=(()=>{try{return st.active().id}catch{return"none"}})();function n(r){const i=r.target.value;if(!(!i||i===t))try{st.select(i)}catch(o){console.error("[FraqtlIde] Math backend switch failed:",o)}}return e.length<2?v.jsx("span",{id:"frqtl-ide-backend-selector",style:{fontSize:"0.62rem",color:"#3a3a3a",letterSpacing:"0.3px",padding:"2px 4px"},title:"Math backend (only js-reference loaded)",children:t}):v.jsx("select",{id:"frqtl-ide-backend-selector",className:"ph-toolbar-select",value:t,onChange:n,title:"Select math backend (internal IDE)",style:{background:"#1a1a1a",color:t==="wasm-math"?"#7ec8e3":"#888",border:"1px solid #2a2a2a",fontSize:"0.65rem",padding:"2px 4px",cursor:"pointer",borderRadius:"2px"},children:e.map(r=>v.jsx("option",{value:r,children:r},r))})}function Wz({engine:e="wasm",mode:t="dev-core",mathSdkUrl:n,onLinkChange:r,audience:i,...o}){const s=tf(i),a=j.useRef(null),[l]=j.useState(HL);j.useEffect(function(){VL(a.current,l)},[l]);const[c]=j.useState(function(){return YL(o)}),[u,d]=j.useState(function(){return pd(c,s)}),[f,h]=j.useState(function(){return uS(c)}),[g,m]=j.useState(function(){return GL(c,pd(c,s))}),x=j.useRef(null),[y]=j.useState(function(){return ST(document)}),[b,w]=j.useState({bag:null,error:null}),E=j.useRef(!1);j.useEffect(function(){const ie=y.load(u);if(!ie)return;let me=!0;return ie.then(function(xe){me&&w({bag:xe,error:null})},function(xe){if(me&&w({bag:null,error:xe}),!E.current)throw E.current=!0,xe}),function(){me=!1}},[u,y]);const[C]=j.useState(function(){return Hg(window)}),S=j.useRef(null),M=j.useRef(null);M.current=f[at.compare]||null,j.useEffect(function(){const ie=x.current,me=M.current;if(u===at.compare&&me&&me.initialWalkthrough)return ie.dataset.runOnceDeferred="gym-scene-card",function(){delete ie.dataset.runOnceDeferred};if(!bL(s)){const ge=Hs(ie,Bg(u),"not-offered-audience","audience "+s);return function(){ge.close()}}if(!Ug[u])throw new Error('[FraqtlIde] public audience reached preset "'+u+'", which has no PRESET_EXPLAINERS row — gateForAudience should make this unreachable.');const xe=Ml(ie,wL(u,{onPhone:C}),{covers:S.current});return function(){xe.close()}},[u,s,C]);const L=j.useCallback(function(ie,me){h(function(xe){return JL(xe,u,ie,me)})},[u]),T=j.useCallback(function(){h(function(ie){return QL(ie,at.compare,at.author)}),re(at.author)},[s]),V=j.useRef(r);V.current=r;const G=f[u];j.useEffect(function(){typeof V.current=="function"&&V.current(cS(G,u))},[u,G]);const F=j.useMemo(()=>Dg({mode:t,engine:e,mathSdkUrl:n}),[t,e,n]),te=F.resolve("experiments/").replace(/\/$/,""),W=F.resolve("assets/vendor/monaco/vs"),Y=F.resolve("assets/vendor/github-markdown-css/github-markdown.css");j.useEffect(()=>{if(!a.current)return;const ie=a.current.querySelector("#frqtl-ide-pane-body");!ie||!window.PaneHost||(window.PaneHost._init(ie),ui.init({engine:e,mathSdkUrl:n,_routerMathSdkUrl:F.mathSdkUrl,_routerMathWasmUrl:F.mathWasmUrl,_routerMathWasmModuleUrl:F.mathWasmModuleUrl,_routerMathBackend:F.mathBackend,_router:F}).then(function(){console.log("[FraqtlIde] Runtime initialized")}).catch(function(me){console.error("[FraqtlIde] Runtime init error:",me)}))},[]);function re(ie){const me=qk(ie,s);me!==u&&m(null),d(me)}function pe(ie){return b.error?{panelStyle:{display:"none"},overlay:v.jsx("div",{"data-role":"ide-roster-error","data-egpt-boot-error":"1",style:{position:"absolute",inset:0,background:"#1a0000",color:"#ff6b6b",font:"13px/1.55 ui-monospace,Menlo,Consolas,monospace",padding:"22px",whiteSpace:"pre-wrap",overflow:"auto",borderTop:"2px solid #b6161c"},children:"IDE BOOT FAILED — "+(Pl[ie]||ie)+` reads this site's scene roster, and it did not load.
162
+
163
+ `+(b.error&&b.error.message?b.error.message:String(b.error))+`
164
+
165
+ The surface is intentionally not mounted.`})}:b.bag?null:{panelStyle:{display:"none"},overlay:v.jsx("div",{"data-role":"ide-roster-loading",style:{padding:"12px",color:"#886"},children:"Loading the scene roster…"})}}function B(ie){if(Wk(ie)){const me=pe(ie);if(me)return me}switch(ie){case"author":return{panelStyle:{display:"none"},overlay:v.jsx("div",{style:{position:"absolute",inset:0},children:v.jsx(EM,{experimentBase:te,monacoBaseUrl:W,resolveScript:F.resolve,roster:b.bag,...f[ie],onLinkSelect:L,deepLinkRefusal:g})})};case"codec":return{panelStyle:{display:"none"},overlay:v.jsx("div",{style:{position:"absolute",inset:0},children:v.jsx(sT,{mathSdkUrl:F.mathSdkUrl,mathWasmUrl:F.mathWasmUrl,mathWasmModuleUrl:F.mathWasmModuleUrl,mathBackend:F.mathBackend,monacoBaseUrl:W,...f[ie],deepLinkRefusal:g,onLinkSelect:L})})};case"ide":return{panelStyle:{display:"none"},overlay:v.jsx("div",{style:{position:"absolute",inset:0},children:v.jsx(Lz,{notebookBase:F.notebookBase,monacoBaseUrl:W,markdownCssUrl:Y,mathUrls:{mathSdkUrl:F.mathSdkUrl,mathWasmUrl:F.mathWasmUrl,mathWasmModuleUrl:F.mathWasmModuleUrl,mathBackend:F.mathBackend},...f[ie],deepLinkRefusal:g,onLinkSelect:L,frqtlEngine:e,frqtlMode:t,audience:s})})};case"bench":return{panelStyle:{display:"none"},overlay:v.jsx("div",{style:{position:"absolute",inset:0},children:v.jsx(AM,{mathSdkUrl:F.mathSdkUrl,mathWasmUrl:F.mathWasmUrl,mathWasmModuleUrl:F.mathWasmModuleUrl,mathBackend:F.mathBackend,deepLinkRefusal:g})})};case"compare":return{panelStyle:{display:"none"},overlay:v.jsx("div",{style:{position:"absolute",inset:0},children:v.jsx(kT,{experimentBase:te,router:F,roster:b.bag,monacoBaseUrl:W,...f[ie],deepLinkRefusal:g,onLinkSelect:L,onOpenInStudio:T})})};default:throw new Error('[FraqtlIde] renderPresetSurface: unrecognized preset "'+ie+'" — normalizePreset() should make this unreachable. (FAIL-LOUD — no PaneHost fallback exists; add a case for this preset.)')}}const{panelStyle:ee,overlay:ce}=B(u),ve=typeof document<"u"?ET(document):null,[ke,je]=j.useState(!1);return v.jsxs("div",{id:"pane-host-app",ref:a,style:{display:"flex",flexDirection:"column",height:"100%",position:"relative"},children:[v.jsxs("div",{ref:S,"data-role":"ide-explainer-covered",style:{display:"contents"},children:[v.jsxs("div",{id:"frqtl-ide-toolbar",style:{display:"flex",alignItems:"center",padding:"4px 8px",background:"#111",borderBottom:"1px solid #222",flexShrink:0},children:[ve?v.jsx("a",{href:ve,"data-role":"frqtl-brand-home",title:"Home",onMouseEnter:()=>je(!0),onMouseLeave:()=>je(!1),onFocus:()=>je(!0),onBlur:()=>je(!1),style:{fontSize:"0.7rem",fontWeight:700,letterSpacing:"1px",marginRight:"6px",color:ke?"#7ec8e3":"#888",cursor:"pointer",textDecoration:"underline",textDecorationStyle:ke?"solid":"dotted",textUnderlineOffset:"3px"},children:"FRQTL"}):v.jsx("span",{"data-role":"frqtl-brand",style:{fontSize:"0.7rem",fontWeight:700,letterSpacing:"1px",color:"#444",marginRight:"6px"},children:"FRQTL"}),v.jsx("div",{className:"ph-toolbar-sep"}),Ng(s).map(ie=>v.jsx("button",{className:"ph-toolbar-btn"+(u===ie?" active":""),type:"button",onClick:()=>re(ie),children:Pl[ie]||ie},ie)),v.jsx("div",{className:"ph-toolbar-sep"}),v.jsx("div",{style:{flex:1}}),v.jsx(DT,{}),s!=="public"&&v.jsxs(v.Fragment,{children:[v.jsx(Hz,{}),v.jsx("div",{className:"ph-toolbar-sep"}),v.jsx(Uz,{onClick:()=>re("bench")})]})]}),v.jsx("div",{id:"pane-host-tabbar"}),v.jsxs("div",{style:{flex:1,position:"relative",overflow:"hidden"},children:[v.jsx("div",{id:"frqtl-ide-pane-body",style:{position:"absolute",inset:0,overflow:"hidden",...ee}}),ce]})]}),v.jsx("div",{ref:x,"data-run-once-host":"",style:{position:"absolute",inset:0,zIndex:1e4,pointerEvents:"none"}})]})}function Vz({engine:e}){return v.jsx("div",{"data-role":"archived-engine-error","data-egpt-boot-error":"1",style:{position:"fixed",inset:0,zIndex:99999,background:"#1a0000",color:"#ff6b6b",font:"13px/1.55 ui-monospace,Menlo,Consolas,monospace",padding:"22px",whiteSpace:"pre-wrap",overflow:"auto",borderTop:"2px solid #b6161c"},children:"ENGINE BOOT FAILED — engine="+e+`
166
+
167
+ JS reference engine archived — FRQTL is WASM-only. Remove ?engine=`+e+` (the only FRQTL physics engine is the compiled Rust/WASM engine).
168
+
169
+ The IDE is intentionally not mounted. The requested engine is not a runtime
170
+ backend, and the shell did NOT fall back to a different engine.
171
+
172
+ Open this surface on the WASM engine instead (drop the ?engine= param, or use
173
+ ?engine=wasm).`})}const SE=new URLSearchParams(window.location.search),Fm=SE.get("engine")||"wasm",EE={mode:"static",audience:"public"};import(new URL(IR,document.baseURI).href);const OE=document.getElementById("root");function qz(e){var t=ZL(window.location.search,e,EE.audience);t!==null&&window.history.replaceState(window.history.state,"",window.location.pathname+(t?"?"+t:"")+window.location.hash)}function $z(){Pg(OE).render(v.jsx(Wz,{engine:Fm,...EE,...aS(SE),onLinkChange:qz}))}Fm!=="wasm"?Pg(OE).render(v.jsx(Vz,{engine:Fm})):$z();export{At as C,v as j,j as r};