@valbuild/ui 0.119.0 → 0.120.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/valbuild-ui.cjs.js +1 -1
- package/dist/valbuild-ui.esm.js +1 -1
- package/package.json +3 -3
- package/server/.tmp/assets/{index-Ba2QpwtQ.js → index-DK4jaz_h.js} +10 -10
- package/server/.tmp/assets/patchsets.worker-D9QWxx6e.js +6 -0
- package/server/.tmp/assets/{patchsets.worker-Da9KaH1a.js → validation.worker-B5R1jZ19.js} +3 -3
- package/server/.tmp/index.html +1 -1
- package/server/dist/valbuild-ui-server.cjs.js +4 -4
- package/server/dist/valbuild-ui-server.esm.js +4 -4
- package/server/.tmp/assets/validation.worker-S1NGke8f.js +0 -6
|
@@ -7,9 +7,9 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
7
7
|
Error generating stack: `+e.message+`
|
|
8
8
|
`+e.stack}}var be=Object.prototype.hasOwnProperty,xe=t.unstable_scheduleCallback,Se=t.unstable_cancelCallback,Ce=t.unstable_shouldYield,we=t.unstable_requestPaint,z=t.unstable_now,B=t.unstable_getCurrentPriorityLevel,Te=t.unstable_ImmediatePriority,Ee=t.unstable_UserBlockingPriority,V=t.unstable_NormalPriority,De=t.unstable_LowPriority,Oe=t.unstable_IdlePriority,ke=t.log,Ae=t.unstable_setDisableYieldValue,je=null,Me=null;function Ne(e){if(typeof ke==`function`&&Ae(e),Me&&typeof Me.setStrictMode==`function`)try{Me.setStrictMode(je,e)}catch{}}var Pe=Math.clz32?Math.clz32:Le,Fe=Math.log,Ie=Math.LN2;function Le(e){return e>>>=0,e===0?32:31-(Fe(e)/Ie|0)|0}var Re=256,ze=262144,Be=4194304;function Ve(e){var t=e&42;if(t!==0)return t;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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function He(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ve(n))):i=Ve(o):i=Ve(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ve(n))):i=Ve(o)):i=Ve(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Ue(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function We(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ge(){var e=Be;return Be<<=1,!(Be&62914560)&&(Be=4194304),e}function Ke(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function qe(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Je(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Pe(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Ye(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Ye(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Pe(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Xe(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Pe(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ze(e,t){var n=t&-t;return n=n&42?1:Qe(n),(n&(e.suspendedLanes|t))===0?n:0}function Qe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function $e(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function et(){var e=L.p;return e===0?(e=window.event,e===void 0?32:_p(e.type)):e}function tt(e,t){var n=L.p;try{return L.p=e,t()}finally{L.p=n}}var nt=Math.random().toString(36).slice(2),rt=`__reactFiber$`+nt,it=`__reactProps$`+nt,at=`__reactContainer$`+nt,ot=`__reactEvents$`+nt,st=`__reactListeners$`+nt,ct=`__reactHandles$`+nt,lt=`__reactResources$`+nt,ut=`__reactMarker$`+nt;function dt(e){delete e[rt],delete e[it],delete e[ot],delete e[st],delete e[ct]}function ft(e){var t=e[rt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[at]||n[rt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=mf(e);e!==null;){if(n=e[rt])return n;e=mf(e)}return t}e=n,n=e.parentNode}return null}function pt(e){if(e=e[rt]||e[at]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function mt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function ht(e){var t=e[lt];return t||=e[lt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function gt(e){e[ut]=!0}var _t=new Set,vt={};function yt(e,t){bt(e,t),bt(e+`Capture`,t)}function bt(e,t){for(vt[e]=t,e=0;e<t.length;e++)_t.add(t[e])}var xt=RegExp(`^[: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]*$`),St={},Ct={};function wt(e){return be.call(Ct,e)?!0:be.call(St,e)?!1:xt.test(e)?Ct[e]=!0:(St[e]=!0,!1)}function Tt(e,t,n){if(wt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}}function Et(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Dt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Ot(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function kt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function At(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function jt(e){if(!e._valueTracker){var t=kt(e)?`checked`:`value`;e._valueTracker=At(e,t,``+e[t])}}function Mt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=kt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function Nt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Pt=/[\n"\\]/g;function Ft(e){return e.replace(Pt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function It(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Ot(t)):e.value!==``+Ot(t)&&(e.value=``+Ot(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Rt(e,o,Ot(n)):Rt(e,o,Ot(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Ot(s):e.removeAttribute(`name`)}function Lt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){jt(e);return}n=n==null?``:``+Ot(n),t=t==null?n:``+Ot(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),jt(e)}function Rt(e,t,n){t===`number`&&Nt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function zt(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=``+Ot(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 Bt(e,t,n){if(t!=null&&(t=``+Ot(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Ot(n)}function Vt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(F(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Ot(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),jt(e)}function Ht(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ut=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Wt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Ut.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Gt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Wt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Wt(e,o,t[o])}function Kt(e){if(e.indexOf(`-`)===-1)return!1;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 qt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Jt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Yt(e){return Jt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Xt(){}var Zt=null;function Qt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var $t=null,en=null;function tn(e){var t=pt(e);if(t&&(e=t.stateNode)){var n=e[it]||null;a:switch(e=t.stateNode,t.type){case`input`:if(It(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Ft(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[it]||null;if(!a)throw Error(i(90));It(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Mt(r)}break a;case`textarea`:Bt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&zt(e,!!n.multiple,t,!1)}}}var nn=!1;function rn(e,t,n){if(nn)return e(t,n);nn=!0;try{return e(t)}finally{if(nn=!1,($t!==null||en!==null)&&(xu(),$t&&(t=$t,e=en,en=$t=null,tn(t),e)))for(t=0;t<e.length;t++)tn(e[t])}}function an(e,t){var n=e.stateNode;if(n===null)return null;var r=n[it]||null;if(r===null)return null;n=r[t];a: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 a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var on=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),sn=!1;if(on)try{var cn={};Object.defineProperty(cn,"passive",{get:function(){sn=!0}}),window.addEventListener(`test`,cn,cn),window.removeEventListener(`test`,cn,cn)}catch{sn=!1}var ln=null,un=null,dn=null;function fn(){if(dn)return dn;var e,t=un,n=t.length,r,i=`value`in ln?ln.value:ln.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return dn=i.slice(e,1<r?1-r:void 0)}function pn(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 mn(){return!0}function hn(){return!1}function gn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?mn:hn,this.isPropagationStopped=hn,this}return f(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=mn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=mn)},persist:function(){},isPersistent:mn}),t}var _n={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vn=gn(_n),yn=f({},_n,{view:0,detail:0}),bn=gn(yn),xn,Sn,Cn,wn=f({},yn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Pn,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!==Cn&&(Cn&&e.type===`mousemove`?(xn=e.screenX-Cn.screenX,Sn=e.screenY-Cn.screenY):Sn=xn=0,Cn=e),xn)},movementY:function(e){return`movementY`in e?e.movementY:Sn}}),Tn=gn(wn),eee=gn(f({},wn,{dataTransfer:0})),En=gn(f({},yn,{relatedTarget:0})),Dn=gn(f({},_n,{animationName:0,elapsedTime:0,pseudoElement:0})),On=gn(f({},_n,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),kn=gn(f({},_n,{data:0})),An={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},jn={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`},Mn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Nn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Mn[e])?!!t[e]:!1}function Pn(){return Nn}var Fn=gn(f({},yn,{key:function(e){if(e.key){var t=An[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=pn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?jn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Pn,charCode:function(e){return e.type===`keypress`?pn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?pn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),In=gn(f({},wn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Ln=gn(f({},yn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Pn})),Rn=gn(f({},_n,{propertyName:0,elapsedTime:0,pseudoElement:0})),zn=gn(f({},wn,{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})),Bn=gn(f({},_n,{newState:0,oldState:0})),Vn=[9,13,27,32],Hn=on&&`CompositionEvent`in window,Un=null;on&&`documentMode`in document&&(Un=document.documentMode);var Wn=on&&`TextEvent`in window&&!Un,Gn=on&&(!Hn||Un&&8<Un&&11>=Un),Kn=` `,qn=!1;function Jn(e,t){switch(e){case`keyup`:return Vn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Yn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Xn=!1;function Zn(e,t){switch(e){case`compositionend`:return Yn(t);case`keypress`:return t.which===32?(qn=!0,Kn):null;case`textInput`:return e=t.data,e===Kn&&qn?null:e;default:return null}}function Qn(e,t){if(Xn)return e===`compositionend`||!Hn&&Jn(e,t)?(e=fn(),dn=un=ln=null,Xn=!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 Gn&&t.locale!==`ko`?null:t.data;default:return null}}var $n={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 er(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!$n[e.type]:t===`textarea`}function tr(e,t,n,r){$t?en?en.push(r):en=[r]:$t=r,t=Od(t,`onChange`),0<t.length&&(n=new vn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var nr=null,rr=null;function ir(e){bd(e,0)}function ar(e){if(Mt(mt(e)))return e}function or(e,t){if(e===`change`)return t}var sr=!1;if(on){var cr;if(on){var lr=`oninput`in document;if(!lr){var ur=document.createElement(`div`);ur.setAttribute(`oninput`,`return;`),lr=typeof ur.oninput==`function`}cr=lr}else cr=!1;sr=cr&&(!document.documentMode||9<document.documentMode)}function dr(){nr&&(nr.detachEvent(`onpropertychange`,fr),rr=nr=null)}function fr(e){if(e.propertyName===`value`&&ar(rr)){var t=[];tr(t,rr,e,Qt(e)),rn(ir,t)}}function pr(e,t,n){e===`focusin`?(dr(),nr=t,rr=n,nr.attachEvent(`onpropertychange`,fr)):e===`focusout`&&dr()}function mr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return ar(rr)}function hr(e,t){if(e===`click`)return ar(t)}function gr(e,t){if(e===`input`||e===`change`)return ar(t)}function _r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var vr=typeof Object.is==`function`?Object.is:_r;function yr(e,t){if(vr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)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(!be.call(t,i)||!vr(e[i],t[i]))return!1}return!0}function br(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function xr(e,t){var n=br(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}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=br(n)}}function Sr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Sr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Cr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Nt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Nt(e.document)}return t}function wr(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`)}var Tr=on&&`documentMode`in document&&11>=document.documentMode,Er=null,Dr=null,Or=null,H=!1;function kr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;H||Er==null||Er!==Nt(r)||(r=Er,`selectionStart`in r&&wr(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}),Or&&yr(Or,r)||(Or=r,r=Od(Dr,`onSelect`),0<r.length&&(t=new vn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Er)))}function Ar(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var jr={animationend:Ar(`Animation`,`AnimationEnd`),animationiteration:Ar(`Animation`,`AnimationIteration`),animationstart:Ar(`Animation`,`AnimationStart`),transitionrun:Ar(`Transition`,`TransitionRun`),transitionstart:Ar(`Transition`,`TransitionStart`),transitioncancel:Ar(`Transition`,`TransitionCancel`),transitionend:Ar(`Transition`,`TransitionEnd`)},Mr={},Nr={};on&&(Nr=document.createElement(`div`).style,`AnimationEvent`in window||(delete jr.animationend.animation,delete jr.animationiteration.animation,delete jr.animationstart.animation),`TransitionEvent`in window||delete jr.transitionend.transition);function Pr(e){if(Mr[e])return Mr[e];if(!jr[e])return e;var t=jr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Nr)return Mr[e]=t[n];return e}var Fr=Pr(`animationend`),Ir=Pr(`animationiteration`),Lr=Pr(`animationstart`),Rr=Pr(`transitionrun`),zr=Pr(`transitionstart`),Br=Pr(`transitioncancel`),Vr=Pr(`transitionend`),Hr=new Map,Ur=`abort auxClick beforeToggle 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(` `);Ur.push(`scrollEnd`);function Wr(e,t){Hr.set(e,t),yt(t,[e])}var Gr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Kr=[],qr=0,Jr=0;function Yr(){for(var e=qr,t=Jr=qr=0;t<e;){var n=Kr[t];Kr[t++]=null;var r=Kr[t];Kr[t++]=null;var i=Kr[t];Kr[t++]=null;var a=Kr[t];if(Kr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Qr(n,i,a)}}function Xr(e,t,n,r){Kr[qr++]=e,Kr[qr++]=t,Kr[qr++]=n,Kr[qr++]=r,Jr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Zr(e,t,n,r){return Xr(e,t,n,r),$r(e)}function U(e,t){return Xr(e,null,null,t),$r(e)}function Qr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Pe(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function $r(e){if(50<hu)throw hu=0,gu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ei={};function ti(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.refCleanup=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 ni(e,t,n,r){return new ti(e,t,n,r)}function ri(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ii(e,t){var n=e.alternate;return n===null?(n=ni(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&65011712,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.refCleanup=e.refCleanup,n}function ai(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function oi(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)ri(e)&&(s=1);else if(typeof e==`string`)s=Kf(e,n,ae.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=ni(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return si(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=ni(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=ni(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=ni(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=ni(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function si(e,t,n,r){return e=ni(7,e,r,t),e.lanes=n,e}function ci(e,t,n){return e=ni(6,e,null,t),e.lanes=n,e}function li(e){var t=ni(18,null,null,0);return t.stateNode=e,t}function ui(e,t,n){return t=ni(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var di=new WeakMap;function fi(e,t){if(typeof e==`object`&&e){var n=di.get(e);return n===void 0?(t={value:e,source:t,stack:ye(t)},di.set(e,t),t):n}return{value:e,source:t,stack:ye(t)}}var pi=[],mi=0,hi=null,gi=0,_i=[],vi=0,yi=null,bi=1,xi=``;function Si(e,t){pi[mi++]=gi,pi[mi++]=hi,hi=e,gi=t}function Ci(e,t,n){_i[vi++]=bi,_i[vi++]=xi,_i[vi++]=yi,yi=e;var r=bi;e=xi;var i=32-Pe(r)-1;r&=~(1<<i),n+=1;var a=32-Pe(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,bi=1<<32-Pe(t)+i|n<<i|r,xi=a+e}else bi=1<<a|n<<i|r,xi=e}function wi(e){e.return!==null&&(Si(e,1),Ci(e,1,0))}function Ti(e){for(;e===hi;)hi=pi[--mi],pi[mi]=null,gi=pi[--mi],pi[mi]=null;for(;e===yi;)yi=_i[--vi],_i[vi]=null,xi=_i[--vi],_i[vi]=null,bi=_i[--vi],_i[vi]=null}function Ei(e,t){_i[vi++]=bi,_i[vi++]=xi,_i[vi++]=yi,bi=t.id,xi=t.overflow,yi=e}var Di=null,Oi=null,ki=!1,Ai=null,ji=!1,Mi=Error(i(519));function Ni(e){throw zi(fi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Mi}function Pi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[rt]=e,t[it]=r,n){case`dialog`:xd(`cancel`,t),xd(`close`,t);break;case`iframe`:case`object`:case`embed`:xd(`load`,t);break;case`video`:case`audio`:for(n=0;n<vd.length;n++)xd(vd[n],t);break;case`source`:xd(`error`,t);break;case`img`:case`image`:case`link`:xd(`error`,t),xd(`load`,t);break;case`details`:xd(`toggle`,t);break;case`input`:xd(`invalid`,t),Lt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:xd(`invalid`,t);break;case`textarea`:xd(`invalid`,t),Vt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Pd(t.textContent,n)?(r.popover!=null&&(xd(`beforetoggle`,t),xd(`toggle`,t)),r.onScroll!=null&&xd(`scroll`,t),r.onScrollEnd!=null&&xd(`scrollend`,t),r.onClick!=null&&(t.onclick=Xt),t=!0):t=!1,t||Ni(e,!0)}function Fi(e){for(Di=e.return;Di;)switch(Di.tag){case 5:case 31:case 13:ji=!1;return;case 27:case 3:ji=!0;return;default:Di=Di.return}}function Ii(e){if(e!==Di)return!1;if(!ki)return Fi(e),ki=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||Kd(e.type,e.memoizedProps)),n=!n),n&&Oi&&Ni(e),Fi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Oi=pf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Oi=pf(e)}else t===27?(t=Oi,ef(e.type)?(e=ff,ff=null,Oi=e):Oi=t):Oi=Di?df(e.stateNode.nextSibling):null;return!0}function Li(){Oi=Di=null,ki=!1}function Ri(){var e=Ai;return e!==null&&(nu===null?nu=e:nu.push.apply(nu,e),Ai=null),e}function zi(e){Ai===null?Ai=[e]:Ai.push(e)}var Bi=ne(null),Vi=null,Hi=null;function Ui(e,t,n){ie(Bi,t._currentValue),t._currentValue=n}function Wi(e){e._currentValue=Bi.current,re(Bi)}function Gi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ki(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Gi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Gi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function qi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;vr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ce.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[tp]:e.push(tp))}a=a.return}e!==null&&Ki(t,e,n,r),t.flags|=262144}function Ji(e){for(e=e.firstContext;e!==null;){if(!vr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Yi(e){Vi=e,Hi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Xi(e){return Qi(Vi,e)}function Zi(e,t){return Vi===null&&Yi(e),Qi(e,t)}function Qi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Hi===null){if(e===null)throw Error(i(308));Hi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Hi=Hi.next=t;return n}var $i=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ea=t.unstable_scheduleCallback,ta=t.unstable_NormalPriority,na={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ra(){return{controller:new $i,data:new Map,refCount:0}}function ia(e){e.refCount--,e.refCount===0&&ea(ta,function(){e.controller.abort()})}var aa=null,oa=0,sa=0,ca=null;function la(e,t){if(aa===null){var n=aa=[];oa=0,sa=fd(),ca={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return oa++,t.then(ua,ua),t}function ua(){if(--oa===0&&aa!==null){ca!==null&&(ca.status=`fulfilled`);var e=aa;aa=null,sa=0,ca=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function da(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var fa=I.S;I.S=function(e,t){au=z(),typeof t==`object`&&t&&typeof t.then==`function`&&la(e,t),fa!==null&&fa(e,t)};var pa=ne(null);function ma(){var e=pa.current;return e===null?Bl.pooledCache:e}function ha(e,t){t===null?ie(pa,pa.current):ie(pa,t.pool)}function ga(){var e=ma();return e===null?null:{parent:na._currentValue,pool:e}}var _a=Error(i(460)),va=Error(i(474)),ya=Error(i(542)),ba={then:function(){}};function xa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Sa(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Xt,Xt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ea(e),e;default:if(typeof t.status==`string`)t.then(Xt,Xt);else{if(e=Bl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ea(e),e}throw wa=t,_a}}function Ca(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(wa=e,_a):e}}var wa=null;function Ta(){if(wa===null)throw Error(i(459));var e=wa;return wa=null,e}function Ea(e){if(e===_a||e===ya)throw Error(i(483))}var Da=null,Oa=0;function ka(e){var t=Oa;return Oa+=1,Da===null&&(Da=[]),Sa(Da,e,t)}function Aa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function ja(e,t){throw t.$$typeof===m?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ma(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=ii(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ci(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&Ca(i)===t.type)?(t=a(t,n.props),Aa(t,n),t.return=e,t):(t=oi(n.type,n.key,n.props,null,e.mode,r),Aa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ui(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=si(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ci(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case g:return n=oi(t.type,t.key,t.props,null,e.mode,n),Aa(n,t),n.return=e,n;case v:return t=ui(t,e.mode,n),t.return=e,t;case O:return t=Ca(t),f(e,t,n)}if(F(t)||M(t))return t=si(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,ka(t),n);if(t.$$typeof===C)return f(e,Zi(e,t),n);ja(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case g:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=Ca(n),p(e,t,n,r)}if(F(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,ka(n),r);if(n.$$typeof===C)return p(e,t,Zi(e,n),r);ja(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case g:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=Ca(r),m(e,t,n,r,i)}if(F(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,ka(r),i);if(r.$$typeof===C)return m(e,t,n,Zi(t,r),i);ja(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),ki&&Si(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return ki&&Si(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),ki&&Si(i,h),l}function _(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),ki&&Si(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return ki&&Si(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),ki&&Si(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case g:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&Ca(l)===r.type){n(e,r.sibling),c=a(r,o.props),Aa(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===y?(c=si(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=oi(o.type,o.key,o.props,null,e.mode,c),Aa(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=ui(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=Ca(o),b(e,r,o,c)}if(F(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),_(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,ka(o),c);if(o.$$typeof===C)return b(e,r,Zi(e,o),c);ja(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ci(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Oa=0;var i=b(e,t,n,r);return Da=null,i}catch(t){if(t===_a||t===ya)throw t;var a=ni(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Na=Ma(!0),Pa=Ma(!1),Fa=!1;function Ia(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function La(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ra(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function za(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,zl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=$r(e),Qr(e,null,n),t}return Xr(e,r,t,n),$r(e)}function Ba(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xe(e,n)}}function Va(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ha=!1;function Ua(){if(Ha){var e=ca;if(e!==null)throw e}}function Wa(e,t,n,r){Ha=!1;var i=e.updateQueue;Fa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(Hl&p)===p:(r&p)===p){p!==0&&p===sa&&(Ha=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:Fa=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Xl|=o,e.lanes=o,e.memoizedState=d}}function Ga(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ka(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ga(n[e],t)}var qa=ne(null),Ja=ne(0);function Ya(e,t){e=Jl,ie(Ja,e),ie(qa,t),Jl=e|t.baseLanes}function Xa(){ie(Ja,Jl),ie(qa,qa.current)}function Za(){Jl=Ja.current,re(qa),re(Ja)}var Qa=ne(null),$a=null;function eo(e){var t=e.alternate;ie(ao,ao.current&1),ie(Qa,e),$a===null&&(t===null||qa.current!==null||t.memoizedState!==null)&&($a=e)}function to(e){ie(ao,ao.current),ie(Qa,e),$a===null&&($a=e)}function no(e){e.tag===22?(ie(ao,ao.current),ie(Qa,e),$a===null&&($a=e)):ro(e)}function ro(){ie(ao,ao.current),ie(Qa,Qa.current)}function io(e){re(Qa),$a===e&&($a=null),re(ao)}var ao=ne(0);function oo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||cf(n)||lf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){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 so=0,co=null,lo=null,uo=null,fo=!1,po=!1,mo=!1,ho=0,go=0,_o=null,vo=0;function yo(){throw Error(i(321))}function bo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!vr(e[n],t[n]))return!1;return!0}function xo(e,t,n,r,i,a){return so=a,co=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=e===null||e.memoizedState===null?Rs:zs,mo=!1,a=n(r,i),mo=!1,po&&(a=Co(t,n,r,i)),So(e),a}function So(e){I.H=Ls;var t=lo!==null&&lo.next!==null;if(so=0,uo=lo=co=null,fo=!1,go=0,_o=null,t)throw Error(i(300));e===null||nc||(e=e.dependencies,e!==null&&Ji(e)&&(nc=!0))}function Co(e,t,n,r){co=e;var a=0;do{if(po&&(_o=null),go=0,po=!1,25<=a)throw Error(i(301));if(a+=1,uo=lo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}I.H=Bs,o=t(n,r)}while(po);return o}function tee(){var e=I.H,t=e.useState()[0];return t=typeof t.then==`function`?Ao(t):t,e=e.useState()[0],(lo===null?null:lo.memoizedState)!==e&&(co.flags|=1024),t}function wo(){var e=ho!==0;return ho=0,e}function To(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Eo(e){if(fo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}fo=!1}so=0,uo=lo=co=null,po=!1,go=ho=0,_o=null}function Do(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return uo===null?co.memoizedState=uo=e:uo=uo.next=e,uo}function Oo(){if(lo===null){var e=co.alternate;e=e===null?null:e.memoizedState}else e=lo.next;var t=uo===null?co.memoizedState:uo.next;if(t!==null)uo=t,lo=e;else{if(e===null)throw co.alternate===null?Error(i(467)):Error(i(310));lo=e,e={memoizedState:lo.memoizedState,baseState:lo.baseState,baseQueue:lo.baseQueue,queue:lo.queue,next:null},uo===null?co.memoizedState=uo=e:uo=uo.next=e}return uo}function ko(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ao(e){var t=go;return go+=1,_o===null&&(_o=[]),e=Sa(_o,e,t),t=co,(uo===null?t.memoizedState:uo.next)===null&&(t=t.alternate,I.H=t===null||t.memoizedState===null?Rs:zs),e}function jo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Ao(e);if(e.$$typeof===C)return Xi(e)}throw Error(i(438,String(e)))}function Mo(e){var t=null,n=co.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=co.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=ko(),co.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=A;return t.index++,n}function No(e,t){return typeof t==`function`?t(e):t}function Po(e){return Fo(Oo(),lo,e)}function Fo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(so&f)===f:(Hl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===sa&&(d=!0);else if((so&p)===p){u=u.next,p===sa&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,co.lanes|=p,Xl|=p;f=u.action,mo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,co.lanes|=f,Xl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!vr(o,e.memoizedState)&&(nc=!0,d&&(n=ca,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Io(e){var t=Oo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);vr(o,t.memoizedState)||(nc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Lo(e,t,n){var r=co,a=Oo(),o=ki;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!vr((lo||a).memoizedState,n);if(s&&(a.memoizedState=n,nc=!0),a=a.queue,ls(Bo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||uo!==null&&uo.memoizedState.tag&1){if(r.flags|=2048,rs(9,{destroy:void 0},zo.bind(null,r,a,n,t),null),Bl===null)throw Error(i(349));o||so&127||Ro(r,t,n)}return n}function Ro(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=co.updateQueue,t===null?(t=ko(),co.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function zo(e,t,n,r){t.value=n,t.getSnapshot=r,Vo(t)&&Ho(e)}function Bo(e,t,n){return n(function(){Vo(t)&&Ho(e)})}function Vo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!vr(e,n)}catch{return!0}}function Ho(e){var t=U(e,2);t!==null&&q(t,e,2)}function Uo(e){var t=Do();if(typeof e==`function`){var n=e;if(e=n(),mo){Ne(!0);try{n()}finally{Ne(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:e},t}function Wo(e,t,n,r){return e.baseState=n,Fo(e,lo,typeof r==`function`?r:No)}function Go(e,t,n,r,a){if(Ps(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};I.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Ko(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Ko(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=I.T,o={};I.T=o;try{var s=n(i,r),c=I.S;c!==null&&c(o,s),qo(e,t,s)}catch(n){Yo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),I.T=a}}else try{a=n(i,r),qo(e,t,a)}catch(n){Yo(e,t,n)}}function qo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Jo(e,t,n)},function(n){return Yo(e,t,n)}):Jo(e,t,n)}function Jo(e,t,n){t.status=`fulfilled`,t.value=n,Xo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ko(e,n)))}function Yo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Xo(t),t=t.next;while(t!==r)}e.action=null}function Xo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Zo(e,t){return t}function Qo(e,t){if(ki){var n=Bl.formState;if(n!==null){a:{var r=co;if(ki){if(Oi){b:{for(var i=Oi,a=ji;i.nodeType!==8;){if(!a){i=null;break b}if(i=df(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Oi=df(i.nextSibling),r=i.data===`F!`;break a}}Ni(r)}r=!1}r&&(t=n[0])}}return n=Do(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zo,lastRenderedState:t},n.queue=r,n=js.bind(null,co,r),r.dispatch=n,r=Uo(!1),a=Ns.bind(null,co,!1,r.queue),r=Do(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Go.bind(null,co,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function $o(e){return es(Oo(),lo,e)}function es(e,t,n){if(t=Fo(e,t,Zo)[0],e=Po(No)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Ao(t)}catch(e){throw e===_a?ya:e}else r=t;t=Oo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(co.flags|=2048,rs(9,{destroy:void 0},ts.bind(null,i,n),null)),[r,a,e]}function ts(e,t){e.action=t}function ns(e){var t=Oo(),n=lo;if(n!==null)return es(t,n,e);Oo(),t=t.memoizedState,n=Oo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function rs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=co.updateQueue,t===null&&(t=ko(),co.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function is(){return Oo().memoizedState}function as(e,t,n,r){var i=Do();co.flags|=e,i.memoizedState=rs(1|t,{destroy:void 0},n,r===void 0?null:r)}function ss(e,t,n,r){var i=Oo();r=r===void 0?null:r;var a=i.memoizedState.inst;lo!==null&&r!==null&&bo(r,lo.memoizedState.deps)?i.memoizedState=rs(t,a,n,r):(co.flags|=e,i.memoizedState=rs(1|t,a,n,r))}function cs(e,t){as(8390656,8,e,t)}function ls(e,t){ss(2048,8,e,t)}function us(e){co.flags|=4;var t=co.updateQueue;if(t===null)t=ko(),co.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ds(e){var t=Oo().memoizedState;return us({ref:t,nextImpl:e}),function(){if(zl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function fs(e,t){return ss(4,2,e,t)}function ps(e,t){return ss(4,4,e,t)}function ms(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function hs(e,t,n){n=n==null?null:n.concat([e]),ss(4,4,ms.bind(null,t,e),n)}function gs(){}function _s(e,t){var n=Oo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&bo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function vs(e,t){var n=Oo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&bo(t,r[1]))return r[0];if(r=e(),mo){Ne(!0);try{e()}finally{Ne(!1)}}return n.memoizedState=[r,t],r}function ys(e,t,n){return n===void 0||so&1073741824&&!(Hl&261930)?e.memoizedState=t:(e.memoizedState=n,e=_u(),co.lanes|=e,Xl|=e,n)}function bs(e,t,n,r){return vr(n,t)?n:qa.current===null?!(so&42)||so&1073741824&&!(Hl&261930)?(nc=!0,e.memoizedState=n):(e=_u(),co.lanes|=e,Xl|=e,t):(e=ys(e,n,r),vr(e,t)||(nc=!0),e)}function xs(e,t,n,r,i){var a=L.p;L.p=a!==0&&8>a?a:8;var o=I.T,s={};I.T=s,Ns(e,!1,t,n);try{var c=i(),l=I.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ms(e,t,da(c,r),K(e)):Ms(e,t,r,K(e))}catch(n){Ms(e,t,{then:function(){},status:`rejected`,reason:n},K())}finally{L.p=a,o!==null&&s.types!==null&&(o.types=s.types),I.T=o}}function Ss(){}function Cs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=ws(e).queue;xs(e,a,t,R,n===null?Ss:function(){return Ts(e),n(r)})}function ws(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:R,baseState:R,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:R},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ts(e){var t=ws(e);t.next===null&&(t=e.alternate.memoizedState),Ms(e,t.next.queue,{},K())}function Es(){return Xi(tp)}function Ds(){return Oo().memoizedState}function Os(){return Oo().memoizedState}function ks(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=K();e=Ra(n);var r=za(t,e,n);r!==null&&(q(r,t,n),Ba(r,t,n)),t={cache:ra()},e.payload=t;return}t=t.return}}function As(e,t,n){var r=K();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ps(e)?Fs(t,n):(n=Zr(e,t,n,r),n!==null&&(q(n,e,r),Is(n,t,r)))}function js(e,t,n){Ms(e,t,n,K())}function Ms(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ps(e))Fs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,vr(s,o))return Xr(e,t,i,0),Bl===null&&Yr(),!1}catch{}if(n=Zr(e,t,i,r),n!==null)return q(n,e,r),Is(n,t,r),!0}return!1}function Ns(e,t,n,r){if(r={lane:2,revertLane:fd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ps(e)){if(t)throw Error(i(479))}else t=Zr(e,n,r,2),t!==null&&q(t,e,2)}function Ps(e){var t=e.alternate;return e===co||t!==null&&t===co}function Fs(e,t){po=fo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Is(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xe(e,n)}}var Ls={readContext:Xi,use:jo,useCallback:yo,useContext:yo,useEffect:yo,useImperativeHandle:yo,useLayoutEffect:yo,useInsertionEffect:yo,useMemo:yo,useReducer:yo,useRef:yo,useState:yo,useDebugValue:yo,useDeferredValue:yo,useTransition:yo,useSyncExternalStore:yo,useId:yo,useHostTransitionStatus:yo,useFormState:yo,useActionState:yo,useOptimistic:yo,useMemoCache:yo,useCacheRefresh:yo};Ls.useEffectEvent=yo;var Rs={readContext:Xi,use:jo,useCallback:function(e,t){return Do().memoizedState=[e,t===void 0?null:t],e},useContext:Xi,useEffect:cs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),as(4194308,4,ms.bind(null,t,e),n)},useLayoutEffect:function(e,t){return as(4194308,4,e,t)},useInsertionEffect:function(e,t){as(4,2,e,t)},useMemo:function(e,t){var n=Do();t=t===void 0?null:t;var r=e();if(mo){Ne(!0);try{e()}finally{Ne(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Do();if(n!==void 0){var i=n(t);if(mo){Ne(!0);try{n(t)}finally{Ne(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=As.bind(null,co,e),[r.memoizedState,e]},useRef:function(e){var t=Do();return e={current:e},t.memoizedState=e},useState:function(e){e=Uo(e);var t=e.queue,n=js.bind(null,co,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:gs,useDeferredValue:function(e,t){return ys(Do(),e,t)},useTransition:function(){var e=Uo(!1);return e=xs.bind(null,co,e.queue,!0,!1),Do().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=co,a=Do();if(ki){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Bl===null)throw Error(i(349));Hl&127||Ro(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,cs(Bo.bind(null,r,o,e),[e]),r.flags|=2048,rs(9,{destroy:void 0},zo.bind(null,r,o,n,t),null),n},useId:function(){var e=Do(),t=Bl.identifierPrefix;if(ki){var n=xi,r=bi;n=(r&~(1<<32-Pe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=ho++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=vo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Es,useFormState:Qo,useActionState:Qo,useOptimistic:function(e){var t=Do();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ns.bind(null,co,!0,n),n.dispatch=t,[e,t]},useMemoCache:Mo,useCacheRefresh:function(){return Do().memoizedState=ks.bind(null,co)},useEffectEvent:function(e){var t=Do(),n={impl:e};return t.memoizedState=n,function(){if(zl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},zs={readContext:Xi,use:jo,useCallback:_s,useContext:Xi,useEffect:ls,useImperativeHandle:hs,useInsertionEffect:fs,useLayoutEffect:ps,useMemo:vs,useReducer:Po,useRef:is,useState:function(){return Po(No)},useDebugValue:gs,useDeferredValue:function(e,t){return bs(Oo(),lo.memoizedState,e,t)},useTransition:function(){var e=Po(No)[0],t=Oo().memoizedState;return[typeof e==`boolean`?e:Ao(e),t]},useSyncExternalStore:Lo,useId:Ds,useHostTransitionStatus:Es,useFormState:$o,useActionState:$o,useOptimistic:function(e,t){return Wo(Oo(),lo,e,t)},useMemoCache:Mo,useCacheRefresh:Os};zs.useEffectEvent=ds;var Bs={readContext:Xi,use:jo,useCallback:_s,useContext:Xi,useEffect:ls,useImperativeHandle:hs,useInsertionEffect:fs,useLayoutEffect:ps,useMemo:vs,useReducer:Io,useRef:is,useState:function(){return Io(No)},useDebugValue:gs,useDeferredValue:function(e,t){var n=Oo();return lo===null?ys(n,e,t):bs(n,lo.memoizedState,e,t)},useTransition:function(){var e=Io(No)[0],t=Oo().memoizedState;return[typeof e==`boolean`?e:Ao(e),t]},useSyncExternalStore:Lo,useId:Ds,useHostTransitionStatus:Es,useFormState:ns,useActionState:ns,useOptimistic:function(e,t){var n=Oo();return lo===null?(n.baseState=e,[e,n.queue.dispatch]):Wo(n,lo,e,t)},useMemoCache:Mo,useCacheRefresh:Os};Bs.useEffectEvent=ds;function Vs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:f({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Hs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=K(),i=Ra(r);i.payload=t,n!=null&&(i.callback=n),t=za(e,i,r),t!==null&&(q(t,e,r),Ba(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=K(),i=Ra(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=za(e,i,r),t!==null&&(q(t,e,r),Ba(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=K(),r=Ra(n);r.tag=2,t!=null&&(r.callback=t),t=za(e,r,n),t!==null&&(q(t,e,n),Ba(t,e,n))}};function Us(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!yr(n,r)||!yr(i,a):!0}function Ws(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&&Hs.enqueueReplaceState(t,t.state,null)}function Gs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=f({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Ks(e){Gr(e)}function qs(e){console.error(e)}function Js(e){Gr(e)}function Ys(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Xs(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Zs(e,t,n){return n=Ra(n),n.tag=3,n.payload={element:null},n.callback=function(){Ys(e,t)},n}function Qs(e){return e=Ra(e),e.tag=3,e}function $s(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Xs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Xs(t,n,r),typeof i!=`function`&&(G===null?G=new Set([this]):G.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function ec(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&qi(t,n,a,!0),n=Qa.current,n!==null){switch(n.tag){case 31:case 13:return $a===null?Ou():n.alternate===null&&Yl===0&&(Yl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ba?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Ku(e,r,a)),!1;case 22:return n.flags|=65536,r===ba?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Ku(e,r,a)),!1}throw Error(i(435,n.tag))}return Ku(e,r,a),Ou(),!1}if(ki)return t=Qa.current,t===null?(r!==Mi&&(t=Error(i(423),{cause:r}),zi(fi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=fi(r,n),a=Zs(e.stateNode,r,a),Va(e,a),Yl!==4&&(Yl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Mi&&(e=Error(i(422),{cause:r}),zi(fi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=fi(o,n),tu===null?tu=[o]:tu.push(o),Yl!==4&&(Yl=2),t===null)return!0;r=fi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Zs(n.stateNode,r,e),Va(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(G===null||!G.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Qs(a),$s(a,e,n,r),Va(n,a),!1}n=n.return}while(n!==null);return!1}var tc=Error(i(461)),nc=!1;function rc(e,t,n,r){t.child=e===null?Pa(t,null,n,r):Na(t,e.child,n,r)}function ic(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Yi(t),r=xo(e,t,n,o,a,i),s=wo(),e!==null&&!nc?(To(e,t,i),Oc(e,t,i)):(ki&&s&&wi(t),t.flags|=1,rc(e,t,r,i),t.child)}function ac(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ri(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,oc(e,t,a,r,i)):(e=oi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!kc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?yr:n,n(o,r)&&e.ref===t.ref)return Oc(e,t,i)}return t.flags|=1,e=ii(a,r),e.ref=t.ref,e.return=t,t.child=e}function oc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(yr(a,r)&&e.ref===t.ref){if(nc=!1,t.pendingProps=r=a,kc(e,i))e.flags&131072&&(nc=!0);else return t.lanes=e.lanes,Oc(e,t,i)}}return mc(e,t,n,r,i)}function sc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return lc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ha(t,a===null?null:a.cachePool),a===null?Xa():Ya(t,a),no(t);else return r=t.lanes=536870912,lc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ha(t,null),Xa(),ro(t)):(ha(t,a.cachePool),Ya(t,a),ro(t),t.memoizedState=null);return rc(e,t,i,n),t.child}function cc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function lc(e,t,n,r,i){var a=ma();return a=a===null?null:{parent:na._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ha(t,null),Xa(),no(t),e!==null&&qi(e,t,r,!0),t.childLanes=i,null}function uc(e,t){return t=Cc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function dc(e,t,n){return Na(t,e.child,null,n),e=uc(t,t.pendingProps),e.flags|=2,io(t),t.memoizedState=null,e}function fc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(ki){if(r.mode===`hidden`)return e=uc(t,r),t.lanes=536870912,cc(null,e);if(to(t),(e=Oi)?(e=sf(e,ji),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:yi===null?null:{id:bi,overflow:xi},retryLane:536870912,hydrationErrors:null},n=li(e),n.return=t,t.child=n,Di=t,Oi=null)):e=null,e===null)throw Ni(t);return t.lanes=536870912,null}return uc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(to(t),a){if(t.flags&256)t.flags&=-257,t=dc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(nc||qi(e,t,n,!1),a=(n&e.childLanes)!==0,nc||a){if(r=Bl,r!==null&&(s=Ze(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,U(e,s),q(r,e,s),tc;Ou(),t=dc(e,t,n)}else e=o.treeContext,Oi=df(s.nextSibling),Di=t,ki=!0,Ai=null,ji=!1,e!==null&&Ei(t,e),t=uc(t,r),t.flags|=4096;return t}return e=ii(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function pc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function mc(e,t,n,r,i){return Yi(t),n=xo(e,t,n,r,void 0,i),r=wo(),e!==null&&!nc?(To(e,t,i),Oc(e,t,i)):(ki&&r&&wi(t),t.flags|=1,rc(e,t,n,i),t.child)}function hc(e,t,n,r,i,a){return Yi(t),t.updateQueue=null,n=Co(t,r,n,i),So(e),r=wo(),e!==null&&!nc?(To(e,t,a),Oc(e,t,a)):(ki&&r&&wi(t),t.flags|=1,rc(e,t,n,a),t.child)}function gc(e,t,n,r,i){if(Yi(t),t.stateNode===null){var a=ei,o=n.contextType;typeof o==`object`&&o&&(a=Xi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Hs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ia(t),o=n.contextType,a.context=typeof o==`object`&&o?Xi(o):ei,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Vs(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Hs.enqueueReplaceState(a,a.state,null),Wa(t,r,a,i),Ua(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Gs(n,s);a.props=c;var l=a.context,u=n.contextType;o=ei,typeof u==`object`&&u&&(o=Xi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ws(t,a,r,o),Fa=!1;var f=t.memoizedState;a.state=f,Wa(t,r,a,i),Ua(),l=t.memoizedState,s||f!==l||Fa?(typeof d==`function`&&(Vs(t,n,d,r),l=t.memoizedState),(c=Fa||Us(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,La(e,t),o=t.memoizedProps,u=Gs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=ei,typeof l==`object`&&l&&(c=Xi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ws(t,a,r,c),Fa=!1,f=t.memoizedState,a.state=f,Wa(t,r,a,i),Ua();var p=t.memoizedState;o!==d||f!==p||Fa||e!==null&&e.dependencies!==null&&Ji(e.dependencies)?(typeof s==`function`&&(Vs(t,n,s,r),p=t.memoizedState),(u=Fa||Us(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ji(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,pc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Na(t,e.child,null,i),t.child=Na(t,null,n,i)):rc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Oc(e,t,i),e}function _c(e,t,n,r){return Li(),t.flags|=256,rc(e,t,n,r),t.child}var vc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function yc(e){return{baseLanes:e,cachePool:ga()}}function bc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=$l),e}function xc(e,t,n){var r=t.pendingProps,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(ao.current&2)),s&&(a=!0,t.flags&=-129),s=!!(t.flags&32),t.flags&=-33,e===null){if(ki){if(a?eo(t):ro(t),(e=Oi)?(e=sf(e,ji),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:yi===null?null:{id:bi,overflow:xi},retryLane:536870912,hydrationErrors:null},n=li(e),n.return=t,t.child=n,Di=t,Oi=null)):e=null,e===null)throw Ni(t);return lf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(ro(t),a=t.mode,c=Cc({mode:`hidden`,children:c},a),r=si(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=yc(n),r.childLanes=bc(e,s,n),t.memoizedState=vc,cc(null,r)):(eo(t),Sc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(eo(t),t.flags&=-257,t=wc(e,t,n)):t.memoizedState===null?(ro(t),c=r.fallback,a=t.mode,r=Cc({mode:`visible`,children:r.children},a),c=si(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Na(t,e.child,null,n),r=t.child,r.memoizedState=yc(n),r.childLanes=bc(e,s,n),t.memoizedState=vc,t=cc(null,r)):(ro(t),t.child=e.child,t.flags|=128,t=null);else if(eo(t),lf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,zi({value:r,source:null,stack:null}),t=wc(e,t,n)}else if(nc||qi(e,t,n,!1),s=(n&e.childLanes)!==0,nc||s){if(s=Bl,s!==null&&(r=Ze(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,U(e,r),q(s,e,r),tc;cf(c)||Ou(),t=wc(e,t,n)}else cf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Oi=df(c.nextSibling),Di=t,ki=!0,Ai=null,ji=!1,e!==null&&Ei(t,e),t=Sc(t,r.children),t.flags|=4096);return t}return a?(ro(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=ii(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=si(c,a,n,null),c.flags|=2):c=ii(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,cc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=yc(n):(a=c.cachePool,a===null?a=ga():(l=na._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=bc(e,s,n),t.memoizedState=vc,cc(e.child,r)):(eo(t),n=e.child,e=n.sibling,n=ii(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function Sc(e,t){return t=Cc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Cc(e,t){return e=ni(22,e,null,t),e.lanes=0,e}function wc(e,t,n){return Na(t,e.child,null,n),e=Sc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Tc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Gi(e.return,t,n)}function Ec(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Dc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=ao.current,s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,ie(ao,o),rc(e,t,r,n),r=ki?gi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Tc(e,n,t);else if(e.tag===19)Tc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&oo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Ec(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&oo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Ec(t,!0,n,null,a,r);break;case`together`:Ec(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Oc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Xl|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(qi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=ii(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ii(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function kc(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Ji(e)))}function Ac(e,t,n){switch(t.tag){case 3:le(t,t.stateNode.containerInfo),Ui(t,na,e.memoizedState.cache),Li();break;case 27:case 5:de(t);break;case 4:le(t,t.stateNode.containerInfo);break;case 10:Ui(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,to(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(eo(t),e=Oc(e,t,n),e===null?null:e.sibling):xc(e,t,n):(eo(t),t.flags|=128,null);eo(t);break;case 19:var i=!!(e.flags&128);if(r=(n&t.childLanes)!==0,r||=(qi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Dc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ie(ao,ao.current),r)break;return null;case 22:return t.lanes=0,sc(e,t,n,t.pendingProps);case 24:Ui(t,na,e.memoizedState.cache)}return Oc(e,t,n)}function jc(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)nc=!0;else{if(!kc(e,n)&&!(t.flags&128))return nc=!1,Ac(e,t,n);nc=!!(e.flags&131072)}}else nc=!1,ki&&t.flags&1048576&&Ci(t,gi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ca(t.elementType),t.type=e,typeof e==`function`)ri(e)?(r=Gs(e,r),t.tag=1,t=gc(null,t,e,r,n)):(t.tag=0,t=mc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=ic(null,t,e,r,n);break a}if(a===D){t.tag=14,t=ac(null,t,e,r,n);break a}}throw t=P(e)||e,Error(i(306,t,``))}}return t;case 0:return mc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Gs(r,t.pendingProps),gc(e,t,r,a,n);case 3:a:{if(le(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,La(e,t),Wa(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ui(t,na,r),r!==o.cache&&Ki(t,[na],n,!0),Ua(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=_c(e,t,r,n);break a}if(r!==a){a=fi(Error(i(424)),t),zi(a),t=_c(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Oi=df(e.firstChild),Di=t,ki=!0,Ai=null,ji=!0,n=Pa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Li(),r===a){t=Oc(e,t,n);break a}rc(e,t,r,n)}t=t.child}return t;case 26:return pc(e,t),e===null?(n=Mf(t.type,null,t.pendingProps,null))?t.memoizedState=n:ki||(n=t.type,e=t.pendingProps,r=Ud(se.current).createElement(n),r[rt]=t,r[it]=e,Ld(r,n,e),gt(r),t.stateNode=r):t.memoizedState=Mf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return de(t),e===null&&ki&&(r=t.stateNode=hf(t.type,t.pendingProps,se.current),Di=t,ji=!0,a=Oi,ef(t.type)?(ff=a,Oi=df(r.firstChild)):Oi=a),rc(e,t,t.pendingProps.children,n),pc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&ki&&((a=r=Oi)&&(r=af(r,t.type,t.pendingProps,ji),r===null?a=!1:(t.stateNode=r,Di=t,Oi=df(r.firstChild),ji=!1,a=!0)),a||Ni(t)),de(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Kd(a,o)?r=null:s!==null&&Kd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=xo(e,t,tee,null,null,n),tp._currentValue=a),pc(e,t),rc(e,t,r,n),t.child;case 6:return e===null&&ki&&((e=n=Oi)&&(n=of(n,t.pendingProps,ji),n===null?e=!1:(t.stateNode=n,Di=t,Oi=null,e=!0)),e||Ni(t)),null;case 13:return xc(e,t,n);case 4:return le(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Na(t,null,r,n):rc(e,t,r,n),t.child;case 11:return ic(e,t,t.type,t.pendingProps,n);case 7:return rc(e,t,t.pendingProps,n),t.child;case 8:return rc(e,t,t.pendingProps.children,n),t.child;case 12:return rc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ui(t,t.type,r.value),rc(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Yi(t),a=Xi(a),r=r(a),t.flags|=1,rc(e,t,r,n),t.child;case 14:return ac(e,t,t.type,t.pendingProps,n);case 15:return oc(e,t,t.type,t.pendingProps,n);case 19:return Dc(e,t,n);case 31:return fc(e,t,n);case 22:return sc(e,t,n,t.pendingProps);case 24:return Yi(t),r=Xi(na),e===null?(a=ma(),a===null&&(a=Bl,o=ra(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Ia(t),Ui(t,na,a)):((e.lanes&n)!==0&&(La(e,t),Wa(t,null,null,n),Ua()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ui(t,na,r),r!==a.cache&&Ki(t,[na],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ui(t,na,r))),rc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Mc(e){e.flags|=4}function Nc(e,t,n,r,i){if((t=!!(e.mode&32))&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Tu())e.flags|=8192;else throw wa=ba,va}}else e.flags&=-16777217}function Pc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!qf(t)){if(Tu())e.flags|=8192;else throw wa=ba,va}}function Fc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ge(),e.lanes|=t,eu|=t)}function Ic(e,t){if(!ki)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 Lc(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&65011712,r|=i.flags&65011712,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 Rc(e,t,n){var r=t.pendingProps;switch(Ti(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lc(t),null;case 1:return Lc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Wi(na),ue(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Ii(t)?Mc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ri())),Lc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Mc(t),o===null?(Lc(t),Nc(t,a,null,r,n)):(Lc(t),Pc(t,o))):o?o===e.memoizedState?(Lc(t),t.flags&=-16777217):(Mc(t),Lc(t),Pc(t,o)):(e=e.memoizedProps,e!==r&&Mc(t),Lc(t),Nc(t,a,e,r,n)),null;case 27:if(fe(t),n=se.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Mc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Lc(t),null}e=ae.current,Ii(t)?Pi(t,e):(e=hf(a,r,n),t.stateNode=e,Mc(t))}return Lc(t),null;case 5:if(fe(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Mc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Lc(t),null}if(o=ae.current,Ii(t))Pi(t,o);else{var s=Ud(se.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[rt]=t,o[it]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Ld(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Mc(t)}}return Lc(t),Nc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Mc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=se.current,Ii(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Di,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[rt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Pd(e.nodeValue,n)),e||Ni(t,!0)}else e=Ud(e).createTextNode(r),e[rt]=t,t.stateNode=e}return Lc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ii(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[rt]=t}else Li(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Lc(t),e=!1}else n=Ri(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(io(t),t):(io(t),null);if(t.flags&128)throw Error(i(558))}return Lc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ii(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[rt]=t}else Li(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Lc(t),a=!1}else a=Ri(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(io(t),t):(io(t),null)}return io(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Fc(t,t.updateQueue),Lc(t),null);case 4:return ue(),e===null&&wd(t.stateNode.containerInfo),Lc(t),null;case 10:return Wi(t.type),Lc(t),null;case 19:if(re(ao),r=t.memoizedState,r===null)return Lc(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)Ic(r,!1);else{if(Yl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=oo(e),o!==null){for(t.flags|=128,Ic(r,!1),e=o.updateQueue,t.updateQueue=e,Fc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ai(n,e),n=n.sibling;return ie(ao,ao.current&1|2),ki&&Si(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&z()>ou&&(t.flags|=128,a=!0,Ic(r,!1),t.lanes=4194304)}}else{if(!a){if(e=oo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Fc(t,e),Ic(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!ki)return Lc(t),null}else 2*z()-r.renderingStartTime>ou&&n!==536870912&&(t.flags|=128,a=!0,Ic(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Lc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=z(),e.sibling=null,n=ao.current,ie(ao,a?n&1|2:n&1),ki&&Si(t,r.treeForkCount),e);case 22:case 23:return io(t),Za(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Lc(t),t.subtreeFlags&6&&(t.flags|=8192)):Lc(t),n=t.updateQueue,n!==null&&Fc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&re(pa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Wi(na),Lc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function zc(e,t){switch(Ti(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wi(na),ue(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return fe(t),null;case 31:if(t.memoizedState!==null){if(io(t),t.alternate===null)throw Error(i(340));Li()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Li()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return re(ao),null;case 4:return ue(),null;case 10:return Wi(t.type),null;case 22:case 23:return io(t),Za(),e!==null&&re(pa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Wi(na),null;case 25:return null;default:return null}}function Bc(e,t){switch(Ti(t),t.tag){case 3:Wi(na),ue();break;case 26:case 27:case 5:fe(t);break;case 4:ue();break;case 31:t.memoizedState!==null&&io(t);break;case 13:io(t);break;case 19:re(ao);break;case 10:Wi(t.type);break;case 22:case 23:io(t),Za(),e!==null&&re(pa);break;case 24:Wi(na)}}function Vc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Gu(t,t.return,e)}}function Hc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Gu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Gu(t,t.return,e)}}function Uc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ka(t,n)}catch(t){Gu(e,e.return,t)}}}function Wc(e,t,n){n.props=Gs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Gu(e,t,n)}}function Gc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Gu(e,t,n)}}function Kc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Gu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Gu(e,t,n)}else n.current=null}}function qc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Gu(e,e.return,t)}}function Jc(e,t,n){try{var r=e.stateNode;Rd(r,e.type,n,t),r[it]=t}catch(t){Gu(e,e.return,t)}}function Yc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ef(e.type)||e.tag===4}function Xc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Yc(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.tag===27&&ef(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Zc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Xt));else if(r!==4&&(r===27&&ef(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Zc(e,t,n),e=e.sibling;e!==null;)Zc(e,t,n),e=e.sibling}function Qc(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&&(r===27&&ef(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Qc(e,t,n),e=e.sibling;e!==null;)Qc(e,t,n),e=e.sibling}function $c(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Ld(t,r,n),t[rt]=e,t[it]=n}catch(t){Gu(e,e.return,t)}}var el=!1,tl=!1,nl=!1,rl=typeof WeakSet==`function`?WeakSet:Set,il=null;function al(e,t){if(e=e.containerInfo,Vd=up,e=Cr(e),wr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Hd={focusedElem:e,selectionRange:n},up=!1,il=t;il!==null;)if(t=il,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,il=e;else for(;il!==null;){switch(t=il,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Gs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Gu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)rf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:rf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,il=e;break}il=t.return}}function ol(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:xl(e,n),r&4&&Vc(5,n);break;case 1:if(xl(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Gu(n,n.return,e)}else{var i=Gs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Gu(n,n.return,e)}}}r&64&&Uc(n),r&512&&Gc(n,n.return);break;case 3:if(xl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Ka(e,t)}catch(e){Gu(n,n.return,e)}}break;case 27:t===null&&r&4&&$c(n);case 26:case 5:xl(e,n),t===null&&r&4&&qc(n),r&512&&Gc(n,n.return);break;case 12:xl(e,n);break;case 31:xl(e,n),r&4&&fl(e,n);break;case 13:xl(e,n),r&4&&pl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Yu.bind(null,n),uf(e,n))));break;case 22:if(r=n.memoizedState!==null||el,!r){t=t!==null&&t.memoizedState!==null||tl,i=el;var a=tl;el=r,(tl=t)&&!a?Cl(e,n,!!(n.subtreeFlags&8772)):xl(e,n),el=i,tl=a}break;case 30:break;default:xl(e,n)}}function sl(e){var t=e.alternate;t!==null&&(e.alternate=null,sl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&dt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var cl=null,ll=!1;function ul(e,t,n){for(n=n.child;n!==null;)dl(e,t,n),n=n.sibling}function dl(e,t,n){if(Me&&typeof Me.onCommitFiberUnmount==`function`)try{Me.onCommitFiberUnmount(je,n)}catch{}switch(n.tag){case 26:tl||Kc(n,t),ul(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:tl||Kc(n,t);var r=cl,i=ll;ef(n.type)&&(cl=n.stateNode,ll=!1),ul(e,t,n),gf(n.stateNode),cl=r,ll=i;break;case 5:tl||Kc(n,t);case 6:if(r=cl,i=ll,cl=null,ul(e,t,n),cl=r,ll=i,cl!==null){if(ll)try{(cl.nodeType===9?cl.body:cl.nodeName===`HTML`?cl.ownerDocument.body:cl).removeChild(n.stateNode)}catch(e){Gu(n,t,e)}else try{cl.removeChild(n.stateNode)}catch(e){Gu(n,t,e)}}break;case 18:cl!==null&&(ll?(e=cl,tf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Ip(e)):tf(cl,n.stateNode));break;case 4:r=cl,i=ll,cl=n.stateNode.containerInfo,ll=!0,ul(e,t,n),cl=r,ll=i;break;case 0:case 11:case 14:case 15:Hc(2,n,t),tl||Hc(4,n,t),ul(e,t,n);break;case 1:tl||(Kc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Wc(n,t,r)),ul(e,t,n);break;case 21:ul(e,t,n);break;case 22:tl=(r=tl)||n.memoizedState!==null,ul(e,t,n),tl=r;break;default:ul(e,t,n)}}function fl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ip(e)}catch(e){Gu(t,t.return,e)}}}function pl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ip(e)}catch(e){Gu(t,t.return,e)}}function ml(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new rl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new rl),t;default:throw Error(i(435,e.tag))}}function hl(e,t){var n=ml(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Xu.bind(null,e,t);t.then(r,r)}})}function gl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(ef(c.type)){cl=c.stateNode,ll=!1;break a}break;case 5:cl=c.stateNode,ll=!1;break a;case 3:case 4:cl=c.stateNode.containerInfo,ll=!0;break a}c=c.return}if(cl===null)throw Error(i(160));dl(o,s,a),cl=null,ll=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)vl(t,e),t=t.sibling}var _l=null;function vl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:gl(t,e),yl(e),r&4&&(Hc(3,e,e.return),Vc(3,e),Hc(5,e,e.return));break;case 1:gl(t,e),yl(e),r&512&&(tl||n===null||Kc(n,n.return)),r&64&&el&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=_l;if(gl(t,e),yl(e),r&512&&(tl||n===null||Kc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null){if(r===null){if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[ut]||o[rt]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Ld(o,r,n),o[rt]=e,gt(o),r=o;break a;case`link`:var s=Wf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Ld(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Wf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Ld(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[rt]=e,gt(o),r=o}e.stateNode=r}else Gf(a,e.type,e.stateNode)}else e.stateNode=zf(a,r,e.memoizedProps)}else o===r?r===null&&e.stateNode!==null&&Jc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Gf(a,e.type,e.stateNode):zf(a,r,e.memoizedProps))}break;case 27:gl(t,e),yl(e),r&512&&(tl||n===null||Kc(n,n.return)),n!==null&&r&4&&Jc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(gl(t,e),yl(e),r&512&&(tl||n===null||Kc(n,n.return)),e.flags&32){a=e.stateNode;try{Ht(a,``)}catch(t){Gu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Jc(e,a,n===null?a:n.memoizedProps)),r&1024&&(nl=!0);break;case 6:if(gl(t,e),yl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Gu(e,e.return,t)}}break;case 3:if(Uf=null,a=_l,_l=yf(t.containerInfo),gl(t,e),_l=a,yl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Ip(t.containerInfo)}catch(t){Gu(e,e.return,t)}nl&&(nl=!1,bl(e));break;case 4:r=_l,_l=yf(e.stateNode.containerInfo),gl(t,e),yl(e),_l=r;break;case 12:gl(t,e),yl(e);break;case 31:gl(t,e),yl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,hl(e,r)));break;case 13:gl(t,e),yl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(iu=z()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,hl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=el,d=tl;if(el=u||a,tl=d||l,gl(t,e),tl=d,el=u,yl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||el||tl||Sl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Gu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Gu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?nf(m,!0):nf(l.stateNode,!1)}catch(e){Gu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,hl(e,n))));break;case 19:gl(t,e),yl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,hl(e,r)));break;case 30:break;case 21:break;default:gl(t,e),yl(e)}}function yl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Yc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Qc(e,Xc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Ht(o,``),n.flags&=-33),Qc(e,Xc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Zc(e,Xc(e),s);break;default:throw Error(i(161))}}catch(t){Gu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function bl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;bl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function xl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)ol(e,t.alternate,t),t=t.sibling}function Sl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Hc(4,t,t.return),Sl(t);break;case 1:Kc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Wc(t,t.return,n),Sl(t);break;case 27:gf(t.stateNode);case 26:case 5:Kc(t,t.return),Sl(t);break;case 22:t.memoizedState===null&&Sl(t);break;case 30:Sl(t);break;default:Sl(t)}e=e.sibling}}function Cl(e,t,n){for(n&&=!!(t.subtreeFlags&8772),t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:Cl(i,a,n),Vc(4,a);break;case 1:if(Cl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Gu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ga(c[i],s)}catch(e){Gu(r,r.return,e)}}n&&o&64&&Uc(a),Gc(a,a.return);break;case 27:$c(a);case 26:case 5:Cl(i,a,n),n&&r===null&&o&4&&qc(a),Gc(a,a.return);break;case 12:Cl(i,a,n);break;case 31:Cl(i,a,n),n&&o&4&&fl(i,a);break;case 13:Cl(i,a,n),n&&o&4&&pl(i,a);break;case 22:a.memoizedState===null&&Cl(i,a,n),Gc(a,a.return);break;case 30:break;default:Cl(i,a,n)}t=t.sibling}}function wl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&ia(n))}function Tl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ia(e))}function El(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Dl(e,t,n,r),t=t.sibling}function Dl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:El(e,t,n,r),i&2048&&Vc(9,t);break;case 1:El(e,t,n,r);break;case 3:El(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ia(e)));break;case 12:if(i&2048){El(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Gu(t,t.return,e)}}else El(e,t,n,r);break;case 31:El(e,t,n,r);break;case 13:El(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?El(e,t,n,r):(a._visibility|=2,Ol(e,t,n,r,!!(t.subtreeFlags&10256)||!1)):a._visibility&2?El(e,t,n,r):kl(e,t),i&2048&&wl(o,t);break;case 24:El(e,t,n,r),i&2048&&Tl(t.alternate,t);break;default:El(e,t,n,r)}}function Ol(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Ol(a,o,s,c,i),Vc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Ol(a,o,s,c,i)):u._visibility&2?Ol(a,o,s,c,i):kl(a,o),i&&l&2048&&wl(o.alternate,o);break;case 24:Ol(a,o,s,c,i),i&&l&2048&&Tl(o.alternate,o);break;default:Ol(a,o,s,c,i)}t=t.sibling}}function kl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:kl(n,r),i&2048&&wl(r.alternate,r);break;case 24:kl(n,r),i&2048&&Tl(r.alternate,r);break;default:kl(n,r)}t=t.sibling}}var Al=8192;function jl(e,t,n){if(e.subtreeFlags&Al)for(e=e.child;e!==null;)Ml(e,t,n),e=e.sibling}function Ml(e,t,n){switch(e.tag){case 26:jl(e,t,n),e.flags&Al&&e.memoizedState!==null&&Jf(n,_l,e.memoizedState,e.memoizedProps);break;case 5:jl(e,t,n);break;case 3:case 4:var r=_l;_l=yf(e.stateNode.containerInfo),jl(e,t,n),_l=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Al,Al=16777216,jl(e,t,n),Al=r):jl(e,t,n));break;default:jl(e,t,n)}}function Nl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Pl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];il=r,Il(r,e)}Nl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Fl(e),e=e.sibling}function Fl(e){switch(e.tag){case 0:case 11:case 15:Pl(e),e.flags&2048&&Hc(9,e,e.return);break;case 3:Pl(e);break;case 12:Pl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,W(e)):Pl(e);break;default:Pl(e)}}function W(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];il=r,Il(r,e)}Nl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Hc(8,t,t.return),W(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,W(t));break;default:W(t)}e=e.sibling}}function Il(e,t){for(;il!==null;){var n=il;switch(n.tag){case 0:case 11:case 15:Hc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:ia(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,il=r;else a:for(n=e;il!==null;){r=il;var i=r.sibling,a=r.return;if(sl(r),r===n){il=null;break a}if(i!==null){i.return=a,il=i;break a}il=a}}}var Ll={getCacheForType:function(e){var t=Xi(na),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Xi(na).controller.signal}},Rl=typeof WeakMap==`function`?WeakMap:Map,zl=0,Bl=null,Vl=null,Hl=0,Ul=0,Wl=null,Gl=!1,Kl=!1,ql=!1,Jl=0,Yl=0,Xl=0,Zl=0,Ql=0,$l=0,eu=0,tu=null,nu=null,ru=!1,iu=0,au=0,ou=1/0,su=null,G=null,cu=0,lu=null,uu=null,du=0,fu=0,pu=null,mu=null,hu=0,gu=null;function K(){return zl&2&&Hl!==0?Hl&-Hl:I.T===null?et():fd()}function _u(){if($l===0){if(!(Hl&536870912)||ki){var e=ze;ze<<=1,!(ze&3932160)&&(ze=262144),$l=e}else $l=536870912}return e=Qa.current,e!==null&&(e.flags|=32),$l}function q(e,t,n){(e===Bl&&(Ul===2||Ul===9)||e.cancelPendingCommit!==null)&&(Cu(e,0),bu(e,Hl,$l,!1)),qe(e,n),(!(zl&2)||e!==Bl)&&(e===Bl&&(!(zl&2)&&(Zl|=n),Yl===4&&bu(e,Hl,$l,!1)),id(e))}function vu(e,t,n){if(zl&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||Ue(e,t),a=r?Au(e,t):ku(e,t,!0),o=r;do{if(a===0){Kl&&!r&&bu(e,t,0,!1);break}if(n=e.current.alternate,o&&!nee(n)){a=ku(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=tu;var l=c.current.memoizedState.isDehydrated;if(l&&(Cu(c,s).flags|=256),s=ku(c,s,!1),s!==2){if(ql&&!l){c.errorRecoveryDisabledLanes|=o,Zl|=o,a=4;break a}o=nu,nu=a,o!==null&&(nu===null?nu=o:nu.push.apply(nu,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Cu(e,0),bu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:bu(r,t,$l,!Gl);break a;case 2:nu=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=iu+300-z(),10<a)){if(bu(r,t,$l,!Gl),He(r,0,!0)!==0)break a;du=t,r.timeoutHandle=Yd(yu.bind(null,r,n,nu,su,ru,t,$l,Zl,eu,Gl,o,`Throttled`,-0,0),a);break a}yu(r,n,nu,su,ru,t,$l,Zl,eu,Gl,o,null,-0,0)}break}while(1);id(e)}function yu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Xt},Ml(t,a,d);var m=(a&62914560)===a?iu-z():(a&4194048)===a?au-z():0;if(m=Xf(d,m),m!==null){du=a,e.cancelPendingCommit=m(Lu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),bu(e,a,o,!l);return}}Lu(e,t,a,n,r,i,o,s,c)}function nee(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!vr(a(),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 bu(e,t,n,r){t&=~Ql,t&=~Zl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Pe(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Ye(e,n,t)}function xu(){return zl&6?!0:(ad(0,!1),!1)}function Su(){if(Vl!==null){if(Ul===0)var e=Vl.return;else e=Vl,Hi=Vi=null,Eo(e),Da=null,Oa=0,e=Vl;for(;e!==null;)Bc(e.alternate,e),e=e.return;Vl=null}}function Cu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Xd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),du=0,Su(),Bl=e,Vl=n=ii(e.current,null),Hl=t,Ul=0,Wl=null,Gl=!1,Kl=Ue(e,t),ql=!1,eu=$l=Ql=Zl=Xl=Yl=0,nu=tu=null,ru=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Pe(r),a=1<<i;t|=e[i],r&=~a}return Jl=t,Yr(),n}function wu(e,t){co=null,I.H=Ls,t===_a||t===ya?(t=Ta(),Ul=3):t===va?(t=Ta(),Ul=4):Ul=t===tc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Wl=t,Vl===null&&(Yl=1,Ys(e,fi(t,e.current)))}function Tu(){var e=Qa.current;return e===null?!0:(Hl&4194048)===Hl?$a===null:(Hl&62914560)===Hl||Hl&536870912?e===$a:!1}function Eu(){var e=I.H;return I.H=Ls,e===null?Ls:e}function Du(){var e=I.A;return I.A=Ll,e}function Ou(){Yl=4,Gl||(Hl&4194048)!==Hl&&Qa.current!==null||(Kl=!0),!(Xl&134217727)&&!(Zl&134217727)||Bl===null||bu(Bl,Hl,$l,!1)}function ku(e,t,n){var r=zl;zl|=2;var i=Eu(),a=Du();(Bl!==e||Hl!==t)&&(su=null,Cu(e,t)),t=!1;var o=Yl;a:do try{if(Ul!==0&&Vl!==null){var s=Vl,c=Wl;switch(Ul){case 8:Su(),o=6;break a;case 3:case 2:case 9:case 6:Qa.current===null&&(t=!0);var l=Ul;if(Ul=0,Wl=null,Pu(e,s,c,l),n&&Kl){o=0;break a}break;default:l=Ul,Ul=0,Wl=null,Pu(e,s,c,l)}}J(),o=Yl;break}catch(t){wu(e,t)}while(1);return t&&e.shellSuspendCounter++,Hi=Vi=null,zl=r,I.H=i,I.A=a,Vl===null&&(Bl=null,Hl=0,Yr()),o}function J(){for(;Vl!==null;)Mu(Vl)}function Au(e,t){var n=zl;zl|=2;var r=Eu(),a=Du();Bl!==e||Hl!==t?(su=null,ou=z()+500,Cu(e,t)):Kl=Ue(e,t);a:do try{if(Ul!==0&&Vl!==null){t=Vl;var o=Wl;b:switch(Ul){case 1:Ul=0,Wl=null,Pu(e,t,o,1);break;case 2:case 9:if(xa(o)){Ul=0,Wl=null,Nu(t);break}t=function(){Ul!==2&&Ul!==9||Bl!==e||(Ul=7),id(e)},o.then(t,t);break a;case 3:Ul=7;break a;case 4:Ul=5;break a;case 7:xa(o)?(Ul=0,Wl=null,Nu(t)):(Ul=0,Wl=null,Pu(e,t,o,7));break;case 5:var s=null;switch(Vl.tag){case 26:s=Vl.memoizedState;case 5:case 27:var c=Vl;if(s?qf(s):c.stateNode.complete){Ul=0,Wl=null;var l=c.sibling;if(l!==null)Vl=l;else{var u=c.return;u===null?Vl=null:(Vl=u,Fu(u))}break b}}Ul=0,Wl=null,Pu(e,t,o,5);break;case 6:Ul=0,Wl=null,Pu(e,t,o,6);break;case 8:Su(),Yl=6;break a;default:throw Error(i(462))}}ju();break}catch(t){wu(e,t)}while(1);return Hi=Vi=null,I.H=r,I.A=a,zl=n,Vl===null?(Bl=null,Hl=0,Yr(),Yl):0}function ju(){for(;Vl!==null&&!Ce();)Mu(Vl)}function Mu(e){var t=jc(e.alternate,e,Jl);e.memoizedProps=e.pendingProps,t===null?Fu(e):Vl=t}function Nu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=hc(n,t,t.pendingProps,t.type,void 0,Hl);break;case 11:t=hc(n,t,t.pendingProps,t.type.render,t.ref,Hl);break;case 5:Eo(t);default:Bc(n,t),t=Vl=ai(t,Jl),t=jc(n,t,Jl)}e.memoizedProps=e.pendingProps,t===null?Fu(e):Vl=t}function Pu(e,t,n,r){Hi=Vi=null,Eo(t),Da=null,Oa=0;var i=t.return;try{if(ec(e,i,t,n,Hl)){Yl=1,Ys(e,fi(n,e.current)),Vl=null;return}}catch(t){if(i!==null)throw Vl=i,t;Yl=1,Ys(e,fi(n,e.current)),Vl=null;return}t.flags&32768?(ki||r===1?e=!0:Kl||Hl&536870912?e=!1:(Gl=e=!0,(r===2||r===9||r===3||r===6)&&(r=Qa.current,r!==null&&r.tag===13&&(r.flags|=16384))),Iu(t,e)):Fu(t)}function Fu(e){var t=e;do{if(t.flags&32768){Iu(t,Gl);return}e=t.return;var n=Rc(t.alternate,t,Jl);if(n!==null){Vl=n;return}if(t=t.sibling,t!==null){Vl=t;return}Vl=t=e}while(t!==null);Yl===0&&(Yl=5)}function Iu(e,t){do{var n=zc(e.alternate,e);if(n!==null){n.flags&=32767,Vl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Vl=e;return}Vl=e=n}while(e!==null);Yl=6,Vl=null}function Lu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Hu();while(cu!==0);if(zl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Jr,Je(e,n,o,s,c,l),e===Bl&&(Vl=Bl=null,Hl=0),uu=t,lu=e,du=n,fu=o,pu=a,mu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Zu(V,function(){return Uu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=I.T,I.T=null,a=L.p,L.p=2,s=zl,zl|=4;try{al(e,t,n)}finally{zl=s,L.p=a,I.T=r}}cu=1,Ru(),zu(),Bu()}}function Ru(){if(cu===1){cu=0;var e=lu,t=uu,n=!!(t.flags&13878);if(t.subtreeFlags&13878||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=zl;zl|=4;try{vl(t,e);var a=Hd,o=Cr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Sr(s.ownerDocument.documentElement,s)){if(c!==null&&wr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=xr(s,h),v=xr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}up=!!Vd,Hd=Vd=null}finally{zl=i,L.p=r,I.T=n}}e.current=t,cu=2}}function zu(){if(cu===2){cu=0;var e=lu,t=uu,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=zl;zl|=4;try{ol(e,t.alternate,t)}finally{zl=i,L.p=r,I.T=n}}cu=3}}function Bu(){if(cu===4||cu===3){cu=0,we();var e=lu,t=uu,n=du,r=mu;t.subtreeFlags&10256||t.flags&10256?cu=5:(cu=0,uu=lu=null,Vu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(G=null),$e(n),t=t.stateNode,Me&&typeof Me.onCommitFiberRoot==`function`)try{Me.onCommitFiberRoot(je,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=I.T,i=L.p,L.p=2,I.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{I.T=t,L.p=i}}du&3&&Hu(),id(e),i=e.pendingLanes,n&261930&&i&42?e===gu?hu++:(hu=0,gu=e):hu=0,ad(0,!1)}}function Vu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ia(t)))}function Hu(){return Ru(),zu(),Bu(),Uu()}function Uu(){if(cu!==5)return!1;var e=lu,t=fu;fu=0;var n=$e(du),r=I.T,a=L.p;try{L.p=32>n?32:n,I.T=null,n=pu,pu=null;var o=lu,s=du;if(cu=0,uu=lu=null,du=0,zl&6)throw Error(i(331));var c=zl;if(zl|=4,Fl(o.current),Dl(o,o.current,s,n),zl=c,ad(0,!1),Me&&typeof Me.onPostCommitFiberRoot==`function`)try{Me.onPostCommitFiberRoot(je,o)}catch{}return!0}finally{L.p=a,I.T=r,Vu(e,t)}}function Wu(e,t,n){t=fi(n,t),t=Zs(e.stateNode,t,2),e=za(e,t,2),e!==null&&(qe(e,2),id(e))}function Gu(e,t,n){if(e.tag===3)Wu(e,e,n);else for(;t!==null;){if(t.tag===3){Wu(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(G===null||!G.has(r))){e=fi(n,e),n=Qs(2),r=za(t,n,2),r!==null&&($s(n,r,t,e),qe(r,2),id(r));break}}t=t.return}}function Ku(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Rl;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)||(ql=!0,i.add(n),e=qu.bind(null,e,t,n),t.then(e,e))}function qu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Bl===e&&(Hl&n)===n&&(Yl===4||Yl===3&&(Hl&62914560)===Hl&&300>z()-iu?!(zl&2)&&Cu(e,0):Ql|=n,eu===Hl&&(eu=0)),id(e)}function Ju(e,t){t===0&&(t=Ge()),e=U(e,t),e!==null&&(qe(e,t),id(e))}function Yu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ju(e,n)}function Xu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Ju(e,n)}function Zu(e,t){return xe(e,t)}var Qu=null,$u=null,ed=!1,td=!1,nd=!1,rd=0;function id(e){e!==$u&&e.next===null&&($u===null?Qu=$u=e:$u=$u.next=e),td=!0,ed||(ed=!0,dd())}function ad(e,t){if(!nd&&td){nd=!0;do for(var n=!1,r=Qu;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Pe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ud(r,a))}else a=Hl,a=He(r,r===Bl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Ue(r,a)||(n=!0,ud(r,a))}r=r.next}while(n);nd=!1}}function od(){sd()}function sd(){td=ed=!1;var e=0;rd!==0&&Jd()&&(e=rd);for(var t=z(),n=null,r=Qu;r!==null;){var i=r.next,a=cd(r,t);a===0?(r.next=null,n===null?Qu=i:n.next=i,i===null&&($u=n)):(n=r,(e!==0||a&3)&&(td=!0)),r=i}cu!==0&&cu!==5||ad(e,!1),rd!==0&&(rd=0)}function cd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Pe(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=We(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Bl,n=Hl,n=He(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Ul===2||Ul===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Se(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Ue(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Se(r),$e(n)){case 2:case 8:n=Ee;break;case 32:n=V;break;case 268435456:n=Oe;break;default:n=V}return r=ld.bind(null,e),n=xe(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Se(r),e.callbackPriority=2,e.callbackNode=null,2}function ld(e,t){if(cu!==0&&cu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Hu()&&e.callbackNode!==n)return null;var r=Hl;return r=He(e,e===Bl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(vu(e,r,t),cd(e,z()),e.callbackNode!=null&&e.callbackNode===n?ld.bind(null,e):null)}function ud(e,t){if(Hu())return null;vu(e,t,!0)}function dd(){Qd(function(){zl&6?xe(Te,od):sd()})}function fd(){if(rd===0){var e=sa;e===0&&(e=Re,Re<<=1,!(Re&261888)&&(Re=256)),rd=e}return rd}function pd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Yt(``+e)}function md(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function hd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=pd((i[it]||null).action),o=r.submitter;o&&(t=(t=o[it]||null)?pd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new vn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(rd!==0){var e=o?md(i,o):new FormData(i);Cs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?md(i,o):new FormData(i),Cs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var gd=0;gd<Ur.length;gd++){var _d=Ur[gd];Wr(_d.toLowerCase(),`on`+(_d[0].toUpperCase()+_d.slice(1)))}Wr(Fr,`onAnimationEnd`),Wr(Ir,`onAnimationIteration`),Wr(Lr,`onAnimationStart`),Wr(`dblclick`,`onDoubleClick`),Wr(`focusin`,`onFocus`),Wr(`focusout`,`onBlur`),Wr(Rr,`onTransitionRun`),Wr(zr,`onTransitionStart`),Wr(Br,`onTransitionCancel`),Wr(Vr,`onTransitionEnd`),bt(`onMouseEnter`,[`mouseout`,`mouseover`]),bt(`onMouseLeave`,[`mouseout`,`mouseover`]),bt(`onPointerEnter`,[`pointerout`,`pointerover`]),bt(`onPointerLeave`,[`pointerout`,`pointerover`]),yt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),yt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),yt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),yt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),yt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),yt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var vd=`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(` `),yd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(vd));function bd(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Gr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Gr(e)}i.currentTarget=null,a=c}}}}function xd(e,t){var n=t[ot];n===void 0&&(n=t[ot]=new Set);var r=e+`__bubble`;n.has(r)||(Td(t,e,2,!1),n.add(r))}function Sd(e,t,n){var r=0;t&&(r|=4),Td(n,e,r,t)}var Cd=`_reactListening`+Math.random().toString(36).slice(2);function wd(e){if(!e[Cd]){e[Cd]=!0,_t.forEach(function(t){t!==`selectionchange`&&(yd.has(t)||Sd(t,!1,e),Sd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Cd]||(t[Cd]=!0,Sd(`selectionchange`,!1,t))}}function Td(e,t,n,r){switch(_p(t)){case 2:var i=dp;break;case 8:i=fp;break;default:i=pp}n=i.bind(null,t,n,e),i=void 0,!sn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Ed(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=ft(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}rn(function(){var r=a,i=Qt(n),s=[];a:{var c=Hr.get(e);if(c!==void 0){var l=vn,u=e;switch(e){case`keypress`:if(pn(n)===0)break a;case`keydown`:case`keyup`:l=Fn;break;case`focusin`:u=`focus`,l=En;break;case`focusout`:u=`blur`,l=En;break;case`beforeblur`:case`afterblur`:l=En;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Tn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=eee;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Ln;break;case Fr:case Ir:case Lr:l=Dn;break;case Vr:l=Rn;break;case`scroll`:case`scrollend`:l=bn;break;case`wheel`:l=zn;break;case`copy`:case`cut`:case`paste`:l=On;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=In;break;case`toggle`:case`beforetoggle`:l=Bn}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=an(m,p),g!=null&&d.push(Dd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Zt&&(u=n.relatedTarget||n.fromElement)&&(ft(u)||u[at]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?ft(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=Tn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=In,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:mt(l),h=u==null?c:mt(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,ft(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=kd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Ad(s,c,l,d,!1),u!==null&&f!==null&&Ad(s,f,u,d,!0)}}a:{if(c=r?mt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=or;else if(er(c)){if(sr)v=gr;else{v=mr;var y=pr}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Kt(r.elementType)&&(v=or):v=hr;if(v&&=v(e,r)){tr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Rt(c,`number`,c.value)}switch(y=r?mt(r):window,e){case`focusin`:(er(y)||y.contentEditable===`true`)&&(Er=y,Dr=r,Or=null);break;case`focusout`:Or=Dr=Er=null;break;case`mousedown`:H=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:H=!1,kr(s,n,i);break;case`selectionchange`:if(Tr)break;case`keydown`:case`keyup`:kr(s,n,i)}var b;if(Hn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Xn?Jn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Gn&&n.locale!==`ko`&&(Xn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Xn&&(b=fn()):(ln=i,un=`value`in ln?ln.value:ln.textContent,Xn=!0)),y=Od(r,x),0<y.length&&(x=new kn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Yn(n),b!==null&&(x.data=b)))),(b=Wn?Zn(e,n):Qn(e,n))&&(x=Od(r,`onBeforeInput`),0<x.length&&(y=new kn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),hd(s,e,r,n,i)}bd(s,t)})}function Dd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Od(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=an(e,n),i!=null&&r.unshift(Dd(e,i,a)),i=an(e,t),i!=null&&r.push(Dd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function kd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Ad(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=an(n,a),l!=null&&o.unshift(Dd(n,l,c))):i||(l=an(n,a),l!=null&&o.push(Dd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var jd=/\r\n?/g,Md=/\u0000|\uFFFD/g;function Nd(e){return(typeof e==`string`?e:``+e).replace(jd,`
|
|
9
9
|
`).replace(Md,``)}function Pd(e,t){return t=Nd(t),Nd(e)===t}function Fd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Ht(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Ht(e,``+r);break;case`className`:Et(e,`class`,r);break;case`tabIndex`:Et(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Et(e,n,r);break;case`style`:Gt(e,r,o);break;case`data`:if(t!==`object`){Et(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Yt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&Fd(e,t,`name`,a.name,a,null),Fd(e,t,`formEncType`,a.formEncType,a,null),Fd(e,t,`formMethod`,a.formMethod,a,null),Fd(e,t,`formTarget`,a.formTarget,a,null)):(Fd(e,t,`encType`,a.encType,a,null),Fd(e,t,`method`,a.method,a,null),Fd(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Yt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Xt);break;case`onScroll`:r!=null&&xd(`scroll`,e);break;case`onScrollEnd`:r!=null&&xd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Yt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:xd(`beforetoggle`,e),xd(`toggle`,e),Tt(e,`popover`,r);break;case`xlinkActuate`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Dt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Dt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Dt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Tt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=qt.get(n)||n,Tt(e,n,r))}}function Id(e,t,n,r,a,o){switch(n){case`style`:Gt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Ht(e,r):(typeof r==`number`||typeof r==`bigint`)&&Ht(e,``+r);break;case`onScroll`:r!=null&&xd(`scroll`,e);break;case`onScrollEnd`:r!=null&&xd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Xt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!vt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[it]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Tt(e,n,r)}}}function Ld(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:xd(`error`,e),xd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Fd(e,t,o,s,n,null)}}a&&Fd(e,t,`srcSet`,n.srcSet,n,null),r&&Fd(e,t,`src`,n.src,n,null);return;case`input`:xd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Fd(e,t,r,d,n,null)}}Lt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in xd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Fd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&zt(e,!!r,n,!0):zt(e,!!r,t,!1);return;case`textarea`:for(s in xd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Fd(e,t,s,c,n,null)}Vt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Fd(e,t,l,r,n,null)}return;case`dialog`:xd(`beforetoggle`,e),xd(`toggle`,e),xd(`cancel`,e),xd(`close`,e);break;case`iframe`:case`object`:xd(`load`,e);break;case`video`:case`audio`:for(r=0;r<vd.length;r++)xd(vd[r],e);break;case`image`:xd(`error`,e),xd(`load`,e);break;case`details`:xd(`toggle`,e);break;case`embed`:case`source`:case`link`:xd(`error`,e),xd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Fd(e,t,u,r,n,null)}return;default:if(Kt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Id(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Fd(e,t,c,r,n,null))}function Rd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Fd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Fd(e,t,p,m,r,f)}}It(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Fd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Fd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?zt(e,!!n,n?[]:``,!1):zt(e,!!n,t,!0)):zt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Fd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Fd(e,t,s,a,r,o)}Bt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Fd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Fd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Fd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Fd(e,t,u,p,r,m)}return;default:if(Kt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Id(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Id(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Fd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Fd(e,t,f,p,r,m)}function zd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Bd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&zd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&zd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Vd=null,Hd=null;function Ud(e){return e.nodeType===9?e:e.ownerDocument}function Wd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Gd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Kd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var qd=null;function Jd(){var e=window.event;return e&&e.type===`popstate`?e!==qd&&(qd=e,!0):(qd=null,!1)}var Yd=typeof setTimeout==`function`?setTimeout:void 0,Xd=typeof clearTimeout==`function`?clearTimeout:void 0,Zd=typeof Promise==`function`?Promise:void 0,Qd=typeof queueMicrotask==`function`?queueMicrotask:Zd===void 0?Yd:function(e){return Zd.resolve(null).then(e).catch($d)};function $d(e){setTimeout(function(){throw e})}function ef(e){return e===`head`}function tf(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===`/$`||n===`/&`){if(r===0){e.removeChild(i),Ip(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)gf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,gf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[ut]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&gf(e.ownerDocument.body)}n=i}while(n);Ip(t)}function nf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function rf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:rf(n),dt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function af(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[ut])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=df(e.nextSibling),e===null)break}return null}function of(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=df(e.nextSibling),e===null))return null;return e}function sf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=df(e.nextSibling),e===null))return null;return e}function cf(e){return e.data===`$?`||e.data===`$~`}function lf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function uf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function df(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===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var ff=null;function pf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return df(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function mf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function hf(e,t,n){switch(t=Ud(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function gf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);dt(e)}var _f=new Map,vf=new Set;function yf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var bf=L.d;L.d={f:xf,r:Sf,D:Tf,C:Ef,L:Df,m:Of,X:Af,S:kf,M:jf};function xf(){var e=bf.f(),t=xu();return e||t}function Sf(e){var t=pt(e);t!==null&&t.tag===5&&t.type===`form`?Ts(t):bf.r(e)}var Cf=typeof document>`u`?null:document;function wf(e,t,n){var r=Cf;if(r&&typeof t==`string`&&t){var i=Ft(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),vf.has(i)||(vf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Ld(t,`link`,e),gt(t),r.head.appendChild(t)))}}function Tf(e){bf.D(e),wf(`dns-prefetch`,e,null)}function Ef(e,t){bf.C(e,t),wf(`preconnect`,e,t)}function Df(e,t,n){bf.L(e,t,n);var r=Cf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ft(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ft(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ft(n.imageSizes)+`"]`)):i+=`[href="`+Ft(e)+`"]`;var a=i;switch(t){case`style`:a=Nf(e);break;case`script`:a=Lf(e)}_f.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),_f.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Pf(a))||t===`script`&&r.querySelector(Rf(a))||(t=r.createElement(`link`),Ld(t,`link`,e),gt(t),r.head.appendChild(t)))}}function Of(e,t){bf.m(e,t);var n=Cf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ft(r)+`"][href="`+Ft(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Lf(e)}if(!_f.has(a)&&(e=f({rel:`modulepreload`,href:e},t),_f.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Rf(a)))return}r=n.createElement(`link`),Ld(r,`link`,e),gt(r),n.head.appendChild(r)}}}function kf(e,t,n){bf.S(e,t,n);var r=Cf;if(r&&e){var i=ht(r).hoistableStyles,a=Nf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Pf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=_f.get(a))&&Vf(e,n);var c=o=r.createElement(`link`);gt(c),Ld(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Bf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Af(e,t){bf.X(e,t);var n=Cf;if(n&&e){var r=ht(n).hoistableScripts,i=Lf(e),a=r.get(i);a||(a=n.querySelector(Rf(i)),a||(e=f({src:e,async:!0},t),(t=_f.get(i))&&Hf(e,t),a=n.createElement(`script`),gt(a),Ld(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function jf(e,t){bf.M(e,t);var n=Cf;if(n&&e){var r=ht(n).hoistableScripts,i=Lf(e),a=r.get(i);a||(a=n.querySelector(Rf(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=_f.get(i))&&Hf(e,t),a=n.createElement(`script`),gt(a),Ld(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mf(e,t,n,r){var a=(a=se.current)?yf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Nf(n.href),n=ht(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Nf(n.href);var o=ht(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Pf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),_f.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},_f.set(e,n),o||If(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Lf(n),n=ht(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Nf(e){return`href="`+Ft(e)+`"`}function Pf(e){return`link[rel="stylesheet"][`+e+`]`}function Ff(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function If(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Ld(t,`link`,n),gt(t),e.head.appendChild(t))}function Lf(e){return`[src="`+Ft(e)+`"]`}function Rf(e){return`script[async]`+e}function zf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ft(n.href)+`"]`);if(r)return t.instance=r,gt(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),gt(r),Ld(r,`style`,a),Bf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Nf(n.href);var o=e.querySelector(Pf(a));if(o)return t.state.loading|=4,t.instance=o,gt(o),o;r=Ff(n),(a=_f.get(a))&&Vf(r,a),o=(e.ownerDocument||e).createElement(`link`),gt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Ld(o,`link`,r),t.state.loading|=4,Bf(o,n.precedence,e),t.instance=o;case`script`:return o=Lf(n.src),(a=e.querySelector(Rf(o)))?(t.instance=a,gt(a),a):(r=n,(a=_f.get(o))&&(r=f({},n),Hf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),gt(a),Ld(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Bf(r,n.precedence,e));return t.instance}function Bf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Vf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Hf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Uf=null;function Wf(e,t,n){if(Uf===null){var r=new Map,i=Uf=new Map;i.set(n,r)}else i=Uf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[ut]||a[rt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Gf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Kf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function qf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Jf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Nf(r.href),a=t.querySelector(Pf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Zf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,gt(a);return}a=t.ownerDocument||t,r=Ff(r),(i=_f.get(i))&&Vf(r,i),a=a.createElement(`link`),gt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Ld(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Zf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Yf=0;function Xf(e,t){return e.stylesheets&&e.count===0&&$f(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&$f(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Yf===0&&(Yf=62500*Bd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&$f(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Yf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Zf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)$f(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Qf=null;function $f(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Qf=new Map,t.forEach(ep,e),Qf=null,Zf.call(e))}function ep(e,t){if(!(t.state.loading&4)){var n=Qf.get(e);if(n)var r=n.get(null);else{n=new Map,Qf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Zf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var tp={$$typeof:C,Provider:null,Consumer:null,_currentValue:R,_currentValue2:R,_threadCount:0};function np(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ke(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ke(0),this.hiddenUpdates=Ke(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function rp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new np(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ni(3,null,null,t),e.current=a,a.stateNode=e,t=ra(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ia(a),e}function ip(e){return e?(e=ei,e):ei}function ap(e,t,n,r,i,a){i=ip(i),r.context===null?r.context=i:r.pendingContext=i,r=Ra(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=za(e,r,t),n!==null&&(q(n,e,t),Ba(n,e,t))}function op(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function sp(e,t){op(e,t),(e=e.alternate)&&op(e,t)}function cp(e){if(e.tag===13||e.tag===31){var t=U(e,67108864);t!==null&&q(t,e,67108864),sp(e,67108864)}}function lp(e){if(e.tag===13||e.tag===31){var t=K();t=Qe(t);var n=U(e,t);n!==null&&q(n,e,t),sp(e,t)}}var up=!0;function dp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=2,pp(e,t,n,r)}finally{L.p=a,I.T=i}}function fp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=8,pp(e,t,n,r)}finally{L.p=a,I.T=i}}function pp(e,t,n,r){if(up){var i=mp(r);if(i===null)Ed(e,t,r,hp,n),Ep(e,r);else if(Op(i,e,t,n,r))r.stopPropagation();else if(Ep(e,r),t&4&&-1<Tp.indexOf(e)){for(;i!==null;){var a=pt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ve(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Pe(o);s.entanglements[1]|=c,o&=~c}id(a),!(zl&6)&&(ou=z()+500,ad(0,!1))}}break;case 31:case 13:s=U(a,2),s!==null&&q(s,a,2),xu(),sp(a,2)}if(a=mp(r),a===null&&Ed(e,t,r,hp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Ed(e,t,r,null,n)}}function mp(e){return e=Qt(e),gp(e)}var hp=null;function gp(e){if(hp=null,e=ft(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(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 hp=e,null}function _p(e){switch(e){case`beforetoggle`: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`toggle`: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 2;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`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(B()){case Te:return 2;case Ee:return 8;case V:case De:return 32;case Oe:return 268435456;default:return 32}default:return 32}}var vp=!1,yp=null,bp=null,xp=null,Sp=new Map,Cp=new Map,wp=[],Tp=`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`.split(` `);function Ep(e,t){switch(e){case`focusin`:case`focusout`:yp=null;break;case`dragenter`:case`dragleave`:bp=null;break;case`mouseover`:case`mouseout`:xp=null;break;case`pointerover`:case`pointerout`:Sp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Cp.delete(t.pointerId)}}function Dp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=pt(t),t!==null&&cp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Op(e,t,n,r,i){switch(t){case`focusin`:return yp=Dp(yp,e,t,n,r,i),!0;case`dragenter`:return bp=Dp(bp,e,t,n,r,i),!0;case`mouseover`:return xp=Dp(xp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Sp.set(a,Dp(Sp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Cp.set(a,Dp(Cp.get(a)||null,e,t,n,r,i)),!0}return!1}function kp(e){var t=ft(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,tt(e.priority,function(){lp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,tt(e.priority,function(){lp(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 Ap(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=mp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Zt=r,n.target.dispatchEvent(r),Zt=null}else return t=pt(n),t!==null&&cp(t),e.blockedOn=n,!1;t.shift()}return!0}function jp(e,t,n){Ap(e)&&n.delete(t)}function Mp(){vp=!1,yp!==null&&Ap(yp)&&(yp=null),bp!==null&&Ap(bp)&&(bp=null),xp!==null&&Ap(xp)&&(xp=null),Sp.forEach(jp),Cp.forEach(jp)}function Np(e,n){e.blockedOn===n&&(e.blockedOn=null,vp||(vp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Mp)))}var Pp=null;function Fp(e){Pp!==e&&(Pp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Pp===e&&(Pp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(gp(r||n)===null)continue;break}var a=pt(n);a!==null&&(e.splice(t,3),t-=3,Cs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Ip(e){function t(t){return Np(t,e)}yp!==null&&Np(yp,e),bp!==null&&Np(bp,e),xp!==null&&Np(xp,e),Sp.forEach(t),Cp.forEach(t);for(var n=0;n<wp.length;n++){var r=wp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<wp.length&&(n=wp[0],n.blockedOn===null);)kp(n),n.blockedOn===null&&wp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[it]||null;if(typeof a==`function`)o||Fp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[it]||null)s=o.formAction;else if(gp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Fp(n)}}}function Lp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Rp(e){this._internalRoot=e}zp.prototype.render=Rp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;ap(n,K(),e,t,null,null)},zp.prototype.unmount=Rp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ap(e.current,2,null,e,null,null),xu(),t[at]=null}};function zp(e){this._internalRoot=e}zp.prototype.unstable_scheduleHydration=function(e){if(e){var t=et();e={blockedOn:null,target:e,priority:t};for(var n=0;n<wp.length&&t!==0&&t<wp[n].priority;n++);wp.splice(n,0,e),n===0&&kp(e)}};var Bp=n.version;if(Bp!==`19.2.8`)throw Error(i(527,Bp,`19.2.8`));L.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var Vp={bundleType:0,version:`19.2.8`,rendererPackageName:`react-dom`,currentDispatcherRef:I,reconcilerVersion:`19.2.8`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Hp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hp.isDisabled&&Hp.supportsFiber)try{je=Hp.inject(Vp),Me=Hp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Ks,s=qs,c=Js;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=rp(e,1,!1,null,null,n,r,null,o,s,c,Lp),e[at]=t.current,wd(e),new Rp(t)}})),y=s(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=v()})),b=u(p()),x=u(y());function S(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function C(e,t){if(e){if(typeof e==`string`)return S(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,t):void 0}}function w(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=C(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
10
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function T(e){return e.length>0}var E=Object.freeze({kind:`ok`,value:void 0});function D(e){return e===void 0?E:{kind:`ok`,value:e}}function O(e){return{kind:`err`,error:e}}function k(e){return e===E||e.kind===`ok`}function A(e){return e!==E&&e.kind===`err`}function j(e){var t=[],n=[],r=w(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;k(a)?t.push(a.value):n.push(a.error)}}catch(e){r.e(e)}finally{r.f()}return T(n)?O(n):D(t)}function M(e){return j(e)}function N(e){var t=[],n=w(e),r;try{for(n.s();!(r=n.n()).done;){var i=r.value;A(i)&&t.push(i.error)}}catch(e){n.e(e)}finally{n.f()}return T(t)?O(t):E}function P(e,t){return function(n){for(var r=D(t),i=0;i<n.length&&k(r);++i)r=e(r.value,n[i],i);return r}}function F(e){return function(t){return k(t)?D(e(t.value)):t}}function I(e){return function(t){return k(t)?e(t.value):t}}function L(e){return function(t){return A(t)?O(e(t.error)):t}}function R(e,t){return function(n){return e(n)?D(n):O(t(n))}}var ee=function(e,t){return function(n){return k(n)?e(n.value)?n:O(t(n.value)):n}},te=Object.freeze({__proto__:null,voidOk:E,ok:D,err:O,isOk:k,isErr:A,allT:j,all:M,allV:N,flatMapReduce:P,map:F,flatMap:I,mapErr:L,fromPredicate:R,filterOrElse:ee}),ne=c({default:()=>ge,dependencies:()=>me,description:()=>ae,devDependencies:()=>pe,exports:()=>ue,files:()=>he,main:()=>ce,module:()=>le,name:()=>re,preconstruct:()=>fe,repository:()=>oe,scripts:()=>se,types:()=>de,version:()=>ie}),re,ie,ae,oe,se,ce,le,ue,de,fe,pe,me,he,ge,_e=o((()=>{re=`@valbuild/core`,ie=`0.
|
|
10
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function T(e){return e.length>0}var E=Object.freeze({kind:`ok`,value:void 0});function D(e){return e===void 0?E:{kind:`ok`,value:e}}function O(e){return{kind:`err`,error:e}}function k(e){return e===E||e.kind===`ok`}function A(e){return e!==E&&e.kind===`err`}function j(e){var t=[],n=[],r=w(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;k(a)?t.push(a.value):n.push(a.error)}}catch(e){r.e(e)}finally{r.f()}return T(n)?O(n):D(t)}function M(e){return j(e)}function N(e){var t=[],n=w(e),r;try{for(n.s();!(r=n.n()).done;){var i=r.value;A(i)&&t.push(i.error)}}catch(e){n.e(e)}finally{n.f()}return T(t)?O(t):E}function P(e,t){return function(n){for(var r=D(t),i=0;i<n.length&&k(r);++i)r=e(r.value,n[i],i);return r}}function F(e){return function(t){return k(t)?D(e(t.value)):t}}function I(e){return function(t){return k(t)?e(t.value):t}}function L(e){return function(t){return A(t)?O(e(t.error)):t}}function R(e,t){return function(n){return e(n)?D(n):O(t(n))}}var ee=function(e,t){return function(n){return k(n)?e(n.value)?n:O(t(n.value)):n}},te=Object.freeze({__proto__:null,voidOk:E,ok:D,err:O,isOk:k,isErr:A,allT:j,all:M,allV:N,flatMapReduce:P,map:F,flatMap:I,mapErr:L,fromPredicate:R,filterOrElse:ee}),ne=c({default:()=>ge,dependencies:()=>me,description:()=>ae,devDependencies:()=>pe,exports:()=>ue,files:()=>he,main:()=>ce,module:()=>le,name:()=>re,preconstruct:()=>fe,repository:()=>oe,scripts:()=>se,types:()=>de,version:()=>ie}),re,ie,ae,oe,se,ce,le,ue,de,fe,pe,me,he,ge,_e=o((()=>{re=`@valbuild/core`,ie=`0.120.0`,ae=`Val - supercharged hard-coded content`,oe={type:`git`,url:`git+https://github.com/valbuild/val.git`},se={typecheck:`tsc --noEmit`,test:`jest`,"analyze-trace":`npx tsc -p tsconfig.json --skipLibCheck --generateTrace trace; npx -p @typescript/analyze-trace analyze-trace trace; npx speedscope trace/trace.json`},ce=`dist/valbuild-core.cjs.js`,le=`dist/valbuild-core.esm.js`,ue={".":{module:`./dist/valbuild-core.esm.js`,default:`./dist/valbuild-core.cjs.js`},"./fp":{module:`./fp/dist/valbuild-core-fp.esm.js`,default:`./fp/dist/valbuild-core-fp.cjs.js`},"./patch":{module:`./patch/dist/valbuild-core-patch.esm.js`,default:`./patch/dist/valbuild-core-patch.cjs.js`},"./package.json":`./package.json`},de=`dist/valbuild-core.cjs.d.ts`,fe={entrypoints:[`./index.ts`,`./fp/index.ts`,`./patch/index.ts`],exports:!0},pe={typescript:`^6.0.3`},me={"ts-toolbelt":`^9.6.0`},he=[`CHANGELOG.md`,`dist`,`fp/dist`,`fp/package.json`,`patch/dist`,`patch/package.json`],ge={name:re,version:ie,private:!1,description:ae,repository:oe,scripts:se,main:ce,module:le,exports:ue,types:de,preconstruct:fe,devDependencies:pe,dependencies:me,files:he}}));function ve(e){if(Array.isArray(e))return e}function ye(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function be(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
11
11
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xe(e,t){return ve(e)||ye(e,t)||C(e,t)||be()}function Se(e){if(Array.isArray(e))return S(e)}function Ce(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function we(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
12
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function z(e){return Se(e)||Ce(e)||C(e)||we()}function B(e){"@babel/helpers - typeof";return B=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},B(e)}function Te(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ee(e){var t=Te(e,`string`);return typeof t==`symbol`?t:t+``}function V(e,t,n){return(t=Ee(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function De(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Oe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,Ee(r.key),r)}}function ke(e,t,n){return t&&Oe(e.prototype,t),n&&Oe(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ae(e){return Ae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ae(e)}function je(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(je=function(){return!!e})()}function Me(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function Ne(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return Me(e)}function Pe(e,t,n){return t=Ae(t),Ne(e,je()?Reflect.construct(t,n||[],Ae(e).constructor):t.apply(e,n))}function Fe(e,t){return Fe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Fe(e,t)}function Ie(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Fe(e,t)}var Le=function(){function e(){De(this,e)}return ke(e,[{key:`executeCustomValidateFunctions`,value:function(e,t,n){var r=[],i=w(t),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;try{var s=o(e,n);s&&r.push({message:s,value:e})}catch(t){r.push({message:`Error in custom validate function: ${t instanceof Error?t.message:String(t)}`,value:e,schemaError:!0})}}}catch(e){i.e(e)}finally{i.f()}return r}},{key:`executePreviewItem`,value:function(e){return null}},{key:`declaresItemPreview`,value:function(){return!1}},{key:`appendValidationError`,value:function(e,t,n,r,i){return e?(e[t]?e[t].push({message:n,value:r,schemaError:i}):e[t]=[{message:n,value:r,schemaError:i}],e):V({},t,[{message:n,value:r,schemaError:i}])}},{key:`mergeValidationErrors`,value:function(e,t){if(!t)return e;if(!e)return t;for(var n in t){var r=n;e[r]=e[r]?e[r].concat(t[r]):t[r]}return e}}])}(),Re=Symbol.for(`@valbuild/core/GetSchema`),ze=Symbol.for(`@valbuild/core/Path`),Be=Symbol.for(`@valbuild/core/GetSource`);function Ve(e){return e[Re]}function He(e){return B(e)===`object`&&e!=null&&ze in e&&`val`in e}function Ue(e){return e[ze]}function We(e,t){if(B(t)===`symbol`)throw Error(`Cannot create val path of array item with symbol prop: ${t.toString()}`);if(e)return e.includes(H.ModuleFilePathSep)?`${e}.${JSON.stringify(t)}`:`${e}${H.ModuleFilePathSep}${JSON.stringify(t)}`}function Ge(e,t){if(B(t)===`symbol`)throw Error(`Cannot create val path of array item with symbol prop: ${t.toString()}`);if(!e)throw Error(`Cannot create val path of array item of empty or missing path: ${e}. Item: ${t}`);return e.includes(H.ModuleFilePathSep)?`${e}.${JSON.stringify(t)}`:`${e}${H.ModuleFilePathSep}${JSON.stringify(t)}`}function Ke(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function qe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ke(Object(n),!0).forEach(function(t){V(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ke(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Je=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[],o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,s=arguments.length>5&&arguments[5]!==void 0&&arguments[5],c=arguments.length>6&&arguments[6]!==void 0&&arguments[6],l=arguments.length>7?arguments[7]:void 0,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:null,d=arguments.length>9&&arguments[9]!==void 0&&arguments[9];return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.isRaw=i,n.customValidateFunctions=a,n.renderInput=o,n.isReadonly=s,n.isHidden=c,n.description=l,n.previewInput=u,n.isMultiline=d,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,e??void 0,this.previewInput,this.isMultiline)}},{key:`min`,value:function(e){return this.minLength(e)}},{key:`minLength`,value:function(e){return new t(qe(qe({},this.options),{},{minLength:e}),this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`max`,value:function(e){return this.maxLength(e)}},{key:`maxLength`,value:function(e){return new t(qe(qe({},this.options),{},{maxLength:e}),this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`regexp`,value:function(e,n){return new t(qe(qe({},this.options),{},{regexp:e,regExpMessage:n}),this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions.concat(e),this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`executeValidate`,value:function(e,t){var n,r,i,a=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null?a.length>0&&V({},e,a):!this.opt&&t==null?V({},e,[{message:`Expected 'string', got '${t===null?`null`:`undefined`}'`,value:t}]):typeof t==`string`?((n=this.options)!=null&&n.maxLength&&t.length>this.options.maxLength&&a.push({message:`Expected string to be at most ${this.options.maxLength} characters long, got ${t.length}`,value:t}),(r=this.options)!=null&&r.minLength&&t.length<this.options.minLength&&a.push({message:`Expected string to be at least ${this.options.minLength} characters long, got ${t.length}`,value:t}),(i=this.options)!=null&&i.regexp&&!this.options.regexp.test(t)&&a.push({message:this.options.regExpMessage||`Expected string to match reg exp: ${this.options.regexp.toString()}, got '${t}'`,value:t}),a.length>0&&V({},e,a)):V({},e,[{message:`Expected 'string', got '${B(t)}'`,value:t}])}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null||typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,!0,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,!0,this.description,this.previewInput,this.isMultiline)}},{key:`raw`,value:function(){return new t(this.options,this.opt,!0,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`executeSerialize`,value:function(){return{type:`string`,render:this.renderInput??void 0,multiline:this.isMultiline?!0:void 0,preview:this.previewInput?!0:void 0,options:{maxLength:this.options?.maxLength,minLength:this.options?.minLength,regexp:this.options?.regexp&&{message:this.options.regExpMessage,source:this.options.regexp.source,flags:this.options.regexp.flags},customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0},opt:this.opt,raw:this.isRaw,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`multiline`,value:function(){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,!0)}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,e,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,e,this.isMultiline)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executePreview`,value:function(){return{}}}])}(Le),Ye=function(e){return new Je(e)},Xe=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.items=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.items,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=!1,r=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return r.length>0&&V({},e,r);if(t===null)return V({},e,[{message:`Expected 'object', got 'null'`}]);if(B(t)!==`object`)return V({},e,[{message:`Expected 'object', got '${B(t)}'`}]);if(Array.isArray(t))return V({},e,[{message:`Expected 'object', got 'array'`}]);var i=w(r),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;n=this.appendValidationError(n,e,o.message,t,o.schemaError)}}catch(e){i.e(e)}finally{i.f()}for(var s=0,c=Object.entries(this.items);s<c.length;s++){var l=xe(c[s],2),u=l[0],d=l[1],f=We(e,u);if(!f)n=this.appendValidationError(n,e,`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} at key ${u}`,t);else{var p=d.executeValidate(f,t[u]);n=this.mergeValidationErrors(n,p)}}return n}},{key:`executeAssert`,value:function(e,t){if(this.opt&&t===null)return{success:!0,data:t};if(t===null)return{success:!1,errors:V({},e,[{message:`Expected 'object', got 'null'`,typeError:!0}])};if(B(t)!==`object`)return{success:!1,errors:V({},e,[{message:`Expected 'object', got '${B(t)}'`,typeError:!0}])};if(Array.isArray(t))return{success:!1,errors:V({},e,[{message:`Expected 'object', got 'array'`,typeError:!0}])};for(var n=[],r=0,i=Object.keys(this.items);r<i.length;r++){var a=i[r];We(e,a)?a in t||n.push({message:`Expected key '${a}' not found in object`,typeError:!0}):n.push({message:`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} at key ${a}`,internalError:!0})}return n.length>0?{success:!1,errors:V({},e,n)}:{success:!0,data:t}}},{key:`nullable`,value:function(){return new t(this.items,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.items,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.items,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`object`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,items:Object.fromEntries(Object.entries(this.items).map(function(e){var t=xe(e,2);return[t[0],t[1].executeSerialize()]})),opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(e,t,n){var r={};if(t===null)return r;for(var i in this.items){var a=t[i];if(a!=null){var o=Ge(e,i);if(!(n!==void 0&&!n.wantsUnder(o))){var s=this.items[i].executePreview(o,a,n);for(var c in s){var l=c;r[l]=s[l]}}}}return r}}])}(Le),Ze=function(e){return new Xe(e)};Ze({get test(){return Ye()}});var Qe=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.item=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.previewInput=c,n.renderInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.previewInput,this.renderInput)}},{key:`validate`,value:function(e){return new t(this.item,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.previewInput,this.renderInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeAssert(e,t);if(!n.success)return n.errors;if(n.data===null)return!1;for(var r=!1,i=0,a=Object.entries(n.data);i<a.length;i++){var o=xe(a[i],2),s=o[0],c=o[1],l=Ge(e,Number(s)),u=this.item.executeValidate(l,c);r=this.mergeValidationErrors(r,u)}return r}},{key:`executeAssert`,value:function(e,t){return t===null&&this.opt?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'array', got 'null'`,typeError:!0}])}:B(t)===`object`?Array.isArray(t)?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected object of type 'array'`,typeError:!0}])}:{success:!1,errors:V({},e,[{message:`Expected 'object', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.item,!0,[],this.isReadonly,this.isHidden,this.description,this.previewInput,this.renderInput)}},{key:`readonly`,value:function(){return new t(this.item,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.previewInput,this.renderInput)}},{key:`hidden`,value:function(){return new t(this.item,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.previewInput,this.renderInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`executeSerialize`,value:function(){return{type:`array`,render:this.renderInput??void 0,item:this.item.executeSerialize(),opt:this.opt,preview:this.previewInput?!0:void 0,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(e,t,n){var r={};if(t===null)return r;for(var i=0;i<t.length;i++){var a=i,o=t[a];if(o!=null){var s=Ge(e,a);if(!(n!==void 0&&!n.wantsUnder(s))){var c=this.item.executePreview(s,o,n);for(var l in c){var u=l;r[u]=c[u]}}}}if(this.item.declaresItemPreview()){for(var d=n!==void 0&&!n.wants(e)?n:null,f=[],p=0;p<t.length;p++){var m=t[p];if(m!=null&&!(d!==null&&!d.wantsUnder(Ge(e,p))))try{var h=this.item.executePreviewItem(m);if(h!==null){var g=h.title,_=h.subtitle,v=h.image;f.push([p,{title:g,subtitle:_,image:v}])}}catch(t){r[Ge(e,p)]={status:`error`,message:t instanceof Error?t.message:`Unknown error`}}}r[e]={status:`success`,data:{parent:`array`,items:f}}}return r}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`preview`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.renderInput)}},{key:`render`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.previewInput,e)}}])}(Le),$e=function(e){return new Qe(e)},et=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.value=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.value,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.value,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null?n.length>0&&V({},e,n):typeof t==`string`?t===this.value?n.length>0&&V({},e,n):V({},e,[].concat(z(n),[{message:`Expected literal '${this.value}', got '${t}'`,value:t}])):V({},e,[].concat(z(n),[{message:`Expected 'string', got '${B(t)}'`,value:t}]))}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'string', got 'null'`,typeError:!0}])}:typeof t==`string`&&t===this.value?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected literal '${this.value}', got '${t}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.value,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.value,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.value,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.value,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.value,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`literal`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,value:this.value,opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),tt=function(e){return new et(e)},nt=function(e){function t(e,n){var r,i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5&&arguments[5]!==void 0&&arguments[5],c=arguments.length>6?arguments[6]:void 0,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:null;return De(this,t),r=Pe(this,t),r.key=e,r.items=n,r.opt=i,r.customValidateFunctions=a,r.isReadonly=o,r.isHidden=s,r.description=c,r.renderInput=l,r.previewInput=u,r}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.key,this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.key,this.items,this.opt,this.customValidateFunctions.concat(e),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e}),r=t;if(this.opt&&r===null)return n.length>0&&V({},e,n);if(!this.key)return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Missing required first argument in union`,schemaError:!0}]));var i=this.key;if(!Array.isArray(this.items))return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`A union schema must take more than 1 schema arguments`,schemaError:!0}]));if(typeof i==`string`){if(this.items.some(function(e){return!(e instanceof Xe)}))return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Key is a string, so all schema items must be objects`,schemaError:!0}]));var a=this.items,o=a.map(function(e){return e.executeSerialize()}),s=o.filter(function(e){return e.type!==`object`||e.items[i].type!==`literal`});if(s.length>0)return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`All schema items must be objects with a key: ${i} that is a literal schema. Found: ${JSON.stringify(s,null,2)}`,schemaError:!0}]));var c=o;if(c.filter(function(e){return e.items[i].opt}).length>1)return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Schema cannot have an optional keys: ${i}`,schemaError:!0}]));if(B(r)!==`object`)return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Expected an object`,typeError:!0}]));var l=r;if(l[i]===void 0)return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Missing required key: ${i}`,typeError:!0}]));var u=[],d=w(c),f;try{for(d.s();!(f=d.n()).done;){var p=f.value.items[i];if(p.type===`literal`){if(!u.includes(p.value))u.push(p.value);else return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Found duplicate key in schema: ${p.value}`,schemaError:!0}]))}}}catch(e){d.e(e)}finally{d.f()}var m=a.find(function(t){return!t.items[i].executeValidate(e,l[i])});if(!m){var h=We(e,i);if(!h)throw Error(`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} at key ${i}`);return V({},h,[{message:`Invalid key: "${i}". Value was: "${l[i]}". Valid values: ${c.map(function(e){var t=e.items[i];if(t.type===`literal`&&t.value)return`"${t.value}"`;throw Error(`Expected literal schema, got ${JSON.stringify(t,null,2)}`)}).join(`, `)}`}])}var g=m.executeValidate(e,l);if(g)return g}else if(i instanceof et){if(this.items.some(function(e){return!(e instanceof et)}))return V({},e,[{message:`Key is a literal schema, so all schema items must be literals`,typeError:!0}]);var _=[i].concat(z(this.items));if(typeof r==`string`&&!_.some(function(t){return!t.executeValidate(e,r)}))return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Union must match one of the following: ${_.map(function(e){return`"${e.value}"`}).join(`, `)}`}]))}else return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Expected a string or literal`}]));return n.length>0&&V({},e,n)}},{key:`executeAssert`,value:function(e,t){if(this.opt&&t===null)return{success:!0,data:t};if(t===null)return{success:!1,errors:V({},e,[{message:`Expected 'object', got 'null'`,typeError:!0}])};if(!this.key)return{success:!1,errors:V({},e,[{message:`Missing required first argument in union schema`,schemaError:!0}])};if(!Array.isArray(this.items))return{success:!1,errors:V({},e,[{message:`The schema of this value is wrong. Schema is neither a union of literals nor a tagged union (of objects)`,schemaError:!0}])};if(this.key instanceof et){var n,r=!1,i={},a=w((n=[this.key]).concat.apply(n,z(this.items))),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;if(!(s instanceof et))return{success:!1,errors:V({},e,[{message:`Schema of value is a union of string, so all schema items must be literals`,schemaError:!0}])};if(typeof t!=`string`){i[e]=[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}];continue}var c=s.executeAssert(e,t);if(c.success){r=!0;break}for(var l=0,u=Object.entries(c.errors);l<u.length;l++){var d,f=xe(u[l],2),p=f[0],m=f[1];i[p]||(i[p]=[]),(d=i[p]).push.apply(d,z(m))}}}catch(e){a.e(e)}finally{a.f()}return r?{success:!0,data:t}:{success:!1,errors:i}}if(typeof this.key==`string`){var h=!1,g={},_=w(this.items),v;try{for(_.s();!(v=_.n()).done;){var y=v.value.executeAssert(e,t);if(y.success){h=!0;break}for(var b=0,x=Object.entries(y.errors);b<x.length;b++){var S,C=xe(x[b],2),T=C[0],E=C[1];g[T]||(g[T]=[]),(S=g[T]).push.apply(S,z(E))}}}catch(e){_.e(e)}finally{_.f()}return h?{success:!0,data:t}:{success:!1,errors:g}}return{success:!1,errors:V({},e,[{message:`The schema of this value is wrong. Schema is neither a union of literals nor a tagged union (of objects)`,schemaError:!0}])}}},{key:`nullable`,value:function(){return new t(this.key,this.items,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.key,this.items,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.key,this.items,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e}),r=this.matchedVariant(t);return r&&n.push.apply(n,z(r.executeCustomValidateAt(e,t))),n}},{key:`matchedVariant`,value:function(e){var t=this.key;if(typeof t!=`string`||!Array.isArray(this.items)||e===null||B(e)!==`object`||Array.isArray(e))return null;var n=e[t];if(typeof n!=`string`)return null;var r=this.items,i=w(r),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;if(o instanceof Xe){var s=o.items[t];if(s instanceof et&&s.value===n)return o}}}catch(e){i.e(e)}finally{i.f()}return null}},{key:`render`,value:function(e){return new t(this.key,this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.key,this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){if(this.previewInput!==null)return this.previewInput({val:e});var t=this.matchedVariant(e);return t?t.executePreviewItem(e):null}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null||Array.isArray(this.items)&&this.items.some(function(e){return e.declaresItemPreview()})}},{key:`executeSerialize`,value:function(){return typeof this.key==`string`?{type:`union`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,key:this.key,items:this.items.map(function(e){return e.executeSerialize()}),opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}:{type:`union`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,key:this.key.executeSerialize(),items:this.items.map(function(e){return e.executeSerialize()}),opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(e,t,n){var r={};if(t===null||this.key instanceof et)return r;var i=this.key;if(typeof i==`string`){var a=this.items.find(function(e){if(e instanceof Xe){var n=e.items[i];if(n instanceof et)return B(t)===`object`&&i in t&&n.value===t[i]}return!1});if(a){var o=a.executePreview(e,t,n);for(var s in o){var c=s;r[c]=o[c]}return r}r[e]={status:`error`,message:`Could not find a matching (object) schema for the union key: ${i}`}}return r[e]={status:`error`,message:`The schema of this value is wrong. Expected a object union schema, but union key is not a string. Got: '${JSON.stringify(i,null,2)}'`},r}}])}(Le),rt=function(e){return new nt(e,[...arguments].slice(1))},it=/^(https?:\/\/[^/]+)\/file\/p\/([^/]+)\/b\/([^/]+)\/v\/([^/]+)\/h\/([^/]+)\/f\/([^/]+)\/p\/(.+)$/;function at(e){if(e[0]===`/`)return{status:`error`,error:`Not a remote ref: `+e};var t=e.match(it);return!t||t[7].indexOf(`public/`)!==0||t[7].split(`/`).some(function(e){return e===`.`||e===`..`})?{status:`error`,error:`Invalid remote ref: `+e}:{status:`success`,remoteHost:t[1],projectId:t[2],bucket:t[3],version:t[4],validationHash:t[5],fileHash:t[6],filePath:t[7]}}function ot(e){return!e.startsWith(`/public`)}function st(e){var t=e.path;if(!ot(t))return e.patch_id?`/api/val/files${t}?patch_id=${e.patch_id}`:t.slice(7);if(e.patch_id){var n=at(t);return n.status===`success`?`/api/val/files/${n.filePath}?patch_id=${e.patch_id}&remote=true&ref=${encodeURIComponent(t)}`:`${t}?patch_id=${e.patch_id}`}return t}function ct(e){return qe(qe({},e),{},{url:st(e)})}function lt(e){return B(e)===`object`&&e!==null&&`type`in e&&(e.type===`image`||e.type===`file`)}function ut(e,t,n){if(!lt(t)||!t.referencedModule)return e;var r=n(t.referencedModule);if(!r||B(r)!==`object`||Array.isArray(r))return e;var i=r,a=e.path in i?e.path:null;if(a===null){var o=at(e.path);o.status===`success`&&o.filePath in i&&(a=o.filePath)}if(a===null)return e;var s=i[a];if(!s||B(s)!==`object`||Array.isArray(s))return e;var c=s,l=c.width,u=c.height,d=c.mimeType,f=c.alt,p=typeof e.alt==`string`;return qe(qe(qe(qe(qe({},e),l===void 0?{}:{width:l}),u===void 0?{}:{height:u}),d===void 0?{}:{mimeType:d}),!p&&typeof f==`string`?{alt:f}:{})}var dt={x3d:`application/vnd.hzn-3d-crossword`,"3gp":`video/3gpp`,"3g2":`video/3gpp2`,mseq:`application/vnd.mseq`,pwn:`application/vnd.3m.post-it-notes`,plb:`application/vnd.3gpp.pic-bw-large`,psb:`application/vnd.3gpp.pic-bw-small`,pvb:`application/vnd.3gpp.pic-bw-var`,tcap:`application/vnd.3gpp2.tcap`,"7z":`application/x-7z-compressed`,abw:`application/x-abiword`,ace:`application/x-ace-compressed`,acc:`application/vnd.americandynamics.acc`,acu:`application/vnd.acucobol`,atc:`application/vnd.acucorp`,adp:`audio/adpcm`,aab:`application/x-authorware-bin`,aam:`application/x-authorware-map`,aas:`application/x-authorware-seg`,air:`application/vnd.adobe.air-application-installer-package+zip`,avif:`image/avif`,swf:`application/x-shockwave-flash`,fxp:`application/vnd.adobe.fxp`,pdf:`application/pdf`,ppd:`application/vnd.cups-ppd`,dir:`application/x-director`,xdp:`application/vnd.adobe.xdp+xml`,xfdf:`application/vnd.adobe.xfdf`,aac:`audio/x-aac`,ahead:`application/vnd.ahead.space`,azf:`application/vnd.airzip.filesecure.azf`,azs:`application/vnd.airzip.filesecure.azs`,azw:`application/vnd.amazon.ebook`,ami:`application/vnd.amiga.ami`,"N/A":`application/andrew-inset`,apk:`application/vnd.android.package-archive`,cii:`application/vnd.anser-web-certificate-issue-initiation`,fti:`application/vnd.anser-web-funds-transfer-initiation`,atx:`application/vnd.antix.game-component`,dmg:`application/x-apple-diskimage`,mpkg:`application/vnd.apple.installer+xml`,aw:`application/applixware`,mp3:`audio/mpeg`,les:`application/vnd.hhe.lesson-player`,swi:`application/vnd.aristanetworks.swi`,s:`text/x-asm`,atomcat:`application/atomcat+xml`,atomsvc:`application/atomsvc+xml`,atom:`application/atom+xml`,ac:`application/pkix-attr-cert`,aif:`audio/x-aiff`,avi:`video/x-msvideo`,aep:`application/vnd.audiograph`,dxf:`image/vnd.dxf`,dwf:`model/vnd.dwf`,par:`text/plain-bas`,bcpio:`application/x-bcpio`,bin:`application/octet-stream`,bmp:`image/bmp`,torrent:`application/x-bittorrent`,cod:`application/vnd.rim.cod`,mpm:`application/vnd.blueice.multipass`,bmi:`application/vnd.bmi`,sh:`application/x-sh`,btif:`image/prs.btif`,rep:`application/vnd.businessobjects`,bz:`application/x-bzip`,bz2:`application/x-bzip2`,csh:`application/x-csh`,c:`text/x-c`,cdxml:`application/vnd.chemdraw+xml`,css:`text/css`,cdx:`chemical/x-cdx`,cml:`chemical/x-cml`,csml:`chemical/x-csml`,cdbcmsg:`application/vnd.contact.cmsg`,cla:`application/vnd.claymore`,c4g:`application/vnd.clonk.c4group`,sub:`image/vnd.dvb.subtitle`,cdmia:`application/cdmi-capability`,cdmic:`application/cdmi-container`,cdmid:`application/cdmi-domain`,cdmio:`application/cdmi-object`,cdmiq:`application/cdmi-queue`,c11amc:`application/vnd.cluetrust.cartomobile-config`,c11amz:`application/vnd.cluetrust.cartomobile-config-pkg`,ras:`image/x-cmu-raster`,dae:`model/vnd.collada+xml`,csv:`text/csv`,cpt:`application/mac-compactpro`,wmlc:`application/vnd.wap.wmlc`,cgm:`image/cgm`,ice:`x-conference/x-cooltalk`,cmx:`image/x-cmx`,xar:`application/vnd.xara`,cmc:`application/vnd.cosmocaller`,cpio:`application/x-cpio`,clkx:`application/vnd.crick.clicker`,clkk:`application/vnd.crick.clicker.keyboard`,clkp:`application/vnd.crick.clicker.palette`,clkt:`application/vnd.crick.clicker.template`,clkw:`application/vnd.crick.clicker.wordbank`,wbs:`application/vnd.criticaltools.wbs+xml`,cryptonote:`application/vnd.rig.cryptonote`,cif:`chemical/x-cif`,cmdf:`chemical/x-cmdf`,cu:`application/cu-seeme`,cww:`application/prs.cww`,curl:`text/vnd.curl`,dcurl:`text/vnd.curl.dcurl`,mcurl:`text/vnd.curl.mcurl`,scurl:`text/vnd.curl.scurl`,car:`application/vnd.curl.car`,pcurl:`application/vnd.curl.pcurl`,cmp:`application/vnd.yellowriver-custom-menu`,dssc:`application/dssc+der`,xdssc:`application/dssc+xml`,deb:`application/x-debian-package`,uva:`audio/vnd.dece.audio`,uvi:`image/vnd.dece.graphic`,uvh:`video/vnd.dece.hd`,uvm:`video/vnd.dece.mobile`,uvu:`video/vnd.uvvu.mp4`,uvp:`video/vnd.dece.pd`,uvs:`video/vnd.dece.sd`,uvv:`video/vnd.dece.video`,dvi:`application/x-dvi`,seed:`application/vnd.fdsn.seed`,dtb:`application/x-dtbook+xml`,res:`application/x-dtbresource+xml`,ait:`application/vnd.dvb.ait`,svc:`application/vnd.dvb.service`,eol:`audio/vnd.digital-winds`,djvu:`image/vnd.djvu`,dtd:`application/xml-dtd`,mlp:`application/vnd.dolby.mlp`,wad:`application/x-doom`,dpg:`application/vnd.dpgraph`,dra:`audio/vnd.dra`,dfac:`application/vnd.dreamfactory`,dts:`audio/vnd.dts`,dtshd:`audio/vnd.dts.hd`,dwg:`image/vnd.dwg`,geo:`application/vnd.dynageo`,es:`application/ecmascript`,mag:`application/vnd.ecowin.chart`,mmr:`image/vnd.fujixerox.edmics-mmr`,rlc:`image/vnd.fujixerox.edmics-rlc`,exi:`application/exi`,mgz:`application/vnd.proteus.magazine`,epub:`application/epub+zip`,eml:`message/rfc822`,nml:`application/vnd.enliven`,xpr:`application/vnd.is-xpr`,xif:`image/vnd.xiff`,xfdl:`application/vnd.xfdl`,emma:`application/emma+xml`,ez2:`application/vnd.ezpix-album`,ez3:`application/vnd.ezpix-package`,fst:`image/vnd.fst`,fvt:`video/vnd.fvt`,fbs:`image/vnd.fastbidsheet`,fe_launch:`application/vnd.denovo.fcselayout-link`,f4v:`video/x-f4v`,flv:`video/x-flv`,fpx:`image/vnd.fpx`,npx:`image/vnd.net-fpx`,flx:`text/vnd.fmi.flexstor`,fli:`video/x-fli`,ftc:`application/vnd.fluxtime.clip`,fdf:`application/vnd.fdf`,f:`text/x-fortran`,mif:`application/vnd.mif`,fm:`application/vnd.framemaker`,fh:`image/x-freehand`,fsc:`application/vnd.fsc.weblaunch`,fnc:`application/vnd.frogans.fnc`,ltf:`application/vnd.frogans.ltf`,ddd:`application/vnd.fujixerox.ddd`,xdw:`application/vnd.fujixerox.docuworks`,xbd:`application/vnd.fujixerox.docuworks.binder`,oas:`application/vnd.fujitsu.oasys`,oa2:`application/vnd.fujitsu.oasys2`,oa3:`application/vnd.fujitsu.oasys3`,fg5:`application/vnd.fujitsu.oasysgp`,bh2:`application/vnd.fujitsu.oasysprs`,spl:`application/x-futuresplash`,fzs:`application/vnd.fuzzysheet`,g3:`image/g3fax`,gmx:`application/vnd.gmx`,gtw:`model/vnd.gtw`,txd:`application/vnd.genomatix.tuxedo`,ggb:`application/vnd.geogebra.file`,ggt:`application/vnd.geogebra.tool`,gdl:`model/vnd.gdl`,gex:`application/vnd.geometry-explorer`,gxt:`application/vnd.geonext`,g2w:`application/vnd.geoplan`,g3w:`application/vnd.geospace`,gsf:`application/x-font-ghostscript`,bdf:`application/x-font-bdf`,gtar:`application/x-gtar`,texinfo:`application/x-texinfo`,gnumeric:`application/x-gnumeric`,kml:`application/vnd.google-earth.kml+xml`,kmz:`application/vnd.google-earth.kmz`,gqf:`application/vnd.grafeq`,gif:`image/gif`,gv:`text/vnd.graphviz`,gac:`application/vnd.groove-account`,ghf:`application/vnd.groove-help`,gim:`application/vnd.groove-identity-message`,grv:`application/vnd.groove-injector`,gtm:`application/vnd.groove-tool-message`,tpl:`application/vnd.groove-tool-template`,vcg:`application/vnd.groove-vcard`,h261:`video/h261`,h263:`video/h263`,h264:`video/h264`,hpid:`application/vnd.hp-hpid`,hps:`application/vnd.hp-hps`,hdf:`application/x-hdf`,rip:`audio/vnd.rip`,hbci:`application/vnd.hbci`,jlt:`application/vnd.hp-jlyt`,pcl:`application/vnd.hp-pcl`,hpgl:`application/vnd.hp-hpgl`,hvs:`application/vnd.yamaha.hv-script`,hvd:`application/vnd.yamaha.hv-dic`,hvp:`application/vnd.yamaha.hv-voice`,"sfd-hdstx":`application/vnd.hydrostatix.sof-data`,stk:`application/hyperstudio`,hal:`application/vnd.hal+xml`,html:`text/html`,irm:`application/vnd.ibm.rights-management`,sc:`application/vnd.ibm.secure-container`,ics:`text/calendar`,icc:`application/vnd.iccprofile`,ico:`image/x-icon`,igl:`application/vnd.igloader`,ief:`image/ief`,ivp:`application/vnd.immervision-ivp`,ivu:`application/vnd.immervision-ivu`,rif:`application/reginfo+xml`,"3dml":`text/vnd.in3d.3dml`,spot:`text/vnd.in3d.spot`,igs:`model/iges`,i2g:`application/vnd.intergeo`,cdy:`application/vnd.cinderella`,xpw:`application/vnd.intercon.formnet`,fcs:`application/vnd.isac.fcs`,ipfix:`application/ipfix`,cer:`application/pkix-cert`,pki:`application/pkixcmp`,crl:`application/pkix-crl`,pkipath:`application/pkix-pkipath`,igm:`application/vnd.insors.igm`,rcprofile:`application/vnd.ipunplugged.rcprofile`,irp:`application/vnd.irepository.package+xml`,jad:`text/vnd.sun.j2me.app-descriptor`,jar:`application/java-archive`,class:`application/java-vm`,jnlp:`application/x-java-jnlp-file`,ser:`application/java-serialized-object`,java:`text/x-java-source,java`,js:`application/javascript`,json:`application/json`,joda:`application/vnd.joost.joda-archive`,jpm:`video/jpm`,jpeg:`image/jpeg`,jpg:`image/jpeg`,pjpeg:`image/pjpeg`,jpgv:`video/jpeg`,ktz:`application/vnd.kahootz`,mmd:`application/vnd.chipnuts.karaoke-mmd`,karbon:`application/vnd.kde.karbon`,chrt:`application/vnd.kde.kchart`,kfo:`application/vnd.kde.kformula`,flw:`application/vnd.kde.kivio`,kon:`application/vnd.kde.kontour`,kpr:`application/vnd.kde.kpresenter`,ksp:`application/vnd.kde.kspread`,kwd:`application/vnd.kde.kword`,htke:`application/vnd.kenameaapp`,kia:`application/vnd.kidspiration`,kne:`application/vnd.kinar`,sse:`application/vnd.kodak-descriptor`,lasxml:`application/vnd.las.las+xml`,latex:`application/x-latex`,lbd:`application/vnd.llamagraphics.life-balance.desktop`,lbe:`application/vnd.llamagraphics.life-balance.exchange+xml`,jam:`application/vnd.jam`,123:`application/vnd.lotus-1-2-3`,apr:`application/vnd.lotus-approach`,pre:`application/vnd.lotus-freelance`,nsf:`application/vnd.lotus-notes`,org:`application/vnd.lotus-organizer`,scm:`application/vnd.lotus-screencam`,lwp:`application/vnd.lotus-wordpro`,lvp:`audio/vnd.lucent.voice`,m3u:`audio/x-mpegurl`,m4v:`video/x-m4v`,hqx:`application/mac-binhex40`,portpkg:`application/vnd.macports.portpkg`,mgp:`application/vnd.osgeo.mapguide.package`,mrc:`application/marc`,mrcx:`application/marcxml+xml`,mxf:`application/mxf`,nbp:`application/vnd.wolfram.player`,ma:`application/mathematica`,mathml:`application/mathml+xml`,mbox:`application/mbox`,mc1:`application/vnd.medcalcdata`,mscml:`application/mediaservercontrol+xml`,cdkey:`application/vnd.mediastation.cdkey`,mwf:`application/vnd.mfer`,mfm:`application/vnd.mfmp`,msh:`model/mesh`,mads:`application/mads+xml`,mets:`application/mets+xml`,mods:`application/mods+xml`,meta4:`application/metalink4+xml`,mcd:`application/vnd.mcd`,flo:`application/vnd.micrografx.flo`,igx:`application/vnd.micrografx.igx`,es3:`application/vnd.eszigno3+xml`,mdb:`application/x-msaccess`,asf:`video/x-ms-asf`,exe:`application/x-msdownload`,cil:`application/vnd.ms-artgalry`,cab:`application/vnd.ms-cab-compressed`,ims:`application/vnd.ms-ims`,application:`application/x-ms-application`,clp:`application/x-msclip`,mdi:`image/vnd.ms-modi`,eot:`application/vnd.ms-fontobject`,xls:`application/vnd.ms-excel`,xlam:`application/vnd.ms-excel.addin.macroenabled.12`,xlsb:`application/vnd.ms-excel.sheet.binary.macroenabled.12`,xltm:`application/vnd.ms-excel.template.macroenabled.12`,xlsm:`application/vnd.ms-excel.sheet.macroenabled.12`,chm:`application/vnd.ms-htmlhelp`,crd:`application/x-mscardfile`,lrm:`application/vnd.ms-lrm`,mvb:`application/x-msmediaview`,mny:`application/x-msmoney`,pptx:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,sldx:`application/vnd.openxmlformats-officedocument.presentationml.slide`,ppsx:`application/vnd.openxmlformats-officedocument.presentationml.slideshow`,potx:`application/vnd.openxmlformats-officedocument.presentationml.template`,xlsx:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,xltx:`application/vnd.openxmlformats-officedocument.spreadsheetml.template`,docx:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,dotx:`application/vnd.openxmlformats-officedocument.wordprocessingml.template`,obd:`application/x-msbinder`,thmx:`application/vnd.ms-officetheme`,onetoc:`application/onenote`,pya:`audio/vnd.ms-playready.media.pya`,pyv:`video/vnd.ms-playready.media.pyv`,ppt:`application/vnd.ms-powerpoint`,ppam:`application/vnd.ms-powerpoint.addin.macroenabled.12`,sldm:`application/vnd.ms-powerpoint.slide.macroenabled.12`,pptm:`application/vnd.ms-powerpoint.presentation.macroenabled.12`,ppsm:`application/vnd.ms-powerpoint.slideshow.macroenabled.12`,potm:`application/vnd.ms-powerpoint.template.macroenabled.12`,mpp:`application/vnd.ms-project`,pub:`application/x-mspublisher`,scd:`application/x-msschedule`,xap:`application/x-silverlight-app`,stl:`application/vnd.ms-pki.stl`,cat:`application/vnd.ms-pki.seccat`,vsd:`application/vnd.visio`,vsdx:`application/vnd.visio2013`,wm:`video/x-ms-wm`,wma:`audio/x-ms-wma`,wax:`audio/x-ms-wax`,wmx:`video/x-ms-wmx`,wmd:`application/x-ms-wmd`,wpl:`application/vnd.ms-wpl`,wmz:`application/x-ms-wmz`,wmv:`video/x-ms-wmv`,wvx:`video/x-ms-wvx`,wmf:`application/x-msmetafile`,trm:`application/x-msterminal`,doc:`application/msword`,docm:`application/vnd.ms-word.document.macroenabled.12`,dotm:`application/vnd.ms-word.template.macroenabled.12`,wri:`application/x-mswrite`,wps:`application/vnd.ms-works`,xbap:`application/x-ms-xbap`,xps:`application/vnd.ms-xpsdocument`,mid:`audio/midi`,mpy:`application/vnd.ibm.minipay`,afp:`application/vnd.ibm.modcap`,rms:`application/vnd.jcp.javame.midlet-rms`,tmo:`application/vnd.tmobile-livetv`,prc:`application/x-mobipocket-ebook`,mbk:`application/vnd.mobius.mbk`,dis:`application/vnd.mobius.dis`,plc:`application/vnd.mobius.plc`,mqy:`application/vnd.mobius.mqy`,msl:`application/vnd.mobius.msl`,txf:`application/vnd.mobius.txf`,daf:`application/vnd.mobius.daf`,fly:`text/vnd.fly`,mpc:`application/vnd.mophun.certificate`,mpn:`application/vnd.mophun.application`,mj2:`video/mj2`,mpga:`audio/mpeg`,mxu:`video/vnd.mpegurl`,mpeg:`video/mpeg`,m21:`application/mp21`,mp4a:`audio/mp4`,mp4:`video/mp4`,m3u8:`application/vnd.apple.mpegurl`,mus:`application/vnd.musician`,msty:`application/vnd.muvee.style`,mxml:`application/xv+xml`,ngdat:`application/vnd.nokia.n-gage.data`,"n-gage":`application/vnd.nokia.n-gage.symbian.install`,ncx:`application/x-dtbncx+xml`,nc:`application/x-netcdf`,nlu:`application/vnd.neurolanguage.nlu`,dna:`application/vnd.dna`,nnd:`application/vnd.noblenet-directory`,nns:`application/vnd.noblenet-sealer`,nnw:`application/vnd.noblenet-web`,rpst:`application/vnd.nokia.radio-preset`,rpss:`application/vnd.nokia.radio-presets`,n3:`text/n3`,edm:`application/vnd.novadigm.edm`,edx:`application/vnd.novadigm.edx`,ext:`application/vnd.novadigm.ext`,gph:`application/vnd.flographit`,ecelp4800:`audio/vnd.nuera.ecelp4800`,ecelp7470:`audio/vnd.nuera.ecelp7470`,ecelp9600:`audio/vnd.nuera.ecelp9600`,oda:`application/oda`,ogx:`application/ogg`,oga:`audio/ogg`,ogv:`video/ogg`,dd2:`application/vnd.oma.dd2+xml`,oth:`application/vnd.oasis.opendocument.text-web`,opf:`application/oebps-package+xml`,qbo:`application/vnd.intu.qbo`,oxt:`application/vnd.openofficeorg.extension`,osf:`application/vnd.yamaha.openscoreformat`,weba:`audio/webm`,webm:`video/webm`,odc:`application/vnd.oasis.opendocument.chart`,otc:`application/vnd.oasis.opendocument.chart-template`,odb:`application/vnd.oasis.opendocument.database`,odf:`application/vnd.oasis.opendocument.formula`,odft:`application/vnd.oasis.opendocument.formula-template`,odg:`application/vnd.oasis.opendocument.graphics`,otg:`application/vnd.oasis.opendocument.graphics-template`,odi:`application/vnd.oasis.opendocument.image`,oti:`application/vnd.oasis.opendocument.image-template`,odp:`application/vnd.oasis.opendocument.presentation`,otp:`application/vnd.oasis.opendocument.presentation-template`,ods:`application/vnd.oasis.opendocument.spreadsheet`,ots:`application/vnd.oasis.opendocument.spreadsheet-template`,odt:`application/vnd.oasis.opendocument.text`,odm:`application/vnd.oasis.opendocument.text-master`,ott:`application/vnd.oasis.opendocument.text-template`,ktx:`image/ktx`,sxc:`application/vnd.sun.xml.calc`,stc:`application/vnd.sun.xml.calc.template`,sxd:`application/vnd.sun.xml.draw`,std:`application/vnd.sun.xml.draw.template`,sxi:`application/vnd.sun.xml.impress`,sti:`application/vnd.sun.xml.impress.template`,sxm:`application/vnd.sun.xml.math`,sxw:`application/vnd.sun.xml.writer`,sxg:`application/vnd.sun.xml.writer.global`,stw:`application/vnd.sun.xml.writer.template`,otf:`application/x-font-otf`,osfpvg:`application/vnd.yamaha.openscoreformat.osfpvg+xml`,dp:`application/vnd.osgi.dp`,pdb:`application/vnd.palm`,p:`text/x-pascal`,paw:`application/vnd.pawaafile`,pclxl:`application/vnd.hp-pclxl`,efif:`application/vnd.picsel`,pcx:`image/x-pcx`,psd:`image/vnd.adobe.photoshop`,prf:`application/pics-rules`,pic:`image/x-pict`,chat:`application/x-chat`,p10:`application/pkcs10`,p12:`application/x-pkcs12`,p7m:`application/pkcs7-mime`,p7s:`application/pkcs7-signature`,p7r:`application/x-pkcs7-certreqresp`,p7b:`application/x-pkcs7-certificates`,p8:`application/pkcs8`,plf:`application/vnd.pocketlearn`,pnm:`image/x-portable-anymap`,pbm:`image/x-portable-bitmap`,pcf:`application/x-font-pcf`,pfr:`application/font-tdpfr`,pgn:`application/x-chess-pgn`,pgm:`image/x-portable-graymap`,png:`image/png`,ppm:`image/x-portable-pixmap`,pskcxml:`application/pskc+xml`,pml:`application/vnd.ctc-posml`,ai:`application/postscript`,pfa:`application/x-font-type1`,pbd:`application/vnd.powerbuilder6`,pgp:`application/pgp-signature`,box:`application/vnd.previewsystems.box`,ptid:`application/vnd.pvi.ptid1`,pls:`application/pls+xml`,str:`application/vnd.pg.format`,ei6:`application/vnd.pg.osasli`,dsc:`text/prs.lines.tag`,psf:`application/x-font-linux-psf`,qps:`application/vnd.publishare-delta-tree`,wg:`application/vnd.pmi.widget`,qxd:`application/vnd.quark.quarkxpress`,esf:`application/vnd.epson.esf`,msf:`application/vnd.epson.msf`,ssf:`application/vnd.epson.ssf`,qam:`application/vnd.epson.quickanime`,qfx:`application/vnd.intu.qfx`,mov:`video/quicktime`,rar:`application/x-rar-compressed`,ram:`audio/x-pn-realaudio`,rmp:`audio/x-pn-realaudio-plugin`,rsd:`application/rsd+xml`,rm:`application/vnd.rn-realmedia`,bed:`application/vnd.realvnc.bed`,mxl:`application/vnd.recordare.musicxml`,musicxml:`application/vnd.recordare.musicxml+xml`,rnc:`application/relax-ng-compact-syntax`,rdz:`application/vnd.data-vision.rdz`,rdf:`application/rdf+xml`,rp9:`application/vnd.cloanto.rp9`,jisp:`application/vnd.jisp`,rtf:`application/rtf`,rtx:`text/richtext`,link66:`application/vnd.route66.link66+xml`,rss:`application/rss+xml`,shf:`application/shf+xml`,st:`application/vnd.sailingtracker.track`,svg:`image/svg+xml`,sus:`application/vnd.sus-calendar`,sru:`application/sru+xml`,setpay:`application/set-payment-initiation`,setreg:`application/set-registration-initiation`,sema:`application/vnd.sema`,semd:`application/vnd.semd`,semf:`application/vnd.semf`,see:`application/vnd.seemail`,snf:`application/x-font-snf`,spq:`application/scvp-vp-request`,spp:`application/scvp-vp-response`,scq:`application/scvp-cv-request`,scs:`application/scvp-cv-response`,sdp:`application/sdp`,etx:`text/x-setext`,movie:`video/x-sgi-movie`,ifm:`application/vnd.shana.informed.formdata`,itp:`application/vnd.shana.informed.formtemplate`,iif:`application/vnd.shana.informed.interchange`,ipk:`application/vnd.shana.informed.package`,tfi:`application/thraud+xml`,shar:`application/x-shar`,rgb:`image/x-rgb`,slt:`application/vnd.epson.salt`,aso:`application/vnd.accpac.simply.aso`,imp:`application/vnd.accpac.simply.imp`,twd:`application/vnd.simtech-mindmapper`,csp:`application/vnd.commonspace`,saf:`application/vnd.yamaha.smaf-audio`,mmf:`application/vnd.smaf`,spf:`application/vnd.yamaha.smaf-phrase`,teacher:`application/vnd.smart.teacher`,svd:`application/vnd.svd`,rq:`application/sparql-query`,srx:`application/sparql-results+xml`,gram:`application/srgs`,grxml:`application/srgs+xml`,ssml:`application/ssml+xml`,skp:`application/vnd.koan`,sgml:`text/sgml`,sdc:`application/vnd.stardivision.calc`,sda:`application/vnd.stardivision.draw`,sdd:`application/vnd.stardivision.impress`,smf:`application/vnd.stardivision.math`,sdw:`application/vnd.stardivision.writer`,sgl:`application/vnd.stardivision.writer-global`,sm:`application/vnd.stepmania.stepchart`,sit:`application/x-stuffit`,sitx:`application/x-stuffitx`,sdkm:`application/vnd.solent.sdkm+xml`,xo:`application/vnd.olpc-sugar`,au:`audio/basic`,wqd:`application/vnd.wqd`,sis:`application/vnd.symbian.install`,smi:`application/smil+xml`,xsm:`application/vnd.syncml+xml`,bdm:`application/vnd.syncml.dm+wbxml`,xdm:`application/vnd.syncml.dm+xml`,sv4cpio:`application/x-sv4cpio`,sv4crc:`application/x-sv4crc`,sbml:`application/sbml+xml`,tsv:`text/tab-separated-values`,tiff:`image/tiff`,tao:`application/vnd.tao.intent-module-archive`,tar:`application/x-tar`,tcl:`application/x-tcl`,tex:`application/x-tex`,tfm:`application/x-tex-tfm`,tei:`application/tei+xml`,txt:`text/plain`,dxp:`application/vnd.spotfire.dxp`,sfs:`application/vnd.spotfire.sfs`,tsd:`application/timestamped-data`,tpt:`application/vnd.trid.tpt`,mxs:`application/vnd.triscape.mxs`,t:`text/troff`,tra:`application/vnd.trueapp`,ttf:`application/x-font-ttf`,ttl:`text/turtle`,umj:`application/vnd.umajin`,uoml:`application/vnd.uoml+xml`,unityweb:`application/vnd.unity`,ufd:`application/vnd.ufdl`,uri:`text/uri-list`,utz:`application/vnd.uiq.theme`,ustar:`application/x-ustar`,uu:`text/x-uuencode`,vcs:`text/x-vcalendar`,vcf:`text/x-vcard`,vcd:`application/x-cdlink`,vsf:`application/vnd.vsf`,wrl:`model/vrml`,vcx:`application/vnd.vcx`,mts:`model/vnd.mts`,vtu:`model/vnd.vtu`,vis:`application/vnd.visionary`,viv:`video/vnd.vivo`,ccxml:`application/ccxml+xml,`,vxml:`application/voicexml+xml`,src:`application/x-wais-source`,wbxml:`application/vnd.wap.wbxml`,wbmp:`image/vnd.wap.wbmp`,wav:`audio/x-wav`,davmount:`application/davmount+xml`,woff:`application/x-font-woff`,wspolicy:`application/wspolicy+xml`,webp:`image/webp`,wtb:`application/vnd.webturbo`,wgt:`application/widget`,hlp:`application/winhlp`,wml:`text/vnd.wap.wml`,wmls:`text/vnd.wap.wmlscript`,wmlsc:`application/vnd.wap.wmlscriptc`,wpd:`application/vnd.wordperfect`,stf:`application/vnd.wt.stf`,wsdl:`application/wsdl+xml`,xbm:`image/x-xbitmap`,xpm:`image/x-xpixmap`,xwd:`image/x-xwindowdump`,der:`application/x-x509-ca-cert`,fig:`application/x-xfig`,xhtml:`application/xhtml+xml`,xml:`application/xml`,xdf:`application/xcap-diff+xml`,xenc:`application/xenc+xml`,xer:`application/patch-ops-error+xml`,rl:`application/resource-lists+xml`,rs:`application/rls-services+xml`,rld:`application/resource-lists-diff+xml`,xslt:`application/xslt+xml`,xop:`application/xop+xml`,xpi:`application/x-xpinstall`,xspf:`application/xspf+xml`,xul:`application/vnd.mozilla.xul+xml`,xyz:`chemical/x-xyz`,yaml:`text/yaml`,yang:`application/yang`,yin:`application/yin+xml`,zir:`application/vnd.zul`,zip:`application/zip`,zmm:`application/vnd.handheld-entertainment+xml`,zaz:`application/vnd.zzazz.deck+xml`},ft=Object.fromEntries(Object.entries(dt).map(function(e){var t=xe(e,2),n=t[0];return[t[1],n]})),pt=/^data:(.*?);base64,/;function mt(e){var t=pt.exec(e);if(t&&t[1])return t[1]}function ht(e){return ft[e]||e.split(`/`)[1]}function gt(e){var t=e.split(`.`).pop(),n=t&&dt[t];if(n)return n}function _t(e,t){return t.split(`,`).map(function(e){return e.trim()}).some(function(t){return t===`*/*`?!0:t.endsWith(`/*`)?e.startsWith(t.slice(0,-1)):t===e})}var vt=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[],o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},s=arguments.length>5&&arguments[5]!==void 0&&arguments[5],c=arguments.length>6&&arguments[6]!==void 0&&arguments[6],l=arguments.length>7?arguments[7]:void 0,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:null,d=arguments.length>9&&arguments[9]!==void 0?arguments[9]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.isRemote=i,n.customValidateFunctions=a,n.moduleMetadata=o,n.isReadonly=s,n.isHidden=c,n.description=l,n.renderInput=u,n.previewInput=d,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`remote`,value:function(){return new t(this.options,this.opt,!0,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,this.isRemote,[].concat(z(this.customValidateFunctions),[e]),this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return n.length>0&&V({},e,n);if(t==null)return V({},e,[].concat(z(n),[{message:`Non-optional image was null or undefined.`,value:t}]));if(typeof t.path!=`string`)return V({},e,[].concat(z(n),[{message:`Image did not have a path string. Got: ${B(t.path)}`,value:t}]));var r=ot(t.path);if(this.isRemote&&!r)return V({},e,[].concat(z(n),[{message:`Expected a remote image, but got a local image.`,value:t,fixes:[`image:upload-remote`]}]));if(this.isRemote&&r)return V({},e,[].concat(z(n),[{message:`Remote image was not checked.`,value:t,fixes:[`image:check-remote`]}]));if(!this.isRemote&&r)return V({},e,[].concat(z(n),[{message:`Expected local image, but found remote.`,value:t,fixes:[`image:download-remote`]}]));if(t.hotspot!==void 0&&(B(t.hotspot)!==`object`||t.hotspot===null||typeof t.hotspot.x!=`number`||typeof t.hotspot.y!=`number`))return V({},e,[].concat(z(n),[{message:`Hotspot must be an object with x and y as numbers.`,value:t}]));var i=this.galleryEntries();if(i){var a=[`width`,`height`,`mimeType`].filter(function(e){return t[e]!==void 0});return a.length>0?V({},e,[].concat(z(n),[{message:`An image from a gallery must not carry its own ${a.join(`, `)}: ${a.length===1?`it is`:`they are`} stored in the gallery module.`,value:t}])):t.path in i?n.length>0&&V({},e,n):V({},e,[].concat(z(n),[{message:`The gallery does not have an image at '${t.path}'.`,value:t}]))}var o=(this.options||{}).accept,s=t.mimeType??``;if(o&&s&&!s.includes(`/`))return V({},e,[].concat(z(n),[{message:`Invalid mime type format. Got: '${s}'`,value:t,fixes:[`image:check-metadata`]}]));if(o&&s&&s.includes(`/`)&&!_t(s,o))return V({},e,[].concat(z(n),[{message:`Mime type mismatch. Found '${s}' but schema accepts '${o}'`,value:t,fixes:[`image:check-metadata`]}]));var c=H.filenameToMimeType(t.path);return c?c&&s&&c!==s?V({},e,[].concat(z(n),[{message:`Mime type and file extension not matching. Mime type is '${s}' but file extension is '${c}'`,value:t,fixes:[`image:check-metadata`]}])):t.width!==void 0||t.height!==void 0||t.mimeType!==void 0?V({},e,[].concat(z(n),[{message:`Image metadata has not been checked against the file.`,value:t,fixes:[`image:check-metadata`]}])):V({},e,[].concat(z(n),[{message:`Image metadata is missing: width, height and mimeType.`,value:t,fixes:[`image:add-metadata`]}])):V({},e,[].concat(z(n),[{message:`Could not determine mime type from file extension. Got: ${t.path}`,value:t,fixes:[`image:check-metadata`]}]))}},{key:`galleryEntries`,value:function(){var e=Object.keys(this.moduleMetadata);return e.length===0?null:this.moduleMetadata[e[0]]}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'object', got 'null'`,typeError:!0}])}:B(t)===`object`?!(`path`in t)||typeof t.path!=`string`?{success:!1,errors:V({},e,[{message:`An image must be an object with a 'path' (error type: missing_path)`,typeError:!0}])}:{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'object', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){var e=this.moduleMetadata?Object.keys(this.moduleMetadata):[];return{type:`image`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,options:this.options,opt:this.opt,remote:this.isRemote,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,referencedModule:e.length>0?e[0]:void 0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le);function yt(e,t){if(e&&H.getValPath(e)){for(var n={},r=0,i=[e];r<i.length;r++){var a=i[r],o=Ue(a);if(o===void 0)throw Error(`Invalid argument passed to s.image(). Expected a ValModule constructed through c.define, but got an object without a valid module path.`);n[o]=Ft(a)}return new vt(t?.encode===void 0?{}:{encode:t.encode},!1,!1,[],n)}return new vt(e)}var bt=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`include`,value:function(e){return new t(qe(qe({},this.options),{},{include:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`exclude`,value:function(e){return new t(qe(qe({},this.options),{},{exclude:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions.concat(e),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null?n.length>0&&V({},e,n):typeof t==`string`?V({},e,[].concat(z(n),[{fixes:[`router:check-route`],message:`Did not validate route (router). This error (router:check-route) should typically be processed by Val internally. Seeing this error most likely means you have a Val version mismatch.`,value:{route:t,sourcePath:e,include:this.options?.include,exclude:this.options?.exclude}}])):V({},e,[{message:`Expected 'string', got '${B(t)}'`,value:t}])}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null||typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`route`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,options:{include:this.options?.include&&{source:this.options.include.source,flags:this.options.include.flags},exclude:this.options?.exclude&&{source:this.options.exclude.source,flags:this.options.exclude.flags},customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0},opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),xt=function(e){return new bt(e)},St=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`maxLength`,value:function(e){return new t(qe(qe({},this.options),{},{maxLength:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`minLength`,value:function(e){return new t(qe(qe({},this.options),{},{minLength:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e}),r=this.executeAssert(e,t);if(!r.success)return n.length>0?V({},e,n):r.errors;var i=r.data;if(i===null&&this.opt)return n.length>0&&V({},e,n);if(i===null)return V({},e,[].concat(z(n),[{message:`Expected 'array', got 'null'`,typeError:!0}]));var a={},o=this.internalValidate(e,i,a);return o?n.length>0?qe(V({},e,n),o):o:Object.keys(a).length>0?n.length>0?qe(V({},e,n),a):a:n.length>0&&V({},e,n)}},{key:`internalValidate`,value:function(e,t,n){var r=this,i=0,a=function(e,t,n){var o=function(e,t,r){n[e]||(n[e]=[]),n[e].push({message:t,typeError:r})},s=w(t),c;try{var l=function(){var s,l,u,d,f,p,m,h,g,_,v=c.value,y=Ge(e,t.indexOf(v));if(typeof v==`string`)return i+=v.length,0;if(B(v)!==`object`)return{v:V({},y,[{message:`Expected nodes of type 'object' or 'string', got '${B(v)}'`,typeError:!0}])};if(v===null)return{v:V({},y,[{message:`Expected nodes of type 'object' or 'string', got 'null'`,typeError:!0}])};if(!(`tag`in v))return{v:V({},y,[{message:`Expected node to either have 'tag' or be of type 'string'`,typeError:!0}])};if(typeof v.tag!=`string`)return{v:V({},y,[{message:`Expected 'string', got '${B(v.tag)}'`,typeError:!0}])};var b=[`p`,`span`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`ol`,`ul`,`li`,`a`,`img`,`br`];if(b.includes(v.tag)||o(y,`Tag '${v.tag}' is not supported. Supported tags: ${b.join(`, `)}`,!0),v.tag===`h1`&&!((s=r.options.block)!=null&&s.h1)&&o(y,`'h' block is not valid`,!1),v.tag===`h2`&&!((l=r.options.block)!=null&&l.h2)&&o(y,`'h2' block is not valid`,!1),v.tag===`h3`&&!((u=r.options.block)!=null&&u.h3)&&o(y,`'h3' block is not valid`,!1),v.tag===`h4`&&!((d=r.options.block)!=null&&d.h4)&&o(y,`'h4' block is not valid`,!1),v.tag===`h5`&&!((f=r.options.block)!=null&&f.h5)&&o(y,`'h5' block is not valid`,!1),v.tag===`h6`&&!((p=r.options.block)!=null&&p.h6)&&o(y,`'h6' block is not valid`,!1),v.tag===`ol`&&!((m=r.options.block)!=null&&m.ol)&&o(y,`'ol' block is not valid`,!1),v.tag===`ul`&&!((h=r.options.block)!=null&&h.ul)&&o(y,`'ul' block is not valid`,!1),v.tag===`li`&&!((g=r.options.block)!=null&&g.ul)&&!((_=r.options.block)!=null&&_.ol)&&o(y,`'li' tag is invalid since neither 'ul' nor 'ol' block is not valid`,!1),v.tag===`a`){var x,S;if(!((x=r.options.inline)!=null&&x.a))o(y,`'a' inline is not valid`,!1);else if((S=r.options.inline)!=null&&S.a){if(!(`href`in v))return{v:V({},y,[{message:`Expected 'href' in 'a'`,typeError:!0}])};var C=Ge(y,`href`),w=typeof r.options.inline?.a==`boolean`?new bt:r.options.inline.a,T=function(){return w instanceof bt||w instanceof Je?w.executeValidate(C,v.href):(console.error(`Exhaustive check failed in RichText (anchor href validation)`,w),!1)}();if(T)for(var E in T){var D,O=E;n[O]||(n[O]=[]),(D=n[O]).push.apply(D,z(T[O]))}}}if(v.tag===`img`){var k,A;if(!((k=r.options.inline)!=null&&k.img))o(y,`'img' inline is not valid`,!1);else if((A=r.options.inline)!=null&&A.img){if(!(`src`in v))return{v:V({},y,[{message:`Expected 'src' in 'img'`,typeError:!0}])};var j=Ge(y,`src`),M=r.options.inline?.img,N=B(M)===`object`?M.executeValidate(j,v.src):new vt({},!1,!1).executeValidate(j,v.src);if(N)for(var P in N){var F,I=P;n[I]||(n[I]=[]),(F=n[I]).push.apply(F,z(N[I]))}}}if(`styles`in v&&v.tag!==`span`)return{v:V({},y,[{message:`Cannot have styles on '${v.tag}'. This is only allowed on 'span'`,typeError:!0}])};if(`styles`in v){if(!Array.isArray(v.styles))return{v:V({},y,[{message:`Expected 'array', got '${B(v.styles)}'`,typeError:!0}])};for(var L=Ge(y,`styles`),R=0;R<v.styles.length;R++){var ee,te,ne,re=v.styles[R],ie=Ge(L,R);if(typeof re!=`string`)return{v:V({},ie,[{message:`Expected 'string', got '${B(re)}'`,typeError:!0}])};re===`bold`&&!((ee=r.options.style)!=null&&ee.bold)&&o(ie,`Style 'bold' is not valid`,!1),re===`italic`&&!((te=r.options.style)!=null&&te.italic)&&o(ie,`Style 'italic' is not valid`,!1),re===`lineThrough`&&!((ne=r.options.style)!=null&&ne.lineThrough)&&o(ie,`Style 'lineThrough' is not valid`,!1)}}if(`children`in v){if(!Array.isArray(v.children))return{v:V({},y,[{message:`Expected 'array', got '${B(v.children)}'`,typeError:!0}])};var ae=a(Ge(y,`children`),v.children,n);if(ae)return{v:ae}}},u;for(s.s();!(c=s.n()).done;)if(u=l(),u!==0&&u)return u.v}catch(e){s.e(e)}finally{s.f()}return!1},o=a(e,t,n),s=[];if(this.options.maxLength&&i>this.options.maxLength&&s.push({message:`Maximum length of ${this.options.maxLength} exceeded (current length: ${i})`,typeError:!1}),this.options.minLength&&i<this.options.minLength&&s.push({message:`Minimum length of ${this.options.minLength} not met (current length: ${i})`,typeError:!1}),o){if(s.length>0){var c;o[e]||(o[e]=[]),(c=o[e]).push.apply(c,s)}return o}if(Object.keys(n).length>0){if(s.length>0){var l;n[e]||(n[e]=[]),(l=n[e]).push.apply(l,s)}return n}return s.length>0&&V({},e,s)}},{key:`executeAssert`,value:function(e,t){if(this.opt&&t===null)return{success:!0,data:t};if(t===null&&!this.opt)return{success:!1,errors:V({},e,[{message:`Expected 'array', got 'null'`,typeError:!0}])};if(!Array.isArray(t))return{success:!1,errors:V({},e,[{message:`Expected 'array', got '${B(t)}'`,typeError:!0}])};for(var n={},r=0;r<t.length;r++)this.recursiveAssert(Ge(e,r),t[r],n);return Object.keys(n).length>0?{success:!1,errors:n}:{success:!0,data:t}}},{key:`recursiveAssert`,value:function(e,t,n){if(B(t)!==`object`){n[e]||(n[e]=[]),n[e].push({message:`Expected 'object', got '${B(t)}'`,typeError:!0});return}if(Array.isArray(t)){n[e]||(n[e]=[]),n[e].push({message:`Expected 'object', got 'array'`,typeError:!0});return}if(t===null){n[e]||(n[e]=[]),n[e].push({message:`Expected 'object', got 'null'`,typeError:!0});return}if(`tag`in t&&typeof t.tag!=`string`){n[e]||(n[e]=[]),n[e].push({message:`Expected 'string', got '${B(t.tag)}'`,typeError:!0});return}if(`children`in t){if(Array.isArray(t.children))for(var r=0;r<t.children.length;r++){var i=t.children[r],a=Ge(Ge(e,`children`),r);if(B(i)===`object`)this.recursiveAssert(a,i,n);else if(typeof i==`string`)continue;else n[a]||(n[a]=[]),n[a].push({message:`Expected 'object' or 'string', got '${B(i)}'`,typeError:!0})}else{n[e]||(n[e]=[]),n[e].push({message:`Expected 'array', got '${B(t.children)}'`,typeError:!0});return}}if(`styles`in t){if(!Array.isArray(t.styles))n[e]||(n[e]=[]),n[e].push({message:`Expected 'array', got '${B(t.styles)}'`,typeError:!0});else for(var o=0;o<t.styles.length;o++){var s=t.styles[o];if(typeof s!=`string`){var c=Ge(e,o);n[c]||(n[c]=[]),n[c].push({message:`Expected 'string', got '${B(s)}'`,typeError:!0})}}}}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){var e=this,t={maxLength:this.options.maxLength,minLength:this.options.minLength,style:this.options.style,block:this.options.block,inline:this.options.inline&&{a:function(){return e.options.inline?.a instanceof bt||e.options.inline?.a instanceof Je?e.options.inline?.a.executeSerialize():e.options.inline?.a}(),img:this.options.inline.img&&B(this.options.inline.img)===`object`?this.options.inline.img.executeSerialize():this.options.inline.img}};return{type:`richtext`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,opt:this.opt,options:t,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),Ct=function(e){return new St(e??{})};function wt(e,t,n,r){var i=Object.defineProperty;try{i({},``,{})}catch{i=0}wt=function(e,t,n,r){function a(t,n){wt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a(`next`,0),a(`throw`,1),a(`return`,2))},wt(e,t,n,r)}function Tt(){var e,t,n=typeof Symbol==`function`?Symbol:{},r=n.iterator||`@@iterator`,i=n.toStringTag||`@@toStringTag`;function a(n,r,i,a){var c=r&&r.prototype instanceof s?r:s,l=Object.create(c.prototype);return wt(l,`_invoke`,function(n,r,i){var a,s,c,l=0,u=i||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,s=0,c=e,f.n=n,o}};function p(n,r){for(s=n,c=r,t=0;!d&&l&&!i&&t<u.length;t++){var i,a=u[t],p=f.p,m=a[2];n>3?(i=m===r)&&(c=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=p&&((i=n<2&&p<a[1])?(s=0,f.v=r,f.n=a[1]):p<m&&(i=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,s=0))}if(i||n>1)return o;throw d=!0,r}return function(i,u,m){if(l>1)throw TypeError(`Generator is already running`);for(d&&u===1&&p(u,m),s=u,c=m;(t=s<2?e:c)||!d;){a||(s?s<3?(s>1&&(f.n=-1),p(s,c)):f.n=c:f.v=c);try{if(l=2,a){if(s||(i=`next`),t=a[i]){if(!(t=t.call(a,c)))throw TypeError(`iterator result is not an object`);if(!t.done)return t;c=t.value,s<2&&(s=0)}else s===1&&(t=a.return)&&t.call(a),s<2&&(c=TypeError(`The iterator does not provide a '`+i+`' method`),s=1);a=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==o)break}catch(t){a=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,i,a),!0),l}var o={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(wt(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,wt(e,i,`GeneratorFunction`)),e.prototype=Object.create(d),e}return c.prototype=l,wt(d,`constructor`,l),wt(l,`constructor`,c),c.displayName=`GeneratorFunction`,wt(l,i,`GeneratorFunction`),wt(d),wt(d,i,`Generator`),wt(d,r,function(){return this}),wt(d,`toString`,function(){return`[object Generator]`}),(Tt=function(){return{w:a,m:f}})()}function Et(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Dt(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Et(a,r,i,o,s,`next`,e)}function s(e){Et(a,r,i,o,s,`throw`,e)}o(void 0)})}}var Ot=`json`;function kt(e){return B(e)===`object`&&e!==null&&`_type`in e&&e._type===Ot}function At(e){var t=e._import;return typeof t==`function`?t:void 0}function jt(e){return Mt.apply(this,arguments)}function Mt(){return Mt=Dt(Tt().m(function e(t){var n,r,i;return Tt().w(function(e){for(;;)switch(e.n){case 0:if(!kt(t)){e.n=3;break}if(n=At(t),n){e.n=1;break}return e.a(2,t);case 1:return e.n=2,n();case 2:return r=e.v.default,e.a(2,jt(r));case 3:if(!Array.isArray(t)){e.n=4;break}return e.a(2,Promise.all(t.map(function(e){return jt(e)})));case 4:if(t===null||B(t)!==`object`){e.n=7;break}if(!(`_type`in t)){e.n=5;break}return e.a(2,t);case 5:return e.n=6,Promise.all(Object.entries(t).map(function(){var e=Dt(Tt().m(function e(t){var n,r,i,a,o;return Tt().w(function(e){for(;;)switch(e.n){case 0:return n=xe(t,2),r=n[0],i=n[1],a=r,e.n=1,jt(i);case 1:return o=e.v,e.a(2,[a,o])}},e)}));return function(t){return e.apply(this,arguments)}}()));case 6:return i=e.v,e.a(2,Object.fromEntries(i));case 7:return e.a(2,t)}},e)})),Mt.apply(this,arguments)}var Nt=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0&&arguments[6],l=arguments.length>7&&arguments[7]!==void 0&&arguments[7],u=arguments.length>8?arguments[8]:void 0,d=arguments.length>9&&arguments[9]!==void 0&&arguments[9],f=arguments.length>10&&arguments[10]!==void 0?arguments[10]:null,p=arguments.length>11&&arguments[11]!==void 0?arguments[11]:null;return De(this,t),n=Pe(this,t),n.item=e,n.opt=r,n.customValidateFunctions=i,n.currentRouter=a,n.keySchema=o,n.mediaOptions=s,n.isReadonly=c,n.isHidden=l,n.description=u,n.isJsonValues=d,n.previewInput=f,n.renderInput=p,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,e??void 0,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`validate`,value:function(e){return new t(this.item,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`executeValidate`,value:function(e,t){var n=this,r=!1,i=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return i.length>0&&V({},e,i);if(t===null)return V({},e,[].concat(z(i),[{message:`Expected 'object', got 'null'`}]));if(B(t)!==`object`)return V({},e,[].concat(z(i),[{message:`Expected 'object', got '${B(t)}'`}]));if(Array.isArray(t))return V({},e,[].concat(z(i),[{message:`Expected 'object', got 'array'`}]));var a=this.getRouterValidations(e,t);r=this.mergeValidationErrors(r,a);var o=w(i),s;try{for(o.s();!(s=o.n()).done;){var c=s.value;r=this.appendValidationError(r,e,c.message,t,c.schemaError)}}catch(e){o.e(e)}finally{o.f()}if(this.mediaOptions){var l=this.mediaOptions.type===`images`?`images:check-unique-folder`:`files:check-unique-folder`,u={message:`Gallery directory '${this.mediaOptions.directory}' must be unique across all galleries`,value:{directory:this.mediaOptions.directory,type:this.mediaOptions.type},fixes:[l]};r?r[e]?r[e]=[].concat(z(r[e]),[u]):r=qe(qe({},r),{},V({},e,[u])):r=V({},e,[u]);var d=this.mediaOptions.type===`images`?`images:check-all-files`:`files:check-all-files`,f={message:`Directory '${this.mediaOptions.directory}' may have files not tracked by this gallery`,value:{directory:this.mediaOptions.directory,type:this.mediaOptions.type},fixes:[d]};r[e]?r[e]=[].concat(z(r[e]),[f]):r=qe(qe({},r),{},V({},e,[f]))}return Object.entries(t).forEach(function(i){var a=xe(i,2),o=a[0],s=a[1];if(n.keySchema){var c=We(e,o);if(!c)throw Error(`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} for key validation`);var l=n.keySchema.executeValidate(c,o);l&&(l[c]=l[c].map(function(e){return qe(qe({},e),{},{keyError:!0})}),r=n.mergeValidationErrors(r,l))}var u=We(e,o);if(!u)r=n.appendValidationError(r,e,`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} at key ${s}`,t);else if(n.mediaOptions){var d=n.validateMediaKey(u,o);d&&n.markKeyErrorsAtPath(d,u),r=n.mergeValidationErrors(r,d);var f=n.validateMediaEntry(u,s);f&&n.markKeyErrorsAtPath(f,u),r=n.mergeValidationErrors(r,f)}else if(!(n.isJsonValues&&kt(s))){var p=n.item.executeValidate(u,s);r=n.mergeValidationErrors(r,p)}}),r}},{key:`isRemoteUrl`,value:function(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}},{key:`markKeyErrorsAtPath`,value:function(e,t){e&&e[t]&&(e[t]=e[t].map(function(e){return qe(qe({},e),{},{keyError:!0})}))}},{key:`validateMediaKey`,value:function(e,t){if(!this.mediaOptions)return!1;var n=this.mediaOptions,r=n.directory,i=n.remote,a=n.type,o=a===`images`?`images`:`files`,s=a===`images`?`images:check-remote`:`files:check-remote`,c=this.isRemoteUrl(t),l=t===r||t.startsWith(r+`/`);if(i){if(c){var u=at(t);if(u.status===`error`)return V({},e,[{message:`Invalid remote URL format. Use Val tooling (CLI, VS Code extension, or Val Studio) to upload ${o}. Got: ${t}`,value:t,fixes:[s]}]);var d=`/`+u.filePath;return d!==r&&!d.startsWith(r+`/`)&&V({},e,[{message:`Remote file path '${d}' is not in expected directory '${r}'. Use Val tooling to upload ${o} to the correct directory.`,value:t,fixes:[s]}])}if(!l)return V({},e,[{message:`Expected a remote URL (https://...) or a local path starting with ${r}/. Got: ${t}`,value:t}]);var f=a===`images`?`images:upload-remote`:`files:upload-remote`;return V({},e,[{message:`Expected a remote ${a===`images`?`image`:`file`}, but got a local path. Use Val tooling (CLI --fix, VS Code extension, or Val Studio) to upload it. Got: ${t}`,value:t,fixes:[f]}])}return c?V({},e,[{message:`Remote URLs are not allowed. Use .remote() to enable remote ${o}. Got: ${t}`,value:t,fixes:[s]}]):!l&&V({},e,[{message:`File path must be within the ${r}/ directory. Got: ${t}`,value:t}])}},{key:`validateMediaEntry`,value:function(e,t){if(!this.mediaOptions)return!1;var n=this.mediaOptions,r=n.type,i=n.accept,a=n.altSchema;if(B(t)!==`object`||t===null)return V({},e,[{message:`Expected 'object', got '${B(t)}'`,value:t}]);var o=t,s=[];if(r===`images`&&((typeof o.width!=`number`||o.width<=0)&&s.push({message:`Expected 'width' to be a positive number, got '${o.width}'`,value:t}),(typeof o.height!=`number`||o.height<=0)&&s.push({message:`Expected 'height' to be a positive number, got '${o.height}'`,value:t})),typeof o.mimeType!=`string`)s.push({message:`Expected 'mimeType' to be a string, got '${B(o.mimeType)}'`,value:t});else{var c=this.validateMediaMimeType(o.mimeType,i);c&&s.push({message:c,value:t})}if(r===`images`){if(o.hotspot!==void 0){var l=o.hotspot;(B(o.hotspot)!==`object`||typeof l.x!=`number`||typeof l.y!=`number`)&&s.push({message:`Hotspot must be an object with x and y as numbers.`,value:t})}var u=We(e,`alt`);if(u&&a){var d=a.executeValidate(u,o.alt);if(d)return s.length>0?qe(qe({},d),{},V({},e,s)):d}}return s.length>0&&V({},e,s)}},{key:`validateMediaMimeType`,value:function(e,t){return e.includes(`/`)?_t(e,t)?null:`Mime type mismatch. Found '${e}' but schema accepts '${t}'`:`Invalid mime type format. Got: '${e}'`}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'object', got 'null'`,typeError:!0}])}:B(t)===`object`?Array.isArray(t)?{success:!1,errors:V({},e,[{message:`Expected 'object', got 'array'`,typeError:!0}])}:{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'object', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.item,!0,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`readonly`,value:function(){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,!0,this.isHidden,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`hidden`,value:function(){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,!0,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`router`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,e,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`remote`,value:function(){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions?qe(qe({},this.mediaOptions),{},{remote:!0}):void 0,this.isReadonly,this.isHidden,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`jsonValues`,value:function(){if(this.mediaOptions)throw Error(`.jsonValues() cannot be used with image/file galleries (s.images()/s.files())`);if(this.customValidateFunctions.length>0)throw Error(`.jsonValues() must come BEFORE .validate(): a validator added first is typed against the un-lazy source shape and cannot be carried over. Write s.record(...).jsonValues().validate(...) instead.`);if(this.previewInput!==null)throw Error(`.jsonValues() must come BEFORE .preview(): a preview added first is typed against the un-lazy source shape and cannot be carried over. Write s.record(...).jsonValues().preview(...) instead.`);return new t(this.item,this.opt,[],this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,!0,null,this.renderInput)}},{key:`getRouterValidations`,value:function(e,t){if(!this.currentRouter||t===null)return!1;var n=xe(Lt(e),2),r=n[0];if(n[1])return V({},e,[{message:`This field was configured as a router, but it is not defined at the root of the module`,schemaError:!0}]);var i=this.currentRouter.validate(r,Object.keys(t));return i.length>0&&Object.fromEntries(i.map(function(t){if(!t.error.urlPath)return[e,[{message:`Router validation error: ${t.error.message} has no url path`,schemaError:!0}]];var n=We(e,t.error.urlPath);if(!n)throw Error(`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} for router validation`);return[n,[{message:t.error.message,value:t.error.urlPath,keyError:!0}]]}))}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`executeSerialize`,value:function(){var e={type:`record`,render:this.renderInput??void 0,item:this.item.executeSerialize(),key:this.keySchema?.executeSerialize(),opt:this.opt,preview:this.previewInput?!0:void 0,router:this.currentRouter?.getRouterId(),customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,jsonValues:this.isJsonValues?!0:void 0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description};return this.mediaOptions&&(e.mediaType=this.mediaOptions.type,e.accept=this.mediaOptions.accept,e.directory=this.mediaOptions.directory,e.remote=this.mediaOptions.remote,this.mediaOptions.encode!==void 0&&(e.encode=this.mediaOptions.encode),this.mediaOptions.altSchema&&(e.alt=this.mediaOptions.altSchema.executeSerialize())),e}},{key:`validateJsonEntryContent`,value:function(e,t){return this.item.executeValidate(e,t)}},{key:`executePreview`,value:function(e,t,n){var r={};if(t===null)return r;for(var i in t){var a=t[i];if(a!=null&&!kt(a)){var o=Ge(e,i);if(!(n!==void 0&&!n.wantsUnder(o))){var s=this.item.executePreview(o,a,n);for(var c in s){var l=c;r[l]=s[l]}}}}if(this.item.declaresItemPreview()){for(var u=n!==void 0&&!n.wants(e)?n:null,d=[],f=0,p=Object.entries(t);f<p.length;f++){var m=xe(p[f],2),h=m[0],g=m[1];if(!kt(g)&&g!=null&&!(u!==null&&!u.wantsUnder(Ge(e,h))))try{var _=this.item.executePreviewItem(g);if(_!==null){var v=_.title,y=_.subtitle,b=_.image;d.push([h,{title:v,subtitle:y,image:b}])}}catch(t){r[Ge(e,h)]={status:`error`,message:t instanceof Error?t.message:`Unknown error`}}}r[e]={status:`success`,data:{parent:`record`,items:d}}}return r}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`preview`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,this.isJsonValues,e,this.renderInput)}},{key:`render`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,this.isJsonValues,this.previewInput,e)}}])}(Le);function Pt(e,t){return t?new Nt(t,!1,[],null,e):new Nt(e,!1,[],null,null)}function Ft(e){return e[Be]}function It(e){return B(e)===`object`&&e!==null&&Be in e&&Re in e&&ze in e}function Lt(e){var t=e.indexOf(`?p=`);return t===-1?[e,``]:[e.slice(0,t),e.slice(t+3)]}function Rt(e,t){return t===``?e:`${e}?p=${t}`}function zt(e){return e instanceof Xe||B(e)===`object`&&`type`in e&&e.type===`object`}function Bt(e){return e instanceof Nt||B(e)===`object`&&`type`in e&&e.type===`record`}function Vt(e){return e instanceof Qe||B(e)===`object`&&`type`in e&&e.type===`array`}function Ht(e){return e instanceof nt||B(e)===`object`&&`type`in e&&e.type===`union`}function Ut(e){return e instanceof St||B(e)===`object`&&`type`in e&&e.type===`richtext`}function Wt(e){return e instanceof vt||B(e)===`object`&&`type`in e&&e.type===`image`}function Gt(e,t,n){for(var r=Jt(e),i=z(r),a=n,o=t,s=function(){var t=r.shift();if(t===void 0)throw Error(`Unexpected undefined part`);if(Vt(a)){if(Number.isNaN(Number(t)))throw Error(`Invalid path: array schema ${JSON.stringify(a)} must have a number as path, but got ${t}. Path: ${e}`);if(B(o)!==`object`&&!Array.isArray(o))throw Error(`Schema type error: expected source to be type of array, but got ${B(o)}`);o=o[t],a=a instanceof Qe?a?.item:a.item}else if(Bt(a)){if(typeof t!=`string`)throw Error(`Invalid path: record schema ${a} must have path: ${t} as string`);if(B(o)!==`object`&&!Array.isArray(o))throw Error(`Schema type error: expected source to be type of record, but got ${B(o)}`);if(!o[t])throw Error(`Invalid path: record source did not have key ${t} from path: ${e}`);if(o=o[t],a=a instanceof Nt?a?.item:a.item,kt(o)&&r.length>0)throw Error(`Cannot resolve path into a jsonValues entry until its content is loaded. Path: ${e}`)}else if(zt(a)){if(B(o)!==`object`)throw Error(`Schema type error: expected source to be type of object, but got ${B(o)}`);if(o!==null&&o[t]===void 0)throw Error(`Invalid path: object source did not have key ${t} from path: ${e}`);o=o===null?o:o[t],a=(a instanceof Xe,a.items[t])}else if(Wt(a))return{v:{path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`),schema:a,source:o}};else if(Ht(a)){var n=a.key;if(typeof n!=`string`)return{v:{path:i.map(function(e){return Number.isNaN(Number(e))?JSON.stringify(e):e}).join(`.`),schema:a,source:o}};var s=o[n];if(!s)throw Error(`Invalid path: union source ${a} did not have required key ${n} in path: ${e}`);var c=a.items.find(function(e){var t;return(e==null||(t=e.items)==null||(t=t[n])==null?void 0:t.value)===s});if(!c)throw Error(`Invalid path: union schema ${a} did not have a child object with ${n} of value ${s} in path: ${e}`);a=c.items[t],o=o[t]}else if(Ut(a)){if(`src`in o&&`tag`in o&&o.tag===`img`&&r.length===0){var l,u;a=a instanceof St&&(l=a.options)!=null&&(l=l.inline)!=null&&l.img&&typeof((u=a.options)==null||(u=u.inline)==null?void 0:u.img)!=`boolean`?a.options.inline.img:a}if(`href`in o&&`tag`in o&&o.tag===`a`&&r.length===0){var d,f;a=a instanceof St&&(d=a.options)!=null&&(d=d.inline)!=null&&d.a&&typeof((f=a.options)==null||(f=f.inline)==null?void 0:f.a)!=`boolean`?a.options.inline.a:a}o=o[t]}else throw Error(`Invalid path: ${t} resolved to an unexpected schema ${JSON.stringify(a)}`)},c;r.length>0;)if(c=s(),c)return c.v;if(r.length>0)throw Error(`Invalid path: ${r.join(`.`)} is not a valid path`);return{path:i.map(function(e){return Number.isNaN(Number(e))?JSON.stringify(e):e}).join(`.`),schema:a,source:o}}function Kt(e,t,n){for(var r=Jt(e),i=z(r),a=n,o=t,s=function(){var t=r.shift();if(t===void 0)return{v:{status:`error`,message:`Unexpected undefined part`}};if(Vt(a)){if(Number.isNaN(Number(t)))return{v:{status:`error`,message:`Invalid path: array schema ${JSON.stringify(a)} must have a number as path, but got ${t}. Path: ${e}`}};if(o===void 0)return{v:{status:`source-undefined`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`)}};if(B(o)!==`object`&&!Array.isArray(o))return{v:{status:`error`,message:`Schema type error: expected source to be type of array, but got ${B(o)}`}};if(o[t]===void 0)return{v:{status:`source-undefined`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`)}};o=o[t],a=a instanceof Qe?a?.item:a.item}else if(Bt(a)){if(typeof t!=`string`)return{v:{status:`error`,message:`Invalid path: record schema ${a} must have path: ${t} as string`}};if(o===void 0)return{v:{status:`source-undefined`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`)}};if(B(o)!==`object`&&!Array.isArray(o))return{v:{status:`error`,message:`Schema type error: expected source to be type of record, but got ${B(o)}`}};if(o[t]===void 0)return{v:{status:`source-undefined`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`)}};if(o=o[t],a=a instanceof Nt?a?.item:a.item,kt(o)&&r.length>0)return{v:{status:`error`,message:`Cannot resolve path into a jsonValues entry until its content is loaded. Path: ${e}`}}}else if(zt(a)){if(o===void 0)return{v:{status:`source-undefined`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`)}};if(B(o)!==`object`)return{v:{status:`error`,message:`Schema type error: expected source to be type of object, but got ${B(o)}`}};if(o!==null&&o[t]===void 0)return{v:{status:`error`,message:`Invalid path: object source did not have key ${t} from path: ${e}`}};o=o===null?o:o[t],a=(a instanceof Xe,a.items[t])}else if(Wt(a))return{v:{status:`ok`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`),schema:a,source:o}};else if(Ht(a)){var n=a.key;if(typeof n!=`string`)return{v:{status:`ok`,path:i.map(function(e){return Number.isNaN(Number(e))?JSON.stringify(e):e}).join(`.`),schema:a,source:o}};var s=o[n];if(!s)return{v:{status:`error`,message:`Invalid path: union source ${a} did not have required key ${n} in path: ${e}`}};var c=a.items.find(function(e){var t;return(e==null||(t=e.items)==null||(t=t[n])==null?void 0:t.value)===s});if(!c)return{v:{status:`error`,message:`Invalid path: union schema ${a} did not have a child object with ${n} of value ${s} in path: ${e}`}};a=c.items[t],o=o[t]}else if(Ut(a)){if(`src`in o&&`tag`in o&&o.tag===`img`&&r.length===0){var l,u;a=a instanceof St&&(l=a.options)!=null&&(l=l.inline)!=null&&l.img&&typeof((u=a.options)==null||(u=u.inline)==null?void 0:u.img)!=`boolean`?a.options.inline.img:a}if(`href`in o&&`tag`in o&&o.tag===`a`&&r.length===0){var d,f;a=a instanceof St&&(d=a.options)!=null&&(d=d.inline)!=null&&d.a&&typeof((f=a.options)==null||(f=f.inline)==null?void 0:f.a)!=`boolean`?a.options.inline.a:a}o=o[t]}else return{v:{status:`error`,message:`Invalid path: ${t} resolved to an unexpected schema ${JSON.stringify(a)}`}}},c;r.length>0;)if(c=s(),c)return c.v;return r.length>0?{status:`error`,message:`Invalid path: ${r.join(`.`)} is not a valid path`}:{status:`ok`,path:i.map(function(e){return Number.isNaN(Number(e))?JSON.stringify(e):e}).join(`.`),schema:a,source:o}}function qt(e){return e.split(`/`).slice(1)}function Jt(e){for(var t=[],n=0;n<e.length;){var r=``;if(e[n]===`"`){for(n++;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&e[n+1]===`"`?(r+=`"`,n++):r+=e[n],n++;if(e[n]!==`"`)throw Error(`Invalid input (${JSON.stringify(e)}): Missing closing double quote: ${e[n]??`at end of string`} (char: ${n}; length: ${e.length})`)}else for(;n<e.length&&e[n]!==`.`;)r+=e[n],n++;r!==``&&t.push(r),n++}return t}function Yt(e){return e.split(`,`)}function Xt(e){var t=xe(Lt(e),2),n=t[0],r=t[1],i=Jt(r).slice(0,-1);return i.length>0?Rt(n,Zt(i)):n}function Zt(e){return e.map(function(e){return Number.isInteger(Number(e))?e:JSON.stringify(e)}).join(`.`)}var Qt=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n,r,i=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null?i.length>0&&V({},e,i):typeof t==`number`?(n=this.options)!=null&&n.max&&t>this.options.max?V({},e,[].concat(z(i),[{message:`Expected 'number' less than ${this.options.max}`,value:t}])):(r=this.options)!=null&&r.min&&t<this.options.min?V({},e,[].concat(z(i),[{message:`Expected 'number' greater than ${this.options.min}`,value:t}])):i.length>0&&V({},e,i):V({},e,[].concat(z(i),[{message:`Expected 'number', got '${B(t)}'`,value:t}]))}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'number', got 'null'`,typeError:!0}])}:typeof t==`number`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'number', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`max`,value:function(e){return new t(qe(qe({},this.options),{},{max:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`min`,value:function(e){return new t(qe(qe({},this.options),{},{min:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`number`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,options:this.options,opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),$t=function(e){return new Qt(e)},en=function(e){function t(){var e,n=arguments.length>0&&arguments[0]!==void 0&&arguments[0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null;return De(this,t),e=Pe(this,t),e.opt=n,e.customValidateFunctions=r,e.isReadonly=i,e.isHidden=a,e.description=o,e.renderInput=s,e.previewInput=c,e}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){return this.opt&&t==null?!1:typeof t!=`boolean`&&V({},e,[{message:`Expected 'boolean', got '${B(t)}'`,value:t}])}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'boolean', got 'null'`,typeError:!0}])}:typeof t==`boolean`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'boolean', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`boolean`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),tn=function(){return new en},nn=function(e){function t(e,n){var r,i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5&&arguments[5]!==void 0&&arguments[5],c=arguments.length>6?arguments[6]:void 0,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:null;return De(this,t),r=Pe(this,t),r.schema=e,r.sourcePath=n,r.opt=i,r.customValidateFunctions=a,r.isReadonly=o,r.isHidden=s,r.description=c,r.renderInput=l,r.previewInput=u,r}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.schema,this.sourcePath,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.schema,this.sourcePath,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return n.length>0&&V({},e,n);if(!this.schema)return V({},e,[].concat(z(n),[{message:`Schema not found for module. keyOf must be used with a Val Module`}]));var r=this.schema;if(r.type!==`object`&&r.type!==`record`)return V({},e,[].concat(z(n),[{message:`Schema in keyOf must be an 'object' or 'record'. Found '${r.type||`unknown`}'`}]));if(r.opt&&t==null)return!1;if(r.type===`record`&&typeof t!=`string`)return V({},e,[].concat(z(n),[{message:`Type of value in keyof (record) must be 'string'`}]));if(r.type===`object`){var i=r.keys;if(!i.includes(t))return V({},e,[].concat(z(n),[{message:`Value of keyOf (object) must be: ${i.join(`, `)}. Found: ${t}`}]))}return r.type===`record`?typeof t==`string`?V({},e,[].concat(z(n),[{fixes:[`keyof:check-keys`],message:`Did not validate keyOf (record). This error (keyof:check-keys) should typically be processed by Val internally. Seeing this error most likely means you have a Val version mismatch.`,value:{key:t,sourcePath:this.sourcePath}}])):V({},e,[].concat(z(n),[{message:`Value of keyOf (record) must be 'string'. Found: ${B(t)}`}])):n.length>0&&V({},e,n)}},{key:`executeAssert`,value:function(e,t){if(this.opt&&t===null)return{success:!0,data:t};if(t===null)return{success:!1,errors:V({},e,[{message:`Expected 'string', got 'null'`,typeError:!0}])};var n=this.schema;if(!n)return{success:!1,errors:V({},e,[{message:`Neither key nor schema was found. keyOf is missing an argument.`,typeError:!0}])};var r=n;if(r.type!==`object`&&r.type!==`record`)return{success:!1,errors:V({},e,[{message:`Schema of first argument must be either: 'array', 'object' or 'record'. Found '${r.type||`unknown`}'`,typeError:!0}])};if(r.type===`record`&&typeof t!=`string`)return{success:!1,errors:V({},e,[{message:`Value of keyOf (record) must be 'string', got '${B(t)}'`,typeError:!0}])};if(r.type===`object`){var i=r.keys;if(!i.includes(t))return{success:!1,errors:V({},e,[{message:`Value of keyOf (object) must be: ${i.join(`, `)}. Found: ${t}`,typeError:!0}])}}return{success:!0,data:t}}},{key:`nullable`,value:function(){return new t(this.schema,this.sourcePath,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.schema,this.sourcePath,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.schema,this.sourcePath,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.schema,this.sourcePath,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.schema,this.sourcePath,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){var e=this.sourcePath;if(!e)throw Error(`Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module of record schema.`);var t=this.schema;if(!t)throw Error(`Cannot serialize keyOf schema with empty selector.`);var n;switch(t.type){case`record`:n=`string`;break;case`object`:n=t.keys;break;default:throw Error(`Cannot serialize keyOf schema with selector of type '${t.type||`unknown`}'`)}return{type:`keyOf`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,path:e,schema:t,opt:this.opt,values:n,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),rn=function(e){var t=e?.[Re],n=void 0;if(t instanceof Xe){var r=[];try{r=Object.keys(t?.items||{})}catch{}n={type:`object`,keys:r,opt:t?.opt}}else t instanceof Nt&&(n={type:`record`,opt:t?.opt});return new nn(n,Ue(e))},an=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[],o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},s=arguments.length>5&&arguments[5]!==void 0&&arguments[5],c=arguments.length>6&&arguments[6]!==void 0&&arguments[6],l=arguments.length>7?arguments[7]:void 0,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:null,d=arguments.length>9&&arguments[9]!==void 0?arguments[9]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.isRemote=i,n.customValidateFunctions=a,n.moduleMetadata=o,n.isReadonly=s,n.isHidden=c,n.description=l,n.renderInput=u,n.previewInput=d,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`remote`,value:function(){return new t(this.options,this.opt,!0,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,this.isRemote,[].concat(z(this.customValidateFunctions),[e]),this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return n.length>0&&V({},e,n);if(t==null)return V({},e,[].concat(z(n),[{message:`Non-optional file was null or undefined.`,value:t}]));if(typeof t.path!=`string`)return V({},e,[].concat(z(n),[{message:`File did not have a path string. Got: ${B(t.path)}`,value:t}]));var r=ot(t.path);if(this.isRemote&&!r)return V({},e,[].concat(z(n),[{message:`Expected a remote file, but got a local file.`,value:t,fixes:[`file:upload-remote`]}]));if(this.isRemote&&r)return V({},e,[].concat(z(n),[{message:`Remote file was not checked.`,value:t,fixes:[`file:check-remote`]}]));if(!this.isRemote&&r)return V({},e,[].concat(z(n),[{message:`Expected local file, but found remote.`,value:t,fixes:[`file:download-remote`]}]));var i=this.galleryEntries();if(i)return t.mimeType===void 0?t.path in i?n.length>0&&V({},e,n):V({},e,[].concat(z(n),[{message:`The gallery does not have a file at '${t.path}'.`,value:t}])):V({},e,[].concat(z(n),[{message:`A file from a gallery must not carry its own mimeType: it is stored in the gallery module.`,value:t}]));var a=(this.options||{}).accept,o=t.mimeType;if(a&&o&&!o.includes(`/`))return V({},e,[].concat(z(n),[{message:`Invalid mime type format. Got: ${o}`,value:t}]));if(a&&o&&o.includes(`/`)&&!_t(o,a))return V({},e,[].concat(z(n),[{message:`Mime type mismatch. Found '${o}' but schema accepts '${a}'`,value:t}]));var s=H.filenameToMimeType(t.path);return s?o&&s!==o?V({},e,[].concat(z(n),[{message:`Mime type and file extension not matching. Mime type is '${o}' but file extension is '${s}'`,value:t}])):o===void 0?V({},e,[].concat(z(n),[{message:`File metadata is missing: mimeType.`,value:t,fixes:[`file:add-metadata`]}])):V({},e,[].concat(z(n),[{message:`File mimeType has not been checked against the file.`,value:t,fixes:[`file:check-metadata`]}])):V({},e,[].concat(z(n),[{message:`Could not determine mime type from file extension. Got: ${t.path}`,value:t}]))}},{key:`galleryEntries`,value:function(){var e=Object.keys(this.moduleMetadata);return e.length===0?null:this.moduleMetadata[e[0]]}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'object', got 'null'`,typeError:!0}])}:B(t)===`object`?!(`path`in t)||typeof t.path!=`string`?{success:!1,errors:V({},e,[{message:`A file must be an object with a 'path' (error type: missing_path)`,typeError:!0}])}:{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected object, got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){var e=this.moduleMetadata?Object.keys(this.moduleMetadata):[];return{type:`file`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,options:this.options,opt:this.opt,remote:this.isRemote,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,referencedModule:e.length>0?e[0]:void 0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le);function on(e){if(e&&H.getValPath(e)){for(var t={},n=0,r=[e];n<r.length;n++){var i=r[n],a=Ue(i);if(a===void 0)throw Error(`Invalid argument passed to s.file(). Expected a ValModule constructed through c.define, but got an object without a valid module path.`);t[a]=Ft(i)}return new an({},!1,!1,[],t)}return new an(e)}var sn=function(e){var t=e.directory;return new Nt(new Xe({mimeType:new Je({},!1)},!1),!1,[],null,null,{type:`files`,accept:e.accept,directory:t,remote:e.remote??!1})},cn=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n,r,i,a,o=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null?o.length>0&&V({},e,o):typeof t==`string`?((n=this.options)!=null&&n.from&&(r=this.options)!=null&&r.to?this.options.from>this.options.to?o.push({message:`From date ${this.options.from} is after to date ${this.options.to}`,value:t,typeError:!0}):(t<this.options.from||t>this.options.to)&&o.push({message:`Date is not between ${this.options.from} and ${this.options.to}`,value:t}):(i=this.options)!=null&&i.from?t<this.options.from&&o.push({message:`Date is before the minimum date ${this.options.from}`,value:t}):(a=this.options)!=null&&a.to&&t>this.options.to&&o.push({message:`Date is after the maximum date ${this.options.to}`,value:t}),o.length>0&&V({},e,o)):(o.push({message:`Expected 'string', got '${B(t)}'`,value:t}),V({},e,o))}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'string', got 'null'`,typeError:!0}])}:typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}])}}},{key:`from`,value:function(e){return new t(qe(qe({},this.options),{},{from:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`to`,value:function(e){return new t(qe(qe({},this.options),{},{to:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`date`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,opt:this.opt,options:this.options,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),ln=function(e){return new cn(e)},un=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return n.length>0&&V({},e,n);if(typeof t!=`string`)return n.push({message:`Expected 'string', got '${B(t)}'`,value:t}),V({},e,n);var r=Date.parse(t);if(Number.isNaN(r))return n.push({message:`Value '${t}' is not a valid ISO 8601 datetime`,value:t}),V({},e,n);var i=this.options?.from===void 0?void 0:Date.parse(this.options.from),a=this.options?.to===void 0?void 0:Date.parse(this.options.to);return i!==void 0&&Number.isNaN(i)?(n.push({message:`From datetime '${this.options?.from}' is not a valid ISO 8601 datetime`,value:t,typeError:!0}),V({},e,n)):a!==void 0&&Number.isNaN(a)?(n.push({message:`To datetime '${this.options?.to}' is not a valid ISO 8601 datetime`,value:t,typeError:!0}),V({},e,n)):(i!==void 0&&a!==void 0?i>a?n.push({message:`From datetime ${this.options?.from} is after to datetime ${this.options?.to}`,value:t,typeError:!0}):(r<i||r>a)&&n.push({message:`Datetime is not between ${this.options?.from} and ${this.options?.to}`,value:t}):i===void 0?a!==void 0&&r>a&&n.push({message:`Datetime is after the maximum datetime ${this.options?.to}`,value:t}):r<i&&n.push({message:`Datetime is before the minimum datetime ${this.options?.from}`,value:t}),n.length>0&&V({},e,n))}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'string', got 'null'`,typeError:!0}])}:typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}])}}},{key:`from`,value:function(e){return new t(qe(qe({},this.options),{},{from:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`to`,value:function(e){return new t(qe(qe({},this.options),{},{to:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`dateTime`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,opt:this.opt,options:this.options,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),dn=function(e){return new un(e)},fn=[`typescript`,`javascript`,`javascriptreact`,`typescriptreact`,`json`,`java`,`html`,`css`,`xml`,`markdown`,`sql`,`python`,`rust`,`php`,`go`,`cpp`,`sass`,`vue`,`angular`],pn=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null||typeof t!=`string`&&n.push({message:`Expected 'string', got '${t===null?`null`:B(t)}'`,value:t}),n.length>0&&V({},e,n)}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null||typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${t===null?`null`:B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`code`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,options:this.options,opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),mn=function(e){return new pn(e)};function hn(e){var t=e.trim().toLowerCase();return t.startsWith(`#`)?`hex`:t.startsWith(`rgb(`)||t.startsWith(`rgba(`)?`rgb`:t.startsWith(`hsl(`)||t.startsWith(`hsla(`)?`hsl`:t.startsWith(`oklch(`)?`oklch`:null}function gn(e,t,n){return Number.isNaN(e)?t:Math.min(n,Math.max(t,e))}function _n(e){var t=e.split(`/`);if(t.length>2)return null;var n=t.length===2?t[1].trim():null,r=t[0].trim();if(r===``)return null;var i;if(r.includes(`,`)){if(n!==null)return null;i=r.split(`,`).map(function(e){return e.trim()}),i.length===4&&(n=i[3],i=i.slice(0,3))}else i=r.split(/\s+/);return i.length!==3||i.some(function(e){return e===``})||n===``?null:{components:i,alpha:n}}function vn(e){if(!/^[+-]?(\d+\.?\d*|\.\d+)$/.test(e))return null;var t=Number(e);return Number.isFinite(t)?t:null}function yn(e,t){if(e.endsWith(`%`)){var n=vn(e.slice(0,-1));return n===null?null:n/100*t}return vn(e)}function bn(e){return e.endsWith(`%`)?vn(e.slice(0,-1)):null}function xn(e){if(e===null)return 1;if(e===`none`)return 0;var t=yn(e,1);return t===null?null:gn(t,0,1)}function Sn(e){var t=/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|grad|rad|turn)?$/.exec(e);if(!t)return null;var n=Number(t[1]);switch(t[2]){case`grad`:return n/400*360;case`rad`:return n*180/Math.PI;case`turn`:return n*360;default:return n}}function Cn(e){var t=e%360;return t<0?t+360:t}function wn(e){var t=e.slice(1);if(!/^[0-9a-f]+$/i.test(t))return null;var n=function(e){return parseInt(e+e,16)},r=function(e){return parseInt(t.slice(e,e+2),16)};return t.length===3||t.length===4?{r:n(t[0]),g:n(t[1]),b:n(t[2]),a:t.length===4?n(t[3])/255:1}:t.length===6||t.length===8?{r:r(0),g:r(2),b:r(4),a:t.length===8?r(6)/255:1}:null}function Tn(e,t){return!e.startsWith(t+`(`)||!e.endsWith(`)`)?null:e.slice(t.length+1,-1)}function eee(e){var t=Tn(e,`rgba`)??Tn(e,`rgb`);if(t===null)return null;var n=_n(t);if(!n)return null;var r=n.components.map(function(e){return e===`none`?0:yn(e,255)}),i=xn(n.alpha);return r.some(function(e){return e===null})||i===null?null:{r:gn(r[0],0,255),g:gn(r[1],0,255),b:gn(r[2],0,255),a:i}}function En(e){var t=Tn(e,`hsla`)??Tn(e,`hsl`);if(t===null)return null;var n=_n(t);if(!n)return null;var r=xe(n.components,3),i=r[0],a=r[1],o=r[2],s=i===`none`?0:Sn(i),c=a===`none`?0:bn(a)??vn(a),l=o===`none`?0:bn(o)??vn(o),u=xn(n.alpha);return s===null||c===null||l===null||u===null?null:qe(qe({},Mn(Cn(s),gn(c,0,100),gn(l,0,100))),{},{a:u})}function Dn(e){var t=Tn(e,`oklch`);if(t===null)return null;var n=_n(t);if(!n)return null;var r=xe(n.components,3),i=r[0],a=r[1],o=r[2],s=i===`none`?0:yn(i,1),c=a===`none`?0:yn(a,.4),l=o===`none`?0:Sn(o),u=xn(n.alpha);return s===null||c===null||l===null||u===null?null:qe(qe({},In(gn(s,0,1),Math.max(0,c),Cn(l))),{},{a:u})}function On(e){var t=e.trim().toLowerCase();if(t===``)return null;switch(hn(t)){case`hex`:return wn(t);case`rgb`:return eee(t);case`hsl`:return En(t);case`oklch`:return Dn(t);default:return null}}function kn(e,t){var n=10**t;return Math.round(e*n)/n||0}function An(e){return gn(Math.round(e),0,255).toString(16).padStart(2,`0`)}function jn(e,t,n){var r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=o-s,l=(o+s)/2;if(c===0)return{h:0,s:0,l:l*100};var u=c/(1-Math.abs(2*l-1));return{h:Cn((o===r?(i-a)/c%6:o===i?(a-r)/c+2:(r-i)/c+4)*60),s:u*100,l:l*100}}function Mn(e,t,n){var r=t/100,i=n/100,a=(1-Math.abs(2*i-1))*r,o=Cn(e)/60,s=a*(1-Math.abs(o%2-1)),c=i-a/2,l=o<1?[a,s,0]:o<2?[s,a,0]:o<3?[0,a,s]:o<4?[0,s,a]:o<5?[s,0,a]:[a,0,s];return{r:(l[0]+c)*255,g:(l[1]+c)*255,b:(l[2]+c)*255}}function Nn(e){var t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Pn(e){return gn((e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055)*255,0,255)}function Fn(e,t,n){var r=Nn(e),i=Nn(t),a=Nn(n),o=Math.cbrt(.4122214708*r+.5363325363*i+.0514459929*a),s=Math.cbrt(.2119034982*r+.6806995451*i+.1073969566*a),c=Math.cbrt(.0883024619*r+.2817188376*i+.6299787005*a),l=.2104542553*o+.793617785*s-.0040720468*c,u=1.9779984951*o-2.428592205*s+.4505937099*c,d=.0259040371*o+.7827717662*s-.808675766*c,f=Math.sqrt(u*u+d*d),p=f<1e-6?0:Cn(Math.atan2(d,u)*180/Math.PI);return{l:gn(l,0,1),c:f,h:p}}function In(e,t,n){var r=Cn(n)*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=(e+.3963377774*i+.2158037573*a)**3,s=(e-.1055613458*i-.0638541728*a)**3,c=(e-.0894841775*i-1.291485548*a)**3;return{r:Pn(4.0767416621*o-3.3077115913*s+.2309699292*c),g:Pn(-1.2684380046*o+2.6097574011*s-.3413193965*c),b:Pn(-.0041960863*o-.7034186147*s+1.707614701*c)}}function Ln(e,t){var n=gn(e.a,0,1),r=n>=1?``:` / ${kn(n,4)}`;switch(t){case`hex`:var i=`#${An(e.r)}${An(e.g)}${An(e.b)}`;return n>=1?i:`${i}${An(n*255)}`;case`rgb`:return`rgb(${gn(Math.round(e.r),0,255)} ${gn(Math.round(e.g),0,255)} ${gn(Math.round(e.b),0,255)}${r})`;case`hsl`:var a=jn(e.r,e.g,e.b),o=a.h,s=a.s,c=a.l;return`hsl(${kn(o,2)} ${kn(s,2)}% ${kn(c,2)}%${r})`;case`oklch`:var l=Fn(e.r,e.g,e.b),u=l.l,d=l.c,f=l.h;return`oklch(${kn(u,4)} ${kn(d,4)} ${kn(f,2)}${r})`}}function Rn(e,t){var n=On(e);return n===null?null:Ln(n,t)}function zn(e){return`#${An(e.r)}${An(e.g)}${An(e.b)}`}var Bn={hex:`#3b82f6`,rgb:`rgb(59 130 246)`,hsl:`hsl(217.22 91.22% 59.8%)`,oklch:`oklch(0.6231 0.188 259.81)`},Vn=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return n.length>0&&V({},e,n);if(typeof t!=`string`)return n.push({message:`Expected 'string', got '${B(t)}'`,value:t}),V({},e,n);var r=this.options?.format??`hsl`,i=On(t);if(i===null)n.push({message:`Invalid color: '${t}'. Expected a CSS color in the '${r}' format (e.g. '${Bn[r]}')`,value:t});else{var a;if(hn(t)!==r){var o,s=Ln((o=this.options)!=null&&o.alpha?i:qe(qe({},i),{},{a:1}),r);n.push({message:`Expected a color in the '${r}' format (e.g. '${Bn[r]}'), got '${t}'. Did you mean '${s}'?`,value:t})}!((a=this.options)!=null&&a.alpha)&&i.a<1&&n.push({message:`Color '${t}' has an alpha channel, but alpha is not enabled. Use s.color({ alpha: true }) to allow transparency`,value:t})}return n.length>0&&V({},e,n)}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'string', got 'null'`,typeError:!0}])}:typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`color`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,opt:this.opt,options:this.options,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),Hn=function(e){return new Vn(e)};function Un(e,t,n){return n?new Nt(n,!1,[],e,t):new Nt(t,!1,[],e,Ye())}var Wn=function(e){var t=e.directory,n=e.alt??Ye().nullable();return new Nt(new Xe({width:new Qt(void 0,!1),height:new Qt(void 0,!1),mimeType:new Je({},!1),alt:n},!1),!1,[],null,null,{type:`images`,accept:e.accept??`image/*`,directory:t,remote:e.remote??!1,altSchema:n,encode:e.encode})};function Gn(){return{string:Ye,boolean:tn,array:$e,object:Ze,number:$t,union:rt,richtext:Ct,image:yt,literal:tt,keyOf:rn,record:Pt,file:on,files:sn,date:ln,datetime:dn,color:Hn,code:mn,route:xt,router:Un,images:Wn}}var Kn=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],qn=function(e){return e[e.inputBytes=64]=`inputBytes`,e[e.inputWords=16]=`inputWords`,e[e.highIndex=14]=`highIndex`,e[e.lowIndex=15]=`lowIndex`,e[e.workWords=64]=`workWords`,e[e.allocBytes=80]=`allocBytes`,e[e.allocWords=20]=`allocWords`,e[e.allocTotal=8e3]=`allocTotal`,e}(qn||{}),Jn={sha256:1};function Yn(e){if(e&&!Jn[e]&&!Jn[e.toLowerCase()])throw Error(`Digest method not supported`);return new Xn}var Xn=function(){function e(){De(this,e),V(this,`A`,1779033703),V(this,`B`,-1150833019),V(this,`C`,1013904242),V(this,`D`,-1521486534),V(this,`E`,1359893119),V(this,`F`,-1694144372),V(this,`G`,528734635),V(this,`H`,1541459225),V(this,`_size`,0),V(this,`_sp`,0),(!Qn||$n>=qn.allocTotal)&&(Qn=new ArrayBuffer(qn.allocTotal),$n=0),this._byte=new Uint8Array(Qn,$n,qn.allocBytes),this._word=new Int32Array(Qn,$n,qn.allocWords),$n+=qn.allocBytes}return ke(e,[{key:`update`,value:function(e){if(typeof e==`string`)return this._utf8(e);if(e==null)throw TypeError(`Invalid type: `+B(e));var t=e.byteOffset,n=e.byteLength,r=n/qn.inputBytes|0,i=0;if(r&&!(t&3)&&!(this._size%qn.inputBytes)){for(var a=new Int32Array(e.buffer,t,r*qn.inputWords);r--;)this._int32(a,i>>2),i+=qn.inputBytes;this._size+=i}if(e.BYTES_PER_ELEMENT!==1&&e.buffer){var o=new Uint8Array(e.buffer,t+i,n-i);return this._uint8(o)}return i===n?this:this._uint8(e,i)}},{key:`_uint8`,value:function(e,t){var n=this._byte,r=this._word,i=e.length;for(t|=0;t<i;){for(var a=this._size%qn.inputBytes,o=a;t<i&&o<qn.inputBytes;)n[o++]=e[t++];o>=qn.inputBytes&&this._int32(r),this._size+=o-a}return this}},{key:`_utf8`,value:function(e){for(var t=this._byte,n=this._word,r=e.length,i=this._sp,a=0;a<r;){for(var o=this._size%qn.inputBytes,s=o;a<r&&s<qn.inputBytes;){var c=e.charCodeAt(a++)|0;c<128?t[s++]=c:c<2048?(t[s++]=192|c>>>6,t[s++]=128|c&63):c<55296||c>57343?(t[s++]=224|c>>>12,t[s++]=128|c>>>6&63,t[s++]=128|c&63):i?(c=((i&1023)<<10)+(c&1023)+65536,t[s++]=240|c>>>18,t[s++]=128|c>>>12&63,t[s++]=128|c>>>6&63,t[s++]=128|c&63,i=0):i=c}s>=qn.inputBytes&&(this._int32(n),n[0]=n[qn.inputWords]),this._size+=s-o}return this._sp=i,this}},{key:`_int32`,value:function(e,t){var n=this.A,r=this.B,i=this.C,a=this.D,o=this.E,s=this.F,c=this.G,l=this.H,u=0;for(t|=0;u<qn.inputWords;)Zn[u++]=tr(e[t++]);for(u=qn.inputWords;u<qn.workWords;u++)Zn[u]=sr(Zn[u-2])+Zn[u-7]+or(Zn[u-15])+Zn[u-16]|0;for(u=0;u<qn.workWords;u++){var d=l+ar(o)+nr(o,s,c)+Kn[u]+Zn[u]|0,f=ir(n)+rr(n,r,i)|0;l=c,c=s,s=o,o=a+d|0,a=i,i=r,r=n,n=d+f|0}this.A=n+this.A|0,this.B=r+this.B|0,this.C=i+this.C|0,this.D=a+this.D|0,this.E=o+this.E|0,this.F=s+this.F|0,this.G=c+this.G|0,this.H=l+this.H|0}},{key:`digest`,value:function(e){var t=this._byte,n=this._word,r=this._size%qn.inputBytes|0;for(t[r++]=128;r&3;)t[r++]=0;if(r>>=2,r>qn.highIndex){for(;r<qn.inputWords;)n[r++]=0;r=0,this._int32(n)}for(;r<qn.inputWords;)n[r++]=0;var i=this._size*8,a=(i&4294967295)>>>0,o=(i-a)/4294967296;return o&&(n[qn.highIndex]=tr(o)),a&&(n[qn.lowIndex]=tr(a)),this._int32(n),e===`hex`?this._hex():this._bin()}},{key:`_hex`,value:function(){var e=this.A,t=this.B,n=this.C,r=this.D,i=this.E,a=this.F,o=this.G,s=this.H;return er(e)+er(t)+er(n)+er(r)+er(i)+er(a)+er(o)+er(s)}},{key:`_bin`,value:function(){var e=this.A,t=this.B,n=this.C,r=this.D,i=this.E,a=this.F,o=this.G,s=this.H,c=this._byte,l=this._word;return l[0]=tr(e),l[1]=tr(t),l[2]=tr(n),l[3]=tr(r),l[4]=tr(i),l[5]=tr(a),l[6]=tr(o),l[7]=tr(s),c.slice(0,32)}}])}(),Zn=new Int32Array(qn.workWords),Qn,$n=0,er=function(e){return(e+4294967296).toString(16).substr(-8)},tr=cr()?function(e){return e}:function(e){return e<<24&4278190080|e<<8&16711680|e>>8&65280|e>>24&255},nr=function(e,t,n){return n^e&(t^n)},rr=function(e,t,n){return e&t|n&(e|t)},ir=function(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)},ar=function(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)},or=function(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3},sr=function(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10};function cr(){return new Uint8Array(new Uint16Array([65279]).buffer)[0]===254}var lr=function(e){return Yn().update(e).digest(`hex`)};function ur(e){if(e.type===`file`||e.type===`image`)return!!e.remote;if(e.type===`richtext`){var t;return B((t=e.options)==null||(t=t.inline)==null?void 0:t.img)===`object`&&ur(e.options.inline.img)}if(e.type===`array`)return ur(e.item);if(e.type===`record`)return e.mediaType&&e.remote?!0:ur(e.item);if(e.type===`object`){for(var n in e.items)if(ur(e.items[n]))return!0;return!1}if(e.type===`union`){var r=B(e.key)===`object`&&e.key.type===`literal`?e:void 0,i=typeof e.key==`string`?e:void 0;if(r)return!1;if(i){var a=w(i.items),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;if(ur(s))return!0}}catch(e){a.e(e)}finally{a.f()}}return!1}if(e.type===`boolean`||e.type===`number`||e.type===`string`||e.type===`literal`||e.type===`date`||e.type===`dateTime`||e.type===`color`||e.type===`code`||e.type===`keyOf`||e.type===`route`)return!1;throw Error(`Unexpected schema: ${JSON.stringify(e)}`)}var dr=`https://remote.val.build`,fr=ke(function e(t){De(this,e),this.message=t});function pr(e,t){var n=t.publicProjectId,r=t.coreVersion,i=t.validationHash,a=t.fileHash,o=t.filePath;return`${e}/file/p/${n}/b/${t.bucket}/v/${r}/h/${i}/f/${a}/p/${o}`}function mr(e,t,n,r,i){var a=`${r?.width||``}${r?.height||``}${r?.mimeType}`,o=qe({},t.options);delete o.encode;var s={type:t.type,opt:t.opt,options:o};return e+JSON.stringify(s)+n+a+i}function hr(e,t,n,r,i,a){return lr(a.encode(mr(e,t,n,r,i))).slice(0,4)}function gr(e){return e.slice(0,12)}function _r(e){return gr(lr(new Uint8Array(e)))}function vr(e){var t=yr(e);return e.readonly&&(t=t.readonly()),e.hidden&&(t=t.hidden()),t}function yr(e){var t;switch(e.type){case`string`:return new Je(qe(qe({},e.options),{},{regexp:e.options?.regexp&&new RegExp(e.options.regexp.source,e.options.regexp.flags),regExpMessage:(t=e.options)==null||(t=t.regexp)==null?void 0:t.message}),e.opt,e.raw,[],e.render??null,!1,!1,e.description,null,e.multiline??!1);case`literal`:return new et(e.value,e.opt,[],!1,!1,e.description,e.render??null);case`boolean`:return new en(e.opt,[],!1,!1,e.description,e.render??null);case`number`:return new Qt(e.options,e.opt,[],!1,!1,e.description,e.render??null);case`object`:return new Xe(Object.fromEntries(Object.entries(e.items).map(function(e){var t=xe(e,2),n=t[0],r=t[1];return[n,vr(r)]})),e.opt,[],!1,!1,e.description,e.render??null);case`array`:return new Qe(vr(e.item),e.opt,[],!1,!1,e.description,null,e.render??null);case`union`:return new nt(typeof e.key==`string`?e.key:vr(e.key),e.items.map(vr),e.opt,[],!1,!1,e.description,e.render??null);case`richtext`:var n,r,i,a,o,s;return new St(qe(qe({},e.options||{}),{},{inline:B((n=e.options)==null||(n=n.inline)==null?void 0:n.img)===`object`||B((r=e.options)==null||(r=r.inline)==null?void 0:r.a)===`object`?{a:B((i=e.options)==null||(i=i.inline)==null?void 0:i.a)===`object`?vr(e.options.inline.a):(a=e.options)==null||(a=a.inline)==null?void 0:a.a,img:B((o=e.options)==null||(o=o.inline)==null?void 0:o.img)===`object`?vr(e.options.inline.img):(s=e.options)==null||(s=s.inline)==null?void 0:s.img}:e.options?.inline}),e.opt,[],!1,!1,e.description,e.render??null);case`record`:return new Nt(vr(e.item),e.opt,[],null,e.key?vr(e.key):null,e.mediaType?{type:e.mediaType,accept:e.accept??`*/*`,directory:e.directory??`/public/val`,remote:e.remote??!1,altSchema:e.alt?vr(e.alt):void 0}:void 0,!1,!1,e.description,e.jsonValues??!1,null,e.render??null);case`keyOf`:return new nn(e.schema,e.path,e.opt,[],!1,!1,e.description,e.render??null);case`route`:return new bt(e.options?{include:e.options.include?new RegExp(e.options.include.source,e.options.include.flags):void 0,exclude:e.options.exclude?new RegExp(e.options.exclude.source,e.options.exclude.flags):void 0}:void 0,e.opt,[],!1,!1,e.description,e.render??null);case`file`:return new an(e.options,e.opt,e.remote,[],{},!1,!1,e.description,e.render??null);case`image`:return new vt(e.options,e.opt,e.remote,[],{},!1,!1,e.description,e.render??null);case`date`:return new cn(e.options,e.opt,[],!1,!1,e.description,e.render??null);case`dateTime`:return new un(e.options,e.opt,[],!1,!1,e.description,e.render??null);case`color`:return new Vn(e.options,e.opt,[],!1,!1,e.description,e.render??null);case`code`:return new pn(e.options,e.opt,[],!1,!1,e.description,e.render??null);default:var c=e;throw c&&B(c)===`object`&&`type`in c?Error(`Unknown schema type: ${c.type}`):Error(`Unknown schema: ${JSON.stringify(c,null,2)}`)}}function br(e){var t=e.map(function(e){var t=xe(Lt(e),2),n=t[0],r=t[1];return{moduleFilePath:n,segments:r===``?[]:Jt(r)}}),n=function(e){var t=xe(Lt(e),2),n=t[0],r=t[1];return{moduleFilePath:n,segments:r===``?[]:Jt(r)}},r=function(e,t){if(e.length>t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0};return{wants:function(e){var i=n(e);return t.some(function(e){return e.moduleFilePath===i.moduleFilePath&&e.segments.length===i.segments.length&&r(e.segments,i.segments)})},wantsUnder:function(e){var i=n(e);return t.some(function(e){return e.moduleFilePath===i.moduleFilePath&&(r(i.segments,e.segments)||r(e.segments,i.segments))})}}}function xr(e){return e.render?.as===`inline`||e.type===`union`&&e.items.some(function(e){return e.render?.as===`inline`})}var Sr={getRouterId:function(){return`external-url-router`},validate:function(e,t){var n=[],r=w(t),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;a.startsWith(`https://`)||a.startsWith(`http://`)||n.push({error:{message:`URL path "${a}" does not start with "https://" or "http://"`,expectedPath:null,urlPath:a}})}}catch(e){r.e(e)}finally{r.f()}return[]}};function Cr(e,t){var n=e.startsWith(`/`)?e.slice(1).split(`/`):e.split(`/`);if(t.length===0)return{isValid:n.length===0||n.length===1&&n[0]===``,expectedPath:`/`};for(var r=0,i=0,a=!1,o=-1,s=0;s<t.length;s++){var c=t[s];c.startsWith(`[[`)&&c.endsWith(`]]`)?(a=!0,o=s,i=1/0):c.startsWith(`[...`)&&c.endsWith(`]`)?(a=!0,o=s,r++,i=1/0):c.startsWith(`[[`)&&c.endsWith(`]`)?i++:(c.startsWith(`[`)&&c.endsWith(`]`),r++,i++)}if(n.length<r||!a&&n.length>i)return{isValid:!1,expectedPath:`/${t.map(function(e){return e.startsWith(`[[`)&&e.endsWith(`]]`)?`[optional:${e.slice(2,-2)}]`:e.startsWith(`[...`)&&e.endsWith(`]`)?`[...${e.slice(4,-1)}]`:e.startsWith(`[[`)&&e.endsWith(`]`)?`[optional:${e.slice(2,-1)}]`:e.startsWith(`[`)&&e.endsWith(`]`)?`[${e.slice(1,-1)}]`:e}).join(`/`)}`};for(var l=a?o:t.length,u=0;u<l;u++){var d=t[u],f=n[u];if(d.startsWith(`[[`)&&d.endsWith(`]]`)){if(f!==``&&f!==void 0&&f===``)return{isValid:!1,expectedPath:`/${t.join(`/`)}`}}else if(d.startsWith(`[`)&&d.endsWith(`]`)){if(f===``||f===void 0)return{isValid:!1,expectedPath:`/${t.join(`/`)}`}}else if(d!==f)return{isValid:!1,expectedPath:`/${t.join(`/`)}`}}return{isValid:!0}}var wr={getRouterId:function(){return`next-app-router`},validate:function(e,t){var n=Tr(e),r=[],i=w(t),a;try{for(i.s();!(a=i.n()).done;){var o=a.value,s=Cr(o,n);s.isValid||r.push({error:{message:`URL path "${o}" does not match the route pattern for "${e}"`,urlPath:o,expectedPath:s.expectedPath||null}})}}catch(e){i.e(e)}finally{i.f()}return r}};function Tr(e){if(!e||typeof e!=`string`)return[];for(var t=[/\/app\/(.+)\/page\.val\.ts$/,/\/src\/app\/(.+)\/page\.val\.ts$/,/\/app\/(.+)\/page\.tsx?$/,/\/src\/app\/(.+)\/page\.tsx?$/],n=0,r=t;n<r.length;n++){var i=r[n],a=e.match(i);if(a)return a[1].split(`/`).flatMap(function(e){if(e.startsWith(`(`)&&e.endsWith(`)`)&&!e.includes(`.`))return[];var t=e.match(/^(\([.]+\)(\(.+\))?)(.*)$/);if(t){var n=t[3]||t[4];return n?[n]:[]}return[e]})}return[]}function Er(e,t){for(var n=0,r=Object.entries(t);n<r.length;n++){var i=xe(r[n],2),a=i[0],o=i[1];if(o.type===`record`&&o.router===`next-app-router`&&Cr(e,Tr(a)).isValid)return{moduleFilePath:a,sourcePath:`${a}?p=${JSON.stringify(e)}`,route:e}}return null}var Dr=`https://content.val.build`,Or=`https://admin.val.build`,H={VERSION:{core:function(){try{return(_e(),d(ne).default).version}catch{return null}}()},mediaUrl:st,resolveMedia:ct,isRemoteMediaPath:ot,media:{fillFromGallery:ut},getSchema:Ve,getValPath:Ue,getSource:Ft,isValModule:It,resolvePath:Gt,safeResolvePath:Kt,splitModuleFilePathAndModulePath:Lt,joinModuleFilePathAndModulePath:Rt,nextAppRouter:wr,externalPageRouter:Sr,color:{parseColor:On,formatColor:Ln,convertColor:Rn,detectColorFormat:hn,colorToHex:zn},remote:{createRemoteRef:pr,getValidationBasis:mr,getValidationHash:hr,getFileHash:_r,hashToRemoteFileHash:gr,splitRemoteRef:at},validate:function(e,t,n){return e&&Ve(e)?.executeValidate(t,n)},isVal:He,isJson:kt,getJsonImport:At,resolveJsonValues:jt,createValPathOfItem:We,getSHA256Hash:lr,initSchema:Gn,getMimeType:mt,mimeTypeToFileExt:ht,filenameToMimeType:gt,mimeTypeMatchesAccept:_t,EXT_TO_MIME_TYPES:dt,MIME_TYPES_TO_EXT:ft,ModuleFilePathSep:`?p=`,notFileOp:function(e){return e.op!==`file`},isFileOp:function(e){return e.op===`file`&&typeof e.filePath==`string`},createPatchJSONPath:function(e){return`/${e.split(`.`).map(function(e){return e&&kr(e)}).join(`/`)}`},createPatchPath:function(e){return Jt(e)},splitModulePath:Jt,splitModuleFilePath:qt,splitJoinedSourcePaths:Yt,parentOfSourcePath:Xt,patchPathToModulePath:Zt,VAL_ENABLE_COOKIE_NAME:`val_enable`,VAL_STATE_COOKIE:`val_state`,VAL_SESSION_COOKIE:`val_session`,createFilename:function(e,t,n,r){if(!n||!e)return t;var i=r.slice(0,5),a=H.getMimeType(e)??`unknown`,o=H.mimeTypeToFileExt(a)??`unknown`;if(t){var s=t.split(`.`).slice(0,-1).join(`.`)||t,c=s.lastIndexOf(`_`);return s.slice(c+1,s.length)===i&&(s=s.slice(0,c)),`${encodeURIComponent(s).replace(/%[0-9A-Fa-f]{2}/g,``).toLowerCase()}_${i}.${o}`}return`${r}.${o}`}};function kr(e){try{return JSON.parse(e)}catch{return e}}function Ar(e){for(var t=e,n=[...arguments].slice(1),r=0,i=n;r<i.length;r++){var a=i[r];t=a(t)}return t}function jr(e){return T(e)}function Mr(e,t){if(e===t)return!0;if(B(e)===`object`&&B(t)===`object`&&e!==null&&t!==null){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(!Mr(e[n],t[n]))return!1;return!0}if(!Array.isArray(e)&&!Array.isArray(t)){var r=Object.entries(e);if(r.length!==Object.keys(t).length)return!1;for(var i=0,a=r;i<a.length;i++){var o=xe(a[i],2),s=o[0],c=o[1],l=t[s];if(l===void 0||!Mr(c,l))return!1}return!0}}return!1}function Nr(e){return Array.isArray(e)?e.map(Nr):B(e)===`object`&&e!==null?Object.fromEntries(Object.entries(e).map(function(e){var t=xe(e,2),n=t[0],r=t[1];return[n,Nr(r)]})):e}function Pr(e){return/^(0|[1-9][0-9]*)$/g.test(e)?D(Number(e)):O(new fr(`Invalid array index "${e}"`))}function Fr(e,t){return e===`-`?D(t.length):Ar(Pr(e),ee(function(e){return e<=t.length},function(){return new fr(`Array index out of bounds`)}))}function Ir(e,t){return Ar(Pr(e),ee(function(e){return e<t.length},function(){return new fr(`Array index out of bounds`)}))}function Lr(e,t,n){if(Array.isArray(e))return Ar(Ir(t,e),F(function(t){var r=e[t];return e[t]=n,r}));if(B(e)===`object`&&e!==null){if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];return e[t]=n,D(r)}return O(new fr(`Cannot replace object element which does not exist`))}return O(new fr(`Cannot replace in non-object/array`))}function Rr(e,t,n){return jr(t)?Ar(Br(e,t),I(function(e){var t=xe(e,2),r=t[0],i=t[1];return Lr(r,i,n)}),F(function(t){return[e,t]})):D([n,e])}function zr(e,t){return Array.isArray(e)?Ar(Pr(t),I(function(t){return t>=e.length?O(new fr(`Array index out of bounds`)):D(e[t])})):B(e)===`object`&&e!==null?Object.prototype.hasOwnProperty.call(e,t)?D(e[t]):D(void 0):O(new fr(`Cannot access non-object/array`))}function Br(e,t){for(var n=e,r=t[0],i=0;i<t.length-1;++i,r=t[i]){var a=zr(n,r);if(A(a))return a;if(a.value===void 0)return O(new fr(`Path refers to non-existing object/array`));n=a.value}return D([n,r])}function Vr(e,t){return Ar(t,P(function(e,t){return Ar(zr(e,t),ee(function(e){return e!==void 0},function(){return new fr(`Path refers to non-existing object/array`)}))},e))}function Hr(e,t){if(Array.isArray(e))return Ar(Ir(t,e),F(function(t){return xe(e.splice(t,1),1)[0]}));if(B(e)===`object`&&e!==null&&Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];return delete e[t],D(n)}return O(new fr(`Cannot remove from non-object/array`))}function Ur(e,t){return Ar(Br(e,t),I(function(e){var t=xe(e,2),n=t[0],r=t[1];return Hr(n,r)}))}function Wr(e,t,n){if(Array.isArray(e))return Ar(Fr(t,e),F(function(t){e.splice(t,0,n)}));if(B(e)===`object`&&e!==null){var r;return Object.prototype.hasOwnProperty.call(e,t)&&(r=e[t]),e[t]=n,D(r)}return O(new fr(`Cannot add to non-object/array`))}function Gr(e,t,n){return jr(t)?Ar(Br(e,t),I(function(e){var t=xe(e,2),r=t[0],i=t[1];return Wr(r,i,n)}),F(function(t){return[e,t]})):D([n,e])}function Kr(e){return xe(e,1)[0]}var qr=function(){function e(){De(this,e)}return ke(e,[{key:`get`,value:function(e,t){return Vr(e,t)}},{key:`add`,value:function(e,t,n){return Ar(Gr(e,t,n),F(Kr))}},{key:`remove`,value:function(e,t){return Ar(Ur(e,t),F(function(){return e}))}},{key:`replace`,value:function(e,t,n){return Ar(Rr(e,t,n),F(Kr))}},{key:`move`,value:function(e,t,n){return Ar(Ur(e,t),I(function(t){return Gr(e,n,t)}),F(Kr))}},{key:`copy`,value:function(e,t,n){return Ar(Vr(e,t),I(function(t){return Gr(e,n,Nr(t))}),F(Kr))}},{key:`test`,value:function(e,t,n){return Ar(Vr(e,t),F(function(e){return Mr(n,e)}))}}])}();function Jr(e,t,n){switch(n.op){case`add`:return t.add(e,n.path,n.value);case`remove`:return t.remove(e,n.path);case`replace`:return t.replace(e,n.path,n.value);case`move`:return t.move(e,n.from,n.path);case`copy`:return t.copy(e,n.from,n.path);case`test`:return t.test(e,n.path,n.value)?D(e):O(new fr(`Test failed`));case`file`:return O(new fr(`Cannot apply a file patch here`))}}function Yr(e,t,n){return Ar(n,P(function(e,n){return Jr(e,t,n)},e))}function Xr(e){for(var t=e.split(`,`)[1],n=atob(t),r=new Uint8Array(n.length),i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r}var Zr;function U(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Qr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},$r=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Zr=globalThis).__zod_globalConfig??(Zr.__zod_globalConfig={});var ei=globalThis.__zod_globalConfig;function ti(e){return e&&Object.assign(ei,e),ei}function ni(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ri(e,t){return typeof t==`bigint`?t.toString():t}function ii(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ai(e){return e==null}function oi(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function si(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var ci=Symbol(`evaluating`);function li(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ci)return r===void 0&&(r=ci,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ui(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function di(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function fi(e){return JSON.stringify(e)}function pi(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var mi=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function hi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var gi=ii(()=>{if(ei.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function _i(e){if(hi(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return hi(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function vi(e){return _i(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var yi=new Set([`string`,`number`,`symbol`]);function bi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function xi(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Si(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ci(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var wi={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ti(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return xi(e,di(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return ui(this,`shape`,e),e},checks:[]}))}function Ei(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return xi(e,di(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return ui(this,`shape`,r),r},checks:[]}))}function Di(e,t){if(!_i(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return xi(e,di(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ui(this,`shape`,n),n}}))}function Oi(e,t){if(!_i(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return xi(e,di(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ui(this,`shape`,n),n}}))}function ki(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return xi(e,di(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ui(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ai(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return xi(t,di(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return ui(this,`shape`,i),i},checks:[]}))}function ji(e,t,n){return xi(t,di(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return ui(this,`shape`,i),i}}))}function Mi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ni(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Pi(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Fi(e){return typeof e==`string`?e:e?.message}function Ii(e,t,n){let r=e.message?e.message:Fi(e.inst?._zod.def?.error?.(e))??Fi(t?.error?.(e))??Fi(n.customError?.(e))??Fi(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Li(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ri(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var zi=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ri,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Bi=U(`$ZodError`,zi),Vi=U(`$ZodError`,zi,{Parent:Error});function Hi(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ui(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function Wi(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Gi(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Wi(e.path)}`);return t.join(`
|
|
12
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function z(e){return Se(e)||Ce(e)||C(e)||we()}function B(e){"@babel/helpers - typeof";return B=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},B(e)}function Te(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ee(e){var t=Te(e,`string`);return typeof t==`symbol`?t:t+``}function V(e,t,n){return(t=Ee(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function De(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Oe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,Ee(r.key),r)}}function ke(e,t,n){return t&&Oe(e.prototype,t),n&&Oe(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ae(e){return Ae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ae(e)}function je(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(je=function(){return!!e})()}function Me(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function Ne(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return Me(e)}function Pe(e,t,n){return t=Ae(t),Ne(e,je()?Reflect.construct(t,n||[],Ae(e).constructor):t.apply(e,n))}function Fe(e,t){return Fe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Fe(e,t)}function Ie(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Fe(e,t)}var Le=function(){function e(){De(this,e)}return ke(e,[{key:`executeCustomValidateFunctions`,value:function(e,t,n){var r=[],i=w(t),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;try{var s=o(e,n);s&&r.push({message:s,value:e})}catch(t){r.push({message:`Error in custom validate function: ${t instanceof Error?t.message:String(t)}`,value:e,schemaError:!0})}}}catch(e){i.e(e)}finally{i.f()}return r}},{key:`executePreviewItem`,value:function(e){return null}},{key:`declaresItemPreview`,value:function(){return!1}},{key:`appendValidationError`,value:function(e,t,n,r,i){return e?(e[t]?e[t].push({message:n,value:r,schemaError:i}):e[t]=[{message:n,value:r,schemaError:i}],e):V({},t,[{message:n,value:r,schemaError:i}])}},{key:`mergeValidationErrors`,value:function(e,t){if(!t)return e;if(!e)return t;for(var n in t){var r=n;e[r]=e[r]?e[r].concat(t[r]):t[r]}return e}}])}(),Re=Symbol.for(`@valbuild/core/GetSchema`),ze=Symbol.for(`@valbuild/core/Path`),Be=Symbol.for(`@valbuild/core/GetSource`);function Ve(e){return e[Re]}function He(e){return B(e)===`object`&&e!=null&&ze in e&&`val`in e}function Ue(e){return e[ze]}function We(e,t){if(B(t)===`symbol`)throw Error(`Cannot create val path of array item with symbol prop: ${t.toString()}`);if(e)return e.includes(H.ModuleFilePathSep)?`${e}.${JSON.stringify(t)}`:`${e}${H.ModuleFilePathSep}${JSON.stringify(t)}`}function Ge(e,t){if(B(t)===`symbol`)throw Error(`Cannot create val path of array item with symbol prop: ${t.toString()}`);if(!e)throw Error(`Cannot create val path of array item of empty or missing path: ${e}. Item: ${t}`);return e.includes(H.ModuleFilePathSep)?`${e}.${JSON.stringify(t)}`:`${e}${H.ModuleFilePathSep}${JSON.stringify(t)}`}function Ke(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function qe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ke(Object(n),!0).forEach(function(t){V(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ke(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Je=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[],o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,s=arguments.length>5&&arguments[5]!==void 0&&arguments[5],c=arguments.length>6&&arguments[6]!==void 0&&arguments[6],l=arguments.length>7?arguments[7]:void 0,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:null,d=arguments.length>9&&arguments[9]!==void 0&&arguments[9];return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.isRaw=i,n.customValidateFunctions=a,n.renderInput=o,n.isReadonly=s,n.isHidden=c,n.description=l,n.previewInput=u,n.isMultiline=d,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,e??void 0,this.previewInput,this.isMultiline)}},{key:`min`,value:function(e){return this.minLength(e)}},{key:`minLength`,value:function(e){return new t(qe(qe({},this.options),{},{minLength:e}),this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`max`,value:function(e){return this.maxLength(e)}},{key:`maxLength`,value:function(e){return new t(qe(qe({},this.options),{},{maxLength:e}),this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`regexp`,value:function(e,n){return new t(qe(qe({},this.options),{},{regexp:e,regExpMessage:n}),this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions.concat(e),this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`executeValidate`,value:function(e,t){var n,r,i,a=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null?a.length>0&&V({},e,a):!this.opt&&t==null?V({},e,[{message:`Expected 'string', got '${t===null?`null`:`undefined`}'`,value:t}]):typeof t==`string`?((n=this.options)!=null&&n.maxLength&&t.length>this.options.maxLength&&a.push({message:`Expected string to be at most ${this.options.maxLength} characters long, got ${t.length}`,value:t}),(r=this.options)!=null&&r.minLength&&t.length<this.options.minLength&&a.push({message:`Expected string to be at least ${this.options.minLength} characters long, got ${t.length}`,value:t}),(i=this.options)!=null&&i.regexp&&!this.options.regexp.test(t)&&a.push({message:this.options.regExpMessage||`Expected string to match reg exp: ${this.options.regexp.toString()}, got '${t}'`,value:t}),a.length>0&&V({},e,a)):V({},e,[{message:`Expected 'string', got '${B(t)}'`,value:t}])}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null||typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,!0,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,!0,this.description,this.previewInput,this.isMultiline)}},{key:`raw`,value:function(){return new t(this.options,this.opt,!0,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`executeSerialize`,value:function(){return{type:`string`,render:this.renderInput??void 0,multiline:this.isMultiline?!0:void 0,preview:this.previewInput?!0:void 0,options:{maxLength:this.options?.maxLength,minLength:this.options?.minLength,regexp:this.options?.regexp&&{message:this.options.regExpMessage,source:this.options.regexp.source,flags:this.options.regexp.flags},customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0},opt:this.opt,raw:this.isRaw,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`multiline`,value:function(){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,this.previewInput,!0)}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,e,this.isReadonly,this.isHidden,this.description,this.previewInput,this.isMultiline)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.isRaw,this.customValidateFunctions,this.renderInput,this.isReadonly,this.isHidden,this.description,e,this.isMultiline)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executePreview`,value:function(){return{}}}])}(Le),Ye=function(e){return new Je(e)},Xe=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.items=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.items,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=!1,r=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return r.length>0&&V({},e,r);if(t===null)return V({},e,[{message:`Expected 'object', got 'null'`}]);if(B(t)!==`object`)return V({},e,[{message:`Expected 'object', got '${B(t)}'`}]);if(Array.isArray(t))return V({},e,[{message:`Expected 'object', got 'array'`}]);var i=w(r),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;n=this.appendValidationError(n,e,o.message,t,o.schemaError)}}catch(e){i.e(e)}finally{i.f()}for(var s=0,c=Object.entries(this.items);s<c.length;s++){var l=xe(c[s],2),u=l[0],d=l[1],f=We(e,u);if(!f)n=this.appendValidationError(n,e,`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} at key ${u}`,t);else{var p=d.executeValidate(f,t[u]);n=this.mergeValidationErrors(n,p)}}return n}},{key:`executeAssert`,value:function(e,t){if(this.opt&&t===null)return{success:!0,data:t};if(t===null)return{success:!1,errors:V({},e,[{message:`Expected 'object', got 'null'`,typeError:!0}])};if(B(t)!==`object`)return{success:!1,errors:V({},e,[{message:`Expected 'object', got '${B(t)}'`,typeError:!0}])};if(Array.isArray(t))return{success:!1,errors:V({},e,[{message:`Expected 'object', got 'array'`,typeError:!0}])};for(var n=[],r=0,i=Object.keys(this.items);r<i.length;r++){var a=i[r];We(e,a)?a in t||n.push({message:`Expected key '${a}' not found in object`,typeError:!0}):n.push({message:`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} at key ${a}`,internalError:!0})}return n.length>0?{success:!1,errors:V({},e,n)}:{success:!0,data:t}}},{key:`nullable`,value:function(){return new t(this.items,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.items,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.items,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`object`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,items:Object.fromEntries(Object.entries(this.items).map(function(e){var t=xe(e,2);return[t[0],t[1].executeSerialize()]})),opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(e,t,n){var r={};if(t===null)return r;for(var i in this.items){var a=t[i];if(a!=null){var o=Ge(e,i);if(!(n!==void 0&&!n.wantsUnder(o))){var s=this.items[i].executePreview(o,a,n);for(var c in s){var l=c;r[l]=s[l]}}}}return r}}])}(Le),Ze=function(e){return new Xe(e)};Ze({get test(){return Ye()}});var Qe=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.item=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.previewInput=c,n.renderInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.previewInput,this.renderInput)}},{key:`validate`,value:function(e){return new t(this.item,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.previewInput,this.renderInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeAssert(e,t);if(!n.success)return n.errors;if(n.data===null)return!1;for(var r=!1,i=0,a=Object.entries(n.data);i<a.length;i++){var o=xe(a[i],2),s=o[0],c=o[1],l=Ge(e,Number(s)),u=this.item.executeValidate(l,c);r=this.mergeValidationErrors(r,u)}return r}},{key:`executeAssert`,value:function(e,t){return t===null&&this.opt?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'array', got 'null'`,typeError:!0}])}:B(t)===`object`?Array.isArray(t)?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected object of type 'array'`,typeError:!0}])}:{success:!1,errors:V({},e,[{message:`Expected 'object', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.item,!0,[],this.isReadonly,this.isHidden,this.description,this.previewInput,this.renderInput)}},{key:`readonly`,value:function(){return new t(this.item,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.previewInput,this.renderInput)}},{key:`hidden`,value:function(){return new t(this.item,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.previewInput,this.renderInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`executeSerialize`,value:function(){return{type:`array`,render:this.renderInput??void 0,item:this.item.executeSerialize(),opt:this.opt,preview:this.previewInput?!0:void 0,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(e,t,n){var r={};if(t===null)return r;for(var i=0;i<t.length;i++){var a=i,o=t[a];if(o!=null){var s=Ge(e,a);if(!(n!==void 0&&!n.wantsUnder(s))){var c=this.item.executePreview(s,o,n);for(var l in c){var u=l;r[u]=c[u]}}}}if(this.item.declaresItemPreview()){for(var d=n!==void 0&&!n.wants(e)?n:null,f=[],p=0;p<t.length;p++){var m=t[p];if(m!=null&&!(d!==null&&!d.wantsUnder(Ge(e,p))))try{var h=this.item.executePreviewItem(m);if(h!==null){var g=h.title,_=h.subtitle,v=h.image;f.push([p,{title:g,subtitle:_,image:v}])}}catch(t){r[Ge(e,p)]={status:`error`,message:t instanceof Error?t.message:`Unknown error`}}}r[e]={status:`success`,data:{parent:`array`,items:f}}}return r}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`preview`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.renderInput)}},{key:`render`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.previewInput,e)}}])}(Le),$e=function(e){return new Qe(e)},et=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.value=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.value,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.value,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null?n.length>0&&V({},e,n):typeof t==`string`?t===this.value?n.length>0&&V({},e,n):V({},e,[].concat(z(n),[{message:`Expected literal '${this.value}', got '${t}'`,value:t}])):V({},e,[].concat(z(n),[{message:`Expected 'string', got '${B(t)}'`,value:t}]))}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'string', got 'null'`,typeError:!0}])}:typeof t==`string`&&t===this.value?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected literal '${this.value}', got '${t}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.value,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.value,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.value,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.value,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.value,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`literal`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,value:this.value,opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),tt=function(e){return new et(e)},nt=function(e){function t(e,n){var r,i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5&&arguments[5]!==void 0&&arguments[5],c=arguments.length>6?arguments[6]:void 0,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:null;return De(this,t),r=Pe(this,t),r.key=e,r.items=n,r.opt=i,r.customValidateFunctions=a,r.isReadonly=o,r.isHidden=s,r.description=c,r.renderInput=l,r.previewInput=u,r}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.key,this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.key,this.items,this.opt,this.customValidateFunctions.concat(e),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e}),r=t;if(this.opt&&r===null)return n.length>0&&V({},e,n);if(!this.key)return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Missing required first argument in union`,schemaError:!0}]));var i=this.key;if(!Array.isArray(this.items))return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`A union schema must take more than 1 schema arguments`,schemaError:!0}]));if(typeof i==`string`){if(this.items.some(function(e){return!(e instanceof Xe)}))return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Key is a string, so all schema items must be objects`,schemaError:!0}]));var a=this.items,o=a.map(function(e){return e.executeSerialize()}),s=o.filter(function(e){return e.type!==`object`||e.items[i].type!==`literal`});if(s.length>0)return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`All schema items must be objects with a key: ${i} that is a literal schema. Found: ${JSON.stringify(s,null,2)}`,schemaError:!0}]));var c=o;if(c.filter(function(e){return e.items[i].opt}).length>1)return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Schema cannot have an optional keys: ${i}`,schemaError:!0}]));if(B(r)!==`object`)return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Expected an object`,typeError:!0}]));var l=r;if(l[i]===void 0)return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Missing required key: ${i}`,typeError:!0}]));var u=[],d=w(c),f;try{for(d.s();!(f=d.n()).done;){var p=f.value.items[i];if(p.type===`literal`){if(!u.includes(p.value))u.push(p.value);else return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Found duplicate key in schema: ${p.value}`,schemaError:!0}]))}}}catch(e){d.e(e)}finally{d.f()}var m=a.find(function(t){return!t.items[i].executeValidate(e,l[i])});if(!m){var h=We(e,i);if(!h)throw Error(`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} at key ${i}`);return V({},h,[{message:`Invalid key: "${i}". Value was: "${l[i]}". Valid values: ${c.map(function(e){var t=e.items[i];if(t.type===`literal`&&t.value)return`"${t.value}"`;throw Error(`Expected literal schema, got ${JSON.stringify(t,null,2)}`)}).join(`, `)}`}])}var g=m.executeValidate(e,l);if(g)return g}else if(i instanceof et){if(this.items.some(function(e){return!(e instanceof et)}))return V({},e,[{message:`Key is a literal schema, so all schema items must be literals`,typeError:!0}]);var _=[i].concat(z(this.items));if(typeof r==`string`&&!_.some(function(t){return!t.executeValidate(e,r)}))return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Union must match one of the following: ${_.map(function(e){return`"${e.value}"`}).join(`, `)}`}]))}else return n.length>0?V({},e,n):V({},e,[].concat(z(n),[{message:`Expected a string or literal`}]));return n.length>0&&V({},e,n)}},{key:`executeAssert`,value:function(e,t){if(this.opt&&t===null)return{success:!0,data:t};if(t===null)return{success:!1,errors:V({},e,[{message:`Expected 'object', got 'null'`,typeError:!0}])};if(!this.key)return{success:!1,errors:V({},e,[{message:`Missing required first argument in union schema`,schemaError:!0}])};if(!Array.isArray(this.items))return{success:!1,errors:V({},e,[{message:`The schema of this value is wrong. Schema is neither a union of literals nor a tagged union (of objects)`,schemaError:!0}])};if(this.key instanceof et){var n,r=!1,i={},a=w((n=[this.key]).concat.apply(n,z(this.items))),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;if(!(s instanceof et))return{success:!1,errors:V({},e,[{message:`Schema of value is a union of string, so all schema items must be literals`,schemaError:!0}])};if(typeof t!=`string`){i[e]=[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}];continue}var c=s.executeAssert(e,t);if(c.success){r=!0;break}for(var l=0,u=Object.entries(c.errors);l<u.length;l++){var d,f=xe(u[l],2),p=f[0],m=f[1];i[p]||(i[p]=[]),(d=i[p]).push.apply(d,z(m))}}}catch(e){a.e(e)}finally{a.f()}return r?{success:!0,data:t}:{success:!1,errors:i}}if(typeof this.key==`string`){var h=!1,g={},_=w(this.items),v;try{for(_.s();!(v=_.n()).done;){var y=v.value.executeAssert(e,t);if(y.success){h=!0;break}for(var b=0,x=Object.entries(y.errors);b<x.length;b++){var S,C=xe(x[b],2),T=C[0],E=C[1];g[T]||(g[T]=[]),(S=g[T]).push.apply(S,z(E))}}}catch(e){_.e(e)}finally{_.f()}return h?{success:!0,data:t}:{success:!1,errors:g}}return{success:!1,errors:V({},e,[{message:`The schema of this value is wrong. Schema is neither a union of literals nor a tagged union (of objects)`,schemaError:!0}])}}},{key:`nullable`,value:function(){return new t(this.key,this.items,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.key,this.items,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.key,this.items,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e}),r=this.matchedVariant(t);return r&&n.push.apply(n,z(r.executeCustomValidateAt(e,t))),n}},{key:`matchedVariant`,value:function(e){var t=this.key;if(typeof t!=`string`||!Array.isArray(this.items)||e===null||B(e)!==`object`||Array.isArray(e))return null;var n=e[t];if(typeof n!=`string`)return null;var r=this.items,i=w(r),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;if(o instanceof Xe){var s=o.items[t];if(s instanceof et&&s.value===n)return o}}}catch(e){i.e(e)}finally{i.f()}return null}},{key:`render`,value:function(e){return new t(this.key,this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.key,this.items,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){if(this.previewInput!==null)return this.previewInput({val:e});var t=this.matchedVariant(e);return t?t.executePreviewItem(e):null}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null||Array.isArray(this.items)&&this.items.some(function(e){return e.declaresItemPreview()})}},{key:`executeSerialize`,value:function(){return typeof this.key==`string`?{type:`union`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,key:this.key,items:this.items.map(function(e){return e.executeSerialize()}),opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}:{type:`union`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,key:this.key.executeSerialize(),items:this.items.map(function(e){return e.executeSerialize()}),opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(e,t,n){var r={};if(t===null||this.key instanceof et)return r;var i=this.key;if(typeof i==`string`){var a=this.items.find(function(e){if(e instanceof Xe){var n=e.items[i];if(n instanceof et)return B(t)===`object`&&i in t&&n.value===t[i]}return!1});if(a){var o=a.executePreview(e,t,n);for(var s in o){var c=s;r[c]=o[c]}return r}r[e]={status:`error`,message:`Could not find a matching (object) schema for the union key: ${i}`}}return r[e]={status:`error`,message:`The schema of this value is wrong. Expected a object union schema, but union key is not a string. Got: '${JSON.stringify(i,null,2)}'`},r}}])}(Le),rt=function(e){return new nt(e,[...arguments].slice(1))},it=/^(https?:\/\/[^/]+)\/file\/p\/([^/]+)\/b\/([^/]+)\/v\/([^/]+)\/h\/([^/]+)\/f\/([^/]+)\/p\/(.+)$/;function at(e){if(e[0]===`/`)return{status:`error`,error:`Not a remote ref: `+e};var t=e.match(it);return!t||t[7].indexOf(`public/`)!==0||t[7].split(`/`).some(function(e){return e===`.`||e===`..`})?{status:`error`,error:`Invalid remote ref: `+e}:{status:`success`,remoteHost:t[1],projectId:t[2],bucket:t[3],version:t[4],validationHash:t[5],fileHash:t[6],filePath:t[7]}}function ot(e){return!e.startsWith(`/public`)}function st(e){var t=e.path;if(!ot(t))return e.patch_id?`/api/val/files${t}?patch_id=${e.patch_id}`:t.slice(7);if(e.patch_id){var n=at(t);return n.status===`success`?`/api/val/files/${n.filePath}?patch_id=${e.patch_id}&remote=true&ref=${encodeURIComponent(t)}`:`${t}?patch_id=${e.patch_id}`}return t}function ct(e){return qe(qe({},e),{},{url:st(e)})}function lt(e){return B(e)===`object`&&e!==null&&`type`in e&&(e.type===`image`||e.type===`file`)}function ut(e,t,n){if(!lt(t)||!t.referencedModule)return e;var r=n(t.referencedModule);if(!r||B(r)!==`object`||Array.isArray(r))return e;var i=r,a=e.path in i?e.path:null;if(a===null){var o=at(e.path);o.status===`success`&&o.filePath in i&&(a=o.filePath)}if(a===null)return e;var s=i[a];if(!s||B(s)!==`object`||Array.isArray(s))return e;var c=s,l=c.width,u=c.height,d=c.mimeType,f=c.alt,p=typeof e.alt==`string`;return qe(qe(qe(qe(qe({},e),l===void 0?{}:{width:l}),u===void 0?{}:{height:u}),d===void 0?{}:{mimeType:d}),!p&&typeof f==`string`?{alt:f}:{})}var dt={x3d:`application/vnd.hzn-3d-crossword`,"3gp":`video/3gpp`,"3g2":`video/3gpp2`,mseq:`application/vnd.mseq`,pwn:`application/vnd.3m.post-it-notes`,plb:`application/vnd.3gpp.pic-bw-large`,psb:`application/vnd.3gpp.pic-bw-small`,pvb:`application/vnd.3gpp.pic-bw-var`,tcap:`application/vnd.3gpp2.tcap`,"7z":`application/x-7z-compressed`,abw:`application/x-abiword`,ace:`application/x-ace-compressed`,acc:`application/vnd.americandynamics.acc`,acu:`application/vnd.acucobol`,atc:`application/vnd.acucorp`,adp:`audio/adpcm`,aab:`application/x-authorware-bin`,aam:`application/x-authorware-map`,aas:`application/x-authorware-seg`,air:`application/vnd.adobe.air-application-installer-package+zip`,avif:`image/avif`,swf:`application/x-shockwave-flash`,fxp:`application/vnd.adobe.fxp`,pdf:`application/pdf`,ppd:`application/vnd.cups-ppd`,dir:`application/x-director`,xdp:`application/vnd.adobe.xdp+xml`,xfdf:`application/vnd.adobe.xfdf`,aac:`audio/x-aac`,ahead:`application/vnd.ahead.space`,azf:`application/vnd.airzip.filesecure.azf`,azs:`application/vnd.airzip.filesecure.azs`,azw:`application/vnd.amazon.ebook`,ami:`application/vnd.amiga.ami`,"N/A":`application/andrew-inset`,apk:`application/vnd.android.package-archive`,cii:`application/vnd.anser-web-certificate-issue-initiation`,fti:`application/vnd.anser-web-funds-transfer-initiation`,atx:`application/vnd.antix.game-component`,dmg:`application/x-apple-diskimage`,mpkg:`application/vnd.apple.installer+xml`,aw:`application/applixware`,mp3:`audio/mpeg`,les:`application/vnd.hhe.lesson-player`,swi:`application/vnd.aristanetworks.swi`,s:`text/x-asm`,atomcat:`application/atomcat+xml`,atomsvc:`application/atomsvc+xml`,atom:`application/atom+xml`,ac:`application/pkix-attr-cert`,aif:`audio/x-aiff`,avi:`video/x-msvideo`,aep:`application/vnd.audiograph`,dxf:`image/vnd.dxf`,dwf:`model/vnd.dwf`,par:`text/plain-bas`,bcpio:`application/x-bcpio`,bin:`application/octet-stream`,bmp:`image/bmp`,torrent:`application/x-bittorrent`,cod:`application/vnd.rim.cod`,mpm:`application/vnd.blueice.multipass`,bmi:`application/vnd.bmi`,sh:`application/x-sh`,btif:`image/prs.btif`,rep:`application/vnd.businessobjects`,bz:`application/x-bzip`,bz2:`application/x-bzip2`,csh:`application/x-csh`,c:`text/x-c`,cdxml:`application/vnd.chemdraw+xml`,css:`text/css`,cdx:`chemical/x-cdx`,cml:`chemical/x-cml`,csml:`chemical/x-csml`,cdbcmsg:`application/vnd.contact.cmsg`,cla:`application/vnd.claymore`,c4g:`application/vnd.clonk.c4group`,sub:`image/vnd.dvb.subtitle`,cdmia:`application/cdmi-capability`,cdmic:`application/cdmi-container`,cdmid:`application/cdmi-domain`,cdmio:`application/cdmi-object`,cdmiq:`application/cdmi-queue`,c11amc:`application/vnd.cluetrust.cartomobile-config`,c11amz:`application/vnd.cluetrust.cartomobile-config-pkg`,ras:`image/x-cmu-raster`,dae:`model/vnd.collada+xml`,csv:`text/csv`,cpt:`application/mac-compactpro`,wmlc:`application/vnd.wap.wmlc`,cgm:`image/cgm`,ice:`x-conference/x-cooltalk`,cmx:`image/x-cmx`,xar:`application/vnd.xara`,cmc:`application/vnd.cosmocaller`,cpio:`application/x-cpio`,clkx:`application/vnd.crick.clicker`,clkk:`application/vnd.crick.clicker.keyboard`,clkp:`application/vnd.crick.clicker.palette`,clkt:`application/vnd.crick.clicker.template`,clkw:`application/vnd.crick.clicker.wordbank`,wbs:`application/vnd.criticaltools.wbs+xml`,cryptonote:`application/vnd.rig.cryptonote`,cif:`chemical/x-cif`,cmdf:`chemical/x-cmdf`,cu:`application/cu-seeme`,cww:`application/prs.cww`,curl:`text/vnd.curl`,dcurl:`text/vnd.curl.dcurl`,mcurl:`text/vnd.curl.mcurl`,scurl:`text/vnd.curl.scurl`,car:`application/vnd.curl.car`,pcurl:`application/vnd.curl.pcurl`,cmp:`application/vnd.yellowriver-custom-menu`,dssc:`application/dssc+der`,xdssc:`application/dssc+xml`,deb:`application/x-debian-package`,uva:`audio/vnd.dece.audio`,uvi:`image/vnd.dece.graphic`,uvh:`video/vnd.dece.hd`,uvm:`video/vnd.dece.mobile`,uvu:`video/vnd.uvvu.mp4`,uvp:`video/vnd.dece.pd`,uvs:`video/vnd.dece.sd`,uvv:`video/vnd.dece.video`,dvi:`application/x-dvi`,seed:`application/vnd.fdsn.seed`,dtb:`application/x-dtbook+xml`,res:`application/x-dtbresource+xml`,ait:`application/vnd.dvb.ait`,svc:`application/vnd.dvb.service`,eol:`audio/vnd.digital-winds`,djvu:`image/vnd.djvu`,dtd:`application/xml-dtd`,mlp:`application/vnd.dolby.mlp`,wad:`application/x-doom`,dpg:`application/vnd.dpgraph`,dra:`audio/vnd.dra`,dfac:`application/vnd.dreamfactory`,dts:`audio/vnd.dts`,dtshd:`audio/vnd.dts.hd`,dwg:`image/vnd.dwg`,geo:`application/vnd.dynageo`,es:`application/ecmascript`,mag:`application/vnd.ecowin.chart`,mmr:`image/vnd.fujixerox.edmics-mmr`,rlc:`image/vnd.fujixerox.edmics-rlc`,exi:`application/exi`,mgz:`application/vnd.proteus.magazine`,epub:`application/epub+zip`,eml:`message/rfc822`,nml:`application/vnd.enliven`,xpr:`application/vnd.is-xpr`,xif:`image/vnd.xiff`,xfdl:`application/vnd.xfdl`,emma:`application/emma+xml`,ez2:`application/vnd.ezpix-album`,ez3:`application/vnd.ezpix-package`,fst:`image/vnd.fst`,fvt:`video/vnd.fvt`,fbs:`image/vnd.fastbidsheet`,fe_launch:`application/vnd.denovo.fcselayout-link`,f4v:`video/x-f4v`,flv:`video/x-flv`,fpx:`image/vnd.fpx`,npx:`image/vnd.net-fpx`,flx:`text/vnd.fmi.flexstor`,fli:`video/x-fli`,ftc:`application/vnd.fluxtime.clip`,fdf:`application/vnd.fdf`,f:`text/x-fortran`,mif:`application/vnd.mif`,fm:`application/vnd.framemaker`,fh:`image/x-freehand`,fsc:`application/vnd.fsc.weblaunch`,fnc:`application/vnd.frogans.fnc`,ltf:`application/vnd.frogans.ltf`,ddd:`application/vnd.fujixerox.ddd`,xdw:`application/vnd.fujixerox.docuworks`,xbd:`application/vnd.fujixerox.docuworks.binder`,oas:`application/vnd.fujitsu.oasys`,oa2:`application/vnd.fujitsu.oasys2`,oa3:`application/vnd.fujitsu.oasys3`,fg5:`application/vnd.fujitsu.oasysgp`,bh2:`application/vnd.fujitsu.oasysprs`,spl:`application/x-futuresplash`,fzs:`application/vnd.fuzzysheet`,g3:`image/g3fax`,gmx:`application/vnd.gmx`,gtw:`model/vnd.gtw`,txd:`application/vnd.genomatix.tuxedo`,ggb:`application/vnd.geogebra.file`,ggt:`application/vnd.geogebra.tool`,gdl:`model/vnd.gdl`,gex:`application/vnd.geometry-explorer`,gxt:`application/vnd.geonext`,g2w:`application/vnd.geoplan`,g3w:`application/vnd.geospace`,gsf:`application/x-font-ghostscript`,bdf:`application/x-font-bdf`,gtar:`application/x-gtar`,texinfo:`application/x-texinfo`,gnumeric:`application/x-gnumeric`,kml:`application/vnd.google-earth.kml+xml`,kmz:`application/vnd.google-earth.kmz`,gqf:`application/vnd.grafeq`,gif:`image/gif`,gv:`text/vnd.graphviz`,gac:`application/vnd.groove-account`,ghf:`application/vnd.groove-help`,gim:`application/vnd.groove-identity-message`,grv:`application/vnd.groove-injector`,gtm:`application/vnd.groove-tool-message`,tpl:`application/vnd.groove-tool-template`,vcg:`application/vnd.groove-vcard`,h261:`video/h261`,h263:`video/h263`,h264:`video/h264`,hpid:`application/vnd.hp-hpid`,hps:`application/vnd.hp-hps`,hdf:`application/x-hdf`,rip:`audio/vnd.rip`,hbci:`application/vnd.hbci`,jlt:`application/vnd.hp-jlyt`,pcl:`application/vnd.hp-pcl`,hpgl:`application/vnd.hp-hpgl`,hvs:`application/vnd.yamaha.hv-script`,hvd:`application/vnd.yamaha.hv-dic`,hvp:`application/vnd.yamaha.hv-voice`,"sfd-hdstx":`application/vnd.hydrostatix.sof-data`,stk:`application/hyperstudio`,hal:`application/vnd.hal+xml`,html:`text/html`,irm:`application/vnd.ibm.rights-management`,sc:`application/vnd.ibm.secure-container`,ics:`text/calendar`,icc:`application/vnd.iccprofile`,ico:`image/x-icon`,igl:`application/vnd.igloader`,ief:`image/ief`,ivp:`application/vnd.immervision-ivp`,ivu:`application/vnd.immervision-ivu`,rif:`application/reginfo+xml`,"3dml":`text/vnd.in3d.3dml`,spot:`text/vnd.in3d.spot`,igs:`model/iges`,i2g:`application/vnd.intergeo`,cdy:`application/vnd.cinderella`,xpw:`application/vnd.intercon.formnet`,fcs:`application/vnd.isac.fcs`,ipfix:`application/ipfix`,cer:`application/pkix-cert`,pki:`application/pkixcmp`,crl:`application/pkix-crl`,pkipath:`application/pkix-pkipath`,igm:`application/vnd.insors.igm`,rcprofile:`application/vnd.ipunplugged.rcprofile`,irp:`application/vnd.irepository.package+xml`,jad:`text/vnd.sun.j2me.app-descriptor`,jar:`application/java-archive`,class:`application/java-vm`,jnlp:`application/x-java-jnlp-file`,ser:`application/java-serialized-object`,java:`text/x-java-source,java`,js:`application/javascript`,json:`application/json`,joda:`application/vnd.joost.joda-archive`,jpm:`video/jpm`,jpeg:`image/jpeg`,jpg:`image/jpeg`,pjpeg:`image/pjpeg`,jpgv:`video/jpeg`,ktz:`application/vnd.kahootz`,mmd:`application/vnd.chipnuts.karaoke-mmd`,karbon:`application/vnd.kde.karbon`,chrt:`application/vnd.kde.kchart`,kfo:`application/vnd.kde.kformula`,flw:`application/vnd.kde.kivio`,kon:`application/vnd.kde.kontour`,kpr:`application/vnd.kde.kpresenter`,ksp:`application/vnd.kde.kspread`,kwd:`application/vnd.kde.kword`,htke:`application/vnd.kenameaapp`,kia:`application/vnd.kidspiration`,kne:`application/vnd.kinar`,sse:`application/vnd.kodak-descriptor`,lasxml:`application/vnd.las.las+xml`,latex:`application/x-latex`,lbd:`application/vnd.llamagraphics.life-balance.desktop`,lbe:`application/vnd.llamagraphics.life-balance.exchange+xml`,jam:`application/vnd.jam`,123:`application/vnd.lotus-1-2-3`,apr:`application/vnd.lotus-approach`,pre:`application/vnd.lotus-freelance`,nsf:`application/vnd.lotus-notes`,org:`application/vnd.lotus-organizer`,scm:`application/vnd.lotus-screencam`,lwp:`application/vnd.lotus-wordpro`,lvp:`audio/vnd.lucent.voice`,m3u:`audio/x-mpegurl`,m4v:`video/x-m4v`,hqx:`application/mac-binhex40`,portpkg:`application/vnd.macports.portpkg`,mgp:`application/vnd.osgeo.mapguide.package`,mrc:`application/marc`,mrcx:`application/marcxml+xml`,mxf:`application/mxf`,nbp:`application/vnd.wolfram.player`,ma:`application/mathematica`,mathml:`application/mathml+xml`,mbox:`application/mbox`,mc1:`application/vnd.medcalcdata`,mscml:`application/mediaservercontrol+xml`,cdkey:`application/vnd.mediastation.cdkey`,mwf:`application/vnd.mfer`,mfm:`application/vnd.mfmp`,msh:`model/mesh`,mads:`application/mads+xml`,mets:`application/mets+xml`,mods:`application/mods+xml`,meta4:`application/metalink4+xml`,mcd:`application/vnd.mcd`,flo:`application/vnd.micrografx.flo`,igx:`application/vnd.micrografx.igx`,es3:`application/vnd.eszigno3+xml`,mdb:`application/x-msaccess`,asf:`video/x-ms-asf`,exe:`application/x-msdownload`,cil:`application/vnd.ms-artgalry`,cab:`application/vnd.ms-cab-compressed`,ims:`application/vnd.ms-ims`,application:`application/x-ms-application`,clp:`application/x-msclip`,mdi:`image/vnd.ms-modi`,eot:`application/vnd.ms-fontobject`,xls:`application/vnd.ms-excel`,xlam:`application/vnd.ms-excel.addin.macroenabled.12`,xlsb:`application/vnd.ms-excel.sheet.binary.macroenabled.12`,xltm:`application/vnd.ms-excel.template.macroenabled.12`,xlsm:`application/vnd.ms-excel.sheet.macroenabled.12`,chm:`application/vnd.ms-htmlhelp`,crd:`application/x-mscardfile`,lrm:`application/vnd.ms-lrm`,mvb:`application/x-msmediaview`,mny:`application/x-msmoney`,pptx:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,sldx:`application/vnd.openxmlformats-officedocument.presentationml.slide`,ppsx:`application/vnd.openxmlformats-officedocument.presentationml.slideshow`,potx:`application/vnd.openxmlformats-officedocument.presentationml.template`,xlsx:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,xltx:`application/vnd.openxmlformats-officedocument.spreadsheetml.template`,docx:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,dotx:`application/vnd.openxmlformats-officedocument.wordprocessingml.template`,obd:`application/x-msbinder`,thmx:`application/vnd.ms-officetheme`,onetoc:`application/onenote`,pya:`audio/vnd.ms-playready.media.pya`,pyv:`video/vnd.ms-playready.media.pyv`,ppt:`application/vnd.ms-powerpoint`,ppam:`application/vnd.ms-powerpoint.addin.macroenabled.12`,sldm:`application/vnd.ms-powerpoint.slide.macroenabled.12`,pptm:`application/vnd.ms-powerpoint.presentation.macroenabled.12`,ppsm:`application/vnd.ms-powerpoint.slideshow.macroenabled.12`,potm:`application/vnd.ms-powerpoint.template.macroenabled.12`,mpp:`application/vnd.ms-project`,pub:`application/x-mspublisher`,scd:`application/x-msschedule`,xap:`application/x-silverlight-app`,stl:`application/vnd.ms-pki.stl`,cat:`application/vnd.ms-pki.seccat`,vsd:`application/vnd.visio`,vsdx:`application/vnd.visio2013`,wm:`video/x-ms-wm`,wma:`audio/x-ms-wma`,wax:`audio/x-ms-wax`,wmx:`video/x-ms-wmx`,wmd:`application/x-ms-wmd`,wpl:`application/vnd.ms-wpl`,wmz:`application/x-ms-wmz`,wmv:`video/x-ms-wmv`,wvx:`video/x-ms-wvx`,wmf:`application/x-msmetafile`,trm:`application/x-msterminal`,doc:`application/msword`,docm:`application/vnd.ms-word.document.macroenabled.12`,dotm:`application/vnd.ms-word.template.macroenabled.12`,wri:`application/x-mswrite`,wps:`application/vnd.ms-works`,xbap:`application/x-ms-xbap`,xps:`application/vnd.ms-xpsdocument`,mid:`audio/midi`,mpy:`application/vnd.ibm.minipay`,afp:`application/vnd.ibm.modcap`,rms:`application/vnd.jcp.javame.midlet-rms`,tmo:`application/vnd.tmobile-livetv`,prc:`application/x-mobipocket-ebook`,mbk:`application/vnd.mobius.mbk`,dis:`application/vnd.mobius.dis`,plc:`application/vnd.mobius.plc`,mqy:`application/vnd.mobius.mqy`,msl:`application/vnd.mobius.msl`,txf:`application/vnd.mobius.txf`,daf:`application/vnd.mobius.daf`,fly:`text/vnd.fly`,mpc:`application/vnd.mophun.certificate`,mpn:`application/vnd.mophun.application`,mj2:`video/mj2`,mpga:`audio/mpeg`,mxu:`video/vnd.mpegurl`,mpeg:`video/mpeg`,m21:`application/mp21`,mp4a:`audio/mp4`,mp4:`video/mp4`,m3u8:`application/vnd.apple.mpegurl`,mus:`application/vnd.musician`,msty:`application/vnd.muvee.style`,mxml:`application/xv+xml`,ngdat:`application/vnd.nokia.n-gage.data`,"n-gage":`application/vnd.nokia.n-gage.symbian.install`,ncx:`application/x-dtbncx+xml`,nc:`application/x-netcdf`,nlu:`application/vnd.neurolanguage.nlu`,dna:`application/vnd.dna`,nnd:`application/vnd.noblenet-directory`,nns:`application/vnd.noblenet-sealer`,nnw:`application/vnd.noblenet-web`,rpst:`application/vnd.nokia.radio-preset`,rpss:`application/vnd.nokia.radio-presets`,n3:`text/n3`,edm:`application/vnd.novadigm.edm`,edx:`application/vnd.novadigm.edx`,ext:`application/vnd.novadigm.ext`,gph:`application/vnd.flographit`,ecelp4800:`audio/vnd.nuera.ecelp4800`,ecelp7470:`audio/vnd.nuera.ecelp7470`,ecelp9600:`audio/vnd.nuera.ecelp9600`,oda:`application/oda`,ogx:`application/ogg`,oga:`audio/ogg`,ogv:`video/ogg`,dd2:`application/vnd.oma.dd2+xml`,oth:`application/vnd.oasis.opendocument.text-web`,opf:`application/oebps-package+xml`,qbo:`application/vnd.intu.qbo`,oxt:`application/vnd.openofficeorg.extension`,osf:`application/vnd.yamaha.openscoreformat`,weba:`audio/webm`,webm:`video/webm`,odc:`application/vnd.oasis.opendocument.chart`,otc:`application/vnd.oasis.opendocument.chart-template`,odb:`application/vnd.oasis.opendocument.database`,odf:`application/vnd.oasis.opendocument.formula`,odft:`application/vnd.oasis.opendocument.formula-template`,odg:`application/vnd.oasis.opendocument.graphics`,otg:`application/vnd.oasis.opendocument.graphics-template`,odi:`application/vnd.oasis.opendocument.image`,oti:`application/vnd.oasis.opendocument.image-template`,odp:`application/vnd.oasis.opendocument.presentation`,otp:`application/vnd.oasis.opendocument.presentation-template`,ods:`application/vnd.oasis.opendocument.spreadsheet`,ots:`application/vnd.oasis.opendocument.spreadsheet-template`,odt:`application/vnd.oasis.opendocument.text`,odm:`application/vnd.oasis.opendocument.text-master`,ott:`application/vnd.oasis.opendocument.text-template`,ktx:`image/ktx`,sxc:`application/vnd.sun.xml.calc`,stc:`application/vnd.sun.xml.calc.template`,sxd:`application/vnd.sun.xml.draw`,std:`application/vnd.sun.xml.draw.template`,sxi:`application/vnd.sun.xml.impress`,sti:`application/vnd.sun.xml.impress.template`,sxm:`application/vnd.sun.xml.math`,sxw:`application/vnd.sun.xml.writer`,sxg:`application/vnd.sun.xml.writer.global`,stw:`application/vnd.sun.xml.writer.template`,otf:`application/x-font-otf`,osfpvg:`application/vnd.yamaha.openscoreformat.osfpvg+xml`,dp:`application/vnd.osgi.dp`,pdb:`application/vnd.palm`,p:`text/x-pascal`,paw:`application/vnd.pawaafile`,pclxl:`application/vnd.hp-pclxl`,efif:`application/vnd.picsel`,pcx:`image/x-pcx`,psd:`image/vnd.adobe.photoshop`,prf:`application/pics-rules`,pic:`image/x-pict`,chat:`application/x-chat`,p10:`application/pkcs10`,p12:`application/x-pkcs12`,p7m:`application/pkcs7-mime`,p7s:`application/pkcs7-signature`,p7r:`application/x-pkcs7-certreqresp`,p7b:`application/x-pkcs7-certificates`,p8:`application/pkcs8`,plf:`application/vnd.pocketlearn`,pnm:`image/x-portable-anymap`,pbm:`image/x-portable-bitmap`,pcf:`application/x-font-pcf`,pfr:`application/font-tdpfr`,pgn:`application/x-chess-pgn`,pgm:`image/x-portable-graymap`,png:`image/png`,ppm:`image/x-portable-pixmap`,pskcxml:`application/pskc+xml`,pml:`application/vnd.ctc-posml`,ai:`application/postscript`,pfa:`application/x-font-type1`,pbd:`application/vnd.powerbuilder6`,pgp:`application/pgp-signature`,box:`application/vnd.previewsystems.box`,ptid:`application/vnd.pvi.ptid1`,pls:`application/pls+xml`,str:`application/vnd.pg.format`,ei6:`application/vnd.pg.osasli`,dsc:`text/prs.lines.tag`,psf:`application/x-font-linux-psf`,qps:`application/vnd.publishare-delta-tree`,wg:`application/vnd.pmi.widget`,qxd:`application/vnd.quark.quarkxpress`,esf:`application/vnd.epson.esf`,msf:`application/vnd.epson.msf`,ssf:`application/vnd.epson.ssf`,qam:`application/vnd.epson.quickanime`,qfx:`application/vnd.intu.qfx`,mov:`video/quicktime`,rar:`application/x-rar-compressed`,ram:`audio/x-pn-realaudio`,rmp:`audio/x-pn-realaudio-plugin`,rsd:`application/rsd+xml`,rm:`application/vnd.rn-realmedia`,bed:`application/vnd.realvnc.bed`,mxl:`application/vnd.recordare.musicxml`,musicxml:`application/vnd.recordare.musicxml+xml`,rnc:`application/relax-ng-compact-syntax`,rdz:`application/vnd.data-vision.rdz`,rdf:`application/rdf+xml`,rp9:`application/vnd.cloanto.rp9`,jisp:`application/vnd.jisp`,rtf:`application/rtf`,rtx:`text/richtext`,link66:`application/vnd.route66.link66+xml`,rss:`application/rss+xml`,shf:`application/shf+xml`,st:`application/vnd.sailingtracker.track`,svg:`image/svg+xml`,sus:`application/vnd.sus-calendar`,sru:`application/sru+xml`,setpay:`application/set-payment-initiation`,setreg:`application/set-registration-initiation`,sema:`application/vnd.sema`,semd:`application/vnd.semd`,semf:`application/vnd.semf`,see:`application/vnd.seemail`,snf:`application/x-font-snf`,spq:`application/scvp-vp-request`,spp:`application/scvp-vp-response`,scq:`application/scvp-cv-request`,scs:`application/scvp-cv-response`,sdp:`application/sdp`,etx:`text/x-setext`,movie:`video/x-sgi-movie`,ifm:`application/vnd.shana.informed.formdata`,itp:`application/vnd.shana.informed.formtemplate`,iif:`application/vnd.shana.informed.interchange`,ipk:`application/vnd.shana.informed.package`,tfi:`application/thraud+xml`,shar:`application/x-shar`,rgb:`image/x-rgb`,slt:`application/vnd.epson.salt`,aso:`application/vnd.accpac.simply.aso`,imp:`application/vnd.accpac.simply.imp`,twd:`application/vnd.simtech-mindmapper`,csp:`application/vnd.commonspace`,saf:`application/vnd.yamaha.smaf-audio`,mmf:`application/vnd.smaf`,spf:`application/vnd.yamaha.smaf-phrase`,teacher:`application/vnd.smart.teacher`,svd:`application/vnd.svd`,rq:`application/sparql-query`,srx:`application/sparql-results+xml`,gram:`application/srgs`,grxml:`application/srgs+xml`,ssml:`application/ssml+xml`,skp:`application/vnd.koan`,sgml:`text/sgml`,sdc:`application/vnd.stardivision.calc`,sda:`application/vnd.stardivision.draw`,sdd:`application/vnd.stardivision.impress`,smf:`application/vnd.stardivision.math`,sdw:`application/vnd.stardivision.writer`,sgl:`application/vnd.stardivision.writer-global`,sm:`application/vnd.stepmania.stepchart`,sit:`application/x-stuffit`,sitx:`application/x-stuffitx`,sdkm:`application/vnd.solent.sdkm+xml`,xo:`application/vnd.olpc-sugar`,au:`audio/basic`,wqd:`application/vnd.wqd`,sis:`application/vnd.symbian.install`,smi:`application/smil+xml`,xsm:`application/vnd.syncml+xml`,bdm:`application/vnd.syncml.dm+wbxml`,xdm:`application/vnd.syncml.dm+xml`,sv4cpio:`application/x-sv4cpio`,sv4crc:`application/x-sv4crc`,sbml:`application/sbml+xml`,tsv:`text/tab-separated-values`,tiff:`image/tiff`,tao:`application/vnd.tao.intent-module-archive`,tar:`application/x-tar`,tcl:`application/x-tcl`,tex:`application/x-tex`,tfm:`application/x-tex-tfm`,tei:`application/tei+xml`,txt:`text/plain`,dxp:`application/vnd.spotfire.dxp`,sfs:`application/vnd.spotfire.sfs`,tsd:`application/timestamped-data`,tpt:`application/vnd.trid.tpt`,mxs:`application/vnd.triscape.mxs`,t:`text/troff`,tra:`application/vnd.trueapp`,ttf:`application/x-font-ttf`,ttl:`text/turtle`,umj:`application/vnd.umajin`,uoml:`application/vnd.uoml+xml`,unityweb:`application/vnd.unity`,ufd:`application/vnd.ufdl`,uri:`text/uri-list`,utz:`application/vnd.uiq.theme`,ustar:`application/x-ustar`,uu:`text/x-uuencode`,vcs:`text/x-vcalendar`,vcf:`text/x-vcard`,vcd:`application/x-cdlink`,vsf:`application/vnd.vsf`,wrl:`model/vrml`,vcx:`application/vnd.vcx`,mts:`model/vnd.mts`,vtu:`model/vnd.vtu`,vis:`application/vnd.visionary`,viv:`video/vnd.vivo`,ccxml:`application/ccxml+xml,`,vxml:`application/voicexml+xml`,src:`application/x-wais-source`,wbxml:`application/vnd.wap.wbxml`,wbmp:`image/vnd.wap.wbmp`,wav:`audio/x-wav`,davmount:`application/davmount+xml`,woff:`application/x-font-woff`,wspolicy:`application/wspolicy+xml`,webp:`image/webp`,wtb:`application/vnd.webturbo`,wgt:`application/widget`,hlp:`application/winhlp`,wml:`text/vnd.wap.wml`,wmls:`text/vnd.wap.wmlscript`,wmlsc:`application/vnd.wap.wmlscriptc`,wpd:`application/vnd.wordperfect`,stf:`application/vnd.wt.stf`,wsdl:`application/wsdl+xml`,xbm:`image/x-xbitmap`,xpm:`image/x-xpixmap`,xwd:`image/x-xwindowdump`,der:`application/x-x509-ca-cert`,fig:`application/x-xfig`,xhtml:`application/xhtml+xml`,xml:`application/xml`,xdf:`application/xcap-diff+xml`,xenc:`application/xenc+xml`,xer:`application/patch-ops-error+xml`,rl:`application/resource-lists+xml`,rs:`application/rls-services+xml`,rld:`application/resource-lists-diff+xml`,xslt:`application/xslt+xml`,xop:`application/xop+xml`,xpi:`application/x-xpinstall`,xspf:`application/xspf+xml`,xul:`application/vnd.mozilla.xul+xml`,xyz:`chemical/x-xyz`,yaml:`text/yaml`,yang:`application/yang`,yin:`application/yin+xml`,zir:`application/vnd.zul`,zip:`application/zip`,zmm:`application/vnd.handheld-entertainment+xml`,zaz:`application/vnd.zzazz.deck+xml`},ft=Object.fromEntries(Object.entries(dt).map(function(e){var t=xe(e,2),n=t[0];return[t[1],n]})),pt=/^data:(.*?);base64,/;function mt(e){var t=pt.exec(e);if(t&&t[1])return t[1]}function ht(e){return ft[e]||e.split(`/`)[1]}function gt(e){var t=e.split(`.`).pop(),n=t&&dt[t];if(n)return n}function _t(e,t){return t.split(`,`).map(function(e){return e.trim()}).some(function(t){return t===`*/*`?!0:t.endsWith(`/*`)?e.startsWith(t.slice(0,-1)):t===e})}var vt=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[],o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},s=arguments.length>5&&arguments[5]!==void 0&&arguments[5],c=arguments.length>6&&arguments[6]!==void 0&&arguments[6],l=arguments.length>7?arguments[7]:void 0,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:null,d=arguments.length>9&&arguments[9]!==void 0?arguments[9]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.isRemote=i,n.customValidateFunctions=a,n.moduleMetadata=o,n.isReadonly=s,n.isHidden=c,n.description=l,n.renderInput=u,n.previewInput=d,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`remote`,value:function(){return new t(this.options,this.opt,!0,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,this.isRemote,[].concat(z(this.customValidateFunctions),[e]),this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return n.length>0&&V({},e,n);if(t==null)return V({},e,[].concat(z(n),[{message:`Non-optional image was null or undefined.`,value:t}]));if(typeof t.path!=`string`)return V({},e,[].concat(z(n),[{message:`Image did not have a path string. Got: ${B(t.path)}`,value:t}]));var r=ot(t.path);if(this.isRemote&&!r)return V({},e,[].concat(z(n),[{message:`Expected a remote image, but got a local image.`,value:t,fixes:[`image:upload-remote`]}]));if(this.isRemote&&r)return V({},e,[].concat(z(n),[{message:`Remote image was not checked.`,value:t,fixes:[`image:check-remote`]}]));if(!this.isRemote&&r)return V({},e,[].concat(z(n),[{message:`Expected local image, but found remote.`,value:t,fixes:[`image:download-remote`]}]));if(t.hotspot!==void 0&&(B(t.hotspot)!==`object`||t.hotspot===null||typeof t.hotspot.x!=`number`||typeof t.hotspot.y!=`number`))return V({},e,[].concat(z(n),[{message:`Hotspot must be an object with x and y as numbers.`,value:t}]));var i=this.galleryEntries();if(i){var a=[`width`,`height`,`mimeType`].filter(function(e){return t[e]!==void 0});return a.length>0?V({},e,[].concat(z(n),[{message:`An image from a gallery must not carry its own ${a.join(`, `)}: ${a.length===1?`it is`:`they are`} stored in the gallery module.`,value:t}])):t.path in i?n.length>0&&V({},e,n):V({},e,[].concat(z(n),[{message:`The gallery does not have an image at '${t.path}'.`,value:t}]))}var o=(this.options||{}).accept,s=t.mimeType??``;if(o&&s&&!s.includes(`/`))return V({},e,[].concat(z(n),[{message:`Invalid mime type format. Got: '${s}'`,value:t,fixes:[`image:check-metadata`]}]));if(o&&s&&s.includes(`/`)&&!_t(s,o))return V({},e,[].concat(z(n),[{message:`Mime type mismatch. Found '${s}' but schema accepts '${o}'`,value:t,fixes:[`image:check-metadata`]}]));var c=H.filenameToMimeType(t.path);return c?c&&s&&c!==s?V({},e,[].concat(z(n),[{message:`Mime type and file extension not matching. Mime type is '${s}' but file extension is '${c}'`,value:t,fixes:[`image:check-metadata`]}])):t.width!==void 0||t.height!==void 0||t.mimeType!==void 0?V({},e,[].concat(z(n),[{message:`Image metadata has not been checked against the file.`,value:t,fixes:[`image:check-metadata`]}])):V({},e,[].concat(z(n),[{message:`Image metadata is missing: width, height and mimeType.`,value:t,fixes:[`image:add-metadata`]}])):V({},e,[].concat(z(n),[{message:`Could not determine mime type from file extension. Got: ${t.path}`,value:t,fixes:[`image:check-metadata`]}]))}},{key:`galleryEntries`,value:function(){var e=Object.keys(this.moduleMetadata);return e.length===0?null:this.moduleMetadata[e[0]]}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'object', got 'null'`,typeError:!0}])}:B(t)===`object`?!(`path`in t)||typeof t.path!=`string`?{success:!1,errors:V({},e,[{message:`An image must be an object with a 'path' (error type: missing_path)`,typeError:!0}])}:{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'object', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){var e=this.moduleMetadata?Object.keys(this.moduleMetadata):[];return{type:`image`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,options:this.options,opt:this.opt,remote:this.isRemote,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,referencedModule:e.length>0?e[0]:void 0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le);function yt(e,t){if(e&&H.getValPath(e)){for(var n={},r=0,i=[e];r<i.length;r++){var a=i[r],o=Ue(a);if(o===void 0)throw Error(`Invalid argument passed to s.image(). Expected a ValModule constructed through c.define, but got an object without a valid module path.`);n[o]=Ft(a)}return new vt(t?.encode===void 0?{}:{encode:t.encode},!1,!1,[],n)}return new vt(e)}var bt=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`include`,value:function(e){return new t(qe(qe({},this.options),{},{include:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`exclude`,value:function(e){return new t(qe(qe({},this.options),{},{exclude:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions.concat(e),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null?n.length>0&&V({},e,n):typeof t==`string`?V({},e,[].concat(z(n),[{fixes:[`router:check-route`],message:`Did not validate route (router). This error (router:check-route) should typically be processed by Val internally. Seeing this error most likely means you have a Val version mismatch.`,value:{route:t,sourcePath:e,include:this.options?.include,exclude:this.options?.exclude}}])):V({},e,[{message:`Expected 'string', got '${B(t)}'`,value:t}])}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null||typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`route`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,options:{include:this.options?.include&&{source:this.options.include.source,flags:this.options.include.flags},exclude:this.options?.exclude&&{source:this.options.exclude.source,flags:this.options.exclude.flags},customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0},opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),xt=function(e){return new bt(e)},St=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`maxLength`,value:function(e){return new t(qe(qe({},this.options),{},{maxLength:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`minLength`,value:function(e){return new t(qe(qe({},this.options),{},{minLength:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e}),r=this.executeAssert(e,t);if(!r.success)return n.length>0?V({},e,n):r.errors;var i=r.data;if(i===null&&this.opt)return n.length>0&&V({},e,n);if(i===null)return V({},e,[].concat(z(n),[{message:`Expected 'array', got 'null'`,typeError:!0}]));var a={},o=this.internalValidate(e,i,a);return o?n.length>0?qe(V({},e,n),o):o:Object.keys(a).length>0?n.length>0?qe(V({},e,n),a):a:n.length>0&&V({},e,n)}},{key:`internalValidate`,value:function(e,t,n){var r=this,i=0,a=function(e,t,n){var o=function(e,t,r){n[e]||(n[e]=[]),n[e].push({message:t,typeError:r})},s=w(t),c;try{var l=function(){var s=c.value,l=Ge(e,t.indexOf(s));if(typeof s==`string`)return i+=s.length,0;if(B(s)!==`object`)return{v:V({},l,[{message:`Expected nodes of type 'object' or 'string', got '${B(s)}'`,typeError:!0}])};if(s===null)return{v:V({},l,[{message:`Expected nodes of type 'object' or 'string', got 'null'`,typeError:!0}])};if(!(`tag`in s))return{v:V({},l,[{message:`Expected node to either have 'tag' or be of type 'string'`,typeError:!0}])};if(typeof s.tag!=`string`)return{v:V({},l,[{message:`Expected 'string', got '${B(s.tag)}'`,typeError:!0}])};var u=[`p`,`span`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`ol`,`ul`,`li`,`a`,`img`,`br`];if(u.includes(s.tag)||o(l,`Tag '${s.tag}' is not supported. Supported tags: ${u.join(`, `)}`,!0),s.tag===`h1`&&!r.options.h1&&o(l,`'h1' block is not valid`,!1),s.tag===`h2`&&!r.options.h2&&o(l,`'h2' block is not valid`,!1),s.tag===`h3`&&!r.options.h3&&o(l,`'h3' block is not valid`,!1),s.tag===`h4`&&!r.options.h4&&o(l,`'h4' block is not valid`,!1),s.tag===`h5`&&!r.options.h5&&o(l,`'h5' block is not valid`,!1),s.tag===`h6`&&!r.options.h6&&o(l,`'h6' block is not valid`,!1),s.tag===`ol`&&!r.options.ol&&o(l,`'ol' block is not valid`,!1),s.tag===`ul`&&!r.options.ul&&o(l,`'ul' block is not valid`,!1),s.tag===`li`&&!r.options.ul&&!r.options.ol&&o(l,`'li' tag is invalid since neither 'ul' nor 'ol' block is valid`,!1),s.tag===`a`){if(!r.options.a)o(l,`'a' inline is not valid`,!1);else if(r.options.a){if(!(`href`in s))return{v:V({},l,[{message:`Expected 'href' in 'a'`,typeError:!0}])};var d=Ge(l,`href`),f=typeof r.options.a==`boolean`?new bt:r.options.a,p=function(){return f instanceof bt||f instanceof Je?f.executeValidate(d,s.href):(console.error(`Exhaustive check failed in RichText (anchor href validation)`,f),!1)}();if(p)for(var m in p){var h,g=m;n[g]||(n[g]=[]),(h=n[g]).push.apply(h,z(p[g]))}}}if(s.tag===`img`){if(!r.options.img)o(l,`'img' inline is not valid`,!1);else if(r.options.img){if(!(`src`in s))return{v:V({},l,[{message:`Expected 'src' in 'img'`,typeError:!0}])};var _=Ge(l,`src`),v=r.options.img,y=B(v)===`object`?v.executeValidate(_,s.src):new vt({},!1,!1).executeValidate(_,s.src);if(y)for(var b in y){var x,S=b;n[S]||(n[S]=[]),(x=n[S]).push.apply(x,z(y[S]))}}}if(`styles`in s&&s.tag!==`span`)return{v:V({},l,[{message:`Cannot have styles on '${s.tag}'. This is only allowed on 'span'`,typeError:!0}])};if(`styles`in s){if(!Array.isArray(s.styles))return{v:V({},l,[{message:`Expected 'array', got '${B(s.styles)}'`,typeError:!0}])};for(var C=Ge(l,`styles`),w=0;w<s.styles.length;w++){var T=s.styles[w],E=Ge(C,w);if(typeof T!=`string`)return{v:V({},E,[{message:`Expected 'string', got '${B(T)}'`,typeError:!0}])};T===`bold`&&!r.options.bold&&o(E,`Style 'bold' is not valid`,!1),T===`italic`&&!r.options.italic&&o(E,`Style 'italic' is not valid`,!1),T===`lineThrough`&&!r.options.lineThrough&&o(E,`Style 'lineThrough' is not valid`,!1)}}if(`children`in s){if(!Array.isArray(s.children))return{v:V({},l,[{message:`Expected 'array', got '${B(s.children)}'`,typeError:!0}])};var D=a(Ge(l,`children`),s.children,n);if(D)return{v:D}}},u;for(s.s();!(c=s.n()).done;)if(u=l(),u!==0&&u)return u.v}catch(e){s.e(e)}finally{s.f()}return!1},o=a(e,t,n),s=[];if(this.options.maxLength&&i>this.options.maxLength&&s.push({message:`Maximum length of ${this.options.maxLength} exceeded (current length: ${i})`,typeError:!1}),this.options.minLength&&i<this.options.minLength&&s.push({message:`Minimum length of ${this.options.minLength} not met (current length: ${i})`,typeError:!1}),o){if(s.length>0){var c;o[e]||(o[e]=[]),(c=o[e]).push.apply(c,s)}return o}if(Object.keys(n).length>0){if(s.length>0){var l;n[e]||(n[e]=[]),(l=n[e]).push.apply(l,s)}return n}return s.length>0&&V({},e,s)}},{key:`executeAssert`,value:function(e,t){if(this.opt&&t===null)return{success:!0,data:t};if(t===null&&!this.opt)return{success:!1,errors:V({},e,[{message:`Expected 'array', got 'null'`,typeError:!0}])};if(!Array.isArray(t))return{success:!1,errors:V({},e,[{message:`Expected 'array', got '${B(t)}'`,typeError:!0}])};for(var n={},r=0;r<t.length;r++)this.recursiveAssert(Ge(e,r),t[r],n);return Object.keys(n).length>0?{success:!1,errors:n}:{success:!0,data:t}}},{key:`recursiveAssert`,value:function(e,t,n){if(B(t)!==`object`){n[e]||(n[e]=[]),n[e].push({message:`Expected 'object', got '${B(t)}'`,typeError:!0});return}if(Array.isArray(t)){n[e]||(n[e]=[]),n[e].push({message:`Expected 'object', got 'array'`,typeError:!0});return}if(t===null){n[e]||(n[e]=[]),n[e].push({message:`Expected 'object', got 'null'`,typeError:!0});return}if(`tag`in t&&typeof t.tag!=`string`){n[e]||(n[e]=[]),n[e].push({message:`Expected 'string', got '${B(t.tag)}'`,typeError:!0});return}if(`children`in t){if(Array.isArray(t.children))for(var r=0;r<t.children.length;r++){var i=t.children[r],a=Ge(Ge(e,`children`),r);if(B(i)===`object`)this.recursiveAssert(a,i,n);else if(typeof i==`string`)continue;else n[a]||(n[a]=[]),n[a].push({message:`Expected 'object' or 'string', got '${B(i)}'`,typeError:!0})}else{n[e]||(n[e]=[]),n[e].push({message:`Expected 'array', got '${B(t.children)}'`,typeError:!0});return}}if(`styles`in t){if(!Array.isArray(t.styles))n[e]||(n[e]=[]),n[e].push({message:`Expected 'array', got '${B(t.styles)}'`,typeError:!0});else for(var o=0;o<t.styles.length;o++){var s=t.styles[o];if(typeof s!=`string`){var c=Ge(e,o);n[c]||(n[c]=[]),n[c].push({message:`Expected 'string', got '${B(s)}'`,typeError:!0})}}}}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){var e=this,t={maxLength:this.options.maxLength,minLength:this.options.minLength,bold:this.options.bold,italic:this.options.italic,lineThrough:this.options.lineThrough,h1:this.options.h1,h2:this.options.h2,h3:this.options.h3,h4:this.options.h4,h5:this.options.h5,h6:this.options.h6,ul:this.options.ul,ol:this.options.ol,a:function(){return e.options.a instanceof bt||e.options.a instanceof Je?e.options.a.executeSerialize():e.options.a}(),img:this.options.img&&B(this.options.img)===`object`?this.options.img.executeSerialize():this.options.img};return{type:`richtext`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,opt:this.opt,options:t,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),Ct=function(e){return new St(e??{})};function wt(e,t,n,r){var i=Object.defineProperty;try{i({},``,{})}catch{i=0}wt=function(e,t,n,r){function a(t,n){wt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a(`next`,0),a(`throw`,1),a(`return`,2))},wt(e,t,n,r)}function Tt(){var e,t,n=typeof Symbol==`function`?Symbol:{},r=n.iterator||`@@iterator`,i=n.toStringTag||`@@toStringTag`;function a(n,r,i,a){var c=r&&r.prototype instanceof s?r:s,l=Object.create(c.prototype);return wt(l,`_invoke`,function(n,r,i){var a,s,c,l=0,u=i||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,s=0,c=e,f.n=n,o}};function p(n,r){for(s=n,c=r,t=0;!d&&l&&!i&&t<u.length;t++){var i,a=u[t],p=f.p,m=a[2];n>3?(i=m===r)&&(c=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=p&&((i=n<2&&p<a[1])?(s=0,f.v=r,f.n=a[1]):p<m&&(i=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,s=0))}if(i||n>1)return o;throw d=!0,r}return function(i,u,m){if(l>1)throw TypeError(`Generator is already running`);for(d&&u===1&&p(u,m),s=u,c=m;(t=s<2?e:c)||!d;){a||(s?s<3?(s>1&&(f.n=-1),p(s,c)):f.n=c:f.v=c);try{if(l=2,a){if(s||(i=`next`),t=a[i]){if(!(t=t.call(a,c)))throw TypeError(`iterator result is not an object`);if(!t.done)return t;c=t.value,s<2&&(s=0)}else s===1&&(t=a.return)&&t.call(a),s<2&&(c=TypeError(`The iterator does not provide a '`+i+`' method`),s=1);a=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==o)break}catch(t){a=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,i,a),!0),l}var o={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(wt(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,wt(e,i,`GeneratorFunction`)),e.prototype=Object.create(d),e}return c.prototype=l,wt(d,`constructor`,l),wt(l,`constructor`,c),c.displayName=`GeneratorFunction`,wt(l,i,`GeneratorFunction`),wt(d),wt(d,i,`Generator`),wt(d,r,function(){return this}),wt(d,`toString`,function(){return`[object Generator]`}),(Tt=function(){return{w:a,m:f}})()}function Et(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Dt(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Et(a,r,i,o,s,`next`,e)}function s(e){Et(a,r,i,o,s,`throw`,e)}o(void 0)})}}var Ot=`json`;function kt(e){return B(e)===`object`&&e!==null&&`_type`in e&&e._type===Ot}function At(e){var t=e._import;return typeof t==`function`?t:void 0}function jt(e){return Mt.apply(this,arguments)}function Mt(){return Mt=Dt(Tt().m(function e(t){var n,r,i;return Tt().w(function(e){for(;;)switch(e.n){case 0:if(!kt(t)){e.n=3;break}if(n=At(t),n){e.n=1;break}return e.a(2,t);case 1:return e.n=2,n();case 2:return r=e.v.default,e.a(2,jt(r));case 3:if(!Array.isArray(t)){e.n=4;break}return e.a(2,Promise.all(t.map(function(e){return jt(e)})));case 4:if(t===null||B(t)!==`object`){e.n=7;break}if(!(`_type`in t)){e.n=5;break}return e.a(2,t);case 5:return e.n=6,Promise.all(Object.entries(t).map(function(){var e=Dt(Tt().m(function e(t){var n,r,i,a,o;return Tt().w(function(e){for(;;)switch(e.n){case 0:return n=xe(t,2),r=n[0],i=n[1],a=r,e.n=1,jt(i);case 1:return o=e.v,e.a(2,[a,o])}},e)}));return function(t){return e.apply(this,arguments)}}()));case 6:return i=e.v,e.a(2,Object.fromEntries(i));case 7:return e.a(2,t)}},e)})),Mt.apply(this,arguments)}var Nt=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0&&arguments[6],l=arguments.length>7&&arguments[7]!==void 0&&arguments[7],u=arguments.length>8?arguments[8]:void 0,d=arguments.length>9&&arguments[9]!==void 0&&arguments[9],f=arguments.length>10&&arguments[10]!==void 0?arguments[10]:null,p=arguments.length>11&&arguments[11]!==void 0?arguments[11]:null;return De(this,t),n=Pe(this,t),n.item=e,n.opt=r,n.customValidateFunctions=i,n.currentRouter=a,n.keySchema=o,n.mediaOptions=s,n.isReadonly=c,n.isHidden=l,n.description=u,n.isJsonValues=d,n.previewInput=f,n.renderInput=p,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,e??void 0,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`validate`,value:function(e){return new t(this.item,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`executeValidate`,value:function(e,t){var n=this,r=!1,i=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return i.length>0&&V({},e,i);if(t===null)return V({},e,[].concat(z(i),[{message:`Expected 'object', got 'null'`}]));if(B(t)!==`object`)return V({},e,[].concat(z(i),[{message:`Expected 'object', got '${B(t)}'`}]));if(Array.isArray(t))return V({},e,[].concat(z(i),[{message:`Expected 'object', got 'array'`}]));var a=this.getRouterValidations(e,t);r=this.mergeValidationErrors(r,a);var o=w(i),s;try{for(o.s();!(s=o.n()).done;){var c=s.value;r=this.appendValidationError(r,e,c.message,t,c.schemaError)}}catch(e){o.e(e)}finally{o.f()}if(this.mediaOptions){var l=this.mediaOptions.type===`images`?`images:check-unique-folder`:`files:check-unique-folder`,u={message:`Gallery directory '${this.mediaOptions.directory}' must be unique across all galleries`,value:{directory:this.mediaOptions.directory,type:this.mediaOptions.type},fixes:[l]};r?r[e]?r[e]=[].concat(z(r[e]),[u]):r=qe(qe({},r),{},V({},e,[u])):r=V({},e,[u]);var d=this.mediaOptions.type===`images`?`images:check-all-files`:`files:check-all-files`,f={message:`Directory '${this.mediaOptions.directory}' may have files not tracked by this gallery`,value:{directory:this.mediaOptions.directory,type:this.mediaOptions.type},fixes:[d]};r[e]?r[e]=[].concat(z(r[e]),[f]):r=qe(qe({},r),{},V({},e,[f]))}return Object.entries(t).forEach(function(i){var a=xe(i,2),o=a[0],s=a[1];if(n.keySchema){var c=We(e,o);if(!c)throw Error(`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} for key validation`);var l=n.keySchema.executeValidate(c,o);l&&(l[c]=l[c].map(function(e){return qe(qe({},e),{},{keyError:!0})}),r=n.mergeValidationErrors(r,l))}var u=We(e,o);if(!u)r=n.appendValidationError(r,e,`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} at key ${s}`,t);else if(n.mediaOptions){var d=n.validateMediaKey(u,o);d&&n.markKeyErrorsAtPath(d,u),r=n.mergeValidationErrors(r,d);var f=n.validateMediaEntry(u,s);f&&n.markKeyErrorsAtPath(f,u),r=n.mergeValidationErrors(r,f)}else if(!(n.isJsonValues&&kt(s))){var p=n.item.executeValidate(u,s);r=n.mergeValidationErrors(r,p)}}),r}},{key:`isRemoteUrl`,value:function(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}},{key:`markKeyErrorsAtPath`,value:function(e,t){e&&e[t]&&(e[t]=e[t].map(function(e){return qe(qe({},e),{},{keyError:!0})}))}},{key:`validateMediaKey`,value:function(e,t){if(!this.mediaOptions)return!1;var n=this.mediaOptions,r=n.directory,i=n.remote,a=n.type,o=a===`images`?`images`:`files`,s=a===`images`?`images:check-remote`:`files:check-remote`,c=this.isRemoteUrl(t),l=t===r||t.startsWith(r+`/`);if(i){if(c){var u=at(t);if(u.status===`error`)return V({},e,[{message:`Invalid remote URL format. Use Val tooling (CLI, VS Code extension, or Val Studio) to upload ${o}. Got: ${t}`,value:t,fixes:[s]}]);var d=`/`+u.filePath;return d!==r&&!d.startsWith(r+`/`)&&V({},e,[{message:`Remote file path '${d}' is not in expected directory '${r}'. Use Val tooling to upload ${o} to the correct directory.`,value:t,fixes:[s]}])}if(!l)return V({},e,[{message:`Expected a remote URL (https://...) or a local path starting with ${r}/. Got: ${t}`,value:t}]);var f=a===`images`?`images:upload-remote`:`files:upload-remote`;return V({},e,[{message:`Expected a remote ${a===`images`?`image`:`file`}, but got a local path. Use Val tooling (CLI --fix, VS Code extension, or Val Studio) to upload it. Got: ${t}`,value:t,fixes:[f]}])}return c?V({},e,[{message:`Remote URLs are not allowed. Use .remote() to enable remote ${o}. Got: ${t}`,value:t,fixes:[s]}]):!l&&V({},e,[{message:`File path must be within the ${r}/ directory. Got: ${t}`,value:t}])}},{key:`validateMediaEntry`,value:function(e,t){if(!this.mediaOptions)return!1;var n=this.mediaOptions,r=n.type,i=n.accept,a=n.altSchema;if(B(t)!==`object`||t===null)return V({},e,[{message:`Expected 'object', got '${B(t)}'`,value:t}]);var o=t,s=[];if(r===`images`&&((typeof o.width!=`number`||o.width<=0)&&s.push({message:`Expected 'width' to be a positive number, got '${o.width}'`,value:t}),(typeof o.height!=`number`||o.height<=0)&&s.push({message:`Expected 'height' to be a positive number, got '${o.height}'`,value:t})),typeof o.mimeType!=`string`)s.push({message:`Expected 'mimeType' to be a string, got '${B(o.mimeType)}'`,value:t});else{var c=this.validateMediaMimeType(o.mimeType,i);c&&s.push({message:c,value:t})}if(r===`images`){if(o.hotspot!==void 0){var l=o.hotspot;(B(o.hotspot)!==`object`||typeof l.x!=`number`||typeof l.y!=`number`)&&s.push({message:`Hotspot must be an object with x and y as numbers.`,value:t})}var u=We(e,`alt`);if(u&&a){var d=a.executeValidate(u,o.alt);if(d)return s.length>0?qe(qe({},d),{},V({},e,s)):d}}return s.length>0&&V({},e,s)}},{key:`validateMediaMimeType`,value:function(e,t){return e.includes(`/`)?_t(e,t)?null:`Mime type mismatch. Found '${e}' but schema accepts '${t}'`:`Invalid mime type format. Got: '${e}'`}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'object', got 'null'`,typeError:!0}])}:B(t)===`object`?Array.isArray(t)?{success:!1,errors:V({},e,[{message:`Expected 'object', got 'array'`,typeError:!0}])}:{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'object', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.item,!0,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`readonly`,value:function(){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,!0,this.isHidden,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`hidden`,value:function(){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,!0,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`router`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,e,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`remote`,value:function(){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions?qe(qe({},this.mediaOptions),{},{remote:!0}):void 0,this.isReadonly,this.isHidden,this.description,this.isJsonValues,this.previewInput,this.renderInput)}},{key:`jsonValues`,value:function(){if(this.mediaOptions)throw Error(`.jsonValues() cannot be used with image/file galleries (s.images()/s.files())`);if(this.customValidateFunctions.length>0)throw Error(`.jsonValues() must come BEFORE .validate(): a validator added first is typed against the un-lazy source shape and cannot be carried over. Write s.record(...).jsonValues().validate(...) instead.`);if(this.previewInput!==null)throw Error(`.jsonValues() must come BEFORE .preview(): a preview added first is typed against the un-lazy source shape and cannot be carried over. Write s.record(...).jsonValues().preview(...) instead.`);return new t(this.item,this.opt,[],this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,!0,null,this.renderInput)}},{key:`getRouterValidations`,value:function(e,t){if(!this.currentRouter||t===null)return!1;var n=xe(Lt(e),2),r=n[0];if(n[1])return V({},e,[{message:`This field was configured as a router, but it is not defined at the root of the module`,schemaError:!0}]);var i=this.currentRouter.validate(r,Object.keys(t));return i.length>0&&Object.fromEntries(i.map(function(t){if(!t.error.urlPath)return[e,[{message:`Router validation error: ${t.error.message} has no url path`,schemaError:!0}]];var n=We(e,t.error.urlPath);if(!n)throw Error(`Internal error: could not create path at ${!e&&typeof e==`string`?`<empty string>`:e} for router validation`);return[n,[{message:t.error.message,value:t.error.urlPath,keyError:!0}]]}))}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`executeSerialize`,value:function(){var e={type:`record`,render:this.renderInput??void 0,item:this.item.executeSerialize(),key:this.keySchema?.executeSerialize(),opt:this.opt,preview:this.previewInput?!0:void 0,router:this.currentRouter?.getRouterId(),customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,jsonValues:this.isJsonValues?!0:void 0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description};return this.mediaOptions&&(e.mediaType=this.mediaOptions.type,e.accept=this.mediaOptions.accept,e.directory=this.mediaOptions.directory,e.remote=this.mediaOptions.remote,this.mediaOptions.encode!==void 0&&(e.encode=this.mediaOptions.encode),this.mediaOptions.altSchema&&(e.alt=this.mediaOptions.altSchema.executeSerialize())),e}},{key:`validateJsonEntryContent`,value:function(e,t){return this.item.executeValidate(e,t)}},{key:`executePreview`,value:function(e,t,n){var r={};if(t===null)return r;for(var i in t){var a=t[i];if(a!=null&&!kt(a)){var o=Ge(e,i);if(!(n!==void 0&&!n.wantsUnder(o))){var s=this.item.executePreview(o,a,n);for(var c in s){var l=c;r[l]=s[l]}}}}if(this.item.declaresItemPreview()){for(var u=n!==void 0&&!n.wants(e)?n:null,d=[],f=0,p=Object.entries(t);f<p.length;f++){var m=xe(p[f],2),h=m[0],g=m[1];if(!kt(g)&&g!=null&&!(u!==null&&!u.wantsUnder(Ge(e,h))))try{var _=this.item.executePreviewItem(g);if(_!==null){var v=_.title,y=_.subtitle,b=_.image;d.push([h,{title:v,subtitle:y,image:b}])}}catch(t){r[Ge(e,h)]={status:`error`,message:t instanceof Error?t.message:`Unknown error`}}}r[e]={status:`success`,data:{parent:`record`,items:d}}}return r}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`preview`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,this.isJsonValues,e,this.renderInput)}},{key:`render`,value:function(e){return new t(this.item,this.opt,this.customValidateFunctions,this.currentRouter,this.keySchema,this.mediaOptions,this.isReadonly,this.isHidden,this.description,this.isJsonValues,this.previewInput,e)}}])}(Le);function Pt(e,t){return t?new Nt(t,!1,[],null,e):new Nt(e,!1,[],null,null)}function Ft(e){return e[Be]}function It(e){return B(e)===`object`&&e!==null&&Be in e&&Re in e&&ze in e}function Lt(e){var t=e.indexOf(`?p=`);return t===-1?[e,``]:[e.slice(0,t),e.slice(t+3)]}function Rt(e,t){return t===``?e:`${e}?p=${t}`}function zt(e){return e instanceof Xe||B(e)===`object`&&`type`in e&&e.type===`object`}function Bt(e){return e instanceof Nt||B(e)===`object`&&`type`in e&&e.type===`record`}function Vt(e){return e instanceof Qe||B(e)===`object`&&`type`in e&&e.type===`array`}function Ht(e){return e instanceof nt||B(e)===`object`&&`type`in e&&e.type===`union`}function Ut(e){return e instanceof St||B(e)===`object`&&`type`in e&&e.type===`richtext`}function Wt(e){return e instanceof vt||B(e)===`object`&&`type`in e&&e.type===`image`}function Gt(e,t,n){for(var r=Jt(e),i=z(r),a=n,o=t,s=function(){var t=r.shift();if(t===void 0)throw Error(`Unexpected undefined part`);if(Vt(a)){if(Number.isNaN(Number(t)))throw Error(`Invalid path: array schema ${JSON.stringify(a)} must have a number as path, but got ${t}. Path: ${e}`);if(B(o)!==`object`&&!Array.isArray(o))throw Error(`Schema type error: expected source to be type of array, but got ${B(o)}`);o=o[t],a=a instanceof Qe?a?.item:a.item}else if(Bt(a)){if(typeof t!=`string`)throw Error(`Invalid path: record schema ${a} must have path: ${t} as string`);if(B(o)!==`object`&&!Array.isArray(o))throw Error(`Schema type error: expected source to be type of record, but got ${B(o)}`);if(!o[t])throw Error(`Invalid path: record source did not have key ${t} from path: ${e}`);if(o=o[t],a=a instanceof Nt?a?.item:a.item,kt(o)&&r.length>0)throw Error(`Cannot resolve path into a jsonValues entry until its content is loaded. Path: ${e}`)}else if(zt(a)){if(B(o)!==`object`)throw Error(`Schema type error: expected source to be type of object, but got ${B(o)}`);if(o!==null&&o[t]===void 0)throw Error(`Invalid path: object source did not have key ${t} from path: ${e}`);o=o===null?o:o[t],a=(a instanceof Xe,a.items[t])}else if(Wt(a))return{v:{path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`),schema:a,source:o}};else if(Ht(a)){var n=a.key;if(typeof n!=`string`)return{v:{path:i.map(function(e){return Number.isNaN(Number(e))?JSON.stringify(e):e}).join(`.`),schema:a,source:o}};var s=o[n];if(!s)throw Error(`Invalid path: union source ${a} did not have required key ${n} in path: ${e}`);var c=a.items.find(function(e){var t;return(e==null||(t=e.items)==null||(t=t[n])==null?void 0:t.value)===s});if(!c)throw Error(`Invalid path: union schema ${a} did not have a child object with ${n} of value ${s} in path: ${e}`);a=c.items[t],o=o[t]}else if(Ut(a)){if(`src`in o&&`tag`in o&&o.tag===`img`&&r.length===0){var l;a=a instanceof St&&(l=a.options)!=null&&l.img&&typeof a.options?.img!=`boolean`?a.options.img:a}if(`href`in o&&`tag`in o&&o.tag===`a`&&r.length===0){var u;a=a instanceof St&&(u=a.options)!=null&&u.a&&typeof a.options?.a!=`boolean`?a.options.a:a}o=o[t]}else throw Error(`Invalid path: ${t} resolved to an unexpected schema ${JSON.stringify(a)}`)},c;r.length>0;)if(c=s(),c)return c.v;if(r.length>0)throw Error(`Invalid path: ${r.join(`.`)} is not a valid path`);return{path:i.map(function(e){return Number.isNaN(Number(e))?JSON.stringify(e):e}).join(`.`),schema:a,source:o}}function Kt(e,t,n){for(var r=Jt(e),i=z(r),a=n,o=t,s=function(){var t=r.shift();if(t===void 0)return{v:{status:`error`,message:`Unexpected undefined part`}};if(Vt(a)){if(Number.isNaN(Number(t)))return{v:{status:`error`,message:`Invalid path: array schema ${JSON.stringify(a)} must have a number as path, but got ${t}. Path: ${e}`}};if(o===void 0)return{v:{status:`source-undefined`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`)}};if(B(o)!==`object`&&!Array.isArray(o))return{v:{status:`error`,message:`Schema type error: expected source to be type of array, but got ${B(o)}`}};if(o[t]===void 0)return{v:{status:`source-undefined`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`)}};o=o[t],a=a instanceof Qe?a?.item:a.item}else if(Bt(a)){if(typeof t!=`string`)return{v:{status:`error`,message:`Invalid path: record schema ${a} must have path: ${t} as string`}};if(o===void 0)return{v:{status:`source-undefined`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`)}};if(B(o)!==`object`&&!Array.isArray(o))return{v:{status:`error`,message:`Schema type error: expected source to be type of record, but got ${B(o)}`}};if(o[t]===void 0)return{v:{status:`source-undefined`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`)}};if(o=o[t],a=a instanceof Nt?a?.item:a.item,kt(o)&&r.length>0)return{v:{status:`error`,message:`Cannot resolve path into a jsonValues entry until its content is loaded. Path: ${e}`}}}else if(zt(a)){if(o===void 0)return{v:{status:`source-undefined`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`)}};if(B(o)!==`object`)return{v:{status:`error`,message:`Schema type error: expected source to be type of object, but got ${B(o)}`}};if(o!==null&&o[t]===void 0)return{v:{status:`error`,message:`Invalid path: object source did not have key ${t} from path: ${e}`}};o=o===null?o:o[t],a=(a instanceof Xe,a.items[t])}else if(Wt(a))return{v:{status:`ok`,path:i.slice(0,i.length-r.length-1).map(function(e){return JSON.stringify(e)}).join(`.`),schema:a,source:o}};else if(Ht(a)){var n=a.key;if(typeof n!=`string`)return{v:{status:`ok`,path:i.map(function(e){return Number.isNaN(Number(e))?JSON.stringify(e):e}).join(`.`),schema:a,source:o}};var s=o[n];if(!s)return{v:{status:`error`,message:`Invalid path: union source ${a} did not have required key ${n} in path: ${e}`}};var c=a.items.find(function(e){var t;return(e==null||(t=e.items)==null||(t=t[n])==null?void 0:t.value)===s});if(!c)return{v:{status:`error`,message:`Invalid path: union schema ${a} did not have a child object with ${n} of value ${s} in path: ${e}`}};a=c.items[t],o=o[t]}else if(Ut(a)){if(`src`in o&&`tag`in o&&o.tag===`img`&&r.length===0){var l;a=a instanceof St&&(l=a.options)!=null&&l.img&&typeof a.options?.img!=`boolean`?a.options.img:a}if(`href`in o&&`tag`in o&&o.tag===`a`&&r.length===0){var u;a=a instanceof St&&(u=a.options)!=null&&u.a&&typeof a.options?.a!=`boolean`?a.options.a:a}o=o[t]}else return{v:{status:`error`,message:`Invalid path: ${t} resolved to an unexpected schema ${JSON.stringify(a)}`}}},c;r.length>0;)if(c=s(),c)return c.v;return r.length>0?{status:`error`,message:`Invalid path: ${r.join(`.`)} is not a valid path`}:{status:`ok`,path:i.map(function(e){return Number.isNaN(Number(e))?JSON.stringify(e):e}).join(`.`),schema:a,source:o}}function qt(e){return e.split(`/`).slice(1)}function Jt(e){for(var t=[],n=0;n<e.length;){var r=``;if(e[n]===`"`){for(n++;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&e[n+1]===`"`?(r+=`"`,n++):r+=e[n],n++;if(e[n]!==`"`)throw Error(`Invalid input (${JSON.stringify(e)}): Missing closing double quote: ${e[n]??`at end of string`} (char: ${n}; length: ${e.length})`)}else for(;n<e.length&&e[n]!==`.`;)r+=e[n],n++;r!==``&&t.push(r),n++}return t}function Yt(e){return e.split(`,`)}function Xt(e){var t=xe(Lt(e),2),n=t[0],r=t[1],i=Jt(r).slice(0,-1);return i.length>0?Rt(n,Zt(i)):n}function Zt(e){return e.map(function(e){return Number.isInteger(Number(e))?e:JSON.stringify(e)}).join(`.`)}var Qt=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n,r,i=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null?i.length>0&&V({},e,i):typeof t==`number`?(n=this.options)!=null&&n.max&&t>this.options.max?V({},e,[].concat(z(i),[{message:`Expected 'number' less than ${this.options.max}`,value:t}])):(r=this.options)!=null&&r.min&&t<this.options.min?V({},e,[].concat(z(i),[{message:`Expected 'number' greater than ${this.options.min}`,value:t}])):i.length>0&&V({},e,i):V({},e,[].concat(z(i),[{message:`Expected 'number', got '${B(t)}'`,value:t}]))}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'number', got 'null'`,typeError:!0}])}:typeof t==`number`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'number', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`max`,value:function(e){return new t(qe(qe({},this.options),{},{max:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`min`,value:function(e){return new t(qe(qe({},this.options),{},{min:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`number`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,options:this.options,opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),$t=function(e){return new Qt(e)},en=function(e){function t(){var e,n=arguments.length>0&&arguments[0]!==void 0&&arguments[0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null;return De(this,t),e=Pe(this,t),e.opt=n,e.customValidateFunctions=r,e.isReadonly=i,e.isHidden=a,e.description=o,e.renderInput=s,e.previewInput=c,e}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){return this.opt&&t==null?!1:typeof t!=`boolean`&&V({},e,[{message:`Expected 'boolean', got '${B(t)}'`,value:t}])}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'boolean', got 'null'`,typeError:!0}])}:typeof t==`boolean`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'boolean', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`boolean`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),tn=function(){return new en},nn=function(e){function t(e,n){var r,i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5&&arguments[5]!==void 0&&arguments[5],c=arguments.length>6?arguments[6]:void 0,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:null;return De(this,t),r=Pe(this,t),r.schema=e,r.sourcePath=n,r.opt=i,r.customValidateFunctions=a,r.isReadonly=o,r.isHidden=s,r.description=c,r.renderInput=l,r.previewInput=u,r}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.schema,this.sourcePath,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.schema,this.sourcePath,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return n.length>0&&V({},e,n);if(!this.schema)return V({},e,[].concat(z(n),[{message:`Schema not found for module. keyOf must be used with a Val Module`}]));var r=this.schema;if(r.type!==`object`&&r.type!==`record`)return V({},e,[].concat(z(n),[{message:`Schema in keyOf must be an 'object' or 'record'. Found '${r.type||`unknown`}'`}]));if(r.opt&&t==null)return!1;if(r.type===`record`&&typeof t!=`string`)return V({},e,[].concat(z(n),[{message:`Type of value in keyof (record) must be 'string'`}]));if(r.type===`object`){var i=r.keys;if(!i.includes(t))return V({},e,[].concat(z(n),[{message:`Value of keyOf (object) must be: ${i.join(`, `)}. Found: ${t}`}]))}return r.type===`record`?typeof t==`string`?V({},e,[].concat(z(n),[{fixes:[`keyof:check-keys`],message:`Did not validate keyOf (record). This error (keyof:check-keys) should typically be processed by Val internally. Seeing this error most likely means you have a Val version mismatch.`,value:{key:t,sourcePath:this.sourcePath}}])):V({},e,[].concat(z(n),[{message:`Value of keyOf (record) must be 'string'. Found: ${B(t)}`}])):n.length>0&&V({},e,n)}},{key:`executeAssert`,value:function(e,t){if(this.opt&&t===null)return{success:!0,data:t};if(t===null)return{success:!1,errors:V({},e,[{message:`Expected 'string', got 'null'`,typeError:!0}])};var n=this.schema;if(!n)return{success:!1,errors:V({},e,[{message:`Neither key nor schema was found. keyOf is missing an argument.`,typeError:!0}])};var r=n;if(r.type!==`object`&&r.type!==`record`)return{success:!1,errors:V({},e,[{message:`Schema of first argument must be either: 'array', 'object' or 'record'. Found '${r.type||`unknown`}'`,typeError:!0}])};if(r.type===`record`&&typeof t!=`string`)return{success:!1,errors:V({},e,[{message:`Value of keyOf (record) must be 'string', got '${B(t)}'`,typeError:!0}])};if(r.type===`object`){var i=r.keys;if(!i.includes(t))return{success:!1,errors:V({},e,[{message:`Value of keyOf (object) must be: ${i.join(`, `)}. Found: ${t}`,typeError:!0}])}}return{success:!0,data:t}}},{key:`nullable`,value:function(){return new t(this.schema,this.sourcePath,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.schema,this.sourcePath,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.schema,this.sourcePath,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.schema,this.sourcePath,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.schema,this.sourcePath,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){var e=this.sourcePath;if(!e)throw Error(`Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module of record schema.`);var t=this.schema;if(!t)throw Error(`Cannot serialize keyOf schema with empty selector.`);var n;switch(t.type){case`record`:n=`string`;break;case`object`:n=t.keys;break;default:throw Error(`Cannot serialize keyOf schema with selector of type '${t.type||`unknown`}'`)}return{type:`keyOf`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,path:e,schema:t,opt:this.opt,values:n,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),rn=function(e){var t=e?.[Re],n=void 0;if(t instanceof Xe){var r=[];try{r=Object.keys(t?.items||{})}catch{}n={type:`object`,keys:r,opt:t?.opt}}else t instanceof Nt&&(n={type:`record`,opt:t?.opt});return new nn(n,Ue(e))},an=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[],o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},s=arguments.length>5&&arguments[5]!==void 0&&arguments[5],c=arguments.length>6&&arguments[6]!==void 0&&arguments[6],l=arguments.length>7?arguments[7]:void 0,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:null,d=arguments.length>9&&arguments[9]!==void 0?arguments[9]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.isRemote=i,n.customValidateFunctions=a,n.moduleMetadata=o,n.isReadonly=s,n.isHidden=c,n.description=l,n.renderInput=u,n.previewInput=d,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`remote`,value:function(){return new t(this.options,this.opt,!0,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,this.isRemote,[].concat(z(this.customValidateFunctions),[e]),this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return n.length>0&&V({},e,n);if(t==null)return V({},e,[].concat(z(n),[{message:`Non-optional file was null or undefined.`,value:t}]));if(typeof t.path!=`string`)return V({},e,[].concat(z(n),[{message:`File did not have a path string. Got: ${B(t.path)}`,value:t}]));var r=ot(t.path);if(this.isRemote&&!r)return V({},e,[].concat(z(n),[{message:`Expected a remote file, but got a local file.`,value:t,fixes:[`file:upload-remote`]}]));if(this.isRemote&&r)return V({},e,[].concat(z(n),[{message:`Remote file was not checked.`,value:t,fixes:[`file:check-remote`]}]));if(!this.isRemote&&r)return V({},e,[].concat(z(n),[{message:`Expected local file, but found remote.`,value:t,fixes:[`file:download-remote`]}]));var i=this.galleryEntries();if(i)return t.mimeType===void 0?t.path in i?n.length>0&&V({},e,n):V({},e,[].concat(z(n),[{message:`The gallery does not have a file at '${t.path}'.`,value:t}])):V({},e,[].concat(z(n),[{message:`A file from a gallery must not carry its own mimeType: it is stored in the gallery module.`,value:t}]));var a=(this.options||{}).accept,o=t.mimeType;if(a&&o&&!o.includes(`/`))return V({},e,[].concat(z(n),[{message:`Invalid mime type format. Got: ${o}`,value:t}]));if(a&&o&&o.includes(`/`)&&!_t(o,a))return V({},e,[].concat(z(n),[{message:`Mime type mismatch. Found '${o}' but schema accepts '${a}'`,value:t}]));var s=H.filenameToMimeType(t.path);return s?o&&s!==o?V({},e,[].concat(z(n),[{message:`Mime type and file extension not matching. Mime type is '${o}' but file extension is '${s}'`,value:t}])):o===void 0?V({},e,[].concat(z(n),[{message:`File metadata is missing: mimeType.`,value:t,fixes:[`file:add-metadata`]}])):V({},e,[].concat(z(n),[{message:`File mimeType has not been checked against the file.`,value:t,fixes:[`file:check-metadata`]}])):V({},e,[].concat(z(n),[{message:`Could not determine mime type from file extension. Got: ${t.path}`,value:t}]))}},{key:`galleryEntries`,value:function(){var e=Object.keys(this.moduleMetadata);return e.length===0?null:this.moduleMetadata[e[0]]}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'object', got 'null'`,typeError:!0}])}:B(t)===`object`?!(`path`in t)||typeof t.path!=`string`?{success:!1,errors:V({},e,[{message:`A file must be an object with a 'path' (error type: missing_path)`,typeError:!0}])}:{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected object, got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.isRemote,this.customValidateFunctions,this.moduleMetadata,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){var e=this.moduleMetadata?Object.keys(this.moduleMetadata):[];return{type:`file`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,options:this.options,opt:this.opt,remote:this.isRemote,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,referencedModule:e.length>0?e[0]:void 0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le);function on(e){if(e&&H.getValPath(e)){for(var t={},n=0,r=[e];n<r.length;n++){var i=r[n],a=Ue(i);if(a===void 0)throw Error(`Invalid argument passed to s.file(). Expected a ValModule constructed through c.define, but got an object without a valid module path.`);t[a]=Ft(i)}return new an({},!1,!1,[],t)}return new an(e)}var sn=function(e){var t=e.directory;return new Nt(new Xe({mimeType:new Je({},!1)},!1),!1,[],null,null,{type:`files`,accept:e.accept,directory:t,remote:e.remote??!1})},cn=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n,r,i,a,o=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null?o.length>0&&V({},e,o):typeof t==`string`?((n=this.options)!=null&&n.from&&(r=this.options)!=null&&r.to?this.options.from>this.options.to?o.push({message:`From date ${this.options.from} is after to date ${this.options.to}`,value:t,typeError:!0}):(t<this.options.from||t>this.options.to)&&o.push({message:`Date is not between ${this.options.from} and ${this.options.to}`,value:t}):(i=this.options)!=null&&i.from?t<this.options.from&&o.push({message:`Date is before the minimum date ${this.options.from}`,value:t}):(a=this.options)!=null&&a.to&&t>this.options.to&&o.push({message:`Date is after the maximum date ${this.options.to}`,value:t}),o.length>0&&V({},e,o)):(o.push({message:`Expected 'string', got '${B(t)}'`,value:t}),V({},e,o))}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'string', got 'null'`,typeError:!0}])}:typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}])}}},{key:`from`,value:function(e){return new t(qe(qe({},this.options),{},{from:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`to`,value:function(e){return new t(qe(qe({},this.options),{},{to:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`date`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,opt:this.opt,options:this.options,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),ln=function(e){return new cn(e)},un=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return n.length>0&&V({},e,n);if(typeof t!=`string`)return n.push({message:`Expected 'string', got '${B(t)}'`,value:t}),V({},e,n);var r=Date.parse(t);if(Number.isNaN(r))return n.push({message:`Value '${t}' is not a valid ISO 8601 datetime`,value:t}),V({},e,n);var i=this.options?.from===void 0?void 0:Date.parse(this.options.from),a=this.options?.to===void 0?void 0:Date.parse(this.options.to);return i!==void 0&&Number.isNaN(i)?(n.push({message:`From datetime '${this.options?.from}' is not a valid ISO 8601 datetime`,value:t,typeError:!0}),V({},e,n)):a!==void 0&&Number.isNaN(a)?(n.push({message:`To datetime '${this.options?.to}' is not a valid ISO 8601 datetime`,value:t,typeError:!0}),V({},e,n)):(i!==void 0&&a!==void 0?i>a?n.push({message:`From datetime ${this.options?.from} is after to datetime ${this.options?.to}`,value:t,typeError:!0}):(r<i||r>a)&&n.push({message:`Datetime is not between ${this.options?.from} and ${this.options?.to}`,value:t}):i===void 0?a!==void 0&&r>a&&n.push({message:`Datetime is after the maximum datetime ${this.options?.to}`,value:t}):r<i&&n.push({message:`Datetime is before the minimum datetime ${this.options?.from}`,value:t}),n.length>0&&V({},e,n))}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'string', got 'null'`,typeError:!0}])}:typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}])}}},{key:`from`,value:function(e){return new t(qe(qe({},this.options),{},{from:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`to`,value:function(e){return new t(qe(qe({},this.options),{},{to:e}),this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`dateTime`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,opt:this.opt,options:this.options,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),dn=function(e){return new un(e)},fn=[`typescript`,`javascript`,`javascriptreact`,`typescriptreact`,`json`,`java`,`html`,`css`,`xml`,`markdown`,`sql`,`python`,`rust`,`php`,`go`,`cpp`,`sass`,`vue`,`angular`],pn=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});return this.opt&&t==null||typeof t!=`string`&&n.push({message:`Expected 'string', got '${t===null?`null`:B(t)}'`,value:t}),n.length>0&&V({},e,n)}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null||typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${t===null?`null`:B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`code`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,options:this.options,opt:this.opt,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),mn=function(e){return new pn(e)};function hn(e){var t=e.trim().toLowerCase();return t.startsWith(`#`)?`hex`:t.startsWith(`rgb(`)||t.startsWith(`rgba(`)?`rgb`:t.startsWith(`hsl(`)||t.startsWith(`hsla(`)?`hsl`:t.startsWith(`oklch(`)?`oklch`:null}function gn(e,t,n){return Number.isNaN(e)?t:Math.min(n,Math.max(t,e))}function _n(e){var t=e.split(`/`);if(t.length>2)return null;var n=t.length===2?t[1].trim():null,r=t[0].trim();if(r===``)return null;var i;if(r.includes(`,`)){if(n!==null)return null;i=r.split(`,`).map(function(e){return e.trim()}),i.length===4&&(n=i[3],i=i.slice(0,3))}else i=r.split(/\s+/);return i.length!==3||i.some(function(e){return e===``})||n===``?null:{components:i,alpha:n}}function vn(e){if(!/^[+-]?(\d+\.?\d*|\.\d+)$/.test(e))return null;var t=Number(e);return Number.isFinite(t)?t:null}function yn(e,t){if(e.endsWith(`%`)){var n=vn(e.slice(0,-1));return n===null?null:n/100*t}return vn(e)}function bn(e){return e.endsWith(`%`)?vn(e.slice(0,-1)):null}function xn(e){if(e===null)return 1;if(e===`none`)return 0;var t=yn(e,1);return t===null?null:gn(t,0,1)}function Sn(e){var t=/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|grad|rad|turn)?$/.exec(e);if(!t)return null;var n=Number(t[1]);switch(t[2]){case`grad`:return n/400*360;case`rad`:return n*180/Math.PI;case`turn`:return n*360;default:return n}}function Cn(e){var t=e%360;return t<0?t+360:t}function wn(e){var t=e.slice(1);if(!/^[0-9a-f]+$/i.test(t))return null;var n=function(e){return parseInt(e+e,16)},r=function(e){return parseInt(t.slice(e,e+2),16)};return t.length===3||t.length===4?{r:n(t[0]),g:n(t[1]),b:n(t[2]),a:t.length===4?n(t[3])/255:1}:t.length===6||t.length===8?{r:r(0),g:r(2),b:r(4),a:t.length===8?r(6)/255:1}:null}function Tn(e,t){return!e.startsWith(t+`(`)||!e.endsWith(`)`)?null:e.slice(t.length+1,-1)}function eee(e){var t=Tn(e,`rgba`)??Tn(e,`rgb`);if(t===null)return null;var n=_n(t);if(!n)return null;var r=n.components.map(function(e){return e===`none`?0:yn(e,255)}),i=xn(n.alpha);return r.some(function(e){return e===null})||i===null?null:{r:gn(r[0],0,255),g:gn(r[1],0,255),b:gn(r[2],0,255),a:i}}function En(e){var t=Tn(e,`hsla`)??Tn(e,`hsl`);if(t===null)return null;var n=_n(t);if(!n)return null;var r=xe(n.components,3),i=r[0],a=r[1],o=r[2],s=i===`none`?0:Sn(i),c=a===`none`?0:bn(a)??vn(a),l=o===`none`?0:bn(o)??vn(o),u=xn(n.alpha);return s===null||c===null||l===null||u===null?null:qe(qe({},Mn(Cn(s),gn(c,0,100),gn(l,0,100))),{},{a:u})}function Dn(e){var t=Tn(e,`oklch`);if(t===null)return null;var n=_n(t);if(!n)return null;var r=xe(n.components,3),i=r[0],a=r[1],o=r[2],s=i===`none`?0:yn(i,1),c=a===`none`?0:yn(a,.4),l=o===`none`?0:Sn(o),u=xn(n.alpha);return s===null||c===null||l===null||u===null?null:qe(qe({},In(gn(s,0,1),Math.max(0,c),Cn(l))),{},{a:u})}function On(e){var t=e.trim().toLowerCase();if(t===``)return null;switch(hn(t)){case`hex`:return wn(t);case`rgb`:return eee(t);case`hsl`:return En(t);case`oklch`:return Dn(t);default:return null}}function kn(e,t){var n=10**t;return Math.round(e*n)/n||0}function An(e){return gn(Math.round(e),0,255).toString(16).padStart(2,`0`)}function jn(e,t,n){var r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=o-s,l=(o+s)/2;if(c===0)return{h:0,s:0,l:l*100};var u=c/(1-Math.abs(2*l-1));return{h:Cn((o===r?(i-a)/c%6:o===i?(a-r)/c+2:(r-i)/c+4)*60),s:u*100,l:l*100}}function Mn(e,t,n){var r=t/100,i=n/100,a=(1-Math.abs(2*i-1))*r,o=Cn(e)/60,s=a*(1-Math.abs(o%2-1)),c=i-a/2,l=o<1?[a,s,0]:o<2?[s,a,0]:o<3?[0,a,s]:o<4?[0,s,a]:o<5?[s,0,a]:[a,0,s];return{r:(l[0]+c)*255,g:(l[1]+c)*255,b:(l[2]+c)*255}}function Nn(e){var t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Pn(e){return gn((e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055)*255,0,255)}function Fn(e,t,n){var r=Nn(e),i=Nn(t),a=Nn(n),o=Math.cbrt(.4122214708*r+.5363325363*i+.0514459929*a),s=Math.cbrt(.2119034982*r+.6806995451*i+.1073969566*a),c=Math.cbrt(.0883024619*r+.2817188376*i+.6299787005*a),l=.2104542553*o+.793617785*s-.0040720468*c,u=1.9779984951*o-2.428592205*s+.4505937099*c,d=.0259040371*o+.7827717662*s-.808675766*c,f=Math.sqrt(u*u+d*d),p=f<1e-6?0:Cn(Math.atan2(d,u)*180/Math.PI);return{l:gn(l,0,1),c:f,h:p}}function In(e,t,n){var r=Cn(n)*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=(e+.3963377774*i+.2158037573*a)**3,s=(e-.1055613458*i-.0638541728*a)**3,c=(e-.0894841775*i-1.291485548*a)**3;return{r:Pn(4.0767416621*o-3.3077115913*s+.2309699292*c),g:Pn(-1.2684380046*o+2.6097574011*s-.3413193965*c),b:Pn(-.0041960863*o-.7034186147*s+1.707614701*c)}}function Ln(e,t){var n=gn(e.a,0,1),r=n>=1?``:` / ${kn(n,4)}`;switch(t){case`hex`:var i=`#${An(e.r)}${An(e.g)}${An(e.b)}`;return n>=1?i:`${i}${An(n*255)}`;case`rgb`:return`rgb(${gn(Math.round(e.r),0,255)} ${gn(Math.round(e.g),0,255)} ${gn(Math.round(e.b),0,255)}${r})`;case`hsl`:var a=jn(e.r,e.g,e.b),o=a.h,s=a.s,c=a.l;return`hsl(${kn(o,2)} ${kn(s,2)}% ${kn(c,2)}%${r})`;case`oklch`:var l=Fn(e.r,e.g,e.b),u=l.l,d=l.c,f=l.h;return`oklch(${kn(u,4)} ${kn(d,4)} ${kn(f,2)}${r})`}}function Rn(e,t){var n=On(e);return n===null?null:Ln(n,t)}function zn(e){return`#${An(e.r)}${An(e.g)}${An(e.b)}`}var Bn={hex:`#3b82f6`,rgb:`rgb(59 130 246)`,hsl:`hsl(217.22 91.22% 59.8%)`,oklch:`oklch(0.6231 0.188 259.81)`},Vn=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],a=arguments.length>3&&arguments[3]!==void 0&&arguments[3],o=arguments.length>4&&arguments[4]!==void 0&&arguments[4],s=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return De(this,t),n=Pe(this,t),n.options=e,n.opt=r,n.customValidateFunctions=i,n.isReadonly=a,n.isHidden=o,n.description=s,n.renderInput=c,n.previewInput=l,n}return Ie(t,e),ke(t,[{key:`describe`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,e??void 0,this.renderInput,this.previewInput)}},{key:`validate`,value:function(e){return new t(this.options,this.opt,[].concat(z(this.customValidateFunctions),[e]),this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`executeCustomValidateAt`,value:function(e,t){return this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e})}},{key:`executeValidate`,value:function(e,t){var n=this.executeCustomValidateFunctions(t,this.customValidateFunctions,{path:e});if(this.opt&&t==null)return n.length>0&&V({},e,n);if(typeof t!=`string`)return n.push({message:`Expected 'string', got '${B(t)}'`,value:t}),V({},e,n);var r=this.options?.format??`hsl`,i=On(t);if(i===null)n.push({message:`Invalid color: '${t}'. Expected a CSS color in the '${r}' format (e.g. '${Bn[r]}')`,value:t});else{var a;if(hn(t)!==r){var o,s=Ln((o=this.options)!=null&&o.alpha?i:qe(qe({},i),{},{a:1}),r);n.push({message:`Expected a color in the '${r}' format (e.g. '${Bn[r]}'), got '${t}'. Did you mean '${s}'?`,value:t})}!((a=this.options)!=null&&a.alpha)&&i.a<1&&n.push({message:`Color '${t}' has an alpha channel, but alpha is not enabled. Use s.color({ alpha: true }) to allow transparency`,value:t})}return n.length>0&&V({},e,n)}},{key:`executeAssert`,value:function(e,t){return this.opt&&t===null?{success:!0,data:t}:t===null?{success:!1,errors:V({},e,[{message:`Expected 'string', got 'null'`,typeError:!0}])}:typeof t==`string`?{success:!0,data:t}:{success:!1,errors:V({},e,[{message:`Expected 'string', got '${B(t)}'`,typeError:!0}])}}},{key:`nullable`,value:function(){return new t(this.options,!0,[],this.isReadonly,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`readonly`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,!0,this.isHidden,this.description,this.renderInput,this.previewInput)}},{key:`hidden`,value:function(){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,!0,this.description,this.renderInput,this.previewInput)}},{key:`render`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,e,this.previewInput)}},{key:`preview`,value:function(e){return new t(this.options,this.opt,this.customValidateFunctions,this.isReadonly,this.isHidden,this.description,this.renderInput,e)}},{key:`executePreviewItem`,value:function(e){return this.previewInput===null?null:this.previewInput({val:e})}},{key:`declaresItemPreview`,value:function(){return this.previewInput!==null}},{key:`executeSerialize`,value:function(){return{type:`color`,render:this.renderInput??void 0,preview:this.previewInput?!0:void 0,opt:this.opt,options:this.options,customValidate:this.customValidateFunctions&&this.customValidateFunctions?.length>0,readonly:this.isReadonly,hidden:this.isHidden,description:this.description}}},{key:`executePreview`,value:function(){return{}}}])}(Le),Hn=function(e){return new Vn(e)};function Un(e,t,n){return n?new Nt(n,!1,[],e,t):new Nt(t,!1,[],e,Ye())}var Wn=function(e){var t=e.directory,n=e.alt??Ye().nullable();return new Nt(new Xe({width:new Qt(void 0,!1),height:new Qt(void 0,!1),mimeType:new Je({},!1),alt:n},!1),!1,[],null,null,{type:`images`,accept:e.accept??`image/*`,directory:t,remote:e.remote??!1,altSchema:n,encode:e.encode})};function Gn(){return{string:Ye,boolean:tn,array:$e,object:Ze,number:$t,union:rt,richtext:Ct,image:yt,literal:tt,keyOf:rn,record:Pt,file:on,files:sn,date:ln,datetime:dn,color:Hn,code:mn,route:xt,router:Un,images:Wn}}var Kn=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],qn=function(e){return e[e.inputBytes=64]=`inputBytes`,e[e.inputWords=16]=`inputWords`,e[e.highIndex=14]=`highIndex`,e[e.lowIndex=15]=`lowIndex`,e[e.workWords=64]=`workWords`,e[e.allocBytes=80]=`allocBytes`,e[e.allocWords=20]=`allocWords`,e[e.allocTotal=8e3]=`allocTotal`,e}(qn||{}),Jn={sha256:1};function Yn(e){if(e&&!Jn[e]&&!Jn[e.toLowerCase()])throw Error(`Digest method not supported`);return new Xn}var Xn=function(){function e(){De(this,e),V(this,`A`,1779033703),V(this,`B`,-1150833019),V(this,`C`,1013904242),V(this,`D`,-1521486534),V(this,`E`,1359893119),V(this,`F`,-1694144372),V(this,`G`,528734635),V(this,`H`,1541459225),V(this,`_size`,0),V(this,`_sp`,0),(!Qn||$n>=qn.allocTotal)&&(Qn=new ArrayBuffer(qn.allocTotal),$n=0),this._byte=new Uint8Array(Qn,$n,qn.allocBytes),this._word=new Int32Array(Qn,$n,qn.allocWords),$n+=qn.allocBytes}return ke(e,[{key:`update`,value:function(e){if(typeof e==`string`)return this._utf8(e);if(e==null)throw TypeError(`Invalid type: `+B(e));var t=e.byteOffset,n=e.byteLength,r=n/qn.inputBytes|0,i=0;if(r&&!(t&3)&&!(this._size%qn.inputBytes)){for(var a=new Int32Array(e.buffer,t,r*qn.inputWords);r--;)this._int32(a,i>>2),i+=qn.inputBytes;this._size+=i}if(e.BYTES_PER_ELEMENT!==1&&e.buffer){var o=new Uint8Array(e.buffer,t+i,n-i);return this._uint8(o)}return i===n?this:this._uint8(e,i)}},{key:`_uint8`,value:function(e,t){var n=this._byte,r=this._word,i=e.length;for(t|=0;t<i;){for(var a=this._size%qn.inputBytes,o=a;t<i&&o<qn.inputBytes;)n[o++]=e[t++];o>=qn.inputBytes&&this._int32(r),this._size+=o-a}return this}},{key:`_utf8`,value:function(e){for(var t=this._byte,n=this._word,r=e.length,i=this._sp,a=0;a<r;){for(var o=this._size%qn.inputBytes,s=o;a<r&&s<qn.inputBytes;){var c=e.charCodeAt(a++)|0;c<128?t[s++]=c:c<2048?(t[s++]=192|c>>>6,t[s++]=128|c&63):c<55296||c>57343?(t[s++]=224|c>>>12,t[s++]=128|c>>>6&63,t[s++]=128|c&63):i?(c=((i&1023)<<10)+(c&1023)+65536,t[s++]=240|c>>>18,t[s++]=128|c>>>12&63,t[s++]=128|c>>>6&63,t[s++]=128|c&63,i=0):i=c}s>=qn.inputBytes&&(this._int32(n),n[0]=n[qn.inputWords]),this._size+=s-o}return this._sp=i,this}},{key:`_int32`,value:function(e,t){var n=this.A,r=this.B,i=this.C,a=this.D,o=this.E,s=this.F,c=this.G,l=this.H,u=0;for(t|=0;u<qn.inputWords;)Zn[u++]=tr(e[t++]);for(u=qn.inputWords;u<qn.workWords;u++)Zn[u]=sr(Zn[u-2])+Zn[u-7]+or(Zn[u-15])+Zn[u-16]|0;for(u=0;u<qn.workWords;u++){var d=l+ar(o)+nr(o,s,c)+Kn[u]+Zn[u]|0,f=ir(n)+rr(n,r,i)|0;l=c,c=s,s=o,o=a+d|0,a=i,i=r,r=n,n=d+f|0}this.A=n+this.A|0,this.B=r+this.B|0,this.C=i+this.C|0,this.D=a+this.D|0,this.E=o+this.E|0,this.F=s+this.F|0,this.G=c+this.G|0,this.H=l+this.H|0}},{key:`digest`,value:function(e){var t=this._byte,n=this._word,r=this._size%qn.inputBytes|0;for(t[r++]=128;r&3;)t[r++]=0;if(r>>=2,r>qn.highIndex){for(;r<qn.inputWords;)n[r++]=0;r=0,this._int32(n)}for(;r<qn.inputWords;)n[r++]=0;var i=this._size*8,a=(i&4294967295)>>>0,o=(i-a)/4294967296;return o&&(n[qn.highIndex]=tr(o)),a&&(n[qn.lowIndex]=tr(a)),this._int32(n),e===`hex`?this._hex():this._bin()}},{key:`_hex`,value:function(){var e=this.A,t=this.B,n=this.C,r=this.D,i=this.E,a=this.F,o=this.G,s=this.H;return er(e)+er(t)+er(n)+er(r)+er(i)+er(a)+er(o)+er(s)}},{key:`_bin`,value:function(){var e=this.A,t=this.B,n=this.C,r=this.D,i=this.E,a=this.F,o=this.G,s=this.H,c=this._byte,l=this._word;return l[0]=tr(e),l[1]=tr(t),l[2]=tr(n),l[3]=tr(r),l[4]=tr(i),l[5]=tr(a),l[6]=tr(o),l[7]=tr(s),c.slice(0,32)}}])}(),Zn=new Int32Array(qn.workWords),Qn,$n=0,er=function(e){return(e+4294967296).toString(16).substr(-8)},tr=cr()?function(e){return e}:function(e){return e<<24&4278190080|e<<8&16711680|e>>8&65280|e>>24&255},nr=function(e,t,n){return n^e&(t^n)},rr=function(e,t,n){return e&t|n&(e|t)},ir=function(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)},ar=function(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)},or=function(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3},sr=function(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10};function cr(){return new Uint8Array(new Uint16Array([65279]).buffer)[0]===254}var lr=function(e){return Yn().update(e).digest(`hex`)};function ur(e){if(e.type===`file`||e.type===`image`)return!!e.remote;if(e.type===`richtext`)return B(e.options?.img)===`object`&&ur(e.options.img);if(e.type===`array`)return ur(e.item);if(e.type===`record`)return e.mediaType&&e.remote?!0:ur(e.item);if(e.type===`object`){for(var t in e.items)if(ur(e.items[t]))return!0;return!1}if(e.type===`union`){var n=B(e.key)===`object`&&e.key.type===`literal`?e:void 0,r=typeof e.key==`string`?e:void 0;if(n)return!1;if(r){var i=w(r.items),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;if(ur(o))return!0}}catch(e){i.e(e)}finally{i.f()}}return!1}if(e.type===`boolean`||e.type===`number`||e.type===`string`||e.type===`literal`||e.type===`date`||e.type===`dateTime`||e.type===`color`||e.type===`code`||e.type===`keyOf`||e.type===`route`)return!1;throw Error(`Unexpected schema: ${JSON.stringify(e)}`)}var dr=`https://remote.val.build`,fr=ke(function e(t){De(this,e),this.message=t});function pr(e,t){var n=t.publicProjectId,r=t.coreVersion,i=t.validationHash,a=t.fileHash,o=t.filePath;return`${e}/file/p/${n}/b/${t.bucket}/v/${r}/h/${i}/f/${a}/p/${o}`}function mr(e,t,n,r,i){var a=`${r?.width||``}${r?.height||``}${r?.mimeType}`,o=qe({},t.options);delete o.encode;var s={type:t.type,opt:t.opt,options:o};return e+JSON.stringify(s)+n+a+i}function hr(e,t,n,r,i,a){return lr(a.encode(mr(e,t,n,r,i))).slice(0,4)}function gr(e){return e.slice(0,12)}function _r(e){return gr(lr(new Uint8Array(e)))}function vr(e){var t=yr(e);return e.readonly&&(t=t.readonly()),e.hidden&&(t=t.hidden()),t}function yr(e){var t;switch(e.type){case`string`:return new Je(qe(qe({},e.options),{},{regexp:e.options?.regexp&&new RegExp(e.options.regexp.source,e.options.regexp.flags),regExpMessage:(t=e.options)==null||(t=t.regexp)==null?void 0:t.message}),e.opt,e.raw,[],e.render??null,!1,!1,e.description,null,e.multiline??!1);case`literal`:return new et(e.value,e.opt,[],!1,!1,e.description,e.render??null);case`boolean`:return new en(e.opt,[],!1,!1,e.description,e.render??null);case`number`:return new Qt(e.options,e.opt,[],!1,!1,e.description,e.render??null);case`object`:return new Xe(Object.fromEntries(Object.entries(e.items).map(function(e){var t=xe(e,2),n=t[0],r=t[1];return[n,vr(r)]})),e.opt,[],!1,!1,e.description,e.render??null);case`array`:return new Qe(vr(e.item),e.opt,[],!1,!1,e.description,null,e.render??null);case`union`:return new nt(typeof e.key==`string`?e.key:vr(e.key),e.items.map(vr),e.opt,[],!1,!1,e.description,e.render??null);case`richtext`:return new St(qe(qe({},e.options||{}),{},{a:B(e.options?.a)===`object`?vr(e.options.a):e.options?.a,img:B(e.options?.img)===`object`?vr(e.options.img):e.options?.img}),e.opt,[],!1,!1,e.description,e.render??null);case`record`:return new Nt(vr(e.item),e.opt,[],null,e.key?vr(e.key):null,e.mediaType?{type:e.mediaType,accept:e.accept??`*/*`,directory:e.directory??`/public/val`,remote:e.remote??!1,altSchema:e.alt?vr(e.alt):void 0}:void 0,!1,!1,e.description,e.jsonValues??!1,null,e.render??null);case`keyOf`:return new nn(e.schema,e.path,e.opt,[],!1,!1,e.description,e.render??null);case`route`:return new bt(e.options?{include:e.options.include?new RegExp(e.options.include.source,e.options.include.flags):void 0,exclude:e.options.exclude?new RegExp(e.options.exclude.source,e.options.exclude.flags):void 0}:void 0,e.opt,[],!1,!1,e.description,e.render??null);case`file`:return new an(e.options,e.opt,e.remote,[],{},!1,!1,e.description,e.render??null);case`image`:return new vt(e.options,e.opt,e.remote,[],{},!1,!1,e.description,e.render??null);case`date`:return new cn(e.options,e.opt,[],!1,!1,e.description,e.render??null);case`dateTime`:return new un(e.options,e.opt,[],!1,!1,e.description,e.render??null);case`color`:return new Vn(e.options,e.opt,[],!1,!1,e.description,e.render??null);case`code`:return new pn(e.options,e.opt,[],!1,!1,e.description,e.render??null);default:var n=e;throw n&&B(n)===`object`&&`type`in n?Error(`Unknown schema type: ${n.type}`):Error(`Unknown schema: ${JSON.stringify(n,null,2)}`)}}function br(e){var t=e.map(function(e){var t=xe(Lt(e),2),n=t[0],r=t[1];return{moduleFilePath:n,segments:r===``?[]:Jt(r)}}),n=function(e){var t=xe(Lt(e),2),n=t[0],r=t[1];return{moduleFilePath:n,segments:r===``?[]:Jt(r)}},r=function(e,t){if(e.length>t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0};return{wants:function(e){var i=n(e);return t.some(function(e){return e.moduleFilePath===i.moduleFilePath&&e.segments.length===i.segments.length&&r(e.segments,i.segments)})},wantsUnder:function(e){var i=n(e);return t.some(function(e){return e.moduleFilePath===i.moduleFilePath&&(r(i.segments,e.segments)||r(e.segments,i.segments))})}}}function xr(e){return e.render?.as===`inline`||e.type===`union`&&e.items.some(function(e){return e.render?.as===`inline`})}var Sr={getRouterId:function(){return`external-url-router`},validate:function(e,t){var n=[],r=w(t),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;a.startsWith(`https://`)||a.startsWith(`http://`)||n.push({error:{message:`URL path "${a}" does not start with "https://" or "http://"`,expectedPath:null,urlPath:a}})}}catch(e){r.e(e)}finally{r.f()}return[]}};function Cr(e,t){var n=e.startsWith(`/`)?e.slice(1).split(`/`):e.split(`/`);if(t.length===0)return{isValid:n.length===0||n.length===1&&n[0]===``,expectedPath:`/`};for(var r=0,i=0,a=!1,o=-1,s=0;s<t.length;s++){var c=t[s];c.startsWith(`[[`)&&c.endsWith(`]]`)?(a=!0,o=s,i=1/0):c.startsWith(`[...`)&&c.endsWith(`]`)?(a=!0,o=s,r++,i=1/0):c.startsWith(`[[`)&&c.endsWith(`]`)?i++:(c.startsWith(`[`)&&c.endsWith(`]`),r++,i++)}if(n.length<r||!a&&n.length>i)return{isValid:!1,expectedPath:`/${t.map(function(e){return e.startsWith(`[[`)&&e.endsWith(`]]`)?`[optional:${e.slice(2,-2)}]`:e.startsWith(`[...`)&&e.endsWith(`]`)?`[...${e.slice(4,-1)}]`:e.startsWith(`[[`)&&e.endsWith(`]`)?`[optional:${e.slice(2,-1)}]`:e.startsWith(`[`)&&e.endsWith(`]`)?`[${e.slice(1,-1)}]`:e}).join(`/`)}`};for(var l=a?o:t.length,u=0;u<l;u++){var d=t[u],f=n[u];if(d.startsWith(`[[`)&&d.endsWith(`]]`)){if(f!==``&&f!==void 0&&f===``)return{isValid:!1,expectedPath:`/${t.join(`/`)}`}}else if(d.startsWith(`[`)&&d.endsWith(`]`)){if(f===``||f===void 0)return{isValid:!1,expectedPath:`/${t.join(`/`)}`}}else if(d!==f)return{isValid:!1,expectedPath:`/${t.join(`/`)}`}}return{isValid:!0}}var wr={getRouterId:function(){return`next-app-router`},validate:function(e,t){var n=Tr(e),r=[],i=w(t),a;try{for(i.s();!(a=i.n()).done;){var o=a.value,s=Cr(o,n);s.isValid||r.push({error:{message:`URL path "${o}" does not match the route pattern for "${e}"`,urlPath:o,expectedPath:s.expectedPath||null}})}}catch(e){i.e(e)}finally{i.f()}return r}};function Tr(e){if(!e||typeof e!=`string`)return[];for(var t=[/\/app\/(.+)\/page\.val\.ts$/,/\/src\/app\/(.+)\/page\.val\.ts$/,/\/app\/(.+)\/page\.tsx?$/,/\/src\/app\/(.+)\/page\.tsx?$/],n=0,r=t;n<r.length;n++){var i=r[n],a=e.match(i);if(a)return a[1].split(`/`).flatMap(function(e){if(e.startsWith(`(`)&&e.endsWith(`)`)&&!e.includes(`.`))return[];var t=e.match(/^(\([.]+\)(\(.+\))?)(.*)$/);if(t){var n=t[3]||t[4];return n?[n]:[]}return[e]})}return[]}function Er(e,t){for(var n=0,r=Object.entries(t);n<r.length;n++){var i=xe(r[n],2),a=i[0],o=i[1];if(o.type===`record`&&o.router===`next-app-router`&&Cr(e,Tr(a)).isValid)return{moduleFilePath:a,sourcePath:`${a}?p=${JSON.stringify(e)}`,route:e}}return null}var Dr=`https://content.val.build`,Or=`https://admin.val.build`,H={VERSION:{core:function(){try{return(_e(),d(ne).default).version}catch{return null}}()},mediaUrl:st,resolveMedia:ct,isRemoteMediaPath:ot,media:{fillFromGallery:ut},getSchema:Ve,getValPath:Ue,getSource:Ft,isValModule:It,resolvePath:Gt,safeResolvePath:Kt,splitModuleFilePathAndModulePath:Lt,joinModuleFilePathAndModulePath:Rt,nextAppRouter:wr,externalPageRouter:Sr,color:{parseColor:On,formatColor:Ln,convertColor:Rn,detectColorFormat:hn,colorToHex:zn},remote:{createRemoteRef:pr,getValidationBasis:mr,getValidationHash:hr,getFileHash:_r,hashToRemoteFileHash:gr,splitRemoteRef:at},validate:function(e,t,n){return e&&Ve(e)?.executeValidate(t,n)},isVal:He,isJson:kt,getJsonImport:At,resolveJsonValues:jt,createValPathOfItem:We,getSHA256Hash:lr,initSchema:Gn,getMimeType:mt,mimeTypeToFileExt:ht,filenameToMimeType:gt,mimeTypeMatchesAccept:_t,EXT_TO_MIME_TYPES:dt,MIME_TYPES_TO_EXT:ft,ModuleFilePathSep:`?p=`,notFileOp:function(e){return e.op!==`file`},isFileOp:function(e){return e.op===`file`&&typeof e.filePath==`string`},createPatchJSONPath:function(e){return`/${e.split(`.`).map(function(e){return e&&kr(e)}).join(`/`)}`},createPatchPath:function(e){return Jt(e)},splitModulePath:Jt,splitModuleFilePath:qt,splitJoinedSourcePaths:Yt,parentOfSourcePath:Xt,patchPathToModulePath:Zt,VAL_ENABLE_COOKIE_NAME:`val_enable`,VAL_STATE_COOKIE:`val_state`,VAL_SESSION_COOKIE:`val_session`,createFilename:function(e,t,n,r){if(!n||!e)return t;var i=r.slice(0,5),a=H.getMimeType(e)??`unknown`,o=H.mimeTypeToFileExt(a)??`unknown`;if(t){var s=t.split(`.`).slice(0,-1).join(`.`)||t,c=s.lastIndexOf(`_`);return s.slice(c+1,s.length)===i&&(s=s.slice(0,c)),`${encodeURIComponent(s).replace(/%[0-9A-Fa-f]{2}/g,``).toLowerCase()}_${i}.${o}`}return`${r}.${o}`}};function kr(e){try{return JSON.parse(e)}catch{return e}}function Ar(e){for(var t=e,n=[...arguments].slice(1),r=0,i=n;r<i.length;r++){var a=i[r];t=a(t)}return t}function jr(e){return T(e)}function Mr(e,t){if(e===t)return!0;if(B(e)===`object`&&B(t)===`object`&&e!==null&&t!==null){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(!Mr(e[n],t[n]))return!1;return!0}if(!Array.isArray(e)&&!Array.isArray(t)){var r=Object.entries(e);if(r.length!==Object.keys(t).length)return!1;for(var i=0,a=r;i<a.length;i++){var o=xe(a[i],2),s=o[0],c=o[1],l=t[s];if(l===void 0||!Mr(c,l))return!1}return!0}}return!1}function Nr(e){return Array.isArray(e)?e.map(Nr):B(e)===`object`&&e!==null?Object.fromEntries(Object.entries(e).map(function(e){var t=xe(e,2),n=t[0],r=t[1];return[n,Nr(r)]})):e}function Pr(e){return/^(0|[1-9][0-9]*)$/g.test(e)?D(Number(e)):O(new fr(`Invalid array index "${e}"`))}function Fr(e,t){return e===`-`?D(t.length):Ar(Pr(e),ee(function(e){return e<=t.length},function(){return new fr(`Array index out of bounds`)}))}function Ir(e,t){return Ar(Pr(e),ee(function(e){return e<t.length},function(){return new fr(`Array index out of bounds`)}))}function Lr(e,t,n){if(Array.isArray(e))return Ar(Ir(t,e),F(function(t){var r=e[t];return e[t]=n,r}));if(B(e)===`object`&&e!==null){if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];return e[t]=n,D(r)}return O(new fr(`Cannot replace object element which does not exist`))}return O(new fr(`Cannot replace in non-object/array`))}function Rr(e,t,n){return jr(t)?Ar(Br(e,t),I(function(e){var t=xe(e,2),r=t[0],i=t[1];return Lr(r,i,n)}),F(function(t){return[e,t]})):D([n,e])}function zr(e,t){return Array.isArray(e)?Ar(Pr(t),I(function(t){return t>=e.length?O(new fr(`Array index out of bounds`)):D(e[t])})):B(e)===`object`&&e!==null?Object.prototype.hasOwnProperty.call(e,t)?D(e[t]):D(void 0):O(new fr(`Cannot access non-object/array`))}function Br(e,t){for(var n=e,r=t[0],i=0;i<t.length-1;++i,r=t[i]){var a=zr(n,r);if(A(a))return a;if(a.value===void 0)return O(new fr(`Path refers to non-existing object/array`));n=a.value}return D([n,r])}function Vr(e,t){return Ar(t,P(function(e,t){return Ar(zr(e,t),ee(function(e){return e!==void 0},function(){return new fr(`Path refers to non-existing object/array`)}))},e))}function Hr(e,t){if(Array.isArray(e))return Ar(Ir(t,e),F(function(t){return xe(e.splice(t,1),1)[0]}));if(B(e)===`object`&&e!==null&&Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];return delete e[t],D(n)}return O(new fr(`Cannot remove from non-object/array`))}function Ur(e,t){return Ar(Br(e,t),I(function(e){var t=xe(e,2),n=t[0],r=t[1];return Hr(n,r)}))}function Wr(e,t,n){if(Array.isArray(e))return Ar(Fr(t,e),F(function(t){e.splice(t,0,n)}));if(B(e)===`object`&&e!==null){var r;return Object.prototype.hasOwnProperty.call(e,t)&&(r=e[t]),e[t]=n,D(r)}return O(new fr(`Cannot add to non-object/array`))}function Gr(e,t,n){return jr(t)?Ar(Br(e,t),I(function(e){var t=xe(e,2),r=t[0],i=t[1];return Wr(r,i,n)}),F(function(t){return[e,t]})):D([n,e])}function Kr(e){return xe(e,1)[0]}var qr=function(){function e(){De(this,e)}return ke(e,[{key:`get`,value:function(e,t){return Vr(e,t)}},{key:`add`,value:function(e,t,n){return Ar(Gr(e,t,n),F(Kr))}},{key:`remove`,value:function(e,t){return Ar(Ur(e,t),F(function(){return e}))}},{key:`replace`,value:function(e,t,n){return Ar(Rr(e,t,n),F(Kr))}},{key:`move`,value:function(e,t,n){return Ar(Ur(e,t),I(function(t){return Gr(e,n,t)}),F(Kr))}},{key:`copy`,value:function(e,t,n){return Ar(Vr(e,t),I(function(t){return Gr(e,n,Nr(t))}),F(Kr))}},{key:`test`,value:function(e,t,n){return Ar(Vr(e,t),F(function(e){return Mr(n,e)}))}}])}();function Jr(e,t,n){switch(n.op){case`add`:return t.add(e,n.path,n.value);case`remove`:return t.remove(e,n.path);case`replace`:return t.replace(e,n.path,n.value);case`move`:return t.move(e,n.from,n.path);case`copy`:return t.copy(e,n.from,n.path);case`test`:return t.test(e,n.path,n.value)?D(e):O(new fr(`Test failed`));case`file`:return O(new fr(`Cannot apply a file patch here`))}}function Yr(e,t,n){return Ar(n,P(function(e,n){return Jr(e,t,n)},e))}function Xr(e){for(var t=e.split(`,`)[1],n=atob(t),r=new Uint8Array(n.length),i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r}var Zr;function U(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Qr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},$r=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Zr=globalThis).__zod_globalConfig??(Zr.__zod_globalConfig={});var ei=globalThis.__zod_globalConfig;function ti(e){return e&&Object.assign(ei,e),ei}function ni(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ri(e,t){return typeof t==`bigint`?t.toString():t}function ii(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ai(e){return e==null}function oi(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function si(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var ci=Symbol(`evaluating`);function li(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ci)return r===void 0&&(r=ci,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ui(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function di(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function fi(e){return JSON.stringify(e)}function pi(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var mi=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function hi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var gi=ii(()=>{if(ei.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function _i(e){if(hi(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return hi(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function vi(e){return _i(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var yi=new Set([`string`,`number`,`symbol`]);function bi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function xi(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Si(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ci(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var wi={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ti(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return xi(e,di(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return ui(this,`shape`,e),e},checks:[]}))}function Ei(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return xi(e,di(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return ui(this,`shape`,r),r},checks:[]}))}function Di(e,t){if(!_i(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return xi(e,di(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ui(this,`shape`,n),n}}))}function Oi(e,t){if(!_i(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return xi(e,di(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ui(this,`shape`,n),n}}))}function ki(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return xi(e,di(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ui(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ai(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return xi(t,di(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return ui(this,`shape`,i),i},checks:[]}))}function ji(e,t,n){return xi(t,di(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return ui(this,`shape`,i),i}}))}function Mi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ni(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Pi(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Fi(e){return typeof e==`string`?e:e?.message}function Ii(e,t,n){let r=e.message?e.message:Fi(e.inst?._zod.def?.error?.(e))??Fi(t?.error?.(e))??Fi(n.customError?.(e))??Fi(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Li(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ri(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var zi=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ri,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Bi=U(`$ZodError`,zi),Vi=U(`$ZodError`,zi,{Parent:Error});function Hi(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ui(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function Wi(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Gi(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Wi(e.path)}`);return t.join(`
|
|
13
13
|
`)}var Ki=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Qr;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Ii(e,a,ti())));throw mi(t,i?.callee),t}return o.value},qi=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Ii(e,a,ti())));throw mi(t,i?.callee),t}return o.value},Ji=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Qr;return a.issues.length?{success:!1,error:new(e??Bi)(a.issues.map(e=>Ii(e,i,ti())))}:{success:!0,data:a.value}},Yi=Ji(Vi),Xi=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Ii(e,i,ti())))}:{success:!0,data:a.value}},Zi=Xi(Vi),Qi=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ki(e)(t,n,i)},$i=e=>(t,n,r)=>Ki(e)(t,n,r),ea=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return qi(e)(t,n,i)},ta=e=>async(t,n,r)=>qi(e)(t,n,r),na=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ji(e)(t,n,i)},ra=e=>(t,n,r)=>Ji(e)(t,n,r),ia=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Xi(e)(t,n,i)},aa=e=>async(t,n,r)=>Xi(e)(t,n,r),oa=/^[cC][0-9a-z]{6,}$/,sa=/^[0-9a-z]+$/,ca=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,la=/^[0-9a-vA-V]{20}$/,ua=/^[A-Za-z0-9]{27}$/,da=/^[a-zA-Z0-9_-]{21}$/,fa=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,pa=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ma=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ha=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ga=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function _a(){return new RegExp(ga,`u`)}var va=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ya=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ba=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,xa=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Sa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ca=/^[A-Za-z0-9_-]*$/,wa=/^https?$/,Ta=/^\+[1-9]\d{6,14}$/,Ea=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Da=RegExp(`^${Ea}$`);function Oa(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ka(e){return RegExp(`^${Oa(e)}$`)}function Aa(e){let t=Oa({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Ea}T(?:${r})$`)}var ja=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Ma=/^-?\d+$/,Na=/^-?\d+(?:\.\d+)?$/,Pa=/^(?:true|false)$/i,Fa=/^null$/i,Ia=/^[^A-Z]*$/,La=/^[^a-z]*$/,Ra=U(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),za={number:`number`,bigint:`bigint`,object:`date`},Ba=U(`$ZodCheckLessThan`,(e,t)=>{Ra.init(e,t);let n=za[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Va=U(`$ZodCheckGreaterThan`,(e,t)=>{Ra.init(e,t);let n=za[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ha=U(`$ZodCheckMultipleOf`,(e,t)=>{Ra.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):si(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ua=U(`$ZodCheckNumberFormat`,(e,t)=>{Ra.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=wi[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Ma)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Wa=U(`$ZodCheckMaxLength`,(e,t)=>{var n;Ra.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ai(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Li(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ga=U(`$ZodCheckMinLength`,(e,t)=>{var n;Ra.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ai(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Li(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ka=U(`$ZodCheckLengthEquals`,(e,t)=>{var n;Ra.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ai(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Li(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),qa=U(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Ra.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ja=U(`$ZodCheckRegex`,(e,t)=>{qa.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ya=U(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Ia,qa.init(e,t)}),Xa=U(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=La,qa.init(e,t)}),Za=U(`$ZodCheckIncludes`,(e,t)=>{Ra.init(e,t);let n=bi(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Qa=U(`$ZodCheckStartsWith`,(e,t)=>{Ra.init(e,t);let n=RegExp(`^${bi(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$a=U(`$ZodCheckEndsWith`,(e,t)=>{Ra.init(e,t);let n=RegExp(`.*${bi(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),eo=U(`$ZodCheckOverwrite`,(e,t)=>{Ra.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),to=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
14
14
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
15
15
|
`))}},no={major:4,minor:4,patch:3},ro=U(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=no;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Mi(e),i;for(let a of t){if(a._zod.def.when){if(Ni(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Qr;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Mi(e,t))});else{if(e.issues.length===t)continue;r||=Mi(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Mi(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Qr;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Qr;return o.then(e=>t(e,r,a))}return t(o,r,a)}}li(e,`~standard`,()=>({validate:t=>{try{let n=Yi(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Zi(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),io=U(`$ZodString`,(e,t)=>{ro.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ja(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),ao=U(`$ZodStringFormat`,(e,t)=>{qa.init(e,t),io.init(e,t)}),oo=U(`$ZodGUID`,(e,t)=>{t.pattern??=pa,ao.init(e,t)}),so=U(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=ma(e)}else t.pattern??=ma();ao.init(e,t)}),co=U(`$ZodEmail`,(e,t)=>{t.pattern??=ha,ao.init(e,t)}),lo=U(`$ZodURL`,(e,t)=>{ao.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===wa.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),uo=U(`$ZodEmoji`,(e,t)=>{t.pattern??=_a(),ao.init(e,t)}),fo=U(`$ZodNanoID`,(e,t)=>{t.pattern??=da,ao.init(e,t)}),po=U(`$ZodCUID`,(e,t)=>{t.pattern??=oa,ao.init(e,t)}),mo=U(`$ZodCUID2`,(e,t)=>{t.pattern??=sa,ao.init(e,t)}),ho=U(`$ZodULID`,(e,t)=>{t.pattern??=ca,ao.init(e,t)}),go=U(`$ZodXID`,(e,t)=>{t.pattern??=la,ao.init(e,t)}),_o=U(`$ZodKSUID`,(e,t)=>{t.pattern??=ua,ao.init(e,t)}),vo=U(`$ZodISODateTime`,(e,t)=>{t.pattern??=Aa(t),ao.init(e,t)}),yo=U(`$ZodISODate`,(e,t)=>{t.pattern??=Da,ao.init(e,t)}),bo=U(`$ZodISOTime`,(e,t)=>{t.pattern??=ka(t),ao.init(e,t)}),xo=U(`$ZodISODuration`,(e,t)=>{t.pattern??=fa,ao.init(e,t)}),So=U(`$ZodIPv4`,(e,t)=>{t.pattern??=va,ao.init(e,t),e._zod.bag.format=`ipv4`}),Co=U(`$ZodIPv6`,(e,t)=>{t.pattern??=ya,ao.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),tee=U(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ba,ao.init(e,t)}),wo=U(`$ZodCIDRv6`,(e,t)=>{t.pattern??=xa,ao.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function To(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Eo=U(`$ZodBase64`,(e,t)=>{t.pattern??=Sa,ao.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{To(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Do(e){if(!Ca.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return To(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Oo=U(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ca,ao.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Do(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ko=U(`$ZodE164`,(e,t)=>{t.pattern??=Ta,ao.init(e,t)});function Ao(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var jo=U(`$ZodJWT`,(e,t)=>{ao.init(e,t),e._zod.check=n=>{Ao(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Mo=U(`$ZodNumber`,(e,t)=>{ro.init(e,t),e._zod.pattern=e._zod.bag.pattern??Na,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),No=U(`$ZodNumberFormat`,(e,t)=>{Ua.init(e,t),Mo.init(e,t)}),Po=U(`$ZodBoolean`,(e,t)=>{ro.init(e,t),e._zod.pattern=Pa,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Fo=U(`$ZodNull`,(e,t)=>{ro.init(e,t),e._zod.pattern=Fa,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Io=U(`$ZodAny`,(e,t)=>{ro.init(e,t),e._zod.parse=e=>e}),Lo=U(`$ZodUnknown`,(e,t)=>{ro.init(e,t),e._zod.parse=e=>e}),Ro=U(`$ZodNever`,(e,t)=>{ro.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function zo(e,t,n){e.issues.length&&t.issues.push(...Pi(n,e.issues)),t.value[n]=e.value}var Bo=U(`$ZodArray`,(e,t)=>{ro.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>zo(t,n,e))):zo(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Vo(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Pi(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Ho(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Ci(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Uo(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Vo(e,n,i,t,u,d))):Vo(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Wo=U(`$ZodObject`,(e,t)=>{if(ro.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=ii(()=>Ho(t));li(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=hi,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Vo(n,t,e,s,r,i))):Vo(a,t,e,s,r,i)}return i?Uo(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Go=U(`$ZodObjectJIT`,(e,t)=>{Wo.init(e,t);let n=e._zod.parse,r=ii(()=>Ho(t)),i=e=>{let t=new to([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=fi(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=fi(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
@@ -74,12 +74,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
74
74
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=hi,s=!ei.jitless,c=s&&gi.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Uo([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Ko(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Mi(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Ii(e,r,ti())))}),t)}var qo=U(`$ZodUnion`,(e,t)=>{ro.init(e,t),li(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),li(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),li(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),li(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>oi(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Ko(t,r,e,i)):Ko(o,r,e,i)}}),Jo=U(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,qo.init(e,t);let n=e._zod.parse;li(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=ii(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!hi(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Yo=U(`$ZodIntersection`,(e,t)=>{ro.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Zo(e,t,n)):Zo(e,i,a)}});function Xo(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(_i(e)&&_i(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Xo(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Xo(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Zo(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Mi(e))return e;let o=Xo(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Qo=U(`$ZodTuple`,(e,t)=>{ro.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=$o(n,`optin`),c=$o(n,`optout`);if(!t.rest){if(a.length<s)return r.issues.push({code:`too_small`,minimum:s,inclusive:!0,input:a,inst:e,origin:`array`}),r;a.length>n.length&&r.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:a,inst:e,origin:`array`})}let l=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:a[e],issues:[]},i);t instanceof Promise?o.push(t.then(t=>{l[e]=t})):l[e]=t}if(t.rest){let e=n.length-1,s=a.slice(n.length);for(let n of s){e++;let a=t.rest._zod.run({value:n,issues:[]},i);a instanceof Promise?o.push(a.then(t=>es(t,r,e))):es(a,r,e)}}return o.length?Promise.all(o).then(()=>ts(l,r,n,a,c)):ts(l,r,n,a,c)}});function $o(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function es(e,t,n){e.issues.length&&t.issues.push(...Pi(n,e.issues)),t.value[n]=e.value}function ts(e,t,n,r,i){for(let a=0;a<n.length;a++){let n=e[a],o=a<r.length;if(n.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...Pi(a,n.issues))}t.value[a]=n.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}var ns=U(`$ZodRecord`,(e,t)=>{ro.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!_i(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Ii(e,r,ti())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Pi(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Pi(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Na.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Ii(e,r,ti())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Pi(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Pi(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),rs=U(`$ZodEnum`,(e,t)=>{ro.init(e,t);let n=ni(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>yi.has(typeof e)).map(e=>typeof e==`string`?bi(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),is=U(`$ZodLiteral`,(e,t)=>{if(ro.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?bi(e):e?bi(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),as=U(`$ZodTransform`,(e,t)=>{ro.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $r(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Qr;return n.value=i,n.fallback=!0,n}});function ss(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var cs=U(`$ZodOptional`,(e,t)=>{ro.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,li(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),li(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${oi(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>ss(e,r)):ss(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ls=U(`$ZodExactOptional`,(e,t)=>{cs.init(e,t),li(e._zod,`values`,()=>t.innerType._zod.values),li(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),us=U(`$ZodNullable`,(e,t)=>{ro.init(e,t),li(e._zod,`optin`,()=>t.innerType._zod.optin),li(e._zod,`optout`,()=>t.innerType._zod.optout),li(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${oi(e.source)}|null)$`):void 0}),li(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ds=U(`$ZodDefault`,(e,t)=>{ro.init(e,t),e._zod.optin=`optional`,li(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>fs(e,t)):fs(r,t)}});function fs(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ps=U(`$ZodPrefault`,(e,t)=>{ro.init(e,t),e._zod.optin=`optional`,li(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),ms=U(`$ZodNonOptional`,(e,t)=>{ro.init(e,t),li(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>hs(t,e)):hs(i,e)}});function hs(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var gs=U(`$ZodCatch`,(e,t)=>{ro.init(e,t),e._zod.optin=`optional`,li(e._zod,`optout`,()=>t.innerType._zod.optout),li(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ii(e,n,ti()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ii(e,n,ti()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),_s=U(`$ZodPipe`,(e,t)=>{ro.init(e,t),li(e._zod,`values`,()=>t.in._zod.values),li(e._zod,`optin`,()=>t.in._zod.optin),li(e._zod,`optout`,()=>t.out._zod.optout),li(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>vs(e,t.in,n)):vs(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>vs(e,t.out,n)):vs(r,t.out,n)}});function vs(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var ys=U(`$ZodReadonly`,(e,t)=>{ro.init(e,t),li(e._zod,`propValues`,()=>t.innerType._zod.propValues),li(e._zod,`values`,()=>t.innerType._zod.values),li(e._zod,`optin`,()=>t.innerType?._zod?.optin),li(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(bs):bs(r)}});function bs(e){return e.value=Object.freeze(e.value),e}var xs=U(`$ZodLazy`,(e,t)=>{ro.init(e,t),li(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),li(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),li(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),li(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),li(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Ss=U(`$ZodCustom`,(e,t)=>{Ra.init(e,t),ro.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Cs(t,n,r,e));Cs(i,n,r,e)}});function Cs(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ri(e))}}var ws,Ts=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Es(){return new Ts}(ws=globalThis).__zod_globalRegistry??(ws.__zod_globalRegistry=Es());var Ds=globalThis.__zod_globalRegistry;function Os(e,t){return new e({type:`string`,...Si(t)})}function ks(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Si(t)})}function As(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Si(t)})}function js(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Si(t)})}function Ms(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Si(t)})}function Ns(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Si(t)})}function Ps(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Si(t)})}function Fs(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Si(t)})}function Is(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Si(t)})}function Ls(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Si(t)})}function Rs(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Si(t)})}function zs(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Si(t)})}function Bs(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Si(t)})}function Vs(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Si(t)})}function Hs(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Si(t)})}function Us(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Si(t)})}function Ws(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Si(t)})}function Gs(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Si(t)})}function Ks(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Si(t)})}function qs(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Si(t)})}function Js(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Si(t)})}function Ys(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Si(t)})}function Xs(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Si(t)})}function Zs(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Si(t)})}function Qs(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Si(t)})}function $s(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Si(t)})}function ec(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Si(t)})}function tc(e,t){return new e({type:`number`,checks:[],...Si(t)})}function nc(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Si(t)})}function rc(e,t){return new e({type:`boolean`,...Si(t)})}function ic(e,t){return new e({type:`null`,...Si(t)})}function ac(e){return new e({type:`any`})}function oc(e){return new e({type:`unknown`})}function sc(e,t){return new e({type:`never`,...Si(t)})}function cc(e,t){return new Ba({check:`less_than`,...Si(t),value:e,inclusive:!1})}function lc(e,t){return new Ba({check:`less_than`,...Si(t),value:e,inclusive:!0})}function uc(e,t){return new Va({check:`greater_than`,...Si(t),value:e,inclusive:!1})}function dc(e,t){return new Va({check:`greater_than`,...Si(t),value:e,inclusive:!0})}function fc(e,t){return new Ha({check:`multiple_of`,...Si(t),value:e})}function pc(e,t){return new Wa({check:`max_length`,...Si(t),maximum:e})}function mc(e,t){return new Ga({check:`min_length`,...Si(t),minimum:e})}function hc(e,t){return new Ka({check:`length_equals`,...Si(t),length:e})}function gc(e,t){return new Ja({check:`string_format`,format:`regex`,...Si(t),pattern:e})}function _c(e){return new Ya({check:`string_format`,format:`lowercase`,...Si(e)})}function vc(e){return new Xa({check:`string_format`,format:`uppercase`,...Si(e)})}function yc(e,t){return new Za({check:`string_format`,format:`includes`,...Si(t),includes:e})}function bc(e,t){return new Qa({check:`string_format`,format:`starts_with`,...Si(t),prefix:e})}function xc(e,t){return new $a({check:`string_format`,format:`ends_with`,...Si(t),suffix:e})}function Sc(e){return new eo({check:`overwrite`,tx:e})}function Cc(e){return Sc(t=>t.normalize(e))}function wc(){return Sc(e=>e.trim())}function Tc(){return Sc(e=>e.toLowerCase())}function Ec(){return Sc(e=>e.toUpperCase())}function Dc(){return Sc(e=>pi(e))}function Oc(e,t,n){return new e({type:`array`,element:t,...Si(n)})}function kc(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Si(n)})}function Ac(e,t){let n=jc(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ri(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Ri(r))}},e(t.value,t)),t);return n}function jc(e,t){let n=new Ra({check:`custom`,...Si(t)});return n._zod.check=e,n}function Mc(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Ds,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Nc(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Nc(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Ic(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Pc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
75
75
|
|
|
76
76
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Fc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Rc(t,`input`,e.processors),output:Rc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ic(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ic(r.element,n);if(r.type===`set`)return Ic(r.valueType,n);if(r.type===`lazy`)return Ic(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Ic(r.innerType,n);if(r.type===`intersection`)return Ic(r.left,n)||Ic(r.right,n);if(r.type===`record`||r.type===`map`)return Ic(r.keyType,n)||Ic(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ic(r.in,n)||Ic(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ic(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ic(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ic(e,n))return!0;return!!(r.rest&&Ic(r.rest,n))}return!1}var Lc=(e,t={})=>n=>{let r=Mc({...n,processors:t});return Nc(e,r),Pc(r,e),Fc(r,e)},Rc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Mc({...i??{},target:a,io:t,processors:n});return Nc(e,o),Pc(o,e),Fc(o,e)},zc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Bc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=zc[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Vc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Hc=(e,t,n,r)=>{n.type=`boolean`},Uc=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Wc=(e,t,n,r)=>{n.not={}},Gc=(e,t,n,r)=>{let i=e._zod.def,a=ni(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Kc=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},qc=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Jc=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Yc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Nc(a.element,t,{...r,path:[...r.path,`items`]})},Xc=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Nc(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Nc(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Zc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Nc(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Qc=(e,t,n,r)=>{let i=e._zod.def,a=Nc(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Nc(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},$c=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Nc(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Nc(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},el=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Nc(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Nc(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Nc(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},tl=(e,t,n,r)=>{let i=e._zod.def,a=Nc(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},nl=(e,t,n,r)=>{let i=e._zod.def;Nc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},rl=(e,t,n,r)=>{let i=e._zod.def;Nc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},il=(e,t,n,r)=>{let i=e._zod.def;Nc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},al=(e,t,n,r)=>{let i=e._zod.def;Nc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ol=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Nc(o,t,r);let s=t.seen.get(e);s.ref=o},sl=(e,t,n,r)=>{let i=e._zod.def;Nc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},cl=(e,t,n,r)=>{let i=e._zod.def;Nc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ll=(e,t,n,r)=>{let i=e._zod.innerType;Nc(i,t,r);let a=t.seen.get(e);a.ref=i},ul=U(`ZodISODateTime`,(e,t)=>{vo.init(e,t),Il.init(e,t)});function dl(e){return Zs(ul,e)}var fl=U(`ZodISODate`,(e,t)=>{yo.init(e,t),Il.init(e,t)});function pl(e){return Qs(fl,e)}var ml=U(`ZodISOTime`,(e,t)=>{bo.init(e,t),Il.init(e,t)});function hl(e){return $s(ml,e)}var gl=U(`ZodISODuration`,(e,t)=>{xo.init(e,t),Il.init(e,t)});function _l(e){return ec(gl,e)}var vl=U(`ZodError`,(e,t)=>{Bi.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ui(e,t)},flatten:{value:t=>Hi(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ri,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ri,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),yl=Ki(vl),bl=qi(vl),xl=Ji(vl),Sl=Xi(vl),Cl=Qi(vl),wl=$i(vl),Tl=ea(vl),El=ta(vl),Dl=na(vl),Ol=ra(vl),kl=ia(vl),Al=aa(vl),jl=new WeakMap;function Ml(e,t,n){let r=Object.getPrototypeOf(e),i=jl.get(r);if(i||(i=new Set,jl.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Nl=U(`ZodType`,(e,t)=>(ro.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Rc(e,`input`),output:Rc(e,`output`)}}),e.toJSONSchema=Lc(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>yl(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>xl(e,t,n),e.parseAsync=async(t,n)=>bl(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Sl(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Cl(e,t,n),e.decode=(t,n)=>wl(e,t,n),e.encodeAsync=async(t,n)=>Tl(e,t,n),e.decodeAsync=async(t,n)=>El(e,t,n),e.safeEncode=(t,n)=>Dl(e,t,n),e.safeDecode=(t,n)=>Ol(e,t,n),e.safeEncodeAsync=async(t,n)=>kl(e,t,n),e.safeDecodeAsync=async(t,n)=>Al(e,t,n),Ml(e,`ZodType`,{check(...e){let t=this.def;return this.clone(di(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return xi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check($u(e,t))},superRefine(e,t){return this.check(ed(e,t))},overwrite(e){return this.check(Sc(e))},optional(){return Nu(this)},exactOptional(){return Fu(this)},nullable(){return Lu(this)},nullish(){return Nu(Lu(this))},nonoptional(e){return Uu(this,e)},array(){return K(this)},or(e){return yu([this,e])},and(e){return Su(this,e)},transform(e){return qu(this,ju(e))},default(e){return zu(this,e)},prefault(e){return Vu(this,e)},catch(e){return Gu(this,e)},pipe(e){return qu(this,e)},readonly(){return Yu(this)},describe(e){let t=this.clone();return Ds.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ds.get(this);let t=this.clone();return Ds.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Ds.get(e)?.description},configurable:!0}),e)),Pl=U(`_ZodString`,(e,t)=>{io.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bc(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ml(e,`_ZodString`,{regex(...e){return this.check(gc(...e))},includes(...e){return this.check(yc(...e))},startsWith(...e){return this.check(bc(...e))},endsWith(...e){return this.check(xc(...e))},min(...e){return this.check(mc(...e))},max(...e){return this.check(pc(...e))},length(...e){return this.check(hc(...e))},nonempty(...e){return this.check(mc(1,...e))},lowercase(e){return this.check(_c(e))},uppercase(e){return this.check(vc(e))},trim(){return this.check(wc())},normalize(...e){return this.check(Cc(...e))},toLowerCase(){return this.check(Tc())},toUpperCase(){return this.check(Ec())},slugify(){return this.check(Dc())}})}),Fl=U(`ZodString`,(e,t)=>{io.init(e,t),Pl.init(e,t),e.email=t=>e.check(ks(Ll,t)),e.url=t=>e.check(Fs(Vl,t)),e.jwt=t=>e.check(Xs(nu,t)),e.emoji=t=>e.check(Is(Hl,t)),e.guid=t=>e.check(As(Rl,t)),e.uuid=t=>e.check(js(zl,t)),e.uuidv4=t=>e.check(Ms(zl,t)),e.uuidv6=t=>e.check(Ns(zl,t)),e.uuidv7=t=>e.check(Ps(zl,t)),e.nanoid=t=>e.check(Ls(Ul,t)),e.guid=t=>e.check(As(Rl,t)),e.cuid=t=>e.check(Rs(Wl,t)),e.cuid2=t=>e.check(zs(Gl,t)),e.ulid=t=>e.check(Bs(Kl,t)),e.base64=t=>e.check(qs($l,t)),e.base64url=t=>e.check(Js(eu,t)),e.xid=t=>e.check(Vs(ql,t)),e.ksuid=t=>e.check(Hs(Jl,t)),e.ipv4=t=>e.check(Us(Yl,t)),e.ipv6=t=>e.check(Ws(Xl,t)),e.cidrv4=t=>e.check(Gs(Zl,t)),e.cidrv6=t=>e.check(Ks(Ql,t)),e.e164=t=>e.check(Ys(tu,t)),e.datetime=t=>e.check(dl(t)),e.date=t=>e.check(pl(t)),e.time=t=>e.check(hl(t)),e.duration=t=>e.check(_l(t))});function W(e){return Os(Fl,e)}var Il=U(`ZodStringFormat`,(e,t)=>{ao.init(e,t),Pl.init(e,t)}),Ll=U(`ZodEmail`,(e,t)=>{co.init(e,t),Il.init(e,t)}),Rl=U(`ZodGUID`,(e,t)=>{oo.init(e,t),Il.init(e,t)}),zl=U(`ZodUUID`,(e,t)=>{so.init(e,t),Il.init(e,t)});function Bl(e){return js(zl,e)}var Vl=U(`ZodURL`,(e,t)=>{lo.init(e,t),Il.init(e,t)}),Hl=U(`ZodEmoji`,(e,t)=>{uo.init(e,t),Il.init(e,t)}),Ul=U(`ZodNanoID`,(e,t)=>{fo.init(e,t),Il.init(e,t)}),Wl=U(`ZodCUID`,(e,t)=>{po.init(e,t),Il.init(e,t)}),Gl=U(`ZodCUID2`,(e,t)=>{mo.init(e,t),Il.init(e,t)}),Kl=U(`ZodULID`,(e,t)=>{ho.init(e,t),Il.init(e,t)}),ql=U(`ZodXID`,(e,t)=>{go.init(e,t),Il.init(e,t)}),Jl=U(`ZodKSUID`,(e,t)=>{_o.init(e,t),Il.init(e,t)}),Yl=U(`ZodIPv4`,(e,t)=>{So.init(e,t),Il.init(e,t)}),Xl=U(`ZodIPv6`,(e,t)=>{Co.init(e,t),Il.init(e,t)}),Zl=U(`ZodCIDRv4`,(e,t)=>{tee.init(e,t),Il.init(e,t)}),Ql=U(`ZodCIDRv6`,(e,t)=>{wo.init(e,t),Il.init(e,t)}),$l=U(`ZodBase64`,(e,t)=>{Eo.init(e,t),Il.init(e,t)}),eu=U(`ZodBase64URL`,(e,t)=>{Oo.init(e,t),Il.init(e,t)}),tu=U(`ZodE164`,(e,t)=>{ko.init(e,t),Il.init(e,t)}),nu=U(`ZodJWT`,(e,t)=>{jo.init(e,t),Il.init(e,t)}),ru=U(`ZodNumber`,(e,t)=>{Mo.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,n,r),Ml(e,`ZodNumber`,{gt(e,t){return this.check(uc(e,t))},gte(e,t){return this.check(dc(e,t))},min(e,t){return this.check(dc(e,t))},lt(e,t){return this.check(cc(e,t))},lte(e,t){return this.check(lc(e,t))},max(e,t){return this.check(lc(e,t))},int(e){return this.check(ou(e))},safe(e){return this.check(ou(e))},positive(e){return this.check(uc(0,e))},nonnegative(e){return this.check(dc(0,e))},negative(e){return this.check(cc(0,e))},nonpositive(e){return this.check(lc(0,e))},multipleOf(e,t){return this.check(fc(e,t))},step(e,t){return this.check(fc(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function iu(e){return tc(ru,e)}var au=U(`ZodNumberFormat`,(e,t)=>{No.init(e,t),ru.init(e,t)});function ou(e){return nc(au,e)}var su=U(`ZodBoolean`,(e,t)=>{Po.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hc(e,t,n,r)});function G(e){return rc(su,e)}var cu=U(`ZodNull`,(e,t)=>{Fo.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uc(e,t,n,r)});function lu(e){return ic(cu,e)}var uu=U(`ZodAny`,(e,t)=>{Io.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function du(){return ac(uu)}var fu=U(`ZodUnknown`,(e,t)=>{Lo.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function pu(){return oc(fu)}var mu=U(`ZodNever`,(e,t)=>{Ro.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wc(e,t,n,r)});function hu(e){return sc(mu,e)}var gu=U(`ZodArray`,(e,t)=>{Bo.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yc(e,t,n,r),e.element=t.element,Ml(e,`ZodArray`,{min(e,t){return this.check(mc(e,t))},nonempty(e){return this.check(mc(1,e))},max(e,t){return this.check(pc(e,t))},length(e,t){return this.check(hc(e,t))},unwrap(){return this.element}})});function K(e,t){return Oc(gu,e,t)}var _u=U(`ZodObject`,(e,t)=>{Go.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xc(e,t,n,r),li(e,`shape`,()=>t.shape),Ml(e,`ZodObject`,{keyof(){return Ou(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:pu()})},loose(){return this.clone({...this._zod.def,catchall:pu()})},strict(){return this.clone({...this._zod.def,catchall:hu()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Di(this,e)},safeExtend(e){return Oi(this,e)},merge(e){return ki(this,e)},pick(e){return Ti(this,e)},omit(e){return Ei(this,e)},partial(...e){return Ai(Mu,this,e[0])},required(...e){return ji(Hu,this,e[0])}})});function q(e,t){return new _u({type:`object`,shape:e??{},...Si(t)})}var vu=U(`ZodUnion`,(e,t)=>{qo.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zc(e,t,n,r),e.options=t.options});function yu(e,t){return new vu({type:`union`,options:e,...Si(t)})}var nee=U(`ZodDiscriminatedUnion`,(e,t)=>{vu.init(e,t),Jo.init(e,t)});function bu(e,t,n){return new nee({type:`union`,options:t,discriminator:e,...Si(n)})}var xu=U(`ZodIntersection`,(e,t)=>{Yo.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qc(e,t,n,r)});function Su(e,t){return new xu({type:`intersection`,left:e,right:t})}var Cu=U(`ZodTuple`,(e,t)=>{Qo.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function wu(e,t,n){let r=t instanceof ro;return new Cu({type:`tuple`,items:e,rest:r?t:null,...Si(r?n:t)})}var Tu=U(`ZodRecord`,(e,t)=>{ns.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>el(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Eu(e,t,n){return!t||!t._zod?new Tu({type:`record`,keyType:W(),valueType:e,...Si(t)}):new Tu({type:`record`,keyType:e,valueType:t,...Si(n)})}var Du=U(`ZodEnum`,(e,t)=>{rs.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gc(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Du({...t,checks:[],...Si(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Du({...t,checks:[],...Si(r),entries:i})}});function Ou(e,t){return new Du({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Si(t)})}var ku=U(`ZodLiteral`,(e,t)=>{is.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kc(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function J(e,t){return new ku({type:`literal`,values:Array.isArray(e)?e:[e],...Si(t)})}var Au=U(`ZodTransform`,(e,t)=>{as.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jc(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $r(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ri(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ri(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function ju(e){return new Au({type:`transform`,transform:e})}var Mu=U(`ZodOptional`,(e,t)=>{cs.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Nu(e){return new Mu({type:`optional`,innerType:e})}var Pu=U(`ZodExactOptional`,(e,t)=>{ls.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fu(e){return new Pu({type:`optional`,innerType:e})}var Iu=U(`ZodNullable`,(e,t)=>{us.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lu(e){return new Iu({type:`nullable`,innerType:e})}var Ru=U(`ZodDefault`,(e,t)=>{ds.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function zu(e,t){return new Ru({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():vi(t)}})}var Bu=U(`ZodPrefault`,(e,t)=>{ps.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vu(e,t){return new Bu({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():vi(t)}})}var Hu=U(`ZodNonOptional`,(e,t)=>{ms.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uu(e,t){return new Hu({type:`nonoptional`,innerType:e,...Si(t)})}var Wu=U(`ZodCatch`,(e,t)=>{gs.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Gu(e,t){return new Wu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Ku=U(`ZodPipe`,(e,t)=>{_s.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r),e.in=t.in,e.out=t.out});function qu(e,t){return new Ku({type:`pipe`,in:e,out:t})}var Ju=U(`ZodReadonly`,(e,t)=>{ys.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yu(e){return new Ju({type:`readonly`,innerType:e})}var Xu=U(`ZodLazy`,(e,t)=>{xs.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Zu(e){return new Xu({type:`lazy`,getter:e})}var Qu=U(`ZodCustom`,(e,t)=>{Ss.init(e,t),Nl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qc(e,t,n,r)});function $u(e,t={}){return kc(Qu,e,t)}function ed(e,t){return Ac(e,t)}function td(e,t={}){let n=new Qu({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...Si(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}function nd(e){return e instanceof Object&&`name`in e&&(e.name===`ZodError`||e.name===`$ZodError`)&&`issues`in e&&Array.isArray(e.issues)}var rd=`ZodValidationError`,id=class extends Error{name;details;constructor(e,t){super(e,t),this.name=rd,this.details=ad(t)}toString(){return this.message}};function ad(e){if(e){let t=e.cause;if(nd(t))return t.issues}return[]}function od(e){return e.description??``}function sd(e){return e.length!==0}var cd=/[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u;function ld(e){if(e.length===1){let t=e[0];return typeof t==`symbol`&&(t=od(t)),t.toString()||`""`}return e.reduce((e,t)=>typeof t==`number`?e+`[`+t.toString()+`]`:(typeof t==`symbol`&&(t=od(t)),t.includes(`"`)?e+`["`+ud(t)+`"]`:cd.test(t)?e+(e.length===0?``:`.`)+t:e+`["`+t+`"]`),``)}function ud(e){return e.replace(/"/g,`\\"`)}function dd(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var fd={prefix:`Validation error`,prefixSeparator:`: `,maxIssuesInMessage:99,unionSeparator:` or `,issueSeparator:`; `,includePath:!0,forceTitleCase:!0};function pd(e={}){let t={...fd,...e};return function(e){return hd(e.slice(0,t.maxIssuesInMessage).map(e=>md(e,t)).join(t.issueSeparator),t)}}function md(e,t){if(e.code===`invalid_union`&&sd(e.errors)){let n=e.errors.map(n=>n.map(n=>md({...n,path:e.path.concat(n.path)},t)).join(t.issueSeparator));return Array.from(new Set(n)).join(t.unionSeparator)}let n=[];t.forceTitleCase?n.push(dd(e.message)):n.push(e.message);pathCondition:if(t.includePath&&e.path!==void 0&&sd(e.path)){if(e.path.length===1){let t=e.path[0];if(typeof t==`number`){n.push(` at index ${t}`);break pathCondition}}n.push(` at "${ld(e.path)}"`)}return n.join(``)}function hd(e,t){return t.prefix==null?e.length>0?e:fd.prefix:e.length>0?[t.prefix,e].join(t.prefixSeparator):t.prefix}function gd(e,t={}){let n=e.issues,r;return r=sd(n)?_d(t)(n):e.message,new id(r,{cause:e})}function _d(e){return`messageBuilder`in e?e.messageBuilder:pd(e)}var vd=(e={})=>t=>nd(t)?gd(t,e):t instanceof Error?new id(t.message,{cause:t}):new id(`Unknown error`);function yd(e,t={}){return vd(t)(e)}function bd(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function xd(e){var t=bd(e,`string`);return typeof t==`symbol`?t:t+``}function Sd(e,t,n){return(t=xd(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Cd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function wd(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Cd(Object(n),!0).forEach(function(t){Sd(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cd(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Td(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ed(e,t){if(e){if(typeof e==`string`)return Td(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Td(e,t):void 0}}function Dd(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=Ed(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
77
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}new TextEncoder;var Od=q({type:yu([J(`bold`),J(`strike`),J(`italic`)])}),kd=q({type:J(`link`),attrs:q({href:W(),target:yu([J(`_blank`),lu()]),auto:G()})}),Ad=Su(q({type:J(`text`),text:W().optional()}),q({marks:K(yu([Od,kd]))}).partial()),jd=Su(q({type:J(`hardBreak`)}),q({marks:K(Od)}).partial()),Md=Su(q({type:J(`image`)}),q({attrs:Su(q({src:W()}),q({align:yu([J(`center`),J(`end`),J(`justify`),J(`left`),J(`match-parent`),J(`right`),J(`start`),lu()]),alt:yu([W(),lu()]),height:yu([W(),iu(),lu()]),width:yu([W(),iu(),lu()]),rotate:yu([W(),lu()]),title:yu([W(),lu()]),fileName:yu([W(),lu()])}).partial())}).partial()),Nd=Su(q({type:J(`heading`)}),q({attrs:q({level:iu()}),content:K(yu([Ad,Md,jd]))}).partial()),Pd=Zu(function(){return Su(q({type:J(`bulletList`)}),q({content:K(Id)}).partial())}),Fd=Zu(function(){return Su(q({type:J(`orderedList`)}),q({content:K(Id)}).partial())}),Id=Zu(function(){return Su(q({type:J(`listItem`)}),q({attrs:q({closed:G(),nested:G()}).partial().optional(),content:K(yu([Ld,Pd,Fd]))}).partial())}),Ld=Zu(function(){return Su(q({type:J(`paragraph`)}),q({content:K(yu([Ad,Md,jd]))}).partial())});q({type:J(`doc`),content:K(yu([Ld,Nd,Pd,Fd]))});var Rd=H.VAL_SESSION_COOKIE,zd=H.VAL_STATE_COOKIE,Bd=H.VAL_ENABLE_COOKIE_NAME;function Vd(e,t,n,r){var i=Object.defineProperty;try{i({},``,{})}catch{i=0}Vd=function(e,t,n,r){function a(t,n){Vd(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a(`next`,0),a(`throw`,1),a(`return`,2))},Vd(e,t,n,r)}function Hd(){var e,t,n=typeof Symbol==`function`?Symbol:{},r=n.iterator||`@@iterator`,i=n.toStringTag||`@@toStringTag`;function a(n,r,i,a){var c=r&&r.prototype instanceof s?r:s,l=Object.create(c.prototype);return Vd(l,`_invoke`,function(n,r,i){var a,s,c,l=0,u=i||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,s=0,c=e,f.n=n,o}};function p(n,r){for(s=n,c=r,t=0;!d&&l&&!i&&t<u.length;t++){var i,a=u[t],p=f.p,m=a[2];n>3?(i=m===r)&&(c=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=p&&((i=n<2&&p<a[1])?(s=0,f.v=r,f.n=a[1]):p<m&&(i=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,s=0))}if(i||n>1)return o;throw d=!0,r}return function(i,u,m){if(l>1)throw TypeError(`Generator is already running`);for(d&&u===1&&p(u,m),s=u,c=m;(t=s<2?e:c)||!d;){a||(s?s<3?(s>1&&(f.n=-1),p(s,c)):f.n=c:f.v=c);try{if(l=2,a){if(s||(i=`next`),t=a[i]){if(!(t=t.call(a,c)))throw TypeError(`iterator result is not an object`);if(!t.done)return t;c=t.value,s<2&&(s=0)}else s===1&&(t=a.return)&&t.call(a),s<2&&(c=TypeError(`The iterator does not provide a '`+i+`' method`),s=1);a=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==o)break}catch(t){a=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,i,a),!0),l}var o={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(Vd(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Vd(e,i,`GeneratorFunction`)),e.prototype=Object.create(d),e}return c.prototype=l,Vd(d,`constructor`,l),Vd(l,`constructor`,c),c.displayName=`GeneratorFunction`,Vd(l,i,`GeneratorFunction`),Vd(d),Vd(d,i,`Generator`),Vd(d,r,function(){return this}),Vd(d,`toString`,function(){return`[object Generator]`}),(Hd=function(){return{w:a,m:f}})()}function Ud(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Wd(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Ud(a,r,i,o,s,`next`,e)}function s(e){Ud(a,r,i,o,s,`throw`,e)}o(void 0)})}}var Gd=Zu(function(){return yu([W(),iu(),G(),lu(),K(Gd),Eu(W(),Gd)])}),Kd=function(e){return q({op:J(`file`),path:e,filePath:W(),value:Gd,remote:G(),nestedFilePath:K(W()).optional(),metadata:Gd.optional()})};bu(`op`,[q({op:J(`add`),path:W(),value:Gd}).strict(),q({op:J(`remove`),path:W()}).strict(),q({op:J(`replace`),path:W(),value:Gd}).strict(),q({op:J(`move`),from:W(),path:W()}).strict(),q({op:J(`copy`),from:W(),path:W()}).strict(),q({op:J(`test`),path:W(),value:Gd}).strict(),Kd(W()).strict()]);var qd=wu([W()],W()),Jd=K(bu(`op`,[q({op:J(`add`),path:K(W()),value:Gd}).strict(),q({op:J(`remove`),path:qd}).strict(),q({op:J(`replace`),path:K(W()),value:Gd}).strict(),q({op:J(`move`),from:qd,path:K(W())}).strict(),q({op:J(`copy`),from:K(W()),path:K(W())}).strict(),q({op:J(`test`),path:K(W()),value:Gd}).strict(),Kd(K(W())).strict()])),Yd=W().refine(function(e){return!0});q({patch:Jd,parentRef:yu([q({type:J(`head`),headBaseSha:W()}),q({type:J(`patch`),patchId:Yd})])});var Xd=W().transform(function(e){return e}),Zd=q({as:J(`inline`)}).optional(),Qd=q({type:J(`string`),render:Zd,multiline:G().optional(),preview:J(!0).optional(),options:q({maxLength:iu().optional(),minLength:iu().optional(),regexp:q({source:W(),flags:W()}).optional()}).optional(),opt:G(),raw:G(),readonly:G().optional(),hidden:G().optional()}),$d=q({type:J(`literal`),render:Zd,preview:J(!0).optional(),value:W(),opt:G(),readonly:G().optional(),hidden:G().optional()}),ef=q({type:J(`boolean`),render:Zd,preview:J(!0).optional(),opt:G(),readonly:G().optional(),hidden:G().optional()}),tf=q({type:J(`number`),render:Zd,preview:J(!0).optional(),options:q({max:iu().optional(),min:iu().optional()}).optional(),opt:G(),readonly:G().optional(),hidden:G().optional()}),nf=Zu(function(){return q({type:J(`object`),render:Zd,preview:J(!0).optional(),items:Eu(W(),Cf),opt:G(),readonly:G().optional(),hidden:G().optional()})}),rf=Zu(function(){return q({type:J(`array`),render:Zd,preview:J(!0).optional(),item:Cf,opt:G(),readonly:G().optional(),hidden:G().optional()})}),af=Zu(function(){return yu([q({type:J(`union`),render:Zd,preview:J(!0).optional(),key:$d,items:K($d),opt:G(),readonly:G().optional(),hidden:G().optional()}),q({type:J(`union`),render:Zd,preview:J(!0).optional(),key:W(),items:K(nf),opt:G(),readonly:G().optional(),hidden:G().optional()})])}),of=yu([J(!1),q({type:J(`webp`),quality:iu().optional(),maxWidth:iu().optional(),maxHeight:iu().optional()})]),sf=q({directory:W().optional(),accept:W().optional(),encode:of.optional()}),cf=q({type:J(`image`),render:Zd,preview:J(!0).optional(),options:sf.optional(),opt:G(),readonly:G().optional(),hidden:G().optional()}),lf=Zu(function(){return q({style:q({bold:G().optional(),italic:G().optional(),lineThrough:G().optional()}).optional(),block:q({h1:G().optional(),h2:G().optional(),h3:G().optional(),h4:G().optional(),h5:G().optional(),h6:G().optional(),ul:G().optional(),ol:G().optional()}).optional(),inline:q({a:yu([G(),Sf,Qd]).optional(),img:yu([G(),cf]).optional()}).optional()})}),uf=q({type:J(`richtext`),render:Zd,preview:J(!0).optional(),options:lf.optional(),opt:G(),readonly:G().optional(),hidden:G().optional()}),df=Zu(function(){return q({type:J(`record`),render:Zd,preview:J(!0).optional(),item:Cf,opt:G(),mediaType:yu([J(`files`),J(`images`)]).optional(),accept:W().optional(),directory:W().optional(),remote:G().optional(),encode:of.optional(),alt:Cf.optional(),moduleMetadata:Eu(W(),Eu(W(),du())).optional(),readonly:G().optional(),hidden:G().optional()}).passthrough()}),ff=Zu(function(){return q({type:J(`keyOf`),render:Zd,preview:J(!0).optional(),path:Xd,schema:yu([q({type:J(`object`),keys:K(W()),opt:G().optional()}),q({type:J(`record`),opt:G().optional()})]).optional(),values:yu([J(`string`),K(W())]),opt:G(),readonly:G().optional(),hidden:G().optional()})}),pf=q({accept:W().optional()}),mf=q({type:J(`file`),render:Zd,preview:J(!0).optional(),options:pf.optional(),opt:G(),readonly:G().optional(),hidden:G().optional()}),hf=q({from:W().optional(),to:W().optional()}),gf=q({type:J(`date`),render:Zd,preview:J(!0).optional(),options:hf.optional(),opt:G(),customValidate:G().optional(),readonly:G().optional(),hidden:G().optional(),description:W().optional()}),_f=q({type:J(`dateTime`),render:Zd,preview:J(!0).optional(),options:hf.optional(),opt:G(),customValidate:G().optional(),readonly:G().optional(),hidden:G().optional(),description:W().optional()}),vf=q({format:Ou([`hex`,`rgb`,`hsl`,`oklch`]).optional(),alpha:G().optional()}),yf=q({type:J(`color`),render:Zd,preview:J(!0).optional(),options:vf.optional(),opt:G(),customValidate:G().optional(),readonly:G().optional(),hidden:G().optional(),description:W().optional()}),bf=q({language:Ou(fn).optional()}),xf=q({type:J(`code`),render:Zd,preview:J(!0).optional(),options:bf.optional(),opt:G(),customValidate:G().optional(),readonly:G().optional(),hidden:G().optional(),description:W().optional()}),Sf=q({type:J(`route`),render:Zd,preview:J(!0).optional(),options:q({include:q({source:W(),flags:W()}).optional(),exclude:q({source:W(),flags:W()}).optional(),customValidate:G().optional()}).optional(),opt:G(),customValidate:G().optional(),readonly:G().optional(),hidden:G().optional()}),Cf=yu([Qd,$d,ef,tf,nf,rf,af,uf,df,ff,Sf,mf,gf,_f,yf,xf,cf]),wf=q({commitSha:W(),clientCommitSha:W(),parentCommitSha:W(),branch:W(),creator:W(),createdAt:W(),commitMessage:W().nullable()}),Tf=W().refine(function(e){return!0}),Ef=yu([q({type:J(`head`),headBaseSha:W()}),q({type:J(`patch`),patchId:Yd})]),Df=q({project:W().optional(),root:W().optional(),files:q({directory:W()}).optional(),gitCommit:W().optional(),gitBranch:W().optional()}),Of=yu([J(`image:add-metadata`),J(`image:check-metadata`),J(`image:check-remote`),J(`image:upload-remote`),J(`image:download-remote`),J(`images:check-remote`),J(`images:upload-remote`),J(`file:add-metadata`),J(`file:check-metadata`),J(`file:check-remote`),J(`file:upload-remote`),J(`file:download-remote`),J(`files:check-remote`),J(`files:upload-remote`),J(`keyof:check-keys`),J(`router:check-route`),J(`images:check-unique-folder`),J(`files:check-unique-folder`),J(`images:check-all-files`),J(`files:check-all-files`),J(`jsonValues:extract-entry`)]),kf=q({message:W(),value:pu().optional(),fatal:G().optional(),fixes:K(Of).optional()}),Af=q({status:J(401),json:q({message:W()})}),jf=q({status:J(404),json:q({message:W()})}),Mf=q({message:W()}),Nf=yu([q({patchId:Yd,message:W()}),q({parentPatchId:W(),message:W()})]),Pf=q({message:W(),path:Tf.optional()});yu([J(`val_session`),J(`val_enable`),J(`val_state`)]);var Ff=q({value:J(`true`),options:q({httpOnly:J(!1),sameSite:J(`lax`)})}),If=K(W()).max(1,`At most one query param is allowed`).transform(function(e){return e[0]}),Lf=If.refine(function(e){return e===`true`||e===`false`},`Value must be true or false`).transform(function(e){return e===`true`}),Rf=If.refine(function(e){return/^\d+$/.test(e)},`Value must be a non-negative whole number`).transform(function(e){return parseInt(e,10)}),zf={"/draft/enable":{GET:{req:{query:{redirect_to:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([q({status:J(401),json:Mf}),q({status:J(302),redirectTo:W()}),q({status:J(400),json:q({message:W()})})])}},"/draft/disable":{GET:{req:{query:{redirect_to:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([q({status:J(401),json:Mf}),q({status:J(302),redirectTo:W()}),q({status:J(400),json:q({message:W()})})])}},"/draft/stat":{GET:{req:{cookies:Sd({},Rd,W().optional())},res:yu([q({status:J(401),json:Mf}),q({status:J(200),json:q({draftMode:G()})})])}},"/enable":{GET:{req:{query:{redirect_to:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([q({status:J(401),json:Mf}),q({status:J(302),redirectTo:W(),cookies:q(Sd(Sd({},Bd,Ff),zd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`lax`),expires:td(Date)})})))}),q({status:J(302),redirectTo:W(),cookies:q(Sd({},Bd,Ff))}),q({status:J(400),json:q({message:W()})})])}},"/disable":{GET:{req:{query:{redirect_to:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([q({status:J(401),json:Mf}),q({status:J(302),redirectTo:W(),cookies:q(Sd({},Bd,q({value:J(`false`)})))}),q({status:J(400),json:q({message:W()})})])}},"/authorize":{GET:{req:{query:{redirect_to:If.optional()}},res:yu([q({status:J(302),redirectTo:W(),cookies:q(Sd(Sd({},Bd,Ff),zd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`lax`),expires:td(Date)})})))}),q({status:J(400),json:q({message:W()})})])}},"/callback":{GET:{req:{query:{code:If.optional(),state:If.optional()},cookies:Sd({},zd,W())},res:q({status:J(302),redirectTo:W(),cookies:q(Sd(Sd(Sd({},zd,q({value:J(null)})),Bd,Ff.optional()),Rd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`strict`),path:W(),secure:J(!0),expires:td(Date)}).optional()}).optional()))})}},"/session":{GET:{req:{cookies:{val_session:W().optional()}},res:yu([q({status:J(200),json:q({mode:yu([J(`local`),J(`proxy`)]),enabled:G()})}),q({status:yu([J(400),J(401),J(403),J(404),J(500),J(501)]),json:q({message:W()})}),q({status:J(401),json:q({message:W(),details:yu([W(),q({reason:W()}),q({sub:W(),exp:iu(),token:W(),org:W(),project:W()})])})}),q({status:J(500),json:q({message:W()})})])}},"/logout":{GET:{req:{query:{redirect_to:If.optional()}},res:yu([q({status:J(200),cookies:q(Sd(Sd({},Rd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`strict`),path:W(),secure:J(!0),expires:td(Date)}).optional()}).optional()),zd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`strict`),path:W(),secure:J(!0),expires:td(Date)}).optional()}).optional()))}),q({status:J(302),redirectTo:W(),cookies:q(Sd(Sd({},Rd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`strict`),path:W(),secure:J(!0),expires:td(Date)}).optional()}).optional()),zd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`strict`),path:W(),secure:J(!0),expires:td(Date)}).optional()}).optional()))})])}},"/remote/settings":{GET:{req:{cookies:{val_session:W().optional()}},res:yu([q({status:J(200),json:q({publicProjectId:W(),coreVersion:W(),remoteFileBuckets:K(q({bucket:W()}))})}),q({status:J(400),json:q({errorCode:yu([J(`project-not-configured`),J(`error-could-not-get-settings`),J(`project-not-configured`),J(`pat-error`),J(`api-key-missing`)]),message:W()})}),q({status:J(401),json:q({errorCode:J(`unauthorized`).optional(),message:W()})}),q({status:J(500),json:q({message:W()})})])}},"/stat":{POST:{req:{body:q({sourcesSha:W(),schemaSha:W(),baseSha:W(),patches:K(W()).optional(),jsonEntriesSha:W().optional()}).nullable(),cookies:{val_session:W().optional()}},res:yu([q({status:J(401),json:Mf}),q({status:J(500),json:Mf}),q({status:J(503),json:Mf}),q({status:J(200),json:yu([q({type:yu([J(`request-again`),J(`no-change`),J(`did-change`)]),baseSha:W(),schemaSha:W(),sourcesSha:W(),patches:K(Yd),removed:K(q({patchId:Yd,reason:W()})).optional(),config:Df,profileId:W().nullable(),mode:yu([J(`http`),J(`fs`)]),jsonEntriesSha:W().optional()}),q({type:J(`use-websocket`),url:W(),nonce:W(),baseSha:W(),schemaSha:W(),sourcesSha:W(),commitSha:W(),patches:K(Yd),commits:K(wf),config:Df,profileId:W().nullable(),mode:yu([J(`http`),J(`fs`)])})])})])}},"/upload/patches":{POST:{req:{path:W().optional(),body:q({parentRef:Ef,filePath:W(),data:du(),type:yu([J(`file`),J(`image`)]),metadata:du(),remote:G()})},res:yu([q({status:J(400),json:Mf}),q({status:J(200),json:q({filePath:W(),patchId:Yd})})])}},"/direct-file-upload-settings":{POST:{req:{cookies:{val_session:W().optional()}},res:yu([q({status:J(400),json:Mf}),q({status:J(401),json:Mf}),q({status:J(500),json:Mf}),q({status:J(200),json:q({nonce:W().nullable(),baseUrl:W(),contentBaseUrl:W().nullable(),contentAuthNonce:W().nullable()})})])}},"/patches":{DELETE:{req:{query:{id:K(Yd).min(1,`At least one patch id is required`)},cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(500),json:q({message:W(),errors:K(Nf)})}),q({status:J(200),json:K(Yd)})])},PUT:{req:{body:q({parentRef:Ef,sessionId:W().nullish(),patches:K(q({path:Tf,patchId:Yd,patch:du()}))}),cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(409),json:q({type:J(`patch-head-conflict`),message:W()})}),q({status:J(400),json:q({type:J(`patch-error`),message:W(),errors:Eu(Tf,K(q({error:Mf})))})}),q({status:J(200),json:q({newPatchIds:K(Yd),parentRef:Ef})})])},GET:{req:{query:{patch_id:K(Yd).optional(),exclude_patch_ops:Lf.optional()},cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(500),json:q({message:W(),patchErrors:K(Nf)})}),q({status:J(500),json:q({message:W(),error:Mf})}),q({status:J(200),json:q({patches:K(q({path:Tf,patch:Jd.optional(),patchId:Yd,createdAt:W(),authorId:W().nullable(),appliedAt:q({commitSha:W()}).nullable()})),baseSha:W(),error:Mf.optional(),errors:Eu(Yd,Mf).optional()})})])}},"/schema":{GET:{req:{cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(500),json:q({message:W(),details:K(Pf)})}),q({status:J(500),json:q({message:W(),details:K(Mf)})}),q({status:J(200),json:q({schemaSha:W(),schemas:Eu(Tf,Cf)})})])}},"/sources/~":{PUT:{req:{path:W().optional(),query:{validate_sources:Lf.optional(),validate_binary_files:Lf.optional(),exclude_patches:Lf.optional(),apply_patches:Lf.optional()},cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(401),json:Mf}),q({status:J(500),json:q({message:W(),details:yu([K(Pf),Mf])})}),q({status:J(409),json:q({message:W()})}),q({status:J(400),json:q({message:W(),details:K(Pf)})}),q({status:J(200),json:q({schemaSha:W(),sourcesSha:W(),modules:Eu(Tf,q({preview:du().optional(),source:du().optional(),baseSource:du().optional(),patches:q({applied:K(Yd),skipped:K(Yd).optional(),errors:Eu(Yd,Mf).optional()}).optional(),validationErrors:Eu(W(),K(kf)).optional()}))})})])}},"/profiles":{GET:{req:{cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(500),json:Mf}),q({status:J(200),json:q({profiles:K(q({profileId:W(),fullName:W(),email:W().optional(),avatar:q({url:W()}).nullable()}))})})])}},"/save":{POST:{req:{body:q({message:W().optional(),patchIds:K(Yd)}),cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(200),json:q({removed:K(q({patchId:Yd,moduleFilePath:Tf,message:W()})).optional()})}),q({status:J(409),json:q({message:W(),isNotFastForward:J(!0)})}),q({status:J(400),json:yu([q({message:W(),details:yu([q({sourceFilePatchErrors:Eu(Tf,K(Mf)),binaryFilePatchErrors:Eu(W(),Mf),unappliablePatches:Eu(Yd,q({moduleFilePath:Tf,message:W()})).optional()}),K(Mf)]).optional()}),q({message:W(),errorCode:yu([J(`project-not-configured`),J(`pat-error`)])})])})])}},"/files":{GET:{req:{path:W(),query:{patch_id:K(Yd).max(1,`At most one patch id is allowed`).transform(function(e){return e[0]}).optional(),remote:If.optional()}},res:yu([Af,jf,q({status:J(200),body:td(ReadableStream)})])}},"/json":{GET:{req:{query:{path:If,key:If.optional(),keys:K(W()).max(100).optional(),offset:Rf.optional(),limit:Rf.refine(function(e){return e>0&&e<=100},`limit must be between 1 and 100`).optional(),apply_patches:Lf.optional()},cookies:Sd({},Rd,W().optional())},res:yu([Af,jf,q({status:J(200),json:q({path:Tf,key:W(),content:du()})}),q({status:J(200),json:q({path:Tf,entries:K(q({key:W(),content:du()})),missing:K(W()),errors:K(q({key:W(),message:W()})),offset:iu().optional(),limit:iu().optional(),total:iu().optional()})}),q({status:J(400),json:Mf}),q({status:J(500),json:Mf})])}},"/ai/initialize":{POST:{req:{cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({nonce:W(),wsUrl:W(),providers:K(W()).optional(),models:K(q({provider:W(),model:W(),label:W(),contextWindow:iu().nullable().optional()})).optional()})}),q({status:J(500),json:Mf})])}},"/ai/sessions":{GET:{req:{query:{limit:If.optional(),cursor_updatedAt:If.optional(),cursor_id:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({sessions:K(q({id:W(),name:W().nullable(),createdAt:W(),updatedAt:W()})),nextCursor:q({updatedAt:W(),id:W()}).nullable().optional()})}),q({status:J(500),json:Mf})])},PATCH:{req:{path:W(),body:q({name:W()}),cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({})}),q({status:J(500),json:Mf})])}},"/ai/messages":{GET:{req:{path:W(),query:{limit:If.optional(),cursor_updatedAt:If.optional(),cursor_id:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({messages:K(q({role:W(),content:yu([W(),K(yu([q({type:J(`text`),text:W()}),q({type:J(`image_url`),url:W()})]))])})),nextCursor:q({updatedAt:W(),id:W()}).nullable().optional()})}),q({status:J(500),json:Mf})])}},"/ai/session-image-to-patch-file":{POST:{req:{body:q({patchId:Yd,parentRef:Ef,files:K(q({filePath:W(),key:W(),isRemote:G().optional()})).min(1)}),cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({patchId:Yd,files:K(q({filePath:W(),metadata:q({width:iu(),height:iu(),mimeType:W()})}))})}),q({status:J(400),json:q({message:W(),details:q({availableKeys:K(W()).optional()}).optional()})}),q({status:J(500),json:Mf})])}},"/ai/images":{PATCH:{req:{body:q({key:W(),metadata:du(),contentType:W()}),cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({key:W()})}),q({status:J(500),json:Mf})])}}};function Bf(e){"@babel/helpers - typeof";return Bf=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Bf(e)}function Vf(e,t){return Bf(e)===`object`&&e!==null&&`message`in e&&typeof e.message==`string`?e.message:t}var Hf=function(e,t){var n=zf;return function(){var t=Wd(Hd().m(function t(r,i,a){var o,s,c,l,u,d,f,p,m,h,g,_,v,y,b;return Hd().w(function(t){for(;;)switch(t.p=t.n){case 0:if(s=a,c=r,s!=null&&s.path&&s.path.length>0&&(c+=s.path),s.query){for(l=[],u=0,d=Object.keys(s.query);u<d.length;u++)if(f=d[u],Array.isArray(s.query?.[f])){p=Dd(s.query?.[f]||[]);try{for(p.s();!(m=p.n()).done;)h=m.value,h!==void 0&&l.push([f,h.toString()])}catch(e){p.e(e)}finally{p.f()}}else s.query?.[f]!==void 0&&l.push([f,s==null||(g=s.query)==null?void 0:g[f].toString()]);s!=null&&s.query&&l.length>0&&(c+=`?${new URLSearchParams(l).toString()}`)}if(_=n==null||(o=n[r])==null?void 0:o[i],_){t.n=1;break}return t.a(2,{status:null,json:{message:`Invalid route ${r} with method ${i}. This is most likely a Val bug.`,type:`client_side_validation_error`,details:{validationError:`Route ${r} with method ${i} not found.`,data:{routes:Object.keys(n||{}),methods:Object.keys(n?.[r]||{}),route:r,method:i}}}});case 1:if(v=_.req.body?.safeParse(s.body),!(v&&!v.success)){t.n=2;break}return console.error(`Got an invalid request body while validating client-side. This is most likely a Val bug.`,{path:r,method:i,body:s.body,error:v.error}),t.a(2,{status:null,json:{message:`There was an issue validating your data. This is most likely a Val bug.`,type:`client_side_validation_error`,details:{validationError:yd(v.error).toString(),data:s.body}}});case 2:return t.p=2,t.n=3,fetch(`${e}${c}`,{method:i,headers:{"Content-Type":`application/json`},body:s.body===void 0?void 0:JSON.stringify(s.body)}).then(function(){var e=Wd(Hd().m(function e(t){var n,a,o,s,c;return Hd().w(function(e){for(;;)switch(e.n){case 0:if(n=t.headers.get(`content-type`),t.status!==413){e.n=1;break}return e.a(2,{status:413,json:{message:`Request too large.`,method:i,path:r}});case 1:if(n!=null&&n.includes(`application/json`)){e.n=2;break}return e.a(2,{status:null,json:{type:`client_side_validation_error`,message:`Invalid response (expected JSON, but got something else). This could be a result of mismatched Val versions or a transient error. ${t.status}`,details:{validationError:`Invalid content type`,data:{status:t.status,contentType:n}}}});case 2:return e.n=3,t.json();case 3:if(a=e.v,o={status:t.status,json:a},t.status!==500){e.n=4;break}return console.error(`Server responded with an error`,a),s=Vf(a,`Unknown error`),e.a(2,{status:500,json:{type:`unknown`,message:s}});case 4:if(c=_.res?.safeParse(o),!(c&&!c.success)){e.n=5;break}return e.a(2,{status:null,json:{message:`Response could not be validated. This could also be a result of mismatched Val versions.`,type:`client_side_validation_error`,details:{validationError:yd(c.error).toString(),data:o}}});case 5:return e.a(2,{status:t.status,json:a})}},e)}));return function(t){return e.apply(this,arguments)}}());case 3:return y=t.v,t.a(2,y);case 4:return t.p=4,b=t.v,t.a(2,{status:null,json:{message:`Failed to fetch data`,type:`network_error`,retryable:Uf(b),details:b instanceof Error?b.message:JSON.stringify(b)}})}},t,null,[[2,4]])}));return function(e,n,r){return t.apply(this,arguments)}}()};function Uf(e){if(e instanceof TypeError)return!0;if(e instanceof Error&&`code`in e){var t=e.code;return[`ECONNRESET`,`ETIMEDOUT`,`ENOTFOUND`,`EAI_AGAIN`].includes(t)}return!1}function Wf(e){if(Array.isArray(e))return e}function Gf(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Kf(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
77
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}new TextEncoder;var Od=q({type:yu([J(`bold`),J(`strike`),J(`italic`)])}),kd=q({type:J(`link`),attrs:q({href:W(),target:yu([J(`_blank`),lu()]),auto:G()})}),Ad=Su(q({type:J(`text`),text:W().optional()}),q({marks:K(yu([Od,kd]))}).partial()),jd=Su(q({type:J(`hardBreak`)}),q({marks:K(Od)}).partial()),Md=Su(q({type:J(`image`)}),q({attrs:Su(q({src:W()}),q({align:yu([J(`center`),J(`end`),J(`justify`),J(`left`),J(`match-parent`),J(`right`),J(`start`),lu()]),alt:yu([W(),lu()]),height:yu([W(),iu(),lu()]),width:yu([W(),iu(),lu()]),rotate:yu([W(),lu()]),title:yu([W(),lu()]),fileName:yu([W(),lu()])}).partial())}).partial()),Nd=Su(q({type:J(`heading`)}),q({attrs:q({level:iu()}),content:K(yu([Ad,Md,jd]))}).partial()),Pd=Zu(function(){return Su(q({type:J(`bulletList`)}),q({content:K(Id)}).partial())}),Fd=Zu(function(){return Su(q({type:J(`orderedList`)}),q({content:K(Id)}).partial())}),Id=Zu(function(){return Su(q({type:J(`listItem`)}),q({attrs:q({closed:G(),nested:G()}).partial().optional(),content:K(yu([Ld,Pd,Fd]))}).partial())}),Ld=Zu(function(){return Su(q({type:J(`paragraph`)}),q({content:K(yu([Ad,Md,jd]))}).partial())});q({type:J(`doc`),content:K(yu([Ld,Nd,Pd,Fd]))});var Rd=H.VAL_SESSION_COOKIE,zd=H.VAL_STATE_COOKIE,Bd=H.VAL_ENABLE_COOKIE_NAME;function Vd(e,t,n,r){var i=Object.defineProperty;try{i({},``,{})}catch{i=0}Vd=function(e,t,n,r){function a(t,n){Vd(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a(`next`,0),a(`throw`,1),a(`return`,2))},Vd(e,t,n,r)}function Hd(){var e,t,n=typeof Symbol==`function`?Symbol:{},r=n.iterator||`@@iterator`,i=n.toStringTag||`@@toStringTag`;function a(n,r,i,a){var c=r&&r.prototype instanceof s?r:s,l=Object.create(c.prototype);return Vd(l,`_invoke`,function(n,r,i){var a,s,c,l=0,u=i||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,s=0,c=e,f.n=n,o}};function p(n,r){for(s=n,c=r,t=0;!d&&l&&!i&&t<u.length;t++){var i,a=u[t],p=f.p,m=a[2];n>3?(i=m===r)&&(c=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=p&&((i=n<2&&p<a[1])?(s=0,f.v=r,f.n=a[1]):p<m&&(i=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,s=0))}if(i||n>1)return o;throw d=!0,r}return function(i,u,m){if(l>1)throw TypeError(`Generator is already running`);for(d&&u===1&&p(u,m),s=u,c=m;(t=s<2?e:c)||!d;){a||(s?s<3?(s>1&&(f.n=-1),p(s,c)):f.n=c:f.v=c);try{if(l=2,a){if(s||(i=`next`),t=a[i]){if(!(t=t.call(a,c)))throw TypeError(`iterator result is not an object`);if(!t.done)return t;c=t.value,s<2&&(s=0)}else s===1&&(t=a.return)&&t.call(a),s<2&&(c=TypeError(`The iterator does not provide a '`+i+`' method`),s=1);a=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==o)break}catch(t){a=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,i,a),!0),l}var o={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(Vd(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Vd(e,i,`GeneratorFunction`)),e.prototype=Object.create(d),e}return c.prototype=l,Vd(d,`constructor`,l),Vd(l,`constructor`,c),c.displayName=`GeneratorFunction`,Vd(l,i,`GeneratorFunction`),Vd(d),Vd(d,i,`Generator`),Vd(d,r,function(){return this}),Vd(d,`toString`,function(){return`[object Generator]`}),(Hd=function(){return{w:a,m:f}})()}function Ud(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Wd(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Ud(a,r,i,o,s,`next`,e)}function s(e){Ud(a,r,i,o,s,`throw`,e)}o(void 0)})}}var Gd=Zu(function(){return yu([W(),iu(),G(),lu(),K(Gd),Eu(W(),Gd)])}),Kd=function(e){return q({op:J(`file`),path:e,filePath:W(),value:Gd,remote:G(),nestedFilePath:K(W()).optional(),metadata:Gd.optional()})};bu(`op`,[q({op:J(`add`),path:W(),value:Gd}).strict(),q({op:J(`remove`),path:W()}).strict(),q({op:J(`replace`),path:W(),value:Gd}).strict(),q({op:J(`move`),from:W(),path:W()}).strict(),q({op:J(`copy`),from:W(),path:W()}).strict(),q({op:J(`test`),path:W(),value:Gd}).strict(),Kd(W()).strict()]);var qd=wu([W()],W()),Jd=K(bu(`op`,[q({op:J(`add`),path:K(W()),value:Gd}).strict(),q({op:J(`remove`),path:qd}).strict(),q({op:J(`replace`),path:K(W()),value:Gd}).strict(),q({op:J(`move`),from:qd,path:K(W())}).strict(),q({op:J(`copy`),from:K(W()),path:K(W())}).strict(),q({op:J(`test`),path:K(W()),value:Gd}).strict(),Kd(K(W())).strict()])),Yd=W().refine(function(e){return!0});q({patch:Jd,parentRef:yu([q({type:J(`head`),headBaseSha:W()}),q({type:J(`patch`),patchId:Yd})])});var Xd=W().transform(function(e){return e}),Zd=q({as:J(`inline`)}).optional(),Qd=q({type:J(`string`),render:Zd,multiline:G().optional(),preview:J(!0).optional(),options:q({maxLength:iu().optional(),minLength:iu().optional(),regexp:q({source:W(),flags:W()}).optional()}).optional(),opt:G(),raw:G(),readonly:G().optional(),hidden:G().optional()}),$d=q({type:J(`literal`),render:Zd,preview:J(!0).optional(),value:W(),opt:G(),readonly:G().optional(),hidden:G().optional()}),ef=q({type:J(`boolean`),render:Zd,preview:J(!0).optional(),opt:G(),readonly:G().optional(),hidden:G().optional()}),tf=q({type:J(`number`),render:Zd,preview:J(!0).optional(),options:q({max:iu().optional(),min:iu().optional()}).optional(),opt:G(),readonly:G().optional(),hidden:G().optional()}),nf=Zu(function(){return q({type:J(`object`),render:Zd,preview:J(!0).optional(),items:Eu(W(),Cf),opt:G(),readonly:G().optional(),hidden:G().optional()})}),rf=Zu(function(){return q({type:J(`array`),render:Zd,preview:J(!0).optional(),item:Cf,opt:G(),readonly:G().optional(),hidden:G().optional()})}),af=Zu(function(){return yu([q({type:J(`union`),render:Zd,preview:J(!0).optional(),key:$d,items:K($d),opt:G(),readonly:G().optional(),hidden:G().optional()}),q({type:J(`union`),render:Zd,preview:J(!0).optional(),key:W(),items:K(nf),opt:G(),readonly:G().optional(),hidden:G().optional()})])}),of=yu([J(!1),q({type:J(`webp`),quality:iu().optional(),maxWidth:iu().optional(),maxHeight:iu().optional()})]),sf=q({directory:W().optional(),accept:W().optional(),encode:of.optional()}),cf=q({type:J(`image`),render:Zd,preview:J(!0).optional(),options:sf.optional(),opt:G(),readonly:G().optional(),hidden:G().optional()}),lf=Zu(function(){return q({maxLength:iu().optional(),minLength:iu().optional(),bold:G().optional(),italic:G().optional(),lineThrough:G().optional(),h1:G().optional(),h2:G().optional(),h3:G().optional(),h4:G().optional(),h5:G().optional(),h6:G().optional(),ul:G().optional(),ol:G().optional(),a:yu([G(),Sf,Qd]).optional(),img:yu([G(),cf]).optional()})}),uf=q({type:J(`richtext`),render:Zd,preview:J(!0).optional(),options:lf.optional(),opt:G(),readonly:G().optional(),hidden:G().optional()}),df=Zu(function(){return q({type:J(`record`),render:Zd,preview:J(!0).optional(),item:Cf,opt:G(),mediaType:yu([J(`files`),J(`images`)]).optional(),accept:W().optional(),directory:W().optional(),remote:G().optional(),encode:of.optional(),alt:Cf.optional(),moduleMetadata:Eu(W(),Eu(W(),du())).optional(),readonly:G().optional(),hidden:G().optional()}).passthrough()}),ff=Zu(function(){return q({type:J(`keyOf`),render:Zd,preview:J(!0).optional(),path:Xd,schema:yu([q({type:J(`object`),keys:K(W()),opt:G().optional()}),q({type:J(`record`),opt:G().optional()})]).optional(),values:yu([J(`string`),K(W())]),opt:G(),readonly:G().optional(),hidden:G().optional()})}),pf=q({accept:W().optional()}),mf=q({type:J(`file`),render:Zd,preview:J(!0).optional(),options:pf.optional(),opt:G(),readonly:G().optional(),hidden:G().optional()}),hf=q({from:W().optional(),to:W().optional()}),gf=q({type:J(`date`),render:Zd,preview:J(!0).optional(),options:hf.optional(),opt:G(),customValidate:G().optional(),readonly:G().optional(),hidden:G().optional(),description:W().optional()}),_f=q({type:J(`dateTime`),render:Zd,preview:J(!0).optional(),options:hf.optional(),opt:G(),customValidate:G().optional(),readonly:G().optional(),hidden:G().optional(),description:W().optional()}),vf=q({format:Ou([`hex`,`rgb`,`hsl`,`oklch`]).optional(),alpha:G().optional()}),yf=q({type:J(`color`),render:Zd,preview:J(!0).optional(),options:vf.optional(),opt:G(),customValidate:G().optional(),readonly:G().optional(),hidden:G().optional(),description:W().optional()}),bf=q({language:Ou(fn).optional()}),xf=q({type:J(`code`),render:Zd,preview:J(!0).optional(),options:bf.optional(),opt:G(),customValidate:G().optional(),readonly:G().optional(),hidden:G().optional(),description:W().optional()}),Sf=q({type:J(`route`),render:Zd,preview:J(!0).optional(),options:q({include:q({source:W(),flags:W()}).optional(),exclude:q({source:W(),flags:W()}).optional(),customValidate:G().optional()}).optional(),opt:G(),customValidate:G().optional(),readonly:G().optional(),hidden:G().optional()}),Cf=yu([Qd,$d,ef,tf,nf,rf,af,uf,df,ff,Sf,mf,gf,_f,yf,xf,cf]),wf=q({commitSha:W(),clientCommitSha:W(),parentCommitSha:W(),branch:W(),creator:W(),createdAt:W(),commitMessage:W().nullable()}),Tf=W().refine(function(e){return!0}),Ef=yu([q({type:J(`head`),headBaseSha:W()}),q({type:J(`patch`),patchId:Yd})]),Df=q({project:W().optional(),root:W().optional(),files:q({directory:W()}).optional(),gitCommit:W().optional(),gitBranch:W().optional()}),Of=yu([J(`image:add-metadata`),J(`image:check-metadata`),J(`image:check-remote`),J(`image:upload-remote`),J(`image:download-remote`),J(`images:check-remote`),J(`images:upload-remote`),J(`file:add-metadata`),J(`file:check-metadata`),J(`file:check-remote`),J(`file:upload-remote`),J(`file:download-remote`),J(`files:check-remote`),J(`files:upload-remote`),J(`keyof:check-keys`),J(`router:check-route`),J(`images:check-unique-folder`),J(`files:check-unique-folder`),J(`images:check-all-files`),J(`files:check-all-files`),J(`jsonValues:extract-entry`)]),kf=q({message:W(),value:pu().optional(),fatal:G().optional(),fixes:K(Of).optional()}),Af=q({status:J(401),json:q({message:W()})}),jf=q({status:J(404),json:q({message:W()})}),Mf=q({message:W()}),Nf=yu([q({patchId:Yd,message:W()}),q({parentPatchId:W(),message:W()})]),Pf=q({message:W(),path:Tf.optional()});yu([J(`val_session`),J(`val_enable`),J(`val_state`)]);var Ff=q({value:J(`true`),options:q({httpOnly:J(!1),sameSite:J(`lax`)})}),If=K(W()).max(1,`At most one query param is allowed`).transform(function(e){return e[0]}),Lf=If.refine(function(e){return e===`true`||e===`false`},`Value must be true or false`).transform(function(e){return e===`true`}),Rf=If.refine(function(e){return/^\d+$/.test(e)},`Value must be a non-negative whole number`).transform(function(e){return parseInt(e,10)}),zf={"/draft/enable":{GET:{req:{query:{redirect_to:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([q({status:J(401),json:Mf}),q({status:J(302),redirectTo:W()}),q({status:J(400),json:q({message:W()})})])}},"/draft/disable":{GET:{req:{query:{redirect_to:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([q({status:J(401),json:Mf}),q({status:J(302),redirectTo:W()}),q({status:J(400),json:q({message:W()})})])}},"/draft/stat":{GET:{req:{cookies:Sd({},Rd,W().optional())},res:yu([q({status:J(401),json:Mf}),q({status:J(200),json:q({draftMode:G()})})])}},"/enable":{GET:{req:{query:{redirect_to:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([q({status:J(401),json:Mf}),q({status:J(302),redirectTo:W(),cookies:q(Sd(Sd({},Bd,Ff),zd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`lax`),expires:td(Date)})})))}),q({status:J(302),redirectTo:W(),cookies:q(Sd({},Bd,Ff))}),q({status:J(400),json:q({message:W()})})])}},"/disable":{GET:{req:{query:{redirect_to:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([q({status:J(401),json:Mf}),q({status:J(302),redirectTo:W(),cookies:q(Sd({},Bd,q({value:J(`false`)})))}),q({status:J(400),json:q({message:W()})})])}},"/authorize":{GET:{req:{query:{redirect_to:If.optional()}},res:yu([q({status:J(302),redirectTo:W(),cookies:q(Sd(Sd({},Bd,Ff),zd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`lax`),expires:td(Date)})})))}),q({status:J(400),json:q({message:W()})})])}},"/callback":{GET:{req:{query:{code:If.optional(),state:If.optional()},cookies:Sd({},zd,W())},res:q({status:J(302),redirectTo:W(),cookies:q(Sd(Sd(Sd({},zd,q({value:J(null)})),Bd,Ff.optional()),Rd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`strict`),path:W(),secure:J(!0),expires:td(Date)}).optional()}).optional()))})}},"/session":{GET:{req:{cookies:{val_session:W().optional()}},res:yu([q({status:J(200),json:q({mode:yu([J(`local`),J(`proxy`)]),enabled:G()})}),q({status:yu([J(400),J(401),J(403),J(404),J(500),J(501)]),json:q({message:W()})}),q({status:J(401),json:q({message:W(),details:yu([W(),q({reason:W()}),q({sub:W(),exp:iu(),token:W(),org:W(),project:W()})])})}),q({status:J(500),json:q({message:W()})})])}},"/logout":{GET:{req:{query:{redirect_to:If.optional()}},res:yu([q({status:J(200),cookies:q(Sd(Sd({},Rd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`strict`),path:W(),secure:J(!0),expires:td(Date)}).optional()}).optional()),zd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`strict`),path:W(),secure:J(!0),expires:td(Date)}).optional()}).optional()))}),q({status:J(302),redirectTo:W(),cookies:q(Sd(Sd({},Rd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`strict`),path:W(),secure:J(!0),expires:td(Date)}).optional()}).optional()),zd,q({value:W(),options:q({httpOnly:J(!0),sameSite:J(`strict`),path:W(),secure:J(!0),expires:td(Date)}).optional()}).optional()))})])}},"/remote/settings":{GET:{req:{cookies:{val_session:W().optional()}},res:yu([q({status:J(200),json:q({publicProjectId:W(),coreVersion:W(),remoteFileBuckets:K(q({bucket:W()}))})}),q({status:J(400),json:q({errorCode:yu([J(`project-not-configured`),J(`error-could-not-get-settings`),J(`project-not-configured`),J(`pat-error`),J(`api-key-missing`)]),message:W()})}),q({status:J(401),json:q({errorCode:J(`unauthorized`).optional(),message:W()})}),q({status:J(500),json:q({message:W()})})])}},"/stat":{POST:{req:{body:q({sourcesSha:W(),schemaSha:W(),baseSha:W(),patches:K(W()).optional(),jsonEntriesSha:W().optional()}).nullable(),cookies:{val_session:W().optional()}},res:yu([q({status:J(401),json:Mf}),q({status:J(500),json:Mf}),q({status:J(503),json:Mf}),q({status:J(200),json:yu([q({type:yu([J(`request-again`),J(`no-change`),J(`did-change`)]),baseSha:W(),schemaSha:W(),sourcesSha:W(),patches:K(Yd),removed:K(q({patchId:Yd,reason:W()})).optional(),config:Df,profileId:W().nullable(),mode:yu([J(`http`),J(`fs`)]),jsonEntriesSha:W().optional()}),q({type:J(`use-websocket`),url:W(),nonce:W(),baseSha:W(),schemaSha:W(),sourcesSha:W(),commitSha:W(),patches:K(Yd),commits:K(wf),config:Df,profileId:W().nullable(),mode:yu([J(`http`),J(`fs`)])})])})])}},"/upload/patches":{POST:{req:{path:W().optional(),body:q({parentRef:Ef,filePath:W(),data:du(),type:yu([J(`file`),J(`image`)]),metadata:du(),remote:G()})},res:yu([q({status:J(400),json:Mf}),q({status:J(200),json:q({filePath:W(),patchId:Yd})})])}},"/direct-file-upload-settings":{POST:{req:{cookies:{val_session:W().optional()}},res:yu([q({status:J(400),json:Mf}),q({status:J(401),json:Mf}),q({status:J(500),json:Mf}),q({status:J(200),json:q({nonce:W().nullable(),baseUrl:W(),contentBaseUrl:W().nullable(),contentAuthNonce:W().nullable()})})])}},"/patches":{DELETE:{req:{query:{id:K(Yd).min(1,`At least one patch id is required`)},cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(500),json:q({message:W(),errors:K(Nf)})}),q({status:J(200),json:K(Yd)})])},PUT:{req:{body:q({parentRef:Ef,sessionId:W().nullish(),patches:K(q({path:Tf,patchId:Yd,patch:du()}))}),cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(409),json:q({type:J(`patch-head-conflict`),message:W()})}),q({status:J(400),json:q({type:J(`patch-error`),message:W(),errors:Eu(Tf,K(q({error:Mf})))})}),q({status:J(200),json:q({newPatchIds:K(Yd),parentRef:Ef})})])},GET:{req:{query:{patch_id:K(Yd).optional(),exclude_patch_ops:Lf.optional()},cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(500),json:q({message:W(),patchErrors:K(Nf)})}),q({status:J(500),json:q({message:W(),error:Mf})}),q({status:J(200),json:q({patches:K(q({path:Tf,patch:Jd.optional(),patchId:Yd,createdAt:W(),authorId:W().nullable(),appliedAt:q({commitSha:W()}).nullable()})),baseSha:W(),error:Mf.optional(),errors:Eu(Yd,Mf).optional()})})])}},"/schema":{GET:{req:{cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(500),json:q({message:W(),details:K(Pf)})}),q({status:J(500),json:q({message:W(),details:K(Mf)})}),q({status:J(200),json:q({schemaSha:W(),schemas:Eu(Tf,Cf)})})])}},"/sources/~":{PUT:{req:{path:W().optional(),query:{validate_sources:Lf.optional(),validate_binary_files:Lf.optional(),exclude_patches:Lf.optional(),apply_patches:Lf.optional()},cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(401),json:Mf}),q({status:J(500),json:q({message:W(),details:yu([K(Pf),Mf])})}),q({status:J(409),json:q({message:W()})}),q({status:J(400),json:q({message:W(),details:K(Pf)})}),q({status:J(200),json:q({schemaSha:W(),sourcesSha:W(),modules:Eu(Tf,q({preview:du().optional(),source:du().optional(),baseSource:du().optional(),patches:q({applied:K(Yd),skipped:K(Yd).optional(),errors:Eu(Yd,Mf).optional()}).optional(),validationErrors:Eu(W(),K(kf)).optional()}))})})])}},"/profiles":{GET:{req:{cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(500),json:Mf}),q({status:J(200),json:q({profiles:K(q({profileId:W(),fullName:W(),email:W().optional(),avatar:q({url:W()}).nullable()}))})})])}},"/save":{POST:{req:{body:q({message:W().optional(),patchIds:K(Yd)}),cookies:{val_session:W().optional()}},res:yu([Af,q({status:J(200),json:q({removed:K(q({patchId:Yd,moduleFilePath:Tf,message:W()})).optional()})}),q({status:J(409),json:q({message:W(),isNotFastForward:J(!0)})}),q({status:J(400),json:yu([q({message:W(),details:yu([q({sourceFilePatchErrors:Eu(Tf,K(Mf)),binaryFilePatchErrors:Eu(W(),Mf),unappliablePatches:Eu(Yd,q({moduleFilePath:Tf,message:W()})).optional()}),K(Mf)]).optional()}),q({message:W(),errorCode:yu([J(`project-not-configured`),J(`pat-error`)])})])})])}},"/files":{GET:{req:{path:W(),query:{patch_id:K(Yd).max(1,`At most one patch id is allowed`).transform(function(e){return e[0]}).optional(),remote:If.optional()}},res:yu([Af,jf,q({status:J(200),body:td(ReadableStream)})])}},"/json":{GET:{req:{query:{path:If,key:If.optional(),keys:K(W()).max(100).optional(),offset:Rf.optional(),limit:Rf.refine(function(e){return e>0&&e<=100},`limit must be between 1 and 100`).optional(),apply_patches:Lf.optional()},cookies:Sd({},Rd,W().optional())},res:yu([Af,jf,q({status:J(200),json:q({path:Tf,key:W(),content:du()})}),q({status:J(200),json:q({path:Tf,entries:K(q({key:W(),content:du()})),missing:K(W()),errors:K(q({key:W(),message:W()})),offset:iu().optional(),limit:iu().optional(),total:iu().optional()})}),q({status:J(400),json:Mf}),q({status:J(500),json:Mf})])}},"/ai/initialize":{POST:{req:{cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({nonce:W(),wsUrl:W(),providers:K(W()).optional(),models:K(q({provider:W(),model:W(),label:W(),contextWindow:iu().nullable().optional()})).optional()})}),q({status:J(500),json:Mf})])}},"/ai/sessions":{GET:{req:{query:{limit:If.optional(),cursor_updatedAt:If.optional(),cursor_id:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({sessions:K(q({id:W(),name:W().nullable(),createdAt:W(),updatedAt:W()})),nextCursor:q({updatedAt:W(),id:W()}).nullable().optional()})}),q({status:J(500),json:Mf})])},PATCH:{req:{path:W(),body:q({name:W()}),cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({})}),q({status:J(500),json:Mf})])}},"/ai/messages":{GET:{req:{path:W(),query:{limit:If.optional(),cursor_updatedAt:If.optional(),cursor_id:If.optional()},cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({messages:K(q({role:W(),content:yu([W(),K(yu([q({type:J(`text`),text:W()}),q({type:J(`image_url`),url:W()})]))])})),nextCursor:q({updatedAt:W(),id:W()}).nullable().optional()})}),q({status:J(500),json:Mf})])}},"/ai/session-image-to-patch-file":{POST:{req:{body:q({patchId:Yd,parentRef:Ef,files:K(q({filePath:W(),key:W(),isRemote:G().optional()})).min(1)}),cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({patchId:Yd,files:K(q({filePath:W(),metadata:q({width:iu(),height:iu(),mimeType:W()})}))})}),q({status:J(400),json:q({message:W(),details:q({availableKeys:K(W()).optional()}).optional()})}),q({status:J(500),json:Mf})])}},"/ai/images":{PATCH:{req:{body:q({key:W(),metadata:du(),contentType:W()}),cookies:Sd({},Rd,W().optional())},res:yu([Af,q({status:J(200),json:q({key:W()})}),q({status:J(500),json:Mf})])}}};function Bf(e){"@babel/helpers - typeof";return Bf=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Bf(e)}function Vf(e,t){return Bf(e)===`object`&&e!==null&&`message`in e&&typeof e.message==`string`?e.message:t}var Hf=function(e,t){var n=zf;return function(){var t=Wd(Hd().m(function t(r,i,a){var o,s,c,l,u,d,f,p,m,h,g,_,v,y,b;return Hd().w(function(t){for(;;)switch(t.p=t.n){case 0:if(s=a,c=r,s!=null&&s.path&&s.path.length>0&&(c+=s.path),s.query){for(l=[],u=0,d=Object.keys(s.query);u<d.length;u++)if(f=d[u],Array.isArray(s.query?.[f])){p=Dd(s.query?.[f]||[]);try{for(p.s();!(m=p.n()).done;)h=m.value,h!==void 0&&l.push([f,h.toString()])}catch(e){p.e(e)}finally{p.f()}}else s.query?.[f]!==void 0&&l.push([f,s==null||(g=s.query)==null?void 0:g[f].toString()]);s!=null&&s.query&&l.length>0&&(c+=`?${new URLSearchParams(l).toString()}`)}if(_=n==null||(o=n[r])==null?void 0:o[i],_){t.n=1;break}return t.a(2,{status:null,json:{message:`Invalid route ${r} with method ${i}. This is most likely a Val bug.`,type:`client_side_validation_error`,details:{validationError:`Route ${r} with method ${i} not found.`,data:{routes:Object.keys(n||{}),methods:Object.keys(n?.[r]||{}),route:r,method:i}}}});case 1:if(v=_.req.body?.safeParse(s.body),!(v&&!v.success)){t.n=2;break}return console.error(`Got an invalid request body while validating client-side. This is most likely a Val bug.`,{path:r,method:i,body:s.body,error:v.error}),t.a(2,{status:null,json:{message:`There was an issue validating your data. This is most likely a Val bug.`,type:`client_side_validation_error`,details:{validationError:yd(v.error).toString(),data:s.body}}});case 2:return t.p=2,t.n=3,fetch(`${e}${c}`,{method:i,headers:{"Content-Type":`application/json`},body:s.body===void 0?void 0:JSON.stringify(s.body)}).then(function(){var e=Wd(Hd().m(function e(t){var n,a,o,s,c;return Hd().w(function(e){for(;;)switch(e.n){case 0:if(n=t.headers.get(`content-type`),t.status!==413){e.n=1;break}return e.a(2,{status:413,json:{message:`Request too large.`,method:i,path:r}});case 1:if(n!=null&&n.includes(`application/json`)){e.n=2;break}return e.a(2,{status:null,json:{type:`client_side_validation_error`,message:`Invalid response (expected JSON, but got something else). This could be a result of mismatched Val versions or a transient error. ${t.status}`,details:{validationError:`Invalid content type`,data:{status:t.status,contentType:n}}}});case 2:return e.n=3,t.json();case 3:if(a=e.v,o={status:t.status,json:a},t.status!==500){e.n=4;break}return console.error(`Server responded with an error`,a),s=Vf(a,`Unknown error`),e.a(2,{status:500,json:{type:`unknown`,message:s}});case 4:if(c=_.res?.safeParse(o),!(c&&!c.success)){e.n=5;break}return e.a(2,{status:null,json:{message:`Response could not be validated. This could also be a result of mismatched Val versions.`,type:`client_side_validation_error`,details:{validationError:yd(c.error).toString(),data:o}}});case 5:return e.a(2,{status:t.status,json:a})}},e)}));return function(t){return e.apply(this,arguments)}}());case 3:return y=t.v,t.a(2,y);case 4:return t.p=4,b=t.v,t.a(2,{status:null,json:{message:`Failed to fetch data`,type:`network_error`,retryable:Uf(b),details:b instanceof Error?b.message:JSON.stringify(b)}})}},t,null,[[2,4]])}));return function(e,n,r){return t.apply(this,arguments)}}()};function Uf(e){if(e instanceof TypeError)return!0;if(e instanceof Error&&`code`in e){var t=e.code;return[`ECONNRESET`,`ETIMEDOUT`,`ENOTFOUND`,`EAI_AGAIN`].includes(t)}return!1}function Wf(e){if(Array.isArray(e))return e}function Gf(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Kf(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
78
78
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qf(e,t){return Wf(e)||Gf(e,t)||Ed(e,t)||Kf()}var Jf=function(){var e=arguments.length<=0?void 0:arguments[0],t=arguments.length<=1?void 0:arguments[1];if(t){var n=Object.entries(t).flatMap(function(e){var t=qf(e,2),n=t[0],r=t[1];return r?[[n,r.toString()]]:[]}),r=new URLSearchParams(n);return`${e+`?`+r.toString()}`}return`${e}`},Yf=`val-config`,Xf=`val-theme`,Zf=`val-ai-session`,Qf=q({contentHostUrl:W().optional(),appHostUrl:W().optional(),project:W().optional(),root:W().optional(),gitCommit:W().optional(),gitBranch:W().optional(),defaultTheme:Ou([`dark`,`light`]).optional(),ai:q({commitMessages:q({disabled:G().optional()}).optional(),chat:q({experimental:q({enable:G().optional()}).optional(),suggestions:K(W()).optional(),title:W().optional(),description:W().optional()}).optional()}).optional()}),$f=q({deploymentId:W(),deploymentState:W(),commitSha:W(),updatedAt:W(),createdAt:W()});function ep(e,t){var n={type:`node`,name:`/`,children:[]},r=Dd(t),i;try{var a=function(){var t=i.value,r=t.urlPath,a=t.moduleFilePath;if(!r.startsWith(`/`))return console.error(`urlPath must start with /: ${r}`),0;var o=tp(a,e);if(r===`/`){var s=`/`;return n.pattern=tp(a,e),n.page={fullPath:s},n.sourcePath=H.joinModuleFilePathAndModulePath(a,`"${s}"`),n.moduleFilePath=a,0}var c=r.split(`/`).slice(1).filter(Boolean),l=n;c.forEach(function(e,t){var n=t<c.length-1,r=t===c.length-1,i=`/`+c.slice(0,t+1).join(`/`),s=H.joinModuleFilePathAndModulePath(a,`"${i}"`),u=n?wd(wd({type:`node`,name:e,pattern:o,moduleFilePath:a},r?{page:{fullPath:i},sourcePath:s}:{}),{},{children:[]}):{type:`leaf`,name:e,pattern:o,fullPath:i,moduleFilePath:a,sourcePath:s,children:[]},d=l.children.findIndex(function(t){return t.name===e});if(d===-1)l.children.push(u),l.type===`node`&&(l.isLinear=!0,l.children.length>1&&delete l.isLinear),l=u;else{var f=l.children[d];if(f.type===`leaf`&&n){var p=f.sourcePath;l.children[d]={type:`node`,name:e,pattern:o,page:{fullPath:i},sourcePath:p,children:f.children,moduleFilePath:a},l=l.children[d]}else f.type===`node`&&r?(f.page={fullPath:i},f.sourcePath=s,f.moduleFilePath=a,f.pattern=o):l=l.children[d]}})};for(r.s();!(i=r.n()).done;)a()}catch(e){r.e(e)}finally{r.f()}return n}function tp(e,t){return e.replace(t,``).replace(/\/\([^/]+\)/g,``).replace(`/page.val.ts`,``).replace(`/page.val.js`,``)}function np(e){return e===``||e===`/`?[]:(e.startsWith(`/`)?e.slice(1):e).split(`/`).map(function(e){var t=e.startsWith(`[[`)&&e.endsWith(`]]`),n=e.startsWith(`[`)&&e.endsWith(`]`),r=t?2:+!!n,i=e.indexOf(`]`,r),a=e.slice(r,r+3)===`...`,o=e.slice(r+(a?3:0),i);return t||n?a?{type:`array-param`,paramName:o,optional:t}:{type:`string-param`,paramName:o,optional:t}:{type:`literal`,name:e}})}function rp(e){return e.startsWith(`/app`)?`/app`:e.startsWith(`/src/app`)?`/src/app`:null}function ip(e,t,n){var r=null,i=null;if(t)try{r=new RegExp(t.source,t.flags)}catch(e){console.warn(`[Val] Invalid include pattern: /${t.source}/${t.flags}`,`
|
|
79
79
|
Error: ${e instanceof Error?e.message:String(e)}`,`
|
|
80
80
|
All routes will be filtered out due to malformed include pattern.`)}if(n)try{i=new RegExp(n.source,n.flags)}catch(e){console.warn(`[Val] Invalid exclude pattern: /${n.source}/${n.flags}`,`
|
|
81
81
|
Error: ${e instanceof Error?e.message:String(e)}`,`
|
|
82
|
-
All routes will be filtered out due to malformed exclude pattern.`)}return e.filter(function(e){return!(t&&(!r||!r.test(e))||n&&(!i||i.test(e)))})}function ap(e,t,n){if(t)try{if(!new RegExp(t.source,t.flags).test(e))return{valid:!1,message:`Route '${e}' does not match include pattern: /${t.source}/${t.flags}`}}catch(e){return{valid:!1,message:`Invalid include pattern: ${e instanceof Error?e.message:String(e)}`}}if(n)try{if(new RegExp(n.source,n.flags).test(e))return{valid:!1,message:`Route '${e}' matches exclude pattern: /${n.source}/${n.flags}`}}catch(e){return{valid:!1,message:`Invalid exclude pattern: ${e instanceof Error?e.message:String(e)}`}}return{valid:!0}}var op=`This is most likely a Val version mismatch or Val bug.`;function sp(e,t){var n=new Map;for(var r in e){var i=r,a=e[i],o=t[i];if(a&&a.type===`record`&&a.router&&o&&Bf(o)===`object`&&!Array.isArray(o))for(var s in o)n.has(s)||n.set(s,i)}return Array.from(n.entries()).map(function(e){var t=qf(e,2);return{route:t[0],moduleFilePath:t[1]}}).sort(function(e,t){return e.route.localeCompare(t.route)})}var cp=function(e,t){var n=[e.length,t.length],r=n[0],i=n[1];if(!r||!i)return Math.max(r,i);for(var a=Array.from({length:r+1},function(e,t){return t}),o=1;o<=i;o++){var s=a[0];a[0]=o;for(var c=1;c<=r;c++){var l=a[c];a[c]=e[c-1]===t[o-1]?s:Math.min(s+1,a[c-1]+1,a[c]+1),s=l}}return a[r]};function lp(e,t){return t.map(function(t){return{target:t,distance:cp(e,t)}}).sort(function(e,t){return e.distance-t.distance})}function up(e,t){var n=qf(H.splitModuleFilePathAndModulePath(e),2),r=n[0],i=n[1],a=t.sources[r],o=t.schemas[r];if(!o||a===void 0)return{source:void 0,schema:void 0};if(!i)return{source:a,schema:o};var s=a,c=o,l=Dd(H.splitModulePath(i)),u;try{for(l.s();!(u=l.n()).done;){var d=u.value;s=s&&Bf(s)===`object`&&!Array.isArray(s)&&d in s?s[d]:void 0,c=c&&c.type===`object`&&c.items[d]?c.items[d]:c&&c.type===`record`?c.item:void 0}}catch(e){l.e(e)}finally{l.f()}return{source:s,schema:c}}function dp(e,t,n){var r=up(t,n),i=r.source,a=r.schema;if(a&&a.type!==`record`)return{error:!0,message:`Expected key at ${t} to be of type 'record'`};if(i&&Bf(i)===`object`&&!Array.isArray(i)&&e in i)return{error:!1};if(!i||Bf(i)!==`object`||Array.isArray(i))return{error:!0,message:`Expected ${t} to be a truthy object`};var o=lp(e,Object.keys(i));return o.length===0?{error:!0,message:`Key '${e}' does not exist in ${t}.`}:{error:!0,message:`Key '${e}' does not exist in ${t}. Closest match: '${o[0].target}'. Other similar: ${o.slice(1,4).map(function(e){return`'${e.target}'`}).join(`, `)}${o.length>4?`, ...`:``}`}}function fp(e,t,n,r){var i={};for(var a in r.schemas){var o=a,s=r.schemas[o];if(s?.type===`record`&&s.router){var c=r.sources[o];c&&Bf(c)===`object`&&!Array.isArray(c)&&(i[o]=Object.keys(c))}}for(var l=Object.entries(i),u=null,d=0,f=l;d<f.length;d++){var p=qf(f[d],2),m=p[0];if(p[1].includes(e)){u=m;break}}if(!u){var h=l.flatMap(function(e){return qf(e,2)[1]});if(h.length===0)return{error:!0,message:`Route '${e}' could not be validated: No router modules found in the project. Use s.record(...).router(...) to define router modules.`};h=ip(h,t,n);var g=lp(e,h);return{error:!0,message:`Route '${e}' does not exist in any router module. ${g.length>0?`Closest match: '${g[0].target}'. Other similar: ${g.slice(1,4).map(function(e){return`'${e.target}'`}).join(`, `)}${g.length>4?`, ...`:``}`:`No similar routes found.`}`}}var _=ap(e,t,n);return _.valid?{error:!1}:{error:!0,message:_.message}}function pp(e,t){var n=e.fixes??[];if(n.includes(`keyof:check-keys`)){if(!e.value)return{status:`remaining`,error:wd(wd({},e),{},{message:`Could not find a value for keyOf. ${op}`,typeError:!0,fixes:void 0})};if(Bf(e.value)!==`object`)return{status:`remaining`,error:wd(wd({},e),{},{message:`Expected keyOf validation error to have a 'value' property of type 'object'. Found: ${Bf(e.value)}. ${op}`,typeError:!0,fixes:void 0})};var r=e.value,i=r.key,a=r.sourcePath;if(typeof i!=`string`)return{status:`remaining`,error:wd(wd({},e),{},{message:`Expected keyOf validation error 'value' to have property 'key' of type 'string'. Found: ${Bf(i)}. ${op}`,typeError:!0,fixes:void 0})};if(typeof a!=`string`)return{status:`remaining`,error:wd(wd({},e),{},{message:`Expected keyOf validation error 'value' to have property 'sourcePath' of type 'string'. Found: ${Bf(a)}. ${op}`,typeError:!0,fixes:void 0})};var o=dp(i,a,t);return o.error?{status:`remaining`,error:wd(wd({},e),{},{message:o.message,fixes:void 0})}:{status:`resolved`}}if(n.includes(`router:check-route`)){if(!e.value)return{status:`remaining`,error:wd(wd({},e),{},{message:`Could not find a value for route. ${op}`,typeError:!0,fixes:void 0})};if(Bf(e.value)!==`object`)return{status:`remaining`,error:wd(wd({},e),{},{message:`Expected route validation error to have a 'value' property of type 'object'. Found: ${Bf(e.value)}. ${op}`,typeError:!0,fixes:void 0})};var s=e.value,c=s.route;if(typeof c!=`string`)return{status:`remaining`,error:wd(wd({},e),{},{message:`Expected route validation error 'value' to have property 'route' of type 'string'. Found: ${Bf(c)}. ${op}`,typeError:!0,fixes:void 0})};var l=fp(c,mp(s.include),mp(s.exclude),t);return l.error?{status:`remaining`,error:wd(wd({},e),{},{message:l.message,fixes:void 0})}:{status:`resolved`}}return null}function mp(e){if(e&&Bf(e)===`object`&&`source`in e&&`flags`in e&&typeof e.source==`string`&&typeof e.flags==`string`)return e}function hp(e,t){var n={};for(var r in e){var i=r,a=[],o=Dd(e[i]),s;try{for(o.s();!(s=o.n()).done;){var c=s.value,l=pp(c,t);l===null?a.push(c):l.status===`remaining`&&a.push(l.error)}}catch(e){o.e(e)}finally{o.f()}a.length>0&&(n[i]=a)}return n}var gp=`val_canvas`,_p=`val-canvas`;function vp(e){if(Bf(e)!==`object`||e===null)return!1;var t=e;return t.val===`val-canvas`?t.type===`ready`||t.type===`elements`||t.type===`clicked`||t.type===`pinch`||t.type===`zoom`||t.type===`refreshing`:!1}function yp(e){return`${e}${e.includes(`?`)?`&`:`?`}${gp}=1`}function bp(e){return`${String(e.getFullYear()).padStart(4,`0`)}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function xp(e,t){return t!=null&&t.to&&e>t.to?t.to:t!=null&&t.from&&e<t.from?t.from:e}function Sp(e,t){if(!t)return e;var n=Date.parse(e);if(Number.isNaN(n))return e;if(t.to){var r=Date.parse(t.to);if(!Number.isNaN(r)&&n>r)return new Date(r).toISOString()}if(t.from){var i=Date.parse(t.from);if(!Number.isNaN(i)&&n<i)return new Date(i).toISOString()}return e}function Cp(e){if(e.type===`object`)return Object.fromEntries(Object.keys(e.items).map(function(t){return[t,Cp(e.items[t])]}));if(e.type===`array`)return[];if(e.type===`record`)return{};if(e.opt)return null;if(e.type===`richtext`)return[];if(e.type===`string`)return``;if(e.type===`boolean`)return!1;if(e.type===`number`)return 0;if(e.type===`keyOf`)return e.values===`string`?``:e.values[0];if(e.type===`route`)return``;if(e.type===`file`||e.type===`image`)return null;if(e.type===`literal`)return e.value;if(e.type===`union`)return typeof e.key==`string`?Cp(e.items[0]):e.key.value;if(e.type===`date`)return xp(bp(new Date),e.options);if(e.type===`dateTime`)return Sp(new Date().toISOString(),e.options);if(e.type===`color`)return H.color.formatColor({r:128,g:128,b:128,a:1},e.options?.format??`hsl`);if(e.type===`code`)return``;throw Error(`Unexpected schema type: `+JSON.stringify(e))}function wp(e,t){return wd({path:e},t)}function Tp(e,t){var n=e,r=Dd(t),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;if(n==null)return;if(Array.isArray(n)){var o=Number(a);if(!Number.isInteger(o))return;n=n[o]}else if(Bf(n)===`object`)n=n[a];else return}}catch(e){r.e(e)}finally{r.f()}return n}function Ep(e,t){for(var n=e,r=0;r<t.length;r++){var i=t[r];if(n.type===`object`){var a=n.items[i];if(!a)return{kind:`unresolved`};n=a}else if(n.type===`array`)n=n.item;else if(n.type===`record`){if(n.mediaType===`images`)return{kind:`gallery-traversed`,schema:n};n=n.item}else if(n.type===`richtext`)return{kind:`richtext`,schema:n,remainingPath:t.slice(r)};else if(n.type===`union`){if(typeof n.key==`string`){var o=Dd(n.items),s;try{for(o.s();!(s=o.n()).done;){var c=s.value,l=Ep(c,t.slice(r));if(l.kind!==`unresolved`)return l}}catch(e){o.e(e)}finally{o.f()}return{kind:`unresolved`}}return{kind:`unresolved`}}else return{kind:`unresolved`}}return{kind:`leaf`,schema:n}}function Dp(e){var t;if(e.type!==`richtext`)return{kind:`not-allowed`};var n=(t=e.options)==null||(t=t.inline)==null?void 0:t.img;return n?n===!0?{kind:`allowed`,remote:!1}:{kind:`allowed`,remote:n.remote===!0}:{kind:`not-allowed`}}function Op(e){return e.type===`image`||e.type===`file`||e.type===`record`?e.remote===!0:!1}function kp(e){var t=Jd.safeParse(e);return t.success?{kind:`ok`,patch:t.data}:{kind:`error`,message:`Built patch failed schema validation: ${JSON.stringify(t.error)}`}}function Ap(e){return e.type===`record`&&e.mediaType===`images`?null:e.type===`image`?{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Module is a plain image field, not an images gallery. Use create_patch with a SessionKey value.`}:e.type===`richtext`?{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Module is a richtext, not an images gallery. Use create_patch with a SessionKey inside a {tag:'img', src: SessionKey} node.`}:{kind:`error`,message:`Module schema is not an images gallery (expected record with mediaType="images", got '${e.type}').`}}function jp(e,t){var n=Ap(t);if(n)return n;var r=Op(t);return kp([{op:`add`,path:[e.filePath],value:wd({},e.metadata)},{op:`file`,path:[e.filePath],filePath:e.filePath,value:e.imageKey,remote:r,metadata:e.metadata}])}function Mp(e,t,n){var r=Ap(t);if(r)return r;if(!n||Bf(n)!==`object`||Array.isArray(n))return{kind:`error`,message:`Cannot remove from gallery: module source is not an object.`};var i=n;if(!Object.prototype.hasOwnProperty.call(i,e.filePath)){var a=Object.keys(i),o=a.length>0?` Available entries: ${a.map(function(e){return`"${e}"`}).join(`, `)}.`:` The gallery is empty.`;return{kind:`error`,message:`No gallery entry with file_path "${e.filePath}".${o}`}}var s=H.remote.splitRemoteRef(e.filePath).status===`success`;return kp([{op:`remove`,path:[e.filePath]},{op:`file`,path:[e.filePath],filePath:e.filePath,value:null,remote:s}])}var Np={kind:`wrong-tool`,suggestedTool:`add_session_image_to_gallery`,reason:`Destination is a media gallery (s.images() / s.files()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery.`};function Pp(e){return e.type===`record`&&e.mediaType!==void 0}function Fp(e,t){var n=Ep(e,t);if(n.kind===`gallery-traversed`)return Np;if(n.kind===`richtext`)return{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Destination is a richtext value. duplicate_source and empty_at_path do not handle richtext edits.`};if(n.kind===`leaf`){if(Pp(n.schema))return Np;if(n.schema.type===`richtext`)return{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Destination is a richtext value. duplicate_source and empty_at_path do not handle richtext edits.`}}if(t.length===0)return{kind:`ok`,op:`replace`,parent:`module`};var r=Ep(e,t.slice(0,-1));if(r.kind===`unresolved`)return{kind:`error`,message:`Destination parent path ${JSON.stringify(t.slice(0,-1))} does not resolve in this module's schema.`};if(r.kind===`richtext`)return{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Destination is inside a richtext value. duplicate_source and empty_at_path do not handle richtext edits.`};if(r.kind===`gallery-traversed`||Pp(r.schema))return Np;var i=r.schema;return i.type===`array`||i.type===`record`?{kind:`ok`,op:`add`,parent:i.type}:i.type===`object`?{kind:`ok`,op:`replace`,parent:`object`}:{kind:`error`,message:`Destination parent has schema type "${i.type}" — cannot use duplicate_source/empty_at_path here. Use create_patch instead.`}}function Ip(e,t,n){var r=Tp(n,e.sourcePath);if(r===void 0)return{kind:`error`,message:`Source path ${JSON.stringify(e.sourcePath)} does not exist in the module. Use get_source to inspect the current contents.`};var i=Fp(t,e.destinationPath);return i.kind===`wrong-tool`?{kind:`wrong-tool`,suggestedTool:i.suggestedTool,reason:i.reason}:i.kind===`error`?{kind:`error`,message:i.message}:Lp(i.parent,n,e.destinationPath)||kp([{op:i.op,path:e.destinationPath,value:r}])}function Lp(e,t,n){if(e!==`record`||Tp(t,n)===void 0)return null;var r=n[n.length-1];return{kind:`error`,message:`Destination key ${JSON.stringify(r)} already exists, and writing to it would replace the entry that is there. Pick a key that is free -- get_record_keys lists the ones in use -- or use create_patch if you meant to change the existing entry.`}}function Rp(e,t,n){var r;if(e.destinationPath.length===0)r=t;else{var i=Ep(t,e.destinationPath);if(i.kind===`unresolved`)return{kind:`error`,message:`Destination path ${JSON.stringify(e.destinationPath)} does not resolve in this module's schema.`};if(i.kind===`richtext`)return{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Destination is a richtext value. Use create_patch to build richtext content.`};if(i.kind===`gallery-traversed`)return{kind:`wrong-tool`,suggestedTool:`add_session_image_to_gallery`,reason:`Destination is inside an images gallery. Use add_session_image_to_gallery to add entries.`};r=i.schema}var a=Fp(t,e.destinationPath);if(a.kind===`wrong-tool`)return{kind:`wrong-tool`,suggestedTool:a.suggestedTool,reason:a.reason};if(a.kind===`error`)return{kind:`error`,message:a.message};var o=Lp(a.parent,n,e.destinationPath);if(o)return o;var s=Cp(r);return kp([{op:a.op,path:e.destinationPath,value:s}])}function zp(e,t,n){var r=Tp(t,n);if(r===void 0)return{kind:`error`,reason:`missing`,message:`Path ${JSON.stringify(n)} does not exist in the module source. Use get_source to inspect the current contents.`};var i=Ep(e,n);if(i.kind===`unresolved`)return{kind:`error`,reason:`missing`,message:`Path ${JSON.stringify(n)} does not resolve in this module's schema.`};if(i.kind===`richtext`)return{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} points inside a richtext value, which has no entries to count or list.`};if(i.kind===`gallery-traversed`)return{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} points inside a gallery entry, which has no entries to count or list.`};var a=i.schema;return a.type===`richtext`?Array.isArray(r)?{kind:`ok`,container:`richtext`,value:r}:{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} is a richtext value but its source is not a block array.`}:a.type===`array`?Array.isArray(r)?{kind:`ok`,container:`array`,value:r}:{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} is an array in the schema but its source is not an array.`}:a.type===`record`||a.type===`object`?r===null||Bf(r)!==`object`||Array.isArray(r)?{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} points to a ${r===null?`null`:Array.isArray(r)?`array`:Bf(r)} value, which has no entries to count or list.`}:{kind:`ok`,container:a.type===`record`?Pp(a)?`gallery`:`record`:`object`,value:r}:{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} points to a "${a.type}" value, which has no entries to count or list.`}}function Bp(e){var t={},n={};for(var r in e){var i=r,a=Dd(e[i]),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;Vp(s)?(n[i]??(n[i]=[])).push(s):(t[i]??(t[i]=[])).push(s)}}catch(e){a.e(e)}finally{a.f()}}return{surfaced:t,skipped:n}}function Vp(e){var t=e.fixes??[];return t.length!==0&&t.every(Hp)}function Hp(e){switch(e){case`image:add-metadata`:case`image:check-metadata`:case`image:upload-remote`:case`image:download-remote`:case`image:check-remote`:case`images:check-remote`:case`images:upload-remote`:case`file:add-metadata`:case`file:check-metadata`:case`file:upload-remote`:case`file:download-remote`:case`file:check-remote`:case`files:check-remote`:case`files:upload-remote`:case`images:check-unique-folder`:case`files:check-unique-folder`:case`images:check-all-files`:case`files:check-all-files`:return!0;case`keyof:check-keys`:case`router:check-route`:case`jsonValues:extract-entry`:return!1;default:return!1}}function Up(e,t,n){return Bp(hp(e,{schemas:t??{},sources:n??{}})).surfaced}function Wp(e){return Array.isArray(e)}function ree(e){let t=Gp(e);if(t===void 0)return`Could not load profiles`;let n=t.indexOf(`{`);if(n===-1)return t;let r;try{r=JSON.parse(t.slice(n))}catch{return t}return Gp(r)??t}function Gp(e){if(typeof e!=`object`||!e||!(`message`in e))return;let t=e.message;return typeof t==`string`?t:void 0}function iee(e){switch(e.reason){case`validation-errors`:return{message:`Cannot publish: some modules have validation errors.`,details:e.modules.join(`
|
|
82
|
+
All routes will be filtered out due to malformed exclude pattern.`)}return e.filter(function(e){return!(t&&(!r||!r.test(e))||n&&(!i||i.test(e)))})}function ap(e,t,n){if(t)try{if(!new RegExp(t.source,t.flags).test(e))return{valid:!1,message:`Route '${e}' does not match include pattern: /${t.source}/${t.flags}`}}catch(e){return{valid:!1,message:`Invalid include pattern: ${e instanceof Error?e.message:String(e)}`}}if(n)try{if(new RegExp(n.source,n.flags).test(e))return{valid:!1,message:`Route '${e}' matches exclude pattern: /${n.source}/${n.flags}`}}catch(e){return{valid:!1,message:`Invalid exclude pattern: ${e instanceof Error?e.message:String(e)}`}}return{valid:!0}}var op=`This is most likely a Val version mismatch or Val bug.`;function sp(e,t){var n=new Map;for(var r in e){var i=r,a=e[i],o=t[i];if(a&&a.type===`record`&&a.router&&o&&Bf(o)===`object`&&!Array.isArray(o))for(var s in o)n.has(s)||n.set(s,i)}return Array.from(n.entries()).map(function(e){var t=qf(e,2);return{route:t[0],moduleFilePath:t[1]}}).sort(function(e,t){return e.route.localeCompare(t.route)})}var cp=function(e,t){var n=[e.length,t.length],r=n[0],i=n[1];if(!r||!i)return Math.max(r,i);for(var a=Array.from({length:r+1},function(e,t){return t}),o=1;o<=i;o++){var s=a[0];a[0]=o;for(var c=1;c<=r;c++){var l=a[c];a[c]=e[c-1]===t[o-1]?s:Math.min(s+1,a[c-1]+1,a[c]+1),s=l}}return a[r]};function lp(e,t){return t.map(function(t){return{target:t,distance:cp(e,t)}}).sort(function(e,t){return e.distance-t.distance})}function up(e,t){var n=qf(H.splitModuleFilePathAndModulePath(e),2),r=n[0],i=n[1],a=t.sources[r],o=t.schemas[r];if(!o||a===void 0)return{source:void 0,schema:void 0};if(!i)return{source:a,schema:o};var s=a,c=o,l=Dd(H.splitModulePath(i)),u;try{for(l.s();!(u=l.n()).done;){var d=u.value;s=s&&Bf(s)===`object`&&!Array.isArray(s)&&d in s?s[d]:void 0,c=c&&c.type===`object`&&c.items[d]?c.items[d]:c&&c.type===`record`?c.item:void 0}}catch(e){l.e(e)}finally{l.f()}return{source:s,schema:c}}function dp(e,t,n){var r=up(t,n),i=r.source,a=r.schema;if(a&&a.type!==`record`)return{error:!0,message:`Expected key at ${t} to be of type 'record'`};if(i&&Bf(i)===`object`&&!Array.isArray(i)&&e in i)return{error:!1};if(!i||Bf(i)!==`object`||Array.isArray(i))return{error:!0,message:`Expected ${t} to be a truthy object`};var o=lp(e,Object.keys(i));return o.length===0?{error:!0,message:`Key '${e}' does not exist in ${t}.`}:{error:!0,message:`Key '${e}' does not exist in ${t}. Closest match: '${o[0].target}'. Other similar: ${o.slice(1,4).map(function(e){return`'${e.target}'`}).join(`, `)}${o.length>4?`, ...`:``}`}}function fp(e,t,n,r){var i={};for(var a in r.schemas){var o=a,s=r.schemas[o];if(s?.type===`record`&&s.router){var c=r.sources[o];c&&Bf(c)===`object`&&!Array.isArray(c)&&(i[o]=Object.keys(c))}}for(var l=Object.entries(i),u=null,d=0,f=l;d<f.length;d++){var p=qf(f[d],2),m=p[0];if(p[1].includes(e)){u=m;break}}if(!u){var h=l.flatMap(function(e){return qf(e,2)[1]});if(h.length===0)return{error:!0,message:`Route '${e}' could not be validated: No router modules found in the project. Use s.record(...).router(...) to define router modules.`};h=ip(h,t,n);var g=lp(e,h);return{error:!0,message:`Route '${e}' does not exist in any router module. ${g.length>0?`Closest match: '${g[0].target}'. Other similar: ${g.slice(1,4).map(function(e){return`'${e.target}'`}).join(`, `)}${g.length>4?`, ...`:``}`:`No similar routes found.`}`}}var _=ap(e,t,n);return _.valid?{error:!1}:{error:!0,message:_.message}}function pp(e,t){var n=e.fixes??[];if(n.includes(`keyof:check-keys`)){if(!e.value)return{status:`remaining`,error:wd(wd({},e),{},{message:`Could not find a value for keyOf. ${op}`,typeError:!0,fixes:void 0})};if(Bf(e.value)!==`object`)return{status:`remaining`,error:wd(wd({},e),{},{message:`Expected keyOf validation error to have a 'value' property of type 'object'. Found: ${Bf(e.value)}. ${op}`,typeError:!0,fixes:void 0})};var r=e.value,i=r.key,a=r.sourcePath;if(typeof i!=`string`)return{status:`remaining`,error:wd(wd({},e),{},{message:`Expected keyOf validation error 'value' to have property 'key' of type 'string'. Found: ${Bf(i)}. ${op}`,typeError:!0,fixes:void 0})};if(typeof a!=`string`)return{status:`remaining`,error:wd(wd({},e),{},{message:`Expected keyOf validation error 'value' to have property 'sourcePath' of type 'string'. Found: ${Bf(a)}. ${op}`,typeError:!0,fixes:void 0})};var o=dp(i,a,t);return o.error?{status:`remaining`,error:wd(wd({},e),{},{message:o.message,fixes:void 0})}:{status:`resolved`}}if(n.includes(`router:check-route`)){if(!e.value)return{status:`remaining`,error:wd(wd({},e),{},{message:`Could not find a value for route. ${op}`,typeError:!0,fixes:void 0})};if(Bf(e.value)!==`object`)return{status:`remaining`,error:wd(wd({},e),{},{message:`Expected route validation error to have a 'value' property of type 'object'. Found: ${Bf(e.value)}. ${op}`,typeError:!0,fixes:void 0})};var s=e.value,c=s.route;if(typeof c!=`string`)return{status:`remaining`,error:wd(wd({},e),{},{message:`Expected route validation error 'value' to have property 'route' of type 'string'. Found: ${Bf(c)}. ${op}`,typeError:!0,fixes:void 0})};var l=fp(c,mp(s.include),mp(s.exclude),t);return l.error?{status:`remaining`,error:wd(wd({},e),{},{message:l.message,fixes:void 0})}:{status:`resolved`}}return null}function mp(e){if(e&&Bf(e)===`object`&&`source`in e&&`flags`in e&&typeof e.source==`string`&&typeof e.flags==`string`)return e}function hp(e,t){var n={};for(var r in e){var i=r,a=[],o=Dd(e[i]),s;try{for(o.s();!(s=o.n()).done;){var c=s.value,l=pp(c,t);l===null?a.push(c):l.status===`remaining`&&a.push(l.error)}}catch(e){o.e(e)}finally{o.f()}a.length>0&&(n[i]=a)}return n}var gp=`val_canvas`,_p=`val-canvas`;function vp(e){if(Bf(e)!==`object`||e===null)return!1;var t=e;return t.val===`val-canvas`?t.type===`ready`||t.type===`elements`||t.type===`clicked`||t.type===`pinch`||t.type===`zoom`||t.type===`refreshing`:!1}function yp(e){return`${e}${e.includes(`?`)?`&`:`?`}${gp}=1`}function bp(e){return`${String(e.getFullYear()).padStart(4,`0`)}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function xp(e,t){return t!=null&&t.to&&e>t.to?t.to:t!=null&&t.from&&e<t.from?t.from:e}function Sp(e,t){if(!t)return e;var n=Date.parse(e);if(Number.isNaN(n))return e;if(t.to){var r=Date.parse(t.to);if(!Number.isNaN(r)&&n>r)return new Date(r).toISOString()}if(t.from){var i=Date.parse(t.from);if(!Number.isNaN(i)&&n<i)return new Date(i).toISOString()}return e}function Cp(e){if(e.type===`object`)return Object.fromEntries(Object.keys(e.items).map(function(t){return[t,Cp(e.items[t])]}));if(e.type===`array`)return[];if(e.type===`record`)return{};if(e.opt)return null;if(e.type===`richtext`)return[];if(e.type===`string`)return``;if(e.type===`boolean`)return!1;if(e.type===`number`)return 0;if(e.type===`keyOf`)return e.values===`string`?``:e.values[0];if(e.type===`route`)return``;if(e.type===`file`||e.type===`image`)return null;if(e.type===`literal`)return e.value;if(e.type===`union`)return typeof e.key==`string`?Cp(e.items[0]):e.key.value;if(e.type===`date`)return xp(bp(new Date),e.options);if(e.type===`dateTime`)return Sp(new Date().toISOString(),e.options);if(e.type===`color`)return H.color.formatColor({r:128,g:128,b:128,a:1},e.options?.format??`hsl`);if(e.type===`code`)return``;throw Error(`Unexpected schema type: `+JSON.stringify(e))}function wp(e,t){return wd({path:e},t)}function Tp(e,t){var n=e,r=Dd(t),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;if(n==null)return;if(Array.isArray(n)){var o=Number(a);if(!Number.isInteger(o))return;n=n[o]}else if(Bf(n)===`object`)n=n[a];else return}}catch(e){r.e(e)}finally{r.f()}return n}function Ep(e,t){for(var n=e,r=0;r<t.length;r++){var i=t[r];if(n.type===`object`){var a=n.items[i];if(!a)return{kind:`unresolved`};n=a}else if(n.type===`array`)n=n.item;else if(n.type===`record`){if(n.mediaType===`images`)return{kind:`gallery-traversed`,schema:n};n=n.item}else if(n.type===`richtext`)return{kind:`richtext`,schema:n,remainingPath:t.slice(r)};else if(n.type===`union`){if(typeof n.key==`string`){var o=Dd(n.items),s;try{for(o.s();!(s=o.n()).done;){var c=s.value,l=Ep(c,t.slice(r));if(l.kind!==`unresolved`)return l}}catch(e){o.e(e)}finally{o.f()}return{kind:`unresolved`}}return{kind:`unresolved`}}else return{kind:`unresolved`}}return{kind:`leaf`,schema:n}}function Dp(e){if(e.type!==`richtext`)return{kind:`not-allowed`};var t=e.options?.img;return t?t===!0?{kind:`allowed`,remote:!1}:{kind:`allowed`,remote:t.remote===!0}:{kind:`not-allowed`}}function Op(e){return e.type===`image`||e.type===`file`||e.type===`record`?e.remote===!0:!1}function kp(e){var t=Jd.safeParse(e);return t.success?{kind:`ok`,patch:t.data}:{kind:`error`,message:`Built patch failed schema validation: ${JSON.stringify(t.error)}`}}function Ap(e){return e.type===`record`&&e.mediaType===`images`?null:e.type===`image`?{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Module is a plain image field, not an images gallery. Use create_patch with a SessionKey value.`}:e.type===`richtext`?{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Module is a richtext, not an images gallery. Use create_patch with a SessionKey inside a {tag:'img', src: SessionKey} node.`}:{kind:`error`,message:`Module schema is not an images gallery (expected record with mediaType="images", got '${e.type}').`}}function jp(e,t){var n=Ap(t);if(n)return n;var r=Op(t);return kp([{op:`add`,path:[e.filePath],value:wd({},e.metadata)},{op:`file`,path:[e.filePath],filePath:e.filePath,value:e.imageKey,remote:r,metadata:e.metadata}])}function Mp(e,t,n){var r=Ap(t);if(r)return r;if(!n||Bf(n)!==`object`||Array.isArray(n))return{kind:`error`,message:`Cannot remove from gallery: module source is not an object.`};var i=n;if(!Object.prototype.hasOwnProperty.call(i,e.filePath)){var a=Object.keys(i),o=a.length>0?` Available entries: ${a.map(function(e){return`"${e}"`}).join(`, `)}.`:` The gallery is empty.`;return{kind:`error`,message:`No gallery entry with file_path "${e.filePath}".${o}`}}var s=H.remote.splitRemoteRef(e.filePath).status===`success`;return kp([{op:`remove`,path:[e.filePath]},{op:`file`,path:[e.filePath],filePath:e.filePath,value:null,remote:s}])}var Np={kind:`wrong-tool`,suggestedTool:`add_session_image_to_gallery`,reason:`Destination is a media gallery (s.images() / s.files()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery.`};function Pp(e){return e.type===`record`&&e.mediaType!==void 0}function Fp(e,t){var n=Ep(e,t);if(n.kind===`gallery-traversed`)return Np;if(n.kind===`richtext`)return{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Destination is a richtext value. duplicate_source and empty_at_path do not handle richtext edits.`};if(n.kind===`leaf`){if(Pp(n.schema))return Np;if(n.schema.type===`richtext`)return{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Destination is a richtext value. duplicate_source and empty_at_path do not handle richtext edits.`}}if(t.length===0)return{kind:`ok`,op:`replace`,parent:`module`};var r=Ep(e,t.slice(0,-1));if(r.kind===`unresolved`)return{kind:`error`,message:`Destination parent path ${JSON.stringify(t.slice(0,-1))} does not resolve in this module's schema.`};if(r.kind===`richtext`)return{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Destination is inside a richtext value. duplicate_source and empty_at_path do not handle richtext edits.`};if(r.kind===`gallery-traversed`||Pp(r.schema))return Np;var i=r.schema;return i.type===`array`||i.type===`record`?{kind:`ok`,op:`add`,parent:i.type}:i.type===`object`?{kind:`ok`,op:`replace`,parent:`object`}:{kind:`error`,message:`Destination parent has schema type "${i.type}" — cannot use duplicate_source/empty_at_path here. Use create_patch instead.`}}function Ip(e,t,n){var r=Tp(n,e.sourcePath);if(r===void 0)return{kind:`error`,message:`Source path ${JSON.stringify(e.sourcePath)} does not exist in the module. Use get_source to inspect the current contents.`};var i=Fp(t,e.destinationPath);return i.kind===`wrong-tool`?{kind:`wrong-tool`,suggestedTool:i.suggestedTool,reason:i.reason}:i.kind===`error`?{kind:`error`,message:i.message}:Lp(i.parent,n,e.destinationPath)||kp([{op:i.op,path:e.destinationPath,value:r}])}function Lp(e,t,n){if(e!==`record`||Tp(t,n)===void 0)return null;var r=n[n.length-1];return{kind:`error`,message:`Destination key ${JSON.stringify(r)} already exists, and writing to it would replace the entry that is there. Pick a key that is free -- get_record_keys lists the ones in use -- or use create_patch if you meant to change the existing entry.`}}function Rp(e,t,n){var r;if(e.destinationPath.length===0)r=t;else{var i=Ep(t,e.destinationPath);if(i.kind===`unresolved`)return{kind:`error`,message:`Destination path ${JSON.stringify(e.destinationPath)} does not resolve in this module's schema.`};if(i.kind===`richtext`)return{kind:`wrong-tool`,suggestedTool:`create_patch`,reason:`Destination is a richtext value. Use create_patch to build richtext content.`};if(i.kind===`gallery-traversed`)return{kind:`wrong-tool`,suggestedTool:`add_session_image_to_gallery`,reason:`Destination is inside an images gallery. Use add_session_image_to_gallery to add entries.`};r=i.schema}var a=Fp(t,e.destinationPath);if(a.kind===`wrong-tool`)return{kind:`wrong-tool`,suggestedTool:a.suggestedTool,reason:a.reason};if(a.kind===`error`)return{kind:`error`,message:a.message};var o=Lp(a.parent,n,e.destinationPath);if(o)return o;var s=Cp(r);return kp([{op:a.op,path:e.destinationPath,value:s}])}function zp(e,t,n){var r=Tp(t,n);if(r===void 0)return{kind:`error`,reason:`missing`,message:`Path ${JSON.stringify(n)} does not exist in the module source. Use get_source to inspect the current contents.`};var i=Ep(e,n);if(i.kind===`unresolved`)return{kind:`error`,reason:`missing`,message:`Path ${JSON.stringify(n)} does not resolve in this module's schema.`};if(i.kind===`richtext`)return{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} points inside a richtext value, which has no entries to count or list.`};if(i.kind===`gallery-traversed`)return{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} points inside a gallery entry, which has no entries to count or list.`};var a=i.schema;return a.type===`richtext`?Array.isArray(r)?{kind:`ok`,container:`richtext`,value:r}:{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} is a richtext value but its source is not a block array.`}:a.type===`array`?Array.isArray(r)?{kind:`ok`,container:`array`,value:r}:{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} is an array in the schema but its source is not an array.`}:a.type===`record`||a.type===`object`?r===null||Bf(r)!==`object`||Array.isArray(r)?{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} points to a ${r===null?`null`:Array.isArray(r)?`array`:Bf(r)} value, which has no entries to count or list.`}:{kind:`ok`,container:a.type===`record`?Pp(a)?`gallery`:`record`:`object`,value:r}:{kind:`error`,reason:`not-a-container`,message:`Path ${JSON.stringify(n)} points to a "${a.type}" value, which has no entries to count or list.`}}function Bp(e){var t={},n={};for(var r in e){var i=r,a=Dd(e[i]),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;Vp(s)?(n[i]??(n[i]=[])).push(s):(t[i]??(t[i]=[])).push(s)}}catch(e){a.e(e)}finally{a.f()}}return{surfaced:t,skipped:n}}function Vp(e){var t=e.fixes??[];return t.length!==0&&t.every(Hp)}function Hp(e){switch(e){case`image:add-metadata`:case`image:check-metadata`:case`image:upload-remote`:case`image:download-remote`:case`image:check-remote`:case`images:check-remote`:case`images:upload-remote`:case`file:add-metadata`:case`file:check-metadata`:case`file:upload-remote`:case`file:download-remote`:case`file:check-remote`:case`files:check-remote`:case`files:upload-remote`:case`images:check-unique-folder`:case`files:check-unique-folder`:case`images:check-all-files`:case`files:check-all-files`:return!0;case`keyof:check-keys`:case`router:check-route`:case`jsonValues:extract-entry`:return!1;default:return!1}}function Up(e,t,n){return Bp(hp(e,{schemas:t??{},sources:n??{}})).surfaced}function Wp(e){return Array.isArray(e)}function ree(e){let t=Gp(e);if(t===void 0)return`Could not load profiles`;let n=t.indexOf(`{`);if(n===-1)return t;let r;try{r=JSON.parse(t.slice(n))}catch{return t}return Gp(r)??t}function Gp(e){if(typeof e!=`object`||!e||!(`message`in e))return;let t=e.message;return typeof t==`string`?t:void 0}function iee(e){switch(e.reason){case`validation-errors`:return{message:`Cannot publish: some modules have validation errors.`,details:e.modules.join(`
|
|
83
83
|
`)};case`already-publishing`:return{message:`A publish is already in progress.`};case`unsaved-changes`:return{message:`Cannot publish: your latest changes could not be saved.`,details:`Nothing was published, so no work is lost. Check the connection and try again.`};case`chain-moved`:return{message:`Cannot publish: the content changed while it was being checked.`,details:`Nothing was published. Try again.`};default:return{message:`Cannot publish.`}}}var Kp=W().uuid().refine(e=>!0),aee=Ou([`openai-gpt-5.1`]);q({id:W(),systemPrompt:W(),model:aee,tools:K(q({name:W(),description:W(),parameters:q({type:J(`object`),properties:Eu(W(),pu()),required:K(W()).optional()})})).optional(),description:W().optional()});var oee=yu([q({type:J(`patches`),patches:K(Kp)}),q({type:J(`deployment`),deployment:$f}),q({type:J(`commit`),commit:wf}),q({type:J(`subscribed`)})]);q({type:yu([J(`did-change`),J(`no-change`),J(`request-again`),J(`use-websocket`)]),profileId:W().nullable(),config:q({project:W().optional(),ai:q({commitMessages:q({disabled:G().optional()}).optional(),chat:q({experimental:q({enable:G().optional()}).optional()}).optional()}).optional(),files:q({directory:W()}).optional()}),commitSha:W().optional(),jsonEntriesSha:W().optional(),removed:K(q({patchId:Kp,reason:W()})).optional(),sourcesSha:W(),schemaSha:W(),baseSha:W(),patches:K(Kp),commits:K(wf).optional(),deployments:K($f).optional(),mode:yu([J(`fs`),J(`http`)])});function see(e){let[t,n]=(0,b.useState)({status:`not-asked`}),r=(0,b.useRef)(null),i=(0,b.useRef)(crypto.randomUUID()),{authenticationState:a,setAuthenticationLoadingIfNotAuthenticated:o,setIsAuthenticated:s}=uee(),[c,l]=(0,b.useState)(),u=(0,b.useRef)(0);return(0,b.useEffect)(()=>{if(t.status===`updated-request-again`||t.status===`error`||t.status===`ws-message-received`){t.status===`error`&&console.error(`Stat error`,t.status,`error:`,t.error);let a=Math.min(t.wait,lee(t.data,Date.now()));if(a===0)console.debug(`Executing stat immediately`,t.status,t.status===`error`?t.error:`no error`,`Now:`,Date.now()),Jp(e,r,i,u,t,n,o,s,l);else{console.debug(`Executing stat in `,a,` status: `,t.status,`Now:`,Date.now());let c=setTimeout(()=>{Jp(e,r,i,u,t,n,o,s,l)},a);return()=>clearTimeout(c)}}},[e,t]),(0,b.useEffect)(()=>{t.status===`not-asked`&&(n({status:`initializing`}),console.debug(`Initializing stat`),Jp(e,r,i,u,t,n,o,s,l))},[e,t.status]),[t,n,a,o,s,c]}var qp=12e5,cee=5e3;function lee(e,t){if(!e?.commitSha)return 1/0;let n=[...(e.commits||[]).map(e=>({commitSha:e.commitSha,createdAt:e.createdAt})),...(e.deployments||[]).map(e=>({commitSha:e.commitSha,createdAt:e.createdAt}))].filter(t=>t.commitSha!==e.commitSha).map(e=>new Date(e.createdAt).getTime()).filter(e=>!Number.isNaN(e));if(n.length===0)return 1/0;let r=Math.max(0,t-Math.max(...n));return Math.min(qp,Math.max(cee,r/4))}async function Jp(e,t,n,r,i,a,o,s,c){let l=++r.current,u=null;return`data`in i&&i.data&&(u={schemaSha:i.data.schemaSha,sourcesSha:i.data.sourcesSha,baseSha:i.data.baseSha,patches:i.data.patches,jsonEntriesSha:i.data.jsonEntriesSha}),o(),e(`/stat`,`POST`,{body:u}).then(e=>{if(e.status===401){s(`login-required`);return}if(s(`authorized`),e.status===503){c(!0),a(e=>({status:`error`,error:`Service unavailable`,retries:(`retries`in e?e.retries:0)+1,waitStart:Date.now(),wait:5e3}));return}if(c(!1),r.current===0||r.current===l){if(e.status===200){if(e.json.type===`did-change`||e.json.type===`no-change`||e.json.type===`request-again`)a({status:`updated-request-again`,data:e.json,waitStart:Date.now(),wait:t.current?qp:0});else if(e.json.type===`use-websocket`){a(t=>({...t,status:`updated-request-again`,data:e.json,waitStart:Date.now(),wait:qp})),t.current&&(console.debug(`Closing existing WebSocket`),t.current.close());let r=e.json.url;console.debug(`Connecting to WebSocket`,r),t.current=new WebSocket(r);let i=e.json.nonce;t.current.onopen=()=>{t.current?.send(JSON.stringify({nonce:i,type:`subscribe`,connectionId:n.current}))},t.current.onmessage=e=>{try{let t=oee.safeParse(JSON.parse(e.data));if(!t.success){console.error(`Could not parse WebSocket message`,t.error);return}let n=t.data;n.type===`patches`?a(e=>`data`in e&&e.data?{status:`ws-message-received`,data:{...e.data,patches:n.patches},waitStart:`waitStart`in e?e.waitStart:Date.now(),wait:`waitStart`in e?Math.max(0,e.waitStart+qp-Date.now()):qp}:e):n.type===`subscribed`?console.debug(`Subscribed!`):n.type===`commit`?(console.debug(`Commit`,n.commit),a(e=>`data`in e&&e.data?{status:`ws-message-received`,data:{...e.data,commits:(e.data.commits||[]).concat(n.commit)},waitStart:`waitStart`in e?e.waitStart:Date.now(),wait:`waitStart`in e?Math.max(0,e.waitStart+qp-Date.now()):qp}:e)):n.type===`deployment`?(console.debug(`Deployment`,n.deployment),a(e=>`data`in e&&e.data?{status:`ws-message-received`,data:{...e.data,deployments:(e.data.deployments||[]).concat({commitSha:n.deployment.commitSha,deploymentId:n.deployment.deploymentId,deploymentState:n.deployment.deploymentState,createdAt:n.deployment.createdAt,updatedAt:n.deployment.updatedAt})},waitStart:`waitStart`in e?e.waitStart:Date.now(),wait:`waitStart`in e?Math.max(0,e.waitStart+qp-Date.now()):qp}:e)):console.warn(`Unknown WebSocket message`,n)}catch(e){console.error(`Could not parse WebSocket message`,e)}};let o=t.current;t.current.onclose=()=>{o===t.current&&(console.debug(`WebSocket closed`),a(e=>Yp(e,`WebSocket closed`)))},t.current.onerror=()=>{console.warn(`WebSocket error`),a(e=>Yp(e,`Got an error while syncing with Val (reason: WebSocket error)`))}}}else a(t=>Yp(t,e.json.message))}}).catch(e=>{(r.current===0||r.current===l)&&a(t=>Yp(t,e.message))})}function Yp(e,t){let n=`retries`in e?e.retries+1:0,r=e.status===`error`&&e.retries>1?Math.min(500,e.retries*50+Math.floor(Math.random()*100))*10:0;return{status:`error`,error:t,data:`data`in e?e.data:void 0,retries:n,waitStart:`waitStart`in e?e.waitStart:Date.now(),wait:r}}function uee(){let[e,t]=(0,b.useState)(`not-asked`);return{authenticationState:e,setIsAuthenticated:t,setAuthenticationLoadingIfNotAuthenticated:(0,b.useCallback)(()=>{e===`not-asked`&&t(`loading`)},[e])}}function dee(e,t,n){let r={};for(let t of e)r[t.commitSha]=t;for(let e of t)r[e.commitSha]||(r[e.commitSha]={commitMessage:e?.commitMessage||null,deploymentState:`created`,creator:e.creator,createdAt:e.createdAt,updatedAt:e.createdAt,commitSha:e.commitSha});let i=[...n].sort((e,t)=>new Date(e.updatedAt).getTime()-new Date(t.updatedAt).getTime());for(let e of i)e.commitSha&&(r[e.commitSha]={commitMessage:r[e.commitSha]?.commitMessage||null,deploymentState:e.deploymentState,creator:r[e.commitSha]?.creator||null,createdAt:r[e.commitSha]?.createdAt||e.createdAt,updatedAt:e.updatedAt,commitSha:e.commitSha});return Object.values(r).sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime())}var fee=Object.defineProperty,Xp=(e,t)=>fee(e,`name`,{value:t,configurable:!0}),Zp=!!(typeof window<`u`&&window.document&&window.document.createElement);function Qp(e,t,{checkForDefaultPrevented:n=!0}={}){return Xp(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}Xp(Qp,`composeEventHandlers`);function pee(e){if(!Zp)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}Xp(pee,`getOwnerWindow`);function $p(e){if(!Zp)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}Xp($p,`getOwnerDocument`);function em(e,t=!1){let{activeElement:n}=$p(e);if(!n?.nodeName)return null;if(tm(n)&&n.contentDocument)return em(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=$p(n).getElementById(e);if(t)return t}}return n}Xp(em,`getActiveElement`);function tm(e){return e.tagName===`IFRAME`}Xp(tm,`isFrame`);var mee=Object.defineProperty,nm=(e,t)=>mee(e,`name`,{value:t,configurable:!0});function rm(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}nm(rm,`setRef`);function im(...e){return t=>{let n=!1,r=e.map(e=>{let r=rm(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():rm(e[t],null)}}}}nm(im,`composeRefs`);function am(...e){return b.useCallback(im(...e),e)}nm(am,`useComposedRefs`);var hee=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Y=s(((e,t)=>{t.exports=hee()}))(),gee=Object.defineProperty,om=(e,t)=>gee(e,`name`,{value:t,configurable:!0});function _ee(e,t){let n=b.createContext(t);n.displayName=e+`Context`;let r=om(e=>{let{children:t,...r}=e,i=b.useMemo(()=>r,Object.values(r));return(0,Y.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=b.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return om(i,`useContext`),[r,i]}om(_ee,`createContext`);function sm(e,t=[]){let n=[];function r(t,r){let i=b.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=om(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=b.useMemo(()=>o,Object.values(o));return(0,Y.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=b.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return om(s,`useContext`),[o,s]}om(r,`createContext`);let i=om(()=>{let t=n.map(e=>b.createContext(e));return om(function(n){let r=n?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,cm(i,...t)]}om(sm,`createContextScope`);function cm(...e){let t=e[0];if(e.length===1)return t;let n=om(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return om(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}om(cm,`composeContextScopes`);var lm=u(_(),1),vee=Object.defineProperty,um=(e,t)=>vee(e,`name`,{value:t,configurable:!0});function dm(e){let t=b.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];vm(r)&&typeof bm==`function`&&(r=bm(r._payload)),b.Children.forEach(r,e=>{if(_m(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;vm(n)&&typeof bm==`function`&&(n=bm(n._payload)),a=yee(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=b.cloneElement(a,void 0,s):!o&&b.Children.count(r)===1&&b.isValidElement(r)&&(a=r);let c=a?gm(a):void 0,l=am(n,c);if(!a){if(r||r===0)throw Error(o?See(e):xee(e));return r}let u=hm(i,a.props??{});return a.type!==b.Fragment&&(u.ref=n?l:c),b.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}um(dm,`createSlot`);var fm=dm(`Slot`),pm=Symbol.for(`radix.slottable`);function mm(e){let t=um(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=pm,t}um(mm,`createSlottable`);var yee=um((e,t)=>{if(`child`in e.props){let t=e.props.child;return b.isValidElement(t)?b.cloneElement(t,void 0,e.props.children(t.props.children)):null}return b.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function hm(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}um(hm,`mergeProps`);function gm(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}um(gm,`getElementRef`);function _m(e){return b.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===pm}um(_m,`isSlottable`);var bee=Symbol.for(`react.lazy`);function vm(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===bee&&`_payload`in e&&ym(e._payload)}um(vm,`isLazyComponent`);function ym(e){return typeof e==`object`&&!!e&&`then`in e}um(ym,`isPromiseLike`);var xee=um(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),See=um(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),bm=b.use,Cee=Object.defineProperty,wee=(e,t)=>Cee(e,`name`,{value:t,configurable:!0}),xm=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=dm(`Primitive.${t}`),r=b.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,Y.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Sm(e,t){e&&lm.flushSync(()=>e.dispatchEvent(t))}wee(Sm,`dispatchDiscreteCustomEvent`);var Tee=Object.defineProperty,Eee=(e,t)=>Tee(e,`name`,{value:t,configurable:!0});function Cm(e){let t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...e)=>t.current?.(...e)),[])}Eee(Cm,`useCallbackRef`);var Dee=Object.defineProperty,wm=(e,t)=>Dee(e,`name`,{value:t,configurable:!0}),Tm=`dismissableLayer.update`,Oee=`dismissableLayer.pointerDownOutside`,kee=`dismissableLayer.focusOutside`,Em,Dm=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Om=b.forwardRef(wm(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=b.useContext(Dm),[d,f]=b.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=b.useState({}),h=am(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,S=y>=v,C=b.useRef(!1),w=km(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:b.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return S&&!t},[u.branches,S])}),T=Am(e=>{if(r&&C.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),E=d?y===g.length-1:!1,D=Cm(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return b.useEffect(()=>{if(E)return p.addEventListener(`keydown`,D,{capture:!0}),()=>p.removeEventListener(`keydown`,D,{capture:!0})},[p,E,D]),b.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Em=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),jm(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Em))}},[d,p,n,u]),b.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),jm())},[d,u]),b.useEffect(()=>{let e=wm(()=>m({}),`handleUpdate`);return document.addEventListener(Tm,e),()=>document.removeEventListener(Tm,e)},[]),(0,Y.jsx)(xm.div,{...l,ref:h,style:{pointerEvents:x?S?`auto`:`none`:void 0,...e.style},onFocusCapture:Qp(e.onFocusCapture,T.onFocusCapture),onBlurCapture:Qp(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Qp(e.onPointerDownCapture,w.onPointerDownCapture)})},`DismissableLayer`));function Aee(){let e=b.useContext(Dm),[t,n]=b.useState(null);return b.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}wm(Aee,`useDismissableLayerSurface`);var jee=wm(()=>!0,`IS_TRUE`);function km(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=jee}=t,s=Cm(e),c=b.useRef(!1),l=b.useRef(!1),u=b.useRef(new Map),d=b.useRef(()=>{});return b.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}wm(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}wm(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}wm(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}wm(p,`handleInteractionBubble`);let m=wm(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||Mm(Oee,s,p,{discrete:!0})};if(wm(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:wm(()=>c.current=!0,`onPointerDownCapture`)}}wm(km,`usePointerDownOutside`);function Am(e,t=globalThis?.document){let n=Cm(e),r=b.useRef(!1);return b.useEffect(()=>{let e=wm(e=>{e.target&&!r.current&&Mm(kee,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:wm(()=>r.current=!0,`onFocusCapture`),onBlurCapture:wm(()=>r.current=!1,`onBlurCapture`)}}wm(Am,`useFocusOutside`);function jm(){let e=new CustomEvent(Tm);document.dispatchEvent(e)}wm(jm,`dispatchUpdate`);function Mm(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Sm(i,a):i.dispatchEvent(a)}wm(Mm,`handleAndDispatchCustomEvent`);var Nm=globalThis?.document?b.useLayoutEffect:()=>{},Mee=Object.defineProperty,Nee=(e,t)=>Mee(e,`name`,{value:t,configurable:!0}),Pee=b.useId||(()=>void 0),Fee=0;function Pm(e){let[t,n]=b.useState(Pee());return Nm(()=>{e||n(e=>e??String(Fee++))},[e]),e||(t?`radix-${t}`:``)}Nee(Pm,`useId`);var Iee=[`top`,`right`,`bottom`,`left`],Fm=Math.min,Im=Math.max,Lm=Math.round,Rm=Math.floor,zm=e=>({x:e,y:e}),Lee={left:`right`,right:`left`,bottom:`top`,top:`bottom`},Ree={start:`end`,end:`start`};function Bm(e,t,n){return Im(e,Fm(t,n))}function Vm(e,t){return typeof e==`function`?e(t):e}function Hm(e){return e.split(`-`)[0]}function Um(e){return e.split(`-`)[1]}function Wm(e){return e===`x`?`y`:`x`}function Gm(e){return e===`y`?`height`:`width`}var zee=new Set([`top`,`bottom`]);function Km(e){return zee.has(Hm(e))?`y`:`x`}function qm(e){return Wm(Km(e))}function Bee(e,t,n){n===void 0&&(n=!1);let r=Um(e),i=qm(e),a=Gm(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Zm(o)),[o,Zm(o)]}function Vee(e){let t=Zm(e);return[Jm(e),t,Jm(t)]}function Jm(e){return e.replace(/start|end/g,e=>Ree[e])}var Ym=[`left`,`right`],Xm=[`right`,`left`],Hee=[`top`,`bottom`],Uee=[`bottom`,`top`];function Wee(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Xm:Ym:t?Ym:Xm;case`left`:case`right`:return t?Hee:Uee;default:return[]}}function Gee(e,t,n,r){let i=Um(e),a=Wee(Hm(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Jm)))),a}function Zm(e){return e.replace(/left|right|bottom|top/g,e=>Lee[e])}function Kee(e){return{top:0,right:0,bottom:0,left:0,...e}}function Qm(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Kee(e)}function $m(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function eh(e,t,n){let{reference:r,floating:i}=e,a=Km(t),o=qm(t),s=Gm(o),c=Hm(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Um(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1)}return p}var qee=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=eh(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=await h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:o,elements:{reference:e,floating:t}});u=g??u,d=_??d,p={...p,[a]:{...p[a],...v}},y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=eh(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}};async function th(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Vm(t,e),p=Qm(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=$m(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=$m(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Jee=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Vm(e,t)||{};if(l==null)return{};let d=Qm(u),f={x:n,y:r},p=qm(i),m=Gm(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Fm(d[_],T),D=Fm(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=Bm(O,A,k),M=!c.arrow&&Um(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),Yee=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Vm(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Hm(r),_=Km(o),v=Hm(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Zm(o)]:Vee(o)),x=p!==`none`;!d&&x&&b.push(...Gee(o,m,p,y));let S=[o,...b],C=await th(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Bee(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Km(t)||T.every(e=>Km(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Km(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function nh(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function rh(e){return Iee.some(t=>e[t]>=0)}var Xee=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n}=t,{strategy:r=`referenceHidden`,...i}=Vm(e,t);switch(r){case`referenceHidden`:{let e=nh(await th(t,{...i,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:rh(e)}}}case`escaped`:{let e=nh(await th(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:rh(e)}}}default:return{}}}}},ih=new Set([`left`,`top`]);async function Zee(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Hm(n),s=Um(n),c=Km(n)===`y`,l=ih.has(o)?-1:1,u=a&&c?-1:1,d=Vm(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Qee=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Zee(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},$ee=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i}=t,{mainAxis:a=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...c}=Vm(e,t),l={x:n,y:r},u=await th(t,c),d=Km(Hm(i)),f=Wm(d),p=l[f],m=l[d];if(a){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=p+u[e],r=p-u[t];p=Bm(n,p,r)}if(o){let e=d===`y`?`top`:`left`,t=d===`y`?`bottom`:`right`,n=m+u[e],r=m-u[t];m=Bm(n,m,r)}let h=s.fn({...t,[f]:p,[d]:m});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[f]:a,[d]:o}}}}}},ete=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Vm(e,t),u={x:n,y:r},d=Km(i),f=Wm(d),p=u[f],m=u[d],h=Vm(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ih.has(Hm(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},tte=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=Vm(e,t),u=await th(t,l),d=Hm(i),f=Um(i),p=Km(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Fm(h-u[g],v),x=Fm(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=Im(u.left,0),t=Im(u.right,0),n=Im(u.top,0),r=Im(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:Im(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:Im(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function ah(){return typeof window<`u`}function oh(e){return lh(e)?(e.nodeName||``).toLowerCase():`#document`}function sh(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ch(e){return((lh(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function lh(e){return ah()?e instanceof Node||e instanceof sh(e).Node:!1}function uh(e){return ah()?e instanceof Element||e instanceof sh(e).Element:!1}function dh(e){return ah()?e instanceof HTMLElement||e instanceof sh(e).HTMLElement:!1}function fh(e){return!ah()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof sh(e).ShadowRoot}var nte=new Set([`inline`,`contents`]);function ph(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=vh(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!nte.has(i)}var rte=new Set([`table`,`td`,`th`]);function ite(e){return rte.has(oh(e))}var ate=[`:popover-open`,`:modal`];function mh(e){return ate.some(t=>{try{return e.matches(t)}catch{return!1}})}var ote=[`transform`,`translate`,`scale`,`rotate`,`perspective`],ste=[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`],cte=[`paint`,`layout`,`strict`,`content`];function hh(e){let t=gh(),n=uh(e)?vh(e):e;return ote.some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||ste.some(e=>(n.willChange||``).includes(e))||cte.some(e=>(n.contain||``).includes(e))}function lte(e){let t=bh(e);for(;dh(t)&&!_h(t);){if(hh(t))return t;if(mh(t))return null;t=bh(t)}return null}function gh(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}var ute=new Set([`html`,`body`,`#document`]);function _h(e){return ute.has(oh(e))}function vh(e){return sh(e).getComputedStyle(e)}function yh(e){return uh(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function bh(e){if(oh(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||fh(e)&&e.host||ch(e);return fh(t)?t.host:t}function xh(e){let t=bh(e);return _h(t)?e.ownerDocument?e.ownerDocument.body:e.body:dh(t)&&ph(t)?t:xh(t)}function Sh(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=xh(e),i=r===e.ownerDocument?.body,a=sh(r);if(i){let e=Ch(a);return t.concat(a,a.visualViewport||[],ph(r)?r:[],e&&n?Sh(e):[])}return t.concat(r,Sh(r,[],n))}function Ch(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wh(e){let t=vh(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=dh(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Lm(n)!==a||Lm(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Th(e){return uh(e)?e:e.contextElement}function Eh(e){let t=Th(e);if(!dh(t))return zm(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=wh(t),o=(a?Lm(n.width):n.width)/r,s=(a?Lm(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var dte=zm(0);function Dh(e){let t=sh(e);return!gh()||!t.visualViewport?dte:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function fte(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==sh(e)?!1:t}function Oh(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Th(e),o=zm(1);t&&(r?uh(r)&&(o=Eh(r)):o=Eh(e));let s=fte(a,n,r)?Dh(a):zm(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=sh(a),t=r&&uh(r)?sh(r):r,n=e,i=Ch(n);for(;i&&r&&t!==n;){let e=Eh(i),t=i.getBoundingClientRect(),r=vh(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=sh(i),i=Ch(n)}}return $m({width:u,height:d,x:c,y:l})}function kh(e,t){let n=yh(e).scrollLeft;return t?t.left+n:Oh(ch(e)).left+n}function Ah(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-kh(e,n),y:n.top+t.scrollTop}}function pte(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ch(r),s=t?mh(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=zm(1),u=zm(0),d=dh(r);if((d||!d&&!a)&&((oh(r)!==`body`||ph(o))&&(c=yh(r)),dh(r))){let e=Oh(r);l=Eh(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ah(o,c):zm(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function mte(e){return Array.from(e.getClientRects())}function hte(e){let t=ch(e),n=yh(e),r=e.ownerDocument.body,i=Im(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Im(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+kh(e),s=-n.scrollTop;return vh(r).direction===`rtl`&&(o+=Im(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var jh=25;function gte(e,t){let n=sh(e),r=ch(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=gh();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=kh(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=jh&&(a-=o)}else l<=jh&&(a+=l);return{width:a,height:o,x:s,y:c}}var _te=new Set([`absolute`,`fixed`]);function vte(e,t){let n=Oh(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=dh(e)?Eh(e):zm(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Mh(e,t,n){let r;if(t===`viewport`)r=gte(e,n);else if(t===`document`)r=hte(ch(e));else if(uh(t))r=vte(t,n);else{let n=Dh(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return $m(r)}function Nh(e,t){let n=bh(e);return n===t||!uh(n)||_h(n)?!1:vh(n).position===`fixed`||Nh(n,t)}function yte(e,t){let n=t.get(e);if(n)return n;let r=Sh(e,[],!1).filter(e=>uh(e)&&oh(e)!==`body`),i=null,a=vh(e).position===`fixed`,o=a?bh(e):e;for(;uh(o)&&!_h(o);){let t=vh(o),n=hh(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&_te.has(i.position)||ph(o)&&!n&&Nh(e,o))?r=r.filter(e=>e!==o):i=t,o=bh(o)}return t.set(e,r),r}function bte(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?mh(t)?[]:yte(t,this._c):[].concat(n),r],o=a[0],s=a.reduce((e,n)=>{let r=Mh(t,n,i);return e.top=Im(r.top,e.top),e.right=Fm(r.right,e.right),e.bottom=Fm(r.bottom,e.bottom),e.left=Im(r.left,e.left),e},Mh(t,o,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function xte(e){let{width:t,height:n}=wh(e);return{width:t,height:n}}function Ste(e,t,n){let r=dh(t),i=ch(t),a=n===`fixed`,o=Oh(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=zm(0);function l(){c.x=kh(i)}if(r||!r&&!a){if((oh(t)!==`body`||ph(i))&&(s=yh(t)),r){let e=Oh(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l()}a&&!r&&i&&l();let u=i&&!r&&!a?Ah(i,s):zm(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Ph(e){return vh(e).position===`static`}function Fh(e,t){if(!dh(e)||vh(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ch(e)===n&&(n=n.ownerDocument.body),n}function Cte(e,t){let n=sh(e);if(mh(e))return n;if(!dh(e)){let t=bh(e);for(;t&&!_h(t);){if(uh(t)&&!Ph(t))return t;t=bh(t)}return n}let r=Fh(e,t);for(;r&&ite(r)&&Ph(r);)r=Fh(r,t);return r&&_h(r)&&Ph(r)&&!hh(r)?n:r||lte(e)||n}var wte=async function(e){let t=this.getOffsetParent||Cte,n=this.getDimensions,r=await n(e.floating);return{reference:Ste(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Tte(e){return vh(e).direction===`rtl`}var Ete={convertOffsetParentRelativeRectToViewportRelativeRect:pte,getDocumentElement:ch,getClippingRect:bte,getOffsetParent:Cte,getElementRects:wte,getClientRects:mte,getDimensions:xte,getScale:Eh,isElement:uh,isRTL:Tte};function Dte(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ote(e,t){let n=null,r,i=ch(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Rm(d),h=Rm(i.clientWidth-(u+f)),g=Rm(i.clientHeight-(d+p)),_=Rm(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Im(0,Fm(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Dte(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function kte(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Th(e),u=i||a?[...l?Sh(l):[],...Sh(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Ote(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?Oh(e):null;c&&g();function g(){let t=Oh(e);h&&!Dte(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Ate=Qee,jte=$ee,Mte=Yee,Nte=tte,Pte=Xee,Fte=Jee,Ite=ete,Lte=(e,t,n)=>{let r=new Map,i={platform:Ete,...n},a={...i.platform,_c:r};return qee(e,t,{...i,platform:a})},Ih=typeof document<`u`?b.useLayoutEffect:function(){};function Lh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Lh(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Lh(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Rte(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function zte(e,t){let n=Rte(e);return Math.round(t*n)/n}function Rh(e){let t=b.useRef(e);return Ih(()=>{t.current=e}),t}function Bte(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=b.useState(r);Lh(f,r)||p(r);let[m,h]=b.useState(null),[g,_]=b.useState(null),v=b.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),y=b.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=a||m,S=o||g,C=b.useRef(null),w=b.useRef(null),T=b.useRef(u),E=c!=null,D=Rh(c),O=Rh(i),k=Rh(l),A=b.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Lte(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Lh(T.current,t)&&(T.current=t,lm.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);Ih(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=b.useRef(!1);Ih(()=>(j.current=!0,()=>{j.current=!1}),[]),Ih(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=b.useMemo(()=>({reference:C,floating:w,setReference:v,setFloating:y}),[v,y]),N=b.useMemo(()=>({reference:x,floating:S}),[x,S]),P=b.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=zte(N.floating,u.x),r=zte(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Rte(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return b.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Vte=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Fte({element:r.current,padding:i}).fn(n):r?Fte({element:r,padding:i}).fn(n):{}}}},Hte=(e,t)=>({...Ate(e),options:[e,t]}),Ute=(e,t)=>({...jte(e),options:[e,t]}),Wte=(e,t)=>({...Ite(e),options:[e,t]}),Gte=(e,t)=>({...Mte(e),options:[e,t]}),Kte=(e,t)=>({...Nte(e),options:[e,t]}),qte=(e,t)=>({...Pte(e),options:[e,t]}),Jte=(e,t)=>({...Vte(e),options:[e,t]}),Yte=Object.defineProperty,Xte=b.forwardRef(((e,t)=>Yte(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,Y.jsx)(xm.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,Y.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),Zte=Object.defineProperty,Qte=(e,t)=>Zte(e,`name`,{value:t,configurable:!0});function zh(e){let[t,n]=b.useState(void 0);return Nm(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}Qte(zh,`useSize`);var $te=Object.defineProperty,Bh=(e,t)=>$te(e,`name`,{value:t,configurable:!0}),ene=`Popper`,[tne,Vh]=sm(ene),[nne,rne]=tne(ene),ine=Bh(e=>{let{__scopePopper:t,children:n}=e,[r,i]=b.useState(null),[a,o]=b.useState(void 0);return(0,Y.jsx)(nne,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),ane=`PopperAnchor`,one=b.forwardRef(Bh(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=rne(ane,n),o=b.useRef(null),s=a.onAnchorChange,c=am(t,b.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=b.useRef(null);b.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&Hh(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,Y.jsx)(xm.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),sne=`PopperContent`,[cne,lne]=tne(sne),une=b.forwardRef(Bh(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=rne(sne,n),[_,v]=b.useState(null),y=am(t,v),[x,S]=b.useState(null),C=zh(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),D=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:D,boundary:O.filter(mne),altBoundary:k},{refs:j,floatingStyles:M,placement:N,isPositioned:P,middlewareData:F}=Bte({strategy:`fixed`,placement:E,whileElementsMounted:Bh((...e)=>kte(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[Hte({mainAxis:i+T,alignmentAxis:o}),c&&Ute({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Wte():void 0,...A}),c&&Gte({...A}),Kte({...A,apply:Bh(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),x&&Jte({element:x,padding:s}),hne({arrowWidth:w,arrowHeight:T}),f&&qte({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),I=g.setPlacementState;Nm(()=>(I(N),()=>{I(void 0)}),[N,I]);let[L,R]=Hh(N),ee=Cm(m);Nm(()=>{P&&ee?.()},[P,ee]);let te=F.arrow?.x,ne=F.arrow?.y,re=F.arrow?.centerOffset!==0,[ie,ae]=b.useState();return Nm(()=>{_&&ae(window.getComputedStyle(_).zIndex)},[_]),(0,Y.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:P?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ie,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,Y.jsx)(cne,{scope:n,placedSide:L,placedAlign:R,onArrowChange:S,arrowX:te,arrowY:ne,shouldHideArrow:re,children:(0,Y.jsx)(xm.div,{"data-side":L,"data-align":R,...h,ref:y,style:{...h.style,animation:P?h.style?.animation:`none`}})})})},`PopperContent`)),dne=`PopperArrow`,fne={top:`bottom`,right:`left`,bottom:`top`,left:`right`},pne=b.forwardRef(Bh(function(e,t){let{__scopePopper:n,...r}=e,i=lne(dne,n),a=fne[i.placedSide];return(0,Y.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,Y.jsx)(Xte,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function mne(e){return e!==null}Bh(mne,`isNotNull`);var hne=Bh(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Hh(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Hh(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Bh(Hh,`getSideAndAlignFromPlacement`);var Uh=ine,Wh=one,Gh=une,gne=pne,_ne=Object.defineProperty,Kh=b.forwardRef(((e,t)=>_ne(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=b.useState(!1);Nm(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?lm.createPortal((0,Y.jsx)(xm.div,{...r,ref:t}),o):null},`Portal`)),vne=Object.defineProperty,qh=(e,t)=>vne(e,`name`,{value:t,configurable:!0});function yne(e,t){return b.useReducer((e,n)=>t[e][n]??e,e)}qh(yne,`useStateMachine`);var Jh=qh(e=>{let{present:t,children:n}=e,r=bne(t),i=typeof n==`function`?n({present:r.isPresent}):b.Children.only(n),a=xne(r.ref,Zh(i));return typeof n==`function`||r.isPresent?b.cloneElement(i,{ref:a}):null},`Presence`);function bne(e){let[t,n]=b.useState(),r=b.useRef(null),i=b.useRef(e),a=b.useRef(`none`),o=b.useRef(void 0),[s,c]=yne(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return b.useEffect(()=>{s===`mounted`?(a.current=o.current??Xh(r.current),o.current=void 0):a.current=`none`},[s]),Nm(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=Xh(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),Nm(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=qh(a=>{let o=Xh(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=qh(e=>{e.target===t&&(a.current=Xh(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:b.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=Xh(t)}else r.current=null;n(e)},[])}}qh(bne,`usePresence`);function Yh(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}qh(Yh,`setRef`);function xne(...e){let t=b.useRef(e);return t.current=e,b.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Yh(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Yh(n[e],null)}}},[])}qh(xne,`useStableComposedRefs`);function Xh(e){return e?.animationName||`none`}qh(Xh,`getAnimationName`);function Zh(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}qh(Zh,`getElementRef`);var Sne=Object.defineProperty,Cne=(e,t)=>Sne(e,`name`,{value:t,configurable:!0}),Qh=b.useEffectEvent,$h=b.useInsertionEffect;function eg(e){if(typeof Qh==`function`)return Qh(e);let t=b.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof $h==`function`?$h(()=>{t.current=e}):Nm(()=>{t.current=e}),b.useMemo(()=>((...e)=>t.current?.(...e)),[])}Cne(eg,`useEffectEvent`);var wne=Object.defineProperty,tg=(e,t)=>wne(e,`name`,{value:t,configurable:!0}),Tne=b.useInsertionEffect||Nm;function ng({prop:e,defaultProp:t,onChange:n=tg(()=>{},`onChange`),caller:r}){let[i,a,o]=rg({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,b.useCallback(t=>{if(s){let n=ig(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}tg(ng,`useControllableState`);function rg({defaultProp:e,onChange:t}){let[n,r]=b.useState(e),i=b.useRef(n),a=b.useRef(t);return Tne(()=>{a.current=t},[t]),b.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}tg(rg,`useUncontrolledState`);function ig(e){return typeof e==`function`}tg(ig,`isFunction`);var ag=Symbol(`RADIX:SYNC_STATE`);function Ene(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=eg(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=b.useReducer((t,n)=>{if(n.type===ag)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=b.useRef(p);b.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=b.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return b.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:ag,state:i})},[i,d.state,c]),[h,f]}tg(Ene,`useControllableStateReducer`);var Dne=Object.defineProperty,One=(e,t)=>Dne(e,`name`,{value:t,configurable:!0}),og=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),kne=b.forwardRef(One(function(e,t){return(0,Y.jsx)(xm.span,{...e,ref:t,style:{...og,...e.style}})},`VisuallyHidden`)),Ane=Object.defineProperty,sg=(e,t)=>Ane(e,`name`,{value:t,configurable:!0}),[cg,jne]=sm(`Tooltip`,[Vh]),lg=Vh(),Mne=`TooltipProvider`,Nne=700,ug=`tooltip.open`,[Pne,dg]=cg(Mne),Fne=sg(e=>{let{__scopeTooltip:t,delayDuration:n=Nne,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=b.useRef(!0),s=b.useRef(!1),c=b.useRef(0);return b.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,Y.jsx)(Pne,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:b.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:b.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:b.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),fg=`Tooltip`,[Ine,pg]=cg(fg),Lne=sg(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=dg(fg,e.__scopeTooltip),l=lg(t),[u,d]=b.useState(null),[f,p]=b.useState(void 0),m=Pm(),h=b.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=b.useRef(!1),[y,x]=ng({prop:r,defaultProp:i??!1,onChange:sg(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(ug))):c.onClose(),a?.(e)},`onChange`),caller:fg}),S=b.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),C=b.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,x(!0)},[x]),w=b.useCallback(()=>{window.clearTimeout(h.current),h.current=0,x(!1)},[x]),T=b.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,x(!0),h.current=0},_)},[_,x]);b.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let E=f??m;return(0,Y.jsx)(Uh,{...l,children:(0,Y.jsx)(Ine,{scope:t,contentId:E,setContentId:p,open:y,stateAttribute:S,trigger:u,onTriggerChange:d,onTriggerEnter:b.useCallback(()=>{c.isOpenDelayedRef.current?T():C()},[c.isOpenDelayedRef,T,C]),onTriggerLeave:b.useCallback(()=>{g?w():(window.clearTimeout(h.current),h.current=0)},[w,g]),onOpen:C,onClose:w,disableHoverableContent:g,children:n})})},`Tooltip`),mg=`TooltipTrigger`,hg=b.forwardRef(sg(function(e,t){let{__scopeTooltip:n,...r}=e,i=pg(mg,n),a=dg(mg,n),o=lg(n),s=am(t,b.useRef(null),i.onTriggerChange),c=b.useRef(!1),l=b.useRef(!1),u=b.useCallback(()=>c.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,Y.jsx)(Wh,{asChild:!0,...o,children:(0,Y.jsx)(xm.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Qp(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Qp(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Qp(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Qp(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Qp(e.onBlur,i.onClose),onClick:Qp(e.onClick,i.onClose)})})},`TooltipTrigger`)),gg=`TooltipPortal`,[Rne,zne]=cg(gg,{forceMount:void 0}),Bne=sg(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=pg(gg,t);return(0,Y.jsx)(Rne,{scope:t,forceMount:n,children:(0,Y.jsx)(Jh,{present:n||a.open,children:(0,Y.jsx)(Kh,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),_g=`TooltipContent`,Vne=b.forwardRef(sg(function(e,t){let n=zne(_g,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=pg(_g,e.__scopeTooltip);return(0,Y.jsx)(Jh,{present:r||o.open,children:o.disableHoverableContent?(0,Y.jsx)(vg,{side:i,...a,ref:t}):(0,Y.jsx)(Hne,{side:i,...a,ref:t})})},`TooltipContent`)),Hne=b.forwardRef(sg(function(e,t){let n=pg(_g,e.__scopeTooltip),r=dg(_g,e.__scopeTooltip),i=b.useRef(null),a=am(t,i),[o,s]=b.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=b.useCallback(()=>{s(null),d(!1)},[d]),p=b.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=bg(r,yg(r,n.getBoundingClientRect())),a=xg(t.getBoundingClientRect()),o=Cg([...i,...a]);s(o),d(!0)},[d]);return b.useEffect(()=>()=>f(),[f]),b.useEffect(()=>{if(c&&u){let e=sg(e=>p(e,u),`handleTriggerLeave`),t=sg(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),b.useEffect(()=>{if(o){let e=sg(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Sg(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,Y.jsx)(vg,{...e,ref:a})},`TooltipContentHoverable`)),Une=mm(`TooltipContent`),vg=b.forwardRef(sg(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=pg(_g,n),u=lg(n),{onClose:d}=l;b.useEffect(()=>(document.addEventListener(ug,d),()=>document.removeEventListener(ug,d)),[d]),b.useEffect(()=>{if(l.trigger){let e=sg(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return Nm(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,Y.jsx)(Om,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,Y.jsxs)(Gh,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,Y.jsx)(Une,{children:r}),i?(0,Y.jsx)(kne,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`));function yg(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}sg(yg,`getExitSideFromRect`);function bg(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}sg(bg,`getPaddedExitPoints`);function xg(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}sg(xg,`getPointsFromRect`);function Sg(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}sg(Sg,`isPointInPolygon`);function Cg(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),wg(t)}sg(Cg,`getHull`);function wg(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}sg(wg,`getHullPresorted`);var Wne=Fne,Gne=Lne,Kne=hg,qne=Bne,Tg=Vne;function Eg(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Eg(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Dg(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Eg(e))&&(r&&(r+=` `),r+=t);return r}var Og=`-`,Jne=e=>{let t=Xne(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{let n=e.split(Og);return n[0]===``&&n.length!==1&&n.shift(),kg(n,t)||Yne(e)},getConflictingClassGroupIds:(e,t)=>{let i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},kg=(e,t)=>{if(e.length===0)return t.classGroupId;let n=e[0],r=t.nextPart.get(n),i=r?kg(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;let a=e.join(Og);return t.validators.find(({validator:e})=>e(a))?.classGroupId},Ag=/^\[(.+)\]$/,Yne=e=>{if(Ag.test(e)){let t=Ag.exec(e)[1],n=t?.substring(0,t.indexOf(`:`));if(n)return`arbitrary..`+n}},Xne=e=>{let{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Qne(Object.entries(e.classGroups),n).forEach(([e,n])=>{jg(n,r,e,t)}),r},jg=(e,t,n,r)=>{e.forEach(e=>{if(typeof e==`string`){let r=e===``?t:Mg(t,e);r.classGroupId=n;return}if(typeof e==`function`){if(Zne(e)){jg(e(r),t,n,r);return}t.validators.push({validator:e,classGroupId:n});return}Object.entries(e).forEach(([e,i])=>{jg(i,Mg(t,e),n,r)})})},Mg=(e,t)=>{let n=e;return t.split(Og).forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},Zne=e=>e.isThemeGetter,Qne=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>typeof e==`string`?t+e:typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,$ne=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=new Map,r=new Map,i=(i,a)=>{n.set(i,a),t++,t>e&&(t=0,r=n,n=new Map)};return{get(e){let t=n.get(e);if(t!==void 0)return t;if((t=r.get(e))!==void 0)return i(e,t),t},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},Ng=`!`,ere=e=>{let{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],a=t.length,o=e=>{let n=[],o=0,s=0,c;for(let l=0;l<e.length;l++){let u=e[l];if(o===0){if(u===i&&(r||e.slice(l,l+a)===t)){n.push(e.slice(s,l)),s=l+a;continue}if(u===`/`){c=l;continue}}u===`[`?o++:u===`]`&&o--}let l=n.length===0?e:e.substring(s),u=l.startsWith(Ng);return{modifiers:n,hasImportantModifier:u,baseClassName:u?l.substring(1):l,maybePostfixModifierPosition:c&&c>s?c-s:void 0}};return n?e=>n({className:e,parseClassName:o}):o},tre=e=>{if(e.length<=1)return e;let t=[],n=[];return e.forEach(e=>{e[0]===`[`?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},nre=e=>({cache:$ne(e.cacheSize),parseClassName:ere(e),...Jne(e)}),rre=/\s+/,ire=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,a=[],o=e.trim().split(rre),s=``;for(let e=o.length-1;e>=0;--e){let t=o[e],{modifiers:c,hasImportantModifier:l,baseClassName:u,maybePostfixModifierPosition:d}=n(t),f=!!d,p=r(f?u.substring(0,d):u);if(!p){if(!f){s=t+(s.length>0?` `+s:s);continue}if(p=r(u),!p){s=t+(s.length>0?` `+s:s);continue}f=!1}let m=tre(c).join(`:`),h=l?m+Ng:m,g=h+p;if(a.includes(g))continue;a.push(g);let _=i(p,f);for(let e=0;e<_.length;++e){let t=_[e];a.push(h+t)}s=t+(s.length>0?` `+s:s)}return s};function are(){let e=0,t,n,r=``;for(;e<arguments.length;)(t=arguments[e++])&&(n=Pg(t))&&(r&&(r+=` `),r+=n);return r}var Pg=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=Pg(e[r]))&&(n&&(n+=` `),n+=t);return n};function ore(e,...t){let n,r,i,a=o;function o(o){return n=nre(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)}function s(e){let t=r(e);if(t)return t;let a=ire(e,n);return i(e,a),a}return function(){return a(are.apply(null,arguments))}}var Fg=e=>{let t=t=>t[e]||[];return t.isThemeGetter=!0,t},Ig=/^\[(?:([a-z-]+):)?(.+)\]$/i,sre=/^\d+\/\d+$/,cre=new Set([`px`,`full`,`screen`]),lre=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ure=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,dre=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fre=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,pre=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Lg=e=>zg(e)||cre.has(e)||sre.test(e),Rg=e=>Gg(e,`length`,xre),zg=e=>!!e&&!Number.isNaN(Number(e)),Bg=e=>Gg(e,`number`,zg),Vg=e=>!!e&&Number.isInteger(Number(e)),mre=e=>e.endsWith(`%`)&&zg(e.slice(0,-1)),Hg=e=>Ig.test(e),Ug=e=>lre.test(e),hre=new Set([`length`,`size`,`percentage`]),gre=e=>Gg(e,hre,Kg),_re=e=>Gg(e,`position`,Kg),vre=new Set([`image`,`url`]),yre=e=>Gg(e,vre,Cre),bre=e=>Gg(e,``,Sre),Wg=()=>!0,Gg=(e,t,n)=>{let r=Ig.exec(e);return r?r[1]?typeof t==`string`?r[1]===t:t.has(r[1]):n(r[2]):!1},xre=e=>ure.test(e)&&!dre.test(e),Kg=()=>!1,Sre=e=>fre.test(e),Cre=e=>pre.test(e),wre=ore(()=>{let e=Fg(`colors`),t=Fg(`spacing`),n=Fg(`blur`),r=Fg(`brightness`),i=Fg(`borderColor`),a=Fg(`borderRadius`),o=Fg(`borderSpacing`),s=Fg(`borderWidth`),c=Fg(`contrast`),l=Fg(`grayscale`),u=Fg(`hueRotate`),d=Fg(`invert`),f=Fg(`gap`),p=Fg(`gradientColorStops`),m=Fg(`gradientColorStopPositions`),h=Fg(`inset`),g=Fg(`margin`),_=Fg(`opacity`),v=Fg(`padding`),y=Fg(`saturate`),b=Fg(`scale`),x=Fg(`sepia`),S=Fg(`skew`),C=Fg(`space`),w=Fg(`translate`),T=()=>[`auto`,`contain`,`none`],E=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],D=()=>[`auto`,Hg,t],O=()=>[Hg,t],k=()=>[``,Lg,Rg],A=()=>[`auto`,zg,Hg],j=()=>[`bottom`,`center`,`left`,`left-bottom`,`left-top`,`right`,`right-bottom`,`right-top`,`top`],M=()=>[`solid`,`dashed`,`dotted`,`double`,`none`],N=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],P=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`],F=()=>[``,`0`,Hg],I=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],L=()=>[zg,Hg];return{cacheSize:500,separator:`:`,theme:{colors:[Wg],spacing:[Lg,Rg],blur:[`none`,``,Ug,Hg],brightness:L(),borderColor:[e],borderRadius:[`none`,``,`full`,Ug,Hg],borderSpacing:O(),borderWidth:k(),contrast:L(),grayscale:F(),hueRotate:L(),invert:F(),gap:O(),gradientColorStops:[e],gradientColorStopPositions:[mre,Rg],inset:D(),margin:D(),opacity:L(),padding:O(),saturate:L(),scale:L(),sepia:F(),skew:L(),space:O(),translate:O()},classGroups:{aspect:[{aspect:[`auto`,`square`,`video`,Hg]}],container:[`container`],columns:[{columns:[Ug]}],"break-after":[{"break-after":I()}],"break-before":[{"break-before":I()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:[...j(),Hg]}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:[h]}],"inset-x":[{"inset-x":[h]}],"inset-y":[{"inset-y":[h]}],start:[{start:[h]}],end:[{end:[h]}],top:[{top:[h]}],right:[{right:[h]}],bottom:[{bottom:[h]}],left:[{left:[h]}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[`auto`,Vg,Hg]}],basis:[{basis:D()}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`wrap`,`wrap-reverse`,`nowrap`]}],flex:[{flex:[`1`,`auto`,`initial`,`none`,Hg]}],grow:[{grow:F()}],shrink:[{shrink:F()}],order:[{order:[`first`,`last`,`none`,Vg,Hg]}],"grid-cols":[{"grid-cols":[Wg]}],"col-start-end":[{col:[`auto`,{span:[`full`,Vg,Hg]},Hg]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[Wg]}],"row-start-end":[{row:[`auto`,{span:[Vg,Hg]},Hg]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":[`auto`,`min`,`max`,`fr`,Hg]}],"auto-rows":[{"auto-rows":[`auto`,`min`,`max`,`fr`,Hg]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:[`normal`,...P()]}],"justify-items":[{"justify-items":[`start`,`end`,`center`,`stretch`]}],"justify-self":[{"justify-self":[`auto`,`start`,`end`,`center`,`stretch`]}],"align-content":[{content:[`normal`,...P(),`baseline`]}],"align-items":[{items:[`start`,`end`,`center`,`baseline`,`stretch`]}],"align-self":[{self:[`auto`,`start`,`end`,`center`,`stretch`,`baseline`]}],"place-content":[{"place-content":[...P(),`baseline`]}],"place-items":[{"place-items":[`start`,`end`,`center`,`baseline`,`stretch`]}],"place-self":[{"place-self":[`auto`,`start`,`end`,`center`,`stretch`]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[C]}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":[C]}],"space-y-reverse":[`space-y-reverse`],w:[{w:[`auto`,`min`,`max`,`fit`,`svw`,`lvw`,`dvw`,Hg,t]}],"min-w":[{"min-w":[Hg,t,`min`,`max`,`fit`]}],"max-w":[{"max-w":[Hg,t,`none`,`full`,`min`,`max`,`fit`,`prose`,{screen:[Ug]},Ug]}],h:[{h:[Hg,t,`auto`,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],"min-h":[{"min-h":[Hg,t,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],"max-h":[{"max-h":[Hg,t,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],size:[{size:[Hg,t,`auto`,`min`,`max`,`fit`]}],"font-size":[{text:[`base`,Ug,Rg]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`,Bg]}],"font-family":[{font:[Wg]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`,Hg]}],"line-clamp":[{"line-clamp":[`none`,zg,Bg]}],leading:[{leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`,Lg,Hg]}],"list-image":[{"list-image":[`none`,Hg]}],"list-style-type":[{list:[`none`,`disc`,`decimal`,Hg]}],"list-style-position":[{list:[`inside`,`outside`]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[_]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[_]}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...M(),`wavy`]}],"text-decoration-thickness":[{decoration:[`auto`,`from-font`,Lg,Rg]}],"underline-offset":[{"underline-offset":[`auto`,Lg,Hg]}],"text-decoration-color":[{decoration:[e]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:O()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,Hg]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,Hg]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-opacity":[{"bg-opacity":[_]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:[...j(),_re]}],"bg-repeat":[{bg:[`no-repeat`,{repeat:[``,`x`,`y`,`round`,`space`]}]}],"bg-size":[{bg:[`auto`,`cover`,`contain`,gre]}],"bg-image":[{bg:[`none`,{"gradient-to":[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},yre]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[s]}],"border-w-x":[{"border-x":[s]}],"border-w-y":[{"border-y":[s]}],"border-w-s":[{"border-s":[s]}],"border-w-e":[{"border-e":[s]}],"border-w-t":[{"border-t":[s]}],"border-w-r":[{"border-r":[s]}],"border-w-b":[{"border-b":[s]}],"border-w-l":[{"border-l":[s]}],"border-opacity":[{"border-opacity":[_]}],"border-style":[{border:[...M(),`hidden`]}],"divide-x":[{"divide-x":[s]}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":[s]}],"divide-y-reverse":[`divide-y-reverse`],"divide-opacity":[{"divide-opacity":[_]}],"divide-style":[{divide:M()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:[``,...M()]}],"outline-offset":[{"outline-offset":[Lg,Hg]}],"outline-w":[{outline:[Lg,Rg]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:k()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[_]}],"ring-offset-w":[{"ring-offset":[Lg,Rg]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:[``,`inner`,`none`,Ug,bre]}],"shadow-color":[{shadow:[Wg]}],opacity:[{opacity:[_]}],"mix-blend":[{"mix-blend":[...N(),`plus-lighter`,`plus-darker`]}],"bg-blend":[{"bg-blend":N()}],filter:[{filter:[``,`none`]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":[``,`none`,Ug,Hg]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[y]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":[``,`none`]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[_]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[`none`,`all`,``,`colors`,`opacity`,`shadow`,`transform`,Hg]}],duration:[{duration:L()}],ease:[{ease:[`linear`,`in`,`out`,`in-out`,Hg]}],delay:[{delay:L()}],animate:[{animate:[`none`,`spin`,`ping`,`pulse`,`bounce`,Hg]}],transform:[{transform:[``,`gpu`,`none`]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[Vg,Hg]}],"translate-x":[{"translate-x":[w]}],"translate-y":[{"translate-y":[w]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:[`center`,`top`,`top-right`,`right`,`bottom-right`,`bottom`,`bottom-left`,`left`,`top-left`,Hg]}],accent:[{accent:[`auto`,e]}],appearance:[{appearance:[`none`,`auto`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,Hg]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":[`none`,`auto`]}],resize:[{resize:[`none`,`y`,`x`,``]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,Hg]}],fill:[{fill:[e,`none`]}],"stroke-w":[{stroke:[Lg,Rg,Bg]}],stroke:[{stroke:[e,`none`]}],sr:[`sr-only`,`not-sr-only`],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-s`,`border-w-e`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-s`,`border-color-e`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]}}});function X(...e){return wre(Dg(e))}var qg=Wne,Jg=Gne,Yg=Kne,Xg=b.forwardRef(({className:e,sideOffset:t=4,container:n,...r},i)=>{let a=(0,Y.jsx)(Tg,{ref:i,sideOffset:t,className:X(`z-50 overflow-hidden rounded-md border bg-bg-primary px-3 py-2 text-sm text-fg-primary shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r});return n?(0,Y.jsx)(qne,{container:n,children:a}):a});Xg.displayName=Tg.displayName;var Zg=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Qg=Dg,Tre=(e,t)=>n=>{if(t?.variants==null)return Qg(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Zg(t)||Zg(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Qg(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},Ere=`disabled:text-fg-disabled disabled:pointer-events-none disabled:opacity-50 aria-disabled:text-fg-disabled aria-disabled:pointer-events-none aria-disabled:opacity-50`,$g=`disabled:bg-bg-disabled disabled:text-fg-disabled disabled:border disabled:border-border-primary aria-disabled:bg-bg-disabled aria-disabled:text-fg-disabled aria-disabled:border aria-disabled:border-border-primary`,e_=Tre(X(`inline-flex items-center justify-center whitespace-nowrap rounded-md text-fg-primary text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,Ere),{variants:{variant:{default:X(`cursor-pointer`,`border border-border-brand-primary`,`bg-bg-brand-primary text-fg-brand-primary`,`hover:bg-bg-brand-primary-hover hover:text-fg-brand-primary-hover`,$g),destructive:X(`cursor-pointer`,`border border-bg-error-primary`,`bg-bg-error-primary text-fg-error-primary hover:bg-bg-error-primary-hover disabled:text-fg-error-primary aria-disabled:text-fg-error-primary`),warning:X(`cursor-pointer`,`border border-bg-warning-secondary`,`bg-bg-warning-secondary text-fg-warning-secondary hover:bg-bg-warning-secondary-hover disabled:text-fg-warning-secondary aria-disabled:text-fg-warning-secondary`),outline:X(`cursor-pointer`,`border border-transparent`,`bg-transparent hover:bg-bg-secondary`,$g),secondary:X(`cursor-pointer`,`border border-border-secondary`,`bg-bg-secondary text-fg-secondary hover:bg-bg-secondary-hover`,$g),ghost:X(`cursor-pointer`,`border border-transparent`,`bg-transparent hover:bg-bg-secondary`,$g,`hover:bg-bg-secondary-hover hover:text-fg-secondary`),link:X(`cursor-pointer`,`border border-transparent`,`text-fg-primary underline-offset-4 hover:underline`)},size:{default:`h-10 px-4 py-2`,sm:`h-9 rounded-md px-3`,xs:`h-8 rounded-md px-2`,lg:`h-11 rounded-md px-8`,icon:`h-10 w-10`,"icon-sm":`h-8 w-8`}},defaultVariants:{variant:`default`,size:`default`}}),t_=b.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,disabled:i,...a},o)=>(0,Y.jsx)(r?fm:`button`,{className:X(e_({variant:t,size:n,className:e})),ref:o,disabled:i,"aria-disabled":i||void 0,...a}));t_.displayName=`Button`;var Dre=Object.defineProperty,n_=(e,t)=>Dre(e,`name`,{value:t,configurable:!0}),r_=`focusScope.autoFocusOnMount`,i_=`focusScope.autoFocusOnUnmount`,a_={bubbles:!1,cancelable:!0},o_=b.forwardRef(n_(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=b.useState(null),l=Cm(i),u=Cm(a),d=b.useRef(null),f=am(t,c),p=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:p_(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||p_(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&p_(s)};n_(e,`handleFocusIn`),n_(t,`handleFocusOut`),n_(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),b.useEffect(()=>{if(s){m_.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(r_,a_);s.addEventListener(r_,l),s.dispatchEvent(t),t.defaultPrevented||(s_(__(l_(s)),{select:!0}),document.activeElement===e&&p_(s))}return()=>{s.removeEventListener(r_,l),setTimeout(()=>{let t=new CustomEvent(i_,a_);s.addEventListener(i_,u),s.dispatchEvent(t),t.defaultPrevented||p_(e??document.body,{select:!0}),s.removeEventListener(i_,u),m_.remove(p)},0)}}},[s,l,u,p]);let m=b.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=c_(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&p_(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&p_(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,Y.jsx)(xm.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})},`FocusScope`));function s_(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(p_(r,{select:t}),document.activeElement!==n)return}n_(s_,`focusFirst`);function c_(e){let t=l_(e);return[u_(t,e),u_(t.reverse(),e)]}n_(c_,`getTabbableEdges`);function l_(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n_(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}n_(l_,`getTabbableCandidates`);function u_(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):d_(r,{upTo:t})))return r}n_(u_,`findVisible`);function d_(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}n_(d_,`isHidden`);function f_(e){return e instanceof HTMLInputElement&&`select`in e}n_(f_,`isSelectableInput`);function p_(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&f_(e)&&t&&e.select()}}n_(p_,`focus`);var m_=h_();function h_(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=g_(e,t),e.unshift(t)},remove(t){e=g_(e,t),e[0]?.resume()}}}n_(h_,`createFocusScopesStack`);function g_(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}n_(g_,`arrayRemove`);function __(e){return e.filter(e=>e.tagName!==`A`)}n_(__,`removeLinks`);var Ore=Object.defineProperty,v_=(e,t)=>Ore(e,`name`,{value:t,configurable:!0}),y_=0,b_=null;function kre(e){return x_(),e.children}v_(kre,`FocusGuards`);function x_(){b.useEffect(()=>{b_||={start:S_(),end:S_()};let{start:e,end:t}=b_;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),y_++,()=>{y_===1&&(b_?.start.remove(),b_?.end.remove(),b_=null),y_=Math.max(0,y_-1)}},[])}v_(x_,`useFocusGuards`);function S_(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}v_(S_,`createFocusGuard`);var C_=function(){return C_=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},C_.apply(this,arguments)};function w_(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Are(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var T_=`right-scroll-bar-position`,E_=`width-before-scroll-bar`,jre=`with-scroll-bars-hidden`,Mre=`--removed-body-scroll-bar-size`;function D_(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Nre(e,t){var n=(0,b.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Pre=typeof window<`u`?b.useLayoutEffect:b.useEffect,O_=new WeakMap;function Fre(e,t){var n=Nre(t||null,function(t){return e.forEach(function(e){return D_(e,t)})});return Pre(function(){var t=O_.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||D_(e,null)}),i.forEach(function(e){r.has(e)||D_(e,a)})}O_.set(n,e)},[e]),n}function Ire(e){return e}function Lre(e,t){t===void 0&&(t=Ire);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Rre(e){e===void 0&&(e={});var t=Lre(null);return t.options=C_({async:!0,ssr:!1},e),t}var k_=function(e){var t=e.sideCar,n=w_(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return b.createElement(r,C_({},n))};k_.isSideCarExport=!0;function zre(e,t){return e.useMedium(t),k_}var A_=Rre(),j_=function(){},M_=b.forwardRef(function(e,t){var n=b.useRef(null),r=b.useState({onScrollCapture:j_,onWheelCapture:j_,onTouchMoveCapture:j_}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,x=w_(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,C=Fre([n,t]),w=C_(C_({},x),i);return b.createElement(b.Fragment,null,u&&b.createElement(S,{sideCar:A_,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?b.cloneElement(b.Children.only(s),C_(C_({},w),{ref:C})):b.createElement(v,C_({},w,{className:c,ref:C}),s))});M_.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},M_.classNames={fullWidth:E_,zeroRight:T_};var Bre=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Vre(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Bre();return t&&e.setAttribute(`nonce`,t),e}function Hre(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ure(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Wre=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Vre())&&(Hre(t,n),Ure(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Gre=function(){var e=Wre();return function(t,n){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},N_=function(){var e=Gre();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Kre={left:0,top:0,right:0,gap:0},P_=function(e){return parseInt(e||``,10)||0},qre=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[P_(n),P_(r),P_(i)]},Jre=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Kre;var t=qre(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Yre=N_(),F_=`data-scroll-locked`,Xre=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
84
84
|
.${jre} {
|
|
85
85
|
overflow: hidden ${r};
|
|
@@ -129,7 +129,7 @@ All routes will be filtered out due to malformed exclude pattern.`)}return e.fil
|
|
|
129
129
|
`)}}var Lb=class e{constructor(){this.target=new EventTarget}static{this.ANY=`val:any`}emit(t){this.target.dispatchEvent(new CustomEvent(e.ANY,{detail:t})),this.target.dispatchEvent(new CustomEvent(t.type,{detail:t}))}on(e,t){let n=e=>{t(e.detail)};return this.target.addEventListener(e,n),()=>this.target.removeEventListener(e,n)}onAny(t){let n=e=>{t(e.detail)};return this.target.addEventListener(e.ANY,n),()=>this.target.removeEventListener(e.ANY,n)}},Rb={work:()=>{}},Doe=class{constructor(e=Rb){this.activity=e,this.events=new Lb,this.schemas={},this.versions=new Map,this.previewDeclared=new Map}receive(e){this.activity.work(`schema:receive`,void 0,Object.keys(e).length),this.schemas={...this.schemas,...e};for(let t of Object.keys(e))this.versions.set(t,(this.versions.get(t)??0)+1);this.events.emit({type:`schema:init`,modules:Object.keys(e)})}get(e){return this.schemas[e]}all(){return this.schemas}version(e){return this.versions.get(e)??0}declaresPreview(e){let t=this.version(e),n=this.previewDeclared.get(e);if(n!==void 0&&n.version===t)return n.declared;let r=this.schemas[e],i=r!==void 0&&zb(r);return this.previewDeclared.set(e,{version:t,declared:i}),i}};function zb(e,t=new Set){if(t.has(e))return!1;if(t.add(e),e.preview===!0)return!0;switch(e.type){case`array`:return zb(e.item,t);case`record`:return zb(e.item,t);case`object`:return Object.values(e.items).some(e=>zb(e,t));case`union`:return e.items.some(e=>zb(e,t));default:return!1}}function Ooe(e,t){return e===t||e.startsWith(t+`.`)||e.startsWith(t+`?p=`)}function koe(e,t){for(let n of e)if(Ooe(t,n)||Ooe(n,t))return!0;return!1}var Aoe=new qr;function joe(e,t){if(e.status!==t.status||e.errors.length!==t.errors.length)return!1;for(let n=0;n<e.errors.length;n++){let r=e.errors[n],i=t.errors[n];if(r.moduleFilePath!==i.moduleFilePath||r.key!==i.key||r.message!==i.message)return!1}return!0}var Moe=class{constructor(e,t=Rb,n){this.schemaStore=e,this.activity=t,this.fetchJsonEntry=n,this.events=new Lb,this.sources={},this.baseSources={},this.chains=new Map,this.revisions=new Map,this.peeked=new Map,this.peekedBase=new Map,this.jsonEntries=new Map,this.baseJsonEntries=new Map,this.loadingEntries=new Map,this.entryFailures=new Map,this.substituted=new WeakMap,this.listenerTargets=new Map,this.listenersByModule=new Map,this.globalRevision=0,this.deferredAnnouncements=new Set,this.batchDepth=0,this.allSourcesAt=null,this.allEntriesProgressCache=null,this.pendingEntryLoads=new Map,this.entriesStatusCache=new Map}bump(e){if(this.revisions.set(e,(this.revisions.get(e)??0)+1),this.globalRevision++,this.allSourcesAt=null,this.batchDepth>0){this.deferredAnnouncements.add(e);return}this.events.emit({type:`source:change`,moduleFilePath:e})}async batched(e){this.batchDepth++;try{return await e()}finally{if(this.batchDepth--,this.batchDepth===0&&this.deferredAnnouncements.size>0){let e=[...this.deferredAnnouncements];this.deferredAnnouncements.clear();for(let t of e)this.events.emit({type:`source:change`,moduleFilePath:t});this.events.emit({type:`source:patch-apply`,success:[],failed:[],modules:e})}}}sourcesVersion(){return this.globalRevision}allSources(){let e=this.allSourcesAt;if(e!==null&&e.n===this.globalRevision)return e.sources;let t={};for(let e of Object.keys(this.sources)){let n=this.moduleSource(e);n!==void 0&&(t[e]=n)}return this.allSourcesAt={n:this.globalRevision,sources:t},t}allEntriesProgress(){let e=0,t=0,n=0;for(let r of Object.keys(this.sources)){let i=this.entriesProgress(r);e+=i.total,t+=i.loaded,n+=i.failed}let r={total:e,loaded:t,failed:n},i=this.allEntriesProgressCache;return i!==null&&i.total===r.total&&i.loaded===r.loaded&&i.failed===r.failed?i:(this.allEntriesProgressCache=r,r)}receiveJsonEntry(e,t,n){let r=this.jsonEntries.get(e);r===void 0&&(r=new Map,this.jsonEntries.set(e,r)),r.set(t,n);let i=this.baseJsonEntries.get(e);i===void 0&&(i=new Map,this.baseJsonEntries.set(e,i)),i.set(t,Nr(n)),this.activity.work(`source:receive-json-entry`,e),this.bump(e),!(this.batchDepth>0)&&this.events.emit({type:`source:patch-apply`,success:[],failed:[],modules:[e]})}markJsonEntriesStale(e){let t=this.clearEntryFailures(e);if(!this.jsonEntries.has(e)){t&&this.bump(e);return}this.jsonEntries.delete(e),this.baseJsonEntries.delete(e),this.bump(e)}clearEntryFailures(e){if(this.entryFailures.size===0)return!1;let t=`${e}\0`,n=!1;for(let e of[...this.entryFailures.keys()])e.startsWith(t)&&(this.entryFailures.delete(e),n=!0);return n}async loadEntries(e,t){let n=this.jsonEntries.get(e),r=t.filter(t=>n?.has(t)!==!0&&!this.entryFailures.has(Ub(e,t)));if(r.length===0)return;let i=this.pendingEntryLoads.get(e);if(i===void 0){let t=new Set;i={keys:t,request:(async()=>{await Promise.resolve(),this.pendingEntryLoads.delete(e),await this.batched(()=>Promise.all([...t].map(t=>this.loadEntry(e,t))))})()},this.pendingEntryLoads.set(e,i)}for(let e of r)i.keys.add(e);await i.request}async loadAllEntries(e){let t=this.sources[e];if(t===void 0||!Hb(t))return;let n=[];for(let[e,r]of Object.entries(t))H.isJson(r)&&n.push(e);await this.loadEntries(e,n)}entriesStatus(e){let t=[],n=!1;for(let r of e){let e=this.sources[r];if(e===void 0){n=!0;continue}if(!Hb(e))continue;let i=this.jsonEntries.get(r);for(let[a,o]of Object.entries(e)){if(!H.isJson(o)||i?.has(a)===!0)continue;let e=this.entryFailures.get(Ub(r,a));if(e!==void 0){t.push({moduleFilePath:r,key:a,message:e});continue}n=!0}}let r=t.length>0?{status:`error`,errors:t}:{status:n?`incomplete`:`complete`,errors:t},i=e.join(`
|
|
130
130
|
`),a=this.entriesStatusCache.get(i);return a!==void 0&&joe(a,r)?a:(this.entriesStatusCache.set(i,r),r)}entryError(e,t){return this.entryFailures.get(Ub(e,t))}hasUnloadedEntries(e){let t=this.sources[e];if(t===void 0||!Hb(t))return!1;let n=this.jsonEntries.get(e);for(let[e,r]of Object.entries(t))if(H.isJson(r)&&n?.has(e)!==!0)return!0;return!1}peek(e){let t=this.computePeek(e,this.sources,this.jsonEntries),n=this.peeked.get(e);return n!==void 0&&Noe(n,t)?n:(this.peeked.set(e,t),t)}computePeek(e,t,n){let[r,i]=H.splitModuleFilePathAndModulePath(e),a=t[r];if(a===void 0||this.schemaStore.get(r)===void 0)return{status:`module-loading`};let o=Vb(this.substitutedSource(r,a,n),i);if(o.status===`needs-entry`){let e=Ub(r,o.key);if(this.loadingEntries.has(e))return{status:`entry-loading`,key:o.key};let t=this.entryFailures.get(e);return t===void 0?{status:`entry-missing`,key:o.key}:{status:`entry-failed`,key:o.key,message:t}}let s=this.revisionOf(r);return o.status===`found`?{status:`ready`,revision:s,data:o.value}:o.status===`absent`?{status:`absent`,revision:s}:{status:`module-loading`}}storePatched(e,t,n,r){let i=r?.sources??this.sources,a=(r?.entries??this.jsonEntries).get(e);if(a===void 0||a.size===0||!Hb(n)||!Hb(t)){i[e]=n;return}let o={...n};for(let e of[...a.keys()]){if(!(e in o)){a.delete(e);continue}H.isJson(t[e])&&(a.set(e,o[e]),o[e]=t[e])}i[e]=o}async loadEntry(e,t){if(this.fetchJsonEntry===void 0)return{status:`error`,message:`Cannot read inside '${t}' of ${e}: no jsonValues fetch is configured. Refusing rather than reporting the path absent.`};let n=Ub(e,t),r=this.loadingEntries.get(n);if(r!==void 0){this.activity.work(`source:share-json-entry-load`,e),await r;let t=this.entryFailures.get(n);return t===void 0?{status:`ok`}:{status:`error`,message:t}}let i;this.entryFailures.delete(n);let a=(async()=>{this.activity.work(`source:load-json-entry`,e);let r=await this.fetchJsonEntry(e,t);if(r.status===`error`){i=r.message,this.entryFailures.set(n,r.message);return}this.receiveJsonEntry(e,t,r.content)})().finally(()=>{this.loadingEntries.delete(n)});return this.loadingEntries.set(n,a),await a,i===void 0?{status:`ok`}:{status:`error`,message:i}}peekBase(e){let t=this.computePeek(e,this.baseSources,this.baseJsonEntries),n=this.peekedBase.get(e);return n!==void 0&&Noe(n,t)?n:(this.peekedBase.set(e,t),t)}entriesProgress(e){let t=this.sources[e];if(t===void 0||!Hb(t))return{total:0,loaded:0,failed:0};let n=this.jsonEntries.get(e),r=0,i=0,a=0;for(let[o,s]of Object.entries(t))H.isJson(s)&&(r++,n?.has(o)===!0?i++:this.entryFailures.has(Ub(e,o))&&a++);return{total:r,loaded:i,failed:a}}async retryEntry(e,t){return this.entryFailures.delete(Ub(e,t)),this.loadEntry(e,t)}promoteToBase(e){for(let t of e){let e=this.sources[t];if(e===void 0)continue;this.activity.work(`source:promote-to-base`,t),this.baseSources[t]=Nr(e);let n=this.jsonEntries.get(t);n!==void 0&&this.baseJsonEntries.set(t,new Map([...n].map(([e,t])=>[e,Nr(t)])))}}promotePublished(e,t){let n=new Set(e);for(let e of t){let t=this.chains.get(e)??[],r=t.filter(e=>!n.has(e.record.patchId));if(r.length===t.length)continue;if(r.length===0){this.promoteToBase([e]),this.chains.set(e,[]);continue}let i=this.baseSources[e];if(i===void 0){this.chains.set(e,r);continue}let a=Nr(this.substitutedSource(e,i,this.baseJsonEntries)),o=!0;for(let r of t){if(!n.has(r.record.patchId))continue;let t=r.record.patch.filter(e=>e.op!==`file`);if(t.length===0)continue;this.activity.work(`source:apply-patch`,r.record.patchId);let i=Yr(Nr(a),Aoe,t);if(!te.isOk(i)){console.error(`Val: could not rebuild the base after a partial save. The value on screen is right; the base behind it is stale until the next load.`,{moduleFilePath:e,patchId:r.record.patchId,error:i.error}),o=!1;break}a=i.value}o&&(this.activity.work(`source:promote-to-base`,e),this.storePatched(e,i,a,{sources:this.baseSources,entries:this.baseJsonEntries}),this.chains.set(e,r))}}forgetPublished(e){let t=new Set(e);for(let[e,n]of this.chains){let r=n.filter(e=>!t.has(e.record.patchId));r.length!==n.length&&this.chains.set(e,r)}}revisionOf(e){return{module:e,n:this.revisions.get(e)??0}}listenTo(e){let t=e.events.on(`patch:receive`,t=>{this.intake({kind:`foreign`,records:e.recordsFor(t.patches)})}),n=e.events.on(`patch:create`,t=>{this.intake({kind:`local`,records:e.recordsFor(t.patches),creatorOf:t=>e.creatorOf(t)})}),r=e.events.on(`patch:drop`,e=>{this.intake({kind:`revoked`,patchIds:e.patches,modules:e.modules})});return()=>{t(),n(),r()}}intake(e){if(e.kind===`revoked`){this.dropFromChains(e.patchIds,e.modules);return}this.applyPatches(e.records,e.kind===`local`?`internal`:`external`,e.kind===`local`?e.creatorOf:()=>void 0)}dropFromChains(e,t){let n=new Set(e),r=[],i=[];for(let e of t){let t=this.chains.get(e);if(t!==void 0){let r=t.filter(e=>!n.has(e.record.patchId));if(r.length===t.length)continue;for(let e of t)n.has(e.record.patchId)&&i.push(...Poe(e.record));this.chains.set(e,r)}let a=this.baseSources[e];if(a===void 0)continue;this.activity.work(`source:rebuild-module`,e),this.sources[e]=Nr(a);let o=this.baseJsonEntries.get(e);o!==void 0&&this.jsonEntries.set(e,new Map([...o].map(([e,t])=>[e,Nr(t)]))),this.bump(e),r.push(e)}if(r.length>0){this.events.emit({type:`source:patch-drop`,modules:r});for(let e of r){let t=this.chains.get(e);t!==void 0&&t.length!==0&&this.applyEntries(t.map(e=>({record:e.record,origin:`external`,creatorFieldId:void 0})))}i.length>0&&this.wakeListeners(new Set(r),[{origin:`external`,creatorFieldId:void 0,paths:i}])}}receive(e){for(let[t,n]of Object.entries(e)){this.activity.work(`source:clone-module`,t);let e=Nr(n);this.baseSources[t]=e,this.sources[t]=Nr(e),this.clearEntryFailures(t),this.bump(t)}this.events.emit({type:`source:init`,sources:Object.keys(e)});for(let t of Object.keys(e)){let e=this.chains.get(t);e!==void 0&&e.length!==0&&this.applyEntries(e)}let t=Object.keys(e).filter(e=>this.sources[e]!==void 0);t.length>0&&this.wakeListeners(new Set(t),[{origin:`external`,creatorFieldId:void 0,paths:t}])}async get(e,t){let[n,r]=H.splitModuleFilePathAndModulePath(e),i=this.revisionOf(n),a=this.sources[n];if(t!==null&&t.module===n&&t.n===i.n&&a!==void 0&&this.schemaStore.get(n)!==void 0)return{status:`unchanged`,revision:i};if(a===void 0||this.schemaStore.get(n)===void 0)return{status:`module-loading`};this.activity.work(`source:read-path`,e);let o=Vb(this.substitutedSource(n,a),r);if(o.status===`needs-entry`){let e=await this.loadEntry(n,o.key);if(e.status===`error`)return{status:`error`,message:e.message};let t=this.sources[n];if(t===void 0)return{status:`module-loading`};if(o=Vb(this.substitutedSource(n,t),r),o.status===`needs-entry`)return{status:`error`,message:`Entry '${o.key}' of ${n} was loaded but its content is still missing.`}}let s=this.revisionOf(n);return o.status===`absent`?{status:`absent`,revision:s}:o.status===`error`?{status:`error`,message:o.message}:{status:`resolved-head`,data:o.value,revision:s}}async isCurrent(e){return e.n===this.revisionOf(e.module).n}moduleSource(e){let t=this.sources[e];if(t===void 0)return;let n=this.jsonEntries.get(e);return n===void 0||n.size===0?t:this.substitutedSource(e,t)}substitutedSource(e,t,n=this.jsonEntries){let r=n.get(e);if(r===void 0||r.size===0||!Hb(t))return t;let i=this.revisions.get(e)??0,a=this.substituted.get(t);if(a!==void 0&&a.n===i)return a.source;this.activity.work(`source:substitute-json-entries`,e);let o=Foe(t,r);return this.substituted.set(t,{n:i,source:o}),o}loadedModules(){return Object.keys(this.sources)}listenedPaths(e){let t=this.listenersByModule.get(e);return t===void 0?[]:[...t]}addListener(e,t,n){let r=this.listenerTargets.get(e);r||(r=new Map,this.listenerTargets.set(e,r));let i=r.get(t);i||(i={target:new EventTarget,count:0},r.set(t,i));let a=i,o=r,[s]=H.splitModuleFilePathAndModulePath(e),c=this.listenersByModule.get(s);c===void 0&&(c=new Set,this.listenersByModule.set(s,c)),c.add(e);let l=e=>{n(e.detail)};a.target.addEventListener(Bb,l),a.count++;let[u]=H.splitModuleFilePathAndModulePath(e);this.events.emit({type:`source:listen`,path:e,moduleFilePath:u});let d=!1;return()=>{if(!d&&(d=!0,a.target.removeEventListener(Bb,l),a.count--,this.events.emit({type:`source:unlisten`,path:e,moduleFilePath:u}),a.count<=0&&o.get(t)===a&&(o.delete(t),o.size===0&&this.listenerTargets.get(e)===o))){this.listenerTargets.delete(e);let t=this.listenersByModule.get(s);t!==void 0&&(t.delete(e),t.size===0&&this.listenersByModule.delete(s))}}}applyPatches(e,t,n){if(e.length===0)return;let r=e.map(e=>({record:e,origin:t,creatorFieldId:n(e.patchId)}));for(let e of r){let t=e.record.moduleFilePath,n=this.chains.get(t);n===void 0?this.chains.set(t,[e]):n.push(e)}this.applyEntries(r)}applyEntries(e){if(e.length===0)return;let t=[],n=[],r=[],i=new Set,a=[];for(let{record:o,origin:s,creatorFieldId:c}of e){let e=this.sources[o.moduleFilePath],l=e===void 0?void 0:this.substitutedSource(o.moduleFilePath,e);if(l===void 0||e===void 0){this.activity.work(`source:skip-unloaded`,o.moduleFilePath);continue}let u=o.patch.filter(e=>e.op!==`file`);if(u.length===0){t.push(o.patchId);continue}this.activity.work(`source:clone-module`,o.moduleFilePath),this.activity.work(`source:apply-patch`,o.patchId);let d=Yr(Nr(l),Aoe,u);if(te.isOk(d)){this.storePatched(o.moduleFilePath,e,d.value),this.bump(o.moduleFilePath),t.push(o.patchId),i.add(o.moduleFilePath);let n=Poe(o);r.push(...n);let l=a.find(e=>e.origin===s&&e.creatorFieldId===c);l===void 0?a.push({origin:s,creatorFieldId:c,paths:[...n]}):l.paths.push(...n)}else n.push({patchId:o.patchId,message:d.error.message})}(t.length!==0||n.length!==0)&&(this.events.emit({type:`source:patch-apply`,success:t,failed:n,modules:[...i]}),r.length!==0&&this.wakeListeners(i,a))}wakeListeners(e,t){let n=new Set;for(let t of e){let e=this.listenersByModule.get(t);if(e!==void 0)for(let t of e)n.add(t)}this.activity.work(`source:scan-listeners`,void 0,n.size);for(let e of n){let n=this.listenerTargets.get(e);if(n===void 0)continue;let r=t.filter(t=>koe(t.paths,e));if(r.length===0)continue;let[i]=H.splitModuleFilePathAndModulePath(e),a=this.revisionOf(i);for(let[t,i]of n){let n=r.find(e=>e.creatorFieldId!==t);if(n===void 0)continue;this.activity.work(`source:wake-listener`,e);let o={type:`${n.origin}-patch`,path:e,revision:a};i.target.dispatchEvent(new CustomEvent(Bb,{detail:o}))}}}},Bb=`val:field-changed`;function Noe(e,t){return e.status===t.status?e.status===`ready`&&t.status===`ready`?e.data===t.data&&e.revision.n===t.revision.n:e.status===`absent`&&t.status===`absent`?e.revision.n===t.revision.n:e.status===`entry-failed`&&t.status===`entry-failed`?e.key===t.key&&e.message===t.message:e.status===`entry-missing`&&t.status===`entry-missing`||e.status===`entry-loading`&&t.status===`entry-loading`?e.key===t.key:e.status===`module-loading`:!1}function Poe(e){let t=[],n=n=>{t.push(H.joinModuleFilePathAndModulePath(e.moduleFilePath,H.patchPathToModulePath(n)))};for(let t of e.patch)t.op!==`file`&&(n(t.path),(t.op===`move`||t.op===`copy`)&&(n(t.from),r(t.from)),(t.op===`add`||t.op===`remove`||t.op===`move`)&&r(t.path));return t;function r(e){if(e.length===0)return;let t=e[e.length-1];Number.isInteger(Number(t))&&n(e.slice(0,-1))}}function Vb(e,t){let n=H.splitModulePath(t),r=e;for(let e=0;e<n.length;e++){let t=n[e];if(typeof r!=`object`||!r)return{status:`absent`};if(Array.isArray(r)){let e=Number(t);if(!Number.isInteger(e)||e<0||e>=r.length)return{status:`absent`};r=r[e];continue}if(!(t in r))return{status:`absent`};if(r=r[t],e===0&&e<n.length-1&&H.isJson(r))return{status:`needs-entry`,key:t}}return{status:`found`,value:r}}function Foe(e,t){if(t===void 0||t.size===0||!Hb(e))return e;let n=null;for(let[r,i]of t)H.isJson(e[r])&&(n===null&&(n={...e}),n[r]=i);return n??e}function Hb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ub(e,t){return`${e}\0${t}`}var Ioe=new TextEncoder;function Loe(e){let t=[],n=[];for(let r of e)r.op===`file`?(t.push(r),n.push({...r,value:typeof r.value==`string`?H.getSHA256Hash(Ioe.encode(r.value)):r.value})):n.push(r);return{patchOps:n,fileOps:t}}function Roe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].record!==t[n].record||e[n].isPending!==t[n].isPending)return!1;return!0}function zoe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var Boe=class{setPublishInFlight(e){this.publishInFlight=e}setParentRefSource(e){this.parentRefSource=e}constructor(e,t=()=>crypto.randomUUID(),n=Rb,r){this.fetchPatches=e,this.newPatchId=t,this.activity=n,this.uploadFile=r,this.events=new Lb,this.ordered=[],this.dataById=new Map,this.originById=new Map,this.appliedIds=new Set,this.failedById=new Map,this.fetching=new Set,this.creatorByPatchId=new Map,this.sessionByPatchId=new Map,this.pendingIds=new Set,this.verifying=new Set,this.notDeliveredOnce=new Set,this.publishInFlight=()=>!1,this.lastBaseSha=null,this.publishedIds=new Set,this.publishedModuleFilePaths=new Set,this.version=0,this.parentRefSource=()=>null,this.statSeen=!1,this.publishErrorById=new Map,this.publishErrorsAt=null,this.patchesByPathAt=null,this.filePatchIdsAt=null}listenTo(e,t){let n=e.events.on(`stat:receive`,t=>{let n=e.currentBaseSha(),r=this.lastBaseSha!==null&&n!==null&&n!==this.lastBaseSha;n!==null&&(this.lastBaseSha=n),this.onStatPatchIds(t.patches,r)}),r=t.events.on(`source:patch-apply`,e=>{for(let t of e.success)this.appliedIds.add(t),this.failedById.delete(t);for(let t of e.failed)this.failedById.set(t.patchId,t.message),this.appliedIds.delete(t.patchId);this.events.emit({type:`patch:head`,head:this.currentHead()})});return()=>{n(),r()}}async onStatPatchIds(e,t=!1){let n=!this.statSeen;this.statSeen=!0;let r=new Set(e.filter(e=>this.publishedIds.has(e)&&!this.dataById.has(e)));r.size>0&&console.debug(`Val: ignoring published changes named by a stat that predates the publish.`,{patchIds:[...r]});let i=r.size>0?e.filter(e=>!r.has(e)):e,a=new Set(i);for(let e of i)this.originById.has(e)||this.originById.set(e,`external`);let o=this.ordered.filter(e=>!a.has(e)),s=[...i,...o],c=n||!zoe(this.ordered,s);this.ordered=s,c&&this.bump(),this.reconcileVanished(o.filter(e=>!this.pendingIds.has(e)),t);let l=i.filter(e=>!this.dataById.has(e)&&!this.fetching.has(e));if(c&&this.events.emit({type:`patch:head`,head:this.currentHead()}),l.length===0)return;for(let e of l)this.fetching.add(e);this.activity.work(`patch:fetch`,void 0,l.length);let u=await this.fetchPatches(l);u.error!==void 0&&this.events.emit({type:`patch:fetch-failed`,patches:l,message:u.error});let d=[];for(let e of u.patches)this.fetching.delete(e.patchId),this.notDeliveredOnce.delete(e.patchId),this.dataById.set(e.patchId,e),d.push(e.patchId),this.bump();for(let[e,t]of Object.entries(u.errors??{}))this.fetching.delete(e),this.notDeliveredOnce.delete(e),this.failedById.set(e,t);let f=[],p=[];for(let e of l)if(this.fetching.delete(e)&&!this.dataById.has(e)&&this.ordered.includes(e)){if(!this.notDeliveredOnce.has(e)){this.notDeliveredOnce.add(e),p.push(e);continue}this.failedById.set(e,`The server said this change exists, but did not send it.`),f.push(e)}p.length>0&&console.warn(`Val: the server named these unpublished changes and did not send them. Asking again on the next stat before reporting it — an announcement can be older than a delete.`,{patchIds:p}),d.length>0&&this.events.emit({type:`patch:receive`,patches:d}),f.length>0&&this.events.emit({type:`patch:announced-not-delivered`,patches:f})}async reconcileVanished(e,t){if(this.publishInFlight())return;let n=e.filter(e=>!this.verifying.has(e));if(n.length!==0){for(let e of n)this.verifying.add(e);this.activity.work(`patch:verify-vanished`,void 0,n.length);try{let e=await this.fetchPatches(n);e.error!==void 0&&this.events.emit({type:`patch:fetch-failed`,patches:n,message:e.error});let r=new Set;for(let t of e.patches)r.add(t.patchId);for(let t of Object.keys(e.errors??{}))r.add(t);let i=n.filter(e=>!r.has(e)&&this.ordered.includes(e)&&!this.pendingIds.has(e));i.length>0&&(t?this.forgetPublished(i):this.drop(i))}finally{for(let e of n)this.verifying.delete(e)}}}async createPatch(e,t,n,r,i,a,o,s=`image`,c=!1){let l=a??this.newPatchId(),u=this.parentRefSource(),{patchOps:d,fileOps:f}=Loe(t),p=c?[]:f.filter(e=>typeof e.value==`string`),m=f.filter(e=>e.value===null);if((p.length>0||m.length>0)&&!this.uploadFile)return{status:`upload-failed`,message:`This patch carries files, but no upload seam is configured. Refusing rather than dropping the bytes.`,rolledBack:[],orphaned:[]};let h=this.uploadFile,g=[];if(h)for(let e of p){this.activity.work(`patch:upload-file`,e.filePath);let t=g.length,n=await h({patchId:l,parentRef:u,filePath:e.filePath,data:e.value,type:s,remote:e.remote,metadata:e.metadata,onProgress:i===void 0?void 0:(e,n)=>i(e,n,t,p.length)});if(n.status===`error`){let e=[],t=[];for(let n of g)this.activity.work(`patch:rollback-file`,n.filePath),(await h({patchId:l,parentRef:u,filePath:n.filePath,data:null,type:s,remote:n.remote})).status===`ok`?e.push(n.filePath):t.push(n.filePath);return{status:`upload-failed`,message:n.message,rolledBack:e,orphaned:t}}g.push({filePath:e.filePath,remote:e.remote===!0})}let _={patchId:l,moduleFilePath:e,patch:d,meta:n,createdAt:new Date().toISOString()};if(this.dataById.set(l,_),this.originById.set(l,`internal`),this.pendingIds.add(l),r!==void 0&&this.creatorByPatchId.set(l,r),o!==void 0&&this.sessionByPatchId.set(l,o),this.ordered=[...this.ordered,l],this.bump(),this.activity.work(`patch:create`,l),this.events.emit({type:`patch:create`,patches:[l]}),h)for(let e of m)this.activity.work(`patch:delete-file`,e.filePath),await h({patchId:l,parentRef:u,filePath:e.filePath,data:null,type:s,remote:e.remote});return{status:`created`,record:_}}unsavedRecords(){let e=[];for(let t of this.ordered){if(!this.pendingIds.has(t))continue;let n=this.dataById.get(t);n&&e.push(n)}return e}mintPatchId(){return this.newPatchId()}sessionOf(e){return this.sessionByPatchId.get(e)}isPending(e){return this.pendingIds.has(e)}pendingPatchIds(){return this.ordered.filter(e=>this.pendingIds.has(e))}markPublished(e){let t=!1;for(let n of e)this.publishedIds.has(n)||(this.publishedIds.add(n),t=!0);t&&this.bump()}publishedPatchIds(){return this.publishedIds}publishedModules(){return[...this.publishedModuleFilePaths]}markSaved(e){let t=[];for(let n of e)this.pendingIds.delete(n)&&t.push(n);t.length!==0&&(this.bump(),this.activity.work(`patch:mark-saved`,void 0,t.length))}forgetPublished(e){let t=[];for(let n of e){if(!this.dataById.has(n)&&!this.ordered.includes(n))continue;let e=this.dataById.get(n)?.moduleFilePath;e!==void 0&&this.publishedModuleFilePaths.add(e),this.dataById.delete(n),this.originById.delete(n),this.pendingIds.delete(n),this.appliedIds.delete(n),this.failedById.delete(n),this.creatorByPatchId.delete(n),this.sessionByPatchId.delete(n),this.fetching.delete(n),this.notDeliveredOnce.delete(n),this.publishErrorById.delete(n),t.push(n)}if(t.length===0)return;let n=new Set(t);this.ordered=this.ordered.filter(e=>!n.has(e)),this.bump(),this.activity.work(`patch:forget-published`,void 0,t.length),this.events.emit({type:`patch:head`,head:this.currentHead()})}drop(e){let t=[],n=new Set;for(let r of e){let e=this.dataById.get(r);e===void 0&&!this.ordered.includes(r)||(e!==void 0&&n.add(e.moduleFilePath),this.dataById.delete(r),this.originById.delete(r),this.pendingIds.delete(r),this.appliedIds.delete(r),this.failedById.delete(r),this.creatorByPatchId.delete(r),this.sessionByPatchId.delete(r),this.fetching.delete(r),this.notDeliveredOnce.delete(r),this.publishErrorById.delete(r),this.publishedIds.delete(r),t.push(r))}if(t.length===0)return;let r=new Set(t);this.ordered=this.ordered.filter(e=>!r.has(e)),this.bump(),this.activity.work(`patch:drop`,void 0,t.length),this.events.emit({type:`patch:drop`,patches:t,modules:[...n]}),this.events.emit({type:`patch:head`,head:this.currentHead()})}async getHead(){return this.currentHead()}recordsFor(e){let t=new Set(e),n=[];for(let e of this.ordered){if(!t.has(e))continue;let r=this.dataById.get(e);r&&n.push(r)}return n}allRecords(){return this.recordsFor(this.ordered)}chainVersion(){return this.version}recordPublishErrors(e){let t=Object.entries(e);if(t.length!==0){for(let[e,n]of t)this.publishErrorById.set(e,n);this.bump()}}publishErrors(){let e=this.publishErrorsAt;if(e!==null&&e.n===this.version)return e.byModule;let t={};for(let[e,n]of this.publishErrorById){let r=this.dataById.get(e);if(r===void 0)continue;let i=t[r.moduleFilePath]??{};i[e]={message:n,source:`server`},t[r.moduleFilePath]=i}return this.publishErrorsAt={n:this.version,byModule:t},t}bump(){this.version++,this.events.emit({type:`patch:chain`,version:this.version})}originOf(e){return this.originById.get(e)??`external`}chainSettled(){if(!this.statSeen)return!1;for(let e of this.ordered)if(!this.failedById.has(e)&&(!this.dataById.has(e)||!this.appliedIds.has(e)&&!this.pendingIds.has(e)))return!1;return!0}chainProgress(){let e=[],t=[],n=[],r=0;for(let i of this.ordered){if(this.failedById.has(i)){n.push(i),r++;continue}if(!this.dataById.has(i)){e.push(i);continue}if(!this.appliedIds.has(i)&&!this.pendingIds.has(i)){t.push(i);continue}r++}return{total:this.ordered.length,settled:r,unfetched:e,unapplied:t,failed:n,statSeen:this.statSeen}}currentHead(){if(this.ordered.length===0)return{type:`empty`};let e=this.ordered[this.ordered.length-1],t=this.originOf(e),n=this.dataById.get(e)??null;return this.failedById.has(e)?{type:`${t}-failed`,patchId:e,patch:n}:n===null||!this.appliedIds.has(e)?{type:`${t}-partial`,patchId:e,patch:n}:{type:`${t}-complete`,patchId:e,patch:n}}creatorOf(e){return this.creatorByPatchId.get(e)}filePatchIds(){let e=this.filePatchIdsAt;if(e!==null&&e.n===this.version)return e.map;let t=new Map;for(let e of this.ordered){let n=this.dataById.get(e);if(n!==void 0&&!(n.appliedAt||this.publishedIds.has(e)))for(let r of n.patch)r.op===`file`&&t.set(r.filePath,e)}return this.filePatchIdsAt={n:this.version,map:t},t}patchesByPath(){let e=this.patchesByPathAt;if(e!==null&&e.n===this.version)return e.byPath;let t=new Map,n=new Map,r=(e,r)=>{let i=n.get(e);if(i===void 0&&(i=new Set,n.set(e,i)),i.has(r.record.patchId))return;i.add(r.record.patchId);let a=t.get(e);a===void 0?t.set(e,[r]):a.push(r)};for(let e of this.ordered){let t=this.dataById.get(e);if(t===void 0)continue;let n={record:t,isPending:this.pendingIds.has(e)};r(t.moduleFilePath,n);for(let e of t.patch)e.op!==`file`&&r(H.joinModuleFilePathAndModulePath(t.moduleFilePath,H.patchPathToModulePath(e.path)),n)}let i=e?.byPath;if(i!==void 0)for(let[e,n]of t){let r=i.get(e);r!==void 0&&Roe(r,n)&&t.set(e,r)}return this.patchesByPathAt={n:this.version,byPath:t},t}hasUnsavedFrom(e,t){for(let n of this.pendingIds)if(this.creatorByPatchId.get(n)===t&&this.dataById.get(n)?.moduleFilePath===e)return!0;return!1}},Voe=class{constructor(){this.events=new Lb,this.patches=[],this.baseSha=null}receiveStat(e){this.patches=[...e.patches],e.baseSha!==void 0&&(this.baseSha=e.baseSha),this.events.emit({type:`stat:receive`,patches:[...this.patches]}),e.removed!==void 0&&e.removed.length>0&&this.events.emit({type:`patch:removed-by-server`,removed:e.removed})}currentPatchIds(){return[...this.patches]}currentBaseSha(){return this.baseSha}},Hoe=class{constructor(e=Rb){this.activity=e,this.events=new Lb,this.transient=[],this.snapshot=null,this.networkErrorSince=null,this.schemaError=null,this.freshness=`current`,this.nextId=0}reportError(e,t){let n=this.transient.find(t=>t.message===e);if(n!==void 0){n.timestamp=Date.now(),n.details=t??n.details,this.announce();return}this.transient=[...this.transient,{id:`status-${++this.nextId}`,message:e,timestamp:Date.now(),details:t}],this.activity.work(`status:report-error`),this.announce()}dismissErrors(e){let t=new Set(e),n=this.transient.filter(e=>!t.has(e.id));n.length!==this.transient.length&&(this.transient=n,this.announce())}reportNetworkError(){this.networkErrorSince===null&&(this.networkErrorSince=Date.now(),this.announce())}clearNetworkError(){this.networkErrorSince!==null&&(this.networkErrorSince=null,this.announce())}reportSchemaError(e){this.schemaError!==e&&(this.schemaError=e,this.announce())}reportSchemaOutOfDate(){this.freshness!==`out-of-date`&&(this.freshness=`out-of-date`,this.activity.work(`status:schema-out-of-date`),this.announce())}current(){return this.snapshot===null&&(this.snapshot={errors:this.transient,networkErrorSince:this.networkErrorSince,schemaError:this.schemaError,schema:this.freshness}),this.snapshot}announce(){this.snapshot=null,this.events.emit({type:`status:change`})}};function Uoe(e,t,n){let r=[];for(let i of e){if(n(i.patchId)!==t)break;r.push(i)}return r}function Woe(e,t){return e.status===t.status?e.status===`in-sync`||t.status===`in-sync`?!0:e.patches.length===t.patches.length&&e.patches.every((e,n)=>e===t.patches[n])?e.status===`retrying`&&t.status===`retrying`?e.attempt===t.attempt&&e.reason===t.reason:!0:!1:!1}var Goe=class{constructor(e,t,n,r=Rb,i,a=e=>Math.min(3e4,500*2**(e-1)),o=e=>new Promise(t=>setTimeout(t,e))){this.patchStore=e,this.savePatches=t,this.resync=n,this.activity=r,this.sessionId=i,this.backoffMs=a,this.sleep=o,this.events=new Lb,this.baseSha=null,this.statPatchIds=[],this.savedNotInStat=[],this.inFlight=null,this.attempt=0,this.reportedStuck=!1,this.state={status:`in-sync`},this.stopped=!1}listenTo(){return this.patchStore.events.on(`patch:create`,()=>{this.flush()})}receiveStat(e,t){this.baseSha=e,this.statPatchIds=[...t];let n=new Set(t);this.savedNotInStat=this.savedNotInStat.filter(e=>!n.has(e))}forget(e){if(e.length===0)return;let t=new Set(e);this.savedNotInStat=this.savedNotInStat.filter(e=>!t.has(e)),this.statPatchIds=this.statPatchIds.filter(e=>!t.has(e))}currentState(){return this.state}currentParentRef(){if(this.baseSha===null)return null;let e=this.savedNotInStat[this.savedNotInStat.length-1]??this.statPatchIds[this.statPatchIds.length-1];return e===void 0?{type:`head`,headBaseSha:this.baseSha}:{type:`patch`,patchId:e}}async flush(){if(this.inFlight!==null)return this.inFlight.then(()=>this.flush());let e=this.drain().finally(()=>{this.inFlight=null});return this.inFlight=e,e}async drain(){for(;;){let e=this.patchStore.unsavedRecords();if(e.length===0){this.setState({status:`in-sync`});return}if(this.stopped)return;let t=this.savePatches;if(t===void 0){this.setState({status:`pending`,patches:e.map(e=>e.patchId)});return}let n=this.currentParentRef(),r=this.patchStore.sessionOf(e[0].patchId),i=Uoe(e,r,e=>this.patchStore.sessionOf(e)),a=i.map(e=>e.patchId);if(n===null){this.setState({status:`retrying`,patches:a,reason:`network-error`,message:`Cannot save yet: the server has not said what the chain starts from.`,attempt:this.attempt});return}this.setState({status:`saving`,patches:a}),this.activity.work(`patch:save`,void 0,i.length),this.events.emit({type:`patch:save`,patches:a,parentRef:n});let o=await t({patches:i.map(e=>({path:e.moduleFilePath,patchId:e.patchId,patch:e.patch})),parentRef:n,sessionId:r??this.sessionId});if(this.stopped||await this.handle(o,a))return}}async handle(e,t){return e.status===`saved`?(this.attempt=0,this.reportedStuck=!1,this.savedNotInStat.push(...e.newPatchIds),this.patchStore.markSaved(e.newPatchIds),this.events.emit({type:`patch:saved`,patches:e.newPatchIds,parentRef:e.parentRef}),!1):e.status===`rejected`?(this.reportedStuck=!1,this.attempt=0,this.patchStore.drop(t),this.events.emit({type:`patch:save-rejected`,patches:t,message:e.message,errors:e.errors}),!1):(this.attempt++,e.status===`conflict`?(this.activity.work(`patch:save-conflict`),this.savedNotInStat=[],this.setState({status:`retrying`,patches:t,reason:`conflict`,message:e.message,attempt:this.attempt}),this.events.emit({type:`patch:save-conflict`,patches:t,message:e.message}),await this.resync(),this.stopped?!0:(this.attempt>=2&&this.reportStuck(t,`conflict`,e.message),await this.sleep(this.backoffMs(this.attempt)),this.stopped)):(this.activity.work(`patch:save-retry`),this.setState({status:`retrying`,patches:t,reason:e.status,message:e.message,attempt:this.attempt}),e.status!==`unauthorized`&&this.attempt>=2&&this.reportStuck(t,e.status,e.message),await this.sleep(this.backoffMs(this.attempt)),this.stopped))}reportStuck(e,t,n){this.reportedStuck||(this.reportedStuck=!0,this.events.emit({type:`patch:save-stuck`,patches:e,reason:t,message:n,attempt:this.attempt}))}setState(e){Woe(this.state,e)||(this.state=e,this.events.emit({type:`patch:sync-state`,state:e}))}dispose(){this.stopped=!0}},Koe=class{constructor(e,t,n=Rb){this.schemaStore=e,this.sourceStore=t,this.activity=n,this.events=new Lb,this.instances={},this.receivedAt=null,this.moduleFailures=[]}initializedAt(){return this.receivedAt}failures(){return this.moduleFailures}receive(e){let t={},n={},r=[],i=[];for(let a of e)try{let e=H.getValPath(a);if(e===void 0){i.push({moduleFilePath:null,message:`Module has no path`});continue}let o=e,s=H.getSchema(a);if(s===void 0){i.push({moduleFilePath:o,message:`Module has no schema`});continue}this.activity.work(`host:serialize-schema`,o),t[o]=s.executeSerialize(),n[o]=JSON.parse(JSON.stringify(H.getSource(a))),this.instances[o]=s,r.push(o)}catch(e){i.push({moduleFilePath:H.getValPath(a)??null,message:e instanceof Error?e.message:String(e)})}this.moduleFailures=i,this.receivedAt=Date.now(),this.events.emit({type:`host:receive`,modules:r}),this.schemaStore.receive(t),this.sourceStore.receive(n)}async preview(e,t){let n=this.instances[e];if(!n)return{status:`unknown-module`};let r=this.sourceStore.moduleSource(e);if(r===void 0)return{status:`unknown-module`};try{this.activity.work(`host:execute-preview`,e);let i=t!==void 0&&t.length>0?br([...t]):void 0;return{status:`previewed`,preview:n.executePreview(e,r,i)}}catch(e){return{status:`error`,message:e instanceof Error?e.message:String(e)}}}validateSpeculative(e,t){let n=this.instances[e];return n?(this.activity.work(`host:execute-validate`,e),{status:`validated`,errors:n.executeValidate(e,t)}):{status:`unknown-module`}}async customValidate(e,t){let n=this.instances[e];if(!n)return{status:`unknown-module`};let r=this.sourceStore.moduleSource(e);if(r===void 0)return{status:`unknown-module`};if(t.length===0)return{status:`validated`,errors:!1};try{return this.activity.work(`host:execute-validate`,e),{status:`validated`,errors:n.executeValidate(e,r)}}catch(e){return{status:`error`,message:e instanceof Error?e.message:String(e)}}}has(e){return this.instances[e]!==void 0}loadedModules(){return Object.keys(this.instances)}};function qoe(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){let n=r;if(!(n in t)||e[n]!==t[n])return!1}return!0}function Joe(e,t){return e.status===t.status?e.status===`previewed`&&t.status===`previewed`?e.preview===t.preview:e.status===`error`&&t.status===`error`?e.message===t.message:!0:!1}var Yoe=class{constructor(e,t,n,r=Rb){this.host=e,this.sourceStore=t,this.schemaStore=n,this.activity=r,this.events=new Lb,this.previews=new Map,this.stale=new Set,this.peeked=new Map,this.pendingForget=new Map,this.inFlight=new Map,this.pendingReads=new Map,this.listenersByModule=new Map,this.allPreviews=null,this.generation=0}listenTo(){let e=this.sourceStore.events.on(`source:listen`,e=>{let t=this.listenersByModule.get(e.moduleFilePath)??0;this.listenersByModule.set(e.moduleFilePath,t+1);let n=this.pendingForget.get(e.moduleFilePath);n!==void 0&&(clearTimeout(n),this.pendingForget.delete(e.moduleFilePath)),!(this.previews.has(e.moduleFilePath)||this.inFlight.has(e.moduleFilePath)||this.pendingReads.has(e.moduleFilePath))&&this.refresh(e.moduleFilePath)}),t=this.sourceStore.events.on(`source:unlisten`,e=>{let t=(this.listenersByModule.get(e.moduleFilePath)??0)-1;if(t>0){this.listenersByModule.set(e.moduleFilePath,t);return}this.listenersByModule.delete(e.moduleFilePath);let n=e.moduleFilePath,r=this.pendingForget.get(n);r!==void 0&&clearTimeout(r),this.pendingForget.set(n,setTimeout(()=>{this.pendingForget.delete(n),!((this.listenersByModule.get(n)??0)>0)&&(this.previews.delete(n),this.stale.delete(n),this.pendingReads.delete(n))},0))}),n=this.sourceStore.events.on(`source:patch-apply`,e=>{this.invalidate(e.modules)}),r=this.sourceStore.events.on(`source:init`,e=>{this.invalidate(e.sources)}),i=this.schemaStore.events.on(`schema:init`,e=>{this.invalidate(e.modules)});return()=>{e(),t(),n(),r(),i();for(let e of this.pendingForget.values())clearTimeout(e);this.pendingForget.clear()}}invalidate(e){this.generation++;let t=e.filter(e=>!this.stale.has(e)&&this.previews.has(e));for(let t of e)this.stale.add(t);t.length>0&&this.events.emit({type:`preview:invalidate`,modules:t})}async get(e){let[t]=H.splitModuleFilePathAndModulePath(e);this.stale.has(t)||!this.covers(t,e)?(this.activity.work(`preview:cache-miss`,t),await this.refreshFor(t,e)):this.activity.work(`preview:cache-hit`,t);let n=this.previews.get(t);if(n===void 0)return{status:`no-preview`};let r=n.preview[e]??n.preview[t];return r===void 0?{status:`no-preview-at-path`}:{status:`previewed`,preview:r}}covers(e,t){let n=this.previews.get(e);return n===void 0?!1:n.scope===null||n.scope.has(t)}async refreshFor(e,t){let n=this.pendingReads.get(e);if(n!==void 0)return this.activity.work(`preview:share-in-flight`,e),n.paths.add(t),n.request;let r=new Set([t]),i=(async()=>{await Promise.resolve(),this.pendingReads.delete(e),await this.computePreview(e,r)})();return n={paths:r,request:i},this.pendingReads.set(e,n),i}async refresh(e){return this.computePreview(e,new Set)}async computePreview(e,t,n=!1){let r=n?void 0:this.inFlight.get(e);if(r!==void 0){let n=r.scope,i=n===null||[...t].every(e=>n.has(e));return this.activity.work(`preview:share-in-flight`,e),await r.request,i?void 0:this.computePreview(e,t,!0)}let i=new Set(this.sourceStore.listenedPaths(e));for(let e of t)i.add(e);let a=this.generation,o=(async()=>{let t=this.schemaStore.declaresPreview(e)?await this.host.preview(e,[...i]):{status:`previewed`,preview:{}};t.status===`previewed`?(this.previews.set(e,{preview:t.preview,scope:i.size===0?null:i}),this.generation===a&&this.stale.delete(e),this.events.emit({type:`preview:result`,moduleFilePath:e})):t.status===`unknown-module`?(this.previews.delete(e),this.generation===a&&this.stale.delete(e)):(this.previews.delete(e),this.generation===a&&this.stale.delete(e),this.events.emit({type:`preview:error`,moduleFilePath:e,message:t.message}))})().finally(()=>{this.inFlight.get(e)?.request===o&&this.inFlight.delete(e)});return this.inFlight.set(e,{scope:i.size===0?null:i,request:o}),o}peek(e){let t=this.computePeek(e),n=this.peeked.get(e);return n!==void 0&&Joe(n,t)?n:(this.peeked.set(e,t),t)}all(){let e={};for(let[t,n]of this.previews)e[t]=this.stale.has(t)?null:n.preview;let t=this.allPreviews;return t!==null&&qoe(t,e)?t:(this.allPreviews=e,e)}computePeek(e){let[t]=H.splitModuleFilePathAndModulePath(e);if(!this.schemaStore.declaresPreview(t))return{status:`no-preview`};if(this.stale.has(t))return{status:`needs-preview`};let n=this.previews.get(t);if(n===void 0||!this.covers(t,e))return{status:`needs-preview`};let r=n.preview[e]??n.preview[t];return r===void 0?{status:`no-preview-at-path`}:{status:`previewed`,preview:r}}};function Wb(e,t){if(!t||t.length===0)return new Set([e.type]);let n=new Set,r=e,i=-1;for(let e of t){if(i++,!r)break;if(r.type===`array`)r=r.item;else if(r.type===`record`)r=r.item;else if(r.type===`object`)r=r.items[e];else if(r.type===`richtext`)break;else if(r.type===`union`){if(typeof r.key==`string`){let e=r.items;for(let r of e){let e=Wb(r,t.slice(i));for(let t of Array.from(e.values()))n.add(t)}return n}if(i!==t.length-1)throw Error(`Found string union (primitive), but path has more parts: `+t.join(`/`)+` at `+e);break}else if(r.type===`boolean`||r.type===`number`||r.type===`string`||r.type===`date`||r.type===`dateTime`||r.type===`color`||r.type===`code`||r.type===`file`||r.type===`image`||r.type===`keyOf`||r.type===`route`||r.type===`literal`){if((r.type===`image`||r.type===`file`)&&t[i]===`metadata`)break;if(i!==t.length-1)throw Error(`Found `+r.type+` (primitive), but path has more parts: `+t.join(`/`)+` at `+e);break}else{let n=r.type;return console.error(`Unexecpted resolved schema type: ${n} in ${t.join(`/`)} at ${e}`),new Set([n])}}return r&&(n.add(r.type),r.type===`union`&&(typeof r.key==`string`?n.add(`object`):n.add(`string`))),n}var Xoe=class{constructor(){this.patchSetMetadata={},this.orderedInsertKeys=[],this.insertedPatches=new Set}reset(){this.patchSetMetadata={},this.orderedInsertKeys=[],this.insertedPatches=new Set}getInsertedPatches(){return this.insertedPatches}insertPath(e,t,n,r,i,a,o,s){let c=t.length>0?`${e}?${t.join(`/`)}`:e,l=[];for(let e=this.orderedInsertKeys.length-1;e>=0;e--){let t=this.orderedInsertKeys[e];c===t?(this.orderedInsertKeys.splice(e,1),this.orderedInsertKeys.unshift(c)):c.startsWith(t)?(c=t,this.orderedInsertKeys.splice(e,1),this.orderedInsertKeys.unshift(c)):t.startsWith(c)&&l.push(e)}for(let n of l){let a=this.orderedInsertKeys[n];this.orderedInsertKeys.splice(n,1);let s=this.patchSetMetadata[a];if(this.patchSetMetadata[c]||(this.patchSetMetadata[c]={moduleFilePath:e,patchPath:t,patches:[],authors:[],opTypes:[],schemaTypes:Array.from(o),lastUpdated:r,lastUpdatedBy:i}),s)for(let e of s.patches.slice())this.patchSetMetadata[c].patches.unshift(e),e.author!==null&&this.patchSetMetadata[c].authors.unshift(e.author),this.patchSetMetadata[c].opTypes.unshift(e.opType);else throw Error(`Could not find patch set metadata or patch metadata for (inserted) patch set path: ${a}`);a!==c&&delete this.patchSetMetadata[a]}this.patchSetMetadata[c]||(this.patchSetMetadata[c]={moduleFilePath:e,patchPath:t,patches:[],authors:[],opTypes:[],schemaTypes:o,lastUpdated:r,lastUpdatedBy:i}),i!==null&&!this.patchSetMetadata[c].authors.includes(i)&&this.patchSetMetadata[c].authors.unshift(i),this.patchSetMetadata[c].lastUpdatedBy=i,this.patchSetMetadata[c].lastUpdated=r,this.patchSetMetadata[c].opTypes.includes(a)||this.patchSetMetadata[c].opTypes.unshift(a),this.patchSetMetadata[c].patches.unshift({patchPath:s,patchId:n,author:i,createdAt:r,opType:a,schemaTypes:o}),this.orderedInsertKeys.includes(c)||this.orderedInsertKeys.unshift(c)}insert(e,t,n,r,i,a){if(!this.insertedPatches.has(r)){if(!t){this.insertPath(e,[],r,i,a,n.op,[],n.path);return}if(this.insertedPatches.add(r),n.op!==`file`&&n.op!==`test`)try{if(n.op===`replace`){let o=Wb(t,n.path);this.insertPath(e,n.path,r,i,a,n.op,Array.from(o),n.path)}else if(n.op===`add`||n.op===`remove`||n.op===`move`||n.op===`copy`){let o=n.path.slice(0,-1),s=Wb(t,o);if(s.size===1&&s.has(`array`)){if(this.insertPath(e,o,r,i,a,n.op,Array.from(s),n.path),n.op===`move`){let o=n.from.slice(0,-1),s=Wb(t,o);this.insertPath(e,o,r,i,a,n.op,Array.from(s),n.path)}}else if(s.size===1&&s.has(`record`)){let o=n.path,s=Wb(t,o);if(this.insertPath(e,o,r,i,a,n.op,Array.from(s),n.path),n.op===`move`){let o=n.from,s=Wb(t,o);this.insertPath(e,o,r,i,a,n.op,Array.from(s),n.path)}}else if(s.size===1&&!(s.has(`image`)||s.has(`file`)))throw Error(`Cannot perform op: '${n.op}' on non-array or non-record schema. Type: ${s.values().next().value}`);else this.insertPath(e,o,r,i,a,n.op,[t.type],n.path)}else throw Error(`Unreachable op: `+n)}catch(o){o instanceof Error?console.error(`Could not resolve path while creating patch set`,o.message):console.error(`Could not resolve path while creating patch set`,o),this.insertPath(e,[],r,i,a,n.op,[t.type],n.path)}}}isInserted(e){return this.insertedPatches.has(e)}serialize(){return this.orderedInsertKeys.map(e=>{if(e in this.patchSetMetadata)return this.patchSetMetadata[e];throw Error(`Could not find patch set metadata or patch metadata for (inserted) patch set path: ${e}`)})}},Zoe=class{constructor(e=Rb){this.activity=e,this.events=new Lb,this.patchSets=new Xoe}insertRecords(e,t,n){n&&this.patchSets.reset();let r=new Set;for(let n of e){let e=t[n.moduleFilePath];this.activity.work(`patch-set:insert`,n.patchId,n.patch.length);for(let t of n.patch)this.patchSets.insert(n.moduleFilePath,e,t,n.patchId,n.createdAt??new Date(0).toISOString(),n.authorId??null),t.op!==`file`&&t.op!==`test`&&r.add(`${n.moduleFilePath}?${t.path.join(`/`)}`)}this.events.emit({type:`patch-set:update`,patchSetPaths:[...r]})}async getPatchSets(e){return e.mode!==`current`&&this.insertRecords(e.records,e.schemas,e.mode===`rebuild`),this.activity.work(`patch-set:serialize`),this.patchSets.serialize()}reset(e){if(e!==void 0)throw Error(`PatchSetStore.reset: per-module reset is not supported — PatchSets has no per-module removal`);this.patchSets.reset(),this.events.emit({type:`patch-set:update`,patchSetPaths:[]})}},Qoe=class{constructor(){this.inserted=[],this.mustRebuild=!0}plan(e){if(this.mustRebuild||this.inserted.length>e.length)return{mode:`rebuild`,patchIds:[...e]};for(let t=0;t<this.inserted.length;t++)if(this.inserted[t]!==e[t])return{mode:`rebuild`,patchIds:[...e]};let t=e.slice(this.inserted.length);return t.length===0?{mode:`current`}:{mode:`append`,patchIds:t}}covers(e){if(e.mode!==`current`){if(e.mode===`rebuild`){this.inserted=[...e.patchIds],this.mustRebuild=!1;return}this.inserted=[...this.inserted,...e.patchIds]}}invalidate(){this.mustRebuild=!0,this.inserted=[]}insertedPatchIds(){return[...this.inserted]}};function Gb(e){if(e.customValidate===!0)return!0;switch(e.type){case`object`:return Object.values(e.items).some(Gb);case`array`:return Gb(e.item);case`record`:return Gb(e.item)||e.key!==void 0&&Gb(e.key);case`union`:return e.items.some(Gb);default:return!1}}function $oe(e,t,n){let r=[],i=new Set,a=(e,t,n)=>{if(t!==void 0&&!H.isJson(n)){if(n===null){t.customValidate===!0&&r.push(e);return}switch(t.customValidate===!0&&r.push(e),t.type){case`object`:if(!Kb(n))return;for(let r in t.items)r in n&&a(sb(e,r),t.items[r],n[r]);return;case`record`:{if(!Kb(n))return;let r=Gb(t.item);for(let o in n){let s=n[o];if(H.isJson(s)){(t.customValidate===!0||r)&&i.add(o);continue}a(sb(e,o),t.item,s)}return}case`array`:if(!Array.isArray(n))return;for(let r=0;r<n.length;r++)a(sb(e,r),t.item,n[r]);return;case`union`:{let i=t.key;if(typeof i!=`string`||!Kb(n))return;let o=n[i];if(typeof o!=`string`)return;let s=t.items.filter(e=>e.type===`object`).find(e=>{let t=e.items[i];return t?.type===`literal`&&t.value===o});if(s){s.customValidate===!0&&t.customValidate!==!0&&r.push(e);for(let t in s.items)t in n&&a(sb(e,t),s.items[t],n[t])}return}default:return}}};return a(e,t,n),{paths:r,needsJsonKeys:Array.from(i)}}function Kb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var qb={status:`stale`},ese=class e{constructor(e,t,n,r,i=Rb){this.schemaStore=e,this.sourceStore=t,this.schemaValidation=n,this.host=r,this.activity=i,this.events=new Lb,this.results=new Map,this.stale=new Set,this.inFlight=new Map,this.generation=0}listenTo(){let e=this.sourceStore.events.on(`source:init`,e=>{this.invalidate(e.sources)}),t=this.sourceStore.events.on(`source:patch-apply`,e=>{this.invalidate(e.modules)}),n=this.schemaStore.events.on(`schema:init`,e=>{this.invalidate(e.modules)});return()=>{e(),t(),n()}}invalidate(e){if(this.generation++,e.length===0)return;let t=e.filter(e=>this.results.has(e));for(let t of e)this.stale.add(t),this.results.delete(t);t.length>0&&this.events.emit({type:`validation:invalidate`,modules:t})}async validate(e){let t=this.results.get(e);if(t!==void 0&&!this.stale.has(e))return this.activity.work(`validation:cache-hit`,e),t;let n=this.inFlight.get(e);if(n)return this.activity.work(`validation:share-in-flight`,e),n;this.activity.work(`validation:cache-miss`,e);let r=this.run(e).finally(()=>{this.inFlight.delete(e)});return this.inFlight.set(e,r),r}static{this.MAX_RECOMPUTES=5}async run(t){let n=qb;for(let r=0;r<e.MAX_RECOMPUTES;r++)if(n=await this.runOnce(t),n.status!==`validated`||!this.stale.has(t))return n;return n}async runOnce(e){let t=this.generation,n=this.schemaStore.get(e),r=this.sourceStore.moduleSource(e);if(n===void 0||r===void 0)return{status:`unknown-module`};this.activity.work(`validation:schema-validate`,e);let i=await this.schemaValidation.validate(e,r,n,String(this.schemaStore.version(e)));this.activity.work(`validation:collect-custom-targets`,e);let a=$oe(e,n,r).paths,o=i,s=`not-needed`;if(a.length>0){let t=await this.host.customValidate(e,a);t.status===`validated`?(this.activity.work(`validation:merge`,e),o=tse(i,t.errors),s=`ran`):s=t.status===`unknown-module`?`unavailable`:`error`}let c={status:`validated`,errors:o,customValidatePaths:a,customValidateStatus:s,jsonEntriesLoaded:!this.sourceStore.hasUnloadedEntries(e)};return this.results.set(e,c),this.generation===t&&this.stale.delete(e),this.events.emit({type:`validation:result`,moduleFilePath:e,errors:o,customValidatePaths:a,customValidateStatus:s}),c}peek(e){let t=this.results.get(e);return t!==void 0&&!this.stale.has(e)?t:qb}};function tse(e,t){if(e===!1)return t;if(t===!1)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=e,i=n[t];if(!i){n[t]=r;continue}let a=new Set(i.map(e=>e.message));n[t]=[...i,...r.filter(e=>!a.has(e.message))]}return n}var nse=`modulepreload`,rse=function(e){return`/api/val/static/`+e},Jb={},ise=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=rse(t,n),t=s(t),t in Jb)return;Jb[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:nse,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Yb=s(((e,t)=>{t.exports={}})),Xb;function Zb(e,t,n){let r=typeof n,i=typeof e;if(r!==`undefined`){if(i!==`undefined`){if(n){if(i===`function`&&r===i)return function(t){return e(n(t))};if(t=e.constructor,t===n.constructor){if(t===Array)return n.concat(e);if(t===Map){var a=new Map(n);for(var o of e)a.set(o[0],o[1]);return a}if(t===Set){o=new Set(n);for(a of e.values())o.add(a);return o}}}return e}return n}return i===`undefined`?t:e}function Qb(e,t){return e===void 0?t:e}function $b(){return Object.create(null)}function ex(e){return typeof e==`string`}function tx(e){return typeof e==`object`}function nx(e,t){if(ex(t))e=e[t];else for(let n=0;e&&n<t.length;n++)e=e[t[n]];return e}var ase=/[^\p{L}\p{N}]+/u,ose=/(\d{3})/g,sse=/(\D)(\d{3})/g,cse=/(\d{3})(\D)/g,rx=/[\u0300-\u036f]/g;function ix(e={}){if(!this||this.constructor!==ix)return new ix(...arguments);if(arguments.length)for(e=0;e<arguments.length;e++)this.assign(arguments[e]);else this.assign(e)}Xb=ix.prototype,Xb.assign=function(e){this.normalize=Zb(e.normalize,!0,this.normalize);let t=e.include,n=t||e.exclude||e.split,r;if(n||n===``){if(typeof n==`object`&&n.constructor!==RegExp){let e=``;r=!t,t||(e+=`\\p{Z}`),n.letter&&(e+=`\\p{L}`),n.number&&(e+=`\\p{N}`,r=!!t),n.symbol&&(e+=`\\p{S}`),n.punctuation&&(e+=`\\p{P}`),n.control&&(e+=`\\p{C}`),(n=n.char)&&(e+=typeof n==`object`?n.join(``):n);try{this.split=RegExp(`[`+(t?`^`:``)+e+`]+`,`u`)}catch{this.split=/\s+/}}else this.split=n,r=n===!1||`a1a`.split(n).length<2;this.numeric=Zb(e.numeric,r)}else{try{this.split=Zb(this.split,ase)}catch{this.split=/\s+/}this.numeric=Zb(e.numeric,Zb(this.numeric,!0))}if(this.prepare=Zb(e.prepare,null,this.prepare),this.finalize=Zb(e.finalize,null,this.finalize),n=e.filter,this.filter=typeof n==`function`?n:Zb(n&&new Set(n),null,this.filter),this.dedupe=Zb(e.dedupe,!0,this.dedupe),this.matcher=Zb((n=e.matcher)&&new Map(n),null,this.matcher),this.mapper=Zb((n=e.mapper)&&new Map(n),null,this.mapper),this.stemmer=Zb((n=e.stemmer)&&new Map(n),null,this.stemmer),this.replacer=Zb(e.replacer,null,this.replacer),this.minlength=Zb(e.minlength,1,this.minlength),this.maxlength=Zb(e.maxlength,1024,this.maxlength),this.rtl=Zb(e.rtl,!1,this.rtl),(this.cache=n=Zb(e.cache,!0,this.cache))&&(this.F=null,this.L=typeof n==`number`?n:2e5,this.B=new Map,this.D=new Map,this.I=this.H=128),this.h=``,this.J=null,this.A=``,this.K=null,this.matcher)for(let e of this.matcher.keys())this.h+=(this.h?`|`:``)+e;if(this.stemmer)for(let e of this.stemmer.keys())this.A+=(this.A?`|`:``)+e;return this},Xb.addStemmer=function(e,t){return this.stemmer||=new Map,this.stemmer.set(e,t),this.A+=(this.A?`|`:``)+e,this.K=null,this.cache&&ax(this),this},Xb.addFilter=function(e){return typeof e==`function`?this.filter=e:(this.filter||=new Set,this.filter.add(e)),this.cache&&ax(this),this},Xb.addMapper=function(e,t){return typeof e==`object`?this.addReplacer(e,t):e.length>1?this.addMatcher(e,t):(this.mapper||=new Map,this.mapper.set(e,t),this.cache&&ax(this),this)},Xb.addMatcher=function(e,t){return typeof e==`object`?this.addReplacer(e,t):e.length<2&&(this.dedupe||this.mapper)?this.addMapper(e,t):(this.matcher||=new Map,this.matcher.set(e,t),this.h+=(this.h?`|`:``)+e,this.J=null,this.cache&&ax(this),this)},Xb.addReplacer=function(e,t){return typeof e==`string`?this.addMatcher(e,t):(this.replacer||=[],this.replacer.push(e,t),this.cache&&ax(this),this)},Xb.encode=function(e,t){if(this.cache&&e.length<=this.H){if(this.F){if(this.B.has(e))return this.B.get(e)}else this.F=setTimeout(ax,50,this)}this.normalize&&(e=typeof this.normalize==`function`?this.normalize(e):rx?e.normalize(`NFKD`).replace(rx,``).toLowerCase():e.toLowerCase()),this.prepare&&(e=this.prepare(e)),this.numeric&&e.length>3&&(e=e.replace(sse,`$1 $2`).replace(cse,`$1 $2`).replace(ose,`$1 `));let n=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer),r=[],i=$b(),a,o,s=this.split||this.split===``?e.split(this.split):[e];for(let e=0,l,u;e<s.length;e++)if((l=u=s[e])&&!(l.length<this.minlength||l.length>this.maxlength)){if(t){if(i[l])continue;i[l]=1}else{if(a===l)continue;a=l}if(n)r.push(l);else if(!this.filter||(typeof this.filter==`function`?this.filter(l):!this.filter.has(l))){if(this.cache&&l.length<=this.I){if(this.F){var c=this.D.get(l);if(c||c===``){c&&r.push(c);continue}}else this.F=setTimeout(ax,50,this)}if(this.stemmer){this.K||=RegExp(`(?!^)(`+this.A+`)$`);let e;for(;e!==l&&l.length>2;)e=l,l=l.replace(this.K,e=>this.stemmer.get(e))}if(l&&(this.mapper||this.dedupe&&l.length>1)){c=``;for(let e=0,t=``,n,r;e<l.length;e++)n=l.charAt(e),n===t&&this.dedupe||((r=this.mapper&&this.mapper.get(n))||r===``?r===t&&this.dedupe||!(t=r)||(c+=r):c+=t=n);l=c}if(this.matcher&&l.length>1&&(this.J||=RegExp(`(`+this.h+`)`,`g`),l=l.replace(this.J,e=>this.matcher.get(e))),l&&this.replacer)for(c=0;l&&c<this.replacer.length;c+=2)l=l.replace(this.replacer[c],this.replacer[c+1]);if(this.cache&&u.length<=this.I&&(this.D.set(u,l),this.D.size>this.L&&(this.D.clear(),this.I=this.I/1.1|0)),l){if(l!==u){if(t){if(i[l])continue;i[l]=1}else{if(o===l)continue;o=l}}r.push(l)}}}return this.finalize&&(r=this.finalize(r)||r),this.cache&&e.length<=this.H&&(this.B.set(e,r),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0)),r};function ax(e){e.F=null,e.B.clear(),e.D.clear()}function ox(e,t,n){n||(t||typeof e!=`object`?typeof t==`object`&&(n=t,t=0):n=e),n&&(e=n.query||e,t=n.limit||t);let r=``+(t||0);n&&(r+=(n.offset||0)+!!n.context+!!n.suggest+(n.resolve!==!1)+(n.resolution||this.resolution)+(n.boost||0)),e=(``+e).toLowerCase(),this.cache||=new sx;let i=this.cache.get(e+r);if(!i){let a=n&&n.cache;a&&(n.cache=!1),i=this.search(e,t,n),a&&(n.cache=a),this.cache.set(e+r,i)}return i}function sx(e){this.limit=e&&e!==!0?e:1e3,this.cache=new Map,this.h=``}sx.prototype.set=function(e,t){this.cache.set(this.h=e,t),this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)},sx.prototype.get=function(e){let t=this.cache.get(e);return t&&this.h!==e&&(this.cache.delete(e),this.cache.set(this.h=e,t)),t},sx.prototype.remove=function(e){for(let t of this.cache){let n=t[0];t[1].includes(e)&&this.cache.delete(n)}},sx.prototype.clear=function(){this.cache.clear(),this.h=``};var cx={normalize:!1,numeric:!1,dedupe:!1},lx={},ux=new Map([[`b`,`p`],[`v`,`f`],[`w`,`f`],[`z`,`s`],[`x`,`s`],[`d`,`t`],[`n`,`m`],[`c`,`k`],[`g`,`k`],[`j`,`k`],[`q`,`k`],[`i`,`e`],[`y`,`e`],[`u`,`o`]]),dx=new Map([[`ae`,`a`],[`oe`,`o`],[`sh`,`s`],[`kh`,`k`],[`th`,`t`],[`ph`,`f`],[`pf`,`f`]]),lse=[/([^aeo])h(.)/g,`$1$2`,/([aeo])h([^aeo]|$)/g,`$1$2`,/(.)\1+/g,`$1`],fx={a:``,e:``,i:``,o:``,u:``,y:``,b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,ß:2,d:3,t:3,l:4,m:5,n:5,r:6},px={Exact:cx,Default:lx,Normalize:lx,LatinBalance:{mapper:ux},LatinAdvanced:{mapper:ux,matcher:dx,replacer:lse},LatinExtra:{mapper:ux,replacer:lse.concat([/(?!^)[aeo]/g,``]),matcher:dx},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(e){for(let n=0;n<e.length;n++){var t=e[n];let r=t.charAt(0),i=fx[r];for(let e=1,n;e<t.length&&(n=t.charAt(e),n===`h`||n===`w`||!(n=fx[n])||n===i||(r+=n,i=n,r.length!==4));e++);e[n]=r}}},CJK:{split:``},LatinExact:cx,LatinDefault:lx,LatinSimple:lx};function mx(e,t,n,r){let i=[];for(let a=0,o;a<e.index.length;a++)if(o=e.index[a],t>=o.length)t-=o.length;else{t=o[r?`splice`:`slice`](t,n);let a=t.length;if(a&&(i=i.length?i.concat(t):t,n-=a,r&&(e.length-=a),!n))break;t=0}return i}function hx(e){if(!this||this.constructor!==hx)return new hx(e);this.index=e?[e]:[],this.length=e?e.length:0;let t=this;return new Proxy([],{get(e,n){if(n===`length`)return t.length;if(n===`push`)return function(e){t.index[t.index.length-1].push(e),t.length++};if(n===`pop`)return function(){if(t.length)return t.length--,t.index[t.index.length-1].pop()};if(n===`indexOf`)return function(e){let n=0;for(let r=0,i,a;r<t.index.length;r++){if(i=t.index[r],a=i.indexOf(e),a>=0)return n+a;n+=i.length}return-1};if(n===`includes`)return function(e){for(let n=0;n<t.index.length;n++)if(t.index[n].includes(e))return!0;return!1};if(n===`slice`)return function(e,n){return mx(t,e||0,n||t.length,!1)};if(n===`splice`)return function(e,n){return mx(t,e||0,n||t.length,!0)};if(n===`constructor`)return Array;if(typeof n!=`symbol`)return(e=t.index[n/2**31|0])&&e[n]},set(e,n,r){return e=n/2**31|0,(t.index[e]||(t.index[e]=[]))[n]=r,t.length++,!0}})}hx.prototype.clear=function(){this.index.length=0},hx.prototype.push=function(){};function gx(e=8){if(!this||this.constructor!==gx)return new gx(e);this.index=$b(),this.h=[],this.size=0,e>32?(this.B=yx,this.A=BigInt(e)):(this.B=vx,this.A=e)}gx.prototype.get=function(e){let t=this.index[this.B(e)];return t&&t.get(e)},gx.prototype.set=function(e,t){var n=this.B(e);let r=this.index[n];r?(n=r.size,r.set(e,t),(n-=r.size)&&this.size++):(this.index[n]=r=new Map([[e,t]]),this.h.push(r),this.size++)};function _x(e=8){if(!this||this.constructor!==_x)return new _x(e);this.index=$b(),this.h=[],this.size=0,e>32?(this.B=yx,this.A=BigInt(e)):(this.B=vx,this.A=e)}_x.prototype.add=function(e){var t=this.B(e);let n=this.index[t];n?(t=n.size,n.add(e),(t-=n.size)&&this.size++):(this.index[t]=n=new Set([e]),this.h.push(n),this.size++)},Xb=gx.prototype,Xb.has=_x.prototype.has=function(e){let t=this.index[this.B(e)];return t&&t.has(e)},Xb.delete=_x.prototype.delete=function(e){let t=this.index[this.B(e)];t&&t.delete(e)&&this.size--},Xb.clear=_x.prototype.clear=function(){this.index=$b(),this.h=[],this.size=0},Xb.values=_x.prototype.values=function*(){for(let e=0;e<this.h.length;e++)for(let t of this.h[e].values())yield t},Xb.keys=_x.prototype.keys=function*(){for(let e=0;e<this.h.length;e++)for(let t of this.h[e].keys())yield t},Xb.entries=_x.prototype.entries=function*(){for(let e=0;e<this.h.length;e++)for(let t of this.h[e].entries())yield t};function vx(e){let t=2**this.A-1;if(typeof e==`number`)return e&t;let n=0,r=this.A+1;for(let i=0;i<e.length;i++)n=(n*r^e.charCodeAt(i))&t;return this.A===32?n+2**31:n}function yx(e){let t=BigInt(2)**this.A-BigInt(1);var n=typeof e;if(n===`bigint`)return e&t;if(n===`number`)return BigInt(e)&t;n=BigInt(0);let r=this.A+BigInt(1);for(let i=0;i<e.length;i++)n=(n*r^BigInt(e.charCodeAt(i)))&t;return n}var bx,xx;async function use(e){e=e.data;var t=e.task;let n=e.id,r=e.args;switch(t){case`init`:xx=e.options||{},(t=e.factory)?(Function(`return `+t)()(self),bx=new self.FlexSearch.Index(xx),delete self.FlexSearch):bx=new rS(xx),postMessage({id:n});break;default:let i;t===`export`&&(r[1]?(r[0]=xx.export,r[2]=0,r[3]=1):r=null),t===`import`?r[0]&&(e=await xx.import.call(bx,r[0]),bx.import(r[0],e)):((i=r&&bx[t].apply(bx,r))&&i.then&&(i=await i),i&&i.await&&(i=await i.await),t===`search`&&i.result&&(i=i.result)),postMessage(t===`search`?{id:n,msg:i}:{id:n})}}function Sx(e){Tx.call(e,`add`),Tx.call(e,`append`),Tx.call(e,`search`),Tx.call(e,`update`),Tx.call(e,`remove`),Tx.call(e,`searchCache`)}var Cx,dse,wx;function fse(){Cx=wx=0}function Tx(e){this[e+`Async`]=function(){let t=arguments;var n=t[t.length-1];let r;if(typeof n==`function`&&(r=n,delete t[t.length-1]),Cx?wx||=Date.now()-dse>=this.priority*this.priority*3:(Cx=setTimeout(fse,0),dse=Date.now()),wx){let n=this;return new Promise(r=>{setTimeout(function(){r(n[e+`Async`].apply(n,t))},0)})}let i=this[e].apply(this,t);return n=i.then?i:new Promise(e=>e(i)),r&&n.then(r),n}}var Ex=0;function Dx(e={},t){function n(n){function o(e){e=e.data||e;let t=e.id,n=t&&a.h[t];n&&(n(e.msg),delete a.h[t])}if(this.worker=n,this.h=$b(),this.worker)return i?this.worker.on(`message`,o):this.worker.onmessage=o,e.config?new Promise(function(t){Ex>1e9&&(Ex=0),a.h[++Ex]=function(){t(a)},a.worker.postMessage({id:Ex,task:`init`,factory:r,options:e})}):(this.priority=e.priority||4,this.encoder=t||null,this.worker.postMessage({task:`init`,factory:r,options:e}),this)}if(!this||this.constructor!==Dx)return new Dx(e);let r=typeof self<`u`?self._factory:typeof window<`u`?window._factory:null;r&&=r.toString();let i=typeof window>`u`,a=this,o=pse(r,i,e.worker);return o.then?o.then(function(e){return n.call(a,e)}):n.call(this,o)}Ox(`add`),Ox(`append`),Ox(`search`),Ox(`update`),Ox(`remove`),Ox(`clear`),Ox(`export`),Ox(`import`),Dx.prototype.searchCache=ox,Sx(Dx.prototype);function Ox(e){Dx.prototype[e]=function(){let t=this,n=[].slice.call(arguments);var r=n[n.length-1];let i;return typeof r==`function`&&(i=r,n.pop()),r=new Promise(function(r){e===`export`&&typeof n[0]==`function`&&(n[0]=null),Ex>1e9&&(Ex=0),t.h[++Ex]=r,t.worker.postMessage({task:e,id:Ex,args:n})}),i?(r.then(i),this):r}}function pse(e,t,n){return t?typeof module<`u`?new(Yb()).Worker(__dirname+`/worker/node.js`):ise(()=>Promise.resolve().then(()=>u(Yb(),1)).then(function(e){return new e.Worker(import.meta.dirname+`/node/node.mjs`)}),void 0):e?new window.Worker(URL.createObjectURL(new Blob([`onmessage=`+use.toString()],{type:`text/javascript`}))):new window.Worker(typeof n==`string`?n:import.meta.url.replace(`/worker.js`,`/worker/worker.js`).replace(`flexsearch.bundle.module.min.js`,`module/worker/worker.js`).replace(`flexsearch.bundle.module.min.mjs`,`module/worker/worker.js`),{type:`module`})}Bx.prototype.add=function(e,t,n){if(tx(e)&&(t=e,e=nx(t,this.key)),t&&(e||e===0)){if(!n&&this.reg.has(e))return this.update(e,t);for(let a=0,o;a<this.field.length;a++){o=this.B[a];var r=this.index.get(this.field[a]);if(typeof o==`function`){var i=o(t);i&&r.add(e,i,n,!0)}else i=o.G,(!i||i(t))&&(o.constructor===String?o=[``+o]:ex(o)&&(o=[o]),Ax(t,o,this.D,0,r,e,o[0],n))}if(this.tag)for(r=0;r<this.A.length;r++){var a=this.A[r];i=this.tag.get(this.F[r]);let s=$b();if(typeof a==`function`){if(a=a(t),!a)continue}else{var o=a.G;if(o&&!o(t))continue;a.constructor===String&&(a=``+a),a=nx(t,a)}if(i&&a){ex(a)&&(a=[a]);for(let t=0,r,c;t<a.length;t++)if(r=a[t],!s[r]&&(s[r]=1,(o=i.get(r))?c=o:i.set(r,c=[]),!n||!c.includes(e))){if(c.length===2**31-1){if(o=new hx(c),this.fastupdate)for(let e of this.reg.values())e.includes(c)&&(e[e.indexOf(c)]=o);i.set(r,c=o)}c.push(e),this.fastupdate&&((o=this.reg.get(e))?o.push(c):this.reg.set(e,[c]))}}}if(this.store&&(!n||!this.store.has(e))){let r;if(this.h){r=$b();for(let e=0,i;e<this.h.length;e++){if(i=this.h[e],(n=i.G)&&!n(t))continue;let a;if(typeof i==`function`){if(a=i(t),!a)continue;i=[i.O]}else if(ex(i)||i.constructor===String){r[i]=t[i];continue}kx(t,r,i,0,i[0],a)}}this.store.set(e,r||t)}this.worker&&(this.fastupdate||this.reg.add(e))}return this};function kx(e,t,n,r,i,a){if(e=e[i],r===n.length-1)t[i]=a||e;else if(e){if(e.constructor===Array)for(t=t[i]=Array(e.length),i=0;i<e.length;i++)kx(e,t,n,r,i);else t=t[i]||(t[i]=$b()),i=n[++r],kx(e,t,n,r,i)}}function Ax(e,t,n,r,i,a,o,s){if(e=e[o]){if(r===t.length-1){if(e.constructor===Array){if(n[r]){for(t=0;t<e.length;t++)i.add(a,e[t],!0,!0);return}e=e.join(` `)}i.add(a,e,s,!0)}else if(e.constructor===Array)for(o=0;o<e.length;o++)Ax(e,t,n,r,i,a,o,s);else o=t[++r],Ax(e,t,n,r,i,a,o,s)}}function jx(e,t,n,r){if(!e.length)return e;if(e.length===1)return e=e[0],e=n||e.length>t?e.slice(n,n+t):e,r?zx.call(this,e):e;let i=[];for(let a=0,o,s;a<e.length;a++)if((o=e[a])&&(s=o.length)){if(n){if(n>=s){n-=s;continue}o=o.slice(n,n+t),s=o.length,n=0}if(s>t&&(o=o.slice(0,t),s=t),!i.length&&s>=t)return r?zx.call(this,o):o;if(i.push(o),t-=s,!t)break}return i=i.length>1?[].concat.apply([],i):i[0],r?zx.call(this,i):i}function Mx(e,t,n,r){var i=r[0];if(i[0]&&i[0].query)return e[t].apply(e,i);if(!(t!==`and`&&t!==`not`||e.result.length||e.await||i.suggest))return r.length>1&&(i=r[r.length-1]),(r=i.resolve)?e.await||e.result:e;let a=[],o=0,s=0,c,l,u,d,f;for(t=0;t<r.length;t++)if(i=r[t]){var p=void 0;if(i.constructor===Fx)p=i.await||i.result;else if(i.then||i.constructor===Array)p=i;else{o=i.limit||0,s=i.offset||0,u=i.suggest,l=i.resolve,c=((d=i.highlight||e.highlight)||i.enrich)&&l,p=i.queue;let n=i.async||p,r=i.index,m=i.query;if(r?e.index||=r:r=e.index,m||i.tag){let o=i.field||i.pluck;if(o&&(!m||e.query&&!d||(e.query=m,e.field=o,e.highlight=d),r=r.index.get(o)),p&&(f||e.await)){f=1;let o,s=e.C.length,c=new Promise(function(e){o=e});(function(t,r){c.h=function(){r.index=null,r.resolve=!1;let i=n?t.searchAsync(r):t.search(r);return i.then?i.then(function(t){return e.C[s]=t=t.result||t,o(t),t}):(i=i.result||i,o(i),i)}})(r,Object.assign({},i)),e.C.push(c),a[t]=c;continue}i.resolve=!1,i.index=null,p=n?r.searchAsync(i):r.search(i),i.resolve=l,i.index=r}else if(i.and)p=Nx(i,`and`,r);else if(i.or)p=Nx(i,`or`,r);else if(i.not)p=Nx(i,`not`,r);else if(i.xor)p=Nx(i,`xor`,r);else continue}p.await?(f=1,p=p.await):p.then?(f=1,p=p.then(function(e){return e.result||e})):p=p.result||p,a[t]=p}if(f&&!e.await&&(e.await=new Promise(function(t){e.return=t})),f){let t=Promise.all(a).then(function(r){for(let i=0;i<e.C.length;i++)if(e.C[i]===t){e.C[i]=function(){return n.call(e,r,o,s,c,l,u,d)};break}Ix(e)});e.C.push(t)}else if(e.await)e.C.push(function(){return n.call(e,a,o,s,c,l,u,d)});else return n.call(e,a,o,s,c,l,u,d);return l?e.await||e.result:e}function Nx(e,t,n){e=e[t];let r=e[0]||e;return r.index||=n,n=new Fx(r),e.length>1&&(n=n[t].apply(n,e.slice(1))),n}Fx.prototype.or=function(){return Mx(this,`or`,mse,arguments)};function mse(e,t,n,r,i,a,o){return e.length&&(this.result.length&&e.push(this.result),e.length<2?this.result=e[0]:(this.result=vse(e,t,n,!1,this.h),n=0)),i&&(this.await=null),i?this.resolve(t,n,r,o):this}Fx.prototype.and=function(){return Mx(this,`and`,hse,arguments)};function hse(e,t,n,r,i,a,o){if(!a&&!this.result.length)return i?this.result:this;let s;if(e.length){if(this.result.length&&e.unshift(this.result),e.length<2)this.result=e[0];else{let r=0;for(let t=0,n,i;t<e.length;t++)if((n=e[t])&&(i=n.length))r<i&&(r=i);else if(!a){r=0;break}r?(this.result=Lx(e,r,t,n,a,this.h,i),s=!0):this.result=[]}}else a||(this.result=e);return i&&(this.await=null),i?this.resolve(t,n,r,o,s):this}Fx.prototype.xor=function(){return Mx(this,`xor`,gse,arguments)};function gse(e,t,n,r,i,a,o){if(e.length){if(this.result.length&&e.unshift(this.result),e.length<2)this.result=e[0];else{a:{a=n;var s=this.h;let r=[],o=$b(),c=0;for(let t=0,n;t<e.length;t++)if(n=e[t]){c<n.length&&(c=n.length);for(let e=0,t;e<n.length;e++)if(t=n[e])for(let e=0,n;e<t.length;e++)n=t[e],o[n]=o[n]?2:1}for(let n=0,l,u=0;n<c;n++)for(let c=0,d;c<e.length;c++)if((d=e[c])&&(l=d[n])){for(let d=0,f;d<l.length;d++)if(f=l[d],o[f]===1){if(a)a--;else if(i){if(r.push(f),r.length===t){e=r;break a}}else{let i=n+(c?s:0);if(r[i]||(r[i]=[]),r[i].push(f),++u===t){e=r;break a}}}}e=r}this.result=e,s=!0}}else a||(this.result=e);return i&&(this.await=null),i?this.resolve(t,n,r,o,s):this}Fx.prototype.not=function(){return Mx(this,`not`,_se,arguments)};function _se(e,t,n,r,i,a,o){if(!a&&!this.result.length)return i?this.result:this;if(e.length&&this.result.length){a:{a=n;var s=[];e=new Set(e.flat().flat());for(let n=0,r,o=0;n<this.result.length;n++)if(r=this.result[n]){for(let c=0,l;c<r.length;c++)if(l=r[c],!e.has(l)){if(a)a--;else if(i){if(s.push(l),s.length===t){e=s;break a}}else if(s[n]||(s[n]=[]),s[n].push(l),++o===t){e=s;break a}}}e=s}this.result=e,s=!0}return i&&(this.await=null),i?this.resolve(t,n,r,o,s):this}function Px(e,t,n,r,i){let a,o,s;typeof i==`string`?(a=i,i=``):a=i.template,o=a.indexOf(`$1`),s=a.substring(o+2),o=a.substring(0,o);let c=i&&i.boundary,l=!i||i.clip!==!1,u=i&&i.merge&&s&&o&&RegExp(s+` `+o,`g`);i&&=i.ellipsis;var d=0;if(typeof i==`object`){var f=i.template;d=f.length-2,i=i.pattern}typeof i!=`string`&&(i=i===!1?``:`...`),d&&(i=f.replace(`$1`,i)),f=i.length-d;let p,m;typeof c==`object`&&(p=c.before,p===0&&(p=-1),m=c.after,m===0&&(m=-1),c=c.total||9e5),d=new Map;for(let N=0,P,F,I;N<t.length;N++){let L;if(r)L=t,I=r;else{var h=t[N];if(I=h.field,!I)continue;L=h.result}F=n.get(I),P=F.encoder,h=d.get(P),typeof h!=`string`&&(h=P.encode(e),d.set(P,h));for(let e=0;e<L.length;e++){var g=L[e].doc;if(!g||(g=nx(g,I),!g))continue;var _=g.trim().split(/\s+/);if(!_.length)continue;g=``;var v=[];let t=[];for(var y=-1,b=-1,x=0,S=0;S<_.length;S++){var C=_[S],w=P.encode(C);w=w.length>1?w.join(` `):w[0];let e;if(w&&C){for(var T=C.length,E=(P.split?C.replace(P.split,``):C).length-w.length,D=``,O=0,k=0;k<h.length;k++){var A=h[k];if(A){var j=A.length;j+=E<0?0:E,O&&j<=O||(A=w.indexOf(A),A>-1&&(D=(A?C.substring(0,A):``)+o+C.substring(A,A+j)+s+(A+j<T?C.substring(A+j):``),O=j,e=!0))}}D&&(c&&(y<0&&(y=g.length+ +!!g),b=g.length+ +!!g+D.length,x+=T,t.push(v.length),v.push({match:D})),g+=(g?` `:``)+D)}if(!e)C=_[S],g+=(g?` `:``)+C,c&&v.push({text:C});else if(c&&x>=c)break}if(x=t.length*(a.length-2),p||m||c&&g.length-x>c){if(x=c+x-f*2,S=b-y,p>0&&(S+=p),m>0&&(S+=m),S<=x)_=p?y-(p>0?p:0):y-((x-S)/2|0),v=m?b+(m>0?m:0):_+x,l||(_>0&&g.charAt(_)!==` `&&g.charAt(_-1)!==` `&&(_=g.indexOf(` `,_),_<0&&(_=0)),v<g.length&&g.charAt(v-1)!==` `&&g.charAt(v)!==` `&&(v=g.lastIndexOf(` `,v),v<b?v=b:++v)),g=(_?i:``)+g.substring(_,v)+(v<g.length?i:``);else{for(b=[],y={},x={},S={},C={},w={},D=E=T=0,k=O=1;;){var M=void 0;for(let e=0,n;e<t.length;e++){if(n=t[e],D){if(E!==D){if(S[e+1])continue;if(n+=D,y[n]){T-=f,x[e+1]=1,S[e+1]=1;continue}if(n>=v.length-1){if(n>=v.length){S[e+1]=1,n>=_.length&&(x[e+1]=1);continue}T-=f}if(g=v[n].text,j=m&&w[e]){if(j>0){if(g.length>j){if(S[e+1]=1,l)g=g.substring(0,j);else continue}(j-=g.length)||(j=-1),w[e]=j}else{S[e+1]=1;continue}}if(T+g.length+1<=c)g=` `+g,b[e]+=g;else if(l)M=c-T-1,M>0&&(g=` `+g.substring(0,M),b[e]+=g),S[e+1]=1;else{S[e+1]=1;continue}}else{if(S[e])continue;if(n-=E,y[n]){T-=f,S[e]=1,x[e]=1;continue}if(n<=0){if(n<0){S[e]=1,x[e]=1;continue}T-=f}if(g=v[n].text,j=p&&C[e]){if(j>0){if(g.length>j){if(S[e]=1,l)g=g.substring(g.length-j);else continue}(j-=g.length)||(j=-1),C[e]=j}else{S[e]=1;continue}}if(T+g.length+1<=c)g+=` `,b[e]=g+b[e];else if(l)M=g.length+1-(c-T),M>=0&&M<g.length&&(g=g.substring(M)+` `,b[e]=g+b[e]),S[e]=1;else{S[e]=1;continue}}}else{g=v[n].match,p&&(C[e]=p),m&&(w[e]=m),e&&T++;let t;if(n?!e&&f&&(T+=f):(x[e]=1,S[e]=1),n>=_.length-1||n<v.length-1&&v[n+1].match?t=1:f&&(T+=f),T-=a.length-2,!e||T+g.length<=c)b[e]=g;else{M=O=k=x[e]=0;break}t&&(x[e+1]=1,S[e+1]=1)}T+=g.length,M=y[n]=1}if(M)E===D?D++:E++;else{if(E===D?O=0:k=0,!O&&!k)break;O?(E++,D=E):D++}}g=``;for(let e=0,t;e<b.length;e++)t=(x[e]?e?` `:``:(e&&!i?` `:``)+i)+b[e],g+=t;i&&!x[b.length]&&(g+=i)}}u&&(g=g.replace(u,` `)),L[e].highlight=g}if(r)break}return t}function Fx(e,t){if(!this||this.constructor!==Fx)return new Fx(e,t);let n=0,r,i,a,o,s,c;if(e&&e.index){let r=e;if(t=r.index,n=r.boost||0,i=r.query){a=r.field||r.pluck,o=r.highlight;let n=r.resolve;e=r.async||r.queue,r.resolve=!1,r.index=null,e=e?t.searchAsync(r):t.search(r),r.resolve=n,r.index=t,e=e.result||e}else e=[]}if(e&&e.then){let t=this;e=e.then(function(e){t.C[0]=t.result=e.result||e,Ix(t)}),r=[e],e=[],s=new Promise(function(e){c=e})}this.index=t||null,this.result=e||[],this.h=n,this.C=r||[],this.await=s||null,this.return=c||null,this.highlight=o||null,this.query=i||``,this.field=a||``}Xb=Fx.prototype,Xb.limit=function(e){if(this.await){let t=this;this.C.push(function(){return t.limit(e).result})}else if(this.result.length){let t=[];for(let n=0,r;n<this.result.length;n++)if(r=this.result[n]){if(r.length<=e){if(t[n]=r,e-=r.length,!e)break}else{t[n]=r.slice(0,e);break}}this.result=t}return this},Xb.offset=function(e){if(this.await){let t=this;this.C.push(function(){return t.offset(e).result})}else if(this.result.length){let t=[];for(let n=0,r;n<this.result.length;n++)(r=this.result[n])&&(r.length<=e?e-=r.length:(t[n]=r.slice(e),e=0));this.result=t}return this},Xb.boost=function(e){if(this.await){let t=this;this.C.push(function(){return t.boost(e).result})}else this.h+=e;return this};function Ix(e,t){let n=e.result;var r=e.await;e.await=null;for(let t=0,i;t<e.C.length;t++)if(i=e.C[t]){if(typeof i==`function`)n=i(),e.C[t]=n=n.result||n,t--;else if(i.h)n=i.h(),e.C[t]=n=n.result||n,t--;else if(i.then)return e.await=r}return r=e.return,e.C=[],e.return=null,t||r(n),n}Xb.resolve=function(e,t,n,r,i){let a=this.await?Ix(this,!0):this.result;if(a.then){let o=this;return a.then(function(){return o.resolve(e,t,n,r,i)})}return a.length&&(typeof e==`object`?(r=e.highlight||this.highlight,n=!!r||e.enrich,t=e.offset,e=e.limit):(r||=this.highlight,n=!!r||n),a=i?n?zx.call(this.index,a):a:jx.call(this.index,a,e||100,t,n)),this.finalize(a,r)},Xb.finalize=function(e,t){if(e.then){let n=this;return e.then(function(e){return n.finalize(e,t)})}t&&e.length&&this.query&&(e=Px(this.query,e,this.index.index,this.field,t));let n=this.return;return this.highlight=this.index=this.result=this.C=this.await=this.return=null,this.query=this.field=``,n&&n(e),e};function Lx(e,t,n,r,i,a,o){let s=e.length,c=[],l,u;l=$b();for(let d=0,f,p,m,h;d<t;d++)for(let t=0;t<s;t++)if(m=e[t],d<m.length&&(f=m[d]))for(let e=0;e<f.length;e++){if(p=f[e],(u=l[p])?l[p]++:(u=0,l[p]=1),h=c[u]||(c[u]=[]),!o){let e=d+(t||!i?0:a||0);h=h[e]||(h[e]=[])}if(h.push(p),o&&n&&u===s-1&&h.length-r===n)return r?h.slice(r):h}if(e=c.length){if(i)c=c.length>1?vse(c,n,r,o,a):(c=c[0])&&n&&c.length>n||r?c.slice(r,n+r):c;else{if(e<s)return[];if(c=c[e-1],n||r){if(o)(c.length>n||r)&&(c=c.slice(r,n+r));else{i=[];for(let e=0,t;e<c.length;e++)if(t=c[e]){if(r&&t.length>r)r-=t.length;else if((n&&t.length>n||r)&&(t=t.slice(r,n+r),n-=t.length,r&&(r-=t.length)),i.push(t),!n)break}c=i}}}}return c}function vse(e,t,n,r,i){let a=[],o=$b(),s;var c=e.length;let l;if(r){for(i=c-1;i>=0;i--)if(l=(r=e[i])&&r.length){for(c=0;c<l;c++)if(s=r[c],!o[s]){if(o[s]=1,n)n--;else if(a.push(s),a.length===t)return a}}}else for(let u=c-1,d,f=0;u>=0;u--){d=e[u];for(let e=0;e<d.length;e++)if(l=(r=d[e])&&r.length){for(let d=0;d<l;d++)if(s=r[d],!o[s]){if(o[s]=1,n)n--;else{let n=(e+(u<c-1&&i||0))/(u+1)|0;if((a[n]||(a[n]=[])).push(s),++f===t)return a}}}}return a}function yse(e,t,n,r,i){let a=$b(),o=[];for(let e=0,n;e<t.length;e++){n=t[e];for(let e=0;e<n.length;e++)a[n[e]]=1}if(i){for(let t=0,i;t<e.length;t++)if(i=e[t],a[i]){if(r)r--;else if(o.push(i),a[i]=0,n&&--n===0)break}}else for(let n=0,r,i;n<e.result.length;n++)for(r=e.result[n],t=0;t<r.length;t++)i=r[t],a[i]&&((o[n]||(o[n]=[])).push(i),a[i]=0);return o}Bx.prototype.search=function(e,t,n,r){n||(!t&&tx(e)?(n=e,e=``):tx(t)&&(n=t,t=0));let i=[];var a=[];let o,s,c,l,u,d,f=0,p=!0,m;if(n){n.constructor===Array&&(n={index:n}),e=n.query||e,o=n.pluck,s=n.merge,l=n.boost,d=o||n.field||(d=n.index)&&(d.index?null:d);var h=this.tag&&n.tag;c=n.suggest,p=n.resolve!==!1,u=n.cache,m=p&&this.store&&n.highlight;var g=!!m||p&&this.store&&n.enrich;t=n.limit||t;var _=n.offset||0;if(t||=p?100:0,h&&(!this.db||!r)){h.constructor!==Array&&(h=[h]);var v=[];for(let e=0,t;e<h.length;e++)if(t=h[e],t.field&&t.tag){var y=t.tag;if(y.constructor===Array)for(var b=0;b<y.length;b++)v.push(t.field,y[b]);else v.push(t.field,y)}else{y=Object.keys(t);for(let e=0,n,r;e<y.length;e++)if(n=y[e],r=t[n],r.constructor===Array)for(b=0;b<r.length;b++)v.push(n,r[b]);else v.push(n,r)}if(h=v,!e){if(a=[],v.length)for(h=0;h<v.length;h+=2){if(this.db){if(r=this.index.get(v[h]),!r)continue;a.push(r=r.db.tag(v[h+1],t,_,g))}else r=bse.call(this,v[h],v[h+1],t,_,g);i.push(p?{field:v[h],tag:v[h+1],result:r}:[r])}if(a.length){let e=this;return Promise.all(a).then(function(t){for(let e=0;e<t.length;e++)p?i[e].result=t[e]:i[e]=t[e];return p?i:new Fx(i.length>1?Lx(i,1,0,0,c,l):i[0],e)})}return p?i:new Fx(i.length>1?Lx(i,1,0,0,c,l):i[0],this)}}p||o||!(d||=this.field)||(ex(d)?o=d:(d.constructor===Array&&d.length===1&&(d=d[0]),o=d.field||d.index)),d&&d.constructor!==Array&&(d=[d])}d||=this.field;let x;v=(this.worker||this.db)&&!r&&[];for(let o=0,s,l,C;o<d.length;o++){if(l=d[o],this.db&&this.tag&&!this.B[o])continue;let w;if(ex(l)||(w=l,l=w.field,e=w.query||e,t=Qb(w.limit,t),_=Qb(w.offset,_),c=Qb(w.suggest,c),m=p&&this.store&&Qb(w.highlight,m),g=!!m||p&&this.store&&Qb(w.enrich,g),u=Qb(w.cache,u)),r)s=r[o];else{y=w||n||{},b=y.enrich;var S=this.index.get(l);if(h&&(this.db&&(y.tag=h,y.field=d,x=S.db.support_tag_search),!x&&b&&(y.enrich=!1),x||(y.limit=0,y.offset=0)),s=u?S.searchCache(e,h&&!x?0:t,y):S.search(e,h&&!x?0:t,y),h&&!x&&(y.limit=t,y.offset=_),b&&(y.enrich=b),v){v[o]=s;continue}}if(C=(s=s.result||s)&&s.length,h&&C){if(y=[],b=0,this.db&&r){if(!x)for(S=d.length;S<r.length;S++){let e=r[S];if(e&&e.length)b++,y.push(e);else if(!c)return p?i:new Fx(i,this)}}else for(let e=0,t,n;e<h.length;e+=2){if(t=this.tag.get(h[e]),!t){if(c)continue;return p?i:new Fx(i,this)}if((t&&=t.get(h[e+1]))&&t.length)b++,y.push(t);else if(!c)return p?i:new Fx(i,this)}if(b){if(s=yse(s,y,t,_,p),C=s.length,!C&&!c)return p?s:new Fx(s,this);b--}}if(C)a[f]=l,i.push(s),f++;else if(d.length===1)return p?i:new Fx(i,this)}if(v){if(this.db&&h&&h.length&&!x)for(g=0;g<h.length;g+=2){if(a=this.index.get(h[g]),!a){if(c)continue;return p?i:new Fx(i,this)}v.push(a.db.tag(h[g+1],t,_,!1))}let r=this;return Promise.all(v).then(function(i){return n&&(n.resolve=p),i.length&&(i=r.search(e,t,n,i)),i})}if(!f)return p?i:new Fx(i,this);if(o&&(!g||!this.store))return i=i[0],p?i:new Fx(i,this);for(v=[],_=0;_<a.length;_++){if(h=i[_],g&&h.length&&h[0].doc===void 0&&(this.db?v.push(h=this.index.get(this.field[0]).db.enrich(h)):h=zx.call(this,h)),o)return p?m?Px(e,h,this.index,o,m):h:new Fx(h,this);i[_]={field:a[_],result:h}}if(g&&this.db&&v.length){let t=this;return Promise.all(v).then(function(n){for(let e=0;e<n.length;e++)i[e].result=n[e];return m&&(i=Px(e,i,t.index,o,m)),s?Rx(i):i})}return m&&(i=Px(e,i,this.index,o,m)),s?Rx(i):i};function Rx(e){let t=[],n=$b(),r=$b();for(let i=0,a,o,s,c,l,u,d;i<e.length;i++){a=e[i],o=a.field,s=a.result;for(let e=0;e<s.length;e++)l=s[e],typeof l==`object`?c=l.id:l={id:c=l},(u=n[c])?u.push(o):(l.field=n[c]=[o],t.push(l)),(d=l.highlight)&&(u=r[c],u||(r[c]=u={},l.highlight=u),u[o]=d)}return t}function bse(e,t,n,r,i){return e=this.tag.get(e),!e||(e=e.get(t),!e)?[]:(t=e.length-r,t>0&&((n&&t>n||r)&&(e=e.slice(r,r+n)),i&&(e=zx.call(this,e))),e)}function zx(e){if(!this||!this.store)return e;if(this.db)return this.index.get(this.field[0]).db.enrich(e);let t=Array(e.length);for(let n=0,r;n<e.length;n++)r=e[n],t[n]={id:r,doc:this.store.get(r)};return t}function Bx(e){if(!this||this.constructor!==Bx)return new Bx(e);let t=e.document||e.doc||e,n,r;if(this.B=[],this.field=[],this.D=[],this.key=(n=t.key||t.id)&&Vx(n,this.D)||`id`,(r=e.keystore||0)&&(this.keystore=r),this.fastupdate=!!e.fastupdate,this.reg=!this.fastupdate||e.worker||e.db?r?new _x(r):new Set:r?new gx(r):new Map,this.h=(n=t.store||null)&&n&&n!==!0&&[],this.store=n?r?new gx(r):new Map:null,this.cache=(n=e.cache||null)&&new sx(n),e.cache=!1,this.worker=e.worker||!1,this.priority=e.priority||4,this.index=xse.call(this,e,t),this.tag=null,(n=t.tag)&&(typeof n==`string`&&(n=[n]),n.length)){this.tag=new Map,this.A=[],this.F=[];for(let e=0,t,r;e<n.length;e++){if(t=n[e],r=t.field||t,!r)throw Error(`The tag field from the document descriptor is undefined.`);t.custom?this.A[e]=t.custom:(this.A[e]=Vx(r,this.D),t.filter&&(typeof this.A[e]==`string`&&(this.A[e]=new String(this.A[e])),this.A[e].G=t.filter)),this.F[e]=r,this.tag.set(r,new Map)}}if(this.worker){this.fastupdate=!1,e=[];for(let t of this.index.values())t.then&&e.push(t);if(e.length){let t=this;return Promise.all(e).then(function(e){let n=0;for(let r of t.index.entries()){let i=r[0],a=r[1];a.then&&(a=e[n],t.index.set(i,a),n++)}return t})}}else e.db&&(this.fastupdate=!1,this.mount(e.db))}Xb=Bx.prototype,Xb.mount=function(e){let t=this.field;if(this.tag)for(let e=0,r;e<this.F.length;e++){r=this.F[e];var n=void 0;this.index.set(r,n=new rS({},this.reg)),t===this.field&&(t=t.slice(0)),t.push(r),n.tag=this.tag.get(r)}n=[];let r={db:e.db,type:e.type,fastupdate:e.fastupdate};for(let i=0,a,o;i<t.length;i++){r.field=o=t[i],a=this.index.get(o);let s=new e.constructor(e.id,r);s.id=e.id,n[i]=s.mount(a),a.document=!0,i?a.bypass=!0:a.store=this.store}let i=this;return this.db=Promise.all(n).then(function(){i.db=!0})},Xb.commit=async function(){let e=[];for(let t of this.index.values())e.push(t.commit());await Promise.all(e),this.reg.clear()},Xb.destroy=function(){let e=[];for(let t of this.index.values())e.push(t.destroy());return Promise.all(e)};function xse(e,t){let n=new Map,r=t.index||t.field||t;ex(r)&&(r=[r]);for(let t=0,a,o;t<r.length;t++){if(a=r[t],ex(a)||(o=a,a=a.field),o=tx(o)?Object.assign({},e,o):e,this.worker){var i=void 0;i=(i=o.encoder)&&i.encode?i:new ix(typeof i==`string`?px[i]:i||{}),i=new Dx(o,i),n.set(a,i)}this.worker||n.set(a,new rS(o,this.reg)),o.custom?this.B[t]=o.custom:(this.B[t]=Vx(a,this.D),o.filter&&(typeof this.B[t]==`string`&&(this.B[t]=new String(this.B[t])),this.B[t].G=o.filter)),this.field[t]=a}if(this.h){e=t.store,ex(e)&&(e=[e]);for(let t=0,n,r;t<e.length;t++)n=e[t],r=n.field||n,n.custom?(this.h[t]=n.custom,n.custom.O=r):(this.h[t]=Vx(r,this.D),n.filter&&(typeof this.h[t]==`string`&&(this.h[t]=new String(this.h[t])),this.h[t].G=n.filter))}return n}function Vx(e,t){let n=e.split(`:`),r=0;for(let i=0;i<n.length;i++)e=n[i],e[e.length-1]===`]`&&(e=e.substring(0,e.length-2))&&(t[r]=!0),e&&(n[r++]=e);return r<n.length&&(n.length=r),r>1?n:n[0]}Xb.append=function(e,t){return this.add(e,t,!0)},Xb.update=function(e,t){return this.remove(e).add(e,t)},Xb.remove=function(e){tx(e)&&(e=nx(e,this.key));for(var t of this.index.values())t.remove(e,!0);if(this.reg.has(e)){if(this.tag&&!this.fastupdate)for(let n of this.tag.values())for(let r of n){t=r[0];let i=r[1],a=i.indexOf(e);a>-1&&(i.length>1?i.splice(a,1):n.delete(t))}this.store&&this.store.delete(e),this.reg.delete(e)}return this.cache&&this.cache.remove(e),this},Xb.clear=function(){let e=[];for(let t of this.index.values()){let n=t.clear();n.then&&e.push(n)}if(this.tag)for(let e of this.tag.values())e.clear();return this.store&&this.store.clear(),this.cache&&this.cache.clear(),e.length?Promise.all(e):this},Xb.contain=function(e){return this.db?this.index.get(this.field[0]).db.has(e):this.reg.has(e)},Xb.cleanup=function(){for(let e of this.index.values())e.cleanup();return this},Xb.get=function(e){return this.db?this.index.get(this.field[0]).db.enrich(e).then(function(e){return e[0]&&e[0].doc||null}):this.store.get(e)||null},Xb.set=function(e,t){return typeof e==`object`&&(t=e,e=nx(t,this.key)),this.store.set(e,t),this},Xb.searchCache=ox,Xb.export=Sse,Xb.import=Cse,Sx(Bx.prototype);function Hx(e,t=0){let n=[],r=[];t&&=25e4/t*5e3|0;for(let i of e.entries())r.push(i),r.length===t&&(n.push(r),r=[]);return r.length&&n.push(r),n}function Ux(e,t){t||=new Map;for(let n=0,r;n<e.length;n++)r=e[n],t.set(r[0],r[1]);return t}function Wx(e,t=0){let n=[],r=[];t&&=25e4/t*1e3|0;for(let i of e.entries())r.push([i[0],Hx(i[1])[0]||[]]),r.length===t&&(n.push(r),r=[]);return r.length&&n.push(r),n}function Gx(e,t){t||=new Map;for(let n=0,r,i;n<e.length;n++)r=e[n],i=t.get(r[0]),t.set(r[0],Ux(r[1],i));return t}function Kx(e){let t=[],n=[];for(let r of e.keys())n.push(r),n.length===25e4&&(t.push(n),n=[]);return n.length&&t.push(n),t}function qx(e,t){t||=new Set;for(let n=0;n<e.length;n++)t.add(e[n]);return t}function Jx(e,t,n,r,i,a,o=0){let s=r&&r.constructor===Array;var c=s?r.shift():r;if(!c)return this.export(e,t,i,a+1);if((c=e((t?t+`.`:``)+(o+1)+`.`+n,JSON.stringify(c)))&&c.then){let l=this;return c.then(function(){return Jx.call(l,e,t,n,s?r:null,i,a,o+1)})}return Jx.call(this,e,t,n,s?r:null,i,a,o+1)}function Sse(e,t,n=0,r=0){if(n<this.field.length){let i=this.field[n];if((t=this.index.get(i).export(e,i,n,r=1))&&t.then){let r=this;return t.then(function(){return r.export(e,i,n+1)})}return this.export(e,i,n+1)}let i,a;switch(r){case 0:i=`reg`,a=Kx(this.reg),t=null;break;case 1:i=`tag`,a=this.tag&&Wx(this.tag,this.reg.size),t=null;break;case 2:i=`doc`,a=this.store&&Hx(this.store),t=null;break;default:return}return Jx.call(this,e,t,i,a||null,n,r)}function Cse(e,t){var n=e.split(`.`);n[n.length-1]===`json`&&n.pop();let r=n.length>2?n[0]:``;if(n=n.length>2?n[2]:n[1],this.worker&&r)return this.index.get(r).import(e);if(t){if(typeof t==`string`&&(t=JSON.parse(t)),r)return this.index.get(r).import(n,t);switch(n){case`reg`:this.fastupdate=!1,this.reg=qx(t,this.reg);for(let e=0,t;e<this.field.length;e++)t=this.index.get(this.field[e]),t.fastupdate=!1,t.reg=this.reg;if(this.worker){t=[];for(let n of this.index.values())t.push(n.import(e));return Promise.all(t)}break;case`tag`:this.tag=Gx(t,this.tag);break;case`doc`:this.store=Ux(t,this.store)}}}function Yx(e,t){let n=``;for(let r of e.entries()){e=r[0];let i=r[1],a=``;for(let e=0,n;e<i.length;e++){n=i[e]||[``];let r=``;for(let e=0;e<n.length;e++)r+=(r?`,`:``)+(t===`string`?`"`+n[e]+`"`:n[e]);r=`[`+r+`]`,a+=(a?`,`:``)+r}a=`["`+e+`",[`+a+`]]`,n+=(n?`,`:``)+a}return n}rS.prototype.remove=function(e,t){let n=this.reg.size&&(this.fastupdate?this.reg.get(e):this.reg.has(e));if(n){if(this.fastupdate){for(let t=0,r,i;t<n.length;t++)if((r=n[t])&&(i=r.length)){if(r[i-1]===e)r.pop();else{let t=r.indexOf(e);t>=0&&r.splice(t,1)}}}else Xx(this.map,e),this.depth&&Xx(this.ctx,e);t||this.reg.delete(e)}return this.db&&(this.commit_task.push({del:e}),this.M&&iS(this)),this.cache&&this.cache.remove(e),this};function Xx(e,t){let n=0;var r=t===void 0;if(e.constructor===Array){for(let i=0,a,o,s;i<e.length;i++)if((a=e[i])&&a.length){if(r)return 1;if(o=a.indexOf(t),o>=0){if(a.length>1)return a.splice(o,1),1;if(delete e[i],n)return 1;s=1}else{if(s)return 1;n++}}}else for(let i of e.entries())r=i[0],Xx(i[1],t)?n++:e.delete(r);return n}var wse={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:`forward`},score:{resolution:9,context:{depth:2,resolution:3}}};rS.prototype.add=function(e,t,n,r){if(t&&(e||e===0)){if(!r&&!n&&this.reg.has(e))return this.update(e,t);r=this.depth,t=this.encoder.encode(t,!r);let l=t.length;if(l){let u=$b(),d=$b(),f=this.resolution;for(let p=0;p<l;p++){let m=t[this.rtl?l-1-p:p];var i=m.length;if(i&&(r||!d[m])){var a=this.score?this.score(t,m,p,null,0):Qx(f,l,p),o=``;switch(this.tokenize){case`tolerant`:if(Zx(this,d,m,a,e,n),i>2){for(let t=1,r,s,c,l;t<i-1;t++)r=m.charAt(t),s=m.charAt(t+1),c=m.substring(0,t)+s,l=m.substring(t+2),o=c+r+l,Zx(this,d,o,a,e,n),o=c+l,Zx(this,d,o,a,e,n);Zx(this,d,m.substring(0,m.length-1),a,e,n)}break;case`full`:if(i>2){for(let r=0,c;r<i;r++)for(a=i;a>r;a--){o=m.substring(r,a),c=this.rtl?i-1-r:r;var s=this.score?this.score(t,m,p,o,c):Qx(f,l,p,i,c);Zx(this,d,o,s,e,n)}break}case`bidirectional`:case`reverse`:if(i>1){for(s=i-1;s>0;s--){o=m[this.rtl?i-1-s:s]+o;var c=this.score?this.score(t,m,p,o,s):Qx(f,l,p,i,s);Zx(this,d,o,c,e,n)}o=``}case`forward`:if(i>1){for(s=0;s<i;s++)o+=m[this.rtl?i-1-s:s],Zx(this,d,o,a,e,n);break}default:if(Zx(this,d,m,a,e,n),r&&l>1&&p<l-1)for(i=this.N,o=m,a=Math.min(r+1,this.rtl?p+1:l-p),s=1;s<a;s++){m=t[this.rtl?l-1-p-s:p+s],c=this.bidirectional&&m>o;let r=this.score?this.score(t,o,p,m,s-1):Qx(i+(l/2>i?0:1),l,p,a-1,s-1);Zx(this,u,c?o:m,r,e,n,c?m:o)}}}}this.fastupdate||this.reg.add(e)}}return this.db&&(this.commit_task.push(n?{ins:e}:{del:e}),this.M&&iS(this)),this};function Zx(e,t,n,r,i,a,o){let s,c;if(!(s=t[n])||o&&!s[o]){if(o?(t=s||(t[n]=$b()),t[o]=1,c=e.ctx,(s=c.get(o))?c=s:c.set(o,c=e.keystore?new gx(e.keystore):new Map)):(c=e.map,t[n]=1),(s=c.get(n))?c=s:c.set(n,c=s=[]),a){for(let n=0,a;n<s.length;n++)if((a=s[n])&&a.includes(i)){if(n<=r)return;a.splice(a.indexOf(i),1),e.fastupdate&&(t=e.reg.get(i))&&t.splice(t.indexOf(a),1);break}}if(c=c[r]||(c[r]=[]),c.push(i),c.length===2**31-1){if(t=new hx(c),e.fastupdate)for(let n of e.reg.values())n.includes(c)&&(n[n.indexOf(c)]=t);s[r]=c=t}e.fastupdate&&((r=e.reg.get(i))?r.push(c):e.reg.set(i,[c]))}}function Qx(e,t,n,r,i){return n&&e>1?t+(r||0)<=e?n+(i||0):(e-1)/(t+(r||0))*(n+(i||0))+1|0:0}rS.prototype.search=function(e,t,n){if(n||(t||typeof e!=`object`?typeof t==`object`&&(n=t,t=0):(n=e,e=``)),n&&n.cache)return n.cache=!1,e=this.searchCache(e,t,n),n.cache=!0,e;let r=[],i,a,o,s=0,c,l,u,d,f;n&&(e=n.query||e,t=n.limit||t,s=n.offset||0,a=n.context,o=n.suggest,f=(c=n.resolve)&&n.enrich,u=n.boost,d=n.resolution,l=this.db&&n.tag),c===void 0&&(c=this.resolve),a=this.depth&&a!==!1;let p=this.encoder.encode(e,!a);if(i=p.length,t||=c?100:0,i===1)return eS.call(this,p[0],``,t,s,c,f,l);if(i===2&&a&&!o)return eS.call(this,p[1],p[0],t,s,c,f,l);let m=$b(),h=0,g;if(a&&(g=p[0],h=1),d||d===0||(d=g?this.N:this.resolution),this.db){if(this.db.search&&(n=this.db.search(this,p,t,s,o,c,f,l),n!==!1))return n;let e=this;return async function(){for(let t,n;h<i;h++){if((n=p[h])&&!m[n]){if(m[n]=1,t=await nS(e,n,g,0,0,!1,!1),t=tS(t,r,o,d)){r=t;break}g&&(o&&t&&r.length||(g=n))}o&&g&&h===i-1&&!r.length&&(d=e.resolution,g=``,h=-1,m=$b())}return $x(r,d,t,s,o,u,c)}()}for(let e,t;h<i;h++){if((t=p[h])&&!m[t]){if(m[t]=1,e=nS(this,t,g,0,0,!1,!1),e=tS(e,r,o,d)){r=e;break}g&&(o&&e&&r.length||(g=t))}o&&g&&h===i-1&&!r.length&&(d=this.resolution,g=``,h=-1,m=$b())}return $x(r,d,t,s,o,u,c)};function $x(e,t,n,r,i,a,o){let s=e.length,c=e;if(s>1)c=Lx(e,t,n,r,i,a,o);else if(s===1)return o?jx.call(null,e[0],n,r):new Fx(e[0],this);return o?c:new Fx(c,this)}function eS(e,t,n,r,i,a,o){return e=nS(this,e,t,n,r,i,a,o),this.db?e.then(function(e){return i?e||[]:new Fx(e,this)}):e&&e.length?i?jx.call(this,e,n,r):new Fx(e,this):i?[]:new Fx([],this)}function tS(e,t,n,r){let i=[];if(e&&e.length){if(e.length<=r){t.push(e);return}for(let t=0,n;t<r;t++)(n=e[t])&&(i[t]=n);if(i.length){t.push(i);return}}if(!n)return i}function nS(e,t,n,r,i,a,o,s){let c;return n&&(c=e.bidirectional&&t>n)&&(c=n,n=t,t=c),e.db?e.db.get(t,n,r,i,a,o,s):(e=n?(e=e.ctx.get(n))&&e.get(t):e.map.get(t),e)}function rS(e,t){if(!this||this.constructor!==rS)return new rS(e);if(e){var n=ex(e)?e:e.preset;n&&(e=Object.assign({},wse[n],e))}else e={};n=e.context;let r=n===!0?{depth:1}:n||{},i=ex(e.encoder)?px[e.encoder]:e.encode||e.encoder||{};this.encoder=i.encode?i:typeof i==`object`?new ix(i):{encode:i},this.resolution=e.resolution||9,this.tokenize=n=(n=e.tokenize)&&n!=="default"&&n!==`exact`&&n||`strict`,this.depth=n===`strict`&&r.depth||0,this.bidirectional=r.bidirectional!==!1,this.fastupdate=!!e.fastupdate,this.score=e.score||null,(n=e.keystore||0)&&(this.keystore=n),this.map=n?new gx(n):new Map,this.ctx=n?new gx(n):new Map,this.reg=t||(this.fastupdate?n?new gx(n):new Map:n?new _x(n):new Set),this.N=r.resolution||3,this.rtl=i.rtl||e.rtl||!1,this.cache=(n=e.cache||null)&&new sx(n),this.resolve=e.resolve!==!1,(n=e.db)&&(this.db=this.mount(n)),this.M=e.commit!==!1,this.commit_task=[],this.commit_timer=null,this.priority=e.priority||4}Xb=rS.prototype,Xb.mount=function(e){return this.commit_timer&&=(clearTimeout(this.commit_timer),null),e.mount(this)},Xb.commit=function(){return this.commit_timer&&=(clearTimeout(this.commit_timer),null),this.db.commit(this)},Xb.destroy=function(){return this.commit_timer&&=(clearTimeout(this.commit_timer),null),this.db.destroy()};function iS(e){e.commit_timer||=setTimeout(function(){e.commit_timer=null,e.db.commit(e)},1)}Xb.clear=function(){return this.map.clear(),this.ctx.clear(),this.reg.clear(),this.cache&&this.cache.clear(),this.db?(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[],this.db.clear()):this},Xb.append=function(e,t){return this.add(e,t,!0)},Xb.contain=function(e){return this.db?this.db.has(e):this.reg.has(e)},Xb.update=function(e,t){let n=this,r=this.remove(e);return r&&r.then?r.then(()=>n.add(e,t)):this.add(e,t)},Xb.cleanup=function(){return this.fastupdate?(Xx(this.map),this.depth&&Xx(this.ctx),this):this},Xb.searchCache=ox,Xb.export=function(e,t,n=0,r=0){let i,a;switch(r){case 0:i=`reg`,a=Kx(this.reg);break;case 1:i=`cfg`,a=null;break;case 2:i=`map`,a=Hx(this.map,this.reg.size);break;case 3:i=`ctx`,a=Wx(this.ctx,this.reg.size);break;default:return}return Jx.call(this,e,t,i,a,n,r)},Xb.import=function(e,t){if(t)switch(typeof t==`string`&&(t=JSON.parse(t)),e=e.split(`.`),e[e.length-1]===`json`&&e.pop(),e.length===3&&e.shift(),e=e.length>1?e[1]:e[0],e){case`reg`:this.fastupdate=!1,this.reg=qx(t,this.reg);break;case`map`:this.map=Ux(t,this.map);break;case`ctx`:this.ctx=Gx(t,this.ctx)}},Xb.serialize=function(e=!0){let t=``,n=``,r=``;if(this.reg.size){let e;for(var i of this.reg.keys())e||=typeof i,t+=(t?`,`:``)+(e===`string`?`"`+i+`"`:i);t=`index.reg=new Set([`+t+`]);`,n=Yx(this.map,e),n=`index.map=new Map([`+n+`]);`;for(let t of this.ctx.entries()){i=t[0];let n=Yx(t[1],e);n=`new Map([`+n+`])`,n=`["`+i+`",`+n+`]`,r+=(r?`,`:``)+n}r=`index.ctx=new Map([`+r+`]);`}return e?`function inject(index){`+t+n+r+`}`:t+n+r},Sx(rS.prototype);var aS=typeof window<`u`&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),oS=[`map`,`ctx`,`tag`,`reg`,`cfg`],sS=$b();function cS(e,t={}){if(!this||this.constructor!==cS)return new cS(e,t);typeof e==`object`&&(t=e,e=e.name),e||console.info(`Default storage space was used, because a name was not passed.`),this.id=`flexsearch`+(e?`:`+e.toLowerCase().replace(/[^a-z0-9_\-]/g,``):``),this.field=t.field?t.field.toLowerCase().replace(/[^a-z0-9_\-]/g,``):``,this.type=t.type,this.fastupdate=this.support_tag_search=!1,this.db=null,this.h={}}Xb=cS.prototype,Xb.mount=function(e){return e.index?e.mount(this):(e.db=this,this.open())},Xb.open=function(){if(this.db)return this.db;let e=this;navigator.storage&&navigator.storage.persist&&navigator.storage.persist(),sS[e.id]||(sS[e.id]=[]),sS[e.id].push(e.field);let t=aS.open(e.id,1);return t.onupgradeneeded=function(){let t=e.db=this.result;for(let n=0,r;n<oS.length;n++){r=oS[n];for(let n=0,i;n<sS[e.id].length;n++)i=sS[e.id][n],t.objectStoreNames.contains(r+(r===`reg`?``:i?`:`+i:``))||t.createObjectStore(r+(r===`reg`?``:i?`:`+i:``))}},e.db=uS(t,function(t){e.db=t,e.db.onversionchange=function(){e.close()}})},Xb.close=function(){this.db&&this.db.close(),this.db=null},Xb.destroy=function(){return uS(aS.deleteDatabase(this.id))},Xb.clear=function(){let e=[];for(let t=0,n;t<oS.length;t++){n=oS[t];for(let t=0,r;t<sS[this.id].length;t++)r=sS[this.id][t],e.push(n+(n===`reg`?``:r?`:`+r:``))}let t=this.db.transaction(e,`readwrite`);for(let n=0;n<e.length;n++)t.objectStore(e[n]).clear();return uS(t)},Xb.get=function(e,t,n=0,r=0,i=!0,a=!1){e=this.db.transaction((t?`ctx`:`map`)+(this.field?`:`+this.field:``),`readonly`).objectStore((t?`ctx`:`map`)+(this.field?`:`+this.field:``)).get(t?t+`:`+e:e);let o=this;return uS(e).then(function(e){let t=[];if(!e||!e.length)return t;if(i){if(!n&&!r&&e.length===1)return e[0];for(let i=0,a;i<e.length;i++)if((a=e[i])&&a.length){if(r>=a.length){r-=a.length;continue}let e=n?r+Math.min(a.length-r,n):a.length;for(let n=r;n<e;n++)t.push(a[n]);if(r=0,t.length===n)break}return a?o.enrich(t):t}return e})},Xb.tag=function(e,t=0,n=0,r=!1){e=this.db.transaction(`tag`+(this.field?`:`+this.field:``),`readonly`).objectStore(`tag`+(this.field?`:`+this.field:``)).get(e);let i=this;return uS(e).then(function(e){return!e||!e.length||n>=e.length?[]:!t&&!n?e:(e=e.slice(n,n+t),r?i.enrich(e):e)})},Xb.enrich=function(e){typeof e!=`object`&&(e=[e]);let t=this.db.transaction(`reg`,`readonly`).objectStore(`reg`),n=[];for(let r=0;r<e.length;r++)n[r]=uS(t.get(e[r]));return Promise.all(n).then(function(t){for(let n=0;n<t.length;n++)t[n]={id:e[n],doc:t[n]?JSON.parse(t[n]):null};return t})},Xb.has=function(e){return e=this.db.transaction(`reg`,`readonly`).objectStore(`reg`).getKey(e),uS(e).then(function(e){return!!e})},Xb.search=null,Xb.info=function(){},Xb.transaction=function(e,t,n){e+=e===`reg`?``:this.field?`:`+this.field:``;let r=this.h[e+`:`+t];if(r)return n.call(this,r);let i=this.db.transaction(e,t);this.h[e+`:`+t]=r=i.objectStore(e);let a=n.call(this,r);return this.h[e+`:`+t]=null,uS(i).finally(function(){return a})},Xb.commit=async function(e){let t=e.commit_task,n=[];e.commit_task=[];for(let e=0,r;e<t.length;e++)r=t[e],r.del&&n.push(r.del);n.length&&await this.remove(n),e.reg.size&&(await this.transaction(`map`,`readwrite`,function(t){for(let n of e.map){let e=n[0],r=n[1];r.length&&(t.get(e).onsuccess=function(){let n=this.result;var i;if(n&&n.length){let e=Math.max(n.length,r.length);for(let t=0,a,o;t<e;t++)if((o=r[t])&&o.length){if((a=n[t])&&a.length)for(i=0;i<o.length;i++)a.push(o[i]);else n[t]=o;i=1}}else n=r,i=1;i&&t.put(n,e)})}}),await this.transaction(`ctx`,`readwrite`,function(t){for(let n of e.ctx){let e=n[0],r=n[1];for(let n of r){let r=n[0],i=n[1];i.length&&(t.get(e+`:`+r).onsuccess=function(){let n=this.result;var a;if(n&&n.length){let e=Math.max(n.length,i.length);for(let t=0,r,o;t<e;t++)if((o=i[t])&&o.length){if((r=n[t])&&r.length)for(a=0;a<o.length;a++)r.push(o[a]);else n[t]=o;a=1}}else n=i,a=1;a&&t.put(n,e+`:`+r)})}}}),e.store?await this.transaction(`reg`,`readwrite`,function(t){for(let n of e.store){let e=n[0],r=n[1];t.put(typeof r==`object`?JSON.stringify(r):1,e)}}):e.bypass||await this.transaction(`reg`,`readwrite`,function(t){for(let n of e.reg.keys())t.put(1,n)}),e.tag&&await this.transaction(`tag`,`readwrite`,function(t){for(let n of e.tag){let e=n[0],r=n[1];r.length&&(t.get(e).onsuccess=function(){let n=this.result;n=n&&n.length?n.concat(r):r,t.put(n,e)})}}),e.map.clear(),e.ctx.clear(),e.tag&&e.tag.clear(),e.store&&e.store.clear(),e.document||e.reg.clear())};function lS(e,t,n){let r=e.value,i,a=0;for(let e=0,o;e<r.length;e++){if(o=n?r:r[e]){for(let n=0,a,s;n<t.length;n++)if(s=t[n],a=o.indexOf(s),a>=0){if(i=1,o.length>1)o.splice(a,1);else{r[e]=[];break}}a+=o.length}if(n)break}a?i&&e.update(r):e.delete(),e.continue()}Xb.remove=function(e){return typeof e!=`object`&&(e=[e]),Promise.all([this.transaction(`map`,`readwrite`,function(t){t.openCursor().onsuccess=function(){let t=this.result;t&&lS(t,e)}}),this.transaction(`ctx`,`readwrite`,function(t){t.openCursor().onsuccess=function(){let t=this.result;t&&lS(t,e)}}),this.transaction(`tag`,`readwrite`,function(t){t.openCursor().onsuccess=function(){let t=this.result;t&&lS(t,e,!0)}}),this.transaction(`reg`,`readwrite`,function(t){for(let n=0;n<e.length;n++)t.delete(e[n])})])};function uS(e,t){return new Promise((n,r)=>{e.onsuccess=e.oncomplete=function(){t&&t(this.result),t=null,n(this.result)},e.onerror=e.onblocked=r,e=null})}var Tse={Index:rS,Charset:px,Encoder:ix,Document:Bx,Worker:Dx,Resolver:Fx,IndexedDB:cS,Language:{}};function dS(e,t,n,r){if(!t?.type)throw Error(`Schema not found for `+n);if(e!==null&&!H.isJson(e)){if(t.type===`string`){typeof e==`string`&&r({source:e,schema:t,path:n});return}if(t.type===`number`){typeof e==`number`&&r({source:e,schema:t,path:n});return}if(t.type===`boolean`){typeof e==`boolean`&&r({source:e,schema:t,path:n});return}if(t.type===`richtext`){r({source:e,schema:t,path:n});return}if(t.type===`file`||t.type===`image`){e&&typeof e==`object`&&`path`in e&&typeof e.path==`string`&&r({source:e,schema:t,path:n});return}if(t.type===`date`){typeof e==`string`&&r({source:e,schema:t,path:n});return}if(t.type===`dateTime`){typeof e==`string`&&r({source:e,schema:t,path:n});return}if(t.type===`color`){typeof e==`string`&&r({source:e,schema:t,path:n});return}if(t.type===`code`){typeof e==`string`&&r({source:e,schema:t,path:n});return}if(t.type===`keyOf`){(typeof e==`string`||typeof e==`number`)&&r({source:e,schema:t,path:n});return}if(t.type===`literal`){r({source:e,schema:t,path:n});return}if(t.type===`route`){typeof e==`string`&&r({source:e,schema:t,path:n});return}if(t.type===`array`){if(!Array.isArray(e))return;if(!t.item)throw Error(`Schema (`+t.type+`) item not found for `+n);for(let i=0;i<e.length;i++){let a=sb(n,i);dS(e[i],t.item,a,r)}return}if(t.type===`object`||t.type===`record`){if(typeof e!=`object`||!e||Array.isArray(e))return;for(let i in e){let a=t.type===`object`?t.items?.[i]:t.item;if(!a)continue;let o=sb(n,i);dS(e[i],a,o,r)}return}if(t.type===`union`){let i=t.key;if(typeof i==`string`){if(e&&typeof e==`object`&&!Array.isArray(e)&&i in e){let a=e[i];if(typeof a==`string`){let o=t.items.filter(e=>e.type===`object`).find(e=>{let t=e.items[i];return t?.type===`literal`&&t.value===a});o&&dS(e,o,n,r)}}}else typeof e==`string`&&r({source:e,schema:t,path:n});return}throw Error(`Unsupported schema type: `+JSON.stringify(t))}}function Ese(e){let t=``;function n(e){if(typeof e==`string`)t+=e;else if(e&&typeof e==`object`&&`children`in e&&Array.isArray(e.children))for(let t of e.children)n(t)}return n({children:e}),t}function fS(e){let t=H.remote.splitRemoteRef(e);return t.status===`success`?`/${t.filePath}`:e}function Dse(e){let t=fS(e);return t.split(`/`).pop()||t}function pS(e){let t=fS(e);return{cleanPath:t,filename:t.split(`/`).pop()||t,folder:t.replace(/^\/public(?=\/|$)/,``).replace(/\/[^/]+$/,``)||`/`}}function mS(){return{index:new Tse.Index({tokenize:`forward`}),pathToLabel:new Map,docsByModule:new Map}}function Ose(e,t,n,r){let{index:i,pathToLabel:a,docsByModule:o}=e;hS(e,t);let s=new Set;o.set(t,s),dS(n,r,t+`?p=`,({source:e,schema:t,path:n})=>{if(e===null)return;let r=``,o=``;if(t.type===`string`||t.type===`number`||t.type===`boolean`||t.type===`date`||t.type===`dateTime`||t.type===`color`||t.type===`code`||t.type===`keyOf`||t.type===`route`)r=e?.toString()??``,o=e?.toString()??``;else if(t.type===`literal`)r=t.value.toString(),o=t.value.toString();else if(t.type===`richtext`)r=Ese(e),o=r.substring(0,50)||`richtext`;else if((t.type===`file`||t.type===`image`)&&typeof e==`object`&&e&&`path`in e&&typeof e.path==`string`){let{filename:t,folder:n}=pS(e.path),i=`alt`in e?e.alt:``;r=t+` `+n+` `+i,o=t}if(r){let[,e]=H.splitModuleFilePathAndModulePath(n),t=Ase(e)+` `;i.add(n,t+` `+n+` `+r),a.set(n,o),s.add(n)}})}function hS(e,t){let{index:n,pathToLabel:r,docsByModule:i}=e,a=i.get(t);if(a!==void 0){for(let e of a)n.remove(e),r.delete(e);i.delete(t)}}var kse=new Set([`/`,`-`,`_`,`.`,`:`,`?`,`&`,`=`,`@`,`"`,`'`]);function Ase(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];kse.has(r)?t+=` `:t+=r}return t}function jse(e,t,n=50,r=0){if(e===null||!t.trim())return{results:[],total:0};let{index:i,pathToLabel:a}=e,o=i.search(t,{limit:r+n}),s=o.length;return{results:o.slice(r,r+n).map(e=>({path:e,label:a.get(e)||e})),total:s}}var Mse=class{constructor(e=Rb){this.activity=e,this.events=new Lb,this.index=null,this.indexed=new Set,this.partial=new Set}async reindex(e){let t=Object.keys(e);this.index===null&&(this.index=mS());let n=[];for(let r of t){this.activity.work(`search:index-module`,r);let t=e[r];Ose(this.index,r,t.source,t.schema),this.indexed.has(r)||n.push(r),this.indexed.add(r),t.complete?this.partial.delete(r):this.partial.add(r)}let r={new:n,all:[...this.indexed]};return this.events.emit({type:`search:build-index`,...r}),r}async forget(e){this.index!==null&&hS(this.index,e),this.indexed.delete(e),this.partial.delete(e)}async buildIndex(e){return this.activity.work(`search:build-index`,void 0,Object.keys(e).length),this.index=mS(),this.indexed=new Set,this.partial.clear(),this.reindex(e)}async search(e,t,n){if(this.index===null)return{status:`no-index`};this.activity.work(`search:query`,e);let{results:r,total:i}=jse(this.index,e,t,n);return{status:`results`,results:r,total:i,partialModules:[...this.partial]}}},Nse=class{constructor(e=Rb){this.activity=e,this.events=new Lb,this.byModule=new Map,this.incomplete=new Map}async forget(e){this.byModule.delete(e),this.incomplete.delete(e)}async rescan(e){let t=Object.keys(e);for(let n of t){this.activity.work(`references:scan-module`,n);let t=e[n],r=new Map;gS(n,t.schema,t.source,r),this.byModule.set(n,r),t.complete?this.incomplete.delete(n):this.incomplete.set(n,Fse(t.schema))}return this.events.emit({type:`references:scan`,modules:t}),t}async find(e){this.activity.work(`references:query`,e.kind);let t=[];for(let n of this.byModule.values())for(let[r,i]of n)Pse(i,e)&&t.push(r);let n=[];for(let[t,r]of this.incomplete)r.has(e.kind)&&n.push(t);return n.length>0?{status:`partial`,refs:t,awaiting:n}:{status:`complete`,refs:t}}async at(e){let[t]=H.splitModuleFilePathAndModulePath(e);return this.byModule.get(t)?.get(e)??null}};function Pse(e,t){return!(e.kind!==t.kind||t.kind!==`route`&&e.target!==t.module||t.value!==void 0&&e.value!==t.value)}function Fse(e){let t=new Set,n=new Set,r=e=>{if(!(e===void 0||n.has(e)))switch(n.add(e),e.type){case`keyOf`:t.add(`keyOf`);return;case`image`:case`file`:t.add(`file`);return;case`route`:t.add(`route`);return;case`object`:for(let t of Object.values(e.items))r(t);return;case`array`:case`record`:r(e.item);return;case`union`:for(let t of e.items)r(t);return;default:return}};return e?.type===`record`?r(e.item):r(e),t}function gS(e,t,n,r){if(t!==void 0&&!H.isJson(n))switch(t.type){case`keyOf`:r.set(e,{kind:`keyOf`,target:t.path,value:typeof n==`string`?n:null});return;case`image`:case`file`:if(t.referencedModule===void 0)return;r.set(e,{kind:`file`,target:t.referencedModule,value:Ise(n)});return;case`route`:r.set(e,{kind:`route`,target:null,value:typeof n==`string`?n:null});return;case`object`:if(!_S(n))return;for(let i in t.items){let a=n[i];a!==void 0&&gS(sb(e,i),t.items[i],a,r)}return;case`record`:if(!_S(n))return;for(let i in n)gS(sb(e,i),t.item,n[i],r);return;case`array`:if(!Array.isArray(n))return;for(let i=0;i<n.length;i++)gS(sb(e,i),t.item,n[i],r);return;case`union`:for(let i of t.items)gS(e,i,n,r);return;default:return}}function Ise(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.path;return typeof t==`string`?t:null}function _S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var vS=class{constructor(e){this.invalidateEvent=e,this.events=new Lb,this.stale=new Set,this.covered=new Set}mark(e){let t=e.filter(e=>!this.stale.has(e));for(let t of e)this.stale.add(t);t.length>0&&this.events.emit({type:this.invalidateEvent,modules:t})}needsPass(){return this.covered.size===0||this.stale.size>0}target(e){return this.covered.size===0?e:[...this.stale]}covers(e){for(let t of e)this.covered.add(t),this.stale.delete(t)}forget(e){this.stale.delete(e),this.covered.delete(e)}coveredModules(){return[...this.covered]}staleModules(){return[...this.stale]}},Lse=300;function Rse(e,t,n){let r=[];for(let i of e){if(!t.has(i)||n.has(i))break;r.push(i)}return r}var zse=5e3,Bse=class{constructor(){this.validator=new Ib}async validate(e,t,n,r){return this.validator.validate(e,t,n,r)}};function Vse(e){let t=e.activity??Rb,n=new Doe(t),r=new Boe(e.fetchPatches,e.createPatchId,t,e.uploadFile),i=new Moe(n,t,e.fetchJsonEntry),a=new Voe,o=new Hoe(t),s=new Goe(r,e.savePatches,e.resyncChain??(async()=>{}),t,e.sessionId,e.saveBackoffMs,e.saveSleep);r.setParentRefSource(()=>s.currentParentRef());let c=new Koe(n,i,t),l=e.hostBridge??c,u=new Yoe(l,i,n,t),d=new ese(n,i,e.schemaValidation??new Bse,l,t),f=e.workerRealm?.search??new Mse(t),p=e.workerRealm?.patchSets??new Zoe(t),m=e.workerRealm?.references??new Nse(t),h=new vS(`search:invalidate`),g=new vS(`references:invalidate`),_=new Qoe,v=!1,y=!1,b=e.mode??`fs`,x=null;r.setPublishInFlight(()=>v);let S=new Map;async function C(t){let n=[];for(let{patchId:e,message:a}of t){let t=r.recordsFor([e])[0],o=t?.moduleFilePath,s=o!==void 0&&i.hasUnloadedEntries(o),c=(S.get(e)??0)+1;if(S.set(e,c),console.error(s?`Val: a patch could not be applied, and this module still has unloaded .jsonValues() entries — so it may apply once they arrive. Keeping it. If the edit never appears, please report this.`:`Val: discarding a patch that cannot be applied. If you see this often, please report it — it means a patch is being generated that does not fit the source it targets.`,{patchId:e,reason:a,module:o??`(record already gone)`,ops:t?.patch?.map(e=>({op:e.op,path:`path`in e?e.path:void 0})),origin:r.originOf(e),savedOnServer:!r.isPending(e),attempt:c}),!s){if(c>3){console.error(`Val: giving up on deleting an unapplicable patch — it keeps coming back. It is out of this session's chain so it cannot block saving, but it is still on the server.`,{patchId:e,attempts:c}),r.drop([e]);continue}n.push(e)}}if(n.length===0)return;if(r.drop(n),o.reportError(n.length===1?`An edit could not be applied and has been discarded.`:`${n.length} edits could not be applied and have been discarded.`,`This usually means a patch was generated that does not fit the content it targets. The browser console has the failing operation.`),e.discardPatches===void 0){console.error(`Val: cannot delete the patch on the server — this system has no discard seam. It will return on the next reload.`,{patchIds:n});return}let a=await e.discardPatches(n);a.status===`error`&&console.error(`Val: could not delete an unapplicable patch on the server.`,{patchIds:n,error:a.message})}let w=e.deferPendingValidation??(e=>{let t=setTimeout(e,Lse);return()=>clearTimeout(t)}),T=null;function E(){T===null&&(T=w(()=>{T=null;let e=new Set;for(let t of r.allRecords())e.add(t.moduleFilePath);for(let t of e)d.validate(t)}))}let D=[r.listenTo(a,i),i.listenTo(r),s.listenTo(),a.events.on(`patch:removed-by-server`,e=>{o.reportError(e.removed.length===1?`An unpublished change was removed because the server could not read it.`:`${e.removed.length} unpublished changes were removed because the server could not read them.`,`They are gone and the fields are back to their published values. The server log and .val/patches/patches.repair.log say which, and why.`),console.error(`Val: the server removed these unpublished changes.`,e.removed)}),r.events.on(`patch:fetch-failed`,e=>{o.reportError(`Unpublished changes could not be loaded.`,`${e.patches.length} ${e.patches.length===1?`change is`:`changes are`} affected: ${e.message} Until this succeeds, the editor shows published content for the fields they touch.`)}),r.events.on(`patch:announced-not-delivered`,e=>{o.reportError(e.patches.length===1?`An unpublished change could not be loaded.`:`${e.patches.length} unpublished changes could not be loaded.`,`The server listed them but did not send them, so they are not shown. Reload before editing: anything you change now is written on top of content that is missing them.`),console.error(`Val: the server announced these unpublished changes and did not send them.`,{patchIds:e.patches})}),s.events.on(`patch:save-rejected`,e=>{o.reportError(e.patches.length===1?`An edit could not be saved and has been reverted.`:`${e.patches.length} edits could not be saved and have been reverted.`,e.errors?Object.entries(e.errors).map(([e,t])=>`${e}: ${t.join(`, `)}`).join(`
|
|
131
131
|
`):e.message)}),s.events.on(`patch:save-stuck`,e=>{let t=Eoe(e.reason,e.message,e.attempt,e.patches.length);o.reportError(t.title,t.detail)}),a.events.on(`stat:receive`,e=>{let t=a.currentBaseSha();t!==null&&(s.receiveStat(t,e.patches),s.flush())}),u.listenTo(),d.listenTo(),r.events.on(`patch:chain`,()=>{E()}),i.events.on(`source:patch-apply`,e=>{e.failed.length!==0&&C(e.failed)}),i.events.on(`source:patch-apply`,e=>{h.mark(e.modules),g.mark(e.modules)}),i.events.on(`source:init`,e=>{h.mark(e.sources),g.mark(e.sources)}),n.events.on(`schema:init`,()=>{_.invalidate()}),r.events.on(`patch:drop`,()=>{_.invalidate()}),r.events.on(`patch:drop`,e=>{s.forget(e.patches)})];function O(e,r){if(e.mode===`current`)return{mode:`current`};let i=new Set(e.patchIds),a=r.filter(e=>i.has(e.patchId)),o=n.all(),s={};for(let e of a){let t=o[e.moduleFilePath];t!==void 0&&(s[e.moduleFilePath]=t)}return t.work(`patch-set:gather`,void 0,a.length),{mode:e.mode,records:a,schemas:s}}function k(e){let r=n.all(),a={};t.work(`search:gather-snapshot`,void 0,e.length);for(let t of e){let e=r[t],n=i.moduleSource(t);e!==void 0&&n!==void 0&&(a[t]={source:n,schema:e,complete:!i.hasUnloadedEntries(t)})}return a}async function A(){if(!g.needsPass())return;let e=g.target(i.loadedModules()),t=await m.rescan(j(e));g.covers(t)}function j(e){let t=n.all(),r={};for(let n of e){let e=t[n],a=i.moduleSource(n);e!==void 0&&a!==void 0&&(r[n]={source:a,schema:e,complete:!i.hasUnloadedEntries(n)})}return r}return{host:c,stat:a,status:o,schemaStore:n,sourceStore:i,patchStore:r,patchSync:s,previewStore:u,validationStore:d,searchStore:f,patchSetStore:p,referenceStore:m,async findReferences(e){return await A(),m.find(e)},async referenceAt(e){return await A(),m.at(e)},async getPatchSets(){if(x!==null)return x;let e=(async()=>{let e=r.allRecords(),t=_.plan(e.map(e=>e.patchId)),n=O(t,e),i=await p.getPatchSets(n);return _.covers(t),i})().finally(()=>{x=null});return x=e,e},async search(e,t,n){if(h.needsPass()){let e=h.target(i.loadedModules()),t=await f.reindex(k(e));h.covers(t.all)}let r=await f.search(e,t,n);return r.status===`no-index`?r:{...r,staleModules:h.staleModules()}},async buildSearchIndex(){let e=i.loadedModules(),t=await f.buildIndex(k(e));return h.covers(t.all),t},async validateEverything(){if(!y){y=!0,d.events.emit({type:`validation:full-pass`,running:!0});try{for(let e of i.loadedModules())await d.validate(e)}finally{y=!1,d.events.emit({type:`validation:full-pass`,running:!1})}}},async publish(t,a,c){let l=c?.exact===!0;if(e.publishPatches===void 0)return{status:`failed`,message:`This system has no publish seam configured.`,retryable:!1};if(v)return{status:`refused`,reason:`already-publishing`};v=!0;try{!l&&e.savePatches!==void 0&&r.unsavedRecords().length>0&&s.currentState().status!==`retrying`&&await Promise.race([s.flush().catch(()=>void 0),new Promise(t=>{let n=setTimeout(t,e.saveFlushTimeoutMs??zse);typeof n==`object`&&`unref`in n&&n.unref()})]);let c=e.savePatches===void 0||l?[]:r.unsavedRecords();if(c.length>0)return{status:`refused`,reason:`unsaved-changes`,patchIds:c.map(e=>e.patchId)};let u=r.allRecords().map(e=>e.patchId),f=l?Rse(u,new Set(t),new Set(r.unsavedRecords().map(e=>e.patchId))):u;if(f.length===0)return{status:`nothing-to-publish`};let p=new Set;for(let e of r.recordsFor(f))p.add(e.moduleFilePath);let m=r.chainVersion(),h=[];for(let e of p){let t=await d.validate(e);if(t.status!==`validated`||t.errors===!1)continue;let r=Up(t.errors,n.all(),i.allSources());Object.keys(r).length>0&&h.push(e)}if(h.length>0)return{status:`refused`,reason:`validation-errors`,modules:h};if(!l&&r.chainVersion()!==m)return{status:`refused`,reason:`chain-moved`};let g=await e.publishPatches({patchIds:f,message:a});if(g.status===`patch-errors`)return r.recordPublishErrors(g.errors),{status:`failed`,message:g.message,patchErrors:g.errors,retryable:!1};if(g.status!==`published`)return{status:`failed`,message:g.message,retryable:g.status===`not-fast-forward`||g.status===`network-error`};let _=g.removed??[];return _.length>0&&(r.drop(_.map(e=>e.patchId)),o.reportError(_.length===1?`An edit could not be applied and was removed.`:`${_.length} edits could not be applied and were removed.`,_.map(e=>`${e.moduleFilePath}: ${e.message}`).join(`
|
|
132
|
-
`)),console.error(`Val: the save removed these changes because they could not be applied.`,_)),r.markPublished(f),b===`fs`&&(i.promotePublished(f,[...p]),r.forgetPublished(f)),{status:`published`,patchIds:f,..._.length>0?{removed:_}:{}}}finally{v=!1}},async discard(t){if(e.discardPatches===void 0)return{status:`failed`,message:`This system has no discard seam configured.`};let n=await e.discardPatches(t);return n.status===`error`?{status:`failed`,message:n.message}:(r.drop(n.patchIds),{status:`discarded`})},patchErrors(){return r.publishErrors()},setMode(e){b=e},dispose(){for(let e of D)e();T!==null&&(T(),T=null),s.dispose()}}}function Hse(){let e=null,t=!1,n=0,r=new Map,i=null;function a(){if(e!==null||t)return e;try{e=new Worker(new URL(`/api/val/static/assets/validation.worker-S1NGke8f.js`,``+import.meta.url),{type:`module`}),e.onmessage=e=>{let t=e.data,n=r.get(t.id);n!==void 0&&(r.delete(t.id),t.type===`result`?n.resolve(t.errors):n.reject(Error(t.error)))},e.onerror=n=>{let i=Error(`Validation worker failed: ${n.message??`unknown error`}`);for(let e of r.values())e.reject(i);r.clear(),e?.terminate(),e=null,t=!0}}catch(n){console.warn(`Val: could not create the validation worker; validating on the main thread instead.`,n),t=!0,e=null}return e}return{async validate(e,t,o,s){let c=a();if(c===null)return i??=new Ib,i.validate(e,t,o,s);let l=`val-${++n}`,u=new Promise((e,t)=>{r.set(l,{resolve:e,reject:t})}),d={type:`validate`,id:l,moduleFilePath:e,source:t,serializedSchema:o,schemaSha:s};c.postMessage(d);try{return await u}catch(n){return console.warn(`Val: validation worker could not validate '${e}'; validating on the main thread instead.`,n),i??=new Ib,i.validate(e,t,o,s)}}}}var Use=1500,Wse=36;function Gse(e){return`&${e}=`.length+Wse}function Kse(e){return Math.max(1,Math.floor(Use/Gse(e)))}function yS(e,t){if(e.length===0)return[];let n=Kse(t),r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}function qse(e,t){let n=null,r=Vse({schemaValidation:t?.schemaValidation??Hse(),...t?.uploadSettings===void 0?{}:{uploadFile:async({patchId:e,parentRef:n,filePath:r,data:i,type:a,remote:o,metadata:s,onProgress:c})=>{let l=await t.uploadSettings();if(l.status===`error`)return{status:`error`,message:`Could not find where to upload files: ${l.error}`};let u=r;if(o){let e=H.remote.splitRemoteRef(r);if(e.status===`error`)return{status:`error`,message:`Could not read the file path out of a remote ref (${e.error}). This is most likely a Val bug.`};u=`/`+e.filePath}let d=JSON.stringify({filePath:u,parentRef:n??{type:`head`,headBaseSha:``},data:i,type:a,metadata:s,remote:o});return new Promise(t=>{let n=new XMLHttpRequest;c!==void 0&&n.upload.addEventListener(`progress`,e=>{e.lengthComputable&&c(e.loaded,e.total)}),n.addEventListener(`load`,()=>{if(n.status>=200&&n.status<300){t({status:`ok`});return}t({status:`error`,message:`Could not upload ${u}: HTTP ${n.status} ${n.statusText}`})}),n.addEventListener(`error`,()=>{t({status:`error`,message:`Could not upload ${u} (network error?)`})}),n.responseType=`text`,n.open(`POST`,`${l.data.baseUrl}/patches/${e}/files`),n.setRequestHeader(`Content-Type`,`application/json`),l.data.nonce!==null&&n.setRequestHeader(`x-val-auth-nonce`,l.data.nonce),n.send(d)})}},fetchPatches:async t=>{let n=[],r={},i,a=0,o=0;for(let s of yS(t,`patch_id`)){a++;let t=await e(`/patches`,`GET`,{query:{exclude_patch_ops:!1,patch_id:s}});if(t.status!==200){let e=`message`in t.json?t.json.message:`GET /patches failed with status ${t.status??`network`}`;for(let t of s)r[t]=e;i=e,o++;continue}for(let e of t.json.patches){if(e.patch===void 0){r[e.patchId]=`No ops for patch ${e.patchId}`;continue}n.push({patchId:e.patchId,moduleFilePath:e.path,patch:e.patch,createdAt:e.createdAt,authorId:e.authorId??void 0,appliedAt:e.appliedAt??null})}}return{patches:n,errors:r,...a>0&&o===a?{error:i}:{}}},fetchJsonEntry:async(t,n)=>{let r=await e(`/json`,`GET`,{query:{path:t,key:void 0,keys:[n],offset:void 0,limit:void 0,apply_patches:!1}});if(r.status!==200||!(`entries`in r.json))return{status:`error`,message:r.status!==200&&`message`in r.json?r.json.message:`GET /json failed with status ${r.status??`network`}`};let i=r.json.entries.find(e=>e.key===n);if(i===void 0){let e=r.json.errors.find(e=>e.key===n);return e===void 0?{status:`error`,message:`Entry not found: ${n} in ${t}`}:{status:`error`,message:e.message}}return{status:`ok`,content:i.content??null}},mode:t?.mode,publishPatches:async({patchIds:t,message:n})=>{let r=await e(`/save`,`POST`,{body:{message:n,patchIds:t}});if(r.status===null)return{status:`network-error`,message:`message`in r.json?r.json.message:`Network error`};if(r.status===200)return{status:`published`,removed:r.json.removed};if(r.status===409)return{status:`not-fast-forward`,message:r.json.message};if(r.status===400){let e={},t=`details`in r.json?r.json.details:void 0;if(Array.isArray(t))for(let n of t)typeof n==`object`&&n&&`patchId`in n&&`message`in n&&(e[n.patchId]=String(n.message));else if(typeof t==`object`&&t&&`unappliablePatches`in t&&t.unappliablePatches!==void 0)for(let[n,r]of Object.entries(t.unappliablePatches))e[n]=r.message;return{status:`patch-errors`,message:r.json.message,errors:e}}return{status:`error`,message:`message`in r.json?r.json.message:`POST /save failed with status ${r.status}`}},discardPatches:async t=>{let n=[];for(let r of yS(t,`id`)){let t=await e(`/patches`,`DELETE`,{query:{id:r}});if(t.status!==200)return{status:`error`,message:t.status!==null&&`message`in t.json?t.json.message:`DELETE /patches failed with status ${t.status??`network`}`};n.push(...t.json)}return{status:`discarded`,patchIds:n}},...t?.writes===!0?{savePatches:async({patches:t,parentRef:n,sessionId:r})=>{let i=await e(`/patches`,`PUT`,{body:{patches:t,parentRef:n,sessionId:r}});if(i.status===null){let e=`message`in i.json?i.json.message:`Network error`;return{status:`type`in i.json&&i.json.type===`client_side_validation_error`?`unparseable-response`:`network-error`,message:e}}return i.status===409?{status:`conflict`,message:i.json.message}:i.status===400?{status:`rejected`,message:i.json.message,errors:Object.fromEntries(Object.entries(i.json.errors??{}).map(([e,t])=>[e,t.map(e=>e.error.message)]))}:i.status===200?{status:`saved`,newPatchIds:i.json.newPatchIds,parentRef:i.json.parentRef}:{status:`unauthorized`,message:`message`in i.json?i.json.message:`PUT /patches failed with status ${i.status}`}}}:{},...t?.writes?{resyncChain:async()=>{let t=await e(`/stat`,`POST`,{body:null});t.status===200&&n?.stat.receiveStat({baseSha:t.json.baseSha,patches:t.json.patches})}}:{}});return n=r,r}var bS=b.createContext(new Proxy({},{get:()=>{throw Error(`Cannot use ValRemoteContext outside of ValRemoteProvider`)}}));function Jse({children:e,remoteFiles:t}){return(0,Y.jsx)(bS.Provider,{value:{remoteFiles:t},children:e})}function xS(){let{remoteFiles:e}=(0,b.useContext)(bS);return e}function SS(){let{remoteFiles:e}=(0,b.useContext)(bS),[t,n]=(0,b.useState)(null);function r(e){return Math.floor(Math.random()*e)}return(0,b.useEffect)(()=>{e.status===`ready`&&e.buckets.length>0&&t===null&&n(e.buckets[r(e.buckets.length)])},[e,t]),t}var CS=(0,b.createContext)({isAIChatEnabled:!1,canMentionField:!1,openAIChat:()=>{},setOpenAIChatImpl:()=>{},chatEditorRef:{current:null},insertFieldRef:()=>{},flushPendingFieldRefs:()=>{}});function Yse({isAIChatEnabled:e,isAIChatOnline:t,children:n}){let r=(0,b.useRef)(null),i=(0,b.useRef)(null),[a,o]=(0,b.useState)(!1),s=(0,b.useRef)([]),c=(0,b.useCallback)(()=>{r.current?.()},[]),l=(0,b.useCallback)(e=>{r.current=e,o(e!==null)},[]),u=(0,b.useCallback)(e=>{c();let t=i.current;if(t===null){s.current.push(e);return}t.insertFieldRef(e)},[c]),d=(0,b.useCallback)(()=>{let e=i.current;if(e===null||s.current.length===0)return;let t=s.current;s.current=[];for(let n of t)e.insertFieldRef(n)},[]),f=(0,b.useMemo)(()=>({isAIChatEnabled:e,canMentionField:e&&t&&a,openAIChat:c,setOpenAIChatImpl:l,chatEditorRef:i,insertFieldRef:u,flushPendingFieldRefs:d}),[e,t,a,c,l,u,d]);return(0,Y.jsx)(CS.Provider,{value:f,children:n})}function wS(){return(0,b.useContext)(CS)}function TS(){return wS().insertFieldRef}var ES=`val:ai:model`;function Xse(){try{let e=localStorage.getItem(ES);if(!e)return null;let t=OS.safeParse(JSON.parse(e));return t.success?{provider:t.data.provider,model:t.data.model}:null}catch{return null}}function Zse(e){try{localStorage.setItem(ES,JSON.stringify(e))}catch{}}function Qse(e,t){if(e.length===0)return t;let n=Xse();return n&&e.find(e=>e.provider===n.provider&&e.model===n.model)||((t&&e.find(e=>e.provider===t.provider&&e.model===t.model))??e[0])}var DS=Ou([`openai`,`anthropic`]),OS=q({provider:DS,model:W().min(1)}),kS=[{ref:{provider:`openai`,model:`gpt-5.1`},label:`GPT-5.1`},{ref:{provider:`anthropic`,model:`claude-sonnet-5`},label:`Claude Sonnet 5`},{ref:{provider:`anthropic`,model:`claude-opus-5`},label:`Claude Opus 5`},{ref:{provider:`anthropic`,model:`claude-haiku-4-5`},label:`Claude Haiku 4.5`}];function $se(e){if(e===void 0)return kS[0].ref;let t=new Set(e);return kS.find(e=>t.has(e.ref.provider))?.ref??null}function ece(e){return e?e.flatMap(e=>{let t=DS.safeParse(e.provider);return t.success?[{ref:{provider:t.data,model:e.model},label:e.label||e.model}]:[]}):[]}function tce(e,t){if(e===void 0){let e=t?kS.find(e=>e.ref.provider===t.provider&&e.ref.model===t.model):void 0;return e?[e]:[]}return kS.filter(t=>e.includes(t.ref.provider))}var AS=q({name:W(),description:W(),parameters:q({type:J(`object`),properties:Eu(W(),pu()),required:K(W()).optional()}),timeoutMs:yu([iu().nonnegative(),lu()]).optional()}),nce=q({id:W(),systemPrompt:W(),model:OS,tools:K(AS).optional(),description:W().optional()}),rce=q({type:J(`ai_tool_call`),id:W(),toolCallId:W(),name:W(),arguments:pu()}),ice=Ou([`max_iterations_reached`,`token_limit_reached`,`authentication_required`,`session_not_found`,`internal_error`,`byok_invalid_key`,`provider_not_configured`,`model_refusal`]),ace=q({type:J(`setup_byok`),label:W(),url:W()}),oce=q({type:J(`ai_error`),id:W(),code:ice.catch(`internal_error`),message:W(),resetDate:W().optional(),action:ace.optional(),details:W().optional()}),sce=bu(`type`,[q({type:J(`ai_response`),id:W(),sessionId:W(),response:W(),metadata:q({model:W().optional(),tokensUsed:iu().optional()}).optional()}),q({type:J(`ai_streaming`),id:W(),chunk:W()}),rce,oce,q({type:J(`ai_cancelled`),id:W(),sessionId:W().optional(),partialResponse:W().optional()}),q({type:J(`ai_session_unhidden`),id:W(),sessionId:W()}),q({type:J(`ai_agent_handoff`),id:W(),sessionId:W(),fromAgent:W(),toAgent:W(),reason:W().optional()})]),cce=yu([q({type:J(`text`),text:W()}),q({type:J(`image_key`),key:W()})]);q({type:J(`ai_prompt`),id:W(),sessionId:Bl().optional(),message:yu([W(),K(cce)]),context:W().optional(),maxIterations:iu().int().min(1).max(200).optional(),hidden:G().optional(),agents:K(nce).min(1)}),q({type:J(`ai_tool_result`),toolCallId:W(),result:pu(),isError:G().optional()}),q({type:J(`ai_get_sessions`),id:W(),limit:iu().int().min(1).max(100).optional(),cursor:q({updatedAt:W(),id:W().uuid()}).optional()}),q({type:J(`ai_set_session_name`),id:W(),sessionId:W().uuid(),name:W()}),q({type:J(`ai_get_sessions_with_messages`),id:W(),limit:iu().int().min(1).max(100).optional(),cursor:q({updatedAt:W(),id:W().uuid()}).optional()}),q({type:J(`ai_cancel`),id:W()}),q({type:J(`ai_unhide_session`),id:W(),sessionId:W()});var lce=3e3,uce=5;function dce(e,t){let n=(0,b.useRef)(null),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)([]),[d,f]=(0,b.useState)(null),p=(0,b.useCallback)(e=>{f(e),Zse(e)},[]),[m,h]=(0,b.useState)(null),g=(0,b.useRef)(new Set),_=(0,b.useRef)(null),v=(0,b.useRef)(0),y=(0,b.useRef)(e);y.current=e;let x=(0,b.useRef)(t);x.current=t;let S=(0,b.useCallback)(e=>{if(v.current>=uce){console.warn(`Giving up on the AI connection:`,e),h(e);return}T.current()},[]),C=(0,b.useCallback)(async()=>{if(y.current){v.current+=1;try{let e=await x.current(`/ai/initialize`,`POST`,{});if(e.status===401){o(!0);return}if(e.status!==200){S(typeof e.json.message==`string`?e.json.message:`The assistant could not be started (${e.status})`);return}o(!1);let t=$se(e.json.providers);c(t);let r=ece(e.json.models),a=r.length>0?r:tce(e.json.providers,t);u(a),f(Qse(a.map(e=>e.ref),t));let s=new WebSocket(e.json.wsUrl+`?nonce=`+encodeURIComponent(e.json.nonce));s.onopen=()=>{v.current=0,h(null),i(!0)},s.onmessage=e=>{try{let t=JSON.parse(e.data),n=sce.safeParse(t);if(!n.success){console.error(`Could not parse AI WebSocket message`,n.error,`Original message:`,t);return}for(let e of g.current)e(n.data)}catch(e){console.error(`Error processing AI WebSocket message`,e)}},s.onclose=()=>{i(!1),n.current===s&&(n.current=null,S(`Lost the connection to the assistant`))},s.onerror=()=>{console.warn(`AI WebSocket error`),s.close()},n.current=s}catch(e){S(e instanceof Error?e.message:`Could not reach the assistant`)}}},[S]),w=(0,b.useCallback)(()=>{_.current||=setTimeout(()=>{_.current=null,y.current&&C()},lce)},[C]),T=(0,b.useRef)(w);T.current=w;let E=(0,b.useCallback)(()=>{_.current&&=(clearTimeout(_.current),null),v.current=0,h(null),o(!1),C()},[C]);return(0,b.useEffect)(()=>(e&&C(),()=>{_.current&&=(clearTimeout(_.current),null),n.current&&=(n.current.close(),null)}),[e,C]),{subscribeToMessages:(0,b.useCallback)(e=>(g.current.add(e),()=>{g.current.delete(e)}),[]),send:(0,b.useCallback)(e=>n.current?.readyState===WebSocket.OPEN?(n.current.send(JSON.stringify(e)),!0):(console.warn(`AI WebSocket not open, cannot send`),!1),[]),isConnected:r,authError:a,connectionError:m,retryConnection:E,availableModel:s,availableModels:l,selectedModel:d,selectModel:p}}q({type:J(`ai_prompt`),id:W(),sessionId:W().uuid().optional(),message:W(),context:W().optional(),maxIterations:iu().int().min(1).max(200).optional(),agents:K(q({id:W(),systemPrompt:W(),model:W(),tools:K(AS).optional(),description:W().optional()})).min(1)});var jS=class extends Error{constructor(e,t){super(e),this.name=`SessionImageToPatchError`,this.availableKeys=t}},MS=new Proxy({},{get:()=>{throw Error(`Cannot use ValContext outside of ValProvider`)}}),NS=b.createContext(MS);function PS({children:e,client:t,config:n,valModules:r,dispatchValEvents:i,theme:a,setTheme:o}){let[s,c,l,u,d,f]=see(t),p=`data`in s&&!!s.data&&(`data`in s&&s.data?s.data.config?.ai?.chat?.experimental?.enable===!0||s.data.config?.ai?.commitMessages?.disabled!==!0:!1),{subscribeToMessages:m,send:h,isConnected:g,authError:_,connectionError:v,retryConnection:y,availableModel:x,availableModels:S,selectedModel:C,selectModel:w}=dce(p,t),T=(0,b.useCallback)(async e=>{let n=await t(`/ai/sessions`,`GET`,{query:{limit:e?.limit===void 0?void 0:String(e.limit),cursor_updatedAt:e?.cursor?.updatedAt,cursor_id:e?.cursor?.id}});if(n.status===200)return n.json;throw Error(`ai/sessions failed: ${n.status??`network`}: ${n.json.message}`)},[t]),E=(0,b.useCallback)(async(e,n)=>{let r=await t(`/ai/messages`,`GET`,{path:`/${encodeURIComponent(e)}/messages`,query:{limit:n?.limit===void 0?void 0:String(n.limit),cursor_updatedAt:n?.cursor?.updatedAt,cursor_id:n?.cursor?.id}});if(r.status===200)return r.json;throw Error(`ai/sessions/messages failed: ${r.status??`network`}: ${r.json.message}`)},[t]),D=(0,b.useCallback)(async(e,n)=>{let r=await t(`/ai/sessions`,`PATCH`,{path:`/${encodeURIComponent(e)}`,body:{name:n}});if(r.status!==200)throw Error(`ai/sessions/rename failed: ${r.status??`network`}: ${r.json.message}`)},[t]),O=(0,b.useCallback)(async e=>{let n=await t(`/ai/session-image-to-patch-file`,`POST`,{body:e});if(n.status===200)return n.json;throw n.status===400?new jS(`ai/session-image-to-patch-file failed: 400: ${n.json.message}`,n.json.details?.availableKeys):new jS(`ai/session-image-to-patch-file failed: ${n.status??`network`}: ${n.json.message}`)},[t]),k=`data`in s&&s.data?s.data.config:void 0,[A,j]=(0,b.useState)();(0,b.useEffect)(()=>{if(A===void 0||A===!0){if(f){let e=setTimeout(()=>{j(f)},2e3);return()=>{clearTimeout(e)}}f||j(!1)}},[f,A]);let M=`data`in s&&s.data?s.data.baseSha:void 0,N=`data`in s&&s.data?s.data.patches:void 0,P=`data`in s&&s.data?s.data.mode:void 0,F=`data`in s&&s.data?s.data.removed:void 0,I=(0,b.useMemo)(()=>M!==void 0&&N!==void 0?{baseSha:M,patches:N,removed:F}:null,[M,N,F]),L=(0,b.useCallback)(async()=>{let e=await t(`/direct-file-upload-settings`,`POST`,{}),n=0;for(;e.status===null&&n<5;)console.warn(`Failed to get direct file upload settings, retrying...`,e),await new Promise(e=>setTimeout(e,500*(n+1))),e=await t(`/direct-file-upload-settings`,`POST`,{}),n++;return e.status===200?{status:`success`,data:e.json}:{status:`error`,error:`Could not get direct file upload settings`}},[t]),R=(0,b.useMemo)(()=>qse(t,{writes:!0,uploadSettings:L}),[t,L]);(0,b.useEffect)(()=>{(P===`fs`||P===`http`)&&R.setMode(P)},[R,P]);let[ee,te]=(0,b.useState)([]),ne=(0,b.useRef)(new Set),re=`data`in s&&s.data?.deployments?s.data.deployments.map(e=>`${e.deploymentId}:${e.deploymentState}:${e.updatedAt}`).join(`,`):``,ie=`data`in s&&s.data?.commits?s.data.commits.map(e=>e.commitSha).join(`,`):``;(0,b.useEffect)(()=>{`data`in s&&s.data&&te(e=>s.data?.deployments&&s.data.deployments?.length>0||s.data?.commits&&s.data.commits?.length>0?dee(e,s.data?.commits||[],s.data?.deployments||[]).filter(e=>!ne.current.has(e.commitSha)):e)},[re,ie]);let ae=(0,b.useCallback)(e=>{te(t=>t.filter(t=>t.commitSha!==e)),ne.current.add(e)},[]),[oe,se]=(0,b.useState)(new Set);(0,b.useEffect)(()=>{`data`in s&&s.data?.commitSha&&se(e=>{if(s.data?.commitSha===void 0||e.has(s.data.commitSha))return e;let t=new Set(e);return t.add(s.data.commitSha),t})},[s]);let[ce,le]=(0,b.useState)({status:`not-asked`}),[ue,de]=(0,b.useState)(!1),fe=(0,b.useSyncExternalStore)((0,b.useCallback)(e=>R.schemaStore.events.on(`schema:init`,e),[R]),(0,b.useCallback)(()=>R.schemaStore.all(),[R]),(0,b.useCallback)(()=>R.schemaStore.all(),[R]));(0,b.useEffect)(()=>{if(fe){let e=fe,t=!1;for(let n of Object.values(e))try{if(ur(n)){t=!0;break}}catch(e){console.error(`Val: could not tell whether a schema needs remote files. Remote uploads may be unavailable.`,e)}de(t)}},[fe]),(0,b.useEffect)(()=>{let e=0;function n(){e++,ce.status!==`ready`&&e<10&&t(`/remote/settings`,`GET`,{}).then(e=>{e.status===200?le({status:`ready`,coreVersion:e.json.coreVersion,buckets:e.json.remoteFileBuckets.map(e=>e.bucket),publicProjectId:e.json.publicProjectId}):(`errorCode`in e.json&&e.json.errorCode?le({status:`inactive`,reason:e.json.errorCode,message:e.json.message}):le({status:`inactive`,reason:`unknown-error`,message:`An unknown error has occurred`}),setTimeout(n,5e3))}).catch(e=>{console.error(`Error getting remote settings`,e),le({status:`inactive`,reason:`unknown-error`,message:`An unknown error has occurred`}),setTimeout(n,5e3)})}ue&&(le({status:`loading`}),n())},[ue]);let[pe,me]=(0,b.useState)({type:`not-asked`}),he=(0,b.useSyncExternalStore)((0,b.useCallback)(e=>R.patchStore.events.on(`patch:chain`,e),[R]),(0,b.useCallback)(()=>R.patchStore.pendingPatchIds().length,[R]),(0,b.useCallback)(()=>R.patchStore.pendingPatchIds().length,[R]));(0,b.useEffect)(()=>{let e=e=>{he>0&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e)}},[he]);let{state:ge,retry:_e}=gce(t,l,`data`in s&&s.data?s.data.mode:`unknown`,f,k?.project);return(0,Y.jsx)(NS.Provider,{value:{client:t,publishSummaryState:pe,setPublishSummaryState:me,profileId:`data`in s&&s.data?s.data.profileId:null,mode:`data`in s&&s.data?s.data.mode:`unknown`,profileAuthError:ge.status===`auth-error`?ge.error:null,profilesError:ge.status===`error`?{message:ge.error,willRetry:ge.willRetry}:null,retryProfiles:_e,serviceUnavailable:A,baseSha:M,observedCommitShas:oe,deployments:ee,dismissDeployment:ae,authenticationState:l,config:k,profiles:`data`in ge&&ge.data?ge.data:{},remoteFiles:ce,subscribeToWsMessages:m,sendWsMessage:h,isWsConnected:g,aiAuthError:_,aiConnectionError:v,retryAiConnection:y,aiGetSessions:T,aiGetSessionMessages:E,aiSetSessionName:D,availableAiModel:x,availableAiModels:S,selectedAiModel:C,selectAiModel:w,aiSessionImagesToPatchFile:O},children:(0,Y.jsx)(qg,{children:(0,Y.jsx)(Yse,{isAIChatEnabled:p,isAIChatOnline:p&&g,children:a!==void 0&&o?(0,Y.jsx)(Uae,{theme:a,setTheme:o,config:k,children:(0,Y.jsx)(boe,{system:R,valModules:r??null,stat:I,children:(0,Y.jsx)(_oe,{children:(0,Y.jsx)(Mce,{children:(0,Y.jsx)(Wae,{children:(0,Y.jsx)(Jse,{remoteFiles:ce,children:(0,Y.jsxs)(Zae,{getDirectFileUploadSettings:L,config:k,children:[(0,Y.jsx)(Toe,{enabled:i}),(0,Y.jsx)(qae,{}),e,(0,Y.jsx)(fce,{})]})})})})})})}):e})})})}function fce(){return FS().schema===`out-of-date`?(0,Y.jsx)(Gae,{}):null}function FS(){let e=nb(),t=(0,b.useCallback)(t=>e===null?()=>{}:e.system.status.events.on(`status:change`,t),[e]),n=(0,b.useCallback)(()=>e===null?pce:e.system.status.current(),[e]);return(0,b.useSyncExternalStore)(t,n,n)}var pce={errors:[],networkErrorSince:null,schemaError:null,schema:`current`},mce=5,hce=1e3;function gce(e,t,n,r,i){let[a,o]=(0,b.useState)({status:`not-asked`}),s=(0,b.useRef)(0),c=(0,b.useRef)(null),l=(0,b.useCallback)(()=>{c.current!==null&&(clearTimeout(c.current),c.current=null)},[]);(0,b.useEffect)(()=>l,[l]);let u=(0,b.useRef)(()=>void 0),d=(0,b.useCallback)(async()=>{s.current+=1,o(e=>({status:`loading`,data:`data`in e?e.data:void 0}));let t=await e(`/profiles`,`GET`,{});if(t.status===200){let e={};for(let n of t.json.profiles)e[n.profileId]={fullName:n.fullName,email:n.email,avatar:n.avatar};s.current=0,o({status:`done`,data:e})}else if(n===`fs`&&t.status===401){let e=`message`in t.json&&typeof t.json.message==`string`?t.json.message:`Could not authenticate while getting profiles`;o(t=>({status:`auth-error`,error:e,data:`data`in t?t.data:void 0}))}else{let e=s.current<mce;if(e||console.error(`Could not get profiles`,t.json),o(n=>({status:`error`,error:ree(t.json),willRetry:e,data:`data`in n?n.data:void 0})),e){let e=hce*2**(s.current-1);c.current=setTimeout(()=>{c.current=null,u.current()},e)}}},[e,n]);u.current=()=>void d();let f=(0,b.useCallback)(()=>{l(),s.current=0,u.current()},[l]);return(0,b.useEffect)(()=>{t!==`not-asked`&&t!==`loading`&&(n===`fs`||t===`authorized`)&&(n===`fs`&&!i||r||a.status===`not-asked`&&d())},[t,d,n,a.status,r,i]),{state:a,retry:f}}function IS(){let{authenticationState:e}=(0,b.useContext)(NS);return e}function _ce(){let{serviceUnavailable:e}=(0,b.useContext)(NS);return e===!0?`service-unavailable`:`connected`}function LS(){let e=nb();return{addModuleFilePatch:(0,b.useCallback)((t,n,r)=>{if(e===null){console.error(`Val: cannot write patch: no store system is mounted`);return}e.system.patchStore.createPatch(t,n).then(e=>{e.status!==`created`&&console.error(`Val: could not write patch`,e.message)})},[e])}}function RS(){let e=nb();return{deletePatches:(0,b.useCallback)(t=>{if(e===null){console.error(`Val: cannot discard: no store system is mounted`);return}for(let n=0;n<t.length;n+=100){let r=t.slice(n,n+100);e.system.discard(r).then(e=>{e.status===`failed`&&console.error(`Val: could not discard patches`,e.message)})}},[e])}}function zS(){let{subscribeToWsMessages:e,sendWsMessage:t,isWsConnected:n,aiAuthError:r,aiGetSessions:i,aiGetSessionMessages:a,aiSetSessionName:o,aiSessionImagesToPatchFile:s}=(0,b.useContext)(NS);return{subscribeToWsMessages:e,sendWsMessage:t,isWsConnected:n,aiAuthError:r,aiGetSessions:i,aiGetSessionMessages:a,aiSetSessionName:o,aiSessionImagesToPatchFile:s}}function BS(){let{availableAiModel:e}=(0,b.useContext)(NS);return e}function VS(){let{availableAiModels:e,selectedAiModel:t,selectAiModel:n}=(0,b.useContext)(NS);return{models:e,selected:t,select:n}}function HS(){let{deployments:e,dismissDeployment:t,observedCommitShas:n}=(0,b.useContext)(NS);return{deployments:e,dismissDeployment:t,observedCommitShas:n}}function US(){let e=nb(),t=WS(),[n,r]=(0,b.useState)({status:`not-asked`}),i=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(e===null)return;let t=!1;return e.system.getPatchSets().then(e=>{if(t)return;let n=JSON.stringify(e);n!==i.current&&(i.current=n,r({status:`success`,data:e}))}).catch(e=>{t||r({status:`error`,error:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e,t]),n}function WS(){let e=nb(),t=(0,b.useCallback)(t=>e===null?()=>{}:e.system.patchStore.events.on(`patch:chain`,t),[e]),n=(0,b.useCallback)(()=>e===null?0:e.system.patchStore.chainVersion(),[e]);return(0,b.useSyncExternalStore)(t,n,n)}function vce(){let e=nb(),[t,n]=(0,b.useState)(0);return(0,b.useEffect)(()=>{if(e!==null)return e.system.patchStore.events.on(`patch:head`,()=>{n(e=>e+1)})},[e]),t}function GS(){let e=nb(),t=WS();return(0,b.useMemo)(()=>{let t=new Set;if(e===null)return t;let n=e.system.patchStore.publishedPatchIds();for(let r of e.system.patchStore.allRecords())(r.appliedAt||n.has(r.patchId))&&t.add(r.patchId);return t},[e,t])}function yce(){let e=nb(),t=WS();return(0,b.useMemo)(()=>{if(e===null)return[];let t=[],n=new Set;for(let r of e.system.patchStore.allRecords()){let e=r.appliedAt?.commitSha;e!==void 0&&!n.has(e)&&(n.add(e),t.unshift(e))}return t},[e,t])}function bce(e){let t=nb(),n=$S(),r=WS();return(0,b.useMemo)(()=>{let n=new Set;if(t===null)return n;let r=t.system.sourceStore;for(let t of e){let e=r.peek(t),i=r.peekBase(t);e.status===`ready`&&i.status===`ready`&&Mr(e.data,i.data)&&n.add(t)}return n},[t,n,r,e])}function KS(){let e=nb(),t=$S(),n=WS(),r=GS(),i=(0,b.useMemo)(()=>{if(e===null)return[];let t=new Set;for(let n of e.system.patchStore.allRecords())r.has(n.patchId)||t.add(n.moduleFilePath);return[...t]},[e,n,r]);return(0,b.useMemo)(()=>{if(e===null||i.length===0)return!0;let t=e.system.sourceStore;for(let e of i){let n=t.moduleSource(e),r=t.peekBase(H.joinModuleFilePathAndModulePath(e,``));if(n===void 0||r.status!==`ready`||!Mr(n,r.data))return!0}return!1},[e,t,n,i])}function qS(){let e=nb(),t=WS();return(0,b.useMemo)(()=>{if(e===null)return[];let t=e.system.patchStore;return t.allRecords().map(e=>e.patchId).filter(e=>!t.isPending(e))},[e,t])}function JS(){let e=nb(),t=WS();return(0,b.useMemo)(()=>e===null?[]:e.system.patchStore.pendingPatchIds(),[e,t])}function xce(){let e=nb(),t=(0,b.useCallback)(t=>{if(e===null)return()=>{};let n=e.system.patchStore.events.on(`patch:chain`,t),r=e.system.patchStore.events.on(`patch:head`,t);return()=>{n(),r()}},[e]),n=(0,b.useCallback)(()=>e!==null&&e.system.patchStore.chainSettled(),[e]),r=(0,b.useSyncExternalStore)(t,n,n),[i,a]=(0,b.useState)(!1),o=i||r;return(0,b.useEffect)(()=>{o&&a(!0)},[o]),o}function Sce(){let e=nb();return(0,b.useCallback)(()=>e===null?{total:0,settled:0,unfetched:[],unapplied:[],failed:[],statSeen:!1}:e.system.patchStore.chainProgress(),[e])}function Cce(){let e=nb(),[t,n]=(0,b.useState)(null);return(0,b.useEffect)(()=>{if(e!==null)return e.system.patchStore.events.on(`patch:fetch-failed`,e=>{n(e.message)})},[e]),t}function YS(){let e=nb(),t=WS();return(0,b.useMemo)(()=>e===null?[]:e.system.patchStore.allRecords().map(e=>e.patchId),[e,t])}var wce=[];function XS(e){let t=nb(),n=(0,b.useCallback)(e=>t===null?()=>{}:t.system.patchStore.events.on(`patch:chain`,e),[t]),r=(0,b.useCallback)(()=>t===null?null:t.system.patchStore.patchesByPath().get(e)??wce,[t,e]),i=(0,b.useSyncExternalStore)(n,r,r);return(0,b.useMemo)(()=>i===null?null:i.map(e=>ZS(e.record,e.isPending)),[i])}function Tce(e){let t=nb(),n=WS();return(0,b.useMemo)(()=>{if(t===null)return[];let n=t.system.patchStore;return n.allRecords().filter(t=>t.moduleFilePath===e).map(e=>ZS(e,n.isPending(e.patchId)))},[t,n,e])}function ZS(e,t){return{moduleFilePath:e.moduleFilePath,patch:e.patch,isPending:t,createdAt:e.createdAt??``,authorId:e.authorId??null,isCommitted:e.appliedAt??void 0}}function QS(){let{mode:e}=(0,b.useContext)(NS);return e}function Ece(){let e=nb(),t=(0,b.useCallback)(t=>e===null?()=>{}:e.system.host.events.on(`host:receive`,t),[e]),n=(0,b.useCallback)(()=>e===null?null:e.system.host.initializedAt(),[e]);return(0,b.useSyncExternalStore)(t,n,n)}function $S(){let e=nb(),t=(0,b.useCallback)(t=>e===null?()=>{}:e.system.sourceStore.events.on(`source:change`,t),[e]),n=(0,b.useCallback)(()=>e===null?0:e.system.sourceStore.sourcesVersion(),[e]);return(0,b.useSyncExternalStore)(t,n,n)}var Dce=yu([q({type:J(`not-asked`),isGenerating:G().optional()}),q({type:J(`manual`).or(J(`ai`)),text:W(),patchIds:K(W()).nullable(),isGenerating:G()})]);function eC(){let{publishSummaryState:e,setPublishSummaryState:t,config:n}=(0,b.useContext)(NS),r=nb(),i=YS(),{patchErrors:a}=oC(),o=(0,b.useMemo)(()=>a?Object.values(a).some(e=>Object.keys(e).length>0):!1,[a]);(0,b.useEffect)(()=>{if(e.type===`not-asked`){let e=kce(n?.project);e&&e.type!==`not-asked`&&i.length>0&&t(e)}},[e,n,t]);let[s,c]=(0,b.useState)(!1),l=(0,b.useCallback)(async e=>i===null?{status:`error`,message:`No changes to publish`}:s?{status:`error`,message:`Already publishing`}:r===null?{status:`error`,message:`No store system is mounted`}:(c(!0),(async()=>{let t=await r.system.publish(i,e);return t.status===`refused`&&t.reason===`chain-moved`?r.system.publish(i,e):t})().then(e=>{if(e.status===`published`)Ace(n?.project),t(e=>({type:`not-asked`,isGenerating:e.isGenerating}));else if(e.status===`refused`){let t=iee(e);r.system.status.reportError(t.message,t.details)}else e.status===`failed`&&r.system.status.reportError(`Could not publish`,e.patchErrors?Object.entries(e.patchErrors).map(([e,t])=>`${e}: ${t}`).join(`
|
|
132
|
+
`)),console.error(`Val: the save removed these changes because they could not be applied.`,_)),r.markPublished(f),b===`fs`&&(i.promotePublished(f,[...p]),r.forgetPublished(f)),{status:`published`,patchIds:f,..._.length>0?{removed:_}:{}}}finally{v=!1}},async discard(t){if(e.discardPatches===void 0)return{status:`failed`,message:`This system has no discard seam configured.`};let n=await e.discardPatches(t);return n.status===`error`?{status:`failed`,message:n.message}:(r.drop(n.patchIds),{status:`discarded`})},patchErrors(){return r.publishErrors()},setMode(e){b=e},dispose(){for(let e of D)e();T!==null&&(T(),T=null),s.dispose()}}}function Hse(){let e=null,t=!1,n=0,r=new Map,i=null;function a(){if(e!==null||t)return e;try{e=new Worker(new URL(`/api/val/static/assets/validation.worker-B5R1jZ19.js`,``+import.meta.url),{type:`module`}),e.onmessage=e=>{let t=e.data,n=r.get(t.id);n!==void 0&&(r.delete(t.id),t.type===`result`?n.resolve(t.errors):n.reject(Error(t.error)))},e.onerror=n=>{let i=Error(`Validation worker failed: ${n.message??`unknown error`}`);for(let e of r.values())e.reject(i);r.clear(),e?.terminate(),e=null,t=!0}}catch(n){console.warn(`Val: could not create the validation worker; validating on the main thread instead.`,n),t=!0,e=null}return e}return{async validate(e,t,o,s){let c=a();if(c===null)return i??=new Ib,i.validate(e,t,o,s);let l=`val-${++n}`,u=new Promise((e,t)=>{r.set(l,{resolve:e,reject:t})}),d={type:`validate`,id:l,moduleFilePath:e,source:t,serializedSchema:o,schemaSha:s};c.postMessage(d);try{return await u}catch(n){return console.warn(`Val: validation worker could not validate '${e}'; validating on the main thread instead.`,n),i??=new Ib,i.validate(e,t,o,s)}}}}var Use=1500,Wse=36;function Gse(e){return`&${e}=`.length+Wse}function Kse(e){return Math.max(1,Math.floor(Use/Gse(e)))}function yS(e,t){if(e.length===0)return[];let n=Kse(t),r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}function qse(e,t){let n=null,r=Vse({schemaValidation:t?.schemaValidation??Hse(),...t?.uploadSettings===void 0?{}:{uploadFile:async({patchId:e,parentRef:n,filePath:r,data:i,type:a,remote:o,metadata:s,onProgress:c})=>{let l=await t.uploadSettings();if(l.status===`error`)return{status:`error`,message:`Could not find where to upload files: ${l.error}`};let u=r;if(o){let e=H.remote.splitRemoteRef(r);if(e.status===`error`)return{status:`error`,message:`Could not read the file path out of a remote ref (${e.error}). This is most likely a Val bug.`};u=`/`+e.filePath}let d=JSON.stringify({filePath:u,parentRef:n??{type:`head`,headBaseSha:``},data:i,type:a,metadata:s,remote:o});return new Promise(t=>{let n=new XMLHttpRequest;c!==void 0&&n.upload.addEventListener(`progress`,e=>{e.lengthComputable&&c(e.loaded,e.total)}),n.addEventListener(`load`,()=>{if(n.status>=200&&n.status<300){t({status:`ok`});return}t({status:`error`,message:`Could not upload ${u}: HTTP ${n.status} ${n.statusText}`})}),n.addEventListener(`error`,()=>{t({status:`error`,message:`Could not upload ${u} (network error?)`})}),n.responseType=`text`,n.open(`POST`,`${l.data.baseUrl}/patches/${e}/files`),n.setRequestHeader(`Content-Type`,`application/json`),l.data.nonce!==null&&n.setRequestHeader(`x-val-auth-nonce`,l.data.nonce),n.send(d)})}},fetchPatches:async t=>{let n=[],r={},i,a=0,o=0;for(let s of yS(t,`patch_id`)){a++;let t=await e(`/patches`,`GET`,{query:{exclude_patch_ops:!1,patch_id:s}});if(t.status!==200){let e=`message`in t.json?t.json.message:`GET /patches failed with status ${t.status??`network`}`;for(let t of s)r[t]=e;i=e,o++;continue}for(let e of t.json.patches){if(e.patch===void 0){r[e.patchId]=`No ops for patch ${e.patchId}`;continue}n.push({patchId:e.patchId,moduleFilePath:e.path,patch:e.patch,createdAt:e.createdAt,authorId:e.authorId??void 0,appliedAt:e.appliedAt??null})}}return{patches:n,errors:r,...a>0&&o===a?{error:i}:{}}},fetchJsonEntry:async(t,n)=>{let r=await e(`/json`,`GET`,{query:{path:t,key:void 0,keys:[n],offset:void 0,limit:void 0,apply_patches:!1}});if(r.status!==200||!(`entries`in r.json))return{status:`error`,message:r.status!==200&&`message`in r.json?r.json.message:`GET /json failed with status ${r.status??`network`}`};let i=r.json.entries.find(e=>e.key===n);if(i===void 0){let e=r.json.errors.find(e=>e.key===n);return e===void 0?{status:`error`,message:`Entry not found: ${n} in ${t}`}:{status:`error`,message:e.message}}return{status:`ok`,content:i.content??null}},mode:t?.mode,publishPatches:async({patchIds:t,message:n})=>{let r=await e(`/save`,`POST`,{body:{message:n,patchIds:t}});if(r.status===null)return{status:`network-error`,message:`message`in r.json?r.json.message:`Network error`};if(r.status===200)return{status:`published`,removed:r.json.removed};if(r.status===409)return{status:`not-fast-forward`,message:r.json.message};if(r.status===400){let e={},t=`details`in r.json?r.json.details:void 0;if(Array.isArray(t))for(let n of t)typeof n==`object`&&n&&`patchId`in n&&`message`in n&&(e[n.patchId]=String(n.message));else if(typeof t==`object`&&t&&`unappliablePatches`in t&&t.unappliablePatches!==void 0)for(let[n,r]of Object.entries(t.unappliablePatches))e[n]=r.message;return{status:`patch-errors`,message:r.json.message,errors:e}}return{status:`error`,message:`message`in r.json?r.json.message:`POST /save failed with status ${r.status}`}},discardPatches:async t=>{let n=[];for(let r of yS(t,`id`)){let t=await e(`/patches`,`DELETE`,{query:{id:r}});if(t.status!==200)return{status:`error`,message:t.status!==null&&`message`in t.json?t.json.message:`DELETE /patches failed with status ${t.status??`network`}`};n.push(...t.json)}return{status:`discarded`,patchIds:n}},...t?.writes===!0?{savePatches:async({patches:t,parentRef:n,sessionId:r})=>{let i=await e(`/patches`,`PUT`,{body:{patches:t,parentRef:n,sessionId:r}});if(i.status===null){let e=`message`in i.json?i.json.message:`Network error`;return{status:`type`in i.json&&i.json.type===`client_side_validation_error`?`unparseable-response`:`network-error`,message:e}}return i.status===409?{status:`conflict`,message:i.json.message}:i.status===400?{status:`rejected`,message:i.json.message,errors:Object.fromEntries(Object.entries(i.json.errors??{}).map(([e,t])=>[e,t.map(e=>e.error.message)]))}:i.status===200?{status:`saved`,newPatchIds:i.json.newPatchIds,parentRef:i.json.parentRef}:{status:`unauthorized`,message:`message`in i.json?i.json.message:`PUT /patches failed with status ${i.status}`}}}:{},...t?.writes?{resyncChain:async()=>{let t=await e(`/stat`,`POST`,{body:null});t.status===200&&n?.stat.receiveStat({baseSha:t.json.baseSha,patches:t.json.patches})}}:{}});return n=r,r}var bS=b.createContext(new Proxy({},{get:()=>{throw Error(`Cannot use ValRemoteContext outside of ValRemoteProvider`)}}));function Jse({children:e,remoteFiles:t}){return(0,Y.jsx)(bS.Provider,{value:{remoteFiles:t},children:e})}function xS(){let{remoteFiles:e}=(0,b.useContext)(bS);return e}function SS(){let{remoteFiles:e}=(0,b.useContext)(bS),[t,n]=(0,b.useState)(null);function r(e){return Math.floor(Math.random()*e)}return(0,b.useEffect)(()=>{e.status===`ready`&&e.buckets.length>0&&t===null&&n(e.buckets[r(e.buckets.length)])},[e,t]),t}var CS=(0,b.createContext)({isAIChatEnabled:!1,canMentionField:!1,openAIChat:()=>{},setOpenAIChatImpl:()=>{},chatEditorRef:{current:null},insertFieldRef:()=>{},flushPendingFieldRefs:()=>{}});function Yse({isAIChatEnabled:e,isAIChatOnline:t,children:n}){let r=(0,b.useRef)(null),i=(0,b.useRef)(null),[a,o]=(0,b.useState)(!1),s=(0,b.useRef)([]),c=(0,b.useCallback)(()=>{r.current?.()},[]),l=(0,b.useCallback)(e=>{r.current=e,o(e!==null)},[]),u=(0,b.useCallback)(e=>{c();let t=i.current;if(t===null){s.current.push(e);return}t.insertFieldRef(e)},[c]),d=(0,b.useCallback)(()=>{let e=i.current;if(e===null||s.current.length===0)return;let t=s.current;s.current=[];for(let n of t)e.insertFieldRef(n)},[]),f=(0,b.useMemo)(()=>({isAIChatEnabled:e,canMentionField:e&&t&&a,openAIChat:c,setOpenAIChatImpl:l,chatEditorRef:i,insertFieldRef:u,flushPendingFieldRefs:d}),[e,t,a,c,l,u,d]);return(0,Y.jsx)(CS.Provider,{value:f,children:n})}function wS(){return(0,b.useContext)(CS)}function TS(){return wS().insertFieldRef}var ES=`val:ai:model`;function Xse(){try{let e=localStorage.getItem(ES);if(!e)return null;let t=OS.safeParse(JSON.parse(e));return t.success?{provider:t.data.provider,model:t.data.model}:null}catch{return null}}function Zse(e){try{localStorage.setItem(ES,JSON.stringify(e))}catch{}}function Qse(e,t){if(e.length===0)return t;let n=Xse();return n&&e.find(e=>e.provider===n.provider&&e.model===n.model)||((t&&e.find(e=>e.provider===t.provider&&e.model===t.model))??e[0])}var DS=Ou([`openai`,`anthropic`]),OS=q({provider:DS,model:W().min(1)}),kS=[{ref:{provider:`openai`,model:`gpt-5.1`},label:`GPT-5.1`},{ref:{provider:`anthropic`,model:`claude-sonnet-5`},label:`Claude Sonnet 5`},{ref:{provider:`anthropic`,model:`claude-opus-5`},label:`Claude Opus 5`},{ref:{provider:`anthropic`,model:`claude-haiku-4-5`},label:`Claude Haiku 4.5`}];function $se(e){if(e===void 0)return kS[0].ref;let t=new Set(e);return kS.find(e=>t.has(e.ref.provider))?.ref??null}function ece(e){return e?e.flatMap(e=>{let t=DS.safeParse(e.provider);return t.success?[{ref:{provider:t.data,model:e.model},label:e.label||e.model}]:[]}):[]}function tce(e,t){if(e===void 0){let e=t?kS.find(e=>e.ref.provider===t.provider&&e.ref.model===t.model):void 0;return e?[e]:[]}return kS.filter(t=>e.includes(t.ref.provider))}var AS=q({name:W(),description:W(),parameters:q({type:J(`object`),properties:Eu(W(),pu()),required:K(W()).optional()}),timeoutMs:yu([iu().nonnegative(),lu()]).optional()}),nce=q({id:W(),systemPrompt:W(),model:OS,tools:K(AS).optional(),description:W().optional()}),rce=q({type:J(`ai_tool_call`),id:W(),toolCallId:W(),name:W(),arguments:pu()}),ice=Ou([`max_iterations_reached`,`token_limit_reached`,`authentication_required`,`session_not_found`,`internal_error`,`byok_invalid_key`,`provider_not_configured`,`model_refusal`]),ace=q({type:J(`setup_byok`),label:W(),url:W()}),oce=q({type:J(`ai_error`),id:W(),code:ice.catch(`internal_error`),message:W(),resetDate:W().optional(),action:ace.optional(),details:W().optional()}),sce=bu(`type`,[q({type:J(`ai_response`),id:W(),sessionId:W(),response:W(),metadata:q({model:W().optional(),tokensUsed:iu().optional()}).optional()}),q({type:J(`ai_streaming`),id:W(),chunk:W()}),rce,oce,q({type:J(`ai_cancelled`),id:W(),sessionId:W().optional(),partialResponse:W().optional()}),q({type:J(`ai_session_unhidden`),id:W(),sessionId:W()}),q({type:J(`ai_agent_handoff`),id:W(),sessionId:W(),fromAgent:W(),toAgent:W(),reason:W().optional()})]),cce=yu([q({type:J(`text`),text:W()}),q({type:J(`image_key`),key:W()})]);q({type:J(`ai_prompt`),id:W(),sessionId:Bl().optional(),message:yu([W(),K(cce)]),context:W().optional(),maxIterations:iu().int().min(1).max(200).optional(),hidden:G().optional(),agents:K(nce).min(1)}),q({type:J(`ai_tool_result`),toolCallId:W(),result:pu(),isError:G().optional()}),q({type:J(`ai_get_sessions`),id:W(),limit:iu().int().min(1).max(100).optional(),cursor:q({updatedAt:W(),id:W().uuid()}).optional()}),q({type:J(`ai_set_session_name`),id:W(),sessionId:W().uuid(),name:W()}),q({type:J(`ai_get_sessions_with_messages`),id:W(),limit:iu().int().min(1).max(100).optional(),cursor:q({updatedAt:W(),id:W().uuid()}).optional()}),q({type:J(`ai_cancel`),id:W()}),q({type:J(`ai_unhide_session`),id:W(),sessionId:W()});var lce=3e3,uce=5;function dce(e,t){let n=(0,b.useRef)(null),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)([]),[d,f]=(0,b.useState)(null),p=(0,b.useCallback)(e=>{f(e),Zse(e)},[]),[m,h]=(0,b.useState)(null),g=(0,b.useRef)(new Set),_=(0,b.useRef)(null),v=(0,b.useRef)(0),y=(0,b.useRef)(e);y.current=e;let x=(0,b.useRef)(t);x.current=t;let S=(0,b.useCallback)(e=>{if(v.current>=uce){console.warn(`Giving up on the AI connection:`,e),h(e);return}T.current()},[]),C=(0,b.useCallback)(async()=>{if(y.current){v.current+=1;try{let e=await x.current(`/ai/initialize`,`POST`,{});if(e.status===401){o(!0);return}if(e.status!==200){S(typeof e.json.message==`string`?e.json.message:`The assistant could not be started (${e.status})`);return}o(!1);let t=$se(e.json.providers);c(t);let r=ece(e.json.models),a=r.length>0?r:tce(e.json.providers,t);u(a),f(Qse(a.map(e=>e.ref),t));let s=new WebSocket(e.json.wsUrl+`?nonce=`+encodeURIComponent(e.json.nonce));s.onopen=()=>{v.current=0,h(null),i(!0)},s.onmessage=e=>{try{let t=JSON.parse(e.data),n=sce.safeParse(t);if(!n.success){console.error(`Could not parse AI WebSocket message`,n.error,`Original message:`,t);return}for(let e of g.current)e(n.data)}catch(e){console.error(`Error processing AI WebSocket message`,e)}},s.onclose=()=>{i(!1),n.current===s&&(n.current=null,S(`Lost the connection to the assistant`))},s.onerror=()=>{console.warn(`AI WebSocket error`),s.close()},n.current=s}catch(e){S(e instanceof Error?e.message:`Could not reach the assistant`)}}},[S]),w=(0,b.useCallback)(()=>{_.current||=setTimeout(()=>{_.current=null,y.current&&C()},lce)},[C]),T=(0,b.useRef)(w);T.current=w;let E=(0,b.useCallback)(()=>{_.current&&=(clearTimeout(_.current),null),v.current=0,h(null),o(!1),C()},[C]);return(0,b.useEffect)(()=>(e&&C(),()=>{_.current&&=(clearTimeout(_.current),null),n.current&&=(n.current.close(),null)}),[e,C]),{subscribeToMessages:(0,b.useCallback)(e=>(g.current.add(e),()=>{g.current.delete(e)}),[]),send:(0,b.useCallback)(e=>n.current?.readyState===WebSocket.OPEN?(n.current.send(JSON.stringify(e)),!0):(console.warn(`AI WebSocket not open, cannot send`),!1),[]),isConnected:r,authError:a,connectionError:m,retryConnection:E,availableModel:s,availableModels:l,selectedModel:d,selectModel:p}}q({type:J(`ai_prompt`),id:W(),sessionId:W().uuid().optional(),message:W(),context:W().optional(),maxIterations:iu().int().min(1).max(200).optional(),agents:K(q({id:W(),systemPrompt:W(),model:W(),tools:K(AS).optional(),description:W().optional()})).min(1)});var jS=class extends Error{constructor(e,t){super(e),this.name=`SessionImageToPatchError`,this.availableKeys=t}},MS=new Proxy({},{get:()=>{throw Error(`Cannot use ValContext outside of ValProvider`)}}),NS=b.createContext(MS);function PS({children:e,client:t,config:n,valModules:r,dispatchValEvents:i,theme:a,setTheme:o}){let[s,c,l,u,d,f]=see(t),p=`data`in s&&!!s.data&&(`data`in s&&s.data?s.data.config?.ai?.chat?.experimental?.enable===!0||s.data.config?.ai?.commitMessages?.disabled!==!0:!1),{subscribeToMessages:m,send:h,isConnected:g,authError:_,connectionError:v,retryConnection:y,availableModel:x,availableModels:S,selectedModel:C,selectModel:w}=dce(p,t),T=(0,b.useCallback)(async e=>{let n=await t(`/ai/sessions`,`GET`,{query:{limit:e?.limit===void 0?void 0:String(e.limit),cursor_updatedAt:e?.cursor?.updatedAt,cursor_id:e?.cursor?.id}});if(n.status===200)return n.json;throw Error(`ai/sessions failed: ${n.status??`network`}: ${n.json.message}`)},[t]),E=(0,b.useCallback)(async(e,n)=>{let r=await t(`/ai/messages`,`GET`,{path:`/${encodeURIComponent(e)}/messages`,query:{limit:n?.limit===void 0?void 0:String(n.limit),cursor_updatedAt:n?.cursor?.updatedAt,cursor_id:n?.cursor?.id}});if(r.status===200)return r.json;throw Error(`ai/sessions/messages failed: ${r.status??`network`}: ${r.json.message}`)},[t]),D=(0,b.useCallback)(async(e,n)=>{let r=await t(`/ai/sessions`,`PATCH`,{path:`/${encodeURIComponent(e)}`,body:{name:n}});if(r.status!==200)throw Error(`ai/sessions/rename failed: ${r.status??`network`}: ${r.json.message}`)},[t]),O=(0,b.useCallback)(async e=>{let n=await t(`/ai/session-image-to-patch-file`,`POST`,{body:e});if(n.status===200)return n.json;throw n.status===400?new jS(`ai/session-image-to-patch-file failed: 400: ${n.json.message}`,n.json.details?.availableKeys):new jS(`ai/session-image-to-patch-file failed: ${n.status??`network`}: ${n.json.message}`)},[t]),k=`data`in s&&s.data?s.data.config:void 0,[A,j]=(0,b.useState)();(0,b.useEffect)(()=>{if(A===void 0||A===!0){if(f){let e=setTimeout(()=>{j(f)},2e3);return()=>{clearTimeout(e)}}f||j(!1)}},[f,A]);let M=`data`in s&&s.data?s.data.baseSha:void 0,N=`data`in s&&s.data?s.data.patches:void 0,P=`data`in s&&s.data?s.data.mode:void 0,F=`data`in s&&s.data?s.data.removed:void 0,I=(0,b.useMemo)(()=>M!==void 0&&N!==void 0?{baseSha:M,patches:N,removed:F}:null,[M,N,F]),L=(0,b.useCallback)(async()=>{let e=await t(`/direct-file-upload-settings`,`POST`,{}),n=0;for(;e.status===null&&n<5;)console.warn(`Failed to get direct file upload settings, retrying...`,e),await new Promise(e=>setTimeout(e,500*(n+1))),e=await t(`/direct-file-upload-settings`,`POST`,{}),n++;return e.status===200?{status:`success`,data:e.json}:{status:`error`,error:`Could not get direct file upload settings`}},[t]),R=(0,b.useMemo)(()=>qse(t,{writes:!0,uploadSettings:L}),[t,L]);(0,b.useEffect)(()=>{(P===`fs`||P===`http`)&&R.setMode(P)},[R,P]);let[ee,te]=(0,b.useState)([]),ne=(0,b.useRef)(new Set),re=`data`in s&&s.data?.deployments?s.data.deployments.map(e=>`${e.deploymentId}:${e.deploymentState}:${e.updatedAt}`).join(`,`):``,ie=`data`in s&&s.data?.commits?s.data.commits.map(e=>e.commitSha).join(`,`):``;(0,b.useEffect)(()=>{`data`in s&&s.data&&te(e=>s.data?.deployments&&s.data.deployments?.length>0||s.data?.commits&&s.data.commits?.length>0?dee(e,s.data?.commits||[],s.data?.deployments||[]).filter(e=>!ne.current.has(e.commitSha)):e)},[re,ie]);let ae=(0,b.useCallback)(e=>{te(t=>t.filter(t=>t.commitSha!==e)),ne.current.add(e)},[]),[oe,se]=(0,b.useState)(new Set);(0,b.useEffect)(()=>{`data`in s&&s.data?.commitSha&&se(e=>{if(s.data?.commitSha===void 0||e.has(s.data.commitSha))return e;let t=new Set(e);return t.add(s.data.commitSha),t})},[s]);let[ce,le]=(0,b.useState)({status:`not-asked`}),[ue,de]=(0,b.useState)(!1),fe=(0,b.useSyncExternalStore)((0,b.useCallback)(e=>R.schemaStore.events.on(`schema:init`,e),[R]),(0,b.useCallback)(()=>R.schemaStore.all(),[R]),(0,b.useCallback)(()=>R.schemaStore.all(),[R]));(0,b.useEffect)(()=>{if(fe){let e=fe,t=!1;for(let n of Object.values(e))try{if(ur(n)){t=!0;break}}catch(e){console.error(`Val: could not tell whether a schema needs remote files. Remote uploads may be unavailable.`,e)}de(t)}},[fe]),(0,b.useEffect)(()=>{let e=0;function n(){e++,ce.status!==`ready`&&e<10&&t(`/remote/settings`,`GET`,{}).then(e=>{e.status===200?le({status:`ready`,coreVersion:e.json.coreVersion,buckets:e.json.remoteFileBuckets.map(e=>e.bucket),publicProjectId:e.json.publicProjectId}):(`errorCode`in e.json&&e.json.errorCode?le({status:`inactive`,reason:e.json.errorCode,message:e.json.message}):le({status:`inactive`,reason:`unknown-error`,message:`An unknown error has occurred`}),setTimeout(n,5e3))}).catch(e=>{console.error(`Error getting remote settings`,e),le({status:`inactive`,reason:`unknown-error`,message:`An unknown error has occurred`}),setTimeout(n,5e3)})}ue&&(le({status:`loading`}),n())},[ue]);let[pe,me]=(0,b.useState)({type:`not-asked`}),he=(0,b.useSyncExternalStore)((0,b.useCallback)(e=>R.patchStore.events.on(`patch:chain`,e),[R]),(0,b.useCallback)(()=>R.patchStore.pendingPatchIds().length,[R]),(0,b.useCallback)(()=>R.patchStore.pendingPatchIds().length,[R]));(0,b.useEffect)(()=>{let e=e=>{he>0&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e)}},[he]);let{state:ge,retry:_e}=gce(t,l,`data`in s&&s.data?s.data.mode:`unknown`,f,k?.project);return(0,Y.jsx)(NS.Provider,{value:{client:t,publishSummaryState:pe,setPublishSummaryState:me,profileId:`data`in s&&s.data?s.data.profileId:null,mode:`data`in s&&s.data?s.data.mode:`unknown`,profileAuthError:ge.status===`auth-error`?ge.error:null,profilesError:ge.status===`error`?{message:ge.error,willRetry:ge.willRetry}:null,retryProfiles:_e,serviceUnavailable:A,baseSha:M,observedCommitShas:oe,deployments:ee,dismissDeployment:ae,authenticationState:l,config:k,profiles:`data`in ge&&ge.data?ge.data:{},remoteFiles:ce,subscribeToWsMessages:m,sendWsMessage:h,isWsConnected:g,aiAuthError:_,aiConnectionError:v,retryAiConnection:y,aiGetSessions:T,aiGetSessionMessages:E,aiSetSessionName:D,availableAiModel:x,availableAiModels:S,selectedAiModel:C,selectAiModel:w,aiSessionImagesToPatchFile:O},children:(0,Y.jsx)(qg,{children:(0,Y.jsx)(Yse,{isAIChatEnabled:p,isAIChatOnline:p&&g,children:a!==void 0&&o?(0,Y.jsx)(Uae,{theme:a,setTheme:o,config:k,children:(0,Y.jsx)(boe,{system:R,valModules:r??null,stat:I,children:(0,Y.jsx)(_oe,{children:(0,Y.jsx)(Mce,{children:(0,Y.jsx)(Wae,{children:(0,Y.jsx)(Jse,{remoteFiles:ce,children:(0,Y.jsxs)(Zae,{getDirectFileUploadSettings:L,config:k,children:[(0,Y.jsx)(Toe,{enabled:i}),(0,Y.jsx)(qae,{}),e,(0,Y.jsx)(fce,{})]})})})})})})}):e})})})}function fce(){return FS().schema===`out-of-date`?(0,Y.jsx)(Gae,{}):null}function FS(){let e=nb(),t=(0,b.useCallback)(t=>e===null?()=>{}:e.system.status.events.on(`status:change`,t),[e]),n=(0,b.useCallback)(()=>e===null?pce:e.system.status.current(),[e]);return(0,b.useSyncExternalStore)(t,n,n)}var pce={errors:[],networkErrorSince:null,schemaError:null,schema:`current`},mce=5,hce=1e3;function gce(e,t,n,r,i){let[a,o]=(0,b.useState)({status:`not-asked`}),s=(0,b.useRef)(0),c=(0,b.useRef)(null),l=(0,b.useCallback)(()=>{c.current!==null&&(clearTimeout(c.current),c.current=null)},[]);(0,b.useEffect)(()=>l,[l]);let u=(0,b.useRef)(()=>void 0),d=(0,b.useCallback)(async()=>{s.current+=1,o(e=>({status:`loading`,data:`data`in e?e.data:void 0}));let t=await e(`/profiles`,`GET`,{});if(t.status===200){let e={};for(let n of t.json.profiles)e[n.profileId]={fullName:n.fullName,email:n.email,avatar:n.avatar};s.current=0,o({status:`done`,data:e})}else if(n===`fs`&&t.status===401){let e=`message`in t.json&&typeof t.json.message==`string`?t.json.message:`Could not authenticate while getting profiles`;o(t=>({status:`auth-error`,error:e,data:`data`in t?t.data:void 0}))}else{let e=s.current<mce;if(e||console.error(`Could not get profiles`,t.json),o(n=>({status:`error`,error:ree(t.json),willRetry:e,data:`data`in n?n.data:void 0})),e){let e=hce*2**(s.current-1);c.current=setTimeout(()=>{c.current=null,u.current()},e)}}},[e,n]);u.current=()=>void d();let f=(0,b.useCallback)(()=>{l(),s.current=0,u.current()},[l]);return(0,b.useEffect)(()=>{t!==`not-asked`&&t!==`loading`&&(n===`fs`||t===`authorized`)&&(n===`fs`&&!i||r||a.status===`not-asked`&&d())},[t,d,n,a.status,r,i]),{state:a,retry:f}}function IS(){let{authenticationState:e}=(0,b.useContext)(NS);return e}function _ce(){let{serviceUnavailable:e}=(0,b.useContext)(NS);return e===!0?`service-unavailable`:`connected`}function LS(){let e=nb();return{addModuleFilePatch:(0,b.useCallback)((t,n,r)=>{if(e===null){console.error(`Val: cannot write patch: no store system is mounted`);return}e.system.patchStore.createPatch(t,n).then(e=>{e.status!==`created`&&console.error(`Val: could not write patch`,e.message)})},[e])}}function RS(){let e=nb();return{deletePatches:(0,b.useCallback)(t=>{if(e===null){console.error(`Val: cannot discard: no store system is mounted`);return}for(let n=0;n<t.length;n+=100){let r=t.slice(n,n+100);e.system.discard(r).then(e=>{e.status===`failed`&&console.error(`Val: could not discard patches`,e.message)})}},[e])}}function zS(){let{subscribeToWsMessages:e,sendWsMessage:t,isWsConnected:n,aiAuthError:r,aiGetSessions:i,aiGetSessionMessages:a,aiSetSessionName:o,aiSessionImagesToPatchFile:s}=(0,b.useContext)(NS);return{subscribeToWsMessages:e,sendWsMessage:t,isWsConnected:n,aiAuthError:r,aiGetSessions:i,aiGetSessionMessages:a,aiSetSessionName:o,aiSessionImagesToPatchFile:s}}function BS(){let{availableAiModel:e}=(0,b.useContext)(NS);return e}function VS(){let{availableAiModels:e,selectedAiModel:t,selectAiModel:n}=(0,b.useContext)(NS);return{models:e,selected:t,select:n}}function HS(){let{deployments:e,dismissDeployment:t,observedCommitShas:n}=(0,b.useContext)(NS);return{deployments:e,dismissDeployment:t,observedCommitShas:n}}function US(){let e=nb(),t=WS(),[n,r]=(0,b.useState)({status:`not-asked`}),i=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(e===null)return;let t=!1;return e.system.getPatchSets().then(e=>{if(t)return;let n=JSON.stringify(e);n!==i.current&&(i.current=n,r({status:`success`,data:e}))}).catch(e=>{t||r({status:`error`,error:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e,t]),n}function WS(){let e=nb(),t=(0,b.useCallback)(t=>e===null?()=>{}:e.system.patchStore.events.on(`patch:chain`,t),[e]),n=(0,b.useCallback)(()=>e===null?0:e.system.patchStore.chainVersion(),[e]);return(0,b.useSyncExternalStore)(t,n,n)}function vce(){let e=nb(),[t,n]=(0,b.useState)(0);return(0,b.useEffect)(()=>{if(e!==null)return e.system.patchStore.events.on(`patch:head`,()=>{n(e=>e+1)})},[e]),t}function GS(){let e=nb(),t=WS();return(0,b.useMemo)(()=>{let t=new Set;if(e===null)return t;let n=e.system.patchStore.publishedPatchIds();for(let r of e.system.patchStore.allRecords())(r.appliedAt||n.has(r.patchId))&&t.add(r.patchId);return t},[e,t])}function yce(){let e=nb(),t=WS();return(0,b.useMemo)(()=>{if(e===null)return[];let t=[],n=new Set;for(let r of e.system.patchStore.allRecords()){let e=r.appliedAt?.commitSha;e!==void 0&&!n.has(e)&&(n.add(e),t.unshift(e))}return t},[e,t])}function bce(e){let t=nb(),n=$S(),r=WS();return(0,b.useMemo)(()=>{let n=new Set;if(t===null)return n;let r=t.system.sourceStore;for(let t of e){let e=r.peek(t),i=r.peekBase(t);e.status===`ready`&&i.status===`ready`&&Mr(e.data,i.data)&&n.add(t)}return n},[t,n,r,e])}function KS(){let e=nb(),t=$S(),n=WS(),r=GS(),i=(0,b.useMemo)(()=>{if(e===null)return[];let t=new Set;for(let n of e.system.patchStore.allRecords())r.has(n.patchId)||t.add(n.moduleFilePath);return[...t]},[e,n,r]);return(0,b.useMemo)(()=>{if(e===null||i.length===0)return!0;let t=e.system.sourceStore;for(let e of i){let n=t.moduleSource(e),r=t.peekBase(H.joinModuleFilePathAndModulePath(e,``));if(n===void 0||r.status!==`ready`||!Mr(n,r.data))return!0}return!1},[e,t,n,i])}function qS(){let e=nb(),t=WS();return(0,b.useMemo)(()=>{if(e===null)return[];let t=e.system.patchStore;return t.allRecords().map(e=>e.patchId).filter(e=>!t.isPending(e))},[e,t])}function JS(){let e=nb(),t=WS();return(0,b.useMemo)(()=>e===null?[]:e.system.patchStore.pendingPatchIds(),[e,t])}function xce(){let e=nb(),t=(0,b.useCallback)(t=>{if(e===null)return()=>{};let n=e.system.patchStore.events.on(`patch:chain`,t),r=e.system.patchStore.events.on(`patch:head`,t);return()=>{n(),r()}},[e]),n=(0,b.useCallback)(()=>e!==null&&e.system.patchStore.chainSettled(),[e]),r=(0,b.useSyncExternalStore)(t,n,n),[i,a]=(0,b.useState)(!1),o=i||r;return(0,b.useEffect)(()=>{o&&a(!0)},[o]),o}function Sce(){let e=nb();return(0,b.useCallback)(()=>e===null?{total:0,settled:0,unfetched:[],unapplied:[],failed:[],statSeen:!1}:e.system.patchStore.chainProgress(),[e])}function Cce(){let e=nb(),[t,n]=(0,b.useState)(null);return(0,b.useEffect)(()=>{if(e!==null)return e.system.patchStore.events.on(`patch:fetch-failed`,e=>{n(e.message)})},[e]),t}function YS(){let e=nb(),t=WS();return(0,b.useMemo)(()=>e===null?[]:e.system.patchStore.allRecords().map(e=>e.patchId),[e,t])}var wce=[];function XS(e){let t=nb(),n=(0,b.useCallback)(e=>t===null?()=>{}:t.system.patchStore.events.on(`patch:chain`,e),[t]),r=(0,b.useCallback)(()=>t===null?null:t.system.patchStore.patchesByPath().get(e)??wce,[t,e]),i=(0,b.useSyncExternalStore)(n,r,r);return(0,b.useMemo)(()=>i===null?null:i.map(e=>ZS(e.record,e.isPending)),[i])}function Tce(e){let t=nb(),n=WS();return(0,b.useMemo)(()=>{if(t===null)return[];let n=t.system.patchStore;return n.allRecords().filter(t=>t.moduleFilePath===e).map(e=>ZS(e,n.isPending(e.patchId)))},[t,n,e])}function ZS(e,t){return{moduleFilePath:e.moduleFilePath,patch:e.patch,isPending:t,createdAt:e.createdAt??``,authorId:e.authorId??null,isCommitted:e.appliedAt??void 0}}function QS(){let{mode:e}=(0,b.useContext)(NS);return e}function Ece(){let e=nb(),t=(0,b.useCallback)(t=>e===null?()=>{}:e.system.host.events.on(`host:receive`,t),[e]),n=(0,b.useCallback)(()=>e===null?null:e.system.host.initializedAt(),[e]);return(0,b.useSyncExternalStore)(t,n,n)}function $S(){let e=nb(),t=(0,b.useCallback)(t=>e===null?()=>{}:e.system.sourceStore.events.on(`source:change`,t),[e]),n=(0,b.useCallback)(()=>e===null?0:e.system.sourceStore.sourcesVersion(),[e]);return(0,b.useSyncExternalStore)(t,n,n)}var Dce=yu([q({type:J(`not-asked`),isGenerating:G().optional()}),q({type:J(`manual`).or(J(`ai`)),text:W(),patchIds:K(W()).nullable(),isGenerating:G()})]);function eC(){let{publishSummaryState:e,setPublishSummaryState:t,config:n}=(0,b.useContext)(NS),r=nb(),i=YS(),{patchErrors:a}=oC(),o=(0,b.useMemo)(()=>a?Object.values(a).some(e=>Object.keys(e).length>0):!1,[a]);(0,b.useEffect)(()=>{if(e.type===`not-asked`){let e=kce(n?.project);e&&e.type!==`not-asked`&&i.length>0&&t(e)}},[e,n,t]);let[s,c]=(0,b.useState)(!1),l=(0,b.useCallback)(async e=>i===null?{status:`error`,message:`No changes to publish`}:s?{status:`error`,message:`Already publishing`}:r===null?{status:`error`,message:`No store system is mounted`}:(c(!0),(async()=>{let t=await r.system.publish(i,e);return t.status===`refused`&&t.reason===`chain-moved`?r.system.publish(i,e):t})().then(e=>{if(e.status===`published`)Ace(n?.project),t(e=>({type:`not-asked`,isGenerating:e.isGenerating}));else if(e.status===`refused`){let t=iee(e);r.system.status.reportError(t.message,t.details)}else e.status===`failed`&&r.system.status.reportError(`Could not publish`,e.patchErrors?Object.entries(e.patchErrors).map(([e,t])=>`${e}: ${t}`).join(`
|
|
133
133
|
`):e.message);return e}).finally(()=>{c(!1)})),[r,i,s,n?.project,t]),u=(0,b.useCallback)(e=>{t(t=>{let r;return r=e.type===`not-asked`?{type:`not-asked`,isGenerating:t.isGenerating}:{type:e.type,text:e.text,patchIds:i,isGenerating:!!t.isGenerating},Oce(r,n?.project),r})},[i,t,n?.project]);return{publish:l,publishDisabled:s||o===!0,isPublishing:s,aiEnabled:n?.ai?.commitMessages?.disabled!==!0,summary:e,setSummary:u}}function Oce(e,t){try{localStorage.setItem(`val-publish-summary-`+(t||`unknown`),JSON.stringify(e))}catch(e){console.error(`Error setting publish summary in local storage`,e)}return e}function kce(e){try{let t=localStorage.getItem(`val-publish-summary-`+(e||`unknown`));if(t){let e=Dce.safeParse(JSON.parse(t));if(e.success)return e.data;console.warn(`Error parsing publish summary from local storage`,e.error)}}catch(e){console.error(`Error getting publish summary from local storage`,e)}return null}function Ace(e){try{localStorage.removeItem(`val-publish-summary-`+(e||`unknown`))}catch(e){console.error(`Error deleting publish summary from local storage`,e)}}function tC(){let{profileId:e,profiles:t,mode:n}=(0,b.useContext)(NS);if(e)return t[e]??null;if(n===`fs`){let[e]=Object.values(t);return e??null}return null}function nC(){let e=(0,b.useContext)(NS);if(e===MS)return null;let{profileId:t,profiles:n,mode:r}=e;if(t)return t;if(r===`fs`){let[e]=Object.keys(n);return e??null}return null}var jce=700,rC=(0,b.createContext)({autoPublish:!1,setAutoPublish:()=>{}}),iC=`val-auto-publish`;function Mce({children:e}){let t=nb(),n=QS(),[r,i]=(0,b.useState)(()=>{try{return localStorage.getItem(iC)===`true`}catch{return!1}}),a=qS(),o=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!r||n!==`fs`||t===null||a.length===0)return;let e=a.join(`,`);if(o.current===e)return;let i=!1,s=setTimeout(()=>{t.system.publish(a,void 0,{exact:!0}).then(n=>{if(!i){if(n.status===`failed`){o.current=e,t.system.status.reportError(`Changes could not be saved to disk.`,n.message);return}o.current=null,n.status===`published`&&t.system.patchStore.allRecords().length===0&&t.system.validateEverything()}})},jce);return()=>{i=!0,clearTimeout(s)}},[r,n,t,a]);let s=(0,b.useMemo)(()=>({autoPublish:r,setAutoPublish:e=>{i(e);try{localStorage.setItem(iC,e.toString())}catch{}}}),[r]);return(0,Y.jsx)(rC.Provider,{value:s,children:e})}function aC(){return(0,b.useContext)(rC)}function Nce(){let e=nb();return(0,b.useCallback)((t,n)=>{e?.system.status.reportError(t,n)},[e])}function Pce(){let e=nb();return{globalTransientErrors:FS().errors,removeGlobalTransientErrors:t=>{e?.system.status.dismissErrors(t)}}}function Fce(){let{remoteFiles:e,profileAuthError:t}=(0,b.useContext)(NS),n=FS();return n.networkErrorSince===null?n.schemaError===null?t===null?e.status===`inactive`?{type:`remote-files-error`,error:e.message,reason:e.reason}:null:{type:`profiles-auth-error`,error:t}:{type:`schema-error`,schemaError:n.schemaError.length}:{type:`network-error`,networkError:n.networkErrorSince}}function oC(){let e=nb(),t=FS();return(0,b.useMemo)(()=>e===null?{patchErrors:void 0}:{patchErrors:e.system.patchErrors()},[e,t])}function Ice(){let{aiAuthError:e,aiConnectionError:t,retryAiConnection:n}=(0,b.useContext)(NS);return(0,b.useMemo)(()=>e||t===null?null:{message:t,retry:n},[e,t,n])}function sC(){let{profiles:e}=(0,b.useContext)(NS);return e}function Lce(){let{profilesError:e,retryProfiles:t}=(0,b.useContext)(NS);return(0,b.useMemo)(()=>e===null||e.willRetry?null:{message:e.message,retry:t},[e,t])}function cC(e,t){let n=nb(),r=Ece(),i=$S(),a=(0,b.useMemo)(()=>n===null?null:(e??[]).map(e=>n.system.sourceStore.moduleSource(e)),[n,i,e]);return(0,b.useMemo)(()=>{if(r===null)return{status:`loading`};if(!a)return{status:`not-found`,data:[],notFoundPaths:e||[]};let n=[],i=[],o=[];if(!e||e.length===0)return{status:`success`,data:[]};for(let r=0;r<e.length;r++){let s=e?.[r];if(s===void 0)throw Error(`While resolving shallow modules at paths, we unexpectedly got an undefined module file path`);let c=a?.[r];if(c===void 0){o.push(s);continue}let l=Rce(s,``,t,c);l.status===`success`?n.push(l.data):i.push({moduleFilePath:s,message:l.error})}return o.length>0?{status:`not-found`,data:n,notFoundPaths:o}:i.length>0?{status:`error`,data:n,errors:i}:{status:`success`,data:n}},[a,t,r,e])}function lC(){let e=wb();return(0,b.useMemo)(()=>{if(e.status===`success`){let t=null;for(let n in e.data){let e=rp(n);if(e){if(t===null)t=e;else if(t!==e)return{status:`error`,error:`Found multiple different src folders in the same project`}}}return{status:`success`,data:t}}return e},[e])}function Rce(e,t,n,r){if(r===null)return{status:`success`,data:null};let i=n;if(i===`object`||i===`record`){if(typeof r!=`object`)return{status:`error`,error:`Expected object, got ${typeof r}`};if(Wp(r))return{status:`error`,error:`Expected object, got array`};let n={};for(let i of Object.keys(r))n[i]=cb(e,t,i);return{status:`success`,data:n}}if(i===`array`){if(typeof r!=`object`||!Wp(r))return{status:`error`,error:`Expected array, got ${typeof r}`};let n=[];for(let i=0;i<r.length;i++)n.push(cb(e,t,i));return{status:`success`,data:n}}if(i===`boolean`)return typeof r!=`boolean`&&r!==null?{status:`error`,error:`Expected boolean, got ${typeof r}`}:{status:`success`,data:r};if(i===`number`)return typeof r!=`number`&&r!==null?{status:`error`,error:`Expected number, got ${typeof r}`}:{status:`success`,data:r};if(i===`richtext`)return typeof r!=`object`||!Wp(r)?{status:`error`,error:`Expected richtext (i.e. array), got ${typeof r}`}:{status:`success`,data:r};if(i===`date`||i===`dateTime`||i===`color`||i===`code`||i===`string`||i===`literal`)return typeof r!=`string`&&r!==null?{status:`error`,error:`Expected string, got ${typeof r}: ${JSON.stringify(r)}`}:{status:`success`,data:r};if(i===`file`||i===`image`)return typeof r!=`object`||!(`path`in r)||typeof r.path!=`string`?{status:`error`,error:`Expected object with a path property, got ${typeof r}`}:{status:`success`,data:r};if(i===`keyOf`||i===`route`)return typeof r==`string`?{status:`success`,data:r}:{status:`error`,error:`Expected string, got ${typeof r}`};if(i===`union`){if(typeof r==`string`)return{status:`success`,data:r};if(typeof r!=`object`)return{status:`error`,error:`Expected object, got ${typeof r}`};if(Wp(r))return{status:`error`,error:`Expected object, got array`};let n={};for(let i of Object.keys(r))n[i]=cb(e,t,i);return{status:`success`,data:n}}return{status:`error`,error:`Unknown schema type: ${i}`}}function uC(e){let[t,n]=(0,b.useState)(()=>dC());return(0,b.useEffect)(()=>{if(!e)return;let t=window.visualViewport,r=()=>n(dC());return r(),t&&(t.addEventListener(`resize`,r),t.addEventListener(`scroll`,r)),window.addEventListener(`orientationchange`,r),()=>{t&&(t.removeEventListener(`resize`,r),t.removeEventListener(`scroll`,r)),window.removeEventListener(`orientationchange`,r)}},[e]),t}var zce=.75;function Bce(e){let{viewportHeight:t,viewportOffsetTop:n,windowHeight:r}=e,i=t??r,a=n??0;return{height:i,offsetTop:a,keyboardInset:Math.max(0,r-(a+i)),isKeyboardOpen:i<r*zce}}function dC(){return typeof window>`u`?{height:0,offsetTop:0,keyboardInset:0,isKeyboardOpen:!1}:Bce({viewportHeight:window.visualViewport?.height,viewportOffsetTop:window.visualViewport?.offsetTop,windowHeight:window.innerHeight})}function fC(e){(0,b.useEffect)(()=>{if(!e)return;let{overflow:t,touchAction:n}=document.body.style;return document.body.style.overflow=`hidden`,document.body.style.touchAction=`none`,()=>{document.body.style.overflow=t,document.body.style.touchAction=n}},[e])}function pC({side:e,width:t,title:n,mobileVariant:r,breakpoint:i,onClose:a,headerAction:o,subheader:s,sticky:c,footer:l,hidden:u=!1,fill:d=!1,children:f}){let p=i===`mobile`&&!u,m=(0,b.useRef)(null),h=uC(p);return fC(p),(0,b.useEffect)(()=>{if(u)return;let e=e=>{e.key===`Escape`&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,u]),(0,Y.jsxs)(Y.Fragment,{children:[!u&&(0,Y.jsx)(`div`,{onClick:a,"aria-hidden":!0,className:X(`absolute inset-0 z-window`,p?`bg-black/40`:`bg-transparent`)}),(0,Y.jsxs)(`div`,{ref:m,role:`dialog`,"aria-label":n,style:p?r===`sheet`?{top:h.offsetTop,height:h.height}:{bottom:h.keyboardInset,...d?{height:h.height*.85}:{maxHeight:h.height*.85}}:{width:t},className:X(`absolute z-full flex flex-col`,`bg-bg-float border border-border-float shadow-lg`,u&&`hidden`,p?r===`sheet`?`fixed left-0 w-[min(20rem,88vw)] border-l-0 rounded-r-lg`:`fixed inset-x-0 rounded-t-xl border-b-0`:X(`top-16 bottom-14 rounded-lg`,e===`right`?`right-3`:i===`desktop`?`left-[4.75rem]`:`left-3`)),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 h-11 pl-4 pr-2 border-b border-border-float`,children:[(0,Y.jsx)(`span`,{className:`text-[0.8125rem] font-semibold tracking-tight truncate`,children:n}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[o,(0,Y.jsx)(`button`,{type:`button`,onClick:a,"aria-label":`Close ${n}`,className:`grid place-items-center w-7 h-7 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:(0,Y.jsx)(Hy,{size:15})})]})]}),s!==void 0&&(0,Y.jsx)(`div`,{className:`shrink-0 px-2 py-2 border-b border-border-float`,children:s}),c!==void 0&&(0,Y.jsx)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border-float`,children:c}),(0,Y.jsx)(`div`,{className:X(`flex-1 min-h-0`,d?`overflow-hidden`:`overflow-y-auto overscroll-contain scrollbar-slim`),children:f}),l!==void 0&&(0,Y.jsx)(`div`,{className:`shrink-0 border-t border-border-float`,children:l})]})]})}function mC({children:e,className:t,divided:n}){return(0,Y.jsx)(`div`,{className:X(`px-4 pt-4 pb-1.5 text-[0.6875rem] font-semibold uppercase tracking-wider text-fg-secondary-alt`,n&&`mt-3 border-t border-border-float`,t),children:e})}function hC({children:e}){return(0,Y.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-secondary-alt`,children:e})}function Vce({breakpoint:e,hidden:t,onClose:n,children:r}){return(0,Y.jsx)(pC,{side:`right`,width:420,title:`AI assistant`,mobileVariant:`bottom-sheet`,fill:!0,breakpoint:e,hidden:t,onClose:n,children:(0,Y.jsx)(`div`,{className:`h-full overflow-hidden`,children:r})})}function gC({value:e,onChange:t,placeholder:n}){return(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(dae,{size:14,"aria-hidden":!0,className:`absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:n,"aria-label":n,className:X(`w-full h-8 pl-8 pr-2 rounded-md text-xs`,`bg-bg-float-raised border border-transparent text-fg-primary`,`placeholder:text-fg-secondary-alt`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`)})]})}function _C({depth:e=0,selected:t,onClick:n,leading:r,label:i,meta:a,errorCount:o,hasDraft:s,trailing:c,action:l,expanded:u,title:d}){let f=o!==void 0&&o>0,p=[s?`Unpublished changes`:null,f?`${o} validation error${o===1?``:`s`}`:null].filter(e=>e!==null),m=(0,b.useId)();return(0,Y.jsxs)(`div`,{className:`group/row flex items-center pr-2`,style:{paddingLeft:8+e*12},children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:n,title:d,"aria-current":t?`true`:void 0,"aria-expanded":u,"aria-describedby":p.length>0?m:void 0,className:X(`group flex items-center gap-1.5 min-w-0 flex-1 h-7 px-1.5 rounded-md text-xs text-left`,t?`bg-bg-float-raised text-fg-primary font-medium`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:[r!==void 0&&(0,Y.jsx)(`span`,{className:`shrink-0 grid place-items-center w-3.5 h-3.5`,children:r}),(0,Y.jsx)(`span`,{className:`truncate`,children:i}),a!==void 0&&(0,Y.jsx)(`span`,{className:`truncate text-fg-secondary-alt font-normal`,children:a}),p.length>0&&(0,Y.jsx)(`span`,{id:m,hidden:!0,children:p.join(`, `)}),(0,Y.jsxs)(`span`,{"aria-hidden":!0,className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[s&&(0,Y.jsx)(`span`,{title:`Unpublished changes`,className:`w-1.5 h-1.5 rounded-full bg-fg-secondary`}),f&&(0,Y.jsx)(`span`,{title:`${o} validation error${o===1?``:`s`}`,className:`min-w-[1rem] h-4 px-1 grid place-items-center rounded bg-bg-error-primary text-fg-error-primary text-[0.625rem] font-semibold tabular-nums`,children:o}),c]})]}),l]})}function vC({rows:e=8}){return(0,Y.jsx)(`div`,{className:`py-2`,"aria-busy":`true`,"aria-label":`Loading`,children:Array.from({length:e},(e,t)=>(0,Y.jsx)(`div`,{className:`flex items-center h-7 px-3.5`,children:(0,Y.jsx)(`span`,{className:`h-2.5 rounded bg-bg-float-raised animate-pulse`,style:{width:`${45+t*17%45}%`}})},t))})}function yC({message:e,onRetry:t}){return(0,Y.jsxs)(`div`,{className:`flex gap-2.5 px-4 py-4`,children:[(0,Y.jsx)(Ly,{size:14,className:`mt-0.5 shrink-0 text-fg-error-on-surface`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-fg-primary`,children:e}),t&&(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`mt-2 h-7 px-2 rounded-md text-xs text-fg-secondary border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,children:`Try again`})]})]})}function Hce(e){let t=[],n=new Map([]);for(let r of e){let e=r.moduleFilePath.split(`/`).filter(Boolean).slice(0,-1),i=t,a=``;for(let t of e){a=`${a}/${t}`;let e=n.get(a);e||(e={kind:`directory`,id:a,name:t,children:[]},n.set(a,e),i.push(e)),i=e.children}i.push({kind:`module`,id:r.id,module:r})}return t}function Uce(e){return[...e].sort((e,t)=>{if(e.kind!==t.kind)return e.kind===`directory`?-1:1;let n=e.kind===`directory`?e.name:e.module.name,r=t.kind===`directory`?t.name:t.module.name;return n.localeCompare(r)}).map(e=>e.kind===`directory`?{...e,children:Uce(e.children)}:e)}function Wce(e){return e.flatMap(e=>e.kind===`directory`?[e.id,...Wce(e.children)]:[])}function Gce(e,t){if(t===null)return[];let n=(e,r)=>{for(let i of e){if(i.id===t)return r;if(i.kind===`directory`){let e=n(i.children,[...r,i.id]);if(e)return e}}return null};return n(e,[])??[]}function Kce({breakpoint:e,data:t,selectedId:n,onSelect:r,onClose:i,navSwitcher:a,isLoading:o,loadError:s,onRetryLoad:c}){let[l,u]=(0,b.useState)(``),d=(0,b.useMemo)(()=>Uce(Hce(t)),[t]),[f,p]=(0,b.useState)(()=>new Set),m=(0,b.useMemo)(()=>Gce(d,n).join(`\0`),[d,n]);(0,b.useEffect)(()=>{if(!m)return;let e=m.split(`\0`);p(t=>{if(!e.some(e=>t.has(e)))return t;let n=new Set(t);for(let t of e)n.delete(t);return n})},[m]);let h=e=>p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),g=(0,b.useMemo)(()=>{if(!l)return d;let e=l.toLowerCase(),t=n=>n.flatMap(n=>{if(n.kind===`module`)return n.module.name.toLowerCase().includes(e)||n.module.moduleFilePath.toLowerCase().includes(e)?[n]:[];let r=t(n.children);return r.length===0&&!n.name.toLowerCase().includes(e)?[]:[{...n,children:r}]});return t(d)},[d,l]),_=(0,b.useMemo)(()=>l?new Set(Wce(g)):null,[l,g]),v=t.length,y=(e,t)=>{if(e.kind===`module`)return(0,Y.jsx)(_C,{depth:t,selected:n===e.id,title:e.module.moduleFilePath,onClick:()=>r(e.module),leading:(0,Y.jsx)(Nv,{size:13,className:`text-fg-secondary-alt`}),label:e.module.name,errorCount:e.module.errorCount,hasDraft:e.module.hasDraft},e.id);let i=_?_.has(e.id):!f.has(e.id);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(_C,{depth:t,title:e.id,onClick:()=>{_||h(e.id)},leading:(0,Y.jsx)(`span`,{className:`text-fg-secondary-alt`,children:i?(0,Y.jsx)(Iv,{size:13}):(0,Y.jsx)(Rv,{size:13})}),label:e.name,errorCount:i?void 0:bC(e),hasDraft:i?void 0:xC(e)}),i&&e.children.map(e=>y(e,t+1))]},e.id)};return(0,Y.jsx)(pC,{side:`left`,width:300,title:`Data`,mobileVariant:`sheet`,breakpoint:e,onClose:i,subheader:a,sticky:o||s?void 0:(0,Y.jsx)(gC,{value:l,onChange:u,placeholder:`Filter data files…`}),children:(0,Y.jsx)(`div`,{className:`py-2`,children:o?(0,Y.jsx)(vC,{}):s?(0,Y.jsx)(yC,{message:s,onRetry:c}):v===0?(0,Y.jsx)(hC,{children:`No data files yet.`}):g.length===0?(0,Y.jsx)(hC,{children:`No data files match this filter.`}):g.map(e=>y(e,0))})})}function bC(e){let t=e.kind===`module`?e.module.errorCount??0:e.children.reduce((e,t)=>e+(bC(t)??0),0);return t===0?void 0:t}function xC(e){return(e.kind===`module`?e.module.hasDraft===!0:e.children.some(e=>xC(e)===!0))?!0:void 0}var qce=1048;function Jce(){return(0,Y.jsx)(`div`,{className:`grid place-items-center min-h-[60svh] text-center`,children:(0,Y.jsxs)(`div`,{className:`max-w-xs`,children:[(0,Y.jsx)($v,{size:28,className:`mx-auto mb-4 text-fg-secondary-alt`,strokeWidth:1.25}),(0,Y.jsx)(`h2`,{className:`text-[0.9375rem] font-medium tracking-tight`,children:`No item selected`}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-secondary-alt leading-relaxed`,children:`Pick a page, a media file or a data item from the navigation to start editing.`})]})})}function Yce({title:e,urlPath:t,sourcePath:n,isDevMode:r,hasDraft:i}){return(0,Y.jsxs)(`article`,{children:[(0,Y.jsxs)(`header`,{className:`pb-7 mb-8 border-b border-border-float`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2.5`,children:[(0,Y.jsx)(`span`,{className:`inline-flex items-center h-5 px-1.5 rounded bg-bg-float-raised font-mono text-[0.6875rem] text-fg-secondary-alt`,children:t}),i&&(0,Y.jsx)(`span`,{className:`inline-flex items-center h-5 px-1.5 rounded bg-bg-float-raised text-fg-primary text-[0.625rem] font-medium uppercase tracking-wide`,children:`Draft`})]}),(0,Y.jsx)(`h1`,{className:`text-[1.75rem] leading-tight font-semibold tracking-[-0.02em]`,children:e}),r&&n&&(0,Y.jsx)(`p`,{className:`mt-2.5 font-mono text-[0.6875rem] text-fg-secondary-alt`,children:n})]}),(0,Y.jsxs)(`div`,{className:`space-y-8`,children:[(0,Y.jsx)(SC,{label:`Title`,hint:`Shown in the browser tab and search results`,children:(0,Y.jsx)(Xce,{value:`Build better websites`})}),(0,Y.jsx)(SC,{label:`Meta description`,children:(0,Y.jsx)(Zce,{value:`Val is a Git-based CMS for developers. Content lives in your repository as TypeScript, validated by the same types your app uses.`})}),(0,Y.jsx)(SC,{label:`Hero image`,children:(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Y.jsx)(`div`,{className:`grid place-items-center w-40 h-24 rounded-md bg-bg-float-raised border border-border-float text-fg-secondary-alt`,children:(0,Y.jsx)(sy,{size:18,strokeWidth:1.5})}),(0,Y.jsxs)(`div`,{className:`text-xs text-fg-secondary-alt space-y-1 pt-1`,children:[(0,Y.jsx)(`p`,{className:`font-mono`,children:`/public/val/hero_a1b2c.png`}),(0,Y.jsx)(`p`,{children:`2400 × 1260 · image/png`})]})]})}),(0,Y.jsx)(SC,{label:`Body`,children:(0,Y.jsxs)(`div`,{className:`rounded-md border border-border-float bg-bg-surface`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 h-8 border-b border-border-float`,children:[[`B`,`I`,`H2`,`H3`].map(e=>(0,Y.jsx)(`span`,{className:`grid place-items-center w-6 h-6 rounded text-[0.6875rem] text-fg-secondary`,children:e},e)),(0,Y.jsx)(`span`,{className:`grid place-items-center w-6 h-6 rounded text-fg-secondary`,children:(0,Y.jsx)(uy,{size:12})})]}),(0,Y.jsxs)(`div`,{className:`px-3 py-3 space-y-3 text-[0.9375rem] text-fg-primary leading-relaxed`,children:[(0,Y.jsx)(`p`,{children:`Content lives next to your code. Every change is a patch, every patch is reviewable, and publishing is a commit.`}),(0,Y.jsx)(`p`,{className:`text-fg-secondary`,children:`Editors get a real editor. Developers get types, validation and a diff.`})]})]})}),(0,Y.jsx)(SC,{label:`Sections`,hint:`4 items`,children:(0,Y.jsx)(`ul`,{className:`space-y-1.5`,children:[`Hero`,`Features`,`Logos`,`Call to action`].map(e=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-2 h-10 px-2.5 rounded-md border border-border-float bg-bg-surface`,children:[(0,Y.jsx)(ay,{size:14,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem]`,children:e}),(0,Y.jsx)(Iv,{size:14,className:`ml-auto shrink-0 text-fg-secondary-alt`})]},e))})})]})]})}function SC({label:e,hint:t,children:n}){return(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-[0.8125rem] font-medium leading-none text-fg-primary`,children:e}),t&&(0,Y.jsx)(`span`,{className:`text-[0.6875rem] leading-none text-fg-secondary-alt`,children:t})]}),n]})}function Xce({value:e,className:t}){return(0,Y.jsx)(`div`,{className:X(`h-10 px-3 flex items-center rounded-md border border-border-float bg-bg-surface text-[0.9375rem]`,t),children:e})}function Zce({value:e}){return(0,Y.jsx)(`div`,{className:`px-3 py-2.5 rounded-md border border-border-float bg-bg-surface text-[0.9375rem] leading-relaxed text-fg-secondary`,children:e})}function CC(){let[e,t]=(0,b.useState)(()=>typeof window>`u`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches);return(0,b.useEffect)(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),n=()=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function Qce(e){let[t,n]=(0,b.useState)(e===`fields`),[r,i]=(0,b.useState)(e);return r!==e&&(i(e),n(e===`fields`)),[t,n]}function $ce({page:e,device:t,selectedFieldId:n,attachedFieldIds:r,onSelectField:i,isSelectMode:a}){let o=t=>e.fields[t]?.value??``,s=t===`mobile`,c=({id:e,as:t=`div`,className:o,children:s})=>(0,Y.jsx)(t,{"data-field-id":e,onClick:t=>{a&&(t.stopPropagation(),i(e))},className:X(`relative transition-shadow`,a&&`cursor-pointer rounded-[2px] shadow-[0_0_0_1px_var(--bg-page-selection-soft)] hover:shadow-[0_0_0_2px_var(--bg-page-selection)]`,a&&(n===e||r.includes(e))&&`shadow-[0_0_0_2px_var(--bg-page-selection)]`,o),children:s});return(0,Y.jsxs)(`div`,{className:`bg-[#fdf8f3] text-[#2b1a12] font-sans`,children:[(0,Y.jsxs)(`header`,{className:X(`flex items-center gap-8 border-b border-[#e8d9c9]`,s?`px-5 h-16`:`px-10 h-20`),children:[(0,Y.jsx)(`span`,{className:`text-xl font-bold tracking-tight text-[#c2410c]`,children:`Nordic Retail`}),!s&&(0,Y.jsx)(`nav`,{className:`flex gap-6 text-sm`,children:[`Shop`,`Stores`,`Journal`,`About`].map(e=>(0,Y.jsx)(`span`,{children:e},e))})]}),(0,Y.jsxs)(`section`,{className:X(s?`px-5 py-10`:`px-10 py-16`),children:[(0,Y.jsx)(c,{id:`eyebrow`,as:`p`,className:`mb-4 inline-block text-sm font-semibold uppercase tracking-[0.2em] text-[#c2410c]`,children:o(`eyebrow`)}),(0,Y.jsx)(c,{id:`headline`,as:`h1`,className:X(`mb-6 font-bold leading-[1.05] tracking-tight`,s?`text-4xl`:`text-6xl max-w-2xl`),children:o(`headline`)}),(0,Y.jsx)(c,{id:`intro`,as:`p`,className:X(`mb-8 leading-relaxed text-[#6b4f3f]`,s?`text-base`:`text-lg max-w-xl`),children:o(`intro`)}),(0,Y.jsx)(c,{id:`ctaLabel`,as:`span`,className:`inline-block rounded-full bg-[#c2410c] px-6 py-3 text-sm font-medium text-white`,children:o(`ctaLabel`)})]}),(0,Y.jsx)(`section`,{className:X(s?`px-5 pb-12`:`px-10 pb-20`),children:(0,Y.jsx)(`div`,{className:X(`grid gap-5`,s?`grid-cols-1`:`grid-cols-3`),children:[1,2,3].map(e=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(c,{id:`cat${e}Image`,className:`mb-3 grid aspect-[4/5] place-items-center rounded-lg bg-[#efe1d3] text-[#c9ab8e]`,children:(0,Y.jsx)(sy,{size:28,strokeWidth:1.25})}),(0,Y.jsx)(c,{id:`cat${e}Title`,as:`p`,className:`font-medium`,children:o(`cat${e}Title`)}),(0,Y.jsx)(c,{id:`cat${e}Price`,as:`p`,className:`text-sm text-[#6b4f3f]`,children:o(`cat${e}Price`)})]},e))})}),(0,Y.jsxs)(`section`,{className:X(`bg-[#f3e7da]`,s?`px-5 py-10`:`px-10 py-16`),children:[(0,Y.jsx)(c,{id:`storyTitle`,as:`h2`,className:X(`mb-4 font-bold tracking-tight`,s?`text-2xl`:`text-4xl`),children:o(`storyTitle`)}),(0,Y.jsx)(c,{id:`storyBody`,as:`p`,className:X(`leading-relaxed text-[#6b4f3f]`,s?`text-base`:`text-lg max-w-2xl`),children:o(`storyBody`)})]}),(0,Y.jsx)(`footer`,{className:X(`border-t border-[#e8d9c9] text-sm text-[#6b4f3f]`,s?`px-5 py-8`:`px-10 py-10`),children:(0,Y.jsx)(c,{id:`footerNote`,as:`span`,className:`inline-block`,children:o(`footerNote`)})})]})}var wC={desktop:hae,tablet:Pae,mobile:Dae};function ele({device:e,onDeviceChange:t,scale:n,onZoomIn:r,onZoomOut:i,onFit:a,isPicking:o,onPickingChange:s,onReload:c,isRefreshing:l,className:u}){return(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1 rounded-lg border border-border-float bg-bg-float p-1 shadow-lg`,`max-w-[calc(100%-1.5rem)] overflow-x-auto scrollbar-none [&>*]:shrink-0`,u),children:[Object.keys(wC).map(n=>{let r=wC[n];return(0,Y.jsx)(`button`,{type:`button`,"aria-label":`${n} width`,"aria-pressed":e===n,onClick:()=>t(n),className:X(`grid h-7 w-7 place-items-center rounded-md`,e===n?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:(0,Y.jsx)(r,{size:14})},n)}),(0,Y.jsx)(TC,{}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Zoom out`,onClick:i,className:`grid h-7 w-7 place-items-center rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:(0,Y.jsx)(yy,{size:14})}),(0,Y.jsxs)(`span`,{className:`w-11 text-center text-[0.6875rem] tabular-nums text-fg-secondary`,children:[Math.round(n*100),`%`]}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Zoom in`,onClick:r,className:`grid h-7 w-7 place-items-center rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:(0,Y.jsx)(Oy,{size:14})}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Fit page to screen`,onClick:a,className:`grid h-7 w-7 place-items-center rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:(0,Y.jsx)(pae,{size:13})}),s&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(TC,{}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":o?`Stop selecting on the page`:`Select on the page`,"aria-pressed":o,title:o?`Clicking the page selects what it hits`:`Clicking the page follows links, as a visitor would`,onClick:()=>s(!o),className:X(`grid h-7 w-7 place-items-center rounded-md`,o?`bg-bg-page-selection-fill text-fg-brand-primary ring-1 ring-inset ring-bg-page-selection`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:(0,Y.jsx)(by,{size:14})})]}),c&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(TC,{}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":l?`Updating the page`:`Reload the page`,title:l?`The page is re-rendering with your change`:`Reload the page`,onClick:c,className:X(`grid h-7 w-7 place-items-center rounded-md hover:bg-bg-float-raised hover:text-fg-primary`,l?`text-fg-brand-primary`:`text-fg-secondary`),children:(0,Y.jsx)(Sae,{size:13,className:X(l&&`animate-spin`)})})]})]})}function TC(){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`mx-0.5 h-5 w-px bg-border-float`})}var tle=.1,nle=(0,b.forwardRef)(function({pageWidth:e,scale:t,onScaleChange:n,autoFit:r=!1,onUserZoom:i,initialScroll:a,onScrollChange:o,children:s,className:c},l){let u=(0,b.useRef)(null),d=(0,b.useRef)(null),[f,p]=(0,b.useState)(0);(0,b.useEffect)(()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(()=>p(e.offsetHeight));return t.observe(e),p(e.offsetHeight),()=>t.disconnect()},[]);let m=(0,b.useRef)(t);m.current=t;let h=(0,b.useRef)(f);h.current=f;let g=(0,b.useRef)(null);(0,b.useLayoutEffect)(()=>{let e=g.current,t=u.current;e===null||!t||(g.current=null,t.scrollLeft=e.x,t.scrollTop=e.y)},[t]);let _=(0,b.useCallback)((t,r,a)=>{let o=u.current;if(!o)return;i?.();let s=m.current,c=EC(t),l=ale(o,{width:e,height:h.current},s,c,r,a);if(c===s){o.scrollLeft=l.x,o.scrollTop=l.y;return}g.current=l,m.current=c,n(c)},[e,n,i]),v=(0,b.useCallback)(()=>{let t=u.current,n=m.current;if(!t)return{x:0,y:0};let r={width:e,height:h.current};return{x:(t.scrollLeft+t.clientWidth/2-DC(t.clientWidth,r.width*n))/n,y:(t.scrollTop+t.clientHeight/2-DC(t.clientHeight,r.height*n))/n}},[e]),y=(0,b.useCallback)(()=>{let t=u.current;if(!t||h.current===0)return;let r=ile({width:e,height:h.current},{width:t.clientWidth,height:t.clientHeight});if(g.current={x:0,y:0},r===m.current){t.scrollLeft=0,t.scrollTop=0,g.current=null;return}m.current=r,n(r)},[e,n]),x=(0,b.useRef)(null),S=(0,b.useCallback)(e=>{if(e.phase===`end`){x.current=null;return}let t=rle(e.span,m.current);if(e.phase===`start`||x.current===null){x.current={span:t,center:e.center,scale:m.current};return}let n=x.current;n.span<=0||_(n.scale*(t/n.span),e.center,n.center)},[_]);(0,b.useImperativeHandle)(l,()=>({zoomBy:(e,t)=>{let n=t??v();_(m.current*e,n,n)},fit:y,pinch:S}),[_,v,y,S]);let[C,w]=(0,b.useState)({width:0,height:0});(0,b.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>w(t=>t.width===e.clientWidth&&t.height===e.clientHeight?t:{width:e.clientWidth,height:e.clientHeight}),n=new ResizeObserver(t);return n.observe(e),t(),()=>n.disconnect()},[]),(0,b.useEffect)(()=>{!r||f===0||C.height===0||y()},[r,f,C,e,y]),(0,b.useEffect)(()=>{let t=u.current;if(!t)return;let n=n=>{if(!n.ctrlKey&&!n.metaKey)return;n.preventDefault();let r=t.getBoundingClientRect(),i=m.current,a={width:e,height:h.current},o={x:(n.clientX-r.left+t.scrollLeft-DC(t.clientWidth,a.width*i))/i,y:(n.clientY-r.top+t.scrollTop-DC(t.clientHeight,a.height*i))/i};_(i*(1-n.deltaY/300),o,o)};return t.addEventListener(`wheel`,n,{passive:!1}),()=>t.removeEventListener(`wheel`,n)},[_,e]);let T=(0,b.useRef)(null),E=(0,b.useCallback)(()=>{!o||T.current!==null||(T.current=requestAnimationFrame(()=>{T.current=null;let e=u.current;e&&o({x:e.scrollLeft,y:e.scrollTop})}))},[o]);(0,b.useEffect)(()=>()=>{T.current!==null&&cancelAnimationFrame(T.current)},[]);let D=(0,b.useRef)(!1);return(0,b.useLayoutEffect)(()=>{if(D.current||!a)return;let e=u.current;!e||f===0||(D.current=!0,e.scrollLeft=a.x,e.scrollTop=a.y)},[a,f]),(0,Y.jsx)(`div`,{ref:u,onScroll:E,className:X(`relative overflow-auto overscroll-contain bg-bg-canvas scrollbar-slim`,`[background-image:radial-gradient(var(--border-float)_1px,transparent_1px)] [background-size:24px_24px]`,c),children:(0,Y.jsx)(`div`,{className:`flex h-max min-h-full w-max min-w-full items-center justify-center`,children:(0,Y.jsx)(`div`,{style:{width:e*t,height:f*t},className:`shrink-0`,children:(0,Y.jsx)(`div`,{ref:d,style:{width:e,transform:`scale(${t})`,transformOrigin:`0 0`},className:`will-change-transform`,children:s})})})})});function rle(e,t){return e*t}function EC(e){return Math.min(2,Math.max(tle,e))}function ile(e,t){let n={width:Math.max(1,t.width-48),height:Math.max(1,t.height-48)};return EC(Math.min(n.width/e.width,n.height/e.height))}function DC(e,t){return Math.max(0,(e-t)/2)}function ale(e,t,n,r,i,a){let o=DC(e.clientWidth,t.width*n)-e.scrollLeft+i.x*n,s=DC(e.clientHeight,t.height*n)-e.scrollTop+i.y*n;return{x:DC(e.clientWidth,t.width*r)+a.x*r-o,y:DC(e.clientHeight,t.height*r)+a.y*r-s}}function ole({page:e,selectedFieldId:t,onSelectField:n,onChangeField:r,onAttachField:i,attachedFieldIds:a,isDevMode:o}){let[s,c]=(0,b.useState)(``),l=(0,b.useRef)(null),u=(0,b.useMemo)(()=>{let t=s.trim().toLowerCase();return e.sections.map(n=>({...n,fields:n.fieldIds.map(t=>e.fields[t]).filter(e=>e!==void 0&&(t===``||e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)))})).filter(e=>e.fields.length>0)},[e,s]);return(0,b.useEffect)(()=>{if(!t)return;let e=l.current,n=e?.querySelector(`[data-field-row="${t}"]`);if(!e||!n)return;let r=n.offsetTop-e.offsetTop,i=r+n.offsetHeight;r<e.scrollTop?e.scrollTo({top:r,behavior:`smooth`}):i>e.scrollTop+e.clientHeight&&e.scrollTo({top:i-e.clientHeight,behavior:`smooth`})},[t]),(0,Y.jsxs)(`div`,{className:`flex h-full flex-col bg-bg-float`,children:[(0,Y.jsx)(`div`,{className:`shrink-0 border-b border-border-float px-3 py-2`,children:(0,Y.jsx)(gC,{value:s,onChange:c,placeholder:`Filter fields…`})}),(0,Y.jsxs)(`div`,{ref:l,className:`min-h-0 flex-1 overflow-y-auto pb-4 scrollbar-slim`,children:[u.length===0&&(0,Y.jsx)(`p`,{className:`px-4 py-6 text-xs text-fg-secondary-alt`,children:`No fields match this filter.`}),u.map(e=>(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h3`,{className:`px-4 pb-1.5 pt-4 text-[0.6875rem] font-semibold uppercase tracking-wider text-fg-secondary-alt`,children:e.name}),e.fields.map(e=>(0,Y.jsx)(cle,{field:e,selected:t===e.id,attached:a.includes(e.id),onSelect:()=>n(e.id),onChange:t=>r(e.id,t),onAttach:()=>i(e.id),isDevMode:o},e.id))]},e.id))]})]})}var sle={string:Ry,text:Ry,richtext:Ry,image:sy,link:uy};function cle({field:e,selected:t,attached:n,onSelect:r,onChange:i,onAttach:a,isDevMode:o}){let s=sle[e.type];return(0,Y.jsxs)(`div`,{"data-field-row":e.id,onFocusCapture:r,onClick:r,className:X(`px-3 py-2 border-l-2 transition-colors`,t?`border-bg-page-selection bg-bg-float-raised`:`border-transparent hover:bg-bg-float-raised/60`),children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5`,children:[(0,Y.jsx)(s,{size:12,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem] font-medium`,children:e.label}),n&&(0,Y.jsx)(`span`,{title:`Attached to the assistant`,className:`text-fg-secondary-alt`,children:(0,Y.jsx)(Ey,{size:11})}),(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},className:`ml-auto rounded px-1.5 py-0.5 text-[0.625rem] text-fg-secondary-alt opacity-0 transition-opacity hover:bg-bg-float-raised hover:text-fg-primary focus:opacity-100 group-hover:opacity-100 [div:hover>div>&]:opacity-100`,children:`Ask AI`})]}),e.type===`image`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border-float bg-bg-surface px-2 py-1.5`,children:[(0,Y.jsx)(`span`,{className:`grid h-8 w-8 shrink-0 place-items-center rounded bg-bg-float-raised text-fg-secondary-alt`,children:(0,Y.jsx)(sy,{size:13})}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-[0.6875rem] text-fg-secondary`,children:e.value})]}):e.type===`text`||e.type===`richtext`?(0,Y.jsx)(`textarea`,{value:e.value,onChange:e=>i(e.target.value),rows:3,"aria-label":e.label,className:`w-full resize-none rounded-md border border-border-float bg-bg-surface px-2 py-1.5 text-xs leading-relaxed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`}):(0,Y.jsx)(`input`,{value:e.value,onChange:e=>i(e.target.value),"aria-label":e.label,className:X(`h-8 w-full rounded-md border border-border-float bg-bg-surface px-2 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,e.type===`link`&&`font-mono`)}),o&&(0,Y.jsx)(`p`,{className:`mt-1 truncate font-mono text-[0.625rem] text-fg-secondary-alt`,children:e.sourcePath})]})}function OC(e){let t=``,n=!1;for(let r=0;r<e.length;r++){let i=e[r]!==e[r].toLowerCase();r===0?(t+=e[r].toUpperCase(),n=!1):n&&i?(n=!1,t+=` `+e[r].toUpperCase()):(t+=e[r].toLowerCase(),n=!0)}return t=t.replace(/[-–—]/g,``),t}function kC(e){let t=e;(t.endsWith(`.val.ts`)||t.endsWith(`.val.js`))&&(t=t.slice(0,-7));let n=t.match(/^\(([^)]+)\)$/);if(n)return OC(n[1]);if(t.match(/^\[\[\.\.\.([^\]]+)\]\]$/)||t.match(/^\[\.\.\.([^\]]+)\]$/))return`…`;let r=t.match(/^\[([^\]]+)\]$/);return OC(r?r[1]:t)}var AC=u(s(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()}))());function jC({path:e,type:t}){return(0,Y.jsx)(`div`,{id:e,className:(0,AC.default)(`pt-6`,{"w-full flex items-center justify-center":t===`module`,"text-left":t!==`module`}),children:(0,Y.jsx)(hy,{size:t===`module`?24:16,className:`animate-spin`})})}function MC({path:e,type:t}){let[n,r]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let e=setTimeout(()=>{r(!0)},2e3);return()=>{clearTimeout(e)}},[]),e.length===0?null:n?(0,Y.jsxs)(`div`,{id:e,className:`pt-6 flex flex-col items-center justify-center text-center gap-4`,children:[(0,Y.jsx)(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-full bg-bg-tertiary`,children:(0,Y.jsx)(Bv,{className:`w-8 h-8 text-fg-tertiary`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`h2`,{className:`text-lg font-semibold text-fg-primary`,children:`Not Found`}),(0,Y.jsxs)(`p`,{className:`text-sm text-fg-tertiary max-w-md`,children:[`The path`,` `,(0,Y.jsx)(`code`,{className:`px-1.5 py-0.5 bg-bg-tertiary rounded text-fg-secondary font-mono text-xs`,children:e}),` `,`can no longer be found.`]})]}),(0,Y.jsxs)(`button`,{onClick:()=>{window.location.href=window.origin+Jf(`/val`)},className:`mt-2 inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-fg-primary bg-bg-secondary hover:bg-bg-tertiary rounded-md transition-colors`,children:[(0,Y.jsx)(Mie,{className:`w-4 h-4`}),`Go Home`]})]}):(0,Y.jsx)(jC,{path:e,type:t})}function NC({error:e,path:t}){return(0,Y.jsx)(`div`,{id:t,children:(0,Y.jsx)(`div`,{className:`p-4 bg-bg-error-primary text-fg-error-primary`,children:e})})}function PC({actualType:e,expectedType:t,path:n}){return(0,Y.jsx)(`div`,{id:n,children:(0,Y.jsxs)(`div`,{children:[`Schema mismatch: actual: `,e,` vs expected: `,t,` `]})})}function FC({error:e,path:t,schema:n}){let{addPatch:r,patchPath:i}=vb(t);return(0,Y.jsxs)(`div`,{id:t,className:`flex justify-between items-center px-2 py-3 rounded-lg bg-bg-error-primary text-fg-primary`,children:[(0,Y.jsxs)(`div`,{children:[`Source error: `,e]}),(0,Y.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[n&&n.status===`success`&&n.data.type!==`file`&&n.data.type!==`image`&&(0,Y.jsx)(t_,{variant:`outline`,className:`hover:bg-bg-error-secondary-hover`,onClick:()=>{r([{op:`replace`,path:i,value:Cp(n.data)}],n.data.type)},children:`Fix`}),(0,Y.jsx)(Ly,{size:16})]})]})}var IC=`/val/compare`,LC=`/val/errors`,RC=b.createContext(new Proxy({},{get:()=>{throw Error(`ValRouter context not provided`)}})),zC=`/val/~`,lle=[`p`,`error-field`,`field`],BC=`data-val-studio-path`;function VC(e,t){let n=Array.from(e.querySelectorAll(`[${BC}]`));for(let e of n)if(e.getAttribute(BC)===t)return e;return null}function HC(e,t=100){let n=()=>{let r=document.getElementById(`val-shadow-root`)?.shadowRoot,i=r?VC(r,e):null;i&&r?UC(r,i):t>0&&(t--,setTimeout(n,100))};n()}var ule=16;function UC(e,t){let n=e.getElementById(`val-content-area`);if(n){let e=Number(n.dataset.scrollClearance),r=Number.isFinite(e)?e:ule,i=t.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTo({top:Math.max(0,n.scrollTop+i-r),behavior:`smooth`})}t.classList.remove(`val-scroll-highlight`),t.offsetWidth,t.classList.add(`val-scroll-highlight`),t.addEventListener(`animationend`,()=>t.classList.remove(`val-scroll-highlight`),{once:!0})}function WC({children:e,overlay:t}){let[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)([]),[m,h]=(0,b.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`session`)),g=(0,b.useRef)([]);(0,b.useEffect)(()=>{let e=()=>{if(h(new URLSearchParams(location.search).get(`session`)),location.pathname===`/val/compare`||location.pathname===`/val/compare/`){l(!0),d(!1),p([]),a(``),r(!0);return}if(location.pathname===`/val/errors`||location.pathname===`/val/errors/`){d(!0),l(!1),p(new URLSearchParams(location.search).getAll(`error-field`)),a(``),r(!0);return}l(!1),d(!1),p([]);let e=location.pathname.indexOf(zC);if(e>-1){let t=new URLSearchParams(location.search).get(`p`),n=location.pathname.slice(e+6)+(t?`?p=${t}`:``);a(n);let r=new URLSearchParams(location.search).get(`field`);s(r||null);let i=g.current.pop();if(i)setTimeout(()=>{let e=document.getElementById(`val-shadow-root`)?.shadowRoot?.getElementById(`val-content-area`);i&&e?.scrollTo(0,i)},50);else if(location.hash){let e=decodeURIComponent(location.hash.slice(1));window.history.replaceState(null,``,location.pathname+location.search),e&&HC(e)}else r&&HC(r)}else(location.pathname===`/val`||location.pathname===`/val/`||location.pathname===zC)&&a(``);r(!0)};return e(),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},[]);let _=(0,b.useCallback)((e,n)=>{let r=e===IC,i=e===LC,a=i&&n?.errorFields&&n.errorFields.length>0?`?`+n.errorFields.map(e=>`error-field=${encodeURIComponent(e)}`).join(`&`):``,o=r?IC:i?LC+a:`${zC}${e}`,s=new URLSearchParams(typeof window>`u`?``:window.location.search);for(let e of lle)s.delete(e);let c=m;if(t&&c==null)try{c=sessionStorage.getItem(Zf)}catch{c=null}c?s.set(`session`,c):s.delete(`session`);let l=!r&&!i&&n?.scrollToPath!==e?n?.scrollToPath??null:null;l&&s.set(`field`,l);let u=s.toString();return u?`${o}${o.includes(`?`)?`&`:`?`}${u}`:o},[t,m]),v=(0,b.useCallback)((e,n)=>{let r=e===IC,i=e===LC,o=_(e,n),c=!r&&!i&&n?.scrollToPath!==e?n?.scrollToPath??null:null;if(l(r),d(i),p(i?n?.errorFields??[]:[]),a(r||i?``:e),s(c),t)window.location.href=o+(n?.scrollToPath?`#${encodeURIComponent(n.scrollToPath)}`:``);else{let e=document.getElementById(`val-shadow-root`)?.shadowRoot,t=e?.getElementById(`val-content-area`),r=t?.scrollTop,i=n?.scrollToPath;if(i&&e){let t=10,n=()=>{let r=VC(e,i);r?UC(e,r):t>0&&(t--,setTimeout(n,100))};setTimeout(n,100)}else t?.scrollTo(0,0);r!==void 0&&g.current.push(r),n?.replace?window.history.replaceState(null,``,o):window.history.pushState(null,``,o)}},[t,_]),y=(0,b.useCallback)((e,n)=>{if(h(e),t)return;let r=new URL(window.location.href);e==null?r.searchParams.delete(`session`):r.searchParams.set(`session`,e);let i=r.pathname+r.search+r.hash;n?.replace?window.history.replaceState(null,``,i):window.history.pushState(null,``,i)},[t]);return(0,Y.jsx)(RC.Provider,{value:{hardLink:!!t,currentSourcePath:i,focusedSourcePath:o,navigate:v,hrefOf:_,ready:n,isCompareView:c,isErrorsView:u,errorFields:f,sessionParam:m,setSessionParam:y},children:e})}function GC(){let{navigate:e,hrefOf:t,currentSourcePath:n,focusedSourcePath:r,ready:i,isCompareView:a,isErrorsView:o,errorFields:s}=(0,b.useContext)(RC);return{navigate:e,hrefOf:t,currentSourcePath:n,focusedSourcePath:r,ready:i,isCompareView:a,isErrorsView:o,errorFields:s}}function KC(){let{sessionParam:e,setSessionParam:t}=(0,b.useContext)(RC);return{sessionParam:e,setSessionParam:t}}function dle(){var e=[...arguments];return(0,b.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var qC=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function JC(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function YC(e){return`nodeType`in e}function XC(e){return e?JC(e)?e:YC(e)?e.ownerDocument?.defaultView??window:window:window}function ZC(e){let{Document:t}=XC(e);return e instanceof t}function QC(e){return!JC(e)&&e instanceof XC(e).HTMLElement}function $C(e){return e instanceof XC(e).SVGElement}function ew(e){return e?JC(e)?e.document:YC(e)?ZC(e)?e:QC(e)||$C(e)?e.ownerDocument:document:document:document}var tw=qC?b.useLayoutEffect:b.useEffect;function nw(e){let t=(0,b.useRef)(e);return tw(()=>{t.current=e}),(0,b.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function fle(){let e=(0,b.useRef)(null);return[(0,b.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,b.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function rw(e,t){t===void 0&&(t=[e]);let n=(0,b.useRef)(e);return tw(()=>{n.current!==e&&(n.current=e)},t),n}function iw(e,t){let n=(0,b.useRef)();return(0,b.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function aw(e){let t=nw(e),n=(0,b.useRef)(null);return[n,(0,b.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function ow(e){let t=(0,b.useRef)();return(0,b.useEffect)(()=>{t.current=e},[e]),t.current}var sw={};function cw(e,t){return(0,b.useMemo)(()=>{if(t)return t;let n=sw[e]==null?0:sw[e]+1;return sw[e]=n,e+`-`+n},[e,t])}function lw(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var uw=lw(1),dw=lw(-1);function ple(e){return`clientX`in e&&`clientY`in e}function fw(e){if(!e)return!1;let{KeyboardEvent:t}=XC(e.target);return t&&e instanceof t}function mle(e){if(!e)return!1;let{TouchEvent:t}=XC(e.target);return t&&e instanceof t}function pw(e){if(mle(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return ple(e)?{x:e.clientX,y:e.clientY}:null}var mw=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[mw.Translate.toString(e),mw.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),hw=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function hle(e){return e.matches(hw)?e:e.querySelector(hw)}var gle={display:`none`};function _le(e){let{id:t,value:n}=e;return b.createElement(`div`,{id:t,style:gle},n)}function vle(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return b.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function yle(){let[e,t]=(0,b.useState)(``);return{announce:(0,b.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var gw=(0,b.createContext)(null);function ble(e){let t=(0,b.useContext)(gw);(0,b.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function xle(){let[e]=(0,b.useState)(()=>new Set),t=(0,b.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,b.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Sle={draggable:`
|
|
134
134
|
To pick up a draggable item, press the space bar.
|
|
135
135
|
While dragging, use the arrow keys to move the item.
|
|
@@ -212,7 +212,7 @@ Defaulting to \`null\`.`}HY(ZY,`getInvalidValueError`);var QY=mRe,_Re=gRe,$Y=b.f
|
|
|
212
212
|
`),slice:t}}function o1(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new wX(vX.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
213
213
|
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=uZ.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=DBe(n),ZQ&&OBe(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||$X.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!wBe.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=kBe(d1(s,+u[1],+u[2]),u[4]);else if(s=wX.maxOpen(TBe(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=d1(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var wBe=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function TBe(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&c1(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=l1(a[a.length-1],i.length));let n=s1(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return vX.from(a)}return e}function s1(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,vX.from(e));return e}function c1(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=c1(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(vX.from(s1(n,e,i+1))))}}function l1(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,l1(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(vX.empty,!0);return e.copy(n.append(r))}function u1(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=u1(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(vX.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function d1(e,t,n){return t<e.openStart&&(e=new wX(u1(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new wX(u1(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var f1={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]};function p1(){return document.implementation.createHTMLDocument(`title`)}var m1=null;function EBe(e){let t=window.trustedTypes;if(!t)return e;if(!m1){if(m1=t.defaultPolicy)try{return m1.createHTML(e)}catch{}m1=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return m1.createHTML(e)}function DBe(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=p1(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&f1[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=EBe(e),a)for(let e=0;e<a.length;e++)r=r.querySelector(a[e])||r;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=r.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return r}function OBe(e){let t=e.querySelectorAll(WQ?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function kBe(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{t.checkAttrs(r[e+1])}catch{break}i=vX.from(t.create(r[e+1],i)),a++,o++}return new wX(i,a,o)}var h1={},g1={},ABe={touchstart:!0,touchmove:!0},jBe=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function MBe(e){for(let t in h1){let n=h1[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{PBe(e,t)&&!y1(e,t)&&(e.editable||!(t.type in g1))&&n(e,t)},ABe[t]?{passive:!0}:void 0)}KQ&&e.dom.addEventListener(`input`,()=>null),v1(e)}function _1(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function NBe(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function v1(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>y1(e,t))})}function y1(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function PBe(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function FBe(e,t){!y1(e,t)&&h1[t.type]&&(e.editable||!(t.type in g1))&&h1[t.type](e,t)}g1.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!D1(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(XQ&&WQ&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),qQ&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,NQ(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||CBe(e,n)?n.preventDefault():_1(e,`key`)}},g1.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},g1.keypress=(e,t)=>{let n=t;if(D1(e)||!n.charCode||n.ctrlKey&&!n.altKey||JQ&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof oQ)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function b1(e){return{left:e.clientX,top:e.clientY}}function IBe(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function x1(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function S1(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function LBe(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&cQ.isSelectable(r)?(S1(e,new cQ(n),`pointer`),!0):!1}function RBe(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof cQ&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(cQ.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(S1(e,cQ.create(e.state.doc,i),`pointer`),!0)}function zBe(e,t,n,r,i){return x1(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?RBe(e,n):LBe(e,n))}function BBe(e,t,n,r){return x1(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function VBe(e,t,n,r){return x1(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||HBe(e,n,r)}function HBe(e,t,n){if(n.button!=0)return!1;let r=C1(e,t,!0),i=e.state.doc;return r?(S1(e,r,`pointer`),r instanceof oQ&&i.eq(e.state.doc)&&(e.input.mouseDown=new WBe(e,r)),!0):!1}function C1(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?oQ.create(r,0,r.content.size):null;let i=r.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),a=i.before(e);if(t.inlineContent)return oQ.create(r,a+1,a+1+t.content.size);if(n&&cQ.isSelectable(t))return cQ.create(r,a)}return null}function w1(e){return A1(e)}var T1=JQ?`metaKey`:`ctrlKey`;h1.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=w1(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&IBe(n,e.input.lastClick)&&!n[T1]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(b1(n));o&&(a==`singleClick`?e.input.mouseDown=new UBe(e,o,n,!!r):(a==`doubleClick`?BBe:VBe)(e,o.pos,o.inside,n)?n.preventDefault():_1(e,`pointer`))};var E1=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},UBe=class extends E1{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[T1],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof cQ&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&HQ&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),_1(e,`pointer`)}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||L$(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(b1(e))),this.updateAllowDefault(e),this.allowDefault||!t?_1(this.view,`pointer`):zBe(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||KQ&&this.mightDrag&&!this.mightDrag.node.isAtom||WQ&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(S1(this.view,nQ.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):_1(this.view,`pointer`)}move(e){this.updateAllowDefault(e),_1(this.view,`pointer`),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},WBe=class extends E1{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),_1(this.view,`pointer`);let t=this.view.posAtCoords(b1(e)),n=t&&C1(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[a,o]=n.from<i.from?[i.to,n.from]:[i.from,n.to];S1(this.view,oQ.create(r,a,o),`pointer`)}};h1.touchstart=e=>{e.input.lastTouch=Date.now(),w1(e),_1(e,`pointer`)},h1.touchmove=e=>{e.input.lastTouch=Date.now(),_1(e,`pointer`)},h1.contextmenu=e=>w1(e);function D1(e,t){return e.composing?!0:KQ&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var GBe=XQ?5e3:-1;g1.compositionstart=g1.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof oQ&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||WQ&&YQ&&KBe(e)))e.markCursor=e.state.storedMarks||n.marks(),A1(e,!0),e.markCursor=null;else if(A1(e,!t.selection.empty),HQ&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}O1(e,GBe)};function KBe(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}g1.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,O1(e,20))};function O1(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>A1(e),t))}function k1(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function qBe(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Rze(t.focusNode,t.focusOffset),r=zze(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function A1(e,t=!1){if(!(XQ&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),k1(e),t||e.docView&&e.docView.dirty){let n=F$(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function JBe(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var j1=BQ&&VQ<15||qQ&&Uze<604;h1.copy=g1.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=j1?null:n.clipboardData,{dom:o,text:s}=a1(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):JBe(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function YBe(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function XBe(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?M1(e,r.value,null,i,t):M1(e,r.textContent,r.innerHTML,i,t)},50)}function M1(e,t,n,r,i){let a=o1(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||wX.empty)))return!0;if(!a)return!1;let o=YBe(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function N1(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}g1.paste=(e,t)=>{let n=t;if(e.composing&&!XQ)return;let r=j1?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&M1(e,N1(r),r.getData(`text/html`),i,n)?n.preventDefault():XBe(e,n)};var P1=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},ZBe=JQ?`altKey`:`ctrlKey`;function F1(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[ZBe]:!n}h1.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(b1(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof cQ?i.to-1:i.to))){if(r&&r.mightDrag)o=cQ.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=cQ.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=a1(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!WQ||GQ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(j1?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,j1||n.dataTransfer.setData(`text/plain`,c),e.dragging=new P1(l,F1(e,n),o)},h1.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},g1.dragover=g1.dragenter=(e,t)=>t.preventDefault(),g1.drop=(e,t)=>{try{QBe(e,t,e.dragging)}finally{e.dragging=null}};function QBe(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(b1(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=o1(e,N1(t.dataTransfer),j1?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&F1(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||wX.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?HZ(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&cQ.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new cQ(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(W$(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}h1.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&L$(e)},20))},h1.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},h1.beforeinput=(e,t)=>{if(XQ&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,NQ(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in g1)h1[e]=g1[e];function I1(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var L1=class e{constructor(e,t){this.toDOM=e,this.spec=t||V1,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new z1(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&I1(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},R1=class e{constructor(e,t){this.attrs=e,this.spec=t||V1}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new z1(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&I1(this.attrs,t.attrs)&&I1(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},$Be=class e{constructor(e,t){this.attrs=e,this.spec=t||V1}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new z1(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&I1(this.attrs,t.attrs)&&I1(this.spec,t.spec)}destroy(){}},z1=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new L1(n,r))}static inline(t,n,r,i){return new e(t,n,new R1(r,i))}static node(t,n,r,i){return new e(t,n,new $Be(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof R1}get widget(){return this.type instanceof L1}},B1=[],V1={},H1=class e{constructor(e,t){this.local=e.length?e:B1,this.children=t.length?t:B1}static create(e,t){return t.length?J1(t,e,0,V1):U1}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==U1||e.maps.length==0?this:this.mapInner(e,t,0,0,n||V1)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?eVe(this.children,o||[],t,n,r,i,a):o?new e(o.sort(Y1),B1):U1}add(t,n){return n.length?this==U1?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=K1(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,J1(s,e,o+1,V1)),a+=3}});let o=G1(a?q1(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(Y1):this.local,i||this.children)}remove(e){return e.length==0||this==U1?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==U1?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):U1}forChild(t,n){if(this==U1)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof R1){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(Y1),B1);return r?new W1([t,r]):t}return r||U1}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return X1(this.localsInner(e))}localsInner(e){if(this==U1)return B1;if(e.inlineContent||!this.local.some(R1.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof R1||t.push(this.local[e]);return t}forEachSet(e){e(this)}};H1.empty=new H1([],[]),H1.removeOverlap=X1;var U1=H1.empty,W1=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,V1));return e.from(r)}forChild(t,n){if(n.isLeaf)return H1.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=U1&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length){if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}}return t?X1(n?t:t.sort(Y1)):B1}static from(t){switch(t.length){case 0:return U1;case 1:return t[0];default:return new e(t.every(e=>e instanceof H1)?t:t.reduce((e,t)=>e.concat(t instanceof H1?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function eVe(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==U1?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=J1(tVe(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new H1(t.sort(Y1),s)}function G1(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new z1(i.from+t,i.to+t,i.type))}return n}function tVe(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function K1(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function q1(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function J1(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=K1(e,t,o+n);if(s){a=!0;let e=J1(s,t,n+o+1,r);e!=U1&&i.push(o,o+t.nodeSize,e)}});let o=G1(a?q1(e):e,-n).sort(Y1);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new H1(o,i):U1}function Y1(e,t){return e.from-t.from||e.to-t.to}function X1(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),Z1(t,i+1,a.copy(r.to,a.to)));continue}a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),Z1(t,i,r.copy(a.from,r.to)));break}}return t}function Z1(e,t,n){for(;t<e.length&&Y1(n,e[t])>0;)t++;e.splice(t,0,n)}function Q1(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=U1&&t.push(r)}),e.cursorWrapper&&t.push(H1.create(e.state.doc,[e.cursorWrapper.deco])),W1.from(t)}var nVe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rVe=BQ&&VQ<=11,iVe=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},aVe=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new iVe,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);BQ&&VQ<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():KQ&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),rVe&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,nVe)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(G$(this.view)){if(this.suppressingSelectionUpdates)return L$(this.view);if(BQ&&VQ<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&OQ(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=TQ(n))t.add(n);for(let r=e.anchorNode;r;r=TQ(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&G$(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||WQ&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(HQ&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||cVe(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&MQ(n)&&(c=F$(e))&&c.eq(nQ.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,L$(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),oVe(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,lVe(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||L$(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(BQ&&VQ<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?wQ(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?wQ(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}return e.type==`attributes`?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},$1=new WeakMap,e0=!1;function oVe(e){if(!$1.has(e)&&($1.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=HQ,e0)return;console.warn(`ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.`),e0=!0}}function t0(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return OQ(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function sVe(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return t0(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?t0(e,n):null}function cVe(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function lVe(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function uVe(e,t,n,r){let{node:i,fromOffset:a,toOffset:o,from:s,to:c}=e.docView.parseRange(t,n),l=e.domSelectionRange(),u,d=l.anchorNode;if(d&&e.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:l.anchorOffset}],MQ(l)||u.push({node:l.focusNode,offset:l.focusOffset})),WQ&&e.input.lastKeyCode===8)for(let e=o;e>a;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||$X.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:dVe(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var dVe=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(KQ&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(t.parentNode.lastChild==t||KQ&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},fVe=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function pVe(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=F$(e,t);if(n&&!e.state.selection.eq(n)){if(WQ&&XQ&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,NQ(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=uVe(e,t,n,i),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=gVe(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(qQ&&e.input.lastIOSEnter>Date.now()-225||XQ)&&i.some(e=>e.nodeType==1&&!fVe.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,NQ(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof oQ&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=n0(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof oQ&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),BQ&&VQ<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((qQ&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,NQ(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&hVe(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,NQ(8,`Backspace`)))){XQ&&WQ&&e.domObserver.suppressSelectionUpdates();return}WQ&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),XQ&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,NQ(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=n0(e,n.doc,l.sel);t&&!(WQ&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||BQ&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v){if(h.pos==g.pos){BQ&&VQ<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>L$(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=mVe(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x())}else e.dispatch(x())}function n0(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:W$(e,t.resolve(n.anchor),t.resolve(n.head))}function mVe(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(vX.from(l).eq(e))return{mark:s,type:o}}function hVe(e,t,n,r,i){if(n-t<=i.pos-r.pos||r0(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(r0(a,!0,!0));return!o.parent.isTextblock||o.pos>n||r0(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function r0(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function gVe(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c<a&&o<s){let e=r<=a&&r>=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l<a){let e=r<=a&&r>=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var i0=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new jBe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(l0),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=s0(this),o0(this),this.nodeViews=c0(this),this.docView=C$(this.state.doc,a0(this),Q1(this),this.dom,this),this.domObserver=new aVe(this,(e,t,n,r)=>pVe(this,e,t,n,r)),this.domObserver.start(),MBe(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&v1(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(l0),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(k1(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=c0(this);vVe(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&v1(this),this.editable=s0(this),o0(this);let o=Q1(this),s=a0(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&Kze(this);if(i){this.domObserver.stop();let t=l&&(BQ||WQ)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&_Ve(n.selection,e.selection);if(l){let n=WQ?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qBe(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=C$(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&gBe(this)&&i.delaySelUpdate())?L$(this,t):(H$(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&qze(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof cQ){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&$Q(this,t.getBoundingClientRect(),e)}else $Q(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new P1(e.slice,e.move,r<0?void 0:cQ.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(BQ){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Jze(this.dom),L$(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return $ze(this,e)}coordsAtPos(e,t=1){return c$(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return iBe(this,t||this.state,e)}pasteHTML(e,t){return M1(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return M1(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return a1(this,e)}destroy(){this.docView&&(NBe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Q1(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ize())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return FBe(this,e)}domSelectionRange(){let e=this.domSelection();return e?KQ&&this.root.nodeType===11&&Vze(this.dom.ownerDocument)==this.dom&&sVe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};i0.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function a0(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[z1.node(0,e.state.doc.content.size,t)]}function o0(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:z1.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function s0(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function _Ve(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function c0(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function vVe(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function l0(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}var u0=200,d0=function(){};d0.prototype.append=function(e){return e.length?(e=d0.from(e),!this.length&&e||e.length<u0&&this.leafAppend(e)||this.length<u0&&e.leafPrepend(this)||this.appendInner(e)):this},d0.prototype.prepend=function(e){return e.length?d0.from(e).append(this):this},d0.prototype.appendInner=function(e){return new yVe(this,e)},d0.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?d0.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},d0.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},d0.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},d0.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},d0.from=function(e){return e instanceof d0?e:e&&e.length?new f0(e):d0.empty};var f0=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=u0)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=u0)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(d0);d0.empty=new f0([]);var yVe=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(d0),bVe=500,p0=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new m0(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new m0(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new m0(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>SVe&&(s=xVe(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new SZ;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new m0(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new m0(i,o,l))}else r.push(new m0(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new m0(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>bVe&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new m0(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(d0.from(i.reverse()),a)}};p0.empty=new p0(d0.empty,0);function xVe(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var m0=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},h0=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},SVe=20;function CVe(e,t,n,r){let i=n.getMeta(x0),a;if(i)return i.historyState;n.getMeta(EVe)&&(e=new h0(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(x0))return o.getMeta(x0).redo?new h0(e.done.addTransform(n,void 0,r,b0(t)),e.undone,g0(n.mapping.maps),e.prevTime,e.prevComposition):new h0(e.done,e.undone.addTransform(n,void 0,r,b0(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!wVe(n,e.prevRanges)),s=o?_0(e.prevRanges,n.mapping):g0(n.mapping.maps);return new h0(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,b0(t)),p0.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new h0(e.done.rebased(n,a),e.undone.rebased(n,a),_0(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new h0(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),_0(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function wVe(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function g0(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function _0(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function TVe(e,t,n){let r=b0(t),i=x0.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new h0(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(x0,{redo:n,historyState:c})}var v0=!1,y0=null;function b0(e){let t=e.plugins;if(y0!=t){v0=!1,y0=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){v0=!0;break}}return v0}var x0=new CQ(`history`),EVe=new CQ(`closeHistory`);function S0(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new bQ({key:x0,state:{init(){return new h0(p0.empty,p0.empty,null,0,-1)},apply(t,n,r){return CVe(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?w0:n==`historyRedo`?T0:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function C0(e,t){return(n,r)=>{let i=x0.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=TVe(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var w0=C0(!1,!0),T0=C0(!0,!0);function E0(e={}){return new bQ({view(t){return new DVe(t,e)}})}var DVe=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=HZ(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},OVe=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),kVe=typeof navigator<`u`&&/Win/.test(navigator.platform);function AVe(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))OVe?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function jVe(e){let t=Object.create(null);for(let n in e)t[AVe(n)]=e[n];return t}function D0(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function O0(e){return new bQ({props:{handleKeyDown:k0(e)}})}function k0(e){let t=jVe(e);return function(e,n){let r=oP(n),i,a=t[D0(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[D0(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(kVe&&n.ctrlKey&&n.altKey)&&(i=nP[n.keyCode])&&i!=r){let r=t[D0(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var A0=class e extends nQ{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):nQ.near(r)}content(){return wX.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new MVe(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!NVe(e)||!PVe(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!cQ.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};A0.prototype.visible=!1,A0.findFrom=A0.findGapCursorFrom,nQ.jsonID(`gapcursor`,A0);var MVe=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return A0.valid(t)?new A0(t):nQ.near(t)}};function j0(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function NVe(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||j0(e.type))return!0;if(e.inlineContent)return!1}}return!0}function PVe(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||j0(e.type))return!0;if(e.inlineContent)return!1}}return!0}function M0(){return new bQ({props:{decorations:RVe,createSelectionBetween(e,t,n){return t.pos==n.pos&&A0.valid(n)?new A0(n):null},handleClick:IVe,handleKeyDown:FVe,handleDOMEvents:{beforeinput:LVe}}})}var FVe=k0({ArrowLeft:N0(`horiz`,-1),ArrowRight:N0(`horiz`,1),ArrowUp:N0(`vert`,-1),ArrowDown:N0(`vert`,1)});function N0(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof oQ){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=A0.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new A0(c))),!0):!1}}function IVe(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!A0.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&cQ.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new A0(r))),!0)}function LVe(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof A0))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=vX.empty;for(let e=r.length-1;e>=0;e--)i=vX.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new wX(i,0,0));return a.setSelection(oQ.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function RVe(e){if(!(e.selection instanceof A0))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,H1.create(e.doc,[z1.widget(e.selection.head,t,{key:`gapcursor`})])}var zVe=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),BVe=Object.prototype.hasOwnProperty;function P0(e,t){return BVe.call(e,t)}function F0(e){if(Array.isArray(e)){for(var t=Array(e.length),n=0;n<t.length;n++)t[n]=``+n;return t}if(Object.keys)return Object.keys(e);var r=[];for(var i in e)P0(e,i)&&r.push(i);return r}function I0(e){switch(typeof e){case`object`:return JSON.parse(JSON.stringify(e));case`undefined`:return null;default:return e}}function L0(e){for(var t=0,n=e.length,r;t<n;){if(r=e.charCodeAt(t),r>=48&&r<=57){t++;continue}return!1}return!0}function R0(e){return e.indexOf(`/`)===-1&&e.indexOf(`~`)===-1?e:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function z0(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function B0(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(B0(e[t]))return!0}else if(typeof e==`object`){for(var r=F0(e),i=r.length,a=0;a<i;a++)if(B0(e[r[a]]))return!0}}return!1}function V0(e,t){var n=[e];for(var r in t){var i=typeof t[r]==`object`?JSON.stringify(t[r],null,2):t[r];i!==void 0&&n.push(r+`: `+i)}return n.join(`
|
|
214
214
|
`)}var H0=function(e){zVe(t,e);function t(t,n,r,i,a){var o=this.constructor,s=e.call(this,V0(t,{name:n,index:r,operation:i,tree:a}))||this;return s.name=n,s.index=r,s.operation=i,s.tree=a,Object.setPrototypeOf(s,o.prototype),s.message=V0(t,{name:n,index:r,operation:i,tree:a}),s}return t}(Error),VVe=c({JsonPatchError:()=>U0,_areEquals:()=>X0,applyOperation:()=>K0,applyPatch:()=>q0,applyReducer:()=>WVe,deepClone:()=>HVe,getValueByPointer:()=>G0,validate:()=>Y0,validator:()=>J0}),U0=H0,HVe=I0,W0={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=G0(n,this.path);r&&=I0(r);var i=K0(n,{op:`remove`,path:this.from}).removed;return K0(n,{op:`add`,path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=G0(n,this.from);return K0(n,{op:`add`,path:this.path,value:I0(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:X0(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},UVe={add:function(e,t,n){return L0(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){return{newDocument:n,removed:e.splice(t,1)[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:W0.move,copy:W0.copy,test:W0.test,_get:W0._get};function G0(e,t){if(t==``)return e;var n={op:`_get`,path:t};return K0(e,n),n.value}function K0(e,t,n,r,i,a){if(n===void 0&&(n=!1),r===void 0&&(r=!0),i===void 0&&(i=!0),a===void 0&&(a=0),n&&(typeof n==`function`?n(t,0,e,t.path):J0(t,0)),t.path===``){var o={newDocument:e};if(t.op===`add`)return o.newDocument=t.value,o;if(t.op===`replace`)return o.newDocument=t.value,o.removed=e,o;if(t.op===`move`||t.op===`copy`)return o.newDocument=G0(e,t.from),t.op===`move`&&(o.removed=e),o;if(t.op===`test`){if(o.test=X0(e,t.value),o.test===!1)throw new U0(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o.newDocument=e,o}if(t.op===`remove`)return o.removed=e,o.newDocument=null,o;if(t.op===`_get`)return t.value=e,o;if(n)throw new U0("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,a,t,e);return o}r||(e=I0(e));var s=(t.path||``).split(`/`),c=e,l=1,u=s.length,d=void 0,f=void 0,p=void 0;for(p=typeof n==`function`?n:J0;;){if(f=s[l],f&&f.indexOf(`~`)!=-1&&(f=z0(f)),i&&(f==`__proto__`||f==`prototype`&&l>0&&s[l-1]==`constructor`))throw TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&d===void 0&&(c[f]===void 0?d=s.slice(0,l).join(`/`):l==u-1&&(d=t.path),d!==void 0&&p(t,0,e,d)),l++,Array.isArray(c)){if(f===`-`)f=c.length;else if(n&&!L0(f))throw new U0(`Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index`,`OPERATION_PATH_ILLEGAL_ARRAY_INDEX`,a,t,e);else L0(f)&&(f=~~f);if(l>=u){if(n&&t.op===`add`&&f>c.length)throw new U0(`The specified index MUST NOT be greater than the number of elements in the array`,`OPERATION_VALUE_OUT_OF_BOUNDS`,a,t,e);var o=UVe[t.op].call(t,c,f,e);if(o.test===!1)throw new U0(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}}else if(l>=u){var o=W0[t.op].call(t,c,f,e);if(o.test===!1)throw new U0(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}if(c=c[f],n&&l<u&&(!c||typeof c!=`object`))throw new U0(`Cannot perform operation at the desired path`,`OPERATION_PATH_UNRESOLVABLE`,a,t,e)}}function q0(e,t,n,r,i){if(r===void 0&&(r=!0),i===void 0&&(i=!0),n&&!Array.isArray(t))throw new U0(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);r||(e=I0(e));for(var a=Array(t.length),o=0,s=t.length;o<s;o++)a[o]=K0(e,t[o],n,!0,i,o),e=a[o].newDocument;return a.newDocument=e,a}function WVe(e,t,n){var r=K0(e,t);if(r.test===!1)throw new U0(`Test operation failed`,`TEST_OPERATION_FAILED`,n,t,e);return r.newDocument}function J0(e,t,n,r){if(typeof e!=`object`||!e||Array.isArray(e))throw new U0(`Operation is not an object`,`OPERATION_NOT_AN_OBJECT`,t,e,n);if(!W0[e.op])throw new U0("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,t,e,n);if(typeof e.path!=`string`)throw new U0("Operation `path` property is not a string",`OPERATION_PATH_INVALID`,t,e,n);if(e.path.indexOf(`/`)!==0&&e.path.length>0)throw new U0('Operation `path` property must start with "/"',`OPERATION_PATH_INVALID`,t,e,n);if((e.op===`move`||e.op===`copy`)&&typeof e.from!=`string`)throw new U0("Operation `from` property is not present (applicable in `move` and `copy` operations)",`OPERATION_FROM_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&e.value===void 0)throw new U0("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&B0(e.value))throw new U0("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED`,t,e,n);if(n){if(e.op==`add`){var i=e.path.split(`/`).length,a=r.split(`/`).length;if(i!==a+1&&i!==a)throw new U0("Cannot perform an `add` operation at the desired path",`OPERATION_PATH_CANNOT_ADD`,t,e,n)}else if(e.op===`replace`||e.op===`remove`||e.op===`_get`){if(e.path!==r)throw new U0(`Cannot perform the operation at a path that does not exist`,`OPERATION_PATH_UNRESOLVABLE`,t,e,n)}else if(e.op===`move`||e.op===`copy`){var o=Y0([{op:`_get`,path:e.from,value:void 0}],n);if(o&&o.name===`OPERATION_PATH_UNRESOLVABLE`)throw new U0(`Cannot perform the operation from a path that does not exist`,`OPERATION_FROM_UNRESOLVABLE`,t,e,n)}}}function Y0(e,t,n){try{if(!Array.isArray(e))throw new U0(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);if(t)q0(I0(t),I0(e),n||!0);else{n||=J0;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(e){if(e instanceof U0)return e;throw e}}function X0(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){var n=Array.isArray(e),r=Array.isArray(t),i,a,o;if(n&&r){if(a=e.length,a!=t.length)return!1;for(i=a;i--!==0;)if(!X0(e[i],t[i]))return!1;return!0}if(n!=r)return!1;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(i=a;i--!==0;)if(!t.hasOwnProperty(s[i]))return!1;for(i=a;i--!==0;)if(o=s[i],!X0(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}var GVe=c({compare:()=>e2,generate:()=>Q0,observe:()=>QVe,unobserve:()=>ZVe}),Z0=new WeakMap,KVe=function(){function e(e){this.observers=new Map,this.obj=e}return e}(),qVe=function(){function e(e,t){this.callback=e,this.observer=t}return e}();function JVe(e){return Z0.get(e)}function YVe(e,t){return e.observers.get(t)}function XVe(e,t){e.observers.delete(t.callback)}function ZVe(e,t){t.unobserve()}function QVe(e,t){var n=[],r,i=JVe(e);if(!i)i=new KVe(e),Z0.set(e,i);else{var a=YVe(i,t);r=a&&a.observer}if(r)return r;if(r={},i.value=I0(e),t){r.callback=t,r.next=null;var o=function(){Q0(r)},s=function(){clearTimeout(r.next),r.next=setTimeout(o)};typeof window<`u`&&(window.addEventListener(`mouseup`,s),window.addEventListener(`keyup`,s),window.addEventListener(`mousedown`,s),window.addEventListener(`keydown`,s),window.addEventListener(`change`,s))}return r.patches=n,r.object=e,r.unobserve=function(){Q0(r),clearTimeout(r.next),XVe(i,r),typeof window<`u`&&(window.removeEventListener(`mouseup`,s),window.removeEventListener(`keyup`,s),window.removeEventListener(`mousedown`,s),window.removeEventListener(`keydown`,s),window.removeEventListener(`change`,s))},i.observers.set(t,new qVe(t,r)),r}function Q0(e,t){t===void 0&&(t=!1);var n=Z0.get(e.object);$0(n.value,e.object,e.patches,``,t),e.patches.length&&q0(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function $0(e,t,n,r,i){if(t!==e){typeof t.toJSON==`function`&&(t=t.toJSON());for(var a=F0(t),o=F0(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if(P0(t,l)&&(t[l]!==void 0||u===void 0||Array.isArray(t)!==!1)){var d=t[l];typeof u==`object`&&u&&typeof d==`object`&&d&&Array.isArray(u)===Array.isArray(d)?$0(u,d,n,r+`/`+R0(l),i):u!==d&&(i&&n.push({op:`test`,path:r+`/`+R0(l),value:I0(u)}),n.push({op:`replace`,path:r+`/`+R0(l),value:I0(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:`test`,path:r+`/`+R0(l),value:I0(u)}),n.push({op:`remove`,path:r+`/`+R0(l)}),s=!0):(i&&n.push({op:`test`,path:r,value:e}),n.push({op:`replace`,path:r,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c<a.length;c++){var l=a[c];!P0(e,l)&&t[l]!==void 0&&n.push({op:`add`,path:r+`/`+R0(l),value:I0(t[l])})}}}function e2(e,t,n){n===void 0&&(n=!1);var r=[];return $0(e,t,r,``,n),r}Object.assign({},VVe,GVe,{JsonPatchError:H0,deepClone:I0,escapePathComponent:R0,unescapePathComponent:z0});var $Ve=`custom_style_`;function eHe(e){return Object.entries(e).map(([e,t])=>`${e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t}`).join(`; `)}function tHe(e,t){let n=new Map((t??[]).map(e=>[e.variant,e.label])),r={doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}},text:{group:`inline`},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}},heading:{attrs:{level:{default:1}},content:`inline*`,group:`block`,defining:!0,parseDOM:[1,2,3,4,5,6].map(e=>({tag:`h${e}`,attrs:{level:e}})),toDOM(e){return[`h${e.attrs.level}`,0]}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return[`blockquote`,0]}},code_block:{content:`text*`,marks:``,group:`block`,code:!0,defining:!0,parseDOM:[{tag:`pre`,preserveWhitespace:`full`}],toDOM(){return[`pre`,[`code`,0]]}},list_item:{content:`paragraph block*`,parseDOM:[{tag:`li`}],toDOM(){return[`li`,0]},defining:!0},bullet_list:{content:`list_item+`,group:`block`,parseDOM:[{tag:`ul`}],toDOM(){return[`ul`,0]}},ordered_list:{attrs:{order:{default:1}},content:`list_item+`,group:`block`,parseDOM:[{tag:`ol`,getAttrs(e){let t=e;return{order:t.hasAttribute(`start`)?+(t.getAttribute(`start`)||1):1}}}],toDOM(e){return e.attrs.order===1?[`ol`,0]:[`ol`,{start:e.attrs.order},0]}},image:{inline:!0,attrs:{src:{},alt:{default:null},previewUrl:{default:null},width:{default:null},height:{default:null},mimeType:{default:null}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[src]`,getAttrs(e){let t=e;return{src:t.getAttribute(`src`),alt:t.getAttribute(`alt`)}}}],toDOM(e){return[`img`,{src:e.attrs.src,alt:e.attrs.alt}]}}};return e.button&&(r.button_atom={inline:!0,atom:!0,group:`inline`,attrs:{variant:{default:`default`}},parseDOM:[{tag:`button[data-variant][data-atom]`,getAttrs(e){return{variant:e.getAttribute(`data-variant`)}}}],toDOM(e){let t=e.attrs.variant,r=n.get(t)??t;return[`button`,{"data-variant":t,"data-atom":`true`,class:`inline-flex items-center rounded bg-bg-brand-secondary px-2 py-0.5 text-sm font-medium text-fg-brand-secondary cursor-default`,contenteditable:`false`},r]}},r.button_editable={inline:!0,content:`text*`,group:`inline`,attrs:{variant:{default:`default`},href:{default:null}},parseDOM:[{tag:`button[data-variant]:not([data-atom])`,getAttrs(e){let t=e;return{variant:t.getAttribute(`data-variant`),href:t.getAttribute(`data-href`)||null}}}],toDOM(e){let t={"data-variant":e.attrs.variant,class:`inline-flex items-center rounded bg-bg-brand-secondary px-2 py-0.5 text-sm font-medium text-fg-brand-secondary`};return e.attrs.href&&(t[`data-href`]=e.attrs.href),[`button`,t,0]}}),e.details&&(r.details_summary={content:`inline*`,defining:!0,parseDOM:[{tag:`summary`}],toDOM(){return[`summary`,0]}},r.details={attrs:{variant:{default:`details`}},content:`details_summary block+`,group:`block`,defining:!0,parseDOM:[{tag:`details`,getAttrs(e){return{variant:e.getAttribute(`data-variant`)||`details`}}}],toDOM(e){let t=e.attrs.variant,n={open:``};return t!==`details`&&(n[`data-variant`]=t),[`details`,n,0]}}),r}function nHe(e,t){let n={};if(n.bold={parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=bold`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return[`strong`,0]}},n.italic={parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`}],toDOM(){return[`em`,0]}},n.strikethrough={parseDOM:[{tag:`s`},{tag:`del`},{style:`text-decoration=line-through`}],toDOM(){return[`del`,0]}},n.code={parseDOM:[{tag:`code`}],toDOM(){return[`code`,0]}},n.link={attrs:{href:{}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`)||``}}}],toDOM(e){return[`a`,{href:e.attrs.href,rel:`noopener noreferrer`},0]}},t)for(let[e,r]of Object.entries(t)){let t=`${$Ve}${e}`,i=eHe(r.css);n[t]={parseDOM:[{tag:`span[data-style="${e}"]`}],toDOM(){return[`span`,{"data-style":e,style:i},0]}}}return n}function rHe(e={}){let t=`features`in e||`buttonVariants`in e||`detailsVariants`in e||`styleConfig`in e,n=t?e.features??{}:e,r=t?e.buttonVariants:void 0,i=t?e.styleConfig??n.styles:n.styles,a={bold:n.bold??!0,italic:n.italic??!0,strikethrough:n.strikethrough??!0,code:n.code??!0,link:n.link??!0,image:n.image??!0,h1:n.h1??!0,h2:n.h2??!0,h3:n.h3??!0,h4:n.h4??!0,h5:n.h5??!0,h6:n.h6??!0,bulletList:n.bulletList??!0,orderedList:n.orderedList??!0,blockquote:n.blockquote??!0,details:n.details??!1,codeBlock:n.codeBlock??!0,hardBreak:n.hardBreak??!0,button:n.button??!1,fixedToolbar:n.fixedToolbar??!0,floatingToolbar:n.floatingToolbar??!0,gutter:n.gutter??!0,styles:n.styles};return new ZX({nodes:tHe(a,r),marks:nHe(a,i)})}var iHe=`custom_style_`,aHe={bold:`bold`,italic:`italic`,"line-through":`strikethrough`,code:`code`};function t2(e,t){let n=aHe[e];if(n){let e=t.marks[n];return e?e.create():null}let r=`${iHe}${e}`,i=t.marks[r];return i?i.create():null}function n2(e,t){let n=e.map(e=>r2(e,t));return n.length===0&&n.push(t.node(`paragraph`)),t.node(`doc`,null,n)}function r2(e,t){switch(e.tag){case`p`:return t.node(`paragraph`,null,a2(e.children,t));case`h1`:case`h2`:case`h3`:case`h4`:case`h5`:case`h6`:{let n=parseInt(e.tag[1],10);return t.node(`heading`,{level:n},a2(e.children,t))}case`ul`:return t.node(`bullet_list`,null,e.children.map(e=>i2(e,t)));case`ol`:return t.node(`ordered_list`,null,e.children.map(e=>i2(e,t)));case`blockquote`:return t.node(`blockquote`,null,e.children.map(e=>r2(e,t)));case`pre`:return t.node(`code_block`,null,e.children[0]?[t.text(e.children[0])]:[]);case`details`:{let n=e.children[0],r=t.node(`details_summary`,null,a2(n.children,t)),i=e.children.slice(1).map(e=>r2(e,t)),a=e.variant??`details`;return t.node(`details`,{variant:a},[r,...i])}}}function i2(e,t){let n=e.children.map(e=>r2(e,t));return t.node(`list_item`,null,n)}function a2(e,t){let n=[];for(let r of e)if(typeof r==`string`)r.length>0&&n.push(t.text(r));else if(r.tag===`br`)t.nodes.hard_break&&n.push(t.node(`hard_break`));else if(r.tag===`span`){let e=r.styles.map(e=>t2(e,t)).filter(e=>e!==null);r.children[0].length>0&&n.push(t.text(r.children[0],e))}else if(r.tag===`a`){if(t.marks.link){let e=t.marks.link.create({href:r.href});for(let i of r.children)if(typeof i==`string`)i.length>0&&n.push(t.text(i,[e]));else if(i.tag===`span`){let r=i.styles.map(e=>t2(e,t)).filter(e=>e!==null);i.children[0].length>0&&n.push(t.text(i.children[0],[e,...r]))}}}else if(r.tag===`img`){if(t.nodes.image){let e=typeof r.src==`string`?null:r.src;n.push(t.node(`image`,{src:e?e.path:r.src,alt:r.alt??null,width:e?.width??null,height:e?.height??null,mimeType:e?.mimeType??null}))}}else if(r.tag===`button`){if(r.children===!1)t.nodes.button_atom&&n.push(t.node(`button_atom`,{variant:r.variant}));else if(t.nodes.button_editable){let e=r.children[0];n.push(t.node(`button_editable`,{variant:r.variant,href:r.href??null},e.length>0?[t.text(e)]:[]))}}return n}function o2(e){let t=[];return e.forEach(e=>{let n=s2(e);n&&t.push(n)}),t}function s2(e){switch(e.type.name){case`paragraph`:return{tag:`p`,children:l2(e)};case`heading`:return{tag:`h${e.attrs.level}`,children:l2(e)};case`bullet_list`:return{tag:`ul`,children:c2(e)};case`ordered_list`:return{tag:`ol`,children:c2(e)};case`blockquote`:{let t=[];return e.forEach(e=>{let n=s2(e);n&&t.push(n)}),{tag:`blockquote`,children:t}}case`code_block`:return{tag:`pre`,children:[e.textContent]};case`details`:{let t=e.attrs.variant,n={tag:`summary`,children:[]},r=[];e.forEach(e=>{if(e.type.name===`details_summary`)n={tag:`summary`,children:l2(e)};else{let t=s2(e);t&&r.push(t)}});let i={tag:`details`,children:[n,...r]};return t!==`details`&&(i.variant=t),i}default:return null}}function c2(e){let t=[];return e.forEach(e=>{if(e.type.name===`list_item`){let n=[];e.forEach(e=>{let t=s2(e);t&&n.push(t)}),t.push({tag:`li`,children:n})}}),t}function l2(e){let t=[];return e.forEach(e=>{if(e.isText){let n=e.text||``,r=e.marks;if(r.length===0)t.push(n);else{let e=r.find(e=>e.type.name===`link`),i=r.filter(e=>e.type.name!==`link`);if(e){let r=e.attrs.href;if(i.length===0)oHe(t,r,n);else{let e={tag:`span`,styles:u2(i),children:[n]};sHe(t,r,e)}}else{let e=u2(i);e.length>0?t.push({tag:`span`,styles:e,children:[n]}):t.push(n)}}}else if(e.type.name===`hard_break`)t.push({tag:`br`});else if(e.type.name===`image`){let n=e.attrs.src,r=e.attrs.width,i=e.attrs.height,a=e.attrs.mimeType,o={tag:`img`,src:{path:n,...r!==null&&i!==null&&a!==null?{width:r,height:i,mimeType:a}:{}},...e.attrs.alt?{alt:e.attrs.alt}:{}};t.push(o)}else if(e.type.name===`button_atom`)t.push({tag:`button`,variant:e.attrs.variant,children:!1});else if(e.type.name===`button_editable`){let n={tag:`button`,variant:e.attrs.variant,children:[e.textContent]};e.attrs.href&&(n.href=e.attrs.href),t.push(n)}}),t}function oHe(e,t,n){let r=e[e.length-1];r&&typeof r==`object`&&r.tag===`a`&&r.href===t?r.children.push(n):e.push({tag:`a`,href:t,children:[n]})}function sHe(e,t,n){let r=e[e.length-1];r&&typeof r==`object`&&r.tag===`a`&&r.href===t?r.children.push(n):e.push({tag:`a`,href:t,children:[n]})}var cHe=`custom_style_`;function u2(e){let t=[];for(let n of e)switch(n.type.name){case`bold`:t.push(`bold`);break;case`italic`:t.push(`italic`);break;case`strikethrough`:t.push(`line-through`);break;case`code`:t.push(`code`);break;default:n.type.name.startsWith(cHe)&&t.push(n.type.name.slice(13))}return t}var d2=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function lHe(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var uHe=(e,t,n)=>{let r=lHe(e,n);if(!r)return!1;let i=p2(r);if(!i){let n=r.blockRange(),i=n&&FZ(n);return i!=null&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(g2(e,i,t,-1))return!0;if(r.parent.content.size==0&&(f2(a,`end`)||cQ.isSelectable(a)))for(let n=r.depth;;n--){let o=UZ(e.doc,r.before(n),r.after(n),wX.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(f2(a,`end`)?nQ.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):cQ.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1};function f2(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var dHe=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=p2(r)}let o=a&&a.nodeBefore;return!o||!cQ.isSelectable(o)?!1:(t&&t(e.tr.setSelection(cQ.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function p2(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function fHe(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var pHe=(e,t,n)=>{let r=fHe(e,n);if(!r)return!1;let i=m2(r);if(!i)return!1;let a=i.nodeAfter;if(g2(e,i,t,1))return!0;if(r.parent.content.size==0&&(f2(a,`start`)||cQ.isSelectable(a))){let n=UZ(e.doc,r.before(),r.after(),wX.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(f2(a,`start`)?nQ.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):cQ.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},mHe=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=m2(r)}let o=a&&a.nodeAfter;return!o||!cQ.isSelectable(o)?!1:(t&&t(e.tr.setSelection(cQ.create(e.doc,a.pos)).scrollIntoView()),!0)};function m2(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var hHe=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&FZ(i);return a!=null&&(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},gHe=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
215
|
-
`).scrollIntoView()),!0)};function h2(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var _He=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=h2(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(nQ.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},vHe=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof lQ||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=h2(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(oQ.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},yHe=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(BZ(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&FZ(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function bHe(e){return(t,n)=>{if(t.selection instanceof cQ&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!BZ(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof oQ||t.selection instanceof lQ)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=h2(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=BZ(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,BZ(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var xHe=bHe(),SHe=(e,t)=>(t&&t(e.tr.setSelection(new lQ(e.doc))),!0);function CHe(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||VZ(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function g2(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&CHe(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=vX.empty;for(let e=o.length-1;e>=0;e--)s=vX.from(o[e].create(null,s));s=vX.from(i.copy(s));let c=e.tr.step(new MZ(t.pos-1,r,t.pos,r,new wX(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&VZ(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:nQ.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&FZ(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&f2(a,`start`,!0)&&f2(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=vX.empty;for(let e=o.length-1;e>=0;e--)r=vX.from(o[e].copy(r));n(e.tr.step(new MZ(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new wX(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function _2(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(oQ.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var wHe=_2(-1),THe=_2(1);function v2(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&IZ(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function y2(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t))){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function EHe(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function DHe(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new rQ(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new rQ(r,i))}return t}function b2(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!EHe(n.doc,l,e,i))return!1;if(o){if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=DHe(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}}return!0}}function x2(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var S2=x2(d2,uHe,dHe),C2=x2(d2,pHe,mHe),w2={Enter:x2(gHe,vHe,yHe,xHe),"Mod-Enter":_He,Backspace:S2,"Mod-Backspace":S2,"Shift-Backspace":S2,Delete:C2,"Mod-Delete":C2,"Mod-a":SHe},T2={"Ctrl-h":w2.Backspace,"Alt-Backspace":w2[`Mod-Backspace`],"Ctrl-d":w2.Delete,"Ctrl-Alt-Backspace":w2[`Mod-Delete`],"Alt-Delete":w2[`Mod-Delete`],"Alt-d":w2[`Mod-Delete`],"Ctrl-a":wHe,"Ctrl-e":THe};for(let e in w2)T2[e]=w2[e];var E2=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?T2:w2;function D2(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return OHe(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function OHe(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new LX(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new LX(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=IZ(a,n,r,t);return s?(e&&kHe(e,t,s,i,n),!0):!1}function kHe(e,t,n,r,i){let a=vX.empty;for(let e=n.length-1;e>=0;e--)a=vX.from(n[e].type.create(n[e].attrs,a));e.step(new MZ(t.start-(r?2:0),t.end,t.start,t.end,new wX(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&BZ(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function O2(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(s.type!=e)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let t=vX.empty,a=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-a;e>=i.depth-3;e--)t=vX.from(i.node(e).copy(t));let o=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;t=t.append(vX.from(e.createAndFill()));let s=i.before(i.depth-(a-1)),c=n.tr.replace(s,i.after(-o),new wX(t,4-a,0)),l=-1;c.doc.nodesBetween(s,c.doc.content.size,(e,t)=>{if(l>-1)return!1;e.isTextblock&&e.content.size==0&&(l=t+1)}),l>-1&&c.setSelection(nQ.near(c.doc.resolve(l))),r(c.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return BZ(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function k2(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?AHe(t,n,e,a):jHe(t,n,a):!0:!1}}function AHe(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new MZ(a-1,o,a,o,new wX(vX.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new LX(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=FZ(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return VZ(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function jHe(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?vX.empty:vX.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new MZ(d-+!!s,f+ +!!c,d+1,f-1,new wX((s?vX.empty:vX.from(i.copy(vX.empty))).append(c?vX.empty:vX.from(i.copy(vX.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function A2(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=vX.from(r?e.create():null),o=new wX(vX.from(e.create(null,vX.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new MZ(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var j2=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`];function M2(e){return e.h1||e.h2||e.h3||e.h4||e.h5||e.h6}var MHe={bold:!0,italic:!0,strikethrough:!0,code:!0,link:!0,image:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,bulletList:!0,orderedList:!0,blockquote:!0,details:!1,codeBlock:!0,hardBreak:!0,button:!1,fixedToolbar:!0,floatingToolbar:!0,gutter:!0};function NHe(e,t){let n={};if(n[`Mod-z`]=w0,n[`Mod-y`]=T0,n[`Mod-Shift-z`]=T0,e.marks.bold&&(!t||t.bold)&&(n[`Mod-b`]=b2(e.marks.bold)),e.marks.italic&&(!t||t.italic)&&(n[`Mod-i`]=b2(e.marks.italic)),e.marks.strikethrough&&(!t||t.strikethrough)&&(n[`Mod-Shift-x`]=b2(e.marks.strikethrough)),e.marks.code&&(!t||t.code)&&(n[`Mod-e`]=b2(e.marks.code)),e.nodes.hard_break&&(!t||t.hardBreak)){let t=e.nodes.hard_break;n[`Shift-Enter`]=(e,n)=>(n&&n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)}if(e.nodes.heading){for(let r=1;r<=6;r++)(!t||t[j2[r-1]])&&(n[`Mod-Alt-${r}`]=y2(e.nodes.heading,{level:r}));(!t||M2(t))&&(n[`Mod-Alt-0`]=y2(e.nodes.paragraph))}return e.nodes.blockquote&&(!t||t.blockquote)&&(n[`Mod-Shift-b`]=v2(e.nodes.blockquote)),e.nodes.code_block&&(!t||t.codeBlock)&&(n[`Mod-Alt-c`]=y2(e.nodes.code_block)),e.nodes.bullet_list&&(!t||t.bulletList)&&(n[`Mod-Shift-8`]=D2(e.nodes.bullet_list)),e.nodes.ordered_list&&(!t||t.orderedList)&&(n[`Mod-Shift-9`]=D2(e.nodes.ordered_list)),e.nodes.list_item&&(!t||t.bulletList||t.orderedList)&&(n.Enter=O2(e.nodes.list_item),n[`Mod-[`]=k2(e.nodes.list_item),n[`Mod-]`]=A2(e.nodes.list_item)),[O0(n),O0(E2)]}var N2=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?PHe(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function PHe(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var FHe=500;function P2({rules:e}){let t=new bQ({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return F2(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&F2(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function F2(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=s.parent.textBetween(Math.max(0,s.parentOffset-FHe),s.parentOffset,null,``)+r;for(let l=0;l<i.length;l++){let u=i[l];if(!u.inCodeMark&&s.marks().some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode===`only`)continue;let d=u.match.exec(c);if(!d||d[0].length<r.length)continue;let f=t-(d[0].length-r.length);if(!u.inCodeMark){let e=!1;if(o.doc.nodesBetween(f,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let p=u.handler(o,d,f,n);if(p)return u.undoable&&p.setMeta(a,{transform:p,from:t,to:n,text:r}),e.dispatch(p),!0}return!1}new N2(/--$/,`—`,{inCodeMark:!1}),new N2(/\.\.\.$/,`…`,{inCodeMark:!1}),new N2(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new N2(/"$/,`”`,{inCodeMark:!1}),new N2(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new N2(/'$/,`’`,{inCodeMark:!1});function I2(e,t,n=null,r){return new N2(e,(e,i,a,o)=>{let s=n instanceof Function?n(i):n,c=e.tr.delete(a,o),l=c.doc.resolve(a).blockRange(),u=l&&IZ(l,t,s);if(!u)return null;c.wrap(l,u);let d=c.doc.resolve(a-1).nodeBefore;return d&&d.type==t&&VZ(c.doc,a-1)&&(!r||r(i,d))&&c.join(a-1),c})}function L2(e,t,n=null){return new N2(e,(e,r,i,a)=>{let o=e.doc.resolve(i),s=n instanceof Function?n(r):n;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t)?e.tr.delete(i,a).setBlockType(i,i,t,s):null})}function IHe(e,t){let n=[];return e.nodes.heading&&(!t||M2(t))&&n.push(L2(/^(#{1,6})\s$/,e.nodes.heading,e=>{let n=e[1].length;return t&&!t[j2[n-1]]?!1:{level:n}})),e.nodes.blockquote&&(!t||t.blockquote)&&n.push(I2(/^\s*>\s$/,e.nodes.blockquote)),e.nodes.bullet_list&&(!t||t.bulletList)&&n.push(I2(/^\s*([-+*])\s$/,e.nodes.bullet_list)),e.nodes.ordered_list&&(!t||t.orderedList)&&n.push(I2(/^(\d+)\.\s$/,e.nodes.ordered_list,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order===+e[1])),e.nodes.code_block&&(!t||t.codeBlock)&&n.push(L2(/^```$/,e.nodes.code_block)),P2({rules:n})}function LHe(e){let t=e.schema.cached.changeSetIDs||(e.schema.cached.changeSetIDs=Object.create(null)),n=t[e.name];return n??(t[e.name]=n=Object.keys(e.schema.nodes).indexOf(e.name)+1),n}var R2={encodeCharacter:e=>e,encodeNodeStart:e=>e.type.name,encodeNodeEnd:e=>-LHe(e.type),compareTokens:(e,t)=>e===t};function z2(e,t,n,r,i){for(let a=0,o=0;a<e.childCount;a++){let s=e.child(a),c=o+s.nodeSize,l=Math.max(o,n),u=Math.min(c,r);if(l<u){if(s.isText)for(let e=l;e<u;e++)i.push(t.encodeCharacter(s.text.charCodeAt(e-o),s.marks));else s.isLeaf?i.push(t.encodeNodeStart(s)):(l==o&&i.push(t.encodeNodeStart(s)),z2(s.content,t,Math.max(o+1,l)-o-1,Math.min(c-1,u)-o-1,i),u==c&&i.push(t.encodeNodeEnd(s)))}o=c}return i}var B2=2500;function RHe(e,t){return Math.min(15,Math.max(2,Math.floor(Math.max(e,t)/10)))}function V2(e,t,n,r=R2){return Math.max(n.toA-n.fromA,n.toB,n.fromB)>B2?[n]:zHe(z2(e,r,n.fromA,n.toA,[]),z2(t,r,n.fromB,n.toB,[]),n,r.compareTokens)}function zHe(e,t,n,r){let i=0,a=e.length,o=t.length;for(;i<e.length&&i<t.length&&r(e[i],t[i]);)i++;if(i==e.length&&i==t.length)return[];for(;a>i&&o>i&&r(e[a-1],t[o-1]);)a--,o--;if(a==i||o==i||a==o&&a==i+1)return[n.slice(i,a,i,o)];let s=a-i,c=o-i,l=Math.min(B2,s+c),u=[],d=new Int16Array((l+1)*2).fill(-1);for(let f=0;f<=l;f++){for(let p=-f;p<=f;p+=2){let m=d[p+1+l],h=d[p-1+l],g=m<h?h:m+1,_=g+p;for(;g<s&&_<c&&r(e[i+g],t[i+_]);)g++,_++;if(d[p+l]=g,g>=s&&_>=c){let e=[],t=RHe(a-i,o-i),r=-1,s=-1,c=-1,m=-1,h=(i,a,o,l)=>{r>-1&&r<a+t?(r=i,c=o):(r>-1&&e.push(n.slice(r,s,c,m)),r=i,s=a,c=o,m=l)};for(let e=f-1;e>=0;e--){let t=d[p+1+l],n=d[p-1+l];t<n?(p--,g=n+i,_=g+p,h(g,g,_,_+1)):(p++,g=t+i,_=g+p,h(g,g+1,_,_)),d=u[e>>1]}return r>-1&&e.push(n.slice(r,s,c,m)),e.reverse()}}f%2==0&&u.push(d.slice())}return[n]}var H2=class e{constructor(e,t){this.length=e,this.data=t}cut(t){return t==this.length?this:new e(t,this.data)}static slice(t,n,r){if(n==r)return e.none;if(n==0&&r==e.len(t))return t;let i=[];for(let e=0,a=0;a<r;e++){let o=t[e],s=a+o.length,c=Math.min(r,s)-Math.max(n,a);c>0&&i.push(o.cut(c)),a=s}return i}static join(t,n,r){if(t.length==0)return n;if(n.length==0)return t;let i=r(t[t.length-1].data,n[0].data);if(i==null)return t.concat(n);let a=t.slice(0,t.length-1);a.push(new e(t[t.length-1].length+n[0].length,i));for(let e=1;e<n.length;e++)a.push(n[e]);return a}static len(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].length;return t}};H2.none=[];var U2=class e{constructor(e,t,n,r,i,a){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r,this.deleted=i,this.inserted=a}get lenA(){return this.toA-this.fromA}get lenB(){return this.toB-this.fromB}slice(t,n,r,i){return t==0&&r==0&&n==this.toA-this.fromA&&i==this.toB-this.fromB?this:new e(this.fromA+t,this.fromA+n,this.fromB+r,this.fromB+i,H2.slice(this.deleted,t,n),H2.slice(this.inserted,r,i))}static merge(t,n,r){if(t.length==0)return n;if(n.length==0)return t;let i=[];for(let a=0,o=0,s=t[0],c=n[0];;)if(!s&&!c)return i;else if(s&&(!c||s.toB<c.fromA)){let r=o?n[o-1].toB-n[o-1].toA:0;i.push(r==0?s:new e(s.fromA,s.toA,s.fromB+r,s.toB+r,s.deleted,s.inserted)),s=a++==t.length?null:t[a]}else if(c&&(!s||c.toA<s.fromB)){let r=a?t[a-1].toB-t[a-1].toA:0;i.push(r==0?c:new e(c.fromA-r,c.toA-r,c.fromB,c.toB,c.deleted,c.inserted)),c=o++==n.length?null:n[o]}else{let l=Math.min(s.fromB,c.fromA),u=Math.min(s.fromA,c.fromA-(a?t[a-1].toB-t[a-1].toA:0)),d=u,f=Math.min(c.fromB,s.fromB+(o?n[o-1].toB-n[o-1].toA:0)),p=f,m=H2.none,h=H2.none,g=!1,_=!1;for(;;){let e=s?l>=s.fromB?s.toB:s.fromB:2e8,i=c?l>=c.fromA?c.toA:c.fromA:2e8,u=Math.min(e,i),f=s&&l>=s.fromB,v=c&&l>=c.fromA;if(!f&&!v)break;f&&l==s.fromB&&!g&&(m=H2.join(m,s.deleted,r),d+=s.lenA,g=!0),f&&!v&&(h=H2.join(h,H2.slice(s.inserted,l-s.fromB,u-s.fromB),r),p+=u-l),v&&l==c.fromA&&!_&&(h=H2.join(h,c.inserted,r),p+=c.lenB,_=!0),v&&!f&&(m=H2.join(m,H2.slice(c.deleted,l-c.fromA,u-c.fromA),r),d+=u-l),f&&u==s.toB&&(s=a++==t.length?null:t[a],g=!1),v&&u==c.toA&&(c=o++==n.length?null:n[o],_=!1),l=u}(u<d||f<p)&&i.push(new e(u,d,f,p,m,h))}}static fromJSON(t){return new e(t.fromA,t.toA,t.fromB,t.toB,t.deleted.map(e=>new H2(e.length,e.data)),t.inserted.map(e=>new H2(e.length,e.data)))}toJSON(){return this}},W2=class e{constructor(e,t){this.config=e,this.changes=t}addSteps(t,n,r){let i=[];for(let e=0;e<n.length;e++){let t=Array.isArray(r)?r[e]:r,a=0;n[e].forEach((e,n,r,o)=>{i.push(new U2(e+a,n+a,r,o,e==n?H2.none:[new H2(n-e,t)],r==o?H2.none:[new H2(o-r,t)])),a=o-r-(n-e)})}if(i.length==0)return this;let a=G2(i,this.config.combine),o=U2.merge(this.changes,a,this.config.combine),s=o;for(let e=0;e<s.length;e++){let n=s[e];if(n.fromA==n.toA||n.fromB==n.toB||!a.some(e=>e.toB>n.fromB&&e.fromB<n.toB))continue;let r=V2(this.config.doc.content,t.content,n,this.config.encoder);(r.length!=1||r[0].fromB!=0||r[0].toB!=n.toB-n.fromB)&&(s==o&&(s=o.slice()),r.length==1?s[e]=r[0]:(s.splice(e,1,...r),e+=r.length-1))}return new e(this.config,s)}get startDoc(){return this.config.doc}map(t){let n=e=>{let n=t(e);return n===e.data?e:new H2(e.length,n)};return new e(this.config,this.changes.map(e=>new U2(e.fromA,e.toA,e.fromB,e.toB,e.deleted.map(n),e.inserted.map(n))))}changedRange(e,t){if(e==this)return null;let n=t&&BHe(t),r=n?n.toB-n.fromB-(n.toA-n.fromA):0;function i(e){return!n||e<=n.fromA?e:e+r}let a=n?n.fromB:2e8,o=n?n.toB:-2e8;function s(e,t=e){a=Math.min(e,a),o=Math.max(t,o)}let c=this.changes,l=e.changes;for(let e=0,t=0;e<c.length&&t<l.length;){let n=c[e],r=l[t];n&&r&&VHe(n,r,i)?(e++,t++):r&&(!n||i(n.fromB)>=r.fromB)?(s(r.fromB,r.toB),t++):(s(i(n.fromB),i(n.toB)),e++)}return a<=o?{from:a,to:o}:null}static create(t,n=(e,t)=>e===t?e:null,r=R2,i=[]){return new e({combine:n,doc:t,encoder:r},i)}};W2.computeDiff=V2;function G2(e,t,n=0,r=e.length){if(r==n+1)return[e[n]];let i=n+r>>1;return U2.merge(G2(e,t,n,i),G2(e,t,i,r),t)}function K2(e){let t=2e8,n=-2e8;for(let r=0;r<e.length;r++){let i=e[r];t!=2e8&&(t=i.map(t,-1),n=i.map(n,1)),i.forEach((e,r,i,a)=>{t=Math.min(t,i),n=Math.max(n,a)})}return t==2e8?null:{from:t,to:n}}function BHe(e){let t=K2(e);if(!t)return null;let n=K2(e.map(e=>e.invert()).reverse());return{fromA:n.from,toA:n.to,fromB:t.from,toB:t.to}}function VHe(e,t,n){return n(e.fromB)==t.fromB&&n(e.toB)==t.toB&&q2(e.deleted,t.deleted)&&q2(e.inserted,t.inserted)}function q2(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].length!=t[n].length||e[n].data!==t[n].data)return!1;return!0}var J2=new CQ(`diff`);function HHe(){return new bQ({key:J2,state:{init(){return{baseDoc:null,changeSet:null,decorations:H1.empty}},apply(e,t,n,r){let i=e.getMeta(J2)?.baseDoc;if(i!==void 0){if(i===null)return{baseDoc:null,changeSet:null,decorations:H1.empty};let e=W2.create(i),t=[];UHe(i,r.doc,t);let n=t.length>0?e.addSteps(r.doc,t,null):e;return{baseDoc:i,changeSet:n,decorations:Y2(n,r.doc,i)}}if(!t.baseDoc||!t.changeSet)return t;if(!e.docChanged)return{...t,decorations:t.decorations.map(e.mapping,e.doc)};let a=e.steps.map(e=>e.getMap()),o=t.changeSet.addSteps(e.doc,a,null);return{...t,changeSet:o,decorations:Y2(o,e.doc,t.baseDoc)}}},props:{decorations(e){return J2.getState(e)?.decorations??H1.empty}}})}function UHe(e,t,n){let r=e.content.size,i=t.content.size;(r!==i||!e.eq(t))&&n.push(new xZ([0,r,i]))}function Y2(e,t,n){let r=[];for(let i of e.changes){if(i.fromB<i.toB){let e=Math.max(0,i.fromB),n=Math.min(t.content.size,i.toB);e<n&&r.push(z1.inline(e,n,{class:`bg-bg-brand-primary/30`}))}if(i.fromA<i.toA&&i.deleted.length>0){let e=Math.min(i.fromB,t.content.size),a=Math.max(0,i.fromA),o=Math.min(n.content.size,i.toA),s=a<o?n.textBetween(a,o,` `):``;if(s.length>0){let t=document.createElement(`span`);t.className=`bg-bg-error-primary line-through text-fg-error-primary opacity-60`,t.textContent=s,r.push(z1.widget(e,t,{side:-1}))}}}return H1.create(t,r)}function X2(e,t){let n=e.split(`/`).filter(e=>e.length>0).map(e=>{let t=parseInt(e,10);return isNaN(t)?e:t});if(n.length===0)return null;let r=t,i=0;for(let e=0;e<n.length;e++){let t=n[e];if(typeof t==`number`){let a=0,o=!1;if(r.forEach((s,c)=>{o||(a===t&&(e===n.length-1?(i+=c,r=s):(i+=c+1,r=s),o=!0),a++)}),!o)return null}else if(t===`children`)continue;else return null}let a=i,o=a+r.nodeSize;return{from:Math.max(0,a),to:Math.min(t.content.size,o)}}var Z2=new CQ(`schemaValidation`),WHe={bullet_list:`bulletList`,ordered_list:`orderedList`,blockquote:`blockquote`,code_block:`codeBlock`,details:`details`,details_summary:`details`,hard_break:`hardBreak`,button_atom:`button`,button_editable:`button`,image:`image`},GHe={bold:`bold`,italic:`italic`,strikethrough:`strikethrough`,code:`code`,link:`link`},KHe={heading:`Heading`,bullet_list:`Bullet list`,ordered_list:`Ordered list`,blockquote:`Blockquote`,code_block:`Code block`,details:`Details`,details_summary:`Details`,hard_break:`Hard break`,button_atom:`Button`,button_editable:`Button`,image:`Image`},qHe={bold:`Bold`,italic:`Italic`,strikethrough:`Strikethrough`,code:`Code`,link:`Link`},Q2={heading:[{id:`schema.convert-to-paragraph`,label:`Convert to paragraph`}],bullet_list:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],ordered_list:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],blockquote:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],code_block:[{id:`schema.convert-to-paragraph`,label:`Convert to paragraph`}],details:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}]},JHe={bold:[{id:`schema.remove-formatting`,label:`Remove formatting`}],italic:[{id:`schema.remove-formatting`,label:`Remove formatting`}],strikethrough:[{id:`schema.remove-formatting`,label:`Remove formatting`}],code:[{id:`schema.remove-formatting`,label:`Remove formatting`}],link:[{id:`schema.remove-link`,label:`Remove link`}]};function $2(e){return`/`+e.join(`/children/`)}function e4(e,t,n,r){e.forEach((e,i,a)=>{let o=[...n,a];if(e.type.name===`heading`){let n=e.attrs.level,i=j2[n-1];if(i&&!t[i]){let t=Q2[e.type.name];r.push({path:$2(o),message:`Heading ${n} is not allowed by the current schema`,kind:`schema.violation`,...t&&{fixes:t}});return}}let s=WHe[e.type.name];if(s&&!t[s]){let t=KHe[e.type.name]??e.type.name,n=Q2[e.type.name];r.push({path:$2(o),message:`${t} is not allowed by the current schema`,kind:`schema.violation`,...n&&{fixes:n}});return}if(e.isText&&e.marks.length>0){let n=$2(o);for(let i of e.marks){let e=GHe[i.type.name];if(e&&!t[e]){let e=qHe[i.type.name]??i.type.name,t=JHe[i.type.name];r.push({path:n,message:`${e} is not allowed by the current schema`,kind:`schema.violation`,...t&&{fixes:t}})}}return}e.childCount>0&&e4(e,t,o,r)})}function t4(e,t){let n=[];return e4(e,t,[],n),n}function YHe(e,t,n){let{state:r}=e,{doc:i,schema:a}=r,o=X2(t,i);if(!o)return!1;let{from:s,to:c}=o,l=i.nodeAt(s);return l?n===`schema.convert-to-paragraph`?XHe(e,l,s,c,a):n===`schema.convert-to-paragraphs`?ZHe(e,l,s,c,a):n===`schema.remove-formatting`||n===`schema.remove-link`?QHe(e,s,c):!1:!1}function XHe(e,t,n,r,i){let a=r4(t),o=i.node(`paragraph`,null,a.length>0?[i.text(a)]:[]),s=e.state.tr.replaceWith(n,r,o);return e.dispatch(s),!0}function ZHe(e,t,n,r,i){let a=[];n4(t,i,a),a.length===0&&a.push(i.node(`paragraph`));let o=e.state.tr.replaceWith(n,r,a);return e.dispatch(o),!0}function n4(e,t,n){if(e.isTextblock){let r=r4(e);n.push(t.node(`paragraph`,null,r.length>0?[t.text(r)]:[]));return}e.forEach(e=>{n4(e,t,n)})}function QHe(e,t,n){let r=e.state.tr,i=e.state.doc.nodeAt(t);if(!i||!i.isText)return!1;for(let e of i.marks)r=r.removeMark(t,n,e.type);return e.dispatch(r),!0}function r4(e){return e.textContent}function $He(e){return new bQ({key:Z2,state:{init(t,n){return{errors:t4(n.doc,e)}},apply(t,n,r,i){return t.docChanged?{errors:t4(i.doc,e)}:n}}})}var i4=new CQ(`errors`);function a4(e){return Z2.getState(e)?.errors??[]}function eUe(){return new bQ({key:i4,state:{init(e,t){let n=a4(t);return{externalErrors:[],errors:n,errorKindClassName:{},decorations:o4(n,t.doc,{})}},apply(e,t,n,r){let i=e.getMeta(i4);if(i){let e=i.errors??t.externalErrors,n=i.errorKindClassName??t.errorKindClassName,a=a4(r),o=[...e,...a];return{externalErrors:e,errors:o,errorKindClassName:n,decorations:o4(o,r.doc,n)}}if(e.docChanged){let e=a4(r),n=[...t.externalErrors,...e];return{...t,errors:n,decorations:o4(n,r.doc,t.errorKindClassName)}}return t}},props:{decorations(e){return i4.getState(e)?.decorations??H1.empty}}})}function o4(e,t,n){if(e.length===0)return H1.empty;let r=[];for(let i of e){let e=X2(i.path,t);if(!e)continue;let{from:a,to:o}=e,s=n[i.kind]??``,c=`border-b-2 border-border-error-primary bg-bg-error-secondary/20`,l=s?`${c} ${s}`:c;r.push(z1.inline(a,o,{class:l,title:i.message,"data-error-kind":i.kind,"data-error-path":i.path}))}return H1.create(t,r)}function s4(e,t){try{let n=e.resolve(t),r=[];for(let e=1;e<=n.depth;e++){let t=n.node(e-1),i=n.index(e-1);t.type.name!==`doc`&&r.push(`children`),r.push(String(i))}let i=e.nodeAt(t);if(i){let e=n.node(n.depth);e.type.name===`doc`&&n.depth===0?r.push(String(n.index(0))):c4(e)&&!c4(i)&&(r.push(`children`),r.push(String(n.index(n.depth))))}return r.length>0?r:null}catch{return null}}function c4(e){let t=e.type.name;return t===`paragraph`||t===`heading`||t===`details_summary`}var tUe=`custom_style_`;function l4(e,t){let n=[];return e.marks.bold&&(!t||t.bold)&&n.push({label:`B`,title:`Bold (Ctrl+B)`,markType:e.marks.bold}),e.marks.italic&&(!t||t.italic)&&n.push({label:`I`,title:`Italic (Ctrl+I)`,markType:e.marks.italic}),e.marks.strikethrough&&(!t||t.strikethrough)&&n.push({label:`S`,title:`Strikethrough (Ctrl+Shift+X)`,markType:e.marks.strikethrough}),e.marks.code&&(!t||t.code)&&n.push({label:`<>`,title:`Code (Ctrl+E)`,markType:e.marks.code}),e.marks.link&&(!t||t.link)&&n.push({label:`🔗`,title:`Link`,markType:e.marks.link}),n}function u4(e,t){if(!t)return[];let n=[];for(let[r,i]of Object.entries(t)){let t=`${tUe}${r}`,a=e.marks[t];a&&n.push({label:i.label,title:i.label,markType:a})}return n}function d4(e,t){let n=[];return e.nodes.bullet_list&&(!t||t.bulletList)&&n.push({label:`•`,title:`Bullet list (Ctrl+Shift+8)`,nodeType:e.nodes.bullet_list}),e.nodes.ordered_list&&(!t||t.orderedList)&&n.push({label:`1.`,title:`Ordered list (Ctrl+Shift+9)`,nodeType:e.nodes.ordered_list}),n}function f4(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--)if(n.node(e).type===t)return!0;return!1}function nUe(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--){let r=n.node(e);if(r.type===t.nodes.bullet_list||r.type===t.nodes.ordered_list)return{depth:e,node:r}}return null}function rUe(e,t){let{state:n}=e,{$from:r}=n.selection,i=r.parent;i.type!==t.nodes.paragraph&&i.type.isTextblock&&y2(t.nodes.paragraph)(n,e.dispatch,e)}function iUe(e,t){return(n,r,i)=>{if(f4(n,e)){let e=t.nodes.list_item;return e?k2(e)(n,r):!1}let a=nUe(n,t);if(a){if(r){let{$from:t}=n.selection,i=t.before(a.depth);r(n.tr.setNodeMarkup(i,e))}return!0}if(i){let{$from:r}=n.selection,a=r.parent;if(a.type!==t.nodes.paragraph&&a.type.isTextblock)return rUe(i,t),D2(e)(i.state,i.dispatch)}return D2(e)(n,r)}}function p4(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}function m4(e,t){let n=[];if(n.push({value:`paragraph`,label:`Normal`,nodeType:e.nodes.paragraph}),e.nodes.heading)for(let r=1;r<=3;r++)(!t||t[j2[r-1]])&&n.push({value:`heading${r}`,label:`Heading ${r}`,nodeType:e.nodes.heading,attrs:{level:r}});return e.nodes.code_block&&(!t||t.codeBlock)&&n.push({value:`code_block`,label:`Code`,nodeType:e.nodes.code_block}),e.nodes.blockquote&&(!t||t.blockquote)&&n.push({value:`blockquote`,label:`Quote`,nodeType:e.nodes.blockquote}),e.nodes.details&&(!t||t.details)&&n.push({value:`details`,label:`Details`,nodeType:e.nodes.details}),n}function aUe(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--){let t=n.node(e);if(t.type.name===`details`)return`details`;if(t.type.name===`blockquote`)return`blockquote`}let r=n.parent;if(r.type.name===`heading`){let e=r.attrs.level,n=t.find(t=>t.value===`heading${e}`);if(n)return n.value}return r.type.name===`code_block`?`code_block`:`paragraph`}function oUe(e,t,n){let{state:r,dispatch:i}=e;if(n.value===`blockquote`){v2(t.nodes.blockquote)(r,i);return}if(n.value===`details`){y4(e,t,`details`);return}let{$from:a}=r.selection,o=!1;for(let e=a.depth;e>0;e--){let t=a.node(e).type.name;if(t===`blockquote`||t===`details`){o=!0;break}}if(o){hHe(r,t=>{let r=e.state.apply(t);e.updateState(r),y2(n.nodeType,n.attrs)(e.state,e.dispatch,e)});return}y2(n.nodeType,n.attrs)(r,i,e)}function h4(e,t,n){let r=e.coordsAtPos(t);if(n)return{left:Math.max(0,r.left),top:r.bottom+4};let i=e.dom.parentElement;if(!i)return null;let a=i.getBoundingClientRect();return{left:Math.max(0,r.left-a.left),top:r.bottom-a.top+4}}function sUe(e){function t(){e.onPickerStateChange(null)}function n(t,n,r){let{$from:i,from:a,to:o}=t.state.selection,s=n.isInSet(i.marks())??(i.nodeAfter?n.isInSet(i.nodeAfter.marks):null),c=s?s.attrs.href.trim():null,l=h4(t,a,!!e.getPortalContainer?.());l&&e.onPickerStateChange({kind:`catalog`,anchorRect:l,savedFrom:a,savedTo:o,currentHref:c,catalog:r})}function r(t,n){let{$from:r,from:i,to:a}=t.state.selection,o=n.isInSet(r.marks())??(r.nodeAfter?n.isInSet(r.nodeAfter.marks):null),s=o?o.attrs.href.trim():null,c=h4(t,i,!!e.getPortalContainer?.());c&&e.onPickerStateChange({kind:`url`,anchorRect:c,savedFrom:i,savedTo:a,currentHref:s,isNewLink:!o})}function i(i,a){let{state:o}=i,s=e.getLinkCatalog?.();if(s&&s.length>0){if(e.isPickerOpen()){t();return}n(i,a,s);return}if(p4(o,a)){b2(a)(o,i.dispatch,i);return}if(e.isPickerOpen()){t();return}r(i,a)}return{handleLinkToggle:i,showCatalogPicker:n,showUrlEditor:r,closePicker:t,isPickerOpen:()=>e.isPickerOpen(),destroy:t}}function g4(e){return e?.type.name===`button_atom`||e?.type.name===`button_editable`}function cUe(e){let{$from:t}=e.selection;return e.selection instanceof cQ&&g4(e.selection.node)?{pos:e.selection.from,node:e.selection.node}:g4(t.parent)?{pos:t.before(t.depth),node:t.parent}:g4(t.nodeBefore)?{pos:t.pos-t.nodeBefore.nodeSize,node:t.nodeBefore}:g4(t.nodeAfter)?{pos:t.pos,node:t.nodeAfter}:null}function _4(e,t,n,r){let i=n.children===!1,a=i?t.nodes.button_atom:t.nodes.button_editable;if(!a)return;let o={variant:n.variant};!i&&r&&(o.href=r);let s=i?a.create(o):a.create(o,n.label?[t.text(n.label)]:[]),c=cUe(e.state);if(c&&c.node){let t=e.state.tr.replaceWith(c.pos,c.pos+c.node.nodeSize,s);e.dispatch(t)}else{let{from:t}=e.state.selection,n=e.state.tr.insert(t,s);e.dispatch(n)}}function v4(e,t,n,r){let i=t.nodes.image;if(!i)return null;let a=i.create({src:n,alt:``,previewUrl:r?.previewUrl??null,width:r?.width??null,height:r?.height??null,mimeType:r?.mimeType??null}),{from:o}=e.state.selection,s=e.state.tr.insert(o,a);e.dispatch(s);let c=s4(e.state.doc,o);return c?[...c,`src`]:null}function y4(e,t,n){let r=t.nodes.details,i=t.nodes.details_summary;if(!r||!i)return;let{state:a}=e,{$from:o}=a.selection,s=i.create(null,[]),c=t.nodes.paragraph.create(),l=r.create({variant:n},[s,c]),u=o.end(o.depth===0?1:o.depth)+1,d=a.tr.insert(u,l);e.dispatch(d),e.focus()}function lUe({schema:e,features:t,styleConfig:n,canInsertImage:r,buttonVariants:i,detailsVariants:a}){return!!(l4(e,t).length>0||u4(e,n).length>0||d4(e,t).length>0||m4(e,t).length>1||e.nodes.image&&(!t||t.image)&&r||i!==void 0&&i.length>0&&(!t||t.button)||a!==void 0&&a.length>0&&(!t||t.details))}var uUe=Object.defineProperty,b4=(e,t)=>uUe(e,`name`,{value:t,configurable:!0}),x4=!1;function S4(){let[e,t]=b.useState(x4);return b.useEffect(()=>{x4||(x4=!0,t(!0))},[]),e}b4(S4,`useIsHydrated`);var C4=b.useSyncExternalStore;function w4(){return()=>{}}b4(w4,`subscribe`);function T4(){return C4(w4,()=>!0,()=>!1)}b4(T4,`useIsHydratedModern`);var dUe=typeof C4==`function`?T4:S4,fUe=Object.defineProperty,E4=(e,t)=>fUe(e,`name`,{value:t,configurable:!0}),D4=`rovingFocusGroup.onEntryFocus`,pUe={bubbles:!1,cancelable:!0},O4=`RovingFocusGroup`,[k4,A4,mUe]=KT(O4),[hUe,j4]=sm(O4,[mUe]),[gUe,_Ue]=hUe(O4),vUe=b.forwardRef(E4(function(e,t){return(0,Y.jsx)(k4.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,Y.jsx)(k4.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,Y.jsx)(yUe,{...e,ref:t})})})},`RovingFocusGroup`)),yUe=b.forwardRef(E4(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=b.useRef(null),p=am(t,f),m=nE(a),[h,g]=ng({prop:o,defaultProp:s??null,onChange:c,caller:O4}),[_,v]=b.useState(!1),y=Cm(l),x=A4(n),S=b.useRef(!1),[C,w]=b.useState(0);return b.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(D4,y),()=>e.removeEventListener(D4,y)},[y]),(0,Y.jsx)(gUe,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:b.useCallback(e=>g(e),[g]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:b.useCallback(()=>w(e=>e-1),[]),children:(0,Y.jsx)(xm.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:Qp(e.onMouseDown,()=>{S.current=!0}),onFocus:Qp(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(D4,pUe);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);P4([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:Qp(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),bUe=`RovingFocusGroupItem`,xUe=b.forwardRef(E4(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Pm(),l=a||c,u=_Ue(bUe,n),d=u.currentTabStopId===l,f=A4(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=dUe();return Nm(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),b.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,Y.jsx)(k4.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,Y.jsx)(xm.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:Qp(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:Qp(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Qp(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=N4(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?F4(n,r+1):n.slice(r+1)}setTimeout(()=>P4(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),SUe={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function M4(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}E4(M4,`getDirectionAwareKey`);function N4(e,t,n){let r=M4(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return SUe[r]}E4(N4,`getFocusIntent`);function P4(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}E4(P4,`focusFirst`);function F4(e,t){return e.map((n,r)=>e[(t+r)%e.length])}E4(F4,`wrapArray`);var CUe=vUe,wUe=xUe,TUe=Object.defineProperty,I4=(e,t)=>TUe(e,`name`,{value:t,configurable:!0}),L4=[`Enter`,` `],EUe=[`ArrowDown`,`PageUp`,`Home`],R4=[`ArrowUp`,`PageDown`,`End`],DUe=[...EUe,...R4],OUe={ltr:[...L4,`ArrowRight`],rtl:[...L4,`ArrowLeft`]},kUe={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},z4=`Menu`,[B4,AUe,jUe]=KT(z4),[V4,H4]=sm(z4,[jUe,Vh,j4]),U4=Vh(),W4=j4(),[MUe,G4]=V4(z4),[NUe,K4]=V4(z4),PUe=I4(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=U4(t),[c,l]=b.useState(null),u=b.useRef(!1),d=Cm(a),f=nE(i);return b.useEffect(()=>{let e=I4(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=I4(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),b.useEffect(()=>{if(!n)return;let e=I4(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,Y.jsx)(Uh,{...s,children:(0,Y.jsx)(MUe,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,Y.jsx)(NUe,{scope:t,onClose:b.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),q4=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e,i=U4(n);return(0,Y.jsx)(Wh,{...i,...r,ref:t})},`MenuAnchor`)),J4=`MenuPortal`,[FUe,Y4]=V4(J4,{forceMount:void 0}),IUe=I4(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=G4(J4,t);return(0,Y.jsx)(FUe,{scope:t,forceMount:n,children:(0,Y.jsx)(Jh,{present:n||a.open,children:(0,Y.jsx)(Kh,{asChild:!0,container:i,children:r})})})},`MenuPortal`),X4=`MenuContent`,[LUe,Z4]=V4(X4),RUe=b.forwardRef(I4(function(e,t){let n=Y4(X4,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=G4(X4,e.__scopeMenu),o=K4(X4,e.__scopeMenu);return(0,Y.jsx)(B4.Provider,{scope:e.__scopeMenu,children:(0,Y.jsx)(Jh,{present:r||a.open,children:(0,Y.jsx)(B4.Slot,{scope:e.__scopeMenu,children:o.modal?(0,Y.jsx)(zUe,{...i,ref:t}):(0,Y.jsx)(BUe,{...i,ref:t})})})})},`MenuContent`)),zUe=b.forwardRef(I4(function(e,t){let n=G4(X4,e.__scopeMenu),r=b.useRef(null),i=am(t,r);return b.useEffect(()=>{let e=r.current;if(e)return ev(e)},[]),(0,Y.jsx)(Q4,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Qp(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),BUe=b.forwardRef(I4(function(e,t){let n=G4(X4,e.__scopeMenu);return(0,Y.jsx)(Q4,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),VUe=dm(`MenuContent.ScrollLock`),Q4=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=G4(X4,n),_=K4(X4,n),v=U4(n),y=W4(n),x=AUe(n),[S,C]=b.useState(null),w=b.useRef(null),T=am(t,w,g.onContentChange),E=b.useRef(0),D=b.useRef(``),O=b.useRef(0),k=b.useRef(null),A=b.useRef(`right`),j=b.useRef(0),M=m?J_:b.Fragment,N=m?{as:VUe,allowPinchZoom:!0}:void 0,P=I4(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=f3(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;I4((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);b.useEffect(()=>()=>window.clearTimeout(E.current),[]),x_();let F=b.useCallback(e=>A.current===k.current?.side&&m3(e,k.current?.area),[]);return(0,Y.jsx)(LUe,{scope:n,searchRef:D,onItemEnter:b.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:b.useCallback(e=>{F(e)||(w.current?.focus(),C(null))},[F]),onTriggerLeave:b.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:O,onPointerGraceIntentChange:b.useCallback(e=>{k.current=e},[]),children:(0,Y.jsx)(M,{...N,children:(0,Y.jsx)(o_,{asChild:!0,trapped:i,onMountAutoFocus:Qp(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,Y.jsx)(Om,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,Y.jsx)(CUe,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Qp(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,Y.jsx)(Gh,{role:`menu`,"aria-orientation":`vertical`,"data-state":s3(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:T,style:{outline:`none`,...h.style},onKeyDown:Qp(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&P(e.key));let i=w.current;if(e.target!==i||!DUe.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);R4.includes(e.key)&&a.reverse(),u3(a)}),onBlur:Qp(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:Qp(e.onPointerMove,h3(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),HUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e;return(0,Y.jsx)(xm.div,{...r,ref:t})},`MenuLabel`)),$4=`MenuItem`,e3=`menu.itemSelect`,t3=b.forwardRef(I4(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=b.useRef(null),o=K4($4,e.__scopeMenu),s=Z4($4,e.__scopeMenu),c=am(t,a),l=b.useRef(!1),u=I4(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(e3,{bubbles:!0,cancelable:!0});e.addEventListener(e3,e=>r?.(e),{once:!0}),Sm(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,Y.jsx)(n3,{...i,ref:c,disabled:n,onClick:Qp(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Qp(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Qp(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&L4.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),n3=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Z4($4,n),s=W4(n),c=b.useRef(null),l=am(t,c),[u,d]=b.useState(!1),[f,p]=b.useState(``);return b.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,Y.jsx)(B4.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,Y.jsx)(wUe,{asChild:!0,...s,focusable:!r,children:(0,Y.jsx)(xm.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Qp(e.onPointerMove,h3(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Qp(e.onPointerLeave,h3(e=>o.onItemLeave(e))),onFocus:Qp(e.onFocus,()=>d(!0)),onBlur:Qp(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),UUe=b.forwardRef(I4(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,Y.jsx)(i3,{scope:e.__scopeMenu,checked:n,children:(0,Y.jsx)(t3,{role:`menuitemcheckbox`,"aria-checked":c3(n)?`mixed`:n,...i,ref:t,"data-state":l3(n),onSelect:Qp(i.onSelect,()=>r?.(c3(n)?!0:!n),{checkForDefaultPrevented:!1})})})},`MenuCheckboxItem`)),[WUe,GUe]=V4(`MenuRadioGroup`,{value:void 0,onValueChange:I4(()=>{},`onValueChange`)}),KUe=`MenuRadioItem`,qUe=b.forwardRef(I4(function(e,t){let{value:n,...r}=e,i=GUe(KUe,e.__scopeMenu),a=n===i.value;return(0,Y.jsx)(i3,{scope:e.__scopeMenu,checked:a,children:(0,Y.jsx)(t3,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":l3(a),onSelect:Qp(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),r3=`MenuItemIndicator`,[i3,JUe]=V4(r3,{checked:!1}),YUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=JUe(r3,n);return(0,Y.jsx)(Jh,{present:r||c3(a.checked)||a.checked===!0,children:(0,Y.jsx)(xm.span,{...i,ref:t,"data-state":l3(a.checked)})})},`MenuItemIndicator`)),XUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e;return(0,Y.jsx)(xm.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[ZUe,a3]=V4(`MenuSub`),o3=`MenuSubTrigger`,QUe=b.forwardRef(I4(function(e,t){let n=G4(o3,e.__scopeMenu),r=K4(o3,e.__scopeMenu),i=a3(o3,e.__scopeMenu),a=Z4(o3,e.__scopeMenu),o=b.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=b.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);b.useEffect(()=>u,[u]),b.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let d=am(t,i.onTriggerChange);return(0,Y.jsx)(q4,{asChild:!0,...l,children:(0,Y.jsx)(n3,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":s3(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Qp(e.onPointerMove,h3(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Qp(e.onPointerLeave,h3(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Qp(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(a.searchRef.current===``||t.key!==` `)&&OUe[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),$Ue=`MenuSubContent`,eWe=b.forwardRef(I4(function(e,t){let n=Y4(X4,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=G4(X4,e.__scopeMenu),s=K4(X4,e.__scopeMenu),c=a3($Ue,e.__scopeMenu),l=b.useRef(null),u=am(t,l);return(0,Y.jsx)(B4.Provider,{scope:e.__scopeMenu,children:(0,Y.jsx)(Jh,{present:r||o.open,children:(0,Y.jsx)(B4.Slot,{scope:e.__scopeMenu,children:(0,Y.jsx)(Q4,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:u,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Qp(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Qp(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:Qp(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=kUe[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function s3(e){return e?`open`:`closed`}I4(s3,`getOpenState`);function c3(e){return e===`indeterminate`}I4(c3,`isIndeterminate`);function l3(e){return c3(e)?`indeterminate`:e?`checked`:`unchecked`}I4(l3,`getCheckedState`);function u3(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}I4(u3,`focusFirst`);function d3(e,t){return e.map((n,r)=>e[(t+r)%e.length])}I4(d3,`wrapArray`);function f3(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=d3(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}I4(f3,`getNextMatch`);function p3(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}I4(p3,`isPointInPolygon`);function m3(e,t){return t?p3({x:e.clientX,y:e.clientY},t):!1}I4(m3,`isPointerInGraceArea`);function h3(e){return t=>t.pointerType===`mouse`?e(t):void 0}I4(h3,`whenMouse`);var tWe=PUe,nWe=q4,rWe=IUe,iWe=RUe,aWe=HUe,oWe=t3,sWe=UUe,cWe=qUe,lWe=YUe,uWe=XUe,dWe=QUe,fWe=eWe,pWe=Object.defineProperty,g3=(e,t)=>pWe(e,`name`,{value:t,configurable:!0}),_3=`DropdownMenu`,[mWe,hWe]=sm(_3,[H4]),v3=H4(),[gWe,y3]=mWe(_3),_We=g3(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=v3(t),l=b.useRef(null),[u,d]=ng({prop:i,defaultProp:a??!1,onChange:o,caller:_3});return(0,Y.jsx)(gWe,{scope:t,triggerId:Pm(),triggerRef:l,contentId:Pm(),open:u,onOpenChange:d,onOpenToggle:b.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,Y.jsx)(tWe,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),vWe=`DropdownMenuTrigger`,yWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=y3(vWe,n),o=v3(n),s=am(t,a.triggerRef);return(0,Y.jsx)(nWe,{asChild:!0,...o,children:(0,Y.jsx)(xm.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:Qp(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Qp(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),bWe=g3(e=>{let{__scopeDropdownMenu:t,...n}=e,r=v3(t);return(0,Y.jsx)(rWe,{...r,...n})},`DropdownMenuPortal`),xWe=`DropdownMenuContent`,SWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=y3(xWe,n),a=v3(n),o=b.useRef(!1);return(0,Y.jsx)(iWe,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Qp(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Qp(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),CWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(aWe,{...i,...r,ref:t})},`DropdownMenuLabel`)),wWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(oWe,{...i,...r,ref:t})},`DropdownMenuItem`)),TWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(sWe,{...i,...r,ref:t})},`DropdownMenuCheckboxItem`)),EWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(cWe,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),DWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(lWe,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),OWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(uWe,{...i,...r,ref:t})},`DropdownMenuSeparator`)),kWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(dWe,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),AWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(fWe,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuSubContent`)),jWe=_We,MWe=yWe,NWe=bWe,b3=SWe,x3=CWe,S3=wWe,C3=TWe,w3=EWe,T3=DWe,E3=OWe,D3=kWe,O3=AWe,k3=jWe,A3=MWe,PWe=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Y.jsxs)(D3,{ref:i,className:X(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-bg-brand-primary data-[state=open]:bg-bg-brand-primary`,t&&`pl-8`,e),...r,children:[n,(0,Y.jsx)(Rv,{className:`ml-auto w-4 h-4`})]}));PWe.displayName=D3.displayName;var FWe=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(O3,{ref:n,className:X(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-bg-secondary p-1 text-fg-secondary shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));FWe.displayName=O3.displayName;var j3=b.forwardRef(({className:e,sideOffset:t=4,container:n,...r},i)=>(0,Y.jsx)(NWe,{container:n,children:(0,Y.jsx)(b3,{ref:i,sideOffset:t,className:X(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-bg-secondary p-1 text-fg-secondary shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));j3.displayName=b3.displayName;var M3=b.forwardRef(({className:e,inset:t,...n},r)=>(0,Y.jsx)(S3,{ref:r,className:X(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-bg-brand-primary focus:text-fg-brand-primary data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,t&&`pl-8`,e),...n}));M3.displayName=S3.displayName;var IWe=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Y.jsxs)(C3,{ref:i,className:X(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(T3,{children:(0,Y.jsx)(Fv,{className:`w-4 h-4`})})}),t]}));IWe.displayName=C3.displayName;var LWe=b.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(w3,{ref:r,className:X(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(T3,{children:(0,Y.jsx)(Bie,{className:`w-2 h-2 fill-current`})})}),t]}));LWe.displayName=w3.displayName;var RWe=b.forwardRef(({className:e,inset:t,...n},r)=>(0,Y.jsx)(x3,{ref:r,className:X(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));RWe.displayName=x3.displayName;var zWe=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(E3,{ref:n,className:X(`-mx-1 my-1 h-px bg-muted`,e),...t}));zWe.displayName=E3.displayName;function N3({images:e,currentSrc:t,onSelect:n}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-secondary`,children:`Select an image:`}),(0,Y.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:e.map((e,r)=>{let i=`Select image ${r+1}`;return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(e.url),"aria-label":i,className:[`overflow-hidden rounded border-2 transition-all`,t===e.url?`border-border-brand-primary ring-2 ring-border-brand-primary`:`border-border-primary hover:border-border-brand-primary`].join(` `),children:(0,Y.jsx)(`img`,{src:e.url,alt:``,className:`h-16 w-full object-cover`})},e.url)})})]})}function P3({catalog:e,currentHref:t,onApplyLink:n,onRemoveLink:r,onClose:i}){let a=new Map(e.map(e=>[e.href.trim(),e])),o=(0,b.useCallback)(e=>{let t=a.get(e);t&&n(t)},[a,n]);return(0,Y.jsxs)(ik,{filter:(e,t)=>{let n=a.get(e);if(!n)return 0;let r=t.toLowerCase();return n.title.toLowerCase().includes(r)||n.subtitle.toLowerCase().includes(r)||n.href.trim().toLowerCase().includes(r)?1:0},children:[(0,Y.jsx)(ak,{placeholder:`Filter...`,onKeyDown:e=>{e.key===`Escape`&&i()}}),(0,Y.jsxs)(ok,{children:[(0,Y.jsx)(sk,{children:`No matches`}),(0,Y.jsx)(ck,{children:e.map(e=>{let n=e.href.trim(),r=t!==null&&n===t;return(0,Y.jsxs)(uk,{value:n,onSelect:o,className:`flex items-center gap-2`,children:[(0,Y.jsx)(Fv,{className:X(`h-4 w-4 shrink-0`,r?`opacity-100`:`opacity-0`)}),(0,Y.jsx)(dk,{title:e.title,subtitle:e.subtitle,image:e.image??null,className:X(r&&`text-fg-brand-primary`)})]},n)})})]}),r&&(0,Y.jsx)(`div`,{className:`border-t border-border-primary p-1`,children:(0,Y.jsx)(`button`,{type:`button`,className:X(`w-full rounded px-2 py-1.5 text-left text-sm text-fg-secondary`,`transition-colors hover:bg-bg-secondary-hover`),onMouseDown:r,children:`Remove link`})})]})}function F3({currentHref:e,isNewLink:t,onApply:n,onUnlink:r,onClose:i}){let[a,o]=(0,b.useState)(e),s=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=s.current;e&&(e.focus(),e.select())},[]);let c=(0,b.useCallback)(()=>{let e=a.trim();e&&n(e)},[a,n]),l=(0,b.useCallback)(e=>{if(e.key===`Escape`){i();return}e.key===`Enter`&&(e.preventDefault(),c())},[i,c]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(MT,{ref:s,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:l,"aria-label":`URL`,placeholder:`https://…`,className:X(`h-8 m-0 min-w-[220px] w-auto text-sm`)}),(0,Y.jsx)(t_,{size:`xs`,onMouseDown:c,children:t?`Apply`:`Update`}),!t&&(0,Y.jsx)(t_,{variant:`ghost`,size:`xs`,onMouseDown:r,children:`Unlink`})]})}var BWe={bold:Mv,italic:ly,strikethrough:Fy,code:Kv,link:dy},VWe={bullet_list:my,ordered_list:fy},I3={1:tae,2:nae,3:iae,4:rae,5:aae,6:oae};function L3(){return(0,Y.jsx)(`div`,{className:`mx-0.5 w-px self-stretch bg-border-primary`,role:`separator`})}var R3=`disabled:bg-transparent disabled:border-transparent aria-disabled:bg-transparent aria-disabled:border-transparent`;function z3({view:e,schema:t,features:n,linkHelper:r,options:i,images:a,imageModuleEntries:o,imageGetUrl:s,onImageUpload:c,imageAccept:l,uploadProgress:u,buttonVariants:d,detailsVariants:f,linkCatalog:p,styleConfig:m,readOnly:h}){let g=l4(t,n),_=u4(t,m),v=d4(t,n),y=i?.showBlockTypeSelect?m4(t,n):[],x=y.length>1,S=x?aUe(e.state,y):`paragraph`,C=(0,b.useRef)(null);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-0`,ref:C}),x&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:`xs`,className:X(`min-w-[3.5rem]`,R3),disabled:h,children:[S.startsWith(`heading`)&&(()=>{let e=I3[Number(S.replace(`heading`,``))];return e?(0,Y.jsx)(e,{size:16}):S})(),!S.startsWith(`heading`)&&(y.find(e=>e.value===S)?.label??`Normal`)]})}),(0,Y.jsx)(j3,{container:C.current,children:y.map(n=>{let r=n.attrs?.level,i=r?I3[r]:void 0;return(0,Y.jsx)(M3,{onClick:()=>{oUe(e,t,n),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):n.label},n.value)})})]}),(0,Y.jsx)(L3,{})]}),g.map(t=>{let n=p4(e.state,t.markType),i=BWe[t.markType.name];return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:t.title,disabled:h,className:X(R3,{"text-accent":n,"stroke-[3px]":n}),onClick:n=>{n.preventDefault(),t.markType.name===`link`?r.handleLinkToggle(e,t.markType):b2(t.markType)(e.state,e.dispatch,e),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):t.label},t.markType.name)}),_.length>0&&g.length>0&&(0,Y.jsx)(L3,{}),_.map(t=>{let n=p4(e.state,t.markType);return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:t.title,disabled:h,className:X(R3,{"text-accent":n,"stroke-[3px]":n}),onClick:n=>{n.preventDefault(),b2(t.markType)(e.state,e.dispatch,e),e.focus()},children:t.label},t.markType.name)}),v.length>0&&(g.length>0||_.length>0)&&(0,Y.jsx)(L3,{}),v.map(n=>{let r=f4(e.state,n.nodeType),i=VWe[n.nodeType.name];return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:n.title,disabled:h,className:X(R3,{"text-accent":r,"stroke-[3px]":r}),onClick:r=>{r.preventDefault(),iUe(n.nodeType,t)(e.state,e.dispatch,e),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):n.label},n.nodeType.name)}),t.nodes.image&&(!n||n.image)&&(a&&a.length>0||o||c)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(HWe,{view:e,schema:t,images:a,imageModuleEntries:o,imageGetUrl:s,onImageUpload:c,imageAccept:l,uploadProgress:u,readOnly:h})]}),d&&d.length>0&&(!n||n.button)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(GWe,{view:e,schema:t,variants:d,linkHelper:r,linkCatalog:p,dropdownContainer:C.current,readOnly:h})]}),f&&f.length>0&&(!n||n.details)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(UWe,{view:e,schema:t,variants:f,dropdownContainer:C.current,readOnly:h})]})]})}function HWe({view:e,schema:t,images:n,imageModuleEntries:r,imageGetUrl:i,onImageUpload:a,imageAccept:o,uploadProgress:s,readOnly:c}){let[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),p=(0,b.useRef)(null),m=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!l)return;function e(e){let t=e.target;(!p.current||!p.current.contains(t))&&u(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let h=!!r||n&&n.length>0;function g(n){a&&(f(!0),a(n,(n,r)=>v4(e,t,n,r)).then(t=>{f(!1),t&&(u(!1),e.focus())}))}return(0,Y.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert image`,disabled:d||c,className:X(R3,{"text-accent stroke-[3px]":l}),onClick:e=>{e.preventDefault(),!h&&a?m.current?.click():u(e=>!e)},children:d?(0,Y.jsx)(hy,{size:16,className:`animate-spin`}):(0,Y.jsx)(sy,{size:16})}),d&&s!=null&&(0,Y.jsxs)(`span`,{className:`text-[10px] font-medium tabular-nums text-fg-secondary select-none`,children:[s,`%`]}),(0,Y.jsx)(`input`,{ref:m,hidden:!0,type:`file`,accept:o??`image/*`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&g(t),e.target.value=``}}),l&&(0,Y.jsxs)(`div`,{ref:p,className:X(`absolute left-0 top-full z-window mt-1 rounded-md`,`border border-border-primary bg-bg-primary shadow-xl`,r?`min-w-[280px] p-0`:`min-w-[240px] p-2`),onMouseDown:e=>{e.stopPropagation()},children:[r?(0,Y.jsx)(uA,{moduleEntries:r,isImage:!0,getUrl:i,autoFocus:!0,maxHeight:280,onSelect:n=>{v4(e,t,n.filePath),u(!1),e.focus()},onEscape:()=>u(!1)}):n&&n.length>0?(0,Y.jsx)(N3,{images:n,currentSrc:``,onSelect:n=>{v4(e,t,n),u(!1),e.focus()}}):null,a&&(0,Y.jsxs)(Y.Fragment,{children:[h&&(0,Y.jsx)(`div`,{className:`mx-2 my-1 border-t border-border-primary`}),(0,Y.jsx)(`div`,{className:X(`flex items-center gap-2`,h?`px-2 pb-2`:``),children:(0,Y.jsxs)(t_,{variant:`secondary`,size:`sm`,className:`w-full`,disabled:d,onClick:e=>{e.preventDefault(),m.current?.click()},children:[d?(0,Y.jsx)(hy,{size:14,className:`mr-1.5 animate-spin`}):(0,Y.jsx)(By,{size:14,className:`mr-1.5`}),d?s==null?`Uploading...`:`Uploading ${s}%`:`Upload image`]})})]})]})]})}function UWe({view:e,schema:t,variants:n,dropdownContainer:r,readOnly:i}){return(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert details`,disabled:i,className:R3,children:(0,Y.jsx)(wy,{size:16})})}),(0,Y.jsx)(j3,{container:r,children:n.map(n=>(0,Y.jsx)(M3,{onClick:()=>{y4(e,t,n.variant),e.focus()},children:n.label},n.variant))})]})}function WWe(e){if(Array.isArray(e.link))return e.link}function GWe({view:e,schema:t,variants:n,dropdownContainer:r,readOnly:i}){let[a,o]=(0,b.useState)(null),s=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!a)return;function e(e){let t=e.target;(!s.current||!s.current.contains(t))&&o(null)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);function c(e){o(e)}function l(n){a&&(_4(e,t,a,n),o(null),e.focus())}function u(){o(null),e.focus()}return(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert button`,disabled:i,className:X(R3,{"text-accent stroke-[3px]":!!a}),children:(0,Y.jsx)(by,{size:16})})}),(0,Y.jsx)(j3,{container:r,children:n.map(n=>(0,Y.jsxs)(M3,{onClick:()=>{n.link?c(n):(_4(e,t,n),e.focus())},children:[n.label,n.link&&(0,Y.jsx)(`span`,{className:`ml-1.5 text-xs text-fg-secondary-alt`,children:`(link)`})]},n.variant))})]}),a&&(0,Y.jsx)(KWe,{ref:s,linkCatalog:WWe(a),onSelectHref:l,onClose:u})]})}var KWe=(0,b.forwardRef)(function({linkCatalog:e,onSelectHref:t,onClose:n},r){let i=e&&e.length>0;return(0,Y.jsx)(`div`,{ref:r,className:X(`absolute left-0 top-full z-window mt-1 rounded-md`,`border border-border-primary bg-bg-primary shadow-xl`,i?`min-w-[280px] flex flex-col`:`flex items-center gap-1.5 p-1.5`),onMouseDown:e=>{e.stopPropagation()},children:i?(0,Y.jsx)(P3,{catalog:e,currentHref:null,onApplyLink:e=>t(e.href.trim()),onRemoveLink:null,onClose:n}):(0,Y.jsx)(F3,{currentHref:``,isNewLink:!0,onApply:e=>t(e),onUnlink:n,onClose:n})})}),qWe=new CQ(`fixedToolbar`);function JWe(e,t){let n=null,r=null;if(!t.linkHelper)throw Error(`fixedToolbar requires a linkHelper instance`);let i=t.linkHelper,a={showBlockTypeSelect:!0};function o(n){r&&r.render((0,b.createElement)(z3,{view:n,schema:e,features:t.features,linkHelper:i,options:a,images:t.getImages?.(),imageModuleEntries:t.getImageModuleEntries?.(),imageGetUrl:t.getImageGetUrl?.(),onImageUpload:t.getOnImageUpload?.(),imageAccept:t.getImageAccept?.(),uploadProgress:t.getUploadProgress?.()??null,buttonVariants:t.getButtonVariants?.(),detailsVariants:t.getDetailsVariants?.(),linkCatalog:t.getLinkCatalog?.(),styleConfig:t.styleConfig,readOnly:t.readOnly}))}return new bQ({key:qWe,view(e){let i=t.getMount();return i&&(n=document.createElement(`div`),n.className=`flex flex-row items-center justify-start px-2 py-1 gap-x-1`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Formatting`),n.addEventListener(`mousedown`,e=>{e.target.tagName!==`SELECT`&&e.preventDefault()},!0),i.appendChild(n),r=(0,x.createRoot)(n),o(e)),{update:o,destroy(){let e=r;r=null,n?.remove(),n=null,e&&queueMicrotask(()=>e.unmount())}}}})}var YWe=new CQ(`floatingToolbar`);function XWe(e,t){let n=null,r=null;if(!t?.linkHelper)throw Error(`floatingToolbar requires a linkHelper instance`);let i=t.linkHelper;function a(a){if(!n||!r)return;let{selection:o}=a.state,{empty:s,from:c,to:l}=o,{$from:u}=o,d=u.parent.type.name===`button_editable`||o instanceof cQ&&o.node.type.name===`button_editable`;if(s||d||!a.hasFocus()&&!i.isPickerOpen()){n.style.display=`none`,i.isPickerOpen()||i.closePicker();return}r.render((0,b.createElement)(z3,{view:a,schema:e,features:t?.features,linkHelper:i,images:t?.getImages?.(),imageModuleEntries:t?.getImageModuleEntries?.(),imageGetUrl:t?.getImageGetUrl?.(),onImageUpload:t?.getOnImageUpload?.(),imageAccept:t?.getImageAccept?.(),uploadProgress:t?.getUploadProgress?.()??null,buttonVariants:t?.getButtonVariants?.(),detailsVariants:t?.getDetailsVariants?.(),linkCatalog:t?.getLinkCatalog?.(),styleConfig:t?.styleConfig}));let f=a.coordsAtPos(c),p=a.coordsAtPos(l);if(t?.getPortalContainer?.()){let e=(f.left+p.left)/2,t=f.top-40;n.style.display=`flex`,n.style.left=`${Math.max(0,e-60)}px`,n.style.top=`${Math.max(0,t)}px`}else{let e=a.dom.parentElement?.getBoundingClientRect();if(!e)return;let t=(f.left+p.left)/2-e.left,r=f.top-e.top-40;n.style.display=`flex`,n.style.left=`${Math.max(0,t-60)}px`,n.style.top=`${Math.max(0,r)}px`}}return new bQ({key:YWe,view(e){n=document.createElement(`div`);let i=t?.getPortalContainer?.();return n.className=[`${i?`fixed`:`absolute`} z-window flex items-center gap-x-1 rounded-md border border-border-primary`,`bg-bg-primary px-2 py-1 shadow-lg transition-opacity`].join(` `),n.style.display=`none`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Formatting (selection)`),n.addEventListener(`mousedown`,e=>e.preventDefault(),!0),(i??e.dom.parentElement)?.appendChild(n),r=(0,x.createRoot)(n),{update:a,destroy(){let e=r;r=null,n?.remove(),n=null,e&&queueMicrotask(()=>e.unmount())}}}})}var ZWe=new CQ(`gutter`);function QWe(e,t,n){let r=null,i=null;function a(e){let t=document.createElement(`div`);return t.className=`absolute left-0 top-0 w-8 pointer-events-none`,t.style.height=`100%`,e.dom.parentElement?.appendChild(t),t}function o(e){let t=document.createElement(`div`);return t.className=[`${e?`fixed`:`absolute`} z-window flex flex-col rounded-md border border-border-primary`,`bg-bg-primary p-1 shadow-lg text-sm min-w-[140px]`].join(` `),t.style.display=`none`,t}function s(e,t){let n=0;for(let r=0;r<=t;r++)n+=e.child(r).nodeSize;return n}function c(e,t,n){let{doc:r}=e.state;if(t<0||t>=r.childCount)return;let i=s(r,t),a=e.state.tr.insert(i,n);a.setSelection(oQ.near(a.doc.resolve(i+1),1)),e.dispatch(a),e.focus()}function l(e,n){let r=[];if(r.push({label:`Paragraph`,action:t=>{c(t,n,e.nodes.paragraph.create())}}),e.nodes.heading)for(let i=1;i<=3;i++)(!t||t[j2[i-1]])&&r.push({label:`Heading ${i}`,action:t=>{c(t,n,e.nodes.heading.create({level:i}))}});return e.nodes.code_block&&(!t||t.codeBlock)&&r.push({label:`Code Block`,action:t=>{c(t,n,e.nodes.code_block.create())}}),e.nodes.details&&e.nodes.details_summary&&(!t||t.details)&&r.push({label:`Details`,action:t=>{let r=e.nodes.details_summary.create(null,[]),i=e.nodes.paragraph.create();c(t,n,e.nodes.details.create({variant:`details`},[r,i]))}}),r}function u(e){if(!r)return;r.innerHTML=``;let t=e.dom.parentElement?.getBoundingClientRect();if(!t)return;let{doc:n}=e.state;n.forEach((n,i,a)=>{let o=e.coordsAtPos(i+1).top-t.top,s=document.createElement(`button`);s.type=`button`,s.className=[`pointer-events-auto absolute left-1 flex h-6 w-6 items-center justify-center`,`rounded text-fg-secondary-alt opacity-0 transition-opacity hover:opacity-100`,`hover:bg-bg-secondary-hover`].join(` `),s.style.top=`${o}px`,s.textContent=`+`,s.title=`Add block below`,s.addEventListener(`mousedown`,t=>{t.preventDefault(),t.stopPropagation(),d(e,s,a)}),r.appendChild(s)})}function d(t,r,a){let s=n?.getPortalContainer?.();i||(i=o(!!s),(s??t.dom.parentElement)?.appendChild(i)),i.innerHTML=``;let c=l(e,a);for(let e of c){let n=document.createElement(`button`);n.type=`button`,n.className=`px-3 py-1 text-left text-fg-secondary hover:bg-bg-secondary-hover rounded`,n.textContent=e.label,n.addEventListener(`mousedown`,n=>{n.preventDefault(),e.action(t),i.style.display=`none`}),i.appendChild(n)}let u=r.getBoundingClientRect();if(s)i.style.display=`flex`,i.style.left=`${u.right+4}px`,i.style.top=`${u.top}px`;else{let e=t.dom.parentElement?.getBoundingClientRect();if(!e)return;i.style.display=`flex`,i.style.left=`${u.right-e.left+4}px`,i.style.top=`${u.top-e.top}px`}let d=e=>{i?.contains(e.target)||(i.style.display=`none`,document.removeEventListener(`mousedown`,d))};setTimeout(()=>document.addEventListener(`mousedown`,d),0)}return new bQ({key:ZWe,view(e){return r=a(e),u(e),{update:u,destroy(){r?.remove(),i?.remove(),r=null,i=null}}}})}function $We({error:e,onApplyFix:t}){let n=e.fixes;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`div`,{className:`text-fg-error-primary font-medium text-sm`,children:e.message}),n&&n.length>0&&(0,Y.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:n.map(n=>(0,Y.jsx)(`button`,{type:`button`,className:[`rounded px-2 py-0.5 text-xs font-medium`,`border border-border-error-primary text-fg-error-primary`,`hover:bg-bg-error-secondary-hover`].join(` `),onClick:r=>{r.preventDefault(),t?.({path:e.path,kind:e.kind,fixId:n.id})},children:n.label},n.id))})]})}var eGe=new CQ(`errorTooltip`);function tGe(e){let t=null,n=null,r=null,i=null,a=null,o=null,s=null,c=null;function l(){c!==null&&(clearTimeout(c),c=null)}function u(){l(),c=setTimeout(()=>{p(),c=null},150)}function d(t){let n=e.getPortalContainer?.(),r=document.createElement(`div`);return r.className=[`${n?`fixed`:`absolute`} z-window max-w-xs rounded-md border border-border-error-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `),r.style.display=`none`,(n??t.dom.parentElement)?.appendChild(r),r}function f(i,a,o){if(!t)return;l(),r=a.path,n||=(0,x.createRoot)(t),n.render((0,Y.jsx)($We,{error:a,onApplyFix:t=>{e.onApplyErrorFix?.(t),p()}}));let s=o.getBoundingClientRect();if(e.getPortalContainer?.())t.style.display=`block`,t.style.left=`${s.left}px`,t.style.top=`${s.bottom+4}px`;else{let e=i.dom.parentElement?.getBoundingClientRect();if(!e)return;t.style.display=`block`,t.style.left=`${s.left-e.left}px`,t.style.top=`${s.bottom-e.top+4}px`}}function p(){l(),t&&(t.style.display=`none`),r=null}function m(e,t){let n=t.closest(`[data-error-path]`);if(!n)return null;let r=n.getAttribute(`data-error-path`);if(!r)return null;let i=(i4.getState(e.state)?.errors??[]).find(e=>e.path===r);return i?{error:i,target:n}:{error:{path:r,kind:n.getAttribute(`data-error-kind`)??``,message:n.getAttribute(`title`)??``},target:n}}return new bQ({key:eGe,view(e){return t=d(e),o=()=>l(),s=()=>u(),t.addEventListener(`mouseenter`,o),t.addEventListener(`mouseleave`,s),i=t=>{let n=t.target;if(!(n instanceof Element))return;let i=m(e,n);i&&i.error.path!==r&&f(e,i.error,i.target)},a=e=>{let n=e.relatedTarget;n instanceof Node&&t?.contains(n)||u()},e.dom.addEventListener(`mouseover`,i),e.dom.addEventListener(`mouseout`,a),{update(){},destroy(){l(),i&&e.dom.removeEventListener(`mouseover`,i),a&&e.dom.removeEventListener(`mouseout`,a),n&&=(n.unmount(),null),t?.remove(),t=null,r=null}}}})}var nGe=new CQ(`linkCatalog`);function rGe(e){return new bQ({key:nGe,appendTransaction(t,n,r){if(!t.some(e=>e.docChanged))return null;let i=e.getLinkCatalog();if(!i||i.length===0)return null;let a=r.schema.marks.link;if(!a)return null;let o=new Set(i.map(e=>e.href.trim())),s=r.tr,c=!1;return r.doc.descendants((e,t)=>{if(!e.isInline||!e.isText)return;let n=a.isInSet(e.marks);if(!n)return;let r=n.attrs.href.trim();o.has(r)||(s=s.removeMark(t,t+e.nodeSize,a),c=!0)}),c?s:null}})}var iGe=new CQ(`linkClick`);function aGe(e,t){let n=e;for(;n&&n!==t;){if(n.nodeName===`A`)return n;n=n.parentElement}return null}function oGe(e,t){let{linkHelper:n,getLinkCatalog:r}=t;return new bQ({key:iGe,props:{handleDOMEvents:{dblclick(t,i){let a=e.marks.link;if(!a)return!1;let o=aGe(i.target,t.dom);if(!o)return!1;i.preventDefault();let s=t.posAtDOM(o.firstChild??o,0);if(s<0)return!1;let c=t.state.doc.resolve(s),l=a.isInSet(c.marks())??(c.nodeAfter&&a.isInSet(c.nodeAfter.marks)||null);if(!l)return!1;let u=l.attrs.href,d=c.parent,f=c.start(c.depth),p=s,m=s,h=0;for(let e=0;e<d.childCount;e++){let t=d.child(e),n=t.isText?a.isInSet(t.marks):null;if(n&&n.attrs.href===u){let n=f+h,r=n+t.nodeSize;if(r>p&&n<=s){p=n,m=r;for(let t=e+1;t<d.childCount;t++){let e=d.child(t),n=e.isText?a.isInSet(e.marks):null;if(!n||n.attrs.href!==u)break;m+=e.nodeSize}for(let t=e-1;t>=0;t--){let e=d.child(t),n=e.isText?a.isInSet(e.marks):null;if(!n||n.attrs.href!==u)break;p-=e.nodeSize}break}}h+=t.nodeSize}if(p>=m)return!1;let g=t.state.tr.setSelection(oQ.create(t.state.doc,p,m));t.dispatch(g);let _=r?.();return _&&_.length>0?n.showCatalogPicker(t,a,_):n.showUrlEditor(t,a),!0}}}})}function sGe({onUpload:e,accept:t}){let[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(null);return(0,b.createElement)(`div`,{style:{marginTop:`6px`}},(0,b.createElement)(`input`,{ref:i,type:`file`,accept:t,hidden:!0,onChange:t=>{let n=t.currentTarget.files?.[0];n&&(r(!0),e(n).finally(()=>r(!1)),t.target.value=``)}}),(0,b.createElement)(`button`,{type:`button`,disabled:n,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`4px`,width:`100%`,padding:`4px 8px`,fontSize:`12px`,borderRadius:`4px`,border:`1px solid var(--border-primary, #ccc)`,background:`var(--bg-secondary, #f5f5f5)`,cursor:n?`wait`:`pointer`,opacity:n?.6:1},onClick:e=>{e.preventDefault(),e.stopPropagation(),i.current?.click()}},n?`Uploading...`:`Upload image`))}function cGe(e,t){let n=t?.inline??!1,r=e=>{let n=t?.getUrl?.();return n?n(e):e};return(i,a,o)=>{let s=document.createElement(n?`span`:`figure`);n?(s.style.position=`relative`,s.style.display=`inline-block`):(s.style.margin=`0.5em 0`,s.style.position=`relative`);let c=document.createElement(`img`);if(c.src=i.attrs.previewUrl||r(i.attrs.src),i.attrs.alt&&(c.alt=i.attrs.alt),c.style.maxWidth=`100%`,c.style.cursor=`pointer`,n||(c.style.display=`block`,c.style.borderRadius=`var(--radius, 0.25rem)`),s.appendChild(c),!n&&i.attrs.caption){let e=document.createElement(`figcaption`);e.textContent=i.attrs.caption,e.style.fontSize=`0.85em`,e.style.color=`var(--fg-secondary-alt)`,e.style.marginTop=`0.3em`,e.style.textAlign=`center`,s.appendChild(e)}let l=null,u=null,d=!1,f=null;function p(){u&&=(u.unmount(),null),l?.remove(),l=null,d=!1,f&&=(document.removeEventListener(`mousedown`,f,!0),null)}function m(){let n=e.current,r=t?.getOnImageUpload?.();if(!n&&!r)return;p(),d=!0,l=document.createElement(`div`),l.style.minWidth=`200px`,l.addEventListener(`mousedown`,e=>{e.stopPropagation()});let m=t?.getPortalContainer?.();if(m){l.className=[`fixed z-window rounded-md border border-border-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `);let e=c.getBoundingClientRect();l.style.left=`${e.left}px`,l.style.top=`${e.bottom+4}px`,m.appendChild(l)}else l.className=[`absolute z-window rounded-md border border-border-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `),l.style.left=`0`,l.style.top=`${c.offsetHeight+4}px`,s.appendChild(l);let h=i.attrs.src;function g(e){let t=o();if(t===void 0)return null;let n=a.state.tr.setNodeMarkup(t,void 0,{...i.attrs,src:e});a.dispatch(n),p(),a.focus();let r=s4(a.state.doc,t);return r?[...r,`src`]:null}u=(0,x.createRoot)(l);let _=[];if(n&&_.push((0,b.createElement)(()=>n(h,g))),r){let e=r,n=t?.getImageAccept?.()??`image/*`;_.push((0,b.createElement)(sGe,{key:`upload`,accept:n,onUpload:async t=>await e(t,g)}))}u.render((0,b.createElement)(`div`,null,..._)),f=e=>{l&&!l.contains(e.target)&&!c.contains(e.target)&&p()},setTimeout(()=>document.addEventListener(`mousedown`,f,!0),0)}return c.addEventListener(`mousedown`,n=>{!e.current&&!t?.getOnImageUpload?.()||(n.preventDefault(),n.stopPropagation(),d?p():m())}),{dom:s,stopEvent:()=>!1,update(e){return e.type===i.type&&(i=e,c.src=i.attrs.previewUrl||r(i.attrs.src),i.attrs.alt?c.alt=i.attrs.alt:c.removeAttribute(`alt`),!0)},destroy(){p()}}}}function lGe(e,t){let n=e.find(e=>e.variant===t);if(n&&Array.isArray(n.link))return n.link}function uGe({variants:e,currentVariant:t,currentHref:n,onSelectVariant:r}){let[i,a]=(0,b.useState)(null);if(i){let t=lGe(e,i),o=t&&t.length>0;return(0,Y.jsx)(`div`,{className:o?`min-w-[280px] flex flex-col`:`flex items-center gap-1.5 p-1.5`,children:o?(0,Y.jsx)(P3,{catalog:t,currentHref:n,onApplyLink:e=>r(i,e.href.trim()),onRemoveLink:null,onClose:()=>a(null)}):(0,Y.jsx)(F3,{currentHref:n??``,isNewLink:!n,onApply:e=>r(i,e),onUnlink:()=>{r(i,``),a(null)},onClose:()=>a(null)})})}return(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.map(e=>{let n=e.variant===t;return(0,Y.jsxs)(`button`,{type:`button`,className:[`flex items-center gap-2 rounded px-3 py-1.5 text-left text-sm`,`transition-colors w-full`,n?`bg-bg-secondary-hover font-medium`:`hover:bg-bg-secondary-hover`].join(` `),onMouseDown:t=>{t.preventDefault(),e.link?a(e.variant):r(e.variant)},children:[n&&(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-brand-primary text-xs`,"aria-hidden":`true`,children:`✓`}),(0,Y.jsx)(`span`,{className:n?`text-fg-brand-primary`:`text-fg-secondary`,children:e.label}),e.link&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-fg-secondary-alt`,children:`link`})]},e.variant)})})}var B3=[`inline-flex items-center rounded px-2 py-0.5 text-sm font-medium`,`bg-bg-brand-secondary text-fg-brand-secondary cursor-pointer`].join(` `);function V3(e,t,n,r,i,a){let o=null,s=null,c=!1,l=null;function u(){s&&=(s.unmount(),null),o?.remove(),o=null,c=!1,l&&=(document.removeEventListener(`mousedown`,l,!0),null)}function d(t){if(!o)return;let r=e.getBoundingClientRect();if(t)o.style.left=`${r.left}px`,o.style.top=`${r.bottom+4}px`;else{let e=n.dom.parentElement,t=e?.offsetParent?.getBoundingClientRect()??e?.parentElement?.getBoundingClientRect();if(!t)return;o.style.left=`${r.left-t.left}px`,o.style.top=`${r.bottom-t.top+4}px`}}function f(){let f=t.variantsRef.current;if(!f||f.length===0)return;let p=n.dom.parentElement;if(!p)return;u(),c=!0,o=document.createElement(`div`),o.style.minWidth=`180px`,o.addEventListener(`mousedown`,e=>{e.stopPropagation()});let m=a?.getPortalContainer?.(),h=!!m;o.className=[`${h?`fixed`:`absolute`} z-window rounded-md border border-border-primary`,`bg-bg-primary p-1 shadow-lg`].join(` `),(m??p).appendChild(o),d(h);let g=i(),_=g.attrs.variant,v=g.attrs.href??null;function y(e,a){let o=r();if(o===void 0)return;let s=t.variantsRef.current?.find(t=>t.variant===e);if(!s)return;let{schema:c}=n.state,l=s.children===!1,d=l?c.nodes.button_atom:c.nodes.button_editable;if(!d)return;let f={variant:e};l||(f.href=a||null);let p=i();if(l===(p.type.name===`button_atom`)){let e=n.state.tr.setNodeMarkup(o,void 0,f);n.dispatch(e)}else{let e=l?d.create(f):d.create(f,s.label?[c.text(s.label)]:[]),t=n.state.tr.replaceWith(o,o+p.nodeSize,e);n.dispatch(t)}u(),n.focus()}s=(0,x.createRoot)(o),s.render((0,b.createElement)(uGe,{variants:f,currentVariant:_,currentHref:v,onSelectVariant:y,onClose:()=>{u(),n.focus()}})),l=t=>{o&&!o.contains(t.target)&&!e.contains(t.target)&&u()},setTimeout(()=>document.addEventListener(`mousedown`,l,!0),0)}function p(){c?u():f()}return{toggle:p,closeOverlay:u,isOpen:()=>c}}function dGe(e,t){return(n,r,i)=>{let a=document.createElement(`span`);a.style.position=`relative`,a.style.display=`inline-block`;let o=document.createElement(`button`);o.setAttribute(`type`,`button`),o.className=`${B3} cursor-default`,o.contentEditable=`false`;let s=n,c=n.attrs.variant;o.setAttribute(`data-variant`,c),o.setAttribute(`data-atom`,`true`),o.textContent=e.current?.find(e=>e.variant===c)?.label??c,a.appendChild(o);let l=V3(o,{variantsRef:e},r,i,()=>s,t);return o.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation(),l.toggle()}),{dom:a,stopEvent:()=>!0,update(t){if(t.type.name!==`button_atom`)return!1;s=t;let n=t.attrs.variant;o.setAttribute(`data-variant`,n);let r=e.current?.find(e=>e.variant===n)?.label??n;return o.textContent=r,!0},destroy(){l.closeOverlay()}}}}function fGe(e,t){return(n,r,i)=>{let a=document.createElement(`span`);a.style.position=`relative`,a.style.display=`inline-block`;let o=document.createElement(`button`);o.setAttribute(`type`,`button`),o.className=B3;let s=n,c=n.attrs.variant;o.setAttribute(`data-variant`,c);function l(e){e?(o.setAttribute(`data-href`,e),o.title=e):(o.removeAttribute(`data-href`),o.removeAttribute(`title`))}l(n.attrs.href);let u=document.createElement(`span`);o.appendChild(u),a.appendChild(o);let d=V3(o,{variantsRef:e},r,i,()=>s,t);return o.addEventListener(`dblclick`,e=>{e.preventDefault(),d.toggle()}),{dom:a,contentDOM:u,update(e){return e.type.name===`button_editable`&&(s=e,o.setAttribute(`data-variant`,e.attrs.variant),l(e.attrs.href),!0)},destroy(){d.closeOverlay()}}}}function H3({schema:e,initialDoc:t,viewRef:n,label:r,minHeight:i,allowEnter:a=!0}){let o=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(!o.current)return;let e=()=>!0,r=a?[O0(E2),S0()]:[O0({Enter:e,"Shift-Enter":e}),O0(E2),S0()],i=vQ.create({doc:t,plugins:r}),s=new i0(o.current,{state:i,editable:()=>!0});return n.current=s,()=>{s.destroy(),n.current=null}},[e,t,n,a]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-secondary`,children:r}),(0,Y.jsx)(`div`,{ref:o,className:[`prose-editor overflow-y-auto rounded-md`,`border border-border-primary bg-bg-primary p-2`,`text-fg-primary caret-fg-primary`,`focus-within:ring-2 focus-within:ring-border-brand-primary`].join(` `),style:{minHeight:i}})]})}function pGe({schema:e,summaryContent:t,bodyNodes:n,onSave:r,onCancel:i}){let a=(0,b.useRef)(null),o=(0,b.useRef)(null),s=e.node(`doc`,null,[e.node(`paragraph`,null,t)]),c=n.length>0?n:[e.node(`paragraph`)],l=e.node(`doc`,null,c),u=(0,b.useCallback)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=[],i=e.state.doc.firstChild;i&&i.forEach(e=>n.push(e));let s=[];t.state.doc.forEach(e=>s.push(e)),r(n,s)},[r]),d=(0,b.useCallback)(e=>{e.target===e.currentTarget&&i()},[i]);return(0,b.useEffect)(()=>{function e(e){e.key===`Escape`&&i()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]),(0,Y.jsx)(`div`,{className:`fixed inset-0 z-overlay flex items-center justify-center bg-black/40`,onMouseDown:d,children:(0,Y.jsxs)(`div`,{className:[`flex w-full max-w-2xl flex-col rounded-lg border border-border-primary`,`bg-bg-primary shadow-2xl`].join(` `),onMouseDown:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border-primary px-4 py-3`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg-primary`,children:`Edit Details`}),(0,Y.jsx)(`button`,{type:`button`,className:`rounded p-1 text-fg-secondary hover:bg-bg-secondary-hover`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,Y.jsx)(H3,{schema:e,initialDoc:s,viewRef:a,label:`Summary`,minHeight:`40px`,allowEnter:!1}),(0,Y.jsx)(H3,{schema:e,initialDoc:l,viewRef:o,label:`Hidden content`,minHeight:`120px`})]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border-primary px-4 py-3`,children:[(0,Y.jsx)(`button`,{type:`button`,className:[`rounded-md px-3 py-1.5 text-sm font-medium`,`text-fg-secondary hover:bg-bg-secondary-hover`].join(` `),onClick:i,children:`Cancel`}),(0,Y.jsx)(`button`,{type:`button`,className:[`rounded-md px-3 py-1.5 text-sm font-medium`,`bg-bg-brand-primary text-fg-brand-primary`,`hover:opacity-90`].join(` `),onClick:u,children:`Save`})]})]})})}function U3(e){let t=``;return e.forEach((e,n,r)=>{r===0&&e.type.name===`details_summary`&&(t=e.textContent)}),t||`Details`}function mGe(e){let t=[];return e.forEach((e,n,r)=>{r===0&&e.type.name===`details_summary`&&e.forEach(e=>t.push(e))}),t}function hGe(e){let t=[],n=!0;return e.forEach(e=>{if(n){n=!1;return}t.push(e)}),t}function gGe(e){return(t,n,r)=>{let i=t.attrs.variant,a=document.createElement(`div`);a.className=`details-collapsed group my-1 select-none`,a.style.cursor=`pointer`,i!==`details`&&a.setAttribute(`data-variant`,i);let o=document.createElement(`div`);o.style.display=`flex`,o.style.alignItems=`center`,o.style.gap=`6px`,o.style.padding=`4px 6px`,o.style.borderRadius=`4px`,o.style.transition=`background 100ms ease`,o.addEventListener(`mouseenter`,()=>{o.style.background=`var(--bg-secondary-hover, #f5f5f5)`}),o.addEventListener(`mouseleave`,()=>{o.style.background=``}),a.appendChild(o);let s=document.createElement(`span`);s.textContent=`▶`,s.style.fontSize=`0.65em`,s.style.color=`var(--fg-secondary-alt, #888)`,s.style.userSelect=`none`,s.style.flexShrink=`0`,s.style.transition=`transform 120ms ease`,o.appendChild(s);let c=document.createElement(`span`);c.style.fontSize=`inherit`,c.style.color=`var(--fg-primary, #333)`,c.textContent=U3(t),o.appendChild(c);let l=null,u=null;function d(){l&&=(l.unmount(),null),u?.remove(),u=null,s.style.transform=``}function f(){d(),s.style.transform=`rotate(90deg)`;let t=r();if(t===void 0)return;let i=n.state.doc.nodeAt(t);if(!i||i.type.name!==`details`)return;let a=mGe(i),o=hGe(i);u=document.createElement(`div`),document.body.appendChild(u),l=(0,x.createRoot)(u),l.render((0,b.createElement)(pGe,{schema:e,summaryContent:a,bodyNodes:o,onSave:(t,i)=>{let a=r();if(a===void 0)return;let o=n.state.doc.nodeAt(a);if(!o||o.type.name!==`details`)return;let s=e.nodes.details_summary.create(null,t),l=i.length>0?i:[e.nodes.paragraph.create()],u=o.type.create(o.attrs,[s,...l]),f=n.state.tr.replaceWith(a,a+o.nodeSize,u);n.dispatch(f),d(),c.textContent=s.textContent||`Details`,n.focus()},onCancel:()=>{d(),n.focus()}}))}return o.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation(),f()}),{dom:a,update(e){if(e.type.name!==`details`)return!1;let t=e.attrs.variant;return t===`details`?a.removeAttribute(`data-variant`):a.setAttribute(`data-variant`,t),c.textContent=U3(e),!0},stopEvent(){return!0},ignoreMutation(){return!0},destroy(){d()}}}}function W3({state:e,useFixedPosition:t,onApplyLink:n,onRemoveLink:r,onApplyUrl:i,onUnlink:a,onClose:o}){let s=(0,b.useRef)(null);(0,b.useEffect)(()=>{function e(e){let t=e.target;s.current&&!s.current.contains(t)&&o()}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let c=e.kind===`catalog`,l=t?`fixed`:`absolute`;return(0,Y.jsx)(`div`,{ref:s,className:c?`${l} z-window flex flex-col rounded-md border border-border-primary bg-bg-primary shadow-xl min-w-[280px]`:`${l} z-window flex items-center gap-1.5 rounded-md border border-border-primary bg-bg-primary p-1.5 shadow-xl`,style:{left:e.anchorRect.left,top:e.anchorRect.top},onMouseDown:e=>{e.stopPropagation()},children:c&&e.catalog?(0,Y.jsx)(P3,{catalog:e.catalog,currentHref:e.currentHref,onApplyLink:n,onRemoveLink:e.currentHref===null?null:r,onClose:o}):(0,Y.jsx)(F3,{currentHref:e.currentHref??``,isNewLink:e.isNewLink??!0,onApply:i,onUnlink:a,onClose:o})})}function G3(e,t){let n=t.content.size,r=Math.min(e.anchor,n);try{return nQ.near(t.resolve(r))}catch{return nQ.atStart(t)}}var _Ge=(0,b.forwardRef)(function(e,t){let{value:n,defaultValue:r,onChange:i,onDirty:a,readOnly:o=!1,features:s,diffBase:c,errors:l,errorKindClassName:u,onApplyErrorFix:d,linkCatalog:f,images:p,imageModulePath:m,onImageUpload:h,imageAccept:g,uploadProgress:_,buttonVariants:v,detailsVariants:y,className:x,portalContainer:S}=e,{moduleEntries:C,getUrl:w,ready:T}=iA(m),E=T&&!!C,D=(0,b.useRef)(null),O=(0,b.useRef)(null),k=(0,b.useRef)(null),A=(0,b.useRef)(null),j=(0,b.useRef)([]),M=(0,b.useRef)(i),N=(0,b.useRef)(a),P=(0,b.useRef)(d),F=(0,b.useRef)(f),I=(0,b.useRef)(p),L=(0,b.useRef)(C),R=(0,b.useRef)(w),[ee,te]=(0,b.useState)(null),ne=(0,b.useRef)(ee);ne.current=ee;let re=(0,b.useRef)(void 0),ie=(0,b.useRef)(h),ae=(0,b.useRef)(g),oe=(0,b.useRef)(_),se=(0,b.useRef)(v),ce=(0,b.useRef)(y),le=(0,b.useRef)(S),ue=(0,b.useRef)(null),de=n!==void 0;(0,b.useEffect)(()=>{M.current=i,N.current=a,P.current=d,F.current=f,I.current=p,L.current=C,R.current=w,ie.current=h,ae.current=g,oe.current=_,se.current=v,ce.current=y,le.current=S,E?re.current=(e,t)=>(0,Y.jsx)(uA,{moduleEntries:L.current,selectedRef:e,isImage:!0,getUrl:R.current,autoFocus:!0,maxHeight:280,onSelect:e=>{t(e.filePath)}}):p&&p.length>0?re.current=(e,t)=>(0,Y.jsx)(N3,{images:I.current,currentSrc:e,onSelect:t}):re.current=void 0});let fe={...MHe,...s},pe=fe.styles,me=(0,b.useMemo)(()=>rHe({features:fe,buttonVariants:v,detailsVariants:y,styleConfig:pe}),[]);A.current=me.marks.link??null;let he=fe.fixedToolbar&&lUe({schema:me,features:fe,styleConfig:pe,canInsertImage:!!h||!!p?.length||!!m,buttonVariants:v,detailsVariants:y});(0,b.useLayoutEffect)(()=>{if(!D.current)return;let e=de?n:r??[],t,i=ue.current;if(ue.current=null,i!==null&&i.type.schema===me)t=i;else{try{t=n2(e??[],me)}catch{t=me.node(`doc`,null,[me.node(`paragraph`)])}j.current=e??[]}let a=()=>le.current??null,s=[...NHe(me,fe),IHe(me,fe),S0(),E0(),M0(),HHe(),$He(fe),eUe(),tGe({getPortalContainer:a,onApplyErrorFix:e=>{if(e.kind===`schema.violation`&&k.current){YHe(k.current,e.path,e.fixId);return}P.current?.(e)}})],c=()=>F.current,l=()=>se.current,u=()=>ce.current,d=sUe({getLinkCatalog:c,getPortalContainer:a,onPickerStateChange:e=>{te(e)},isPickerOpen:()=>ne.current!==null});s.push(rGe({getLinkCatalog:c})),!o&&fe.link&&s.push(oGe(me,{getLinkCatalog:c,linkHelper:d}));let f=()=>I.current,p=()=>L.current,m=()=>R.current,h=()=>ie.current,g=()=>ae.current,_=()=>oe.current;fe.fixedToolbar&&s.push(JWe(me,{getMount:()=>O.current,getLinkCatalog:c,getImages:f,getImageModuleEntries:p,getImageGetUrl:m,getOnImageUpload:h,getImageAccept:g,getUploadProgress:_,getButtonVariants:l,getDetailsVariants:u,linkHelper:d,styleConfig:pe,features:fe,readOnly:o})),fe.floatingToolbar&&!o&&s.push(XWe(me,{getPortalContainer:a,getLinkCatalog:c,getImages:f,getImageModuleEntries:p,getImageGetUrl:m,getOnImageUpload:h,getImageAccept:g,getUploadProgress:_,getButtonVariants:l,getDetailsVariants:u,linkHelper:d,styleConfig:pe,features:fe})),fe.gutter&&!o&&s.push(QWe(me,fe,{getPortalContainer:a}));let v={};me.nodes.image&&(v.image=cGe(re,{inline:!0,getPortalContainer:a,getUrl:m,getOnImageUpload:h,getImageAccept:g})),me.nodes.button_atom&&(v.button_atom=dGe(se,{getPortalContainer:a})),me.nodes.button_editable&&(v.button_editable=fGe(se,{getPortalContainer:a})),me.nodes.details&&(v.details=gGe(me));let y=vQ.create({doc:t,plugins:s}),b=new i0(D.current,{state:y,editable:()=>!o,nodeViews:v,dispatchTransaction(e){let t=b.state.apply(e);if(b.updateState(t),e.docChanged&&(N.current?.(),M.current)){let e=o2(t.doc),n=e2(j.current,e);j.current=e,M.current({value:e,patches:n})}}});return k.current=b,()=>{ue.current=b.state.doc,d.destroy(),b.destroy(),k.current=null}},[me,o,he,fe.floatingToolbar,fe.gutter]),(0,b.useEffect)(()=>{let e=k.current;e&&e.dispatch(e.state.tr)},[C,p,h,v,y]),(0,b.useEffect)(()=>{let e=k.current;if(!e||!de||!n)return;let t=o2(e.state.doc);if(JSON.stringify(t)!==JSON.stringify(n))try{let t=n2(n,me),r=e.state.selection,i=vQ.create({doc:t,plugins:e.state.plugins,selection:G3(r,t)});e.updateState(i),j.current=n}catch(e){console.error(e)}},[n,de,me]),(0,b.useEffect)(()=>{let e=k.current;if(e){if(c)try{let t=n2(c,me),n=e.state.tr.setMeta(J2,{baseDoc:t});e.dispatch(n)}catch{}else{let t=e.state.tr.setMeta(J2,{baseDoc:null});e.dispatch(t)}}},[c,me]),(0,b.useEffect)(()=>{let e=k.current;if(!e)return;let t=e.state.tr.setMeta(i4,{errors:l??[],errorKindClassName:u??{}});e.dispatch(t)},[l,u]);let ge=(0,b.useCallback)(()=>k.current?o2(k.current.state.doc):[],[]),_e=(0,b.useCallback)(e=>e2(e,k.current?o2(k.current.state.doc):[]),[]),ve=(0,b.useCallback)(e=>{let t=k.current;if(!t)return;let n=e?n2(e,me):me.node(`doc`,null,[me.node(`paragraph`)]),r=t.state.selection,i=vQ.create({doc:n,plugins:t.state.plugins,selection:G3(r,n)});t.updateState(i),j.current=e??[]},[me]);(0,b.useImperativeHandle)(t,()=>({getDocument:ge,getPatches:_e,reset:ve}),[ge,_e,ve]);let ye=(0,b.useCallback)(e=>{let t=k.current,n=A.current,r=ne.current;if(!t||!n||!r)return;let{state:i,dispatch:a}=t,o=i.tr;e?(o=o.removeMark(r.savedFrom,r.savedTo,n),o=o.addMark(r.savedFrom,r.savedTo,n.create({href:e}))):o=o.removeMark(r.savedFrom,r.savedTo,n),a(o),te(null),t.focus()},[]),be=(0,b.useCallback)(e=>{ye(e.href.trim())},[ye]),xe=(0,b.useCallback)(()=>{ye(null)},[ye]),Se=(0,b.useCallback)(e=>{ye(e)},[ye]),Ce=(0,b.useCallback)(()=>{ye(null)},[ye]),we=(0,b.useCallback)(()=>{te(null),k.current?.focus()},[]);return(0,Y.jsxs)(`div`,{className:[`rich-text-editor relative flex flex-col`,o?`cursor-default`:``,x??``].filter(Boolean).join(` `),children:[he&&(0,Y.jsx)(`div`,{ref:O,className:[`rounded-t-md border border-border-primary`,`bg-bg-secondary absolute left-0 top-0 z-hover w-full`].join(` `)}),(0,Y.jsx)(`div`,{ref:D,className:[`prose-editor relative min-h-10 border border-border-primary`,`bg-bg-primary text-fg-primary caret-fg-primary`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-border-focus rounded-md`,`px-3 py-2`,he?`pt-14`:``,o?`opacity-80`:``].join(` `)}),ee&&(S?(0,lm.createPortal)((0,Y.jsx)(W3,{state:ee,useFixedPosition:!0,onApplyLink:be,onRemoveLink:xe,onApplyUrl:Se,onUnlink:Ce,onClose:we}),S):(0,Y.jsx)(W3,{state:ee,onApplyLink:be,onRemoveLink:xe,onApplyUrl:Se,onUnlink:Ce,onClose:we}))]})});function vGe(e){if(!e)return{};let t={};return t.bold=e.style?.bold??!1,t.italic=e.style?.italic??!1,t.strikethrough=e.style?.lineThrough??!1,t.h1=e.block?.h1??!1,t.h2=e.block?.h2??!1,t.h3=e.block?.h3??!1,t.h4=e.block?.h4??!1,t.h5=e.block?.h5??!1,t.h6=e.block?.h6??!1,t.bulletList=e.block?.ul??!1,t.orderedList=e.block?.ol??!1,t.link=!!e.inline?.a,t.image=!!e.inline?.img,t.hardBreak=!0,t.fixedToolbar=!0,t.floatingToolbar=!1,t.gutter=!1,t.code=!1,t.blockquote=!1,t.codeBlock=!1,t.details=!1,t.button=!1,t}function yGe(e){if(!(!e||typeof e.path!=`string`))return H.mediaUrl({path:e.path})}function bGe(e){let t=(0,b.useMemo)(()=>vGe(e),[e]),n=e?.inline?.a===!0||typeof e?.inline?.a==`object`&&`type`in e.inline.a&&e.inline.a.type===`route`,r=n&&e?.inline?.a&&typeof e.inline.a==`object`&&`type`in e.inline.a&&e.inline.a.type===`route`?e.inline.a:void 0,i=(0,b.useMemo)(()=>r?.options?.include?new RegExp(r.options.include.source,r.options.include.flags):void 0,[r?.options?.include?.source,r?.options?.include?.flags]),a=(0,b.useMemo)(()=>r?.options?.exclude?new RegExp(r.options.exclude.source,r.options.exclude.flags):void 0,[r?.options?.exclude?.source,r?.options?.exclude?.flags]),o=TA(),s=ooe();return{features:t,linkCatalog:(0,b.useMemo)(()=>{if(!n)return;let e=new Map;return o.filter(({route:e})=>!(i&&!i.test(e)||a&&a.test(e))).map(({route:t,moduleFilePath:n})=>{if(!e.has(n)){let t=new Map,r=s[n];if(r){let e=r[n];if(e&&`data`in e&&e.data&&e.data.parent===`record`)for(let[n,r]of e.data.items)t.set(n,{title:r.title,subtitle:r.subtitle,image:yGe(r.image)})}e.set(n,t)}let r=e.get(n)?.get(t);return r?{title:r.title,subtitle:r.subtitle??n,href:t,image:r.image}:{title:t,subtitle:n,href:t}})},[n,o,i,a,s]),imageModulePath:(0,b.useMemo)(()=>{let t=e?.inline?.img;if(t&&typeof t==`object`&&`type`in t&&t.type===`image`&&`referencedModule`in t&&typeof t.referencedModule==`string`)return t.referencedModule},[e]),imageSchema:(0,b.useMemo)(()=>{let t=e?.inline?.img;if(t&&typeof t==`object`&&`type`in t&&t.type===`image`)return t},[e])}}var xGe=400;function SGe({path:e,readonly:t}){let n=`richtext`,r=bb(),i=xS(),a=SS(),{source:o,schema:s,patchPath:c,addPatch:l,addAndUploadPatchWithFileOps:u,addModuleFilePatch:d}=yb(e,n),f=`data`in o?o.data:void 0,p=(0,b.useRef)(null),m=(0,b.useRef)(f??[]),h=(0,b.useRef)(null),g=(0,b.useRef)(!1),_=(0,b.useRef)(!1),v=(0,b.useRef)(!1),y=(0,b.useRef)(null),[x,S]=(0,b.useState)(null),C=`clientSideOnly`in o&&o.clientSideOnly;(0,b.useEffect)(()=>{if(C!==!1||!f||v.current)return;let e=f,t=p.current?.getDocument();t&&!Mr(t,e)&&(p.current?.reset(e),m.current=e)},[f,C]);let w=eb(),T=`data`in s&&s.data.type===`richtext`?s.data.options:void 0,{features:E,linkCatalog:D,imageModulePath:O,imageSchema:k}=bGe(T),A=!!T?.inline?.img,j=k?.referencedModule,M=Tb(j),N=(0,b.useMemo)(()=>{if(A){if(k?.options?.accept)return k.options.accept;if(M?.type===`record`&&M.accept)return M.accept}},[A,k,M]),P=(0,b.useMemo)(()=>M?.type===`record`?M.directory:void 0,[M]),F=(0,b.useMemo)(()=>{let e=M?.type===`record`?M.encode:void 0;return{settings:hA(k?.options?.encode,e),accept:N}},[k,M,N]),I=(0,b.useMemo)(()=>!A||!k?.remote||i.status!==`ready`||!a||!r?.remoteHost?null:{publicProjectId:i.publicProjectId,bucket:a,coreVersion:i.coreVersion,schema:k,remoteHost:r.remoteHost},[A,k,i,a,r]),L=(0,b.useMemo)(()=>{if(A)return async(e,t)=>{try{let n=await gA(e,F),r;n.width&&n.height&&n.mimeType&&(r={width:n.width,height:n.height,mimeType:n.mimeType});let{patch:i,filePath:a}=await CA(c,n.src,n.filename??null,n.fileHash,r,`image`,I,P,!!j);if(i.length===0)return null;let o=i[0]&&`value`in i[0]&&typeof i[0].value==`object`&&i[0].value!==null&&`path`in i[0].value?i[0].value.path:a,s=i.filter(e=>e.op===`file`);_.current=!0;let l=t(o,{previewUrl:n.src,width:r?.width,height:r?.height,mimeType:r?.mimeType});h.current&&=(clearTimeout(h.current),null),v.current=!1;let f=p.current?.getDocument();if(!f)return null;let g=K3(c,f);m.current=f;let y=s.map(e=>({...e,...l?{nestedFilePath:l}:{}})),b=[...g,...y],x=[];j&&a&&r?.mimeType&&r.width!==void 0&&r.height!==void 0&&x.push({moduleFilePath:j,patch:[{op:`add`,path:[a],value:{width:r.width,height:r.height,mimeType:r.mimeType,alt:null}}]}),S(0),await u(b,`image`,e=>{console.error(`Failed to upload image in richtext:`,e),S(null)},(e,t,n,r)=>{let i=t>0?Math.round(e*(n+1)/(t*r)*100):0;S(Math.min(i,100))}),S(null);for(let e of x)d(e.moduleFilePath,e.patch,`record`);return{filePath:a,ref:o}}catch(e){return console.error(`Failed to prepare image for upload`,e),S(null),null}}},[A,c,I,P,j,u,d,F]),R=(0,b.useCallback)(()=>{if(!g.current){if(_.current){_.current=!1;return}v.current=!0,y.current=p.current?.getDocument()??null,h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,ee.current()},xGe)}},[]),ee=(0,b.useRef)(()=>void 0);return ee.current=()=>{let e=y.current??p.current?.getDocument();if(!e)return;y.current=null;let t=K3(c,e);m.current=e,l(t,`richtext`),v.current=!1},(0,b.useEffect)(()=>()=>{h.current&&(clearTimeout(h.current),h.current=null,ee.current()),v.current=!1},[]),s.status===`error`?(0,Y.jsx)(NC,{path:e,error:s.error,type:n}):o.status===`error`?(0,Y.jsx)(FC,{path:e,error:o.error,schema:s}):o.status===`not-found`||s.status===`not-found`?(0,Y.jsx)(MC,{path:e,type:n}):s.status===`loading`||!(`data`in o)||o.data===void 0?(0,Y.jsx)(jC,{path:e,type:n}):s.data.type===n?(r?.remoteHost||console.warn(`RichTextField: config.remoteHost is not set. Remote images will not work.`),(0,Y.jsx)(`div`,{id:e,className:`m-1`,children:(0,Y.jsx)(_Ge,{ref:p,defaultValue:f??[],features:E,linkCatalog:D,readOnly:t||g.current,onDirty:R,imageModulePath:O,onImageUpload:L,imageAccept:N,uploadProgress:x,portalContainer:w})})):(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:s.data.type})}function K3(e,t){return[{op:`replace`,path:e,value:t}]}function CGe({path:e}){let t=Ob(e,`richtext`);if(t.status===`error`)return(0,Y.jsx)(FC,{path:e,error:t.error});if(t.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:`richtext`});if(!(`data`in t)||t.data===void 0)return(0,Y.jsx)(J3,{path:e});if(t.data===null)return(0,Y.jsx)(Y3,{path:e});let n=wGe(t.data);return n.status===`error`?(0,Y.jsx)(FC,{path:e,error:n.error}):(0,Y.jsx)(`div`,{className:`truncate`,children:n.value})}function wGe(e){let t;function n(e){if(t)return t;if(typeof e==`string`)return e;if(typeof e==`object`&&e){if(`children`in e&&Array.isArray(e.children))return e.children.map(n).join(` `);if(`tag`in e&&typeof e.tag==`string`)return``}return t=`Invalid richtext node: `+JSON.stringify(e),JSON.stringify(e)}let r=e.map(n).join(` `);return t?{status:`error`,error:t}:{status:`ok`,value:r}}function q3({path:e,size:t}){let n=Cb(e),r=Ob(e,`data`in n&&n.data.type?n.data.type:void 0);if(!(`data`in n)||n.data===void 0)return(0,Y.jsx)(J3,{path:e});let i=n.data.type;return`data`in r&&r.data===null?(0,Y.jsx)(Y3,{path:e}):i===`string`?(0,Y.jsx)(ude,{path:e}):i===`array`?(0,Y.jsx)(FGe,{path:e}):i===`boolean`?(0,Y.jsx)(Cde,{path:e}):i===`number`?(0,Y.jsx)(Tde,{path:e}):i===`union`?(0,Y.jsx)(ige,{path:e}):i===`object`?(0,Y.jsx)(Jhe,{path:e,size:t}):i===`image`?(0,Y.jsx)(Uge,{path:e}):i===`keyOf`?(0,Y.jsx)(qge,{path:e}):i===`route`?(0,Y.jsx)(y_e,{path:e}):i===`date`?(0,Y.jsx)(qye,{path:e}):i===`dateTime`?(0,Y.jsx)(nbe,{path:e}):i===`color`?(0,Y.jsx)(nRe,{path:e}):i===`code`?(0,Y.jsx)($Le,{path:e}):i===`literal`?(0,Y.jsx)(rRe,{path:e}):i===`record`?(0,Y.jsx)(FRe,{path:e,size:t}):i===`richtext`?(0,Y.jsx)(CGe,{path:e}):i===`file`?(0,Y.jsx)(zge,{path:e}):(0,Y.jsxs)(`div`,{children:[`Cannot preview: `,i]})}function J3({path:e}){return(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(hy,{size:12,className:`animate-spin`})},e+`-loading`)}function Y3({path:e}){return(0,Y.jsx)(`div`,{id:e,className:`text-fg-quaternary`,children:`<empty>`},e+`-null`)}function X3({path:e,className:t,size:n}){let r=fk(e);return r?(0,Y.jsx)(ode,{title:r.title,image:r.image,subtitle:r.subtitle??null,className:t,size:n}):(0,Y.jsx)(`div`,{className:X(`p-2`,t),children:(0,Y.jsx)(q3,{path:e,size:n})})}function Z3({source:e,disabled:t,onMove:n,renderItem:r,className:i}){let[a,o]=(0,b.useState)([]);(0,b.useEffect)(()=>{let t=[],n=1;for(let r of e)t.push({path:r,id:n}),n++;o(t)},[e]);let s=bw(yw(nT),yw(iT),yw(Xw,{coordinateGetter:AT})),[c,l]=(0,b.useState)(null),u=c===null?void 0:a.find(e=>e.id===c),d=(0,b.useCallback)(e=>{let{active:t,over:r}=e;if(t?.id!==r?.id){let e=a.findIndex(e=>e.id===Number(t?.id)),i=a.findIndex(e=>e.id===Number(r?.id));o(t=>TT(t,e,i)),n(e,i)}l(null)},[a,n]);return(0,Y.jsxs)(bue,{sensors:s,collisionDetection:Dw,onDragStart:e=>l(Number(e.active.id)),onDragEnd:d,onDragCancel:()=>l(null),children:[(0,Y.jsx)(Yue,{items:a,strategy:Gue,disabled:t,children:(0,Y.jsx)(`div`,{className:i??`flex flex-col gap-y-4 w-full`,children:a.map(({path:e,id:t},n)=>(0,Y.jsx)(`div`,{style:{opacity:t===c?.3:void 0},children:r({path:e,id:t,index:n})},t))})}),(0,Y.jsx)(Bue,{dropAnimation:null,children:u?r({path:u.path,id:u.id,index:a.indexOf(u)}):null})]})}function TGe({source:e,disabled:t,onClick:n,onMove:r,onDelete:i,onDuplicate:a}){return(0,Y.jsx)(Z3,{source:e,disabled:t,onMove:r,renderItem:({path:e,id:r})=>(0,Y.jsx)(EGe,{id:r,disabled:t,path:e,onClick:n,onDelete:e=>{i(e-1)},onDuplicate:e=>{a(e-1)}})})}function EGe({id:e,path:t,disabled:n,onClick:r,onDelete:i,onDuplicate:a}){let o=eb(),s=(0,b.useRef)(null),[c,l]=(0,b.useState)(!1);(0,b.useEffect)(()=>{s.current&&(s.current.getBoundingClientRect().height>=170?l(!0):l(!1))},[e,t]);let{attributes:u,listeners:d,setNodeRef:f,transform:p,transition:m}=OT({id:e,disabled:n===!0}),h=Fb()||{},g={transform:mw.Transform.toString(p),transition:m},_=!(h[t]?.length>0);return(0,Y.jsxs)(`div`,{"touch-action":`manipulation`,ref:f,style:g,className:X(`relative flex disabled:opacity-55 flex-1`,{"items-start":!_,"items-center":_}),children:[(0,Y.jsx)(`button`,{...u,...d,className:X(`pb-1 pr-2 rounded-sm text-fg-secondary hover:text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,{"opacity-30":n,"mt-2.5":!_}),disabled:n,onClick:()=>{r(t)},children:(0,Y.jsx)(ay,{})}),(0,Y.jsxs)(`button`,{className:X(`flex-grow`,`relative flex text-left border rounded-lg border-border bg-card gap-y-2 bg-bg-primary`,`hover:bg-bg-secondary-hover`,`overflow-y-clip`),style:{maxHeight:170},ref:s,disabled:n,onClick:()=>{r(t)},children:[(0,Y.jsx)(X3,{path:t,className:`flex-grow w-full`}),c&&(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full bg-gradient-to-b via-50% from-transparent via-card/90 to-card`,style:{height:40}})]}),cX(t,h)&&(0,Y.jsx)(`div`,{className:X(`absolute right-3`,{"top-2":_,"top-0":!_}),children:(0,Y.jsx)(lX,{})}),(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(CD,{className:X(`flex hover:bg-bg-secondary-hover px-2 hover:rounded-lg`,{"items-start mt-4":!_,"items-center py-2":_}),children:(0,Y.jsx)(Yv,{size:16})}),(0,Y.jsxs)(wD,{className:`p-2`,container:o,side:`top`,children:[(0,Y.jsxs)(`button`,{className:X(`flex items-center gap-x-2`),onClick:()=>{i(e)},children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(Iy,{className:`w-4 h-4`})}),(0,Y.jsx)(`span`,{children:`Delete`})]}),(0,Y.jsxs)(`button`,{className:X(`flex items-center gap-x-2`),onClick:()=>{a(e)},children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(qv,{className:`w-4 h-4`})}),(0,Y.jsx)(`span`,{children:`Duplicate`})]})]})]})]})}var DGe=X(`[&_input]:h-7 [&_input]:m-0 [&_input]:w-full [&_input]:px-2 [&_input]:py-1 [&_input]:text-[13px]`,`[&_textarea]:min-h-0 [&_textarea]:m-0 [&_textarea]:px-2 [&_textarea]:py-1 [&_textarea]:text-[13px] [&_textarea]:leading-5 [&_textarea]:[field-sizing:content]`,`[&_[data-testid=auto-growing-textarea-ghost]]:m-0 [&_[data-testid=auto-growing-textarea-ghost]]:px-2 [&_[data-testid=auto-growing-textarea-ghost]]:py-1 [&_[data-testid=auto-growing-textarea-ghost]]:text-[13px] [&_[data-testid=auto-growing-textarea-ghost]]:leading-5`,`[&_.rich-text-editor:not(:focus-within)_.prose-editor]:p-2 [&_.rich-text-editor:not(:focus-within)_.prose-editor]:min-h-0`,`[&_.rich-text-editor:not(:focus-within)>.absolute]:hidden`,`[&_.prose-editor]:text-[13px]`);function Q3({path:e,readonly:t,depth:n=0}){let r=`array`,{navigate:i}=GC(),a=Ab(e),{source:o,schema:s,addPatch:c,patchPath:l}=yb(e,r,{watchUnsaved:!0}),[u,d]=(0,b.useState)([]),f=`data`in o&&o.data?o.data:null;(0,b.useEffect)(()=>{let e=[],t=1;for(let n of f??[])e.push({path:n,id:t}),t++;d(e)},[f]);let p=bw(yw(nT),yw(iT),yw(Xw,{coordinateGetter:AT})),[m,h]=(0,b.useState)(null),g=m===null?void 0:u.find(e=>e.id===m),_=(0,b.useCallback)((e,t)=>{c([{op:`move`,from:l.concat(e.toString()),path:l.concat(t.toString())}],r)},[c,l]),v=(0,b.useCallback)(e=>{let{active:t,over:n}=e;if(t?.id!==n?.id){let e=u.findIndex(e=>e.id===Number(t?.id)),r=u.findIndex(e=>e.id===Number(n?.id));d(t=>TT(t,e,r)),_(e,r)}h(null)},[u,_]);if(s.status===`error`||s.status===`not-found`||s.status===`loading`||f===null||s.data.type!==`array`)return null;let y=s.data,x=(e,o)=>(0,Y.jsx)(OGe,{id:e.id,index:o,path:e.path,itemSchema:y.item,depth:n,readonly:t,onNavigate:e=>i(e),onDelete:()=>{c([{op:`remove`,path:l.concat(o.toString())}],r)},onDuplicate:()=>{`data`in a&&a.data&&Array.isArray(a.data)&&c([{op:`add`,path:l.concat(o.toString()),value:a.data[o]??null}],r)}},e.id);return(0,Y.jsxs)(`div`,{id:e,className:X(`w-full`,{[DGe]:n===0}),children:[(0,Y.jsxs)(bue,{sensors:p,collisionDetection:Dw,onDragStart:e=>h(Number(e.active.id)),onDragEnd:v,onDragCancel:()=>h(null),children:[(0,Y.jsx)(Yue,{items:u,strategy:Gue,disabled:t,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:u.map((e,t)=>(0,Y.jsx)(`div`,{style:{opacity:e.id===m?.3:void 0},children:x(e,t)},e.id))})}),(0,Y.jsx)(Bue,{dropAnimation:null,children:g?x(g,u.indexOf(g)):null})]}),!t&&(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 h-6 mt-0.5 px-1 text-xs text-fg-tertiary hover:text-fg-primary`,onClick:()=>{c([{op:`add`,path:l.concat(u.length.toString()),value:Cp(y.item)}],r)},children:[(0,Y.jsx)(Oy,{size:12}),(0,Y.jsx)(`span`,{children:`Add`})]})]})}function OGe({id:e,index:t,path:n,itemSchema:r,depth:i,readonly:a,onNavigate:o,onDelete:s,onDuplicate:c}){let{attributes:l,listeners:u,setNodeRef:d,transform:f,transition:p}=OT({id:e,disabled:a===!0}),[m,h]=(0,b.useState)(!1),g=Pb(n),_={transform:mw.Transform.toString(f),transition:p},v=xr(r),y=v&&(r.type===`object`||r.type===`union`&&Zhe(r)),x=(0,Y.jsx)(`button`,{...l,...u,className:X(`cursor-grab text-fg-quaternary hover:text-fg-primary`,{"opacity-30":a}),disabled:a,children:(0,Y.jsx)(ay,{size:14})}),S=a?null:(0,Y.jsx)(MGe,{onDelete:s,onDuplicate:c});return(0,Y.jsxs)(`div`,{"touch-action":`manipulation`,"data-val-studio-path":n,ref:d,style:_,className:X(`border bg-bg-primary`,i===0?`rounded-md`:`rounded-r-md border-l-0`,{"border-border-primary":g.length===0,"border-bg-warning-secondary":g.length>0}),children:[y&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 h-7 px-1.5`,children:[x,(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 flex-1 min-w-0 text-left`,onClick:()=>h(e=>!e),children:[(0,Y.jsx)(Rv,{size:12,className:X(`shrink-0 text-fg-quaternary transition-transform`,{"rotate-90":!m})}),(0,Y.jsx)(`span`,{className:`w-4 shrink-0 text-[10px] text-fg-quaternary`,children:t+1}),(0,Y.jsx)(jGe,{path:n})]}),S]}),y&&!m&&(0,Y.jsx)(`div`,{className:`pr-1.5 pb-1.5 pt-0.5`,children:r.type===`union`?(0,Y.jsx)(kGe,{path:n,itemSchema:r,depth:i,readonly:a}):(0,Y.jsx)($3,{path:n,itemSchema:r,depth:i,readonly:a})}),v&&!y&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 px-1.5 py-1`,children:[(0,Y.jsx)(`div`,{className:`pt-2`,children:x}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(r6,{path:n,schema:r,readonly:a===!0||r.readonly===!0,compact:!0,errorDisplay:`none`})}),S]}),!v&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1.5 py-1`,children:[x,(0,Y.jsx)(`button`,{className:`flex-1 min-w-0 overflow-y-clip rounded text-left text-xs hover:bg-bg-secondary-hover`,style:{maxHeight:96},onClick:()=>o(n),children:(0,Y.jsx)(X3,{path:n,className:`w-full`})}),S]}),g.length>0&&(0,Y.jsx)(`div`,{className:`px-2.5 pb-1.5`,children:(0,Y.jsx)(Uk,{validationErrors:g})})]})}function kGe({path:e,itemSchema:t,depth:n,readonly:r}){return Zhe(t)?(0,Y.jsx)(AGe,{path:e,itemSchema:t,depth:n,readonly:r}):null}function AGe({path:e,itemSchema:t,depth:n,readonly:r}){let i=$he(e,t);return i.status===`loading`?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{className:`pl-2`,children:(0,Y.jsx)(ege,{state:i,readonly:r,className:`h-7 w-auto min-w-24 px-2 py-1 text-[13px]`})}),(0,Y.jsx)($3,{path:e,itemSchema:i.selectedSchema,depth:n,readonly:r,omitKeys:[t.key]})]})}function $3({path:e,itemSchema:t,depth:n,readonly:r,omitKeys:i}){let[a,o]=(0,b.useState)({});return t.type===`object`?(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:Object.entries(t.items).map(([t,s])=>{if(s.hidden||i?.includes(t))return null;let c=sD(e,t),l=r===!0||s.readonly===!0;if(s.type===`array`&&xr(s.item)){let e=a[t]===!0;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 pl-2 text-left`,onClick:()=>o(n=>({...n,[t]:!e})),children:[(0,Y.jsx)(Rv,{size:10,className:X(`shrink-0 text-fg-quaternary transition-transform`,{"rotate-90":!e})}),(0,Y.jsx)(e6,{label:t})]}),!e&&(0,Y.jsx)(Q3,{path:c,depth:n+1,readonly:l})]},t)}return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2`,children:[(0,Y.jsx)(e6,{label:t}),(0,Y.jsx)(r6,{path:c,schema:s,readonly:l,compact:!0,errorDisplay:`compact`})]},t)})}):null}function e6({label:e}){return(0,Y.jsx)(`span`,{className:`text-[11px] leading-4 text-fg-tertiary`,children:e})}function jGe({path:e}){let t=fk(e),n=Ab(e),r=(0,b.useMemo)(()=>t?.title?t.title:`data`in n&&n.data!==void 0?t6(n.data):null,[t,n]);return(0,Y.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-xs text-fg-tertiary`,children:r??``})}function t6(e){if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=t6(t);if(e!==null)return e}return null}if(typeof e==`object`&&e)for(let[t,n]of Object.entries(e)){if(t===`type`||t===`_type`||t===`tag`||n===void 0)continue;let e=t6(n);if(e!==null)return e}return null}function MGe({onDelete:e,onDuplicate:t}){let n=eb();return(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(CD,{className:`shrink-0 rounded px-0.5 py-1 text-fg-quaternary hover:text-fg-primary hover:bg-bg-secondary-hover`,children:(0,Y.jsx)(Yv,{size:14})}),(0,Y.jsxs)(wD,{className:`p-2 w-auto`,container:n,side:`top`,children:[(0,Y.jsxs)(`button`,{className:`flex items-center gap-x-2 text-sm`,onClick:e,children:[(0,Y.jsx)(Iy,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:`Delete`})]}),(0,Y.jsxs)(`button`,{className:`flex items-center gap-x-2 text-sm`,onClick:t,children:[(0,Y.jsx)(qv,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:`Duplicate`})]})]})]})}function NGe({id:e,disabled:t,children:n}){let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s}=OT({id:e,disabled:t===!0}),c={transform:mw.Transform.toString(o),transition:s};return(0,Y.jsxs)(`div`,{ref:a,style:c,className:`flex items-start gap-2`,children:[(0,Y.jsx)(`button`,{...r,...i,className:X(`pt-4 pr-1`,{invisible:t}),disabled:t,children:(0,Y.jsx)(ay,{size:16})}),(0,Y.jsx)(`div`,{className:`flex-1`,children:n})]})}function PGe({path:e,readonly:t,compact:n,inline:r,errorDisplay:i=`default`}){let a=`array`,{navigate:o}=GC(),s=xb(e),c=Ab(e),{source:l,schema:u,addPatch:d,patchPath:f,hasUnsavedOwnEdit:p}=yb(e,a,{watchUnsaved:!0});if(u.status===`error`)return(0,Y.jsx)(NC,{path:e,error:u.error,type:a});if(l.status===`error`)return(0,Y.jsx)(FC,{path:e,error:l.error,schema:u});if(l.status==`not-found`||u.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:a});if(u.status===`loading`)return(0,Y.jsx)(jC,{path:e,type:a});if(u.data.type!==`array`)return(0,Y.jsx)(PC,{path:e,expectedType:`array`,actualType:u.data.type});let m=u.data,h=(s&&`data`in s?s.data:void 0)!==void 0&&(p||l.status===`loading`);if(xr(m.item))return(0,Y.jsxs)(`div`,{className:`relative w-full`,children:[s?.status===`error`&&(0,Y.jsx)(uX,{error:s.message,path:e}),(0,Y.jsx)(Q3,{path:e,readonly:t})]});if(r){let a=l.data;return a===null?null:(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(Z3,{source:a,disabled:t,onMove:(e,t)=>{d([{op:`move`,from:f.concat(e.toString()),path:f.concat(t.toString())}],m.type)},className:`flex flex-col ${n?`gap-3`:`gap-4`}`,renderItem:({path:e,id:a})=>m.item.hidden?null:(0,Y.jsx)(NGe,{id:a,disabled:t,children:(0,Y.jsx)(qk,{path:e,type:m.item.type,readonly:t||m.item.readonly,compact:n,errorDisplay:i,children:(0,Y.jsx)(r6,{path:e,schema:m.item,readonly:t||m.item.readonly,compact:n,inline:r,errorDisplay:i})})})})})}return(0,Y.jsxs)(`div`,{id:e,className:`relative w-full`,children:[s?.status===`error`&&(0,Y.jsx)(uX,{error:s.message,path:e}),h&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-[40] flex items-center text-fg-secondary`,children:(0,Y.jsx)(hy,{className:`animate-spin h-4 w-4`})}),(0,Y.jsx)(TGe,{path:e,disabled:t,onClick:e=>{o(e)},onDelete:async e=>{d([{op:`remove`,path:f.concat(e.toString())}],m.type)},onDuplicate:async e=>{`data`in c&&c.data&&Array.isArray(c.data)&&d([{op:`add`,path:f.concat(e.toString()),value:c.data?.[e]??null}],m.type)},onMove:async(e,t)=>{d([{op:`move`,from:f.concat(e.toString()),path:f.concat(t.toString())}],m.type)},source:l.data||[]})]})}function FGe({path:e}){let t=Ob(e,`array`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(`div`,{children:`${t.data.length} items`})}function IGe({path:e}){let t=Pb(e)??[];return(0,Y.jsx)(Uk,{validationErrors:t})}var n6=(0,b.createContext)(!1);function LGe({held:e,children:t}){return(0,Y.jsx)(n6.Provider,{value:e,children:t})}function RGe(){return(0,b.useContext)(n6)}function r6({path:e,schema:t,autoFocus:n,readonly:r,compact:i,inline:a,hideUpload:o,errorDisplay:s=`default`}){let c=RGe();if(t.hidden)return null;let l=r||t.readonly||c,u={readonly:l,compact:i},d;if(t.type===`string`)d=(0,Y.jsx)(lde,{path:e,autoFocus:n,...u},e);else if(t.type===`number`)d=(0,Y.jsx)(wde,{path:e,...u},e);else if(t.type===`boolean`)d=(0,Y.jsx)(xde,{path:e,...u},e);else if(t.type===`image`)d=(0,Y.jsx)(Vge,{path:e,...u,hideUpload:o},e);else if(t.type===`object`)return(0,Y.jsx)(qhe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`array`)return(0,Y.jsx)(PGe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`record`)return(0,Y.jsx)(ARe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`union`)return(0,Y.jsx)(Qhe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else d=t.type===`keyOf`?(0,Y.jsx)(Gge,{path:e,...u},e):t.type===`route`?(0,Y.jsx)(v_e,{path:e,...u},e):t.type===`richtext`?(0,Y.jsx)(SGe,{path:e,autoFocus:n,...u},e):t.type===`date`?(0,Y.jsx)(Kye,{path:e,...u},e):t.type===`dateTime`?(0,Y.jsx)(tbe,{path:e,...u},e):t.type===`color`?(0,Y.jsx)(tRe,{path:e,...u},e):t.type===`code`?(0,Y.jsx)(QLe,{path:e,...u},e):t.type===`file`?(0,Y.jsx)(Rge,{path:e,...u},e):t.type===`literal`?(0,Y.jsx)(NC,{path:e,error:`Literal fields are not editable`}):(0,Y.jsx)(NC,{path:e,error:`Unexpected field schema: `+JSON.stringify(t)});return s===`compact`?(0,Y.jsxs)(`div`,{className:`flex items-stretch gap-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:d}),(0,Y.jsx)(`div`,{className:`flex items-center px-1`,children:(0,Y.jsx)(Fhe,{path:e})})]}):(0,Y.jsxs)(Y.Fragment,{children:[d,s==="default"&&(0,Y.jsx)(zGe,{path:e})]})}function zGe({path:e}){return Rhe()?null:(0,Y.jsx)(IGe,{path:e})}var BGe=8,VGe=1200;function HGe({paths:e,selectedPath:t,onSelect:n}){let[r,i]=(0,b.useState)(``),a=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=a.current;if(!t||!e)return;let n=()=>{let n=e.querySelector(`[data-canvas-field="${CSS.escape(t)}"]`);if(!(n instanceof HTMLElement))return;let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();i.top>=r.top&&i.bottom<=r.bottom||(e.scrollTop+=i.top-r.top-BGe)};n();let r=new ResizeObserver(n);r.observe(e);for(let t of Array.from(e.children))r.observe(t);let i=setTimeout(()=>r.disconnect(),VGe);return()=>{clearTimeout(i),r.disconnect()}},[t,e]);let o=(0,b.useMemo)(()=>{let t=new Map;for(let n of e){let[e]=H.splitModuleFilePathAndModulePath(n),r=t.get(e);r?r.push(n):t.set(e,[n])}return Array.from(t.entries()).map(([e,t])=>({moduleFilePath:e,label:kC(e.split(`/`).pop()??e),entries:t}))},[e]),s=(0,b.useMemo)(()=>{let e=r.trim().toLowerCase();return e?o.map(t=>({...t,entries:t.entries.filter(t=>t.toLowerCase().includes(e))})).filter(e=>e.entries.length>0):o},[o,r]);return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-xl border border-border-float bg-bg-float`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-border-float px-3 py-2.5`,children:[(0,Y.jsxs)(`h2`,{className:`text-[0.8125rem] font-medium text-fg-primary`,children:[`On this page`,(0,Y.jsx)(`span`,{className:`ml-1.5 font-normal text-fg-secondary-alt`,children:e.length})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-[0.6875rem] leading-relaxed text-fg-secondary-alt`,children:`Edit here, or click an element on the page.`})]}),(0,Y.jsx)(`div`,{className:`shrink-0 border-b border-border-float px-2 py-2`,children:(0,Y.jsxs)(`div`,{className:`flex h-7 items-center gap-1.5 rounded-md bg-bg-float-raised px-2 focus-within:ring-2 focus-within:ring-border-focus`,children:[(0,Y.jsx)(My,{size:12,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Filter fields…`,"aria-label":`Filter fields`,className:`min-w-0 flex-1 bg-transparent text-xs text-fg-primary placeholder:text-fg-secondary-alt focus:outline-none`})]})}),(0,Y.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto scrollbar-slim px-2 py-2`,children:s.length===0?(0,Y.jsx)(`p`,{className:`px-1 py-6 text-center text-xs text-fg-secondary-alt`,children:r?`No fields match this filter.`:`The page reported no editable content.`}):s.map(e=>(0,Y.jsxs)(`section`,{className:`mb-3`,children:[(0,Y.jsx)(`h3`,{title:e.moduleFilePath,className:`truncate px-1 pb-1.5 text-[0.625rem] font-medium uppercase tracking-wide text-fg-secondary-alt`,children:e.label}),(0,Y.jsx)(`div`,{className:`space-y-2`,children:e.entries.map(e=>(0,Y.jsx)(UGe,{path:e,selected:t===e,onSelect:n},e))})]},e.moduleFilePath))})]})}function UGe({path:e,selected:t,onSelect:n}){let r=Cb(e);return(0,Y.jsxs)(`div`,{"data-canvas-field":e,onFocusCapture:()=>n?.(e),className:X(`rounded-lg border px-2.5 py-2`,t?`border-border-brand-primary bg-bg-float-raised`:`border-border-float`),children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n?.(e),title:e,className:`mb-1.5 block max-w-full truncate text-left text-[0.8125rem] font-medium text-fg-primary`,children:WGe(e)}),r.status===`error`?(0,Y.jsx)(NC,{path:e,error:r.error,type:`module`}):r.status===`loading`?(0,Y.jsx)(jC,{path:e,type:`module`}):r.status===`not-found`?(0,Y.jsx)(MC,{path:e,type:`module`}):(0,Y.jsx)(r6,{path:e,schema:r.data,compact:!0})]})}function WGe(e){let[,t]=H.splitModuleFilePathAndModulePath(e);if(!t)return e;let n=H.splitModulePath(t),r=n.length>1&&n[0].startsWith(`/`)?n.slice(1):n;return r.length===0?n.join(` › `):r.join(` › `)}function i6(e,t,n){(0,b.useEffect)(()=>{if(!t)return;let r=t=>{let r=e.current;r&&t.composedPath().includes(r)||n()};return document.addEventListener(`pointerdown`,r),()=>document.removeEventListener(`pointerdown`,r)},[t,n,e])}var a6=12;function GGe({value:e,routes:t,onChange:n,className:r}){let[i,a]=(0,b.useState)(e),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(0),u=(0,b.useRef)(null);(0,b.useEffect)(()=>{o||a(e)},[e,o]);let d=(0,b.useMemo)(()=>{let e=i.trim().toLowerCase();if(!e)return t.slice(0,a6);let n=t=>{let n=t.toLowerCase();return n===e?0:n.startsWith(e)?1:2};return t.filter(t=>t.toLowerCase().includes(e)).map((e,t)=>({route:e,index:t,rank:n(e)})).sort((e,t)=>e.rank-t.rank||e.index-t.index).slice(0,a6).map(e=>e.route)},[t,i]),f=(0,b.useMemo)(()=>{let e=i.trim().toLowerCase(),n=e?t.filter(t=>t.toLowerCase().includes(e)).length:t.length;return Math.max(0,n-d.length)},[t,i,d.length]);(0,b.useEffect)(()=>l(0),[i]),i6(u,o,(0,b.useCallback)(()=>{s(!1),a(e)},[e]));let p=t=>{let r=KGe(t);s(!1),a(r),r!==e&&n(r)};return(0,Y.jsxs)(`div`,{ref:u,className:X(`relative`,r),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 h-8 pl-2 pr-1 rounded-md border border-border-float bg-bg-float`,children:[(0,Y.jsx)(uy,{size:13,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),s(!0)},onFocus:()=>s(!0),onKeyDown:t=>{if(t.key===`Escape`){t.preventDefault(),s(!1),a(e),t.currentTarget.blur();return}if(t.key===`Enter`){t.preventDefault();let e=o?d[c]:void 0;p(e??i),t.currentTarget.blur();return}(t.key===`ArrowDown`||t.key===`ArrowUp`)&&d.length>0&&(t.preventDefault(),s(!0),l(e=>((t.key===`ArrowDown`?e+1:e-1)+d.length)%d.length))},spellCheck:!1,"aria-label":`Canvas route`,placeholder:`/`,className:`min-w-0 flex-1 bg-transparent font-mono text-[0.6875rem] text-fg-primary placeholder:text-fg-secondary-alt focus:outline-none`}),i!==e&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Discard the typed route`,onClick:()=>{a(e),s(!1)},className:`grid h-6 w-6 shrink-0 place-items-center rounded text-fg-secondary-alt hover:text-fg-primary`,children:(0,Y.jsx)(Hy,{size:12})})]}),o&&d.length>0&&(0,Y.jsxs)(`ul`,{role:`listbox`,"aria-label":`Tracked routes`,className:`absolute left-0 right-0 top-full z-window mt-1 max-h-56 overflow-y-auto rounded-md border border-border-float bg-bg-float py-1 shadow-lg scrollbar-slim`,children:[d.map((e,t)=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":t===c,onMouseMove:()=>l(t),onMouseDown:t=>{t.preventDefault(),p(e)},className:X(`block w-full truncate px-2.5 py-1 text-left font-mono text-[0.6875rem]`,t===c?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary`),children:e})},`${t}-${e}`)),f>0&&(0,Y.jsxs)(`li`,{"aria-hidden":!0,className:`px-2.5 py-1 text-[0.625rem] text-fg-secondary-alt`,children:[f,` more — keep typing to narrow`]})]})]})}function KGe(e){let t=e.trim();if(t===``)return`/`;if(/^[a-z][a-z0-9+.-]*:\/\//i.test(t))try{let e=new URL(t);return`${e.pathname}${e.search}${e.hash}`||`/`}catch{}return t.startsWith(`/`)?t:`/${t}`}var qGe={desktop:1280,tablet:834,mobile:390},JGe={desktop:800,tablet:1112,mobile:844},YGe=`clamp(340px, 34%, 520px)`,o6=320,XGe=280,ZGe=.72,QGe=24,$Ge=`4.5rem`,eKe=`8.25rem`,s6=`2.125rem`,tKe=320,c6=200,l6=`cubic-bezier(0.4, 0, 0.2, 1)`;function nKe({children:e,breakpoint:t,page:n,renderCanvas:r,canvasPaths:i,onSelectCanvasPath:a,selectedCanvasPath:o,canvasRoute:s,onCanvasRouteChange:c,canvasRoutes:l,initialTransform:u,onTransformChange:d,isCanvasOpen:f,onCloseCanvas:p,view:m,onViewChange:h,pane:g,onPaneChange:_,isDevMode:v,onAttachToChat:y,skipTransition:x}){let S=t===`mobile`,C=CC(),w=f&&(n!==void 0||r!==void 0),T=e=>C||x?void 0:e.map(e=>`${e} ${tKe}ms ${l6}`).join(`, `),[E,D]=(0,b.useState)(S?`mobile`:`desktop`),[O,k]=(0,b.useState)(()=>u?.scale??1),A=(0,b.useRef)(O);A.current=O;let j=(0,b.useRef)({x:u?.x??0,y:u?.y??0});(0,b.useEffect)(()=>{d?.({scale:O,...j.current})},[O,d]);let M=(0,b.useCallback)(e=>{j.current=e,d?.({scale:A.current,...e})},[d]),[N,P]=(0,b.useState)(null),[F,I]=(0,b.useState)([]);(0,b.useEffect)(()=>{w||(P(null),I(e=>e.length===0?e:[]))},[w]);let L=(0,b.useRef)(null),R=(0,b.useRef)(null),[ee,te]=(0,b.useState)(null),[ne,re]=(0,b.useState)(0),[ie,ae]=(0,b.useState)(!1),[oe,se]=(0,b.useState)(0);(0,b.useEffect)(()=>{let e=R.current;if(!e)return;let t=new ResizeObserver(()=>se(e.clientWidth));return t.observe(e),se(e.clientWidth),()=>t.disconnect()},[]);let ce=(0,b.useMemo)(()=>{if(oe===0)return{min:o6,max:o6};let e=Math.max(o6,Math.min(oe*ZGe,oe-XGe));return{min:Math.min(o6,e),max:e}},[oe]),le=(0,b.useCallback)(e=>Math.round(Math.min(ce.max,Math.max(ce.min,e))),[ce]);(0,b.useEffect)(()=>{if(ee===null)return;let e=le(ee);e!==ee&&te(e)},[ee,le]);let ue=(0,b.useCallback)(e=>{if(e.button!==0)return;let t=R.current;if(!t)return;e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),ae(!0);let n=t.getBoundingClientRect().left,r=e=>{te(le(e.clientX-n))},i=()=>{ae(!1),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),window.removeEventListener(`pointercancel`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i),window.addEventListener(`pointercancel`,i)},[le]),de=(0,b.useCallback)(e=>{let t=R.current,n=ee??t?.firstElementChild?.clientWidth??o6;te(le(n+e))},[ee,le]),fe=qGe[E],[pe,me]=(0,b.useState)(u==null),he=(0,b.useRef)({device:E,open:w});(0,b.useEffect)(()=>{(he.current.device!==E||he.current.open!==w)&&(he.current={device:E,open:w},me(!0))},[E,w]);let ge=(0,b.useCallback)(()=>{re(e=>e+1),me(!0)},[]),_e=(0,b.useCallback)(()=>me(!1),[]),ve=(0,b.useCallback)((e,t)=>{L.current?.zoomBy(e,t)},[]),ye=(0,b.useCallback)(e=>{L.current?.pinch(e)},[]),be=(0,b.useCallback)(e=>{I(t=>t.includes(e)?t:[...t,e]);let t=n?.fields[e];t&&y?.(t.sourcePath)},[n,y]),[xe,Se]=Qce(m),Ce=(0,b.useCallback)(()=>{xe&&(h(`fields`),S&&_(`editor`))},[xe,h,S,_]),[we,z]=(0,b.useState)(!1),B=t===`desktop`&&w?{paddingLeft:`5.5rem`}:void 0,Te=i??[],Ee=n?Object.keys(n.fields).length:Te.length,V=(0,Y.jsx)(oKe,{view:m,onChange:h,fieldCount:Ee>0?Ee:void 0,animate:!C}),De=g===`canvas`?`preview`:m===`fields`?`fields`:`normal`,Oe=(0,b.useCallback)(e=>{if(e===`preview`){_(`canvas`);return}_(`editor`),h(e)},[_,h]),ke=w&&!S,Ae=!ke&&!(w&&S),je=(0,Y.jsx)(`div`,{id:`val-content-area`,"data-scroll-clearance":ke?16:96,className:`h-full overflow-y-auto scrollbar-slim`,children:(0,Y.jsx)(`div`,{style:{maxWidth:qce,...B},className:X(`w-full mx-auto px-4 md:px-6 pb-24`,Ae?`pt-20 desktop:pt-24`:`pt-1`),children:e})}),Me=(0,Y.jsx)(`div`,{style:B,className:`h-full px-4 md:px-6 pt-1 pb-14`,children:n?(0,Y.jsx)(ole,{page:n,selectedFieldId:N,onSelectField:P,onChangeField:()=>void 0,onAttachField:be,attachedFieldIds:F,isDevMode:v}):Te.length>0?(0,Y.jsx)(HGe,{paths:Te,selectedPath:o,onSelect:a}):(0,Y.jsx)(rKe,{onGoToPreview:S?()=>_(`canvas`):void 0})}),Ne=(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[ke&&(0,Y.jsx)(`div`,{style:B,className:`shrink-0 px-4 md:px-6 pt-20 pb-2.5`,children:V}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1`,children:m===`fields`&&w?Me:je})]}),Pe=s!==void 0&&c&&(0,Y.jsx)(GGe,{value:s,routes:l??[],onChange:c,className:`min-w-0 flex-1 md:max-w-[28rem]`}),Fe=w&&(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-2`,children:[(Pe||!S)&&(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[Pe,!S&&(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Exit Preview`,onClick:p,className:X(`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md pl-2.5 pr-3`,`border border-border-float bg-bg-float text-fg-secondary`,`hover:text-fg-primary`),children:[(0,Y.jsx)(Hy,{size:15}),(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:`Exit Preview`})]})]}),(0,Y.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border-float bg-bg-float-raised`,children:(0,Y.jsx)(nle,{ref:L,pageWidth:fe,scale:O,onScaleChange:k,autoFit:pe,onUserZoom:_e,initialScroll:u&&{x:u.x,y:u.y},onScrollChange:M,className:`h-full`,children:(0,Y.jsx)(`div`,{className:`shadow-2xl`,onClick:()=>P(null),children:r?.({device:E,width:fe,height:JGe[E],reloadKey:ne,isPicking:xe,onRequestReload:ge,onRefreshingChange:z,onPinch:ye,onZoom:(e,t)=>ve(e,t),onPicked:Ce})??(n&&(0,Y.jsx)($ce,{page:n,device:E,selectedFieldId:xe?N:null,attachedFieldIds:xe?F:[],onSelectField:e=>{xe&&(P(e),Ce())},isSelectMode:xe}))})})}),(0,Y.jsx)(`div`,{className:`flex shrink-0 justify-center`,children:(0,Y.jsx)(ele,{className:`max-w-full`,device:E,onDeviceChange:D,scale:O,onZoomIn:()=>ve(1.2,null),onZoomOut:()=>ve(1/1.2,null),onFit:()=>me(!0),isPicking:xe,onPickingChange:Ee>0?Se:void 0,isRefreshing:we,onReload:r&&ge})})]});return S?(0,Y.jsxs)(`div`,{className:`absolute inset-0 bg-bg-canvas`,children:[(0,Y.jsx)(`div`,{className:`h-full overflow-clip`,style:w?{paddingTop:eKe}:void 0,children:(0,Y.jsxs)(`div`,{className:`flex h-full w-full`,style:{transform:`translateX(${w&&g===`canvas`?`-100%`:`0%`})`,transition:T([`transform`])},children:[(0,Y.jsx)(`div`,{className:`h-full w-full shrink-0`,children:Ne}),w&&(0,Y.jsx)(`div`,{className:`h-full w-full shrink-0 p-3 pb-14`,children:Fe})]})}),w&&(0,Y.jsxs)(`div`,{className:`absolute inset-x-3 z-window flex items-center gap-2`,style:{top:$Ge},children:[(0,Y.jsx)(aKe,{mode:De,onChange:Oe,fieldCount:Ee>0?Ee:void 0,animate:!C}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Exit Preview`,onClick:p,style:{height:s6,width:s6},className:X(`ml-auto grid shrink-0 place-items-center rounded-md`,`border border-border-float bg-bg-float text-fg-secondary`),children:(0,Y.jsx)(Hy,{size:15})})]})]}):(0,Y.jsxs)(`div`,{ref:R,className:`absolute inset-0 flex overflow-hidden bg-bg-canvas`,children:[(0,Y.jsx)(`div`,{style:{width:w?ee===null?YGe:`${ee}px`:`100%`,transition:ie?void 0:T([`width`])},className:`relative h-full min-w-0 shrink-0`,children:Ne}),w&&(0,Y.jsx)(iKe,{isDragging:ie,onPointerDown:ue,onNudge:de}),(0,Y.jsx)(`div`,{style:{transition:T([`opacity`,`transform`])},className:X(`min-w-0 flex-1 pt-20 pb-14 pr-3`,w?`scale-100 opacity-100`:`invisible pointer-events-none scale-95 opacity-0`),children:Fe})]})}function rKe({onGoToPreview:e}){return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 rounded-xl border border-border-float bg-bg-float px-6 text-center`,children:[(0,Y.jsx)(py,{size:20,className:`text-fg-secondary-alt`}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`h2`,{className:`text-[0.8125rem] font-medium text-fg-primary`,children:`Nothing reported yet`}),(0,Y.jsx)(`p`,{className:`text-[0.6875rem] leading-relaxed text-fg-secondary-alt`,children:`Usually that means preview mode is off: without it the page mounts none of Val's client code and tags nothing, and the Preview has the button that turns it on. A page that is already in preview mode and simply has no Val content on it looks the same from here.`})]}),e&&(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:X(`inline-flex h-8 items-center gap-1.5 rounded-md px-3`,`border border-border-float bg-bg-float-raised text-xs font-medium`,`text-fg-secondary hover:text-fg-primary`),children:[(0,Y.jsx)(Qv,{size:13}),`Go to Preview`]})]})}function iKe({isDragging:e,onPointerDown:t,onNudge:n}){return(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the editor and canvas`,tabIndex:0,onPointerDown:t,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),n(-24)):e.key===`ArrowRight`&&(e.preventDefault(),n(QGe))},className:X(`group relative z-hover w-3 shrink-0 cursor-col-resize self-stretch`,`focus-visible:outline-none`),children:(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`pointer-events-none absolute inset-y-14 left-1/2 w-px -translate-x-1/2 rounded-full`,`transition-colors`,e?`bg-fg-brand-primary`:`bg-border-float group-hover:bg-fg-secondary group-focus-visible:bg-fg-brand-primary`)})})}function u6({label:e,value:t,onChange:n,options:r,animate:i,compact:a}){let o=Math.max(0,r.findIndex(e=>e.value===t)),s=(0,b.useRef)(null),[c,l]=(0,b.useState)(null);return(0,b.useLayoutEffect)(()=>{let e=s.current;if(e===null)return;let t=()=>{let t=e.querySelectorAll(`button`)[o];if(t===void 0)return;let n=t.getBoundingClientRect().left-e.getBoundingClientRect().left-e.clientLeft,r=t.getBoundingClientRect().width;l(e=>e!==null&&e.left===n&&e.width===r?e:{left:n,width:r})};t();let n=new ResizeObserver(t);return n.observe(e),e.querySelectorAll(`button`).forEach(e=>n.observe(e)),()=>n.disconnect()},[o,r.length]),(0,Y.jsxs)(`div`,{ref:s,role:`tablist`,"aria-label":e,className:`relative inline-flex rounded-md border border-border-float bg-bg-float p-0.5`,children:[c!==null&&(0,Y.jsx)(`span`,{"aria-hidden":!0,style:{width:c.width,transform:`translateX(${c.left}px)`,transition:i?`transform ${c6}ms ${l6}, width ${c6}ms ${l6}`:void 0},className:`absolute inset-y-0.5 left-0 rounded bg-bg-float-raised shadow-sm`}),r.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:X(`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded text-[0.6875rem] transition-colors`,a?`px-2.5`:`px-4`,t===e.value?`font-medium text-fg-primary`:`text-fg-secondary hover:text-fg-primary`),children:[(0,Y.jsx)(e.icon,{size:12}),e.label,e.badge!==void 0&&(0,Y.jsx)(`span`,{className:`tabular-nums text-fg-secondary-alt`,children:e.badge})]},e.value))]})}function aKe({mode:e,onChange:t,fieldCount:n,animate:r}){return(0,Y.jsx)(u6,{label:`Workspace view`,value:e,onChange:t,animate:r,options:[{value:`normal`,label:`Normal`,icon:Py},{value:`fields`,label:`Fields`,icon:py,badge:n},{value:`preview`,label:`Preview`,icon:Qv}],compact:!0})}function oKe({view:e,onChange:t,fieldCount:n,animate:r}){return(0,Y.jsx)(u6,{label:`Preview view`,value:e,onChange:t,animate:r,options:[{value:`normal`,label:`Normal`,icon:Py},{value:`fields`,label:`Fields`,icon:py,badge:n}]})}function sKe({selectionKind:e,editedPath:t,canvasModules:n}){if(e===`page`)return!0;if(t===null)return!1;let[r]=H.splitModuleFilePathAndModulePath(t);return n.has(r)?!0:n.size===0&&e===null}function cKe(e){let t=new Set;for(let n of e??[])t.add(H.splitModuleFilePathAndModulePath(n)[0]);return Array.from(t).sort().join(`
|
|
215
|
+
`).scrollIntoView()),!0)};function h2(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var _He=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=h2(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(nQ.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},vHe=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof lQ||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=h2(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(oQ.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},yHe=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(BZ(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&FZ(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function bHe(e){return(t,n)=>{if(t.selection instanceof cQ&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!BZ(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof oQ||t.selection instanceof lQ)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=h2(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=BZ(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,BZ(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var xHe=bHe(),SHe=(e,t)=>(t&&t(e.tr.setSelection(new lQ(e.doc))),!0);function CHe(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||VZ(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function g2(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&CHe(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=vX.empty;for(let e=o.length-1;e>=0;e--)s=vX.from(o[e].create(null,s));s=vX.from(i.copy(s));let c=e.tr.step(new MZ(t.pos-1,r,t.pos,r,new wX(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&VZ(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:nQ.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&FZ(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&f2(a,`start`,!0)&&f2(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=vX.empty;for(let e=o.length-1;e>=0;e--)r=vX.from(o[e].copy(r));n(e.tr.step(new MZ(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new wX(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function _2(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(oQ.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var wHe=_2(-1),THe=_2(1);function v2(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&IZ(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function y2(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t))){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function EHe(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function DHe(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new rQ(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new rQ(r,i))}return t}function b2(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!EHe(n.doc,l,e,i))return!1;if(o){if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=DHe(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}}return!0}}function x2(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var S2=x2(d2,uHe,dHe),C2=x2(d2,pHe,mHe),w2={Enter:x2(gHe,vHe,yHe,xHe),"Mod-Enter":_He,Backspace:S2,"Mod-Backspace":S2,"Shift-Backspace":S2,Delete:C2,"Mod-Delete":C2,"Mod-a":SHe},T2={"Ctrl-h":w2.Backspace,"Alt-Backspace":w2[`Mod-Backspace`],"Ctrl-d":w2.Delete,"Ctrl-Alt-Backspace":w2[`Mod-Delete`],"Alt-Delete":w2[`Mod-Delete`],"Alt-d":w2[`Mod-Delete`],"Ctrl-a":wHe,"Ctrl-e":THe};for(let e in w2)T2[e]=w2[e];var E2=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?T2:w2;function D2(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return OHe(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function OHe(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new LX(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new LX(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=IZ(a,n,r,t);return s?(e&&kHe(e,t,s,i,n),!0):!1}function kHe(e,t,n,r,i){let a=vX.empty;for(let e=n.length-1;e>=0;e--)a=vX.from(n[e].type.create(n[e].attrs,a));e.step(new MZ(t.start-(r?2:0),t.end,t.start,t.end,new wX(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&BZ(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function O2(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(s.type!=e)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let t=vX.empty,a=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-a;e>=i.depth-3;e--)t=vX.from(i.node(e).copy(t));let o=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;t=t.append(vX.from(e.createAndFill()));let s=i.before(i.depth-(a-1)),c=n.tr.replace(s,i.after(-o),new wX(t,4-a,0)),l=-1;c.doc.nodesBetween(s,c.doc.content.size,(e,t)=>{if(l>-1)return!1;e.isTextblock&&e.content.size==0&&(l=t+1)}),l>-1&&c.setSelection(nQ.near(c.doc.resolve(l))),r(c.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return BZ(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function k2(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?AHe(t,n,e,a):jHe(t,n,a):!0:!1}}function AHe(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new MZ(a-1,o,a,o,new wX(vX.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new LX(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=FZ(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return VZ(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function jHe(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?vX.empty:vX.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new MZ(d-+!!s,f+ +!!c,d+1,f-1,new wX((s?vX.empty:vX.from(i.copy(vX.empty))).append(c?vX.empty:vX.from(i.copy(vX.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function A2(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=vX.from(r?e.create():null),o=new wX(vX.from(e.create(null,vX.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new MZ(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var j2=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`];function M2(e){return e.h1||e.h2||e.h3||e.h4||e.h5||e.h6}var MHe={bold:!0,italic:!0,strikethrough:!0,code:!0,link:!0,image:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,bulletList:!0,orderedList:!0,blockquote:!0,details:!1,codeBlock:!0,hardBreak:!0,button:!1,fixedToolbar:!0,floatingToolbar:!0,gutter:!0};function NHe(e,t){let n={};if(n[`Mod-z`]=w0,n[`Mod-y`]=T0,n[`Mod-Shift-z`]=T0,e.marks.bold&&(!t||t.bold)&&(n[`Mod-b`]=b2(e.marks.bold)),e.marks.italic&&(!t||t.italic)&&(n[`Mod-i`]=b2(e.marks.italic)),e.marks.strikethrough&&(!t||t.strikethrough)&&(n[`Mod-Shift-x`]=b2(e.marks.strikethrough)),e.marks.code&&(!t||t.code)&&(n[`Mod-e`]=b2(e.marks.code)),e.nodes.hard_break&&(!t||t.hardBreak)){let t=e.nodes.hard_break;n[`Shift-Enter`]=(e,n)=>(n&&n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)}if(e.nodes.heading){for(let r=1;r<=6;r++)(!t||t[j2[r-1]])&&(n[`Mod-Alt-${r}`]=y2(e.nodes.heading,{level:r}));(!t||M2(t))&&(n[`Mod-Alt-0`]=y2(e.nodes.paragraph))}return e.nodes.blockquote&&(!t||t.blockquote)&&(n[`Mod-Shift-b`]=v2(e.nodes.blockquote)),e.nodes.code_block&&(!t||t.codeBlock)&&(n[`Mod-Alt-c`]=y2(e.nodes.code_block)),e.nodes.bullet_list&&(!t||t.bulletList)&&(n[`Mod-Shift-8`]=D2(e.nodes.bullet_list)),e.nodes.ordered_list&&(!t||t.orderedList)&&(n[`Mod-Shift-9`]=D2(e.nodes.ordered_list)),e.nodes.list_item&&(!t||t.bulletList||t.orderedList)&&(n.Enter=O2(e.nodes.list_item),n[`Mod-[`]=k2(e.nodes.list_item),n[`Mod-]`]=A2(e.nodes.list_item)),[O0(n),O0(E2)]}var N2=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?PHe(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function PHe(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var FHe=500;function P2({rules:e}){let t=new bQ({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return F2(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&F2(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function F2(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=s.parent.textBetween(Math.max(0,s.parentOffset-FHe),s.parentOffset,null,``)+r;for(let l=0;l<i.length;l++){let u=i[l];if(!u.inCodeMark&&s.marks().some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode===`only`)continue;let d=u.match.exec(c);if(!d||d[0].length<r.length)continue;let f=t-(d[0].length-r.length);if(!u.inCodeMark){let e=!1;if(o.doc.nodesBetween(f,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let p=u.handler(o,d,f,n);if(p)return u.undoable&&p.setMeta(a,{transform:p,from:t,to:n,text:r}),e.dispatch(p),!0}return!1}new N2(/--$/,`—`,{inCodeMark:!1}),new N2(/\.\.\.$/,`…`,{inCodeMark:!1}),new N2(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new N2(/"$/,`”`,{inCodeMark:!1}),new N2(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new N2(/'$/,`’`,{inCodeMark:!1});function I2(e,t,n=null,r){return new N2(e,(e,i,a,o)=>{let s=n instanceof Function?n(i):n,c=e.tr.delete(a,o),l=c.doc.resolve(a).blockRange(),u=l&&IZ(l,t,s);if(!u)return null;c.wrap(l,u);let d=c.doc.resolve(a-1).nodeBefore;return d&&d.type==t&&VZ(c.doc,a-1)&&(!r||r(i,d))&&c.join(a-1),c})}function L2(e,t,n=null){return new N2(e,(e,r,i,a)=>{let o=e.doc.resolve(i),s=n instanceof Function?n(r):n;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t)?e.tr.delete(i,a).setBlockType(i,i,t,s):null})}function IHe(e,t){let n=[];return e.nodes.heading&&(!t||M2(t))&&n.push(L2(/^(#{1,6})\s$/,e.nodes.heading,e=>{let n=e[1].length;return t&&!t[j2[n-1]]?!1:{level:n}})),e.nodes.blockquote&&(!t||t.blockquote)&&n.push(I2(/^\s*>\s$/,e.nodes.blockquote)),e.nodes.bullet_list&&(!t||t.bulletList)&&n.push(I2(/^\s*([-+*])\s$/,e.nodes.bullet_list)),e.nodes.ordered_list&&(!t||t.orderedList)&&n.push(I2(/^(\d+)\.\s$/,e.nodes.ordered_list,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order===+e[1])),e.nodes.code_block&&(!t||t.codeBlock)&&n.push(L2(/^```$/,e.nodes.code_block)),P2({rules:n})}function LHe(e){let t=e.schema.cached.changeSetIDs||(e.schema.cached.changeSetIDs=Object.create(null)),n=t[e.name];return n??(t[e.name]=n=Object.keys(e.schema.nodes).indexOf(e.name)+1),n}var R2={encodeCharacter:e=>e,encodeNodeStart:e=>e.type.name,encodeNodeEnd:e=>-LHe(e.type),compareTokens:(e,t)=>e===t};function z2(e,t,n,r,i){for(let a=0,o=0;a<e.childCount;a++){let s=e.child(a),c=o+s.nodeSize,l=Math.max(o,n),u=Math.min(c,r);if(l<u){if(s.isText)for(let e=l;e<u;e++)i.push(t.encodeCharacter(s.text.charCodeAt(e-o),s.marks));else s.isLeaf?i.push(t.encodeNodeStart(s)):(l==o&&i.push(t.encodeNodeStart(s)),z2(s.content,t,Math.max(o+1,l)-o-1,Math.min(c-1,u)-o-1,i),u==c&&i.push(t.encodeNodeEnd(s)))}o=c}return i}var B2=2500;function RHe(e,t){return Math.min(15,Math.max(2,Math.floor(Math.max(e,t)/10)))}function V2(e,t,n,r=R2){return Math.max(n.toA-n.fromA,n.toB,n.fromB)>B2?[n]:zHe(z2(e,r,n.fromA,n.toA,[]),z2(t,r,n.fromB,n.toB,[]),n,r.compareTokens)}function zHe(e,t,n,r){let i=0,a=e.length,o=t.length;for(;i<e.length&&i<t.length&&r(e[i],t[i]);)i++;if(i==e.length&&i==t.length)return[];for(;a>i&&o>i&&r(e[a-1],t[o-1]);)a--,o--;if(a==i||o==i||a==o&&a==i+1)return[n.slice(i,a,i,o)];let s=a-i,c=o-i,l=Math.min(B2,s+c),u=[],d=new Int16Array((l+1)*2).fill(-1);for(let f=0;f<=l;f++){for(let p=-f;p<=f;p+=2){let m=d[p+1+l],h=d[p-1+l],g=m<h?h:m+1,_=g+p;for(;g<s&&_<c&&r(e[i+g],t[i+_]);)g++,_++;if(d[p+l]=g,g>=s&&_>=c){let e=[],t=RHe(a-i,o-i),r=-1,s=-1,c=-1,m=-1,h=(i,a,o,l)=>{r>-1&&r<a+t?(r=i,c=o):(r>-1&&e.push(n.slice(r,s,c,m)),r=i,s=a,c=o,m=l)};for(let e=f-1;e>=0;e--){let t=d[p+1+l],n=d[p-1+l];t<n?(p--,g=n+i,_=g+p,h(g,g,_,_+1)):(p++,g=t+i,_=g+p,h(g,g+1,_,_)),d=u[e>>1]}return r>-1&&e.push(n.slice(r,s,c,m)),e.reverse()}}f%2==0&&u.push(d.slice())}return[n]}var H2=class e{constructor(e,t){this.length=e,this.data=t}cut(t){return t==this.length?this:new e(t,this.data)}static slice(t,n,r){if(n==r)return e.none;if(n==0&&r==e.len(t))return t;let i=[];for(let e=0,a=0;a<r;e++){let o=t[e],s=a+o.length,c=Math.min(r,s)-Math.max(n,a);c>0&&i.push(o.cut(c)),a=s}return i}static join(t,n,r){if(t.length==0)return n;if(n.length==0)return t;let i=r(t[t.length-1].data,n[0].data);if(i==null)return t.concat(n);let a=t.slice(0,t.length-1);a.push(new e(t[t.length-1].length+n[0].length,i));for(let e=1;e<n.length;e++)a.push(n[e]);return a}static len(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].length;return t}};H2.none=[];var U2=class e{constructor(e,t,n,r,i,a){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r,this.deleted=i,this.inserted=a}get lenA(){return this.toA-this.fromA}get lenB(){return this.toB-this.fromB}slice(t,n,r,i){return t==0&&r==0&&n==this.toA-this.fromA&&i==this.toB-this.fromB?this:new e(this.fromA+t,this.fromA+n,this.fromB+r,this.fromB+i,H2.slice(this.deleted,t,n),H2.slice(this.inserted,r,i))}static merge(t,n,r){if(t.length==0)return n;if(n.length==0)return t;let i=[];for(let a=0,o=0,s=t[0],c=n[0];;)if(!s&&!c)return i;else if(s&&(!c||s.toB<c.fromA)){let r=o?n[o-1].toB-n[o-1].toA:0;i.push(r==0?s:new e(s.fromA,s.toA,s.fromB+r,s.toB+r,s.deleted,s.inserted)),s=a++==t.length?null:t[a]}else if(c&&(!s||c.toA<s.fromB)){let r=a?t[a-1].toB-t[a-1].toA:0;i.push(r==0?c:new e(c.fromA-r,c.toA-r,c.fromB,c.toB,c.deleted,c.inserted)),c=o++==n.length?null:n[o]}else{let l=Math.min(s.fromB,c.fromA),u=Math.min(s.fromA,c.fromA-(a?t[a-1].toB-t[a-1].toA:0)),d=u,f=Math.min(c.fromB,s.fromB+(o?n[o-1].toB-n[o-1].toA:0)),p=f,m=H2.none,h=H2.none,g=!1,_=!1;for(;;){let e=s?l>=s.fromB?s.toB:s.fromB:2e8,i=c?l>=c.fromA?c.toA:c.fromA:2e8,u=Math.min(e,i),f=s&&l>=s.fromB,v=c&&l>=c.fromA;if(!f&&!v)break;f&&l==s.fromB&&!g&&(m=H2.join(m,s.deleted,r),d+=s.lenA,g=!0),f&&!v&&(h=H2.join(h,H2.slice(s.inserted,l-s.fromB,u-s.fromB),r),p+=u-l),v&&l==c.fromA&&!_&&(h=H2.join(h,c.inserted,r),p+=c.lenB,_=!0),v&&!f&&(m=H2.join(m,H2.slice(c.deleted,l-c.fromA,u-c.fromA),r),d+=u-l),f&&u==s.toB&&(s=a++==t.length?null:t[a],g=!1),v&&u==c.toA&&(c=o++==n.length?null:n[o],_=!1),l=u}(u<d||f<p)&&i.push(new e(u,d,f,p,m,h))}}static fromJSON(t){return new e(t.fromA,t.toA,t.fromB,t.toB,t.deleted.map(e=>new H2(e.length,e.data)),t.inserted.map(e=>new H2(e.length,e.data)))}toJSON(){return this}},W2=class e{constructor(e,t){this.config=e,this.changes=t}addSteps(t,n,r){let i=[];for(let e=0;e<n.length;e++){let t=Array.isArray(r)?r[e]:r,a=0;n[e].forEach((e,n,r,o)=>{i.push(new U2(e+a,n+a,r,o,e==n?H2.none:[new H2(n-e,t)],r==o?H2.none:[new H2(o-r,t)])),a=o-r-(n-e)})}if(i.length==0)return this;let a=G2(i,this.config.combine),o=U2.merge(this.changes,a,this.config.combine),s=o;for(let e=0;e<s.length;e++){let n=s[e];if(n.fromA==n.toA||n.fromB==n.toB||!a.some(e=>e.toB>n.fromB&&e.fromB<n.toB))continue;let r=V2(this.config.doc.content,t.content,n,this.config.encoder);(r.length!=1||r[0].fromB!=0||r[0].toB!=n.toB-n.fromB)&&(s==o&&(s=o.slice()),r.length==1?s[e]=r[0]:(s.splice(e,1,...r),e+=r.length-1))}return new e(this.config,s)}get startDoc(){return this.config.doc}map(t){let n=e=>{let n=t(e);return n===e.data?e:new H2(e.length,n)};return new e(this.config,this.changes.map(e=>new U2(e.fromA,e.toA,e.fromB,e.toB,e.deleted.map(n),e.inserted.map(n))))}changedRange(e,t){if(e==this)return null;let n=t&&BHe(t),r=n?n.toB-n.fromB-(n.toA-n.fromA):0;function i(e){return!n||e<=n.fromA?e:e+r}let a=n?n.fromB:2e8,o=n?n.toB:-2e8;function s(e,t=e){a=Math.min(e,a),o=Math.max(t,o)}let c=this.changes,l=e.changes;for(let e=0,t=0;e<c.length&&t<l.length;){let n=c[e],r=l[t];n&&r&&VHe(n,r,i)?(e++,t++):r&&(!n||i(n.fromB)>=r.fromB)?(s(r.fromB,r.toB),t++):(s(i(n.fromB),i(n.toB)),e++)}return a<=o?{from:a,to:o}:null}static create(t,n=(e,t)=>e===t?e:null,r=R2,i=[]){return new e({combine:n,doc:t,encoder:r},i)}};W2.computeDiff=V2;function G2(e,t,n=0,r=e.length){if(r==n+1)return[e[n]];let i=n+r>>1;return U2.merge(G2(e,t,n,i),G2(e,t,i,r),t)}function K2(e){let t=2e8,n=-2e8;for(let r=0;r<e.length;r++){let i=e[r];t!=2e8&&(t=i.map(t,-1),n=i.map(n,1)),i.forEach((e,r,i,a)=>{t=Math.min(t,i),n=Math.max(n,a)})}return t==2e8?null:{from:t,to:n}}function BHe(e){let t=K2(e);if(!t)return null;let n=K2(e.map(e=>e.invert()).reverse());return{fromA:n.from,toA:n.to,fromB:t.from,toB:t.to}}function VHe(e,t,n){return n(e.fromB)==t.fromB&&n(e.toB)==t.toB&&q2(e.deleted,t.deleted)&&q2(e.inserted,t.inserted)}function q2(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].length!=t[n].length||e[n].data!==t[n].data)return!1;return!0}var J2=new CQ(`diff`);function HHe(){return new bQ({key:J2,state:{init(){return{baseDoc:null,changeSet:null,decorations:H1.empty}},apply(e,t,n,r){let i=e.getMeta(J2)?.baseDoc;if(i!==void 0){if(i===null)return{baseDoc:null,changeSet:null,decorations:H1.empty};let e=W2.create(i),t=[];UHe(i,r.doc,t);let n=t.length>0?e.addSteps(r.doc,t,null):e;return{baseDoc:i,changeSet:n,decorations:Y2(n,r.doc,i)}}if(!t.baseDoc||!t.changeSet)return t;if(!e.docChanged)return{...t,decorations:t.decorations.map(e.mapping,e.doc)};let a=e.steps.map(e=>e.getMap()),o=t.changeSet.addSteps(e.doc,a,null);return{...t,changeSet:o,decorations:Y2(o,e.doc,t.baseDoc)}}},props:{decorations(e){return J2.getState(e)?.decorations??H1.empty}}})}function UHe(e,t,n){let r=e.content.size,i=t.content.size;(r!==i||!e.eq(t))&&n.push(new xZ([0,r,i]))}function Y2(e,t,n){let r=[];for(let i of e.changes){if(i.fromB<i.toB){let e=Math.max(0,i.fromB),n=Math.min(t.content.size,i.toB);e<n&&r.push(z1.inline(e,n,{class:`bg-bg-brand-primary/30`}))}if(i.fromA<i.toA&&i.deleted.length>0){let e=Math.min(i.fromB,t.content.size),a=Math.max(0,i.fromA),o=Math.min(n.content.size,i.toA),s=a<o?n.textBetween(a,o,` `):``;if(s.length>0){let t=document.createElement(`span`);t.className=`bg-bg-error-primary line-through text-fg-error-primary opacity-60`,t.textContent=s,r.push(z1.widget(e,t,{side:-1}))}}}return H1.create(t,r)}function X2(e,t){let n=e.split(`/`).filter(e=>e.length>0).map(e=>{let t=parseInt(e,10);return isNaN(t)?e:t});if(n.length===0)return null;let r=t,i=0;for(let e=0;e<n.length;e++){let t=n[e];if(typeof t==`number`){let a=0,o=!1;if(r.forEach((s,c)=>{o||(a===t&&(e===n.length-1?(i+=c,r=s):(i+=c+1,r=s),o=!0),a++)}),!o)return null}else if(t===`children`)continue;else return null}let a=i,o=a+r.nodeSize;return{from:Math.max(0,a),to:Math.min(t.content.size,o)}}var Z2=new CQ(`schemaValidation`),WHe={bullet_list:`bulletList`,ordered_list:`orderedList`,blockquote:`blockquote`,code_block:`codeBlock`,details:`details`,details_summary:`details`,hard_break:`hardBreak`,button_atom:`button`,button_editable:`button`,image:`image`},GHe={bold:`bold`,italic:`italic`,strikethrough:`strikethrough`,code:`code`,link:`link`},KHe={heading:`Heading`,bullet_list:`Bullet list`,ordered_list:`Ordered list`,blockquote:`Blockquote`,code_block:`Code block`,details:`Details`,details_summary:`Details`,hard_break:`Hard break`,button_atom:`Button`,button_editable:`Button`,image:`Image`},qHe={bold:`Bold`,italic:`Italic`,strikethrough:`Strikethrough`,code:`Code`,link:`Link`},Q2={heading:[{id:`schema.convert-to-paragraph`,label:`Convert to paragraph`}],bullet_list:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],ordered_list:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],blockquote:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],code_block:[{id:`schema.convert-to-paragraph`,label:`Convert to paragraph`}],details:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}]},JHe={bold:[{id:`schema.remove-formatting`,label:`Remove formatting`}],italic:[{id:`schema.remove-formatting`,label:`Remove formatting`}],strikethrough:[{id:`schema.remove-formatting`,label:`Remove formatting`}],code:[{id:`schema.remove-formatting`,label:`Remove formatting`}],link:[{id:`schema.remove-link`,label:`Remove link`}]};function $2(e){return`/`+e.join(`/children/`)}function e4(e,t,n,r){e.forEach((e,i,a)=>{let o=[...n,a];if(e.type.name===`heading`){let n=e.attrs.level,i=j2[n-1];if(i&&!t[i]){let t=Q2[e.type.name];r.push({path:$2(o),message:`Heading ${n} is not allowed by the current schema`,kind:`schema.violation`,...t&&{fixes:t}});return}}let s=WHe[e.type.name];if(s&&!t[s]){let t=KHe[e.type.name]??e.type.name,n=Q2[e.type.name];r.push({path:$2(o),message:`${t} is not allowed by the current schema`,kind:`schema.violation`,...n&&{fixes:n}});return}if(e.isText&&e.marks.length>0){let n=$2(o);for(let i of e.marks){let e=GHe[i.type.name];if(e&&!t[e]){let e=qHe[i.type.name]??i.type.name,t=JHe[i.type.name];r.push({path:n,message:`${e} is not allowed by the current schema`,kind:`schema.violation`,...t&&{fixes:t}})}}return}e.childCount>0&&e4(e,t,o,r)})}function t4(e,t){let n=[];return e4(e,t,[],n),n}function YHe(e,t,n){let{state:r}=e,{doc:i,schema:a}=r,o=X2(t,i);if(!o)return!1;let{from:s,to:c}=o,l=i.nodeAt(s);return l?n===`schema.convert-to-paragraph`?XHe(e,l,s,c,a):n===`schema.convert-to-paragraphs`?ZHe(e,l,s,c,a):n===`schema.remove-formatting`||n===`schema.remove-link`?QHe(e,s,c):!1:!1}function XHe(e,t,n,r,i){let a=r4(t),o=i.node(`paragraph`,null,a.length>0?[i.text(a)]:[]),s=e.state.tr.replaceWith(n,r,o);return e.dispatch(s),!0}function ZHe(e,t,n,r,i){let a=[];n4(t,i,a),a.length===0&&a.push(i.node(`paragraph`));let o=e.state.tr.replaceWith(n,r,a);return e.dispatch(o),!0}function n4(e,t,n){if(e.isTextblock){let r=r4(e);n.push(t.node(`paragraph`,null,r.length>0?[t.text(r)]:[]));return}e.forEach(e=>{n4(e,t,n)})}function QHe(e,t,n){let r=e.state.tr,i=e.state.doc.nodeAt(t);if(!i||!i.isText)return!1;for(let e of i.marks)r=r.removeMark(t,n,e.type);return e.dispatch(r),!0}function r4(e){return e.textContent}function $He(e){return new bQ({key:Z2,state:{init(t,n){return{errors:t4(n.doc,e)}},apply(t,n,r,i){return t.docChanged?{errors:t4(i.doc,e)}:n}}})}var i4=new CQ(`errors`);function a4(e){return Z2.getState(e)?.errors??[]}function eUe(){return new bQ({key:i4,state:{init(e,t){let n=a4(t);return{externalErrors:[],errors:n,errorKindClassName:{},decorations:o4(n,t.doc,{})}},apply(e,t,n,r){let i=e.getMeta(i4);if(i){let e=i.errors??t.externalErrors,n=i.errorKindClassName??t.errorKindClassName,a=a4(r),o=[...e,...a];return{externalErrors:e,errors:o,errorKindClassName:n,decorations:o4(o,r.doc,n)}}if(e.docChanged){let e=a4(r),n=[...t.externalErrors,...e];return{...t,errors:n,decorations:o4(n,r.doc,t.errorKindClassName)}}return t}},props:{decorations(e){return i4.getState(e)?.decorations??H1.empty}}})}function o4(e,t,n){if(e.length===0)return H1.empty;let r=[];for(let i of e){let e=X2(i.path,t);if(!e)continue;let{from:a,to:o}=e,s=n[i.kind]??``,c=`border-b-2 border-border-error-primary bg-bg-error-secondary/20`,l=s?`${c} ${s}`:c;r.push(z1.inline(a,o,{class:l,title:i.message,"data-error-kind":i.kind,"data-error-path":i.path}))}return H1.create(t,r)}function s4(e,t){try{let n=e.resolve(t),r=[];for(let e=1;e<=n.depth;e++){let t=n.node(e-1),i=n.index(e-1);t.type.name!==`doc`&&r.push(`children`),r.push(String(i))}let i=e.nodeAt(t);if(i){let e=n.node(n.depth);e.type.name===`doc`&&n.depth===0?r.push(String(n.index(0))):c4(e)&&!c4(i)&&(r.push(`children`),r.push(String(n.index(n.depth))))}return r.length>0?r:null}catch{return null}}function c4(e){let t=e.type.name;return t===`paragraph`||t===`heading`||t===`details_summary`}var tUe=`custom_style_`;function l4(e,t){let n=[];return e.marks.bold&&(!t||t.bold)&&n.push({label:`B`,title:`Bold (Ctrl+B)`,markType:e.marks.bold}),e.marks.italic&&(!t||t.italic)&&n.push({label:`I`,title:`Italic (Ctrl+I)`,markType:e.marks.italic}),e.marks.strikethrough&&(!t||t.strikethrough)&&n.push({label:`S`,title:`Strikethrough (Ctrl+Shift+X)`,markType:e.marks.strikethrough}),e.marks.code&&(!t||t.code)&&n.push({label:`<>`,title:`Code (Ctrl+E)`,markType:e.marks.code}),e.marks.link&&(!t||t.link)&&n.push({label:`🔗`,title:`Link`,markType:e.marks.link}),n}function u4(e,t){if(!t)return[];let n=[];for(let[r,i]of Object.entries(t)){let t=`${tUe}${r}`,a=e.marks[t];a&&n.push({label:i.label,title:i.label,markType:a})}return n}function d4(e,t){let n=[];return e.nodes.bullet_list&&(!t||t.bulletList)&&n.push({label:`•`,title:`Bullet list (Ctrl+Shift+8)`,nodeType:e.nodes.bullet_list}),e.nodes.ordered_list&&(!t||t.orderedList)&&n.push({label:`1.`,title:`Ordered list (Ctrl+Shift+9)`,nodeType:e.nodes.ordered_list}),n}function f4(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--)if(n.node(e).type===t)return!0;return!1}function nUe(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--){let r=n.node(e);if(r.type===t.nodes.bullet_list||r.type===t.nodes.ordered_list)return{depth:e,node:r}}return null}function rUe(e,t){let{state:n}=e,{$from:r}=n.selection,i=r.parent;i.type!==t.nodes.paragraph&&i.type.isTextblock&&y2(t.nodes.paragraph)(n,e.dispatch,e)}function iUe(e,t){return(n,r,i)=>{if(f4(n,e)){let e=t.nodes.list_item;return e?k2(e)(n,r):!1}let a=nUe(n,t);if(a){if(r){let{$from:t}=n.selection,i=t.before(a.depth);r(n.tr.setNodeMarkup(i,e))}return!0}if(i){let{$from:r}=n.selection,a=r.parent;if(a.type!==t.nodes.paragraph&&a.type.isTextblock)return rUe(i,t),D2(e)(i.state,i.dispatch)}return D2(e)(n,r)}}function p4(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}function m4(e,t){let n=[];if(n.push({value:`paragraph`,label:`Normal`,nodeType:e.nodes.paragraph}),e.nodes.heading)for(let r=1;r<=3;r++)(!t||t[j2[r-1]])&&n.push({value:`heading${r}`,label:`Heading ${r}`,nodeType:e.nodes.heading,attrs:{level:r}});return e.nodes.code_block&&(!t||t.codeBlock)&&n.push({value:`code_block`,label:`Code`,nodeType:e.nodes.code_block}),e.nodes.blockquote&&(!t||t.blockquote)&&n.push({value:`blockquote`,label:`Quote`,nodeType:e.nodes.blockquote}),e.nodes.details&&(!t||t.details)&&n.push({value:`details`,label:`Details`,nodeType:e.nodes.details}),n}function aUe(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--){let t=n.node(e);if(t.type.name===`details`)return`details`;if(t.type.name===`blockquote`)return`blockquote`}let r=n.parent;if(r.type.name===`heading`){let e=r.attrs.level,n=t.find(t=>t.value===`heading${e}`);if(n)return n.value}return r.type.name===`code_block`?`code_block`:`paragraph`}function oUe(e,t,n){let{state:r,dispatch:i}=e;if(n.value===`blockquote`){v2(t.nodes.blockquote)(r,i);return}if(n.value===`details`){y4(e,t,`details`);return}let{$from:a}=r.selection,o=!1;for(let e=a.depth;e>0;e--){let t=a.node(e).type.name;if(t===`blockquote`||t===`details`){o=!0;break}}if(o){hHe(r,t=>{let r=e.state.apply(t);e.updateState(r),y2(n.nodeType,n.attrs)(e.state,e.dispatch,e)});return}y2(n.nodeType,n.attrs)(r,i,e)}function h4(e,t,n){let r=e.coordsAtPos(t);if(n)return{left:Math.max(0,r.left),top:r.bottom+4};let i=e.dom.parentElement;if(!i)return null;let a=i.getBoundingClientRect();return{left:Math.max(0,r.left-a.left),top:r.bottom-a.top+4}}function sUe(e){function t(){e.onPickerStateChange(null)}function n(t,n,r){let{$from:i,from:a,to:o}=t.state.selection,s=n.isInSet(i.marks())??(i.nodeAfter?n.isInSet(i.nodeAfter.marks):null),c=s?s.attrs.href.trim():null,l=h4(t,a,!!e.getPortalContainer?.());l&&e.onPickerStateChange({kind:`catalog`,anchorRect:l,savedFrom:a,savedTo:o,currentHref:c,catalog:r})}function r(t,n){let{$from:r,from:i,to:a}=t.state.selection,o=n.isInSet(r.marks())??(r.nodeAfter?n.isInSet(r.nodeAfter.marks):null),s=o?o.attrs.href.trim():null,c=h4(t,i,!!e.getPortalContainer?.());c&&e.onPickerStateChange({kind:`url`,anchorRect:c,savedFrom:i,savedTo:a,currentHref:s,isNewLink:!o})}function i(i,a){let{state:o}=i,s=e.getLinkCatalog?.();if(s&&s.length>0){if(e.isPickerOpen()){t();return}n(i,a,s);return}if(p4(o,a)){b2(a)(o,i.dispatch,i);return}if(e.isPickerOpen()){t();return}r(i,a)}return{handleLinkToggle:i,showCatalogPicker:n,showUrlEditor:r,closePicker:t,isPickerOpen:()=>e.isPickerOpen(),destroy:t}}function g4(e){return e?.type.name===`button_atom`||e?.type.name===`button_editable`}function cUe(e){let{$from:t}=e.selection;return e.selection instanceof cQ&&g4(e.selection.node)?{pos:e.selection.from,node:e.selection.node}:g4(t.parent)?{pos:t.before(t.depth),node:t.parent}:g4(t.nodeBefore)?{pos:t.pos-t.nodeBefore.nodeSize,node:t.nodeBefore}:g4(t.nodeAfter)?{pos:t.pos,node:t.nodeAfter}:null}function _4(e,t,n,r){let i=n.children===!1,a=i?t.nodes.button_atom:t.nodes.button_editable;if(!a)return;let o={variant:n.variant};!i&&r&&(o.href=r);let s=i?a.create(o):a.create(o,n.label?[t.text(n.label)]:[]),c=cUe(e.state);if(c&&c.node){let t=e.state.tr.replaceWith(c.pos,c.pos+c.node.nodeSize,s);e.dispatch(t)}else{let{from:t}=e.state.selection,n=e.state.tr.insert(t,s);e.dispatch(n)}}function v4(e,t,n,r){let i=t.nodes.image;if(!i)return null;let a=i.create({src:n,alt:``,previewUrl:r?.previewUrl??null,width:r?.width??null,height:r?.height??null,mimeType:r?.mimeType??null}),{from:o}=e.state.selection,s=e.state.tr.insert(o,a);e.dispatch(s);let c=s4(e.state.doc,o);return c?[...c,`src`]:null}function y4(e,t,n){let r=t.nodes.details,i=t.nodes.details_summary;if(!r||!i)return;let{state:a}=e,{$from:o}=a.selection,s=i.create(null,[]),c=t.nodes.paragraph.create(),l=r.create({variant:n},[s,c]),u=o.end(o.depth===0?1:o.depth)+1,d=a.tr.insert(u,l);e.dispatch(d),e.focus()}function lUe({schema:e,features:t,styleConfig:n,canInsertImage:r,buttonVariants:i,detailsVariants:a}){return!!(l4(e,t).length>0||u4(e,n).length>0||d4(e,t).length>0||m4(e,t).length>1||e.nodes.image&&(!t||t.image)&&r||i!==void 0&&i.length>0&&(!t||t.button)||a!==void 0&&a.length>0&&(!t||t.details))}var uUe=Object.defineProperty,b4=(e,t)=>uUe(e,`name`,{value:t,configurable:!0}),x4=!1;function S4(){let[e,t]=b.useState(x4);return b.useEffect(()=>{x4||(x4=!0,t(!0))},[]),e}b4(S4,`useIsHydrated`);var C4=b.useSyncExternalStore;function w4(){return()=>{}}b4(w4,`subscribe`);function T4(){return C4(w4,()=>!0,()=>!1)}b4(T4,`useIsHydratedModern`);var dUe=typeof C4==`function`?T4:S4,fUe=Object.defineProperty,E4=(e,t)=>fUe(e,`name`,{value:t,configurable:!0}),D4=`rovingFocusGroup.onEntryFocus`,pUe={bubbles:!1,cancelable:!0},O4=`RovingFocusGroup`,[k4,A4,mUe]=KT(O4),[hUe,j4]=sm(O4,[mUe]),[gUe,_Ue]=hUe(O4),vUe=b.forwardRef(E4(function(e,t){return(0,Y.jsx)(k4.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,Y.jsx)(k4.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,Y.jsx)(yUe,{...e,ref:t})})})},`RovingFocusGroup`)),yUe=b.forwardRef(E4(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=b.useRef(null),p=am(t,f),m=nE(a),[h,g]=ng({prop:o,defaultProp:s??null,onChange:c,caller:O4}),[_,v]=b.useState(!1),y=Cm(l),x=A4(n),S=b.useRef(!1),[C,w]=b.useState(0);return b.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(D4,y),()=>e.removeEventListener(D4,y)},[y]),(0,Y.jsx)(gUe,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:b.useCallback(e=>g(e),[g]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:b.useCallback(()=>w(e=>e-1),[]),children:(0,Y.jsx)(xm.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:Qp(e.onMouseDown,()=>{S.current=!0}),onFocus:Qp(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(D4,pUe);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);P4([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:Qp(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),bUe=`RovingFocusGroupItem`,xUe=b.forwardRef(E4(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Pm(),l=a||c,u=_Ue(bUe,n),d=u.currentTabStopId===l,f=A4(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=dUe();return Nm(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),b.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,Y.jsx)(k4.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,Y.jsx)(xm.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:Qp(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:Qp(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Qp(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=N4(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?F4(n,r+1):n.slice(r+1)}setTimeout(()=>P4(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),SUe={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function M4(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}E4(M4,`getDirectionAwareKey`);function N4(e,t,n){let r=M4(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return SUe[r]}E4(N4,`getFocusIntent`);function P4(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}E4(P4,`focusFirst`);function F4(e,t){return e.map((n,r)=>e[(t+r)%e.length])}E4(F4,`wrapArray`);var CUe=vUe,wUe=xUe,TUe=Object.defineProperty,I4=(e,t)=>TUe(e,`name`,{value:t,configurable:!0}),L4=[`Enter`,` `],EUe=[`ArrowDown`,`PageUp`,`Home`],R4=[`ArrowUp`,`PageDown`,`End`],DUe=[...EUe,...R4],OUe={ltr:[...L4,`ArrowRight`],rtl:[...L4,`ArrowLeft`]},kUe={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},z4=`Menu`,[B4,AUe,jUe]=KT(z4),[V4,H4]=sm(z4,[jUe,Vh,j4]),U4=Vh(),W4=j4(),[MUe,G4]=V4(z4),[NUe,K4]=V4(z4),PUe=I4(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=U4(t),[c,l]=b.useState(null),u=b.useRef(!1),d=Cm(a),f=nE(i);return b.useEffect(()=>{let e=I4(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=I4(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),b.useEffect(()=>{if(!n)return;let e=I4(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,Y.jsx)(Uh,{...s,children:(0,Y.jsx)(MUe,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,Y.jsx)(NUe,{scope:t,onClose:b.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),q4=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e,i=U4(n);return(0,Y.jsx)(Wh,{...i,...r,ref:t})},`MenuAnchor`)),J4=`MenuPortal`,[FUe,Y4]=V4(J4,{forceMount:void 0}),IUe=I4(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=G4(J4,t);return(0,Y.jsx)(FUe,{scope:t,forceMount:n,children:(0,Y.jsx)(Jh,{present:n||a.open,children:(0,Y.jsx)(Kh,{asChild:!0,container:i,children:r})})})},`MenuPortal`),X4=`MenuContent`,[LUe,Z4]=V4(X4),RUe=b.forwardRef(I4(function(e,t){let n=Y4(X4,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=G4(X4,e.__scopeMenu),o=K4(X4,e.__scopeMenu);return(0,Y.jsx)(B4.Provider,{scope:e.__scopeMenu,children:(0,Y.jsx)(Jh,{present:r||a.open,children:(0,Y.jsx)(B4.Slot,{scope:e.__scopeMenu,children:o.modal?(0,Y.jsx)(zUe,{...i,ref:t}):(0,Y.jsx)(BUe,{...i,ref:t})})})})},`MenuContent`)),zUe=b.forwardRef(I4(function(e,t){let n=G4(X4,e.__scopeMenu),r=b.useRef(null),i=am(t,r);return b.useEffect(()=>{let e=r.current;if(e)return ev(e)},[]),(0,Y.jsx)(Q4,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Qp(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),BUe=b.forwardRef(I4(function(e,t){let n=G4(X4,e.__scopeMenu);return(0,Y.jsx)(Q4,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),VUe=dm(`MenuContent.ScrollLock`),Q4=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=G4(X4,n),_=K4(X4,n),v=U4(n),y=W4(n),x=AUe(n),[S,C]=b.useState(null),w=b.useRef(null),T=am(t,w,g.onContentChange),E=b.useRef(0),D=b.useRef(``),O=b.useRef(0),k=b.useRef(null),A=b.useRef(`right`),j=b.useRef(0),M=m?J_:b.Fragment,N=m?{as:VUe,allowPinchZoom:!0}:void 0,P=I4(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=f3(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;I4((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);b.useEffect(()=>()=>window.clearTimeout(E.current),[]),x_();let F=b.useCallback(e=>A.current===k.current?.side&&m3(e,k.current?.area),[]);return(0,Y.jsx)(LUe,{scope:n,searchRef:D,onItemEnter:b.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:b.useCallback(e=>{F(e)||(w.current?.focus(),C(null))},[F]),onTriggerLeave:b.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:O,onPointerGraceIntentChange:b.useCallback(e=>{k.current=e},[]),children:(0,Y.jsx)(M,{...N,children:(0,Y.jsx)(o_,{asChild:!0,trapped:i,onMountAutoFocus:Qp(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,Y.jsx)(Om,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,Y.jsx)(CUe,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Qp(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,Y.jsx)(Gh,{role:`menu`,"aria-orientation":`vertical`,"data-state":s3(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:T,style:{outline:`none`,...h.style},onKeyDown:Qp(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&P(e.key));let i=w.current;if(e.target!==i||!DUe.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);R4.includes(e.key)&&a.reverse(),u3(a)}),onBlur:Qp(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:Qp(e.onPointerMove,h3(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),HUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e;return(0,Y.jsx)(xm.div,{...r,ref:t})},`MenuLabel`)),$4=`MenuItem`,e3=`menu.itemSelect`,t3=b.forwardRef(I4(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=b.useRef(null),o=K4($4,e.__scopeMenu),s=Z4($4,e.__scopeMenu),c=am(t,a),l=b.useRef(!1),u=I4(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(e3,{bubbles:!0,cancelable:!0});e.addEventListener(e3,e=>r?.(e),{once:!0}),Sm(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,Y.jsx)(n3,{...i,ref:c,disabled:n,onClick:Qp(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Qp(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Qp(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&L4.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),n3=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Z4($4,n),s=W4(n),c=b.useRef(null),l=am(t,c),[u,d]=b.useState(!1),[f,p]=b.useState(``);return b.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,Y.jsx)(B4.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,Y.jsx)(wUe,{asChild:!0,...s,focusable:!r,children:(0,Y.jsx)(xm.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Qp(e.onPointerMove,h3(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Qp(e.onPointerLeave,h3(e=>o.onItemLeave(e))),onFocus:Qp(e.onFocus,()=>d(!0)),onBlur:Qp(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),UUe=b.forwardRef(I4(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,Y.jsx)(i3,{scope:e.__scopeMenu,checked:n,children:(0,Y.jsx)(t3,{role:`menuitemcheckbox`,"aria-checked":c3(n)?`mixed`:n,...i,ref:t,"data-state":l3(n),onSelect:Qp(i.onSelect,()=>r?.(c3(n)?!0:!n),{checkForDefaultPrevented:!1})})})},`MenuCheckboxItem`)),[WUe,GUe]=V4(`MenuRadioGroup`,{value:void 0,onValueChange:I4(()=>{},`onValueChange`)}),KUe=`MenuRadioItem`,qUe=b.forwardRef(I4(function(e,t){let{value:n,...r}=e,i=GUe(KUe,e.__scopeMenu),a=n===i.value;return(0,Y.jsx)(i3,{scope:e.__scopeMenu,checked:a,children:(0,Y.jsx)(t3,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":l3(a),onSelect:Qp(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),r3=`MenuItemIndicator`,[i3,JUe]=V4(r3,{checked:!1}),YUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=JUe(r3,n);return(0,Y.jsx)(Jh,{present:r||c3(a.checked)||a.checked===!0,children:(0,Y.jsx)(xm.span,{...i,ref:t,"data-state":l3(a.checked)})})},`MenuItemIndicator`)),XUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e;return(0,Y.jsx)(xm.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[ZUe,a3]=V4(`MenuSub`),o3=`MenuSubTrigger`,QUe=b.forwardRef(I4(function(e,t){let n=G4(o3,e.__scopeMenu),r=K4(o3,e.__scopeMenu),i=a3(o3,e.__scopeMenu),a=Z4(o3,e.__scopeMenu),o=b.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=b.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);b.useEffect(()=>u,[u]),b.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let d=am(t,i.onTriggerChange);return(0,Y.jsx)(q4,{asChild:!0,...l,children:(0,Y.jsx)(n3,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":s3(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Qp(e.onPointerMove,h3(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Qp(e.onPointerLeave,h3(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Qp(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(a.searchRef.current===``||t.key!==` `)&&OUe[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),$Ue=`MenuSubContent`,eWe=b.forwardRef(I4(function(e,t){let n=Y4(X4,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=G4(X4,e.__scopeMenu),s=K4(X4,e.__scopeMenu),c=a3($Ue,e.__scopeMenu),l=b.useRef(null),u=am(t,l);return(0,Y.jsx)(B4.Provider,{scope:e.__scopeMenu,children:(0,Y.jsx)(Jh,{present:r||o.open,children:(0,Y.jsx)(B4.Slot,{scope:e.__scopeMenu,children:(0,Y.jsx)(Q4,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:u,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Qp(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Qp(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:Qp(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=kUe[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function s3(e){return e?`open`:`closed`}I4(s3,`getOpenState`);function c3(e){return e===`indeterminate`}I4(c3,`isIndeterminate`);function l3(e){return c3(e)?`indeterminate`:e?`checked`:`unchecked`}I4(l3,`getCheckedState`);function u3(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}I4(u3,`focusFirst`);function d3(e,t){return e.map((n,r)=>e[(t+r)%e.length])}I4(d3,`wrapArray`);function f3(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=d3(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}I4(f3,`getNextMatch`);function p3(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}I4(p3,`isPointInPolygon`);function m3(e,t){return t?p3({x:e.clientX,y:e.clientY},t):!1}I4(m3,`isPointerInGraceArea`);function h3(e){return t=>t.pointerType===`mouse`?e(t):void 0}I4(h3,`whenMouse`);var tWe=PUe,nWe=q4,rWe=IUe,iWe=RUe,aWe=HUe,oWe=t3,sWe=UUe,cWe=qUe,lWe=YUe,uWe=XUe,dWe=QUe,fWe=eWe,pWe=Object.defineProperty,g3=(e,t)=>pWe(e,`name`,{value:t,configurable:!0}),_3=`DropdownMenu`,[mWe,hWe]=sm(_3,[H4]),v3=H4(),[gWe,y3]=mWe(_3),_We=g3(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=v3(t),l=b.useRef(null),[u,d]=ng({prop:i,defaultProp:a??!1,onChange:o,caller:_3});return(0,Y.jsx)(gWe,{scope:t,triggerId:Pm(),triggerRef:l,contentId:Pm(),open:u,onOpenChange:d,onOpenToggle:b.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,Y.jsx)(tWe,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),vWe=`DropdownMenuTrigger`,yWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=y3(vWe,n),o=v3(n),s=am(t,a.triggerRef);return(0,Y.jsx)(nWe,{asChild:!0,...o,children:(0,Y.jsx)(xm.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:Qp(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Qp(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),bWe=g3(e=>{let{__scopeDropdownMenu:t,...n}=e,r=v3(t);return(0,Y.jsx)(rWe,{...r,...n})},`DropdownMenuPortal`),xWe=`DropdownMenuContent`,SWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=y3(xWe,n),a=v3(n),o=b.useRef(!1);return(0,Y.jsx)(iWe,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Qp(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Qp(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),CWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(aWe,{...i,...r,ref:t})},`DropdownMenuLabel`)),wWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(oWe,{...i,...r,ref:t})},`DropdownMenuItem`)),TWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(sWe,{...i,...r,ref:t})},`DropdownMenuCheckboxItem`)),EWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(cWe,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),DWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(lWe,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),OWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(uWe,{...i,...r,ref:t})},`DropdownMenuSeparator`)),kWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(dWe,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),AWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(fWe,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuSubContent`)),jWe=_We,MWe=yWe,NWe=bWe,b3=SWe,x3=CWe,S3=wWe,C3=TWe,w3=EWe,T3=DWe,E3=OWe,D3=kWe,O3=AWe,k3=jWe,A3=MWe,PWe=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Y.jsxs)(D3,{ref:i,className:X(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-bg-brand-primary data-[state=open]:bg-bg-brand-primary`,t&&`pl-8`,e),...r,children:[n,(0,Y.jsx)(Rv,{className:`ml-auto w-4 h-4`})]}));PWe.displayName=D3.displayName;var FWe=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(O3,{ref:n,className:X(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-bg-secondary p-1 text-fg-secondary shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));FWe.displayName=O3.displayName;var j3=b.forwardRef(({className:e,sideOffset:t=4,container:n,...r},i)=>(0,Y.jsx)(NWe,{container:n,children:(0,Y.jsx)(b3,{ref:i,sideOffset:t,className:X(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-bg-secondary p-1 text-fg-secondary shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));j3.displayName=b3.displayName;var M3=b.forwardRef(({className:e,inset:t,...n},r)=>(0,Y.jsx)(S3,{ref:r,className:X(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-bg-brand-primary focus:text-fg-brand-primary data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,t&&`pl-8`,e),...n}));M3.displayName=S3.displayName;var IWe=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Y.jsxs)(C3,{ref:i,className:X(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(T3,{children:(0,Y.jsx)(Fv,{className:`w-4 h-4`})})}),t]}));IWe.displayName=C3.displayName;var LWe=b.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(w3,{ref:r,className:X(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(T3,{children:(0,Y.jsx)(Bie,{className:`w-2 h-2 fill-current`})})}),t]}));LWe.displayName=w3.displayName;var RWe=b.forwardRef(({className:e,inset:t,...n},r)=>(0,Y.jsx)(x3,{ref:r,className:X(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));RWe.displayName=x3.displayName;var zWe=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(E3,{ref:n,className:X(`-mx-1 my-1 h-px bg-muted`,e),...t}));zWe.displayName=E3.displayName;function N3({images:e,currentSrc:t,onSelect:n}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-secondary`,children:`Select an image:`}),(0,Y.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:e.map((e,r)=>{let i=`Select image ${r+1}`;return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(e.url),"aria-label":i,className:[`overflow-hidden rounded border-2 transition-all`,t===e.url?`border-border-brand-primary ring-2 ring-border-brand-primary`:`border-border-primary hover:border-border-brand-primary`].join(` `),children:(0,Y.jsx)(`img`,{src:e.url,alt:``,className:`h-16 w-full object-cover`})},e.url)})})]})}function P3({catalog:e,currentHref:t,onApplyLink:n,onRemoveLink:r,onClose:i}){let a=new Map(e.map(e=>[e.href.trim(),e])),o=(0,b.useCallback)(e=>{let t=a.get(e);t&&n(t)},[a,n]);return(0,Y.jsxs)(ik,{filter:(e,t)=>{let n=a.get(e);if(!n)return 0;let r=t.toLowerCase();return n.title.toLowerCase().includes(r)||n.subtitle.toLowerCase().includes(r)||n.href.trim().toLowerCase().includes(r)?1:0},children:[(0,Y.jsx)(ak,{placeholder:`Filter...`,onKeyDown:e=>{e.key===`Escape`&&i()}}),(0,Y.jsxs)(ok,{children:[(0,Y.jsx)(sk,{children:`No matches`}),(0,Y.jsx)(ck,{children:e.map(e=>{let n=e.href.trim(),r=t!==null&&n===t;return(0,Y.jsxs)(uk,{value:n,onSelect:o,className:`flex items-center gap-2`,children:[(0,Y.jsx)(Fv,{className:X(`h-4 w-4 shrink-0`,r?`opacity-100`:`opacity-0`)}),(0,Y.jsx)(dk,{title:e.title,subtitle:e.subtitle,image:e.image??null,className:X(r&&`text-fg-brand-primary`)})]},n)})})]}),r&&(0,Y.jsx)(`div`,{className:`border-t border-border-primary p-1`,children:(0,Y.jsx)(`button`,{type:`button`,className:X(`w-full rounded px-2 py-1.5 text-left text-sm text-fg-secondary`,`transition-colors hover:bg-bg-secondary-hover`),onMouseDown:r,children:`Remove link`})})]})}function F3({currentHref:e,isNewLink:t,onApply:n,onUnlink:r,onClose:i}){let[a,o]=(0,b.useState)(e),s=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=s.current;e&&(e.focus(),e.select())},[]);let c=(0,b.useCallback)(()=>{let e=a.trim();e&&n(e)},[a,n]),l=(0,b.useCallback)(e=>{if(e.key===`Escape`){i();return}e.key===`Enter`&&(e.preventDefault(),c())},[i,c]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(MT,{ref:s,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:l,"aria-label":`URL`,placeholder:`https://…`,className:X(`h-8 m-0 min-w-[220px] w-auto text-sm`)}),(0,Y.jsx)(t_,{size:`xs`,onMouseDown:c,children:t?`Apply`:`Update`}),!t&&(0,Y.jsx)(t_,{variant:`ghost`,size:`xs`,onMouseDown:r,children:`Unlink`})]})}var BWe={bold:Mv,italic:ly,strikethrough:Fy,code:Kv,link:dy},VWe={bullet_list:my,ordered_list:fy},I3={1:tae,2:nae,3:iae,4:rae,5:aae,6:oae};function L3(){return(0,Y.jsx)(`div`,{className:`mx-0.5 w-px self-stretch bg-border-primary`,role:`separator`})}var R3=`disabled:bg-transparent disabled:border-transparent aria-disabled:bg-transparent aria-disabled:border-transparent`;function z3({view:e,schema:t,features:n,linkHelper:r,options:i,images:a,imageModuleEntries:o,imageGetUrl:s,onImageUpload:c,imageAccept:l,uploadProgress:u,buttonVariants:d,detailsVariants:f,linkCatalog:p,styleConfig:m,readOnly:h}){let g=l4(t,n),_=u4(t,m),v=d4(t,n),y=i?.showBlockTypeSelect?m4(t,n):[],x=y.length>1,S=x?aUe(e.state,y):`paragraph`,C=(0,b.useRef)(null);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-0`,ref:C}),x&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:`xs`,className:X(`min-w-[3.5rem]`,R3),disabled:h,children:[S.startsWith(`heading`)&&(()=>{let e=I3[Number(S.replace(`heading`,``))];return e?(0,Y.jsx)(e,{size:16}):S})(),!S.startsWith(`heading`)&&(y.find(e=>e.value===S)?.label??`Normal`)]})}),(0,Y.jsx)(j3,{container:C.current,children:y.map(n=>{let r=n.attrs?.level,i=r?I3[r]:void 0;return(0,Y.jsx)(M3,{onClick:()=>{oUe(e,t,n),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):n.label},n.value)})})]}),(0,Y.jsx)(L3,{})]}),g.map(t=>{let n=p4(e.state,t.markType),i=BWe[t.markType.name];return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:t.title,disabled:h,className:X(R3,{"text-accent":n,"stroke-[3px]":n}),onClick:n=>{n.preventDefault(),t.markType.name===`link`?r.handleLinkToggle(e,t.markType):b2(t.markType)(e.state,e.dispatch,e),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):t.label},t.markType.name)}),_.length>0&&g.length>0&&(0,Y.jsx)(L3,{}),_.map(t=>{let n=p4(e.state,t.markType);return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:t.title,disabled:h,className:X(R3,{"text-accent":n,"stroke-[3px]":n}),onClick:n=>{n.preventDefault(),b2(t.markType)(e.state,e.dispatch,e),e.focus()},children:t.label},t.markType.name)}),v.length>0&&(g.length>0||_.length>0)&&(0,Y.jsx)(L3,{}),v.map(n=>{let r=f4(e.state,n.nodeType),i=VWe[n.nodeType.name];return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:n.title,disabled:h,className:X(R3,{"text-accent":r,"stroke-[3px]":r}),onClick:r=>{r.preventDefault(),iUe(n.nodeType,t)(e.state,e.dispatch,e),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):n.label},n.nodeType.name)}),t.nodes.image&&(!n||n.image)&&(a&&a.length>0||o||c)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(HWe,{view:e,schema:t,images:a,imageModuleEntries:o,imageGetUrl:s,onImageUpload:c,imageAccept:l,uploadProgress:u,readOnly:h})]}),d&&d.length>0&&(!n||n.button)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(GWe,{view:e,schema:t,variants:d,linkHelper:r,linkCatalog:p,dropdownContainer:C.current,readOnly:h})]}),f&&f.length>0&&(!n||n.details)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(UWe,{view:e,schema:t,variants:f,dropdownContainer:C.current,readOnly:h})]})]})}function HWe({view:e,schema:t,images:n,imageModuleEntries:r,imageGetUrl:i,onImageUpload:a,imageAccept:o,uploadProgress:s,readOnly:c}){let[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),p=(0,b.useRef)(null),m=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!l)return;function e(e){let t=e.target;(!p.current||!p.current.contains(t))&&u(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let h=!!r||n&&n.length>0;function g(n){a&&(f(!0),a(n,(n,r)=>v4(e,t,n,r)).then(t=>{f(!1),t&&(u(!1),e.focus())}))}return(0,Y.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert image`,disabled:d||c,className:X(R3,{"text-accent stroke-[3px]":l}),onClick:e=>{e.preventDefault(),!h&&a?m.current?.click():u(e=>!e)},children:d?(0,Y.jsx)(hy,{size:16,className:`animate-spin`}):(0,Y.jsx)(sy,{size:16})}),d&&s!=null&&(0,Y.jsxs)(`span`,{className:`text-[10px] font-medium tabular-nums text-fg-secondary select-none`,children:[s,`%`]}),(0,Y.jsx)(`input`,{ref:m,hidden:!0,type:`file`,accept:o??`image/*`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&g(t),e.target.value=``}}),l&&(0,Y.jsxs)(`div`,{ref:p,className:X(`absolute left-0 top-full z-window mt-1 rounded-md`,`border border-border-primary bg-bg-primary shadow-xl`,r?`min-w-[280px] p-0`:`min-w-[240px] p-2`),onMouseDown:e=>{e.stopPropagation()},children:[r?(0,Y.jsx)(uA,{moduleEntries:r,isImage:!0,getUrl:i,autoFocus:!0,maxHeight:280,onSelect:n=>{v4(e,t,n.filePath),u(!1),e.focus()},onEscape:()=>u(!1)}):n&&n.length>0?(0,Y.jsx)(N3,{images:n,currentSrc:``,onSelect:n=>{v4(e,t,n),u(!1),e.focus()}}):null,a&&(0,Y.jsxs)(Y.Fragment,{children:[h&&(0,Y.jsx)(`div`,{className:`mx-2 my-1 border-t border-border-primary`}),(0,Y.jsx)(`div`,{className:X(`flex items-center gap-2`,h?`px-2 pb-2`:``),children:(0,Y.jsxs)(t_,{variant:`secondary`,size:`sm`,className:`w-full`,disabled:d,onClick:e=>{e.preventDefault(),m.current?.click()},children:[d?(0,Y.jsx)(hy,{size:14,className:`mr-1.5 animate-spin`}):(0,Y.jsx)(By,{size:14,className:`mr-1.5`}),d?s==null?`Uploading...`:`Uploading ${s}%`:`Upload image`]})})]})]})]})}function UWe({view:e,schema:t,variants:n,dropdownContainer:r,readOnly:i}){return(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert details`,disabled:i,className:R3,children:(0,Y.jsx)(wy,{size:16})})}),(0,Y.jsx)(j3,{container:r,children:n.map(n=>(0,Y.jsx)(M3,{onClick:()=>{y4(e,t,n.variant),e.focus()},children:n.label},n.variant))})]})}function WWe(e){if(Array.isArray(e.link))return e.link}function GWe({view:e,schema:t,variants:n,dropdownContainer:r,readOnly:i}){let[a,o]=(0,b.useState)(null),s=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!a)return;function e(e){let t=e.target;(!s.current||!s.current.contains(t))&&o(null)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);function c(e){o(e)}function l(n){a&&(_4(e,t,a,n),o(null),e.focus())}function u(){o(null),e.focus()}return(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert button`,disabled:i,className:X(R3,{"text-accent stroke-[3px]":!!a}),children:(0,Y.jsx)(by,{size:16})})}),(0,Y.jsx)(j3,{container:r,children:n.map(n=>(0,Y.jsxs)(M3,{onClick:()=>{n.link?c(n):(_4(e,t,n),e.focus())},children:[n.label,n.link&&(0,Y.jsx)(`span`,{className:`ml-1.5 text-xs text-fg-secondary-alt`,children:`(link)`})]},n.variant))})]}),a&&(0,Y.jsx)(KWe,{ref:s,linkCatalog:WWe(a),onSelectHref:l,onClose:u})]})}var KWe=(0,b.forwardRef)(function({linkCatalog:e,onSelectHref:t,onClose:n},r){let i=e&&e.length>0;return(0,Y.jsx)(`div`,{ref:r,className:X(`absolute left-0 top-full z-window mt-1 rounded-md`,`border border-border-primary bg-bg-primary shadow-xl`,i?`min-w-[280px] flex flex-col`:`flex items-center gap-1.5 p-1.5`),onMouseDown:e=>{e.stopPropagation()},children:i?(0,Y.jsx)(P3,{catalog:e,currentHref:null,onApplyLink:e=>t(e.href.trim()),onRemoveLink:null,onClose:n}):(0,Y.jsx)(F3,{currentHref:``,isNewLink:!0,onApply:e=>t(e),onUnlink:n,onClose:n})})}),qWe=new CQ(`fixedToolbar`);function JWe(e,t){let n=null,r=null;if(!t.linkHelper)throw Error(`fixedToolbar requires a linkHelper instance`);let i=t.linkHelper,a={showBlockTypeSelect:!0};function o(n){r&&r.render((0,b.createElement)(z3,{view:n,schema:e,features:t.features,linkHelper:i,options:a,images:t.getImages?.(),imageModuleEntries:t.getImageModuleEntries?.(),imageGetUrl:t.getImageGetUrl?.(),onImageUpload:t.getOnImageUpload?.(),imageAccept:t.getImageAccept?.(),uploadProgress:t.getUploadProgress?.()??null,buttonVariants:t.getButtonVariants?.(),detailsVariants:t.getDetailsVariants?.(),linkCatalog:t.getLinkCatalog?.(),styleConfig:t.styleConfig,readOnly:t.readOnly}))}return new bQ({key:qWe,view(e){let i=t.getMount();return i&&(n=document.createElement(`div`),n.className=`flex flex-row items-center justify-start px-2 py-1 gap-x-1`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Formatting`),n.addEventListener(`mousedown`,e=>{e.target.tagName!==`SELECT`&&e.preventDefault()},!0),i.appendChild(n),r=(0,x.createRoot)(n),o(e)),{update:o,destroy(){let e=r;r=null,n?.remove(),n=null,e&&queueMicrotask(()=>e.unmount())}}}})}var YWe=new CQ(`floatingToolbar`);function XWe(e,t){let n=null,r=null;if(!t?.linkHelper)throw Error(`floatingToolbar requires a linkHelper instance`);let i=t.linkHelper;function a(a){if(!n||!r)return;let{selection:o}=a.state,{empty:s,from:c,to:l}=o,{$from:u}=o,d=u.parent.type.name===`button_editable`||o instanceof cQ&&o.node.type.name===`button_editable`;if(s||d||!a.hasFocus()&&!i.isPickerOpen()){n.style.display=`none`,i.isPickerOpen()||i.closePicker();return}r.render((0,b.createElement)(z3,{view:a,schema:e,features:t?.features,linkHelper:i,images:t?.getImages?.(),imageModuleEntries:t?.getImageModuleEntries?.(),imageGetUrl:t?.getImageGetUrl?.(),onImageUpload:t?.getOnImageUpload?.(),imageAccept:t?.getImageAccept?.(),uploadProgress:t?.getUploadProgress?.()??null,buttonVariants:t?.getButtonVariants?.(),detailsVariants:t?.getDetailsVariants?.(),linkCatalog:t?.getLinkCatalog?.(),styleConfig:t?.styleConfig}));let f=a.coordsAtPos(c),p=a.coordsAtPos(l);if(t?.getPortalContainer?.()){let e=(f.left+p.left)/2,t=f.top-40;n.style.display=`flex`,n.style.left=`${Math.max(0,e-60)}px`,n.style.top=`${Math.max(0,t)}px`}else{let e=a.dom.parentElement?.getBoundingClientRect();if(!e)return;let t=(f.left+p.left)/2-e.left,r=f.top-e.top-40;n.style.display=`flex`,n.style.left=`${Math.max(0,t-60)}px`,n.style.top=`${Math.max(0,r)}px`}}return new bQ({key:YWe,view(e){n=document.createElement(`div`);let i=t?.getPortalContainer?.();return n.className=[`${i?`fixed`:`absolute`} z-window flex items-center gap-x-1 rounded-md border border-border-primary`,`bg-bg-primary px-2 py-1 shadow-lg transition-opacity`].join(` `),n.style.display=`none`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Formatting (selection)`),n.addEventListener(`mousedown`,e=>e.preventDefault(),!0),(i??e.dom.parentElement)?.appendChild(n),r=(0,x.createRoot)(n),{update:a,destroy(){let e=r;r=null,n?.remove(),n=null,e&&queueMicrotask(()=>e.unmount())}}}})}var ZWe=new CQ(`gutter`);function QWe(e,t,n){let r=null,i=null;function a(e){let t=document.createElement(`div`);return t.className=`absolute left-0 top-0 w-8 pointer-events-none`,t.style.height=`100%`,e.dom.parentElement?.appendChild(t),t}function o(e){let t=document.createElement(`div`);return t.className=[`${e?`fixed`:`absolute`} z-window flex flex-col rounded-md border border-border-primary`,`bg-bg-primary p-1 shadow-lg text-sm min-w-[140px]`].join(` `),t.style.display=`none`,t}function s(e,t){let n=0;for(let r=0;r<=t;r++)n+=e.child(r).nodeSize;return n}function c(e,t,n){let{doc:r}=e.state;if(t<0||t>=r.childCount)return;let i=s(r,t),a=e.state.tr.insert(i,n);a.setSelection(oQ.near(a.doc.resolve(i+1),1)),e.dispatch(a),e.focus()}function l(e,n){let r=[];if(r.push({label:`Paragraph`,action:t=>{c(t,n,e.nodes.paragraph.create())}}),e.nodes.heading)for(let i=1;i<=3;i++)(!t||t[j2[i-1]])&&r.push({label:`Heading ${i}`,action:t=>{c(t,n,e.nodes.heading.create({level:i}))}});return e.nodes.code_block&&(!t||t.codeBlock)&&r.push({label:`Code Block`,action:t=>{c(t,n,e.nodes.code_block.create())}}),e.nodes.details&&e.nodes.details_summary&&(!t||t.details)&&r.push({label:`Details`,action:t=>{let r=e.nodes.details_summary.create(null,[]),i=e.nodes.paragraph.create();c(t,n,e.nodes.details.create({variant:`details`},[r,i]))}}),r}function u(e){if(!r)return;r.innerHTML=``;let t=e.dom.parentElement?.getBoundingClientRect();if(!t)return;let{doc:n}=e.state;n.forEach((n,i,a)=>{let o=e.coordsAtPos(i+1).top-t.top,s=document.createElement(`button`);s.type=`button`,s.className=[`pointer-events-auto absolute left-1 flex h-6 w-6 items-center justify-center`,`rounded text-fg-secondary-alt opacity-0 transition-opacity hover:opacity-100`,`hover:bg-bg-secondary-hover`].join(` `),s.style.top=`${o}px`,s.textContent=`+`,s.title=`Add block below`,s.addEventListener(`mousedown`,t=>{t.preventDefault(),t.stopPropagation(),d(e,s,a)}),r.appendChild(s)})}function d(t,r,a){let s=n?.getPortalContainer?.();i||(i=o(!!s),(s??t.dom.parentElement)?.appendChild(i)),i.innerHTML=``;let c=l(e,a);for(let e of c){let n=document.createElement(`button`);n.type=`button`,n.className=`px-3 py-1 text-left text-fg-secondary hover:bg-bg-secondary-hover rounded`,n.textContent=e.label,n.addEventListener(`mousedown`,n=>{n.preventDefault(),e.action(t),i.style.display=`none`}),i.appendChild(n)}let u=r.getBoundingClientRect();if(s)i.style.display=`flex`,i.style.left=`${u.right+4}px`,i.style.top=`${u.top}px`;else{let e=t.dom.parentElement?.getBoundingClientRect();if(!e)return;i.style.display=`flex`,i.style.left=`${u.right-e.left+4}px`,i.style.top=`${u.top-e.top}px`}let d=e=>{i?.contains(e.target)||(i.style.display=`none`,document.removeEventListener(`mousedown`,d))};setTimeout(()=>document.addEventListener(`mousedown`,d),0)}return new bQ({key:ZWe,view(e){return r=a(e),u(e),{update:u,destroy(){r?.remove(),i?.remove(),r=null,i=null}}}})}function $We({error:e,onApplyFix:t}){let n=e.fixes;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`div`,{className:`text-fg-error-primary font-medium text-sm`,children:e.message}),n&&n.length>0&&(0,Y.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:n.map(n=>(0,Y.jsx)(`button`,{type:`button`,className:[`rounded px-2 py-0.5 text-xs font-medium`,`border border-border-error-primary text-fg-error-primary`,`hover:bg-bg-error-secondary-hover`].join(` `),onClick:r=>{r.preventDefault(),t?.({path:e.path,kind:e.kind,fixId:n.id})},children:n.label},n.id))})]})}var eGe=new CQ(`errorTooltip`);function tGe(e){let t=null,n=null,r=null,i=null,a=null,o=null,s=null,c=null;function l(){c!==null&&(clearTimeout(c),c=null)}function u(){l(),c=setTimeout(()=>{p(),c=null},150)}function d(t){let n=e.getPortalContainer?.(),r=document.createElement(`div`);return r.className=[`${n?`fixed`:`absolute`} z-window max-w-xs rounded-md border border-border-error-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `),r.style.display=`none`,(n??t.dom.parentElement)?.appendChild(r),r}function f(i,a,o){if(!t)return;l(),r=a.path,n||=(0,x.createRoot)(t),n.render((0,Y.jsx)($We,{error:a,onApplyFix:t=>{e.onApplyErrorFix?.(t),p()}}));let s=o.getBoundingClientRect();if(e.getPortalContainer?.())t.style.display=`block`,t.style.left=`${s.left}px`,t.style.top=`${s.bottom+4}px`;else{let e=i.dom.parentElement?.getBoundingClientRect();if(!e)return;t.style.display=`block`,t.style.left=`${s.left-e.left}px`,t.style.top=`${s.bottom-e.top+4}px`}}function p(){l(),t&&(t.style.display=`none`),r=null}function m(e,t){let n=t.closest(`[data-error-path]`);if(!n)return null;let r=n.getAttribute(`data-error-path`);if(!r)return null;let i=(i4.getState(e.state)?.errors??[]).find(e=>e.path===r);return i?{error:i,target:n}:{error:{path:r,kind:n.getAttribute(`data-error-kind`)??``,message:n.getAttribute(`title`)??``},target:n}}return new bQ({key:eGe,view(e){return t=d(e),o=()=>l(),s=()=>u(),t.addEventListener(`mouseenter`,o),t.addEventListener(`mouseleave`,s),i=t=>{let n=t.target;if(!(n instanceof Element))return;let i=m(e,n);i&&i.error.path!==r&&f(e,i.error,i.target)},a=e=>{let n=e.relatedTarget;n instanceof Node&&t?.contains(n)||u()},e.dom.addEventListener(`mouseover`,i),e.dom.addEventListener(`mouseout`,a),{update(){},destroy(){l(),i&&e.dom.removeEventListener(`mouseover`,i),a&&e.dom.removeEventListener(`mouseout`,a),n&&=(n.unmount(),null),t?.remove(),t=null,r=null}}}})}var nGe=new CQ(`linkCatalog`);function rGe(e){return new bQ({key:nGe,appendTransaction(t,n,r){if(!t.some(e=>e.docChanged))return null;let i=e.getLinkCatalog();if(!i||i.length===0)return null;let a=r.schema.marks.link;if(!a)return null;let o=new Set(i.map(e=>e.href.trim())),s=r.tr,c=!1;return r.doc.descendants((e,t)=>{if(!e.isInline||!e.isText)return;let n=a.isInSet(e.marks);if(!n)return;let r=n.attrs.href.trim();o.has(r)||(s=s.removeMark(t,t+e.nodeSize,a),c=!0)}),c?s:null}})}var iGe=new CQ(`linkClick`);function aGe(e,t){let n=e;for(;n&&n!==t;){if(n.nodeName===`A`)return n;n=n.parentElement}return null}function oGe(e,t){let{linkHelper:n,getLinkCatalog:r}=t;return new bQ({key:iGe,props:{handleDOMEvents:{dblclick(t,i){let a=e.marks.link;if(!a)return!1;let o=aGe(i.target,t.dom);if(!o)return!1;i.preventDefault();let s=t.posAtDOM(o.firstChild??o,0);if(s<0)return!1;let c=t.state.doc.resolve(s),l=a.isInSet(c.marks())??(c.nodeAfter&&a.isInSet(c.nodeAfter.marks)||null);if(!l)return!1;let u=l.attrs.href,d=c.parent,f=c.start(c.depth),p=s,m=s,h=0;for(let e=0;e<d.childCount;e++){let t=d.child(e),n=t.isText?a.isInSet(t.marks):null;if(n&&n.attrs.href===u){let n=f+h,r=n+t.nodeSize;if(r>p&&n<=s){p=n,m=r;for(let t=e+1;t<d.childCount;t++){let e=d.child(t),n=e.isText?a.isInSet(e.marks):null;if(!n||n.attrs.href!==u)break;m+=e.nodeSize}for(let t=e-1;t>=0;t--){let e=d.child(t),n=e.isText?a.isInSet(e.marks):null;if(!n||n.attrs.href!==u)break;p-=e.nodeSize}break}}h+=t.nodeSize}if(p>=m)return!1;let g=t.state.tr.setSelection(oQ.create(t.state.doc,p,m));t.dispatch(g);let _=r?.();return _&&_.length>0?n.showCatalogPicker(t,a,_):n.showUrlEditor(t,a),!0}}}})}function sGe({onUpload:e,accept:t}){let[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(null);return(0,b.createElement)(`div`,{style:{marginTop:`6px`}},(0,b.createElement)(`input`,{ref:i,type:`file`,accept:t,hidden:!0,onChange:t=>{let n=t.currentTarget.files?.[0];n&&(r(!0),e(n).finally(()=>r(!1)),t.target.value=``)}}),(0,b.createElement)(`button`,{type:`button`,disabled:n,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`4px`,width:`100%`,padding:`4px 8px`,fontSize:`12px`,borderRadius:`4px`,border:`1px solid var(--border-primary, #ccc)`,background:`var(--bg-secondary, #f5f5f5)`,cursor:n?`wait`:`pointer`,opacity:n?.6:1},onClick:e=>{e.preventDefault(),e.stopPropagation(),i.current?.click()}},n?`Uploading...`:`Upload image`))}function cGe(e,t){let n=t?.inline??!1,r=e=>{let n=t?.getUrl?.();return n?n(e):e};return(i,a,o)=>{let s=document.createElement(n?`span`:`figure`);n?(s.style.position=`relative`,s.style.display=`inline-block`):(s.style.margin=`0.5em 0`,s.style.position=`relative`);let c=document.createElement(`img`);if(c.src=i.attrs.previewUrl||r(i.attrs.src),i.attrs.alt&&(c.alt=i.attrs.alt),c.style.maxWidth=`100%`,c.style.cursor=`pointer`,n||(c.style.display=`block`,c.style.borderRadius=`var(--radius, 0.25rem)`),s.appendChild(c),!n&&i.attrs.caption){let e=document.createElement(`figcaption`);e.textContent=i.attrs.caption,e.style.fontSize=`0.85em`,e.style.color=`var(--fg-secondary-alt)`,e.style.marginTop=`0.3em`,e.style.textAlign=`center`,s.appendChild(e)}let l=null,u=null,d=!1,f=null;function p(){u&&=(u.unmount(),null),l?.remove(),l=null,d=!1,f&&=(document.removeEventListener(`mousedown`,f,!0),null)}function m(){let n=e.current,r=t?.getOnImageUpload?.();if(!n&&!r)return;p(),d=!0,l=document.createElement(`div`),l.style.minWidth=`200px`,l.addEventListener(`mousedown`,e=>{e.stopPropagation()});let m=t?.getPortalContainer?.();if(m){l.className=[`fixed z-window rounded-md border border-border-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `);let e=c.getBoundingClientRect();l.style.left=`${e.left}px`,l.style.top=`${e.bottom+4}px`,m.appendChild(l)}else l.className=[`absolute z-window rounded-md border border-border-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `),l.style.left=`0`,l.style.top=`${c.offsetHeight+4}px`,s.appendChild(l);let h=i.attrs.src;function g(e){let t=o();if(t===void 0)return null;let n=a.state.tr.setNodeMarkup(t,void 0,{...i.attrs,src:e});a.dispatch(n),p(),a.focus();let r=s4(a.state.doc,t);return r?[...r,`src`]:null}u=(0,x.createRoot)(l);let _=[];if(n&&_.push((0,b.createElement)(()=>n(h,g))),r){let e=r,n=t?.getImageAccept?.()??`image/*`;_.push((0,b.createElement)(sGe,{key:`upload`,accept:n,onUpload:async t=>await e(t,g)}))}u.render((0,b.createElement)(`div`,null,..._)),f=e=>{l&&!l.contains(e.target)&&!c.contains(e.target)&&p()},setTimeout(()=>document.addEventListener(`mousedown`,f,!0),0)}return c.addEventListener(`mousedown`,n=>{!e.current&&!t?.getOnImageUpload?.()||(n.preventDefault(),n.stopPropagation(),d?p():m())}),{dom:s,stopEvent:()=>!1,update(e){return e.type===i.type&&(i=e,c.src=i.attrs.previewUrl||r(i.attrs.src),i.attrs.alt?c.alt=i.attrs.alt:c.removeAttribute(`alt`),!0)},destroy(){p()}}}}function lGe(e,t){let n=e.find(e=>e.variant===t);if(n&&Array.isArray(n.link))return n.link}function uGe({variants:e,currentVariant:t,currentHref:n,onSelectVariant:r}){let[i,a]=(0,b.useState)(null);if(i){let t=lGe(e,i),o=t&&t.length>0;return(0,Y.jsx)(`div`,{className:o?`min-w-[280px] flex flex-col`:`flex items-center gap-1.5 p-1.5`,children:o?(0,Y.jsx)(P3,{catalog:t,currentHref:n,onApplyLink:e=>r(i,e.href.trim()),onRemoveLink:null,onClose:()=>a(null)}):(0,Y.jsx)(F3,{currentHref:n??``,isNewLink:!n,onApply:e=>r(i,e),onUnlink:()=>{r(i,``),a(null)},onClose:()=>a(null)})})}return(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.map(e=>{let n=e.variant===t;return(0,Y.jsxs)(`button`,{type:`button`,className:[`flex items-center gap-2 rounded px-3 py-1.5 text-left text-sm`,`transition-colors w-full`,n?`bg-bg-secondary-hover font-medium`:`hover:bg-bg-secondary-hover`].join(` `),onMouseDown:t=>{t.preventDefault(),e.link?a(e.variant):r(e.variant)},children:[n&&(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-brand-primary text-xs`,"aria-hidden":`true`,children:`✓`}),(0,Y.jsx)(`span`,{className:n?`text-fg-brand-primary`:`text-fg-secondary`,children:e.label}),e.link&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-fg-secondary-alt`,children:`link`})]},e.variant)})})}var B3=[`inline-flex items-center rounded px-2 py-0.5 text-sm font-medium`,`bg-bg-brand-secondary text-fg-brand-secondary cursor-pointer`].join(` `);function V3(e,t,n,r,i,a){let o=null,s=null,c=!1,l=null;function u(){s&&=(s.unmount(),null),o?.remove(),o=null,c=!1,l&&=(document.removeEventListener(`mousedown`,l,!0),null)}function d(t){if(!o)return;let r=e.getBoundingClientRect();if(t)o.style.left=`${r.left}px`,o.style.top=`${r.bottom+4}px`;else{let e=n.dom.parentElement,t=e?.offsetParent?.getBoundingClientRect()??e?.parentElement?.getBoundingClientRect();if(!t)return;o.style.left=`${r.left-t.left}px`,o.style.top=`${r.bottom-t.top+4}px`}}function f(){let f=t.variantsRef.current;if(!f||f.length===0)return;let p=n.dom.parentElement;if(!p)return;u(),c=!0,o=document.createElement(`div`),o.style.minWidth=`180px`,o.addEventListener(`mousedown`,e=>{e.stopPropagation()});let m=a?.getPortalContainer?.(),h=!!m;o.className=[`${h?`fixed`:`absolute`} z-window rounded-md border border-border-primary`,`bg-bg-primary p-1 shadow-lg`].join(` `),(m??p).appendChild(o),d(h);let g=i(),_=g.attrs.variant,v=g.attrs.href??null;function y(e,a){let o=r();if(o===void 0)return;let s=t.variantsRef.current?.find(t=>t.variant===e);if(!s)return;let{schema:c}=n.state,l=s.children===!1,d=l?c.nodes.button_atom:c.nodes.button_editable;if(!d)return;let f={variant:e};l||(f.href=a||null);let p=i();if(l===(p.type.name===`button_atom`)){let e=n.state.tr.setNodeMarkup(o,void 0,f);n.dispatch(e)}else{let e=l?d.create(f):d.create(f,s.label?[c.text(s.label)]:[]),t=n.state.tr.replaceWith(o,o+p.nodeSize,e);n.dispatch(t)}u(),n.focus()}s=(0,x.createRoot)(o),s.render((0,b.createElement)(uGe,{variants:f,currentVariant:_,currentHref:v,onSelectVariant:y,onClose:()=>{u(),n.focus()}})),l=t=>{o&&!o.contains(t.target)&&!e.contains(t.target)&&u()},setTimeout(()=>document.addEventListener(`mousedown`,l,!0),0)}function p(){c?u():f()}return{toggle:p,closeOverlay:u,isOpen:()=>c}}function dGe(e,t){return(n,r,i)=>{let a=document.createElement(`span`);a.style.position=`relative`,a.style.display=`inline-block`;let o=document.createElement(`button`);o.setAttribute(`type`,`button`),o.className=`${B3} cursor-default`,o.contentEditable=`false`;let s=n,c=n.attrs.variant;o.setAttribute(`data-variant`,c),o.setAttribute(`data-atom`,`true`),o.textContent=e.current?.find(e=>e.variant===c)?.label??c,a.appendChild(o);let l=V3(o,{variantsRef:e},r,i,()=>s,t);return o.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation(),l.toggle()}),{dom:a,stopEvent:()=>!0,update(t){if(t.type.name!==`button_atom`)return!1;s=t;let n=t.attrs.variant;o.setAttribute(`data-variant`,n);let r=e.current?.find(e=>e.variant===n)?.label??n;return o.textContent=r,!0},destroy(){l.closeOverlay()}}}}function fGe(e,t){return(n,r,i)=>{let a=document.createElement(`span`);a.style.position=`relative`,a.style.display=`inline-block`;let o=document.createElement(`button`);o.setAttribute(`type`,`button`),o.className=B3;let s=n,c=n.attrs.variant;o.setAttribute(`data-variant`,c);function l(e){e?(o.setAttribute(`data-href`,e),o.title=e):(o.removeAttribute(`data-href`),o.removeAttribute(`title`))}l(n.attrs.href);let u=document.createElement(`span`);o.appendChild(u),a.appendChild(o);let d=V3(o,{variantsRef:e},r,i,()=>s,t);return o.addEventListener(`dblclick`,e=>{e.preventDefault(),d.toggle()}),{dom:a,contentDOM:u,update(e){return e.type.name===`button_editable`&&(s=e,o.setAttribute(`data-variant`,e.attrs.variant),l(e.attrs.href),!0)},destroy(){d.closeOverlay()}}}}function H3({schema:e,initialDoc:t,viewRef:n,label:r,minHeight:i,allowEnter:a=!0}){let o=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(!o.current)return;let e=()=>!0,r=a?[O0(E2),S0()]:[O0({Enter:e,"Shift-Enter":e}),O0(E2),S0()],i=vQ.create({doc:t,plugins:r}),s=new i0(o.current,{state:i,editable:()=>!0});return n.current=s,()=>{s.destroy(),n.current=null}},[e,t,n,a]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-secondary`,children:r}),(0,Y.jsx)(`div`,{ref:o,className:[`prose-editor overflow-y-auto rounded-md`,`border border-border-primary bg-bg-primary p-2`,`text-fg-primary caret-fg-primary`,`focus-within:ring-2 focus-within:ring-border-brand-primary`].join(` `),style:{minHeight:i}})]})}function pGe({schema:e,summaryContent:t,bodyNodes:n,onSave:r,onCancel:i}){let a=(0,b.useRef)(null),o=(0,b.useRef)(null),s=e.node(`doc`,null,[e.node(`paragraph`,null,t)]),c=n.length>0?n:[e.node(`paragraph`)],l=e.node(`doc`,null,c),u=(0,b.useCallback)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=[],i=e.state.doc.firstChild;i&&i.forEach(e=>n.push(e));let s=[];t.state.doc.forEach(e=>s.push(e)),r(n,s)},[r]),d=(0,b.useCallback)(e=>{e.target===e.currentTarget&&i()},[i]);return(0,b.useEffect)(()=>{function e(e){e.key===`Escape`&&i()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]),(0,Y.jsx)(`div`,{className:`fixed inset-0 z-overlay flex items-center justify-center bg-black/40`,onMouseDown:d,children:(0,Y.jsxs)(`div`,{className:[`flex w-full max-w-2xl flex-col rounded-lg border border-border-primary`,`bg-bg-primary shadow-2xl`].join(` `),onMouseDown:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border-primary px-4 py-3`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg-primary`,children:`Edit Details`}),(0,Y.jsx)(`button`,{type:`button`,className:`rounded p-1 text-fg-secondary hover:bg-bg-secondary-hover`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,Y.jsx)(H3,{schema:e,initialDoc:s,viewRef:a,label:`Summary`,minHeight:`40px`,allowEnter:!1}),(0,Y.jsx)(H3,{schema:e,initialDoc:l,viewRef:o,label:`Hidden content`,minHeight:`120px`})]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border-primary px-4 py-3`,children:[(0,Y.jsx)(`button`,{type:`button`,className:[`rounded-md px-3 py-1.5 text-sm font-medium`,`text-fg-secondary hover:bg-bg-secondary-hover`].join(` `),onClick:i,children:`Cancel`}),(0,Y.jsx)(`button`,{type:`button`,className:[`rounded-md px-3 py-1.5 text-sm font-medium`,`bg-bg-brand-primary text-fg-brand-primary`,`hover:opacity-90`].join(` `),onClick:u,children:`Save`})]})]})})}function U3(e){let t=``;return e.forEach((e,n,r)=>{r===0&&e.type.name===`details_summary`&&(t=e.textContent)}),t||`Details`}function mGe(e){let t=[];return e.forEach((e,n,r)=>{r===0&&e.type.name===`details_summary`&&e.forEach(e=>t.push(e))}),t}function hGe(e){let t=[],n=!0;return e.forEach(e=>{if(n){n=!1;return}t.push(e)}),t}function gGe(e){return(t,n,r)=>{let i=t.attrs.variant,a=document.createElement(`div`);a.className=`details-collapsed group my-1 select-none`,a.style.cursor=`pointer`,i!==`details`&&a.setAttribute(`data-variant`,i);let o=document.createElement(`div`);o.style.display=`flex`,o.style.alignItems=`center`,o.style.gap=`6px`,o.style.padding=`4px 6px`,o.style.borderRadius=`4px`,o.style.transition=`background 100ms ease`,o.addEventListener(`mouseenter`,()=>{o.style.background=`var(--bg-secondary-hover, #f5f5f5)`}),o.addEventListener(`mouseleave`,()=>{o.style.background=``}),a.appendChild(o);let s=document.createElement(`span`);s.textContent=`▶`,s.style.fontSize=`0.65em`,s.style.color=`var(--fg-secondary-alt, #888)`,s.style.userSelect=`none`,s.style.flexShrink=`0`,s.style.transition=`transform 120ms ease`,o.appendChild(s);let c=document.createElement(`span`);c.style.fontSize=`inherit`,c.style.color=`var(--fg-primary, #333)`,c.textContent=U3(t),o.appendChild(c);let l=null,u=null;function d(){l&&=(l.unmount(),null),u?.remove(),u=null,s.style.transform=``}function f(){d(),s.style.transform=`rotate(90deg)`;let t=r();if(t===void 0)return;let i=n.state.doc.nodeAt(t);if(!i||i.type.name!==`details`)return;let a=mGe(i),o=hGe(i);u=document.createElement(`div`),document.body.appendChild(u),l=(0,x.createRoot)(u),l.render((0,b.createElement)(pGe,{schema:e,summaryContent:a,bodyNodes:o,onSave:(t,i)=>{let a=r();if(a===void 0)return;let o=n.state.doc.nodeAt(a);if(!o||o.type.name!==`details`)return;let s=e.nodes.details_summary.create(null,t),l=i.length>0?i:[e.nodes.paragraph.create()],u=o.type.create(o.attrs,[s,...l]),f=n.state.tr.replaceWith(a,a+o.nodeSize,u);n.dispatch(f),d(),c.textContent=s.textContent||`Details`,n.focus()},onCancel:()=>{d(),n.focus()}}))}return o.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation(),f()}),{dom:a,update(e){if(e.type.name!==`details`)return!1;let t=e.attrs.variant;return t===`details`?a.removeAttribute(`data-variant`):a.setAttribute(`data-variant`,t),c.textContent=U3(e),!0},stopEvent(){return!0},ignoreMutation(){return!0},destroy(){d()}}}}function W3({state:e,useFixedPosition:t,onApplyLink:n,onRemoveLink:r,onApplyUrl:i,onUnlink:a,onClose:o}){let s=(0,b.useRef)(null);(0,b.useEffect)(()=>{function e(e){let t=e.target;s.current&&!s.current.contains(t)&&o()}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let c=e.kind===`catalog`,l=t?`fixed`:`absolute`;return(0,Y.jsx)(`div`,{ref:s,className:c?`${l} z-window flex flex-col rounded-md border border-border-primary bg-bg-primary shadow-xl min-w-[280px]`:`${l} z-window flex items-center gap-1.5 rounded-md border border-border-primary bg-bg-primary p-1.5 shadow-xl`,style:{left:e.anchorRect.left,top:e.anchorRect.top},onMouseDown:e=>{e.stopPropagation()},children:c&&e.catalog?(0,Y.jsx)(P3,{catalog:e.catalog,currentHref:e.currentHref,onApplyLink:n,onRemoveLink:e.currentHref===null?null:r,onClose:o}):(0,Y.jsx)(F3,{currentHref:e.currentHref??``,isNewLink:e.isNewLink??!0,onApply:i,onUnlink:a,onClose:o})})}function G3(e,t){let n=t.content.size,r=Math.min(e.anchor,n);try{return nQ.near(t.resolve(r))}catch{return nQ.atStart(t)}}var _Ge=(0,b.forwardRef)(function(e,t){let{value:n,defaultValue:r,onChange:i,onDirty:a,readOnly:o=!1,features:s,diffBase:c,errors:l,errorKindClassName:u,onApplyErrorFix:d,linkCatalog:f,images:p,imageModulePath:m,onImageUpload:h,imageAccept:g,uploadProgress:_,buttonVariants:v,detailsVariants:y,className:x,portalContainer:S}=e,{moduleEntries:C,getUrl:w,ready:T}=iA(m),E=T&&!!C,D=(0,b.useRef)(null),O=(0,b.useRef)(null),k=(0,b.useRef)(null),A=(0,b.useRef)(null),j=(0,b.useRef)([]),M=(0,b.useRef)(i),N=(0,b.useRef)(a),P=(0,b.useRef)(d),F=(0,b.useRef)(f),I=(0,b.useRef)(p),L=(0,b.useRef)(C),R=(0,b.useRef)(w),[ee,te]=(0,b.useState)(null),ne=(0,b.useRef)(ee);ne.current=ee;let re=(0,b.useRef)(void 0),ie=(0,b.useRef)(h),ae=(0,b.useRef)(g),oe=(0,b.useRef)(_),se=(0,b.useRef)(v),ce=(0,b.useRef)(y),le=(0,b.useRef)(S),ue=(0,b.useRef)(null),de=n!==void 0;(0,b.useEffect)(()=>{M.current=i,N.current=a,P.current=d,F.current=f,I.current=p,L.current=C,R.current=w,ie.current=h,ae.current=g,oe.current=_,se.current=v,ce.current=y,le.current=S,E?re.current=(e,t)=>(0,Y.jsx)(uA,{moduleEntries:L.current,selectedRef:e,isImage:!0,getUrl:R.current,autoFocus:!0,maxHeight:280,onSelect:e=>{t(e.filePath)}}):p&&p.length>0?re.current=(e,t)=>(0,Y.jsx)(N3,{images:I.current,currentSrc:e,onSelect:t}):re.current=void 0});let fe={...MHe,...s},pe=fe.styles,me=(0,b.useMemo)(()=>rHe({features:fe,buttonVariants:v,detailsVariants:y,styleConfig:pe}),[]);A.current=me.marks.link??null;let he=fe.fixedToolbar&&lUe({schema:me,features:fe,styleConfig:pe,canInsertImage:!!h||!!p?.length||!!m,buttonVariants:v,detailsVariants:y});(0,b.useLayoutEffect)(()=>{if(!D.current)return;let e=de?n:r??[],t,i=ue.current;if(ue.current=null,i!==null&&i.type.schema===me)t=i;else{try{t=n2(e??[],me)}catch{t=me.node(`doc`,null,[me.node(`paragraph`)])}j.current=e??[]}let a=()=>le.current??null,s=[...NHe(me,fe),IHe(me,fe),S0(),E0(),M0(),HHe(),$He(fe),eUe(),tGe({getPortalContainer:a,onApplyErrorFix:e=>{if(e.kind===`schema.violation`&&k.current){YHe(k.current,e.path,e.fixId);return}P.current?.(e)}})],c=()=>F.current,l=()=>se.current,u=()=>ce.current,d=sUe({getLinkCatalog:c,getPortalContainer:a,onPickerStateChange:e=>{te(e)},isPickerOpen:()=>ne.current!==null});s.push(rGe({getLinkCatalog:c})),!o&&fe.link&&s.push(oGe(me,{getLinkCatalog:c,linkHelper:d}));let f=()=>I.current,p=()=>L.current,m=()=>R.current,h=()=>ie.current,g=()=>ae.current,_=()=>oe.current;fe.fixedToolbar&&s.push(JWe(me,{getMount:()=>O.current,getLinkCatalog:c,getImages:f,getImageModuleEntries:p,getImageGetUrl:m,getOnImageUpload:h,getImageAccept:g,getUploadProgress:_,getButtonVariants:l,getDetailsVariants:u,linkHelper:d,styleConfig:pe,features:fe,readOnly:o})),fe.floatingToolbar&&!o&&s.push(XWe(me,{getPortalContainer:a,getLinkCatalog:c,getImages:f,getImageModuleEntries:p,getImageGetUrl:m,getOnImageUpload:h,getImageAccept:g,getUploadProgress:_,getButtonVariants:l,getDetailsVariants:u,linkHelper:d,styleConfig:pe,features:fe})),fe.gutter&&!o&&s.push(QWe(me,fe,{getPortalContainer:a}));let v={};me.nodes.image&&(v.image=cGe(re,{inline:!0,getPortalContainer:a,getUrl:m,getOnImageUpload:h,getImageAccept:g})),me.nodes.button_atom&&(v.button_atom=dGe(se,{getPortalContainer:a})),me.nodes.button_editable&&(v.button_editable=fGe(se,{getPortalContainer:a})),me.nodes.details&&(v.details=gGe(me));let y=vQ.create({doc:t,plugins:s}),b=new i0(D.current,{state:y,editable:()=>!o,nodeViews:v,dispatchTransaction(e){let t=b.state.apply(e);if(b.updateState(t),e.docChanged&&(N.current?.(),M.current)){let e=o2(t.doc),n=e2(j.current,e);j.current=e,M.current({value:e,patches:n})}}});return k.current=b,()=>{ue.current=b.state.doc,d.destroy(),b.destroy(),k.current=null}},[me,o,he,fe.floatingToolbar,fe.gutter]),(0,b.useEffect)(()=>{let e=k.current;e&&e.dispatch(e.state.tr)},[C,p,h,v,y]),(0,b.useEffect)(()=>{let e=k.current;if(!e||!de||!n)return;let t=o2(e.state.doc);if(JSON.stringify(t)!==JSON.stringify(n))try{let t=n2(n,me),r=e.state.selection,i=vQ.create({doc:t,plugins:e.state.plugins,selection:G3(r,t)});e.updateState(i),j.current=n}catch(e){console.error(e)}},[n,de,me]),(0,b.useEffect)(()=>{let e=k.current;if(e){if(c)try{let t=n2(c,me),n=e.state.tr.setMeta(J2,{baseDoc:t});e.dispatch(n)}catch{}else{let t=e.state.tr.setMeta(J2,{baseDoc:null});e.dispatch(t)}}},[c,me]),(0,b.useEffect)(()=>{let e=k.current;if(!e)return;let t=e.state.tr.setMeta(i4,{errors:l??[],errorKindClassName:u??{}});e.dispatch(t)},[l,u]);let ge=(0,b.useCallback)(()=>k.current?o2(k.current.state.doc):[],[]),_e=(0,b.useCallback)(e=>e2(e,k.current?o2(k.current.state.doc):[]),[]),ve=(0,b.useCallback)(e=>{let t=k.current;if(!t)return;let n=e?n2(e,me):me.node(`doc`,null,[me.node(`paragraph`)]),r=t.state.selection,i=vQ.create({doc:n,plugins:t.state.plugins,selection:G3(r,n)});t.updateState(i),j.current=e??[]},[me]);(0,b.useImperativeHandle)(t,()=>({getDocument:ge,getPatches:_e,reset:ve}),[ge,_e,ve]);let ye=(0,b.useCallback)(e=>{let t=k.current,n=A.current,r=ne.current;if(!t||!n||!r)return;let{state:i,dispatch:a}=t,o=i.tr;e?(o=o.removeMark(r.savedFrom,r.savedTo,n),o=o.addMark(r.savedFrom,r.savedTo,n.create({href:e}))):o=o.removeMark(r.savedFrom,r.savedTo,n),a(o),te(null),t.focus()},[]),be=(0,b.useCallback)(e=>{ye(e.href.trim())},[ye]),xe=(0,b.useCallback)(()=>{ye(null)},[ye]),Se=(0,b.useCallback)(e=>{ye(e)},[ye]),Ce=(0,b.useCallback)(()=>{ye(null)},[ye]),we=(0,b.useCallback)(()=>{te(null),k.current?.focus()},[]);return(0,Y.jsxs)(`div`,{className:[`rich-text-editor relative flex flex-col`,o?`cursor-default`:``,x??``].filter(Boolean).join(` `),children:[he&&(0,Y.jsx)(`div`,{ref:O,className:[`rounded-t-md border border-border-primary`,`bg-bg-secondary absolute left-0 top-0 z-hover w-full`].join(` `)}),(0,Y.jsx)(`div`,{ref:D,className:[`prose-editor relative min-h-10 border border-border-primary`,`bg-bg-primary text-fg-primary caret-fg-primary`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-border-focus rounded-md`,`px-3 py-2`,he?`pt-14`:``,o?`opacity-80`:``].join(` `)}),ee&&(S?(0,lm.createPortal)((0,Y.jsx)(W3,{state:ee,useFixedPosition:!0,onApplyLink:be,onRemoveLink:xe,onApplyUrl:Se,onUnlink:Ce,onClose:we}),S):(0,Y.jsx)(W3,{state:ee,onApplyLink:be,onRemoveLink:xe,onApplyUrl:Se,onUnlink:Ce,onClose:we}))]})});function vGe(e){if(!e)return{};let t={};return t.bold=e.bold??!1,t.italic=e.italic??!1,t.strikethrough=e.lineThrough??!1,t.h1=e.h1??!1,t.h2=e.h2??!1,t.h3=e.h3??!1,t.h4=e.h4??!1,t.h5=e.h5??!1,t.h6=e.h6??!1,t.bulletList=e.ul??!1,t.orderedList=e.ol??!1,t.link=!!e.a,t.image=!!e.img,t.hardBreak=!0,t.fixedToolbar=!0,t.floatingToolbar=!1,t.gutter=!1,t.code=!1,t.blockquote=!1,t.codeBlock=!1,t.details=!1,t.button=!1,t}function yGe(e){if(!(!e||typeof e.path!=`string`))return H.mediaUrl({path:e.path})}function bGe(e){let t=(0,b.useMemo)(()=>vGe(e),[e]),n=e?.a===!0||typeof e?.a==`object`&&`type`in e.a&&e.a.type===`route`,r=n&&e?.a&&typeof e.a==`object`&&`type`in e.a&&e.a.type===`route`?e.a:void 0,i=(0,b.useMemo)(()=>r?.options?.include?new RegExp(r.options.include.source,r.options.include.flags):void 0,[r?.options?.include?.source,r?.options?.include?.flags]),a=(0,b.useMemo)(()=>r?.options?.exclude?new RegExp(r.options.exclude.source,r.options.exclude.flags):void 0,[r?.options?.exclude?.source,r?.options?.exclude?.flags]),o=TA(),s=ooe();return{features:t,linkCatalog:(0,b.useMemo)(()=>{if(!n)return;let e=new Map;return o.filter(({route:e})=>!(i&&!i.test(e)||a&&a.test(e))).map(({route:t,moduleFilePath:n})=>{if(!e.has(n)){let t=new Map,r=s[n];if(r){let e=r[n];if(e&&`data`in e&&e.data&&e.data.parent===`record`)for(let[n,r]of e.data.items)t.set(n,{title:r.title,subtitle:r.subtitle,image:yGe(r.image)})}e.set(n,t)}let r=e.get(n)?.get(t);return r?{title:r.title,subtitle:r.subtitle??n,href:t,image:r.image}:{title:t,subtitle:n,href:t}})},[n,o,i,a,s]),imageModulePath:(0,b.useMemo)(()=>{let t=e?.img;if(t&&typeof t==`object`&&`type`in t&&t.type===`image`&&`referencedModule`in t&&typeof t.referencedModule==`string`)return t.referencedModule},[e]),imageSchema:(0,b.useMemo)(()=>{let t=e?.img;if(t&&typeof t==`object`&&`type`in t&&t.type===`image`)return t},[e])}}var xGe=400;function SGe({path:e,readonly:t}){let n=`richtext`,r=bb(),i=xS(),a=SS(),{source:o,schema:s,patchPath:c,addPatch:l,addAndUploadPatchWithFileOps:u,addModuleFilePatch:d}=yb(e,n),f=`data`in o?o.data:void 0,p=(0,b.useRef)(null),m=(0,b.useRef)(f??[]),h=(0,b.useRef)(null),g=(0,b.useRef)(!1),_=(0,b.useRef)(!1),v=(0,b.useRef)(!1),y=(0,b.useRef)(null),[x,S]=(0,b.useState)(null),C=`clientSideOnly`in o&&o.clientSideOnly;(0,b.useEffect)(()=>{if(C!==!1||!f||v.current)return;let e=f,t=p.current?.getDocument();t&&!Mr(t,e)&&(p.current?.reset(e),m.current=e)},[f,C]);let w=eb(),T=`data`in s&&s.data.type===`richtext`?s.data.options:void 0,{features:E,linkCatalog:D,imageModulePath:O,imageSchema:k}=bGe(T),A=!!T?.img,j=k?.referencedModule,M=Tb(j),N=(0,b.useMemo)(()=>{if(A){if(k?.options?.accept)return k.options.accept;if(M?.type===`record`&&M.accept)return M.accept}},[A,k,M]),P=(0,b.useMemo)(()=>M?.type===`record`?M.directory:void 0,[M]),F=(0,b.useMemo)(()=>{let e=M?.type===`record`?M.encode:void 0;return{settings:hA(k?.options?.encode,e),accept:N}},[k,M,N]),I=(0,b.useMemo)(()=>!A||!k?.remote||i.status!==`ready`||!a||!r?.remoteHost?null:{publicProjectId:i.publicProjectId,bucket:a,coreVersion:i.coreVersion,schema:k,remoteHost:r.remoteHost},[A,k,i,a,r]),L=(0,b.useMemo)(()=>{if(A)return async(e,t)=>{try{let n=await gA(e,F),r;n.width&&n.height&&n.mimeType&&(r={width:n.width,height:n.height,mimeType:n.mimeType});let{patch:i,filePath:a}=await CA(c,n.src,n.filename??null,n.fileHash,r,`image`,I,P,!!j);if(i.length===0)return null;let o=i[0]&&`value`in i[0]&&typeof i[0].value==`object`&&i[0].value!==null&&`path`in i[0].value?i[0].value.path:a,s=i.filter(e=>e.op===`file`);_.current=!0;let l=t(o,{previewUrl:n.src,width:r?.width,height:r?.height,mimeType:r?.mimeType});h.current&&=(clearTimeout(h.current),null),v.current=!1;let f=p.current?.getDocument();if(!f)return null;let g=K3(c,f);m.current=f;let y=s.map(e=>({...e,...l?{nestedFilePath:l}:{}})),b=[...g,...y],x=[];j&&a&&r?.mimeType&&r.width!==void 0&&r.height!==void 0&&x.push({moduleFilePath:j,patch:[{op:`add`,path:[a],value:{width:r.width,height:r.height,mimeType:r.mimeType,alt:null}}]}),S(0),await u(b,`image`,e=>{console.error(`Failed to upload image in richtext:`,e),S(null)},(e,t,n,r)=>{let i=t>0?Math.round(e*(n+1)/(t*r)*100):0;S(Math.min(i,100))}),S(null);for(let e of x)d(e.moduleFilePath,e.patch,`record`);return{filePath:a,ref:o}}catch(e){return console.error(`Failed to prepare image for upload`,e),S(null),null}}},[A,c,I,P,j,u,d,F]),R=(0,b.useCallback)(()=>{if(!g.current){if(_.current){_.current=!1;return}v.current=!0,y.current=p.current?.getDocument()??null,h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,ee.current()},xGe)}},[]),ee=(0,b.useRef)(()=>void 0);return ee.current=()=>{let e=y.current??p.current?.getDocument();if(!e)return;y.current=null;let t=K3(c,e);m.current=e,l(t,`richtext`),v.current=!1},(0,b.useEffect)(()=>()=>{h.current&&(clearTimeout(h.current),h.current=null,ee.current()),v.current=!1},[]),s.status===`error`?(0,Y.jsx)(NC,{path:e,error:s.error,type:n}):o.status===`error`?(0,Y.jsx)(FC,{path:e,error:o.error,schema:s}):o.status===`not-found`||s.status===`not-found`?(0,Y.jsx)(MC,{path:e,type:n}):s.status===`loading`||!(`data`in o)||o.data===void 0?(0,Y.jsx)(jC,{path:e,type:n}):s.data.type===n?(r?.remoteHost||console.warn(`RichTextField: config.remoteHost is not set. Remote images will not work.`),(0,Y.jsx)(`div`,{id:e,className:`m-1`,children:(0,Y.jsx)(_Ge,{ref:p,defaultValue:f??[],features:E,linkCatalog:D,readOnly:t||g.current,onDirty:R,imageModulePath:O,onImageUpload:L,imageAccept:N,uploadProgress:x,portalContainer:w})})):(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:s.data.type})}function K3(e,t){return[{op:`replace`,path:e,value:t}]}function CGe({path:e}){let t=Ob(e,`richtext`);if(t.status===`error`)return(0,Y.jsx)(FC,{path:e,error:t.error});if(t.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:`richtext`});if(!(`data`in t)||t.data===void 0)return(0,Y.jsx)(J3,{path:e});if(t.data===null)return(0,Y.jsx)(Y3,{path:e});let n=wGe(t.data);return n.status===`error`?(0,Y.jsx)(FC,{path:e,error:n.error}):(0,Y.jsx)(`div`,{className:`truncate`,children:n.value})}function wGe(e){let t;function n(e){if(t)return t;if(typeof e==`string`)return e;if(typeof e==`object`&&e){if(`children`in e&&Array.isArray(e.children))return e.children.map(n).join(` `);if(`tag`in e&&typeof e.tag==`string`)return``}return t=`Invalid richtext node: `+JSON.stringify(e),JSON.stringify(e)}let r=e.map(n).join(` `);return t?{status:`error`,error:t}:{status:`ok`,value:r}}function q3({path:e,size:t}){let n=Cb(e),r=Ob(e,`data`in n&&n.data.type?n.data.type:void 0);if(!(`data`in n)||n.data===void 0)return(0,Y.jsx)(J3,{path:e});let i=n.data.type;return`data`in r&&r.data===null?(0,Y.jsx)(Y3,{path:e}):i===`string`?(0,Y.jsx)(ude,{path:e}):i===`array`?(0,Y.jsx)(FGe,{path:e}):i===`boolean`?(0,Y.jsx)(Cde,{path:e}):i===`number`?(0,Y.jsx)(Tde,{path:e}):i===`union`?(0,Y.jsx)(ige,{path:e}):i===`object`?(0,Y.jsx)(Jhe,{path:e,size:t}):i===`image`?(0,Y.jsx)(Uge,{path:e}):i===`keyOf`?(0,Y.jsx)(qge,{path:e}):i===`route`?(0,Y.jsx)(y_e,{path:e}):i===`date`?(0,Y.jsx)(qye,{path:e}):i===`dateTime`?(0,Y.jsx)(nbe,{path:e}):i===`color`?(0,Y.jsx)(nRe,{path:e}):i===`code`?(0,Y.jsx)($Le,{path:e}):i===`literal`?(0,Y.jsx)(rRe,{path:e}):i===`record`?(0,Y.jsx)(FRe,{path:e,size:t}):i===`richtext`?(0,Y.jsx)(CGe,{path:e}):i===`file`?(0,Y.jsx)(zge,{path:e}):(0,Y.jsxs)(`div`,{children:[`Cannot preview: `,i]})}function J3({path:e}){return(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(hy,{size:12,className:`animate-spin`})},e+`-loading`)}function Y3({path:e}){return(0,Y.jsx)(`div`,{id:e,className:`text-fg-quaternary`,children:`<empty>`},e+`-null`)}function X3({path:e,className:t,size:n}){let r=fk(e);return r?(0,Y.jsx)(ode,{title:r.title,image:r.image,subtitle:r.subtitle??null,className:t,size:n}):(0,Y.jsx)(`div`,{className:X(`p-2`,t),children:(0,Y.jsx)(q3,{path:e,size:n})})}function Z3({source:e,disabled:t,onMove:n,renderItem:r,className:i}){let[a,o]=(0,b.useState)([]);(0,b.useEffect)(()=>{let t=[],n=1;for(let r of e)t.push({path:r,id:n}),n++;o(t)},[e]);let s=bw(yw(nT),yw(iT),yw(Xw,{coordinateGetter:AT})),[c,l]=(0,b.useState)(null),u=c===null?void 0:a.find(e=>e.id===c),d=(0,b.useCallback)(e=>{let{active:t,over:r}=e;if(t?.id!==r?.id){let e=a.findIndex(e=>e.id===Number(t?.id)),i=a.findIndex(e=>e.id===Number(r?.id));o(t=>TT(t,e,i)),n(e,i)}l(null)},[a,n]);return(0,Y.jsxs)(bue,{sensors:s,collisionDetection:Dw,onDragStart:e=>l(Number(e.active.id)),onDragEnd:d,onDragCancel:()=>l(null),children:[(0,Y.jsx)(Yue,{items:a,strategy:Gue,disabled:t,children:(0,Y.jsx)(`div`,{className:i??`flex flex-col gap-y-4 w-full`,children:a.map(({path:e,id:t},n)=>(0,Y.jsx)(`div`,{style:{opacity:t===c?.3:void 0},children:r({path:e,id:t,index:n})},t))})}),(0,Y.jsx)(Bue,{dropAnimation:null,children:u?r({path:u.path,id:u.id,index:a.indexOf(u)}):null})]})}function TGe({source:e,disabled:t,onClick:n,onMove:r,onDelete:i,onDuplicate:a}){return(0,Y.jsx)(Z3,{source:e,disabled:t,onMove:r,renderItem:({path:e,id:r})=>(0,Y.jsx)(EGe,{id:r,disabled:t,path:e,onClick:n,onDelete:e=>{i(e-1)},onDuplicate:e=>{a(e-1)}})})}function EGe({id:e,path:t,disabled:n,onClick:r,onDelete:i,onDuplicate:a}){let o=eb(),s=(0,b.useRef)(null),[c,l]=(0,b.useState)(!1);(0,b.useEffect)(()=>{s.current&&(s.current.getBoundingClientRect().height>=170?l(!0):l(!1))},[e,t]);let{attributes:u,listeners:d,setNodeRef:f,transform:p,transition:m}=OT({id:e,disabled:n===!0}),h=Fb()||{},g={transform:mw.Transform.toString(p),transition:m},_=!(h[t]?.length>0);return(0,Y.jsxs)(`div`,{"touch-action":`manipulation`,ref:f,style:g,className:X(`relative flex disabled:opacity-55 flex-1`,{"items-start":!_,"items-center":_}),children:[(0,Y.jsx)(`button`,{...u,...d,className:X(`pb-1 pr-2 rounded-sm text-fg-secondary hover:text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,{"opacity-30":n,"mt-2.5":!_}),disabled:n,onClick:()=>{r(t)},children:(0,Y.jsx)(ay,{})}),(0,Y.jsxs)(`button`,{className:X(`flex-grow`,`relative flex text-left border rounded-lg border-border bg-card gap-y-2 bg-bg-primary`,`hover:bg-bg-secondary-hover`,`overflow-y-clip`),style:{maxHeight:170},ref:s,disabled:n,onClick:()=>{r(t)},children:[(0,Y.jsx)(X3,{path:t,className:`flex-grow w-full`}),c&&(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full bg-gradient-to-b via-50% from-transparent via-card/90 to-card`,style:{height:40}})]}),cX(t,h)&&(0,Y.jsx)(`div`,{className:X(`absolute right-3`,{"top-2":_,"top-0":!_}),children:(0,Y.jsx)(lX,{})}),(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(CD,{className:X(`flex hover:bg-bg-secondary-hover px-2 hover:rounded-lg`,{"items-start mt-4":!_,"items-center py-2":_}),children:(0,Y.jsx)(Yv,{size:16})}),(0,Y.jsxs)(wD,{className:`p-2`,container:o,side:`top`,children:[(0,Y.jsxs)(`button`,{className:X(`flex items-center gap-x-2`),onClick:()=>{i(e)},children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(Iy,{className:`w-4 h-4`})}),(0,Y.jsx)(`span`,{children:`Delete`})]}),(0,Y.jsxs)(`button`,{className:X(`flex items-center gap-x-2`),onClick:()=>{a(e)},children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(qv,{className:`w-4 h-4`})}),(0,Y.jsx)(`span`,{children:`Duplicate`})]})]})]})]})}var DGe=X(`[&_input]:h-7 [&_input]:m-0 [&_input]:w-full [&_input]:px-2 [&_input]:py-1 [&_input]:text-[13px]`,`[&_textarea]:min-h-0 [&_textarea]:m-0 [&_textarea]:px-2 [&_textarea]:py-1 [&_textarea]:text-[13px] [&_textarea]:leading-5 [&_textarea]:[field-sizing:content]`,`[&_[data-testid=auto-growing-textarea-ghost]]:m-0 [&_[data-testid=auto-growing-textarea-ghost]]:px-2 [&_[data-testid=auto-growing-textarea-ghost]]:py-1 [&_[data-testid=auto-growing-textarea-ghost]]:text-[13px] [&_[data-testid=auto-growing-textarea-ghost]]:leading-5`,`[&_.rich-text-editor:not(:focus-within)_.prose-editor]:p-2 [&_.rich-text-editor:not(:focus-within)_.prose-editor]:min-h-0`,`[&_.rich-text-editor:not(:focus-within)>.absolute]:hidden`,`[&_.prose-editor]:text-[13px]`);function Q3({path:e,readonly:t,depth:n=0}){let r=`array`,{navigate:i}=GC(),a=Ab(e),{source:o,schema:s,addPatch:c,patchPath:l}=yb(e,r,{watchUnsaved:!0}),[u,d]=(0,b.useState)([]),f=`data`in o&&o.data?o.data:null;(0,b.useEffect)(()=>{let e=[],t=1;for(let n of f??[])e.push({path:n,id:t}),t++;d(e)},[f]);let p=bw(yw(nT),yw(iT),yw(Xw,{coordinateGetter:AT})),[m,h]=(0,b.useState)(null),g=m===null?void 0:u.find(e=>e.id===m),_=(0,b.useCallback)((e,t)=>{c([{op:`move`,from:l.concat(e.toString()),path:l.concat(t.toString())}],r)},[c,l]),v=(0,b.useCallback)(e=>{let{active:t,over:n}=e;if(t?.id!==n?.id){let e=u.findIndex(e=>e.id===Number(t?.id)),r=u.findIndex(e=>e.id===Number(n?.id));d(t=>TT(t,e,r)),_(e,r)}h(null)},[u,_]);if(s.status===`error`||s.status===`not-found`||s.status===`loading`||f===null||s.data.type!==`array`)return null;let y=s.data,x=(e,o)=>(0,Y.jsx)(OGe,{id:e.id,index:o,path:e.path,itemSchema:y.item,depth:n,readonly:t,onNavigate:e=>i(e),onDelete:()=>{c([{op:`remove`,path:l.concat(o.toString())}],r)},onDuplicate:()=>{`data`in a&&a.data&&Array.isArray(a.data)&&c([{op:`add`,path:l.concat(o.toString()),value:a.data[o]??null}],r)}},e.id);return(0,Y.jsxs)(`div`,{id:e,className:X(`w-full`,{[DGe]:n===0}),children:[(0,Y.jsxs)(bue,{sensors:p,collisionDetection:Dw,onDragStart:e=>h(Number(e.active.id)),onDragEnd:v,onDragCancel:()=>h(null),children:[(0,Y.jsx)(Yue,{items:u,strategy:Gue,disabled:t,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:u.map((e,t)=>(0,Y.jsx)(`div`,{style:{opacity:e.id===m?.3:void 0},children:x(e,t)},e.id))})}),(0,Y.jsx)(Bue,{dropAnimation:null,children:g?x(g,u.indexOf(g)):null})]}),!t&&(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 h-6 mt-0.5 px-1 text-xs text-fg-tertiary hover:text-fg-primary`,onClick:()=>{c([{op:`add`,path:l.concat(u.length.toString()),value:Cp(y.item)}],r)},children:[(0,Y.jsx)(Oy,{size:12}),(0,Y.jsx)(`span`,{children:`Add`})]})]})}function OGe({id:e,index:t,path:n,itemSchema:r,depth:i,readonly:a,onNavigate:o,onDelete:s,onDuplicate:c}){let{attributes:l,listeners:u,setNodeRef:d,transform:f,transition:p}=OT({id:e,disabled:a===!0}),[m,h]=(0,b.useState)(!1),g=Pb(n),_={transform:mw.Transform.toString(f),transition:p},v=xr(r),y=v&&(r.type===`object`||r.type===`union`&&Zhe(r)),x=(0,Y.jsx)(`button`,{...l,...u,className:X(`cursor-grab text-fg-quaternary hover:text-fg-primary`,{"opacity-30":a}),disabled:a,children:(0,Y.jsx)(ay,{size:14})}),S=a?null:(0,Y.jsx)(MGe,{onDelete:s,onDuplicate:c});return(0,Y.jsxs)(`div`,{"touch-action":`manipulation`,"data-val-studio-path":n,ref:d,style:_,className:X(`border bg-bg-primary`,i===0?`rounded-md`:`rounded-r-md border-l-0`,{"border-border-primary":g.length===0,"border-bg-warning-secondary":g.length>0}),children:[y&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 h-7 px-1.5`,children:[x,(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 flex-1 min-w-0 text-left`,onClick:()=>h(e=>!e),children:[(0,Y.jsx)(Rv,{size:12,className:X(`shrink-0 text-fg-quaternary transition-transform`,{"rotate-90":!m})}),(0,Y.jsx)(`span`,{className:`w-4 shrink-0 text-[10px] text-fg-quaternary`,children:t+1}),(0,Y.jsx)(jGe,{path:n})]}),S]}),y&&!m&&(0,Y.jsx)(`div`,{className:`pr-1.5 pb-1.5 pt-0.5`,children:r.type===`union`?(0,Y.jsx)(kGe,{path:n,itemSchema:r,depth:i,readonly:a}):(0,Y.jsx)($3,{path:n,itemSchema:r,depth:i,readonly:a})}),v&&!y&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 px-1.5 py-1`,children:[(0,Y.jsx)(`div`,{className:`pt-2`,children:x}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(r6,{path:n,schema:r,readonly:a===!0||r.readonly===!0,compact:!0,errorDisplay:`none`})}),S]}),!v&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1.5 py-1`,children:[x,(0,Y.jsx)(`button`,{className:`flex-1 min-w-0 overflow-y-clip rounded text-left text-xs hover:bg-bg-secondary-hover`,style:{maxHeight:96},onClick:()=>o(n),children:(0,Y.jsx)(X3,{path:n,className:`w-full`})}),S]}),g.length>0&&(0,Y.jsx)(`div`,{className:`px-2.5 pb-1.5`,children:(0,Y.jsx)(Uk,{validationErrors:g})})]})}function kGe({path:e,itemSchema:t,depth:n,readonly:r}){return Zhe(t)?(0,Y.jsx)(AGe,{path:e,itemSchema:t,depth:n,readonly:r}):null}function AGe({path:e,itemSchema:t,depth:n,readonly:r}){let i=$he(e,t);return i.status===`loading`?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{className:`pl-2`,children:(0,Y.jsx)(ege,{state:i,readonly:r,className:`h-7 w-auto min-w-24 px-2 py-1 text-[13px]`})}),(0,Y.jsx)($3,{path:e,itemSchema:i.selectedSchema,depth:n,readonly:r,omitKeys:[t.key]})]})}function $3({path:e,itemSchema:t,depth:n,readonly:r,omitKeys:i}){let[a,o]=(0,b.useState)({});return t.type===`object`?(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:Object.entries(t.items).map(([t,s])=>{if(s.hidden||i?.includes(t))return null;let c=sD(e,t),l=r===!0||s.readonly===!0;if(s.type===`array`&&xr(s.item)){let e=a[t]===!0;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 pl-2 text-left`,onClick:()=>o(n=>({...n,[t]:!e})),children:[(0,Y.jsx)(Rv,{size:10,className:X(`shrink-0 text-fg-quaternary transition-transform`,{"rotate-90":!e})}),(0,Y.jsx)(e6,{label:t})]}),!e&&(0,Y.jsx)(Q3,{path:c,depth:n+1,readonly:l})]},t)}return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2`,children:[(0,Y.jsx)(e6,{label:t}),(0,Y.jsx)(r6,{path:c,schema:s,readonly:l,compact:!0,errorDisplay:`compact`})]},t)})}):null}function e6({label:e}){return(0,Y.jsx)(`span`,{className:`text-[11px] leading-4 text-fg-tertiary`,children:e})}function jGe({path:e}){let t=fk(e),n=Ab(e),r=(0,b.useMemo)(()=>t?.title?t.title:`data`in n&&n.data!==void 0?t6(n.data):null,[t,n]);return(0,Y.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-xs text-fg-tertiary`,children:r??``})}function t6(e){if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=t6(t);if(e!==null)return e}return null}if(typeof e==`object`&&e)for(let[t,n]of Object.entries(e)){if(t===`type`||t===`_type`||t===`tag`||n===void 0)continue;let e=t6(n);if(e!==null)return e}return null}function MGe({onDelete:e,onDuplicate:t}){let n=eb();return(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(CD,{className:`shrink-0 rounded px-0.5 py-1 text-fg-quaternary hover:text-fg-primary hover:bg-bg-secondary-hover`,children:(0,Y.jsx)(Yv,{size:14})}),(0,Y.jsxs)(wD,{className:`p-2 w-auto`,container:n,side:`top`,children:[(0,Y.jsxs)(`button`,{className:`flex items-center gap-x-2 text-sm`,onClick:e,children:[(0,Y.jsx)(Iy,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:`Delete`})]}),(0,Y.jsxs)(`button`,{className:`flex items-center gap-x-2 text-sm`,onClick:t,children:[(0,Y.jsx)(qv,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:`Duplicate`})]})]})]})}function NGe({id:e,disabled:t,children:n}){let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s}=OT({id:e,disabled:t===!0}),c={transform:mw.Transform.toString(o),transition:s};return(0,Y.jsxs)(`div`,{ref:a,style:c,className:`flex items-start gap-2`,children:[(0,Y.jsx)(`button`,{...r,...i,className:X(`pt-4 pr-1`,{invisible:t}),disabled:t,children:(0,Y.jsx)(ay,{size:16})}),(0,Y.jsx)(`div`,{className:`flex-1`,children:n})]})}function PGe({path:e,readonly:t,compact:n,inline:r,errorDisplay:i=`default`}){let a=`array`,{navigate:o}=GC(),s=xb(e),c=Ab(e),{source:l,schema:u,addPatch:d,patchPath:f,hasUnsavedOwnEdit:p}=yb(e,a,{watchUnsaved:!0});if(u.status===`error`)return(0,Y.jsx)(NC,{path:e,error:u.error,type:a});if(l.status===`error`)return(0,Y.jsx)(FC,{path:e,error:l.error,schema:u});if(l.status==`not-found`||u.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:a});if(u.status===`loading`)return(0,Y.jsx)(jC,{path:e,type:a});if(u.data.type!==`array`)return(0,Y.jsx)(PC,{path:e,expectedType:`array`,actualType:u.data.type});let m=u.data,h=(s&&`data`in s?s.data:void 0)!==void 0&&(p||l.status===`loading`);if(xr(m.item))return(0,Y.jsxs)(`div`,{className:`relative w-full`,children:[s?.status===`error`&&(0,Y.jsx)(uX,{error:s.message,path:e}),(0,Y.jsx)(Q3,{path:e,readonly:t})]});if(r){let a=l.data;return a===null?null:(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(Z3,{source:a,disabled:t,onMove:(e,t)=>{d([{op:`move`,from:f.concat(e.toString()),path:f.concat(t.toString())}],m.type)},className:`flex flex-col ${n?`gap-3`:`gap-4`}`,renderItem:({path:e,id:a})=>m.item.hidden?null:(0,Y.jsx)(NGe,{id:a,disabled:t,children:(0,Y.jsx)(qk,{path:e,type:m.item.type,readonly:t||m.item.readonly,compact:n,errorDisplay:i,children:(0,Y.jsx)(r6,{path:e,schema:m.item,readonly:t||m.item.readonly,compact:n,inline:r,errorDisplay:i})})})})})}return(0,Y.jsxs)(`div`,{id:e,className:`relative w-full`,children:[s?.status===`error`&&(0,Y.jsx)(uX,{error:s.message,path:e}),h&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-[40] flex items-center text-fg-secondary`,children:(0,Y.jsx)(hy,{className:`animate-spin h-4 w-4`})}),(0,Y.jsx)(TGe,{path:e,disabled:t,onClick:e=>{o(e)},onDelete:async e=>{d([{op:`remove`,path:f.concat(e.toString())}],m.type)},onDuplicate:async e=>{`data`in c&&c.data&&Array.isArray(c.data)&&d([{op:`add`,path:f.concat(e.toString()),value:c.data?.[e]??null}],m.type)},onMove:async(e,t)=>{d([{op:`move`,from:f.concat(e.toString()),path:f.concat(t.toString())}],m.type)},source:l.data||[]})]})}function FGe({path:e}){let t=Ob(e,`array`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(`div`,{children:`${t.data.length} items`})}function IGe({path:e}){let t=Pb(e)??[];return(0,Y.jsx)(Uk,{validationErrors:t})}var n6=(0,b.createContext)(!1);function LGe({held:e,children:t}){return(0,Y.jsx)(n6.Provider,{value:e,children:t})}function RGe(){return(0,b.useContext)(n6)}function r6({path:e,schema:t,autoFocus:n,readonly:r,compact:i,inline:a,hideUpload:o,errorDisplay:s=`default`}){let c=RGe();if(t.hidden)return null;let l=r||t.readonly||c,u={readonly:l,compact:i},d;if(t.type===`string`)d=(0,Y.jsx)(lde,{path:e,autoFocus:n,...u},e);else if(t.type===`number`)d=(0,Y.jsx)(wde,{path:e,...u},e);else if(t.type===`boolean`)d=(0,Y.jsx)(xde,{path:e,...u},e);else if(t.type===`image`)d=(0,Y.jsx)(Vge,{path:e,...u,hideUpload:o},e);else if(t.type===`object`)return(0,Y.jsx)(qhe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`array`)return(0,Y.jsx)(PGe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`record`)return(0,Y.jsx)(ARe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`union`)return(0,Y.jsx)(Qhe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else d=t.type===`keyOf`?(0,Y.jsx)(Gge,{path:e,...u},e):t.type===`route`?(0,Y.jsx)(v_e,{path:e,...u},e):t.type===`richtext`?(0,Y.jsx)(SGe,{path:e,autoFocus:n,...u},e):t.type===`date`?(0,Y.jsx)(Kye,{path:e,...u},e):t.type===`dateTime`?(0,Y.jsx)(tbe,{path:e,...u},e):t.type===`color`?(0,Y.jsx)(tRe,{path:e,...u},e):t.type===`code`?(0,Y.jsx)(QLe,{path:e,...u},e):t.type===`file`?(0,Y.jsx)(Rge,{path:e,...u},e):t.type===`literal`?(0,Y.jsx)(NC,{path:e,error:`Literal fields are not editable`}):(0,Y.jsx)(NC,{path:e,error:`Unexpected field schema: `+JSON.stringify(t)});return s===`compact`?(0,Y.jsxs)(`div`,{className:`flex items-stretch gap-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:d}),(0,Y.jsx)(`div`,{className:`flex items-center px-1`,children:(0,Y.jsx)(Fhe,{path:e})})]}):(0,Y.jsxs)(Y.Fragment,{children:[d,s==="default"&&(0,Y.jsx)(zGe,{path:e})]})}function zGe({path:e}){return Rhe()?null:(0,Y.jsx)(IGe,{path:e})}var BGe=8,VGe=1200;function HGe({paths:e,selectedPath:t,onSelect:n}){let[r,i]=(0,b.useState)(``),a=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=a.current;if(!t||!e)return;let n=()=>{let n=e.querySelector(`[data-canvas-field="${CSS.escape(t)}"]`);if(!(n instanceof HTMLElement))return;let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();i.top>=r.top&&i.bottom<=r.bottom||(e.scrollTop+=i.top-r.top-BGe)};n();let r=new ResizeObserver(n);r.observe(e);for(let t of Array.from(e.children))r.observe(t);let i=setTimeout(()=>r.disconnect(),VGe);return()=>{clearTimeout(i),r.disconnect()}},[t,e]);let o=(0,b.useMemo)(()=>{let t=new Map;for(let n of e){let[e]=H.splitModuleFilePathAndModulePath(n),r=t.get(e);r?r.push(n):t.set(e,[n])}return Array.from(t.entries()).map(([e,t])=>({moduleFilePath:e,label:kC(e.split(`/`).pop()??e),entries:t}))},[e]),s=(0,b.useMemo)(()=>{let e=r.trim().toLowerCase();return e?o.map(t=>({...t,entries:t.entries.filter(t=>t.toLowerCase().includes(e))})).filter(e=>e.entries.length>0):o},[o,r]);return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-xl border border-border-float bg-bg-float`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-border-float px-3 py-2.5`,children:[(0,Y.jsxs)(`h2`,{className:`text-[0.8125rem] font-medium text-fg-primary`,children:[`On this page`,(0,Y.jsx)(`span`,{className:`ml-1.5 font-normal text-fg-secondary-alt`,children:e.length})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-[0.6875rem] leading-relaxed text-fg-secondary-alt`,children:`Edit here, or click an element on the page.`})]}),(0,Y.jsx)(`div`,{className:`shrink-0 border-b border-border-float px-2 py-2`,children:(0,Y.jsxs)(`div`,{className:`flex h-7 items-center gap-1.5 rounded-md bg-bg-float-raised px-2 focus-within:ring-2 focus-within:ring-border-focus`,children:[(0,Y.jsx)(My,{size:12,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Filter fields…`,"aria-label":`Filter fields`,className:`min-w-0 flex-1 bg-transparent text-xs text-fg-primary placeholder:text-fg-secondary-alt focus:outline-none`})]})}),(0,Y.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto scrollbar-slim px-2 py-2`,children:s.length===0?(0,Y.jsx)(`p`,{className:`px-1 py-6 text-center text-xs text-fg-secondary-alt`,children:r?`No fields match this filter.`:`The page reported no editable content.`}):s.map(e=>(0,Y.jsxs)(`section`,{className:`mb-3`,children:[(0,Y.jsx)(`h3`,{title:e.moduleFilePath,className:`truncate px-1 pb-1.5 text-[0.625rem] font-medium uppercase tracking-wide text-fg-secondary-alt`,children:e.label}),(0,Y.jsx)(`div`,{className:`space-y-2`,children:e.entries.map(e=>(0,Y.jsx)(UGe,{path:e,selected:t===e,onSelect:n},e))})]},e.moduleFilePath))})]})}function UGe({path:e,selected:t,onSelect:n}){let r=Cb(e);return(0,Y.jsxs)(`div`,{"data-canvas-field":e,onFocusCapture:()=>n?.(e),className:X(`rounded-lg border px-2.5 py-2`,t?`border-border-brand-primary bg-bg-float-raised`:`border-border-float`),children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n?.(e),title:e,className:`mb-1.5 block max-w-full truncate text-left text-[0.8125rem] font-medium text-fg-primary`,children:WGe(e)}),r.status===`error`?(0,Y.jsx)(NC,{path:e,error:r.error,type:`module`}):r.status===`loading`?(0,Y.jsx)(jC,{path:e,type:`module`}):r.status===`not-found`?(0,Y.jsx)(MC,{path:e,type:`module`}):(0,Y.jsx)(r6,{path:e,schema:r.data,compact:!0})]})}function WGe(e){let[,t]=H.splitModuleFilePathAndModulePath(e);if(!t)return e;let n=H.splitModulePath(t),r=n.length>1&&n[0].startsWith(`/`)?n.slice(1):n;return r.length===0?n.join(` › `):r.join(` › `)}function i6(e,t,n){(0,b.useEffect)(()=>{if(!t)return;let r=t=>{let r=e.current;r&&t.composedPath().includes(r)||n()};return document.addEventListener(`pointerdown`,r),()=>document.removeEventListener(`pointerdown`,r)},[t,n,e])}var a6=12;function GGe({value:e,routes:t,onChange:n,className:r}){let[i,a]=(0,b.useState)(e),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(0),u=(0,b.useRef)(null);(0,b.useEffect)(()=>{o||a(e)},[e,o]);let d=(0,b.useMemo)(()=>{let e=i.trim().toLowerCase();if(!e)return t.slice(0,a6);let n=t=>{let n=t.toLowerCase();return n===e?0:n.startsWith(e)?1:2};return t.filter(t=>t.toLowerCase().includes(e)).map((e,t)=>({route:e,index:t,rank:n(e)})).sort((e,t)=>e.rank-t.rank||e.index-t.index).slice(0,a6).map(e=>e.route)},[t,i]),f=(0,b.useMemo)(()=>{let e=i.trim().toLowerCase(),n=e?t.filter(t=>t.toLowerCase().includes(e)).length:t.length;return Math.max(0,n-d.length)},[t,i,d.length]);(0,b.useEffect)(()=>l(0),[i]),i6(u,o,(0,b.useCallback)(()=>{s(!1),a(e)},[e]));let p=t=>{let r=KGe(t);s(!1),a(r),r!==e&&n(r)};return(0,Y.jsxs)(`div`,{ref:u,className:X(`relative`,r),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 h-8 pl-2 pr-1 rounded-md border border-border-float bg-bg-float`,children:[(0,Y.jsx)(uy,{size:13,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),s(!0)},onFocus:()=>s(!0),onKeyDown:t=>{if(t.key===`Escape`){t.preventDefault(),s(!1),a(e),t.currentTarget.blur();return}if(t.key===`Enter`){t.preventDefault();let e=o?d[c]:void 0;p(e??i),t.currentTarget.blur();return}(t.key===`ArrowDown`||t.key===`ArrowUp`)&&d.length>0&&(t.preventDefault(),s(!0),l(e=>((t.key===`ArrowDown`?e+1:e-1)+d.length)%d.length))},spellCheck:!1,"aria-label":`Canvas route`,placeholder:`/`,className:`min-w-0 flex-1 bg-transparent font-mono text-[0.6875rem] text-fg-primary placeholder:text-fg-secondary-alt focus:outline-none`}),i!==e&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Discard the typed route`,onClick:()=>{a(e),s(!1)},className:`grid h-6 w-6 shrink-0 place-items-center rounded text-fg-secondary-alt hover:text-fg-primary`,children:(0,Y.jsx)(Hy,{size:12})})]}),o&&d.length>0&&(0,Y.jsxs)(`ul`,{role:`listbox`,"aria-label":`Tracked routes`,className:`absolute left-0 right-0 top-full z-window mt-1 max-h-56 overflow-y-auto rounded-md border border-border-float bg-bg-float py-1 shadow-lg scrollbar-slim`,children:[d.map((e,t)=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":t===c,onMouseMove:()=>l(t),onMouseDown:t=>{t.preventDefault(),p(e)},className:X(`block w-full truncate px-2.5 py-1 text-left font-mono text-[0.6875rem]`,t===c?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary`),children:e})},`${t}-${e}`)),f>0&&(0,Y.jsxs)(`li`,{"aria-hidden":!0,className:`px-2.5 py-1 text-[0.625rem] text-fg-secondary-alt`,children:[f,` more — keep typing to narrow`]})]})]})}function KGe(e){let t=e.trim();if(t===``)return`/`;if(/^[a-z][a-z0-9+.-]*:\/\//i.test(t))try{let e=new URL(t);return`${e.pathname}${e.search}${e.hash}`||`/`}catch{}return t.startsWith(`/`)?t:`/${t}`}var qGe={desktop:1280,tablet:834,mobile:390},JGe={desktop:800,tablet:1112,mobile:844},YGe=`clamp(340px, 34%, 520px)`,o6=320,XGe=280,ZGe=.72,QGe=24,$Ge=`4.5rem`,eKe=`8.25rem`,s6=`2.125rem`,tKe=320,c6=200,l6=`cubic-bezier(0.4, 0, 0.2, 1)`;function nKe({children:e,breakpoint:t,page:n,renderCanvas:r,canvasPaths:i,onSelectCanvasPath:a,selectedCanvasPath:o,canvasRoute:s,onCanvasRouteChange:c,canvasRoutes:l,initialTransform:u,onTransformChange:d,isCanvasOpen:f,onCloseCanvas:p,view:m,onViewChange:h,pane:g,onPaneChange:_,isDevMode:v,onAttachToChat:y,skipTransition:x}){let S=t===`mobile`,C=CC(),w=f&&(n!==void 0||r!==void 0),T=e=>C||x?void 0:e.map(e=>`${e} ${tKe}ms ${l6}`).join(`, `),[E,D]=(0,b.useState)(S?`mobile`:`desktop`),[O,k]=(0,b.useState)(()=>u?.scale??1),A=(0,b.useRef)(O);A.current=O;let j=(0,b.useRef)({x:u?.x??0,y:u?.y??0});(0,b.useEffect)(()=>{d?.({scale:O,...j.current})},[O,d]);let M=(0,b.useCallback)(e=>{j.current=e,d?.({scale:A.current,...e})},[d]),[N,P]=(0,b.useState)(null),[F,I]=(0,b.useState)([]);(0,b.useEffect)(()=>{w||(P(null),I(e=>e.length===0?e:[]))},[w]);let L=(0,b.useRef)(null),R=(0,b.useRef)(null),[ee,te]=(0,b.useState)(null),[ne,re]=(0,b.useState)(0),[ie,ae]=(0,b.useState)(!1),[oe,se]=(0,b.useState)(0);(0,b.useEffect)(()=>{let e=R.current;if(!e)return;let t=new ResizeObserver(()=>se(e.clientWidth));return t.observe(e),se(e.clientWidth),()=>t.disconnect()},[]);let ce=(0,b.useMemo)(()=>{if(oe===0)return{min:o6,max:o6};let e=Math.max(o6,Math.min(oe*ZGe,oe-XGe));return{min:Math.min(o6,e),max:e}},[oe]),le=(0,b.useCallback)(e=>Math.round(Math.min(ce.max,Math.max(ce.min,e))),[ce]);(0,b.useEffect)(()=>{if(ee===null)return;let e=le(ee);e!==ee&&te(e)},[ee,le]);let ue=(0,b.useCallback)(e=>{if(e.button!==0)return;let t=R.current;if(!t)return;e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),ae(!0);let n=t.getBoundingClientRect().left,r=e=>{te(le(e.clientX-n))},i=()=>{ae(!1),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),window.removeEventListener(`pointercancel`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i),window.addEventListener(`pointercancel`,i)},[le]),de=(0,b.useCallback)(e=>{let t=R.current,n=ee??t?.firstElementChild?.clientWidth??o6;te(le(n+e))},[ee,le]),fe=qGe[E],[pe,me]=(0,b.useState)(u==null),he=(0,b.useRef)({device:E,open:w});(0,b.useEffect)(()=>{(he.current.device!==E||he.current.open!==w)&&(he.current={device:E,open:w},me(!0))},[E,w]);let ge=(0,b.useCallback)(()=>{re(e=>e+1),me(!0)},[]),_e=(0,b.useCallback)(()=>me(!1),[]),ve=(0,b.useCallback)((e,t)=>{L.current?.zoomBy(e,t)},[]),ye=(0,b.useCallback)(e=>{L.current?.pinch(e)},[]),be=(0,b.useCallback)(e=>{I(t=>t.includes(e)?t:[...t,e]);let t=n?.fields[e];t&&y?.(t.sourcePath)},[n,y]),[xe,Se]=Qce(m),Ce=(0,b.useCallback)(()=>{xe&&(h(`fields`),S&&_(`editor`))},[xe,h,S,_]),[we,z]=(0,b.useState)(!1),B=t===`desktop`&&w?{paddingLeft:`5.5rem`}:void 0,Te=i??[],Ee=n?Object.keys(n.fields).length:Te.length,V=(0,Y.jsx)(oKe,{view:m,onChange:h,fieldCount:Ee>0?Ee:void 0,animate:!C}),De=g===`canvas`?`preview`:m===`fields`?`fields`:`normal`,Oe=(0,b.useCallback)(e=>{if(e===`preview`){_(`canvas`);return}_(`editor`),h(e)},[_,h]),ke=w&&!S,Ae=!ke&&!(w&&S),je=(0,Y.jsx)(`div`,{id:`val-content-area`,"data-scroll-clearance":ke?16:96,className:`h-full overflow-y-auto scrollbar-slim`,children:(0,Y.jsx)(`div`,{style:{maxWidth:qce,...B},className:X(`w-full mx-auto px-4 md:px-6 pb-24`,Ae?`pt-20 desktop:pt-24`:`pt-1`),children:e})}),Me=(0,Y.jsx)(`div`,{style:B,className:`h-full px-4 md:px-6 pt-1 pb-14`,children:n?(0,Y.jsx)(ole,{page:n,selectedFieldId:N,onSelectField:P,onChangeField:()=>void 0,onAttachField:be,attachedFieldIds:F,isDevMode:v}):Te.length>0?(0,Y.jsx)(HGe,{paths:Te,selectedPath:o,onSelect:a}):(0,Y.jsx)(rKe,{onGoToPreview:S?()=>_(`canvas`):void 0})}),Ne=(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[ke&&(0,Y.jsx)(`div`,{style:B,className:`shrink-0 px-4 md:px-6 pt-20 pb-2.5`,children:V}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1`,children:m===`fields`&&w?Me:je})]}),Pe=s!==void 0&&c&&(0,Y.jsx)(GGe,{value:s,routes:l??[],onChange:c,className:`min-w-0 flex-1 md:max-w-[28rem]`}),Fe=w&&(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-2`,children:[(Pe||!S)&&(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[Pe,!S&&(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Exit Preview`,onClick:p,className:X(`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md pl-2.5 pr-3`,`border border-border-float bg-bg-float text-fg-secondary`,`hover:text-fg-primary`),children:[(0,Y.jsx)(Hy,{size:15}),(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:`Exit Preview`})]})]}),(0,Y.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border-float bg-bg-float-raised`,children:(0,Y.jsx)(nle,{ref:L,pageWidth:fe,scale:O,onScaleChange:k,autoFit:pe,onUserZoom:_e,initialScroll:u&&{x:u.x,y:u.y},onScrollChange:M,className:`h-full`,children:(0,Y.jsx)(`div`,{className:`shadow-2xl`,onClick:()=>P(null),children:r?.({device:E,width:fe,height:JGe[E],reloadKey:ne,isPicking:xe,onRequestReload:ge,onRefreshingChange:z,onPinch:ye,onZoom:(e,t)=>ve(e,t),onPicked:Ce})??(n&&(0,Y.jsx)($ce,{page:n,device:E,selectedFieldId:xe?N:null,attachedFieldIds:xe?F:[],onSelectField:e=>{xe&&(P(e),Ce())},isSelectMode:xe}))})})}),(0,Y.jsx)(`div`,{className:`flex shrink-0 justify-center`,children:(0,Y.jsx)(ele,{className:`max-w-full`,device:E,onDeviceChange:D,scale:O,onZoomIn:()=>ve(1.2,null),onZoomOut:()=>ve(1/1.2,null),onFit:()=>me(!0),isPicking:xe,onPickingChange:Ee>0?Se:void 0,isRefreshing:we,onReload:r&&ge})})]});return S?(0,Y.jsxs)(`div`,{className:`absolute inset-0 bg-bg-canvas`,children:[(0,Y.jsx)(`div`,{className:`h-full overflow-clip`,style:w?{paddingTop:eKe}:void 0,children:(0,Y.jsxs)(`div`,{className:`flex h-full w-full`,style:{transform:`translateX(${w&&g===`canvas`?`-100%`:`0%`})`,transition:T([`transform`])},children:[(0,Y.jsx)(`div`,{className:`h-full w-full shrink-0`,children:Ne}),w&&(0,Y.jsx)(`div`,{className:`h-full w-full shrink-0 p-3 pb-14`,children:Fe})]})}),w&&(0,Y.jsxs)(`div`,{className:`absolute inset-x-3 z-window flex items-center gap-2`,style:{top:$Ge},children:[(0,Y.jsx)(aKe,{mode:De,onChange:Oe,fieldCount:Ee>0?Ee:void 0,animate:!C}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Exit Preview`,onClick:p,style:{height:s6,width:s6},className:X(`ml-auto grid shrink-0 place-items-center rounded-md`,`border border-border-float bg-bg-float text-fg-secondary`),children:(0,Y.jsx)(Hy,{size:15})})]})]}):(0,Y.jsxs)(`div`,{ref:R,className:`absolute inset-0 flex overflow-hidden bg-bg-canvas`,children:[(0,Y.jsx)(`div`,{style:{width:w?ee===null?YGe:`${ee}px`:`100%`,transition:ie?void 0:T([`width`])},className:`relative h-full min-w-0 shrink-0`,children:Ne}),w&&(0,Y.jsx)(iKe,{isDragging:ie,onPointerDown:ue,onNudge:de}),(0,Y.jsx)(`div`,{style:{transition:T([`opacity`,`transform`])},className:X(`min-w-0 flex-1 pt-20 pb-14 pr-3`,w?`scale-100 opacity-100`:`invisible pointer-events-none scale-95 opacity-0`),children:Fe})]})}function rKe({onGoToPreview:e}){return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 rounded-xl border border-border-float bg-bg-float px-6 text-center`,children:[(0,Y.jsx)(py,{size:20,className:`text-fg-secondary-alt`}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`h2`,{className:`text-[0.8125rem] font-medium text-fg-primary`,children:`Nothing reported yet`}),(0,Y.jsx)(`p`,{className:`text-[0.6875rem] leading-relaxed text-fg-secondary-alt`,children:`Usually that means preview mode is off: without it the page mounts none of Val's client code and tags nothing, and the Preview has the button that turns it on. A page that is already in preview mode and simply has no Val content on it looks the same from here.`})]}),e&&(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:X(`inline-flex h-8 items-center gap-1.5 rounded-md px-3`,`border border-border-float bg-bg-float-raised text-xs font-medium`,`text-fg-secondary hover:text-fg-primary`),children:[(0,Y.jsx)(Qv,{size:13}),`Go to Preview`]})]})}function iKe({isDragging:e,onPointerDown:t,onNudge:n}){return(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the editor and canvas`,tabIndex:0,onPointerDown:t,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),n(-24)):e.key===`ArrowRight`&&(e.preventDefault(),n(QGe))},className:X(`group relative z-hover w-3 shrink-0 cursor-col-resize self-stretch`,`focus-visible:outline-none`),children:(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`pointer-events-none absolute inset-y-14 left-1/2 w-px -translate-x-1/2 rounded-full`,`transition-colors`,e?`bg-fg-brand-primary`:`bg-border-float group-hover:bg-fg-secondary group-focus-visible:bg-fg-brand-primary`)})})}function u6({label:e,value:t,onChange:n,options:r,animate:i,compact:a}){let o=Math.max(0,r.findIndex(e=>e.value===t)),s=(0,b.useRef)(null),[c,l]=(0,b.useState)(null);return(0,b.useLayoutEffect)(()=>{let e=s.current;if(e===null)return;let t=()=>{let t=e.querySelectorAll(`button`)[o];if(t===void 0)return;let n=t.getBoundingClientRect().left-e.getBoundingClientRect().left-e.clientLeft,r=t.getBoundingClientRect().width;l(e=>e!==null&&e.left===n&&e.width===r?e:{left:n,width:r})};t();let n=new ResizeObserver(t);return n.observe(e),e.querySelectorAll(`button`).forEach(e=>n.observe(e)),()=>n.disconnect()},[o,r.length]),(0,Y.jsxs)(`div`,{ref:s,role:`tablist`,"aria-label":e,className:`relative inline-flex rounded-md border border-border-float bg-bg-float p-0.5`,children:[c!==null&&(0,Y.jsx)(`span`,{"aria-hidden":!0,style:{width:c.width,transform:`translateX(${c.left}px)`,transition:i?`transform ${c6}ms ${l6}, width ${c6}ms ${l6}`:void 0},className:`absolute inset-y-0.5 left-0 rounded bg-bg-float-raised shadow-sm`}),r.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:X(`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded text-[0.6875rem] transition-colors`,a?`px-2.5`:`px-4`,t===e.value?`font-medium text-fg-primary`:`text-fg-secondary hover:text-fg-primary`),children:[(0,Y.jsx)(e.icon,{size:12}),e.label,e.badge!==void 0&&(0,Y.jsx)(`span`,{className:`tabular-nums text-fg-secondary-alt`,children:e.badge})]},e.value))]})}function aKe({mode:e,onChange:t,fieldCount:n,animate:r}){return(0,Y.jsx)(u6,{label:`Workspace view`,value:e,onChange:t,animate:r,options:[{value:`normal`,label:`Normal`,icon:Py},{value:`fields`,label:`Fields`,icon:py,badge:n},{value:`preview`,label:`Preview`,icon:Qv}],compact:!0})}function oKe({view:e,onChange:t,fieldCount:n,animate:r}){return(0,Y.jsx)(u6,{label:`Preview view`,value:e,onChange:t,animate:r,options:[{value:`normal`,label:`Normal`,icon:Py},{value:`fields`,label:`Fields`,icon:py,badge:n}]})}function sKe({selectionKind:e,editedPath:t,canvasModules:n}){if(e===`page`)return!0;if(t===null)return!1;let[r]=H.splitModuleFilePathAndModulePath(t);return n.has(r)?!0:n.size===0&&e===null}function cKe(e){let t=new Set;for(let n of e??[])t.add(H.splitModuleFilePathAndModulePath(n)[0]);return Array.from(t).sort().join(`
|
|
216
216
|
`)}function lKe(e){return new Set(e===``?[]:e.split(`
|
|
217
217
|
`))}var uKe={page:$v,external:Zv,media:sy,data:Nv,content:Lae,recent:Ay},dKe={page:`Pages`,external:`External pages`,media:`Media`,data:`Data`,content:`In content`,recent:`Recently changed`},fKe=[`page`,`data`,`media`,`external`];function pKe(e){let t=[],n=e=>{for(let r of e)t.push({id:r.id,kind:`page`,label:r.name,detail:r.urlPath}),n(r.children??[])};n(e.pages);for(let n of e.data)t.push({id:n.id,kind:`data`,label:n.name,detail:n.moduleFilePath});for(let n of e.media)t.push({id:n.id,kind:`media`,label:n.name,detail:n.directory});for(let n of e.externalPages)t.push({id:n.id,kind:`external`,label:n.name,detail:n.url});return t}function mKe({results:e,contentResults:t,recentResults:n,isSearchingContent:r,onQueryChange:i,onSelect:a,onClose:o}){let[s,c]=(0,b.useState)(``);(0,b.useEffect)(()=>{i?.(s)},[s,i]);let[l,u]=(0,b.useState)(0),d=(0,b.useRef)(null),f=(0,b.useMemo)(()=>{let r=s.trim().toLowerCase(),i=r?e.filter(e=>e.label.toLowerCase().includes(r)||e.detail.toLowerCase().includes(r)):e,a=fKe.flatMap(e=>i.filter(t=>t.kind===e)),o=new Set(a.map(e=>e.id)),c=(r?t??[]:[]).filter(e=>!o.has(e.id));return[...r?[]:n??[],...a,...c].slice(0,40)},[e,t,n,s]);(0,b.useEffect)(()=>u(0),[s]),(0,b.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),o();return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),u(t=>f.length===0?0:((e.key===`ArrowDown`?t+1:t-1)+f.length)%f.length);return}if(e.key===`Enter`){e.preventDefault();let t=f[l];t&&a(t)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f,l,a,o]),(0,b.useEffect)(()=>{d.current?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})},[l]);let p=null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{onClick:o,"aria-hidden":!0,className:`absolute inset-0 z-overlay bg-black/50`}),(0,Y.jsxs)(`div`,{role:`dialog`,"aria-label":`Search`,className:`absolute z-overlay left-1/2 -translate-x-1/2 top-[12svh] w-[min(34rem,calc(100vw-1.5rem))] max-h-[70svh] flex flex-col rounded-xl bg-bg-float border border-border-float shadow-xl overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 h-11 px-3 border-b border-border-float shrink-0`,children:[(0,Y.jsx)(My,{size:15,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:s,onChange:e=>c(e.target.value),placeholder:`Search pages, media and data…`,"aria-label":`Search the project`,className:`flex-1 min-w-0 rounded-sm bg-transparent text-sm placeholder:text-fg-secondary-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`}),(0,Y.jsx)(`kbd`,{className:`shrink-0 px-1.5 py-0.5 rounded border border-border-float text-[0.625rem] text-fg-secondary-alt font-sans`,children:`esc`})]}),(0,Y.jsxs)(`div`,{ref:d,className:`flex-1 min-h-0 overflow-y-auto py-1.5 scrollbar-slim`,children:[f.length===0?(0,Y.jsx)(`p`,{className:`px-4 py-6 text-xs text-fg-secondary-alt`,children:r?`Searching…`:`Nothing matches “${s}”.`}):f.map((e,t)=>{let n=uKe[e.kind],r=e.kind!==p;return p=e.kind,(0,Y.jsxs)(`div`,{children:[r&&(0,Y.jsx)(`div`,{className:`px-4 pt-2.5 pb-1 text-[0.6875rem] font-semibold uppercase tracking-wider text-fg-secondary-alt`,children:dKe[e.kind]}),(0,Y.jsxs)(`button`,{type:`button`,"data-active":t===l,onMouseMove:()=>u(t),onClick:()=>a(e),className:X(`flex items-center gap-2.5 w-full px-3 py-1.5 mx-1.5 rounded-md text-left`,`w-[calc(100%-0.75rem)]`,t===l?`bg-bg-float-raised`:`hover:bg-bg-float-raised`),children:[(0,Y.jsx)(n,{size:14,className:X(`shrink-0`,t===l?`text-fg-primary`:`text-fg-secondary-alt`)}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary truncate`,children:e.label}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt truncate`,children:e.detail})]})]})]},`${e.kind}-${e.id}`)}),r&&f.length>0&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 px-4 py-2 text-[0.6875rem] text-fg-secondary-alt`,children:[(0,Y.jsx)(hy,{size:11,className:`animate-spin`}),`Still searching content…`]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 h-8 px-3 shrink-0 border-t border-border-float text-[0.625rem] text-fg-secondary-alt`,children:[(0,Y.jsx)(`span`,{children:`↑↓ to navigate`}),(0,Y.jsx)(`span`,{children:`↵ to open`})]})]})]})}function hKe(e){(0,b.useEffect)(()=>{let t=t=>{if(t.key!==`k`||!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return;let n=t.target;n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable)||(t.preventDefault(),e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function d6({className:e,blinking:t}){let n=CC(),r=t&&!n;return(0,Y.jsxs)(`svg`,{viewBox:`0 0 105 149`,fill:`none`,role:`img`,"aria-label":`Val`,className:X(`w-full h-full`,e),children:[(0,Y.jsxs)(`defs`,{children:[(0,Y.jsxs)(`mask`,{id:`val-mark-hole`,children:[(0,Y.jsx)(`rect`,{x:`0`,y:`0`,width:`105`,height:`149`,fill:`white`}),(0,Y.jsx)(`circle`,{cx:`49.9`,cy:`104.2`,r:`9.61`,fill:`black`,children:r&&(0,Y.jsx)(`animate`,{attributeName:`fill`,values:`black;black;white;white`,dur:`1.06s`,calcMode:`discrete`,repeatCount:`indefinite`})})]}),(0,Y.jsxs)(`filter`,{id:`val-mark-glow`,x:`0`,y:`0`,width:`105`,height:`149`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:[(0,Y.jsx)(`feColorMatrix`,{in:`SourceAlpha`,type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0`,result:`hardAlpha`}),(0,Y.jsx)(`feGaussianBlur`,{stdDeviation:`10.72`}),(0,Y.jsx)(`feComposite`,{in2:`hardAlpha`,operator:`out`}),(0,Y.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 0.219608 0 0 0 0 0.803922 0 0 0 0 0.501961 0 0 0 0.3 0`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in2:`SourceGraphic`})]}),(0,Y.jsx)(`filter`,{id:`val-mark-hole-shadow`,x:`35`,y:`90`,width:`30`,height:`30`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:(0,Y.jsx)(`feGaussianBlur`,{stdDeviation:`2.4`})})]}),(0,Y.jsx)(`g`,{filter:`url(#val-mark-glow)`,children:(0,Y.jsx)(`path`,{d:`M21.4768 23.3474C21.4768 22.4628 22.1939 21.7457 23.0785 21.7457H77.1357C78.0203 21.7457 78.7374 22.4628 78.7374 23.3474V125.055C78.7374 125.94 78.0203 126.657 77.1357 126.657H23.0785C22.1939 126.657 21.4768 125.94 21.4768 125.055V23.3474Z`,fill:f6,mask:`url(#val-mark-hole)`})}),(0,Y.jsx)(`circle`,{cx:`49.9`,cy:`104.2`,r:`9.61`,fill:`none`,stroke:f6,strokeWidth:`3`,strokeOpacity:`0.3`,filter:`url(#val-mark-hole-shadow)`})]})}var f6=`var(--colors-brand-green-400)`;function p6({initials:e,size:t=`md`,className:n}){return(0,Y.jsx)(`span`,{className:X(`grid place-items-center rounded-full bg-bg-float-raised text-fg-primary border border-border-float font-medium select-none`,t===`sm`?`w-7 h-7 text-[0.625rem]`:`w-8 h-8 text-[0.6875rem]`,n),children:e})}function m6({className:e}){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full`,`bg-fg-error-on-surface ring-2 ring-bg-float`,e)})}function gKe({error:e}){return(0,Y.jsxs)(`div`,{className:`mx-4 my-3 rounded-md border border-border-error-primary bg-bg-error-secondary p-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Ly,{size:13,className:`mt-0.5 shrink-0 text-fg-error-on-surface`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-fg-error-on-surface`,children:`Could not load your account`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[0.6875rem] text-fg-secondary`,children:e.message})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:e.onRetry,className:X(`mt-2 inline-flex h-7 items-center rounded-md px-2.5 text-xs font-medium`,`border border-border-primary text-fg-primary hover:bg-bg-float-raised`),children:`Try again`})]})}var h6=[{panel:`pages`,label:`Pages`,icon:$v},{panel:`media`,label:`Media`,icon:sy},{panel:`data`,label:`Data`,icon:Nv}];function g6(e){return e===void 0?h6:h6.filter(t=>e.includes(t.panel))}function _Ke({openPanel:e,onSelect:t,destinations:n,user:r,hasDraftChanges:i,accountError:a,isLoading:o}){let s=g6(n);return(0,Y.jsxs)(`nav`,{"aria-label":`Main`,className:`absolute left-3 top-3 bottom-3 z-full w-12 flex flex-col items-center py-2 gap-1 rounded-lg bg-bg-float border border-border-float shadow-sm`,children:[(0,Y.jsx)(`div`,{className:`grid place-items-center w-8 h-8 mb-1 shrink-0 text-fg-primary`,children:(0,Y.jsx)(d6,{className:`h-6`,blinking:o})}),s.map(({panel:n,label:r,icon:i})=>(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":r,"aria-current":e===n?`true`:void 0,onClick:()=>t(n),className:X(`grid place-items-center w-8 h-8 rounded-md shrink-0 transition-colors`,e===n?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:(0,Y.jsx)(i,{size:17})})}),(0,Y.jsx)(Xg,{side:`right`,children:r})]},n)),(0,Y.jsx)(`div`,{className:`mt-auto shrink-0`,children:r?(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Account: ${r.name}`,"aria-current":e===`settings`?`true`:void 0,onClick:()=>t(`settings`),className:`relative grid place-items-center w-8 h-8 rounded-full`,children:[(0,Y.jsx)(p6,{initials:r.initials,size:`sm`}),a&&(0,Y.jsx)(m6,{}),i&&(0,Y.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 w-2 h-2 rounded-full bg-fg-secondary ring-2 ring-bg-float`})]})}),(0,Y.jsx)(Xg,{side:`right`,children:a?a.message:r.name})]}):(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Settings`,"aria-current":e===`settings`?`true`:void 0,onClick:()=>t(`settings`),className:X(`relative grid place-items-center w-8 h-8 rounded-md transition-colors`,e===`settings`?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:[(0,Y.jsx)(Tae,{size:17}),a&&(0,Y.jsx)(m6,{}),i&&(0,Y.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 w-2 h-2 rounded-full bg-fg-secondary ring-2 ring-bg-float`})]})}),(0,Y.jsx)(Xg,{side:`right`,children:a?a.message:`Settings`})]})})]})}var _6=40;function vKe({breakpoint:e,media:t,selectedId:n,onSelect:r,onSelectFile:i,getFileUrl:a,onUpload:o,onClose:s,navSwitcher:c,isLoading:l,loadError:u,onRetryLoad:d}){let[f,p]=(0,b.useState)(``),[m,h]=(0,b.useState)(()=>new Set),g=f.trim().toLowerCase(),_=(0,b.useMemo)(()=>g?t.map(e=>{let t=e.name.toLowerCase().includes(g)||e.directory.toLowerCase().includes(g);return{gallery:e,files:(e.files??[]).filter(e=>e.ref.toLowerCase().includes(g)),galleryMatches:t}}).filter(({files:e,galleryMatches:t})=>t||e.length>0).map(({gallery:e,files:t,galleryMatches:n})=>({gallery:e,files:n&&t.length===0?e.files:t})):t.map(e=>({gallery:e,files:e.files})),[t,g]),v=e=>g?!0:m.has(e),y=e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,Y.jsx)(pC,{side:`left`,width:300,title:`Media`,mobileVariant:`sheet`,breakpoint:e,onClose:s,subheader:c,headerAction:o&&t.length>0?(0,Y.jsx)(CKe,{media:t,onUpload:o}):void 0,sticky:l||u?void 0:(0,Y.jsx)(gC,{value:f,onChange:p,placeholder:`Filter media…`}),children:(0,Y.jsx)(`div`,{className:`py-2`,children:l?(0,Y.jsx)(vC,{}):u?(0,Y.jsx)(yC,{message:u,onRetry:d}):_.length===0?(0,Y.jsx)(hC,{children:f?`Nothing matches this filter.`:`No galleries yet.`}):_.map(({gallery:e,files:t})=>{let o=v(e.id);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(_C,{selected:n===e.id,title:e.moduleFilePath,expanded:o,onClick:()=>{g||y(e.id)},action:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(e),title:`Open in the editor`,"aria-label":`Open ${e.name} in the editor`,className:X(`ml-1 shrink-0 rounded px-1.5 h-6 text-[0.6875rem] text-fg-secondary`,`hover:bg-bg-float-raised hover:text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,`opacity-0 transition-opacity`,`group-hover/row:opacity-100 focus-visible:opacity-100`,`[@media(hover:none)]:opacity-100`,n===e.id&&`opacity-100`),children:`Open`}),leading:(0,Y.jsx)(`span`,{className:`text-fg-secondary-alt`,children:o?(0,Y.jsx)(Iv,{size:13}):(0,Y.jsx)(Rv,{size:13})}),label:e.name,meta:aA(e.directory),trailing:(0,Y.jsx)(`span`,{className:`text-[0.6875rem] tabular-nums text-fg-secondary-alt`,children:e.itemCount})}),o&&(0,Y.jsx)(yKe,{gallery:e,files:t,selectedId:n,onSelectFile:i,getFileUrl:a})]},e.id)})})})}function yKe({gallery:e,files:t,selectedId:n,onSelectFile:r,getFileUrl:i}){let[a,o]=(0,b.useState)(_6),s=t?.length??-1;if((0,b.useEffect)(()=>o(_6),[s]),t===void 0)return(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 pl-8 py-1.5 text-[0.6875rem] text-fg-secondary-alt`,children:[(0,Y.jsx)(hy,{size:11,className:`animate-spin`}),`Loading files…`]});if(t.length===0)return(0,Y.jsx)(`p`,{className:`pl-8 py-1.5 text-[0.6875rem] text-fg-secondary-alt`,children:`No files in this gallery yet.`});let c=t.slice(0,a),l=t.length-c.length,u=wKe(c,e.directory);return(0,Y.jsxs)(`div`,{children:[u.map(t=>(0,Y.jsxs)(`div`,{children:[u.length>1&&(0,Y.jsx)(`p`,{title:aA(t.directory),className:`truncate pl-8 pr-3 pt-1.5 pb-0.5 text-[0.625rem] uppercase tracking-wide text-fg-secondary-alt`,children:t.label}),t.files.map(t=>(0,Y.jsx)(bKe,{gallery:e,file:t,selected:n===t.sourcePath,onSelect:r,getFileUrl:i},t.ref))]},t.directory)),l>0&&(0,Y.jsx)(xKe,{remaining:l,onShowMore:()=>o(e=>e+_6)})]})}function bKe({gallery:e,file:t,selected:n,onSelect:r,getFileUrl:i}){let[a,o]=(0,b.useState)(!1),s=i?.(t.ref)??null,c=e.mediaType===`images`&&s!==null&&!a;return(0,Y.jsx)(`div`,{className:`flex items-center pl-5 pr-2`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r?.(e,t),title:aA(t.ref),"aria-current":n?`true`:void 0,className:X(`group flex items-center gap-2 min-w-0 flex-1 h-8 px-1.5 rounded-md text-xs text-left`,n?`bg-bg-float-raised text-fg-primary font-medium`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:[(0,Y.jsx)(`span`,{className:`grid place-items-center w-6 h-6 shrink-0 overflow-hidden rounded bg-bg-float-raised`,children:c?(0,Y.jsx)(cA,{url:s,loading:`lazy`,onError:()=>o(!0)}):e.mediaType===`images`?(0,Y.jsx)(sy,{size:12,className:`text-fg-secondary-alt`}):(0,Y.jsx)($v,{size:12,className:`text-fg-secondary-alt`})}),(0,Y.jsx)(`span`,{className:`truncate`,children:SKe(t.ref)})]})})}function xKe({remaining:e,onShowMore:t}){let n=(0,b.useRef)(null);return(0,b.useEffect)(()=>{let e=n.current;if(!e||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&t()});return r.observe(e),()=>r.disconnect()},[t]),(0,Y.jsxs)(`button`,{ref:n,type:`button`,onClick:t,className:`block w-full pl-8 pr-3 py-1.5 text-left text-[0.6875rem] text-fg-secondary-alt hover:text-fg-primary`,children:[`Show `,Math.min(e,_6),` more (`,e,` left)`]})}function SKe(e){let t=e.split(`/`);return t[t.length-1]||e}function CKe({media:e,onUpload:t}){let[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(null);i6(i,n,(0,b.useCallback)(()=>r(!1),[]));let a=e.length===1?e[0]:null;return(0,Y.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-haspopup":a?void 0:`menu`,"aria-expanded":a?void 0:n,title:a?`Upload into ${aA(a.directory)}`:`Choose where to upload`,onClick:()=>a?t(a):r(e=>!e),className:`inline-flex items-center gap-1 h-7 px-2 rounded-md text-xs font-medium text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(Oy,{size:13}),`Upload`,!a&&(0,Y.jsx)(Iv,{size:12})]}),n&&!a&&(0,Y.jsx)(`div`,{role:`menu`,className:`absolute right-0 top-full z-window mt-1 w-64 rounded-md border border-border-float bg-bg-float py-1 shadow-lg`,children:e.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(!1),t(e)},className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:[e.mediaType===`images`?(0,Y.jsx)(sy,{size:13,className:`mt-0.5 shrink-0`}):(0,Y.jsx)($v,{size:13,className:`mt-0.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-xs`,children:aA(e.directory)}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:e.mediaType===`images`?`Images`:`Files`})]})]},e.id))})]})}function wKe(e,t){let n=new Map;for(let t of e){let e=t.ref.slice(0,t.ref.lastIndexOf(`/`))||`/`,r=n.get(e);r?r.push(t):n.set(e,[t])}return Array.from(n.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>({directory:e,label:TKe(e,t),files:n}))}function TKe(e,t){if(e===t)return`In this folder`;let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)?e.slice(n.length):aA(e)}function EKe({breakpoint:e,projectName:t,projectHref:n,openPanel:r,onTogglePanel:i,onOpenMenu:a,unreadNotifications:o,user:s,onOpenSearch:c,onPreview:l,onToggleCanvas:u,isCanvasOpen:d,onPublish:f,publishSlot:p,pendingChanges:m,onCompare:h,reviewCount:g,publishState:_=`idle`,accountError:v,isLoading:y,aiEnabled:b=!1,previewHref:x}){let S=e===`mobile`,C=e===`desktop`;return(0,Y.jsxs)(`header`,{className:X(`absolute z-full top-3 h-11 flex items-center gap-1.5 px-2 rounded-lg`,`bg-bg-float border border-border-float shadow-sm`,C?`left-[4.75rem] right-3`:`left-3 right-3`),children:[!C&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Open navigation`,onClick:a,className:`grid place-items-center w-8 h-8 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary shrink-0`,children:(0,Y.jsx)(mae,{size:17})}),!C&&(0,Y.jsx)(`div`,{className:`grid place-items-center w-7 h-7 shrink-0 text-fg-primary`,children:(0,Y.jsx)(d6,{className:`h-5`,blinking:y})}),(0,Y.jsx)(OKe,{projectName:t,projectHref:n}),(0,Y.jsx)(kKe,{breakpoint:e,onClick:c}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[!S&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(v6,{onPreview:l,previewHref:x,onToggleCanvas:u,isCanvasOpen:d}),(0,Y.jsx)(DKe,{onCompare:h,pendingChanges:m,reviewCount:g}),p??(0,Y.jsx)(S6,{pendingChanges:m,onPublish:f,publishState:_}),(0,Y.jsx)(b6,{})]}),b&&(0,Y.jsx)(x6,{label:`AI assistant`,active:r===`ai`,onClick:()=>i(`ai`),children:(0,Y.jsx)(Ny,{size:16})}),!S&&(0,Y.jsx)(x6,{label:`Quick actions`,active:r===`utility`,onClick:()=>i(`utility`),children:(0,Y.jsx)(Cy,{size:16})}),o!==void 0&&(0,Y.jsxs)(x6,{label:o>0?`Notifications (${o} unread)`:`Notifications`,active:r===`notifications`,onClick:()=>i(`notifications`),children:[(0,Y.jsx)(Iie,{size:16}),o>0&&(0,Y.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-[1rem] h-4 px-1 grid place-items-center rounded-full bg-fg-primary text-bg-float text-[0.625rem] font-semibold tabular-nums`,children:o>9?`9+`:o})]}),(s||v)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(b6,{}),(0,Y.jsxs)(`button`,{type:`button`,"aria-label":v?`Account: ${v.message}`:`Account: ${s?.name}`,title:v?.message,onClick:()=>i(`settings`),className:`relative shrink-0 rounded-full`,children:[s?(0,Y.jsx)(p6,{initials:s.initials,size:`sm`}):(0,Y.jsx)(`span`,{className:`grid h-6 w-6 place-items-center rounded-full text-fg-secondary`,children:(0,Y.jsx)(Bae,{size:15})}),v&&(0,Y.jsx)(m6,{})]})]})]})]})}function v6({onPreview:e,previewHref:t,onToggleCanvas:n,isCanvasOpen:r,canvasActionLabel:i,onExitCanvas:a,className:o,menuPlacement:s=`below`,alwaysShowLabel:c}){let[l,u]=(0,b.useState)(!1),d=(0,b.useRef)(null);i6(d,l,(0,b.useCallback)(()=>u(!1),[])),(0,b.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[l]);let f=c?void 0:`hidden md:inline`;return n?(0,Y.jsxs)(`div`,{ref:d,className:X(`relative h-8`,o),children:[(0,Y.jsxs)(`div`,{className:X(`inline-flex h-full w-full items-stretch overflow-hidden rounded-md border`,r?`border-border-float bg-bg-float-raised text-fg-primary`:`border-border-float text-fg-secondary`),children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-label":i??(r?`Close the canvas`:`Open the canvas`),"aria-pressed":i===void 0?r:void 0,onClick:n,className:`inline-flex flex-1 items-center justify-center gap-1.5 px-2.5 text-xs font-medium hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(Hie,{size:14}),(0,Y.jsx)(`span`,{className:f,children:`Preview`})]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-px self-stretch bg-border-float`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Other ways to preview`,"aria-haspopup":`menu`,"aria-expanded":l,onClick:()=>u(e=>!e),className:`grid w-6 place-items-center hover:bg-bg-float-raised hover:text-fg-primary`,children:(0,Y.jsx)(Iv,{size:13})})]}),l&&(0,Y.jsxs)(`div`,{role:`menu`,className:X(`absolute right-0 z-full w-56 rounded-md border border-border-float bg-bg-float py-1 shadow-lg`,s===`above`?`bottom-full mb-1`:`top-full mt-1`),children:[a?(0,Y.jsx)(y6,{icon:Hy,label:`Exit Preview`,detail:`Back to the editor, and stop the page`,onClick:()=>{u(!1),a()}}):(0,Y.jsx)(y6,{icon:Hie,label:r?`Close the canvas`:`Open the canvas`,detail:`Beside the editor, in the studio`,onClick:()=>{u(!1),n()}}),(0,Y.jsx)(y6,{icon:uy,label:`Open in a new tab`,detail:`The page with your unpublished changes`,href:t,onClick:()=>{u(!1),t===void 0&&e()}})]})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:X(`inline-flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-md text-xs font-medium text-fg-secondary border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,o),children:[(0,Y.jsx)(Qv,{size:14}),(0,Y.jsx)(`span`,{className:f,children:`Preview`})]})}function y6({icon:e,label:t,detail:n,onClick:r,href:i}){let a=`flex w-full items-start gap-2 px-2.5 py-1.5 text-left text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,o=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(e,{size:14,className:`mt-0.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs`,children:t}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:n})]})]});return i===void 0?(0,Y.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:r,className:a,children:o}):(0,Y.jsx)(`a`,{role:`menuitem`,href:i,target:`_blank`,rel:`noopener noreferrer`,onClick:r,className:a,children:o})}function b6(){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-px h-5 mx-0.5 bg-border-float`})}function DKe({onCompare:e,pendingChanges:t,reviewCount:n}){if(!e)return null;let r=t>0,i=r&&n!==void 0&&n>0;return(0,Y.jsxs)(`button`,{type:`button`,onClick:e,...r?{}:{"aria-hidden":!0,tabIndex:-1},"aria-label":i?`Review ${n} ${n===1?`change`:`changes`}`:`Review changes`,className:X(`relative inline-flex items-center gap-1.5 h-8 px-2.5 rounded-md shrink-0`,`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,!r&&`invisible`),children:[(0,Y.jsx)(ny,{size:15}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem]`,children:`Review`}),i&&(0,Y.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-[1rem] h-4 px-1 grid place-items-center rounded-full bg-fg-primary text-bg-float text-[0.625rem] font-semibold tabular-nums`,children:n>9?`9+`:n})]})}function x6({label:e,active:t,onClick:n,children:r}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,onClick:n,className:X(`relative grid place-items-center w-8 h-8 rounded-md shrink-0`,t?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:r})}function S6({pendingChanges:e,onPublish:t,publishState:n=`idle`,className:r}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:t,disabled:e===0||n===`publishing`||n===`blocked`,title:n===`blocked`?`Fix the validation errors before publishing`:void 0,className:X(`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium`,n===`error`?`bg-bg-error-primary text-fg-error-primary hover:bg-bg-error-primary-hover`:`bg-bg-brand-primary text-fg-brand-primary border border-border-brand-primary hover:bg-bg-brand-primary-hover`,`disabled:bg-bg-disabled disabled:text-fg-disabled`,r),children:[n===`publishing`?(0,Y.jsx)(hy,{size:14,className:`animate-spin`}):n===`error`?(0,Y.jsx)(Ly,{size:14}):(0,Y.jsx)(By,{size:14}),n===`publishing`?`Publishing…`:n===`error`?`Publish failed`:`Publish`,n===`idle`&&e>0&&(0,Y.jsx)(`span`,{className:`tabular-nums opacity-80`,children:e})]})}function OKe({projectName:e,projectHref:t}){let n=`min-w-0 px-2 text-[0.8125rem] font-semibold tracking-tight truncate`;return t===void 0?(0,Y.jsx)(`span`,{className:n,children:e}):(0,Y.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,title:`Open ${e} in Val Build`,className:X(n,`rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`),children:e})}function kKe({breakpoint:e,onClick:t}){return e===`mobile`?(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Search`,onClick:t,className:`grid place-items-center w-8 h-8 shrink-0 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:(0,Y.jsx)(My,{size:16})}):(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Search`,onClick:t,className:`inline-flex items-center gap-2 h-8 pl-2 pr-1.5 rounded-md text-xs text-fg-secondary-alt border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(My,{size:14}),(0,Y.jsx)(`span`,{className:`hidden lg:inline`,children:`Search`}),(0,Y.jsx)(`kbd`,{className:`hidden lg:inline px-1.5 py-0.5 rounded border border-border-float text-[0.625rem] font-sans`,children:`⌘K`})]})}function AKe({openPanel:e,onSelect:t,destinations:n}){let r=g6(n);return r.length<2?null:(0,Y.jsx)(`div`,{role:`tablist`,"aria-label":`Destinations`,className:`flex gap-0.5 p-0.5 rounded-md bg-bg-float-raised`,children:r.map(({panel:n,label:r,icon:i})=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,onClick:()=>t(n),className:X(`flex-1 inline-flex items-center justify-center gap-1.5 h-7 rounded text-[0.6875rem]`,e===n?`bg-bg-float text-fg-primary shadow-sm font-medium`:`text-fg-secondary`),children:[(0,Y.jsx)(i,{size:13}),r]},n))})}function jKe({pendingChanges:e,onPreview:t,previewHref:n,onPublish:r,publishSlot:i,onOpenStatus:a,onOpenQuickActions:o,onToggleCanvas:s,isCanvasOpen:c,canvasActionLabel:l,onExitCanvas:u}){return(0,Y.jsxs)(`div`,{className:`absolute z-full bottom-0 inset-x-0 flex items-center gap-2 px-3 py-2.5 bg-bg-float border-t border-border-float`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:a,"aria-label":`Status and settings`,className:`grid place-items-center w-9 h-9 shrink-0 rounded-md text-fg-secondary border border-border-float`,children:(0,Y.jsx)(cy,{size:16})}),o&&(0,Y.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`Quick actions`,className:`grid h-9 w-9 shrink-0 place-items-center rounded-md border border-border-float text-fg-secondary`,children:(0,Y.jsx)(Cy,{size:16})}),(0,Y.jsx)(v6,{onPreview:t,previewHref:n,onToggleCanvas:s,isCanvasOpen:c,canvasActionLabel:l,onExitCanvas:u,menuPlacement:`above`,alwaysShowLabel:!0,className:`h-9 flex-1`}),i??(0,Y.jsx)(S6,{pendingChanges:e,onPublish:r,className:`flex-1 h-9`})]})}var C6=5;function w6(e){return e.length<=C6?e.join(`, `):`${e.slice(0,C6).join(`, `)} and ${e.length-C6} more`}function MKe(e,t){let{total:n,settled:r,unfetched:i,unapplied:a,statSeen:o}=e;return o?i.length>0?{summary:`${r} of ${n} unpublished ${n===1?`change`:`changes`} loaded. ${i.length} never arrived.`,detail:[`The server announced ${n} unpublished ${n===1?`change`:`changes`} and sent the contents of ${r}. These were announced but never delivered:`,w6(i),t===null?`No fetch error was reported, so the request is most likely still outstanding rather than refused.`:`The last fetch error was: ${t}`,`The fields are editable again. Anything you change now is written on top of what did load, so the changes above may be lost — reload before editing if you can.`].join(`
|
|
218
218
|
|
|
@@ -238,7 +238,7 @@ Guidance:
|
|
|
238
238
|
- State only what the values show. Never speculate about why ("so that", "to enable").
|
|
239
239
|
- Do not repeat the title in the description.
|
|
240
240
|
- Where a value was truncated, describe it as far as you can see and do not invent the rest.
|
|
241
|
-
- Reply with the commit message only. No preamble, no quoting of these instructions.`;function jJe(e){let{sendWsMessage:t,subscribeToWsMessages:n,isWsConnected:r}=zS(),[i,a]=(0,b.useState)({status:e===null?`off`:`idle`}),o=(0,b.useRef)(null),s=(0,b.useRef)(null),c=(0,b.useRef)(!1),l=(0,b.useRef)(``);(0,b.useEffect)(()=>{a(t=>e===null?t.status===`off`?t:{status:`off`}:t.status===`off`?{status:`idle`}:t)},[e]),(0,b.useEffect)(()=>n(e=>{if(!(!(`id`in e)||e.id!==o.current)){if(e.type===`ai_streaming`){l.current+=e.chunk;return}if(e.type===`ai_response`){let t=(e.response||l.current).trim();a(t?{status:`ready`,text:t,sessionId:s.current}:{status:`failed`,message:`The AI returned an empty summary.`}),o.current=null;return}if(e.type===`ai_error`){a({status:`failed`,message:e.message,canSetUp:e.code===`provider_not_configured`||e.code===`byok_invalid_key`}),o.current=null;return}e.type===`ai_cancelled`&&(a({status:`idle`}),o.current=null)}}),[n]);let u=(0,b.useCallback)(()=>{let e=o.current;o.current=null,e!==null&&t({type:`ai_cancel`,id:e})},[t]);return(0,b.useEffect)(()=>()=>{u(),c.current=!1},[u]),{state:i,start:(0,b.useCallback)(n=>{if(c.current||e===null||!r)return;c.current=!0;let i=crypto.randomUUID(),u=crypto.randomUUID();o.current=i,s.current=u,l.current=``,a({status:`loading`}),t({type:`ai_prompt`,id:i,sessionId:u,hidden:!0,message:n,maxIterations:1,agents:[{id:`commit-summary`,model:e,systemPrompt:AJe,tools:[]}]})||(o.current=null,a({status:`failed`,message:`Could not reach the AI service.`}))},[r,e,t]),cancel:u,reveal:(0,b.useCallback)(async()=>{let e=s.current;if(e===null)return null;let r=crypto.randomUUID();return new Promise(i=>{let a=setTimeout(()=>{o(),i(null)},1e4),o=n(e=>{!(`id`in e)||e.id!==r||(clearTimeout(a),o(),i(e.type===`ai_session_unhidden`?e.sessionId:null))});t({type:`ai_unhide_session`,id:r,sessionId:e})||(clearTimeout(a),o(),i(null))})},[t,n])}}var L8=Symbol(`unknown`);function R8(e){if(e.status===`ready`)return e.data;if(e.status!==`absent`)return L8}var MJe=10;function NJe({onPublish:e,onClose:t}){let{summary:n,setSummary:r,publishDisabled:i,isPublishing:a,aiEnabled:o}=eC(),s=US(),c=nb(),l=BS(),u=o?l:null,d=CJe(MJe),{setSessionParam:f}=KC(),{openAIChat:p}=wS(),m=jJe(u),h=(0,b.useMemo)(()=>s.status===`success`?s.data.map(e=>e.moduleFilePath):[],[s]),g=(0,b.useMemo)(()=>TJe(h),[h]),_=`text`in n?n.text:``,v=(0,b.useRef)(!1);(0,b.useEffect)(()=>{v.current||(v.current=!0,_.trim()===``&&r({type:`manual`,text:g}))},[g,_,r]),(0,b.useEffect)(()=>{if(c===null||s.status!==`success`)return;let e=c.system.sourceStore,t=[];for(let n of s.data){let r=H.joinModuleFilePathAndModulePath(n.moduleFilePath,H.patchPathToModulePath(n.patchPath)),i=R8(e.peek(r)),a=R8(e.peekBase(r));i!==L8&&a!==L8&&t.push({sourcePath:r,moduleFilePath:n.moduleFilePath,fieldPath:n.patchPath.join(`.`),schemaType:n.schemaTypes[0],before:a,after:i})}t.length!==0&&m.start(kJe(t))},[m.start,s,c]);let[y,x]=(0,b.useState)(!1),S=(0,b.useRef)(!1);(0,b.useEffect)(()=>{S.current||m.state.status!==`ready`||(S.current=!0,P8({hasEdited:y,currentValue:_,defaultSummary:g})&&r({type:`ai`,text:m.state.text}))},[m.state,y,_,g,r]);let{isWaiting:C,skip:w}=d;(0,b.useEffect)(()=>{C&&(m.state.status===`ready`||m.state.status===`failed`)&&w()},[m.state.status,C,w]);let T=()=>{m.cancel(),e?.()};return(0,Y.jsx)(xJe,{value:_,onChange:e=>{x(!0),r({type:`manual`,text:e})},ai:m.state,onUseAiSummary:()=>{m.state.status===`ready`&&r({type:`ai`,text:m.state.text})},onOpenAiSession:m.state.status===`ready`&&m.state.sessionId!==null?()=>{m.reveal().then(e=>{e!==null&&(f(e,{replace:!0}),t(),p())})}:void 0,onPublish:()=>{if(d.isWaiting){d.skip();return}if(m.state.status===`loading`&&P8({hasEdited:y,currentValue:_,defaultSummary:g})){d.start(T);return}T()},onClose:()=>{d.cancel(),m.cancel(),t()},publishDisabled:i,isPublishing:a,waitingForAiSeconds:d.remaining})}var PJe=`h-auto w-auto p-2`;function FJe({kind:e,saving:t}){return(0,Y.jsx)(`span`,{className:`grid size-4 shrink-0 place-items-center`,children:e===`blocked`?(0,Y.jsx)(Ly,{size:16}):e===`in-flight`?(0,Y.jsx)(Gv,{size:16,className:`animate-pulse`}):t?(0,Y.jsx)(jy,{size:16}):(0,Y.jsx)(ky,{size:16})})}function z8({compact:e}){let[t,n]=(0,b.useState)(!1),{publish:r,publishDisabled:i,isPublishing:a,summary:o}=eC(),s=Fb(),c=Object.keys(s??{}),{patchErrors:l}=oC(),u=Object.values(l||{}).reduce((e,t)=>e+Object.keys(t||{}).length,0),d=qS(),f=GS(),p=(0,b.useMemo)(()=>d.filter(e=>!f.has(e)),[d,f]),m=JS(),h=KS(),g=QS(),_=eb(),{autoPublish:v}=aC(),{navigate:y}=GC(),x=bJe({mode:g===`fs`?`fs`:g===null?`unknown`:`http`,validationErrorCount:c.length,conflictingChangeCount:u,isPublishing:a,publishDisabled:i,autoPublish:v,pendingServerSidePatchCount:p.length,pendingClientSidePatchCount:m.length,netChangesEmpty:!h}),S=g===`fs`,C=e?PJe:`flex h-8 min-w-[6.5rem] items-center justify-center gap-2 px-3 text-xs font-medium`,w=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(FJe,{kind:x.kind,saving:S}),!e&&(0,Y.jsx)(`span`,{children:x.label})]}),T=x.reason??x.description;if(x.kind===`blocked`){let t=(0,Y.jsx)(t_,{className:C,variant:x.action===`show-errors`?`destructive`:`default`,disabled:x.action===`none`,"aria-label":e?x.description:void 0,onClick:()=>{x.action===`show-errors`&&y(LC,{errorFields:c})},children:w});return(0,Y.jsx)(B8,{label:x.description,description:T,disabled:x.action===`none`,container:_,children:t})}if(S||x.kind!==`ready`){let t=(0,Y.jsx)(t_,{className:C,disabled:x.action===`none`,"aria-label":e?x.description:void 0,onClick:()=>{x.action===`save`&&r(`No summary provided`)},children:w});return(0,Y.jsx)(B8,{label:x.description,description:T,disabled:x.action===`none`,container:_,children:t})}let E=(0,Y.jsx)(t_,{className:C,"aria-label":e?x.description:void 0,onClick:()=>{n(!0)},children:w});return(0,Y.jsx)(`span`,{className:`inline-flex`,children:(0,Y.jsxs)(SD,{open:t,onOpenChange:e=>{n(e)},children:[e?(0,Y.jsx)(B8,{label:x.description,description:T,disabled:!1,container:_,children:(0,Y.jsx)(CD,{asChild:!0,children:E})}):(0,Y.jsx)(CD,{asChild:!0,children:E}),(0,Y.jsxs)(wD,{container:_,align:`end`,className:`z-[9001] flex flex-col gap-4`,children:[(0,Y.jsx)(yD,{asChild:!0,className:`self-end cursor-pointer`,children:(0,Y.jsx)(Hy,{size:12})}),(0,Y.jsx)(NJe,{onClose:()=>{n(!1)},onPublish:()=>{if(n(!1),o.type===`not-asked`)return;let e=o.text.trim();r(e)}})]})]})})}function B8({label:e,description:t,disabled:n,container:r,children:i}){return(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:n?(0,Y.jsx)(`span`,{className:`inline-flex`,role:`button`,tabIndex:0,"aria-disabled":`true`,"aria-label":e,children:(0,Y.jsx)(`span`,{className:`inline-flex`,"aria-hidden":`true`,children:i})}):i}),(0,Y.jsx)(Xg,{container:r,children:(0,Y.jsx)(`p`,{children:t})})]})}var IJe=`font-mono text-sm px-2 py-0.5 rounded bg-bg-secondary text-fg-primary truncate transition-colors min-w-0 block hover:bg-bg-tertiary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`;function V8({sourcePath:e,previewSegment:t,className:n,children:r}){let i=wb(),a=ob(e,Eb(),i.status===`success`?i.data:void 0)??e,o=E8(a,{scrollToPath:a===e?void 0:e}),s=(0,Y.jsx)(`a`,{...o,title:e,className:X(IJe,n),children:r});if(t===void 0)return s;let c=Jf(`/api/val/enable`,{redirect_to:(typeof window<`u`?window.location.origin:``)+t});return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 truncate min-w-0 max-w-full`,children:[s,(0,Y.jsx)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 text-fg-tertiary hover:text-fg-primary transition-colors`,title:`Preview ${t}`,children:(0,Y.jsx)(ry,{size:12})})]})}function LJe({errorFields:e,allErrors:t}){let n=(0,b.useMemo)(()=>UJe(e),[e]),r=e.length,i=n.length,a=r>0&&e.every(e=>!t?.[e]||t[e].length===0),o=e.filter(e=>t?.[e]&&t[e].length>0).length;return e.length===0?(0,Y.jsx)(`div`,{className:`mx-auto max-w-3xl py-12 text-center text-sm text-fg-secondary`,children:`No errors selected.`}):(0,Y.jsxs)(`div`,{className:`mx-auto max-w-3xl flex flex-col gap-4 py-6`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Ly,{size:18,className:`text-fg-warning-primary-alt`,"aria-hidden":!0}),(0,Y.jsx)(`h1`,{className:`text-lg font-medium text-fg-primary`,children:`Validation errors`}),a?(0,Y.jsx)(H8,{tone:`success`,children:`All fixed`}):(0,Y.jsxs)(H8,{tone:`warning`,children:[r,` `,r===1?`field`:`fields`,i>1?(0,Y.jsxs)(Y.Fragment,{children:[` across `,i,` modules`]}):null]})]}),a&&(0,Y.jsx)(HJe,{total:r}),!a&&o<r&&r>1&&(0,Y.jsxs)(`div`,{className:`text-sm text-fg-secondary`,children:[o,` of `,r,` still need attention.`]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map(({moduleFilePath:e,paths:n})=>(0,Y.jsx)(zJe,{moduleFilePath:e,paths:n,allErrors:t},e))})]})}function RJe(){let{errorFields:e}=GC(),t=Fb();return(0,Y.jsx)(LJe,{errorFields:e,allErrors:t})}function zJe({moduleFilePath:e,paths:t,allErrors:n}){let r=(0,b.useMemo)(()=>H.splitModuleFilePath(e),[e]),i=E8(e),a=t.filter(e=>n?.[e]&&n[e].length>0).length;return(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-border-primary bg-bg-primary`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border-primary bg-bg-secondary px-4 py-2`,children:[(0,Y.jsx)(Kie,{size:14,className:`text-fg-secondary-alt shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`a`,{...i,title:e,className:`min-w-0 flex flex-wrap items-center gap-1 rounded-sm text-sm text-fg-secondary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:r.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[t>0&&(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`}),(0,Y.jsx)(`span`,{className:(0,AC.default)({"text-fg-tertiary":t<r.length-1,"text-fg-primary":t===r.length-1}),children:kC(e)})]},`m-${t}`))}),(0,Y.jsx)(`div`,{className:`ml-auto`,children:a===0?(0,Y.jsxs)(H8,{tone:`success`,children:[(0,Y.jsx)(Vv,{size:11,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Fixed`})]}):(0,Y.jsxs)(H8,{tone:`warning`,children:[a,` `,a===1?`issue`:`issues`]})})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:t.map((e,r)=>(0,Y.jsx)(BJe,{sourcePath:e,errors:n?.[e],isLast:r===t.length-1},e))})]})}function BJe({sourcePath:e,errors:t,isLast:n}){let r=Cb(e),i=!!t&&t.length>0;return(0,Y.jsxs)(`li`,{className:(0,AC.default)(`flex flex-col gap-3 px-4 py-3`,{"border-b border-border-secondary":!n}),children:[(0,Y.jsx)(VJe,{sourcePath:e}),r.status===`success`?(0,Y.jsx)(Lhe,{children:(0,Y.jsx)(r6,{path:e,schema:r.data})}):(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:14,className:`animate-spin`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Loading field…`})]}),i?(0,Y.jsx)(Phe,{validationErrors:t}):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-fg-brand-primary`,children:[(0,Y.jsx)(Vv,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Fixed.`})]})]})}function VJe({sourcePath:e}){let t=wb(),[n,r]=H.splitModuleFilePathAndModulePath(e),i=r?H.splitModulePath(r):[],a=(t.status===`success`?t.data:void 0)?.[n],o=a?.type===`record`&&!!a.router&&i.length===1;return(0,Y.jsx)(V8,{sourcePath:e,previewSegment:o?i[0]:void 0,className:o?void 0:`self-start max-w-full`,children:o?i[0]:r?lD(r):kC(H.splitModuleFilePath(n).pop()??``)})}function H8({children:e,tone:t}){return(0,Y.jsx)(`span`,{className:(0,AC.default)(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium`,{"bg-bg-warning-primary text-fg-warning-primary":t===`warning`,"bg-bg-brand-primary text-fg-brand-primary":t===`success`}),children:e})}function HJe({total:e}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border-primary bg-bg-secondary px-4 py-3 text-sm text-fg-primary`,children:[(0,Y.jsx)(Vv,{size:16,className:`text-fg-secondary`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{children:[`All `,(0,Y.jsx)(`span`,{className:`font-medium`,children:e}),` `,e===1?`error is`:`errors are`,` fixed. Ready to publish.`]})]})}function UJe(e){let t=new Map;for(let n of e){let[e]=H.splitModuleFilePathAndModulePath(n),r=t.get(e);r?r.push(n):t.set(e,[n])}let n=Array.from(t.entries()).map(([e,t])=>({moduleFilePath:e,paths:t.slice().sort(WJe)}));return n.sort((e,t)=>e.moduleFilePath.localeCompare(t.moduleFilePath)),n}function WJe(e,t){let[,n]=H.splitModuleFilePathAndModulePath(e),[,r]=H.splitModuleFilePathAndModulePath(t),i=n?H.splitModulePath(n):[],a=r?H.splitModulePath(r):[],o=Math.min(i.length,a.length);for(let e=0;e<o;e++)if(i[e]!==a[e])return i[e].localeCompare(a[e]);return i.length-a.length}function GJe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function KJe(e){let t=e.patchPath,n=!1,r=!1,i=!1;for(let a of e.patches)GJe(a.patchPath,t)&&(a.opType===`add`&&(n=!0),a.opType===`remove`&&(r=!0),a.opType===`move`&&(i=!0));return n&&r?null:i&&r?`removed`:n?`added`:i?`moved`:r?`removed`:`field-change`}function qJe(e,t){if(t.length===0)return e;let n=H.patchPathToModulePath(t);return H.joinModuleFilePathAndModulePath(e,n)}function JJe(e,t){let n={};for(let r of t){let t=r.author??`unknown`;n[t]||(n[t]=[]),n[t].push({moduleFilePath:e,patchId:r.patchId,opType:r.opType,createdAt:r.createdAt,authorId:r.author})}return n}function YJe(e,t,n,r,i,a,o,s,c,l){if(n.length===0){e.change={changeType:r,patchIds:i,authors:a,lastUpdatedBy:s,patchesByAuthorIds:c},o>e.lastUpdated&&(e.lastUpdated=o);return}let u=e;for(let e=0;e<n.length;e++){let d=qJe(t,n.slice(0,e+1)),f=e===n.length-1,p=u.children.find(e=>e.sourcePath===d);p||(p={sourcePath:d,lastUpdated:o,isCommitted:l,children:[]},u.children.push(p)),o>p.lastUpdated&&(p.lastUpdated=o),f&&(p.change={changeType:r,patchIds:i,authors:a,lastUpdatedBy:s,patchesByAuthorIds:c}),u=p}}function U8(e){let t=e.lastUpdated;for(let n of e.children){let e=U8(n);e>t&&(t=e)}return e.lastUpdated=t,t}function W8(e){let t=String(e),[,n]=H.splitModuleFilePathAndModulePath(t);if(!n)return t;let r=H.splitModulePath(n);return r[r.length-1]??t}function G8(e){e.children.sort((e,t)=>W8(e.sourcePath).localeCompare(W8(t.sourcePath)));for(let t of e.children)G8(t)}function K8(e,t){let n=[],r=[],i=t[0].createdAt,a=t[0].author;for(let e of t)e.author!==null&&!n.includes(e.author)&&n.push(e.author),r.includes(e.opType)||r.push(e.opType),e.createdAt>i&&(i=e.createdAt,a=e.author);return{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath,patches:t,authors:n,opTypes:r,schemaTypes:e.schemaTypes,lastUpdated:i,lastUpdatedBy:a}}function XJe(e,t){if(t.size===0)return{pending:e,committed:null};let n=[],r=[];for(let i of e.patches)t.has(i.patchId)?r.push(i):n.push(i);return r.length===0?{pending:e,committed:null}:n.length===0?{pending:null,committed:e}:{pending:K8(e,n),committed:K8(e,r)}}function ZJe(e,t){return`${e?`committed`:`pending`}\u0000${t}`}function QJe(e,t=new Set){let n={};for(let r of e){let{pending:e,committed:i}=XJe(r,t);for(let t of[{set:e,isCommitted:!1},{set:i,isCommitted:!0}])t.set!==null&&$Je(n,t.set,t.isCommitted)}let r=Object.values(n);for(let e of r)U8(e),G8(e);return r.sort((e,t)=>e.isCommitted===t.isCommitted?t.lastUpdated.localeCompare(e.lastUpdated):e.isCommitted?1:-1),{trees:r}}function $Je(e,t,n){let r=KJe(t);if(r===null)return;let{moduleFilePath:i}=t,a=ZJe(n,i);e[a]||(e[a]={sourcePath:i,lastUpdated:t.lastUpdated,isCommitted:n,children:[]});let o=e[a],s=t.patches.map(e=>e.patchId),c=t.authors.filter(e=>e!==null),l=JJe(i,t.patches);YJe(o,i,t.patchPath,r,s,c,t.lastUpdated,t.lastUpdatedBy,l,n)}var eYe=typeof window<`u`&&typeof Worker<`u`;function tYe(e,t,n){let r=(0,b.useRef)(null),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(!1),u=(0,b.useRef)(0),d=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!eYe)return;let e=new Worker(new URL(`/api/val/static/assets/patchsets.worker-Da9KaH1a.js`,``+import.meta.url),{type:`module`});return r.current=e,e.onmessage=e=>{let t=e.data;t.id===d.current&&(t.type===`result`?(a(t.trees),s(!1),l(!0)):t.type===`error`&&(console.error(`PatchSets worker error:`,t.error),s(!1),l(!0)))},e.onerror=e=>{console.error(`PatchSets worker failed:`,e.message),s(!1),l(!0)},()=>{e.terminate(),r.current=null}},[]);let f=n?Array.from(n).sort().join(`,`):``,p=(0,b.useMemo)(()=>n===void 0?[]:Array.from(n).sort(),[f]),m=(0,b.useCallback)((e,t)=>{if(!r.current){let{trees:n}=QJe(e,new Set(t));a(n),s(!1),l(!0);return}let n=`ps-${u.current++}`;d.current=n,s(!0);let i={type:`compute`,id:n,patchSets:e,committedPatchIds:t};r.current.postMessage(i)},[]),[h,g]=(0,b.useState)(t);return h!==t&&(g(t),a([]),l(!1),s(!0)),(0,b.useEffect)(()=>{m(e,p)},[e,m,t,p]),{trees:i,isComputing:o,hasComputed:c}}function q8(e,t){return e===t}function nYe(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let a=n-1;a>=0;a--)for(let n=r-1;n>=0;n--)i[a][n]=q8(e[a],t[n])?i[a+1][n+1]+1:Math.max(i[a+1][n],i[a][n+1]);let a=[],o=0,s=0;for(;o<n&&s<r;)q8(e[o],t[s])?(a.push({beforeIndex:o,index:s}),o++,s++):i[o+1][s]>=i[o][s+1]?o++:s++;return a}function rYe(e,t){let n=[],r=Math.min(e.length,t.length);for(let i=0;i<r;i++)q8(e[i],t[i])?n.push({kind:`unchanged`,index:i,beforeIndex:i,value:t[i]}):n.push({kind:`changed`,index:i,beforeIndex:i,before:e[i],after:t[i]});for(let e=r;e<t.length;e++)n.push({kind:`added`,index:e,value:t[e]});for(let t=r;t<e.length;t++)n.push({kind:`removed`,beforeIndex:t,value:e[t]});return{lines:n,positional:!0}}function iYe(e,t){if(e.length>1e3||t.length>1e3)return rYe(e,t);let n=nYe(e,t),r=new Set(n.map(e=>e.beforeIndex)),i=new Set(n.map(e=>e.index)),a=new Map(n.map(e=>[e.index,e.beforeIndex])),o=[];for(let t=0;t<e.length;t++)r.has(t)||o.push(t);let s=new Map,c=new Set;for(let n=0;n<t.length;n++){if(i.has(n))continue;let r=o.find(r=>!c.has(r)&&q8(e[r],t[n]));r!==void 0&&(c.add(r),s.set(n,r))}let l=[],u=0,d=0,f=(n,r)=>{let i=[],a=[];for(;u<n;)c.has(u)||i.push(u),u++;for(;d<r;){if(s.has(d)){let e=s.get(d);if(e===void 0)throw Error(`unreachable: movedFrom.has without a value`);l.push({kind:`moved`,index:d,beforeIndex:e,value:t[d]})}else a.push(d);d++}let o=Math.min(i.length,a.length);for(let n=0;n<o;n++)l.push({kind:`changed`,index:a[n],beforeIndex:i[n],before:e[i[n]],after:t[a[n]]});for(let e=o;e<a.length;e++)l.push({kind:`added`,index:a[e],value:t[a[e]]});for(let t=o;t<i.length;t++)l.push({kind:`removed`,beforeIndex:i[t],value:e[i[t]]})};for(let e of n){f(e.beforeIndex,e.index);let n=a.get(e.index)??e.beforeIndex;l.push({kind:`unchanged`,index:e.index,beforeIndex:n,value:t[e.index]}),u=e.beforeIndex+1,d=e.index+1}return f(e.length,t.length),{lines:l,positional:!1}}function aYe(e){return e.lines.some(e=>e.kind!==`unchanged`)}function oYe(e){let t={added:0,removed:0,moved:0,changed:0,unchanged:0};for(let n of e.lines)t[n.kind]+=1;return t}function sYe({sourcePath:e}){let t=jb(e),n=Ab(e),r=Y8(t.status===`success`?t.data:void 0),i=Y8(n.status===`success`?n.data:void 0),a=(0,b.useMemo)(()=>r===null||i===null?null:iYe(r,i),[r,i]);if(a===null)return null;if(!aYe(a))return(0,Y.jsx)(`div`,{className:`text-sm text-fg-tertiary`,children:`The list ended up the same as it started.`});let o=oYe(a);return(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(cYe,{counts:o}),a.positional&&(0,Y.jsx)(lYe,{}),(0,Y.jsx)(`ol`,{className:`mt-3 flex flex-col gap-px font-mono text-sm tabular-nums`,children:a.lines.map((e,t)=>(0,Y.jsx)(uYe,{line:e},`${e.kind}-${t}`))})]})}function cYe({counts:e}){let t=[];return e.added>0&&t.push(`${e.added} added`),e.removed>0&&t.push(`${e.removed} removed`),e.moved>0&&t.push(`${e.moved} moved`),e.changed>0&&t.push(`${e.changed} changed`),(0,Y.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[t.join(`, `),e.unchanged>0&&(0,Y.jsxs)(`span`,{className:`text-fg-tertiary`,children:[t.length>0?` · `:``,e.unchanged,` unchanged`]})]})}function lYe(){return(0,Y.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-xs text-fg-secondary`,children:[(0,Y.jsx)(Ly,{size:12,className:`mt-0.5 shrink-0 text-fg-warning-primary-alt`,"aria-hidden":!0}),`This list is too long to match items by content, so it is compared position by position. A reorder will read as a run of changes.`]})}function uYe({line:e}){let t=`index`in e?e.index:null;return(0,Y.jsxs)(`li`,{className:X(`flex min-w-0 items-baseline gap-2 rounded border-l-[3px] py-1 pl-2 pr-1`,e.kind===`added`&&`border-fg-brand-primary bg-bg-brand-primary/5`,e.kind===`removed`&&`border-fg-error bg-bg-error-secondary/30`,e.kind===`moved`&&`border-fg-warning bg-bg-secondary/40`,e.kind===`changed`&&`border-fg-warning`,e.kind===`unchanged`&&`border-transparent`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`w-3 shrink-0 select-none text-center`,e.kind===`added`&&`text-fg-brand-primary`,e.kind===`removed`&&`text-fg-error`,e.kind===`moved`&&`text-fg-warning`,e.kind===`changed`&&`text-fg-warning`,e.kind===`unchanged`&&`text-fg-quaternary`),children:dYe(e.kind)}),(0,Y.jsx)(`span`,{className:`w-8 shrink-0 text-right text-xs text-fg-quaternary`,children:t===null?``:t+1}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:(0,Y.jsx)(fYe,{line:e})}),(0,Y.jsx)(pYe,{line:e})]})}function dYe(e){switch(e){case`added`:return`+`;case`removed`:return`−`;case`moved`:return`↕`;case`changed`:return`~`;case`unchanged`:return``}}function fYe({line:e}){return e.kind===`changed`?(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-fg-tertiary line-through decoration-fg-error/60`,children:(0,Y.jsx)(J8,{value:e.before})}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`text-fg-quaternary`,children:`→`}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(J8,{value:e.after})})]}):(0,Y.jsx)(`span`,{className:e.kind===`removed`?`text-fg-tertiary`:void 0,children:(0,Y.jsx)(J8,{value:e.value})})}function J8({value:e}){return e===null?(0,Y.jsx)(`span`,{className:`italic text-fg-tertiary`,children:`null`}):e===``?(0,Y.jsx)(`span`,{className:`italic text-fg-tertiary`,children:`empty`}):typeof e==`boolean`||typeof e==`number`?(0,Y.jsx)(Y.Fragment,{children:String(e)}):(0,Y.jsx)(Y.Fragment,{children:e})}function pYe({line:e}){if(e.kind===`unchanged`)return null;if(e.kind===`moved`){let t=e.index<e.beforeIndex;return(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 whitespace-nowrap font-sans text-xs text-fg-warning`,children:[t?(0,Y.jsx)(jv,{size:11,"aria-hidden":!0}):(0,Y.jsx)(kv,{size:11,"aria-hidden":!0}),`moved from `,e.beforeIndex+1]})}let t=e.kind===`added`?`added`:e.kind===`removed`?`removed from ${e.beforeIndex+1}`:`changed`;return(0,Y.jsx)(`span`,{className:X(`ml-auto shrink-0 whitespace-nowrap font-sans text-xs`,e.kind===`added`&&`text-fg-brand-primary`,e.kind===`removed`&&`text-fg-error`,e.kind===`changed`&&`text-fg-warning`),children:t})}function Y8(e){if(!Array.isArray(e))return null;let t=[];for(let n of e)if(n===null||typeof n==`string`||typeof n==`number`||typeof n==`boolean`)t.push(n);else return null;return t}function mYe({patchSets:e,profilesByAuthorIds:t,mode:n=`unknown`,canDiscard:r=!1,reloadKey:i,committedPatchIds:a,deployment:o}){let s=eb(),c=wb(),l=GS(),u=a??l,{trees:d,isComputing:f,hasComputed:p}=tYe(e,i,u),m=(0,b.useMemo)(()=>d.flatMap(T5),[d]),h=gYe(d),g=bce((0,b.useMemo)(()=>d.filter(e=>!e.isCommitted).map(e=>e.sourcePath),[d])),{changing:_,reverted:v,committedTrees:y}=(0,b.useMemo)(()=>{let e=[],t=[],n=[];for(let r of d)r.isCommitted?n.push(r):g.has(r.sourcePath)?t.push(r):e.push(r);return{changing:e,reverted:t,committedTrees:n}},[d,g]),x=(0,b.useMemo)(()=>Q8(v.flatMap(T5)),[v]),S=(0,b.useMemo)(()=>{let t=[],n=new Set,r=new Set;for(let i of e)for(let e of i.patches)u.has(e.patchId)||r.has(e.patchId)||(r.add(e.patchId),t.push(e.patchId),e.author!==null&&n.add(e.author));return{ids:t,authorIds:[...n]}},[e,u]);if(!p||f&&d.length===0)return(0,Y.jsx)(e5,{});if(m.length===0)return S.ids.length>0?(0,Y.jsx)(`div`,{className:`mx-auto max-w-7xl min-w-0`,children:(0,Y.jsx)(Z8,{patchIds:S.ids,authorIds:S.authorIds,profilesByAuthorIds:t,canDiscard:r,portalContainer:s})}):(0,Y.jsx)(`div`,{className:`text-sm text-fg-secondary py-8 text-center`,children:`No pending changes.`});let C=c.status===`success`?c.data:void 0;return(0,Y.jsxs)(`div`,{className:`mx-auto max-w-7xl flex flex-col gap-6 lg:gap-8 min-w-0`,children:[(0,Y.jsx)(_Ye,{authorIds:h.authorIds,pendingAuthorIds:h.pendingAuthorIds,profilesByAuthorIds:t,mode:n,pendingPatchIds:h.pendingPatchIds,deployingCount:h.deployingCount,canDiscard:r,portalContainer:s}),_.length===0&&v.length>0&&(0,Y.jsx)(Z8,{patchIds:x,authorIds:h.pendingAuthorIds,profilesByAuthorIds:t,canDiscard:r,portalContainer:s}),_.map(e=>(0,Y.jsx)(i5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`pending-${e.sourcePath}`)),v.length>0&&(0,Y.jsx)(hYe,{count:x.length,children:v.map(e=>(0,Y.jsx)(i5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`reverted-${e.sourcePath}`))}),y.length>0&&(o===void 0?(0,Y.jsx)(vYe,{}):(0,Y.jsx)(t5,{deployment:o})),y.map(e=>(0,Y.jsx)(i5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`committed-${e.sourcePath}`))]})}function X8(e,t){let n=nC();return(0,b.useMemo)(()=>e.filter(e=>e!==n).map(e=>t?.[e]?.fullName).filter(e=>!!e),[e,t,n])}function Z8({patchIds:e,authorIds:t,profilesByAuthorIds:n,canDiscard:r,portalContainer:i}){let{deletePatches:a}=RS(),o=X8(t,n);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border-primary bg-bg-secondary px-4 py-3 sm:flex-row sm:items-center`,children:[(0,Y.jsx)(Xv,{size:16,className:`shrink-0 text-fg-secondary`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-fg-primary`,children:e.length===1?`The one pending change has been reverted.`:`Every pending change has been reverted.`}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`The content matches what is published, so there is nothing to publish.`})]}),r&&e.length>0&&(0,Y.jsx)(w5,{description:n8(e.length,o),title:`Discard ${e.length} ${e.length===1?`change`:`changes`}?`,confirmLabel:`Discard ${e.length}`,onConfirm:()=>a(e),portalContainer:i,ariaLabel:`Discard all ${e.length} reverted ${e.length===1?`change`:`changes`}`,label:`Discard all`})]})}function hYe({count:e,children:t}){let[n,r]=(0,b.useState)(!1);return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`flex items-center gap-2 self-start rounded-md px-1 py-1 text-xs text-fg-secondary hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:[(0,Y.jsx)(Rv,{size:14,"aria-hidden":!0,className:(0,AC.default)(`transition-transform`,{"rotate-90":n})}),(0,Y.jsx)(Ay,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e===1?`1 reverted change`:`${e} reverted changes`})]}),n&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-6 lg:gap-8`,children:t})]})}function gYe(e){return(0,b.useMemo)(()=>{let t=e.filter(e=>!e.isCommitted).flatMap(T5),n=e.filter(e=>e.isCommitted).flatMap(T5);return{authorIds:$8(e.flatMap(T5)),pendingAuthorIds:$8(t),pendingPatchIds:Q8(t),deployingCount:Q8(n).length}},[e])}function Q8(e){let t=[],n=new Set;for(let r of e)for(let e of r.change?.patchIds??[])n.has(e)||(n.add(e),t.push(e));return t}function $8(e){let t=[],n=new Set;for(let r of e)for(let e of r.change?.authors??[])n.has(e)||(n.add(e),t.push(e));return t}function e5(){return(0,Y.jsxs)(`div`,{className:`mx-auto max-w-7xl flex flex-col gap-8 min-w-[380px]`,"aria-busy":`true`,"aria-live":`polite`,"aria-label":`Loading changes`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:14,className:`animate-spin`,"aria-hidden":!0}),`Building the comparison…`]}),[0,1].map(e=>(0,Y.jsxs)(`section`,{className:`border border-border-primary rounded-lg bg-bg-primary overflow-hidden`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2 px-5 py-4 border-b border-border-primary`,children:[(0,Y.jsx)(eX,{className:`h-4 w-48`}),(0,Y.jsx)(eX,{className:`ml-auto h-6 w-6 rounded-full`})]}),(0,Y.jsx)(`div`,{className:`divide-y divide-border-primary`,children:[0,1].map(e=>(0,Y.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,Y.jsx)(eX,{className:`h-3 w-32`}),(0,Y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,Y.jsx)(eX,{className:`h-10 w-full`}),(0,Y.jsx)(eX,{className:`h-10 w-full`})]})]},e))})]},e))]})}function _Ye({authorIds:e,pendingAuthorIds:t,profilesByAuthorIds:n,mode:r,pendingPatchIds:i,deployingCount:a,canDiscard:o,portalContainer:s}){let{deletePatches:c}=RS(),l=X8(t??e,n),u=i.length===0&&a>0,d=u?a:i.length;return(0,Y.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col sm:flex-row sm:items-center gap-2 sm:gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xl font-medium leading-none text-fg-primary tabular-nums`,children:d}),(0,Y.jsx)(`span`,{className:`text-sm text-fg-secondary truncate`,children:u?`${d===1?`change`:`changes`} deploying`:`${d===1?`change`:`changes`} to review`}),(0,Y.jsx)(`span`,{className:`ml-auto sm:hidden`,children:(0,Y.jsx)(_5,{authorIds:e,profilesByAuthorIds:n,mode:r})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 sm:ml-auto border-t border-border-primary pt-2 sm:border-t-0 sm:pt-0`,children:[a>0&&i.length>0&&(0,Y.jsxs)(`span`,{className:`text-xs text-fg-tertiary whitespace-nowrap`,children:[a,` deploying`]}),o&&i.length>0&&(0,Y.jsx)(w5,{description:n8(i.length,l),title:`Discard ${i.length} ${i.length===1?`change`:`changes`}?`,confirmLabel:`Discard ${i.length}`,onConfirm:()=>c(i),portalContainer:s,ariaLabel:`Discard all ${i.length} pending ${i.length===1?`change`:`changes`}`,label:`Discard all`}),o&&i.length===0&&a>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-tertiary whitespace-nowrap`,children:[(0,Y.jsx)(gy,{size:12,"aria-hidden":!0}),`Nothing left to discard`]}),(0,Y.jsx)(`span`,{className:`ml-auto hidden sm:inline-flex`,children:(0,Y.jsx)(_5,{authorIds:e,profilesByAuthorIds:n,mode:r})})]})]})}function vYe(){let{deployments:e}=HS(),t=yce(),n=(0,b.useMemo)(()=>{for(let n of t){let t=e.find(e=>e.commitSha===n);if(t)return t}return null},[e,t]);return(0,Y.jsx)(t5,{deployment:n,commitShas:t})}function t5({deployment:e,commitShas:t=[]}){let[n]=(0,b.useState)(()=>new Date),r=e?.deploymentState,i=r===`created`||r===`pending`,a=r===`failure`||r===`error`,o=r===`success`,s=a?`Published — deploy failed`:i?`Published & deploying`:o?`Published — live`:`Published`,c=t.length>0?t:e?[e.commitSha]:[],l=c.length>1?`${c.length} commits`:c.length===1?`${c[0].slice(0,7)}${e?` · ${Wk(n,e.updatedAt)}`:``}`:null,u=(0,Y.jsx)(`span`,{className:`hidden sm:block h-px flex-1 bg-border-primary`,role:`separator`,"aria-hidden":!0});return(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-0 sm:gap-4`,children:[(0,Y.jsx)(`span`,{className:`block sm:hidden h-px bg-border-primary`,"aria-hidden":!0}),u,(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex items-start sm:items-center gap-2 min-w-0`,`border rounded-lg px-3 py-2 -mt-px`,`sm:rounded-full sm:py-1.5 sm:mt-0 sm:shrink-0`,{"bg-bg-error-secondary border-border-error-secondary text-fg-error-secondary":a,"bg-bg-warning-primary border-border-warning-primary text-fg-warning-primary":i,"bg-bg-brand-primary border-border-brand-primary text-fg-brand-primary":o,"bg-bg-secondary border-border-primary text-fg-secondary":!a&&!i&&!o}),children:[i?(0,Y.jsx)(hy,{size:14,className:`animate-spin shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):a?(0,Y.jsx)(Bv,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):o?(0,Y.jsx)(Fv,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):(0,Y.jsx)(gy,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`flex flex-col sm:flex-row sm:items-center sm:gap-2 min-w-0 text-xs sm:text-[13px]`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:s}),(0,Y.jsxs)(`span`,{className:`opacity-80`,children:[l&&(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[l,` — `]}),`these cannot be discarded`]})]})]}),u]})}function n5(e){let t=[],n=new Set;function r(e){for(let r of e.change?.patchIds??[])n.has(r)||(n.add(r),t.push(r));for(let t of e.children)r(t)}return r(e),t}function r5(e){let t=[],n=new Set,r={};function i(e){if(e.change){for(let r of e.change.authors)n.has(r)||(n.add(r),t.push(r));for(let[t,n]of Object.entries(e.change.patchesByAuthorIds)){r[t]||(r[t]=[]);for(let e of n)r[t].push({createdAt:e.createdAt,opType:e.opType})}}for(let t of e.children)i(t)}return i(e),{authorIds:t,patchesByAuthorIds:r}}function i5({tree:e,profilesByAuthorIds:t,portalContainer:n,mode:r,schemas:i,canDiscard:a}){let o=e.sourcePath,s=i?.[o],c=s?.type===`record`&&!!s.router,[l,u]=(0,b.useState)(!1),{deletePatches:d}=RS(),[f]=(0,b.useState)(()=>new Date),p=jb(o),m=Ab(o),h=p.status===`success`&&m.status===`success`&&Mr(p.data,m.data),g=(0,b.useMemo)(()=>n5(e),[e]),{patchesByAuthorIds:_}=(0,b.useMemo)(()=>r5(e),[e]),v=a&&!e.isCommitted,y={moduleFilePath:o,isRouterModule:c,profilesByAuthorIds:t,portalContainer:n,mode:r,canDiscard:v,isCommitted:e.isCommitted};return(0,Y.jsxs)(`section`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`border rounded-lg overflow-hidden`,e.isCommitted?`border-dashed border-border-primary bg-bg-secondary`:`border-border-primary bg-bg-primary`),children:[(0,Y.jsxs)(`header`,{className:(0,AC.default)(`flex items-center gap-2 px-4 lg:px-5 py-4 border-b min-w-0`,e.isCommitted?`border-dashed border-border-primary`:`border-border-primary`),children:[(0,Y.jsx)(SYe,{moduleFilePath:o}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[e.isCommitted&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-tertiary`,title:`Published — this cannot be discarded`,children:[(0,Y.jsx)(gy,{size:12,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:`Deploying`})]}),v&&g.length>0&&(0,Y.jsx)(y5,{isEqual:h,onDiscard:()=>d(g),confirmDescription:`Discard all changes in this module? This cannot be undone.`,unchangedAriaLabel:`Discard all unchanged in this module`,confirmAriaLabel:`Discard all changes in this module`,portalContainer:n}),Object.keys(_).length>0&&(0,Y.jsx)(Whe,{patchesByAuthorIds:_,profilesByAuthorIds:t,now:f,portalContainer:n,mode:r}),(0,Y.jsx)(v5,{isOpen:!l,onToggle:()=>u(e=>!e),openLabel:`Collapse module`,closedLabel:`Expand module`})]})]}),!l&&(0,Y.jsxs)(`div`,{className:`divide-y divide-border-primary`,children:[e.isCommitted&&(0,Y.jsx)(`p`,{className:`px-4 lg:px-5 py-3 text-xs text-fg-tertiary`,children:`Already part of the published content, so there is no before and after to compare. Open a field to see its current value.`}),(0,Y.jsx)(a5,{node:e,rowProps:y})]})]})}function yYe(e){let t=Cb(e);if(t.status===`loading`)return;if(t.status!==`success`||t.data.type!==`array`)return!1;let n=t.data.item.type;return n===`string`||n===`number`||n===`boolean`}function a5({node:e,rowProps:t}){let n=yYe(e.sourcePath);return n===void 0?null:n?(0,Y.jsx)(CYe,{row:e,...t},e.sourcePath):e.change?e.change.changeType===`added`||e.change.changeType===`removed`?(0,Y.jsx)(c5,{row:e,...t},e.sourcePath):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(c5,{row:e,...t},e.sourcePath),e.children.length>0&&(0,Y.jsx)(s5,{parent:e,rowProps:t})]}):e.children.some(e=>o5(e))?(0,Y.jsx)(s5,{parent:e,rowProps:t}):null}function bYe(e){return H.mediaUrl({path:e})}function o5(e){return e.change?!0:e.children.some(o5)}function xYe(e){let t=[],n=[],r={},i=new Set,a=new Set,o=``,s=null;function c(e){let l=e.change;if(l){for(let e of l.patchIds)i.has(e)||(i.add(e),t.push(e));for(let e of l.authors)a.has(e)||(a.add(e),n.push(e));for(let[e,t]of Object.entries(l.patchesByAuthorIds))r[e]||(r[e]=[]),r[e].push(...t);e.lastUpdated>o&&(o=e.lastUpdated,s=l.lastUpdatedBy)}for(let t of e.children)c(t)}return c(e),{...e,children:[],change:{changeType:e.change?.changeType??`field-change`,patchIds:t,authors:n,lastUpdatedBy:s,patchesByAuthorIds:r}}}function s5({parent:e,rowProps:t}){let n=Cb(e.sourcePath),r=n.status===`success`&&n.data.type===`record`?n.data.mediaType:void 0;return r?(0,Y.jsx)(Y.Fragment,{children:e.children.filter(e=>o5(e)).map(e=>(0,Y.jsx)(c5,{row:xYe(e),...t,parentMediaType:r},e.sourcePath))}):(0,Y.jsx)(Y.Fragment,{children:e.children.filter(e=>o5(e)).map(e=>(0,Y.jsx)(a5,{node:e,rowProps:t},e.sourcePath))})}function SYe({moduleFilePath:e}){let t=H.splitModuleFilePath(e),n=E8(e);return(0,Y.jsx)(`h2`,{className:`text-sm font-medium text-fg-primary truncate min-w-0`,children:(0,Y.jsx)(`a`,{...n,title:e,className:`flex items-center gap-1.5 min-w-0 rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:t.map((e,n)=>(0,Y.jsxs)(b.Fragment,{children:[n>0&&(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,"aria-hidden":!0,children:`/`}),(0,Y.jsx)(`span`,{className:(0,AC.default)({"text-fg-secondary":n<t.length-1}),children:kC(e)})]},`${e}-${n}`))})})}function CYe({row:e,moduleFilePath:t,isRouterModule:n,profilesByAuthorIds:r,portalContainer:i,mode:a,canDiscard:o,isCommitted:s}){let{deletePatches:c}=RS(),[l]=(0,b.useState)(()=>new Date),[u,d]=(0,b.useState)(!0),f=e.sourcePath,p=jb(f),m=Ab(f),h=!s&&p.status===`success`&&m.status===`success`&&Mr(p.data,m.data),g=(0,b.useMemo)(()=>n5(e),[e]),{patchesByAuthorIds:_}=(0,b.useMemo)(()=>r5(e),[e]),[,v]=H.splitModuleFilePathAndModulePath(f),y=v?H.splitModulePath(v):[],x=n&&y.length===1,S=y[y.length-1]??``;return g.length===0?null:(0,Y.jsxs)(`article`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`px-5 py-5`,{"opacity-60":h}),children:[(0,Y.jsx)(l5,{sourcePath:f,changeType:`field-change`,segment:S,modulePath:v,moduleFilePath:t,isRouterPageKey:x,patchesByAuthorIds:_,profilesByAuthorIds:r,portalContainer:i,mode:a,now:l,onDiscard:()=>c(g),isExpanded:u,onToggleExpand:()=>d(e=>!e),isEqual:h,canDiscard:o,hideExpand:s}),u&&!s&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(sYe,{sourcePath:f})})]})}function c5({row:e,moduleFilePath:t,isRouterModule:n,profilesByAuthorIds:r,portalContainer:i,mode:a,canDiscard:o,isCommitted:s,parentMediaType:c}){let{deletePatches:l}=RS(),[u]=(0,b.useState)(()=>new Date),d=e.change,[f,p]=(0,b.useState)(d?.changeType!==`removed`),m=e.sourcePath,h=jb(m),g=Ab(m);if(!d)return null;let _=!s&&d.changeType===`field-change`&&h.status===`success`&&g.status===`success`&&Mr(h.data,g.data),[,v]=H.splitModuleFilePathAndModulePath(m),y=v?H.splitModulePath(v):[],x=n&&y.length===1,S=y[y.length-1]??``,C={};for(let[e,t]of Object.entries(d.patchesByAuthorIds))C[e]=t.map(e=>({createdAt:e.createdAt,opType:e.opType}));return(0,Y.jsxs)(`article`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`px-5 py-5`,{"opacity-60":_,"bg-bg-error-secondary/30":d.changeType===`removed`,"bg-bg-brand-primary/5":d.changeType===`added`}),children:[(0,Y.jsx)(l5,{sourcePath:m,changeType:d.changeType,segment:S,modulePath:v,moduleFilePath:t,isRouterPageKey:x,patchesByAuthorIds:C,profilesByAuthorIds:r,portalContainer:i,mode:a,now:u,onDiscard:()=>l(d.patchIds),isExpanded:f,onToggleExpand:()=>p(e=>!e),isEqual:_,canDiscard:o,hideExpand:s,parentMediaType:c}),!s&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(DYe,{sourcePath:m,changeType:d.changeType,isExpanded:f,isEqual:_,parentMediaType:c})})]})}function l5({sourcePath:e,changeType:t,segment:n,modulePath:r,moduleFilePath:i,isRouterPageKey:a,patchesByAuthorIds:o,profilesByAuthorIds:s,portalContainer:c,mode:l,now:u,onDiscard:d,isExpanded:f,onToggleExpand:p,isEqual:m,canDiscard:h,hideExpand:g,parentMediaType:_}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(EYe,{changeType:t,isEqual:m}),(0,Y.jsx)(wYe,{sourcePath:e,segment:n,modulePath:r,moduleFilePath:i,isRouterPageKey:a,parentMediaType:_}),(0,Y.jsx)(TYe,{changeType:t,isEqual:m}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[h&&(0,Y.jsx)(y5,{isEqual:m,onDiscard:d,confirmDescription:`Discard this change? This cannot be undone.`,unchangedAriaLabel:`Discard unchanged`,confirmAriaLabel:`Discard this change`,portalContainer:c}),(0,Y.jsx)(Whe,{patchesByAuthorIds:o,profilesByAuthorIds:s,now:u,portalContainer:c,mode:l}),!g&&(0,Y.jsx)(v5,{isOpen:f,onToggle:p,openLabel:`Collapse`,closedLabel:`Expand`})]})]})}function wYe({sourcePath:e,segment:t,modulePath:n,moduleFilePath:r,isRouterPageKey:i,parentMediaType:a}){let o=(()=>{if(a){let{filename:e,folder:n}=pS(t);return n===`/`?`/${e}`:`${n}/${e}`}return n?i?t:lD(n):kC(H.splitModuleFilePath(r).pop()??``)})();return(0,Y.jsx)(V8,{sourcePath:e,previewSegment:i&&!a&&n?t:void 0,className:`min-w-0`,children:o})}function TYe({changeType:e,isEqual:t}){return t?(0,Y.jsx)(`span`,{className:`text-sm text-fg-tertiary px-1.5 py-0.5 rounded bg-bg-secondary shrink-0`,children:`Unchanged`}):e===`added`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-brand-primary shrink-0`,children:`Added`}):e===`removed`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-error shrink-0`,children:`Removed`}):e===`moved`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-warning shrink-0`,children:`Moved`}):null}function EYe({changeType:e,isEqual:t}){if(t)return(0,Y.jsx)(Xv,{size:14,className:`shrink-0 text-fg-tertiary`,"aria-label":`Unchanged`});switch(e){case`added`:return(0,Y.jsx)(Oy,{size:14,className:`shrink-0 text-fg-brand-primary`,"aria-label":`Added`});case`removed`:return(0,Y.jsx)(yy,{size:14,className:`shrink-0 text-fg-error`,"aria-label":`Removed`});case`moved`:return(0,Y.jsx)(Av,{size:14,className:`shrink-0 text-fg-warning`,"aria-label":`Moved`});case`field-change`:return(0,Y.jsx)(Dy,{size:14,className:`shrink-0 text-fg-secondary`,"aria-label":`Edited`})}}function DYe({sourcePath:e,changeType:t,isExpanded:n,isEqual:r,parentMediaType:i}){return i?(0,Y.jsx)(kYe,{sourcePath:e,changeType:t,mediaType:i,isExpanded:n,isEqual:r}):t===`field-change`?(0,Y.jsx)(jYe,{sourcePath:e,isExpanded:n,isEqual:r}):n?t===`added`?(0,Y.jsx)(m5,{sourcePath:e,side:`after`,diffStyle:`added`}):t===`removed`?(0,Y.jsx)(AYe,{sourcePath:e}):(0,Y.jsx)(m5,{sourcePath:e,side:`after`,diffStyle:`added`}):null}function u5(e){if(e&&typeof e.hotspot==`object`&&e.hotspot!==null&&`x`in e.hotspot&&`y`in e.hotspot){let t=e.hotspot;if(typeof t.x==`number`&&typeof t.y==`number`)return{x:t.x,y:t.y}}}function d5({metadata:e}){let t=[];return e&&(typeof e.mimeType==`string`&&t.push({label:`mimeType`,value:e.mimeType}),typeof e.width==`number`&&typeof e.height==`number`&&t.push({label:`dimensions`,value:`${e.width} × ${e.height}`})),t.length===0?null:(0,Y.jsx)(`dl`,{className:`mt-4 text-xs text-fg-secondary grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:t.map(e=>(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-fg-tertiary`,children:e.label}),(0,Y.jsx)(`dd`,{className:`truncate`,children:e.value})]},e.label))})}function f5({sourcePath:e,showValidation:t=!1}){let n=H.createValPathOfItem(e,`alt`),r=Cb(n);return r.status===`success`?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium mb-1 block`,children:`Alt`}),(0,Y.jsx)(r6,{path:n,schema:r.data,readonly:!0,errorDisplay:t?`compact`:`none`})]}):null}function p5({url:e,filename:t,diffStyle:n,hotspot:r}){return e?(0,Y.jsxs)(`div`,{className:`w-[120px] flex-shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`relative w-[120px] h-[90px]`,children:[(0,Y.jsx)(`img`,{src:e,alt:t,draggable:!1,className:(0,AC.default)(`w-full h-full object-cover rounded border border-border-primary`,{"opacity-40":n===`removed`}),style:r?{objectPosition:`${r.x*100}% ${r.y*100}%`}:void 0}),r&&(0,Y.jsx)(sA,{hotspot:r,size:`sm`})]}),r&&(0,Y.jsxs)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:[`hotspot `,Math.round(r.x*100),`%, `,Math.round(r.y*100),`%`]})]}):(0,Y.jsxs)(`div`,{className:`w-[120px] flex-shrink-0`,children:[(0,Y.jsx)(`div`,{className:`w-[120px] h-[90px] rounded bg-bg-secondary flex items-center justify-center text-fg-disabled text-xs`,children:`No preview`}),r&&(0,Y.jsxs)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:[`hotspot `,Math.round(r.x*100),`%,`,` `,Math.round(r.y*100),`%`]})]})}function OYe(e){return(0,b.useMemo)(()=>{let[,t]=H.splitModuleFilePathAndModulePath(e),n=t?H.splitModulePath(t):[];return n[n.length-1]??``},[e])}function kYe({sourcePath:e,changeType:t,mediaType:n,isExpanded:r,isEqual:i}){let a=OYe(e),o=Mb(),s=n===`images`,c=Ab(e),l=jb(e),u=c.status===`success`?c.data:null,d=l.status===`success`?l.data:null,f=u5(u),p=u5(d),m=s?rA(a,o):null,h=Dse(a);if(!r&&t!==`field-change`)return null;if(i&&t===`field-change`)return(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(`div`,{className:`border-l-[3px] border-border-secondary pl-3 pr-1 py-2 min-w-0`,children:(0,Y.jsx)(C5,{isImage:s,url:m,filename:h,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})});if(t===`added`||t===`moved`)return r?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`added`,children:(0,Y.jsx)(C5,{isImage:s,url:m,filename:h,diffStyle:`added`,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})}):null;if(t===`removed`){if(!r)return null;let t=s?bYe(a):null;return(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`removed`,children:(0,Y.jsx)(C5,{isImage:s,url:t,filename:h,diffStyle:`removed`,hotspot:p,metadata:d,sourcePath:e})})})})}if(!r)return null;let g=l.status===`success`;return g&&l.data===null||!g?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`added`,children:(0,Y.jsx)(C5,{isImage:s,url:m,filename:h,diffStyle:`added`,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})}):(0,Y.jsxs)(`div`,{className:`border-l-[3px] border-fg-brand-primary pl-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[s&&(0,Y.jsx)(p5,{url:m,filename:h,hotspot:f}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(x5,{variant:`media`,before:(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(f5,{sourcePath:e})}),after:(0,Y.jsx)(f5,{sourcePath:e,showValidation:!0})})})]}),(0,Y.jsx)(d5,{metadata:u})]})}function AYe({sourcePath:e}){return(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(m5,{sourcePath:e,side:`after`,diffStyle:`removed`})})}function jYe({sourcePath:e,isExpanded:t,isEqual:n}){let r=roe(e),i=r.status===`success`?r.resolvedPath:e,a=jb(i);if(r.status!==`success`)return null;let o=r.data,s=a.status===`success`,c=s&&a.data===null;return t?n?(0,Y.jsx)(x5,{variant:`equal`,before:(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}),after:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`compact`})}):c||!s?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`added`,children:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})})}):(0,Y.jsx)(x5,{variant:`changed`,before:(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}),after:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})}):null}function m5({sourcePath:e,side:t,diffStyle:n}){let[r]=(0,b.useMemo)(()=>H.splitModuleFilePathAndModulePath(e),[e]),i=jb(r),a=(0,b.useMemo)(()=>i.status===`success`?{moduleFilePath:r,moduleSource:i.data}:null,[r,i]);return t===`before`?(0,Y.jsx)(lb.Provider,{value:a,children:(0,Y.jsx)(h5,{sourcePath:e,diffStyle:n})}):(0,Y.jsx)(h5,{sourcePath:e,diffStyle:n})}function h5({sourcePath:e,diffStyle:t}){let n=Cb(e);if(n.status!==`success`)return null;let r=n.data;return(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:t,children:t===`removed`?(0,Y.jsx)(`div`,{className:`[&_div]:decoration-fg-error [&_pre]:decoration-fg-error line-through decoration-fg-error`,children:(0,Y.jsx)(r6,{path:e,schema:r,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}):(0,Y.jsx)(r6,{path:e,schema:r,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})})})}function g5({diffStyle:e,children:t}){return(0,Y.jsx)(`div`,{className:(0,AC.default)(`border-l-[3px] pl-3 pr-1 py-2 min-w-0`,{"border-fg-error":e===`removed`,"border-fg-brand-primary":e===`added`}),children:t})}function _5({authorIds:e,profilesByAuthorIds:t,mode:n}){if(e.length===0)return null;let r=e.slice(0,9),i=e.length-r.length;return(0,Y.jsxs)(`div`,{className:`flex items-center`,"aria-label":`Authors`,children:[r.map((e,r)=>(0,Y.jsx)(MYe,{profile:t[e]??null,isFirst:r===0,mode:n},e)),i>0&&(0,Y.jsxs)(`span`,{className:`-ml-2 w-7 h-7 rounded-full inline-flex items-center justify-center text-[11px] font-semibold bg-bg-secondary text-fg-secondary border-2 border-bg-primary`,"aria-label":`${i} more authors`,children:[`+`,i]})]})}function MYe({profile:e,isFirst:t,mode:n}){let r=(0,AC.default)(`shrink-0 w-7 h-7 rounded-full inline-flex items-center justify-center text-[11px] font-semibold overflow-hidden border-2 border-bg-primary`,{"-ml-2":!t});return e?e.avatar?.url?(0,Y.jsx)(`img`,{src:e.avatar.url,alt:e.fullName,title:e.fullName,className:(0,AC.default)(r,`object-cover`)}):(0,Y.jsx)(`span`,{className:(0,AC.default)(r,`bg-bg-brand-primary text-fg-brand-primary`),title:e.fullName,children:zhe(e.fullName)}):(0,Y.jsx)(`span`,{className:(0,AC.default)(r,`bg-bg-secondary text-fg-disabled`),title:n===`fs`?`Local changes`:`Unknown author`,children:n===`fs`?(0,Y.jsx)(jy,{size:12}):(0,Y.jsx)(Vy,{size:12})})}function v5({isOpen:e,onToggle:t,openLabel:n,closedLabel:r}){return(0,Y.jsx)(`button`,{onClick:t,className:(0,AC.default)(`size-5 flex items-center justify-center text-fg-secondary hover:text-fg-primary transition-transform`,{"rotate-180":e}),"aria-label":e?n:r,children:(0,Y.jsx)(Iv,{size:14})})}function y5({isEqual:e,onDiscard:t,confirmDescription:n,unchangedAriaLabel:r,confirmAriaLabel:i,portalContainer:a}){return e?(0,Y.jsx)(t_,{variant:`default`,size:`icon-sm`,onClick:t,"aria-label":r,children:(0,Y.jsx)(zy,{size:14})}):(0,Y.jsx)(w5,{description:n,onConfirm:t,portalContainer:a,ariaLabel:i})}function b5({sourcePath:e,children:t}){let[n]=(0,b.useMemo)(()=>H.splitModuleFilePathAndModulePath(e),[e]),r=jb(n),i=(0,b.useMemo)(()=>r.status===`success`?{moduleFilePath:n,moduleSource:r.data}:null,[n,r]);return(0,Y.jsx)(lb.Provider,{value:i,children:t})}function x5({variant:e,before:t,after:n}){if(e===`media`)return(0,Y.jsxs)(`div`,{className:`grid gap-3 lg:gap-0 lg:grid-cols-[minmax(0,1fr)_24px_minmax(0,1fr)] items-start`,children:[(0,Y.jsxs)(`div`,{className:`pr-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-tertiary mb-1`,children:`Before`}),t]}),(0,Y.jsx)(`div`,{className:`hidden lg:flex items-center justify-center text-fg-tertiary pt-3`,"aria-hidden":!0,children:(0,Y.jsx)(Av,{size:14})}),(0,Y.jsxs)(`div`,{className:`pl-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-tertiary mb-1`,children:`After`}),n]})]});let r=e===`equal`?`border-border-secondary`:`border-fg-brand-primary`,i=e===`equal`?Xv:Av;return(0,Y.jsxs)(`div`,{className:`grid gap-3 lg:gap-0 lg:grid-cols-[minmax(0,1fr)_24px_minmax(0,1fr)] items-stretch`,children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`border-l-[3px] pl-3 pr-12 lg:pr-1 py-2 min-w-0`,r),children:[(0,Y.jsx)(S5,{children:`Before`}),t]}),(0,Y.jsx)(`div`,{className:`hidden lg:flex items-center justify-center text-fg-tertiary`,"aria-hidden":!0,children:(0,Y.jsx)(i,{size:14})}),(0,Y.jsxs)(`div`,{className:`pl-4 lg:pl-1 pr-3 py-2 min-w-0`,children:[(0,Y.jsx)(S5,{children:`After`}),n]})]})}function S5({children:e}){return(0,Y.jsx)(`div`,{className:`lg:hidden text-[10px] uppercase tracking-wider font-medium text-fg-tertiary mb-1`,children:e})}function C5({isImage:e,url:t,filename:n,hotspot:r,diffStyle:i,metadata:a,sourcePath:o,showValidation:s}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[e&&(0,Y.jsx)(p5,{url:t,filename:n,diffStyle:i,hotspot:r}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(f5,{sourcePath:o,showValidation:s})})]}),(0,Y.jsx)(d5,{metadata:a})]})}function w5({description:e,title:t,confirmLabel:n,onConfirm:r,portalContainer:i,ariaLabel:a,label:o}){let[s,c]=(0,b.useState)(!1);return(0,Y.jsxs)(SD,{open:s,onOpenChange:c,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:o?`sm`:`icon-sm`,"aria-label":a,className:o?`gap-2`:void 0,children:[(0,Y.jsx)(zy,{size:14}),o&&(0,Y.jsx)(`span`,{children:o})]})}),(0,Y.jsxs)(wD,{container:i,className:`w-[calc(100vw-24px)] sm:w-auto sm:max-w-xs p-3`,side:`bottom`,align:`end`,children:[t&&(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-sm font-medium text-fg-primary mb-1.5`,children:[(0,Y.jsx)(Bv,{size:15,className:`shrink-0 mt-0.5 text-fg-error-on-surface`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:t})]}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-secondary mb-3`,children:e}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:flex sm:items-center sm:justify-end`,children:[(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>c(!1),children:`Cancel`}),(0,Y.jsx)(t_,{variant:`destructive`,size:`sm`,onClick:()=>{r(),c(!1)},children:n??`Discard`})]})]})]})}function T5(e){let t=[];if(e.change&&t.push(e),!e.change||e.change.changeType!==`added`&&e.change.changeType!==`removed`)for(let n of e.children)for(let e of T5(n))t.push(e);return t}function NYe(){let e=eb();return(0,Y.jsx)(Uy,{open:!0,modal:!0,children:(0,Y.jsxs)(Wy,{children:[(0,Y.jsx)(Gy,{}),(0,Y.jsxs)(Ky,{container:e,"aria-label":`Login required`,className:`bg-bg-secondary text-fg-secondary`,children:[(0,Y.jsx)(qy,{children:(0,Y.jsx)(Yy,{children:(0,Y.jsx)(`span`,{children:`Log in required`})})}),(0,Y.jsx)(Xy,{children:`You need to log in to access Val.`}),(0,Y.jsx)(t_,{asChild:!0,children:(0,Y.jsx)(`a`,{href:Jf(`/api/val/authorize`,{redirect_to:window.origin+Jf(`/val`)}),children:`Log in`})})]})]})})}function E5({code:e}){return(0,Y.jsxs)(`div`,{className:`relative bg-bg-secondary rounded-md p-4 pr-16 my-4`,children:[(0,Y.jsx)(`pre`,{className:`text-xs overflow-x-auto `,children:(0,Y.jsx)(`code`,{children:e})}),(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,className:`absolute top-2 right-2`,onClick:()=>{navigator.clipboard.writeText(e)},children:(0,Y.jsx)(qv,{size:16,className:`mr-2`})})]})}function PYe({moduleFilePath:e,patchPath:t,className:n,toolTip:r=!0,link:i=!0}){let a=bb(),o=(0,b.useRef)(null),s=(0,b.useRef)(new Map),[c,l]=(0,b.useState)([]),[u,d]=(0,b.useState)(),f=Eb(),p=wb(),{navigate:m}=GC();(0,b.useEffect)(()=>{let n=e?H.splitModuleFilePath(e):[],r=t,i=()=>{if(!o.current)return;let t=o.current,i=getComputedStyle(t),a=`${i.fontSize} ${i.fontFamily}`,c=t.offsetWidth,u=n.map(FYe).concat(r).map(e=>`/${e}`);d(u.join(``));let f=e=>{let t=`${e}:${a}`,n=s.current.get(t)??IYe(e,a);return s.current.set(t,n),n},p=`/…`,m=f(p),h=[],g=0;for(let t=u.length-1;t>=0;t--){let i=f(u[t]),a=t!==0;if(g+i+(a?m:0)<=c){let a=t>n.length?`module-path`:`module-file-path`;h.unshift({text:u[t],type:a,moduleFilePath:e,modulePathSegments:r.slice(0,t)}),g+=i}else{h.unshift({type:`ellipsis`,text:p});break}}l(h)},a=new ResizeObserver(i);return o.current&&(a.observe(o.current),i()),()=>{o.current&&a.unobserve(o.current)}},[e,t]);let h=(0,b.useMemo)(()=>{if(!i)return null;let n=`data`in p?p.data:{};if(t.length===0){let t=e;return{navPath:t,sourcePath:t}}let r=rb(t,n[e],f[e]);if(r.success){let i=H.joinModuleFilePathAndModulePath(e,r.modulePath),a=ob(i,f,n);if(a)return{navPath:a,scrollToPath:i};console.debug(`Failed to resolve nav path for ${e} and ${t.join(`.`)}: ${a}`)}else console.debug(`Failed to resolve source path for ${e} and ${t.join(`.`)}: ${r.error}`);return null},[e,t,f,p]);return(0,Y.jsxs)(Jg,{open:r!==!1&&void 0,children:[(0,Y.jsx)(hg,{asChild:!0,children:(0,Y.jsx)(`a`,{href:h&&a?`${a.studioPrefix}${h.navPath}${h.scrollToPath?`#${encodeURIComponent(h.scrollToPath)}`:``}`:void 0,ref:o,className:(0,AC.default)(`inline-block whitespace-nowrap overflow-hidden w-full align-baseline`,{"cursor-pointer hover:underline":i},n),onClick:e=>{i&&h&&e.metaKey===!1&&e.ctrlKey===!1&&e.shiftKey===!1&&(e.preventDefault(),m(h.navPath,{scrollToPath:h.scrollToPath}))},children:c.map((e,t)=>(0,Y.jsx)(`span`,{children:e.text},t))})}),(0,Y.jsx)(Xg,{side:`top`,children:(0,Y.jsx)(eD,{orientation:`horizontal`,className:`max-w-[calc(100vw-3rem)] whitespace-nowrap`,children:u})})]})}function FYe(e){let t=kC(e);return t.slice(0,1).toUpperCase()+t.slice(1)}function IYe(e,t){let n=document.createElement(`canvas`).getContext(`2d`);return n?(n.font=t,n.measureText(e).width):0}function LYe(){let{patchErrors:e}=oC(),{deletePatches:t}=RS(),{navigate:n}=GC(),r=sC(),i=US(),a=eb(),o=QS(),[s,c]=(0,b.useState)(!1),l=(0,b.useMemo)(()=>zYe(e,`data`in i?i.data:void 0),[e,i]),u=(0,b.useMemo)(()=>JSON.stringify({mode:o,changes:l},null,2),[o,l]),d=l.map(e=>e.patchId).join(`|`),[f,p]=(0,b.useState)(d);return f!==d&&(p(d),c(!1)),l.length===0?null:(0,Y.jsx)(Uy,{open:!s,onOpenChange:e=>{c(!e)},children:(0,Y.jsxs)(Ky,{container:a,className:`max-w-2xl`,children:[(0,Y.jsxs)(qy,{children:[(0,Y.jsxs)(Yy,{className:`flex gap-2 items-center`,children:[(0,Y.jsx)(Ly,{size:18}),(0,Y.jsxs)(`span`,{children:[l.length,` change`,l.length===1?``:`s`,` cannot be applied`]})]}),(0,Y.jsx)(Xy,{children:`These changes conflict with newer ones, so they can no longer be applied to the content. Nothing can be published until they are removed. Removing a change discards only that edit.`})]}),(0,Y.jsx)(eD,{className:`max-h-[40vh]`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:l.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 rounded-md border border-border-primary`,children:[(0,Y.jsx)(`div`,{className:`text-sm`,children:e.patchPath?(0,Y.jsx)(PYe,{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath}):(0,Y.jsx)(`span`,{children:e.moduleFilePath})}),(0,Y.jsx)(`div`,{className:`text-xs text-fg-secondary`,children:[e.author?r[e.author]?.fullName??e.author:null,e.createdAt?Wk(new Date,e.createdAt):null].filter(e=>e!==null).join(` · `)}),(0,Y.jsx)(`div`,{className:`text-xs text-fg-error-primary`,children:e.message}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(t_,{variant:`destructive`,size:`sm`,onClick:()=>{t([e.patchId])},children:(0,Y.jsxs)(`span`,{className:`flex gap-2 items-center`,children:[(0,Y.jsx)(`span`,{children:`Remove change`}),(0,Y.jsx)(zy,{size:14})]})}),(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>{c(!0),n(`/val/compare`,{scrollToPath:RYe(e)})},children:`Review in compare`})]})]},e.patchId))})}),(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{className:`text-xs cursor-pointer text-fg-secondary`,children:`Diagnosis for Val developers`}),(0,Y.jsx)(E5,{code:u})]}),(0,Y.jsx)(Jy,{children:(0,Y.jsxs)(t_,{variant:`destructive`,onClick:()=>{t(l.map(e=>e.patchId))},children:[`Remove all `,l.length,` and continue`]})})]})})}function RYe(e){return!e.patchPath||e.patchPath.length===0?e.moduleFilePath:H.joinModuleFilePathAndModulePath(e.moduleFilePath,H.patchPathToModulePath(e.patchPath))}function zYe(e,t){if(!e)return[];let n=new Map;for(let e of t??[])for(let t of e.patches)n.set(t.patchId,{author:t.author,createdAt:t.createdAt,patchPath:e.patchPath});let r=[];for(let[t,i]of Object.entries(e))if(i)for(let[e,a]of Object.entries(i)){let i=e,o=n.get(i);r.push({patchId:i,moduleFilePath:t,message:a.message,author:o?.author??null,createdAt:o?.createdAt??null,patchPath:o?.patchPath??null})}return r.sort((e,t)=>(e.createdAt??``).localeCompare(t.createdAt??``))}function BYe({value:e}){return console.warn(`Exhaustive check failed for value:`,e),null}function VYe(){let e=Fce();return e===null?null:e.type===`network-error`?(0,Y.jsx)(D5,{children:`Network error - retrying...`}):e.type===`schema-error`?(0,Y.jsx)(D5,{children:`Schema error - check your console for details`}):e.type===`profiles-auth-error`?(0,Y.jsx)(D5,{children:`Could not authenticate with your personal access token while getting profiles.`}):e.type===`remote-files-error`?(0,Y.jsx)(HYe,{error:e}):(0,Y.jsx)(BYe,{value:e})}function D5({children:e}){return(0,Y.jsx)(`div`,{role:`status`,className:`fixed inset-x-0 top-0 z-full p-4 text-center text-fg-error-primary bg-bg-error-primary`,children:e})}function HYe({error:e}){let t=eb();return(0,Y.jsx)(Uy,{defaultOpen:!0,children:(0,Y.jsxs)(Wy,{children:[(0,Y.jsx)(Gy,{}),(0,Y.jsxs)(Ky,{container:t,className:`max-w-lg p-6 rounded-lg bg-bg-primary text-fg-primary`,children:[(0,Y.jsx)(Yy,{className:`text-lg font-medium mb-4`,children:`Personal access token file required`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{children:`This project uses remote files, which means you need to be authenticated to update them.`}),(0,Y.jsx)(`p`,{children:`To do this locally in this dev environment, you need a Personal Access Token (PAT) stored in a file.`}),(0,Y.jsx)(`p`,{children:`Run the command in the root directory of your project to create the token file.`})]}),(0,Y.jsx)(E5,{code:`npx -p @valbuild/cli val login`}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(zk,{type:`multiple`,children:[(0,Y.jsxs)(Bk,{value:`why-pat`,children:[(0,Y.jsx)(Vk,{children:`Why a personal token file?`}),(0,Y.jsxs)(Hk,{children:[(0,Y.jsx)(`p`,{children:`You are using remote files, which require authentication. In local development, Val uses a personal access token (PAT) to authenticate and allow you to update remote files.`}),(0,Y.jsx)(`p`,{children:`You can create it by running the command shown above, which will create a PAT file.`}),(0,Y.jsx)(`p`,{children:`If you have the PAT already, check that you have internet access and that the project is setup correctly in https://admin.val.build, as issues with either of those could also cause this error.`})]})]}),(0,Y.jsxs)(Bk,{value:`details`,children:[(0,Y.jsx)(Vk,{children:`More details`}),(0,Y.jsx)(Hk,{children:(0,Y.jsxs)(`p`,{children:[`The underlying error message was: "`,e.error,`".`]})})]})]})})]})]})})}function UYe(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var WYe=e=>{switch(e){case`success`:return qYe;case`info`:return YYe;case`warning`:return JYe;case`error`:return XYe;default:return null}},GYe=Array(12).fill(0),KYe=({visible:e,className:t})=>b.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},b.createElement(`div`,{className:`sonner-spinner`},GYe.map((e,t)=>b.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),qYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),JYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),YYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),XYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),ZYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`},b.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),b.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),QYe=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},$Ye=1,eXe=100,O5=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:$Ye++,k5=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-eXe;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{let{message:t,...n}=e,r=O5(e),i=this.pendingDismissals.get(r);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));let a=this.dismissedToasts.has(r),o=e.dismissible===void 0||e.dismissible;return a&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(e=>e.id!==r)),!a&&this.toasts.find(e=>e.id===r)?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:o,title:t}):n):this.addToast({title:t,...n,dismissible:o,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(e=>{this.dismissedToasts.add(e.id),this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);let t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(t=>t({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],b.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(nXe(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=O5(t);return this.create({...t,jsx:e(n),id:n,type:void 0}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},tXe=(e,t)=>k5.message(e,t),nXe=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,rXe=Object.assign(tXe,{success:k5.success,info:k5.info,warning:k5.warning,error:k5.error,custom:k5.custom,message:k5.message,promise:k5.promise,dismiss:k5.dismiss,loading:k5.loading},{getHistory:()=>k5.toasts,getToasts:()=>k5.getActiveToasts()});UYe(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function A5(e){return e.label!==void 0}var iXe=3,aXe=`24px`,oXe=`16px`,j5=4e3,sXe=356,cXe=14,lXe=45,uXe=200;function M5(...e){return e.filter(Boolean).join(` `)}function dXe(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var fXe=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:x,gap:S,expandByDefault:C,classNames:w,icons:T,closeButtonAriaLabel:E=`Close toast`}=e,[D,O]=b.useState(null),[k,A]=b.useState(null),[j,M]=b.useState(!1),[N,P]=b.useState(!1),[F,I]=b.useState(!1),[L,R]=b.useState(!1),[ee,te]=b.useState(!1),[ne,re]=b.useState(0),[ie,ae]=b.useState(0),oe=b.useRef(n.duration||y||j5),se=b.useRef(null),ce=b.useRef(null),le=c===0,ue=c+1<=o,de=n.type,fe=de??`default`,pe=n.dismissible!==!1,me=n.className||``,he=n.descriptionClassName||``,ge=b.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),_e=b.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ve=b.useMemo(()=>n.duration||y||j5,[n.duration,y]),ye=b.useRef(0),be=b.useRef(0),xe=b.useRef(0),Se=b.useRef(null),[Ce,we]=x.split(`-`),z=b.useMemo(()=>s.reduce((e,t,n)=>n>=ge?e:e+t.height,0),[s,ge]),B=QYe(),Te=b.useMemo(()=>e.swipeDirections??dXe(x),[e.swipeDirections,x]),Ee=n.invert||t,V=de===`loading`;be.current=b.useMemo(()=>ge*S+z,[ge,z]),b.useEffect(()=>{oe.current=ve},[ve]),b.useEffect(()=>{M(!0)},[]),b.useEffect(()=>{let e=ce.current;if(e){let t=e.getBoundingClientRect().height;return ae(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),b.useLayoutEffect(()=>{if(!j)return;let e=ce.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ae(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[j,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let De=b.useCallback(()=>{P(!0),re(be.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},uXe)},[n,d,a,be]);b.useEffect(()=>{if(n.promise&&de===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||B?(()=>{if(xe.current<ye.current){let e=new Date().getTime()-ye.current;oe.current-=e}xe.current=new Date().getTime()})():oe.current!==1/0&&(ye.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),De()},oe.current)),()=>clearTimeout(e)},[u,i,n,de,B,De]),b.useEffect(()=>{n.delete&&(De(),n.onDismiss==null||n.onDismiss.call(n,n))},[De,n.delete]);function Oe(){return T?.loading?b.createElement(`div`,{className:M5(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":de===`loading`},T.loading):b.createElement(KYe,{className:M5(w?.loader,n?.classNames?.loader),visible:de===`loading`})}let ke=n.icon||T?.[de]||WYe(de);return b.createElement(`li`,{tabIndex:0,ref:ce,className:M5(_,me,w?.toast,n?.classNames?.toast,w?.[fe],n?.classNames?.[fe]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":j,"data-promise":!!n.promise,"data-swiped":ee,"data-removed":N,"data-visible":ue,"data-y-position":Ce,"data-x-position":we,"data-index":c,"data-front":le,"data-swiping":F,"data-dismissible":pe,"data-type":de,"data-invert":Ee,"data-swipe-out":L,"data-swipe-direction":k,"data-expanded":!!(u||C&&j),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${N?ne:be.current}px`,"--initial-height":C?`auto`:`${ie}px`,...m,...n.style},onDragEnd:()=>{I(!1),O(null),Se.current=null},onPointerDown:e=>{e.button!==2&&(V||!pe||(se.current=new Date,re(be.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(I(!0),Se.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(L||!pe)return;Se.current=null;let e=Number(ce.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(ce.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-se.current?.getTime(),i=D===`x`?e:t,a=Math.abs(i)/r;if((D===`x`?Te.includes(e>0?`right`:`left`):Te.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=lXe||a>.11)){re(be.current),n.onDismiss==null||n.onDismiss.call(n,n),A(D===`x`?e>0?`right`:`left`:t>0?`down`:`up`),De(),R(!0);return}var o,s;(o=ce.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=ce.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),te(!1),I(!1),O(null)},onPointerMove:e=>{var t,n;if(!Se.current||!pe||window.getSelection()?.toString().length>0)return;let r=e.clientY-Se.current.y,i=e.clientX-Se.current.x;!D&&(Math.abs(i)>1||Math.abs(r)>1)&&O(Math.abs(i)>Math.abs(r)?`x`:`y`);let a={x:0,y:0},o=e=>1/(1.5+Math.abs(e)/20);if(D===`y`){if(Te.includes(`top`)||Te.includes(`bottom`)){if(Te.includes(`top`)&&r<0||Te.includes(`bottom`)&&r>0)a.y=r;else{let e=r*o(r);a.y=Math.abs(e)<Math.abs(r)?e:r}}}else if(D===`x`&&(Te.includes(`left`)||Te.includes(`right`))){if(Te.includes(`left`)&&i<0||Te.includes(`right`)&&i>0)a.x=i;else{let e=i*o(i);a.x=Math.abs(e)<Math.abs(i)?e:i}}(Math.abs(a.x)>0||Math.abs(a.y)>0)&&te(!0),(t=ce.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=ce.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},_e&&!n.jsx&&de!==`loading`?b.createElement(`button`,{"aria-label":E,"data-disabled":V,"data-close-button":!0,onClick:V||!pe?()=>{}:()=>{De(),n.onDismiss==null||n.onDismiss.call(n,n)},className:M5(w?.closeButton,n?.classNames?.closeButton)},T?.close??ZYe):null,(de||n.icon||n.promise)&&n.icon!==null&&(T?.[de]!==null||n.icon)?b.createElement(`div`,{"data-icon":``,className:M5(w?.icon,n?.classNames?.icon)},de===`loading`?n.icon||Oe():n.promise?Oe():null,de===`loading`?null:ke):null,b.createElement(`div`,{"data-content":``,className:M5(w?.content,n?.classNames?.content)},b.createElement(`div`,{"data-title":``,className:M5(w?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?b.createElement(`div`,{"data-description":``,className:M5(v,he,w?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),b.isValidElement(n.cancel)?n.cancel:n.cancel&&A5(n.cancel)?b.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{A5(n.cancel)&&pe&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),De())},className:M5(w?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,b.isValidElement(n.action)?n.action:n.action&&A5(n.action)?b.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{A5(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&De())},className:M5(w?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function N5(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function pXe(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?oXe:aXe;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var mXe=b.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=iXe,toastOptions:g,dir:_=N5(),gap:v=cXe,icons:y,customAriaLabel:x,containerAriaLabel:S=`Notifications`}=e,[C,w]=b.useState([]),T=b.useMemo(()=>n?C.filter(e=>e.toasterId===n):C.filter(e=>!e.toasterId),[C,n]),E=b.useMemo(()=>Array.from(new Set([i].concat(T.filter(e=>e.position).map(e=>e.position)))),[T,i]),[D,O]=b.useState([]),[k,A]=b.useState(!1),[j,M]=b.useState(!1),[N,P]=b.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),F=b.useRef(null),I=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),L=b.useRef(null),R=b.useRef(!1),ee=b.useCallback(e=>{w(t=>(t.find(t=>t.id===e.id)?.delete||k5.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return b.useEffect(()=>k5.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{w(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{lm.flushSync(()=>{w(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),b.useEffect(()=>{if(d!==`system`){P(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?P(`dark`):P(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{P(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{P(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),b.useEffect(()=>{C.length<=1&&A(!1)},[C]),b.useEffect(()=>{let e=e=>{if(a.length>0&&a.every(t=>e[t]||e.code===t)){var t;A(!0),(t=F.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===F.current||F.current?.contains(document.activeElement))&&A(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),b.useEffect(()=>{if(F.current)return()=>{L.current&&(L.current.focus({preventScroll:!0}),L.current=null,R.current=!1)}},[F.current]),b.createElement(`section`,{ref:t,"aria-label":x??`${S} ${I}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},E.map((t,n)=>{let[i,a]=t.split(`-`);return T.length?b.createElement(`ol`,{key:t,dir:_===`auto`?N5():_,tabIndex:-1,ref:F,className:c,"data-sonner-toaster":!0,"data-sonner-theme":N,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${D[0]?.height||0}px`,"--width":`${sXe}px`,"--gap":`${v}px`,...m,...pXe(l,u)},onBlur:e=>{R.current&&!e.currentTarget.contains(e.relatedTarget)&&(R.current=!1,L.current&&=(L.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||R.current||(R.current=!0,L.current=e.relatedTarget)},onMouseEnter:()=>A(!0),onMouseMove:()=>A(!0),onMouseLeave:()=>{j||A(!1)},onDragEnd:()=>A(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||M(!0)},onPointerUp:()=>M(!1)},T.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>b.createElement(fXe,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:j,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:ee,toasts:T.filter(e=>e.position==n.position),heights:D.filter(e=>e.position==n.position),setHeights:O,expandByDefault:o,gap:v,expanded:k,swipeDirections:e.swipeDirections}))):null}))});function hXe(e){let{theme:t}=Qy();return(0,Y.jsx)(mXe,{theme:t??`light`,position:`bottom-center`,closeButton:!0,toastOptions:{classNames:{toast:`group rounded-lg border border-border-primary bg-bg-primary text-fg-primary shadow-lg font-serif`,title:`font-bold`,description:`text-fg-secondary`,icon:`text-fg-error-secondary`,closeButton:`bg-bg-primary text-fg-secondary border-border-primary hover:text-fg-primary`}},...e})}var gXe=6e3;function _Xe(){let{globalTransientErrors:e}=Pce(),t=(0,b.useRef)(new Set);return(0,b.useEffect)(()=>{let n=new Set;for(let r of e)n.add(r.id),!t.current.has(r.id)&&rXe.error(r.message,{id:r.id,description:r.details,duration:gXe});t.current=n},[e]),null}function vXe(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var yXe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bXe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xXe={};function P5(e,t){return((t||xXe).jsx?bXe:yXe).test(e)}var SXe=/[ \t\n\f\r]/g;function CXe(e){return typeof e==`object`?e.type===`text`&&F5(e.value):F5(e)}function F5(e){return e.replace(SXe,``)===``}var I5=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};I5.prototype.normal={},I5.prototype.property={},I5.prototype.space=void 0;function L5(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new I5(n,r,t)}function R5(e){return e.toLowerCase()}var z5=class{constructor(e,t){this.attribute=t,this.property=e}};z5.prototype.attribute=``,z5.prototype.booleanish=!1,z5.prototype.boolean=!1,z5.prototype.commaOrSpaceSeparated=!1,z5.prototype.commaSeparated=!1,z5.prototype.defined=!1,z5.prototype.mustUseProperty=!1,z5.prototype.number=!1,z5.prototype.overloadedBoolean=!1,z5.prototype.property=``,z5.prototype.spaceSeparated=!1,z5.prototype.space=void 0;var B5=c({boolean:()=>V5,booleanish:()=>H5,commaOrSpaceSeparated:()=>q5,commaSeparated:()=>K5,number:()=>W5,overloadedBoolean:()=>U5,spaceSeparated:()=>G5}),wXe=0,V5=J5(),H5=J5(),U5=J5(),W5=J5(),G5=J5(),K5=J5(),q5=J5();function J5(){return 2**++wXe}var Y5=Object.keys(B5),X5=class extends z5{constructor(e,t,n,r){let i=-1;if(super(e,t),Z5(this,`space`,r),typeof n==`number`)for(;++i<Y5.length;){let e=Y5[i];Z5(this,Y5[i],(n&B5[e])===B5[e])}}};X5.prototype.defined=!0;function Z5(e,t,n){n&&(e[t]=n)}function Q5(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new X5(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[R5(r)]=r,n[R5(a.attribute)]=r}return new I5(t,n,e.space)}var $5=Q5({properties:{ariaActiveDescendant:null,ariaAtomic:H5,ariaAutoComplete:null,ariaBusy:H5,ariaChecked:H5,ariaColCount:W5,ariaColIndex:W5,ariaColSpan:W5,ariaControls:G5,ariaCurrent:null,ariaDescribedBy:G5,ariaDetails:null,ariaDisabled:H5,ariaDropEffect:G5,ariaErrorMessage:null,ariaExpanded:H5,ariaFlowTo:G5,ariaGrabbed:H5,ariaHasPopup:null,ariaHidden:H5,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:G5,ariaLevel:W5,ariaLive:null,ariaModal:H5,ariaMultiLine:H5,ariaMultiSelectable:H5,ariaOrientation:null,ariaOwns:G5,ariaPlaceholder:null,ariaPosInSet:W5,ariaPressed:H5,ariaReadOnly:H5,ariaRelevant:null,ariaRequired:H5,ariaRoleDescription:G5,ariaRowCount:W5,ariaRowIndex:W5,ariaRowSpan:W5,ariaSelected:H5,ariaSetSize:W5,ariaSort:null,ariaValueMax:W5,ariaValueMin:W5,ariaValueNow:W5,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function e7(e,t){return t in e?e[t]:t}function t7(e,t){return e7(e,t.toLowerCase())}var TXe=Q5({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:K5,acceptCharset:G5,accessKey:G5,action:null,allow:null,allowFullScreen:V5,allowPaymentRequest:V5,allowUserMedia:V5,alt:null,as:null,async:V5,autoCapitalize:null,autoComplete:G5,autoFocus:V5,autoPlay:V5,blocking:G5,capture:null,charSet:null,checked:V5,cite:null,className:G5,cols:W5,colSpan:null,content:null,contentEditable:H5,controls:V5,controlsList:G5,coords:W5|K5,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V5,defer:V5,dir:null,dirName:null,disabled:V5,download:U5,draggable:H5,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V5,formTarget:null,headers:G5,height:W5,hidden:U5,high:W5,href:null,hrefLang:null,htmlFor:G5,httpEquiv:G5,id:null,imageSizes:null,imageSrcSet:null,inert:V5,inputMode:null,integrity:null,is:null,isMap:V5,itemId:null,itemProp:G5,itemRef:G5,itemScope:V5,itemType:G5,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V5,low:W5,manifest:null,max:null,maxLength:W5,media:null,method:null,min:null,minLength:W5,multiple:V5,muted:V5,name:null,nonce:null,noModule:V5,noValidate:V5,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:V5,optimum:W5,pattern:null,ping:G5,placeholder:null,playsInline:V5,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V5,referrerPolicy:null,rel:G5,required:V5,reversed:V5,rows:W5,rowSpan:W5,sandbox:G5,scope:null,scoped:V5,seamless:V5,selected:V5,shadowRootClonable:V5,shadowRootDelegatesFocus:V5,shadowRootMode:null,shape:null,size:W5,sizes:null,slot:null,span:W5,spellCheck:H5,src:null,srcDoc:null,srcLang:null,srcSet:null,start:W5,step:null,style:null,tabIndex:W5,target:null,title:null,translate:null,type:null,typeMustMatch:V5,useMap:null,value:H5,width:W5,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:G5,axis:null,background:null,bgColor:null,border:W5,borderColor:null,bottomMargin:W5,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V5,declare:V5,event:null,face:null,frame:null,frameBorder:null,hSpace:W5,leftMargin:W5,link:null,longDesc:null,lowSrc:null,marginHeight:W5,marginWidth:W5,noResize:V5,noHref:V5,noShade:V5,noWrap:V5,object:null,profile:null,prompt:null,rev:null,rightMargin:W5,rules:null,scheme:null,scrolling:H5,standby:null,summary:null,text:null,topMargin:W5,valueType:null,version:null,vAlign:null,vLink:null,vSpace:W5,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V5,disableRemotePlayback:V5,prefix:null,property:null,results:W5,security:null,unselectable:null},space:`html`,transform:t7}),EXe=Q5({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:q5,accentHeight:W5,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:W5,amplitude:W5,arabicForm:null,ascent:W5,attributeName:null,attributeType:null,azimuth:W5,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:W5,by:null,calcMode:null,capHeight:W5,className:G5,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:W5,diffuseConstant:W5,direction:null,display:null,dur:null,divisor:W5,dominantBaseline:null,download:V5,dx:null,dy:null,edgeMode:null,editable:null,elevation:W5,enableBackground:null,end:null,event:null,exponent:W5,externalResourcesRequired:null,fill:null,fillOpacity:W5,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:K5,g2:K5,glyphName:K5,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:W5,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:W5,horizOriginX:W5,horizOriginY:W5,id:null,ideographic:W5,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:W5,k:W5,k1:W5,k2:W5,k3:W5,k4:W5,kernelMatrix:q5,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:W5,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:W5,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:W5,overlineThickness:W5,paintOrder:null,panose1:null,path:null,pathLength:W5,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:G5,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:W5,pointsAtY:W5,pointsAtZ:W5,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:q5,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:q5,rev:q5,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:q5,requiredFeatures:q5,requiredFonts:q5,requiredFormats:q5,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:W5,specularExponent:W5,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:W5,strikethroughThickness:W5,string:null,stroke:null,strokeDashArray:q5,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:W5,strokeOpacity:W5,strokeWidth:null,style:null,surfaceScale:W5,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:q5,tabIndex:W5,tableValues:null,target:null,targetX:W5,targetY:W5,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:q5,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:W5,underlineThickness:W5,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:W5,values:null,vAlphabetic:W5,vMathematical:W5,vectorEffect:null,vHanging:W5,vIdeographic:W5,version:null,vertAdvY:W5,vertOriginX:W5,vertOriginY:W5,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:W5,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:e7}),n7=Q5({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),r7=Q5({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:t7}),i7=Q5({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),DXe={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},OXe=/[A-Z]/g,a7=/-[a-z]/g,kXe=/^data[-\w.:]+$/i;function AXe(e,t){let n=R5(t),r=t,i=z5;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&kXe.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(a7,MXe);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!a7.test(e)){let n=e.replace(OXe,jXe);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=X5}return new i(r,t)}function jXe(e){return`-`+e.toLowerCase()}function MXe(e){return e.charAt(1).toUpperCase()}var NXe=L5([$5,TXe,n7,r7,i7],`html`),o7=L5([$5,EXe,n7,r7,i7],`svg`);function PXe(e){return e.join(` `).trim()}var FXe=s(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
241
|
+
- Reply with the commit message only. No preamble, no quoting of these instructions.`;function jJe(e){let{sendWsMessage:t,subscribeToWsMessages:n,isWsConnected:r}=zS(),[i,a]=(0,b.useState)({status:e===null?`off`:`idle`}),o=(0,b.useRef)(null),s=(0,b.useRef)(null),c=(0,b.useRef)(!1),l=(0,b.useRef)(``);(0,b.useEffect)(()=>{a(t=>e===null?t.status===`off`?t:{status:`off`}:t.status===`off`?{status:`idle`}:t)},[e]),(0,b.useEffect)(()=>n(e=>{if(!(!(`id`in e)||e.id!==o.current)){if(e.type===`ai_streaming`){l.current+=e.chunk;return}if(e.type===`ai_response`){let t=(e.response||l.current).trim();a(t?{status:`ready`,text:t,sessionId:s.current}:{status:`failed`,message:`The AI returned an empty summary.`}),o.current=null;return}if(e.type===`ai_error`){a({status:`failed`,message:e.message,canSetUp:e.code===`provider_not_configured`||e.code===`byok_invalid_key`}),o.current=null;return}e.type===`ai_cancelled`&&(a({status:`idle`}),o.current=null)}}),[n]);let u=(0,b.useCallback)(()=>{let e=o.current;o.current=null,e!==null&&t({type:`ai_cancel`,id:e})},[t]);return(0,b.useEffect)(()=>()=>{u(),c.current=!1},[u]),{state:i,start:(0,b.useCallback)(n=>{if(c.current||e===null||!r)return;c.current=!0;let i=crypto.randomUUID(),u=crypto.randomUUID();o.current=i,s.current=u,l.current=``,a({status:`loading`}),t({type:`ai_prompt`,id:i,sessionId:u,hidden:!0,message:n,maxIterations:1,agents:[{id:`commit-summary`,model:e,systemPrompt:AJe,tools:[]}]})||(o.current=null,a({status:`failed`,message:`Could not reach the AI service.`}))},[r,e,t]),cancel:u,reveal:(0,b.useCallback)(async()=>{let e=s.current;if(e===null)return null;let r=crypto.randomUUID();return new Promise(i=>{let a=setTimeout(()=>{o(),i(null)},1e4),o=n(e=>{!(`id`in e)||e.id!==r||(clearTimeout(a),o(),i(e.type===`ai_session_unhidden`?e.sessionId:null))});t({type:`ai_unhide_session`,id:r,sessionId:e})||(clearTimeout(a),o(),i(null))})},[t,n])}}var L8=Symbol(`unknown`);function R8(e){if(e.status===`ready`)return e.data;if(e.status!==`absent`)return L8}var MJe=10;function NJe({onPublish:e,onClose:t}){let{summary:n,setSummary:r,publishDisabled:i,isPublishing:a,aiEnabled:o}=eC(),s=US(),c=nb(),l=BS(),u=o?l:null,d=CJe(MJe),{setSessionParam:f}=KC(),{openAIChat:p}=wS(),m=jJe(u),h=(0,b.useMemo)(()=>s.status===`success`?s.data.map(e=>e.moduleFilePath):[],[s]),g=(0,b.useMemo)(()=>TJe(h),[h]),_=`text`in n?n.text:``,v=(0,b.useRef)(!1);(0,b.useEffect)(()=>{v.current||(v.current=!0,_.trim()===``&&r({type:`manual`,text:g}))},[g,_,r]),(0,b.useEffect)(()=>{if(c===null||s.status!==`success`)return;let e=c.system.sourceStore,t=[];for(let n of s.data){let r=H.joinModuleFilePathAndModulePath(n.moduleFilePath,H.patchPathToModulePath(n.patchPath)),i=R8(e.peek(r)),a=R8(e.peekBase(r));i!==L8&&a!==L8&&t.push({sourcePath:r,moduleFilePath:n.moduleFilePath,fieldPath:n.patchPath.join(`.`),schemaType:n.schemaTypes[0],before:a,after:i})}t.length!==0&&m.start(kJe(t))},[m.start,s,c]);let[y,x]=(0,b.useState)(!1),S=(0,b.useRef)(!1);(0,b.useEffect)(()=>{S.current||m.state.status!==`ready`||(S.current=!0,P8({hasEdited:y,currentValue:_,defaultSummary:g})&&r({type:`ai`,text:m.state.text}))},[m.state,y,_,g,r]);let{isWaiting:C,skip:w}=d;(0,b.useEffect)(()=>{C&&(m.state.status===`ready`||m.state.status===`failed`)&&w()},[m.state.status,C,w]);let T=()=>{m.cancel(),e?.()};return(0,Y.jsx)(xJe,{value:_,onChange:e=>{x(!0),r({type:`manual`,text:e})},ai:m.state,onUseAiSummary:()=>{m.state.status===`ready`&&r({type:`ai`,text:m.state.text})},onOpenAiSession:m.state.status===`ready`&&m.state.sessionId!==null?()=>{m.reveal().then(e=>{e!==null&&(f(e,{replace:!0}),t(),p())})}:void 0,onPublish:()=>{if(d.isWaiting){d.skip();return}if(m.state.status===`loading`&&P8({hasEdited:y,currentValue:_,defaultSummary:g})){d.start(T);return}T()},onClose:()=>{d.cancel(),m.cancel(),t()},publishDisabled:i,isPublishing:a,waitingForAiSeconds:d.remaining})}var PJe=`h-auto w-auto p-2`;function FJe({kind:e,saving:t}){return(0,Y.jsx)(`span`,{className:`grid size-4 shrink-0 place-items-center`,children:e===`blocked`?(0,Y.jsx)(Ly,{size:16}):e===`in-flight`?(0,Y.jsx)(Gv,{size:16,className:`animate-pulse`}):t?(0,Y.jsx)(jy,{size:16}):(0,Y.jsx)(ky,{size:16})})}function z8({compact:e}){let[t,n]=(0,b.useState)(!1),{publish:r,publishDisabled:i,isPublishing:a,summary:o}=eC(),s=Fb(),c=Object.keys(s??{}),{patchErrors:l}=oC(),u=Object.values(l||{}).reduce((e,t)=>e+Object.keys(t||{}).length,0),d=qS(),f=GS(),p=(0,b.useMemo)(()=>d.filter(e=>!f.has(e)),[d,f]),m=JS(),h=KS(),g=QS(),_=eb(),{autoPublish:v}=aC(),{navigate:y}=GC(),x=bJe({mode:g===`fs`?`fs`:g===null?`unknown`:`http`,validationErrorCount:c.length,conflictingChangeCount:u,isPublishing:a,publishDisabled:i,autoPublish:v,pendingServerSidePatchCount:p.length,pendingClientSidePatchCount:m.length,netChangesEmpty:!h}),S=g===`fs`,C=e?PJe:`flex h-8 min-w-[6.5rem] items-center justify-center gap-2 px-3 text-xs font-medium`,w=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(FJe,{kind:x.kind,saving:S}),!e&&(0,Y.jsx)(`span`,{children:x.label})]}),T=x.reason??x.description;if(x.kind===`blocked`){let t=(0,Y.jsx)(t_,{className:C,variant:x.action===`show-errors`?`destructive`:`default`,disabled:x.action===`none`,"aria-label":e?x.description:void 0,onClick:()=>{x.action===`show-errors`&&y(LC,{errorFields:c})},children:w});return(0,Y.jsx)(B8,{label:x.description,description:T,disabled:x.action===`none`,container:_,children:t})}if(S||x.kind!==`ready`){let t=(0,Y.jsx)(t_,{className:C,disabled:x.action===`none`,"aria-label":e?x.description:void 0,onClick:()=>{x.action===`save`&&r(`No summary provided`)},children:w});return(0,Y.jsx)(B8,{label:x.description,description:T,disabled:x.action===`none`,container:_,children:t})}let E=(0,Y.jsx)(t_,{className:C,"aria-label":e?x.description:void 0,onClick:()=>{n(!0)},children:w});return(0,Y.jsx)(`span`,{className:`inline-flex`,children:(0,Y.jsxs)(SD,{open:t,onOpenChange:e=>{n(e)},children:[e?(0,Y.jsx)(B8,{label:x.description,description:T,disabled:!1,container:_,children:(0,Y.jsx)(CD,{asChild:!0,children:E})}):(0,Y.jsx)(CD,{asChild:!0,children:E}),(0,Y.jsxs)(wD,{container:_,align:`end`,className:`z-[9001] flex flex-col gap-4`,children:[(0,Y.jsx)(yD,{asChild:!0,className:`self-end cursor-pointer`,children:(0,Y.jsx)(Hy,{size:12})}),(0,Y.jsx)(NJe,{onClose:()=>{n(!1)},onPublish:()=>{if(n(!1),o.type===`not-asked`)return;let e=o.text.trim();r(e)}})]})]})})}function B8({label:e,description:t,disabled:n,container:r,children:i}){return(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:n?(0,Y.jsx)(`span`,{className:`inline-flex`,role:`button`,tabIndex:0,"aria-disabled":`true`,"aria-label":e,children:(0,Y.jsx)(`span`,{className:`inline-flex`,"aria-hidden":`true`,children:i})}):i}),(0,Y.jsx)(Xg,{container:r,children:(0,Y.jsx)(`p`,{children:t})})]})}var IJe=`font-mono text-sm px-2 py-0.5 rounded bg-bg-secondary text-fg-primary truncate transition-colors min-w-0 block hover:bg-bg-tertiary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`;function V8({sourcePath:e,previewSegment:t,className:n,children:r}){let i=wb(),a=ob(e,Eb(),i.status===`success`?i.data:void 0)??e,o=E8(a,{scrollToPath:a===e?void 0:e}),s=(0,Y.jsx)(`a`,{...o,title:e,className:X(IJe,n),children:r});if(t===void 0)return s;let c=Jf(`/api/val/enable`,{redirect_to:(typeof window<`u`?window.location.origin:``)+t});return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 truncate min-w-0 max-w-full`,children:[s,(0,Y.jsx)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 text-fg-tertiary hover:text-fg-primary transition-colors`,title:`Preview ${t}`,children:(0,Y.jsx)(ry,{size:12})})]})}function LJe({errorFields:e,allErrors:t}){let n=(0,b.useMemo)(()=>UJe(e),[e]),r=e.length,i=n.length,a=r>0&&e.every(e=>!t?.[e]||t[e].length===0),o=e.filter(e=>t?.[e]&&t[e].length>0).length;return e.length===0?(0,Y.jsx)(`div`,{className:`mx-auto max-w-3xl py-12 text-center text-sm text-fg-secondary`,children:`No errors selected.`}):(0,Y.jsxs)(`div`,{className:`mx-auto max-w-3xl flex flex-col gap-4 py-6`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Ly,{size:18,className:`text-fg-warning-primary-alt`,"aria-hidden":!0}),(0,Y.jsx)(`h1`,{className:`text-lg font-medium text-fg-primary`,children:`Validation errors`}),a?(0,Y.jsx)(H8,{tone:`success`,children:`All fixed`}):(0,Y.jsxs)(H8,{tone:`warning`,children:[r,` `,r===1?`field`:`fields`,i>1?(0,Y.jsxs)(Y.Fragment,{children:[` across `,i,` modules`]}):null]})]}),a&&(0,Y.jsx)(HJe,{total:r}),!a&&o<r&&r>1&&(0,Y.jsxs)(`div`,{className:`text-sm text-fg-secondary`,children:[o,` of `,r,` still need attention.`]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map(({moduleFilePath:e,paths:n})=>(0,Y.jsx)(zJe,{moduleFilePath:e,paths:n,allErrors:t},e))})]})}function RJe(){let{errorFields:e}=GC(),t=Fb();return(0,Y.jsx)(LJe,{errorFields:e,allErrors:t})}function zJe({moduleFilePath:e,paths:t,allErrors:n}){let r=(0,b.useMemo)(()=>H.splitModuleFilePath(e),[e]),i=E8(e),a=t.filter(e=>n?.[e]&&n[e].length>0).length;return(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-border-primary bg-bg-primary`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border-primary bg-bg-secondary px-4 py-2`,children:[(0,Y.jsx)(Kie,{size:14,className:`text-fg-secondary-alt shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`a`,{...i,title:e,className:`min-w-0 flex flex-wrap items-center gap-1 rounded-sm text-sm text-fg-secondary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:r.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[t>0&&(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`}),(0,Y.jsx)(`span`,{className:(0,AC.default)({"text-fg-tertiary":t<r.length-1,"text-fg-primary":t===r.length-1}),children:kC(e)})]},`m-${t}`))}),(0,Y.jsx)(`div`,{className:`ml-auto`,children:a===0?(0,Y.jsxs)(H8,{tone:`success`,children:[(0,Y.jsx)(Vv,{size:11,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Fixed`})]}):(0,Y.jsxs)(H8,{tone:`warning`,children:[a,` `,a===1?`issue`:`issues`]})})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:t.map((e,r)=>(0,Y.jsx)(BJe,{sourcePath:e,errors:n?.[e],isLast:r===t.length-1},e))})]})}function BJe({sourcePath:e,errors:t,isLast:n}){let r=Cb(e),i=!!t&&t.length>0;return(0,Y.jsxs)(`li`,{className:(0,AC.default)(`flex flex-col gap-3 px-4 py-3`,{"border-b border-border-secondary":!n}),children:[(0,Y.jsx)(VJe,{sourcePath:e}),r.status===`success`?(0,Y.jsx)(Lhe,{children:(0,Y.jsx)(r6,{path:e,schema:r.data})}):(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:14,className:`animate-spin`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Loading field…`})]}),i?(0,Y.jsx)(Phe,{validationErrors:t}):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-fg-brand-primary`,children:[(0,Y.jsx)(Vv,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Fixed.`})]})]})}function VJe({sourcePath:e}){let t=wb(),[n,r]=H.splitModuleFilePathAndModulePath(e),i=r?H.splitModulePath(r):[],a=(t.status===`success`?t.data:void 0)?.[n],o=a?.type===`record`&&!!a.router&&i.length===1;return(0,Y.jsx)(V8,{sourcePath:e,previewSegment:o?i[0]:void 0,className:o?void 0:`self-start max-w-full`,children:o?i[0]:r?lD(r):kC(H.splitModuleFilePath(n).pop()??``)})}function H8({children:e,tone:t}){return(0,Y.jsx)(`span`,{className:(0,AC.default)(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium`,{"bg-bg-warning-primary text-fg-warning-primary":t===`warning`,"bg-bg-brand-primary text-fg-brand-primary":t===`success`}),children:e})}function HJe({total:e}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border-primary bg-bg-secondary px-4 py-3 text-sm text-fg-primary`,children:[(0,Y.jsx)(Vv,{size:16,className:`text-fg-secondary`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{children:[`All `,(0,Y.jsx)(`span`,{className:`font-medium`,children:e}),` `,e===1?`error is`:`errors are`,` fixed. Ready to publish.`]})]})}function UJe(e){let t=new Map;for(let n of e){let[e]=H.splitModuleFilePathAndModulePath(n),r=t.get(e);r?r.push(n):t.set(e,[n])}let n=Array.from(t.entries()).map(([e,t])=>({moduleFilePath:e,paths:t.slice().sort(WJe)}));return n.sort((e,t)=>e.moduleFilePath.localeCompare(t.moduleFilePath)),n}function WJe(e,t){let[,n]=H.splitModuleFilePathAndModulePath(e),[,r]=H.splitModuleFilePathAndModulePath(t),i=n?H.splitModulePath(n):[],a=r?H.splitModulePath(r):[],o=Math.min(i.length,a.length);for(let e=0;e<o;e++)if(i[e]!==a[e])return i[e].localeCompare(a[e]);return i.length-a.length}function GJe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function KJe(e){let t=e.patchPath,n=!1,r=!1,i=!1;for(let a of e.patches)GJe(a.patchPath,t)&&(a.opType===`add`&&(n=!0),a.opType===`remove`&&(r=!0),a.opType===`move`&&(i=!0));return n&&r?null:i&&r?`removed`:n?`added`:i?`moved`:r?`removed`:`field-change`}function qJe(e,t){if(t.length===0)return e;let n=H.patchPathToModulePath(t);return H.joinModuleFilePathAndModulePath(e,n)}function JJe(e,t){let n={};for(let r of t){let t=r.author??`unknown`;n[t]||(n[t]=[]),n[t].push({moduleFilePath:e,patchId:r.patchId,opType:r.opType,createdAt:r.createdAt,authorId:r.author})}return n}function YJe(e,t,n,r,i,a,o,s,c,l){if(n.length===0){e.change={changeType:r,patchIds:i,authors:a,lastUpdatedBy:s,patchesByAuthorIds:c},o>e.lastUpdated&&(e.lastUpdated=o);return}let u=e;for(let e=0;e<n.length;e++){let d=qJe(t,n.slice(0,e+1)),f=e===n.length-1,p=u.children.find(e=>e.sourcePath===d);p||(p={sourcePath:d,lastUpdated:o,isCommitted:l,children:[]},u.children.push(p)),o>p.lastUpdated&&(p.lastUpdated=o),f&&(p.change={changeType:r,patchIds:i,authors:a,lastUpdatedBy:s,patchesByAuthorIds:c}),u=p}}function U8(e){let t=e.lastUpdated;for(let n of e.children){let e=U8(n);e>t&&(t=e)}return e.lastUpdated=t,t}function W8(e){let t=String(e),[,n]=H.splitModuleFilePathAndModulePath(t);if(!n)return t;let r=H.splitModulePath(n);return r[r.length-1]??t}function G8(e){e.children.sort((e,t)=>W8(e.sourcePath).localeCompare(W8(t.sourcePath)));for(let t of e.children)G8(t)}function K8(e,t){let n=[],r=[],i=t[0].createdAt,a=t[0].author;for(let e of t)e.author!==null&&!n.includes(e.author)&&n.push(e.author),r.includes(e.opType)||r.push(e.opType),e.createdAt>i&&(i=e.createdAt,a=e.author);return{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath,patches:t,authors:n,opTypes:r,schemaTypes:e.schemaTypes,lastUpdated:i,lastUpdatedBy:a}}function XJe(e,t){if(t.size===0)return{pending:e,committed:null};let n=[],r=[];for(let i of e.patches)t.has(i.patchId)?r.push(i):n.push(i);return r.length===0?{pending:e,committed:null}:n.length===0?{pending:null,committed:e}:{pending:K8(e,n),committed:K8(e,r)}}function ZJe(e,t){return`${e?`committed`:`pending`}\u0000${t}`}function QJe(e,t=new Set){let n={};for(let r of e){let{pending:e,committed:i}=XJe(r,t);for(let t of[{set:e,isCommitted:!1},{set:i,isCommitted:!0}])t.set!==null&&$Je(n,t.set,t.isCommitted)}let r=Object.values(n);for(let e of r)U8(e),G8(e);return r.sort((e,t)=>e.isCommitted===t.isCommitted?t.lastUpdated.localeCompare(e.lastUpdated):e.isCommitted?1:-1),{trees:r}}function $Je(e,t,n){let r=KJe(t);if(r===null)return;let{moduleFilePath:i}=t,a=ZJe(n,i);e[a]||(e[a]={sourcePath:i,lastUpdated:t.lastUpdated,isCommitted:n,children:[]});let o=e[a],s=t.patches.map(e=>e.patchId),c=t.authors.filter(e=>e!==null),l=JJe(i,t.patches);YJe(o,i,t.patchPath,r,s,c,t.lastUpdated,t.lastUpdatedBy,l,n)}var eYe=typeof window<`u`&&typeof Worker<`u`;function tYe(e,t,n){let r=(0,b.useRef)(null),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(!1),u=(0,b.useRef)(0),d=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!eYe)return;let e=new Worker(new URL(`/api/val/static/assets/patchsets.worker-D9QWxx6e.js`,``+import.meta.url),{type:`module`});return r.current=e,e.onmessage=e=>{let t=e.data;t.id===d.current&&(t.type===`result`?(a(t.trees),s(!1),l(!0)):t.type===`error`&&(console.error(`PatchSets worker error:`,t.error),s(!1),l(!0)))},e.onerror=e=>{console.error(`PatchSets worker failed:`,e.message),s(!1),l(!0)},()=>{e.terminate(),r.current=null}},[]);let f=n?Array.from(n).sort().join(`,`):``,p=(0,b.useMemo)(()=>n===void 0?[]:Array.from(n).sort(),[f]),m=(0,b.useCallback)((e,t)=>{if(!r.current){let{trees:n}=QJe(e,new Set(t));a(n),s(!1),l(!0);return}let n=`ps-${u.current++}`;d.current=n,s(!0);let i={type:`compute`,id:n,patchSets:e,committedPatchIds:t};r.current.postMessage(i)},[]),[h,g]=(0,b.useState)(t);return h!==t&&(g(t),a([]),l(!1),s(!0)),(0,b.useEffect)(()=>{m(e,p)},[e,m,t,p]),{trees:i,isComputing:o,hasComputed:c}}function q8(e,t){return e===t}function nYe(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let a=n-1;a>=0;a--)for(let n=r-1;n>=0;n--)i[a][n]=q8(e[a],t[n])?i[a+1][n+1]+1:Math.max(i[a+1][n],i[a][n+1]);let a=[],o=0,s=0;for(;o<n&&s<r;)q8(e[o],t[s])?(a.push({beforeIndex:o,index:s}),o++,s++):i[o+1][s]>=i[o][s+1]?o++:s++;return a}function rYe(e,t){let n=[],r=Math.min(e.length,t.length);for(let i=0;i<r;i++)q8(e[i],t[i])?n.push({kind:`unchanged`,index:i,beforeIndex:i,value:t[i]}):n.push({kind:`changed`,index:i,beforeIndex:i,before:e[i],after:t[i]});for(let e=r;e<t.length;e++)n.push({kind:`added`,index:e,value:t[e]});for(let t=r;t<e.length;t++)n.push({kind:`removed`,beforeIndex:t,value:e[t]});return{lines:n,positional:!0}}function iYe(e,t){if(e.length>1e3||t.length>1e3)return rYe(e,t);let n=nYe(e,t),r=new Set(n.map(e=>e.beforeIndex)),i=new Set(n.map(e=>e.index)),a=new Map(n.map(e=>[e.index,e.beforeIndex])),o=[];for(let t=0;t<e.length;t++)r.has(t)||o.push(t);let s=new Map,c=new Set;for(let n=0;n<t.length;n++){if(i.has(n))continue;let r=o.find(r=>!c.has(r)&&q8(e[r],t[n]));r!==void 0&&(c.add(r),s.set(n,r))}let l=[],u=0,d=0,f=(n,r)=>{let i=[],a=[];for(;u<n;)c.has(u)||i.push(u),u++;for(;d<r;){if(s.has(d)){let e=s.get(d);if(e===void 0)throw Error(`unreachable: movedFrom.has without a value`);l.push({kind:`moved`,index:d,beforeIndex:e,value:t[d]})}else a.push(d);d++}let o=Math.min(i.length,a.length);for(let n=0;n<o;n++)l.push({kind:`changed`,index:a[n],beforeIndex:i[n],before:e[i[n]],after:t[a[n]]});for(let e=o;e<a.length;e++)l.push({kind:`added`,index:a[e],value:t[a[e]]});for(let t=o;t<i.length;t++)l.push({kind:`removed`,beforeIndex:i[t],value:e[i[t]]})};for(let e of n){f(e.beforeIndex,e.index);let n=a.get(e.index)??e.beforeIndex;l.push({kind:`unchanged`,index:e.index,beforeIndex:n,value:t[e.index]}),u=e.beforeIndex+1,d=e.index+1}return f(e.length,t.length),{lines:l,positional:!1}}function aYe(e){return e.lines.some(e=>e.kind!==`unchanged`)}function oYe(e){let t={added:0,removed:0,moved:0,changed:0,unchanged:0};for(let n of e.lines)t[n.kind]+=1;return t}function sYe({sourcePath:e}){let t=jb(e),n=Ab(e),r=Y8(t.status===`success`?t.data:void 0),i=Y8(n.status===`success`?n.data:void 0),a=(0,b.useMemo)(()=>r===null||i===null?null:iYe(r,i),[r,i]);if(a===null)return null;if(!aYe(a))return(0,Y.jsx)(`div`,{className:`text-sm text-fg-tertiary`,children:`The list ended up the same as it started.`});let o=oYe(a);return(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(cYe,{counts:o}),a.positional&&(0,Y.jsx)(lYe,{}),(0,Y.jsx)(`ol`,{className:`mt-3 flex flex-col gap-px font-mono text-sm tabular-nums`,children:a.lines.map((e,t)=>(0,Y.jsx)(uYe,{line:e},`${e.kind}-${t}`))})]})}function cYe({counts:e}){let t=[];return e.added>0&&t.push(`${e.added} added`),e.removed>0&&t.push(`${e.removed} removed`),e.moved>0&&t.push(`${e.moved} moved`),e.changed>0&&t.push(`${e.changed} changed`),(0,Y.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[t.join(`, `),e.unchanged>0&&(0,Y.jsxs)(`span`,{className:`text-fg-tertiary`,children:[t.length>0?` · `:``,e.unchanged,` unchanged`]})]})}function lYe(){return(0,Y.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-xs text-fg-secondary`,children:[(0,Y.jsx)(Ly,{size:12,className:`mt-0.5 shrink-0 text-fg-warning-primary-alt`,"aria-hidden":!0}),`This list is too long to match items by content, so it is compared position by position. A reorder will read as a run of changes.`]})}function uYe({line:e}){let t=`index`in e?e.index:null;return(0,Y.jsxs)(`li`,{className:X(`flex min-w-0 items-baseline gap-2 rounded border-l-[3px] py-1 pl-2 pr-1`,e.kind===`added`&&`border-fg-brand-primary bg-bg-brand-primary/5`,e.kind===`removed`&&`border-fg-error bg-bg-error-secondary/30`,e.kind===`moved`&&`border-fg-warning bg-bg-secondary/40`,e.kind===`changed`&&`border-fg-warning`,e.kind===`unchanged`&&`border-transparent`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`w-3 shrink-0 select-none text-center`,e.kind===`added`&&`text-fg-brand-primary`,e.kind===`removed`&&`text-fg-error`,e.kind===`moved`&&`text-fg-warning`,e.kind===`changed`&&`text-fg-warning`,e.kind===`unchanged`&&`text-fg-quaternary`),children:dYe(e.kind)}),(0,Y.jsx)(`span`,{className:`w-8 shrink-0 text-right text-xs text-fg-quaternary`,children:t===null?``:t+1}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:(0,Y.jsx)(fYe,{line:e})}),(0,Y.jsx)(pYe,{line:e})]})}function dYe(e){switch(e){case`added`:return`+`;case`removed`:return`−`;case`moved`:return`↕`;case`changed`:return`~`;case`unchanged`:return``}}function fYe({line:e}){return e.kind===`changed`?(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-fg-tertiary line-through decoration-fg-error/60`,children:(0,Y.jsx)(J8,{value:e.before})}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`text-fg-quaternary`,children:`→`}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(J8,{value:e.after})})]}):(0,Y.jsx)(`span`,{className:e.kind===`removed`?`text-fg-tertiary`:void 0,children:(0,Y.jsx)(J8,{value:e.value})})}function J8({value:e}){return e===null?(0,Y.jsx)(`span`,{className:`italic text-fg-tertiary`,children:`null`}):e===``?(0,Y.jsx)(`span`,{className:`italic text-fg-tertiary`,children:`empty`}):typeof e==`boolean`||typeof e==`number`?(0,Y.jsx)(Y.Fragment,{children:String(e)}):(0,Y.jsx)(Y.Fragment,{children:e})}function pYe({line:e}){if(e.kind===`unchanged`)return null;if(e.kind===`moved`){let t=e.index<e.beforeIndex;return(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 whitespace-nowrap font-sans text-xs text-fg-warning`,children:[t?(0,Y.jsx)(jv,{size:11,"aria-hidden":!0}):(0,Y.jsx)(kv,{size:11,"aria-hidden":!0}),`moved from `,e.beforeIndex+1]})}let t=e.kind===`added`?`added`:e.kind===`removed`?`removed from ${e.beforeIndex+1}`:`changed`;return(0,Y.jsx)(`span`,{className:X(`ml-auto shrink-0 whitespace-nowrap font-sans text-xs`,e.kind===`added`&&`text-fg-brand-primary`,e.kind===`removed`&&`text-fg-error`,e.kind===`changed`&&`text-fg-warning`),children:t})}function Y8(e){if(!Array.isArray(e))return null;let t=[];for(let n of e)if(n===null||typeof n==`string`||typeof n==`number`||typeof n==`boolean`)t.push(n);else return null;return t}function mYe({patchSets:e,profilesByAuthorIds:t,mode:n=`unknown`,canDiscard:r=!1,reloadKey:i,committedPatchIds:a,deployment:o}){let s=eb(),c=wb(),l=GS(),u=a??l,{trees:d,isComputing:f,hasComputed:p}=tYe(e,i,u),m=(0,b.useMemo)(()=>d.flatMap(T5),[d]),h=gYe(d),g=bce((0,b.useMemo)(()=>d.filter(e=>!e.isCommitted).map(e=>e.sourcePath),[d])),{changing:_,reverted:v,committedTrees:y}=(0,b.useMemo)(()=>{let e=[],t=[],n=[];for(let r of d)r.isCommitted?n.push(r):g.has(r.sourcePath)?t.push(r):e.push(r);return{changing:e,reverted:t,committedTrees:n}},[d,g]),x=(0,b.useMemo)(()=>Q8(v.flatMap(T5)),[v]),S=(0,b.useMemo)(()=>{let t=[],n=new Set,r=new Set;for(let i of e)for(let e of i.patches)u.has(e.patchId)||r.has(e.patchId)||(r.add(e.patchId),t.push(e.patchId),e.author!==null&&n.add(e.author));return{ids:t,authorIds:[...n]}},[e,u]);if(!p||f&&d.length===0)return(0,Y.jsx)(e5,{});if(m.length===0)return S.ids.length>0?(0,Y.jsx)(`div`,{className:`mx-auto max-w-7xl min-w-0`,children:(0,Y.jsx)(Z8,{patchIds:S.ids,authorIds:S.authorIds,profilesByAuthorIds:t,canDiscard:r,portalContainer:s})}):(0,Y.jsx)(`div`,{className:`text-sm text-fg-secondary py-8 text-center`,children:`No pending changes.`});let C=c.status===`success`?c.data:void 0;return(0,Y.jsxs)(`div`,{className:`mx-auto max-w-7xl flex flex-col gap-6 lg:gap-8 min-w-0`,children:[(0,Y.jsx)(_Ye,{authorIds:h.authorIds,pendingAuthorIds:h.pendingAuthorIds,profilesByAuthorIds:t,mode:n,pendingPatchIds:h.pendingPatchIds,deployingCount:h.deployingCount,canDiscard:r,portalContainer:s}),_.length===0&&v.length>0&&(0,Y.jsx)(Z8,{patchIds:x,authorIds:h.pendingAuthorIds,profilesByAuthorIds:t,canDiscard:r,portalContainer:s}),_.map(e=>(0,Y.jsx)(i5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`pending-${e.sourcePath}`)),v.length>0&&(0,Y.jsx)(hYe,{count:x.length,children:v.map(e=>(0,Y.jsx)(i5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`reverted-${e.sourcePath}`))}),y.length>0&&(o===void 0?(0,Y.jsx)(vYe,{}):(0,Y.jsx)(t5,{deployment:o})),y.map(e=>(0,Y.jsx)(i5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`committed-${e.sourcePath}`))]})}function X8(e,t){let n=nC();return(0,b.useMemo)(()=>e.filter(e=>e!==n).map(e=>t?.[e]?.fullName).filter(e=>!!e),[e,t,n])}function Z8({patchIds:e,authorIds:t,profilesByAuthorIds:n,canDiscard:r,portalContainer:i}){let{deletePatches:a}=RS(),o=X8(t,n);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border-primary bg-bg-secondary px-4 py-3 sm:flex-row sm:items-center`,children:[(0,Y.jsx)(Xv,{size:16,className:`shrink-0 text-fg-secondary`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-fg-primary`,children:e.length===1?`The one pending change has been reverted.`:`Every pending change has been reverted.`}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`The content matches what is published, so there is nothing to publish.`})]}),r&&e.length>0&&(0,Y.jsx)(w5,{description:n8(e.length,o),title:`Discard ${e.length} ${e.length===1?`change`:`changes`}?`,confirmLabel:`Discard ${e.length}`,onConfirm:()=>a(e),portalContainer:i,ariaLabel:`Discard all ${e.length} reverted ${e.length===1?`change`:`changes`}`,label:`Discard all`})]})}function hYe({count:e,children:t}){let[n,r]=(0,b.useState)(!1);return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`flex items-center gap-2 self-start rounded-md px-1 py-1 text-xs text-fg-secondary hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:[(0,Y.jsx)(Rv,{size:14,"aria-hidden":!0,className:(0,AC.default)(`transition-transform`,{"rotate-90":n})}),(0,Y.jsx)(Ay,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e===1?`1 reverted change`:`${e} reverted changes`})]}),n&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-6 lg:gap-8`,children:t})]})}function gYe(e){return(0,b.useMemo)(()=>{let t=e.filter(e=>!e.isCommitted).flatMap(T5),n=e.filter(e=>e.isCommitted).flatMap(T5);return{authorIds:$8(e.flatMap(T5)),pendingAuthorIds:$8(t),pendingPatchIds:Q8(t),deployingCount:Q8(n).length}},[e])}function Q8(e){let t=[],n=new Set;for(let r of e)for(let e of r.change?.patchIds??[])n.has(e)||(n.add(e),t.push(e));return t}function $8(e){let t=[],n=new Set;for(let r of e)for(let e of r.change?.authors??[])n.has(e)||(n.add(e),t.push(e));return t}function e5(){return(0,Y.jsxs)(`div`,{className:`mx-auto max-w-7xl flex flex-col gap-8 min-w-[380px]`,"aria-busy":`true`,"aria-live":`polite`,"aria-label":`Loading changes`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:14,className:`animate-spin`,"aria-hidden":!0}),`Building the comparison…`]}),[0,1].map(e=>(0,Y.jsxs)(`section`,{className:`border border-border-primary rounded-lg bg-bg-primary overflow-hidden`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2 px-5 py-4 border-b border-border-primary`,children:[(0,Y.jsx)(eX,{className:`h-4 w-48`}),(0,Y.jsx)(eX,{className:`ml-auto h-6 w-6 rounded-full`})]}),(0,Y.jsx)(`div`,{className:`divide-y divide-border-primary`,children:[0,1].map(e=>(0,Y.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,Y.jsx)(eX,{className:`h-3 w-32`}),(0,Y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,Y.jsx)(eX,{className:`h-10 w-full`}),(0,Y.jsx)(eX,{className:`h-10 w-full`})]})]},e))})]},e))]})}function _Ye({authorIds:e,pendingAuthorIds:t,profilesByAuthorIds:n,mode:r,pendingPatchIds:i,deployingCount:a,canDiscard:o,portalContainer:s}){let{deletePatches:c}=RS(),l=X8(t??e,n),u=i.length===0&&a>0,d=u?a:i.length;return(0,Y.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col sm:flex-row sm:items-center gap-2 sm:gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xl font-medium leading-none text-fg-primary tabular-nums`,children:d}),(0,Y.jsx)(`span`,{className:`text-sm text-fg-secondary truncate`,children:u?`${d===1?`change`:`changes`} deploying`:`${d===1?`change`:`changes`} to review`}),(0,Y.jsx)(`span`,{className:`ml-auto sm:hidden`,children:(0,Y.jsx)(_5,{authorIds:e,profilesByAuthorIds:n,mode:r})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 sm:ml-auto border-t border-border-primary pt-2 sm:border-t-0 sm:pt-0`,children:[a>0&&i.length>0&&(0,Y.jsxs)(`span`,{className:`text-xs text-fg-tertiary whitespace-nowrap`,children:[a,` deploying`]}),o&&i.length>0&&(0,Y.jsx)(w5,{description:n8(i.length,l),title:`Discard ${i.length} ${i.length===1?`change`:`changes`}?`,confirmLabel:`Discard ${i.length}`,onConfirm:()=>c(i),portalContainer:s,ariaLabel:`Discard all ${i.length} pending ${i.length===1?`change`:`changes`}`,label:`Discard all`}),o&&i.length===0&&a>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-tertiary whitespace-nowrap`,children:[(0,Y.jsx)(gy,{size:12,"aria-hidden":!0}),`Nothing left to discard`]}),(0,Y.jsx)(`span`,{className:`ml-auto hidden sm:inline-flex`,children:(0,Y.jsx)(_5,{authorIds:e,profilesByAuthorIds:n,mode:r})})]})]})}function vYe(){let{deployments:e}=HS(),t=yce(),n=(0,b.useMemo)(()=>{for(let n of t){let t=e.find(e=>e.commitSha===n);if(t)return t}return null},[e,t]);return(0,Y.jsx)(t5,{deployment:n,commitShas:t})}function t5({deployment:e,commitShas:t=[]}){let[n]=(0,b.useState)(()=>new Date),r=e?.deploymentState,i=r===`created`||r===`pending`,a=r===`failure`||r===`error`,o=r===`success`,s=a?`Published — deploy failed`:i?`Published & deploying`:o?`Published — live`:`Published`,c=t.length>0?t:e?[e.commitSha]:[],l=c.length>1?`${c.length} commits`:c.length===1?`${c[0].slice(0,7)}${e?` · ${Wk(n,e.updatedAt)}`:``}`:null,u=(0,Y.jsx)(`span`,{className:`hidden sm:block h-px flex-1 bg-border-primary`,role:`separator`,"aria-hidden":!0});return(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-0 sm:gap-4`,children:[(0,Y.jsx)(`span`,{className:`block sm:hidden h-px bg-border-primary`,"aria-hidden":!0}),u,(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex items-start sm:items-center gap-2 min-w-0`,`border rounded-lg px-3 py-2 -mt-px`,`sm:rounded-full sm:py-1.5 sm:mt-0 sm:shrink-0`,{"bg-bg-error-secondary border-border-error-secondary text-fg-error-secondary":a,"bg-bg-warning-primary border-border-warning-primary text-fg-warning-primary":i,"bg-bg-brand-primary border-border-brand-primary text-fg-brand-primary":o,"bg-bg-secondary border-border-primary text-fg-secondary":!a&&!i&&!o}),children:[i?(0,Y.jsx)(hy,{size:14,className:`animate-spin shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):a?(0,Y.jsx)(Bv,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):o?(0,Y.jsx)(Fv,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):(0,Y.jsx)(gy,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`flex flex-col sm:flex-row sm:items-center sm:gap-2 min-w-0 text-xs sm:text-[13px]`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:s}),(0,Y.jsxs)(`span`,{className:`opacity-80`,children:[l&&(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[l,` — `]}),`these cannot be discarded`]})]})]}),u]})}function n5(e){let t=[],n=new Set;function r(e){for(let r of e.change?.patchIds??[])n.has(r)||(n.add(r),t.push(r));for(let t of e.children)r(t)}return r(e),t}function r5(e){let t=[],n=new Set,r={};function i(e){if(e.change){for(let r of e.change.authors)n.has(r)||(n.add(r),t.push(r));for(let[t,n]of Object.entries(e.change.patchesByAuthorIds)){r[t]||(r[t]=[]);for(let e of n)r[t].push({createdAt:e.createdAt,opType:e.opType})}}for(let t of e.children)i(t)}return i(e),{authorIds:t,patchesByAuthorIds:r}}function i5({tree:e,profilesByAuthorIds:t,portalContainer:n,mode:r,schemas:i,canDiscard:a}){let o=e.sourcePath,s=i?.[o],c=s?.type===`record`&&!!s.router,[l,u]=(0,b.useState)(!1),{deletePatches:d}=RS(),[f]=(0,b.useState)(()=>new Date),p=jb(o),m=Ab(o),h=p.status===`success`&&m.status===`success`&&Mr(p.data,m.data),g=(0,b.useMemo)(()=>n5(e),[e]),{patchesByAuthorIds:_}=(0,b.useMemo)(()=>r5(e),[e]),v=a&&!e.isCommitted,y={moduleFilePath:o,isRouterModule:c,profilesByAuthorIds:t,portalContainer:n,mode:r,canDiscard:v,isCommitted:e.isCommitted};return(0,Y.jsxs)(`section`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`border rounded-lg overflow-hidden`,e.isCommitted?`border-dashed border-border-primary bg-bg-secondary`:`border-border-primary bg-bg-primary`),children:[(0,Y.jsxs)(`header`,{className:(0,AC.default)(`flex items-center gap-2 px-4 lg:px-5 py-4 border-b min-w-0`,e.isCommitted?`border-dashed border-border-primary`:`border-border-primary`),children:[(0,Y.jsx)(SYe,{moduleFilePath:o}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[e.isCommitted&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-tertiary`,title:`Published — this cannot be discarded`,children:[(0,Y.jsx)(gy,{size:12,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:`Deploying`})]}),v&&g.length>0&&(0,Y.jsx)(y5,{isEqual:h,onDiscard:()=>d(g),confirmDescription:`Discard all changes in this module? This cannot be undone.`,unchangedAriaLabel:`Discard all unchanged in this module`,confirmAriaLabel:`Discard all changes in this module`,portalContainer:n}),Object.keys(_).length>0&&(0,Y.jsx)(Whe,{patchesByAuthorIds:_,profilesByAuthorIds:t,now:f,portalContainer:n,mode:r}),(0,Y.jsx)(v5,{isOpen:!l,onToggle:()=>u(e=>!e),openLabel:`Collapse module`,closedLabel:`Expand module`})]})]}),!l&&(0,Y.jsxs)(`div`,{className:`divide-y divide-border-primary`,children:[e.isCommitted&&(0,Y.jsx)(`p`,{className:`px-4 lg:px-5 py-3 text-xs text-fg-tertiary`,children:`Already part of the published content, so there is no before and after to compare. Open a field to see its current value.`}),(0,Y.jsx)(a5,{node:e,rowProps:y})]})]})}function yYe(e){let t=Cb(e);if(t.status===`loading`)return;if(t.status!==`success`||t.data.type!==`array`)return!1;let n=t.data.item.type;return n===`string`||n===`number`||n===`boolean`}function a5({node:e,rowProps:t}){let n=yYe(e.sourcePath);return n===void 0?null:n?(0,Y.jsx)(CYe,{row:e,...t},e.sourcePath):e.change?e.change.changeType===`added`||e.change.changeType===`removed`?(0,Y.jsx)(c5,{row:e,...t},e.sourcePath):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(c5,{row:e,...t},e.sourcePath),e.children.length>0&&(0,Y.jsx)(s5,{parent:e,rowProps:t})]}):e.children.some(e=>o5(e))?(0,Y.jsx)(s5,{parent:e,rowProps:t}):null}function bYe(e){return H.mediaUrl({path:e})}function o5(e){return e.change?!0:e.children.some(o5)}function xYe(e){let t=[],n=[],r={},i=new Set,a=new Set,o=``,s=null;function c(e){let l=e.change;if(l){for(let e of l.patchIds)i.has(e)||(i.add(e),t.push(e));for(let e of l.authors)a.has(e)||(a.add(e),n.push(e));for(let[e,t]of Object.entries(l.patchesByAuthorIds))r[e]||(r[e]=[]),r[e].push(...t);e.lastUpdated>o&&(o=e.lastUpdated,s=l.lastUpdatedBy)}for(let t of e.children)c(t)}return c(e),{...e,children:[],change:{changeType:e.change?.changeType??`field-change`,patchIds:t,authors:n,lastUpdatedBy:s,patchesByAuthorIds:r}}}function s5({parent:e,rowProps:t}){let n=Cb(e.sourcePath),r=n.status===`success`&&n.data.type===`record`?n.data.mediaType:void 0;return r?(0,Y.jsx)(Y.Fragment,{children:e.children.filter(e=>o5(e)).map(e=>(0,Y.jsx)(c5,{row:xYe(e),...t,parentMediaType:r},e.sourcePath))}):(0,Y.jsx)(Y.Fragment,{children:e.children.filter(e=>o5(e)).map(e=>(0,Y.jsx)(a5,{node:e,rowProps:t},e.sourcePath))})}function SYe({moduleFilePath:e}){let t=H.splitModuleFilePath(e),n=E8(e);return(0,Y.jsx)(`h2`,{className:`text-sm font-medium text-fg-primary truncate min-w-0`,children:(0,Y.jsx)(`a`,{...n,title:e,className:`flex items-center gap-1.5 min-w-0 rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:t.map((e,n)=>(0,Y.jsxs)(b.Fragment,{children:[n>0&&(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,"aria-hidden":!0,children:`/`}),(0,Y.jsx)(`span`,{className:(0,AC.default)({"text-fg-secondary":n<t.length-1}),children:kC(e)})]},`${e}-${n}`))})})}function CYe({row:e,moduleFilePath:t,isRouterModule:n,profilesByAuthorIds:r,portalContainer:i,mode:a,canDiscard:o,isCommitted:s}){let{deletePatches:c}=RS(),[l]=(0,b.useState)(()=>new Date),[u,d]=(0,b.useState)(!0),f=e.sourcePath,p=jb(f),m=Ab(f),h=!s&&p.status===`success`&&m.status===`success`&&Mr(p.data,m.data),g=(0,b.useMemo)(()=>n5(e),[e]),{patchesByAuthorIds:_}=(0,b.useMemo)(()=>r5(e),[e]),[,v]=H.splitModuleFilePathAndModulePath(f),y=v?H.splitModulePath(v):[],x=n&&y.length===1,S=y[y.length-1]??``;return g.length===0?null:(0,Y.jsxs)(`article`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`px-5 py-5`,{"opacity-60":h}),children:[(0,Y.jsx)(l5,{sourcePath:f,changeType:`field-change`,segment:S,modulePath:v,moduleFilePath:t,isRouterPageKey:x,patchesByAuthorIds:_,profilesByAuthorIds:r,portalContainer:i,mode:a,now:l,onDiscard:()=>c(g),isExpanded:u,onToggleExpand:()=>d(e=>!e),isEqual:h,canDiscard:o,hideExpand:s}),u&&!s&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(sYe,{sourcePath:f})})]})}function c5({row:e,moduleFilePath:t,isRouterModule:n,profilesByAuthorIds:r,portalContainer:i,mode:a,canDiscard:o,isCommitted:s,parentMediaType:c}){let{deletePatches:l}=RS(),[u]=(0,b.useState)(()=>new Date),d=e.change,[f,p]=(0,b.useState)(d?.changeType!==`removed`),m=e.sourcePath,h=jb(m),g=Ab(m);if(!d)return null;let _=!s&&d.changeType===`field-change`&&h.status===`success`&&g.status===`success`&&Mr(h.data,g.data),[,v]=H.splitModuleFilePathAndModulePath(m),y=v?H.splitModulePath(v):[],x=n&&y.length===1,S=y[y.length-1]??``,C={};for(let[e,t]of Object.entries(d.patchesByAuthorIds))C[e]=t.map(e=>({createdAt:e.createdAt,opType:e.opType}));return(0,Y.jsxs)(`article`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`px-5 py-5`,{"opacity-60":_,"bg-bg-error-secondary/30":d.changeType===`removed`,"bg-bg-brand-primary/5":d.changeType===`added`}),children:[(0,Y.jsx)(l5,{sourcePath:m,changeType:d.changeType,segment:S,modulePath:v,moduleFilePath:t,isRouterPageKey:x,patchesByAuthorIds:C,profilesByAuthorIds:r,portalContainer:i,mode:a,now:u,onDiscard:()=>l(d.patchIds),isExpanded:f,onToggleExpand:()=>p(e=>!e),isEqual:_,canDiscard:o,hideExpand:s,parentMediaType:c}),!s&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(DYe,{sourcePath:m,changeType:d.changeType,isExpanded:f,isEqual:_,parentMediaType:c})})]})}function l5({sourcePath:e,changeType:t,segment:n,modulePath:r,moduleFilePath:i,isRouterPageKey:a,patchesByAuthorIds:o,profilesByAuthorIds:s,portalContainer:c,mode:l,now:u,onDiscard:d,isExpanded:f,onToggleExpand:p,isEqual:m,canDiscard:h,hideExpand:g,parentMediaType:_}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(EYe,{changeType:t,isEqual:m}),(0,Y.jsx)(wYe,{sourcePath:e,segment:n,modulePath:r,moduleFilePath:i,isRouterPageKey:a,parentMediaType:_}),(0,Y.jsx)(TYe,{changeType:t,isEqual:m}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[h&&(0,Y.jsx)(y5,{isEqual:m,onDiscard:d,confirmDescription:`Discard this change? This cannot be undone.`,unchangedAriaLabel:`Discard unchanged`,confirmAriaLabel:`Discard this change`,portalContainer:c}),(0,Y.jsx)(Whe,{patchesByAuthorIds:o,profilesByAuthorIds:s,now:u,portalContainer:c,mode:l}),!g&&(0,Y.jsx)(v5,{isOpen:f,onToggle:p,openLabel:`Collapse`,closedLabel:`Expand`})]})]})}function wYe({sourcePath:e,segment:t,modulePath:n,moduleFilePath:r,isRouterPageKey:i,parentMediaType:a}){let o=(()=>{if(a){let{filename:e,folder:n}=pS(t);return n===`/`?`/${e}`:`${n}/${e}`}return n?i?t:lD(n):kC(H.splitModuleFilePath(r).pop()??``)})();return(0,Y.jsx)(V8,{sourcePath:e,previewSegment:i&&!a&&n?t:void 0,className:`min-w-0`,children:o})}function TYe({changeType:e,isEqual:t}){return t?(0,Y.jsx)(`span`,{className:`text-sm text-fg-tertiary px-1.5 py-0.5 rounded bg-bg-secondary shrink-0`,children:`Unchanged`}):e===`added`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-brand-primary shrink-0`,children:`Added`}):e===`removed`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-error shrink-0`,children:`Removed`}):e===`moved`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-warning shrink-0`,children:`Moved`}):null}function EYe({changeType:e,isEqual:t}){if(t)return(0,Y.jsx)(Xv,{size:14,className:`shrink-0 text-fg-tertiary`,"aria-label":`Unchanged`});switch(e){case`added`:return(0,Y.jsx)(Oy,{size:14,className:`shrink-0 text-fg-brand-primary`,"aria-label":`Added`});case`removed`:return(0,Y.jsx)(yy,{size:14,className:`shrink-0 text-fg-error`,"aria-label":`Removed`});case`moved`:return(0,Y.jsx)(Av,{size:14,className:`shrink-0 text-fg-warning`,"aria-label":`Moved`});case`field-change`:return(0,Y.jsx)(Dy,{size:14,className:`shrink-0 text-fg-secondary`,"aria-label":`Edited`})}}function DYe({sourcePath:e,changeType:t,isExpanded:n,isEqual:r,parentMediaType:i}){return i?(0,Y.jsx)(kYe,{sourcePath:e,changeType:t,mediaType:i,isExpanded:n,isEqual:r}):t===`field-change`?(0,Y.jsx)(jYe,{sourcePath:e,isExpanded:n,isEqual:r}):n?t===`added`?(0,Y.jsx)(m5,{sourcePath:e,side:`after`,diffStyle:`added`}):t===`removed`?(0,Y.jsx)(AYe,{sourcePath:e}):(0,Y.jsx)(m5,{sourcePath:e,side:`after`,diffStyle:`added`}):null}function u5(e){if(e&&typeof e.hotspot==`object`&&e.hotspot!==null&&`x`in e.hotspot&&`y`in e.hotspot){let t=e.hotspot;if(typeof t.x==`number`&&typeof t.y==`number`)return{x:t.x,y:t.y}}}function d5({metadata:e}){let t=[];return e&&(typeof e.mimeType==`string`&&t.push({label:`mimeType`,value:e.mimeType}),typeof e.width==`number`&&typeof e.height==`number`&&t.push({label:`dimensions`,value:`${e.width} × ${e.height}`})),t.length===0?null:(0,Y.jsx)(`dl`,{className:`mt-4 text-xs text-fg-secondary grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:t.map(e=>(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-fg-tertiary`,children:e.label}),(0,Y.jsx)(`dd`,{className:`truncate`,children:e.value})]},e.label))})}function f5({sourcePath:e,showValidation:t=!1}){let n=H.createValPathOfItem(e,`alt`),r=Cb(n);return r.status===`success`?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium mb-1 block`,children:`Alt`}),(0,Y.jsx)(r6,{path:n,schema:r.data,readonly:!0,errorDisplay:t?`compact`:`none`})]}):null}function p5({url:e,filename:t,diffStyle:n,hotspot:r}){return e?(0,Y.jsxs)(`div`,{className:`w-[120px] flex-shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`relative w-[120px] h-[90px]`,children:[(0,Y.jsx)(`img`,{src:e,alt:t,draggable:!1,className:(0,AC.default)(`w-full h-full object-cover rounded border border-border-primary`,{"opacity-40":n===`removed`}),style:r?{objectPosition:`${r.x*100}% ${r.y*100}%`}:void 0}),r&&(0,Y.jsx)(sA,{hotspot:r,size:`sm`})]}),r&&(0,Y.jsxs)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:[`hotspot `,Math.round(r.x*100),`%, `,Math.round(r.y*100),`%`]})]}):(0,Y.jsxs)(`div`,{className:`w-[120px] flex-shrink-0`,children:[(0,Y.jsx)(`div`,{className:`w-[120px] h-[90px] rounded bg-bg-secondary flex items-center justify-center text-fg-disabled text-xs`,children:`No preview`}),r&&(0,Y.jsxs)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:[`hotspot `,Math.round(r.x*100),`%,`,` `,Math.round(r.y*100),`%`]})]})}function OYe(e){return(0,b.useMemo)(()=>{let[,t]=H.splitModuleFilePathAndModulePath(e),n=t?H.splitModulePath(t):[];return n[n.length-1]??``},[e])}function kYe({sourcePath:e,changeType:t,mediaType:n,isExpanded:r,isEqual:i}){let a=OYe(e),o=Mb(),s=n===`images`,c=Ab(e),l=jb(e),u=c.status===`success`?c.data:null,d=l.status===`success`?l.data:null,f=u5(u),p=u5(d),m=s?rA(a,o):null,h=Dse(a);if(!r&&t!==`field-change`)return null;if(i&&t===`field-change`)return(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(`div`,{className:`border-l-[3px] border-border-secondary pl-3 pr-1 py-2 min-w-0`,children:(0,Y.jsx)(C5,{isImage:s,url:m,filename:h,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})});if(t===`added`||t===`moved`)return r?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`added`,children:(0,Y.jsx)(C5,{isImage:s,url:m,filename:h,diffStyle:`added`,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})}):null;if(t===`removed`){if(!r)return null;let t=s?bYe(a):null;return(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`removed`,children:(0,Y.jsx)(C5,{isImage:s,url:t,filename:h,diffStyle:`removed`,hotspot:p,metadata:d,sourcePath:e})})})})}if(!r)return null;let g=l.status===`success`;return g&&l.data===null||!g?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`added`,children:(0,Y.jsx)(C5,{isImage:s,url:m,filename:h,diffStyle:`added`,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})}):(0,Y.jsxs)(`div`,{className:`border-l-[3px] border-fg-brand-primary pl-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[s&&(0,Y.jsx)(p5,{url:m,filename:h,hotspot:f}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(x5,{variant:`media`,before:(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(f5,{sourcePath:e})}),after:(0,Y.jsx)(f5,{sourcePath:e,showValidation:!0})})})]}),(0,Y.jsx)(d5,{metadata:u})]})}function AYe({sourcePath:e}){return(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(m5,{sourcePath:e,side:`after`,diffStyle:`removed`})})}function jYe({sourcePath:e,isExpanded:t,isEqual:n}){let r=roe(e),i=r.status===`success`?r.resolvedPath:e,a=jb(i);if(r.status!==`success`)return null;let o=r.data,s=a.status===`success`,c=s&&a.data===null;return t?n?(0,Y.jsx)(x5,{variant:`equal`,before:(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}),after:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`compact`})}):c||!s?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`added`,children:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})})}):(0,Y.jsx)(x5,{variant:`changed`,before:(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}),after:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})}):null}function m5({sourcePath:e,side:t,diffStyle:n}){let[r]=(0,b.useMemo)(()=>H.splitModuleFilePathAndModulePath(e),[e]),i=jb(r),a=(0,b.useMemo)(()=>i.status===`success`?{moduleFilePath:r,moduleSource:i.data}:null,[r,i]);return t===`before`?(0,Y.jsx)(lb.Provider,{value:a,children:(0,Y.jsx)(h5,{sourcePath:e,diffStyle:n})}):(0,Y.jsx)(h5,{sourcePath:e,diffStyle:n})}function h5({sourcePath:e,diffStyle:t}){let n=Cb(e);if(n.status!==`success`)return null;let r=n.data;return(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:t,children:t===`removed`?(0,Y.jsx)(`div`,{className:`[&_div]:decoration-fg-error [&_pre]:decoration-fg-error line-through decoration-fg-error`,children:(0,Y.jsx)(r6,{path:e,schema:r,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}):(0,Y.jsx)(r6,{path:e,schema:r,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})})})}function g5({diffStyle:e,children:t}){return(0,Y.jsx)(`div`,{className:(0,AC.default)(`border-l-[3px] pl-3 pr-1 py-2 min-w-0`,{"border-fg-error":e===`removed`,"border-fg-brand-primary":e===`added`}),children:t})}function _5({authorIds:e,profilesByAuthorIds:t,mode:n}){if(e.length===0)return null;let r=e.slice(0,9),i=e.length-r.length;return(0,Y.jsxs)(`div`,{className:`flex items-center`,"aria-label":`Authors`,children:[r.map((e,r)=>(0,Y.jsx)(MYe,{profile:t[e]??null,isFirst:r===0,mode:n},e)),i>0&&(0,Y.jsxs)(`span`,{className:`-ml-2 w-7 h-7 rounded-full inline-flex items-center justify-center text-[11px] font-semibold bg-bg-secondary text-fg-secondary border-2 border-bg-primary`,"aria-label":`${i} more authors`,children:[`+`,i]})]})}function MYe({profile:e,isFirst:t,mode:n}){let r=(0,AC.default)(`shrink-0 w-7 h-7 rounded-full inline-flex items-center justify-center text-[11px] font-semibold overflow-hidden border-2 border-bg-primary`,{"-ml-2":!t});return e?e.avatar?.url?(0,Y.jsx)(`img`,{src:e.avatar.url,alt:e.fullName,title:e.fullName,className:(0,AC.default)(r,`object-cover`)}):(0,Y.jsx)(`span`,{className:(0,AC.default)(r,`bg-bg-brand-primary text-fg-brand-primary`),title:e.fullName,children:zhe(e.fullName)}):(0,Y.jsx)(`span`,{className:(0,AC.default)(r,`bg-bg-secondary text-fg-disabled`),title:n===`fs`?`Local changes`:`Unknown author`,children:n===`fs`?(0,Y.jsx)(jy,{size:12}):(0,Y.jsx)(Vy,{size:12})})}function v5({isOpen:e,onToggle:t,openLabel:n,closedLabel:r}){return(0,Y.jsx)(`button`,{onClick:t,className:(0,AC.default)(`size-5 flex items-center justify-center text-fg-secondary hover:text-fg-primary transition-transform`,{"rotate-180":e}),"aria-label":e?n:r,children:(0,Y.jsx)(Iv,{size:14})})}function y5({isEqual:e,onDiscard:t,confirmDescription:n,unchangedAriaLabel:r,confirmAriaLabel:i,portalContainer:a}){return e?(0,Y.jsx)(t_,{variant:`default`,size:`icon-sm`,onClick:t,"aria-label":r,children:(0,Y.jsx)(zy,{size:14})}):(0,Y.jsx)(w5,{description:n,onConfirm:t,portalContainer:a,ariaLabel:i})}function b5({sourcePath:e,children:t}){let[n]=(0,b.useMemo)(()=>H.splitModuleFilePathAndModulePath(e),[e]),r=jb(n),i=(0,b.useMemo)(()=>r.status===`success`?{moduleFilePath:n,moduleSource:r.data}:null,[n,r]);return(0,Y.jsx)(lb.Provider,{value:i,children:t})}function x5({variant:e,before:t,after:n}){if(e===`media`)return(0,Y.jsxs)(`div`,{className:`grid gap-3 lg:gap-0 lg:grid-cols-[minmax(0,1fr)_24px_minmax(0,1fr)] items-start`,children:[(0,Y.jsxs)(`div`,{className:`pr-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-tertiary mb-1`,children:`Before`}),t]}),(0,Y.jsx)(`div`,{className:`hidden lg:flex items-center justify-center text-fg-tertiary pt-3`,"aria-hidden":!0,children:(0,Y.jsx)(Av,{size:14})}),(0,Y.jsxs)(`div`,{className:`pl-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-tertiary mb-1`,children:`After`}),n]})]});let r=e===`equal`?`border-border-secondary`:`border-fg-brand-primary`,i=e===`equal`?Xv:Av;return(0,Y.jsxs)(`div`,{className:`grid gap-3 lg:gap-0 lg:grid-cols-[minmax(0,1fr)_24px_minmax(0,1fr)] items-stretch`,children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`border-l-[3px] pl-3 pr-12 lg:pr-1 py-2 min-w-0`,r),children:[(0,Y.jsx)(S5,{children:`Before`}),t]}),(0,Y.jsx)(`div`,{className:`hidden lg:flex items-center justify-center text-fg-tertiary`,"aria-hidden":!0,children:(0,Y.jsx)(i,{size:14})}),(0,Y.jsxs)(`div`,{className:`pl-4 lg:pl-1 pr-3 py-2 min-w-0`,children:[(0,Y.jsx)(S5,{children:`After`}),n]})]})}function S5({children:e}){return(0,Y.jsx)(`div`,{className:`lg:hidden text-[10px] uppercase tracking-wider font-medium text-fg-tertiary mb-1`,children:e})}function C5({isImage:e,url:t,filename:n,hotspot:r,diffStyle:i,metadata:a,sourcePath:o,showValidation:s}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[e&&(0,Y.jsx)(p5,{url:t,filename:n,diffStyle:i,hotspot:r}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(f5,{sourcePath:o,showValidation:s})})]}),(0,Y.jsx)(d5,{metadata:a})]})}function w5({description:e,title:t,confirmLabel:n,onConfirm:r,portalContainer:i,ariaLabel:a,label:o}){let[s,c]=(0,b.useState)(!1);return(0,Y.jsxs)(SD,{open:s,onOpenChange:c,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:o?`sm`:`icon-sm`,"aria-label":a,className:o?`gap-2`:void 0,children:[(0,Y.jsx)(zy,{size:14}),o&&(0,Y.jsx)(`span`,{children:o})]})}),(0,Y.jsxs)(wD,{container:i,className:`w-[calc(100vw-24px)] sm:w-auto sm:max-w-xs p-3`,side:`bottom`,align:`end`,children:[t&&(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-sm font-medium text-fg-primary mb-1.5`,children:[(0,Y.jsx)(Bv,{size:15,className:`shrink-0 mt-0.5 text-fg-error-on-surface`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:t})]}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-secondary mb-3`,children:e}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:flex sm:items-center sm:justify-end`,children:[(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>c(!1),children:`Cancel`}),(0,Y.jsx)(t_,{variant:`destructive`,size:`sm`,onClick:()=>{r(),c(!1)},children:n??`Discard`})]})]})]})}function T5(e){let t=[];if(e.change&&t.push(e),!e.change||e.change.changeType!==`added`&&e.change.changeType!==`removed`)for(let n of e.children)for(let e of T5(n))t.push(e);return t}function NYe(){let e=eb();return(0,Y.jsx)(Uy,{open:!0,modal:!0,children:(0,Y.jsxs)(Wy,{children:[(0,Y.jsx)(Gy,{}),(0,Y.jsxs)(Ky,{container:e,"aria-label":`Login required`,className:`bg-bg-secondary text-fg-secondary`,children:[(0,Y.jsx)(qy,{children:(0,Y.jsx)(Yy,{children:(0,Y.jsx)(`span`,{children:`Log in required`})})}),(0,Y.jsx)(Xy,{children:`You need to log in to access Val.`}),(0,Y.jsx)(t_,{asChild:!0,children:(0,Y.jsx)(`a`,{href:Jf(`/api/val/authorize`,{redirect_to:window.origin+Jf(`/val`)}),children:`Log in`})})]})]})})}function E5({code:e}){return(0,Y.jsxs)(`div`,{className:`relative bg-bg-secondary rounded-md p-4 pr-16 my-4`,children:[(0,Y.jsx)(`pre`,{className:`text-xs overflow-x-auto `,children:(0,Y.jsx)(`code`,{children:e})}),(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,className:`absolute top-2 right-2`,onClick:()=>{navigator.clipboard.writeText(e)},children:(0,Y.jsx)(qv,{size:16,className:`mr-2`})})]})}function PYe({moduleFilePath:e,patchPath:t,className:n,toolTip:r=!0,link:i=!0}){let a=bb(),o=(0,b.useRef)(null),s=(0,b.useRef)(new Map),[c,l]=(0,b.useState)([]),[u,d]=(0,b.useState)(),f=Eb(),p=wb(),{navigate:m}=GC();(0,b.useEffect)(()=>{let n=e?H.splitModuleFilePath(e):[],r=t,i=()=>{if(!o.current)return;let t=o.current,i=getComputedStyle(t),a=`${i.fontSize} ${i.fontFamily}`,c=t.offsetWidth,u=n.map(FYe).concat(r).map(e=>`/${e}`);d(u.join(``));let f=e=>{let t=`${e}:${a}`,n=s.current.get(t)??IYe(e,a);return s.current.set(t,n),n},p=`/…`,m=f(p),h=[],g=0;for(let t=u.length-1;t>=0;t--){let i=f(u[t]),a=t!==0;if(g+i+(a?m:0)<=c){let a=t>n.length?`module-path`:`module-file-path`;h.unshift({text:u[t],type:a,moduleFilePath:e,modulePathSegments:r.slice(0,t)}),g+=i}else{h.unshift({type:`ellipsis`,text:p});break}}l(h)},a=new ResizeObserver(i);return o.current&&(a.observe(o.current),i()),()=>{o.current&&a.unobserve(o.current)}},[e,t]);let h=(0,b.useMemo)(()=>{if(!i)return null;let n=`data`in p?p.data:{};if(t.length===0){let t=e;return{navPath:t,sourcePath:t}}let r=rb(t,n[e],f[e]);if(r.success){let i=H.joinModuleFilePathAndModulePath(e,r.modulePath),a=ob(i,f,n);if(a)return{navPath:a,scrollToPath:i};console.debug(`Failed to resolve nav path for ${e} and ${t.join(`.`)}: ${a}`)}else console.debug(`Failed to resolve source path for ${e} and ${t.join(`.`)}: ${r.error}`);return null},[e,t,f,p]);return(0,Y.jsxs)(Jg,{open:r!==!1&&void 0,children:[(0,Y.jsx)(hg,{asChild:!0,children:(0,Y.jsx)(`a`,{href:h&&a?`${a.studioPrefix}${h.navPath}${h.scrollToPath?`#${encodeURIComponent(h.scrollToPath)}`:``}`:void 0,ref:o,className:(0,AC.default)(`inline-block whitespace-nowrap overflow-hidden w-full align-baseline`,{"cursor-pointer hover:underline":i},n),onClick:e=>{i&&h&&e.metaKey===!1&&e.ctrlKey===!1&&e.shiftKey===!1&&(e.preventDefault(),m(h.navPath,{scrollToPath:h.scrollToPath}))},children:c.map((e,t)=>(0,Y.jsx)(`span`,{children:e.text},t))})}),(0,Y.jsx)(Xg,{side:`top`,children:(0,Y.jsx)(eD,{orientation:`horizontal`,className:`max-w-[calc(100vw-3rem)] whitespace-nowrap`,children:u})})]})}function FYe(e){let t=kC(e);return t.slice(0,1).toUpperCase()+t.slice(1)}function IYe(e,t){let n=document.createElement(`canvas`).getContext(`2d`);return n?(n.font=t,n.measureText(e).width):0}function LYe(){let{patchErrors:e}=oC(),{deletePatches:t}=RS(),{navigate:n}=GC(),r=sC(),i=US(),a=eb(),o=QS(),[s,c]=(0,b.useState)(!1),l=(0,b.useMemo)(()=>zYe(e,`data`in i?i.data:void 0),[e,i]),u=(0,b.useMemo)(()=>JSON.stringify({mode:o,changes:l},null,2),[o,l]),d=l.map(e=>e.patchId).join(`|`),[f,p]=(0,b.useState)(d);return f!==d&&(p(d),c(!1)),l.length===0?null:(0,Y.jsx)(Uy,{open:!s,onOpenChange:e=>{c(!e)},children:(0,Y.jsxs)(Ky,{container:a,className:`max-w-2xl`,children:[(0,Y.jsxs)(qy,{children:[(0,Y.jsxs)(Yy,{className:`flex gap-2 items-center`,children:[(0,Y.jsx)(Ly,{size:18}),(0,Y.jsxs)(`span`,{children:[l.length,` change`,l.length===1?``:`s`,` cannot be applied`]})]}),(0,Y.jsx)(Xy,{children:`These changes conflict with newer ones, so they can no longer be applied to the content. Nothing can be published until they are removed. Removing a change discards only that edit.`})]}),(0,Y.jsx)(eD,{className:`max-h-[40vh]`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:l.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 rounded-md border border-border-primary`,children:[(0,Y.jsx)(`div`,{className:`text-sm`,children:e.patchPath?(0,Y.jsx)(PYe,{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath}):(0,Y.jsx)(`span`,{children:e.moduleFilePath})}),(0,Y.jsx)(`div`,{className:`text-xs text-fg-secondary`,children:[e.author?r[e.author]?.fullName??e.author:null,e.createdAt?Wk(new Date,e.createdAt):null].filter(e=>e!==null).join(` · `)}),(0,Y.jsx)(`div`,{className:`text-xs text-fg-error-primary`,children:e.message}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(t_,{variant:`destructive`,size:`sm`,onClick:()=>{t([e.patchId])},children:(0,Y.jsxs)(`span`,{className:`flex gap-2 items-center`,children:[(0,Y.jsx)(`span`,{children:`Remove change`}),(0,Y.jsx)(zy,{size:14})]})}),(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>{c(!0),n(`/val/compare`,{scrollToPath:RYe(e)})},children:`Review in compare`})]})]},e.patchId))})}),(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{className:`text-xs cursor-pointer text-fg-secondary`,children:`Diagnosis for Val developers`}),(0,Y.jsx)(E5,{code:u})]}),(0,Y.jsx)(Jy,{children:(0,Y.jsxs)(t_,{variant:`destructive`,onClick:()=>{t(l.map(e=>e.patchId))},children:[`Remove all `,l.length,` and continue`]})})]})})}function RYe(e){return!e.patchPath||e.patchPath.length===0?e.moduleFilePath:H.joinModuleFilePathAndModulePath(e.moduleFilePath,H.patchPathToModulePath(e.patchPath))}function zYe(e,t){if(!e)return[];let n=new Map;for(let e of t??[])for(let t of e.patches)n.set(t.patchId,{author:t.author,createdAt:t.createdAt,patchPath:e.patchPath});let r=[];for(let[t,i]of Object.entries(e))if(i)for(let[e,a]of Object.entries(i)){let i=e,o=n.get(i);r.push({patchId:i,moduleFilePath:t,message:a.message,author:o?.author??null,createdAt:o?.createdAt??null,patchPath:o?.patchPath??null})}return r.sort((e,t)=>(e.createdAt??``).localeCompare(t.createdAt??``))}function BYe({value:e}){return console.warn(`Exhaustive check failed for value:`,e),null}function VYe(){let e=Fce();return e===null?null:e.type===`network-error`?(0,Y.jsx)(D5,{children:`Network error - retrying...`}):e.type===`schema-error`?(0,Y.jsx)(D5,{children:`Schema error - check your console for details`}):e.type===`profiles-auth-error`?(0,Y.jsx)(D5,{children:`Could not authenticate with your personal access token while getting profiles.`}):e.type===`remote-files-error`?(0,Y.jsx)(HYe,{error:e}):(0,Y.jsx)(BYe,{value:e})}function D5({children:e}){return(0,Y.jsx)(`div`,{role:`status`,className:`fixed inset-x-0 top-0 z-full p-4 text-center text-fg-error-primary bg-bg-error-primary`,children:e})}function HYe({error:e}){let t=eb();return(0,Y.jsx)(Uy,{defaultOpen:!0,children:(0,Y.jsxs)(Wy,{children:[(0,Y.jsx)(Gy,{}),(0,Y.jsxs)(Ky,{container:t,className:`max-w-lg p-6 rounded-lg bg-bg-primary text-fg-primary`,children:[(0,Y.jsx)(Yy,{className:`text-lg font-medium mb-4`,children:`Personal access token file required`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{children:`This project uses remote files, which means you need to be authenticated to update them.`}),(0,Y.jsx)(`p`,{children:`To do this locally in this dev environment, you need a Personal Access Token (PAT) stored in a file.`}),(0,Y.jsx)(`p`,{children:`Run the command in the root directory of your project to create the token file.`})]}),(0,Y.jsx)(E5,{code:`npx -p @valbuild/cli val login`}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(zk,{type:`multiple`,children:[(0,Y.jsxs)(Bk,{value:`why-pat`,children:[(0,Y.jsx)(Vk,{children:`Why a personal token file?`}),(0,Y.jsxs)(Hk,{children:[(0,Y.jsx)(`p`,{children:`You are using remote files, which require authentication. In local development, Val uses a personal access token (PAT) to authenticate and allow you to update remote files.`}),(0,Y.jsx)(`p`,{children:`You can create it by running the command shown above, which will create a PAT file.`}),(0,Y.jsx)(`p`,{children:`If you have the PAT already, check that you have internet access and that the project is setup correctly in https://admin.val.build, as issues with either of those could also cause this error.`})]})]}),(0,Y.jsxs)(Bk,{value:`details`,children:[(0,Y.jsx)(Vk,{children:`More details`}),(0,Y.jsx)(Hk,{children:(0,Y.jsxs)(`p`,{children:[`The underlying error message was: "`,e.error,`".`]})})]})]})})]})]})})}function UYe(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var WYe=e=>{switch(e){case`success`:return qYe;case`info`:return YYe;case`warning`:return JYe;case`error`:return XYe;default:return null}},GYe=Array(12).fill(0),KYe=({visible:e,className:t})=>b.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},b.createElement(`div`,{className:`sonner-spinner`},GYe.map((e,t)=>b.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),qYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),JYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),YYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),XYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),ZYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`},b.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),b.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),QYe=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},$Ye=1,eXe=100,O5=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:$Ye++,k5=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-eXe;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{let{message:t,...n}=e,r=O5(e),i=this.pendingDismissals.get(r);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));let a=this.dismissedToasts.has(r),o=e.dismissible===void 0||e.dismissible;return a&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(e=>e.id!==r)),!a&&this.toasts.find(e=>e.id===r)?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:o,title:t}):n):this.addToast({title:t,...n,dismissible:o,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(e=>{this.dismissedToasts.add(e.id),this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);let t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(t=>t({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],b.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(nXe(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=O5(t);return this.create({...t,jsx:e(n),id:n,type:void 0}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},tXe=(e,t)=>k5.message(e,t),nXe=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,rXe=Object.assign(tXe,{success:k5.success,info:k5.info,warning:k5.warning,error:k5.error,custom:k5.custom,message:k5.message,promise:k5.promise,dismiss:k5.dismiss,loading:k5.loading},{getHistory:()=>k5.toasts,getToasts:()=>k5.getActiveToasts()});UYe(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function A5(e){return e.label!==void 0}var iXe=3,aXe=`24px`,oXe=`16px`,j5=4e3,sXe=356,cXe=14,lXe=45,uXe=200;function M5(...e){return e.filter(Boolean).join(` `)}function dXe(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var fXe=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:x,gap:S,expandByDefault:C,classNames:w,icons:T,closeButtonAriaLabel:E=`Close toast`}=e,[D,O]=b.useState(null),[k,A]=b.useState(null),[j,M]=b.useState(!1),[N,P]=b.useState(!1),[F,I]=b.useState(!1),[L,R]=b.useState(!1),[ee,te]=b.useState(!1),[ne,re]=b.useState(0),[ie,ae]=b.useState(0),oe=b.useRef(n.duration||y||j5),se=b.useRef(null),ce=b.useRef(null),le=c===0,ue=c+1<=o,de=n.type,fe=de??`default`,pe=n.dismissible!==!1,me=n.className||``,he=n.descriptionClassName||``,ge=b.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),_e=b.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ve=b.useMemo(()=>n.duration||y||j5,[n.duration,y]),ye=b.useRef(0),be=b.useRef(0),xe=b.useRef(0),Se=b.useRef(null),[Ce,we]=x.split(`-`),z=b.useMemo(()=>s.reduce((e,t,n)=>n>=ge?e:e+t.height,0),[s,ge]),B=QYe(),Te=b.useMemo(()=>e.swipeDirections??dXe(x),[e.swipeDirections,x]),Ee=n.invert||t,V=de===`loading`;be.current=b.useMemo(()=>ge*S+z,[ge,z]),b.useEffect(()=>{oe.current=ve},[ve]),b.useEffect(()=>{M(!0)},[]),b.useEffect(()=>{let e=ce.current;if(e){let t=e.getBoundingClientRect().height;return ae(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),b.useLayoutEffect(()=>{if(!j)return;let e=ce.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ae(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[j,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let De=b.useCallback(()=>{P(!0),re(be.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},uXe)},[n,d,a,be]);b.useEffect(()=>{if(n.promise&&de===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||B?(()=>{if(xe.current<ye.current){let e=new Date().getTime()-ye.current;oe.current-=e}xe.current=new Date().getTime()})():oe.current!==1/0&&(ye.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),De()},oe.current)),()=>clearTimeout(e)},[u,i,n,de,B,De]),b.useEffect(()=>{n.delete&&(De(),n.onDismiss==null||n.onDismiss.call(n,n))},[De,n.delete]);function Oe(){return T?.loading?b.createElement(`div`,{className:M5(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":de===`loading`},T.loading):b.createElement(KYe,{className:M5(w?.loader,n?.classNames?.loader),visible:de===`loading`})}let ke=n.icon||T?.[de]||WYe(de);return b.createElement(`li`,{tabIndex:0,ref:ce,className:M5(_,me,w?.toast,n?.classNames?.toast,w?.[fe],n?.classNames?.[fe]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":j,"data-promise":!!n.promise,"data-swiped":ee,"data-removed":N,"data-visible":ue,"data-y-position":Ce,"data-x-position":we,"data-index":c,"data-front":le,"data-swiping":F,"data-dismissible":pe,"data-type":de,"data-invert":Ee,"data-swipe-out":L,"data-swipe-direction":k,"data-expanded":!!(u||C&&j),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${N?ne:be.current}px`,"--initial-height":C?`auto`:`${ie}px`,...m,...n.style},onDragEnd:()=>{I(!1),O(null),Se.current=null},onPointerDown:e=>{e.button!==2&&(V||!pe||(se.current=new Date,re(be.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(I(!0),Se.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(L||!pe)return;Se.current=null;let e=Number(ce.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(ce.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-se.current?.getTime(),i=D===`x`?e:t,a=Math.abs(i)/r;if((D===`x`?Te.includes(e>0?`right`:`left`):Te.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=lXe||a>.11)){re(be.current),n.onDismiss==null||n.onDismiss.call(n,n),A(D===`x`?e>0?`right`:`left`:t>0?`down`:`up`),De(),R(!0);return}var o,s;(o=ce.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=ce.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),te(!1),I(!1),O(null)},onPointerMove:e=>{var t,n;if(!Se.current||!pe||window.getSelection()?.toString().length>0)return;let r=e.clientY-Se.current.y,i=e.clientX-Se.current.x;!D&&(Math.abs(i)>1||Math.abs(r)>1)&&O(Math.abs(i)>Math.abs(r)?`x`:`y`);let a={x:0,y:0},o=e=>1/(1.5+Math.abs(e)/20);if(D===`y`){if(Te.includes(`top`)||Te.includes(`bottom`)){if(Te.includes(`top`)&&r<0||Te.includes(`bottom`)&&r>0)a.y=r;else{let e=r*o(r);a.y=Math.abs(e)<Math.abs(r)?e:r}}}else if(D===`x`&&(Te.includes(`left`)||Te.includes(`right`))){if(Te.includes(`left`)&&i<0||Te.includes(`right`)&&i>0)a.x=i;else{let e=i*o(i);a.x=Math.abs(e)<Math.abs(i)?e:i}}(Math.abs(a.x)>0||Math.abs(a.y)>0)&&te(!0),(t=ce.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=ce.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},_e&&!n.jsx&&de!==`loading`?b.createElement(`button`,{"aria-label":E,"data-disabled":V,"data-close-button":!0,onClick:V||!pe?()=>{}:()=>{De(),n.onDismiss==null||n.onDismiss.call(n,n)},className:M5(w?.closeButton,n?.classNames?.closeButton)},T?.close??ZYe):null,(de||n.icon||n.promise)&&n.icon!==null&&(T?.[de]!==null||n.icon)?b.createElement(`div`,{"data-icon":``,className:M5(w?.icon,n?.classNames?.icon)},de===`loading`?n.icon||Oe():n.promise?Oe():null,de===`loading`?null:ke):null,b.createElement(`div`,{"data-content":``,className:M5(w?.content,n?.classNames?.content)},b.createElement(`div`,{"data-title":``,className:M5(w?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?b.createElement(`div`,{"data-description":``,className:M5(v,he,w?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),b.isValidElement(n.cancel)?n.cancel:n.cancel&&A5(n.cancel)?b.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{A5(n.cancel)&&pe&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),De())},className:M5(w?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,b.isValidElement(n.action)?n.action:n.action&&A5(n.action)?b.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{A5(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&De())},className:M5(w?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function N5(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function pXe(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?oXe:aXe;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var mXe=b.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=iXe,toastOptions:g,dir:_=N5(),gap:v=cXe,icons:y,customAriaLabel:x,containerAriaLabel:S=`Notifications`}=e,[C,w]=b.useState([]),T=b.useMemo(()=>n?C.filter(e=>e.toasterId===n):C.filter(e=>!e.toasterId),[C,n]),E=b.useMemo(()=>Array.from(new Set([i].concat(T.filter(e=>e.position).map(e=>e.position)))),[T,i]),[D,O]=b.useState([]),[k,A]=b.useState(!1),[j,M]=b.useState(!1),[N,P]=b.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),F=b.useRef(null),I=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),L=b.useRef(null),R=b.useRef(!1),ee=b.useCallback(e=>{w(t=>(t.find(t=>t.id===e.id)?.delete||k5.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return b.useEffect(()=>k5.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{w(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{lm.flushSync(()=>{w(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),b.useEffect(()=>{if(d!==`system`){P(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?P(`dark`):P(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{P(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{P(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),b.useEffect(()=>{C.length<=1&&A(!1)},[C]),b.useEffect(()=>{let e=e=>{if(a.length>0&&a.every(t=>e[t]||e.code===t)){var t;A(!0),(t=F.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===F.current||F.current?.contains(document.activeElement))&&A(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),b.useEffect(()=>{if(F.current)return()=>{L.current&&(L.current.focus({preventScroll:!0}),L.current=null,R.current=!1)}},[F.current]),b.createElement(`section`,{ref:t,"aria-label":x??`${S} ${I}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},E.map((t,n)=>{let[i,a]=t.split(`-`);return T.length?b.createElement(`ol`,{key:t,dir:_===`auto`?N5():_,tabIndex:-1,ref:F,className:c,"data-sonner-toaster":!0,"data-sonner-theme":N,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${D[0]?.height||0}px`,"--width":`${sXe}px`,"--gap":`${v}px`,...m,...pXe(l,u)},onBlur:e=>{R.current&&!e.currentTarget.contains(e.relatedTarget)&&(R.current=!1,L.current&&=(L.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||R.current||(R.current=!0,L.current=e.relatedTarget)},onMouseEnter:()=>A(!0),onMouseMove:()=>A(!0),onMouseLeave:()=>{j||A(!1)},onDragEnd:()=>A(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||M(!0)},onPointerUp:()=>M(!1)},T.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>b.createElement(fXe,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:j,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:ee,toasts:T.filter(e=>e.position==n.position),heights:D.filter(e=>e.position==n.position),setHeights:O,expandByDefault:o,gap:v,expanded:k,swipeDirections:e.swipeDirections}))):null}))});function hXe(e){let{theme:t}=Qy();return(0,Y.jsx)(mXe,{theme:t??`light`,position:`bottom-center`,closeButton:!0,toastOptions:{classNames:{toast:`group rounded-lg border border-border-primary bg-bg-primary text-fg-primary shadow-lg font-serif`,title:`font-bold`,description:`text-fg-secondary`,icon:`text-fg-error-secondary`,closeButton:`bg-bg-primary text-fg-secondary border-border-primary hover:text-fg-primary`}},...e})}var gXe=6e3;function _Xe(){let{globalTransientErrors:e}=Pce(),t=(0,b.useRef)(new Set);return(0,b.useEffect)(()=>{let n=new Set;for(let r of e)n.add(r.id),!t.current.has(r.id)&&rXe.error(r.message,{id:r.id,description:r.details,duration:gXe});t.current=n},[e]),null}function vXe(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var yXe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bXe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xXe={};function P5(e,t){return((t||xXe).jsx?bXe:yXe).test(e)}var SXe=/[ \t\n\f\r]/g;function CXe(e){return typeof e==`object`?e.type===`text`&&F5(e.value):F5(e)}function F5(e){return e.replace(SXe,``)===``}var I5=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};I5.prototype.normal={},I5.prototype.property={},I5.prototype.space=void 0;function L5(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new I5(n,r,t)}function R5(e){return e.toLowerCase()}var z5=class{constructor(e,t){this.attribute=t,this.property=e}};z5.prototype.attribute=``,z5.prototype.booleanish=!1,z5.prototype.boolean=!1,z5.prototype.commaOrSpaceSeparated=!1,z5.prototype.commaSeparated=!1,z5.prototype.defined=!1,z5.prototype.mustUseProperty=!1,z5.prototype.number=!1,z5.prototype.overloadedBoolean=!1,z5.prototype.property=``,z5.prototype.spaceSeparated=!1,z5.prototype.space=void 0;var B5=c({boolean:()=>V5,booleanish:()=>H5,commaOrSpaceSeparated:()=>q5,commaSeparated:()=>K5,number:()=>W5,overloadedBoolean:()=>U5,spaceSeparated:()=>G5}),wXe=0,V5=J5(),H5=J5(),U5=J5(),W5=J5(),G5=J5(),K5=J5(),q5=J5();function J5(){return 2**++wXe}var Y5=Object.keys(B5),X5=class extends z5{constructor(e,t,n,r){let i=-1;if(super(e,t),Z5(this,`space`,r),typeof n==`number`)for(;++i<Y5.length;){let e=Y5[i];Z5(this,Y5[i],(n&B5[e])===B5[e])}}};X5.prototype.defined=!0;function Z5(e,t,n){n&&(e[t]=n)}function Q5(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new X5(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[R5(r)]=r,n[R5(a.attribute)]=r}return new I5(t,n,e.space)}var $5=Q5({properties:{ariaActiveDescendant:null,ariaAtomic:H5,ariaAutoComplete:null,ariaBusy:H5,ariaChecked:H5,ariaColCount:W5,ariaColIndex:W5,ariaColSpan:W5,ariaControls:G5,ariaCurrent:null,ariaDescribedBy:G5,ariaDetails:null,ariaDisabled:H5,ariaDropEffect:G5,ariaErrorMessage:null,ariaExpanded:H5,ariaFlowTo:G5,ariaGrabbed:H5,ariaHasPopup:null,ariaHidden:H5,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:G5,ariaLevel:W5,ariaLive:null,ariaModal:H5,ariaMultiLine:H5,ariaMultiSelectable:H5,ariaOrientation:null,ariaOwns:G5,ariaPlaceholder:null,ariaPosInSet:W5,ariaPressed:H5,ariaReadOnly:H5,ariaRelevant:null,ariaRequired:H5,ariaRoleDescription:G5,ariaRowCount:W5,ariaRowIndex:W5,ariaRowSpan:W5,ariaSelected:H5,ariaSetSize:W5,ariaSort:null,ariaValueMax:W5,ariaValueMin:W5,ariaValueNow:W5,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function e7(e,t){return t in e?e[t]:t}function t7(e,t){return e7(e,t.toLowerCase())}var TXe=Q5({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:K5,acceptCharset:G5,accessKey:G5,action:null,allow:null,allowFullScreen:V5,allowPaymentRequest:V5,allowUserMedia:V5,alt:null,as:null,async:V5,autoCapitalize:null,autoComplete:G5,autoFocus:V5,autoPlay:V5,blocking:G5,capture:null,charSet:null,checked:V5,cite:null,className:G5,cols:W5,colSpan:null,content:null,contentEditable:H5,controls:V5,controlsList:G5,coords:W5|K5,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V5,defer:V5,dir:null,dirName:null,disabled:V5,download:U5,draggable:H5,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V5,formTarget:null,headers:G5,height:W5,hidden:U5,high:W5,href:null,hrefLang:null,htmlFor:G5,httpEquiv:G5,id:null,imageSizes:null,imageSrcSet:null,inert:V5,inputMode:null,integrity:null,is:null,isMap:V5,itemId:null,itemProp:G5,itemRef:G5,itemScope:V5,itemType:G5,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V5,low:W5,manifest:null,max:null,maxLength:W5,media:null,method:null,min:null,minLength:W5,multiple:V5,muted:V5,name:null,nonce:null,noModule:V5,noValidate:V5,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:V5,optimum:W5,pattern:null,ping:G5,placeholder:null,playsInline:V5,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V5,referrerPolicy:null,rel:G5,required:V5,reversed:V5,rows:W5,rowSpan:W5,sandbox:G5,scope:null,scoped:V5,seamless:V5,selected:V5,shadowRootClonable:V5,shadowRootDelegatesFocus:V5,shadowRootMode:null,shape:null,size:W5,sizes:null,slot:null,span:W5,spellCheck:H5,src:null,srcDoc:null,srcLang:null,srcSet:null,start:W5,step:null,style:null,tabIndex:W5,target:null,title:null,translate:null,type:null,typeMustMatch:V5,useMap:null,value:H5,width:W5,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:G5,axis:null,background:null,bgColor:null,border:W5,borderColor:null,bottomMargin:W5,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V5,declare:V5,event:null,face:null,frame:null,frameBorder:null,hSpace:W5,leftMargin:W5,link:null,longDesc:null,lowSrc:null,marginHeight:W5,marginWidth:W5,noResize:V5,noHref:V5,noShade:V5,noWrap:V5,object:null,profile:null,prompt:null,rev:null,rightMargin:W5,rules:null,scheme:null,scrolling:H5,standby:null,summary:null,text:null,topMargin:W5,valueType:null,version:null,vAlign:null,vLink:null,vSpace:W5,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V5,disableRemotePlayback:V5,prefix:null,property:null,results:W5,security:null,unselectable:null},space:`html`,transform:t7}),EXe=Q5({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:q5,accentHeight:W5,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:W5,amplitude:W5,arabicForm:null,ascent:W5,attributeName:null,attributeType:null,azimuth:W5,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:W5,by:null,calcMode:null,capHeight:W5,className:G5,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:W5,diffuseConstant:W5,direction:null,display:null,dur:null,divisor:W5,dominantBaseline:null,download:V5,dx:null,dy:null,edgeMode:null,editable:null,elevation:W5,enableBackground:null,end:null,event:null,exponent:W5,externalResourcesRequired:null,fill:null,fillOpacity:W5,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:K5,g2:K5,glyphName:K5,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:W5,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:W5,horizOriginX:W5,horizOriginY:W5,id:null,ideographic:W5,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:W5,k:W5,k1:W5,k2:W5,k3:W5,k4:W5,kernelMatrix:q5,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:W5,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:W5,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:W5,overlineThickness:W5,paintOrder:null,panose1:null,path:null,pathLength:W5,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:G5,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:W5,pointsAtY:W5,pointsAtZ:W5,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:q5,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:q5,rev:q5,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:q5,requiredFeatures:q5,requiredFonts:q5,requiredFormats:q5,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:W5,specularExponent:W5,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:W5,strikethroughThickness:W5,string:null,stroke:null,strokeDashArray:q5,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:W5,strokeOpacity:W5,strokeWidth:null,style:null,surfaceScale:W5,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:q5,tabIndex:W5,tableValues:null,target:null,targetX:W5,targetY:W5,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:q5,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:W5,underlineThickness:W5,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:W5,values:null,vAlphabetic:W5,vMathematical:W5,vectorEffect:null,vHanging:W5,vIdeographic:W5,version:null,vertAdvY:W5,vertOriginX:W5,vertOriginY:W5,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:W5,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:e7}),n7=Q5({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),r7=Q5({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:t7}),i7=Q5({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),DXe={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},OXe=/[A-Z]/g,a7=/-[a-z]/g,kXe=/^data[-\w.:]+$/i;function AXe(e,t){let n=R5(t),r=t,i=z5;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&kXe.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(a7,MXe);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!a7.test(e)){let n=e.replace(OXe,jXe);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=X5}return new i(r,t)}function jXe(e){return`-`+e.toLowerCase()}function MXe(e){return e.charAt(1).toUpperCase()}var NXe=L5([$5,TXe,n7,r7,i7],`html`),o7=L5([$5,EXe,n7,r7,i7],`svg`);function PXe(e){return e.join(` `).trim()}var FXe=s(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
242
242
|
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),IXe=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(FXe());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),LXe=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),RXe=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(IXe()),r=LXe();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),s7=l7(`end`),c7=l7(`start`);function l7(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function zXe(e){let t=c7(e),n=s7(e);if(t&&n)return{start:t,end:n}}function u7(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?f7(e.position):`start`in e||`end`in e?f7(e):`line`in e||`column`in e?d7(e):``}function d7(e){return p7(e&&e.line)+`:`+p7(e&&e.column)}function f7(e){return d7(e&&e.start)+`-`+d7(e&&e.end)}function p7(e){return e&&typeof e==`number`?e:1}var m7=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=u7(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};m7.prototype.file=``,m7.prototype.name=``,m7.prototype.reason=``,m7.prototype.message=``,m7.prototype.stack=``,m7.prototype.column=void 0,m7.prototype.line=void 0,m7.prototype.ancestors=void 0,m7.prototype.cause=void 0,m7.prototype.fatal=void 0,m7.prototype.place=void 0,m7.prototype.ruleId=void 0,m7.prototype.source=void 0;var BXe=u(RXe(),1),h7={}.hasOwnProperty,VXe=new Map,HXe=/[A-Z]/g,UXe=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),WXe=new Set([`td`,`th`]),g7=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function GXe(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=$Xe(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=QXe(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?o7:NXe,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=_7(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function _7(e,t,n){if(t.type===`element`)return KXe(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return qXe(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return YXe(e,t,n);if(t.type===`mdxjsEsm`)return JXe(e,t);if(t.type===`root`)return XXe(e,t,n);if(t.type===`text`)return ZXe(e,t)}function KXe(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=o7,e.schema=i),e.ancestors.push(t);let a=x7(e,t.tagName,!1),o=eZe(e,t),s=b7(e,t);return UXe.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!CXe(e)})),v7(e,o,a,t),y7(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function qXe(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}S7(e,t.position)}function JXe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);S7(e,t.position)}function YXe(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=o7,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:x7(e,t.name,!0),o=tZe(e,t),s=b7(e,t);return v7(e,o,a,t),y7(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function XXe(e,t,n){let r={};return y7(r,b7(e,t)),e.create(t,e.Fragment,r,n)}function ZXe(e,t){return t.value}function v7(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function y7(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function QXe(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function $Xe(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=c7(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function eZe(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&h7.call(t.properties,i)){let a=nZe(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&WXe.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function tZe(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else S7(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else S7(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function b7(e,t){let n=[],r=-1,i=e.passKeys?new Map:VXe;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=_7(e,a,o);s!==void 0&&n.push(s)}return n}function nZe(e,t,n){let r=AXe(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?vXe(n):PXe(n)),r.property===`style`){let t=typeof n==`object`?n:rZe(e,String(n));return e.stylePropertyNameCase===`css`&&(t=iZe(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?DXe[r.property]||r.property:r.attribute,n]}}function rZe(e,t){try{return(0,BXe.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new m7("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=g7+`#cannot-parse-style-attribute`,r}}function x7(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=P5(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=P5(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return h7.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);S7(e)}function S7(e,t){let n=new m7("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=g7+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function iZe(e){let t={},n;for(n in e)h7.call(e,n)&&(t[aZe(n)]=e[n]);return t}function aZe(e){let t=e.replace(HXe,oZe);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function oZe(e){return`-`+e.toLowerCase()}var C7={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},sZe={};function cZe(e,t){let n=t||sZe;return w7(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function w7(e,t,n){if(lZe(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return T7(e.children,t,n)}return Array.isArray(e)?T7(e,t,n):``}function T7(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=w7(e[i],t,n);return r.join(``)}function lZe(e){return!!(e&&typeof e==`object`)}var E7=document.createElement(`i`);function D7(e){let t=`&`+e+`;`;E7.innerHTML=t;let n=E7.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function O7(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function k7(e,t){return e.length>0?(O7(e,e.length,0,t),e):t}var uZe={}.hasOwnProperty;function dZe(e){let t={},n=-1;for(;++n<e.length;)fZe(t,e[n]);return t}function fZe(e,t){let n;for(n in t){let r=(uZe.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){uZe.call(r,a)||(r[a]=[]);let e=i[a];pZe(r[a],Array.isArray(e)?e:e?[e]:[])}}}function pZe(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);O7(e,0,0,r)}function mZe(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function A7(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var j7=R7(/[A-Za-z]/),M7=R7(/[\dA-Za-z]/),hZe=R7(/[#-'*+\--9=?A-Z^-~]/);function N7(e){return e!==null&&(e<32||e===127)}var P7=R7(/\d/),gZe=R7(/[\dA-Fa-f]/),_Ze=R7(/[!-/:-@[-`{-~]/);function F7(e){return e!==null&&e<-2}function I7(e){return e!==null&&(e<0||e===32)}function L7(e){return e===-2||e===-1||e===32}var vZe=R7(/\p{P}|\p{S}/u),yZe=R7(/\s/);function R7(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function z7(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&M7(e.charCodeAt(n+1))&&M7(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function B7(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return L7(r)?(e.enter(n),s(r)):t(r)}function s(r){return L7(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var bZe={tokenize:xZe};function xZe(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),B7(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return F7(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var SZe={tokenize:wZe},CZe={tokenize:TZe};function wZe(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return O7(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(CZe,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(CZe,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return F7(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;O7(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function TZe(e,t,n){return B7(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function EZe(e){if(e===null||I7(e)||yZe(e))return 1;if(vZe(e))return 2}function V7(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var H7={name:`attention`,resolveAll:DZe,tokenize:OZe};function DZe(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};kZe(d,-c),kZe(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=k7(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=k7(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=k7(l,V7(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=k7(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=k7(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,O7(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function OZe(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=EZe(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=EZe(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function kZe(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var AZe={name:`autolink`,tokenize:jZe};function jZe(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return j7(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||M7(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||M7(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||N7(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):hZe(t)?(e.consume(t),l):n(t)}function u(e){return M7(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||M7(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var U7={partial:!0,tokenize:MZe};function MZe(e,t,n){return r;function r(t){return L7(t)?B7(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||F7(e)?t(e):n(e)}}var NZe={continuation:{tokenize:FZe},exit:IZe,name:`blockQuote`,tokenize:PZe};function PZe(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return L7(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function FZe(e,t,n){let r=this;return i;function i(t){return L7(t)?B7(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(NZe,t,n)(r)}}function IZe(e){e.exit(`blockQuote`)}var LZe={name:`characterEscape`,tokenize:RZe};function RZe(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return _Ze(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var zZe={name:`characterReference`,tokenize:BZe};function BZe(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=M7,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=gZe,u):(e.enter(`characterReferenceValue`),a=7,o=P7,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===M7&&!D7(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var VZe={partial:!0,tokenize:WZe},HZe={concrete:!0,name:`codeFenced`,tokenize:UZe};function UZe(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),L7(t)?B7(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||F7(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(VZe,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||F7(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):L7(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),B7(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||F7(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||F7(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&L7(t)?B7(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||F7(t)?e.check(VZe,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||F7(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),L7(t)?B7(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),L7(t)?B7(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||F7(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function WZe(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var W7={name:`codeIndented`,tokenize:KZe},GZe={partial:!0,tokenize:qZe};function KZe(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),B7(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):F7(t)?e.attempt(GZe,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||F7(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function qZe(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):F7(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):B7(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):F7(e)?i(e):n(e)}}var JZe={name:`codeText`,previous:XZe,resolve:YZe,tokenize:ZZe};function YZe(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function XZe(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function ZZe(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):F7(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||F7(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var QZe=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&G7(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),G7(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),G7(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);G7(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);G7(this.left,t.reverse())}}}};function G7(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function $Ze(e){let t={},n=-1,r,i,a,o,s,c,l,u=new QZe(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,eQe(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return O7(e,0,1/0,u.slice(0)),!l}function eQe(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var tQe={resolve:rQe,tokenize:iQe},nQe={partial:!0,tokenize:aQe};function rQe(e){return $Ze(e),e}function iQe(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):F7(t)?e.check(nQe,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function aQe(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),B7(e,a,`linePrefix`)}function a(i){if(i===null||F7(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function oQe(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||N7(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||F7(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||I7(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||N7(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function sQe(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):F7(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||F7(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!L7(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function cQe(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):F7(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),B7(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||F7(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function K7(e,t){let n;return r;function r(i){return F7(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):L7(i)?B7(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var lQe={name:`definition`,tokenize:dQe},uQe={partial:!0,tokenize:fQe};function dQe(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return sQe.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=A7(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return I7(t)?K7(e,l)(t):l(t)}function l(t){return oQe(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(uQe,d,d)(t)}function d(t){return L7(t)?B7(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||F7(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function fQe(e,t,n){return r;function r(t){return I7(t)?K7(e,i)(t):n(t)}function i(t){return cQe(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return L7(t)?B7(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||F7(e)?t(e):n(e)}}var pQe={name:`hardBreakEscape`,tokenize:mQe};function mQe(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return F7(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var hQe={name:`headingAtx`,resolve:gQe,tokenize:_Qe};function gQe(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},O7(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function _Qe(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||I7(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||F7(n)?(e.exit(`atxHeading`),t(n)):L7(n)?B7(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||I7(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var vQe=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),yQe=[`pre`,`script`,`style`,`textarea`],bQe={concrete:!0,name:`htmlFlow`,resolveTo:CQe,tokenize:wQe},xQe={partial:!0,tokenize:EQe},SQe={partial:!0,tokenize:TQe};function CQe(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function wQe(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):j7(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):j7(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return j7(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||I7(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&yQe.includes(l)?(i=1,r.interrupt?t(s):O(s)):vQe.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||M7(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return L7(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||j7(t)?(e.consume(t),b):L7(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||M7(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):L7(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):L7(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||F7(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||I7(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||L7(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||F7(t)?O(t):L7(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):F7(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(xQe,R,k)(t)):t===null||F7(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(SQe,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||F7(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return yQe.includes(n)?(e.consume(t),L):O(t)}return j7(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||F7(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function TQe(e,t,n){let r=this;return i;function i(t){return F7(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function EQe(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(U7,t,n)}}var DQe={name:`htmlText`,tokenize:OQe};function OQe(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):j7(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):j7(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):F7(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):F7(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):F7(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):F7(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return j7(t)?(e.consume(t),S):n(t)}function S(t){return t===45||M7(t)?(e.consume(t),S):C(t)}function C(t){return F7(t)?(o=C,N(t)):L7(t)?(e.consume(t),C):M(t)}function w(t){return t===45||M7(t)?(e.consume(t),w):t===47||t===62||I7(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||j7(t)?(e.consume(t),E):F7(t)?(o=T,N(t)):L7(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||M7(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):F7(t)?(o=D,N(t)):L7(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):F7(t)?(o=O,N(t)):L7(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):F7(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||I7(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||I7(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return L7(t)?B7(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var q7={name:`labelEnd`,resolveAll:MQe,resolveTo:NQe,tokenize:PQe},kQe={tokenize:FQe},AQe={tokenize:IQe},jQe={tokenize:LQe};function MQe(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&O7(e,0,e.length,n),e}function NQe(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=k7(s,e.slice(a+1,a+r+3)),s=k7(s,[[`enter`,u,t]]),s=k7(s,V7(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=k7(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=k7(s,e.slice(o+1)),s=k7(s,[[`exit`,c,t]]),O7(e,a,e.length,s),e}function PQe(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(A7(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(kQe,u,o?u:d)(t):t===91?e.attempt(AQe,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(jQe,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function FQe(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return I7(t)?K7(e,a)(t):a(t)}function a(t){return t===41?u(t):oQe(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return I7(t)?K7(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?cQe(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return I7(t)?K7(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function IQe(e,t,n){let r=this;return i;function i(t){return sQe.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(A7(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function LQe(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var RQe={name:`labelStartImage`,resolveAll:q7.resolveAll,tokenize:zQe};function zQe(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var BQe={name:`labelStartLink`,resolveAll:q7.resolveAll,tokenize:VQe};function VQe(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var J7={name:`lineEnding`,tokenize:HQe};function HQe(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),B7(e,t,`linePrefix`)}}var Y7={name:`thematicBreak`,tokenize:UQe};function UQe(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||F7(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),L7(t)?B7(e,s,`whitespace`)(t):s(t))}}var X7={continuation:{tokenize:qQe},exit:YQe,name:`list`,tokenize:KQe},WQe={partial:!0,tokenize:XQe},GQe={partial:!0,tokenize:JQe};function KQe(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:P7(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Y7,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return P7(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(U7,r.interrupt?n:u,e.attempt(WQe,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return L7(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function qQe(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(U7,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B7(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!L7(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(GQe,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,B7(e,e.attempt(X7,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function JQe(e,t,n){let r=this;return B7(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function YQe(e){e.exit(this.containerState.type)}function XQe(e,t,n){let r=this;return B7(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!L7(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var ZQe={name:`setextUnderline`,resolveTo:QQe,tokenize:$Qe};function QQe(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function $Qe(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),L7(t)?B7(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||F7(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var e$e={tokenize:t$e};function t$e(e){let t=this,n=e.attempt(U7,r,e.attempt(this.parser.constructs.flowInitial,i,B7(e,e.attempt(this.parser.constructs.flow,i,e.attempt(tQe,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var n$e={resolveAll:o$e()},r$e=a$e(`string`),i$e=a$e(`text`);function a$e(e){return{resolveAll:o$e(e===`text`?s$e:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function o$e(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function s$e(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var c$e=c({attentionMarkers:()=>g$e,contentInitial:()=>u$e,disable:()=>_$e,document:()=>l$e,flow:()=>f$e,flowInitial:()=>d$e,insideSpan:()=>h$e,string:()=>p$e,text:()=>m$e}),l$e={42:X7,43:X7,45:X7,48:X7,49:X7,50:X7,51:X7,52:X7,53:X7,54:X7,55:X7,56:X7,57:X7,62:NZe},u$e={91:lQe},d$e={[-2]:W7,[-1]:W7,32:W7},f$e={35:hQe,42:Y7,45:[ZQe,Y7],60:bQe,61:ZQe,95:Y7,96:HZe,126:HZe},p$e={38:zZe,92:LZe},m$e={[-5]:J7,[-4]:J7,[-3]:J7,33:RQe,38:zZe,42:H7,60:[AZe,DQe],91:BQe,92:[pQe,LZe],93:q7,95:H7,96:JZe},h$e={null:[H7,n$e]},g$e={null:[42,95]},_$e={null:[]};function v$e(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=k7(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=V7(a,l.events,l),l.events):[]}function f(e,t){return b$e(p(e),t)}function p(e){return y$e(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){F7(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&O7(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function y$e(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function b$e(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
243
243
|
`;break;case-3:o=`\r
|
|
244
244
|
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function x$e(e){let t={constructs:dZe([c$e,...(e||{}).extensions||[]]),content:n(bZe),defined:[],document:n(SZe),flow:n(e$e),lazy:{},string:n(r$e),text:n(i$e)};return t;function n(e){return n;function n(n){return v$e(t,e,n)}}}function S$e(e){for(;!$Ze(e););return e}var C$e=/[\0\t\n\r]/g;function w$e(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(C$e.lastIndex=u,c=C$e.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var T$e=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function E$e(e){return e.replace(T$e,D$e)}function D$e(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return mZe(n.slice(t?2:1),t?16:10)}return D7(n)||e}var O$e={}.hasOwnProperty;function k$e(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),A$e(n)(S$e(x$e(n).document().write(w$e()(e,t,!0))))}function A$e(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ge),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(fe),blockQuote:a(se),characterEscape:T,characterReference:T,codeFenced:a(ce),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(ce,o),codeText:a(le,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ue),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(de),hardBreakEscape:a(pe),hardBreakTrailing:a(pe),htmlFlow:a(me,o),htmlFlowData:T,htmlText:a(me,o),htmlTextData:T,image:a(he),label:o,link:a(ge),listItem:a(ve),listItemValue:f,listOrdered:a(_e,d),listUnordered:a(_e),paragraph:a(ye),reference:ee,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(fe),strong:a(be),thematicBreak:a(Se)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:oe,autolinkProtocol:ae,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:re,characterReference:ie,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:te,resourceDestinationString:I,resourceTitleString:L,resource:R,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};j$e(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];O$e.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||N$e).call(a,void 0,e[0])}for(r.position={start:Z7(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Z7(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Z7(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||N$e).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+u7({start:e.start,end:e.end})+`): it’s not open`);n.position.end=Z7(e.end)}function u(){return cZe(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=A7(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=xe(),n.position={start:Z7(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Z7(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=Z7(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=E$e(t),n.identifier=A7(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function ee(){this.data.referenceType=`collapsed`}function te(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=A7(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ne(e){this.data.characterReferenceType=e.type}function re(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=mZe(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=D7(t);let i=this.stack[this.stack.length-1];i.value+=r}function ie(e){let t=this.stack.pop();t.position.end=Z7(e.end)}function ae(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function se(){return{type:`blockquote`,children:[]}}function ce(){return{type:`code`,lang:null,meta:null,value:``}}function le(){return{type:`inlineCode`,value:``}}function ue(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function de(){return{type:`emphasis`,children:[]}}function fe(){return{type:`heading`,depth:0,children:[]}}function pe(){return{type:`break`}}function me(){return{type:`html`,value:``}}function he(){return{type:`image`,title:null,url:``,alt:null}}function ge(){return{type:`link`,title:null,url:``,children:[]}}function _e(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ve(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function ye(){return{type:`paragraph`,children:[]}}function be(){return{type:`strong`,children:[]}}function xe(){return{type:`text`,value:``}}function Se(){return{type:`thematicBreak`}}}function Z7(e){return{line:e.line,column:e.column,offset:e.offset}}function j$e(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?j$e(e,r):M$e(e,r)}}function M$e(e,t){let n;for(n in t)if(O$e.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function N$e(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+u7({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+u7({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+u7({start:t.start,end:t.end})+`) is still open`)}function P$e(e){let t=this;t.parser=n;function n(n){return k$e(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function F$e(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function I$e(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
@@ -262,7 +262,7 @@ Guidance:
|
|
|
262
262
|
|
|
263
263
|
`)}function s2e(e,t){typeof e!=`string`&&e.tag===`img`&&t.push(e)}function c2e(e,t){for(let n of e.children)k9(n,t)}function k9(e,t){switch(e.tag){case`p`:case`h1`:case`h2`:case`h3`:for(let n of e.children)s2e(n,t);return;case`ul`:case`ol`:for(let n of e.children)c2e(n,t);return;case`blockquote`:for(let n of e.children)k9(n,t);return}}function l2e(e){let t=[];for(let n of e)k9(n,t);return t}function u2e(e){return l2e(e).map(e=>e.key)}function A9(e){return e.questions!==void 0&&e.answers===void 0&&!e.cancelled&&e.status===`pending`}var d2e={get_all_schema:{label:`Reading schemas`,icon:(0,Y.jsx)(Uie,{className:`h-3 w-3`})},get_source:{label:`Reading content`,icon:(0,Y.jsx)($v,{className:`h-3 w-3`})},search_content:{label:`Searching`,icon:(0,Y.jsx)(My,{className:`h-3 w-3`})},validate_content:{label:`Validating`,icon:(0,Y.jsx)(Eae,{className:`h-3 w-3`})},create_patch:{label:`Updating content`,icon:(0,Y.jsx)(Dy,{className:`h-3 w-3`})},add_session_image_to_gallery:{label:`Adding image to gallery`,icon:(0,Y.jsx)(Ey,{className:`h-3 w-3`})},remove_image_gallery_entry:{label:`Removing image from gallery`,icon:(0,Y.jsx)(Ey,{className:`h-3 w-3`})},navigate_to:{label:`Navigating to content`,icon:(0,Y.jsx)(xy,{className:`h-3 w-3`})},get_patches:{label:`Loading changes`,icon:(0,Y.jsx)(Wv,{className:`h-3 w-3`})},get_source_path_from_route:{label:`Resolving route`,icon:(0,Y.jsx)(xy,{className:`h-3 w-3`})},get_current_context:{label:`Gathering context`,icon:(0,Y.jsx)(Vy,{className:`h-3 w-3`})},set_session_name:{label:`Naming session`,icon:(0,Y.jsx)(Fae,{className:`h-3 w-3`})},show_compare_view:{label:`Opening compare view`,icon:(0,Y.jsx)(ty,{className:`h-3 w-3`})},ask_user_question:{label:`Asking a question`,icon:(0,Y.jsx)(Hv,{className:`h-3 w-3`})},duplicate_source:{label:`Duplicating content`,icon:(0,Y.jsx)(qv,{className:`h-3 w-3`})},empty_at_path:{label:`Creating empty entry`,icon:(0,Y.jsx)(Zie,{className:`h-3 w-3`})},count_entries:{label:`Counting entries`,icon:(0,Y.jsx)(oy,{className:`h-3 w-3`})},get_record_keys:{label:`Listing keys`,icon:(0,Y.jsx)(my,{className:`h-3 w-3`})}};function j9(e){return d2e[e]??{label:e,icon:(0,Y.jsx)(Ny,{className:`h-3 w-3`})}}function f2e(e){return e===`pending`?`Running`:e===`error`?`Failed`:`Completed`}function p2e({activities:e,onSubmitAnswers:t,onCancel:n,defaultExpanded:r}){let i=e.filter(e=>e.questions===void 0),a=e.filter(e=>e.questions!==void 0);return e.length===0?null:(0,Y.jsxs)(`div`,{className:`not-prose flex flex-col gap-1.5 min-w-0`,children:[i.length>0&&(0,Y.jsx)(h2e,{activities:i,defaultExpanded:r}),a.map(e=>A9(e)&&e.questions?(0,Y.jsx)(v2e,{questions:e.questions,onSubmit:n=>t(e.toolCallId,n),onCancel:()=>n(e.toolCallId)},e.toolCallId):e.questions&&e.answers?(0,Y.jsx)(g2e,{answers:e.answers,questions:e.questions},e.toolCallId):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs py-0.5 text-fg-secondary`,children:[(0,Y.jsx)(Uv,{className:`h-3 w-3`}),(0,Y.jsx)(Hv,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:`Question dismissed`})]},e.toolCallId))]})}function m2e(e){let t=e.find(e=>e.status===`pending`);return t?`${j9(t.name).label}…`:e.length===1?j9(e[0].name).label:`Used ${e.length} tools`}function h2e({activities:e,defaultExpanded:t}){let[n,r]=(0,b.useState)(t===!0),i=(0,b.useId)(),a=e.find(e=>e.status===`pending`),o=e.filter(e=>e.status===`error`).length,s=m2e(e),c=j9((a??e[e.length-1]).name).icon;return(0,Y.jsxs)(`div`,{className:`rounded-md border border-border-primary bg-bg-secondary overflow-hidden`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,"aria-controls":i,className:X(`flex w-full items-center gap-2 px-2.5 py-1.5 text-left`,`text-xs touch:text-sm hover:bg-bg-secondary-hover transition-colors`),children:[(0,Y.jsx)(Rv,{className:X(`h-3 w-3 shrink-0 text-fg-tertiary transition-transform`,n&&`rotate-90`)}),(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-tertiary`,children:c}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-secondary`,children:(0,Y.jsx)(`span`,{className:X(a&&`val-shimmer-text`),children:s})}),o>0&&(0,Y.jsxs)(`span`,{className:`shrink-0 text-fg-error-on-surface`,children:[o,` failed`]})]}),n&&(0,Y.jsx)(`ul`,{id:i,className:`flex flex-col gap-1 border-t border-border-primary px-2.5 py-1.5`,children:e.map(e=>{let t=j9(e.name);return(0,Y.jsxs)(`li`,{className:X(`flex items-center gap-1.5 text-xs touch:text-sm`,e.status===`error`?`text-fg-error-on-surface`:`text-fg-secondary`),children:[(0,Y.jsx)(`span`,{className:`shrink-0`,"aria-hidden":`true`,children:e.status===`pending`?(0,Y.jsx)(hy,{className:`h-3 w-3 animate-spin`}):e.status===`error`?(0,Y.jsx)(Uv,{className:`h-3 w-3`}):(0,Y.jsx)(Fv,{className:`h-3 w-3`})}),(0,Y.jsx)(`span`,{className:`sr-only`,children:f2e(e.status)}),(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-tertiary`,"aria-hidden":`true`,children:t.icon}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,Y.jsxs)(`span`,{className:X(e.status===`pending`&&`val-shimmer-text`),children:[t.label,e.status===`pending`?`…`:``]})})]},e.toolCallId)})})]})}function g2e({questions:e,answers:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-xs text-fg-secondary py-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Hv,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:`Asked a question`})]}),t.map((t,n)=>{let r=e[n],i=[];r&&t.selectedOptions.forEach(e=>{let t=r.options[e]?.label;t&&i.push(t)}),t.customAnswer&&i.push(t.customAnswer);let a=i.join(`, `)||`(no answer)`;return(0,Y.jsxs)(`div`,{className:`pl-4 truncate`,children:[(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`Q:`}),` `,t.question,` `,(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`→`}),` `,a]},n)})]})}function _2e(e){return e.map(e=>{let t=new Set;if(e.defaults&&e.defaults.length>0){let n=e.defaults.filter(t=>Number.isInteger(t)&&t>=0&&t<e.options.length);e.multiSelect?n.forEach(e=>t.add(e)):n.length>0&&t.add(n[0])}return{selected:t,custom:``,otherSelected:!1}})}function v2e({questions:e,onSubmit:t,onCancel:n}){let[r,i]=(0,b.useState)(()=>_2e(e)),[a,o]=(0,b.useState)(!1),s=(0,b.useId)(),c=r.every(e=>e.selected.size>0||e.otherSelected&&e.custom.trim().length>0),l=(e,t,n)=>{a||i(r=>r.map((r,i)=>{if(i!==e)return r;let a=new Set(r.selected);return n?(a.has(t)?a.delete(t):a.add(t),{...r,selected:a}):(a.clear(),a.add(t),{...r,selected:a,otherSelected:!1})}))},u=(e,t)=>{a||i(n=>n.map((n,r)=>r===e?t?{...n,otherSelected:!n.otherSelected}:{...n,selected:new Set,otherSelected:!0}:n))},d=(e,t,n)=>{a||i(r=>r.map((r,i)=>i===e?n?{...r,custom:t,otherSelected:!0}:{...r,custom:t,otherSelected:!0,selected:new Set}:r))},f=(0,b.useRef)(new Map),p=(e,t)=>`${e}:${t}`,m=(e,t,n,r)=>{let i;if(e.key===`ArrowDown`||e.key===`ArrowRight`)i=(n+1)%r;else if(e.key===`ArrowUp`||e.key===`ArrowLeft`)i=(n-1+r)%r;else return;e.preventDefault();let a=r-1;i===a?u(t,!1):l(t,i,!1),f.current.get(p(t,i))?.focus()};return(0,Y.jsxs)(`div`,{className:`not-prose flex flex-col gap-3 rounded-md border border-border-primary bg-bg-secondary p-3 my-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-secondary`,children:[(0,Y.jsx)(Hv,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:`Please answer to continue`})]}),e.map((e,t)=>{let n=e.multiSelect===!0,i=r[t],o=e.options.length,c=o+1,h=`${s}-q${t}`,g=i.otherSelected?o:Array.from(i.selected).sort((e,t)=>e-t)[0]??0,_=e=>n?void 0:g===e?0:-1;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.header&&(0,Y.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-tertiary`,children:e.header}),(0,Y.jsx)(`div`,{id:h,className:`text-sm text-fg-primary`,children:e.question}),(0,Y.jsxs)(`div`,{role:n?`group`:`radiogroup`,"aria-labelledby":h,className:`flex flex-col gap-1`,children:[e.options.map((e,r)=>{let o=i.selected.has(r);return(0,Y.jsxs)(`button`,{ref:e=>{f.current.set(p(t,r),e)},type:`button`,role:n?`checkbox`:`radio`,"aria-checked":o,tabIndex:_(r),disabled:a,onClick:()=>l(t,r,n),onKeyDown:n?void 0:e=>m(e,t,r,c),className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-left text-sm transition-colors`,o?`border-fg-primary bg-bg-primary`:`border-border-primary bg-bg-primary hover:bg-bg-secondary`,a&&`opacity-60 cursor-not-allowed`),children:[(0,Y.jsxs)(`span`,{className:X(`shrink-0 h-3.5 w-3.5 flex items-center justify-center border`,n?`rounded-sm`:`rounded-full`,o?`bg-fg-primary border-fg-primary`:`border-border-primary`),children:[o&&n&&(0,Y.jsx)(Fv,{className:`h-2.5 w-2.5 text-bg-primary`}),o&&!n&&(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-bg-primary`})]}),(0,Y.jsxs)(`span`,{className:`flex-1 leading-tight`,children:[(0,Y.jsx)(`span`,{className:`block text-fg-primary`,children:e.label}),e.description&&(0,Y.jsx)(`span`,{className:`block text-xs text-fg-secondary`,children:e.description})]})]},r)}),(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-sm transition-colors`,i.otherSelected?`border-fg-primary bg-bg-primary`:`border-border-primary bg-bg-primary`,a&&`opacity-60`),children:[(0,Y.jsxs)(`button`,{ref:e=>{f.current.set(p(t,o),e)},type:`button`,role:n?`checkbox`:`radio`,"aria-checked":i.otherSelected,"aria-label":`Other`,tabIndex:_(o),disabled:a,onClick:()=>u(t,n),onKeyDown:n?void 0:e=>m(e,t,o,c),className:X(`shrink-0 h-3.5 w-3.5 flex items-center justify-center border`,n?`rounded-sm`:`rounded-full`,i.otherSelected?`bg-fg-primary border-fg-primary`:`border-border-primary`,a&&`cursor-not-allowed`),children:[i.otherSelected&&n&&(0,Y.jsx)(Fv,{className:`h-2.5 w-2.5 text-bg-primary`}),i.otherSelected&&!n&&(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-bg-primary`})]}),(0,Y.jsx)(`input`,{type:`text`,disabled:a,placeholder:`Other (type your own answer)`,value:i.custom,onChange:e=>d(t,e.target.value,n),className:X(`flex-1 bg-transparent text-fg-primary`,`focus:outline-none placeholder:text-fg-tertiary`)})]})]})]},t)}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{a||(o(!0),n())},disabled:a,children:`Cancel`}),(0,Y.jsx)(t_,{size:`sm`,onClick:()=>{a||!c||(o(!0),t(e.map((e,t)=>{let n=r[t];return{question:e.question,selectedOptions:Array.from(n.selected).sort((e,t)=>e-t),customAnswer:n.otherSelected&&n.custom.trim().length>0?n.custom.trim():null}})))},disabled:a||!c,children:`Submit`})]})]})}function y2e(e){let{isUser:t,isError:n,isStreaming:r,hasText:i,hasFiles:a,hasRunningTool:o,hasPendingQuestion:s}=e,c=r&&!s&&(i||!o);return{hasBubble:t||n||i||a||c||!r&&!s,showCursor:c}}var b2e=[`Summarize recent changes`,`What am I looking at?`,`Fix typos`],x2e=0;function S2e(){return`chat-${++x2e}-${Date.now()}`}function M9(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
264
264
|
|
|
265
|
-
`)}var C2e=/<\/?(?:p|h[1-3]|blockquote|ul|ol|li|strong|b|em|i|del|s|code|br|img|field)\b/i;function w2e(e){return Array.from(e).map((e,t)=>T2e(e,t))}function T2e(e,t){if(e.nodeType===3)return e.nodeValue??``;if(e.nodeType!==1)return null;let n=e,r=w2e(n.childNodes);switch(n.tagName.toLowerCase()){case`p`:return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:r},t);case`h1`:return(0,Y.jsx)(`h1`,{className:`text-base font-semibold`,children:r},t);case`h2`:return(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:r},t);case`h3`:return(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:r},t);case`blockquote`:return(0,Y.jsx)(`blockquote`,{className:`border-l-2 border-border-primary pl-2 italic`,children:r},t);case`ul`:return(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:r},t);case`ol`:return(0,Y.jsx)(`ol`,{className:`list-decimal pl-5`,children:r},t);case`li`:return(0,Y.jsx)(`li`,{children:r},t);case`strong`:case`b`:return(0,Y.jsx)(`strong`,{children:r},t);case`em`:case`i`:return(0,Y.jsx)(`em`,{children:r},t);case`del`:case`s`:return(0,Y.jsx)(`del`,{children:r},t);case`code`:return(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.85em]`,children:r},t);case`br`:return(0,Y.jsx)(`br`,{},t);case`img`:{let e=n.getAttribute(`alt`);return(0,Y.jsxs)(`span`,{className:`italic text-fg-secondary`,children:[`[`,e?`image: ${e}`:`image`,`]`]},t)}case`field`:{let e=n.getAttribute(`path`)??``;return(0,Y.jsxs)(`span`,{className:`rounded bg-bg-tertiary px-1 py-0.5 text-fg-brand-primary`,children:[`@`,e]},t)}default:return(0,Y.jsx)(b.Fragment,{children:r},t)}}function E2e(e){if(!C2e.test(e))return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e});let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`);return(0,Y.jsx)(Y.Fragment,{children:w2e(t.body.childNodes)})}function D2e({doc:e}){return(0,Y.jsx)(Y.Fragment,{children:e.map((e,t)=>N9(e,t))})}function N9(e,t){switch(e.tag){case`p`:return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.children.map((e,t)=>P9(e,t))},t);case`h1`:return(0,Y.jsx)(`h1`,{className:`text-base font-semibold`,children:e.children.map((e,t)=>P9(e,t))},t);case`h2`:return(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.children.map((e,t)=>P9(e,t))},t);case`h3`:return(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.children.map((e,t)=>P9(e,t))},t);case`blockquote`:return(0,Y.jsx)(`blockquote`,{className:`border-l-2 border-border-primary pl-2 italic`,children:e.children.map((e,t)=>N9(e,t))},t);case`ul`:return(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:e.children.map((e,t)=>(0,Y.jsx)(`li`,{children:e.children.map((e,t)=>N9(e,t))},t))},t);case`ol`:return(0,Y.jsx)(`ol`,{className:`list-decimal pl-5`,children:e.children.map((e,t)=>(0,Y.jsx)(`li`,{children:e.children.map((e,t)=>N9(e,t))},t))},t)}}function P9(e,t){if(typeof e==`string`)return e;if(e.tag===`br`)return(0,Y.jsx)(`br`,{},t);if(e.tag===`span`){let n=e.children[0];for(let r of e.styles)r===`bold`?n=(0,Y.jsx)(`strong`,{children:n},t):r===`italic`?n=(0,Y.jsx)(`em`,{children:n},t):r===`line-through`?n=(0,Y.jsx)(`del`,{children:n},t):r===`code`&&(n=(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.85em]`,children:n},t));return(0,Y.jsx)(b.Fragment,{children:n},t)}return e.tag===`img`?e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.alt??``,className:`inline-block max-h-16 rounded border border-border-primary align-baseline mx-0.5`},t):(0,Y.jsxs)(`span`,{className:`italic text-fg-secondary`,children:[`[`,e.alt?`image: ${e.alt}`:`image`,`]`]},t):e.tag===`field_ref`?(0,Y.jsxs)(`span`,{className:`rounded bg-bg-tertiary px-1 py-0.5 text-fg-brand-primary`,children:[`@`,e.path]},t):null}function O2e(e){return typeof e==`string`?[]:e.filter(e=>e.type===`image_url`).map(e=>e.url)}var k2e=(0,b.forwardRef)(function({onCancel:e,models:t,selectedModel:n,onSelectModel:r,onSendMessage:i,onUploadFile:a,onNewSession:o,suggestions:s=b2e,className:c,isConnected:l,authError:u,unavailable:d,mode:f,sessions:p,currentSessionId:m,onLoadSession:h,onFetchSessions:g,onSetSessionName:_,isLoadingSession:v,onAnswerToolQuestions:y,onCancelToolQuestion:x,initialMessages:S,chatEditorRef:C},w){let[T,E]=(0,b.useState)(S??[]),[D,O]=(0,b.useState)(null),[k,A]=(0,b.useState)(!0),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)([]),L=(0,b.useRef)(null),R=(0,b.useRef)(null),ee=C??R,te=(0,b.useRef)(null),[ne,re]=(0,b.useState)(!1),[ie,ae]=(0,b.useState)(null),[oe,se]=(0,b.useState)(``),ce=bb(),le=eb(),ue=ce?.ai?.chat?.suggestions??s,de=ce?.ai?.chat?.title,fe=ce?.ai?.chat?.description,pe=D?[...T,D.message]:T;(0,b.useEffect)(()=>{requestAnimationFrame(()=>{te.current?.scrollIntoView({block:`end`})})},[pe]),(0,b.useEffect)(()=>{D&&P(!1)},[D]);let me=(D?.message.toolActivities??[]).some(A9),he=(0,b.useCallback)((e,t)=>{O(n=>{if(!n)return null;if(e!==null&&n.message.id!==e)return n;let r=t(n.message);return E(e=>e.some(e=>e.id===r.id)?e:[...e,r]),null})},[]),ge=(0,b.useCallback)(e=>({...e,status:`error`,error:`Response timed out`}),[]);(0,b.useEffect)(()=>{if(!D||me)return;let e=12e4-(Date.now()-D.startedAt);if(e<=0){he(D.message.id,ge);return}let t=setTimeout(()=>{he(null,ge)},e);return()=>clearTimeout(t)},[D,me,he,ge]);let _e=(0,b.useCallback)((e,t,n)=>{let r=e=>({...e,toolActivities:(e.toolActivities??[]).map(e=>e.toolCallId===t?n(e):e)});O(t=>!t||t.message.id!==e?t:{message:r(t.message),startedAt:Date.now()}),E(t=>t.some(t=>t.id===e)?t.map(t=>t.id===e?r(t):t):t)},[]),ve=(0,b.useCallback)((e,t,n)=>{_e(e,t,e=>({...e,status:`complete`,answers:n}))},[_e]),ye=(0,b.useCallback)((e,t)=>{_e(e,t,e=>({...e,status:`error`,cancelled:!0}))},[_e]);(0,b.useImperativeHandle)(w,()=>({startAssistantMessage(e){O({message:{id:e,role:`assistant`,content:``,status:`streaming`},startedAt:Date.now()})},appendAssistantChunk(e,t){O(n=>n?.message.id===e?{...n,message:{...n.message,content:M9(n.message.content)+t}}:n)},completeAssistantMessage(e){he(e,e=>({...e,status:`complete`}))},errorAssistantMessage(e,t,n,r,i){he(e,e=>({...e,status:`error`,error:t,errorAction:r,errorCode:n,errorDetails:i}))},addToolCall(e,t,n,r){let i={toolCallId:t,name:n,status:`pending`,...r?{questions:r}:{}};O(t=>t&&t.message.id===e?{...t,message:{...t.message,toolActivities:[...t.message.toolActivities??[],i]}}:t)},completeToolCall(e,t){O(n=>!n||n.message.id!==e?n:{...n,message:{...n.message,toolActivities:(n.message.toolActivities??[]).map(e=>e.toolCallId===t?{...e,status:`complete`}:e)}})},errorToolCall(e,t){O(n=>!n||n.message.id!==e?n:{...n,message:{...n.message,toolActivities:(n.message.toolActivities??[]).map(e=>e.toolCallId===t?{...e,status:`error`}:e)}})},clearMessages(){E([]),O(null)},loadMessages(e){O(null),E(e)}}));let be=D!==null,xe=F.some(e=>e.status===`uploading`),Se=pe.length===0,Ce=(0,b.useCallback)(e=>{let t=Array.from(e.target.files??[]);if(t.length===0)return;e.target.value=``;let n=t.map(e=>({id:crypto.randomUUID(),file:e,status:`uploading`,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0}));I(e=>[...e,...n]),a&&n.forEach(e=>{a(e.file).then(({key:t})=>{I(n=>n.map(n=>n.id===e.id?{...n,status:`done`,key:t}:n))}).catch(t=>{console.error(`Failed to upload file`,{fileName:e.file.name,error:t}),I(t=>t.map(t=>t.id===e.id?{...t,status:`error`}:t))})})},[a]),we=(0,b.useCallback)(e=>{I(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),z=(0,b.useCallback)(e=>{if(be)return;let t,n,r;if(e!==void 0){let r=e.trim();if(!r)return;t=r,n=r}else{let e=ee.current;if(!e||e.isEmpty())return;let i=e.getDocument();if(u2e(i).some(e=>e.startsWith(`pending:`)))return;t=i,r=i,n=o2e(i)}let a=F.filter(e=>e.status===`done`&&e.key!==void 0).map(e=>({key:e.key,name:e.file.name,mimeType:e.file.type||void 0,previewUrl:e.previewUrl}));F.forEach(e=>{e.previewUrl&&e.status!==`done`&&URL.revokeObjectURL(e.previewUrl)}),I([]);let o=S2e(),s={id:o,role:`user`,content:n,status:`complete`,attachments:a.length>0?a:void 0,userDoc:r};E(e=>[...e,s]),e===void 0&&(ee.current?.clear(),A(!0)),!i||i(t,a.length>0?a:void 0)?P(!0):E(e=>e.map(e=>e.id===o?{...e,status:`error`,error:`Failed to send`}:e)),requestAnimationFrame(()=>ee.current?.focus())},[be,F,i,ee]),B=(0,b.useCallback)(e=>{let t=pe.find(t=>t.id===e);if(t?.role===`user`){E(t=>t.map(t=>t.id===e?{...t,status:`complete`,error:void 0}:t));let n=t.userDoc??M9(t.content);!i||i(n,t.attachments)?P(!0):E(t=>t.map(t=>t.id===e?{...t,status:`error`,error:`Failed to send`}:t));return}let n=pe.findIndex(t=>t.id===e);if(n<=0)return;let r=pe.slice(0,n).reverse().find(e=>e.role===`user`);if(!r)return;E(t=>t.filter(t=>t.id!==e));let a=r.userDoc??M9(r.content);(i?.(a,r.attachments)??!0)&&P(!0)},[pe,i]);return(0,Y.jsxs)(`div`,{className:X(`flex flex-col h-full w-full bg-bg-primary text-fg-primary relative overflow-hidden`,c),children:[(!Se||g)&&(0,Y.jsxs)(`div`,{className:`shrink-0 flex justify-between items-center p-2 border-b border-border-primary`,children:[(0,Y.jsx)(`div`,{children:g&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{g(),re(!0)},className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Ay,{className:`h-3 w-3`}),`History`]})}),(0,Y.jsx)(`div`,{children:!Se&&o&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:o,disabled:be,className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Oy,{className:`h-3 w-3`}),`New chat`]})})]}),ne&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 z-overlay flex flex-col bg-bg-primary`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 p-2 border-b border-border-primary`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:()=>{re(!1),ae(null)},"aria-label":`Back to chat`,children:(0,Y.jsx)(Lv,{className:`h-4 w-4`})}),(0,Y.jsx)(`span`,{className:`text-sm font-medium flex-1`,children:`Chat history`}),o&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{o(),re(!1)},className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Oy,{className:`h-3 w-3`}),`New chat`]})]}),(0,Y.jsx)(eD,{className:`flex-1 min-h-0`,children:!p||p.length===0?(0,Y.jsx)(`div`,{className:`p-6 text-center text-sm text-fg-secondary`,children:`No previous sessions`}):(0,Y.jsx)(`div`,{className:`flex flex-col divide-y divide-border-primary`,children:p.map(e=>{let t=e.id===m,n=ie===e.id,r=e.name??`Chat, ${new Date(e.updatedAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}`;return(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 px-3 py-2.5 group`,t&&`bg-bg-secondary`),children:[n?(0,Y.jsx)(`input`,{autoFocus:!0,className:`flex-1 text-sm bg-bg-primary border border-border-primary rounded px-2 py-0.5 focus:outline-none focus:ring-1 focus:ring-border-focus`,value:oe,onChange:e=>se(e.target.value),onKeyDown:t=>{if(t.key===`Enter`){let t=oe.trim();t&&_&&_(e.id,t),ae(null)}else t.key===`Escape`&&ae(null)},onBlur:()=>{let t=oe.trim();t&&_&&_(e.id,t),ae(null)}}):(0,Y.jsx)(`button`,{className:`flex-1 text-left text-sm truncate`,onClick:()=>{h?.(e.id),re(!1)},children:r}),!n&&(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,className:`opacity-0 group-hover:opacity-100 shrink-0`,onClick:t=>{t.stopPropagation(),se(e.name??``),ae(e.id)},"aria-label":`Rename session`,children:(0,Y.jsx)(Dy,{className:`h-3 w-3`})})]},e.id)})})})]}),(0,Y.jsx)(eD,{className:`flex-1 min-h-0`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 min-w-0 max-w-full`,children:[u?(0,Y.jsx)(j2e,{mode:f}):v&&Se?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-12 text-fg-secondary`,children:[(0,Y.jsx)(hy,{className:`h-5 w-5 animate-spin`}),(0,Y.jsx)(`span`,{className:`text-sm`,children:`Loading conversation…`})]}):Se?(0,Y.jsx)(M2e,{suggestions:ue,title:de,description:fe,onSelect:e=>z(e)}):pe.map(e=>(0,Y.jsx)(N2e,{message:e,onRetry:B,onSubmitToolAnswers:(t,n)=>{ve(e.id,t,n),y?.(t,n)},onCancelToolQuestion:t=>{ye(e.id,t),x?.(t)}},e.id)),N&&!D&&(0,Y.jsx)(I2e,{}),(0,Y.jsx)(`div`,{ref:te})]})}),(0,Y.jsx)(`div`,{className:`shrink-0 border-t border-border-primary bg-bg-primary p-3`,children:d&&!u?(0,Y.jsx)(A2e,{...d}):(0,Y.jsxs)(Y.Fragment,{children:[!l&&!u&&(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-center gap-1.5 rounded-md border border-border-primary bg-bg-secondary px-2 py-1.5 text-xs touch:text-sm text-fg-secondary`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),`Connecting…`]}),F.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:F.map(e=>(0,Y.jsxs)(`div`,{className:`relative flex items-center gap-1.5 rounded-md border border-border-primary bg-bg-secondary px-2 py-1 text-xs touch:text-sm text-fg-primary`,children:[e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.file.name,className:`h-8 w-8 rounded object-cover`}):(0,Y.jsx)($v,{className:`h-4 w-4 shrink-0 text-fg-secondary`}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.file.name}),e.status===`uploading`&&(0,Y.jsx)(hy,{className:`h-3 w-3 animate-spin text-fg-secondary`}),e.status===`error`&&(0,Y.jsx)(Uv,{className:`h-3 w-3 text-fg-error-primary`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>we(e.id),className:`ml-0.5 text-fg-secondary hover:text-fg-primary`,"aria-label":`Remove ${e.file.name}`,children:(0,Y.jsx)(Hy,{className:`h-3 w-3`})})]},e.id))}),a&&(0,Y.jsx)(`input`,{ref:L,type:`file`,multiple:!0,className:`hidden`,onChange:Ce,accept:`image/*`}),(0,Y.jsxs)(`div`,{className:X(`flex flex-col rounded-md border border-border-primary bg-bg-primary`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-border-focus`),children:[(0,Y.jsx)(Z0e,{ref:ee,disabled:u||!l||be,placeholder:l&&!u?`Ask something…`:``,onSubmit:()=>z(),onUploadAiImage:a,getPortalContainer:()=>le,onChange:e=>{let t=e.length===0||e.length===1&&e[0].tag===`p`&&e[0].children.length===0;A(t);let n=u2e(e);M(n.some(e=>e.startsWith(`pending:`)))},className:X(`max-h-[18rem] overflow-y-auto px-3 pt-3 pb-1`,`text-fg-primary text-base`)}),(0,Y.jsxs)(`div`,{className:`flex items-center border-t border-border-primary px-2 py-1.5`,children:[a&&(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,disabled:!l||be||u,onClick:()=>L.current?.click(),"aria-label":`Attach files`,children:(0,Y.jsx)(Ey,{className:`h-4 w-4`})}),t&&t.length>1&&r&&(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,disabled:be,className:`h-7 px-2 text-xs text-fg-secondary gap-1`,"aria-label":F9(t,n)===P2e?`Choose a model`:`Change model, currently ${F9(t,n)}`,children:[F9(t,n),(0,Y.jsx)(Iv,{className:`h-3 w-3`})]})}),(0,Y.jsx)(j3,{align:`start`,className:`max-h-72 overflow-y-auto`,children:t.map(e=>{let t=n?.provider===e.ref.provider&&n?.model===e.ref.model;return(0,Y.jsxs)(M3,{onSelect:()=>r(e.ref),className:`text-xs`,children:[(0,Y.jsx)(Fv,{className:X(`h-3 w-3 mr-2`,t?`opacity-100`:`opacity-0`)}),e.label]},`${e.ref.provider}:${e.ref.model}`)})})]}),be&&e?(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:e,"aria-label":`Stop generating`,title:`Stop generating`,className:`ml-auto`,children:(0,Y.jsx)(jae,{className:`h-3.5 w-3.5 fill-current`})}):(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,disabled:!l||be||xe||j||u||k,onClick:()=>z(),"aria-label":`Send message`,className:`ml-auto`,children:(0,Y.jsx)(Cae,{className:`h-4 w-4`})})]})]})]})})]})});function A2e({message:e,onRetry:t}){return(0,Y.jsxs)(`div`,{className:`rounded-md border border-border-primary bg-bg-secondary p-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Ly,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-fg-error-primary`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-fg-primary`,children:`The assistant is unavailable`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[0.6875rem] text-fg-secondary`,children:e})]})]}),(0,Y.jsx)(t_,{variant:`outline`,size:`sm`,onClick:t,className:`mt-2 text-xs`,children:`Try again`})]})}function j2e({mode:e}){let t=e===`fs`;return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 py-12 text-center`,children:[(0,Y.jsx)(`div`,{className:`rounded-full bg-bg-secondary p-3`,children:(0,Y.jsx)(_y,{className:`h-6 w-6`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-lg font-semibold text-fg-primary`,children:`Login to use AI chat`}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:t?`Val is running in development mode. Run this command in your project root to create a personal access token, then refresh:`:`Your session has expired. Sign in again to continue.`})]}),t?(0,Y.jsx)(`div`,{className:`w-full text-left`,children:(0,Y.jsx)(E5,{code:`npx -p @valbuild/cli val login`})}):(0,Y.jsx)(t_,{asChild:!0,variant:`default`,size:`sm`,children:(0,Y.jsxs)(`a`,{href:Jf(`/api/val/authorize`,{redirect_to:window.location.href}),children:[(0,Y.jsx)(_y,{className:`mr-2 h-4 w-4`}),`Sign in`]})})]})}function M2e({suggestions:e,title:t,description:n,onSelect:r}){return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-6 py-16 text-center`,children:[(0,Y.jsx)(`div`,{className:`rounded-full p-3`,children:(0,Y.jsx)(Ny,{className:`h-8 w-8`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-lg font-semibold text-fg-primary`,children:t??`How can I help?`}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:n??`Ask me anything or pick a suggestion below`})]}),e.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:e.map(e=>(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>r(e),className:`text-sm`,children:e},e))})]})}function N2e({message:e,onRetry:t,onSubmitToolAnswers:n,onCancelToolQuestion:r}){let i=e.role===`user`,a=e.status===`error`,o=e.status===`streaming`,s=e.toolActivities??[],c=s.some(A9),l=s.some(e=>e.status===`pending`&&e.questions===void 0),u=M9(e.content),d=O2e(e.content),{hasBubble:f,showCursor:p}=y2e({isUser:i,isError:a,isStreaming:o,hasText:u.length>0,hasFiles:d.length>0,hasRunningTool:l,hasPendingQuestion:c});return(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-1.5 min-w-0`,i?`items-end`:`items-stretch`),children:[!i&&s.length>0&&(0,Y.jsx)(p2e,{activities:s,onSubmitAnswers:n,onCancel:r}),f&&(0,Y.jsxs)(`div`,{className:X(`min-w-0 overflow-hidden rounded-lg px-4 py-2.5 text-sm touch:text-base leading-relaxed`,`[overflow-wrap:anywhere]`,i?`bg-bg-secondary text-fg-primary max-w-[80%]`:`bg-bg-tertiary text-fg-primary w-full max-w-full`,a&&`border border-border-error-primary`),children:[i?(0,Y.jsxs)(Y.Fragment,{children:[e.attachments&&e.attachments.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-1.5`,children:e.attachments.map(e=>e.mimeType?.startsWith(`image/`)&&e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`h-16 w-16 rounded object-cover`},e.key):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded border border-border-primary bg-bg-primary px-2 py-1 text-xs text-fg-secondary`,children:[(0,Y.jsx)($v,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.name})]},e.key))}),d.length>0&&(0,Y.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:d.map(e=>(0,Y.jsx)(`img`,{src:e,alt:`Session attachment`,className:`max-h-48 rounded object-contain`},e))}),e.userDoc?(0,Y.jsx)(D2e,{doc:e.userDoc}):u&&E2e(u)]}):(0,Y.jsxs)(`div`,{className:X(`prose prose-sm dark:prose-invert max-w-none`,`[&_pre]:overflow-x-auto [&_pre]:max-w-full`,`[&_code]:break-words`,`[&_table]:block [&_table]:overflow-x-auto [&_table]:max-w-full`,`[&_a]:break-all`),children:[d.length>0&&(0,Y.jsx)(`div`,{className:`not-prose mb-3 flex flex-wrap gap-2`,children:d.map(e=>(0,Y.jsx)(`img`,{src:e,alt:`AI session image`,className:`max-h-64 rounded border border-border-primary object-contain`},e))}),u?(0,Y.jsx)(_0e,{children:u}):o||a||d.length>0||c?null:(0,Y.jsx)(`p`,{className:`text-fg-secondary italic`,children:`Empty response`}),p&&(0,Y.jsx)(F2e,{})]}),a&&(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-fg-error-primary`,children:e.error??`Something went wrong`}),e.errorAction&&S0e(e.errorAction.url)&&(0,Y.jsx)(`a`,{href:S0e(e.errorAction.url),target:`_blank`,rel:`noreferrer noopener`,className:`text-xs text-fg-brand-primary underline`,children:e.errorAction.label}),e.errorDetails&&(0,Y.jsxs)(`details`,{className:`text-xs text-fg-secondary`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),(0,Y.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-bg-secondary p-2 font-mono text-[11px] text-fg-secondary`,children:e.errorDetails})]})]}),(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:()=>t(e.id),"aria-label":`Retry`,className:`h-6 w-6`,children:(0,Y.jsx)(xae,{className:`h-3.5 w-3.5 text-fg-error-primary`})})]})]})]})}var P2e=`Model`;function F9(e,t){return(t?e.find(e=>e.ref.provider===t.provider&&e.ref.model===t.model):void 0)?.label??P2e}function F2e(){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 ml-1 align-middle`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`150ms`}}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`300ms`}})]})}function I2e(){return(0,Y.jsx)(`div`,{className:`flex justify-start`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg bg-bg-tertiary px-4 py-3`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`150ms`}}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`300ms`}})]})})}function L2e(){let e=nb();return{query:(0,b.useCallback)(async(t,n,r)=>{if(e===null)return;let i=await e.system.search(t,n,r);return i.status===`no-index`?{results:[],total:0}:{results:i.results,total:i.total}},[e])}}function R2e(){let e=Fb();return{getErrors:(0,b.useCallback)(()=>{let t=e??{},n=new Map;for(let e in t){let r=e,[i]=H.splitModuleFilePathAndModulePath(r),a=t[r]??[],o={sourcePath:e,messages:a.map(e=>e.message)};a.some(e=>e.typeError)&&(o.typeError=!0),a.some(e=>e.schemaError)&&(o.schemaError=!0),a.some(e=>e.keyError)&&(o.keyError=!0);let s=n.get(i)??[];s.push(o),n.set(i,s)}return Array.from(n.entries()).map(([e,t])=>({modulePath:e,errors:t}))},[e])}}var I9=`_tag`;function L9(e){if(typeof e!=`object`||!e)return!1;let t=e;return!(t._type!==`ai_session_file`||t[I9]!==`image`&&t[I9]!==`file`||typeof t.key!=`string`||typeof t.filePath!=`string`)}function z2e(e){return JSON.parse(JSON.stringify(e))}function B2e(e,t,n){if(t.length===0)return{ok:!1,reason:`cannot set at empty path`};let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];if(Array.isArray(r)){let i=Number(n);if(!Number.isInteger(i)||i<0||i>=r.length)return{ok:!1,reason:`index out of bounds at ${t.slice(0,e+1).join(`/`)}`};r=r[i]}else if(r&&typeof r==`object`)r=r[n];else return{ok:!1,reason:`cannot descend into non-object at ${t.slice(0,e+1).join(`/`)}`}}let i=t[t.length-1];if(Array.isArray(r)){let e=Number(i);return Number.isInteger(e)?(r[e]=n,{ok:!0}):{ok:!1,reason:`expected numeric index at ${t.join(`/`)}`}}return r&&typeof r==`object`?(r[i]=n,{ok:!0}):{ok:!1,reason:`cannot set on non-object at ${t.join(`/`)}`}}function V2e(e,t,n){let r=(e,i)=>{if(L9(e)){n(i);return}if(Array.isArray(e)){e.forEach((e,t)=>r(e,[...i,String(t)]));return}if(e&&typeof e==`object`){let n=e;if(n.tag===`img`&&L9(n.src)){for(let[e,t]of Object.entries(n))e!==`src`&&r(t,[...i,e]);t(n.src,[...i,`src`]);return}for(let[e,t]of Object.entries(n))r(t,[...i,e])}};r(e,[])}function R9(e){return L9(e)?!0:Array.isArray(e)?e.some(R9):e&&typeof e==`object`?Object.values(e).some(R9):!1}function H2e(e,t){let n=e?{...e}:{};return t[I9]===`image`&&(t.alt!==void 0&&(n.alt=t.alt),t.hotspot!==void 0&&(n.hotspot=t.hotspot)),n}function U2e(e){let{patch:t,moduleSchema:n}=e,r=[];for(let e=0;e<t.length;e++){let i=t[e];if(i.op===`file`)return{kind:`error`,message:`Patch op #${e} is a 'file' op — those are emitted by the system, not by create_patch input.`};if(i.op===`remove`||i.op===`move`||i.op===`copy`)continue;if(i.op===`test`){if(R9(i.value))return{kind:`error`,message:`Patch op #${e} ('test') cannot contain a SessionKey.`};continue}let a=i.path,o=Ep(n,a);if(o.kind===`unresolved`){if(R9(i.value))return{kind:`error`,message:`Patch op #${e} contains a SessionKey but the path ${JSON.stringify(a)} could not be resolved against the module schema.`};continue}if(o.kind===`gallery-traversed`){if(R9(i.value))return{kind:`wrong-tool`,suggestedTool:`add_session_image_to_gallery`,reason:`Patch op #${e} targets an images gallery (s.images()) with a SessionKey. Galleries use file paths as keys; use add_session_image_to_gallery instead.`};continue}if(o.kind===`leaf`){let t=o.schema,n=L9(i.value);if(t.type===`image`||t.type===`file`){if(n){let n=i.value;if(n[I9]!==t.type)return{kind:`error`,message:`Patch op #${e}: SessionKey _tag is '${n[I9]}' but the schema is '${t.type}'.`};r.push({kind:`leaf`,opIndex:e,opPath:a,subtype:t.type,remote:Op(t),sessionKey:n});continue}if(R9(i.value))return{kind:`error`,message:`Patch op #${e}: SessionKey nested inside a non-SessionKey value at an ${t.type} field. Place the SessionKey directly as the value.`};continue}if(R9(i.value))return{kind:`error`,message:`Patch op #${e}: SessionKey is not allowed at a '${t.type}' field.`};continue}let s=Dp(o.schema),c=0,l=null;if(V2e(i.value,(t,n)=>{r.push({kind:`inline-img`,opIndex:e,opPath:a,valuePath:n,remote:s.kind===`allowed`&&s.remote,sessionKey:t}),c+=1},e=>{l===null&&(l=e)}),l)return{kind:`error`,message:`Patch op #${e}: SessionKey at value path ${JSON.stringify(l)} is not inside a {tag:"img", src: ...} node.`};if(c>0&&s.kind===`not-allowed`)return{kind:`error`,message:`Patch op #${e} inserts an inline image into a richtext that does not allow inline images (options.inline.img is not enabled).`}}return{kind:`ok`,transfers:r.map((e,t)=>({siteId:t,key:e.sessionKey.key,filePath:e.sessionKey.filePath,isRemote:e.remote})),apply:e=>{if(r.length===0)return{kind:`ok`,patch:t};let n=t.map(e=>z2e(e)),i=[];for(let t=0;t<r.length;t++){let a=r[t],o=H2e(e[t],a.sessionKey),s=wp(a.sessionKey.filePath,o);if(a.kind===`leaf`){let e=n[a.opIndex];e.value=s,i.push({op:`file`,path:a.opPath,filePath:a.sessionKey.filePath,value:a.sessionKey.key,remote:a.remote,metadata:o})}else{let e=n[a.opIndex];if(a.valuePath.length===0)e.value=s;else{let t=B2e(e.value,a.valuePath,s);if(!t.ok)return{kind:`error`,message:`Failed to rewrite SessionKey at op #${a.opIndex}, value path ${JSON.stringify(a.valuePath)}: ${t.reason}`}}i.push({op:`file`,path:a.opPath,nestedFilePath:a.valuePath,filePath:a.sessionKey.filePath,value:a.sessionKey.key,remote:a.remote,metadata:o})}}let a=[...n,...i],o=Jd.safeParse(a);return o.success?{kind:`ok`,patch:o.data}:{kind:`error`,message:`Rewritten patch failed schema validation: ${JSON.stringify(o.error)}`}}}}async function W2e(e){let t=U2e({patch:e.patch,moduleSchema:e.moduleSchema,moduleSource:e.moduleSource});if(t.kind!==`ok`)return t;let n={};if(t.transfers.length>0){let r=e=>`${e.isRemote?`1`:`0`}${e.filePath}${e.key}`,i=[],a=new Map;for(let e of t.transfers){let t=r(e);a.has(t)||(a.set(t,i.length),i.push({filePath:e.filePath,key:e.key,isRemote:e.isRemote}))}let o=await e.transfer({patchId:e.patchId,parentRef:e.parentRef,files:i});if(o.files.length!==i.length)return{kind:`error`,message:`Session image transfer returned ${o.files.length} results for ${i.length} files.`};for(let e of t.transfers){let t=a.get(r(e));if(t===void 0)return{kind:`error`,message:`Internal error: missing transfer index for site ${e.siteId}.`};n[e.siteId]=o.files[t].metadata}}let r=t.apply(n);return r.kind===`error`?{kind:`error`,message:r.message}:{kind:`ok`,patch:r.patch}}var G2e=new qr,K2e={name:`get_all_schema`,description:`Get all val schemas — returns the complete schema definitions for all val modules`,parameters:{type:`object`,properties:{},required:[]}},q2e={name:`get_source`,description:`Get the current source content of a Val module by its file path. The 'module_file_path' must exactly match one of the keys returned by get_all_schema.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/homepage.val.ts'. Can be obtained from the keys of get_all_schema.`}},required:[`module_file_path`]}},J2e={name:`search_content`,description:`Search content — accepts a query and returns matching content items. Returns { results, total } where total is the number of matches found. Use offset to page through results if total exceeds the returned results count.`,parameters:{type:`object`,properties:{query:{type:`string`,description:`The search query`},limit:{type:`number`,description:`Max results to return (default 50)`},offset:{type:`number`,description:`Number of results to skip for pagination (default 0)`}},required:[`query`]}},Y2e={name:`validate_content`,description:`Get all current validation errors — returns a list of modules with their validation errors, grouped by module path`,parameters:{type:`object`,properties:{},required:[]}},X2e={name:`create_patch`,description:`Create a Val patch — applies JSON Patch operations to a Val module.
|
|
265
|
+
`)}var C2e=/<\/?(?:p|h[1-3]|blockquote|ul|ol|li|strong|b|em|i|del|s|code|br|img|field)\b/i;function w2e(e){return Array.from(e).map((e,t)=>T2e(e,t))}function T2e(e,t){if(e.nodeType===3)return e.nodeValue??``;if(e.nodeType!==1)return null;let n=e,r=w2e(n.childNodes);switch(n.tagName.toLowerCase()){case`p`:return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:r},t);case`h1`:return(0,Y.jsx)(`h1`,{className:`text-base font-semibold`,children:r},t);case`h2`:return(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:r},t);case`h3`:return(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:r},t);case`blockquote`:return(0,Y.jsx)(`blockquote`,{className:`border-l-2 border-border-primary pl-2 italic`,children:r},t);case`ul`:return(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:r},t);case`ol`:return(0,Y.jsx)(`ol`,{className:`list-decimal pl-5`,children:r},t);case`li`:return(0,Y.jsx)(`li`,{children:r},t);case`strong`:case`b`:return(0,Y.jsx)(`strong`,{children:r},t);case`em`:case`i`:return(0,Y.jsx)(`em`,{children:r},t);case`del`:case`s`:return(0,Y.jsx)(`del`,{children:r},t);case`code`:return(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.85em]`,children:r},t);case`br`:return(0,Y.jsx)(`br`,{},t);case`img`:{let e=n.getAttribute(`alt`);return(0,Y.jsxs)(`span`,{className:`italic text-fg-secondary`,children:[`[`,e?`image: ${e}`:`image`,`]`]},t)}case`field`:{let e=n.getAttribute(`path`)??``;return(0,Y.jsxs)(`span`,{className:`rounded bg-bg-tertiary px-1 py-0.5 text-fg-brand-primary`,children:[`@`,e]},t)}default:return(0,Y.jsx)(b.Fragment,{children:r},t)}}function E2e(e){if(!C2e.test(e))return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e});let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`);return(0,Y.jsx)(Y.Fragment,{children:w2e(t.body.childNodes)})}function D2e({doc:e}){return(0,Y.jsx)(Y.Fragment,{children:e.map((e,t)=>N9(e,t))})}function N9(e,t){switch(e.tag){case`p`:return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.children.map((e,t)=>P9(e,t))},t);case`h1`:return(0,Y.jsx)(`h1`,{className:`text-base font-semibold`,children:e.children.map((e,t)=>P9(e,t))},t);case`h2`:return(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.children.map((e,t)=>P9(e,t))},t);case`h3`:return(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.children.map((e,t)=>P9(e,t))},t);case`blockquote`:return(0,Y.jsx)(`blockquote`,{className:`border-l-2 border-border-primary pl-2 italic`,children:e.children.map((e,t)=>N9(e,t))},t);case`ul`:return(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:e.children.map((e,t)=>(0,Y.jsx)(`li`,{children:e.children.map((e,t)=>N9(e,t))},t))},t);case`ol`:return(0,Y.jsx)(`ol`,{className:`list-decimal pl-5`,children:e.children.map((e,t)=>(0,Y.jsx)(`li`,{children:e.children.map((e,t)=>N9(e,t))},t))},t)}}function P9(e,t){if(typeof e==`string`)return e;if(e.tag===`br`)return(0,Y.jsx)(`br`,{},t);if(e.tag===`span`){let n=e.children[0];for(let r of e.styles)r===`bold`?n=(0,Y.jsx)(`strong`,{children:n},t):r===`italic`?n=(0,Y.jsx)(`em`,{children:n},t):r===`line-through`?n=(0,Y.jsx)(`del`,{children:n},t):r===`code`&&(n=(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.85em]`,children:n},t));return(0,Y.jsx)(b.Fragment,{children:n},t)}return e.tag===`img`?e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.alt??``,className:`inline-block max-h-16 rounded border border-border-primary align-baseline mx-0.5`},t):(0,Y.jsxs)(`span`,{className:`italic text-fg-secondary`,children:[`[`,e.alt?`image: ${e.alt}`:`image`,`]`]},t):e.tag===`field_ref`?(0,Y.jsxs)(`span`,{className:`rounded bg-bg-tertiary px-1 py-0.5 text-fg-brand-primary`,children:[`@`,e.path]},t):null}function O2e(e){return typeof e==`string`?[]:e.filter(e=>e.type===`image_url`).map(e=>e.url)}var k2e=(0,b.forwardRef)(function({onCancel:e,models:t,selectedModel:n,onSelectModel:r,onSendMessage:i,onUploadFile:a,onNewSession:o,suggestions:s=b2e,className:c,isConnected:l,authError:u,unavailable:d,mode:f,sessions:p,currentSessionId:m,onLoadSession:h,onFetchSessions:g,onSetSessionName:_,isLoadingSession:v,onAnswerToolQuestions:y,onCancelToolQuestion:x,initialMessages:S,chatEditorRef:C},w){let[T,E]=(0,b.useState)(S??[]),[D,O]=(0,b.useState)(null),[k,A]=(0,b.useState)(!0),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)([]),L=(0,b.useRef)(null),R=(0,b.useRef)(null),ee=C??R,te=(0,b.useRef)(null),[ne,re]=(0,b.useState)(!1),[ie,ae]=(0,b.useState)(null),[oe,se]=(0,b.useState)(``),ce=bb(),le=eb(),ue=ce?.ai?.chat?.suggestions??s,de=ce?.ai?.chat?.title,fe=ce?.ai?.chat?.description,pe=D?[...T,D.message]:T;(0,b.useEffect)(()=>{requestAnimationFrame(()=>{te.current?.scrollIntoView({block:`end`})})},[pe]),(0,b.useEffect)(()=>{D&&P(!1)},[D]);let me=(D?.message.toolActivities??[]).some(A9),he=(0,b.useCallback)((e,t)=>{O(n=>{if(!n)return null;if(e!==null&&n.message.id!==e)return n;let r=t(n.message);return E(e=>e.some(e=>e.id===r.id)?e:[...e,r]),null})},[]),ge=(0,b.useCallback)(e=>({...e,status:`error`,error:`Response timed out`}),[]);(0,b.useEffect)(()=>{if(!D||me)return;let e=12e4-(Date.now()-D.startedAt);if(e<=0){he(D.message.id,ge);return}let t=setTimeout(()=>{he(null,ge)},e);return()=>clearTimeout(t)},[D,me,he,ge]);let _e=(0,b.useCallback)((e,t,n)=>{let r=e=>({...e,toolActivities:(e.toolActivities??[]).map(e=>e.toolCallId===t?n(e):e)});O(t=>!t||t.message.id!==e?t:{message:r(t.message),startedAt:Date.now()}),E(t=>t.some(t=>t.id===e)?t.map(t=>t.id===e?r(t):t):t)},[]),ve=(0,b.useCallback)((e,t,n)=>{_e(e,t,e=>({...e,status:`complete`,answers:n}))},[_e]),ye=(0,b.useCallback)((e,t)=>{_e(e,t,e=>({...e,status:`error`,cancelled:!0}))},[_e]);(0,b.useImperativeHandle)(w,()=>({startAssistantMessage(e){O({message:{id:e,role:`assistant`,content:``,status:`streaming`},startedAt:Date.now()})},appendAssistantChunk(e,t){O(n=>n?.message.id===e?{...n,message:{...n.message,content:M9(n.message.content)+t}}:n)},completeAssistantMessage(e){he(e,e=>({...e,status:`complete`}))},errorAssistantMessage(e,t,n,r,i){he(e,e=>({...e,status:`error`,error:t,errorAction:r,errorCode:n,errorDetails:i}))},addToolCall(e,t,n,r){let i={toolCallId:t,name:n,status:`pending`,...r?{questions:r}:{}};O(t=>t&&t.message.id===e?{...t,message:{...t.message,toolActivities:[...t.message.toolActivities??[],i]}}:t)},completeToolCall(e,t){O(n=>!n||n.message.id!==e?n:{...n,message:{...n.message,toolActivities:(n.message.toolActivities??[]).map(e=>e.toolCallId===t?{...e,status:`complete`}:e)}})},errorToolCall(e,t){O(n=>!n||n.message.id!==e?n:{...n,message:{...n.message,toolActivities:(n.message.toolActivities??[]).map(e=>e.toolCallId===t?{...e,status:`error`}:e)}})},clearMessages(){E([]),O(null)},loadMessages(e){O(null),E(e)}}));let be=D!==null,xe=F.some(e=>e.status===`uploading`),Se=pe.length===0,Ce=(0,b.useCallback)(e=>{let t=Array.from(e.target.files??[]);if(t.length===0)return;e.target.value=``;let n=t.map(e=>({id:crypto.randomUUID(),file:e,status:`uploading`,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0}));I(e=>[...e,...n]),a&&n.forEach(e=>{a(e.file).then(({key:t})=>{I(n=>n.map(n=>n.id===e.id?{...n,status:`done`,key:t}:n))}).catch(t=>{console.error(`Failed to upload file`,{fileName:e.file.name,error:t}),I(t=>t.map(t=>t.id===e.id?{...t,status:`error`}:t))})})},[a]),we=(0,b.useCallback)(e=>{I(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),z=(0,b.useCallback)(e=>{if(be)return;let t,n,r;if(e!==void 0){let r=e.trim();if(!r)return;t=r,n=r}else{let e=ee.current;if(!e||e.isEmpty())return;let i=e.getDocument();if(u2e(i).some(e=>e.startsWith(`pending:`)))return;t=i,r=i,n=o2e(i)}let a=F.filter(e=>e.status===`done`&&e.key!==void 0).map(e=>({key:e.key,name:e.file.name,mimeType:e.file.type||void 0,previewUrl:e.previewUrl}));F.forEach(e=>{e.previewUrl&&e.status!==`done`&&URL.revokeObjectURL(e.previewUrl)}),I([]);let o=S2e(),s={id:o,role:`user`,content:n,status:`complete`,attachments:a.length>0?a:void 0,userDoc:r};E(e=>[...e,s]),e===void 0&&(ee.current?.clear(),A(!0)),!i||i(t,a.length>0?a:void 0)?P(!0):E(e=>e.map(e=>e.id===o?{...e,status:`error`,error:`Failed to send`}:e)),requestAnimationFrame(()=>ee.current?.focus())},[be,F,i,ee]),B=(0,b.useCallback)(e=>{let t=pe.find(t=>t.id===e);if(t?.role===`user`){E(t=>t.map(t=>t.id===e?{...t,status:`complete`,error:void 0}:t));let n=t.userDoc??M9(t.content);!i||i(n,t.attachments)?P(!0):E(t=>t.map(t=>t.id===e?{...t,status:`error`,error:`Failed to send`}:t));return}let n=pe.findIndex(t=>t.id===e);if(n<=0)return;let r=pe.slice(0,n).reverse().find(e=>e.role===`user`);if(!r)return;E(t=>t.filter(t=>t.id!==e));let a=r.userDoc??M9(r.content);(i?.(a,r.attachments)??!0)&&P(!0)},[pe,i]);return(0,Y.jsxs)(`div`,{className:X(`flex flex-col h-full w-full bg-bg-primary text-fg-primary relative overflow-hidden`,c),children:[(!Se||g)&&(0,Y.jsxs)(`div`,{className:`shrink-0 flex justify-between items-center p-2 border-b border-border-primary`,children:[(0,Y.jsx)(`div`,{children:g&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{g(),re(!0)},className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Ay,{className:`h-3 w-3`}),`History`]})}),(0,Y.jsx)(`div`,{children:!Se&&o&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:o,disabled:be,className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Oy,{className:`h-3 w-3`}),`New chat`]})})]}),ne&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 z-overlay flex flex-col bg-bg-primary`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 p-2 border-b border-border-primary`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:()=>{re(!1),ae(null)},"aria-label":`Back to chat`,children:(0,Y.jsx)(Lv,{className:`h-4 w-4`})}),(0,Y.jsx)(`span`,{className:`text-sm font-medium flex-1`,children:`Chat history`}),o&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{o(),re(!1)},className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Oy,{className:`h-3 w-3`}),`New chat`]})]}),(0,Y.jsx)(eD,{className:`flex-1 min-h-0`,children:!p||p.length===0?(0,Y.jsx)(`div`,{className:`p-6 text-center text-sm text-fg-secondary`,children:`No previous sessions`}):(0,Y.jsx)(`div`,{className:`flex flex-col divide-y divide-border-primary`,children:p.map(e=>{let t=e.id===m,n=ie===e.id,r=e.name??`Chat, ${new Date(e.updatedAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}`;return(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 px-3 py-2.5 group`,t&&`bg-bg-secondary`),children:[n?(0,Y.jsx)(`input`,{autoFocus:!0,className:`flex-1 text-sm bg-bg-primary border border-border-primary rounded px-2 py-0.5 focus:outline-none focus:ring-1 focus:ring-border-focus`,value:oe,onChange:e=>se(e.target.value),onKeyDown:t=>{if(t.key===`Enter`){let t=oe.trim();t&&_&&_(e.id,t),ae(null)}else t.key===`Escape`&&ae(null)},onBlur:()=>{let t=oe.trim();t&&_&&_(e.id,t),ae(null)}}):(0,Y.jsx)(`button`,{className:`flex-1 text-left text-sm truncate`,onClick:()=>{h?.(e.id),re(!1)},children:r}),!n&&(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,className:`opacity-0 group-hover:opacity-100 shrink-0`,onClick:t=>{t.stopPropagation(),se(e.name??``),ae(e.id)},"aria-label":`Rename session`,children:(0,Y.jsx)(Dy,{className:`h-3 w-3`})})]},e.id)})})})]}),(0,Y.jsx)(eD,{className:`flex-1 min-h-0`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 min-w-0 max-w-full`,children:[u?(0,Y.jsx)(j2e,{mode:f}):v&&Se?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-12 text-fg-secondary`,children:[(0,Y.jsx)(hy,{className:`h-5 w-5 animate-spin`}),(0,Y.jsx)(`span`,{className:`text-sm`,children:`Loading conversation…`})]}):Se?(0,Y.jsx)(M2e,{suggestions:ue,title:de,description:fe,onSelect:e=>z(e)}):pe.map(e=>(0,Y.jsx)(N2e,{message:e,onRetry:B,onSubmitToolAnswers:(t,n)=>{ve(e.id,t,n),y?.(t,n)},onCancelToolQuestion:t=>{ye(e.id,t),x?.(t)}},e.id)),N&&!D&&(0,Y.jsx)(I2e,{}),(0,Y.jsx)(`div`,{ref:te})]})}),(0,Y.jsx)(`div`,{className:`shrink-0 border-t border-border-primary bg-bg-primary p-3`,children:d&&!u?(0,Y.jsx)(A2e,{...d}):(0,Y.jsxs)(Y.Fragment,{children:[!l&&!u&&(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-center gap-1.5 rounded-md border border-border-primary bg-bg-secondary px-2 py-1.5 text-xs touch:text-sm text-fg-secondary`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),`Connecting…`]}),F.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:F.map(e=>(0,Y.jsxs)(`div`,{className:`relative flex items-center gap-1.5 rounded-md border border-border-primary bg-bg-secondary px-2 py-1 text-xs touch:text-sm text-fg-primary`,children:[e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.file.name,className:`h-8 w-8 rounded object-cover`}):(0,Y.jsx)($v,{className:`h-4 w-4 shrink-0 text-fg-secondary`}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.file.name}),e.status===`uploading`&&(0,Y.jsx)(hy,{className:`h-3 w-3 animate-spin text-fg-secondary`}),e.status===`error`&&(0,Y.jsx)(Uv,{className:`h-3 w-3 text-fg-error-primary`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>we(e.id),className:`ml-0.5 text-fg-secondary hover:text-fg-primary`,"aria-label":`Remove ${e.file.name}`,children:(0,Y.jsx)(Hy,{className:`h-3 w-3`})})]},e.id))}),a&&(0,Y.jsx)(`input`,{ref:L,type:`file`,multiple:!0,className:`hidden`,onChange:Ce,accept:`image/*`}),(0,Y.jsxs)(`div`,{className:X(`flex flex-col rounded-md border border-border-primary bg-bg-primary`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-border-focus`),children:[(0,Y.jsx)(Z0e,{ref:ee,disabled:u||!l||be,placeholder:l&&!u?`Ask something…`:``,onSubmit:()=>z(),onUploadAiImage:a,getPortalContainer:()=>le,onChange:e=>{let t=e.length===0||e.length===1&&e[0].tag===`p`&&e[0].children.length===0;A(t);let n=u2e(e);M(n.some(e=>e.startsWith(`pending:`)))},className:X(`max-h-[18rem] overflow-y-auto px-3 pt-3 pb-1`,`text-fg-primary text-base`)}),(0,Y.jsxs)(`div`,{className:`flex items-center border-t border-border-primary px-2 py-1.5`,children:[a&&(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,disabled:!l||be||u,onClick:()=>L.current?.click(),"aria-label":`Attach files`,children:(0,Y.jsx)(Ey,{className:`h-4 w-4`})}),t&&t.length>1&&r&&(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,disabled:be,className:`h-7 px-2 text-xs text-fg-secondary gap-1`,"aria-label":F9(t,n)===P2e?`Choose a model`:`Change model, currently ${F9(t,n)}`,children:[F9(t,n),(0,Y.jsx)(Iv,{className:`h-3 w-3`})]})}),(0,Y.jsx)(j3,{align:`start`,className:`max-h-72 overflow-y-auto`,children:t.map(e=>{let t=n?.provider===e.ref.provider&&n?.model===e.ref.model;return(0,Y.jsxs)(M3,{onSelect:()=>r(e.ref),className:`text-xs`,children:[(0,Y.jsx)(Fv,{className:X(`h-3 w-3 mr-2`,t?`opacity-100`:`opacity-0`)}),e.label]},`${e.ref.provider}:${e.ref.model}`)})})]}),be&&e?(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:e,"aria-label":`Stop generating`,title:`Stop generating`,className:`ml-auto`,children:(0,Y.jsx)(jae,{className:`h-3.5 w-3.5 fill-current`})}):(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,disabled:!l||be||xe||j||u||k,onClick:()=>z(),"aria-label":`Send message`,className:`ml-auto`,children:(0,Y.jsx)(Cae,{className:`h-4 w-4`})})]})]})]})})]})});function A2e({message:e,onRetry:t}){return(0,Y.jsxs)(`div`,{className:`rounded-md border border-border-primary bg-bg-secondary p-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Ly,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-fg-error-primary`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-fg-primary`,children:`The assistant is unavailable`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[0.6875rem] text-fg-secondary`,children:e})]})]}),(0,Y.jsx)(t_,{variant:`outline`,size:`sm`,onClick:t,className:`mt-2 text-xs`,children:`Try again`})]})}function j2e({mode:e}){let t=e===`fs`;return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 py-12 text-center`,children:[(0,Y.jsx)(`div`,{className:`rounded-full bg-bg-secondary p-3`,children:(0,Y.jsx)(_y,{className:`h-6 w-6`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-lg font-semibold text-fg-primary`,children:`Login to use AI chat`}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:t?`Val is running in development mode. Run this command in your project root to create a personal access token, then refresh:`:`Your session has expired. Sign in again to continue.`})]}),t?(0,Y.jsx)(`div`,{className:`w-full text-left`,children:(0,Y.jsx)(E5,{code:`npx -p @valbuild/cli val login`})}):(0,Y.jsx)(t_,{asChild:!0,variant:`default`,size:`sm`,children:(0,Y.jsxs)(`a`,{href:Jf(`/api/val/authorize`,{redirect_to:window.location.href}),children:[(0,Y.jsx)(_y,{className:`mr-2 h-4 w-4`}),`Sign in`]})})]})}function M2e({suggestions:e,title:t,description:n,onSelect:r}){return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-6 py-16 text-center`,children:[(0,Y.jsx)(`div`,{className:`rounded-full p-3`,children:(0,Y.jsx)(Ny,{className:`h-8 w-8`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-lg font-semibold text-fg-primary`,children:t??`How can I help?`}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:n??`Ask me anything or pick a suggestion below`})]}),e.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:e.map(e=>(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>r(e),className:`text-sm`,children:e},e))})]})}function N2e({message:e,onRetry:t,onSubmitToolAnswers:n,onCancelToolQuestion:r}){let i=e.role===`user`,a=e.status===`error`,o=e.status===`streaming`,s=e.toolActivities??[],c=s.some(A9),l=s.some(e=>e.status===`pending`&&e.questions===void 0),u=M9(e.content),d=O2e(e.content),{hasBubble:f,showCursor:p}=y2e({isUser:i,isError:a,isStreaming:o,hasText:u.length>0,hasFiles:d.length>0,hasRunningTool:l,hasPendingQuestion:c});return(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-1.5 min-w-0`,i?`items-end`:`items-stretch`),children:[!i&&s.length>0&&(0,Y.jsx)(p2e,{activities:s,onSubmitAnswers:n,onCancel:r}),f&&(0,Y.jsxs)(`div`,{className:X(`min-w-0 overflow-hidden rounded-lg px-4 py-2.5 text-sm touch:text-base leading-relaxed`,`[overflow-wrap:anywhere]`,i?`bg-bg-secondary text-fg-primary max-w-[80%]`:`bg-bg-tertiary text-fg-primary w-full max-w-full`,a&&`border border-border-error-primary`),children:[i?(0,Y.jsxs)(Y.Fragment,{children:[e.attachments&&e.attachments.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-1.5`,children:e.attachments.map(e=>e.mimeType?.startsWith(`image/`)&&e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`h-16 w-16 rounded object-cover`},e.key):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded border border-border-primary bg-bg-primary px-2 py-1 text-xs text-fg-secondary`,children:[(0,Y.jsx)($v,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.name})]},e.key))}),d.length>0&&(0,Y.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:d.map(e=>(0,Y.jsx)(`img`,{src:e,alt:`Session attachment`,className:`max-h-48 rounded object-contain`},e))}),e.userDoc?(0,Y.jsx)(D2e,{doc:e.userDoc}):u&&E2e(u)]}):(0,Y.jsxs)(`div`,{className:X(`prose prose-sm dark:prose-invert max-w-none`,`[&_pre]:overflow-x-auto [&_pre]:max-w-full`,`[&_code]:break-words`,`[&_table]:block [&_table]:overflow-x-auto [&_table]:max-w-full`,`[&_a]:break-all`),children:[d.length>0&&(0,Y.jsx)(`div`,{className:`not-prose mb-3 flex flex-wrap gap-2`,children:d.map(e=>(0,Y.jsx)(`img`,{src:e,alt:`AI session image`,className:`max-h-64 rounded border border-border-primary object-contain`},e))}),u?(0,Y.jsx)(_0e,{children:u}):o||a||d.length>0||c?null:(0,Y.jsx)(`p`,{className:`text-fg-secondary italic`,children:`Empty response`}),p&&(0,Y.jsx)(F2e,{})]}),a&&(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-fg-error-primary`,children:e.error??`Something went wrong`}),e.errorAction&&S0e(e.errorAction.url)&&(0,Y.jsx)(`a`,{href:S0e(e.errorAction.url),target:`_blank`,rel:`noreferrer noopener`,className:`text-xs text-fg-brand-primary underline`,children:e.errorAction.label}),e.errorDetails&&(0,Y.jsxs)(`details`,{className:`text-xs text-fg-secondary`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),(0,Y.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-bg-secondary p-2 font-mono text-[11px] text-fg-secondary`,children:e.errorDetails})]})]}),(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:()=>t(e.id),"aria-label":`Retry`,className:`h-6 w-6`,children:(0,Y.jsx)(xae,{className:`h-3.5 w-3.5 text-fg-error-primary`})})]})]})]})}var P2e=`Model`;function F9(e,t){return(t?e.find(e=>e.ref.provider===t.provider&&e.ref.model===t.model):void 0)?.label??P2e}function F2e(){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 ml-1 align-middle`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`150ms`}}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`300ms`}})]})}function I2e(){return(0,Y.jsx)(`div`,{className:`flex justify-start`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg bg-bg-tertiary px-4 py-3`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`150ms`}}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`300ms`}})]})})}function L2e(){let e=nb();return{query:(0,b.useCallback)(async(t,n,r)=>{if(e===null)return;let i=await e.system.search(t,n,r);return i.status===`no-index`?{results:[],total:0}:{results:i.results,total:i.total}},[e])}}function R2e(){let e=Fb();return{getErrors:(0,b.useCallback)(()=>{let t=e??{},n=new Map;for(let e in t){let r=e,[i]=H.splitModuleFilePathAndModulePath(r),a=t[r]??[],o={sourcePath:e,messages:a.map(e=>e.message)};a.some(e=>e.typeError)&&(o.typeError=!0),a.some(e=>e.schemaError)&&(o.schemaError=!0),a.some(e=>e.keyError)&&(o.keyError=!0);let s=n.get(i)??[];s.push(o),n.set(i,s)}return Array.from(n.entries()).map(([e,t])=>({modulePath:e,errors:t}))},[e])}}var I9=`_tag`;function L9(e){if(typeof e!=`object`||!e)return!1;let t=e;return!(t._type!==`ai_session_file`||t[I9]!==`image`&&t[I9]!==`file`||typeof t.key!=`string`||typeof t.filePath!=`string`)}function z2e(e){return JSON.parse(JSON.stringify(e))}function B2e(e,t,n){if(t.length===0)return{ok:!1,reason:`cannot set at empty path`};let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];if(Array.isArray(r)){let i=Number(n);if(!Number.isInteger(i)||i<0||i>=r.length)return{ok:!1,reason:`index out of bounds at ${t.slice(0,e+1).join(`/`)}`};r=r[i]}else if(r&&typeof r==`object`)r=r[n];else return{ok:!1,reason:`cannot descend into non-object at ${t.slice(0,e+1).join(`/`)}`}}let i=t[t.length-1];if(Array.isArray(r)){let e=Number(i);return Number.isInteger(e)?(r[e]=n,{ok:!0}):{ok:!1,reason:`expected numeric index at ${t.join(`/`)}`}}return r&&typeof r==`object`?(r[i]=n,{ok:!0}):{ok:!1,reason:`cannot set on non-object at ${t.join(`/`)}`}}function V2e(e,t,n){let r=(e,i)=>{if(L9(e)){n(i);return}if(Array.isArray(e)){e.forEach((e,t)=>r(e,[...i,String(t)]));return}if(e&&typeof e==`object`){let n=e;if(n.tag===`img`&&L9(n.src)){for(let[e,t]of Object.entries(n))e!==`src`&&r(t,[...i,e]);t(n.src,[...i,`src`]);return}for(let[e,t]of Object.entries(n))r(t,[...i,e])}};r(e,[])}function R9(e){return L9(e)?!0:Array.isArray(e)?e.some(R9):e&&typeof e==`object`?Object.values(e).some(R9):!1}function H2e(e,t){let n=e?{...e}:{};return t[I9]===`image`&&(t.alt!==void 0&&(n.alt=t.alt),t.hotspot!==void 0&&(n.hotspot=t.hotspot)),n}function U2e(e){let{patch:t,moduleSchema:n}=e,r=[];for(let e=0;e<t.length;e++){let i=t[e];if(i.op===`file`)return{kind:`error`,message:`Patch op #${e} is a 'file' op — those are emitted by the system, not by create_patch input.`};if(i.op===`remove`||i.op===`move`||i.op===`copy`)continue;if(i.op===`test`){if(R9(i.value))return{kind:`error`,message:`Patch op #${e} ('test') cannot contain a SessionKey.`};continue}let a=i.path,o=Ep(n,a);if(o.kind===`unresolved`){if(R9(i.value))return{kind:`error`,message:`Patch op #${e} contains a SessionKey but the path ${JSON.stringify(a)} could not be resolved against the module schema.`};continue}if(o.kind===`gallery-traversed`){if(R9(i.value))return{kind:`wrong-tool`,suggestedTool:`add_session_image_to_gallery`,reason:`Patch op #${e} targets an images gallery (s.images()) with a SessionKey. Galleries use file paths as keys; use add_session_image_to_gallery instead.`};continue}if(o.kind===`leaf`){let t=o.schema,n=L9(i.value);if(t.type===`image`||t.type===`file`){if(n){let n=i.value;if(n[I9]!==t.type)return{kind:`error`,message:`Patch op #${e}: SessionKey _tag is '${n[I9]}' but the schema is '${t.type}'.`};r.push({kind:`leaf`,opIndex:e,opPath:a,subtype:t.type,remote:Op(t),sessionKey:n});continue}if(R9(i.value))return{kind:`error`,message:`Patch op #${e}: SessionKey nested inside a non-SessionKey value at an ${t.type} field. Place the SessionKey directly as the value.`};continue}if(R9(i.value))return{kind:`error`,message:`Patch op #${e}: SessionKey is not allowed at a '${t.type}' field.`};continue}let s=Dp(o.schema),c=0,l=null;if(V2e(i.value,(t,n)=>{r.push({kind:`inline-img`,opIndex:e,opPath:a,valuePath:n,remote:s.kind===`allowed`&&s.remote,sessionKey:t}),c+=1},e=>{l===null&&(l=e)}),l)return{kind:`error`,message:`Patch op #${e}: SessionKey at value path ${JSON.stringify(l)} is not inside a {tag:"img", src: ...} node.`};if(c>0&&s.kind===`not-allowed`)return{kind:`error`,message:`Patch op #${e} inserts an inline image into a richtext that does not allow inline images (options.img is not enabled).`}}return{kind:`ok`,transfers:r.map((e,t)=>({siteId:t,key:e.sessionKey.key,filePath:e.sessionKey.filePath,isRemote:e.remote})),apply:e=>{if(r.length===0)return{kind:`ok`,patch:t};let n=t.map(e=>z2e(e)),i=[];for(let t=0;t<r.length;t++){let a=r[t],o=H2e(e[t],a.sessionKey),s=wp(a.sessionKey.filePath,o);if(a.kind===`leaf`){let e=n[a.opIndex];e.value=s,i.push({op:`file`,path:a.opPath,filePath:a.sessionKey.filePath,value:a.sessionKey.key,remote:a.remote,metadata:o})}else{let e=n[a.opIndex];if(a.valuePath.length===0)e.value=s;else{let t=B2e(e.value,a.valuePath,s);if(!t.ok)return{kind:`error`,message:`Failed to rewrite SessionKey at op #${a.opIndex}, value path ${JSON.stringify(a.valuePath)}: ${t.reason}`}}i.push({op:`file`,path:a.opPath,nestedFilePath:a.valuePath,filePath:a.sessionKey.filePath,value:a.sessionKey.key,remote:a.remote,metadata:o})}}let a=[...n,...i],o=Jd.safeParse(a);return o.success?{kind:`ok`,patch:o.data}:{kind:`error`,message:`Rewritten patch failed schema validation: ${JSON.stringify(o.error)}`}}}}async function W2e(e){let t=U2e({patch:e.patch,moduleSchema:e.moduleSchema,moduleSource:e.moduleSource});if(t.kind!==`ok`)return t;let n={};if(t.transfers.length>0){let r=e=>`${e.isRemote?`1`:`0`}${e.filePath}${e.key}`,i=[],a=new Map;for(let e of t.transfers){let t=r(e);a.has(t)||(a.set(t,i.length),i.push({filePath:e.filePath,key:e.key,isRemote:e.isRemote}))}let o=await e.transfer({patchId:e.patchId,parentRef:e.parentRef,files:i});if(o.files.length!==i.length)return{kind:`error`,message:`Session image transfer returned ${o.files.length} results for ${i.length} files.`};for(let e of t.transfers){let t=a.get(r(e));if(t===void 0)return{kind:`error`,message:`Internal error: missing transfer index for site ${e.siteId}.`};n[e.siteId]=o.files[t].metadata}}let r=t.apply(n);return r.kind===`error`?{kind:`error`,message:r.message}:{kind:`ok`,patch:r.patch}}var G2e=new qr,K2e={name:`get_all_schema`,description:`Get all val schemas — returns the complete schema definitions for all val modules`,parameters:{type:`object`,properties:{},required:[]}},q2e={name:`get_source`,description:`Get the current source content of a Val module by its file path. The 'module_file_path' must exactly match one of the keys returned by get_all_schema.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/homepage.val.ts'. Can be obtained from the keys of get_all_schema.`}},required:[`module_file_path`]}},J2e={name:`search_content`,description:`Search content — accepts a query and returns matching content items. Returns { results, total } where total is the number of matches found. Use offset to page through results if total exceeds the returned results count.`,parameters:{type:`object`,properties:{query:{type:`string`,description:`The search query`},limit:{type:`number`,description:`Max results to return (default 50)`},offset:{type:`number`,description:`Number of results to skip for pagination (default 0)`}},required:[`query`]}},Y2e={name:`validate_content`,description:`Get all current validation errors — returns a list of modules with their validation errors, grouped by module path`,parameters:{type:`object`,properties:{},required:[]}},X2e={name:`create_patch`,description:`Create a Val patch — applies JSON Patch operations to a Val module.
|
|
266
266
|
Supports string, number, boolean, null, object, array, date (ISO 8601), image, file, and richtext fields.
|
|
267
267
|
Supported ops: 'replace', 'add', 'remove'.
|
|
268
268
|
The 'path' must be a JSON Pointer AS AN ARRAY: (e.g. ['title'], ['items', '0', 'name']).
|
|
@@ -288,7 +288,7 @@ Guidance:
|
|
|
288
288
|
File field example:
|
|
289
289
|
{"patch":[{"op":"replace","path":["brochure"],"value":{"key":"abc","filePath":"/public/val/files/brochure.pdf","_type":"ai_session_file","_tag":"file"}}]}
|
|
290
290
|
|
|
291
|
-
Richtext inline image example (richtext schema must have options.
|
|
291
|
+
Richtext inline image example (richtext schema must have options.img enabled):
|
|
292
292
|
{"patch":[{"op":"add","path":["body","0","children","2"],"value":{"tag":"img","src":{"key":"abc","filePath":"/public/val/images/inline.png","_type":"ai_session_file","_tag":"image"}}}]}
|
|
293
293
|
|
|
294
294
|
Multiple session keys can appear in a single patch.
|
|
@@ -358,7 +358,7 @@ Never tell the user to navigate manually — offer to navigate for them instead.
|
|
|
358
358
|
- img: {tag:"img", src:{...}} — cannot be added via assistant (no file system access)
|
|
359
359
|
- br: {tag:"br"}
|
|
360
360
|
- example: [{tag:"p",children:["Hello ",{tag:"span",styles:["bold"],children:["World"]}]}]
|
|
361
|
-
- richtext schema has options, which tells you which type of tags you can use. Example: if options do not have
|
|
361
|
+
- richtext schema has options, which tells you which type of tags you can use. Example: if options do not have ul: true, then ul is not allowed. The schema.options type is like this: Partial<{bold: boolean;italic: boolean;lineThrough: boolean;h1: boolean;h2: boolean;h3: boolean;h4: boolean;h5: boolean;h6: boolean;ul: boolean;ol: boolean;a: boolean | SerializedRouteSchema | SerializedStringSchema;img: boolean | SerializedImageSchema;}>;
|
|
362
362
|
- image / file: cannot be changed through this assistant (no file system access). If the user needs to add one, navigate to the matching media gallery.
|
|
363
363
|
- union: a value that must match exactly one of several allowed shapes. Two kinds:
|
|
364
364
|
- string union: key is a literal schema, all items are literals. The value is one fixed string chosen from a set (e.g. "draft", "published", "archived"). Patch by replacing the string with one of the allowed values.
|