@opencraw/studio 0.0.14 → 0.0.15
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.
|
@@ -11,8 +11,8 @@ Error generating stack: `+e.message+`
|
|
|
11
11
|
)+\\(\\s*min(-device)?-${e}`,`i`),max:RegExp(`\\(\\s*max(-device)?-${e}`,`i`)}),tb=eb(`width`),nb=eb(`height`),rb=e=>({isMin:hb(e.minMax,e.maxMin,e.min),isMax:hb(e.maxMin,e.minMax,e.max)}),{isMin:ib,isMax:ab}=rb(tb),{isMin:ob,isMax:sb}=rb(nb),cb=/print/i,lb=/^print$/i,ub=/(-?\d*\.?\d+)(ch|em|ex|px|rem)/,db=/(\d)/,fb=Number.MAX_VALUE,pb={ch:8.8984375,em:16,rem:16,ex:8.296875,px:1};function mb(e){let t=ub.exec(e)||(ib(e)||ob(e)?db.exec(e):null);return t?t[0]===`0`?0:parseFloat(t[1])*(pb[t[2]]||1):fb}function hb(e,t,n){return r=>e.test(r)||!t.test(r)&&n.test(r)}function gb(e,t){let n=cb.test(e),r=lb.test(e),i=cb.test(t),a=lb.test(t);return n&&i?!r&&a?1:r&&!a?-1:e.localeCompare(t):n?1:i?-1:null}var _b=Fy((e,t)=>{let n=gb(e,t);if(n!==null)return n;let r=ib(e)||ob(e),i=ab(e)||sb(e),a=ib(t)||ob(t),o=ab(t)||sb(t);if(r&&o)return-1;if(i&&a)return 1;let s=mb(e),c=mb(t);return s===fb&&c===fb?e.localeCompare(t):s===fb?1:c===fb?-1:s===c?e.localeCompare(t):s>c?i?-1:1:i?1:-1});function vb(e){return e.sort(([e],[t])=>_b(e,t))}function yb(e){let t=[],n=[],r={};for(let[i,a]of Object.entries(e))i.startsWith(`@media`)?t.push([i,a]):i.startsWith(`@container`)?n.push([i,a]):r[i]=Kt(a)?yb(a):a;let i=vb(t),a=vb(n);return{...r,...Object.fromEntries(i),...Object.fromEntries(a)}}var bb=/\s*!(important)?/i,xb=Fy(e=>qt(e)?bb.test(e):!1),Sb=Fy(e=>qt(e)?e.replace(bb,``).trim():e);function Cb(e){let{transform:t,conditions:n,normalize:r}=e,i=Eb(e);return Fy(function(...e){let a=i(...e),o=r(a),s=$y();return Hv(o,(e,r)=>{if(e==null)return;let[i,...a]=n.sort(r).map(n.resolve),o=xb(e);o&&(e=Sb(e));let c=t(i,e)??Zy;c=Hv(c,e=>qt(e)&&o?`${e} !important`:e,{getKey:e=>n.expandAtRule(e)}),wb(s,a.flat(),c)}),yb(s)})}function wb(e,t,n){let r=e;for(let e of t)e&&(r[e]||(r[e]=$y()),r=r[e]);Bv(r,n)}function Tb(...e){return e.filter(e=>{if(!Kt(e))return!1;let t=Gt(e);return Object.keys(t).length>0})}function Eb(e){function t(t){let n=Tb(...t);return n.length===1?n:n.map(t=>e.normalize(t))}return Fy(function(...e){return Bv({},...t(e))})}var Db=e=>({base:Zy,variants:Zy,defaultVariants:Zy,compoundVariants:[],...e});function Ob(e){let{css:t,conditions:n,normalize:r,layers:i}=e;function a(e={}){let s=Db(e),{base:c,defaultVariants:l,compoundVariants:u}=s,d=Oy(s.variants,(e,t)=>[e,Oy(t,(e,t)=>[e,r(t)])]),f=Cb({conditions:n,normalize:r,transform(e,t){return d[e]?.[t]}}),p=Fy(function(e={}){let n=r({...l,...Gt(e)}),a={...r(c)};Bv(a,f(n));let s=o(u,n);return i.wrap(`recipes`,t(a,s))}),m=Object.keys(d),h=e=>{let[t,n]=on(Fv(e,[`recipe`]),m),r=m.includes(`colorPalette`),i=m.includes(`orientation`);return r||(t.colorPalette=e.colorPalette||l.colorPalette),i&&(n.orientation=e.orientation),[t,n]},g=Oy(d,(e,t)=>[e,Object.keys(t)]),_=Fy(function(e){return t(p(e))});return Object.assign(_,{className:e.className,__cva__:!0,variantMap:g,variantKeys:m,raw:p,config:e,splitVariantProps:h,merge(e){return a(Ab(this,e))}})}function o(e,n){let r=Zy;return e.forEach(e=>{Object.entries(e).every(([e,t])=>e===`css`||(Array.isArray(t)?t:[t]).some(t=>n[e]===t))&&(r=t(r,e.css))}),r}return a}var kb=e=>(e?.__cva__?e.config:e)??Zy;function Ab(e,t){let n=Db(kb(e)),r=Db(kb(t)),i=Qt(Object.keys(n.variants),Object.keys(r.variants)),a=Bv({},n.base,r.base),o=Object.fromEntries(i.map(e=>[e,Bv({},n.variants[e],r.variants[e])])),s=Bv({},n.defaultVariants,r.defaultVariants),c=[...n.compoundVariants,...r.compoundVariants];return{className:Yt(n.className,r.className),base:a,variants:o,defaultVariants:s,compoundVariants:c}}var jb={reset:`reset`,base:`base`,tokens:`tokens`,recipes:`recipes`},Mb={reset:0,base:1,tokens:2,recipes:3};function Nb(e){let t=e.layers??jb,n=Object.values(t).sort((e,t)=>Mb[e]-Mb[t]);return{names:n,atRule:`@layer ${n.join(`, `)};`,wrap(n,r){return e.disableLayers?r:{[`@layer ${t[n]}`]:r}}}}function Pb(e){let{utility:t,normalize:n}=e,{hasShorthand:r,resolveShorthand:i}=t;return function(e){return Hv(e,n,{stop:e=>Array.isArray(e),getKey:r?i:void 0})}}function Fb(e){let{preflight:t}=e;if(!t)return{};let{scope:n=``,level:r=`parent`}=Kt(t)?t:{},i=``;n&&r===`parent`?i=`${n} `:n&&r===`element`&&(i=`&${n}`);let a={"*":{margin:`0px`,padding:`0px`,font:`inherit`,wordWrap:`break-word`,WebkitTapHighlightColor:`transparent`},"*, *::before, *::after, *::backdrop":{boxSizing:`border-box`,borderWidth:`0px`,borderStyle:`solid`,borderColor:`var(--global-color-border, currentColor)`},hr:{height:`0px`,color:`inherit`,borderTopWidth:`1px`},body:{minHeight:`100dvh`,position:`relative`},img:{borderStyle:`none`},"img, svg, video, canvas, audio, iframe, embed, object":{display:`block`,verticalAlign:`middle`},iframe:{border:`none`},"img, video":{maxWidth:`100%`,height:`auto`},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:`break-word`},"ol, ul":{listStyle:`none`},"code, kbd, pre, samp":{fontSize:`1em`},"button, [type='button'], [type='reset'], [type='submit']":{WebkitAppearance:`button`,backgroundColor:`transparent`,backgroundImage:`none`},"button, input, optgroup, select, textarea":{color:`inherit`},"button, select":{textTransform:`none`},table:{textIndent:`0px`,borderColor:`inherit`,borderCollapse:`collapse`},"*::placeholder":{opacity:`unset`,color:`#9ca3af`,userSelect:`none`},textarea:{resize:`vertical`},summary:{display:`list-item`},small:{fontSize:`80%`},"sub, sup":{fontSize:`75%`,lineHeight:0,position:`relative`,verticalAlign:`baseline`},sub:{bottom:`-0.25em`},sup:{top:`-0.5em`},dialog:{padding:`0px`},a:{color:`inherit`,textDecoration:`inherit`},"abbr:where([title])":{textDecoration:`underline dotted`},"b, strong":{fontWeight:`bolder`},"i, em":{fontStyle:`italic`},"code, kbd, samp, pre":{fontSize:`1em`,"--font-mono-fallback":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New'`,fontFamily:`var(--global-font-mono, var(--font-mono-fallback))`},'input[type="text"], input[type="email"], input[type="search"], input[type="password"]':{WebkitAppearance:`none`,MozAppearance:`none`},"input[type='search']":{WebkitAppearance:`textfield`,outlineOffset:`-2px`},"::-webkit-search-decoration, ::-webkit-search-cancel-button":{WebkitAppearance:`none`},"::-webkit-file-upload-button":{WebkitAppearance:`button`,font:`inherit`},'input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button':{height:`auto`},"input[type='number']":{MozAppearance:`textfield`},":-moz-ui-invalid":{boxShadow:`none`},":-moz-focusring":{outline:`auto`},"[hidden]:where(:not([hidden='until-found']))":{display:`none !important`}},o={[n||`html`]:{lineHeight:1.5,"--font-fallback":`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'`,WebkitTextSizeAdjust:`100%`,WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`,textRendering:`optimizeLegibility`,touchAction:`manipulation`,MozTabSize:`4`,tabSize:`4`,fontFamily:`var(--global-font-body, var(--font-fallback))`}};if(r===`element`){let e=Object.entries(a).reduce((e,[t,n])=>(e[t]={[i]:n},e),{});Object.assign(o,e)}else i?o[i]=a:Object.assign(o,a);return o}function Ib(e){let{conditions:t,isValidProperty:n}=e,r=Fy((e,r)=>!n(e)||!r.split(`,`).every(e=>e===`base`||t.has(e)));return function(e){return Hv(e,e=>e,{stop:e=>Array.isArray(e),getKey:(e,n)=>!Kt(n)||t.has(e)?e:r(e,Object.keys(n).join(`,`))?Rb(e).map(e=>{let t=e.startsWith(`&`)?e.slice(1):e;return Lb(t)?`${t} &`:`&${t}`}).join(`, `):e})}}function Lb(e){let t=e.toLowerCase();return t.startsWith(`:host-context`)||t.startsWith(`:host`)||t.startsWith(`::slotted`)}function Rb(e){let t=[],n=0,r=``,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o===`\\`&&!i){i=!0,r+=o;continue}if(i){i=!1,r+=o;continue}o===`(`?n++:o===`)`&&n--,o===`,`&&n===0?(t.push(r.trim()),r=``):r+=o}return r&&t.push(r.trim()),t}var zb=(e=Zy)=>{let t=t=>({base:e.base?.[t]??Zy,variants:$y(),defaultVariants:e.defaultVariants??Zy,compoundVariants:e.compoundVariants?Bb(e.compoundVariants,t):Qy}),n=(e.slots??[]).map(e=>[e,t(e)]);for(let[t,r]of Object.entries(e.variants??{}))for(let[e,i]of Object.entries(r))n.forEach(([n,r])=>{var a;(a=r.variants)[t]??(a[t]={}),r.variants[t][e]=i[n]??Zy});return Object.fromEntries(n)},Bb=(e,t)=>e.filter(e=>e.css[t]).map(e=>({...e,css:e.css[t]}));function Vb(e){let{cva:t}=e;return function(e=Zy){let n=Object.entries(zb(e)).map(([e,n])=>[e,t(n)]),r=Fy(function(e){let t=n.map(([t,n])=>[t,n(e)]);return Object.fromEntries(t)}),i=e.variants??Zy,a=Object.keys(i);function o(t){let[n,r]=on(Fv(t,[`recipe`]),a),i=a.includes(`colorPalette`),o=a.includes(`orientation`);return i||(n.colorPalette=t.colorPalette||e.defaultVariants?.colorPalette),o&&(r.orientation=t.orientation),[n,r]}let s=Oy(i,(e,t)=>[e,Object.keys(t)]),c={};return e.className&&(c=Object.fromEntries(e.slots.map(t=>[t,`${e.className}__${t}`]))),Object.assign(r,{variantMap:s,variantKeys:a,splitVariantProps:o,classNameMap:c})}}var Hb=()=>e=>Array.from(new Set(e)),Ub=/([\0-\x1f\x7f]|^-?\d)|^-$|^-|[^\x80-\uFFFF\w-]/g,Wb=function(e,t){return t?e===`\0`?`�`:e===`-`&&e.length===1?`\\-`:e.slice(0,-1)+`\\`+e.charCodeAt(e.length-1).toString(16):`\\`+e},Gb=e=>(e+``).replace(Ub,Wb),Kb=(e,t)=>{let n=``,r=0,i=`char`,a=``,o=``,s=[];for(;r<e.length;){let c=e[r];if(c===`{`){let i=e.indexOf(`}`,r);if(i===-1)break;let a=e.slice(r+1,i),o=t(a);n+=o??a,r=i+1;continue}if(i===`token`&&c===`,`){e[r]===``&&r++,i=`fallback`,s.push(i);let c=t(a);c?.endsWith(`)`)&&(n+=c.slice(0,-1)),a=``,o=``;continue}if(i===`fallback`&&o+c===`, var(`){let t=qb(e.slice(r+1))+r+1,a=e.slice(r+1,t);if(t===-1)break;n+=`, var(`+a+`)`,r=t+1,i=s.pop()??i,o=``;continue}if(i===`token`||i===`fallback`){if(r++,c===`)`){i=s.pop()??i??`char`,o+=c;let e=a&&(t(a)??Gb(a));if(o){if(o=o.slice(1).trim(),!o.startsWith(`token(`)&&o.endsWith(`)`)&&(o=o.slice(0,-1)),o.includes(`token(`)){let e=Kb(o,t);e&&(o=e.slice(0,-1))}else if(o){let e=t(o);e&&(o=e)}}let r=n.at(-1);o?r?.trim()?n+=e.slice(0,-1)+(`, `+o+`)`):n+=o:n+=e||`)`,a=``,o=``,i=`char`;continue}i===`token`&&(a+=c),i===`fallback`&&(o+=c);continue}let l=e.indexOf(`token(`,r);if(l!==-1){let t=l+6;n+=e.slice(r,l),r=t,i=`token`,s.push(i);continue}n+=c,r++}return n},qb=e=>{let t=0,n=[`(`];for(;t<e.length;){let r=e[t];if(r===`(`)n.push(r);else if(r===`)`&&(n.pop(),n.length===0))return t;t++}return t};function Jb(e){let t={};return e.forEach((e,n)=>{e instanceof Map?t[n]=Object.fromEntries(e):t[n]=e}),t}var Yb=/({([^}]*)})/g,Xb=/[{}]/g,Zb=/\w+\.\w+/,Qb=e=>{if(!qt(e))return[];let t=e.match(Yb);return t?t.map(e=>e.replace(Xb,``).trim()):[]},$b=e=>Yb.test(e);function ex(e){if(!e.extensions?.references)return e.extensions?.cssVar?.ref??e.value;let t=e.extensions.references??{},n=e.value,r=Object.keys(t);for(let e=0;e<r.length;e++){let i=r[e],a=t[i];if(a.extensions.conditions)continue;let o=ex(a);n=n.replace(`{${i}}`,o)}return e.value=n,delete e.extensions.references,e.value}function tx(e,t){if(t==null||!Array.isArray(t))return t;switch(e){case`easings`:return`cubic-bezier(${t.join(`, `)})`;case`animations`:case`fonts`:case`gradients`:case`shadows`:return t.join(`, `);default:return t}}function nx(e,t){let n={};for(let r in t)n[r]=tx(e,t[r]);return n}var rx=/calc/g;function ix(e){return Kt(e)&&e.reference?e.reference:String(e)}var ax=(e,...t)=>t.map(ix).join(` ${e} `).replace(rx,``),ox=(...e)=>`calc(${ax(`+`,...e)})`,sx=(...e)=>`calc(${ax(`-`,...e)})`,cx=(...e)=>`calc(${ax(`*`,...e)})`,lx=(...e)=>`calc(${ax(`/`,...e)})`,ux=e=>{let t=ix(e);return t!=null&&!Number.isNaN(parseFloat(t))?String(t).startsWith(`-`)?String(t).slice(1):`-${t}`:cx(t,-1)},dx=Object.assign(e=>({add:(...t)=>dx(ox(e,...t)),subtract:(...t)=>dx(sx(e,...t)),multiply:(...t)=>dx(cx(e,...t)),divide:(...t)=>dx(lx(e,...t)),negate:()=>dx(ux(e)),toString:()=>e.toString()}),{add:ox,subtract:sx,multiply:cx,divide:lx,negate:ux}),fx={enforce:`pre`,transform(e){let{prefix:t,allTokens:n,formatCssVar:r,formatTokenName:i,registerToken:a}=e;n.filter(({extensions:e})=>e.category===`spacing`).forEach(e=>{let n=e.path.slice(),o=r(n,t);if(qt(e.value)&&e.value===`0rem`)return;let s=[...e.path],c=s[s.length-1];c!=null&&(s[s.length-1]=`-${c}`);let l={...e,value:dx.negate(o.ref),name:i(s),path:s,extensions:{...e.extensions,negative:!0,prop:`-${e.extensions.prop}`,originalPath:n}};a(l)})}},px=new Set([`spacing`,`sizes`,`borderWidths`,`fontSizes`,`radii`]),mx=[fx,{enforce:`post`,transform(e){let{allTokens:t,registerToken:n,formatTokenName:r}=e,i=t.filter(({extensions:e})=>e.category===`colors`),a=new Map,o=new Map;i.forEach(e=>{let{colorPalette:t}=e.extensions;t&&(t.keys.forEach(e=>{a.set(r(e),e)}),t.roots.forEach(n=>{let i=r(n),s=o.get(i)||[];if(s.push(e),o.set(i,s),e.extensions.default&&n.length===1){let e=t.keys[0]?.filter(Boolean);if(!e.length)return;let i=n.concat(e);a.set(r(i),[])}}))}),a.forEach(e=>{let t=[`colors`,`colorPalette`,...e].filter(Boolean),i=r(t),a={name:i,value:i,originalValue:i,path:t,extensions:{condition:`base`,originalPath:t,category:`colors`,prop:r(t.slice(1)),virtual:!0}};n(a,`pre`)})}},{enforce:`post`,transform(e){e.allTokens.filter(e=>px.has(e.extensions.category)&&!e.extensions.negative).forEach(e=>{Object.assign(e.extensions,{pixelValue:Vy(e.value)})})}},{enforce:`post`,transform(e){let t=[],n=[];e.allTokens.forEach(e=>{e.value===``?t.push(e):n.push(e)}),e.allTokens.splice(0,e.allTokens.length,...n),t.forEach(t=>{if(e.tokenMap.get(t.name)!==t)return;let n=e.allTokens.find(e=>e.name===t.name);if(!n){e.tokenMap.delete(t.name);return}t.extensions.conditions&&!n.extensions.conditions&&(n.extensions.conditions=t.extensions.conditions),e.tokenMap.set(t.name,n)})}}],hx=[{type:`extensions`,enforce:`pre`,name:`tokens/css-var`,transform(e,t){let{prefix:n,formatCssVar:r}=t,{negative:i,originalPath:a}=e.extensions;return{cssVar:r((i?a:e.path).filter(Boolean),n)}}},{enforce:`post`,type:`value`,name:`tokens/conditionals`,transform(e,t){let{prefix:n,formatCssVar:r,getByName:i}=t,a=Qb(e.value);return a.length&&a.forEach(t=>{if(!i(t))return;let a=r(t.split(`.`),n);e.value=e.value.replaceAll(`{${t}}`,a.ref)}),e.value}},{type:`extensions`,enforce:`pre`,name:`tokens/colors/colorPalette`,match(e){return e.extensions.category===`colors`&&!e.extensions.virtual},transform(e,t){let n=e.path.slice();if(n.pop(),n.shift(),n.length===0){let t=[...e.path];t.shift(),n=t}if(n.length===0)return{};let r=n.reduce((e,t,n,r)=>{let i=r.slice(0,n+1);return e.push(i),e},[]),i=n[0],a=t.formatTokenName(n),o=e.path.slice(e.path.indexOf(i)+1).reduce((e,t,n,r)=>(e.push(r.slice(n)),e),[]);return o.length===0&&o.push([``]),{colorPalette:{value:a,roots:r,keys:o}}}}],gx=e=>Kt(e)&&Object.prototype.hasOwnProperty.call(e,`value`);function _x(e){return e?{breakpoints:Uv(e,e=>({value:e})),sizes:Oy(e,(e,t)=>[`breakpoint-${e}`,{value:t}])}:{breakpoints:{},sizes:{}}}function vx(e){let{prefix:t=``,tokens:n={},semanticTokens:r={},breakpoints:i={}}=e,a=e=>e.join(`.`),o=(e,t)=>ly(e.join(`-`),{prefix:t}),s=[],c=new Map,l=new Map,u=new Map,d=new Map,f=new Map,p=new Map,m=new Map,h=new Map,g=[];function _(e,t){s.push(e),(e.extensions.condition===`base`||!c.has(e.name))&&c.set(e.name,e),t&&h.forEach(n=>{n.enforce===t&&ie(n,e)})}let v=_x(i),y=Gt({...n,breakpoints:v.breakpoints,sizes:{...n.sizes,...v.sizes}});function b(){Hv(y,(e,t)=>{let n=t.includes(`DEFAULT`);t=yx(t);let r=t[0],i=a(t),o=tx(r,(qt(e)?{value:e}:e).value),s={value:o,originalValue:o,name:i,path:t,extensions:{condition:`base`,originalPath:t,category:r,prop:a(t.slice(1))}};n&&(s.extensions.default=!0),_(s)},{stop:gx}),Hv(r,(e,t)=>{let n=t.includes(`DEFAULT`);t=bx(yx(t));let r=t[0],i=a(t),o=nx(r,(qt(e.value)||Array.isArray(e.value)?{value:{base:e.value}}:e).value),s={value:o.base??``,originalValue:o.base??``,name:i,path:t,extensions:{originalPath:t,category:r,conditions:o,condition:`base`,prop:a(t.slice(1))}};n&&(s.extensions.default=!0),_(s)},{stop:gx})}function x(e){return c.get(e)}function S(e){let{condition:t}=e.extensions;t&&(l.has(t)||l.set(t,new Set),l.get(t).add(e))}function C(e){let{category:t,prop:n,condition:r,conditions:i}=e.extensions;if(!t)return;m.has(t)||m.set(t,new Map);let a=m.get(t),o=a.get(n);if(r==null||r===`base`){a.set(n,e);return}i&&!o&&a.set(n,e)}function w(e){let{condition:t,negative:n,virtual:r,cssVar:i}=e.extensions;!n&&!r&&t&&i&&e.value!==``&&(u.has(t)||u.set(t,new Map),u.get(t).set(i.var,e.value))}function T(e){let{category:t,prop:n,cssVar:r,negative:i}=e.extensions;if(!t)return;p.has(t)||p.set(t,new Map);let a=i?e.extensions.conditions?e.originalValue:e.value:r.ref;p.get(t).set(n,a),f.set([t,n].join(`.`),a)}function E(e){let{colorPalette:t,virtual:n,default:r}=e.extensions;t&&!n&&t.roots.forEach(n=>{let i=a(n);d.has(i)||d.set(i,new Map);let o=Sx([...e.path],[...n]),s=x(a(o));if(!s||!s.extensions.cssVar)return;let{var:c}=s.extensions.cssVar;if(d.get(i).set(c,e.extensions.cssVar.ref),r&&n.length===1){let r=x(a([`colors`,`colorPalette`]));if(!r)return;let i=x(a(e.path));if(!i)return;let o=t.keys[0]?.filter(Boolean);if(!o.length)return;let s=a(n.concat(o));d.has(s)||d.set(s,new Map),d.get(s).set(r.extensions.cssVar.var,i.extensions.cssVar.ref)}})}let D={};function O(){s.forEach(e=>{S(e),C(e),w(e),T(e),E(e)}),D=Jb(p)}let k=(e,t)=>{if(!e||typeof e!=`string`)return{invalid:!0,value:e};let[n,r]=e.split(`/`);if(!n||!r)return{invalid:!0,value:n};let i=t(n),a=x(`opacity.${r}`)?.value;if(!a&&isNaN(Number(r)))return{invalid:!0,value:n};let o=a?Number(a)*100+`%`:`${r}%`,s=i??n;return{invalid:!1,color:s,value:`color-mix(in srgb, ${s} ${o}, transparent)`}},ee=Fy((e,t)=>f.get(e)??t),te={prefix:t,allTokens:s,tokenMap:c,registerToken:_,getByName:x,formatTokenName:a,formatCssVar:o,flatMap:f,cssVarMap:u,categoryMap:m,colorPaletteMap:d,getVar:ee,getCategoryValues:Fy(e=>D[e]||null),expandReferenceInValue:Fy(e=>Kb(e,e=>{if(e){if(e.includes(`/`)){let t=k(e,e=>ee(e));if(t.invalid)throw Error(`Invalid color mix at `+e+`: `+t.value);return t.value}return ee(e)||(Zb.test(e)?Gb(e):e)}}))};function ne(...e){e.forEach(e=>{h.set(e.name,e)})}function re(...e){g.push(...e)}function ie(e,t){if(t.extensions.references||Jt(e.match)&&!e.match(t))return;let n=(t=>e.transform(t,te))(t);switch(!0){case e.type===`extensions`:Object.assign(t.extensions,n);break;case e.type===`value`:t.value=n;break;default:t[e.type]=n}}function ae(e){g.forEach(t=>{t.enforce===e&&t.transform(te)})}function oe(e){h.forEach(t=>{t.enforce===e&&s.forEach(e=>{ie(t,e)})})}function se(){s.slice().forEach(e=>{let t=xx(e);t&&t.length!==0&&t.forEach(e=>{_(e)})})}function ce(e){let t=Qb(e),n=[];for(let e=0;e<t.length;e++){let r=x(t[e]);r&&n.push(r)}return n}function le(){s.forEach(e=>{if(!$b(e.value))return;let t=ce(e.value);e.extensions.references=t.reduce((e,t)=>(e[t.name]=t,e),{})})}function A(){s.forEach(e=>{ex(e)})}function ue(){ae(`pre`),oe(`pre`),se(),le(),A(),ae(`post`),oe(`post`),O()}return b(),ne(...hx),re(...mx),ue(),te}function yx(e){return e[0]===`DEFAULT`?e:e.filter(e=>e!==`DEFAULT`)}function bx(e){return e.filter(e=>e!==`base`)}function xx(e){if(!e.extensions.conditions)return;let{conditions:t}=e.extensions,n=[];return Hv(t,(t,r)=>{let i=bx(r);if(!i.length)return;let a={...e,value:t,extensions:{...e.extensions,condition:i.join(`:`)}};n.push(a)}),n}function Sx(e,t){let n=e.findIndex((n,r)=>t.every((t,n)=>e[r+n]===t));return n===-1?e:(e.splice(n,t.length),e.splice(n,0,`colorPalette`),e)}Hb()([`aspectRatios`,`zIndex`,`opacity`,`colors`,`fonts`,`fontSizes`,`fontWeights`,`lineHeights`,`letterSpacings`,`sizes`,`shadows`,`spacing`,`radii`,`cursor`,`borders`,`borderWidths`,`borderStyles`,`durations`,`easings`,`animations`,`blurs`,`gradients`,`breakpoints`,`assets`]);function Cx(e){return e}function wx(e){return Oy(e,(e,t)=>[e,Cx(t)])}function Tx(e){let t=wx(e.config),n=e.tokens,r=new Map,i=new Map;function a(e,n){t[e]=Cx(n),o(e,n)}let o=(e,t)=>{let n=h(t);n&&(i.set(e,n),d(e,t))},s=()=>{for(let[e,n]of Object.entries(t))n&&o(e,n)},c=()=>{for(let[e,n]of Object.entries(t)){let{shorthand:t}=n??{};t&&(Array.isArray(t)?t:[t]).forEach(t=>r.set(t,e))}},l=()=>{let e=Jb(n.colorPaletteMap);a(`colorPalette`,{values:Object.keys(e),transform:Fy(t=>e[t])})},u=new Map,d=(e,t)=>{if(!t)return;let n=h(t,e=>`type:Tokens["${e}"]`);if(typeof n==`object`&&n.type){u.set(e,new Set([`type:${n.type}`]));return}if(n){let t=new Set(Object.keys(n));u.set(e,t)}let r=u.get(e)??new Set;t.property&&u.set(e,r.add(`CssProperties["${t.property}"]`))},f=()=>{for(let[e,n]of Object.entries(t))n&&d(e,n)},p=(e,t)=>{let n=u.get(e)??new Set;u.set(e,new Set([...n,...t]))},m=()=>{let e=new Map;for(let[t,n]of u.entries()){if(n.size===0){e.set(t,[`string`]);continue}let r=Array.from(n).map(e=>e.startsWith(`CssProperties`)?e:e.startsWith(`type:`)?e.replace(`type:`,``):JSON.stringify(e));e.set(t,r)}return e},h=(e,t)=>{let{values:r}=e,i=e=>{let n=t?.(e);return n?{[n]:n}:void 0};if(qt(r))return i?.(r)??n.getCategoryValues(r)??Zy;if(Array.isArray(r)){let e={};for(let t=0;t<r.length;t++)e[r[t]]=r[t];return e}return Jt(r)?r(t?i:n.getCategoryValues):r},g=Fy((e,t)=>({[e]:e.startsWith(`--`)?n.getVar(t,t):t})),_=Object.assign(n.getVar,{raw:e=>n.getByName(e)}),v=Fy((e,r)=>{let a=x(e);qt(r)&&!r.includes(`_EMO_`)&&(r=n.expandReferenceInValue(r));let o=t[a];if(!o)return g(a,r);let s=i.get(a)?.[r];return o.transform?o.transform(s??r,{raw:r,token:_,utils:{colorMix:e=>Iv(e,_)}}):g(e,s??r)});function y(){c(),l(),s(),f()}y();let b=r.size>0,x=Fy(e=>r.get(e)??e);return{keys:()=>[...Array.from(r.keys()),...Object.keys(t)],hasShorthand:b,transform:v,shorthands:r,resolveShorthand:x,register:a,getTypes:m,addPropertyType:p}}function Ex(...e){let t=Kv(...e),{theme:n={},utilities:r={},globalCss:i={},cssVarsRoot:a=`:where(:root, :host)`,cssVarsPrefix:o=`chakra`,preflight:s}=t,c=Nb(t),l=vx({breakpoints:n.breakpoints,tokens:n.tokens,semanticTokens:n.semanticTokens,prefix:o}),u=Wy(n.breakpoints??Zy),d=Xy({conditions:t.conditions??Zy,breakpoints:u}),f=Tx({config:r,tokens:l});function p(){let{textStyles:e,layerStyles:t,animationStyles:r}=n,i=Gt({textStyle:e,layerStyle:t,animationStyle:r});for(let[e,t]of Object.entries(i)){let n=ky(t??Zy,Ox);f.register(e,{values:Object.keys(n),transform(e){return y(n[e])}})}}p(),f.addPropertyType(`animationName`,Object.keys(n.keyframes??Zy));let m=new Set([`css`,...f.keys(),...d.keys()]),h=Fy(e=>m.has(e)||Dy(e)),g=e=>{if(Array.isArray(e)){let t=$y();for(let n=0;n<e.length;n++){let r=e[n];if(r!=null){let e=d.breakpoints[n];t[e]=r}}return t}return e},_=Pb({utility:f,normalize:g}),v=Ib({conditions:d,isValidProperty:h}),y=Cb({transform:f.transform,conditions:d,normalize:_}),b=Ob({css:y,conditions:d,normalize:_,layers:c}),x=Vb({cva:b});function S(){let e={};for(let[t,n]of l.cssVarMap.entries()){let r=Object.fromEntries(n);if(Object.keys(r).length===0)continue;let i=t===`base`?a:d.resolve(t),o=i.startsWith(`@`);Bv(e,y(v({[i]:o?{[a]:r}:r})))}return c.wrap(`tokens`,e)}function C(){let e=Oy(n.keyframes??Zy,(e,t)=>[`@keyframes ${e}`,t]),t=Object.assign({},e,y(v(i)));return c.wrap(`base`,t)}function w(e){return on(e,h)}function T(){let e=Fb({preflight:s});return c.wrap(`reset`,e)}let E=Dx(l),D=(e,t)=>E.get(e)?.value||t;D.var=(e,t)=>E.get(e)?.variable||t;function O(e,t){return n.recipes?.[e]??t}function k(e,t){return n.slotRecipes?.[e]??t}let ee=new Map,te=new Map;function ne(e,t){let n=ee.get(e);return n||(n=b(O(e,t??Zy)),ee.set(e,n)),n}function re(e,t){let n=te.get(e);return n||(n=x(k(e,t??Zy)),te.set(e,n)),n}function ie(e){return Object.hasOwnProperty.call(n.recipes??Zy,e)}function ae(e){return Object.hasOwnProperty.call(n.slotRecipes??Zy,e)}function oe(e){return ie(e)||ae(e)}return{$$chakra:!0,_config:t,_global:[T(),C(),S()],breakpoints:u,tokens:l,conditions:d,utility:f,token:D,properties:m,layers:c,isValidProperty:h,splitCssProps:w,normalizeValue:g,getTokenCss:S,getGlobalCss:C,getPreflightCss:T,css:y,cva:b,sva:x,getRecipe:O,getSlotRecipe:k,getRecipeFn:ne,getSlotRecipeFn:re,hasRecipe:oe,isRecipe:ie,isSlotRecipe:ae,query:{layerStyles:kx(n.layerStyles??Zy),textStyles:kx(n.textStyles??Zy),animationStyles:kx(n.animationStyles??Zy),tokens:Ax(l,Object.keys(n.tokens??Zy),(e,t)=>!e.extensions.conditions&&!t.includes(`colorPalette`)),semanticTokens:Ax(l,Object.keys(n.semanticTokens??Zy),e=>!!e.extensions.conditions),keyframes:jx(n.keyframes??Zy),breakpoints:jx(n.breakpoints??Zy)}}}function Dx(e){let t=new Map,n=new Set(e.allTokens.map(e=>e.name));for(let r of n){let n=e.getByName(r);if(!n?.extensions.cssVar)continue;let{cssVar:i,virtual:a,conditions:o}=n.extensions,s=o||a?i.ref:n.value;t.set(r,{value:s,variable:i.ref})}return t}var Ox=e=>Kt(e)&&`value`in e,kx=e=>({list(){return Object.keys(ky(e,Ox))},search(e){return this.list().filter(t=>t.includes(e))}}),Ax=(e,t,n)=>({categoryKeys:t,list(t){let r=e.categoryMap.get(t),i=r?[...r.entries()]:[],a=[];for(let e=0;e<i.length;e++){let[t,r]=i[e];n(r,t)&&a.push(t)}return a},search(e,t){return this.list(e).filter(e=>e.includes(t))}}),jx=e=>({list(){return Object.keys(e)},search(e){return this.list().filter(t=>t.includes(e))}}),Mx={sm:`480px`,md:`768px`,lg:`1024px`,xl:`1280px`,"2xl":`1536px`},Nx=`var(--chakra-empty, )`,Px=Xv({"*":{fontFeatureSettings:`"cv11"`,"--ring-inset":Nx,"--ring-offset-width":`0px`,"--ring-offset-color":`#fff`,"--ring-color":`rgba(66, 153, 225, 0.6)`,"--ring-offset-shadow":`0 0 #0000`,"--ring-shadow":`0 0 #0000`,...Object.fromEntries([`brightness`,`contrast`,`grayscale`,`hue-rotate`,`invert`,`saturate`,`sepia`,`drop-shadow`].map(e=>[`--${e}`,Nx])),...Object.fromEntries([`blur`,`brightness`,`contrast`,`grayscale`,`hue-rotate`,`invert`,`opacity`,`saturate`,`sepia`].map(e=>[`--backdrop-${e}`,Nx])),"--global-font-mono":`fonts.mono`,"--global-font-body":`fonts.body`,"--global-color-border":`colors.border`},html:{color:`fg`,bg:`bg`,lineHeight:`1.5`,colorPalette:`gray`},"*::placeholder, *[data-placeholder]":{color:`fg.muted/80`},"*::selection":{bg:`colorPalette.emphasized/80`}}),Fx=ey({"fill.muted":{value:{background:`colorPalette.muted`,color:`colorPalette.fg`}},"fill.subtle":{value:{background:`colorPalette.subtle`,color:`colorPalette.fg`}},"fill.surface":{value:{background:`colorPalette.subtle`,color:`colorPalette.fg`,boxShadow:`0 0 0px 1px var(--shadow-color)`,boxShadowColor:`colorPalette.muted`}},"fill.solid":{value:{background:`colorPalette.solid`,color:`colorPalette.contrast`}},"outline.subtle":{value:{color:`colorPalette.fg`,boxShadow:`inset 0 0 0px 1px var(--shadow-color)`,boxShadowColor:`colorPalette.subtle`}},"outline.solid":{value:{borderWidth:`1px`,borderColor:`colorPalette.solid`,color:`colorPalette.fg`}},"indicator.bottom":{value:{position:`relative`,"--indicator-color-fallback":`colors.colorPalette.solid`,_before:{content:`""`,position:`absolute`,bottom:`var(--indicator-offset-y, 0)`,insetInline:`var(--indicator-offset-x, 0)`,height:`var(--indicator-thickness, 2px)`,background:`var(--indicator-color, var(--indicator-color-fallback))`}}},"indicator.top":{value:{position:`relative`,"--indicator-color-fallback":`colors.colorPalette.solid`,_before:{content:`""`,position:`absolute`,top:`var(--indicator-offset-y, 0)`,insetInline:`var(--indicator-offset-x, 0)`,height:`var(--indicator-thickness, 2px)`,background:`var(--indicator-color, var(--indicator-color-fallback))`}}},"indicator.start":{value:{position:`relative`,"--indicator-color-fallback":`colors.colorPalette.solid`,_before:{content:`""`,position:`absolute`,insetInlineStart:`var(--indicator-offset-x, 0)`,insetBlock:`var(--indicator-offset-y, 0)`,width:`var(--indicator-thickness, 2px)`,background:`var(--indicator-color, var(--indicator-color-fallback))`}}},"indicator.end":{value:{position:`relative`,"--indicator-color-fallback":`colors.colorPalette.solid`,_before:{content:`""`,position:`absolute`,insetInlineEnd:`var(--indicator-offset-x, 0)`,insetBlock:`var(--indicator-offset-y, 0)`,width:`var(--indicator-thickness, 2px)`,background:`var(--indicator-color, var(--indicator-color-fallback))`}}},disabled:{value:{opacity:`0.5`,cursor:`not-allowed`}},none:{value:{}}}),Ix=$v({"slide-fade-in":{value:{transformOrigin:`var(--transform-origin)`,"&[data-placement^=top]":{animationName:`slide-from-bottom, fade-in`},"&[data-placement^=bottom]":{animationName:`slide-from-top, fade-in`},"&[data-placement^=left]":{animationName:`slide-from-right, fade-in`},"&[data-placement^=right]":{animationName:`slide-from-left, fade-in`}}},"slide-fade-out":{value:{transformOrigin:`var(--transform-origin)`,"&[data-placement^=top]":{animationName:`slide-to-bottom, fade-out`},"&[data-placement^=bottom]":{animationName:`slide-to-top, fade-out`},"&[data-placement^=left]":{animationName:`slide-to-right, fade-out`},"&[data-placement^=right]":{animationName:`slide-to-left, fade-out`}}},"scale-fade-in":{value:{transformOrigin:`var(--transform-origin)`,animationName:`scale-in, fade-in`}},"scale-fade-out":{value:{transformOrigin:`var(--transform-origin)`,animationName:`scale-out, fade-out`}}}),Lx=Jv({className:`chakra-badge`,base:{display:`inline-flex`,alignItems:`center`,borderRadius:`l2`,gap:`1`,fontWeight:`medium`,fontVariantNumeric:`tabular-nums`,whiteSpace:`nowrap`,userSelect:`none`},variants:{variant:{solid:{bg:`colorPalette.solid`,color:`colorPalette.contrast`},subtle:{bg:`colorPalette.subtle`,color:`colorPalette.fg`},outline:{color:`colorPalette.fg`,"--outline-shadow-legacy":`colors.colorPalette.muted`,"--outline-shadow":`colors.colorPalette.border`,shadow:`inset 0 0 0px 1px var(--shadow-color)`,shadowColor:`var(--outline-shadow, var(--outline-shadow-legacy))`},surface:{bg:`colorPalette.subtle`,color:`colorPalette.fg`,shadow:`inset 0 0 0px 1px var(--shadow-color)`,shadowColor:`colorPalette.muted`},plain:{color:`colorPalette.fg`}},size:{xs:{textStyle:`2xs`,px:`1`,minH:`4`},sm:{textStyle:`xs`,px:`1.5`,minH:`5`},md:{textStyle:`sm`,px:`2`,minH:`6`},lg:{textStyle:`sm`,px:`2.5`,minH:`7`}}},defaultVariants:{variant:`subtle`,size:`sm`}}),Rx=Jv({className:`chakra-button`,base:{display:`inline-flex`,appearance:`none`,alignItems:`center`,justifyContent:`center`,userSelect:`none`,position:`relative`,borderRadius:`l2`,whiteSpace:`nowrap`,verticalAlign:`middle`,borderWidth:`1px`,borderColor:`transparent`,cursor:`button`,flexShrink:`0`,outline:`0`,lineHeight:`1.2`,isolation:`isolate`,fontWeight:`medium`,transitionProperty:`common`,transitionDuration:`moderate`,focusVisibleRing:`outside`,_disabled:{layerStyle:`disabled`},_icon:{flexShrink:`0`}},variants:{size:{"2xs":{h:`6`,minW:`6`,textStyle:`xs`,px:`2`,gap:`1`,_icon:{width:`3.5`,height:`3.5`}},xs:{h:`8`,minW:`8`,textStyle:`xs`,px:`2.5`,gap:`1`,_icon:{width:`4`,height:`4`}},sm:{h:`9`,minW:`9`,px:`3.5`,textStyle:`sm`,gap:`2`,_icon:{width:`4`,height:`4`}},md:{h:`10`,minW:`10`,textStyle:`sm`,px:`4`,gap:`2`,_icon:{width:`5`,height:`5`}},lg:{h:`11`,minW:`11`,textStyle:`md`,px:`5`,gap:`3`,_icon:{width:`5`,height:`5`}},xl:{h:`12`,minW:`12`,textStyle:`md`,px:`5`,gap:`2.5`,_icon:{width:`5`,height:`5`}},"2xl":{h:`16`,minW:`16`,textStyle:`lg`,px:`7`,gap:`3`,_icon:{width:`6`,height:`6`}}},variant:{solid:{bg:`colorPalette.solid`,color:`colorPalette.contrast`,borderColor:`transparent`,_hover:{bg:`colorPalette.solid/90`},_expanded:{bg:`colorPalette.solid/90`}},subtle:{bg:`colorPalette.subtle`,color:`colorPalette.fg`,borderColor:`transparent`,_hover:{bg:`colorPalette.muted`},_expanded:{bg:`colorPalette.muted`}},surface:{bg:`colorPalette.subtle`,color:`colorPalette.fg`,shadow:`0 0 0px 1px var(--shadow-color)`,shadowColor:`colorPalette.muted`,_hover:{bg:`colorPalette.muted`},_expanded:{bg:`colorPalette.muted`}},outline:{borderWidth:`1px`,"--outline-color-legacy":`colors.colorPalette.muted`,"--outline-color":`colors.colorPalette.border`,borderColor:`var(--outline-color, var(--outline-color-legacy))`,color:`colorPalette.fg`,_hover:{bg:`colorPalette.subtle`},_expanded:{bg:`colorPalette.subtle`}},ghost:{bg:`transparent`,color:`colorPalette.fg`,_hover:{bg:`colorPalette.subtle`},_expanded:{bg:`colorPalette.subtle`}},plain:{color:`colorPalette.fg`}}},defaultVariants:{size:`md`,variant:`solid`}}),zx=Jv({className:`chakra-checkmark`,base:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`,color:`white`,borderWidth:`1px`,borderColor:`transparent`,borderRadius:`l1`,cursor:`checkbox`,focusVisibleRing:`outside`,_icon:{boxSize:`full`},_invalid:{colorPalette:`red`,borderColor:`border.error`},_disabled:{opacity:`0.5`,cursor:`disabled`}},variants:{size:{xs:{boxSize:`3`},sm:{boxSize:`4`},md:{boxSize:`5`,p:`0.5`},lg:{boxSize:`6`,p:`0.5`}},variant:{solid:{borderColor:`border.emphasized`,"&:is([data-state=checked], [data-state=indeterminate])":{bg:`colorPalette.solid`,color:`colorPalette.contrast`,borderColor:`colorPalette.solid`}},outline:{borderColor:`border`,"&:is([data-state=checked], [data-state=indeterminate])":{color:`colorPalette.fg`,borderColor:`colorPalette.solid`}},subtle:{bg:`colorPalette.muted`,borderColor:`colorPalette.muted`,"&:is([data-state=checked], [data-state=indeterminate])":{color:`colorPalette.fg`}},plain:{"&:is([data-state=checked], [data-state=indeterminate])":{color:`colorPalette.fg`}},inverted:{borderColor:`border`,color:`colorPalette.fg`,"&:is([data-state=checked], [data-state=indeterminate])":{borderColor:`colorPalette.solid`}}},filled:{true:{bg:`bg`}}},defaultVariants:{variant:`solid`,size:`md`}}),{variants:Bx,defaultVariants:Vx}=Lx,Hx=Jv({className:`chakra-code`,base:{fontFamily:`mono`,alignItems:`center`,display:`inline-flex`,borderRadius:`l2`},variants:Bx,defaultVariants:Vx}),Ux=Jv({className:`color-swatch`,base:{boxSize:`var(--swatch-size)`,shadow:`inset 0 0 0 1px rgba(0, 0, 0, 0.1)`,"--checker-size":`8px`,"--checker-bg":`colors.bg`,"--checker-fg":`colors.bg.emphasized`,background:`linear-gradient(var(--color), var(--color)), repeating-conic-gradient(var(--checker-fg) 0%, var(--checker-fg) 25%, var(--checker-bg) 0%, var(--checker-bg) 50%) 0% 50% / var(--checker-size) var(--checker-size) !important`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`},variants:{size:{"2xs":{"--swatch-size":`sizes.3.5`},xs:{"--swatch-size":`sizes.4`},sm:{"--swatch-size":`sizes.4.5`},md:{"--swatch-size":`sizes.5`},lg:{"--swatch-size":`sizes.6`},xl:{"--swatch-size":`sizes.7`},"2xl":{"--swatch-size":`sizes.8`},inherit:{"--swatch-size":`inherit`},full:{"--swatch-size":`100%`}},shape:{square:{borderRadius:`none`},circle:{borderRadius:`full`},rounded:{borderRadius:`l1`}}},defaultVariants:{size:`md`,shape:`rounded`}}),Wx=Jv({className:`chakra-container`,base:{position:`relative`,maxWidth:`8xl`,w:`100%`,mx:`auto`,px:{base:`4`,md:`6`,lg:`8`}},variants:{centerContent:{true:{display:`flex`,flexDirection:`column`,alignItems:`center`}},fluid:{true:{maxWidth:`full`}}}}),Gx=Jv({className:`chakra-heading`,base:{fontFamily:`heading`,fontWeight:`semibold`},variants:{size:{xs:{textStyle:`xs`},sm:{textStyle:`sm`},md:{textStyle:`md`},lg:{textStyle:`lg`},xl:{textStyle:`xl`},"2xl":{textStyle:`2xl`},"3xl":{textStyle:`3xl`},"4xl":{textStyle:`4xl`},"5xl":{textStyle:`5xl`},"6xl":{textStyle:`6xl`},"7xl":{textStyle:`7xl`}}},defaultVariants:{size:`xl`}}),Kx=Jv({className:`chakra-icon`,base:{display:`inline-block`,lineHeight:`1em`,flexShrink:`0`,color:`currentcolor`,verticalAlign:`middle`},variants:{size:{inherit:{},xs:{boxSize:`3`},sm:{boxSize:`4`},md:{boxSize:`5`},lg:{boxSize:`6`},xl:{boxSize:`7`},"2xl":{boxSize:`8`}}},defaultVariants:{size:`inherit`}}),qx=Jv({className:`chakra-input`,base:{width:`100%`,minWidth:`0`,outline:`0`,position:`relative`,appearance:`none`,textAlign:`start`,borderRadius:`l2`,_disabled:{layerStyle:`disabled`},height:`var(--input-height)`,minW:`var(--input-height)`,"--focus-color":`colors.colorPalette.focusRing`,"--error-color":`colors.border.error`,_invalid:{focusRingColor:`var(--error-color)`,borderColor:`var(--error-color)`}},variants:{size:{"2xs":{textStyle:`xs`,px:`2`,"--input-height":`sizes.7`},xs:{textStyle:`xs`,px:`2`,"--input-height":`sizes.8`},sm:{textStyle:`sm`,px:`2.5`,"--input-height":`sizes.9`},md:{textStyle:`sm`,px:`3`,"--input-height":`sizes.10`},lg:{textStyle:`md`,px:`4`,"--input-height":`sizes.11`},xl:{textStyle:`md`,px:`4.5`,"--input-height":`sizes.12`},"2xl":{textStyle:`lg`,px:`5`,"--input-height":`sizes.16`}},variant:{outline:{bg:`transparent`,borderWidth:`1px`,borderColor:`border`,focusVisibleRing:`inside`,focusRingColor:`var(--focus-color)`},subtle:{borderWidth:`1px`,borderColor:`transparent`,bg:`bg.muted`,focusVisibleRing:`inside`,focusRingColor:`var(--focus-color)`},flushed:{bg:`transparent`,borderBottomWidth:`1px`,borderBottomColor:`border`,borderRadius:`0`,px:`0`,_focusVisible:{borderColor:`var(--focus-color)`,boxShadow:`0px 1px 0px 0px var(--focus-color)`,_invalid:{borderColor:`var(--error-color)`,boxShadow:`0px 1px 0px 0px var(--error-color)`}}}}},defaultVariants:{size:`md`,variant:`outline`}}),Jx=Jv({className:`chakra-input-addon`,base:{flex:`0 0 auto`,width:`auto`,display:`flex`,alignItems:`center`,whiteSpace:`nowrap`,alignSelf:`stretch`,borderRadius:`l2`},variants:{size:qx.variants.size,variant:{outline:{borderWidth:`1px`,borderColor:`border`,bg:`bg.muted`},subtle:{borderWidth:`1px`,borderColor:`transparent`,bg:`bg.emphasized`},flushed:{borderBottom:`1px solid`,borderColor:`inherit`,borderRadius:`0`,px:`0`,bg:`transparent`}}},defaultVariants:{size:`md`,variant:`outline`}}),Yx=Jv({className:`chakra-kbd`,base:{display:`inline-flex`,alignItems:`center`,fontWeight:`medium`,fontFamily:`mono`,flexShrink:`0`,whiteSpace:`nowrap`,wordSpacing:`-0.5em`,userSelect:`none`,px:`1`,borderRadius:`l2`},variants:{variant:{raised:{bg:`colorPalette.subtle`,color:`colorPalette.fg`,borderWidth:`1px`,borderBottomWidth:`2px`,borderColor:`colorPalette.muted`},outline:{borderWidth:`1px`,color:`colorPalette.fg`},subtle:{bg:`colorPalette.muted`,color:`colorPalette.fg`},plain:{color:`colorPalette.fg`}},size:{sm:{textStyle:`xs`,height:`4.5`},md:{textStyle:`sm`,height:`5`},lg:{textStyle:`md`,height:`6`}}},defaultVariants:{size:`md`,variant:`raised`}}),Xx=Jv({className:`chakra-link`,base:{display:`inline-flex`,alignItems:`center`,outline:`none`,gap:`1.5`,cursor:`pointer`,borderRadius:`l1`,focusVisibleRing:`outside`},variants:{variant:{underline:{color:`colorPalette.fg`,textDecoration:`underline`,textUnderlineOffset:`3px`,textDecorationColor:`currentColor/20`},plain:{color:`colorPalette.fg`,_hover:{textDecoration:`underline`,textUnderlineOffset:`3px`,textDecorationColor:`currentColor/20`}}}},defaultVariants:{variant:`plain`}}),Zx=Jv({className:`chakra-mark`,base:{bg:`transparent`,color:`inherit`,whiteSpace:`nowrap`},variants:{variant:{subtle:{bg:`colorPalette.subtle`,color:`inherit`},solid:{bg:`colorPalette.solid`,color:`colorPalette.contrast`},text:{fontWeight:`medium`},plain:{}}}}),Qx=Jv({className:`chakra-radiomark`,base:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,verticalAlign:`top`,color:`white`,borderWidth:`1px`,borderColor:`transparent`,borderRadius:`full`,cursor:`radio`,_focusVisible:{outline:`2px solid`,outlineColor:`colorPalette.focusRing`,outlineOffset:`2px`},_invalid:{colorPalette:`red`,borderColor:`red.500`},_disabled:{opacity:`0.5`,cursor:`disabled`},"& .dot":{height:`100%`,width:`100%`,borderRadius:`full`,bg:`currentColor`,scale:`0.4`}},variants:{variant:{solid:{borderWidth:`1px`,borderColor:`border.emphasized`,_checked:{bg:`colorPalette.solid`,color:`colorPalette.contrast`,borderColor:`colorPalette.solid`}},subtle:{borderWidth:`1px`,bg:`colorPalette.muted`,borderColor:`colorPalette.muted`,color:`transparent`,_checked:{color:`colorPalette.fg`}},outline:{borderWidth:`1px`,borderColor:`inherit`,_checked:{color:`colorPalette.fg`,borderColor:`colorPalette.solid`},"& .dot":{scale:`0.6`}},inverted:{bg:`bg`,borderWidth:`1px`,borderColor:`inherit`,_checked:{color:`colorPalette.solid`,borderColor:`currentcolor`}}},size:{xs:{boxSize:`3`},sm:{boxSize:`4`},md:{boxSize:`5`},lg:{boxSize:`6`}},filled:{true:{bg:`bg`}}},defaultVariants:{variant:`solid`,size:`md`}}),$x={badge:Lx,button:Rx,code:Hx,container:Wx,heading:Gx,input:qx,inputAddon:Jx,kbd:Yx,link:Xx,mark:Zx,separator:Jv({className:`chakra-separator`,base:{display:`block`,borderColor:`border`},variants:{variant:{solid:{borderStyle:`solid`},dashed:{borderStyle:`dashed`},dotted:{borderStyle:`dotted`}},orientation:{vertical:{borderInlineStartWidth:`var(--separator-thickness)`},horizontal:{borderTopWidth:`var(--separator-thickness)`}},size:{xs:{"--separator-thickness":`0.5px`},sm:{"--separator-thickness":`1px`},md:{"--separator-thickness":`2px`},lg:{"--separator-thickness":`3px`}}},defaultVariants:{size:`sm`,variant:`solid`,orientation:`horizontal`}}),skeleton:Jv({className:`chakra-skeleton`,base:{},variants:{loading:{true:{borderRadius:`l2`,boxShadow:`none`,backgroundClip:`padding-box`,cursor:`default`,color:`transparent`,pointerEvents:`none`,userSelect:`none`,flexShrink:`0`,"&::before, &::after, *":{visibility:`hidden`}},false:{background:`unset`,animation:`fade-in var(--fade-duration, 0.1s) ease-out !important`}},variant:{pulse:{background:`bg.emphasized`,animation:`pulse`,animationDuration:`var(--duration, 1.2s)`},shine:{"--animate-from":`200%`,"--animate-to":`-200%`,"--start-color":`colors.bg.muted`,"--end-color":`colors.bg.emphasized`,backgroundImage:`linear-gradient(270deg,var(--start-color),var(--end-color),var(--end-color),var(--start-color))`,backgroundSize:`400% 100%`,animation:`bg-position var(--duration, 5s) ease-in-out infinite`},none:{animation:`none`}}},defaultVariants:{variant:`pulse`,loading:!0}}),skipNavLink:Jv({className:`chakra-skip-nav`,base:{display:`inline-flex`,bg:`bg.panel`,padding:`2.5`,borderRadius:`l2`,fontWeight:`semibold`,focusVisibleRing:`outside`,textStyle:`sm`,userSelect:`none`,border:`0`,height:`1px`,width:`1px`,margin:`-1px`,outline:`0`,overflow:`hidden`,position:`absolute`,clip:`rect(0 0 0 0)`,_focusVisible:{clip:`auto`,width:`auto`,height:`auto`,position:`fixed`,top:`6`,insetStart:`6`}}}),spinner:Jv({className:`chakra-spinner`,base:{display:`inline-block`,borderColor:`currentColor`,borderStyle:`solid`,borderWidth:`2px`,borderRadius:`full`,width:`var(--spinner-size)`,height:`var(--spinner-size)`,animation:`spin`,animationDuration:`slowest`,"--spinner-track-color":`transparent`,borderBottomColor:`var(--spinner-track-color)`,borderInlineStartColor:`var(--spinner-track-color)`},variants:{size:{inherit:{"--spinner-size":`1em`},xs:{"--spinner-size":`sizes.3`},sm:{"--spinner-size":`sizes.4`},md:{"--spinner-size":`sizes.5`},lg:{"--spinner-size":`sizes.8`},xl:{"--spinner-size":`sizes.10`}}},defaultVariants:{size:`md`}}),textarea:Jv({className:`chakra-textarea`,base:{width:`100%`,minWidth:`0`,outline:`0`,position:`relative`,appearance:`none`,textAlign:`start`,borderRadius:`l2`,_disabled:{layerStyle:`disabled`},"--focus-color":`colors.colorPalette.focusRing`,"--error-color":`colors.border.error`,_invalid:{focusRingColor:`var(--error-color)`,borderColor:`var(--error-color)`}},variants:{size:{xs:{textStyle:`xs`,px:`2`,py:`1.5`,scrollPaddingBottom:`1.5`},sm:{textStyle:`sm`,px:`2.5`,py:`2`,scrollPaddingBottom:`2`},md:{textStyle:`sm`,px:`3`,py:`2`,scrollPaddingBottom:`2`},lg:{textStyle:`md`,px:`4`,py:`3`,scrollPaddingBottom:`3`},xl:{textStyle:`md`,px:`4.5`,py:`3.5`,scrollPaddingBottom:`3.5`}},variant:{outline:{bg:`transparent`,borderWidth:`1px`,borderColor:`border`,focusVisibleRing:`inside`},subtle:{borderWidth:`1px`,borderColor:`transparent`,bg:`bg.muted`,focusVisibleRing:`inside`},flushed:{bg:`transparent`,borderBottomWidth:`1px`,borderBottomColor:`border`,borderRadius:`0`,px:`0`,_focusVisible:{borderColor:`var(--focus-color)`,boxShadow:`0px 1px 0px 0px var(--focus-color)`}}}},defaultVariants:{size:`md`,variant:`outline`}}),icon:Kx,checkmark:zx,radiomark:Qx,colorSwatch:Ux},eS=ry.colors({bg:{DEFAULT:{value:{_light:`{colors.white}`,_dark:`{colors.black}`}},subtle:{value:{_light:`{colors.gray.50}`,_dark:`{colors.gray.950}`}},muted:{value:{_light:`{colors.gray.100}`,_dark:`{colors.gray.900}`}},emphasized:{value:{_light:`{colors.gray.200}`,_dark:`{colors.gray.800}`}},inverted:{value:{_light:`{colors.black}`,_dark:`{colors.white}`}},panel:{value:{_light:`{colors.white}`,_dark:`{colors.gray.950}`}},error:{value:{_light:`{colors.red.50}`,_dark:`{colors.red.950}`}},warning:{value:{_light:`{colors.orange.50}`,_dark:`{colors.orange.950}`}},success:{value:{_light:`{colors.green.50}`,_dark:`{colors.green.950}`}},info:{value:{_light:`{colors.blue.50}`,_dark:`{colors.blue.950}`}}},fg:{DEFAULT:{value:{_light:`{colors.black}`,_dark:`{colors.gray.50}`}},muted:{value:{_light:`{colors.gray.600}`,_dark:`{colors.gray.400}`}},subtle:{value:{_light:`{colors.gray.400}`,_dark:`{colors.gray.500}`}},inverted:{value:{_light:`{colors.gray.50}`,_dark:`{colors.black}`}},error:{value:{_light:`{colors.red.500}`,_dark:`{colors.red.400}`}},warning:{value:{_light:`{colors.orange.600}`,_dark:`{colors.orange.300}`}},success:{value:{_light:`{colors.green.600}`,_dark:`{colors.green.300}`}},info:{value:{_light:`{colors.blue.600}`,_dark:`{colors.blue.300}`}}},border:{DEFAULT:{value:{_light:`{colors.gray.200}`,_dark:`{colors.gray.800}`}},muted:{value:{_light:`{colors.gray.100}`,_dark:`{colors.gray.900}`}},subtle:{value:{_light:`{colors.gray.50}`,_dark:`{colors.gray.950}`}},emphasized:{value:{_light:`{colors.gray.300}`,_dark:`{colors.gray.700}`}},inverted:{value:{_light:`{colors.gray.800}`,_dark:`{colors.gray.200}`}},error:{value:{_light:`{colors.red.500}`,_dark:`{colors.red.400}`}},warning:{value:{_light:`{colors.orange.500}`,_dark:`{colors.orange.400}`}},success:{value:{_light:`{colors.green.500}`,_dark:`{colors.green.400}`}},info:{value:{_light:`{colors.blue.500}`,_dark:`{colors.blue.400}`}}},gray:{contrast:{value:{_light:`{colors.white}`,_dark:`{colors.black}`}},fg:{value:{_light:`{colors.gray.800}`,_dark:`{colors.gray.200}`}},subtle:{value:{_light:`{colors.gray.100}`,_dark:`{colors.gray.900}`}},muted:{value:{_light:`{colors.gray.200}`,_dark:`{colors.gray.800}`}},emphasized:{value:{_light:`{colors.gray.300}`,_dark:`{colors.gray.700}`}},solid:{value:{_light:`{colors.gray.900}`,_dark:`{colors.white}`}},focusRing:{value:{_light:`{colors.gray.400}`,_dark:`{colors.gray.400}`}},border:{value:{_light:`{colors.gray.200}`,_dark:`{colors.gray.800}`}}},red:{contrast:{value:{_light:`white`,_dark:`white`}},fg:{value:{_light:`{colors.red.700}`,_dark:`{colors.red.300}`}},subtle:{value:{_light:`{colors.red.100}`,_dark:`{colors.red.900}`}},muted:{value:{_light:`{colors.red.200}`,_dark:`{colors.red.800}`}},emphasized:{value:{_light:`{colors.red.300}`,_dark:`{colors.red.700}`}},solid:{value:{_light:`{colors.red.600}`,_dark:`{colors.red.600}`}},focusRing:{value:{_light:`{colors.red.500}`,_dark:`{colors.red.500}`}},border:{value:{_light:`{colors.red.500}`,_dark:`{colors.red.400}`}}},orange:{contrast:{value:{_light:`white`,_dark:`black`}},fg:{value:{_light:`{colors.orange.700}`,_dark:`{colors.orange.300}`}},subtle:{value:{_light:`{colors.orange.100}`,_dark:`{colors.orange.900}`}},muted:{value:{_light:`{colors.orange.200}`,_dark:`{colors.orange.800}`}},emphasized:{value:{_light:`{colors.orange.300}`,_dark:`{colors.orange.700}`}},solid:{value:{_light:`{colors.orange.600}`,_dark:`{colors.orange.500}`}},focusRing:{value:{_light:`{colors.orange.500}`,_dark:`{colors.orange.500}`}},border:{value:{_light:`{colors.orange.500}`,_dark:`{colors.orange.400}`}}},green:{contrast:{value:{_light:`white`,_dark:`white`}},fg:{value:{_light:`{colors.green.700}`,_dark:`{colors.green.300}`}},subtle:{value:{_light:`{colors.green.100}`,_dark:`{colors.green.900}`}},muted:{value:{_light:`{colors.green.200}`,_dark:`{colors.green.800}`}},emphasized:{value:{_light:`{colors.green.300}`,_dark:`{colors.green.700}`}},solid:{value:{_light:`{colors.green.600}`,_dark:`{colors.green.600}`}},focusRing:{value:{_light:`{colors.green.500}`,_dark:`{colors.green.500}`}},border:{value:{_light:`{colors.green.500}`,_dark:`{colors.green.400}`}}},blue:{contrast:{value:{_light:`white`,_dark:`white`}},fg:{value:{_light:`{colors.blue.700}`,_dark:`{colors.blue.300}`}},subtle:{value:{_light:`{colors.blue.100}`,_dark:`{colors.blue.900}`}},muted:{value:{_light:`{colors.blue.200}`,_dark:`{colors.blue.800}`}},emphasized:{value:{_light:`{colors.blue.300}`,_dark:`{colors.blue.700}`}},solid:{value:{_light:`{colors.blue.600}`,_dark:`{colors.blue.600}`}},focusRing:{value:{_light:`{colors.blue.500}`,_dark:`{colors.blue.500}`}},border:{value:{_light:`{colors.blue.500}`,_dark:`{colors.blue.400}`}}},yellow:{contrast:{value:{_light:`black`,_dark:`black`}},fg:{value:{_light:`{colors.yellow.800}`,_dark:`{colors.yellow.300}`}},subtle:{value:{_light:`{colors.yellow.100}`,_dark:`{colors.yellow.900}`}},muted:{value:{_light:`{colors.yellow.200}`,_dark:`{colors.yellow.800}`}},emphasized:{value:{_light:`{colors.yellow.300}`,_dark:`{colors.yellow.700}`}},solid:{value:{_light:`{colors.yellow.300}`,_dark:`{colors.yellow.300}`}},focusRing:{value:{_light:`{colors.yellow.500}`,_dark:`{colors.yellow.500}`}},border:{value:{_light:`{colors.yellow.500}`,_dark:`{colors.yellow.500}`}}},teal:{contrast:{value:{_light:`white`,_dark:`white`}},fg:{value:{_light:`{colors.teal.700}`,_dark:`{colors.teal.300}`}},subtle:{value:{_light:`{colors.teal.100}`,_dark:`{colors.teal.900}`}},muted:{value:{_light:`{colors.teal.200}`,_dark:`{colors.teal.800}`}},emphasized:{value:{_light:`{colors.teal.300}`,_dark:`{colors.teal.700}`}},solid:{value:{_light:`{colors.teal.600}`,_dark:`{colors.teal.600}`}},focusRing:{value:{_light:`{colors.teal.500}`,_dark:`{colors.teal.500}`}},border:{value:{_light:`{colors.teal.500}`,_dark:`{colors.teal.400}`}}},purple:{contrast:{value:{_light:`white`,_dark:`white`}},fg:{value:{_light:`{colors.purple.700}`,_dark:`{colors.purple.300}`}},subtle:{value:{_light:`{colors.purple.100}`,_dark:`{colors.purple.900}`}},muted:{value:{_light:`{colors.purple.200}`,_dark:`{colors.purple.800}`}},emphasized:{value:{_light:`{colors.purple.300}`,_dark:`{colors.purple.700}`}},solid:{value:{_light:`{colors.purple.600}`,_dark:`{colors.purple.600}`}},focusRing:{value:{_light:`{colors.purple.500}`,_dark:`{colors.purple.500}`}},border:{value:{_light:`{colors.purple.500}`,_dark:`{colors.purple.400}`}}},pink:{contrast:{value:{_light:`white`,_dark:`white`}},fg:{value:{_light:`{colors.pink.700}`,_dark:`{colors.pink.300}`}},subtle:{value:{_light:`{colors.pink.100}`,_dark:`{colors.pink.900}`}},muted:{value:{_light:`{colors.pink.200}`,_dark:`{colors.pink.800}`}},emphasized:{value:{_light:`{colors.pink.300}`,_dark:`{colors.pink.700}`}},solid:{value:{_light:`{colors.pink.600}`,_dark:`{colors.pink.600}`}},focusRing:{value:{_light:`{colors.pink.500}`,_dark:`{colors.pink.500}`}},border:{value:{_light:`{colors.pink.500}`,_dark:`{colors.pink.400}`}}},cyan:{contrast:{value:{_light:`white`,_dark:`white`}},fg:{value:{_light:`{colors.cyan.700}`,_dark:`{colors.cyan.300}`}},subtle:{value:{_light:`{colors.cyan.100}`,_dark:`{colors.cyan.900}`}},muted:{value:{_light:`{colors.cyan.200}`,_dark:`{colors.cyan.800}`}},emphasized:{value:{_light:`{colors.cyan.300}`,_dark:`{colors.cyan.700}`}},solid:{value:{_light:`{colors.cyan.600}`,_dark:`{colors.cyan.600}`}},focusRing:{value:{_light:`{colors.cyan.500}`,_dark:`{colors.cyan.500}`}},border:{value:{_light:`{colors.cyan.500}`,_dark:`{colors.cyan.400}`}}}}),tS=ry.radii({l1:{value:`{radii.xs}`},l2:{value:`{radii.sm}`},l3:{value:`{radii.md}`}}),nS=ry.shadows({xs:{value:{_light:`0px 1px 2px {colors.gray.900/10}, 0px 0px 1px {colors.gray.900/20}`,_dark:`0px 1px 1px {black/64}, 0px 0px 1px inset {colors.gray.300/20}`}},sm:{value:{_light:`0px 2px 4px {colors.gray.900/10}, 0px 0px 1px {colors.gray.900/30}`,_dark:`0px 2px 4px {black/64}, 0px 0px 1px inset {colors.gray.300/30}`}},md:{value:{_light:`0px 4px 8px {colors.gray.900/10}, 0px 0px 1px {colors.gray.900/30}`,_dark:`0px 4px 8px {black/64}, 0px 0px 1px inset {colors.gray.300/30}`}},lg:{value:{_light:`0px 8px 16px {colors.gray.900/10}, 0px 0px 1px {colors.gray.900/30}`,_dark:`0px 8px 16px {black/64}, 0px 0px 1px inset {colors.gray.300/30}`}},xl:{value:{_light:`0px 16px 24px {colors.gray.900/10}, 0px 0px 1px {colors.gray.900/30}`,_dark:`0px 16px 24px {black/64}, 0px 0px 1px inset {colors.gray.300/30}`}},"2xl":{value:{_light:`0px 24px 40px {colors.gray.900/16}, 0px 0px 1px {colors.gray.900/30}`,_dark:`0px 24px 40px {black/64}, 0px 0px 1px inset {colors.gray.300/30}`}},inner:{value:{_light:`inset 0 2px 4px 0 {black/5}`,_dark:`inset 0 2px 4px 0 black`}},inset:{value:{_light:`inset 0 0 0 1px {black/5}`,_dark:`inset 0 0 0 1px {colors.gray.300/5}`}}}),rS=qc.extendWith(`itemBody`),iS=V(`action-bar`).parts(`positioner`,`content`,`separator`,`selectionTrigger`,`closeTrigger`),aS=V(`alert`).parts(`title`,`description`,`root`,`indicator`,`content`),oS=V(`breadcrumb`).parts(`link`,`currentLink`,`item`,`list`,`root`,`ellipsis`,`separator`),sS=V(`blockquote`).parts(`root`,`icon`,`content`,`caption`),cS=V(`card`).parts(`root`,`header`,`body`,`footer`,`title`,`description`),lS=V(`checkbox-card`,[`root`,`control`,`label`,`description`,`addon`,`indicator`,`content`]),uS=V(`data-list`).parts(`root`,`item`,`itemLabel`,`itemValue`),dS=Rp.extendWith(`indicatorGroup`),fS=zp.extendWith(`header`,`body`,`footer`,`backdrop`),pS=zp.extendWith(`header`,`body`,`footer`,`backdrop`),mS=am.extendWith(`textarea`),hS=V(`empty-state`,[`root`,`content`,`indicator`,`title`,`description`]),gS=om.extendWith(`requiredIndicator`),_S=cm.extendWith(`content`),vS=lm.extendWith(`itemContent`,`dropzoneContent`,`fileText`),yS=V(`list`).parts(`root`,`item`,`indicator`),bS=hm.extendWith(`itemCommand`),xS=V(`select`).parts(`root`,`field`,`indicator`),SS=vm.extendWith(`header`,`body`,`footer`),CS=xm.extendWith(`itemAddon`,`itemIndicator`),wS=CS.extendWith(`itemContent`,`itemDescription`),TS=Sm.extendWith(`itemIndicator`),ES=Tm.extendWith(`indicatorGroup`),DS=Fp.extendWith(`indicatorGroup`,`empty`),OS=$m.extendWith(`markerIndicator`,`markerLabel`),kS=V(`stat`).parts(`root`,`label`,`helpText`,`valueText`,`valueUnit`,`indicator`),AS=V(`status`).parts(`root`,`indicator`),jS=V(`steps`,[`root`,`list`,`item`,`trigger`,`indicator`,`separator`,`content`,`title`,`description`,`nextTrigger`,`prevTrigger`,`progress`]),MS=og.extendWith(`indicator`),NS=V(`table`).parts(`root`,`header`,`body`,`row`,`columnHeader`,`cell`,`footer`,`caption`),PS=V(`toast`).parts(`root`,`title`,`description`,`indicator`,`closeTrigger`,`actionTrigger`),FS=V(`tabs`).parts(`root`,`trigger`,`list`,`content`,`contentGroup`,`indicator`),IS=V(`tag`).parts(`root`,`label`,`closeTrigger`,`startElement`,`endElement`),LS=V(`timeline`).parts(`root`,`item`,`content`,`separator`,`indicator`,`connector`,`title`,`description`),RS=Sp.extendWith(`channelText`),zS=V(`code-block`,[`root`,`content`,`title`,`header`,`footer`,`control`,`overlay`,`code`,`codeText`,`copyTrigger`,`copyIndicator`,`collapseTrigger`,`collapseIndicator`,`collapseText`]),BS=rh.extendWith(`resizeTriggerSeparator`,`resizeTriggerIndicator`);Gu.extendWith(`valueText`);var VS=pm,HS=W({className:`chakra-accordion`,slots:rS.keys(),base:{root:{width:`full`,"--accordion-radius":`radii.l2`},item:{overflowAnchor:`none`},itemTrigger:{display:`flex`,alignItems:`center`,textAlign:`start`,width:`full`,outline:`0`,gap:`3`,fontWeight:`medium`,borderRadius:`var(--accordion-radius)`,_focusVisible:{outline:`2px solid`,outlineColor:`colorPalette.focusRing`},_disabled:{layerStyle:`disabled`}},itemBody:{pt:`var(--accordion-padding-y)`,pb:`calc(var(--accordion-padding-y) * 2)`},itemContent:{overflow:`hidden`,borderRadius:`var(--accordion-radius)`,_open:{animationName:`expand-height, fade-in`,animationDuration:`moderate`},_closed:{animationName:`collapse-height, fade-out`,animationDuration:`moderate`}},itemIndicator:{transition:`rotate 0.2s`,transformOrigin:`center`,color:`fg.subtle`,_open:{rotate:`180deg`},_icon:{width:`1.2em`,height:`1.2em`}}},variants:{variant:{outline:{item:{borderBottomWidth:`1px`}},subtle:{itemTrigger:{px:`var(--accordion-padding-x)`},itemContent:{px:`var(--accordion-padding-x)`},item:{borderRadius:`var(--accordion-radius)`,_open:{bg:`colorPalette.subtle`}}},enclosed:{root:{borderWidth:`1px`,borderRadius:`var(--accordion-radius)`,divideY:`1px`,overflow:`hidden`},itemTrigger:{px:`var(--accordion-padding-x)`},itemContent:{px:`var(--accordion-padding-x)`},item:{_open:{bg:`bg.subtle`}}},plain:{}},size:{sm:{root:{"--accordion-padding-x":`spacing.3`,"--accordion-padding-y":`spacing.2`},itemTrigger:{textStyle:`sm`,py:`var(--accordion-padding-y)`}},md:{root:{"--accordion-padding-x":`spacing.4`,"--accordion-padding-y":`spacing.2`},itemTrigger:{textStyle:`md`,py:`var(--accordion-padding-y)`}},lg:{root:{"--accordion-padding-x":`spacing.4.5`,"--accordion-padding-y":`spacing.2.5`},itemTrigger:{textStyle:`lg`,py:`var(--accordion-padding-y)`}}}},defaultVariants:{size:`md`,variant:`outline`}}),US=W({className:`chakra-action-bar`,slots:iS.keys(),base:{positioner:{position:`fixed`,display:`flex`,pointerEvents:`none`,insetInline:`0`,"--action-bar-offset":`spacing.4`},content:{bg:`bg.panel`,shadow:`md`,display:`flex`,alignItems:`center`,gap:`3`,borderRadius:`l3`,py:`2.5`,px:`3`,pointerEvents:`auto`,translate:`calc(-1 * var(--scrollbar-width) / 2) 0px`,_open:{animationName:`slide-from-bottom, fade-in`,animationDuration:`moderate`},_closed:{animationName:`slide-to-bottom, fade-out`,animationDuration:`faster`}},separator:{width:`1px`,height:`5`,bg:`border`},selectionTrigger:{display:`inline-flex`,alignItems:`center`,gap:`2`,alignSelf:`stretch`,textStyle:`sm`,px:`4`,py:`1`,borderRadius:`l2`,borderWidth:`1px`,borderStyle:`dashed`}},variants:{placement:{bottom:{positioner:{bottom:`calc(env(safe-area-inset-bottom) + var(--action-bar-offset))`,justifyContent:`center`}},"bottom-start":{positioner:{bottom:`calc(env(safe-area-inset-bottom) + var(--action-bar-offset))`,justifyContent:`flex-start`,ps:`var(--action-bar-offset)`}},"bottom-end":{positioner:{bottom:`calc(env(safe-area-inset-bottom) + var(--action-bar-offset))`,justifyContent:`flex-end`,pe:`var(--action-bar-offset)`}}}},defaultVariants:{placement:`bottom`}}),WS=W({slots:aS.keys(),className:`chakra-alert`,base:{root:{width:`full`,display:`flex`,alignItems:`flex-start`,position:`relative`,borderRadius:`l3`},title:{fontWeight:`medium`},description:{display:`inline`},indicator:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`,width:`1em`,height:`1em`,_icon:{boxSize:`full`}},content:{display:`flex`,flex:`1`,gap:`1`}},variants:{status:{info:{root:{colorPalette:`blue`}},warning:{root:{colorPalette:`orange`}},success:{root:{colorPalette:`green`}},error:{root:{colorPalette:`red`}},neutral:{root:{colorPalette:`gray`}}},inline:{true:{content:{display:`inline-flex`,flexDirection:`row`,alignItems:`center`}},false:{content:{display:`flex`,flexDirection:`column`}}},variant:{subtle:{root:{bg:`colorPalette.subtle`,color:`colorPalette.fg`}},surface:{root:{bg:`colorPalette.subtle`,color:`colorPalette.fg`,shadow:`inset 0 0 0px 1px var(--shadow-color)`,shadowColor:`colorPalette.muted`},indicator:{color:`colorPalette.fg`}},outline:{root:{color:`colorPalette.fg`,shadow:`inset 0 0 0px 1px var(--shadow-color)`,"--outline-shadow-legacy":`colors.colorPalette.muted`,"--outline-shadow":`colors.colorPalette.border`,shadowColor:`var(--outline-shadow, var(--outline-shadow-legacy))`},indicator:{color:`colorPalette.fg`}},solid:{root:{bg:`colorPalette.solid`,color:`colorPalette.contrast`},indicator:{color:`colorPalette.contrast`}}},size:{sm:{root:{gap:`2`,px:`3`,py:`3`,textStyle:`xs`},indicator:{textStyle:`lg`}},md:{root:{gap:`3`,px:`4`,py:`4`,textStyle:`sm`},indicator:{textStyle:`xl`}},lg:{root:{gap:`3`,px:`4`,py:`4`,textStyle:`md`},indicator:{textStyle:`2xl`}}}},defaultVariants:{status:`info`,variant:`subtle`,size:`md`,inline:!1}}),GS=W({slots:Jc.keys(),className:`chakra-avatar`,base:{root:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,fontWeight:`medium`,position:`relative`,verticalAlign:`top`,flexShrink:`0`,userSelect:`none`,width:`var(--avatar-size)`,height:`var(--avatar-size)`,fontSize:`var(--avatar-font-size)`,borderRadius:`var(--avatar-radius)`,"&[data-group-item]":{borderWidth:`2px`,borderColor:`bg`}},image:{width:`100%`,height:`100%`,objectFit:`cover`,borderRadius:`var(--avatar-radius)`},fallback:{lineHeight:`1`,textTransform:`uppercase`,fontWeight:`medium`,fontSize:`var(--avatar-font-size)`,borderRadius:`var(--avatar-radius)`}},variants:{size:{full:{root:{"--avatar-size":`100%`,"--avatar-font-size":`100%`}},"2xs":{root:{"--avatar-font-size":`fontSizes.2xs`,"--avatar-size":`sizes.6`}},xs:{root:{"--avatar-font-size":`fontSizes.xs`,"--avatar-size":`sizes.8`}},sm:{root:{"--avatar-font-size":`fontSizes.sm`,"--avatar-size":`sizes.9`}},md:{root:{"--avatar-font-size":`fontSizes.md`,"--avatar-size":`sizes.10`}},lg:{root:{"--avatar-font-size":`fontSizes.md`,"--avatar-size":`sizes.11`}},xl:{root:{"--avatar-font-size":`fontSizes.lg`,"--avatar-size":`sizes.12`}},"2xl":{root:{"--avatar-font-size":`fontSizes.xl`,"--avatar-size":`sizes.16`}}},variant:{solid:{root:{bg:`colorPalette.solid`,color:`colorPalette.contrast`}},subtle:{root:{bg:`colorPalette.muted`,color:`colorPalette.fg`}},outline:{root:{color:`colorPalette.fg`,borderWidth:`1px`,"--outline-shadow-legacy":`colors.colorPalette.muted`,"--outline-shadow":`colors.colorPalette.border`,borderColor:`var(--outline-shadow, var(--outline-shadow-legacy))`}}},shape:{square:{},rounded:{root:{"--avatar-radius":`radii.l3`}},full:{root:{"--avatar-radius":`radii.full`}}},borderless:{true:{root:{"&[data-group-item]":{borderWidth:`0px`}}}}},defaultVariants:{size:`md`,shape:`full`,variant:`subtle`}}),KS=W({className:`chakra-blockquote`,slots:sS.keys(),base:{root:{position:`relative`,display:`flex`,flexDirection:`column`,gap:`2`},caption:{textStyle:`sm`,color:`fg.muted`},icon:{boxSize:`5`}},variants:{justify:{start:{root:{alignItems:`flex-start`,textAlign:`start`}},center:{root:{alignItems:`center`,textAlign:`center`}},end:{root:{alignItems:`flex-end`,textAlign:`end`}}},variant:{subtle:{root:{paddingX:`5`,borderStartWidth:`4px`,borderStartColor:`colorPalette.muted`},icon:{color:`colorPalette.fg`}},solid:{root:{paddingX:`5`,borderStartWidth:`4px`,borderStartColor:`colorPalette.solid`},icon:{color:`colorPalette.solid`}},plain:{root:{paddingX:`5`},icon:{color:`colorPalette.solid`}}}},defaultVariants:{variant:`subtle`,justify:`start`}}),qS=W({className:`chakra-breadcrumb`,slots:oS.keys(),base:{list:{display:`flex`,alignItems:`center`,wordBreak:`break-word`,color:`fg.muted`,listStyle:`none`},link:{outline:`0`,textDecoration:`none`,borderRadius:`l1`,focusRing:`outside`,display:`inline-flex`,alignItems:`center`,gap:`2`},item:{display:`inline-flex`,alignItems:`center`},separator:{color:`fg.muted`,opacity:`0.8`,_icon:{boxSize:`1em`},_rtl:{rotate:`180deg`}},ellipsis:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,_icon:{boxSize:`1em`}}},variants:{variant:{underline:{link:{color:`colorPalette.fg`,textDecoration:`underline`,textUnderlineOffset:`0.2em`,textDecorationColor:`colorPalette.muted`},currentLink:{color:`colorPalette.fg`}},plain:{link:{color:`fg.muted`,_hover:{color:`fg`}},currentLink:{color:`fg`}}},size:{sm:{list:{gap:`1`,textStyle:`xs`}},md:{list:{gap:`1.5`,textStyle:`sm`}},lg:{list:{gap:`2`,textStyle:`md`}}}},defaultVariants:{variant:`plain`,size:`md`}}),JS=W({className:`chakra-card`,slots:cS.keys(),base:{root:{display:`flex`,flexDirection:`column`,position:`relative`,minWidth:`0`,wordWrap:`break-word`,borderRadius:`l3`,color:`fg`,textAlign:`start`},title:{fontWeight:`semibold`},description:{color:`fg.muted`,fontSize:`sm`},header:{paddingInline:`var(--card-padding)`,paddingTop:`var(--card-padding)`,display:`flex`,flexDirection:`column`,gap:`1.5`},body:{padding:`var(--card-padding)`,flex:`1`,display:`flex`,flexDirection:`column`},footer:{display:`flex`,alignItems:`center`,gap:`2`,paddingInline:`var(--card-padding)`,paddingBottom:`var(--card-padding)`}},variants:{size:{sm:{root:{"--card-padding":`spacing.4`},title:{textStyle:`md`}},md:{root:{"--card-padding":`spacing.6`},title:{textStyle:`lg`}},lg:{root:{"--card-padding":`spacing.7`},title:{textStyle:`xl`}}},variant:{elevated:{root:{bg:`bg.panel`,boxShadow:`md`}},outline:{root:{bg:`bg.panel`,borderWidth:`1px`,borderColor:`border`}},subtle:{root:{bg:`bg.muted`}}}},defaultVariants:{variant:`outline`,size:`md`}}),YS=W({className:`carousel`,slots:ou.keys(),base:{root:{position:`relative`,display:`flex`,gap:`2`,_horizontal:{flexDirection:`column`},_vertical:{flexDirection:`row`}},item:{_horizontal:{width:`100%`},_vertical:{height:`100%`}},control:{display:`flex`,alignItems:`center`,_horizontal:{flexDirection:`row`,width:`100%`},_vertical:{flexDirection:`column`,height:`100%`}},indicatorGroup:{display:`flex`,justifyContent:`center`,gap:`3`,_horizontal:{flexDirection:`row`},_vertical:{flexDirection:`column`}},indicator:{width:`2.5`,height:`2.5`,borderRadius:`full`,bg:`colorPalette.subtle`,cursor:`button`,_current:{bg:`colorPalette.solid`}}},defaultVariants:{}}),XS=W({slots:Wu.keys(),className:`chakra-checkbox`,base:{root:{display:`inline-flex`,gap:`2`,alignItems:`center`,verticalAlign:`top`,position:`relative`},control:zx.base,label:{fontWeight:`medium`,userSelect:`none`,_disabled:{opacity:`0.5`}}},variants:{size:{xs:{root:{gap:`1.5`},label:{textStyle:`xs`},control:zx.variants?.size?.xs},sm:{root:{gap:`2`},label:{textStyle:`sm`},control:zx.variants?.size?.sm},md:{root:{gap:`2.5`},label:{textStyle:`sm`},control:zx.variants?.size?.md},lg:{root:{gap:`3`},label:{textStyle:`md`},control:zx.variants?.size?.lg}},variant:{outline:{control:zx.variants?.variant?.outline},solid:{control:zx.variants?.variant?.solid},subtle:{control:zx.variants?.variant?.subtle}}},defaultVariants:{variant:`solid`,size:`md`}}),ZS=W({slots:lS.keys(),className:`chakra-checkbox-card`,base:{root:{display:`flex`,flexDirection:`column`,userSelect:`none`,position:`relative`,borderRadius:`l2`,flex:`1`,focusVisibleRing:`outside`,_disabled:{opacity:`0.8`},_invalid:{outline:`2px solid`,outlineColor:`border.error`}},control:{display:`inline-flex`,flex:`1`,position:`relative`,borderRadius:`inherit`,justifyContent:`var(--checkbox-card-justify)`,alignItems:`var(--checkbox-card-align)`},label:{fontWeight:`medium`,display:`flex`,alignItems:`center`,gap:`2`,flex:`1`,_disabled:{opacity:`0.5`}},description:{opacity:`0.64`,textStyle:`sm`,_disabled:{opacity:`0.5`}},addon:{_disabled:{opacity:`0.5`}},indicator:zx.base,content:{display:`flex`,flexDirection:`column`,flex:`1`,gap:`1`,justifyContent:`var(--checkbox-card-justify)`,alignItems:`var(--checkbox-card-align)`}},variants:{size:{sm:{root:{textStyle:`sm`},control:{padding:`3`,gap:`1.5`},addon:{px:`3`,py:`1.5`,borderTopWidth:`1px`},indicator:zx.variants?.size.sm},md:{root:{textStyle:`sm`},control:{padding:`4`,gap:`2.5`},addon:{px:`4`,py:`2`,borderTopWidth:`1px`},indicator:zx.variants?.size.md},lg:{root:{textStyle:`md`},control:{padding:`4`,gap:`3.5`},addon:{px:`4`,py:`2`,borderTopWidth:`1px`},indicator:zx.variants?.size.lg}},variant:{surface:{root:{borderWidth:`1px`,borderColor:`border`,_checked:{bg:`colorPalette.subtle`,color:`colorPalette.fg`,borderColor:`colorPalette.muted`},_disabled:{bg:`bg.muted`}},indicator:zx.variants?.variant.solid},subtle:{root:{bg:`bg.muted`},control:{_checked:{bg:`colorPalette.muted`,color:`colorPalette.fg`}},indicator:zx.variants?.variant.plain},outline:{root:{borderWidth:`1px`,borderColor:`border`,_checked:{boxShadow:`inset 0 0 0 1px var(--shadow-color)`,boxShadowColor:`colorPalette.solid`,borderColor:`colorPalette.solid`}},indicator:zx.variants?.variant.solid},solid:{root:{borderWidth:`1px`,_checked:{bg:`colorPalette.solid`,color:`colorPalette.contrast`,borderColor:`colorPalette.solid`}},indicator:zx.variants?.variant.inverted}},justify:{start:{root:{"--checkbox-card-justify":`flex-start`}},end:{root:{"--checkbox-card-justify":`flex-end`}},center:{root:{"--checkbox-card-justify":`center`}}},align:{start:{root:{"--checkbox-card-align":`flex-start`},content:{textAlign:`start`}},end:{root:{"--checkbox-card-align":`flex-end`},content:{textAlign:`end`}},center:{root:{"--checkbox-card-align":`center`},content:{textAlign:`center`}}},orientation:{vertical:{control:{flexDirection:`column`}},horizontal:{control:{flexDirection:`row`}}}},defaultVariants:{size:`md`,variant:`outline`,align:`start`,orientation:`horizontal`}}),QS=W({slots:zS.keys(),className:`code-block`,base:{root:{colorPalette:`gray`,rounded:`var(--code-block-radius)`,overflow:`hidden`,bg:`bg`,color:`fg`,borderWidth:`1px`,"--code-block-max-height":`320px`,"--code-block-bg":`colors.bg`,"--code-block-fg":`colors.fg`,"--code-block-obscured-opacity":`0.5`,"--code-block-obscured-blur":`1px`,"--code-block-line-number-width":`sizes.3`,"--code-block-line-number-margin":`spacing.4`,"--code-block-highlight-bg":`{colors.teal.focusRing/20}`,"--code-block-highlight-border":`colors.teal.focusRing`,"--code-block-highlight-added-bg":`{colors.green.focusRing/20}`,"--code-block-highlight-added-border":`colors.green.focusRing`,"--code-block-highlight-removed-bg":`{colors.red.focusRing/20}`,"--code-block-highlight-removed-border":`colors.red.focusRing`},header:{display:`flex`,alignItems:`center`,gap:`2`,position:`relative`,px:`var(--code-block-padding)`,minH:`var(--code-block-header-height)`,mb:`calc(var(--code-block-padding) / 2 * -1)`},title:{display:`inline-flex`,alignItems:`center`,gap:`1.5`,flex:`1`,color:`fg.muted`},control:{gap:`1.5`,display:`inline-flex`,alignItems:`center`},footer:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`2`,px:`var(--code-block-padding)`,minH:`var(--code-block-header-height)`},content:{position:`relative`,colorScheme:`dark`,borderBottomRadius:`var(--code-block-radius)`,maxHeight:`var(--code-block-max-height)`,"& ::selection":{bg:`blue.500/40`},_expanded:{maxHeight:`unset`}},overlay:{"--bg":`{colors.black/50}`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,padding:`4`,bgImage:`linear-gradient(0deg,var(--bg) 25%,transparent 100%)`,color:`white`,minH:`5rem`,pos:`absolute`,bottom:`0`,insetInline:`0`,zIndex:`1`,fontWeight:`medium`,_expanded:{display:`none`}},code:{fontFamily:`mono`,lineHeight:`tall`,whiteSpace:`pre`,counterReset:`line 0`,overflowX:`auto`,overflowY:`hidden`},codeText:{px:`var(--code-block-padding)`,py:`var(--code-block-padding)`,position:`relative`,display:`block`,width:`100%`,"&[data-has-focused]":{"& [data-line]:not([data-focused])":{transitionProperty:`opacity, filter`,transitionDuration:`moderate`,transitionTimingFunction:`ease-in-out`,opacity:`var(--code-block-obscured-opacity)`,filter:`blur(var(--code-block-obscured-blur))`},"&:hover":{"--code-block-obscured-opacity":`1`,"--code-block-obscured-blur":`0px`}},"&[data-has-line-numbers][data-plaintext]":{paddingInlineStart:`calc(var(--code-block-line-number-width) + var(--code-block-line-number-margin) + var(--code-block-padding))`},"& [data-line]":{position:`relative`,paddingInlineEnd:`var(--code-block-padding)`,"--highlight-bg":`var(--code-block-highlight-bg)`,"--highlight-border":`var(--code-block-highlight-border)`,"&[data-highlight], &[data-diff]":{display:`inline-block`,width:`full`,"&:after":{content:`''`,display:`block`,position:`absolute`,top:`0`,insetStart:`calc(var(--code-block-padding) * -1)`,insetEnd:`0px`,width:`calc(100% + var(--code-block-padding) * 2)`,height:`100%`,bg:`var(--highlight-bg)`,borderStartWidth:`2px`,borderStartColor:`var(--highlight-border)`}},"&[data-diff='added']":{"--highlight-bg":`var(--code-block-highlight-added-bg)`,"--highlight-border":`var(--code-block-highlight-added-border)`},"&[data-diff='removed']":{"--highlight-bg":`var(--code-block-highlight-removed-bg)`,"--highlight-border":`var(--code-block-highlight-removed-border)`}},"&[data-word-wrap]":{"&[data-plaintext], & [data-line]":{whiteSpace:`pre-wrap`,wordBreak:`break-all`}},"&[data-has-line-numbers]":{"--content":`counter(line)`,"& [data-line]:before":{content:`var(--content)`,counterIncrement:`line`,width:`var(--code-block-line-number-width)`,marginRight:`var(--code-block-line-number-margin)`,display:`inline-block`,textAlign:`end`,userSelect:`none`,whiteSpace:`nowrap`,opacity:.4},"& [data-diff='added']:before":{content:`'+'`},"& [data-diff='removed']:before":{content:`'-'`}}}},variants:{size:{sm:{root:{"--code-block-padding":`spacing.4`,"--code-block-radius":`radii.md`,"--code-block-header-height":`sizes.8`},title:{textStyle:`xs`},code:{fontSize:`xs`}},md:{root:{"--code-block-padding":`spacing.4`,"--code-block-radius":`radii.lg`,"--code-block-header-height":`sizes.10`},title:{textStyle:`xs`},code:{fontSize:`sm`}},lg:{root:{"--code-block-padding":`spacing.5`,"--code-block-radius":`radii.xl`,"--code-block-header-height":`sizes.12`},title:{textStyle:`sm`},code:{fontSize:`sm`}}}},defaultVariants:{size:`md`}}),$S=W({slots:Ku.keys(),className:`chakra-collapsible`,base:{content:{overflow:`hidden`,_open:{animationName:`expand-height, fade-in`,animationDuration:`moderate`,"&[data-has-collapsed-size]":{animationName:`expand-height`}},_closed:{animationName:`collapse-height, fade-out`,animationDuration:`moderate`,"&[data-has-collapsed-size]":{animationName:`collapse-height`}}}}}),eC=W({className:`colorPicker`,slots:RS.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`1.5`},label:{color:`fg`,fontWeight:`medium`,textStyle:`sm`,_disabled:{opacity:`0.5`}},valueText:{textAlign:`start`},control:{display:`flex`,alignItems:`center`,flexDirection:`row`,gap:`2`,position:`relative`},swatchTrigger:{display:`flex`,alignItems:`center`,justifyContent:`center`},trigger:{display:`flex`,alignItems:`center`,justifyContent:`center`,flexDirection:`row`,flexShrink:`0`,gap:`2`,textStyle:`sm`,minH:`var(--input-height)`,minW:`var(--input-height)`,px:`1`,rounded:`l2`,_disabled:{opacity:`0.5`},"--focus-color":`colors.colorPalette.focusRing`,"&:focus-visible":{borderColor:`var(--focus-color)`,outline:`1px solid var(--focus-color)`},"&[data-fit-content]":{"--input-height":`unset`,px:`0`,border:`0`}},content:{display:`flex`,flexDirection:`column`,bg:`bg.panel`,borderRadius:`l3`,boxShadow:`lg`,width:`64`,p:`4`,gap:`3`,"--color-picker-z-index":`zIndex.popover`,zIndex:`calc(var(--color-picker-z-index) + var(--layer-index, 0))`,_open:{animationStyle:`slide-fade-in`,animationDuration:`fast`},_closed:{animationStyle:`slide-fade-out`,animationDuration:`faster`}},area:{height:`180px`,borderRadius:`l2`,overflow:`hidden`},areaThumb:{borderRadius:`full`,height:`var(--thumb-size)`,width:`var(--thumb-size)`,borderWidth:`2px`,borderColor:`white`,shadow:`sm`,focusVisibleRing:`mixed`,focusRingColor:`white`},areaBackground:{height:`full`},channelSlider:{borderRadius:`l2`,flex:`1`},channelSliderTrack:{height:`var(--slider-height)`,borderRadius:`inherit`,boxShadow:`inset 0 0 0 1px rgba(0,0,0,0.1)`},channelText:{textStyle:`xs`,color:`fg.muted`,fontWeight:`medium`,textTransform:`capitalize`},swatchGroup:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`2`},swatch:{...Ux.base,borderRadius:`l1`},swatchIndicator:{color:`white`,rounded:`full`},channelSliderThumb:{borderRadius:`full`,height:`var(--thumb-size)`,width:`var(--thumb-size)`,borderWidth:`2px`,borderColor:`white`,shadow:`sm`,transform:`translate(-50%, -50%)`,focusVisibleRing:`outside`,focusRingOffset:`1px`},channelInput:{...qx.base,"&::-webkit-inner-spin-button, &::-webkit-outer-spin-button":{WebkitAppearance:`none`,margin:0}},formatSelect:{textStyle:`xs`,textTransform:`uppercase`,borderWidth:`1px`,minH:`6`,focusRing:`inside`,rounded:`l2`},transparencyGrid:{borderRadius:`l2`},view:{display:`flex`,flexDirection:`column`,gap:`2`}},variants:{size:{"2xs":{channelInput:qx.variants?.size?.[`2xs`],swatch:{"--swatch-size":`sizes.4.5`},trigger:{"--input-height":`sizes.7`},area:{"--thumb-size":`sizes.3`},channelSlider:{"--slider-height":`sizes.3`,"--thumb-size":`sizes.3`}},xs:{channelInput:qx.variants?.size?.xs,swatch:{"--swatch-size":`sizes.5`},trigger:{"--input-height":`sizes.8`},area:{"--thumb-size":`sizes.3.5`},channelSlider:{"--slider-height":`sizes.3.5`,"--thumb-size":`sizes.3.5`}},sm:{channelInput:qx.variants?.size?.sm,swatch:{"--swatch-size":`sizes.6`},trigger:{"--input-height":`sizes.9`},area:{"--thumb-size":`sizes.3.5`},channelSlider:{"--slider-height":`sizes.3.5`,"--thumb-size":`sizes.3.5`}},md:{channelInput:qx.variants?.size?.md,swatch:{"--swatch-size":`sizes.7`},trigger:{"--input-height":`sizes.10`},area:{"--thumb-size":`sizes.3.5`},channelSlider:{"--slider-height":`sizes.3.5`,"--thumb-size":`sizes.3.5`}},lg:{channelInput:qx.variants?.size?.lg,swatch:{"--swatch-size":`sizes.7`},trigger:{"--input-height":`sizes.11`},area:{"--thumb-size":`sizes.3.5`},channelSlider:{"--slider-height":`sizes.3.5`,"--thumb-size":`sizes.3.5`}},xl:{channelInput:qx.variants?.size?.xl,swatch:{"--swatch-size":`sizes.8`},trigger:{"--input-height":`sizes.12`},area:{"--thumb-size":`sizes.3.5`},channelSlider:{"--slider-height":`sizes.3.5`,"--thumb-size":`sizes.3.5`}},"2xl":{channelInput:qx.variants?.size?.[`2xl`],swatch:{"--swatch-size":`sizes.10`},trigger:{"--input-height":`sizes.16`},area:{"--thumb-size":`sizes.3.5`},channelSlider:{"--slider-height":`sizes.3.5`,"--thumb-size":`sizes.3.5`}}},variant:{outline:{channelInput:qx.variants?.variant?.outline,trigger:{borderWidth:`1px`}},subtle:{channelInput:qx.variants?.variant?.subtle,trigger:{borderWidth:`1px`,borderColor:`transparent`,bg:`bg.muted`}}}},defaultVariants:{size:`md`,variant:`outline`}}),tC=W({className:`chakra-combobox`,slots:DS.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`1.5`,width:`full`},label:{fontWeight:`medium`,userSelect:`none`,textStyle:`sm`,_disabled:{layerStyle:`disabled`}},control:{pos:`relative`,"--padding-factor":`1`,"--combobox-input-padding-end":`var(--combobox-input-padding-x)`,"&:has([data-part=trigger]), &:has([data-part=clear-trigger])":{"--combobox-input-padding-end":`calc(var(--combobox-input-height) * var(--padding-factor))`},"&:has([data-part=trigger]):has([data-part=clear-trigger]:not([hidden]))":{"--padding-factor":`1.5`}},input:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,background:`bg.panel`,width:`full`,minH:`var(--combobox-input-height)`,ps:`var(--combobox-input-padding-x)`,pe:`var(--combobox-input-padding-end)`,"--input-height":`var(--combobox-input-height)`,borderRadius:`l2`,outline:0,userSelect:`none`,textAlign:`start`,_placeholderShown:{color:`fg.muted`},_disabled:{layerStyle:`disabled`},"--focus-color":`colors.colorPalette.focusRing`,"--error-color":`colors.border.error`,_invalid:{focusRingColor:`var(--error-color)`,borderColor:`var(--error-color)`}},trigger:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,"--input-height":`var(--combobox-input-height)`},clearTrigger:{color:`fg.muted`,pointerEvents:`auto`,focusVisibleRing:`inside`,focusRingWidth:`2px`,rounded:`l1`},indicatorGroup:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`1`,pos:`absolute`,insetEnd:`0`,top:`0`,bottom:`0`,px:`var(--combobox-input-padding-x)`,_icon:{boxSize:`var(--combobox-indicator-size)`},"[data-disabled] &":{opacity:.5}},content:{background:`bg.panel`,display:`flex`,flexDirection:`column`,"--combobox-z-index":`zIndex.popover`,zIndex:`calc(var(--combobox-z-index) + var(--layer-index, 0))`,borderRadius:`l2`,outline:0,maxH:`96`,overflowY:`auto`,boxShadow:`md`,_open:{animationStyle:`slide-fade-in`,animationDuration:`fast`},_closed:{animationStyle:`slide-fade-out`,animationDuration:`0s`},"&[data-empty]:not(:has([data-scope=combobox][data-part=empty]))":{opacity:0}},item:{position:`relative`,userSelect:`none`,display:`flex`,alignItems:`center`,gap:`2`,py:`var(--combobox-item-padding-y)`,px:`var(--combobox-item-padding-x)`,cursor:`option`,justifyContent:`space-between`,flex:`1`,textAlign:`start`,borderRadius:`l1`,_highlighted:{bg:`bg.emphasized/60`},_disabled:{pointerEvents:`none`,opacity:`0.5`},_icon:{boxSize:`var(--combobox-indicator-size)`}},empty:{py:`var(--combobox-item-padding-y)`,px:`var(--combobox-item-padding-x)`},itemText:{flex:`1`},itemGroup:{pb:`var(--combobox-item-padding-y)`,_last:{pb:`0`}},itemGroupLabel:{fontWeight:`medium`,py:`var(--combobox-item-padding-y)`,px:`var(--combobox-item-padding-x)`}},variants:{variant:{outline:{input:{bg:`transparent`,borderWidth:`1px`,borderColor:`border`,focusVisibleRing:`inside`}},subtle:{input:{borderWidth:`1px`,borderColor:`transparent`,bg:`bg.muted`,focusVisibleRing:`inside`}},flushed:{input:{bg:`transparent`,borderBottomWidth:`1px`,borderBottomColor:`border`,borderRadius:`0`,px:`0`,_focusVisible:{borderColor:`var(--focus-color)`,boxShadow:`0px 1px 0px 0px var(--focus-color)`}},indicatorGroup:{px:`0`}}},size:{xs:{root:{"--combobox-input-height":`sizes.8`,"--combobox-input-padding-x":`spacing.2`,"--combobox-indicator-size":`sizes.3.5`},input:{textStyle:`xs`},content:{"--combobox-item-padding-x":`spacing.1.5`,"--combobox-item-padding-y":`spacing.1`,"--combobox-indicator-size":`sizes.3.5`,p:`1`,textStyle:`xs`},trigger:{textStyle:`xs`,gap:`1`}},sm:{root:{"--combobox-input-height":`sizes.9`,"--combobox-input-padding-x":`spacing.2.5`,"--combobox-indicator-size":`sizes.4`},input:{textStyle:`sm`},content:{"--combobox-item-padding-x":`spacing.2`,"--combobox-item-padding-y":`spacing.1.5`,"--combobox-indicator-size":`sizes.4`,p:`1`,textStyle:`sm`},trigger:{textStyle:`sm`,gap:`1`}},md:{root:{"--combobox-input-height":`sizes.10`,"--combobox-input-padding-x":`spacing.3`,"--combobox-indicator-size":`sizes.4`},input:{textStyle:`sm`},content:{"--combobox-item-padding-x":`spacing.2`,"--combobox-item-padding-y":`spacing.1.5`,"--combobox-indicator-size":`sizes.4`,p:`1`,textStyle:`sm`},itemIndicator:{display:`flex`,alignItems:`center`,justifyContent:`center`},trigger:{textStyle:`sm`,gap:`2`}},lg:{root:{"--combobox-input-height":`sizes.12`,"--combobox-input-padding-x":`spacing.4`,"--combobox-indicator-size":`sizes.5`},input:{textStyle:`md`},content:{"--combobox-item-padding-y":`spacing.2`,"--combobox-item-padding-x":`spacing.3`,"--combobox-indicator-size":`sizes.5`,p:`1.5`,textStyle:`md`},trigger:{textStyle:`md`,py:`3`,gap:`2`}}}},defaultVariants:{size:`md`,variant:`outline`}}),nC=W({slots:uS.keys(),className:`chakra-data-list`,base:{itemLabel:{display:`flex`,alignItems:`center`,gap:`1`},itemValue:{display:`flex`,minWidth:`0`,flex:`1`}},variants:{orientation:{horizontal:{root:{display:`flex`,flexDirection:`column`},item:{display:`inline-flex`,alignItems:`center`,gap:`4`},itemLabel:{minWidth:`120px`}},vertical:{root:{display:`flex`,flexDirection:`column`},item:{display:`flex`,flexDirection:`column`,gap:`1`}}},size:{sm:{root:{gap:`3`},item:{textStyle:`xs`}},md:{root:{gap:`4`},item:{textStyle:`sm`}},lg:{root:{gap:`5`},item:{textStyle:`md`}}},variant:{subtle:{itemLabel:{color:`fg.muted`}},bold:{itemLabel:{fontWeight:`medium`},itemValue:{color:`fg.muted`}}}},defaultVariants:{size:`md`,orientation:`vertical`,variant:`subtle`}}),rC=W({className:`chakra-date-input`,slots:Ip.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`1.5`,width:`full`,_disabled:{opacity:`0.5`}},label:{textStyle:`label`},control:{display:`flex`,alignItems:`center`,width:`full`},segmentGroup:{flex:`1`,outline:`0`,position:`relative`,appearance:`none`,textAlign:`start`,borderRadius:`l2`,height:`var(--input-height)`,minW:`var(--input-height)`,"--focus-color":`colors.colorPalette.focusRing`,"--error-color":`colors.border.error`,_invalid:{focusRingColor:`var(--error-color)`,borderColor:`var(--error-color)`},display:`flex`,alignItems:`center`,gap:`1`,cursor:`text`},segment:{borderRadius:`l1`,px:`0.5`,outline:`none`,_placeholderShown:{color:`fg.subtle`},"&[data-type=literal]":{px:`0`,color:`fg.subtle`}}},variants:{size:{"2xs":{segmentGroup:{textStyle:`xs`,px:`1.5`,"--input-height":`sizes.7`}},xs:{segmentGroup:{textStyle:`xs`,px:`1.5`,"--input-height":`sizes.8`}},sm:{segmentGroup:{textStyle:`sm`,px:`2`,"--input-height":`sizes.9`}},md:{segmentGroup:{textStyle:`sm`,px:`2.5`,"--input-height":`sizes.10`}},lg:{segmentGroup:{textStyle:`md`,px:`3.5`,"--input-height":`sizes.11`}},xl:{segmentGroup:{textStyle:`md`,px:`4`,"--input-height":`sizes.12`}},"2xl":{segmentGroup:{textStyle:`lg`,px:`4.5`,"--input-height":`sizes.16`}}},variant:{outline:{segmentGroup:{bg:`transparent`,borderWidth:`1px`,borderColor:`border`,focusRing:`inside`,focusRingColor:`var(--focus-color)`},segment:{_focus:{bg:`colorPalette.emphasized`,color:`fg`}}},subtle:{segmentGroup:{borderWidth:`1px`,borderColor:`transparent`,bg:`bg.muted`,focusRing:`inside`,focusRingColor:`var(--focus-color)`},segment:{_focus:{bg:`colorPalette.subtle`,color:`colorPalette.fg`}}},flushed:{segmentGroup:{bg:`transparent`,borderBottomWidth:`1px`,borderBottomColor:`border`,borderRadius:`0`,px:`0`,_focus:{borderColor:`var(--focus-color)`,boxShadow:`0px 1px 0px 0px var(--focus-color)`,_invalid:{borderColor:`var(--error-color)`,boxShadow:`0px 1px 0px 0px var(--error-color)`}}},segment:{_focus:{bg:`colorPalette.subtle`,color:`colorPalette.fg`}}}}},defaultVariants:{size:`md`,variant:`outline`}}),iC=Zv({display:`inline-flex`,alignItems:`center`,justifyContent:`center`,boxSize:`var(--datepicker-nav-trigger-size)`,borderRadius:`l2`,color:`fg`,focusVisibleRing:`inside`,focusRingWidth:`2px`,_hover:{bg:`colorPalette.subtle`},_focusVisible:{boxShadow:`0 0 0 2px var(--colors-color-palette-focus-ring)`},_disabled:{opacity:.5},_icon:{boxSize:`4`}}),aC=Zv({height:`var(--datepicker-select-height)`,ps:`2`,pe:`8`,textStyle:`sm`,borderWidth:`1px`,borderRadius:`l2`,outline:`none`,focusVisibleRing:`inside`,appearance:`none`,fieldSizing:`content`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")`,backgroundRepeat:`no-repeat`,backgroundPosition:`right 0.375rem center`,backgroundSize:`1.25em`}),oC=W({className:`date-picker`,slots:dS.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`1.5`,width:`full`,"--datepicker-indicators-offset":`sizes.3`,_disabled:{opacity:.5}},label:{textStyle:`sm`,fontWeight:`medium`},indicatorGroup:{position:`absolute`,insetEnd:`var(--datepicker-indicators-offset)`,top:`50%`,transform:`translateY(-50%)`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`1`},control:{display:`flex`,alignItems:`center`,gap:`2`,width:`full`,position:`relative`},input:{flex:`1`,minWidth:`0`,height:`var(--datepicker-input-height)`,"--input-height":`var(--datepicker-input-height)`,px:`var(--datepicker-input-px)`,textStyle:`sm`,bg:`transparent`,borderRadius:`l2`,outline:`0`,appearance:`none`,color:`fg`,"--focus-color":`colors.colorPalette.focusRing`,"--error-color":`colors.border.error`,_invalid:{focusRingColor:`var(--error-color)`,borderColor:`var(--error-color)`}},trigger:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`6`,height:`6`,borderRadius:`l1`,color:`fg.muted`,outline:`none`,_hover:{color:`fg`},focusVisibleRing:`inside`,focusRingWidth:`2px`,_icon:{boxSize:`4`}},content:{display:`flex`,flexDirection:`column`,gap:`3`,p:`3`,minW:`18rem`,bg:`bg.panel`,borderRadius:`l2`,boxShadow:`lg`,color:`fg`,"--date-picker-z-index":`zIndex.popover`,zIndex:`calc(var(--date-picker-z-index) + var(--layer-index, 0))`,outline:`none`,_open:{animationStyle:`scale-fade-in`,animationDuration:`fast`},_closed:{animationStyle:`scale-fade-out`,animationDuration:`faster`}},view:{display:`flex`,flexDirection:`column`,gap:`3`},viewControl:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`2`,height:`var(--datepicker-nav-trigger-size)`},viewTrigger:{display:`inline-flex`,flex:`1`,alignItems:`center`,justifyContent:`center`,gap:`1`,py:`1.5`,px:`2`,textStyle:`sm`,fontWeight:`semibold`,borderRadius:`l2`,focusVisibleRing:`inside`,focusRingWidth:`2px`,_hover:{bg:`colorPalette.subtle`}},prevTrigger:iC,nextTrigger:iC,rangeText:{textStyle:`sm`,fontWeight:`semibold`},table:{borderCollapse:`separate`,borderSpacing:`0`},tableHeader:{width:`var(--table-cell-size)`,py:`2`,textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,textAlign:`center`,textTransform:`uppercase`,"&[data-type='week-number']":{color:`fg.subtle`}},tableCell:{py:`0.5`,"&[data-type='week-number']":{color:`fg.subtle`}},tableCellTrigger:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,minWidth:`var(--table-cell-size)`,minHeight:`var(--table-cell-size)`,textStyle:`sm`,borderRadius:`l2`,focusVisibleRing:`inside`,focusRingWidth:`2px`,focusRingOffset:`0px`,cursor:`default`,position:`relative`,_hover:{bg:`colorPalette.subtle`},"[data-view=month] &, [data-view=year] &":{width:`calc(var(--table-cell-size) * 1.75)`},_today:{color:`colorPalette.fg`,fontWeight:`semibold`,textDecoration:`underline`,textUnderlineOffset:`3px`,textDecorationThickness:`2px`},"&[data-selected]":{bg:`colorPalette.solid`,color:`colorPalette.contrast`,_hover:{bg:`colorPalette.solid`}},"&[data-in-range]":{bg:`colorPalette.subtle`,color:`colorPalette.fg`,borderRadius:`0`,_hover:{bg:`colorPalette.subtle`}},"&[data-in-range][data-selected]":{bg:`colorPalette.solid`,color:`colorPalette.contrast`,borderRadius:`0`,_hover:{bg:`colorPalette.solid`},"&[data-range-start][data-range-end]":{borderRadius:`l2`},"&[data-range-start]:not([data-range-end])":{borderStartRadius:`l2`,borderEndRadius:`0`},"&[data-range-end]:not([data-range-start])":{borderEndRadius:`l2`,borderStartRadius:`0`}},_disabled:{opacity:.4}},monthSelect:aC,yearSelect:aC,clearTrigger:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`6`,height:`6`,flexShrink:0,textStyle:`xs`,borderRadius:`l2`,color:`fg.muted`,_hover:{color:`fg`},focusVisibleRing:`inside`,_icon:{width:`4`,height:`4`}}},variants:{size:{xs:{root:{"--datepicker-input-height":`sizes.8`,"--datepicker-input-px":`sizes.2`,"--datepicker-indicators-offset":`sizes.2`},view:{"--table-cell-size":`sizes.8`,"--datepicker-nav-trigger-size":`sizes.7`,"--datepicker-select-height":`sizes.8`}},sm:{root:{"--datepicker-input-height":`sizes.9`,"--datepicker-input-px":`sizes.2.5`,"--datepicker-indicators-offset":`sizes.2.5`},view:{"--table-cell-size":`sizes.9`,"--datepicker-nav-trigger-size":`sizes.8`,"--datepicker-select-height":`sizes.9`}},md:{root:{"--datepicker-input-height":`sizes.10`,"--datepicker-input-px":`sizes.3`},view:{"--table-cell-size":`sizes.10`,"--datepicker-nav-trigger-size":`sizes.8`,"--datepicker-select-height":`sizes.10`}},lg:{root:{"--datepicker-input-height":`sizes.11`,"--datepicker-input-px":`sizes.4`},view:{"--table-cell-size":`sizes.10`,"--datepicker-nav-trigger-size":`sizes.9`,"--datepicker-select-height":`sizes.10`}},xl:{root:{"--datepicker-input-height":`sizes.12`,"--datepicker-input-px":`sizes.4.5`},view:{"--table-cell-size":`sizes.10`,"--datepicker-nav-trigger-size":`sizes.9`,"--datepicker-select-height":`sizes.10`}}},hideOutsideDays:{true:{tableCellTrigger:{"&[data-outside-range]":{visibility:`hidden`}}}},variant:{outline:{input:{bg:`transparent`,borderWidth:`1px`,borderColor:`border`,focusVisibleRing:`inside`,focusRingColor:`var(--focus-color)`}},subtle:{input:{borderWidth:`1px`,borderColor:`transparent`,bg:`bg.muted`,focusVisibleRing:`inside`,focusRingColor:`var(--focus-color)`}},flushed:{input:{bg:`transparent`,borderBottomWidth:`1px`,borderBottomColor:`border`,borderRadius:`0`,px:`0`,_focusVisible:{borderColor:`var(--focus-color)`,boxShadow:`0px 1px 0px 0px var(--focus-color)`,_invalid:{borderColor:`var(--error-color)`,boxShadow:`0px 1px 0px 0px var(--error-color)`}}},indicatorGroup:{insetEnd:`0`}}}},defaultVariants:{size:`md`,variant:`outline`}}),sC=W({slots:fS.keys(),className:`chakra-dialog`,base:{backdrop:{bg:`blackAlpha.500`,pos:`fixed`,left:0,top:0,w:`100dvw`,h:`100dvh`,"--dialog-z-index":`zIndex.popover`,zIndex:`calc(var(--dialog-z-index) + var(--layer-index, 0) - 1)`,_open:{animationName:`fade-in`,animationDuration:`slow`},_closed:{animationName:`fade-out`,animationDuration:`moderate`}},positioner:{display:`flex`,width:`100dvw`,height:`100dvh`,position:`fixed`,left:0,top:0,"--dialog-z-index":`zIndex.popover`,zIndex:`calc(var(--dialog-z-index) + var(--layer-index, 0))`,justifyContent:`center`,overscrollBehaviorY:`none`},content:{display:`flex`,flexDirection:`column`,position:`relative`,width:`100%`,outline:0,borderRadius:`l3`,textStyle:`sm`,my:`var(--dialog-margin, var(--dialog-base-margin))`,"--dialog-z-index":`zIndex.popover`,zIndex:`calc(var(--dialog-z-index) + var(--layer-index, 0))`,bg:`bg.panel`,boxShadow:`lg`,_open:{animationDuration:`moderate`},_closed:{animationDuration:`faster`}},header:{display:`flex`,gap:`2`,flex:0,px:`6`,pt:`6`,pb:`4`},body:{flex:`1`,px:`6`,pt:`2`,pb:`6`},footer:{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:`3`,px:`6`,pt:`2`,pb:`4`},title:{textStyle:`lg`,fontWeight:`semibold`},description:{color:`fg.muted`},closeTrigger:{pos:`absolute`,top:`2`,insetEnd:`2`}},variants:{placement:{center:{positioner:{alignItems:`center`},content:{"--dialog-base-margin":`auto`,mx:`auto`}},top:{positioner:{alignItems:`flex-start`},content:{"--dialog-base-margin":`spacing.16`,mx:`auto`}},bottom:{positioner:{alignItems:`flex-end`},content:{"--dialog-base-margin":`spacing.16`,mx:`auto`}}},scrollBehavior:{inside:{positioner:{overflow:`hidden`},content:{maxH:`calc(100% - 7.5rem)`},body:{overflow:`auto`}},outside:{positioner:{overflow:`auto`,pointerEvents:`auto`}}},size:{xs:{content:{maxW:`sm`}},sm:{content:{maxW:`md`}},md:{content:{maxW:`lg`}},lg:{content:{maxW:`2xl`}},xl:{content:{maxW:`4xl`}},cover:{positioner:{padding:`10`},content:{width:`100%`,height:`100%`,"--dialog-margin":`0`}},full:{content:{maxW:`100dvw`,minH:`100dvh`,"--dialog-margin":`0`,borderRadius:`0`}}},motionPreset:{scale:{content:{_open:{animationName:`scale-in, fade-in`},_closed:{animationName:`scale-out, fade-out`}}},"slide-in-bottom":{content:{_open:{animationName:`slide-from-bottom, fade-in`},_closed:{animationName:`slide-to-bottom, fade-out`}}},"slide-in-top":{content:{_open:{animationName:`slide-from-top, fade-in`},_closed:{animationName:`slide-to-top, fade-out`}}},"slide-in-left":{content:{_open:{animationName:`slide-from-left, fade-in`},_closed:{animationName:`slide-to-left, fade-out`}}},"slide-in-right":{content:{_open:{animationName:`slide-from-right, fade-in`},_closed:{animationName:`slide-to-right, fade-out`}}},none:{}}},defaultVariants:{size:`md`,scrollBehavior:`outside`,placement:`top`,motionPreset:`scale`}}),cC=W({slots:pS.keys(),className:`chakra-drawer`,base:{backdrop:{bg:`blackAlpha.500`,pos:`fixed`,insetInlineStart:0,top:0,w:`100vw`,h:`100dvh`,"--drawer-z-index":`zIndex.popover`,zIndex:`calc(var(--drawer-z-index) + var(--layer-index, 0) - 1)`,_open:{animationName:`fade-in`,animationDuration:`slow`},_closed:{animationName:`fade-out`,animationDuration:`moderate`}},positioner:{display:`flex`,width:`100vw`,height:`100dvh`,position:`fixed`,insetInlineStart:0,top:0,"--drawer-z-index":`zIndex.popover`,zIndex:`calc(var(--drawer-z-index) + var(--layer-index, 0))`,overscrollBehaviorY:`none`},content:{display:`flex`,flexDirection:`column`,position:`relative`,width:`100%`,outline:0,"--drawer-z-index":`zIndex.popover`,zIndex:`calc(var(--drawer-z-index) + var(--layer-index, 0))`,textStyle:`sm`,maxH:`100dvh`,color:`inherit`,bg:`bg.panel`,boxShadow:`lg`,_open:{animationDuration:`slowest`,animationTimingFunction:`ease-in-smooth`},_closed:{animationDuration:`slower`,animationTimingFunction:`ease-in-smooth`}},header:{display:`flex`,alignItems:`center`,gap:`2`,flex:0,px:`6`,pt:`6`,pb:`4`},body:{px:`6`,py:`2`,flex:`1`,overflow:`auto`},footer:{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:`3`,px:`6`,pt:`2`,pb:`4`},title:{flex:`1`,textStyle:`lg`,fontWeight:`semibold`},description:{color:`fg.muted`},closeTrigger:{pos:`absolute`,top:`3`,insetEnd:`2`}},variants:{size:{xs:{content:{maxW:`xs`}},sm:{content:{maxW:`md`}},md:{content:{maxW:`lg`}},lg:{content:{maxW:`2xl`}},xl:{content:{maxW:`4xl`}},full:{content:{maxW:`100vw`,h:`100dvh`}}},placement:{start:{positioner:{justifyContent:`flex-start`,alignItems:`stretch`},content:{_open:{animationName:{base:`slide-from-left-full, fade-in`,_rtl:`slide-from-right-full, fade-in`}},_closed:{animationName:{base:`slide-to-left-full, fade-out`,_rtl:`slide-to-right-full, fade-out`}}}},end:{positioner:{justifyContent:`flex-end`,alignItems:`stretch`},content:{_open:{animationName:{base:`slide-from-right-full, fade-in`,_rtl:`slide-from-left-full, fade-in`}},_closed:{animationName:{base:`slide-to-right-full, fade-out`,_rtl:`slide-to-left-full, fade-out`}}}},top:{positioner:{justifyContent:`stretch`,alignItems:`flex-start`},content:{maxW:`100%`,_open:{animationName:`slide-from-top-full, fade-in`},_closed:{animationName:`slide-to-top-full, fade-out`}}},bottom:{positioner:{justifyContent:`stretch`,alignItems:`flex-end`},content:{maxW:`100%`,_open:{animationName:`slide-from-bottom-full, fade-in`},_closed:{animationName:`slide-to-bottom-full, fade-out`}}}},contained:{true:{positioner:{padding:`4`},content:{borderRadius:`l3`}}}},defaultVariants:{size:`xs`,placement:`end`}}),lC=Zv({fontSize:`inherit`,fontWeight:`inherit`,textAlign:`inherit`,bg:`transparent`,borderRadius:`l2`}),uC=W({slots:mS.keys(),className:`chakra-editable`,base:{root:{display:`inline-flex`,alignItems:`center`,position:`relative`,gap:`1.5`,width:`full`},preview:{...lC,py:`1`,px:`1`,display:`inline-flex`,alignItems:`center`,transitionProperty:`common`,transitionDuration:`moderate`,cursor:`text`,_hover:{bg:`bg.muted`},_disabled:{userSelect:`none`}},input:{...lC,outline:`0`,py:`1`,px:`1`,transitionProperty:`common`,transitionDuration:`normal`,width:`full`,focusVisibleRing:`inside`,focusRingWidth:`2px`,_placeholder:{opacity:.6}},control:{display:`inline-flex`,alignItems:`center`,gap:`1.5`}},variants:{size:{sm:{root:{textStyle:`sm`},preview:{minH:`8`},input:{minH:`8`}},md:{root:{textStyle:`sm`},preview:{minH:`9`},input:{minH:`9`}},lg:{root:{textStyle:`md`},preview:{minH:`10`},input:{minH:`10`}}}},defaultVariants:{size:`md`}}),dC=W({slots:hS.keys(),className:`chakra-empty-state`,base:{root:{width:`full`},content:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`},indicator:{display:`flex`,alignItems:`center`,justifyContent:`center`,color:`fg.subtle`,_icon:{boxSize:`1em`}},title:{fontWeight:`semibold`},description:{textStyle:`sm`,color:`fg.muted`}},variants:{size:{sm:{root:{px:`4`,py:`6`},title:{textStyle:`md`},content:{gap:`4`},indicator:{textStyle:`2xl`}},md:{root:{px:`8`,py:`12`},title:{textStyle:`lg`},content:{gap:`6`},indicator:{textStyle:`4xl`}},lg:{root:{px:`12`,py:`16`},title:{textStyle:`xl`},content:{gap:`8`},indicator:{textStyle:`6xl`}}}},defaultVariants:{size:`md`}}),fC=W({className:`chakra-field`,slots:gS.keys(),base:{requiredIndicator:{color:`fg.error`,lineHeight:`1`},root:{display:`flex`,width:`100%`,position:`relative`,gap:`1.5`},label:{display:`flex`,alignItems:`center`,textAlign:`start`,textStyle:`sm`,fontWeight:`medium`,gap:`1`,userSelect:`none`,_disabled:{opacity:`0.5`}},errorText:{display:`inline-flex`,alignItems:`center`,fontWeight:`medium`,gap:`1`,color:`fg.error`,textStyle:`xs`},helperText:{color:`fg.muted`,textStyle:`xs`}},variants:{orientation:{vertical:{root:{flexDirection:`column`,alignItems:`flex-start`}},horizontal:{root:{flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`},label:{flex:`0 0 var(--field-label-width, 80px)`}}}},defaultVariants:{orientation:`vertical`}}),pC=W({className:`fieldset`,slots:_S.keys(),base:{root:{display:`flex`,flexDirection:`column`,width:`full`},content:{display:`flex`,flexDirection:`column`,width:`full`},legend:{color:`fg`,fontWeight:`medium`,_disabled:{opacity:`0.5`}},helperText:{color:`fg.muted`,textStyle:`sm`},errorText:{display:`inline-flex`,alignItems:`center`,color:`fg.error`,gap:`2`,fontWeight:`medium`,textStyle:`sm`}},variants:{size:{sm:{root:{spaceY:`2`},content:{gap:`1.5`},legend:{textStyle:`sm`}},md:{root:{spaceY:`4`},content:{gap:`4`},legend:{textStyle:`sm`}},lg:{root:{spaceY:`6`},content:{gap:`4`},legend:{textStyle:`md`}}}},defaultVariants:{size:`md`}}),mC=W({className:`chakra-file-upload`,slots:vS.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`4`,width:`100%`,alignItems:`flex-start`},label:{fontWeight:`medium`,textStyle:`sm`},dropzone:{background:`bg`,borderRadius:`l3`,borderWidth:`2px`,borderStyle:`dashed`,display:`flex`,alignItems:`center`,flexDirection:`column`,gap:`4`,justifyContent:`center`,minHeight:`2xs`,px:`3`,py:`2`,transition:`backgrounds`,focusVisibleRing:`outside`,_hover:{bg:`bg.subtle`},_dragging:{bg:`colorPalette.subtle`,borderStyle:`solid`,borderColor:`colorPalette.solid`}},dropzoneContent:{display:`flex`,flexDirection:`column`,alignItems:`center`,textAlign:`center`,gap:`1`,textStyle:`sm`},item:{pos:`relative`,textStyle:`sm`,animationName:`fade-in`,animationDuration:`moderate`,background:`bg`,borderRadius:`l2`,borderWidth:`1px`,width:`100%`,display:`flex`,alignItems:`center`,gap:`3`,p:`4`},itemGroup:{width:`100%`,display:`flex`,flexDirection:`column`,gap:`3`,_empty:{display:`none`}},itemName:{color:`fg`,fontWeight:`medium`,lineClamp:`1`},itemContent:{display:`flex`,flexDirection:`column`,gap:`0.5`,flex:`1`},itemSizeText:{color:`fg.muted`,textStyle:`xs`},itemDeleteTrigger:{display:`flex`,alignItems:`center`,justifyContent:`center`,alignSelf:`flex-start`,boxSize:`5`,p:`2px`,color:`fg.muted`,cursor:`button`},itemPreview:{color:`fg.muted`,_icon:{boxSize:`4.5`}}},defaultVariants:{}}),hC=W({slots:um.keys(),className:`chakra-floating-panel`,base:{positioner:{"--floating-panel-z-index":`zIndex.popover`,zIndex:`calc(var(--floating-panel-z-index) + var(--layer-index, 0))`,"&:has([data-topmost])":{"--layer-index":`100`},"&:has([data-behind])":{"--layer-index":`-100`}},content:{display:`flex`,flexDirection:`column`,bg:`bg.panel`,borderRadius:`l2`,boxShadow:`lg`,overflow:`hidden`,outline:0,position:`relative`,_open:{animationName:`scale-in, fade-in`,animationDuration:`moderate`}},dragTrigger:{flex:`1`,display:`flex`,alignItems:`center`,gap:`2`,minW:`0`},header:{display:`flex`,alignItems:`center`,gap:`2`,px:`3`,py:`2`,borderBottomWidth:`1px`,bg:`bg.subtle`,flex:`none`},title:{fontWeight:`semibold`,textStyle:`sm`,flex:`1`,truncate:!0},body:{flex:`1`,overflow:`auto`,p:`3`,textStyle:`sm`},resizeTrigger:{zIndex:`1`,"--size":`sizes.2.5`,'&[data-axis="n"], &[data-axis="s"]':{h:`var(--size)`},'&[data-axis="e"], &[data-axis="w"]':{w:`var(--size)`},'&[data-axis]:is([data-axis="ne"], [data-axis="nw"], [data-axis="se"], [data-axis="sw"])':{w:`var(--size)`,h:`var(--size)`}}}}),gC=W({className:`chakra-hover-card`,slots:dm.keys(),base:{content:{position:`relative`,display:`flex`,flexDirection:`column`,textStyle:`sm`,"--hovercard-bg":`colors.bg.panel`,bg:`var(--hovercard-bg)`,boxShadow:`lg`,maxWidth:`80`,borderRadius:`l3`,"--hover-card-z-index":`zIndex.popover`,zIndex:`calc(var(--hover-card-z-index) + var(--layer-index, 0))`,transformOrigin:`var(--transform-origin)`,outline:`0`,_open:{animationStyle:`slide-fade-in`,animationDuration:`fast`},_closed:{animationStyle:`slide-fade-out`,animationDuration:`faster`}},arrow:{"--arrow-size":`sizes.3`,"--arrow-background":`var(--hovercard-bg)`},arrowTip:{borderTopWidth:`0.5px`,borderLeftWidth:`0.5px`}},variants:{size:{xs:{content:{padding:`3`}},sm:{content:{padding:`4`}},md:{content:{padding:`5`}},lg:{content:{padding:`6`}}}},defaultVariants:{size:`md`}}),_C=W({className:`chakra-list`,slots:yS.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`var(--list-gap)`,"& :where(ul, ol)":{marginTop:`var(--list-gap)`}},item:{whiteSpace:`normal`,display:`list-item`},indicator:{marginEnd:`2`,minHeight:`1lh`,flexShrink:0,display:`inline-block`,verticalAlign:`middle`}},variants:{variant:{marker:{root:{listStyle:`revert`},item:{_marker:{color:`fg.subtle`}}},plain:{item:{alignItems:`flex-start`,display:`inline-flex`}}},align:{center:{item:{alignItems:`center`}},start:{item:{alignItems:`flex-start`}},end:{item:{alignItems:`flex-end`}}}},defaultVariants:{variant:`marker`}}),vC=W({className:`chakra-listbox`,slots:VS.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`1.5`,width:`full`},content:{display:`flex`,maxH:`96`,p:`1`,gap:`1`,textStyle:`sm`,outline:`none`,scrollPadding:`1`,_horizontal:{flexDirection:`row`,overflowX:`auto`},_vertical:{flexDirection:`column`,overflowY:`auto`},"--listbox-item-padding-x":`spacing.2`,"--listbox-item-padding-y":`spacing.1.5`},item:{position:`relative`,userSelect:`none`,display:`flex`,alignItems:`center`,gap:`2`,cursor:`pointer`,justifyContent:`space-between`,flex:`1`,textAlign:`start`,borderRadius:`l1`,py:`var(--listbox-item-padding-y)`,px:`var(--listbox-item-padding-x)`,_highlighted:{outline:`2px solid`,outlineColor:`border.emphasized`},_disabled:{pointerEvents:`none`,opacity:`0.5`}},empty:{py:`var(--listbox-item-padding-y)`,px:`var(--listbox-item-padding-x)`},itemText:{flex:`1`},itemGroup:{mt:`1.5`,_first:{mt:`0`}},itemGroupLabel:{py:`1.5`,px:`2`,fontWeight:`medium`},label:{fontWeight:`medium`,userSelect:`none`,textStyle:`sm`,_disabled:{layerStyle:`disabled`}},valueText:{lineClamp:`1`,maxW:`80%`},itemIndicator:{display:`flex`,alignItems:`center`,justifyContent:`center`,_icon:{boxSize:`4`}}},variants:{variant:{subtle:{content:{bg:`bg.panel`,borderWidth:`1px`,borderRadius:`l2`},item:{_hover:{bg:`bg.emphasized/60`},_selected:{bg:`bg.muted`}}},solid:{content:{bg:`bg.panel`,borderWidth:`1px`,borderRadius:`l2`},item:{_selected:{bg:`colorPalette.solid`,color:`colorPalette.contrast`}}},plain:{}}},defaultVariants:{variant:`subtle`}}),yC=W({className:`chakra-marquee`,slots:mm.keys(),base:{root:{position:`relative`,width:`100%`,"--marquee-edge-color":`colors.bg`,"--marquee-edge-size":`20%`,"&[data-paused]":{animationPlayState:`paused !important`,"& *":{animationPlayState:`paused !important`}}},viewport:{overflow:`hidden`,display:`flex`,width:`100%`,height:`100%`},content:{display:`flex`,minWidth:`max-content`,animationTimingFunction:`linear`,animationFillMode:`forwards`,animationDuration:`var(--marquee-duration)`,animationDelay:`var(--marquee-delay)`,animationIterationCount:`var(--marquee-loop-count)`,_motionReduce:{animation:`none !important`},"&[data-side='start'], &[data-side='end']":{animationName:`marqueeX`},"&[data-side='top'], &[data-side='bottom']":{animationName:`marqueeY`},"&[data-reverse]":{animationDirection:`reverse`},"&[data-orientation='horizontal']":{flexDirection:`row`},"&[data-orientation='vertical']":{flexDirection:`column`}},edge:{position:`absolute`,zIndex:`1`,pointerEvents:`none`,"&[data-side='start']":{width:`var(--marquee-edge-size)`,insetY:`0`,insetInlineStart:`0`,background:`linear-gradient(to right, var(--marquee-edge-color, white), transparent)`,_rtl:{background:`linear-gradient(to left, var(--marquee-edge-color, white), transparent)`}},"&[data-side='end']":{width:`var(--marquee-edge-size)`,insetY:`0`,insetInlineEnd:`0`,background:`linear-gradient(to left, var(--marquee-edge-color, white), transparent)`,_rtl:{background:`linear-gradient(to right, var(--marquee-edge-color, white), transparent)`}},"&[data-side='top']":{height:`var(--marquee-edge-size)`,insetX:`0`,top:`0`,background:`linear-gradient(to bottom, var(--marquee-edge-color, white), transparent)`},"&[data-side='bottom']":{height:`var(--marquee-edge-size)`,insetX:`0`,bottom:`0`,background:`linear-gradient(to top, var(--marquee-edge-color, white), transparent)`}}}}),bC=W({className:`chakra-menu`,slots:bS.keys(),base:{content:{outline:0,"--menu-bg":`colors.bg.panel`,bg:`var(--menu-bg)`,boxShadow:`lg`,color:`fg`,maxHeight:`var(--available-height)`,"--menu-z-index":`zIndex.popover`,zIndex:`calc(var(--menu-z-index) + var(--layer-index, 0))`,borderRadius:`l2`,overflow:`hidden`,overflowY:`auto`,_open:{animationStyle:`slide-fade-in`,animationDuration:`fast`},_closed:{animationStyle:`slide-fade-out`,animationDuration:`faster`}},item:{textDecoration:`none`,color:`fg`,userSelect:`none`,borderRadius:`l1`,width:`100%`,display:`flex`,cursor:`menuitem`,alignItems:`center`,textAlign:`start`,position:`relative`,flex:`0 0 auto`,outline:0,_disabled:{layerStyle:`disabled`},"&[data-type]":{ps:`8`}},itemText:{flex:`1`},itemIndicator:{position:`absolute`,insetStart:`2`,transform:`translateY(-50%)`,top:`50%`},itemGroupLabel:{px:`2`,py:`1.5`,fontWeight:`semibold`,textStyle:`sm`},indicator:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`},itemCommand:{opacity:`0.6`,textStyle:`xs`,ms:`auto`,ps:`4`,letterSpacing:`widest`,fontFamily:`inherit`},separator:{height:`1px`,bg:`bg.muted`,my:`1`,mx:`-1`},arrow:{"--arrow-size":`sizes.3`,"--arrow-background":`var(--menu-bg)`},arrowTip:{borderTopWidth:`1px`,borderLeftWidth:`1px`}},variants:{variant:{subtle:{item:{_highlighted:{bg:`bg.emphasized/60`}}},solid:{item:{_highlighted:{bg:`colorPalette.solid`,color:`colorPalette.contrast`}}}},size:{sm:{content:{minW:`8rem`,padding:`1`,scrollPadding:`1`},item:{gap:`1`,textStyle:`xs`,py:`1`,px:`1.5`}},md:{content:{minW:`8rem`,padding:`1.5`,scrollPadding:`1.5`},item:{gap:`2`,textStyle:`sm`,py:`1.5`,px:`2`}}}},defaultVariants:{size:`md`,variant:`subtle`}}),xC=W({className:`chakra-select`,slots:ES.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`1.5`,width:`full`},trigger:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,width:`full`,minH:`var(--select-trigger-height)`,"--input-height":`var(--select-trigger-height)`,px:`var(--select-trigger-padding-x)`,borderRadius:`l2`,userSelect:`none`,textAlign:`start`,focusVisibleRing:`inside`,_placeholderShown:{color:`fg.muted/80`},_disabled:{layerStyle:`disabled`},_invalid:{borderColor:`border.error`}},indicatorGroup:{display:`flex`,alignItems:`center`,gap:`1`,pos:`absolute`,insetEnd:`0`,top:`0`,bottom:`0`,px:`var(--select-trigger-padding-x)`,pointerEvents:`none`},indicator:{display:`flex`,alignItems:`center`,justifyContent:`center`,color:{base:`fg.muted`,_disabled:`fg.subtle`,_invalid:`fg.error`}},content:{background:`bg.panel`,display:`flex`,flexDirection:`column`,"--select-z-index":`zIndex.popover`,zIndex:`calc(var(--select-z-index) + var(--layer-index, 0))`,borderRadius:`l2`,outline:0,maxH:`96`,overflowY:`auto`,boxShadow:`md`,_open:{animationStyle:`slide-fade-in`,animationDuration:`fast`},_closed:{animationStyle:`slide-fade-out`,animationDuration:`fastest`}},item:{position:`relative`,userSelect:`none`,display:`flex`,alignItems:`center`,gap:`2`,cursor:`option`,justifyContent:`space-between`,flex:`1`,textAlign:`start`,borderRadius:`l1`,_highlighted:{bg:`bg.emphasized/60`},_disabled:{pointerEvents:`none`,opacity:`0.5`},_icon:{width:`4`,height:`4`}},control:{pos:`relative`},itemText:{flex:`1`},itemGroup:{_first:{mt:`0`}},itemGroupLabel:{py:`1`,fontWeight:`medium`},label:{fontWeight:`medium`,userSelect:`none`,textStyle:`sm`,_disabled:{layerStyle:`disabled`}},valueText:{lineClamp:`1`,maxW:`80%`},clearTrigger:{color:`fg.muted`,pointerEvents:`auto`,focusVisibleRing:`inside`,focusRingWidth:`2px`,rounded:`l1`}},variants:{variant:{outline:{trigger:{bg:`transparent`,borderWidth:`1px`,borderColor:`border`,_expanded:{borderColor:`border.emphasized`}}},subtle:{trigger:{borderWidth:`1px`,borderColor:`transparent`,bg:`bg.muted`}},ghost:{trigger:{bg:`transparent`,_expanded:{bg:`bg.muted`}}}},size:{xs:{root:{"--select-trigger-height":`sizes.8`,"--select-trigger-padding-x":`spacing.2`},content:{p:`1`,gap:`1`,textStyle:`xs`},trigger:{textStyle:`xs`,gap:`1`},item:{py:`1`,px:`2`},itemGroupLabel:{py:`1`,px:`2`},indicator:{_icon:{width:`3.5`,height:`3.5`}}},sm:{root:{"--select-trigger-height":`sizes.9`,"--select-trigger-padding-x":`spacing.2.5`},content:{p:`1`,textStyle:`sm`},trigger:{textStyle:`sm`,gap:`1`},indicator:{_icon:{width:`4`,height:`4`}},item:{py:`1`,px:`1.5`},itemGroup:{mt:`1`},itemGroupLabel:{py:`1`,px:`1.5`}},md:{root:{"--select-trigger-height":`sizes.10`,"--select-trigger-padding-x":`spacing.3`},content:{p:`1`,textStyle:`sm`},itemGroup:{mt:`1.5`},item:{py:`1.5`,px:`2`},itemIndicator:{display:`flex`,alignItems:`center`,justifyContent:`center`},itemGroupLabel:{py:`1.5`,px:`2`},trigger:{textStyle:`sm`,gap:`2`},indicator:{_icon:{width:`4`,height:`4`}}},lg:{root:{"--select-trigger-height":`sizes.12`,"--select-trigger-padding-x":`spacing.4`},content:{p:`1.5`,textStyle:`md`},itemGroup:{mt:`2`},item:{py:`2`,px:`3`},itemGroupLabel:{py:`2`,px:`3`},trigger:{textStyle:`md`,py:`3`,gap:`2`},indicator:{_icon:{width:`5`,height:`5`}}}}},defaultVariants:{size:`md`,variant:`outline`}}),SC=W({className:`chakra-native-select`,slots:xS.keys(),base:{root:{height:`fit-content`,display:`flex`,width:`100%`,position:`relative`},field:{width:`100%`,minWidth:`0`,outline:`0`,appearance:`none`,borderRadius:`l2`,"--error-color":`colors.border.error`,"--input-height":`var(--select-field-height)`,height:`var(--select-field-height)`,_disabled:{layerStyle:`disabled`},_invalid:{focusRingColor:`var(--error-color)`,borderColor:`var(--error-color)`},focusVisibleRing:`inside`,lineHeight:`normal`,"& > option, & > optgroup":{bg:`bg`}},indicator:{position:`absolute`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,pointerEvents:`none`,top:`50%`,transform:`translateY(-50%)`,height:`100%`,color:`fg.muted`,_disabled:{opacity:`0.5`},_invalid:{color:`fg.error`},_icon:{width:`1em`,height:`1em`}}},variants:{variant:{outline:{field:xC.variants?.variant.outline.trigger},subtle:{field:xC.variants?.variant.subtle.trigger},plain:{field:{bg:`transparent`,color:`fg`,focusRingWidth:`2px`}},ghost:{field:xC.variants?.variant.ghost.trigger}},size:{xs:{root:{"--select-field-height":`sizes.8`},field:{textStyle:`xs`,ps:`2`,pe:`6`},indicator:{textStyle:`sm`,insetEnd:`1.5`}},sm:{root:{"--select-field-height":`sizes.9`},field:{textStyle:`sm`,ps:`2.5`,pe:`8`},indicator:{textStyle:`md`,insetEnd:`2`}},md:{root:{"--select-field-height":`sizes.10`},field:{textStyle:`sm`,ps:`3`,pe:`8`},indicator:{textStyle:`lg`,insetEnd:`2`}},lg:{root:{"--select-field-height":`sizes.11`},field:{textStyle:`md`,ps:`4`,pe:`8`},indicator:{textStyle:`xl`,insetEnd:`3`}},xl:{root:{"--select-field-height":`sizes.12`},field:{textStyle:`md`,ps:`4.5`,pe:`10`},indicator:{textStyle:`xl`,insetEnd:`3`}}}},defaultVariants:xC.defaultVariants}),CC=Zv({display:`flex`,justifyContent:`center`,alignItems:`center`,flex:`1`,userSelect:`none`,cursor:`button`,lineHeight:`1`,color:`fg.muted`,"--stepper-base-radius":`radii.l1`,"--stepper-radius":`calc(var(--stepper-base-radius) + 1px)`,_icon:{boxSize:`1em`},_disabled:{opacity:`0.5`},_hover:{bg:`bg.muted`},_active:{bg:`bg.emphasized`}}),wC=W({className:`chakra-number-input`,slots:gm.keys(),base:{root:{position:`relative`,zIndex:`0`,isolation:`isolate`},input:{...qx.base,verticalAlign:`top`,pe:`calc(var(--stepper-width) + 0.5rem)`},control:{display:`flex`,flexDirection:`column`,position:`absolute`,top:`0`,insetEnd:`0px`,margin:`1px`,width:`var(--stepper-width)`,height:`calc(100% - 2px)`,zIndex:`1`,borderStartWidth:`1px`,divideY:`1px`},incrementTrigger:{...CC,borderTopEndRadius:`var(--stepper-radius)`},decrementTrigger:{...CC,borderBottomEndRadius:`var(--stepper-radius)`},valueText:{fontWeight:`medium`,fontFeatureSettings:`pnum`,fontVariantNumeric:`proportional-nums`}},variants:{size:{xs:{input:qx.variants.size.xs,control:{fontSize:`2xs`,"--stepper-width":`sizes.4`}},sm:{input:qx.variants.size.sm,control:{fontSize:`xs`,"--stepper-width":`sizes.5`}},md:{input:qx.variants.size.md,control:{fontSize:`sm`,"--stepper-width":`sizes.6`}},lg:{input:qx.variants.size.lg,control:{fontSize:`sm`,"--stepper-width":`sizes.6`}}},variant:Oy(qx.variants.variant,(e,t)=>[e,{input:t}])},defaultVariants:{size:`md`,variant:`outline`}}),{variants:TC,defaultVariants:EC}=qx,DC=W({className:`chakra-pin-input`,slots:_m.keys(),base:{input:{...qx.base,textAlign:`center`,width:`var(--input-height)`},control:{display:`inline-flex`,gap:`2`,isolation:`isolate`}},variants:{size:Oy(TC.size,(e,t)=>[e,{input:{...t,px:`1`}}]),variant:Oy(TC.variant,(e,t)=>[e,{input:t}]),attached:{true:{control:{gap:`0`,spaceX:`-1px`},input:{_notFirst:{borderStartRadius:`0`},_notLast:{borderEndRadius:`0`},_focusVisible:{zIndex:`1`}}}}},defaultVariants:EC}),OC=W({className:`chakra-popover`,slots:SS.keys(),base:{content:{position:`relative`,display:`flex`,flexDirection:`column`,textStyle:`sm`,"--popover-bg":`colors.bg.panel`,bg:`var(--popover-bg)`,boxShadow:`lg`,"--popover-size":`sizes.xs`,"--popover-mobile-size":`calc(100dvw - 1rem)`,width:{base:`min(var(--popover-mobile-size), var(--popover-size))`,sm:`var(--popover-size)`},borderRadius:`l3`,"--popover-z-index":`zIndex.popover`,zIndex:`calc(var(--popover-z-index) + var(--layer-index, 0))`,outline:`0`,transformOrigin:`var(--transform-origin)`,maxHeight:`var(--available-height)`,_open:{animationStyle:`scale-fade-in`,animationDuration:`fast`},_closed:{animationStyle:`scale-fade-out`,animationDuration:`faster`}},header:{paddingInline:`var(--popover-padding)`,paddingTop:`var(--popover-padding)`},body:{padding:`var(--popover-padding)`,flex:`1`},footer:{display:`flex`,alignItems:`center`,paddingInline:`var(--popover-padding)`,paddingBottom:`var(--popover-padding)`},arrow:{"--arrow-size":`sizes.3`,"--arrow-background":`var(--popover-bg)`},arrowTip:{borderTopWidth:`1px`,borderLeftWidth:`1px`}},variants:{size:{xs:{content:{"--popover-padding":`spacing.3`}},sm:{content:{"--popover-padding":`spacing.4`}},md:{content:{"--popover-padding":`spacing.5`}},lg:{content:{"--popover-padding":`spacing.6`}}}},defaultVariants:{size:`md`}}),kC=W({slots:ym.keys(),className:`chakra-progress`,base:{root:{textStyle:`sm`,position:`relative`},track:{overflow:`hidden`,position:`relative`},range:{display:`flex`,alignItems:`center`,justifyContent:`center`,transitionProperty:`width, height`,transitionDuration:`slow`,height:`100%`,bgColor:`var(--track-color)`,_indeterminate:{"--animate-from-x":`-40%`,"--animate-to-x":`100%`,position:`absolute`,willChange:`left`,minWidth:`50%`,animation:`position 1s ease infinite normal none running`,backgroundImage:`linear-gradient(to right, transparent 0%, var(--track-color) 50%, transparent 100%)`}},label:{display:`inline-flex`,fontWeight:`medium`,alignItems:`center`,gap:`1`},valueText:{textStyle:`xs`,lineHeight:`1`,fontWeight:`medium`}},variants:{variant:{outline:{track:{shadow:`inset`,bgColor:`bg.muted`},range:{bgColor:`colorPalette.solid`}},subtle:{track:{bgColor:`colorPalette.muted`},range:{bgColor:`colorPalette.solid/72`}}},shape:{square:{},rounded:{track:{borderRadius:`l1`}},full:{track:{borderRadius:`full`}}},striped:{true:{range:{backgroundImage:`linear-gradient(45deg, var(--stripe-color) 25%, transparent 25%, transparent 50%, var(--stripe-color) 50%, var(--stripe-color) 75%, transparent 75%, transparent)`,backgroundSize:`var(--stripe-size) var(--stripe-size)`,"--stripe-size":`1rem`,"--stripe-color":{_light:`rgba(255, 255, 255, 0.3)`,_dark:`rgba(0, 0, 0, 0.3)`}}}},animated:{true:{range:{"--animate-from":`var(--stripe-size)`,animation:`bg-position 1s linear infinite`}}},size:{xs:{track:{h:`1.5`}},sm:{track:{h:`2`}},md:{track:{h:`2.5`}},lg:{track:{h:`3`}},xl:{track:{h:`4`}}}},defaultVariants:{variant:`outline`,size:`md`,shape:`rounded`}}),AC=W({className:`chakra-progress-circle`,slots:ym.keys(),base:{root:{display:`inline-flex`,textStyle:`sm`,position:`relative`},circle:{_indeterminate:{animation:`spin 2s linear infinite`}},circleTrack:{"--track-color":`colors.colorPalette.muted`,stroke:`var(--track-color)`},circleRange:{stroke:`colorPalette.solid`,transitionProperty:`stroke-dashoffset, stroke-dasharray`,transitionDuration:`0.6s`,_indeterminate:{animation:`circular-progress 1.5s linear infinite`}},label:{display:`inline-flex`},valueText:{lineHeight:`1`,fontWeight:`medium`,letterSpacing:`tight`,fontVariantNumeric:`tabular-nums`}},variants:{size:{xs:{circle:{"--size":`24px`,"--thickness":`4px`},valueText:{textStyle:`2xs`}},sm:{circle:{"--size":`32px`,"--thickness":`5px`},valueText:{textStyle:`2xs`}},md:{circle:{"--size":`40px`,"--thickness":`6px`},valueText:{textStyle:`xs`}},lg:{circle:{"--size":`48px`,"--thickness":`7px`},valueText:{textStyle:`sm`}},xl:{circle:{"--size":`64px`,"--thickness":`8px`},valueText:{textStyle:`sm`}}}},defaultVariants:{size:`md`}}),jC=W({slots:bm.keys(),className:`chakra-qr-code`,base:{root:{position:`relative`,width:`fit-content`,"--qr-code-overlay-size":`calc(var(--qr-code-size) / 3)`},frame:{width:`var(--qr-code-size)`,height:`var(--qr-code-size)`,fill:`currentColor`},overlay:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:`var(--qr-code-overlay-size)`,height:`var(--qr-code-overlay-size)`,padding:`1`,bg:`bg`,rounded:`l1`}},variants:{size:{"2xs":{root:{"--qr-code-size":`40px`}},xs:{root:{"--qr-code-size":`64px`}},sm:{root:{"--qr-code-size":`80px`}},md:{root:{"--qr-code-size":`120px`}},lg:{root:{"--qr-code-size":`160px`}},xl:{root:{"--qr-code-size":`200px`}},"2xl":{root:{"--qr-code-size":`240px`}},full:{root:{"--qr-code-size":`100%`}}}},defaultVariants:{size:`md`}}),MC=W({className:`chakra-radio-card`,slots:wS.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`1.5`,isolation:`isolate`},item:{flex:`1`,display:`flex`,flexDirection:`column`,userSelect:`none`,position:`relative`,borderRadius:`l2`,_focus:{bg:`colorPalette.muted/20`},_disabled:{opacity:`0.5`},_checked:{zIndex:`1`}},label:{display:`inline-flex`,fontWeight:`medium`,textStyle:`sm`,_disabled:{opacity:`0.5`}},itemText:{fontWeight:`medium`,flex:`1`},itemDescription:{opacity:`0.64`,textStyle:`sm`},itemControl:{display:`inline-flex`,flex:`1`,pos:`relative`,rounded:`inherit`,justifyContent:`var(--radio-card-justify)`,alignItems:`var(--radio-card-align)`,_disabled:{bg:`bg.muted`}},itemIndicator:Qx.base,itemAddon:{roundedBottom:`inherit`,_disabled:{color:`fg.muted`}},itemContent:{display:`flex`,flexDirection:`column`,flex:`1`,gap:`1`,justifyContent:`var(--radio-card-justify)`,alignItems:`var(--radio-card-align)`}},variants:{size:{sm:{item:{textStyle:`sm`},itemControl:{padding:`3`,gap:`1.5`},itemAddon:{px:`3`,py:`1.5`,borderTopWidth:`1px`},itemIndicator:Qx.variants?.size.sm},md:{item:{textStyle:`sm`},itemControl:{padding:`4`,gap:`2.5`},itemAddon:{px:`4`,py:`2`,borderTopWidth:`1px`},itemIndicator:Qx.variants?.size.md},lg:{item:{textStyle:`md`},itemControl:{padding:`4`,gap:`3.5`},itemAddon:{px:`4`,py:`2`,borderTopWidth:`1px`},itemIndicator:Qx.variants?.size.lg}},variant:{surface:{item:{borderWidth:`1px`,_checked:{bg:`colorPalette.subtle`,color:`colorPalette.fg`,borderColor:`colorPalette.muted`}},itemIndicator:Qx.variants?.variant.solid},subtle:{item:{bg:`bg.muted`},itemControl:{_checked:{bg:`colorPalette.muted`,color:`colorPalette.fg`}},itemIndicator:Qx.variants?.variant.outline},outline:{item:{borderWidth:`1px`,_checked:{boxShadow:`inset 0 0 0 1px var(--shadow-color)`,boxShadowColor:`colorPalette.solid`,borderColor:`colorPalette.solid`}},itemControl:{_disabled:{bg:`unset`}},itemIndicator:Qx.variants?.variant.solid},solid:{item:{borderWidth:`1px`,_checked:{bg:`colorPalette.solid`,color:`colorPalette.contrast`,borderColor:`colorPalette.solid`}},itemControl:{_disabled:{bg:`unset`}},itemIndicator:Qx.variants?.variant.inverted}},justify:{start:{item:{"--radio-card-justify":`flex-start`}},end:{item:{"--radio-card-justify":`flex-end`}},center:{item:{"--radio-card-justify":`center`}}},align:{start:{item:{"--radio-card-align":`flex-start`},itemControl:{textAlign:`start`}},end:{item:{"--radio-card-align":`flex-end`},itemControl:{textAlign:`end`}},center:{item:{"--radio-card-align":`center`},itemControl:{textAlign:`center`}}},orientation:{vertical:{itemControl:{flexDirection:`column`}},horizontal:{itemControl:{flexDirection:`row`}}}},defaultVariants:{size:`md`,variant:`outline`,align:`start`,orientation:`horizontal`}}),NC=W({className:`chakra-radio-group`,slots:CS.keys(),base:{item:{display:`inline-flex`,alignItems:`center`,position:`relative`,fontWeight:`medium`,_disabled:{cursor:`disabled`}},itemControl:Qx.base,label:{userSelect:`none`,textStyle:`sm`,_disabled:{opacity:`0.5`}}},variants:{variant:{outline:{itemControl:Qx.variants?.variant?.outline},subtle:{itemControl:Qx.variants?.variant?.subtle},solid:{itemControl:Qx.variants?.variant?.solid}},size:{xs:{item:{textStyle:`xs`,gap:`1.5`},itemControl:Qx.variants?.size?.xs},sm:{item:{textStyle:`sm`,gap:`2`},itemControl:Qx.variants?.size?.sm},md:{item:{textStyle:`sm`,gap:`2.5`},itemControl:Qx.variants?.size?.md},lg:{item:{textStyle:`md`,gap:`3`},itemControl:Qx.variants?.size?.lg}}},defaultVariants:{size:`md`,variant:`solid`}}),PC=W({className:`chakra-rating-group`,slots:TS.keys(),base:{root:{display:`inline-flex`},control:{display:`inline-flex`,alignItems:`center`},item:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,userSelect:`none`},itemIndicator:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`1em`,height:`1em`,position:`relative`,"--clip-path":{base:`inset(0 50% 0 0)`,_rtl:`inset(0 0 0 50%)`},_icon:{stroke:`currentColor`,width:`100%`,height:`100%`,display:`inline-block`,flexShrink:0,position:`absolute`,left:0,top:0},"& [data-bg]":{color:`bg.emphasized`},"& [data-fg]":{color:`transparent`},"&[data-highlighted]:not([data-half])":{"& [data-fg]":{color:`colorPalette.solid`}},"&[data-half]":{"& [data-fg]":{color:`colorPalette.solid`,clipPath:`var(--clip-path)`}}}},variants:{size:{xs:{item:{textStyle:`sm`}},sm:{item:{textStyle:`md`}},md:{item:{textStyle:`xl`}},lg:{item:{textStyle:`2xl`}}}},defaultVariants:{size:`md`}}),FC=W({className:`chakra-scroll-area`,slots:Cm.keys(),base:{root:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,position:`relative`,overflow:`hidden`,"--scrollbar-margin":`2px`,"--scrollbar-click-area":`calc(var(--scrollbar-size) + calc(var(--scrollbar-margin) * 2))`},viewport:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`,borderRadius:`inherit`,WebkitOverflowScrolling:`touch`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}},content:{minWidth:`100%`},scrollbar:{display:`flex`,userSelect:`none`,touchAction:`none`,borderRadius:`full`,colorPalette:`gray`,transition:`opacity 150ms 300ms`,position:`relative`,margin:`var(--scrollbar-margin)`,"&:not([data-overflow-x], [data-overflow-y])":{display:`none`},bg:`{colors.colorPalette.solid/10}`,"--thumb-bg":`{colors.colorPalette.solid/25}`,"&:is(:hover, :active)":{"--thumb-bg":`{colors.colorPalette.solid/50}`},_before:{content:`""`,position:`absolute`},_vertical:{width:`var(--scrollbar-size)`,flexDirection:`column`,"&::before":{width:`var(--scrollbar-click-area)`,height:`100%`,insetInlineStart:`calc(var(--scrollbar-margin) * -1)`}},_horizontal:{height:`var(--scrollbar-size)`,flexDirection:`row`,"&::before":{height:`var(--scrollbar-click-area)`,width:`100%`,top:`calc(var(--scrollbar-margin) * -1)`}}},thumb:{borderRadius:`inherit`,bg:`var(--thumb-bg)`,transition:`backgrounds`,_vertical:{width:`full`},_horizontal:{height:`full`}},corner:{bg:`bg.muted`,margin:`var(--scrollbar-margin)`,opacity:0,transition:`opacity 150ms 300ms`,"&[data-hover]":{transitionDelay:`0ms`,opacity:1}}},variants:{variant:{hover:{scrollbar:{opacity:`0`,"&[data-hover], &[data-scrolling]":{opacity:`1`,transitionDuration:`faster`,transitionDelay:`0ms`}}},always:{scrollbar:{opacity:`1`}}},size:{xs:{root:{"--scrollbar-size":`sizes.1`}},sm:{root:{"--scrollbar-size":`sizes.1.5`}},md:{root:{"--scrollbar-size":`sizes.2`}},lg:{root:{"--scrollbar-size":`sizes.3`}}}},defaultVariants:{size:`md`,variant:`hover`}}),IC=W({className:`chakra-segment-group`,slots:wm.keys(),base:{root:{"--segment-radius":`radii.l2`,"--segment-indicator-bg":{_light:`colors.bg`,_dark:`colors.bg.emphasized`},"--segment-indicator-shadow":`shadows.sm`,borderRadius:`var(--segment-radius)`,display:`inline-flex`,boxShadow:`inset`,minW:`max-content`,textAlign:`center`,position:`relative`,isolation:`isolate`,bg:`bg.muted`,_vertical:{flexDirection:`column`}},item:{display:`flex`,alignItems:`center`,justifyContent:`center`,userSelect:`none`,fontSize:`sm`,position:`relative`,color:`fg`,borderRadius:`var(--segment-radius)`,_disabled:{opacity:`0.5`},"&:has(input:focus-visible)":{focusRing:`outside`},_before:{content:`""`,position:`absolute`,bg:`border`,transition:`opacity 0.2s`},_horizontal:{_before:{insetInlineStart:0,insetBlock:`1.5`,width:`1px`}},_vertical:{_before:{insetBlockStart:0,insetInline:`1.5`,height:`1px`}},"& + &[data-state=checked], &[data-state=checked] + &, &:first-of-type":{_before:{opacity:`0`}},"&[data-state=checked][data-ssr]":{shadow:`sm`,bg:`bg`,borderRadius:`var(--segment-radius)`}},indicator:{shadow:`var(--segment-indicator-shadow)`,pos:`absolute`,bg:`var(--segment-indicator-bg)`,width:`var(--width)`,height:`var(--height)`,top:`var(--top)`,left:`var(--left)`,zIndex:-1,borderRadius:`var(--segment-radius)`}},variants:{size:{xs:{item:{textStyle:`xs`,px:`3`,gap:`1`,height:`6`}},sm:{item:{textStyle:`sm`,px:`4`,gap:`2`,height:`8`}},md:{item:{textStyle:`sm`,px:`4`,gap:`2`,height:`10`}},lg:{item:{textStyle:`md`,px:`4.5`,gap:`3`,height:`11`}}}},defaultVariants:{size:`md`}}),LC=W({className:`chakra-slider`,slots:OS.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`1`,textStyle:`sm`,position:`relative`,isolation:`isolate`,touchAction:`none`},label:{fontWeight:`medium`,textStyle:`sm`},control:{display:`inline-flex`,alignItems:`center`,position:`relative`},track:{overflow:`hidden`,borderRadius:`full`,flex:`1`},range:{width:`inherit`,height:`inherit`,_disabled:{bg:`border.emphasized!`}},markerGroup:{position:`absolute!`,zIndex:`1`},marker:{"--marker-bg":{base:`white`,_underValue:`colors.bg`},display:`flex`,alignItems:`center`,gap:`calc(var(--slider-thumb-size) / 2)`,color:`fg.muted`,textStyle:`xs`},markerIndicator:{width:`var(--slider-marker-size)`,height:`var(--slider-marker-size)`,borderRadius:`full`,bg:`var(--marker-bg)`},thumb:{width:`var(--slider-thumb-size)`,height:`var(--slider-thumb-size)`,display:`flex`,alignItems:`center`,justifyContent:`center`,outline:0,zIndex:`2`,borderRadius:`full`,transition:`shadow`,_focusVisible:{ring:`3px`,ringColor:`colorPalette.focusRing/50`}}},variants:{size:{sm:{root:{"--slider-thumb-size":`sizes.4`,"--slider-track-size":`sizes.1.5`,"--slider-marker-center":`6px`,"--slider-marker-size":`sizes.1`,"--slider-marker-inset":`3px`}},md:{root:{"--slider-thumb-size":`sizes.5`,"--slider-track-size":`sizes.2`,"--slider-marker-center":`8px`,"--slider-marker-size":`sizes.1`,"--slider-marker-inset":`4px`}},lg:{root:{"--slider-thumb-size":`sizes.6`,"--slider-track-size":`sizes.2.5`,"--slider-marker-center":`9px`,"--slider-marker-size":`sizes.1.5`,"--slider-marker-inset":`5px`}}},variant:{outline:{track:{shadow:`inset`,bg:`bg.emphasized/72`},range:{bg:`colorPalette.solid`},thumb:{borderWidth:`2px`,borderColor:`colorPalette.solid`,bg:`bg`,_disabled:{bg:`border.emphasized`,borderColor:`border.emphasized`}}},solid:{track:{bg:`colorPalette.subtle`,_disabled:{bg:`bg.muted`}},range:{bg:`colorPalette.solid`},thumb:{bg:`colorPalette.solid`,_disabled:{bg:`border.emphasized`}}}},orientation:{vertical:{root:{display:`inline-flex`},control:{flexDirection:`column`,height:`100%`,minWidth:`var(--slider-thumb-size)`,"&:has(.chakra-slider__markerLabel)":{marginEnd:`4`}},track:{width:`var(--slider-track-size)`},thumb:{left:`50%`,translate:`-50% 0`},markerGroup:{insetStart:`var(--slider-marker-center)`,insetBlock:`var(--slider-marker-inset)`},marker:{flexDirection:`row`}},horizontal:{control:{flexDirection:`row`,width:`100%`,minHeight:`var(--slider-thumb-size)`,"&:has(.chakra-slider__markerLabel)":{marginBottom:`4`}},track:{height:`var(--slider-track-size)`},thumb:{top:`50%`,translate:`0 -50%`},markerGroup:{top:`var(--slider-marker-center)`,insetInline:`var(--slider-marker-inset)`},marker:{flexDirection:`column`}}}},defaultVariants:{size:`md`,variant:`outline`,orientation:`horizontal`}}),RC=W({slots:BS.keys(),className:`splitter`,base:{resizeTrigger:{"--splitter-border-color":`colors.border`,"--splitter-thumb-color":`colors.bg`,"--splitter-thumb-size":`sizes.2`,"--splitter-thumb-inset":`calc(var(--splitter-thumb-size) * -0.5)`,"--splitter-border-size":`1px`,"--splitter-handle-size":`sizes.6`,outline:`0`,display:`grid`,placeItems:`center`,position:`relative`,_focus:{"--splitter-border-color":`colors.border.emphasized`,"--splitter-thumb-color":`colors.colorPalette.subtle`},_dragging:{"--splitter-thumb-color":`colors.colorPalette.focusRing`},_horizontal:{minWidth:`var(--splitter-thumb-size)`,marginInline:`var(--splitter-thumb-inset)`},_vertical:{minHeight:`var(--splitter-thumb-size)`,marginBlock:`var(--splitter-thumb-inset)`}},resizeTriggerSeparator:{position:`absolute`,bg:`var(--splitter-border-color)`,"[data-part='resize-trigger'][data-orientation=horizontal] &":{insetInlineEnd:`calc(var(--splitter-thumb-size) * 0.5)`,insetBlock:`0`,insetInlineStart:`auto`,w:`var(--splitter-border-size)`},"[data-part='resize-trigger'][data-orientation=vertical] &":{insetBlockEnd:`calc(var(--splitter-thumb-size) * 0.5)`,insetInline:`0`,insetBlockStart:`auto`,h:`var(--splitter-border-size)`}},resizeTriggerIndicator:{position:`relative`,rounded:`full`,bg:`var(--splitter-thumb-color)`,shadow:`xs`,borderWidth:`1px`,zIndex:`1`,"[data-part='resize-trigger'][data-orientation=horizontal] &":{w:`full`,h:`var(--splitter-handle-size)`},"[data-part='resize-trigger'][data-orientation=vertical] &":{w:`var(--splitter-handle-size)`,h:`full`},"[data-part='resize-trigger'][data-focus]:focus-visible &":{outlineWidth:`2px`,outlineColor:`colorPalette.focusRing`,outlineStyle:`solid`},"[data-part='resize-trigger'][data-disabled] &":{visibility:`hidden`}}}}),zC=W({className:`chakra-stat`,slots:kS.keys(),base:{root:{display:`flex`,flexDirection:`column`,gap:`1`,position:`relative`,flex:`1`},label:{display:`inline-flex`,gap:`1.5`,alignItems:`center`,color:`fg.muted`,textStyle:`sm`},helpText:{color:`fg.muted`,textStyle:`xs`},valueUnit:{color:`fg.muted`,textStyle:`xs`,fontWeight:`initial`,letterSpacing:`initial`},valueText:{verticalAlign:`baseline`,fontWeight:`semibold`,letterSpacing:`tight`,fontFeatureSettings:`pnum`,fontVariantNumeric:`proportional-nums`,display:`inline-flex`,gap:`1`},indicator:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,marginEnd:1,"& :where(svg)":{w:`1em`,h:`1em`},"&[data-type=up]":{color:`fg.success`},"&[data-type=down]":{color:`fg.error`}}},variants:{size:{sm:{valueText:{textStyle:`xl`}},md:{valueText:{textStyle:`2xl`}},lg:{valueText:{textStyle:`3xl`}}}},defaultVariants:{size:`md`}}),BC=W({className:`chakra-status`,slots:AS.keys(),base:{root:{display:`inline-flex`,alignItems:`center`,gap:`2`},indicator:{width:`0.64em`,height:`0.64em`,flexShrink:0,borderRadius:`full`,forcedColorAdjust:`none`,bg:`colorPalette.solid`}},variants:{size:{sm:{root:{textStyle:`xs`}},md:{root:{textStyle:`sm`}},lg:{root:{textStyle:`md`}}}},defaultVariants:{size:`md`}}),VC=W({className:`chakra-steps`,slots:jS.keys(),base:{root:{display:`flex`,width:`full`},list:{display:`flex`,justifyContent:`space-between`,"--steps-gutter":`spacing.3`,"--steps-thickness":`2px`},title:{fontWeight:`medium`,color:`fg`},description:{color:`fg.muted`},separator:{bg:`border`,flex:`1`},indicator:{display:`flex`,justifyContent:`center`,alignItems:`center`,flexShrink:`0`,borderRadius:`full`,fontWeight:`medium`,width:`var(--steps-size)`,height:`var(--steps-size)`,_icon:{flexShrink:`0`,width:`var(--steps-icon-size)`,height:`var(--steps-icon-size)`}},item:{position:`relative`,display:`flex`,gap:`3`,flex:`1 0 0`,"&:last-of-type":{flex:`initial`,"& [data-part=separator]":{display:`none`}}},trigger:{display:`flex`,alignItems:`center`,gap:`3`,textAlign:`start`,focusVisibleRing:`outside`,borderRadius:`l2`},content:{focusVisibleRing:`outside`}},variants:{orientation:{vertical:{root:{flexDirection:`row`,height:`100%`},list:{flexDirection:`column`,alignItems:`flex-start`},separator:{position:`absolute`,width:`var(--steps-thickness)`,height:`100%`,maxHeight:`calc(100% - var(--steps-size) - var(--steps-gutter) * 2)`,top:`calc(var(--steps-size) + var(--steps-gutter))`,insetStart:`calc(var(--steps-size) / 2 - 1px)`},item:{alignItems:`flex-start`}},horizontal:{root:{flexDirection:`column`,width:`100%`},list:{flexDirection:`row`,alignItems:`center`},separator:{width:`100%`,height:`var(--steps-thickness)`,marginX:`var(--steps-gutter)`},item:{alignItems:`center`}}},variant:{solid:{indicator:{_incomplete:{borderWidth:`var(--steps-thickness)`},_current:{bg:`colorPalette.muted`,borderWidth:`var(--steps-thickness)`,borderColor:`colorPalette.solid`,color:`colorPalette.fg`},_complete:{bg:`colorPalette.solid`,borderColor:`colorPalette.solid`,color:`colorPalette.contrast`}},separator:{_complete:{bg:`colorPalette.solid`}}},subtle:{indicator:{_incomplete:{bg:`bg.muted`},_current:{bg:`colorPalette.muted`,color:`colorPalette.fg`},_complete:{bg:`colorPalette.emphasized`,color:`colorPalette.fg`}},separator:{_complete:{bg:`colorPalette.emphasized`}}}},size:{xs:{root:{gap:`2.5`},list:{"--steps-size":`sizes.6`,"--steps-icon-size":`sizes.3.5`,textStyle:`xs`},title:{textStyle:`sm`}},sm:{root:{gap:`3`},list:{"--steps-size":`sizes.8`,"--steps-icon-size":`sizes.4`,textStyle:`xs`},title:{textStyle:`sm`}},md:{root:{gap:`4`},list:{"--steps-size":`sizes.10`,"--steps-icon-size":`sizes.4`,textStyle:`sm`},title:{textStyle:`sm`}},lg:{root:{gap:`6`},list:{"--steps-size":`sizes.11`,"--steps-icon-size":`sizes.5`,textStyle:`md`},title:{textStyle:`md`}}}},defaultVariants:{size:`md`,variant:`solid`,orientation:`horizontal`}}),HC=W({slots:MS.keys(),className:`chakra-switch`,base:{root:{display:`inline-flex`,gap:`2.5`,alignItems:`center`,position:`relative`,verticalAlign:`middle`,"--switch-diff":`calc(var(--switch-width) - var(--switch-height))`,"--switch-x":{base:`var(--switch-diff)`,_rtl:`calc(var(--switch-diff) * -1)`}},label:{lineHeight:`1`,userSelect:`none`,fontSize:`sm`,fontWeight:`medium`,_disabled:{opacity:`0.5`}},indicator:{position:`absolute`,height:`var(--switch-height)`,width:`var(--switch-height)`,fontSize:`var(--switch-indicator-font-size)`,fontWeight:`medium`,flexShrink:0,userSelect:`none`,display:`grid`,placeContent:`center`,transition:`inset-inline-start 0.12s ease`,insetInlineStart:`calc(var(--switch-x) - 2px)`,_checked:{insetInlineStart:`2px`}},control:{display:`inline-flex`,gap:`0.5rem`,flexShrink:0,justifyContent:`flex-start`,cursor:`switch`,borderRadius:`full`,position:`relative`,width:`var(--switch-width)`,height:`var(--switch-height)`,transition:`backgrounds`,_disabled:{opacity:`0.5`,cursor:`not-allowed`},_invalid:{outline:`2px solid`,outlineColor:`border.error`,outlineOffset:`2px`}},thumb:{display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,transitionProperty:`translate`,transitionDuration:`fast`,borderRadius:`inherit`,_checked:{translate:`var(--switch-x) 0`}}},variants:{variant:{solid:{control:{borderRadius:`full`,bg:`bg.emphasized`,focusVisibleRing:`outside`,_checked:{bg:`colorPalette.solid`}},thumb:{bg:`white`,width:`var(--switch-height)`,height:`var(--switch-height)`,scale:`0.8`,boxShadow:`sm`,_checked:{bg:`colorPalette.contrast`}}},raised:{control:{borderRadius:`full`,height:`calc(var(--switch-height) / 2)`,bg:`bg.muted`,boxShadow:`inset`,_checked:{bg:`colorPalette.solid/60`}},thumb:{width:`var(--switch-height)`,height:`var(--switch-height)`,position:`relative`,top:`calc(var(--switch-height) * -0.25)`,bg:`white`,boxShadow:`xs`,focusVisibleRing:`outside`,_checked:{bg:`colorPalette.solid`}}}},size:{xs:{root:{"--switch-width":`sizes.6`,"--switch-height":`sizes.3`,"--switch-indicator-font-size":`fontSizes.xs`}},sm:{root:{"--switch-width":`sizes.8`,"--switch-height":`sizes.4`,"--switch-indicator-font-size":`fontSizes.xs`}},md:{root:{"--switch-width":`sizes.10`,"--switch-height":`sizes.5`,"--switch-indicator-font-size":`fontSizes.sm`}},lg:{root:{"--switch-width":`sizes.12`,"--switch-height":`sizes.6`,"--switch-indicator-font-size":`fontSizes.md`}}}},defaultVariants:{variant:`solid`,size:`md`}}),UC=W({className:`chakra-table`,slots:NS.keys(),base:{root:{fontVariantNumeric:`lining-nums tabular-nums`,borderCollapse:`collapse`,width:`full`,textAlign:`start`,verticalAlign:`top`},row:{_selected:{bg:`colorPalette.subtle`}},cell:{textAlign:`start`,alignItems:`center`},columnHeader:{fontWeight:`medium`,textAlign:`start`,color:`fg`},caption:{fontWeight:`medium`,textStyle:`xs`},footer:{fontWeight:`medium`}},variants:{interactive:{true:{body:{"& tr":{_hover:{bg:`colorPalette.subtle`}}}}},stickyHeader:{true:{header:{"& :where(tr)":{top:`var(--table-sticky-offset, 0)`,position:`sticky`,zIndex:1}}}},striped:{true:{row:{"&:nth-of-type(odd) td":{bg:`bg.muted`}}}},showColumnBorder:{true:{columnHeader:{"&:not(:last-of-type)":{borderInlineEndWidth:`1px`}},cell:{"&:not(:last-of-type)":{borderInlineEndWidth:`1px`}}}},variant:{line:{columnHeader:{borderBottomWidth:`1px`},cell:{borderBottomWidth:`1px`},row:{bg:`bg`}},outline:{root:{boxShadow:`0 0 0 1px {colors.border}`},columnHeader:{borderBottomWidth:`1px`},header:{bg:`bg.muted`},row:{"&:not(:last-of-type)":{borderBottomWidth:`1px`}},footer:{borderTopWidth:`1px`}}},size:{sm:{root:{textStyle:`sm`},columnHeader:{px:`2`,py:`2`},cell:{px:`2`,py:`2`}},md:{root:{textStyle:`sm`},columnHeader:{px:`3`,py:`3`},cell:{px:`3`,py:`3`}},lg:{root:{textStyle:`md`},columnHeader:{px:`4`,py:`3`},cell:{px:`4`,py:`3`}}}},defaultVariants:{variant:`line`,size:`md`}}),WC=W({slots:FS.keys(),className:`chakra-tabs`,base:{root:{"--tabs-trigger-radius":`radii.l2`,"--tabs-indicator-shadow":`shadows.xs`,"--tabs-indicator-bg":`colors.bg`,position:`relative`,_horizontal:{display:`block`},_vertical:{display:`flex`}},list:{display:`inline-flex`,position:`relative`,isolation:`isolate`,minH:`var(--tabs-height)`,_horizontal:{flexDirection:`row`},_vertical:{flexDirection:`column`}},trigger:{outline:`0`,minW:`var(--tabs-height)`,height:`var(--tabs-height)`,display:`flex`,alignItems:`center`,fontWeight:`medium`,position:`relative`,cursor:`button`,gap:`2`,_focusVisible:{zIndex:1,outline:`2px solid`,outlineColor:`colorPalette.focusRing`},_disabled:{cursor:`not-allowed`,opacity:.5}},content:{focusVisibleRing:`inside`,_horizontal:{width:`100%`,pt:`var(--tabs-content-padding)`},_vertical:{height:`100%`,ps:`var(--tabs-content-padding)`}},indicator:{width:`var(--width)`,height:`var(--height)`,borderRadius:`var(--tabs-trigger-radius)`,bg:`var(--tabs-indicator-bg)`,shadow:`var(--tabs-indicator-shadow)`,zIndex:-1}},variants:{fitted:{true:{list:{display:`flex`},trigger:{flex:1,textAlign:`center`,justifyContent:`center`}}},justify:{start:{list:{justifyContent:`flex-start`}},center:{list:{justifyContent:`center`}},end:{list:{justifyContent:`flex-end`}}},size:{sm:{root:{"--tabs-height":`sizes.9`,"--tabs-content-padding":`spacing.3`},trigger:{py:`1`,px:`3`,textStyle:`sm`}},md:{root:{"--tabs-height":`sizes.10`,"--tabs-content-padding":`spacing.4`},trigger:{py:`2`,px:`4`,textStyle:`sm`}},lg:{root:{"--tabs-height":`sizes.11`,"--tabs-content-padding":`spacing.4.5`},trigger:{py:`2`,px:`4.5`,textStyle:`md`}}},variant:{line:{list:{display:`flex`,borderColor:`border`,_horizontal:{borderBottomWidth:`1px`},_vertical:{borderEndWidth:`1px`}},trigger:{color:`fg.muted`,_disabled:{_active:{bg:`initial`}},_selected:{color:`fg`,_horizontal:{layerStyle:`indicator.bottom`,"--indicator-offset-y":`-1px`,"--indicator-color":`colors.colorPalette.solid`},_vertical:{layerStyle:`indicator.end`,"--indicator-offset-x":`-1px`}}}},subtle:{trigger:{borderRadius:`var(--tabs-trigger-radius)`,color:`fg.muted`,_selected:{bg:`colorPalette.subtle`,color:`colorPalette.fg`}}},enclosed:{list:{bg:`bg.muted`,padding:`1`,borderRadius:`l3`,minH:`calc(var(--tabs-height) - 4px)`},trigger:{justifyContent:`center`,color:`fg.muted`,borderRadius:`var(--tabs-trigger-radius)`,_selected:{bg:`bg`,color:`colorPalette.fg`,shadow:`xs`}}},outline:{list:{"--line-thickness":`1px`,"--line-offset":`calc(var(--line-thickness) * -1)`,borderColor:`border`,display:`flex`,_horizontal:{_before:{content:`""`,position:`absolute`,bottom:`0px`,width:`100%`,borderBottomWidth:`var(--line-thickness)`,borderBottomColor:`border`}},_vertical:{_before:{content:`""`,position:`absolute`,insetInline:`var(--line-offset)`,height:`calc(100% - calc(var(--line-thickness) * 2))`,borderEndWidth:`var(--line-thickness)`,borderEndColor:`border`}}},trigger:{color:`fg.muted`,borderWidth:`1px`,borderColor:`transparent`,_selected:{bg:`currentBg`,color:`colorPalette.fg`},_horizontal:{borderTopRadius:`var(--tabs-trigger-radius)`,marginBottom:`var(--line-offset)`,marginEnd:{_notLast:`var(--line-offset)`},_selected:{borderColor:`border`,borderBottomColor:`transparent`}},_vertical:{borderStartRadius:`var(--tabs-trigger-radius)`,marginEnd:`var(--line-offset)`,marginBottom:{_notLast:`var(--line-offset)`},_selected:{borderColor:`border`,borderEndColor:`transparent`}}}},plain:{trigger:{color:`fg.muted`,_selected:{color:`colorPalette.fg`},borderRadius:`var(--tabs-trigger-radius)`,"&[data-selected][data-ssr]":{bg:`var(--tabs-indicator-bg)`,shadow:`var(--tabs-indicator-shadow)`,borderRadius:`var(--tabs-trigger-radius)`}}}}},defaultVariants:{size:`md`,variant:`line`}}),GC=Lx.variants?.variant,KC=W({slots:IS.keys(),className:`chakra-tag`,base:{root:{display:`inline-flex`,alignItems:`center`,verticalAlign:`top`,maxWidth:`100%`,userSelect:`none`,borderRadius:`l2`,focusVisibleRing:`outside`},label:{lineClamp:`1`},closeTrigger:{display:`flex`,alignItems:`center`,justifyContent:`center`,outline:`0`,borderRadius:`l1`,color:`currentColor`,focusVisibleRing:`inside`,focusRingWidth:`2px`},startElement:{flexShrink:0,boxSize:`var(--tag-element-size)`,ms:`var(--tag-element-offset)`,"&:has([data-scope=avatar])":{boxSize:`var(--tag-avatar-size)`,ms:`calc(var(--tag-element-offset) * 1.5)`},_icon:{boxSize:`100%`}},endElement:{flexShrink:0,boxSize:`var(--tag-element-size)`,me:`var(--tag-element-offset)`,_icon:{boxSize:`100%`},"&:has(button)":{ms:`calc(var(--tag-element-offset) * -1)`}}},variants:{size:{sm:{root:{px:`1.5`,minH:`4.5`,gap:`1`,"--tag-avatar-size":`spacing.3`,"--tag-element-size":`spacing.3`,"--tag-element-offset":`-2px`},label:{textStyle:`xs`}},md:{root:{px:`1.5`,minH:`5`,gap:`1`,"--tag-avatar-size":`spacing.3.5`,"--tag-element-size":`spacing.3.5`,"--tag-element-offset":`-2px`},label:{textStyle:`xs`}},lg:{root:{px:`2`,minH:`6`,gap:`1.5`,"--tag-avatar-size":`spacing.4.5`,"--tag-element-size":`spacing.4`,"--tag-element-offset":`-3px`},label:{textStyle:`sm`}},xl:{root:{px:`2.5`,minH:`8`,gap:`1.5`,"--tag-avatar-size":`spacing.6`,"--tag-element-size":`spacing.4.5`,"--tag-element-offset":`-4px`},label:{textStyle:`sm`}}},variant:{subtle:{root:GC?.subtle},solid:{root:GC?.solid},outline:{root:GC?.outline},surface:{root:GC?.surface}}},defaultVariants:{size:`md`,variant:`surface`}}),qC=W({slots:vg.keys(),className:`tags-input`,base:{root:{display:`flex`,flexDirection:`column`,gap:`1.5`,width:`full`},label:{fontWeight:`medium`,textStyle:`sm`,_disabled:{opacity:`0.5`}},control:{"--focus-color":`colors.colorPalette.focusRing`,"--error-color":`colors.border.error`,minH:`var(--tags-input-height)`,"--input-height":`var(--tags-input-height)`,px:`var(--tags-input-px)`,py:`var(--tags-input-py)`,gap:`var(--tags-input-gap)`,display:`flex`,flexWrap:`wrap`,alignItems:`center`,borderRadius:`l2`,pos:`relative`,transitionProperty:`border-color, box-shadow`,transitionDuration:`normal`,_disabled:{opacity:`0.5`},_invalid:{borderColor:`var(--error-color)`}},input:{flex:`1`,minWidth:`20`,outline:`none`,bg:`transparent`,color:`fg`,px:`calc(var(--tags-input-item-px) / 1.25)`,height:`var(--tags-input-item-height)`,_readOnly:{display:`none`}},item:{maxWidth:`100%`,minWidth:`0`},itemText:{lineClamp:`1`,minWidth:`0`},itemInput:{outline:`none`,bg:`transparent`,minWidth:`2ch`,color:`inherit`,px:`var(--tags-input-item-px)`,height:`var(--tags-input-item-height)`},itemPreview:{height:`var(--tags-input-item-height)`,userSelect:`none`,display:`inline-flex`,alignItems:`center`,gap:`1`,rounded:`l1`,px:`var(--tags-input-item-px)`,maxWidth:`100%`},itemDeleteTrigger:{display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`,boxSize:`calc(var(--tags-input-item-height) / 1.5)`,cursor:{base:`button`,_disabled:`initial`},me:`-1`,opacity:`0.4`,_hover:{opacity:`1`},"[data-highlighted] &":{opacity:`1`},_icon:{boxSize:`80%`}},clearTrigger:{display:`flex`,alignItems:`center`,justifyContent:`center`,boxSize:`calc(var(--tags-input-item-height) / 1.5)`,cursor:{base:`button`,_disabled:`initial`},color:`fg.muted`,focusVisibleRing:`inside`,focusRingWidth:`2px`,rounded:`l1`,_icon:{boxSize:`5`}}},variants:{size:{xs:{root:{"--tags-input-height":`sizes.8`,"--tags-input-px":`spacing.1.5`,"--tags-input-py":`spacing.1`,"--tags-input-gap":`spacing.1`,"--tags-input-item-height":`sizes.6`,"--tags-input-item-px":`spacing.2`,textStyle:`xs`}},sm:{root:{"--tags-input-height":`sizes.9`,"--tags-input-px":`spacing.1.5`,"--tags-input-py":`spacing.1`,"--tags-input-gap":`spacing.1`,"--tags-input-item-height":`sizes.6`,"--tags-input-item-px":`spacing.2`,textStyle:`sm`}},md:{root:{"--tags-input-height":`sizes.10`,"--tags-input-px":`spacing.1.5`,"--tags-input-py":`spacing.1`,"--tags-input-gap":`spacing.1`,"--tags-input-item-height":`sizes.7`,"--tags-input-item-px":`spacing.2`,textStyle:`sm`}},lg:{root:{"--tags-input-height":`sizes.11`,"--tags-input-px":`spacing.1.5`,"--tags-input-py":`spacing.1`,"--tags-input-gap":`spacing.1`,"--tags-input-item-height":`sizes.8`,"--tags-input-item-px":`spacing.2`,textStyle:`md`}}},variant:{outline:{control:{borderWidth:`1px`,bg:`bg`,_focus:{outlineWidth:`1px`,outlineStyle:`solid`,outlineColor:`var(--focus-color)`,borderColor:`var(--focus-color)`,_invalid:{outlineColor:`var(--error-color)`,borderColor:`var(--error-color)`}}},itemPreview:{bg:`colorPalette.subtle`,_highlighted:{bg:`colorPalette.muted`}}},subtle:{control:{bg:`bg.muted`,borderWidth:`1px`,borderColor:`transparent`,_focus:{outlineWidth:`1px`,outlineStyle:`solid`,outlineColor:`var(--focus-color)`,borderColor:`var(--focus-color)`,_invalid:{outlineColor:`var(--error-color)`,borderColor:`var(--error-color)`}}},itemPreview:{bg:`bg`,borderWidth:`1px`,_highlighted:{bg:`colorPalette.subtle`,borderColor:`colorPalette.emphasized`}}},flushed:{control:{borderRadius:`0`,px:`0`,bg:`transparent`,borderBottomWidth:`1px`,borderBottomColor:`border`,_focus:{borderColor:`var(--focus-color)`,boxShadow:`0px 1px 0px 0px var(--focus-color)`}},itemPreview:{bg:`colorPalette.subtle`,_highlighted:{bg:`colorPalette.muted`}}}}},defaultVariants:{size:`md`,variant:`outline`}}),JC=W({slots:LS.keys(),className:`chakra-timeline`,base:{root:{display:`flex`,flexDirection:`column`,width:`full`,"--timeline-thickness":`1px`,"--timeline-gutter":`4px`},item:{"--timeline-content-gap":`spacing.6`,display:`flex`,position:`relative`,alignItems:`flex-start`,flexShrink:0,gap:`4`,_last:{"--timeline-content-gap":`0`}},separator:{display:`var(--timeline-separator-display)`,position:`absolute`,borderStartWidth:`var(--timeline-thickness)`,ms:`calc(-1 * var(--timeline-thickness) / 2)`,insetInlineStart:`calc(var(--timeline-indicator-size) / 2)`,insetBlock:`0`,borderColor:`border`},indicator:{outline:`2px solid {colors.bg}`,position:`relative`,flexShrink:`0`,boxSize:`var(--timeline-indicator-size)`,fontSize:`var(--timeline-font-size)`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`full`,fontWeight:`medium`},connector:{alignSelf:`stretch`,position:`relative`},content:{pb:`var(--timeline-content-gap)`,display:`flex`,flexDirection:`column`,width:`full`,gap:`2`},title:{display:`flex`,fontWeight:`medium`,flexWrap:`wrap`,gap:`1.5`,alignItems:`center`,mt:`var(--timeline-margin)`},description:{color:`fg.muted`,textStyle:`xs`}},variants:{variant:{subtle:{indicator:{bg:`colorPalette.muted`}},solid:{indicator:{bg:`colorPalette.solid`,color:`colorPalette.contrast`}},outline:{indicator:{bg:`currentBg`,borderWidth:`1px`,borderColor:`colorPalette.muted`}},plain:{}},showLastSeparator:{true:{item:{_last:{"--timeline-separator-display":`initial`}}},false:{item:{_last:{"--timeline-separator-display":`none`}}}},size:{sm:{root:{"--timeline-indicator-size":`sizes.4`,"--timeline-font-size":`fontSizes.2xs`},title:{textStyle:`xs`}},md:{root:{"--timeline-indicator-size":`sizes.5`,"--timeline-font-size":`fontSizes.xs`},title:{textStyle:`sm`}},lg:{root:{"--timeline-indicator-size":`sizes.6`,"--timeline-font-size":`fontSizes.xs`},title:{mt:`0.5`,textStyle:`sm`}},xl:{root:{"--timeline-indicator-size":`sizes.8`,"--timeline-font-size":`fontSizes.sm`},title:{mt:`1.5`,textStyle:`sm`}}}},defaultVariants:{size:`md`,variant:`solid`,showLastSeparator:!1}}),YC=W({slots:PS.keys(),className:`chakra-toast`,base:{root:{width:`full`,display:`flex`,alignItems:`flex-start`,position:`relative`,gap:`3`,py:`4`,ps:`4`,pe:`6`,borderRadius:`l2`,translate:`var(--x) var(--y)`,scale:`var(--scale)`,zIndex:`var(--z-index)`,height:`var(--height)`,opacity:`var(--opacity)`,willChange:`translate, opacity, scale`,transition:`translate 400ms, scale 400ms, opacity 400ms, height 400ms, box-shadow 200ms`,transitionTimingFunction:`cubic-bezier(0.21, 1.02, 0.73, 1)`,_closed:{transition:`translate 400ms, scale 400ms, opacity 200ms`,transitionTimingFunction:`cubic-bezier(0.06, 0.71, 0.55, 1)`},bg:`bg.panel`,color:`fg`,boxShadow:`xl`,"--toast-trigger-bg":`colors.bg.muted`,"&[data-type=warning]":{bg:`orange.solid`,color:`orange.contrast`,"--toast-trigger-bg":`{white/10}`,"--toast-border-color":`{white/40}`},"&[data-type=success]":{bg:`green.solid`,color:`green.contrast`,"--toast-trigger-bg":`{white/10}`,"--toast-border-color":`{white/40}`},"&[data-type=error]":{bg:`red.solid`,color:`red.contrast`,"--toast-trigger-bg":`{white/10}`,"--toast-border-color":`{white/40}`}},title:{fontWeight:`medium`,textStyle:`sm`,marginEnd:`2`},description:{display:`inline`,textStyle:`sm`,opacity:`0.8`},indicator:{flexShrink:`0`,boxSize:`5`},actionTrigger:{textStyle:`sm`,fontWeight:`medium`,height:`8`,px:`3`,borderRadius:`l2`,alignSelf:`center`,borderWidth:`1px`,borderColor:`var(--toast-border-color, inherit)`,transition:`background 200ms`,_hover:{bg:`var(--toast-trigger-bg)`}},closeTrigger:{position:`absolute`,top:`1`,insetEnd:`1`,padding:`1`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,color:`{currentColor/60}`,borderRadius:`l2`,textStyle:`md`,transition:`background 200ms`,_icon:{boxSize:`1em`}}}}),XC=W({slots:bg.keys(),className:`chakra-tooltip`,base:{content:{"--tooltip-bg":`colors.bg.inverted`,bg:`var(--tooltip-bg)`,color:`fg.inverted`,px:`2.5`,py:`1`,borderRadius:`l2`,fontWeight:`medium`,textStyle:`xs`,boxShadow:`md`,maxW:`xs`,zIndex:`tooltip`,transformOrigin:`var(--transform-origin)`,_open:{animationStyle:`scale-fade-in`,animationDuration:`fast`},_closed:{animationStyle:`scale-fade-out`,animationDuration:`fast`}},arrow:{"--arrow-size":`sizes.2`,"--arrow-background":`var(--tooltip-bg)`},arrowTip:{borderTopWidth:`1px`,borderLeftWidth:`1px`,borderColor:`var(--tooltip-bg)`}}}),ZC=Zv({display:`flex`,alignItems:`center`,gap:`var(--tree-item-gap)`,rounded:`l2`,userSelect:`none`,position:`relative`,"--tree-depth":`calc(var(--depth) - 1)`,"--tree-indentation-offset":`calc(var(--tree-indentation) * var(--tree-depth))`,"--tree-offset":`calc(var(--tree-padding-inline) + var(--tree-indentation-offset))`,ps:`var(--tree-offset)`,pe:`var(--tree-padding-inline)`,py:`var(--tree-padding-block)`,focusVisibleRing:`inside`,focusRingColor:`border.emphasized`,focusRingWidth:`2px`,"&:hover, &:focus-visible":{bg:`bg.muted`},_disabled:{layerStyle:`disabled`}}),QC=Zv({flex:`1`}),$C=Zv({_selected:{bg:`colorPalette.subtle`,color:`colorPalette.fg`}}),ew=Zv({_selected:{layerStyle:`fill.solid`}}),tw={accordion:HS,actionBar:US,alert:WS,avatar:GS,blockquote:KS,breadcrumb:qS,card:JS,carousel:YS,checkbox:XS,checkboxCard:ZS,codeBlock:QS,collapsible:$S,dataList:nC,dateInput:rC,datePicker:oC,dialog:sC,drawer:cC,editable:uC,emptyState:dC,field:fC,fieldset:pC,fileUpload:mC,hoverCard:gC,list:_C,listbox:vC,menu:bC,nativeSelect:SC,numberInput:wC,pinInput:DC,popover:OC,progress:kC,progressCircle:AC,radioCard:MC,radioGroup:NC,ratingGroup:PC,scrollArea:FC,segmentGroup:IC,select:xC,combobox:tC,slider:LC,splitter:RC,stat:zC,steps:VC,switch:HC,table:UC,tabs:WC,tag:KC,tagsInput:qC,toast:YC,tooltip:XC,status:BC,timeline:JC,colorPicker:eC,qrCode:jC,treeView:W({slots:xg.keys(),className:`chakra-tree-view`,base:{root:{width:`full`,display:`flex`,flexDirection:`column`,gap:`2`},tree:{display:`flex`,flexDirection:`column`,"--tree-item-gap":`spacing.2`,"--tree-indentation":`calc(var(--tree-indent-size) + var(--tree-icon-size) * 0.5)`,_icon:{boxSize:`var(--tree-icon-size)`}},label:{fontWeight:`medium`,textStyle:`sm`},branch:{position:`relative`},branchContent:{position:`relative`},branchIndentGuide:{height:`100%`,width:`1px`,bg:`border`,position:`absolute`,"--tree-depth":`calc(var(--depth) - 1)`,"--tree-indentation-offset":`calc(var(--tree-indentation) * var(--tree-depth))`,"--tree-offset":`calc(var(--tree-padding-inline) + var(--tree-indentation-offset))`,insetInlineStart:`calc(var(--tree-offset) + var(--tree-icon-size) * 0.5)`,zIndex:`1`},branchIndicator:{color:`fg.muted`,transformOrigin:`center`,transitionDuration:`normal`,transitionProperty:`transform`,transitionTimingFunction:`default`,_open:{transform:`rotate(90deg)`}},branchTrigger:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`},branchControl:ZC,item:ZC,itemText:QC,branchText:QC,nodeCheckbox:{display:`inline-flex`}},variants:{size:{md:{tree:{textStyle:`sm`,"--tree-indent-size":`spacing.4`,"--tree-icon-size":`spacing.4`,"--tree-padding-inline":`spacing.3`,"--tree-padding-block":`spacing.1.5`}},sm:{tree:{textStyle:`sm`,"--tree-indent-size":`spacing.4`,"--tree-icon-size":`spacing.3`,"--tree-padding-inline":`spacing.3`,"--tree-padding-block":`spacing.1`}},xs:{tree:{textStyle:`xs`,"--tree-indent-size":`spacing.4`,"--tree-icon-size":`spacing.3`,"--tree-padding-inline":`spacing.2`,"--tree-padding-block":`spacing.1`}}},variant:{subtle:{branchControl:$C,item:$C},solid:{branchControl:ew,item:ew}},animateContent:{true:{branchContent:{_open:{animationName:`expand-height, fade-in`,animationDuration:`moderate`},_closed:{animationName:`collapse-height, fade-out`,animationDuration:`moderate`}}}}},defaultVariants:{size:`md`,variant:`subtle`}}),marquee:yC,floatingPanel:hC},nw=Qv({"2xs":{value:{fontSize:`2xs`,lineHeight:`0.75rem`}},xs:{value:{fontSize:`xs`,lineHeight:`1rem`}},sm:{value:{fontSize:`sm`,lineHeight:`1.25rem`}},md:{value:{fontSize:`md`,lineHeight:`1.5rem`}},lg:{value:{fontSize:`lg`,lineHeight:`1.75rem`}},xl:{value:{fontSize:`xl`,lineHeight:`1.875rem`}},"2xl":{value:{fontSize:`2xl`,lineHeight:`2rem`}},"3xl":{value:{fontSize:`3xl`,lineHeight:`2.375rem`}},"4xl":{value:{fontSize:`4xl`,lineHeight:`2.75rem`,letterSpacing:`-0.025em`}},"5xl":{value:{fontSize:`5xl`,lineHeight:`3.75rem`,letterSpacing:`-0.025em`}},"6xl":{value:{fontSize:`6xl`,lineHeight:`4.5rem`,letterSpacing:`-0.025em`}},"7xl":{value:{fontSize:`7xl`,lineHeight:`5.75rem`,letterSpacing:`-0.025em`}},none:{value:{}},label:{value:{fontSize:`sm`,lineHeight:`1.25rem`,fontWeight:`medium`}}}),rw=ny.animations({spin:{value:`spin 1s linear infinite`},ping:{value:`ping 1s cubic-bezier(0, 0, 0.2, 1) infinite`},pulse:{value:`pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite`},bounce:{value:`bounce 1s infinite`}}),iw=ny.aspectRatios({square:{value:`1 / 1`},landscape:{value:`4 / 3`},portrait:{value:`3 / 4`},wide:{value:`16 / 9`},ultrawide:{value:`18 / 5`},golden:{value:`1.618 / 1`}}),aw=ny.blurs({none:{value:` `},sm:{value:`4px`},md:{value:`8px`},lg:{value:`12px`},xl:{value:`16px`},"2xl":{value:`24px`},"3xl":{value:`40px`},"4xl":{value:`64px`}}),ow=ny.borders({xs:{value:`0.5px solid`},sm:{value:`1px solid`},md:{value:`2px solid`},lg:{value:`4px solid`},xl:{value:`8px solid`}}),sw=ny.colors({transparent:{value:`transparent`},current:{value:`currentColor`},black:{value:`#09090B`},white:{value:`#FFFFFF`},whiteAlpha:{50:{value:`rgba(255, 255, 255, 0.04)`},100:{value:`rgba(255, 255, 255, 0.06)`},200:{value:`rgba(255, 255, 255, 0.08)`},300:{value:`rgba(255, 255, 255, 0.16)`},400:{value:`rgba(255, 255, 255, 0.24)`},500:{value:`rgba(255, 255, 255, 0.36)`},600:{value:`rgba(255, 255, 255, 0.48)`},700:{value:`rgba(255, 255, 255, 0.64)`},800:{value:`rgba(255, 255, 255, 0.80)`},900:{value:`rgba(255, 255, 255, 0.92)`},950:{value:`rgba(255, 255, 255, 0.95)`}},blackAlpha:{50:{value:`rgba(0, 0, 0, 0.04)`},100:{value:`rgba(0, 0, 0, 0.06)`},200:{value:`rgba(0, 0, 0, 0.08)`},300:{value:`rgba(0, 0, 0, 0.16)`},400:{value:`rgba(0, 0, 0, 0.24)`},500:{value:`rgba(0, 0, 0, 0.36)`},600:{value:`rgba(0, 0, 0, 0.48)`},700:{value:`rgba(0, 0, 0, 0.64)`},800:{value:`rgba(0, 0, 0, 0.80)`},900:{value:`rgba(0, 0, 0, 0.92)`},950:{value:`rgba(0, 0, 0, 0.95)`}},gray:{50:{value:`#fafafa`},100:{value:`#f4f4f5`},200:{value:`#e4e4e7`},300:{value:`#d4d4d8`},400:{value:`#a1a1aa`},500:{value:`#71717a`},600:{value:`#52525b`},700:{value:`#3f3f46`},800:{value:`#27272a`},900:{value:`#18181b`},950:{value:`#111111`}},red:{50:{value:`#fef2f2`},100:{value:`#fee2e2`},200:{value:`#fecaca`},300:{value:`#fca5a5`},400:{value:`#f87171`},500:{value:`#ef4444`},600:{value:`#dc2626`},700:{value:`#991919`},800:{value:`#511111`},900:{value:`#300c0c`},950:{value:`#1f0808`}},orange:{50:{value:`#fff7ed`},100:{value:`#ffedd5`},200:{value:`#fed7aa`},300:{value:`#fdba74`},400:{value:`#fb923c`},500:{value:`#f97316`},600:{value:`#ea580c`},700:{value:`#92310a`},800:{value:`#6c2710`},900:{value:`#3b1106`},950:{value:`#220a04`}},yellow:{50:{value:`#fefce8`},100:{value:`#fef9c3`},200:{value:`#fef08a`},300:{value:`#fde047`},400:{value:`#facc15`},500:{value:`#eab308`},600:{value:`#ca8a04`},700:{value:`#845209`},800:{value:`#713f12`},900:{value:`#422006`},950:{value:`#281304`}},green:{50:{value:`#f0fdf4`},100:{value:`#dcfce7`},200:{value:`#bbf7d0`},300:{value:`#86efac`},400:{value:`#4ade80`},500:{value:`#22c55e`},600:{value:`#16a34a`},700:{value:`#116932`},800:{value:`#124a28`},900:{value:`#042713`},950:{value:`#03190c`}},teal:{50:{value:`#f0fdfa`},100:{value:`#ccfbf1`},200:{value:`#99f6e4`},300:{value:`#5eead4`},400:{value:`#2dd4bf`},500:{value:`#14b8a6`},600:{value:`#0d9488`},700:{value:`#0c5d56`},800:{value:`#114240`},900:{value:`#032726`},950:{value:`#021716`}},blue:{50:{value:`#eff6ff`},100:{value:`#dbeafe`},200:{value:`#bfdbfe`},300:{value:`#a3cfff`},400:{value:`#60a5fa`},500:{value:`#3b82f6`},600:{value:`#2563eb`},700:{value:`#173da6`},800:{value:`#1a3478`},900:{value:`#14204a`},950:{value:`#0c142e`}},cyan:{50:{value:`#ecfeff`},100:{value:`#cffafe`},200:{value:`#a5f3fc`},300:{value:`#67e8f9`},400:{value:`#22d3ee`},500:{value:`#06b6d4`},600:{value:`#0891b2`},700:{value:`#0c5c72`},800:{value:`#134152`},900:{value:`#072a38`},950:{value:`#051b24`}},purple:{50:{value:`#faf5ff`},100:{value:`#f3e8ff`},200:{value:`#e9d5ff`},300:{value:`#d8b4fe`},400:{value:`#c084fc`},500:{value:`#a855f7`},600:{value:`#9333ea`},700:{value:`#641ba3`},800:{value:`#4a1772`},900:{value:`#2f0553`},950:{value:`#1a032e`}},pink:{50:{value:`#fdf2f8`},100:{value:`#fce7f3`},200:{value:`#fbcfe8`},300:{value:`#f9a8d4`},400:{value:`#f472b6`},500:{value:`#ec4899`},600:{value:`#db2777`},700:{value:`#a41752`},800:{value:`#6d0e34`},900:{value:`#45061f`},950:{value:`#2c0514`}}}),cw=ny.cursor({button:{value:`pointer`},checkbox:{value:`default`},disabled:{value:`not-allowed`},menuitem:{value:`default`},option:{value:`default`},radio:{value:`default`},slider:{value:`default`},switch:{value:`pointer`}}),lw=ny.durations({fastest:{value:`50ms`},faster:{value:`100ms`},fast:{value:`150ms`},moderate:{value:`200ms`},slow:{value:`300ms`},slower:{value:`400ms`},slowest:{value:`500ms`}}),uw=ny.easings({"ease-in":{value:`cubic-bezier(0.42, 0, 1, 1)`},"ease-out":{value:`cubic-bezier(0, 0, 0.58, 1)`},"ease-in-out":{value:`cubic-bezier(0.42, 0, 0.58, 1)`},"ease-in-smooth":{value:`cubic-bezier(0.32, 0.72, 0, 1)`}}),dw=ny.fontSizes({"2xs":{value:`0.625rem`},xs:{value:`0.75rem`},sm:{value:`0.875rem`},md:{value:`1rem`},lg:{value:`1.125rem`},xl:{value:`1.25rem`},"2xl":{value:`1.5rem`},"3xl":{value:`1.875rem`},"4xl":{value:`2.25rem`},"5xl":{value:`3rem`},"6xl":{value:`3.75rem`},"7xl":{value:`4.5rem`},"8xl":{value:`6rem`},"9xl":{value:`8rem`}}),fw=ny.fontWeights({thin:{value:`100`},extralight:{value:`200`},light:{value:`300`},normal:{value:`400`},medium:{value:`500`},semibold:{value:`600`},bold:{value:`700`},extrabold:{value:`800`},black:{value:`900`}}),pw=`-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"`,mw=ny.fonts({heading:{value:`Inter, ${pw}`},body:{value:`Inter, ${pw}`},mono:{value:`SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace`}}),hw=Yv({spin:{"0%":{transform:`rotate(0deg)`},"100%":{transform:`rotate(360deg)`}},pulse:{"50%":{opacity:`0.5`}},ping:{"75%, 100%":{transform:`scale(2)`,opacity:`0`}},bounce:{"0%, 100%":{transform:`translateY(-25%)`,animationTimingFunction:`cubic-bezier(0.8,0,1,1)`},"50%":{transform:`none`,animationTimingFunction:`cubic-bezier(0,0,0.2,1)`}},"bg-position":{from:{backgroundPosition:`var(--animate-from, 1rem) 0`},to:{backgroundPosition:`var(--animate-to, 0) 0`}},position:{from:{insetInlineStart:`var(--animate-from-x)`,insetBlockStart:`var(--animate-from-y)`},to:{insetInlineStart:`var(--animate-to-x)`,insetBlockStart:`var(--animate-to-y)`}},"circular-progress":{"0%":{strokeDasharray:`1, 400`,strokeDashoffset:`0`},"50%":{strokeDasharray:`400, 400`,strokeDashoffset:`-100%`},"100%":{strokeDasharray:`400, 400`,strokeDashoffset:`-260%`}},"expand-height":{from:{height:`var(--collapsed-height, 0)`},to:{height:`var(--height)`}},"collapse-height":{from:{height:`var(--height)`},to:{height:`var(--collapsed-height, 0)`}},"expand-width":{from:{width:`var(--collapsed-width, 0)`},to:{width:`var(--width)`}},"collapse-width":{from:{width:`var(--width)`},to:{width:`var(--collapsed-width, 0)`}},"fade-in":{from:{opacity:0},to:{opacity:1}},"fade-out":{from:{opacity:1},to:{opacity:0}},"slide-from-left-full":{from:{translate:`-100% 0`},to:{translate:`0 0`}},"slide-from-right-full":{from:{translate:`100% 0`},to:{translate:`0 0`}},"slide-from-top-full":{from:{translate:`0 -100%`},to:{translate:`0 0`}},"slide-from-bottom-full":{from:{translate:`0 100%`},to:{translate:`0 0`}},"slide-to-left-full":{from:{translate:`0 0`},to:{translate:`-100% 0`}},"slide-to-right-full":{from:{translate:`0 0`},to:{translate:`100% 0`}},"slide-to-top-full":{from:{translate:`0 0`},to:{translate:`0 -100%`}},"slide-to-bottom-full":{from:{translate:`0 0`},to:{translate:`0 100%`}},"slide-from-top":{"0%":{translate:`0 calc(var(--slide-from-top-distance, 0.5rem) * -1)`},to:{translate:`0`}},"slide-from-bottom":{"0%":{translate:`0 var(--slide-from-bottom-distance, 0.5rem)`},to:{translate:`0`}},"slide-from-left":{"0%":{translate:`calc(var(--slide-from-left-distance, 0.5rem) * -1) 0`},to:{translate:`0`}},"slide-from-right":{"0%":{translate:`var(--slide-from-right-distance, 0.5rem) 0`},to:{translate:`0`}},"slide-to-top":{"0%":{translate:`0`},to:{translate:`0 calc(var(--slide-to-top-distance, 0.5rem) * -1)`}},"slide-to-bottom":{"0%":{translate:`0`},to:{translate:`0 var(--slide-to-bottom-distance, 0.5rem)`}},"slide-to-left":{"0%":{translate:`0`},to:{translate:`calc(var(--slide-to-left-distance, 0.5rem) * -1) 0`}},"slide-to-right":{"0%":{translate:`0`},to:{translate:`var(--slide-to-right-distance, 0.5rem) 0`}},"scale-in":{from:{scale:`0.95`},to:{scale:`1`}},"scale-out":{from:{scale:`1`},to:{scale:`0.95`}},marqueeX:{from:{transform:`translateX(0%)`},to:{transform:`translateX(var(--marquee-translate))`}},marqueeY:{from:{transform:`translateY(0%)`},to:{transform:`translateY(var(--marquee-translate))`}}}),gw=ny.letterSpacings({tighter:{value:`-0.05em`},tight:{value:`-0.025em`},wide:{value:`0.025em`},wider:{value:`0.05em`},widest:{value:`0.1em`}}),_w=ny.lineHeights({shorter:{value:1.25},short:{value:1.375},moderate:{value:1.5},tall:{value:1.625},taller:{value:2}}),vw=ny.radii({none:{value:`0`},"2xs":{value:`0.0625rem`},xs:{value:`0.125rem`},sm:{value:`0.25rem`},md:{value:`0.375rem`},lg:{value:`0.5rem`},xl:{value:`0.75rem`},"2xl":{value:`1rem`},"3xl":{value:`1.5rem`},"4xl":{value:`2rem`},full:{value:`9999px`}}),yw=ny.spacing({.5:{value:`0.125rem`},1:{value:`0.25rem`},1.5:{value:`0.375rem`},2:{value:`0.5rem`},2.5:{value:`0.625rem`},3:{value:`0.75rem`},3.5:{value:`0.875rem`},4:{value:`1rem`},4.5:{value:`1.125rem`},5:{value:`1.25rem`},6:{value:`1.5rem`},7:{value:`1.75rem`},8:{value:`2rem`},9:{value:`2.25rem`},10:{value:`2.5rem`},11:{value:`2.75rem`},12:{value:`3rem`},14:{value:`3.5rem`},16:{value:`4rem`},20:{value:`5rem`},24:{value:`6rem`},28:{value:`7rem`},32:{value:`8rem`},36:{value:`9rem`},40:{value:`10rem`},44:{value:`11rem`},48:{value:`12rem`},52:{value:`13rem`},56:{value:`14rem`},60:{value:`15rem`},64:{value:`16rem`},72:{value:`18rem`},80:{value:`20rem`},96:{value:`24rem`}}),bw=ny.sizes({"3xs":{value:`14rem`},"2xs":{value:`16rem`},xs:{value:`20rem`},sm:{value:`24rem`},md:{value:`28rem`},lg:{value:`32rem`},xl:{value:`36rem`},"2xl":{value:`42rem`},"3xl":{value:`48rem`},"4xl":{value:`56rem`},"5xl":{value:`64rem`},"6xl":{value:`72rem`},"7xl":{value:`80rem`},"8xl":{value:`90rem`}}),xw=ny.sizes({max:{value:`max-content`},min:{value:`min-content`},fit:{value:`fit-content`},prose:{value:`60ch`},full:{value:`100%`},dvh:{value:`100dvh`},svh:{value:`100svh`},lvh:{value:`100lvh`},dvw:{value:`100dvw`},svw:{value:`100svw`},lvw:{value:`100lvw`},vw:{value:`100vw`},vh:{value:`100vh`}}),Sw=ny.sizes({"1/2":{value:`50%`},"1/3":{value:`33.333333%`},"2/3":{value:`66.666667%`},"1/4":{value:`25%`},"3/4":{value:`75%`},"1/5":{value:`20%`},"2/5":{value:`40%`},"3/5":{value:`60%`},"4/5":{value:`80%`},"1/6":{value:`16.666667%`},"2/6":{value:`33.333333%`},"3/6":{value:`50%`},"4/6":{value:`66.666667%`},"5/6":{value:`83.333333%`},"1/12":{value:`8.333333%`},"2/12":{value:`16.666667%`},"3/12":{value:`25%`},"4/12":{value:`33.333333%`},"5/12":{value:`41.666667%`},"6/12":{value:`50%`},"7/12":{value:`58.333333%`},"8/12":{value:`66.666667%`},"9/12":{value:`75%`},"10/12":{value:`83.333333%`},"11/12":{value:`91.666667%`}}),Cw=Ex(Kv(by,iy({preflight:!0,cssVarsPrefix:`chakra`,cssVarsRoot:`:where(html, .chakra-theme)`,globalCss:Px,theme:{breakpoints:Mx,keyframes:hw,tokens:{aspectRatios:iw,animations:rw,blurs:aw,borders:ow,colors:sw,durations:lw,easings:uw,fonts:mw,fontSizes:dw,fontWeights:fw,letterSpacings:gw,lineHeights:_w,radii:vw,spacing:yw,sizes:ny.sizes({...bw,...yw,...Sw,...xw}),zIndex:ny.zIndex({hide:{value:-1},base:{value:0},docked:{value:10},dropdown:{value:1e3},sticky:{value:1100},banner:{value:1200},overlay:{value:1300},modal:{value:1400},popover:{value:1500},skipNav:{value:1600},toast:{value:1700},tooltip:{value:1800},max:{value:2147483647}}),cursor:cw},semanticTokens:{colors:eS,shadows:nS,radii:tS},recipes:$x,slotRecipes:tw,textStyles:nw,layerStyles:Fx,animationStyles:Ix}}))),ww=bn(`div`,{base:{position:`absolute`,display:`flex`,alignItems:`center`,justifyContent:`center`},variants:{axis:{horizontal:{insetStart:`50%`,translate:`-50%`,_rtl:{translate:`50%`}},vertical:{top:`50%`,translate:`0 -50%`},both:{insetStart:`50%`,top:`50%`,translate:`-50% -50%`,_rtl:{translate:`50% -50%`}}}},defaultVariants:{axis:`both`}});ww.displayName=`AbsoluteCenter`;var Tw=e=>(0,P.jsx)(bn.svg,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:(0,P.jsx)(`path`,{d:`M20 6 9 17l-5-5`})}),Ew=e=>(0,P.jsx)(bn.svg,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:(0,P.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),Dw=e=>(0,P.jsx)(bn.svg,{viewBox:`0 0 24 24`,fill:`currentColor`,...e,children:(0,P.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M18.7071 6.70711C19.0976 6.31658 19.0976 5.68342 18.7071 5.29289C18.3166 4.90237 17.6834 4.90237 17.2929 5.29289L12 10.5858L6.70711 5.29289C6.31658 4.90237 5.68342 4.90237 5.29289 5.29289C4.90237 5.68342 4.90237 6.31658 5.29289 6.70711L10.5858 12L5.29289 17.2929C4.90237 17.6834 4.90237 18.3166 5.29289 18.7071C5.68342 19.0976 6.31658 19.0976 6.70711 18.7071L12 13.4142L17.2929 18.7071C17.6834 19.0976 18.3166 19.0976 18.7071 18.7071C19.0976 18.3166 19.0976 17.6834 18.7071 17.2929L13.4142 12L18.7071 6.70711Z`})}),{PropsProvider:Ow,withContext:kw}=kn({key:`badge`}),Aw=kw(`span`),{withContext:jw,PropsProvider:Mw}=kn({key:`spinner`}),Nw=jw(`span`),Pw=N.forwardRef(function(e,t){let{spinner:n=(0,P.jsx)(Nw,{size:`inherit`,borderWidth:`0.125em`,color:`inherit`}),spinnerPlacement:r=`start`,children:i,text:a,visible:o=!0,...s}=e;return o?a?(0,P.jsxs)(qs,{ref:t,display:`contents`,...s,children:[r===`start`&&n,a,r===`end`&&n]}):n?(0,P.jsxs)(qs,{ref:t,display:`contents`,...s,children:[(0,P.jsx)(ww,{display:`inline-flex`,children:n}),(0,P.jsx)(qs,{visibility:`hidden`,display:`contents`,children:i})]}):(0,P.jsx)(qs,{ref:t,display:`contents`,...s,children:i}):i});Pw.displayName=`Loader`;var{useRecipeResult:Fw,PropsProvider:Iw,usePropsContext:Lw}=kn({key:`button`}),Rw=(0,N.forwardRef)(function(e,t){let n=Lw(),r=(0,N.useMemo)(()=>Vt(n,e),[n,e]),i=Fw(r),{loading:a,loadingText:o,children:s,spinner:c,spinnerPlacement:l,...u}=i.props;return(0,P.jsx)(bn.button,{type:`button`,ref:t,...u,"data-loading":L(a),disabled:a||u.disabled,className:Yt(i.className,r.className),css:[i.styles,r.css],children:!r.asChild&&a?(0,P.jsx)(Pw,{spinner:c,text:o,spinnerPlacement:l,children:s}):s})});Rw.displayName=`Button`;var zw=(0,N.forwardRef)(function(e,t){let n=On({key:`checkmark`,recipe:e.recipe}),[r,i]=n.splitVariantProps(e),{checked:a,indeterminate:o,disabled:s,unstyled:c,children:l,css:u,...d}=i,f=c?En:n(r);return(0,P.jsx)(bn.svg,{ref:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3px`,strokeLinecap:`round`,strokeLinejoin:`round`,"data-state":o?`indeterminate`:a?`checked`:`unchecked`,"data-disabled":L(s),css:[f,u],...d,children:o?(0,P.jsx)(`path`,{d:`M5 12h14`}):a?(0,P.jsx)(`polyline`,{points:`20 6 9 17 4 12`}):null})});zw.displayName=`Checkmark`;var{withProvider:Bw,withContext:Vw,useStyles:Hw,PropsProvider:Uw}=Ic({key:`checkbox`});Bw(c_.RootProvider,`root`,{forwardAsChild:!0});var Ww=Bw(c_.Root,`root`,{forwardAsChild:!0}),Gw=Vw(c_.Label,`label`,{forwardAsChild:!0}),Kw=(0,N.forwardRef)(function(e,t){let{checked:n,indeterminate:r,...i}=e,a=wg(),o=Hw();return n&&a.checked?(0,P.jsx)(bn.svg,{ref:t,asChild:!0,...i,css:[o.indicator,e.css],children:n}):r&&a.indeterminate?(0,P.jsx)(bn.svg,{ref:t,asChild:!0,...i,css:[o.indicator,e.css],children:r}):(0,P.jsx)(zw,{ref:t,checked:a.checked,indeterminate:a.indeterminate,disabled:a.disabled,unstyled:!0,...i,css:[o.indicator,e.css]})}),qw=Vw(c_.Control,`control`,{forwardAsChild:!0,defaultProps:{children:(0,P.jsx)(Kw,{})}});bn(c_.Group,{base:{display:`flex`,flexDirection:`column`,gap:`1.5`}},{forwardAsChild:!0}),c_.Context;var Jw=c_.HiddenInput,Yw=(0,N.forwardRef)(function(e,t){return(0,P.jsx)(Rw,{px:`0`,py:`0`,_icon:{fontSize:`1.2em`},ref:t,...e})});Yw.displayName=`IconButton`;var Xw=N.forwardRef(function(e,t){return(0,P.jsx)(Yw,{variant:`ghost`,"aria-label":`Close`,ref:t,...e,children:e.children??(0,P.jsx)(Dw,{})})});Xw.displayName=`CloseButton`;function Zw(e){let{gap:t,direction:n}=e,r={column:{marginY:t,marginX:0,borderInlineStartWidth:0,borderTopWidth:`1px`},"column-reverse":{marginY:t,marginX:0,borderInlineStartWidth:0,borderTopWidth:`1px`},row:{marginX:t,marginY:0,borderInlineStartWidth:`1px`,borderTopWidth:0},"row-reverse":{marginX:t,marginY:0,borderInlineStartWidth:`1px`,borderTopWidth:0}};return{"&":Uv(n,e=>r[e])}}function Qw(e){return N.Children.toArray(e).filter(e=>(0,N.isValidElement)(e))}var $w=(0,N.forwardRef)(function(e,t){let{direction:n=`column`,align:r,justify:i,gap:a=`0.5rem`,wrap:o,children:s,separator:c,className:l,...u}=e,d=(0,N.useMemo)(()=>Zw({gap:a,direction:n}),[a,n]),f=(0,N.useMemo)(()=>(0,N.isValidElement)(c)?Qw(s).map((e,t,n)=>{let r=e.key===void 0?t:e.key,i=c,a=(0,N.cloneElement)(i,{css:[d,i.props.css]});return(0,P.jsxs)(N.Fragment,{children:[e,t===n.length-1?null:a]},r)}):s,[s,c,d]);return(0,P.jsx)(bn.div,{ref:t,display:`flex`,alignItems:r,justifyContent:i,flexDirection:n,flexWrap:o,gap:c?void 0:a,className:Yt(`chakra-stack`,l),...u,children:f})});$w.displayName=`Stack`;var{withRootProvider:eT,withContext:tT,useStyles:nT,PropsProvider:rT}=Ic({key:`dialog`});eT(w_.RootProvider,{defaultProps:{unmountOnExit:!0,lazyMount:!0}});var iT=eT(w_.Root,{defaultProps:{unmountOnExit:!0,lazyMount:!0}}),aT=tT(w_.Trigger,`trigger`,{forwardAsChild:!0}),oT=tT(w_.Positioner,`positioner`,{forwardAsChild:!0}),sT=tT(w_.Content,`content`,{forwardAsChild:!0});tT(w_.Description,`description`,{forwardAsChild:!0});var cT=tT(w_.Title,`title`,{forwardAsChild:!0}),lT=tT(w_.CloseTrigger,`closeTrigger`,{forwardAsChild:!0});(0,N.forwardRef)(function(e,t){let n=d_();return(0,P.jsx)(bn.button,{type:`button`,...e,ref:t,onClick:t=>{e.onClick?.(t),n.setOpen(!1)}})});var uT=tT(w_.Backdrop,`backdrop`,{forwardAsChild:!0}),dT=tT(`div`,`body`);tT(`div`,`footer`);var fT=tT(`div`,`header`);w_.Context;var{useRecipeResult:pT,PropsProvider:mT}=kn({key:`icon`}),hT=N.forwardRef(function(e,t){let{styles:n,className:r,props:i}=pT({asChild:!e.as,...e});return(0,P.jsx)(bn.svg,{ref:t,focusable:!1,"aria-hidden":`true`,...i,css:[n,e.css],className:Yt(r,e.className)})});function gT(e){let{viewBox:t=`0 0 24 24`,d:n,displayName:r,defaultProps:i={}}=e,a=N.Children.toArray(e.path),o=(0,N.forwardRef)((e,r)=>(0,P.jsx)(hT,{ref:r,asChild:!1,viewBox:t,...i,...e,children:a.length?a:(0,P.jsx)(`path`,{fill:`currentColor`,d:n})}));return o.displayName=r,o}var{withProvider:_T,withContext:vT,useStyles:yT,useClassNames:bT,PropsProvider:xT}=Ic({key:`field`}),ST=_T($g.Root,`root`,{forwardAsChild:!0}),CT=vT($g.Label,`label`,{forwardAsChild:!0});vT($g.HelperText,`helperText`,{forwardAsChild:!0});var wT=vT($g.ErrorText,`errorText`,{forwardAsChild:!0});gT({d:`M11.983,0a12.206,12.206,0,0,0-8.51,3.653A11.8,11.8,0,0,0,0,12.207,11.779,11.779,0,0,0,11.8,24h.214A12.111,12.111,0,0,0,24,11.791h0A11.766,11.766,0,0,0,11.983,0ZM10.5,16.542a1.476,1.476,0,0,1,1.449-1.53h.027a1.527,1.527,0,0,1,1.523,1.47,1.475,1.475,0,0,1-1.449,1.53h-.027A1.529,1.529,0,0,1,10.5,16.542ZM11,12.5v-6a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Z`,defaultProps:{boxSize:`1em`}}),(0,N.forwardRef)(function(e,t){let{fallback:n,children:r=`*`,...i}=e,a=Rg(),o=bT(),s=yT();return a?.required?(0,P.jsx)(bn.span,{ref:t,"aria-hidden":`true`,...i,className:Yt(o.requiredIndicator,e.className),css:[s.requiredIndicator,e.css],children:r}):n});var G=(0,N.forwardRef)(function(e,t){return(0,P.jsx)($w,{align:`center`,...e,direction:`row`,ref:t})});G.displayName=`HStack`;var{withContext:TT,PropsProvider:ET}=kn({key:`input`}),DT=TT($g.Input),[OT,kT]=en({name:`NativeSelectBasePropsContext`,hookName:`useNativeSelectBaseProps`,providerName:`<NativeSelectRoot />`,strict:!1}),{withProvider:AT,useClassNames:jT,useStyles:MT,PropsProvider:NT}=Ic({key:`nativeSelect`}),PT=AT(`div`,`root`,{wrapElement(e,t){let n=Rg(),r=!!(n?.disabled??t.disabled),i=!!(n?.invalid??t.invalid);return(0,P.jsx)(OT,{value:{disabled:r,invalid:i},children:e})}}),FT=bn($g.Select,{},{forwardAsChild:!0}),IT=(0,N.forwardRef)(function(e,t){let{children:n,placeholder:r,unstyled:i,...a}=e,{disabled:o,invalid:s}=kT(),c=MT(),l=jT();return(0,P.jsxs)(FT,{disabled:o,"data-invalid":L(s),...a,ref:t,className:Yt(l.field,e.className),css:[i?void 0:c.field,e.css],children:[r&&(0,P.jsx)(`option`,{value:``,children:r}),n]})}),{withProvider:LT,withContext:RT,useStyles:zT,PropsProvider:BT}=Ic({key:`select`});LT(iv.RootProvider,`root`,{forwardAsChild:!0});var VT=LT(iv.Root,`root`,{forwardAsChild:!0,defaultProps:{positioning:{sameWidth:!0}}}),HT=RT(iv.Trigger,`trigger`,{forwardAsChild:!0}),UT=RT(iv.Positioner,`positioner`,{forwardAsChild:!0}),WT=RT(iv.Content,`content`,{forwardAsChild:!0});RT(iv.List,`list`,{forwardAsChild:!0});var GT=RT(iv.ValueText,`valueText`,{forwardAsChild:!0});RT(iv.ClearTrigger,`clearTrigger`,{forwardAsChild:!0,defaultProps:{children:(0,P.jsx)(Dw,{boxSize:`1em`})}}),RT(iv.ItemGroup,`itemGroup`,{forwardAsChild:!0}),RT(iv.ItemGroupLabel,`itemGroupLabel`,{forwardAsChild:!0});var KT=RT(iv.Item,`item`,{forwardAsChild:!0});RT(iv.ItemText,`itemText`,{forwardAsChild:!0}),RT(iv.ItemIndicator,`itemIndicator`,{forwardAsChild:!0,defaultProps:{children:(0,P.jsx)(Tw,{})}}),RT(`div`,`indicatorGroup`),RT(iv.Indicator,`indicator`,{forwardAsChild:!0,defaultProps:{children:(0,P.jsx)(Ew,{})}});var qT=RT(iv.Control,`control`,{forwardAsChild:!0});RT(iv.Label,`label`,{forwardAsChild:!0}),iv.Context;var JT=iv.HiddenSelect;iv.ItemContext;var{withProvider:YT,withContext:XT,useStyles:ZT,PropsProvider:QT}=Ic({key:`splitter`});YT(xv.RootProvider,`root`,{forwardAsChild:!0});var $T=YT(xv.Root,`root`,{forwardAsChild:!0}),eE=XT(xv.Panel,`panel`,{forwardAsChild:!0}),tE=XT(`div`,`resizeTriggerSeparator`),nE=XT(xv.ResizeTriggerIndicator,`resizeTriggerIndicator`),rE=XT(xv.ResizeTrigger,`resizeTrigger`,{forwardAsChild:!0,defaultProps:{"aria-label":`Resize`,children:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(tE,{}),(0,P.jsx)(nE,{})]})}});xv.Context;var{withProvider:iE,withContext:aE,useStyles:oE,PropsProvider:sE}=Ic({key:`switch`});iE(Pv.RootProvider,`root`,{forwardAsChild:!0});var cE=iE(Pv.Root,`root`,{forwardAsChild:!0}),lE=aE(Pv.Label,`label`,{forwardAsChild:!0}),uE=aE(Pv.Thumb,`thumb`,{forwardAsChild:!0}),dE=aE(Pv.Control,`control`,{forwardAsChild:!0,defaultProps:{children:(0,P.jsx)(uE,{})}});(0,N.forwardRef)(function(e,t){let n=Cv(),r=oE(),{fallback:i,children:a,unstyled:o,...s}=e;return(0,P.jsx)(bn.span,{ref:t,"data-checked":L(n.checked),...s,css:[o?void 0:r.indicator,e.css],children:n.checked?a:i})}),(0,N.forwardRef)(function(e,t){let n=Cv(),{fallback:r,children:i,...a}=e;return(0,P.jsx)(bn.span,{ref:t,"data-checked":L(n.checked),...a,children:n.checked?i:r})}),Pv.Context;var fE=Pv.HiddenInput,{StylesProvider:pE,ClassNamesProvider:mE,useRecipeResult:hE,withContext:gE,useStyles:_E,PropsProvider:vE}=Ic({key:`table`}),yE=(0,N.forwardRef)(function({native:e,...t},n){let{styles:r,props:i,classNames:a}=hE(t),o=(0,N.useMemo)(()=>e?{...r.root,"& thead":r.header,"& tbody":r.body,"& tfoot":r.footer,"& thead th":r.columnHeader,"& tr":r.row,"& td":r.cell,"& caption":r.caption}:r.root,[r,e]);return(0,P.jsx)(mE,{value:a,children:(0,P.jsx)(pE,{value:r,children:(0,P.jsx)(bn.table,{ref:n,...i,css:[o,t.css],className:Yt(a?.root,t.className)})})})}),bE=gE(`tr`,`row`),xE=bn(`div`,{base:{display:`block`,whiteSpace:`nowrap`,WebkitOverflowScrolling:`touch`,overflow:`auto`,maxWidth:`100%`}}),SE=gE(`thead`,`header`);gE(`tfoot`,`footer`);var CE=gE(`th`,`columnHeader`),wE=gE(`td`,`cell`);gE(`caption`,`caption`,{defaultProps:{captionSide:`bottom`}});var TE=gE(`tbody`,`body`);gE(`colgroup`),gE(`col`);var{withContext:EE,PropsProvider:DE}=kn({key:`textarea`}),OE=EE($g.Textarea),kE=(0,N.forwardRef)(function(e,t){return(0,P.jsx)($w,{align:`center`,...e,direction:`column`,ref:t})});kE.displayName=`VStack`;var AE=N.createContext(void 0),jE=e=>{let t=N.useContext(AE);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},ME=({client:e,children:t})=>(N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,P.jsx)(AE.Provider,{value:e,children:t})),NE={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},PE=new class{#e=NE;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function FE(e){setTimeout(e,0)}var IE=typeof window>`u`||`Deno`in globalThis;function LE(){}function RE(e,t){return typeof e==`function`?e(t):e}function zE(e){return typeof e==`number`&&e>=0&&e!==1/0}function BE(e,t){return Math.max(e+(t||0)-Date.now(),0)}function VE(e,t){return typeof e==`function`?e(t):e}function HE(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==WE(o,t.options))return!1}else if(!KE(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function UE(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(GE(t.options.mutationKey)!==GE(a))return!1}else if(!KE(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function WE(e,t){return(t?.queryKeyHashFn||GE)(e)}function GE(e){return JSON.stringify(e,(e,t)=>ZE(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function KE(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!KE(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!KE(e[r],t[r]))return!1;return!0}return!1}var qE=Object.prototype.hasOwnProperty;function JE(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=XE(e)&&XE(t);if(!r&&!(ZE(e)&&ZE(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:qE.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=JE(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function YE(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function XE(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ZE(e){if(!QE(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!QE(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function QE(e){return Object.prototype.toString.call(e)===`[object Object]`}function $E(e){return new Promise(t=>{PE.setTimeout(t,e)})}function eD(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:JE(e,t)}function tD(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function nD(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var rD=Symbol();function iD(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===rD?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function aD(e,t){return typeof e==`function`?e(...t):!!e}function oD(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var sD=()=>IE,cD=()=>sD(),lD=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},uD=new class extends lD{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},dD=FE;function fD(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=dD,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var pD=fD(),mD=new class extends lD{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function hD(e){return Math.min(1e3*2**e,3e4)}function gD(e){return(e??`online`)!==`online`||mD.isOnline()}var _D=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function vD(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(LE);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new _D(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>uD.isFocused()&&(e.networkMode===`always`||mD.isOnline())&&e.canRun(),p=()=>gD(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(cD()?0:3),a=e.retryDelay??hD,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),$E(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var yD=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),zE(this.gcTime)&&(this.#e=PE.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(cD()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(PE.clearTimeout(this.#e),this.#e=void 0)}};function bD(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{oD(e,()=>t.signal,()=>n=!0)},u=iD(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?nD:tD;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?SD:xD,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:xD(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function xD(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function SD(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var CD=class extends yD{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=ED(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=ED(this.options);e.data!==void 0&&(this.setState(TD(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=eD(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(LE).catch(LE):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>VE(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===rD||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>VE(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!BE(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=iD(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?bD(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=vD({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof _D&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof _D){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...wD(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...TD(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),pD.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function wD(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:gD(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function TD(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function ED(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var DD=class extends lD{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),kD(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return AD(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return AD(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof VE(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!YE(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&jD(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||VE(this.options.enabled,this.#t)!==VE(t.enabled,this.#t)||VE(this.options.staleTime,this.#t)!==VE(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||VE(this.options.enabled,this.#t)!==VE(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return YE(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(LE)),t}#h(e){return!cD()&&VE(this.options.enabled,this.#t)!==!1&&zE(e)}#g(){this.#b();let e=VE(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=BE(this.#r.dataUpdatedAt,e)+1;this.#u=PE.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return VE(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=PE.setInterval(()=>{(this.options.refetchIntervalInBackground||uD.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(PE.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(PE.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&kD(e,t),o=i&&jD(e,n,t,r);(a||o)&&(l={...l,...wD(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=eD(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=eD(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:MD(e,t),refetch:this.refetch,isEnabled:VE(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),YE(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();pD.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function OD(e,t){return VE(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||VE(t.retryOnMount,e)!==!1)}function kD(e,t){return OD(e,t)||e.state.data!==void 0&&AD(e,t,t.refetchOnMount)}function AD(e,t,n){if(VE(t.enabled,e)!==!1&&VE(t.staleTime,e)!==`static`){let r=VE(n,e);return r===`always`||r!==!1&&MD(e,t)}return!1}function jD(e,t,n,r){return(e!==t||VE(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&MD(e,n)}function MD(e,t){return VE(t.enabled,e)!==!1&&e.isStaleByTime(VE(t.staleTime,e))}var ND=class extends yD{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||PD(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=vD({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),pD.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function PD(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var FD=class extends lD{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new ND({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=ID(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=ID(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=ID(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=ID(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){pD.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>UE(t,e))}findAll(e={}){return this.getAll().filter(t=>UE(e,t))}notify(e){pD.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return pD.batch(()=>Promise.all(e.map(e=>e.continue().catch(LE))))}};function ID(e){return e.options.scope?.id}var LD=class extends lD{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),YE(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&GE(t.mutationKey)!==GE(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??PD();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){pD.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},RD=class extends lD{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??WE(r,t),a=this.get(i);return a||(a=new CD({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){pD.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>HE(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>HE(e,t)):t}notify(e){pD.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){pD.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){pD.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},zD=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new RD,this.#t=e.mutationCache||new FD,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=uD.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=mD.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(VE(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=RE(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return pD.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;pD.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return pD.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=pD.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(LE).catch(LE)}invalidateQueries(e,t={}){return pD.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=pD.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(LE)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(LE)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(VE(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(VE(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(LE).catch(LE)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(LE).catch(LE)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return mD.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(GE(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{KE(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(GE(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{KE(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=WE(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===rD&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},BD=N.createContext(!1),VD=()=>N.useContext(BD);BD.Provider;function HD(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var UD=N.createContext(HD()),WD=()=>N.useContext(UD),GD=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?aD(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},KD=e=>{N.useEffect(()=>{e.clearReset()},[e])},qD=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||aD(n,[e.error,r])),JD=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},YD=(e,t)=>e?.suspense&&t.isPending,XD=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ZD(e,t,n){let r=VD(),i=WD(),a=jE(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,JD(o),GD(o,i,s),KD(i);let[l]=N.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(N.useSyncExternalStore(N.useCallback(e=>{let t=d?l.subscribe(pD.batchCalls(e)):LE;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),N.useEffect(()=>{l.setOptions(o)},[o,l]),YD(o,u))throw XD(o,l,i);if(qD({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function QD(e,t){return ZD(e,DD,t)}function $D(e,t){let n=jE(t),[r]=N.useState(()=>new LD(n,e));N.useEffect(()=>{r.setOptions(e)},[r,e]);let i=N.useSyncExternalStore(N.useCallback(e=>r.subscribe(pD.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=N.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(LE)},[r]);if(i.error&&aD(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function eO(e,t){let n=new Set;for(let t of e)tO(t,n);let r=new Map;return t.map(e=>{let t=new Set;tO(e,t);let i=new Map;for(let e of t){if(!n.has(e))continue;let r=2;for(;n.has(`${e}_${r}`)||t.has(`${e}_${r}`);)r++;i.set(e,`${e}_${r}`)}for(let[e,t]of i)r.set(e,t);let a=i.size===0&&r.size===0?e:nO(e,i,r);return tO(a,n),a})}function tO(e,t){for(let n of[`id`,`as`]){let r=e.step[n];typeof r==`string`&&t.add(r)}if(e.kind===`bracket`){for(let n of e.children)tO(n,t);let n=e.elseChildren??[];for(let e of n)tO(e,t)}}function nO(e,t,n){let r={...e.step};for(let e of[`id`,`as`]){let n=r[e];typeof n==`string`&&t.has(n)&&(r[e]=t.get(n))}for(let e of[`over`,`from`]){let t=r[e];typeof t==`string`&&n.has(t)&&(r[e]=n.get(t))}return e.kind===`card`?{...e,step:r}:{...e,step:r,children:e.children.map(e=>nO(e,t,n)),...e.elseChildren!==void 0&&{elseChildren:e.elseChildren.map(e=>nO(e,t,n))}}}var rO=`value`,iO=`items`,aO=`item`;function oO(e,t,n=rO){return{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:n,selector:e.selector,kind:`css`,...e.take!==`text`&&{take:e.take}}}}function sO(e,t,n={}){let r=n.id??rO,i=e.jsonpath===void 0?`xpath`:`jsonpath`,a=e.jsonpath??e.xpath;if(a===void 0)throw Error(`documentReadCardNode: the node has neither a jsonpath nor an xpath`);if(n.generalize===!0&&e.listPath===void 0)throw Error(`documentReadCardNode: this node has no list to generalise to (it is not part of an array or a repeated sibling group)`);let o=n.generalize===!0?e.listPath:a,s=i===`xpath`&&n.namespaces!==void 0&&Object.keys(n.namespaces).length>0?n.namespaces:void 0;return{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:r,selector:o,kind:i,...n.generalize===!0&&{many:!0},...s!==void 0&&{namespaces:s}}}}function cO(e,t){if(e.jsonpath===void 0)throw Error(`paginateFromNextNode: pagination reads a JSON/YAML "next" value (node.jsonpath)`);return{kind:`bracket`,path:t,stepType:`paginate`,sentence:[],children:[],step:{type:`paginate`,next:{jsonpath:e.jsonpath},steps:[]}}}function lO(e,t,n={}){let r=n.itemsId??iO,i=n.itemAlias??aO,a=n.fieldId??rO,o=vO(t);return[{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:r,selector:e.item.selector,kind:`css`,take:`html`,many:!0}},{kind:`bracket`,path:o,stepType:`forEach`,sentence:[],children:[{kind:`card`,path:`${o}.steps.0`,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:a,from:i,selector:e.field.selector,kind:`css`,...e.field.take!==`text`&&{take:e.field.take}}}],step:{type:`forEach`,over:r,as:i,emit:!0,steps:[]}}]}function uO(e){if(e.jsonpath===void 0||e.listPath===void 0)return;let t=e.listPath.lastIndexOf(`[*]`);if(t===-1)return;let n=e.listPath.slice(t+3);return{items:e.listPath.slice(0,t+3),field:n===``?`$`:`$${n}`}}function dO(e,t,n,r){return{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:r,from:n,selector:e,kind:`jsonpath`,take:`json`}}}function fO(e,t){let n=uO(e);if(n===void 0)return;let r=vO(t);return[{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:iO,selector:n.items,kind:`jsonpath`,take:`json`,many:!0}},{kind:`bracket`,path:r,stepType:`forEach`,sentence:[],children:[dO(n.field,`${r}.steps.0`,aO,rO)],step:{type:`forEach`,over:iO,as:aO,emit:!0,steps:[]}}]}function pO(e,t){let n=uO(t);if(n===void 0)return;let r=e.find(e=>e.kind===`card`&&e.step.type===`extract`&&e.step.kind===`jsonpath`&&e.step.selector===n.items&&e.step.many===!0),i=e.findIndex(e=>e.kind===`bracket`&&e.stepType===`forEach`&&e.step.over===r?.step.id),a=e[i];if(r===void 0||a?.kind!==`bracket`)return;let[o]=eO(e,[dO(n.field,`${a.path}.steps.${a.children.length}`,String(a.step.as),rO)]);return e.map((e,t)=>t===i?{...a,children:[...a.children,o]}:e).map((e,t)=>_O(e,`steps.${t}`))}function mO(e){let t=e[e.length-1];return t?.kind===`card`&&t.stepType===`emit`?e.length-1:e.length}function hO(e,t,n){let r=eO(t===void 0?e:e.filter((e,n)=>n!==t),n),i=mO(e),a=t===void 0?[...e.slice(0,i),...r,...e.slice(i)]:[...e.slice(0,t),...r,...e.slice(t+1)];return(r.some(e=>e.kind===`bracket`&&e.stepType===`forEach`&&e.step.emit===!0)&&gO(a[a.length-1])?a.slice(0,-1):a).map((e,t)=>_O(e,`steps.${t}`))}function gO(e){return e?.kind===`card`&&e.stepType===`emit`}function _O(e,t){return e.kind===`card`?{...e,path:t}:{...e,path:t,children:e.children.map((e,n)=>_O(e,`${t}.steps.${n}`))}}function vO(e){let t=e.split(`.`),n=Number(t[t.length-1]);return[...t.slice(0,-1),String(n+1)].join(`.`)}function yO(e){let t=0;for(let n of e)t=Math.trunc(t*31+(n.codePointAt(0)??0));return`hsl(${Math.abs(t)%360}, 65%, 42%)`}function bO(e){return e.kind===`bracket`}function xO(e,t){if(t===``)return e.steps;let[n,r]=t.split(`::`,2),i=EO(e.steps,n);return i===void 0?[]:r===`else`?i.elseChildren??[]:i.children}function SO(e,t,n){if(t===``)return{...e,steps:n};let[r,i]=t.split(`::`,2);return{...e,steps:wO(e.steps,r,i,n)}}function CO(e,t,n){return{...e,steps:TO(e.steps,t,n)}}function wO(e,t,n,r){return e.map(e=>bO(e)?e.path===t?n===`else`?{...e,elseChildren:r}:{...e,children:r}:{...e,children:wO(e.children,t,n,r),elseChildren:e.elseChildren===void 0?void 0:wO(e.elseChildren,t,n,r)}:e)}function TO(e,t,n){return e.map(e=>e.path===t?n(e):bO(e)?{...e,children:TO(e.children,t,n),elseChildren:e.elseChildren===void 0?void 0:TO(e.elseChildren,t,n)}:e)}function EO(e,t){for(let n of e){if(!bO(n))continue;if(n.path===t)return n;let e=EO(n.children,t);if(e!==void 0)return e;if(n.elseChildren!==void 0){let e=EO(n.elseChildren,t);if(e!==void 0)return e}}}function DO(e){if(e===``)return`steps`;let[t,n]=e.split(`::`,2);return`${t}.${n===`else`?`else`:`steps`}`}function OO(e,t){if(e!==void 0&&t!==void 0)return kO(e.steps,t)}function kO(e,t){for(let n of e){if(n.step.id===t)return n;if(!bO(n))continue;let e=kO(n.children,t);if(e!==void 0)return e;if(n.elseChildren!==void 0){let e=kO(n.elseChildren,t);if(e!==void 0)return e}}}function AO(e){return e===void 0?[]:jO(e.steps)}function jO(e){return e.flatMap(e=>bO(e)?[e,...jO(e.children),...jO(e.elseChildren??[])]:[e])}function MO(e,t){return e.filter(e=>{if(e.path===t)return!0;if(!e.path.startsWith(`${t}.`))return!1;let n=e.path.slice(t.length+1);return!n.startsWith(`steps.`)&&!n.startsWith(`else.`)})}function NO(e){return new URLSearchParams(globalThis.location.search).get(e)??void 0}async function PO(e,t){let n=await fetch(`/api/command?token=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),r=await n.json();if(!n.ok)throw Error(FO(r,n.status));return r}function FO(e,t){return typeof e==`object`&&e&&`error`in e?String(e.error):`request failed: ${t}`}function IO(){let e=NO(`token`)??``;return{token:e,initialFolder:NO(`folder`),openWorkspace:t=>PO(e,{type:`open-workspace`,folder:t}),importDocument:(t,n,r)=>PO(e,{type:`import-document`,folder:t,name:n,bytes:r}),runSample:async(t,n)=>{await PO(e,{type:`run-sample`,recipeId:t,budget:n})},stopRun:async()=>{await PO(e,{type:`stop-run`})},saveRecipe:async(t,n)=>{await PO(e,{type:`save-recipe`,path:t,recipe:n})},saveOutline:async(t,n)=>{await PO(e,{type:`save-outline`,path:t,outline:n})},fetchStartPage:async t=>(await PO(e,{type:`fetch-start-page`,recipeId:t})).html,takeSnapshot:(t,n)=>PO(e,{type:`take-snapshot`,recipeId:t,path:n}),verifySelector:(t,n,r)=>PO(e,{type:`verify-selector`,recipeId:t,path:n,selector:r}),inferSelector:(t,n,r)=>PO(e,{type:`infer-selector`,recipeId:t,path:n,nodeIds:r}),explainWhy:t=>PO(e,{type:`explain-why`,target:t}),inspectPage:(t,n)=>PO(e,{type:`inspect-page`,recipeId:t,path:n}),responsesSeen:(t,n)=>PO(e,{type:`responses-seen`,recipeId:t,path:n}),documentTree:(t,n)=>PO(e,{type:`document-tree`,recipeId:t,path:n}),pdfView:(t,n)=>PO(e,{type:`pdf-view`,recipeId:t,path:n}),tablePreview:(t,n,r)=>PO(e,{type:`table-preview`,recipeId:t,path:n,options:r}),regionPreview:(t,n,r)=>PO(e,{type:`region-preview`,recipeId:t,path:n,selector:r}),pdfBytesUrl:(t,n)=>`/api/pdf-bytes?token=${encodeURIComponent(e)}&recipeId=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,gridView:(t,n,r)=>PO(e,{type:`grid-view`,recipeId:t,path:n,delimiter:r?.delimiter,encoding:r?.encoding}),gridPreview:(t,n,r)=>PO(e,{type:`grid-preview`,recipeId:t,path:n,options:r}),deckView:(t,n)=>PO(e,{type:`deck-view`,recipeId:t,path:n}),deckPreview:(t,n,r)=>PO(e,{type:`deck-preview`,recipeId:t,path:n,options:r}),startRecording:t=>PO(e,{type:`start-recording`,recipeId:t}),stopRecording:()=>PO(e,{type:`stop-recording`}),subscribe:t=>{let n=globalThis.location.protocol===`https:`?`wss`:`ws`,r=new WebSocket(`${n}://${globalThis.location.host}/ws?token=${encodeURIComponent(e)}`);return r.addEventListener(`message`,e=>{t(JSON.parse(String(e.data)))}),()=>{r.close()}}}}function LO(){return(0,N.useMemo)(()=>IO(),[])}function RO(){return new zD({defaultOptions:{queries:{retry:!1},mutations:{retry:!1}}})}function zO(e){return[`workspace`,e]}function BO(e){let t=LO();return QD({queryKey:zO(e),queryFn:()=>t.openWorkspace(e),enabled:e!==void 0})}var VO=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},HO=(e=>e?VO(e):VO),UO=e=>e;function WO(e,t=UO){let n=N.useSyncExternalStore(e.subscribe,N.useCallback(()=>t(e.getState()),[e,t]),N.useCallback(()=>t(e.getInitialState()),[e,t]));return N.useDebugValue(n),n}var GO=e=>{let t=HO(e),n=e=>WO(t,e);return Object.assign(n,t),n},KO=(e=>e?GO(e):GO),qO={folder:``,editorTab:`steps`,showHidden:!1},JO=KO((e,t)=>({...qO,setFolder:t=>{e({folder:t})},commitFolder:t=>{e({folder:t,openFolder:t})},selectRecipe:t=>{e({selectedRecipeId:t})},setEditorTab:t=>{e({editorTab:t})},startPicking:(t,n)=>{e({pickTarget:{recipeId:t,stepPath:n}})},stopPicking:()=>{e({pickTarget:void 0})},registerPick:n=>{let r=t().pickTarget;if(r?.firstNodeId===void 0)return e({pickTarget:{...r??{recipeId:``,stepPath:``},firstNodeId:n}}),{kind:`first`};let i=r.firstNodeId;return e({pickTarget:void 0}),{kind:`second`,firstNodeId:i}},setShowHidden:t=>{e({showHidden:t})},setHoveredNodeId:t=>{e({hoveredNodeId:t})},setHoveredStepId:t=>{e({hoveredStepId:t})}}));JO.getState();var YO={running:!1,records:[],rejected:[],traceLines:[]},XO=KO(e=>({...YO,startRun:()=>{e({running:!0,records:[],rejected:[],traceLines:[],error:void 0})},appendTraceLine:t=>{e(e=>({traceLines:[...e.traceLines,t]}))},appendRecord:t=>{e(e=>({records:[...e.records,t]}))},appendRejected:t=>{e(e=>({rejected:[...e.rejected,t]}))},finishRun:t=>{e(t===void 0?{running:!1}:{running:!1,error:t})},setError:t=>{e({error:t})}}));XO.getState();var ZO={active:!1,cards:[],notes:[]},QO=KO(e=>({...ZO,startRecording:(t,n)=>{e({active:!0,recipeId:t,startUrl:n,cards:[],notes:[],stoppedSteps:void 0,error:void 0})},addCard:t=>{e(e=>({cards:[...e.cards,t]}))},addNote:t=>{e(e=>({notes:[...e.notes,t]}))},recordingStopped:t=>{e({active:!1,stoppedSteps:t})},dismissStopped:()=>{e({stoppedSteps:void 0,cards:[],notes:[]})},failStart:t=>{e({active:!1,error:t})},setError:t=>{e({error:t})}}));QO.getState();function $O(){let e=JO(e=>e.openFolder),t=JO(e=>e.selectedRecipeId);return BO(e).data?.recipes.find(e=>e.id===t)}function ek(){return BO(JO(e=>e.openFolder)).data?.recipes.filter(e=>e.kind===`input`)??[]}function tk(){let e=LO(),t=jE();return $D({mutationFn:({path:t,recipe:n})=>e.saveRecipe(t,n),onSuccess:()=>{t.invalidateQueries({queryKey:[`workspace`]})}})}function nk(){let e=LO();return $D({mutationFn:({folder:t,name:n,bytes:r})=>e.importDocument(t,n,r)})}function rk(){let e=LO(),t=jE();return $D({mutationFn:({path:t,outline:n})=>e.saveOutline(t,n),onSuccess:()=>{t.invalidateQueries({queryKey:[`workspace`]})}})}function ik(){let e=LO(),t=XO(e=>e.startRun),n=XO(e=>e.finishRun),r=XO(e=>e.setError);return $D({mutationFn:({recipeId:t,budget:n})=>e.runSample(t,n),onMutate:()=>{t()},onError:e=>{n(),r(e instanceof Error?e.message:String(e))}})}function ak(){let e=LO();return $D({mutationFn:()=>e.stopRun()})}function ok(){let e=LO(),t=jE(),n=XO(e=>e.appendTraceLine),r=XO(e=>e.appendRecord),i=XO(e=>e.appendRejected),a=XO(e=>e.finishRun),o=QO(e=>e.addCard),s=QO(e=>e.addNote),c=QO(e=>e.recordingStopped);(0,N.useEffect)(()=>e.subscribe(e=>{switch(e.type){case`trace-line`:n(e.line);break;case`record`:r({key:e.key,data:e.data,scope:e.scope,mapping:e.mapping});break;case`record-rejected`:i({field:e.field,reason:e.reason,scope:e.scope});break;case`run-finished`:a(e.error);break;case`recording-card`:o({node:e.node,secret:e.secret});break;case`recording-note`:s({kind:e.kind,message:e.message,selector:e.kind===`next-link`?sk():void 0});break;case`recording-stopped`:c(e.steps),t.invalidateQueries({queryKey:[`snapshot`]});break;case`workspace-changed`:t.invalidateQueries({queryKey:[`workspace`]}),t.invalidateQueries({queryKey:[`snapshot`]})}}),[e,t,n,r,i,a,o,s,c])}function sk(){let e=QO.getState().cards,t=e[e.length-1];if(t===void 0||t.node.kind!==`card`||t.node.stepType!==`click`)return;let n=t.node.step.selector;return typeof n==`string`?n:void 0}function ck(e,t){let n=LO();return QD({queryKey:[`snapshot`,e,t],queryFn:()=>n.takeSnapshot(e,t),enabled:e!==void 0&&t!==void 0})}function lk(){let e=LO();return $D({mutationFn:({recipeId:t,path:n,nodeIds:r})=>e.inferSelector(t,n,r)})}function uk(){let e=LO();return $D({mutationFn:t=>e.explainWhy(t)})}function dk(e,t,n=!0){let r=LO();return QD({queryKey:[`inspect-page`,e,t],queryFn:()=>r.inspectPage(e,t),enabled:n&&e!==void 0&&t!==void 0})}function fk(){let e=LO();return $D({mutationFn:({recipeId:t,path:n})=>e.responsesSeen(t,n)})}function pk(e,t,n=!0){let r=LO();return QD({queryKey:[`document-tree`,e,t],queryFn:()=>r.documentTree(e,t),enabled:n&&e!==void 0&&t!==void 0})}function mk(e,t,n=!0){let r=LO();return QD({queryKey:[`pdf-view`,e,t],queryFn:()=>r.pdfView(e,t),enabled:n&&e!==void 0&&t!==void 0})}function hk(e,t,n){let r=LO();return QD({queryKey:[`table-preview`,e,t,n],queryFn:()=>r.tablePreview(e,t,n),enabled:e!==void 0&&t!==void 0&&n!==void 0})}function gk(e,t,n){let r=LO();return QD({queryKey:[`region-preview`,e,t,n],queryFn:()=>r.regionPreview(e,t,n),enabled:e!==void 0&&t!==void 0&&n!==void 0,placeholderData:e=>e})}function _k(e,t,n=!0,r){let i=LO();return QD({queryKey:[`grid-view`,e,t,r],queryFn:()=>i.gridView(e,t,r),enabled:n&&e!==void 0&&t!==void 0})}function vk(e,t,n){let r=LO();return QD({queryKey:[`grid-preview`,e,t,n],queryFn:()=>r.gridPreview(e,t,n),enabled:e!==void 0&&t!==void 0&&n!==void 0})}function yk(e,t,n=!0){let r=LO();return QD({queryKey:[`deck-view`,e,t],queryFn:()=>r.deckView(e,t),enabled:n&&e!==void 0&&t!==void 0})}function bk(e,t,n){let r=LO();return QD({queryKey:[`deck-preview`,e,t,n],queryFn:()=>r.deckPreview(e,t,n),enabled:e!==void 0&&t!==void 0&&n!==void 0})}function xk(){let e=LO(),t=QO(e=>e.startRecording),n=QO(e=>e.failStart);return $D({mutationFn:async({recipeId:t})=>{await e.startRecording(t)},onMutate:({recipeId:e,startUrl:n})=>{t(e,n)},onError:e=>{n(e instanceof Error?e.message:String(e))}})}function Sk(){let e=LO();return $D({mutationFn:async()=>{await e.stopRecording()}})}function Ck(e){return typeof e==`object`?e.key:e}function wk(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function Tk(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function Ek(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var Dk=(e,t)=>Math.abs(e-t)<1.01,Ok=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},kk,Ak=()=>{if(kk!==void 0)return kk;if(typeof navigator>`u`)return kk=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return kk=!0;let e=navigator.maxTouchPoints;return kk=navigator.platform===`MacIntel`&&e!==void 0&&e>0},jk=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Mk=e=>e,Nk=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Pk=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(jk(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(jk(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Fk={passive:!0},Ik=typeof window>`u`||`onscrollend`in window,Lk=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Ik,o=0,s=a?null:Ok(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Fk),a&&r.addEventListener(`scrollend`,u,Fk),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Rk=(e,t)=>Lk(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),zk=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Bk=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})};function Vk(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var Hk=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Mk,rangeExtractor:Nk,onChange:()=>{},measureElement:zk,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>Ck(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||Vk(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Tk(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,Ak()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Fk),e.addEventListener(`touchend`,n,Fk),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(Ak()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this.scrollState?.behavior===`smooth`&&!Dk(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Tk(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=Tk(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=wk(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Tk(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=Gk(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Tk(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&a!=null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f),this._retryClampedAdjustment()}},this.getVirtualItems=Tk(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return Ek(t[Uk(0,t.length-1,r?e=>n[e*2]:e=>Ek(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(Ak()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&Dk(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Uk=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Wk(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function Gk(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=Wk(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=Uk(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Kk=typeof document<`u`?N.useLayoutEffect:N.useEffect;function qk({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=N.useReducer(e=>e+1,0)[1],a=N.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=N.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=e=>{let t=a.current;if(!t.enabled||!t.container)return;s(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,o=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let s=a.start-o,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==s&&(t.lastPositions.set(c,s),r?c.style.transform=n?`translate3d(${s}px, 0, 0)`:`translate3d(0, ${s}px, 0)`:c.style[i]=`${s}px`)}},l={...r,onChange:(t,n)=>{var s;let l=a.current,u=!0;if(l.enabled){c(t);let e=t.range,n=l.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(l.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,nt.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[u]=N.useState(()=>{let e=new Hk(l),t=e.measureElement;return e.measureElement=e=>{o.current=!0;try{t(e)}finally{o.current=!1}},Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return u.setOptions(l),Kk(()=>u._didMount(),[]),Kk(()=>(s(u),u._willUpdate())),Kk(()=>{c(u)}),u}function Jk(e){return qk({observeElementRect:Pk,observeElementOffset:Rk,scrollToFn:Bk,...e})}function Yk(e,t,n=``,r=!1){let i=n.trim().toLowerCase();return i===``?Xk(e,t,0,r):Zk(e,i,0,r).rows}function Xk(e,t,n,r){if(!r&&e.hidden)return[];let i=t.has(e.nodeId),a={key:e.nodeId,node:e,depth:n,hasChildren:e.children.length>0,expanded:i};return i?[a,...e.children.flatMap(e=>Xk(e,t,n+1,r))]:[a]}function Zk(e,t,n,r){if(!r&&e.hidden)return{rows:[],matched:!1};let i=e.children.map(e=>Zk(e,t,n+1,r));return!i.some(e=>e.matched)&&!Qk(e,t)?{rows:[],matched:!1}:{rows:[{key:e.nodeId,node:e,depth:n,hasChildren:e.children.length>0,expanded:!0},...i.flatMap(e=>e.rows)],matched:!0}}function Qk(e,t){return e.tag.toLowerCase().includes(t)||e.id?.toLowerCase().includes(t)===!0||e.classes?.some(e=>e.toLowerCase().includes(t))===!0||e.text?.toLowerCase().includes(t)===!0?!0:Object.values(e.attributes).some(e=>e.toLowerCase().includes(t))}var $k=3;function eA({row:e,highlightColor:t,hovered:n,onToggle:r,onHover:i,onClick:a,onContextMenu:o}){let{node:s,depth:c,hasChildren:l,expanded:u}=e,d=Object.entries(s.attributes).slice(0,$k),f=Object.keys(s.attributes).length-d.length;return(0,P.jsxs)(G,{gap:1,pl:`${c*14+4}px`,pr:2,h:`22px`,fontSize:`xs`,fontFamily:`mono`,opacity:s.hidden?.5:1,bg:n?`bg.emphasized`:void 0,style:t===void 0?void 0:{boxShadow:`inset 3px 0 0 ${t}`},cursor:`pointer`,whiteSpace:`nowrap`,overflow:`hidden`,onMouseEnter:()=>{i(!0)},onMouseLeave:()=>{i(!1)},onClick:a,onContextMenu:o,children:[l?(0,P.jsx)(H,{as:`button`,w:`12px`,flexShrink:0,color:`fg.muted`,onClick:e=>{e.stopPropagation(),r()},children:u?`▾`:`▸`}):(0,P.jsx)(F,{w:`12px`,flexShrink:0}),(0,P.jsx)(H,{as:`span`,color:`purple.fg`,children:`<${s.tag}`}),s.id!==void 0&&(0,P.jsx)(H,{as:`span`,color:`blue.fg`,children:`#${s.id}`}),s.classes?.map(e=>(0,P.jsx)(H,{as:`span`,color:`teal.fg`,children:`.${e}`},e)),d.map(([e,t])=>(0,P.jsx)(H,{as:`span`,color:`fg.muted`,children:`${e}="${t}"`},e)),f>0&&(0,P.jsx)(H,{as:`span`,color:`fg.muted`,children:`…+${f}`}),(0,P.jsx)(H,{as:`span`,color:`purple.fg`,children:`>`}),s.text!==void 0&&s.text!==``&&(0,P.jsx)(H,{as:`span`,color:`fg.muted`,truncate:!0,children:s.text}),s.repeatCount!==void 0&&(0,P.jsx)(Aw,{size:`xs`,colorPalette:`gray`,children:`×${s.repeatCount}`})]})}var tA=22,nA=20;function rA({tree:e,showHidden:t,query:n,expanded:r,onToggle:i,nodeColors:a,hoveredNodeId:o,onHoverNode:s,onPickNode:c,onContextMenuNode:l}){let u=(0,N.useRef)(null),d=Yk(e,r,n,t),f=Jk({count:d.length,getScrollElement:()=>u.current,estimateSize:()=>tA,overscan:nA});return(0,P.jsx)(F,{ref:u,h:`full`,overflow:`auto`,children:(0,P.jsx)(F,{h:`${f.getTotalSize()}px`,position:`relative`,children:f.getVirtualItems().map(e=>{let t=d[e.index];return t===void 0?null:(0,P.jsx)(F,{position:`absolute`,top:0,left:0,w:`full`,style:{transform:`translateY(${e.start}px)`},children:(0,P.jsx)(eA,{row:t,highlightColor:a.get(t.node.nodeId),hovered:o===t.node.nodeId,onToggle:()=>{i(t.node.nodeId)},onHover:e=>{s(e?t.node.nodeId:void 0)},onClick:()=>{c(t.node.nodeId)},onContextMenu:e=>{e.preventDefault(),l(t.node,e.clientX,e.clientY)}})},t.key)})})})}function iA({node:e,x:t,y:n,onClose:r,onChoose:i}){let a=(0,N.useRef)(null);(0,N.useEffect)(()=>{let e=e=>{a.current!==null&&!a.current.contains(e.target)&&r()},t=e=>{e.key===`Escape`&&r()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let o=Object.keys(e.attributes);return(0,P.jsxs)(F,{ref:a,position:`fixed`,top:`${n}px`,left:`${t}px`,zIndex:1e3,bg:`bg.panel`,borderWidth:`1px`,borderRadius:`md`,boxShadow:`lg`,py:1,minW:`190px`,fontSize:`sm`,children:[(0,P.jsx)(aA,{label:`Read as text`,onClick:()=>{i({kind:`take`,take:`text`})}}),(0,P.jsx)(aA,{label:`Read as html`,onClick:()=>{i({kind:`take`,take:`html`})}}),(0,P.jsx)(aA,{label:`Read as json`,onClick:()=>{i({kind:`take`,take:`json`})}}),o.length>0&&(0,P.jsxs)(F,{borderTopWidth:`1px`,mt:1,pt:1,children:[(0,P.jsx)(H,{px:3,py:`2px`,fontSize:`xs`,color:`fg.muted`,children:`As an attribute`}),o.map(e=>(0,P.jsx)(aA,{label:e,onClick:()=>{i({kind:`take`,take:`attr:${e}`})}},e))]}),(0,P.jsx)(F,{borderTopWidth:`1px`,mt:1,pt:1,children:(0,P.jsx)(aA,{label:`Regex on its text…`,onClick:()=>{i({kind:`regex`})}})})]})}function aA({label:e,onClick:t}){return(0,P.jsx)(H,{as:`button`,display:`block`,w:`full`,textAlign:`left`,px:3,py:`4px`,_hover:{bg:`bg.emphasized`},onClick:t,children:e})}var oA=`data-oc-node`;function sA(e,t){if(t.trim()===``)return new Set;try{let n=new DOMParser().parseFromString(e,`text/html`).querySelectorAll(t);return new Set(Array.from(n,e=>e.getAttribute(oA)).filter(e=>e!==null))}catch{return new Set}}function cA({findings:e,onPick:t}){return e.length===0?(0,P.jsx)(F,{p:3,color:`fg.muted`,fontSize:`sm`,children:`No JSON-LD, inline state, meta or link data found in this page.`}):(0,P.jsx)(kE,{align:`stretch`,gap:0,fontSize:`sm`,overflow:`auto`,h:`full`,children:e.map(e=>(0,P.jsxs)(F,{borderBottomWidth:`1px`,px:3,py:2,children:[(0,P.jsxs)(G,{justify:`space-between`,gap:2,children:[(0,P.jsx)(H,{fontWeight:`medium`,truncate:!0,children:e.label}),(0,P.jsx)(H,{as:`button`,flexShrink:0,fontSize:`xs`,color:`blue.fg`,onClick:()=>{t(e,void 0)},children:e.keys===void 0?`Read`:`Read whole value`})]}),e.keys!==void 0&&e.keys.length>0&&(0,P.jsx)(G,{wrap:`wrap`,gap:1,mt:1,children:e.keys.map(n=>(0,P.jsx)(H,{as:`button`,fontSize:`xs`,px:2,py:`1px`,borderRadius:`full`,borderWidth:`1px`,onClick:()=>{t(e,n)},children:n},n))})]},`${e.kind}-${e.selector}`))})}var lA=`data`;function uA(e,t,n,r=lA){if(e.kind===`meta`||e.kind===`link`)return[{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:r,selector:e.selector,kind:`css`,take:`attr:${e.attribute??`content`}`}}];let i={kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:r,selector:e.selector,kind:`css`}};return n===void 0?[i]:[i,{kind:`card`,path:dA(t),stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:`${r}_${n}`,from:r,selector:`$.${n}`,kind:`jsonpath`}}]}function dA(e){let t=e.split(`.`),n=Number(t[t.length-1]);return[...t.slice(0,-1),String(n+1)].join(`.`)}function fA({responses:e,loading:t,error:n,onCheck:r,onPick:i}){return(0,P.jsxs)(kE,{align:`stretch`,gap:2,p:3,fontSize:`sm`,overflow:`auto`,h:`full`,children:[(0,P.jsx)(H,{as:`button`,alignSelf:`flex-start`,colorPalette:`blue`,color:`colorPalette.fg`,fontWeight:`medium`,opacity:t?.6:1,pointerEvents:t?`none`:void 0,onClick:r,children:t?`Checking…`:`Check for JSON responses`}),n!==void 0&&(0,P.jsx)(H,{color:`red.fg`,children:n}),e!==void 0&&e.length===0&&(0,P.jsx)(H,{color:`fg.muted`,children:`No JSON responses seen while the page rendered.`}),e?.map(e=>(0,P.jsxs)(F,{borderWidth:`1px`,borderRadius:`md`,p:2,children:[(0,P.jsx)(H,{fontWeight:`medium`,truncate:!0,title:e.url,children:e.url}),(0,P.jsx)(H,{color:`fg.muted`,fontSize:`xs`,children:`${e.status} · ${e.size} bytes · ${e.shape}`}),(0,P.jsx)(H,{as:`button`,fontSize:`xs`,color:`blue.fg`,mt:1,onClick:()=>{i(e)},children:`Switch to api mode on this endpoint`})]},e.url))]})}var pA=`response`;function mA(e,t){return{mode:`api`,start:[{url:hA(e.url,t)}],steps:[{type:`request`,id:pA,url:`{{start.url}}`,as:`json`}]}}function hA(e,t){let n=new URL(e),r=new Map(Object.entries(t??{}).map(([e,t])=>[String(t),e])),i=[...n.searchParams].map(([e,t])=>{let n=r.get(t);return`${e}=${n===void 0?encodeURIComponent(t):`{{vars.${n}}}`}`});return`${n.origin}${n.pathname}${i.length===0?``:`?${i.join(`&`)}`}`}var gA=`start`,_A=`#dd6b20`;function vA({recipeId:e,recipe:t,snapshot:n,onSaveOutline:r,onSaveRecipe:i}){let[a,o]=(0,N.useState)(`tree`),[s,c]=(0,N.useState)(``),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(()=>new Set),[p,m]=(0,N.useState)(void 0),[h,g]=(0,N.useState)(void 0),_=JO(e=>e.hoveredStepId),v=JO(e=>e.hoveredNodeId),y=JO(e=>e.setHoveredNodeId),b=(0,N.useMemo)(()=>{let e=OO(t?.outline,_)?.step.selector;return typeof e==`string`?e:void 0},[t?.outline,_]),x=dk(e,gA,n!==void 0),S=lk(),C=fk(),w=(0,N.useMemo)(()=>{let e=new Map;if(n===void 0)return e;let r=t?.outline?.steps??[];for(let t of r){if(t.kind!==`card`)continue;let r=t.step;if(r.type===`extract`&&r.kind===`css`&&typeof r.id==`string`&&typeof r.selector==`string`)for(let t of sA(n.html,r.selector))e.set(t,yO(r.id))}if(b!==void 0&&b!==``)for(let t of sA(n.html,b))e.set(t,_A);return e},[n,t,b]);(0,N.useEffect)(()=>{f(new Set)},[e]),(0,N.useEffect)(()=>{x.data!==void 0&&f(e=>{if(e.size>0)return e;let t=x.data.tree,n=new Set([t.nodeId]),[r]=t.children;return r!==void 0&&t.children.length===1&&n.add(r.nodeId),n})},[x.data]);function T(e){f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function E(e){if(r===void 0||t?.outline===void 0)return;let n=hO(t.outline.steps,void 0,e);await r(t.file,{...t.outline,steps:n})}async function D(t,n){if(e===void 0)return;let r=await S.mutateAsync({recipeId:e,path:gA,nodeIds:[t]});if(r.kind!==`field`){g(r.kind===`unsupported`?r.reason:void 0);return}let i=n===void 0?r.field:{...r.field,take:n};await E([oO(i,`steps.0`)]),g(`Read card: ${i.selector}`)}async function O(t){if(e===void 0)return;let n=await S.mutateAsync({recipeId:e,path:gA,nodeIds:[t]});if(n.kind!==`field`)return;let r=`text`;await E([oO({...n.field,take:`text`},`steps.0`,r),{kind:`card`,path:`steps.1`,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:`${r}_match`,from:r,selector:``,kind:`regex`}}]),g(`Read card: ${n.field.selector} → regex (fill the pattern in its form)`)}async function k(e,t){await E(uA(e,`steps.0`,t)),g(`Read card: ${e.selector}${t===void 0?``:` → $.${t}`}`)}async function ee(e){if(i===void 0||t===void 0)return;let n;try{n=JSON.parse(t.text)}catch{g(`The recipe's JSON does not parse; fix it in the JSON tab first`);return}let r=mA(e,yA(n.vars)?n.vars:void 0);await i(t.file,{...n,...r}),g(`Switched to api mode: ${r.start[0].url}`)}function te(e){if(p===void 0)return;let t=p.node.nodeId;m(void 0),e.kind===`regex`?O(t):D(t,e.take)}return(0,P.jsxs)(F,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,P.jsxs)(G,{px:2,py:1,borderBottomWidth:`1px`,gap:2,flexShrink:0,children:[(0,P.jsx)(bA,{label:`Tree`,active:a===`tree`,onClick:()=>{o(`tree`)}}),(0,P.jsx)(bA,{label:`Data in page`,active:a===`data`,count:x.data?.pageData.length,onClick:()=>{o(`data`)}}),(0,P.jsx)(bA,{label:`Responses`,active:a===`responses`,count:C.data?.responses.length,onClick:()=>{o(`responses`)}})]}),a===`tree`&&(0,P.jsxs)(G,{px:2,py:1,borderBottomWidth:`1px`,gap:2,flexShrink:0,children:[(0,P.jsx)(DT,{size:`xs`,placeholder:`Search by tag, class or text…`,value:s,onChange:e=>{c(e.target.value)}}),(0,P.jsx)(H,{as:`button`,fontSize:`xs`,color:l?`colorPalette.fg`:`fg.muted`,colorPalette:`orange`,whiteSpace:`nowrap`,onClick:()=>{u(e=>!e)},children:l?`Hide hidden`:`Show hidden`})]}),h!==void 0&&(0,P.jsx)(F,{px:2,py:`2px`,fontSize:`xs`,color:`fg.muted`,borderBottomWidth:`1px`,flexShrink:0,children:h}),(0,P.jsxs)(F,{flex:`1`,minH:`0`,position:`relative`,children:[a===`tree`&&x.data!==void 0&&(0,P.jsx)(rA,{tree:x.data.tree,showHidden:l,query:s,expanded:d,onToggle:T,nodeColors:w,hoveredNodeId:v,onHoverNode:y,onPickNode:e=>{D(e)},onContextMenuNode:(e,t,n)=>{m({node:e,x:t,y:n})}}),a===`tree`&&x.isFetching&&(0,P.jsx)(F,{p:3,color:`fg.muted`,fontSize:`sm`,children:`Inspecting…`}),a===`data`&&(0,P.jsx)(cA,{findings:x.data?.pageData??[],onPick:(e,t)=>{k(e,t)}}),a===`responses`&&(0,P.jsx)(fA,{responses:C.data?.responses,loading:C.isPending,error:C.error?.message,onCheck:()=>{e!==void 0&&C.mutate({recipeId:e,path:gA})},onPick:e=>{ee(e)}}),p!==void 0&&(0,P.jsx)(iA,{node:p.node,x:p.x,y:p.y,onClose:()=>{m(void 0)},onChoose:te})]})]})}function yA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function bA({label:e,active:t,count:n,onClick:r}){return(0,P.jsxs)(G,{as:`button`,gap:1,px:2,py:`2px`,borderRadius:`sm`,fontSize:`xs`,fontWeight:t?`semibold`:`normal`,color:t?`fg`:`fg.muted`,bg:t?`bg.emphasized`:void 0,onClick:r,children:[(0,P.jsx)(H,{as:`span`,children:e}),n!==void 0&&(0,P.jsx)(Aw,{size:`xs`,children:n})]})}var xA=`application/x-opencraw-card`;function SA(e){return JSON.stringify(e)}function CA(e){let t=e.getData(xA);if(t!==``)try{let e=JSON.parse(t);return e.kind===`card`||e.kind===`bracket`?e:void 0}catch{return}}function wA(e){return[...e.types].includes(xA)}var TA=[{label:`Go to`,stepType:`goto`,bracket:!1},{label:`Read`,stepType:`extract`,bracket:!1},{label:`Loop`,stepType:`forEach`,bracket:!0},{label:`Next page`,stepType:`paginate`,bracket:!0},{label:`If`,stepType:`if`,bracket:!0},{label:`Fill form`,stepType:`fill`,bracket:!1},{label:`Click`,stepType:`click`,bracket:!1},{label:`Set`,stepType:`set`,bracket:!1},{label:`Collect`,stepType:`collect`,bracket:!1},{label:`Emit`,stepType:`emit`,bracket:!1}];function EA(e){switch(e){case`goto`:return{type:`goto`,url:``};case`extract`:return{type:`extract`,id:`value`,selector:``,kind:`css`};case`forEach`:return{type:`forEach`,as:`item`,over:``,steps:[]};case`paginate`:return{type:`paginate`,next:{selector:``},steps:[]};case`if`:return{type:`if`,test:``,steps:[]};case`fill`:return{type:`fill`,selector:``,value:``};case`click`:return{type:`click`,selector:``};case`set`:return{type:`set`,id:`value`,value:``};case`collect`:return{type:`collect`,into:``,value:``};case`emit`:return{type:`emit`};default:return{type:e}}}var DA=[`forEach`,`paginate`,`if`];function OA(e,t){let n=EA(e),r=[{kind:`word`,text:TA.find(t=>t.stepType===e)?.label??e}],i=DA.find(t=>t===e);return i===void 0?{kind:`card`,path:t,stepType:e,sentence:r,step:n,custom:!1}:{kind:`bracket`,path:t,stepType:i,sentence:r,step:n,children:[]}}function kA({onAdd:e,ariaLabel:t}){return(0,P.jsx)(PT,{size:`xs`,width:`9em`,variant:`outline`,children:(0,P.jsxs)(IT,{"aria-label":t,value:``,onChange:t=>{let n=t.target.value;n!==``&&e(n),t.target.value=``},children:[(0,P.jsx)(`option`,{value:``,disabled:!0,children:`+ Add step`}),TA.map(e=>(0,P.jsx)(`option`,{value:e.stepType,children:e.label},e.stepType))]})})}var AA=`application/x-opencraw-pill`;function jA({name:e,draggable:t=!0}){let n=t?t=>{t.dataTransfer.setData(AA,e),t.dataTransfer.setData(`text/plain`,e),t.dataTransfer.effectAllowed=`copy`}:void 0;return(0,P.jsx)(H,{as:`span`,display:`inline-block`,px:2,py:`1px`,borderRadius:`full`,fontSize:`xs`,fontWeight:`medium`,color:`white`,bg:yO(e),draggable:t,cursor:t?`grab`:void 0,onDragStart:n,children:e})}var MA=/^\{\{env\.[A-Za-z_]\w*\}\}$/;function NA({parts:e}){return(0,P.jsx)(G,{gap:1,wrap:`wrap`,fontSize:`sm`,children:e.map((e,t)=>{let n=`${t}:${e.kind}:${e.text}`;return e.kind===`pill`?(0,P.jsx)(jA,{name:e.text},n):e.kind===`code`&&MA.test(e.text)?(0,P.jsx)(PA,{placeholder:e.text},n):e.kind===`code`?(0,P.jsx)(H,{as:`code`,fontFamily:`mono`,fontSize:`xs`,bg:`bg.muted`,px:1,borderRadius:`sm`,children:e.text},n):(0,P.jsx)(H,{color:`fg.muted`,children:e.text},n)})})}function PA({placeholder:e}){let t=e.slice(6,-2);return(0,P.jsx)(H,{as:`span`,display:`inline-block`,px:2,py:`1px`,borderRadius:`full`,fontSize:`xs`,fontFamily:`mono`,fontWeight:`medium`,color:`red.fg`,bg:`red.subtle`,borderWidth:`1px`,borderColor:`red.muted`,title:`Never the real value — set the ${t} environment variable before running this recipe.`,children:e})}function FA({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(1)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(1)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function IA(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var LA=[],RA=0,{link:zA,unlink:BA,propagate:VA,checkDirty:HA,shallowPropagate:UA}=FA({update(e){return e._update()},notify(e){LA[GA++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,YA(e))}}),WA=0,GA=0,KA,qA=0;function JA(e){try{++qA,e()}finally{--qA||XA()}}function YA(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=BA(n,e)}function XA(){if(!(qA>0)){for(;WA<GA;){let e=LA[WA];LA[WA++]=void 0,e.notify()}WA=0,GA=0}}function ZA(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return KA!==void 0&&zA(i,KA,RA),i._snapshot},subscribe(e){let t=IA(e),n={current:!1},r=QA(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=KA,o=t?.compare??Object.is;if(n)KA=i,++RA,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{KA=a,n&&(i.flags&=-5),YA(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&HA(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&UA(e)}}else e&32&&(i.flags=e&-33);return KA!==void 0&&zA(i,KA,RA),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(VA(e),UA(e),XA())}},i}function QA(e){let t=()=>{let t=KA;KA=n,++RA,n.depsTail=void 0,n.flags=6;try{return e()}finally{KA=t,n.flags&=-5,YA(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&HA(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,YA(this)}};return t(),n}var $A=class{constructor(e,t){this.atom=ZA(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(IA(e))}},ej=class{constructor(e){this.atom=ZA(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(IA(e))}};function tj(e,t){return typeof e==`function`?new ej(e):t?new $A(e,t):new $A(e)}var nj=class{constructor(e,t){this.fn=e,this.options=t,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...e)=>{let t=Date.now()-this.lastExecutionTime;if(this.options.leading&&t>=this.options.wait)this.execute(...e);else if(this.lastArgs=e,!this.timeoutId&&this.options.trailing){let e=this.options.wait-t;this.isPending=!0,this.timeoutId=setTimeout(()=>{this.lastArgs!==void 0&&this.execute(...this.lastArgs)},e)}},this.execute=(...e)=>{this.fn(...e),this.options.onExecute?.(e,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{this.isPending&&this.lastArgs&&this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{this.timeoutId&&=(clearTimeout(this.timeoutId),void 0)},this.options.leading===void 0&&this.options.trailing===void 0&&(this.options.leading=!0,this.options.trailing=!0)}};function rj(e,t){return new nj(e,t).maybeExecute}var ij=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{if(this.#c<this.#l){this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{});return}this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop()};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e){this.debugLog(`Event bus client is disabled, not emitting event`,e,t);return}if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d){this.debugLog(`Previously failed to connect, not emitting to bus`);return}if(!this.#a){this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},aj=new class extends ij{constructor(){super({pluginId:`form-devtools`,reconnectEveryMs:1e3})}};function oj(e,t){return typeof e==`function`?e(t):e}function sj(e,t){return hj(t).reduce((e,t)=>{if(e===null)return null;if(e!==void 0)return e[t]},e)}function cj(e,t,n){let r=hj(t);function i(e){if(!r.length)return oj(n,e);let t=r.shift();if(typeof t==`string`||typeof t==`number`&&!Array.isArray(e))return typeof e==`object`?(e===null&&(e={}),{...e,[t]:i(e[t])}):{[t]:i()};if(Array.isArray(e)&&typeof t==`number`){let n=e.slice(0,t);return[...n.length?n:Array(t),i(e[t]),...e.slice(t+1)]}return[...Array(t),i()]}return i(e)}function lj(e,t){let n=hj(t);function r(e){if(!e)return;if(n.length===1){let t=n[0];if(Array.isArray(e)&&typeof t==`number`)return e.filter((e,n)=>n!==t);let{[t]:r,...i}=e;return i}let t=n.shift();if((typeof t==`string`||typeof t==`number`&&!Array.isArray(e))&&typeof e==`object`)return{...e,[t]:r(e[t])};if(typeof t==`number`&&Array.isArray(e)){if(t>=e.length)return e;let n=e.slice(0,t);return[...n.length?n:Array(t),r(e[t]),...e.slice(t+1)]}throw Error(`It seems we have created an infinite loop in deleteBy. `)}return r(e)}var uj=46,dj=91,fj=93,pj=48,mj=57;function hj(e){if(Array.isArray(e))return[...e];if(typeof e!=`string`)throw Error(`Path must be a string.`);let t=e.length,n=[],r=+(t>0&&e.charCodeAt(0)===dj),i=!0,a=-1;for(let o=r;o<=t;o++){let s=o<t?e.charCodeAt(o):-1;if(o===t||s===uj||s===dj||s===fj){let t=o-r;if(t>0){let a=i&&(t===1||e.charCodeAt(r)!==pj),s=e.slice(r,o);if(a){let e=parseInt(s,10);t<=15||String(e)===s?n.push(e):n.push(s)}else n.push(s)}else a!==fj&&(a!==-1||s!==fj)&&(a!==s||s!==uj&&s!==dj)&&n.push(``);r=o+1,i=!0}else(s<pj||s>mj)&&(i=!1);a=s}return n.length||n.push(``),n}function gj(e){return!(Array.isArray(e)&&e.length===0)}function _j(e,t){return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!1},runValidation:e=>e.validators.filter(Boolean).map(e=>({cause:e.cause,validate:e.fn}))})}function vj(e,t){let{asyncDebounceMs:n}=t,{onBlurAsyncDebounceMs:r,onChangeAsyncDebounceMs:i,onDynamicAsyncDebounceMs:a}=t.validators||{},o=n??0;return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!0},runValidation:t=>t.validators.filter(Boolean).map(t=>{let n=t?.cause||e,s=o;switch(n){case`change`:s=i??o;break;case`blur`:s=r??o;break;case`dynamic`:s=a??o;break;case`submit`:s=0}return e===`submit`&&(s=0),{cause:n,validate:t.fn,debounceMs:s}})})}var yj=e=>!!e&&typeof e==`object`&&`fields`in e;function bj(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length||n.length===0&&!Array.isArray(e)&&!Array.isArray(t)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype))return!1;for(let i of n)if(!r.includes(i)||!bj(e[i],t[i]))return!1;return!0}var xj=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:n})=>e?{newErrorValue:e,newSource:`form`}:t?{newErrorValue:void 0,newSource:void 0}:n?{newErrorValue:n,newSource:`field`}:{newErrorValue:void 0,newSource:void 0},Sj=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:`field`}:e?{newErrorValue:e,newSource:`form`}:{newErrorValue:void 0,newSource:void 0};function Cj(e,t){return e==null?t:{...e,...t}}for(var wj=256,Tj=[],Ej;wj--;)Tj[wj]=(wj+256).toString(16).substring(1);function Dj(){let e=0,t,n=``;if(!Ej||wj+16>256){for(Ej=Array(256),e=256;e--;)Ej[e]=256*Math.random()|0;e=0,wj=0}for(;e<16;e++)t=Ej[wj+e],n+=e===6?Tj[t&15|64]:e===8?Tj[t&63|128]:Tj[t],e&1&&e>1&&e<11&&(n+=`-`);return wj++,n}var Oj=rj(e=>aj.emit(`form-state`,{id:e.formId,state:e.store.state}),{wait:300});function kj(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++)t[n]=kj(e[n]);return t}if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(n,kj(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(kj(e))}),t}let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=kj(e[n]));return t}function Aj(e,t){return t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}[`)}var jj=e=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let t=e.event.async,n=t?void 0:{fn:e.validators.onMount,cause:`mount`},r={fn:t?e.validators.onChangeAsync:e.validators.onChange,cause:`change`},i={fn:t?e.validators.onBlurAsync:e.validators.onBlur,cause:`blur`},a={fn:t?e.validators.onSubmitAsync:e.validators.onSubmit,cause:`submit`},o=t?void 0:{fn:()=>void 0,cause:`server`};switch(e.event.type){case`mount`:return e.runValidation({validators:[n],form:e.form});case`submit`:return e.runValidation({validators:[r,i,a,o],form:e.form});case`server`:return e.runValidation({validators:[],form:e.form});case`blur`:return e.runValidation({validators:[i,o],form:e.form});case`change`:return e.runValidation({validators:[r,o],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function Mj(e,t){let n=new Map;for(let r of e){let e=r.path??[],i=t,a=``;for(let t=0;t<e.length;t++){let n=e[t];if(n===void 0)continue;let r=typeof n==`object`?n.key:n,o=Number(r);a+=Array.isArray(i)&&!Number.isNaN(o)?`[${o}]`:(t>0?`.`:``)+String(r),i=typeof i==`object`&&i?i[r]:void 0}n.set(a,(n.get(a)??[]).concat(r))}return Object.fromEntries(n)}var Nj=(e,t)=>{let n=Mj(e,t);return{form:n,fields:n}},Pj={validate({value:e,validationSource:t},n){let r=n[`~standard`].validate(e);if(r instanceof Promise)throw Error(`async function passed to sync validator`);if(r.issues)return t===`field`?r.issues:Nj(r.issues,e)},async validateAsync({value:e,validationSource:t},n){let r=await n[`~standard`].validate(e);if(r.issues)return t===`field`?r.issues:Nj(r.issues,e)}},Fj=e=>!!e&&`~standard`in e,Ij={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function Lj(e){function t(t){let n=e.getFieldMeta(t)??Ij;e.setFieldMeta(t,{...n,_arrayVersion:(n._arrayVersion||0)+1})}function n(n,r,i){t(n);let a=s(n,r,`move`,i),c=Math.min(r,i),u=Math.max(r,i);for(let e=c;e<=u;e++)a.push(o(n,e));let d=Object.keys(e.fieldInfo).reduce((t,i)=>(i.startsWith(o(n,r))&&t.set(i,e.getFieldMeta(i)),t),new Map);l(a,r<i?`up`:`down`),Object.keys(e.fieldInfo).filter(e=>e.startsWith(o(n,i))).forEach(t=>{let a=t.replace(o(n,i),o(n,r)),s=d.get(a);s&&e.setFieldMeta(t,s)})}function r(e,n){t(e),l(s(e,n,`remove`),`up`)}function i(n,r,i){t(n),s(n,r,`swap`,i).forEach(t=>{if(!t.toString().startsWith(o(n,r)))return;let a=t.toString().replace(o(n,r),o(n,i)),[s,c]=[e.getFieldMeta(t),e.getFieldMeta(a)];s&&e.setFieldMeta(a,s),c&&e.setFieldMeta(t,c)})}function a(n,r){t(n);let i=s(n,r,`insert`);l(i,`down`),i.forEach(t=>{t.toString().startsWith(o(n,r))&&e.setFieldMeta(t,u())})}function o(e,t){return`${e}[${t}]`}function s(t,n,r,i){let a=[o(t,n)];switch(r){case`swap`:a.push(o(t,i));break;case`move`:{let[e,r]=[Math.min(n,i),Math.max(n,i)];for(let n=e;n<=r;n++)a.push(o(t,n));break}default:{let r=e.getFieldValue(t),i=Array.isArray(r)?r.length:0;for(let e=n+1;e<i;e++)a.push(o(t,e));break}}return Object.keys(e.fieldInfo).filter(e=>a.some(t=>e.startsWith(t)))}function c(e,t){return e.replace(/\[(\d+)\]/,(e,n)=>{let r=parseInt(n,10);return`[${t===`up`?r+1:Math.max(0,r-1)}]`})}function l(t,n){(n===`up`?t:[...t].reverse()).forEach(t=>{let r=c(t.toString(),n),i=e.getFieldMeta(r);i?e.setFieldMeta(t,i):e.setFieldMeta(t,u())})}let u=()=>Ij;return{bumpArrayVersion:t,handleArrayMove:n,handleArrayRemove:r,handleArraySwap:i,handleArrayInsert:a}}function Rj(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}var zj=class{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let e=this.store.subscribe(()=>{Oj(this)}),t=aj.on(`request-form-state`,e=>{e.payload.id===this._formId&&aj.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}),n=aj.on(`request-form-reset`,e=>{e.payload.id===this._formId&&this.reset()}),r=aj.on(`request-form-force-submit`,e=>{e.payload.id===this._formId&&(this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1)}),i=()=>{r(),n(),t(),e.unsubscribe(),aj.emit(`form-unmounted`,{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:a}=this.options.validators||{};return aj.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options}),a&&this.validateSync(`mount`),i},this.update=e=>{if(!e)return;let t=this.options;this.options=e;let n=e.defaultValues&&!bj(e.defaultValues,t.defaultValues)&&!this.state.isTouched,r=!bj(e.defaultState,t.defaultState)&&!this.state.isTouched;if(n||r){if(JA(()=>{this.baseStore.setState(()=>Rj(Object.assign({},this.state,r?e.defaultState:{},n?{values:e.defaultValues}:{})))}),n){let e=Lj(this);for(let t of Object.keys(this.fieldInfo))Array.isArray(this.getFieldValue(t))&&e.bumpArrayVersion(t)}aj.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}},this.reset=(e,t)=>{let{fieldMeta:n}=this.state,r=this.resetFieldMeta(n);e&&!t?.keepDefaultValues&&(this.options={...this.options,defaultValues:e}),this.baseStore.setState(()=>{let t=e??this.options.defaultValues??this.options.defaultState?.values;return e||Object.values(this.fieldInfo).forEach(e=>{e.instance&&e.instance.options.defaultValue!==void 0&&(t=cj(t,e.instance.name,e.instance.options.defaultValue))}),Rj({...this.options.defaultState,values:t,fieldMetaBase:r})})},this.validateAllFields=async e=>{let t=[];return JA(()=>{Object.values(this.fieldInfo).forEach(n=>{if(!n.instance)return;let r=n.instance;t.push(Promise.resolve().then(()=>r.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.instance.store.state.meta.isTouched||n.instance.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null,a=[`${e}[${t}]`];for(let n=t+1;n<=(i??0);n++)a.push(`${e}[${n}]`);let o=Object.keys(this.fieldInfo).filter(e=>a.some(t=>e.startsWith(t))),s=[];return JA(()=>{o.forEach(e=>{s.push(Promise.resolve().then(()=>this.validateField(e,n)))})}),(await Promise.all(s)).flat()},this.validateField=(e,t)=>{let n=this.fieldInfo[e]?.instance;if(!n){let{hasErrored:n}=this.validateSync(t);return n&&!this.options.asyncAlways?this.getFieldMeta(e)?.errors??[]:this.validateAsync(t).then(()=>this.getFieldMeta(e)?.errors??[])}return n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0})),n.validate(t)},this.validateSync=(e,t)=>{let n=_j(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||jj}),r=!1,i={};return JA(()=>{for(let e of n){if(!e.validate)continue;let{formError:n,fieldErrors:a}=Bj(this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`},type:`validate`})),o=Vj(e.cause),s=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(a||{})]);t?.filterFieldNames&&(s=new Set([...s].filter(t.filterFieldNames)));for(let e of s){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!a?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??Ij,r=a?.[e],{newErrorValue:s,newSource:c}=xj({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[o]===`form`,previousErrorValue:t?.[o]});c===`form`&&(i[e]={...i[e],[o]:r}),t?.[o]!==s&&this.setFieldMeta(e,(e=Ij)=>({...e,errorMap:{...e.errorMap,[o]:s},errorSourceMap:{...e.errorSourceMap,[o]:c}}))}t?.dontUpdateFormErrorMap||this.state.errorMap?.[o]!==n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:n}})),(n||a)&&(r=!0)}if(t?.dontUpdateFormErrorMap)return;let a=Vj(`submit`);this.state.errorMap?.[a]&&e!==`submit`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}));let o=Vj(`server`);this.state.errorMap?.[o]&&e!==`server`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:void 0}}))}),{hasErrored:r,fieldsErrorMap:i}},this.validateAsync=async(e,t)=>{let n=vj(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||jj});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));let r=[],i;for(let e of n){if(!e.validate)continue;let n=Vj(e.cause);this.state.validationMetaMap[n]?.lastAbortController.abort();let a=new AbortController;this.state.validationMetaMap[n]={lastAbortController:a},r.push(new Promise(async n=>{let r;try{r=await new Promise((t,n)=>{setTimeout(async()=>{if(a.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`,signal:a.signal},type:`validateAsync`}))}catch(e){n(e)}},e.debounceMs)})}catch(e){r=e}let{formError:o,fieldErrors:s}=Bj(r);s&&(i=i?{...i,...s}:s);let c=Vj(e.cause),l=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(i||{})]),u=Array.from(l);t?.filterFieldNames&&(u=u.filter(t.filterFieldNames));for(let e of u){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!i?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??Ij,r=i?.[e],{newErrorValue:a,newSource:o}=xj({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[c]===`form`,previousErrorValue:t?.[c]});t?.[c]!==a&&this.setFieldMeta(e,(e=Ij)=>({...e,errorMap:{...e.errorMap,[c]:a},errorSourceMap:{...e.errorSourceMap,[c]:o}}))}t?.dontUpdateFormErrorMap||this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[c]:o}})),n(i?{fieldErrors:i,errorMapKey:c}:void 0)}))}let a=[],o={};if(r.length){a=await Promise.all(r);for(let e of a)if(e?.fieldErrors){let{errorMapKey:t}=e;for(let[n,r]of Object.entries(e.fieldErrors))o[n]={...o[n]||{},[t]:r}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),o},this.validate=(e,t)=>{let{hasErrored:n,fieldsErrorMap:r}=this.validateSync(e,t);return n&&!this.options.asyncAlways?r:this.validateAsync(e,t)},this._handleSubmit=async e=>{this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),JA(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.store.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})});let t=e??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride&&this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t});return}this.baseStore.setState(e=>({...e,isSubmitting:!0}));let n=()=>{this.baseStore.setState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.state.isFieldsValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),aj.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validateAllFields`,errors:Object.values(this.state.fieldMeta).map(e=>e.errors).flat()});return}if(await this.validate(`submit`),!this.state.isValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),aj.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validate`,errors:this.state.errors});return}JA(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t}),JA(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),aj.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),n()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),aj.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`inflight`,onError:e}),n(),e}},this.getFieldValue=e=>sj(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[e],this.getFormGroupMeta=e=>this.formGroupMetaDerived.state[e],this.getFieldInfo=e=>this.fieldInfo[e]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(e,t)=>{this.baseStore.setState(n=>({...n,fieldMetaBase:{...n.fieldMetaBase,[e]:oj(t,n.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>{let n=t;return e[n]=Ij,e},{}),this.setFieldValue=(e,t,n)=>{let r=n?.dontUpdateMeta??!1,i=n?.dontRunListeners??!1,a=n?.dontValidate??!1;JA(()=>{r||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(n=>({...n,values:cj(n.values,e,t)}))}),i||this.getFieldInfo(e).instance?.triggerOnChangeListener(),a||this.validateField(e,`change`)},this.deleteField=e=>{let t=[...Object.keys(this.fieldInfo).filter(t=>{let n=e.toString();return t.startsWith(`${n}.`)||t.startsWith(`${n}[`)}),e];this.baseStore.setState(e=>{let n={...e};return t.forEach(e=>{n.values=lj(n.values,e),delete this.fieldInfo[e],delete n.fieldMetaBase[e]}),n})},this.pushFieldValue=(e,t,n)=>{this.setFieldValue(e,e=>[...Array.isArray(e)?e:[],t],n),Lj(this).bumpArrayVersion(e)},this.insertFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>[...e.slice(0,t),n,...e.slice(t)],Cj(r,{dontValidate:!0}));let i=r?.dontValidate??!1;i||await this.validateField(e,`change`),Lj(this).handleArrayInsert(e,t),i||await this.validateArrayFieldsStartingFrom(e,t,`change`)},this.replaceFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>e.map((e,r)=>r===t?n:e),Cj(r,{dontValidate:!0})),Lj(this).bumpArrayVersion(e),(r?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.removeFieldValue=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null;if(this.setFieldValue(e,e=>e.filter((e,n)=>n!==t),Cj(n,{dontValidate:!0})),Lj(this).handleArrayRemove(e,t),i!==null){let t=`${e}[${i}]`;this.deleteField(t)}(n?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.swapFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=e[t],i=e[n];return cj(cj(e,`${t}`,i),`${n}`,r)},Cj(r,{dontValidate:!0})),Lj(this).handleArraySwap(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.moveFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=[...e];return r.splice(n,0,r.splice(t,1)[0]),r},Cj(r,{dontValidate:!0})),Lj(this).handleArrayMove(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.clearFieldValues=(e,t)=>{let n=this.getFieldValue(e),r=Array.isArray(n)?Math.max(n.length-1,0):null;if(this.setFieldValue(e,[],Cj(t,{dontValidate:!0})),Lj(this).bumpArrayVersion(e),r!==null)for(let t=0;t<=r;t++){let n=`${e}[${t}]`;this.deleteField(n)}(t?.dontValidate??!1)||this.validateField(e,`change`)},this.resetField=e=>{this.baseStore.setState(t=>{let n=this.getFieldInfo(e).instance?.options.defaultValue,r=sj(this.options.defaultValues,e),i=n??r;return{...t,fieldMetaBase:{...t.fieldMetaBase,[e]:Ij},values:i===void 0?t.values:cj(t.values,e,i)}})},this.setErrorMap=e=>{JA(()=>{Object.entries(e).forEach(([e,t])=>{let n=e;if(yj(t)){let{formError:e,fieldErrors:r}=Bj(t);for(let e of Object.keys(this.fieldInfo))this.getFieldMeta(e)&&this.setFieldMeta(e,t=>({...t,errorMap:{...t.errorMap,[n]:r?.[e]},errorSourceMap:{...t.errorSourceMap,[n]:`form`}}));this.baseStore.setState(t=>({...t,errorMap:{...t.errorMap,[n]:e}}))}else this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[n]:t}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((e,[t,n])=>(Object.keys(n).length&&n.errors.length&&(e[t]={errors:n.errors,errorMap:n.errorMap}),e),{})}),this.parseValuesWithSchema=e=>Pj.validate({value:this.state.values,validationSource:`form`},e),this.parseValuesWithSchemaAsync=e=>Pj.validateAsync({value:this.state.values,validationSource:`form`},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??Dj(),this._devtoolsSubmissionOverride=!1;let t=Rj({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){t=e.transform({state:t}).state;for(let e of Object.keys(t.errorMap)){let n=t.errorMap[e];if(n!==void 0&&yj(n))for(let r of Object.keys(n.fields)){let i=n.fields[r];if(i===void 0)continue;let a=t.fieldMetaBase[r];t.fieldMetaBase[r]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...a??{},errorSourceMap:{...a?.errorSourceMap??{},onChange:`form`},errorMap:{...a?.errorMap??{},[e]:i}}}}}this.baseStore=tj(t);let n;this.fieldMetaDerived=tj(e=>{let t=this.baseStore.get(),r=0,i={};for(let a of Object.keys(t.fieldMetaBase)){let o=t.fieldMetaBase[a],s=n?.fieldMetaBase[a],c=e?.[a],l=sj(t.values,a),u=c?.errors;if(!s||o.errorMap!==s.errorMap){u=Object.values(o.errorMap??{}).filter(e=>e!==void 0);let e=this.getFieldInfo(a)?.instance;(!e||!e.options.disableErrorFlat)&&(u=u.flat(1))}let d=!gj(u),f=!o.isDirty,p=bj(l,this.getFieldInfo(a)?.instance?.options.defaultValue??sj(this.options.defaultValues,a));if(c&&c.isPristine===f&&c.isValid===d&&c.isDefaultValue===p&&c.errors===u&&o===s){i[a]=c,r++;continue}i[a]={...o,errors:u??[],isPristine:f,isValid:d,isDefaultValue:p}}return Object.keys(t.fieldMetaBase).length?e&&r===Object.keys(t.fieldMetaBase).length?e:(n=this.baseStore.get(),i):i}),this.formGroupMetaDerived=tj(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),r={};for(let i of this.formGroupApis){let a=i.name,o=t.formGroupStateBase[a]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},s=n[a],c=!1,l=!0,u=!1,d=!1,f=!0,p=!1;for(let e in n){if(e===a||!Aj(a,e))continue;let t=n[e];t&&(t.isValidating&&(c=!0),t.isValid||(l=!1),t.isTouched&&(u=!0),t.isBlurred&&(d=!0),t.isDefaultValue||(f=!1),t.isDirty&&(p=!0))}let m=!p,h=!!c||o.isValidating,g=s?.errorMap??{},_=s?.errorSourceMap??{},v=!!(g.onMount||Object.entries(n).some(([e,t])=>t&&e!==a&&Aj(a,e)&&t.errorMap.onMount)),y=e?.[a],b=y?.errors??[];(!y||y.__srcErrorMap!==g)&&(b=Object.values(g).reduce((e,t)=>{if(t===void 0)return e;if(t&&typeof t==`object`&&`fields`in t){let n=t.group;return n!==void 0&&e.push(n),e}return e.push(t),e},[]));let x=b.length===0,S=l&&x,C=i.options.canSubmitWhenInvalid??!1,w=o.submissionAttempts===0&&!u&&!v||!h&&!o.isSubmitting&&S||C;if(y&&y.errorMap===g&&y.errorSourceMap===_&&y.errors===b&&y.isFieldsValidating===c&&y.isFieldsValid===l&&y.isGroupValid===x&&y.isValid===S&&y.canSubmit===w&&y.isTouched===u&&y.isBlurred===d&&y.isPristine===m&&y.isDefaultValue===f&&y.isDirty===p&&y.isValidating===h&&y.isSubmitting===o.isSubmitting&&y.isSubmitted===o.isSubmitted&&y.submissionAttempts===o.submissionAttempts&&y.isSubmitSuccessful===o.isSubmitSuccessful){r[a]=y;continue}let T={...o,errorMap:g,errorSourceMap:_,_arrayVersion:s?._arrayVersion??0,isTouched:u,isBlurred:d,isDirty:p,isPristine:m,isDefaultValue:f,isValid:S,errors:b,isValidating:h,isFieldsValidating:c,isFieldsValid:l,isGroupValid:x,canSubmit:w};Object.defineProperty(T,"__srcErrorMap",{value:g,enumerable:!1,configurable:!0}),r[a]=T}return r});let r;this.store=tj(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),i=Object.values(n).filter(Boolean),a=i.some(e=>e.isValidating),o=i.every(e=>e.isValid),s=i.some(e=>e.isTouched),c=i.some(e=>e.isBlurred),l=i.every(e=>e.isDefaultValue),u=s&&t.errorMap?.onMount,d=i.some(e=>e.isDirty),f=!d,p=!!(t.errorMap?.onMount||i.some(e=>e?.errorMap?.onMount)),m=!!a,h=e?.errors??[];(!r||t.errorMap!==r.errorMap)&&(h=Object.values(t.errorMap).reduce((e,t)=>t===void 0?e:t&&yj(t)?(e.push(t.form),e):(e.push(t),e),[]));let g=h.length===0,_=o&&g,v=this.options.canSubmitWhenInvalid??!1,y=t.submissionAttempts===0&&!s&&!p||!m&&!t.isSubmitting&&_||v,b=t.errorMap;if(u&&(h=h.filter(e=>e!==t.errorMap.onMount),b=Object.assign(b,{onMount:void 0})),e&&r&&e.errorMap===b&&e.fieldMeta===this.fieldMetaDerived.state&&e.errors===h&&e.isFieldsValidating===a&&e.isFieldsValid===o&&e.isFormValid===g&&e.isValid===_&&e.canSubmit===y&&e.isTouched===s&&e.isBlurred===c&&e.isPristine===f&&e.isDefaultValue===l&&e.isDirty===d&&bj(r,t))return e;let x={...t,errorMap:b,fieldMeta:this.fieldMetaDerived.state,errors:h,isFieldsValidating:a,isFieldsValid:o,isFormValid:g,isValid:_,canSubmit:y,isTouched:s,isBlurred:c,isPristine:f,isDefaultValue:l,isDirty:d};return r=this.baseStore.get(),x}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){return Fj(e.validate)?Pj[e.type](e.value,e.validate):e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function Bj(e){return e?yj(e)?{formError:Bj(e.form).formError,fieldErrors:e.fields}:{formError:e}:{formError:void 0}}function Vj(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}var Hj=class e{constructor(t){this.options={},this.mount=()=>{this.options.defaultValue!==void 0&&!this.getMeta().isTouched&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let e=this.getInfo();e.instance=this,this.update(this.options);let{onMount:t}=this.options.validators||{};if(t){let e=this.runValidator({validate:t,value:{value:this.state.value,fieldApi:this,validationSource:`field`},type:`validate`});e&&this.setMeta(t=>({...t,errorMap:{...t?.errorMap,onMount:e},errorSourceMap:{...t?.errorSourceMap,onMount:`field`}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);let e=this.form.fieldInfo[this.name];if(e&&e.instance===this){for(let[t,n]of Object.entries(e.validationMetaMap))n?.lastAbortController.abort(),e.validationMetaMap[t]=void 0;this.form.baseStore.setState(e=>({...e,fieldMetaBase:{...e.fieldMetaBase,[this.name]:{...Ij,isTouched:e.fieldMetaBase[this.name]?.isTouched??Ij.isTouched,isBlurred:e.fieldMetaBase[this.name]?.isBlurred??Ij.isBlurred,isDirty:e.fieldMetaBase[this.name]?.isDirty??Ij.isDirty}}})),e.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}}},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(bj(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,Cj(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(e,t)=>{this.form.pushFieldValue(this.name,e,Cj(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,n)=>{this.form.insertFieldValue(this.name,e,t,Cj(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,n)=>{this.form.replaceFieldValue(this.name,e,t,Cj(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,Cj(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,n)=>{this.form.swapFieldValues(this.name,e,t,Cj(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,n)=>{this.form.moveFieldValues(this.name,e,t,Cj(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,Cj(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=t=>{let n=Object.values(this.form.fieldInfo),r=[];for(let i of n){if(!i.instance||!(i.instance instanceof e))continue;let{onChangeListenTo:n,onBlurListenTo:a}=i.instance.options.validators||{};t===`change`&&n?.includes(this.name)&&r.push(i.instance),t===`blur`&&a?.includes(this.name)&&r.push(i.instance)}return r},this.validateSync=(e,t)=>{let n=_j(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||jj}),r=this.getLinkedFields(e).reduce((t,n)=>{let r=_j(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||jj});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),i=!1;JA(()=>{let e=(e,n)=>{let r=Wj(n.cause),a=n.validate?Uj(e.runValidator({validate:n.validate,value:{value:e.store.state.value,validationSource:`field`,fieldApi:e},type:`validate`})):void 0,o=t[r],{newErrorValue:s,newSource:c}=Sj({formLevelError:o,fieldLevelError:a});e.state.meta.errorMap?.[r]!==s&&e.setMeta(e=>({...e,errorMap:{...e.errorMap,[r]:s},errorSourceMap:{...e.errorSourceMap,[r]:c}})),s&&(i=!0)};for(let t of n)e(this,t);for(let t of r)t.validate&&e(t.field,t)});let a=Wj(`submit`);return this.state.meta.errorMap?.[a]&&e!==`submit`&&!i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[a]:void 0},errorSourceMap:{...e.errorSourceMap,[a]:void 0}})),{hasErrored:i}},this.validateAsync=async(e,t)=>{let n=vj(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||jj}),r=await t,i=this.getLinkedFields(e).reduce((t,n)=>{let r=vj(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||jj});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),a=[],o=[],s=n.some(e=>e.validate),c=Array.from(new Set(i.filter(e=>e.validate).map(e=>e.field)));JA(()=>{s&&this.startValidation();for(let e of c)e.startValidation()});let l=(e,t,n)=>{let i=Wj(t.cause),a=e.getInfo();a.validationMetaMap[i]?.lastAbortController.abort();let o=new AbortController;a.validationMetaMap[i]={lastAbortController:o},n.push(new Promise(async n=>{let a;try{a=await new Promise((n,r)=>{e.timeoutIds.validations[t.cause]&&(clearTimeout(e.timeoutIds.validations[t.cause]),e.endValidation()),e.timeoutIds.validations[t.cause]=setTimeout(async()=>{if(o.signal.aborted)return n(void 0);try{n(await this.runValidator({validate:t.validate,value:{value:e.store.state.value,fieldApi:e,signal:o.signal,validationSource:`field`},type:`validateAsync`}))}catch(e){r(e)}},t.debounceMs)})}catch(e){a=e}if(o.signal.aborted)return n(void 0);let s=Uj(a),c=r[e.name]?.[i],{newErrorValue:l,newSource:u}=Sj({formLevelError:c,fieldLevelError:s});if(e.getInfo().instance!==e)return n(void 0);e.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:l},errorSourceMap:{...e.errorSourceMap,[i]:u}})),n(l)}))};for(let e of n)e.validate&&l(this,e,a);for(let e of i)e.validate&&l(e.field,e,o);let u=[];return(a.length||o.length)&&(u=await Promise.all(a),await Promise.all(o)),JA(()=>{s&&this.endValidation();for(let e of c)e.endValidation()}),u.filter(Boolean)},this.validate=(e,t)=>{if(!this.state.meta.isTouched)return[];let n=t?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter(e=>this.name.startsWith(e.name)),r=(t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e)).fieldsErrorMap[this.name]??{};if(!t?.skipFormValidation)for(let t of n){if(t.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:n}=this.form.validateSync(e,{group:t,dontUpdateFormErrorMap:!0,filterFieldNames:e=>Aj(t.name,e)});r={...r,...n[this.name]??{}}}let{hasErrored:i}=this.validateSync(e,r),a=new WeakMap;for(let t of n){let{hasErrored:n}=t.validateSync(e,{},{skipRelatedFieldValidation:!0});a.set(t,n)}if(i&&!this.options.asyncAlways){this.getInfo().validationMetaMap[Wj(e)]?.lastAbortController.abort();let t=[];for(let r of n)r.getInfo().validationMetaMap[Wj(e)]?.lastAbortController.abort(),t.push(r.state.meta.errors);return[...this.state.meta.errors,...t.flat()]}let o=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e),s=this.validateAsync(e,o),c=[];for(let t of n)(!a.get(t)||t.options.asyncAlways)&&c.push(t.validateAsync(e,o,{skipRelatedFieldValidation:!0}));return c.length===0?s:Promise.all([s,...c]).then(e=>e.flat())},this.handleChange=e=>{this.setValue(e)},this.handleBlur=()=>{this.state.meta.isTouched||this.setMeta(e=>({...e,isTouched:!0})),this.state.meta.isBlurred||this.setMeta(e=>({...e,isBlurred:!0})),this.validate(`blur`),this.triggerOnBlurListener()},this.setErrorMap=e=>{this.setMeta(t=>({...t,errorMap:{...t.errorMap,...e}}))},this.parseValueWithSchema=e=>Pj.validate({value:this.state.value,validationSource:`field`},e),this.parseValueWithSchemaAsync=e=>Pj.validateAsync({value:this.state.value,validationSource:`field`},e),this.triggerOnBlurListener=()=>{let e=this.form.options.listeners?.onBlurDebounceMs;e&&e>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onBlurDebounceMs;t&&t>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let e of this.form.formGroupApis)Aj(e.name,this.name)&&e.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=tj(e=>{this.form.store.get();let n=this.form.getFieldMeta(this.name)??{...Ij,...t.defaultMeta},r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!bj(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}})}get state(){return this.store.state}runValidator(e){return Fj(e.validate)?Pj[e.type](e.value,e.validate):e.validate(e.value)}startValidation(){this.setMeta(e=>{let t=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:t,isValidating:t>0&&!e.isValidating||e.isValidating}})}endValidation(){this.setMeta(e=>{let t=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:t,isValidating:t===0&&e.isValidating?!1:e.isValidating}})}};function Uj(e){if(e)return e}function Wj(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function Gj(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function Kj(e){return{...Ij,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}var qj=class e{constructor(t){this.options={},this.setFormGroupState=e=>{this.form.baseStore.setState(t=>{let n=t.formGroupStateBase[this.name]??Gj({});return{...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:e(n)}}})},this._lastDistributedFieldNames={},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(bj(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,{...Ij,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:e.formGroupStateBase[this.name]??Gj({...this.options.defaultState})}}));let{onMount:e}=this.options.validators||{};if(e){let t=this.runValidator({validate:e,value:{value:this.state.value,groupApi:this,validationSource:`form`},type:`validate`}),n=t,r;Yj(t)&&(n=t.group,r=t.fields);let i=Jj(n);i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,onMount:i},errorSourceMap:{...e.errorSourceMap,onMount:`field`}})),this.distributeFieldErrors(`onMount`,r)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);if(this.fieldInfo.instance===this){for(let[e,t]of Object.entries(this.fieldInfo.validationMetaMap))t?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[e]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:Gj({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}}},this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,Cj(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let e=Object.values(this.form.fieldInfo),t=[];for(let n of e)n.instance&&n.instance instanceof Hj&&n.instance.name.startsWith(this.name)&&t.push(n.instance);return t},this.getRelatedFieldMetasDerived=()=>{let e=Object.entries(this.form.fieldMetaDerived.state),t=[];for(let[n,r]of e)n!==this.name&&Aj(this.name,n)&&t.push({...r,name:n});return t},this.buildChildFieldName=e=>e===``?this.name:e.startsWith(`[`)?`${this.name}${e}`:`${this.name}.${e}`,this.distributeFieldErrors=(e,t)=>{let n=this._lastDistributedFieldNames[e]??new Set,r=new Set;if(t)for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.add(this.buildChildFieldName(e));let i=new Set([...n,...r]),a=!1;for(let n of i){let r=n.startsWith(this.name+`[`)?n.slice(this.name.length):n.slice(this.name.length+1),i=t?.[r],o=this.form.getFieldMeta(n);if(!o&&!i)continue;let s=o?.errorMap[e],{newErrorValue:c,newSource:l}=xj({newFormValidatorError:i,isPreviousErrorFromFormValidator:o?.errorSourceMap[e]===`form`,previousErrorValue:s});c&&(a=!0),(s!==c||o?.errorSourceMap[e]!==l)&&this.form.setFieldMeta(n,(t=Ij)=>({...t,errorMap:{...t.errorMap,[e]:c},errorSourceMap:{...t.errorSourceMap,[e]:l}}))}return this._lastDistributedFieldNames[e]=r,a},this.validateSync=(t,n,r={})=>{let i=_j(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||jj}),a=(r.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((e,n)=>{let r=_j(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||jj});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),o=!1;JA(()=>{let t=(t,r)=>{let i=Zj(r.cause),a=t===this,s;r.validate&&(s=t.runValidator({validate:r.validate,value:{value:t.store.state.value,validationSource:a?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validate`}));let c=s,l;a&&Yj(s)&&(c=s.group,l=s.fields);let u=Jj(c),d=n[i],{newErrorValue:f,newSource:p}=Sj({formLevelError:d,fieldLevelError:u});t.state.meta.errorMap?.[i]!==f&&t.setMeta(e=>({...e,errorMap:{...e.errorMap,[i]:f},errorSourceMap:{...e.errorSourceMap,[i]:p}})),f&&(o=!0),a&&this.distributeFieldErrors(i,l)&&(o=!0)};for(let e of i)t(this,e);for(let e of a)e.validate&&t(e.field,e)});let s=Zj(`submit`);return this.state.meta.errorMap?.[s]&&t!==`submit`&&!o&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[s]:void 0},errorSourceMap:{...e.errorSourceMap,[s]:void 0}})),{hasErrored:o}},this.validateAsync=async(t,n,r={})=>{let i=vj(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||jj}),a=await n,o=r.skipRelatedFieldValidation?[]:this.getRelatedFields(),s=o.reduce((e,n)=>{let r=vj(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||jj});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),c=[],l=[],u=i.some(e=>e.validate)||s.some(e=>e.validate);if(u){this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(let e of o)e.setMeta(e=>({...e,isValidating:!0}))}let d=(t,n,r)=>{let i=Zj(n.cause),o=t.getInfo();o.validationMetaMap[i]?.lastAbortController.abort();let s=new AbortController;o.validationMetaMap[i]={lastAbortController:s};let c=t===this;r.push(new Promise(async r=>{let o;try{o=await new Promise((r,i)=>{t.timeoutIds.validations[n.cause]&&clearTimeout(t.timeoutIds.validations[n.cause]),t.timeoutIds.validations[n.cause]=setTimeout(async()=>{if(s.signal.aborted)return r(void 0);try{r(await this.runValidator({validate:n.validate,value:{value:t.store.state.value,signal:s.signal,validationSource:c?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validateAsync`}))}catch(e){i(e)}},n.debounceMs)})}catch(e){o=e}if(s.signal.aborted)return r(void 0);let l=o,u;c&&Yj(o)&&(l=o.group,u=o.fields);let d=Jj(l),f=a[t.name]?.[i],{newErrorValue:p,newSource:m}=Sj({formLevelError:f,fieldLevelError:d});if(t.getInfo().instance!==t)return r(void 0);t.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:p},errorSourceMap:{...e.errorSourceMap,[i]:m}})),c&&this.distributeFieldErrors(i,u),r(p)}))};for(let e of i)e.validate&&d(this,e,c);for(let e of s)e.validate&&d(e.field,e,l);let f=[];if((c.length||l.length)&&(f=await Promise.all(c),await Promise.all(l)),u){this.setMeta(e=>({...e,isValidating:!1}));for(let e of o)e.setMeta(e=>({...e,isValidating:!1}))}return f.filter(Boolean)},this.validateAllFields=async e=>{let t=[];return JA(()=>{Object.values(this.getRelatedFields()).forEach(n=>{t.push(Promise.resolve().then(()=>n.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=(e,t,n)=>this.form.validateArrayFieldsStartingFrom(e,t,n),this.validateField=(e,t)=>this.form.validateField(e,t),this.getFieldValue=e=>this.form.getFieldValue(e),this.getFieldMeta=e=>this.form.getFieldMeta(e),this.setFieldMeta=(e,t)=>this.form.setFieldMeta(e,t),this.setFieldValue=(e,t)=>this.form.setFieldValue(e,t),this.deleteField=e=>this.form.deleteField(e),this.pushFieldValue=(e,t)=>this.form.pushFieldValue(e,t),this.insertFieldValue=(e,t,n)=>this.form.insertFieldValue(e,t,n),this.replaceFieldValue=(e,t,n)=>this.form.replaceFieldValue(e,t,n),this.swapFieldValues=(e,t,n)=>this.form.swapFieldValues(e,t,n),this.moveFieldValues=(e,t,n)=>this.form.moveFieldValues(e,t,n),this.clearFieldValues=e=>this.form.clearFieldValues(e),this.resetField=e=>this.form.resetField(e),this.removeFieldValue=(e,t)=>this.form.removeFieldValue(e,t),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every(e=>e.state.meta.isValid),this.validate=(e,t)=>{let{fieldsErrorMap:n}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>Aj(this.name,e)}),{hasErrored:r}=this.validateSync(e,n[this.name]??{},{skipRelatedFieldValidation:t?.skipRelatedFieldValidation});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[Zj(e)]?.lastAbortController.abort(),this.state.meta.errors;let i=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>Aj(this.name,e)});return this.validateAsync(e,i,{skipRelatedFieldValidation:t?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeGroupDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},e)):this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async e=>{this.setFormGroupState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),JA(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.state.meta.isTouched||e.setMeta(e=>({...e,isTouched:!0}))})});let t=e??this.options.onSubmitMeta;this.setFormGroupState(e=>({...e,isSubmitting:!0}));let n=()=>{this.setFormGroupState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.areRelatedFieldsValid()){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}if(await this.validate(`submit`,{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}JA(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.options.listeners?.onGroupSubmit?.({value:e.state.value,fieldApi:e})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:t}),JA(()=>{this.setFormGroupState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),n()})}catch(e){throw this.setFormGroupState(e=>({...e,isSubmitSuccessful:!1})),n(),e}},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=tj(e=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let n=this.form.getFormGroupMeta(this.name)??Kj(t.defaultMeta),r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!bj(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(Fj(e.validate)){let t=Pj[e.type](e.value,e.validate);return e.type===`validate`?Xj(t):t.then(Xj)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function Jj(e){if(e)return e}function Yj(e){return!!e&&typeof e==`object`&&`fields`in e}function Xj(e){if(!e||typeof e!=`object`||!(`form`in e)&&!(`fields`in e))return e;let{form:t,fields:n,...r}=e;return{...r,group:t,fields:n}}function Zj(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function Qj(e,t){if(!t)return;let n=Object.assign({},e,{state:kj(e.state)});t(n),n.fieldInfo!==e.fieldInfo&&(e.fieldInfo=n.fieldInfo),n.options!==e.options&&(e.options=n.options);let r=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((t,r)=>(e.state[r]!==n.state[r]&&(t[r]=n.state[r]),t),{});return JA(()=>{Object.keys(r).length&&e.baseStore.setState(e=>({...e,...r})),n.state.errorMap!==e.state.errorMap&&e.setErrorMap(n.state.errorMap)}),n}var $j=o((e=>{var t=u();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),eM=o(((e,t)=>{t.exports=$j()})),tM=o((e=>{var t=u(),n=eM();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),nM=o(((e,t)=>{t.exports=tM()}))();function rM(e,t){return e===t}function iM(e,t=e=>e,n){let r=n?.compare??rM,i=(0,N.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,N.useCallback)(()=>e.get(),[e]);return(0,nM.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var aM=typeof window<`u`?N.useLayoutEffect:N.useEffect;function oM(e){let[t,n]=(0,N.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,N.useState)(()=>new Hj({...e})),a=r;(t.form!==e.form||t.name!==e.name)&&(a=new Hj({...e}),i(a),n({form:e.form,name:e.name}));let o=iM(a.store,e.mode===`array`?e=>e.meta._arrayVersion||0:e=>e.value),s=iM(a.store,e=>e.meta.isTouched),c=iM(a.store,e=>e.meta.isBlurred),l=iM(a.store,e=>e.meta.isDirty),u=iM(a.store,e=>e.meta.errorMap),d=iM(a.store,e=>e.meta.errorSourceMap),f=iM(a.store,e=>e.meta.isValidating),p=(0,N.useMemo)(()=>({...a,get state(){return{value:e.mode===`array`?a.state.value:o,get meta(){return{...a.state.meta,isTouched:s,isBlurred:c,isDirty:l,errorMap:u,errorSourceMap:d,isValidating:f}}}}}),[a,e.mode,o,s,c,l,u,d,f]);return aM(a.mount,[a]),aM(()=>{a.update(e)}),p}var sM=(({children:e,...t})=>{let n=oM(t),r=(0,N.useMemo)(()=>oj(e,n),[e,n]);return(0,P.jsx)(P.Fragment,{children:r})});function cM(){return(0,N.useState)(()=>Dj())[0]}var lM=N,uM=`19.3.0`.split(`.`)[0]===`17`?cM:lM.useId;function dM(e){let[t,n]=(0,N.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,N.useState)(()=>new qj({...e}));(t.form!==e.form||t.name!==e.name)&&(i(new qj({...e})),n({form:e.form,name:e.name}));let a=iM(r.store,e=>e.value),o=iM(r.store,e=>e.meta.isTouched),s=iM(r.store,e=>e.meta.isBlurred),c=iM(r.store,e=>e.meta.isDirty),l=iM(r.store,e=>e.meta.errorMap),u=iM(r.store,e=>e.meta.errorSourceMap),d=iM(r.store,e=>e.meta.isValidating),f=iM(r.store,e=>e.meta.isSubmitting),p=iM(r.store,e=>e.meta.isSubmitted),m=iM(r.store,e=>e.meta.submissionAttempts),h=iM(r.store,e=>e.meta.isSubmitSuccessful),g=iM(r.store,e=>e.meta.canSubmit),_=iM(r.store,e=>e.meta.isValid),v=iM(r.store,e=>e.meta.isFieldsValid),y=iM(r.store,e=>e.meta.isFieldsValidating),b=iM(r.store,e=>e.meta.isGroupValid),x=(0,N.useMemo)(()=>({...r,handleSubmit:((...e)=>r._handleSubmit(...e)),get state(){return{...r.state,value:a,get meta(){return{...r.state.meta,isTouched:o,isBlurred:s,isDirty:c,errorMap:l,errorSourceMap:u,isValidating:d,isSubmitting:f,isSubmitted:p,submissionAttempts:m,isSubmitSuccessful:h,canSubmit:g,isValid:_,isFieldsValid:v,isFieldsValidating:y,isGroupValid:b}}}}}),[r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]);return aM(r.mount,[r]),aM(()=>{r.update(e)}),x}var fM=(({children:e,...t})=>{let n=dM(t),r=(0,N.useMemo)(()=>oj(e,n),[e,n]);return(0,P.jsx)(P.Fragment,{children:r})});function pM({form:e,selector:t=e=>e,children:n}){let r=iM(e.store,t);return(0,P.jsx)(P.Fragment,{children:oj(n,r)})}function mM(e){let t=uM(),[n,r]=(0,N.useState)(e?.formId),[i,a]=(0,N.useState)(()=>new zj({...e,formId:e?.formId??t}));if(n!==e?.formId){let n=e?.formId??t;a(new zj({...e,formId:n})),r(n)}let o=(0,N.useMemo)(()=>{let e={...i,handleSubmit:((...e)=>i._handleSubmit(...e)),get formId(){return i._formId},get state(){return i.store.state}};return e.Field=function(e){return(0,P.jsx)(sM,{...e,form:i})},e.FormGroup=function(e){return(0,P.jsx)(fM,{...e,form:i})},e.Subscribe=function(e){return(0,P.jsx)(pM,{form:i,selector:e.selector,children:e.children})},e},[i]);aM(i.mount,[]),aM(()=>{i.update(e)});let s=(0,N.useRef)(!1);return aM(()=>{s.current&&e?.transform&&Qj(i,e.transform)},[i,e?.transform]),aM(()=>{s.current=!0}),o}var hM={key:`id`,label:`id`,kind:`string`},gM={key:`when`,label:`when (template)`,kind:`string`},_M={goto:[{key:`url`,label:`url`,kind:`string`},{key:`waitUntil`,label:`wait until`,kind:`enum`,options:[`load`,`domcontentloaded`,`networkidle`,`commit`]},gM],click:[{key:`selector`,label:`selector`,kind:`string`},{key:`optional`,label:`optional`,kind:`boolean`},hM,gM],fill:[{key:`selector`,label:`selector`,kind:`string`},{key:`value`,label:`value (template)`,kind:`string`},hM,gM],press:[{key:`selector`,label:`selector`,kind:`string`},{key:`key`,label:`key`,kind:`string`},hM,gM],select:[{key:`selector`,label:`selector`,kind:`string`},{key:`value`,label:`value`,kind:`string`},hM,gM],scroll:[{key:`to`,label:`to`,kind:`string`},{key:`untilStable`,label:`until stable`,kind:`boolean`},gM],wait:[{key:`selector`,label:`selector`,kind:`string`},{key:`ms`,label:`ms`,kind:`number`},gM],screenshot:[{key:`path`,label:`path`,kind:`string`},hM,gM],request:[{key:`url`,label:`url`,kind:`string`},{key:`method`,label:`method`,kind:`enum`,options:[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`HEAD`]},{key:`as`,label:`read as`,kind:`enum`,options:[`text`,`json`,`html`,`xml`,`csv`,`yaml`,`pdf`,`workbook`,`deck`]},hM,gM],extract:[{key:`selector`,label:`selector`,kind:`string`},{key:`kind`,label:`kind`,kind:`enum`,options:[`css`,`xpath`,`jsonpath`,`table`]},{key:`take`,label:`take`,kind:`string`},{key:`many`,label:`many`,kind:`boolean`},{key:`from`,label:`from (id)`,kind:`string`},hM,gM],set:[{key:`value`,label:`value (JSON)`,kind:`json`},hM,gM],collect:[{key:`into`,label:`into (id)`,kind:`string`},{key:`value`,label:`value (JSON)`,kind:`json`},gM],forEach:[{key:`as`,label:`as`,kind:`string`},{key:`over`,label:`over (id)`,kind:`string`},{key:`selector`,label:`selector (live elements)`,kind:`string`},{key:`emit`,label:`emits a record`,kind:`boolean`},hM,gM],paginate:[{key:`until`,label:`until (template)`,kind:`string`},{key:`maxPages`,label:`max pages`,kind:`number`},hM,gM],if:[{key:`test`,label:`test (template)`,kind:`string`},hM],emit:[{key:`output`,label:`output recipe id`,kind:`string`},gM]};function vM({stepType:e,step:t,onChange:n,onCommit:r}){let[i,a]=(0,N.useState)(!1),o=_M[e]??[],s=mM({defaultValues:t});return(0,P.jsxs)($w,{gap:2,p:2,borderWidth:`1px`,borderRadius:`md`,bg:`bg.subtle`,children:[o.map(e=>(0,P.jsx)(s.Field,{name:e.key,validators:{onMount:({value:t})=>yM(e,t),onChange:({value:t})=>yM(e,t)},children:i=>(0,P.jsxs)($w,{gap:0,children:[(0,P.jsx)(bM,{field:e,value:i.state.value,onChange:r=>{i.handleChange(r),n({...t,[e.key]:r})},onCommit:()=>{i.handleBlur(),r()}}),i.state.meta.errors.length>0&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.error`,children:String(i.state.meta.errors[0])})]})},e.key)),o.length===0&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`No common fields for this step type; edit its JSON below.`}),(0,P.jsxs)(F,{children:[(0,P.jsxs)(H,{as:`button`,fontSize:`xs`,color:`fg.muted`,cursor:`pointer`,onClick:()=>{a(e=>!e)},children:[i?`▾`:`▸`,` Advanced (JSON)`]}),i&&(0,P.jsx)(SM,{step:t,onChange:n,onCommit:r})]})]})}function yM(e,t){return t!==void 0&&typeof t!=`number`&&e.kind===`number`?`must be a number`:void 0}function bM({field:e,value:t,onChange:n,onCommit:r}){return e.kind===`boolean`?(0,P.jsxs)(Ww,{checked:t===!0,onCheckedChange:e=>{n(e.checked===!0),r()},children:[(0,P.jsx)(Jw,{}),(0,P.jsx)(qw,{}),(0,P.jsx)(Gw,{fontSize:`sm`,children:e.label})]}):e.kind===`enum`?(0,P.jsxs)(ST,{children:[(0,P.jsx)(CT,{fontSize:`xs`,children:e.label}),(0,P.jsx)(PT,{size:`sm`,children:(0,P.jsxs)(IT,{value:typeof t==`string`?t:``,onChange:e=>{n(e.target.value===``?void 0:e.target.value),r()},children:[(0,P.jsx)(`option`,{value:``,children:`(default)`}),e.options?.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})})]}):e.kind===`json`?(0,P.jsx)(xM,{field:e,value:t,onChange:n,onCommit:r}):(0,P.jsxs)(ST,{children:[(0,P.jsx)(CT,{fontSize:`xs`,children:e.label}),(0,P.jsx)(DT,{size:`sm`,type:e.kind===`number`?`number`:`text`,value:t===void 0?``:String(t),onChange:t=>{n(e.kind===`number`?CM(t.target.value):t.target.value)},onBlur:r})]})}function xM({field:e,value:t,onChange:n,onCommit:r}){let[i,a]=(0,N.useState)(()=>wM(t));return(0,P.jsxs)(ST,{children:[(0,P.jsx)(CT,{fontSize:`xs`,children:e.label}),(0,P.jsx)(DT,{size:`sm`,fontFamily:`mono`,value:i,onChange:e=>{a(e.target.value)},onBlur:()=>{n(TM(i)),r()}})]})}function SM({step:e,onChange:t,onCommit:n}){let[r,i]=(0,N.useState)(()=>JSON.stringify(e,null,2)),[a,o]=(0,N.useState)();return(0,P.jsxs)($w,{gap:1,mt:1,children:[(0,P.jsx)(OE,{size:`sm`,fontFamily:`mono`,fontSize:`xs`,rows:6,"aria-label":`Advanced step JSON`,value:r,onChange:e=>{i(e.target.value)},onBlur:()=>{try{let e=JSON.parse(r);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`a step is a JSON object`);o(void 0),t(e),n()}catch(e){o(e instanceof Error?e.message:String(e))}}}),a!==void 0&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.error`,children:a})]})}function CM(e){if(e===``)return;let t=Number(e);return Number.isNaN(t)?void 0:t}function wM(e){return typeof e==`string`?e:e===void 0?``:JSON.stringify(e)}function TM(e){try{return JSON.parse(e)}catch{return e}}function EM({listId:e,nodes:t,allIssues:n,actions:r,menuLabel:i}){return(0,P.jsxs)($w,{gap:1,children:[(0,P.jsx)(kA,{ariaLabel:`${i} at the start`,onAdd:t=>{r.insert(e,0,t)}}),t.map((a,o)=>(0,P.jsxs)($w,{gap:1,children:[(0,P.jsx)(DM,{node:a,listId:e,index:o,lastIndex:t.length-1,allIssues:n,actions:r}),(0,P.jsx)(kA,{ariaLabel:`${i} after this step`,onAdd:t=>{r.insert(e,o+1,t)}})]},a.path))]})}function DM({node:e,listId:t,index:n,lastIndex:r,allIssues:i,actions:a,readOnly:o=!1}){let[s,c]=(0,N.useState)(!1),l=e.kind===`bracket`,u=e.kind===`card`&&e.custom,d=MO(i,e.path),f=typeof e.step.id==`string`?e.step.id:void 0,p=JO(e=>e.hoveredStepId),m=JO(e=>e.setHoveredStepId),h=f!==void 0&&f===p;return(0,P.jsxs)($w,{gap:1,"data-testid":`outline-card-${e.path}`,children:[(0,P.jsxs)(G,{gap:2,p:2,borderWidth:`1px`,borderRadius:`md`,"data-highlighted":h,borderColor:h?`orange.solid`:void 0,bg:h?`orange.subtle`:u?`bg.muted`:`bg.panel`,cursor:o?`default`:`pointer`,onClick:o?void 0:()=>{c(e=>!e)},onMouseEnter:o||f===void 0?void 0:()=>{m(f)},onMouseLeave:o||f===void 0?void 0:()=>{m(void 0)},children:[!o&&(0,P.jsxs)($w,{gap:0,flexShrink:0,children:[(0,P.jsx)(Yw,{"aria-label":`Move up`,size:`2xs`,variant:`ghost`,disabled:n===0,onClick:e=>{e.stopPropagation(),a.move(t,n,-1)},children:`↑`}),(0,P.jsx)(Yw,{"aria-label":`Move down`,size:`2xs`,variant:`ghost`,disabled:n===r,onClick:e=>{e.stopPropagation(),a.move(t,n,1)},children:`↓`})]}),(0,P.jsxs)(F,{flex:`1`,children:[(0,P.jsx)(NA,{parts:e.sentence}),d.length>0&&(0,P.jsx)($w,{gap:0,mt:1,children:d.map(e=>(0,P.jsx)(H,{fontSize:`xs`,color:`fg.error`,children:e.message},e.message))})]}),!o&&(0,P.jsx)(Yw,{"aria-label":`Remove step`,size:`2xs`,variant:`ghost`,onClick:e=>{e.stopPropagation(),a.remove(t,n)},children:`✕`})]}),s&&!u&&!o&&(0,P.jsx)(F,{pl:8,children:(0,P.jsx)(vM,{stepType:e.stepType,step:e.step,onChange:t=>{a.edit(e.path,e=>({...e,step:t}))},onCommit:a.commit})}),s&&u&&!o&&(0,P.jsxs)(F,{pl:8,children:[(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,mb:1,children:`This step doesn't read as a sentence yet: edit its JSON directly.`}),(0,P.jsx)(vM,{stepType:e.stepType,step:e.step,onChange:t=>{a.edit(e.path,e=>({...e,step:t}))},onCommit:a.commit})]}),l&&(0,P.jsxs)(F,{pl:8,borderLeftWidth:`2px`,borderColor:`border.muted`,children:[(0,P.jsx)(EM,{listId:`${e.path}::then`,nodes:e.children,allIssues:i,actions:a,menuLabel:`Add step`}),e.stepType===`if`&&e.elseChildren!==void 0&&(0,P.jsxs)($w,{gap:1,mt:2,children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`medium`,color:`fg.muted`,children:`Else`}),(0,P.jsx)(EM,{listId:`${e.path}::else`,nodes:e.elseChildren,allIssues:i,actions:a,menuLabel:`Add step`})]}),e.stepType===`if`&&e.elseChildren===void 0&&(0,P.jsx)(Rw,{size:`xs`,variant:`outline`,mt:2,onClick:()=>{a.insert(`${e.path}::else`,0,`emit`)},children:`+ Add an else branch`})]})]})}var OM={edit:()=>{},commit:()=>{},move:()=>{},remove:()=>{},insert:()=>{}};function kM({recipe:e,onSaveOutline:t}){let[n,r]=(0,N.useState)(e?.outline);(0,N.useEffect)(()=>{r(e?.outline)},[e?.file,e?.text]);let[i,a]=(0,N.useState)(new Set),[o,s]=(0,N.useState)(!1),c=QO(e=>e.recipeId),l=QO(e=>e.active),u=QO(e=>e.stoppedSteps!==void 0),d=QO(e=>e.cards),f=QO(e=>e.notes);if(e===void 0)return(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`Select a recipe to see its steps.`})});if(n===void 0)return(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`This recipe has no steps to show (not an input recipe, or its JSON is not an object).`})});let p=n=>{r(n),t(e.file,n)},m={edit:(e,t)=>{r(n=>n===void 0?n:CO(n,e,t))},commit:()=>{r(n=>(n!==void 0&&t(e.file,n),n))},move:(e,t,r)=>{if(n===void 0)return;let i=xO(n,e),a=t+r;if(a<0||a>=i.length)return;let o=[...i],[s]=o.splice(t,1);o.splice(a,0,s),p(SO(n,e,o))},remove:(e,t)=>{if(n===void 0)return;let r=xO(n,e);p(SO(n,e,r.filter((e,n)=>n!==t)))},insert:(e,t,r)=>{if(n===void 0)return;let i=xO(n,e),a=OA(r,`${DO(e)}.${t}`);p(SO(n,e,[...i.slice(0,t),a,...i.slice(t)]))}};function h(e,t){if(n===void 0||e.selector===void 0)return;let r={kind:`bracket`,path:`steps.${n.steps.length}`,stepType:`paginate`,sentence:[{kind:`word`,text:`For every page — click`},{kind:`code`,text:e.selector}],step:{type:`paginate`,next:{selector:e.selector},steps:[]},children:[]};p({...n,steps:[...n.steps,r]}),a(e=>new Set(e).add(t))}let g=c===e.id&&(l||u);function _(e){if(!wA(e.dataTransfer))return;e.preventDefault(),s(!1);let t=CA(e.dataTransfer);t!==void 0&&n!==void 0&&p({...n,steps:[...n.steps,{...t,path:`steps.${String(n.steps.length)}`}]})}function v(e){wA(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,s(!0))}return(0,P.jsxs)(F,{h:`full`,overflow:`auto`,p:2,"data-testid":`steps-outline`,"data-card-over":o,outline:o?`2px dashed`:void 0,outlineColor:`blue.solid`,outlineOffset:`-4px`,onDragOver:v,onDragLeave:()=>{s(!1)},onDrop:_,children:[(0,P.jsx)(EM,{listId:``,nodes:n.steps,allIssues:e.issues,actions:m,menuLabel:`Add step`},e.file),g&&(0,P.jsxs)(F,{mt:3,pt:2,borderTopWidth:`1px`,borderColor:`border.muted`,"data-testid":`recording-cards`,children:[(0,P.jsxs)(G,{gap:2,mb:1,children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`semibold`,color:`fg.muted`,children:l?`Recording…`:`Recording stopped`}),(0,P.jsxs)(Aw,{size:`sm`,colorPalette:l?`red`:`gray`,children:[d.length,` step`,d.length===1?``:`s`]})]}),(0,P.jsx)($w,{gap:1,children:d.map((e,t)=>(0,P.jsx)(DM,{node:e.node,listId:`recording`,index:t,lastIndex:d.length-1,allIssues:[],actions:OM,readOnly:!0},`recording:${t}:${e.node.path}`))}),f.length>0&&(0,P.jsx)($w,{gap:1,mt:2,children:f.map((e,t)=>(0,P.jsxs)(G,{gap:2,p:2,borderWidth:`1px`,borderRadius:`md`,borderColor:e.kind===`unsupported`?`orange.muted`:`border.muted`,bg:`bg.muted`,children:[(0,P.jsx)(H,{fontSize:`xs`,flex:`1`,children:e.message}),e.kind===`next-link`&&e.selector!==void 0&&!i.has(t)&&(0,P.jsx)(Rw,{size:`2xs`,colorPalette:`blue`,onClick:()=>{h(e,t)},children:`Turn into pagination`}),e.kind===`next-link`&&i.has(t)&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`green`,children:`Added`})]},`note:${t}:${e.message}`))})]})]})}function AM(){return(0,P.jsx)(F,{px:3,py:2,bg:`orange.subtle`,borderBottomWidth:`1px`,flexShrink:0,role:`status`,children:(0,P.jsx)(H,{fontSize:`sm`,children:`This page shows almost nothing. If it should have content, it builds it with JavaScript and the engine fetched it without a browser. Use Inspect to see the data it loads.`})})}var jM=`table`,MM=`text`,NM=4,PM=1;function FM(e){return`^${WM(e.trim())}`}function IM(e){let t=e.trim().toLowerCase().replace(/[^\d a-z]/gi,` `).trim().split(/\s+/).filter(e=>e!==``);if(t.length===0)return`column`;let[n,...r]=t;return n+r.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function LM(e,t,n=jM){if(e.header===void 0)throw Error(`tableCardNode: pick the header row first`);let r=e.columns,i=r!==void 0&&Object.keys(r).length>0;return{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:n,kind:`table`,selector:e.header,...e.until!==void 0&&{until:e.until},...i&&{columns:r}}}}function RM(e,t,n){let[r,i]=UM(n.x1,n.x2),[a,o]=UM(n.y1,n.y2);return`${e}=${String(t)} x=${String(Math.round(r))}..${String(Math.round(i))} y=${String(Math.round(a))}..${String(Math.round(o))}`}function zM(e){return{x1:e.x-PM,y1:e.y-PM,x2:e.x+Math.max(e.width,1)+PM,y2:e.y+e.height+PM}}function BM(e,t){return{x1:Math.min(e.x1,t.x1),y1:Math.min(e.y1,t.y1),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}}function VM(e){let[t=``]=e.split(`
|
|
12
12
|
`,1),n=t.trim().toLowerCase().replace(/[^\d a-z]/gi,` `).trim().split(/\s+/).filter(e=>e!==``).slice(0,NM);if(n.length===0)return MM;let[r,...i]=n;return r+i.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function HM(e,t,n){return{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:n,kind:`region`,selector:e}}}function UM(e,t){return e<=t?[e,t]:[t,e]}function WM(e){return e.replace(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}var GM=`table`;function KM(e){return`${FM(e)}$`}function qM(e){return e.map(e=>String(e.value).trim()).filter(e=>e!==``).join(` `)}function JM(e){let t=e.rows.map(e=>e.map(e=>e.value));for(let n of e.merges){let e=t[n.top]?.[n.left]??``;for(let r=n.top;r<=n.bottom;r+=1){t[r]??=[];for(let i=n.left;i<=n.right;i+=1)t[r][i]=e}}return t}function YM(e,t,n){let r=[];for(let i of t){let t=String(e[i]?.[n]??``).trim();t!==``&&!r.includes(t)&&r.push(t)}return r.join(` `)}function XM(e,t){let n=FM(t);return Object.entries(e.columns??{}).find(([,e])=>e===n)?.[0]??t}function ZM(e,t,n=GM){if(e.header===void 0)throw Error(`gridTableCardNode: pick the header row first`);let r=e.columns,i=r!==void 0&&Object.keys(r).length>0,a=e.fillDown!==void 0&&e.fillDown.length>0;return{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:n,kind:`table`,selector:e.header,...e.sheet!==void 0&&{sheet:e.sheet},...e.until!==void 0&&{until:e.until},...i&&{columns:r},...e.headerRows!==void 0&&e.headerRows>1&&{headerRows:e.headerRows},...a&&{fillDown:e.fillDown},...e.includeHidden===!0&&{includeHidden:!0}}}}function QM(e,t){let n=t.top===t.bottom?`[${String(t.top)}]`:`[${String(t.top)}:${String(t.bottom+1)}]`,r=t.left===t.right?`[${String(t.left)}]`:`[${String(t.left)}:${String(t.right+1)}]`;return`$.sheets[?(@.name==${rN(e)})].rows${n}${r}`}function $M(e,t){return{top:Math.min(e.top,t.top),left:Math.min(e.left,t.left),bottom:Math.max(e.bottom,t.bottom),right:Math.max(e.right,t.right)}}function eN(e){return e.top===e.bottom&&e.left===e.right}function tN(e,t){let n=[];for(let r=t.top;r<=t.bottom;r+=1){let i=e.rows[r]?.slice(t.left,t.right+1)??[];n.push(i.map(e=>String(e.value)).join(` `))}return n.join(`
|
|
13
13
|
`)}function nN(e,t,n,r){return{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:n,kind:`jsonpath`,selector:e,take:`json`,...r&&{many:!0}}}}function rN(e){return e.includes(`'`)?`"${e.replace(/["\\]/g,String.raw`\$&`)}"`:`'${e}'`}var iN=`table`,aN=`value`,oN=1;function sN(e){return`${FM(e)}$`}function cN(e,t,n=iN){if(e.header===void 0)throw Error(`deckTableCardNode: pick the header row first`);let r=e.columns,i=r!==void 0&&Object.keys(r).length>0,a=e.fillDown!==void 0&&e.fillDown.length>0;return{kind:`card`,path:t,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:n,kind:`table`,selector:e.header,...e.slide!==void 0&&{slide:e.slide},...e.shapes===!0&&{shapes:!0},...e.until!==void 0&&{until:e.until},...i&&{columns:r},...e.headerRows!==void 0&&e.headerRows>1&&{headerRows:e.headerRows},...a&&{fillDown:e.fillDown},...e.includeHidden===!0&&{includeHidden:!0}}}}function lN(e,t,n,r=aN){return{kind:`card`,path:n,stepType:`extract`,sentence:[],custom:!1,step:{type:`extract`,id:r,selector:`$.slides[${String(e)}].charts[${String(t)}].series`,kind:`jsonpath`,take:`json`}}}function uN(e){return{x1:e.x-oN,y1:e.y-oN,x2:e.x+Math.max(e.width,1)+oN,y2:e.y+Math.max(e.height,1)+oN}}var dN=`#9b5de5`;function fN({left:e,top:t,text:n,loading:r,onAdd:i,onClear:a,onDragStart:o}){let s=n===void 0&&!r,[c=``]=(n??``).split(`
|
|
14
|
-
`,1);return(0,P.jsxs)(G,{"data-testid":`region-chip`,position:`absolute`,style:{left:`${String(e)}px`,top:`${String(t)}px`},zIndex:`docked`,gap:2,px:2,py:1,bg:`bg.panel`,borderWidth:`1px`,borderColor:dN,borderRadius:`md`,shadow:`md`,maxW:`420px`,draggable:n!==void 0,onDragStart:o,onMouseDown:e=>{e.stopPropagation()},onMouseUp:e=>{e.stopPropagation()},cursor:n===void 0?`default`:`grab`,title:n===void 0?void 0:`Drag onto the Steps tab to add it there`,children:[(0,P.jsx)(H,{fontSize:`xs`,fontFamily:`mono`,truncate:!0,flex:`1`,color:s?`fg.muted`:`fg`,children:r&&n===void 0?`reading…`:s?`nothing to read here`:c}),(0,P.jsx)(Rw,{size:`2xs`,colorPalette:`blue`,onClick:i,disabled:n===void 0,children:`Add to recipe`}),(0,P.jsx)(Xw,{size:`2xs`,"aria-label":`Clear selection`,onClick:a})]})}var pN=/^\s*(page|slide)=(\*|\d+)\s+x=(-?\d+(?:\.\d+)?)\.\.(-?\d+(?:\.\d+)?)\s+y=(-?\d+(?:\.\d+)?)\.\.(-?\d+(?:\.\d+)?)\s*$/,mN=/^\$\.sheets\[\?\(@\.name==(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\)\]\.rows\[(\d+)(?::(\d+))?\]\[(\d+)(?::(\d+))?\]$/,hN=/^\$\.slides\[(\d+)\]\.charts\[(\d+)\]\.series$/;function gN(e){let t=[];for(let n of AO(e)){let{id:e,kind:r,selector:i}=n.step;typeof e==`string`&&typeof r==`string`&&typeof i==`string`&&n.step.type===`extract`&&t.push({id:e,kind:r,selector:i})}return t}function _N(e,t){let n=new Set([e.jsonpath,e.xpath,e.listPath].filter(e=>e!==void 0));return t.filter(e=>n.has(e.selector)&&(e.kind===`jsonpath`||e.kind===`xpath`)).map(e=>e.id)}function vN(e){let t=pN.exec(e);if(t===null)return;let[,n,r,i,a,o,s]=t;return{on:n,at:r===`*`?`*`:Number(r),box:{x1:Number(i),y1:Number(o),x2:Number(a),y2:Number(s)}}}function yN(e,t,n){let r=[];for(let i of e){if(i.kind!==`region`)continue;let e=vN(i.selector);e===void 0||e.on!==t||e.at!==`*`&&e.at!==n||r.push({id:i.id,box:e.box})}return r}function bN(e,t){let[n,r]=EN(e.x1,e.x2),[i,a]=EN(e.y1,e.y2),[o,s]=EN(t.x1,t.x2),[c,l]=EN(t.y1,t.y2),u=(r-n)*(a-i);return u===0?n>=o&&n<=s&&i>=c&&i<=l:Math.max(0,Math.min(r,s)-Math.max(n,o))*Math.max(0,Math.min(a,l)-Math.max(i,c))>=u/2}function xN(e,t){return t.filter(t=>bN(e,t.box)).map(e=>e.id)}function SN(e){let t=mN.exec(e);if(t===null)return;let[,n,r,i,a,o,s]=t;return{sheet:n??(r??``).replace(/\\(.)/g,`$1`),range:{top:Number(i),left:Number(o),bottom:a===void 0?Number(i):Number(a)-1,right:s===void 0?Number(o):Number(s)-1}}}function CN(e,t){let n=[];for(let r of e){if(r.kind!==`jsonpath`)continue;let e=SN(r.selector);e!==void 0&&e.sheet===t&&n.push({id:r.id,range:e.range})}return n}function wN(e,t,n){return n.filter(({range:n})=>e>=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right).map(e=>e.id)}function TN(e,t,n){for(let r of e){if(r.kind!==`jsonpath`)continue;let e=hN.exec(r.selector);if(e!==null&&Number(e[1])===t&&Number(e[2])===n)return r.id}}function EN(e,t){return e<=t?[e,t]:[t,e]}var DN=[],ON=5,kN=24,AN=4,jN=`#1d4ed8`,MN=`#ea580c`;function NN({recipeId:e,stepPath:t,view:n,onTablePick:r,onChartPick:i,onRegionPick:a,steps:o=DN,hoveredStepId:s,onHoverStepId:c}){let[l,u]=(0,N.useState)(0),[d,f]=(0,N.useState)(`table`),[p,m]=(0,N.useState)(0),[h,g]=(0,N.useState)(`text`),[_,v]=(0,N.useState)({}),[y,b]=(0,N.useState)(void 0),[x,S]=(0,N.useState)(void 0),[C,w]=(0,N.useState)(void 0),T=(0,N.useRef)(void 0),E=n.slides[l],D=(0,N.useMemo)(()=>yN(o,`slide`,E?.number??-1),[o,E?.number]),O=(0,N.useMemo)(()=>(E?.charts??[]).map((e,t)=>TN(o,l,t)),[o,E?.charts,l]),k=d===`table`?E?.tables[p]:void 0,ee=_.headerRowIndex===void 0?void 0:Array.from({length:_.headerRows??1},(e,t)=>_.headerRowIndex+t),te=bk(e,t,_.header===void 0?void 0:{slide:_.slide,shapes:_.shapes,header:_.header,until:_.until,columns:_.columns,headerRows:_.headerRows,fillDown:_.fillDown,includeHidden:_.includeHidden}),ne=(0,N.useMemo)(()=>te.data?.matches.find(e=>e.slide===E?.number),[te.data,E?.number]),re=x===void 0?void 0:RM(`slide`,x.slide,x.box),ie=gk(e,t,re),ae=ie.data?.matches.find(e=>e.page===x?.slide),oe=ae?.text;if((0,N.useEffect)(()=>{_.header!==void 0&&r(cN(_,t))},[_]),(0,N.useEffect)(()=>{m(0),v({}),f(E!==void 0&&E.tables.length===0&&E.shapes.length>0?`shapes`:`table`)},[l]),E===void 0)return(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`This deck has no slides.`})});function se(e){e!==d&&(f(e),v({}))}function ce(e){if(k===void 0)return;let t=qM(k.rows[e]);if(t!==``){if(h===`header`){v(n=>n.headerRowIndex!==void 0&&e===n.headerRowIndex+(n.headerRows??1)?{...n,headerRows:(n.headerRows??1)+1}:{slide:sN(E.title??``),includeHidden:n.includeHidden,header:FM(t),headerRowIndex:e,headerRows:1});return}h===`until`&&_.header!==void 0&&v(e=>({...e,until:FM(t)}))}}function le(e,t){if(k===void 0||ee===void 0)return;let n=JM(k);if(h===`column`){let e=YM(n,ee,t);if(e===``)return;v(t=>({...t,columns:{...t.columns,[IM(e)]:FM(e)}}));return}if(h===`fillDown`&&PN(k,e,t)){let e=YM(n,ee,t);if(e===``)return;let r=XM(_,e);v(e=>{let t=e.fillDown??[];return t.includes(r)?e:{...e,fillDown:[...t,r]}})}}function A(e){let t=E.shapeRows.findIndex(t=>t.includes(e));if(t===-1)return;let n=E.shapeRows[t];if(h===`header`){let e=E.shapes[n[0]]?.text??``;if(e.trim()===``)return;v({slide:sN(E.title??``),shapes:!0,header:FM(e),headerRowIndex:t,headerRows:1});return}if(h===`until`){if(_.header===void 0)return;let e=E.shapes[n[0]]?.text??``;if(e.trim()===``)return;v(t=>({...t,until:FM(e)}));return}if(h===`column`){if(_.headerRowIndex!==t)return;let n=E.shapes[e]?.text??``;if(n.trim()===``)return;v(e=>({...e,columns:{...e.columns,[IM(n)]:FM(n)}}))}}function ue(e){f(`table`),m(e),v({})}function de(e){i(lN(l,e,t))}function fe(e,t){let n=x;S(t&&n!==void 0&&n.slide===E.number?{slide:E.number,box:BM(n.box,e)}:{slide:E.number,box:e})}function pe(e){c!==void 0&&T.current!==e&&(T.current=e,c(e))}function me(e){let t=FN(e);if(C!==void 0){w({...C,currentX:t.x,currentY:t.y});return}let n=zN(E,t);b(n),pe(n===void 0?void 0:xN(uN(n),D)[0])}function he(e){if(e.button!==0)return;let t=FN(e);w({startX:t.x,startY:t.y,currentX:t.x,currentY:t.y})}function ge(e){if(C===void 0)return;let t=FN(e);if(w(void 0),Math.abs(t.x-C.startX)+Math.abs(t.y-C.startY)>AN){fe({x1:C.startX,y1:C.startY,x2:t.x,y2:t.y},e.shiftKey);return}let n=zN(E,t);if(n===void 0){e.shiftKey||S(void 0);return}fe(uN(n),e.shiftKey)}function _e(){if(re!==void 0&&oe!==void 0)return HM(re,t,VM(oe))}function ve(){let e=_e();e!==void 0&&(a(e),S(void 0))}function ye(e){let t=_e();t!==void 0&&oe!==void 0&&(e.dataTransfer.setData(xA,SA(t)),e.dataTransfer.setData(`text/plain`,oe),e.dataTransfer.effectAllowed=`copy`)}let j=h===`text`,M=x!==void 0&&x.slide===E.number?x:void 0;return(0,P.jsxs)(F,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,P.jsxs)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,flexWrap:`wrap`,children:[n.slides.length>1&&(0,P.jsx)(VN,{slides:n.slides,value:l,onChange:u}),(0,P.jsx)(BN,{label:`Text`,active:j,onClick:()=>{g(`text`)}}),!j&&(0,P.jsx)(BN,{label:`Native table`,active:d===`table`,onClick:()=>{se(`table`)}}),!j&&(0,P.jsx)(BN,{label:`Text-box grid`,active:d===`shapes`,onClick:()=>{se(`shapes`)}}),(0,P.jsx)(BN,{label:`Header row(s)`,active:h===`header`,onClick:()=>{g(`header`)}}),(0,P.jsx)(BN,{label:`Last row (until)`,active:h===`until`,onClick:()=>{g(`until`)}}),(0,P.jsx)(BN,{label:`Column`,active:h===`column`,onClick:()=>{g(`column`)}}),!j&&d===`table`&&(0,P.jsx)(BN,{label:`Fill down`,active:h===`fillDown`,onClick:()=>{g(`fillDown`)}}),j&&x===void 0&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Click a text box (shift+click to extend) or drag a box, then add it to the recipe or drag it onto the Steps tab.`}),_.header!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`green`,children:`table: ${_.header}${_.until===void 0?``:` until ${_.until}`}`}),te.data?.error!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`orange`,children:te.data.error}),ie.data?.error!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`orange`,children:ie.data.error})]}),(0,P.jsxs)(F,{flex:`1`,minH:`0`,display:`flex`,overflow:`hidden`,children:[(0,P.jsxs)(F,{flex:`2`,minW:`0`,overflow:`auto`,p:3,children:[j&&(0,P.jsxs)(F,{position:`relative`,width:`${String(n.width)}px`,height:`${String(n.height)}px`,children:[(0,P.jsx)(HN,{slide:E,width:n.width,height:n.height}),(0,P.jsxs)(`svg`,{"data-testid":`deck-overlay`,width:n.width,height:n.height,style:{position:`absolute`,top:0,left:0,cursor:`crosshair`},onMouseMove:me,onMouseDown:he,onMouseUp:ge,onMouseLeave:()=>{b(void 0),pe(void 0)},children:[D.map(e=>(0,P.jsx)(`rect`,{"data-testid":`recipe-region`,"data-step-id":e.id,"data-highlighted":e.id===s,...RN(e.box),fill:e.id===s?`rgba(234, 88, 12, 0.22)`:`rgba(234, 88, 12, 0.05)`,stroke:MN,strokeWidth:e.id===s?2:1,strokeDasharray:e.id===s?void 0:`4 3`,pointerEvents:`none`,children:(0,P.jsx)(`title`,{children:`In the recipe: ${e.id}`})},`recipe:${e.id}`)),y!==void 0&&C===void 0&&(0,P.jsx)(`rect`,{"data-testid":`snap-target`,...LN(y),fill:`rgba(29, 78, 216, 0.08)`,stroke:jN,strokeWidth:1.5,strokeDasharray:`3 2`,pointerEvents:`none`}),M!==void 0&&(0,P.jsx)(`rect`,{"data-testid":`staged-region`,...RN(M.box),fill:`rgba(155, 93, 229, 0.12)`,stroke:`#9b5de5`,strokeWidth:1.5,pointerEvents:`none`}),M!==void 0&&ae?.shapes.map(e=>(0,P.jsx)(`rect`,{"data-testid":`staged-shape`,...LN(e),fill:`rgba(155, 93, 229, 0.28)`,pointerEvents:`none`},IN(e))),C!==void 0&&(0,P.jsx)(`rect`,{...RN({x1:C.startX,y1:C.startY,x2:C.currentX,y2:C.currentY}),fill:`rgba(155, 93, 229, 0.2)`,stroke:`#9b5de5`,strokeDasharray:`4 2`,pointerEvents:`none`})]}),M!==void 0&&(0,P.jsx)(fN,{left:Math.min(M.box.x1,M.box.x2),top:Math.max(M.box.y1,M.box.y2)+6,text:oe,loading:ie.isPending,onAdd:ve,onClear:()=>{S(void 0)},onDragStart:ye})]}),!j&&d===`shapes`&&(0,P.jsx)(HN,{slide:E,width:n.width,height:n.height,headerRowIndex:_.headerRowIndex,onPick:A}),!j&&d===`table`&&k!==void 0&&(0,P.jsx)(UN,{table:k,headerRowIndexes:ee,mode:h,onRowPick:ce,onCellPick:le}),!j&&d===`table`&&k===void 0&&(0,P.jsx)(H,{color:`fg.muted`,fontSize:`sm`,children:`This slide has no native tables.`}),!j&&ne!==void 0&&(0,P.jsx)(GN,{match:ne})]}),(0,P.jsx)(F,{flex:`1`,minW:`220px`,maxW:`320px`,borderLeftWidth:`1px`,overflow:`auto`,p:3,children:(0,P.jsx)(WN,{slide:E,activeSource:d,activeTableIndex:p,onTablePick:ue,onChartPick:de,chartStepIds:O,hoveredStepId:s,onHoverStepId:pe})})]})]})}function PN(e,t,n){let r=e.merges.find(e=>e.top===t&&e.left===n);return r!==void 0&&r.bottom>r.top&&r.left===r.right}function FN(e){let t=e.currentTarget.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function IN(e){return`staged:${String(e.x)}:${String(e.y)}`}function LN(e){return{x:e.x,y:e.y,width:Math.max(e.width,1),height:Math.max(e.height,1)}}function RN(e){let[t,n]=[Math.min(e.x1,e.x2),Math.max(e.x1,e.x2)],[r,i]=[Math.min(e.y1,e.y2),Math.max(e.y1,e.y2)];return{x:t,y:r,width:n-t,height:i-r}}function zN(e,t){let n;for(let r of e.shapes){let e=LN(r),i=Math.max(e.x-t.x,0,t.x-(e.x+e.width)),a=Math.max(e.y-t.y,0,t.y-(e.y+e.height)),o=Math.hypot(i,a);o<=kN&&(n===void 0||o<n.distance)&&(n={shape:r,distance:o})}return n?.shape}function BN({label:e,active:t,onClick:n}){return(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:t?`semibold`:`normal`,color:t?`colorPalette.fg`:`fg`,colorPalette:`blue`,cursor:`pointer`,onClick:n,children:e})}function VN({slides:e,value:t,onChange:n}){let r=l_({items:e.map((e,t)=>({label:`Slide ${String(e.number)}${e.title===void 0||e.title===``?``:` — ${e.title}`}${e.hidden?` (hidden)`:``}`,value:String(t)}))});return(0,P.jsxs)(VT,{collection:r,size:`sm`,width:`220px`,value:[String(t)],onValueChange:e=>{n(Number(e.value[0]))},children:[(0,P.jsx)(JT,{}),(0,P.jsx)(qT,{children:(0,P.jsx)(HT,{children:(0,P.jsx)(GT,{})})}),(0,P.jsx)(UT,{children:(0,P.jsx)(WT,{children:r.items.map(e=>(0,P.jsx)(KT,{item:e,children:e.label},e.value))})})]})}function HN({slide:e,width:t,height:n,headerRowIndex:r,onPick:i}){let a=r===void 0?void 0:new Set(e.shapeRows[r]);return(0,P.jsx)(F,{position:`relative`,width:`${String(t)}px`,height:`${String(n)}px`,borderWidth:`1px`,bg:`bg.panel`,children:e.shapes.map((e,t)=>(0,P.jsx)(F,{position:`absolute`,style:{left:`${String(e.x)}px`,top:`${String(e.y)}px`,width:`${String(Math.max(e.width,1))}px`,height:`${String(Math.max(e.height,1))}px`},borderWidth:`1px`,borderColor:a?.has(t)===!0?`orange.fg`:`border.muted`,bg:a?.has(t)===!0?`orange.subtle`:`bg`,overflow:`hidden`,px:1,fontSize:`xs`,cursor:i===void 0?`default`:`pointer`,_hover:i===void 0?void 0:{bg:`bg.emphasized`},onClick:i===void 0?void 0:()=>{i(t)},title:e.placeholder,children:e.text},`${String(e.x)}:${String(e.y)}:${String(t)}`))})}function UN({table:e,headerRowIndexes:t,mode:n,onRowPick:r,onCellPick:i}){return(0,P.jsx)(yE,{size:`sm`,variant:`outline`,children:(0,P.jsx)(TE,{children:e.rows.map((e,a)=>(0,P.jsx)(bE,{bg:t?.includes(a)===!0?`yellow.subtle`:void 0,children:e.map((e,t)=>(0,P.jsx)(wE,{fontSize:`xs`,cursor:`pointer`,_hover:{bg:`bg.emphasized`},onClick:()=>{n===`header`||n===`until`?r(a):i(a,t)},children:String(e.value)},t))},a))})})}function WN({slide:e,activeSource:t,activeTableIndex:n,onTablePick:r,onChartPick:i,chartStepIds:a,hoveredStepId:o,onHoverStepId:s}){return(0,P.jsxs)(kE,{align:`stretch`,gap:4,children:[(0,P.jsxs)(F,{children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`semibold`,color:`fg.muted`,mb:1,children:`Native tables (${String(e.tables.length)})`}),e.tables.length===0&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`None on this slide.`}),(0,P.jsx)(kE,{align:`stretch`,gap:1,children:e.tables.map((e,i)=>(0,P.jsxs)(F,{as:`button`,textAlign:`left`,p:2,borderWidth:`1px`,borderRadius:`sm`,bg:t===`table`&&n===i?`bg.emphasized`:void 0,onClick:()=>{r(i)},children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`medium`,children:e.name}),(0,P.jsx)(H,{fontSize:`2xs`,color:`fg.muted`,children:`${String(e.rows.length)} rows`})]},e.name))})]}),(0,P.jsxs)(F,{children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`semibold`,color:`fg.muted`,mb:1,children:`Charts (${String(e.charts.length)})`}),e.charts.length===0&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`None on this slide.`}),(0,P.jsx)(kE,{align:`stretch`,gap:1,children:e.charts.map((e,t)=>(0,P.jsxs)(F,{as:`button`,"data-testid":`deck-chart`,"data-step-ids":a[t],"data-highlighted":a[t]!==void 0&&a[t]===o,textAlign:`left`,p:2,borderWidth:`1px`,borderRadius:`sm`,borderColor:a[t]===void 0?void 0:`orange.solid`,borderStyle:a[t]===void 0||a[t]===o?`solid`:`dashed`,bg:a[t]!==void 0&&a[t]===o?`orange.subtle`:void 0,onClick:()=>{i(t)},onMouseEnter:()=>{s(a[t])},onMouseLeave:()=>{s(void 0)},children:[(0,P.jsxs)(G,{gap:1,children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`medium`,children:e.title??e.type}),a[t]!==void 0&&(0,P.jsx)(Aw,{size:`xs`,colorPalette:`orange`,title:`Already in the recipe: the step reading this`,children:a[t]})]}),(0,P.jsx)(H,{fontSize:`2xs`,color:`fg.muted`,children:`${e.type} · ${String(e.series.length)} series`})]},t))})]}),(0,P.jsxs)(F,{children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`semibold`,color:`fg.muted`,mb:1,children:`Notes`}),(0,P.jsx)(H,{fontSize:`xs`,color:e.notes===``?`fg.muted`:`fg`,whiteSpace:`pre-wrap`,children:e.notes===``?`None.`:e.notes})]})]})}function GN({match:e}){let t=e.rows.slice(0,ON);return(0,P.jsxs)(F,{borderTopWidth:`1px`,mt:3,maxH:`160px`,overflow:`auto`,children:[(0,P.jsx)(G,{px:0,py:1,gap:2,children:(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Live preview: ${String(e.rows.length)} row${e.rows.length===1?``:`s`} matched${e.title===``?``:` ("${e.title}")`}`})}),(0,P.jsxs)(yE,{size:`sm`,variant:`outline`,children:[(0,P.jsx)(SE,{children:(0,P.jsx)(bE,{children:e.header.map(e=>(0,P.jsx)(CE,{fontSize:`2xs`,children:e},e))})}),(0,P.jsx)(TE,{children:t.map((t,n)=>(0,P.jsx)(bE,{children:e.header.map(e=>(0,P.jsx)(wE,{fontSize:`2xs`,children:String(t[e]??``)},e))},n))})]})]})}var KN=[],qN=24,JN=130,YN=30,XN=5;function ZN({recipeId:e,stepPath:t,view:n,onTablePick:r,onCellPick:i,steps:a=KN,hoveredStepId:o,onHoverStepId:s,csvOverride:c,onCsvOverrideChange:l}){let[u,d]=(0,N.useState)(0),[f,p]=(0,N.useState)(`cell`),[m,h]=(0,N.useState)({}),[g,_]=(0,N.useState)(void 0),[v,y]=(0,N.useState)(void 0),[b,x]=(0,N.useState)(void 0),S=(0,N.useRef)(null),C=(0,N.useRef)(void 0),w=n.sheets[u],T=(0,N.useMemo)(()=>CN(a,w?.name??``),[a,w?.name]),E=(0,N.useMemo)(()=>w===void 0?[]:JM(w),[w]),D=(0,N.useMemo)(()=>w===void 0?[]:QN(w),[w]),O=m.headerRowIndex===void 0?void 0:Array.from({length:m.headerRows??1},(e,t)=>m.headerRowIndex+t),k=vk(e,t,m.header===void 0?void 0:{sheet:m.sheet,header:m.header,until:m.until,columns:m.columns,headerRows:m.headerRows,fillDown:m.fillDown,includeHidden:m.includeHidden}),ee=(0,N.useMemo)(()=>k.data?.matches.find(e=>e.sheet===w?.name),[k.data,w?.name]),te=Jk({count:w?.rows.length??0,getScrollElement:()=>S.current,estimateSize:()=>qN,overscan:YN});(0,N.useEffect)(()=>{m.header!==void 0&&r(ZM(m,t))},[m]);let ne=f===`cell`,re=b!==void 0&&w!==void 0&&b.sheet===w.name?b:void 0,ie=re===void 0?void 0:QM(re.sheet,re.range),ae=re===void 0||w===void 0?void 0:tN(w,re.range);if(w===void 0)return(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`This workbook has no sheets.`})});function oe(e){s!==void 0&&C.current!==e&&(C.current=e,s(e))}function se(e,t){let n=re;x(t&&n!==void 0?{sheet:w.name,range:$M(n.range,e)}:{sheet:w.name,range:e})}function ce(e,t){ne&&t.button===0&&(t.stopPropagation(),y(e))}function le(e,t){if(!ne)return;t.stopPropagation();let n=v??e;y(void 0),se({top:Math.min(n.row,e.row),left:Math.min(n.column,e.column),bottom:Math.max(n.row,e.row),right:Math.max(n.column,e.column)},t.shiftKey)}function A(e){ne&&(y(void 0),e.shiftKey||x(void 0))}function ue(){if(re!==void 0&&ie!==void 0&&ae!==void 0)return nN(ie,t,VM(ae),!eN(re.range))}function de(){let e=ue();e!==void 0&&(i(e),x(void 0))}function fe(e){let t=ue();t!==void 0&&ae!==void 0&&(e.dataTransfer.setData(xA,SA(t)),e.dataTransfer.setData(`text/plain`,ae),e.dataTransfer.effectAllowed=`copy`)}function pe(e){if(d(e),f!==`sheet`)return;let t=n.sheets[e].name;h(e=>({...e,sheet:KM(t)}))}function me(e){let t=qM(w.rows[e]);t!==``&&h(n=>n.headerRowIndex!==void 0&&e===n.headerRowIndex+(n.headerRows??1)?{...n,headerRows:(n.headerRows??1)+1}:{sheet:n.sheet,includeHidden:n.includeHidden,header:FM(t),headerRowIndex:e,headerRows:1})}function he(e){if(m.header===void 0)return;let t=qM(w.rows[e]);t!==``&&h(e=>({...e,until:FM(t)}))}function ge(e){if(O===void 0)return;let t=YM(E,O,e);if(t===``)return;let n=IM(t);h(e=>({...e,columns:{...e.columns,[n]:FM(t)}}))}function _e(e){if(O===void 0)return;let t=YM(E,O,e);if(t===``)return;let n=XM(m,t);h(e=>{let t=e.fillDown??[];return t.includes(n)?e:{...e,fillDown:[...t,n]}})}function ve(e,t,n){if(f===`header`){me(e);return}if(f===`until`){he(e);return}if(f===`column`){ge(t);return}f===`fillDown`&&n&&_e(t)}return(0,P.jsxs)(F,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,P.jsx)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:1,flexShrink:0,flexWrap:`wrap`,children:n.sheets.map((e,t)=>(0,P.jsx)(nP,{sheet:e,active:t===u,onClick:()=>{pe(t)}},e.name))}),(0,P.jsxs)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,flexWrap:`wrap`,children:[(0,P.jsx)(tP,{label:`Cell`,active:ne,onClick:()=>{p(`cell`)}}),(0,P.jsx)(tP,{label:`Sheet`,active:f===`sheet`,onClick:()=>{p(`sheet`)}}),(0,P.jsx)(tP,{label:`Header row(s)`,active:f===`header`,onClick:()=>{p(`header`)}}),(0,P.jsx)(tP,{label:`First non-data row (until)`,active:f===`until`,onClick:()=>{p(`until`)}}),(0,P.jsx)(tP,{label:`Column`,active:f===`column`,onClick:()=>{p(`column`)}}),(0,P.jsx)(tP,{label:`Fill down`,active:f===`fillDown`,onClick:()=>{p(`fillDown`)}}),n.csv!==void 0&&(0,P.jsx)(cP,{format:n.csv,override:c,onChange:l}),ne&&b===void 0&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Click a cell (shift+click, or press and release, for a range), then add it to the recipe or drag it onto the Steps tab.`}),m.header!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`green`,children:`table: ${m.header}${m.until===void 0?``:` until ${m.until}`}`}),k.data?.error!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`orange`,children:k.data.error})]}),(0,P.jsxs)(F,{flex:`1`,minH:`0`,display:`flex`,flexDirection:`column`,children:[(0,P.jsx)(F,{ref:S,flex:`1`,minH:`0`,overflow:`auto`,position:`relative`,onMouseUp:A,onMouseLeave:()=>{_(void 0),oe(void 0)},children:(0,P.jsxs)(F,{h:`${String(te.getTotalSize())}px`,position:`relative`,style:{width:`${String(w.columnCount*JN)}px`},children:[te.getVirtualItems().map(e=>D[e.index]?.map(t=>t===void 0?null:(0,P.jsx)(oP,{cell:t,top:e.start,isHeader:O?.includes(e.index)??!1,isHidden:w.hiddenRows.includes(e.index),isSnapped:ne&&g?.row===e.index&&g.column===t.columnIndex,isStaged:re!==void 0&&eP(re.range,e.index,t.columnIndex),stepIds:wN(e.index,t.columnIndex,T),hoveredStepId:o,onClick:ne?void 0:()=>{ve(e.index,t.columnIndex,t.isMergeLabel)},onMouseEnter:n=>{ne&&_({row:e.index,column:t.columnIndex}),oe(n[0])},onMouseDown:ne?n=>{ce({row:e.index,column:t.columnIndex},n)}:void 0,onMouseUp:ne?n=>{le({row:e.index,column:t.columnIndex},n)}:void 0},`${String(e.index)}:${String(t.columnIndex)}`))),re!==void 0&&(0,P.jsx)(fN,{left:re.range.left*JN,top:(re.range.bottom+1)*qN+4,text:ae,loading:!1,onAdd:de,onClear:()=>{x(void 0)},onDragStart:fe})]})}),ee!==void 0&&(0,P.jsx)(sP,{match:ee})]})]})}function QN(e){let t=$N(e.merges),n=new Map(e.merges.map(e=>[`${String(e.top)}:${String(e.left)}`,{rowSpan:e.bottom-e.top+1,colSpan:e.right-e.left+1}]));return e.rows.map((e,r)=>e.map((e,i)=>{let a=`${String(r)}:${String(i)}`;if(t.has(a))return;let o=n.get(a);return{columnIndex:i,rowSpan:o?.rowSpan??1,colSpan:o?.colSpan??1,value:e.value,type:e.type,isMergeLabel:o!==void 0&&o.rowSpan>1&&o.colSpan===1}}))}function $N(e){let t=new Set;for(let n of e)for(let e=n.top;e<=n.bottom;e+=1)for(let r=n.left;r<=n.right;r+=1)(e!==n.top||r!==n.left)&&t.add(`${String(e)}:${String(r)}`);return t}function eP(e,t,n){return t>=e.top&&t<=e.bottom&&n>=e.left&&n<=e.right}function tP({label:e,active:t,onClick:n}){return(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:t?`semibold`:`normal`,color:t?`colorPalette.fg`:`fg`,colorPalette:`blue`,cursor:`pointer`,onClick:n,children:e})}function nP({sheet:e,active:t,onClick:n}){return(0,P.jsxs)(G,{as:`button`,gap:1,px:2,py:1,borderRadius:`sm`,bg:t?`bg.emphasized`:void 0,opacity:e.hidden?.55:1,onClick:n,children:[(0,P.jsx)(H,{fontSize:`sm`,fontWeight:t?`semibold`:`normal`,children:e.name}),e.hidden&&(0,P.jsx)(Aw,{size:`xs`,colorPalette:`gray`,children:`hidden`})]})}var rP={string:`fg`,number:`orange.fg`,boolean:`blue.fg`,date:`purple.fg`};function iP(e,t,n){return e?`purple.fg`:t?`blue.fg`:n?`orange.solid`:`border.muted`}function aP(e,t,n,r){return n?`purple.muted`:r?`orange.subtle`:t?`yellow.subtle`:e.isMergeLabel?`purple.subtle`:`bg`}function oP({cell:e,top:t,isHeader:n,isHidden:r,isSnapped:i,isStaged:a,stepIds:o,hoveredStepId:s,onClick:c,onMouseEnter:l,onMouseDown:u,onMouseUp:d}){let f=o.length>0,p=s!==void 0&&o.includes(s);return(0,P.jsx)(F,{"data-testid":i?`snap-target`:a?`staged-cell`:`grid-cell`,"data-step-ids":f?o.join(` `):void 0,"data-highlighted":p,position:`absolute`,style:{top:`${String(t)}px`,left:`${String(e.columnIndex*JN)}px`,width:`${String(e.colSpan*JN)}px`,height:`${String(e.rowSpan*qN)}px`},borderWidth:f?`2px`:`1px`,borderStyle:f&&!p?`dashed`:`solid`,borderColor:iP(a,i,f),bg:aP(e,n,a,p),opacity:r?.4:1,overflow:`hidden`,px:1,fontSize:`xs`,color:rP[e.type],cursor:c===void 0?`cell`:`pointer`,_hover:{bg:a?`purple.muted`:`bg.emphasized`},onClick:c,onMouseEnter:l===void 0?void 0:()=>{l(o)},onMouseDown:u,onMouseUp:d,title:f?`In the recipe: ${o.join(`, `)}`:r?`Hidden row`:void 0,truncate:!0,children:String(e.value)})}function sP({match:e}){let t=e.rows.slice(0,XN);return(0,P.jsxs)(F,{borderTopWidth:`1px`,maxH:`160px`,overflow:`auto`,flexShrink:0,children:[(0,P.jsx)(G,{px:2,py:1,gap:2,children:(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Live preview: ${String(e.rows.length)} row${e.rows.length===1?``:`s`} matched${e.title===``?``:` ("${e.title}")`}`})}),(0,P.jsxs)(yE,{size:`sm`,variant:`outline`,children:[(0,P.jsx)(SE,{children:(0,P.jsx)(bE,{children:e.header.map(e=>(0,P.jsx)(CE,{fontSize:`2xs`,children:e},e))})}),(0,P.jsx)(TE,{children:t.map((t,n)=>(0,P.jsx)(bE,{children:e.header.map(e=>(0,P.jsx)(wE,{fontSize:`2xs`,children:String(t[e]??``)},e))},n))})]})]})}function cP({format:e,override:t,onChange:n}){let r=t?.delimiter??e.delimiter,i=t?.encoding??e.encoding;return(0,P.jsxs)(G,{gap:2,children:[(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Delimiter`}),(0,P.jsx)(DT,{size:`xs`,width:`40px`,defaultValue:r,onBlur:e=>{let i=e.target.value;i!==``&&i!==r&&n({delimiter:i,encoding:t?.encoding})}},r),(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Encoding`}),(0,P.jsx)(DT,{size:`xs`,width:`110px`,defaultValue:i,onBlur:e=>{let r=e.target.value;r!==``&&r!==i&&n({delimiter:t?.delimiter,encoding:r})}},i)]})}var lP=`modulepreload`,uP=function(e){return`/`+e},dP={},fP=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=uP(t,n),t=s(t),t in dP)return;dP[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`:lP,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}`)))})}).filter(e=>e!==void 0))}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)})},pP=[],mP=1.5,hP=1.2,gP=24,_P=4,vP=[`#2e86ab`,`#3bb273`],yP=`#e4572e`,bP=`rgba(59, 178, 115, 0.18)`,xP=`#1d4ed8`,SP=`#ea580c`;function CP({recipeId:e,stepPath:t,view:n,bytesUrl:r,onTablePick:i,onRegionPick:a,steps:o=pP,hoveredStepId:s,onHoverStepId:c}){let[l,u]=(0,N.useState)(0),[d,f]=(0,N.useState)(`text`),[p,m]=(0,N.useState)({}),[h,g]=(0,N.useState)(void 0),[_,v]=(0,N.useState)(void 0),[y,b]=(0,N.useState)(void 0),x=(0,N.useRef)(null),S=(0,N.useRef)(void 0),C=n.pages[l],w=(0,N.useMemo)(()=>yN(o,`page`,C?.number??-1),[o,C?.number]),T=C===void 0?0:Math.ceil(C.width*mP),E=C===void 0?0:Math.ceil(C.height*mP),D=hk(e,t,p.header===void 0?void 0:{header:p.header,until:p.until,columns:p.columns}),O=(0,N.useMemo)(()=>D.data?.matches.find(e=>e.page===C?.number),[D.data,C?.number]),k=_===void 0?void 0:RM(`page`,_.page,_.box),ee=gk(e,t,k),te=ee.data?.matches.find(e=>e.page===_?.page),ne=te?.text;if((0,N.useEffect)(()=>{p.header!==void 0&&i(LM(p,t))},[p]),(0,N.useEffect)(()=>{let e=x.current;if(e===null||C===void 0)return;let t=new AbortController;return PP(e,r,C.number,mP,t.signal).catch(e=>{t.signal.aborted||console.error(`PDF canvas: could not render the page`,e)}),()=>{t.abort()}},[r,C?.number]),C===void 0)return(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`This PDF has no pages.`})});function re(e){let t=e.cells[0]?.text??``;if(d===`header`){m({header:FM(t)});return}d===`until`&&p.header!==void 0&&m(e=>({...e,until:FM(t)}))}function ie(e){p.header!==void 0&&m(t=>({...t,columns:{...t.columns,[IM(e)]:FM(e)}}))}function ae(e,t){let n=_;v(t&&n!==void 0&&n.page===C.number?{page:C.number,box:BM(n.box,e)}:{page:C.number,box:e})}function oe(e){c!==void 0&&S.current!==e&&(S.current=e,c(e))}function se(e){if(d!==`text`)return;let t=wP(e);if(y!==void 0){b({...y,currentX:t.x,currentY:t.y});return}let n=kP(C,t);g(n),oe(n===void 0?void 0:xN(zM(n),w)[0])}function ce(e){if(d!==`text`||e.button!==0)return;let t=wP(e);b({startX:t.x,startY:t.y,currentX:t.x,currentY:t.y})}function le(e){if(d!==`text`||y===void 0)return;let t=wP(e);if(b(void 0),Math.abs(t.x-y.startX)+Math.abs(t.y-y.startY)>_P){ae(OP(C,y.startX,y.startY,t.x,t.y),e.shiftKey);return}let n=kP(C,t);if(n===void 0){e.shiftKey||v(void 0);return}ae(zM(n),e.shiftKey)}function A(){if(k!==void 0&&ne!==void 0)return HM(k,t,VM(ne))}function ue(){let e=A();e!==void 0&&(a(e),v(void 0))}function de(e){let t=A();t!==void 0&&ne!==void 0&&(e.dataTransfer.setData(xA,SA(t)),e.dataTransfer.setData(`text/plain`,ne),e.dataTransfer.effectAllowed=`copy`)}let fe=d===`text`,pe=_!==void 0&&_.page===C.number?_:void 0;return(0,P.jsxs)(F,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,P.jsxs)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,flexWrap:`wrap`,children:[n.pages.length>1&&(0,P.jsx)(jP,{pages:n.pages.length,value:l,onChange:u}),(0,P.jsx)(AP,{label:`Text`,active:fe,onClick:()=>{f(`text`)}}),(0,P.jsx)(AP,{label:`Header row`,active:d===`header`,onClick:()=>{f(`header`)}}),(0,P.jsx)(AP,{label:`Last row (until)`,active:d===`until`,onClick:()=>{f(`until`)}}),(0,P.jsx)(AP,{label:`Column`,active:d===`column`,onClick:()=>{f(`column`)}}),(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`${String(C.rowCount)} rows, ${String(C.cellCount)} cells${C.hasTextLayer?``:` — no text layer (a scan?)`}`}),fe&&_===void 0&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Click a line (shift+click to extend) or drag a box, then add it to the recipe or drag it onto the Steps tab.`}),p.header!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`green`,children:`table: ${p.header}${p.until===void 0?``:` until ${p.until}`}`}),D.data?.error!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`orange`,children:D.data.error}),ee.data?.error!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`orange`,children:ee.data.error})]}),(0,P.jsx)(F,{flex:`1`,minH:`0`,overflow:`auto`,position:`relative`,children:(0,P.jsxs)(F,{position:`relative`,width:`${String(T)}px`,height:`${String(E)}px`,children:[(0,P.jsx)(`canvas`,{ref:x,width:T,height:E,style:{position:`absolute`,top:0,left:0}}),(0,P.jsxs)(`svg`,{"data-testid":`pdf-overlay`,width:T,height:E,style:{position:`absolute`,top:0,left:0,cursor:fe?`crosshair`:`pointer`},onMouseMove:se,onMouseDown:ce,onMouseUp:le,onMouseLeave:()=>{g(void 0),oe(void 0)},children:[w.map(e=>(0,P.jsx)(`rect`,{"data-testid":`recipe-region`,"data-step-id":e.id,"data-highlighted":e.id===s,...DP(e.box,C.height),fill:e.id===s?`rgba(234, 88, 12, 0.22)`:`rgba(234, 88, 12, 0.05)`,stroke:SP,strokeWidth:e.id===s?2:1,strokeDasharray:e.id===s?void 0:`4 3`,pointerEvents:`none`,children:(0,P.jsx)(`title`,{children:`In the recipe: ${e.id}`})},`recipe:${e.id}`)),C.rows.map((e,t)=>(0,P.jsx)(MP,{row:e,colour:e.cells[0]?.text!==void 0&&O?.headerRowIndex===t?yP:vP[t%2],highlighted:O?.matchedRowIndices.includes(t)??!1,scale:mP,pageHeight:C.height,cursor:fe?`crosshair`:`pointer`,onClick:fe?void 0:()=>{re(e)}},`${String(e.top)}:${String(e.bottom)}`)),d===`column`&&O!==void 0&&O.bands.map(e=>(0,P.jsx)(NP,{band:e,scale:mP,pageHeight:C.height,onClick:()=>{ie(e.name)}},e.column)),fe&&h!==void 0&&y===void 0&&(0,P.jsx)(`rect`,{"data-testid":`snap-target`,...EP(h,C.height),fill:`rgba(29, 78, 216, 0.08)`,stroke:xP,strokeWidth:1.5,strokeDasharray:`3 2`,pointerEvents:`none`}),pe!==void 0&&(0,P.jsx)(`rect`,{"data-testid":`staged-region`,...DP(pe.box,C.height),fill:`rgba(155, 93, 229, 0.12)`,stroke:`#9b5de5`,strokeWidth:1.5,pointerEvents:`none`}),pe!==void 0&&te?.cells.map(e=>(0,P.jsx)(`rect`,{"data-testid":`staged-cell`,...EP(e,C.height),fill:`rgba(155, 93, 229, 0.28)`,pointerEvents:`none`},TP(e))),y!==void 0&&(0,P.jsx)(`rect`,{x:Math.min(y.startX,y.currentX),y:Math.min(y.startY,y.currentY),width:Math.abs(y.currentX-y.startX),height:Math.abs(y.currentY-y.startY),fill:`rgba(155, 93, 229, 0.2)`,stroke:`#9b5de5`,strokeDasharray:`4 2`,pointerEvents:`none`})]}),pe!==void 0&&(0,P.jsx)(fN,{left:Math.min(pe.box.x1,pe.box.x2)*mP,top:(C.height-Math.min(pe.box.y1,pe.box.y2))*mP+6,text:ne,loading:ee.isPending,onAdd:ue,onClear:()=>{v(void 0)},onDragStart:de})]})})]})}function wP(e){let t=e.currentTarget.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function TP(e){return`staged:${String(e.x)}:${String(e.y)}`}function EP(e,t){return{x:e.x*mP,y:(t-e.y-e.height)*mP,width:Math.max(e.width,1)*mP,height:e.height*mP*hP}}function DP(e,t){let[n,r]=[Math.min(e.x1,e.x2),Math.max(e.x1,e.x2)],[i,a]=[Math.min(e.y1,e.y2),Math.max(e.y1,e.y2)];return{x:n*mP,y:(t-a)*mP,width:(r-n)*mP,height:(a-i)*mP}}function OP(e,t,n,r,i){return{x1:t/mP,y1:e.height-n/mP,x2:r/mP,y2:e.height-i/mP}}function kP(e,t){let n;for(let r of e.rows)for(let i of r.cells){let r=EP(i,e.height),a=Math.max(r.x-t.x,0,t.x-(r.x+r.width)),o=Math.max(r.y-t.y,0,t.y-(r.y+r.height)),s=Math.hypot(a,o);s<=gP&&(n===void 0||s<n.distance)&&(n={cell:i,distance:s})}return n?.cell}function AP({label:e,active:t,onClick:n}){return(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:t?`semibold`:`normal`,color:t?`colorPalette.fg`:`fg`,colorPalette:`blue`,cursor:`pointer`,onClick:n,children:e})}function jP({pages:e,value:t,onChange:n}){let r=l_({items:Array.from({length:e},(e,t)=>({label:`Page ${String(t+1)}`,value:String(t)}))});return(0,P.jsxs)(VT,{collection:r,size:`sm`,width:`140px`,value:[String(t)],onValueChange:e=>{n(Number(e.value[0]))},children:[(0,P.jsx)(JT,{}),(0,P.jsx)(qT,{children:(0,P.jsx)(HT,{children:(0,P.jsx)(GT,{})})}),(0,P.jsx)(UT,{children:(0,P.jsx)(WT,{children:r.items.map(e=>(0,P.jsx)(KT,{item:e,children:e.label},e.value))})})]})}function MP({row:e,colour:t,highlighted:n,scale:r,pageHeight:i,cursor:a,onClick:o}){return(0,P.jsxs)(`g`,{onClick:o,style:{cursor:a},children:[n&&e.cells.length>0&&(0,P.jsx)(`rect`,{x:Math.min(...e.cells.map(e=>e.x))*r,y:(i-e.top)*r,width:(Math.max(...e.cells.map(e=>e.x+e.width))-Math.min(...e.cells.map(e=>e.x)))*r,height:(e.top-e.bottom)*r,fill:bP}),e.cells.map(e=>(0,P.jsx)(`rect`,{x:e.x*r,y:(i-e.y-e.height)*r,width:Math.max(e.width,1)*r,height:e.height*r*hP,fill:`transparent`,stroke:t,strokeWidth:1.5},`${String(e.x)}:${String(e.y)}`))]})}function NP({band:e,scale:t,pageHeight:n,onClick:r}){return(0,P.jsx)(`rect`,{x:e.start*t,y:0,width:Math.max(e.end-e.start,1)*t,height:n*t,fill:`rgba(46, 134, 171, 0.08)`,stroke:`#2e86ab`,strokeDasharray:`4 2`,onClick:r,style:{cursor:`pointer`},children:(0,P.jsx)(`title`,{children:e.name})})}async function PP(e,t,n,r,i){let a=await fP(()=>import(`./pdf-DS1lgaK8.js`),[]),o=await fP(()=>import(`./pdf.worker.min-D7i8o3wR.js`),[]);a.GlobalWorkerOptions.workerSrc=o.default;let s=a.getDocument({url:t}),c=await s.promise;try{let t=await c.getPage(n);if(i.aborted)return;let a=t.getViewport({scale:r});e.width=Math.ceil(a.width),e.height=Math.ceil(a.height);let o=e.getContext(`2d`);if(o===null)return;let s=t.render({canvas:e,canvasContext:o,viewport:a});i.addEventListener(`abort`,()=>{s.cancel()}),await s.promise}finally{await s.destroy()}}function FP(e,t){return{kind:`card`,path:t,stepType:`goto`,sentence:[{kind:`word`,text:`Go to`},{kind:`code`,text:e}],custom:!1,step:{type:`goto`,url:e}}}function IP(e,t){return[{type:`goto`,url:e},...t]}function LP(e,t,n,r){return{...n,steps:IP(e,t),keep:[`cookies`],saveTo:r}}function RP(e){let t=e.start;if(!Array.isArray(t))return;let n=t[0];if(typeof n!=`object`||!n)return;let r=n.url;return typeof r==`string`?r:void 0}function zP(e,t){let n=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),r=n===-1?`.`:e.slice(0,n),i=n===-1||e[n]===void 0?`/`:e[n];return`${r}${i}storage${i}${t}-session.json`}function BP(e,t,n){let r=[`[data-oc-node] { cursor: ${e?`crosshair`:`inherit`}; }`,`[data-oc-node]:hover { outline: 2px solid #3182ce !important; outline-offset: -2px; }`];return n!==void 0&&n!==``&&r.push(`${n} { outline: 2px solid #dd6b20 !important; outline-offset: -2px; background: rgba(221,107,32,0.08) !important; }`),t&&r.push(`[data-oc-hidden] { display: revert !important; visibility: visible !important; opacity: 0.5 !important; outline: 1px dashed #ed8936 !important; }`),r.join(`
|
|
15
|
-
`)}var VP=`data-oc-node`,HP=`opencraw-picker-style`;function UP({html:e,pickMode:t,showHidden:n,hoveredSelector:r,onHoverNode:i,onPickNode:a}){let o=(0,N.useRef)(null),s=(0,N.useRef)({pickMode:t,onHoverNode:i,onPickNode:a});return s.current={pickMode:t,onHoverNode:i,onPickNode:a},(0,N.useEffect)(()=>{let e=o.current;if(e===null)return;let t,n=e=>{s.current.onHoverNode(WP(e.target))},r=()=>{s.current.onHoverNode(void 0)},i=e=>{if(!s.current.pickMode)return;let t=WP(e.target);t!==void 0&&(e.preventDefault(),e.stopPropagation(),s.current.onPickNode(t))},a=()=>{let a=e.contentDocument;a!==null&&(a.addEventListener(`mouseover`,n),a.addEventListener(`mouseout`,r),a.addEventListener(`click`,i,{capture:!0}),t=()=>{a.removeEventListener(`mouseover`,n),a.removeEventListener(`mouseout`,r),a.removeEventListener(`click`,i,{capture:!0})})};return e.addEventListener(`load`,a),()=>{e.removeEventListener(`load`,a),t?.()}},[e]),(0,N.useEffect)(()=>{let e=o.current?.contentDocument;if(e==null)return;let i=e.getElementById(HP);i===null&&(i=e.createElement(`style`),i.id=HP,e.head?.append(i)),i.textContent=BP(t,n,r)}),(0,P.jsx)(`iframe`,{ref:o,title:`Snapshot`,sandbox:`allow-same-origin`,srcDoc:e,style:{width:`100%`,height:`100%`,border:`none`,background:`white`}})}function WP(e){return(e?.nodeType===Node.ELEMENT_NODE?e.closest(`[${CSS.escape(VP)}]`):null)?.getAttribute(VP)??void 0}var GP=[],KP={object:`purple.fg`,array:`purple.fg`,element:`purple.fg`,string:`green.fg`,number:`orange.fg`,boolean:`blue.fg`,null:`fg.muted`};function qP({tree:e,onPick:t,steps:n=GP,hoveredStepId:r,onHoverStepId:i}){let[a,o]=(0,N.useState)(()=>new Set);function s(e){o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,P.jsxs)(F,{h:`full`,overflow:`auto`,fontFamily:`mono`,fontSize:`xs`,py:2,children:[e.namespaces!==void 0&&Object.keys(e.namespaces).length>0&&(0,P.jsxs)(G,{px:2,pb:2,gap:2,flexWrap:`wrap`,children:[(0,P.jsx)(H,{color:`fg.muted`,children:`Namespaces:`}),Object.entries(e.namespaces).map(([e,t])=>(0,P.jsx)(Aw,{size:`xs`,colorPalette:`gray`,children:`${e}: ${t}`},e))]}),(0,P.jsx)(JP,{node:e.root,depth:0,collapsed:a,onToggle:s,onPick:t,steps:n,hoveredStepId:r,onHoverStepId:i})]})}function JP({node:e,depth:t,collapsed:n,onToggle:r,onPick:i,steps:a,hoveredStepId:o,onHoverStepId:s}){let c=e.children.length>0,l=n.has(e.id),u=e.valueType!==`object`&&e.valueType!==`array`&&e.valueType!==`element`,d=_N(e,a),f=o!==void 0&&d.includes(o);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(G,{"data-testid":`tree-node`,"data-highlighted":f,"data-step-ids":d.length===0?void 0:d.join(` `),gap:1,pl:`${t*14+4}px`,pr:2,minH:`20px`,cursor:`pointer`,bg:f?`orange.subtle`:void 0,_hover:{bg:f?`orange.subtle`:`bg.emphasized`},onClick:()=>{i(e,`value`)},onMouseEnter:s===void 0?void 0:()=>{s(d[0])},onMouseLeave:s===void 0?void 0:()=>{s(void 0)},children:[c?(0,P.jsx)(H,{as:`button`,w:`12px`,flexShrink:0,color:`fg.muted`,onClick:t=>{t.stopPropagation(),r(e.id)},children:l?`▸`:`▾`}):(0,P.jsx)(F,{w:`12px`,flexShrink:0}),(0,P.jsx)(H,{as:`span`,color:KP[e.valueType],fontWeight:`medium`,children:e.label}),u&&e.preview!==void 0&&(0,P.jsx)(H,{as:`span`,color:`fg.muted`,truncate:!0,children:e.preview}),d.map(e=>(0,P.jsx)(Aw,{size:`xs`,colorPalette:`orange`,variant:f?`solid`:`subtle`,title:`Already in the recipe: the step reading this`,flexShrink:0,children:e},e)),e.listPath!==void 0&&(0,P.jsx)(Aw,{as:`button`,size:`xs`,colorPalette:`blue`,onClick:t=>{t.stopPropagation(),i(e,`list`)},title:`Read every one of the ${String(e.listCount??0)} items in this list`,children:`[*] ×${String(e.listCount??0)}`}),u&&e.jsonpath!==void 0&&(0,P.jsx)(H,{as:`button`,fontSize:`2xs`,color:`fg.muted`,_hover:{color:`fg`,textDecoration:`underline`},onClick:t=>{t.stopPropagation(),i(e,`next`)},title:`Use as the pagination "next" cursor/URL`,children:`next →`})]}),c&&!l&&e.children.map(e=>(0,P.jsx)(JP,{node:e,depth:t+1,collapsed:n,onToggle:r,onPick:i,steps:a,hoveredStepId:o,onHoverStepId:s},e.id))]})}var YP=100,XP=`img, picture, video, canvas, svg, iframe, object, embed, input, select, textarea, table`,ZP=`h1, h2, h3, h4, h5, h6, li, a[href]`;function QP(e){let t=new DOMParser().parseFromString(e,`text/html`).body;for(let e of t.querySelectorAll(`script, style, noscript, template`))e.remove();return(t.textContent??``).trim().length>=YP||t.querySelector(`${XP}, ${ZP}`)!==null}function $P(e,t){let n=OO(e,t)?.step.selector;return typeof n==`string`?n:void 0}function eF(e,t,n){if(e!==void 0&&t!==void 0)for(let r of AO(e)){let e=r.step.selector,i=r.step.id;if(typeof e==`string`&&typeof i==`string`&&sA(t,e).has(n))return i}}var tF=`start`,nF=new Set([`json`,`yaml`,`jsonl`,`xml`]),rF=new Set([`csv`,`xlsx`]),iF=new Set([`pptx`]);function aF({recipe:e,onSaveOutline:t,onSaveRecipe:n}){let r=e?.id,i=ck(r,r===void 0?void 0:tF),a=lk(),[o,s]=(0,N.useState)(!1),c=LO(),l=i.data?.format,u=l!==void 0&&nF.has(l),d=l===`pdf`,f=l!==void 0&&rF.has(l),p=l!==void 0&&iF.has(l),m=!u&&!d&&!f&&!p,h=i.data?.html,g=(0,N.useMemo)(()=>h===void 0||QP(h),[h]),_=pk(r,r===void 0?void 0:tF,u),v=mk(r,r===void 0?void 0:tF,d),[y,b]=(0,N.useState)(void 0),x=_k(r,r===void 0?void 0:tF,f,y),S=yk(r,r===void 0?void 0:tF,p),C=JO(e=>e.pickTarget),w=JO(e=>e.showHidden),T=JO(e=>e.hoveredStepId),E=JO(e=>e.startPicking),D=JO(e=>e.stopPicking),O=JO(e=>e.registerPick),k=JO(e=>e.setShowHidden),ee=JO(e=>e.setHoveredNodeId),te=JO(e=>e.setHoveredStepId),ne=(0,N.useMemo)(()=>$P(e?.outline,T),[e?.outline,T]),re=(0,N.useMemo)(()=>gN(e?.outline),[e?.outline]),ie=t=>{ee(t),te(t===void 0?void 0:eF(e?.outline,i.data?.html,t))},ae=QO(e=>e.recipeId),oe=QO(e=>e.active),se=QO(e=>e.cards.length),ce=QO(e=>e.stoppedSteps),le=QO(e=>e.error),A=QO(e=>e.dismissStopped),ue=xk(),de=Sk(),fe=ae===r&&oe,pe=ae===r?ce:void 0,[me,he]=(0,N.useState)(void 0),ge=e=>{he(e===void 0?void 0:{text:e,ok:!0})},_e=e=>{he(e===void 0?void 0:{text:e,ok:!1})},ve=(0,N.useRef)(void 0),ye=(0,N.useRef)(void 0),j=C!==void 0&&C.recipeId===r;(0,N.useEffect)(()=>{ye.current=void 0,b(void 0)},[r]);async function M(e){if(r===void 0)return;let t=O(e);if(t.kind===`first`){let t=await a.mutateAsync({recipeId:r,path:tF,nodeIds:[e]});if(t.kind!==`field`){_e(t.kind===`unsupported`?t.reason:void 0);return}await we(e=>(ve.current=mO(e),ge(`Read card: ${t.field.selector} (${t.field.matches} match${t.field.matches===1?``:`es`})`),hO(e,void 0,[oO(t.field,`steps.${e.length}`)])));return}let n=await a.mutateAsync({recipeId:r,path:tF,nodeIds:[t.firstNodeId,e]});if(n.kind!==`list`){_e(n.kind===`unsupported`?n.reason:void 0);return}await we(e=>{let t=ve.current;ve.current=void 0;let r=t??mO(e);return ge(`List: ${n.item.selector} (${n.item.matches} items) → ${n.field.selector}`),hO(e,t,lO(n,`steps.${r}`))})}async function be(e,t){if(r!==void 0)try{if(t===`next`){await we(t=>{let n=cO(e,`steps.${t.length}`);return ge(`Paginate: next from ${e.jsonpath}`),hO(t,void 0,[n])});return}await we(n=>{if(t===`list`){let t=pO(n,e);if(t!==void 0)return ge(`Added to the list: ${String(e.listPath)}`),t;let r=fO(e,`steps.${mO(n)}`);if(r!==void 0)return ge(`List: ${String(e.listPath)} (${String(e.listCount??0)} items)`),hO(n,void 0,r)}let r=sO(e,`steps.${n.length}`,{generalize:t===`list`,namespaces:_.data?.namespaces});return ge(`Read card: ${r.step.selector}${t===`list`?` (${String(e.listCount??0)} items)`:``}`),hO(n,void 0,[r])})}catch(e){_e(e instanceof Error?e.message:String(e))}}async function xe(e){await we(t=>{let n=ye.current,r=n??mO(t);return ye.current=r,ge(`table: ${String(e.step.selector)}`),hO(t,n,[{...e,path:`steps.${r}`}])})}async function Se(e){await we(t=>(ge(`${String(e.step.kind)}: ${String(e.step.id)} ← ${String(e.step.selector)}`),hO(t,void 0,[{...e,path:`steps.${t.length}`}])))}async function Ce(e){await we(t=>(ge(`jsonpath: ${String(e.step.selector)}`),hO(t,void 0,[{...e,path:`steps.${t.length}`}])))}async function we(n){if(t===void 0||e?.outline===void 0)return;let r=n(e.outline.steps);await t(e.file,{...e.outline,steps:r})}function Te(){if(r===void 0||e?.outline===void 0)return;let t=RP(e.outline.recipe);if(t===void 0){_e(`this recipe has no start point to record from`);return}ue.mutate({recipeId:r,startUrl:t})}async function Ee(){if(pe===void 0||e?.outline===void 0)return;let n=QO.getState().startUrl;if(n===void 0)return;let i=e.outline.recipe.session,a=oF(i)?i:{},o=a.bootstrap,s=oF(o)?o:void 0,c=zP(e.file,r??`recipe`),l={...a,bootstrap:LP(n,pe,s,c)};await t?.(e.file,{...e.outline,recipe:{...e.outline.recipe,session:l}}),ge(`Made the login: session.bootstrap, ${pe.length} step${pe.length===1?``:`s`}`),A()}async function De(){if(pe===void 0||e?.outline===void 0)return;let t=QO.getState().startUrl;if(t===void 0)return;let n=QO.getState().cards;await we(e=>hO(e,void 0,[FP(t,`steps.${e.length}`),...n.map(e=>e.node)])),ge(`Kept as steps: ${pe.length} step${pe.length===1?``:`s`}`),A()}if(r===void 0)return(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`Pick a recipe to see its snapshot here.`})});function Oe(){if(j){D();return}ve.current=void 0,E(r,tF)}return(0,P.jsxs)(F,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,P.jsxs)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,children:[!u&&!d&&!f&&!p&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:j?`semibold`:`normal`,color:j?`colorPalette.fg`:`fg`,colorPalette:`blue`,cursor:`pointer`,onClick:Oe,children:j?`Cancel pick`:`Read`}),(0,P.jsxs)(cE,{checked:w,onCheckedChange:e=>{k(e.checked)},size:`sm`,children:[(0,P.jsx)(fE,{}),(0,P.jsx)(dE,{}),(0,P.jsx)(lE,{fontSize:`sm`,children:`Show hidden`})]}),(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:o?`semibold`:`normal`,color:o?`colorPalette.fg`:`fg`,colorPalette:`purple`,cursor:`pointer`,onClick:()=>{s(e=>!e)},children:o?`Hide inspector`:`Inspect`}),(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:fe?`semibold`:`normal`,color:fe?`red.fg`:`fg`,colorPalette:`red`,cursor:`pointer`,onClick:()=>{fe?de.mutate():Te()},children:fe?`Stop recording`:`Record`})]}),u&&(0,P.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:`Click a value to read it; [*] reads every item of a list.`}),(i.isFetching||u&&_.isFetching||d&&v.isFetching||f&&x.isFetching||p&&S.isFetching)&&(0,P.jsx)(Nw,{size:`xs`}),me!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:me.ok?`green`:`orange`,children:me.text})]}),fe&&(0,P.jsxs)(G,{px:3,py:2,bg:`red.subtle`,color:`red.fg`,fontSize:`sm`,gap:3,flexShrink:0,"data-testid":`recording-banner`,children:[(0,P.jsx)(F,{w:`8px`,h:`8px`,borderRadius:`full`,bg:`red.solid`,flexShrink:0}),(0,P.jsx)(H,{children:`Recording — a browser window opened for you to drive; interact with it, not with the snapshot below.`}),(0,P.jsxs)(Aw,{size:`sm`,colorPalette:`red`,children:[se,` step`,se===1?``:`s`]})]}),le!==void 0&&ae===r&&(0,P.jsx)(F,{px:3,py:1,bg:`red.subtle`,color:`red.fg`,fontSize:`sm`,flexShrink:0,children:le}),pe!==void 0&&(0,P.jsxs)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,"data-testid":`recording-stopped-bar`,children:[(0,P.jsxs)(H,{fontSize:`sm`,children:[`Recording stopped: `,pe.length,` step`,pe.length===1?``:`s`,` recorded.`]}),(0,P.jsx)(Rw,{size:`xs`,colorPalette:`blue`,onClick:()=>{Ee()},disabled:pe.length===0,children:`Make this the login`}),(0,P.jsx)(Rw,{size:`xs`,variant:`outline`,onClick:()=>{De()},disabled:pe.length===0,children:`Keep as steps`}),(0,P.jsx)(Rw,{size:`xs`,variant:`ghost`,onClick:A,children:`Discard`})]}),m&&i.data!==void 0&&!g&&(0,P.jsx)(AM,{}),(0,P.jsxs)(F,{flex:`1`,minH:`0`,children:[u&&_.data!==void 0&&(0,P.jsx)(qP,{tree:_.data,onPick:(e,t)=>{be(e,t)},steps:re,hoveredStepId:T,onHoverStepId:te}),u&&_.isError&&(0,P.jsx)(F,{p:4,color:`fg.error`,children:(0,P.jsx)(H,{children:_.error.message})}),d&&v.data!==void 0&&(0,P.jsx)(CP,{recipeId:r,stepPath:tF,view:v.data,bytesUrl:c.pdfBytesUrl(r,tF),onTablePick:e=>{xe(e)},onRegionPick:e=>{Se(e)},steps:re,hoveredStepId:T,onHoverStepId:te}),d&&v.isError&&(0,P.jsx)(F,{p:4,color:`fg.error`,children:(0,P.jsx)(H,{children:v.error.message})}),f&&x.data!==void 0&&(0,P.jsx)(ZN,{recipeId:r,stepPath:tF,view:x.data,onTablePick:e=>{xe(e)},onCellPick:e=>{Se(e)},steps:re,hoveredStepId:T,onHoverStepId:te,csvOverride:y,onCsvOverrideChange:b}),f&&x.isError&&(0,P.jsx)(F,{p:4,color:`fg.error`,children:(0,P.jsx)(H,{children:x.error.message})}),p&&S.data!==void 0&&(0,P.jsx)(NN,{recipeId:r,stepPath:tF,view:S.data,onTablePick:e=>{xe(e)},onChartPick:e=>{Ce(e)},onRegionPick:e=>{Se(e)},steps:re,hoveredStepId:T,onHoverStepId:te}),p&&S.isError&&(0,P.jsx)(F,{p:4,color:`fg.error`,children:(0,P.jsx)(H,{children:S.error.message})}),!u&&!d&&!f&&!p&&i.data!==void 0&&!o&&(0,P.jsx)(UP,{html:i.data.html,pickMode:j,showHidden:w,hoveredSelector:ne,onHoverNode:ie,onPickNode:e=>{M(e)}}),!u&&!d&&!f&&!p&&i.data!==void 0&&o&&(0,P.jsxs)($T,{panels:[{id:`snapshot`,minSize:15},{id:`inspect`,minSize:20}],h:`full`,children:[(0,P.jsx)(eE,{id:`snapshot`,overflow:`hidden`,children:(0,P.jsx)(UP,{html:i.data.html,pickMode:j,showHidden:w,hoveredSelector:ne,onHoverNode:ie,onPickNode:e=>{M(e)}})}),(0,P.jsx)(rE,{id:`snapshot:inspect`}),(0,P.jsx)(eE,{id:`inspect`,overflow:`hidden`,children:(0,P.jsx)(vA,{recipeId:r,recipe:e,snapshot:i.data,onSaveOutline:t,onSaveRecipe:n})})]}),i.isError&&(0,P.jsxs)(F,{p:4,color:`fg.error`,role:`alert`,children:[(0,P.jsx)(H,{fontWeight:`semibold`,children:`Could not take a snapshot of this recipe's page.`}),(0,P.jsx)(H,{children:i.error.message})]}),!i.isFetching&&!i.isError&&i.data===void 0&&(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`Run a sample, or open a recipe, to see its snapshot here.`})})]})]})}function oF(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var sF=1024,cF=0,lF=class{constructor(e,t){this.from=e,this.to=t}},uF=class{constructor(e={}){this.id=cF++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=pF.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};uF.closedBy=new uF({deserialize:e=>e.split(` `)}),uF.openedBy=new uF({deserialize:e=>e.split(` `)}),uF.group=new uF({deserialize:e=>e.split(` `)}),uF.isolate=new uF({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),uF.contextHash=new uF({perNode:!0}),uF.lookAhead=new uF({perNode:!0}),uF.mounted=new uF({perNode:!0});var dF=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[uF.mounted.id]}},fF=Object.create(null),pF=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):fF,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(uF.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(uF.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};pF.none=new pF(``,Object.create(null),0,8);var mF=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new pF(e.name,r,e.id,e.flags):e)}return new e(n)}},hF=new WeakMap,gF=new WeakMap,_F;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(_F||={});var vF=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=dF.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new MF(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new MF(hF.get(this)||this.topNode);return r.moveTo(e,t),hF.set(this,r._tree),r}get topNode(){return new wF(this,0,0,null)}resolve(e,t=0){let n=SF(hF.get(this)||this.topNode,e,t,!1);return hF.set(this,n),n}resolveInner(e,t=0){let n=SF(gF.get(this)||this.topNode,e,t,!0);return gF.set(this,n),n}resolveStack(e,t=0){return jF(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&_F.IncludeAnonymous)>0;for(let e=this.cursor(a|_F.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:LF(pF.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(pF.none,t,n,r)))}static build(e){return PF(e)}};vF.empty=new vF(pF.none,[],[],0);var yF=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},bF=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return pF.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(xF(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function xF(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function SF(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof wF&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:_F.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof wF&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var CF=class{cursor(e=0){return new MF(this,e)}getChild(e,t=null,n=null){let r=TF(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return TF(this,e,t,n)}resolve(e,t=0){return SF(this,e,t,!1)}resolveInner(e,t=0){return SF(this,e,t,!0)}matchContext(e){return EF(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},wF=class e extends CF{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&_F.EnterBracketed&&l instanceof vF&&(d=dF.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||xF(i,r,u,u+l.length)){if(l instanceof bF){if(a&_F.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new OF(new DF(o,l,t,u),null,e)}else if(a&_F.IncludeAnonymous||!l.type.isAnonymous||NF(l)){let s;if(!(a&_F.IgnoreMounts)&&(s=dF.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&_F.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&_F.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&_F.IgnoreOverlays)&&(i=dF.get(this._tree))&&i.overlay){let a=t-this.from,o=r&_F.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function TF(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function EF(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var DF=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},OF=class e extends CF{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&_F.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new vF(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function kF(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof wF&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new AF(i,n)}var AF=class{constructor(e,t){this.heads=e,this.node=t}get next(){return kF(this.heads)}};function jF(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof wF?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=dF.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new wF(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(SF(o,t,n,!1))}}return i?kF(i):r}var MF=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~_F.EnterBracketed,e instanceof wF)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof wF?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&_F.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&_F.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&_F.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&_F.IncludeAnonymous||e instanceof bF||!e.type.isAnonymous||NF(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new OF(this.buffer,t,this.stack[e]);return this.bufferNode=new OF(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return EF(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return EF(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function NF(e){return e.children.some(e=>e instanceof bF||!e.type.isAnonymous||NF(e))}function PF(e){let{buffer:t,nodeSet:n,maxBufferLength:r=sF,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new yF(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0){if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}if(w==-3){c=x;return}if(w==-4){l=x;return}throw RangeError(`Unrecognized record size: ${w}`)}let D=s[x],O,k,ee=S-e;if(C-S<=r&&(k=h(o.pos-t,y))){let t=new Uint16Array(k.size-k.skip),r=o.pos-k.size,i=t.length;for(;o.pos>r;)i=g(k.start,t,i);O=new bF(t,C-k.start,n),ee=k.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,E),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,E),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(D,E);O=LF(D,t,n,0,t.length,0,C-S,e,e)}else O=m(D,t,n,C-S,T-C,E)}_.push(O),v.push(ee)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new bF(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof vF){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(uF.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[uF.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[uF.lookAhead,i];o=o?[e].concat(o):[e]}return new vF(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new vF(s[e.topID],_.reverse(),v.reverse(),y)}var FF=new WeakMap;function IF(e,t){if(!e.isAnonymous||t instanceof bF||t.type!=e)return 1;let n=FF.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof vF)){n=1;break}n+=IF(e,r)}FF.set(t,n)}return n}function LF(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=IF(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=IF(e,t[s]);for(s++;s<i;s++){let n=IF(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(LF(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var RF=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},zF=class{startParse(e,t,n){return typeof e==`string`&&(e=new BF(e)),n=n?n.length?n.map(e=>new lF(e.from,e.to)):[new lF(0,0)]:[new lF(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},BF=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new uF({perNode:!0});var VF=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new HF(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&s==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this.buffer.length;if(e>0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new UF(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new HF(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},HF=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},UF=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},WF=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function GF(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var KF=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},qF=new KF,JF=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=qF,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1:this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=qF,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},YF=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;ZF(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};YF.prototype.contextual=YF.prototype.fallback=YF.prototype.extend=!1;var XF=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?GF(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(ZF(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};XF.prototype.contextual=YF.prototype.fallback=YF.prototype.extend=!1;function ZF(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||$F(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function QF(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function $F(e,t,n,r){let i=QF(n,r,t);return i<0||QF(n,r,e)<i}var eI=typeof process<`u`&&/\bparse\b/.test({}.LOG),tI=null;function nI(e,t,n){let r=e.cursor(_F.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var rI=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?nI(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?nI(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof vF){if(a==e){if(a<this.safeFrom)return null;let e=a+i.length;if(e<=this.safeTo){let t=i.prop(uF.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},iI=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new KF)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if((!n||c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new KF,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new KF,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535){if(o[s+1]==1)s=lI(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(lI(o,s+2),t,n,r));break}}o[s]==t&&(r=this.putAction(lI(o,s+1),t,n,r))}return r}},aI=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new JF(t,r),this.tokens=new iI(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[VF.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new rI(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&uI(r);if(e)return eI&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw eI&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return eI&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=eI?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(uF.contextHash)||0)==n))return e.useNode(o,r),eI&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(o.type.id)})`),!0;if(!(o instanceof vF)||o.children.length==0||o.positions[0]>0)break;let s=o.children[0];if(s instanceof vF&&o.positions[0]==0)o=s;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),eI&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),eI&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return oI(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=eI?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),eI&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(eI&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)eI&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))eI&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),eI&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),oI(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),vF.build({buffer:WF.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(tI||=new WeakMap).get(e);return t||tI.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function oI(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var sI=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},cI=class e extends zF{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=uF[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new mF(t.map((t,i)=>pF.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=sF;let a=GF(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(dI),this.states=GF(e.states,Uint32Array),this.data=GF(e.stateData),this.goto=GF(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new YF(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new aI(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535){if(n[i+1]==1)a=n[i=lI(n,i+2)];else if(n[i+1]==2)return lI(n,i+2);else break}if(a==t||a==0)return lI(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=lI(this.data,n+2);else break}r=t(lI(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=lI(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=dI(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new sI(e,n,r)}static deserialize(t){return new e(t)}};function lI(e,t){return e[t]|e[t+1]<<16}function uI(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function dI(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}var fI=0,pI=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=fI++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new hI(e);return e=>e.modified.indexOf(t)>-1?e:hI.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},mI=0,hI=class e{constructor(e){this.name=e,this.instances=[],this.id=mI++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&gI(n,e.modified));if(r)return r;let i=[],a=new pI(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=_I(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function gI(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function _I(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function vI(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new bI(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return yI.add(t)}var yI=new uF({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new bI(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),bI=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};bI.empty=new bI([],2,null);function xI(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function SI(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function CI(e,t,n,r=0,i=e.length){let a=new wI(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var wI=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=TI(e)||bI.empty,u=SI(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(uF.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function TI(e){let t=e.type.prop(yI);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var K=pI.define,EI=K(),DI=K(),OI=K(DI),kI=K(DI),AI=K(),jI=K(AI),MI=K(AI),NI=K(),PI=K(NI),FI=K(),II=K(),LI=K(),RI=K(LI),zI=K(),q={comment:EI,lineComment:K(EI),blockComment:K(EI),docComment:K(EI),name:DI,variableName:K(DI),typeName:OI,tagName:K(OI),propertyName:kI,attributeName:K(kI),className:K(DI),labelName:K(DI),namespace:K(DI),macroName:K(DI),literal:AI,string:jI,docString:K(jI),character:K(jI),attributeValue:K(jI),number:MI,integer:K(MI),float:K(MI),bool:K(AI),regexp:K(AI),escape:K(AI),color:K(AI),url:K(AI),keyword:FI,self:K(FI),null:K(FI),atom:K(FI),unit:K(FI),modifier:K(FI),operatorKeyword:K(FI),controlKeyword:K(FI),definitionKeyword:K(FI),moduleKeyword:K(FI),operator:II,derefOperator:K(II),arithmeticOperator:K(II),logicOperator:K(II),bitwiseOperator:K(II),compareOperator:K(II),updateOperator:K(II),definitionOperator:K(II),typeOperator:K(II),controlOperator:K(II),punctuation:LI,separator:K(LI),bracket:RI,angleBracket:K(RI),squareBracket:K(RI),paren:K(RI),brace:K(RI),content:NI,heading:PI,heading1:K(PI),heading2:K(PI),heading3:K(PI),heading4:K(PI),heading5:K(PI),heading6:K(PI),contentSeparator:K(NI),list:K(NI),quote:K(NI),emphasis:K(NI),strong:K(NI),link:K(NI),monospace:K(NI),strikethrough:K(NI),inserted:K(),deleted:K(),changed:K(),invalid:K(),meta:zI,documentMeta:K(zI),annotation:K(zI),processingInstruction:K(zI),definition:pI.defineModifier(`definition`),constant:pI.defineModifier(`constant`),function:pI.defineModifier(`function`),standard:pI.defineModifier(`standard`),local:pI.defineModifier(`local`),special:pI.defineModifier(`special`)};for(let e in q){let t=q[e];t instanceof pI&&(t.name=e)}xI([{tag:q.link,class:`tok-link`},{tag:q.heading,class:`tok-heading`},{tag:q.emphasis,class:`tok-emphasis`},{tag:q.strong,class:`tok-strong`},{tag:q.keyword,class:`tok-keyword`},{tag:q.atom,class:`tok-atom`},{tag:q.bool,class:`tok-bool`},{tag:q.url,class:`tok-url`},{tag:q.labelName,class:`tok-labelName`},{tag:q.inserted,class:`tok-inserted`},{tag:q.deleted,class:`tok-deleted`},{tag:q.literal,class:`tok-literal`},{tag:q.string,class:`tok-string`},{tag:q.number,class:`tok-number`},{tag:[q.regexp,q.escape,q.special(q.string)],class:`tok-string2`},{tag:q.variableName,class:`tok-variableName`},{tag:q.local(q.variableName),class:`tok-variableName tok-local`},{tag:q.definition(q.variableName),class:`tok-variableName tok-definition`},{tag:q.special(q.variableName),class:`tok-variableName2`},{tag:q.definition(q.propertyName),class:`tok-propertyName tok-definition`},{tag:q.typeName,class:`tok-typeName`},{tag:q.namespace,class:`tok-namespace`},{tag:q.className,class:`tok-className`},{tag:q.macroName,class:`tok-macroName`},{tag:q.propertyName,class:`tok-propertyName`},{tag:q.operator,class:`tok-operator`},{tag:q.comment,class:`tok-comment`},{tag:q.meta,class:`tok-meta`},{tag:q.invalid,class:`tok-invalid`},{tag:q.punctuation,class:`tok-punctuation`}]);var BI=vI({String:q.string,Number:q.number,"True False":q.bool,PropertyName:q.propertyName,Null:q.null,", :":q.separator,"[ ]":q.squareBracket,"{ }":q.brace}),VI=cI.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:`#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O`,goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:`⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array`,maxTerm:25,nodeProps:[[`isolate`,-2,6,11,``],[`openedBy`,7,`{`,14,`[`],[`closedBy`,8,`}`,15,`]`]],propSources:[BI],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),HI=[],UI=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?UI:HI).push(n+=e[t])})();function WI(e){if(e<768)return!1;for(let t=0,n=HI.length;;){let r=t+n>>1;if(e<HI[r])n=r;else if(e>=UI[r])t=r+1;else return!0;if(t==n)return!1}}function GI(e){return e>=127462&&e<=127487}var KI=8205;function qI(e,t,n=!0,r=!0){return(n?JI:YI)(e,t,r)}function JI(e,t,n){if(t==e.length)return t;t&&ZI(e.charCodeAt(t))&&QI(e.charCodeAt(t-1))&&t--;let r=XI(e,t);for(t+=$I(r);t<e.length;){let i=XI(e,t);if(r==KI||i==KI||n&&WI(i))t+=$I(i),r=i;else if(GI(i)){let n=0,r=t-2;for(;r>=0&&GI(XI(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function YI(e,t,n){for(;t>1;){let r=JI(e,t-2,n);if(r<t)return r;t--}return 0}function XI(e,t){let n=e.charCodeAt(t);if(!QI(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ZI(r)?(n-55296<<10)+(r-56320)+65536:n}function ZI(e){return e>=56320&&e<57344}function QI(e){return e>=55296&&e<56320}function $I(e){return e<65536?1:2}var eL=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=uL(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),nL.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=uL(this,e,t);let n=[];return this.decompose(e,t,n,0),nL.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new oL(this),i=new oL(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new oL(this,e)}iterRange(e,t=this.length){return new sL(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new cL(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new tL(t):nL.from(tL.split(t,[]))}},tL=class e extends eL{constructor(e,t=rL(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new lL(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(aL(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=iL(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=uL(this,t,n);let i=iL(this.text,iL(r.text,aL(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):nL.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
14
|
+
`,1);return(0,P.jsxs)(G,{"data-testid":`region-chip`,position:`absolute`,style:{left:`${String(e)}px`,top:`${String(t)}px`},zIndex:`docked`,gap:2,px:2,py:1,bg:`bg.panel`,borderWidth:`1px`,borderColor:dN,borderRadius:`md`,shadow:`md`,maxW:`420px`,draggable:n!==void 0,onDragStart:o,onMouseDown:e=>{e.stopPropagation()},onMouseUp:e=>{e.stopPropagation()},cursor:n===void 0?`default`:`grab`,title:n===void 0?void 0:`Drag onto the Steps tab to add it there`,children:[(0,P.jsx)(H,{fontSize:`xs`,fontFamily:`mono`,truncate:!0,flex:`1`,color:s?`fg.muted`:`fg`,children:r&&n===void 0?`reading…`:s?`nothing to read here`:c}),(0,P.jsx)(Rw,{size:`2xs`,colorPalette:`blue`,onClick:i,disabled:n===void 0,children:`Add to recipe`}),(0,P.jsx)(Xw,{size:`2xs`,"aria-label":`Clear selection`,onClick:a})]})}var pN=/^\s*(page|slide)=(\*|\d+)\s+x=(-?\d+(?:\.\d+)?)\.\.(-?\d+(?:\.\d+)?)\s+y=(-?\d+(?:\.\d+)?)\.\.(-?\d+(?:\.\d+)?)\s*$/,mN=/^\$\.sheets\[\?\(@\.name==(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\)\]\.rows\[(\d+)(?::(\d+))?\]\[(\d+)(?::(\d+))?\]$/,hN=/^\$\.slides\[(\d+)\]\.charts\[(\d+)\]\.series$/;function gN(e){let t=[];for(let n of AO(e)){let{id:e,kind:r,selector:i}=n.step;typeof e==`string`&&typeof r==`string`&&typeof i==`string`&&n.step.type===`extract`&&t.push({id:e,kind:r,selector:i})}return t}function _N(e,t){let n=new Set([e.jsonpath,e.xpath,e.listPath].filter(e=>e!==void 0));return t.filter(e=>n.has(e.selector)&&(e.kind===`jsonpath`||e.kind===`xpath`)).map(e=>e.id)}function vN(e){let t=pN.exec(e);if(t===null)return;let[,n,r,i,a,o,s]=t;return{on:n,at:r===`*`?`*`:Number(r),box:{x1:Number(i),y1:Number(o),x2:Number(a),y2:Number(s)}}}function yN(e,t,n){let r=[];for(let i of e){if(i.kind!==`region`)continue;let e=vN(i.selector);e===void 0||e.on!==t||e.at!==`*`&&e.at!==n||r.push({id:i.id,box:e.box})}return r}function bN(e,t){let[n,r]=EN(e.x1,e.x2),[i,a]=EN(e.y1,e.y2),[o,s]=EN(t.x1,t.x2),[c,l]=EN(t.y1,t.y2),u=(r-n)*(a-i);return u===0?n>=o&&n<=s&&i>=c&&i<=l:Math.max(0,Math.min(r,s)-Math.max(n,o))*Math.max(0,Math.min(a,l)-Math.max(i,c))>=u/2}function xN(e,t){return t.filter(t=>bN(e,t.box)).map(e=>e.id)}function SN(e){let t=mN.exec(e);if(t===null)return;let[,n,r,i,a,o,s]=t;return{sheet:n??(r??``).replace(/\\(.)/g,`$1`),range:{top:Number(i),left:Number(o),bottom:a===void 0?Number(i):Number(a)-1,right:s===void 0?Number(o):Number(s)-1}}}function CN(e,t){let n=[];for(let r of e){if(r.kind!==`jsonpath`)continue;let e=SN(r.selector);e!==void 0&&e.sheet===t&&n.push({id:r.id,range:e.range})}return n}function wN(e,t,n){return n.filter(({range:n})=>e>=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right).map(e=>e.id)}function TN(e,t,n){for(let r of e){if(r.kind!==`jsonpath`)continue;let e=hN.exec(r.selector);if(e!==null&&Number(e[1])===t&&Number(e[2])===n)return r.id}}function EN(e,t){return e<=t?[e,t]:[t,e]}var DN=[],ON=5,kN=24,AN=4,jN=`#1d4ed8`,MN=`#ea580c`;function NN({recipeId:e,stepPath:t,view:n,onTablePick:r,onChartPick:i,onRegionPick:a,steps:o=DN,hoveredStepId:s,onHoverStepId:c}){let[l,u]=(0,N.useState)(0),[d,f]=(0,N.useState)(`table`),[p,m]=(0,N.useState)(0),[h,g]=(0,N.useState)(`text`),[_,v]=(0,N.useState)({}),[y,b]=(0,N.useState)(void 0),[x,S]=(0,N.useState)(void 0),[C,w]=(0,N.useState)(void 0),T=(0,N.useRef)(void 0),E=n.slides[l],D=(0,N.useMemo)(()=>yN(o,`slide`,E?.number??-1),[o,E?.number]),O=(0,N.useMemo)(()=>(E?.charts??[]).map((e,t)=>TN(o,l,t)),[o,E?.charts,l]),k=d===`table`?E?.tables[p]:void 0,ee=_.headerRowIndex===void 0?void 0:Array.from({length:_.headerRows??1},(e,t)=>_.headerRowIndex+t),te=bk(e,t,_.header===void 0?void 0:{slide:_.slide,shapes:_.shapes,header:_.header,until:_.until,columns:_.columns,headerRows:_.headerRows,fillDown:_.fillDown,includeHidden:_.includeHidden}),ne=(0,N.useMemo)(()=>te.data?.matches.find(e=>e.slide===E?.number),[te.data,E?.number]),re=x===void 0?void 0:RM(`slide`,x.slide,x.box),ie=gk(e,t,re),ae=ie.data?.matches.find(e=>e.page===x?.slide),oe=ae?.text;if((0,N.useEffect)(()=>{_.header!==void 0&&r(cN(_,t))},[_]),(0,N.useEffect)(()=>{m(0),v({}),f(E!==void 0&&E.tables.length===0&&E.shapes.length>0?`shapes`:`table`)},[l]),E===void 0)return(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`This deck has no slides.`})});function se(e){e!==d&&(f(e),v({}))}function ce(e){if(k===void 0)return;let t=qM(k.rows[e]);if(t!==``){if(h===`header`){v(n=>n.headerRowIndex!==void 0&&e===n.headerRowIndex+(n.headerRows??1)?{...n,headerRows:(n.headerRows??1)+1}:{slide:sN(E.title??``),includeHidden:n.includeHidden,header:FM(t),headerRowIndex:e,headerRows:1});return}h===`until`&&_.header!==void 0&&v(e=>({...e,until:FM(t)}))}}function le(e,t){if(k===void 0||ee===void 0)return;let n=JM(k);if(h===`column`){let e=YM(n,ee,t);if(e===``)return;v(t=>({...t,columns:{...t.columns,[IM(e)]:FM(e)}}));return}if(h===`fillDown`&&PN(k,e,t)){let e=YM(n,ee,t);if(e===``)return;let r=XM(_,e);v(e=>{let t=e.fillDown??[];return t.includes(r)?e:{...e,fillDown:[...t,r]}})}}function A(e){let t=E.shapeRows.findIndex(t=>t.includes(e));if(t===-1)return;let n=E.shapeRows[t];if(h===`header`){let e=E.shapes[n[0]]?.text??``;if(e.trim()===``)return;v({slide:sN(E.title??``),shapes:!0,header:FM(e),headerRowIndex:t,headerRows:1});return}if(h===`until`){if(_.header===void 0)return;let e=E.shapes[n[0]]?.text??``;if(e.trim()===``)return;v(t=>({...t,until:FM(e)}));return}if(h===`column`){if(_.headerRowIndex!==t)return;let n=E.shapes[e]?.text??``;if(n.trim()===``)return;v(e=>({...e,columns:{...e.columns,[IM(n)]:FM(n)}}))}}function ue(e){f(`table`),m(e),v({})}function de(e){i(lN(l,e,t))}function fe(e,t){let n=x;S(t&&n!==void 0&&n.slide===E.number?{slide:E.number,box:BM(n.box,e)}:{slide:E.number,box:e})}function pe(e){c!==void 0&&T.current!==e&&(T.current=e,c(e))}function me(e){let t=FN(e);if(C!==void 0){w({...C,currentX:t.x,currentY:t.y});return}let n=zN(E,t);b(n),pe(n===void 0?void 0:xN(uN(n),D)[0])}function he(e){if(e.button!==0)return;let t=FN(e);w({startX:t.x,startY:t.y,currentX:t.x,currentY:t.y})}function ge(e){if(C===void 0)return;let t=FN(e);if(w(void 0),Math.abs(t.x-C.startX)+Math.abs(t.y-C.startY)>AN){fe({x1:C.startX,y1:C.startY,x2:t.x,y2:t.y},e.shiftKey);return}let n=zN(E,t);if(n===void 0){e.shiftKey||S(void 0);return}fe(uN(n),e.shiftKey)}function _e(){if(re!==void 0&&oe!==void 0)return HM(re,t,VM(oe))}function ve(){let e=_e();e!==void 0&&(a(e),S(void 0))}function ye(e){let t=_e();t!==void 0&&oe!==void 0&&(e.dataTransfer.setData(xA,SA(t)),e.dataTransfer.setData(`text/plain`,oe),e.dataTransfer.effectAllowed=`copy`)}let j=h===`text`,M=x!==void 0&&x.slide===E.number?x:void 0;return(0,P.jsxs)(F,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,P.jsxs)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,flexWrap:`wrap`,children:[n.slides.length>1&&(0,P.jsx)(VN,{slides:n.slides,value:l,onChange:u}),(0,P.jsx)(BN,{label:`Text`,active:j,onClick:()=>{g(`text`)}}),!j&&(0,P.jsx)(BN,{label:`Native table`,active:d===`table`,onClick:()=>{se(`table`)}}),!j&&(0,P.jsx)(BN,{label:`Text-box grid`,active:d===`shapes`,onClick:()=>{se(`shapes`)}}),(0,P.jsx)(BN,{label:`Header row(s)`,active:h===`header`,onClick:()=>{g(`header`)}}),(0,P.jsx)(BN,{label:`Last row (until)`,active:h===`until`,onClick:()=>{g(`until`)}}),(0,P.jsx)(BN,{label:`Column`,active:h===`column`,onClick:()=>{g(`column`)}}),!j&&d===`table`&&(0,P.jsx)(BN,{label:`Fill down`,active:h===`fillDown`,onClick:()=>{g(`fillDown`)}}),j&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,visibility:x===void 0?`visible`:`hidden`,children:`Click a text box (shift+click to extend) or drag a box, then add it to the recipe or drag it onto the Steps tab.`}),_.header!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`green`,children:`table: ${_.header}${_.until===void 0?``:` until ${_.until}`}`}),te.data?.error!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`orange`,children:te.data.error}),ie.data?.error!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`orange`,children:ie.data.error})]}),(0,P.jsxs)(F,{flex:`1`,minH:`0`,display:`flex`,overflow:`hidden`,children:[(0,P.jsxs)(F,{flex:`2`,minW:`0`,overflow:`auto`,p:3,children:[j&&(0,P.jsxs)(F,{position:`relative`,width:`${String(n.width)}px`,height:`${String(n.height)}px`,children:[(0,P.jsx)(HN,{slide:E,width:n.width,height:n.height}),(0,P.jsxs)(`svg`,{"data-testid":`deck-overlay`,width:n.width,height:n.height,style:{position:`absolute`,top:0,left:0,cursor:`crosshair`},onMouseMove:me,onMouseDown:he,onMouseUp:ge,onMouseLeave:()=>{b(void 0),pe(void 0)},children:[D.map(e=>(0,P.jsx)(`rect`,{"data-testid":`recipe-region`,"data-step-id":e.id,"data-highlighted":e.id===s,...RN(e.box),fill:e.id===s?`rgba(234, 88, 12, 0.22)`:`rgba(234, 88, 12, 0.05)`,stroke:MN,strokeWidth:e.id===s?2:1,strokeDasharray:e.id===s?void 0:`4 3`,pointerEvents:`none`,children:(0,P.jsx)(`title`,{children:`In the recipe: ${e.id}`})},`recipe:${e.id}`)),y!==void 0&&C===void 0&&(0,P.jsx)(`rect`,{"data-testid":`snap-target`,...LN(y),fill:`rgba(29, 78, 216, 0.08)`,stroke:jN,strokeWidth:1.5,strokeDasharray:`3 2`,pointerEvents:`none`}),M!==void 0&&(0,P.jsx)(`rect`,{"data-testid":`staged-region`,...RN(M.box),fill:`rgba(155, 93, 229, 0.12)`,stroke:`#9b5de5`,strokeWidth:1.5,pointerEvents:`none`}),M!==void 0&&ae?.shapes.map(e=>(0,P.jsx)(`rect`,{"data-testid":`staged-shape`,...LN(e),fill:`rgba(155, 93, 229, 0.28)`,pointerEvents:`none`},IN(e))),C!==void 0&&(0,P.jsx)(`rect`,{...RN({x1:C.startX,y1:C.startY,x2:C.currentX,y2:C.currentY}),fill:`rgba(155, 93, 229, 0.2)`,stroke:`#9b5de5`,strokeDasharray:`4 2`,pointerEvents:`none`})]}),M!==void 0&&(0,P.jsx)(fN,{left:Math.min(M.box.x1,M.box.x2),top:Math.max(M.box.y1,M.box.y2)+6,text:oe,loading:ie.isPending,onAdd:ve,onClear:()=>{S(void 0)},onDragStart:ye})]}),!j&&d===`shapes`&&(0,P.jsx)(HN,{slide:E,width:n.width,height:n.height,headerRowIndex:_.headerRowIndex,onPick:A}),!j&&d===`table`&&k!==void 0&&(0,P.jsx)(UN,{table:k,headerRowIndexes:ee,mode:h,onRowPick:ce,onCellPick:le}),!j&&d===`table`&&k===void 0&&(0,P.jsx)(H,{color:`fg.muted`,fontSize:`sm`,children:`This slide has no native tables.`}),!j&&ne!==void 0&&(0,P.jsx)(GN,{match:ne})]}),(0,P.jsx)(F,{flex:`1`,minW:`220px`,maxW:`320px`,borderLeftWidth:`1px`,overflow:`auto`,p:3,children:(0,P.jsx)(WN,{slide:E,activeSource:d,activeTableIndex:p,onTablePick:ue,onChartPick:de,chartStepIds:O,hoveredStepId:s,onHoverStepId:pe})})]})]})}function PN(e,t,n){let r=e.merges.find(e=>e.top===t&&e.left===n);return r!==void 0&&r.bottom>r.top&&r.left===r.right}function FN(e){let t=e.currentTarget.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function IN(e){return`staged:${String(e.x)}:${String(e.y)}`}function LN(e){return{x:e.x,y:e.y,width:Math.max(e.width,1),height:Math.max(e.height,1)}}function RN(e){let[t,n]=[Math.min(e.x1,e.x2),Math.max(e.x1,e.x2)],[r,i]=[Math.min(e.y1,e.y2),Math.max(e.y1,e.y2)];return{x:t,y:r,width:n-t,height:i-r}}function zN(e,t){let n;for(let r of e.shapes){let e=LN(r),i=Math.max(e.x-t.x,0,t.x-(e.x+e.width)),a=Math.max(e.y-t.y,0,t.y-(e.y+e.height)),o=Math.hypot(i,a);o<=kN&&(n===void 0||o<n.distance)&&(n={shape:r,distance:o})}return n?.shape}function BN({label:e,active:t,onClick:n}){return(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:t?`semibold`:`normal`,color:t?`colorPalette.fg`:`fg`,colorPalette:`blue`,cursor:`pointer`,onClick:n,children:e})}function VN({slides:e,value:t,onChange:n}){let r=l_({items:e.map((e,t)=>({label:`Slide ${String(e.number)}${e.title===void 0||e.title===``?``:` — ${e.title}`}${e.hidden?` (hidden)`:``}`,value:String(t)}))});return(0,P.jsxs)(VT,{collection:r,size:`sm`,width:`220px`,value:[String(t)],onValueChange:e=>{n(Number(e.value[0]))},children:[(0,P.jsx)(JT,{}),(0,P.jsx)(qT,{children:(0,P.jsx)(HT,{children:(0,P.jsx)(GT,{})})}),(0,P.jsx)(UT,{children:(0,P.jsx)(WT,{children:r.items.map(e=>(0,P.jsx)(KT,{item:e,children:e.label},e.value))})})]})}function HN({slide:e,width:t,height:n,headerRowIndex:r,onPick:i}){let a=r===void 0?void 0:new Set(e.shapeRows[r]);return(0,P.jsx)(F,{position:`relative`,width:`${String(t)}px`,height:`${String(n)}px`,borderWidth:`1px`,bg:`bg.panel`,children:e.shapes.map((e,t)=>(0,P.jsx)(F,{position:`absolute`,style:{left:`${String(e.x)}px`,top:`${String(e.y)}px`,width:`${String(Math.max(e.width,1))}px`,height:`${String(Math.max(e.height,1))}px`},borderWidth:`1px`,borderColor:a?.has(t)===!0?`orange.fg`:`border.muted`,bg:a?.has(t)===!0?`orange.subtle`:`bg`,overflow:`hidden`,px:1,fontSize:`xs`,cursor:i===void 0?`default`:`pointer`,_hover:i===void 0?void 0:{bg:`bg.emphasized`},onClick:i===void 0?void 0:()=>{i(t)},title:e.placeholder,children:e.text},`${String(e.x)}:${String(e.y)}:${String(t)}`))})}function UN({table:e,headerRowIndexes:t,mode:n,onRowPick:r,onCellPick:i}){return(0,P.jsx)(yE,{size:`sm`,variant:`outline`,children:(0,P.jsx)(TE,{children:e.rows.map((e,a)=>(0,P.jsx)(bE,{bg:t?.includes(a)===!0?`yellow.subtle`:void 0,children:e.map((e,t)=>(0,P.jsx)(wE,{fontSize:`xs`,cursor:`pointer`,_hover:{bg:`bg.emphasized`},onClick:()=>{n===`header`||n===`until`?r(a):i(a,t)},children:String(e.value)},t))},a))})})}function WN({slide:e,activeSource:t,activeTableIndex:n,onTablePick:r,onChartPick:i,chartStepIds:a,hoveredStepId:o,onHoverStepId:s}){return(0,P.jsxs)(kE,{align:`stretch`,gap:4,children:[(0,P.jsxs)(F,{children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`semibold`,color:`fg.muted`,mb:1,children:`Native tables (${String(e.tables.length)})`}),e.tables.length===0&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`None on this slide.`}),(0,P.jsx)(kE,{align:`stretch`,gap:1,children:e.tables.map((e,i)=>(0,P.jsxs)(F,{as:`button`,textAlign:`left`,p:2,borderWidth:`1px`,borderRadius:`sm`,bg:t===`table`&&n===i?`bg.emphasized`:void 0,onClick:()=>{r(i)},children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`medium`,children:e.name}),(0,P.jsx)(H,{fontSize:`2xs`,color:`fg.muted`,children:`${String(e.rows.length)} rows`})]},e.name))})]}),(0,P.jsxs)(F,{children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`semibold`,color:`fg.muted`,mb:1,children:`Charts (${String(e.charts.length)})`}),e.charts.length===0&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`None on this slide.`}),(0,P.jsx)(kE,{align:`stretch`,gap:1,children:e.charts.map((e,t)=>(0,P.jsxs)(F,{as:`button`,"data-testid":`deck-chart`,"data-step-ids":a[t],"data-highlighted":a[t]!==void 0&&a[t]===o,textAlign:`left`,p:2,borderWidth:`1px`,borderRadius:`sm`,borderColor:a[t]===void 0?void 0:`orange.solid`,borderStyle:a[t]===void 0||a[t]===o?`solid`:`dashed`,bg:a[t]!==void 0&&a[t]===o?`orange.subtle`:void 0,onClick:()=>{i(t)},onMouseEnter:()=>{s(a[t])},onMouseLeave:()=>{s(void 0)},children:[(0,P.jsxs)(G,{gap:1,children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`medium`,children:e.title??e.type}),a[t]!==void 0&&(0,P.jsx)(Aw,{size:`xs`,colorPalette:`orange`,title:`Already in the recipe: the step reading this`,children:a[t]})]}),(0,P.jsx)(H,{fontSize:`2xs`,color:`fg.muted`,children:`${e.type} · ${String(e.series.length)} series`})]},t))})]}),(0,P.jsxs)(F,{children:[(0,P.jsx)(H,{fontSize:`xs`,fontWeight:`semibold`,color:`fg.muted`,mb:1,children:`Notes`}),(0,P.jsx)(H,{fontSize:`xs`,color:e.notes===``?`fg.muted`:`fg`,whiteSpace:`pre-wrap`,children:e.notes===``?`None.`:e.notes})]})]})}function GN({match:e}){let t=e.rows.slice(0,ON);return(0,P.jsxs)(F,{borderTopWidth:`1px`,mt:3,maxH:`160px`,overflow:`auto`,children:[(0,P.jsx)(G,{px:0,py:1,gap:2,children:(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Live preview: ${String(e.rows.length)} row${e.rows.length===1?``:`s`} matched${e.title===``?``:` ("${e.title}")`}`})}),(0,P.jsxs)(yE,{size:`sm`,variant:`outline`,children:[(0,P.jsx)(SE,{children:(0,P.jsx)(bE,{children:e.header.map(e=>(0,P.jsx)(CE,{fontSize:`2xs`,children:e},e))})}),(0,P.jsx)(TE,{children:t.map((t,n)=>(0,P.jsx)(bE,{children:e.header.map(e=>(0,P.jsx)(wE,{fontSize:`2xs`,children:String(t[e]??``)},e))},n))})]})]})}var KN=[],qN=24,JN=130,YN=30,XN=5;function ZN({recipeId:e,stepPath:t,view:n,onTablePick:r,onCellPick:i,steps:a=KN,hoveredStepId:o,onHoverStepId:s,csvOverride:c,onCsvOverrideChange:l}){let[u,d]=(0,N.useState)(0),[f,p]=(0,N.useState)(`cell`),[m,h]=(0,N.useState)({}),[g,_]=(0,N.useState)(void 0),[v,y]=(0,N.useState)(void 0),[b,x]=(0,N.useState)(void 0),S=(0,N.useRef)(null),C=(0,N.useRef)(void 0),w=n.sheets[u],T=(0,N.useMemo)(()=>CN(a,w?.name??``),[a,w?.name]),E=(0,N.useMemo)(()=>w===void 0?[]:JM(w),[w]),D=(0,N.useMemo)(()=>w===void 0?[]:QN(w),[w]),O=m.headerRowIndex===void 0?void 0:Array.from({length:m.headerRows??1},(e,t)=>m.headerRowIndex+t),k=vk(e,t,m.header===void 0?void 0:{sheet:m.sheet,header:m.header,until:m.until,columns:m.columns,headerRows:m.headerRows,fillDown:m.fillDown,includeHidden:m.includeHidden}),ee=(0,N.useMemo)(()=>k.data?.matches.find(e=>e.sheet===w?.name),[k.data,w?.name]),te=Jk({count:w?.rows.length??0,getScrollElement:()=>S.current,estimateSize:()=>qN,overscan:YN});(0,N.useEffect)(()=>{m.header!==void 0&&r(ZM(m,t))},[m]);let ne=f===`cell`,re=b!==void 0&&w!==void 0&&b.sheet===w.name?b:void 0,ie=re===void 0?void 0:QM(re.sheet,re.range),ae=re===void 0||w===void 0?void 0:tN(w,re.range);if(w===void 0)return(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`This workbook has no sheets.`})});function oe(e){s!==void 0&&C.current!==e&&(C.current=e,s(e))}function se(e,t){let n=re;x(t&&n!==void 0?{sheet:w.name,range:$M(n.range,e)}:{sheet:w.name,range:e})}function ce(e,t){ne&&t.button===0&&(t.stopPropagation(),y(e))}function le(e,t){if(!ne)return;t.stopPropagation();let n=v??e;y(void 0),se({top:Math.min(n.row,e.row),left:Math.min(n.column,e.column),bottom:Math.max(n.row,e.row),right:Math.max(n.column,e.column)},t.shiftKey)}function A(e){ne&&(y(void 0),e.shiftKey||x(void 0))}function ue(){if(re!==void 0&&ie!==void 0&&ae!==void 0)return nN(ie,t,VM(ae),!eN(re.range))}function de(){let e=ue();e!==void 0&&(i(e),x(void 0))}function fe(e){let t=ue();t!==void 0&&ae!==void 0&&(e.dataTransfer.setData(xA,SA(t)),e.dataTransfer.setData(`text/plain`,ae),e.dataTransfer.effectAllowed=`copy`)}function pe(e){if(d(e),f!==`sheet`)return;let t=n.sheets[e].name;h(e=>({...e,sheet:KM(t)}))}function me(e){let t=qM(w.rows[e]);t!==``&&h(n=>n.headerRowIndex!==void 0&&e===n.headerRowIndex+(n.headerRows??1)?{...n,headerRows:(n.headerRows??1)+1}:{sheet:n.sheet,includeHidden:n.includeHidden,header:FM(t),headerRowIndex:e,headerRows:1})}function he(e){if(m.header===void 0)return;let t=qM(w.rows[e]);t!==``&&h(e=>({...e,until:FM(t)}))}function ge(e){if(O===void 0)return;let t=YM(E,O,e);if(t===``)return;let n=IM(t);h(e=>({...e,columns:{...e.columns,[n]:FM(t)}}))}function _e(e){if(O===void 0)return;let t=YM(E,O,e);if(t===``)return;let n=XM(m,t);h(e=>{let t=e.fillDown??[];return t.includes(n)?e:{...e,fillDown:[...t,n]}})}function ve(e,t,n){if(f===`header`){me(e);return}if(f===`until`){he(e);return}if(f===`column`){ge(t);return}f===`fillDown`&&n&&_e(t)}return(0,P.jsxs)(F,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,P.jsx)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:1,flexShrink:0,flexWrap:`wrap`,children:n.sheets.map((e,t)=>(0,P.jsx)(nP,{sheet:e,active:t===u,onClick:()=>{pe(t)}},e.name))}),(0,P.jsxs)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,flexWrap:`wrap`,children:[(0,P.jsx)(tP,{label:`Cell`,active:ne,onClick:()=>{p(`cell`)}}),(0,P.jsx)(tP,{label:`Sheet`,active:f===`sheet`,onClick:()=>{p(`sheet`)}}),(0,P.jsx)(tP,{label:`Header row(s)`,active:f===`header`,onClick:()=>{p(`header`)}}),(0,P.jsx)(tP,{label:`First non-data row (until)`,active:f===`until`,onClick:()=>{p(`until`)}}),(0,P.jsx)(tP,{label:`Column`,active:f===`column`,onClick:()=>{p(`column`)}}),(0,P.jsx)(tP,{label:`Fill down`,active:f===`fillDown`,onClick:()=>{p(`fillDown`)}}),n.csv!==void 0&&(0,P.jsx)(cP,{format:n.csv,override:c,onChange:l}),ne&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,visibility:b===void 0?`visible`:`hidden`,children:`Click a cell (shift+click, or press and release, for a range), then add it to the recipe or drag it onto the Steps tab.`}),m.header!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`green`,children:`table: ${m.header}${m.until===void 0?``:` until ${m.until}`}`}),k.data?.error!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`orange`,children:k.data.error})]}),(0,P.jsxs)(F,{flex:`1`,minH:`0`,display:`flex`,flexDirection:`column`,children:[(0,P.jsx)(F,{ref:S,flex:`1`,minH:`0`,overflow:`auto`,position:`relative`,onMouseUp:A,onMouseLeave:()=>{_(void 0),oe(void 0)},children:(0,P.jsxs)(F,{h:`${String(te.getTotalSize())}px`,position:`relative`,style:{width:`${String(w.columnCount*JN)}px`},children:[te.getVirtualItems().map(e=>D[e.index]?.map(t=>t===void 0?null:(0,P.jsx)(oP,{cell:t,top:e.start,isHeader:O?.includes(e.index)??!1,isHidden:w.hiddenRows.includes(e.index),isSnapped:ne&&g?.row===e.index&&g.column===t.columnIndex,isStaged:re!==void 0&&eP(re.range,e.index,t.columnIndex),stepIds:wN(e.index,t.columnIndex,T),hoveredStepId:o,onClick:ne?void 0:()=>{ve(e.index,t.columnIndex,t.isMergeLabel)},onMouseEnter:n=>{ne&&_({row:e.index,column:t.columnIndex}),oe(n[0])},onMouseDown:ne?n=>{ce({row:e.index,column:t.columnIndex},n)}:void 0,onMouseUp:ne?n=>{le({row:e.index,column:t.columnIndex},n)}:void 0},`${String(e.index)}:${String(t.columnIndex)}`))),re!==void 0&&(0,P.jsx)(fN,{left:re.range.left*JN,top:(re.range.bottom+1)*qN+4,text:ae,loading:!1,onAdd:de,onClear:()=>{x(void 0)},onDragStart:fe})]})}),ee!==void 0&&(0,P.jsx)(sP,{match:ee})]})]})}function QN(e){let t=$N(e.merges),n=new Map(e.merges.map(e=>[`${String(e.top)}:${String(e.left)}`,{rowSpan:e.bottom-e.top+1,colSpan:e.right-e.left+1}]));return e.rows.map((e,r)=>e.map((e,i)=>{let a=`${String(r)}:${String(i)}`;if(t.has(a))return;let o=n.get(a);return{columnIndex:i,rowSpan:o?.rowSpan??1,colSpan:o?.colSpan??1,value:e.value,type:e.type,isMergeLabel:o!==void 0&&o.rowSpan>1&&o.colSpan===1}}))}function $N(e){let t=new Set;for(let n of e)for(let e=n.top;e<=n.bottom;e+=1)for(let r=n.left;r<=n.right;r+=1)(e!==n.top||r!==n.left)&&t.add(`${String(e)}:${String(r)}`);return t}function eP(e,t,n){return t>=e.top&&t<=e.bottom&&n>=e.left&&n<=e.right}function tP({label:e,active:t,onClick:n}){return(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:t?`semibold`:`normal`,color:t?`colorPalette.fg`:`fg`,colorPalette:`blue`,cursor:`pointer`,onClick:n,children:e})}function nP({sheet:e,active:t,onClick:n}){return(0,P.jsxs)(G,{as:`button`,gap:1,px:2,py:1,borderRadius:`sm`,bg:t?`bg.emphasized`:void 0,opacity:e.hidden?.55:1,onClick:n,children:[(0,P.jsx)(H,{fontSize:`sm`,fontWeight:t?`semibold`:`normal`,children:e.name}),e.hidden&&(0,P.jsx)(Aw,{size:`xs`,colorPalette:`gray`,children:`hidden`})]})}var rP={string:`fg`,number:`orange.fg`,boolean:`blue.fg`,date:`purple.fg`};function iP(e,t,n){return e?`purple.fg`:t?`blue.fg`:n?`orange.solid`:`border.muted`}function aP(e,t,n,r){return n?`purple.muted`:r?`orange.subtle`:t?`yellow.subtle`:e.isMergeLabel?`purple.subtle`:`bg`}function oP({cell:e,top:t,isHeader:n,isHidden:r,isSnapped:i,isStaged:a,stepIds:o,hoveredStepId:s,onClick:c,onMouseEnter:l,onMouseDown:u,onMouseUp:d}){let f=o.length>0,p=s!==void 0&&o.includes(s);return(0,P.jsx)(F,{"data-testid":i?`snap-target`:a?`staged-cell`:`grid-cell`,"data-step-ids":f?o.join(` `):void 0,"data-highlighted":p,position:`absolute`,style:{top:`${String(t)}px`,left:`${String(e.columnIndex*JN)}px`,width:`${String(e.colSpan*JN)}px`,height:`${String(e.rowSpan*qN)}px`},borderWidth:f?`2px`:`1px`,borderStyle:f&&!p?`dashed`:`solid`,borderColor:iP(a,i,f),bg:aP(e,n,a,p),opacity:r?.4:1,overflow:`hidden`,px:1,fontSize:`xs`,color:rP[e.type],cursor:c===void 0?`cell`:`pointer`,_hover:{bg:a?`purple.muted`:`bg.emphasized`},onClick:c,onMouseEnter:l===void 0?void 0:()=>{l(o)},onMouseDown:u,onMouseUp:d,title:f?`In the recipe: ${o.join(`, `)}`:r?`Hidden row`:void 0,truncate:!0,children:String(e.value)})}function sP({match:e}){let t=e.rows.slice(0,XN);return(0,P.jsxs)(F,{borderTopWidth:`1px`,maxH:`160px`,overflow:`auto`,flexShrink:0,children:[(0,P.jsx)(G,{px:2,py:1,gap:2,children:(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Live preview: ${String(e.rows.length)} row${e.rows.length===1?``:`s`} matched${e.title===``?``:` ("${e.title}")`}`})}),(0,P.jsxs)(yE,{size:`sm`,variant:`outline`,children:[(0,P.jsx)(SE,{children:(0,P.jsx)(bE,{children:e.header.map(e=>(0,P.jsx)(CE,{fontSize:`2xs`,children:e},e))})}),(0,P.jsx)(TE,{children:t.map((t,n)=>(0,P.jsx)(bE,{children:e.header.map(e=>(0,P.jsx)(wE,{fontSize:`2xs`,children:String(t[e]??``)},e))},n))})]})]})}function cP({format:e,override:t,onChange:n}){let r=t?.delimiter??e.delimiter,i=t?.encoding??e.encoding;return(0,P.jsxs)(G,{gap:2,children:[(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Delimiter`}),(0,P.jsx)(DT,{size:`xs`,width:`40px`,defaultValue:r,onBlur:e=>{let i=e.target.value;i!==``&&i!==r&&n({delimiter:i,encoding:t?.encoding})}},r),(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`Encoding`}),(0,P.jsx)(DT,{size:`xs`,width:`110px`,defaultValue:i,onBlur:e=>{let r=e.target.value;r!==``&&r!==i&&n({delimiter:t?.delimiter,encoding:r})}},i)]})}var lP=`modulepreload`,uP=function(e){return`/`+e},dP={},fP=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=uP(t,n),t=s(t),t in dP)return;dP[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`:lP,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}`)))})}).filter(e=>e!==void 0))}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)})},pP=[],mP=1.5,hP=1.2,gP=24,_P=4,vP=[`#2e86ab`,`#3bb273`],yP=`#e4572e`,bP=`rgba(59, 178, 115, 0.18)`,xP=`#1d4ed8`,SP=`#ea580c`;function CP({recipeId:e,stepPath:t,view:n,bytesUrl:r,onTablePick:i,onRegionPick:a,steps:o=pP,hoveredStepId:s,onHoverStepId:c}){let[l,u]=(0,N.useState)(0),[d,f]=(0,N.useState)(`text`),[p,m]=(0,N.useState)({}),[h,g]=(0,N.useState)(void 0),[_,v]=(0,N.useState)(void 0),[y,b]=(0,N.useState)(void 0),x=(0,N.useRef)(null),S=(0,N.useRef)(void 0),C=n.pages[l],w=(0,N.useMemo)(()=>yN(o,`page`,C?.number??-1),[o,C?.number]),T=C===void 0?0:Math.ceil(C.width*mP),E=C===void 0?0:Math.ceil(C.height*mP),D=hk(e,t,p.header===void 0?void 0:{header:p.header,until:p.until,columns:p.columns}),O=(0,N.useMemo)(()=>D.data?.matches.find(e=>e.page===C?.number),[D.data,C?.number]),k=_===void 0?void 0:RM(`page`,_.page,_.box),ee=gk(e,t,k),te=ee.data?.matches.find(e=>e.page===_?.page),ne=te?.text;if((0,N.useEffect)(()=>{p.header!==void 0&&i(LM(p,t))},[p]),(0,N.useEffect)(()=>{let e=x.current;if(e===null||C===void 0)return;let t=new AbortController;return PP(e,r,C.number,mP,t.signal).catch(e=>{t.signal.aborted||console.error(`PDF canvas: could not render the page`,e)}),()=>{t.abort()}},[r,C?.number]),C===void 0)return(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`This PDF has no pages.`})});function re(e){let t=e.cells[0]?.text??``;if(d===`header`){m({header:FM(t)});return}d===`until`&&p.header!==void 0&&m(e=>({...e,until:FM(t)}))}function ie(e){p.header!==void 0&&m(t=>({...t,columns:{...t.columns,[IM(e)]:FM(e)}}))}function ae(e,t){let n=_;v(t&&n!==void 0&&n.page===C.number?{page:C.number,box:BM(n.box,e)}:{page:C.number,box:e})}function oe(e){c!==void 0&&S.current!==e&&(S.current=e,c(e))}function se(e){if(d!==`text`)return;let t=wP(e);if(y!==void 0){b({...y,currentX:t.x,currentY:t.y});return}let n=kP(C,t);g(n),oe(n===void 0?void 0:xN(zM(n),w)[0])}function ce(e){if(d!==`text`||e.button!==0)return;let t=wP(e);b({startX:t.x,startY:t.y,currentX:t.x,currentY:t.y})}function le(e){if(d!==`text`||y===void 0)return;let t=wP(e);if(b(void 0),Math.abs(t.x-y.startX)+Math.abs(t.y-y.startY)>_P){ae(OP(C,y.startX,y.startY,t.x,t.y),e.shiftKey);return}let n=kP(C,t);if(n===void 0){e.shiftKey||v(void 0);return}ae(zM(n),e.shiftKey)}function A(){if(k!==void 0&&ne!==void 0)return HM(k,t,VM(ne))}function ue(){let e=A();e!==void 0&&(a(e),v(void 0))}function de(e){let t=A();t!==void 0&&ne!==void 0&&(e.dataTransfer.setData(xA,SA(t)),e.dataTransfer.setData(`text/plain`,ne),e.dataTransfer.effectAllowed=`copy`)}let fe=d===`text`,pe=_!==void 0&&_.page===C.number?_:void 0;return(0,P.jsxs)(F,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,P.jsxs)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,flexWrap:`wrap`,children:[n.pages.length>1&&(0,P.jsx)(jP,{pages:n.pages.length,value:l,onChange:u}),(0,P.jsx)(AP,{label:`Text`,active:fe,onClick:()=>{f(`text`)}}),(0,P.jsx)(AP,{label:`Header row`,active:d===`header`,onClick:()=>{f(`header`)}}),(0,P.jsx)(AP,{label:`Last row (until)`,active:d===`until`,onClick:()=>{f(`until`)}}),(0,P.jsx)(AP,{label:`Column`,active:d===`column`,onClick:()=>{f(`column`)}}),(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,children:`${String(C.rowCount)} rows, ${String(C.cellCount)} cells${C.hasTextLayer?``:` — no text layer (a scan?)`}`}),fe&&(0,P.jsx)(H,{fontSize:`xs`,color:`fg.muted`,visibility:_===void 0?`visible`:`hidden`,children:`Click a line (shift+click to extend) or drag a box, then add it to the recipe or drag it onto the Steps tab.`}),p.header!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`green`,children:`table: ${p.header}${p.until===void 0?``:` until ${p.until}`}`}),D.data?.error!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`orange`,children:D.data.error}),ee.data?.error!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:`orange`,children:ee.data.error})]}),(0,P.jsx)(F,{flex:`1`,minH:`0`,overflow:`auto`,position:`relative`,children:(0,P.jsxs)(F,{position:`relative`,width:`${String(T)}px`,height:`${String(E)}px`,children:[(0,P.jsx)(`canvas`,{ref:x,width:T,height:E,style:{position:`absolute`,top:0,left:0}}),(0,P.jsxs)(`svg`,{"data-testid":`pdf-overlay`,width:T,height:E,style:{position:`absolute`,top:0,left:0,cursor:fe?`crosshair`:`pointer`},onMouseMove:se,onMouseDown:ce,onMouseUp:le,onMouseLeave:()=>{g(void 0),oe(void 0)},children:[w.map(e=>(0,P.jsx)(`rect`,{"data-testid":`recipe-region`,"data-step-id":e.id,"data-highlighted":e.id===s,...DP(e.box,C.height),fill:e.id===s?`rgba(234, 88, 12, 0.22)`:`rgba(234, 88, 12, 0.05)`,stroke:SP,strokeWidth:e.id===s?2:1,strokeDasharray:e.id===s?void 0:`4 3`,pointerEvents:`none`,children:(0,P.jsx)(`title`,{children:`In the recipe: ${e.id}`})},`recipe:${e.id}`)),C.rows.map((e,t)=>(0,P.jsx)(MP,{row:e,colour:e.cells[0]?.text!==void 0&&O?.headerRowIndex===t?yP:vP[t%2],highlighted:O?.matchedRowIndices.includes(t)??!1,scale:mP,pageHeight:C.height,cursor:fe?`crosshair`:`pointer`,onClick:fe?void 0:()=>{re(e)}},`${String(e.top)}:${String(e.bottom)}`)),d===`column`&&O!==void 0&&O.bands.map(e=>(0,P.jsx)(NP,{band:e,scale:mP,pageHeight:C.height,onClick:()=>{ie(e.name)}},e.column)),fe&&h!==void 0&&y===void 0&&(0,P.jsx)(`rect`,{"data-testid":`snap-target`,...EP(h,C.height),fill:`rgba(29, 78, 216, 0.08)`,stroke:xP,strokeWidth:1.5,strokeDasharray:`3 2`,pointerEvents:`none`}),pe!==void 0&&(0,P.jsx)(`rect`,{"data-testid":`staged-region`,...DP(pe.box,C.height),fill:`rgba(155, 93, 229, 0.12)`,stroke:`#9b5de5`,strokeWidth:1.5,pointerEvents:`none`}),pe!==void 0&&te?.cells.map(e=>(0,P.jsx)(`rect`,{"data-testid":`staged-cell`,...EP(e,C.height),fill:`rgba(155, 93, 229, 0.28)`,pointerEvents:`none`},TP(e))),y!==void 0&&(0,P.jsx)(`rect`,{x:Math.min(y.startX,y.currentX),y:Math.min(y.startY,y.currentY),width:Math.abs(y.currentX-y.startX),height:Math.abs(y.currentY-y.startY),fill:`rgba(155, 93, 229, 0.2)`,stroke:`#9b5de5`,strokeDasharray:`4 2`,pointerEvents:`none`})]}),pe!==void 0&&(0,P.jsx)(fN,{left:Math.min(pe.box.x1,pe.box.x2)*mP,top:(C.height-Math.min(pe.box.y1,pe.box.y2))*mP+6,text:ne,loading:ee.isPending,onAdd:ue,onClear:()=>{v(void 0)},onDragStart:de})]})})]})}function wP(e){let t=e.currentTarget.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function TP(e){return`staged:${String(e.x)}:${String(e.y)}`}function EP(e,t){return{x:e.x*mP,y:(t-e.y-e.height)*mP,width:Math.max(e.width,1)*mP,height:e.height*mP*hP}}function DP(e,t){let[n,r]=[Math.min(e.x1,e.x2),Math.max(e.x1,e.x2)],[i,a]=[Math.min(e.y1,e.y2),Math.max(e.y1,e.y2)];return{x:n*mP,y:(t-a)*mP,width:(r-n)*mP,height:(a-i)*mP}}function OP(e,t,n,r,i){return{x1:t/mP,y1:e.height-n/mP,x2:r/mP,y2:e.height-i/mP}}function kP(e,t){let n;for(let r of e.rows)for(let i of r.cells){let r=EP(i,e.height),a=Math.max(r.x-t.x,0,t.x-(r.x+r.width)),o=Math.max(r.y-t.y,0,t.y-(r.y+r.height)),s=Math.hypot(a,o);s<=gP&&(n===void 0||s<n.distance)&&(n={cell:i,distance:s})}return n?.cell}function AP({label:e,active:t,onClick:n}){return(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:t?`semibold`:`normal`,color:t?`colorPalette.fg`:`fg`,colorPalette:`blue`,cursor:`pointer`,onClick:n,children:e})}function jP({pages:e,value:t,onChange:n}){let r=l_({items:Array.from({length:e},(e,t)=>({label:`Page ${String(t+1)}`,value:String(t)}))});return(0,P.jsxs)(VT,{collection:r,size:`sm`,width:`140px`,value:[String(t)],onValueChange:e=>{n(Number(e.value[0]))},children:[(0,P.jsx)(JT,{}),(0,P.jsx)(qT,{children:(0,P.jsx)(HT,{children:(0,P.jsx)(GT,{})})}),(0,P.jsx)(UT,{children:(0,P.jsx)(WT,{children:r.items.map(e=>(0,P.jsx)(KT,{item:e,children:e.label},e.value))})})]})}function MP({row:e,colour:t,highlighted:n,scale:r,pageHeight:i,cursor:a,onClick:o}){return(0,P.jsxs)(`g`,{onClick:o,style:{cursor:a},children:[n&&e.cells.length>0&&(0,P.jsx)(`rect`,{x:Math.min(...e.cells.map(e=>e.x))*r,y:(i-e.top)*r,width:(Math.max(...e.cells.map(e=>e.x+e.width))-Math.min(...e.cells.map(e=>e.x)))*r,height:(e.top-e.bottom)*r,fill:bP}),e.cells.map(e=>(0,P.jsx)(`rect`,{x:e.x*r,y:(i-e.y-e.height)*r,width:Math.max(e.width,1)*r,height:e.height*r*hP,fill:`transparent`,stroke:t,strokeWidth:1.5},`${String(e.x)}:${String(e.y)}`))]})}function NP({band:e,scale:t,pageHeight:n,onClick:r}){return(0,P.jsx)(`rect`,{x:e.start*t,y:0,width:Math.max(e.end-e.start,1)*t,height:n*t,fill:`rgba(46, 134, 171, 0.08)`,stroke:`#2e86ab`,strokeDasharray:`4 2`,onClick:r,style:{cursor:`pointer`},children:(0,P.jsx)(`title`,{children:e.name})})}async function PP(e,t,n,r,i){let a=await fP(()=>import(`./pdf-fTUtwf59.js`),[]),o=await fP(()=>import(`./pdf.worker.min-D7i8o3wR.js`),[]);a.GlobalWorkerOptions.workerSrc=o.default;let s=a.getDocument({url:t}),c=await s.promise;try{let t=await c.getPage(n);if(i.aborted)return;let a=t.getViewport({scale:r});e.width=Math.ceil(a.width),e.height=Math.ceil(a.height);let o=e.getContext(`2d`);if(o===null)return;let s=t.render({canvas:e,canvasContext:o,viewport:a});i.addEventListener(`abort`,()=>{s.cancel()}),await s.promise}finally{await s.destroy()}}function FP(e,t){return{kind:`card`,path:t,stepType:`goto`,sentence:[{kind:`word`,text:`Go to`},{kind:`code`,text:e}],custom:!1,step:{type:`goto`,url:e}}}function IP(e,t){return[{type:`goto`,url:e},...t]}function LP(e,t,n,r){return{...n,steps:IP(e,t),keep:[`cookies`],saveTo:r}}function RP(e){let t=e.start;if(!Array.isArray(t))return;let n=t[0];if(typeof n!=`object`||!n)return;let r=n.url;return typeof r==`string`?r:void 0}function zP(e,t){let n=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),r=n===-1?`.`:e.slice(0,n),i=n===-1||e[n]===void 0?`/`:e[n];return`${r}${i}storage${i}${t}-session.json`}function BP(e,t,n){let r=[`[data-oc-node] { cursor: ${e?`crosshair`:`inherit`}; }`,`[data-oc-node]:hover { outline: 2px solid #3182ce !important; outline-offset: -2px; }`];return n!==void 0&&n!==``&&r.push(`${n} { outline: 2px solid #dd6b20 !important; outline-offset: -2px; background: rgba(221,107,32,0.08) !important; }`),t&&r.push(`[data-oc-hidden] { display: revert !important; visibility: visible !important; opacity: 0.5 !important; outline: 1px dashed #ed8936 !important; }`),r.join(`
|
|
15
|
+
`)}var VP=`data-oc-node`,HP=`opencraw-picker-style`;function UP({html:e,pickMode:t,showHidden:n,hoveredSelector:r,onHoverNode:i,onPickNode:a}){let o=(0,N.useRef)(null),s=(0,N.useRef)({pickMode:t,onHoverNode:i,onPickNode:a});return s.current={pickMode:t,onHoverNode:i,onPickNode:a},(0,N.useEffect)(()=>{let e=o.current;if(e===null)return;let t,n=e=>{s.current.onHoverNode(WP(e.target))},r=()=>{s.current.onHoverNode(void 0)},i=e=>{if(!s.current.pickMode)return;let t=WP(e.target);t!==void 0&&(e.preventDefault(),e.stopPropagation(),s.current.onPickNode(t))},a=()=>{let a=e.contentDocument;a!==null&&(a.addEventListener(`mouseover`,n),a.addEventListener(`mouseout`,r),a.addEventListener(`click`,i,{capture:!0}),t=()=>{a.removeEventListener(`mouseover`,n),a.removeEventListener(`mouseout`,r),a.removeEventListener(`click`,i,{capture:!0})})};return e.addEventListener(`load`,a),()=>{e.removeEventListener(`load`,a),t?.()}},[e]),(0,N.useEffect)(()=>{let e=o.current?.contentDocument;if(e==null)return;let i=e.getElementById(HP);i===null&&(i=e.createElement(`style`),i.id=HP,e.head?.append(i)),i.textContent=BP(t,n,r)}),(0,P.jsx)(`iframe`,{ref:o,title:`Snapshot`,sandbox:`allow-same-origin`,srcDoc:e,style:{width:`100%`,height:`100%`,border:`none`,background:`white`}})}function WP(e){return(e?.nodeType===Node.ELEMENT_NODE?e.closest(`[${CSS.escape(VP)}]`):null)?.getAttribute(VP)??void 0}var GP=[],KP={object:`purple.fg`,array:`purple.fg`,element:`purple.fg`,string:`green.fg`,number:`orange.fg`,boolean:`blue.fg`,null:`fg.muted`};function qP({tree:e,onPick:t,steps:n=GP,hoveredStepId:r,onHoverStepId:i}){let[a,o]=(0,N.useState)(()=>new Set);function s(e){o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,P.jsxs)(F,{h:`full`,overflow:`auto`,fontFamily:`mono`,fontSize:`xs`,py:2,children:[e.namespaces!==void 0&&Object.keys(e.namespaces).length>0&&(0,P.jsxs)(G,{px:2,pb:2,gap:2,flexWrap:`wrap`,children:[(0,P.jsx)(H,{color:`fg.muted`,children:`Namespaces:`}),Object.entries(e.namespaces).map(([e,t])=>(0,P.jsx)(Aw,{size:`xs`,colorPalette:`gray`,children:`${e}: ${t}`},e))]}),(0,P.jsx)(JP,{node:e.root,depth:0,collapsed:a,onToggle:s,onPick:t,steps:n,hoveredStepId:r,onHoverStepId:i})]})}function JP({node:e,depth:t,collapsed:n,onToggle:r,onPick:i,steps:a,hoveredStepId:o,onHoverStepId:s}){let c=e.children.length>0,l=n.has(e.id),u=e.valueType!==`object`&&e.valueType!==`array`&&e.valueType!==`element`,d=_N(e,a),f=o!==void 0&&d.includes(o);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(G,{"data-testid":`tree-node`,"data-highlighted":f,"data-step-ids":d.length===0?void 0:d.join(` `),gap:1,pl:`${t*14+4}px`,pr:2,minH:`20px`,cursor:`pointer`,bg:f?`orange.subtle`:void 0,_hover:{bg:f?`orange.subtle`:`bg.emphasized`},onClick:()=>{i(e,`value`)},onMouseEnter:s===void 0?void 0:()=>{s(d[0])},onMouseLeave:s===void 0?void 0:()=>{s(void 0)},children:[c?(0,P.jsx)(H,{as:`button`,w:`12px`,flexShrink:0,color:`fg.muted`,onClick:t=>{t.stopPropagation(),r(e.id)},children:l?`▸`:`▾`}):(0,P.jsx)(F,{w:`12px`,flexShrink:0}),(0,P.jsx)(H,{as:`span`,color:KP[e.valueType],fontWeight:`medium`,children:e.label}),u&&e.preview!==void 0&&(0,P.jsx)(H,{as:`span`,color:`fg.muted`,truncate:!0,children:e.preview}),d.map(e=>(0,P.jsx)(Aw,{size:`xs`,colorPalette:`orange`,variant:f?`solid`:`subtle`,title:`Already in the recipe: the step reading this`,flexShrink:0,children:e},e)),e.listPath!==void 0&&(0,P.jsx)(Aw,{as:`button`,size:`xs`,colorPalette:`blue`,onClick:t=>{t.stopPropagation(),i(e,`list`)},title:`Read every one of the ${String(e.listCount??0)} items in this list`,children:`[*] ×${String(e.listCount??0)}`}),u&&e.jsonpath!==void 0&&(0,P.jsx)(H,{as:`button`,fontSize:`2xs`,color:`fg.muted`,_hover:{color:`fg`,textDecoration:`underline`},onClick:t=>{t.stopPropagation(),i(e,`next`)},title:`Use as the pagination "next" cursor/URL`,children:`next →`})]}),c&&!l&&e.children.map(e=>(0,P.jsx)(JP,{node:e,depth:t+1,collapsed:n,onToggle:r,onPick:i,steps:a,hoveredStepId:o,onHoverStepId:s},e.id))]})}var YP=100,XP=`img, picture, video, canvas, svg, iframe, object, embed, input, select, textarea, table`,ZP=`h1, h2, h3, h4, h5, h6, li, a[href]`;function QP(e){let t=new DOMParser().parseFromString(e,`text/html`).body;for(let e of t.querySelectorAll(`script, style, noscript, template`))e.remove();return(t.textContent??``).trim().length>=YP||t.querySelector(`${XP}, ${ZP}`)!==null}function $P(e,t){let n=OO(e,t)?.step.selector;return typeof n==`string`?n:void 0}function eF(e,t,n){if(e!==void 0&&t!==void 0)for(let r of AO(e)){let e=r.step.selector,i=r.step.id;if(typeof e==`string`&&typeof i==`string`&&sA(t,e).has(n))return i}}var tF=`start`,nF=new Set([`json`,`yaml`,`jsonl`,`xml`]),rF=new Set([`csv`,`xlsx`]),iF=new Set([`pptx`]);function aF({recipe:e,onSaveOutline:t,onSaveRecipe:n}){let r=e?.id,i=ck(r,r===void 0?void 0:tF),a=lk(),[o,s]=(0,N.useState)(!1),c=LO(),l=i.data?.format,u=l!==void 0&&nF.has(l),d=l===`pdf`,f=l!==void 0&&rF.has(l),p=l!==void 0&&iF.has(l),m=!u&&!d&&!f&&!p,h=i.data?.html,g=(0,N.useMemo)(()=>h===void 0||QP(h),[h]),_=pk(r,r===void 0?void 0:tF,u),v=mk(r,r===void 0?void 0:tF,d),[y,b]=(0,N.useState)(void 0),x=_k(r,r===void 0?void 0:tF,f,y),S=yk(r,r===void 0?void 0:tF,p),C=JO(e=>e.pickTarget),w=JO(e=>e.showHidden),T=JO(e=>e.hoveredStepId),E=JO(e=>e.startPicking),D=JO(e=>e.stopPicking),O=JO(e=>e.registerPick),k=JO(e=>e.setShowHidden),ee=JO(e=>e.setHoveredNodeId),te=JO(e=>e.setHoveredStepId),ne=(0,N.useMemo)(()=>$P(e?.outline,T),[e?.outline,T]),re=(0,N.useMemo)(()=>gN(e?.outline),[e?.outline]),ie=t=>{ee(t),te(t===void 0?void 0:eF(e?.outline,i.data?.html,t))},ae=QO(e=>e.recipeId),oe=QO(e=>e.active),se=QO(e=>e.cards.length),ce=QO(e=>e.stoppedSteps),le=QO(e=>e.error),A=QO(e=>e.dismissStopped),ue=xk(),de=Sk(),fe=ae===r&&oe,pe=ae===r?ce:void 0,[me,he]=(0,N.useState)(void 0),ge=e=>{he(e===void 0?void 0:{text:e,ok:!0})},_e=e=>{he(e===void 0?void 0:{text:e,ok:!1})},ve=(0,N.useRef)(void 0),ye=(0,N.useRef)(void 0),j=C!==void 0&&C.recipeId===r;(0,N.useEffect)(()=>{ye.current=void 0,b(void 0)},[r]);async function M(e){if(r===void 0)return;let t=O(e);if(t.kind===`first`){let t=await a.mutateAsync({recipeId:r,path:tF,nodeIds:[e]});if(t.kind!==`field`){_e(t.kind===`unsupported`?t.reason:void 0);return}await we(e=>(ve.current=mO(e),ge(`Read card: ${t.field.selector} (${t.field.matches} match${t.field.matches===1?``:`es`})`),hO(e,void 0,[oO(t.field,`steps.${e.length}`)])));return}let n=await a.mutateAsync({recipeId:r,path:tF,nodeIds:[t.firstNodeId,e]});if(n.kind!==`list`){_e(n.kind===`unsupported`?n.reason:void 0);return}await we(e=>{let t=ve.current;ve.current=void 0;let r=t??mO(e);return ge(`List: ${n.item.selector} (${n.item.matches} items) → ${n.field.selector}`),hO(e,t,lO(n,`steps.${r}`))})}async function be(e,t){if(r!==void 0)try{if(t===`next`){await we(t=>{let n=cO(e,`steps.${t.length}`);return ge(`Paginate: next from ${e.jsonpath}`),hO(t,void 0,[n])});return}await we(n=>{if(t===`list`){let t=pO(n,e);if(t!==void 0)return ge(`Added to the list: ${String(e.listPath)}`),t;let r=fO(e,`steps.${mO(n)}`);if(r!==void 0)return ge(`List: ${String(e.listPath)} (${String(e.listCount??0)} items)`),hO(n,void 0,r)}let r=sO(e,`steps.${n.length}`,{generalize:t===`list`,namespaces:_.data?.namespaces});return ge(`Read card: ${r.step.selector}${t===`list`?` (${String(e.listCount??0)} items)`:``}`),hO(n,void 0,[r])})}catch(e){_e(e instanceof Error?e.message:String(e))}}async function xe(e){await we(t=>{let n=ye.current,r=n??mO(t);return ye.current=r,ge(`table: ${String(e.step.selector)}`),hO(t,n,[{...e,path:`steps.${r}`}])})}async function Se(e){await we(t=>(ge(`${String(e.step.kind)}: ${String(e.step.id)} ← ${String(e.step.selector)}`),hO(t,void 0,[{...e,path:`steps.${t.length}`}])))}async function Ce(e){await we(t=>(ge(`jsonpath: ${String(e.step.selector)}`),hO(t,void 0,[{...e,path:`steps.${t.length}`}])))}async function we(n){if(t===void 0||e?.outline===void 0)return;let r=n(e.outline.steps);await t(e.file,{...e.outline,steps:r})}function Te(){if(r===void 0||e?.outline===void 0)return;let t=RP(e.outline.recipe);if(t===void 0){_e(`this recipe has no start point to record from`);return}ue.mutate({recipeId:r,startUrl:t})}async function Ee(){if(pe===void 0||e?.outline===void 0)return;let n=QO.getState().startUrl;if(n===void 0)return;let i=e.outline.recipe.session,a=oF(i)?i:{},o=a.bootstrap,s=oF(o)?o:void 0,c=zP(e.file,r??`recipe`),l={...a,bootstrap:LP(n,pe,s,c)};await t?.(e.file,{...e.outline,recipe:{...e.outline.recipe,session:l}}),ge(`Made the login: session.bootstrap, ${pe.length} step${pe.length===1?``:`s`}`),A()}async function De(){if(pe===void 0||e?.outline===void 0)return;let t=QO.getState().startUrl;if(t===void 0)return;let n=QO.getState().cards;await we(e=>hO(e,void 0,[FP(t,`steps.${e.length}`),...n.map(e=>e.node)])),ge(`Kept as steps: ${pe.length} step${pe.length===1?``:`s`}`),A()}if(r===void 0)return(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`Pick a recipe to see its snapshot here.`})});function Oe(){if(j){D();return}ve.current=void 0,E(r,tF)}return(0,P.jsxs)(F,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,P.jsxs)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,minH:`38px`,children:[!u&&!d&&!f&&!p&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:j?`semibold`:`normal`,color:j?`colorPalette.fg`:`fg`,colorPalette:`blue`,cursor:`pointer`,onClick:Oe,children:j?`Cancel pick`:`Read`}),(0,P.jsxs)(cE,{checked:w,onCheckedChange:e=>{k(e.checked)},size:`sm`,children:[(0,P.jsx)(fE,{}),(0,P.jsx)(dE,{}),(0,P.jsx)(lE,{fontSize:`sm`,children:`Show hidden`})]}),(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:o?`semibold`:`normal`,color:o?`colorPalette.fg`:`fg`,colorPalette:`purple`,cursor:`pointer`,onClick:()=>{s(e=>!e)},children:o?`Hide inspector`:`Inspect`}),(0,P.jsx)(H,{as:`button`,fontSize:`sm`,fontWeight:fe?`semibold`:`normal`,color:fe?`red.fg`:`fg`,colorPalette:`red`,cursor:`pointer`,onClick:()=>{fe?de.mutate():Te()},children:fe?`Stop recording`:`Record`})]}),u&&(0,P.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:`Click a value to read it; [*] reads every item of a list.`}),(i.isFetching||u&&_.isFetching||d&&v.isFetching||f&&x.isFetching||p&&S.isFetching)&&(0,P.jsx)(Nw,{size:`xs`}),me!==void 0&&(0,P.jsx)(Aw,{size:`sm`,colorPalette:me.ok?`green`:`orange`,children:me.text})]}),fe&&(0,P.jsxs)(G,{px:3,py:2,bg:`red.subtle`,color:`red.fg`,fontSize:`sm`,gap:3,flexShrink:0,"data-testid":`recording-banner`,children:[(0,P.jsx)(F,{w:`8px`,h:`8px`,borderRadius:`full`,bg:`red.solid`,flexShrink:0}),(0,P.jsx)(H,{children:`Recording — a browser window opened for you to drive; interact with it, not with the snapshot below.`}),(0,P.jsxs)(Aw,{size:`sm`,colorPalette:`red`,children:[se,` step`,se===1?``:`s`]})]}),le!==void 0&&ae===r&&(0,P.jsx)(F,{px:3,py:1,bg:`red.subtle`,color:`red.fg`,fontSize:`sm`,flexShrink:0,children:le}),pe!==void 0&&(0,P.jsxs)(G,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,"data-testid":`recording-stopped-bar`,children:[(0,P.jsxs)(H,{fontSize:`sm`,children:[`Recording stopped: `,pe.length,` step`,pe.length===1?``:`s`,` recorded.`]}),(0,P.jsx)(Rw,{size:`xs`,colorPalette:`blue`,onClick:()=>{Ee()},disabled:pe.length===0,children:`Make this the login`}),(0,P.jsx)(Rw,{size:`xs`,variant:`outline`,onClick:()=>{De()},disabled:pe.length===0,children:`Keep as steps`}),(0,P.jsx)(Rw,{size:`xs`,variant:`ghost`,onClick:A,children:`Discard`})]}),m&&i.data!==void 0&&!g&&(0,P.jsx)(AM,{}),(0,P.jsxs)(F,{flex:`1`,minH:`0`,children:[u&&_.data!==void 0&&(0,P.jsx)(qP,{tree:_.data,onPick:(e,t)=>{be(e,t)},steps:re,hoveredStepId:T,onHoverStepId:te}),u&&_.isError&&(0,P.jsx)(F,{p:4,color:`fg.error`,children:(0,P.jsx)(H,{children:_.error.message})}),d&&v.data!==void 0&&(0,P.jsx)(CP,{recipeId:r,stepPath:tF,view:v.data,bytesUrl:c.pdfBytesUrl(r,tF),onTablePick:e=>{xe(e)},onRegionPick:e=>{Se(e)},steps:re,hoveredStepId:T,onHoverStepId:te}),d&&v.isError&&(0,P.jsx)(F,{p:4,color:`fg.error`,children:(0,P.jsx)(H,{children:v.error.message})}),f&&x.data!==void 0&&(0,P.jsx)(ZN,{recipeId:r,stepPath:tF,view:x.data,onTablePick:e=>{xe(e)},onCellPick:e=>{Se(e)},steps:re,hoveredStepId:T,onHoverStepId:te,csvOverride:y,onCsvOverrideChange:b}),f&&x.isError&&(0,P.jsx)(F,{p:4,color:`fg.error`,children:(0,P.jsx)(H,{children:x.error.message})}),p&&S.data!==void 0&&(0,P.jsx)(NN,{recipeId:r,stepPath:tF,view:S.data,onTablePick:e=>{xe(e)},onChartPick:e=>{Ce(e)},onRegionPick:e=>{Se(e)},steps:re,hoveredStepId:T,onHoverStepId:te}),p&&S.isError&&(0,P.jsx)(F,{p:4,color:`fg.error`,children:(0,P.jsx)(H,{children:S.error.message})}),!u&&!d&&!f&&!p&&i.data!==void 0&&!o&&(0,P.jsx)(UP,{html:i.data.html,pickMode:j,showHidden:w,hoveredSelector:ne,onHoverNode:ie,onPickNode:e=>{M(e)}}),!u&&!d&&!f&&!p&&i.data!==void 0&&o&&(0,P.jsxs)($T,{panels:[{id:`snapshot`,minSize:15},{id:`inspect`,minSize:20}],h:`full`,children:[(0,P.jsx)(eE,{id:`snapshot`,overflow:`hidden`,children:(0,P.jsx)(UP,{html:i.data.html,pickMode:j,showHidden:w,hoveredSelector:ne,onHoverNode:ie,onPickNode:e=>{M(e)}})}),(0,P.jsx)(rE,{id:`snapshot:inspect`}),(0,P.jsx)(eE,{id:`inspect`,overflow:`hidden`,children:(0,P.jsx)(vA,{recipeId:r,recipe:e,snapshot:i.data,onSaveOutline:t,onSaveRecipe:n})})]}),i.isError&&(0,P.jsxs)(F,{p:4,color:`fg.error`,role:`alert`,children:[(0,P.jsx)(H,{fontWeight:`semibold`,children:`Could not take a snapshot of this recipe's page.`}),(0,P.jsx)(H,{children:i.error.message})]}),!i.isFetching&&!i.isError&&i.data===void 0&&(0,P.jsx)(F,{p:4,color:`fg.muted`,children:(0,P.jsx)(H,{children:`Run a sample, or open a recipe, to see its snapshot here.`})})]})]})}function oF(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var sF=1024,cF=0,lF=class{constructor(e,t){this.from=e,this.to=t}},uF=class{constructor(e={}){this.id=cF++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=pF.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};uF.closedBy=new uF({deserialize:e=>e.split(` `)}),uF.openedBy=new uF({deserialize:e=>e.split(` `)}),uF.group=new uF({deserialize:e=>e.split(` `)}),uF.isolate=new uF({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),uF.contextHash=new uF({perNode:!0}),uF.lookAhead=new uF({perNode:!0}),uF.mounted=new uF({perNode:!0});var dF=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[uF.mounted.id]}},fF=Object.create(null),pF=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):fF,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(uF.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(uF.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};pF.none=new pF(``,Object.create(null),0,8);var mF=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new pF(e.name,r,e.id,e.flags):e)}return new e(n)}},hF=new WeakMap,gF=new WeakMap,_F;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(_F||={});var vF=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=dF.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new MF(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new MF(hF.get(this)||this.topNode);return r.moveTo(e,t),hF.set(this,r._tree),r}get topNode(){return new wF(this,0,0,null)}resolve(e,t=0){let n=SF(hF.get(this)||this.topNode,e,t,!1);return hF.set(this,n),n}resolveInner(e,t=0){let n=SF(gF.get(this)||this.topNode,e,t,!0);return gF.set(this,n),n}resolveStack(e,t=0){return jF(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&_F.IncludeAnonymous)>0;for(let e=this.cursor(a|_F.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:LF(pF.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(pF.none,t,n,r)))}static build(e){return PF(e)}};vF.empty=new vF(pF.none,[],[],0);var yF=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},bF=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return pF.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(xF(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function xF(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function SF(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof wF&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:_F.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof wF&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var CF=class{cursor(e=0){return new MF(this,e)}getChild(e,t=null,n=null){let r=TF(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return TF(this,e,t,n)}resolve(e,t=0){return SF(this,e,t,!1)}resolveInner(e,t=0){return SF(this,e,t,!0)}matchContext(e){return EF(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},wF=class e extends CF{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&_F.EnterBracketed&&l instanceof vF&&(d=dF.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||xF(i,r,u,u+l.length)){if(l instanceof bF){if(a&_F.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new OF(new DF(o,l,t,u),null,e)}else if(a&_F.IncludeAnonymous||!l.type.isAnonymous||NF(l)){let s;if(!(a&_F.IgnoreMounts)&&(s=dF.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&_F.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&_F.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&_F.IgnoreOverlays)&&(i=dF.get(this._tree))&&i.overlay){let a=t-this.from,o=r&_F.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function TF(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function EF(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var DF=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},OF=class e extends CF{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&_F.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new vF(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function kF(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof wF&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new AF(i,n)}var AF=class{constructor(e,t){this.heads=e,this.node=t}get next(){return kF(this.heads)}};function jF(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof wF?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=dF.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new wF(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(SF(o,t,n,!1))}}return i?kF(i):r}var MF=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~_F.EnterBracketed,e instanceof wF)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof wF?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&_F.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&_F.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&_F.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&_F.IncludeAnonymous||e instanceof bF||!e.type.isAnonymous||NF(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new OF(this.buffer,t,this.stack[e]);return this.bufferNode=new OF(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return EF(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return EF(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function NF(e){return e.children.some(e=>e instanceof bF||!e.type.isAnonymous||NF(e))}function PF(e){let{buffer:t,nodeSet:n,maxBufferLength:r=sF,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new yF(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0){if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}if(w==-3){c=x;return}if(w==-4){l=x;return}throw RangeError(`Unrecognized record size: ${w}`)}let D=s[x],O,k,ee=S-e;if(C-S<=r&&(k=h(o.pos-t,y))){let t=new Uint16Array(k.size-k.skip),r=o.pos-k.size,i=t.length;for(;o.pos>r;)i=g(k.start,t,i);O=new bF(t,C-k.start,n),ee=k.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,E),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,E),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(D,E);O=LF(D,t,n,0,t.length,0,C-S,e,e)}else O=m(D,t,n,C-S,T-C,E)}_.push(O),v.push(ee)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new bF(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof vF){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(uF.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[uF.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[uF.lookAhead,i];o=o?[e].concat(o):[e]}return new vF(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new vF(s[e.topID],_.reverse(),v.reverse(),y)}var FF=new WeakMap;function IF(e,t){if(!e.isAnonymous||t instanceof bF||t.type!=e)return 1;let n=FF.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof vF)){n=1;break}n+=IF(e,r)}FF.set(t,n)}return n}function LF(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=IF(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=IF(e,t[s]);for(s++;s<i;s++){let n=IF(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(LF(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var RF=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},zF=class{startParse(e,t,n){return typeof e==`string`&&(e=new BF(e)),n=n?n.length?n.map(e=>new lF(e.from,e.to)):[new lF(0,0)]:[new lF(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},BF=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new uF({perNode:!0});var VF=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new HF(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&s==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this.buffer.length;if(e>0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new UF(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new HF(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},HF=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},UF=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},WF=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function GF(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var KF=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},qF=new KF,JF=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=qF,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1:this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=qF,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},YF=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;ZF(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};YF.prototype.contextual=YF.prototype.fallback=YF.prototype.extend=!1;var XF=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?GF(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(ZF(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};XF.prototype.contextual=YF.prototype.fallback=YF.prototype.extend=!1;function ZF(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||$F(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function QF(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function $F(e,t,n,r){let i=QF(n,r,t);return i<0||QF(n,r,e)<i}var eI=typeof process<`u`&&/\bparse\b/.test({}.LOG),tI=null;function nI(e,t,n){let r=e.cursor(_F.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var rI=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?nI(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?nI(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof vF){if(a==e){if(a<this.safeFrom)return null;let e=a+i.length;if(e<=this.safeTo){let t=i.prop(uF.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},iI=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new KF)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if((!n||c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new KF,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new KF,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535){if(o[s+1]==1)s=lI(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(lI(o,s+2),t,n,r));break}}o[s]==t&&(r=this.putAction(lI(o,s+1),t,n,r))}return r}},aI=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new JF(t,r),this.tokens=new iI(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[VF.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new rI(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&uI(r);if(e)return eI&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw eI&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return eI&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=eI?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(uF.contextHash)||0)==n))return e.useNode(o,r),eI&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(o.type.id)})`),!0;if(!(o instanceof vF)||o.children.length==0||o.positions[0]>0)break;let s=o.children[0];if(s instanceof vF&&o.positions[0]==0)o=s;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),eI&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),eI&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return oI(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=eI?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),eI&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(eI&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)eI&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))eI&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),eI&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),oI(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),vF.build({buffer:WF.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(tI||=new WeakMap).get(e);return t||tI.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function oI(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var sI=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},cI=class e extends zF{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=uF[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new mF(t.map((t,i)=>pF.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=sF;let a=GF(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(dI),this.states=GF(e.states,Uint32Array),this.data=GF(e.stateData),this.goto=GF(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new YF(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new aI(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535){if(n[i+1]==1)a=n[i=lI(n,i+2)];else if(n[i+1]==2)return lI(n,i+2);else break}if(a==t||a==0)return lI(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=lI(this.data,n+2);else break}r=t(lI(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=lI(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=dI(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new sI(e,n,r)}static deserialize(t){return new e(t)}};function lI(e,t){return e[t]|e[t+1]<<16}function uI(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function dI(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}var fI=0,pI=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=fI++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new hI(e);return e=>e.modified.indexOf(t)>-1?e:hI.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},mI=0,hI=class e{constructor(e){this.name=e,this.instances=[],this.id=mI++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&gI(n,e.modified));if(r)return r;let i=[],a=new pI(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=_I(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function gI(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function _I(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function vI(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new bI(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return yI.add(t)}var yI=new uF({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new bI(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),bI=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};bI.empty=new bI([],2,null);function xI(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function SI(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function CI(e,t,n,r=0,i=e.length){let a=new wI(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var wI=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=TI(e)||bI.empty,u=SI(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(uF.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function TI(e){let t=e.type.prop(yI);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var K=pI.define,EI=K(),DI=K(),OI=K(DI),kI=K(DI),AI=K(),jI=K(AI),MI=K(AI),NI=K(),PI=K(NI),FI=K(),II=K(),LI=K(),RI=K(LI),zI=K(),q={comment:EI,lineComment:K(EI),blockComment:K(EI),docComment:K(EI),name:DI,variableName:K(DI),typeName:OI,tagName:K(OI),propertyName:kI,attributeName:K(kI),className:K(DI),labelName:K(DI),namespace:K(DI),macroName:K(DI),literal:AI,string:jI,docString:K(jI),character:K(jI),attributeValue:K(jI),number:MI,integer:K(MI),float:K(MI),bool:K(AI),regexp:K(AI),escape:K(AI),color:K(AI),url:K(AI),keyword:FI,self:K(FI),null:K(FI),atom:K(FI),unit:K(FI),modifier:K(FI),operatorKeyword:K(FI),controlKeyword:K(FI),definitionKeyword:K(FI),moduleKeyword:K(FI),operator:II,derefOperator:K(II),arithmeticOperator:K(II),logicOperator:K(II),bitwiseOperator:K(II),compareOperator:K(II),updateOperator:K(II),definitionOperator:K(II),typeOperator:K(II),controlOperator:K(II),punctuation:LI,separator:K(LI),bracket:RI,angleBracket:K(RI),squareBracket:K(RI),paren:K(RI),brace:K(RI),content:NI,heading:PI,heading1:K(PI),heading2:K(PI),heading3:K(PI),heading4:K(PI),heading5:K(PI),heading6:K(PI),contentSeparator:K(NI),list:K(NI),quote:K(NI),emphasis:K(NI),strong:K(NI),link:K(NI),monospace:K(NI),strikethrough:K(NI),inserted:K(),deleted:K(),changed:K(),invalid:K(),meta:zI,documentMeta:K(zI),annotation:K(zI),processingInstruction:K(zI),definition:pI.defineModifier(`definition`),constant:pI.defineModifier(`constant`),function:pI.defineModifier(`function`),standard:pI.defineModifier(`standard`),local:pI.defineModifier(`local`),special:pI.defineModifier(`special`)};for(let e in q){let t=q[e];t instanceof pI&&(t.name=e)}xI([{tag:q.link,class:`tok-link`},{tag:q.heading,class:`tok-heading`},{tag:q.emphasis,class:`tok-emphasis`},{tag:q.strong,class:`tok-strong`},{tag:q.keyword,class:`tok-keyword`},{tag:q.atom,class:`tok-atom`},{tag:q.bool,class:`tok-bool`},{tag:q.url,class:`tok-url`},{tag:q.labelName,class:`tok-labelName`},{tag:q.inserted,class:`tok-inserted`},{tag:q.deleted,class:`tok-deleted`},{tag:q.literal,class:`tok-literal`},{tag:q.string,class:`tok-string`},{tag:q.number,class:`tok-number`},{tag:[q.regexp,q.escape,q.special(q.string)],class:`tok-string2`},{tag:q.variableName,class:`tok-variableName`},{tag:q.local(q.variableName),class:`tok-variableName tok-local`},{tag:q.definition(q.variableName),class:`tok-variableName tok-definition`},{tag:q.special(q.variableName),class:`tok-variableName2`},{tag:q.definition(q.propertyName),class:`tok-propertyName tok-definition`},{tag:q.typeName,class:`tok-typeName`},{tag:q.namespace,class:`tok-namespace`},{tag:q.className,class:`tok-className`},{tag:q.macroName,class:`tok-macroName`},{tag:q.propertyName,class:`tok-propertyName`},{tag:q.operator,class:`tok-operator`},{tag:q.comment,class:`tok-comment`},{tag:q.meta,class:`tok-meta`},{tag:q.invalid,class:`tok-invalid`},{tag:q.punctuation,class:`tok-punctuation`}]);var BI=vI({String:q.string,Number:q.number,"True False":q.bool,PropertyName:q.propertyName,Null:q.null,", :":q.separator,"[ ]":q.squareBracket,"{ }":q.brace}),VI=cI.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:`#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O`,goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:`⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array`,maxTerm:25,nodeProps:[[`isolate`,-2,6,11,``],[`openedBy`,7,`{`,14,`[`],[`closedBy`,8,`}`,15,`]`]],propSources:[BI],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),HI=[],UI=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?UI:HI).push(n+=e[t])})();function WI(e){if(e<768)return!1;for(let t=0,n=HI.length;;){let r=t+n>>1;if(e<HI[r])n=r;else if(e>=UI[r])t=r+1;else return!0;if(t==n)return!1}}function GI(e){return e>=127462&&e<=127487}var KI=8205;function qI(e,t,n=!0,r=!0){return(n?JI:YI)(e,t,r)}function JI(e,t,n){if(t==e.length)return t;t&&ZI(e.charCodeAt(t))&&QI(e.charCodeAt(t-1))&&t--;let r=XI(e,t);for(t+=$I(r);t<e.length;){let i=XI(e,t);if(r==KI||i==KI||n&&WI(i))t+=$I(i),r=i;else if(GI(i)){let n=0,r=t-2;for(;r>=0&&GI(XI(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function YI(e,t,n){for(;t>1;){let r=JI(e,t-2,n);if(r<t)return r;t--}return 0}function XI(e,t){let n=e.charCodeAt(t);if(!QI(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ZI(r)?(n-55296<<10)+(r-56320)+65536:n}function ZI(e){return e>=56320&&e<57344}function QI(e){return e>=55296&&e<56320}function $I(e){return e<65536?1:2}var eL=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=uL(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),nL.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=uL(this,e,t);let n=[];return this.decompose(e,t,n,0),nL.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new oL(this),i=new oL(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new oL(this,e)}iterRange(e,t=this.length){return new sL(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new cL(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new tL(t):nL.from(tL.split(t,[]))}},tL=class e extends eL{constructor(e,t=rL(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new lL(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(aL(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=iL(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=uL(this,t,n);let i=iL(this.text,iL(r.text,aL(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):nL.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
16
16
|
`){[e,t]=uL(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},nL=class e extends eL{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=uL(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
17
17
|
`){[e,t]=uL(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new tL(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof tL&&c&&(n=u[u.length-1])instanceof tL&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new tL(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};eL.empty=new tL([``],0);function rL(e){let t=-1;for(let n of e)t+=n.length+1;return t}function iL(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function aL(e,t,n){return iL(e,[``],t,n)}var oL=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof tL?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof tL?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
18
18
|
`,this;e--}else if(r instanceof tL){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof tL?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},sL=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new oL(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},cL=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(eL.prototype[Symbol.iterator]=function(){return this.iter()},oL.prototype[Symbol.iterator]=sL.prototype[Symbol.iterator]=cL.prototype[Symbol.iterator]=function(){return this});var lL=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function uL(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function dL(e,t,n=!0,r=!0){return qI(e,t,n,r)}function fL(e){return e>=56320&&e<57344}function pL(e){return e>=55296&&e<56320}function mL(e,t){let n=e.charCodeAt(t);if(!pL(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return fL(r)?(n-55296<<10)+(r-56320)+65536:n}function hL(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function gL(e){return e<65536?1:2}var _L=/\r\n?|\n/,vL=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(vL||={}),yL=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){CL(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:TL(this,e)}mapDesc(e,t=!1){return e.empty?this:wL(this,e,t)}mapPos(e,t=-1,n=vL.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=vL.Simple&&c>=e&&(n==vL.TrackDel&&r<e&&c>e||n==vL.TrackBefore&&r<e||n==vL.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},bL=class e extends yL{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return CL(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return wL(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(eL.empty);r.push(a?t.slice(i,i+a):eL.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:TL(this,e,!0)}map(e,t=!1){return e.empty?this:wL(this,e,t,!0)}iterChanges(e,t=!1){CL(this,e,t)}get desc(){return yL.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new EL(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);xL(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;xL(n,e,t),t>0&&SL(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);xL(n,e,-1),xL(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:yL.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&xL(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?eL.of(l.split(r||_L)):l:eL.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&xL(i,e-o,-1),xL(i,s-e,d),SL(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(eL.empty);r[e]=eL.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function xL(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function SL(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(eL.empty);e.push(n)}}function CL(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=eL.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function wL(e,t,n,r=!1){let i=[],a=r?[]:null,o=new EL(e),s=new EL(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);xL(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(xL(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(xL(i,0,o.ins),a&&SL(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;xL(i,t,e<o.i?o.ins:0),a&&e<o.i&&SL(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?bL.createSet(i,a):yL.create(i);else throw Error(`Mismatched change set lengths`)}function TL(e,t,n=!1){let r=[],i=n?[]:null,a=new EL(e),o=new EL(t);for(let e=!1;;)if(a.done&&o.done)return i?bL.createSet(r,i):yL.create(r);else if(a.ins==0)xL(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)xL(r,0,o.ins,e),i&&SL(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;xL(r,t,n,e),i&&n&&SL(i,r,o.text)}else o.ins==-1?(xL(r,a.off?0:a.len,t,e),i&&SL(i,r,a.textBit(t))):(xL(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&SL(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var EL=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?eL.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?eL.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},DL=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return J.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return J.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return J.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},J=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>DL.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return DL.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,i){let a=r==null?7:Math.min(6,r);return!i&&e!=t&&(i=t<e?1:-1),i&&(a|=i<0?8:16),t<e?DL.create(t,e,a|32,n):DL.create(e,t,a,n)}static undirectionalRange(e,t){return DL.create(e,t,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function OL(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var kL=0,Y=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=kL++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:AL),!!t.static,t.enables)}of(e){return new jL([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new jL(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new jL(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function AL(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var jL=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=kL++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||NL(e,c)){let r=t(e);if(a?!ML(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=KL(o,c);if(this.dependencies.every(t=>t instanceof Y?o.facet(t)===e.facet(t):t instanceof IL?o.field(t,!1)==e.field(t,!1):!0)||(a?ML(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function ML(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function NL(e,t){let n=!1;for(let r of t)GL(e,r)&1&&(n=!0);return n}function PL(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=KL(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)GL(e,t);return e.values[o]=s(e),1},update(e,n){if(!NL(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=NL(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&AL(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var FL=Y.define({static:!0}),IL=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(kL++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(FL).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(FL),i=n.facet(FL),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,FL.of({field:this,create:e})]}get extension(){return this}},LL={lowest:4,low:3,default:2,high:1,highest:0};function RL(e){return t=>new BL(t,e)}var zL={highest:RL(LL.highest),high:RL(LL.high),default:RL(LL.default),low:RL(LL.low),lowest:RL(LL.lowest)},BL=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},VL=class e{of(e){return new HL(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},HL=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},UL=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of WL(t,n,o))e instanceof IL?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,AL(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>PL(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function WL(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof HL&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof HL){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof BL)a(e.inner,e.prec);else if(e instanceof IL)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof jL)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,LL.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,LL.default),r.reduce((e,t)=>e.concat(t))}function GL(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function KL(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var qL=Y.define(),JL=Y.define({combine:e=>e.some(e=>e),static:!0}),YL=Y.define({combine:e=>e.length?e[0]:void 0,static:!0}),XL=Y.define(),ZL=Y.define(),QL=Y.define(),$L=Y.define({combine:e=>e.length?e[0]:!1}),eR=class{constructor(e,t){this.type=e,this.value=t}static define(){return new tR}},tR=class{of(e){return new eR(this,e)}},nR=class{constructor(e){this.map=e}of(e){return new X(this,e)}},X=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new nR(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};X.reconfigure=X.define(),X.appendConfig=X.define();var rR=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&OL(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};rR.time=eR.define(),rR.userEvent=eR.define(),rR.addToHistory=eR.define(),rR.remote=eR.define();function iR(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function aR(e,t,n){let r,i,a;return n?(r=t.changes,i=bL.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:X.mapEffects(e.effects,r).concat(X.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function oR(e,t,n){let r=t.selection,i=dR(t.annotations);return t.userEvent&&(i=i.concat(rR.userEvent.of(t.userEvent))),{changes:t.changes instanceof bL?t.changes:bL.of(t.changes||[],n,e.facet(YL)),selection:r&&(r instanceof J?r:J.single(r.anchor,r.head)),effects:dR(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function sR(e,t,n){let r=oR(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=aR(r,oR(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=rR.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return lR(n?cR(i):i)}function cR(e){let t=e.startState,n=!0;for(let r of t.facet(XL)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:iR(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=bL.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=rR.create(t,r,e.selection&&e.selection.map(i),X.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(ZL);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof rR?i:Array.isArray(i)&&i.length==1&&i[0]instanceof rR?i[0]:sR(t,dR(i),!1)}return e}function lR(e){let t=e.startState,n=t.facet(QL),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=aR(r,oR(t,a,e.changes.newLength),!0))}return r==e?e:rR.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var uR=[];function dR(e){return e==null?uR:Array.isArray(e)?e:[e]}var fR=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(fR||={}),pR=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,mR;try{mR=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function hR(e){if(mR)return mR.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||pR.test(n)))return!0}return!1}function gR(e){return t=>{if(!/\S/.test(t))return fR.Space;if(hR(t))return fR.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return fR.Word;return fR.Other}}var _R=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)GL(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return GL(this,n),KL(this,n)}update(...e){return sR(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(VL.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(X.reconfigure)?(n=null,r=e.value):e.is(X.appendConfig)&&(n=null,r=dR(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=UL.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(JL)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:J.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=dR(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=X.mapEffects(a,c).concat(X.mapEffects(dR(o.effects),l))}return{changes:r,selection:J.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof bL?t:bL.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return eL.of(t.split(this.facet(e.lineSeparator)||_L))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(GL(this,t),KL(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof IL&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:J.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=UL.resolve(t.extensions||[],new Map),r=t.doc instanceof eL?t.doc:eL.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||_L)),i=t.selection?t.selection instanceof J?t.selection:J.single(t.selection.anchor,t.selection.head):J.single(0);return OL(i,r.length),n.staticFacet(JL)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|