@deepagents/devtool 7.43.2 → 7.43.4

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.
@@ -3,7 +3,7 @@ import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./p
3
3
  `).map((e,t)=>(0,L.jsx)(Ri,{children:e},t)):t})})}var Li=tn(`relative -mx-3 block min-h-lh px-3 group-data-[size=sm]/code-block:-mx-2.5 group-data-[size=sm]/code-block:px-2.5 before:min-w-6 before:text-end before:text-muted-foreground after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3 in-data-numbered:[counter-increment:line] in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']`,{variants:{variant:{default:``,added:`bg-muted after:content-['+']`,removed:`bg-destructive/10 after:text-destructive after:content-['−']`,highlighted:`bg-muted`}},defaultVariants:{variant:`default`}});function Ri({className:e,variant:t=`default`,children:n,...r}){let i=n==null||n===``||Array.isArray(n)&&n.length===0;return(0,L.jsx)(`span`,{"data-slot":`code-block-line`,"data-variant":t,className:It(Li({variant:t}),e),...r,children:(0,L.jsx)(`span`,{"data-slot":`code-block-line-content`,className:`min-w-0`,children:i?`
4
4
  `:n})})}var zi={...Yr,...v},Bi=I.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=M(o),d=zr({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=I.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=I.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=tt(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:zi});return(0,L.jsx)(Br.Provider,{value:p,children:m})}),Vi={...Jr,...v},Hi=I.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=Vr(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=rt({disabled:c,native:u});return tt(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:Vi})}),Ui=`--collapsible-panel-height`,Wi=`--collapsible-panel-width`,Gi=I.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=Vr(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;mn(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:ee,width:te}=Zr({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),ne={...g,transitionStatus:ee},D=Sn(s,ne),re=tt(`div`,{...e,style:void 0},{state:ne,ref:w,props:[C,{style:{[Ui]:S===void 0?`auto`:`${S}px`,[Wi]:te===void 0?`auto`:`${te}px`}},c,D?{style:D}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:zi});return E?re:null});function Ki({...e}){return(0,L.jsx)(Bi,{"data-slot":`collapsible`,...e})}function qi({...e}){return(0,L.jsx)(Hi,{"data-slot":`collapsible-trigger`,...e})}function Ji({...e}){return(0,L.jsx)(Gi,{"data-slot":`collapsible-content`,...e})}var Yi=I.createContext(void 0);function Xi(e=!1){let t=I.useContext(Yi);if(!t&&!e)throw Error(Pe(86));return t}Object.keys(Re);function Zi(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var Qi=`data-composite-item-active`;function $i(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=Le}=e,[p,m]=I.useState(0),h=r!=null,g=I.useRef(null),_=vn(g,c),v=I.useRef([]),y=I.useRef(!1),b=I.useRef(null),x=o??p,S=M((e,t=!1)=>{if(b.current=v.current[e]??null,(s??m)(e),t){let t=v.current[e];He(g.current,t,a,n)}}),C=M(e=>{if(e.size===0)return;if(y.current){let e=v.current,t=e.indexOf(b.current);if(t===-1){let t=e[x];!t||ke(e,x,d)?S(ea(e,d)):b.current=t}else t!==x&&S(t);return}y.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)S(i);else if(ke(t,x,d)){let e=fe(t,{disabledIndices:d});$e(t,e)||S(e)}He(g.current,r,a,n)});mn(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(ke(e,x,d)){let t=fe(e,{disabledIndices:d});$e(e,t)||S(t)}},[d,o,x,v,S]);let w=M((e,t,n)=>i?i(e,t,n,v):n),T=M(e=>{let o=e.key===`Home`||e.key===`End`;if(!Me.has(e.key)||!l&&o||ta(e,f)||!g.current)return;let s=a===`rtl`,c=s?D:ce,p=s?ce:D,m=n===`vertical`?De:c,_=n===`vertical`?he:p,y=Dt(e.nativeEvent);if(y!=null&&A(y)&&!zt(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=x,C=ue(v,d),T=Zt(v,d);r!=null&&(b=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:x,loopFocus:t,maxIndex:T,minIndex:C,onLoop:w,orientation:n,rtl:s}));let E=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,ee=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=C:e.key===`End`&&(b=T)),b===x&&(E||ee)&&(t&&b===T&&E?(b=C,i&&(b=i(e,x,b,v))):t&&b===C&&ee?(b=T,i&&(b=i(e,x,b,v))):b=fe(v.current,{startingIndex:b,decrement:ee,disabledIndices:d})),b!==x&&!$e(v.current,b)&&(u&&e.stopPropagation(),(h||o||E||ee)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{v.current[b]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=Dt(e.nativeEvent);!t||n==null||!A(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:T},highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:v,onMapChange:C,relayKeyboardEvent:T}}function ea(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(!(!i||ke(e,r,t))){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function ta(e,t){for(let n of _)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function na(e){let{render:t,className:n,style:r,refs:i=Le,props:a=Le,state:o=E,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:b,highlightItemOnHover:x=!1,tag:S=`div`,...C}=e,{props:w,highlightedIndex:T,onHighlightedIndexChange:ee,elementsRef:te,onMapChange:ne,relayKeyboardEvent:D}=$i({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:yt(),disabledIndices:v,modifierKeys:b}),re=tt(S,e,{state:o,ref:i,props:[w,...a,C],stateAttributesMapping:s}),O=I.useMemo(()=>({highlightedIndex:T,onHighlightedIndexChange:ee,highlightItemOnHover:x,relayKeyboardEvent:D}),[T,ee,x,D]);return(0,L.jsx)(wn.Provider,{value:O,children:(0,L.jsx)(y,{elementsRef:te,onMapChange:e=>{h?.(e),ne(e)},children:re})})}var ra=`data-checked`,ia=`data-unchecked`,aa={checked(e){return e?{[ra]:``}:{[ia]:``}},...v,...ee},oa=I.createContext(void 0);function sa(){return I.useContext(oa)}var ca=I.createContext(void 0);function la(){let e=I.useContext(ca);if(e===void 0)throw Error(Pe(52));return e}var ua=I.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:f,style:p,...m}=e,h=sa(),{disabled:g,readOnly:_,required:v,form:y,checkedValue:x,touched:S=!1,validation:w,name:T,setCheckedValue:ee=C,setTouched:te=C,registerInputRef:ne=C}=h??{},{setTouched:D,setFilled:re,state:O,disabled:ie}=hn(),k=xi(),{labelId:A,getDescriptionProps:ae}=ct(),oe=ie||k.disabled||g||i,se=_||a,ce=v||o,le=y,j=h?x===c:c===``,ue=I.useRef(null),de=b(oe,ue),fe=I.useRef(null),pe=w?.registerInput,me=vn(l,fe,ne,I.useCallback(e=>pe?.(e,{controlRef:ue,value:void 0}),[pe]));mn(()=>{fe.current?.checked&&re(!0)},[re]),mn(()=>{if(fe.current){if(oe&&j){ne(null);return}ne(fe.current)}},[j,oe,ne]);let he=Kt(),ge=Cn({id:f}),_e=u?void 0:ge,ve={role:`radio`,"aria-checked":j,"aria-labelledby":Si(s,A,fe,!u,_e,m[`aria-label`]),[Qi]:j?``:void 0,id:u?ge:he,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||oe||se)return;e.preventDefault();let t=fe.current;t&&dn(t,e)},onFocus(e){de(!0),!(e.defaultPrevented||oe||se||!S)&&(fe.current?.click(),te(!1))},onBlur(){h||de(!1)}},{getButtonProps:ye,buttonRef:be}=rt({disabled:oe,native:u,composite:!1}),xe={type:`radio`,ref:me,form:le,id:_e,name:T,tabIndex:-1,style:T?ht:d,"aria-hidden":!0,...c===void 0?E:{value:nt(c)},disabled:oe,checked:j,required:ce,readOnly:se,onChange(e){if(e.nativeEvent.defaultPrevented||oe||se||c===void 0)return;let t=ft(Qt,e.nativeEvent);ee(c,t),!t.isCanceled&&D(!0)},onClick(e){e.stopPropagation()},onFocus(){ue.current?.focus()}},Se=I.useMemo(()=>({...O,required:ce,disabled:oe,readOnly:se,checked:j}),[O,oe,se,j,ce]),M=Se,Ce=h!==void 0,we=[t,ue,be],Te=[ve,m,ye,ae,w?e=>w.getValidationProps(oe,e):E],Ee=tt(`span`,e,{enabled:!Ce,state:Se,ref:we,props:Te,stateAttributesMapping:aa});return(0,L.jsxs)(ca.Provider,{value:M,children:[Ce?(0,L.jsx)(Ct,{tag:`span`,render:n,className:r,style:p,state:Se,refs:we,props:Te,stateAttributesMapping:aa}):Ee,(0,L.jsx)(`input`,{...xe,suppressHydrationWarning:!0})]})}),da=I.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=la(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Ye(c),f={...s,transitionStatus:u},p=I.useRef(null),m=a||l,h=tt(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:aa});return on({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null}),fa=[Ge],pa=I.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:m,style:h,...g}=e,{setTouched:_,setFocused:v,validationMode:y,name:b,disabled:x,state:S,validation:C,setDirty:w,setFilled:T,validityData:E}=hn(),{labelId:te}=ct(),{clearErrors:ne,elementRef:D}=yn(),re=Xi(!0),O=x||i,ie=b??d,k=Kt(m),[A,ae]=p({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[oe,se]=I.useState(!1),ce=M((e,t)=>{s?.(e,t),!t.isCanceled&&ae(e)}),le=C.getInputControl,j=I.useMemo(()=>({get current(){return le()}}),[le]),ue=I.useRef(null),de=I.useRef(null),fe=vn(ue,f),pe=I.useRef(fe),me=M(e=>{ue.current===e&&pe.current===fe||(pe.current=fe,fe?.(e))});mn(()=>{me(ue.current)},[fe,me]);let he=M(e=>{if(e){if(!e.disabled){de.current||=e;let t=ue.current;(e.checked||t==null||t.disabled)&&me(e)}return()=>{de.current===e&&(de.current=null),ue.current===e&&me(null)}}}),ge=M(()=>{let e=D.current;if(!e)return A??null;for(let t of C.registeredInputs.keys())if(t.checked&&Zi(t,e))return A??null;return null});Fe(j,k,A??null,ge,!O,d),xe(A,()=>{ne(ie),w(A!==E.initialValue),T(A!=null),C.change(A);let e=de.current;A==null&&e&&!e.disabled&&me(e)});let _e=te??re?.legendId,ve={...S,disabled:O??!1,required:o??!1,readOnly:a??!1},ye=I.useMemo(()=>({checkedValue:A,disabled:O,form:u,validation:C,name:ie,readOnly:a,registerInputRef:he,required:o,setCheckedValue:ce,setTouched:se,touched:oe}),[A,O,u,C,ie,a,he,o,ce,se,oe]),be={id:m,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":O||void 0,"aria-readonly":a||void 0,"aria-labelledby":_e,onBlur(e){$t(e.currentTarget,e.relatedTarget)||(se(!1),_(!0),v(!1),y===`onBlur`&&C.commit(A))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&se(!0)}};return(0,L.jsx)(oa.Provider,{value:ye,children:(0,L.jsx)(na,{render:n,className:r,style:h,state:ve,props:[be,g,e=>C.getValidationProps(O??!1,e)],refs:[t],stateAttributesMapping:ee,enableHomeAndEndKeys:!1,modifierKeys:fa})})}),ma=tn(`group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-2.5 px-3 py-2.5`,sm:`gap-2.5 px-3 py-2.5`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function eee({className:e,variant:t=`default`,size:n=`default`,render:r,...i}){return Nt({defaultTagName:`div`,props:ln({className:It(ma({variant:t,size:n,className:e}))},i),render:r,state:{slot:`item`,variant:t,size:n}})}var ha=tn(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function ga({className:e,variant:t=`default`,...n}){return(0,L.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:It(ha({variant:t,className:e})),...n})}function _a({className:e,...t}){return(0,L.jsx)(`div`,{"data-slot":`item-content`,className:It(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none`,e),...t})}function va({className:e,...t}){return(0,L.jsx)(`div`,{"data-slot":`item-title`,className:It(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function ya({className:e,...t}){return(0,L.jsx)(`p`,{"data-slot":`item-description`,className:It(`line-clamp-2 text-start text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function ba({className:e,...t}){return(0,L.jsx)(pa,{"data-slot":`radio-group`,className:It(`grid w-full gap-2`,e),...t})}function xa({className:e,...t}){return(0,L.jsx)(ua,{"data-slot":`radio-group-item`,className:It(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,L.jsx)(da,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`absolute top-1/2 start-1/2 size-2 -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})})})}function Sa({className:e,...t}){return(0,L.jsx)(be,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:It(`size-4 animate-spin`,e),...t})}var Ca=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function wa(e){return Ta(e)}function Ta(e){return Array.isArray(e)?Ea(e):e instanceof RegExp?e:typeof e==`object`?Da(e):e}function Ea(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Ta(e[n]);return t}function Da(e){let t={};for(let n in e)t[n]=Ta(e[n]);return t}function Oa(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function ka(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?ka(e.substring(0,e.length-1)):e.substr(~t+1)}var Aa=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,ja=class{static hasCaptures(e){return e===null?!1:(Aa.lastIndex=0,Aa.test(e))}static replaceCaptures(e,t,n){return e.replace(Aa,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function Ma(e,t){return e<t?-1:+(e>t)}function Na(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=Ma(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function Pa(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Fa(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var Ia=class{constructor(e){this.fn=e}fn;cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},La=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}_colorMap;_defaults;_root;static createFromRawTheme(e,t){return this.createFromParsedTheme(Ha(e),t)}static createFromParsedTheme(e,t){return Ga(e,t)}_cachedMatchRoot=new Ia(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>za(e.parent,t.parentScopes));return n?new Va(n.fontStyle,n.foreground,n.background):null}},Ra=class e{constructor(e,t){this.parent=e,this.scopeName=t}parent;scopeName;static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function za(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!Ba(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Ba(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var Va=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}fontStyle;foregroundId;backgroundId};function Ha(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&Pa(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&Pa(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new Ua(l,u,e,o,s,c)}}return n}var Ua=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}scope;parentScopes;index;fontStyle;foreground;background},Wa=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(Wa||{});function Ga(e,t){e.sort((e,t)=>{let n=Ma(e.scope,t.scope);return n!==0||(n=Na(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new Ka(t),o=new Va(n,a.getId(r),a.getId(i)),s=new Ya(new Ja(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new La(a,o,s)}var Ka=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},qa=Object.freeze([]),Ja=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||qa,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},Ya=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_mainRule;_children;_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),Ja.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(Na(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new Ja(e,t,n,r,i))}},Xa=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=Qa(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function Za(e){return e}function Qa(e){return e}function $a(e,t){let n=[],r=to(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(eo(i)){let e=[];do e.push(i),i=r.next();while(eo(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function eo(e){return!!e&&!!e.match(/[\w\.:]+/)}function to(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function no(e){typeof e.dispose==`function`&&e.dispose()}var ro=class{constructor(e){this.scopeName=e}scopeName;toKey(){return this.scopeName}},io=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;toKey(){return`${this.scopeName}#${this.ruleName}`}},ao=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},oo=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new ro(this.initialScopeName)]}repo;initialScopeName;seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new ao;for(let n of e)so(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof ro){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function so(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof ro?lo({baseGrammar:a,selfGrammar:i},r):co(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new ro(e))}function co(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];uo([r],t,n)}}function lo(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&uo(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&uo(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function uo(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?Oa({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&uo(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=_o(i);switch(a.kind){case 0:lo({...t,selfGrammar:t.baseGrammar},n);break;case 1:lo(t,n);break;case 2:co(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?co(a.ruleName,i,n):lo(i,n)}else a.kind===4?n.add(new io(a.scopeName,a.ruleName)):n.add(new ro(a.scopeName));break}}}var fo=class{kind=0},po=class{kind=1},mo=class{constructor(e){this.ruleName=e}ruleName;kind=2},ho=class{constructor(e){this.scopeName=e}scopeName;kind=3},go=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;kind=4};function _o(e){if(e===`$base`)return new fo;if(e===`$self`)return new po;let t=e.indexOf(`#`);return t===-1?new ho(e):t===0?new mo(e.substring(1)):new go(e.substring(0,t),e.substring(t+1))}var vo=/\\(\d+)/,yo=/\\(\d+)/g,bo=-1,xo=-2;function So(e){return e}function Co(e){return e}var wo=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=ja.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=ja.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${ka(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:ja.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:ja.replaceCaptures(this._contentName,e,t)}},To=class extends wo{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Eo=class extends wo{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new jo(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Mo,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Do=class extends wo{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Mo,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Oo=class extends wo{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new jo(i,this.id),this.beginCaptures=a,this._end=new jo(o||`￿`,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Mo;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},ko=class extends wo{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new jo(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new jo(o,xo),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Mo;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Mo,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||`￿`),this._cachedCompiledWhilePatterns}},Ao=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new To(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Eo(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=Oa({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new Do(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new ko(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new Oo(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=_o(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof Do||e instanceof Oo||e instanceof ko)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},jo=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=vo.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return yo.lastIndex=0,this.source.replace(yo,(e,t)=>Fa(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=`￿`,t[i+1]=`￿`,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=`￿`,t[i+1]=`G`,n[i+1]=`￿`,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Mo=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new No(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new No(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},No=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}regExps;rules;scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
5
5
  `)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Po=class{constructor(e,t){this.languageId=e,this.tokenType=t}languageId;tokenType},Fo=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new Po(e,8),this._embeddedLanguagesMatcher=new Io(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Po(0,0);_getBasicScopeAttributes=new Ia(e=>new Po(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Io=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>Fa(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&{}.VSCODE_TEXTMATE_DEBUG;var Lo=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}stack;stoppedEarly};function Ro(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=zo(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new Lo(i,!0);f()}return new Lo(i,!1);function f(){let o=Bo(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===bo){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),Go(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof Oo){let r=o;Go(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof ko){let r=o;Go(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(Go(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function zo(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof ko&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=Wo(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==xo){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),Go(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function Bo(e,t,n,r,i,a){let o=Vo(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=Ho(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function Vo(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=Uo(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function Ho(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=Uo(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function Uo(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function Wo(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function Go(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));Ro(e,p,n&&d.start===0,d.start,f,i,!1,0),no(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new Ko(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var Ko=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function qo(e,t,n,r,i,a,o,s){return new Zo(e,t,n,r,i,a,o,s)}function Jo(e,t,n,r,i){let a=$a(t,Yo),o=Ao.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function Yo(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(Xo(t[r],e))return n=r+1,!0;return!1})}function Xo(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var Zo=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new Fo(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=Qo(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=$a(e,Yo);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootScopeName;balancedBracketSelectors;_onigLib;_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)Jo(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&Jo(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(So(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[Co(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Qo(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=Ao.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===es.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=Xa.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?$o.createRootAndLookUpScopeName(a,r,this):$o.createRoot(`unknown`,r),t=new es(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
6
- `;let a=this.createOnigString(e),o=a.content.length,s=new ns(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=Ro(this,a,i,0,t,s,!0,r);return no(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function Qo(e,t){return e=wa(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var $o=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}parent;scopePath;tokenAttributes;static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=Ra.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new Ra(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new Ra(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),Xa.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},es=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}parent;ruleId;beginRuleCapturedEOL;endRule;nameScopesList;contentNameScopesList;_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?$o.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:Co(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=$o.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,So(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,$o.fromExtension(r,n.contentNameScopesList))}},ts=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):$a(e,Yo).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>$a(e,Yo).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},ns=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}balancedBracketSelectors;_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=Xa.set(n,0,Za(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=Xa.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},rs=class{constructor(e,t){this._onigLib=t,this._theme=e}_onigLib;_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,qo(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},is=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new rs(La.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(La.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new ts(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new oo(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},as=es.NULL;function ss(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function cs(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function ls(e){return Array.isArray(e)?e:[e]}async function us(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function ds(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function fs(e){return e===`ansi`||ds(e)}function ps(e){return e===`none`}function ms(e){return ps(e)}var hs=/(\r?\n)/g;function gs(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(hs),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var _s={light:`#333333`,dark:`#bbbbbb`},vs={light:`#fffffe`,dark:`#1e1e1e`},ys=`__shiki_resolved`;function bs(e){if(e?.[ys])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?_s.light:_s.dark,n||=t.type===`light`?vs.light:vs.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,ys,{enumerable:!1,writable:!1,value:!0}),t}async function xs(e){return[...new Set((await Promise.all(e.filter(e=>!fs(e)).map(async e=>await us(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function Ss(e){return(await Promise.all(e.map(async e=>ms(e)?null:bs(await us(e))))).filter(e=>!!e)}function Cs(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new Ca(`Circular alias \`${[...n].join(` -> `)} -> ${e}\``);n.add(e)}}return e}var ws=class extends is{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=bs(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=La.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Cs(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null;for(let e of t)this.reloadLanguage(e);if(e.injectTo){let t=[...this._langMap.values()].filter(t=>t!==e&&this._resolvedGrammars.has(t.name)&&e.injectTo.some(e=>t.scopeName===e||t.scopeName.startsWith(`${e}.`))&&!this.hasCurrentInjections(t.scopeName));for(let e of t)this.reloadLanguage(e)}}hasCurrentInjections(e){let t=this._syncRegistry?._injectionGrammars?.get(e)||[],n=this._resolver.getInjections(e)||[];return t.length===n.length&&t.every((e,t)=>e===n[t])}reloadLanguage(e){this._syncRegistry?._grammars?.get(e.scopeName)?.dispose(),this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._grammars?.delete(e.scopeName),this._syncRegistry?._injectionGrammars?.set(e.scopeName,this._resolver.getInjections(e.scopeName)||[]),this.loadLanguage(this._langMap.get(e.name)||e)}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=[...this._langGraph.entries()],n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new Ca(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},Ts=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).includes(e.scopeName)||this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},Es=0;function Ds(e){Es+=1,e.warnings!==!1&&Es>=10&&Es%10==0&&console.warn(`[Shiki] ${Es} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Ca("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(bs),i=new ws(new Ts(e.engine,n),r,n,e.langAlias),a;function o(t){return Cs(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new Ca(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new Ca(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await xs(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await Ss(e))}function g(){if(t)throw new Ca(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--Es)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function Os(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Ss(e.themes||[]),xs(e.langs||[]),e.engine]);return Ds({...e,themes:t,langs:n,engine:r})}var ks=new WeakMap;function As(e,t){ks.set(e,t)}function js(e){return ks.get(e)}var Ms=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(ls(n).map(e=>[e,as])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Ns(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Ns(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function Ps(e,t){if(!(e instanceof Ms))throw new Ca(`Invalid grammar state`);return e.getInternalStack(t)}var Fs=/,/,Is=/ /;function Ls(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(ds(e.resolveLangAlias(n.lang||`text`))||ps(r))return gs(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new Ca(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new Ca(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return zs(t,o,i,a,n)}function Rs(...e){if(e.length===2)return js(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(ds(i)||ps(a))throw new Ca(`Plain language does not have grammar state`);if(i===`ansi`)throw new Ca(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new Ms(Bs(n,c,o,s,r).stateStack,c.name,o.name)}function zs(e,t,n,r,i){let a=Bs(e,t,n,r,i),o=new Ms(a.stateStack,t.name,n.name);return As(a.tokens,o),a.tokens}function Bs(e,t,n,r,i){let a=ss(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500,includeExplanation:c=!1}=i,l=gs(e),u=i.grammarState?Ps(i.grammarState,n.name)??as:i.grammarContextCode==null?as:Bs(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,d=[],f=[];for(let e=0,i=l.length;e<i;e++){let[i,p]=l[e];if(i===``){d=[],f.push([]);continue}if(o>0&&i.length>=o){d=[],f.push([{content:i,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;c&&c!==`tokenType`&&(m=t.tokenizeLine(i,u,s),h=m.tokens,g=0);let _=t.tokenizeLine2(i,u,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:i.length;if(t===o)continue;let s=_.tokens[2*e+1],l=cs(r[Xa.getForeground(s)],a),u=Xa.getFontStyle(s),f={content:i.substring(t,o),offset:p+t,color:l,fontStyle:u};if(c===`tokenType`)f.type=Xa.getTokenType(s);else if(c){let e=[];if(c!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(Fs).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(Is))})}f.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=i.substring(t.startIndex,t.endIndex);r+=n.length,f.explanation.push({content:n,scopes:c===`scopeName`?Vs(t.scopes):Hs(e,t.scopes)}),g+=1}}d.push(f)}f.push(d),d=[],u=_.ruleStack}return{tokens:f,stateStack:u}}function Vs(e){return e.map(e=>({scopeName:e}))}function Hs(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:tee(e,i,t.slice(0,r))}}return n}function Us(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function Ws(e,t,n){if(!Us(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)Us(e[r],n[i])&&--r,--i;return r===-1}function tee(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(Ws(e,t,n)){r.push(a);break}return r}function Gs(e,t,n,r=Ls){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:js(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=Ks(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new Ms(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&As(s,c),s}function Ks(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}var qs=/["&'<>`]/g,Js=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ys=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Xs=/[|\\{}()[\]^$+*?.]/g,Zs=new WeakMap;function Qs(e,t){if(e=e.replace(t.subset?$s(t.subset):qs,r),t.subset||t.escapeOnly)return e;return e.replace(Js,n).replace(Ys,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function $s(e){let t=Zs.get(e);return t||(t=ec(e),Zs.set(e,t)),t}function ec(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(Xs,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var tc=/[\dA-Fa-f]/;function nc(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!tc.test(String.fromCharCode(t))?r:r+`;`}var rc=/\d/;function ic(e,t,n){let r=`&#`+String(e);return n&&t&&!rc.test(String.fromCharCode(t))?r:r+`;`}var ac=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),oc={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:`‌`,zwj:`‍`,lrm:`‎`,rlm:`‏`,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},sc=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],cc={}.hasOwnProperty,lc={},uc;for(uc in oc)cc.call(oc,uc)&&(lc[oc[uc]]=uc);var dc=/[^\dA-Za-z]/;function fc(e,t,n,r){let i=String.fromCharCode(e);if(cc.call(lc,i)){let e=lc[i],a=`&`+e;return n&&ac.includes(e)&&!sc.includes(e)&&(!r||t&&t!==61&&dc.test(String.fromCharCode(t)))?a:a+`;`}return``}function pc(e,t,n){let r=nc(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=fc(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=ic(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function mc(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function hc(e,t){return Qs(e,Object.assign({format:pc},t))}function gc(e,t){return Qs(e,Object.assign({format:mc},t))}var _c=/^>|^->|<!--|-->|--!>|<!-$/g,vc=[`>`],yc=[`<`,`>`];function bc(e,t,n,r){return r.settings.bogusComments?`<?`+hc(e.value,Object.assign({},r.settings.characterReferences,{subset:vc}))+`>`:`<!--`+e.value.replace(_c,i)+`-->`;function i(e){return hc(e,Object.assign({},r.settings.characterReferences,{subset:yc}))}}function xc(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}var Sc=Tc(1),Cc=Tc(-1),wc=[];function Tc(e){return t;function t(t,n,r){let i=t?t.children:wc,a=(n||0)+e,o=i[a];if(!r)for(;o&&Fn(o);)a+=e,o=i[a];return o}}var Ec={}.hasOwnProperty;function Dc(e){return t;function t(t,n,r){return Ec.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var Oc=Dc({body:jc,caption:kc,colgroup:kc,dd:Fc,dt:Pc,head:kc,html:Ac,li:Nc,optgroup:Lc,option:Rc,p:Mc,rp:Ic,rt:Ic,tbody:Bc,td:Uc,tfoot:Vc,th:Uc,thead:zc,tr:Hc});function kc(e,t,n){let r=Sc(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&Fn(r.value.charAt(0)))}function Ac(e,t,n){let r=Sc(n,t);return!r||r.type!==`comment`}function jc(e,t,n){let r=Sc(n,t);return!r||r.type!==`comment`}function Mc(e,t,n){let r=Sc(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||!(n.type===`element`&&(n.tagName===`a`||n.tagName===`audio`||n.tagName===`del`||n.tagName===`ins`||n.tagName===`map`||n.tagName===`noscript`||n.tagName===`video`||n.tagName.includes(`-`)))}function Nc(e,t,n){let r=Sc(n,t);return!r||r.type===`element`&&r.tagName===`li`}function Pc(e,t,n){let r=Sc(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function Fc(e,t,n){let r=Sc(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function Ic(e,t,n){let r=Sc(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function Lc(e,t,n){let r=Sc(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function Rc(e,t,n){let r=Sc(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function zc(e,t,n){let r=Sc(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function Bc(e,t,n){let r=Sc(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function Vc(e,t,n){return!Sc(n,t)}function Hc(e,t,n){let r=Sc(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function Uc(e,t,n){let r=Sc(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var Wc=Dc({body:qc,colgroup:Jc,head:Kc,html:Gc,tbody:Yc});function Gc(e){let t=Sc(e,-1);return!t||t.type!==`comment`}function Kc(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function qc(e){let t=Sc(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&Fn(t.value.charAt(0)))&&!(t.type===`element`&&(t.tagName===`meta`||t.tagName===`link`||t.tagName===`script`||t.tagName===`style`||t.tagName===`template`))}function Jc(e,t,n){let r=Cc(n,t);if(n&&r&&r.type===`element`&&r.tagName===`colgroup`&&Oc(r,n.children.indexOf(r),n))return!1;let i=Sc(e,-1,!0);return!!(i&&i.type===`element`&&i.tagName===`col`)}function Yc(e,t,n){let r=Cc(n,t);if(n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&Oc(r,n.children.indexOf(r),n))return!1;let i=Sc(e,-1);return!!(i&&i.type===`element`&&i.tagName===`tr`)}var Xc={name:[[`
6
+ `;let a=this.createOnigString(e),o=a.content.length,s=new ns(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=Ro(this,a,i,0,t,s,!0,r);return no(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function Qo(e,t){return e=wa(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var $o=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}parent;scopePath;tokenAttributes;static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=Ra.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new Ra(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new Ra(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),Xa.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},es=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}parent;ruleId;beginRuleCapturedEOL;endRule;nameScopesList;contentNameScopesList;_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?$o.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:Co(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=$o.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,So(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,$o.fromExtension(r,n.contentNameScopesList))}},ts=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):$a(e,Yo).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>$a(e,Yo).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},ns=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}balancedBracketSelectors;_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=Xa.set(n,0,Za(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=Xa.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},rs=class{constructor(e,t){this._onigLib=t,this._theme=e}_onigLib;_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,qo(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},is=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new rs(La.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(La.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new ts(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new oo(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},as=es.NULL;function ss(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function cs(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function ls(e){return Array.isArray(e)?e:[e]}async function us(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function ds(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function fs(e){return e===`ansi`||ds(e)}function ps(e){return e===`none`}function ms(e){return ps(e)}var hs=/(\r?\n)/g;function gs(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(hs),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var _s={light:`#333333`,dark:`#bbbbbb`},vs={light:`#fffffe`,dark:`#1e1e1e`},ys=`__shiki_resolved`;function bs(e){if(e?.[ys])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?_s.light:_s.dark,n||=t.type===`light`?vs.light:vs.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,ys,{enumerable:!1,writable:!1,value:!0}),t}async function xs(e){return[...new Set((await Promise.all(e.filter(e=>!fs(e)).map(async e=>await us(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function Ss(e){return(await Promise.all(e.map(async e=>ms(e)?null:bs(await us(e))))).filter(e=>!!e)}function Cs(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new Ca(`Circular alias \`${[...n].join(` -> `)} -> ${e}\``);n.add(e)}}return e}var ws=class extends is{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=bs(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=La.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Cs(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null;for(let e of t)this.reloadLanguage(e);if(e.injectTo){let t=[...this._langMap.values()].filter(t=>t!==e&&this._resolvedGrammars.has(t.name)&&e.injectTo.some(e=>t.scopeName===e||t.scopeName.startsWith(`${e}.`))&&!this.hasCurrentInjections(t.scopeName));for(let e of t)this.reloadLanguage(e)}}hasCurrentInjections(e){let t=this._syncRegistry?._injectionGrammars?.get(e)||[],n=this._resolver.getInjections(e)||[];return t.length===n.length&&t.every((e,t)=>e===n[t])}reloadLanguage(e){this._syncRegistry?._grammars?.get(e.scopeName)?.dispose(),this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._grammars?.delete(e.scopeName),this._syncRegistry?._injectionGrammars?.set(e.scopeName,this._resolver.getInjections(e.scopeName)||[]),this.loadLanguage(this._langMap.get(e.name)||e)}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=[...this._langGraph.entries()],n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new Ca(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},Ts=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).includes(e.scopeName)||this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},Es=0;function Ds(e){Es+=1,e.warnings!==!1&&Es>=10&&Es%10==0&&console.warn(`[Shiki] ${Es} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Ca("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(bs),i=new ws(new Ts(e.engine,n),r,n,e.langAlias),a;function o(t){return Cs(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new Ca(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new Ca(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await xs(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await Ss(e))}function g(){if(t)throw new Ca(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--Es)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function Os(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Ss(e.themes||[]),xs(e.langs||[]),e.engine]);return Ds({...e,themes:t,langs:n,engine:r})}var ks=new WeakMap;function As(e,t){ks.set(e,t)}function js(e){return ks.get(e)}var Ms=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(ls(n).map(e=>[e,as])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Ns(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Ns(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function Ps(e,t){if(!(e instanceof Ms))throw new Ca(`Invalid grammar state`);return e.getInternalStack(t)}var Fs=/,/,Is=/ /;function Ls(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(ds(e.resolveLangAlias(n.lang||`text`))||ps(r))return gs(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new Ca(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new Ca(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return zs(t,o,i,a,n)}function Rs(...e){if(e.length===2)return js(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(ds(i)||ps(a))throw new Ca(`Plain language does not have grammar state`);if(i===`ansi`)throw new Ca(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new Ms(Bs(n,c,o,s,r).stateStack,c.name,o.name)}function zs(e,t,n,r,i){let a=Bs(e,t,n,r,i),o=new Ms(a.stateStack,t.name,n.name);return As(a.tokens,o),a.tokens}function Bs(e,t,n,r,i){let a=ss(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500,includeExplanation:c=!1}=i,l=gs(e),u=i.grammarState?Ps(i.grammarState,n.name)??as:i.grammarContextCode==null?as:Bs(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,d=[],f=[];for(let e=0,i=l.length;e<i;e++){let[i,p]=l[e];if(i===``){d=[],f.push([]);continue}if(o>0&&i.length>=o){d=[],f.push([{content:i,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;c&&c!==`tokenType`&&(m=t.tokenizeLine(i,u,s),h=m.tokens,g=0);let _=t.tokenizeLine2(i,u,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:i.length;if(t===o)continue;let s=_.tokens[2*e+1],l=cs(r[Xa.getForeground(s)],a),u=Xa.getFontStyle(s),f={content:i.substring(t,o),offset:p+t,color:l,fontStyle:u};if(c===`tokenType`)f.type=Xa.getTokenType(s);else if(c){let e=[];if(c!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(Fs).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(Is))})}f.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=i.substring(t.startIndex,t.endIndex);r+=n.length,f.explanation.push({content:n,scopes:c===`scopeName`?Vs(t.scopes):Hs(e,t.scopes)}),g+=1}}d.push(f)}f.push(d),d=[],u=_.ruleStack}return{tokens:f,stateStack:u}}function Vs(e){return e.map(e=>({scopeName:e}))}function Hs(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:Gs(e,i,t.slice(0,r))}}return n}function Us(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function Ws(e,t,n){if(!Us(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)Us(e[r],n[i])&&--r,--i;return r===-1}function Gs(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(Ws(e,t,n)){r.push(a);break}return r}function Ks(e,t,n,r=Ls){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:js(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=qs(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new Ms(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&As(s,c),s}function qs(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}var Js=/["&'<>`]/g,Ys=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Xs=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Zs=/[|\\{}()[\]^$+*?.]/g,Qs=new WeakMap;function $s(e,t){if(e=e.replace(t.subset?ec(t.subset):Js,r),t.subset||t.escapeOnly)return e;return e.replace(Ys,n).replace(Xs,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function ec(e){let t=Qs.get(e);return t||(t=tc(e),Qs.set(e,t)),t}function tc(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(Zs,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var nc=/[\dA-Fa-f]/;function rc(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!nc.test(String.fromCharCode(t))?r:r+`;`}var ic=/\d/;function ac(e,t,n){let r=`&#`+String(e);return n&&t&&!ic.test(String.fromCharCode(t))?r:r+`;`}var oc=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),sc={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:`‌`,zwj:`‍`,lrm:`‎`,rlm:`‏`,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},cc=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],lc={}.hasOwnProperty,uc={},dc;for(dc in sc)lc.call(sc,dc)&&(uc[sc[dc]]=dc);var fc=/[^\dA-Za-z]/;function pc(e,t,n,r){let i=String.fromCharCode(e);if(lc.call(uc,i)){let e=uc[i],a=`&`+e;return n&&oc.includes(e)&&!cc.includes(e)&&(!r||t&&t!==61&&fc.test(String.fromCharCode(t)))?a:a+`;`}return``}function mc(e,t,n){let r=rc(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=pc(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=ac(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function hc(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function gc(e,t){return $s(e,Object.assign({format:mc},t))}function _c(e,t){return $s(e,Object.assign({format:hc},t))}var vc=/^>|^->|<!--|-->|--!>|<!-$/g,yc=[`>`],bc=[`<`,`>`];function xc(e,t,n,r){return r.settings.bogusComments?`<?`+gc(e.value,Object.assign({},r.settings.characterReferences,{subset:yc}))+`>`:`<!--`+e.value.replace(vc,i)+`-->`;function i(e){return gc(e,Object.assign({},r.settings.characterReferences,{subset:bc}))}}function Sc(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}var Cc=Ec(1),wc=Ec(-1),Tc=[];function Ec(e){return t;function t(t,n,r){let i=t?t.children:Tc,a=(n||0)+e,o=i[a];if(!r)for(;o&&Fn(o);)a+=e,o=i[a];return o}}var Dc={}.hasOwnProperty;function Oc(e){return t;function t(t,n,r){return Dc.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var kc=Oc({body:Mc,caption:Ac,colgroup:Ac,dd:Ic,dt:Fc,head:Ac,html:jc,li:Pc,optgroup:Rc,option:zc,p:Nc,rp:Lc,rt:Lc,tbody:Vc,td:Wc,tfoot:Hc,th:Wc,thead:Bc,tr:Uc});function Ac(e,t,n){let r=Cc(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&Fn(r.value.charAt(0)))}function jc(e,t,n){let r=Cc(n,t);return!r||r.type!==`comment`}function Mc(e,t,n){let r=Cc(n,t);return!r||r.type!==`comment`}function Nc(e,t,n){let r=Cc(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||!(n.type===`element`&&(n.tagName===`a`||n.tagName===`audio`||n.tagName===`del`||n.tagName===`ins`||n.tagName===`map`||n.tagName===`noscript`||n.tagName===`video`||n.tagName.includes(`-`)))}function Pc(e,t,n){let r=Cc(n,t);return!r||r.type===`element`&&r.tagName===`li`}function Fc(e,t,n){let r=Cc(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function Ic(e,t,n){let r=Cc(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function Lc(e,t,n){let r=Cc(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function Rc(e,t,n){let r=Cc(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function zc(e,t,n){let r=Cc(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function Bc(e,t,n){let r=Cc(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function Vc(e,t,n){let r=Cc(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function Hc(e,t,n){return!Cc(n,t)}function Uc(e,t,n){let r=Cc(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function Wc(e,t,n){let r=Cc(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var Gc=Oc({body:Jc,colgroup:Yc,head:qc,html:Kc,tbody:Xc});function Kc(e){let t=Cc(e,-1);return!t||t.type!==`comment`}function qc(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function Jc(e){let t=Cc(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&Fn(t.value.charAt(0)))&&!(t.type===`element`&&(t.tagName===`meta`||t.tagName===`link`||t.tagName===`script`||t.tagName===`style`||t.tagName===`template`))}function Yc(e,t,n){let r=wc(n,t);if(n&&r&&r.type===`element`&&r.tagName===`colgroup`&&kc(r,n.children.indexOf(r),n))return!1;let i=Cc(e,-1,!0);return!!(i&&i.type===`element`&&i.tagName===`col`)}function Xc(e,t,n){let r=wc(n,t);if(n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&kc(r,n.children.indexOf(r),n))return!1;let i=Cc(e,-1);return!!(i&&i.type===`element`&&i.tagName===`tr`)}var Zc={name:[[`
7
7
  \f\r &/=>`.split(``),`
8
8
  \f\r "&'/=>\``.split(``)],[`\0
9
9
  \f\r "&'/<=>`.split(``),`\0
@@ -11,10 +11,10 @@ import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./p
11
11
  \f\r &>`.split(``),`\0
12
12
  \f\r "&'<=>\``.split(``)],[`\0
13
13
  \f\r "&'<=>\``.split(``),`\0
14
- \f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]},Zc=new Set([`desc`,`foreignObject`,`title`]);function Qc(e,t,n,r){let{schema:i}=r,a=i.space!==`svg`&&r.settings.omitOptionalTags,o=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[];i.space===`html`&&e.tagName===`svg`&&(r.schema=In);let c=$c(r,e.properties);r.schema.space===`svg`&&Zc.has(e.tagName)&&(r.schema=Pn);let l=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);if(r.schema=i,l&&(o=!1),c||!a||!Wc(e,t,n)){if(s.push(`<`,e.tagName,c?` `+c:``),o&&(i.space===`svg`||r.settings.closeSelfClosing)){let e=c.charAt(c.length-1);(!r.settings.tightSelfClosing||e===`/`||e&&e!==`"`&&e!==`'`)&&s.push(` `),s.push(`/`)}s.push(`>`)}return s.push(l),!o&&(!a||!Oc(e,t,n))&&s.push(`</`+e.tagName+`>`),s.join(``)}function $c(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=el(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function el(e,t,n){let r=jn(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,a=+!e.settings.allowDangerousCharacters;if(r.overloadedBoolean&&(n===r.attribute||n===``)?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!=`string`||n===r.attribute||n===``)&&(n=!!n),n==null||n===!1||typeof n==`number`&&Number.isNaN(n))return``;let o=hc(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Xc.name[i][a]}));if(n===!0||(n=Array.isArray(n)?(r.commaSeparated?On:Jn)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n))return o;let s;if(e.settings.preferUnquoted&&(s=hc(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Xc.unquoted[i][a]}))),s!==n){let{quote:t}=e;e.settings.quoteSmart&&qn(n,t)>qn(n,e.alternative)&&(t=e.alternative),s=t+hc(n,Object.assign({},e.settings.characterReferences,{subset:(t===`'`?Xc.single:Xc.double)[i][a],attribute:!0}))+t}return o+(s&&`=`+s)}var tl=[`<`,`&`],nl=new Set([`iframe`,`noembed`,`noframes`,`plaintext`,`script`,`style`,`xmp`]);function rl(e,t,n,r){return n&&n.type===`element`&&r.schema.space===`html`&&nl.has(n.tagName)?e.value:hc(e.value,Object.assign({},r.settings.characterReferences,{subset:tl}))}function il(e,t,n,r){return r.settings.allowDangerousHtml?e.value:rl(e,t,n,r)}function al(e,t,n,r){return r.all(e)}var ol=Nn(`type`,{invalid:sl,unknown:cl,handlers:{comment:bc,doctype:xc,element:Qc,raw:il,root:al,text:rl}});function sl(e){throw Error("Expected node, not `"+e+"`")}function cl(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var ll={},ul={},dl=[];function fl(e,t){let n=t||ll,r=n.quote||`"`;if(r!==`"`&&r!==`'`)throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");let i=r===`"`?`'`:`"`;return{one:pl,all:ml,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Mn,characterReferences:n.characterReferences||ul,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space===`svg`?In:Pn,quote:r,alternative:i}.one(Array.isArray(e)?{type:`root`,children:e}:e,void 0,void 0)}function pl(e,t,n){return ol(e,t,n,this)}function ml(e){let t=[],n=e&&e.children||dl,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}var hl=/\s+/g;function gl(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(hl)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(hl);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function _l(e){let t=gs(e,!0),n=t.map(([e])=>e),r=t.map(([,e])=>e);function i(t){if(t===e.length)return{line:n.length-1,character:n.at(-1).length};let i=0,a=n.length-1;for(;i<a;){let e=i+a+1>>>1;r[e]<=t?i=e:a=e-1}return{line:i,character:t-r[i]}}function a(e,t){return r[e]+t}return{lines:n,indexToPos:i,posToIndex:a}}var vl=[`color`,`background-color`];function yl(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function bl(e,t){let n=0,r=e.length;for(;n<r;){let i=n+(r-n>>1);e[i]<=t?n=i+1:r=i}return n}function xl(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=e.offset+e.content.length,r=bl(n,e.offset),i=r;for(;i<n.length&&n[i]<t;)i++;if(r===i)return e;let a=n.slice(r,i);for(let t=0;t<a.length;t++)a[t]-=e.offset;return yl(e,a)})):e}function Sl(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>Cl(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&vl.includes(a))if(r===`light-dark()`&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new Ca('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let u=o[e][a]||`inherit`,d=o[r][a]||`inherit`;c[a]=`light-dark(${u}, ${d})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function Cl(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&Wa.Italic&&(t[`font-style`]=`italic`),e.fontStyle&Wa.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&Wa.Underline&&n.push(`underline`),e.fontStyle&Wa.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function wl(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function Tl(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=_l(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new Ca(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}else{let t=n.lines[e.line];if(t===void 0)throw new Ca(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new Ca(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));El(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return xl(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=[...e.children].filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new Ca(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=Ol(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new Ca(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new Ca(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&gl(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.push(()=>a(r,e));i(n.line,0,n.character,e)}}for(let e=s.length-1;e>=0;e--)s[e]()}}}function El(e){if(!Dl(e))for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new Ca(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new Ca(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function Dl(e){let t=[],n=new Map,r=new Map;for(let i=0;i<e.length;i++){let{start:a,end:o}=e[i];if(a.offset>o.offset)return!1;a.offset!==o.offset&&(t.push(e[i]),n.has(a.offset)||n.set(a.offset,i),r.set(o.offset,i))}for(let t=0;t<e.length;t++){let{start:i,end:a}=e[t];if(i.offset===a.offset&&((n.get(i.offset)??t)<t||(r.get(i.offset)??t)>t))return!1}t.sort((e,t)=>e.start.offset-t.start.offset||t.end.offset-e.end.offset);let i=[];for(let{start:e,end:n}of t){for(;i.length&&i.at(-1)<=e.offset;)i.pop();if(i.length&&n.offset>i.at(-1))return!1;i.push(n.offset)}return!0}function Ol(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(Ol).join(``):``}var kl=[Tl()];function Al(e){let t=jl(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...kl]}function jl(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var Ml=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],Nl={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function Pl(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function Fl(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}else if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function Il(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)Nl[r]&&t.push({type:`setDecoration`,value:Nl[r]});else if(r<=29){let e=Nl[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:Ml[r-30]}});else if(r===38){let n=Fl(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:Ml[r-40]}});else if(r===48){let n=Fl(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:Ml[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:Ml[r-100+8]}})}return t}function Ll(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=Pl(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=Il(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var Rl={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function zl(e=Rl){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<Ml.length;e++)r.push(t(Ml[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var Bl=/#([0-9a-f]{3,8})/i,Vl=/var\((--[\w-]+-ansi-[\w-]+)\)/,Hl={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function Ul(e,t,n){let r=ss(e,n),i=gs(t),a=zl(Object.fromEntries(Ml.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||Hl[t]]}))),o=Ll();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=cs(i,r),o=cs(o,r),n.decorations.has(`dim`)&&(i=Wl(i));let s=Wa.None;return n.decorations.has(`bold`)&&(s|=Wa.Bold),n.decorations.has(`italic`)&&(s|=Wa.Italic),n.decorations.has(`underline`)&&(s|=Wa.Underline),n.decorations.has(`strikethrough`)&&(s|=Wa.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function Wl(e){let t=e.match(Bl);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}else if(e.length===6)return`#${e}80`;else if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}else if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(Vl);return n?`var(${n[1]}-dim)`:e}function Gl(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!ds(r)&&!ps(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return Ul(r,t,n)}return Ls(e,t,n)}function Kl(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new Ca("`themes` option must not be empty");let p=Gs(e,t,n,Gl);if(c=js(p),l&&l!==`light-dark()`&&!f.some(e=>e.color===l))throw new Ca(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>Sl(e,h,u,l,d))),c&&As(a,c);let g=f.map(e=>ss(e.theme,n));i=ql(f,m,g,u,l,`fg`,d),r=ql(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=ss(n.theme,n);a=Gl(e,t,n);let l=e.getTheme(n.theme);r=cs(l.bg,s),i=cs(l.fg,s),o=l.name,c=js(a)}else throw new Ca("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function ql(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=cs(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===`light-dark()`&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new Ca('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${cs(t[r][a],n[r])||`inherit`}, ${cs(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}var Jl=/^\s+$/,Yl=/^(\s*)(.*?)(\s*)$/;function Xl(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>Xl(e,t,n),codeToTokens:(t,n)=>Kl(e,t,n)}){let i=t;for(let e of Al(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=Kl(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=Ql(a):d===`never`&&(a=$l(a)),f&&(a=eu(a));let p={...r,get source(){return i}};for(let e of Al(n))a=e.tokens?.call(p,a)||a;return Zl(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function Zl(e,t,n,r=js(e)){let i=Al(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(t.rootStyle==null?l.style=`background-color:${t.bg};color:${t.fg}`:l.style=t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:gl,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
15
- `}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=wl(a.htmlStyle||Cl(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&As(m,r),m}function Ql(e){return e.map(e=>{let t=[],n=``,r;return e.forEach((i,a)=>{let o=!(i.fontStyle&&(i.fontStyle&Wa.Underline||i.fontStyle&Wa.Strikethrough));o&&Jl.test(i.content)&&e[a+1]?(r===void 0&&(r=i.offset),n+=i.content):n?(o?t.push({...i,offset:r,content:n+i.content}):t.push({content:n,offset:r},i),r=void 0,n=``):t.push(i)}),t})}function $l(e){return e.map(e=>e.flatMap(e=>{if(Jl.test(e.content))return e;let t=e.content.match(Yl);if(!t)return e;let[,n,r,i]=t;if(!n&&!i)return e;let a=[{...e,offset:e.offset+n.length,content:r}];return n&&a.unshift({content:n,offset:e.offset}),i&&a.push({content:i,offset:e.offset+n.length+r.length}),a}))}function eu(e){return e.map(e=>{let t=[];for(let n of e){if(t.length===0){t.push({...n});continue}let e=t.at(-1),r=wl(e.htmlStyle||Cl(e)),i=wl(n.htmlStyle||Cl(n)),a=e.fontStyle&&(e.fontStyle&Wa.Underline||e.fontStyle&Wa.Strikethrough),o=n.fontStyle&&(n.fontStyle&Wa.Underline||n.fontStyle&Wa.Strikethrough);!a&&!o&&r===i?e.content+=n.content:t.push({...n})}return t})}var tu=fl;function nu(e,t,n){let r={meta:{},options:n,codeToHast:(t,n)=>Xl(e,t,n),codeToTokens:(t,n)=>Kl(e,t,n)},i=tu(Xl(e,t,n,r));for(let e of Al(n))i=e.postprocess?.call(r,i,n)||i;return i}async function ru(e){let t=await Os(e);return{getLastGrammarState:(...e)=>Rs(t,...e),codeToTokensBase:(e,n)=>Gl(t,e,n),codeToTokensWithThemes:(e,n)=>Gs(t,e,n),codeToTokens:(e,n)=>Kl(t,e,n),codeToHast:(e,n)=>Xl(t,e,n),codeToHtml:(e,n)=>nu(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}var iu=4294967295;function au(e){return!e.sticky&&!e.rawOptions?.strategy}function ou(e,t){return{index:e,captureIndices:t.map(e=>e==null?{start:iu,end:iu,length:0}:{start:e[0],end:e[1],length:e[1]-e[0]})}}var su=class{patterns;options;regexps;lastSearches;constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if(typeof e!=`string`)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}}),this.lastSearches=this.regexps.map(e=>e&&au(e)?{strId:0,searchedFrom:0,matchIndex:-1,indices:null}:null)}findNextMatchSync(e,t,n){let r=typeof e==`string`?e:e.content,i=typeof e==`string`?0:e.id||0,a=-1,o=0,s=null;for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{let c=i?this.lastSearches[e]:null,l,u;if(c&&c.strId===i&&c.searchedFrom<=t&&(c.matchIndex===-1||c.matchIndex>=t))l=c.matchIndex,u=c.indices;else{n.lastIndex=t;let e=n.exec(r);l=e?e.index:-1,u=e?e.indices:null,c&&(c.strId=i,c.searchedFrom=t,c.matchIndex=l,c.indices=u)}if(l===-1)continue;if(l===t)return ou(e,u);(a===-1||l<o)&&(a=e,o=l,s=u)}catch(e){if(this.options.forgiving)continue;throw e}}return a===-1?null:ou(a,s)}},cu=0;function lu(e){return{content:e,id:++cu}}function uu(e){if([...e].length!==1)throw Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function du(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var fu=new Set([`alnum`,`alpha`,`ascii`,`blank`,`cntrl`,`digit`,`graph`,`lower`,`print`,`punct`,`space`,`upper`,`word`,`xdigit`]),pu=String.raw;function mu(e,t){if(e==null)throw Error(t??`Value expected`);return e}var hu=pu`\[\^?`,gu=`c.? | C(?:-.?)?|${pu`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${pu`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${pu`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${pu`o\{[^\}]*\}?`}|${pu`\d{1,3}`}`,_u=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,vu=new RegExp(pu`
14
+ \f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]},Qc=new Set([`desc`,`foreignObject`,`title`]);function $c(e,t,n,r){let{schema:i}=r,a=i.space!==`svg`&&r.settings.omitOptionalTags,o=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[];i.space===`html`&&e.tagName===`svg`&&(r.schema=In);let c=el(r,e.properties);r.schema.space===`svg`&&Qc.has(e.tagName)&&(r.schema=Pn);let l=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);if(r.schema=i,l&&(o=!1),c||!a||!Gc(e,t,n)){if(s.push(`<`,e.tagName,c?` `+c:``),o&&(i.space===`svg`||r.settings.closeSelfClosing)){let e=c.charAt(c.length-1);(!r.settings.tightSelfClosing||e===`/`||e&&e!==`"`&&e!==`'`)&&s.push(` `),s.push(`/`)}s.push(`>`)}return s.push(l),!o&&(!a||!kc(e,t,n))&&s.push(`</`+e.tagName+`>`),s.join(``)}function el(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=tl(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function tl(e,t,n){let r=jn(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,a=+!e.settings.allowDangerousCharacters;if(r.overloadedBoolean&&(n===r.attribute||n===``)?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!=`string`||n===r.attribute||n===``)&&(n=!!n),n==null||n===!1||typeof n==`number`&&Number.isNaN(n))return``;let o=gc(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Zc.name[i][a]}));if(n===!0||(n=Array.isArray(n)?(r.commaSeparated?On:Jn)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n))return o;let s;if(e.settings.preferUnquoted&&(s=gc(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Zc.unquoted[i][a]}))),s!==n){let{quote:t}=e;e.settings.quoteSmart&&qn(n,t)>qn(n,e.alternative)&&(t=e.alternative),s=t+gc(n,Object.assign({},e.settings.characterReferences,{subset:(t===`'`?Zc.single:Zc.double)[i][a],attribute:!0}))+t}return o+(s&&`=`+s)}var nl=[`<`,`&`],rl=new Set([`iframe`,`noembed`,`noframes`,`plaintext`,`script`,`style`,`xmp`]);function il(e,t,n,r){return n&&n.type===`element`&&r.schema.space===`html`&&rl.has(n.tagName)?e.value:gc(e.value,Object.assign({},r.settings.characterReferences,{subset:nl}))}function al(e,t,n,r){return r.settings.allowDangerousHtml?e.value:il(e,t,n,r)}function ol(e,t,n,r){return r.all(e)}var sl=Nn(`type`,{invalid:cl,unknown:ll,handlers:{comment:xc,doctype:Sc,element:$c,raw:al,root:ol,text:il}});function cl(e){throw Error("Expected node, not `"+e+"`")}function ll(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var ul={},dl={},fl=[];function pl(e,t){let n=t||ul,r=n.quote||`"`;if(r!==`"`&&r!==`'`)throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");let i=r===`"`?`'`:`"`;return{one:ml,all:hl,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Mn,characterReferences:n.characterReferences||dl,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space===`svg`?In:Pn,quote:r,alternative:i}.one(Array.isArray(e)?{type:`root`,children:e}:e,void 0,void 0)}function ml(e,t,n){return sl(e,t,n,this)}function hl(e){let t=[],n=e&&e.children||fl,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}var gl=/\s+/g;function _l(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(gl)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(gl);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function vl(e){let t=gs(e,!0),n=t.map(([e])=>e),r=t.map(([,e])=>e);function i(t){if(t===e.length)return{line:n.length-1,character:n.at(-1).length};let i=0,a=n.length-1;for(;i<a;){let e=i+a+1>>>1;r[e]<=t?i=e:a=e-1}return{line:i,character:t-r[i]}}function a(e,t){return r[e]+t}return{lines:n,indexToPos:i,posToIndex:a}}var yl=[`color`,`background-color`];function bl(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function xl(e,t){let n=0,r=e.length;for(;n<r;){let i=n+(r-n>>1);e[i]<=t?n=i+1:r=i}return n}function Sl(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=e.offset+e.content.length,r=xl(n,e.offset),i=r;for(;i<n.length&&n[i]<t;)i++;if(r===i)return e;let a=n.slice(r,i);for(let t=0;t<a.length;t++)a[t]-=e.offset;return bl(e,a)})):e}function Cl(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>wl(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&yl.includes(a))if(r===`light-dark()`&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new Ca('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let u=o[e][a]||`inherit`,d=o[r][a]||`inherit`;c[a]=`light-dark(${u}, ${d})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function wl(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&Wa.Italic&&(t[`font-style`]=`italic`),e.fontStyle&Wa.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&Wa.Underline&&n.push(`underline`),e.fontStyle&Wa.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function Tl(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function El(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=vl(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new Ca(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}else{let t=n.lines[e.line];if(t===void 0)throw new Ca(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new Ca(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));Dl(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return Sl(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=[...e.children].filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new Ca(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=kl(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new Ca(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new Ca(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&_l(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.push(()=>a(r,e));i(n.line,0,n.character,e)}}for(let e=s.length-1;e>=0;e--)s[e]()}}}function Dl(e){if(!Ol(e))for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new Ca(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new Ca(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function Ol(e){let t=[],n=new Map,r=new Map;for(let i=0;i<e.length;i++){let{start:a,end:o}=e[i];if(a.offset>o.offset)return!1;a.offset!==o.offset&&(t.push(e[i]),n.has(a.offset)||n.set(a.offset,i),r.set(o.offset,i))}for(let t=0;t<e.length;t++){let{start:i,end:a}=e[t];if(i.offset===a.offset&&((n.get(i.offset)??t)<t||(r.get(i.offset)??t)>t))return!1}t.sort((e,t)=>e.start.offset-t.start.offset||t.end.offset-e.end.offset);let i=[];for(let{start:e,end:n}of t){for(;i.length&&i.at(-1)<=e.offset;)i.pop();if(i.length&&n.offset>i.at(-1))return!1;i.push(n.offset)}return!0}function kl(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(kl).join(``):``}var Al=[El()];function jl(e){let t=Ml(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Al]}function Ml(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var Nl=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],Pl={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function Fl(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function Il(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}else if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function Ll(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)Pl[r]&&t.push({type:`setDecoration`,value:Pl[r]});else if(r<=29){let e=Pl[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:Nl[r-30]}});else if(r===38){let n=Il(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:Nl[r-40]}});else if(r===48){let n=Il(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:Nl[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:Nl[r-100+8]}})}return t}function Rl(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=Fl(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=Ll(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var zl={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function Bl(e=zl){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<Nl.length;e++)r.push(t(Nl[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var Vl=/#([0-9a-f]{3,8})/i,Hl=/var\((--[\w-]+-ansi-[\w-]+)\)/,Ul={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function Wl(e,t,n){let r=ss(e,n),i=gs(t),a=Bl(Object.fromEntries(Nl.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||Ul[t]]}))),o=Rl();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=cs(i,r),o=cs(o,r),n.decorations.has(`dim`)&&(i=Gl(i));let s=Wa.None;return n.decorations.has(`bold`)&&(s|=Wa.Bold),n.decorations.has(`italic`)&&(s|=Wa.Italic),n.decorations.has(`underline`)&&(s|=Wa.Underline),n.decorations.has(`strikethrough`)&&(s|=Wa.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function Gl(e){let t=e.match(Vl);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}else if(e.length===6)return`#${e}80`;else if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}else if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(Hl);return n?`var(${n[1]}-dim)`:e}function Kl(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!ds(r)&&!ps(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return Wl(r,t,n)}return Ls(e,t,n)}function ql(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new Ca("`themes` option must not be empty");let p=Ks(e,t,n,Kl);if(c=js(p),l&&l!==`light-dark()`&&!f.some(e=>e.color===l))throw new Ca(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>Cl(e,h,u,l,d))),c&&As(a,c);let g=f.map(e=>ss(e.theme,n));i=Jl(f,m,g,u,l,`fg`,d),r=Jl(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=ss(n.theme,n);a=Kl(e,t,n);let l=e.getTheme(n.theme);r=cs(l.bg,s),i=cs(l.fg,s),o=l.name,c=js(a)}else throw new Ca("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function Jl(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=cs(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===`light-dark()`&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new Ca('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${cs(t[r][a],n[r])||`inherit`}, ${cs(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}var Yl=/^\s+$/,Xl=/^(\s*)(.*?)(\s*)$/;function Zl(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>Zl(e,t,n),codeToTokens:(t,n)=>ql(e,t,n)}){let i=t;for(let e of jl(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=ql(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=$l(a):d===`never`&&(a=eu(a)),f&&(a=tu(a));let p={...r,get source(){return i}};for(let e of jl(n))a=e.tokens?.call(p,a)||a;return Ql(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function Ql(e,t,n,r=js(e)){let i=jl(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(t.rootStyle==null?l.style=`background-color:${t.bg};color:${t.fg}`:l.style=t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:_l,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
15
+ `}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=Tl(a.htmlStyle||wl(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&As(m,r),m}function $l(e){return e.map(e=>{let t=[],n=``,r;return e.forEach((i,a)=>{let o=!(i.fontStyle&&(i.fontStyle&Wa.Underline||i.fontStyle&Wa.Strikethrough));o&&Yl.test(i.content)&&e[a+1]?(r===void 0&&(r=i.offset),n+=i.content):n?(o?t.push({...i,offset:r,content:n+i.content}):t.push({content:n,offset:r},i),r=void 0,n=``):t.push(i)}),t})}function eu(e){return e.map(e=>e.flatMap(e=>{if(Yl.test(e.content))return e;let t=e.content.match(Xl);if(!t)return e;let[,n,r,i]=t;if(!n&&!i)return e;let a=[{...e,offset:e.offset+n.length,content:r}];return n&&a.unshift({content:n,offset:e.offset}),i&&a.push({content:i,offset:e.offset+n.length+r.length}),a}))}function tu(e){return e.map(e=>{let t=[];for(let n of e){if(t.length===0){t.push({...n});continue}let e=t.at(-1),r=Tl(e.htmlStyle||wl(e)),i=Tl(n.htmlStyle||wl(n)),a=e.fontStyle&&(e.fontStyle&Wa.Underline||e.fontStyle&Wa.Strikethrough),o=n.fontStyle&&(n.fontStyle&Wa.Underline||n.fontStyle&Wa.Strikethrough);!a&&!o&&r===i?e.content+=n.content:t.push({...n})}return t})}var nu=pl;function ru(e,t,n){let r={meta:{},options:n,codeToHast:(t,n)=>Zl(e,t,n),codeToTokens:(t,n)=>ql(e,t,n)},i=nu(Zl(e,t,n,r));for(let e of jl(n))i=e.postprocess?.call(r,i,n)||i;return i}async function iu(e){let t=await Os(e);return{getLastGrammarState:(...e)=>Rs(t,...e),codeToTokensBase:(e,n)=>Kl(t,e,n),codeToTokensWithThemes:(e,n)=>Ks(t,e,n),codeToTokens:(e,n)=>ql(t,e,n),codeToHast:(e,n)=>Zl(t,e,n),codeToHtml:(e,n)=>ru(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}var au=4294967295;function ou(e){return!e.sticky&&!e.rawOptions?.strategy}function su(e,t){return{index:e,captureIndices:t.map(e=>e==null?{start:au,end:au,length:0}:{start:e[0],end:e[1],length:e[1]-e[0]})}}var cu=class{patterns;options;regexps;lastSearches;constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if(typeof e!=`string`)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}}),this.lastSearches=this.regexps.map(e=>e&&ou(e)?{strId:0,searchedFrom:0,matchIndex:-1,indices:null}:null)}findNextMatchSync(e,t,n){let r=typeof e==`string`?e:e.content,i=typeof e==`string`?0:e.id||0,a=-1,o=0,s=null;for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{let c=i?this.lastSearches[e]:null,l,u;if(c&&c.strId===i&&c.searchedFrom<=t&&(c.matchIndex===-1||c.matchIndex>=t))l=c.matchIndex,u=c.indices;else{n.lastIndex=t;let e=n.exec(r);l=e?e.index:-1,u=e?e.indices:null,c&&(c.strId=i,c.searchedFrom=t,c.matchIndex=l,c.indices=u)}if(l===-1)continue;if(l===t)return su(e,u);(a===-1||l<o)&&(a=e,o=l,s=u)}catch(e){if(this.options.forgiving)continue;throw e}}return a===-1?null:su(a,s)}},lu=0;function uu(e){return{content:e,id:++lu}}function du(e){if([...e].length!==1)throw Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function fu(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var pu=new Set([`alnum`,`alpha`,`ascii`,`blank`,`cntrl`,`digit`,`graph`,`lower`,`print`,`punct`,`space`,`upper`,`word`,`xdigit`]),mu=String.raw;function hu(e,t){if(e==null)throw Error(t??`Value expected`);return e}var gu=mu`\[\^?`,_u=`c.? | C(?:-.?)?|${mu`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${mu`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${mu`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${mu`o\{[^\}]*\}?`}|${mu`\d{1,3}`}`,vu=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,yu=new RegExp(mu`
16
16
  \\ (?:
17
- ${gu}
17
+ ${_u}
18
18
  | [gk]<[^>]*>?
19
19
  | [gk]'[^']*'?
20
20
  | .
@@ -31,20 +31,20 @@ import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./p
31
31
  )?
32
32
  | \*[^\)]*\)?
33
33
  )?
34
- | (?:${_u.source})+
35
- | ${hu}
34
+ | (?:${vu.source})+
35
+ | ${gu}
36
36
  | .
37
- `.replace(/\s+/g,``),`gsu`),yu=new RegExp(pu`
37
+ `.replace(/\s+/g,``),`gsu`),bu=new RegExp(mu`
38
38
  \\ (?:
39
- ${gu}
39
+ ${_u}
40
40
  | .
41
41
  )
42
42
  | \[:(?:\^?\p{Alpha}+|\^):\]
43
- | ${hu}
43
+ | ${gu}
44
44
  | &&
45
45
  | .
46
- `.replace(/\s+/g,``),`gsu`);function bu(e,t={}){let n={flags:``,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!=`string`)throw Error(`String expected as pattern`);let r=Xu(n.flags),i=[r.extended],a={captureGroup:n.rules.captureGroup,getCurrentModX(){return i.at(-1)},numOpenGroups:0,popModX(){i.pop()},pushModX(e){i.push(e)},replaceCurrentModX(e){i[i.length-1]=e},singleline:n.rules.singleline},o=[],s;for(vu.lastIndex=0;s=vu.exec(e);){let t=xu(a,e,s[0],vu.lastIndex);t.tokens?o.push(...t.tokens):t.token&&o.push(t.token),t.lastIndex!==void 0&&(vu.lastIndex=t.lastIndex)}let c=[],l=0;o.filter(e=>e.type===`GroupOpen`).forEach(e=>{e.kind===`capturing`?e.number=++l:e.raw===`(`&&c.push(e)}),l||c.forEach((e,t)=>{e.kind=`capturing`,e.number=t+1});let u=l||c.length;return{tokens:o.map(e=>e.type===`EscapedNumber`?Qu(e,u):e).flat(),flags:r}}function xu(e,t,n,r){let[i,a]=n;if(n===`[`||n===`[^`){let e=Su(t,n,r);return{tokens:e.tokens,lastIndex:e.lastIndex}}if(i===`\\`){if(`AbBGyYzZ`.includes(a))return{token:Eu(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:Bu(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:Du(n)}}if(a===`K`)return{token:Pu(`keep`,n)};if(a===`N`||a===`R`)return{token:Nu(`newline`,n,{negate:a===`N`})};if(a===`O`)return{token:Nu(`any`,n)};if(a===`X`)return{token:Nu(`text_segment`,n)};let e=wu(n,{inCharClass:!1});return Array.isArray(e)?{tokens:e}:{token:e}}if(i===`(`){if(a===`*`)return{token:Gu(n)};if(n===`(?{`)throw Error(`Unsupported callout "${n}"`);if(n.startsWith(`(?#`)){if(t[r]!==`)`)throw Error(`Unclosed comment group "(?#"`);return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:Wu(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n===`(`&&!e.captureGroup||n===`(?:`)return{token:Lu(`group`,n)};if(n===`(?>`)return{token:Lu(`atomic`,n)};if(n===`(?=`||n===`(?!`||n===`(?<=`||n===`(?<!`)return{token:Lu(n[2]===`<`?`lookbehind`:`lookahead`,n,{negate:n.endsWith(`!`)})};if(n===`(`&&e.captureGroup||n.startsWith(`(?<`)&&n.endsWith(`>`)||n.startsWith(`(?'`)&&n.endsWith(`'`))return{token:Lu(`capturing`,n,{...n!==`(`&&{name:n.slice(3,-1)}})};if(n.startsWith(`(?~`)){if(n===`(?~|`)throw Error(`Unsupported absence function kind "${n}"`);return{token:Lu(`absence_repeater`,n)}}throw Error(n===`(?(`?`Unsupported conditional "${n}"`:`Invalid or unsupported group option "${n}"`)}if(n===`)`){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw Error(`Unmatched ")"`);return{token:Iu(n)}}if(e.getCurrentModX()){if(n===`#`){let e=t.indexOf(`
47
- `,r);return{lastIndex:e===-1?t.length:e}}if(/^\s$/.test(n)){let e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}return n===`.`?{token:Nu(`dot`,n)}:n===`^`||n===`$`?{token:Eu(e.singleline?{"^":pu`\A`,$:pu`\Z`}[n]:n,n)}:n===`|`?{token:Tu(n)}:_u.test(n)?{tokens:$u(n)}:{token:Ou(uu(n),n)}}function Su(e,t,n){let r=[Mu(t[1]===`^`,t)],i=1,a;for(yu.lastIndex=n;a=yu.exec(e);){let e=a[0];if(e[0]===`[`&&e[1]!==`:`)i++,r.push(Mu(e[1]===`^`,e));else if(e===`]`){if(r.at(-1).type===`CharacterClassOpen`)r.push(Ou(93,e));else if(i--,r.push(ku(e)),!i)break}else{let t=Cu(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:yu.lastIndex||e.length}}function Cu(e){if(e[0]===`\\`)return wu(e,{inCharClass:!0});if(e[0]===`[`){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!fu.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return Nu(`posix`,e,{value:t.groups.name,negate:!!t.groups.negate})}return e===`-`?Au(e):e===`&&`?ju(e):Ou(uu(e),e)}function wu(e,{inCharClass:t}){let n=e[1];if(n===`c`||n===`C`)return Uu(e);if(`dDhHsSwW`.includes(n))return qu(e);if(e.startsWith(pu`\o{`))throw Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw Error(`Incomplete or invalid Unicode property "${e}"`);return Ju(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{let t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join(``);return Ou(uu(e),t)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n===`u`||n===`x`)return Ou(Zu(e),e);if(Hu.has(n))return Ou(Hu.get(n),e);if(/\d/.test(n))return Fu(t,e);if(e===`\\`)throw Error(pu`Incomplete escape "\"`);if(n===`M`)throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return Ou(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function Tu(e){return{type:`Alternator`,raw:e}}function Eu(e,t){return{type:`Assertion`,kind:e,raw:t}}function Du(e){return{type:`Backreference`,raw:e}}function Ou(e,t){return{type:`Character`,value:e,raw:t}}function ku(e){return{type:`CharacterClassClose`,raw:e}}function Au(e){return{type:`CharacterClassHyphen`,raw:e}}function ju(e){return{type:`CharacterClassIntersector`,raw:e}}function Mu(e,t){return{type:`CharacterClassOpen`,negate:e,raw:t}}function Nu(e,t,n={}){return{type:`CharacterSet`,kind:e,...n,raw:t}}function Pu(e,t,n={}){return e===`keep`?{type:`Directive`,kind:e,raw:t}:{type:`Directive`,kind:e,flags:mu(n.flags),raw:t}}function Fu(e,t){return{type:`EscapedNumber`,inCharClass:e,raw:t}}function Iu(e){return{type:`GroupClose`,raw:e}}function Lu(e,t,n={}){return{type:`GroupOpen`,kind:e,...n,raw:t}}function Ru(e,t,n,r){return{type:`NamedCallout`,kind:e,tag:t,arguments:n,raw:r}}function zu(e,t,n,r){return{type:`Quantifier`,kind:e,min:t,max:n,raw:r}}function Bu(e){return{type:`Subroutine`,raw:e}}var Vu=new Set([`COUNT`,`CMP`,`ERROR`,`FAIL`,`MAX`,`MISMATCH`,`SKIP`,`TOTAL_COUNT`]),Hu=new Map([[`a`,7],[`b`,8],[`e`,27],[`f`,12],[`n`,10],[`r`,13],[`t`,9],[`v`,11]]);function Uu(e){let t=e[1]===`c`?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return Ou(uu(t.toUpperCase())-64,e)}function Wu(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??=``;let i=(t.getCurrentModX()||n.includes(`x`))&&!r.includes(`x`),a=Yu(n),o=Yu(r),s={};if(a&&(s.enable=a),o&&(s.disable=o),e.endsWith(`)`))return t.replaceCurrentModX(i),Pu(`flags`,e,{flags:s});if(e.endsWith(`:`))return t.pushModX(i),t.numOpenGroups++,Lu(`group`,e,{...(a||o)&&{flags:s}});throw Error(`Unexpected flag modifier "${e}"`)}function Gu(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:i}=t.groups;if(!n)throw Error(`Invalid named callout "${e}"`);if(r===``)throw Error(`Named callout tag with empty value not allowed "${e}"`);let a=i?i.split(`,`).filter(e=>e!==``).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,s,c]=a,l=Vu.has(n)?n.toLowerCase():`custom`;switch(l){case`fail`:case`mismatch`:case`skip`:if(a.length>0)throw Error(`Named callout arguments not allowed "${a}"`);break;case`error`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(typeof o==`string`)throw Error(`Named callout argument must be a number "${o}"`);break;case`max`:if(!a.length||a.length>2)throw Error(`Named callout must have one or two arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(a.length===2&&(typeof s==`number`||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case`count`:case`total_count`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof o==`number`||!/^[<>X]$/.test(o)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case`cmp`:if(a.length!==3)throw Error(`Named callout must have three arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof s==`number`||!/^(?:[<>!=]=|[<>])$/.test(s))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof c==`string`&&!/^[A-Za-z_]\w*$/.test(c))throw Error(`Named callout argument three must be a tag or number "${c}"`);break;case`custom`:throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${l}"`)}return Ru(l,r??null,i?.split(`,`)??null,e)}function Ku(e){let t=null,n,r;if(e[0]===`{`){let{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+i>o||a&&+a>o)throw Error(`Quantifier value unsupported in Oniguruma`);if(n=+i,r=a===void 0?+i:a===``?1/0:+a,n>r&&(t=`possessive`,[n,r]=[r,n]),e.endsWith(`?`)){if(t===`possessive`)throw Error(`Unsupported possessive interval quantifier chain with "?"`);t=`lazy`}else t||=`greedy`}else n=+(e[0]===`+`),r=e[0]===`?`?1:1/0,t=e[1]===`+`?`possessive`:e[1]===`?`?`lazy`:`greedy`;return zu(t,n,r,e)}function qu(e){let t=e[1].toLowerCase();return Nu({d:`digit`,h:`hex`,s:`space`,w:`word`}[t],e,{negate:e[1]!==t})}function Ju(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Nu(`property`,e,{value:r,negate:t===`P`&&!n||t===`p`&&!!n})}function Yu(e){let t={};return e.includes(`i`)&&(t.ignoreCase=!0),e.includes(`m`)&&(t.dotAll=!0),e.includes(`x`)&&(t.extended=!0),Object.keys(t).length?t:null}function Xu(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!`imxDPSWy`.includes(r))throw Error(`Invalid flag "${r}"`);if(r===`y`){if(!/^y{[gw]}/.test(e.slice(n)))throw Error(`Invalid or unspecified flag "y" mode`);t.textSegmentMode=e[n+2]===`g`?`grapheme`:`word`,n+=3;continue}t[{i:`ignoreCase`,m:`dotAll`,x:`extended`,D:`digitIsAscii`,P:`posixIsAscii`,S:`spaceIsAscii`,W:`wordIsAscii`}[r]]=!0}return t}function Zu(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw Error(`Incomplete or invalid escape "${e}"`);let t=e[2]===`{`?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Qu(e,t){let{raw:n,inCharClass:r}=e,i=n.slice(1);if(!r&&(i!==`0`&&i.length===1||i[0]!==`0`&&+i<=t))return[Du(n)];let a=[],o=i.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){let t=o[e],r;if(e===0&&t!==`8`&&t!==`9`){if(r=parseInt(t,8),r>127)throw Error(pu`Octal encoded byte above 177 unsupported "${n}"`)}else r=uu(t);a.push(Ou(r,(e===0?`\\`:``)+t))}return a}function $u(e){let t=[],n=new RegExp(_u,`gy`),r;for(;r=n.exec(e);){let e=r[0];if(e[0]===`{`){let r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){let{min:i,max:a}=r.groups;if(+i>+a&&e.endsWith(`?`)){n.lastIndex--,t.push(Ku(e.slice(0,-1)));continue}}}t.push(Ku(e))}return t}function ed(e,t){if(!Array.isArray(e.body))throw Error(`Expected node with body array`);if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}function td(e){return nd.has(e.type)}var nd=new Set([`AbsenceFunction`,`Backreference`,`CapturingGroup`,`Character`,`CharacterClass`,`CharacterSet`,`Group`,`Quantifier`,`Subroutine`]);function rd(e,t={}){let n={flags:``,normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=bu(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(e,t)=>{let n=r.tokens[a.nextIndex];switch(a.parent=e,a.nextIndex++,n.type){case`Alternator`:return pd();case`Assertion`:return id(n);case`Backreference`:return ad(n,a);case`Character`:return _d(n.value,{useLastValid:!!t.isCheckingRangeEnd});case`CharacterClassHyphen`:return od(n,a,t);case`CharacterClassOpen`:return sd(n,a,t);case`CharacterSet`:return cd(n,a);case`Directive`:return xd(n.kind,{flags:n.flags});case`GroupOpen`:return ld(n,a,t);case`NamedCallout`:return Td(n.kind,n.tag,n.arguments);case`Quantifier`:return ud(n,a);case`Subroutine`:return dd(n,a);default:throw Error(`Unexpected token type "${n.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},o=Od(Sd(r.flags)),s=o.body[0];for(;a.nextIndex<r.tokens.length;){let e=i(s,{});e.type===`Alternative`?(o.body.push(e),s=e):s.body.push(e)}let{capturingGroups:c,hasNumberedRef:l,namedGroupsByName:u,subroutines:d}=a;if(l&&u.size&&!n.rules.captureGroup)throw Error(`Numbered backref/subroutine not allowed when using named capture`);for(let{ref:e}of d)if(typeof e==`number`){if(e>c.length)throw Error(`Subroutine uses a group number that's not defined`);e&&(c[e-1].isSubroutined=!0)}else if(u.has(e)){if(u.get(e).length>1)throw Error(pu`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}else throw Error(pu`Subroutine uses a group name that's not defined "\g<${e}>"`);return o}function id({kind:e}){return md(mu({"^":`line_start`,$:`line_end`,"\\A":`string_start`,"\\b":`word_boundary`,"\\B":`word_boundary`,"\\G":`search_start`,"\\y":`text_segment_boundary`,"\\Y":`text_segment_boundary`,"\\z":`string_end`,"\\Z":`string_end_newline`}[e],`Unexpected assertion kind "${e}"`),{negate:e===pu`\B`||e===pu`\Y`})}function ad({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(n,r=!1)=>{let i=t.capturingGroups.length,a=!1;if(n>i)if(t.skipBackrefValidation)a=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,hd(r?i+1-n:n,{orphan:a})};if(n){let n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return i(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw Error(`Group name not defined to the left "${e}"`);return hd(r)}return i(+r)}function od(e,t,n){let{tokens:r,walk:i}=t,a=t.parent,o=a.body.at(-1),s=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!==`CharacterClass`&&o.type!==`CharacterClassRange`&&s&&s.type!==`CharacterClassOpen`&&s.type!==`CharacterClassClose`&&s.type!==`CharacterClassIntersector`){let e=i(a,{...n,isCheckingRangeEnd:!0});if(o.type===`Character`&&e.type===`Character`)return a.body.pop(),yd(o,e);throw Error(`Invalid character class range`)}return _d(uu(`-`))}function sd({negate:e},t,n){let{tokens:r,walk:i}=t,a=[vd()],o=r[t.nextIndex],s=zd(o);for(;s.type!==`CharacterClassClose`;){if(s.type===`CharacterClassIntersector`)a.push(vd()),t.nextIndex++;else{let e=a.at(-1);e.body.push(i(e,n))}s=zd(r[t.nextIndex],o)}let c=vd({negate:e});return a.length===1?c.body=a[0].body:(c.kind=`intersection`,c.body=a.map(e=>e.body.length===1?e.body[0]:e)),t.nextIndex++,c}function cd({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o}=r;if(e===`property`){let r=Rd(n);if(fu.has(r)&&!o?.has(r))e=`posix`,n=r;else return Ad(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o})}return e===`posix`?Ed(n,{negate:t}):bd(e,{negate:t})}function ld(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:a,skipLookbehindValidation:o,walk:s}=t,c=jd(e),l=c.type===`AbsenceFunction`,u=Fd(c),d=u&&c.negate;if(c.type===`CapturingGroup`&&(i.push(c),c.name&&du(a,c.name,[]).push(c)),l&&n.isInAbsenceFunction)throw Error(`Nested absence function not supported by Oniguruma`);let f=Bd(r[t.nextIndex]);for(;f.type!==`GroupClose`;){if(f.type===`Alternator`)c.body.push(pd()),t.nextIndex++;else{let e=c.body.at(-1),t=s(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(e.body.push(t),(u||n.isInLookbehind)&&!o){let e=`Lookbehind includes a pattern not allowed by Oniguruma`;if(d||n.isInNegLookbehind){if(Pd(t)||t.type===`CapturingGroup`)throw Error(e)}else if(Pd(t)||Fd(t)&&t.negate)throw Error(e)}}f=Bd(r[t.nextIndex])}return t.nextIndex++,c}function ud({kind:e,min:t,max:n},r){let i=r.parent,a=i.body.at(-1);if(!a||!td(a))throw Error(`Quantifier requires a repeatable token`);let o=Dd(e,t,n,a);return i.body.pop(),o}function dd({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){let e=+a.groups.num,r=n.length;if(t.hasNumberedRef=!0,i={"":e,"+":r+e,"-":r+1-e}[a.groups.sign],i<1)throw Error(`Invalid subroutine number`)}else i===`0`&&(i=0);let o=kd(i);return r.push(o),o}function fd(e,t){if(e!==`repeater`)throw Error(`Unexpected absence function kind "${e}"`);return{type:`AbsenceFunction`,kind:e,body:Md(t?.body)}}function pd(e){return{type:`Alternative`,body:Nd(e?.body)}}function md(e,t){let n={type:`Assertion`,kind:e};return(e===`word_boundary`||e===`text_segment_boundary`)&&(n.negate=!!t?.negate),n}function hd(e,t){let n=!!t?.orphan;return{type:`Backreference`,ref:e,...n&&{orphan:n}}}function gd(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!Id(n.name))throw Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:`CapturingGroup`,number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Md(t?.body)}}function _d(e,t){let n={useLastValid:!1,...t};if(e>1114111){let t=e.toString(16);if(n.useLastValid)e=1114111;else throw Error(e>1310719?`Invalid code point out of range "\\x{${t}}"`:`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:`Character`,value:e}}function vd(e){let t={kind:`union`,negate:!1,...e};return{type:`CharacterClass`,kind:t.kind,negate:t.negate,body:Nd(e?.body)}}function yd(e,t){if(t.value<e.value)throw Error(`Character class range out of order`);return{type:`CharacterClassRange`,min:e,max:t}}function bd(e,t){let n=!!t?.negate,r={type:`CharacterSet`,kind:e};return(e===`digit`||e===`hex`||e===`newline`||e===`space`||e===`word`)&&(r.negate=n),(e===`text_segment`||e===`newline`&&!n)&&(r.variableLength=!0),r}function xd(e,t={}){if(e===`keep`)return{type:`Directive`,kind:e};if(e===`flags`)return{type:`Directive`,kind:e,flags:mu(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function Sd(e){return{type:`Flags`,...e}}function Cd(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw Error(`Atomic group cannot have flags`);return{type:`Group`,...t&&{atomic:t},...n&&{flags:n},body:Md(e?.body)}}function wd(e){let t={behind:!1,negate:!1,...e};return{type:`LookaroundAssertion`,kind:t.behind?`lookbehind`:`lookahead`,negate:t.negate,body:Md(e?.body)}}function Td(e,t,n){return{type:`NamedCallout`,kind:e,tag:t,arguments:n}}function Ed(e,t){let n=!!t?.negate;if(!fu.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:`CharacterSet`,kind:`posix`,value:e,negate:n}}function Dd(e,t,n,r){if(t>n)throw Error(`Invalid reversed quantifier range`);return{type:`Quantifier`,kind:e,min:t,max:n,body:r}}function Od(e,t){return{type:`Regex`,body:Md(t?.body),flags:e}}function kd(e){return{type:`Subroutine`,ref:e}}function Ad(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(Rd(e));if(!r){if(n.normalizeUnknownPropertyNames)r=Ld(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(pu`Invalid Unicode property "\p{${e}}"`)}return{type:`CharacterSet`,kind:`property`,value:r??e,negate:n.negate}}function jd({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case`absence_repeater`:return fd(`repeater`);case`atomic`:return Cd({atomic:!0});case`capturing`:return gd(i,{name:n});case`group`:return Cd({flags:e});case`lookahead`:case`lookbehind`:return wd({behind:t===`lookbehind`,negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function Md(e){if(e===void 0)e=[pd()];else if(!Array.isArray(e)||!e.length||!e.every(e=>e.type===`Alternative`))throw Error(`Invalid body; expected array of one or more Alternative nodes`);return e}function Nd(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw Error(`Invalid body; expected array of nodes`);return e}function Pd(e){return e.type===`LookaroundAssertion`&&e.kind===`lookahead`}function Fd(e){return e.type===`LookaroundAssertion`&&e.kind===`lookbehind`}function Id(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function Ld(e){return e.trim().replace(/[- _]+/g,`_`).replace(/[A-Z][a-z]+(?=[A-Z])/g,`$&_`).replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function Rd(e){return e.replace(/[- _]+/g,``).toLowerCase()}function zd(e,t){let n=t;return mu(e,`Unclosed character class${n?.type===`Character`&&n.value===93&&n.raw===`]`?` (started with "]")`:``}`)}function Bd(e){return mu(e,`Unclosed group`)}function Vd(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){let r=i(e[n],t,n,e);n=Math.max(-1,n+r)}}function i(a,o=null,s=null,c=null){let l=0,u=!1,d={node:a,parent:o,key:s,container:c,root:e,remove(){Hd(c).splice(Math.max(0,Ud(s)+l),1),l--,u=!0},removeAllNextSiblings(){return Hd(c).splice(Ud(s)+1)},removeAllPrevSiblings(){let e=Ud(s)+l;return l-=e,Hd(c).splice(0,Math.max(0,e))},replaceWith(e,t={}){let n=!!t.traverse;c?c[Math.max(0,Ud(s)+l)]=e:mu(o,`Can't replace root node`)[s]=e,n&&i(e,o,s,c),u=!0},replaceWithMultiple(e,t={}){let n=!!t.traverse;if(Hd(c).splice(Math.max(0,Ud(s)+l),1,...e),l+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=i(e[n],o,Ud(s)+n+t,c)}u=!0},skip(){u=!0}},{type:f}=a,p=t[`*`],m=t[f],h=typeof p==`function`?p:p?.enter,g=typeof m==`function`?m:m?.enter;if(h?.(d,n),g?.(d,n),!u)switch(f){case`AbsenceFunction`:case`Alternative`:case`CapturingGroup`:case`CharacterClass`:case`Group`:case`LookaroundAssertion`:r(a.body,a);break;case`Assertion`:case`Backreference`:case`Character`:case`CharacterSet`:case`Directive`:case`Flags`:case`NamedCallout`:case`Subroutine`:break;case`CharacterClassRange`:i(a.min,a,`min`),i(a.max,a,`max`);break;case`Quantifier`:i(a.body,a,`body`);break;case`Regex`:r(a.body,a),i(a.flags,a,`flags`);break;default:throw Error(`Unexpected node type "${f}"`)}return m?.exit?.(d,n),p?.exit?.(d,n),l}return i(e),e}function Hd(e){if(!Array.isArray(e))throw Error(`Container expected`);return e}function Ud(e){if(typeof e!=`number`)throw Error(`Numeric key expected`);return e}var Wd=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Gd(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Kd(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var qd=Object.freeze({DEFAULT:`DEFAULT`,CHAR_CLASS:`CHAR_CLASS`});function Jd(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,`gsu`),a=[!1],o=0,s=``;for(let t of e.matchAll(i)){let{0:e,groups:{$skip:i}}=t;if(!i&&(!r||r===qd.DEFAULT==!o)){n instanceof Function?s+=n(t,{context:o?qd.CHAR_CLASS:qd.DEFAULT,negated:a[a.length-1]}):s+=n;continue}e[0]===`[`?(o++,a.push(e[1]===`^`)):e===`]`&&o&&(o--,a.pop()),s+=e}return s}function Yd(e,t,n,r){Jd(e,t,n,r)}function Xd(e,t,n=0,r){if(!new RegExp(t,`su`).test(e))return null;let i=RegExp(`${t}|(?<$skip>\\\\?.)`,`gsu`);i.lastIndex=n;let a=0,o;for(;o=i.exec(e);){let{0:e,groups:{$skip:t}}=o;if(!t&&(!r||r===qd.DEFAULT==!a))return o;e===`[`?a++:e===`]`&&a&&a--,i.lastIndex==o.index&&i.lastIndex++}return null}function Zd(e,t,n){return!!Xd(e,t,0,n)}function Qd(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,a=1,o;for(;o=n.exec(e);){let[e]=o;if(e===`[`)i++;else if(i)e===`]`&&i--;else if(e===`(`)a++;else if(e===`)`&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var $d=new RegExp(String.raw`(?<noncapturingStart>${Wd})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,`gsu`);function ef(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i=[0],a=[],o=0,s=0,c=NaN,l;do{l=!1;let t=0,u=0,d=!1,f;for($d.lastIndex=Number.isNaN(c)?0:c+7;f=$d.exec(e);){let{0:p,index:m,groups:{capturingStart:h,noncapturingStart:g}}=f;if(p===`[`)t++;else if(t)p===`]`&&t--;else if(p===`(?>`&&!d)c=m,d=!0;else if(d&&g)u++;else if(h)d?u++:(o++,i.push(o+s));else if(p===`)`&&d){if(!u){s++;let t=o+s;if(e=`${e.slice(0,c)}(?:(?=(${e.slice(c+3,m)}))<$$${t}>)${e.slice(m+1)}`,l=!0,a.push(t),Gd(n,t),r.size){let e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}u--}}}while(l);return n.push(...a),e=Jd(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){let n=+t;if(n>i.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},qd.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var tf=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,nf=new RegExp(String.raw`
46
+ `.replace(/\s+/g,``),`gsu`);function xu(e,t={}){let n={flags:``,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!=`string`)throw Error(`String expected as pattern`);let r=Zu(n.flags),i=[r.extended],a={captureGroup:n.rules.captureGroup,getCurrentModX(){return i.at(-1)},numOpenGroups:0,popModX(){i.pop()},pushModX(e){i.push(e)},replaceCurrentModX(e){i[i.length-1]=e},singleline:n.rules.singleline},o=[],s;for(yu.lastIndex=0;s=yu.exec(e);){let t=Su(a,e,s[0],yu.lastIndex);t.tokens?o.push(...t.tokens):t.token&&o.push(t.token),t.lastIndex!==void 0&&(yu.lastIndex=t.lastIndex)}let c=[],l=0;o.filter(e=>e.type===`GroupOpen`).forEach(e=>{e.kind===`capturing`?e.number=++l:e.raw===`(`&&c.push(e)}),l||c.forEach((e,t)=>{e.kind=`capturing`,e.number=t+1});let u=l||c.length;return{tokens:o.map(e=>e.type===`EscapedNumber`?$u(e,u):e).flat(),flags:r}}function Su(e,t,n,r){let[i,a]=n;if(n===`[`||n===`[^`){let e=Cu(t,n,r);return{tokens:e.tokens,lastIndex:e.lastIndex}}if(i===`\\`){if(`AbBGyYzZ`.includes(a))return{token:Du(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:Vu(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:Ou(n)}}if(a===`K`)return{token:Fu(`keep`,n)};if(a===`N`||a===`R`)return{token:Pu(`newline`,n,{negate:a===`N`})};if(a===`O`)return{token:Pu(`any`,n)};if(a===`X`)return{token:Pu(`text_segment`,n)};let e=Tu(n,{inCharClass:!1});return Array.isArray(e)?{tokens:e}:{token:e}}if(i===`(`){if(a===`*`)return{token:Ku(n)};if(n===`(?{`)throw Error(`Unsupported callout "${n}"`);if(n.startsWith(`(?#`)){if(t[r]!==`)`)throw Error(`Unclosed comment group "(?#"`);return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:Gu(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n===`(`&&!e.captureGroup||n===`(?:`)return{token:Ru(`group`,n)};if(n===`(?>`)return{token:Ru(`atomic`,n)};if(n===`(?=`||n===`(?!`||n===`(?<=`||n===`(?<!`)return{token:Ru(n[2]===`<`?`lookbehind`:`lookahead`,n,{negate:n.endsWith(`!`)})};if(n===`(`&&e.captureGroup||n.startsWith(`(?<`)&&n.endsWith(`>`)||n.startsWith(`(?'`)&&n.endsWith(`'`))return{token:Ru(`capturing`,n,{...n!==`(`&&{name:n.slice(3,-1)}})};if(n.startsWith(`(?~`)){if(n===`(?~|`)throw Error(`Unsupported absence function kind "${n}"`);return{token:Ru(`absence_repeater`,n)}}throw Error(n===`(?(`?`Unsupported conditional "${n}"`:`Invalid or unsupported group option "${n}"`)}if(n===`)`){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw Error(`Unmatched ")"`);return{token:Lu(n)}}if(e.getCurrentModX()){if(n===`#`){let e=t.indexOf(`
47
+ `,r);return{lastIndex:e===-1?t.length:e}}if(/^\s$/.test(n)){let e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}return n===`.`?{token:Pu(`dot`,n)}:n===`^`||n===`$`?{token:Du(e.singleline?{"^":mu`\A`,$:mu`\Z`}[n]:n,n)}:n===`|`?{token:Eu(n)}:vu.test(n)?{tokens:ed(n)}:{token:ku(du(n),n)}}function Cu(e,t,n){let r=[Nu(t[1]===`^`,t)],i=1,a;for(bu.lastIndex=n;a=bu.exec(e);){let e=a[0];if(e[0]===`[`&&e[1]!==`:`)i++,r.push(Nu(e[1]===`^`,e));else if(e===`]`){if(r.at(-1).type===`CharacterClassOpen`)r.push(ku(93,e));else if(i--,r.push(Au(e)),!i)break}else{let t=wu(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:bu.lastIndex||e.length}}function wu(e){if(e[0]===`\\`)return Tu(e,{inCharClass:!0});if(e[0]===`[`){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!pu.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return Pu(`posix`,e,{value:t.groups.name,negate:!!t.groups.negate})}return e===`-`?ju(e):e===`&&`?Mu(e):ku(du(e),e)}function Tu(e,{inCharClass:t}){let n=e[1];if(n===`c`||n===`C`)return Wu(e);if(`dDhHsSwW`.includes(n))return Ju(e);if(e.startsWith(mu`\o{`))throw Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw Error(`Incomplete or invalid Unicode property "${e}"`);return Yu(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{let t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join(``);return ku(du(e),t)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n===`u`||n===`x`)return ku(Qu(e),e);if(Uu.has(n))return ku(Uu.get(n),e);if(/\d/.test(n))return Iu(t,e);if(e===`\\`)throw Error(mu`Incomplete escape "\"`);if(n===`M`)throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return ku(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function Eu(e){return{type:`Alternator`,raw:e}}function Du(e,t){return{type:`Assertion`,kind:e,raw:t}}function Ou(e){return{type:`Backreference`,raw:e}}function ku(e,t){return{type:`Character`,value:e,raw:t}}function Au(e){return{type:`CharacterClassClose`,raw:e}}function ju(e){return{type:`CharacterClassHyphen`,raw:e}}function Mu(e){return{type:`CharacterClassIntersector`,raw:e}}function Nu(e,t){return{type:`CharacterClassOpen`,negate:e,raw:t}}function Pu(e,t,n={}){return{type:`CharacterSet`,kind:e,...n,raw:t}}function Fu(e,t,n={}){return e===`keep`?{type:`Directive`,kind:e,raw:t}:{type:`Directive`,kind:e,flags:hu(n.flags),raw:t}}function Iu(e,t){return{type:`EscapedNumber`,inCharClass:e,raw:t}}function Lu(e){return{type:`GroupClose`,raw:e}}function Ru(e,t,n={}){return{type:`GroupOpen`,kind:e,...n,raw:t}}function zu(e,t,n,r){return{type:`NamedCallout`,kind:e,tag:t,arguments:n,raw:r}}function Bu(e,t,n,r){return{type:`Quantifier`,kind:e,min:t,max:n,raw:r}}function Vu(e){return{type:`Subroutine`,raw:e}}var Hu=new Set([`COUNT`,`CMP`,`ERROR`,`FAIL`,`MAX`,`MISMATCH`,`SKIP`,`TOTAL_COUNT`]),Uu=new Map([[`a`,7],[`b`,8],[`e`,27],[`f`,12],[`n`,10],[`r`,13],[`t`,9],[`v`,11]]);function Wu(e){let t=e[1]===`c`?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return ku(du(t.toUpperCase())-64,e)}function Gu(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??=``;let i=(t.getCurrentModX()||n.includes(`x`))&&!r.includes(`x`),a=Xu(n),o=Xu(r),s={};if(a&&(s.enable=a),o&&(s.disable=o),e.endsWith(`)`))return t.replaceCurrentModX(i),Fu(`flags`,e,{flags:s});if(e.endsWith(`:`))return t.pushModX(i),t.numOpenGroups++,Ru(`group`,e,{...(a||o)&&{flags:s}});throw Error(`Unexpected flag modifier "${e}"`)}function Ku(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:i}=t.groups;if(!n)throw Error(`Invalid named callout "${e}"`);if(r===``)throw Error(`Named callout tag with empty value not allowed "${e}"`);let a=i?i.split(`,`).filter(e=>e!==``).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,s,c]=a,l=Hu.has(n)?n.toLowerCase():`custom`;switch(l){case`fail`:case`mismatch`:case`skip`:if(a.length>0)throw Error(`Named callout arguments not allowed "${a}"`);break;case`error`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(typeof o==`string`)throw Error(`Named callout argument must be a number "${o}"`);break;case`max`:if(!a.length||a.length>2)throw Error(`Named callout must have one or two arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(a.length===2&&(typeof s==`number`||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case`count`:case`total_count`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof o==`number`||!/^[<>X]$/.test(o)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case`cmp`:if(a.length!==3)throw Error(`Named callout must have three arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof s==`number`||!/^(?:[<>!=]=|[<>])$/.test(s))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof c==`string`&&!/^[A-Za-z_]\w*$/.test(c))throw Error(`Named callout argument three must be a tag or number "${c}"`);break;case`custom`:throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${l}"`)}return zu(l,r??null,i?.split(`,`)??null,e)}function qu(e){let t=null,n,r;if(e[0]===`{`){let{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+i>o||a&&+a>o)throw Error(`Quantifier value unsupported in Oniguruma`);if(n=+i,r=a===void 0?+i:a===``?1/0:+a,n>r&&(t=`possessive`,[n,r]=[r,n]),e.endsWith(`?`)){if(t===`possessive`)throw Error(`Unsupported possessive interval quantifier chain with "?"`);t=`lazy`}else t||=`greedy`}else n=+(e[0]===`+`),r=e[0]===`?`?1:1/0,t=e[1]===`+`?`possessive`:e[1]===`?`?`lazy`:`greedy`;return Bu(t,n,r,e)}function Ju(e){let t=e[1].toLowerCase();return Pu({d:`digit`,h:`hex`,s:`space`,w:`word`}[t],e,{negate:e[1]!==t})}function Yu(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Pu(`property`,e,{value:r,negate:t===`P`&&!n||t===`p`&&!!n})}function Xu(e){let t={};return e.includes(`i`)&&(t.ignoreCase=!0),e.includes(`m`)&&(t.dotAll=!0),e.includes(`x`)&&(t.extended=!0),Object.keys(t).length?t:null}function Zu(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!`imxDPSWy`.includes(r))throw Error(`Invalid flag "${r}"`);if(r===`y`){if(!/^y{[gw]}/.test(e.slice(n)))throw Error(`Invalid or unspecified flag "y" mode`);t.textSegmentMode=e[n+2]===`g`?`grapheme`:`word`,n+=3;continue}t[{i:`ignoreCase`,m:`dotAll`,x:`extended`,D:`digitIsAscii`,P:`posixIsAscii`,S:`spaceIsAscii`,W:`wordIsAscii`}[r]]=!0}return t}function Qu(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw Error(`Incomplete or invalid escape "${e}"`);let t=e[2]===`{`?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function $u(e,t){let{raw:n,inCharClass:r}=e,i=n.slice(1);if(!r&&(i!==`0`&&i.length===1||i[0]!==`0`&&+i<=t))return[Ou(n)];let a=[],o=i.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){let t=o[e],r;if(e===0&&t!==`8`&&t!==`9`){if(r=parseInt(t,8),r>127)throw Error(mu`Octal encoded byte above 177 unsupported "${n}"`)}else r=du(t);a.push(ku(r,(e===0?`\\`:``)+t))}return a}function ed(e){let t=[],n=new RegExp(vu,`gy`),r;for(;r=n.exec(e);){let e=r[0];if(e[0]===`{`){let r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){let{min:i,max:a}=r.groups;if(+i>+a&&e.endsWith(`?`)){n.lastIndex--,t.push(qu(e.slice(0,-1)));continue}}}t.push(qu(e))}return t}function td(e,t){if(!Array.isArray(e.body))throw Error(`Expected node with body array`);if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}function nd(e){return rd.has(e.type)}var rd=new Set([`AbsenceFunction`,`Backreference`,`CapturingGroup`,`Character`,`CharacterClass`,`CharacterSet`,`Group`,`Quantifier`,`Subroutine`]);function id(e,t={}){let n={flags:``,normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=xu(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(e,t)=>{let n=r.tokens[a.nextIndex];switch(a.parent=e,a.nextIndex++,n.type){case`Alternator`:return md();case`Assertion`:return ad(n);case`Backreference`:return od(n,a);case`Character`:return vd(n.value,{useLastValid:!!t.isCheckingRangeEnd});case`CharacterClassHyphen`:return sd(n,a,t);case`CharacterClassOpen`:return cd(n,a,t);case`CharacterSet`:return ld(n,a);case`Directive`:return Sd(n.kind,{flags:n.flags});case`GroupOpen`:return ud(n,a,t);case`NamedCallout`:return Ed(n.kind,n.tag,n.arguments);case`Quantifier`:return dd(n,a);case`Subroutine`:return fd(n,a);default:throw Error(`Unexpected token type "${n.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},o=kd(Cd(r.flags)),s=o.body[0];for(;a.nextIndex<r.tokens.length;){let e=i(s,{});e.type===`Alternative`?(o.body.push(e),s=e):s.body.push(e)}let{capturingGroups:c,hasNumberedRef:l,namedGroupsByName:u,subroutines:d}=a;if(l&&u.size&&!n.rules.captureGroup)throw Error(`Numbered backref/subroutine not allowed when using named capture`);for(let{ref:e}of d)if(typeof e==`number`){if(e>c.length)throw Error(`Subroutine uses a group number that's not defined`);e&&(c[e-1].isSubroutined=!0)}else if(u.has(e)){if(u.get(e).length>1)throw Error(mu`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}else throw Error(mu`Subroutine uses a group name that's not defined "\g<${e}>"`);return o}function ad({kind:e}){return hd(hu({"^":`line_start`,$:`line_end`,"\\A":`string_start`,"\\b":`word_boundary`,"\\B":`word_boundary`,"\\G":`search_start`,"\\y":`text_segment_boundary`,"\\Y":`text_segment_boundary`,"\\z":`string_end`,"\\Z":`string_end_newline`}[e],`Unexpected assertion kind "${e}"`),{negate:e===mu`\B`||e===mu`\Y`})}function od({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(n,r=!1)=>{let i=t.capturingGroups.length,a=!1;if(n>i)if(t.skipBackrefValidation)a=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,gd(r?i+1-n:n,{orphan:a})};if(n){let n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return i(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw Error(`Group name not defined to the left "${e}"`);return gd(r)}return i(+r)}function sd(e,t,n){let{tokens:r,walk:i}=t,a=t.parent,o=a.body.at(-1),s=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!==`CharacterClass`&&o.type!==`CharacterClassRange`&&s&&s.type!==`CharacterClassOpen`&&s.type!==`CharacterClassClose`&&s.type!==`CharacterClassIntersector`){let e=i(a,{...n,isCheckingRangeEnd:!0});if(o.type===`Character`&&e.type===`Character`)return a.body.pop(),bd(o,e);throw Error(`Invalid character class range`)}return vd(du(`-`))}function cd({negate:e},t,n){let{tokens:r,walk:i}=t,a=[yd()],o=r[t.nextIndex],s=Bd(o);for(;s.type!==`CharacterClassClose`;){if(s.type===`CharacterClassIntersector`)a.push(yd()),t.nextIndex++;else{let e=a.at(-1);e.body.push(i(e,n))}s=Bd(r[t.nextIndex],o)}let c=yd({negate:e});return a.length===1?c.body=a[0].body:(c.kind=`intersection`,c.body=a.map(e=>e.body.length===1?e.body[0]:e)),t.nextIndex++,c}function ld({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o}=r;if(e===`property`){let r=zd(n);if(pu.has(r)&&!o?.has(r))e=`posix`,n=r;else return jd(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o})}return e===`posix`?Dd(n,{negate:t}):xd(e,{negate:t})}function ud(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:a,skipLookbehindValidation:o,walk:s}=t,c=Md(e),l=c.type===`AbsenceFunction`,u=Id(c),d=u&&c.negate;if(c.type===`CapturingGroup`&&(i.push(c),c.name&&fu(a,c.name,[]).push(c)),l&&n.isInAbsenceFunction)throw Error(`Nested absence function not supported by Oniguruma`);let f=Vd(r[t.nextIndex]);for(;f.type!==`GroupClose`;){if(f.type===`Alternator`)c.body.push(md()),t.nextIndex++;else{let e=c.body.at(-1),t=s(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(e.body.push(t),(u||n.isInLookbehind)&&!o){let e=`Lookbehind includes a pattern not allowed by Oniguruma`;if(d||n.isInNegLookbehind){if(Fd(t)||t.type===`CapturingGroup`)throw Error(e)}else if(Fd(t)||Id(t)&&t.negate)throw Error(e)}}f=Vd(r[t.nextIndex])}return t.nextIndex++,c}function dd({kind:e,min:t,max:n},r){let i=r.parent,a=i.body.at(-1);if(!a||!nd(a))throw Error(`Quantifier requires a repeatable token`);let o=Od(e,t,n,a);return i.body.pop(),o}function fd({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){let e=+a.groups.num,r=n.length;if(t.hasNumberedRef=!0,i={"":e,"+":r+e,"-":r+1-e}[a.groups.sign],i<1)throw Error(`Invalid subroutine number`)}else i===`0`&&(i=0);let o=Ad(i);return r.push(o),o}function pd(e,t){if(e!==`repeater`)throw Error(`Unexpected absence function kind "${e}"`);return{type:`AbsenceFunction`,kind:e,body:Nd(t?.body)}}function md(e){return{type:`Alternative`,body:Pd(e?.body)}}function hd(e,t){let n={type:`Assertion`,kind:e};return(e===`word_boundary`||e===`text_segment_boundary`)&&(n.negate=!!t?.negate),n}function gd(e,t){let n=!!t?.orphan;return{type:`Backreference`,ref:e,...n&&{orphan:n}}}function _d(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!Ld(n.name))throw Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:`CapturingGroup`,number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Nd(t?.body)}}function vd(e,t){let n={useLastValid:!1,...t};if(e>1114111){let t=e.toString(16);if(n.useLastValid)e=1114111;else throw Error(e>1310719?`Invalid code point out of range "\\x{${t}}"`:`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:`Character`,value:e}}function yd(e){let t={kind:`union`,negate:!1,...e};return{type:`CharacterClass`,kind:t.kind,negate:t.negate,body:Pd(e?.body)}}function bd(e,t){if(t.value<e.value)throw Error(`Character class range out of order`);return{type:`CharacterClassRange`,min:e,max:t}}function xd(e,t){let n=!!t?.negate,r={type:`CharacterSet`,kind:e};return(e===`digit`||e===`hex`||e===`newline`||e===`space`||e===`word`)&&(r.negate=n),(e===`text_segment`||e===`newline`&&!n)&&(r.variableLength=!0),r}function Sd(e,t={}){if(e===`keep`)return{type:`Directive`,kind:e};if(e===`flags`)return{type:`Directive`,kind:e,flags:hu(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function Cd(e){return{type:`Flags`,...e}}function wd(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw Error(`Atomic group cannot have flags`);return{type:`Group`,...t&&{atomic:t},...n&&{flags:n},body:Nd(e?.body)}}function Td(e){let t={behind:!1,negate:!1,...e};return{type:`LookaroundAssertion`,kind:t.behind?`lookbehind`:`lookahead`,negate:t.negate,body:Nd(e?.body)}}function Ed(e,t,n){return{type:`NamedCallout`,kind:e,tag:t,arguments:n}}function Dd(e,t){let n=!!t?.negate;if(!pu.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:`CharacterSet`,kind:`posix`,value:e,negate:n}}function Od(e,t,n,r){if(t>n)throw Error(`Invalid reversed quantifier range`);return{type:`Quantifier`,kind:e,min:t,max:n,body:r}}function kd(e,t){return{type:`Regex`,body:Nd(t?.body),flags:e}}function Ad(e){return{type:`Subroutine`,ref:e}}function jd(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(zd(e));if(!r){if(n.normalizeUnknownPropertyNames)r=Rd(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(mu`Invalid Unicode property "\p{${e}}"`)}return{type:`CharacterSet`,kind:`property`,value:r??e,negate:n.negate}}function Md({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case`absence_repeater`:return pd(`repeater`);case`atomic`:return wd({atomic:!0});case`capturing`:return _d(i,{name:n});case`group`:return wd({flags:e});case`lookahead`:case`lookbehind`:return Td({behind:t===`lookbehind`,negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function Nd(e){if(e===void 0)e=[md()];else if(!Array.isArray(e)||!e.length||!e.every(e=>e.type===`Alternative`))throw Error(`Invalid body; expected array of one or more Alternative nodes`);return e}function Pd(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw Error(`Invalid body; expected array of nodes`);return e}function Fd(e){return e.type===`LookaroundAssertion`&&e.kind===`lookahead`}function Id(e){return e.type===`LookaroundAssertion`&&e.kind===`lookbehind`}function Ld(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function Rd(e){return e.trim().replace(/[- _]+/g,`_`).replace(/[A-Z][a-z]+(?=[A-Z])/g,`$&_`).replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function zd(e){return e.replace(/[- _]+/g,``).toLowerCase()}function Bd(e,t){let n=t;return hu(e,`Unclosed character class${n?.type===`Character`&&n.value===93&&n.raw===`]`?` (started with "]")`:``}`)}function Vd(e){return hu(e,`Unclosed group`)}function Hd(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){let r=i(e[n],t,n,e);n=Math.max(-1,n+r)}}function i(a,o=null,s=null,c=null){let l=0,u=!1,d={node:a,parent:o,key:s,container:c,root:e,remove(){Ud(c).splice(Math.max(0,Wd(s)+l),1),l--,u=!0},removeAllNextSiblings(){return Ud(c).splice(Wd(s)+1)},removeAllPrevSiblings(){let e=Wd(s)+l;return l-=e,Ud(c).splice(0,Math.max(0,e))},replaceWith(e,t={}){let n=!!t.traverse;c?c[Math.max(0,Wd(s)+l)]=e:hu(o,`Can't replace root node`)[s]=e,n&&i(e,o,s,c),u=!0},replaceWithMultiple(e,t={}){let n=!!t.traverse;if(Ud(c).splice(Math.max(0,Wd(s)+l),1,...e),l+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=i(e[n],o,Wd(s)+n+t,c)}u=!0},skip(){u=!0}},{type:f}=a,p=t[`*`],m=t[f],h=typeof p==`function`?p:p?.enter,g=typeof m==`function`?m:m?.enter;if(h?.(d,n),g?.(d,n),!u)switch(f){case`AbsenceFunction`:case`Alternative`:case`CapturingGroup`:case`CharacterClass`:case`Group`:case`LookaroundAssertion`:r(a.body,a);break;case`Assertion`:case`Backreference`:case`Character`:case`CharacterSet`:case`Directive`:case`Flags`:case`NamedCallout`:case`Subroutine`:break;case`CharacterClassRange`:i(a.min,a,`min`),i(a.max,a,`max`);break;case`Quantifier`:i(a.body,a,`body`);break;case`Regex`:r(a.body,a),i(a.flags,a,`flags`);break;default:throw Error(`Unexpected node type "${f}"`)}return m?.exit?.(d,n),p?.exit?.(d,n),l}return i(e),e}function Ud(e){if(!Array.isArray(e))throw Error(`Container expected`);return e}function Wd(e){if(typeof e!=`number`)throw Error(`Numeric key expected`);return e}var Gd=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Kd(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function qd(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var Jd=Object.freeze({DEFAULT:`DEFAULT`,CHAR_CLASS:`CHAR_CLASS`});function Yd(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,`gsu`),a=[!1],o=0,s=``;for(let t of e.matchAll(i)){let{0:e,groups:{$skip:i}}=t;if(!i&&(!r||r===Jd.DEFAULT==!o)){n instanceof Function?s+=n(t,{context:o?Jd.CHAR_CLASS:Jd.DEFAULT,negated:a[a.length-1]}):s+=n;continue}e[0]===`[`?(o++,a.push(e[1]===`^`)):e===`]`&&o&&(o--,a.pop()),s+=e}return s}function Xd(e,t,n,r){Yd(e,t,n,r)}function Zd(e,t,n=0,r){if(!new RegExp(t,`su`).test(e))return null;let i=RegExp(`${t}|(?<$skip>\\\\?.)`,`gsu`);i.lastIndex=n;let a=0,o;for(;o=i.exec(e);){let{0:e,groups:{$skip:t}}=o;if(!t&&(!r||r===Jd.DEFAULT==!a))return o;e===`[`?a++:e===`]`&&a&&a--,i.lastIndex==o.index&&i.lastIndex++}return null}function Qd(e,t,n){return!!Zd(e,t,0,n)}function $d(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,a=1,o;for(;o=n.exec(e);){let[e]=o;if(e===`[`)i++;else if(i)e===`]`&&i--;else if(e===`(`)a++;else if(e===`)`&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var ef=new RegExp(String.raw`(?<noncapturingStart>${Gd})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,`gsu`);function tf(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i=[0],a=[],o=0,s=0,c=NaN,l;do{l=!1;let t=0,u=0,d=!1,f;for(ef.lastIndex=Number.isNaN(c)?0:c+7;f=ef.exec(e);){let{0:p,index:m,groups:{capturingStart:h,noncapturingStart:g}}=f;if(p===`[`)t++;else if(t)p===`]`&&t--;else if(p===`(?>`&&!d)c=m,d=!0;else if(d&&g)u++;else if(h)d?u++:(o++,i.push(o+s));else if(p===`)`&&d){if(!u){s++;let t=o+s;if(e=`${e.slice(0,c)}(?:(?=(${e.slice(c+3,m)}))<$$${t}>)${e.slice(m+1)}`,l=!0,a.push(t),Kd(n,t),r.size){let e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}u--}}}while(l);return n.push(...a),e=Yd(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){let n=+t;if(n>i.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},Jd.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var nf=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,rf=new RegExp(String.raw`
48
48
  \\(?: \d+
49
49
  | c[A-Za-z]
50
50
  | [gk]<[^>]+>
@@ -57,9 +57,9 @@ import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./p
57
57
  | [A-Za-z\-]+:
58
58
  | \(DEFINE\)
59
59
  ))?
60
- | (?<qBase>${tf})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
60
+ | (?<qBase>${nf})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
61
61
  | \\?.
62
- `.replace(/\s+/g,``),`gsu`);function rf(e){if(!RegExp(`${tf}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,i=``,a=0,o;for(nf.lastIndex=0;o=nf.exec(e);){let{0:s,index:c,groups:{qBase:l,qMod:u,invalidQ:d}}=o;if(s===`[`)a||(r=c),a++;else if(s===`]`)a?a--:r=null;else if(!a)if(u===`+`&&i&&!i.startsWith(`(`)){if(d)throw Error(`Invalid quantifier "${s}"`);let t=-1;if(/^\{\d+\}$/.test(l))e=Kd(e,c+l.length,u,``);else{if(i===`)`||i===`]`){let t=i===`)`?n:r;if(t===null)throw Error(`Invalid unmatched "${i}"`);e=`${e.slice(0,t)}(?>${e.slice(t,c)}${l})${e.slice(c+s.length)}`}else e=`${e.slice(0,c-i.length)}(?>${i}${l})${e.slice(c+s.length)}`;t+=4}nf.lastIndex+=t}else s[0]===`(`?t.push(c):s===`)`&&(n=t.length?t.pop():null);i=s}return{pattern:e}}var af=String.raw,of=af`\(\?R=(?<rDepth>[^\)]+)\)|${af`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`}`,sf=af`\(\?<(?![=!])(?<captureName>[^>]+)>`,cf=af`${sf}|(?<unnamed>\()(?!\?)`,lf=new RegExp(af`${sf}|${of}|\(\?|\\?.`,`gsu`),uf=`Cannot use multiple overlapping recursions`;function df(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:`plugin`,...t},i=t?.captureTransfers??new Map;if(!new RegExp(of,`su`).test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:n};if(r===`plugin`&&Zd(e,af`\(\?\(DEFINE\)`,qd.DEFAULT))throw Error(`DEFINE groups cannot be used with recursion`);let a=[],o=Zd(e,af`\\[1-9]`,qd.DEFAULT),s=new Map,c=[],l=!1,u=0,d=0,f;for(lf.lastIndex=0;f=lf.exec(e);){let{0:t,groups:{captureName:p,rDepth:m,gRNameOrNum:h,gRDepth:g}}=f;if(t===`[`)u++;else if(u)t===`]`&&u--;else if(m){if(ff(m),l)throw Error(uf);if(o)throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with global recursion`);let t=e.slice(0,f.index),s=e.slice(lf.lastIndex);if(Zd(s,of,qd.DEFAULT))throw Error(uf);let c=m-1;e=pf(t,s,c,!1,n,a,d),i=gf(i,t,c,a.length,0,d);break}else if(h){ff(g);let u=!1;for(let e of c)if(e.name===h||e.num===+h){if(u=!0,e.hasRecursedWithin)throw Error(uf);break}if(!u)throw Error(af`Recursive \g cannot be used outside the referenced group "${r===`external`?h:af`\g<${h}&R=${g}>`}"`);let p=s.get(h),m=Qd(e,p);if(o&&Zd(m,af`${sf}|\((?!\?)`,qd.DEFAULT))throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with recursion of capturing groups`);let _=e.slice(p,f.index),v=m.slice(_.length+t.length),y=a.length,b=g-1,x=pf(_,v,b,!0,n,a,d);i=gf(i,_,b,a.length-y,y,d),e=`${e.slice(0,p)}${x}${e.slice(p+m.length)}`,lf.lastIndex+=x.length-t.length-_.length-v.length,c.forEach(e=>e.hasRecursedWithin=!0),l=!0}else if(p)d++,s.set(String(d),lf.lastIndex),s.set(p,lf.lastIndex),c.push({num:d,name:p});else if(t[0]===`(`){let e=t===`(`;e&&(d++,s.set(String(d),lf.lastIndex)),c.push(e?{num:d}:{})}else t===`)`&&c.pop()}return n.push(...a),{pattern:e,captureTransfers:i,hiddenCaptures:n}}function ff(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e)||(e=+e,e<2||e>100))throw Error(t)}function pf(e,t,n,r,i,a,o){let s=new Set;r&&Yd(e+t,sf,({groups:{captureName:e}})=>{s.add(e)},qd.DEFAULT);let c=[n,r?s:null,i,a,o];return`${e}${mf(`(?:${e}`,`forward`,...c)}(?:)${mf(`${t})`,`backward`,...c)}${t}`}function mf(e,t,n,r,i,a,o){let s=e=>t===`forward`?e+2:n-e+2-1,c=``;for(let t=0;t<n;t++){let n=s(t);c+=Jd(e,af`${cf}|\\k<(?<backref>[^>]+)>`,({0:e,groups:{captureName:t,unnamed:s,backref:c}})=>{if(c&&r&&!r.has(c))return e;let l=`_$${n}`;if(s||t){let n=o+a.length+1;return a.push(n),hf(i,n),s?e:`(?<${t}${l}>`}return af`\k<${c}${l}>`},qd.DEFAULT)}return c}function hf(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function gf(e,t,n,r,i,a){if(e.size&&r){let o=0;Yd(t,cf,()=>o++,qd.DEFAULT);let s=a-o+i,c=new Map;return e.forEach((e,t)=>{let i=(r-o*n)/n,a=o*n,l=t>s+o?t+r:t,u=[];for(let t of e)if(t<=s)u.push(t);else if(t>s+o+i)u.push(t+r);else if(t<=s+o)for(let e=0;e<=n;e++)u.push(t+o*e);else for(let e=0;e<=n;e++)u.push(t+a+i*e);c.set(l,u)}),c}return e}var _f=String.fromCodePoint,R=String.raw,vf={},yf=globalThis.RegExp;vf.flagGroups=(()=>{try{new yf(`(?i:)`)}catch{return!1}return!0})(),vf.unicodeSets=(()=>{try{new yf(`[[]]`,`v`)}catch{return!1}return!0})(),vf.bugFlagVLiteralHyphenIsRange=vf.unicodeSets?(()=>{try{new yf(R`[\d\-a]`,`v`)}catch{return!0}return!1})():!1,vf.bugNestedClassIgnoresNegation=vf.unicodeSets&&new yf(`[[^a]]`,`v`).test(`a`);function bf(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function xf(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Sf(e,t){return wf[e]>=wf[t]}function Cf(e,t){if(e==null)throw Error(t??`Value expected`);return e}var wf={ES2025:2025,ES2024:2024,ES2018:2018},Tf={auto:`auto`,ES2025:`ES2025`,ES2024:`ES2024`,ES2018:`ES2018`};function Ef(e={}){if({}.toString.call(e)!==`[object Object]`)throw Error(`Unexpected options`);if(e.target!==void 0&&!Tf[e.target])throw Error(`Unexpected target "${e.target}"`);let t={accuracy:`default`,avoidSubclass:!1,flags:``,global:!1,hasIndices:!1,lazyCompileLength:1/0,target:`auto`,verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target===`auto`&&(t.target=vf.flagGroups?`ES2025`:vf.unicodeSets?`ES2024`:`ES2018`),t}var Df=`[ -\r ]`,Of=new Set([_f(304),_f(305)]),kf=R`[\p{L}\p{M}\p{N}\p{Pc}]`;function Af(e){if(Of.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),i=Pf.get(n),a=Mf.get(n),o=Nf.get(n);return[...r].length===1&&t.add(r),o&&t.add(o),i&&t.add(i),t.add(n),a&&t.add(a),[...t]}var jf=new Map(`C Other
62
+ `.replace(/\s+/g,``),`gsu`);function af(e){if(!RegExp(`${nf}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,i=``,a=0,o;for(rf.lastIndex=0;o=rf.exec(e);){let{0:s,index:c,groups:{qBase:l,qMod:u,invalidQ:d}}=o;if(s===`[`)a||(r=c),a++;else if(s===`]`)a?a--:r=null;else if(!a)if(u===`+`&&i&&!i.startsWith(`(`)){if(d)throw Error(`Invalid quantifier "${s}"`);let t=-1;if(/^\{\d+\}$/.test(l))e=qd(e,c+l.length,u,``);else{if(i===`)`||i===`]`){let t=i===`)`?n:r;if(t===null)throw Error(`Invalid unmatched "${i}"`);e=`${e.slice(0,t)}(?>${e.slice(t,c)}${l})${e.slice(c+s.length)}`}else e=`${e.slice(0,c-i.length)}(?>${i}${l})${e.slice(c+s.length)}`;t+=4}rf.lastIndex+=t}else s[0]===`(`?t.push(c):s===`)`&&(n=t.length?t.pop():null);i=s}return{pattern:e}}var of=String.raw,sf=of`\(\?R=(?<rDepth>[^\)]+)\)|${of`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`}`,cf=of`\(\?<(?![=!])(?<captureName>[^>]+)>`,lf=of`${cf}|(?<unnamed>\()(?!\?)`,uf=new RegExp(of`${cf}|${sf}|\(\?|\\?.`,`gsu`),df=`Cannot use multiple overlapping recursions`;function ff(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:`plugin`,...t},i=t?.captureTransfers??new Map;if(!new RegExp(sf,`su`).test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:n};if(r===`plugin`&&Qd(e,of`\(\?\(DEFINE\)`,Jd.DEFAULT))throw Error(`DEFINE groups cannot be used with recursion`);let a=[],o=Qd(e,of`\\[1-9]`,Jd.DEFAULT),s=new Map,c=[],l=!1,u=0,d=0,f;for(uf.lastIndex=0;f=uf.exec(e);){let{0:t,groups:{captureName:p,rDepth:m,gRNameOrNum:h,gRDepth:g}}=f;if(t===`[`)u++;else if(u)t===`]`&&u--;else if(m){if(pf(m),l)throw Error(df);if(o)throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with global recursion`);let t=e.slice(0,f.index),s=e.slice(uf.lastIndex);if(Qd(s,sf,Jd.DEFAULT))throw Error(df);let c=m-1;e=mf(t,s,c,!1,n,a,d),i=_f(i,t,c,a.length,0,d);break}else if(h){pf(g);let u=!1;for(let e of c)if(e.name===h||e.num===+h){if(u=!0,e.hasRecursedWithin)throw Error(df);break}if(!u)throw Error(of`Recursive \g cannot be used outside the referenced group "${r===`external`?h:of`\g<${h}&R=${g}>`}"`);let p=s.get(h),m=$d(e,p);if(o&&Qd(m,of`${cf}|\((?!\?)`,Jd.DEFAULT))throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with recursion of capturing groups`);let _=e.slice(p,f.index),v=m.slice(_.length+t.length),y=a.length,b=g-1,x=mf(_,v,b,!0,n,a,d);i=_f(i,_,b,a.length-y,y,d),e=`${e.slice(0,p)}${x}${e.slice(p+m.length)}`,uf.lastIndex+=x.length-t.length-_.length-v.length,c.forEach(e=>e.hasRecursedWithin=!0),l=!0}else if(p)d++,s.set(String(d),uf.lastIndex),s.set(p,uf.lastIndex),c.push({num:d,name:p});else if(t[0]===`(`){let e=t===`(`;e&&(d++,s.set(String(d),uf.lastIndex)),c.push(e?{num:d}:{})}else t===`)`&&c.pop()}return n.push(...a),{pattern:e,captureTransfers:i,hiddenCaptures:n}}function pf(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e)||(e=+e,e<2||e>100))throw Error(t)}function mf(e,t,n,r,i,a,o){let s=new Set;r&&Xd(e+t,cf,({groups:{captureName:e}})=>{s.add(e)},Jd.DEFAULT);let c=[n,r?s:null,i,a,o];return`${e}${hf(`(?:${e}`,`forward`,...c)}(?:)${hf(`${t})`,`backward`,...c)}${t}`}function hf(e,t,n,r,i,a,o){let s=e=>t===`forward`?e+2:n-e+2-1,c=``;for(let t=0;t<n;t++){let n=s(t);c+=Yd(e,of`${lf}|\\k<(?<backref>[^>]+)>`,({0:e,groups:{captureName:t,unnamed:s,backref:c}})=>{if(c&&r&&!r.has(c))return e;let l=`_$${n}`;if(s||t){let n=o+a.length+1;return a.push(n),gf(i,n),s?e:`(?<${t}${l}>`}return of`\k<${c}${l}>`},Jd.DEFAULT)}return c}function gf(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function _f(e,t,n,r,i,a){if(e.size&&r){let o=0;Xd(t,lf,()=>o++,Jd.DEFAULT);let s=a-o+i,c=new Map;return e.forEach((e,t)=>{let i=(r-o*n)/n,a=o*n,l=t>s+o?t+r:t,u=[];for(let t of e)if(t<=s)u.push(t);else if(t>s+o+i)u.push(t+r);else if(t<=s+o)for(let e=0;e<=n;e++)u.push(t+o*e);else for(let e=0;e<=n;e++)u.push(t+a+i*e);c.set(l,u)}),c}return e}var vf=String.fromCodePoint,R=String.raw,yf={},bf=globalThis.RegExp;yf.flagGroups=(()=>{try{new bf(`(?i:)`)}catch{return!1}return!0})(),yf.unicodeSets=(()=>{try{new bf(`[[]]`,`v`)}catch{return!1}return!0})(),yf.bugFlagVLiteralHyphenIsRange=yf.unicodeSets?(()=>{try{new bf(R`[\d\-a]`,`v`)}catch{return!0}return!1})():!1,yf.bugNestedClassIgnoresNegation=yf.unicodeSets&&new bf(`[[^a]]`,`v`).test(`a`);function xf(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function Sf(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Cf(e,t){return Tf[e]>=Tf[t]}function wf(e,t){if(e==null)throw Error(t??`Value expected`);return e}var Tf={ES2025:2025,ES2024:2024,ES2018:2018},Ef={auto:`auto`,ES2025:`ES2025`,ES2024:`ES2024`,ES2018:`ES2018`};function Df(e={}){if({}.toString.call(e)!==`[object Object]`)throw Error(`Unexpected options`);if(e.target!==void 0&&!Ef[e.target])throw Error(`Unexpected target "${e.target}"`);let t={accuracy:`default`,avoidSubclass:!1,flags:``,global:!1,hasIndices:!1,lazyCompileLength:1/0,target:`auto`,verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target===`auto`&&(t.target=yf.flagGroups?`ES2025`:yf.unicodeSets?`ES2024`:`ES2018`),t}var Of=`[ -\r ]`,kf=new Set([vf(304),vf(305)]),Af=R`[\p{L}\p{M}\p{N}\p{Pc}]`;function jf(e){if(kf.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),i=Ff.get(n),a=Nf.get(n),o=Pf.get(n);return[...r].length===1&&t.add(r),o&&t.add(o),i&&t.add(i),t.add(n),a&&t.add(a),[...t]}var Mf=new Map(`C Other
63
63
  Cc Control cntrl
64
64
  Cf Format
65
65
  Cn Unassigned
@@ -149,25 +149,25 @@ Uppercase Upper
149
149
  Variation_Selector VS
150
150
  White_Space space
151
151
  XID_Continue XIDC
152
- XID_Start XIDS`.split(/\s/).map(e=>[Rd(e),e])),Mf=new Map([[`s`,_f(383)],[_f(383),`s`]]),Nf=new Map([[_f(223),_f(7838)],[_f(107),_f(8490)],[_f(229),_f(8491)],[_f(969),_f(8486)]]),Pf=new Map([Lf(453),Lf(456),Lf(459),Lf(498),...Rf(8072,8079),...Rf(8088,8095),...Rf(8104,8111),Lf(8124),Lf(8140),Lf(8188)]),Ff=new Map([[`alnum`,R`[\p{Alpha}\p{Nd}]`],[`alpha`,R`\p{Alpha}`],[`ascii`,R`\p{ASCII}`],[`blank`,R`[\p{Zs}\t]`],[`cntrl`,R`\p{Cc}`],[`digit`,R`\p{Nd}`],[`graph`,R`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],[`lower`,R`\p{Lower}`],[`print`,R`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],[`punct`,R`[\p{P}\p{S}]`],[`space`,R`\p{space}`],[`upper`,R`\p{Upper}`],[`word`,R`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],[`xdigit`,R`\p{AHex}`]]);function If(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Lf(e){let t=_f(e);return[t.toLowerCase(),t]}function Rf(e,t){return If(e,t).map(e=>Lf(e))}var zf=new Set([`Lower`,`Lowercase`,`Upper`,`Uppercase`,`Ll`,`Lowercase_Letter`,`Lt`,`Titlecase_Letter`,`Lu`,`Uppercase_Letter`]);function Bf(e,t){let n={accuracy:`default`,asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:`ES2025`,...t};Wf(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Sf(n.bestEffortTarget,`ES2024`),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Vd(e,Vf,r);let i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};return Vd(e,Hf,a),Vd(e,Uf,{groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer}),e._originMap=a.groupOriginByCopy,e._strategy=r.strategy,e}var Vf={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:i}=e;if(i===`repeater`){let e=Cd();e.body[0].body.push(wd({negate:!0,body:r}),Ad(`Any`));let i=Cd();i.body[0].body.push(Dd(`greedy`,0,1/0,e)),n(lp(i,t),{traverse:!0})}else throw Error(`Unsupported absence function "(?~|"`)},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let i=e.body.filter(e=>e.kind===`flags`);for(let e=n+1;e<t.body.length;e++){let n=t.body[e];xf(r,n,[]).push(...i)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=Zf(t.get(e));if(n){let t=Cd({flags:n});t.body[0].body=e.body,e.body=[lp(t,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:i,remove:a,replaceWith:o},s){let{kind:c,negate:l}=e,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:f,wordIsAscii:p}=s;if(c===`text_segment_boundary`)throw Error(`Unsupported text segment boundary "\\${l?`Y`:`y`}"`);if(c===`line_end`)o(lp(wd({body:[pd({body:[md(`string_end`)]}),pd({body:[_d(10)]})]}),t));else if(c===`line_start`)o(lp(op(R`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(c===`search_start`)if(f.has(e))i.flags.sticky=!0,a();else{let e=r[n-1];if(e&&rp(e))o(lp(wd({negate:!0}),t));else if(d)throw Error(R`Uses "\G" in a way that requires a subclass`);else o(cp(md(`string_start`),t)),s.strategy=`clip_search`}else if(!(c===`string_end`||c===`string_start`))if(c===`string_end_newline`)o(lp(op(R`(?=\n?\z)`),t));else if(c===`word_boundary`){if(!p&&!u){let e=`(?:(?<=${kf})(?!${kf})|(?<!${kf})(?=${kf}))`,n=`(?:(?<=${kf})(?=${kf})|(?<!${kf})(?!${kf}))`;o(lp(op(l?n:e),t))}}else throw Error(`Unexpected assertion kind "${c}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!ap(n)&&(n=Xf(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!ap(r)&&(r=Xf(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){t.kind===`intersection`&&n(lp(vd({body:[e]}),t),{traverse:!0})},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:i,digitIsAscii:a,spaceIsAscii:o,wordIsAscii:s}){let{kind:c,negate:l,value:u}=e;if(a&&(c===`digit`||u===`digit`)){n(cp(bd(`digit`,{negate:l}),t));return}if(o&&(c===`space`||u===`space`)){n(lp(sp(op(Df),l),t));return}if(s&&(c===`word`||u===`word`)){n(cp(bd(`word`,{negate:l}),t));return}if(c===`any`)n(cp(Ad(`Any`),t));else if(c===`digit`)n(cp(Ad(`Nd`,{negate:l}),t));else if(c!==`dot`)if(c===`text_segment`){if(r===`strict`)throw Error(R`Use of "\X" requires non-strict accuracy`);let e=`\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?`,a=R`\p{RI}{2}|${e}(?:\u200D${e})*`;n(lp(op(R`(?>\r\n|${i?R`\p{RGI_Emoji}`:a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(c===`hex`)n(cp(Ad(`AHex`,{negate:l}),t));else if(c===`newline`)n(lp(op(l?`[^
152
+ XID_Start XIDS`.split(/\s/).map(e=>[zd(e),e])),Nf=new Map([[`s`,vf(383)],[vf(383),`s`]]),Pf=new Map([[vf(223),vf(7838)],[vf(107),vf(8490)],[vf(229),vf(8491)],[vf(969),vf(8486)]]),Ff=new Map([Rf(453),Rf(456),Rf(459),Rf(498),...zf(8072,8079),...zf(8088,8095),...zf(8104,8111),Rf(8124),Rf(8140),Rf(8188)]),If=new Map([[`alnum`,R`[\p{Alpha}\p{Nd}]`],[`alpha`,R`\p{Alpha}`],[`ascii`,R`\p{ASCII}`],[`blank`,R`[\p{Zs}\t]`],[`cntrl`,R`\p{Cc}`],[`digit`,R`\p{Nd}`],[`graph`,R`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],[`lower`,R`\p{Lower}`],[`print`,R`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],[`punct`,R`[\p{P}\p{S}]`],[`space`,R`\p{space}`],[`upper`,R`\p{Upper}`],[`word`,R`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],[`xdigit`,R`\p{AHex}`]]);function Lf(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Rf(e){let t=vf(e);return[t.toLowerCase(),t]}function zf(e,t){return Lf(e,t).map(e=>Rf(e))}var Bf=new Set([`Lower`,`Lowercase`,`Upper`,`Uppercase`,`Ll`,`Lowercase_Letter`,`Lt`,`Titlecase_Letter`,`Lu`,`Uppercase_Letter`]);function Vf(e,t){let n={accuracy:`default`,asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:`ES2025`,...t};Gf(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Cf(n.bestEffortTarget,`ES2024`),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Hd(e,Hf,r);let i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};return Hd(e,Uf,a),Hd(e,Wf,{groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer}),e._originMap=a.groupOriginByCopy,e._strategy=r.strategy,e}var Hf={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:i}=e;if(i===`repeater`){let e=wd();e.body[0].body.push(Td({negate:!0,body:r}),jd(`Any`));let i=wd();i.body[0].body.push(Od(`greedy`,0,1/0,e)),n(up(i,t),{traverse:!0})}else throw Error(`Unsupported absence function "(?~|"`)},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let i=e.body.filter(e=>e.kind===`flags`);for(let e=n+1;e<t.body.length;e++){let n=t.body[e];Sf(r,n,[]).push(...i)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=Qf(t.get(e));if(n){let t=wd({flags:n});t.body[0].body=e.body,e.body=[up(t,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:i,remove:a,replaceWith:o},s){let{kind:c,negate:l}=e,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:f,wordIsAscii:p}=s;if(c===`text_segment_boundary`)throw Error(`Unsupported text segment boundary "\\${l?`Y`:`y`}"`);if(c===`line_end`)o(up(Td({body:[md({body:[hd(`string_end`)]}),md({body:[vd(10)]})]}),t));else if(c===`line_start`)o(up(sp(R`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(c===`search_start`)if(f.has(e))i.flags.sticky=!0,a();else{let e=r[n-1];if(e&&ip(e))o(up(Td({negate:!0}),t));else if(d)throw Error(R`Uses "\G" in a way that requires a subclass`);else o(lp(hd(`string_start`),t)),s.strategy=`clip_search`}else if(!(c===`string_end`||c===`string_start`))if(c===`string_end_newline`)o(up(sp(R`(?=\n?\z)`),t));else if(c===`word_boundary`){if(!p&&!u){let e=`(?:(?<=${Af})(?!${Af})|(?<!${Af})(?=${Af}))`,n=`(?:(?<=${Af})(?=${Af})|(?<!${Af})(?!${Af}))`;o(up(sp(l?n:e),t))}}else throw Error(`Unexpected assertion kind "${c}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!op(n)&&(n=Zf(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!op(r)&&(r=Zf(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){t.kind===`intersection`&&n(up(yd({body:[e]}),t),{traverse:!0})},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:i,digitIsAscii:a,spaceIsAscii:o,wordIsAscii:s}){let{kind:c,negate:l,value:u}=e;if(a&&(c===`digit`||u===`digit`)){n(lp(xd(`digit`,{negate:l}),t));return}if(o&&(c===`space`||u===`space`)){n(up(cp(sp(Of),l),t));return}if(s&&(c===`word`||u===`word`)){n(lp(xd(`word`,{negate:l}),t));return}if(c===`any`)n(lp(jd(`Any`),t));else if(c===`digit`)n(lp(jd(`Nd`,{negate:l}),t));else if(c!==`dot`)if(c===`text_segment`){if(r===`strict`)throw Error(R`Use of "\X" requires non-strict accuracy`);let e=`\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?`,a=R`\p{RI}{2}|${e}(?:\u200D${e})*`;n(up(sp(R`(?>\r\n|${i?R`\p{RGI_Emoji}`:a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(c===`hex`)n(lp(jd(`AHex`,{negate:l}),t));else if(c===`newline`)n(up(sp(l?`[^
153
153
  ]`:`(?>\r
154
154
  ?|[
155
- \v\f…\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${_f(e.codePointAt(0)-1)}${_f(e.codePointAt(2)+1)}-\u{10FFFF}`),n(lp(op(`[${e}]`),t))}else n(lp(sp(op(Ff.get(u)),l),t));else if(c===`property`)jf.has(Rd(u))||(e.key=`sc`);else if(c===`space`)n(cp(Ad(`space`,{negate:l}),t));else if(c===`word`)n(lp(sp(op(kf),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=Cd({flags:c});e.body[0].body=o(),i(lp(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&ed(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(R`Uses "\K" in a way that's unsupported`);let o=wd({behind:!0});o.body[0].body=a(),i(lp(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(lp(wd({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=Cd();t.body[0].body.push(e.body),e.body=lp(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=ep(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(R`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!ap(n)&&(n=Xf(n,t),e.ref=n)}},Hf={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=cp(Jf(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&xf(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=xf(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=bf(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?Jf(0):qf(o,r.groupOriginByCopy,null),l=c;if(!s){let e=Zf(Yf(o,e=>e.type===`Group`&&!!e.flags)),t=e?bf(r.globalFlags,e):r.globalFlags;Gf(t,r.currentFlags)||(l=Cd({flags:Qf(t)}),l.body[0].body.push(c))}n(lp(l,t),{traverse:!s})}},Uf={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>Kf(t,e));i.length?i.length>1?n(lp(Cd({atomic:!0,body:i.reverse().map(e=>pd({body:[hd(e.number)]}))}),t)):e.ref=i[0].number:n(lp(wd({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=gd();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Wf(e){Vd(e,{"*"({node:e,parent:t}){e.parent=t}})}function Gf(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Kf(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=$f(n.parent);for(let r of t){if(r===n)break;if(r===e||tp(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function qf(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=qf(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function Jf(e){let t=kd(e);return t.isRecursive=!0,t}function Yf(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Xf(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function Zf(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Qf({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function $f(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function ep(e){let t=e.find(e=>e.kind===`search_start`||ip(e,{negate:!1})||!np(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=ep(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function tp(e,t){let n=$f(e)??[];for(let e of n)if(e===t||tp(e,t))return!0;return!1}function np({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function rp(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function ip(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&ed(e.body[0],{type:`Assertion`,kind:`search_start`})}function ap(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function op(e,t){let n=rd(e,{...t,unicodePropertyMap:jf}).body;return n.length>1||n[0].body.length>1?Cd({body:n}):n[0].body[0]}function sp(e,t){return e.negate=t,e}function cp(e,t){return e.parent=t,e}function lp(e,t){return Wf(e),e.parent=t,e}function up(e,t){let n=Ef(t),r=Sf(n.target,`ES2024`),i=Sf(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];Vd(e,dp,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,Cf(fp[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&xf(f._captureTransfers,e.transferTo,[]).push(t)}),f}var dp={"*":{enter({node:e},t){if(wp(e)){let n=t.getCurrentModI();t.pushModI(e.flags?bf({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){wp(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){vp(_f(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),yp(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&zf.has(e.value)&&t.setHasCasedChar()}},fp={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?R`\B`:R`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=_f(e),r=bp(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&vp(n)){let e=Af(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);vf.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(Ep)&&(o=[_d(45),...o.filter(e=>!Ep(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||vf.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=Cd(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=pd({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(vf.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=bp(n,i),o=bp(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&xp(yp(e)).forEach(e=>{s.add(Array.isArray(e)?`${bp(e[0],i)}-${bp(e[1],i)}`:bp(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:R`[^\n]`;if(e===`digit`)return t?R`\D`:R`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&zf.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?R`\P`:R`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?R`\W`:R`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=bf(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${Sp(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+Cp(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:R`\g<${t}&R=${r}>`}},pp=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),mp=new Set([`-`,`\\`,`]`,`^`,`[`]),hp=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),gp=new Map([[9,R`\t`],[10,R`\n`],[11,R`\v`],[12,R`\f`],[13,R`\r`],[8232,R`\u2028`],[8233,R`\u2029`],[65279,R`\uFEFF`]]),_p=/^\p{Cased}$/u;function vp(e){return _p.test(e)}function yp(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=_f(e);if(!vp(t))continue;let o=Af(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function bp(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(gp.has(e))return gp.get(e);if(e<32||e>126&&e<160||e>262143||t&&Tp(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?hp:mp:pp,a=_f(e);return(i.has(a)?`\\`:``)+a}function xp(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function Sp(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function Cp({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function wp({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function Tp(e){return e>47&&e<58}function Ep({type:e,value:t}){return e===`Character`&&t===45}var Dp=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=kp(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(Op(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=Ap(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function Op(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function kp(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)xf(n,t,{}).transferTo=e;return n}function Ap(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function jp(e,t){let n=Mp(e,t);return n.options?new Dp(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Mp(e,t){let n=Ef(t),r=Bf(rd(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:jf}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=up(r,n),a=df(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=ef(rf(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function Np(e,t){return jp(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function Pp(e={}){let t={target:`auto`,cache:new Map,...e};return t.regexConstructor||=e=>Np(e,{target:t.target}),{createScanner(e){return new su(e,t)},createString:lu}}var Fp={bash:()=>c(()=>import(`./shellscript-CLZ0U2zV.js`),[],import.meta.url),css:()=>c(()=>import(`./css-DUjzNfgv.js`),__vite__mapDeps([0,1]),import.meta.url),diff:()=>c(()=>import(`./diff-woXpYk--.js`),[],import.meta.url),html:()=>c(()=>import(`./html-BHZv6uqE.js`),__vite__mapDeps([2,1,3]),import.meta.url),javascript:()=>c(()=>import(`./javascript-Yelw-5ZN.js`),__vite__mapDeps([4,3]),import.meta.url),json:()=>c(()=>import(`./json-qhed-kSA.js`),[],import.meta.url),jsx:()=>c(()=>import(`./jsx-Bz0zcwM4.js`),[],import.meta.url),markdown:()=>c(()=>import(`./markdown-BYOwaDjH.js`),[],import.meta.url),python:()=>c(()=>import(`./python-gzcpVVnB.js`),[],import.meta.url),sql:()=>c(()=>import(`./sql-CEbI0hMM.js`),[],import.meta.url),tsx:()=>c(()=>import(`./tsx-udAQXfEw.js`),[],import.meta.url),typescript:()=>c(()=>import(`./typescript-bsJCZSQ-.js`),[],import.meta.url),yaml:()=>c(()=>import(`./yaml-rwi0_p6S.js`),[],import.meta.url)},Ip={js:`javascript`,md:`markdown`,py:`python`,sh:`bash`,shell:`bash`,shellscript:`bash`,ts:`typescript`,yml:`yaml`,zsh:`bash`},Lp;function Rp(){return Lp??=ru({themes:[c(()=>import(`./github-light-EUqPIrTm.js`),[],import.meta.url),c(()=>import(`./github-dark-C-LZuMrd.js`),[],import.meta.url)],langs:[],engine:Pp({forgiving:!0})}),Lp}function zp(e){let t=e.toLowerCase();return t===`ansi`||t in Fp?t:Ip[t]??null}async function Bp(e){let t=zp(e);if(!t)return null;let n=await Rp();return t!==`ansi`&&!n.getLoadedLanguages().includes(t)&&await n.loadLanguage(Fp[t]),{highlight(e,r){let i=e=>n.codeToTokens(e,{lang:t,themes:{light:`github-light`,dark:`github-dark`},defaultColor:!1,grammarState:r}).tokens,a=t===`ansi`?e.split(`
156
- `).flatMap(e=>i(e)):i(e);return{lines:a.map(e=>e.map((e,t)=>(0,L.jsx)(`span`,{style:e.htmlStyle,className:`text-(--shiki-light) dark:text-(--shiki-dark)`,children:e.content},t))),state:n.getLastGrammarState(a)}}}}function Vp(e,t){let n=e.endsWith(`
157
- `)?e.slice(0,-1):e,[r,i]=I.useState(null),a=r?.language===t?r.highlighter:null;I.useEffect(()=>{let e=!1;return Bp(t).then(n=>{e||i({language:t,highlighter:n})}).catch(()=>{}),()=>{e=!0}},[t]);let[o,s]=I.useState({highlighter:null,text:``,lines:[]}),c=o;(c.highlighter!==a||!n.startsWith(c.text))&&(c={highlighter:a,text:``,lines:[]});let l=n.lastIndexOf(`
155
+ \v\f…\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${vf(e.codePointAt(0)-1)}${vf(e.codePointAt(2)+1)}-\u{10FFFF}`),n(up(sp(`[${e}]`),t))}else n(up(cp(sp(If.get(u)),l),t));else if(c===`property`)Mf.has(zd(u))||(e.key=`sc`);else if(c===`space`)n(lp(jd(`space`,{negate:l}),t));else if(c===`word`)n(up(cp(sp(Af),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=wd({flags:c});e.body[0].body=o(),i(up(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&td(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(R`Uses "\K" in a way that's unsupported`);let o=Td({behind:!0});o.body[0].body=a(),i(up(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(up(Td({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=wd();t.body[0].body.push(e.body),e.body=up(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=tp(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(R`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!op(n)&&(n=Zf(n,t),e.ref=n)}},Uf={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=lp(Yf(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&Sf(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=Sf(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=xf(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?Yf(0):Jf(o,r.groupOriginByCopy,null),l=c;if(!s){let e=Qf(Xf(o,e=>e.type===`Group`&&!!e.flags)),t=e?xf(r.globalFlags,e):r.globalFlags;Kf(t,r.currentFlags)||(l=wd({flags:$f(t)}),l.body[0].body.push(c))}n(up(l,t),{traverse:!s})}},Wf={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>qf(t,e));i.length?i.length>1?n(up(wd({atomic:!0,body:i.reverse().map(e=>md({body:[gd(e.number)]}))}),t)):e.ref=i[0].number:n(up(Td({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=_d();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Gf(e){Hd(e,{"*"({node:e,parent:t}){e.parent=t}})}function Kf(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function qf(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=ep(n.parent);for(let r of t){if(r===n)break;if(r===e||np(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function Jf(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=Jf(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function Yf(e){let t=Ad(e);return t.isRecursive=!0,t}function Xf(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Zf(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function Qf(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function $f({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function ep(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function tp(e){let t=e.find(e=>e.kind===`search_start`||ap(e,{negate:!1})||!rp(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=tp(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function np(e,t){let n=ep(e)??[];for(let e of n)if(e===t||np(e,t))return!0;return!1}function rp({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function ip(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function ap(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&td(e.body[0],{type:`Assertion`,kind:`search_start`})}function op(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function sp(e,t){let n=id(e,{...t,unicodePropertyMap:Mf}).body;return n.length>1||n[0].body.length>1?wd({body:n}):n[0].body[0]}function cp(e,t){return e.negate=t,e}function lp(e,t){return e.parent=t,e}function up(e,t){return Gf(e),e.parent=t,e}function dp(e,t){let n=Df(t),r=Cf(n.target,`ES2024`),i=Cf(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];Hd(e,fp,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,wf(pp[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&Sf(f._captureTransfers,e.transferTo,[]).push(t)}),f}var fp={"*":{enter({node:e},t){if(Tp(e)){let n=t.getCurrentModI();t.pushModI(e.flags?xf({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Tp(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){yp(vf(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),bp(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&Bf.has(e.value)&&t.setHasCasedChar()}},pp={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?R`\B`:R`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=vf(e),r=xp(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&yp(n)){let e=jf(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);yf.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(Dp)&&(o=[vd(45),...o.filter(e=>!Dp(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||yf.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=wd(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=md({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(yf.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=xp(n,i),o=xp(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Sp(bp(e)).forEach(e=>{s.add(Array.isArray(e)?`${xp(e[0],i)}-${xp(e[1],i)}`:xp(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:R`[^\n]`;if(e===`digit`)return t?R`\D`:R`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&Bf.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?R`\P`:R`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?R`\W`:R`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=xf(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${Cp(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+wp(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:R`\g<${t}&R=${r}>`}},mp=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),hp=new Set([`-`,`\\`,`]`,`^`,`[`]),gp=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),_p=new Map([[9,R`\t`],[10,R`\n`],[11,R`\v`],[12,R`\f`],[13,R`\r`],[8232,R`\u2028`],[8233,R`\u2029`],[65279,R`\uFEFF`]]),vp=/^\p{Cased}$/u;function yp(e){return vp.test(e)}function bp(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=vf(e);if(!yp(t))continue;let o=jf(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function xp(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(_p.has(e))return _p.get(e);if(e<32||e>126&&e<160||e>262143||t&&Ep(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?gp:hp:mp,a=vf(e);return(i.has(a)?`\\`:``)+a}function Sp(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function Cp(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function wp({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function Tp({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function Ep(e){return e>47&&e<58}function Dp({type:e,value:t}){return e===`Character`&&t===45}var Op=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=Ap(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(kp(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=jp(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function kp(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function Ap(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)Sf(n,t,{}).transferTo=e;return n}function jp(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function Mp(e,t){let n=Np(e,t);return n.options?new Op(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Np(e,t){let n=Df(t),r=Vf(id(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Mf}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=dp(r,n),a=ff(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=tf(af(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function Pp(e,t){return Mp(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function Fp(e={}){let t={target:`auto`,cache:new Map,...e};return t.regexConstructor||=e=>Pp(e,{target:t.target}),{createScanner(e){return new cu(e,t)},createString:uu}}var Ip={bash:()=>c(()=>import(`./shellscript-CLZ0U2zV.js`),[],import.meta.url),css:()=>c(()=>import(`./css-DUjzNfgv.js`),__vite__mapDeps([0,1]),import.meta.url),diff:()=>c(()=>import(`./diff-woXpYk--.js`),[],import.meta.url),html:()=>c(()=>import(`./html-BHZv6uqE.js`),__vite__mapDeps([2,1,3]),import.meta.url),javascript:()=>c(()=>import(`./javascript-Yelw-5ZN.js`),__vite__mapDeps([4,3]),import.meta.url),json:()=>c(()=>import(`./json-qhed-kSA.js`),[],import.meta.url),jsx:()=>c(()=>import(`./jsx-Bz0zcwM4.js`),[],import.meta.url),markdown:()=>c(()=>import(`./markdown-BYOwaDjH.js`),[],import.meta.url),python:()=>c(()=>import(`./python-gzcpVVnB.js`),[],import.meta.url),sql:()=>c(()=>import(`./sql-CEbI0hMM.js`),[],import.meta.url),tsx:()=>c(()=>import(`./tsx-udAQXfEw.js`),[],import.meta.url),typescript:()=>c(()=>import(`./typescript-bsJCZSQ-.js`),[],import.meta.url),yaml:()=>c(()=>import(`./yaml-rwi0_p6S.js`),[],import.meta.url)},Lp={js:`javascript`,md:`markdown`,py:`python`,sh:`bash`,shell:`bash`,shellscript:`bash`,ts:`typescript`,yml:`yaml`,zsh:`bash`},Rp;function zp(){return Rp??=iu({themes:[c(()=>import(`./github-light-EUqPIrTm.js`),[],import.meta.url),c(()=>import(`./github-dark-C-LZuMrd.js`),[],import.meta.url)],langs:[],engine:Fp({forgiving:!0})}),Rp}function Bp(e){let t=e.toLowerCase();return t===`ansi`||t in Ip?t:Lp[t]??null}async function Vp(e){let t=Bp(e);if(!t)return null;let n=await zp();return t!==`ansi`&&!n.getLoadedLanguages().includes(t)&&await n.loadLanguage(Ip[t]),{highlight(e,r){let i=e=>n.codeToTokens(e,{lang:t,themes:{light:`github-light`,dark:`github-dark`},defaultColor:!1,grammarState:r}).tokens,a=t===`ansi`?e.split(`
156
+ `).flatMap(e=>i(e)):i(e);return{lines:a.map(e=>e.map((e,t)=>(0,L.jsx)(`span`,{style:e.htmlStyle,className:`text-(--shiki-light) dark:text-(--shiki-dark)`,children:e.content},t))),state:n.getLastGrammarState(a)}}}}function Hp(e,t){let n=e.endsWith(`
157
+ `)?e.slice(0,-1):e,[r,i]=I.useState(null),a=r?.language===t?r.highlighter:null;I.useEffect(()=>{let e=!1;return Vp(t).then(n=>{e||i({language:t,highlighter:n})}).catch(()=>{}),()=>{e=!0}},[t]);let[o,s]=I.useState({highlighter:null,text:``,lines:[]}),c=o;(c.highlighter!==a||!n.startsWith(c.text))&&(c={highlighter:a,text:``,lines:[]});let l=n.lastIndexOf(`
158
158
  `)+1;if(a&&l>c.text.length){let e=a.highlight(n.slice(c.text.length,l-1),c.state);c={highlighter:a,text:n.slice(0,l),lines:[...c.lines,...e.lines],state:e.state}}c!==o&&s(c);let u=n.slice(l);return I.useMemo(()=>a?[...c.lines,a.highlight(u,c.state).lines[0]]:n.split(`
159
- `),[n,a,c,u])}var Hp=`vercel.ai.error`,Up=Symbol.for(Hp),Wp=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[Up]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Hp)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},Gp=`AI_APICallError`,Kp=`vercel.ai.error.${Gp}`,qp=Symbol.for(Kp),Jp=class extends Wp{constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:Gp,message:e,cause:o}),this[qp]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return Wp.hasMarker(e,Kp)}},Yp=`AI_EmptyResponseBodyError`,Xp=`vercel.ai.error.${Yp}`,Zp=Symbol.for(Xp),Qp=class extends Wp{constructor({message:e=`Empty response body`}={}){super({name:Yp,message:e}),this[Zp]=!0}static isInstance(e){return Wp.hasMarker(e,Xp)}};function $p(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var em=`AI_InvalidArgumentError`,tm=`vercel.ai.error.${em}`,nm=Symbol.for(tm),rm=class extends Wp{constructor({message:e,cause:t,argument:n}){super({name:em,message:e,cause:t}),this[nm]=!0,this.argument=n}static isInstance(e){return Wp.hasMarker(e,tm)}},im=`AI_JSONParseError`,am=`vercel.ai.error.${im}`,om=Symbol.for(am),sm=class extends Wp{constructor({text:e,cause:t}){super({name:im,message:`JSON parsing failed: Text: ${e}.\nError message: ${$p(t)}`,cause:t}),this[om]=!0,this.text=e}static isInstance(e){return Wp.hasMarker(e,am)}},cm=`AI_TypeValidationError`,lm=`vercel.ai.error.${cm}`,um=Symbol.for(lm),dm=class e extends Wp{constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:cm,message:`${r}: Value: ${JSON.stringify(e)}.\nError message: ${$p(t)}`,cause:t}),this[um]=!0,this.value=e,this.context=n}static isInstance(e){return Wp.hasMarker(e,lm)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},fm=`AI_UnsupportedFunctionalityError`,pm=`vercel.ai.error.${fm}`,mm=Symbol.for(pm),hm=class extends Wp{constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:fm,message:t}),this[mm]=!0,this.functionality=e}static isInstance(e){return Wp.hasMarker(e,pm)}},gm=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},_m=10,vm=13,ym=32;function bm(e){}function xm(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=bm,onError:n=bm,onRetry:r=bm,onComment:i}=e,a=[],o=!0,s,c=``,l=0,u;function d(e){if(o&&(o=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),a.length===0){let t=f(e);t!==``&&a.push(t);return}if(e.indexOf(`
159
+ `),[n,a,c,u])}var Up=`vercel.ai.error`,Wp=Symbol.for(Up),Gp=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[Wp]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Up)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},Kp=`AI_APICallError`,qp=`vercel.ai.error.${Kp}`,Jp=Symbol.for(qp),Yp=class extends Gp{constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:Kp,message:e,cause:o}),this[Jp]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return Gp.hasMarker(e,qp)}},Xp=`AI_EmptyResponseBodyError`,Zp=`vercel.ai.error.${Xp}`,Qp=Symbol.for(Zp),$p=class extends Gp{constructor({message:e=`Empty response body`}={}){super({name:Xp,message:e}),this[Qp]=!0}static isInstance(e){return Gp.hasMarker(e,Zp)}};function em(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var tm=`AI_InvalidArgumentError`,nm=`vercel.ai.error.${tm}`,rm=Symbol.for(nm),im=class extends Gp{constructor({message:e,cause:t,argument:n}){super({name:tm,message:e,cause:t}),this[rm]=!0,this.argument=n}static isInstance(e){return Gp.hasMarker(e,nm)}},am=`AI_JSONParseError`,om=`vercel.ai.error.${am}`,sm=Symbol.for(om),cm=class extends Gp{constructor({text:e,cause:t}){super({name:am,message:`JSON parsing failed: Text: ${e}.\nError message: ${em(t)}`,cause:t}),this[sm]=!0,this.text=e}static isInstance(e){return Gp.hasMarker(e,om)}},lm=`AI_TypeValidationError`,um=`vercel.ai.error.${lm}`,dm=Symbol.for(um),fm=class e extends Gp{constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:lm,message:`${r}: Value: ${JSON.stringify(e)}.\nError message: ${em(t)}`,cause:t}),this[dm]=!0,this.value=e,this.context=n}static isInstance(e){return Gp.hasMarker(e,um)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},pm=`AI_UnsupportedFunctionalityError`,mm=`vercel.ai.error.${pm}`,hm=Symbol.for(mm),gm=class extends Gp{constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:pm,message:t}),this[hm]=!0,this.functionality=e}static isInstance(e){return Gp.hasMarker(e,mm)}},_m=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},vm=10,ym=13,bm=32;function xm(e){}function Sm(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=xm,onError:n=xm,onRetry:r=xm,onComment:i}=e,a=[],o=!0,s,c=``,l=0,u;function d(e){if(o&&(o=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),a.length===0){let t=f(e);t!==``&&a.push(t);return}if(e.indexOf(`
160
160
  `)===-1&&e.indexOf(`\r`)===-1){a.push(e);return}a.push(e);let t=a.join(``);a.length=0;let n=f(t);n!==``&&a.push(n)}function f(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
161
161
  `,n);for(;r!==-1;){if(n===r){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0,n=r+1,r=e.indexOf(`
162
- `,n);continue}let i=e.charCodeAt(n);if(Sm(e,n,i)){let i=e.charCodeAt(n+5)===ym?n+6:n+5,a=e.slice(i,r);if(l===0&&e.charCodeAt(r+1)===_m){t({id:s,event:u,data:a}),s=void 0,c=``,u=void 0,n=r+2,r=e.indexOf(`
162
+ `,n);continue}let i=e.charCodeAt(n);if(Cm(e,n,i)){let i=e.charCodeAt(n+5)===bm?n+6:n+5,a=e.slice(i,r);if(l===0&&e.charCodeAt(r+1)===vm){t({id:s,event:u,data:a}),s=void 0,c=``,u=void 0,n=r+2,r=e.indexOf(`
163
163
  `,n);continue}c=l===0?a:`${c}
164
- ${a}`,l++}else Cm(e,n,i)?u=e.slice(e.charCodeAt(n+6)===ym?n+7:n+6,r)||void 0:p(e,n,r);n=r+1,r=e.indexOf(`
164
+ ${a}`,l++}else wm(e,n,i)?u=e.slice(e.charCodeAt(n+6)===bm?n+7:n+6,r)||void 0:p(e,n,r);n=r+1,r=e.indexOf(`
165
165
  `,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
166
- `,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;p(e,n,i),n=i+1,e.charCodeAt(n-1)===vm&&e.charCodeAt(n)===_m&&n++}return e.slice(n)}function p(e,t,n){if(t===n){h();return}let r=e.charCodeAt(t);if(Sm(e,t,r)){let r=e.charCodeAt(t+5)===ym?t+6:t+5,i=e.slice(r,n);c=l===0?i:`${c}
167
- ${i}`,l++;return}if(Cm(e,t,r)){u=e.slice(e.charCodeAt(t+6)===ym?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===ym?t+4:t+3,n);s=r.includes(`\0`)?void 0:r;return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===ym?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){m(a,``,a);return}let d=a.slice(0,o),f=a.charCodeAt(o+1)===ym?2:1;m(d,a.slice(o+f),a)}function m(e,t,i){switch(e){case`event`:u=t||void 0;break;case`data`:c=l===0?t:`${c}
168
- ${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new gm(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new gm(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function h(){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0}function g(e={}){if(e.consume&&a.length>0){let e=a.join(``);p(e,0,e.length)}o=!0,s=void 0,c=``,l=0,u=void 0,a.length=0}return{feed:d,reset:g}}function Sm(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function Cm(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var wm=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=xm({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};new TextDecoder;var{btoa:nee,atob:ree}=globalThis,Tm=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get,Em=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`).get;function Dm(e){return ArrayBuffer.isView(e)&&Tm.call(e)===`Uint8Array`}function Om(e){if(typeof e!=`object`||!e||!(`byteLength`in e))return!1;try{return Em.call(e),!0}catch{return!1}}function km(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var Am=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new rm({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},jm=Am();function Mm(e){return globalThis.Buffer?.isBuffer(e)??!1}function Nm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Pm=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Fm=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Im(e){let t=JSON.parse(e);return typeof t!=`object`||!t||Pm.test(e)===!1&&Fm.test(e)===!1?t:Lm(t)}function Lm(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function Rm(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Im(e)}try{return Im(e)}finally{Error.stackTraceLimit=t}}function zm(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){let{additionalProperties:t}=e;e.additionalProperties=t!=null&&typeof t!=`boolean`&&Bm(t);let{properties:n}=e;if(n!=null)for(let e of Object.keys(n))n[e]=Bm(n[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(Bm):Bm(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(Bm)),e.allOf!=null&&(e.allOf=e.allOf.map(Bm)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(Bm));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=Bm(t[e]);return e}function Bm(e){return typeof e==`boolean`?e:zm(e)}var Vm=Symbol(`Let zodToJsonSchema decide on which parser to use`),Hm={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},Um=e=>typeof e==`string`?{...Hm,name:e}:{...Hm,...e};function Wm(){return{}}function Gm(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==`ZodAny`&&(n.items=z(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function Km(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function qm(){return{type:`boolean`}}function Jm(e,t){return z(e.type._def,t)}var Ym=(e,t)=>z(e.innerType._def,t);function Xm(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(n=>Xm(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return Zm(e)}}var Zm=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value}return t};function Qm(e,t){return{...z(e.innerType._def,t),default:e.defaultValue()}}function $m(e,t){return t.effectStrategy===`input`?z(e.schema._def,t):Wm()}function eh(e){return{type:`string`,enum:Array.from(e.values)}}var th=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function nh(e,t){let n=[z(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),z(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(th(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function rh(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var ih=void 0,ah={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(ih===void 0&&(ih=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),ih),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function oh(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:uh(n,`email`,r.message,t);break;case`format:idn-email`:uh(n,`idn-email`,r.message,t);break;case`pattern:zod`:dh(n,ah.email,r.message,t)}break;case`url`:uh(n,`uri`,r.message,t);break;case`uuid`:uh(n,`uuid`,r.message,t);break;case`regex`:dh(n,r.regex,r.message,t);break;case`cuid`:dh(n,ah.cuid,r.message,t);break;case`cuid2`:dh(n,ah.cuid2,r.message,t);break;case`startsWith`:dh(n,RegExp(`^${sh(r.value,t)}`),r.message,t);break;case`endsWith`:dh(n,RegExp(`${sh(r.value,t)}$`),r.message,t);break;case`datetime`:uh(n,`date-time`,r.message,t);break;case`date`:uh(n,`date`,r.message,t);break;case`time`:uh(n,`time`,r.message,t);break;case`duration`:uh(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:dh(n,RegExp(sh(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&uh(n,`ipv4`,r.message,t),r.version!==`v4`&&uh(n,`ipv6`,r.message,t);break;case`base64url`:dh(n,ah.base64url,r.message,t);break;case`jwt`:dh(n,ah.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&dh(n,ah.ipv4Cidr,r.message,t),r.version!==`v4`&&dh(n,ah.ipv6Cidr,r.message,t);break;case`emoji`:dh(n,ah.emoji(),r.message,t);break;case`ulid`:dh(n,ah.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:uh(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:dh(n,ah.base64,r.message,t)}break;case`nanoid`:dh(n,ah.nanoid,r.message,t)}return n}function sh(e,t){return t.patternStrategy===`escape`?lh(e):e}var ch=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function lh(e){let t=``;for(let n=0;n<e.length;n++)ch.has(e[n])||(t+=`\\`),t+=e[n];return t}function uh(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function dh(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:fh(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=fh(t,r)}function fh(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
166
+ `,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;p(e,n,i),n=i+1,e.charCodeAt(n-1)===ym&&e.charCodeAt(n)===vm&&n++}return e.slice(n)}function p(e,t,n){if(t===n){h();return}let r=e.charCodeAt(t);if(Cm(e,t,r)){let r=e.charCodeAt(t+5)===bm?t+6:t+5,i=e.slice(r,n);c=l===0?i:`${c}
167
+ ${i}`,l++;return}if(wm(e,t,r)){u=e.slice(e.charCodeAt(t+6)===bm?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===bm?t+4:t+3,n);s=r.includes(`\0`)?void 0:r;return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===bm?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){m(a,``,a);return}let d=a.slice(0,o),f=a.charCodeAt(o+1)===bm?2:1;m(d,a.slice(o+f),a)}function m(e,t,i){switch(e){case`event`:u=t||void 0;break;case`data`:c=l===0?t:`${c}
168
+ ${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new _m(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new _m(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function h(){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0}function g(e={}){if(e.consume&&a.length>0){let e=a.join(``);p(e,0,e.length)}o=!0,s=void 0,c=``,l=0,u=void 0,a.length=0}return{feed:d,reset:g}}function Cm(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function wm(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Tm=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Sm({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};new TextDecoder;var{btoa:tee,atob:nee}=globalThis,Em=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get,Dm=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`).get;function Om(e){return ArrayBuffer.isView(e)&&Em.call(e)===`Uint8Array`}function km(e){if(typeof e!=`object`||!e||!(`byteLength`in e))return!1;try{return Dm.call(e),!0}catch{return!1}}function Am(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var jm=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new im({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},Mm=jm();function Nm(e){return globalThis.Buffer?.isBuffer(e)??!1}function Pm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Fm=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Im=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Lm(e){let t=JSON.parse(e);return typeof t!=`object`||!t||Fm.test(e)===!1&&Im.test(e)===!1?t:Rm(t)}function Rm(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function zm(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Lm(e)}try{return Lm(e)}finally{Error.stackTraceLimit=t}}function Bm(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){let{additionalProperties:t}=e;e.additionalProperties=t!=null&&typeof t!=`boolean`&&Vm(t);let{properties:n}=e;if(n!=null)for(let e of Object.keys(n))n[e]=Vm(n[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(Vm):Vm(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(Vm)),e.allOf!=null&&(e.allOf=e.allOf.map(Vm)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(Vm));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=Vm(t[e]);return e}function Vm(e){return typeof e==`boolean`?e:Bm(e)}var Hm=Symbol(`Let zodToJsonSchema decide on which parser to use`),Um={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},Wm=e=>typeof e==`string`?{...Um,name:e}:{...Um,...e};function Gm(){return{}}function Km(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==`ZodAny`&&(n.items=z(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function qm(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function Jm(){return{type:`boolean`}}function Ym(e,t){return z(e.type._def,t)}var Xm=(e,t)=>z(e.innerType._def,t);function Zm(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(n=>Zm(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return Qm(e)}}var Qm=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value}return t};function $m(e,t){return{...z(e.innerType._def,t),default:e.defaultValue()}}function eh(e,t){return t.effectStrategy===`input`?z(e.schema._def,t):Gm()}function th(e){return{type:`string`,enum:Array.from(e.values)}}var nh=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function rh(e,t){let n=[z(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),z(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(nh(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function ih(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var ah=void 0,oh={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(ah===void 0&&(ah=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),ah),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function sh(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:dh(n,`email`,r.message,t);break;case`format:idn-email`:dh(n,`idn-email`,r.message,t);break;case`pattern:zod`:fh(n,oh.email,r.message,t)}break;case`url`:dh(n,`uri`,r.message,t);break;case`uuid`:dh(n,`uuid`,r.message,t);break;case`regex`:fh(n,r.regex,r.message,t);break;case`cuid`:fh(n,oh.cuid,r.message,t);break;case`cuid2`:fh(n,oh.cuid2,r.message,t);break;case`startsWith`:fh(n,RegExp(`^${ch(r.value,t)}`),r.message,t);break;case`endsWith`:fh(n,RegExp(`${ch(r.value,t)}$`),r.message,t);break;case`datetime`:dh(n,`date-time`,r.message,t);break;case`date`:dh(n,`date`,r.message,t);break;case`time`:dh(n,`time`,r.message,t);break;case`duration`:dh(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:fh(n,RegExp(ch(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&dh(n,`ipv4`,r.message,t),r.version!==`v4`&&dh(n,`ipv6`,r.message,t);break;case`base64url`:fh(n,oh.base64url,r.message,t);break;case`jwt`:fh(n,oh.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&fh(n,oh.ipv4Cidr,r.message,t),r.version!==`v4`&&fh(n,oh.ipv6Cidr,r.message,t);break;case`emoji`:fh(n,oh.emoji(),r.message,t);break;case`ulid`:fh(n,oh.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:dh(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:fh(n,oh.base64,r.message,t)}break;case`nanoid`:fh(n,oh.nanoid,r.message,t)}return n}function ch(e,t){return t.patternStrategy===`escape`?uh(e):e}var lh=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function uh(e){let t=``;for(let n=0;n<e.length;n++)lh.has(e[n])||(t+=`\\`),t+=e[n];return t}function dh(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function fh(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:ph(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=ph(t,r)}function ph(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
169
169
  ]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
170
- ]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function ph(e,t){let n={type:`object`,additionalProperties:z(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===`ZodString`&&e.keyType._def.checks?.length){let{type:r,...i}=oh(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===`ZodEnum`)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===`ZodBranded`&&e.keyType._def.type._def.typeName===`ZodString`&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=Jm(e.keyType._def,t);return{...n,propertyNames:i}}return n}function mh(e,t){return t.mapStrategy===`record`?ph(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[z(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Wm(),z(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Wm()],minItems:2,maxItems:2}}}function hh(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function gh(){return{not:Wm()}}function _h(){return{type:`null`}}var vh={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function yh(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in vh&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=vh[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return bh(e,t)}var bh=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>z(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function xh(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[vh[e.innerType._def.typeName],`null`]};let n=z(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function Sh(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function Ch(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=Th(a),s=z(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=wh(e,t);return a!==void 0&&(n.additionalProperties=a),n}function wh(e,t){if(e.catchall._def.typeName!==`ZodNever`)return z(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Th(e){try{return e.isOptional()}catch{return!0}}var Eh=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return z(e.innerType._def,t);let n=z(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Wm()},n]}:Wm()},Dh=(e,t)=>{if(t.pipeStrategy===`input`)return z(e.in._def,t);if(t.pipeStrategy===`output`)return z(e.out._def,t);let n=z(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,z(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Oh(e,t){return z(e.type._def,t)}function kh(e,t){let n={type:`array`,uniqueItems:!0,items:z(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function Ah(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>z(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:z(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>z(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function jh(){return{not:Wm()}}function Mh(){return Wm()}var Nh=(e,t)=>z(e.innerType._def,t),Ph=(e,t,n)=>{switch(t){case`ZodString`:return oh(e,n);case`ZodNumber`:return Sh(e);case`ZodObject`:return Ch(e,n);case`ZodBigInt`:return Km(e);case`ZodBoolean`:return qm();case`ZodDate`:return Xm(e,n);case`ZodUndefined`:return jh();case`ZodNull`:return _h();case`ZodArray`:return Gm(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return yh(e,n);case`ZodIntersection`:return nh(e,n);case`ZodTuple`:return Ah(e,n);case`ZodRecord`:return ph(e,n);case`ZodLiteral`:return rh(e);case`ZodEnum`:return eh(e);case`ZodNativeEnum`:return hh(e);case`ZodNullable`:return xh(e,n);case`ZodOptional`:return Eh(e,n);case`ZodMap`:return mh(e,n);case`ZodSet`:return kh(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return Oh(e,n);case`ZodNaN`:case`ZodNever`:return gh();case`ZodEffects`:return $m(e,n);case`ZodAny`:return Wm();case`ZodUnknown`:return Mh();case`ZodDefault`:return Qm(e,n);case`ZodBranded`:return Jm(e,n);case`ZodReadonly`:return Nh(e,n);case`ZodCatch`:return Ym(e,n);case`ZodPipeline`:return Dh(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},Fh=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function z(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==Vm)return i}if(r&&!n){let e=Ih(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Ph(e,e.typeName,t),o=typeof a==`function`?z(a(),t):a;if(o&&Lh(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Ih=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Fh(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Wm()):t.$refStrategy===`seen`?Wm():void 0}},Lh=(e,t,n)=>(e.description&&(n.description=e.description),n),Rh=e=>{let t=Um(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},zh=(e,t)=>{let n=Rh(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:z(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Wm()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=z(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Wm(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},Bh=Symbol.for(`vercel.ai.schema`);function Vh(e){let t;return()=>(t??=e(),t)}function Hh(e,{validate:t}={}){return{[Bh]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function Uh(e){return typeof e==`object`&&!!e&&Bh in e&&e[Bh]===!0&&`jsonSchema`in e&&`validate`in e}function Wh(e){return e==null?Hh({type:`object`,properties:{},additionalProperties:!1}):Uh(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?Xh(e):Gh(e):e()}function Gh(e){return Hh(()=>{if(!Kh(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return zm(e[`~standard`].jsonSchema.input({target:`draft-07`}))},{validate:async t=>{let n=await e[`~standard`].validate(t);return n.issues===void 0&&`value`in n?{success:!0,value:n.value}:{success:!1,error:new dm({value:t,cause:n.issues})}}})}function Kh(e){return e[`~standard`].jsonSchema!=null}function qh(e,t){let n=t?.useReferences??!1;return Hh(()=>zh(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Jh(e,t){lt().localeError||lt(j());let n=t?.useReferences??!1;return Hh(()=>zm(Te(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await ye(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Yh(e){return`_zod`in e}function Xh(e,t){return Yh(e)?Jh(e,t):qh(e,t)}async function Zh({value:e,schema:t,context:n}){let r=await Qh({value:e,schema:t,context:n});if(!r.success)throw dm.wrap({value:e,cause:r.error,context:n});return r.value}async function Qh({value:e,schema:t,context:n}){let r=Wh(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:dm.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:dm.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function $h({text:e,schema:t}){try{let n=Rm(e);return t==null?{success:!0,value:n,rawValue:n}:await Qh({value:n,schema:t})}catch(t){return{success:!1,error:sm.isInstance(t)?t:new sm({text:e,cause:t}),rawValue:void 0}}}function eg({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new wm).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await $h({text:e,schema:t}))}}))}async function tg(e){return typeof e==`function`&&(e=e()),e}new TextDecoder;var ng=fn(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);sn.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){ze(this,`with`,e)},parse(e,t){return Yt(this,e,t,{callee:this.parse})},parseAsync(e,t){return Vt(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return wt(this,e,t)},safeParseAsync(e,t){return xt(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return bn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),rg=fn(`ZodMiniString`,(e,t)=>{dt.init(e,t),ng.init(e,t)});function ig(e){return de(rg,e)}var ag=fn(`ZodMiniNumber`,(e,t)=>{Ht.init(e,t),ng.init(e,t)});function og(e){return k(ag,e)}var sg=fn(`ZodMiniNumberFormat`,(e,t)=>{en.init(e,t),ag.init(e,t)});function cg(e){return pe(sg,e)}var lg=fn(`ZodMiniBoolean`,(e,t)=>{Xe.init(e,t),ng.init(e,t)});function ug(e){return te(lg,e)}var dg=fn(`ZodMiniUnknown`,(e,t)=>{_t.init(e,t),ng.init(e,t)});function fg(){return Xt(dg)}var pg=fn(`ZodMiniNever`,(e,t)=>{an.init(e,t),ng.init(e,t)});function mg(e){return h(pg,e)}var hg=fn(`ZodMiniArray`,(e,t)=>{Ze.init(e,t),ng.init(e,t)});function gg(e,t){return new hg({type:`array`,element:e,...gn(t)})}var _g=fn(`ZodMiniObject`,(e,t)=>{Ot.init(e,t),ng.init(e,t),x(e,`shape`,e=>e._zod.def.shape,!1)});function vg(e,t){return new _g({type:`object`,shape:e??{},...gn(t)})}function yg(e,t){return new _g({type:`object`,shape:e,catchall:fg(),...gn(t)})}function bg(e,t){return Ie(e,t)}var xg=fn(`ZodMiniUnion`,(e,t)=>{mt.init(e,t),ng.init(e,t)});function Sg(e,t){return new xg({type:`union`,options:e,...gn(t)})}var Cg=fn(`ZodMiniDiscriminatedUnion`,(e,t)=>{Oe.init(e,t),ng.init(e,t)});function wg(e,t,n){return new Cg({type:`union`,options:t,discriminator:e,...gn(n)})}var Tg=fn(`ZodMiniRecord`,(e,t)=>{nn.init(e,t),ng.init(e,t)});function Eg(e,t,n){return!t||!t._zod?new Tg({type:`record`,keyType:ig(),valueType:e,...gn(t)}):new Tg({type:`record`,keyType:e,valueType:t,...gn(n)})}var Dg=fn(`ZodMiniEnum`,(e,t)=>{u.init(e,t),ng.init(e,t),e.options=[...e._zod.values]});function Og(e,t){return new Dg({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...gn(t)})}var kg=fn(`ZodMiniLiteral`,(e,t)=>{gt.init(e,t),ng.init(e,t)});function Ag(e,t){return new kg({type:`literal`,values:Array.isArray(e)?e:[e],...gn(t)})}var jg=fn(`ZodMiniTransform`,(e,t)=>{Lt.init(e,t),ng.init(e,t)});function Mg(e){return new jg({type:`transform`,transform:e})}var Ng=fn(`ZodMiniOptional`,(e,t)=>{ot.init(e,t),ng.init(e,t)});function Pg(e){return new Ng({type:`optional`,innerType:e})}var Fg=fn(`ZodMiniPipe`,(e,t)=>{Wt.init(e,t),ng.init(e,t)});function Ig(e,t){return new Fg({type:`pipe`,in:e,out:t})}var Lg=fn(`ZodMiniCustom`,(e,t)=>{Qe.init(e,t),ng.init(e,t)});function Rg(e,t){return oe(Lg,e??(()=>!0),t)}function zg(e,t={}){return Ke(Lg,e,t)}var Bg=`AI_InvalidArgumentError`,Vg=`vercel.ai.error.${Bg}`,Hg=Symbol.for(Vg),Ug=class extends Wp{constructor({parameter:e,value:t,message:n}){super({name:Bg,message:`Invalid argument for parameter ${e}: ${n}`}),this[Hg]=!0,this.parameter=e,this.value=t}static isInstance(e){return Wp.hasMarker(e,Vg)}},Wg=new Map([[`generateObject`,`AISDK_DEP_GENERATE_OBJECT`],[`streamObject`,`AISDK_DEP_STREAM_OBJECT`],[`experimental_generateSpeech`,`AISDK_DEP_EXPERIMENTAL_GENERATE_SPEECH`],[`experimental_transcribe`,`AISDK_DEP_EXPERIMENTAL_TRANSCRIBE`],[`"image" content part`,`AISDK_DEP_IMAGE_CONTENT_PART`],[`"tool-result" content of type "file-data"`,`AISDK_DEP_TOOL_RESULT_FILE_DATA`],[`"tool-result" content of type "file-url"`,`AISDK_DEP_TOOL_RESULT_FILE_URL`],[`"tool-result" content of type "file-id"`,`AISDK_DEP_TOOL_RESULT_FILE_ID`],[`"tool-result" content of type "file-reference"`,`AISDK_DEP_TOOL_RESULT_FILE_REFERENCE`],[`"tool-result" content of type "image-data"`,`AISDK_DEP_TOOL_RESULT_IMAGE_DATA`],[`"tool-result" content of type "image-url"`,`AISDK_DEP_TOOL_RESULT_IMAGE_URL`],[`"tool-result" content of type "image-file-id"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_ID`],[`"tool-result" content of type "image-file-reference"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_REFERENCE`],[`rawInput in output-error UI message parts`,`AISDK_DEP_UI_MESSAGE_RAW_INPUT`]]);function Gg(e){return e.replace(/[^a-zA-Z0-9]/g,e=>`_${e.charCodeAt(0).toString(16).toUpperCase().padStart(4,`0`)}`)}function Kg({setting:e,provider:t}){return t==null?Wg.get(e)??`AISDK_DEP_SETTING_${Gg(e)}`:`AISDK_DEP_PROVIDER_${Gg(t)}__${Gg(e)}`}function qg({warning:e,provider:t,model:n}){let r=`AI SDK Warning${t!=null&&n!=null?` (${t} / ${n})`:``}:`;switch(e.type){case`unsupported`:{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case`compatibility`:{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case`deprecated`:return`${r} Deprecated: "${e.setting}". ${e.message}`;case`other`:return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}var Jg=`AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.`,Yg=!1,Xg=new Set;function Zg({message:e,type:t,code:n}){typeof process<`u`&&typeof process.emitWarning==`function`?process.emitWarning(e,n==null?{type:t}:{type:t,code:n}):console.warn(n==null?e:`[${n}] ${e}`)}var Qg=e=>{if(e.warnings.length===0)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t==`function`){t(e);return}Yg||(Yg=!0,Zg({message:Jg,type:`Warning`}));for(let t of e.warnings){let n=t.type===`deprecated`?Kg({setting:t.setting,provider:e.provider}):void 0;if(n!=null){if(Xg.has(n))continue;Xg.add(n)}Zg({message:qg({warning:t,provider:e.provider,model:e.model}),type:t.type===`deprecated`?`DeprecationWarning`:`Warning`,code:n})}}};function $g(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(!(r===`__proto__`||r===`constructor`||r===`prototype`)&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);o&&s?n[r]=$g(a,i):n[r]=i}return n}function e_(e,t){return e!=null&&Object.hasOwn(e,t)?e[t]:void 0}function t_(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(typeof e!=`object`&&typeof t!=`object`)return e===t;if(e.constructor!==t.constructor)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!t_(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||!t_(e[i],t[i]))return!1;return!0}new TextEncoder,new TextEncoder;var n_=`AI_UIMessageStreamError`,r_=`vercel.ai.error.${n_}`,i_=Symbol.for(r_),a_=class extends Wp{constructor({chunkType:e,chunkId:t,message:n}){super({name:n_,message:n}),this[i_]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Wp.hasMarker(e,r_)}};function o_(e){let t=[`ROOT`],n=-1,r=null,i=0;function a(e){return e>=`0`&&e<=`9`||e>=`A`&&e<=`F`||e>=`a`&&e<=`f`}function o(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`)}}function s(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop()}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop()}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case`ROOT`:o(u,l,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=l,t.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`)}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`)}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`)}break;case`INSIDE_OBJECT_BEFORE_VALUE`:o(u,l,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:s(u,l);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=l;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=l}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=l,t.pop();break;default:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=l,t.pop();break;default:n=l}break;case`INSIDE_ARRAY_AFTER_COMMA`:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),u===`u`?(i=0,t.push(`INSIDE_STRING_UNICODE_ESCAPE`)):n=l;break;case`INSIDE_STRING_UNICODE_ESCAPE`:a(u)&&(i++,i===4&&(t.pop(),n=l));break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=l;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l);break;default:t.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,l+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?s(u,l):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l)):n=l;break}}}let l=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:l+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:l+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:l+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?l+=`true`.slice(t.length):`false`.startsWith(t)?l+=`false`.slice(t.length):`null`.startsWith(t)&&(l+=`null`.slice(t.length))}}return l}async function s_(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await $h({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await $h({text:o_(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}Am({prefix:`steer`,size:24}),Am({prefix:`aitxt`,size:24}),Am({prefix:`call`,size:24}),TransformStream;var B={NEVER:Tn,array:gg,boolean:ug,custom:Rg,discriminatedUnion:wg,enum:Og,extend:bg,int:cg,literal:Ag,looseObject:yg,maximum:Ae,minLength:En,never:mg,nonnegative:Ue,number:og,object:vg,optional:Pg,pipe:Ig,positive:Be,record:Eg,refine:zg,safeParse:wt,startsWith:re,string:ig,transform:Mg,union:Sg,unknown:fg},V={array:vt,boolean:et,custom:cn,discriminatedUnion:xn,instanceof:Rt,lazy:_n,literal:Ne,null:St,number:pn,object:N,record:S,string:F,union:f,unknown:kt},c_=V.lazy(()=>V.union([V.null(),V.string(),V.number(),V.boolean(),V.record(V.string(),c_.optional()),V.array(c_)])),H=V.record(V.string(),V.record(V.string(),c_.optional()));function l_(e){return B.object({source:B.discriminatedUnion(`sourceType`,[B.object({type:B.literal(`source`),sourceType:B.literal(`url`),id:B.string(),url:B.string(),title:B.optional(B.string()),providerMetadata:B.optional(e)}),B.object({type:B.literal(`source`),sourceType:B.literal(`document`),id:B.string(),mediaType:B.string(),title:B.string(),filename:B.optional(B.string()),providerMetadata:B.optional(e)})]),startIndex:B.optional(B.number().check(B.int()).check(B.nonnegative())),endIndex:B.optional(B.number().check(B.int()).check(B.nonnegative())),citedText:B.optional(B.string())})}var u_=l_(H),d_=B.record(B.string(),B.optional(c_)),f_=Vh(()=>Xh(B.union([B.looseObject({type:B.literal(`text-start`),id:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`text-delta`),id:B.string(),delta:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`text-end`),id:B.string(),citations:B.optional(B.array(u_)),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`error`),errorText:B.string()}),B.looseObject({type:B.literal(`tool-input-start`),toolCallId:B.string(),toolName:B.string(),inputEncoding:B.optional(B.enum([`json`,`text`])),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H),toolMetadata:B.optional(d_),dynamic:B.optional(B.boolean()),title:B.optional(B.string())}),B.looseObject({type:B.literal(`tool-input-delta`),toolCallId:B.string(),inputTextDelta:B.string()}),B.looseObject({type:B.literal(`tool-input-available`),toolCallId:B.string(),toolName:B.string(),input:B.unknown(),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H),toolMetadata:B.optional(d_),dynamic:B.optional(B.boolean()),title:B.optional(B.string())}),B.looseObject({type:B.literal(`tool-input-error`),toolCallId:B.string(),toolName:B.string(),input:B.unknown(),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H),toolMetadata:B.optional(d_),dynamic:B.optional(B.boolean()),errorText:B.string(),title:B.optional(B.string())}),B.looseObject({type:B.literal(`tool-approval-request`),approvalId:B.string(),toolCallId:B.string(),approvalDescriptor:B.optional(B.unknown()),inputSchemaInput:B.optional(B.unknown()),reason:B.optional(B.string()),isAutomatic:B.optional(B.boolean()),signature:B.optional(B.string())}),B.looseObject({type:B.literal(`tool-approval-response`),approvalId:B.string(),approved:B.boolean(),reason:B.optional(B.string()),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`tool-output-available`),toolCallId:B.string(),output:B.unknown(),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H),toolMetadata:B.optional(d_),dynamic:B.optional(B.boolean()),preliminary:B.optional(B.boolean())}),B.looseObject({type:B.literal(`tool-output-error`),toolCallId:B.string(),errorText:B.string(),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H),toolMetadata:B.optional(d_),dynamic:B.optional(B.boolean())}),B.looseObject({type:B.literal(`tool-output-denied`),toolCallId:B.string()}),B.looseObject({type:B.literal(`reasoning-start`),id:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`reasoning-delta`),id:B.string(),delta:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`reasoning-end`),id:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`custom`),kind:B.pipe(B.string(),B.transform(e=>e)),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`source-url`),sourceId:B.string(),url:B.string(),title:B.optional(B.string()),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`source-document`),sourceId:B.string(),mediaType:B.string(),title:B.string(),filename:B.optional(B.string()),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`file`),url:B.string(),mediaType:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`reasoning-file`),url:B.string(),mediaType:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`steering-message`),id:B.string(),parts:B.array(B.union([B.looseObject({type:B.literal(`text`),text:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`file`),mediaType:B.string(),url:B.string(),filename:B.optional(B.string()),providerReference:B.optional(B.record(B.string(),B.string())),providerMetadata:B.optional(H)})]))}),B.looseObject({type:B.custom(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:B.optional(B.string()),data:B.unknown(),transient:B.optional(B.boolean())}),B.looseObject({type:B.literal(`start-step`)}),B.looseObject({type:B.literal(`finish-step`)}),B.looseObject({type:B.literal(`reset-step`)}),B.looseObject({type:B.literal(`start`),messageId:B.optional(B.string()),messageMetadata:B.optional(B.unknown())}),B.looseObject({type:B.literal(`finish`),finishReason:B.optional(B.enum([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`interrupted`,`other`])),messageMetadata:B.optional(B.unknown())}),B.looseObject({type:B.literal(`abort`),reason:B.optional(B.string())}),B.looseObject({type:B.literal(`message-metadata`),messageMetadata:B.unknown()})])));function p_(e){return e.type.startsWith(`data-`)}function m_(){return Object.create(null)}function h_(e){return e.type===`text`}function g_(e){return e.type===`reasoning`}function __(e){return e.type.startsWith(`tool-`)}function v_(e){return e.type===`dynamic-tool`}function y_(e){return __(e)||v_(e)}function b_(e){return e.type.split(`-`).slice(1).join(`-`)}function x_(e){return v_(e)?e.toolName:b_(e)}function S_({lastMessage:e,messageId:t}){let n=e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},r=m_(),i=n.parts.findLastIndex(e=>e.type===`step-start`),a=0;for(let e of n.parts.slice(i+1)){if(!y_(e))continue;let t=a;__(e)&&a++,e.state===`input-streaming`&&(r[e.toolCallId]={text:e.rawInput??``,inputEncoding:e.inputEncoding,index:t,toolName:e.type===`dynamic-tool`?e.toolName:b_(e),dynamic:e.type===`dynamic-tool`,title:e.title,toolMetadata:e.toolMetadata})}return{message:n,activeTextParts:m_(),activeReasoningParts:m_(),partialToolCalls:r}}function C_({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o,resetStateOnMessageIdChange:s=!1,resetStateOnFirstMessageStart:c=!1}){let l=!0;return e.pipeThrough(new TransformStream({async transform(e,u){await r(async({state:r,write:d})=>{function f(){let e=r.message.parts,t=e.length-1;for(;t>=0&&e[t].type!==`step-start`;)t--;return e.slice(t+1)}function p(){return f().filter(y_)}function m(e){let t=p().find(t=>t.toolCallId===e);if(t==null){let n=r.message.parts;for(let r=n.length-1;r>=0;r--){let i=n[r];if(y_(i)&&i.toolCallId===e){t=i;break}}}if(t==null)throw new a_({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function h(e){let t=r.message.parts.filter(y_).find(t=>t.approval?.id===e);if(t==null)throw new a_({chunkType:`tool-approval-response`,chunkId:e,message:`No tool invocation found for approval ID "${e}".`});return t}function g(e,t){let n=t??f().find(t=>__(t)&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.type=`tool-${e.toolName}`,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,rawInput:i.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,preliminary:i.preliminary,...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}function _(e,t){let n=t??f().find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.toolName=e.toolName,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,errorText:i.errorText,preliminary:i.preliminary,providerExecuted:i.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}async function v(e){if(e!=null){let n=r.message.metadata==null?e:$g(r.message.metadata,e);t!=null&&await Zh({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),d();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new a_({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new a_({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,e.citations!=null&&(t.citations=e.citations),t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],d();break}case`custom`:{let t={type:`custom`,kind:e.kind,providerMetadata:e.providerMetadata};r.message.parts.push(t),d();break}case`reasoning-start`:{let t={type:`reasoning`,id:e.id,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),d();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new a_({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new a_({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],d();break}case`file`:case`reasoning-file`:r.message.parts.push({type:e.type,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),d();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),d();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),d();break;case`tool-input-start`:{let t=f().filter(__);r.partialToolCalls[e.toolCallId]={text:``,inputEncoding:e.inputEncoding,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),d();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new a_({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let n=t.inputEncoding===`text`?t.text:(await s_(t.text)).value;t.dynamic?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}):g({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}),d();break}case`tool-input-available`:e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),d(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=f().filter(y_).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),d();break}case`tool-approval-request`:{let t=m(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.approvalDescriptor==null?{}:{descriptor:e.approvalDescriptor},...Object.prototype.hasOwnProperty.call(e,`inputSchemaInput`)?{inputSchemaInput:e.inputSchemaInput}:{},...e.reason==null?{}:{requestReason:e.reason},...e.isAutomatic===!0?{isAutomatic:!0}:{},...e.signature==null?{}:{signature:e.signature}},d();break}case`tool-approval-response`:{let t=h(e.approvalId),n=t.approval==null?{id:e.approvalId}:t.approval;t.state=`approval-responded`,t.approval={...n,id:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason}},e.providerExecuted!=null&&(t.providerExecuted=e.providerExecuted),e.providerMetadata!=null&&(t.callProviderMetadata=e.providerMetadata),d();break}case`tool-output-denied`:{let t=m(e.toolCallId);t.state=`output-denied`,d();break}case`tool-output-available`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:b_(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`tool-output-error`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:b_(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`steering-message`:r.message.parts.push({type:`steering-message`,id:e.id,parts:e.parts}),d();break;case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:break;case`reset-step`:{let e=f();r.activeTextParts=m_(),r.activeReasoningParts=m_(),r.partialToolCalls=m_(),e.length>0&&(r.message.parts.splice(r.message.parts.length-e.length,e.length),d());break}case`start`:{let t=c&&l||s&&e.messageId!=null&&e.messageId!==r.message.id;l=!1,t&&Object.assign(r,S_({lastMessage:void 0,messageId:e.messageId??r.message.id}),{finishReason:void 0}),e.messageId!=null&&(r.message.id=e.messageId),await v(e.messageMetadata),(t||e.messageId!=null||e.messageMetadata!=null)&&d({updateStatus:!1});break}case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`message-metadata`:await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`error`:i?.(Error(e.errorText));break;default:if(p_(e)){let t=n?.[e.type.slice(5)];if(t!=null){let n=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=n>=0?n:r.message.parts.length;await Zh({value:e.data,schema:t,context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let i=e;if(i.transient){o?.(i);break}let a=i.id==null?void 0:r.message.parts.find(e=>i.type===e.type&&i.id===e.id);a==null?r.message.parts.push(i):a.data=i.data,o?.(i),d()}}u.enqueue(e)})}}))}async function w_({stream:e,onError:t,abortSignal:n}){let r=e.getReader(),i=()=>{r.cancel().catch(()=>{})};n?.aborted?i():n?.addEventListener(`abort`,i,{once:!0});try{for(;;){let{done:e}=await r.read();if(e)break}}catch(e){t?.(e)}finally{n?.removeEventListener(`abort`,i),r.releaseLock()}}function T_(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}Am({prefix:`aitxt`,size:24}),Am({prefix:`call`,size:24}),Am({prefix:`aitxt`,size:24}),Am({prefix:`call`,size:24});function E_(e){return e.dynamic=!1,e}var D_={type:`deprecated`,setting:`rawInput in output-error UI message parts`,message:`Use the "input" field instead. The "rawInput" field will be removed in the next major version.`};function O_(e){e.some(e=>e.parts.some(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`&&(e.type===`dynamic-tool`||e.type.startsWith(`tool-`))&&`state`in e&&e.state===`output-error`&&Object.prototype.hasOwnProperty.call(e,`rawInput`)&&`rawInput`in e&&e.rawInput!==void 0))&&Qg({warnings:[D_]})}var k_=Symbol(`invalid`);function A_(e){let t=[],n=j_(e,t,new Set);return n===k_?{success:!1,path:t}:{success:!0,value:n}}function j_(e,t,n){switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isFinite(e)?e:k_;case`object`:{if(e===null)return e;if(n.has(e))return k_;n.add(e);let r=Array.isArray(e)?M_(e,t,n):N_(e,t,n);return n.delete(e),r}default:return k_}}function M_(e,t,n){let r;for(let i=0;i<e.length;i++){let a=e[i];t.push(i);let o=j_(a,t,n);if(o===k_)return k_;t.pop(),r==null?o!==a&&(r=e.slice(0,i),r.push(o)):r.push(o)}return r??e}function N_(e,t,n){if(!F_(e)||I_(e))return k_;let r=Object.keys(e),i;for(let a=0;a<r.length;a++){let o=r[a];if(o===`__proto__`){i??=P_(e,r,a);continue}let s=e[o],c=s;if(s!==void 0){if(t.push(o),c=j_(s,t,n),c===k_)return k_;t.pop()}i==null?c!==s&&(i=P_(e,r,a),i[o]=c):i[o]=c}return i??e}function P_(e,t,n){let r={};for(let i=0;i<n;i++)r[t[i]]=e[t[i]];return r}function F_(e){let t=e.constructor;if(typeof t!=`function`)return!0;let n=t.prototype;return typeof n==`object`&&!!n&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)}function I_(e){let t=Object.getOwnPropertySymbols(e);for(let n=0;n<t.length;n++)if(Object.prototype.propertyIsEnumerable.call(e,t[n]))return!0;return!1}var L_=B.pipe(B.unknown(),B.transform((e,t)=>{let n=A_(e);return n.success?n.value:(t.issues.push({code:`custom`,message:`Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.`,input:e,path:n.path}),B.NEVER)})),R_=B.custom(),z_=B.pipe(L_,B.record(B.string(),R_)),B_=B.pipe(L_,B.record(B.string(),B.record(B.string(),R_))),V_=B.record(B.string(),B.string()),H_=l_(B_);function U_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function W_(e){let{type:t,...n}=e;return E_({...n,type:`dynamic-tool`,toolName:t.slice(5)})}function G_(e){return e.approval!=null&&Object.prototype.hasOwnProperty.call(e.approval,`inputSchemaInput`)?{value:e.approval.inputSchemaInput}:void 0}function K_(e){return B.pipe(B.array(B.unknown()),B.transform((t,n)=>{let r=[];for(let[i,a]of t.entries()){let t=B.safeParse(e(a),a);if(!t.success){for(let e of t.error.issues)n.issues.push({...e,path:[i,...e.path]});return B.NEVER}r.push(t.data)}return r}))}var q_=Vh(()=>{let e=B.object({id:B.string(),approved:B.optional(B.never()),descriptor:B.optional(B.unknown()),requestReason:B.optional(B.string()),reason:B.optional(B.never()),isAutomatic:B.optional(B.boolean()),signature:B.optional(B.string()),inputSchemaInput:B.optional(B.unknown())}),t=B.extend(e,{approved:B.boolean(),reason:B.optional(B.string())}),n=B.extend(t,{approved:B.literal(!0)}),r=B.extend(t,{approved:B.literal(!1)}),i=B.discriminatedUnion(`type`,[B.object({type:B.literal(`text`),text:B.string(),providerMetadata:B.optional(B_)}),B.object({type:B.literal(`file`),mediaType:B.string(),filename:B.optional(B.string()),url:B.string(),providerReference:B.optional(V_),providerMetadata:B.optional(B_)})]),a=B.discriminatedUnion(`type`,[B.object({type:B.literal(`text`),text:B.string(),citations:B.optional(K_(()=>H_)),state:B.optional(B.enum([`streaming`,`done`])),providerMetadata:B.optional(B_)}),B.object({type:B.literal(`reasoning`),id:B.optional(B.string()),text:B.string(),state:B.optional(B.enum([`streaming`,`done`])),providerMetadata:B.optional(B_)}),B.object({type:B.literal(`custom`),kind:B.string(),providerMetadata:B.optional(B_)}),B.object({type:B.literal(`source-url`),sourceId:B.string(),url:B.string(),title:B.optional(B.string()),providerMetadata:B.optional(B_)}),B.object({type:B.literal(`source-document`),sourceId:B.string(),mediaType:B.string(),title:B.string(),filename:B.optional(B.string()),providerMetadata:B.optional(B_)}),B.object({type:B.literal(`file`),mediaType:B.string(),filename:B.optional(B.string()),url:B.string(),providerReference:B.optional(V_),providerMetadata:B.optional(B_)}),B.object({type:B.literal(`reasoning-file`),mediaType:B.string(),url:B.string(),providerMetadata:B.optional(B_)}),B.object({type:B.literal(`steering-message`),id:B.string(),parts:K_(()=>i)}),B.object({type:B.literal(`step-start`)})],{error:e=>e.code===`invalid_union`?`Invalid UI message part type. Expected a known part type (for example "text" or "dynamic-tool") or a type starting with "data-" or "tool-".`:void 0}),o=B.object({type:B.string().check(B.startsWith(`data-`)),id:B.optional(B.string()),data:B.unknown()}),s=B.discriminatedUnion(`state`,[B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`input-streaming`),input:B.optional(B.unknown()),rawInput:B.optional(B.string()),inputEncoding:B.optional(B.enum([`json`,`text`])),providerExecuted:B.optional(B.boolean()),callProviderMetadata:B.optional(B_),output:B.optional(B.never()),errorText:B.optional(B.never()),approval:B.optional(B.never())}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`input-available`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(B_),approval:B.optional(B.never())}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`approval-requested`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(B_),approval:e}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`approval-responded`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(B_),approval:t}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`output-available`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.unknown(),errorText:B.optional(B.never()),callProviderMetadata:B.optional(B_),resultProviderMetadata:B.optional(B_),preliminary:B.optional(B.boolean()),approval:B.optional(n)}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`output-error`),input:B.optional(B.unknown()),rawInput:B.optional(B.unknown()),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.string(),callProviderMetadata:B.optional(B_),resultProviderMetadata:B.optional(B_),approval:B.optional(n)}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`output-denied`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(B_),approval:r})]),c=B.discriminatedUnion(`state`,[B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`input-streaming`),providerExecuted:B.optional(B.boolean()),callProviderMetadata:B.optional(B_),input:B.optional(B.unknown()),rawInput:B.optional(B.string()),inputEncoding:B.optional(B.enum([`json`,`text`])),output:B.optional(B.never()),errorText:B.optional(B.never()),approval:B.optional(B.never())}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`input-available`),providerExecuted:B.optional(B.boolean()),input:B.unknown(),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(B_),approval:B.optional(B.never())}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`approval-requested`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(B_),approval:e}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`approval-responded`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(B_),approval:t}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`output-available`),providerExecuted:B.optional(B.boolean()),input:B.unknown(),output:B.unknown(),errorText:B.optional(B.never()),callProviderMetadata:B.optional(B_),resultProviderMetadata:B.optional(B_),preliminary:B.optional(B.boolean()),approval:B.optional(n)}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`output-error`),providerExecuted:B.optional(B.boolean()),input:B.optional(B.unknown()),rawInput:B.optional(B.unknown()),output:B.optional(B.never()),errorText:B.string(),callProviderMetadata:B.optional(B_),resultProviderMetadata:B.optional(B_),approval:B.optional(n)}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(z_),state:B.literal(`output-denied`),providerExecuted:B.optional(B.boolean()),input:B.unknown(),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(B_),approval:r})]),l=B.object({id:B.string(),role:B.enum([`system`,`user`,`assistant`]),metadata:B.optional(B.unknown()),parts:K_(e=>{let t=e?.type;if(typeof t==`string`){if(t.startsWith(`data-`))return o;if(t.startsWith(`tool-`))return c;if(t===`dynamic-tool`)return s}return a})}).check(e=>{let t=e.value;t.role!==`assistant`&&t.parts.length===0&&e.issues.push({continue:!0,origin:`array`,code:`too_small`,minimum:1,inclusive:!0,input:t.parts,path:[`parts`],message:`Message must contain at least one part`})});return Xh(K_(()=>l).check(B.minLength(1,`Messages array must not be empty`)))});async function J_({messages:e,metadataSchema:t,dataSchemas:n,tools:r,experimental_refineToolInput:i},{convertMissingTerminalToolsToDynamic:a}){try{if(e==null)return{success:!1,error:new Ug({parameter:`messages`,value:e,message:`messages parameter must be provided`})};let o=await Zh({value:e,schema:q_});if(O_(o),t)for(let[e,n]of o.entries())n.metadata=await Zh({value:n.metadata,schema:t,context:{field:`messages[${e}].metadata`,entityId:n.id}});let s=r!=null||a;if(n||s)for(let[e,t]of o.entries())for(let[o,c]of t.parts.entries()){if(n&&c.type.startsWith(`data-`)){let t=c,r=t.type.slice(5),i=n[r];if(!i)return{success:!1,error:new dm({value:t.data,cause:`No data schema found for data part ${r}`,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})};t.data=await Zh({value:t.data,schema:i,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})}if(s&&c.type.startsWith(`tool-`)){let n=c,s=n.type.slice(5),l=r==null?void 0:e_(r,s),u=n.state===`output-available`||n.state===`output-error`||n.state===`output-denied`;if(!l&&u){(r!=null||a)&&(t.parts[o]=W_(n));continue}if(!l)return{success:!1,error:new dm({value:n.input,cause:`No tool schema found for tool part ${s}`,context:{field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId}})};let d={field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId},f=G_(n),p=f==null?n.input:f.value,m=!1;if(n.state!==`input-streaming`&&(n.state!==`output-error`||f!=null||n.input!==void 0)){let e=await Qh({value:p,schema:l.inputSchema,context:d}),t;if(!e.success)t=e.error;else if(f!=null)try{let r=e_(i,s);t_(r==null?e.value:await r(e.value),n.input)||(t=new dm({value:n.input,cause:`Tool input does not match the output reconstructed from inputSchemaInput.`,context:d}))}catch(e){t=new dm({value:p,cause:e,context:d})}if(t!=null)if(n.state===`output-error`||n.state===`output-available`&&U_(n.input))m=!0;else throw t}n.state===`output-available`&&l.outputSchema&&await Zh({value:n.output,schema:l.outputSchema,context:{field:`messages[${e}].parts[${o}].output`,entityName:s,entityId:n.toolCallId}}),m&&(t.parts[o]=W_(n))}}return{success:!0,data:o}}catch(e){return{success:!1,error:e}}}async function Y_(e){return J_(e,{convertMissingTerminalToolsToDynamic:!1})}async function X_(e){let t=await Y_(e);if(!t.success)throw t.error;return t.data}Am({prefix:`call`,size:24}),Am({prefix:`call`,size:24}),new TextEncoder,Am({prefix:`call`,size:24}),Am({prefix:`call`,size:24}),Am({prefix:`aiobj`,size:24});var{atob:iee}=globalThis,Z_=class{constructor(){this.queue=[],this.isProcessing=!1,this.idleWaiters=[]}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;this.queue.length>0;)await this.queue[0](),this.queue.shift()}finally{this.isProcessing=!1;for(let e of this.idleWaiters.splice(0))e()}}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}async waitForIdle(){!this.isProcessing&&this.queue.length===0||await new Promise(e=>{this.idleWaiters.push(e)})}};Am({prefix:`aiobj`,size:24}),Am({prefix:`call`,size:24});var Q_=V.union([V.string(),V.custom(Dm,{message:`Must be a Uint8Array`}),V.custom(Om,{message:`Must be an ArrayBuffer`}),V.custom(Mm,{message:`Must be a Buffer`})]),$_=V.record(V.string(),V.string()),ev=V.object({type:V.literal(`text`),text:V.string(),providerOptions:H.optional()}),tv=V.object({type:V.literal(`image`),image:V.union([Q_,V.instanceof(URL),$_]),mediaType:V.string().optional(),providerOptions:H.optional()}),nv=V.discriminatedUnion(`type`,[V.object({type:V.literal(`data`),data:Q_}),V.object({type:V.literal(`url`),url:V.instanceof(URL)}),V.object({type:V.literal(`reference`),reference:$_}),V.object({type:V.literal(`text`),text:V.string()})]),rv=V.discriminatedUnion(`type`,[V.object({type:V.literal(`data`),data:Q_}),V.object({type:V.literal(`url`),url:V.instanceof(URL)})]),iv=V.object({type:V.literal(`file`),data:V.union([nv,Q_,V.instanceof(URL),$_]),filename:V.string().optional(),mediaType:V.string(),providerOptions:H.optional()}),av=V.object({type:V.literal(`reasoning`),text:V.string(),providerOptions:H.optional()}),ov=V.object({type:V.literal(`custom`),kind:V.string().transform(e=>e),providerOptions:H.optional()}),sv=V.object({type:V.literal(`reasoning-file`),data:V.union([rv,Q_,V.instanceof(URL)]),mediaType:V.string(),providerOptions:H.optional()}),cv=V.object({type:V.literal(`tool-call`),toolCallId:V.string(),toolName:V.string(),input:V.unknown(),providerOptions:H.optional(),providerExecuted:V.boolean().optional()}),lv=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),value:V.string(),providerOptions:H.optional()}),V.object({type:V.literal(`json`),value:c_,providerOptions:H.optional()}),V.object({type:V.literal(`execution-denied`),reason:V.string().optional(),providerOptions:H.optional()}),V.object({type:V.literal(`error-text`),value:V.string(),providerOptions:H.optional()}),V.object({type:V.literal(`error-json`),value:c_,providerOptions:H.optional()}),V.object({type:V.literal(`content`),value:V.array(V.union([V.object({type:V.literal(`text`),text:V.string(),providerOptions:H.optional()}),V.object({type:V.literal(`file`),data:nv,mediaType:V.string(),filename:V.string().optional(),providerOptions:H.optional()}),V.object({type:V.literal(`file-data`),data:V.string(),mediaType:V.string(),filename:V.string().optional(),providerOptions:H.optional()}),V.object({type:V.literal(`file-url`),url:V.string(),mediaType:V.string().optional(),providerOptions:H.optional()}),V.object({type:V.literal(`file-id`),fileId:V.union([V.string(),V.record(V.string(),V.string())]),providerOptions:H.optional()}),V.object({type:V.literal(`file-reference`),providerReference:V.record(V.string(),V.string()),providerOptions:H.optional()}),V.object({type:V.literal(`image-data`),data:V.string(),mediaType:V.string(),providerOptions:H.optional()}),V.object({type:V.literal(`image-url`),url:V.string(),providerOptions:H.optional()}),V.object({type:V.literal(`image-file-id`),fileId:V.union([V.string(),V.record(V.string(),V.string())]),providerOptions:H.optional()}),V.object({type:V.literal(`image-file-reference`),providerReference:V.record(V.string(),V.string()),providerOptions:H.optional()}),V.object({type:V.literal(`custom`),providerOptions:H.optional()})]))})]),uv=V.object({type:V.literal(`tool-result`),toolCallId:V.string(),toolName:V.string(),output:lv,providerOptions:H.optional()}),dv=V.object({type:V.literal(`tool-approval-request`),approvalId:V.string(),toolCallId:V.string(),reason:V.string().optional(),isAutomatic:V.boolean().optional(),signature:V.string().optional(),inputSchemaInput:V.unknown().optional()}),fv=V.object({type:V.literal(`tool-approval-response`),approvalId:V.string(),approved:V.boolean(),reason:V.string().optional()}),pv=V.object({role:V.literal(`system`),content:V.string(),providerOptions:H.optional()}),mv=V.object({role:V.literal(`user`),content:V.union([V.string(),V.array(V.union([ev,tv,iv]))]),providerOptions:H.optional()}),hv=V.object({role:V.literal(`assistant`),content:V.union([V.string(),V.array(V.union([ev,ov,iv,av,sv,cv,uv,dv]))]),providerOptions:H.optional()}),gv=V.object({role:V.literal(`tool`),content:V.array(V.union([uv,fv])),providerOptions:H.optional()});V.union([pv,mv,hv,gv]),B.object({token:B.string().check(B.refine(e=>e.trim().length>0)),url:B.string().check(B.refine(e=>{try{let t=new URL(e);return(t.protocol===`ws:`||t.protocol===`wss:`)&&t.hostname!==``}catch{return!1}})),expiresAt:B.optional(B.number().check(B.positive()).check(B.maximum(2**53-1))),tools:B.optional(B.array(B.object({type:B.literal(`function`),name:B.string().check(B.minLength(1)),description:B.optional(B.string()),parameters:B.record(B.string(),B.unknown())})))}),Am({prefix:`call`,size:24}),Am({prefix:`call`,size:24}),Am({prefix:`call`,size:24});async function _v({response:e,url:t,fallbackMessage:n}){let r=await e.text();return new Jp({message:r||n,url:t,requestBodyValues:void 0,statusCode:e.status,responseBody:r})}async function vv(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new hm({functionality:`FileList`,message:`FileList is not supported in the current environment`});return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}function yv(e,t){let n=e.search(/[?#]/),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n);return`${r.endsWith(`/`)&&t.startsWith(`/`)?r.slice(0,-1):r}${t}${i}`}var bv=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await tg(this.body),r=await tg(this.headers),i=await tg(this.credentials),a={...km(r),...km(t.headers)},o=await this.prepareSendMessagesRequest?.({api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:km(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"content-type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw await _v({response:d,url:s,fallbackMessage:`Failed to fetch the chat response.`});if(!d.body)throw new Qp({message:`The response body is empty.`});return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await tg(this.body),n=await tg(this.headers),r=await tg(this.credentials),i={...km(n),...km(e.headers)},a=await this.prepareReconnectToStreamRequest?.({api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api;if(o==null){if(e.chatId===`.`||e.chatId===`..`)throw new Ug({parameter:`chatId`,value:e.chatId,message:`Chat IDs must not be "." or ".." when using the default reconnect URL.`});o=yv(this.api,`/${encodeURIComponent(e.chatId)}/stream`)}let s=a?.headers===void 0?i:km(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c,signal:e.abortSignal});if(l.status===204)return null;if(!l.ok)throw await _v({response:l,url:o,fallbackMessage:`Failed to fetch the chat response.`});if(!l.body)throw new Qp({message:`The response body is empty.`});return this.processResponseStream(l.body)}},xv=class extends bv{constructor({resumeStreamIsReplay:e=!0,...t}={}){super(t),this.resumeStreamIsReplay=e}processResponseStream(e){return eg({stream:e,schema:f_}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},Sv=class{get id(){return this._id??=this.generateId()}constructor({generateId:e=jm,id:t,transport:n=new xv,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u,experimental_queue:d=!1}){this.queuedMessagesFallback=[],this.queuedMessageOptions=new Map,this.isQueuePaused=!1,this.pendingAutomaticDecisions=[],this.pendingMessagePreparations=new Set,this.interruptedMessageIds=new Set,this.activeResponse=void 0,this.activeResumeRequest=void 0,this.resumableStreamState=void 0,this.jobExecutor=new Z_,this.activeStopCount=0,this.stopGeneration=0,this.experimental_removeQueuedMessage=e=>{this.queuedMessageOptions.delete(e),this.setQueuedMessages(this.experimental_queuedMessages.filter(t=>t.id!==e))},this.experimental_sendQueuedMessageNow=async e=>{let t=this.experimental_queuedMessages.find(t=>t.id===e);if(t==null)return;this.setQueuedMessages([t,...this.experimental_queuedMessages.filter(t=>t.id!==e)]);let n=this.stopGeneration+1;await this.stop(),n===this.stopGeneration&&await this.resumeQueue({skipWaitForUser:!0,options:this.queuedMessageOptions.get(e)})},this.sendMessage=async(e,t)=>{if(e==null){let e=this.pendingApprovalMessageId;if(e==null){e=this.lastMessage?.id;for(let t=this.state.messages.length-1;t>=0;t--){let n=this.state.messages[t];if(n.role===`assistant`&&n.parts.some(e=>y_(e)&&e.state===`approval-responded`)){e=n.id;break}}}let n=e!=null&&e===this.pendingApprovalMessageId?this.state.messages.findIndex(t=>t.id===e):-1;await this.makeRequestForToolApproval({messageId:e,messageIndex:n,...t});return}let n;if(`text`in e||`files`in e){let t=new AbortController;this.pendingMessagePreparations.add(t);let r;try{r=Array.isArray(e.files)?e.files:await vv(e.files)}finally{this.pendingMessagePreparations.delete(t)}if(t.signal.aborted)return;n={parts:[...r,...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}}else n=e;if(this.queueEnabled&&e.messageId==null&&(this.isRequestInProgress()||this.isWaitingForUser()||this.experimental_queuedMessages.length>0)){let r={...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata};t!=null&&this.queuedMessageOptions.set(r.id,t),this.setQueuedMessages([...this.experimental_queuedMessages,r]),await this.resumeQueue({skipWaitForUser:this.isQueuePaused,options:t});return}if(e.messageId!=null){await this.clearQueueForHistoryChange();let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw new Ug({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} not found`});if(this.state.messages[t].role!==`user`)throw new Ug({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} is not a user message`});this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{id:e.messageId,...n,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});this.isQueuePaused=!1,await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{await this.clearQueueForHistoryChange();let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw new Ug({parameter:`messageId`,value:e,message:`message ${e} not found`});this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this[`~resumeStreamIfDisconnected`]=async({shouldResume:e=()=>!0}={})=>{let t=this.activeResponse;this.resumableStreamState==null&&t!=null&&(await t.completionPromise,this.resumableStreamState!==t.state)||this.resumableStreamState!=null&&e()&&await this.resumeStream()},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.stopGeneration,a=this.state.messages,o=r=>y_(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{...r.approval,id:e,approved:t,reason:n}}:r,s=a.findIndex(t=>t.parts.some(t=>y_(t)&&t.state===`approval-requested`&&t.approval.id===e));if(s!==-1){let e=a[s];this.state.replaceMessage(s,{...e,parts:e.parts.map(o)}),this.pendingApprovalMessageId=e.id}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),s!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(a[s].id);if(e){this.runAutomaticRequest(()=>{let e=s===-1?this.lastMessage?.id:a[s].id;return this.makeRequestForToolApproval({messageId:e,messageIndex:s,...r})},e);return}}this.settleQueue({stopGeneration:i})}),this.addToolOutput=async({state:e,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.stopGeneration,o=this.state.messages,s=i=>{if(!y_(i)||i.toolCallId!==t)return i;let{approval:a,...o}=i,s=a?.approved===!0?{approval:{...a,approved:a.approved}}:{};return e===`output-error`?{...o,...s,state:e,input:i.input,output:void 0,errorText:r}:{...o,...s,state:`output-available`,input:i.input,output:n,errorText:void 0}},c=o.findIndex(e=>e.parts.some(e=>y_(e)&&e.toolCallId===t));if(c!==-1){let e=o[c];this.state.replaceMessage(c,{...e,parts:e.parts.map(s)})}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),c!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(o[c].id);if(e){this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:o[c].id,...i}),e);return}}this.settleQueue({stopGeneration:a})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{this.activeStopCount++,this.stopGeneration++,this.deferredApprovalSend=void 0;try{let e=this.activeResumeRequest,t=this.activeResponse;for(let e of this.pendingMessagePreparations)e.abort();e?.abortController.abort(),t?.abortController.abort(),await Promise.all([e?.completionPromise,t?.completionPromise]),await this.jobExecutor.waitForIdle(),this.isQueuePaused=!0}finally{this.activeStopCount--}},this.dispose=async()=>{await this.stop(),this.transport.close?.()},this._id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u,this.queueEnabled=d}get status(){return this.state.status}setStatus({status:e,error:t}){if(this.status===e){this.error!==t&&(this.state.error=t);return}this.state.status=e,this.state.error=t}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}get experimental_queuedMessages(){return this.state.experimental_queuedMessages??this.queuedMessagesFallback}setQueuedMessages(e){`experimental_queuedMessages`in this.state?this.state.experimental_queuedMessages=e:this.queuedMessagesFallback=e}async resumeQueue({skipWaitForUser:e,options:t}){if(this.isQueuePaused=!1,this.hasUnsentApprovalResponse()){if(!this.isRequestInProgress()){await this.sendMessage(void 0,t);return}this.deferredApprovalSend={options:t}}await this.settleQueue({skipWaitForUser:e})}async clearQueueForHistoryChange(){this.queueEnabled&&(this.queuedMessageOptions.clear(),this.setQueuedMessages([]),this.deferredApprovalSend=void 0,this.isRequestInProgress()&&await this.stop())}isRequestInProgress(){return this.pendingAutomaticDecisions.includes(this.stopGeneration)||this.activeResponse!=null||this.status===`submitted`||this.status===`streaming`}isWaitingForUser(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>y_(e)&&(e.state===`approval-requested`||e.state===`approval-responded`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}hasUnsentApprovalResponse(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>y_(e)&&e.state===`approval-responded`)&&!e.parts.some(e=>y_(e)&&(e.state===`approval-requested`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}async settleQueue({stopGeneration:e=this.stopGeneration,skipWaitForUser:t=!1}={}){if(this.isQueuePaused||this.isRequestInProgress()||this.activeStopCount>0||e!==this.stopGeneration)return;let n=this.deferredApprovalSend;if(this.deferredApprovalSend=void 0,n!=null&&this.hasUnsentApprovalResponse()){await this.sendMessage(void 0,n.options);return}let[r,...i]=this.experimental_queuedMessages;if(r==null||!t&&this.isWaitingForUser())return;let a=this.queuedMessageOptions.get(r.id);this.queuedMessageOptions.delete(r.id),this.setQueuedMessages(i),this.state.pushMessage(r),await this.makeRequest({trigger:`submit-message`,...a})}set messages(e){this.state.messages=e}async shouldSendAutomatically(e=this.lastMessage?.id){let t=e=>e!=null&&this.interruptedMessageIds.has(e);if(!this.sendAutomaticallyWhen||t(e)||t(this.lastMessage?.id))return!1;let n=this.stopGeneration;this.pendingAutomaticDecisions.push(n);let r;try{r=await this.sendAutomaticallyWhen({messages:this.state.messages})}finally{this.pendingAutomaticDecisions.splice(this.pendingAutomaticDecisions.indexOf(n),1)}return r&&!t(e)&&!t(this.lastMessage?.id)}async runAutomaticRequest(e,t){let n=this.stopGeneration,r=this.activeStopCount>0;return!(t??await this.shouldSendAutomatically())||r||n!==this.stopGeneration||this.activeStopCount>0?!1:(await e(),!0)}async makeRequestForToolApproval({messageId:e,messageIndex:t,...n}){this.deferredApprovalSend=void 0;let r=e!=null&&e===this.pendingApprovalMessageId;r&&(this.pendingApprovalMessageId=void 0),await this.makeRequest({trigger:`submit-message`,messageId:e,...n}),r&&this.status===`error`&&this.pendingApprovalMessageId==null&&(this.pendingApprovalMessageId=this.state.messages[t]?.id??e)}async makeRequest(e){let t=T_();try{await this.makeRequestImpl({...e,completionPromise:t.promise})}finally{t.resolve()}}async makeRequestImpl({trigger:e,metadata:t,headers:n,body:r,messageId:i,completionPromise:a}){e!==`resume-stream`&&(this.resumableStreamState=void 0);let o=new AbortController,s=e===`resume-stream`?{abortController:o,completionPromise:a}:void 0;s&&(this.activeResumeRequest?.abortController.abort(),this.activeResumeRequest=s);let c=()=>s==null||this.activeResumeRequest===s,l=()=>{this.activeResumeRequest===s&&(this.activeResumeRequest=void 0)},u;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,abortSignal:o.signal,metadata:t,headers:n,body:r});if(o.signal.aborted||!c()){await e?.cancel().catch(()=>{}),c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(e==null){this.setStatus({status:`ready`}),this.resumableStreamState=void 0,l();return}u=e}catch(e){if(o.signal.aborted||e.name===`AbortError`){c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(!c())return;this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e}),l();return}this.setStatus({status:`submitted`,error:void 0});let d=this.lastMessage,f=e===`submit-message`&&i!=null?this.state.messages.findIndex(e=>e.id===i):this.state.messages.length-1,p=f===-1?d:this.state.messages[f],m=p?.id,h=e===`resume-stream`&&p?.role===`assistant`&&p.parts.some(e=>y_(e)&&(e.state===`input-streaming`||e.state===`input-available`&&e.providerExecuted||e.state===`approval-responded`))?this.state.snapshot(p):void 0,g=f!==-1&&f<this.state.messages.length-1&&p?.role===`assistant`,_=!1,v=!1,y=!1,b;try{let s={state:e===`resume-stream`&&this.resumableStreamState!=null?this.resumableStreamState:S_({lastMessage:e===`resume-stream`?h:e===`regenerate-message`?void 0:this.state.snapshot(p),messageId:this.generateId()}),abortController:o,completionPromise:a};b=s,s.abortController.signal.addEventListener(`abort`,()=>{_=!0}),this.activeResponse=s;let l;if(l=e===`resume-stream`?u:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:s.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await w_({stream:C_({stream:l,resetStateOnMessageIdChange:e===`resume-stream`,resetStateOnFirstMessageStart:e===`resume-stream`&&this.transport.resumeStreamIsReplay,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>s.abortController.signal.aborted?Promise.resolve():e({state:s.state,write:({updateStatus:e=!0}={})=>{if(s.abortController.signal.aborted)return;e&&this.setStatus({status:`streaming`});let t=this.state.messages.findLastIndex(e=>e.id===s.state.message.id);if(t!==-1)this.state.replaceMessage(t,s.state.message);else if(g){let e=this.state.messages.findLastIndex(e=>e.id===m);e===-1?this.state.pushMessage(s.state.message):this.state.replaceMessage(e,s.state.message)}else this.state.pushMessage(s.state.message)}})),onError:e=>{throw e}}),abortSignal:s.abortController.signal,onError:e=>{throw e}}),_)return c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0)),null;c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0))}catch(e){if(_||e.name===`AbortError`)return _=!0,c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0)),null;if(!c())return null;if(y=!0,e instanceof TypeError){let t=e.message.toLowerCase();v=t.includes(`fetch`)||t.includes(`network`)||t===`load failed`}v?this.resumableStreamState=b?.state:this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{if(b){let{message:e,finishReason:t}=b.state;t===`interrupted`?this.interruptedMessageIds.add(e.id):!_&&!y&&this.interruptedMessageIds.delete(e.id),this.onFinish?.({message:b.state.message,messages:this.state.messages,isAbort:_,isDisconnect:v,isError:y,finishReason:b.state.finishReason})}}finally{(_||y||b?.state.finishReason===`interrupted`)&&(this.isQueuePaused=!0),this.activeResponse===b&&(this.activeResponse=void 0),l()}}if(!_&&!y&&b?.state.finishReason!==`interrupted`){let e=this.stopGeneration;await this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r}))||await this.settleQueue({stopGeneration:e})}}};function Cv({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1).filter(y_);return r.filter(e=>e.state===`approval-responded`).length>0&&r.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`||e.state===`output-denied`||e.state===`approval-responded`)}function wv({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1),i=r.filter(y_).filter(e=>!e.providerExecuted),a=r.reduce((e,t,n)=>y_(t)&&!t.providerExecuted?n:e,-1);return i.length>0&&!r.slice(a+1).some(e=>e.type===`text`&&e.state!==`done`)&&i.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`)}var Tv=n(a(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n}))(),1);function Ev(e,t){return t==null?e:(0,Tv.default)(e,t)}function Dv(e){return Array.isArray(e)?[...e]:typeof e==`object`&&e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)?{...e}:e}var Ov=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e=[]){this.#t=`ready`,this.#n=void 0,this.#r=[],this.#i=new Set,this.#a=new Set,this.#o=new Set,this.#s=new Set,this.pushMessage=e=>{this.#e=this.#e.concat(e),this.#c()},this.popMessage=()=>{this.#e=this.#e.slice(0,-1),this.#c()},this.replaceMessage=(e,t)=>{this.#e=[...this.#e.slice(0,e),this.snapshot(t),...this.#e.slice(e+1)],this.#c()},this.snapshot=e=>{if(typeof e!=`object`||!e||!(`parts`in e)||!Array.isArray(e.parts))return e;let t=e,n={...t,parts:t.parts.map(e=>({...e}))};return`metadata`in t&&(n.metadata=Dv(t.metadata)),n},this[`~registerMessagesCallback`]=(e,t)=>{let n=t?Ev(e,t):e;return this.#i.add(n),()=>{this.#i.delete(n)}},this[`~registerStatusCallback`]=e=>(this.#o.add(e),()=>{this.#o.delete(e)}),this[`~registerErrorCallback`]=e=>(this.#s.add(e),()=>{this.#s.delete(e)}),this[`~registerQueuedMessagesCallback`]=e=>(this.#a.add(e),()=>{this.#a.delete(e)}),this.#c=()=>{this.#i.forEach(e=>e())},this.#l=()=>{this.#o.forEach(e=>e())},this.#u=()=>{this.#s.forEach(e=>e())},this.#e=e}get status(){return this.#t}set status(e){this.#t=e,this.#l()}get error(){return this.#n}set error(e){this.#n=e,this.#u()}get experimental_queuedMessages(){return this.#r}set experimental_queuedMessages(e){this.#r=e,this.#a.forEach(e=>e())}get messages(){return this.#e}set messages(e){this.#e=[...e],this.#c()}#c;#l;#u},kv=class extends Sv{#e;constructor({messages:e,...t}){let n=new Ov(e);super({...t,state:n}),this[`~registerMessagesCallback`]=(e,t)=>this.#e[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>this.#e[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>this.#e[`~registerErrorCallback`](e),this[`~registerQueuedMessagesCallback`]=e=>this.#e[`~registerQueuedMessagesCallback`](e),this.#e=n}},Av=new WeakMap;function jv({chat:e,state:t}){if(document.visibilityState!==`visible`||t.pendingVisibilityResume!=null)return;let n=()=>Av.get(e)===t&&t.registrations.size>0,r=()=>{t.pendingVisibilityResume=void 0};t.pendingVisibilityResume=e[`~resumeStreamIfDisconnected`]({shouldResume:()=>n()&&document.visibilityState===`visible`}).then(r,r)}function Mv({chat:e,registration:t}){let n=Av.get(e);if(n==null){let t={registrations:new Set};if(Av.set(e,t),n=t,typeof document<`u`){let n=()=>jv({chat:e,state:t});document.addEventListener(`visibilitychange`,n),t.cleanupVisibilityListener=()=>{document.removeEventListener(`visibilitychange`,n)}}}let{registrations:r}=n,i=r.size===0;return r.add(t),i&&e.status!==`submitted`&&e.status!==`streaming`&&e.resumeStream(),()=>{r.delete(t),r.size===0&&(n.cleanupVisibilityListener?.(),Av.delete(e))}}function Nv(e){return{chat:e,messages:e.messages,status:e.status,error:e.error,experimental_queuedMessages:e.experimental_queuedMessages}}function Pv(e,t){return e.chat===t.chat&&e.messages===t.messages&&e.status===t.status&&e.error===t.error&&e.experimental_queuedMessages===t.experimental_queuedMessages}function Fv({throttle:e,experimental_throttle:t,resume:n=!1,...r}={}){let i=e??t,a=(0,I.useRef)({}),o=(0,I.useRef)({});`chat`in r||(o.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen,transport:r.transport});let s,c=()=>o.current.transport??(s??=new xv),l={...r,transport:{get resumeStreamIsReplay(){return c().resumeStreamIsReplay},sendMessages:e=>c().sendMessages(e),reconnectToStream:e=>c().reconnectToStream(e)},onToolCall:e=>o.current.onToolCall?.(e),onData:e=>o.current.onData?.(e),onFinish:e=>o.current.onFinish?.(e),onError:e=>o.current.onError?.(e),sendAutomaticallyWhen:e=>o.current.sendAutomaticallyWhen?.(e)??!1},{chat:u,isExternallyManaged:d}=(0,I.useMemo)(()=>({chat:`chat`in r?r.chat:new kv(l),isExternallyManaged:`chat`in r}),[`chat`in r?r.chat:r.id]);(0,I.useEffect)(()=>{if(!d)return()=>{u.stop()}},[u,d]);let[f,p]=(0,I.useState)(()=>Nv(u));f.chat!==u&&p(Nv(u)),(0,I.useEffect)(()=>{let e=!0,t=()=>{if(!e)return;let t=Nv(u);p(e=>e.chat!==u||Pv(e,t)?e:t)},n=[u[`~registerMessagesCallback`](t,i),u[`~registerStatusCallback`](t),u[`~registerErrorCallback`](t),u[`~registerQueuedMessagesCallback`](t)],r=Nv(u);return p(e=>Pv(e,r)?e:r),()=>{e=!1,n.forEach(e=>e())}},[u,i]);let{messages:m,status:h,error:g,experimental_queuedMessages:_}=f,v=(0,I.useCallback)(e=>{typeof e==`function`&&(e=e(u.messages)),u.messages=e},[u]);return(0,I.useEffect)(()=>{if(n)return Mv({chat:u,registration:a.current})},[n,u]),{get id(){return u.id},messages:m,setMessages:v,sendMessage:u.sendMessage,regenerate:u.regenerate,clearError:u.clearError,stop:u.stop,error:g,resumeStream:u.resumeStream,status:h,addToolResult:u.addToolOutput,addToolOutput:u.addToolOutput,addToolApprovalResponse:u.addToolApprovalResponse,experimental_queuedMessages:_,experimental_removeQueuedMessage:u.experimental_removeQueuedMessage,experimental_sendQueuedMessageNow:u.experimental_sendQueuedMessageNow}}var Iv=a(((e,t)=>{(function(n,r){typeof i==`function`&&typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(function(){return r()}):n.pluralize=r()})(e,function(){var e=[],t=[],n={},r={},i={};function a(e){return typeof e==`string`?RegExp(`^`+e+`$`,`i`):e}function o(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||``})}function c(e,t){return e.replace(t[0],function(n,r){var i=s(t[1],arguments);return o(n===``?e[r-1]:n,i)})}function l(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var a=r[i];if(a[0].test(t))return c(t,a)}return t}function u(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?o(r,i):e.hasOwnProperty(i)?o(r,e[i]):l(i,r,n)}}function d(e,t,n,r){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?!0:!e.hasOwnProperty(i)&&l(i,i,n)===i}}function f(e,t,n){var r=t===1?f.singular(e):f.plural(e);return(n?t+` `:``)+r}return f.plural=u(i,r,e),f.isPlural=d(i,r,e),f.singular=u(r,i,t),f.isSingular=d(r,i,t),f.addPluralRule=function(t,n){e.push([a(t),n])},f.addSingularRule=function(e,n){t.push([a(e),n])},f.addUncountableRule=function(e){if(typeof e==`string`){n[e.toLowerCase()]=!0;return}f.addPluralRule(e,`$0`),f.addSingularRule(e,`$0`)},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[[`I`,`we`],[`me`,`us`],[`he`,`they`],[`she`,`they`],[`them`,`them`],[`myself`,`ourselves`],[`yourself`,`yourselves`],[`itself`,`themselves`],[`herself`,`themselves`],[`himself`,`themselves`],[`themself`,`themselves`],[`is`,`are`],[`was`,`were`],[`has`,`have`],[`this`,`these`],[`that`,`those`],[`echo`,`echoes`],[`dingo`,`dingoes`],[`volcano`,`volcanoes`],[`tornado`,`tornadoes`],[`torpedo`,`torpedoes`],[`genus`,`genera`],[`viscus`,`viscera`],[`stigma`,`stigmata`],[`stoma`,`stomata`],[`dogma`,`dogmata`],[`lemma`,`lemmata`],[`schema`,`schemata`],[`anathema`,`anathemata`],[`ox`,`oxen`],[`axe`,`axes`],[`die`,`dice`],[`yes`,`yeses`],[`foot`,`feet`],[`eave`,`eaves`],[`goose`,`geese`],[`tooth`,`teeth`],[`quiz`,`quizzes`],[`human`,`humans`],[`proof`,`proofs`],[`carve`,`carves`],[`valve`,`valves`],[`looey`,`looies`],[`thief`,`thieves`],[`groove`,`grooves`],[`pickaxe`,`pickaxes`],[`passerby`,`passersby`]].forEach(function(e){return f.addIrregularRule(e[0],e[1])}),[[/s?$/i,`s`],[/[^\u0000-\u007F]$/i,`$0`],[/([^aeiou]ese)$/i,`$1`],[/(ax|test)is$/i,`$1es`],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,`$1es`],[/(e[mn]u)s?$/i,`$1s`],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,`$1`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1i`],[/(alumn|alg|vertebr)(?:a|ae)$/i,`$1ae`],[/(seraph|cherub)(?:im)?$/i,`$1im`],[/(her|at|gr)o$/i,`$1oes`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,`$1a`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,`$1a`],[/sis$/i,`ses`],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,`$1$2ves`],[/([^aeiouy]|qu)y$/i,`$1ies`],[/([^ch][ieo][ln])ey$/i,`$1ies`],[/(x|ch|ss|sh|zz)$/i,`$1es`],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,`$1ices`],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,`$1ice`],[/(pe)(?:rson|ople)$/i,`$1ople`],[/(child)(?:ren)?$/i,`$1ren`],[/eaux$/i,`$0`],[/m[ae]n$/i,`men`],[`thou`,`you`]].forEach(function(e){return f.addPluralRule(e[0],e[1])}),[[/s$/i,``],[/(ss)$/i,`$1`],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,`$1fe`],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,`$1f`],[/ies$/i,`y`],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,`$1ie`],[/\b(mon|smil)ies$/i,`$1ey`],[/\b((?:tit)?m|l)ice$/i,`$1ouse`],[/(seraph|cherub)im$/i,`$1`],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,`$1`],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,`$1sis`],[/(movie|twelve|abuse|e[mn]u)s$/i,`$1`],[/(test)(?:is|es)$/i,`$1is`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1us`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,`$1um`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,`$1on`],[/(alumn|alg|vertebr)ae$/i,`$1a`],[/(cod|mur|sil|vert|ind)ices$/i,`$1ex`],[/(matr|append)ices$/i,`$1ix`],[/(pe)(rson|ople)$/i,`$1rson`],[/(child)ren$/i,`$1`],[/(eau)x?$/i,`$1`],[/men$/i,`man`]].forEach(function(e){return f.addSingularRule(e[0],e[1])}),[`adulthood`,`advice`,`agenda`,`aid`,`aircraft`,`alcohol`,`ammo`,`analytics`,`anime`,`athletics`,`audio`,`bison`,`blood`,`bream`,`buffalo`,`butter`,`carp`,`cash`,`chassis`,`chess`,`clothing`,`cod`,`commerce`,`cooperation`,`corps`,`debris`,`diabetes`,`digestion`,`elk`,`energy`,`equipment`,`excretion`,`expertise`,`firmware`,`flounder`,`fun`,`gallows`,`garbage`,`graffiti`,`hardware`,`headquarters`,`health`,`herpes`,`highjinks`,`homework`,`housework`,`information`,`jeans`,`justice`,`kudos`,`labour`,`literature`,`machinery`,`mackerel`,`mail`,`media`,`mews`,`moose`,`music`,`mud`,`manga`,`news`,`only`,`personnel`,`pike`,`plankton`,`pliers`,`police`,`pollution`,`premises`,`rain`,`research`,`rice`,`salmon`,`scissors`,`series`,`sewage`,`shambles`,`shrimp`,`software`,`species`,`staff`,`swine`,`tennis`,`traffic`,`transportation`,`trout`,`tuna`,`wealth`,`welfare`,`whiting`,`wildebeest`,`wildlife`,`you`,/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f})})),Lv=a(((e,t)=>{function n(e){return e=String(e),e&&e.toLowerCase()}n.isLowercase=function(e){return e&&!/[A-Z]+/.test(e)},t.exports=n})),Rv=a(((e,t)=>{function n(e){return e=String(e),e&&e.toUpperCase()}n.isUppercase=function(e){return e&&!/[a-z]+/.test(e)},t.exports=n})),zv=a(((e,t)=>{var n=Lv(),r=Rv(),i={from:/[\-_:\.\s]([a-zA-Z])([a-zA-Z]*)/g,to:function(e,t,n,i,a){return t.length,r(t)+n}};function a(e){return a.isCamelcase(e)||(e=String(e).replace(/^[\-_:\.\s]/,``),!e)?e:(r.isUppercase(e)&&(e=n(e)),n(e[0])+e.replace(i.from,i.to).slice(1).replace(/^([A-Z]+)([A-Z])/,function(e,t,r){return n(t)+r}))}a.isCamelcase=function(e){return e&&/^[a-zA-Z]+$/.test(e)&&n(e[0])===e[0]},t.exports=a})),Bv=a(((e,t)=>{var n=Rv();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),Vv=a(((e,t)=>{var n=Lv(),r=Rv(),i=`_`,a={from:/([A-Z]+)/g,to:function(e,t,a,o){var s=a===0?``:i,c=t.length;if(c===1)return s+n(t);var l=o.slice(a+t.length);return r.isUppercase(t)&&l[0]===i?s+n(t):s+(n(t.substr(0,c-1))+i+n(t[c-1]))}};function o(e){return o.isSnakecase(e)||(e=String(e).replace(/[\-.:\s]/g,i),!e)?e:(r.isUppercase(e)&&(e=n(e)),e.replace(a.from,a.to).replace(/_+/g,`_`))}o.isSnakecase=function(e){return e&&/^[a-z_]+$/.test(e)},t.exports=o})),Hv=a(((e,t)=>{var n=Rv(),r=Vv();function i(e){return i.isConstcase(e)?e:n(r(e))}i.isConstcase=function(e){return e&&/^[A-Z_]+$/.test(e)},t.exports=i})),Uv=a(((e,t)=>{var n=Vv();function r(e){return n(e).replace(/_/g,``)}t.exports=r})),Wv=a(((e,t)=>{var n=Lv();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),Gv=a(((e,t)=>{var n=Vv();function r(e){return n(e).replace(/_/g,`.`)}t.exports=r})),Kv=a(((e,t)=>{var n=Vv();function r(e){return n(e).replace(/_/g,`:`)}t.exports=r})),qv=a(((e,t)=>{var n=zv(),r=Bv();function i(e){return r(n(e))}t.exports=i})),Jv=a(((e,t)=>{var n=Vv();function r(e){return n(e).replace(/_/g,`/`)}t.exports=r})),Yv=a(((e,t)=>{function n(e){return String(e).trim()}t.exports=n})),Xv=a(((e,t)=>{Lv();var n=Yv(),r=Vv(),i=Bv(),a=` `;function o(e){return e=String(e).replace(/^[\-_\.\s]/g,a),e&&i(r(n(e)).replace(/_/g,a))}t.exports=o})),Zv=a(((e,t)=>{var n=Vv();function r(e){return n(e).replace(/_/g,` `)}t.exports=r})),Qv=a(((e,t)=>{var n=Vv();function r(e){return n(e).replace(/_/g,`-`)}t.exports=r})),$v=a(((e,t)=>{var n=Vv(),r=Lv(),i=Yv(),a=Bv(),o=`a,the,and,or,not,but,for,of`.split(`,`);function s(e){return n(e).split(/_/g).map(i).map(function(e){return~o.indexOf(e)?r(e):a(e)}).join(` `)}t.exports=s})),ey=a(((e,t)=>{var n=zv(),r=Bv(),i=Hv(),a=Uv(),o=Wv(),s=Gv(),c=Kv(),l=Lv(),u=qv(),d=Jv(),f=Xv(),p=Vv(),m=Zv(),h=Qv(),g=$v(),_=Yv(),v=Rv();e.camelcase=n,e.capitalcase=r,e.constcase=i,e.cramcase=a,e.decapitalcase=o,e.dotcase=s,e.enumcase=c,e.lowercase=l,e.pascalcase=u,e.pathcase=d,e.sentencecase=f,e.snakecase=p,e.spacecase=m,e.spinalcase=h,e.titlecase=g,e.trimcase=_,e.uppercase=v,t.exports={camelcase:n,capitalcase:r,constcase:i,cramcase:a,decapitalcase:o,dotcase:s,enumcase:c,lowercase:l,pascalcase:u,pathcase:d,sentencecase:f,snakecase:p,spacecase:m,spinalcase:h,titlecase:g,trimcase:_,uppercase:v}}));Iv(),ey();function ty(e){return typeof e==`object`&&!!e&&`name`in e&&(`data`in e||`codec`in e)&&typeof e.name==`string`}function ny(e){return ry(e,new WeakSet)}function ry(e,t){return typeof e==`object`?e===null||t.has(e)?!0:(t.add(e),Array.isArray(e)?e.every(e=>ry(e,t)):e instanceof Promise?!1:Symbol.asyncIterator in e||Symbol.iterator in e?!0:ty(e)?ry(e.data,t):Object.values(e).every(e=>ry(e,t))):typeof e!=`bigint`&&typeof e!=`symbol`}function iy(e){return!(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Promise||Symbol.asyncIterator in e||Symbol.iterator in e||ty(e))}function ay(e){return e.type===`message`}function oy(e){if(ty(e)){if(ay(e))throw Error(`Message fragments are not supported by serialized fragment conversion`);if(!e.codec)throw Error(`Fragment "${e.name}" is missing codec`);return e.codec.encode()}return Array.isArray(e)?e.map(e=>oy(e)):iy(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,oy(t)])):e}function sy(e,t){return{name:`term`,data:{name:e,definition:t},codec:{encode(){return{type:`term`,name:e,definition:t}},decode(){return{name:e,definition:t}}}}}function cy(e){return{name:`hint`,data:e,codec:{encode(){return{type:`hint`,text:e}},decode(){return e}}}}function ly(e){return{name:`guardrail`,data:{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}},codec:{encode(){return{type:`guardrail`,rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}},decode(){return{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}}}}}function uy(e){return{name:`explain`,data:{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}},codec:{encode(){return{type:`explain`,concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}},decode(){return{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}}}}}function dy(e){return{name:`example`,data:{question:e.question,answer:e.answer,...e.note&&{note:e.note}},codec:{encode(){return{type:`example`,question:e.question,answer:e.answer,...e.note&&{note:e.note}}},decode(){return{question:e.question,answer:e.answer,...e.note&&{note:e.note}}}}}}function fy(e){return{name:`clarification`,data:{when:e.when,ask:e.ask,reason:e.reason},codec:{encode(){return{type:`clarification`,when:e.when,ask:e.ask,reason:e.reason}},decode(){return{when:e.when,ask:e.ask,reason:e.reason}}}}}function py(e){return{name:`workflow`,data:{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}},codec:{encode(){return{type:`workflow`,task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}},decode(){return{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}}}}}function my(e){return{name:`quirk`,data:{issue:e.issue,workaround:e.workaround},codec:{encode(){return{type:`quirk`,issue:e.issue,workaround:e.workaround}},decode(){return{issue:e.issue,workaround:e.workaround}}}}}function hy(e){return{name:`styleGuide`,data:{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}},codec:{encode(){return{type:`styleGuide`,prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}},decode(){return{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}}}}}function gy(e){return{name:`analogy`,data:{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}},codec:{encode(){return{type:`analogy`,concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}},decode(){return{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}}}}}function _y(e){return{name:`glossary`,data:Object.entries(e).map(([e,t])=>({term:e,expression:t})),codec:{encode(){return{type:`glossary`,entries:e}},decode(){return Object.entries(e).map(([e,t])=>({term:e,expression:t}))}}}}function vy(e){return{name:`role`,data:e,codec:{encode(){return{type:`role`,content:e}},decode(){return e}}}}function yy(e){return{name:`principle`,data:{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`principle`,title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies.map(e=>oy(e))}}},decode(){return{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}}}}}}function by(e){return{name:`policy`,data:{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`policy`,rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies.map(e=>oy(e))}}},decode(){return{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}}}}}}function xy(e){return{name:`identity`,data:{...e.name&&{name:e.name},...e.role&&{role:e.role}},codec:{encode(){return{type:`identity`,...e.name&&{name:e.name},...e.role&&{role:e.role}}},decode(){return{...e.name&&{name:e.name},...e.role&&{role:e.role}}}}}}function Sy(e){return{name:`persona`,data:{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}},codec:{encode(){return{type:`persona`,name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}},decode(){return{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}}}}}function Cy(e,t){return{name:`alias`,data:{term:e,meaning:t},codec:{encode(){return{type:`alias`,term:e,meaning:t}},decode(){return{term:e,meaning:t}}}}}function wy(e,t){return{name:`preference`,data:{aspect:e,value:t},codec:{encode(){return{type:`preference`,aspect:e,value:t}},decode(){return{aspect:e,value:t}}}}}function Ty(e,t){return{name:`correction`,data:{subject:e,clarification:t},codec:{encode(){return{type:`correction`,subject:e,clarification:t}},decode(){return{subject:e,clarification:t}}}}}function Ey(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function Dy(e,t){if(Ey(e))return Ny(e,t);if(Array.isArray(e))return e.map(e=>Dy(e,t));if(iy(e))return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Dy(n,t)]));if(!ny(e))throw Error(`Unsupported serialized value of type ${typeof e}`);return e}function Oy(e,t){return{toFragment:(n,r)=>{let i=e.safeParse(n);if(!i.success)throw Error(`Invalid serialized ${n.type} fragment: ${it(i.error)}`);return t(i.data,r)}}}var ky=vt(kt()).optional(),Ay={term:Oy(N({name:F(),definition:F()}),e=>sy(e.name,e.definition)),hint:Oy(N({text:F()}),e=>cy(e.text)),guardrail:Oy(N({rule:F(),reason:F().optional(),action:F().optional()}),e=>ly({rule:e.rule,reason:e.reason,action:e.action})),explain:Oy(N({concept:F(),explanation:F(),therefore:F().optional()}),e=>uy({concept:e.concept,explanation:e.explanation,therefore:e.therefore})),example:Oy(N({question:F(),answer:F(),note:F().optional()}),e=>dy({question:e.question,answer:e.answer,note:e.note})),clarification:Oy(N({when:F(),ask:F(),reason:F()}),e=>fy({when:e.when,ask:e.ask,reason:e.reason})),workflow:Oy(N({task:F(),steps:vt(F()),triggers:vt(F()).optional(),notes:F().optional()}),e=>py({task:e.task,steps:e.steps,triggers:e.triggers,notes:e.notes})),quirk:Oy(N({issue:F(),workaround:F()}),e=>my({issue:e.issue,workaround:e.workaround})),styleGuide:Oy(N({prefer:F(),never:F().optional(),always:F().optional()}),e=>hy({prefer:e.prefer,never:e.never,always:e.always})),analogy:Oy(N({concepts:vt(F()),relationship:F(),insight:F().optional(),therefore:F().optional(),pitfall:F().optional()}),e=>gy({concepts:e.concepts,relationship:e.relationship,insight:e.insight,therefore:e.therefore,pitfall:e.pitfall})),glossary:Oy(N({entries:S(F(),F())}),e=>_y(e.entries)),role:Oy(N({content:F()}),e=>vy(e.content)),principle:Oy(N({title:F(),description:F(),policies:ky}),(e,t)=>yy({title:e.title,description:e.description,policies:e.policies?.map(e=>Dy(e,t))})),policy:Oy(N({rule:F(),before:F().optional(),reason:F().optional(),policies:ky}),(e,t)=>by({rule:e.rule,before:e.before,reason:e.reason,policies:e.policies?.map(e=>Dy(e,t))})),identity:Oy(N({name:F().optional(),role:F().optional()}),e=>xy({name:e.name,role:e.role})),persona:Oy(N({name:F(),role:F().optional(),objective:F().optional(),tone:F().optional()}),e=>Sy({name:e.name,role:e.role,objective:e.objective,tone:e.tone})),alias:Oy(N({term:F(),meaning:F()}),e=>Cy(e.term,e.meaning)),preference:Oy(N({aspect:F(),value:F()}),e=>wy(e.aspect,e.value)),correction:Oy(N({subject:F(),clarification:F()}),e=>Ty(e.subject,e.clarification))};function jy(e){return Object.hasOwn(Ay,e)}var My=new Set([`user`,`assistant`,`message`]);function Ny(e,t){if(My.has(e.type))throw Error(`Message fragments are not supported by serialized fragment conversion`);let n=t?.registry?.[e.type]??(jy(e.type)?Ay[e.type]:void 0);if(!n)throw Error(`Unsupported serialized fragment type: ${e.type}`);return n.toFragment(e,t)}function Py(e){let t=e?.reminders;return Array.isArray(t)?t.filter(e=>Nm(e)&&typeof e.partIndex==`number`&&typeof e.start==`number`&&typeof e.end==`number`):[]}function Fy(e,t){if(t.length===0)return e;let n=t.map(t=>({start:Math.max(0,Math.min(e.length,t.start)),end:Math.max(0,Math.min(e.length,t.end))})).filter(e=>e.end>e.start).sort((e,t)=>e.start-t.start);if(n.length===0)return e;let r=0,i=``;for(let t of n){if(t.start<r){t.end>r&&(r=t.end);continue}i+=e.slice(r,t.start),r=t.end}return i+=e.slice(r),i.trimEnd()}function Iy(e){if(Ly(e))return Ry(e);let t=Py(Nm(e.metadata)?e.metadata:void 0),n=new Map;for(let e of t){let t=n.get(e.partIndex)??[];t.push({start:e.start,end:e.end}),n.set(e.partIndex,t)}let r=e.parts.flatMap((e,t)=>{let r={...e},i=n.get(t);if(r.type!==`text`||i===void 0)return[r];let a=Fy(r.text,i);return a.length===0?[]:[{...r,text:a}]}),i={...e,parts:r};if(Nm(e.metadata)){let t={...e.metadata};delete t.reminders,Object.keys(t).length>0?i.metadata=t:delete i.metadata}return i}function Ly(e){let t=e.metadata;if(!Nm(t))return!1;let n=t.synthetic;return Nm(n)?n.source===`reminder`:!1}function Ry(e){let t={...e,parts:e.parts.filter(e=>e.type!==`text`)};if(Nm(e.metadata)){let n={...e.metadata};delete n.synthetic,Object.keys(n).length>0?t.metadata=n:delete t.metadata}return t}var zy=(0,I.createContext)({});function By(e){let t=(0,I.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Vy=typeof window<`u`?I.useLayoutEffect:I.useEffect,Hy=(0,I.createContext)(null);function Uy(e,t){e.indexOf(t)===-1&&e.push(t)}function Wy(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Gy=(e,t,n)=>n>t?t:n<e?e:n,Ky={},qy=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Jy=e=>typeof e==`object`&&!!e,Yy=e=>/^0[^.\s]+$/u.test(e);function Xy(e){let t;return()=>(t===void 0&&(t=e()),t)}var Zy=e=>e,Qy=(...e)=>e.reduce((e,t)=>n=>t(e(n))),$y=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},eb=class{constructor(){this.subscriptions=[]}add(e){return Uy(this.subscriptions,e),()=>Wy(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},tb=e=>e*1e3,nb=e=>e/1e3,rb=(e,t)=>t?1e3/t*e:0,ib=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ab=1e-7,ob=12;function sb(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=ib(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>ab&&++s<ob);return o}function cb(e,t,n,r){if(e===t&&n===r)return Zy;let i=t=>sb(t,0,1,e,n);return e=>e===0||e===1?e:ib(i(e),t,r)}var lb=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ub=e=>t=>1-e(1-t),db=cb(.33,1.53,.69,.99),fb=ub(db),pb=lb(fb),mb=e=>e>=1?1:(e*=2)<1?.5*fb(e):.5*(2-2**(-10*(e-1))),hb=e=>1-Math.sin(Math.acos(e)),gb=ub(hb),_b=lb(hb),vb=cb(.42,0,1,1),yb=cb(0,0,.58,1),bb=cb(.42,0,.58,1),xb=e=>Array.isArray(e)&&typeof e[0]!=`number`,Sb=e=>Array.isArray(e)&&typeof e[0]==`number`,Cb={linear:Zy,easeIn:vb,easeInOut:bb,easeOut:yb,circIn:hb,circInOut:_b,circOut:gb,backIn:fb,backInOut:pb,backOut:db,anticipate:mb},wb=e=>typeof e==`string`,Tb=e=>{if(Sb(e)){e.length;let[t,n,r,i]=e;return cb(t,n,r,i)}else if(wb(e))return Cb[e],`${e}`,Cb[e];return e},Eb=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function Db(e){let t=new Set,n=new Set,r=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(c.schedule(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var Ob=40;function kb(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Eb.reduce((e,t)=>(e[t]=Db(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Ky.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,Ob),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:Eb.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Eb.length;t++)o[Eb[t]].cancel(e)},state:i,steps:o}}var{schedule:Ab,cancel:jb,state:Mb,steps:Nb}=kb(typeof requestAnimationFrame<`u`?requestAnimationFrame:Zy,!0),Pb;function Fb(){Pb=void 0}var Ib={now:()=>(Pb===void 0&&Ib.set(Mb.isProcessing||Ky.useManualTiming?Mb.timestamp:performance.now()),Pb),set:e=>{Pb=e,queueMicrotask(Fb)}},Lb=e=>t=>typeof t==`string`&&t.startsWith(e),Rb=Lb(`--`),zb=Lb(`var(--`),Bb=e=>zb(e)?aee.test(e.split(`/*`)[0].trim()):!1,aee=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Vb(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Hb={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Ub={...Hb,transform:e=>Gy(0,1,e)},Wb={...Hb,default:1},Gb=e=>Math.round(e*1e5)/1e5,Kb=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function qb(e){return e==null}var Jb=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Yb=(e,t)=>n=>!!(typeof n==`string`&&Jb.test(n)&&n.startsWith(e)||t&&!qb(n)&&Object.prototype.hasOwnProperty.call(n,t)),Xb=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Kb);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Zb=e=>Gy(0,255,e),Qb={...Hb,transform:e=>Math.round(Zb(e))},$b={test:Yb(`rgb`,`red`),parse:Xb(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Qb.transform(e)+`, `+Qb.transform(t)+`, `+Qb.transform(n)+`, `+Gb(Ub.transform(r))+`)`};function ex(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var tx={test:Yb(`#`),parse:ex,transform:$b.transform},nx=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),rx=nx(`deg`),ix=nx(`%`),U=nx(`px`),ax=nx(`vh`),ox=nx(`vw`),sx={...ix,parse:e=>ix.parse(e)/100,transform:e=>ix.transform(e*100)},cx={test:Yb(`hsl`,`hue`),parse:Xb(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+ix.transform(Gb(t))+`, `+ix.transform(Gb(n))+`, `+Gb(Ub.transform(r))+`)`},lx={test:e=>$b.test(e)||tx.test(e)||cx.test(e),parse:e=>$b.test(e)?$b.parse(e):cx.test(e)?cx.parse(e):tx.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?$b.transform(e):cx.transform(e),getAnimatableNone:e=>{let t=lx.parse(e);return t.alpha=0,lx.transform(t)}},ux=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function dx(e){return isNaN(e)&&typeof e==`string`&&(e.match(Kb)?.length||0)+(e.match(ux)?.length||0)>0}var fx=`number`,px=`color`,mx=`var`,hx=`var(`,gx="${}",_x=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function vx(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(_x,e=>(lx.test(e)?(r.color.push(a),i.push(px),n.push(lx.parse(e))):e.startsWith(hx)?(r.var.push(a),i.push(mx),n.push(e)):(r.number.push(a),i.push(fx),n.push(parseFloat(e))),++a,gx)).split(gx),indexes:r,types:i}}function yx(e){return vx(e).values}function bx({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===fx?i+=Gb(r[a]):e===px?i+=lx.transform(r[a]):i+=r[a]}return i}}function xx(e){return bx(vx(e))}var Sx=e=>typeof e==`number`?0:lx.test(e)?lx.getAnimatableNone(e):e,Cx=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Sx(e);function wx(e){let t=vx(e);return bx(t)(t.values.map((e,n)=>Cx(e,t.split[n])))}var Tx={test:dx,parse:yx,createTransformer:xx,getAnimatableNone:wx};function Ex(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Dx({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Ex(s,r,e+1/3),a=Ex(s,r,e),o=Ex(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Ox(e,t){return n=>n>0?t:e}var kx=(e,t,n)=>e+(t-e)*n,Ax=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},jx=[tx,$b,cx],Mx=e=>jx.find(t=>t.test(e));function Nx(e){let t=Mx(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===cx&&(n=Dx(n)),n}var Px=(e,t)=>{let n=Nx(e),r=Nx(t);if(!n||!r)return Ox(e,t);let i={...n};return e=>(i.red=Ax(n.red,r.red,e),i.green=Ax(n.green,r.green,e),i.blue=Ax(n.blue,r.blue,e),i.alpha=kx(n.alpha,r.alpha,e),$b.transform(i))},Fx=new Set([`none`,`hidden`]);function Ix(e,t){return Fx.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Lx(e,t){return n=>kx(e,t,n)}function Rx(e){return typeof e==`number`?Lx:typeof e==`string`?Bb(e)?Ox:lx.test(e)?Px:Hx:Array.isArray(e)?zx:typeof e==`object`?lx.test(e)?Px:Bx:Ox}function zx(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Rx(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Bx(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Rx(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Vx(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var Hx=(e,t)=>{let n=Tx.createTransformer(t),r=vx(e),i=vx(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Fx.has(e)&&!i.values.length||Fx.has(t)&&!r.values.length?Ix(e,t):Qy(zx(Vx(r,i),i.values),n):(`${e}${t}`,Ox(e,t))};function Ux(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?kx(e,t,n):Rx(e)(e,t)}var Wx=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>Ab.update(t,e),stop:()=>jb(t),now:()=>Mb.isProcessing?Mb.timestamp:Ib.now()}},Gx=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Kx=2e4;function qx(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function Jx(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(qx(r),Kx);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:nb(i)}}var Yx={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Xx(e,t){return e*Math.sqrt(1-t*t)}var Zx=12;function Qx(e,t,n){let r=n;for(let n=1;n<Zx;n++)r-=e(r)/t(r);return r}var $x=.001;function eS({duration:e=Yx.duration,bounce:t=Yx.bounce,velocity:n=Yx.velocity,mass:r=Yx.mass}){let i,a;Yx.maxDuration;let o=1-t;o=Gy(Yx.minDamping,Yx.maxDamping,o),e=Gy(Yx.minDuration,Yx.maxDuration,nb(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=Xx(t,o),c=Math.exp(-i);return $x-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=Xx(t**2,o);return(-i(t)+$x>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Qx(i,a,s);if(e=tb(e),isNaN(c))return{stiffness:Yx.stiffness,damping:Yx.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var tS=[`duration`,`bounce`],nS=[`stiffness`,`damping`,`mass`];function rS(e,t){return t.some(t=>e[t]!==void 0)}function iS(e){let t={velocity:Yx.velocity,stiffness:Yx.stiffness,damping:Yx.damping,mass:Yx.mass,isResolvedFromDuration:!1,...e};if(!rS(e,nS)&&rS(e,tS))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Gy(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Yx.mass,stiffness:i,damping:a}}else{let n=eS({...e,velocity:0});t={...t,...n,mass:Yx.mass},t.isResolvedFromDuration=!0}return t}function aS(e=Yx.visualDuration,t=Yx.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=iS({...n,velocity:-nb(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=nb(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Yx.restSpeed.granular:Yx.restSpeed.default,i||=v?Yx.restDelta.granular:Yx.restDelta.default;let y,b,x,S,C,w;if(h<1)x=Xx(_,h),S=(m+h*_*g)/x,y=e=>{let t=Math.exp(-h*_*e);return o-t*(S*Math.sin(x*e)+g*Math.cos(x*e))},C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>tb(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=tb(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=tb(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(qx(T),Kx),t=Gx(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}aS.applyToOptions=e=>{let t=Jx(e,100,aS);return e.ease=t.ease,e.duration=tb(t.duration),e.type=`keyframes`,e};var oS=5;function sS(e,t,n){let r=Math.max(t-oS,0);return rb(n-e(r),t-r)}function cS({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=aS({keyframes:[f.value,m(f.value)],velocity:sS(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function lS(e,t,n){let r=[],i=n||Ky.mix||Ux,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Qy(Array.isArray(t)?t[n]||Zy:t,a)),r.push(a)}return r}function uS(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=lS(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=$y(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Gy(e[0],e[a-1],t)):l}function dS(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=$y(0,t,r);e.push(kx(n,1,i))}}function fS(e){let t=[0];return dS(t,e.length-1),t}function pS(e,t){return e.map(e=>e*t)}function mS(e,t){return e.map(()=>t||bb).splice(0,e.length-1)}function hS({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=xb(r)?r.map(Tb):Tb(r),a={done:!1,value:t[0]},o=uS(pS(n&&n.length===t.length?n:fS(t),e),t,{ease:Array.isArray(i)?i:mS(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var gS=e=>e!==null;function _S(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(gS),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var vS={decay:cS,inertia:cS,tween:hS,keyframes:hS,spring:aS};function yS(e){typeof e.type==`string`&&(e.type=vS[e.type])}var bS=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},xS=e=>e/100,SS=class extends bS{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Ib.now()&&this.tick(Ib.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;yS(e);let{type:t=hS,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||hS;s!==hS&&typeof o[0]!=`number`&&(this.mixKeyframes=Qy(xS,Ux(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=qx(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=Gy(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==cS&&(b.value=_S(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return nb(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+nb(e)}get time(){return nb(this.currentTime)}set time(e){e=tb(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return sS(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Ib.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=nb(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Wx,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Ib.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function CS(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var wS=e=>e*180/Math.PI,TS=e=>DS(wS(Math.atan2(e[1],e[0]))),ES={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:TS,rotateZ:TS,skewX:e=>wS(Math.atan(e[1])),skewY:e=>wS(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},DS=e=>(e%=360,e<0&&(e+=360),e),OS=TS,kS=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),AS=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),jS={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:kS,scaleY:AS,scale:e=>(kS(e)+AS(e))/2,rotateX:e=>DS(wS(Math.atan2(e[6],e[5]))),rotateY:e=>DS(wS(Math.atan2(-e[2],e[0]))),rotateZ:OS,rotate:OS,skewX:e=>wS(Math.atan(e[4])),skewY:e=>wS(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function MS(e){return+!!e.includes(`scale`)}function NS(e,t){if(!e||e===`none`)return MS(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=jS,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=ES,i=t}if(!i)return MS(t);let a=r[t],o=i[1].split(`,`).map(FS);return typeof a==`function`?a(o):o[a]}var PS=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return NS(n,t)};function FS(e){return parseFloat(e.trim())}var IS=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],LS=new Set([...IS,`pathRotation`]),RS=e=>e===Hb||e===U,zS=new Set([`x`,`y`,`z`]),BS=IS.filter(e=>!zS.has(e));function VS(e){let t=[];return BS.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var HS={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>NS(t,`x`),y:(e,{transform:t})=>NS(t,`y`)};HS.translateX=HS.x,HS.translateY=HS.y;var US=new Set,WS=!1,GS=!1,KS=!1;function qS(){if(GS){let e=Array.from(US).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=VS(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}GS=!1,WS=!1,US.forEach(e=>e.complete(KS)),US.clear()}function JS(){US.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(GS=!0)})}function YS(){KS=!0,JS(),qS(),KS=!1}var XS=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(US.add(this),WS||(WS=!0,Ab.read(JS),Ab.resolveKeyframes(qS))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}CS(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),US.delete(this)}cancel(){this.state===`scheduled`&&(US.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},ZS=e=>e.startsWith(`--`);function QS(e,t,n){ZS(t)?e.style.setProperty(t,n):e.style[t]=n}var $S={};function eC(e,t){let n=Xy(e);return()=>$S[t]??n()}var tC=eC(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),nC=eC(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),rC=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,iC={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:rC([0,.65,.55,1]),circOut:rC([.55,0,1,.45]),backIn:rC([.31,.01,.66,-.59]),backOut:rC([.33,1.53,.69,.99])};function aC(e,t){if(e)return typeof e==`function`?nC()?Gx(e,t):`ease-out`:Sb(e)?rC(e):Array.isArray(e)?e.map(e=>aC(e,t)||iC.easeOut):iC[e]}function oC(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=aC(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function sC(e){return typeof e==`function`&&`applyToOptions`in e}function cC({type:e,...t}){return sC(e)&&nC()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var lC=class extends bS{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=cC(e);this.animation=oC(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=_S(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),QS(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return nb(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+nb(e)}get time(){return nb(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=tb(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&tC()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Zy):r(this)}},uC={anticipate:mb,backInOut:pb,circInOut:_b};function dC(e){return e in uC}function fC(e){typeof e.ease==`string`&&dC(e.ease)&&(e.ease=uC[e.ease])}var pC=10,mC=class extends lC{constructor(e){fC(e),yS(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new SS({...a,autoplay:!1}),s=Math.max(pC,Ib.now()-this.startTime),c=Gy(0,pC,s-pC),l=o.sample(s).value,{name:u}=this.options;i&&u&&QS(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},hC=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Tx.test(e)||e===`0`)&&!e.startsWith(`url(`));function gC(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function _C(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=hC(i,t),s=hC(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:gC(e)||(n===`spring`||sC(n))&&r}function vC(e){e.duration=0,e.type=`keyframes`}var yC=new Set([`opacity`,`clipPath`,`filter`,`transform`]),bC=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function xC(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&bC.test(e[t]))return!0;return!1}var SC=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),CC=Xy(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function wC(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return CC()&&n&&(yC.has(n)||SC.has(n)&&xC(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var TC=40,EC=class extends bS{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ib.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||XS;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Ib.now();let u=!0;_C(e,i,a,o)||(u=!1,(Ky.instantAnimations||!s)&&l?.(_S(e,n,t)),e[0]=e[e.length-1],vC(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>TC?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&wC(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new mC({...d,element:p})}catch{m=new SS(d)}else m=new SS(d);m.finished.then(()=>{this.notifyFinished()}).catch(Zy),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),YS()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function DC(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var OC=30,kC=e=>!isNaN(parseFloat(e)),AC={current:void 0},jC=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Ib.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Ib.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=kC(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new eb);let n=this.events[e].add(t);return e===`change`?()=>{n(),Ab.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return AC.current&&AC.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Ib.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>OC)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,OC);return rb(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function MC(e,t){return new jC(e,t)}function NC(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function PC(e,t){let n=e?.[t]??e?.default??e;return n===e?n:NC(n,e)}var FC={type:`spring`,stiffness:500,damping:25,restSpeed:10},IC=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),LC={type:`keyframes`,duration:.8},RC={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},zC=(e,{keyframes:t})=>t.length>2?LC:LS.has(e)?e.startsWith(`scale`)?IC(t[1]):FC:RC,BC=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function VC(e){for(let t in e)if(!BC.has(t))return!0;return!1}var HC=(e,t,n,r={},i,a)=>o=>{let s=PC(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=tb(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};VC(s)||Object.assign(u,zC(e,u)),u.duration&&=tb(u.duration),u.repeatDelay&&=tb(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(vC(u),u.delay===0&&(d=!0)),(Ky.instantAnimations||Ky.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,vC(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=_S(u.keyframes,s);if(e!==void 0){Ab.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new SS(u):new EC(u)},UC=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function WC(e){let t=UC.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function GC(e,t,n=1){`${e}`;let[r,i]=WC(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return qy(e)?parseFloat(e):e}return Bb(i)?GC(i,t,n+1):i}function KC(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function qC(e,t,n,r){if(typeof t==`function`){let[i,a]=KC(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=KC(r);t=t(n===void 0?e.custom:n,i,a)}return t}function JC(e,t,n){let r=e.getProps();return qC(r,t,n===void 0?r.custom:n,e)}var YC=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...IS]),XC=e=>Array.isArray(e);function ZC(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,MC(n))}function QC(e){return XC(e)?e[e.length-1]||0:e}function $C(e,t){let{transitionEnd:n={},transition:r={},...i}=JC(e,t)||{};i={...i,...n};for(let t in i)ZC(e,t,QC(i[t]))}var ew=e=>!!(e&&e.getVelocity);function tw(e){return!!(ew(e)&&e.add)}function nw(e,t){let n=e.getValue(`willChange`);if(tw(n))return n.add(t);if(!n&&Ky.WillChange){let n=new Ky.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function rw(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var iw=`data-`+rw(`framerAppearId`);function aw(e){return e.props[iw]}function ow({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function sw(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?NC(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&ow(f,t))continue;let o={delay:n,...PC(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){Ab.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=aw(e);if(n){let e=window.MotionHandoffAnimation(n,t,Ab);e!==null&&(o.startTime=e,p=!0)}}nw(e,t);let m=l??e.shouldReduceMotion;r.start(HC(t,r,i,m&&YC.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>Ab.update(()=>{o&&$C(e,o)});d.length?Promise.all(d).then(t):t()}return d}function cw(e,t,n={}){let r=JC(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(sw(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return lw(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function lw(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(cw(c,t,{...o,delay:n+(typeof r==`function`?0:r)+DC(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function uw(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>cw(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=cw(e,t,n);else{let i=typeof t==`function`?JC(e,t,n.custom):t;r=Promise.all(sw(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var dw={test:e=>e===`auto`,parse:e=>e},fw=e=>t=>t.test(e),pw=[Hb,U,ix,rx,ox,ax,dw],mw=e=>pw.find(fw(e));function hw(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||Yy(e)}var gw=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function _w(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Kb)||[];if(!r)return e;let i=n.replace(r,``),a=+!!gw.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var vw=/\b([a-z-]*)\(.*?\)/gu,yw={...Tx,getAnimatableNone:e=>{let t=e.match(vw);return t?t.map(_w).join(` `):e}},bw={...Tx,getAnimatableNone:e=>{let t=Tx.parse(e);return Tx.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},xw={...Hb,transform:Math.round},Sw={borderWidth:U,borderTopWidth:U,borderRightWidth:U,borderBottomWidth:U,borderLeftWidth:U,borderRadius:U,borderTopLeftRadius:U,borderTopRightRadius:U,borderBottomRightRadius:U,borderBottomLeftRadius:U,width:U,maxWidth:U,height:U,maxHeight:U,top:U,right:U,bottom:U,left:U,inset:U,insetBlock:U,insetBlockStart:U,insetBlockEnd:U,insetInline:U,insetInlineStart:U,insetInlineEnd:U,padding:U,paddingTop:U,paddingRight:U,paddingBottom:U,paddingLeft:U,paddingBlock:U,paddingBlockStart:U,paddingBlockEnd:U,paddingInline:U,paddingInlineStart:U,paddingInlineEnd:U,margin:U,marginTop:U,marginRight:U,marginBottom:U,marginLeft:U,marginBlock:U,marginBlockStart:U,marginBlockEnd:U,marginInline:U,marginInlineStart:U,marginInlineEnd:U,fontSize:U,backgroundPositionX:U,backgroundPositionY:U,rotate:rx,pathRotation:rx,rotateX:rx,rotateY:rx,rotateZ:rx,scale:Wb,scaleX:Wb,scaleY:Wb,scaleZ:Wb,skew:rx,skewX:rx,skewY:rx,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:Ub,originX:sx,originY:sx,originZ:U,zIndex:xw,fillOpacity:Ub,strokeOpacity:Ub,numOctaves:xw},Cw={...Sw,color:lx,backgroundColor:lx,outlineColor:lx,fill:lx,stroke:lx,borderColor:lx,borderTopColor:lx,borderRightColor:lx,borderBottomColor:lx,borderLeftColor:lx,filter:yw,WebkitFilter:yw,mask:bw,WebkitMask:bw},ww=e=>Cw[e],Tw=new Set([yw,bw]);function Ew(e,t){let n=ww(e);return Tw.has(n)||(n=Tx),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var Dw=new Set([`auto`,`none`,`0`]);function Ow(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!Dw.has(t)&&vx(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Ew(n,i)}var kw=class extends XS{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Bb(r))){let i=GC(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!YC.has(n)||e.length!==2)return;let[r,i]=e,a=mw(r),o=mw(i);if(Vb(r)!==Vb(i)&&HS[n]){this.needsMeasurement=!0;return}if(a!==o)if(RS(a)&&RS(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else HS[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||hw(e[t]))&&n.push(t);n.length&&Ow(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=HS[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=HS[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},Aw=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function jw(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var Mw=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function Nw(e){return Jy(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:Pw,cancel:oee}=kb(queueMicrotask,!1),Fw={x:!1,y:!1};function Iw(){return Fw.x||Fw.y}function Lw(e){return e===`x`||e===`y`?Fw[e]?null:(Fw[e]=!0,()=>{Fw[e]=!1}):Fw.x||Fw.y?null:(Fw.x=Fw.y=!0,()=>{Fw.x=Fw.y=!1})}function Rw(e,t){let n=jw(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function zw(e){return!(e.pointerType===`touch`||Iw())}function Bw(e,t,n={}){let[r,i,a]=Rw(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!zw(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Vw=(e,t)=>t?e===t||Vw(e,t.parentElement):!1,Hw=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Uw=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Ww(e){return Uw.has(e.tagName)||e.isContentEditable===!0}var Gw=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Kw(e){return Gw.has(e.tagName)||e.isContentEditable===!0}var qw=new WeakSet;function Jw(e){return t=>{t.key===`Enter`&&e(t)}}function Yw(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Xw=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Jw(()=>{if(qw.has(n))return;Yw(n,`down`);let e=Jw(()=>{Yw(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Yw(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Zw(e){return Hw(e)&&!Iw()}var Qw=new WeakSet;function $w(e,t,n={}){let[r,i,a]=Rw(e,n),o=e=>{let r=e.currentTarget;if(!Zw(e)||Qw.has(e))return;qw.add(r),n.stopPropagation&&Qw.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),qw.has(r)&&qw.delete(r),Zw(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||Vw(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),Nw(e)&&(e.addEventListener(`focus`,e=>Xw(e,i)),!Ww(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function eT(e){return Jy(e)&&`ownerSVGElement`in e}var tT=new WeakMap,nT,rT=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:eT(r)&&`getBBox`in r?r.getBBox()[t]:r[n],iT=rT(`inline`,`width`,`offsetWidth`),aT=rT(`block`,`height`,`offsetHeight`);function oT({target:e,borderBoxSize:t}){tT.get(e)?.forEach(n=>{n(e,{get width(){return iT(e,t)},get height(){return aT(e,t)}})})}function sT(e){e.forEach(oT)}function cT(){typeof ResizeObserver>`u`||(nT=new ResizeObserver(sT))}function lT(e,t){nT||cT();let n=jw(e);return n.forEach(e=>{let n=tT.get(e);n||(n=new Set,tT.set(e,n)),n.add(t),nT?.observe(e)}),()=>{n.forEach(e=>{let n=tT.get(e);n?.delete(t),n?.size||nT?.unobserve(e)})}}var uT=new Set,dT;function fT(){dT=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};uT.forEach(t=>t(e))},window.addEventListener(`resize`,dT)}function pT(e){return uT.add(e),dT||fT(),()=>{uT.delete(e),!uT.size&&typeof dT==`function`&&(window.removeEventListener(`resize`,dT),dT=void 0)}}function mT(e,t){return typeof e==`function`?pT(e):lT(e,t)}var hT={value:null,addProjectionMetrics:null};function gT(e){return eT(e)&&e.tagName===`svg`}var _T=[...pw,lx,Tx],vT=e=>_T.find(fw(e)),yT=()=>({translate:0,scale:1,origin:0,originPoint:0}),bT=()=>({x:yT(),y:yT()}),xT=()=>({min:0,max:0}),ST=()=>({x:xT(),y:xT()}),CT=new WeakMap;function wT(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function TT(e){return typeof e==`string`||Array.isArray(e)}var ET=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],DT=[`initial`,...ET];function OT(e){return wT(e.animate)||DT.some(t=>TT(e[t]))}function kT(e){return!!(OT(e)||e.variants)}function AT(e,t,n){for(let r in t){let i=t[r],a=n[r];if(ew(i))e.addValue(r,i);else if(ew(a))e.addValue(r,MC(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,MC(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var jT={current:null},MT={current:!1},NT=typeof window<`u`;function PT(){if(MT.current=!0,NT)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>jT.current=e.matches;e.addEventListener(`change`,t),t()}else jT.current=!1}var FT=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],IT={};function LT(e){IT=e}function RT(){return IT}var zT=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=XS,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Ib.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Ab.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=OT(t),this.isVariantNode=kT(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&ew(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,CT.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(MT.current||PT(),this.shouldReduceMotion=jT.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),jb(this.notifyUpdate),jb(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&yC.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new lC({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:tb(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=LS.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Ab.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in IT){let t=IT[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):ST()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<FT.length;t++){let n=FT[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=AT(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=MC(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(qy(n)||Yy(n))?n=parseFloat(n):!vT(n)&&Tx.test(t)&&(n=Ew(e,t)),this.setBaseTarget(e,ew(n)?n.get():n)),ew(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=qC(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!ew(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new eb),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Pw.render(this.render)}},BT=class extends zT{constructor(){super(...arguments),this.KeyframeResolver=kw}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;ew(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},VT=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function HT({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function UT({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function WT(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function GT(e){return e===void 0||e===1}function KT({scale:e,scaleX:t,scaleY:n}){return!GT(e)||!GT(t)||!GT(n)}function qT(e){return KT(e)||JT(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function JT(e){return YT(e.x)||YT(e.y)}function YT(e){return e&&e!==`0%`}function XT(e,t,n){return n+t*(e-n)}function ZT(e,t,n,r,i){return i!==void 0&&(e=XT(e,i,r)),XT(e,n,r)+t}function QT(e,t=0,n=1,r,i){e.min=ZT(e.min,t,n,r,i),e.max=ZT(e.max,t,n,r,i)}function $T(e,{x:t,y:n}){QT(e.x,t.translate,t.scale,t.originPoint),QT(e.y,n.translate,n.scale,n.originPoint)}var eE=.999999999999,tE=1.0000000000001;function nE(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(rE(e.x,-a.scroll.offset.x),rE(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,$T(e,o)),r&&qT(a.latestValues)&&oE(e,a.latestValues,a.layout?.layoutBox))}t.x<tE&&t.x>eE&&(t.x=1),t.y<tE&&t.y>eE&&(t.y=1)}function rE(e,t){e.min+=t,e.max+=t}function iE(e,t,n,r,i=.5){QT(e,t,n,kx(e.min,e.max,i),r)}function aE(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function oE(e,t,n){let r=n??e;iE(e.x,aE(t.x,r.x),t.scaleX,t.scale,t.originX),iE(e.y,aE(t.y,r.y),t.scaleY,t.scale,t.originY)}function sE(e,t){return HT(WT(e.getBoundingClientRect(),t))}function cE(e,t,n){let r=sE(e,n),{scroll:i}=t;return i&&(rE(r.x,i.offset.x),rE(r.y,i.offset.y)),r}var lE={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},uE=IS.length;function dE(e,t,n){let r=``,i=!0;for(let a=0;a<uE;a++){let o=IS[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=Mw(s,Sw[o]);if(!c){i=!1;let t=lE[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${Mw(a,Sw.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function fE(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(LS.has(e)){o=!0;continue}else if(Rb(e)){i[e]=n;continue}else{let t=Mw(n,Sw[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=dE(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function pE(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function mE(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var hE={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(U.test(e))e=parseFloat(e);else return e;return`${mE(e,t.target.x)}% ${mE(e,t.target.y)}%`}},gE={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Tx.parse(e);if(i.length>5)return r;let a=Tx.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=kx(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},_E={borderRadius:{...hE,applyTo:[...Aw]},borderTopLeftRadius:hE,borderTopRightRadius:hE,borderBottomLeftRadius:hE,borderBottomRightRadius:hE,boxShadow:gE};function vE(e,{layout:t,layoutId:n}){return LS.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!_E[e]||e===`opacity`)}function yE(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(ew(r[t])||i&&ew(i[t])||vE(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function bE(e){return window.getComputedStyle(e)}var xE=class extends BT{constructor(){super(...arguments),this.type=`html`,this.renderInstance=pE}readValueFromInstance(e,t){if(LS.has(t))return this.projection?.isProjecting?MS(t):PS(e,t);{let n=bE(e),r=(Rb(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return sE(e,t)}build(e,t,n){fE(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return yE(e,t,n)}},SE={offset:`stroke-dashoffset`,array:`stroke-dasharray`},CE={offset:`strokeDashoffset`,array:`strokeDasharray`};function wE(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?SE:CE;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var TE=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function EE(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(fE(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of TE)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&wE(d,i,a,o,!1)}var DE=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),OE=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function kE(e,t,n,r){pE(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(DE.has(n)?n:rw(n),t.attrs[n])}function AE(e,t,n){let r=yE(e,t,n);for(let n in e)if(ew(e[n])||ew(t[n])){let t=IS.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var jE=class extends BT{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=ST}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(LS.has(t)){let e=ww(t);return e&&e.default||0}return t=DE.has(t)?t:rw(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return AE(e,t,n)}build(e,t,n){EE(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){kE(e,t,n,r)}mount(e){this.isSVGTag=OE(e.tagName),super.mount(e)}},ME=DT.length;function NE(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&NE(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<ME;n++){let r=DT[n],i=e.props[r];(TT(i)||i===!1)&&(t[r]=i)}return t}function PE(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var FE=[...ET].reverse(),IE=ET.length;function LE(e){return t=>Promise.all(t.map(({animation:t,options:n})=>uw(e,t,n)))}function RE(e){let t=LE(e),n=VE(),r=!0,i=!1,a=t=>(n,r)=>{let i=JC(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=NE(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<IE;t++){let p=FE[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=TT(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||wT(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=zE(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=XC(t)&&XC(n)?!PE(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let ee=v&&y;b&&(!ee||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!ee&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=JC(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=DC(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=JC(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=VE(),i=!0}}}function zE(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!PE(t,e):!1}function BE(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function VE(){return{animate:BE(!0),whileInView:BE(),whileHover:BE(),whileTap:BE(),whileDrag:BE(),whileFocus:BE(),exit:BE()}}function HE(e,t){e.min=t.min,e.max=t.max}function UE(e,t){HE(e.x,t.x),HE(e.y,t.y)}function WE(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var GE=.9999,KE=1.0001,qE=-.01,JE=.01;function YE(e){return e.max-e.min}function XE(e,t,n){return Math.abs(e-t)<=n}function ZE(e,t,n,r=.5){e.origin=r,e.originPoint=kx(t.min,t.max,e.origin),e.scale=YE(n)/YE(t),e.translate=kx(n.min,n.max,e.origin)-e.originPoint,(e.scale>=GE&&e.scale<=KE||isNaN(e.scale))&&(e.scale=1),(e.translate>=qE&&e.translate<=JE||isNaN(e.translate))&&(e.translate=0)}function QE(e,t,n,r){ZE(e.x,t.x,n.x,r?r.originX:void 0),ZE(e.y,t.y,n.y,r?r.originY:void 0)}function $E(e,t,n,r=0){e.min=(r?kx(n.min,n.max,r):n.min)+t.min,e.max=e.min+YE(t)}function eD(e,t,n,r){$E(e.x,t.x,n.x,r?.x),$E(e.y,t.y,n.y,r?.y)}function tD(e,t,n,r=0){let i=r?kx(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+YE(t)}function nD(e,t,n,r){tD(e.x,t.x,n.x,r?.x),tD(e.y,t.y,n.y,r?.y)}function rD(e,t,n,r,i){return e-=t,e=XT(e,1/n,r),i!==void 0&&(e=XT(e,1/i,r)),e}function iD(e,t=0,n=1,r=.5,i,a=e,o=e){if(ix.test(t)&&(t=parseFloat(t),t=kx(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=kx(a.min,a.max,r);e===a&&(s-=t),e.min=rD(e.min,t,n,s,i),e.max=rD(e.max,t,n,s,i)}function aD(e,t,[n,r,i],a,o){iD(e,t[n],t[r],t[i],t.scale,a,o)}var oD=[`x`,`scaleX`,`originX`],sD=[`y`,`scaleY`,`originY`];function cD(e,t,n,r){aD(e.x,t,oD,n?n.x:void 0,r?r.x:void 0),aD(e.y,t,sD,n?n.y:void 0,r?r.y:void 0)}function lD(e){return e.translate===0&&e.scale===1}function uD(e){return lD(e.x)&&lD(e.y)}function dD(e,t){return e.min===t.min&&e.max===t.max}function fD(e,t){return dD(e.x,t.x)&&dD(e.y,t.y)}function pD(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function mD(e,t){return pD(e.x,t.x)&&pD(e.y,t.y)}function hD(e){return YE(e.x)/YE(e.y)}function gD(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function _D(e){return[e(`x`),e(`y`)]}function vD(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var yD=Aw.length,bD=e=>typeof e==`string`?parseFloat(e):e,xD=e=>typeof e==`number`||U.test(e);function SD(e,t,n,r,i,a){i?(e.opacity=kx(0,n.opacity??1,wD(r)),e.opacityExit=kx(t.opacity??1,0,TD(r))):a&&(e.opacity=kx(t.opacity??1,n.opacity??1,r));for(let i=0;i<yD;i++){let a=Aw[i],o=CD(t,a),s=CD(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||xD(o)===xD(s)?(e[a]=Math.max(kx(bD(o),bD(s),r),0),(ix.test(s)||ix.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=kx(t.rotate||0,n.rotate||0,r))}function CD(e,t){return e[t]===void 0?e.borderRadius:e[t]}var wD=ED(0,.5,gb),TD=ED(.5,.95,Zy);function ED(e,t,n){return r=>r<e?0:r>t?1:n($y(e,t,r))}function DD(e,t,n){let r=ew(e)?e:MC(e);return r.start(HC(``,r,t,n)),r.animation}function OD(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var kD=(e,t)=>e.depth-t.depth,AD=class{constructor(){this.children=[],this.isDirty=!1}add(e){Uy(this.children,e),this.isDirty=!0}remove(e){Wy(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(kD),this.isDirty=!1,this.children.forEach(e)}};function jD(e,t){let n=Ib.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(jb(r),e(a-t))};return Ab.setup(r,!0),()=>jb(r)}function MD(e){return ew(e)?e.get():e}var ND=class{constructor(){this.members=[]}add(e){Uy(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(Wy(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Wy(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},PD={hasAnimatedSinceResize:!0,hasEverUpdated:!1},FD={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},ID=[``,`X`,`Y`,`Z`],LD=1e3,RD=0;function zD(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function BD(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=aw(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Ab,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&BD(r)}function VD({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=RD++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,hT.value&&(FD.nodes=FD.calculatedTargetDeltas=FD.calculatedProjections=0),this.nodes.forEach(WD),this.nodes.forEach($D),this.nodes.forEach(eO),this.nodes.forEach(GD),hT.addProjectionMetrics&&hT.addProjectionMetrics(FD)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new AD)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new eb),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=eT(t)&&!gT(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;Ab.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=jD(i,250),PD.hasAnimatedSinceResize&&(PD.hasAnimatedSinceResize=!1,this.nodes.forEach(QD)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||sO,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!mD(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...PC(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||QD(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),jb(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(tO),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&BD(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(JD),this.nodes.forEach(qD);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(YD);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(XD),this.nodes.forEach(ZD),this.nodes.forEach(HD),this.nodes.forEach(UD)):this.nodes.forEach(YD),this.clearAllSnapshots();let e=Ib.now();Mb.delta=Gy(0,1e3/60,e-Mb.timestamp),Mb.timestamp=e,Mb.isProcessing=!0,Nb.update.process(Mb),Nb.preRender.process(Mb),Nb.render.process(Mb),Mb.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Pw.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(KD),this.sharedNodes.forEach(nO)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ab.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ab.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!YE(this.snapshot.measuredBox.x)&&!YE(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=ST(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!uD(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||qT(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),dO(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return ST();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(pO))){let{scroll:e}=this.root;e&&(rE(t.x,e.offset.x),rE(t.y,e.offset.y))}return t}removeElementScroll(e){let t=ST();if(UE(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&UE(t,e),rE(t.x,i.offset.x),rE(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||ST();UE(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(rE(r.x,-n.scroll.offset.x),rE(r.y,-n.scroll.offset.y)),qT(n.latestValues)&&oE(r,n.latestValues,n.layout?.layoutBox)}return qT(this.latestValues)&&oE(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=ST();UE(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!qT(n.latestValues))continue;let r;n.instance&&(KT(n.latestValues)&&n.updateSnapshot(),r=ST(),UE(r,n.measurePageBox())),cD(t,n.latestValues,n.snapshot?.layoutBox,r)}return qT(this.latestValues)&&cD(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Mb.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Mb.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=ST(),this.targetWithTransforms=ST()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),eD(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):UE(this.target,this.layout.layoutBox),$T(this.target,this.targetDelta)):UE(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),hT.value&&FD.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||KT(this.parent.latestValues)||JT(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=ST(),this.relativeTargetOrigin=ST(),nD(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),UE(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Mb.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;UE(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;nE(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=ST());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(WE(this.prevProjectionDelta.x,this.projectionDelta.x),WE(this.prevProjectionDelta.y,this.projectionDelta.y)),QE(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!gD(this.projectionDelta.x,this.prevProjectionDelta.x)||!gD(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),hT.value&&FD.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=bT(),this.projectionDelta=bT(),this.projectionDeltaWithTransform=bT()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=bT();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=ST(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!!(c&&!u&&this.options.crossfade===!0&&!this.path.some(oO));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=kx(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=kx(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(rO(o.x,e.x,n),rO(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(nD(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),aO(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&fD(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=ST(),UE(f,this.relativeTarget)),c&&(this.animationValues=a,SD(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(jb(this.pendingAnimation),void 0),this.pendingAnimation=Ab.update(()=>{PD.hasAnimatedSinceResize=!0,this.motionValue||=MC(0),this.motionValue.jump(0,!1),this.currentAnimation=DD(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(LD),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&fO(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||ST();let t=YE(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=YE(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}UE(t,n),oE(t,i),QE(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new ND),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&zD(`z`,e,r,this.animationValues);for(let t=0;t<ID.length;t++)zD(`rotate${ID[t]}`,e,r,this.animationValues),zD(`skew${ID[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=MD(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=MD(t?.pointerEvents)||``),this.hasProjected&&!qT(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=vD(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in _E){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=_E[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?MD(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(qD),this.root.sharedNodes.clear()}}}function HD(e){e.updateLayout()}function UD(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)_D(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=YE(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;HE(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else fO(i,t.layoutBox,n)&&_D(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=YE(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=bT();QE(o,n,t.layoutBox);let s=bT();a?QE(s,e.applyTransform(r,!0),t.measuredBox):QE(s,n,t.layoutBox);let c=!uD(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=ST();nD(s,t.layoutBox,i.layoutBox,o);let c=ST();nD(c,n,a.layoutBox,o),mD(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function WD(e){hT.value&&FD.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function GD(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function KD(e){e.clearSnapshot()}function qD(e){e.clearMeasurements()}function JD(e){e.isLayoutDirty=!0,e.updateLayout()}function YD(e){e.isLayoutDirty=!1}function XD(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function ZD(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function QD(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function $D(e){e.resolveTargetDelta()}function eO(e){e.calcProjection()}function tO(e){e.resetSkewAndRotation()}function nO(e){e.removeLeadSnapshot()}function rO(e,t,n){e.translate=kx(t.translate,0,n),e.scale=kx(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function iO(e,t,n,r){e.min=kx(t.min,n.min,r),e.max=kx(t.max,n.max,r)}function aO(e,t,n,r){iO(e.x,t.x,n.x,r),iO(e.y,t.y,n.y,r)}function oO(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var sO={duration:.45,ease:[.4,0,.1,1]},cO=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),lO=cO(`applewebkit/`)&&!cO(`chrome/`)?Math.round:Zy;function uO(e){e.min=lO(e.min),e.max=lO(e.max)}function dO(e){uO(e.x),uO(e.y)}function fO(e,t,n){return e===`position`||e===`preserve-aspect`&&!XE(hD(t),hD(n),.2)}function pO(e){return e!==e.root&&e.scroll?.wasRoot}var mO=VD({attachResizeListener:(e,t)=>OD(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),hO={current:void 0},gO=VD({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!hO.current){let e=new mO({});e.mount(window),e.setOptions({layoutScroll:!0}),hO.current=e}return hO.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),_O=(0,I.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function vO(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function yO(...e){return t=>{let n=!1,r=e.map(e=>{let r=vO(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():vO(e[t],null)}}}}function bO(...e){return I.useCallback(yO(...e),e)}var xO=class extends I.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(Nw(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=Nw(e)&&e.offsetWidth||0,r=Nw(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function SO({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,I.useId)(),s=(0,I.useRef)(null),c=(0,I.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,I.useContext)(_O),u=bO(s,e.props?.ref??e?.ref);return(0,I.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
170
+ ]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function mh(e,t){let n={type:`object`,additionalProperties:z(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===`ZodString`&&e.keyType._def.checks?.length){let{type:r,...i}=sh(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===`ZodEnum`)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===`ZodBranded`&&e.keyType._def.type._def.typeName===`ZodString`&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=Ym(e.keyType._def,t);return{...n,propertyNames:i}}return n}function hh(e,t){return t.mapStrategy===`record`?mh(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[z(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Gm(),z(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Gm()],minItems:2,maxItems:2}}}function gh(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function _h(){return{not:Gm()}}function vh(){return{type:`null`}}var yh={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function bh(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in yh&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=yh[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return xh(e,t)}var xh=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>z(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Sh(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[yh[e.innerType._def.typeName],`null`]};let n=z(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function Ch(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function wh(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=Eh(a),s=z(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=Th(e,t);return a!==void 0&&(n.additionalProperties=a),n}function Th(e,t){if(e.catchall._def.typeName!==`ZodNever`)return z(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Eh(e){try{return e.isOptional()}catch{return!0}}var Dh=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return z(e.innerType._def,t);let n=z(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Gm()},n]}:Gm()},Oh=(e,t)=>{if(t.pipeStrategy===`input`)return z(e.in._def,t);if(t.pipeStrategy===`output`)return z(e.out._def,t);let n=z(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,z(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function kh(e,t){return z(e.type._def,t)}function Ah(e,t){let n={type:`array`,uniqueItems:!0,items:z(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function jh(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>z(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:z(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>z(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Mh(){return{not:Gm()}}function Nh(){return Gm()}var Ph=(e,t)=>z(e.innerType._def,t),Fh=(e,t,n)=>{switch(t){case`ZodString`:return sh(e,n);case`ZodNumber`:return Ch(e);case`ZodObject`:return wh(e,n);case`ZodBigInt`:return qm(e);case`ZodBoolean`:return Jm();case`ZodDate`:return Zm(e,n);case`ZodUndefined`:return Mh();case`ZodNull`:return vh();case`ZodArray`:return Km(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return bh(e,n);case`ZodIntersection`:return rh(e,n);case`ZodTuple`:return jh(e,n);case`ZodRecord`:return mh(e,n);case`ZodLiteral`:return ih(e);case`ZodEnum`:return th(e);case`ZodNativeEnum`:return gh(e);case`ZodNullable`:return Sh(e,n);case`ZodOptional`:return Dh(e,n);case`ZodMap`:return hh(e,n);case`ZodSet`:return Ah(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return kh(e,n);case`ZodNaN`:case`ZodNever`:return _h();case`ZodEffects`:return eh(e,n);case`ZodAny`:return Gm();case`ZodUnknown`:return Nh();case`ZodDefault`:return $m(e,n);case`ZodBranded`:return Ym(e,n);case`ZodReadonly`:return Ph(e,n);case`ZodCatch`:return Xm(e,n);case`ZodPipeline`:return Oh(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},Ih=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function z(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==Hm)return i}if(r&&!n){let e=Lh(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Fh(e,e.typeName,t),o=typeof a==`function`?z(a(),t):a;if(o&&Rh(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Lh=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Ih(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Gm()):t.$refStrategy===`seen`?Gm():void 0}},Rh=(e,t,n)=>(e.description&&(n.description=e.description),n),zh=e=>{let t=Wm(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},Bh=(e,t)=>{let n=zh(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:z(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Gm()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=z(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Gm(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},Vh=Symbol.for(`vercel.ai.schema`);function Hh(e){let t;return()=>(t??=e(),t)}function Uh(e,{validate:t}={}){return{[Vh]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function Wh(e){return typeof e==`object`&&!!e&&Vh in e&&e[Vh]===!0&&`jsonSchema`in e&&`validate`in e}function Gh(e){return e==null?Uh({type:`object`,properties:{},additionalProperties:!1}):Wh(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?Zh(e):Kh(e):e()}function Kh(e){return Uh(()=>{if(!qh(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return Bm(e[`~standard`].jsonSchema.input({target:`draft-07`}))},{validate:async t=>{let n=await e[`~standard`].validate(t);return n.issues===void 0&&`value`in n?{success:!0,value:n.value}:{success:!1,error:new fm({value:t,cause:n.issues})}}})}function qh(e){return e[`~standard`].jsonSchema!=null}function Jh(e,t){let n=t?.useReferences??!1;return Uh(()=>Bh(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Yh(e,t){lt().localeError||lt(j());let n=t?.useReferences??!1;return Uh(()=>Bm(Te(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await ye(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Xh(e){return`_zod`in e}function Zh(e,t){return Xh(e)?Yh(e,t):Jh(e,t)}async function Qh({value:e,schema:t,context:n}){let r=await $h({value:e,schema:t,context:n});if(!r.success)throw fm.wrap({value:e,cause:r.error,context:n});return r.value}async function $h({value:e,schema:t,context:n}){let r=Gh(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:fm.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:fm.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function eg({text:e,schema:t}){try{let n=zm(e);return t==null?{success:!0,value:n,rawValue:n}:await $h({value:n,schema:t})}catch(t){return{success:!1,error:cm.isInstance(t)?t:new cm({text:e,cause:t}),rawValue:void 0}}}function tg({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Tm).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await eg({text:e,schema:t}))}}))}async function ng(e){return typeof e==`function`&&(e=e()),e}new TextDecoder;var rg=fn(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);sn.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){ze(this,`with`,e)},parse(e,t){return Yt(this,e,t,{callee:this.parse})},parseAsync(e,t){return Vt(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return wt(this,e,t)},safeParseAsync(e,t){return xt(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return bn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),ig=fn(`ZodMiniString`,(e,t)=>{dt.init(e,t),rg.init(e,t)});function ag(e){return de(ig,e)}var og=fn(`ZodMiniNumber`,(e,t)=>{Ht.init(e,t),rg.init(e,t)});function sg(e){return k(og,e)}var cg=fn(`ZodMiniNumberFormat`,(e,t)=>{en.init(e,t),og.init(e,t)});function lg(e){return pe(cg,e)}var ug=fn(`ZodMiniBoolean`,(e,t)=>{Xe.init(e,t),rg.init(e,t)});function dg(e){return te(ug,e)}var fg=fn(`ZodMiniUnknown`,(e,t)=>{_t.init(e,t),rg.init(e,t)});function pg(){return Xt(fg)}var mg=fn(`ZodMiniNever`,(e,t)=>{an.init(e,t),rg.init(e,t)});function hg(e){return h(mg,e)}var gg=fn(`ZodMiniArray`,(e,t)=>{Ze.init(e,t),rg.init(e,t)});function _g(e,t){return new gg({type:`array`,element:e,...gn(t)})}var vg=fn(`ZodMiniObject`,(e,t)=>{Ot.init(e,t),rg.init(e,t),x(e,`shape`,e=>e._zod.def.shape,!1)});function yg(e,t){return new vg({type:`object`,shape:e??{},...gn(t)})}function bg(e,t){return new vg({type:`object`,shape:e,catchall:pg(),...gn(t)})}function xg(e,t){return Ie(e,t)}var Sg=fn(`ZodMiniUnion`,(e,t)=>{mt.init(e,t),rg.init(e,t)});function Cg(e,t){return new Sg({type:`union`,options:e,...gn(t)})}var wg=fn(`ZodMiniDiscriminatedUnion`,(e,t)=>{Oe.init(e,t),rg.init(e,t)});function Tg(e,t,n){return new wg({type:`union`,options:t,discriminator:e,...gn(n)})}var Eg=fn(`ZodMiniRecord`,(e,t)=>{nn.init(e,t),rg.init(e,t)});function Dg(e,t,n){return!t||!t._zod?new Eg({type:`record`,keyType:ag(),valueType:e,...gn(t)}):new Eg({type:`record`,keyType:e,valueType:t,...gn(n)})}var Og=fn(`ZodMiniEnum`,(e,t)=>{u.init(e,t),rg.init(e,t),e.options=[...e._zod.values]});function kg(e,t){return new Og({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...gn(t)})}var Ag=fn(`ZodMiniLiteral`,(e,t)=>{gt.init(e,t),rg.init(e,t)});function jg(e,t){return new Ag({type:`literal`,values:Array.isArray(e)?e:[e],...gn(t)})}var Mg=fn(`ZodMiniTransform`,(e,t)=>{Lt.init(e,t),rg.init(e,t)});function Ng(e){return new Mg({type:`transform`,transform:e})}var Pg=fn(`ZodMiniOptional`,(e,t)=>{ot.init(e,t),rg.init(e,t)});function Fg(e){return new Pg({type:`optional`,innerType:e})}var Ig=fn(`ZodMiniPipe`,(e,t)=>{Wt.init(e,t),rg.init(e,t)});function Lg(e,t){return new Ig({type:`pipe`,in:e,out:t})}var Rg=fn(`ZodMiniCustom`,(e,t)=>{Qe.init(e,t),rg.init(e,t)});function zg(e,t){return oe(Rg,e??(()=>!0),t)}function Bg(e,t={}){return Ke(Rg,e,t)}var Vg=`AI_InvalidArgumentError`,Hg=`vercel.ai.error.${Vg}`,Ug=Symbol.for(Hg),Wg=class extends Gp{constructor({parameter:e,value:t,message:n}){super({name:Vg,message:`Invalid argument for parameter ${e}: ${n}`}),this[Ug]=!0,this.parameter=e,this.value=t}static isInstance(e){return Gp.hasMarker(e,Hg)}},Gg=new Map([[`generateObject`,`AISDK_DEP_GENERATE_OBJECT`],[`streamObject`,`AISDK_DEP_STREAM_OBJECT`],[`experimental_generateSpeech`,`AISDK_DEP_EXPERIMENTAL_GENERATE_SPEECH`],[`experimental_transcribe`,`AISDK_DEP_EXPERIMENTAL_TRANSCRIBE`],[`"image" content part`,`AISDK_DEP_IMAGE_CONTENT_PART`],[`"tool-result" content of type "file-data"`,`AISDK_DEP_TOOL_RESULT_FILE_DATA`],[`"tool-result" content of type "file-url"`,`AISDK_DEP_TOOL_RESULT_FILE_URL`],[`"tool-result" content of type "file-id"`,`AISDK_DEP_TOOL_RESULT_FILE_ID`],[`"tool-result" content of type "file-reference"`,`AISDK_DEP_TOOL_RESULT_FILE_REFERENCE`],[`"tool-result" content of type "image-data"`,`AISDK_DEP_TOOL_RESULT_IMAGE_DATA`],[`"tool-result" content of type "image-url"`,`AISDK_DEP_TOOL_RESULT_IMAGE_URL`],[`"tool-result" content of type "image-file-id"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_ID`],[`"tool-result" content of type "image-file-reference"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_REFERENCE`],[`rawInput in output-error UI message parts`,`AISDK_DEP_UI_MESSAGE_RAW_INPUT`]]);function Kg(e){return e.replace(/[^a-zA-Z0-9]/g,e=>`_${e.charCodeAt(0).toString(16).toUpperCase().padStart(4,`0`)}`)}function qg({setting:e,provider:t}){return t==null?Gg.get(e)??`AISDK_DEP_SETTING_${Kg(e)}`:`AISDK_DEP_PROVIDER_${Kg(t)}__${Kg(e)}`}function Jg({warning:e,provider:t,model:n}){let r=`AI SDK Warning${t!=null&&n!=null?` (${t} / ${n})`:``}:`;switch(e.type){case`unsupported`:{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case`compatibility`:{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case`deprecated`:return`${r} Deprecated: "${e.setting}". ${e.message}`;case`other`:return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}var Yg=`AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.`,Xg=!1,Zg=new Set;function Qg({message:e,type:t,code:n}){typeof process<`u`&&typeof process.emitWarning==`function`?process.emitWarning(e,n==null?{type:t}:{type:t,code:n}):console.warn(n==null?e:`[${n}] ${e}`)}var $g=e=>{if(e.warnings.length===0)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t==`function`){t(e);return}Xg||(Xg=!0,Qg({message:Yg,type:`Warning`}));for(let t of e.warnings){let n=t.type===`deprecated`?qg({setting:t.setting,provider:e.provider}):void 0;if(n!=null){if(Zg.has(n))continue;Zg.add(n)}Qg({message:Jg({warning:t,provider:e.provider,model:e.model}),type:t.type===`deprecated`?`DeprecationWarning`:`Warning`,code:n})}}};function e_(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(!(r===`__proto__`||r===`constructor`||r===`prototype`)&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);o&&s?n[r]=e_(a,i):n[r]=i}return n}function t_(e,t){return e!=null&&Object.hasOwn(e,t)?e[t]:void 0}function n_(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(typeof e!=`object`&&typeof t!=`object`)return e===t;if(e.constructor!==t.constructor)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!n_(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||!n_(e[i],t[i]))return!1;return!0}new TextEncoder,new TextEncoder;var r_=`AI_UIMessageStreamError`,i_=`vercel.ai.error.${r_}`,a_=Symbol.for(i_),o_=class extends Gp{constructor({chunkType:e,chunkId:t,message:n}){super({name:r_,message:n}),this[a_]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Gp.hasMarker(e,i_)}};function s_(e){let t=[`ROOT`],n=-1,r=null,i=0;function a(e){return e>=`0`&&e<=`9`||e>=`A`&&e<=`F`||e>=`a`&&e<=`f`}function o(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`)}}function s(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop()}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop()}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case`ROOT`:o(u,l,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=l,t.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`)}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`)}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`)}break;case`INSIDE_OBJECT_BEFORE_VALUE`:o(u,l,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:s(u,l);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=l;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=l}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=l,t.pop();break;default:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=l,t.pop();break;default:n=l}break;case`INSIDE_ARRAY_AFTER_COMMA`:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),u===`u`?(i=0,t.push(`INSIDE_STRING_UNICODE_ESCAPE`)):n=l;break;case`INSIDE_STRING_UNICODE_ESCAPE`:a(u)&&(i++,i===4&&(t.pop(),n=l));break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=l;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l);break;default:t.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,l+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?s(u,l):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l)):n=l;break}}}let l=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:l+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:l+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:l+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?l+=`true`.slice(t.length):`false`.startsWith(t)?l+=`false`.slice(t.length):`null`.startsWith(t)&&(l+=`null`.slice(t.length))}}return l}async function c_(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await eg({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await eg({text:s_(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}jm({prefix:`steer`,size:24}),jm({prefix:`aitxt`,size:24}),jm({prefix:`call`,size:24}),TransformStream;var B={NEVER:Tn,array:_g,boolean:dg,custom:zg,discriminatedUnion:Tg,enum:kg,extend:xg,int:lg,literal:jg,looseObject:bg,maximum:Ae,minLength:En,never:hg,nonnegative:Ue,number:sg,object:yg,optional:Fg,pipe:Lg,positive:Be,record:Dg,refine:Bg,safeParse:wt,startsWith:re,string:ag,transform:Ng,union:Cg,unknown:pg},V={array:vt,boolean:et,custom:cn,discriminatedUnion:xn,instanceof:Rt,lazy:_n,literal:Ne,null:St,number:pn,object:N,record:S,string:F,union:f,unknown:kt},l_=V.lazy(()=>V.union([V.null(),V.string(),V.number(),V.boolean(),V.record(V.string(),l_.optional()),V.array(l_)])),H=V.record(V.string(),V.record(V.string(),l_.optional()));function u_(e){return B.object({source:B.discriminatedUnion(`sourceType`,[B.object({type:B.literal(`source`),sourceType:B.literal(`url`),id:B.string(),url:B.string(),title:B.optional(B.string()),providerMetadata:B.optional(e)}),B.object({type:B.literal(`source`),sourceType:B.literal(`document`),id:B.string(),mediaType:B.string(),title:B.string(),filename:B.optional(B.string()),providerMetadata:B.optional(e)})]),startIndex:B.optional(B.number().check(B.int()).check(B.nonnegative())),endIndex:B.optional(B.number().check(B.int()).check(B.nonnegative())),citedText:B.optional(B.string())})}var d_=u_(H),f_=B.record(B.string(),B.optional(l_)),p_=Hh(()=>Zh(B.union([B.looseObject({type:B.literal(`text-start`),id:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`text-delta`),id:B.string(),delta:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`text-end`),id:B.string(),citations:B.optional(B.array(d_)),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`error`),errorText:B.string()}),B.looseObject({type:B.literal(`tool-input-start`),toolCallId:B.string(),toolName:B.string(),inputEncoding:B.optional(B.enum([`json`,`text`])),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H),toolMetadata:B.optional(f_),dynamic:B.optional(B.boolean()),title:B.optional(B.string())}),B.looseObject({type:B.literal(`tool-input-delta`),toolCallId:B.string(),inputTextDelta:B.string()}),B.looseObject({type:B.literal(`tool-input-available`),toolCallId:B.string(),toolName:B.string(),input:B.unknown(),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H),toolMetadata:B.optional(f_),dynamic:B.optional(B.boolean()),title:B.optional(B.string())}),B.looseObject({type:B.literal(`tool-input-error`),toolCallId:B.string(),toolName:B.string(),input:B.unknown(),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H),toolMetadata:B.optional(f_),dynamic:B.optional(B.boolean()),errorText:B.string(),title:B.optional(B.string())}),B.looseObject({type:B.literal(`tool-approval-request`),approvalId:B.string(),toolCallId:B.string(),approvalDescriptor:B.optional(B.unknown()),inputSchemaInput:B.optional(B.unknown()),reason:B.optional(B.string()),isAutomatic:B.optional(B.boolean()),signature:B.optional(B.string())}),B.looseObject({type:B.literal(`tool-approval-response`),approvalId:B.string(),approved:B.boolean(),reason:B.optional(B.string()),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`tool-output-available`),toolCallId:B.string(),output:B.unknown(),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H),toolMetadata:B.optional(f_),dynamic:B.optional(B.boolean()),preliminary:B.optional(B.boolean())}),B.looseObject({type:B.literal(`tool-output-error`),toolCallId:B.string(),errorText:B.string(),providerExecuted:B.optional(B.boolean()),providerMetadata:B.optional(H),toolMetadata:B.optional(f_),dynamic:B.optional(B.boolean())}),B.looseObject({type:B.literal(`tool-output-denied`),toolCallId:B.string()}),B.looseObject({type:B.literal(`reasoning-start`),id:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`reasoning-delta`),id:B.string(),delta:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`reasoning-end`),id:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`custom`),kind:B.pipe(B.string(),B.transform(e=>e)),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`source-url`),sourceId:B.string(),url:B.string(),title:B.optional(B.string()),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`source-document`),sourceId:B.string(),mediaType:B.string(),title:B.string(),filename:B.optional(B.string()),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`file`),url:B.string(),mediaType:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`reasoning-file`),url:B.string(),mediaType:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`steering-message`),id:B.string(),parts:B.array(B.union([B.looseObject({type:B.literal(`text`),text:B.string(),providerMetadata:B.optional(H)}),B.looseObject({type:B.literal(`file`),mediaType:B.string(),url:B.string(),filename:B.optional(B.string()),providerReference:B.optional(B.record(B.string(),B.string())),providerMetadata:B.optional(H)})]))}),B.looseObject({type:B.custom(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:B.optional(B.string()),data:B.unknown(),transient:B.optional(B.boolean())}),B.looseObject({type:B.literal(`start-step`)}),B.looseObject({type:B.literal(`finish-step`)}),B.looseObject({type:B.literal(`reset-step`)}),B.looseObject({type:B.literal(`start`),messageId:B.optional(B.string()),messageMetadata:B.optional(B.unknown())}),B.looseObject({type:B.literal(`finish`),finishReason:B.optional(B.enum([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`interrupted`,`other`])),messageMetadata:B.optional(B.unknown())}),B.looseObject({type:B.literal(`abort`),reason:B.optional(B.string())}),B.looseObject({type:B.literal(`message-metadata`),messageMetadata:B.unknown()})])));function m_(e){return e.type.startsWith(`data-`)}function h_(){return Object.create(null)}function g_(e){return e.type===`text`}function __(e){return e.type===`reasoning`}function v_(e){return e.type.startsWith(`tool-`)}function y_(e){return e.type===`dynamic-tool`}function b_(e){return v_(e)||y_(e)}function x_(e){return e.type.split(`-`).slice(1).join(`-`)}function S_(e){return y_(e)?e.toolName:x_(e)}function C_({lastMessage:e,messageId:t}){let n=e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},r=h_(),i=n.parts.findLastIndex(e=>e.type===`step-start`),a=0;for(let e of n.parts.slice(i+1)){if(!b_(e))continue;let t=a;v_(e)&&a++,e.state===`input-streaming`&&(r[e.toolCallId]={text:e.rawInput??``,inputEncoding:e.inputEncoding,index:t,toolName:e.type===`dynamic-tool`?e.toolName:x_(e),dynamic:e.type===`dynamic-tool`,title:e.title,toolMetadata:e.toolMetadata})}return{message:n,activeTextParts:h_(),activeReasoningParts:h_(),partialToolCalls:r}}function w_({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o,resetStateOnMessageIdChange:s=!1,resetStateOnFirstMessageStart:c=!1}){let l=!0;return e.pipeThrough(new TransformStream({async transform(e,u){await r(async({state:r,write:d})=>{function f(){let e=r.message.parts,t=e.length-1;for(;t>=0&&e[t].type!==`step-start`;)t--;return e.slice(t+1)}function p(){return f().filter(b_)}function m(e){let t=p().find(t=>t.toolCallId===e);if(t==null){let n=r.message.parts;for(let r=n.length-1;r>=0;r--){let i=n[r];if(b_(i)&&i.toolCallId===e){t=i;break}}}if(t==null)throw new o_({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function h(e){let t=r.message.parts.filter(b_).find(t=>t.approval?.id===e);if(t==null)throw new o_({chunkType:`tool-approval-response`,chunkId:e,message:`No tool invocation found for approval ID "${e}".`});return t}function g(e,t){let n=t??f().find(t=>v_(t)&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.type=`tool-${e.toolName}`,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,rawInput:i.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,preliminary:i.preliminary,...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}function _(e,t){let n=t??f().find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.toolName=e.toolName,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,errorText:i.errorText,preliminary:i.preliminary,providerExecuted:i.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}async function v(e){if(e!=null){let n=r.message.metadata==null?e:e_(r.message.metadata,e);t!=null&&await Qh({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),d();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new o_({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new o_({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,e.citations!=null&&(t.citations=e.citations),t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],d();break}case`custom`:{let t={type:`custom`,kind:e.kind,providerMetadata:e.providerMetadata};r.message.parts.push(t),d();break}case`reasoning-start`:{let t={type:`reasoning`,id:e.id,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),d();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new o_({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new o_({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],d();break}case`file`:case`reasoning-file`:r.message.parts.push({type:e.type,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),d();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),d();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),d();break;case`tool-input-start`:{let t=f().filter(v_);r.partialToolCalls[e.toolCallId]={text:``,inputEncoding:e.inputEncoding,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),d();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new o_({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let n=t.inputEncoding===`text`?t.text:(await c_(t.text)).value;t.dynamic?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}):g({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}),d();break}case`tool-input-available`:e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),d(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=f().filter(b_).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),d();break}case`tool-approval-request`:{let t=m(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.approvalDescriptor==null?{}:{descriptor:e.approvalDescriptor},...Object.prototype.hasOwnProperty.call(e,`inputSchemaInput`)?{inputSchemaInput:e.inputSchemaInput}:{},...e.reason==null?{}:{requestReason:e.reason},...e.isAutomatic===!0?{isAutomatic:!0}:{},...e.signature==null?{}:{signature:e.signature}},d();break}case`tool-approval-response`:{let t=h(e.approvalId),n=t.approval==null?{id:e.approvalId}:t.approval;t.state=`approval-responded`,t.approval={...n,id:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason}},e.providerExecuted!=null&&(t.providerExecuted=e.providerExecuted),e.providerMetadata!=null&&(t.callProviderMetadata=e.providerMetadata),d();break}case`tool-output-denied`:{let t=m(e.toolCallId);t.state=`output-denied`,d();break}case`tool-output-available`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:x_(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`tool-output-error`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:x_(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`steering-message`:r.message.parts.push({type:`steering-message`,id:e.id,parts:e.parts}),d();break;case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:break;case`reset-step`:{let e=f();r.activeTextParts=h_(),r.activeReasoningParts=h_(),r.partialToolCalls=h_(),e.length>0&&(r.message.parts.splice(r.message.parts.length-e.length,e.length),d());break}case`start`:{let t=c&&l||s&&e.messageId!=null&&e.messageId!==r.message.id;l=!1,t&&Object.assign(r,C_({lastMessage:void 0,messageId:e.messageId??r.message.id}),{finishReason:void 0}),e.messageId!=null&&(r.message.id=e.messageId),await v(e.messageMetadata),(t||e.messageId!=null||e.messageMetadata!=null)&&d({updateStatus:!1});break}case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`message-metadata`:await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`error`:i?.(Error(e.errorText));break;default:if(m_(e)){let t=n?.[e.type.slice(5)];if(t!=null){let n=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=n>=0?n:r.message.parts.length;await Qh({value:e.data,schema:t,context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let i=e;if(i.transient){o?.(i);break}let a=i.id==null?void 0:r.message.parts.find(e=>i.type===e.type&&i.id===e.id);a==null?r.message.parts.push(i):a.data=i.data,o?.(i),d()}}u.enqueue(e)})}}))}async function T_({stream:e,onError:t,abortSignal:n}){let r=e.getReader(),i=()=>{r.cancel().catch(()=>{})};n?.aborted?i():n?.addEventListener(`abort`,i,{once:!0});try{for(;;){let{done:e}=await r.read();if(e)break}}catch(e){t?.(e)}finally{n?.removeEventListener(`abort`,i),r.releaseLock()}}function E_(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}jm({prefix:`aitxt`,size:24}),jm({prefix:`call`,size:24}),jm({prefix:`aitxt`,size:24}),jm({prefix:`call`,size:24});function D_(e){return e.dynamic=!1,e}var O_={type:`deprecated`,setting:`rawInput in output-error UI message parts`,message:`Use the "input" field instead. The "rawInput" field will be removed in the next major version.`};function k_(e){e.some(e=>e.parts.some(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`&&(e.type===`dynamic-tool`||e.type.startsWith(`tool-`))&&`state`in e&&e.state===`output-error`&&Object.prototype.hasOwnProperty.call(e,`rawInput`)&&`rawInput`in e&&e.rawInput!==void 0))&&$g({warnings:[O_]})}var A_=Symbol(`invalid`);function j_(e){let t=[],n=M_(e,t,new Set);return n===A_?{success:!1,path:t}:{success:!0,value:n}}function M_(e,t,n){switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isFinite(e)?e:A_;case`object`:{if(e===null)return e;if(n.has(e))return A_;n.add(e);let r=Array.isArray(e)?N_(e,t,n):P_(e,t,n);return n.delete(e),r}default:return A_}}function N_(e,t,n){let r;for(let i=0;i<e.length;i++){let a=e[i];t.push(i);let o=M_(a,t,n);if(o===A_)return A_;t.pop(),r==null?o!==a&&(r=e.slice(0,i),r.push(o)):r.push(o)}return r??e}function P_(e,t,n){if(!I_(e)||L_(e))return A_;let r=Object.keys(e),i;for(let a=0;a<r.length;a++){let o=r[a];if(o===`__proto__`){i??=F_(e,r,a);continue}let s=e[o],c=s;if(s!==void 0){if(t.push(o),c=M_(s,t,n),c===A_)return A_;t.pop()}i==null?c!==s&&(i=F_(e,r,a),i[o]=c):i[o]=c}return i??e}function F_(e,t,n){let r={};for(let i=0;i<n;i++)r[t[i]]=e[t[i]];return r}function I_(e){let t=e.constructor;if(typeof t!=`function`)return!0;let n=t.prototype;return typeof n==`object`&&!!n&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)}function L_(e){let t=Object.getOwnPropertySymbols(e);for(let n=0;n<t.length;n++)if(Object.prototype.propertyIsEnumerable.call(e,t[n]))return!0;return!1}var R_=B.pipe(B.unknown(),B.transform((e,t)=>{let n=j_(e);return n.success?n.value:(t.issues.push({code:`custom`,message:`Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.`,input:e,path:n.path}),B.NEVER)})),z_=B.custom(),B_=B.pipe(R_,B.record(B.string(),z_)),V_=B.pipe(R_,B.record(B.string(),B.record(B.string(),z_))),H_=B.record(B.string(),B.string()),U_=u_(V_);function W_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function G_(e){let{type:t,...n}=e;return D_({...n,type:`dynamic-tool`,toolName:t.slice(5)})}function K_(e){return e.approval!=null&&Object.prototype.hasOwnProperty.call(e.approval,`inputSchemaInput`)?{value:e.approval.inputSchemaInput}:void 0}function q_(e){return B.pipe(B.array(B.unknown()),B.transform((t,n)=>{let r=[];for(let[i,a]of t.entries()){let t=B.safeParse(e(a),a);if(!t.success){for(let e of t.error.issues)n.issues.push({...e,path:[i,...e.path]});return B.NEVER}r.push(t.data)}return r}))}var J_=Hh(()=>{let e=B.object({id:B.string(),approved:B.optional(B.never()),descriptor:B.optional(B.unknown()),requestReason:B.optional(B.string()),reason:B.optional(B.never()),isAutomatic:B.optional(B.boolean()),signature:B.optional(B.string()),inputSchemaInput:B.optional(B.unknown())}),t=B.extend(e,{approved:B.boolean(),reason:B.optional(B.string())}),n=B.extend(t,{approved:B.literal(!0)}),r=B.extend(t,{approved:B.literal(!1)}),i=B.discriminatedUnion(`type`,[B.object({type:B.literal(`text`),text:B.string(),providerMetadata:B.optional(V_)}),B.object({type:B.literal(`file`),mediaType:B.string(),filename:B.optional(B.string()),url:B.string(),providerReference:B.optional(H_),providerMetadata:B.optional(V_)})]),a=B.discriminatedUnion(`type`,[B.object({type:B.literal(`text`),text:B.string(),citations:B.optional(q_(()=>U_)),state:B.optional(B.enum([`streaming`,`done`])),providerMetadata:B.optional(V_)}),B.object({type:B.literal(`reasoning`),id:B.optional(B.string()),text:B.string(),state:B.optional(B.enum([`streaming`,`done`])),providerMetadata:B.optional(V_)}),B.object({type:B.literal(`custom`),kind:B.string(),providerMetadata:B.optional(V_)}),B.object({type:B.literal(`source-url`),sourceId:B.string(),url:B.string(),title:B.optional(B.string()),providerMetadata:B.optional(V_)}),B.object({type:B.literal(`source-document`),sourceId:B.string(),mediaType:B.string(),title:B.string(),filename:B.optional(B.string()),providerMetadata:B.optional(V_)}),B.object({type:B.literal(`file`),mediaType:B.string(),filename:B.optional(B.string()),url:B.string(),providerReference:B.optional(H_),providerMetadata:B.optional(V_)}),B.object({type:B.literal(`reasoning-file`),mediaType:B.string(),url:B.string(),providerMetadata:B.optional(V_)}),B.object({type:B.literal(`steering-message`),id:B.string(),parts:q_(()=>i)}),B.object({type:B.literal(`step-start`)})],{error:e=>e.code===`invalid_union`?`Invalid UI message part type. Expected a known part type (for example "text" or "dynamic-tool") or a type starting with "data-" or "tool-".`:void 0}),o=B.object({type:B.string().check(B.startsWith(`data-`)),id:B.optional(B.string()),data:B.unknown()}),s=B.discriminatedUnion(`state`,[B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`input-streaming`),input:B.optional(B.unknown()),rawInput:B.optional(B.string()),inputEncoding:B.optional(B.enum([`json`,`text`])),providerExecuted:B.optional(B.boolean()),callProviderMetadata:B.optional(V_),output:B.optional(B.never()),errorText:B.optional(B.never()),approval:B.optional(B.never())}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`input-available`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(V_),approval:B.optional(B.never())}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`approval-requested`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(V_),approval:e}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`approval-responded`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(V_),approval:t}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`output-available`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.unknown(),errorText:B.optional(B.never()),callProviderMetadata:B.optional(V_),resultProviderMetadata:B.optional(V_),preliminary:B.optional(B.boolean()),approval:B.optional(n)}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`output-error`),input:B.optional(B.unknown()),rawInput:B.optional(B.unknown()),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.string(),callProviderMetadata:B.optional(V_),resultProviderMetadata:B.optional(V_),approval:B.optional(n)}),B.object({type:B.literal(`dynamic-tool`),dynamic:B.optional(B.literal(!1)),toolName:B.string(),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`output-denied`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(V_),approval:r})]),c=B.discriminatedUnion(`state`,[B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`input-streaming`),providerExecuted:B.optional(B.boolean()),callProviderMetadata:B.optional(V_),input:B.optional(B.unknown()),rawInput:B.optional(B.string()),inputEncoding:B.optional(B.enum([`json`,`text`])),output:B.optional(B.never()),errorText:B.optional(B.never()),approval:B.optional(B.never())}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`input-available`),providerExecuted:B.optional(B.boolean()),input:B.unknown(),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(V_),approval:B.optional(B.never())}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`approval-requested`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(V_),approval:e}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`approval-responded`),input:B.unknown(),providerExecuted:B.optional(B.boolean()),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(V_),approval:t}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`output-available`),providerExecuted:B.optional(B.boolean()),input:B.unknown(),output:B.unknown(),errorText:B.optional(B.never()),callProviderMetadata:B.optional(V_),resultProviderMetadata:B.optional(V_),preliminary:B.optional(B.boolean()),approval:B.optional(n)}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`output-error`),providerExecuted:B.optional(B.boolean()),input:B.optional(B.unknown()),rawInput:B.optional(B.unknown()),output:B.optional(B.never()),errorText:B.string(),callProviderMetadata:B.optional(V_),resultProviderMetadata:B.optional(V_),approval:B.optional(n)}),B.object({type:B.string().check(B.startsWith(`tool-`)),toolCallId:B.string(),title:B.optional(B.string()),toolMetadata:B.optional(B_),state:B.literal(`output-denied`),providerExecuted:B.optional(B.boolean()),input:B.unknown(),output:B.optional(B.never()),errorText:B.optional(B.never()),callProviderMetadata:B.optional(V_),approval:r})]),l=B.object({id:B.string(),role:B.enum([`system`,`user`,`assistant`]),metadata:B.optional(B.unknown()),parts:q_(e=>{let t=e?.type;if(typeof t==`string`){if(t.startsWith(`data-`))return o;if(t.startsWith(`tool-`))return c;if(t===`dynamic-tool`)return s}return a})}).check(e=>{let t=e.value;t.role!==`assistant`&&t.parts.length===0&&e.issues.push({continue:!0,origin:`array`,code:`too_small`,minimum:1,inclusive:!0,input:t.parts,path:[`parts`],message:`Message must contain at least one part`})});return Zh(q_(()=>l).check(B.minLength(1,`Messages array must not be empty`)))});async function Y_({messages:e,metadataSchema:t,dataSchemas:n,tools:r,experimental_refineToolInput:i},{convertMissingTerminalToolsToDynamic:a}){try{if(e==null)return{success:!1,error:new Wg({parameter:`messages`,value:e,message:`messages parameter must be provided`})};let o=await Qh({value:e,schema:J_});if(k_(o),t)for(let[e,n]of o.entries())n.metadata=await Qh({value:n.metadata,schema:t,context:{field:`messages[${e}].metadata`,entityId:n.id}});let s=r!=null||a;if(n||s)for(let[e,t]of o.entries())for(let[o,c]of t.parts.entries()){if(n&&c.type.startsWith(`data-`)){let t=c,r=t.type.slice(5),i=n[r];if(!i)return{success:!1,error:new fm({value:t.data,cause:`No data schema found for data part ${r}`,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})};t.data=await Qh({value:t.data,schema:i,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})}if(s&&c.type.startsWith(`tool-`)){let n=c,s=n.type.slice(5),l=r==null?void 0:t_(r,s),u=n.state===`output-available`||n.state===`output-error`||n.state===`output-denied`;if(!l&&u){(r!=null||a)&&(t.parts[o]=G_(n));continue}if(!l)return{success:!1,error:new fm({value:n.input,cause:`No tool schema found for tool part ${s}`,context:{field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId}})};let d={field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId},f=K_(n),p=f==null?n.input:f.value,m=!1;if(n.state!==`input-streaming`&&(n.state!==`output-error`||f!=null||n.input!==void 0)){let e=await $h({value:p,schema:l.inputSchema,context:d}),t;if(!e.success)t=e.error;else if(f!=null)try{let r=t_(i,s);n_(r==null?e.value:await r(e.value),n.input)||(t=new fm({value:n.input,cause:`Tool input does not match the output reconstructed from inputSchemaInput.`,context:d}))}catch(e){t=new fm({value:p,cause:e,context:d})}if(t!=null)if(n.state===`output-error`||n.state===`output-available`&&W_(n.input))m=!0;else throw t}n.state===`output-available`&&l.outputSchema&&await Qh({value:n.output,schema:l.outputSchema,context:{field:`messages[${e}].parts[${o}].output`,entityName:s,entityId:n.toolCallId}}),m&&(t.parts[o]=G_(n))}}return{success:!0,data:o}}catch(e){return{success:!1,error:e}}}async function X_(e){return Y_(e,{convertMissingTerminalToolsToDynamic:!1})}async function Z_(e){let t=await X_(e);if(!t.success)throw t.error;return t.data}jm({prefix:`call`,size:24}),jm({prefix:`call`,size:24}),new TextEncoder,jm({prefix:`call`,size:24}),jm({prefix:`call`,size:24}),jm({prefix:`aiobj`,size:24});var{atob:ree}=globalThis,Q_=class{constructor(){this.queue=[],this.isProcessing=!1,this.idleWaiters=[]}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;this.queue.length>0;)await this.queue[0](),this.queue.shift()}finally{this.isProcessing=!1;for(let e of this.idleWaiters.splice(0))e()}}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}async waitForIdle(){!this.isProcessing&&this.queue.length===0||await new Promise(e=>{this.idleWaiters.push(e)})}};jm({prefix:`aiobj`,size:24}),jm({prefix:`call`,size:24});var $_=V.union([V.string(),V.custom(Om,{message:`Must be a Uint8Array`}),V.custom(km,{message:`Must be an ArrayBuffer`}),V.custom(Nm,{message:`Must be a Buffer`})]),ev=V.record(V.string(),V.string()),tv=V.object({type:V.literal(`text`),text:V.string(),providerOptions:H.optional()}),nv=V.object({type:V.literal(`image`),image:V.union([$_,V.instanceof(URL),ev]),mediaType:V.string().optional(),providerOptions:H.optional()}),rv=V.discriminatedUnion(`type`,[V.object({type:V.literal(`data`),data:$_}),V.object({type:V.literal(`url`),url:V.instanceof(URL)}),V.object({type:V.literal(`reference`),reference:ev}),V.object({type:V.literal(`text`),text:V.string()})]),iv=V.discriminatedUnion(`type`,[V.object({type:V.literal(`data`),data:$_}),V.object({type:V.literal(`url`),url:V.instanceof(URL)})]),av=V.object({type:V.literal(`file`),data:V.union([rv,$_,V.instanceof(URL),ev]),filename:V.string().optional(),mediaType:V.string(),providerOptions:H.optional()}),ov=V.object({type:V.literal(`reasoning`),text:V.string(),providerOptions:H.optional()}),sv=V.object({type:V.literal(`custom`),kind:V.string().transform(e=>e),providerOptions:H.optional()}),cv=V.object({type:V.literal(`reasoning-file`),data:V.union([iv,$_,V.instanceof(URL)]),mediaType:V.string(),providerOptions:H.optional()}),lv=V.object({type:V.literal(`tool-call`),toolCallId:V.string(),toolName:V.string(),input:V.unknown(),providerOptions:H.optional(),providerExecuted:V.boolean().optional()}),uv=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),value:V.string(),providerOptions:H.optional()}),V.object({type:V.literal(`json`),value:l_,providerOptions:H.optional()}),V.object({type:V.literal(`execution-denied`),reason:V.string().optional(),providerOptions:H.optional()}),V.object({type:V.literal(`error-text`),value:V.string(),providerOptions:H.optional()}),V.object({type:V.literal(`error-json`),value:l_,providerOptions:H.optional()}),V.object({type:V.literal(`content`),value:V.array(V.union([V.object({type:V.literal(`text`),text:V.string(),providerOptions:H.optional()}),V.object({type:V.literal(`file`),data:rv,mediaType:V.string(),filename:V.string().optional(),providerOptions:H.optional()}),V.object({type:V.literal(`file-data`),data:V.string(),mediaType:V.string(),filename:V.string().optional(),providerOptions:H.optional()}),V.object({type:V.literal(`file-url`),url:V.string(),mediaType:V.string().optional(),providerOptions:H.optional()}),V.object({type:V.literal(`file-id`),fileId:V.union([V.string(),V.record(V.string(),V.string())]),providerOptions:H.optional()}),V.object({type:V.literal(`file-reference`),providerReference:V.record(V.string(),V.string()),providerOptions:H.optional()}),V.object({type:V.literal(`image-data`),data:V.string(),mediaType:V.string(),providerOptions:H.optional()}),V.object({type:V.literal(`image-url`),url:V.string(),providerOptions:H.optional()}),V.object({type:V.literal(`image-file-id`),fileId:V.union([V.string(),V.record(V.string(),V.string())]),providerOptions:H.optional()}),V.object({type:V.literal(`image-file-reference`),providerReference:V.record(V.string(),V.string()),providerOptions:H.optional()}),V.object({type:V.literal(`custom`),providerOptions:H.optional()})]))})]),dv=V.object({type:V.literal(`tool-result`),toolCallId:V.string(),toolName:V.string(),output:uv,providerOptions:H.optional()}),fv=V.object({type:V.literal(`tool-approval-request`),approvalId:V.string(),toolCallId:V.string(),reason:V.string().optional(),isAutomatic:V.boolean().optional(),signature:V.string().optional(),inputSchemaInput:V.unknown().optional()}),pv=V.object({type:V.literal(`tool-approval-response`),approvalId:V.string(),approved:V.boolean(),reason:V.string().optional()}),mv=V.object({role:V.literal(`system`),content:V.string(),providerOptions:H.optional()}),hv=V.object({role:V.literal(`user`),content:V.union([V.string(),V.array(V.union([tv,nv,av]))]),providerOptions:H.optional()}),gv=V.object({role:V.literal(`assistant`),content:V.union([V.string(),V.array(V.union([tv,sv,av,ov,cv,lv,dv,fv]))]),providerOptions:H.optional()}),_v=V.object({role:V.literal(`tool`),content:V.array(V.union([dv,pv])),providerOptions:H.optional()});V.union([mv,hv,gv,_v]),B.object({token:B.string().check(B.refine(e=>e.trim().length>0)),url:B.string().check(B.refine(e=>{try{let t=new URL(e);return(t.protocol===`ws:`||t.protocol===`wss:`)&&t.hostname!==``}catch{return!1}})),expiresAt:B.optional(B.number().check(B.positive()).check(B.maximum(2**53-1))),tools:B.optional(B.array(B.object({type:B.literal(`function`),name:B.string().check(B.minLength(1)),description:B.optional(B.string()),parameters:B.record(B.string(),B.unknown())})))}),jm({prefix:`call`,size:24}),jm({prefix:`call`,size:24}),jm({prefix:`call`,size:24});async function vv({response:e,url:t,fallbackMessage:n}){let r=await e.text();return new Yp({message:r||n,url:t,requestBodyValues:void 0,statusCode:e.status,responseBody:r})}async function yv(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new gm({functionality:`FileList`,message:`FileList is not supported in the current environment`});return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}function bv(e,t){let n=e.search(/[?#]/),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n);return`${r.endsWith(`/`)&&t.startsWith(`/`)?r.slice(0,-1):r}${t}${i}`}var xv=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await ng(this.body),r=await ng(this.headers),i=await ng(this.credentials),a={...Am(r),...Am(t.headers)},o=await this.prepareSendMessagesRequest?.({api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:Am(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"content-type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw await vv({response:d,url:s,fallbackMessage:`Failed to fetch the chat response.`});if(!d.body)throw new $p({message:`The response body is empty.`});return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await ng(this.body),n=await ng(this.headers),r=await ng(this.credentials),i={...Am(n),...Am(e.headers)},a=await this.prepareReconnectToStreamRequest?.({api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api;if(o==null){if(e.chatId===`.`||e.chatId===`..`)throw new Wg({parameter:`chatId`,value:e.chatId,message:`Chat IDs must not be "." or ".." when using the default reconnect URL.`});o=bv(this.api,`/${encodeURIComponent(e.chatId)}/stream`)}let s=a?.headers===void 0?i:Am(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c,signal:e.abortSignal});if(l.status===204)return null;if(!l.ok)throw await vv({response:l,url:o,fallbackMessage:`Failed to fetch the chat response.`});if(!l.body)throw new $p({message:`The response body is empty.`});return this.processResponseStream(l.body)}},Sv=class extends xv{constructor({resumeStreamIsReplay:e=!0,...t}={}){super(t),this.resumeStreamIsReplay=e}processResponseStream(e){return tg({stream:e,schema:p_}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},Cv=class{get id(){return this._id??=this.generateId()}constructor({generateId:e=Mm,id:t,transport:n=new Sv,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u,experimental_queue:d=!1}){this.queuedMessagesFallback=[],this.queuedMessageOptions=new Map,this.isQueuePaused=!1,this.pendingAutomaticDecisions=[],this.pendingMessagePreparations=new Set,this.interruptedMessageIds=new Set,this.activeResponse=void 0,this.activeResumeRequest=void 0,this.resumableStreamState=void 0,this.jobExecutor=new Q_,this.activeStopCount=0,this.stopGeneration=0,this.experimental_removeQueuedMessage=e=>{this.queuedMessageOptions.delete(e),this.setQueuedMessages(this.experimental_queuedMessages.filter(t=>t.id!==e))},this.experimental_sendQueuedMessageNow=async e=>{let t=this.experimental_queuedMessages.find(t=>t.id===e);if(t==null)return;this.setQueuedMessages([t,...this.experimental_queuedMessages.filter(t=>t.id!==e)]);let n=this.stopGeneration+1;await this.stop(),n===this.stopGeneration&&await this.resumeQueue({skipWaitForUser:!0,options:this.queuedMessageOptions.get(e)})},this.sendMessage=async(e,t)=>{if(e==null){let e=this.pendingApprovalMessageId;if(e==null){e=this.lastMessage?.id;for(let t=this.state.messages.length-1;t>=0;t--){let n=this.state.messages[t];if(n.role===`assistant`&&n.parts.some(e=>b_(e)&&e.state===`approval-responded`)){e=n.id;break}}}let n=e!=null&&e===this.pendingApprovalMessageId?this.state.messages.findIndex(t=>t.id===e):-1;await this.makeRequestForToolApproval({messageId:e,messageIndex:n,...t});return}let n;if(`text`in e||`files`in e){let t=new AbortController;this.pendingMessagePreparations.add(t);let r;try{r=Array.isArray(e.files)?e.files:await yv(e.files)}finally{this.pendingMessagePreparations.delete(t)}if(t.signal.aborted)return;n={parts:[...r,...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}}else n=e;if(this.queueEnabled&&e.messageId==null&&(this.isRequestInProgress()||this.isWaitingForUser()||this.experimental_queuedMessages.length>0)){let r={...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata};t!=null&&this.queuedMessageOptions.set(r.id,t),this.setQueuedMessages([...this.experimental_queuedMessages,r]),await this.resumeQueue({skipWaitForUser:this.isQueuePaused,options:t});return}if(e.messageId!=null){await this.clearQueueForHistoryChange();let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw new Wg({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} not found`});if(this.state.messages[t].role!==`user`)throw new Wg({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} is not a user message`});this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{id:e.messageId,...n,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});this.isQueuePaused=!1,await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{await this.clearQueueForHistoryChange();let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw new Wg({parameter:`messageId`,value:e,message:`message ${e} not found`});this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this[`~resumeStreamIfDisconnected`]=async({shouldResume:e=()=>!0}={})=>{let t=this.activeResponse;this.resumableStreamState==null&&t!=null&&(await t.completionPromise,this.resumableStreamState!==t.state)||this.resumableStreamState!=null&&e()&&await this.resumeStream()},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.stopGeneration,a=this.state.messages,o=r=>b_(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{...r.approval,id:e,approved:t,reason:n}}:r,s=a.findIndex(t=>t.parts.some(t=>b_(t)&&t.state===`approval-requested`&&t.approval.id===e));if(s!==-1){let e=a[s];this.state.replaceMessage(s,{...e,parts:e.parts.map(o)}),this.pendingApprovalMessageId=e.id}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),s!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(a[s].id);if(e){this.runAutomaticRequest(()=>{let e=s===-1?this.lastMessage?.id:a[s].id;return this.makeRequestForToolApproval({messageId:e,messageIndex:s,...r})},e);return}}this.settleQueue({stopGeneration:i})}),this.addToolOutput=async({state:e,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.stopGeneration,o=this.state.messages,s=i=>{if(!b_(i)||i.toolCallId!==t)return i;let{approval:a,...o}=i,s=a?.approved===!0?{approval:{...a,approved:a.approved}}:{};return e===`output-error`?{...o,...s,state:e,input:i.input,output:void 0,errorText:r}:{...o,...s,state:`output-available`,input:i.input,output:n,errorText:void 0}},c=o.findIndex(e=>e.parts.some(e=>b_(e)&&e.toolCallId===t));if(c!==-1){let e=o[c];this.state.replaceMessage(c,{...e,parts:e.parts.map(s)})}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),c!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(o[c].id);if(e){this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:o[c].id,...i}),e);return}}this.settleQueue({stopGeneration:a})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{this.activeStopCount++,this.stopGeneration++,this.deferredApprovalSend=void 0;try{let e=this.activeResumeRequest,t=this.activeResponse;for(let e of this.pendingMessagePreparations)e.abort();e?.abortController.abort(),t?.abortController.abort(),await Promise.all([e?.completionPromise,t?.completionPromise]),await this.jobExecutor.waitForIdle(),this.isQueuePaused=!0}finally{this.activeStopCount--}},this.dispose=async()=>{await this.stop(),this.transport.close?.()},this._id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u,this.queueEnabled=d}get status(){return this.state.status}setStatus({status:e,error:t}){if(this.status===e){this.error!==t&&(this.state.error=t);return}this.state.status=e,this.state.error=t}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}get experimental_queuedMessages(){return this.state.experimental_queuedMessages??this.queuedMessagesFallback}setQueuedMessages(e){`experimental_queuedMessages`in this.state?this.state.experimental_queuedMessages=e:this.queuedMessagesFallback=e}async resumeQueue({skipWaitForUser:e,options:t}){if(this.isQueuePaused=!1,this.hasUnsentApprovalResponse()){if(!this.isRequestInProgress()){await this.sendMessage(void 0,t);return}this.deferredApprovalSend={options:t}}await this.settleQueue({skipWaitForUser:e})}async clearQueueForHistoryChange(){this.queueEnabled&&(this.queuedMessageOptions.clear(),this.setQueuedMessages([]),this.deferredApprovalSend=void 0,this.isRequestInProgress()&&await this.stop())}isRequestInProgress(){return this.pendingAutomaticDecisions.includes(this.stopGeneration)||this.activeResponse!=null||this.status===`submitted`||this.status===`streaming`}isWaitingForUser(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>b_(e)&&(e.state===`approval-requested`||e.state===`approval-responded`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}hasUnsentApprovalResponse(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>b_(e)&&e.state===`approval-responded`)&&!e.parts.some(e=>b_(e)&&(e.state===`approval-requested`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}async settleQueue({stopGeneration:e=this.stopGeneration,skipWaitForUser:t=!1}={}){if(this.isQueuePaused||this.isRequestInProgress()||this.activeStopCount>0||e!==this.stopGeneration)return;let n=this.deferredApprovalSend;if(this.deferredApprovalSend=void 0,n!=null&&this.hasUnsentApprovalResponse()){await this.sendMessage(void 0,n.options);return}let[r,...i]=this.experimental_queuedMessages;if(r==null||!t&&this.isWaitingForUser())return;let a=this.queuedMessageOptions.get(r.id);this.queuedMessageOptions.delete(r.id),this.setQueuedMessages(i),this.state.pushMessage(r),await this.makeRequest({trigger:`submit-message`,...a})}set messages(e){this.state.messages=e}async shouldSendAutomatically(e=this.lastMessage?.id){let t=e=>e!=null&&this.interruptedMessageIds.has(e);if(!this.sendAutomaticallyWhen||t(e)||t(this.lastMessage?.id))return!1;let n=this.stopGeneration;this.pendingAutomaticDecisions.push(n);let r;try{r=await this.sendAutomaticallyWhen({messages:this.state.messages})}finally{this.pendingAutomaticDecisions.splice(this.pendingAutomaticDecisions.indexOf(n),1)}return r&&!t(e)&&!t(this.lastMessage?.id)}async runAutomaticRequest(e,t){let n=this.stopGeneration,r=this.activeStopCount>0;return!(t??await this.shouldSendAutomatically())||r||n!==this.stopGeneration||this.activeStopCount>0?!1:(await e(),!0)}async makeRequestForToolApproval({messageId:e,messageIndex:t,...n}){this.deferredApprovalSend=void 0;let r=e!=null&&e===this.pendingApprovalMessageId;r&&(this.pendingApprovalMessageId=void 0),await this.makeRequest({trigger:`submit-message`,messageId:e,...n}),r&&this.status===`error`&&this.pendingApprovalMessageId==null&&(this.pendingApprovalMessageId=this.state.messages[t]?.id??e)}async makeRequest(e){let t=E_();try{await this.makeRequestImpl({...e,completionPromise:t.promise})}finally{t.resolve()}}async makeRequestImpl({trigger:e,metadata:t,headers:n,body:r,messageId:i,completionPromise:a}){e!==`resume-stream`&&(this.resumableStreamState=void 0);let o=new AbortController,s=e===`resume-stream`?{abortController:o,completionPromise:a}:void 0;s&&(this.activeResumeRequest?.abortController.abort(),this.activeResumeRequest=s);let c=()=>s==null||this.activeResumeRequest===s,l=()=>{this.activeResumeRequest===s&&(this.activeResumeRequest=void 0)},u;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,abortSignal:o.signal,metadata:t,headers:n,body:r});if(o.signal.aborted||!c()){await e?.cancel().catch(()=>{}),c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(e==null){this.setStatus({status:`ready`}),this.resumableStreamState=void 0,l();return}u=e}catch(e){if(o.signal.aborted||e.name===`AbortError`){c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(!c())return;this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e}),l();return}this.setStatus({status:`submitted`,error:void 0});let d=this.lastMessage,f=e===`submit-message`&&i!=null?this.state.messages.findIndex(e=>e.id===i):this.state.messages.length-1,p=f===-1?d:this.state.messages[f],m=p?.id,h=e===`resume-stream`&&p?.role===`assistant`&&p.parts.some(e=>b_(e)&&(e.state===`input-streaming`||e.state===`input-available`&&e.providerExecuted||e.state===`approval-responded`))?this.state.snapshot(p):void 0,g=f!==-1&&f<this.state.messages.length-1&&p?.role===`assistant`,_=!1,v=!1,y=!1,b;try{let s={state:e===`resume-stream`&&this.resumableStreamState!=null?this.resumableStreamState:C_({lastMessage:e===`resume-stream`?h:e===`regenerate-message`?void 0:this.state.snapshot(p),messageId:this.generateId()}),abortController:o,completionPromise:a};b=s,s.abortController.signal.addEventListener(`abort`,()=>{_=!0}),this.activeResponse=s;let l;if(l=e===`resume-stream`?u:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:s.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await T_({stream:w_({stream:l,resetStateOnMessageIdChange:e===`resume-stream`,resetStateOnFirstMessageStart:e===`resume-stream`&&this.transport.resumeStreamIsReplay,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>s.abortController.signal.aborted?Promise.resolve():e({state:s.state,write:({updateStatus:e=!0}={})=>{if(s.abortController.signal.aborted)return;e&&this.setStatus({status:`streaming`});let t=this.state.messages.findLastIndex(e=>e.id===s.state.message.id);if(t!==-1)this.state.replaceMessage(t,s.state.message);else if(g){let e=this.state.messages.findLastIndex(e=>e.id===m);e===-1?this.state.pushMessage(s.state.message):this.state.replaceMessage(e,s.state.message)}else this.state.pushMessage(s.state.message)}})),onError:e=>{throw e}}),abortSignal:s.abortController.signal,onError:e=>{throw e}}),_)return c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0)),null;c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0))}catch(e){if(_||e.name===`AbortError`)return _=!0,c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0)),null;if(!c())return null;if(y=!0,e instanceof TypeError){let t=e.message.toLowerCase();v=t.includes(`fetch`)||t.includes(`network`)||t===`load failed`}v?this.resumableStreamState=b?.state:this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{if(b){let{message:e,finishReason:t}=b.state;t===`interrupted`?this.interruptedMessageIds.add(e.id):!_&&!y&&this.interruptedMessageIds.delete(e.id),this.onFinish?.({message:b.state.message,messages:this.state.messages,isAbort:_,isDisconnect:v,isError:y,finishReason:b.state.finishReason})}}finally{(_||y||b?.state.finishReason===`interrupted`)&&(this.isQueuePaused=!0),this.activeResponse===b&&(this.activeResponse=void 0),l()}}if(!_&&!y&&b?.state.finishReason!==`interrupted`){let e=this.stopGeneration;await this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r}))||await this.settleQueue({stopGeneration:e})}}};function wv({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1).filter(b_);return r.filter(e=>e.state===`approval-responded`).length>0&&r.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`||e.state===`output-denied`||e.state===`approval-responded`)}function Tv({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1),i=r.filter(b_).filter(e=>!e.providerExecuted),a=r.reduce((e,t,n)=>b_(t)&&!t.providerExecuted?n:e,-1);return i.length>0&&!r.slice(a+1).some(e=>e.type===`text`&&e.state!==`done`)&&i.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`)}var Ev=n(a(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n}))(),1);function Dv(e,t){return t==null?e:(0,Ev.default)(e,t)}function Ov(e){return Array.isArray(e)?[...e]:typeof e==`object`&&e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)?{...e}:e}var kv=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e=[]){this.#t=`ready`,this.#n=void 0,this.#r=[],this.#i=new Set,this.#a=new Set,this.#o=new Set,this.#s=new Set,this.pushMessage=e=>{this.#e=this.#e.concat(e),this.#c()},this.popMessage=()=>{this.#e=this.#e.slice(0,-1),this.#c()},this.replaceMessage=(e,t)=>{this.#e=[...this.#e.slice(0,e),this.snapshot(t),...this.#e.slice(e+1)],this.#c()},this.snapshot=e=>{if(typeof e!=`object`||!e||!(`parts`in e)||!Array.isArray(e.parts))return e;let t=e,n={...t,parts:t.parts.map(e=>({...e}))};return`metadata`in t&&(n.metadata=Ov(t.metadata)),n},this[`~registerMessagesCallback`]=(e,t)=>{let n=t?Dv(e,t):e;return this.#i.add(n),()=>{this.#i.delete(n)}},this[`~registerStatusCallback`]=e=>(this.#o.add(e),()=>{this.#o.delete(e)}),this[`~registerErrorCallback`]=e=>(this.#s.add(e),()=>{this.#s.delete(e)}),this[`~registerQueuedMessagesCallback`]=e=>(this.#a.add(e),()=>{this.#a.delete(e)}),this.#c=()=>{this.#i.forEach(e=>e())},this.#l=()=>{this.#o.forEach(e=>e())},this.#u=()=>{this.#s.forEach(e=>e())},this.#e=e}get status(){return this.#t}set status(e){this.#t=e,this.#l()}get error(){return this.#n}set error(e){this.#n=e,this.#u()}get experimental_queuedMessages(){return this.#r}set experimental_queuedMessages(e){this.#r=e,this.#a.forEach(e=>e())}get messages(){return this.#e}set messages(e){this.#e=[...e],this.#c()}#c;#l;#u},Av=class extends Cv{#e;constructor({messages:e,...t}){let n=new kv(e);super({...t,state:n}),this[`~registerMessagesCallback`]=(e,t)=>this.#e[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>this.#e[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>this.#e[`~registerErrorCallback`](e),this[`~registerQueuedMessagesCallback`]=e=>this.#e[`~registerQueuedMessagesCallback`](e),this.#e=n}},jv=new WeakMap;function Mv({chat:e,state:t}){if(document.visibilityState!==`visible`||t.pendingVisibilityResume!=null)return;let n=()=>jv.get(e)===t&&t.registrations.size>0,r=()=>{t.pendingVisibilityResume=void 0};t.pendingVisibilityResume=e[`~resumeStreamIfDisconnected`]({shouldResume:()=>n()&&document.visibilityState===`visible`}).then(r,r)}function Nv({chat:e,registration:t}){let n=jv.get(e);if(n==null){let t={registrations:new Set};if(jv.set(e,t),n=t,typeof document<`u`){let n=()=>Mv({chat:e,state:t});document.addEventListener(`visibilitychange`,n),t.cleanupVisibilityListener=()=>{document.removeEventListener(`visibilitychange`,n)}}}let{registrations:r}=n,i=r.size===0;return r.add(t),i&&e.status!==`submitted`&&e.status!==`streaming`&&e.resumeStream(),()=>{r.delete(t),r.size===0&&(n.cleanupVisibilityListener?.(),jv.delete(e))}}function Pv(e){return{chat:e,messages:e.messages,status:e.status,error:e.error,experimental_queuedMessages:e.experimental_queuedMessages}}function Fv(e,t){return e.chat===t.chat&&e.messages===t.messages&&e.status===t.status&&e.error===t.error&&e.experimental_queuedMessages===t.experimental_queuedMessages}function Iv({throttle:e,experimental_throttle:t,resume:n=!1,...r}={}){let i=e??t,a=(0,I.useRef)({}),o=(0,I.useRef)({});`chat`in r||(o.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen,transport:r.transport});let s,c=()=>o.current.transport??(s??=new Sv),l={...r,transport:{get resumeStreamIsReplay(){return c().resumeStreamIsReplay},sendMessages:e=>c().sendMessages(e),reconnectToStream:e=>c().reconnectToStream(e)},onToolCall:e=>o.current.onToolCall?.(e),onData:e=>o.current.onData?.(e),onFinish:e=>o.current.onFinish?.(e),onError:e=>o.current.onError?.(e),sendAutomaticallyWhen:e=>o.current.sendAutomaticallyWhen?.(e)??!1},{chat:u,isExternallyManaged:d}=(0,I.useMemo)(()=>({chat:`chat`in r?r.chat:new Av(l),isExternallyManaged:`chat`in r}),[`chat`in r?r.chat:r.id]);(0,I.useEffect)(()=>{if(!d)return()=>{u.stop()}},[u,d]);let[f,p]=(0,I.useState)(()=>Pv(u));f.chat!==u&&p(Pv(u)),(0,I.useEffect)(()=>{let e=!0,t=()=>{if(!e)return;let t=Pv(u);p(e=>e.chat!==u||Fv(e,t)?e:t)},n=[u[`~registerMessagesCallback`](t,i),u[`~registerStatusCallback`](t),u[`~registerErrorCallback`](t),u[`~registerQueuedMessagesCallback`](t)],r=Pv(u);return p(e=>Fv(e,r)?e:r),()=>{e=!1,n.forEach(e=>e())}},[u,i]);let{messages:m,status:h,error:g,experimental_queuedMessages:_}=f,v=(0,I.useCallback)(e=>{typeof e==`function`&&(e=e(u.messages)),u.messages=e},[u]);return(0,I.useEffect)(()=>{if(n)return Nv({chat:u,registration:a.current})},[n,u]),{get id(){return u.id},messages:m,setMessages:v,sendMessage:u.sendMessage,regenerate:u.regenerate,clearError:u.clearError,stop:u.stop,error:g,resumeStream:u.resumeStream,status:h,addToolResult:u.addToolOutput,addToolOutput:u.addToolOutput,addToolApprovalResponse:u.addToolApprovalResponse,experimental_queuedMessages:_,experimental_removeQueuedMessage:u.experimental_removeQueuedMessage,experimental_sendQueuedMessageNow:u.experimental_sendQueuedMessageNow}}var Lv=a(((e,t)=>{(function(n,r){typeof i==`function`&&typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(function(){return r()}):n.pluralize=r()})(e,function(){var e=[],t=[],n={},r={},i={};function a(e){return typeof e==`string`?RegExp(`^`+e+`$`,`i`):e}function o(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||``})}function c(e,t){return e.replace(t[0],function(n,r){var i=s(t[1],arguments);return o(n===``?e[r-1]:n,i)})}function l(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var a=r[i];if(a[0].test(t))return c(t,a)}return t}function u(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?o(r,i):e.hasOwnProperty(i)?o(r,e[i]):l(i,r,n)}}function d(e,t,n,r){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?!0:!e.hasOwnProperty(i)&&l(i,i,n)===i}}function f(e,t,n){var r=t===1?f.singular(e):f.plural(e);return(n?t+` `:``)+r}return f.plural=u(i,r,e),f.isPlural=d(i,r,e),f.singular=u(r,i,t),f.isSingular=d(r,i,t),f.addPluralRule=function(t,n){e.push([a(t),n])},f.addSingularRule=function(e,n){t.push([a(e),n])},f.addUncountableRule=function(e){if(typeof e==`string`){n[e.toLowerCase()]=!0;return}f.addPluralRule(e,`$0`),f.addSingularRule(e,`$0`)},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[[`I`,`we`],[`me`,`us`],[`he`,`they`],[`she`,`they`],[`them`,`them`],[`myself`,`ourselves`],[`yourself`,`yourselves`],[`itself`,`themselves`],[`herself`,`themselves`],[`himself`,`themselves`],[`themself`,`themselves`],[`is`,`are`],[`was`,`were`],[`has`,`have`],[`this`,`these`],[`that`,`those`],[`echo`,`echoes`],[`dingo`,`dingoes`],[`volcano`,`volcanoes`],[`tornado`,`tornadoes`],[`torpedo`,`torpedoes`],[`genus`,`genera`],[`viscus`,`viscera`],[`stigma`,`stigmata`],[`stoma`,`stomata`],[`dogma`,`dogmata`],[`lemma`,`lemmata`],[`schema`,`schemata`],[`anathema`,`anathemata`],[`ox`,`oxen`],[`axe`,`axes`],[`die`,`dice`],[`yes`,`yeses`],[`foot`,`feet`],[`eave`,`eaves`],[`goose`,`geese`],[`tooth`,`teeth`],[`quiz`,`quizzes`],[`human`,`humans`],[`proof`,`proofs`],[`carve`,`carves`],[`valve`,`valves`],[`looey`,`looies`],[`thief`,`thieves`],[`groove`,`grooves`],[`pickaxe`,`pickaxes`],[`passerby`,`passersby`]].forEach(function(e){return f.addIrregularRule(e[0],e[1])}),[[/s?$/i,`s`],[/[^\u0000-\u007F]$/i,`$0`],[/([^aeiou]ese)$/i,`$1`],[/(ax|test)is$/i,`$1es`],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,`$1es`],[/(e[mn]u)s?$/i,`$1s`],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,`$1`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1i`],[/(alumn|alg|vertebr)(?:a|ae)$/i,`$1ae`],[/(seraph|cherub)(?:im)?$/i,`$1im`],[/(her|at|gr)o$/i,`$1oes`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,`$1a`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,`$1a`],[/sis$/i,`ses`],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,`$1$2ves`],[/([^aeiouy]|qu)y$/i,`$1ies`],[/([^ch][ieo][ln])ey$/i,`$1ies`],[/(x|ch|ss|sh|zz)$/i,`$1es`],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,`$1ices`],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,`$1ice`],[/(pe)(?:rson|ople)$/i,`$1ople`],[/(child)(?:ren)?$/i,`$1ren`],[/eaux$/i,`$0`],[/m[ae]n$/i,`men`],[`thou`,`you`]].forEach(function(e){return f.addPluralRule(e[0],e[1])}),[[/s$/i,``],[/(ss)$/i,`$1`],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,`$1fe`],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,`$1f`],[/ies$/i,`y`],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,`$1ie`],[/\b(mon|smil)ies$/i,`$1ey`],[/\b((?:tit)?m|l)ice$/i,`$1ouse`],[/(seraph|cherub)im$/i,`$1`],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,`$1`],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,`$1sis`],[/(movie|twelve|abuse|e[mn]u)s$/i,`$1`],[/(test)(?:is|es)$/i,`$1is`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1us`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,`$1um`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,`$1on`],[/(alumn|alg|vertebr)ae$/i,`$1a`],[/(cod|mur|sil|vert|ind)ices$/i,`$1ex`],[/(matr|append)ices$/i,`$1ix`],[/(pe)(rson|ople)$/i,`$1rson`],[/(child)ren$/i,`$1`],[/(eau)x?$/i,`$1`],[/men$/i,`man`]].forEach(function(e){return f.addSingularRule(e[0],e[1])}),[`adulthood`,`advice`,`agenda`,`aid`,`aircraft`,`alcohol`,`ammo`,`analytics`,`anime`,`athletics`,`audio`,`bison`,`blood`,`bream`,`buffalo`,`butter`,`carp`,`cash`,`chassis`,`chess`,`clothing`,`cod`,`commerce`,`cooperation`,`corps`,`debris`,`diabetes`,`digestion`,`elk`,`energy`,`equipment`,`excretion`,`expertise`,`firmware`,`flounder`,`fun`,`gallows`,`garbage`,`graffiti`,`hardware`,`headquarters`,`health`,`herpes`,`highjinks`,`homework`,`housework`,`information`,`jeans`,`justice`,`kudos`,`labour`,`literature`,`machinery`,`mackerel`,`mail`,`media`,`mews`,`moose`,`music`,`mud`,`manga`,`news`,`only`,`personnel`,`pike`,`plankton`,`pliers`,`police`,`pollution`,`premises`,`rain`,`research`,`rice`,`salmon`,`scissors`,`series`,`sewage`,`shambles`,`shrimp`,`software`,`species`,`staff`,`swine`,`tennis`,`traffic`,`transportation`,`trout`,`tuna`,`wealth`,`welfare`,`whiting`,`wildebeest`,`wildlife`,`you`,/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f})})),Rv=a(((e,t)=>{function n(e){return e=String(e),e&&e.toLowerCase()}n.isLowercase=function(e){return e&&!/[A-Z]+/.test(e)},t.exports=n})),zv=a(((e,t)=>{function n(e){return e=String(e),e&&e.toUpperCase()}n.isUppercase=function(e){return e&&!/[a-z]+/.test(e)},t.exports=n})),Bv=a(((e,t)=>{var n=Rv(),r=zv(),i={from:/[\-_:\.\s]([a-zA-Z])([a-zA-Z]*)/g,to:function(e,t,n,i,a){return t.length,r(t)+n}};function a(e){return a.isCamelcase(e)||(e=String(e).replace(/^[\-_:\.\s]/,``),!e)?e:(r.isUppercase(e)&&(e=n(e)),n(e[0])+e.replace(i.from,i.to).slice(1).replace(/^([A-Z]+)([A-Z])/,function(e,t,r){return n(t)+r}))}a.isCamelcase=function(e){return e&&/^[a-zA-Z]+$/.test(e)&&n(e[0])===e[0]},t.exports=a})),Vv=a(((e,t)=>{var n=zv();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),Hv=a(((e,t)=>{var n=Rv(),r=zv(),i=`_`,a={from:/([A-Z]+)/g,to:function(e,t,a,o){var s=a===0?``:i,c=t.length;if(c===1)return s+n(t);var l=o.slice(a+t.length);return r.isUppercase(t)&&l[0]===i?s+n(t):s+(n(t.substr(0,c-1))+i+n(t[c-1]))}};function o(e){return o.isSnakecase(e)||(e=String(e).replace(/[\-.:\s]/g,i),!e)?e:(r.isUppercase(e)&&(e=n(e)),e.replace(a.from,a.to).replace(/_+/g,`_`))}o.isSnakecase=function(e){return e&&/^[a-z_]+$/.test(e)},t.exports=o})),Uv=a(((e,t)=>{var n=zv(),r=Hv();function i(e){return i.isConstcase(e)?e:n(r(e))}i.isConstcase=function(e){return e&&/^[A-Z_]+$/.test(e)},t.exports=i})),Wv=a(((e,t)=>{var n=Hv();function r(e){return n(e).replace(/_/g,``)}t.exports=r})),Gv=a(((e,t)=>{var n=Rv();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),Kv=a(((e,t)=>{var n=Hv();function r(e){return n(e).replace(/_/g,`.`)}t.exports=r})),qv=a(((e,t)=>{var n=Hv();function r(e){return n(e).replace(/_/g,`:`)}t.exports=r})),Jv=a(((e,t)=>{var n=Bv(),r=Vv();function i(e){return r(n(e))}t.exports=i})),Yv=a(((e,t)=>{var n=Hv();function r(e){return n(e).replace(/_/g,`/`)}t.exports=r})),Xv=a(((e,t)=>{function n(e){return String(e).trim()}t.exports=n})),Zv=a(((e,t)=>{Rv();var n=Xv(),r=Hv(),i=Vv(),a=` `;function o(e){return e=String(e).replace(/^[\-_\.\s]/g,a),e&&i(r(n(e)).replace(/_/g,a))}t.exports=o})),Qv=a(((e,t)=>{var n=Hv();function r(e){return n(e).replace(/_/g,` `)}t.exports=r})),$v=a(((e,t)=>{var n=Hv();function r(e){return n(e).replace(/_/g,`-`)}t.exports=r})),ey=a(((e,t)=>{var n=Hv(),r=Rv(),i=Xv(),a=Vv(),o=`a,the,and,or,not,but,for,of`.split(`,`);function s(e){return n(e).split(/_/g).map(i).map(function(e){return~o.indexOf(e)?r(e):a(e)}).join(` `)}t.exports=s})),ty=a(((e,t)=>{var n=Bv(),r=Vv(),i=Uv(),a=Wv(),o=Gv(),s=Kv(),c=qv(),l=Rv(),u=Jv(),d=Yv(),f=Zv(),p=Hv(),m=Qv(),h=$v(),g=ey(),_=Xv(),v=zv();e.camelcase=n,e.capitalcase=r,e.constcase=i,e.cramcase=a,e.decapitalcase=o,e.dotcase=s,e.enumcase=c,e.lowercase=l,e.pascalcase=u,e.pathcase=d,e.sentencecase=f,e.snakecase=p,e.spacecase=m,e.spinalcase=h,e.titlecase=g,e.trimcase=_,e.uppercase=v,t.exports={camelcase:n,capitalcase:r,constcase:i,cramcase:a,decapitalcase:o,dotcase:s,enumcase:c,lowercase:l,pascalcase:u,pathcase:d,sentencecase:f,snakecase:p,spacecase:m,spinalcase:h,titlecase:g,trimcase:_,uppercase:v}}));Lv(),ty();function ny(e){return typeof e==`object`&&!!e&&`name`in e&&(`data`in e||`codec`in e)&&typeof e.name==`string`}function ry(e){return iy(e,new WeakSet)}function iy(e,t){return typeof e==`object`?e===null||t.has(e)?!0:(t.add(e),Array.isArray(e)?e.every(e=>iy(e,t)):e instanceof Promise?!1:Symbol.asyncIterator in e||Symbol.iterator in e?!0:ny(e)?iy(e.data,t):Object.values(e).every(e=>iy(e,t))):typeof e!=`bigint`&&typeof e!=`symbol`}function ay(e){return!(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Promise||Symbol.asyncIterator in e||Symbol.iterator in e||ny(e))}function oy(e){return e.type===`message`}function sy(e){if(ny(e)){if(oy(e))throw Error(`Message fragments are not supported by serialized fragment conversion`);if(!e.codec)throw Error(`Fragment "${e.name}" is missing codec`);return e.codec.encode()}return Array.isArray(e)?e.map(e=>sy(e)):ay(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,sy(t)])):e}function cy(e,t){return{name:`term`,data:{name:e,definition:t},codec:{encode(){return{type:`term`,name:e,definition:t}},decode(){return{name:e,definition:t}}}}}function ly(e){return{name:`hint`,data:e,codec:{encode(){return{type:`hint`,text:e}},decode(){return e}}}}function uy(e){return{name:`guardrail`,data:{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}},codec:{encode(){return{type:`guardrail`,rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}},decode(){return{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}}}}}function dy(e){return{name:`explain`,data:{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}},codec:{encode(){return{type:`explain`,concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}},decode(){return{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}}}}}function fy(e){return{name:`example`,data:{question:e.question,answer:e.answer,...e.note&&{note:e.note}},codec:{encode(){return{type:`example`,question:e.question,answer:e.answer,...e.note&&{note:e.note}}},decode(){return{question:e.question,answer:e.answer,...e.note&&{note:e.note}}}}}}function py(e){return{name:`clarification`,data:{when:e.when,ask:e.ask,reason:e.reason},codec:{encode(){return{type:`clarification`,when:e.when,ask:e.ask,reason:e.reason}},decode(){return{when:e.when,ask:e.ask,reason:e.reason}}}}}function my(e){return{name:`workflow`,data:{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}},codec:{encode(){return{type:`workflow`,task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}},decode(){return{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}}}}}function hy(e){return{name:`quirk`,data:{issue:e.issue,workaround:e.workaround},codec:{encode(){return{type:`quirk`,issue:e.issue,workaround:e.workaround}},decode(){return{issue:e.issue,workaround:e.workaround}}}}}function gy(e){return{name:`styleGuide`,data:{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}},codec:{encode(){return{type:`styleGuide`,prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}},decode(){return{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}}}}}function _y(e){return{name:`analogy`,data:{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}},codec:{encode(){return{type:`analogy`,concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}},decode(){return{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}}}}}function vy(e){return{name:`glossary`,data:Object.entries(e).map(([e,t])=>({term:e,expression:t})),codec:{encode(){return{type:`glossary`,entries:e}},decode(){return Object.entries(e).map(([e,t])=>({term:e,expression:t}))}}}}function yy(e){return{name:`role`,data:e,codec:{encode(){return{type:`role`,content:e}},decode(){return e}}}}function by(e){return{name:`principle`,data:{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`principle`,title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies.map(e=>sy(e))}}},decode(){return{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}}}}}}function xy(e){return{name:`policy`,data:{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`policy`,rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies.map(e=>sy(e))}}},decode(){return{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}}}}}}function Sy(e){return{name:`identity`,data:{...e.name&&{name:e.name},...e.role&&{role:e.role}},codec:{encode(){return{type:`identity`,...e.name&&{name:e.name},...e.role&&{role:e.role}}},decode(){return{...e.name&&{name:e.name},...e.role&&{role:e.role}}}}}}function Cy(e){return{name:`persona`,data:{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}},codec:{encode(){return{type:`persona`,name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}},decode(){return{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}}}}}function wy(e,t){return{name:`alias`,data:{term:e,meaning:t},codec:{encode(){return{type:`alias`,term:e,meaning:t}},decode(){return{term:e,meaning:t}}}}}function Ty(e,t){return{name:`preference`,data:{aspect:e,value:t},codec:{encode(){return{type:`preference`,aspect:e,value:t}},decode(){return{aspect:e,value:t}}}}}function Ey(e,t){return{name:`correction`,data:{subject:e,clarification:t},codec:{encode(){return{type:`correction`,subject:e,clarification:t}},decode(){return{subject:e,clarification:t}}}}}function Dy(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function Oy(e,t){if(Dy(e))return Py(e,t);if(Array.isArray(e))return e.map(e=>Oy(e,t));if(ay(e))return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Oy(n,t)]));if(!ry(e))throw Error(`Unsupported serialized value of type ${typeof e}`);return e}function ky(e,t){return{toFragment:(n,r)=>{let i=e.safeParse(n);if(!i.success)throw Error(`Invalid serialized ${n.type} fragment: ${it(i.error)}`);return t(i.data,r)}}}var Ay=vt(kt()).optional(),jy={term:ky(N({name:F(),definition:F()}),e=>cy(e.name,e.definition)),hint:ky(N({text:F()}),e=>ly(e.text)),guardrail:ky(N({rule:F(),reason:F().optional(),action:F().optional()}),e=>uy({rule:e.rule,reason:e.reason,action:e.action})),explain:ky(N({concept:F(),explanation:F(),therefore:F().optional()}),e=>dy({concept:e.concept,explanation:e.explanation,therefore:e.therefore})),example:ky(N({question:F(),answer:F(),note:F().optional()}),e=>fy({question:e.question,answer:e.answer,note:e.note})),clarification:ky(N({when:F(),ask:F(),reason:F()}),e=>py({when:e.when,ask:e.ask,reason:e.reason})),workflow:ky(N({task:F(),steps:vt(F()),triggers:vt(F()).optional(),notes:F().optional()}),e=>my({task:e.task,steps:e.steps,triggers:e.triggers,notes:e.notes})),quirk:ky(N({issue:F(),workaround:F()}),e=>hy({issue:e.issue,workaround:e.workaround})),styleGuide:ky(N({prefer:F(),never:F().optional(),always:F().optional()}),e=>gy({prefer:e.prefer,never:e.never,always:e.always})),analogy:ky(N({concepts:vt(F()),relationship:F(),insight:F().optional(),therefore:F().optional(),pitfall:F().optional()}),e=>_y({concepts:e.concepts,relationship:e.relationship,insight:e.insight,therefore:e.therefore,pitfall:e.pitfall})),glossary:ky(N({entries:S(F(),F())}),e=>vy(e.entries)),role:ky(N({content:F()}),e=>yy(e.content)),principle:ky(N({title:F(),description:F(),policies:Ay}),(e,t)=>by({title:e.title,description:e.description,policies:e.policies?.map(e=>Oy(e,t))})),policy:ky(N({rule:F(),before:F().optional(),reason:F().optional(),policies:Ay}),(e,t)=>xy({rule:e.rule,before:e.before,reason:e.reason,policies:e.policies?.map(e=>Oy(e,t))})),identity:ky(N({name:F().optional(),role:F().optional()}),e=>Sy({name:e.name,role:e.role})),persona:ky(N({name:F(),role:F().optional(),objective:F().optional(),tone:F().optional()}),e=>Cy({name:e.name,role:e.role,objective:e.objective,tone:e.tone})),alias:ky(N({term:F(),meaning:F()}),e=>wy(e.term,e.meaning)),preference:ky(N({aspect:F(),value:F()}),e=>Ty(e.aspect,e.value)),correction:ky(N({subject:F(),clarification:F()}),e=>Ey(e.subject,e.clarification))};function My(e){return Object.hasOwn(jy,e)}var Ny=new Set([`user`,`assistant`,`message`]);function Py(e,t){if(Ny.has(e.type))throw Error(`Message fragments are not supported by serialized fragment conversion`);let n=t?.registry?.[e.type]??(My(e.type)?jy[e.type]:void 0);if(!n)throw Error(`Unsupported serialized fragment type: ${e.type}`);return n.toFragment(e,t)}function Fy(e){let t=e?.reminders;return Array.isArray(t)?t.filter(e=>Pm(e)&&typeof e.partIndex==`number`&&typeof e.start==`number`&&typeof e.end==`number`):[]}function Iy(e,t){if(t.length===0)return e;let n=t.map(t=>({start:Math.max(0,Math.min(e.length,t.start)),end:Math.max(0,Math.min(e.length,t.end))})).filter(e=>e.end>e.start).sort((e,t)=>e.start-t.start);if(n.length===0)return e;let r=0,i=``;for(let t of n){if(t.start<r){t.end>r&&(r=t.end);continue}i+=e.slice(r,t.start),r=t.end}return i+=e.slice(r),i.trimEnd()}function Ly(e){if(Ry(e))return zy(e);let t=Fy(Pm(e.metadata)?e.metadata:void 0),n=new Map;for(let e of t){let t=n.get(e.partIndex)??[];t.push({start:e.start,end:e.end}),n.set(e.partIndex,t)}let r=e.parts.flatMap((e,t)=>{let r={...e},i=n.get(t);if(r.type!==`text`||i===void 0)return[r];let a=Iy(r.text,i);return a.length===0?[]:[{...r,text:a}]}),i={...e,parts:r};if(Pm(e.metadata)){let t={...e.metadata};delete t.reminders,Object.keys(t).length>0?i.metadata=t:delete i.metadata}return i}function Ry(e){let t=e.metadata;if(!Pm(t))return!1;let n=t.synthetic;return Pm(n)?n.source===`reminder`:!1}function zy(e){let t={...e,parts:e.parts.filter(e=>e.type!==`text`)};if(Pm(e.metadata)){let n={...e.metadata};delete n.synthetic,Object.keys(n).length>0?t.metadata=n:delete t.metadata}return t}var By=(0,I.createContext)({});function Vy(e){let t=(0,I.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Hy=typeof window<`u`?I.useLayoutEffect:I.useEffect,Uy=(0,I.createContext)(null);function Wy(e,t){e.indexOf(t)===-1&&e.push(t)}function Gy(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Ky=(e,t,n)=>n>t?t:n<e?e:n,qy={},Jy=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Yy=e=>typeof e==`object`&&!!e,Xy=e=>/^0[^.\s]+$/u.test(e);function Zy(e){let t;return()=>(t===void 0&&(t=e()),t)}var Qy=e=>e,$y=(...e)=>e.reduce((e,t)=>n=>t(e(n))),eb=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},tb=class{constructor(){this.subscriptions=[]}add(e){return Wy(this.subscriptions,e),()=>Gy(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},nb=e=>e*1e3,rb=e=>e/1e3,ib=(e,t)=>t?1e3/t*e:0,ab=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ob=1e-7,sb=12;function cb(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=ab(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>ob&&++s<sb);return o}function lb(e,t,n,r){if(e===t&&n===r)return Qy;let i=t=>cb(t,0,1,e,n);return e=>e===0||e===1?e:ab(i(e),t,r)}var ub=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,db=e=>t=>1-e(1-t),fb=lb(.33,1.53,.69,.99),pb=db(fb),mb=ub(pb),hb=e=>e>=1?1:(e*=2)<1?.5*pb(e):.5*(2-2**(-10*(e-1))),gb=e=>1-Math.sin(Math.acos(e)),_b=db(gb),vb=ub(gb),yb=lb(.42,0,1,1),bb=lb(0,0,.58,1),xb=lb(.42,0,.58,1),Sb=e=>Array.isArray(e)&&typeof e[0]!=`number`,Cb=e=>Array.isArray(e)&&typeof e[0]==`number`,wb={linear:Qy,easeIn:yb,easeInOut:xb,easeOut:bb,circIn:gb,circInOut:vb,circOut:_b,backIn:pb,backInOut:mb,backOut:fb,anticipate:hb},Tb=e=>typeof e==`string`,Eb=e=>{if(Cb(e)){e.length;let[t,n,r,i]=e;return lb(t,n,r,i)}else if(Tb(e))return wb[e],`${e}`,wb[e];return e},Db=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function Ob(e){let t=new Set,n=new Set,r=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(c.schedule(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var kb=40;function Ab(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Db.reduce((e,t)=>(e[t]=Ob(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=qy.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,kb),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:Db.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Db.length;t++)o[Db[t]].cancel(e)},state:i,steps:o}}var{schedule:jb,cancel:Mb,state:Nb,steps:Pb}=Ab(typeof requestAnimationFrame<`u`?requestAnimationFrame:Qy,!0),Fb;function Ib(){Fb=void 0}var Lb={now:()=>(Fb===void 0&&Lb.set(Nb.isProcessing||qy.useManualTiming?Nb.timestamp:performance.now()),Fb),set:e=>{Fb=e,queueMicrotask(Ib)}},Rb=e=>t=>typeof t==`string`&&t.startsWith(e),zb=Rb(`--`),Bb=Rb(`var(--`),Vb=e=>Bb(e)?iee.test(e.split(`/*`)[0].trim()):!1,iee=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Hb(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Ub={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Wb={...Ub,transform:e=>Ky(0,1,e)},Gb={...Ub,default:1},Kb=e=>Math.round(e*1e5)/1e5,qb=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Jb(e){return e==null}var Yb=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Xb=(e,t)=>n=>!!(typeof n==`string`&&Yb.test(n)&&n.startsWith(e)||t&&!Jb(n)&&Object.prototype.hasOwnProperty.call(n,t)),Zb=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(qb);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Qb=e=>Ky(0,255,e),$b={...Ub,transform:e=>Math.round(Qb(e))},ex={test:Xb(`rgb`,`red`),parse:Zb(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+$b.transform(e)+`, `+$b.transform(t)+`, `+$b.transform(n)+`, `+Kb(Wb.transform(r))+`)`};function tx(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var nx={test:Xb(`#`),parse:tx,transform:ex.transform},rx=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ix=rx(`deg`),ax=rx(`%`),U=rx(`px`),ox=rx(`vh`),sx=rx(`vw`),cx={...ax,parse:e=>ax.parse(e)/100,transform:e=>ax.transform(e*100)},lx={test:Xb(`hsl`,`hue`),parse:Zb(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+ax.transform(Kb(t))+`, `+ax.transform(Kb(n))+`, `+Kb(Wb.transform(r))+`)`},ux={test:e=>ex.test(e)||nx.test(e)||lx.test(e),parse:e=>ex.test(e)?ex.parse(e):lx.test(e)?lx.parse(e):nx.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?ex.transform(e):lx.transform(e),getAnimatableNone:e=>{let t=ux.parse(e);return t.alpha=0,ux.transform(t)}},dx=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function fx(e){return isNaN(e)&&typeof e==`string`&&(e.match(qb)?.length||0)+(e.match(dx)?.length||0)>0}var px=`number`,mx=`color`,hx=`var`,gx=`var(`,_x="${}",vx=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function yx(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(vx,e=>(ux.test(e)?(r.color.push(a),i.push(mx),n.push(ux.parse(e))):e.startsWith(gx)?(r.var.push(a),i.push(hx),n.push(e)):(r.number.push(a),i.push(px),n.push(parseFloat(e))),++a,_x)).split(_x),indexes:r,types:i}}function bx(e){return yx(e).values}function xx({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===px?i+=Kb(r[a]):e===mx?i+=ux.transform(r[a]):i+=r[a]}return i}}function Sx(e){return xx(yx(e))}var Cx=e=>typeof e==`number`?0:ux.test(e)?ux.getAnimatableNone(e):e,wx=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Cx(e);function Tx(e){let t=yx(e);return xx(t)(t.values.map((e,n)=>wx(e,t.split[n])))}var Ex={test:fx,parse:bx,createTransformer:Sx,getAnimatableNone:Tx};function Dx(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Ox({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Dx(s,r,e+1/3),a=Dx(s,r,e),o=Dx(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function kx(e,t){return n=>n>0?t:e}var Ax=(e,t,n)=>e+(t-e)*n,jx=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Mx=[nx,ex,lx],Nx=e=>Mx.find(t=>t.test(e));function Px(e){let t=Nx(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===lx&&(n=Ox(n)),n}var Fx=(e,t)=>{let n=Px(e),r=Px(t);if(!n||!r)return kx(e,t);let i={...n};return e=>(i.red=jx(n.red,r.red,e),i.green=jx(n.green,r.green,e),i.blue=jx(n.blue,r.blue,e),i.alpha=Ax(n.alpha,r.alpha,e),ex.transform(i))},Ix=new Set([`none`,`hidden`]);function Lx(e,t){return Ix.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Rx(e,t){return n=>Ax(e,t,n)}function zx(e){return typeof e==`number`?Rx:typeof e==`string`?Vb(e)?kx:ux.test(e)?Fx:Ux:Array.isArray(e)?Bx:typeof e==`object`?ux.test(e)?Fx:Vx:kx}function Bx(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>zx(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Vx(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=zx(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Hx(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var Ux=(e,t)=>{let n=Ex.createTransformer(t),r=yx(e),i=yx(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Ix.has(e)&&!i.values.length||Ix.has(t)&&!r.values.length?Lx(e,t):$y(Bx(Hx(r,i),i.values),n):(`${e}${t}`,kx(e,t))};function Wx(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?Ax(e,t,n):zx(e)(e,t)}var Gx=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>jb.update(t,e),stop:()=>Mb(t),now:()=>Nb.isProcessing?Nb.timestamp:Lb.now()}},Kx=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},qx=2e4;function Jx(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function Yx(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Jx(r),qx);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:rb(i)}}var Xx={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Zx(e,t){return e*Math.sqrt(1-t*t)}var Qx=12;function $x(e,t,n){let r=n;for(let n=1;n<Qx;n++)r-=e(r)/t(r);return r}var eS=.001;function tS({duration:e=Xx.duration,bounce:t=Xx.bounce,velocity:n=Xx.velocity,mass:r=Xx.mass}){let i,a;Xx.maxDuration;let o=1-t;o=Ky(Xx.minDamping,Xx.maxDamping,o),e=Ky(Xx.minDuration,Xx.maxDuration,rb(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=Zx(t,o),c=Math.exp(-i);return eS-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=Zx(t**2,o);return(-i(t)+eS>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=$x(i,a,s);if(e=nb(e),isNaN(c))return{stiffness:Xx.stiffness,damping:Xx.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var nS=[`duration`,`bounce`],rS=[`stiffness`,`damping`,`mass`];function iS(e,t){return t.some(t=>e[t]!==void 0)}function aS(e){let t={velocity:Xx.velocity,stiffness:Xx.stiffness,damping:Xx.damping,mass:Xx.mass,isResolvedFromDuration:!1,...e};if(!iS(e,rS)&&iS(e,nS))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Ky(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Xx.mass,stiffness:i,damping:a}}else{let n=tS({...e,velocity:0});t={...t,...n,mass:Xx.mass},t.isResolvedFromDuration=!0}return t}function oS(e=Xx.visualDuration,t=Xx.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=aS({...n,velocity:-rb(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=rb(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Xx.restSpeed.granular:Xx.restSpeed.default,i||=v?Xx.restDelta.granular:Xx.restDelta.default;let y,b,x,S,C,w;if(h<1)x=Zx(_,h),S=(m+h*_*g)/x,y=e=>{let t=Math.exp(-h*_*e);return o-t*(S*Math.sin(x*e)+g*Math.cos(x*e))},C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>nb(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=nb(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=nb(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(Jx(T),qx),t=Kx(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}oS.applyToOptions=e=>{let t=Yx(e,100,oS);return e.ease=t.ease,e.duration=nb(t.duration),e.type=`keyframes`,e};var sS=5;function cS(e,t,n){let r=Math.max(t-sS,0);return ib(n-e(r),t-r)}function lS({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=oS({keyframes:[f.value,m(f.value)],velocity:cS(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function uS(e,t,n){let r=[],i=n||qy.mix||Wx,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=$y(Array.isArray(t)?t[n]||Qy:t,a)),r.push(a)}return r}function dS(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=uS(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=eb(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Ky(e[0],e[a-1],t)):l}function fS(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=eb(0,t,r);e.push(Ax(n,1,i))}}function pS(e){let t=[0];return fS(t,e.length-1),t}function mS(e,t){return e.map(e=>e*t)}function hS(e,t){return e.map(()=>t||xb).splice(0,e.length-1)}function gS({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=Sb(r)?r.map(Eb):Eb(r),a={done:!1,value:t[0]},o=dS(mS(n&&n.length===t.length?n:pS(t),e),t,{ease:Array.isArray(i)?i:hS(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var _S=e=>e!==null;function vS(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(_S),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var yS={decay:lS,inertia:lS,tween:gS,keyframes:gS,spring:oS};function bS(e){typeof e.type==`string`&&(e.type=yS[e.type])}var xS=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},SS=e=>e/100,CS=class extends xS{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Lb.now()&&this.tick(Lb.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;bS(e);let{type:t=gS,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||gS;s!==gS&&typeof o[0]!=`number`&&(this.mixKeyframes=$y(SS,Wx(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=Jx(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=Ky(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==lS&&(b.value=vS(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return rb(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+rb(e)}get time(){return rb(this.currentTime)}set time(e){e=nb(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return cS(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Lb.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=rb(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Gx,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Lb.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function wS(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var TS=e=>e*180/Math.PI,ES=e=>OS(TS(Math.atan2(e[1],e[0]))),DS={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:ES,rotateZ:ES,skewX:e=>TS(Math.atan(e[1])),skewY:e=>TS(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},OS=e=>(e%=360,e<0&&(e+=360),e),kS=ES,AS=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),jS=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),MS={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:AS,scaleY:jS,scale:e=>(AS(e)+jS(e))/2,rotateX:e=>OS(TS(Math.atan2(e[6],e[5]))),rotateY:e=>OS(TS(Math.atan2(-e[2],e[0]))),rotateZ:kS,rotate:kS,skewX:e=>TS(Math.atan(e[4])),skewY:e=>TS(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function NS(e){return+!!e.includes(`scale`)}function PS(e,t){if(!e||e===`none`)return NS(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=MS,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=DS,i=t}if(!i)return NS(t);let a=r[t],o=i[1].split(`,`).map(IS);return typeof a==`function`?a(o):o[a]}var FS=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return PS(n,t)};function IS(e){return parseFloat(e.trim())}var LS=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],RS=new Set([...LS,`pathRotation`]),zS=e=>e===Ub||e===U,BS=new Set([`x`,`y`,`z`]),VS=LS.filter(e=>!BS.has(e));function HS(e){let t=[];return VS.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var US={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>PS(t,`x`),y:(e,{transform:t})=>PS(t,`y`)};US.translateX=US.x,US.translateY=US.y;var WS=new Set,GS=!1,KS=!1,qS=!1;function JS(){if(KS){let e=Array.from(WS).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=HS(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}KS=!1,GS=!1,WS.forEach(e=>e.complete(qS)),WS.clear()}function YS(){WS.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(KS=!0)})}function XS(){qS=!0,YS(),JS(),qS=!1}var ZS=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(WS.add(this),GS||(GS=!0,jb.read(YS),jb.resolveKeyframes(JS))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}wS(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),WS.delete(this)}cancel(){this.state===`scheduled`&&(WS.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},QS=e=>e.startsWith(`--`);function $S(e,t,n){QS(t)?e.style.setProperty(t,n):e.style[t]=n}var eC={};function tC(e,t){let n=Zy(e);return()=>eC[t]??n()}var nC=tC(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),rC=tC(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),iC=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,aC={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:iC([0,.65,.55,1]),circOut:iC([.55,0,1,.45]),backIn:iC([.31,.01,.66,-.59]),backOut:iC([.33,1.53,.69,.99])};function oC(e,t){if(e)return typeof e==`function`?rC()?Kx(e,t):`ease-out`:Cb(e)?iC(e):Array.isArray(e)?e.map(e=>oC(e,t)||aC.easeOut):aC[e]}function sC(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=oC(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function cC(e){return typeof e==`function`&&`applyToOptions`in e}function lC({type:e,...t}){return cC(e)&&rC()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var uC=class extends xS{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=lC(e);this.animation=sC(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=vS(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),$S(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return rb(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+rb(e)}get time(){return rb(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=nb(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&nC()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Qy):r(this)}},dC={anticipate:hb,backInOut:mb,circInOut:vb};function fC(e){return e in dC}function pC(e){typeof e.ease==`string`&&fC(e.ease)&&(e.ease=dC[e.ease])}var mC=10,hC=class extends uC{constructor(e){pC(e),bS(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new CS({...a,autoplay:!1}),s=Math.max(mC,Lb.now()-this.startTime),c=Ky(0,mC,s-mC),l=o.sample(s).value,{name:u}=this.options;i&&u&&$S(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},gC=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Ex.test(e)||e===`0`)&&!e.startsWith(`url(`));function _C(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function vC(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=gC(i,t),s=gC(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:_C(e)||(n===`spring`||cC(n))&&r}function yC(e){e.duration=0,e.type=`keyframes`}var bC=new Set([`opacity`,`clipPath`,`filter`,`transform`]),xC=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function SC(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&xC.test(e[t]))return!0;return!1}var CC=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),wC=Zy(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function TC(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return wC()&&n&&(bC.has(n)||CC.has(n)&&SC(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var EC=40,DC=class extends xS{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Lb.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||ZS;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Lb.now();let u=!0;vC(e,i,a,o)||(u=!1,(qy.instantAnimations||!s)&&l?.(vS(e,n,t)),e[0]=e[e.length-1],yC(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>EC?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&TC(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new hC({...d,element:p})}catch{m=new CS(d)}else m=new CS(d);m.finished.then(()=>{this.notifyFinished()}).catch(Qy),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),XS()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function OC(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var kC=30,AC=e=>!isNaN(parseFloat(e)),jC={current:void 0},MC=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Lb.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Lb.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=AC(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new tb);let n=this.events[e].add(t);return e===`change`?()=>{n(),jb.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return jC.current&&jC.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Lb.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>kC)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,kC);return ib(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function NC(e,t){return new MC(e,t)}function PC(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function FC(e,t){let n=e?.[t]??e?.default??e;return n===e?n:PC(n,e)}var IC={type:`spring`,stiffness:500,damping:25,restSpeed:10},LC=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),RC={type:`keyframes`,duration:.8},zC={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},BC=(e,{keyframes:t})=>t.length>2?RC:RS.has(e)?e.startsWith(`scale`)?LC(t[1]):IC:zC,VC=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function HC(e){for(let t in e)if(!VC.has(t))return!0;return!1}var UC=(e,t,n,r={},i,a)=>o=>{let s=FC(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=nb(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};HC(s)||Object.assign(u,BC(e,u)),u.duration&&=nb(u.duration),u.repeatDelay&&=nb(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(yC(u),u.delay===0&&(d=!0)),(qy.instantAnimations||qy.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,yC(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=vS(u.keyframes,s);if(e!==void 0){jb.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new CS(u):new DC(u)},WC=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function GC(e){let t=WC.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function KC(e,t,n=1){`${e}`;let[r,i]=GC(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Jy(e)?parseFloat(e):e}return Vb(i)?KC(i,t,n+1):i}function qC(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function JC(e,t,n,r){if(typeof t==`function`){let[i,a]=qC(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=qC(r);t=t(n===void 0?e.custom:n,i,a)}return t}function YC(e,t,n){let r=e.getProps();return JC(r,t,n===void 0?r.custom:n,e)}var XC=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...LS]),ZC=e=>Array.isArray(e);function QC(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,NC(n))}function $C(e){return ZC(e)?e[e.length-1]||0:e}function ew(e,t){let{transitionEnd:n={},transition:r={},...i}=YC(e,t)||{};i={...i,...n};for(let t in i)QC(e,t,$C(i[t]))}var tw=e=>!!(e&&e.getVelocity);function nw(e){return!!(tw(e)&&e.add)}function rw(e,t){let n=e.getValue(`willChange`);if(nw(n))return n.add(t);if(!n&&qy.WillChange){let n=new qy.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function iw(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var aw=`data-`+iw(`framerAppearId`);function ow(e){return e.props[aw]}function sw({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function cw(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?PC(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&sw(f,t))continue;let o={delay:n,...FC(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){jb.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=ow(e);if(n){let e=window.MotionHandoffAnimation(n,t,jb);e!==null&&(o.startTime=e,p=!0)}}rw(e,t);let m=l??e.shouldReduceMotion;r.start(UC(t,r,i,m&&XC.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>jb.update(()=>{o&&ew(e,o)});d.length?Promise.all(d).then(t):t()}return d}function lw(e,t,n={}){let r=YC(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(cw(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return uw(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function uw(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(lw(c,t,{...o,delay:n+(typeof r==`function`?0:r)+OC(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function dw(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>lw(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=lw(e,t,n);else{let i=typeof t==`function`?YC(e,t,n.custom):t;r=Promise.all(cw(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var fw={test:e=>e===`auto`,parse:e=>e},pw=e=>t=>t.test(e),mw=[Ub,U,ax,ix,sx,ox,fw],hw=e=>mw.find(pw(e));function gw(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||Xy(e)}var _w=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function vw(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(qb)||[];if(!r)return e;let i=n.replace(r,``),a=+!!_w.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var yw=/\b([a-z-]*)\(.*?\)/gu,bw={...Ex,getAnimatableNone:e=>{let t=e.match(yw);return t?t.map(vw).join(` `):e}},xw={...Ex,getAnimatableNone:e=>{let t=Ex.parse(e);return Ex.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},Sw={...Ub,transform:Math.round},Cw={borderWidth:U,borderTopWidth:U,borderRightWidth:U,borderBottomWidth:U,borderLeftWidth:U,borderRadius:U,borderTopLeftRadius:U,borderTopRightRadius:U,borderBottomRightRadius:U,borderBottomLeftRadius:U,width:U,maxWidth:U,height:U,maxHeight:U,top:U,right:U,bottom:U,left:U,inset:U,insetBlock:U,insetBlockStart:U,insetBlockEnd:U,insetInline:U,insetInlineStart:U,insetInlineEnd:U,padding:U,paddingTop:U,paddingRight:U,paddingBottom:U,paddingLeft:U,paddingBlock:U,paddingBlockStart:U,paddingBlockEnd:U,paddingInline:U,paddingInlineStart:U,paddingInlineEnd:U,margin:U,marginTop:U,marginRight:U,marginBottom:U,marginLeft:U,marginBlock:U,marginBlockStart:U,marginBlockEnd:U,marginInline:U,marginInlineStart:U,marginInlineEnd:U,fontSize:U,backgroundPositionX:U,backgroundPositionY:U,rotate:ix,pathRotation:ix,rotateX:ix,rotateY:ix,rotateZ:ix,scale:Gb,scaleX:Gb,scaleY:Gb,scaleZ:Gb,skew:ix,skewX:ix,skewY:ix,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:Wb,originX:cx,originY:cx,originZ:U,zIndex:Sw,fillOpacity:Wb,strokeOpacity:Wb,numOctaves:Sw},ww={...Cw,color:ux,backgroundColor:ux,outlineColor:ux,fill:ux,stroke:ux,borderColor:ux,borderTopColor:ux,borderRightColor:ux,borderBottomColor:ux,borderLeftColor:ux,filter:bw,WebkitFilter:bw,mask:xw,WebkitMask:xw},Tw=e=>ww[e],Ew=new Set([bw,xw]);function Dw(e,t){let n=Tw(e);return Ew.has(n)||(n=Ex),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var Ow=new Set([`auto`,`none`,`0`]);function kw(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!Ow.has(t)&&yx(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Dw(n,i)}var Aw=class extends ZS{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Vb(r))){let i=KC(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!XC.has(n)||e.length!==2)return;let[r,i]=e,a=hw(r),o=hw(i);if(Hb(r)!==Hb(i)&&US[n]){this.needsMeasurement=!0;return}if(a!==o)if(zS(a)&&zS(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else US[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||gw(e[t]))&&n.push(t);n.length&&kw(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=US[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=US[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},jw=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function Mw(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var Nw=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function Pw(e){return Yy(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:Fw,cancel:aee}=Ab(queueMicrotask,!1),Iw={x:!1,y:!1};function Lw(){return Iw.x||Iw.y}function Rw(e){return e===`x`||e===`y`?Iw[e]?null:(Iw[e]=!0,()=>{Iw[e]=!1}):Iw.x||Iw.y?null:(Iw.x=Iw.y=!0,()=>{Iw.x=Iw.y=!1})}function zw(e,t){let n=Mw(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Bw(e){return!(e.pointerType===`touch`||Lw())}function Vw(e,t,n={}){let[r,i,a]=zw(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!Bw(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Hw=(e,t)=>t?e===t||Hw(e,t.parentElement):!1,Uw=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Ww=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Gw(e){return Ww.has(e.tagName)||e.isContentEditable===!0}var Kw=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function qw(e){return Kw.has(e.tagName)||e.isContentEditable===!0}var Jw=new WeakSet;function Yw(e){return t=>{t.key===`Enter`&&e(t)}}function Xw(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Zw=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Yw(()=>{if(Jw.has(n))return;Xw(n,`down`);let e=Yw(()=>{Xw(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Xw(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Qw(e){return Uw(e)&&!Lw()}var $w=new WeakSet;function eT(e,t,n={}){let[r,i,a]=zw(e,n),o=e=>{let r=e.currentTarget;if(!Qw(e)||$w.has(e))return;Jw.add(r),n.stopPropagation&&$w.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),Jw.has(r)&&Jw.delete(r),Qw(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||Hw(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),Pw(e)&&(e.addEventListener(`focus`,e=>Zw(e,i)),!Gw(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function tT(e){return Yy(e)&&`ownerSVGElement`in e}var nT=new WeakMap,rT,iT=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:tT(r)&&`getBBox`in r?r.getBBox()[t]:r[n],aT=iT(`inline`,`width`,`offsetWidth`),oT=iT(`block`,`height`,`offsetHeight`);function sT({target:e,borderBoxSize:t}){nT.get(e)?.forEach(n=>{n(e,{get width(){return aT(e,t)},get height(){return oT(e,t)}})})}function cT(e){e.forEach(sT)}function lT(){typeof ResizeObserver>`u`||(rT=new ResizeObserver(cT))}function uT(e,t){rT||lT();let n=Mw(e);return n.forEach(e=>{let n=nT.get(e);n||(n=new Set,nT.set(e,n)),n.add(t),rT?.observe(e)}),()=>{n.forEach(e=>{let n=nT.get(e);n?.delete(t),n?.size||rT?.unobserve(e)})}}var dT=new Set,fT;function pT(){fT=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};dT.forEach(t=>t(e))},window.addEventListener(`resize`,fT)}function mT(e){return dT.add(e),fT||pT(),()=>{dT.delete(e),!dT.size&&typeof fT==`function`&&(window.removeEventListener(`resize`,fT),fT=void 0)}}function hT(e,t){return typeof e==`function`?mT(e):uT(e,t)}var gT={value:null,addProjectionMetrics:null};function _T(e){return tT(e)&&e.tagName===`svg`}var vT=[...mw,ux,Ex],yT=e=>vT.find(pw(e)),bT=()=>({translate:0,scale:1,origin:0,originPoint:0}),xT=()=>({x:bT(),y:bT()}),ST=()=>({min:0,max:0}),CT=()=>({x:ST(),y:ST()}),wT=new WeakMap;function TT(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function ET(e){return typeof e==`string`||Array.isArray(e)}var DT=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],OT=[`initial`,...DT];function kT(e){return TT(e.animate)||OT.some(t=>ET(e[t]))}function AT(e){return!!(kT(e)||e.variants)}function jT(e,t,n){for(let r in t){let i=t[r],a=n[r];if(tw(i))e.addValue(r,i);else if(tw(a))e.addValue(r,NC(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,NC(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var MT={current:null},NT={current:!1},PT=typeof window<`u`;function FT(){if(NT.current=!0,PT)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>MT.current=e.matches;e.addEventListener(`change`,t),t()}else MT.current=!1}var IT=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],LT={};function RT(e){LT=e}function zT(){return LT}var BT=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=ZS,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Lb.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,jb.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=kT(t),this.isVariantNode=AT(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&tw(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,wT.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(NT.current||FT(),this.shouldReduceMotion=MT.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Mb(this.notifyUpdate),Mb(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&bC.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new uC({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:nb(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=RS.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&jb.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in LT){let t=LT[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):CT()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<IT.length;t++){let n=IT[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=jT(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=NC(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Jy(n)||Xy(n))?n=parseFloat(n):!yT(n)&&Ex.test(t)&&(n=Dw(e,t)),this.setBaseTarget(e,tw(n)?n.get():n)),tw(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=JC(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!tw(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new tb),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Fw.render(this.render)}},VT=class extends BT{constructor(){super(...arguments),this.KeyframeResolver=Aw}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;tw(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},HT=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function UT({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function WT({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function GT(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function KT(e){return e===void 0||e===1}function qT({scale:e,scaleX:t,scaleY:n}){return!KT(e)||!KT(t)||!KT(n)}function JT(e){return qT(e)||YT(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function YT(e){return XT(e.x)||XT(e.y)}function XT(e){return e&&e!==`0%`}function ZT(e,t,n){return n+t*(e-n)}function QT(e,t,n,r,i){return i!==void 0&&(e=ZT(e,i,r)),ZT(e,n,r)+t}function $T(e,t=0,n=1,r,i){e.min=QT(e.min,t,n,r,i),e.max=QT(e.max,t,n,r,i)}function eE(e,{x:t,y:n}){$T(e.x,t.translate,t.scale,t.originPoint),$T(e.y,n.translate,n.scale,n.originPoint)}var tE=.999999999999,nE=1.0000000000001;function rE(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(iE(e.x,-a.scroll.offset.x),iE(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,eE(e,o)),r&&JT(a.latestValues)&&sE(e,a.latestValues,a.layout?.layoutBox))}t.x<nE&&t.x>tE&&(t.x=1),t.y<nE&&t.y>tE&&(t.y=1)}function iE(e,t){e.min+=t,e.max+=t}function aE(e,t,n,r,i=.5){$T(e,t,n,Ax(e.min,e.max,i),r)}function oE(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function sE(e,t,n){let r=n??e;aE(e.x,oE(t.x,r.x),t.scaleX,t.scale,t.originX),aE(e.y,oE(t.y,r.y),t.scaleY,t.scale,t.originY)}function cE(e,t){return UT(GT(e.getBoundingClientRect(),t))}function lE(e,t,n){let r=cE(e,n),{scroll:i}=t;return i&&(iE(r.x,i.offset.x),iE(r.y,i.offset.y)),r}var uE={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},dE=LS.length;function fE(e,t,n){let r=``,i=!0;for(let a=0;a<dE;a++){let o=LS[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=Nw(s,Cw[o]);if(!c){i=!1;let t=uE[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${Nw(a,Cw.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function pE(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(RS.has(e)){o=!0;continue}else if(zb(e)){i[e]=n;continue}else{let t=Nw(n,Cw[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=fE(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function mE(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function hE(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var gE={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(U.test(e))e=parseFloat(e);else return e;return`${hE(e,t.target.x)}% ${hE(e,t.target.y)}%`}},_E={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Ex.parse(e);if(i.length>5)return r;let a=Ex.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=Ax(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},vE={borderRadius:{...gE,applyTo:[...jw]},borderTopLeftRadius:gE,borderTopRightRadius:gE,borderBottomLeftRadius:gE,borderBottomRightRadius:gE,boxShadow:_E};function yE(e,{layout:t,layoutId:n}){return RS.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!vE[e]||e===`opacity`)}function bE(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(tw(r[t])||i&&tw(i[t])||yE(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function xE(e){return window.getComputedStyle(e)}var SE=class extends VT{constructor(){super(...arguments),this.type=`html`,this.renderInstance=mE}readValueFromInstance(e,t){if(RS.has(t))return this.projection?.isProjecting?NS(t):FS(e,t);{let n=xE(e),r=(zb(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return cE(e,t)}build(e,t,n){pE(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return bE(e,t,n)}},CE={offset:`stroke-dashoffset`,array:`stroke-dasharray`},wE={offset:`strokeDashoffset`,array:`strokeDasharray`};function TE(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?CE:wE;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var EE=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function DE(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(pE(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of EE)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&TE(d,i,a,o,!1)}var OE=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),kE=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function AE(e,t,n,r){mE(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(OE.has(n)?n:iw(n),t.attrs[n])}function jE(e,t,n){let r=bE(e,t,n);for(let n in e)if(tw(e[n])||tw(t[n])){let t=LS.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var ME=class extends VT{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=CT}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(RS.has(t)){let e=Tw(t);return e&&e.default||0}return t=OE.has(t)?t:iw(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return jE(e,t,n)}build(e,t,n){DE(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){AE(e,t,n,r)}mount(e){this.isSVGTag=kE(e.tagName),super.mount(e)}},NE=OT.length;function PE(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&PE(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<NE;n++){let r=OT[n],i=e.props[r];(ET(i)||i===!1)&&(t[r]=i)}return t}function FE(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var IE=[...DT].reverse(),LE=DT.length;function RE(e){return t=>Promise.all(t.map(({animation:t,options:n})=>dw(e,t,n)))}function zE(e){let t=RE(e),n=HE(),r=!0,i=!1,a=t=>(n,r)=>{let i=YC(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=PE(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<LE;t++){let p=IE[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=ET(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||TT(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=BE(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=ZC(t)&&ZC(n)?!FE(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let ee=v&&y;b&&(!ee||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!ee&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=YC(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=OC(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=YC(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=HE(),i=!0}}}function BE(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!FE(t,e):!1}function VE(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function HE(){return{animate:VE(!0),whileInView:VE(),whileHover:VE(),whileTap:VE(),whileDrag:VE(),whileFocus:VE(),exit:VE()}}function UE(e,t){e.min=t.min,e.max=t.max}function WE(e,t){UE(e.x,t.x),UE(e.y,t.y)}function GE(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var KE=.9999,qE=1.0001,JE=-.01,YE=.01;function XE(e){return e.max-e.min}function ZE(e,t,n){return Math.abs(e-t)<=n}function QE(e,t,n,r=.5){e.origin=r,e.originPoint=Ax(t.min,t.max,e.origin),e.scale=XE(n)/XE(t),e.translate=Ax(n.min,n.max,e.origin)-e.originPoint,(e.scale>=KE&&e.scale<=qE||isNaN(e.scale))&&(e.scale=1),(e.translate>=JE&&e.translate<=YE||isNaN(e.translate))&&(e.translate=0)}function $E(e,t,n,r){QE(e.x,t.x,n.x,r?r.originX:void 0),QE(e.y,t.y,n.y,r?r.originY:void 0)}function eD(e,t,n,r=0){e.min=(r?Ax(n.min,n.max,r):n.min)+t.min,e.max=e.min+XE(t)}function tD(e,t,n,r){eD(e.x,t.x,n.x,r?.x),eD(e.y,t.y,n.y,r?.y)}function nD(e,t,n,r=0){let i=r?Ax(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+XE(t)}function rD(e,t,n,r){nD(e.x,t.x,n.x,r?.x),nD(e.y,t.y,n.y,r?.y)}function iD(e,t,n,r,i){return e-=t,e=ZT(e,1/n,r),i!==void 0&&(e=ZT(e,1/i,r)),e}function aD(e,t=0,n=1,r=.5,i,a=e,o=e){if(ax.test(t)&&(t=parseFloat(t),t=Ax(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Ax(a.min,a.max,r);e===a&&(s-=t),e.min=iD(e.min,t,n,s,i),e.max=iD(e.max,t,n,s,i)}function oD(e,t,[n,r,i],a,o){aD(e,t[n],t[r],t[i],t.scale,a,o)}var sD=[`x`,`scaleX`,`originX`],cD=[`y`,`scaleY`,`originY`];function lD(e,t,n,r){oD(e.x,t,sD,n?n.x:void 0,r?r.x:void 0),oD(e.y,t,cD,n?n.y:void 0,r?r.y:void 0)}function uD(e){return e.translate===0&&e.scale===1}function dD(e){return uD(e.x)&&uD(e.y)}function fD(e,t){return e.min===t.min&&e.max===t.max}function pD(e,t){return fD(e.x,t.x)&&fD(e.y,t.y)}function mD(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function hD(e,t){return mD(e.x,t.x)&&mD(e.y,t.y)}function gD(e){return XE(e.x)/XE(e.y)}function _D(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function vD(e){return[e(`x`),e(`y`)]}function yD(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var bD=jw.length,xD=e=>typeof e==`string`?parseFloat(e):e,SD=e=>typeof e==`number`||U.test(e);function CD(e,t,n,r,i,a){i?(e.opacity=Ax(0,n.opacity??1,TD(r)),e.opacityExit=Ax(t.opacity??1,0,ED(r))):a&&(e.opacity=Ax(t.opacity??1,n.opacity??1,r));for(let i=0;i<bD;i++){let a=jw[i],o=wD(t,a),s=wD(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||SD(o)===SD(s)?(e[a]=Math.max(Ax(xD(o),xD(s),r),0),(ax.test(s)||ax.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Ax(t.rotate||0,n.rotate||0,r))}function wD(e,t){return e[t]===void 0?e.borderRadius:e[t]}var TD=DD(0,.5,_b),ED=DD(.5,.95,Qy);function DD(e,t,n){return r=>r<e?0:r>t?1:n(eb(e,t,r))}function OD(e,t,n){let r=tw(e)?e:NC(e);return r.start(UC(``,r,t,n)),r.animation}function kD(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var AD=(e,t)=>e.depth-t.depth,jD=class{constructor(){this.children=[],this.isDirty=!1}add(e){Wy(this.children,e),this.isDirty=!0}remove(e){Gy(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(AD),this.isDirty=!1,this.children.forEach(e)}};function MD(e,t){let n=Lb.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Mb(r),e(a-t))};return jb.setup(r,!0),()=>Mb(r)}function ND(e){return tw(e)?e.get():e}var PD=class{constructor(){this.members=[]}add(e){Wy(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(Gy(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Gy(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},FD={hasAnimatedSinceResize:!0,hasEverUpdated:!1},ID={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},LD=[``,`X`,`Y`,`Z`],RD=1e3,zD=0;function BD(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function VD(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=ow(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,jb,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&VD(r)}function HD({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=zD++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,gT.value&&(ID.nodes=ID.calculatedTargetDeltas=ID.calculatedProjections=0),this.nodes.forEach(GD),this.nodes.forEach(eO),this.nodes.forEach(tO),this.nodes.forEach(KD),gT.addProjectionMetrics&&gT.addProjectionMetrics(ID)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new jD)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new tb),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=tT(t)&&!_T(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;jb.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=MD(i,250),FD.hasAnimatedSinceResize&&(FD.hasAnimatedSinceResize=!1,this.nodes.forEach($D)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||cO,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!hD(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...FC(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||$D(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Mb(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(nO),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&VD(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(YD),this.nodes.forEach(JD);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(XD);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ZD),this.nodes.forEach(QD),this.nodes.forEach(UD),this.nodes.forEach(WD)):this.nodes.forEach(XD),this.clearAllSnapshots();let e=Lb.now();Nb.delta=Ky(0,1e3/60,e-Nb.timestamp),Nb.timestamp=e,Nb.isProcessing=!0,Pb.update.process(Nb),Pb.preRender.process(Nb),Pb.render.process(Nb),Nb.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Fw.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(qD),this.sharedNodes.forEach(rO)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,jb.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){jb.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!XE(this.snapshot.measuredBox.x)&&!XE(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=CT(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!dD(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||JT(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),fO(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return CT();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(mO))){let{scroll:e}=this.root;e&&(iE(t.x,e.offset.x),iE(t.y,e.offset.y))}return t}removeElementScroll(e){let t=CT();if(WE(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&WE(t,e),iE(t.x,i.offset.x),iE(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||CT();WE(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(iE(r.x,-n.scroll.offset.x),iE(r.y,-n.scroll.offset.y)),JT(n.latestValues)&&sE(r,n.latestValues,n.layout?.layoutBox)}return JT(this.latestValues)&&sE(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=CT();WE(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!JT(n.latestValues))continue;let r;n.instance&&(qT(n.latestValues)&&n.updateSnapshot(),r=CT(),WE(r,n.measurePageBox())),lD(t,n.latestValues,n.snapshot?.layoutBox,r)}return JT(this.latestValues)&&lD(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Nb.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Nb.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=CT(),this.targetWithTransforms=CT()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),tD(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):WE(this.target,this.layout.layoutBox),eE(this.target,this.targetDelta)):WE(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),gT.value&&ID.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||qT(this.parent.latestValues)||YT(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=CT(),this.relativeTargetOrigin=CT(),rD(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),WE(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Nb.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;WE(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;rE(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=CT());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(GE(this.prevProjectionDelta.x,this.projectionDelta.x),GE(this.prevProjectionDelta.y,this.projectionDelta.y)),$E(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!_D(this.projectionDelta.x,this.prevProjectionDelta.x)||!_D(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),gT.value&&ID.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=xT(),this.projectionDelta=xT(),this.projectionDeltaWithTransform=xT()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=xT();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=CT(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!!(c&&!u&&this.options.crossfade===!0&&!this.path.some(sO));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=Ax(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=Ax(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(iO(o.x,e.x,n),iO(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(rD(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),oO(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&pD(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=CT(),WE(f,this.relativeTarget)),c&&(this.animationValues=a,CD(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Mb(this.pendingAnimation),void 0),this.pendingAnimation=jb.update(()=>{FD.hasAnimatedSinceResize=!0,this.motionValue||=NC(0),this.motionValue.jump(0,!1),this.currentAnimation=OD(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(RD),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&pO(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||CT();let t=XE(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=XE(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}WE(t,n),sE(t,i),$E(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new PD),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&BD(`z`,e,r,this.animationValues);for(let t=0;t<LD.length;t++)BD(`rotate${LD[t]}`,e,r,this.animationValues),BD(`skew${LD[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=ND(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=ND(t?.pointerEvents)||``),this.hasProjected&&!JT(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=yD(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in vE){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=vE[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?ND(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(JD),this.root.sharedNodes.clear()}}}function UD(e){e.updateLayout()}function WD(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)vD(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=XE(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;UE(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else pO(i,t.layoutBox,n)&&vD(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=XE(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=xT();$E(o,n,t.layoutBox);let s=xT();a?$E(s,e.applyTransform(r,!0),t.measuredBox):$E(s,n,t.layoutBox);let c=!dD(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=CT();rD(s,t.layoutBox,i.layoutBox,o);let c=CT();rD(c,n,a.layoutBox,o),hD(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function GD(e){gT.value&&ID.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function KD(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function qD(e){e.clearSnapshot()}function JD(e){e.clearMeasurements()}function YD(e){e.isLayoutDirty=!0,e.updateLayout()}function XD(e){e.isLayoutDirty=!1}function ZD(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function QD(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function $D(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function eO(e){e.resolveTargetDelta()}function tO(e){e.calcProjection()}function nO(e){e.resetSkewAndRotation()}function rO(e){e.removeLeadSnapshot()}function iO(e,t,n){e.translate=Ax(t.translate,0,n),e.scale=Ax(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function aO(e,t,n,r){e.min=Ax(t.min,n.min,r),e.max=Ax(t.max,n.max,r)}function oO(e,t,n,r){aO(e.x,t.x,n.x,r),aO(e.y,t.y,n.y,r)}function sO(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var cO={duration:.45,ease:[.4,0,.1,1]},lO=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),uO=lO(`applewebkit/`)&&!lO(`chrome/`)?Math.round:Qy;function dO(e){e.min=uO(e.min),e.max=uO(e.max)}function fO(e){dO(e.x),dO(e.y)}function pO(e,t,n){return e===`position`||e===`preserve-aspect`&&!ZE(gD(t),gD(n),.2)}function mO(e){return e!==e.root&&e.scroll?.wasRoot}var hO=HD({attachResizeListener:(e,t)=>kD(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),gO={current:void 0},_O=HD({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!gO.current){let e=new hO({});e.mount(window),e.setOptions({layoutScroll:!0}),gO.current=e}return gO.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),vO=(0,I.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function yO(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function bO(...e){return t=>{let n=!1,r=e.map(e=>{let r=yO(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():yO(e[t],null)}}}}function xO(...e){return I.useCallback(bO(...e),e)}var SO=class extends I.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(Pw(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=Pw(e)&&e.offsetWidth||0,r=Pw(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function CO({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,I.useId)(),s=(0,I.useRef)(null),c=(0,I.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,I.useContext)(vO),u=xO(s,e.props?.ref??e?.ref);return(0,I.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
171
171
  [data-motion-pop-id="${o}"] {
172
172
  position: absolute !important;
173
173
  width: ${e}px !important;
@@ -175,12 +175,12 @@ ${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.t
175
175
  ${_}px !important;
176
176
  ${v}px !important;
177
177
  }
178
- `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,L.jsx)(xO,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:I.cloneElement(e,{ref:u})})}var CO=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=By(wO),d=(0,I.useId)(),f=(0,I.useRef)(n),p=(0,I.useRef)(r);Vy(()=>{f.current=n,p.current=r});let m=!0,h=(0,I.useMemo)(()=>(m=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&p.current?.()})}),[n,u,r]);return a&&m&&(h={...h}),(0,I.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),I.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,L.jsx)(SO,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,L.jsx)(Hy.Provider,{value:h,children:e})};function wO(){return new Map}function TO(e=!0){let t=(0,I.useContext)(Hy);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,I.useId)();(0,I.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,I.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var EO=e=>e.key||``;function DO(e){let t=[];return I.Children.forEach(e,e=>{(0,I.isValidElement)(e)&&t.push(e)}),t}var OO=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=TO(o),f=(0,I.useMemo)(()=>DO(e),[e]),p=o&&!u?[]:f.map(EO),m=(0,I.useRef)(!0),h=(0,I.useRef)(f),g=By(()=>new Map),_=(0,I.useRef)(new Set),[v,y]=(0,I.useState)(f),[b,x]=(0,I.useState)(f);Vy(()=>{m.current=!1,h.current=f;for(let e=0;e<b.length;e++){let t=EO(b[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[b,p.length,p.join(`-`)]);let S=[];if(f!==v){let e=[...f];for(let t=0;t<b.length;t++){let n=b[t],r=EO(n);p.includes(r)||(e.splice(t,0,n),S.push(n))}return a===`wait`&&S.length&&(e=S),x(DO(e)),y(f),null}let{forceRender:C}=(0,I.useContext)(zy);return(0,L.jsx)(L.Fragment,{children:b.map(e=>{let v=EO(e),y=o&&!u?!1:f===b||p.includes(v);return(0,L.jsx)(CO,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(C?.(),x(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},kO=(0,I.createContext)({strict:!1}),AO={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},jO=!1;function MO(){if(jO)return;let e={};for(let t in AO)e[t]={isEnabled:e=>AO[t].some(t=>!!e[t])};LT(e),jO=!0}function NO(){return MO(),RT()}function PO(e){let t=NO();for(let n in e)t[n]={...t[n],...e[n]};LT(t)}var FO=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function IO(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||FO.has(e)}var LO=t({default:()=>RO}),RO,zO=s((()=>{throw RO={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),BO=e=>!IO(e);function VO(e){typeof e==`function`&&(BO=t=>t.startsWith(`on`)?!IO(t):e(t))}try{VO((zO(),l(LO)).default)}catch{}function HO(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||ew(e[i])||(BO(i)||n===!0&&IO(i)||!t&&!IO(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var UO=(0,I.createContext)({});function WO(e,t){if(OT(e)){let{initial:t,animate:n}=e;return{initial:t===!1||TT(t)?t:void 0,animate:TT(n)?n:void 0}}return e.inherit===!1?{}:t}function GO(e){let{initial:t,animate:n}=WO(e,(0,I.useContext)(UO));return(0,I.useMemo)(()=>({initial:t,animate:n}),[KO(t),KO(n)])}function KO(e){return Array.isArray(e)?e.join(` `):e}var qO=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function JO(e,t,n){for(let r in t)!ew(t[r])&&!vE(r,n)&&(e[r]=t[r])}function YO({transformTemplate:e},t){return(0,I.useMemo)(()=>{let n=qO();return fE(n,t,e),Object.assign({},n.vars,n.style)},[t])}function XO(e,t){let n=e.style||{},r={};return JO(r,n,e),Object.assign(r,YO(e,t)),r}function ZO(e,t){let n={},r=XO(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var QO=()=>({...qO(),attrs:{}});function $O(e,t,n,r){let i=(0,I.useMemo)(()=>{let n=QO();return EE(n,t,OE(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};JO(t,e.style,e),i.style={...t,...i.style}}return i}var ek=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function tk(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(ek.indexOf(e)>-1||/[A-Z]/u.test(e))}function nk(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??tk(e)?$O:ZO)(t,r,i,e),c=HO(t,typeof e==`string`,a),l=e===I.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,I.useMemo)(()=>ew(u)?u.get():u,[u]);return(0,I.createElement)(e,{...l,children:d})}function rk({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:ik(n,r,i,e),renderState:t()}}function ik(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=MD(a[e]);let{initial:o,animate:s}=e,c=OT(e),l=kT(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!wT(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=qC(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var ak=e=>(t,n)=>{let r=(0,I.useContext)(UO),i=(0,I.useContext)(Hy),a=()=>rk(e,t,r,i);return n?a():By(a)},ok=ak({scrapeMotionValuesFromProps:yE,createRenderState:qO}),sk=ak({scrapeMotionValuesFromProps:AE,createRenderState:QO}),ck=Symbol.for(`motionComponentSymbol`);function lk(e,t,n){let r=(0,I.useRef)(n);(0,I.useInsertionEffect)(()=>{r.current=n});let i=(0,I.useRef)(null);return(0,I.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var uk=(0,I.createContext)({});function dk(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function fk(e,t,n,r,i,a){let{visualElement:o}=(0,I.useContext)(UO),s=(0,I.useContext)(kO),c=(0,I.useContext)(Hy),l=(0,I.useContext)(_O),u=l.reducedMotion,d=l.skipAnimations,f=(0,I.useRef)(null),p=(0,I.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,I.useContext)(uk);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&pk(f.current,n,i,h);let g=(0,I.useRef)(!1);(0,I.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[iw],v=(0,I.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Vy(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,I.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function pk(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:mk(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&dk(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function mk(e){if(e)return e.options.allowProjection===!1?mk(e.parent):e.projection}function hk(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&PO(r);let a=n?n===`svg`:tk(e),o=a?sk:ok;function s(n,s){let c,l={...(0,I.useContext)(_O),...n,layoutId:gk(n)},{isStatic:u}=l,d=GO(n),f=o(n,u);if(!u&&typeof window<`u`){_k(l,r);let t=vk(l);c=t.MeasureLayout,d.visualElement=fk(e,f,l,i,t.ProjectionNode,a)}return(0,L.jsxs)(UO.Provider,{value:d,children:[c&&d.visualElement?(0,L.jsx)(c,{visualElement:d.visualElement,...l}):null,nk(e,n,lk(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,I.forwardRef)(s);return c[ck]=e,c}function gk({layoutId:e}){let t=(0,I.useContext)(zy).id;return t&&e!==void 0?t+`-`+e:e}function _k(e,t){(0,I.useContext)(kO).strict}function vk(e){let{drag:t,layout:n}=NO();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function yk(e,t){if(typeof Proxy>`u`)return hk;let n=new Map,r=(n,r)=>hk(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,hk(a,void 0,e,t)),n.get(a))})}var bk=(e,t)=>t.isSVG??tk(e)?new jE(t):new xE(t,{allowProjection:e!==I.Fragment}),xk=class extends VT{constructor(e){super(e),e.animationState||=RE(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();wT(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},Sk=0,Ck={animation:{Feature:xk},exit:{Feature:class extends VT{constructor(){super(...arguments),this.id=Sk++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=JC(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function wk(e){return{point:{x:e.pageX,y:e.pageY}}}var Tk=e=>t=>Hw(t)&&e(t,wk(t));function Ek(e,t,n,r){return OD(e,t,Tk(n),r)}var Dk=({current:e})=>e?e.ownerDocument.defaultView:null,Ok=(e,t)=>Math.abs(e-t);function kk(e,t){let n=Ok(e.x,t.x),r=Ok(e.y,t.y);return Math.sqrt(n**2+r**2)}var Ak=new Set([`auto`,`scroll`]),jk=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Mk(this.lastRawMoveEventInfo,this.transformPagePoint));let e=Pk(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=kk(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Mb;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Mk(t,this.transformPagePoint),Ab.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=Pk(e.type===`pointercancel`?this.lastMoveEventInfo:Mk(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Hw(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Mk(wk(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Mb;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,Pk(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=Qy(Ek(this.contextWindow,`pointermove`,this.handlePointerMove,d),Ek(this.contextWindow,`pointerup`,this.handlePointerUp,d),Ek(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Ak.has(e.overflowX)||Ak.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Ab.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),jb(this.updatePoint)}};function Mk(e,t){return t?{point:t(e.point)}:e}function Nk(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Pk({point:e},t){return{point:e,delta:Nk(e,Ik(t)),offset:Nk(e,Fk(t)),velocity:Lk(t,.1)}}function Fk(e){return e[0]}function Ik(e){return e[e.length-1]}function Lk(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Ik(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>tb(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>tb(t)*2&&(r=e[1]);let a=nb(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Rk(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?kx(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?kx(n,e,r.max):Math.min(e,n)),e}function zk(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Bk(e,{top:t,left:n,bottom:r,right:i}){return{x:zk(e.x,n,i),y:zk(e.y,t,r)}}function Vk(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function Hk(e,t){return{x:Vk(e.x,t.x),y:Vk(e.y,t.y)}}function Uk(e,t){let n=.5,r=YE(e),i=YE(t);return i>r?n=$y(t.min,t.max-r,e.min):r>i&&(n=$y(e.min,e.max-i,t.min)),Gy(0,1,n)}function Wk(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var Gk=.35;function Kk(e=Gk){return e===!1?e=0:e===!0&&(e=Gk),{x:qk(e,`left`,`right`),y:qk(e,`top`,`bottom`)}}function qk(e,t,n){return{min:Jk(e,t),max:Jk(e,n)}}function Jk(e,t){return typeof e==`number`?e:e[t]||0}var Yk=new WeakMap,Xk=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ST(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(wk(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Lw(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),_D(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ix.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=YE(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&Ab.update(()=>i(e,t),!1,!0),nw(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=eA(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&Ab.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new jk(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:Dk(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&Ab.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!$k(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Rk(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&dk(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Bk(n.layoutBox,e):this.constraints=!1,this.elastic=Kk(t),r!==this.constraints&&!dk(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&_D(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=Wk(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!dk(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=cE(n,r.root,this.visualElement.getTransformPagePoint()),a=Hk(r.layout.layoutBox,i);if(t){let e=t(UT(a));this.hasMutatedConstraints=!!e,e&&(a=HT(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=_D(o=>{if(!$k(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return nw(this.visualElement,e),n.start(HC(e,n,0,t,this.visualElement,!1))}stopAnimation(){_D(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){_D(t=>{let{drag:n}=this.getProps();if(!$k(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-kx(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!dk(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};_D(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Uk({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),_D(t=>{if(!$k(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(kx(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Yk.set(this.visualElement,this);let e=this.visualElement.current,t=Ek(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Kw(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();dk(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=Qk(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Ab.read(r);let o=OD(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(_D(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=Gk,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Zk(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Qk(e,t,n){let r=mT(e,Zk(n)),i=mT(t,Zk(n));return()=>{r(),i()}}function $k(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function eA(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var tA=class extends VT{constructor(e){super(e),this.removeGroupControls=Zy,this.removeListeners=Zy,this.controls=new Xk(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Zy}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},nA=e=>(t,n)=>{e&&Ab.update(()=>e(t,n),!1,!0)},rA=class extends VT{constructor(){super(...arguments),this.removePointerDownListener=Zy}onPointerDown(e){this.session=new jk(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Dk(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:nA(e),onStart:nA(t),onMove:nA(n),onEnd:(e,t)=>{delete this.session,r&&Ab.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Ek(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},iA=!1,aA=class extends I.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),iA&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),PD.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),iA=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Ab.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Pw.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;iA=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function oA(e){let[t,n]=TO(),r=(0,I.useContext)(zy);return(0,L.jsx)(aA,{...e,layoutGroup:r,switchLayoutGroup:(0,I.useContext)(uk),isPresent:t,safeToRemove:n})}var sA={pan:{Feature:rA},drag:{Feature:tA,ProjectionNode:gO,MeasureLayout:oA}};function cA(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&Ab.postRender(()=>i(t,wk(t)))}var lA=class extends VT{mount(){let{current:e}=this.node;e&&(this.unmount=Bw(e,(e,t)=>(cA(this.node,t,`Start`),e=>cA(this.node,e,`End`))))}unmount(){}},uA=class extends VT{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=Qy(OD(this.node.current,`focus`,()=>this.onFocus()),OD(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function dA(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&Ab.postRender(()=>i(t,wk(t)))}var fA=class extends VT{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=$w(e,(e,t)=>(dA(this.node,t,`Start`),(e,{success:t})=>dA(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},pA=new WeakMap,mA=new WeakMap,hA=e=>{let t=pA.get(e.target);t&&t(e)},gA=e=>{e.forEach(hA)};function _A({root:e,...t}){let n=e||document;mA.has(n)||mA.set(n,{});let r=mA.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(gA,{root:e,...t})),r[i]}function vA(e,t,n){let r=_A(t);return pA.set(e,n),r.observe(e),()=>{pA.delete(e),r.unobserve(e)}}var yA={some:0,all:1},bA=class extends VT{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:yA[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=vA(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(xA(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function xA({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var SA={inView:{Feature:bA},tap:{Feature:fA},focus:{Feature:uA},hover:{Feature:lA}},CA={layout:{ProjectionNode:gO,MeasureLayout:oA}},wA=yk({...Ck,...SA,...sA,...CA},bk);function TA(){!MT.current&&PT();let[e]=(0,I.useState)(jT.current);return e}function EA(e){e.values.forEach(e=>e.stop())}function DA(e,t){[...t].reverse().forEach(n=>{let r=e.getVariant(n);r&&$C(e,r),e.variantChildren&&e.variantChildren.forEach(e=>{DA(e,t)})})}function OA(e,t){if(Array.isArray(t))return DA(e,t);if(typeof t==`string`)return DA(e,[t]);$C(e,t)}function kA(){let e=new Set,t={subscribe(t){return e.add(t),()=>void e.delete(t)},start(t,n){let r=[];return e.forEach(e=>{r.push(uw(e,t,{transitionOverride:n}))}),Promise.all(r)},set(t){return e.forEach(e=>{OA(e,t)})},stop(){e.forEach(e=>{EA(e)})},mount(){return()=>{t.stop()}}};return t}function AA(){let e=By(kA);return Vy(e.mount,[]),e}var jA=AA,W=qe(),MA=wA,NA={damping:.7,stiffness:.05,mass:1.25},PA=70,FA=1e3/60,IA=350,LA=!1;globalThis.document?.addEventListener(`mousedown`,()=>{LA=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{LA=!1}),globalThis.document?.addEventListener(`click`,()=>{LA=!1});var RA=(e={})=>{let[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(e.initial!==!1),[a,o]=(0,I.useState)(!1),s=(0,I.useRef)(null);s.current=e;let c=(0,I.useCallback)(()=>{if(!LA)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,I.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,I.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,I.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=PA}}},[]),f=(0,I.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=VA(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/FA;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:VA(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,I.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,I.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,I.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=zA(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=zA(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=VA(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:IA})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function zA(e,t){let n=(0,I.useCallback)(t=>(n.current=t,e(t)),t);return n}var BA=new Map;function VA(...e){let t={...NA},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return BA.has(r)||BA.set(r,Object.freeze(t)),n?`instant`:BA.get(r)}var HA=new Set([`name`,`id`,`aria-describedby`,`aria-labelledby`]);function UA(e){let t=new Set;for(let{name:n}of e){if(t.has(n))return n;t.add(n)}}function WA(e){let t=e.allowedAttributes.filter(e=>HA.has(e));if(t.length>0)throw Error(`Interactive element <${e.name}> declares reserved attribute(s) ${t.join(`, `)}. The markdown sanitizer rewrites these to "user-content-<value>" (DOM-clobbering protection), so the component would receive a mangled value. Use a domain attribute instead (e.g. "param").`)}var GA=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,KA=F().min(1).max(64).regex(GA).refine(e=>!HA.has(e),{error:`Attribute is reserved: the markdown sanitizer rewrites it to "user-content-<value>". Use a domain attribute instead (e.g. "param").`}),qA=Se({name:F().min(1).max(64).regex(GA),description:F().max(512).optional(),allowedAttributes:vt(KA).max(20)});vt(qA).max(100).superRefine((e,t)=>{let n=UA(e);n!==void 0&&t.addIssue({code:`custom`,message:`Duplicate element name "${n}": a catalog must map each tag to exactly one element.`})}).optional();function JA(e){let{name:t,allowedAttributes:n,description:r}=e;return{name:t,allowedAttributes:n,description:r}}function YA(e){for(let t of e){let e=qA.safeParse(JA(t));if(!e.success)throw Error(`Interactive element <${t.name}> is invalid:
179
- ${it(e.error)}`)}let t=UA(e);if(t!==void 0)throw Error(`Duplicate element name <${t}>: a catalog must map each tag to exactly one element.`);return[...e]}var XA={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`};function ZA(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}function QA(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function $A(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function ej(e){return $A(e)||ZA(e)}var tj=[``,`Named character references must be terminated by a semicolon`,`Numeric character references must be terminated by a semicolon`,`Named character references cannot be empty`,`Numeric character references cannot be empty`,`Named character references must be known`,`Numeric character references cannot be disallowed`,`Numeric character references cannot be outside the permissible Unicode range`];function nj(e,t){let n=t||{},r=typeof n.additional==`string`?n.additional.charCodeAt(0):n.additional,i=[],a=0,o=-1,s=``,c,l;n.position&&(`start`in n.position||`indent`in n.position?(l=n.position.indent,c=n.position.start):c=n.position);let u=(c?c.line:0)||1,d=(c?c.column:0)||1,f=m(),p;for(a--;++a<=e.length;)if(p===10&&(d=(l?l[o]:0)||1),p=e.charCodeAt(a),p===38){let t=e.charCodeAt(a+1);if(t===9||t===10||t===12||t===32||t===38||t===60||Number.isNaN(t)||r&&t===r){s+=String.fromCharCode(p),d++;continue}let o=a+1,c=o,l=o,u;if(t===35){l=++c;let t=e.charCodeAt(l);t===88||t===120?(u=`hexadecimal`,l=++c):u=`decimal`}else u=`named`;let _=``,v=``,y=``,b=u===`named`?ej:u===`decimal`?ZA:QA;for(l--;++l<=e.length;){let t=e.charCodeAt(l);if(!b(t))break;y+=String.fromCharCode(t),u===`named`&&ac.includes(y)&&(_=y,v=kn(y))}let x=e.charCodeAt(l)===59;if(x){l++;let e=u===`named`&&kn(y);e&&(_=y,v=e)}let S=1+l-o,C=``;if(!(!x&&n.nonTerminated===!1))if(!y)u!==`named`&&h(4,S);else if(u===`named`){if(x&&!v)h(5,1);else if(_!==y&&(l=c+_.length,S=1+l-c,x=!1),!x){let t=_?1:3;if(n.attribute){let n=e.charCodeAt(l);n===61?(h(t,S),v=``):ej(n)?v=``:h(t,S)}else h(t,S)}C=v}else{x||h(2,S);let e=Number.parseInt(y,u===`hexadecimal`?16:10);if(rj(e))h(7,S),C=`�`;else if(e in XA)h(6,S),C=XA[e];else{let t=``;ij(e)&&h(6,S),e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10|55296),e=56320|e&1023),C=t+String.fromCharCode(e)}}if(C){g(),f=m(),a=l-1,d+=l-o+1,i.push(C);let t=m();t.offset++,n.reference&&n.reference.call(n.referenceContext||void 0,C,{start:f,end:t},e.slice(o-1,l)),f=t}else y=e.slice(o-1,l),s+=y,d+=y.length,a=l-1}else p===10&&(u++,o++,d=0),Number.isNaN(p)?g():(s+=String.fromCharCode(p),d++);return i.join(``);function m(){return{line:u,column:d,offset:a+((c?c.offset:0)||0)}}function h(e,t){let r;n.warning&&(r=m(),r.column+=t,r.offset+=t,n.warning.call(n.warningContext||void 0,tj[e],r,e))}function g(){s&&=(i.push(s),n.text&&n.text.call(n.textContext||void 0,s,{start:f,end:m()}),``)}}function rj(e){return e>=55296&&e<=57343||e>1114111}function ij(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}var aj={}.hasOwnProperty,oj={},sj=/^[^\t\n\r "#'.<=>`}]+$/,cj=/^[^\t\n\r "'<=>`}]+$/;function lj(){return{canContainEols:[`textDirective`],enter:{directiveContainer:dj,directiveContainerAttributes:vj,directiveContainerLabel:gj,directiveLeaf:fj,directiveLeafAttributes:vj,directiveText:pj,directiveTextAttributes:vj},exit:{directiveContainer:wj,directiveContainerAttributeClassValue:bj,directiveContainerAttributeIdValue:yj,directiveContainerAttributeName:Sj,directiveContainerAttributeValue:xj,directiveContainerAttributes:Cj,directiveContainerLabel:_j,directiveContainerName:hj,directiveLeaf:wj,directiveLeafAttributeClassValue:bj,directiveLeafAttributeIdValue:yj,directiveLeafAttributeName:Sj,directiveLeafAttributeValue:xj,directiveLeafAttributes:Cj,directiveLeafName:hj,directiveText:wj,directiveTextAttributeClassValue:bj,directiveTextAttributeIdValue:yj,directiveTextAttributeName:Sj,directiveTextAttributeValue:xj,directiveTextAttributes:Cj,directiveTextName:hj}}}function uj(e){let t=e||oj;if(t.quote!==`"`&&t.quote!==`'`&&t.quote!==null&&t.quote!==void 0)throw Error("Invalid quote `"+t.quote+"`, expected `'` or `\"`");return n.peek=Tj,{handlers:{containerDirective:n,leafDirective:n,textDirective:n},unsafe:[{character:`\r`,inConstruct:[`leafDirectiveLabel`,`containerDirectiveLabel`]},{character:`
178
+ `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,L.jsx)(SO,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:I.cloneElement(e,{ref:u})})}var wO=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=Vy(TO),d=(0,I.useId)(),f=(0,I.useRef)(n),p=(0,I.useRef)(r);Hy(()=>{f.current=n,p.current=r});let m=!0,h=(0,I.useMemo)(()=>(m=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&p.current?.()})}),[n,u,r]);return a&&m&&(h={...h}),(0,I.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),I.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,L.jsx)(CO,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,L.jsx)(Uy.Provider,{value:h,children:e})};function TO(){return new Map}function EO(e=!0){let t=(0,I.useContext)(Uy);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,I.useId)();(0,I.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,I.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var DO=e=>e.key||``;function OO(e){let t=[];return I.Children.forEach(e,e=>{(0,I.isValidElement)(e)&&t.push(e)}),t}var kO=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=EO(o),f=(0,I.useMemo)(()=>OO(e),[e]),p=o&&!u?[]:f.map(DO),m=(0,I.useRef)(!0),h=(0,I.useRef)(f),g=Vy(()=>new Map),_=(0,I.useRef)(new Set),[v,y]=(0,I.useState)(f),[b,x]=(0,I.useState)(f);Hy(()=>{m.current=!1,h.current=f;for(let e=0;e<b.length;e++){let t=DO(b[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[b,p.length,p.join(`-`)]);let S=[];if(f!==v){let e=[...f];for(let t=0;t<b.length;t++){let n=b[t],r=DO(n);p.includes(r)||(e.splice(t,0,n),S.push(n))}return a===`wait`&&S.length&&(e=S),x(OO(e)),y(f),null}let{forceRender:C}=(0,I.useContext)(By);return(0,L.jsx)(L.Fragment,{children:b.map(e=>{let v=DO(e),y=o&&!u?!1:f===b||p.includes(v);return(0,L.jsx)(wO,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(C?.(),x(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},AO=(0,I.createContext)({strict:!1}),jO={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},MO=!1;function NO(){if(MO)return;let e={};for(let t in jO)e[t]={isEnabled:e=>jO[t].some(t=>!!e[t])};RT(e),MO=!0}function PO(){return NO(),zT()}function FO(e){let t=PO();for(let n in e)t[n]={...t[n],...e[n]};RT(t)}var IO=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function LO(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||IO.has(e)}var RO=t({default:()=>zO}),zO,BO=s((()=>{throw zO={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),VO=e=>!LO(e);function HO(e){typeof e==`function`&&(VO=t=>t.startsWith(`on`)?!LO(t):e(t))}try{HO((BO(),l(RO)).default)}catch{}function UO(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||tw(e[i])||(VO(i)||n===!0&&LO(i)||!t&&!LO(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var WO=(0,I.createContext)({});function GO(e,t){if(kT(e)){let{initial:t,animate:n}=e;return{initial:t===!1||ET(t)?t:void 0,animate:ET(n)?n:void 0}}return e.inherit===!1?{}:t}function KO(e){let{initial:t,animate:n}=GO(e,(0,I.useContext)(WO));return(0,I.useMemo)(()=>({initial:t,animate:n}),[qO(t),qO(n)])}function qO(e){return Array.isArray(e)?e.join(` `):e}var JO=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function YO(e,t,n){for(let r in t)!tw(t[r])&&!yE(r,n)&&(e[r]=t[r])}function XO({transformTemplate:e},t){return(0,I.useMemo)(()=>{let n=JO();return pE(n,t,e),Object.assign({},n.vars,n.style)},[t])}function ZO(e,t){let n=e.style||{},r={};return YO(r,n,e),Object.assign(r,XO(e,t)),r}function QO(e,t){let n={},r=ZO(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var $O=()=>({...JO(),attrs:{}});function ek(e,t,n,r){let i=(0,I.useMemo)(()=>{let n=$O();return DE(n,t,kE(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};YO(t,e.style,e),i.style={...t,...i.style}}return i}var tk=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function nk(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(tk.indexOf(e)>-1||/[A-Z]/u.test(e))}function rk(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??nk(e)?ek:QO)(t,r,i,e),c=UO(t,typeof e==`string`,a),l=e===I.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,I.useMemo)(()=>tw(u)?u.get():u,[u]);return(0,I.createElement)(e,{...l,children:d})}function ik({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:ak(n,r,i,e),renderState:t()}}function ak(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=ND(a[e]);let{initial:o,animate:s}=e,c=kT(e),l=AT(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!TT(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=JC(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var ok=e=>(t,n)=>{let r=(0,I.useContext)(WO),i=(0,I.useContext)(Uy),a=()=>ik(e,t,r,i);return n?a():Vy(a)},sk=ok({scrapeMotionValuesFromProps:bE,createRenderState:JO}),ck=ok({scrapeMotionValuesFromProps:jE,createRenderState:$O}),lk=Symbol.for(`motionComponentSymbol`);function uk(e,t,n){let r=(0,I.useRef)(n);(0,I.useInsertionEffect)(()=>{r.current=n});let i=(0,I.useRef)(null);return(0,I.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var dk=(0,I.createContext)({});function fk(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function pk(e,t,n,r,i,a){let{visualElement:o}=(0,I.useContext)(WO),s=(0,I.useContext)(AO),c=(0,I.useContext)(Uy),l=(0,I.useContext)(vO),u=l.reducedMotion,d=l.skipAnimations,f=(0,I.useRef)(null),p=(0,I.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,I.useContext)(dk);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&mk(f.current,n,i,h);let g=(0,I.useRef)(!1);(0,I.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[aw],v=(0,I.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Hy(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,I.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function mk(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:hk(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&fk(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function hk(e){if(e)return e.options.allowProjection===!1?hk(e.parent):e.projection}function gk(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&FO(r);let a=n?n===`svg`:nk(e),o=a?ck:sk;function s(n,s){let c,l={...(0,I.useContext)(vO),...n,layoutId:_k(n)},{isStatic:u}=l,d=KO(n),f=o(n,u);if(!u&&typeof window<`u`){vk(l,r);let t=yk(l);c=t.MeasureLayout,d.visualElement=pk(e,f,l,i,t.ProjectionNode,a)}return(0,L.jsxs)(WO.Provider,{value:d,children:[c&&d.visualElement?(0,L.jsx)(c,{visualElement:d.visualElement,...l}):null,rk(e,n,uk(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,I.forwardRef)(s);return c[lk]=e,c}function _k({layoutId:e}){let t=(0,I.useContext)(By).id;return t&&e!==void 0?t+`-`+e:e}function vk(e,t){(0,I.useContext)(AO).strict}function yk(e){let{drag:t,layout:n}=PO();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function bk(e,t){if(typeof Proxy>`u`)return gk;let n=new Map,r=(n,r)=>gk(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,gk(a,void 0,e,t)),n.get(a))})}var xk=(e,t)=>t.isSVG??nk(e)?new ME(t):new SE(t,{allowProjection:e!==I.Fragment}),Sk=class extends HT{constructor(e){super(e),e.animationState||=zE(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();TT(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},Ck=0,wk={animation:{Feature:Sk},exit:{Feature:class extends HT{constructor(){super(...arguments),this.id=Ck++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=YC(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function Tk(e){return{point:{x:e.pageX,y:e.pageY}}}var Ek=e=>t=>Uw(t)&&e(t,Tk(t));function Dk(e,t,n,r){return kD(e,t,Ek(n),r)}var Ok=({current:e})=>e?e.ownerDocument.defaultView:null,kk=(e,t)=>Math.abs(e-t);function Ak(e,t){let n=kk(e.x,t.x),r=kk(e.y,t.y);return Math.sqrt(n**2+r**2)}var jk=new Set([`auto`,`scroll`]),Mk=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Nk(this.lastRawMoveEventInfo,this.transformPagePoint));let e=Fk(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Ak(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Nb;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Nk(t,this.transformPagePoint),jb.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=Fk(e.type===`pointercancel`?this.lastMoveEventInfo:Nk(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Uw(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Nk(Tk(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Nb;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,Fk(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=$y(Dk(this.contextWindow,`pointermove`,this.handlePointerMove,d),Dk(this.contextWindow,`pointerup`,this.handlePointerUp,d),Dk(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(jk.has(e.overflowX)||jk.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),jb.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Mb(this.updatePoint)}};function Nk(e,t){return t?{point:t(e.point)}:e}function Pk(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Fk({point:e},t){return{point:e,delta:Pk(e,Lk(t)),offset:Pk(e,Ik(t)),velocity:Rk(t,.1)}}function Ik(e){return e[0]}function Lk(e){return e[e.length-1]}function Rk(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Lk(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>nb(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>nb(t)*2&&(r=e[1]);let a=rb(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function zk(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Ax(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Ax(n,e,r.max):Math.min(e,n)),e}function Bk(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Vk(e,{top:t,left:n,bottom:r,right:i}){return{x:Bk(e.x,n,i),y:Bk(e.y,t,r)}}function Hk(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function Uk(e,t){return{x:Hk(e.x,t.x),y:Hk(e.y,t.y)}}function Wk(e,t){let n=.5,r=XE(e),i=XE(t);return i>r?n=eb(t.min,t.max-r,e.min):r>i&&(n=eb(e.min,e.max-i,t.min)),Ky(0,1,n)}function Gk(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var Kk=.35;function qk(e=Kk){return e===!1?e=0:e===!0&&(e=Kk),{x:Jk(e,`left`,`right`),y:Jk(e,`top`,`bottom`)}}function Jk(e,t,n){return{min:Yk(e,t),max:Yk(e,n)}}function Yk(e,t){return typeof e==`number`?e:e[t]||0}var Xk=new WeakMap,Zk=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=CT(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(Tk(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Rw(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),vD(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ax.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=XE(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&jb.update(()=>i(e,t),!1,!0),rw(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=tA(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&jb.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new Mk(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:Ok(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&jb.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!eA(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=zk(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&fk(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Vk(n.layoutBox,e):this.constraints=!1,this.elastic=qk(t),r!==this.constraints&&!fk(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&vD(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=Gk(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!fk(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=lE(n,r.root,this.visualElement.getTransformPagePoint()),a=Uk(r.layout.layoutBox,i);if(t){let e=t(WT(a));this.hasMutatedConstraints=!!e,e&&(a=UT(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=vD(o=>{if(!eA(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return rw(this.visualElement,e),n.start(UC(e,n,0,t,this.visualElement,!1))}stopAnimation(){vD(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){vD(t=>{let{drag:n}=this.getProps();if(!eA(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-Ax(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!fk(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};vD(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Wk({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),vD(t=>{if(!eA(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(Ax(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Xk.set(this.visualElement,this);let e=this.visualElement.current,t=Dk(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&qw(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();fk(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=$k(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),jb.read(r);let o=kD(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(vD(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=Kk,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Qk(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function $k(e,t,n){let r=hT(e,Qk(n)),i=hT(t,Qk(n));return()=>{r(),i()}}function eA(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function tA(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var nA=class extends HT{constructor(e){super(e),this.removeGroupControls=Qy,this.removeListeners=Qy,this.controls=new Zk(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Qy}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},rA=e=>(t,n)=>{e&&jb.update(()=>e(t,n),!1,!0)},iA=class extends HT{constructor(){super(...arguments),this.removePointerDownListener=Qy}onPointerDown(e){this.session=new Mk(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ok(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:rA(e),onStart:rA(t),onMove:rA(n),onEnd:(e,t)=>{delete this.session,r&&jb.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Dk(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},aA=!1,oA=class extends I.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),aA&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),FD.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),aA=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||jb.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Fw.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;aA=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function sA(e){let[t,n]=EO(),r=(0,I.useContext)(By);return(0,L.jsx)(oA,{...e,layoutGroup:r,switchLayoutGroup:(0,I.useContext)(dk),isPresent:t,safeToRemove:n})}var cA={pan:{Feature:iA},drag:{Feature:nA,ProjectionNode:_O,MeasureLayout:sA}};function lA(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&jb.postRender(()=>i(t,Tk(t)))}var uA=class extends HT{mount(){let{current:e}=this.node;e&&(this.unmount=Vw(e,(e,t)=>(lA(this.node,t,`Start`),e=>lA(this.node,e,`End`))))}unmount(){}},dA=class extends HT{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=$y(kD(this.node.current,`focus`,()=>this.onFocus()),kD(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function fA(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&jb.postRender(()=>i(t,Tk(t)))}var pA=class extends HT{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=eT(e,(e,t)=>(fA(this.node,t,`Start`),(e,{success:t})=>fA(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},mA=new WeakMap,hA=new WeakMap,gA=e=>{let t=mA.get(e.target);t&&t(e)},_A=e=>{e.forEach(gA)};function vA({root:e,...t}){let n=e||document;hA.has(n)||hA.set(n,{});let r=hA.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(_A,{root:e,...t})),r[i]}function yA(e,t,n){let r=vA(t);return mA.set(e,n),r.observe(e),()=>{mA.delete(e),r.unobserve(e)}}var bA={some:0,all:1},xA=class extends HT{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:bA[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=yA(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(SA(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function SA({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var CA={inView:{Feature:xA},tap:{Feature:pA},focus:{Feature:dA},hover:{Feature:uA}},wA={layout:{ProjectionNode:_O,MeasureLayout:sA}},TA=bk({...wk,...CA,...cA,...wA},xk);function EA(){!NT.current&&FT();let[e]=(0,I.useState)(MT.current);return e}function DA(e){e.values.forEach(e=>e.stop())}function OA(e,t){[...t].reverse().forEach(n=>{let r=e.getVariant(n);r&&ew(e,r),e.variantChildren&&e.variantChildren.forEach(e=>{OA(e,t)})})}function kA(e,t){if(Array.isArray(t))return OA(e,t);if(typeof t==`string`)return OA(e,[t]);ew(e,t)}function AA(){let e=new Set,t={subscribe(t){return e.add(t),()=>void e.delete(t)},start(t,n){let r=[];return e.forEach(e=>{r.push(dw(e,t,{transitionOverride:n}))}),Promise.all(r)},set(t){return e.forEach(e=>{kA(e,t)})},stop(){e.forEach(e=>{DA(e)})},mount(){return()=>{t.stop()}}};return t}function jA(){let e=Vy(AA);return Hy(e.mount,[]),e}var MA=jA,W=qe(),NA=TA,PA={damping:.7,stiffness:.05,mass:1.25},FA=70,IA=1e3/60,LA=350,RA=!1;globalThis.document?.addEventListener(`mousedown`,()=>{RA=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{RA=!1}),globalThis.document?.addEventListener(`click`,()=>{RA=!1});var zA=(e={})=>{let[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(e.initial!==!1),[a,o]=(0,I.useState)(!1),s=(0,I.useRef)(null);s.current=e;let c=(0,I.useCallback)(()=>{if(!RA)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,I.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,I.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,I.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=FA}}},[]),f=(0,I.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=HA(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/IA;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:HA(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,I.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,I.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,I.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=BA(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=BA(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=HA(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:LA})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function BA(e,t){let n=(0,I.useCallback)(t=>(n.current=t,e(t)),t);return n}var VA=new Map;function HA(...e){let t={...PA},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return VA.has(r)||VA.set(r,Object.freeze(t)),n?`instant`:VA.get(r)}var UA=new Set([`name`,`id`,`aria-describedby`,`aria-labelledby`]);function WA(e){let t=new Set;for(let{name:n}of e){if(t.has(n))return n;t.add(n)}}function oee(e){let t=e.allowedAttributes.filter(e=>UA.has(e));if(t.length>0)throw Error(`Interactive element <${e.name}> declares reserved attribute(s) ${t.join(`, `)}. The markdown sanitizer rewrites these to "user-content-<value>" (DOM-clobbering protection), so the component would receive a mangled value. Use a domain attribute instead (e.g. "param").`)}var GA=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,KA=F().min(1).max(64).regex(GA).refine(e=>!UA.has(e),{error:`Attribute is reserved: the markdown sanitizer rewrites it to "user-content-<value>". Use a domain attribute instead (e.g. "param").`}),qA=Se({name:F().min(1).max(64).regex(GA),description:F().max(512).optional(),allowedAttributes:vt(KA).max(20)});vt(qA).max(100).superRefine((e,t)=>{let n=WA(e);n!==void 0&&t.addIssue({code:`custom`,message:`Duplicate element name "${n}": a catalog must map each tag to exactly one element.`})}).optional();function JA(e){let{name:t,allowedAttributes:n,description:r}=e;return{name:t,allowedAttributes:n,description:r}}function YA(e){for(let t of e){let e=qA.safeParse(JA(t));if(!e.success)throw Error(`Interactive element <${t.name}> is invalid:
179
+ ${it(e.error)}`)}let t=WA(e);if(t!==void 0)throw Error(`Duplicate element name <${t}>: a catalog must map each tag to exactly one element.`);return[...e]}var XA={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`};function ZA(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}function QA(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function $A(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function ej(e){return $A(e)||ZA(e)}var tj=[``,`Named character references must be terminated by a semicolon`,`Numeric character references must be terminated by a semicolon`,`Named character references cannot be empty`,`Numeric character references cannot be empty`,`Named character references must be known`,`Numeric character references cannot be disallowed`,`Numeric character references cannot be outside the permissible Unicode range`];function nj(e,t){let n=t||{},r=typeof n.additional==`string`?n.additional.charCodeAt(0):n.additional,i=[],a=0,o=-1,s=``,c,l;n.position&&(`start`in n.position||`indent`in n.position?(l=n.position.indent,c=n.position.start):c=n.position);let u=(c?c.line:0)||1,d=(c?c.column:0)||1,f=m(),p;for(a--;++a<=e.length;)if(p===10&&(d=(l?l[o]:0)||1),p=e.charCodeAt(a),p===38){let t=e.charCodeAt(a+1);if(t===9||t===10||t===12||t===32||t===38||t===60||Number.isNaN(t)||r&&t===r){s+=String.fromCharCode(p),d++;continue}let o=a+1,c=o,l=o,u;if(t===35){l=++c;let t=e.charCodeAt(l);t===88||t===120?(u=`hexadecimal`,l=++c):u=`decimal`}else u=`named`;let _=``,v=``,y=``,b=u===`named`?ej:u===`decimal`?ZA:QA;for(l--;++l<=e.length;){let t=e.charCodeAt(l);if(!b(t))break;y+=String.fromCharCode(t),u===`named`&&oc.includes(y)&&(_=y,v=kn(y))}let x=e.charCodeAt(l)===59;if(x){l++;let e=u===`named`&&kn(y);e&&(_=y,v=e)}let S=1+l-o,C=``;if(!(!x&&n.nonTerminated===!1))if(!y)u!==`named`&&h(4,S);else if(u===`named`){if(x&&!v)h(5,1);else if(_!==y&&(l=c+_.length,S=1+l-c,x=!1),!x){let t=_?1:3;if(n.attribute){let n=e.charCodeAt(l);n===61?(h(t,S),v=``):ej(n)?v=``:h(t,S)}else h(t,S)}C=v}else{x||h(2,S);let e=Number.parseInt(y,u===`hexadecimal`?16:10);if(rj(e))h(7,S),C=`�`;else if(e in XA)h(6,S),C=XA[e];else{let t=``;ij(e)&&h(6,S),e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10|55296),e=56320|e&1023),C=t+String.fromCharCode(e)}}if(C){g(),f=m(),a=l-1,d+=l-o+1,i.push(C);let t=m();t.offset++,n.reference&&n.reference.call(n.referenceContext||void 0,C,{start:f,end:t},e.slice(o-1,l)),f=t}else y=e.slice(o-1,l),s+=y,d+=y.length,a=l-1}else p===10&&(u++,o++,d=0),Number.isNaN(p)?g():(s+=String.fromCharCode(p),d++);return i.join(``);function m(){return{line:u,column:d,offset:a+((c?c.offset:0)||0)}}function h(e,t){let r;n.warning&&(r=m(),r.column+=t,r.offset+=t,n.warning.call(n.warningContext||void 0,tj[e],r,e))}function g(){s&&=(i.push(s),n.text&&n.text.call(n.textContext||void 0,s,{start:f,end:m()}),``)}}function rj(e){return e>=55296&&e<=57343||e>1114111}function ij(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}var aj={}.hasOwnProperty,oj={},sj=/^[^\t\n\r "#'.<=>`}]+$/,cj=/^[^\t\n\r "'<=>`}]+$/;function lj(){return{canContainEols:[`textDirective`],enter:{directiveContainer:dj,directiveContainerAttributes:vj,directiveContainerLabel:gj,directiveLeaf:fj,directiveLeafAttributes:vj,directiveText:pj,directiveTextAttributes:vj},exit:{directiveContainer:wj,directiveContainerAttributeClassValue:bj,directiveContainerAttributeIdValue:yj,directiveContainerAttributeName:Sj,directiveContainerAttributeValue:xj,directiveContainerAttributes:Cj,directiveContainerLabel:_j,directiveContainerName:hj,directiveLeaf:wj,directiveLeafAttributeClassValue:bj,directiveLeafAttributeIdValue:yj,directiveLeafAttributeName:Sj,directiveLeafAttributeValue:xj,directiveLeafAttributes:Cj,directiveLeafName:hj,directiveText:wj,directiveTextAttributeClassValue:bj,directiveTextAttributeIdValue:yj,directiveTextAttributeName:Sj,directiveTextAttributeValue:xj,directiveTextAttributes:Cj,directiveTextName:hj}}}function uj(e){let t=e||oj;if(t.quote!==`"`&&t.quote!==`'`&&t.quote!==null&&t.quote!==void 0)throw Error("Invalid quote `"+t.quote+"`, expected `'` or `\"`");return n.peek=Tj,{handlers:{containerDirective:n,leafDirective:n,textDirective:n},unsafe:[{character:`\r`,inConstruct:[`leafDirectiveLabel`,`containerDirectiveLabel`]},{character:`
180
180
  `,inConstruct:[`leafDirectiveLabel`,`containerDirectiveLabel`]},{before:`[^:]`,character:`:`,after:`[A-Za-z]`,inConstruct:[`phrasing`]},{atBreak:!0,character:`:`,after:`:`}]};function n(e,t,n,i){let a=n.createTracker(i),o=Dj(e),s=n.enter(e.type),c=a.move(o+(e.name||``)),l;if(e.type===`containerDirective`){let t=(e.children||[])[0];l=Ej(t)?t:void 0}else l=e;if(l&&l.children&&l.children.length>0){let t=n.enter(`label`),r=`${e.type}Label`,i=n.enter(r);c+=a.move(`[`),c+=a.move(n.containerPhrasing(l,{...a.current(),before:c,after:`]`})),c+=a.move(`]`),i(),t()}if(c+=a.move(r(e,n)),e.type===`containerDirective`){let t=(e.children||[])[0],r=e;Ej(t)&&(r=Object.assign({},e,{children:e.children.slice(1)})),r&&r.children&&r.children.length>0&&(c+=a.move(`
181
181
  `),c+=a.move(n.containerFlow(r,a.current()))),c+=a.move(`
182
182
  `+o)}return s(),c}function r(e,n){let r=e.attributes||{},a=[],o,s,c,l;for(l in r)if(aj.call(r,l)&&r[l]!==void 0&&r[l]!==null){let u=String(r[l]);if(l===`id`)c=t.preferShortcut!==!1&&sj.test(u)?`#`+u:i(`id`,u,e,n);else if(l===`class`){let r=u.split(/[\t\n\r ]+/g),a=[],c=[],l=-1;for(;++l<r.length;)(t.preferShortcut!==!1&&sj.test(r[l])?c:a).push(r[l]);o=a.length>0?i(`class`,a.join(` `),e,n):``,s=c.length>0?`.`+c.join(`.`):``}else a.push(i(l,u,e,n))}return o&&a.unshift(o),s&&a.unshift(s),c&&a.unshift(c),a.length>0?`{`+a.join(` `)+`}`:``}function i(e,n,r,i){if(t.collapseEmptyAttributes!==!1&&!n)return e;if(t.preferUnquoted&&cj.test(n))return e+`=`+n;let a=t.quote||i.options.quote||`"`,o=a===`"`?`'`:`"`,s=t.quoteSmart&&qn(n,a)>qn(n,o)?o:a,c=r.type===`textDirective`?[s]:[s,`
183
- `,`\r`];return e+`=`+s+gc(n,{subset:c})+s}}function dj(e){mj.call(this,`containerDirective`,e)}function fj(e){mj.call(this,`leafDirective`,e)}function pj(e){mj.call(this,`textDirective`,e)}function mj(e,t){this.enter({type:e,name:``,attributes:{},children:[]},t)}function hj(e){let t=this.stack[this.stack.length-1];t.type===`containerDirective`||t.type===`leafDirective`||t.type,t.name=this.sliceSerialize(e)}function gj(e){this.enter({type:`paragraph`,data:{directiveLabel:!0},children:[]},e)}function _j(e){this.exit(e)}function vj(){this.data.directiveAttributes=[],this.buffer()}function yj(e){this.data.directiveAttributes.push([`id`,nj(this.sliceSerialize(e),{attribute:!0})])}function bj(e){this.data.directiveAttributes.push([`class`,nj(this.sliceSerialize(e),{attribute:!0})])}function xj(e){let t=this.data.directiveAttributes;t[t.length-1][1]=nj(this.sliceSerialize(e),{attribute:!0})}function Sj(e){this.data.directiveAttributes.push([this.sliceSerialize(e),``])}function Cj(){let e=this.data.directiveAttributes,t={},n=-1;for(;++n<e.length;){let r=e[n];r[0]===`class`&&t.class?t.class+=` `+r[1]:t[r[0]]=r[1]}this.data.directiveAttributes=void 0,this.resume();let r=this.stack[this.stack.length-1];r.type===`containerDirective`||r.type===`leafDirective`||r.type,r.attributes=t}function wj(e){this.exit(e)}function Tj(){return`:`}function Ej(e){return!!(e&&e.type===`paragraph`&&e.data&&e.data.directiveLabel)}function Dj(e){let t=0;return e.type===`containerDirective`?(An(e,function(e,n){if(e.type===`containerDirective`){let e=n.length,r=0;for(;e--;)n[e].type===`containerDirective`&&r++;r>t&&(t=r)}}),t+=3):t=e.type===`leafDirective`?2:1,`:`.repeat(t)}function Oj(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h,g;return _;function _(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),v}function v(t){return t===35?(h=o,y(t)):t===46?(h=s,y(t)):m&&Vn(t)?Gn(e,v,`whitespace`)(t):!m&&ir(t)?Kn(e,v)(t):t===null||tr(t)||Ln(t)||rr(t)&&t!==45&&t!==95?D(t):(e.enter(a),e.enter(c),e.consume(t),S)}function y(t){let n=h+`Marker`;return e.enter(a),e.enter(h),e.enter(n),e.consume(t),e.exit(n),b}function b(t){if(t===null||t===34||t===35||t===39||t===46||t===60||t===61||t===62||t===96||t===125||ir(t))return n(t);let r=h+`Value`;return e.enter(r),e.consume(t),x}function x(t){if(t===null||t===34||t===39||t===60||t===61||t===62||t===96)return n(t);if(t===35||t===46||t===125||ir(t)){let n=h+`Value`;return e.exit(n),e.exit(h),e.exit(a),v(t)}return e.consume(t),x}function S(t){return t===null||tr(t)||Ln(t)||rr(t)&&t!==45&&t!==46&&t!==58&&t!==95?(e.exit(c),m&&Vn(t)?Gn(e,C,`whitespace`)(t):!m&&ir(t)?Kn(e,C)(t):C(t)):(e.consume(t),S)}function C(t){return t===61?(e.enter(l),e.consume(t),e.exit(l),w):(e.exit(a),v(t))}function w(t){return t===null||t===60||t===61||t===62||t===96||t===125||m&&tr(t)?n(t):t===34||t===39?(e.enter(u),e.enter(f),e.consume(t),e.exit(f),g=t,E):m&&Vn(t)?Gn(e,w,`whitespace`)(t):!m&&ir(t)?Kn(e,w)(t):(e.enter(d),e.enter(p),e.consume(t),g=void 0,T)}function T(t){return t===null||t===34||t===39||t===60||t===61||t===62||t===96?n(t):t===125||ir(t)?(e.exit(p),e.exit(d),e.exit(a),v(t)):(e.consume(t),T)}function E(t){return t===g?(e.enter(f),e.consume(t),e.exit(f),e.exit(u),e.exit(a),ne):(e.enter(d),ee(t))}function ee(t){return t===g?(e.exit(d),E(t)):t===null?n(t):tr(t)?m?n(t):Kn(e,ee)(t):(e.enter(p),e.consume(t),te)}function te(t){return t===g||t===null||tr(t)?(e.exit(p),ee(t)):(e.consume(t),te)}function ne(e){return e===125||ir(e)?v(e):D(e)}function D(a){return a===125?(e.enter(i),e.consume(a),e.exit(i),e.exit(r),t):n(a)}}function kj(e,t,n,r,i,a,o){let s=0,c=0,l;return u;function u(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),d}function d(n){return n===93?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),f(n))}function f(t){if(t===93&&!c)return h(t);let n=e.enter(`chunkText`,{_contentTypeTextTrailing:!0,contentType:`text`,previous:l});return l&&(l.next=n),l=n,p(t)}function p(t){return t===null||s>999||t===91&&++c>32?n(t):t===93&&!c--?(e.exit(`chunkText`),h(t)):tr(t)?o?n(t):(e.consume(t),e.exit(`chunkText`),f):(e.consume(t),t===92?m:p)}function m(t){return t===91||t===92||t===93?(e.consume(t),s++,p):p(t)}function h(n){return e.exit(a),e.enter(i),e.consume(n),e.exit(i),e.exit(r),t}}function Aj(e,t,n,r){let i=this;return a;function a(t){return t===null||tr(t)||rr(t)||Ln(t)?n(t):(e.enter(r),e.consume(t),o)}function o(a){return a===null||tr(a)||Ln(a)||rr(a)&&a!==45&&a!==95?(e.exit(r),i.previous===45||i.previous===95?n(a):t(a)):(e.consume(a),o)}}var jj={tokenize:Fj,concrete:!0},Mj={tokenize:Ij,partial:!0},Nj={tokenize:Lj,partial:!0},Pj={tokenize:Rj,partial:!0};function Fj(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0,s;return c;function c(t){return e.enter(`directiveContainer`),e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),l(t)}function l(t){return t===58?(e.consume(t),o++,l):o<3?n(t):(e.exit(`directiveContainerSequence`),Aj.call(r,e,u,n,`directiveContainerName`)(t))}function u(t){return t===91?e.attempt(Mj,d,d)(t):d(t)}function d(t){return t===123?e.attempt(Nj,f,f)(t):f(t)}function f(t){return Gn(e,p,`whitespace`)(t)}function p(i){return e.exit(`directiveContainerFence`),i===null?C(i):tr(i)?r.interrupt?t(i):e.attempt(Pj,m,C)(i):n(i)}function m(t){return t===null?C(t):tr(t)?e.check(Pj,y,C)(t):(e.enter(`directiveContainerContent`),h(t))}function h(t){return e.attempt({tokenize:w,partial:!0},S,a?Gn(e,g,`linePrefix`,a+1):g)(t)}function g(t){return t===null?S(t):tr(t)?e.check(Pj,v,S)(t):v(t)}function _(t){if(t===null){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}return tr(t)?e.check(Pj,b,x)(t):(e.consume(t),_)}function v(t){let n=e.enter(`chunkDocument`,{contentType:`document`,previous:s});return s&&(s.next=n),s=n,_(t)}function y(t){return e.enter(`directiveContainerContent`),h(t)}function b(t){e.consume(t);let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,h}function x(t){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}function S(t){return e.exit(`directiveContainerContent`),C(t)}function C(n){return e.exit(`directiveContainer`),t(n)}function w(e,t,n){let i=0;return Gn(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),s(t)}function s(t){return t===58?(e.consume(t),i++,s):i<o?n(t):(e.exit(`directiveContainerSequence`),Gn(e,c,`whitespace`)(t))}function c(r){return r===null||tr(r)?(e.exit(`directiveContainerFence`),t(r)):n(r)}}}function Ij(e,t,n){return kj(e,t,n,`directiveContainerLabel`,`directiveContainerLabelMarker`,`directiveContainerLabelString`,!0)}function Lj(e,t,n){return Oj(e,t,n,`directiveContainerAttributes`,`directiveContainerAttributesMarker`,`directiveContainerAttribute`,`directiveContainerAttributeId`,`directiveContainerAttributeClass`,`directiveContainerAttributeName`,`directiveContainerAttributeInitializerMarker`,`directiveContainerAttributeValueLiteral`,`directiveContainerAttributeValue`,`directiveContainerAttributeValueMarker`,`directiveContainerAttributeValueData`,!0)}function Rj(e,t,n){let r=this;return i;function i(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var zj={tokenize:Hj},Bj={tokenize:Uj,partial:!0},Vj={tokenize:Wj,partial:!0};function Hj(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveLeaf`),e.enter(`directiveLeafSequence`),e.consume(t),a}function a(t){return t===58?(e.consume(t),e.exit(`directiveLeafSequence`),Aj.call(r,e,o,n,`directiveLeafName`)):n(t)}function o(t){return t===91?e.attempt(Bj,s,s)(t):s(t)}function s(t){return t===123?e.attempt(Vj,c,c)(t):c(t)}function c(t){return Gn(e,l,`whitespace`)(t)}function l(r){return r===null||tr(r)?(e.exit(`directiveLeaf`),t(r)):n(r)}}function Uj(e,t,n){return kj(e,t,n,`directiveLeafLabel`,`directiveLeafLabelMarker`,`directiveLeafLabelString`,!0)}function Wj(e,t,n){return Oj(e,t,n,`directiveLeafAttributes`,`directiveLeafAttributesMarker`,`directiveLeafAttribute`,`directiveLeafAttributeId`,`directiveLeafAttributeClass`,`directiveLeafAttributeName`,`directiveLeafAttributeInitializerMarker`,`directiveLeafAttributeValueLiteral`,`directiveLeafAttributeValue`,`directiveLeafAttributeValueMarker`,`directiveLeafAttributeValueData`,!0)}var Gj={tokenize:Yj,previous:Jj},Kj={tokenize:Xj,partial:!0},qj={tokenize:Zj,partial:!0};function Jj(e){return e!==58||this.events[this.events.length-1][1].type===`characterEscape`}function Yj(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveText`),e.enter(`directiveTextMarker`),e.consume(t),e.exit(`directiveTextMarker`),Aj.call(r,e,a,n,`directiveTextName`)}function a(t){return t===58?n(t):t===91?e.attempt(Kj,o,o)(t):o(t)}function o(t){return t===123?e.attempt(qj,s,s)(t):s(t)}function s(n){return e.exit(`directiveText`),t(n)}}function Xj(e,t,n){return kj(e,t,n,`directiveTextLabel`,`directiveTextLabelMarker`,`directiveTextLabelString`)}function Zj(e,t,n){return Oj(e,t,n,`directiveTextAttributes`,`directiveTextAttributesMarker`,`directiveTextAttribute`,`directiveTextAttributeId`,`directiveTextAttributeClass`,`directiveTextAttributeName`,`directiveTextAttributeInitializerMarker`,`directiveTextAttributeValueLiteral`,`directiveTextAttributeValue`,`directiveTextAttributeValueMarker`,`directiveTextAttributeValueData`)}function Qj(){return{text:{58:Gj},flow:{58:[jj,zj]}}}function $j(){let e=this.data(),t=e.micromarkExtensions||=[],n=e.fromMarkdownExtensions||=[],r=e.toMarkdownExtensions||=[];t.push(Qj()),n.push(lj()),r.push(uj())}var eM=n(o(),1),tM=/```([^\r\n`]*)\r?\n?([\s\S]*?)```|`([^`\r\n]+)`/g,nM=/\$\[[^\]\r\n]+\]|\$[A-Za-z0-9][\w.-]*/g,rM=`skill://`,iM=`mention://`;function aM(e,t){return`[${fM(e,`[]`)}](${fM(t,`()`)})`}function oM(e){let t=[],n=0;for(let r of e.matchAll(tM)){let i=r.index;i>n&&t.push(...sM(e.slice(n,i),n));let a=r[0],o=i+a.length,s=r[2];s===void 0?t.push({kind:`inline-code`,source:a,start:i,end:o,value:r[3]??``}):t.push({kind:`code-block`,source:a,start:i,end:o,language:r[1]??``,value:s}),n=o}return n<e.length&&t.push(...sM(e.slice(n),n)),t}function sM(e,t){let n=[],r=dM(e),i=0;for(let a of r)a.start>i&&n.push(...lM(e.slice(i,a.start),t+i)),n.push(cM(a,e,t)),i=a.end;return i<e.length&&n.push(...lM(e.slice(i),t+i)),n}function cM(e,t,n){let r=n+e.start,i=n+e.end,a=t.slice(e.start,e.end);if(e.href.startsWith(iM)){let t=e.href.slice(10);if(t)return{kind:`mention`,source:a,start:r,end:i,label:e.label,href:e.href,name:t}}if(e.label.startsWith(`$`)&&e.href.startsWith(rM)){let t=e.label.slice(1),n=e.href.slice(8);if(t&&n)return{kind:`skill-link`,source:a,start:r,end:i,label:e.label,href:e.href,name:t,skillId:n}}return{kind:`link`,source:a,start:r,end:i,label:e.label,href:e.href}}function lM(e,t){let n=[],r=0;for(let i of e.matchAll(nM)){let a=i.index,o=e[a-1];if(o&&/[\w$]/.test(o))continue;a>r&&n.push(uM(e.slice(r,a),t+r));let s=i[0],c=t+a;n.push({kind:`standalone-skill`,source:s,start:c,end:c+s.length,name:s.startsWith(`$[`)?s.slice(2,-1):s.slice(1)}),r=a+s.length}return r<e.length&&n.push(uM(e.slice(r),t+r)),n}function uM(e,t){return{kind:`text`,source:e,start:t,end:t+e.length,value:e}}function dM(e){let t=[];for(let n=0;n<e.length;n+=1){if(e[n]!==`[`)continue;let r=pM(e,n+1,`]`);if(!r||e[r.end+1]!==`(`)continue;let i=mM(e,r.end+2);i&&(t.push({label:r.value,href:i.value,start:n,end:i.end+1}),n=i.end)}return t}function fM(e,t){let n=``;for(let r of e)n+=r===`\\`||t.includes(r)?`\\${r}`:r;return n}function pM(e,t,n){let r=``;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){r+=e[i+1],i+=1;continue}if(t===n)return{value:r,end:i};r+=t}return null}function mM(e,t){let n=``,r=0;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){n+=e[i+1],i+=1;continue}if(t===`(`){r+=1,n+=t;continue}if(t===`)`){if(r===0)return{value:n,end:i};--r,n+=t;continue}n+=t}return null}var hM=O(),gM=Object.defineProperty,_M=(e,t)=>{let n={};for(var r in e)gM(n,r,{get:e[r],enumerable:!0});return t||gM(n,Symbol.toStringTag,{value:`Module`}),n};function vM(e){this.content=e}vM.prototype={constructor:vM,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new vM(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new vM(n)},addToStart:function(e,t){return new vM([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new vM(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new vM(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=vM.from(e),e.size?new vM(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=vM.from(e),e.size?new vM(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=vM.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},vM.from=function(e){if(e instanceof vM)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new vM(t)};function yM(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&SM(e.charCodeAt(r-1))&&xM(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=yM(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function bM(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&SM(e.charCodeAt(i-1))&&xM(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=bM(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function xM(e){return e>=56320&&e<57344}function SM(e){return e>=55296&&e<56320}var G=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return yM(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return bM(this,e,t,n)}findIndex(e){if(e==0)return wM(0,e);if(e==this.size)return wM(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?wM(t+1,i):wM(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};G.empty=new G([],0);var CM={index:0,offset:0};function wM(e,t){return CM.index=e,CM.offset=t,CM}function TM(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!TM(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!TM(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var EM=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&TM(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};EM.none=[];var DM=class extends Error{},K=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=kM(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(OM(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(G.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};K.empty=new K(G.empty,0,0);function OM(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(OM(a.content,t-i-1,n-i-1)))}function kM(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=kM(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function AM(e,t,n){if(n.openStart>e.depth)throw new DM(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new DM(`Inconsistent open depths`);return jM(e,t,n,0)}function jM(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=jM(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return IM(a,RM(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return IM(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=zM(n,e);return IM(a,LM(e,i,o,t,r))}}function MM(e,t){if(!t.type.compatibleContent(e.type))throw new DM(`Cannot join `+t.type.name+` onto `+e.type.name)}function NM(e,t,n){let r=e.node(n);return MM(r,t.node(n)),r}function PM(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function FM(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(PM(e.nodeAfter,r),a++));for(let e=a;e<o;e++)PM(i.child(e),r);t&&t.depth==n&&t.textOffset&&PM(t.nodeBefore,r)}function IM(e,t){if(!e.type.validContent(t))throw new DM(`Invalid content for node `+e.type.name);return e.copy(t)}function LM(e,t,n,r,i){let a=e.depth>i&&NM(e,t,i+1),o=r.depth>i&&NM(n,r,i+1),s=[];return FM(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(MM(a,o),PM(IM(a,LM(e,t,n,r,i+1)),s)):(a&&PM(IM(a,RM(e,t,i+1)),s),FM(t,n,i,s),o&&PM(IM(o,RM(n,r,i+1)),s)),FM(r,null,i,s),new G(s)}function RM(e,t,n){let r=[];return FM(null,e,n,r),e.depth>n&&PM(IM(NM(e,t,n+1),RM(e,t,n+1)),r),FM(t,null,n,r),new G(r)}function zM(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(G.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var BM=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return EM.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new WM(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=UM.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else UM.set(t,r=new VM);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%HM,i}},VM=class{constructor(){this.elts=[],this.i=0}},HM=12,UM=new WeakMap,WM=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},GM=Object.create(null),KM=class e{constructor(e,t,n,r=EM.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||G.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&TM(this.attrs,t||e.defaultAttrs||GM)&&EM.sameSet(this.marks,n||EM.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return K.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new K(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return AM(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return BM.resolveCached(this,e)}resolveNoCache(e){return BM.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),JM(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=G.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=EM.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!EM.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=G.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};KM.prototype.text=void 0;var qM=class e extends KM{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):JM(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function JM(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var YM=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new XM(t,n);if(r.next==null)return e.empty;let i=ZM(r);r.next&&r.err(`Unexpected trailing text`);let a=sN(iN(i));return cN(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return G.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
183
+ `,`\r`];return e+`=`+s+_c(n,{subset:c})+s}}function dj(e){mj.call(this,`containerDirective`,e)}function fj(e){mj.call(this,`leafDirective`,e)}function pj(e){mj.call(this,`textDirective`,e)}function mj(e,t){this.enter({type:e,name:``,attributes:{},children:[]},t)}function hj(e){let t=this.stack[this.stack.length-1];t.type===`containerDirective`||t.type===`leafDirective`||t.type,t.name=this.sliceSerialize(e)}function gj(e){this.enter({type:`paragraph`,data:{directiveLabel:!0},children:[]},e)}function _j(e){this.exit(e)}function vj(){this.data.directiveAttributes=[],this.buffer()}function yj(e){this.data.directiveAttributes.push([`id`,nj(this.sliceSerialize(e),{attribute:!0})])}function bj(e){this.data.directiveAttributes.push([`class`,nj(this.sliceSerialize(e),{attribute:!0})])}function xj(e){let t=this.data.directiveAttributes;t[t.length-1][1]=nj(this.sliceSerialize(e),{attribute:!0})}function Sj(e){this.data.directiveAttributes.push([this.sliceSerialize(e),``])}function Cj(){let e=this.data.directiveAttributes,t={},n=-1;for(;++n<e.length;){let r=e[n];r[0]===`class`&&t.class?t.class+=` `+r[1]:t[r[0]]=r[1]}this.data.directiveAttributes=void 0,this.resume();let r=this.stack[this.stack.length-1];r.type===`containerDirective`||r.type===`leafDirective`||r.type,r.attributes=t}function wj(e){this.exit(e)}function Tj(){return`:`}function Ej(e){return!!(e&&e.type===`paragraph`&&e.data&&e.data.directiveLabel)}function Dj(e){let t=0;return e.type===`containerDirective`?(An(e,function(e,n){if(e.type===`containerDirective`){let e=n.length,r=0;for(;e--;)n[e].type===`containerDirective`&&r++;r>t&&(t=r)}}),t+=3):t=e.type===`leafDirective`?2:1,`:`.repeat(t)}function Oj(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h,g;return _;function _(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),v}function v(t){return t===35?(h=o,y(t)):t===46?(h=s,y(t)):m&&Vn(t)?Gn(e,v,`whitespace`)(t):!m&&ir(t)?Kn(e,v)(t):t===null||tr(t)||Ln(t)||rr(t)&&t!==45&&t!==95?D(t):(e.enter(a),e.enter(c),e.consume(t),S)}function y(t){let n=h+`Marker`;return e.enter(a),e.enter(h),e.enter(n),e.consume(t),e.exit(n),b}function b(t){if(t===null||t===34||t===35||t===39||t===46||t===60||t===61||t===62||t===96||t===125||ir(t))return n(t);let r=h+`Value`;return e.enter(r),e.consume(t),x}function x(t){if(t===null||t===34||t===39||t===60||t===61||t===62||t===96)return n(t);if(t===35||t===46||t===125||ir(t)){let n=h+`Value`;return e.exit(n),e.exit(h),e.exit(a),v(t)}return e.consume(t),x}function S(t){return t===null||tr(t)||Ln(t)||rr(t)&&t!==45&&t!==46&&t!==58&&t!==95?(e.exit(c),m&&Vn(t)?Gn(e,C,`whitespace`)(t):!m&&ir(t)?Kn(e,C)(t):C(t)):(e.consume(t),S)}function C(t){return t===61?(e.enter(l),e.consume(t),e.exit(l),w):(e.exit(a),v(t))}function w(t){return t===null||t===60||t===61||t===62||t===96||t===125||m&&tr(t)?n(t):t===34||t===39?(e.enter(u),e.enter(f),e.consume(t),e.exit(f),g=t,E):m&&Vn(t)?Gn(e,w,`whitespace`)(t):!m&&ir(t)?Kn(e,w)(t):(e.enter(d),e.enter(p),e.consume(t),g=void 0,T)}function T(t){return t===null||t===34||t===39||t===60||t===61||t===62||t===96?n(t):t===125||ir(t)?(e.exit(p),e.exit(d),e.exit(a),v(t)):(e.consume(t),T)}function E(t){return t===g?(e.enter(f),e.consume(t),e.exit(f),e.exit(u),e.exit(a),ne):(e.enter(d),ee(t))}function ee(t){return t===g?(e.exit(d),E(t)):t===null?n(t):tr(t)?m?n(t):Kn(e,ee)(t):(e.enter(p),e.consume(t),te)}function te(t){return t===g||t===null||tr(t)?(e.exit(p),ee(t)):(e.consume(t),te)}function ne(e){return e===125||ir(e)?v(e):D(e)}function D(a){return a===125?(e.enter(i),e.consume(a),e.exit(i),e.exit(r),t):n(a)}}function kj(e,t,n,r,i,a,o){let s=0,c=0,l;return u;function u(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),d}function d(n){return n===93?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),f(n))}function f(t){if(t===93&&!c)return h(t);let n=e.enter(`chunkText`,{_contentTypeTextTrailing:!0,contentType:`text`,previous:l});return l&&(l.next=n),l=n,p(t)}function p(t){return t===null||s>999||t===91&&++c>32?n(t):t===93&&!c--?(e.exit(`chunkText`),h(t)):tr(t)?o?n(t):(e.consume(t),e.exit(`chunkText`),f):(e.consume(t),t===92?m:p)}function m(t){return t===91||t===92||t===93?(e.consume(t),s++,p):p(t)}function h(n){return e.exit(a),e.enter(i),e.consume(n),e.exit(i),e.exit(r),t}}function Aj(e,t,n,r){let i=this;return a;function a(t){return t===null||tr(t)||rr(t)||Ln(t)?n(t):(e.enter(r),e.consume(t),o)}function o(a){return a===null||tr(a)||Ln(a)||rr(a)&&a!==45&&a!==95?(e.exit(r),i.previous===45||i.previous===95?n(a):t(a)):(e.consume(a),o)}}var jj={tokenize:Fj,concrete:!0},Mj={tokenize:Ij,partial:!0},Nj={tokenize:Lj,partial:!0},Pj={tokenize:Rj,partial:!0};function Fj(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0,s;return c;function c(t){return e.enter(`directiveContainer`),e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),l(t)}function l(t){return t===58?(e.consume(t),o++,l):o<3?n(t):(e.exit(`directiveContainerSequence`),Aj.call(r,e,u,n,`directiveContainerName`)(t))}function u(t){return t===91?e.attempt(Mj,d,d)(t):d(t)}function d(t){return t===123?e.attempt(Nj,f,f)(t):f(t)}function f(t){return Gn(e,p,`whitespace`)(t)}function p(i){return e.exit(`directiveContainerFence`),i===null?C(i):tr(i)?r.interrupt?t(i):e.attempt(Pj,m,C)(i):n(i)}function m(t){return t===null?C(t):tr(t)?e.check(Pj,y,C)(t):(e.enter(`directiveContainerContent`),h(t))}function h(t){return e.attempt({tokenize:w,partial:!0},S,a?Gn(e,g,`linePrefix`,a+1):g)(t)}function g(t){return t===null?S(t):tr(t)?e.check(Pj,v,S)(t):v(t)}function _(t){if(t===null){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}return tr(t)?e.check(Pj,b,x)(t):(e.consume(t),_)}function v(t){let n=e.enter(`chunkDocument`,{contentType:`document`,previous:s});return s&&(s.next=n),s=n,_(t)}function y(t){return e.enter(`directiveContainerContent`),h(t)}function b(t){e.consume(t);let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,h}function x(t){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}function S(t){return e.exit(`directiveContainerContent`),C(t)}function C(n){return e.exit(`directiveContainer`),t(n)}function w(e,t,n){let i=0;return Gn(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),s(t)}function s(t){return t===58?(e.consume(t),i++,s):i<o?n(t):(e.exit(`directiveContainerSequence`),Gn(e,c,`whitespace`)(t))}function c(r){return r===null||tr(r)?(e.exit(`directiveContainerFence`),t(r)):n(r)}}}function Ij(e,t,n){return kj(e,t,n,`directiveContainerLabel`,`directiveContainerLabelMarker`,`directiveContainerLabelString`,!0)}function Lj(e,t,n){return Oj(e,t,n,`directiveContainerAttributes`,`directiveContainerAttributesMarker`,`directiveContainerAttribute`,`directiveContainerAttributeId`,`directiveContainerAttributeClass`,`directiveContainerAttributeName`,`directiveContainerAttributeInitializerMarker`,`directiveContainerAttributeValueLiteral`,`directiveContainerAttributeValue`,`directiveContainerAttributeValueMarker`,`directiveContainerAttributeValueData`,!0)}function Rj(e,t,n){let r=this;return i;function i(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var zj={tokenize:Hj},Bj={tokenize:Uj,partial:!0},Vj={tokenize:Wj,partial:!0};function Hj(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveLeaf`),e.enter(`directiveLeafSequence`),e.consume(t),a}function a(t){return t===58?(e.consume(t),e.exit(`directiveLeafSequence`),Aj.call(r,e,o,n,`directiveLeafName`)):n(t)}function o(t){return t===91?e.attempt(Bj,s,s)(t):s(t)}function s(t){return t===123?e.attempt(Vj,c,c)(t):c(t)}function c(t){return Gn(e,l,`whitespace`)(t)}function l(r){return r===null||tr(r)?(e.exit(`directiveLeaf`),t(r)):n(r)}}function Uj(e,t,n){return kj(e,t,n,`directiveLeafLabel`,`directiveLeafLabelMarker`,`directiveLeafLabelString`,!0)}function Wj(e,t,n){return Oj(e,t,n,`directiveLeafAttributes`,`directiveLeafAttributesMarker`,`directiveLeafAttribute`,`directiveLeafAttributeId`,`directiveLeafAttributeClass`,`directiveLeafAttributeName`,`directiveLeafAttributeInitializerMarker`,`directiveLeafAttributeValueLiteral`,`directiveLeafAttributeValue`,`directiveLeafAttributeValueMarker`,`directiveLeafAttributeValueData`,!0)}var Gj={tokenize:Yj,previous:Jj},Kj={tokenize:Xj,partial:!0},qj={tokenize:Zj,partial:!0};function Jj(e){return e!==58||this.events[this.events.length-1][1].type===`characterEscape`}function Yj(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveText`),e.enter(`directiveTextMarker`),e.consume(t),e.exit(`directiveTextMarker`),Aj.call(r,e,a,n,`directiveTextName`)}function a(t){return t===58?n(t):t===91?e.attempt(Kj,o,o)(t):o(t)}function o(t){return t===123?e.attempt(qj,s,s)(t):s(t)}function s(n){return e.exit(`directiveText`),t(n)}}function Xj(e,t,n){return kj(e,t,n,`directiveTextLabel`,`directiveTextLabelMarker`,`directiveTextLabelString`)}function Zj(e,t,n){return Oj(e,t,n,`directiveTextAttributes`,`directiveTextAttributesMarker`,`directiveTextAttribute`,`directiveTextAttributeId`,`directiveTextAttributeClass`,`directiveTextAttributeName`,`directiveTextAttributeInitializerMarker`,`directiveTextAttributeValueLiteral`,`directiveTextAttributeValue`,`directiveTextAttributeValueMarker`,`directiveTextAttributeValueData`)}function Qj(){return{text:{58:Gj},flow:{58:[jj,zj]}}}function $j(){let e=this.data(),t=e.micromarkExtensions||=[],n=e.fromMarkdownExtensions||=[],r=e.toMarkdownExtensions||=[];t.push(Qj()),n.push(lj()),r.push(uj())}var eM=n(o(),1),tM=/```([^\r\n`]*)\r?\n?([\s\S]*?)```|`([^`\r\n]+)`/g,nM=/\$\[[^\]\r\n]+\]|\$[A-Za-z0-9][\w.-]*/g,rM=`skill://`,iM=`mention://`;function aM(e,t){return`[${fM(e,`[]`)}](${fM(t,`()`)})`}function oM(e){let t=[],n=0;for(let r of e.matchAll(tM)){let i=r.index;i>n&&t.push(...sM(e.slice(n,i),n));let a=r[0],o=i+a.length,s=r[2];s===void 0?t.push({kind:`inline-code`,source:a,start:i,end:o,value:r[3]??``}):t.push({kind:`code-block`,source:a,start:i,end:o,language:r[1]??``,value:s}),n=o}return n<e.length&&t.push(...sM(e.slice(n),n)),t}function sM(e,t){let n=[],r=dM(e),i=0;for(let a of r)a.start>i&&n.push(...lM(e.slice(i,a.start),t+i)),n.push(cM(a,e,t)),i=a.end;return i<e.length&&n.push(...lM(e.slice(i),t+i)),n}function cM(e,t,n){let r=n+e.start,i=n+e.end,a=t.slice(e.start,e.end);if(e.href.startsWith(iM)){let t=e.href.slice(10);if(t)return{kind:`mention`,source:a,start:r,end:i,label:e.label,href:e.href,name:t}}if(e.label.startsWith(`$`)&&e.href.startsWith(rM)){let t=e.label.slice(1),n=e.href.slice(8);if(t&&n)return{kind:`skill-link`,source:a,start:r,end:i,label:e.label,href:e.href,name:t,skillId:n}}return{kind:`link`,source:a,start:r,end:i,label:e.label,href:e.href}}function lM(e,t){let n=[],r=0;for(let i of e.matchAll(nM)){let a=i.index,o=e[a-1];if(o&&/[\w$]/.test(o))continue;a>r&&n.push(uM(e.slice(r,a),t+r));let s=i[0],c=t+a;n.push({kind:`standalone-skill`,source:s,start:c,end:c+s.length,name:s.startsWith(`$[`)?s.slice(2,-1):s.slice(1)}),r=a+s.length}return r<e.length&&n.push(uM(e.slice(r),t+r)),n}function uM(e,t){return{kind:`text`,source:e,start:t,end:t+e.length,value:e}}function dM(e){let t=[];for(let n=0;n<e.length;n+=1){if(e[n]!==`[`)continue;let r=pM(e,n+1,`]`);if(!r||e[r.end+1]!==`(`)continue;let i=mM(e,r.end+2);i&&(t.push({label:r.value,href:i.value,start:n,end:i.end+1}),n=i.end)}return t}function fM(e,t){let n=``;for(let r of e)n+=r===`\\`||t.includes(r)?`\\${r}`:r;return n}function pM(e,t,n){let r=``;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){r+=e[i+1],i+=1;continue}if(t===n)return{value:r,end:i};r+=t}return null}function mM(e,t){let n=``,r=0;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){n+=e[i+1],i+=1;continue}if(t===`(`){r+=1,n+=t;continue}if(t===`)`){if(r===0)return{value:n,end:i};--r,n+=t;continue}n+=t}return null}var hM=O(),gM=Object.defineProperty,_M=(e,t)=>{let n={};for(var r in e)gM(n,r,{get:e[r],enumerable:!0});return t||gM(n,Symbol.toStringTag,{value:`Module`}),n};function vM(e){this.content=e}vM.prototype={constructor:vM,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new vM(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new vM(n)},addToStart:function(e,t){return new vM([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new vM(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new vM(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=vM.from(e),e.size?new vM(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=vM.from(e),e.size?new vM(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=vM.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},vM.from=function(e){if(e instanceof vM)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new vM(t)};function yM(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&SM(e.charCodeAt(r-1))&&xM(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=yM(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function bM(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&SM(e.charCodeAt(i-1))&&xM(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=bM(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function xM(e){return e>=56320&&e<57344}function SM(e){return e>=55296&&e<56320}var G=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return yM(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return bM(this,e,t,n)}findIndex(e){if(e==0)return wM(0,e);if(e==this.size)return wM(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?wM(t+1,i):wM(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};G.empty=new G([],0);var CM={index:0,offset:0};function wM(e,t){return CM.index=e,CM.offset=t,CM}function TM(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!TM(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!TM(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var EM=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&TM(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};EM.none=[];var DM=class extends Error{},K=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=kM(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(OM(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(G.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};K.empty=new K(G.empty,0,0);function OM(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(OM(a.content,t-i-1,n-i-1)))}function kM(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=kM(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function AM(e,t,n){if(n.openStart>e.depth)throw new DM(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new DM(`Inconsistent open depths`);return jM(e,t,n,0)}function jM(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=jM(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return IM(a,RM(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return IM(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=zM(n,e);return IM(a,LM(e,i,o,t,r))}}function MM(e,t){if(!t.type.compatibleContent(e.type))throw new DM(`Cannot join `+t.type.name+` onto `+e.type.name)}function NM(e,t,n){let r=e.node(n);return MM(r,t.node(n)),r}function PM(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function FM(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(PM(e.nodeAfter,r),a++));for(let e=a;e<o;e++)PM(i.child(e),r);t&&t.depth==n&&t.textOffset&&PM(t.nodeBefore,r)}function IM(e,t){if(!e.type.validContent(t))throw new DM(`Invalid content for node `+e.type.name);return e.copy(t)}function LM(e,t,n,r,i){let a=e.depth>i&&NM(e,t,i+1),o=r.depth>i&&NM(n,r,i+1),s=[];return FM(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(MM(a,o),PM(IM(a,LM(e,t,n,r,i+1)),s)):(a&&PM(IM(a,RM(e,t,i+1)),s),FM(t,n,i,s),o&&PM(IM(o,RM(n,r,i+1)),s)),FM(r,null,i,s),new G(s)}function RM(e,t,n){let r=[];return FM(null,e,n,r),e.depth>n&&PM(IM(NM(e,t,n+1),RM(e,t,n+1)),r),FM(t,null,n,r),new G(r)}function zM(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(G.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var BM=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return EM.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new WM(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=UM.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else UM.set(t,r=new VM);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%HM,i}},VM=class{constructor(){this.elts=[],this.i=0}},HM=12,UM=new WeakMap,WM=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},GM=Object.create(null),KM=class e{constructor(e,t,n,r=EM.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||G.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&TM(this.attrs,t||e.defaultAttrs||GM)&&EM.sameSet(this.marks,n||EM.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return K.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new K(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return AM(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return BM.resolveCached(this,e)}resolveNoCache(e){return BM.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),JM(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=G.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=EM.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!EM.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=G.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};KM.prototype.text=void 0;var qM=class e extends KM{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):JM(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function JM(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var YM=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new XM(t,n);if(r.next==null)return e.empty;let i=ZM(r);r.next&&r.err(`Unexpected trailing text`);let a=sN(iN(i));return cN(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return G.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
184
184
  `)}};YM.empty=new YM(!0);var XM=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function ZM(e){let t=[];do t.push(QM(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function QM(e){let t=[];do t.push($M(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function $M(e){let t=rN(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=tN(e,t);else break;return t}function eN(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function tN(e,t){let n=eN(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:eN(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function nN(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function rN(e){if(e.eat(`(`)){let t=ZM(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=nN(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function iN(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function aN(e,t){return t-e}function oN(e,t){let n=[];return r(t),n.sort(aN);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function sN(e){let t=Object.create(null);return n(oN(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);oN(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new YM(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(aN);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function cN(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function lN(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function uN(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function dN(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function fN(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new hN(e,r,t[r]);return n}var pN=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=fN(e,n.attrs),this.defaultAttrs=lN(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==YM.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:uN(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new KM(this,this.computeAttrs(e),G.from(t),EM.setFrom(n))}createChecked(e=null,t,n){return t=G.from(t),this.checkContent(t),new KM(this,this.computeAttrs(e),t,EM.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=G.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(G.empty,!0);return i?new KM(this,e,t.append(i),EM.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){dN(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:EM.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function mN(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var hN=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?mN(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},gN=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=fN(e,r.attrs),this.excluded=null;let i=lN(this.attrs);this.instance=i?new EM(this,i):null}create(e=null){return!e&&this.instance?this.instance:new EM(this,uN(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){dN(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},_N=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=vM.from(e.nodes),t.marks=vM.from(e.marks||{}),this.nodes=pN.compile(this.spec.nodes,this),this.marks=gN.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=YM.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?vN(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:vN(this,n.split(` `))}this.nodeFromJSON=e=>KM.fromJSON(this,e),this.markFromJSON=e=>EM.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof pN))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new qM(n,n.defaultAttrs,e,EM.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function vN(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function yN(e){return e.tag!=null}function bN(e){return e.style!=null}var xN=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(yN(e))this.tags.push(e);else if(bN(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new AN(this,t,!1);return n.addAll(e,EM.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new AN(this,t,!0);return n.addAll(e,EM.none,t.from,t.to),K.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(MN(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=NN(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=NN(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},SN={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},CN={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},wN={ol:!0,ul:!0},TN=1,EN=2,DN=4;function ON(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?TN:0)|(t===`full`?EN:0)}var kN=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=EM.none,this.match=i||(a&DN?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(G.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&TN)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=G.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(G.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!SN.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},AN=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=ON(null,t.preserveWhitespace,0)|(n?DN:0);i=r?new kN(r.type,r.attrs,EM.none,!0,t.topMatch||r.type.contentMatch,a):n?new kN(null,null,EM.none,!0,null,a):new kN(e.schema.topNodeType,null,EM.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&EN?`full`:this.localPreserveWS||(r.options&TN)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
185
185
  `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;wN.hasOwnProperty(a)&&this.parser.normalizeLists&&jN(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:CN.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(SN.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
186
186
  `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=EM.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):PN(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=ON(e,i,a.options);a.options&DN&&a.content.length==0&&(o|=DN);let s=EM.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):PN(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new kN(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=TN);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function jN(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&wN.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function MN(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function NN(e){let t={};for(let n in e)t[n]=e[n];return t}function PN(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var FN=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=LN(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return LN(t).createTextNode(e.text);let{dom:n,contentDOM:r}=VN(LN(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&VN(LN(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:VN(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=IN(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return IN(e.marks)}};function IN(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function LN(e){return e.document||window.document}var RN=new WeakMap;function zN(e){let t=RN.get(e);return t===void 0&&RN.set(e,t=BN(e)),t}function BN(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function VN(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=zN(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=VN(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var HN=65535,UN=2**16;function WN(e,t){return e+t*UN}function GN(e){return e&HN}function KN(e){return(e-(e&HN))/UN}var qN=1,JN=2,YN=4,XN=8,ZN=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&XN)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&YN)>0}},QN=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=GN(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+KN(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:WN(o/3,e-s),f=e==s?JN:e==u?qN:YN;return(t<0?e!=s:e!=u)&&(f|=XN),new ZN(a,f,d)}r+=l-c}return n?e+r:new ZN(e+r,0,null)}touches(e,t){let n=0,r=GN(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};QN.empty=new QN([]);var $N=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new ZN(e,r,null)}},eP=Object.create(null),tP=class{getMap(){return QN.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=eP[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in eP)throw RangeError(`Duplicate use of step JSON ID `+e);return eP[e]=t,t.prototype.jsonID=e,t}},nP=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof DM)return e.fail(t.message);throw t}}};function rP(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(rP(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return G.fromArray(r)}var iP=class e extends tP{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new K(rP(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return nP.fromReplace(e,this.from,this.to,i)}invert(){return new aP(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};tP.jsonID(`addMark`,iP);var aP=class e extends tP{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new K(rP(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return nP.fromReplace(e,this.from,this.to,n)}invert(){return new iP(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};tP.jsonID(`removeMark`,aP);var oP=class e extends tP{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return nP.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return nP.fromReplace(e,this.pos,this.pos+1,new K(G.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new sP(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};tP.jsonID(`addNodeMark`,oP);var sP=class e extends tP{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return nP.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return nP.fromReplace(e,this.pos,this.pos+1,new K(G.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new oP(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};tP.jsonID(`removeNodeMark`,sP);var cP=class e extends tP{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&uP(e,this.from,this.to)?nP.fail(`Structure replace would overwrite content`):nP.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new QN([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?K.empty:new K(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?K.empty:new K(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,K.fromJSON(t,n.slice),!!n.structure)}};cP.MAP_BIAS=1,tP.jsonID(`replace`,cP);var lP=class e extends tP{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(uP(e,this.from,this.gapFrom)||uP(e,this.gapTo,this.to)))return nP.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return nP.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?nP.fromReplace(e,this.from,this.to,n):nP.fail(`Content does not fit in gap`)}getMap(){return new QN([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,K.fromJSON(t,n.slice),n.insert,!!n.structure)}};tP.jsonID(`replaceAround`,lP);function uP(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function dP(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new aP(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new iP(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function fP(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof gN){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new aP(t.from,t.to,t.style)))}function pP(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new cP(s,l,K.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new aP(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new K(G.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new cP(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(G.empty,!0);e.replace(s,s,new K(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function mP(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function hP(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!mP(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function gP(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=G.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=G.from(r.node(e).copy(u)),d++):c--;let f=G.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=G.from(i.node(e).copy(f)),p++):l++;e.step(new lP(c,l,o,s,new K(u.append(f),d,p),u.size-d,!0))}function _P(e,t,n=null,r=e){let i=yP(e,t),a=i&&bP(r,t);return a?i.map(vP).concat({type:t,attrs:n}).concat(a.map(vP)):null}function vP(e){return{type:e,attrs:null}}function yP(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function bP(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function xP(e,t,n){let r=G.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=G.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new lP(i,a,i,a,new K(r,0,0),n.length,!0))}function SP(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&TP(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&wP(e,t,n,a),pP(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new lP(c,l,c+1,l-1,new K(G.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&CP(e,t,n,a),!1}})}function CP(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function wP(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
@@ -274,7 +274,7 @@ img.ProseMirror-separator {
274
274
  `,Kq=`️`,qq=`‍`,Jq=``,Yq=null,Xq=null;function Zq(e=[]){let t={};PK.groups=t;let n=new PK;Yq??=tJ(yK),Xq??=tJ(bK),$(n,`'`,fq),$(n,`{`,YK),$(n,`}`,XK),$(n,`[`,ZK),$(n,`]`,QK),$(n,`(`,$K),$(n,`)`,eq),$(n,`<`,tq),$(n,`>`,nq),$(n,`(`,rq),$(n,`)`,iq),$(n,`「`,aq),$(n,`」`,oq),$(n,`『`,sq),$(n,`』`,cq),$(n,`<`,lq),$(n,`>`,uq),$(n,`&`,dq),$(n,`*`,pq),$(n,`@`,mq),$(n,"`",gq),$(n,`^`,_q),$(n,`:`,vq),$(n,`,`,yq),$(n,`$`,bq),$(n,`.`,xq),$(n,`=`,Sq),$(n,`!`,Cq),$(n,`-`,wq),$(n,`%`,Tq),$(n,`|`,Eq),$(n,`+`,Dq),$(n,`#`,Oq),$(n,`?`,kq),$(n,`"`,Aq),$(n,`/`,Nq),$(n,`;`,Mq),$(n,`~`,Pq),$(n,`_`,Fq),$(n,`\\`,hq),$(n,`・`,jq);let r=FK(n,Hq,KK,{[xK]:!0});FK(r,Hq,r);let i=FK(r,zq,zK,{[wK]:!0}),a=FK(r,Bq,BK,{[TK]:!0}),o=FK(n,zq,LK,{[SK]:!0});FK(o,Hq,i),FK(o,zq,o),FK(i,Hq,i),FK(i,zq,i);let s=FK(n,Bq,RK,{[CK]:!0});FK(s,zq),FK(s,Hq,a),FK(s,Bq,s),FK(a,Hq,a),FK(a,zq),FK(a,Bq,a);let c=$(n,Gq,JK,{[AK]:!0}),l=$(n,Wq,qK,{[AK]:!0}),u=FK(n,Uq,qK,{[AK]:!0});$(n,Jq,u),$(l,Gq,c),$(l,Jq,u),FK(l,Uq,u),$(u,Wq),$(u,Gq),FK(u,Uq,u),$(u,Jq,u);let d=FK(n,Vq,Iq,{[DK]:!0});$(d,`#`),FK(d,Vq,d),$(d,Kq,d);let f=$(d,qq);$(f,`#`),FK(f,Vq,d);let p=[[zq,o],[Hq,i]],m=[[zq,null],[Bq,s],[Hq,a]];for(let e=0;e<Yq.length;e++)eJ(n,Yq[e],HK,LK,p);for(let e=0;e<Xq.length;e++)eJ(n,Xq[e],UK,RK,m);MK(HK,{tld:!0,ascii:!0},t),MK(UK,{utld:!0,alpha:!0},t),eJ(n,`file`,WK,LK,p),eJ(n,`mailto`,WK,LK,p),eJ(n,`http`,GK,LK,p),eJ(n,`https`,GK,LK,p),eJ(n,`ftp`,GK,LK,p),eJ(n,`ftps`,GK,LK,p),MK(WK,{scheme:!0,ascii:!0},t),MK(GK,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[OK]:!0}:{[kK]:!0};r.indexOf(`-`)>=0?i[EK]=!0:zq.test(r)?Hq.test(r)?i[wK]=!0:i[SK]=!0:i[xK]=!0,IK(n,r,r,i)}return IK(n,`localhost`,VK,{ascii:!0}),n.jd=new PK(Lq),{start:n,tokens:Object.assign({groups:t},Rq)}}function Qq(e,t){let n=$q(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function $q(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function eJ(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new PK(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new PK(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function tJ(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var nJ={defaultProtocol:`http`,events:null,format:iJ,formatHref:iJ,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function rJ(e,t=null){let n=Object.assign({},nJ);e&&(n=Object.assign(n,e instanceof rJ?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}rJ.prototype={o:nJ,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:nJ[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function iJ(e){return e}function aJ(e,t){this.t=`token`,this.v=e,this.tk=t}aJ.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=nJ.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function oJ(e,t){class n extends aJ{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var sJ=oJ(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),cJ=oJ(`text`),lJ=oJ(`nl`),uJ=oJ(`url`,{isLink:!0,toHref(e=nJ.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==VK&&e[1].t===vq}}),dJ=e=>new PK(e);function fJ({groups:e}){let t=e.domain.concat([dq,pq,mq,hq,gq,_q,bq,Sq,wq,KK,Tq,Eq,Dq,Oq,Nq,Lq,Pq,Fq]),n=[fq,vq,yq,xq,Cq,Tq,kq,Aq,Mq,tq,nq,YK,XK,QK,ZK,$K,eq,rq,iq,aq,oq,sq,cq,lq,uq],r=[dq,fq,pq,hq,gq,_q,bq,Sq,wq,YK,XK,Tq,Eq,Dq,Oq,kq,Nq,Lq,Pq,Fq],i=dJ(),a=$(i,Pq);Q(a,r,a),Q(a,e.domain,a);let o=dJ(),s=dJ(),c=dJ();Q(i,e.domain,o),Q(i,e.scheme,s),Q(i,e.slashscheme,c),Q(o,r,a),Q(o,e.domain,o);let l=$(o,mq);$(a,mq,l),$(s,mq,l),$(c,mq,l);let u=$(a,xq);Q(u,r,a),Q(u,e.domain,a);let d=dJ();Q(l,e.domain,d),Q(d,e.domain,d);let f=$(d,xq);Q(f,e.domain,d);let p=dJ(sJ);Q(f,e.tld,p),Q(f,e.utld,p),$(l,VK,p);let m=$(d,wq);$(m,wq,m),Q(m,e.domain,d),Q(p,e.domain,d),$(p,xq,f),$(p,wq,m);let h=$(o,wq),g=$(o,xq);$(h,wq,h),Q(h,e.domain,o),Q(g,r,a),Q(g,e.domain,o);let _=dJ(uJ);Q(g,e.tld,_),Q(g,e.utld,_),Q(_,e.domain,o),Q(_,r,a),$(_,xq,g),$(_,wq,h),$(_,mq,l);let v=$(_,vq),y=dJ(uJ);Q(v,e.numeric,y);let b=dJ(uJ),x=dJ();Q(b,t,b),Q(b,n,x),Q(x,t,b),Q(x,n,x),$(_,Nq,b),$(y,Nq,b);let S=$(s,vq),C=$($($(c,vq),Nq),Nq);Q(s,e.domain,o),$(s,xq,g),$(s,wq,h),Q(c,e.domain,o),$(c,xq,g),$(c,wq,h),Q(S,e.domain,b),$(S,Nq,b),$(S,kq,b),Q(C,e.domain,b),Q(C,t,b),$(C,Nq,b);let w=[[YK,XK],[ZK,QK],[$K,eq],[tq,nq],[rq,iq],[aq,oq],[sq,cq],[lq,uq]];for(let e=0;e<w.length;e++){let[r,i]=w[e],a=$(b,r);$(x,r,a);let o=dJ(uJ);Q(a,t,o);let s=dJ();Q(a,n,s),$(a,i,b),Q(o,t,o),Q(o,n,s),Q(s,t,o),Q(s,n,s),$(o,i,b),$(s,i,b)}return $(i,VK,_),$(i,JK,lJ),{start:i,tokens:Rq}}function pJ(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(mJ(cJ,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(mJ(e,t,r))}}return o.length>0&&a.push(mJ(cJ,t,o)),a}function mJ(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var hJ=typeof console<`u`&&console&&console.warn||(()=>{}),gJ=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,_J={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function vJ(){return PK.groups={},_J.scanner=null,_J.parser=null,_J.tokenQueue=[],_J.pluginQueue=[],_J.customSchemes=[],_J.initialized=!1,_J}function yJ(e,t=!1){if(_J.initialized&&hJ(`linkifyjs: already initialized - will not register custom scheme "${e}" ${gJ}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
275
275
  1. Must only contain digits, lowercase ASCII letters or "-"
276
276
  2. Cannot start or end with "-"
277
- 3. "-" cannot repeat`);_J.customSchemes.push([e,t])}function bJ(){_J.scanner=Zq(_J.customSchemes);for(let e=0;e<_J.tokenQueue.length;e++)_J.tokenQueue[e][1]({scanner:_J.scanner});_J.parser=fJ(_J.scanner.tokens);for(let e=0;e<_J.pluginQueue.length;e++)_J.pluginQueue[e][1]({scanner:_J.scanner,parser:_J.parser});return _J.initialized=!0,_J}function xJ(e){return _J.initialized||bJ(),pJ(_J.parser.start,e,Qq(_J.scanner.start,e))}xJ.scan=Qq;function SJ(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new rJ(n),i=xJ(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var CJ=`[\0- \xA0 ᠎ -\u2029  ]`,wJ=new RegExp(CJ),TJ=RegExp(`${CJ}$`),EJ=new RegExp(CJ,`g`);function DJ(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function OJ(e){return new xF({key:new wF(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(KH(_H(n.doc,[...t])).forEach(({newRange:t})=>{let n=vH(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!TJ.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(wJ).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=xJ(n).map(t=>t.toObject(e.defaultProtocol));if(!DJ(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{qH(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function kJ(e){return new xF({key:new wF(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=UH(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var AJ=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,jJ=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function MJ(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function NJ(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&MJ(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function PJ(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||MJ(e,t.index??0)||NJ(e,t.index??0)?!1:!!r.trim()&&n(i)}function FJ(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function IJ(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function LJ(e){return{href:e.data?.href,title:e.data?.title??null}}function RJ(e){let t=YW({find:t=>{let n=AJ.exec(t);return!n||!PJ(t,n,e.isAllowedHref)?null:FJ(n)},type:e.type,getAttributes:LJ});return new yW({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function zJ(e){let t=eG({find:t=>{let n=[];for(let r of t.matchAll(jJ))PJ(t,r,e.isAllowedHref)&&n.push(FJ(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>IJ(t,e)));return[...n,...r]},type:e.type,getAttributes:LJ});return new TW({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function BJ(e){return new xF({key:new wF(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=SJ(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function VJ(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(EJ,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var HJ=wW.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){yJ(e);return}yJ(e.scheme,e.optionalSlashes)})},onDestroy(){vJ()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!VJ(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,kH(this.options.HTMLAttributes,e),0]:[`a`,kH(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[RJ({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;SJ(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!VJ(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[zJ({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[eG({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(OJ({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!VJ(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(kJ({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(BJ({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),UJ=HJ;function WJ(e={}){return new xF({view(t){return new GJ(t,e)}})}var GJ=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=FP(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},KJ=class e extends q{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):q.near(r)}content(){return K.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new qJ(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!YJ(e)||!XJ(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Y.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};KJ.prototype.visible=!1,KJ.findFrom=KJ.findGapCursorFrom,q.jsonID(`gapcursor`,KJ);var qJ=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return KJ.valid(t)?new KJ(t):q.near(t)}};function JJ(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function YJ(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||JJ(e.type))return!0;if(e.inlineContent)return!1}}return!0}function XJ(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||JJ(e.type))return!0;if(e.inlineContent)return!1}}return!0}function ZJ(){return new xF({props:{decorations:nY,createSelectionBetween(e,t,n){return t.pos==n.pos&&KJ.valid(n)?new KJ(n):null},handleClick:eY,handleKeyDown:QJ,handleDOMEvents:{beforeinput:tY}}})}var QJ=ZB({ArrowLeft:$J(`horiz`,-1),ArrowRight:$J(`horiz`,1),ArrowUp:$J(`vert`,-1),ArrowDown:$J(`vert`,1)});function $J(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof J){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=KJ.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new KJ(c))),!0):!1}}function eY(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!KJ.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Y.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new KJ(r))),!0)}function tY(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof KJ))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=G.empty;for(let e=r.length-1;e>=0;e--)i=G.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new K(i,0,0));return a.setSelection(J.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function nY(e){if(!(e.selection instanceof KJ))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,Zz.create(e.doc,[Jz.widget(e.selection.head,t,{key:`gapcursor`})])}var rY=200,iY=function(){};iY.prototype.append=function(e){return e.length?(e=iY.from(e),!this.length&&e||e.length<rY&&this.leafAppend(e)||this.length<rY&&e.leafPrepend(this)||this.appendInner(e)):this},iY.prototype.prepend=function(e){return e.length?iY.from(e).append(this):this},iY.prototype.appendInner=function(e){return new oY(this,e)},iY.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?iY.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},iY.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},iY.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},iY.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},iY.from=function(e){return e instanceof iY?e:e&&e.length?new aY(e):iY.empty};var aY=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=rY)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=rY)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(iY);iY.empty=new aY([]);var oY=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(iY),sY=500,cY=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new uY(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new uY(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new uY(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>fY&&(s=lY(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new $N;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new uY(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new uY(i,o,l))}else r.push(new uY(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new uY(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>sY&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new uY(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(iY.from(i.reverse()),a)}};cY.empty=new cY(iY.empty,0);function lY(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var uY=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},dY=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},fY=20;function pY(e,t,n,r){let i=n.getMeta(xY),a;if(i)return i.historyState;n.getMeta(SY)&&(e=new dY(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(xY))return o.getMeta(xY).redo?new dY(e.done.addTransform(n,void 0,r,bY(t)),e.undone,hY(n.mapping.maps),e.prevTime,e.prevComposition):new dY(e.done,e.undone.addTransform(n,void 0,r,bY(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!mY(n,e.prevRanges)),s=o?gY(e.prevRanges,n.mapping):hY(n.mapping.maps);return new dY(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,bY(t)),cY.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new dY(e.done.rebased(n,a),e.undone.rebased(n,a),gY(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new dY(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),gY(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function mY(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function hY(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function gY(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function _Y(e,t,n){let r=bY(t),i=xY.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new dY(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(xY,{redo:n,historyState:c})}var vY=!1,yY=null;function bY(e){let t=e.plugins;if(yY!=t){vY=!1,yY=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){vY=!0;break}}return vY}var xY=new wF(`history`),SY=new wF(`closeHistory`);function CY(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new xF({key:xY,state:{init(){return new dY(cY.empty,cY.empty,null,0,-1)},apply(t,n,r){return pY(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?TY:n==`historyRedo`?EY:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function wY(e,t){return(n,r)=>{let i=xY.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=_Y(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var TY=wY(!1,!0),EY=wY(!0,!0);MW.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new xF({key:new wF(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var DY=MW.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[WJ(this.options)]}});MW.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new xF({key:new wF(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return Zz.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(Jz.node(t,t+e.nodeSize,{class:this.options.className}))}),Zz.create(e,a)}}})]}});var OY=MW.create({name:`gapCursor`,addProseMirrorPlugins(){return[ZJ()]},extendNodeSchema(e){return{allowGapCursor:Z(X(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),kY=`placeholder`,AY=new wF(`tiptap__placeholder`);function jY(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),Jz.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function MY(e,t){return typeof e==`function`?e(t):e}function NY({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&aU(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(jY({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:MY(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function PY({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&aU(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(jY({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:MY(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...NY({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return Zz.create(r,o)}function FY(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function IY(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function LY(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function RY(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function zY(e,t){let n=LY(e,t.from,t.to);return n.push(IY(e,FY(e,t.from))),t.to>t.from?n.push(IY(e,FY(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(IY(e,FY(e,Math.min(t.from+1,e.content.size)))),n}function BY(e,t,n){let r=[];if(e.docChanged){let t=KH(e);for(let e of t)r.push(...zY(n.doc,e.newRange))}return e.selectionSet&&(r.push(IY(n.doc,FY(n.doc,e.mapping.map(t.selection.anchor)))),r.push(IY(n.doc,FY(n.doc,n.selection.anchor)))),RY(r)}function see(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function VY({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=see(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=NY({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function HY({editor:e,options:t,dataAttribute:n}){return{init(r,i){return PY({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??Zz.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:VY({decorations:i.map(r.mapping,r.doc),ranges:BY(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function UY(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function WY({editor:e,options:t}){let n=t.dataAttribute?`data-${UY(t.dataAttribute)}`:`data-${kY}`,r=t.showOnlyCurrent&&!t.includeChildren;return new xF({key:AY,...r?{}:{state:HY({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>PY({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?Zz.empty:AY.getState(n)??Zz.empty}})}var GY=MW.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:kY,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[WY({editor:this.editor,options:this.options})]}});function KY(e,t){return!e.selection.empty&&!oU(e.selection)&&t.isEditable}function qY(e,t){return KY(e,t)&&!t.isFocused&&!t.view.dragging}function JY(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function YY(e){e.focus()}MW.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new xF({key:new wF(`selection`),props:{decorations(n){return qY(n,e)?Zz.create(n.doc,[Jz.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return KY(t.state,e)&&JY(),!1},focus(t){return KY(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&YY(t)}),!1}}}})]}});function XY({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var ZY=MW.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new wF(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new xF({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!XY({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!XY({node:r,types:n})}}})]}}),QY=MW.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>TY(e,t),redo:()=>({state:e,dispatch:t})=>EY(e,t)}},addProseMirrorPlugins(){return[CY(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),$Y=new WeakSet,eX=new WeakSet;function tX(e){let t=e;return $Y.add(t),t}function nX(e){return Array.isArray(e)&&$Y.has(e)}function rX(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&eX.has(e)&&!nX(e)?rX(e):[e])}function iX(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!nX(n)&&!eX.has(n)?tX(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(nX(n))return tX([e,r,n]);if(n.length===0)return tX([e,r]);let t=rX(n);return t.length===0?tX([e,r]):tX([e,r,...t])}return tX(n==null?[e,r]:[e,r,n])}var aX=(e,t)=>iX(e,t),oX=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new K(n,0,0);return e.replace(l,i.after(),r),e.setSelection(J.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},sX=/^\s*>\s$/,cX=$W.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return aX(`blockquote`,{...kH(this.options.HTMLAttributes,e),children:aX(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
277
+ 3. "-" cannot repeat`);_J.customSchemes.push([e,t])}function bJ(){_J.scanner=Zq(_J.customSchemes);for(let e=0;e<_J.tokenQueue.length;e++)_J.tokenQueue[e][1]({scanner:_J.scanner});_J.parser=fJ(_J.scanner.tokens);for(let e=0;e<_J.pluginQueue.length;e++)_J.pluginQueue[e][1]({scanner:_J.scanner,parser:_J.parser});return _J.initialized=!0,_J}function xJ(e){return _J.initialized||bJ(),pJ(_J.parser.start,e,Qq(_J.scanner.start,e))}xJ.scan=Qq;function SJ(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new rJ(n),i=xJ(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var CJ=`[\0- \xA0 ᠎ -\u2029  ]`,wJ=new RegExp(CJ),TJ=RegExp(`${CJ}$`),EJ=new RegExp(CJ,`g`);function DJ(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function OJ(e){return new xF({key:new wF(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(KH(_H(n.doc,[...t])).forEach(({newRange:t})=>{let n=vH(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!TJ.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(wJ).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=xJ(n).map(t=>t.toObject(e.defaultProtocol));if(!DJ(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{qH(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function kJ(e){return new xF({key:new wF(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=UH(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var AJ=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,jJ=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function MJ(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function NJ(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&MJ(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function PJ(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||MJ(e,t.index??0)||NJ(e,t.index??0)?!1:!!r.trim()&&n(i)}function FJ(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function IJ(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function LJ(e){return{href:e.data?.href,title:e.data?.title??null}}function RJ(e){let t=YW({find:t=>{let n=AJ.exec(t);return!n||!PJ(t,n,e.isAllowedHref)?null:FJ(n)},type:e.type,getAttributes:LJ});return new yW({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function zJ(e){let t=eG({find:t=>{let n=[];for(let r of t.matchAll(jJ))PJ(t,r,e.isAllowedHref)&&n.push(FJ(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>IJ(t,e)));return[...n,...r]},type:e.type,getAttributes:LJ});return new TW({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function BJ(e){return new xF({key:new wF(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=SJ(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function VJ(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(EJ,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var HJ=wW.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){yJ(e);return}yJ(e.scheme,e.optionalSlashes)})},onDestroy(){vJ()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!VJ(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,kH(this.options.HTMLAttributes,e),0]:[`a`,kH(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[RJ({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;SJ(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!VJ(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[zJ({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!VJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[eG({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(OJ({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!VJ(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(kJ({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(BJ({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),UJ=HJ;function WJ(e={}){return new xF({view(t){return new GJ(t,e)}})}var GJ=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=FP(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},KJ=class e extends q{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):q.near(r)}content(){return K.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new qJ(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!YJ(e)||!XJ(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Y.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};KJ.prototype.visible=!1,KJ.findFrom=KJ.findGapCursorFrom,q.jsonID(`gapcursor`,KJ);var qJ=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return KJ.valid(t)?new KJ(t):q.near(t)}};function JJ(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function YJ(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||JJ(e.type))return!0;if(e.inlineContent)return!1}}return!0}function XJ(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||JJ(e.type))return!0;if(e.inlineContent)return!1}}return!0}function ZJ(){return new xF({props:{decorations:nY,createSelectionBetween(e,t,n){return t.pos==n.pos&&KJ.valid(n)?new KJ(n):null},handleClick:eY,handleKeyDown:QJ,handleDOMEvents:{beforeinput:tY}}})}var QJ=ZB({ArrowLeft:$J(`horiz`,-1),ArrowRight:$J(`horiz`,1),ArrowUp:$J(`vert`,-1),ArrowDown:$J(`vert`,1)});function $J(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof J){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=KJ.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new KJ(c))),!0):!1}}function eY(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!KJ.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Y.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new KJ(r))),!0)}function tY(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof KJ))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=G.empty;for(let e=r.length-1;e>=0;e--)i=G.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new K(i,0,0));return a.setSelection(J.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function nY(e){if(!(e.selection instanceof KJ))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,Zz.create(e.doc,[Jz.widget(e.selection.head,t,{key:`gapcursor`})])}var rY=200,iY=function(){};iY.prototype.append=function(e){return e.length?(e=iY.from(e),!this.length&&e||e.length<rY&&this.leafAppend(e)||this.length<rY&&e.leafPrepend(this)||this.appendInner(e)):this},iY.prototype.prepend=function(e){return e.length?iY.from(e).append(this):this},iY.prototype.appendInner=function(e){return new oY(this,e)},iY.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?iY.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},iY.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},iY.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},iY.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},iY.from=function(e){return e instanceof iY?e:e&&e.length?new aY(e):iY.empty};var aY=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=rY)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=rY)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(iY);iY.empty=new aY([]);var oY=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(iY),sY=500,cY=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new uY(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new uY(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new uY(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>fY&&(s=lY(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new $N;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new uY(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new uY(i,o,l))}else r.push(new uY(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new uY(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>sY&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new uY(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(iY.from(i.reverse()),a)}};cY.empty=new cY(iY.empty,0);function lY(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var uY=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},dY=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},fY=20;function pY(e,t,n,r){let i=n.getMeta(xY),a;if(i)return i.historyState;n.getMeta(SY)&&(e=new dY(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(xY))return o.getMeta(xY).redo?new dY(e.done.addTransform(n,void 0,r,bY(t)),e.undone,hY(n.mapping.maps),e.prevTime,e.prevComposition):new dY(e.done,e.undone.addTransform(n,void 0,r,bY(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!mY(n,e.prevRanges)),s=o?gY(e.prevRanges,n.mapping):hY(n.mapping.maps);return new dY(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,bY(t)),cY.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new dY(e.done.rebased(n,a),e.undone.rebased(n,a),gY(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new dY(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),gY(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function mY(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function hY(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function gY(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function _Y(e,t,n){let r=bY(t),i=xY.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new dY(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(xY,{redo:n,historyState:c})}var vY=!1,yY=null;function bY(e){let t=e.plugins;if(yY!=t){vY=!1,yY=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){vY=!0;break}}return vY}var xY=new wF(`history`),SY=new wF(`closeHistory`);function CY(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new xF({key:xY,state:{init(){return new dY(cY.empty,cY.empty,null,0,-1)},apply(t,n,r){return pY(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?TY:n==`historyRedo`?EY:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function wY(e,t){return(n,r)=>{let i=xY.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=_Y(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var TY=wY(!1,!0),EY=wY(!0,!0);MW.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new xF({key:new wF(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var DY=MW.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[WJ(this.options)]}});MW.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new xF({key:new wF(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return Zz.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(Jz.node(t,t+e.nodeSize,{class:this.options.className}))}),Zz.create(e,a)}}})]}});var OY=MW.create({name:`gapCursor`,addProseMirrorPlugins(){return[ZJ()]},extendNodeSchema(e){return{allowGapCursor:Z(X(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),kY=`placeholder`,AY=new wF(`tiptap__placeholder`);function jY(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),Jz.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function MY(e,t){return typeof e==`function`?e(t):e}function NY({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&aU(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(jY({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:MY(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function PY({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&aU(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(jY({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:MY(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...NY({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return Zz.create(r,o)}function FY(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function IY(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function LY(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function RY(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function zY(e,t){let n=LY(e,t.from,t.to);return n.push(IY(e,FY(e,t.from))),t.to>t.from?n.push(IY(e,FY(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(IY(e,FY(e,Math.min(t.from+1,e.content.size)))),n}function BY(e,t,n){let r=[];if(e.docChanged){let t=KH(e);for(let e of t)r.push(...zY(n.doc,e.newRange))}return e.selectionSet&&(r.push(IY(n.doc,FY(n.doc,e.mapping.map(t.selection.anchor)))),r.push(IY(n.doc,FY(n.doc,n.selection.anchor)))),RY(r)}function VY(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function see({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=VY(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=NY({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function HY({editor:e,options:t,dataAttribute:n}){return{init(r,i){return PY({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??Zz.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:see({decorations:i.map(r.mapping,r.doc),ranges:BY(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function UY(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function WY({editor:e,options:t}){let n=t.dataAttribute?`data-${UY(t.dataAttribute)}`:`data-${kY}`,r=t.showOnlyCurrent&&!t.includeChildren;return new xF({key:AY,...r?{}:{state:HY({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>PY({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?Zz.empty:AY.getState(n)??Zz.empty}})}var GY=MW.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:kY,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[WY({editor:this.editor,options:this.options})]}});function KY(e,t){return!e.selection.empty&&!oU(e.selection)&&t.isEditable}function qY(e,t){return KY(e,t)&&!t.isFocused&&!t.view.dragging}function JY(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function YY(e){e.focus()}MW.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new xF({key:new wF(`selection`),props:{decorations(n){return qY(n,e)?Zz.create(n.doc,[Jz.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return KY(t.state,e)&&JY(),!1},focus(t){return KY(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&YY(t)}),!1}}}})]}});function XY({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var ZY=MW.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new wF(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new xF({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!XY({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!XY({node:r,types:n})}}})]}}),QY=MW.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>TY(e,t),redo:()=>({state:e,dispatch:t})=>EY(e,t)}},addProseMirrorPlugins(){return[CY(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),$Y=new WeakSet,eX=new WeakSet;function tX(e){let t=e;return $Y.add(t),t}function nX(e){return Array.isArray(e)&&$Y.has(e)}function rX(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&eX.has(e)&&!nX(e)?rX(e):[e])}function iX(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!nX(n)&&!eX.has(n)?tX(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(nX(n))return tX([e,r,n]);if(n.length===0)return tX([e,r]);let t=rX(n);return t.length===0?tX([e,r]):tX([e,r,...t])}return tX(n==null?[e,r]:[e,r,n])}var aX=(e,t)=>iX(e,t),oX=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new K(n,0,0);return e.replace(l,i.after(),r),e.setSelection(J.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},sX=/^\s*>\s$/,cX=$W.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return aX(`blockquote`,{...kH(this.options.HTMLAttributes,e),children:aX(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
278
278
  `).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
279
279
  `))}),n.join(`
280
280
  >
@@ -323,7 +323,7 @@ img.ProseMirror-separator {
323
323
  `:e.type.name===`composerMention`||e.type.name===`composerAtom`?u0(e):null}function l0(e,t,n){if(n<=t)return null;let r=e.state.doc.slice(t,n),i={text:e.state.doc.textBetween(t,n,`
324
324
  `,u0),slice:r.toJSON()};return e.chain().focus().deleteRange({from:t,to:n}).run(),i}function u0(e){return e.type.name===`composerMention`?String(e.attrs.label??``)||`${String(e.attrs.trigger??``)}${String(e.attrs.value??``)}`:e.type.name===`composerAtom`?String(e.attrs.label??``):``}function d0(e,t){let{selection:n}=e.state;if(typeof t==`string`){if(!n.empty){e.chain().focus().deleteSelection().insertContent(t).run();return}e.chain().focus().insertContent(t).run();return}let r=K.fromJSON(e.state.schema,t.slice);e.view.dispatch(e.state.tr.replaceSelection(r).scrollIntoView()),e.view.focus()}function f0(e,t){let{selection:n}=e.state;if(!n.empty)return!1;let r=n.$from,i=t===`Backspace`?r.nodeBefore:r.nodeAfter;if(!i||!p0(i))return!1;let a=t===`Backspace`?n.from-i.nodeSize:n.from,o=t===`Backspace`?n.from:n.from+i.nodeSize;return e.chain().focus().deleteRange({from:a,to:o}).run(),!0}function p0(e){return e.isAtom&&(e.type.name===`composerMention`||e.type.name===`composerAtom`)}function m0(e){try{return e.state.doc.textBetween(0,e.state.selection.from,`
325
325
  `,``).length}catch{return 0}}function h0(e){return e.state.selection.empty&&m0(e)===0}function g0(e,t){return dQ(e.persistedPrompt,t)?`ParseSlash`:e.action}function _0(e){return e.key===`ArrowUp`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`p`}function v0(e){return e.key===`ArrowDown`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`n`}function y0(e){let t=new Map;for(let n of e)t.set(`${n.kind}:${n.range.start}:${n.range.end}:${n.label}`,n);return LQ([...t.values()])}function b0(e){return e.replace(/\r\n?/g,`
326
- `)}function x0(e){return e.startsWith(`file://`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||/^[A-Za-z]:[\\/]/.test(e)}function S0(e){let t=e.trim();if(!t.startsWith(`file://`))return t;let n=URL.parse(t);if(!n)return t;try{return decodeURIComponent(n.pathname)}catch{return n.pathname}}function C0(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??e}function w0(e){return/[\\/]$/.test(e)}function T0(e){return e.split(/\r?\n/).map(e=>e.trim()).find(e=>e&&!e.startsWith(`#`))??``}function E0(e){let t=T0(e);return t?t.match(/^[\w.+-]+\/[\w.+-]+:[^:\n]+:(.+)$/)?.[1]?.trim()??t:``}function D0(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function O0(e){return ZQ(e.trim())}function k0(e){let t=(0,W.c)(3),n=e.draftKey??``,r;return t[0]!==e||t[1]!==n?(r=(0,L.jsx)(j0,{...e},n),t[0]=e,t[1]=n,t[2]=r):r=t[2],r}function A0(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function j0({initialDraft:e,draftKey:t,disabled:n=!1,isTaskRunning:r=!1,queueSubmissions:i=!1,hasInteracted:a=!1,maxExpandedTextChars:o,editorAriaLabel:s=`Rich prompt composer`,className:c,children:l,dictation:u,validateSubmission:d,onSubmit:f,onStateChange:p}){let m=Ve(),h=R$(l),g=(0,I.useRef)({signature:z$(h),slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers}),_=z$(h);_!==g.current.signature&&(g.current={signature:_,slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers});let{slashCommands:v,mentionCandidates:y,commandTriggers:b,mentionTriggers:x}=g.current,S=(0,I.useMemo)(()=>({commandTriggers:b,mentionTriggers:x}),[b,x]),C=(0,I.useRef)(x);C.current=x;let[w]=(0,I.useState)(()=>{if(e)return e;if(t===void 0)return;let n=D$(t);return n?YQ({source:n,slashCommands:v,mentionCandidates:y}):void 0}),T=(0,I.useRef)(w?.remoteImages??[]),E=(0,I.useRef)(v1({state:w,slashCommands:v,mentionCandidates:y,triggers:S})),ee=(0,I.useRef)(0),te=(0,I.useRef)(!0);(0,I.useEffect)(()=>(te.current=!0,()=>{te.current=!1}),[]);let[ne,D]=(0,I.useState)(T.current),[re,O]=(0,I.useState)(null),[ie,k]=(0,I.useState)(()=>C1(E.current,T.current,v,r,i,0)),A=(0,I.useRef)(ie),ae=(0,I.useRef)(ne),oe=(0,I.useRef)(re),se=(0,I.useRef)(null),ce=(0,I.useRef)(null),le=(0,I.useRef)(void 0),j=(0,I.useRef)(null),ue=(0,I.useRef)(null),de=(0,I.useRef)(null),fe=(0,I.useEffectEvent)((e,t)=>{p?.(e,t)}),pe=(0,I.useRef)(d),me=(0,I.useRef)(f),he=(0,I.useRef)(new Map),ge=(0,I.useRef)(()=>null),_e=(0,I.useRef)(()=>void 0),ve=(0,I.useRef)(()=>void 0),ye=(0,I.useRef)(()=>!1),[be,xe]=(0,I.useState)(``),Se=(0,I.useRef)(be);Se.current=be;let M=dK({extensions:(0,I.useMemo)(()=>u1({getPlaceholder:()=>Se.current,getMentionTrigger:()=>C.current[0]??`@`,getRemoteImageCount:()=>ae.current.length,attachImageFile:e=>ge.current(e)}),[]),content:E.current,editable:!n,editorProps:{attributes:{"data-slot":`composer-editor`,role:`textbox`,"aria-label":s,"aria-placeholder":be,"aria-disabled":n?`true`:`false`,dir:`auto`,spellcheck:`false`},handleKeyDown(e,t){return ye.current(t)}},immediatelyRender:!1,onUpdate({editor:e}){_e.current(e),ve.current(e)},onSelectionUpdate({editor:e}){_e.current(e),ve.current(e)}}),Ce=(0,I.useMemo)(()=>re?W$(re,v,y,a):[],[re,a,y,v]),we=(0,I.useMemo)(()=>hQ(ie,v,b),[b,ie,v]);(0,I.useEffect)(()=>{A.current=ie},[ie]),(0,I.useEffect)(()=>{ae.current=ne},[ne]),(0,I.useEffect)(()=>{oe.current=re},[re]),(0,I.useEffect)(()=>{ie.shortcutsOpen&&(re||ie.reverseSearch!==null||!mQ(ie))&&k(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)},[re,ie]),(0,I.useEffect)(()=>{pe.current=d},[d]),(0,I.useEffect)(()=>{me.current=f},[f]),(0,I.useEffect)(()=>{M&&(M.setEditable(!n),n&&O(null))},[n,M]),(0,I.useEffect)(()=>{fe(ie,we),t!==void 0&&(we?O$(t,KQ(ie,we.persistedPrompt)):ee.current===0&&O$(t,null))},[ie,t,we]),(0,I.useEffect)(()=>{k(e=>e.isTaskRunning===r&&e.queueSubmissions===i?e:{...e,isTaskRunning:r,queueSubmissions:i})},[r,i]),_e.current=e=>{if(n)return;let t=C1(e.getJSON(),ae.current,v,r,i,m0(e)),a=ce.current,o=le.current;ce.current=null,le.current=void 0,k(e=>{let n=o===void 0?j.current:o;j.current=n;let r=e.shortcutsOpen&&mQ(t);return{...t,error:e.error,history:e.history,historyCursor:n,killBuffer:e.killBuffer,reverseSearch:e.reverseSearch,shortcutsOpen:r,selectedRemoteImageId:a}})},ve.current=e=>{if(n){O(null);return}let t=F1(e,S);if(!t){O(null);return}if(b.includes(t.trigger)){let e={trigger:t.trigger,query:t.query,selectedIndex:0},n=W$(e,v,y,a);O(t=>n.length===0?null:{...e,selectedIndex:t?.trigger===e.trigger?Math.min(t.selectedIndex,n.length-1):0});return}O(e=>{let n=t.trigger,r={trigger:n,query:t.query,selectedIndex:e?.trigger===n?e.selectedIndex:0},i=W$(r,v,y,a);return{...r,selectedIndex:e?.trigger===n?Math.min(e.selectedIndex,Math.max(i.length-1,0)):0}})};function Te(e){M?.commands.setContent(e),M&&(_e.current(M),ve.current(M))}function Ee(e){if(n||!M)return;let t=F1(M,S),r=[{type:`text`,text:`${e.trigger}${e.value}`,marks:[{type:`composerSlashCommand`,attrs:{value:e.value,detail:e.detail}}]},{type:`text`,text:` `}];t&&t.trigger===e.trigger?M.chain().focus().deleteRange({from:t.from,to:t.to}).insertContent(r).run():M.chain().focus().insertContent(r).run(),O(null)}function De({index:e=oe.current?.selectedIndex??0}={}){let t=oe.current;if(n||!M||!t)return;let r=W$(t,v,y,a),i=r[e]??r[0];if(!i)return;if(!i.atomic){Ee(i);return}let o=F1(M,S),s=o?.trigger===t.trigger,c=M.chain().focus();s&&o&&c.deleteRange({from:o.from,to:o.to}),c.insertContent([j1(i),{type:`text`,text:` `}]).run(),O(null)}function Oe(){if(n||!M)return;M.commands.focus();let e=b[0];e&&O(t=>t?.trigger===e?null:{trigger:e,query:``,selectedIndex:0})}function ke(e){return mQ(e)&&e.reverseSearch===null&&oe.current===null}function Ae(){n||k(e=>ke(e)&&!e.shortcutsOpen?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function je(){k(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)}function Me(){n||k(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:ke(e)?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function Ne(e){n||!M||!e||M.chain().focus().insertContent(e).run()}function Pe(e){if(zQ(e)===null)return k(t=>({...t,error:`Only image, video, or audio files can be attached: ${e.name||`unnamed file`}`,shortcutsOpen:!1})),O(null),null;let t=crypto.randomUUID();return he.current.set(t,e),t}function Fe(e,t){let n=Pe(t);if(n===null)return;let r=qe(),i=r.remoteImages.length+r.imageAttachments.length+1,a=zQ(t)??`image`;e.chain().focus().insertContent([P1(n,VQ(a,i),a),{type:`text`,text:` `}]).run()}function Ie(e){if(!(n||!M))for(let t of e)Fe(M,t)}function N(e){n||!M||(he.current.delete(e),Te(q1(Y1(M.getJSON(),e),ae.current.length)))}function Le(e){if(n||!M)return;let t=[...ae.current,{id:m$(`remote-image`,e,m.Date.now()),url:e}];ae.current=t,D(t),Te(q1(M.getJSON(),t.length))}function Re(e){return n||!M?!1:_1(M.view,e,ae.current.length,x[0]??`@`,Pe)}function ze(e){if(n)return;let t=ae.current[e]??A.current.remoteImages[e];t&&(ce.current=t.id,k(e=>({...e,selectedRemoteImageId:t.id,shortcutsOpen:!1})))}function Be(){n||(ce.current=null,k(e=>e.selectedRemoteImageId?{...e,selectedRemoteImageId:null,shortcutsOpen:!1}:e))}function He(e){return A.current.selectedRemoteImageId?e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`Escape`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`?(Be(),O(null),!0):e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey?(Be(),!0):!1:!1}function Ue(e){if(n)return e.preventDefault(),!0;if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`)return e.preventDefault(),Be(),O(null),M?.commands.selectAll(),!0;let t=qe(),r=A.current.selectedRemoteImageId;if(!oe.current&&e.key===`ArrowUp`){let n=UQ({...t,selectedRemoteImageId:r},r);if(n!==null)return e.preventDefault(),ze(Math.max(0,n-1)),!0;if((M&&h0(M)||t.cursor===0)&&t.remoteImages.length>0)return e.preventDefault(),ze(t.remoteImages.length-1),!0}if(!oe.current&&r&&e.key===`ArrowDown`){e.preventDefault();let n=UQ({...t,selectedRemoteImageId:r},r);return n!==null&&n+1<t.remoteImages.length?ze(n+1):Be(),!0}return!oe.current&&r&&(e.key===`Backspace`||e.key===`Delete`)?(e.preventDefault(),We(r),!0):(He(e),!1)}function We(e){if(n||!M)return;let t=qe(),r=t.remoteImages.findIndex(t=>t.id===e),i=t.remoteImages.filter(t=>t.id!==e),a=r===-1?null:i[r]??i[r-1]??null;ce.current=a?.id??null,ae.current=i,D(i),Te(q1(M.getJSON(),i.length)),k(e=>({...e,remoteImages:i,selectedRemoteImageId:a?.id??null,shortcutsOpen:!1}))}function Ge(e){if(n||!M)return;let t=Z1(M.getJSON(),WQ(e));M.chain().focus().insertContent(N1({kind:`paste`,label:t,detail:`${WQ(e)} chars`,content:e})).run()}function Ke(e,t=e,r){n||M?.chain().focus().insertContent(N1({kind:`rich-link`,label:t,detail:e,href:e,metadata:r})).run()}function qe(){return M?{...C1(M.getJSON(),ae.current,v,r,i,m0(M)),error:A.current.error,history:A.current.history,historyCursor:j.current??A.current.historyCursor,killBuffer:A.current.killBuffer,reverseSearch:A.current.reverseSearch,shortcutsOpen:A.current.shortcutsOpen,selectedRemoteImageId:A.current.selectedRemoteImageId}:A.current}function Je(e){let t=pe.current?.(e);return t?(k(e=>({...e,error:t,shortcutsOpen:!1})),O(null),!0):!1}function Ye(e){let t=qe(),n=t.text.slice(0,t.cursor);Ne(n&&!/\s$/.test(n)?` ${e}`:e)}function Xe(){dt?.endWithSend()||Ze()}function Ze(){if(n)return;let e=qe(),r=M?.getJSON()??O1(),i=e.isTaskRunning||e.queueSubmissions,a=i?null:xQ(e.text,v,b);if(a){k(e=>({...e,error:`Unrecognized command: /${a}`,shortcutsOpen:!1})),O(null);return}let s=hQ(e,v,b),c=s??{mode:`submitted`,prompt:``,persistedPrompt:``,historyPrompt:``,action:`Plain`,command:void 0,args:void 0,items:[],elements:[],payloadElements:[],mentionBindings:[]},l=gQ(c,o);if(l){k(e=>({...e,error:l,shortcutsOpen:!1})),O(null);return}let u=new Map,d=[];for(let t of e.imageAttachments){let e=he.current.get(t.id);if(!e){k(e=>({...e,error:`Attached image is no longer available: ${t.placeholder}`,shortcutsOpen:!1})),O(null);return}u.set(t.id,e),d.push({type:t.media,placeholder:t.placeholder,file:e})}let f=[...c.items.filter(e=>e.type===`remote_image`),...d,...c.items.filter(e=>e.type!==`remote_image`)],p={id:crypto.randomUUID(),at:new Date(m.Date.now()).toLocaleTimeString(),mode:i?`queued`:c.mode,prompt:c.prompt,persistedPrompt:c.persistedPrompt,action:i?g0(c,b):c.action,command:c.command,args:c.args,items:f};if(Je(p))return;for(let e of u.keys())he.current.delete(e);let h=KQ(e,c.persistedPrompt),g=me.current?.(p,{editableSource:h});A0(g)&&(ee.current+=1,g.then(()=>{t!==void 0&&O$(t,null)}).catch(e=>{for(let[e,t]of u)he.current.set(e,t);t!==void 0&&O$(t,h),te.current&&(Te(r),M?.commands.focus(`end`),k(t=>({...t,error:e instanceof Error?e.message:`Could not send prompt`})))}).finally(()=>{--ee.current}));let _=s?qQ(e,c.historyPrompt):e.history;j.current=null,ae.current=[],D([]),O(null),Te(O1()),k(e=>({...e,text:``,cursor:0,elements:[],mentionBindings:[],imageAttachments:[],remoteImages:[],pendingPastes:[],selectedRemoteImageId:null,error:null,shortcutsOpen:!1,history:_,historyCursor:null}))}function Qe(){if(n)return;let e=A.current.history,t=A.current.killBuffer;j.current=null,de.current=null,he.current.clear(),ae.current=T.current,D(T.current),O(null),Te(E.current),M?.commands.focus(`end`),k(n=>({...n,history:e,historyCursor:null,killBuffer:t,reverseSearch:null,selectedRemoteImageId:null,error:null,shortcutsOpen:!1}))}function $e(e){if(n||!M||A.current.history.length===0)return;let t=A.current,r=j.current??t.historyCursor;if(e>0&&r===0&&ue.current){tt(ue.current,null),ue.current=null;return}let i=r===null?e<0?0:t.history.length-1:p$(r+e,t.history.length);r===null&&(ue.current=GQ(qe()));let a=t.history[i];et(a,i)}function et(e,t){tt(YQ({source:e,slashCommands:v,mentionCandidates:y}),t)}function tt(e,t){let n=e.remoteImages??[];ae.current=n,A.current={...A.current,historyCursor:t,shortcutsOpen:!1},j.current=t,le.current=t,D(n),Te(v1({state:e,slashCommands:v,mentionCandidates:y,triggers:S})),M?.commands.focus(`end`),k(e=>({...e,historyCursor:t,shortcutsOpen:!1}))}function nt(){n||(O(null),j.current=null,de.current=qe(),k(e=>({...e,reverseSearch:``,historyCursor:null,shortcutsOpen:!1})))}function rt(e){if(n){e.preventDefault();return}if(e.preventDefault(),e.key===`Escape`){st(null),de.current=null;return}if(e.key===`Enter`){de.current=null,k(e=>({...e,reverseSearch:null,shortcutsOpen:!1}));return}if(e.key===`Backspace`){it(e=>e.slice(0,-1));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){at(1);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`){at(-1);return}e.key.length===1&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&it(t=>`${t}${e.key}`)}function it(e){if(n)return;let t=A.current,r=e(t.reverseSearch??``),i=l$(t.history,r,null);if(!M||!i){st(r);return}ot(i.entry,i.index,r)}function at(e){if(n||!M)return;let t=A.current,r=t.reverseSearch??``,i=l$(t.history,r,t.historyCursor,e);i&&ot(i.entry,i.index,r)}function ot(e,t,n){let r=M;if(!r)return;let i=YQ({source:e,slashCommands:v,mentionCandidates:y}),a=i.remoteImages??[];ae.current=a,D(a),Te(v1({state:i,slashCommands:v,mentionCandidates:y,triggers:S})),r.commands.focus(`end`),k(e=>({...e,historyCursor:t,reverseSearch:n,selectedRemoteImageId:null,shortcutsOpen:!1}))}function st(e){if(n)return;let t=de.current;if(!t||!M){k(t=>({...t,reverseSearch:e,shortcutsOpen:!1}));return}let r={...t,history:A.current.history,killBuffer:A.current.killBuffer,reverseSearch:e,historyCursor:null,selectedRemoteImageId:null,shortcutsOpen:!1};j.current=null,ae.current=r.remoteImages,D(r.remoteImages),Te(v1({state:r,slashCommands:v,mentionCandidates:y,triggers:S})),M.commands.focus(`end`),k(r)}ye.current=n?e=>(e.preventDefault(),!0):Ue,ge.current=Pe;function ct(e){if(!(e.target instanceof Element)||!e.target.closest(`[data-slot="composer-editor"]`))return;if(n){e.preventDefault();return}if(!M||Ue(e))return;if(A.current.reverseSearch!==null){rt(e);return}if(A.current.shortcutsOpen&&e.key===`Escape`){e.preventDefault(),je();return}if(e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&ke(qe())){e.preventDefault(),Me();return}if(t2(e)){e.preventDefault(),M.chain().focus().setHardBreak().run(),j.current=null,O(null);return}if(oe.current){if(_0(e)||v0(e)){e.preventDefault(),ut(_0(e)?-1:1);return}if(e.key===`Tab`){e.preventDefault(),De();return}if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),Ce.length===0){O(null),Xe();return}De();return}if(e.key===`Escape`){e.preventDefault(),O(null);return}}if(n2(e)){let t=n0(M);t&&(e.preventDefault(),se.current=t,k(e=>({...e,killBuffer:t.text}))),j.current=null;return}let t=r2(e);if(t!==null){e.preventDefault(),i0(M,t),j.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`e`){e.preventDefault(),r0(M),j.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){let t=e0(M);t&&(e.preventDefault(),se.current=t,k(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`u`){let t=t0(M);t&&(e.preventDefault(),se.current=t,k(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`y`&&A.current.killBuffer){e.preventDefault(),d0(M,se.current??A.current.killBuffer);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){e.preventDefault(),nt();return}if((e.key===`Backspace`||e.key===`Delete`)&&a2(M)){e.preventDefault(),j.current=null,O(null);return}if((e.key===`Backspace`||e.key===`Delete`)&&f0(M,e.key)){e.preventDefault(),j.current=null;return}if((e.key===`Backspace`||e.key===`Delete`||e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey)&&(j.current=null),e.key===`Enter`&&!e.shiftKey&&!e.altKey){e.preventDefault(),Xe();return}let r=i2(e);if(r!==null&&!oe.current){let t=qe();if(e.key===`ArrowUp`&&(h0(M)||t.cursor===0)&&t.remoteImages.length>0){e.preventDefault(),ze(t.remoteImages.length-1);return}u$(t.text,t.cursor,r)&&(e.preventDefault(),$e(r))}}function lt(e){if(n){e.preventDefault();return}e.target instanceof Element&&e.target.closest(`[data-slot="composer-editor"]`)&&Be()}function ut(e){n||O(t=>{if(!t)return t;let n=W$(t,v,y,a).length;return n===0?t:{...t,selectedIndex:p$(t.selectedIndex+e,n)}})}let dt=l1({dictation:u,disabled:n,insertTranscript:Ye,submitDraft:Ze});return(0,L.jsx)(UZ,{value:{state:ie,disabled:n,commandTriggers:b,activePopup:re,suggestions:Ce,attachedImages:he.current,setEditorPlaceholder:xe,actions:{acceptSuggestion:De,toggleSlashMenu:Oe,insertText:Ne,attachImageFiles:Ie,removeImageAttachment:N,addRemoteImage:Le,handleDrop:Re,insertPaste:Ge,insertRichLink:Ke,openShortcuts:Ae,closeShortcuts:je,toggleShortcuts:Me,submit:Xe,reset:Qe},meta:{editor:M}},children:(0,L.jsx)(K$,{value:dt?.api??null,children:(0,L.jsx)(`section`,{"data-slot":`composer`,className:P(`border-border bg-card relative border font-[inherit]`,c),children:(0,L.jsxs)(`div`,{onKeyDownCapture:ct,onMouseDownCapture:lt,children:[l,h.hasLayoutChildren?null:(0,L.jsx)(M0,{})]})})})})}function M0(){let e=(0,W.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsx)(z0,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,L.jsxs)(L.Fragment,{children:[t,(0,L.jsxs)(N0,{children:[(0,L.jsx)(F0,{}),(0,L.jsx)(KZ,{}),(0,L.jsx)(L0,{}),(0,L.jsx)(R0,{})]}),(0,L.jsx)(U0,{}),(0,L.jsx)(K0,{})]}),e[1]=n):n=e[1],n}function N0(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`space-y-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function P0(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`flex flex-wrap items-center gap-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function F0(e){let t=(0,W.c)(14),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=WZ(`Composer.RemoteImages`);if(i.remoteImages.length===0)return null;let a;t[3]===n?a=t[4]:(a=P(`border-border space-y-1 border-b pb-2 text-sm`,n),t[3]=n,t[4]=a);let o;if(t[5]!==i.remoteImages||t[6]!==i.selectedRemoteImageId){let e;t[8]===i.selectedRemoteImageId?e=t[9]:(e=(e,t)=>(0,L.jsxs)(`div`,{className:P(`flex h-6 items-center gap-2 rounded-sm px-2`,i.selectedRemoteImageId===e.id?`bg-primary text-primary-foreground`:`text-sky-500`),children:[(0,L.jsxs)(`span`,{className:`shrink-0`,children:[`[Image #`,t+1,`]`]}),(0,L.jsx)(`span`,{className:`truncate text-xs opacity-70`,children:e.url})]},e.id),t[8]=i.selectedRemoteImageId,t[9]=e),o=i.remoteImages.map(e),t[5]=i.remoteImages,t[6]=i.selectedRemoteImageId,t[7]=o}else o=t[7];let s;return t[10]!==r||t[11]!==a||t[12]!==o?(s=(0,L.jsx)(`div`,{className:a,...r,children:o}),t[10]=r,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function I0(e){e.dataTransfer.types.includes(`Files`)&&e.preventDefault()}function L0(e){let t=(0,W.c)(29),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,onDragEnter:r,onDragOver:i,onDrop:a,placeholder:s,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?`Type a message or / for commands`:s,{disabled:l,meta:u,actions:d,setEditorPlaceholder:f}=WZ(`Composer.Editor`),p,m;t[7]!==c||t[8]!==f?(p=()=>{f(c)},m=[c,f],t[7]=c,t[8]=f,t[9]=p,t[10]=m):(p=t[9],m=t[10]),(0,I.useLayoutEffect)(p,m);let h=l?``:void 0,g;t[11]===r?g=t[12]:(g=e=>{r?.(e),I0(e)},t[11]=r,t[12]=g);let _;t[13]===i?_=t[14]:(_=e=>{i?.(e),I0(e)},t[13]=i,t[14]=_);let v;t[15]!==d||t[16]!==a?(v=e=>{a?.(e),!e.defaultPrevented&&d.handleDrop(e.dataTransfer)&&e.preventDefault()},t[15]=d,t[16]=a,t[17]=v):v=t[17];let y;t[18]===u.editor?y=t[19]:(y=(0,L.jsx)(iK,{editor:u.editor}),t[18]=u.editor,t[19]=y);let b;return t[20]!==n||t[21]!==l||t[22]!==o||t[23]!==h||t[24]!==g||t[25]!==_||t[26]!==v||t[27]!==y?(b=(0,L.jsx)(`div`,{"data-slot":`composer-frame`,className:n,"aria-disabled":l,"data-disabled":h,onDragEnter:g,onDragOver:_,onDrop:v,...o,children:y}),t[20]=n,t[21]=l,t[22]=o,t[23]=h,t[24]=g,t[25]=_,t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function R0(e){let t=(0,W.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=WZ(`Composer.Error`);if(!i.error)return null;let a;t[3]===n?a=t[4]:(a=P(`border-primary/30 bg-primary/10 text-primary rounded-md border px-3 py-2 text-xs`,n),t[3]=n,t[4]=a);let o;return t[5]!==r||t[6]!==i.error||t[7]!==a?(o=(0,L.jsx)(`div`,{role:`alert`,className:a,...r,children:i.error}),t[5]=r,t[6]=i.error,t[7]=a,t[8]=o):o=t[8],o}function z0(e){let t=(0,W.c)(25),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,suggestions:a,actions:o}=WZ(`Composer.Popup`),{acceptSuggestion:s}=o;if(!i)return null;let c;t[3]===a?c=t[4]:(c=a.some(B0),t[3]=a,t[4]=c);let l=c,u;t[5]===n?u=t[6]:(u=P(`border-border bg-popover absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-10 rounded-xl border shadow-lg`,n),t[5]=n,t[6]=u);let d;if(t[7]!==s||t[8]!==i||t[9]!==a||t[10]!==l){let e;t[12]!==s||t[13]!==i||t[14]!==l?(e=(e,t)=>(0,L.jsx)(V0,{selected:t===i.selectedIndex,icon:l?e.icon:null,token:fQ(e),takesArgs:e.supportsArgs===!0,description:e.detail,onMouseDown:()=>s({index:t})},`item:${e.id}`),t[12]=s,t[13]=i,t[14]=l,t[15]=e):e=t[15],d=a.map(e),t[7]=s,t[8]=i,t[9]=a,t[10]=l,t[11]=d}else d=t[11];let f;t[16]===a.length?f=t[17]:(f=a.length===0?(0,L.jsx)(`div`,{className:`text-muted-foreground px-2 py-1 text-[13px] leading-4`,children:`no matches`}):null,t[16]=a.length,t[17]=f);let p;t[18]!==d||t[19]!==f?(p=(0,L.jsxs)(`div`,{className:`flex max-h-72 flex-col gap-1 overflow-y-auto p-1`,role:`listbox`,"aria-label":`Suggestions`,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;return t[21]!==r||t[22]!==u||t[23]!==p?(m=(0,L.jsx)(`div`,{className:u,...r,children:p}),t[21]=r,t[22]=u,t[23]=p,t[24]=m):m=t[24],m}function B0(e){return e.icon}function V0(e){let t=(0,W.c)(23),{selected:n,icon:r,token:i,takesArgs:a,description:o,onMouseDown:s}=e,c=(0,I.useRef)(null),l,u;t[0]===n?(l=t[1],u=t[2]):(l=()=>{n&&c.current?.scrollIntoView({block:`nearest`})},u=[n],t[0]=n,t[1]=l,t[2]=u),(0,I.useEffect)(l,u);let d=n?`bg-accent text-foreground`:`text-foreground/80 hover:bg-accent/60`,f;t[3]===d?f=t[4]:(f=P(`flex w-full items-center gap-2 rounded-md px-2 py-1 text-start text-[13px] leading-4 [&_svg]:size-4 [&_svg]:shrink-0`,d),t[3]=d,t[4]=f);let p;t[5]===s?p=t[6]:(p=e=>{e.preventDefault(),s()},t[5]=s,t[6]=p);let m;t[7]===r?m=t[8]:(m=r===null?null:(0,L.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:r}),t[7]=r,t[8]=m);let h;t[9]===i?h=t[10]:(h=(0,L.jsx)(`span`,{className:`truncate`,children:i}),t[9]=i,t[10]=h);let g;t[11]===a?g=t[12]:(g=a?(0,L.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`args`}):null,t[11]=a,t[12]=g);let _;t[13]===o?_=t[14]:(_=(0,L.jsx)(`span`,{className:`text-muted-foreground truncate`,children:o}),t[13]=o,t[14]=_);let v;return t[15]!==n||t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h||t[20]!==g||t[21]!==_?(v=(0,L.jsxs)(`button`,{ref:c,type:`button`,role:`option`,"aria-selected":n,className:f,onMouseDown:p,children:[m,h,g,_]}),t[15]=n,t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g,t[21]=_,t[22]=v):v=t[22],v}var H0=[{title:`Send`,items:[[`Enter`,`send or queue`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`]]},{title:`Edit`,items:[[`Ctrl K`,`kill to end`],[`Ctrl U`,`kill to start`],[`Ctrl W`,`kill word`],[`Ctrl Y`,`yank`]]},{title:`Navigate`,items:[[`Ctrl P/N`,`history`],[`Ctrl R`,`reverse search`],[`Ctrl E`,`line end`],[`Alt B/F`,`word move`]]}];function U0(e){let t=(0,W.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i,actions:a}=WZ(`Composer.Shortcuts`),{closeShortcuts:o}=a;if(!i.shortcutsOpen||!mQ(i))return null;let s;t[3]===n?s=t[4]:(s=P(`border-border bg-popover border-t px-3 py-3 text-xs`,n),t[3]=n,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,L.jsx)(`div`,{className:`text-foreground font-medium`,children:`Keyboard shortcuts`}),t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[c,(0,L.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded-sm px-2 py-1`,onClick:o,children:`close`})]}),t[6]=o,t[7]=l);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,L.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:H0.map(W0)}),t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==s||t[11]!==l?(d=(0,L.jsxs)(`div`,{role:`dialog`,"aria-label":`Keyboard shortcuts`,className:s,...r,children:[l,u]}),t[9]=r,t[10]=s,t[11]=l,t[12]=d):d=t[12],d}function W0(e){return(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:e.title}),(0,L.jsx)(`div`,{className:`space-y-1`,children:e.items.map(G0)})]},e.title)}function G0(e){let[t,n]=e;return(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),(0,L.jsx)(`span`,{className:`text-muted-foreground text-right`,children:n})]},`${t}-${n}`)}function K0(e){let t=(0,W.c)(29),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,state:a}=WZ(`Composer.Footer`);if(a.reverseSearch!==null){let e;t[3]===n?e=t[4]:(e=P(`border-border text-muted-foreground flex items-center gap-2 border-t px-3 py-2 text-[11px]`,n),t[3]=n,t[4]=e);let i,o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,L.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:`Ctrl R`}),o=(0,L.jsx)(`span`,{children:`reverse-i-search:`}),t[5]=i,t[6]=o):(i=t[5],o=t[6]);let s=a.reverseSearch||`_`,c;t[7]===s?c=t[8]:(c=(0,L.jsx)(`span`,{className:`text-foreground`,children:s}),t[7]=s,t[8]=c);let l,u,d,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,L.jsx)(`span`,{children:`Ctrl R previous`}),u=(0,L.jsx)(`span`,{children:`Ctrl S next`}),d=(0,L.jsx)(`span`,{children:`Enter accept`}),f=(0,L.jsx)(`span`,{children:`Esc cancel`}),t[9]=l,t[10]=u,t[11]=d,t[12]=f):(l=t[9],u=t[10],d=t[11],f=t[12]);let p;return t[13]!==r||t[14]!==e||t[15]!==c?(p=(0,L.jsxs)(`div`,{className:e,...r,children:[i,o,c,l,u,d,f]}),t[13]=r,t[14]=e,t[15]=c,t[16]=p):p=t[16],p}let o;t[17]!==i||t[18]!==a.isTaskRunning||t[19]!==a.queueSubmissions?(o=i?[[`Enter`,`insert`],[`Tab`,`insert`],[`Esc`,`dismiss`]]:[[`Enter`,a.isTaskRunning||a.queueSubmissions?`queue`:`send`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`],[`Ctrl J/M`,`newline`],[`Ctrl P/N`,`history`],[`Ctrl E`,`line end`],[`Ctrl K`,`kill`],[`Ctrl U`,`kill back`],[`Ctrl W`,`word kill`],[`Alt B/F`,`word move`],[`Ctrl Y`,`yank`]],t[17]=i,t[18]=a.isTaskRunning,t[19]=a.queueSubmissions,t[20]=o):o=t[20];let s=o,c;t[21]===n?c=t[22]:(c=P(`border-border text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 text-[11px]`,n),t[21]=n,t[22]=c);let l;t[23]===s?l=t[24]:(l=s.map(q0),t[23]=s,t[24]=l);let u;return t[25]!==r||t[26]!==c||t[27]!==l?(u=(0,L.jsx)(`div`,{className:c,...r,children:l}),t[25]=r,t[26]=c,t[27]=l,t[28]=u):u=t[28],u}function q0(e){let[t,n]=e;return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),n]},`${t}-${n}`)}function J0(e){let t=(0,W.c)(19),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({accept:i,multiple:a,disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`image/*,video/*,audio/*`:i,s=a===void 0||a,{actions:c,disabled:l}=WZ(`Composer.AttachFiles`),u=(0,I.useRef)(null),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>u.current?.click(),t[5]=d):d=t[5];let f;t[6]!==n||t[7]!==r?(f=(0,L.jsx)(e2,{action:d,disabled:n,...r}),t[6]=n,t[7]=r,t[8]=f):f=t[8];let p=l||n,m;t[9]===c?m=t[10]:(m=e=>{let t=e.currentTarget;t.files&&c.attachImageFiles(t.files),t.value=``},t[9]=c,t[10]=m);let h;t[11]!==o||t[12]!==s||t[13]!==p||t[14]!==m?(h=(0,L.jsx)(`input`,{ref:u,type:`file`,accept:o,multiple:s,"aria-label":`Attach media files`,hidden:!0,disabled:p,onChange:m}),t[11]=o,t[12]=s,t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;return t[16]!==f||t[17]!==h?(g=(0,L.jsxs)(L.Fragment,{children:[f,h]}),t[16]=f,t[17]=h,t[18]=g):g=t[18],g}function Y0(e){let t=(0,W.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({url:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=WZ(`Composer.AddRemoteImage`),a;t[3]!==i||t[4]!==r?(a=()=>i.addRemoteImage(r),t[3]=i,t[4]=r,t[5]=a):a=t[5];let o;return t[6]!==n||t[7]!==a?(o=(0,L.jsx)(e2,{action:a,...n}),t[6]=n,t[7]=a,t[8]=o):o=t[8],o}function X0(e){let t=(0,W.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({content:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=WZ(`Composer.InsertPaste`),a;t[3]!==i||t[4]!==n?(a=()=>i.insertPaste(n),t[3]=i,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==a?(o=(0,L.jsx)(e2,{action:a,...r}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Z0(e){let t=(0,W.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({href:n,label:r,metadata:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{actions:o}=WZ(`Composer.InsertRichLink`),s;t[5]!==o||t[6]!==n||t[7]!==r||t[8]!==i?(s=()=>o.insertRichLink(n,r,i),t[5]=o,t[6]=n,t[7]=r,t[8]=i,t[9]=s):s=t[9];let c;return t[10]!==a||t[11]!==s?(c=(0,L.jsx)(e2,{action:s,...a}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}function Q0(e){let t=(0,W.c)(3),{actions:n}=WZ(`Composer.Submit`),r;return t[0]!==n.submit||t[1]!==e?(r=(0,L.jsx)(e2,{action:n.submit,...e}),t[0]=n.submit,t[1]=e,t[2]=r):r=t[2],r}function $0(e){let t=(0,W.c)(3),{actions:n}=WZ(`Composer.Reset`),r;return t[0]!==n.reset||t[1]!==e?(r=(0,L.jsx)(e2,{action:n.reset,...e}),t[0]=n.reset,t[1]=e,t[2]=r):r=t[2],r}function e2(e){let t=(0,W.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({action:n,onClick:i,disabled:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{disabled:o}=WZ(`Composer.ActionTrigger`),s=o||r,c;t[5]!==n||t[6]!==i?(c=e=>{i?.(e),e.defaultPrevented||n()},t[5]=n,t[6]=i,t[7]=c):c=t[7];let l;return t[8]!==a||t[9]!==s||t[10]!==c?(l=(0,L.jsx)(ut,{...a,disabled:s,onClick:c}),t[8]=a,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function t2(e){if(e.metaKey)return!1;if(e.key===`Enter`)return e.altKey&&!e.ctrlKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&(t===`j`||t===`m`)}function n2(e){if(e.metaKey)return!1;if(e.key===`Backspace`)return e.ctrlKey||e.altKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&t===`w`||e.ctrlKey&&e.altKey&&t===`h`}function r2(e){if(e.metaKey||e.shiftKey)return null;if(e.key===`ArrowLeft`&&(e.altKey||e.ctrlKey))return-1;if(e.key===`ArrowRight`&&(e.altKey||e.ctrlKey))return 1;if(!e.altKey||e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`b`?-1:t===`f`?1:null}function i2(e){if(e.key===`ArrowUp`)return-1;if(e.key===`ArrowDown`)return 1;if(e.metaKey||e.altKey||e.shiftKey||!e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`p`?-1:t===`n`?1:null}function a2(e){let{doc:t,selection:n}=e.state;return n.empty||n.from>1||n.to<t.content.size-1?!1:(e.commands.setContent(O1(),{emitUpdate:!0}),e.commands.focus(`start`),e.commands.setTextSelection(1),!0)}var o2={Root:k0,Trigger:F$,Command:I$,Mention:L$,Content:N0,Toolbar:P0,RemoteImages:F0,Attachments:KZ,Editor:L0,Error:R0,Popup:z0,Shortcuts:U0,Footer:K0,AttachFiles:J0,AddRemoteImage:Y0,InsertPaste:X0,InsertRichLink:Z0,Dictate:Z$,CancelDictation:Q$,Submit:Q0,Reset:$0};(0,I.createContext)(null);function s2(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return null;let r=n.cloneContents();for(let e of r.querySelectorAll(`[data-persisted-source]`)){let t=e.getAttribute(`data-persisted-source`);t!==null&&e.replaceWith(t)}return r.textContent??``}function c2(e){let t=(0,W.c)(6),{text:n}=e,r,i;if(t[0]!==n){let e=oM(n);r=d2,i=e.map(l2),t[0]=n,t[1]=r,t[2]=i}else r=t[1],i=t[2];let a;return t[3]!==r||t[4]!==i?(a=(0,L.jsx)(`span`,{onCopy:r,children:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a}function l2(e){switch(e.kind){case`text`:return e.value;case`inline-code`:return(0,L.jsx)(`code`,{"data-persisted-source":e.source,className:`bg-muted rounded px-1 py-0.5 font-mono text-[0.9em]`,children:e.value},e.start);case`code-block`:return(0,L.jsx)(`span`,{"data-persisted-source":e.source,className:`bg-muted my-2 block overflow-x-auto rounded-md px-3 py-2`,children:(0,L.jsx)(`code`,{className:`font-mono text-[0.9em]`,children:e.value})},e.start);case`skill-link`:return(0,L.jsx)(u2,{name:e.name,source:e.source,skillId:e.skillId,title:e.href},e.start);case`standalone-skill`:return(0,L.jsx)(u2,{name:e.name,source:e.source},e.start);case`mention`:return(0,L.jsx)(`span`,{"data-token":`mention`,"data-persisted-source":e.source,className:`bg-foreground/10 rounded-sm px-0.5 font-medium`,children:e.label},e.start);case`link`:return/^(?:https?:|mailto:)/.test(e.href)?(0,L.jsx)(`a`,{href:e.href,"data-persisted-source":e.source,className:`text-primary underline underline-offset-2`,target:`_blank`,rel:`noreferrer`,children:e.label},e.start):e.source}}function u2(e){let t=(0,W.c)(9),{name:n,source:r,skillId:i,title:a}=e,o=i?void 0:n,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(Or,{"aria-hidden":`true`,className:`size-3.5 self-center`}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,L.jsx)(`span`,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==c||t[7]!==a?(l=(0,L.jsxs)(`span`,{"data-skill-id":i,"data-skill-name":o,"data-persisted-source":r,title:a,className:`text-primary inline-flex items-baseline gap-1`,children:[s,c]}),t[3]=i,t[4]=r,t[5]=o,t[6]=c,t[7]=a,t[8]=l):l=t[8],l}function d2(e){let t=s2(e.currentTarget,window.getSelection());t!==null&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault())}var f2=typeof global==`object`&&global&&global.Object===Object&&global,p2=typeof self==`object`&&self&&self.Object===Object&&self,m2=f2||p2||Function(`return this`)(),h2=m2.Symbol,g2=Object.prototype,_2=g2.hasOwnProperty,v2=g2.toString,y2=h2?h2.toStringTag:void 0;function b2(e){var t=_2.call(e,y2),n=e[y2];try{e[y2]=void 0;var r=!0}catch{}var i=v2.call(e);return r&&(t?e[y2]=n:delete e[y2]),i}var x2=Object.prototype.toString;function S2(e){return x2.call(e)}var C2=`[object Null]`,w2=`[object Undefined]`,T2=h2?h2.toStringTag:void 0;function E2(e){return e==null?e===void 0?w2:C2:T2&&T2 in Object(e)?b2(e):S2(e)}function D2(e){return typeof e==`object`&&!!e}var O2=`[object Symbol]`;function k2(e){return typeof e==`symbol`||D2(e)&&E2(e)==O2}function A2(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var j2=Array.isArray,M2=1/0,N2=h2?h2.prototype:void 0,P2=N2?N2.toString:void 0;function F2(e){if(typeof e==`string`)return e;if(j2(e))return A2(e,F2)+``;if(k2(e))return P2?P2.call(e):``;var t=e+``;return t==`0`&&1/e==-M2?`-0`:t}function I2(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var L2=`[object AsyncFunction]`,R2=`[object Function]`,z2=`[object GeneratorFunction]`,B2=`[object Proxy]`;function V2(e){if(!I2(e))return!1;var t=E2(e);return t==R2||t==z2||t==L2||t==B2}var H2=m2[`__core-js_shared__`],U2=function(){var e=/[^.]+$/.exec(H2&&H2.keys&&H2.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function W2(e){return!!U2&&U2 in e}var G2=Function.prototype.toString;function K2(e){if(e!=null){try{return G2.call(e)}catch{}try{return e+``}catch{}}return``}var q2=/[\\^$.*+?()[\]{}|]/g,J2=/^\[object .+?Constructor\]$/,Y2=Function.prototype,X2=Object.prototype,Z2=Y2.toString,Q2=X2.hasOwnProperty,$2=RegExp(`^`+Z2.call(Q2).replace(q2,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function e4(e){return!I2(e)||W2(e)?!1:(V2(e)?$2:J2).test(K2(e))}function t4(e,t){return e?.[t]}function n4(e,t){var n=t4(e,t);return e4(n)?n:void 0}function r4(e,t){return e===t||e!==e&&t!==t}var i4=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a4=/^\w*$/;function o4(e,t){if(j2(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||k2(e)?!0:a4.test(e)||!i4.test(e)||t!=null&&e in Object(t)}var s4=n4(Object,`create`);function c4(){this.__data__=s4?s4(null):{},this.size=0}function l4(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var u4=`__lodash_hash_undefined__`,d4=Object.prototype.hasOwnProperty;function f4(e){var t=this.__data__;if(s4){var n=t[e];return n===u4?void 0:n}return d4.call(t,e)?t[e]:void 0}var p4=Object.prototype.hasOwnProperty;function m4(e){var t=this.__data__;return s4?t[e]!==void 0:p4.call(t,e)}var h4=`__lodash_hash_undefined__`;function g4(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=s4&&t===void 0?h4:t,this}function _4(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}_4.prototype.clear=c4,_4.prototype.delete=l4,_4.prototype.get=f4,_4.prototype.has=m4,_4.prototype.set=g4;function v4(){this.__data__=[],this.size=0}function y4(e,t){for(var n=e.length;n--;)if(r4(e[n][0],t))return n;return-1}var b4=Array.prototype.splice;function x4(e){var t=this.__data__,n=y4(t,e);return n<0?!1:(n==t.length-1?t.pop():b4.call(t,n,1),--this.size,!0)}function S4(e){var t=this.__data__,n=y4(t,e);return n<0?void 0:t[n][1]}function C4(e){return y4(this.__data__,e)>-1}function w4(e,t){var n=this.__data__,r=y4(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function T4(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}T4.prototype.clear=v4,T4.prototype.delete=x4,T4.prototype.get=S4,T4.prototype.has=C4,T4.prototype.set=w4;var E4=n4(m2,`Map`);function D4(){this.size=0,this.__data__={hash:new _4,map:new(E4||T4),string:new _4}}function O4(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function k4(e,t){var n=e.__data__;return O4(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function A4(e){var t=k4(this,e).delete(e);return this.size-=+!!t,t}function j4(e){return k4(this,e).get(e)}function M4(e){return k4(this,e).has(e)}function N4(e,t){var n=k4(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function P4(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}P4.prototype.clear=D4,P4.prototype.delete=A4,P4.prototype.get=j4,P4.prototype.has=M4,P4.prototype.set=N4;var F4=`Expected a function`;function I4(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(F4);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(I4.Cache||P4),n}I4.Cache=P4;var L4=500;function R4(e){var t=I4(e,function(e){return n.size===L4&&n.clear(),e}),n=t.cache;return t}var z4=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,B4=/\\(\\)?/g,V4=R4(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(z4,function(e,n,r,i){t.push(r?i.replace(B4,`$1`):n||e)}),t});function H4(e){return e==null?``:F2(e)}function U4(e,t){return j2(e)?e:o4(e,t)?[e]:V4(H4(e))}var W4=1/0;function G4(e){if(typeof e==`string`||k2(e))return e;var t=e+``;return t==`0`&&1/e==-W4?`-0`:t}function K4(e,t){t=U4(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[G4(t[n++])];return n&&n==r?e:void 0}function q4(e,t,n){var r=e==null?void 0:K4(e,t);return r===void 0?n:r}function J4(e){if(!e)return{};let t={...e};return delete t.whenNullish,delete t.locale,t}function Y4(e,t){return e==null||Number.isNaN(e)?t?.whenNullish??`—`:new Intl.NumberFormat(t?.locale??`en-US`,J4(t)).format(e)}var X4=Y4;function Z4(e,t){return Y4(e,{notation:`compact`,maximumFractionDigits:1,...t})}var Q4=`pending-chat-prefill`;function $4(){try{let e=sessionStorage.getItem(Q4);return e?JSON.parse(e):null}catch{return sessionStorage.removeItem(Q4),null}}function e3(e){sessionStorage.setItem(Q4,JSON.stringify(e))}function t3(){sessionStorage.removeItem(Q4)}function n3(e){let t=Nm(e.metadata)?e.metadata.persistedPrompt:void 0;if(typeof t!=`string`)throw Error(`Message ${e.id} has no persistedPrompt: send it with useAgent().submit.`);return t}var r3=class{chat;uploadFile;submissions=new Z_;onResetChat;constructor(e){this.chat=e.chat,this.uploadFile=e.uploadFile,this.onResetChat=e.onResetChat}bind(e){this.chat=e}initialize(e){e&&this.consumePrefill(e)}submit(e){this.chat.clearError();let{files:t=[],...n}=e,r=this.chat.id;return this.submissions.run(async()=>{if(t.length===0){this.assertCurrentChat(r),this.send(n);return}let e=await this.uploadFiles(r,t);this.assertCurrentChat(r),this.send({...n,metadata:{...n.metadata,uploads:e}})})}async uploadFiles(e,t){return Promise.all(t.map(t=>this.uploadFile(e,t)))}assertCurrentChat(e){if(this.chat.id!==e)throw Error(`The chat changed before the submission was sent.`)}send({prompt:e,persistedPrompt:t,metadata:n}){this.chat.sendMessage({role:`user`,parts:[{type:`text`,text:e}],metadata:{...n,persistedPrompt:t}})}clearChat(){for(let{id:e}of this.chat.experimental_queuedMessages)this.chat.experimental_removeQueuedMessage(e);this.chat.setMessages([])}setChat(e){this.chat.setMessages(e)}stop(){this.chat.stop()}resetChat(e){let t=crypto.randomUUID();e&&e3({prompt:e,targetChatId:t}),this.onResetChat(t)}consumePrefill(e){let t=$4();!t||t.targetChatId!==e||(t3(),this.submit({prompt:t.prompt,persistedPrompt:t.prompt}))}getTriggeringUserMessage(e){let{messages:t}=this.chat,n=t.findIndex(t=>t.role===`assistant`&&t.parts.some(t=>`toolCallId`in t&&t.toolCallId===e));if(n<=0)return null;let r=t[n-1];return r?.role===`user`?r:null}getLastUserMessageId(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`)return e[t].id;return null}getLastAssistantMessage(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`)return e[t];return null}get hasSubmitted(){return this.chat.messages.length>0}};async function i3(e,t,n){let r=t?.[n.toolName];n.toolName.startsWith(`render`)&&r?.static===!1&&r.requiresUserInput!==!0&&await e.addToolOutput({toolCallId:n.toolCallId,tool:n.toolName,output:`rendered`,state:`output-available`})}function a3(e){let t=Fv({id:e.chatId,messages:e.initialMessages,transport:e.transport,throttle:50,experimental_queue:!0,resume:e.resume,onData:e.onData,onFinish:e.onFinish,sendAutomaticallyWhen:o3,onToolCall(n){let{toolCall:r}=n;i3(t,e.registry,r)}});return t}function o3(e){return wv(e)||Cv(e)}function s3(e){let t=(0,W.c)(2),n;return t[0]===e?n=t[1]:(n=(0,L.jsx)(c3,{...e}),t[0]=e,t[1]=n),n}function c3(e){let t=(0,W.c)(13),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={initial:`smooth`},t[0]=n):n=t[0];let{scrollRef:r,contentRef:i}=RA(n),{hasSubmitted:a}=S3(),o;t[1]===e.className?o=t[2]:(o=P(`@container mx-auto h-full w-full overflow-y-auto`,e.className),t[1]=e.className,t[2]=o);let s=a?`min-h-full`:`h-full justify-center`,c;t[3]===s?c=t[4]:(c=P(`relative mx-auto flex w-full flex-col`,s),t[3]=s,t[4]=c);let l;t[5]!==i||t[6]!==e.children||t[7]!==c?(l=(0,L.jsx)(`div`,{ref:i,"data-slot":`content`,className:c,children:e.children}),t[5]=i,t[6]=e.children,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==r||t[10]!==o||t[11]!==l?(u=(0,L.jsx)(`div`,{id:`agent`,"data-slot":`agent`,className:o,ref:r,children:l}),t[9]=r,t[10]=o,t[11]=l,t[12]=u):u=t[12],u}function l3(e){let t=(0,W.c)(12),{hasSubmitted:n}=S3(),r;t[0]!==n||t[1]!==e.className?(r=P(n?P(`bg-background sticky top-0 z-10 shrink-0 space-y-1 backdrop-blur-md`,e.className):`relative flex justify-center py-4`),t[0]=n,t[1]=e.className,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i={layout:{type:`tween`,ease:[.4,0,.2,1],duration:.4}},t[3]=i):i=t[3];let a=n?`text-left`:`space-y-3 text-center`,o;t[4]===a?o=t[5]:(o=P(a),t[4]=a,t[5]=o);let s;t[6]!==e.children||t[7]!==o?(s=(0,L.jsx)(`div`,{className:o,children:e.children}),t[6]=e.children,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==r||t[10]!==s?(c=(0,L.jsx)(MA.div,{layout:!0,className:r,transition:i,children:s}),t[9]=r,t[10]=s,t[11]=c):c=t[11],c}l3.displayName=`AgentHeader.Root`;function u3(e){let t=(0,W.c)(6),{hasSubmitted:n}=S3(),r;t[0]!==n||t[1]!==e.children||t[2]!==e.icon?(r=!n&&(0,L.jsx)(MA.div,{exit:{opacity:0},transition:{duration:.2},children:(0,L.jsxs)(`h1`,{className:`flex items-center justify-center gap-2 text-2xl font-medium tracking-tight`,children:[e.icon,e.children??`How can I help today?`]})},`agent-header-initial`),t[0]=n,t[1]=e.children,t[2]=e.icon,t[3]=r):r=t[3];let i;return t[4]===r?i=t[5]:(i=(0,L.jsx)(OO,{mode:`sync`,children:r}),t[4]=r,t[5]=i),i}u3.displayName=`AgentHeader.Hero`;function d3(e){let t=(0,W.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,L.jsx)(MA.h2,{layout:`position`,className:`text-muted-foreground text-sm font-medium`,children:e.children}),t[0]=e.children,t[1]=n),n}d3.displayName=`AgentHeader.Title`;function f3(e){let t=(0,W.c)(5),{hasSubmitted:n}=S3(),r;t[0]!==n||t[1]!==e.children?(r=n&&!!e.children&&(0,L.jsx)(MA.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.25},className:`text-muted-foreground text-sm`,children:e.children}),t[0]=n,t[1]=e.children,t[2]=r):r=t[2];let i;return t[3]===r?i=t[4]:(i=(0,L.jsx)(OO,{children:r}),t[3]=r,t[4]=i),i}f3.displayName=`AgentHeader.Description`;var p3={Root:l3,Hero:u3,Title:d3,Description:f3},m3=(0,I.createContext)(void 0),h3=(0,I.createContext)(`ready`),g3=(0,I.createContext)(void 0),_3=(0,I.createContext)(null),v3=(0,I.createContext)(void 0);function y3({chatId:e,children:t,skipInitialView:n,debugMode:r,registry:i,initialMessages:a,transport:o,resume:s,onData:c,onFinish:l,onResetChat:u}){let d=a3({chatId:e,transport:o,registry:i,initialMessages:a,resume:s,onData:c,onFinish:l}),[f,p]=(0,I.useState)(r),m=(0,I.useCallback)(()=>p(e=>!e),[]),h=(0,I.useRef)(u);(0,I.useEffect)(()=>{h.current=u},[u]);let g=(0,I.useCallback)(e=>{h.current(e)},[]),[_]=(0,I.useState)(()=>new r3({chat:d,uploadFile:o.uploadFile.bind(o),onResetChat:g}));_.bind(d),(0,I.useEffect)(()=>{_.initialize(e)},[_,e]);let v=(0,I.useMemo)(()=>({clearChat:()=>_.clearChat(),resetChat:e=>_.resetChat(e),submit:e=>_.submit(e),setChat:e=>_.setChat(e),getTriggeringUserMessage:e=>_.getTriggeringUserMessage(e),getLastUserMessageId:()=>_.getLastUserMessageId(),stop:()=>_.stop()}),[_]),y=(0,I.useMemo)(()=>({chatId:e,registry:i,debugMode:f,toggleDebugMode:m,...v}),[e,i,f,m,v]),b=(0,I.useMemo)(()=>d,[d.id,d.messages,d.status,d.error,d.experimental_queuedMessages]),x=!!n||d.messages.length>0,S=(0,I.useMemo)(()=>({hasSubmitted:x}),[x]);return(0,L.jsx)(_3,{value:_,children:(0,L.jsx)(m3,{value:y,children:(0,L.jsx)(h3,{value:d.status,children:(0,L.jsx)(g3,{value:b,children:(0,L.jsx)(v3,{value:S,children:t})})})})})}function b3(){let e=(0,I.use)(m3);if(e===void 0)throw Error(`useAgent must be used within an AgentProvider`);return e}function x3(){return{status:(0,I.use)(h3)}}function S3(){let e=(0,I.use)(v3);if(e===void 0)throw Error(`useAgentMeta must be used within an AgentProvider`);return e}function C3(){let e=(0,I.use)(g3);if(e===void 0)throw Error(`useAgentMessages must be used within an AgentProvider`);return e}function w3(e){let t=new Set,n=[];for(let r of e)for(let e of r.parts)e.type===`source-url`&&(t.has(e.url)||(t.add(e.url),n.push({url:e.url,title:e.title})));return n}function T3(e,t){let n=e.findIndex(e=>e.url===t);return n===-1?null:n+1}function E3(e,t){return t===`streaming`||t===`submitted`?!1:e===`input-streaming`||e===`input-available`}function D3(e,t){return E3(e.state,t)}function O3(e){return Object.entries(e).reduce((e,[t,n])=>(n.static||(e[t]={inputSchema:Te(n.inputSchema,{io:`input`,unrepresentable:`any`}),description:n.description}),e),{})}function k3(e){let t=(0,W.c)(11),{children:n,as:r,className:i,duration:a,enabled:o}=e,s=r===void 0?`p`:r,c=o===void 0||o,l=c&&`shimmer`,u;t[0]!==i||t[1]!==l?(u=P(l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d;t[3]!==a||t[4]!==c?(d=c&&a!==void 0?{animationDuration:`${a}s`}:void 0,t[3]=a,t[4]=c,t[5]=d):d=t[5];let f;return t[6]!==s||t[7]!==n||t[8]!==u||t[9]!==d?(f=(0,L.jsx)(s,{className:u,style:d,children:n}),t[6]=s,t[7]=n,t[8]=u,t[9]=d,t[10]=f):f=t[10],f}function A3(e){let t=(0,W.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=P(`size-3.5 shrink-0 transition-transform group-data-[panel-open]:rotate-90`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,L.jsx)(se,{"aria-hidden":!0,className:r}),t[2]=r,t[3]=i),i}function j3(e){return P(`group hover:bg-muted/30 flex min-h-7 w-full gap-2 rounded-sm py-1 text-left transition-colors`,e)}(0,I.createContext)(null);var M3=(0,I.createContext)(void 0),N3=(0,I.createContext)(void 0);function P3(){let e=(0,I.use)(M3);if(!e)throw Error(`useMessagesContext must be used within <Messages>`);return e}function F3(){let e=(0,I.use)(M3),{status:t}=x3();return e?.status??t}function I3(){let e=(0,I.use)(N3);if(!e)throw Error(`useMessageItem must be used within <Messages.Item>`);return e}function L3(e){let t=(0,W.c)(4),{source:n,index:r}=e,i=n.title??n.url,a;return t[0]!==r||t[1]!==n.url||t[2]!==i?(a=(0,L.jsx)(`sup`,{className:`ml-0.5 inline-block`,children:(0,L.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noopener noreferrer`,title:i,className:`text-primary bg-primary/10 hover:bg-primary/20 focus-visible:ring-ring focus-visible:ring-offset-background inline-block rounded px-1 font-mono text-[10px] leading-tight no-underline transition-colors focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none`,children:r})}),t[0]=r,t[1]=n.url,t[2]=i,t[3]=a):a=t[3],a}function R3(e){let t=(0,W.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({ref:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=P(`border-border bg-background relative min-w-0 gap-0 overflow-visible rounded-md border py-0 text-sm/normal ring-0`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,L.jsx)(li,{ref:i,"data-slot":`table-panel`,size:`default`,className:a,...r}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}R3.displayName=`TablePanel.Root`;function z3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`border-border flex items-center justify-between gap-4 border-b px-4 py-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(ui,{"data-slot":`table-panel-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function B3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`min-w-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(`div`,{"data-slot":`table-panel-heading`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function V3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`text-base font-medium text-balance wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(di,{"data-slot":`table-panel-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function H3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`text-muted-foreground text-xs text-pretty wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(fi,{"data-slot":`table-panel-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function U3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`flex shrink-0 items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(pi,{"data-slot":`table-panel-actions`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function W3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`min-w-0 flex-1 overflow-auto p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(mi,{"data-slot":`table-panel-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var G3=Object.assign(R3,{Header:z3,Heading:B3,Title:V3,Description:H3,Actions:U3,Content:W3}),K3=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>/g,q3=/\b([\w-]+)="((?:\\.|[^"])*)"/g;function J3(e){return e.replace(K3,e=>e.replace(q3,(e,t,n)=>`${t}="${n.replace(/\\"/g,`&quot;`)}"`))}function Y3(e,t){if(typeof e!=`string`)return e;let n=J3(e).replace(/<(\w[\w-]*)((?:\s+[\w-]+="[^"]*")+)\s*(\/?>)/g,(e,t,n,r)=>`<${t}${n.replace(/\s+/g,` `).replace(/"([^"]*)"/g,(e,t)=>`"${t.replace(/\*/g,`&#42;`)}"`)}${r}`);return n=n.replace(/\/>(\s*)</g,(e,t,n,r)=>!t.includes(`
326
+ `)}function x0(e){return e.startsWith(`file://`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||/^[A-Za-z]:[\\/]/.test(e)}function S0(e){let t=e.trim();if(!t.startsWith(`file://`))return t;let n=URL.parse(t);if(!n)return t;try{return decodeURIComponent(n.pathname)}catch{return n.pathname}}function C0(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??e}function w0(e){return/[\\/]$/.test(e)}function T0(e){return e.split(/\r?\n/).map(e=>e.trim()).find(e=>e&&!e.startsWith(`#`))??``}function E0(e){let t=T0(e);return t?t.match(/^[\w.+-]+\/[\w.+-]+:[^:\n]+:(.+)$/)?.[1]?.trim()??t:``}function D0(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function O0(e){return ZQ(e.trim())}function k0(e){let t=(0,W.c)(3),n=e.draftKey??``,r;return t[0]!==e||t[1]!==n?(r=(0,L.jsx)(j0,{...e},n),t[0]=e,t[1]=n,t[2]=r):r=t[2],r}function A0(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function j0({initialDraft:e,draftKey:t,disabled:n=!1,isTaskRunning:r=!1,queueSubmissions:i=!1,hasInteracted:a=!1,maxExpandedTextChars:o,editorAriaLabel:s=`Rich prompt composer`,className:c,children:l,dictation:u,validateSubmission:d,onSubmit:f,onStateChange:p}){let m=Ve(),h=R$(l),g=(0,I.useRef)({signature:z$(h),slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers}),_=z$(h);_!==g.current.signature&&(g.current={signature:_,slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers});let{slashCommands:v,mentionCandidates:y,commandTriggers:b,mentionTriggers:x}=g.current,S=(0,I.useMemo)(()=>({commandTriggers:b,mentionTriggers:x}),[b,x]),C=(0,I.useRef)(x);C.current=x;let[w]=(0,I.useState)(()=>{if(e)return e;if(t===void 0)return;let n=D$(t);return n?YQ({source:n,slashCommands:v,mentionCandidates:y}):void 0}),T=(0,I.useRef)(w?.remoteImages??[]),E=(0,I.useRef)(v1({state:w,slashCommands:v,mentionCandidates:y,triggers:S})),ee=(0,I.useRef)(0),te=(0,I.useRef)(!0);(0,I.useEffect)(()=>(te.current=!0,()=>{te.current=!1}),[]);let[ne,D]=(0,I.useState)(T.current),[re,O]=(0,I.useState)(null),[ie,k]=(0,I.useState)(()=>C1(E.current,T.current,v,r,i,0)),A=(0,I.useRef)(ie),ae=(0,I.useRef)(ne),oe=(0,I.useRef)(re),se=(0,I.useRef)(null),ce=(0,I.useRef)(null),le=(0,I.useRef)(void 0),j=(0,I.useRef)(null),ue=(0,I.useRef)(null),de=(0,I.useRef)(null),fe=(0,I.useEffectEvent)((e,t)=>{p?.(e,t)}),pe=(0,I.useRef)(d),me=(0,I.useRef)(f),he=(0,I.useRef)(new Map),ge=(0,I.useRef)(()=>null),_e=(0,I.useRef)(()=>void 0),ve=(0,I.useRef)(()=>void 0),ye=(0,I.useRef)(()=>!1),[be,xe]=(0,I.useState)(``),Se=(0,I.useRef)(be);Se.current=be;let M=dK({extensions:(0,I.useMemo)(()=>u1({getPlaceholder:()=>Se.current,getMentionTrigger:()=>C.current[0]??`@`,getRemoteImageCount:()=>ae.current.length,attachImageFile:e=>ge.current(e)}),[]),content:E.current,editable:!n,editorProps:{attributes:{"data-slot":`composer-editor`,role:`textbox`,"aria-label":s,"aria-placeholder":be,"aria-disabled":n?`true`:`false`,dir:`auto`,spellcheck:`false`},handleKeyDown(e,t){return ye.current(t)}},immediatelyRender:!1,onUpdate({editor:e}){_e.current(e),ve.current(e)},onSelectionUpdate({editor:e}){_e.current(e),ve.current(e)}}),Ce=(0,I.useMemo)(()=>re?W$(re,v,y,a):[],[re,a,y,v]),we=(0,I.useMemo)(()=>hQ(ie,v,b),[b,ie,v]);(0,I.useEffect)(()=>{A.current=ie},[ie]),(0,I.useEffect)(()=>{ae.current=ne},[ne]),(0,I.useEffect)(()=>{oe.current=re},[re]),(0,I.useEffect)(()=>{ie.shortcutsOpen&&(re||ie.reverseSearch!==null||!mQ(ie))&&k(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)},[re,ie]),(0,I.useEffect)(()=>{pe.current=d},[d]),(0,I.useEffect)(()=>{me.current=f},[f]),(0,I.useEffect)(()=>{M&&(M.setEditable(!n),n&&O(null))},[n,M]),(0,I.useEffect)(()=>{fe(ie,we),t!==void 0&&(we?O$(t,KQ(ie,we.persistedPrompt)):ee.current===0&&O$(t,null))},[ie,t,we]),(0,I.useEffect)(()=>{k(e=>e.isTaskRunning===r&&e.queueSubmissions===i?e:{...e,isTaskRunning:r,queueSubmissions:i})},[r,i]),_e.current=e=>{if(n)return;let t=C1(e.getJSON(),ae.current,v,r,i,m0(e)),a=ce.current,o=le.current;ce.current=null,le.current=void 0,k(e=>{let n=o===void 0?j.current:o;j.current=n;let r=e.shortcutsOpen&&mQ(t);return{...t,error:e.error,history:e.history,historyCursor:n,killBuffer:e.killBuffer,reverseSearch:e.reverseSearch,shortcutsOpen:r,selectedRemoteImageId:a}})},ve.current=e=>{if(n){O(null);return}let t=F1(e,S);if(!t){O(null);return}if(b.includes(t.trigger)){let e={trigger:t.trigger,query:t.query,selectedIndex:0},n=W$(e,v,y,a);O(t=>n.length===0?null:{...e,selectedIndex:t?.trigger===e.trigger?Math.min(t.selectedIndex,n.length-1):0});return}O(e=>{let n=t.trigger,r={trigger:n,query:t.query,selectedIndex:e?.trigger===n?e.selectedIndex:0},i=W$(r,v,y,a);return{...r,selectedIndex:e?.trigger===n?Math.min(e.selectedIndex,Math.max(i.length-1,0)):0}})};function Te(e){M?.commands.setContent(e),M&&(_e.current(M),ve.current(M))}function Ee(e){if(n||!M)return;let t=F1(M,S),r=[{type:`text`,text:`${e.trigger}${e.value}`,marks:[{type:`composerSlashCommand`,attrs:{value:e.value,detail:e.detail}}]},{type:`text`,text:` `}];t&&t.trigger===e.trigger?M.chain().focus().deleteRange({from:t.from,to:t.to}).insertContent(r).run():M.chain().focus().insertContent(r).run(),O(null)}function De({index:e=oe.current?.selectedIndex??0}={}){let t=oe.current;if(n||!M||!t)return;let r=W$(t,v,y,a),i=r[e]??r[0];if(!i)return;if(!i.atomic){Ee(i);return}let o=F1(M,S),s=o?.trigger===t.trigger,c=M.chain().focus();s&&o&&c.deleteRange({from:o.from,to:o.to}),c.insertContent([j1(i),{type:`text`,text:` `}]).run(),O(null)}function Oe(){if(n||!M)return;M.commands.focus();let e=b[0];e&&O(t=>t?.trigger===e?null:{trigger:e,query:``,selectedIndex:0})}function ke(e){return mQ(e)&&e.reverseSearch===null&&oe.current===null}function Ae(){n||k(e=>ke(e)&&!e.shortcutsOpen?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function je(){k(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)}function Me(){n||k(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:ke(e)?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function Ne(e){n||!M||!e||M.chain().focus().insertContent(e).run()}function Pe(e){if(zQ(e)===null)return k(t=>({...t,error:`Only image, video, or audio files can be attached: ${e.name||`unnamed file`}`,shortcutsOpen:!1})),O(null),null;let t=crypto.randomUUID();return he.current.set(t,e),t}function Fe(e,t){let n=Pe(t);if(n===null)return;let r=qe(),i=r.remoteImages.length+r.imageAttachments.length+1,a=zQ(t)??`image`;e.chain().focus().insertContent([P1(n,VQ(a,i),a),{type:`text`,text:` `}]).run()}function Ie(e){if(!(n||!M))for(let t of e)Fe(M,t)}function N(e){n||!M||(he.current.delete(e),Te(q1(Y1(M.getJSON(),e),ae.current.length)))}function Le(e){if(n||!M)return;let t=[...ae.current,{id:m$(`remote-image`,e,m.Date.now()),url:e}];ae.current=t,D(t),Te(q1(M.getJSON(),t.length))}function Re(e){return n||!M?!1:_1(M.view,e,ae.current.length,x[0]??`@`,Pe)}function ze(e){if(n)return;let t=ae.current[e]??A.current.remoteImages[e];t&&(ce.current=t.id,k(e=>({...e,selectedRemoteImageId:t.id,shortcutsOpen:!1})))}function Be(){n||(ce.current=null,k(e=>e.selectedRemoteImageId?{...e,selectedRemoteImageId:null,shortcutsOpen:!1}:e))}function He(e){return A.current.selectedRemoteImageId?e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`Escape`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`?(Be(),O(null),!0):e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey?(Be(),!0):!1:!1}function Ue(e){if(n)return e.preventDefault(),!0;if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`)return e.preventDefault(),Be(),O(null),M?.commands.selectAll(),!0;let t=qe(),r=A.current.selectedRemoteImageId;if(!oe.current&&e.key===`ArrowUp`){let n=UQ({...t,selectedRemoteImageId:r},r);if(n!==null)return e.preventDefault(),ze(Math.max(0,n-1)),!0;if((M&&h0(M)||t.cursor===0)&&t.remoteImages.length>0)return e.preventDefault(),ze(t.remoteImages.length-1),!0}if(!oe.current&&r&&e.key===`ArrowDown`){e.preventDefault();let n=UQ({...t,selectedRemoteImageId:r},r);return n!==null&&n+1<t.remoteImages.length?ze(n+1):Be(),!0}return!oe.current&&r&&(e.key===`Backspace`||e.key===`Delete`)?(e.preventDefault(),We(r),!0):(He(e),!1)}function We(e){if(n||!M)return;let t=qe(),r=t.remoteImages.findIndex(t=>t.id===e),i=t.remoteImages.filter(t=>t.id!==e),a=r===-1?null:i[r]??i[r-1]??null;ce.current=a?.id??null,ae.current=i,D(i),Te(q1(M.getJSON(),i.length)),k(e=>({...e,remoteImages:i,selectedRemoteImageId:a?.id??null,shortcutsOpen:!1}))}function Ge(e){if(n||!M)return;let t=Z1(M.getJSON(),WQ(e));M.chain().focus().insertContent(N1({kind:`paste`,label:t,detail:`${WQ(e)} chars`,content:e})).run()}function Ke(e,t=e,r){n||M?.chain().focus().insertContent(N1({kind:`rich-link`,label:t,detail:e,href:e,metadata:r})).run()}function qe(){return M?{...C1(M.getJSON(),ae.current,v,r,i,m0(M)),error:A.current.error,history:A.current.history,historyCursor:j.current??A.current.historyCursor,killBuffer:A.current.killBuffer,reverseSearch:A.current.reverseSearch,shortcutsOpen:A.current.shortcutsOpen,selectedRemoteImageId:A.current.selectedRemoteImageId}:A.current}function Je(e){let t=pe.current?.(e);return t?(k(e=>({...e,error:t,shortcutsOpen:!1})),O(null),!0):!1}function Ye(e){let t=qe(),n=t.text.slice(0,t.cursor);Ne(n&&!/\s$/.test(n)?` ${e}`:e)}function Xe(){dt?.endWithSend()||Ze()}function Ze(){if(n)return;let e=qe(),r=M?.getJSON()??O1(),i=e.isTaskRunning||e.queueSubmissions,a=i?null:xQ(e.text,v,b);if(a){k(e=>({...e,error:`Unrecognized command: /${a}`,shortcutsOpen:!1})),O(null);return}let s=hQ(e,v,b),c=s??{mode:`submitted`,prompt:``,persistedPrompt:``,historyPrompt:``,action:`Plain`,command:void 0,args:void 0,items:[],elements:[],payloadElements:[],mentionBindings:[]},l=gQ(c,o);if(l){k(e=>({...e,error:l,shortcutsOpen:!1})),O(null);return}let u=new Map,d=[];for(let t of e.imageAttachments){let e=he.current.get(t.id);if(!e){k(e=>({...e,error:`Attached image is no longer available: ${t.placeholder}`,shortcutsOpen:!1})),O(null);return}u.set(t.id,e),d.push({type:t.media,placeholder:t.placeholder,file:e})}let f=[...c.items.filter(e=>e.type===`remote_image`),...d,...c.items.filter(e=>e.type!==`remote_image`)],p={id:crypto.randomUUID(),at:new Date(m.Date.now()).toLocaleTimeString(),mode:i?`queued`:c.mode,prompt:c.prompt,persistedPrompt:c.persistedPrompt,action:i?g0(c,b):c.action,command:c.command,args:c.args,items:f};if(Je(p))return;for(let e of u.keys())he.current.delete(e);let h=KQ(e,c.persistedPrompt),g=me.current?.(p,{editableSource:h});A0(g)&&(ee.current+=1,g.then(()=>{t!==void 0&&O$(t,null)}).catch(e=>{for(let[e,t]of u)he.current.set(e,t);t!==void 0&&O$(t,h),te.current&&(Te(r),M?.commands.focus(`end`),k(t=>({...t,error:e instanceof Error?e.message:`Could not send prompt`})))}).finally(()=>{--ee.current}));let _=s?qQ(e,c.historyPrompt):e.history;j.current=null,ae.current=[],D([]),O(null),Te(O1()),k(e=>({...e,text:``,cursor:0,elements:[],mentionBindings:[],imageAttachments:[],remoteImages:[],pendingPastes:[],selectedRemoteImageId:null,error:null,shortcutsOpen:!1,history:_,historyCursor:null}))}function Qe(){if(n)return;let e=A.current.history,t=A.current.killBuffer;j.current=null,de.current=null,he.current.clear(),ae.current=T.current,D(T.current),O(null),Te(E.current),M?.commands.focus(`end`),k(n=>({...n,history:e,historyCursor:null,killBuffer:t,reverseSearch:null,selectedRemoteImageId:null,error:null,shortcutsOpen:!1}))}function $e(e){if(n||!M||A.current.history.length===0)return;let t=A.current,r=j.current??t.historyCursor;if(e>0&&r===0&&ue.current){tt(ue.current,null),ue.current=null;return}let i=r===null?e<0?0:t.history.length-1:p$(r+e,t.history.length);r===null&&(ue.current=GQ(qe()));let a=t.history[i];et(a,i)}function et(e,t){tt(YQ({source:e,slashCommands:v,mentionCandidates:y}),t)}function tt(e,t){let n=e.remoteImages??[];ae.current=n,A.current={...A.current,historyCursor:t,shortcutsOpen:!1},j.current=t,le.current=t,D(n),Te(v1({state:e,slashCommands:v,mentionCandidates:y,triggers:S})),M?.commands.focus(`end`),k(e=>({...e,historyCursor:t,shortcutsOpen:!1}))}function nt(){n||(O(null),j.current=null,de.current=qe(),k(e=>({...e,reverseSearch:``,historyCursor:null,shortcutsOpen:!1})))}function rt(e){if(n){e.preventDefault();return}if(e.preventDefault(),e.key===`Escape`){st(null),de.current=null;return}if(e.key===`Enter`){de.current=null,k(e=>({...e,reverseSearch:null,shortcutsOpen:!1}));return}if(e.key===`Backspace`){it(e=>e.slice(0,-1));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){at(1);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`){at(-1);return}e.key.length===1&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&it(t=>`${t}${e.key}`)}function it(e){if(n)return;let t=A.current,r=e(t.reverseSearch??``),i=l$(t.history,r,null);if(!M||!i){st(r);return}ot(i.entry,i.index,r)}function at(e){if(n||!M)return;let t=A.current,r=t.reverseSearch??``,i=l$(t.history,r,t.historyCursor,e);i&&ot(i.entry,i.index,r)}function ot(e,t,n){let r=M;if(!r)return;let i=YQ({source:e,slashCommands:v,mentionCandidates:y}),a=i.remoteImages??[];ae.current=a,D(a),Te(v1({state:i,slashCommands:v,mentionCandidates:y,triggers:S})),r.commands.focus(`end`),k(e=>({...e,historyCursor:t,reverseSearch:n,selectedRemoteImageId:null,shortcutsOpen:!1}))}function st(e){if(n)return;let t=de.current;if(!t||!M){k(t=>({...t,reverseSearch:e,shortcutsOpen:!1}));return}let r={...t,history:A.current.history,killBuffer:A.current.killBuffer,reverseSearch:e,historyCursor:null,selectedRemoteImageId:null,shortcutsOpen:!1};j.current=null,ae.current=r.remoteImages,D(r.remoteImages),Te(v1({state:r,slashCommands:v,mentionCandidates:y,triggers:S})),M.commands.focus(`end`),k(r)}ye.current=n?e=>(e.preventDefault(),!0):Ue,ge.current=Pe;function ct(e){if(!(e.target instanceof Element)||!e.target.closest(`[data-slot="composer-editor"]`))return;if(n){e.preventDefault();return}if(!M||Ue(e))return;if(A.current.reverseSearch!==null){rt(e);return}if(A.current.shortcutsOpen&&e.key===`Escape`){e.preventDefault(),je();return}if(e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&ke(qe())){e.preventDefault(),Me();return}if(t2(e)){e.preventDefault(),M.chain().focus().setHardBreak().run(),j.current=null,O(null);return}if(oe.current){if(_0(e)||v0(e)){e.preventDefault(),ut(_0(e)?-1:1);return}if(e.key===`Tab`){e.preventDefault(),De();return}if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),Ce.length===0){O(null),Xe();return}De();return}if(e.key===`Escape`){e.preventDefault(),O(null);return}}if(n2(e)){let t=n0(M);t&&(e.preventDefault(),se.current=t,k(e=>({...e,killBuffer:t.text}))),j.current=null;return}let t=r2(e);if(t!==null){e.preventDefault(),i0(M,t),j.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`e`){e.preventDefault(),r0(M),j.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){let t=e0(M);t&&(e.preventDefault(),se.current=t,k(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`u`){let t=t0(M);t&&(e.preventDefault(),se.current=t,k(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`y`&&A.current.killBuffer){e.preventDefault(),d0(M,se.current??A.current.killBuffer);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){e.preventDefault(),nt();return}if((e.key===`Backspace`||e.key===`Delete`)&&a2(M)){e.preventDefault(),j.current=null,O(null);return}if((e.key===`Backspace`||e.key===`Delete`)&&f0(M,e.key)){e.preventDefault(),j.current=null;return}if((e.key===`Backspace`||e.key===`Delete`||e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey)&&(j.current=null),e.key===`Enter`&&!e.shiftKey&&!e.altKey){e.preventDefault(),Xe();return}let r=i2(e);if(r!==null&&!oe.current){let t=qe();if(e.key===`ArrowUp`&&(h0(M)||t.cursor===0)&&t.remoteImages.length>0){e.preventDefault(),ze(t.remoteImages.length-1);return}u$(t.text,t.cursor,r)&&(e.preventDefault(),$e(r))}}function lt(e){if(n){e.preventDefault();return}e.target instanceof Element&&e.target.closest(`[data-slot="composer-editor"]`)&&Be()}function ut(e){n||O(t=>{if(!t)return t;let n=W$(t,v,y,a).length;return n===0?t:{...t,selectedIndex:p$(t.selectedIndex+e,n)}})}let dt=l1({dictation:u,disabled:n,insertTranscript:Ye,submitDraft:Ze});return(0,L.jsx)(UZ,{value:{state:ie,disabled:n,commandTriggers:b,activePopup:re,suggestions:Ce,attachedImages:he.current,setEditorPlaceholder:xe,actions:{acceptSuggestion:De,toggleSlashMenu:Oe,insertText:Ne,attachImageFiles:Ie,removeImageAttachment:N,addRemoteImage:Le,handleDrop:Re,insertPaste:Ge,insertRichLink:Ke,openShortcuts:Ae,closeShortcuts:je,toggleShortcuts:Me,submit:Xe,reset:Qe},meta:{editor:M}},children:(0,L.jsx)(K$,{value:dt?.api??null,children:(0,L.jsx)(`section`,{"data-slot":`composer`,className:P(`border-border bg-card relative border font-[inherit]`,c),children:(0,L.jsxs)(`div`,{onKeyDownCapture:ct,onMouseDownCapture:lt,children:[l,h.hasLayoutChildren?null:(0,L.jsx)(M0,{})]})})})})}function M0(){let e=(0,W.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsx)(z0,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,L.jsxs)(L.Fragment,{children:[t,(0,L.jsxs)(N0,{children:[(0,L.jsx)(F0,{}),(0,L.jsx)(KZ,{}),(0,L.jsx)(L0,{}),(0,L.jsx)(R0,{})]}),(0,L.jsx)(U0,{}),(0,L.jsx)(K0,{})]}),e[1]=n):n=e[1],n}function N0(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`space-y-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function P0(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`flex flex-wrap items-center gap-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function F0(e){let t=(0,W.c)(14),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=WZ(`Composer.RemoteImages`);if(i.remoteImages.length===0)return null;let a;t[3]===n?a=t[4]:(a=P(`border-border space-y-1 border-b pb-2 text-sm`,n),t[3]=n,t[4]=a);let o;if(t[5]!==i.remoteImages||t[6]!==i.selectedRemoteImageId){let e;t[8]===i.selectedRemoteImageId?e=t[9]:(e=(e,t)=>(0,L.jsxs)(`div`,{className:P(`flex h-6 items-center gap-2 rounded-sm px-2`,i.selectedRemoteImageId===e.id?`bg-primary text-primary-foreground`:`text-sky-500`),children:[(0,L.jsxs)(`span`,{className:`shrink-0`,children:[`[Image #`,t+1,`]`]}),(0,L.jsx)(`span`,{className:`truncate text-xs opacity-70`,children:e.url})]},e.id),t[8]=i.selectedRemoteImageId,t[9]=e),o=i.remoteImages.map(e),t[5]=i.remoteImages,t[6]=i.selectedRemoteImageId,t[7]=o}else o=t[7];let s;return t[10]!==r||t[11]!==a||t[12]!==o?(s=(0,L.jsx)(`div`,{className:a,...r,children:o}),t[10]=r,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function I0(e){e.dataTransfer.types.includes(`Files`)&&e.preventDefault()}function L0(e){let t=(0,W.c)(29),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,onDragEnter:r,onDragOver:i,onDrop:a,placeholder:s,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?`Type a message or / for commands`:s,{disabled:l,meta:u,actions:d,setEditorPlaceholder:f}=WZ(`Composer.Editor`),p,m;t[7]!==c||t[8]!==f?(p=()=>{f(c)},m=[c,f],t[7]=c,t[8]=f,t[9]=p,t[10]=m):(p=t[9],m=t[10]),(0,I.useLayoutEffect)(p,m);let h=l?``:void 0,g;t[11]===r?g=t[12]:(g=e=>{r?.(e),I0(e)},t[11]=r,t[12]=g);let _;t[13]===i?_=t[14]:(_=e=>{i?.(e),I0(e)},t[13]=i,t[14]=_);let v;t[15]!==d||t[16]!==a?(v=e=>{a?.(e),!e.defaultPrevented&&d.handleDrop(e.dataTransfer)&&e.preventDefault()},t[15]=d,t[16]=a,t[17]=v):v=t[17];let y;t[18]===u.editor?y=t[19]:(y=(0,L.jsx)(iK,{editor:u.editor}),t[18]=u.editor,t[19]=y);let b;return t[20]!==n||t[21]!==l||t[22]!==o||t[23]!==h||t[24]!==g||t[25]!==_||t[26]!==v||t[27]!==y?(b=(0,L.jsx)(`div`,{"data-slot":`composer-frame`,className:n,"aria-disabled":l,"data-disabled":h,onDragEnter:g,onDragOver:_,onDrop:v,...o,children:y}),t[20]=n,t[21]=l,t[22]=o,t[23]=h,t[24]=g,t[25]=_,t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function R0(e){let t=(0,W.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=WZ(`Composer.Error`);if(!i.error)return null;let a;t[3]===n?a=t[4]:(a=P(`border-primary/30 bg-primary/10 text-primary rounded-md border px-3 py-2 text-xs`,n),t[3]=n,t[4]=a);let o;return t[5]!==r||t[6]!==i.error||t[7]!==a?(o=(0,L.jsx)(`div`,{role:`alert`,className:a,...r,children:i.error}),t[5]=r,t[6]=i.error,t[7]=a,t[8]=o):o=t[8],o}function z0(e){let t=(0,W.c)(25),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,suggestions:a,actions:o}=WZ(`Composer.Popup`),{acceptSuggestion:s}=o;if(!i)return null;let c;t[3]===a?c=t[4]:(c=a.some(B0),t[3]=a,t[4]=c);let l=c,u;t[5]===n?u=t[6]:(u=P(`border-border bg-popover absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-10 rounded-xl border shadow-lg`,n),t[5]=n,t[6]=u);let d;if(t[7]!==s||t[8]!==i||t[9]!==a||t[10]!==l){let e;t[12]!==s||t[13]!==i||t[14]!==l?(e=(e,t)=>(0,L.jsx)(V0,{selected:t===i.selectedIndex,icon:l?e.icon:null,token:fQ(e),takesArgs:e.supportsArgs===!0,description:e.detail,onMouseDown:()=>s({index:t})},`item:${e.id}`),t[12]=s,t[13]=i,t[14]=l,t[15]=e):e=t[15],d=a.map(e),t[7]=s,t[8]=i,t[9]=a,t[10]=l,t[11]=d}else d=t[11];let f;t[16]===a.length?f=t[17]:(f=a.length===0?(0,L.jsx)(`div`,{className:`text-muted-foreground px-2 py-1 text-[13px] leading-4`,children:`no matches`}):null,t[16]=a.length,t[17]=f);let p;t[18]!==d||t[19]!==f?(p=(0,L.jsxs)(`div`,{className:`flex max-h-72 flex-col gap-1 overflow-y-auto p-1`,role:`listbox`,"aria-label":`Suggestions`,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;return t[21]!==r||t[22]!==u||t[23]!==p?(m=(0,L.jsx)(`div`,{className:u,...r,children:p}),t[21]=r,t[22]=u,t[23]=p,t[24]=m):m=t[24],m}function B0(e){return e.icon}function V0(e){let t=(0,W.c)(23),{selected:n,icon:r,token:i,takesArgs:a,description:o,onMouseDown:s}=e,c=(0,I.useRef)(null),l,u;t[0]===n?(l=t[1],u=t[2]):(l=()=>{n&&c.current?.scrollIntoView({block:`nearest`})},u=[n],t[0]=n,t[1]=l,t[2]=u),(0,I.useEffect)(l,u);let d=n?`bg-accent text-foreground`:`text-foreground/80 hover:bg-accent/60`,f;t[3]===d?f=t[4]:(f=P(`flex w-full items-center gap-2 rounded-md px-2 py-1 text-start text-[13px] leading-4 [&_svg]:size-4 [&_svg]:shrink-0`,d),t[3]=d,t[4]=f);let p;t[5]===s?p=t[6]:(p=e=>{e.preventDefault(),s()},t[5]=s,t[6]=p);let m;t[7]===r?m=t[8]:(m=r===null?null:(0,L.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:r}),t[7]=r,t[8]=m);let h;t[9]===i?h=t[10]:(h=(0,L.jsx)(`span`,{className:`truncate`,children:i}),t[9]=i,t[10]=h);let g;t[11]===a?g=t[12]:(g=a?(0,L.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`args`}):null,t[11]=a,t[12]=g);let _;t[13]===o?_=t[14]:(_=(0,L.jsx)(`span`,{className:`text-muted-foreground truncate`,children:o}),t[13]=o,t[14]=_);let v;return t[15]!==n||t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h||t[20]!==g||t[21]!==_?(v=(0,L.jsxs)(`button`,{ref:c,type:`button`,role:`option`,"aria-selected":n,className:f,onMouseDown:p,children:[m,h,g,_]}),t[15]=n,t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g,t[21]=_,t[22]=v):v=t[22],v}var H0=[{title:`Send`,items:[[`Enter`,`send or queue`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`]]},{title:`Edit`,items:[[`Ctrl K`,`kill to end`],[`Ctrl U`,`kill to start`],[`Ctrl W`,`kill word`],[`Ctrl Y`,`yank`]]},{title:`Navigate`,items:[[`Ctrl P/N`,`history`],[`Ctrl R`,`reverse search`],[`Ctrl E`,`line end`],[`Alt B/F`,`word move`]]}];function U0(e){let t=(0,W.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i,actions:a}=WZ(`Composer.Shortcuts`),{closeShortcuts:o}=a;if(!i.shortcutsOpen||!mQ(i))return null;let s;t[3]===n?s=t[4]:(s=P(`border-border bg-popover border-t px-3 py-3 text-xs`,n),t[3]=n,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,L.jsx)(`div`,{className:`text-foreground font-medium`,children:`Keyboard shortcuts`}),t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[c,(0,L.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded-sm px-2 py-1`,onClick:o,children:`close`})]}),t[6]=o,t[7]=l);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,L.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:H0.map(W0)}),t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==s||t[11]!==l?(d=(0,L.jsxs)(`div`,{role:`dialog`,"aria-label":`Keyboard shortcuts`,className:s,...r,children:[l,u]}),t[9]=r,t[10]=s,t[11]=l,t[12]=d):d=t[12],d}function W0(e){return(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:e.title}),(0,L.jsx)(`div`,{className:`space-y-1`,children:e.items.map(G0)})]},e.title)}function G0(e){let[t,n]=e;return(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),(0,L.jsx)(`span`,{className:`text-muted-foreground text-right`,children:n})]},`${t}-${n}`)}function K0(e){let t=(0,W.c)(29),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,state:a}=WZ(`Composer.Footer`);if(a.reverseSearch!==null){let e;t[3]===n?e=t[4]:(e=P(`border-border text-muted-foreground flex items-center gap-2 border-t px-3 py-2 text-[11px]`,n),t[3]=n,t[4]=e);let i,o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,L.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:`Ctrl R`}),o=(0,L.jsx)(`span`,{children:`reverse-i-search:`}),t[5]=i,t[6]=o):(i=t[5],o=t[6]);let s=a.reverseSearch||`_`,c;t[7]===s?c=t[8]:(c=(0,L.jsx)(`span`,{className:`text-foreground`,children:s}),t[7]=s,t[8]=c);let l,u,d,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,L.jsx)(`span`,{children:`Ctrl R previous`}),u=(0,L.jsx)(`span`,{children:`Ctrl S next`}),d=(0,L.jsx)(`span`,{children:`Enter accept`}),f=(0,L.jsx)(`span`,{children:`Esc cancel`}),t[9]=l,t[10]=u,t[11]=d,t[12]=f):(l=t[9],u=t[10],d=t[11],f=t[12]);let p;return t[13]!==r||t[14]!==e||t[15]!==c?(p=(0,L.jsxs)(`div`,{className:e,...r,children:[i,o,c,l,u,d,f]}),t[13]=r,t[14]=e,t[15]=c,t[16]=p):p=t[16],p}let o;t[17]!==i||t[18]!==a.isTaskRunning||t[19]!==a.queueSubmissions?(o=i?[[`Enter`,`insert`],[`Tab`,`insert`],[`Esc`,`dismiss`]]:[[`Enter`,a.isTaskRunning||a.queueSubmissions?`queue`:`send`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`],[`Ctrl J/M`,`newline`],[`Ctrl P/N`,`history`],[`Ctrl E`,`line end`],[`Ctrl K`,`kill`],[`Ctrl U`,`kill back`],[`Ctrl W`,`word kill`],[`Alt B/F`,`word move`],[`Ctrl Y`,`yank`]],t[17]=i,t[18]=a.isTaskRunning,t[19]=a.queueSubmissions,t[20]=o):o=t[20];let s=o,c;t[21]===n?c=t[22]:(c=P(`border-border text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 text-[11px]`,n),t[21]=n,t[22]=c);let l;t[23]===s?l=t[24]:(l=s.map(q0),t[23]=s,t[24]=l);let u;return t[25]!==r||t[26]!==c||t[27]!==l?(u=(0,L.jsx)(`div`,{className:c,...r,children:l}),t[25]=r,t[26]=c,t[27]=l,t[28]=u):u=t[28],u}function q0(e){let[t,n]=e;return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),n]},`${t}-${n}`)}function J0(e){let t=(0,W.c)(19),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({accept:i,multiple:a,disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`image/*,video/*,audio/*`:i,s=a===void 0||a,{actions:c,disabled:l}=WZ(`Composer.AttachFiles`),u=(0,I.useRef)(null),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>u.current?.click(),t[5]=d):d=t[5];let f;t[6]!==n||t[7]!==r?(f=(0,L.jsx)(e2,{action:d,disabled:n,...r}),t[6]=n,t[7]=r,t[8]=f):f=t[8];let p=l||n,m;t[9]===c?m=t[10]:(m=e=>{let t=e.currentTarget;t.files&&c.attachImageFiles(t.files),t.value=``},t[9]=c,t[10]=m);let h;t[11]!==o||t[12]!==s||t[13]!==p||t[14]!==m?(h=(0,L.jsx)(`input`,{ref:u,type:`file`,accept:o,multiple:s,"aria-label":`Attach media files`,hidden:!0,disabled:p,onChange:m}),t[11]=o,t[12]=s,t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;return t[16]!==f||t[17]!==h?(g=(0,L.jsxs)(L.Fragment,{children:[f,h]}),t[16]=f,t[17]=h,t[18]=g):g=t[18],g}function Y0(e){let t=(0,W.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({url:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=WZ(`Composer.AddRemoteImage`),a;t[3]!==i||t[4]!==r?(a=()=>i.addRemoteImage(r),t[3]=i,t[4]=r,t[5]=a):a=t[5];let o;return t[6]!==n||t[7]!==a?(o=(0,L.jsx)(e2,{action:a,...n}),t[6]=n,t[7]=a,t[8]=o):o=t[8],o}function X0(e){let t=(0,W.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({content:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=WZ(`Composer.InsertPaste`),a;t[3]!==i||t[4]!==n?(a=()=>i.insertPaste(n),t[3]=i,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==a?(o=(0,L.jsx)(e2,{action:a,...r}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Z0(e){let t=(0,W.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({href:n,label:r,metadata:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{actions:o}=WZ(`Composer.InsertRichLink`),s;t[5]!==o||t[6]!==n||t[7]!==r||t[8]!==i?(s=()=>o.insertRichLink(n,r,i),t[5]=o,t[6]=n,t[7]=r,t[8]=i,t[9]=s):s=t[9];let c;return t[10]!==a||t[11]!==s?(c=(0,L.jsx)(e2,{action:s,...a}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}function Q0(e){let t=(0,W.c)(3),{actions:n}=WZ(`Composer.Submit`),r;return t[0]!==n.submit||t[1]!==e?(r=(0,L.jsx)(e2,{action:n.submit,...e}),t[0]=n.submit,t[1]=e,t[2]=r):r=t[2],r}function $0(e){let t=(0,W.c)(3),{actions:n}=WZ(`Composer.Reset`),r;return t[0]!==n.reset||t[1]!==e?(r=(0,L.jsx)(e2,{action:n.reset,...e}),t[0]=n.reset,t[1]=e,t[2]=r):r=t[2],r}function e2(e){let t=(0,W.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({action:n,onClick:i,disabled:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{disabled:o}=WZ(`Composer.ActionTrigger`),s=o||r,c;t[5]!==n||t[6]!==i?(c=e=>{i?.(e),e.defaultPrevented||n()},t[5]=n,t[6]=i,t[7]=c):c=t[7];let l;return t[8]!==a||t[9]!==s||t[10]!==c?(l=(0,L.jsx)(ut,{...a,disabled:s,onClick:c}),t[8]=a,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function t2(e){if(e.metaKey)return!1;if(e.key===`Enter`)return e.altKey&&!e.ctrlKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&(t===`j`||t===`m`)}function n2(e){if(e.metaKey)return!1;if(e.key===`Backspace`)return e.ctrlKey||e.altKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&t===`w`||e.ctrlKey&&e.altKey&&t===`h`}function r2(e){if(e.metaKey||e.shiftKey)return null;if(e.key===`ArrowLeft`&&(e.altKey||e.ctrlKey))return-1;if(e.key===`ArrowRight`&&(e.altKey||e.ctrlKey))return 1;if(!e.altKey||e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`b`?-1:t===`f`?1:null}function i2(e){if(e.key===`ArrowUp`)return-1;if(e.key===`ArrowDown`)return 1;if(e.metaKey||e.altKey||e.shiftKey||!e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`p`?-1:t===`n`?1:null}function a2(e){let{doc:t,selection:n}=e.state;return n.empty||n.from>1||n.to<t.content.size-1?!1:(e.commands.setContent(O1(),{emitUpdate:!0}),e.commands.focus(`start`),e.commands.setTextSelection(1),!0)}var o2={Root:k0,Trigger:F$,Command:I$,Mention:L$,Content:N0,Toolbar:P0,RemoteImages:F0,Attachments:KZ,Editor:L0,Error:R0,Popup:z0,Shortcuts:U0,Footer:K0,AttachFiles:J0,AddRemoteImage:Y0,InsertPaste:X0,InsertRichLink:Z0,Dictate:Z$,CancelDictation:Q$,Submit:Q0,Reset:$0};(0,I.createContext)(null);function s2(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return null;let r=n.cloneContents();for(let e of r.querySelectorAll(`[data-persisted-source]`)){let t=e.getAttribute(`data-persisted-source`);t!==null&&e.replaceWith(t)}return r.textContent??``}function c2(e){let t=(0,W.c)(6),{text:n}=e,r,i;if(t[0]!==n){let e=oM(n);r=d2,i=e.map(l2),t[0]=n,t[1]=r,t[2]=i}else r=t[1],i=t[2];let a;return t[3]!==r||t[4]!==i?(a=(0,L.jsx)(`span`,{onCopy:r,children:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a}function l2(e){switch(e.kind){case`text`:return e.value;case`inline-code`:return(0,L.jsx)(`code`,{"data-persisted-source":e.source,className:`bg-muted rounded px-1 py-0.5 font-mono text-[0.9em]`,children:e.value},e.start);case`code-block`:return(0,L.jsx)(`span`,{"data-persisted-source":e.source,className:`bg-muted my-2 block overflow-x-auto rounded-md px-3 py-2`,children:(0,L.jsx)(`code`,{className:`font-mono text-[0.9em]`,children:e.value})},e.start);case`skill-link`:return(0,L.jsx)(u2,{name:e.name,source:e.source,skillId:e.skillId,title:e.href},e.start);case`standalone-skill`:return(0,L.jsx)(u2,{name:e.name,source:e.source},e.start);case`mention`:return(0,L.jsx)(`span`,{"data-token":`mention`,"data-persisted-source":e.source,className:`bg-foreground/10 rounded-sm px-0.5 font-medium`,children:e.label},e.start);case`link`:return/^(?:https?:|mailto:)/.test(e.href)?(0,L.jsx)(`a`,{href:e.href,"data-persisted-source":e.source,className:`text-primary underline underline-offset-2`,target:`_blank`,rel:`noreferrer`,children:e.label},e.start):e.source}}function u2(e){let t=(0,W.c)(9),{name:n,source:r,skillId:i,title:a}=e,o=i?void 0:n,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(Or,{"aria-hidden":`true`,className:`size-3.5 self-center`}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,L.jsx)(`span`,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==c||t[7]!==a?(l=(0,L.jsxs)(`span`,{"data-skill-id":i,"data-skill-name":o,"data-persisted-source":r,title:a,className:`text-primary inline-flex items-baseline gap-1`,children:[s,c]}),t[3]=i,t[4]=r,t[5]=o,t[6]=c,t[7]=a,t[8]=l):l=t[8],l}function d2(e){let t=s2(e.currentTarget,window.getSelection());t!==null&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault())}var f2=typeof global==`object`&&global&&global.Object===Object&&global,p2=typeof self==`object`&&self&&self.Object===Object&&self,m2=f2||p2||Function(`return this`)(),h2=m2.Symbol,g2=Object.prototype,_2=g2.hasOwnProperty,v2=g2.toString,y2=h2?h2.toStringTag:void 0;function b2(e){var t=_2.call(e,y2),n=e[y2];try{e[y2]=void 0;var r=!0}catch{}var i=v2.call(e);return r&&(t?e[y2]=n:delete e[y2]),i}var x2=Object.prototype.toString;function S2(e){return x2.call(e)}var C2=`[object Null]`,w2=`[object Undefined]`,T2=h2?h2.toStringTag:void 0;function E2(e){return e==null?e===void 0?w2:C2:T2&&T2 in Object(e)?b2(e):S2(e)}function D2(e){return typeof e==`object`&&!!e}var O2=`[object Symbol]`;function k2(e){return typeof e==`symbol`||D2(e)&&E2(e)==O2}function A2(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var j2=Array.isArray,M2=1/0,N2=h2?h2.prototype:void 0,P2=N2?N2.toString:void 0;function F2(e){if(typeof e==`string`)return e;if(j2(e))return A2(e,F2)+``;if(k2(e))return P2?P2.call(e):``;var t=e+``;return t==`0`&&1/e==-M2?`-0`:t}function I2(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var L2=`[object AsyncFunction]`,R2=`[object Function]`,z2=`[object GeneratorFunction]`,B2=`[object Proxy]`;function V2(e){if(!I2(e))return!1;var t=E2(e);return t==R2||t==z2||t==L2||t==B2}var H2=m2[`__core-js_shared__`],U2=function(){var e=/[^.]+$/.exec(H2&&H2.keys&&H2.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function W2(e){return!!U2&&U2 in e}var G2=Function.prototype.toString;function K2(e){if(e!=null){try{return G2.call(e)}catch{}try{return e+``}catch{}}return``}var q2=/[\\^$.*+?()[\]{}|]/g,J2=/^\[object .+?Constructor\]$/,Y2=Function.prototype,X2=Object.prototype,Z2=Y2.toString,Q2=X2.hasOwnProperty,$2=RegExp(`^`+Z2.call(Q2).replace(q2,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function e4(e){return!I2(e)||W2(e)?!1:(V2(e)?$2:J2).test(K2(e))}function t4(e,t){return e?.[t]}function n4(e,t){var n=t4(e,t);return e4(n)?n:void 0}function r4(e,t){return e===t||e!==e&&t!==t}var i4=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a4=/^\w*$/;function o4(e,t){if(j2(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||k2(e)?!0:a4.test(e)||!i4.test(e)||t!=null&&e in Object(t)}var s4=n4(Object,`create`);function c4(){this.__data__=s4?s4(null):{},this.size=0}function l4(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var u4=`__lodash_hash_undefined__`,d4=Object.prototype.hasOwnProperty;function f4(e){var t=this.__data__;if(s4){var n=t[e];return n===u4?void 0:n}return d4.call(t,e)?t[e]:void 0}var p4=Object.prototype.hasOwnProperty;function m4(e){var t=this.__data__;return s4?t[e]!==void 0:p4.call(t,e)}var h4=`__lodash_hash_undefined__`;function g4(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=s4&&t===void 0?h4:t,this}function _4(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}_4.prototype.clear=c4,_4.prototype.delete=l4,_4.prototype.get=f4,_4.prototype.has=m4,_4.prototype.set=g4;function v4(){this.__data__=[],this.size=0}function y4(e,t){for(var n=e.length;n--;)if(r4(e[n][0],t))return n;return-1}var b4=Array.prototype.splice;function x4(e){var t=this.__data__,n=y4(t,e);return n<0?!1:(n==t.length-1?t.pop():b4.call(t,n,1),--this.size,!0)}function S4(e){var t=this.__data__,n=y4(t,e);return n<0?void 0:t[n][1]}function C4(e){return y4(this.__data__,e)>-1}function w4(e,t){var n=this.__data__,r=y4(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function T4(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}T4.prototype.clear=v4,T4.prototype.delete=x4,T4.prototype.get=S4,T4.prototype.has=C4,T4.prototype.set=w4;var E4=n4(m2,`Map`);function D4(){this.size=0,this.__data__={hash:new _4,map:new(E4||T4),string:new _4}}function O4(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function k4(e,t){var n=e.__data__;return O4(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function A4(e){var t=k4(this,e).delete(e);return this.size-=+!!t,t}function j4(e){return k4(this,e).get(e)}function M4(e){return k4(this,e).has(e)}function N4(e,t){var n=k4(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function P4(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}P4.prototype.clear=D4,P4.prototype.delete=A4,P4.prototype.get=j4,P4.prototype.has=M4,P4.prototype.set=N4;var F4=`Expected a function`;function I4(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(F4);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(I4.Cache||P4),n}I4.Cache=P4;var L4=500;function R4(e){var t=I4(e,function(e){return n.size===L4&&n.clear(),e}),n=t.cache;return t}var z4=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,B4=/\\(\\)?/g,V4=R4(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(z4,function(e,n,r,i){t.push(r?i.replace(B4,`$1`):n||e)}),t});function H4(e){return e==null?``:F2(e)}function U4(e,t){return j2(e)?e:o4(e,t)?[e]:V4(H4(e))}var W4=1/0;function G4(e){if(typeof e==`string`||k2(e))return e;var t=e+``;return t==`0`&&1/e==-W4?`-0`:t}function K4(e,t){t=U4(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[G4(t[n++])];return n&&n==r?e:void 0}function q4(e,t,n){var r=e==null?void 0:K4(e,t);return r===void 0?n:r}function J4(e){if(!e)return{};let t={...e};return delete t.whenNullish,delete t.locale,t}function Y4(e,t){return e==null||Number.isNaN(e)?t?.whenNullish??`—`:new Intl.NumberFormat(t?.locale??`en-US`,J4(t)).format(e)}var X4=Y4;function Z4(e,t){return Y4(e,{notation:`compact`,maximumFractionDigits:1,...t})}var Q4=`pending-chat-prefill`;function $4(){try{let e=sessionStorage.getItem(Q4);return e?JSON.parse(e):null}catch{return sessionStorage.removeItem(Q4),null}}function e3(e){sessionStorage.setItem(Q4,JSON.stringify(e))}function t3(){sessionStorage.removeItem(Q4)}function n3(e){let t=Pm(e.metadata)?e.metadata.persistedPrompt:void 0;if(typeof t!=`string`)throw Error(`Message ${e.id} has no persistedPrompt: send it with useAgent().submit.`);return t}var r3=class{chat;uploadFile;submissions=new Q_;onResetChat;constructor(e){this.chat=e.chat,this.uploadFile=e.uploadFile,this.onResetChat=e.onResetChat}bind(e){this.chat=e}initialize(e){e&&this.consumePrefill(e)}submit(e){this.chat.clearError();let{files:t=[],...n}=e,r=this.chat.id;return this.submissions.run(async()=>{if(t.length===0){this.assertCurrentChat(r),this.send(n);return}let e=await this.uploadFiles(r,t);this.assertCurrentChat(r),this.send({...n,metadata:{...n.metadata,uploads:e}})})}async uploadFiles(e,t){return Promise.all(t.map(t=>this.uploadFile(e,t)))}assertCurrentChat(e){if(this.chat.id!==e)throw Error(`The chat changed before the submission was sent.`)}send({prompt:e,persistedPrompt:t,metadata:n}){this.chat.sendMessage({role:`user`,parts:[{type:`text`,text:e}],metadata:{...n,persistedPrompt:t}})}clearChat(){for(let{id:e}of this.chat.experimental_queuedMessages)this.chat.experimental_removeQueuedMessage(e);this.chat.setMessages([])}setChat(e){this.chat.setMessages(e)}stop(){this.chat.stop()}resetChat(e){let t=crypto.randomUUID();e&&e3({prompt:e,targetChatId:t}),this.onResetChat(t)}consumePrefill(e){let t=$4();!t||t.targetChatId!==e||(t3(),this.submit({prompt:t.prompt,persistedPrompt:t.prompt}))}getTriggeringUserMessage(e){let{messages:t}=this.chat,n=t.findIndex(t=>t.role===`assistant`&&t.parts.some(t=>`toolCallId`in t&&t.toolCallId===e));if(n<=0)return null;let r=t[n-1];return r?.role===`user`?r:null}getLastUserMessageId(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`)return e[t].id;return null}getLastAssistantMessage(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`)return e[t];return null}get hasSubmitted(){return this.chat.messages.length>0}};async function i3(e,t,n){let r=t?.[n.toolName];n.toolName.startsWith(`render`)&&r?.static===!1&&r.requiresUserInput!==!0&&await e.addToolOutput({toolCallId:n.toolCallId,tool:n.toolName,output:`rendered`,state:`output-available`})}function a3(e){let t=Iv({id:e.chatId,messages:e.initialMessages,transport:e.transport,throttle:50,experimental_queue:!0,resume:e.resume,onData:e.onData,onFinish:e.onFinish,sendAutomaticallyWhen:o3,onToolCall(n){let{toolCall:r}=n;i3(t,e.registry,r)}});return t}function o3(e){return Tv(e)||wv(e)}function s3(e){let t=(0,W.c)(2),n;return t[0]===e?n=t[1]:(n=(0,L.jsx)(c3,{...e}),t[0]=e,t[1]=n),n}function c3(e){let t=(0,W.c)(13),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={initial:`smooth`},t[0]=n):n=t[0];let{scrollRef:r,contentRef:i}=zA(n),{hasSubmitted:a}=S3(),o;t[1]===e.className?o=t[2]:(o=P(`@container mx-auto h-full w-full overflow-y-auto`,e.className),t[1]=e.className,t[2]=o);let s=a?`min-h-full`:`h-full justify-center`,c;t[3]===s?c=t[4]:(c=P(`relative mx-auto flex w-full flex-col`,s),t[3]=s,t[4]=c);let l;t[5]!==i||t[6]!==e.children||t[7]!==c?(l=(0,L.jsx)(`div`,{ref:i,"data-slot":`content`,className:c,children:e.children}),t[5]=i,t[6]=e.children,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==r||t[10]!==o||t[11]!==l?(u=(0,L.jsx)(`div`,{id:`agent`,"data-slot":`agent`,className:o,ref:r,children:l}),t[9]=r,t[10]=o,t[11]=l,t[12]=u):u=t[12],u}function l3(e){let t=(0,W.c)(12),{hasSubmitted:n}=S3(),r;t[0]!==n||t[1]!==e.className?(r=P(n?P(`bg-background sticky top-0 z-10 shrink-0 space-y-1 backdrop-blur-md`,e.className):`relative flex justify-center py-4`),t[0]=n,t[1]=e.className,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i={layout:{type:`tween`,ease:[.4,0,.2,1],duration:.4}},t[3]=i):i=t[3];let a=n?`text-left`:`space-y-3 text-center`,o;t[4]===a?o=t[5]:(o=P(a),t[4]=a,t[5]=o);let s;t[6]!==e.children||t[7]!==o?(s=(0,L.jsx)(`div`,{className:o,children:e.children}),t[6]=e.children,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==r||t[10]!==s?(c=(0,L.jsx)(NA.div,{layout:!0,className:r,transition:i,children:s}),t[9]=r,t[10]=s,t[11]=c):c=t[11],c}l3.displayName=`AgentHeader.Root`;function u3(e){let t=(0,W.c)(6),{hasSubmitted:n}=S3(),r;t[0]!==n||t[1]!==e.children||t[2]!==e.icon?(r=!n&&(0,L.jsx)(NA.div,{exit:{opacity:0},transition:{duration:.2},children:(0,L.jsxs)(`h1`,{className:`flex items-center justify-center gap-2 text-2xl font-medium tracking-tight`,children:[e.icon,e.children??`How can I help today?`]})},`agent-header-initial`),t[0]=n,t[1]=e.children,t[2]=e.icon,t[3]=r):r=t[3];let i;return t[4]===r?i=t[5]:(i=(0,L.jsx)(kO,{mode:`sync`,children:r}),t[4]=r,t[5]=i),i}u3.displayName=`AgentHeader.Hero`;function d3(e){let t=(0,W.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,L.jsx)(NA.h2,{layout:`position`,className:`text-muted-foreground text-sm font-medium`,children:e.children}),t[0]=e.children,t[1]=n),n}d3.displayName=`AgentHeader.Title`;function f3(e){let t=(0,W.c)(5),{hasSubmitted:n}=S3(),r;t[0]!==n||t[1]!==e.children?(r=n&&!!e.children&&(0,L.jsx)(NA.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.25},className:`text-muted-foreground text-sm`,children:e.children}),t[0]=n,t[1]=e.children,t[2]=r):r=t[2];let i;return t[3]===r?i=t[4]:(i=(0,L.jsx)(kO,{children:r}),t[3]=r,t[4]=i),i}f3.displayName=`AgentHeader.Description`;var p3={Root:l3,Hero:u3,Title:d3,Description:f3},m3=(0,I.createContext)(void 0),h3=(0,I.createContext)(`ready`),g3=(0,I.createContext)(void 0),_3=(0,I.createContext)(null),v3=(0,I.createContext)(void 0);function y3({chatId:e,children:t,skipInitialView:n,debugMode:r,registry:i,initialMessages:a,transport:o,resume:s,onData:c,onFinish:l,onResetChat:u}){let d=a3({chatId:e,transport:o,registry:i,initialMessages:a,resume:s,onData:c,onFinish:l}),[f,p]=(0,I.useState)(r),m=(0,I.useCallback)(()=>p(e=>!e),[]),h=(0,I.useRef)(u);(0,I.useEffect)(()=>{h.current=u},[u]);let g=(0,I.useCallback)(e=>{h.current(e)},[]),[_]=(0,I.useState)(()=>new r3({chat:d,uploadFile:o.uploadFile.bind(o),onResetChat:g}));_.bind(d),(0,I.useEffect)(()=>{_.initialize(e)},[_,e]);let v=(0,I.useMemo)(()=>({clearChat:()=>_.clearChat(),resetChat:e=>_.resetChat(e),submit:e=>_.submit(e),setChat:e=>_.setChat(e),getTriggeringUserMessage:e=>_.getTriggeringUserMessage(e),getLastUserMessageId:()=>_.getLastUserMessageId(),stop:()=>_.stop()}),[_]),y=(0,I.useMemo)(()=>({chatId:e,registry:i,debugMode:f,toggleDebugMode:m,...v}),[e,i,f,m,v]),b=(0,I.useMemo)(()=>d,[d.id,d.messages,d.status,d.error,d.experimental_queuedMessages]),x=!!n||d.messages.length>0,S=(0,I.useMemo)(()=>({hasSubmitted:x}),[x]);return(0,L.jsx)(_3,{value:_,children:(0,L.jsx)(m3,{value:y,children:(0,L.jsx)(h3,{value:d.status,children:(0,L.jsx)(g3,{value:b,children:(0,L.jsx)(v3,{value:S,children:t})})})})})}function b3(){let e=(0,I.use)(m3);if(e===void 0)throw Error(`useAgent must be used within an AgentProvider`);return e}function x3(){return{status:(0,I.use)(h3)}}function S3(){let e=(0,I.use)(v3);if(e===void 0)throw Error(`useAgentMeta must be used within an AgentProvider`);return e}function C3(){let e=(0,I.use)(g3);if(e===void 0)throw Error(`useAgentMessages must be used within an AgentProvider`);return e}function w3(e){let t=new Set,n=[];for(let r of e)for(let e of r.parts)e.type===`source-url`&&(t.has(e.url)||(t.add(e.url),n.push({url:e.url,title:e.title})));return n}function T3(e,t){let n=e.findIndex(e=>e.url===t);return n===-1?null:n+1}function E3(e,t){return t===`streaming`||t===`submitted`?!1:e===`input-streaming`||e===`input-available`}function D3(e,t){return E3(e.state,t)}function O3(e){return Object.entries(e).reduce((e,[t,n])=>(n.static||(e[t]={inputSchema:Te(n.inputSchema,{io:`input`,unrepresentable:`any`}),description:n.description}),e),{})}function k3(e){let t=(0,W.c)(11),{children:n,as:r,className:i,duration:a,enabled:o}=e,s=r===void 0?`p`:r,c=o===void 0||o,l=c&&`shimmer`,u;t[0]!==i||t[1]!==l?(u=P(l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d;t[3]!==a||t[4]!==c?(d=c&&a!==void 0?{animationDuration:`${a}s`}:void 0,t[3]=a,t[4]=c,t[5]=d):d=t[5];let f;return t[6]!==s||t[7]!==n||t[8]!==u||t[9]!==d?(f=(0,L.jsx)(s,{className:u,style:d,children:n}),t[6]=s,t[7]=n,t[8]=u,t[9]=d,t[10]=f):f=t[10],f}function A3(e){let t=(0,W.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=P(`size-3.5 shrink-0 transition-transform group-data-[panel-open]:rotate-90`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,L.jsx)(se,{"aria-hidden":!0,className:r}),t[2]=r,t[3]=i),i}function j3(e){return P(`group hover:bg-muted/30 flex min-h-7 w-full gap-2 rounded-sm py-1 text-left transition-colors`,e)}(0,I.createContext)(null);var M3=(0,I.createContext)(void 0),N3=(0,I.createContext)(void 0);function P3(){let e=(0,I.use)(M3);if(!e)throw Error(`useMessagesContext must be used within <Messages>`);return e}function F3(){let e=(0,I.use)(M3),{status:t}=x3();return e?.status??t}function I3(){let e=(0,I.use)(N3);if(!e)throw Error(`useMessageItem must be used within <Messages.Item>`);return e}function L3(e){let t=(0,W.c)(4),{source:n,index:r}=e,i=n.title??n.url,a;return t[0]!==r||t[1]!==n.url||t[2]!==i?(a=(0,L.jsx)(`sup`,{className:`ml-0.5 inline-block`,children:(0,L.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noopener noreferrer`,title:i,className:`text-primary bg-primary/10 hover:bg-primary/20 focus-visible:ring-ring focus-visible:ring-offset-background inline-block rounded px-1 font-mono text-[10px] leading-tight no-underline transition-colors focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none`,children:r})}),t[0]=r,t[1]=n.url,t[2]=i,t[3]=a):a=t[3],a}function R3(e){let t=(0,W.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({ref:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=P(`border-border bg-background relative min-w-0 gap-0 overflow-visible rounded-md border py-0 text-sm/normal ring-0`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,L.jsx)(li,{ref:i,"data-slot":`table-panel`,size:`default`,className:a,...r}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}R3.displayName=`TablePanel.Root`;function z3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`border-border flex items-center justify-between gap-4 border-b px-4 py-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(ui,{"data-slot":`table-panel-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function B3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`min-w-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(`div`,{"data-slot":`table-panel-heading`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function V3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`text-base font-medium text-balance wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(di,{"data-slot":`table-panel-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function H3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`text-muted-foreground text-xs text-pretty wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(fi,{"data-slot":`table-panel-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function U3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`flex shrink-0 items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(pi,{"data-slot":`table-panel-actions`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function W3(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`min-w-0 flex-1 overflow-auto p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(mi,{"data-slot":`table-panel-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var G3=Object.assign(R3,{Header:z3,Heading:B3,Title:V3,Description:H3,Actions:U3,Content:W3}),K3=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>/g,q3=/\b([\w-]+)="((?:\\.|[^"])*)"/g;function J3(e){return e.replace(K3,e=>e.replace(q3,(e,t,n)=>`${t}="${n.replace(/\\"/g,`&quot;`)}"`))}function Y3(e,t){if(typeof e!=`string`)return e;let n=J3(e).replace(/<(\w[\w-]*)((?:\s+[\w-]+="[^"]*")+)\s*(\/?>)/g,(e,t,n,r)=>`<${t}${n.replace(/\s+/g,` `).replace(/"([^"]*)"/g,(e,t)=>`"${t.replace(/\*/g,`&#42;`)}"`)}${r}`);return n=n.replace(/\/>(\s*)</g,(e,t,n,r)=>!t.includes(`
327
327
  `)&&Z3(r,n)?e:`/>
328
328
 
329
329
  <`),Q3(n,t)}var X3=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>|<\/[\w-]+\s*>/g;function Z3(e,t){let n=e.lastIndexOf(`
@@ -339,9 +339,9 @@ img.ProseMirror-separator {
339
339
  `)?e+`
340
340
  `:e+`
341
341
 
342
- `}var n6=`response-table-panel`,r6=[`title`,`description`],i6=P(Ut({variant:`ghost`,size:`icon-sm`})),a6=Wn().use(Qn).use(Xn).use($j),o6=e=>{let t=Hn(e),n=l6(e);if(n.length===0)return t;let r=0,i=t.map(e=>{let t={start:r,end:r+e.length};return r=t.end,t}),a=new Set;for(let e of n){let t=!1;for(let[n,r]of i.entries())r.start<e.end&&r.end>e.start&&(t&&a.add(n),t=!0)}return t.reduce((e,t,n)=>(a.has(n)&&e.length>0?e[e.length-1]+=t:e.push(t),e),[])};function s6(e){return e?.type===`leafDirective`&&`name`in e&&e.name===`table`}function c6(e,t){if(t===void 0)return;let n=e[t-1];return s6(n)?n:void 0}function l6(e){let t=[];return nr(a6.parse(e),`table`,(e,n,r)=>{if(!r)return;let i=c6(r.children,n)?.position?.start.offset,a=e.position?.end.offset;i!==void 0&&a!==void 0&&t.push({start:i,end:a})}),t}function u6(e,t){return e.attributes?.[t]?.trim()||void 0}function d6(e){let t=a6.parse(e),n=!1;if(nr(t,`leafDirective`,(e,t,r)=>{let i=t===void 0?void 0:r?.children[t+1];if(e.name!==`table`||i?.type!==`table`)return;n=!0;let a=[u6(e,`title`),u6(e,`description`)].filter(Boolean).join(` `);e.children=a?[{type:`text`,value:a}]:[]}),n)return Zn(zn(t,{includeHtml:!1}))}function f6(e){let t=(0,W.c)(2),n;return t[0]===e?n=t[1]:(n=(0,L.jsx)(Un,{...e}),t[0]=e,t[1]=n),n}function p6(e){function t(t){let n=(0,W.c)(6),r;n[0]!==t.content||n[1]!==t.dir?(r=d6(t.content)??t.dir,n[0]=t.content,n[1]=t.dir,n[2]=r):r=n[2];let i=r,a;return n[3]!==i||n[4]!==t?(a=(0,L.jsx)(e,{...t,dir:i}),n[3]=i,n[4]=t,n[5]=a):a=n[5],a}return t.displayName=`DirectionAwareTableBlock`,t}function m6(e,t){let n=t&&u6(t,`title`),r=t&&u6(t,`description`),i={...n?{title:n}:{},...r?{description:r}:{}};return{type:`tablePanel`,data:{hName:n6,...Object.keys(i).length>0?{hProperties:i}:{}},children:[e]}}function h6(){return e=>{nr(e,`table`,(e,t,n)=>{if(t===void 0||!n)return;let r=c6(n.children,t),i=r?t-1:t,a=r?2:1;return n.children.splice(i,a,m6(e,r)),[Rn,i+1]})}}var g6=[...Object.values(Yn),$j,h6],_6=I.createContext({actions:null,controls:!0});function v6(e,t){if(e===!1)return!1;if(e===!0||e===void 0)return!0;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1}function y6(e){return e===!1?!1:e===!0||e===void 0?{table:!1}:{...e,table:!1}}function b6(e){let t=(0,W.c)(21),{children:n,className:r,title:i,description:a}=e,{actions:o,controls:s}=I.use(_6),c;t[0]===s?c=t[1]:(c=v6(s,`copy`),t[0]=s,t[1]=c);let l=c,u;t[2]===s?u=t[3]:(u=v6(s,`download`),t[2]=s,t[3]=u);let d=u,f=!!(i||a),p=!!(l||d||o);if(!n)return null;let m;t[4]===r?m=t[5]:(m=P(`my-4`,r),t[4]=r,t[5]=m);let h;t[6]!==o||t[7]!==a||t[8]!==p||t[9]!==f||t[10]!==l||t[11]!==d||t[12]!==i?(h=(f||p)&&(0,L.jsxs)(G3.Header,{className:P(!f&&`justify-end`),children:[f&&(0,L.jsxs)(G3.Heading,{children:[i&&(0,L.jsx)(G3.Title,{children:i}),a&&(0,L.jsx)(G3.Description,{className:P(i&&`mt-1`),children:a})]}),p&&(0,L.jsxs)(G3.Actions,{"data-copy-exclude":`assistant-snapshot`,children:[l&&(0,L.jsx)($n,{className:i6}),d&&(0,L.jsx)(Bn,{className:i6}),o]})]}),t[6]=o,t[7]=a,t[8]=p,t[9]=f,t[10]=l,t[11]=d,t[12]=i,t[13]=h):h=t[13];let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=P(`overflow-hidden`,`[&>[data-streamdown=table-wrapper]]:m-0 [&>[data-streamdown=table-wrapper]]:gap-0 [&>[data-streamdown=table-wrapper]]:rounded-none [&>[data-streamdown=table-wrapper]]:border-0 [&>[data-streamdown=table-wrapper]]:bg-transparent [&>[data-streamdown=table-wrapper]]:p-0`,`[&>[data-streamdown=table-wrapper]>div:last-child]:rounded-none [&>[data-streamdown=table-wrapper]>div:last-child]:border-0`,`[&_[data-streamdown=table]]:tabular-nums`,`[&_[data-streamdown=table-header]]:bg-muted/30`,`[&_[data-streamdown=table-header-cell]]:text-muted-foreground [&_[data-streamdown=table-header-cell]]:text-xs [&_[data-streamdown=table-header-cell]]:font-medium`,`[&_[data-streamdown=table-cell]]:py-2`,`[&_[data-streamdown=table-row]]:hover:bg-muted/30`),t[14]=g):g=t[14];let _;t[15]===n?_=t[16]:(_=(0,L.jsx)(G3.Content,{className:g,children:n}),t[15]=n,t[16]=_);let v;return t[17]!==m||t[18]!==h||t[19]!==_?(v=(0,L.jsxs)(G3,{"data-streamdown":`table-wrapper`,className:m,children:[h,_]}),t[17]=m,t[18]=h,t[19]=_,t[20]=v):v=t[20],v}function x6(e){let t=(0,W.c)(43),n,r,i,a,o,s,c,l,u,d;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10]):({allowedTags:r,BlockComponent:n,children:i,components:a,controls:o,dir:s,mode:c,remarkPlugins:u,tableActions:d,...l}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d);let f;bb0:{if(!u){f=g6;break bb0}let e;t[11]===u?e=t[12]:(e=[...u,$j,h6],t[11]=u,t[12]=e),f=e}let p=f,m;t[13]===r?m=t[14]:(m={...r,[n6]:r6},t[13]=r,t[14]=m);let h=m,g;t[15]===a?g=t[16]:(g={...a,[n6]:b6},t[15]=a,t[16]=g);let _=g,v;t[17]!==o||t[18]!==d?(v={actions:d,controls:o},t[17]=o,t[18]=d,t[19]=v):v=t[19];let y=v,b;bb1:{if(s!==`auto`||c===`static`){b=n;break bb1}let e=n??f6,r;t[20]===e?r=t[21]:(r=p6(e),t[20]=e,t[21]=r),b=r}let x=b,S;bb2:{if(s!==`auto`||c!==`static`||typeof i!=`string`){S=s;break bb2}let e;t[22]!==i||t[23]!==s?(e=d6(i)??s,t[22]=i,t[23]=s,t[24]=e):e=t[24],S=e}let C=S,w;t[25]===o?w=t[26]:(w=y6(o),t[25]=o,t[26]=w);let T;t[27]!==i||t[28]!==h?(T=Y3(i,Object.keys(h)),t[27]=i,t[28]=h,t[29]=T):T=t[29];let E;t[30]!==c||t[31]!==l||t[32]!==C||t[33]!==w||t[34]!==T||t[35]!==h||t[36]!==x||t[37]!==_||t[38]!==p?(E=(0,L.jsx)(er,{allowedTags:h,BlockComponent:x,components:_,controls:w,dir:C,mode:c,parseMarkdownIntoBlocksFn:o6,remarkPlugins:p,...l,children:T}),t[30]=c,t[31]=l,t[32]=C,t[33]=w,t[34]=T,t[35]=h,t[36]=x,t[37]=_,t[38]=p,t[39]=E):E=t[39];let ee;return t[40]!==E||t[41]!==y?(ee=(0,L.jsx)(_6,{value:y,children:E}),t[40]=E,t[41]=y,t[42]=ee):ee=t[42],ee}var S6=class extends I.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){return this.state.hasError?this.props.fallback||(0,L.jsxs)(`div`,{className:`text-destructive p-2 text-sm`,children:[`Failed to render content: `,this.state.error?.message]}):this.props.children}},C6=(0,I.memo)(e=>{let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`size-full space-y-2 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(S6,{children:(0,L.jsx)(x6,{className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a});C6.displayName=`Response`;function w6(e){let t=(0,W.c)(9),n=e===void 0?2e3:e,r=Ve(),[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>()=>{o.current&&r.clearTimeout(o.current)},c=[r],t[0]=r,t[1]=s,t[2]=c),(0,I.useEffect)(s,c);let l;t[3]!==r||t[4]!==n?(l=async e=>{await navigator.clipboard.writeText(e),a(!0),o.current&&r.clearTimeout(o.current),o.current=r.setTimeout(()=>a(!1),n)},t[3]=r,t[4]=n,t[5]=l):l=t[5];let u=l,d;return t[6]!==i||t[7]!==u?(d=[i,u],t[6]=i,t[7]=u,t[8]=d):d=t[8],d}var T6=(0,I.createContext)({code:``}),E6=e=>{let t=(0,W.c)(24),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({code:r,language:i,showLineNumbers:o,wrap:s,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o!==void 0&&o,l=s!==void 0&&s,u=Vp(r,i),d;t[7]===r?d=t[8]:(d={code:r},t[7]=r,t[8]=d);let f;t[9]===u?f=t[10]:(f=u.map(O6),t[9]=u,t[10]=f);let p;t[11]!==c||t[12]!==f||t[13]!==l?(p=(0,L.jsx)(Ii,{lineNumbers:c,wrap:l,children:f}),t[11]=c,t[12]=f,t[13]=l,t[14]=p):p=t[14];let m;t[15]===n?m=t[16]:(m=!!n&&(0,L.jsx)(Fi,{children:n}),t[15]=n,t[16]=m);let h;t[17]!==a||t[18]!==p||t[19]!==m?(h=(0,L.jsxs)(Pi,{size:`sm`,...a,children:[p,m]}),t[17]=a,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==d||t[22]!==h?(g=(0,L.jsx)(T6,{value:d,children:h}),t[21]=d,t[22]=h,t[23]=g):g=t[23],g},D6=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,...a})=>{let[o,s]=w6(n),{code:c}=(0,I.use)(T6),l=async()=>{if(typeof window>`u`||!navigator.clipboard.writeText){t?.(Error(`Clipboard API not available`));return}try{await s(c),e?.()}catch(e){t?.(e instanceof Error?e:Error(String(e)))}},u=o?je:mr;return(0,L.jsx)(at,{className:P(`shrink-0`,i),onClick:()=>void l(),size:`icon-xs`,variant:`ghost`,...a,children:r??(0,L.jsx)(u,{})})};function O6(e,t){return(0,L.jsx)(Ri,{children:e},t)}var k6=e=>{let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`not-prose mb-4 w-full rounded-md border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(Ki,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},A6=e=>(0,L.jsxs)(Ce,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,L.jsx)(Ee,{className:`size-4`}),"input-available":(0,L.jsx)(fr,{className:`size-4 animate-pulse`}),"approval-requested":(0,L.jsx)(fr,{className:`size-4 text-yellow-600`}),"approval-responded":(0,L.jsx)(or,{className:`size-4 text-blue-600`}),"output-available":(0,L.jsx)(or,{className:`size-4 text-green-600`}),"output-error":(0,L.jsx)(ur,{className:`size-4 text-red-600`}),"output-denied":(0,L.jsx)(ur,{className:`size-4 text-orange-600`})}[e],{"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`}[e]]}),j6=e=>{let t=(0,W.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,title:a,part:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=P(`group flex w-full items-center justify-between gap-4 p-3`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(Rr,{className:`text-muted-foreground size-4`}),t[7]=s):s=t[7];let c;t[8]!==r||t[9]!==a?(c=a??x_(r),t[8]=r,t[9]=a,t[10]=c):c=t[10];let l;t[11]===c?l=t[12]:(l=(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:c}),t[11]=c,t[12]=l);let u;t[13]===r.state?u=t[14]:(u=A6(r.state),t[13]=r.state,t[14]=u);let d;t[15]!==l||t[16]!==u?(d=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,l,u]}),t[15]=l,t[16]=u,t[17]=d):d=t[17];let f;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,L.jsx)(me,{className:`text-muted-foreground size-4 transition-transform group-data-[panel-open]:rotate-180`}),t[18]=f):f=t[18];let p;return t[19]!==i||t[20]!==o||t[21]!==d?(p=(0,L.jsxs)(qi,{className:o,...i,children:[d,f]}),t[19]=i,t[20]=o,t[21]=d,t[22]=p):p=t[22],p},M6=e=>{let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`data-closed:fade-out-0 data-closed:slide-out-to-top-2 data-open:slide-in-from-top-2 text-popover-foreground data-closed:animate-out data-open:animate-in outline-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(Ji,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},N6=e=>{let t=(0,W.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,input:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=P(`space-y-2 overflow-hidden p-4`,n),t[4]=n,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,L.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:`Parameters`}),t[6]=o):o=t[6];let s;t[7]===r?s=t[8]:(s=JSON.stringify(r,null,2),t[7]=r,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,L.jsx)(`div`,{className:`bg-muted/50 rounded-md`,children:(0,L.jsx)(E6,{code:s,language:`json`})}),t[9]=s,t[10]=c);let l;return t[11]!==i||t[12]!==a||t[13]!==c?(l=(0,L.jsxs)(`div`,{className:a,...i,children:[o,c]}),t[11]=i,t[12]=a,t[13]=c,t[14]=l):l=t[14],l},P6=e=>{let t=(0,W.c)(24),n,r,i,a;if(t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,output:i,errorText:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a),!(i||r))return null;let o;t[5]===n?o=t[6]:(o=P(`space-y-2 p-4`,n),t[5]=n,t[6]=o);let s=r?`Error`:`Result`,c;t[7]===s?c=t[8]:(c=(0,L.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:s}),t[7]=s,t[8]=c);let l=r?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`,u;t[9]===l?u=t[10]:(u=P(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,l),t[9]=l,t[10]=u);let d;t[11]===r?d=t[12]:(d=r&&(0,L.jsx)(`div`,{children:r}),t[11]=r,t[12]=d);let f;t[13]===i?f=t[14]:(f=F6(i),t[13]=i,t[14]=f);let p;t[15]!==u||t[16]!==d||t[17]!==f?(p=(0,L.jsxs)(`div`,{className:u,children:[d,f]}),t[15]=u,t[16]=d,t[17]=f,t[18]=p):p=t[18];let m;return t[19]!==a||t[20]!==o||t[21]!==c||t[22]!==p?(m=(0,L.jsxs)(`div`,{className:o,...a,children:[c,p]}),t[19]=a,t[20]=o,t[21]=c,t[22]=p,t[23]=m):m=t[23],m};function F6(e){return typeof e==`string`?(0,L.jsx)(E6,{code:e,language:`json`}):(0,I.isValidElement)(e)?(0,L.jsx)(`div`,{children:e}):typeof e==`object`?(0,L.jsx)(E6,{code:JSON.stringify(e,null,2),language:`json`}):typeof e==`number`||typeof e==`bigint`?(0,L.jsx)(`div`,{children:e}):(0,L.jsx)(`div`,{})}function I6(e){let t=(0,W.c)(20),{part:n}=e,r;t[0]===n?r=t[1]:(r=x_(n),t[0]=n,t[1]=r);let i=`Executing ${r}`,a;t[2]!==n||t[3]!==i?(a=(0,L.jsx)(j6,{title:i,part:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===n.input?o=t[6]:(o=(0,L.jsx)(N6,{input:n.input}),t[5]=n.input,t[6]=o);let s;t[7]===n.output?s=t[8]:(s=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[7]=n.output,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,L.jsx)(C6,{className:`break-all`,children:s}),t[9]=s,t[10]=c);let l;t[11]!==n.errorText||t[12]!==c?(l=(0,L.jsx)(P6,{output:c,errorText:n.errorText}),t[11]=n.errorText,t[12]=c,t[13]=l):l=t[13];let u;t[14]!==o||t[15]!==l?(u=(0,L.jsxs)(M6,{children:[o,l]}),t[14]=o,t[15]=l,t[16]=u):u=t[16];let d;return t[17]!==a||t[18]!==u?(d=(0,L.jsxs)(k6,{"data-copy-exclude":`assistant-snapshot`,children:[a,u]}),t[17]=a,t[18]=u,t[19]=d):d=t[19],d}function L6(e){let t=(0,W.c)(18),{part:n}=e,r=`Executing ${n.toolName}`,i;t[0]!==n||t[1]!==r?(i=(0,L.jsx)(j6,{title:r,part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n.input?a=t[4]:(a=(0,L.jsx)(N6,{input:n.input}),t[3]=n.input,t[4]=a);let o;t[5]===n.output?o=t[6]:(o=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[5]=n.output,t[6]=o);let s;t[7]===o?s=t[8]:(s=(0,L.jsx)(C6,{className:`break-all`,children:o}),t[7]=o,t[8]=s);let c;t[9]!==n.errorText||t[10]!==s?(c=(0,L.jsx)(P6,{output:s,errorText:n.errorText}),t[9]=n.errorText,t[10]=s,t[11]=c):c=t[11];let l;t[12]!==a||t[13]!==c?(l=(0,L.jsxs)(M6,{children:[a,c]}),t[12]=a,t[13]=c,t[14]=l):l=t[14];let u;return t[15]!==i||t[16]!==l?(u=(0,L.jsxs)(k6,{"data-copy-exclude":`assistant-snapshot`,children:[i,l]}),t[15]=i,t[16]=l,t[17]=u):u=t[17],u}var R6=(0,I.createContext)(!1);function z6(e){return e.parts.filter(h_).map(e=>e.text).join(`
343
- `)}function B6(){return(0,I.use)(R6)}function V6(e){return y_(e)&&e.toolMetadata?.kind===`subagent`}function H6(e,t){let n=b_(e);return{toolKey:n,toolEntry:t?.[n]}}function U6(e,t){return e?.static===!1&&!!e?.requiresUserInput&&t===`input-available`}function W6(e){let t=(0,W.c)(4),{children:n}=e,r=I.Children.toArray(n);if(!r.some(K6)){let e;return t[0]===n?e=t[1]:(e=(0,L.jsx)(`p`,{children:n}),t[0]=n,t[1]=e),e}if(r.length>0&&r.every(G6))return n;let i;return t[2]===n?i=t[3]:(i=(0,L.jsx)(`div`,{children:n}),t[2]=n,t[3]=i),i}function G6(e){return I.isValidElement(e)&&typeof e.type!=`string`}function K6(e){return I.isValidElement(e)&&typeof e.type!=`string`}var q6={p:({children:e})=>(0,L.jsx)(W6,{children:e})};function J6(e){let t={...q6},n={};for(let r of e)WA(r),t[r.name]=r.component,n[r.name]=r.allowedAttributes;return{components:t,allowedTags:n}}function Y6(e){let t=(0,W.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({elements:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=n??[],t[3]=n,t[4]=i);let a;t[5]===i?a=t[6]:(a=J6(i),t[5]=i,t[6]=a);let o=a,s;return t[7]!==r||t[8]!==o?(s=(0,L.jsx)(C6,{...o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function X6(e){let t=(0,W.c)(22),{part:n}=e,{addToolApprovalResponse:r}=C3();if(n.state!==`approval-requested`)return null;let i;t[0]===n?i=t[1]:(i=n.title??b_(n),t[0]=n,t[1]=i);let a=i,o=`${a} approval`,s;t[2]===a?s=t[3]:(s=(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:a}),t[2]=a,t[3]=s);let c;t[4]===n.approval.requestReason?c=t[5]:(c=n.approval.requestReason&&(0,L.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n.approval.requestReason}),t[4]=n.approval.requestReason,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,L.jsxs)(`div`,{className:`space-y-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.approval.id?(u=(0,L.jsx)(at,{type:`button`,variant:`destructive`,onClick:()=>void r({id:n.approval.id,approved:!1}),children:`Deny`}),t[9]=r,t[10]=n.approval.id,t[11]=u):u=t[11];let d;t[12]!==r||t[13]!==n.approval.id?(d=(0,L.jsx)(at,{type:`button`,onClick:()=>void r({id:n.approval.id,approved:!0}),children:`Approve`}),t[12]=r,t[13]=n.approval.id,t[14]=d):d=t[14];let f;t[15]!==u||t[16]!==d?(f=(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17];let p;return t[18]!==o||t[19]!==l||t[20]!==f?(p=(0,L.jsxs)(`div`,{"aria-label":o,className:`border-border bg-muted/30 space-y-3 rounded-lg border p-3`,"data-copy-exclude":`assistant-snapshot`,role:`group`,children:[l,f]}),t[18]=o,t[19]=l,t[20]=f,t[21]=p):p=t[21],p}function Z6(e){let t=(0,W.c)(25),{part:n}=e,{registry:r}=b3();if(n.input===void 0){let e;return t[0]!==n.errorText||t[1]!==n.output||t[2]!==n.state?(e=n.state===`output-error`?(0,L.jsx)(P6,{output:n.output,errorText:n.errorText}):(0,L.jsx)(Sr,{className:`size-4 animate-spin`}),t[0]=n.errorText,t[1]=n.output,t[2]=n.state,t[3]=e):e=t[3],e}let i;t[4]===n?i=t[5]:(i=(0,L.jsx)(X6,{part:n}),t[4]=n,t[5]=i);let a=i;if(!r)return a;let o;t[6]!==n||t[7]!==r?(o=H6(n,r),t[6]=n,t[7]=r,t[8]=o):o=t[8];let{toolEntry:s}=o;if(s){let e=s.component,i;t[9]!==n||t[10]!==r.progress?(i=r.progress&&(0,L.jsx)(r.progress.component,{part:n}),t[9]=n,t[10]=r.progress,t[11]=i):i=t[11];let o;t[12]!==e||t[13]!==n?(o=(0,L.jsx)(e,{part:n}),t[12]=e,t[13]=n,t[14]=o):o=t[14];let c;return t[15]!==a||t[16]!==i||t[17]!==o?(c=(0,L.jsxs)(`div`,{className:`space-y-2`,children:[i,o,a]}),t[15]=a,t[16]=i,t[17]=o,t[18]=c):c=t[18],c}else{let e;t[19]!==n||t[20]!==r.progress?(e=r.progress&&(0,L.jsx)(r.progress.component,{part:n}),t[19]=n,t[20]=r.progress,t[21]=e):e=t[21];let i;return t[22]!==a||t[23]!==e?(i=(0,L.jsxs)(L.Fragment,{children:[e,a]}),t[22]=a,t[23]=e,t[24]=i):i=t[24],i}}var Q6={animation:`slideUp`};function $6(e){let t=(0,W.c)(3),{filename:n,url:r}=e,i=n??`Attached image`,a;return t[0]!==i||t[1]!==r?(a=(0,L.jsx)(`img`,{src:r,alt:i,className:`max-h-64 rounded-md border object-contain`}),t[0]=i,t[1]=r,t[2]=a):a=t[2],a}function e8(e){let t=(0,W.c)(16),{filename:n,mediaType:r,url:i}=e,a=n||`Untitled`,o;t[0]!==r||t[1]!==a||t[2]!==i?(o=i?.startsWith(`data:`)?null:i&&r.startsWith(`video/`)?(0,L.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:i,"aria-label":a,className:`max-h-96 w-full rounded-md bg-black`,children:(0,L.jsx)(`track`,{kind:`captions`})}):i&&r.startsWith(`audio/`)?(0,L.jsx)(`audio`,{controls:!0,preload:`metadata`,src:i,"aria-label":a,className:`w-full`,children:(0,L.jsx)(`track`,{kind:`captions`})}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o):o=t[3];let s=o,c=s?`mt-2`:void 0,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,L.jsx)(`strong`,{children:`File:`}),t[4]=l):l=t[4];let u;t[5]!==n||t[6]!==i?(u=i?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`a`,{href:i,download:n,className:`underline`,children:`Download`})]}):null,t[5]=n,t[6]=i,t[7]=u):u=t[7];let d;t[8]!==r||t[9]!==a||t[10]!==c||t[11]!==u?(d=(0,L.jsxs)(`div`,{className:c,children:[l,` `,a,` (`,r,`)`,u]}),t[8]=r,t[9]=a,t[10]=c,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==s||t[14]!==d?(f=(0,L.jsxs)(ii,{className:`bg-muted/30 block w-full rounded-md p-3 text-sm text-inherit`,children:[s,d]}),t[13]=s,t[14]=d,t[15]=f):f=t[15],f}function t8(e){let t=(0,W.c)(4),{filename:n,mediaType:r,url:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=r.split(`/`)[0]===`image`?(0,L.jsx)($6,{filename:n,url:i}):(0,L.jsx)(e8,{filename:n,mediaType:r,url:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}function n8(e){let t=(0,W.c)(9),{text:n,elements:r,className:i}=e,{status:a}=x3(),o=B6(),s;t[0]===i?s=t[1]:(s=P(`text-sm`,i),t[0]=i,t[1]=s);let c=!o&&a===`streaming`,l;t[2]!==r||t[3]!==c||t[4]!==n?(l=(0,L.jsx)(Y6,{elements:r,animated:Q6,isAnimating:c,children:n}),t[2]=r,t[3]=c,t[4]=n,t[5]=l):l=t[5];let u;return t[6]!==s||t[7]!==l?(u=(0,L.jsx)(`div`,{className:s,children:l}),t[6]=s,t[7]=l,t[8]=u):u=t[8],u}function r8(e){let t=(0,W.c)(8),{part:n}=e,r=i8(),i;t[0]!==n||t[1]!==r?(i=r&&(0,L.jsx)(I6,{part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=(0,L.jsx)(Z6,{part:n}),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,L.jsxs)(L.Fragment,{children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function i8(){let{debugMode:e}=b3(),t=B6();return!!e&&!t}function a8(e){return!!e&&e!==`output-available`}function o8(e){let t=(0,W.c)(5),{label:n,part:r,state:i}=e,a=B6(),o;return t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i?(o=!a&&!!n.actions&&!!r&&!a8(i),t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o}function s8(e){let t=(0,W.c)(18),{label:n,part:r}=e,i=n.icon,a=n.actions,o;t[0]!==n||t[1]!==r?(o={label:n,part:r,state:r.state},t[0]=n,t[1]=r,t[2]=o):o=t[2];let s=o8(o),c;t[3]!==i||t[4]!==n.isError?(c=i&&(0,L.jsx)(i,{className:P(`size-3.5`,n.isError?`text-destructive`:`text-muted-foreground`)}),t[3]=i,t[4]=n.isError,t[5]=c):c=t[5];let l;t[6]===n.name?l=t[7]:(l=(0,L.jsx)(`span`,{className:`font-mono`,children:n.name}),t[6]=n.name,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==a||t[12]!==r||t[13]!==s?(d=s&&a&&(0,L.jsx)(a,{part:r}),t[11]=a,t[12]=r,t[13]=s,t[14]=d):d=t[14];let f;return t[15]!==u||t[16]!==d?(f=(0,L.jsxs)(`div`,{className:`text-muted-foreground flex items-center justify-between gap-1.5 text-xs`,children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function c8(e){let t=(0,W.c)(3),{name:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,L.jsxs)(`span`,{"data-slot":`tool-arg`,children:[n,`: "`,r,`"`]}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function l8(e){let t=(0,W.c)(23),{label:n,state:r,part:i,children:a}=e,o=n.actions,s;t[0]!==n||t[1]!==i||t[2]!==r?(s={label:n,part:i,state:r},t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c=o8(s),l;t[4]===n.args?l=t[5]:(l=n.args?Object.entries(n.args).map(u8):`...`,t[4]=n.args,t[5]=l);let u;t[6]!==a||t[7]!==n.name||t[8]!==l?(u=(0,L.jsxs)(`span`,{className:`text-muted-foreground min-w-0 truncate font-mono text-xs [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:mr-1 [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:content-[',']`,children:[n.name,`(`,a,l,`)`]}),t[6]=a,t[7]=n.name,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==o||t[11]!==i||t[12]!==c?(d=c&&o&&i&&(0,L.jsx)(`span`,{className:`shrink-0`,children:(0,L.jsx)(o,{part:i})}),t[10]=o,t[11]=i,t[12]=c,t[13]=d):d=t[13];let f;t[14]!==u||t[15]!==d?(f=(0,L.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16];let p;t[17]!==n.detail||t[18]!==n.isError?(p=n.detail&&(0,L.jsx)(`span`,{className:P(`line-clamp-3 text-start font-mono text-[10px] leading-relaxed whitespace-pre-wrap`,n.isError?`text-destructive/80`:`text-muted-foreground`),children:n.detail}),t[17]=n.detail,t[18]=n.isError,t[19]=p):p=t[19];let m;return t[20]!==f||t[21]!==p?(m=(0,L.jsxs)(`span`,{className:`mb-2 flex flex-col gap-1`,children:[f,p]}),t[20]=f,t[21]=p,t[22]=m):m=t[22],m}function u8(e){let[t,n]=e;return(0,L.jsx)(c8,{name:t,value:n},t)}function d8(e){return e.type===`text`&&e.providerMetadata?.openai?.phase===`commentary`}function f8(e){let t=(0,W.c)(9),{segment:n,elements:r,className:i}=e,a;if(t[0]!==i||t[1]!==r||t[2]!==n.parts){let e;t[4]!==i||t[5]!==r?(e=e=>{let{part:t,idx:n}=e;return t.type===`text`?(0,L.jsx)(n8,{text:t.text,elements:r,className:i},`${n}-text`):null},t[4]=i,t[5]=r,t[6]=e):e=t[6],a=n.parts.map(e),t[0]=i,t[1]=r,t[2]=n.parts,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,L.jsx)(L.Fragment,{children:a}),t[7]=a,t[8]=o),o}function p8(e){let t=(0,W.c)(4),{segment:n}=e,{part:r}=n;if(r.type!==`file`)return null;let i;return t[0]!==r.filename||t[1]!==r.mediaType||t[2]!==r.url?(i=(0,L.jsx)(t8,{filename:r.filename,mediaType:r.mediaType,url:r.url}),t[0]=r.filename,t[1]=r.mediaType,t[2]=r.url,t[3]=i):i=t[3],i}function m8(e){let t=(0,W.c)(9),{segment:n}=e,{messages:r}=C3(),i;t[0]===r?i=t[1]:(i=w3(r),t[0]=r,t[1]=i);let a=i,o;if(t[2]!==n.parts||t[3]!==a){let e;t[5]===a?e=t[6]:(e=e=>{let{part:t,idx:n}=e;if(t.type!==`source-url`)return null;let r=T3(a,t.url);return r===null?null:(0,L.jsx)(L3,{source:{url:t.url,title:t.title},index:r},`source-${n}`)},t[5]=a,t[6]=e),o=n.parts.map(e),t[2]=n.parts,t[3]=a,t[4]=o}else o=t[4];let s;return t[7]===o?s=t[8]:(s=(0,L.jsx)(`span`,{children:o}),t[7]=o,t[8]=s),s}function h8(e){let t=(0,W.c)(3),{segment:n}=e,r=F3();if(B6())return null;let{part:i}=n;if(i.type!==`reasoning`)return null;let a=r===`streaming`,o;return t[0]!==i.text||t[1]!==a?(o=(0,L.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:(0,L.jsx)(C6,{animated:Q6,isAnimating:a,children:i.text})}),t[0]=i.text,t[1]=a,t[2]=o):o=t[2],o}function g8(e){let t=(0,W.c)(2),{segment:n}=e;if(!i8())return null;let{part:r}=n;if(r.type!==`dynamic-tool`)return null;let i;return t[0]===r?i=t[1]:(i=(0,L.jsx)(L6,{part:r}),t[0]=r,t[1]=i),i}var _8=(0,I.createContext)(null),v8=(0,I.createContext)(null);function y8(){let e=(0,I.use)(_8);if(!e)throw Error(`Segment.Tool* parts must be rendered within Segment.Tool`);return e}function b8(e){let t=(0,W.c)(29),{segment:n,children:r}=e,i=b3(),a=F3(),{part:o}=n;if(!__(o))return null;let s,c,l,u;t[0]!==i.registry||t[1]!==a||t[2]!==o?({toolEntry:u}=H6(o,i.registry),c=U6(u,o.state),s=!c&&D3(o,a),l=u?.label?.(o),t[0]=i.registry,t[1]=a,t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u):(s=t[3],c=t[4],l=t[5],u=t[6]);let d=l,f;t[7]!==s||t[8]!==d||t[9]!==o?(f=s?{...d??{name:b_(o)},isError:!0,detail:`Cancelled by user`}:d,t[7]=s,t[8]=d,t[9]=o,t[10]=f):f=t[10];let p=f,m=u?.static===!1&&!!u?.requiresUserInput&&!c,h;t[11]!==s||t[12]!==c||t[13]!==m||t[14]!==p||t[15]!==o?(h={part:o,label:p,aborted:s,activeClientInput:c,defaultOpen:m},t[11]=s,t[12]=c,t[13]=m,t[14]=p,t[15]=o,t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==p||t[19]!==o.state?(g={label:p,state:o.state,aborted:s},t[17]=s,t[18]=p,t[19]=o.state,t[20]=g):g=t[20];let _;t[21]===r?_=t[22]:(_=r??(0,L.jsx)(S8,{}),t[21]=r,t[22]=_);let v;t[23]!==g||t[24]!==_?(v=(0,L.jsx)(v8,{value:g,children:_}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let y;return t[26]!==h||t[27]!==v?(y=(0,L.jsx)(_8,{value:h,children:v}),t[26]=h,t[27]=v,t[28]=y):y=t[28],y}function x8(){let e=(0,W.c)(2),{part:t,activeClientInput:n}=y8();if(n)return null;let r;return e[0]===t?r=e[1]:(r=(0,L.jsx)(r8,{part:t}),e[0]=t,e[1]=r),r}function S8(e){let t=(0,W.c)(9),{children:n}=e,{part:r,label:i,defaultOpen:a}=y8();if(!i){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(x8,{})}),t[0]=e):e=t[0],e}let o;t[1]!==n||t[2]!==i||t[3]!==r?(o=(0,L.jsx)(qi,{className:`cursor-pointer`,children:(0,L.jsx)(l8,{label:i,state:r.state,part:r,children:n})}),t[1]=n,t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(Ji,{className:`mb-2`,children:(0,L.jsx)(x8,{})}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,L.jsxs)(Ki,{defaultOpen:a,className:`flex min-w-0 flex-1 flex-col`,children:[o,s]}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}var C8={Text:f8,File:p8,Source:m8,Reasoning:h8,DynamicTool:g8,Tool:b8,ToolDisclosure:S8,ToolContent:x8};function w8(e){return __(e)?`tool`:e.type===`dynamic-tool`?`dynamic-tool`:e.type===`reasoning`&&`text`in e&&e.text?`reasoning`:null}function T8(e,t){return e.kind===`text`||e.kind===`file`||e.kind===`source`?!1:e.kind===`reasoning`||e.kind!==`dynamic-tool`||!!t}function E8(e,t,n){let r=e[t+1];return!!r&&T8(r,n)}function D8(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=w8(r);if(i)t.push({kind:i,part:r,idx:n});else if(r.type===`text`){let e=t[t.length-1];e&&e.kind===`text`?e.parts.push({part:r,idx:n}):t.push({kind:`text`,parts:[{part:r,idx:n}]})}else if(r.type===`file`)t.push({kind:`file`,part:r,idx:n});else if(r.type===`source-url`){let e=t[t.length-1];e&&e.kind===`source`?e.parts.push({part:r,idx:n}):t.push({kind:`source`,parts:[{part:r,idx:n}]})}}return t}function O8(e,t){return e.kind===`text`||e.kind===`source`?e.parts[0]?.idx??t:e.idx}(0,I.memo)(function(e){let t=(0,W.c)(8),{segment:n}=e;if(n.kind===`tool`){let e;return t[0]===n?e=t[1]:(e=(0,L.jsx)(C8.Tool,{segment:n}),t[0]=n,t[1]=e),e}if(n.kind===`reasoning`){let e;return t[2]===n?e=t[3]:(e=(0,L.jsx)(C8.Reasoning,{segment:n}),t[2]=n,t[3]=e),e}if(n.kind===`text`){let e;return t[4]===n?e=t[5]:(e=(0,L.jsx)(C8.Text,{segment:n,className:`text-xs`}),t[4]=n,t[5]=e),e}if(n.kind===`file`){let e;return t[6]===n?e=t[7]:(e=(0,L.jsx)(C8.File,{segment:n}),t[6]=n,t[7]=e),e}return null},k8);function k8(e,t){return e.complete&&t.complete&&e.cacheKey===t.cacheKey}function A8(e){let t=(0,W.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({icon:r,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a={scale:.94},t[4]=a):a=t[4];let o;t[5]===n?o=t[6]:(o=P(`group text-muted-foreground hover:text-foreground relative rounded-lg p-2 transition-colors`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(`span`,{className:`bg-primary/10 absolute inset-0 rounded-lg opacity-0 transition-opacity group-hover:opacity-100`}),t[7]=s):s=t[7];let c;return t[8]!==r||t[9]!==i||t[10]!==o?(c=(0,L.jsxs)(MA.button,{type:`button`,whileTap:a,className:o,...i,children:[r,s]}),t[8]=r,t[9]=i,t[10]=o,t[11]=c):c=t[11],c}function j8(){let{index:e}=I3(),{messages:t}=P3(),n=F3();return!(e===t.length-1&&(n===`submitted`||n===`streaming`||n===`error`))}function M8(e){let t=(0,W.c)(5),{className:n,children:r}=e;if(!j8()||I.Children.toArray(r).length===0)return null;let i;t[0]===n?i=t[1]:(i=P(`mt-1 flex items-center gap-0.5`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,L.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function N8(e){let t=(0,W.c)(12),{className:n}=e,{message:r}=I3(),[i,a]=w6(),o=i?`Copied`:`Copy message`,s;t[0]===n?s=t[1]:(s=P(`p-1.5`,n),t[0]=n,t[1]=s);let c;t[2]!==a||t[3]!==r?(c=()=>void a(z6(r)),t[2]=a,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,L.jsx)(i?je:mr,{className:`size-3.5`}),t[5]=i,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,L.jsx)(A8,{"aria-label":o,className:s,onClick:c,icon:l}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function P8(e){let t=(0,W.c)(9),{className:n}=e,{message:r}=I3(),{regenerate:i}=C3(),a;t[0]===n?a=t[1]:(a=P(`p-1.5`,n),t[0]=n,t[1]=a);let o;t[2]!==r.id||t[3]!==i?(o=()=>void i({messageId:r.id}),t[2]=r.id,t[3]=i,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(Pr,{className:`size-3.5`}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,L.jsx)(A8,{"aria-label":`Regenerate response`,className:a,onClick:o,icon:s}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function F8(e){let t=(0,W.c)(12),{className:n}=e,{message:r}=I3(),[i,a]=w6(),o=i?`Copied`:`Copy debug JSON`,s;t[0]===n?s=t[1]:(s=P(`p-1.5`,n),t[0]=n,t[1]=s);let c;t[2]!==a||t[3]!==r?(c=()=>void a(JSON.stringify(r,null,2)),t[2]=a,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,L.jsx)(i?je:Dn,{className:`size-3.5`}),t[5]=i,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,L.jsx)(A8,{"aria-label":o,className:s,onClick:c,icon:l}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function I8(e){let t=(0,W.c)(7),{onTryAgain:n,error:r}=e,i=r instanceof Error?r.message:`An error occurred. Please try again.`,a;t[0]===i?a=t[1]:(a=(0,L.jsx)(`div`,{className:`text-destructive text-sm`,children:(0,L.jsx)(C6,{mode:`static`,children:i})}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,L.jsx)(at,{type:`button`,onClick:n,size:`sm`,variant:`outline`,children:`Try Again`}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,L.jsx)(`div`,{className:`mt-3 flex justify-start`,children:(0,L.jsxs)(`div`,{className:`max-w-[80%] space-y-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s}function L8(e){let t=(0,W.c)(3),{error:n,onRetry:r}=e;if(!n||!r)return null;let i;return t[0]!==n||t[1]!==r?(i=(0,L.jsx)(I8,{onTryAgain:r,error:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function R8(e){let t=(0,W.c)(14),{messages:n,className:r,elements:i,status:a,children:o}=e,s;t[0]!==i||t[1]!==n||t[2]!==a?(s={messages:n,elements:i,status:a},t[0]=i,t[1]=n,t[2]=a,t[3]=s):s=t[3];let c=s,l;t[4]===r?l=t[5]:(l=P(`flex h-full flex-col`,r),t[4]=r,t[5]=l);let u;t[6]===o?u=t[7]:(u=(0,L.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col`,children:o}),t[6]=o,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,L.jsx)(`div`,{className:l,children:u}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;return t[11]!==d||t[12]!==c?(f=(0,L.jsx)(M3,{value:c,children:d}),t[11]=d,t[12]=c,t[13]=f):f=t[13],f}function z8(e){let t=(0,W.c)(5),{className:n,children:r}=e,i;t[0]===n?i=t[1]:(i=P(`flex flex-col gap-4`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,L.jsx)(`div`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function B8(e){let t=(0,W.c)(9),{message:n,index:r,className:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o={message:n,index:r},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]!==a||t[4]!==i?(c=(0,L.jsx)(`div`,{className:i,children:a}),t[3]=a,t[4]=i,t[5]=c):c=t[5];let l;return t[6]!==c||t[7]!==s?(l=(0,L.jsx)(N3,{value:s,children:c}),t[6]=c,t[7]=s,t[8]=l):l=t[8],l}function V8(){let e=(0,W.c)(5),{registry:t}=b3(),n=C3().messages,r;if(e[0]!==n||e[1]!==t){bb0:{if(!t){r=null;break bb0}let i=n.findLast(H8);if(!i){r=null;break bb0}let a;e[3]===t?a=e[4]:(a=e=>{if(!__(e)||e.state!==`input-available`)return[];let n=t[b_(e)];return!n||n.static!==!1||!n.requiresUserInput?[]:[{part:e,entry:n}]},e[3]=t,e[4]=a),r=i.parts.flatMap(a).at(0)??null}e[0]=n,e[1]=t,e[2]=r}else r=e[2];return r}function H8(e){let{role:t}=e;return t===`assistant`}function U8(e){let t=(0,W.c)(10),{children:n,className:r}=e,i=V8(),a=i?.entry.component,o=i?`hidden`:`visible`,s;t[0]!==n||t[1]!==o?(s=(0,L.jsx)(I.Activity,{mode:o,children:n}),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==a||t[4]!==i||t[5]!==r?(c=i&&a?(0,L.jsx)(`div`,{className:P(`sticky bottom-0 mt-auto`,r),children:(0,L.jsx)(a,{part:i.part},i.part.toolCallId)}):null,t[3]=a,t[4]=i,t[5]=r,t[6]=c):c=t[6];let l;return t[7]!==s||t[8]!==c?(l=(0,L.jsxs)(L.Fragment,{children:[s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function W8(e,t){if(e===`error`||e===`ready`||!t)return null;if(t.role!==`assistant`)return`Thinking...`;for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(h_(n)&&d8(n)&&n.text)return n.text}for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(g_(n)&&n.text)return n.text;if(y_(n)){let e=n.input;if(Nm(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return n.toolCallId}if(h_(n)&&n.text)return``}return`Thinking...`}function G8(e){let t=(0,W.c)(5),{isLast:n}=e,r=n!==void 0&&n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,L.jsx)(`span`,{className:`bg-muted-foreground/50 z-10 mt-1 size-2 shrink-0 rounded-full`}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=!r&&(0,L.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[1]=r,t[2]=a);let o;return t[3]===a?o=t[4]:(o=(0,L.jsxs)(`div`,{className:`absolute top-0 left-0 flex size-3.5 h-full flex-col items-center`,children:[i,a]}),t[3]=a,t[4]=o),o}function K8(e){let t=(0,W.c)(6),{marker:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=P(`relative z-0 flex gap-3 pl-5`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==n||t[4]!==a?(o=(0,L.jsxs)(`div`,{className:a,children:[n,r]}),t[2]=r,t[3]=n,t[4]=a,t[5]=o):o=t[5],o}function q8(){let e=(0,W.c)(6),t=F3(),{messages:n}=P3(),r=V8(),i=n[n.length-1],a;e[0]!==t||e[1]!==i?(a=W8(t,i),e[0]=t,e[1]=i,e[2]=a):a=e[2];let o=a;if(!o||r)return null;let s;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(G8,{isLast:!0}),e[3]=s):s=e[3];let c;return e[4]===o?c=e[5]:(c=(0,L.jsx)(K8,{className:`mt-2`,marker:s,children:(0,L.jsx)(`span`,{role:`status`,children:(0,L.jsx)(k3,{as:`span`,className:`text-muted-foreground line-clamp-2 font-mono text-xs`,children:o})})}),e[4]=o,e[5]=c),c}var J8=[`inputTokens`,`outputTokens`,`reasoningTokens`,`cachedInputTokens`,`totalTokens`],Y8={inputTokens:[[`inputTokens`],[`raw`,`prompt_tokens`]],outputTokens:[[`outputTokens`],[`raw`,`completion_tokens`]],reasoningTokens:[[`reasoningTokens`],[`outputTokenDetails`,`reasoningTokens`],[`raw`,`completion_tokens_details`,`reasoning_tokens`]],cachedInputTokens:[[`inputTokenDetails`,`cacheReadTokens`],[`cachedInputTokens`],[`inputTokenDetails`,`cachedTokens`],[`raw`,`prompt_tokens_details`,`cached_tokens`]],totalTokens:[[`totalTokens`],[`raw`,`total_tokens`]]};function X8(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e==`string`&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>=0)return t}return null}function Z8(e){if(!e||typeof e!=`object`)return null;let t={inputTokens:null,outputTokens:null,reasoningTokens:null,cachedInputTokens:null,totalTokens:null};for(let n of J8)for(let r of Y8[n]){let i=X8(q4(e,r));if(i!==null){t[n]=i;break}}return J8.some(e=>t[e]!==null)?t:null}function Q8(e){return Nm(e)?Z8(e.totalUsage??e.usage):null}function $8(e){let t=[`↑ ${Z4(e.inputTokens)}`,`↓ ${Z4(e.outputTokens)}`];return e.totalTokens!==null&&t.push(`· ${X4(e.totalTokens)} tokens`),e.cachedInputTokens!==null&&e.cachedInputTokens>0&&t.push(`(${Z4(e.cachedInputTokens)} cached)`),t.join(` `)}var e5=`x-upload-filename`,t5=Se({path:F().startsWith(`/`),name:F().min(1),mediaType:Gt([`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/heic`,`image/heif`,`video/mp4`,`video/quicktime`,`audio/mpeg`,`audio/mp4`,`audio/wav`]),size:st().nonnegative(),url:ge()}),n5=class extends xv{sessionsApi;request;constructor({api:e,fetch:t=(e,t)=>globalThis.fetch(e,t),tools:n={},elements:r=[]}){let i=o5(e),a=r.map(JA);super({api:i,fetch:async(e,n)=>{let r=await t(e,n);if((n?.method??`GET`).toUpperCase()!==`POST`||!r.ok)return r;let i=await r.json();if(!s5(i))throw Error(`Zukhruf returned an invalid accepted-turn response`);let a=o5(String(e)),o=decodeURIComponent(a.slice(a.lastIndexOf(`/`)+1));if(i.sessionId!==o)throw Error(`Zukhruf returned a different session ID`);let s=n?.signal;return s?.addEventListener(`abort`,()=>{t(`${a}/cancel`,{method:`POST`})},{once:!0}),t(`${a}/stream`,{headers:{accept:`text/event-stream`},method:`GET`,signal:s})},prepareSendMessagesRequest:({id:e,messages:t,trigger:r})=>{let o=t[t.length-1];if(!o)throw Error(`A message is required`);return{api:r5(i,e),body:{sessionId:e,message:o,trigger:r,...Object.keys(n).length>0?{tools:n}:{},...a.length>0?{elements:a}:{}}}},prepareReconnectToStreamRequest:({headers:e,id:t})=>({api:`${r5(i,t)}/stream`,headers:e})}),this.sessionsApi=i,this.request=t}async uploadFile(e,t){let n=await this.request(`${r5(this.sessionsApi,e)}/uploads`,{method:`POST`,headers:{"content-type":t.type,[e5]:encodeURIComponent(t.name)},body:t});if(!n.ok)throw Error(await i5(n,t));let r=t5.safeParse(await n.json());if(!r.success)throw Error(`Zukhruf returned an invalid upload response`);return r.data}};function r5(e,t){return`${e}/${encodeURIComponent(t)}`}async function i5(e,t){let n=`Uploading ${t.name} failed with HTTP ${e.status}`,r=a5(await e.json().catch(e=>{if(e instanceof SyntaxError)return null;throw e}));return r?`${n}: ${r}`:n}function a5(e){if(typeof e!=`object`||!e)return null;let t=`cause`in e&&typeof e.cause==`object`&&e.cause!==null?e.cause:null;return[t&&`code`in t&&typeof t.code==`string`?t.code:null,t&&`detail`in t&&typeof t.detail==`string`?t.detail:`error`in e&&typeof e.error==`string`?e.error:null].filter(e=>e!==null).join(` — `)||null}function o5(e){return e.replace(/\/$/,``)}function s5(e){return typeof e==`object`&&!!e&&`ok`in e&&e.ok===!0&&`sessionId`in e&&typeof e.sessionId==`string`&&`turnId`in e&&typeof e.turnId==`string`}function c5(e){let t=(0,W.c)(24),{label:n,open:r,onOpenChange:i,children:a,className:o,triggerClassName:s,contentClassName:c,chevronClassName:l}=e,u;t[0]===s?u=t[1]:(u=P(`flex items-center font-mono`,s),t[0]=s,t[1]=u);let d;t[2]===u?d=t[3]:(d=(0,L.jsx)(`button`,{type:`button`,className:u}),t[2]=u,t[3]=d);let f=r&&`rotate-180`,p;t[4]!==l||t[5]!==f?(p=P(`size-4 transition-transform`,l,f),t[4]=l,t[5]=f,t[6]=p):p=t[6];let m;t[7]===p?m=t[8]:(m=(0,L.jsx)(me,{className:p}),t[7]=p,t[8]=m);let h;t[9]===n?h=t[10]:(h=(0,L.jsx)(`span`,{children:n}),t[9]=n,t[10]=h);let g;t[11]!==d||t[12]!==m||t[13]!==h?(g=(0,L.jsxs)(qi,{render:d,children:[m,h]}),t[11]=d,t[12]=m,t[13]=h,t[14]=g):g=t[14];let _;t[15]!==a||t[16]!==c?(_=(0,L.jsx)(Ji,{className:c,children:a}),t[15]=a,t[16]=c,t[17]=_):_=t[17];let v;return t[18]!==o||t[19]!==i||t[20]!==r||t[21]!==g||t[22]!==_?(v=(0,L.jsxs)(Ki,{open:r,onOpenChange:i,className:o,children:[g,_]}),t[18]=o,t[19]=i,t[20]=r,t[21]=g,t[22]=_,t[23]=v):v=t[23],v}function l5(e){let t=(0,W.c)(7),{metadata:n}=e;if(!n)return null;let r,i,a;if(t[0]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Q8(n);if(!e){a=null;break bb0}r=`text-muted-foreground mt-2 text-xs tabular-nums opacity-60`,i=$8(e)}t[0]=n,t[1]=r,t[2]=i,t[3]=a}else r=t[1],i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o;return t[4]!==r||t[5]!==i?(o=(0,L.jsx)(`div`,{className:r,children:i}),t[4]=r,t[5]=i,t[6]=o):o=t[6],o}function u5(e,t){return Nm(e.metadata)?e.metadata[t]:void 0}function d5(e){let t=u5(e,`reminders`);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.text==`string`&&t.text.trim().length>0}):[]}function f5(e){let t=u5(e,`uploads`);return Array.isArray(t)?t.flatMap(e=>{let t=t5.safeParse(e);return t.success?[t.data]:[]}):[]}function p5(e){let t=(0,W.c)(7),{text:n}=e,[r,i]=(0,I.useState)(!1),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>i(m5),t[0]=a):a=t[0];let o=!r&&`line-clamp-3`,s;t[1]===o?s=t[2]:(s=P(`hover:text-foreground w-full cursor-pointer text-left whitespace-pre-wrap`,o),t[1]=o,t[2]=s);let c;return t[3]!==r||t[4]!==s||t[5]!==n?(c=(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":r,className:s,children:n})}),t[3]=r,t[4]=s,t[5]=n,t[6]=c):c=t[6],c}function m5(e){return!e}function h5(e){let t=(0,W.c)(8),{reminders:n}=e,[r,i]=(0,I.useState)(!1);if(n.length===0)return null;let a=`${n.length} reminder${n.length===1?``:`s`} attached`,o;t[0]===n?o=t[1]:(o=n.map(g5),t[0]=n,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,L.jsx)(`ul`,{className:`border-ink-12 text-muted-foreground space-y-1 border-l pl-3 text-xs`,children:o}),t[2]=o,t[3]=s);let c;return t[4]!==a||t[5]!==r||t[6]!==s?(c=(0,L.jsx)(c5,{label:a,open:r,onOpenChange:i,className:`mt-1`,triggerClassName:`text-muted-foreground hover:text-foreground gap-1.5 text-xs`,contentClassName:`mt-1.5`,chevronClassName:`size-3.5`,children:s}),t[4]=a,t[5]=r,t[6]=s,t[7]=c):c=t[7],c}function g5(e){return(0,L.jsx)(p5,{text:e.text},e.id)}function _5(e){let t=(0,W.c)(19),{upload:n}=e;if(n.mediaType.startsWith(`video/`)){let e;t[0]!==n.name||t[1]!==n.url?(e=(0,L.jsx)(`video`,{src:n.url,"aria-label":n.name,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full object-cover`}),t[0]=n.name,t[1]=n.url,t[2]=e):e=t[2];let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,L.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center text-2xl text-white drop-shadow`,children:`▶`}),t[3]=r):r=t[3];let i;return t[4]!==e||t[5]!==n.name?(i=(0,L.jsxs)(oi,{variant:`image`,className:`size-36 rounded-2xl`,title:n.name,children:[e,r]}),t[4]=e,t[5]=n.name,t[6]=i):i=t[6],i}if(n.mediaType.startsWith(`audio/`)){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-2xl`,children:`♪`}),t[7]=e):e=t[7];let r;t[8]===n.name?r=t[9]:(r=(0,L.jsx)(`span`,{className:`text-foreground w-full truncate text-center`,children:n.name}),t[8]=n.name,t[9]=r);let i;t[10]===n.mediaType?i=t[11]:(i=(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:n.mediaType}),t[10]=n.mediaType,t[11]=i);let a;return t[12]!==r||t[13]!==i||t[14]!==n.name?(a=(0,L.jsxs)(oi,{variant:`icon`,className:`h-36 w-48 flex-col gap-1 rounded-2xl px-3 text-xs`,title:n.name,"aria-label":n.name,children:[e,r,i]}),t[12]=r,t[13]=i,t[14]=n.name,t[15]=a):a=t[15],a}let r;return t[16]!==n.name||t[17]!==n.url?(r=(0,L.jsx)(oi,{variant:`image`,className:`size-36 rounded-2xl`,children:(0,L.jsx)(`img`,{src:n.url,alt:n.name})}),t[16]=n.name,t[17]=n.url,t[18]=r):r=t[18],r}function v5(e){let t=(0,W.c)(13),{message:n}=e,r,i,a,o,s,c;if(t[0]!==n){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=f5(n);if(e.length===0){c=null;break bb0}r=si,i=`list`,a=`Attached files`,o=`max-w-full gap-2 py-0`,s=e.map(y5)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;return t[7]!==r||t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==s?(l=(0,L.jsx)(r,{role:i,"aria-label":a,className:o,children:s}),t[7]=r,t[8]=i,t[9]=a,t[10]=o,t[11]=s,t[12]=l):l=t[12],l}function y5(e){return(0,L.jsx)(`div`,{role:`listitem`,"data-slot":`attachment`,children:(0,L.jsx)(_5,{upload:e})},e.path)}function b5(e){let t=(0,W.c)(10),{body:n,reminders:r,metadata:i}=e,a;t[0]===n?a=t[1]:(a=(0,L.jsx)(`div`,{className:`flex-1 space-y-3`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,L.jsx)(h5,{reminders:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i!==void 0&&(0,L.jsx)(l5,{metadata:i}),t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,L.jsxs)(`div`,{className:`bg-secondary flex max-w-[80%] flex-col gap-3 rounded-lg p-3`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function x5(e){let t=(0,W.c)(28),{message:n}=e;u5(n,`reminders`);let r;t[0]===n?r=t[1]:(r=Iy(n),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=d5(n),t[2]=n,t[3]=i);let a;t[4]!==r||t[5]!==i?(a={message:r,reminders:i},t[4]=r,t[5]=i,t[6]=a):a=t[6];let{message:o,reminders:s}=a,c;if(t[7]!==n){let e=u5(n,`alias`);c=typeof e==`string`&&e.trim().length>0?e:void 0,t[7]=n,t[8]=c}else c=t[8];let l=c;if(l){let e;t[9]===l?e=t[10]:(e=(0,L.jsx)(`div`,{className:`text-sm whitespace-pre-wrap`,children:l}),t[9]=l,t[10]=e);let n;return t[11]!==s||t[12]!==e?(n=(0,L.jsx)(b5,{reminders:s,body:e}),t[11]=s,t[12]=e,t[13]=n):n=t[13],n}let u;t[14]===o?u=t[15]:(u=(0,L.jsx)(v5,{message:o}),t[14]=o,t[15]=u);let d=o.metadata,f;if(t[16]!==o.id||t[17]!==o.parts){let e;t[19]===o.id?e=t[20]:(e=(e,t)=>e.type===`text`?(0,L.jsx)(`div`,{className:`text-sm whitespace-pre-wrap`,children:(0,L.jsx)(c2,{text:e.text})},`${o.id}-${t}-text`):null,t[19]=o.id,t[20]=e),f=o.parts.map(e),t[16]=o.id,t[17]=o.parts,t[18]=f}else f=t[18];let p;t[21]!==o.metadata||t[22]!==s||t[23]!==f?(p=(0,L.jsx)(b5,{reminders:s,metadata:d,body:f}),t[21]=o.metadata,t[22]=s,t[23]=f,t[24]=p):p=t[24];let m;return t[25]!==u||t[26]!==p?(m=(0,L.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-end gap-3`,children:[u,p]}),t[25]=u,t[26]=p,t[27]=m):m=t[27],m}var S5=(0,I.memo)(function(e){let t=(0,W.c)(7),{className:n}=e,{message:r}=I3(),i;t[0]===n?i=t[1]:(i=P(`flex justify-end`,n),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,L.jsx)(x5,{message:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,L.jsx)(`div`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o});function C5(e){return e.kind===`tool`?!V6(e.part):e.kind===`dynamic-tool`||e.kind===`reasoning`}function w5(e,t){return e.kind===`tool`?!0:e.kind===`reasoning`||e.kind===`dynamic-tool`?!!t:!1}function T5(e){return e.kind===`text`&&e.parts.some(({part:e})=>e.type===`text`&&!d8(e))}function E5(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(!C5(i)){n.push({kind:`segment`,segment:i,segmentIndex:r});continue}let a=[],o=r;for(;r<e.length&&C5(e[r]);){let n=e[r];w5(n,t)&&a.push({segment:n}),r++}r--,a.length>0&&n.push({kind:`group`,items:a,hasLaterText:e.slice(r+1).some(e=>T5(e)),firstIndex:o})}return n}function D5(e){if(e.kind!==`tool`&&e.kind!==`dynamic-tool`)return;let{part:t}=e;return y_(t)?t.state:void 0}function O5({groupStatus:e,labelCount:t}){return e===`running`?{title:`text-info`,detail:`text-info/80`,chevron:`text-info`}:e===`aborted`?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:e===`error`?t===1?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:{title:`text-warning`,detail:`text-warning/80`,chevron:`text-warning`}:{title:`text-muted-foreground`,detail:`text-muted-foreground`,chevron:`text-muted-foreground`}}function k5(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A5(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-3).trimEnd()}...`}function j5(e){if(typeof e==`string`)return A5(e,48);if(typeof e==`number`||typeof e==`boolean`)return String(e);if(Array.isArray(e))return`${e.length} items`}function M5(e){if(!k5(e))return;let t=[`command`,`query`,`path`,`file`,`table`,`metric`,`dimension`,`checks`],n=[...t.filter(t=>t in e).map(t=>[t,e[t]]),...Object.entries(e).filter(([e])=>!t.includes(e))],r={};for(let[e,t]of n){let n=j5(t);if(n&&(r[e]=n,Object.keys(r).length>=2))break}return Object.keys(r).length>0?r:void 0}function N5(e){if(k5(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim().length>0)return A5(n)}}function P5(e){if(e.kind!==`reasoning`)return;let{part:t}=e;if(t.type===`reasoning`)return A5(t.text,96)}function F5(e,t){if(e.kind===`reasoning`)return{kind:`reasoning`,name:`reasoning`,detail:P5(e)};if(e.kind===`dynamic-tool`&&e.part.type===`dynamic-tool`){let t=e.part;return{kind:`dynamic-tool`,name:t.toolName||`Tool`,args:M5(t.input),detail:N5(t.input)}}if(e.kind===`tool`&&__(e.part)){let n=e.part,{toolEntry:r,toolKey:i}=H6(n,t),a=r?.label?.(n);return{kind:`tool`,name:a?.name??i,args:a?.args??M5(n.input),detail:a?.detail??N5(n.input),isError:a?.isError}}return{kind:`tool`,name:`Step`}}function I5(e){if(!e)return;let t=Object.entries(e).filter(e=>typeof e[1]==`string`&&e[1].trim().length>0);if(t.length!==0)return t.slice(0,2).map(([e,t])=>`${e}: ${A5(t,36)}`).join(`, `)}function L5(e){let t=I5(e.args);return t?`${e.name}(${t})`:e.name}function R5(e){return e===`output-available`||e===`output-error`||e===`output-denied`}function z5(e){return!!e&&!R5(e)}function B5(e,t){return E3(e,t)}function V5({items:e,labels:t,status:n,hasLaterText:r}){return e.some(({segment:e})=>B5(D5(e),n))?`aborted`:!r&&(n===`streaming`||n===`submitted`)?`running`:t.some(e=>e.isError)||e.some(({segment:e})=>{let t=D5(e);return t===`output-error`||t===`output-denied`})?`error`:e.some(({segment:e})=>z5(D5(e)))||!r&&t.every(e=>e.kind===`reasoning`)&&(n===`streaming`||n===`submitted`)?`running`:`complete`}function H5(e){return e&&`${e[0].toUpperCase()}${e.slice(1)}`}function U5(e){return e.filter(e=>e.kind!==`reasoning`).length}function W5(e,t){let n=U5(e);if(n!==0)return`${t===`running`||t===`aborted`?`running`:`ran`} ${n} ${n===1?`tool`:`tools`}`}function G5(e,t){let n=W5(e,t);if(n)return H5(t===`error`?`${n} with issues`:t===`aborted`?`cancelled after ${n}`:n)}function K5(e,t,n){let r=e.length===1?e[0]:void 0;if(t===`running`)return n||(r?.kind===`reasoning`?`Reasoning${r.detail?` ${r.detail}`:``}`:e.every(e=>e.kind===`reasoning`)?`Reasoning`:`Working...`);if(r){let e=L5(r);return t===`error`?`Failed ${e}`:t===`aborted`?`Cancelled ${e}`:r.kind===`reasoning`?`Reasoned${r.detail?` ${r.detail}`:``}`:`Called ${e}`}return e.every(e=>e.kind===`reasoning`)?`Reasoned`:G5(e,t)??`Ran tools`}function q5(e,t){if(t!==`running`){if(e.length===1){let t=e[0];return t.kind===`reasoning`?void 0:t.detail}return Array.from(new Set([...e].sort((e,t)=>e.kind===`reasoning`&&t.kind!==`reasoning`?1:e.kind!==`reasoning`&&t.kind===`reasoning`?-1:0).map(e=>e.name))).slice(0,3).join(`, `)||void 0}}function J5(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].segment;if(r.kind===`dynamic-tool`&&r.part.type===`dynamic-tool`){let e=N5(r.part.input);if(e)return e}if(r.kind===`tool`&&__(r.part)){let e=N5(r.part.input);if(e)return e}r.kind===`reasoning`&&(t??=P5(r))}return t}function Y5(e,t){return!e||e.role!==`assistant`?!1:E5(D8(e.parts),t).some(e=>e.kind===`group`&&!e.hasLaterText)}function X5(){let e=(0,W.c)(8),{message:t}=I3(),{debugMode:n}=b3(),r;e[0]===t.parts?r=e[1]:(r=D8(t.parts),e[0]=t.parts,e[1]=r);let i=r,a;if(e[2]!==n||e[3]!==t.id||e[4]!==i){let r;e[6]===t.id?r=e[7]:(r=e=>e.kind===`group`?{...e,key:`${t.id}-${e.firstIndex}-group-${e.hasLaterText?`past`:`current`}`}:{...e,key:`${t.id}-${O8(e.segment,e.segmentIndex)}-${e.segment.kind}`},e[6]=t.id,e[7]=r),a=E5(i,n).map(r),e[2]=n,e[3]=t.id,e[4]=i,e[5]=a}else a=e[5];return a}var Z5=(0,I.createContext)(null);function Q5(){let e=(0,I.use)(Z5);if(!e)throw Error(`CompactTrajectory group parts must be rendered within CompactTrajectory.Group`);return e}function $5(e){let t=(0,W.c)(21),{group:n,children:r}=e,{registry:i}=b3(),{message:a}=I3(),o=F3(),[s,c]=(0,I.useState)(!n.hasLaterText),l,u,d;if(t[0]!==n.hasLaterText||t[1]!==n.items||t[2]!==i||t[3]!==o){let e;t[7]===i?e=t[8]:(e=e=>{let{segment:t}=e;return F5(t,i)},t[7]=i,t[8]=e),u=n.items.map(e),l=V5({items:n.items,labels:u,status:o,hasLaterText:n.hasLaterText}),d=O5({groupStatus:l,labelCount:u.length}),t[0]=n.hasLaterText,t[1]=n.items,t[2]=i,t[3]=o,t[4]=l,t[5]=u,t[6]=d}else l=t[4],u=t[5],d=t[6];let f=d,p;t[9]!==n.items||t[10]!==l||t[11]!==u||t[12]!==a.id||t[13]!==f?(p={items:n.items,labels:u,groupStatus:l,tone:f,messageId:a.id},t[9]=n.items,t[10]=l,t[11]=u,t[12]=a.id,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==r||t[16]!==s?(m=(0,L.jsx)(Ki,{open:s,onOpenChange:c,className:`my-2 min-w-0`,children:r}),t[15]=r,t[16]=s,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,L.jsx)(Z5,{value:p,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function e7(e){let t=(0,W.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,L.jsx)(`button`,{type:`button`,className:j3(`items-start`)}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,L.jsx)(qi,{render:r,children:(0,L.jsx)(`span`,{className:`min-w-0 flex-1 text-left text-sm`,children:n})}),t[1]=n,t[2]=i),i}function t7(){let e=(0,W.c)(12),{items:t,labels:n,groupStatus:r,tone:i}=Q5(),a;e[0]!==r||e[1]!==t||e[2]!==n?(a=K5(n,r,J5(t)),e[0]=r,e[1]=t,e[2]=n,e[3]=a):a=e[3];let o=a,s;e[4]!==r||e[5]!==n?(s=q5(n,r),e[4]=r,e[5]=n,e[6]=s):s=e[6];let c=s,l;return e[7]!==c||e[8]!==r||e[9]!==o||e[10]!==i?(l={title:o,detail:c,tone:i,groupStatus:r},e[7]=c,e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}function n7(e){let t=(0,W.c)(9),{title:n,suffix:r,children:i}=e,{title:a,tone:o,groupStatus:s}=t7(),c=n??a,l=r?`${c} · ${r}`:c,u=s===`running`,d=s===`running`?`text-info`:o.title,f;t[0]===d?f=t[1]:(f=P(`max-w-full min-w-0 truncate`,d),t[0]=d,t[1]=f);let p;t[2]!==u||t[3]!==f||t[4]!==l?(p=(0,L.jsx)(k3,{as:`span`,enabled:u,className:f,children:l}),t[2]=u,t[3]=f,t[4]=l,t[5]=p):p=t[5];let m;return t[6]!==i||t[7]!==p?(m=(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[p,i]}),t[6]=i,t[7]=p,t[8]=m):m=t[8],m}function r7(){let e=(0,W.c)(2),{tone:t}=Q5(),n;return e[0]===t.chevron?n=e[1]:(n=(0,L.jsx)(A3,{className:t.chevron}),e[0]=t.chevron,e[1]=n),n}function i7(e){let t=(0,W.c)(5),{detail:n}=e,{title:r,detail:i,tone:a}=t7();if(n===null)return null;let o=n??i;if(!o||o===r)return null;let s;t[0]===a.detail?s=t[1]:(s=P(`block truncate text-xs`,a.detail),t[0]=a.detail,t[1]=s);let c;return t[2]!==o||t[3]!==s?(c=(0,L.jsx)(`span`,{className:s,children:o}),t[2]=o,t[3]=s,t[4]=c):c=t[4],c}function a7(e){let t=(0,W.c)(14),{children:n}=e,{items:r,messageId:i,groupStatus:a}=Q5(),o=a===`running`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={initial:`instant`,resize:`instant`},t[0]=s):s=t[0];let{scrollRef:c,contentRef:l}=RA(s),u=o?c:void 0,d=o&&`max-h-64 overflow-y-auto`,f;t[1]===d?f=t[2]:(f=P(`mt-2`,d),t[1]=d,t[2]=f);let p=o?l:void 0,m;t[3]!==n||t[4]!==r||t[5]!==i?(m=n??r.map((e,t)=>{let{segment:n}=e,r=`${i}-${O8(n,t)}-${n.kind}`;return n.kind===`tool`?(0,L.jsx)(C8.Tool,{segment:n},r):n.kind===`reasoning`?(0,L.jsx)(C8.Reasoning,{segment:n},r):n.kind===`dynamic-tool`?(0,L.jsx)(C8.DynamicTool,{segment:n},r):null}),t[3]=n,t[4]=r,t[5]=i,t[6]=m):m=t[6];let h;t[7]!==p||t[8]!==m?(h=(0,L.jsx)(`div`,{ref:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;return t[10]!==u||t[11]!==f||t[12]!==h?(g=(0,L.jsx)(Ji,{ref:u,className:f,children:h}),t[10]=u,t[11]=f,t[12]=h,t[13]=g):g=t[13],g}function o7(e){let t=(0,W.c)(19),{item:n,textClassName:r}=e,i=r===void 0?`my-4`:r,{elements:a}=P3(),{segment:o}=n;if(o.kind===`text`){let e;t[0]===o.parts?e=t[1]:(e=o.parts.filter(s7),t[0]=o.parts,t[1]=e);let n=e;if(n.length===0)return null;let r;t[2]!==o||t[3]!==n?(r={...o,parts:n},t[2]=o,t[3]=n,t[4]=r):r=t[4];let s;return t[5]!==a||t[6]!==r||t[7]!==i?(s=(0,L.jsx)(C8.Text,{segment:r,elements:a,className:i}),t[5]=a,t[6]=r,t[7]=i,t[8]=s):s=t[8],s}if(o.kind===`file`){let e;return t[9]===o?e=t[10]:(e=(0,L.jsx)(C8.File,{segment:o}),t[9]=o,t[10]=e),e}if(o.kind===`source`){let e;return t[11]===o?e=t[12]:(e=(0,L.jsx)(C8.Source,{segment:o}),t[11]=o,t[12]=e),e}if(o.kind===`tool`){let e;return t[13]===o?e=t[14]:(e=(0,L.jsx)(C8.Tool,{segment:o}),t[13]=o,t[14]=e),e}if(o.kind===`reasoning`){let e;return t[15]===o?e=t[16]:(e=(0,L.jsx)(C8.Reasoning,{segment:o}),t[15]=o,t[16]=e),e}if(o.kind===`dynamic-tool`){let e;return t[17]===o?e=t[18]:(e=(0,L.jsx)(C8.DynamicTool,{segment:o}),t[17]=o,t[18]=e),e}return null}function s7(e){let{part:t}=e;return!d8(t)}function c7(){let e=(0,W.c)(1),t=F3(),{messages:n}=P3(),{debugMode:r}=b3(),i=n[n.length-1];if(t!==`ready`&&t!==`error`&&Y5(i,r))return null;let a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,L.jsx)(q8,{}),e[0]=a):a=e[0],a}var l7={Root:R8,List:z8,Item:B8,UserBubble:S5,AssistantContent:(0,I.memo)(function(e){let t=(0,W.c)(5),{className:n}=e,r=X5(),i;t[0]===r?i=t[1]:(i=r.map(u7),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,L.jsx)(`div`,{className:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}),Actions:M8,CopyAction:N8,RegenerateAction:P8,CopyDebugJsonAction:F8,Thinking:c7,Error:L8};function u7(e){return e.kind===`group`?(0,L.jsxs)($5,{group:e,children:[(0,L.jsxs)(e7,{children:[(0,L.jsx)(n7,{children:(0,L.jsx)(r7,{})}),(0,L.jsx)(i7,{})]}),(0,L.jsx)(a7,{})]},e.key):(0,L.jsx)(o7,{item:e},e.key)}function d7(e){let t=(0,W.c)(8),{message:n,className:r}=e,i;t[0]===r?i=t[1]:(i=P(`text-destructive/90 bg-destructive/10 flex items-start gap-2 rounded-md px-3 py-2 text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,L.jsx)(ne,{className:`text-destructive mt-0.5 size-4 shrink-0`}),t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o=(0,L.jsx)(`span`,{children:n}),t[3]=n,t[4]=o);let s;return t[5]!==i||t[6]!==o?(s=(0,L.jsxs)(`div`,{className:i,children:[a,o]}),t[5]=i,t[6]=o,t[7]=s):s=t[7],s}function f7(e){let t=(0,W.c)(15),{part:n}=e,r=b3(),i,a;if(t[0]!==r.registry||t[1]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let{toolEntry:e}=H6(n,r.registry);if(e&&U6(e,n.state)){let t=e.label?.(n);if(!t){a=null;break bb0}let r=t.icon,i=t.args?Object.values(t.args)[0]:void 0;a=(0,L.jsxs)(`div`,{className:`text-muted-foreground flex items-center text-xs`,children:[r&&(0,L.jsx)(r,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`ms-2 font-mono`,children:t.name}),i&&(0,L.jsxs)(`span`,{className:`truncate`,children:[`(`,i,`)`]})]});break bb0}i=e?.label?.(n)}t[0]=r.registry,t[1]=n,t[2]=i,t[3]=a}else i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o=i,s;t[4]!==o||t[5]!==n?(s=o&&(0,L.jsx)(s8,{label:o,part:n}),t[4]=o,t[5]=n,t[6]=s):s=t[6];let c;t[7]===o?c=t[8]:(c=o?.isError&&o.detail&&(0,L.jsx)(d7,{message:o.detail}),t[7]=o,t[8]=c);let l;t[9]===n?l=t[10]:(l=(0,L.jsx)(r8,{part:n}),t[9]=n,t[10]=l);let u;return t[11]!==s||t[12]!==c||t[13]!==l?(u=(0,L.jsxs)(L.Fragment,{children:[s,c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function p7(e){let t=(0,W.c)(5),{part:n}=e,[r,i]=(0,I.useState)(!1),a;t[0]===n.text?a=t[1]:(a=(0,L.jsx)(C6,{mode:`static`,children:n.text}),t[0]=n.text,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,L.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:`bg-muted/30 prose max-w-auto prose-sm text-muted-foreground border-border mb-4 w-full min-w-full rounded-lg p-3`,children:(0,L.jsx)(c5,{label:`Reasoning`,open:r,onOpenChange:i,className:`text-xs`,triggerClassName:`w-full gap-x-2 text-sm hover:opacity-80`,contentClassName:`mt-2`,children:a})}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function m7(e){let t=(0,W.c)(15),{part:n}=e,{elements:r}=P3(),i=i8();if(n.type===`text`){if(d8(n))return null;let e;return t[0]!==r||t[1]!==n.text?(e=(0,L.jsx)(n8,{text:n.text,elements:r}),t[0]=r,t[1]=n.text,t[2]=e):e=t[2],e}if(n.type===`dynamic-tool`){let e;return t[3]!==i||t[4]!==n?(e=i?(0,L.jsx)(L6,{part:n}):null,t[3]=i,t[4]=n,t[5]=e):e=t[5],e}if(__(n)){let e;return t[6]===n?e=t[7]:(e=(0,L.jsx)(f7,{part:n}),t[6]=n,t[7]=e),e}if(n.type===`reasoning`&&n.text){let e;return t[8]!==i||t[9]!==n?(e=i?(0,L.jsx)(p7,{part:n}):null,t[8]=i,t[9]=n,t[10]=e):e=t[10],e}if(n.type===`file`){let e;return t[11]!==n.filename||t[12]!==n.mediaType||t[13]!==n.url?(e=(0,L.jsx)(t8,{filename:n.filename,mediaType:n.mediaType,url:n.url}),t[11]=n.filename,t[12]=n.mediaType,t[13]=n.url,t[14]=e):e=t[14],e}return null}(0,I.memo)(function(e){let t=(0,W.c)(10),{className:n}=e,{message:r}=I3(),i;t[0]===n?i=t[1]:(i=P(`flex-1 space-y-3`,n),t[0]=n,t[1]=i);let a;if(t[2]!==r.id||t[3]!==r.parts){let e;t[5]===r.id?e=t[6]:(e=(e,t)=>(0,L.jsx)(m7,{part:e},`${r.id}-${t}`),t[5]=r.id,t[6]=e),a=r.parts.map(e),t[2]=r.id,t[3]=r.parts,t[4]=a}else a=t[4];let o;return t[7]!==i||t[8]!==a?(o=(0,L.jsx)(`div`,{className:i,children:a}),t[7]=i,t[8]=a,t[9]=o):o=t[9],o});var h7={braille:{frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},pulse:{frames:[`⠁`,`⠉`,`⠋`,`⠛`,`⠟`,`⠿`,`⡿`,`⣿`,`⡿`,`⠿`,`⠟`,`⠛`,`⠋`,`⠉`,`⠁`,`⠀`],interval:80},clock:{frames:[`⠁`,`⠈`,`⠐`,`⠠`,`⢀`,`⡀`,`⠄`,`⠂`],interval:100},limerence:{frames:[`⠁`,`⠃`,`⠇`,`⡇`,`⣇`,`⣇`,`⣆`,`⣄`,`⣀`,`⢀`,`⠀`],interval:100}};function g7(e){let t=(0,W.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`braille`:i,o=Ve(),{frames:s,interval:c}=h7[a],[l,u]=(0,I.useState)(0),d,f;t[4]!==o||t[5]!==s.length||t[6]!==c?(d=()=>{if(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=o.setInterval(()=>{u(e=>(e+1)%s.length)},c);return()=>o.clearInterval(e)},f=[o,s.length,c],t[4]=o,t[5]=s.length,t[6]=c,t[7]=d,t[8]=f):(d=t[7],f=t[8]),(0,I.useEffect)(d,f);let p;t[9]===n?p=t[10]:(p=P(`inline-block`,n),t[9]=n,t[10]=p);let m=s[l],h;return t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,L.jsx)(`span`,{role:`status`,"aria-label":`Loading`,className:p,...r,children:m}),t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function _7(e){let t=(0,W.c)(11),{Icon:n,isLast:r,isLoading:i,aborted:a,state:o,isError:s}=e,c;t[0]!==n||t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==o?(c=i?(0,L.jsx)(g7,{className:`text-muted-foreground z-10 shrink-0 text-sm`}):a?(0,L.jsx)(g,{className:`text-destructive z-10 size-3.5 shrink-0`}):(0,L.jsx)(n,{className:P(`z-10 size-3.5 shrink-0`,o===`output-error`||s?`text-destructive`:`text-muted-foreground`)}),t[0]=n,t[1]=a,t[2]=s,t[3]=i,t[4]=o,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=!r&&(0,L.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[6]=r,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,L.jsxs)(`div`,{className:`absolute top-0 left-0 flex h-full flex-col items-center`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u}function v7(e){let t=(0,W.c)(15),{isLast:n,label:r,state:i,aborted:a,children:o}=e,s=(0,I.use)(v8),c=r??s?.label,l=i??s?.state,u=a??s?.aborted??!1,d=c?.icon,f=!!l&&!u&&l!==`output-available`&&l!==`output-error`,p;t[0]!==d||t[1]!==u||t[2]!==c?.isError||t[3]!==l||t[4]!==n||t[5]!==f?(p=d?(0,L.jsx)(_7,{Icon:d,isLast:n,isLoading:f,aborted:u,state:l,isError:c?.isError??!1}):(0,L.jsx)(G8,{isLast:n}),t[0]=d,t[1]=u,t[2]=c?.isError,t[3]=l,t[4]=n,t[5]=f,t[6]=p):p=t[6];let m=p,h=n?``:`pb-3.5`,g;t[7]===h?g=t[8]:(g=P(`min-w-0 flex-1`,h),t[7]=h,t[8]=g);let _;t[9]!==o||t[10]!==g?(_=(0,L.jsx)(`div`,{className:g,children:o}),t[9]=o,t[10]=g,t[11]=_):_=t[11];let v;return t[12]!==m||t[13]!==_?(v=(0,L.jsx)(K8,{marker:m,children:_}),t[12]=m,t[13]=_,t[14]=v):v=t[14],v}function y7(e){let t=(0,W.c)(10),{label:n,state:r,part:i,defaultOpen:a,children:o}=e,s=a!==void 0&&a,c;t[0]!==n||t[1]!==i||t[2]!==r?(c=(0,L.jsx)(qi,{className:`cursor-pointer`,children:(0,L.jsx)(l8,{label:n,state:r,part:i})}),t[0]=n,t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,L.jsx)(Ji,{children:o}),t[4]=o,t[5]=l);let u;return t[6]!==s||t[7]!==c||t[8]!==l?(u=(0,L.jsxs)(Ki,{defaultOpen:s,className:`flex min-w-0 flex-1 flex-col`,children:[c,l]}),t[6]=s,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}var b7={Item:v7,Disclosure:y7};(0,I.memo)(function(e){let t=(0,W.c)(12),{className:n}=e,{message:r}=I3(),{elements:i}=P3(),{debugMode:a}=b3(),o=i8(),s=B6(),c;t[0]===r.parts?c=t[1]:(c=D8(r.parts),t[0]=r.parts,t[1]=c);let l=c,u;t[2]!==a||t[3]!==i||t[4]!==s||t[5]!==r.id||t[6]!==l||t[7]!==o?(u=l.map((e,t)=>{let n=`${r.id}-${O8(e,t)}-${e.kind}`;if(e.kind===`text`)return(0,L.jsx)(C8.Text,{segment:e,elements:i,className:`my-4`},n);if(e.kind===`file`)return(0,L.jsx)(C8.File,{segment:e},n);if(e.kind===`source`)return(0,L.jsx)(C8.Source,{segment:e},n);if(e.kind===`dynamic-tool`){if(!o)return null;let r=!E8(l,t,!0);return(0,L.jsx)(b7.Item,{isLast:r,children:(0,L.jsx)(C8.DynamicTool,{segment:e})},n)}if(e.kind===`reasoning`){if(s||e.part.type!==`reasoning`)return null;let r=!E8(l,t,a),i={name:`Reasoning`,icon:vr,args:{text:[...e.part.text].slice(0,60).join(``)}};return(0,L.jsx)(b7.Item,{isLast:r,label:i,children:(0,L.jsx)(b7.Disclosure,{label:i,children:(0,L.jsx)(C8.Reasoning,{segment:e})})},n)}if(e.kind===`tool`){let r=!E8(l,t,a);return(0,L.jsx)(C8.Tool,{segment:e,children:(0,L.jsx)(b7.Item,{isLast:r,children:(0,L.jsx)(C8.ToolDisclosure,{})})},n)}return null}),t[2]=a,t[3]=i,t[4]=s,t[5]=r.id,t[6]=l,t[7]=o,t[8]=u):u=t[8];let d;return t[9]!==n||t[10]!==u?(d=(0,L.jsx)(`div`,{className:n,children:u}),t[9]=n,t[10]=u,t[11]=d):d=t[11],d});function x7(e){let t=(0,W.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{hasSubmitted:i}=S3(),a;t[3]===n?a=t[4]:(a=P(`bg-background sticky bottom-0 rounded-t-2xl border-0 **:data-[slot=composer-editor]:!min-h-15`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==r||t[7]!==a?(o=(0,L.jsx)(o2.Root,{hasInteracted:i,className:a,...r}),t[5]=i,t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function S7(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`border-border bg-card focus-within:border-primary/80 focus-within:ring-primary/15 relative rounded-2xl border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function C7(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`space-y-1 px-3.5 pt-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(o2.Content,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function w7(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`!min-h-15 !rounded-none !border-0 !bg-transparent !shadow-none **:data-[slot=composer-editor]:!p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(o2.Editor,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function T7(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`pb-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(o2.Attachments,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function E7(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`p-1.5 pt-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(o2.Toolbar,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function D7(e){let t=(0,W.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,L.jsx)(A8,{icon:(0,L.jsx)(Ar,{className:`size-4`})}),t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,L.jsx)(o2.AttachFiles,{"aria-label":`Attach files`,render:n,...e}),t[1]=e,t[2]=r),r}function O7(){let e=(0,W.c)(6),{actions:t,meta:n}=GZ(`ChatComposer.CommandButton`),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,L.jsx)(Mr,{className:`size-4`}),e[0]=r):r=e[0];let i=n.activePopup?.trigger===`/`,a;e[1]===t?a=e[2]:(a=e=>{e.stopPropagation(),t.toggleSlashMenu()},e[1]=t,e[2]=a);let o;return e[3]!==i||e[4]!==a?(o=(0,L.jsx)(A8,{"data-command-button":!0,icon:r,"aria-label":`Toggle command menu`,"aria-expanded":i,onClick:a}),e[3]=i,e[4]=a,e[5]=o):o=e[5],o}function k7(e){switch(e){case`permission-denied`:return`Allow microphone access to use dictation`;case`no-microphone`:return`Connect a microphone to use dictation`;case`microphone-in-use`:return`Close other apps using the microphone`;case`interrupted`:return`Recording interrupted`;case`transcription-failed`:return`Unable to transcribe audio`}}function A7(e){switch(e.status){case`unavailable`:return e.reason===`blocked`?`Allow microphone access in your browser settings to use dictation`:`Dictation is not available in this browser`;case`idle`:return`Start dictation`;case`starting`:return`Starting dictation`;case`recording`:return`Stop dictation`;case`finishing`:return`Transcribing…`;case`failed`:return k7(e.error.code)}}function j7(e){switch(e.status){case`recording`:return(0,L.jsx)(Ir,{className:`size-4 fill-current`});case`starting`:case`finishing`:return(0,L.jsx)(be,{className:`size-4 animate-spin`});case`unavailable`:case`idle`:case`failed`:return(0,L.jsx)(wr,{className:`size-4`})}}function M7(){let e=(0,W.c)(20),{status:t}=x3(),{state:n}=q$(`ChatComposer.Dictate`),r;e[0]===n?r=e[1]:(r=A7(n),e[0]=n,e[1]=r);let i=r,a=n.status===`starting`||n.status===`recording`||n.status===`finishing`,o=t===`streaming`||t===`submitted`,s;e[2]===n?s=e[3]:(s=j7(n),e[2]=n,e[3]=s);let c;e[4]!==i||e[5]!==s?(c=(0,L.jsx)(A8,{icon:s,"aria-label":i,title:i}),e[4]=i,e[5]=s,e[6]=c):c=e[6];let l;e[7]!==o||e[8]!==c?(l=(0,L.jsx)(o2.Dictate,{disabled:o,render:c}),e[7]=o,e[8]=c,e[9]=l):l=e[9];let u;e[10]!==a||e[11]!==n.status?(u=a?(0,L.jsx)(o2.CancelDictation,{render:(0,L.jsx)(A8,{icon:(0,L.jsx)(At,{className:`size-4`}),"aria-label":n.status===`finishing`?`Cancel transcription`:`Cancel dictation`})}):null,e[10]=a,e[11]=n.status,e[12]=u):u=e[12];let d;e[13]!==i||e[14]!==n.status?(d=n.status===`failed`?(0,L.jsx)(`span`,{role:`status`,className:`text-destructive max-w-48 truncate text-xs`,children:i}):null,e[13]=i,e[14]=n.status,e[15]=d):d=e[15];let f;return e[16]!==l||e[17]!==u||e[18]!==d?(f=(0,L.jsxs)(L.Fragment,{children:[l,u,d]}),e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}var N7={Provider:x7,Root:S7,Popup:o2.Popup,Content:C7,Attachments:T7,Editor:w7,Error:o2.Error,Toolbar:E7,CommandButton:O7,AttachFiles:D7,Dictate:M7};function P7(e){let t=(0,W.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=P(`border-border flex flex-col border-b px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,L.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function F7(e){let t=(0,W.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=P(`flex items-center gap-2 px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,L.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function I7(e){let t=(0,W.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=P(`text-muted-foreground size-3.5 shrink-0`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,L.jsx)(br,{className:r}),t[2]=r,t[3]=i),i}function L7(e){let t=(0,W.c)(7),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=P(`min-w-0 flex-1 truncate text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=typeof n==`string`?(0,L.jsx)(c2,{text:n}):n,t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,L.jsx)(`span`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function R7(e){let t=(0,W.c)(6),{onClick:n,className:r}=e,i;t[0]===r?i=t[1]:(i=P(`text-muted-foreground hover:text-foreground shrink-0 rounded p-1 transition-colors`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,L.jsx)(_e,{className:`size-3.5`}),t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==i?(o=(0,L.jsx)(`button`,{type:`button`,onClick:n,className:i,"aria-label":`Remove queued message`,children:a}),t[3]=n,t[4]=i,t[5]=o):o=t[5],o}var z7={Root:P7,Item:F7,Icon:I7,Text:L7,Remove:R7},B7={normal:{d:`m5 12 7-7 7 7`,translateY:0},animate:{d:`m5 12 7-7 7 7`,translateY:[0,3,0],transition:{duration:.4}}},V7={normal:{d:`M12 19V5`},animate:{d:[`M12 19V5`,`M12 19V10`,`M12 19V5`],transition:{duration:.4}}},H7=e=>{let t=(0,W.c)(30),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({ref:o,onMouseEnter:r,onMouseLeave:i,className:n,size:s,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?20:s,l=jA(),u=(0,I.useRef)(!1),d;t[7]===l?d=t[8]:(d=()=>(u.current=!0,{startAnimation:()=>l.start(`animate`),stopAnimation:()=>l.start(`normal`)}),t[7]=l,t[8]=d),(0,I.useImperativeHandle)(o,d);let f;t[9]!==l||t[10]!==r?(f=e=>{u.current?r?.(e):l.start(`animate`)},t[9]=l,t[10]=r,t[11]=f):f=t[11];let p=f,m;t[12]!==l||t[13]!==i?(m=e=>{u.current?i?.(e):l.start(`normal`)},t[12]=l,t[13]=i,t[14]=m):m=t[14];let h=m,g;t[15]===n?g=t[16]:(g=P(n),t[15]=n,t[16]=g);let _,v;t[17]===l?(_=t[18],v=t[19]):(_=(0,L.jsx)(MA.path,{animate:l,d:`m5 12 7-7 7 7`,variants:B7}),v=(0,L.jsx)(MA.path,{animate:l,d:`M12 19V5`,variants:V7}),t[17]=l,t[18]=_,t[19]=v);let y;t[20]!==c||t[21]!==_||t[22]!==v?(y=(0,L.jsxs)(`svg`,{fill:`none`,height:c,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:c,xmlns:`http://www.w3.org/2000/svg`,children:[_,v]}),t[20]=c,t[21]=_,t[22]=v,t[23]=y):y=t[23];let b;return t[24]!==p||t[25]!==h||t[26]!==a||t[27]!==g||t[28]!==y?(b=(0,L.jsx)(`div`,{className:g,onMouseEnter:p,onMouseLeave:h,...a,children:y}),t[24]=p,t[25]=h,t[26]=a,t[27]=g,t[28]=y,t[29]=b):b=t[29],b};H7.displayName=`ArrowUpIcon`;var U7={duration:.15,ease:[0,0,.2,1]},W7={duration:.12,ease:[0,0,.2,1]};function G7(e){let t=(0,W.c)(40),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({variant:a,className:n,disabled:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=TA(),s=a===`stop`,c;t[5]===o?c=t[6]:(c=!o&&{opacity:0,scale:.9},t[5]=o,t[6]=c);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l={opacity:1,scale:1},t[7]=l):l=t[7];let u;t[8]===o?u=t[9]:(u=o?void 0:{opacity:0,scale:.9},t[8]=o,t[9]=u);let d;t[10]!==r||t[11]!==o?(d=r||o?void 0:{scale:1.04},t[10]=r,t[11]=o,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==o?(f=r||o?void 0:{scale:.96},t[13]=r,t[14]=o,t[15]=f):f=t[15];let p=s?`Stop streaming`:`Send prompt`,m;t[16]===n?m=t[17]:(m=P(`relative flex size-8 items-center justify-center rounded-full`,`bg-primary text-primary-foreground`,`transition-opacity hover:opacity-90 active:opacity-80`,`disabled:cursor-not-allowed disabled:opacity-35 disabled:hover:opacity-35`,`focus-visible:outline-[1.5px] focus-visible:outline-offset-[2.5px] focus-visible:outline-current`,n),t[16]=n,t[17]=m);let h=s?`stop`:`send`,g;t[18]===o?g=t[19]:(g=!o&&{opacity:0,scale:.7},t[18]=o,t[19]=g);let _;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(_={opacity:1,scale:1},t[20]=_):_=t[20];let v;t[21]===o?v=t[22]:(v=o?void 0:{opacity:0,scale:.7},t[21]=o,t[22]=v);let y;t[23]===s?y=t[24]:(y=(0,L.jsx)(s?J7:q7,{}),t[23]=s,t[24]=y);let b;t[25]!==v||t[26]!==y||t[27]!==h||t[28]!==g?(b=(0,L.jsx)(OO,{initial:!1,children:(0,L.jsx)(MA.span,{initial:g,animate:_,exit:v,transition:W7,className:`absolute flex items-center justify-center`,children:y},h)}),t[25]=v,t[26]=y,t[27]=h,t[28]=g,t[29]=b):b=t[29];let x;return t[30]!==r||t[31]!==i||t[32]!==c||t[33]!==b||t[34]!==u||t[35]!==d||t[36]!==f||t[37]!==p||t[38]!==m?(x=(0,L.jsx)(MA.button,{initial:c,animate:l,exit:u,transition:U7,whileHover:d,whileTap:f,"aria-label":p,...i,disabled:r,className:m,children:b}),t[30]=r,t[31]=i,t[32]=c,t[33]=b,t[34]=u,t[35]=d,t[36]=f,t[37]=p,t[38]=m,t[39]=x):x=t[39],x}function K7(e){let t=(0,W.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,L.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:n}),t[0]=n,t[1]=r),r}function q7(){let e=(0,W.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsx)(H7,{}),e[0]=t):t=e[0],t}function J7(){let e=(0,W.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsx)(K7,{children:(0,L.jsx)(`rect`,{x:`5`,y:`5`,width:`10`,height:`10`,rx:`1.5`})}),e[0]=t):t=e[0],t}function Y7(e){let t=(0,W.c)(25),{title:n,detail:r,detailLabel:i,part:a,error:o}=e,s=n===void 0?`Failed to render tool`:n,c=i===void 0?`View details`:i,l=C3(),u;t[0]===o.issues?u=t[1]:(u=o.issues.map(X7).join(`
344
- `),t[0]=o.issues,t[1]=u);let d=u,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,L.jsx)(ne,{className:`size-5`}),t[2]=f):f=t[2];let p;t[3]===s?p=t[4]:(p=(0,L.jsx)(ui,{children:(0,L.jsxs)(di,{className:`text-destructive flex items-center gap-2`,children:[f,s]})}),t[3]=s,t[4]=p);let h,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,L.jsx)(ne,{className:`size-4`}),g=(0,L.jsx)(ve,{children:`Error`}),t[5]=h,t[6]=g):(h=t[5],g=t[6]);let _;t[7]===d?_=t[8]:(_=(0,L.jsxs)(m,{variant:`destructive`,children:[h,g,(0,L.jsx)(jt,{children:d})]}),t[7]=d,t[8]=_);let v;t[9]!==r||t[10]!==c?(v=r&&(0,L.jsxs)(`details`,{className:`text-sm`,children:[(0,L.jsx)(`summary`,{className:`text-muted-foreground hover:text-foreground cursor-pointer`,children:c}),(0,L.jsx)(`pre`,{className:`bg-muted mt-2 max-h-48 overflow-auto rounded-md p-3 text-xs`,children:(0,L.jsx)(`code`,{children:r})})]}),t[9]=r,t[10]=c,t[11]=v):v=t[11];let y;t[12]!==_||t[13]!==v?(y=(0,L.jsxs)(mi,{className:`space-y-4`,children:[_,v]}),t[12]=_,t[13]=v,t[14]=y):y=t[14];let b;t[15]!==l||t[16]!==a?(b=()=>{let e=[`The model tried to call the tool "${x_(a)}" with the following inputs:`,JSON.stringify(a.input),`Please fix the inputs.`];l.addToolOutput({toolCallId:a.toolCallId,tool:x_(a),output:e,state:`output-available`})},t[15]=l,t[16]=a,t[17]=b):b=t[17];let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,L.jsx)(Pr,{className:`size-4`}),t[18]=x):x=t[18];let S;t[19]===b?S=t[20]:(S=(0,L.jsx)(hi,{children:(0,L.jsxs)(at,{variant:`outline`,onClick:b,className:`gap-2`,children:[x,`Ask AI to fix this`]})}),t[19]=b,t[20]=S);let C;return t[21]!==y||t[22]!==S||t[23]!==p?(C=(0,L.jsxs)(li,{className:`border-destructive/50 bg-destructive/5`,children:[p,y,S]}),t[21]=y,t[22]=S,t[23]=p,t[24]=C):C=t[24],C}function X7(e){return`${e.path.join(`.`)}: ${e.message}`}(0,I.createContext)(``);function Z7({question:e}){let{submit:t}=b3();return typeof e!=`string`||e===``?null:(0,L.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-accent hover:text-accent-foreground my-1 inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-sm transition-colors`,onClick:()=>void t({prompt:e,persistedPrompt:e}),children:[(0,L.jsx)(gr,{className:`size-3.5`}),e]})}var Q7=YA([{name:`followup`,description:`Suggest a follow-up question the user is likely to ask next. Renders as a clickable chip that sends the question as the next message. Example: <followup question="How do I undo this?" />`,allowedAttributes:[`question`],component:Z7}]),$7=N({label:F().describe(`Display text for the option`),value:F().optional().describe(`Machine value; defaults to label`),description:F().optional().describe(`Helper text for the option`)}),e9=T(e=>typeof e==`object`&&e&&`questions`in e&&Array.isArray(e.questions)?{...e,questions:e.questions.map(e=>typeof e==`object`&&e?{...e,type:`choice`}:e)}:e,N({questions:vt(N({type:Ne(`choice`).describe(`Selection from predefined options`),question:F().describe(`The question text displayed to the user`),header:F().optional().describe(`Short context label`),multiSelect:et().default(!1).describe(`Whether multiple options can be selected`),options:vt($7).min(1).describe(`Available choices`)})).min(1).describe(`Questions to present as a wizard`)})),t9=N({label:F(),value:F()}),n9=N({answers:vt(N({type:F(),question:F(),freeText:F().optional(),notes:F().optional(),choice:t9.optional(),choices:vt(t9).optional(),multiSelect:et().optional(),answer:F().optional()}))});function r9(e){if(e.multiSelect){if(e.selectedMulti.length===0&&!e.customText.trim())return`Pick at least one option or add your own answer.`}else{if(!e.selected&&!e.isOther)return`Select an option or add your own answer.`;if(e.isOther&&!e.customText.trim())return`Add your custom answer for the "Other" option.`}return null}function i9(e){return{type:`choice`,multiSelect:e.multiSelect??!1,selected:null,selectedMulti:[],isOther:!1,customText:``,notes:``}}function a9(e){return e.options.filter(e=>(e.value??e.label).toLowerCase()!==`other`&&e.label.toLowerCase()!==`other`).map(e=>({label:e.label,value:e.value??e.label,description:e.description}))}function o9(e,t,n){let r=e=>{let t=n.find(t=>t.value===e);return t?{label:t.label,value:t.value}:{label:e,value:e}},i=t.notes.trim()||void 0,a=t.customText.trim()||void 0;if(t.multiSelect){let n=t.selectedMulti.map(r);return a&&n.push({label:`Other`,value:a}),{type:`choice`,question:e.question,multiSelect:!0,choices:n,freeText:a,notes:i}}return{type:`choice`,question:e.question,multiSelect:!1,choice:t.isOther?{label:`Other`,value:a??``}:r(t.selected??``),freeText:t.isOther?a:void 0,notes:i}}function s9({checked:e,children:t,disabled:n}){return(0,L.jsx)(`div`,{className:P(`border-border/60 relative flex items-start gap-2 rounded-lg border px-3 py-1.5 transition-all duration-150`,!n&&`hover:bg-muted/40`,e&&`border-primary/50 bg-primary/5`,n&&`opacity-60`),children:t})}function c9({htmlFor:e,label:t,description:n}){return(0,L.jsxs)(qt,{htmlFor:e,className:`min-w-0 flex-1 cursor-pointer flex-col items-start gap-0`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:t}),n?(0,L.jsx)(`p`,{className:`text-muted-foreground text-xs leading-relaxed text-pretty`,children:n}):null]})}function l9({id:e,value:t,label:n,description:r,checked:i,disabled:a}){return(0,L.jsxs)(s9,{checked:i,disabled:a,children:[(0,L.jsx)(xa,{id:e,value:t,disabled:a,className:`mt-0.5`}),(0,L.jsx)(c9,{htmlFor:e,label:n,description:r})]})}function u9({id:e,label:t,description:n,checked:r,disabled:i,onCheckedChange:a}){return(0,L.jsxs)(s9,{checked:r,disabled:i,children:[(0,L.jsx)(Mi,{id:e,checked:r,disabled:i,onCheckedChange:e=>a(e===!0),className:`mt-0.5`}),(0,L.jsx)(c9,{htmlFor:e,label:t,description:n})]})}function d9({id:e,checked:t,disabled:n,customText:r,onCustomTextChange:i}){let a=(0,I.useRef)(null);return(0,L.jsxs)(s9,{checked:t,disabled:n,children:[(0,L.jsx)(xa,{ref:a,id:e,value:`other`,disabled:n,className:`mt-0.5`}),(0,L.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Type your answer...`,disabled:n,onFocus:()=>{t||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function f9({hasCustom:e,disabled:t,customText:n,onCustomTextChange:r,onClear:i}){let a=(0,I.useRef)(null);return(0,L.jsxs)(s9,{checked:e,disabled:t,children:[(0,L.jsx)(Mi,{ref:a,checked:e,disabled:t,onCheckedChange:e=>{e||i()},className:`mt-0.5`}),(0,L.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Type your answer...`,disabled:t,onFocus:()=>{e||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function p9({value:e,onChange:t,disabled:n}){return(0,L.jsx)(`div`,{className:`mt-2.5 border-t border-dashed pt-2.5`,children:(0,L.jsx)(un,{value:e,onChange:e=>t(e.target.value),placeholder:`Add notes (optional)...`,disabled:n,rows:2,className:`resize-none text-sm`})})}function m9({value:e,onChange:t,options:n,disabled:r,fieldId:i}){if(e.multiSelect){let a=e.customText.trim().length>0,o=(n,r)=>{let i=new Set(e.selectedMulti);r?i.add(n):i.delete(n),t({...e,selectedMulti:[...i]})};return(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[n.map(t=>(0,L.jsx)(u9,{id:`${i}-multi-${t.value}`,label:t.label,description:t.description,checked:e.selectedMulti.includes(t.value),disabled:r,onCheckedChange:e=>o(t.value,e)},t.value)),(0,L.jsx)(f9,{hasCustom:a,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n}),onClear:()=>t({...e,customText:``})})]})}return(0,L.jsxs)(ba,{value:e.isOther?`other`:e.selected??``,onValueChange:n=>t(n===`other`?{...e,selected:null,isOther:!0}:{...e,selected:n,isOther:!1,customText:``}),children:[n.map(t=>(0,L.jsx)(l9,{id:`${i}-single-${t.value}`,value:t.value,label:t.label,description:t.description,checked:!e.isOther&&e.selected===t.value,disabled:r},t.value)),(0,L.jsx)(d9,{id:`${i}-single-other`,checked:e.isOther,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n})})]})}function h9({current:e,total:t}){return t<=1?null:(0,L.jsx)(`div`,{className:`flex items-center gap-1`,children:Array.from({length:t},(t,n)=>(0,L.jsx)(`div`,{className:P(`h-1 w-3 rounded-full transition-colors duration-200`,n<=e?`bg-primary`:`bg-muted`)},n))})}function g9({onBack:e,onNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}){return o?null:(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-t border-dashed px-3 py-1.5`,children:[(0,L.jsx)(`div`,{className:`w-16`,children:n?null:(0,L.jsx)(`button`,{type:`button`,onClick:e,disabled:a,className:`text-muted-foreground hover:text-foreground text-xs transition-colors disabled:opacity-50`,children:`← Back`})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(h9,{current:s,total:c}),c>1?(0,L.jsxs)(`span`,{className:`text-muted-foreground text-[11px] tabular-nums`,children:[s+1,`/`,c]}):null]}),(0,L.jsx)(`div`,{className:`flex w-16 justify-end`,children:(0,L.jsxs)(at,{type:`button`,size:`sm`,onClick:t,disabled:!i||a,children:[a?(0,L.jsx)(Sa,{}):null,a?`Sending...`:r?`Submit`:`Next`]})})]})}function _9({question:e}){return(0,L.jsxs)(`div`,{className:`px-3 pt-2.5 pb-2`,children:[(0,L.jsxs)(`div`,{className:`text-muted-foreground mb-2 flex items-center gap-2 text-[11px]`,children:[(0,L.jsx)(se,{className:`size-3`}),(0,L.jsx)(`span`,{children:e.header??`Clarification`})]}),(0,L.jsx)(ci,{className:`mb-2`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-pretty`,children:e.question})]})}function v9({question:e,answer:t,options:n,onChange:r,disabled:i,fieldId:a}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(m9,{value:t,onChange:r,options:n,disabled:i,fieldId:a}),(0,L.jsx)(p9,{value:t.notes,onChange:e=>r({...t,notes:e}),disabled:i})]})}function y9({question:e,answer:t,options:n}){let r=t.multiSelect?[...t.selectedMulti.map(e=>n.find(t=>t.value===e)?.label??e),...t.customText.trim()?[`Other: ${t.customText.trim()}`]:[]].join(`, `):t.isOther?`Other: ${t.customText.trim()}`:n.find(e=>e.value===t.selected)?.label??t.selected??``,i=t.notes.trim()||void 0;return(0,L.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,L.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:r}),i?(0,L.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,i]}):null]})}function b9(e){return e.type===`free_form`?e.answer??``:e.multiSelect&&e.choices?e.choices.map(({label:e,value:t})=>e===`Other`?`Other: ${t}`:e).join(`, `):e.freeText?`Other: ${e.freeText}`:e.choice?.label??``}function x9({answers:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,L.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,L.jsx)(je,{className:`size-3`}),(0,L.jsx)(`span`,{children:`Answered`})]})}),(0,L.jsx)(ci,{}),e.map((e,t)=>(0,L.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,L.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:b9(e)}),e.notes?(0,L.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,e.notes]}):null]},t))]})}function S9({questions:e,answers:t}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,L.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,L.jsx)(je,{className:`size-3`}),(0,L.jsx)(`span`,{children:`Answered`})]})}),(0,L.jsx)(ci,{}),e.map((e,n)=>(0,L.jsx)(y9,{question:e,answer:t[n],options:a9(e)},n))]})}var C9=(0,I.createContext)(void 0);function w9(){let e=(0,I.use)(C9);if(!e)throw Error(`useWizard must be used within <ClarificationWizard.Root>`);return e}function T9({questions:e,onSubmit:t,disabled:n,fieldId:r,children:i}){let[a,o]=(0,I.useState)(0),[s,c]=(0,I.useState)(()=>e.map(i9)),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(!1),h=e[a],g=s[a],_=a===0,v=a===e.length-1,y={questions:e,currentStep:a,currentQuestion:h,currentAnswer:g,options:a9(h),answers:s,updateAnswer:e=>{c(t=>{let n=[...t];return n[a]=e,n}),u(null)},handleBack:()=>{_||(o(e=>e-1),u(null))},handleNext:async()=>{let n=r9(g);if(n){u(n);return}if(!v){o(e=>e+1),u(null);return}for(let t=0;t<e.length;t++){let e=r9(s[t]);if(e){o(t),u(e);return}}f(!0);try{await t(e.map((e,t)=>o9(e,s[t],a9(e)))),m(!0)}catch(e){u(e instanceof Error?e.message:`Failed to send your answers.`)}finally{f(!1)}},error:l,isFirst:_,isLast:v,canProceed:!n&&!p,isSubmitting:d,isSubmitted:p,disabled:n,fieldId:r,totalSteps:e.length};return(0,L.jsx)(C9,{value:y,children:i})}function E9(){let{currentQuestion:e,isSubmitted:t}=w9();return t?null:(0,L.jsx)(_9,{question:e})}function D9(){let{currentQuestion:e,currentAnswer:t,options:n,updateAnswer:r,disabled:i,isSubmitting:a,isSubmitted:o,fieldId:s,currentStep:c}=w9();return o?null:(0,L.jsx)(v9,{question:e,answer:t,options:n,onChange:r,disabled:i||a,fieldId:`${s}-step-${c}`})}function O9(){let{error:e,isSubmitted:t}=w9();return t||!e?null:(0,L.jsx)(`p`,{className:`text-destructive text-xs`,role:`alert`,children:e})}function k9(){let{handleBack:e,handleNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}=w9();return(0,L.jsx)(g9,{onBack:e,onNext:()=>void t(),isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c})}function A9({children:e,className:t}){let{isSubmitted:n}=w9();return n?null:(0,L.jsx)(`div`,{className:t,children:e})}function j9(){let{questions:e,answers:t,isSubmitted:n}=w9();return n?(0,L.jsx)(S9,{questions:e,answers:t}):null}var M9={Root:T9,Header:E9,Content:A9,Field:D9,Error:O9,Navigation:k9,Submitted:j9};function N9({part:e}){let t=C3(),[n,r]=(0,I.useState)(!1),i=(0,I.useId)();if(e.state===`output-available`){let t=n9.safeParse(e.output);return t.success?(0,L.jsx)(`div`,{className:P(`border-border/60 bg-muted/20 mb-2 rounded-lg border border-dashed`),children:(0,L.jsx)(x9,{answers:t.data.answers})}):null}if(e.state!==`input-available`)return null;let a=e9.safeParse(e.input);return a.success?(0,L.jsx)(`div`,{className:P(`border-border/60 bg-muted/20 rounded-lg border border-dashed`,`animate-in fade-in-0 duration-200`),children:(0,L.jsxs)(M9.Root,{questions:a.data.questions,onSubmit:async n=>{await t.addToolOutput({toolCallId:e.toolCallId,tool:x_(e),output:{answers:n},state:`output-available`}),r(!0)},disabled:n,fieldId:i,children:[(0,L.jsx)(M9.Submitted,{}),(0,L.jsx)(M9.Header,{}),(0,L.jsxs)(M9.Content,{className:`space-y-2 px-3 pb-2`,children:[(0,L.jsx)(M9.Field,{}),(0,L.jsx)(M9.Error,{})]}),(0,L.jsx)(M9.Navigation,{})]})}):(0,L.jsx)(Y7,{error:a.error,title:`Failed to render clarification`,detail:JSON.stringify(e.input,null,2),detailLabel:`View input`,part:e})}var P9={component:N9,label:e=>{let t=e.state===`input-available`||e.state===`output-available`?e9.safeParse(e.input):void 0,n=t?.success?t.data.questions[0]:void 0;return{name:`AskUserQuestion`,icon:cr,args:n?{question:n.header??n.question}:void 0}},requiresUserInput:!0,static:!1,inputSchema:e9,description:`Tool to collect information from the user via a multi-step wizard. Use when you need to clarify requirements, gather preferences, or resolve ambiguity before proceeding.
342
+ `}var n6=`response-table-panel`,r6=[`title`,`description`],i6=P(Ut({variant:`ghost`,size:`icon-sm`})),a6=Wn().use(Qn).use(Xn).use($j),o6=e=>{let t=Hn(e),n=l6(e);if(n.length===0)return t;let r=0,i=t.map(e=>{let t={start:r,end:r+e.length};return r=t.end,t}),a=new Set;for(let e of n){let t=!1;for(let[n,r]of i.entries())r.start<e.end&&r.end>e.start&&(t&&a.add(n),t=!0)}return t.reduce((e,t,n)=>(a.has(n)&&e.length>0?e[e.length-1]+=t:e.push(t),e),[])};function s6(e){return e?.type===`leafDirective`&&`name`in e&&e.name===`table`}function c6(e,t){if(t===void 0)return;let n=e[t-1];return s6(n)?n:void 0}function l6(e){let t=[];return nr(a6.parse(e),`table`,(e,n,r)=>{if(!r)return;let i=c6(r.children,n)?.position?.start.offset,a=e.position?.end.offset;i!==void 0&&a!==void 0&&t.push({start:i,end:a})}),t}function u6(e,t){return e.attributes?.[t]?.trim()||void 0}function d6(e){let t=a6.parse(e),n=!1;if(nr(t,`leafDirective`,(e,t,r)=>{let i=t===void 0?void 0:r?.children[t+1];if(e.name!==`table`||i?.type!==`table`)return;n=!0;let a=[u6(e,`title`),u6(e,`description`)].filter(Boolean).join(` `);e.children=a?[{type:`text`,value:a}]:[]}),n)return Zn(zn(t,{includeHtml:!1}))}function f6(e){let t=(0,W.c)(2),n;return t[0]===e?n=t[1]:(n=(0,L.jsx)(Un,{...e}),t[0]=e,t[1]=n),n}function p6(e){function t(t){let n=(0,W.c)(6),r;n[0]!==t.content||n[1]!==t.dir?(r=d6(t.content)??t.dir,n[0]=t.content,n[1]=t.dir,n[2]=r):r=n[2];let i=r,a;return n[3]!==i||n[4]!==t?(a=(0,L.jsx)(e,{...t,dir:i}),n[3]=i,n[4]=t,n[5]=a):a=n[5],a}return t.displayName=`DirectionAwareTableBlock`,t}function m6(e,t){let n=t&&u6(t,`title`),r=t&&u6(t,`description`),i={...n?{title:n}:{},...r?{description:r}:{}};return{type:`tablePanel`,data:{hName:n6,...Object.keys(i).length>0?{hProperties:i}:{}},children:[e]}}function h6(){return e=>{nr(e,`table`,(e,t,n)=>{if(t===void 0||!n)return;let r=c6(n.children,t),i=r?t-1:t,a=r?2:1;return n.children.splice(i,a,m6(e,r)),[Rn,i+1]})}}var g6=[...Object.values(Yn),$j,h6],_6=I.createContext({actions:null,controls:!0});function v6(e,t){if(e===!1)return!1;if(e===!0||e===void 0)return!0;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1}function y6(e){return e===!1?!1:e===!0||e===void 0?{table:!1}:{...e,table:!1}}function b6(e){let t=(0,W.c)(21),{children:n,className:r,title:i,description:a}=e,{actions:o,controls:s}=I.use(_6),c;t[0]===s?c=t[1]:(c=v6(s,`copy`),t[0]=s,t[1]=c);let l=c,u;t[2]===s?u=t[3]:(u=v6(s,`download`),t[2]=s,t[3]=u);let d=u,f=!!(i||a),p=!!(l||d||o);if(!n)return null;let m;t[4]===r?m=t[5]:(m=P(`my-4`,r),t[4]=r,t[5]=m);let h;t[6]!==o||t[7]!==a||t[8]!==p||t[9]!==f||t[10]!==l||t[11]!==d||t[12]!==i?(h=(f||p)&&(0,L.jsxs)(G3.Header,{className:P(!f&&`justify-end`),children:[f&&(0,L.jsxs)(G3.Heading,{children:[i&&(0,L.jsx)(G3.Title,{children:i}),a&&(0,L.jsx)(G3.Description,{className:P(i&&`mt-1`),children:a})]}),p&&(0,L.jsxs)(G3.Actions,{"data-copy-exclude":`assistant-snapshot`,children:[l&&(0,L.jsx)($n,{className:i6}),d&&(0,L.jsx)(Bn,{className:i6}),o]})]}),t[6]=o,t[7]=a,t[8]=p,t[9]=f,t[10]=l,t[11]=d,t[12]=i,t[13]=h):h=t[13];let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=P(`overflow-hidden`,`[&>[data-streamdown=table-wrapper]]:m-0 [&>[data-streamdown=table-wrapper]]:gap-0 [&>[data-streamdown=table-wrapper]]:rounded-none [&>[data-streamdown=table-wrapper]]:border-0 [&>[data-streamdown=table-wrapper]]:bg-transparent [&>[data-streamdown=table-wrapper]]:p-0`,`[&>[data-streamdown=table-wrapper]>div:last-child]:rounded-none [&>[data-streamdown=table-wrapper]>div:last-child]:border-0`,`[&_[data-streamdown=table]]:tabular-nums`,`[&_[data-streamdown=table-header]]:bg-muted/30`,`[&_[data-streamdown=table-header-cell]]:text-muted-foreground [&_[data-streamdown=table-header-cell]]:text-xs [&_[data-streamdown=table-header-cell]]:font-medium`,`[&_[data-streamdown=table-cell]]:py-2`,`[&_[data-streamdown=table-row]]:hover:bg-muted/30`),t[14]=g):g=t[14];let _;t[15]===n?_=t[16]:(_=(0,L.jsx)(G3.Content,{className:g,children:n}),t[15]=n,t[16]=_);let v;return t[17]!==m||t[18]!==h||t[19]!==_?(v=(0,L.jsxs)(G3,{"data-streamdown":`table-wrapper`,className:m,children:[h,_]}),t[17]=m,t[18]=h,t[19]=_,t[20]=v):v=t[20],v}function x6(e){let t=(0,W.c)(43),n,r,i,a,o,s,c,l,u,d;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10]):({allowedTags:r,BlockComponent:n,children:i,components:a,controls:o,dir:s,mode:c,remarkPlugins:u,tableActions:d,...l}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d);let f;bb0:{if(!u){f=g6;break bb0}let e;t[11]===u?e=t[12]:(e=[...u,$j,h6],t[11]=u,t[12]=e),f=e}let p=f,m;t[13]===r?m=t[14]:(m={...r,[n6]:r6},t[13]=r,t[14]=m);let h=m,g;t[15]===a?g=t[16]:(g={...a,[n6]:b6},t[15]=a,t[16]=g);let _=g,v;t[17]!==o||t[18]!==d?(v={actions:d,controls:o},t[17]=o,t[18]=d,t[19]=v):v=t[19];let y=v,b;bb1:{if(s!==`auto`||c===`static`){b=n;break bb1}let e=n??f6,r;t[20]===e?r=t[21]:(r=p6(e),t[20]=e,t[21]=r),b=r}let x=b,S;bb2:{if(s!==`auto`||c!==`static`||typeof i!=`string`){S=s;break bb2}let e;t[22]!==i||t[23]!==s?(e=d6(i)??s,t[22]=i,t[23]=s,t[24]=e):e=t[24],S=e}let C=S,w;t[25]===o?w=t[26]:(w=y6(o),t[25]=o,t[26]=w);let T;t[27]!==i||t[28]!==h?(T=Y3(i,Object.keys(h)),t[27]=i,t[28]=h,t[29]=T):T=t[29];let E;t[30]!==c||t[31]!==l||t[32]!==C||t[33]!==w||t[34]!==T||t[35]!==h||t[36]!==x||t[37]!==_||t[38]!==p?(E=(0,L.jsx)(er,{allowedTags:h,BlockComponent:x,components:_,controls:w,dir:C,mode:c,parseMarkdownIntoBlocksFn:o6,remarkPlugins:p,...l,children:T}),t[30]=c,t[31]=l,t[32]=C,t[33]=w,t[34]=T,t[35]=h,t[36]=x,t[37]=_,t[38]=p,t[39]=E):E=t[39];let ee;return t[40]!==E||t[41]!==y?(ee=(0,L.jsx)(_6,{value:y,children:E}),t[40]=E,t[41]=y,t[42]=ee):ee=t[42],ee}var S6=class extends I.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){return this.state.hasError?this.props.fallback||(0,L.jsxs)(`div`,{className:`text-destructive p-2 text-sm`,children:[`Failed to render content: `,this.state.error?.message]}):this.props.children}},C6=(0,I.memo)(e=>{let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`size-full space-y-2 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(S6,{children:(0,L.jsx)(x6,{className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a});C6.displayName=`Response`;function w6(e){let t=(0,W.c)(9),n=e===void 0?2e3:e,r=Ve(),[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>()=>{o.current&&r.clearTimeout(o.current)},c=[r],t[0]=r,t[1]=s,t[2]=c),(0,I.useEffect)(s,c);let l;t[3]!==r||t[4]!==n?(l=async e=>{await navigator.clipboard.writeText(e),a(!0),o.current&&r.clearTimeout(o.current),o.current=r.setTimeout(()=>a(!1),n)},t[3]=r,t[4]=n,t[5]=l):l=t[5];let u=l,d;return t[6]!==i||t[7]!==u?(d=[i,u],t[6]=i,t[7]=u,t[8]=d):d=t[8],d}var T6=(0,I.createContext)({code:``}),E6=e=>{let t=(0,W.c)(24),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({code:r,language:i,showLineNumbers:o,wrap:s,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o!==void 0&&o,l=s!==void 0&&s,u=Hp(r,i),d;t[7]===r?d=t[8]:(d={code:r},t[7]=r,t[8]=d);let f;t[9]===u?f=t[10]:(f=u.map(O6),t[9]=u,t[10]=f);let p;t[11]!==c||t[12]!==f||t[13]!==l?(p=(0,L.jsx)(Ii,{lineNumbers:c,wrap:l,children:f}),t[11]=c,t[12]=f,t[13]=l,t[14]=p):p=t[14];let m;t[15]===n?m=t[16]:(m=!!n&&(0,L.jsx)(Fi,{children:n}),t[15]=n,t[16]=m);let h;t[17]!==a||t[18]!==p||t[19]!==m?(h=(0,L.jsxs)(Pi,{size:`sm`,...a,children:[p,m]}),t[17]=a,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==d||t[22]!==h?(g=(0,L.jsx)(T6,{value:d,children:h}),t[21]=d,t[22]=h,t[23]=g):g=t[23],g},D6=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,...a})=>{let[o,s]=w6(n),{code:c}=(0,I.use)(T6),l=async()=>{if(typeof window>`u`||!navigator.clipboard.writeText){t?.(Error(`Clipboard API not available`));return}try{await s(c),e?.()}catch(e){t?.(e instanceof Error?e:Error(String(e)))}},u=o?je:mr;return(0,L.jsx)(at,{className:P(`shrink-0`,i),onClick:()=>void l(),size:`icon-xs`,variant:`ghost`,...a,children:r??(0,L.jsx)(u,{})})};function O6(e,t){return(0,L.jsx)(Ri,{children:e},t)}var k6=e=>{let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`not-prose mb-4 w-full rounded-md border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(Ki,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},A6=e=>(0,L.jsxs)(Ce,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,L.jsx)(Ee,{className:`size-4`}),"input-available":(0,L.jsx)(fr,{className:`size-4 animate-pulse`}),"approval-requested":(0,L.jsx)(fr,{className:`size-4 text-yellow-600`}),"approval-responded":(0,L.jsx)(or,{className:`size-4 text-blue-600`}),"output-available":(0,L.jsx)(or,{className:`size-4 text-green-600`}),"output-error":(0,L.jsx)(ur,{className:`size-4 text-red-600`}),"output-denied":(0,L.jsx)(ur,{className:`size-4 text-orange-600`})}[e],{"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`}[e]]}),j6=e=>{let t=(0,W.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,title:a,part:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=P(`group flex w-full items-center justify-between gap-4 p-3`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(Rr,{className:`text-muted-foreground size-4`}),t[7]=s):s=t[7];let c;t[8]!==r||t[9]!==a?(c=a??S_(r),t[8]=r,t[9]=a,t[10]=c):c=t[10];let l;t[11]===c?l=t[12]:(l=(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:c}),t[11]=c,t[12]=l);let u;t[13]===r.state?u=t[14]:(u=A6(r.state),t[13]=r.state,t[14]=u);let d;t[15]!==l||t[16]!==u?(d=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,l,u]}),t[15]=l,t[16]=u,t[17]=d):d=t[17];let f;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,L.jsx)(me,{className:`text-muted-foreground size-4 transition-transform group-data-[panel-open]:rotate-180`}),t[18]=f):f=t[18];let p;return t[19]!==i||t[20]!==o||t[21]!==d?(p=(0,L.jsxs)(qi,{className:o,...i,children:[d,f]}),t[19]=i,t[20]=o,t[21]=d,t[22]=p):p=t[22],p},M6=e=>{let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`data-closed:fade-out-0 data-closed:slide-out-to-top-2 data-open:slide-in-from-top-2 text-popover-foreground data-closed:animate-out data-open:animate-in outline-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(Ji,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},N6=e=>{let t=(0,W.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,input:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=P(`space-y-2 overflow-hidden p-4`,n),t[4]=n,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,L.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:`Parameters`}),t[6]=o):o=t[6];let s;t[7]===r?s=t[8]:(s=JSON.stringify(r,null,2),t[7]=r,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,L.jsx)(`div`,{className:`bg-muted/50 rounded-md`,children:(0,L.jsx)(E6,{code:s,language:`json`})}),t[9]=s,t[10]=c);let l;return t[11]!==i||t[12]!==a||t[13]!==c?(l=(0,L.jsxs)(`div`,{className:a,...i,children:[o,c]}),t[11]=i,t[12]=a,t[13]=c,t[14]=l):l=t[14],l},P6=e=>{let t=(0,W.c)(24),n,r,i,a;if(t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,output:i,errorText:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a),!(i||r))return null;let o;t[5]===n?o=t[6]:(o=P(`space-y-2 p-4`,n),t[5]=n,t[6]=o);let s=r?`Error`:`Result`,c;t[7]===s?c=t[8]:(c=(0,L.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:s}),t[7]=s,t[8]=c);let l=r?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`,u;t[9]===l?u=t[10]:(u=P(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,l),t[9]=l,t[10]=u);let d;t[11]===r?d=t[12]:(d=r&&(0,L.jsx)(`div`,{children:r}),t[11]=r,t[12]=d);let f;t[13]===i?f=t[14]:(f=F6(i),t[13]=i,t[14]=f);let p;t[15]!==u||t[16]!==d||t[17]!==f?(p=(0,L.jsxs)(`div`,{className:u,children:[d,f]}),t[15]=u,t[16]=d,t[17]=f,t[18]=p):p=t[18];let m;return t[19]!==a||t[20]!==o||t[21]!==c||t[22]!==p?(m=(0,L.jsxs)(`div`,{className:o,...a,children:[c,p]}),t[19]=a,t[20]=o,t[21]=c,t[22]=p,t[23]=m):m=t[23],m};function F6(e){return typeof e==`string`?(0,L.jsx)(E6,{code:e,language:`json`}):(0,I.isValidElement)(e)?(0,L.jsx)(`div`,{children:e}):typeof e==`object`?(0,L.jsx)(E6,{code:JSON.stringify(e,null,2),language:`json`}):typeof e==`number`||typeof e==`bigint`?(0,L.jsx)(`div`,{children:e}):(0,L.jsx)(`div`,{})}function I6(e){let t=(0,W.c)(20),{part:n}=e,r;t[0]===n?r=t[1]:(r=S_(n),t[0]=n,t[1]=r);let i=`Executing ${r}`,a;t[2]!==n||t[3]!==i?(a=(0,L.jsx)(j6,{title:i,part:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===n.input?o=t[6]:(o=(0,L.jsx)(N6,{input:n.input}),t[5]=n.input,t[6]=o);let s;t[7]===n.output?s=t[8]:(s=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[7]=n.output,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,L.jsx)(C6,{className:`break-all`,children:s}),t[9]=s,t[10]=c);let l;t[11]!==n.errorText||t[12]!==c?(l=(0,L.jsx)(P6,{output:c,errorText:n.errorText}),t[11]=n.errorText,t[12]=c,t[13]=l):l=t[13];let u;t[14]!==o||t[15]!==l?(u=(0,L.jsxs)(M6,{children:[o,l]}),t[14]=o,t[15]=l,t[16]=u):u=t[16];let d;return t[17]!==a||t[18]!==u?(d=(0,L.jsxs)(k6,{"data-copy-exclude":`assistant-snapshot`,children:[a,u]}),t[17]=a,t[18]=u,t[19]=d):d=t[19],d}function L6(e){let t=(0,W.c)(18),{part:n}=e,r=`Executing ${n.toolName}`,i;t[0]!==n||t[1]!==r?(i=(0,L.jsx)(j6,{title:r,part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n.input?a=t[4]:(a=(0,L.jsx)(N6,{input:n.input}),t[3]=n.input,t[4]=a);let o;t[5]===n.output?o=t[6]:(o=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[5]=n.output,t[6]=o);let s;t[7]===o?s=t[8]:(s=(0,L.jsx)(C6,{className:`break-all`,children:o}),t[7]=o,t[8]=s);let c;t[9]!==n.errorText||t[10]!==s?(c=(0,L.jsx)(P6,{output:s,errorText:n.errorText}),t[9]=n.errorText,t[10]=s,t[11]=c):c=t[11];let l;t[12]!==a||t[13]!==c?(l=(0,L.jsxs)(M6,{children:[a,c]}),t[12]=a,t[13]=c,t[14]=l):l=t[14];let u;return t[15]!==i||t[16]!==l?(u=(0,L.jsxs)(k6,{"data-copy-exclude":`assistant-snapshot`,children:[i,l]}),t[15]=i,t[16]=l,t[17]=u):u=t[17],u}var R6=(0,I.createContext)(!1);function z6(e){return e.parts.filter(g_).map(e=>e.text).join(`
343
+ `)}function B6(){return(0,I.use)(R6)}function V6(e){return b_(e)&&e.toolMetadata?.kind===`subagent`}function H6(e,t){let n=x_(e);return{toolKey:n,toolEntry:t?.[n]}}function U6(e,t){return e?.static===!1&&!!e?.requiresUserInput&&t===`input-available`}var W6=new Set(`a.abbr.b.bdi.bdo.br.cite.code.data.del.dfn.em.i.ins.kbd.mark.q.s.samp.small.span.strong.sub.sup.time.u.var.wbr`.split(`.`));function G6(e){if(!I.isValidElement(e))return!1;let t=typeof e.type==`string`?e.type:e.props.node?.tagName;return t===void 0||!W6.has(t)}function K6(e){let t=(0,W.c)(4),{children:n}=e,r=I.Children.toArray(n);if(!r.some(G6)){let e;return t[0]===n?e=t[1]:(e=(0,L.jsx)(`p`,{children:n}),t[0]=n,t[1]=e),e}if(r.every(G6))return n;let i;return t[2]===n?i=t[3]:(i=(0,L.jsx)(`div`,{children:n}),t[2]=n,t[3]=i),i}var q6={p:({children:e})=>(0,L.jsx)(K6,{children:e})};function J6(e){let t={...q6},n={};for(let r of e)oee(r),t[r.name]=r.component,n[r.name]=r.allowedAttributes;return{components:t,allowedTags:n}}function Y6(e){let t=(0,W.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({elements:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=n??[],t[3]=n,t[4]=i);let a;t[5]===i?a=t[6]:(a=J6(i),t[5]=i,t[6]=a);let o=a,s;return t[7]!==r||t[8]!==o?(s=(0,L.jsx)(C6,{...o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function X6(e){let t=(0,W.c)(22),{part:n}=e,{addToolApprovalResponse:r}=C3();if(n.state!==`approval-requested`)return null;let i;t[0]===n?i=t[1]:(i=n.title??x_(n),t[0]=n,t[1]=i);let a=i,o=`${a} approval`,s;t[2]===a?s=t[3]:(s=(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:a}),t[2]=a,t[3]=s);let c;t[4]===n.approval.requestReason?c=t[5]:(c=n.approval.requestReason&&(0,L.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n.approval.requestReason}),t[4]=n.approval.requestReason,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,L.jsxs)(`div`,{className:`space-y-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.approval.id?(u=(0,L.jsx)(at,{type:`button`,variant:`destructive`,onClick:()=>void r({id:n.approval.id,approved:!1}),children:`Deny`}),t[9]=r,t[10]=n.approval.id,t[11]=u):u=t[11];let d;t[12]!==r||t[13]!==n.approval.id?(d=(0,L.jsx)(at,{type:`button`,onClick:()=>void r({id:n.approval.id,approved:!0}),children:`Approve`}),t[12]=r,t[13]=n.approval.id,t[14]=d):d=t[14];let f;t[15]!==u||t[16]!==d?(f=(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17];let p;return t[18]!==o||t[19]!==l||t[20]!==f?(p=(0,L.jsxs)(`div`,{"aria-label":o,className:`border-border bg-muted/30 space-y-3 rounded-lg border p-3`,"data-copy-exclude":`assistant-snapshot`,role:`group`,children:[l,f]}),t[18]=o,t[19]=l,t[20]=f,t[21]=p):p=t[21],p}function Z6(e){let t=(0,W.c)(25),{part:n}=e,{registry:r}=b3();if(n.input===void 0){let e;return t[0]!==n.errorText||t[1]!==n.output||t[2]!==n.state?(e=n.state===`output-error`?(0,L.jsx)(P6,{output:n.output,errorText:n.errorText}):(0,L.jsx)(Sr,{className:`size-4 animate-spin`}),t[0]=n.errorText,t[1]=n.output,t[2]=n.state,t[3]=e):e=t[3],e}let i;t[4]===n?i=t[5]:(i=(0,L.jsx)(X6,{part:n}),t[4]=n,t[5]=i);let a=i;if(!r)return a;let o;t[6]!==n||t[7]!==r?(o=H6(n,r),t[6]=n,t[7]=r,t[8]=o):o=t[8];let{toolEntry:s}=o;if(s){let e=s.component,i;t[9]!==n||t[10]!==r.progress?(i=r.progress&&(0,L.jsx)(r.progress.component,{part:n}),t[9]=n,t[10]=r.progress,t[11]=i):i=t[11];let o;t[12]!==e||t[13]!==n?(o=(0,L.jsx)(e,{part:n}),t[12]=e,t[13]=n,t[14]=o):o=t[14];let c;return t[15]!==a||t[16]!==i||t[17]!==o?(c=(0,L.jsxs)(`div`,{className:`space-y-2`,children:[i,o,a]}),t[15]=a,t[16]=i,t[17]=o,t[18]=c):c=t[18],c}else{let e;t[19]!==n||t[20]!==r.progress?(e=r.progress&&(0,L.jsx)(r.progress.component,{part:n}),t[19]=n,t[20]=r.progress,t[21]=e):e=t[21];let i;return t[22]!==a||t[23]!==e?(i=(0,L.jsxs)(L.Fragment,{children:[e,a]}),t[22]=a,t[23]=e,t[24]=i):i=t[24],i}}var Q6={animation:`slideUp`};function $6(e){let t=(0,W.c)(3),{filename:n,url:r}=e,i=n??`Attached image`,a;return t[0]!==i||t[1]!==r?(a=(0,L.jsx)(`img`,{src:r,alt:i,className:`max-h-64 rounded-md border object-contain`}),t[0]=i,t[1]=r,t[2]=a):a=t[2],a}function e8(e){let t=(0,W.c)(16),{filename:n,mediaType:r,url:i}=e,a=n||`Untitled`,o;t[0]!==r||t[1]!==a||t[2]!==i?(o=i?.startsWith(`data:`)?null:i&&r.startsWith(`video/`)?(0,L.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:i,"aria-label":a,className:`max-h-96 w-full rounded-md bg-black`,children:(0,L.jsx)(`track`,{kind:`captions`})}):i&&r.startsWith(`audio/`)?(0,L.jsx)(`audio`,{controls:!0,preload:`metadata`,src:i,"aria-label":a,className:`w-full`,children:(0,L.jsx)(`track`,{kind:`captions`})}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o):o=t[3];let s=o,c=s?`mt-2`:void 0,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,L.jsx)(`strong`,{children:`File:`}),t[4]=l):l=t[4];let u;t[5]!==n||t[6]!==i?(u=i?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`a`,{href:i,download:n,className:`underline`,children:`Download`})]}):null,t[5]=n,t[6]=i,t[7]=u):u=t[7];let d;t[8]!==r||t[9]!==a||t[10]!==c||t[11]!==u?(d=(0,L.jsxs)(`div`,{className:c,children:[l,` `,a,` (`,r,`)`,u]}),t[8]=r,t[9]=a,t[10]=c,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==s||t[14]!==d?(f=(0,L.jsxs)(ii,{className:`bg-muted/30 block w-full rounded-md p-3 text-sm text-inherit`,children:[s,d]}),t[13]=s,t[14]=d,t[15]=f):f=t[15],f}function t8(e){let t=(0,W.c)(4),{filename:n,mediaType:r,url:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=r.split(`/`)[0]===`image`?(0,L.jsx)($6,{filename:n,url:i}):(0,L.jsx)(e8,{filename:n,mediaType:r,url:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}function n8(e){let t=(0,W.c)(9),{text:n,elements:r,className:i}=e,{status:a}=x3(),o=B6(),s;t[0]===i?s=t[1]:(s=P(`text-sm`,i),t[0]=i,t[1]=s);let c=!o&&a===`streaming`,l;t[2]!==r||t[3]!==c||t[4]!==n?(l=(0,L.jsx)(Y6,{elements:r,animated:Q6,isAnimating:c,children:n}),t[2]=r,t[3]=c,t[4]=n,t[5]=l):l=t[5];let u;return t[6]!==s||t[7]!==l?(u=(0,L.jsx)(`div`,{className:s,children:l}),t[6]=s,t[7]=l,t[8]=u):u=t[8],u}function r8(e){let t=(0,W.c)(8),{part:n}=e,r=i8(),i;t[0]!==n||t[1]!==r?(i=r&&(0,L.jsx)(I6,{part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=(0,L.jsx)(Z6,{part:n}),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,L.jsxs)(L.Fragment,{children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function i8(){let{debugMode:e}=b3(),t=B6();return!!e&&!t}function a8(e){return!!e&&e!==`output-available`}function o8(e){let t=(0,W.c)(5),{label:n,part:r,state:i}=e,a=B6(),o;return t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i?(o=!a&&!!n.actions&&!!r&&!a8(i),t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o}function s8(e){let t=(0,W.c)(18),{label:n,part:r}=e,i=n.icon,a=n.actions,o;t[0]!==n||t[1]!==r?(o={label:n,part:r,state:r.state},t[0]=n,t[1]=r,t[2]=o):o=t[2];let s=o8(o),c;t[3]!==i||t[4]!==n.isError?(c=i&&(0,L.jsx)(i,{className:P(`size-3.5`,n.isError?`text-destructive`:`text-muted-foreground`)}),t[3]=i,t[4]=n.isError,t[5]=c):c=t[5];let l;t[6]===n.name?l=t[7]:(l=(0,L.jsx)(`span`,{className:`font-mono`,children:n.name}),t[6]=n.name,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==a||t[12]!==r||t[13]!==s?(d=s&&a&&(0,L.jsx)(a,{part:r}),t[11]=a,t[12]=r,t[13]=s,t[14]=d):d=t[14];let f;return t[15]!==u||t[16]!==d?(f=(0,L.jsxs)(`div`,{className:`text-muted-foreground flex items-center justify-between gap-1.5 text-xs`,children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function c8(e){let t=(0,W.c)(3),{name:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,L.jsxs)(`span`,{"data-slot":`tool-arg`,children:[n,`: "`,r,`"`]}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function l8(e){let t=(0,W.c)(23),{label:n,state:r,part:i,children:a}=e,o=n.actions,s;t[0]!==n||t[1]!==i||t[2]!==r?(s={label:n,part:i,state:r},t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c=o8(s),l;t[4]===n.args?l=t[5]:(l=n.args?Object.entries(n.args).map(u8):`...`,t[4]=n.args,t[5]=l);let u;t[6]!==a||t[7]!==n.name||t[8]!==l?(u=(0,L.jsxs)(`span`,{className:`text-muted-foreground min-w-0 truncate font-mono text-xs [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:mr-1 [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:content-[',']`,children:[n.name,`(`,a,l,`)`]}),t[6]=a,t[7]=n.name,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==o||t[11]!==i||t[12]!==c?(d=c&&o&&i&&(0,L.jsx)(`span`,{className:`shrink-0`,children:(0,L.jsx)(o,{part:i})}),t[10]=o,t[11]=i,t[12]=c,t[13]=d):d=t[13];let f;t[14]!==u||t[15]!==d?(f=(0,L.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16];let p;t[17]!==n.detail||t[18]!==n.isError?(p=n.detail&&(0,L.jsx)(`span`,{className:P(`line-clamp-3 text-start font-mono text-[10px] leading-relaxed whitespace-pre-wrap`,n.isError?`text-destructive/80`:`text-muted-foreground`),children:n.detail}),t[17]=n.detail,t[18]=n.isError,t[19]=p):p=t[19];let m;return t[20]!==f||t[21]!==p?(m=(0,L.jsxs)(`span`,{className:`mb-2 flex flex-col gap-1`,children:[f,p]}),t[20]=f,t[21]=p,t[22]=m):m=t[22],m}function u8(e){let[t,n]=e;return(0,L.jsx)(c8,{name:t,value:n},t)}function d8(e){return e.type===`text`&&e.providerMetadata?.openai?.phase===`commentary`}function f8(e){let t=(0,W.c)(9),{segment:n,elements:r,className:i}=e,a;if(t[0]!==i||t[1]!==r||t[2]!==n.parts){let e;t[4]!==i||t[5]!==r?(e=e=>{let{part:t,idx:n}=e;return t.type===`text`?(0,L.jsx)(n8,{text:t.text,elements:r,className:i},`${n}-text`):null},t[4]=i,t[5]=r,t[6]=e):e=t[6],a=n.parts.map(e),t[0]=i,t[1]=r,t[2]=n.parts,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,L.jsx)(L.Fragment,{children:a}),t[7]=a,t[8]=o),o}function p8(e){let t=(0,W.c)(4),{segment:n}=e,{part:r}=n;if(r.type!==`file`)return null;let i;return t[0]!==r.filename||t[1]!==r.mediaType||t[2]!==r.url?(i=(0,L.jsx)(t8,{filename:r.filename,mediaType:r.mediaType,url:r.url}),t[0]=r.filename,t[1]=r.mediaType,t[2]=r.url,t[3]=i):i=t[3],i}function m8(e){let t=(0,W.c)(9),{segment:n}=e,{messages:r}=C3(),i;t[0]===r?i=t[1]:(i=w3(r),t[0]=r,t[1]=i);let a=i,o;if(t[2]!==n.parts||t[3]!==a){let e;t[5]===a?e=t[6]:(e=e=>{let{part:t,idx:n}=e;if(t.type!==`source-url`)return null;let r=T3(a,t.url);return r===null?null:(0,L.jsx)(L3,{source:{url:t.url,title:t.title},index:r},`source-${n}`)},t[5]=a,t[6]=e),o=n.parts.map(e),t[2]=n.parts,t[3]=a,t[4]=o}else o=t[4];let s;return t[7]===o?s=t[8]:(s=(0,L.jsx)(`span`,{children:o}),t[7]=o,t[8]=s),s}function h8(e){let t=(0,W.c)(3),{segment:n}=e,r=F3();if(B6())return null;let{part:i}=n;if(i.type!==`reasoning`)return null;let a=r===`streaming`,o;return t[0]!==i.text||t[1]!==a?(o=(0,L.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:(0,L.jsx)(C6,{animated:Q6,isAnimating:a,children:i.text})}),t[0]=i.text,t[1]=a,t[2]=o):o=t[2],o}function g8(e){let t=(0,W.c)(2),{segment:n}=e;if(!i8())return null;let{part:r}=n;if(r.type!==`dynamic-tool`)return null;let i;return t[0]===r?i=t[1]:(i=(0,L.jsx)(L6,{part:r}),t[0]=r,t[1]=i),i}var _8=(0,I.createContext)(null),v8=(0,I.createContext)(null);function y8(){let e=(0,I.use)(_8);if(!e)throw Error(`Segment.Tool* parts must be rendered within Segment.Tool`);return e}function b8(e){let t=(0,W.c)(29),{segment:n,children:r}=e,i=b3(),a=F3(),{part:o}=n;if(!v_(o))return null;let s,c,l,u;t[0]!==i.registry||t[1]!==a||t[2]!==o?({toolEntry:u}=H6(o,i.registry),c=U6(u,o.state),s=!c&&D3(o,a),l=u?.label?.(o),t[0]=i.registry,t[1]=a,t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u):(s=t[3],c=t[4],l=t[5],u=t[6]);let d=l,f;t[7]!==s||t[8]!==d||t[9]!==o?(f=s?{...d??{name:x_(o)},isError:!0,detail:`Cancelled by user`}:d,t[7]=s,t[8]=d,t[9]=o,t[10]=f):f=t[10];let p=f,m=u?.static===!1&&!!u?.requiresUserInput&&!c,h;t[11]!==s||t[12]!==c||t[13]!==m||t[14]!==p||t[15]!==o?(h={part:o,label:p,aborted:s,activeClientInput:c,defaultOpen:m},t[11]=s,t[12]=c,t[13]=m,t[14]=p,t[15]=o,t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==p||t[19]!==o.state?(g={label:p,state:o.state,aborted:s},t[17]=s,t[18]=p,t[19]=o.state,t[20]=g):g=t[20];let _;t[21]===r?_=t[22]:(_=r??(0,L.jsx)(S8,{}),t[21]=r,t[22]=_);let v;t[23]!==g||t[24]!==_?(v=(0,L.jsx)(v8,{value:g,children:_}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let y;return t[26]!==h||t[27]!==v?(y=(0,L.jsx)(_8,{value:h,children:v}),t[26]=h,t[27]=v,t[28]=y):y=t[28],y}function x8(){let e=(0,W.c)(2),{part:t,activeClientInput:n}=y8();if(n)return null;let r;return e[0]===t?r=e[1]:(r=(0,L.jsx)(r8,{part:t}),e[0]=t,e[1]=r),r}function S8(e){let t=(0,W.c)(9),{children:n}=e,{part:r,label:i,defaultOpen:a}=y8();if(!i){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(x8,{})}),t[0]=e):e=t[0],e}let o;t[1]!==n||t[2]!==i||t[3]!==r?(o=(0,L.jsx)(qi,{className:`cursor-pointer`,children:(0,L.jsx)(l8,{label:i,state:r.state,part:r,children:n})}),t[1]=n,t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(Ji,{className:`mb-2`,children:(0,L.jsx)(x8,{})}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,L.jsxs)(Ki,{defaultOpen:a,className:`flex min-w-0 flex-1 flex-col`,children:[o,s]}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}var C8={Text:f8,File:p8,Source:m8,Reasoning:h8,DynamicTool:g8,Tool:b8,ToolDisclosure:S8,ToolContent:x8};function w8(e){return v_(e)?`tool`:e.type===`dynamic-tool`?`dynamic-tool`:e.type===`reasoning`&&`text`in e&&e.text?`reasoning`:null}function T8(e,t){return e.kind===`text`||e.kind===`file`||e.kind===`source`?!1:e.kind===`reasoning`||e.kind!==`dynamic-tool`||!!t}function E8(e,t,n){let r=e[t+1];return!!r&&T8(r,n)}function D8(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=w8(r);if(i)t.push({kind:i,part:r,idx:n});else if(r.type===`text`){let e=t[t.length-1];e&&e.kind===`text`?e.parts.push({part:r,idx:n}):t.push({kind:`text`,parts:[{part:r,idx:n}]})}else if(r.type===`file`)t.push({kind:`file`,part:r,idx:n});else if(r.type===`source-url`){let e=t[t.length-1];e&&e.kind===`source`?e.parts.push({part:r,idx:n}):t.push({kind:`source`,parts:[{part:r,idx:n}]})}}return t}function O8(e,t){return e.kind===`text`||e.kind===`source`?e.parts[0]?.idx??t:e.idx}(0,I.memo)(function(e){let t=(0,W.c)(8),{segment:n}=e;if(n.kind===`tool`){let e;return t[0]===n?e=t[1]:(e=(0,L.jsx)(C8.Tool,{segment:n}),t[0]=n,t[1]=e),e}if(n.kind===`reasoning`){let e;return t[2]===n?e=t[3]:(e=(0,L.jsx)(C8.Reasoning,{segment:n}),t[2]=n,t[3]=e),e}if(n.kind===`text`){let e;return t[4]===n?e=t[5]:(e=(0,L.jsx)(C8.Text,{segment:n,className:`text-xs`}),t[4]=n,t[5]=e),e}if(n.kind===`file`){let e;return t[6]===n?e=t[7]:(e=(0,L.jsx)(C8.File,{segment:n}),t[6]=n,t[7]=e),e}return null},k8);function k8(e,t){return e.complete&&t.complete&&e.cacheKey===t.cacheKey}function A8(e){let t=(0,W.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({icon:r,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a={scale:.94},t[4]=a):a=t[4];let o;t[5]===n?o=t[6]:(o=P(`group text-muted-foreground hover:text-foreground relative rounded-lg p-2 transition-colors`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(`span`,{className:`bg-primary/10 absolute inset-0 rounded-lg opacity-0 transition-opacity group-hover:opacity-100`}),t[7]=s):s=t[7];let c;return t[8]!==r||t[9]!==i||t[10]!==o?(c=(0,L.jsxs)(NA.button,{type:`button`,whileTap:a,className:o,...i,children:[r,s]}),t[8]=r,t[9]=i,t[10]=o,t[11]=c):c=t[11],c}function j8(){let{index:e}=I3(),{messages:t}=P3(),n=F3();return!(e===t.length-1&&(n===`submitted`||n===`streaming`||n===`error`))}function M8(e){let t=(0,W.c)(5),{className:n,children:r}=e;if(!j8()||I.Children.toArray(r).length===0)return null;let i;t[0]===n?i=t[1]:(i=P(`mt-1 flex items-center gap-0.5`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,L.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function N8(e){let t=(0,W.c)(12),{className:n}=e,{message:r}=I3(),[i,a]=w6(),o=i?`Copied`:`Copy message`,s;t[0]===n?s=t[1]:(s=P(`p-1.5`,n),t[0]=n,t[1]=s);let c;t[2]!==a||t[3]!==r?(c=()=>void a(z6(r)),t[2]=a,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,L.jsx)(i?je:mr,{className:`size-3.5`}),t[5]=i,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,L.jsx)(A8,{"aria-label":o,className:s,onClick:c,icon:l}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function P8(e){let t=(0,W.c)(9),{className:n}=e,{message:r}=I3(),{regenerate:i}=C3(),a;t[0]===n?a=t[1]:(a=P(`p-1.5`,n),t[0]=n,t[1]=a);let o;t[2]!==r.id||t[3]!==i?(o=()=>void i({messageId:r.id}),t[2]=r.id,t[3]=i,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(Pr,{className:`size-3.5`}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,L.jsx)(A8,{"aria-label":`Regenerate response`,className:a,onClick:o,icon:s}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function F8(e){let t=(0,W.c)(12),{className:n}=e,{message:r}=I3(),[i,a]=w6(),o=i?`Copied`:`Copy debug JSON`,s;t[0]===n?s=t[1]:(s=P(`p-1.5`,n),t[0]=n,t[1]=s);let c;t[2]!==a||t[3]!==r?(c=()=>void a(JSON.stringify(r,null,2)),t[2]=a,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,L.jsx)(i?je:Dn,{className:`size-3.5`}),t[5]=i,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,L.jsx)(A8,{"aria-label":o,className:s,onClick:c,icon:l}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function I8(e){let t=(0,W.c)(7),{onTryAgain:n,error:r}=e,i=r instanceof Error?r.message:`An error occurred. Please try again.`,a;t[0]===i?a=t[1]:(a=(0,L.jsx)(`div`,{className:`text-destructive text-sm`,children:(0,L.jsx)(C6,{mode:`static`,children:i})}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,L.jsx)(at,{type:`button`,onClick:n,size:`sm`,variant:`outline`,children:`Try Again`}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,L.jsx)(`div`,{className:`mt-3 flex justify-start`,children:(0,L.jsxs)(`div`,{className:`max-w-[80%] space-y-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s}function L8(e){let t=(0,W.c)(3),{error:n,onRetry:r}=e;if(!n||!r)return null;let i;return t[0]!==n||t[1]!==r?(i=(0,L.jsx)(I8,{onTryAgain:r,error:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function R8(e){let t=(0,W.c)(14),{messages:n,className:r,elements:i,status:a,children:o}=e,s;t[0]!==i||t[1]!==n||t[2]!==a?(s={messages:n,elements:i,status:a},t[0]=i,t[1]=n,t[2]=a,t[3]=s):s=t[3];let c=s,l;t[4]===r?l=t[5]:(l=P(`flex h-full flex-col`,r),t[4]=r,t[5]=l);let u;t[6]===o?u=t[7]:(u=(0,L.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col`,children:o}),t[6]=o,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,L.jsx)(`div`,{className:l,children:u}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;return t[11]!==d||t[12]!==c?(f=(0,L.jsx)(M3,{value:c,children:d}),t[11]=d,t[12]=c,t[13]=f):f=t[13],f}function z8(e){let t=(0,W.c)(5),{className:n,children:r}=e,i;t[0]===n?i=t[1]:(i=P(`flex flex-col gap-4`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,L.jsx)(`div`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function B8(e){let t=(0,W.c)(9),{message:n,index:r,className:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o={message:n,index:r},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]!==a||t[4]!==i?(c=(0,L.jsx)(`div`,{className:i,children:a}),t[3]=a,t[4]=i,t[5]=c):c=t[5];let l;return t[6]!==c||t[7]!==s?(l=(0,L.jsx)(N3,{value:s,children:c}),t[6]=c,t[7]=s,t[8]=l):l=t[8],l}function V8(){let e=(0,W.c)(5),{registry:t}=b3(),n=C3().messages,r;if(e[0]!==n||e[1]!==t){bb0:{if(!t){r=null;break bb0}let i=n.findLast(H8);if(!i){r=null;break bb0}let a;e[3]===t?a=e[4]:(a=e=>{if(!v_(e)||e.state!==`input-available`)return[];let n=t[x_(e)];return!n||n.static!==!1||!n.requiresUserInput?[]:[{part:e,entry:n}]},e[3]=t,e[4]=a),r=i.parts.flatMap(a).at(0)??null}e[0]=n,e[1]=t,e[2]=r}else r=e[2];return r}function H8(e){let{role:t}=e;return t===`assistant`}function U8(e){let t=(0,W.c)(10),{children:n,className:r}=e,i=V8(),a=i?.entry.component,o=i?`hidden`:`visible`,s;t[0]!==n||t[1]!==o?(s=(0,L.jsx)(I.Activity,{mode:o,children:n}),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==a||t[4]!==i||t[5]!==r?(c=i&&a?(0,L.jsx)(`div`,{className:P(`sticky bottom-0 mt-auto`,r),children:(0,L.jsx)(a,{part:i.part},i.part.toolCallId)}):null,t[3]=a,t[4]=i,t[5]=r,t[6]=c):c=t[6];let l;return t[7]!==s||t[8]!==c?(l=(0,L.jsxs)(L.Fragment,{children:[s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function W8(e,t){if(e===`error`||e===`ready`||!t)return null;if(t.role!==`assistant`)return`Thinking...`;for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(g_(n)&&d8(n)&&n.text)return n.text}for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(__(n)&&n.text)return n.text;if(b_(n)){let e=n.input;if(Pm(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return n.toolCallId}if(g_(n)&&n.text)return``}return`Thinking...`}function G8(e){let t=(0,W.c)(5),{isLast:n}=e,r=n!==void 0&&n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,L.jsx)(`span`,{className:`bg-muted-foreground/50 z-10 mt-1 size-2 shrink-0 rounded-full`}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=!r&&(0,L.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[1]=r,t[2]=a);let o;return t[3]===a?o=t[4]:(o=(0,L.jsxs)(`div`,{className:`absolute top-0 left-0 flex size-3.5 h-full flex-col items-center`,children:[i,a]}),t[3]=a,t[4]=o),o}function K8(e){let t=(0,W.c)(6),{marker:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=P(`relative z-0 flex gap-3 pl-5`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==n||t[4]!==a?(o=(0,L.jsxs)(`div`,{className:a,children:[n,r]}),t[2]=r,t[3]=n,t[4]=a,t[5]=o):o=t[5],o}function q8(){let e=(0,W.c)(6),t=F3(),{messages:n}=P3(),r=V8(),i=n[n.length-1],a;e[0]!==t||e[1]!==i?(a=W8(t,i),e[0]=t,e[1]=i,e[2]=a):a=e[2];let o=a;if(!o||r)return null;let s;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(G8,{isLast:!0}),e[3]=s):s=e[3];let c;return e[4]===o?c=e[5]:(c=(0,L.jsx)(K8,{className:`mt-2`,marker:s,children:(0,L.jsx)(`span`,{role:`status`,children:(0,L.jsx)(k3,{as:`span`,className:`text-muted-foreground line-clamp-2 font-mono text-xs`,children:o})})}),e[4]=o,e[5]=c),c}var J8=[`inputTokens`,`outputTokens`,`reasoningTokens`,`cachedInputTokens`,`totalTokens`],Y8={inputTokens:[[`inputTokens`],[`raw`,`prompt_tokens`]],outputTokens:[[`outputTokens`],[`raw`,`completion_tokens`]],reasoningTokens:[[`reasoningTokens`],[`outputTokenDetails`,`reasoningTokens`],[`raw`,`completion_tokens_details`,`reasoning_tokens`]],cachedInputTokens:[[`inputTokenDetails`,`cacheReadTokens`],[`cachedInputTokens`],[`inputTokenDetails`,`cachedTokens`],[`raw`,`prompt_tokens_details`,`cached_tokens`]],totalTokens:[[`totalTokens`],[`raw`,`total_tokens`]]};function X8(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e==`string`&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>=0)return t}return null}function Z8(e){if(!e||typeof e!=`object`)return null;let t={inputTokens:null,outputTokens:null,reasoningTokens:null,cachedInputTokens:null,totalTokens:null};for(let n of J8)for(let r of Y8[n]){let i=X8(q4(e,r));if(i!==null){t[n]=i;break}}return J8.some(e=>t[e]!==null)?t:null}function Q8(e){return Pm(e)?Z8(e.totalUsage??e.usage):null}function $8(e){let t=[`↑ ${Z4(e.inputTokens)}`,`↓ ${Z4(e.outputTokens)}`];return e.totalTokens!==null&&t.push(`· ${X4(e.totalTokens)} tokens`),e.cachedInputTokens!==null&&e.cachedInputTokens>0&&t.push(`(${Z4(e.cachedInputTokens)} cached)`),t.join(` `)}var e5=`x-upload-filename`,t5=Se({path:F().startsWith(`/`),name:F().min(1),mediaType:Gt([`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/heic`,`image/heif`,`video/mp4`,`video/quicktime`,`audio/mpeg`,`audio/mp4`,`audio/wav`]),size:st().nonnegative(),url:ge()}),n5=class extends Sv{sessionsApi;request;constructor({api:e,fetch:t=(e,t)=>globalThis.fetch(e,t),tools:n={},elements:r=[]}){let i=o5(e),a=r.map(JA);super({api:i,fetch:async(e,n)=>{let r=await t(e,n);if((n?.method??`GET`).toUpperCase()!==`POST`||!r.ok)return r;let i=await r.json();if(!s5(i))throw Error(`Zukhruf returned an invalid accepted-turn response`);let a=o5(String(e)),o=decodeURIComponent(a.slice(a.lastIndexOf(`/`)+1));if(i.sessionId!==o)throw Error(`Zukhruf returned a different session ID`);let s=n?.signal;return s?.addEventListener(`abort`,()=>{t(`${a}/cancel`,{method:`POST`})},{once:!0}),t(`${a}/stream`,{headers:{accept:`text/event-stream`},method:`GET`,signal:s})},prepareSendMessagesRequest:({id:e,messages:t,trigger:r})=>{let o=t[t.length-1];if(!o)throw Error(`A message is required`);return{api:r5(i,e),body:{sessionId:e,message:o,trigger:r,...Object.keys(n).length>0?{tools:n}:{},...a.length>0?{elements:a}:{}}}},prepareReconnectToStreamRequest:({headers:e,id:t})=>({api:`${r5(i,t)}/stream`,headers:e})}),this.sessionsApi=i,this.request=t}async uploadFile(e,t){let n=await this.request(`${r5(this.sessionsApi,e)}/uploads`,{method:`POST`,headers:{"content-type":t.type,[e5]:encodeURIComponent(t.name)},body:t});if(!n.ok)throw Error(await i5(n,t));let r=t5.safeParse(await n.json());if(!r.success)throw Error(`Zukhruf returned an invalid upload response`);return r.data}};function r5(e,t){return`${e}/${encodeURIComponent(t)}`}async function i5(e,t){let n=`Uploading ${t.name} failed with HTTP ${e.status}`,r=a5(await e.json().catch(e=>{if(e instanceof SyntaxError)return null;throw e}));return r?`${n}: ${r}`:n}function a5(e){if(typeof e!=`object`||!e)return null;let t=`cause`in e&&typeof e.cause==`object`&&e.cause!==null?e.cause:null;return[t&&`code`in t&&typeof t.code==`string`?t.code:null,t&&`detail`in t&&typeof t.detail==`string`?t.detail:`error`in e&&typeof e.error==`string`?e.error:null].filter(e=>e!==null).join(` — `)||null}function o5(e){return e.replace(/\/$/,``)}function s5(e){return typeof e==`object`&&!!e&&`ok`in e&&e.ok===!0&&`sessionId`in e&&typeof e.sessionId==`string`&&`turnId`in e&&typeof e.turnId==`string`}function c5(e){let t=(0,W.c)(24),{label:n,open:r,onOpenChange:i,children:a,className:o,triggerClassName:s,contentClassName:c,chevronClassName:l}=e,u;t[0]===s?u=t[1]:(u=P(`flex items-center font-mono`,s),t[0]=s,t[1]=u);let d;t[2]===u?d=t[3]:(d=(0,L.jsx)(`button`,{type:`button`,className:u}),t[2]=u,t[3]=d);let f=r&&`rotate-180`,p;t[4]!==l||t[5]!==f?(p=P(`size-4 transition-transform`,l,f),t[4]=l,t[5]=f,t[6]=p):p=t[6];let m;t[7]===p?m=t[8]:(m=(0,L.jsx)(me,{className:p}),t[7]=p,t[8]=m);let h;t[9]===n?h=t[10]:(h=(0,L.jsx)(`span`,{children:n}),t[9]=n,t[10]=h);let g;t[11]!==d||t[12]!==m||t[13]!==h?(g=(0,L.jsxs)(qi,{render:d,children:[m,h]}),t[11]=d,t[12]=m,t[13]=h,t[14]=g):g=t[14];let _;t[15]!==a||t[16]!==c?(_=(0,L.jsx)(Ji,{className:c,children:a}),t[15]=a,t[16]=c,t[17]=_):_=t[17];let v;return t[18]!==o||t[19]!==i||t[20]!==r||t[21]!==g||t[22]!==_?(v=(0,L.jsxs)(Ki,{open:r,onOpenChange:i,className:o,children:[g,_]}),t[18]=o,t[19]=i,t[20]=r,t[21]=g,t[22]=_,t[23]=v):v=t[23],v}function l5(e){let t=(0,W.c)(7),{metadata:n}=e;if(!n)return null;let r,i,a;if(t[0]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Q8(n);if(!e){a=null;break bb0}r=`text-muted-foreground mt-2 text-xs tabular-nums opacity-60`,i=$8(e)}t[0]=n,t[1]=r,t[2]=i,t[3]=a}else r=t[1],i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o;return t[4]!==r||t[5]!==i?(o=(0,L.jsx)(`div`,{className:r,children:i}),t[4]=r,t[5]=i,t[6]=o):o=t[6],o}function u5(e,t){return Pm(e.metadata)?e.metadata[t]:void 0}function d5(e){let t=u5(e,`reminders`);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.text==`string`&&t.text.trim().length>0}):[]}function f5(e){let t=u5(e,`uploads`);return Array.isArray(t)?t.flatMap(e=>{let t=t5.safeParse(e);return t.success?[t.data]:[]}):[]}function p5(e){let t=(0,W.c)(7),{text:n}=e,[r,i]=(0,I.useState)(!1),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>i(m5),t[0]=a):a=t[0];let o=!r&&`line-clamp-3`,s;t[1]===o?s=t[2]:(s=P(`hover:text-foreground w-full cursor-pointer text-left whitespace-pre-wrap`,o),t[1]=o,t[2]=s);let c;return t[3]!==r||t[4]!==s||t[5]!==n?(c=(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":r,className:s,children:n})}),t[3]=r,t[4]=s,t[5]=n,t[6]=c):c=t[6],c}function m5(e){return!e}function h5(e){let t=(0,W.c)(8),{reminders:n}=e,[r,i]=(0,I.useState)(!1);if(n.length===0)return null;let a=`${n.length} reminder${n.length===1?``:`s`} attached`,o;t[0]===n?o=t[1]:(o=n.map(g5),t[0]=n,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,L.jsx)(`ul`,{className:`border-ink-12 text-muted-foreground space-y-1 border-l pl-3 text-xs`,children:o}),t[2]=o,t[3]=s);let c;return t[4]!==a||t[5]!==r||t[6]!==s?(c=(0,L.jsx)(c5,{label:a,open:r,onOpenChange:i,className:`mt-1`,triggerClassName:`text-muted-foreground hover:text-foreground gap-1.5 text-xs`,contentClassName:`mt-1.5`,chevronClassName:`size-3.5`,children:s}),t[4]=a,t[5]=r,t[6]=s,t[7]=c):c=t[7],c}function g5(e){return(0,L.jsx)(p5,{text:e.text},e.id)}function _5(e){let t=(0,W.c)(19),{upload:n}=e;if(n.mediaType.startsWith(`video/`)){let e;t[0]!==n.name||t[1]!==n.url?(e=(0,L.jsx)(`video`,{src:n.url,"aria-label":n.name,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full object-cover`}),t[0]=n.name,t[1]=n.url,t[2]=e):e=t[2];let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,L.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center text-2xl text-white drop-shadow`,children:`▶`}),t[3]=r):r=t[3];let i;return t[4]!==e||t[5]!==n.name?(i=(0,L.jsxs)(oi,{variant:`image`,className:`size-36 rounded-2xl`,title:n.name,children:[e,r]}),t[4]=e,t[5]=n.name,t[6]=i):i=t[6],i}if(n.mediaType.startsWith(`audio/`)){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-2xl`,children:`♪`}),t[7]=e):e=t[7];let r;t[8]===n.name?r=t[9]:(r=(0,L.jsx)(`span`,{className:`text-foreground w-full truncate text-center`,children:n.name}),t[8]=n.name,t[9]=r);let i;t[10]===n.mediaType?i=t[11]:(i=(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:n.mediaType}),t[10]=n.mediaType,t[11]=i);let a;return t[12]!==r||t[13]!==i||t[14]!==n.name?(a=(0,L.jsxs)(oi,{variant:`icon`,className:`h-36 w-48 flex-col gap-1 rounded-2xl px-3 text-xs`,title:n.name,"aria-label":n.name,children:[e,r,i]}),t[12]=r,t[13]=i,t[14]=n.name,t[15]=a):a=t[15],a}let r;return t[16]!==n.name||t[17]!==n.url?(r=(0,L.jsx)(oi,{variant:`image`,className:`size-36 rounded-2xl`,children:(0,L.jsx)(`img`,{src:n.url,alt:n.name})}),t[16]=n.name,t[17]=n.url,t[18]=r):r=t[18],r}function v5(e){let t=(0,W.c)(13),{message:n}=e,r,i,a,o,s,c;if(t[0]!==n){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=f5(n);if(e.length===0){c=null;break bb0}r=si,i=`list`,a=`Attached files`,o=`max-w-full gap-2 py-0`,s=e.map(y5)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;return t[7]!==r||t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==s?(l=(0,L.jsx)(r,{role:i,"aria-label":a,className:o,children:s}),t[7]=r,t[8]=i,t[9]=a,t[10]=o,t[11]=s,t[12]=l):l=t[12],l}function y5(e){return(0,L.jsx)(`div`,{role:`listitem`,"data-slot":`attachment`,children:(0,L.jsx)(_5,{upload:e})},e.path)}function b5(e){let t=(0,W.c)(10),{body:n,reminders:r,metadata:i}=e,a;t[0]===n?a=t[1]:(a=(0,L.jsx)(`div`,{className:`flex-1 space-y-3`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,L.jsx)(h5,{reminders:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i!==void 0&&(0,L.jsx)(l5,{metadata:i}),t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,L.jsxs)(`div`,{className:`bg-secondary flex max-w-[80%] flex-col gap-3 rounded-lg p-3`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function x5(e){let t=(0,W.c)(28),{message:n}=e;u5(n,`reminders`);let r;t[0]===n?r=t[1]:(r=Ly(n),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=d5(n),t[2]=n,t[3]=i);let a;t[4]!==r||t[5]!==i?(a={message:r,reminders:i},t[4]=r,t[5]=i,t[6]=a):a=t[6];let{message:o,reminders:s}=a,c;if(t[7]!==n){let e=u5(n,`alias`);c=typeof e==`string`&&e.trim().length>0?e:void 0,t[7]=n,t[8]=c}else c=t[8];let l=c;if(l){let e;t[9]===l?e=t[10]:(e=(0,L.jsx)(`div`,{className:`text-sm whitespace-pre-wrap`,children:l}),t[9]=l,t[10]=e);let n;return t[11]!==s||t[12]!==e?(n=(0,L.jsx)(b5,{reminders:s,body:e}),t[11]=s,t[12]=e,t[13]=n):n=t[13],n}let u;t[14]===o?u=t[15]:(u=(0,L.jsx)(v5,{message:o}),t[14]=o,t[15]=u);let d=o.metadata,f;if(t[16]!==o.id||t[17]!==o.parts){let e;t[19]===o.id?e=t[20]:(e=(e,t)=>e.type===`text`?(0,L.jsx)(`div`,{className:`text-sm whitespace-pre-wrap`,children:(0,L.jsx)(c2,{text:e.text})},`${o.id}-${t}-text`):null,t[19]=o.id,t[20]=e),f=o.parts.map(e),t[16]=o.id,t[17]=o.parts,t[18]=f}else f=t[18];let p;t[21]!==o.metadata||t[22]!==s||t[23]!==f?(p=(0,L.jsx)(b5,{reminders:s,metadata:d,body:f}),t[21]=o.metadata,t[22]=s,t[23]=f,t[24]=p):p=t[24];let m;return t[25]!==u||t[26]!==p?(m=(0,L.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-end gap-3`,children:[u,p]}),t[25]=u,t[26]=p,t[27]=m):m=t[27],m}var S5=(0,I.memo)(function(e){let t=(0,W.c)(7),{className:n}=e,{message:r}=I3(),i;t[0]===n?i=t[1]:(i=P(`flex justify-end`,n),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,L.jsx)(x5,{message:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,L.jsx)(`div`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o});function C5(e){return e.kind===`tool`?!V6(e.part):e.kind===`dynamic-tool`||e.kind===`reasoning`}function w5(e,t){return e.kind===`tool`?!0:e.kind===`reasoning`||e.kind===`dynamic-tool`?!!t:!1}function T5(e){return e.kind===`text`&&e.parts.some(({part:e})=>e.type===`text`&&!d8(e))}function E5(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(!C5(i)){n.push({kind:`segment`,segment:i,segmentIndex:r});continue}let a=[],o=r;for(;r<e.length&&C5(e[r]);){let n=e[r];w5(n,t)&&a.push({segment:n}),r++}r--,a.length>0&&n.push({kind:`group`,items:a,hasLaterText:e.slice(r+1).some(e=>T5(e)),firstIndex:o})}return n}function D5(e){if(e.kind!==`tool`&&e.kind!==`dynamic-tool`)return;let{part:t}=e;return b_(t)?t.state:void 0}function O5({groupStatus:e,labelCount:t}){return e===`running`?{title:`text-info`,detail:`text-info/80`,chevron:`text-info`}:e===`aborted`?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:e===`error`?t===1?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:{title:`text-warning`,detail:`text-warning/80`,chevron:`text-warning`}:{title:`text-muted-foreground`,detail:`text-muted-foreground`,chevron:`text-muted-foreground`}}function k5(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A5(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-3).trimEnd()}...`}function j5(e){if(typeof e==`string`)return A5(e,48);if(typeof e==`number`||typeof e==`boolean`)return String(e);if(Array.isArray(e))return`${e.length} items`}function M5(e){if(!k5(e))return;let t=[`command`,`query`,`path`,`file`,`table`,`metric`,`dimension`,`checks`],n=[...t.filter(t=>t in e).map(t=>[t,e[t]]),...Object.entries(e).filter(([e])=>!t.includes(e))],r={};for(let[e,t]of n){let n=j5(t);if(n&&(r[e]=n,Object.keys(r).length>=2))break}return Object.keys(r).length>0?r:void 0}function N5(e){if(k5(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim().length>0)return A5(n)}}function P5(e){if(e.kind!==`reasoning`)return;let{part:t}=e;if(t.type===`reasoning`)return A5(t.text,96)}function F5(e,t){if(e.kind===`reasoning`)return{kind:`reasoning`,name:`reasoning`,detail:P5(e)};if(e.kind===`dynamic-tool`&&e.part.type===`dynamic-tool`){let t=e.part;return{kind:`dynamic-tool`,name:t.toolName||`Tool`,args:M5(t.input),detail:N5(t.input)}}if(e.kind===`tool`&&v_(e.part)){let n=e.part,{toolEntry:r,toolKey:i}=H6(n,t),a=r?.label?.(n);return{kind:`tool`,name:a?.name??i,args:a?.args??M5(n.input),detail:a?.detail??N5(n.input),isError:a?.isError}}return{kind:`tool`,name:`Step`}}function I5(e){if(!e)return;let t=Object.entries(e).filter(e=>typeof e[1]==`string`&&e[1].trim().length>0);if(t.length!==0)return t.slice(0,2).map(([e,t])=>`${e}: ${A5(t,36)}`).join(`, `)}function L5(e){let t=I5(e.args);return t?`${e.name}(${t})`:e.name}function R5(e){return e===`output-available`||e===`output-error`||e===`output-denied`}function z5(e){return!!e&&!R5(e)}function B5(e,t){return E3(e,t)}function V5({items:e,labels:t,status:n,hasLaterText:r}){return e.some(({segment:e})=>B5(D5(e),n))?`aborted`:!r&&(n===`streaming`||n===`submitted`)?`running`:t.some(e=>e.isError)||e.some(({segment:e})=>{let t=D5(e);return t===`output-error`||t===`output-denied`})?`error`:e.some(({segment:e})=>z5(D5(e)))||!r&&t.every(e=>e.kind===`reasoning`)&&(n===`streaming`||n===`submitted`)?`running`:`complete`}function H5(e){return e&&`${e[0].toUpperCase()}${e.slice(1)}`}function U5(e){return e.filter(e=>e.kind!==`reasoning`).length}function W5(e,t){let n=U5(e);if(n!==0)return`${t===`running`||t===`aborted`?`running`:`ran`} ${n} ${n===1?`tool`:`tools`}`}function G5(e,t){let n=W5(e,t);if(n)return H5(t===`error`?`${n} with issues`:t===`aborted`?`cancelled after ${n}`:n)}function K5(e,t,n){let r=e.length===1?e[0]:void 0;if(t===`running`)return n||(r?.kind===`reasoning`?`Reasoning${r.detail?` ${r.detail}`:``}`:e.every(e=>e.kind===`reasoning`)?`Reasoning`:`Working...`);if(r){let e=L5(r);return t===`error`?`Failed ${e}`:t===`aborted`?`Cancelled ${e}`:r.kind===`reasoning`?`Reasoned${r.detail?` ${r.detail}`:``}`:`Called ${e}`}return e.every(e=>e.kind===`reasoning`)?`Reasoned`:G5(e,t)??`Ran tools`}function q5(e,t){if(t!==`running`){if(e.length===1){let t=e[0];return t.kind===`reasoning`?void 0:t.detail}return Array.from(new Set([...e].sort((e,t)=>e.kind===`reasoning`&&t.kind!==`reasoning`?1:e.kind!==`reasoning`&&t.kind===`reasoning`?-1:0).map(e=>e.name))).slice(0,3).join(`, `)||void 0}}function J5(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].segment;if(r.kind===`dynamic-tool`&&r.part.type===`dynamic-tool`){let e=N5(r.part.input);if(e)return e}if(r.kind===`tool`&&v_(r.part)){let e=N5(r.part.input);if(e)return e}r.kind===`reasoning`&&(t??=P5(r))}return t}function Y5(e,t){return!e||e.role!==`assistant`?!1:E5(D8(e.parts),t).some(e=>e.kind===`group`&&!e.hasLaterText)}function X5(){let e=(0,W.c)(8),{message:t}=I3(),{debugMode:n}=b3(),r;e[0]===t.parts?r=e[1]:(r=D8(t.parts),e[0]=t.parts,e[1]=r);let i=r,a;if(e[2]!==n||e[3]!==t.id||e[4]!==i){let r;e[6]===t.id?r=e[7]:(r=e=>e.kind===`group`?{...e,key:`${t.id}-${e.firstIndex}-group-${e.hasLaterText?`past`:`current`}`}:{...e,key:`${t.id}-${O8(e.segment,e.segmentIndex)}-${e.segment.kind}`},e[6]=t.id,e[7]=r),a=E5(i,n).map(r),e[2]=n,e[3]=t.id,e[4]=i,e[5]=a}else a=e[5];return a}var Z5=(0,I.createContext)(null);function Q5(){let e=(0,I.use)(Z5);if(!e)throw Error(`CompactTrajectory group parts must be rendered within CompactTrajectory.Group`);return e}function $5(e){let t=(0,W.c)(21),{group:n,children:r}=e,{registry:i}=b3(),{message:a}=I3(),o=F3(),[s,c]=(0,I.useState)(!n.hasLaterText),l,u,d;if(t[0]!==n.hasLaterText||t[1]!==n.items||t[2]!==i||t[3]!==o){let e;t[7]===i?e=t[8]:(e=e=>{let{segment:t}=e;return F5(t,i)},t[7]=i,t[8]=e),u=n.items.map(e),l=V5({items:n.items,labels:u,status:o,hasLaterText:n.hasLaterText}),d=O5({groupStatus:l,labelCount:u.length}),t[0]=n.hasLaterText,t[1]=n.items,t[2]=i,t[3]=o,t[4]=l,t[5]=u,t[6]=d}else l=t[4],u=t[5],d=t[6];let f=d,p;t[9]!==n.items||t[10]!==l||t[11]!==u||t[12]!==a.id||t[13]!==f?(p={items:n.items,labels:u,groupStatus:l,tone:f,messageId:a.id},t[9]=n.items,t[10]=l,t[11]=u,t[12]=a.id,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==r||t[16]!==s?(m=(0,L.jsx)(Ki,{open:s,onOpenChange:c,className:`my-2 min-w-0`,children:r}),t[15]=r,t[16]=s,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,L.jsx)(Z5,{value:p,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function e7(e){let t=(0,W.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,L.jsx)(`button`,{type:`button`,className:j3(`items-start`)}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,L.jsx)(qi,{render:r,children:(0,L.jsx)(`span`,{className:`min-w-0 flex-1 text-left text-sm`,children:n})}),t[1]=n,t[2]=i),i}function t7(){let e=(0,W.c)(12),{items:t,labels:n,groupStatus:r,tone:i}=Q5(),a;e[0]!==r||e[1]!==t||e[2]!==n?(a=K5(n,r,J5(t)),e[0]=r,e[1]=t,e[2]=n,e[3]=a):a=e[3];let o=a,s;e[4]!==r||e[5]!==n?(s=q5(n,r),e[4]=r,e[5]=n,e[6]=s):s=e[6];let c=s,l;return e[7]!==c||e[8]!==r||e[9]!==o||e[10]!==i?(l={title:o,detail:c,tone:i,groupStatus:r},e[7]=c,e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}function n7(e){let t=(0,W.c)(9),{title:n,suffix:r,children:i}=e,{title:a,tone:o,groupStatus:s}=t7(),c=n??a,l=r?`${c} · ${r}`:c,u=s===`running`,d=s===`running`?`text-info`:o.title,f;t[0]===d?f=t[1]:(f=P(`max-w-full min-w-0 truncate`,d),t[0]=d,t[1]=f);let p;t[2]!==u||t[3]!==f||t[4]!==l?(p=(0,L.jsx)(k3,{as:`span`,enabled:u,className:f,children:l}),t[2]=u,t[3]=f,t[4]=l,t[5]=p):p=t[5];let m;return t[6]!==i||t[7]!==p?(m=(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[p,i]}),t[6]=i,t[7]=p,t[8]=m):m=t[8],m}function r7(){let e=(0,W.c)(2),{tone:t}=Q5(),n;return e[0]===t.chevron?n=e[1]:(n=(0,L.jsx)(A3,{className:t.chevron}),e[0]=t.chevron,e[1]=n),n}function i7(e){let t=(0,W.c)(5),{detail:n}=e,{title:r,detail:i,tone:a}=t7();if(n===null)return null;let o=n??i;if(!o||o===r)return null;let s;t[0]===a.detail?s=t[1]:(s=P(`block truncate text-xs`,a.detail),t[0]=a.detail,t[1]=s);let c;return t[2]!==o||t[3]!==s?(c=(0,L.jsx)(`span`,{className:s,children:o}),t[2]=o,t[3]=s,t[4]=c):c=t[4],c}function a7(e){let t=(0,W.c)(14),{children:n}=e,{items:r,messageId:i,groupStatus:a}=Q5(),o=a===`running`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={initial:`instant`,resize:`instant`},t[0]=s):s=t[0];let{scrollRef:c,contentRef:l}=zA(s),u=o?c:void 0,d=o&&`max-h-64 overflow-y-auto`,f;t[1]===d?f=t[2]:(f=P(`mt-2`,d),t[1]=d,t[2]=f);let p=o?l:void 0,m;t[3]!==n||t[4]!==r||t[5]!==i?(m=n??r.map((e,t)=>{let{segment:n}=e,r=`${i}-${O8(n,t)}-${n.kind}`;return n.kind===`tool`?(0,L.jsx)(C8.Tool,{segment:n},r):n.kind===`reasoning`?(0,L.jsx)(C8.Reasoning,{segment:n},r):n.kind===`dynamic-tool`?(0,L.jsx)(C8.DynamicTool,{segment:n},r):null}),t[3]=n,t[4]=r,t[5]=i,t[6]=m):m=t[6];let h;t[7]!==p||t[8]!==m?(h=(0,L.jsx)(`div`,{ref:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;return t[10]!==u||t[11]!==f||t[12]!==h?(g=(0,L.jsx)(Ji,{ref:u,className:f,children:h}),t[10]=u,t[11]=f,t[12]=h,t[13]=g):g=t[13],g}function o7(e){let t=(0,W.c)(19),{item:n,textClassName:r}=e,i=r===void 0?`my-4`:r,{elements:a}=P3(),{segment:o}=n;if(o.kind===`text`){let e;t[0]===o.parts?e=t[1]:(e=o.parts.filter(s7),t[0]=o.parts,t[1]=e);let n=e;if(n.length===0)return null;let r;t[2]!==o||t[3]!==n?(r={...o,parts:n},t[2]=o,t[3]=n,t[4]=r):r=t[4];let s;return t[5]!==a||t[6]!==r||t[7]!==i?(s=(0,L.jsx)(C8.Text,{segment:r,elements:a,className:i}),t[5]=a,t[6]=r,t[7]=i,t[8]=s):s=t[8],s}if(o.kind===`file`){let e;return t[9]===o?e=t[10]:(e=(0,L.jsx)(C8.File,{segment:o}),t[9]=o,t[10]=e),e}if(o.kind===`source`){let e;return t[11]===o?e=t[12]:(e=(0,L.jsx)(C8.Source,{segment:o}),t[11]=o,t[12]=e),e}if(o.kind===`tool`){let e;return t[13]===o?e=t[14]:(e=(0,L.jsx)(C8.Tool,{segment:o}),t[13]=o,t[14]=e),e}if(o.kind===`reasoning`){let e;return t[15]===o?e=t[16]:(e=(0,L.jsx)(C8.Reasoning,{segment:o}),t[15]=o,t[16]=e),e}if(o.kind===`dynamic-tool`){let e;return t[17]===o?e=t[18]:(e=(0,L.jsx)(C8.DynamicTool,{segment:o}),t[17]=o,t[18]=e),e}return null}function s7(e){let{part:t}=e;return!d8(t)}function c7(){let e=(0,W.c)(1),t=F3(),{messages:n}=P3(),{debugMode:r}=b3(),i=n[n.length-1];if(t!==`ready`&&t!==`error`&&Y5(i,r))return null;let a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,L.jsx)(q8,{}),e[0]=a):a=e[0],a}var l7={Root:R8,List:z8,Item:B8,UserBubble:S5,AssistantContent:(0,I.memo)(function(e){let t=(0,W.c)(5),{className:n}=e,r=X5(),i;t[0]===r?i=t[1]:(i=r.map(u7),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,L.jsx)(`div`,{className:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}),Actions:M8,CopyAction:N8,RegenerateAction:P8,CopyDebugJsonAction:F8,Thinking:c7,Error:L8};function u7(e){return e.kind===`group`?(0,L.jsxs)($5,{group:e,children:[(0,L.jsxs)(e7,{children:[(0,L.jsx)(n7,{children:(0,L.jsx)(r7,{})}),(0,L.jsx)(i7,{})]}),(0,L.jsx)(a7,{})]},e.key):(0,L.jsx)(o7,{item:e},e.key)}function d7(e){let t=(0,W.c)(8),{message:n,className:r}=e,i;t[0]===r?i=t[1]:(i=P(`text-destructive/90 bg-destructive/10 flex items-start gap-2 rounded-md px-3 py-2 text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,L.jsx)(ne,{className:`text-destructive mt-0.5 size-4 shrink-0`}),t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o=(0,L.jsx)(`span`,{children:n}),t[3]=n,t[4]=o);let s;return t[5]!==i||t[6]!==o?(s=(0,L.jsxs)(`div`,{className:i,children:[a,o]}),t[5]=i,t[6]=o,t[7]=s):s=t[7],s}function f7(e){let t=(0,W.c)(15),{part:n}=e,r=b3(),i,a;if(t[0]!==r.registry||t[1]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let{toolEntry:e}=H6(n,r.registry);if(e&&U6(e,n.state)){let t=e.label?.(n);if(!t){a=null;break bb0}let r=t.icon,i=t.args?Object.values(t.args)[0]:void 0;a=(0,L.jsxs)(`div`,{className:`text-muted-foreground flex items-center text-xs`,children:[r&&(0,L.jsx)(r,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`ms-2 font-mono`,children:t.name}),i&&(0,L.jsxs)(`span`,{className:`truncate`,children:[`(`,i,`)`]})]});break bb0}i=e?.label?.(n)}t[0]=r.registry,t[1]=n,t[2]=i,t[3]=a}else i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o=i,s;t[4]!==o||t[5]!==n?(s=o&&(0,L.jsx)(s8,{label:o,part:n}),t[4]=o,t[5]=n,t[6]=s):s=t[6];let c;t[7]===o?c=t[8]:(c=o?.isError&&o.detail&&(0,L.jsx)(d7,{message:o.detail}),t[7]=o,t[8]=c);let l;t[9]===n?l=t[10]:(l=(0,L.jsx)(r8,{part:n}),t[9]=n,t[10]=l);let u;return t[11]!==s||t[12]!==c||t[13]!==l?(u=(0,L.jsxs)(L.Fragment,{children:[s,c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function p7(e){let t=(0,W.c)(5),{part:n}=e,[r,i]=(0,I.useState)(!1),a;t[0]===n.text?a=t[1]:(a=(0,L.jsx)(C6,{mode:`static`,children:n.text}),t[0]=n.text,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,L.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:`bg-muted/30 prose max-w-auto prose-sm text-muted-foreground border-border mb-4 w-full min-w-full rounded-lg p-3`,children:(0,L.jsx)(c5,{label:`Reasoning`,open:r,onOpenChange:i,className:`text-xs`,triggerClassName:`w-full gap-x-2 text-sm hover:opacity-80`,contentClassName:`mt-2`,children:a})}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function m7(e){let t=(0,W.c)(15),{part:n}=e,{elements:r}=P3(),i=i8();if(n.type===`text`){if(d8(n))return null;let e;return t[0]!==r||t[1]!==n.text?(e=(0,L.jsx)(n8,{text:n.text,elements:r}),t[0]=r,t[1]=n.text,t[2]=e):e=t[2],e}if(n.type===`dynamic-tool`){let e;return t[3]!==i||t[4]!==n?(e=i?(0,L.jsx)(L6,{part:n}):null,t[3]=i,t[4]=n,t[5]=e):e=t[5],e}if(v_(n)){let e;return t[6]===n?e=t[7]:(e=(0,L.jsx)(f7,{part:n}),t[6]=n,t[7]=e),e}if(n.type===`reasoning`&&n.text){let e;return t[8]!==i||t[9]!==n?(e=i?(0,L.jsx)(p7,{part:n}):null,t[8]=i,t[9]=n,t[10]=e):e=t[10],e}if(n.type===`file`){let e;return t[11]!==n.filename||t[12]!==n.mediaType||t[13]!==n.url?(e=(0,L.jsx)(t8,{filename:n.filename,mediaType:n.mediaType,url:n.url}),t[11]=n.filename,t[12]=n.mediaType,t[13]=n.url,t[14]=e):e=t[14],e}return null}(0,I.memo)(function(e){let t=(0,W.c)(10),{className:n}=e,{message:r}=I3(),i;t[0]===n?i=t[1]:(i=P(`flex-1 space-y-3`,n),t[0]=n,t[1]=i);let a;if(t[2]!==r.id||t[3]!==r.parts){let e;t[5]===r.id?e=t[6]:(e=(e,t)=>(0,L.jsx)(m7,{part:e},`${r.id}-${t}`),t[5]=r.id,t[6]=e),a=r.parts.map(e),t[2]=r.id,t[3]=r.parts,t[4]=a}else a=t[4];let o;return t[7]!==i||t[8]!==a?(o=(0,L.jsx)(`div`,{className:i,children:a}),t[7]=i,t[8]=a,t[9]=o):o=t[9],o});var h7={braille:{frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},pulse:{frames:[`⠁`,`⠉`,`⠋`,`⠛`,`⠟`,`⠿`,`⡿`,`⣿`,`⡿`,`⠿`,`⠟`,`⠛`,`⠋`,`⠉`,`⠁`,`⠀`],interval:80},clock:{frames:[`⠁`,`⠈`,`⠐`,`⠠`,`⢀`,`⡀`,`⠄`,`⠂`],interval:100},limerence:{frames:[`⠁`,`⠃`,`⠇`,`⡇`,`⣇`,`⣇`,`⣆`,`⣄`,`⣀`,`⢀`,`⠀`],interval:100}};function g7(e){let t=(0,W.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`braille`:i,o=Ve(),{frames:s,interval:c}=h7[a],[l,u]=(0,I.useState)(0),d,f;t[4]!==o||t[5]!==s.length||t[6]!==c?(d=()=>{if(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=o.setInterval(()=>{u(e=>(e+1)%s.length)},c);return()=>o.clearInterval(e)},f=[o,s.length,c],t[4]=o,t[5]=s.length,t[6]=c,t[7]=d,t[8]=f):(d=t[7],f=t[8]),(0,I.useEffect)(d,f);let p;t[9]===n?p=t[10]:(p=P(`inline-block`,n),t[9]=n,t[10]=p);let m=s[l],h;return t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,L.jsx)(`span`,{role:`status`,"aria-label":`Loading`,className:p,...r,children:m}),t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function _7(e){let t=(0,W.c)(11),{Icon:n,isLast:r,isLoading:i,aborted:a,state:o,isError:s}=e,c;t[0]!==n||t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==o?(c=i?(0,L.jsx)(g7,{className:`text-muted-foreground z-10 shrink-0 text-sm`}):a?(0,L.jsx)(g,{className:`text-destructive z-10 size-3.5 shrink-0`}):(0,L.jsx)(n,{className:P(`z-10 size-3.5 shrink-0`,o===`output-error`||s?`text-destructive`:`text-muted-foreground`)}),t[0]=n,t[1]=a,t[2]=s,t[3]=i,t[4]=o,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=!r&&(0,L.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[6]=r,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,L.jsxs)(`div`,{className:`absolute top-0 left-0 flex h-full flex-col items-center`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u}function v7(e){let t=(0,W.c)(15),{isLast:n,label:r,state:i,aborted:a,children:o}=e,s=(0,I.use)(v8),c=r??s?.label,l=i??s?.state,u=a??s?.aborted??!1,d=c?.icon,f=!!l&&!u&&l!==`output-available`&&l!==`output-error`,p;t[0]!==d||t[1]!==u||t[2]!==c?.isError||t[3]!==l||t[4]!==n||t[5]!==f?(p=d?(0,L.jsx)(_7,{Icon:d,isLast:n,isLoading:f,aborted:u,state:l,isError:c?.isError??!1}):(0,L.jsx)(G8,{isLast:n}),t[0]=d,t[1]=u,t[2]=c?.isError,t[3]=l,t[4]=n,t[5]=f,t[6]=p):p=t[6];let m=p,h=n?``:`pb-3.5`,g;t[7]===h?g=t[8]:(g=P(`min-w-0 flex-1`,h),t[7]=h,t[8]=g);let _;t[9]!==o||t[10]!==g?(_=(0,L.jsx)(`div`,{className:g,children:o}),t[9]=o,t[10]=g,t[11]=_):_=t[11];let v;return t[12]!==m||t[13]!==_?(v=(0,L.jsx)(K8,{marker:m,children:_}),t[12]=m,t[13]=_,t[14]=v):v=t[14],v}function y7(e){let t=(0,W.c)(10),{label:n,state:r,part:i,defaultOpen:a,children:o}=e,s=a!==void 0&&a,c;t[0]!==n||t[1]!==i||t[2]!==r?(c=(0,L.jsx)(qi,{className:`cursor-pointer`,children:(0,L.jsx)(l8,{label:n,state:r,part:i})}),t[0]=n,t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,L.jsx)(Ji,{children:o}),t[4]=o,t[5]=l);let u;return t[6]!==s||t[7]!==c||t[8]!==l?(u=(0,L.jsxs)(Ki,{defaultOpen:s,className:`flex min-w-0 flex-1 flex-col`,children:[c,l]}),t[6]=s,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}var b7={Item:v7,Disclosure:y7};(0,I.memo)(function(e){let t=(0,W.c)(12),{className:n}=e,{message:r}=I3(),{elements:i}=P3(),{debugMode:a}=b3(),o=i8(),s=B6(),c;t[0]===r.parts?c=t[1]:(c=D8(r.parts),t[0]=r.parts,t[1]=c);let l=c,u;t[2]!==a||t[3]!==i||t[4]!==s||t[5]!==r.id||t[6]!==l||t[7]!==o?(u=l.map((e,t)=>{let n=`${r.id}-${O8(e,t)}-${e.kind}`;if(e.kind===`text`)return(0,L.jsx)(C8.Text,{segment:e,elements:i,className:`my-4`},n);if(e.kind===`file`)return(0,L.jsx)(C8.File,{segment:e},n);if(e.kind===`source`)return(0,L.jsx)(C8.Source,{segment:e},n);if(e.kind===`dynamic-tool`){if(!o)return null;let r=!E8(l,t,!0);return(0,L.jsx)(b7.Item,{isLast:r,children:(0,L.jsx)(C8.DynamicTool,{segment:e})},n)}if(e.kind===`reasoning`){if(s||e.part.type!==`reasoning`)return null;let r=!E8(l,t,a),i={name:`Reasoning`,icon:vr,args:{text:[...e.part.text].slice(0,60).join(``)}};return(0,L.jsx)(b7.Item,{isLast:r,label:i,children:(0,L.jsx)(b7.Disclosure,{label:i,children:(0,L.jsx)(C8.Reasoning,{segment:e})})},n)}if(e.kind===`tool`){let r=!E8(l,t,a);return(0,L.jsx)(C8.Tool,{segment:e,children:(0,L.jsx)(b7.Item,{isLast:r,children:(0,L.jsx)(C8.ToolDisclosure,{})})},n)}return null}),t[2]=a,t[3]=i,t[4]=s,t[5]=r.id,t[6]=l,t[7]=o,t[8]=u):u=t[8];let d;return t[9]!==n||t[10]!==u?(d=(0,L.jsx)(`div`,{className:n,children:u}),t[9]=n,t[10]=u,t[11]=d):d=t[11],d});function x7(e){let t=(0,W.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{hasSubmitted:i}=S3(),a;t[3]===n?a=t[4]:(a=P(`bg-background sticky bottom-0 rounded-t-2xl border-0 **:data-[slot=composer-editor]:!min-h-15`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==r||t[7]!==a?(o=(0,L.jsx)(o2.Root,{hasInteracted:i,className:a,...r}),t[5]=i,t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function S7(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`border-border bg-card focus-within:border-primary/80 focus-within:ring-primary/15 relative rounded-2xl border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function C7(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`space-y-1 px-3.5 pt-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(o2.Content,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function w7(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`!min-h-15 !rounded-none !border-0 !bg-transparent !shadow-none **:data-[slot=composer-editor]:!p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(o2.Editor,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function T7(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`pb-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(o2.Attachments,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function E7(e){let t=(0,W.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=P(`p-1.5 pt-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,L.jsx)(o2.Toolbar,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function D7(e){let t=(0,W.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,L.jsx)(A8,{icon:(0,L.jsx)(Ar,{className:`size-4`})}),t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,L.jsx)(o2.AttachFiles,{"aria-label":`Attach files`,render:n,...e}),t[1]=e,t[2]=r),r}function O7(){let e=(0,W.c)(6),{actions:t,meta:n}=GZ(`ChatComposer.CommandButton`),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,L.jsx)(Mr,{className:`size-4`}),e[0]=r):r=e[0];let i=n.activePopup?.trigger===`/`,a;e[1]===t?a=e[2]:(a=e=>{e.stopPropagation(),t.toggleSlashMenu()},e[1]=t,e[2]=a);let o;return e[3]!==i||e[4]!==a?(o=(0,L.jsx)(A8,{"data-command-button":!0,icon:r,"aria-label":`Toggle command menu`,"aria-expanded":i,onClick:a}),e[3]=i,e[4]=a,e[5]=o):o=e[5],o}function k7(e){switch(e){case`permission-denied`:return`Allow microphone access to use dictation`;case`no-microphone`:return`Connect a microphone to use dictation`;case`microphone-in-use`:return`Close other apps using the microphone`;case`interrupted`:return`Recording interrupted`;case`transcription-failed`:return`Unable to transcribe audio`}}function A7(e){switch(e.status){case`unavailable`:return e.reason===`blocked`?`Allow microphone access in your browser settings to use dictation`:`Dictation is not available in this browser`;case`idle`:return`Start dictation`;case`starting`:return`Starting dictation`;case`recording`:return`Stop dictation`;case`finishing`:return`Transcribing…`;case`failed`:return k7(e.error.code)}}function j7(e){switch(e.status){case`recording`:return(0,L.jsx)(Ir,{className:`size-4 fill-current`});case`starting`:case`finishing`:return(0,L.jsx)(be,{className:`size-4 animate-spin`});case`unavailable`:case`idle`:case`failed`:return(0,L.jsx)(wr,{className:`size-4`})}}function M7(){let e=(0,W.c)(20),{status:t}=x3(),{state:n}=q$(`ChatComposer.Dictate`),r;e[0]===n?r=e[1]:(r=A7(n),e[0]=n,e[1]=r);let i=r,a=n.status===`starting`||n.status===`recording`||n.status===`finishing`,o=t===`streaming`||t===`submitted`,s;e[2]===n?s=e[3]:(s=j7(n),e[2]=n,e[3]=s);let c;e[4]!==i||e[5]!==s?(c=(0,L.jsx)(A8,{icon:s,"aria-label":i,title:i}),e[4]=i,e[5]=s,e[6]=c):c=e[6];let l;e[7]!==o||e[8]!==c?(l=(0,L.jsx)(o2.Dictate,{disabled:o,render:c}),e[7]=o,e[8]=c,e[9]=l):l=e[9];let u;e[10]!==a||e[11]!==n.status?(u=a?(0,L.jsx)(o2.CancelDictation,{render:(0,L.jsx)(A8,{icon:(0,L.jsx)(At,{className:`size-4`}),"aria-label":n.status===`finishing`?`Cancel transcription`:`Cancel dictation`})}):null,e[10]=a,e[11]=n.status,e[12]=u):u=e[12];let d;e[13]!==i||e[14]!==n.status?(d=n.status===`failed`?(0,L.jsx)(`span`,{role:`status`,className:`text-destructive max-w-48 truncate text-xs`,children:i}):null,e[13]=i,e[14]=n.status,e[15]=d):d=e[15];let f;return e[16]!==l||e[17]!==u||e[18]!==d?(f=(0,L.jsxs)(L.Fragment,{children:[l,u,d]}),e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}var N7={Provider:x7,Root:S7,Popup:o2.Popup,Content:C7,Attachments:T7,Editor:w7,Error:o2.Error,Toolbar:E7,CommandButton:O7,AttachFiles:D7,Dictate:M7};function P7(e){let t=(0,W.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=P(`border-border flex flex-col border-b px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,L.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function F7(e){let t=(0,W.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=P(`flex items-center gap-2 px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,L.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function I7(e){let t=(0,W.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=P(`text-muted-foreground size-3.5 shrink-0`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,L.jsx)(br,{className:r}),t[2]=r,t[3]=i),i}function L7(e){let t=(0,W.c)(7),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=P(`min-w-0 flex-1 truncate text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=typeof n==`string`?(0,L.jsx)(c2,{text:n}):n,t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,L.jsx)(`span`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function R7(e){let t=(0,W.c)(6),{onClick:n,className:r}=e,i;t[0]===r?i=t[1]:(i=P(`text-muted-foreground hover:text-foreground shrink-0 rounded p-1 transition-colors`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,L.jsx)(_e,{className:`size-3.5`}),t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==i?(o=(0,L.jsx)(`button`,{type:`button`,onClick:n,className:i,"aria-label":`Remove queued message`,children:a}),t[3]=n,t[4]=i,t[5]=o):o=t[5],o}var z7={Root:P7,Item:F7,Icon:I7,Text:L7,Remove:R7},B7={normal:{d:`m5 12 7-7 7 7`,translateY:0},animate:{d:`m5 12 7-7 7 7`,translateY:[0,3,0],transition:{duration:.4}}},V7={normal:{d:`M12 19V5`},animate:{d:[`M12 19V5`,`M12 19V10`,`M12 19V5`],transition:{duration:.4}}},H7=e=>{let t=(0,W.c)(30),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({ref:o,onMouseEnter:r,onMouseLeave:i,className:n,size:s,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?20:s,l=MA(),u=(0,I.useRef)(!1),d;t[7]===l?d=t[8]:(d=()=>(u.current=!0,{startAnimation:()=>l.start(`animate`),stopAnimation:()=>l.start(`normal`)}),t[7]=l,t[8]=d),(0,I.useImperativeHandle)(o,d);let f;t[9]!==l||t[10]!==r?(f=e=>{u.current?r?.(e):l.start(`animate`)},t[9]=l,t[10]=r,t[11]=f):f=t[11];let p=f,m;t[12]!==l||t[13]!==i?(m=e=>{u.current?i?.(e):l.start(`normal`)},t[12]=l,t[13]=i,t[14]=m):m=t[14];let h=m,g;t[15]===n?g=t[16]:(g=P(n),t[15]=n,t[16]=g);let _,v;t[17]===l?(_=t[18],v=t[19]):(_=(0,L.jsx)(NA.path,{animate:l,d:`m5 12 7-7 7 7`,variants:B7}),v=(0,L.jsx)(NA.path,{animate:l,d:`M12 19V5`,variants:V7}),t[17]=l,t[18]=_,t[19]=v);let y;t[20]!==c||t[21]!==_||t[22]!==v?(y=(0,L.jsxs)(`svg`,{fill:`none`,height:c,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:c,xmlns:`http://www.w3.org/2000/svg`,children:[_,v]}),t[20]=c,t[21]=_,t[22]=v,t[23]=y):y=t[23];let b;return t[24]!==p||t[25]!==h||t[26]!==a||t[27]!==g||t[28]!==y?(b=(0,L.jsx)(`div`,{className:g,onMouseEnter:p,onMouseLeave:h,...a,children:y}),t[24]=p,t[25]=h,t[26]=a,t[27]=g,t[28]=y,t[29]=b):b=t[29],b};H7.displayName=`ArrowUpIcon`;var U7={duration:.15,ease:[0,0,.2,1]},W7={duration:.12,ease:[0,0,.2,1]};function G7(e){let t=(0,W.c)(40),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({variant:a,className:n,disabled:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=EA(),s=a===`stop`,c;t[5]===o?c=t[6]:(c=!o&&{opacity:0,scale:.9},t[5]=o,t[6]=c);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l={opacity:1,scale:1},t[7]=l):l=t[7];let u;t[8]===o?u=t[9]:(u=o?void 0:{opacity:0,scale:.9},t[8]=o,t[9]=u);let d;t[10]!==r||t[11]!==o?(d=r||o?void 0:{scale:1.04},t[10]=r,t[11]=o,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==o?(f=r||o?void 0:{scale:.96},t[13]=r,t[14]=o,t[15]=f):f=t[15];let p=s?`Stop streaming`:`Send prompt`,m;t[16]===n?m=t[17]:(m=P(`relative flex size-8 items-center justify-center rounded-full`,`bg-primary text-primary-foreground`,`transition-opacity hover:opacity-90 active:opacity-80`,`disabled:cursor-not-allowed disabled:opacity-35 disabled:hover:opacity-35`,`focus-visible:outline-[1.5px] focus-visible:outline-offset-[2.5px] focus-visible:outline-current`,n),t[16]=n,t[17]=m);let h=s?`stop`:`send`,g;t[18]===o?g=t[19]:(g=!o&&{opacity:0,scale:.7},t[18]=o,t[19]=g);let _;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(_={opacity:1,scale:1},t[20]=_):_=t[20];let v;t[21]===o?v=t[22]:(v=o?void 0:{opacity:0,scale:.7},t[21]=o,t[22]=v);let y;t[23]===s?y=t[24]:(y=(0,L.jsx)(s?J7:q7,{}),t[23]=s,t[24]=y);let b;t[25]!==v||t[26]!==y||t[27]!==h||t[28]!==g?(b=(0,L.jsx)(kO,{initial:!1,children:(0,L.jsx)(NA.span,{initial:g,animate:_,exit:v,transition:W7,className:`absolute flex items-center justify-center`,children:y},h)}),t[25]=v,t[26]=y,t[27]=h,t[28]=g,t[29]=b):b=t[29];let x;return t[30]!==r||t[31]!==i||t[32]!==c||t[33]!==b||t[34]!==u||t[35]!==d||t[36]!==f||t[37]!==p||t[38]!==m?(x=(0,L.jsx)(NA.button,{initial:c,animate:l,exit:u,transition:U7,whileHover:d,whileTap:f,"aria-label":p,...i,disabled:r,className:m,children:b}),t[30]=r,t[31]=i,t[32]=c,t[33]=b,t[34]=u,t[35]=d,t[36]=f,t[37]=p,t[38]=m,t[39]=x):x=t[39],x}function K7(e){let t=(0,W.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,L.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:n}),t[0]=n,t[1]=r),r}function q7(){let e=(0,W.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsx)(H7,{}),e[0]=t):t=e[0],t}function J7(){let e=(0,W.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsx)(K7,{children:(0,L.jsx)(`rect`,{x:`5`,y:`5`,width:`10`,height:`10`,rx:`1.5`})}),e[0]=t):t=e[0],t}function Y7(e){let t=(0,W.c)(25),{title:n,detail:r,detailLabel:i,part:a,error:o}=e,s=n===void 0?`Failed to render tool`:n,c=i===void 0?`View details`:i,l=C3(),u;t[0]===o.issues?u=t[1]:(u=o.issues.map(X7).join(`
344
+ `),t[0]=o.issues,t[1]=u);let d=u,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,L.jsx)(ne,{className:`size-5`}),t[2]=f):f=t[2];let p;t[3]===s?p=t[4]:(p=(0,L.jsx)(ui,{children:(0,L.jsxs)(di,{className:`text-destructive flex items-center gap-2`,children:[f,s]})}),t[3]=s,t[4]=p);let h,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,L.jsx)(ne,{className:`size-4`}),g=(0,L.jsx)(ve,{children:`Error`}),t[5]=h,t[6]=g):(h=t[5],g=t[6]);let _;t[7]===d?_=t[8]:(_=(0,L.jsxs)(m,{variant:`destructive`,children:[h,g,(0,L.jsx)(jt,{children:d})]}),t[7]=d,t[8]=_);let v;t[9]!==r||t[10]!==c?(v=r&&(0,L.jsxs)(`details`,{className:`text-sm`,children:[(0,L.jsx)(`summary`,{className:`text-muted-foreground hover:text-foreground cursor-pointer`,children:c}),(0,L.jsx)(`pre`,{className:`bg-muted mt-2 max-h-48 overflow-auto rounded-md p-3 text-xs`,children:(0,L.jsx)(`code`,{children:r})})]}),t[9]=r,t[10]=c,t[11]=v):v=t[11];let y;t[12]!==_||t[13]!==v?(y=(0,L.jsxs)(mi,{className:`space-y-4`,children:[_,v]}),t[12]=_,t[13]=v,t[14]=y):y=t[14];let b;t[15]!==l||t[16]!==a?(b=()=>{let e=[`The model tried to call the tool "${S_(a)}" with the following inputs:`,JSON.stringify(a.input),`Please fix the inputs.`];l.addToolOutput({toolCallId:a.toolCallId,tool:S_(a),output:e,state:`output-available`})},t[15]=l,t[16]=a,t[17]=b):b=t[17];let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,L.jsx)(Pr,{className:`size-4`}),t[18]=x):x=t[18];let S;t[19]===b?S=t[20]:(S=(0,L.jsx)(hi,{children:(0,L.jsxs)(at,{variant:`outline`,onClick:b,className:`gap-2`,children:[x,`Ask AI to fix this`]})}),t[19]=b,t[20]=S);let C;return t[21]!==y||t[22]!==S||t[23]!==p?(C=(0,L.jsxs)(li,{className:`border-destructive/50 bg-destructive/5`,children:[p,y,S]}),t[21]=y,t[22]=S,t[23]=p,t[24]=C):C=t[24],C}function X7(e){return`${e.path.join(`.`)}: ${e.message}`}(0,I.createContext)(``);function Z7({question:e}){let{submit:t}=b3();return typeof e!=`string`||e===``?null:(0,L.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-accent hover:text-accent-foreground my-1 inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-sm transition-colors`,onClick:()=>void t({prompt:e,persistedPrompt:e}),children:[(0,L.jsx)(gr,{className:`size-3.5`}),e]})}var Q7=YA([{name:`followup`,description:`Suggest a follow-up question the user is likely to ask next. Renders as a clickable chip that sends the question as the next message. Example: <followup question="How do I undo this?" />`,allowedAttributes:[`question`],component:Z7}]),$7=N({label:F().describe(`Display text for the option`),value:F().optional().describe(`Machine value; defaults to label`),description:F().optional().describe(`Helper text for the option`)}),e9=T(e=>typeof e==`object`&&e&&`questions`in e&&Array.isArray(e.questions)?{...e,questions:e.questions.map(e=>typeof e==`object`&&e?{...e,type:`choice`}:e)}:e,N({questions:vt(N({type:Ne(`choice`).describe(`Selection from predefined options`),question:F().describe(`The question text displayed to the user`),header:F().optional().describe(`Short context label`),multiSelect:et().default(!1).describe(`Whether multiple options can be selected`),options:vt($7).min(1).describe(`Available choices`)})).min(1).describe(`Questions to present as a wizard`)})),t9=N({label:F(),value:F()}),n9=N({answers:vt(N({type:F(),question:F(),freeText:F().optional(),notes:F().optional(),choice:t9.optional(),choices:vt(t9).optional(),multiSelect:et().optional(),answer:F().optional()}))});function r9(e){if(e.multiSelect){if(e.selectedMulti.length===0&&!e.customText.trim())return`Pick at least one option or add your own answer.`}else{if(!e.selected&&!e.isOther)return`Select an option or add your own answer.`;if(e.isOther&&!e.customText.trim())return`Add your custom answer for the "Other" option.`}return null}function i9(e){return{type:`choice`,multiSelect:e.multiSelect??!1,selected:null,selectedMulti:[],isOther:!1,customText:``,notes:``}}function a9(e){return e.options.filter(e=>(e.value??e.label).toLowerCase()!==`other`&&e.label.toLowerCase()!==`other`).map(e=>({label:e.label,value:e.value??e.label,description:e.description}))}function o9(e,t,n){let r=e=>{let t=n.find(t=>t.value===e);return t?{label:t.label,value:t.value}:{label:e,value:e}},i=t.notes.trim()||void 0,a=t.customText.trim()||void 0;if(t.multiSelect){let n=t.selectedMulti.map(r);return a&&n.push({label:`Other`,value:a}),{type:`choice`,question:e.question,multiSelect:!0,choices:n,freeText:a,notes:i}}return{type:`choice`,question:e.question,multiSelect:!1,choice:t.isOther?{label:`Other`,value:a??``}:r(t.selected??``),freeText:t.isOther?a:void 0,notes:i}}function s9({checked:e,children:t,disabled:n}){return(0,L.jsx)(`div`,{className:P(`border-border/60 relative flex items-start gap-2 rounded-lg border px-3 py-1.5 transition-all duration-150`,!n&&`hover:bg-muted/40`,e&&`border-primary/50 bg-primary/5`,n&&`opacity-60`),children:t})}function c9({htmlFor:e,label:t,description:n}){return(0,L.jsxs)(qt,{htmlFor:e,className:`min-w-0 flex-1 cursor-pointer flex-col items-start gap-0`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:t}),n?(0,L.jsx)(`p`,{className:`text-muted-foreground text-xs leading-relaxed text-pretty`,children:n}):null]})}function l9({id:e,value:t,label:n,description:r,checked:i,disabled:a}){return(0,L.jsxs)(s9,{checked:i,disabled:a,children:[(0,L.jsx)(xa,{id:e,value:t,disabled:a,className:`mt-0.5`}),(0,L.jsx)(c9,{htmlFor:e,label:n,description:r})]})}function u9({id:e,label:t,description:n,checked:r,disabled:i,onCheckedChange:a}){return(0,L.jsxs)(s9,{checked:r,disabled:i,children:[(0,L.jsx)(Mi,{id:e,checked:r,disabled:i,onCheckedChange:e=>a(e===!0),className:`mt-0.5`}),(0,L.jsx)(c9,{htmlFor:e,label:t,description:n})]})}function d9({id:e,checked:t,disabled:n,customText:r,onCustomTextChange:i}){let a=(0,I.useRef)(null);return(0,L.jsxs)(s9,{checked:t,disabled:n,children:[(0,L.jsx)(xa,{ref:a,id:e,value:`other`,disabled:n,className:`mt-0.5`}),(0,L.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Type your answer...`,disabled:n,onFocus:()=>{t||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function f9({hasCustom:e,disabled:t,customText:n,onCustomTextChange:r,onClear:i}){let a=(0,I.useRef)(null);return(0,L.jsxs)(s9,{checked:e,disabled:t,children:[(0,L.jsx)(Mi,{ref:a,checked:e,disabled:t,onCheckedChange:e=>{e||i()},className:`mt-0.5`}),(0,L.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Type your answer...`,disabled:t,onFocus:()=>{e||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function p9({value:e,onChange:t,disabled:n}){return(0,L.jsx)(`div`,{className:`mt-2.5 border-t border-dashed pt-2.5`,children:(0,L.jsx)(un,{value:e,onChange:e=>t(e.target.value),placeholder:`Add notes (optional)...`,disabled:n,rows:2,className:`resize-none text-sm`})})}function m9({value:e,onChange:t,options:n,disabled:r,fieldId:i}){if(e.multiSelect){let a=e.customText.trim().length>0,o=(n,r)=>{let i=new Set(e.selectedMulti);r?i.add(n):i.delete(n),t({...e,selectedMulti:[...i]})};return(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[n.map(t=>(0,L.jsx)(u9,{id:`${i}-multi-${t.value}`,label:t.label,description:t.description,checked:e.selectedMulti.includes(t.value),disabled:r,onCheckedChange:e=>o(t.value,e)},t.value)),(0,L.jsx)(f9,{hasCustom:a,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n}),onClear:()=>t({...e,customText:``})})]})}return(0,L.jsxs)(ba,{value:e.isOther?`other`:e.selected??``,onValueChange:n=>t(n===`other`?{...e,selected:null,isOther:!0}:{...e,selected:n,isOther:!1,customText:``}),children:[n.map(t=>(0,L.jsx)(l9,{id:`${i}-single-${t.value}`,value:t.value,label:t.label,description:t.description,checked:!e.isOther&&e.selected===t.value,disabled:r},t.value)),(0,L.jsx)(d9,{id:`${i}-single-other`,checked:e.isOther,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n})})]})}function h9({current:e,total:t}){return t<=1?null:(0,L.jsx)(`div`,{className:`flex items-center gap-1`,children:Array.from({length:t},(t,n)=>(0,L.jsx)(`div`,{className:P(`h-1 w-3 rounded-full transition-colors duration-200`,n<=e?`bg-primary`:`bg-muted`)},n))})}function g9({onBack:e,onNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}){return o?null:(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-t border-dashed px-3 py-1.5`,children:[(0,L.jsx)(`div`,{className:`w-16`,children:n?null:(0,L.jsx)(`button`,{type:`button`,onClick:e,disabled:a,className:`text-muted-foreground hover:text-foreground text-xs transition-colors disabled:opacity-50`,children:`← Back`})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(h9,{current:s,total:c}),c>1?(0,L.jsxs)(`span`,{className:`text-muted-foreground text-[11px] tabular-nums`,children:[s+1,`/`,c]}):null]}),(0,L.jsx)(`div`,{className:`flex w-16 justify-end`,children:(0,L.jsxs)(at,{type:`button`,size:`sm`,onClick:t,disabled:!i||a,children:[a?(0,L.jsx)(Sa,{}):null,a?`Sending...`:r?`Submit`:`Next`]})})]})}function _9({question:e}){return(0,L.jsxs)(`div`,{className:`px-3 pt-2.5 pb-2`,children:[(0,L.jsxs)(`div`,{className:`text-muted-foreground mb-2 flex items-center gap-2 text-[11px]`,children:[(0,L.jsx)(se,{className:`size-3`}),(0,L.jsx)(`span`,{children:e.header??`Clarification`})]}),(0,L.jsx)(ci,{className:`mb-2`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-pretty`,children:e.question})]})}function v9({question:e,answer:t,options:n,onChange:r,disabled:i,fieldId:a}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(m9,{value:t,onChange:r,options:n,disabled:i,fieldId:a}),(0,L.jsx)(p9,{value:t.notes,onChange:e=>r({...t,notes:e}),disabled:i})]})}function y9({question:e,answer:t,options:n}){let r=t.multiSelect?[...t.selectedMulti.map(e=>n.find(t=>t.value===e)?.label??e),...t.customText.trim()?[`Other: ${t.customText.trim()}`]:[]].join(`, `):t.isOther?`Other: ${t.customText.trim()}`:n.find(e=>e.value===t.selected)?.label??t.selected??``,i=t.notes.trim()||void 0;return(0,L.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,L.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:r}),i?(0,L.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,i]}):null]})}function b9(e){return e.type===`free_form`?e.answer??``:e.multiSelect&&e.choices?e.choices.map(({label:e,value:t})=>e===`Other`?`Other: ${t}`:e).join(`, `):e.freeText?`Other: ${e.freeText}`:e.choice?.label??``}function x9({answers:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,L.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,L.jsx)(je,{className:`size-3`}),(0,L.jsx)(`span`,{children:`Answered`})]})}),(0,L.jsx)(ci,{}),e.map((e,t)=>(0,L.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,L.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:b9(e)}),e.notes?(0,L.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,e.notes]}):null]},t))]})}function S9({questions:e,answers:t}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,L.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,L.jsx)(je,{className:`size-3`}),(0,L.jsx)(`span`,{children:`Answered`})]})}),(0,L.jsx)(ci,{}),e.map((e,n)=>(0,L.jsx)(y9,{question:e,answer:t[n],options:a9(e)},n))]})}var C9=(0,I.createContext)(void 0);function w9(){let e=(0,I.use)(C9);if(!e)throw Error(`useWizard must be used within <ClarificationWizard.Root>`);return e}function T9({questions:e,onSubmit:t,disabled:n,fieldId:r,children:i}){let[a,o]=(0,I.useState)(0),[s,c]=(0,I.useState)(()=>e.map(i9)),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(!1),h=e[a],g=s[a],_=a===0,v=a===e.length-1,y={questions:e,currentStep:a,currentQuestion:h,currentAnswer:g,options:a9(h),answers:s,updateAnswer:e=>{c(t=>{let n=[...t];return n[a]=e,n}),u(null)},handleBack:()=>{_||(o(e=>e-1),u(null))},handleNext:async()=>{let n=r9(g);if(n){u(n);return}if(!v){o(e=>e+1),u(null);return}for(let t=0;t<e.length;t++){let e=r9(s[t]);if(e){o(t),u(e);return}}f(!0);try{await t(e.map((e,t)=>o9(e,s[t],a9(e)))),m(!0)}catch(e){u(e instanceof Error?e.message:`Failed to send your answers.`)}finally{f(!1)}},error:l,isFirst:_,isLast:v,canProceed:!n&&!p,isSubmitting:d,isSubmitted:p,disabled:n,fieldId:r,totalSteps:e.length};return(0,L.jsx)(C9,{value:y,children:i})}function E9(){let{currentQuestion:e,isSubmitted:t}=w9();return t?null:(0,L.jsx)(_9,{question:e})}function D9(){let{currentQuestion:e,currentAnswer:t,options:n,updateAnswer:r,disabled:i,isSubmitting:a,isSubmitted:o,fieldId:s,currentStep:c}=w9();return o?null:(0,L.jsx)(v9,{question:e,answer:t,options:n,onChange:r,disabled:i||a,fieldId:`${s}-step-${c}`})}function O9(){let{error:e,isSubmitted:t}=w9();return t||!e?null:(0,L.jsx)(`p`,{className:`text-destructive text-xs`,role:`alert`,children:e})}function k9(){let{handleBack:e,handleNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}=w9();return(0,L.jsx)(g9,{onBack:e,onNext:()=>void t(),isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c})}function A9({children:e,className:t}){let{isSubmitted:n}=w9();return n?null:(0,L.jsx)(`div`,{className:t,children:e})}function j9(){let{questions:e,answers:t,isSubmitted:n}=w9();return n?(0,L.jsx)(S9,{questions:e,answers:t}):null}var M9={Root:T9,Header:E9,Content:A9,Field:D9,Error:O9,Navigation:k9,Submitted:j9};function N9({part:e}){let t=C3(),[n,r]=(0,I.useState)(!1),i=(0,I.useId)();if(e.state===`output-available`){let t=n9.safeParse(e.output);return t.success?(0,L.jsx)(`div`,{className:P(`border-border/60 bg-muted/20 mb-2 rounded-lg border border-dashed`),children:(0,L.jsx)(x9,{answers:t.data.answers})}):null}if(e.state!==`input-available`)return null;let a=e9.safeParse(e.input);return a.success?(0,L.jsx)(`div`,{className:P(`border-border/60 bg-muted/20 rounded-lg border border-dashed`,`animate-in fade-in-0 duration-200`),children:(0,L.jsxs)(M9.Root,{questions:a.data.questions,onSubmit:async n=>{await t.addToolOutput({toolCallId:e.toolCallId,tool:S_(e),output:{answers:n},state:`output-available`}),r(!0)},disabled:n,fieldId:i,children:[(0,L.jsx)(M9.Submitted,{}),(0,L.jsx)(M9.Header,{}),(0,L.jsxs)(M9.Content,{className:`space-y-2 px-3 pb-2`,children:[(0,L.jsx)(M9.Field,{}),(0,L.jsx)(M9.Error,{})]}),(0,L.jsx)(M9.Navigation,{})]})}):(0,L.jsx)(Y7,{error:a.error,title:`Failed to render clarification`,detail:JSON.stringify(e.input,null,2),detailLabel:`View input`,part:e})}var P9={component:N9,label:e=>{let t=e.state===`input-available`||e.state===`output-available`?e9.safeParse(e.input):void 0,n=t?.success?t.data.questions[0]:void 0;return{name:`AskUserQuestion`,icon:cr,args:n?{question:n.header??n.question}:void 0}},requiresUserInput:!0,static:!1,inputSchema:e9,description:`Tool to collect information from the user via a multi-step wizard. Use when you need to clarify requirements, gather preferences, or resolve ambiguity before proceeding.
345
345
 
346
346
  Each question MUST have a "type" field set to "choice" for selection from predefined options (single or multiple).
347
347
 
@@ -349,4 +349,4 @@ IMPORTANT: NEVER include an "Other" option in your options array — the UI alwa
349
349
 
350
350
  Example:
351
351
  {"questions":[{"type":"choice","question":"Which timeframe?","header":"Timeframe","multiSelect":false,"options":[{"label":"Last 30 days"},{"label":"Last quarter"}]}]}`};function F9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function I9(e,t){if(!F9(e))return;let n=e[t];return typeof n==`string`?n:void 0}function L9(e,t){if(!F9(e))return;let n=e[t];return typeof n==`number`?n:void 0}function R9(e,t){if(!F9(e))return;let n=e[t];return typeof n==`boolean`?n:void 0}function z9(e){return e.state!==`output-available`&&e.state!==`output-error`&&e.state!==`output-denied`}function B9(e){if(e.state===`output-error`)return e.errorText;if(e.state===`output-denied`)return`Execution denied.`}function V9({children:e,pending:t=!1,error:n=!1}){return(0,L.jsx)(`p`,{"aria-live":t?`polite`:void 0,className:P(`text-xs leading-relaxed`,t&&`animate-pulse`,n?`text-destructive`:`text-muted-foreground`),children:e})}function H9({title:e,code:t,language:n,detail:r,error:i=!1}){return(0,L.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,L.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3 px-0.5`,children:[(0,L.jsx)(`h4`,{className:P(`text-[10px] font-semibold tracking-[0.08em] uppercase`,i?`text-destructive`:`text-muted-foreground`),children:e}),r&&(0,L.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px]`,children:r})]}),(0,L.jsx)(`div`,{className:`max-h-64 overflow-auto rounded-md`,children:(0,L.jsx)(E6,{className:P(`border-border/60 rounded-md shadow-none`,i&&`border-destructive/30`),code:t,language:n,wrap:!0,children:(0,L.jsx)(D6,{"aria-label":`Copy ${e.toLowerCase()}`,className:`text-muted-foreground bg-background/90 hover:bg-muted h-6 rounded-md px-2 font-mono text-[10px]`,size:`xs`,variant:`ghost`,children:`Copy`})})})]})}function U9({children:e}){return(0,L.jsx)(`div`,{className:`border-border/60 mb-2 space-y-3 border-l pl-3`,children:e})}function W9({part:e}){let t=I9(e.input,`command`)??``,n=I9(e.output,`stdout`)??``,r=I9(e.output,`stderr`)??``,i=L9(e.output,`exitCode`),a=B9(e),o=z9(e);return(0,L.jsxs)(U9,{children:[a?(0,L.jsx)(V9,{error:!0,children:a}):o?(0,L.jsx)(V9,{pending:!0,children:`Running command...`}):(0,L.jsx)(V9,{error:i!==void 0&&i!==0,children:i===void 0?`Command finished.`:`Command exited with code ${i}.`}),t&&(0,L.jsx)(H9,{code:t,language:`bash`,title:`Command`}),n&&(0,L.jsx)(H9,{code:n,language:`text`,title:`Standard output`}),r&&(0,L.jsx)(H9,{code:r,error:!0,language:`text`,title:`Standard error`}),!o&&!a&&!n&&!r&&(0,L.jsx)(V9,{children:`The command produced no output.`})]})}function G9(e){if(typeof e==`string`)return e;if(F9(e)){if((e.type===`text`||e.type===`error-text`)&&typeof e.value==`string`)return e.value;if(!(e.type!==`content`||!Array.isArray(e.value)))return e.value.filter(e=>F9(e)&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
352
- `)||void 0}}function K9(e){return!F9(e)||e.type!==`content`||!Array.isArray(e.value)?[]:e.value.flatMap(e=>{if(!F9(e)||e.type!==`file`)return[];let t=typeof e.mediaType==`string`?e.mediaType:`file`;return[`${typeof e.filename==`string`?e.filename:`Attachment`} · ${t}`]})}var q9={css:`css`,csv:`csv`,html:`html`,js:`javascript`,json:`json`,jsx:`jsx`,md:`markdown`,py:`python`,sh:`bash`,sql:`sql`,ts:`typescript`,tsx:`tsx`,txt:`text`,xml:`xml`,yaml:`yaml`,yml:`yaml`};function J9(e){return q9[e.split(`.`).pop()?.toLowerCase()??``]??`text`}function Y9(e){let t=L9(e,`offset`),n=L9(e,`limit`);if(t===void 0&&n===void 0)return;let r=t??1;return n===void 0?`${r}+`:`${r}-${r+n-1}`}function X9({part:e}){let t=I9(e.input,`path`)??``,n=G9(e.output),r=K9(e.output),i=F9(e.output)&&e.output.type===`error-text`?G9(e.output):void 0,a=B9(e)??i,o=z9(e),s=Y9(e.input);return(0,L.jsx)(U9,{children:a?(0,L.jsx)(V9,{error:!0,children:a}):o?(0,L.jsxs)(V9,{pending:!0,children:[`Reading `,t||`file`,`...`]}):n===void 0?r.length>0?(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`File content`}),r.map(e=>(0,L.jsx)(`p`,{className:`text-foreground/80 text-xs`,children:e},e))]}):(0,L.jsx)(V9,{children:`File content is unavailable.`}):n?(0,L.jsx)(H9,{code:n,detail:s?`lines ${s}`:void 0,language:J9(t),title:`File contents`}):(0,L.jsx)(V9,{children:`The file is empty.`})})}function cee({part:e}){let t=I9(e.input,`path`)??``,n=I9(e.input,`content`)??``,r=L9(e.output,`exitCode`),i=I9(e.output,`stderr`)??``,a=I9(e.output,`stdout`)??``,o=R9(e.output,`success`),s=B9(e);return(0,L.jsxs)(U9,{children:[z9(e)?(0,L.jsxs)(V9,{pending:!0,children:[`Writing `,t||`file`,`...`]}):s||o===!1||(r??0)!==0?(0,L.jsx)(V9,{error:!0,children:s||i||a||`Failed to write ${t||`file`}.`}):(0,L.jsx)(V9,{children:`File written.`}),n?(0,L.jsx)(H9,{code:n,language:J9(t),title:`Written content`}):(0,L.jsx)(V9,{children:`The file content is empty.`})]})}function lee(e){let t=I9(e.input,`command`),n=I9(e.input,`reasoning`),r=L9(e.output,`exitCode`);return{name:`Bash`,args:t?{cmd:t.slice(0,80)}:void 0,detail:n,isError:e.state===`output-error`||e.state===`output-denied`||r!==void 0&&r!==0}}function Z9(e,t){let n=I9(e.input,`path`),r=t===`ReadFile`?Y9(e.input):void 0,i=L9(e.output,`exitCode`);return{name:t,args:n||r?{...n?{path:n}:{},...r?{lines:r}:{}}:void 0,isError:e.state===`output-error`||e.state===`output-denied`||R9(e.output,`success`)===!1||i!==void 0&&i!==0||F9(e.output)&&e.output.type===`error-text`}}var Q9={ask_user_question:P9,bash:{component:W9,label:lee,static:!0},readFile:{component:X9,label:e=>Z9(e,`ReadFile`),static:!0},writeFile:{component:cee,label:e=>Z9(e,`WriteFile`),static:!0}},uee=xn(`status`,[N({id:F(),status:Ne(`restored`),sourceMessages:pn(),replacementMessages:pn()}),N({id:F(),status:Ne(`started`),tokenScope:Ne(`request`).optional(),triggerIndex:pn(),targetTokens:pn(),messageCount:pn()}),N({id:F(),status:Ne(`completed`),tokenScope:Ne(`request`).optional(),tokens:N({before:pn(),after:pn()})}),N({id:F(),status:Ne(`failed`),phase:Gt([`restore`,`evaluate`,`compact`,`persist`]),reason:Gt([`no-safe-boundary`,`protected-history`,`incomplete-summary`,`empty-summary`,`summary-too-large`,`request-overhead`,`error`])})]);function dee({message:e,running:t}){let n=e.parts.flatMap(e=>{if(e.type!==`data-compaction`)return[];let t=uee.safeParse(e.data);return t.success?[t.data]:[]}),r=Map.groupBy(n,e=>e.id);return Array.from(r,([e,n])=>(0,L.jsx)(fee,{events:n,running:t},e))}function fee({events:e,running:t}){let n=e.find(e=>e.status===`started`),r=e.find(e=>e.status===`completed`),i=e.find(e=>e.status===`failed`),a=e.find(e=>e.status===`restored`),o=n!==void 0&&!r&&!i;return(0,L.jsxs)(Ki,{className:`my-3`,children:[(0,L.jsx)(qi,{className:`group w-full text-left`,children:(0,L.jsxs)(eee,{children:[(0,L.jsx)(ga,{children:o&&t?(0,L.jsx)(Sa,{"aria-label":`Compacting context`}):i?(0,L.jsx)(ne,{className:`text-destructive size-4`}):r?(0,L.jsx)(je,{className:`size-4`}):(0,L.jsx)(Er,{className:`size-4`})}),(0,L.jsxs)(_a,{children:[(0,L.jsx)(va,{children:i?`Compaction failed`:r?`Context compacted`:o?t?`Compacting context…`:`Compaction interrupted`:`Using saved summary`}),r&&(0,L.jsxs)(ya,{children:[r.tokens.before.toLocaleString(),` →`,` `,r.tokens.after.toLocaleString(),` estimated`,` `,r.tokenScope===`request`?`input`:`message`,` `,`tokens`]})]}),(0,L.jsx)(se,{className:`size-3.5 transition-transform group-data-[panel-open]:rotate-90`})]})}),(0,L.jsxs)(Ji,{children:[(0,L.jsx)(ci,{}),(0,L.jsxs)(`div`,{className:`space-y-3 px-3 py-3 text-sm`,children:[(0,L.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-x-4 gap-y-2`,children:[n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Messages before compaction`}),(0,L.jsx)(`dd`,{children:n.messageCount.toLocaleString()}),(0,L.jsxs)(`dt`,{children:[`Estimated`,` `,n.tokenScope===`request`?`input`:`message`,` `,`target`]}),(0,L.jsxs)(`dd`,{children:[n.targetTokens.toLocaleString(),` tokens`]}),(0,L.jsx)(`dt`,{children:`Matched trigger`}),(0,L.jsxs)(`dd`,{children:[`#`,n.triggerIndex+1]})]}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Checkpoint`}),(0,L.jsx)(`dd`,{children:`Saved`})]}),a&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Using saved summary`}),(0,L.jsxs)(`dd`,{children:[a.sourceMessages,` → `,a.replacementMessages,` `,`messages`]})]})]}),i&&(0,L.jsx)(m,{variant:`destructive`,children:(0,L.jsxs)(jt,{children:[i.phase,`: `,i.reason]})})]})]})]})}var pee=N({messages:vt(kt())});async function mee(e){let{params:t,request:n}=e,r=t.sessionId??new URL(n.url).searchParams.get(`chatId`);if(!r)return Et(`/chat?chatId=${encodeURIComponent(crypto.randomUUID())}`);let i=await rn(n.signal),a=i.history.find(e=>e.chatId===r),o=i.discovery?.capabilities.chat.href;if(!o||!t.sessionId&&!a&&!i.historyError)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};try{let e=await fetch(`${o}/${encodeURIComponent(r)}`,{signal:n.signal});if(e.status===404&&!t.sessionId)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};if(!e.ok)throw Error(`Session request failed: ${e.status}`);let s=pee.safeParse(await e.json());if(!s.success)throw Error(`Session response did not include messages`);return{...i,chatId:r,conversation:a,initialMessages:await X_({messages:s.data.messages}),sessionExists:!0,sessionError:!1}}catch{return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!0}}}function hee({currentParams:e,currentUrl:t,nextParams:n,nextUrl:r}){return e.sessionId!==n.sessionId||t.searchParams.get(`chatId`)!==r.searchParams.get(`chatId`)}function gee(){let{chatId:e}=we();return(0,L.jsx)(_ee,{chatId:e},e)}function _ee({chatId:e}){let{discovery:t,initialMessages:n,sessionError:r,sessionExists:i}=we(),a=t?.capabilities.chat.href;return a?r?(0,L.jsx)($9,{children:`Unable to load this conversation.`}):(0,L.jsx)(vee,{api:a,chatId:e,initialMessages:n,sessionExists:i,supportsUploads:t.capabilities.uploads!==void 0,accept:t.capabilities.uploads?.mediaTypes?.join(`,`)}):(0,L.jsx)($9,{children:`Development runtime unavailable.`})}function vee({api:e,chatId:t,initialMessages:n,sessionExists:r,supportsUploads:i,accept:a}){let o=Mt(),{revalidate:s}=le(),c=we(),[l]=(0,I.useState)(()=>new n5({api:e,tools:O3(Q9),elements:Q7}));return(0,L.jsx)(y3,{chatId:t,initialMessages:n,onFinish:()=>void s(),onResetChat:e=>{o(`/chat?chatId=${encodeURIComponent(e)}`)},resume:r,registry:Q9,transport:l,children:(0,L.jsxs)(s3,{className:`**:data-[slot='content']:max-w-3xl`,children:[(0,L.jsx)(p3.Root,{className:`px-6`,children:(0,L.jsx)(p3.Hero,{children:`How can I help?`})}),(0,L.jsx)(yee,{}),(0,L.jsx)(Tt,{treeId:t,snapshot:c.conversation?.children}),(0,L.jsx)(bee,{supportsUploads:i,accept:a})]})})}function yee(){let{error:e,messages:t,regenerate:n,status:r}=C3();return t.length===0&&!e?null:(0,L.jsxs)(l7.Root,{className:`mb-8 min-h-0 flex-1 px-6`,messages:t,elements:Q7,status:r,children:[(0,L.jsx)(l7.List,{children:t.map((e,n)=>(0,L.jsx)(l7.Item,{message:e,index:n,children:e.role===`user`?(0,L.jsx)(l7.UserBubble,{}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(dee,{message:e,running:n===t.length-1&&(r===`submitted`||r===`streaming`)}),(0,L.jsx)(l7.AssistantContent,{})]})},e.id))}),(0,L.jsx)(l7.Error,{error:e,onRetry:()=>void n()}),(0,L.jsx)(l7.Thinking,{})]})}function bee({supportsUploads:e,accept:t}){let{submit:n}=b3(),{hasSubmitted:r}=S3(),{status:i}=x3(),a=i===`submitted`||i===`streaming`;return(0,L.jsx)(`div`,{className:P(`w-full px-6 pb-6`,r&&`bg-background sticky bottom-0 mt-auto pt-2`),children:(0,L.jsx)(U8,{className:`bg-background`,children:(0,L.jsx)(N7.Provider,{isTaskRunning:a,onSubmit:t=>{let r=t.items.flatMap(e=>e.type===`image`||e.type===`video`||e.type===`audio`?[e.file]:[]);return!e&&r.length>0?Promise.reject(Error(`This runtime does not support file uploads`)):n({prompt:t.prompt,persistedPrompt:t.persistedPrompt,files:r})},children:(0,L.jsxs)(N7.Root,{children:[(0,L.jsx)(xee,{}),(0,L.jsx)(N7.Popup,{}),(0,L.jsxs)(N7.Content,{children:[(0,L.jsx)(N7.Attachments,{}),(0,L.jsx)(N7.Editor,{placeholder:`Message Zukhruf…`}),(0,L.jsx)(N7.Error,{})]}),(0,L.jsxs)(N7.Toolbar,{children:[e&&(0,L.jsx)(N7.AttachFiles,{accept:t}),(0,L.jsx)(See,{})]})]})})})})}function xee(){let{experimental_queuedMessages:e,experimental_removeQueuedMessage:t}=C3();return e.length===0?null:(0,L.jsx)(z7.Root,{children:e.map(e=>(0,L.jsxs)(z7.Item,{children:[(0,L.jsx)(z7.Icon,{}),(0,L.jsx)(z7.Text,{children:n3(e)}),(0,L.jsx)(z7.Remove,{onClick:()=>t(e.id)})]},e.id))})}function See(){let{state:e}=GZ(`ChatSubmitButton`),{stop:t}=b3(),{status:n}=x3(),r=e.text.trim().length>0;return(n===`submitted`||n===`streaming`)&&!r?(0,L.jsx)(G7,{className:`ml-auto`,type:`button`,variant:`stop`,onClick:t}):(0,L.jsx)(o2.Submit,{render:(0,L.jsx)(G7,{className:`ml-auto`,type:`button`,variant:`send`,disabled:!r})})}function $9({children:e}){return(0,L.jsx)(`p`,{className:`text-muted-foreground p-8 text-sm`,children:e})}export{gee as Component,mee as loader,hee as shouldRevalidate};
352
+ `)||void 0}}function K9(e){return!F9(e)||e.type!==`content`||!Array.isArray(e.value)?[]:e.value.flatMap(e=>{if(!F9(e)||e.type!==`file`)return[];let t=typeof e.mediaType==`string`?e.mediaType:`file`;return[`${typeof e.filename==`string`?e.filename:`Attachment`} · ${t}`]})}var q9={css:`css`,csv:`csv`,html:`html`,js:`javascript`,json:`json`,jsx:`jsx`,md:`markdown`,py:`python`,sh:`bash`,sql:`sql`,ts:`typescript`,tsx:`tsx`,txt:`text`,xml:`xml`,yaml:`yaml`,yml:`yaml`};function J9(e){return q9[e.split(`.`).pop()?.toLowerCase()??``]??`text`}function Y9(e){let t=L9(e,`offset`),n=L9(e,`limit`);if(t===void 0&&n===void 0)return;let r=t??1;return n===void 0?`${r}+`:`${r}-${r+n-1}`}function X9({part:e}){let t=I9(e.input,`path`)??``,n=G9(e.output),r=K9(e.output),i=F9(e.output)&&e.output.type===`error-text`?G9(e.output):void 0,a=B9(e)??i,o=z9(e),s=Y9(e.input);return(0,L.jsx)(U9,{children:a?(0,L.jsx)(V9,{error:!0,children:a}):o?(0,L.jsxs)(V9,{pending:!0,children:[`Reading `,t||`file`,`...`]}):n===void 0?r.length>0?(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`File content`}),r.map(e=>(0,L.jsx)(`p`,{className:`text-foreground/80 text-xs`,children:e},e))]}):(0,L.jsx)(V9,{children:`File content is unavailable.`}):n?(0,L.jsx)(H9,{code:n,detail:s?`lines ${s}`:void 0,language:J9(t),title:`File contents`}):(0,L.jsx)(V9,{children:`The file is empty.`})})}function cee({part:e}){let t=I9(e.input,`path`)??``,n=I9(e.input,`content`)??``,r=L9(e.output,`exitCode`),i=I9(e.output,`stderr`)??``,a=I9(e.output,`stdout`)??``,o=R9(e.output,`success`),s=B9(e);return(0,L.jsxs)(U9,{children:[z9(e)?(0,L.jsxs)(V9,{pending:!0,children:[`Writing `,t||`file`,`...`]}):s||o===!1||(r??0)!==0?(0,L.jsx)(V9,{error:!0,children:s||i||a||`Failed to write ${t||`file`}.`}):(0,L.jsx)(V9,{children:`File written.`}),n?(0,L.jsx)(H9,{code:n,language:J9(t),title:`Written content`}):(0,L.jsx)(V9,{children:`The file content is empty.`})]})}function lee(e){let t=I9(e.input,`command`),n=I9(e.input,`reasoning`),r=L9(e.output,`exitCode`);return{name:`Bash`,args:t?{cmd:t.slice(0,80)}:void 0,detail:n,isError:e.state===`output-error`||e.state===`output-denied`||r!==void 0&&r!==0}}function Z9(e,t){let n=I9(e.input,`path`),r=t===`ReadFile`?Y9(e.input):void 0,i=L9(e.output,`exitCode`);return{name:t,args:n||r?{...n?{path:n}:{},...r?{lines:r}:{}}:void 0,isError:e.state===`output-error`||e.state===`output-denied`||R9(e.output,`success`)===!1||i!==void 0&&i!==0||F9(e.output)&&e.output.type===`error-text`}}var Q9={ask_user_question:P9,bash:{component:W9,label:lee,static:!0},readFile:{component:X9,label:e=>Z9(e,`ReadFile`),static:!0},writeFile:{component:cee,label:e=>Z9(e,`WriteFile`),static:!0}},uee=xn(`status`,[N({id:F(),status:Ne(`restored`),sourceMessages:pn(),replacementMessages:pn()}),N({id:F(),status:Ne(`started`),tokenScope:Ne(`request`).optional(),triggerIndex:pn(),targetTokens:pn(),messageCount:pn()}),N({id:F(),status:Ne(`completed`),tokenScope:Ne(`request`).optional(),tokens:N({before:pn(),after:pn()})}),N({id:F(),status:Ne(`failed`),phase:Gt([`restore`,`evaluate`,`compact`,`persist`]),reason:Gt([`no-safe-boundary`,`protected-history`,`incomplete-summary`,`empty-summary`,`summary-too-large`,`request-overhead`,`error`])})]);function dee({message:e,running:t}){let n=e.parts.flatMap(e=>{if(e.type!==`data-compaction`)return[];let t=uee.safeParse(e.data);return t.success?[t.data]:[]}),r=Map.groupBy(n,e=>e.id);return Array.from(r,([e,n])=>(0,L.jsx)(fee,{events:n,running:t},e))}function fee({events:e,running:t}){let n=e.find(e=>e.status===`started`),r=e.find(e=>e.status===`completed`),i=e.find(e=>e.status===`failed`),a=e.find(e=>e.status===`restored`),o=n!==void 0&&!r&&!i;return(0,L.jsxs)(Ki,{className:`my-3`,children:[(0,L.jsx)(qi,{className:`group w-full text-left`,children:(0,L.jsxs)(eee,{children:[(0,L.jsx)(ga,{children:o&&t?(0,L.jsx)(Sa,{"aria-label":`Compacting context`}):i?(0,L.jsx)(ne,{className:`text-destructive size-4`}):r?(0,L.jsx)(je,{className:`size-4`}):(0,L.jsx)(Er,{className:`size-4`})}),(0,L.jsxs)(_a,{children:[(0,L.jsx)(va,{children:i?`Compaction failed`:r?`Context compacted`:o?t?`Compacting context…`:`Compaction interrupted`:`Using saved summary`}),r&&(0,L.jsxs)(ya,{children:[r.tokens.before.toLocaleString(),` →`,` `,r.tokens.after.toLocaleString(),` estimated`,` `,r.tokenScope===`request`?`input`:`message`,` `,`tokens`]})]}),(0,L.jsx)(se,{className:`size-3.5 transition-transform group-data-[panel-open]:rotate-90`})]})}),(0,L.jsxs)(Ji,{children:[(0,L.jsx)(ci,{}),(0,L.jsxs)(`div`,{className:`space-y-3 px-3 py-3 text-sm`,children:[(0,L.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-x-4 gap-y-2`,children:[n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Messages before compaction`}),(0,L.jsx)(`dd`,{children:n.messageCount.toLocaleString()}),(0,L.jsxs)(`dt`,{children:[`Estimated`,` `,n.tokenScope===`request`?`input`:`message`,` `,`target`]}),(0,L.jsxs)(`dd`,{children:[n.targetTokens.toLocaleString(),` tokens`]}),(0,L.jsx)(`dt`,{children:`Matched trigger`}),(0,L.jsxs)(`dd`,{children:[`#`,n.triggerIndex+1]})]}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Checkpoint`}),(0,L.jsx)(`dd`,{children:`Saved`})]}),a&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Using saved summary`}),(0,L.jsxs)(`dd`,{children:[a.sourceMessages,` → `,a.replacementMessages,` `,`messages`]})]})]}),i&&(0,L.jsx)(m,{variant:`destructive`,children:(0,L.jsxs)(jt,{children:[i.phase,`: `,i.reason]})})]})]})]})}var pee=N({messages:vt(kt())});async function mee(e){let{params:t,request:n}=e,r=t.sessionId??new URL(n.url).searchParams.get(`chatId`);if(!r)return Et(`/chat?chatId=${encodeURIComponent(crypto.randomUUID())}`);let i=await rn(n.signal),a=i.history.find(e=>e.chatId===r),o=i.discovery?.capabilities.chat.href;if(!o||!t.sessionId&&!a&&!i.historyError)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};try{let e=await fetch(`${o}/${encodeURIComponent(r)}`,{signal:n.signal});if(e.status===404&&!t.sessionId)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};if(!e.ok)throw Error(`Session request failed: ${e.status}`);let s=pee.safeParse(await e.json());if(!s.success)throw Error(`Session response did not include messages`);return{...i,chatId:r,conversation:a,initialMessages:await Z_({messages:s.data.messages}),sessionExists:!0,sessionError:!1}}catch{return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!0}}}function hee({currentParams:e,currentUrl:t,nextParams:n,nextUrl:r}){return e.sessionId!==n.sessionId||t.searchParams.get(`chatId`)!==r.searchParams.get(`chatId`)}function gee(){let{chatId:e}=we();return(0,L.jsx)(_ee,{chatId:e},e)}function _ee({chatId:e}){let{discovery:t,initialMessages:n,sessionError:r,sessionExists:i}=we(),a=t?.capabilities.chat.href;return a?r?(0,L.jsx)($9,{children:`Unable to load this conversation.`}):(0,L.jsx)(vee,{api:a,chatId:e,initialMessages:n,sessionExists:i,supportsUploads:t.capabilities.uploads!==void 0,accept:t.capabilities.uploads?.mediaTypes?.join(`,`)}):(0,L.jsx)($9,{children:`Development runtime unavailable.`})}function vee({api:e,chatId:t,initialMessages:n,sessionExists:r,supportsUploads:i,accept:a}){let o=Mt(),{revalidate:s}=le(),c=we(),[l]=(0,I.useState)(()=>new n5({api:e,tools:O3(Q9),elements:Q7}));return(0,L.jsx)(y3,{chatId:t,initialMessages:n,onFinish:()=>void s(),onResetChat:e=>{o(`/chat?chatId=${encodeURIComponent(e)}`)},resume:r,registry:Q9,transport:l,children:(0,L.jsxs)(s3,{className:`**:data-[slot='content']:max-w-3xl`,children:[(0,L.jsx)(p3.Root,{className:`px-6`,children:(0,L.jsx)(p3.Hero,{children:`How can I help?`})}),(0,L.jsx)(yee,{}),(0,L.jsx)(Tt,{treeId:t,snapshot:c.conversation?.children}),(0,L.jsx)(bee,{supportsUploads:i,accept:a})]})})}function yee(){let{error:e,messages:t,regenerate:n,status:r}=C3();return t.length===0&&!e?null:(0,L.jsxs)(l7.Root,{className:`mb-8 min-h-0 flex-1 px-6`,messages:t,elements:Q7,status:r,children:[(0,L.jsx)(l7.List,{children:t.map((e,n)=>(0,L.jsx)(l7.Item,{message:e,index:n,children:e.role===`user`?(0,L.jsx)(l7.UserBubble,{}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(dee,{message:e,running:n===t.length-1&&(r===`submitted`||r===`streaming`)}),(0,L.jsx)(l7.AssistantContent,{})]})},e.id))}),(0,L.jsx)(l7.Error,{error:e,onRetry:()=>void n()}),(0,L.jsx)(l7.Thinking,{})]})}function bee({supportsUploads:e,accept:t}){let{submit:n}=b3(),{hasSubmitted:r}=S3(),{status:i}=x3(),a=i===`submitted`||i===`streaming`;return(0,L.jsx)(`div`,{className:P(`w-full px-6 pb-6`,r&&`bg-background sticky bottom-0 mt-auto pt-2`),children:(0,L.jsx)(U8,{className:`bg-background`,children:(0,L.jsx)(N7.Provider,{isTaskRunning:a,onSubmit:t=>{let r=t.items.flatMap(e=>e.type===`image`||e.type===`video`||e.type===`audio`?[e.file]:[]);return!e&&r.length>0?Promise.reject(Error(`This runtime does not support file uploads`)):n({prompt:t.prompt,persistedPrompt:t.persistedPrompt,files:r})},children:(0,L.jsxs)(N7.Root,{children:[(0,L.jsx)(xee,{}),(0,L.jsx)(N7.Popup,{}),(0,L.jsxs)(N7.Content,{children:[(0,L.jsx)(N7.Attachments,{}),(0,L.jsx)(N7.Editor,{placeholder:`Message Zukhruf…`}),(0,L.jsx)(N7.Error,{})]}),(0,L.jsxs)(N7.Toolbar,{children:[e&&(0,L.jsx)(N7.AttachFiles,{accept:t}),(0,L.jsx)(See,{})]})]})})})})}function xee(){let{experimental_queuedMessages:e,experimental_removeQueuedMessage:t}=C3();return e.length===0?null:(0,L.jsx)(z7.Root,{children:e.map(e=>(0,L.jsxs)(z7.Item,{children:[(0,L.jsx)(z7.Icon,{}),(0,L.jsx)(z7.Text,{children:n3(e)}),(0,L.jsx)(z7.Remove,{onClick:()=>t(e.id)})]},e.id))})}function See(){let{state:e}=GZ(`ChatSubmitButton`),{stop:t}=b3(),{status:n}=x3(),r=e.text.trim().length>0;return(n===`submitted`||n===`streaming`)&&!r?(0,L.jsx)(G7,{className:`ml-auto`,type:`button`,variant:`stop`,onClick:t}):(0,L.jsx)(o2.Submit,{render:(0,L.jsx)(G7,{className:`ml-auto`,type:`button`,variant:`send`,disabled:!r})})}function $9({children:e}){return(0,L.jsx)(`p`,{className:`text-muted-foreground p-8 text-sm`,children:e})}export{gee as Component,mee as loader,hee as shouldRevalidate};