import{q as ie,x as i,I as _,P as _r,i as pa,b as We,E as Mi,B as tr,O as fa,k as Ri,M as ma,X as Fe,u as vr,S as Ue,H as tt,c as rn,d as Ct,A as xa,z as ga,e as ba,l as sn,n as On,T as dt,D as ka,g as ya,o as Nr,G as wa,f as ja,m as _a,L as Cr,R as Li,j as va,h as Na,r as Ca}from"./display-OFjwfD4F.js";import{g as Sa,l as Ea}from"./context-windows-C2Qe_OYn.js";import{F as f,x as Ia,w as Di,G as Pi,j as Fi,d as $n,H as Sr,p as Aa,m as Ta,y as at}from"./capabilities-CQ-mRPPK.js";import{n as te}from"./local-folders-Bgzoz3Cn.js";import{l as za,x as Oi,e as Ma,s as Ra,i as Xt,C as La,w as Da,d as $i,b as Pa,n as Qt,v as Fa,c as Oa,p as $a,o as Ba,m as Er}from"./schedule-time-BOqpL1aq.js";import{c as Yt,a as Wa}from"./_commonjsHelpers-C4iS2aBk.js";import"./tool-dispatcher-Bh6bg_9Z.js";import"./engine-DyHa3vHM.js";import"./local-fs-read-BFSyS_5z.js";import"./preload-helper-2LWRYvkK.js";/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Bi=ie("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const nr=ie("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ua=ie("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ha=ie("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const nt=ie("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const qa=ie("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Va=ie("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ka=ie("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const an=ie("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ga=ie("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Wi=ie("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Xa=ie("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Qa=ie("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ya=ie("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ui=ie("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const vt=ie("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Za=ie("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Hi=ie("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const rr=ie("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ja=ie("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Zt=ie("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const eo=ie("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const qi=ie("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const to=ie("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Vi=ie("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const no=ie("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ro=ie("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const io=ie("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const so=ie("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ao=ie("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const oo=ie("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const lo=ie("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const co=ie("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);async function uo(e){return chrome.permissions.request({permissions:e.permissions,origins:e.origins})}function ho(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const po=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fo=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,mo={};function Ir(e,t){return(mo.jsx?fo:po).test(e)}const xo=/[ \t\n\f\r]/g;function go(e){return typeof e=="object"?e.type==="text"?Ar(e.value):!1:Ar(e)}function Ar(e){return e.replace(xo,"")===""}class St{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}St.prototype.normal={};St.prototype.property={};St.prototype.space=void 0;function Ki(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new St(n,r,t)}function Bn(e){return e.toLowerCase()}class Ce{constructor(t,n){this.attribute=n,this.property=t}}Ce.prototype.attribute="";Ce.prototype.booleanish=!1;Ce.prototype.boolean=!1;Ce.prototype.commaOrSpaceSeparated=!1;Ce.prototype.commaSeparated=!1;Ce.prototype.defined=!1;Ce.prototype.mustUseProperty=!1;Ce.prototype.number=!1;Ce.prototype.overloadedBoolean=!1;Ce.prototype.property="";Ce.prototype.spaceSeparated=!1;Ce.prototype.space=void 0;let bo=0;const q=it(),he=it(),Wn=it(),A=it(),le=it(),ut=it(),Ie=it();function it(){return 2**++bo}const Un=Object.freeze(Object.defineProperty({__proto__:null,boolean:q,booleanish:he,commaOrSpaceSeparated:Ie,commaSeparated:ut,number:A,overloadedBoolean:Wn,spaceSeparated:le},Symbol.toStringTag,{value:"Module"})),wn=Object.keys(Un);class ir extends Ce{constructor(t,n,r,s){let o=-1;if(super(t,n),Tr(this,"space",s),typeof r=="number")for(;++o<wn.length;){const a=wn[o];Tr(this,wn[o],(r&Un[a])===Un[a])}}}ir.prototype.defined=!0;function Tr(e,t,n){n&&(e[t]=n)}function ht(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new ir(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Bn(r)]=r,n[Bn(o.attribute)]=r}return new St(t,n,e.space)}const Gi=ht({properties:{ariaActiveDescendant:null,ariaAtomic:he,ariaAutoComplete:null,ariaBusy:he,ariaChecked:he,ariaColCount:A,ariaColIndex:A,ariaColSpan:A,ariaControls:le,ariaCurrent:null,ariaDescribedBy:le,ariaDetails:null,ariaDisabled:he,ariaDropEffect:le,ariaErrorMessage:null,ariaExpanded:he,ariaFlowTo:le,ariaGrabbed:he,ariaHasPopup:null,ariaHidden:he,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:le,ariaLevel:A,ariaLive:null,ariaModal:he,ariaMultiLine:he,ariaMultiSelectable:he,ariaOrientation:null,ariaOwns:le,ariaPlaceholder:null,ariaPosInSet:A,ariaPressed:he,ariaReadOnly:he,ariaRelevant:null,ariaRequired:he,ariaRoleDescription:le,ariaRowCount:A,ariaRowIndex:A,ariaRowSpan:A,ariaSelected:he,ariaSetSize:A,ariaSort:null,ariaValueMax:A,ariaValueMin:A,ariaValueNow:A,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Xi(e,t){return t in e?e[t]:t}function Qi(e,t){return Xi(e,t.toLowerCase())}const ko=ht({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ut,acceptCharset:le,accessKey:le,action:null,allow:null,allowFullScreen:q,allowPaymentRequest:q,allowUserMedia:q,alt:null,as:null,async:q,autoCapitalize:null,autoComplete:le,autoFocus:q,autoPlay:q,blocking:le,capture:null,charSet:null,checked:q,cite:null,className:le,cols:A,colSpan:null,content:null,contentEditable:he,controls:q,controlsList:le,coords:A|ut,crossOrigin:null,data:null,dateTime:null,decoding:null,default:q,defer:q,dir:null,dirName:null,disabled:q,download:Wn,draggable:he,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:q,formTarget:null,headers:le,height:A,hidden:Wn,high:A,href:null,hrefLang:null,htmlFor:le,httpEquiv:le,id:null,imageSizes:null,imageSrcSet:null,inert:q,inputMode:null,integrity:null,is:null,isMap:q,itemId:null,itemProp:le,itemRef:le,itemScope:q,itemType:le,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:q,low:A,manifest:null,max:null,maxLength:A,media:null,method:null,min:null,minLength:A,multiple:q,muted:q,name:null,nonce:null,noModule:q,noValidate:q,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:q,optimum:A,pattern:null,ping:le,placeholder:null,playsInline:q,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:q,referrerPolicy:null,rel:le,required:q,reversed:q,rows:A,rowSpan:A,sandbox:le,scope:null,scoped:q,seamless:q,selected:q,shadowRootClonable:q,shadowRootDelegatesFocus:q,shadowRootMode:null,shape:null,size:A,sizes:null,slot:null,span:A,spellCheck:he,src:null,srcDoc:null,srcLang:null,srcSet:null,start:A,step:null,style:null,tabIndex:A,target:null,title:null,translate:null,type:null,typeMustMatch:q,useMap:null,value:he,width:A,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:le,axis:null,background:null,bgColor:null,border:A,borderColor:null,bottomMargin:A,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:q,declare:q,event:null,face:null,frame:null,frameBorder:null,hSpace:A,leftMargin:A,link:null,longDesc:null,lowSrc:null,marginHeight:A,marginWidth:A,noResize:q,noHref:q,noShade:q,noWrap:q,object:null,profile:null,prompt:null,rev:null,rightMargin:A,rules:null,scheme:null,scrolling:he,standby:null,summary:null,text:null,topMargin:A,valueType:null,version:null,vAlign:null,vLink:null,vSpace:A,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:q,disableRemotePlayback:q,prefix:null,property:null,results:A,security:null,unselectable:null},space:"html",transform:Qi}),yo=ht({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ie,accentHeight:A,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:A,amplitude:A,arabicForm:null,ascent:A,attributeName:null,attributeType:null,azimuth:A,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:A,by:null,calcMode:null,capHeight:A,className:le,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:A,diffuseConstant:A,direction:null,display:null,dur:null,divisor:A,dominantBaseline:null,download:q,dx:null,dy:null,edgeMode:null,editable:null,elevation:A,enableBackground:null,end:null,event:null,exponent:A,externalResourcesRequired:null,fill:null,fillOpacity:A,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ut,g2:ut,glyphName:ut,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:A,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:A,horizOriginX:A,horizOriginY:A,id:null,ideographic:A,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:A,k:A,k1:A,k2:A,k3:A,k4:A,kernelMatrix:Ie,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:A,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:A,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:A,overlineThickness:A,paintOrder:null,panose1:null,path:null,pathLength:A,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:le,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:A,pointsAtY:A,pointsAtZ:A,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ie,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ie,rev:Ie,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ie,requiredFeatures:Ie,requiredFonts:Ie,requiredFormats:Ie,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:A,specularExponent:A,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:A,strikethroughThickness:A,string:null,stroke:null,strokeDashArray:Ie,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:A,strokeOpacity:A,strokeWidth:null,style:null,surfaceScale:A,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ie,tabIndex:A,tableValues:null,target:null,targetX:A,targetY:A,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ie,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:A,underlineThickness:A,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:A,values:null,vAlphabetic:A,vMathematical:A,vectorEffect:null,vHanging:A,vIdeographic:A,version:null,vertAdvY:A,vertOriginX:A,vertOriginY:A,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:A,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Xi}),Yi=ht({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Zi=ht({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Qi}),Ji=ht({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),wo={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},jo=/[A-Z]/g,zr=/-[a-z]/g,_o=/^data[-\w.:]+$/i;function vo(e,t){const n=Bn(t);let r=t,s=Ce;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&_o.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(zr,Co);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!zr.test(o)){let a=o.replace(jo,No);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=ir}return new s(r,t)}function No(e){return"-"+e.toLowerCase()}function Co(e){return e.charAt(1).toUpperCase()}const So=Ki([Gi,ko,Yi,Zi,Ji],"html"),sr=Ki([Gi,yo,Yi,Zi,Ji],"svg");function Eo(e){return e.join(" ").trim()}var ar={},Mr=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Io=/\n/g,Ao=/^\s*/,To=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,zo=/^:\s*/,Mo=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Ro=/^[;\s]*/,Lo=/^\s+|\s+$/g,Do=`
`,Rr="/",Lr="*",Ze="",Po="comment",Fo="declaration";function Oo(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(m){var g=m.match(Io);g&&(n+=g.length);var w=m.lastIndexOf(Do);r=~w?m.length-w:r+m.length}function o(){var m={line:n,column:r};return function(g){return g.position=new a(m),u(),g}}function a(m){this.start=m,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(m){var g=new Error(t.source+":"+n+":"+r+": "+m);if(g.reason=m,g.filename=t.source,g.line=n,g.column=r,g.source=e,!t.silent)throw g}function c(m){var g=m.exec(e);if(g){var w=g[0];return s(w),e=e.slice(w.length),g}}function u(){c(Ao)}function h(m){var g;for(m=m||[];g=d();)g!==!1&&m.push(g);return m}function d(){var m=o();if(!(Rr!=e.charAt(0)||Lr!=e.charAt(1))){for(var g=2;Ze!=e.charAt(g)&&(Lr!=e.charAt(g)||Rr!=e.charAt(g+1));)++g;if(g+=2,Ze===e.charAt(g-1))return l("End of comment missing");var w=e.slice(2,g-2);return r+=2,s(w),e=e.slice(g),r+=2,m({type:Po,comment:w})}}function x(){var m=o(),g=c(To);if(g){if(d(),!c(zo))return l("property missing ':'");var w=c(Mo),y=m({type:Fo,property:Dr(g[0].replace(Mr,Ze)),value:w?Dr(w[0].replace(Mr,Ze)):Ze});return c(Ro),y}}function p(){var m=[];h(m);for(var g;g=x();)g!==!1&&(m.push(g),h(m));return m}return u(),p()}function Dr(e){return e?e.replace(Lo,Ze):Ze}var $o=Oo,Bo=Yt&&Yt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ar,"__esModule",{value:!0});ar.default=Uo;const Wo=Bo($o);function Uo(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,Wo.default)(e),s=typeof t=="function";return r.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:l}=o;s?t(a,l,o):l&&(n=n||{},n[a]=l)}),n}var on={};Object.defineProperty(on,"__esModule",{value:!0});on.camelCase=void 0;var Ho=/^--[a-zA-Z0-9_-]+$/,qo=/-([a-z])/g,Vo=/^[^-]+$/,Ko=/^-(webkit|moz|ms|o|khtml)-/,Go=/^-(ms)-/,Xo=function(e){return!e||Vo.test(e)||Ho.test(e)},Qo=function(e,t){return t.toUpperCase()},Pr=function(e,t){return"".concat(t,"-")},Yo=function(e,t){return t===void 0&&(t={}),Xo(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(Go,Pr):e=e.replace(Ko,Pr),e.replace(qo,Qo))};on.camelCase=Yo;var Zo=Yt&&Yt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Jo=Zo(ar),el=on;function Hn(e,t){var n={};return!e||typeof e!="string"||(0,Jo.default)(e,function(r,s){r&&s&&(n[(0,el.camelCase)(r,t)]=s)}),n}Hn.default=Hn;var tl=Hn;const nl=Wa(tl),es=ts("end"),or=ts("start");function ts(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function rl(e){const t=or(e),n=es(e);if(t&&n)return{start:t,end:n}}function bt(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Fr(e.position):"start"in e||"end"in e?Fr(e):"line"in e||"column"in e?qn(e):""}function qn(e){return Or(e&&e.line)+":"+Or(e&&e.column)}function Fr(e){return qn(e&&e.start)+"-"+qn(e&&e.end)}function Or(e){return e&&typeof e=="number"?e:1}class ke extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?s=t:!o.cause&&t&&(a=!0,s=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?o.ruleId=r:(o.source=r.slice(0,c),o.ruleId=r.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=bt(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ke.prototype.file="";ke.prototype.name="";ke.prototype.reason="";ke.prototype.message="";ke.prototype.stack="";ke.prototype.column=void 0;ke.prototype.line=void 0;ke.prototype.ancestors=void 0;ke.prototype.cause=void 0;ke.prototype.fatal=void 0;ke.prototype.place=void 0;ke.prototype.ruleId=void 0;ke.prototype.source=void 0;const lr={}.hasOwnProperty,il=new Map,sl=/[A-Z]/g,al=new Set(["table","tbody","thead","tfoot","tr"]),ol=new Set(["td","th"]),ns="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ll(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=xl(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=ml(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?sr:So,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=rs(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function rs(e,t,n){if(t.type==="element")return cl(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return ul(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return hl(e,t,n);if(t.type==="mdxjsEsm")return dl(e,t);if(t.type==="root")return pl(e,t,n);if(t.type==="text")return fl(e,t)}function cl(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=sr,e.schema=s),e.ancestors.push(t);const o=ss(e,t.tagName,!1),a=gl(e,t);let l=ur(e,t);return al.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!go(c):!0})),is(e,a,o,t),cr(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function ul(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Nt(e,t.position)}function dl(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Nt(e,t.position)}function hl(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=sr,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:ss(e,t.name,!0),a=bl(e,t),l=ur(e,t);return is(e,a,o,t),cr(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function pl(e,t,n){const r={};return cr(r,ur(e,t)),e.create(t,e.Fragment,r,n)}function fl(e,t){return t.value}function is(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function cr(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function ml(e,t,n){return r;function r(s,o,a,l){const u=Array.isArray(a.children)?n:t;return l?u(o,a,l):u(o,a)}}function xl(e,t){return n;function n(r,s,o,a){const l=Array.isArray(o.children),c=or(r);return t(s,o,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function gl(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&lr.call(t.properties,s)){const o=kl(e,s,t.properties[s]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&ol.has(t.tagName)?r=l:n[a]=l}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function bl(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Nt(e,t.position);else{const s=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,o=e.evaluater.evaluateExpression(l.expression)}else Nt(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function ur(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:il;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const c=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(c){const u=s.get(c)||0;a=c+"-"+u,s.set(c,u+1)}}const l=rs(e,o,a);l!==void 0&&n.push(l)}return n}function kl(e,t,n){const r=vo(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ho(n):Eo(n)),r.property==="style"){let s=typeof n=="object"?n:yl(e,String(n));return e.stylePropertyNameCase==="css"&&(s=wl(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?wo[r.property]||r.property:r.attribute,n]}}function yl(e,t){try{return nl(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new ke("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=ns+"#cannot-parse-style-attribute",s}}function ss(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let o=-1,a;for(;++o<s.length;){const l=Ir(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(o&&l.type==="Literal"),optional:!1}:l}r=a}else r=Ir(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return lr.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Nt(e)}function Nt(e,t){const n=new ke("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=ns+"#cannot-handle-mdx-estrees-without-createevaluater",n}function wl(e){const t={};let n;for(n in e)lr.call(e,n)&&(t[jl(n)]=e[n]);return t}function jl(e){let t=e.replace(sl,_l);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function _l(e){return"-"+e.toLowerCase()}const jn={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},vl={};function dr(e,t){const n=vl,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return as(e,r,s)}function as(e,t,n){if(Nl(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return $r(e.children,t,n)}return Array.isArray(e)?$r(e,t,n):""}function $r(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=as(e[s],t,n);return r.join("")}function Nl(e){return!!(e&&typeof e=="object")}const Br=document.createElement("i");function hr(e){const t="&"+e+";";Br.innerHTML=t;const n=Br.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Ae(e,t,n,r){const s=e.length;let o=0,a;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function Me(e,t){return e.length>0?(Ae(e,e.length,0,t),e):t}const Wr={}.hasOwnProperty;function os(e){const t={};let n=-1;for(;++n<e.length;)Cl(t,e[n]);return t}function Cl(e,t){let n;for(n in t){const s=(Wr.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){Wr.call(s,a)||(s[a]=[]);const l=o[a];Sl(s[a],Array.isArray(l)?l:l?[l]:[])}}}function Sl(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Ae(e,0,0,r)}function ls(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCharCode(n)}function Pe(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const _e=Ke(/[A-Za-z]/),be=Ke(/[\dA-Za-z]/),El=Ke(/[#-'*+\--9=?A-Z^-~]/);function Jt(e){return e!==null&&(e<32||e===127)}const Vn=Ke(/\d/),Il=Ke(/[\dA-Fa-f]/),Al=Ke(/[!-/:-@[-`{-~]/);function O(e){return e!==null&&e<-2}function oe(e){return e!==null&&(e<0||e===32)}function J(e){return e===-2||e===-1||e===32}const ln=Ke(new RegExp("\\p{P}","u")),rt=Ke(/\s/);function Ke(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function pt(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&be(e.charCodeAt(n+1))&&be(e.charCodeAt(n+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const l=e.charCodeAt(n+1);o<56320&&l>56319&&l<57344?(a=String.fromCharCode(o,l),s=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function ne(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(c){return J(c)?(e.enter(n),l(c)):t(c)}function l(c){return J(c)&&o++<s?(e.consume(c),l):(e.exit(n),t(c))}}const Tl={tokenize:zl};function zl(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),ne(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),o(l)}function o(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return O(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const Ml={tokenize:Rl},Ur={tokenize:Ll};function Rl(e){const t=this,n=[];let r=0,s,o,a;return l;function l(C){if(r<n.length){const I=n[r];return t.containerState=I[1],e.attempt(I[0].continuation,c,u)(C)}return u(C)}function c(C){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&E();const I=t.events.length;let T=I,v;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){v=t.events[T][1].end;break}y(r);let F=I;for(;F<t.events.length;)t.events[F][1].end=Object.assign({},v),F++;return Ae(t.events,T+1,0,t.events.slice(I)),t.events.length=F,u(C)}return l(C)}function u(C){if(r===n.length){if(!s)return x(C);if(s.currentConstruct&&s.currentConstruct.concrete)return m(C);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ur,h,d)(C)}function h(C){return s&&E(),y(r),x(C)}function d(C){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(C)}function x(C){return t.containerState={},e.attempt(Ur,p,m)(C)}function p(C){return r++,n.push([t.currentConstruct,t.containerState]),x(C)}function m(C){if(C===null){s&&E(),y(0),e.consume(C);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{contentType:"flow",previous:o,_tokenizer:s}),g(C)}function g(C){if(C===null){w(e.exit("chunkFlow"),!0),y(0),e.consume(C);return}return O(C)?(e.consume(C),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(C),g)}function w(C,I){const T=t.sliceStream(C);if(I&&T.push(null),C.previous=o,o&&(o.next=C),o=C,s.defineSkip(C.start),s.write(T),t.parser.lazy[C.start.line]){let v=s.events.length;for(;v--;)if(s.events[v][1].start.offset<a&&(!s.events[v][1].end||s.events[v][1].end.offset>a))return;const F=t.events.length;let Q=F,V,j;for(;Q--;)if(t.events[Q][0]==="exit"&&t.events[Q][1].type==="chunkFlow"){if(V){j=t.events[Q][1].end;break}V=!0}for(y(r),v=F;v<t.events.length;)t.events[v][1].end=Object.assign({},j),v++;Ae(t.events,Q+1,0,t.events.slice(F)),t.events.length=v}}function y(C){let I=n.length;for(;I-- >C;){const T=n[I];t.containerState=T[1],T[0].exit.call(t,e)}n.length=C}function E(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function Ll(e,t,n){return ne(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function en(e){if(e===null||oe(e)||rt(e))return 1;if(ln(e))return 2}function cn(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const Kn={name:"attention",tokenize:Pl,resolveAll:Dl};function Dl(e,t){let n=-1,r,s,o,a,l,c,u,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d=Object.assign({},e[r][1].end),x=Object.assign({},e[n][1].start);Hr(d,-c),Hr(x,c),a={type:c>1?"strongSequence":"emphasisSequence",start:d,end:Object.assign({},e[r][1].end)},l={type:c>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[n][1].start),end:x},o={type:c>1?"strongText":"emphasisText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},s={type:c>1?"strong":"emphasis",start:Object.assign({},a.start),end:Object.assign({},l.end)},e[r][1].end=Object.assign({},a.start),e[n][1].start=Object.assign({},l.end),u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Me(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Me(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",o,t]]),u=Me(u,cn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Me(u,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,u=Me(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,Ae(e,r-1,n-r+3,u),n=r+u.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Pl(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=en(r);let o;return a;function a(c){return o=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===o)return e.consume(c),l;const u=e.exit("attentionSequence"),h=en(c),d=!h||h===2&&s||n.includes(c),x=!s||s===2&&h||n.includes(r);return u._open=!!(o===42?d:d&&(s||!x)),u._close=!!(o===42?x:x&&(h||!d)),t(c)}}function Hr(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Fl={name:"autolink",tokenize:Ol};function Ol(e,t,n){let r=0;return s;function s(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(p){return _e(p)?(e.consume(p),a):u(p)}function a(p){return p===43||p===45||p===46||be(p)?(r=1,l(p)):u(p)}function l(p){return p===58?(e.consume(p),r=0,c):(p===43||p===45||p===46||be(p))&&r++<32?(e.consume(p),l):(r=0,u(p))}function c(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||Jt(p)?n(p):(e.consume(p),c)}function u(p){return p===64?(e.consume(p),h):El(p)?(e.consume(p),u):n(p)}function h(p){return be(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,h):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):x(p)}function x(p){if((p===45||be(p))&&r++<63){const m=p===45?x:d;return e.consume(p),m}return n(p)}}const Et={tokenize:$l,partial:!0};function $l(e,t,n){return r;function r(o){return J(o)?ne(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||O(o)?t(o):n(o)}}const cs={name:"blockQuote",tokenize:Bl,continuation:{tokenize:Wl},exit:Ul};function Bl(e,t,n){const r=this;return s;function s(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return n(a)}function o(a){return J(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Wl(e,t,n){const r=this;return s;function s(a){return J(a)?ne(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(cs,t,n)(a)}}function Ul(e){e.exit("blockQuote")}const us={name:"characterEscape",tokenize:Hl};function Hl(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return Al(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const ds={name:"characterReference",tokenize:ql};function ql(e,t,n){const r=this;let s=0,o,a;return l;function l(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),c}function c(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,a=be,h(d))}function u(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=Il,h):(e.enter("characterReferenceValue"),o=7,a=Vn,h(d))}function h(d){if(d===59&&s){const x=e.exit("characterReferenceValue");return a===be&&!hr(r.sliceSerialize(x))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(d)&&s++<o?(e.consume(d),h):n(d)}}const qr={tokenize:Kl,partial:!0},Vr={name:"codeFenced",tokenize:Vl,concrete:!0};function Vl(e,t,n){const r=this,s={tokenize:T,partial:!0};let o=0,a=0,l;return c;function c(v){return u(v)}function u(v){const F=r.events[r.events.length-1];return o=F&&F[1].type==="linePrefix"?F[2].sliceSerialize(F[1],!0).length:0,l=v,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(v)}function h(v){return v===l?(a++,e.consume(v),h):a<3?n(v):(e.exit("codeFencedFenceSequence"),J(v)?ne(e,d,"whitespace")(v):d(v))}function d(v){return v===null||O(v)?(e.exit("codeFencedFence"),r.interrupt?t(v):e.check(qr,g,I)(v)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(v))}function x(v){return v===null||O(v)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(v)):J(v)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ne(e,p,"whitespace")(v)):v===96&&v===l?n(v):(e.consume(v),x)}function p(v){return v===null||O(v)?d(v):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(v))}function m(v){return v===null||O(v)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(v)):v===96&&v===l?n(v):(e.consume(v),m)}function g(v){return e.attempt(s,I,w)(v)}function w(v){return e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),y}function y(v){return o>0&&J(v)?ne(e,E,"linePrefix",o+1)(v):E(v)}function E(v){return v===null||O(v)?e.check(qr,g,I)(v):(e.enter("codeFlowValue"),C(v))}function C(v){return v===null||O(v)?(e.exit("codeFlowValue"),E(v)):(e.consume(v),C)}function I(v){return e.exit("codeFenced"),t(v)}function T(v,F,Q){let V=0;return j;function j(K){return v.enter("lineEnding"),v.consume(K),v.exit("lineEnding"),R}function R(K){return v.enter("codeFencedFence"),J(K)?ne(v,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):L(K)}function L(K){return K===l?(v.enter("codeFencedFenceSequence"),ee(K)):Q(K)}function ee(K){return K===l?(V++,v.consume(K),ee):V>=a?(v.exit("codeFencedFenceSequence"),J(K)?ne(v,se,"whitespace")(K):se(K)):Q(K)}function se(K){return K===null||O(K)?(v.exit("codeFencedFence"),F(K)):Q(K)}}}function Kl(e,t,n){const r=this;return s;function s(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const _n={name:"codeIndented",tokenize:Xl},Gl={tokenize:Ql,partial:!0};function Xl(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),ne(e,o,"linePrefix",5)(u)}function o(u){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):O(u)?e.attempt(Gl,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||O(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function Ql(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):O(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):ne(e,o,"linePrefix",5)(a)}function o(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):O(a)?s(a):n(a)}}const Yl={name:"codeText",tokenize:ec,resolve:Zl,previous:Jl};function Zl(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function Jl(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function ec(e,t,n){let r=0,s,o;return a;function a(d){return e.enter("codeText"),e.enter("codeTextSequence"),l(d)}function l(d){return d===96?(e.consume(d),r++,l):(e.exit("codeTextSequence"),c(d))}function c(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),c):d===96?(o=e.enter("codeTextSequence"),s=0,h(d)):O(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||O(d)?(e.exit("codeTextData"),c(d)):(e.consume(d),u)}function h(d){return d===96?(e.consume(d),s++,h):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(o.type="codeTextData",u(d))}}function hs(e){const t={};let n=-1,r,s,o,a,l,c,u;for(;++n<e.length;){for(;n in t;)n=t[n];if(r=e[n],n&&r[1].type==="chunkFlow"&&e[n-1][1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,tc(e,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,s=void 0;o--&&(a=e[o],a[1].type==="lineEnding"||a[1].type==="lineEndingBlank");)a[0]==="enter"&&(s&&(e[s][1].type="lineEndingBlank"),a[1].type="lineEnding",s=o);s&&(r[1].end=Object.assign({},e[s][1].start),l=e.slice(s,n),l.unshift(r),Ae(e,s,n-s+1,l))}}return!u}function tc(e,t){const n=e[t][1],r=e[t][2];let s=t-1;const o=[],a=n._tokenizer||r.parser[n.contentType](n.start),l=a.events,c=[],u={};let h,d,x=-1,p=n,m=0,g=0;const w=[g];for(;p;){for(;e[++s][1]!==p;);o.push(s),p._tokenizer||(h=r.sliceStream(p),p.next||h.push(null),d&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(h),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++x<l.length;)l[x][0]==="exit"&&l[x-1][0]==="enter"&&l[x][1].type===l[x-1][1].type&&l[x][1].start.line!==l[x][1].end.line&&(g=x+1,w.push(g),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):w.pop(),x=w.length;x--;){const y=l.slice(w[x],w[x+1]),E=o.pop();c.unshift([E,E+y.length-1]),Ae(e,E,2,y)}for(x=-1;++x<c.length;)u[m+c[x][0]]=m+c[x][1],m+=c[x][1]-c[x][0]-1;return u}const nc={tokenize:sc,resolve:ic},rc={tokenize:ac,partial:!0};function ic(e){return hs(e),e}function sc(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(l)}function s(l){return l===null?o(l):O(l)?e.check(rc,a,o)(l):(e.consume(l),s)}function o(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function ac(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ne(e,o,"linePrefix")}function o(a){if(a===null||O(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function ps(e,t,n,r,s,o,a,l,c){const u=c||Number.POSITIVE_INFINITY;let h=0;return d;function d(y){return y===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(y),e.exit(o),x):y===null||y===32||y===41||Jt(y)?n(y):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),g(y))}function x(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(l),x(y)):y===null||y===60||O(y)?n(y):(e.consume(y),y===92?m:p)}function m(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function g(y){return!h&&(y===null||y===41||oe(y))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(y)):h<u&&y===40?(e.consume(y),h++,g):y===41?(e.consume(y),h--,g):y===null||y===32||y===40||Jt(y)?n(y):(e.consume(y),y===92?w:g)}function w(y){return y===40||y===41||y===92?(e.consume(y),g):g(y)}}function fs(e,t,n,r,s,o){const a=this;let l=0,c;return u;function u(p){return e.enter(r),e.enter(s),e.consume(p),e.exit(s),e.enter(o),h}function h(p){return l>999||p===null||p===91||p===93&&!c||p===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(o),e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):O(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||O(p)||l++>999?(e.exit("chunkString"),h(p)):(e.consume(p),c||(c=!J(p)),p===92?x:d)}function x(p){return p===91||p===92||p===93?(e.consume(p),l++,d):d(p)}}function ms(e,t,n,r,s,o){let a;return l;function l(x){return x===34||x===39||x===40?(e.enter(r),e.enter(s),e.consume(x),e.exit(s),a=x===40?41:x,c):n(x)}function c(x){return x===a?(e.enter(s),e.consume(x),e.exit(s),e.exit(r),t):(e.enter(o),u(x))}function u(x){return x===a?(e.exit(o),c(a)):x===null?n(x):O(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),ne(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(x))}function h(x){return x===a||x===null||O(x)?(e.exit("chunkString"),u(x)):(e.consume(x),x===92?d:h)}function d(x){return x===a||x===92?(e.consume(x),h):h(x)}}function kt(e,t){let n;return r;function r(s){return O(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):J(s)?ne(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const oc={name:"definition",tokenize:cc},lc={tokenize:uc,partial:!0};function cc(e,t,n){const r=this;let s;return o;function o(p){return e.enter("definition"),a(p)}function a(p){return fs.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function l(p){return s=Pe(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return oe(p)?kt(e,u)(p):u(p)}function u(p){return ps(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function h(p){return e.attempt(lc,d,d)(p)}function d(p){return J(p)?ne(e,x,"whitespace")(p):x(p)}function x(p){return p===null||O(p)?(e.exit("definition"),r.parser.defined.push(s),t(p)):n(p)}}function uc(e,t,n){return r;function r(l){return oe(l)?kt(e,s)(l):n(l)}function s(l){return ms(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return J(l)?ne(e,a,"whitespace")(l):a(l)}function a(l){return l===null||O(l)?t(l):n(l)}}const dc={name:"hardBreakEscape",tokenize:hc};function hc(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return O(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const pc={name:"headingAtx",tokenize:mc,resolve:fc};function fc(e,t){let n=e.length-2,r=3,s,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Ae(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function mc(e,t,n){let r=0;return s;function s(h){return e.enter("atxHeading"),o(h)}function o(h){return e.enter("atxHeadingSequence"),a(h)}function a(h){return h===35&&r++<6?(e.consume(h),a):h===null||oe(h)?(e.exit("atxHeadingSequence"),l(h)):n(h)}function l(h){return h===35?(e.enter("atxHeadingSequence"),c(h)):h===null||O(h)?(e.exit("atxHeading"),t(h)):J(h)?ne(e,l,"whitespace")(h):(e.enter("atxHeadingText"),u(h))}function c(h){return h===35?(e.consume(h),c):(e.exit("atxHeadingSequence"),l(h))}function u(h){return h===null||h===35||oe(h)?(e.exit("atxHeadingText"),l(h)):(e.consume(h),u)}}const xc=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Kr=["pre","script","style","textarea"],gc={name:"htmlFlow",tokenize:wc,resolveTo:yc,concrete:!0},bc={tokenize:_c,partial:!0},kc={tokenize:jc,partial:!0};function yc(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function wc(e,t,n){const r=this;let s,o,a,l,c;return u;function u(k){return h(k)}function h(k){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(k),d}function d(k){return k===33?(e.consume(k),x):k===47?(e.consume(k),o=!0,g):k===63?(e.consume(k),s=3,r.interrupt?t:b):_e(k)?(e.consume(k),a=String.fromCharCode(k),w):n(k)}function x(k){return k===45?(e.consume(k),s=2,p):k===91?(e.consume(k),s=5,l=0,m):_e(k)?(e.consume(k),s=4,r.interrupt?t:b):n(k)}function p(k){return k===45?(e.consume(k),r.interrupt?t:b):n(k)}function m(k){const M="CDATA[";return k===M.charCodeAt(l++)?(e.consume(k),l===M.length?r.interrupt?t:L:m):n(k)}function g(k){return _e(k)?(e.consume(k),a=String.fromCharCode(k),w):n(k)}function w(k){if(k===null||k===47||k===62||oe(k)){const M=k===47,H=a.toLowerCase();return!M&&!o&&Kr.includes(H)?(s=1,r.interrupt?t(k):L(k)):xc.includes(a.toLowerCase())?(s=6,M?(e.consume(k),y):r.interrupt?t(k):L(k)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(k):o?E(k):C(k))}return k===45||be(k)?(e.consume(k),a+=String.fromCharCode(k),w):n(k)}function y(k){return k===62?(e.consume(k),r.interrupt?t:L):n(k)}function E(k){return J(k)?(e.consume(k),E):j(k)}function C(k){return k===47?(e.consume(k),j):k===58||k===95||_e(k)?(e.consume(k),I):J(k)?(e.consume(k),C):j(k)}function I(k){return k===45||k===46||k===58||k===95||be(k)?(e.consume(k),I):T(k)}function T(k){return k===61?(e.consume(k),v):J(k)?(e.consume(k),T):C(k)}function v(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(e.consume(k),c=k,F):J(k)?(e.consume(k),v):Q(k)}function F(k){return k===c?(e.consume(k),c=null,V):k===null||O(k)?n(k):(e.consume(k),F)}function Q(k){return k===null||k===34||k===39||k===47||k===60||k===61||k===62||k===96||oe(k)?T(k):(e.consume(k),Q)}function V(k){return k===47||k===62||J(k)?C(k):n(k)}function j(k){return k===62?(e.consume(k),R):n(k)}function R(k){return k===null||O(k)?L(k):J(k)?(e.consume(k),R):n(k)}function L(k){return k===45&&s===2?(e.consume(k),ae):k===60&&s===1?(e.consume(k),ue):k===62&&s===4?(e.consume(k),de):k===63&&s===3?(e.consume(k),b):k===93&&s===5?(e.consume(k),fe):O(k)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(bc,we,ee)(k)):k===null||O(k)?(e.exit("htmlFlowData"),ee(k)):(e.consume(k),L)}function ee(k){return e.check(kc,se,we)(k)}function se(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),K}function K(k){return k===null||O(k)?ee(k):(e.enter("htmlFlowData"),L(k))}function ae(k){return k===45?(e.consume(k),b):L(k)}function ue(k){return k===47?(e.consume(k),a="",ye):L(k)}function ye(k){if(k===62){const M=a.toLowerCase();return Kr.includes(M)?(e.consume(k),de):L(k)}return _e(k)&&a.length<8?(e.consume(k),a+=String.fromCharCode(k),ye):L(k)}function fe(k){return k===93?(e.consume(k),b):L(k)}function b(k){return k===62?(e.consume(k),de):k===45&&s===2?(e.consume(k),b):L(k)}function de(k){return k===null||O(k)?(e.exit("htmlFlowData"),we(k)):(e.consume(k),de)}function we(k){return e.exit("htmlFlow"),t(k)}}function jc(e,t,n){const r=this;return s;function s(a){return O(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function _c(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Et,t,n)}}const vc={name:"htmlText",tokenize:Nc};function Nc(e,t,n){const r=this;let s,o,a;return l;function l(b){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(b),c}function c(b){return b===33?(e.consume(b),u):b===47?(e.consume(b),T):b===63?(e.consume(b),C):_e(b)?(e.consume(b),Q):n(b)}function u(b){return b===45?(e.consume(b),h):b===91?(e.consume(b),o=0,m):_e(b)?(e.consume(b),E):n(b)}function h(b){return b===45?(e.consume(b),p):n(b)}function d(b){return b===null?n(b):b===45?(e.consume(b),x):O(b)?(a=d,ue(b)):(e.consume(b),d)}function x(b){return b===45?(e.consume(b),p):d(b)}function p(b){return b===62?ae(b):b===45?x(b):d(b)}function m(b){const de="CDATA[";return b===de.charCodeAt(o++)?(e.consume(b),o===de.length?g:m):n(b)}function g(b){return b===null?n(b):b===93?(e.consume(b),w):O(b)?(a=g,ue(b)):(e.consume(b),g)}function w(b){return b===93?(e.consume(b),y):g(b)}function y(b){return b===62?ae(b):b===93?(e.consume(b),y):g(b)}function E(b){return b===null||b===62?ae(b):O(b)?(a=E,ue(b)):(e.consume(b),E)}function C(b){return b===null?n(b):b===63?(e.consume(b),I):O(b)?(a=C,ue(b)):(e.consume(b),C)}function I(b){return b===62?ae(b):C(b)}function T(b){return _e(b)?(e.consume(b),v):n(b)}function v(b){return b===45||be(b)?(e.consume(b),v):F(b)}function F(b){return O(b)?(a=F,ue(b)):J(b)?(e.consume(b),F):ae(b)}function Q(b){return b===45||be(b)?(e.consume(b),Q):b===47||b===62||oe(b)?V(b):n(b)}function V(b){return b===47?(e.consume(b),ae):b===58||b===95||_e(b)?(e.consume(b),j):O(b)?(a=V,ue(b)):J(b)?(e.consume(b),V):ae(b)}function j(b){return b===45||b===46||b===58||b===95||be(b)?(e.consume(b),j):R(b)}function R(b){return b===61?(e.consume(b),L):O(b)?(a=R,ue(b)):J(b)?(e.consume(b),R):V(b)}function L(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),s=b,ee):O(b)?(a=L,ue(b)):J(b)?(e.consume(b),L):(e.consume(b),se)}function ee(b){return b===s?(e.consume(b),s=void 0,K):b===null?n(b):O(b)?(a=ee,ue(b)):(e.consume(b),ee)}function se(b){return b===null||b===34||b===39||b===60||b===61||b===96?n(b):b===47||b===62||oe(b)?V(b):(e.consume(b),se)}function K(b){return b===47||b===62||oe(b)?V(b):n(b)}function ae(b){return b===62?(e.consume(b),e.exit("htmlTextData"),e.exit("htmlText"),t):n(b)}function ue(b){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),ye}function ye(b){return J(b)?ne(e,fe,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):fe(b)}function fe(b){return e.enter("htmlTextData"),a(b)}}const pr={name:"labelEnd",tokenize:Tc,resolveTo:Ac,resolveAll:Ic},Cc={tokenize:zc},Sc={tokenize:Mc},Ec={tokenize:Rc};function Ic(e){let t=-1;for(;++t<e.length;){const n=e[t][1];(n.type==="labelImage"||n.type==="labelLink"||n.type==="labelEnd")&&(e.splice(t+1,n.type==="labelImage"?4:2),n.type="data",t++)}return e}function Ac(e,t){let n=e.length,r=0,s,o,a,l;for(;n--;)if(s=e[n][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:Object.assign({},e[o][1].start),end:Object.assign({},e[e.length-1][1].end)},u={type:"label",start:Object.assign({},e[o][1].start),end:Object.assign({},e[a][1].end)},h={type:"labelText",start:Object.assign({},e[o+r+2][1].end),end:Object.assign({},e[a-2][1].start)};return l=[["enter",c,t],["enter",u,t]],l=Me(l,e.slice(o+1,o+r+3)),l=Me(l,[["enter",h,t]]),l=Me(l,cn(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=Me(l,[["exit",h,t],e[a-2],e[a-1],["exit",u,t]]),l=Me(l,e.slice(a+1)),l=Me(l,[["exit",c,t]]),Ae(e,o,e.length,l),e}function Tc(e,t,n){const r=this;let s=r.events.length,o,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){o=r.events[s][1];break}return l;function l(x){return o?o._inactive?d(x):(a=r.parser.defined.includes(Pe(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),c):n(x)}function c(x){return x===40?e.attempt(Cc,h,a?h:d)(x):x===91?e.attempt(Sc,h,a?u:d)(x):a?h(x):d(x)}function u(x){return e.attempt(Ec,h,d)(x)}function h(x){return t(x)}function d(x){return o._balanced=!0,n(x)}}function zc(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),s}function s(d){return oe(d)?kt(e,o)(d):o(d)}function o(d){return d===41?h(d):ps(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return oe(d)?kt(e,c)(d):h(d)}function l(d){return n(d)}function c(d){return d===34||d===39||d===40?ms(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):h(d)}function u(d){return oe(d)?kt(e,h)(d):h(d)}function h(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function Mc(e,t,n){const r=this;return s;function s(l){return fs.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(Pe(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function Rc(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const Lc={name:"labelStartImage",tokenize:Dc,resolveAll:pr.resolveAll};function Dc(e,t,n){const r=this;return s;function s(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),o}function o(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const Pc={name:"labelStartLink",tokenize:Fc,resolveAll:pr.resolveAll};function Fc(e,t,n){const r=this;return s;function s(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const vn={name:"lineEnding",tokenize:Oc};function Oc(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ne(e,t,"linePrefix")}}const Vt={name:"thematicBreak",tokenize:$c};function $c(e,t,n){let r=0,s;return o;function o(u){return e.enter("thematicBreak"),a(u)}function a(u){return s=u,l(u)}function l(u){return u===s?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||O(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),J(u)?ne(e,l,"whitespace")(u):l(u))}}const Ne={name:"list",tokenize:Uc,continuation:{tokenize:Hc},exit:Vc},Bc={tokenize:Kc,partial:!0},Wc={tokenize:qc,partial:!0};function Uc(e,t,n){const r=this,s=r.events[r.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Vn(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Vt,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return Vn(p)&&++a<10?(e.consume(p),c):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Et,r.interrupt?n:h,e.attempt(Bc,x,d))}function h(p){return r.containerState.initialBlankLine=!0,o++,x(p)}function d(p){return J(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),x):n(p)}function x(p){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Hc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Et,s,o);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ne(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!J(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Wc,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,ne(e,e.attempt(Ne,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function qc(e,t,n){const r=this;return ne(e,s,"listItemIndent",r.containerState.size+1);function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function Vc(e){e.exit(this.containerState.type)}function Kc(e,t,n){const r=this;return ne(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const a=r.events[r.events.length-1];return!J(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Gr={name:"setextUnderline",tokenize:Xc,resolveTo:Gc};function Gc(e,t){let n=e.length,r,s,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:Object.assign({},e[s][1].start),end:Object.assign({},e[e.length-1][1].end)};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end=Object.assign({},e[o][1].end)):e[r][1]=a,e.push(["exit",a,t]),e}function Xc(e,t,n){const r=this;let s;return o;function o(u){let h=r.events.length,d;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){d=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),s=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===s?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),J(u)?ne(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||O(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Qc={tokenize:Yc};function Yc(e){const t=this,n=e.attempt(Et,r,e.attempt(this.parser.constructs.flowInitial,s,ne(e,e.attempt(this.parser.constructs.flow,s,e.attempt(nc,s)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Zc={resolveAll:gs()},Jc=xs("string"),eu=xs("text");function xs(e){return{tokenize:t,resolveAll:gs(e==="text"?tu:void 0)};function t(n){const r=this,s=this.parser.constructs[e],o=n.attempt(s,a,l);return a;function a(h){return u(h)?o(h):l(h)}function l(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),c}function c(h){return u(h)?(n.exit("data"),o(h)):(n.consume(h),c)}function u(h){if(h===null)return!0;const d=s[h];let x=-1;if(d)for(;++x<d.length;){const p=d[x];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function gs(e){return t;function t(n,r){let s=-1,o;for(;++s<=n.length;)o===void 0?n[s]&&n[s][1].type==="data"&&(o=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==o+2&&(n[o][1].end=n[s-1][1].end,n.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(n,r):n}}function tu(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let o=s.length,a=-1,l=0,c;for(;o--;){const u=s[o];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)c=!0,l++;else if(u!==-1){o++;break}}if(l){const u={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{line:r.end.line,column:r.end.column-l,offset:r.end.offset-l,_index:r.start._index+o,_bufferIndex:o?a:r.start._bufferIndex+a},end:Object.assign({},r.end)};r.end=Object.assign({},u.start),r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}function nu(e,t,n){let r=Object.assign(n?Object.assign({},n):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1});const s={},o=[];let a=[],l=[];const c={consume:E,enter:C,exit:I,attempt:F(T),check:F(v),interrupt:F(v,{interrupt:!0})},u={previous:null,code:null,containerState:{},events:[],parser:e,sliceStream:p,sliceSerialize:x,now:m,defineSkip:g,write:d};let h=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function d(R){return a=Me(a,R),w(),a[a.length-1]!==null?[]:(Q(t,0),u.events=cn(o,u.events,u),u.events)}function x(R,L){return iu(p(R),L)}function p(R){return ru(a,R)}function m(){const{line:R,column:L,offset:ee,_index:se,_bufferIndex:K}=r;return{line:R,column:L,offset:ee,_index:se,_bufferIndex:K}}function g(R){s[R.line]=R.column,j()}function w(){let R;for(;r._index<a.length;){const L=a[r._index];if(typeof L=="string")for(R=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===R&&r._bufferIndex<L.length;)y(L.charCodeAt(r._bufferIndex));else y(L)}}function y(R){h=h(R)}function E(R){O(R)?(r.line++,r.column=1,r.offset+=R===-3?2:1,j()):R!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=R}function C(R,L){const ee=L||{};return ee.type=R,ee.start=m(),u.events.push(["enter",ee,u]),l.push(ee),ee}function I(R){const L=l.pop();return L.end=m(),u.events.push(["exit",L,u]),L}function T(R,L){Q(R,L.from)}function v(R,L){L.restore()}function F(R,L){return ee;function ee(se,K,ae){let ue,ye,fe,b;return Array.isArray(se)?we(se):"tokenize"in se?we([se]):de(se);function de(U){return W;function W(Y){const ve=Y!==null&&U[Y],G=Y!==null&&U.null,Te=[...Array.isArray(ve)?ve:ve?[ve]:[],...Array.isArray(G)?G:G?[G]:[]];return we(Te)(Y)}}function we(U){return ue=U,ye=0,U.length===0?ae:k(U[ye])}function k(U){return W;function W(Y){return b=V(),fe=U,U.partial||(u.currentConstruct=U),U.name&&u.parser.constructs.disable.null.includes(U.name)?H():U.tokenize.call(L?Object.assign(Object.create(u),L):u,c,M,H)(Y)}}function M(U){return R(fe,b),K}function H(U){return b.restore(),++ye<ue.length?k(ue[ye]):ae}}}function Q(R,L){R.resolveAll&&!o.includes(R)&&o.push(R),R.resolve&&Ae(u.events,L,u.events.length-L,R.resolve(u.events.slice(L),u)),R.resolveTo&&(u.events=R.resolveTo(u.events,u))}function V(){const R=m(),L=u.previous,ee=u.currentConstruct,se=u.events.length,K=Array.from(l);return{restore:ae,from:se};function ae(){r=R,u.previous=L,u.currentConstruct=ee,u.events.length=se,l=K,j()}}function j(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function ru(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,o=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,o)];else{if(a=e.slice(n,s),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}o>0&&a.push(e[s].slice(0,o))}return a}function iu(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
`;break}case-3:{a=`\r
`;break}case-2:{a=t?" ":"	";break}case-1:{if(!t&&s)continue;a=" ";break}default:a=String.fromCharCode(o)}s=o===-2,r.push(a)}return r.join("")}const su={42:Ne,43:Ne,45:Ne,48:Ne,49:Ne,50:Ne,51:Ne,52:Ne,53:Ne,54:Ne,55:Ne,56:Ne,57:Ne,62:cs},au={91:oc},ou={[-2]:_n,[-1]:_n,32:_n},lu={35:pc,42:Vt,45:[Gr,Vt],60:gc,61:Gr,95:Vt,96:Vr,126:Vr},cu={38:ds,92:us},uu={[-5]:vn,[-4]:vn,[-3]:vn,33:Lc,38:ds,42:Kn,60:[Fl,vc],91:Pc,92:[dc,us],93:pr,95:Kn,96:Yl},du={null:[Kn,Zc]},hu={null:[42,95]},pu={null:[]},fu=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:hu,contentInitial:au,disable:pu,document:su,flow:lu,flowInitial:ou,insideSpan:du,string:cu,text:uu},Symbol.toStringTag,{value:"Module"}));function mu(e){const n=os([fu,...(e||{}).extensions||[]]),r={defined:[],lazy:{},constructs:n,content:s(Tl),document:s(Ml),flow:s(Qc),string:s(Jc),text:s(eu)};return r;function s(o){return a;function a(l){return nu(r,o,l)}}}function xu(e){for(;!hs(e););return e}const Xr=/[\0\t\n\r]/g;function gu(){let e=1,t="",n=!0,r;return s;function s(o,a,l){const c=[];let u,h,d,x,p;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),d=0,t="",n&&(o.charCodeAt(0)===65279&&d++,n=void 0);d<o.length;){if(Xr.lastIndex=d,u=Xr.exec(o),x=u&&u.index!==void 0?u.index:o.length,p=o.charCodeAt(x),!u){t=o.slice(d);break}if(p===10&&d===x&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),d<x&&(c.push(o.slice(d,x)),e+=x-d),p){case 0:{c.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,c.push(-2);e++<h;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}d=x+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const bu=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ku(e){return e.replace(bu,yu)}function yu(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return ls(n.slice(o?2:1),o?16:10)}return hr(n)||e}const bs={}.hasOwnProperty;function wu(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),ju(n)(xu(mu(n).document().write(gu()(e,t,!0))))}function ju(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(ft),autolinkProtocol:V,autolinkEmail:V,atxHeading:o(At),blockQuote:o(G),characterEscape:V,characterReference:V,codeFenced:o(Te),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(Te,a),codeText:o(ge,a),codeTextData:V,data:V,codeFlowValue:V,definition:o(me),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(pn),hardBreakEscape:o(Tt),hardBreakTrailing:o(Tt),htmlFlow:o(zt,a),htmlFlowData:V,htmlText:o(zt,a),htmlTextData:V,image:o(fn),label:a,link:o(ft),listItem:o(mn),listItemValue:x,listOrdered:o(Mt,d),listUnordered:o(Mt),paragraph:o(xn),reference:k,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(At),strong:o(gn),thematicBreak:o(bn)},exit:{atxHeading:c(),atxHeadingSequence:T,autolink:c(),autolinkEmail:ve,autolinkProtocol:Y,blockQuote:c(),characterEscapeValue:j,characterReferenceMarkerHexadecimal:H,characterReferenceMarkerNumeric:H,characterReferenceValue:U,characterReference:W,codeFenced:c(w),codeFencedFence:g,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:j,codeIndented:c(y),codeText:c(K),codeTextData:j,data:j,definition:c(),definitionDestinationString:I,definitionLabelString:E,definitionTitleString:C,emphasis:c(),hardBreakEscape:c(L),hardBreakTrailing:c(L),htmlFlow:c(ee),htmlFlowData:j,htmlText:c(se),htmlTextData:j,image:c(ue),label:fe,labelText:ye,lineEnding:R,link:c(ae),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:M,resourceDestinationString:b,resourceTitleString:de,resource:we,setextHeading:c(Q),setextHeadingLineSequence:F,setextHeadingText:v,strong:c(),thematicBreak:c()}};ks(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(S){let z={type:"root",children:[]};const B={stack:[z],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:h,data:n},Z=[];let re=-1;for(;++re<S.length;)if(S[re][1].type==="listOrdered"||S[re][1].type==="listUnordered")if(S[re][0]==="enter")Z.push(re);else{const Se=Z.pop();re=s(S,Se,re)}for(re=-1;++re<S.length;){const Se=t[S[re][0]];bs.call(Se,S[re][1].type)&&Se[S[re][1].type].call(Object.assign({sliceSerialize:S[re][2].sliceSerialize},B),S[re][1])}if(B.tokenStack.length>0){const Se=B.tokenStack[B.tokenStack.length-1];(Se[1]||Qr).call(B,void 0,Se[0])}for(z.position={start:Ve(S.length>0?S[0][1].start:{line:1,column:1,offset:0}),end:Ve(S.length>0?S[S.length-2][1].end:{line:1,column:1,offset:0})},re=-1;++re<t.transforms.length;)z=t.transforms[re](z)||z;return z}function s(S,z,B){let Z=z-1,re=-1,Se=!1,Be,ze,Ge,Xe;for(;++Z<=B;){const je=S[Z];switch(je[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{je[0]==="enter"?re++:re--,Xe=void 0;break}case"lineEndingBlank":{je[0]==="enter"&&(Be&&!Xe&&!re&&!Ge&&(Ge=Z),Xe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Xe=void 0}if(!re&&je[0]==="enter"&&je[1].type==="listItemPrefix"||re===-1&&je[0]==="exit"&&(je[1].type==="listUnordered"||je[1].type==="listOrdered")){if(Be){let qe=Z;for(ze=void 0;qe--;){const Le=S[qe];if(Le[1].type==="lineEnding"||Le[1].type==="lineEndingBlank"){if(Le[0]==="exit")continue;ze&&(S[ze][1].type="lineEndingBlank",Se=!0),Le[1].type="lineEnding",ze=qe}else if(!(Le[1].type==="linePrefix"||Le[1].type==="blockQuotePrefix"||Le[1].type==="blockQuotePrefixWhitespace"||Le[1].type==="blockQuoteMarker"||Le[1].type==="listItemIndent"))break}Ge&&(!ze||Ge<ze)&&(Be._spread=!0),Be.end=Object.assign({},ze?S[ze][1].start:je[1].end),S.splice(ze||Z,0,["exit",Be,je[2]]),Z++,B++}if(je[1].type==="listItemPrefix"){const qe={type:"listItem",_spread:!1,start:Object.assign({},je[1].start),end:void 0};Be=qe,S.splice(Z,0,["enter",qe,je[2]]),Z++,B++,Ge=void 0,Xe=!0}}}return S[z][1]._spread=Se,B}function o(S,z){return B;function B(Z){l.call(this,S(Z),Z),z&&z.call(this,Z)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(S,z,B){this.stack[this.stack.length-1].children.push(S),this.stack.push(S),this.tokenStack.push([z,B||void 0]),S.position={start:Ve(z.start),end:void 0}}function c(S){return z;function z(B){S&&S.call(this,B),u.call(this,B)}}function u(S,z){const B=this.stack.pop(),Z=this.tokenStack.pop();if(Z)Z[0].type!==S.type&&(z?z.call(this,S,Z[0]):(Z[1]||Qr).call(this,S,Z[0]));else throw new Error("Cannot close `"+S.type+"` ("+bt({start:S.start,end:S.end})+"): it’s not open");B.position.end=Ve(S.end)}function h(){return dr(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function x(S){if(this.data.expectingFirstListItemValue){const z=this.stack[this.stack.length-2];z.start=Number.parseInt(this.sliceSerialize(S),10),this.data.expectingFirstListItemValue=void 0}}function p(){const S=this.resume(),z=this.stack[this.stack.length-1];z.lang=S}function m(){const S=this.resume(),z=this.stack[this.stack.length-1];z.meta=S}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const S=this.resume(),z=this.stack[this.stack.length-1];z.value=S.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const S=this.resume(),z=this.stack[this.stack.length-1];z.value=S.replace(/(\r?\n|\r)$/g,"")}function E(S){const z=this.resume(),B=this.stack[this.stack.length-1];B.label=z,B.identifier=Pe(this.sliceSerialize(S)).toLowerCase()}function C(){const S=this.resume(),z=this.stack[this.stack.length-1];z.title=S}function I(){const S=this.resume(),z=this.stack[this.stack.length-1];z.url=S}function T(S){const z=this.stack[this.stack.length-1];if(!z.depth){const B=this.sliceSerialize(S).length;z.depth=B}}function v(){this.data.setextHeadingSlurpLineEnding=!0}function F(S){const z=this.stack[this.stack.length-1];z.depth=this.sliceSerialize(S).codePointAt(0)===61?1:2}function Q(){this.data.setextHeadingSlurpLineEnding=void 0}function V(S){const B=this.stack[this.stack.length-1].children;let Z=B[B.length-1];(!Z||Z.type!=="text")&&(Z=Rt(),Z.position={start:Ve(S.start),end:void 0},B.push(Z)),this.stack.push(Z)}function j(S){const z=this.stack.pop();z.value+=this.sliceSerialize(S),z.position.end=Ve(S.end)}function R(S){const z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const B=z.children[z.children.length-1];B.position.end=Ve(S.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(z.type)&&(V.call(this,S),j.call(this,S))}function L(){this.data.atHardBreak=!0}function ee(){const S=this.resume(),z=this.stack[this.stack.length-1];z.value=S}function se(){const S=this.resume(),z=this.stack[this.stack.length-1];z.value=S}function K(){const S=this.resume(),z=this.stack[this.stack.length-1];z.value=S}function ae(){const S=this.stack[this.stack.length-1];if(this.data.inReference){const z=this.data.referenceType||"shortcut";S.type+="Reference",S.referenceType=z,delete S.url,delete S.title}else delete S.identifier,delete S.label;this.data.referenceType=void 0}function ue(){const S=this.stack[this.stack.length-1];if(this.data.inReference){const z=this.data.referenceType||"shortcut";S.type+="Reference",S.referenceType=z,delete S.url,delete S.title}else delete S.identifier,delete S.label;this.data.referenceType=void 0}function ye(S){const z=this.sliceSerialize(S),B=this.stack[this.stack.length-2];B.label=ku(z),B.identifier=Pe(z).toLowerCase()}function fe(){const S=this.stack[this.stack.length-1],z=this.resume(),B=this.stack[this.stack.length-1];if(this.data.inReference=!0,B.type==="link"){const Z=S.children;B.children=Z}else B.alt=z}function b(){const S=this.resume(),z=this.stack[this.stack.length-1];z.url=S}function de(){const S=this.resume(),z=this.stack[this.stack.length-1];z.title=S}function we(){this.data.inReference=void 0}function k(){this.data.referenceType="collapsed"}function M(S){const z=this.resume(),B=this.stack[this.stack.length-1];B.label=z,B.identifier=Pe(this.sliceSerialize(S)).toLowerCase(),this.data.referenceType="full"}function H(S){this.data.characterReferenceType=S.type}function U(S){const z=this.sliceSerialize(S),B=this.data.characterReferenceType;let Z;B?(Z=ls(z,B==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Z=hr(z);const re=this.stack[this.stack.length-1];re.value+=Z}function W(S){const z=this.stack.pop();z.position.end=Ve(S.end)}function Y(S){j.call(this,S);const z=this.stack[this.stack.length-1];z.url=this.sliceSerialize(S)}function ve(S){j.call(this,S);const z=this.stack[this.stack.length-1];z.url="mailto:"+this.sliceSerialize(S)}function G(){return{type:"blockquote",children:[]}}function Te(){return{type:"code",lang:null,meta:null,value:""}}function ge(){return{type:"inlineCode",value:""}}function me(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function pn(){return{type:"emphasis",children:[]}}function At(){return{type:"heading",depth:0,children:[]}}function Tt(){return{type:"break"}}function zt(){return{type:"html",value:""}}function fn(){return{type:"image",title:null,url:"",alt:null}}function ft(){return{type:"link",title:null,url:"",children:[]}}function Mt(S){return{type:"list",ordered:S.type==="listOrdered",start:null,spread:S._spread,children:[]}}function mn(S){return{type:"listItem",spread:S._spread,checked:null,children:[]}}function xn(){return{type:"paragraph",children:[]}}function gn(){return{type:"strong",children:[]}}function Rt(){return{type:"text",value:""}}function bn(){return{type:"thematicBreak"}}}function Ve(e){return{line:e.line,column:e.column,offset:e.offset}}function ks(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?ks(e,r):_u(e,r)}}function _u(e,t){let n;for(n in t)if(bs.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Qr(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+bt({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+bt({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+bt({start:t.start,end:t.end})+") is still open")}function vu(e){const t=this;t.parser=n;function n(r){return wu(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Nu(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Cu(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
`}]}function Su(e,t){const n=t.value?t.value+`
`:"",r={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function Eu(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Iu(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Au(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=pt(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,l+=1,e.footnoteCounts.set(r,l);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+s,id:n+"fnref-"+s+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function Tu(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function zu(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ys(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const s=e.all(t),o=s[0];o&&o.type==="text"?o.value="["+o.value:s.unshift({type:"text",value:"["});const a=s[s.length-1];return a&&a.type==="text"?a.value+=r:s.push({type:"text",value:r}),s}function Mu(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ys(e,t);const s={src:pt(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,o),e.applyData(t,o)}function Ru(e,t){const n={src:pt(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Lu(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Du(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ys(e,t);const s={href:pt(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function Pu(e,t){const n={href:pt(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Fu(e,t,n){const r=e.all(t),s=n?Ou(n):ws(t),o={},a=[];if(typeof t.checked=="boolean"){const h=r[0];let d;h&&h.type==="element"&&h.tagName==="p"?d=h:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const h=r[l];(s||l!==0||h.type!=="element"||h.tagName!=="p")&&a.push({type:"text",value:`
`}),h.type==="element"&&h.tagName==="p"&&!s?a.push(...h.children):a.push(h)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
`});const u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)}function Ou(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=ws(n[r])}return t}function ws(e){const t=e.spread;return t??e.children.length>1}function $u(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<r.length;){const a=r[s];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function Bu(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Wu(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Uu(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Hu(e,t){const n=e.all(t),r=n.shift(),s=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),s.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=or(t.children[1]),c=es(t.children[t.children.length-1]);l&&c&&(a.position={start:l,end:c}),s.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,o),e.applyData(t,o)}function qu(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let c=-1;const u=[];for(;++c<l;){const d=t.children[c],x={},p=a?a[c]:void 0;p&&(x.align=p);let m={type:"element",tagName:o,properties:x,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),u.push(m)}const h={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,h),e.applyData(t,h)}function Vu(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Yr=9,Zr=32;function Ku(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(Jr(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(Jr(t.slice(s),s>0,!1)),o.join("")}function Jr(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===Yr||o===Zr;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===Yr||o===Zr;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function Gu(e,t){const n={type:"text",value:Ku(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Xu(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Qu={blockquote:Nu,break:Cu,code:Su,delete:Eu,emphasis:Iu,footnoteReference:Au,heading:Tu,html:zu,imageReference:Mu,image:Ru,inlineCode:Lu,linkReference:Du,link:Pu,listItem:Fu,list:$u,paragraph:Bu,root:Wu,strong:Uu,table:Hu,tableCell:Vu,tableRow:qu,text:Gu,thematicBreak:Xu,toml:Lt,yaml:Lt,definition:Lt,footnoteDefinition:Lt};function Lt(){}const js=-1,un=0,yt=1,tn=2,fr=3,mr=4,xr=5,gr=6,_s=7,vs=8,Yu=typeof self=="object"?self:globalThis,ei=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new Yu[e](t)},Zu=(e,t)=>{const n=(s,o)=>(e.set(o,s),s),r=s=>{if(e.has(s))return e.get(s);const[o,a]=t[s];switch(o){case un:case js:return n(a,s);case yt:{const l=n([],s);for(const c of a)l.push(r(c));return l}case tn:{const l=n({},s);for(const[c,u]of a)l[r(c)]=r(u);return l}case fr:return n(new Date(a),s);case mr:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case xr:{const l=n(new Map,s);for(const[c,u]of a)l.set(r(c),r(u));return l}case gr:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case _s:{const{name:l,message:c}=a;return n(ei(l,c),s)}case vs:return n(BigInt(a),s);case"BigInt":return n(Object(BigInt(a)),s);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return n(new DataView(l),a)}}return n(ei(o,a),s)};return r},ti=e=>Zu(new Map,e)(0),ot="",{toString:Ju}={},{keys:ed}=Object,mt=e=>{const t=typeof e;if(t!=="object"||!e)return[un,t];const n=Ju.call(e).slice(8,-1);switch(n){case"Array":return[yt,ot];case"Object":return[tn,ot];case"Date":return[fr,ot];case"RegExp":return[mr,ot];case"Map":return[xr,ot];case"Set":return[gr,ot];case"DataView":return[yt,n]}return n.includes("Array")?[yt,n]:n.includes("Error")?[_s,n]:[tn,n]},Dt=([e,t])=>e===un&&(t==="function"||t==="symbol"),td=(e,t,n,r)=>{const s=(a,l)=>{const c=r.push(a)-1;return n.set(l,c),c},o=a=>{if(n.has(a))return n.get(a);let[l,c]=mt(a);switch(l){case un:{let h=a;switch(c){case"bigint":l=vs,h=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);h=null;break;case"undefined":return s([js],a)}return s([l,h],a)}case yt:{if(c){let x=a;return c==="DataView"?x=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(x=new Uint8Array(a)),s([c,[...x]],a)}const h=[],d=s([l,h],a);for(const x of a)h.push(o(x));return d}case tn:{if(c)switch(c){case"BigInt":return s([c,a.toString()],a);case"Boolean":case"Number":case"String":return s([c,a.valueOf()],a)}if(t&&"toJSON"in a)return o(a.toJSON());const h=[],d=s([l,h],a);for(const x of ed(a))(e||!Dt(mt(a[x])))&&h.push([o(x),o(a[x])]);return d}case fr:return s([l,a.toISOString()],a);case mr:{const{source:h,flags:d}=a;return s([l,{source:h,flags:d}],a)}case xr:{const h=[],d=s([l,h],a);for(const[x,p]of a)(e||!(Dt(mt(x))||Dt(mt(p))))&&h.push([o(x),o(p)]);return d}case gr:{const h=[],d=s([l,h],a);for(const x of a)(e||!Dt(mt(x)))&&h.push(o(x));return d}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return o},ni=(e,{json:t,lossy:n}={})=>{const r=[];return td(!(t||n),!!t,new Map,r)(e),r},Je=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ti(ni(e,t)):structuredClone(e):(e,t)=>ti(ni(e,t));function nd(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function rd(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function id(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||nd,r=e.options.footnoteBackLabel||rd,s=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const h=e.all(u),d=String(u.identifier).toUpperCase(),x=pt(d.toLowerCase());let p=0;const m=[],g=e.footnoteCounts.get(d);for(;g!==void 0&&++p<=g;){m.length>0&&m.push({type:"text",value:" "});let E=typeof n=="string"?n:n(c,p);typeof E=="string"&&(E={type:"text",value:E}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,p),className:["data-footnote-backref"]},children:Array.isArray(E)?E:[E]})}const w=h[h.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const E=w.children[w.children.length-1];E&&E.type==="text"?E.value+=" ":w.children.push({type:"text",value:" "}),w.children.push(...m)}else h.push(...m);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(h,!0)};e.patch(u,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Je(a),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
`}]}}const dn=function(e){if(e==null)return ld;if(typeof e=="function")return hn(e);if(typeof e=="object")return Array.isArray(e)?sd(e):ad(e);if(typeof e=="string")return od(e);throw new Error("Expected function, string, or object as test")};function sd(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=dn(e[n]);return hn(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function ad(e){const t=e;return hn(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function od(e){return hn(t);function t(n){return n&&n.type===e}}function hn(e){return t;function t(n,r,s){return!!(cd(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function ld(){return!0}function cd(e){return e!==null&&typeof e=="object"&&"type"in e}const Ns=[],ud=!0,Gn=!1,dd="skip";function Cs(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=dn(s),a=r?-1:1;l(e,void 0,[])();function l(c,u,h){const d=c&&typeof c=="object"?c:{};if(typeof d.type=="string"){const p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(c.type+(p?"<"+p+">":""))+")"})}return x;function x(){let p=Ns,m,g,w;if((!t||o(c,u,h[h.length-1]||void 0))&&(p=hd(n(c,h)),p[0]===Gn))return p;if("children"in c&&c.children){const y=c;if(y.children&&p[0]!==dd)for(g=(r?y.children.length:-1)+a,w=h.concat(y);g>-1&&g<y.children.length;){const E=y.children[g];if(m=l(E,g,w)(),m[0]===Gn)return m;g=typeof m[1]=="number"?m[1]:g+a}}return p}}}function hd(e){return Array.isArray(e)?e:typeof e=="number"?[ud,e]:e==null?Ns:[e]}function br(e,t,n,r){let s,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,s=n):(o=t,a=n,s=r),Cs(e,o,l,s);function l(c,u){const h=u[u.length-1],d=h?h.children.indexOf(c):void 0;return a(c,d,h)}}const Xn={}.hasOwnProperty,pd={};function fd(e,t){const n=t||pd,r=new Map,s=new Map,o=new Map,a={...Qu,...n.handlers},l={all:u,applyData:xd,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:md,wrap:bd};return br(e,function(h){if(h.type==="definition"||h.type==="footnoteDefinition"){const d=h.type==="definition"?r:s,x=String(h.identifier).toUpperCase();d.has(x)||d.set(x,h)}}),l;function c(h,d){const x=h.type,p=l.handlers[x];if(Xn.call(l.handlers,x)&&p)return p(l,h,d);if(l.options.passThrough&&l.options.passThrough.includes(x)){if("children"in h){const{children:g,...w}=h,y=Je(w);return y.children=l.all(h),y}return Je(h)}return(l.options.unknownHandler||gd)(l,h,d)}function u(h){const d=[];if("children"in h){const x=h.children;let p=-1;for(;++p<x.length;){const m=l.one(x[p],h);if(m){if(p&&x[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=ri(m.value)),!Array.isArray(m)&&m.type==="element")){const g=m.children[0];g&&g.type==="text"&&(g.value=ri(g.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function md(e,t){e.position&&(t.position=rl(e))}function xd(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,Je(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function gd(e,t){const n=t.data||{},r="value"in t&&!(Xn.call(n,"hProperties")||Xn.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function bd(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
`});++r<e.length;)r&&n.push({type:"text",value:`
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
`}),n}function ri(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ii(e,t){const n=fd(e,t),r=n.one(e,void 0),s=id(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&o.children.push({type:"text",value:`
`},s),o}function kd(e,t){return e&&"run"in e?async function(n,r){const s=ii(n,{file:r,...t});await e.run(s,r)}:function(n,r){return ii(n,{file:r,...e||t})}}function si(e){if(e)throw e}function Qn(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function yd(){const e=[],t={run:n,use:r};return t;function n(...s){let o=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...s);function l(c,...u){const h=e[++o];let d=-1;if(c){a(c);return}for(;++d<s.length;)(u[d]===null||u[d]===void 0)&&(u[d]=s[d]);s=u,h?wd(h,l)(...u):a(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function wd(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(s);try{c=e.apply(this,a)}catch(u){const h=u;if(l&&n)throw h;return s(h)}l||(c&&c.then&&typeof c.then=="function"?c.then(o,s):c instanceof Error?s(c):o(c))}function s(a,...l){n||(n=!0,t(a,...l))}function o(a){s(null,a)}}const Oe={basename:jd,dirname:_d,extname:vd,join:Nd,sep:"/"};function jd(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');It(e);let n=0,r=-1,s=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else r<0&&(o=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else a<0&&(o=!0,a=s+1),l>-1&&(e.codePointAt(s)===t.codePointAt(l--)?l<0&&(r=s):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function _d(e){if(It(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function vd(e){It(e);let t=e.length,n=-1,r=0,s=-1,o=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?s<0?s=t:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||n<0||o===0||o===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function Nd(...e){let t=-1,n;for(;++t<e.length;)It(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Cd(n)}function Cd(e){It(e);const t=e.codePointAt(0)===47;let n=Sd(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Sd(e,t){let n="",r=0,s=-1,o=0,a=-1,l,c;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(s===a-1||o===1))if(s!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),s=a,o=0;continue}}else if(n.length>0){n="",r=0,s=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),r=a-s-1;s=a,o=0}else l===46&&o>-1?o++:o=-1}return n}function It(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Ed={cwd:Id};function Id(){return"/"}function Yn(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Ad(e){if(typeof e=="string")e=new URL(e);else if(!Yn(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Td(e)}function Td(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const Nn=["history","path","basename","stem","extname","dirname"];class Ss{constructor(t){let n;t?Yn(t)?n={path:t}:typeof t=="string"||zd(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":Ed.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Nn.length;){const o=Nn[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let s;for(s in n)Nn.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Oe.basename(this.path):void 0}set basename(t){Sn(t,"basename"),Cn(t,"basename"),this.path=Oe.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Oe.dirname(this.path):void 0}set dirname(t){ai(this.basename,"dirname"),this.path=Oe.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Oe.extname(this.path):void 0}set extname(t){if(Cn(t,"extname"),ai(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Oe.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Yn(t)&&(t=Ad(t)),Sn(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Oe.basename(this.path,this.extname):void 0}set stem(t){Sn(t,"stem"),Cn(t,"stem"),this.path=Oe.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new ke(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Cn(e,t){if(e&&e.includes(Oe.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Oe.sep+"`")}function Sn(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ai(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function zd(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Md=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};Object.setPrototypeOf(o,r);const a=Object.getOwnPropertyNames(s);for(const l of a){const c=Object.getOwnPropertyDescriptor(s,l);c&&Object.defineProperty(o,l,c)}return o},Rd={}.hasOwnProperty;class kr extends Md{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=yd()}copy(){const t=new kr;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Je(this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(An("data",this.frozen),this.namespace[t]=n,this):Rd.call(this.namespace,t)&&this.namespace[t]||void 0:t?(An("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const s=n.call(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Pt(t),r=this.parser||this.Parser;return En("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),En("process",this.parser||this.Parser),In("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const l=Pt(t),c=r.parse(l);r.run(c,l,function(h,d,x){if(h||!d||!x)return u(h);const p=d,m=r.stringify(p,x);Pd(m)?x.value=m:x.result=m,u(h,x)});function u(h,d){h||!d?a(h):o?o(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),En("processSync",this.parser||this.Parser),In("processSync",this.compiler||this.Compiler),this.process(t,s),li("processSync","process",n),r;function s(o,a){n=!0,si(o),r=a}}run(t,n,r){oi(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(a,l){const c=Pt(n);s.run(t,c,u);function u(h,d,x){const p=d||t;h?l(h):a?a(p):r(void 0,p,x)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),li("runSync","run",r),s;function o(a,l){si(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Pt(n),s=this.compiler||this.Compiler;return In("stringify",s),oi(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(An("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[h,...d]=u;c(h,d)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(s.settings={...s.settings,...Je(u.settings)})}function l(u){let h=-1;if(u!=null)if(Array.isArray(u))for(;++h<u.length;){const d=u[h];o(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,h){let d=-1,x=-1;for(;++d<r.length;)if(r[d][0]===u){x=d;break}if(x===-1)r.push([u,...h]);else if(h.length>0){let[p,...m]=h;const g=r[x][1];Qn(g)&&Qn(p)&&(p=Je({...g,...p})),r[x]=[u,p,...m]}}}}const Ld=new kr().freeze();function En(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function In(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function An(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function oi(e){if(!Qn(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function li(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Pt(e){return Dd(e)?e:new Ss(e)}function Dd(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Pd(e){return typeof e=="string"||Fd(e)}function Fd(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Od="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",ci=[],ui={allowDangerousHtml:!0},$d=/^(https?|ircs?|mailto|xmpp)$/i,Bd=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Es(e){const t=Wd(e),n=Ud(e);return Hd(t.runSync(t.parse(n),n),e)}function Wd(e){const t=e.rehypePlugins||ci,n=e.remarkPlugins||ci,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...ui}:ui;return Ld().use(vu).use(n).use(kd,r).use(t)}function Ud(e){const t=e.children||"",n=new Ss;return typeof t=="string"&&(n.value=t),n}function Hd(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||qd;for(const h of Bd)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+Od+h.id,void 0);return br(e,u),ll(e,{Fragment:i.Fragment,components:s,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function u(h,d,x){if(h.type==="raw"&&x&&typeof d=="number")return a?x.children.splice(d,1):x.children[d]={type:"text",value:h.value},d;if(h.type==="element"){let p;for(p in jn)if(Object.hasOwn(jn,p)&&Object.hasOwn(h.properties,p)){const m=h.properties[p],g=jn[p];(g===null||g.includes(h.tagName))&&(h.properties[p]=c(String(m||""),p,h))}}if(h.type==="element"){let p=n?!n.includes(h.tagName):o?o.includes(h.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(h,d,x)),p&&x&&typeof d=="number")return l&&h.children?x.children.splice(d,1,...h.children):x.children.splice(d,1),d}}}function qd(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||$d.test(e.slice(0,t))?e:""}function di(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;s!==-1;)r++,s=n.indexOf(t,s+t.length);return r}function Vd(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Kd(e,t,n){const s=dn((n||{}).ignore||[]),o=Gd(t);let a=-1;for(;++a<o.length;)Cs(e,"text",l);function l(u,h){let d=-1,x;for(;++d<h.length;){const p=h[d],m=x?x.children:void 0;if(s(p,m?m.indexOf(p):void 0,x))return;x=p}if(x)return c(u,h)}function c(u,h){const d=h[h.length-1],x=o[a][0],p=o[a][1];let m=0;const w=d.children.indexOf(u);let y=!1,E=[];x.lastIndex=0;let C=x.exec(u.value);for(;C;){const I=C.index,T={index:C.index,input:C.input,stack:[...h,u]};let v=p(...C,T);if(typeof v=="string"&&(v=v.length>0?{type:"text",value:v}:void 0),v===!1?x.lastIndex=I+1:(m!==I&&E.push({type:"text",value:u.value.slice(m,I)}),Array.isArray(v)?E.push(...v):v&&E.push(v),m=I+C[0].length,y=!0),!x.global)break;C=x.exec(u.value)}return y?(m<u.value.length&&E.push({type:"text",value:u.value.slice(m)}),d.children.splice(w,1,...E)):E=[u],w+E.length}}function Gd(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const s=n[r];t.push([Xd(s[0]),Qd(s[1])])}return t}function Xd(e){return typeof e=="string"?new RegExp(Vd(e),"g"):e}function Qd(e){return typeof e=="function"?e:function(){return e}}const Tn="phrasing",zn=["autolink","link","image","label"];function Yd(){return{transforms:[ih],enter:{literalAutolink:Jd,literalAutolinkEmail:Mn,literalAutolinkHttp:Mn,literalAutolinkWww:Mn},exit:{literalAutolink:rh,literalAutolinkEmail:nh,literalAutolinkHttp:eh,literalAutolinkWww:th}}}function Zd(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Tn,notInConstruct:zn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Tn,notInConstruct:zn},{character:":",before:"[ps]",after:"\\/",inConstruct:Tn,notInConstruct:zn}]}}function Jd(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Mn(e){this.config.enter.autolinkProtocol.call(this,e)}function eh(e){this.config.exit.autolinkProtocol.call(this,e)}function th(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function nh(e){this.config.exit.autolinkEmail.call(this,e)}function rh(e){this.exit(e)}function ih(e){Kd(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,sh],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),ah]],{ignore:["link","linkReference"]})}function sh(e,t,n,r,s){let o="";if(!Is(s)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!oh(n)))return!1;const a=lh(n+r);if(!a[0])return!1;const l={type:"link",title:null,url:o+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[l,{type:"text",value:a[1]}]:l}function ah(e,t,n,r){return!Is(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function oh(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function lh(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const s=di(e,"(");let o=di(e,")");for(;r!==-1&&s>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}function Is(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||rt(n)||ln(n))&&(!t||n!==47)}As.peek=gh;function ch(){this.buffer()}function uh(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function dh(){this.buffer()}function hh(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function ph(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Pe(this.sliceSerialize(e)).toLowerCase(),n.label=t}function fh(e){this.exit(e)}function mh(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Pe(this.sliceSerialize(e)).toLowerCase(),n.label=t}function xh(e){this.exit(e)}function gh(){return"["}function As(e,t,n,r){const s=n.createTracker(r);let o=s.move("[^");const a=n.enter("footnoteReference"),l=n.enter("reference");return o+=s.move(n.safe(n.associationId(e),{after:"]",before:o})),l(),a(),o+=s.move("]"),o}function bh(){return{enter:{gfmFootnoteCallString:ch,gfmFootnoteCall:uh,gfmFootnoteDefinitionLabelString:dh,gfmFootnoteDefinition:hh},exit:{gfmFootnoteCallString:ph,gfmFootnoteCall:fh,gfmFootnoteDefinitionLabelString:mh,gfmFootnoteDefinition:xh}}}function kh(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:As},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,s,o,a){const l=o.createTracker(a);let c=l.move("[^");const u=o.enter("footnoteDefinition"),h=o.enter("label");return c+=l.move(o.safe(o.associationId(r),{before:c,after:"]"})),h(),c+=l.move("]:"),r.children&&r.children.length>0&&(l.shift(4),c+=l.move((t?`
`:" ")+o.indentLines(o.containerFlow(r,l.current()),t?Ts:yh))),u(),c}}function yh(e,t,n){return t===0?e:Ts(e,t,n)}function Ts(e,t,n){return(n?"":"    ")+e}const wh=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];zs.peek=Ch;function jh(){return{canContainEols:["delete"],enter:{strikethrough:vh},exit:{strikethrough:Nh}}}function _h(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:wh}],handlers:{delete:zs}}}function vh(e){this.enter({type:"delete",children:[]},e)}function Nh(e){this.exit(e)}function zs(e,t,n,r){const s=n.createTracker(r),o=n.enter("strikethrough");let a=s.move("~~");return a+=n.containerPhrasing(e,{...s.current(),before:a,after:"~"}),a+=s.move("~~"),o(),a}function Ch(){return"~"}function Sh(e){return e.length}function Eh(e,t){const n=t||{},r=(n.align||[]).concat(),s=n.stringLength||Sh,o=[],a=[],l=[],c=[];let u=0,h=-1;for(;++h<e.length;){const g=[],w=[];let y=-1;for(e[h].length>u&&(u=e[h].length);++y<e[h].length;){const E=Ih(e[h][y]);if(n.alignDelimiters!==!1){const C=s(E);w[y]=C,(c[y]===void 0||C>c[y])&&(c[y]=C)}g.push(E)}a[h]=g,l[h]=w}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<u;)o[d]=hi(r[d]);else{const g=hi(r);for(;++d<u;)o[d]=g}d=-1;const x=[],p=[];for(;++d<u;){const g=o[d];let w="",y="";g===99?(w=":",y=":"):g===108?w=":":g===114&&(y=":");let E=n.alignDelimiters===!1?1:Math.max(1,c[d]-w.length-y.length);const C=w+"-".repeat(E)+y;n.alignDelimiters!==!1&&(E=w.length+E+y.length,E>c[d]&&(c[d]=E),p[d]=E),x[d]=C}a.splice(1,0,x),l.splice(1,0,p),h=-1;const m=[];for(;++h<a.length;){const g=a[h],w=l[h];d=-1;const y=[];for(;++d<u;){const E=g[d]||"";let C="",I="";if(n.alignDelimiters!==!1){const T=c[d]-(w[d]||0),v=o[d];v===114?C=" ".repeat(T):v===99?T%2?(C=" ".repeat(T/2+.5),I=" ".repeat(T/2-.5)):(C=" ".repeat(T/2),I=C):I=" ".repeat(T)}n.delimiterStart!==!1&&!d&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&E==="")&&(n.delimiterStart!==!1||d)&&y.push(" "),n.alignDelimiters!==!1&&y.push(C),y.push(E),n.alignDelimiters!==!1&&y.push(I),n.padding!==!1&&y.push(" "),(n.delimiterEnd!==!1||d!==u-1)&&y.push("|")}m.push(n.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return m.join(`
`)}function Ih(e){return e==null?"":String(e)}function hi(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function Ah(e,t,n,r){const s=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const a=n.indentLines(n.containerFlow(e,o.current()),Th);return s(),a}function Th(e,t,n){return">"+(n?"":" ")+e}function zh(e,t){return pi(e,t.inConstruct,!0)&&!pi(e,t.notInConstruct,!1)}function pi(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function fi(e,t,n,r){let s=-1;for(;++s<n.unsafe.length;)if(n.unsafe[s].character===`
`&&zh(n.stack,n.unsafe[s]))return/[ \t]/.test(r.before)?"":" ";return`\\
`}function Mh(e,t){const n=String(e);let r=n.indexOf(t),s=r,o=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===s?++o>a&&(a=o):o=1,s=r+t.length,r=n.indexOf(t,s);return a}function Rh(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Lh(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Dh(e,t,n,r){const s=Lh(n),o=e.value||"",a=s==="`"?"GraveAccent":"Tilde";if(Rh(e,n)){const d=n.enter("codeIndented"),x=n.indentLines(o,Ph);return d(),x}const l=n.createTracker(r),c=s.repeat(Math.max(Mh(o,s)+1,3)),u=n.enter("codeFenced");let h=l.move(c);if(e.lang){const d=n.enter(`codeFencedLang${a}`);h+=l.move(n.safe(e.lang,{before:h,after:" ",encode:["`"],...l.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${a}`);h+=l.move(" "),h+=l.move(n.safe(e.meta,{before:h,after:`
`,encode:["`"],...l.current()})),d()}return h+=l.move(`
`),o&&(h+=l.move(o+`
`)),h+=l.move(c),u(),h}function Ph(e,t,n){return(n?"":"    ")+e}function yr(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Fh(e,t,n,r){const s=yr(n),o=s==='"'?"Quote":"Apostrophe",a=n.enter("definition");let l=n.enter("label");const c=n.createTracker(r);let u=c.move("[");return u+=c.move(n.safe(n.associationId(e),{before:u,after:"]",...c.current()})),u+=c.move("]: "),l(),!e.url||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(l=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":`
`,...c.current()}))),l(),e.title&&(l=n.enter(`title${o}`),u+=c.move(" "+s),u+=c.move(n.safe(e.title,{before:u,after:s,...c.current()})),u+=c.move(s),l()),a(),u}function Oh(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}Ms.peek=$h;function Ms(e,t,n,r){const s=Oh(n),o=n.enter("emphasis"),a=n.createTracker(r);let l=a.move(s);return l+=a.move(n.containerPhrasing(e,{before:l,after:s,...a.current()})),l+=a.move(s),o(),l}function $h(e,t,n){return n.options.emphasis||"*"}function Bh(e,t){let n=!1;return br(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Gn}),!!((!e.depth||e.depth<3)&&dr(e)&&(t.options.setext||n))}function Wh(e,t,n,r){const s=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(Bh(e,n)){const h=n.enter("headingSetext"),d=n.enter("phrasing"),x=n.containerPhrasing(e,{...o.current(),before:`
`,after:`
`});return d(),h(),x+`
`+(s===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(`
`))+1))}const a="#".repeat(s),l=n.enter("headingAtx"),c=n.enter("phrasing");o.move(a+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
`,...o.current()});return/^[\t ]/.test(u)&&(u="&#x"+u.charCodeAt(0).toString(16).toUpperCase()+";"+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),c(),l(),u}Rs.peek=Uh;function Rs(e){return e.value||""}function Uh(){return"<"}Ls.peek=Hh;function Ls(e,t,n,r){const s=yr(n),o=s==='"'?"Quote":"Apostrophe",a=n.enter("image");let l=n.enter("label");const c=n.createTracker(r);let u=c.move("![");return u+=c.move(n.safe(e.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(l=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":")",...c.current()}))),l(),e.title&&(l=n.enter(`title${o}`),u+=c.move(" "+s),u+=c.move(n.safe(e.title,{before:u,after:s,...c.current()})),u+=c.move(s),l()),u+=c.move(")"),a(),u}function Hh(){return"!"}Ds.peek=qh;function Ds(e,t,n,r){const s=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("![");const u=n.safe(e.alt,{before:c,after:"]",...l.current()});c+=l.move(u+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:c,after:"]",...l.current()});return a(),n.stack=h,o(),s==="full"||!u||u!==d?c+=l.move(d+"]"):s==="shortcut"?c=c.slice(0,-1):c+=l.move("]"),c}function qh(){return"!"}function Vh(e){if(!e._compiled){const t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}Ps.peek=Kh;function Ps(e,t,n){let r=e.value||"",s="`",o=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const a=n.unsafe[o],l=Vh(a);let c;if(a.atBreak)for(;c=l.exec(r);){let u=c.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(c.index+1)}}return s+r+s}function Kh(){return"`"}function Fs(e,t){const n=dr(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Os.peek=Gh;function Os(e,t,n,r){const s=yr(n),o=s==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let l,c;if(Fs(e,n)){const h=n.stack;n.stack=[],l=n.enter("autolink");let d=a.move("<");return d+=a.move(n.containerPhrasing(e,{before:d,after:">",...a.current()})),d+=a.move(">"),l(),n.stack=h,d}l=n.enter("link"),c=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(c=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),c(),e.title&&(c=n.enter(`title${o}`),u+=a.move(" "+s),u+=a.move(n.safe(e.title,{before:u,after:s,...a.current()})),u+=a.move(s),c()),u+=a.move(")"),l(),u}function Gh(e,t,n){return Fs(e,n)?"<":"["}$s.peek=Xh;function $s(e,t,n,r){const s=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("[");const u=n.containerPhrasing(e,{before:c,after:"]",...l.current()});c+=l.move(u+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:c,after:"]",...l.current()});return a(),n.stack=h,o(),s==="full"||!u||u!==d?c+=l.move(d+"]"):s==="shortcut"?c=c.slice(0,-1):c+=l.move("]"),c}function Xh(){return"["}function wr(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Qh(e){const t=wr(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Yh(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Bs(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Zh(e,t,n,r){const s=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?Yh(n):wr(n);const l=e.ordered?a==="."?")":".":Qh(n);let c=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Bs(n)===a&&h){let d=-1;for(;++d<e.children.length;){const x=e.children[d];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(a=l),n.bulletCurrent=a;const u=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=o,s(),u}function Jh(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function ep(e,t,n,r){const s=Jh(n);let o=n.bulletCurrent||wr(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let a=o.length+1;(s==="tab"||s==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const l=n.createTracker(r);l.move(o+" ".repeat(a-o.length)),l.shift(a);const c=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,l.current()),h);return c(),u;function h(d,x,p){return x?(p?"":" ".repeat(a))+d:(p?o:o+" ".repeat(a-o.length))+d}}function tp(e,t,n,r){const s=n.enter("paragraph"),o=n.enter("phrasing"),a=n.containerPhrasing(e,r);return o(),s(),a}const np=dn(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function rp(e,t,n,r){return(e.children.some(function(a){return np(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function ip(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ws.peek=sp;function Ws(e,t,n,r){const s=ip(n),o=n.enter("strong"),a=n.createTracker(r);let l=a.move(s+s);return l+=a.move(n.containerPhrasing(e,{before:l,after:s,...a.current()})),l+=a.move(s+s),o(),l}function sp(e,t,n){return n.options.strong||"*"}function ap(e,t,n,r){return n.safe(e.value,r)}function op(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function lp(e,t,n){const r=(Bs(n)+(n.options.ruleSpaces?" ":"")).repeat(op(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Us={blockquote:Ah,break:fi,code:Dh,definition:Fh,emphasis:Ms,hardBreak:fi,heading:Wh,html:Rs,image:Ls,imageReference:Ds,inlineCode:Ps,link:Os,linkReference:$s,list:Zh,listItem:ep,paragraph:tp,root:rp,strong:Ws,text:ap,thematicBreak:lp};function cp(){return{enter:{table:up,tableData:mi,tableHeader:mi,tableRow:hp},exit:{codeText:pp,table:dp,tableData:Rn,tableHeader:Rn,tableRow:Rn}}}function up(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function dp(e){this.exit(e),this.data.inTable=void 0}function hp(e){this.enter({type:"tableRow",children:[]},e)}function Rn(e){this.exit(e)}function mi(e){this.enter({type:"tableCell",children:[]},e)}function pp(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,fp));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function fp(e,t){return t==="|"?t:e}function mp(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,s=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[	 :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:a,tableCell:c,tableRow:l}};function a(p,m,g,w){return u(h(p,g,w),p.align)}function l(p,m,g,w){const y=d(p,g,w),E=u([y]);return E.slice(0,E.indexOf(`
`))}function c(p,m,g,w){const y=g.enter("tableCell"),E=g.enter("phrasing"),C=g.containerPhrasing(p,{...w,before:o,after:o});return E(),y(),C}function u(p,m){return Eh(p,{align:m,alignDelimiters:r,padding:n,stringLength:s})}function h(p,m,g){const w=p.children;let y=-1;const E=[],C=m.enter("table");for(;++y<w.length;)E[y]=d(w[y],m,g);return C(),E}function d(p,m,g){const w=p.children;let y=-1;const E=[],C=m.enter("tableRow");for(;++y<w.length;)E[y]=c(w[y],p,m,g);return C(),E}function x(p,m,g){let w=Us.inlineCode(p,m,g);return g.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function xp(){return{exit:{taskListCheckValueChecked:xi,taskListCheckValueUnchecked:xi,paragraph:bp}}}function gp(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:kp}}}function xi(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function bp(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=t.children;let o=-1,a;for(;++o<s.length;){const l=s[o];if(l.type==="paragraph"){a=l;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function kp(e,t,n,r){const s=e.children[0],o=typeof e.checked=="boolean"&&s&&s.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);o&&l.move(a);let c=Us.listItem(e,t,n,{...r,...l.current()});return o&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(h){return h+a}}function yp(){return[Yd(),bh(),jh(),cp(),xp()]}function wp(e){return{extensions:[Zd(),kh(e),_h(),mp(e),gp()]}}const jp={tokenize:Ep,partial:!0},Hs={tokenize:Ip,partial:!0},qs={tokenize:Ap,partial:!0},Vs={tokenize:Tp,partial:!0},_p={tokenize:zp,partial:!0},Ks={name:"wwwAutolink",tokenize:Cp,previous:Xs},Gs={name:"protocolAutolink",tokenize:Sp,previous:Qs},He={name:"emailAutolink",tokenize:Np,previous:Ys},$e={};function vp(){return{text:$e}}let Qe=48;for(;Qe<123;)$e[Qe]=He,Qe++,Qe===58?Qe=65:Qe===91&&(Qe=97);$e[43]=He;$e[45]=He;$e[46]=He;$e[95]=He;$e[72]=[He,Gs];$e[104]=[He,Gs];$e[87]=[He,Ks];$e[119]=[He,Ks];function Np(e,t,n){const r=this;let s,o;return a;function a(d){return!Zn(d)||!Ys.call(r,r.previous)||jr(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(d))}function l(d){return Zn(d)?(e.consume(d),l):d===64?(e.consume(d),c):n(d)}function c(d){return d===46?e.check(_p,h,u)(d):d===45||d===95||be(d)?(o=!0,e.consume(d),c):h(d)}function u(d){return e.consume(d),s=!0,c}function h(d){return o&&s&&_e(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function Cp(e,t,n){const r=this;return s;function s(a){return a!==87&&a!==119||!Xs.call(r,r.previous)||jr(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(jp,e.attempt(Hs,e.attempt(qs,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function Sp(e,t,n){const r=this;let s="",o=!1;return a;function a(d){return(d===72||d===104)&&Qs.call(r,r.previous)&&!jr(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(d),e.consume(d),l):n(d)}function l(d){if(_e(d)&&s.length<5)return s+=String.fromCodePoint(d),e.consume(d),l;if(d===58){const x=s.toLowerCase();if(x==="http"||x==="https")return e.consume(d),c}return n(d)}function c(d){return d===47?(e.consume(d),o?u:(o=!0,c)):n(d)}function u(d){return d===null||Jt(d)||oe(d)||rt(d)||ln(d)?n(d):e.attempt(Hs,e.attempt(qs,h),n)(d)}function h(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function Ep(e,t,n){let r=0;return s;function s(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),s):a===46&&r===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function Ip(e,t,n){let r,s,o;return a;function a(u){return u===46||u===95?e.check(Vs,c,l)(u):u===null||oe(u)||rt(u)||u!==45&&ln(u)?c(u):(o=!0,e.consume(u),a)}function l(u){return u===95?r=!0:(s=r,r=void 0),e.consume(u),a}function c(u){return s||r||!o?n(u):t(u)}}function Ap(e,t){let n=0,r=0;return s;function s(a){return a===40?(n++,e.consume(a),s):a===41&&r<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(Vs,t,o)(a):a===null||oe(a)||rt(a)?t(a):(e.consume(a),s)}function o(a){return a===41&&r++,e.consume(a),s}}function Tp(e,t,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),r):l===38?(e.consume(l),o):l===93?(e.consume(l),s):l===60||l===null||oe(l)||rt(l)?t(l):n(l)}function s(l){return l===null||l===40||l===91||oe(l)||rt(l)?t(l):r(l)}function o(l){return _e(l)?a(l):n(l)}function a(l){return l===59?(e.consume(l),r):_e(l)?(e.consume(l),a):n(l)}}function zp(e,t,n){return r;function r(o){return e.consume(o),s}function s(o){return be(o)?n(o):t(o)}}function Xs(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||oe(e)}function Qs(e){return!_e(e)}function Ys(e){return!(e===47||Zn(e))}function Zn(e){return e===43||e===45||e===46||e===95||be(e)}function jr(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Mp={tokenize:Bp,partial:!0};function Rp(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Fp,continuation:{tokenize:Op},exit:$p}},text:{91:{name:"gfmFootnoteCall",tokenize:Pp},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Lp,resolveTo:Dp}}}}function Lp(e,t,n){const r=this;let s=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;s--;){const c=r.events[s][1];if(c.type==="labelImage"){a=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return l;function l(c){if(!a||!a._balanced)return n(c);const u=Pe(r.sliceSerialize({start:a.end,end:r.now()}));return u.codePointAt(0)!==94||!o.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function Dp(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},l=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",o,t],["enter",a,t],["exit",a,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...l),e}function Pp(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,a;return l;function l(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),c}function c(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(o>999||d===93&&!a||d===null||d===91||oe(d))return n(d);if(d===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return s.includes(Pe(r.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return oe(d)||(a=!0),o++,e.consume(d),d===92?h:u}function h(d){return d===91||d===92||d===93?(e.consume(d),o++,u):u(d)}}function Fp(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,a=0,l;return c;function c(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(m)}function h(m){if(a>999||m===93&&!l||m===null||m===91||oe(m))return n(m);if(m===93){e.exit("chunkString");const g=e.exit("gfmFootnoteDefinitionLabelString");return o=Pe(r.sliceSerialize(g)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return oe(m)||(l=!0),a++,e.consume(m),m===92?d:h}function d(m){return m===91||m===92||m===93?(e.consume(m),a++,h):h(m)}function x(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),s.includes(o)||s.push(o),ne(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function Op(e,t,n){return e.check(Et,t,e.attempt(Mp,t,n))}function $p(e){e.exit("gfmFootnoteDefinition")}function Bp(e,t,n){const r=this;return ne(e,s,"gfmFootnoteDefinitionIndent",5);function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(o):n(o)}}function Wp(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:s};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function s(a,l){let c=-1;for(;++c<a.length;)if(a[c][0]==="enter"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._close){let u=c;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[c][1].end.offset-a[c][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[c][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[c][1].end)},d={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[c][1].start)},x=[["enter",h,l],["enter",a[u][1],l],["exit",a[u][1],l],["enter",d,l]],p=l.parser.constructs.insideSpan.null;p&&Ae(x,x.length,0,cn(p,a.slice(u+1,c),l)),Ae(x,x.length,0,[["exit",d,l],["enter",a[c][1],l],["exit",a[c][1],l],["exit",h,l]]),Ae(a,u-1,c-u+3,x),c=u+x.length-2;break}}for(c=-1;++c<a.length;)a[c][1].type==="strikethroughSequenceTemporary"&&(a[c][1].type="data");return a}function o(a,l,c){const u=this.previous,h=this.events;let d=0;return x;function x(m){return u===126&&h[h.length-1][1].type!=="characterEscape"?c(m):(a.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const g=en(u);if(m===126)return d>1?c(m):(a.consume(m),d++,p);if(d<2&&!n)return c(m);const w=a.exit("strikethroughSequenceTemporary"),y=en(m);return w._open=!y||y===2&&!!g,w._close=!g||g===2&&!!y,l(m)}}}class Up{constructor(){this.map=[]}add(t,n,r){Hp(this,t,n,r)}consume(t){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let s=r.pop();for(;s;){for(const o of s)t.push(o);s=r.pop()}this.map.length=0}}function Hp(e,t,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([t,n,r])}}function qp(e,t){let n=!1;const r=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Vp(){return{flow:{null:{name:"table",tokenize:Kp,resolveAll:Gp}}}}function Kp(e,t,n){const r=this;let s=0,o=0,a;return l;function l(j){let R=r.events.length-1;for(;R>-1;){const se=r.events[R][1].type;if(se==="lineEnding"||se==="linePrefix")R--;else break}const L=R>-1?r.events[R][1].type:null,ee=L==="tableHead"||L==="tableRow"?v:c;return ee===v&&r.parser.lazy[r.now().line]?n(j):ee(j)}function c(j){return e.enter("tableHead"),e.enter("tableRow"),u(j)}function u(j){return j===124||(a=!0,o+=1),h(j)}function h(j){return j===null?n(j):O(j)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),p):n(j):J(j)?ne(e,h,"whitespace")(j):(o+=1,a&&(a=!1,s+=1),j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),a=!0,h):(e.enter("data"),d(j)))}function d(j){return j===null||j===124||oe(j)?(e.exit("data"),h(j)):(e.consume(j),j===92?x:d)}function x(j){return j===92||j===124?(e.consume(j),d):d(j)}function p(j){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(j):(e.enter("tableDelimiterRow"),a=!1,J(j)?ne(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):m(j))}function m(j){return j===45||j===58?w(j):j===124?(a=!0,e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),g):T(j)}function g(j){return J(j)?ne(e,w,"whitespace")(j):w(j)}function w(j){return j===58?(o+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),y):j===45?(o+=1,y(j)):j===null||O(j)?I(j):T(j)}function y(j){return j===45?(e.enter("tableDelimiterFiller"),E(j)):T(j)}function E(j){return j===45?(e.consume(j),E):j===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),C):(e.exit("tableDelimiterFiller"),C(j))}function C(j){return J(j)?ne(e,I,"whitespace")(j):I(j)}function I(j){return j===124?m(j):j===null||O(j)?!a||s!==o?T(j):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(j)):T(j)}function T(j){return n(j)}function v(j){return e.enter("tableRow"),F(j)}function F(j){return j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),F):j===null||O(j)?(e.exit("tableRow"),t(j)):J(j)?ne(e,F,"whitespace")(j):(e.enter("data"),Q(j))}function Q(j){return j===null||j===124||oe(j)?(e.exit("data"),F(j)):(e.consume(j),j===92?V:Q)}function V(j){return j===92||j===124?(e.consume(j),Q):Q(j)}}function Gp(e,t){let n=-1,r=!0,s=0,o=[0,0,0,0],a=[0,0,0,0],l=!1,c=0,u,h,d;const x=new Up;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(l=!1,c!==0&&(gi(x,t,c,u,h),h=void 0,c=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},x.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,o=[0,0,0,0],a=[0,n+1,0,0],l&&(l=!1,h={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},x.add(n,0,[["enter",h,t]])),s=m.type==="tableDelimiterRow"?2:h?3:1):s&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(o[1]!==0&&(a[0]=a[1],d=Ft(x,t,o,s,void 0,d),o=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(a[0]=a[1],d=Ft(x,t,o,s,void 0,d)),o=a,a=[o[1],n,0,0])):m.type==="tableHead"?(l=!0,c=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(c=n,o[1]!==0?(a[0]=a[1],d=Ft(x,t,o,s,n,d)):a[1]!==0&&(d=Ft(x,t,a,s,n,d)),s=0):s&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(c!==0&&gi(x,t,c,u,h),x.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=qp(t.events,n))}return e}function Ft(e,t,n,r,s,o){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(o.end=Object.assign({},ct(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const c=ct(t.events,n[1]);if(o={type:a,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const u=ct(t.events,n[2]),h=ct(t.events,n[3]),d={type:l,start:Object.assign({},u),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const x=t.events[n[2]],p=t.events[n[3]];if(x[1].end=Object.assign({},p[1].end),x[1].type="chunkText",x[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,g=n[3]-n[2]-1;e.add(m,g,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return s!==void 0&&(o.end=Object.assign({},ct(t.events,s)),e.add(s,0,[["exit",o,t]]),o=void 0),o}function gi(e,t,n,r,s){const o=[],a=ct(t.events,n);s&&(s.end=Object.assign({},a),o.push(["exit",s,t])),r.end=Object.assign({},a),o.push(["exit",r,t]),e.add(n+1,0,o)}function ct(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Xp={name:"tasklistCheck",tokenize:Yp};function Qp(){return{text:{91:Xp}}}function Yp(e,t,n){const r=this;return s;function s(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),o)}function o(c){return oe(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),a):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),a):n(c)}function a(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(c)}function l(c){return O(c)?t(c):J(c)?e.check({tokenize:Zp},t,n)(c):n(c)}}function Zp(e,t,n){return ne(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function Jp(e){return os([vp(),Rp(),Wp(e),Vp(),Qp()])}const ef={};function Zs(e){const t=this,n=e||ef,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(Jp(n)),o.push(yp()),a.push(wp(n))}const Jn=new Set;function bi(e){for(const t of Jn)t(e)}function Ot(){const[e,t]=_.useState(null);return _.useEffect(()=>{let n=null;const r=s=>{t(s),n!=null&&window.clearTimeout(n),n=window.setTimeout(()=>t(null),800)};return Jn.add(r),()=>{Jn.delete(r),n!=null&&window.clearTimeout(n)}},[]),e?i.jsx("output",{className:"pointer-events-none fixed bottom-3 left-1/2 -translate-x-1/2 z-50 flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-ink-1/90 backdrop-blur text-bg-app font-mono text-sm shadow-modal","aria-live":"polite",children:e.split("+").map((n,r,s)=>i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded-md bg-bg-app/15 border border-bg-app/30 text-bg-app",style:{fontSize:"11px",lineHeight:1.1},children:n}),r<s.length-1&&i.jsx("span",{className:"text-bg-app/60",children:"+"})]},`${r}-${n}`))}):null}function tf(e){if(e>=1e6){const t=e/1e6;return`${Number.isInteger(t)?t:t.toFixed(1)}M`}return e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function ki(e){return e.label||`${e.kind} · ${e.model}`}function nf({providers:e,activeProviderId:t,onSelect:n}){const[r,s]=_.useState(!1),[o,a]=_.useState(0),l=_.useRef(null),c=_.useRef([]),u=_.useMemo(()=>[...e].sort((m,g)=>_r.indexOf(m.kind)-_r.indexOf(g.kind)),[e]),h=e.find(m=>m.id===t);_.useEffect(()=>{if(!r)return;const m=u.findIndex(g=>g.id===t);a(m>=0?m:0)},[r,u,t]),_.useEffect(()=>{var m;r&&((m=c.current[o])==null||m.scrollIntoView({block:"nearest"}))},[r,o]);function d(m){n(m),s(!1)}function x(m){if(!r){(m.key==="Enter"||m.key===" "||m.key==="ArrowUp"||m.key==="ArrowDown")&&(m.preventDefault(),s(!0));return}if(m.key==="Escape")m.preventDefault(),s(!1);else if(m.key==="ArrowDown")m.preventDefault(),a(g=>Math.min(g+1,u.length-1));else if(m.key==="ArrowUp")m.preventDefault(),a(g=>Math.max(g-1,0));else if(m.key==="Enter"){m.preventDefault();const g=u[o];g&&d(g.id)}}if(e.length===0)return null;let p="";return i.jsxs("div",{ref:l,className:"relative",onKeyDown:x,children:[i.jsxs("button",{type:"button",onClick:()=>s(m=>!m),title:f("chat_switch_model"),"aria-haspopup":"listbox","aria-expanded":r,className:"inline-flex items-center gap-1 font-mono text-xs text-ink-2 hover:text-ink-1 max-w-[180px] cursor-pointer",children:[i.jsx("span",{className:"w-2 h-2 rounded-sm bg-modeA shrink-0","aria-hidden":"true"}),i.jsx("span",{className:"truncate",children:h?ki(h):f("chat_switch_model")})]}),r&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button","aria-label":f("chat_switch_model"),className:"fixed inset-0 z-40 cursor-default",onClick:()=>s(!1)}),i.jsx("div",{role:"listbox",tabIndex:-1,className:"absolute left-0 bottom-full mb-1 z-50 w-72 max-h-80 overflow-y-auto rounded-lg border border-line bg-bg-app shadow-[0_14px_36px_-10px_rgba(40,40,30,0.28)] py-1",children:u.map((m,g)=>{const w=m.kind!==p;p=m.kind;const y=m.id===t,E=g===o,C=Ia(m.model,m.kind),I=Di(m.model,m.kind),T=tf(Sa(m.model,m.contextWindowTokens));return i.jsxs("div",{children:[w&&i.jsx("div",{className:"px-3 pt-1.5 pb-0.5 text-[10px] font-medium uppercase tracking-wide text-ink-4",children:pa[m.kind]}),i.jsxs("button",{ref:v=>{c.current[g]=v},type:"button",role:"option","aria-selected":y,onClick:()=>d(m.id),onMouseEnter:()=>a(g),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left ${E?"bg-bg-soft":""}`,children:[i.jsx(We,{size:13,strokeWidth:2.5,className:`shrink-0 ${y?"text-modeA":"text-transparent"}`}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-xs text-ink-1 truncate",children:ki(m)}),m.label&&i.jsx("div",{className:"font-mono text-[10px] text-ink-4 truncate",children:m.model})]}),i.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 text-ink-4",children:[C&&i.jsx(Mi,{size:12,strokeWidth:2,"aria-label":"vision"}),I&&i.jsx(tr,{size:12,strokeWidth:2,"aria-label":"thinking"}),i.jsx("span",{className:"font-mono text-[10px] tabular-nums",children:T})]})]})]},m.id)})})]})]})}const rf=5*1024*1024;function sf({sessionKey:e,messages:t,contextStats:n,displayCurrency:r,providers:s,activeProviderId:o,onSelectModel:a,onPickElement:l,onSend:c,onAbort:u,busy:h,stopping:d,onResumeMacro:x,onCreateMacro:p,onDismissMessage:m,onResolvePatch:g,onAnswerAsk:w,headless:y,onToggleHeadless:E,onToggleThinking:C}){const[I,T]=_.useState(""),[v,F]=_.useState([]),[Q,V]=_.useState([]),[j,R]=_.useState(!1),L=_.useRef(null),ee=_.useRef(null),se=_.useRef(!0),K=_.useRef(!1),ae=_.useRef(null),ue=_.useCallback(()=>{K.current=!0,ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{K.current=!1},150)},[]);_.useEffect(()=>()=>{ae.current&&clearTimeout(ae.current)},[]);const ye=_.useCallback(()=>{if(!K.current)return;const M=L.current;M&&(se.current=M.scrollHeight-M.scrollTop-M.clientHeight<80)},[]);_.useEffect(()=>{se.current=!0;const M=L.current;M&&(M.scrollTop=M.scrollHeight)},[e]),_.useEffect(()=>{const M=L.current;!M||!se.current||(M.scrollTop=M.scrollHeight)},[t]);const fe=_.useCallback(()=>{let M=I.trim();if(!M&&v.length===0&&Q.length===0)return;const H=Q.filter(W=>W.screenshotDataUrl).map((W,Y)=>({dataUrl:W.screenshotDataUrl,mediaType:"image/jpeg",name:`picked-${Y+1}.jpg`,size:0}));if(Q.length>0){const W=Q.map(Y=>`- ${Y.label} → \`${Y.selector}\``).join(`
`);M=`${M}

[Pointing at these page elements (picked by hand because you couldn't reach them on your own):
${W}
The moment one of these actually works, write_element_cache it for this page so a future run lands automatically and never needs another manual pick.]`.trim()}const U=[...v,...H];c(M,U.length>0?U:void 0),T(""),F([]),V([])},[I,v,Q,c]);async function b(M){if(!M||M.length===0)return;const H=[];for(const U of M){if(!U.type.startsWith("image/")||U.size>rf&&!confirm(f("chat_image_size_warning",U.name)))continue;const W=await new Promise((Y,ve)=>{const G=new FileReader;G.onload=()=>Y(String(G.result??"")),G.onerror=()=>ve(G.error),G.readAsDataURL(U)});H.push({dataUrl:W,mediaType:U.type,name:U.name,size:U.size})}H.length>0&&F(U=>[...U,...H]),ee.current&&(ee.current.value="")}async function de(){if(!(!l||j)){R(!0);try{const M=await l();M&&V(H=>[...H,M])}finally{R(!1)}}}function we(M){V(H=>H.filter((U,W)=>W!==M))}function k(M){F(H=>H.filter((U,W)=>W!==M))}return i.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[i.jsxs("div",{ref:L,onScroll:ye,onWheel:ue,onTouchStart:ue,className:"flex-1 overflow-y-auto px-4 py-5 space-y-4",children:[t.length===0&&i.jsx("div",{className:"text-sm text-ink-3 italic",children:"Tell yank what you want done in this tab. It'll do it once and save a macro so the next run is free."}),(()=>{const M=new Map;for(const W of t){const Y=W.role==="tool-call"||W.role==="macro-notify"||W.role==="macro-wait-user"||W.role==="macro-ask"?W.runId:void 0;if(!Y)continue;const ve=M.get(Y)??[];ve.push(W),M.set(Y,ve)}const H=new Set;for(const W of M.values())for(const Y of W)H.add(Y.id);const U=W=>i.jsx(af,{message:W,displayCurrency:r??"USD",onResumeMacro:x,onCreateMacro:p,onDismissMessage:m,onResolvePatch:g,onAnswerAsk:w},W.id);return t.map(W=>W.role==="macro-run"?i.jsx(Js,{run:W,children:(M.get(W.runId)??[]).map(U)},W.id):H.has(W.id)?null:U(W))})(),h&&!d&&i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-ink-3",children:[i.jsxs("span",{className:"flex items-center gap-0.5",children:[i.jsx("span",{className:"w-1 h-1 rounded-full bg-ink-3 animate-bounce",style:{animationDelay:"-0.3s"}}),i.jsx("span",{className:"w-1 h-1 rounded-full bg-ink-3 animate-bounce",style:{animationDelay:"-0.15s"}}),i.jsx("span",{className:"w-1 h-1 rounded-full bg-ink-3 animate-bounce"})]}),i.jsx("span",{children:f("chat_typing")})]})]}),i.jsxs("div",{className:"px-4 py-3 border-t border-line",children:[n&&i.jsx(bf,{stats:n}),v.length>0&&i.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:v.map((M,H)=>i.jsxs("div",{className:"relative rounded-md border border-line bg-bg-app overflow-hidden",children:[i.jsx(gt,{src:M.dataUrl,alt:M.name,className:"h-16 w-16 object-cover"}),i.jsx("button",{type:"button",onClick:()=>k(H),className:"absolute top-0.5 right-0.5 h-5 w-5 flex items-center justify-center rounded-full bg-bg/80 text-ink-2 hover:text-err","aria-label":"Remove",children:i.jsx(Fe,{size:10,strokeWidth:2})})]},`${M.name}-${H}`))}),Q.length>0&&i.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:Q.map((M,H)=>i.jsxs("div",{title:M.selector,className:"relative flex items-center gap-1.5 rounded-md border border-modeA/40 bg-modeA-bg py-1 pl-1 pr-5 max-w-[180px]",children:[M.screenshotDataUrl?i.jsx("img",{src:M.screenshotDataUrl,alt:"",className:"h-6 w-6 rounded object-cover shrink-0"}):i.jsx(vt,{size:12,strokeWidth:2,className:"text-modeA shrink-0"}),i.jsx("span",{className:"text-xs font-mono text-modeA truncate",children:M.label}),i.jsx("button",{type:"button",onClick:()=>we(H),className:"absolute top-0.5 right-0.5 h-4 w-4 flex items-center justify-center rounded-full text-modeA hover:text-err","aria-label":"Remove",children:i.jsx(Fe,{size:10,strokeWidth:2})})]},`${M.selector}-${H}`))}),i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsx("input",{ref:ee,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:M=>void b(M.target.files)}),i.jsx("button",{type:"button",onClick:()=>{var M;return(M=ee.current)==null?void 0:M.click()},disabled:h,"aria-label":f("chat_attach_image"),title:f("chat_attach_image"),className:"h-10 w-10 flex items-center justify-center rounded-lg border border-line hover:border-line text-ink-3 hover:text-ink-1 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:i.jsx(Za,{size:16,strokeWidth:1.5})}),l&&i.jsx("button",{type:"button","data-tour":"picker",onClick:()=>void de(),disabled:h||j,"aria-label":f("chat_pick_element"),title:f("chat_pick_element"),className:`h-10 w-10 flex items-center justify-center rounded-lg border transition-colors disabled:opacity-30 disabled:cursor-not-allowed ${j?"border-modeA text-modeA bg-modeA-bg":"border-line hover:border-line text-ink-3 hover:text-ink-1"}`,children:i.jsx(vt,{size:16,strokeWidth:1.5})}),i.jsx("textarea",{"data-tour":"composer",value:I,onChange:M=>T(M.target.value),onKeyDown:M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),fe())},onPaste:M=>{var U;const H=(U=M.clipboardData)==null?void 0:U.files;H!=null&&H.length&&[...H].some(W=>W.type.startsWith("image/"))&&(M.preventDefault(),b(H))},placeholder:h?f("chat_composer_placeholder_busy"):f("chat_composer_placeholder"),rows:2,className:"flex-1 resize-none bg-bg-app border border-line rounded-lg px-3 py-2 text-base text-ink-1 placeholder:text-ink-4 caret-accent outline-none focus:border-brand-2"}),h&&i.jsx("button",{type:"button",onClick:u,disabled:d,className:`h-10 w-10 flex items-center justify-center rounded-lg border border-line text-ink-2 transition-colors ${d?"opacity-50 cursor-wait":"hover:border-modeB hover:text-modeB"}`,"aria-label":d?f("chat_stopping_aria"):f("chat_stop_aria"),title:d?f("chat_stopping_aria"):void 0,children:i.jsx(ao,{size:14,strokeWidth:2,fill:"currentColor",className:d?"animate-pulse":void 0})}),i.jsx("button",{type:"button",onClick:fe,disabled:!I.trim()&&v.length===0&&Q.length===0,className:"h-10 w-10 flex items-center justify-center rounded-lg bg-brand hover:bg-brand-2 text-brand-ink disabled:opacity-30 disabled:cursor-not-allowed transition-colors","aria-label":h?f("chat_send_interject_aria"):f("chat_send_aria"),title:h?f("chat_send_interject_aria"):void 0,children:i.jsx(io,{size:16,strokeWidth:2})})]}),i.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-ink-4",children:[i.jsx(nf,{providers:s,activeProviderId:o,onSelect:a}),(()=>{const M=s.find(U=>U.id===o);if(!C||!M||!Di(M.model,M.kind))return null;const H=M.thinking??!0;return i.jsxs("button",{type:"button",onClick:()=>C(!H),title:f("chat_thinking_hint"),"aria-pressed":H,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors ${H?"text-modeA":"text-ink-4 hover:text-ink-2"}`,children:[i.jsx(tr,{size:12,strokeWidth:2}),f("chat_thinking_label")]})})(),E&&i.jsxs("button",{type:"button",onClick:()=>E(!y),title:f("chat_headless_hint"),"aria-pressed":y,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors ${y?"text-modeA":"text-ink-4 hover:text-ink-2"}`,children:[i.jsx(ba,{size:12,strokeWidth:2}),y?f("chat_headless_toggle_on"):f("chat_headless_toggle_off")]}),i.jsx("span",{className:"flex-1"}),i.jsx("span",{children:f("chat_help_text")})]})]})]})}const af=_.memo(function({message:t,displayCurrency:n,onResumeMacro:r,onCreateMacro:s,onDismissMessage:o,onResolvePatch:a,onAnswerAsk:l}){var u,h;const c=fa();if(t.role==="user")return i.jsxs("div",{className:"space-y-1",children:[i.jsx("div",{className:"text-xs text-ink-3 uppercase tracking-wider",children:f("chat_role_you")}),t.text&&i.jsx("div",{className:"text-base whitespace-pre-wrap",children:t.text}),t.images&&t.images.length>0&&i.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:t.images.map((d,x)=>i.jsx(gt,{src:d.dataUrl,alt:d.name,className:"max-h-40 rounded-md border border-line"},`${d.name}-${x}`))})]});if(t.role==="assistant")return i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"text-xs text-ink-3 uppercase tracking-wider",children:["yank",t.streaming&&i.jsx("span",{className:"ml-1 animate-pulse",children:"·"})]}),i.jsx("div",{className:"markdown-body text-base text-ink-1",children:t.text?t.streaming?i.jsx(pf,{text:t.text}):i.jsx(Es,{remarkPlugins:[Zs],components:ea,children:t.text}):i.jsx("span",{className:"text-ink-3",children:"…"})}),t.text&&!t.streaming&&i.jsx("div",{className:"text-[10px] text-ink-4 select-none",children:f("chat_ai_generated_disclaimer")})]});if(t.role==="thinking")return i.jsx(ff,{text:t.text,streaming:t.streaming});if(t.role==="system")return i.jsx("div",{className:"text-xs text-ink-3 italic px-2",children:t.text});if(t.role==="tool-call"){const d=t.tool==="screenshot"&&t.status==="success"?(u=t.data)==null?void 0:u.screenshotBase64:void 0,x=((h=t.data)==null?void 0:h.format)==="png"?"png":"jpeg",p=jf(t.input),m=wf(t.tool),g=za(t.tool),w=t.status==="failed"?"is-fail":"",y=t.status==="running"?"is-active":t.status==="success"?"is-done":"",E=g?Oi(t.tool):null,C=E?c.get(E.server)??E.server:"";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`yk-tc ${g?"is-mcp":""} ${y} ${g?w:""}`,children:[i.jsxs("div",{className:"yk-tc-head",children:[E?i.jsx("span",{className:"yk-tc-ico",children:i.jsx(Ri,{size:12,strokeWidth:1.6})}):i.jsx("span",{className:"yk-tc-ico",style:{background:m.bg,color:m.fg,borderColor:m.border},children:m.glyph}),i.jsxs("span",{className:"font-mono text-xs font-semibold text-ink-1 truncate flex items-center gap-1.5",children:[E?i.jsxs("span",{className:"inline-flex items-center gap-1.5 text-mcp-ink font-bold",children:[i.jsx(ma,{label:C}),C,i.jsx("span",{className:"text-mcp font-normal",children:"·"}),i.jsx("span",{className:"text-ink-1 font-semibold",children:E.tool})]}):Pi(t.tool),t.status==="running"&&i.jsx("span",{className:`inline-block w-3 h-3 rounded-full border-[1.5px] border-bg-inset animate-yk-spin ${g?"border-t-mcp-2":"border-t-brand-2"}`}),p[0]&&i.jsx("span",{className:"font-normal text-ink-3 truncate max-w-[180px]",children:p[0].value})]}),i.jsxs("span",{className:"font-mono text-xs text-ink-3 flex items-center gap-1",children:[g&&i.jsx("span",{className:"yk-mcp-badge",children:"MCP"}),t.status==="success"&&i.jsx(We,{size:10,strokeWidth:2.5,className:"text-ok"}),t.status==="failed"&&i.jsx(Fe,{size:10,strokeWidth:2.5,className:"text-err"})]})]}),(p.length>1||t.status==="failed"&&t.error||d)&&i.jsxs("div",{className:"px-2.5 py-2 font-mono text-xs text-ink-2 space-y-1",children:[p.slice(1).map(I=>i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-ink-4 shrink-0 w-14",children:I.key}),i.jsx("span",{className:"text-ink-2 break-all",children:I.value})]},I.key)),t.status==="failed"&&t.error&&i.jsx("div",{className:"text-err",children:t.error}),d&&i.jsx(gt,{src:`data:image/${x};base64,${d}`,alt:"screenshot taken by AI",className:"mt-1.5 rounded border border-line"})]})]}),g&&t.status==="failed"&&i.jsx(yf,{error:t.error})]})}if(t.role==="macro-card")return i.jsxs("div",{className:"rounded-xl border border-brand-2/40 bg-brand/5 px-4 py-3 space-y-2",children:[i.jsxs("div",{className:"text-xs text-brand-ink uppercase tracking-wider flex items-center gap-1",children:[i.jsx(an,{size:12,strokeWidth:2}),f("chat_macro_saved")]}),i.jsx("div",{className:"text-md font-medium",children:t.macroName}),i.jsx("div",{className:"text-xs text-ink-3",children:f("chat_macro_saved_meta",String(t.stepCount))})]});if(t.role==="macro-patch-proposal")return i.jsx(xf,{message:t,onResolvePatch:a});if(t.role==="compression"){const d=t.status==="running",x=t.mode==="blocking",p=x&&d?"border-warn/50 bg-warn-bg text-warn":"border-line bg-bg-app/40 text-ink-3",m=d?x?f("chat_compress_running_blocking"):f("chat_compress_running_bg"):x?f("chat_compress_done_blocking",[String(t.compressedCount??0),wt(t.savedTokens??0)]):f("chat_compress_done_bg",wt(t.savedTokens??0));return i.jsx("div",{className:`rounded-md border px-3 py-1.5 text-xs font-mono ${p}`,children:m})}return t.role==="cost-summary"?i.jsxs("div",{className:"rounded-lg border border-line bg-bg-app/40 px-3 py-2 text-xs text-ink-3 flex flex-wrap items-center justify-between gap-2 font-mono",children:[i.jsxs("span",{children:[f("chat_cost_total"),":"," ",i.jsx("span",{className:"text-ink-1",children:vr(t.totalUsd??0,n)})]}),t.cacheSavedUsd>0&&i.jsx("span",{className:"text-brand-ink",children:f("chat_cost_saved",vr(t.cacheSavedUsd,n))}),i.jsx("span",{className:"text-ink-3 text-[10px]",children:(()=>{const d=mf(t.cacheReadTokens,t.inputTokens,t.cacheCreationTokens);return`${d===null?"—":`${d.toFixed(1)}% cache hit`} · ${wt(t.outputTokens)} out`})()})]}):t.role==="macro-run"?i.jsx(Js,{run:t}):t.role==="macro-notify"?i.jsxs("div",{className:"rounded-lg border border-sky-500/30 bg-sky-500/[0.06] px-3 py-2.5 space-y-2",children:[i.jsxs("div",{className:"text-xs text-sky-300/90 uppercase tracking-wider flex items-center gap-1.5",children:[i.jsx(Ua,{size:11,strokeWidth:2}),f("chat_macro_notify")]}),t.message&&i.jsx("div",{className:"text-sm text-ink-1 whitespace-pre-wrap",children:t.message}),t.screenshotBase64&&i.jsx(gt,{src:`data:image/jpeg;base64,${t.screenshotBase64}`,alt:"screenshot",className:"rounded-md border border-line w-full max-h-[480px] object-contain"})]}):t.role==="suggestions"?i.jsx(of,{message:t,onCreateMacro:s,onDismissMessage:o}):t.role==="macro-wait-user"?i.jsxs("div",{className:"rounded-lg border border-warn/40 bg-warn-bg/40 px-3 py-2.5 space-y-2.5",children:[i.jsxs("div",{className:"text-xs text-warn uppercase tracking-wider flex items-center gap-1.5",children:[i.jsx(vt,{size:11,strokeWidth:2}),f("chat_macro_wait_user")]}),t.reason&&i.jsx("div",{className:"text-sm text-ink-1 whitespace-pre-wrap",children:t.reason}),t.screenshotBase64&&i.jsx(gt,{src:`data:image/png;base64,${t.screenshotBase64}`,alt:"screenshot"}),t.resumed?i.jsxs("div",{className:"text-xs text-ink-3 italic flex items-center gap-1",children:[i.jsx(We,{size:12,strokeWidth:2,className:"text-brand-ink"}),f("chat_macro_resumed")]}):i.jsx("button",{type:"button",onClick:()=>r==null?void 0:r(t.resumeId),className:"px-3 py-1.5 rounded-md bg-warn hover:bg-warn text-brand-ink text-sm font-medium transition-colors",children:f("chat_macro_resume")})]}):t.role==="macro-ask"?i.jsx(cf,{message:t,onAnswer:l}):null});function of({message:e,onCreateMacro:t,onDismissMessage:n}){const[r,s]=_.useState(!1),[o,a]=_.useState(""),l=_.useRef(null);_.useEffect(()=>{var u;r&&((u=l.current)==null||u.focus())},[r]);const c=u=>{t==null||t(e.id,u!=null&&u.trim()?lf(u):void 0)};return i.jsxs("div",{className:"rounded-xl border border-dashed border-brand-2/60 bg-brand-bg px-3.5 py-3",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-md font-semibold text-brand-ink",children:[i.jsx(Ue,{size:13,strokeWidth:1.5}),f("chat_save_prompt")]}),i.jsxs("div",{className:"text-sm text-brand-ink/80 mt-1 leading-relaxed",children:[f("chat_next_pre")," ",i.jsx("strong",{className:"text-brand-ink",children:f("chat_next_again")})," ",f("chat_next_or")," ",i.jsx("span",{className:"yk-chip yk-chip-brand px-1.5 py-0",children:"/run …"})," ",f("chat_next_post"),i.jsx("br",{}),i.jsx("strong",{className:"text-modeC",children:f("ob_sub_strong")})]}),r&&i.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[i.jsx("span",{className:"font-mono text-md text-brand-ink/70",children:"/"}),i.jsx("input",{ref:l,type:"text",value:o,onChange:u=>a(u.target.value),onKeyDown:u=>{u.key==="Enter"?(u.preventDefault(),o.trim()&&c(o)):u.key==="Escape"&&s(!1)},placeholder:"my-macro-name",className:"flex-1 px-2.5 py-1.5 rounded-md border border-brand-2 bg-white text-md text-brand-ink font-mono outline-none shadow-ring-brand"}),i.jsx("span",{className:"yk-kbd",children:"↵"})]}),i.jsx("div",{className:"flex items-center gap-1.5 mt-2.5 flex-wrap",children:r?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:()=>c(o),disabled:!o.trim(),className:"yk-btn yk-btn-primary is-sm disabled:opacity-50",children:[i.jsx(We,{size:11,strokeWidth:2.5}),f("chat_save_with_name")]}),i.jsx("button",{type:"button",onClick:()=>s(!1),className:"yk-btn yk-btn-ghost is-sm",children:f("chat_cancel")})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:()=>c(),className:"yk-btn yk-btn-primary is-sm",children:[i.jsx(We,{size:11,strokeWidth:2.5}),f("chat_save_as_macro")]}),i.jsx("button",{type:"button",onClick:()=>s(!0),className:"yk-btn is-sm",children:f("chat_rename_params")}),i.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(e.id),className:"yk-btn yk-btn-ghost is-sm",children:f("chat_dismiss")})]})})]})}function lf(e){return e.toLowerCase().trim().replace(/[^a-z0-9_-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function cf({message:e,onAnswer:t}){const[n,r]=_.useState(e.defaultValue??""),s=_.useRef(null);if(_.useEffect(()=>{var a;e.answered||(a=s.current)==null||a.focus()},[e.answered]),e.answered)return i.jsxs("div",{className:"rounded-lg border border-modeA/30 bg-modeA-bg/40 px-3 py-1.5 text-sm flex items-center gap-2",children:[i.jsx(We,{size:12,strokeWidth:2.5,className:"text-modeA"}),i.jsx("span",{className:"font-mono text-modeA",children:"ask"}),i.jsx("span",{className:"font-mono text-ink-3",children:e.varName}),i.jsx("span",{className:"text-ink-4",children:"="}),i.jsx("span",{className:"font-mono text-ink-1 truncate",children:e.answer||"(empty)"})]});const o=()=>t==null?void 0:t(e.askId,e.varName,n);if(e.varName==="__grant_bookmarks__"){const a=()=>{uo({permissions:["bookmarks"]}).then(c=>t==null?void 0:t(e.askId,e.varName,c?"yes":"no"))},l=()=>t==null?void 0:t(e.askId,e.varName,"no");return i.jsxs("div",{className:"rounded-xl border-2 border-modeA shadow-ring-modeA bg-bg-app overflow-hidden",children:[i.jsxs("div",{className:"px-3 py-1.5 bg-modeA-bg border-b border-modeA/30 flex items-center gap-2 font-mono text-xs text-modeA",children:[i.jsx("span",{className:"font-bold",children:f("chat_permission")}),i.jsx("span",{className:"flex-1"}),i.jsx("span",{className:"text-ink-3",children:f("chat_paused_grant")})]}),i.jsxs("div",{className:"px-3.5 pt-3 pb-3",children:[i.jsx("div",{className:"text-md font-semibold text-ink-1 mb-2",children:e.question}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:a,className:"yk-btn yk-btn-primary",children:f("chat_grant_bookmarks")}),i.jsx("button",{type:"button",onClick:l,className:"yk-btn",children:f("chat_deny")})]})]})]})}return i.jsxs("div",{className:"rounded-xl border-2 border-modeA shadow-ring-modeA bg-bg-app overflow-hidden",children:[i.jsxs("div",{className:"px-3 py-1.5 bg-modeA-bg border-b border-modeA/30 flex items-center gap-2 font-mono text-xs text-modeA",children:[i.jsx("span",{className:"font-bold",children:"ask"}),i.jsx("span",{className:"text-ink-2",children:"name="}),i.jsxs("span",{className:"text-ink-1",children:['"',e.varName,'"']}),i.jsx("span",{className:"flex-1"}),i.jsx("span",{className:"text-ink-3",children:f("chat_paused_ask")})]}),i.jsxs("div",{className:"px-3.5 pt-3 pb-3",children:[i.jsx("div",{className:"text-md font-semibold text-ink-1 mb-2",children:e.question}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{ref:s,type:"text",value:n,onChange:a=>r(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),o())},placeholder:e.defaultValue||"",className:"flex-1 px-3 py-2 rounded-lg border border-modeA bg-white text-md text-ink-1 font-mono outline-none shadow-ring-modeA"}),i.jsxs("button",{type:"button",onClick:o,className:"yk-btn yk-btn-primary",children:[f("chat_continue")," ",i.jsx("span",{className:"yk-kbd bg-white/40",children:"↵"})]})]})]})]})}function Js({run:e,children:t}){const n=e.status==="success",r=uf(t);return n?i.jsxs("div",{className:"rounded-xl border px-4 py-3 space-y-3",style:{borderColor:"#d8e8a8",background:"#f7faea"},children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"yk-zero-badge text-xs",children:[i.jsx("span",{className:"text-2xl leading-none tracking-tight",children:"0"}),i.jsxs("span",{className:"text-xs uppercase opacity-80 leading-tight",children:["LLM",i.jsx("br",{}),"calls"]})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"text-md font-semibold text-brand-ink truncate",children:["/run ",i.jsx("span",{className:"font-mono",children:e.macroName})]}),i.jsxs("div",{className:"text-sm text-modeC mt-0.5 font-mono",children:[e.durationMs!==void 0?kf(e.durationMs):""," ·"," ",f("chat_zero_replay")]})]})]}),r.length>0&&i.jsx("div",{className:"space-y-2 pt-1",children:r})]}):e.status==="failed"?i.jsxs("div",{className:"rounded-xl border overflow-hidden",style:{borderColor:"#e7d2ab",background:"#fbeada"},children:[i.jsxs("div",{className:"flex items-center gap-3 px-3.5 py-3 border-b border-warn/30",children:[i.jsxs("div",{className:"w-[54px] h-[54px] rounded-xl bg-warn-bg border border-warn/40 text-warn flex flex-col items-center justify-center font-mono font-bold relative flex-none","aria-label":"self-heal pending",children:[i.jsx("span",{className:"absolute top-1.5 right-1.5 w-2.5 h-2.5 rounded-full bg-warn animate-yk-pulse","aria-hidden":"true"}),i.jsx("span",{className:"text-lg leading-none",children:"!"}),i.jsx("span",{className:"text-xs tracking-widest mt-0.5",children:"HEAL"})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"text-md font-semibold truncate",style:{color:"#7d4d18"},title:e.macroName,children:["/run ",i.jsx("span",{className:"font-mono",children:e.macroName})," · ",f("chat_run_broke")]}),i.jsx("div",{className:"text-sm mt-0.5",style:{color:"#7d4d18"},children:e.healState==="started"?f("chat_ai_inspecting"):e.healState==="proposed"?f("chat_heal_proposed"):e.healState==="failed"?f("chat_heal_failed"):e.healState==="quota"?f("chat_heal_quota",`${e.healsUsed??0}/${e.healLimit??0}`):f("chat_run_failed_plain")}),e.healState==="started"&&i.jsxs("div",{className:"mt-1.5 h-1 rounded-full overflow-hidden relative bg-black/5","aria-hidden":"true",children:[i.jsx("div",{className:"absolute inset-y-0 left-0 w-[70%] bg-warn"}),i.jsx("div",{className:"absolute inset-y-0 left-[68%] w-[8%] animate-yk-sheen",style:{background:"linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent)"}})]}),e.healState==="quota"&&i.jsx("button",{type:"button",onClick:()=>void tt(),className:"mt-1 font-semibold text-brand-ink hover:underline text-sm",children:f("chat_run_upgrade_cta")})]})]}),r.length>0&&i.jsx("div",{className:"px-3.5 py-2.5 space-y-2",children:r}),e.failedStepSource&&i.jsxs("div",{className:"px-3.5 py-2 border-t border-warn/30 text-xs font-mono text-err bg-err-bg/40 overflow-x-auto",children:[i.jsx("span",{className:"font-semibold uppercase tracking-wider mr-2",children:"FAILED"}),"`",e.failedStepSource,"`"]}),e.failedReason&&i.jsxs("div",{className:"px-3.5 py-2 text-sm text-err border-t border-warn/30 bg-err-bg/40",children:[e.failedReason,e.failedProGate&&i.jsx("button",{type:"button",onClick:()=>void tt(),className:"block mt-1.5 font-semibold text-brand-ink hover:underline",children:f("chat_run_upgrade_cta")})]}),e.healState==="failed"&&e.healError&&i.jsxs("div",{className:"px-3.5 py-2 text-xs text-ink-2 border-t border-warn/30",children:[f("chat_heal_failed")," — ",e.healError]})]}):i.jsxs("div",{className:"rounded-xl border border-line bg-bg-app px-4 py-3 space-y-2",children:[i.jsxs("div",{className:"text-xs text-ink-3 uppercase tracking-wider flex items-center gap-1.5",children:[i.jsx(an,{size:12,strokeWidth:2,className:"animate-pulse text-brand-ink"}),i.jsx("span",{children:f("chat_macro_running")})]}),i.jsx("div",{className:"text-md font-medium text-ink-1",children:e.macroName}),r.length>0&&i.jsx("div",{className:"space-y-2 pt-1",children:r})]})}function uf(e){var o;const t=[];let n,r=0;const s=Array.isArray(e)?e:e==null?[]:[e];for(const a of s){if(a&&typeof a=="object"&&"props"in a&&((o=a.props)!=null&&o.message)){const l=a.props.message,c=l.role==="tool-call"||l.role==="macro-notify"||l.role==="macro-wait-user"?l.description:void 0;c&&c!==n&&(t.push(i.jsx("div",{className:"text-[10px] uppercase tracking-wider text-ink-3 font-medium pt-1 pb-0.5 border-l-2 border-line pl-2",children:c},`desc-${r++}`)),n=c)}t.push(a)}return t}const df=150;function hf(e){const t=e.match(/^[ \t]*(```|~~~)/gm);return t&&t.length%2===1?`${e}
\`\`\``:e}function pf({text:e}){const[t,n]=_.useState(e),r=_.useRef(e);return r.current=e,_.useEffect(()=>{const s=setInterval(()=>{n(o=>o===r.current?o:r.current)},df);return()=>clearInterval(s)},[]),_.useMemo(()=>i.jsx(Es,{remarkPlugins:[Zs],components:ea,children:hf(t)}),[t])}const ea={a:({href:e,children:t})=>i.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-ink hover:underline break-all",children:t}),code:({className:e,children:t,...n})=>/language-/.test(e??"")||String(t).includes(`
`)?i.jsx("code",{className:`${e??""} text-xs font-mono text-ink-2`,...n,children:t}):i.jsx("code",{className:"px-1 py-0.5 rounded bg-bg-soft text-brand-ink text-[12.5px] font-mono",children:t}),pre:({children:e})=>i.jsx("pre",{className:"rounded-md bg-bg-app border border-line p-3 overflow-x-auto text-xs font-mono text-ink-2 my-2",children:e}),ul:({children:e})=>i.jsx("ul",{className:"list-disc pl-5 space-y-0.5 my-1.5",children:e}),ol:({children:e})=>i.jsx("ol",{className:"list-decimal pl-5 space-y-0.5 my-1.5",children:e}),p:({children:e})=>i.jsx("p",{className:"my-1.5 leading-relaxed",children:e}),h1:({children:e})=>i.jsx("h1",{className:"text-base font-semibold my-2.5",children:e}),h2:({children:e})=>i.jsx("h2",{className:"text-base font-semibold my-2",children:e}),h3:({children:e})=>i.jsx("h3",{className:"text-sm font-semibold my-1.5",children:e}),strong:({children:e})=>i.jsx("strong",{className:"font-semibold text-ink-1",children:e}),em:({children:e})=>i.jsx("em",{className:"italic text-ink-1",children:e}),blockquote:({children:e})=>i.jsx("blockquote",{className:"border-l-2 border-line pl-3 italic text-ink-3 my-2",children:e}),hr:()=>i.jsx("hr",{className:"my-3 border-line"}),table:({children:e})=>i.jsx("div",{className:"my-2 overflow-x-auto",children:i.jsx("table",{className:"text-sm border-collapse",children:e})}),th:({children:e})=>i.jsx("th",{className:"border border-line px-2 py-1 bg-bg-app text-left font-semibold",children:e}),td:({children:e})=>i.jsx("td",{className:"border border-line px-2 py-1",children:e})};function ff({text:e,streaming:t}){const[n,r]=_.useState(!0),s=_.useRef(t??!1);_.useEffect(()=>{s.current&&!t&&r(!1),s.current=t??!1},[t]);const o=e?e.split(`
`).filter(a=>a.trim().length>0).length:0;return i.jsxs("div",{className:"rounded-lg border border-line bg-bg-app/50",children:[i.jsxs("button",{type:"button",onClick:()=>r(!n),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-ink-3 hover:text-ink-1 transition-colors",children:[n?i.jsx(rn,{size:12,strokeWidth:1.5}):i.jsx(Ct,{size:12,strokeWidth:1.5}),i.jsx(tr,{size:12,strokeWidth:1.5,className:t?"animate-pulse":""}),i.jsx("span",{className:"flex-1 text-left",children:t?f("chat_thinking_streaming"):f("chat_thinking_done",String(o))})]}),n&&i.jsx("div",{className:"px-3 pb-2.5 pt-0",children:i.jsx("div",{className:"text-[13px] text-ink-2 leading-[1.65] whitespace-pre-wrap break-words max-h-[400px] overflow-y-auto",children:e||i.jsx("span",{className:"text-ink-3",children:"…"})})})]})}function wt(e){const t=typeof e=="number"&&Number.isFinite(e)?e:0;return t<1e3?String(t):t<1e5?`${(t/1e3).toFixed(1)}k`:t<1e6?`${Math.round(t/1e3)}k`:`${(t/1e6).toFixed(1)}M`}function mf(e,t,n){const r=e+t+n;return r<=0?null:e/r*100}function xf({message:e,onResolvePatch:t}){const n=e.status!=="pending"&&e.status!=="applying";_.useEffect(()=>{if(n||!t)return;const o=a=>{const l=a.target;(l==null?void 0:l.tagName)==="INPUT"||(l==null?void 0:l.tagName)==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey||(a.key==="a"||a.key==="A"?(a.preventDefault(),bi("A"),t(e.patchId,"accept")):(a.key==="r"||a.key==="R")&&(a.preventDefault(),bi("R"),t(e.patchId,"reject")))};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n,t,e.patchId]);const r=e.status==="accepted"?"border-modeC/40 bg-modeC-bg/40":e.status==="rejected"?"border-line bg-bg-app/40 opacity-60":e.status==="superseded"||e.status==="error"?"border-warn/40 bg-warn-bg/40":"border-brand-2/40 bg-brand-bg/40",s=e.confidence==="high"?"text-modeC":e.confidence==="low"?"text-warn":"text-ink-3";return i.jsxs("div",{className:`rounded-xl border px-3.5 py-3 space-y-2.5 ${r}`,children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsxs("div",{className:"text-xs uppercase tracking-wider text-ink-3 flex items-center gap-1.5",children:[i.jsx(lo,{size:12,strokeWidth:2,className:"text-brand-ink"}),i.jsx("span",{className:"text-brand-ink",children:f("chat_patch_proposal")}),i.jsx("span",{className:"yk-chip yk-chip-brand px-1 py-0",children:"patch"})]}),i.jsxs("span",{className:`text-xs font-mono ${s}`,children:["confidence: ",e.confidence]})]}),i.jsxs("div",{className:"text-md font-semibold",children:[e.macroName," ",i.jsxs("span",{className:"text-sm text-ink-3 font-mono",children:["v",e.fromVersion]})]}),e.reasoning&&i.jsxs("div",{className:"rounded-md bg-bg-soft border border-line-soft px-2.5 py-1.5 text-sm text-ink-2 leading-snug",children:[i.jsxs("span",{className:"font-semibold text-ink-1",children:[f("chat_why")," "]}),"· ",e.reasoning]}),i.jsx(gf,{diff:e.diff}),n?i.jsxs("div",{className:"text-sm text-ink-3",children:[e.status==="accepted"&&i.jsxs("span",{className:"text-modeC",children:["✓ Applied — bumped to v",e.newVersion??"?","."]}),e.status==="rejected"&&(e.error?`✗ ${e.error}`:"✗ Rejected."),e.status==="superseded"&&(e.error??"Macro changed since proposal — superseded."),e.status==="error"&&i.jsx("span",{className:"text-err",children:e.error??"Apply failed."})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[i.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(e.patchId,"accept"),disabled:e.status==="applying",className:"yk-btn yk-btn-primary flex-1 justify-center disabled:opacity-50",children:[i.jsx(We,{size:12,strokeWidth:2.5}),e.status==="applying"?f("chat_patch_applying"):f("chat_patch_apply"),i.jsx("span",{className:"yk-kbd bg-white/40 border-white/30",children:"A"})]}),i.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(e.patchId,"reject"),disabled:e.status==="applying",className:"yk-btn disabled:opacity-40",children:[f("chat_patch_reject"),i.jsx("span",{className:"yk-kbd",children:"R"})]})]}),i.jsxs("div",{className:"text-xs text-ink-4 font-mono flex items-center gap-1.5 pt-0.5",children:[i.jsx("span",{className:"yk-kbd",children:"A"})," accept",i.jsx("span",{children:"·"}),i.jsx("span",{className:"yk-kbd",children:"R"})," reject"]})]})]})}function gf({diff:e}){const t=e.split(`
`);return i.jsx("div",{className:"yk-diff",children:t.map((n,r)=>{const s=n.startsWith("+")&&!n.startsWith("+++")?"yk-diff-add":n.startsWith("-")&&!n.startsWith("---")?"yk-diff-rem":"",o=s==="yk-diff-add"?"+":s==="yk-diff-rem"?"−":" ",a=s?n.slice(1):n;return i.jsxs("div",{className:`yk-diff-ln ${s}`,children:[i.jsx("span",{className:"yk-diff-gn",children:r+1}),i.jsx("span",{className:"yk-diff-mk",children:o}),i.jsx("span",{className:"yk-diff-tx",children:a||" "})]},`${r}-${n.slice(0,16)}`)})})}function gt({src:e,alt:t,className:n}){const r=()=>{var l,c;const s=Math.max(800,Math.floor((((l=globalThis.screen)==null?void 0:l.width)??1600)*.9)),o=Math.max(600,Math.floor((((c=globalThis.screen)==null?void 0:c.height)??900)*.9)),a=`popup=1,width=${s},height=${o},noopener,noreferrer`;if(e.startsWith("data:"))try{const u=e.indexOf(","),h=e.slice(5,u),d=h.endsWith(";base64"),x=h.replace(/;base64$/,""),p=e.slice(u+1),m=d?Uint8Array.from(atob(p),y=>y.charCodeAt(0)):new TextEncoder().encode(decodeURIComponent(p)),g=new Blob([m],{type:x}),w=URL.createObjectURL(g);window.open(w,"_blank",a),setTimeout(()=>URL.revokeObjectURL(w),6e4);return}catch{}window.open(e,"_blank",a)};return i.jsx("button",{type:"button",onClick:r,className:"block cursor-zoom-in","aria-label":"Open full-size in a new tab",children:i.jsx("img",{src:e,alt:t,className:`${n??"max-h-60 rounded-md border border-line"} hover:border-brand-2/60 transition-colors`})})}function bf({stats:e}){const t=e.ctxWindow>0?Math.min(100,e.estTokens/e.ctxWindow*100):0,n=t>=90?"text-err":t>=60?"text-warn":"text-ink-3";return i.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-[11px] font-mono",children:[i.jsxs("span",{className:n,children:["ctx ",wt(e.estTokens)," / ",wt(e.ctxWindow)]}),i.jsx("div",{className:"flex-1 h-1 rounded-full bg-bg-app overflow-hidden",children:i.jsx("div",{className:t>=90?"bg-err/70":t>=60?"bg-warn/70":"bg-ink-3",style:{width:`${t}%`,height:"100%",transition:"width 200ms"}})}),i.jsxs("span",{className:`${n} tabular-nums`,children:[t.toFixed(0),"%"]})]})}function kf(e){if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?1:0)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m ${r}s`}function yf({error:e}){const t=xa(e),n=ga(t),r=n.warn?"border-[#e7d2ab] bg-warn-bg text-warn":"border-[#ebc9c2] bg-err-bg text-err",s=n.warn?"text-[#7d4d18]":"text-[#7a2c1e]";return i.jsxs("div",{className:`mt-0.5 mb-2 rounded-lg border px-3 py-2.5 ${r}`,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full text-xs font-bold text-white ${n.warn?"bg-warn":"bg-err"}`,children:"!"}),i.jsx("span",{className:"text-base font-semibold",children:n.title}),i.jsx("span",{className:"ml-auto yk-mcp-badge",children:t??"error"})]}),i.jsxs("div",{className:`mt-1.5 flex items-start gap-1.5 text-sm leading-relaxed ${s}`,children:[i.jsx("span",{children:"↳"}),i.jsx("span",{children:n.fix})]}),t==="auth"&&i.jsx("button",{type:"button",onClick:()=>chrome.runtime.openOptionsPage(),className:"mt-2 rounded-md border border-mcp-line bg-bg-app px-2.5 py-1 text-xs font-medium text-mcp-ink hover:bg-mcp-bg/40",children:f("chat_mcp_open_settings")})]})}function wf(e){switch(e){case"click":return{glyph:"↗",bg:"#eef3fb",fg:"#4870a8",border:"#cfd8e6"};case"type":case"input":return{glyph:"⌨",bg:"#f3eef9",fg:"#6c4ea3",border:"#d8cae6"};case"extract":case"extract_table":return{glyph:"⌗",bg:"#f0f7d9",fg:"#2a3a0a",border:"#d8e8a8"};case"screenshot":return{glyph:"◰",bg:"#fff6df",fg:"#8a6a17",border:"#e7d2ab"};case"navigate":case"open_new_tab":case"reload":return{glyph:"→",bg:"#e8f1ec",fg:"#2f8a4a",border:"#c6dfca"};case"wait":case"sleep":case"wait_for":return{glyph:"⏱",bg:"#f4f4ef",fg:"#7a7a72",border:"#e8e8df"};case"eval":return{glyph:"ƒ",bg:"#f3eef9",fg:"#6c4ea3",border:"#d8cae6"};case"ask":case"wait_user":return{glyph:"?",bg:"#e2eaf5",fg:"#4870a8",border:"#c8d6ec"};case"scroll":return{glyph:"↕",bg:"#f4f4ef",fg:"#7a7a72",border:"#e8e8df"};case"press_key":return{glyph:"⏎",bg:"#f4f4ef",fg:"#7a7a72",border:"#e8e8df"};default:return{glyph:"·",bg:"#ffffff",fg:"#4a4a44",border:"#e8e8df"}}}function jf(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(r==null||r==="")continue;const s=_f(r);s&&t.push({key:n,value:s})}return t}function _f(e){if(typeof e=="string")return $t(e,200);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return $t(JSON.stringify(e),200);if(typeof e=="object"&&e!==null){const t=[];for(const[n,r]of Object.entries(e)){if(r==null||r==="")continue;const s=typeof r=="string"?`"${$t(r,80)}"`:typeof r=="number"||typeof r=="boolean"?String(r):$t(JSON.stringify(r),80);t.push(`${n}=${s}`)}return t.join(" · ")}return""}function $t(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}function vf(e){const t=e.markdown,n=e.tags.length>0?`tags: [${e.tags.join(", ")}]`:null,r=t.split(`
`);if((r[0]??"").trim()!=="---"){const c=["---",`name: ${e.name}`,`description: ${e.description}`];return n&&c.push(n),c.push("---",""),`${c.join(`
`)}${t}`}const s=r.findIndex((c,u)=>u>0&&c.trim()==="---"),o=s===-1?r.slice(1):r.slice(1,s),a=c=>o.some(u=>new RegExp(`^${c}\\s*:`).test(u)),l=[];return a("name")||l.push(`name: ${e.name}`),a("description")||l.push(`description: ${e.description}`),!a("tags")&&n&&l.push(n),l.length===0?t:[r[0],...l,...r.slice(1)].join(`
`)}function Nf(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"macro"}const Cf=[{key:"macro_detail_sched_hourly",minutes:60},{key:"macro_detail_sched_6h",minutes:360},{key:"macro_detail_sched_daily",minutes:1440},{key:"macro_detail_sched_weekly",minutes:10080}],er=[0,1,2,3,4,5,6],ta=()=>Fi()==="zh_CN"?"zh-CN":"en-US";function Sf(){const e=new Intl.DateTimeFormat(ta(),{weekday:"narrow"});return er.map(t=>e.format(new Date(Date.UTC(2023,0,1+t))))}function Ef(e){return new Intl.DateTimeFormat(ta(),{weekday:"short",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(e))}function na(e,t){return e.kind==="times"?(e.times??[]).join(", ")||"—":t(e.everyMinutes)}function ra({value:e,onChange:t}){const n=(e==null?void 0:e.kind)==="times",r=n?e.times??[]:[],s=n?e.daysOfWeek??[]:[],o=n?!!e.catchUp:!1,[a,l]=_.useState("09:00"),c=_.useMemo(Sf,[]),u=_.useMemo(Ma,[]),h=n&&r.length?Ra({times:r,daysOfWeek:s.length?s:void 0,tz:u},Date.now()):null;function d(g){const w=g.times??r,y=g.days??s;t({kind:"times",enabled:w.length>0,everyMinutes:0,times:w,daysOfWeek:y.length?y:void 0,catchUp:g.catchUp??o,tz:u})}function x(){!/^\d{1,2}:\d{2}$/.test(a)||r.includes(a)||d({times:[...r,a].sort()})}function p(g){const w=s.length?s:er,y=w.includes(g)?w.filter(E=>E!==g):[...w,g].sort();y.length!==0&&d({days:y})}const m=g=>`px-2.5 py-1 rounded-md text-xs border transition-colors ${g?"border-brand bg-brand text-brand-ink":"border-line text-ink-2 hover:text-ink-1"}`;return i.jsxs("div",{className:"space-y-2.5",children:[i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{type:"button",className:m(!n&&!!(e!=null&&e.enabled)),onClick:()=>t(!n&&(e!=null&&e.enabled)?e:{everyMinutes:1440,enabled:!0}),children:f("macro_detail_sched_mode_every")}),i.jsx("button",{type:"button",className:m(n),onClick:()=>d({}),children:f("macro_detail_sched_mode_at")}),i.jsx("button",{type:"button",className:m(!(e!=null&&e.enabled)),onClick:()=>t(null),children:f("macro_detail_sched_off")})]}),!n&&(e==null?void 0:e.enabled)&&i.jsx("div",{className:"flex flex-wrap gap-1",children:Cf.map(g=>i.jsx("button",{type:"button",className:m(e.everyMinutes===g.minutes),onClick:()=>t({everyMinutes:g.minutes,enabled:!0}),children:f(g.key)},g.key))}),n&&i.jsxs("div",{className:"space-y-2",children:[r.length>0&&i.jsx("div",{className:"flex flex-wrap items-center gap-1",children:r.map(g=>i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs border border-line text-ink-1",children:[g,i.jsx("button",{type:"button",onClick:()=>d({times:r.filter(w=>w!==g)}),className:"text-ink-3 hover:text-err",children:i.jsx(Fe,{size:11,strokeWidth:2})})]},g))}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("input",{type:"time",value:a,onChange:g=>l(g.target.value),className:"px-2 py-1 rounded-md text-xs border border-line bg-transparent text-ink-1"}),i.jsxs("button",{type:"button",onClick:x,className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs border border-line text-ink-2 hover:text-ink-1",children:[i.jsx(sn,{size:12,strokeWidth:2})," ",f("macro_detail_sched_add")]})]}),i.jsx("div",{className:"flex gap-1",children:er.map(g=>i.jsx("button",{type:"button",onClick:()=>p(g),className:`w-6 h-6 rounded-md text-[11px] border transition-colors ${s.length===0||s.includes(g)?"border-brand bg-brand text-brand-ink":"border-line text-ink-3 hover:text-ink-1"}`,children:c[g]},g))}),i.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-ink-2",children:[i.jsx("input",{type:"checkbox",checked:o,onChange:g=>d({catchUp:g.target.checked})}),f("macro_detail_sched_catchup")]}),r.length===0?i.jsx("div",{className:"text-[11px] text-ink-3",children:f("macro_detail_sched_times_empty")}):h?i.jsxs("div",{className:"text-[11px] text-ink-2",children:[f("macro_detail_sched_next"),": ",Ef(h)]}):null]}),i.jsx("div",{className:"text-[11px] text-ink-3 leading-relaxed",children:f("macro_detail_sched_notice")})]})}function If(e){var V;const[t,n]=_.useState(null),[r,s]=_.useState("view"),[o,a]=_.useState(""),[l,c]=_.useState(!1),[u,h]=_.useState(null),[d,x]=_.useState(!1),[p,m]=_.useState({schedule:!0,io:!0});if(_.useEffect(()=>{Promise.all([$n("scheduled_runs"),$n("macro_import_export")]).then(([j,R])=>m({schedule:j,io:R}))},[]),_.useEffect(()=>{Xt(e.macroId).then(j=>{j&&(n(j),a(j.markdown))})},[e.macroId]),!t)return i.jsx("div",{className:"p-5 text-sm text-ink-3",children:f("macros_loading")});const g=t,w=o!==g.markdown;async function y(j){const R=await La(g.id,j);R&&n(R)}async function E(){if(w){c(!0);try{const j=await Pa(g.id,o);j&&(n(j),s("view"))}finally{c(!1)}}}function C(){w&&!confirm(f("macro_detail_unsaved_warning"))||(a(g.markdown),s("view"))}function I(){w&&!confirm(f("macro_detail_unsaved_warning"))||(a(g.markdown),s("view"))}function T(j){h(j),s("edit")}async function v(){confirm(f("macro_detail_delete_confirm",g.name))&&(await $i(g.id),e.onDeleted())}function F(){const j=new Blob([vf(g)],{type:"text/markdown"}),R=URL.createObjectURL(j),L=document.createElement("a");L.href=R,L.download=`${Nf(g.name)}.md`,L.click(),URL.revokeObjectURL(R)}async function Q(j){await chrome.runtime.sendMessage({type:"macro:schedule:set",macroId:g.id,schedule:j}),n({...g,schedule:j})}return i.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[i.jsxs("div",{className:"px-4 py-2 border-b border-line flex items-center justify-between",children:[i.jsxs("button",{type:"button",onClick:e.onBack,disabled:l,className:"flex items-center gap-1.5 text-sm text-ink-3 hover:text-ink-1 transition-colors disabled:opacity-50",children:[i.jsx(Bi,{size:14,strokeWidth:1.5}),f("macro_detail_back")]}),i.jsxs("div",{className:"flex gap-1 rounded-lg border border-line p-0.5",children:[i.jsx(_i,{active:r==="view",onClick:I,disabled:l,children:f("macro_detail_tab_view")}),i.jsx(_i,{active:r==="edit",onClick:()=>s("edit"),disabled:l,children:f("macro_detail_tab_edit")})]})]}),i.jsx(Af,{macro:g,onSave:y}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:r==="view"?i.jsx(zf,{macro:g,onSwitchToEdit:()=>s("edit"),onJumpToLine:T}):i.jsx("div",{className:"px-4 py-4 space-y-4",children:i.jsx(Kf,{markdown:o,onMarkdown:a,jumpToLine:u,onJumpHandled:()=>h(null)})})}),r==="view"&&d&&i.jsxs("div",{className:"px-4 py-3 border-t border-line space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-ink-1",children:[i.jsx(nt,{size:14,strokeWidth:1.5}),f("macro_detail_schedule")]}),i.jsx("button",{type:"button",onClick:()=>x(!1),className:"text-ink-3 hover:text-ink-1 transition-colors",children:i.jsx(Fe,{size:14,strokeWidth:1.5})})]}),p.schedule?i.jsx(ra,{value:g.schedule??null,onChange:Q}):i.jsxs("button",{type:"button",onClick:()=>void tt(),className:"flex items-center gap-1.5 text-xs text-ink-3 hover:text-ink-1 transition-colors",children:[f("macro_detail_sched_pro"),i.jsx(On,{})]})]}),i.jsx("div",{className:"px-4 py-3 border-t border-line flex items-center justify-between gap-2",children:r==="view"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-0.5",children:[i.jsxs("button",{type:"button",onClick:v,className:"flex items-center gap-1.5 px-2.5 py-2 text-sm text-ink-3 hover:text-err transition-colors",children:[i.jsx(dt,{size:14,strokeWidth:1.5}),f("macro_detail_delete")]}),i.jsxs("button",{type:"button",onClick:p.io?F:()=>void tt(),title:f("macro_detail_export"),className:"flex items-center gap-1.5 px-2.5 py-2 text-sm text-ink-3 hover:text-ink-1 transition-colors",children:[i.jsx(ka,{size:14,strokeWidth:1.5}),f("macro_detail_export"),!p.io&&i.jsx(On,{})]}),i.jsxs("button",{type:"button",onClick:()=>x(j=>!j),title:f("macro_detail_schedule"),className:`flex items-center gap-1.5 px-2.5 py-2 text-sm transition-colors ${(V=g.schedule)!=null&&V.enabled?"text-brand":"text-ink-3 hover:text-ink-1"}`,children:[i.jsx(nt,{size:14,strokeWidth:1.5}),f("macro_detail_schedule")]})]}),i.jsxs("button",{type:"button",onClick:e.onRun,disabled:!e.canRun,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-brand hover:bg-brand-2 text-brand-ink font-medium disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[i.jsx(an,{size:14,strokeWidth:2}),f("macro_detail_run_now")]})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onClick:C,disabled:l,className:"px-3 py-2 text-sm text-ink-3 hover:text-ink-1 transition-colors disabled:opacity-50",children:f("macro_detail_cancel")}),i.jsxs("button",{type:"button",onClick:E,disabled:!w||l,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-brand hover:bg-brand-2 text-brand-ink font-medium disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[l&&i.jsx(rr,{size:14,className:"animate-spin"}),f("macro_detail_save")]})]})})]})}function Af({macro:e,onSave:t}){const[n,r]=_.useState(e.name),[s,o]=_.useState(e.description);_.useEffect(()=>{r(e.name),o(e.description)},[e.name,e.description]);function a(){const c=n.trim();if(c===e.name||c===""){r(e.name);return}t({name:c})}function l(){const c=s.trim();c!==e.description&&t({description:c})}return i.jsxs("div",{className:"px-4 pt-3 pb-3 border-b border-line space-y-1.5",children:[i.jsx("input",{type:"text",value:n,onChange:c=>r(c.target.value),onBlur:a,onKeyDown:c=>{c.key==="Enter"&&c.target.blur(),c.key==="Escape"&&(r(e.name),c.target.blur())},placeholder:f("macro_detail_name_placeholder"),className:"w-full bg-transparent border-0 text-xl font-semibold tracking-tight text-ink-1 placeholder:text-ink-4 rounded px-1.5 -mx-1.5 py-0.5 outline-none hover:bg-bg-app/50 focus:bg-bg-app focus:ring-1 focus:ring-brand-2/60 transition-colors"}),i.jsx("textarea",{value:s,onChange:c=>o(c.target.value),onBlur:l,onKeyDown:c=>{c.key==="Escape"&&(o(e.description),c.target.blur())},placeholder:f("macro_detail_description_placeholder"),rows:2,className:"w-full resize-none bg-transparent border-0 text-sm text-ink-2 placeholder:text-ink-4 leading-relaxed rounded px-1.5 -mx-1.5 py-0.5 outline-none hover:bg-bg-app/50 focus:bg-bg-app focus:ring-1 focus:ring-brand-2/60 transition-colors"}),i.jsxs("div",{className:"flex items-start gap-1.5 text-[11px] text-ink-3 leading-relaxed px-0.5",children:[i.jsx(Hi,{size:11,strokeWidth:1.75,className:"mt-0.5 shrink-0 text-ink-4"}),i.jsx("span",{children:f("macro_detail_description_hint")})]}),i.jsx(Tf,{tags:e.tags,onChange:c=>t({tags:c})})]})}function Tf({tags:e,onChange:t}){const[n,r]=_.useState(!1),[s,o]=_.useState("");function a(){const l=s.trim();l&&!e.includes(l)&&t([...e,l]),o(""),r(!1)}return i.jsxs("div",{className:"flex flex-wrap gap-1 pt-0.5",children:[e.map(l=>i.jsxs("span",{className:"group flex items-center gap-1 text-xs pl-2 pr-1 py-0.5 rounded-full bg-bg-app border border-line text-ink-3",children:[l,i.jsx("button",{type:"button",onClick:()=>t(e.filter(c=>c!==l)),className:"opacity-0 group-hover:opacity-100 text-ink-3 hover:text-err transition-opacity","aria-label":`remove ${l}`,children:i.jsx(Fe,{size:10,strokeWidth:2})})]},l)),n?i.jsx("input",{autoFocus:!0,type:"text",value:s,onChange:l=>o(l.target.value),onBlur:a,onKeyDown:l=>{l.key==="Enter"&&a(),l.key==="Escape"&&(o(""),r(!1))},placeholder:f("macro_detail_tag_add_placeholder"),className:"text-xs bg-bg-app border border-brand-2/60 rounded-full px-2 py-0.5 outline-none w-24 text-ink-1 placeholder:text-ink-4"}):i.jsx("button",{type:"button",onClick:()=>r(!0),className:"text-xs px-2 py-0.5 rounded-full border border-dashed border-line text-ink-3 hover:text-ink-2 hover:border-ink-4 transition-colors",children:f("macro_detail_tag_add")})]})}function zf({macro:e,onSwitchToEdit:t,onJumpToLine:n}){const{parsed:r,parseError:s,diagnostics:o}=_.useMemo(()=>{try{const x=Da(e.markdown);return{parsed:x.ast,parseError:null,diagnostics:x.unparsed}}catch(x){return{parsed:null,parseError:x instanceof Error?x.message:String(x),diagnostics:[]}}},[e.markdown]),a=(r==null?void 0:r.frontmatter.inputs)??[],l=(r==null?void 0:r.frontmatter.outputs)??[],c=(r==null?void 0:r.body)??null,u=_.useMemo(()=>{if(!r)return!1;const x=jt(r.body,m=>m.kind==="for"),p=jt(r.body,m=>m.kind==="call"&&m.tool==="ai_decide");return x&&!p},[r]),[h,d]=_.useState(!1);return i.jsxs("div",{className:"px-4 py-4 space-y-4",children:[i.jsx(Rf,{macro:e}),u&&i.jsx(Mf,{onCta:t}),i.jsx(Lf,{inputs:a}),l.length>0&&i.jsx(Pf,{outputs:l}),i.jsx(Wf,{body:c,parseError:s,diagnostics:o,onJumpToLine:n}),i.jsxs("button",{type:"button",onClick:()=>d(x=>!x),className:"w-full flex items-center gap-1.5 text-xs text-ink-3 hover:text-ink-2 transition-colors pt-1",children:[h?i.jsx(rn,{size:12}):i.jsx(Ct,{size:12}),h?f("macro_detail_hide_source"):f("macro_detail_show_source")]}),h&&i.jsx(Ff,{markdown:e.markdown,onJumpToLine:n})]})}function Mf({onCta:e}){return i.jsx("div",{className:"rounded-xl border border-line bg-bg-app px-3 py-2.5 border-l-2 border-l-accent",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx(Ue,{size:14,strokeWidth:1.75,className:"text-brand-ink mt-0.5 shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-xs text-ink-2 leading-relaxed",children:f("macro_detail_hint_loop_no_ai")}),i.jsxs("button",{type:"button",onClick:e,className:"text-xs text-brand-ink hover:text-brand-ink-hover mt-1.5 font-medium transition-colors",children:[f("macro_detail_hint_loop_no_ai_cta")," →"]})]})]})})}function Rf({macro:e}){const{stats:t,version:n}=e,r=t.runsTotal>0?Math.round(t.runsSuccess/t.runsTotal*100):null,s=t.lastRunAt!=null?Qf(t.lastRunAt):f("macro_detail_last_run_never");return i.jsxs("div",{className:"rounded-xl border border-line bg-bg-app divide-x divide-line grid grid-cols-4",children:[i.jsx(Bt,{label:f("macro_detail_runs_label"),value:String(t.runsTotal)}),i.jsx(Bt,{label:f("macro_detail_success_rate_label"),value:r==null?"—":`${r}%`,tone:r==null?"neutral":r>=90?"good":r>=50?"warn":"bad"}),i.jsx(Bt,{label:f("macro_detail_version_label"),value:`v${n}`}),i.jsx(Bt,{label:f("macro_detail_last_run_label"),value:s,compact:!0})]})}function Bt({label:e,value:t,tone:n="neutral",compact:r=!1}){const s={neutral:"text-ink-1",good:"text-brand-ink",warn:"text-warn",bad:"text-err"}[n];return i.jsxs("div",{className:"px-3 py-2 min-w-0",children:[i.jsx("div",{className:"text-[10px] uppercase tracking-wider text-ink-3 font-medium truncate",children:e}),i.jsx("div",{className:`mt-1 font-mono font-medium truncate ${r?"text-xs":"text-base"} ${s}`,title:t,children:t})]})}function Lf({inputs:e}){return i.jsx(nn,{title:f("macro_detail_section_params"),count:e.length>0?e.length:void 0,children:e.length===0?i.jsx("div",{className:"text-xs text-ink-3 italic",children:f("macro_detail_no_params")}):i.jsx("div",{className:"space-y-2",children:e.map(([t,n])=>i.jsx(Df,{name:t,spec:n},t))})})}function Df({name:e,spec:t}){return i.jsxs("div",{className:"rounded-md border border-line bg-bg-app px-3 py-2 border-l-2 border-l-accent/40",children:[i.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[i.jsxs("code",{className:"text-sm font-mono text-brand-ink",children:["$",e]}),i.jsx(ia,{type:t.type}),t.required?i.jsx(ji,{tone:"warn",children:f("macro_detail_param_required")}):i.jsx(ji,{tone:"muted",children:f("macro_detail_param_optional")}),t.default!==void 0&&i.jsxs("span",{className:"text-[11px] text-ink-3 ml-auto",children:[f("macro_detail_param_default"),":"," ",i.jsx("code",{className:"font-mono text-ink-2",children:Xf(t.default)})]})]}),t.description&&i.jsx("p",{className:"text-xs text-ink-3 mt-1 leading-relaxed",children:t.description})]})}function Pf({outputs:e}){return i.jsx(nn,{title:f("macro_detail_section_outputs"),count:e.length,children:i.jsx("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-sm",children:e.map(([t,n])=>i.jsxs("div",{className:"contents",children:[i.jsx("code",{className:"font-mono text-ink-1",children:t}),i.jsx(ia,{type:n})]},t))})})}function Ff({markdown:e,onJumpToLine:t}){const n=_.useMemo(()=>Of(e),[e]);return i.jsx("div",{className:"yk-md",children:n.map(r=>i.jsxs("div",{className:"yk-md-line",children:[i.jsx("button",{type:"button",onClick:()=>t(r.n),className:"yk-md-gutter cursor-pointer hover:text-brand-2",title:`Edit line ${r.n}`,children:r.n}),i.jsx("div",{className:`yk-md-src ${r.cls}`,style:r.kind==="in-loop"?{paddingLeft:26,background:"rgba(184, 232, 86, 0.04)",borderLeft:"2px solid rgba(196, 122, 42, 0.6)"}:r.kind==="for-open"||r.kind==="for-close"?{paddingLeft:10,background:"rgba(196, 122, 42, 0.10)",borderLeft:"2px solid #c47a2a"}:void 0,children:i.jsx($f,{text:r.text,kind:r.kind})})]},r.n))})}function Of(e){const t=[];let n=!1,r=0;for(const s of e.split(`
`)){r+=1;const o=s,a=s.trim();let l;a?/^#+\s/.test(a)?l="h":/^`for\b/.test(a)?(l="for-open",n=!0):/^`(end|endfor)`?$/.test(a)?(l="for-close",n=!1):/^`ask\b/.test(a)?l="ask":/^`[a-zA-Z_][\w-]*\b/.test(a)?l=n?"in-loop":"step":l="cmt":l="blank";const c=l==="h"?"is-h":l==="cmt"?"is-cmt":l==="ask"?"is-ask":l==="step"||l==="in-loop"?"is-step":"";t.push({n:r,text:o,kind:l,cls:c})}return t}function $f({text:e,kind:t}){var c,u,h;if(t==="blank")return i.jsx(i.Fragment,{children:" "});if(t==="h"||t==="cmt")return i.jsx(i.Fragment,{children:e||" "});if(t==="for-open"||t==="for-close")return i.jsxs(i.Fragment,{children:[((c=e.replace(/^(\s*)(`)/,(d,x,p)=>x+p).match(/^(\s*`)/))==null?void 0:c[1])??"",i.jsx("span",{style:{color:"#f5a67a",fontWeight:600},children:((u=e.match(/`(for|end|endfor)\b[^`]*`/))==null?void 0:u[0].slice(1,-1))??e.trim()}),((h=e.match(/`[^`]*`(\s*)$/))==null?void 0:h[1])??""]});const n=e.match(/^(\s*)`(\w+)([^`]*)`(\s*)$/);if(!n)return i.jsx(i.Fragment,{children:e});const[,r,s,o,a]=n,l=t==="ask"?"#c4d8f3":"#b8e856";return i.jsxs(i.Fragment,{children:[r,i.jsx("span",{children:"`"}),i.jsx("span",{style:{color:l},children:s}),Bf(o??""),i.jsx("span",{children:"`"}),a]})}function Bf(e){return e.split(/("[^"]*"|\$\w+|\$\{[^}]+\})/g).map((n,r)=>{const s=`${r}-${n.slice(0,8)}`;return/^".*"$/.test(n)?i.jsx("span",{className:"tk-str",children:n},s):/^\$/.test(n)?i.jsx("span",{className:"tk-var",children:n},s):i.jsx("span",{children:n},s)})}function Wf({body:e,parseError:t,diagnostics:n,onJumpToLine:r}){const[s,o]=_.useState("node"),a=_.useMemo(()=>e?Gt(e):[],[e]);if(t!==null)return i.jsxs(nn,{title:f("macro_detail_section_steps"),children:[i.jsx("div",{className:"text-xs text-err",children:f("macro_detail_parse_error")}),i.jsx("div",{className:"mt-1 text-xs text-ink-2 font-mono break-all",children:t})]});const l=!e||e.length===0,c=l?void 0:i.jsxs("div",{className:"flex gap-0.5 rounded border border-line p-px",children:[i.jsx(yi,{active:s==="node",onClick:()=>o("node"),children:f("macro_detail_view_nodes")}),i.jsx(yi,{active:s==="source",onClick:()=>o("source"),children:f("macro_detail_view_source")})]});return i.jsxs(nn,{title:f("macro_detail_section_steps"),count:l?void 0:a.length,toolbar:c,children:[n.length>0&&i.jsxs("div",{className:"mb-2 space-y-0.5",children:[i.jsx("div",{className:"text-xs text-err",children:f("macro_detail_parse_warn")}),n.map(u=>i.jsxs("button",{type:"button",onClick:()=>r(u.line),className:"block w-full text-left text-xs font-mono text-ink-2 hover:text-ink-1 break-all transition-colors",title:`Edit line ${u.line}`,children:["L",u.line,": ",u.message," — ",u.source]},`${u.line}-${u.source}`))]}),l?i.jsx("div",{className:"text-xs text-ink-3 italic",children:"—"}):s==="node"?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"text-[10px] text-ink-4 mb-1 italic",children:f("macro_detail_node_click_hint")}),i.jsx("div",{className:"space-y-1.5",children:e.map((u,h)=>i.jsx(Kt,{node:u,onJumpToLine:r},`${u.line}-${h}`))})]}):i.jsx("ol",{className:"space-y-0.5",children:a.map((u,h)=>i.jsxs("li",{className:"flex items-start gap-2 text-xs font-mono leading-relaxed",children:[i.jsx("button",{type:"button",onClick:()=>r(u.line),className:"text-ink-4 hover:text-brand-ink select-none tabular-nums w-6 text-right shrink-0 cursor-pointer transition-colors",title:`Edit line ${u.line}`,children:h+1}),i.jsx("button",{type:"button",onClick:()=>r(u.line),className:"text-ink-2 hover:text-ink-1 min-w-0 break-all text-left transition-colors cursor-pointer",style:{paddingLeft:u.depth*12},children:u.source})]},`${u.line}-${h}`))})]})}function yi({active:e,onClick:t,children:n}){return i.jsx("button",{type:"button",onClick:t,className:`px-1.5 py-0.5 rounded text-[10px] uppercase tracking-wider transition-colors ${e?"bg-bg-inset/70 text-ink-1":"text-ink-3 hover:text-ink-2"}`,children:n})}function Kt({node:e,onJumpToLine:t}){return e.kind==="for"?i.jsxs("div",{className:"rounded-xl border border-line overflow-hidden",style:{background:"rgba(196,122,42,0.04)",borderLeftWidth:2,borderLeftColor:"#c47a2a"},children:[i.jsxs("button",{type:"button",onClick:()=>t(e.line),className:"w-full px-3 py-2 flex items-center gap-2 hover:bg-warn-bg/60 transition-colors duration-fast text-left",children:[i.jsx(Vi,{size:12,strokeWidth:1.75,className:"text-warn shrink-0"}),i.jsx("code",{className:"text-xs font-mono text-ink-1 truncate",title:e.source,children:e.source})]}),i.jsx("div",{className:"ml-4 my-2 mr-3 pl-3 space-y-1.5",style:{borderLeft:"1px dashed rgba(196,122,42,0.5)"},children:e.body.map((n,r)=>i.jsx(Kt,{node:n,onJumpToLine:t},`${n.line}-${r}`))})]}):e.kind==="if"?i.jsxs("div",{className:"rounded-xl border border-line bg-bg-app overflow-hidden",children:[i.jsxs("button",{type:"button",onClick:()=>t(e.line),className:"w-full px-3 py-2 flex items-center gap-2 hover:bg-bg-soft/60 transition-colors duration-fast text-left",children:[i.jsx(Ui,{size:12,strokeWidth:1.75,className:"text-ink-3 shrink-0"}),i.jsx("code",{className:"text-xs font-mono text-ink-1 truncate",title:e.source,children:e.source})]}),i.jsxs("div",{className:"border-l border-line ml-4 my-2 mr-3 pl-3 space-y-1.5",children:[i.jsx(wi,{text:f("macro_detail_node_then")}),e.then_.map((n,r)=>i.jsx(Kt,{node:n,onJumpToLine:t},`t-${n.line}-${r}`)),e.else_.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(wi,{text:f("macro_detail_node_else")}),e.else_.map((n,r)=>i.jsx(Kt,{node:n,onJumpToLine:t},`e-${n.line}-${r}`))]})]})]}):i.jsx(Uf,{node:e,onJumpToLine:t})}function Uf({node:e,onJumpToLine:t}){const{cat:n,Icon:r}=qf(e),s=Hf[n],o=e.kind==="call"?Pi(e.tool):e.kind,a=Vf(e),l=e.kind==="call"?Oi(e.tool):null;return i.jsxs("button",{type:"button",onClick:()=>t(e.line),className:`group w-full text-left rounded-md border border-line bg-bg-app hover:bg-bg-soft/70 hover:border-line px-2.5 py-1.5 transition-colors duration-fast border-l-2 ${s.barCls}`,children:[i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[i.jsx(r,{size:11,strokeWidth:1.75,className:`${s.iconCls} shrink-0`}),l?i.jsxs("span",{className:"text-xs font-mono font-medium flex items-center gap-1 min-w-0",children:[i.jsx("span",{className:"yk-mcp-badge",children:"MCP"}),i.jsx("span",{className:"text-mcp-ink font-semibold truncate",children:l.server}),i.jsx("span",{className:"text-mcp",children:"·"}),i.jsx("span",{className:"text-ink-1 truncate",children:l.tool})]}):i.jsx("span",{className:`text-xs font-mono font-medium ${s.titleCls}`,children:o}),e.kind==="call"&&e.bind&&i.jsxs("span",{className:"text-[10px] font-mono text-ink-3 ml-auto truncate",children:["→ $",e.bind]})]}),a&&i.jsx("div",{className:"text-[11px] font-mono text-ink-3 mt-0.5 pl-[19px] break-all leading-snug line-clamp-2",children:a})]})}function wi({text:e}){return i.jsx("div",{className:"text-[10px] uppercase tracking-wider text-ink-3 font-medium pt-0.5",children:e})}const Hf={ai:{barCls:"border-l-brand-2",iconCls:"text-brand-ink",titleCls:"text-brand-ink"},loop:{barCls:"border-l-warn",iconCls:"text-warn",titleCls:"text-ink-1"},user:{barCls:"border-l-modeA",iconCls:"text-modeA",titleCls:"text-ink-1"},read:{barCls:"border-l-warn",iconCls:"text-warn",titleCls:"text-ink-1"},alert:{barCls:"border-l-err",iconCls:"text-err",titleCls:"text-ink-1"},mcp:{barCls:"border-l-mcp",iconCls:"text-mcp",titleCls:"text-mcp-ink"},default:{barCls:"border-l-line",iconCls:"text-ink-3",titleCls:"text-ink-1"}};function qf(e){if(e.kind==="assert")return{cat:"alert",Icon:Va};if(e.kind==="return")return{cat:"default",Icon:ya};const t=e.tool;return t.startsWith("mcp:")?{cat:"mcp",Icon:Ri}:t==="ai_decide"?{cat:"ai",Icon:Ue}:t==="ask"?{cat:"user",Icon:Zt}:t==="confirm"?{cat:"user",Icon:vt}:t==="wait_user"?{cat:"user",Icon:qi}:t==="notify"?{cat:"user",Icon:Zt}:t==="click"||t==="type"||t==="press_key"||t==="scroll"?{cat:"default",Icon:eo}:t==="extract"||t==="snapshot"||t==="screenshot"?{cat:"read",Icon:Mi}:t==="navigate"||t==="open_new_tab"||t==="reload"?{cat:"default",Icon:nr}:t==="wait"?{cat:"default",Icon:Xa}:{cat:"default",Icon:Ha}}function Vf(e){const t=e.source;if(e.kind==="call"){const s=t.indexOf(e.tool);if(s<0)return t;const o=t.slice(s+e.tool.length).trim();return o.startsWith("(")&&o.endsWith(")")?o.slice(1,-1).trim():o}const n=e.kind==="assert"?"assert":"return",r=t.indexOf(n);return r<0?t:t.slice(r+n.length).trim()}function nn({title:e,count:t,toolbar:n,children:r}){return i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[i.jsx("h2",{className:"text-[11px] uppercase tracking-wider text-ink-3 font-medium",children:e}),t!==void 0&&i.jsxs("span",{className:"text-[10px] text-ink-4 font-mono",children:["(",t,")"]}),n&&i.jsx("div",{className:"ml-auto",children:n})]}),r]})}function ia({type:e}){return i.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wider px-1.5 py-px rounded-sm text-ink-3 bg-bg-soft",children:e})}function ji({children:e,tone:t}){const n=t==="warn"?"text-[10px] px-2 py-px rounded-full text-brand-ink bg-brand/10 font-medium":"text-[10px] px-2 py-px rounded-full text-ink-3 bg-bg-soft font-medium";return i.jsx("span",{className:n,children:e})}function Kf(e){const t=_.useRef(null),n=_.useRef(null);_.useLayoutEffect(()=>{const s=n.current;s&&t.current&&(n.current=null,t.current.focus(),t.current.setSelectionRange(s[0],s[1]))},[e.markdown]),_.useLayoutEffect(()=>{if(e.jumpToLine==null)return;const s=t.current;if(!s)return;const o=Math.max(0,e.jumpToLine-1),a=s.value.split(`
`);let l=0;for(let h=0;h<o&&h<a.length;h++)l+=(a[h]??"").length+1;const c=(a[o]??"").length;s.focus(),s.setSelectionRange(l,l+c);const u=Number.parseFloat(getComputedStyle(s).lineHeight)||20;s.scrollTop=Math.max(0,o*u-s.clientHeight/3),e.onJumpHandled()},[e.jumpToLine]);function r(s){const o=t.current;if(!o)return;const a=o.selectionStart,l=o.selectionEnd,c=e.markdown.substring(0,a),u=e.markdown.substring(l),d=c.length>0&&!c.endsWith(`
`)?`
`:"",x=d+s.snippet,p=c+x+u;let m,g;const w=s.placeholder?s.snippet.indexOf(s.placeholder):-1;s.placeholder&&w>=0?(m=a+d.length+w,g=m+s.placeholder.length):(m=a+x.length,g=m),n.current=[m,g],e.onMarkdown(p)}return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-line bg-bg-app/40 px-3 py-2",children:[i.jsx(Hi,{size:12,strokeWidth:1.75,className:"mt-0.5 shrink-0 text-ink-3"}),i.jsx("p",{className:"text-[11px] text-ink-3 leading-relaxed",children:f("macro_detail_edit_tip")})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"md-markdown",className:"text-xs uppercase tracking-wider text-ink-3",children:f("macro_detail_field_markdown")}),i.jsx(Gf,{onInsert:r}),i.jsx("textarea",{ref:t,id:"md-markdown",value:e.markdown,onChange:s=>e.onMarkdown(s.target.value),rows:18,spellCheck:!1,className:"mt-1 w-full bg-bg-app border border-line rounded-md px-3 py-2 text-sm font-mono leading-relaxed text-ink-1 placeholder:text-ink-4 caret-accent outline-none focus:border-brand-2 resize-y"})]})]})}function Gf({onInsert:e}){const t=[{key:"ai_decide",label:f("macro_detail_insert_ai_decide"),Icon:Ue,tone:"ai",spec:{snippet:'`$d = ai_decide(prompt="should this be approved?", context=$x, options="approve|reject")`',placeholder:"should this be approved?"}},{key:"confirm",label:f("macro_detail_insert_confirm"),Icon:vt,tone:"user",spec:{snippet:'`$ok = confirm("ship it?")`',placeholder:"ship it?"}},{key:"ask",label:f("macro_detail_insert_ask"),Icon:Zt,tone:"user",spec:{snippet:'`ask("Question?") → $answer`',placeholder:"Question?"}},{key:"wait_user",label:f("macro_detail_insert_wait_user"),Icon:qi,tone:"user",spec:{snippet:'`wait_user("Solve the CAPTCHA, then click Resume")`',placeholder:"Solve the CAPTCHA, then click Resume"}},{key:"for",label:f("macro_detail_insert_for"),Icon:Vi,tone:"flow",spec:{snippet:`
# Loop
\`for $item in $items:\`

## Each
\`# step here\`
`,placeholder:"# step here"}},{key:"if",label:f("macro_detail_insert_if"),Icon:Ui,tone:"flow",spec:{snippet:`
# Branch
\`if $cond\`

## Then
\`# step here\`
`,placeholder:"# step here"}}],n={ai:"text-brand-ink",user:"text-blue-400",flow:"text-ink-3"},r=s=>s==="ai"?"border-brand-2/40 text-brand-ink hover:bg-brand/10 hover:border-brand-2":"border-line text-ink-2 hover:bg-bg-soft hover:border-line hover:text-ink-1";return i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:[i.jsx("span",{className:"text-[10px] uppercase tracking-wider text-ink-3 font-medium mr-1",children:f("macro_detail_insert_label")}),t.map(({key:s,label:o,Icon:a,tone:l,spec:c})=>i.jsxs("button",{type:"button",onClick:()=>e(c),title:c.snippet.trim(),className:`flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] border transition-colors duration-fast ${r(l)}`,children:[i.jsx(a,{size:11,strokeWidth:1.75,className:n[l]}),o]},s))]})}function _i(e){return i.jsx("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:`px-3 py-1 rounded-md text-sm font-medium transition-colors duration-fast disabled:opacity-50 ${e.active?"bg-bg-soft text-ink-1":"text-ink-3 hover:text-ink-1"}`,children:e.children})}function jt(e,t){for(const n of e)if(t(n)||n.kind==="for"&&jt(n.body,t)||n.kind==="if"&&(jt(n.then_,t)||jt(n.else_,t)))return!0;return!1}function Gt(e,t=0){const n=[];for(const r of e)n.push({depth:t,line:r.line,source:r.source}),r.kind==="if"?(n.push(...Gt(r.then_,t+1)),r.else_.length>0&&n.push(...Gt(r.else_,t+1))):r.kind==="for"&&n.push(...Gt(r.body,t+1));return n}function Xf(e){return e===null?"null":typeof e=="string"?JSON.stringify(e):String(e)}function Qf(e){const t=Date.now()-e;if(t<0)return"just now";const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const s=Math.floor(r/60);if(s<24)return`${s}h ago`;const o=Math.floor(s/24);if(o<7)return`${o}d ago`;const a=Math.floor(o/7);if(a<4)return`${a}w ago`;const l=Math.floor(o/30);return l<12?`${l}mo ago`:`${Math.floor(o/365)}y ago`}function Yf({target:e,onRun:t,onOpen:n}){const[r,s]=_.useState(null),[o,a]=_.useState(""),[l,c]=_.useState([]),u=_.useRef(null);_.useEffect(()=>{Qt({}).then(s)},[]);async function h(g){confirm("Delete this macro? This cannot be undone.")&&(await $i(g),s(w=>(w==null?void 0:w.filter(y=>y.id!==g))??null))}async function d(g){if(!g||g.length===0)return;const w=[];for(const y of Array.from(g))try{const E=await y.text(),C=Fa(E).frontmatter;await Oa({name:C.name??y.name.replace(/\.md$/i,""),description:C.description??"",markdown:E,tags:C.tags??[]})}catch(E){w.push(`${y.name}: ${E instanceof Error?E.message:String(E)}`)}s(await Qt({})),c(w)}function x(){var g;(g=u.current)==null||g.click()}const p=_.useMemo(()=>{if(!e)return null;try{return new URL(e.url).hostname}catch{return null}},[e]),m=_.useMemo(()=>{if(!r)return{here:[],other:[]};const g=o.trim().toLowerCase(),w=I=>!g||I.name.toLowerCase().includes(g)||I.description.toLowerCase().includes(g)||I.tags.some(T=>T.toLowerCase().includes(g)),y=I=>p?I.tags.some(T=>{if(!T.includes("."))return!1;const v=T.replace(/^\*\./,"");return p.includes(v)}):!1,E=[],C=[];for(const I of r.filter(w))(y(I)?E:C).push(I);return{here:E,other:C}},[r,o,p]);return r===null?i.jsx("div",{className:"p-5 text-sm text-ink-3",children:"Loading…"}):r.length===0?i.jsxs("div",{className:"px-5 py-8 space-y-3",children:[i.jsx(Ni,{errors:l,onDismiss:()=>c([])}),i.jsx("div",{className:"text-base text-ink-3 italic",children:f("mac_empty")}),i.jsxs("button",{type:"button",onClick:x,className:"yk-btn is-sm",children:[i.jsx(Nr,{size:12,strokeWidth:1.5}),f("macros_import")]}),i.jsx("input",{ref:u,type:"file",accept:".md,text/markdown",multiple:!0,className:"hidden",onChange:g=>{d(g.target.files),g.target.value=""}})]}):i.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[l.length>0&&i.jsx("div",{className:"px-3.5 pt-2",children:i.jsx(Ni,{errors:l,onDismiss:()=>c([])})}),i.jsxs("div",{className:"px-3.5 pt-2.5 pb-1.5 flex items-center gap-2",children:[i.jsxs("div",{className:"flex-1 flex items-center gap-1.5 px-2.5 py-1 bg-bg-soft rounded-lg border border-line-soft",children:[i.jsx(ro,{size:12,strokeWidth:1.5,className:"text-ink-3"}),i.jsx("input",{type:"text",value:o,onChange:g=>a(g.target.value),placeholder:f("mac_search_ph"),className:"flex-1 bg-transparent text-base text-ink-1 placeholder:text-ink-4 outline-none"})]}),i.jsx("button",{type:"button",onClick:x,className:"yk-btn is-sm",title:f("macros_import"),children:i.jsx(Nr,{size:12,strokeWidth:1.5})}),i.jsxs("button",{type:"button",className:"yk-btn is-sm",children:[i.jsx(sn,{size:12,strokeWidth:1.5}),f("mac_new")]}),i.jsx("input",{ref:u,type:"file",accept:".md,text/markdown",multiple:!0,className:"hidden",onChange:g=>{d(g.target.files),g.target.value=""}})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p&&m.here.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"yk-sec-label",children:[i.jsx("span",{children:f("mac_this_site",p)}),i.jsx("span",{className:"line"}),i.jsx("span",{className:"normal-case",children:m.here.length})]}),m.here.map(g=>i.jsx(vi,{m:g,disabled:!e,onRun:()=>e&&t(g.id,e.tabId),onOpen:()=>n(g.id),onDelete:()=>h(g.id)},g.id))]}),m.other.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"yk-sec-label",children:[i.jsx("span",{children:p?f("mac_other_sites"):f("mac_all_macros")}),i.jsx("span",{className:"line"}),i.jsx("span",{className:"normal-case",children:m.other.length})]}),m.other.map(g=>i.jsx(vi,{m:g,dim:!!p,disabled:!e,onRun:()=>e&&t(g.id,e.tabId),onOpen:()=>n(g.id),onDelete:()=>h(g.id)},g.id))]}),m.here.length===0&&m.other.length===0&&i.jsx("div",{className:"px-5 py-6 text-base text-ink-3 italic",children:f("mac_no_match")})]})]})}function vi({m:e,dim:t,disabled:n,onRun:r,onOpen:s,onDelete:o}){var u;const a=e.tags.find(h=>h.includes(".")),l=e.stats.lastRunAt?Jf(e.stats.lastRunAt):"never",c=Zf(e);return i.jsxs("div",{className:`group px-3 py-2 border-b border-line-soft grid gap-2.5 items-center hover:bg-bg-soft cursor-pointer ${t?"opacity-85":""}`,style:{gridTemplateColumns:"28px 1fr auto auto"},children:[i.jsx("button",{type:"button",onClick:s,className:"w-7 h-7 rounded-md bg-bg-soft border border-line-soft flex items-center justify-center text-ink-2 font-mono text-sm hover:border-line",children:((u=e.name[0])==null?void 0:u.toUpperCase())??"·"}),i.jsxs("button",{type:"button",onClick:s,className:"min-w-0 text-left",children:[i.jsxs("div",{className:"text-base font-semibold text-ink-1 flex items-center gap-1.5 truncate",children:[e.name,e.type==="playbook"&&i.jsx("span",{className:"yk-chip yk-chip-A px-1 py-0 text-xs uppercase tracking-wide",children:"Playbook"}),c&&i.jsx("span",{className:"yk-chip yk-chip-A px-1 py-0 text-xs",children:c})]}),e.description&&i.jsx("div",{className:"text-sm text-ink-3 truncate mt-px",children:e.description}),i.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-ink-3 font-mono mt-px",children:[a&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"inline-flex items-center gap-1",children:[i.jsx(wa,{size:10,strokeWidth:1.5}),a]}),i.jsx("span",{children:"·"})]}),i.jsxs("span",{children:[e.stats.runsTotal," runs"]}),i.jsx("span",{children:"·"}),i.jsx("span",{children:l}),i.jsx("span",{children:"·"}),i.jsx("span",{className:"text-modeC",children:"saves 0¢/run"})]})]}),i.jsx("button",{type:"button",onClick:o,className:"opacity-0 group-hover:opacity-100 text-ink-3 hover:text-err transition-opacity","aria-label":f("macros_delete"),title:f("macros_delete"),children:i.jsx(dt,{size:14,strokeWidth:1.5})}),i.jsx("button",{type:"button",disabled:n,onClick:r,title:f("macros_run"),"aria-label":`Run ${e.name}`,className:"w-7 h-7 rounded-md border border-line flex items-center justify-center text-ink-2 hover:bg-brand hover:border-brand-2 hover:text-brand-ink disabled:opacity-30 disabled:cursor-not-allowed",children:i.jsx(an,{size:14,strokeWidth:1.5})})]})}function Zf(e){const t=e.markdown,n=/^`\s*for\b/m.test(t),r=/^`\s*ask\b/m.test(t);return n&&r?"loop·ask":n?"loop":r?"ask":null}function Jf(e){const t=Date.now()-e;return t<6e4?f("time_just_now"):t<36e5?`${Math.floor(t/6e4)}m`:t<864e5?`${Math.floor(t/36e5)}h`:`${Math.floor(t/864e5)}d`}function Ni({errors:e,onDismiss:t}){return e.length===0?null:i.jsx("div",{className:"text-sm text-err bg-err-bg border border-err/40 rounded-md px-3 py-2 space-y-1",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsx("span",{className:"whitespace-pre-wrap break-all",children:f("macros_import_failed",e.join(`
`))}),i.jsx("button",{type:"button",onClick:t,"aria-label":"Dismiss",className:"text-ink-3 hover:text-ink-1 shrink-0",children:"✕"})]})})}function em(){const e=Fi()==="zh_CN"?"zh-CN":"en-US";return[{key:"tech-radar",title:f("ob_starter_radar_title"),desc:f("ob_starter_radar_desc"),feature:"loop",prompt:f("ob_starter_radar_prompt"),startUrl:"https://news.ycombinator.com"},{key:"extract-code",title:f("ob_starter_code_title"),desc:f("ob_starter_code_desc"),feature:"loop",prompt:f("ob_starter_code_prompt"),startUrl:`https://developer.mozilla.org/${e}/docs/Web/API/Fetch_API/Using_Fetch`},{key:"summarize",title:f("ob_starter_sum_title"),desc:f("ob_starter_sum_desc"),feature:"ask",prompt:f("ob_starter_sum_prompt"),startUrl:`https://developer.mozilla.org/${e}/docs/Web/HTTP/Guides/Overview`},{key:"gh-trending",title:f("ob_starter_gh_title"),desc:f("ob_starter_gh_desc"),feature:"loop",prompt:f("ob_starter_gh_prompt"),startUrl:"https://github.com/trending/rust?since=daily"}]}function tm({hasApiKey:e,onDismiss:t,onOpenSettings:n,onTryExample:r,onStartTour:s}){const[o,a]=_.useState(!1);return i.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:i.jsxs("div",{className:"max-w-md mx-auto px-5 py-6 space-y-5",children:[i.jsxs("header",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"w-11 h-11 rounded-xl bg-brand-bg border border-brand-2/40 text-brand-ink flex items-center justify-center mb-2.5",children:i.jsx(Ue,{size:20,strokeWidth:1.5})}),i.jsxs("h1",{className:"text-xl font-semibold tracking-tight leading-snug",children:[f("ob_hero_pre"),i.jsx("span",{className:"text-brand-ink bg-brand-bg px-1.5 rounded-sm",children:f("ob_hero_hl")}),f("ob_hero_punct"),i.jsx("br",{}),f("ob_hero_line2")]}),i.jsxs("p",{className:"text-base text-ink-3 leading-relaxed mt-1.5",children:[f("ob_sub_line1"),i.jsx("br",{}),i.jsx("strong",{className:"text-modeC",children:f("ob_sub_strong")})]})]}),i.jsx("button",{type:"button",onClick:()=>t(o),"aria-label":f("onboarding_close_aria"),className:"w-6 h-6 rounded-md flex items-center justify-center text-ink-3 hover:text-ink-1 hover:bg-bg-soft",children:i.jsx(Fe,{size:14,strokeWidth:1.5})})]}),!e&&i.jsxs("section",{children:[i.jsx("div",{className:"font-mono text-xs uppercase text-ink-3 tracking-wider mb-2",children:f("onboarding_first_step_header")}),i.jsxs("button",{type:"button",onClick:n,className:"w-full flex items-center justify-between gap-2 px-4 py-3 rounded-lg bg-brand hover:bg-brand-2 text-brand-ink font-medium transition-colors",children:[i.jsx("span",{children:f("onboarding_setup_key")}),i.jsx(nr,{size:16,strokeWidth:2})]})]}),e&&i.jsxs("div",{className:"text-base text-ink-2 bg-bg-app border border-line rounded-lg px-3 py-2 flex items-center gap-2",children:[i.jsx(We,{size:14,strokeWidth:2,className:"text-modeC shrink-0"}),f("onboarding_already_setup")]}),i.jsxs("button",{type:"button",onClick:s,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg border border-line hover:border-brand-2 hover:bg-brand-bg/30 text-ink-2 hover:text-ink-1 font-medium transition-colors",children:[i.jsx(Qa,{size:15,strokeWidth:1.6}),f("onboarding_start_tour")]}),i.jsxs("section",{children:[i.jsxs("div",{className:"font-mono text-xs uppercase text-ink-3 tracking-wider mb-2 flex items-center gap-2",children:[i.jsx("span",{children:f("ob_starters_header")}),i.jsx("span",{className:"flex-1 h-px bg-line-soft"}),i.jsx("span",{className:"normal-case text-ink-4",children:f("ob_starters_hint")})]}),i.jsx("div",{className:"flex flex-col gap-2",children:em().map(l=>{var c;return i.jsxs("button",{type:"button",disabled:!e,onClick:()=>{if(!e){n();return}r==null||r(l.prompt,l.startUrl)},title:e?l.prompt:f("ob_need_key_tip"),className:"px-3 py-2.5 rounded-xl bg-bg-app border border-line grid items-center gap-3 text-left hover:border-brand-2 hover:bg-brand-bg/30 transition-colors disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bg-app disabled:hover:border-line",style:{gridTemplateColumns:"36px 1fr auto"},children:[i.jsx("div",{className:"w-9 h-9 rounded-md bg-bg-soft border border-line-soft flex items-center justify-center text-ink-2 font-mono text-md font-bold",children:(c=l.key[0])==null?void 0:c.toUpperCase()}),i.jsxs("div",{className:"min-w-0",children:[i.jsxs("div",{className:"text-md font-semibold text-ink-1 flex items-center gap-1.5",children:[l.title,i.jsx("span",{className:"yk-chip yk-chip-A px-1 py-0 text-xs",children:l.feature})]}),i.jsx("div",{className:"text-sm text-ink-3 mt-px leading-snug",children:l.desc})]}),i.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1.5 font-mono text-sm text-brand-ink bg-brand-bg rounded-md border border-brand-2/40",children:[i.jsx(co,{size:11,strokeWidth:1.5}),f("ob_try")]})]},l.key)})}),!e&&i.jsx("div",{className:"mt-2 text-xs text-ink-3 italic",children:f("ob_need_key_note")})]}),i.jsxs("section",{className:"rounded-xl border border-dashed border-line bg-bg-soft px-3 py-2.5 text-sm text-ink-3 leading-relaxed",children:[i.jsx("strong",{className:"text-ink-2",children:f("ob_rec_pre")})," ",i.jsxs("span",{className:"inline-flex items-center gap-1 align-middle",children:[i.jsx(Wi,{size:9,strokeWidth:0,fill:"currentColor",className:"text-modeB"}),"Rec"]})," ",f("ob_rec_post")]}),i.jsxs("section",{className:"rounded-xl border border-line px-4 py-3 space-y-3",children:[i.jsx("div",{className:"font-mono text-xs uppercase text-ink-3 tracking-wider",children:f("legal_section_title")}),i.jsx(Ln,{icon:i.jsx(ja,{size:12,strokeWidth:1.5}),body:f("legal_privacy_body")}),i.jsx(Ln,{icon:i.jsx(no,{size:12,strokeWidth:1.5}),body:f("legal_liability_body")}),i.jsx(Ln,{icon:"⚖",body:f("legal_lawful_use_body")})]}),i.jsxs("div",{className:"space-y-2.5",children:[i.jsxs("label",{className:"flex items-center justify-center gap-2 text-sm text-ink-3 cursor-pointer select-none",children:[i.jsx("input",{type:"checkbox",checked:o,onChange:l=>a(l.target.checked),className:"w-3.5 h-3.5 accent-brand"}),f("onboarding_dont_show_again")]}),i.jsx("button",{type:"button",onClick:()=>t(o),className:"w-full px-4 py-2 text-base text-ink-3 hover:text-ink-1 border border-line rounded-lg transition-colors",children:f("onboarding_dismiss")})]})]})})}function Ln(e){return i.jsxs("div",{className:"flex items-start gap-2.5",children:[i.jsx("div",{className:"text-ink-3 mt-0.5 shrink-0 text-xs",children:e.icon}),i.jsx("p",{className:"text-xs text-ink-3 leading-relaxed",children:e.body})]})}async function Re(e){return chrome.runtime.sendMessage(e)}async function nm(e){return Re({type:"yank:recording:start",tabId:e})}async function rm(){return Re({type:"yank:recording:stop"})}async function im(){return Re({type:"yank:recording:query"})}async function sm(e){return Re({type:"yank:recording:get",id:e})}async function am(e){await Re({type:"yank:recording:discard",id:e})}async function Ci(){const e=await Re({type:"yank:session:list"});return{sessions:e.sessions??[],activeId:e.activeId}}async function Si(e){return(await Re({type:"yank:session:get",id:e})).session??null}async function om(){return Re({type:"yank:session:new"})}async function Ei(e){await Re({type:"yank:session:set-active",id:e})}async function lm(e){await Re({type:"yank:session:delete",id:e})}async function cm(e,t){await Re({type:"yank:session:rename",id:e,title:t})}async function um(e){var a;const t=await chrome.tabs.sendMessage(e,{type:"yank:pick:start"}).catch(()=>null),n=t!=null&&t.ok?t.picked:null;if(!n)return null;const r=await Re({type:"yank:screenshot-element",tabId:e,selector:n.candidates}).catch(()=>null),s=r!=null&&r.ok?(a=r.data)==null?void 0:a.screenshotBase64:void 0;return{selector:n.candidates.testid??n.candidates.css,label:n.label,screenshotDataUrl:s?`data:image/jpeg;base64,${s}`:void 0}}function Wt(){chrome.windows.create({url:chrome.runtime.getURL("src/panel/index.html?popout=1"),type:"popup",width:420,height:720})}function dm(e){let t=null,n=!1;function r(a){const{__sessionId:l,...c}=a;e(c,l)}function s(){if(t)return t;const a=chrome.runtime.connect({name:"yank:panel"});return a.onMessage.addListener(r),a.onDisconnect.addListener(()=>{chrome.runtime.lastError,t===a&&(t=null)}),t=a,a}function o(a){if(!n)try{s().postMessage(a)}catch{t=null,s().postMessage(a)}}return s(),{startModeA(a,l,c,u){o({type:"mode-a:start",intent:a,tabId:l,sessionId:c,attachments:u==null?void 0:u.map(h=>({dataUrl:h.dataUrl,mediaType:h.mediaType}))})},setHeadless(a,l){o({type:"mode-a:set-headless",headless:a,sessionId:l})},interject(a,l){o({type:"mode-a:interject",text:a,sessionId:l})},abort(a){o({type:"mode-a:abort",sessionId:a})},resetConversation(a){o({type:"mode-a:reset",sessionId:a})},runMacro(a,l,c){o({type:"macro:run",macroId:a,tabId:l,overrides:c})},generateMacroStream(a,l){o({type:"recording:generate-stream",recordingId:a,intent:l})},answerAsk(a,l){o({askAnswer:{question:a,answer:l}})},resumeMacro(a){o({type:"macro:resume",resumeId:a})},resolvePatch(a,l){o({type:"patch:resolve",patchId:a,decision:l})},disconnect(){n=!0,t==null||t.disconnect(),t=null}}}async function hm(e){const n=(await chrome.tabs.create({url:e,active:!0})).id;if(n==null)return null;await new Promise(o=>{const a=()=>{chrome.tabs.onUpdated.removeListener(l),clearTimeout(c),o()},l=(u,h)=>{u===n&&h.status==="complete"&&a()},c=setTimeout(a,12e3);chrome.tabs.onUpdated.addListener(l)});const r=await chrome.tabs.get(n).catch(()=>null),s={tabId:n,url:(r==null?void 0:r.url)??e,title:(r==null?void 0:r.title)??""};return await chrome.storage.session.set({"yank:target-tab":{...s,at:Date.now()}}),s}async function Ye(){const t=(await chrome.storage.session.get("yank:target-tab"))["yank:target-tab"];if(t)try{const a=await chrome.tabs.get(t.tabId);if(a.url&&!Ut(a.url))return{tabId:a.id??t.tabId,url:a.url,title:a.title??t.title}}catch{}const n=await chrome.tabs.query({active:!0,lastFocusedWindow:!0});for(const a of n)if(a.id&&a.url&&!Ut(a.url))return{tabId:a.id,url:a.url,title:a.title??""};const r=await chrome.tabs.query({active:!0,currentWindow:!0});for(const a of r)if(a.id&&a.url&&!Ut(a.url))return{tabId:a.id,url:a.url,title:a.title??""};const o=(await chrome.tabs.query({})).sort((a,l)=>Number(l.active)-Number(a.active));for(const a of o)if(a.id&&a.url&&!Ut(a.url))return{tabId:a.id,url:a.url,title:a.title??""};return null}function Ut(e){return e.startsWith("chrome-extension://")||e.startsWith("moz-extension://")||e.startsWith("chrome://")||e.startsWith("about:")}function pm(e){const[t,n]=_.useState(null),[r,s]=_.useState(""),[o,a]=_.useState(new Set),[l,c]=_.useState(null);_.useEffect(()=>{sm(e.recordingId).then(w=>{w.ok&&w.recording&&(n(w.recording),w.recording.intent&&s(w.recording.intent))})},[e.recordingId]);const u=e.generating.isGenerating,h=l??(e.generating.error&&f("rec_generate_error",e.generating.error))??null;if(!t)return i.jsx("div",{className:"p-5 text-sm text-ink-3",children:f("macros_loading")});const d=t.events.filter((w,y)=>!o.has(y)),x=mm((t.endedAt??Date.now())-t.startedAt);function p(w){a(y=>{const E=new Set(y);return E.has(w)?E.delete(w):E.add(w),E})}function m(){if(c(null),!r.trim()){c(f("rec_generate_no_intent"));return}e.onGenerate(r.trim())}async function g(){confirm(f("rec_discard_confirm"))&&(await am(e.recordingId),e.onDiscard())}return i.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[i.jsxs("div",{className:"px-4 py-2 border-b border-line flex items-center justify-between",children:[i.jsx("button",{type:"button",onClick:e.onBack,disabled:u,className:"text-sm text-ink-3 hover:text-ink-1 transition-colors disabled:opacity-50",children:f("rec_back_to_chat")}),i.jsx("span",{className:"text-xs text-ink-3 font-mono",children:f("rec_title",[String(d.length),x])})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-4",children:[u?i.jsx(fm,{reasoning:e.generating.reasoning,text:e.generating.text}):i.jsxs(i.Fragment,{children:[i.jsxs("section",{children:[i.jsx("label",{htmlFor:"rec-intent",className:"text-xs uppercase tracking-wider text-ink-3",children:f("rec_intent_label")}),i.jsx("textarea",{id:"rec-intent",value:r,onChange:w=>s(w.target.value),placeholder:f("rec_intent_placeholder"),rows:2,className:"mt-2 w-full resize-none bg-bg-app border border-line rounded-lg px-3 py-2 text-base text-ink-1 placeholder:text-ink-4 caret-accent outline-none focus:border-brand-2"})]}),i.jsxs("section",{children:[i.jsx("div",{className:"text-xs uppercase tracking-wider text-ink-3 mb-2",children:f("rec_events_label",String(d.length))}),t.events.length===0?i.jsx("div",{className:"text-sm text-ink-3 italic",children:f("rec_no_events")}):i.jsx("ul",{className:"space-y-1",children:t.events.map((w,y)=>{const E=o.has(y),C=xm(w);return i.jsxs("li",{className:`group flex items-start gap-2 px-2 py-1.5 rounded-md font-mono text-sm ${E?"opacity-30 line-through":"hover:bg-bg-app"} transition-colors`,children:[i.jsx("span",{className:"text-ink-3 w-7 shrink-0 text-right",children:y+1}),C?i.jsxs("span",{className:"flex-1 min-w-0 truncate",children:[i.jsx("span",{className:"yk-mcp-badge mr-1.5",children:"MCP"}),i.jsx("span",{className:"text-mcp-ink font-semibold",children:C.name}),C.args&&i.jsxs("span",{className:"text-ink-3",children:[" ",C.args]})]}):i.jsxs("span",{className:"flex-1 min-w-0 truncate",children:[i.jsx("span",{className:"text-brand-ink",children:w.type})," ",i.jsx("span",{className:"text-ink-3",children:gm(w)})]}),i.jsx("button",{type:"button",onClick:()=>p(y),className:"opacity-0 group-hover:opacity-100 text-ink-3 hover:text-err transition-opacity","aria-label":f("rec_delete_event_aria"),children:E?i.jsx(dt,{size:12,strokeWidth:1.5}):i.jsx(Fe,{size:12,strokeWidth:1.5})})]},`${y}-${w.type}`)})})]})]}),h&&i.jsx("div",{className:"text-sm text-err bg-err-bg border border-err/40 rounded-md px-3 py-2",children:h})]}),i.jsxs("div",{className:"px-4 py-3 border-t border-line flex items-center justify-between gap-2",children:[i.jsx("button",{type:"button",onClick:g,disabled:u,className:"px-3 py-2 text-sm text-ink-3 hover:text-err transition-colors disabled:opacity-50",children:f("rec_discard")}),i.jsx("button",{type:"button",onClick:m,disabled:u||!r.trim(),className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-brand hover:bg-brand-2 text-brand-ink font-medium disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:u?i.jsxs(i.Fragment,{children:[i.jsx(rr,{size:14,className:"animate-spin"}),f("rec_generating")]}):i.jsxs(i.Fragment,{children:[f("rec_generate"),i.jsx(nr,{size:14,strokeWidth:2})]})})]})]})}function fm(e){const[t,n]=_.useState(!0),r=e.reasoning.length>0,s=e.text.length>0;return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"text-sm text-ink-2 flex items-center gap-2",children:[i.jsx(rr,{size:14,className:"animate-spin shrink-0"}),s?f("rec_gen_writing"):f("rec_gen_thinking")]}),r&&i.jsxs("div",{className:"rounded-lg border border-line bg-bg-app/40",children:[i.jsxs("button",{type:"button",onClick:()=>n(!t),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-ink-3 hover:text-ink-1 transition-colors",children:[t?i.jsx(rn,{size:12,strokeWidth:1.5}):i.jsx(Ct,{size:12,strokeWidth:1.5}),i.jsx("span",{className:"flex-1 text-left",children:f("rec_gen_reasoning")})]}),t&&i.jsx("pre",{className:"px-3 pb-2.5 text-xs text-ink-3 font-mono leading-relaxed whitespace-pre-wrap break-words max-h-[280px] overflow-y-auto",children:e.reasoning})]}),s&&i.jsxs("div",{className:"rounded-lg border border-brand-2/30 bg-brand/5 px-3 py-2.5",children:[i.jsx("div",{className:"text-xs uppercase tracking-wider text-brand-ink mb-1.5",children:"macro markdown"}),i.jsx("pre",{className:"text-xs text-ink-2 font-mono leading-relaxed whitespace-pre-wrap break-words max-h-[420px] overflow-y-auto",children:e.text})]})]})}function mm(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return`${n}m ${r}s`}function xm(e){const t=n=>n&&typeof n=="object"&&Object.keys(n).length>0?et(JSON.stringify(n),60):"";if(e.type==="mcp_call")return{name:e.textHint||`mcp:${e.server}.${e.tool}`,args:t(e.args)};if(e.type==="click"&&e.mcp&&typeof e.mcp=="object"){const n=e.mcp;return{name:e.textHint||`mcp:${n.serverId??""}.${n.toolName??""}`,args:t(n.args)}}return null}function gm(e){const t=bm(e);if(e.type==="click"||e.type==="submit")return t||"(no target)";if(e.type==="input"){const n=e.value??"",r=e.pressKey?`key=${e.pressKey}`:`"${et(n,60)}"`;return t?`${r} → ${t}`:r}if(e.type==="select"){const n=e.value??"";return t?`"${n}" → ${t}`:`"${n}"`}if(e.type==="navigate"){const n=et(e.url,80);return e.reload?`reload${e.reload.hardReload?" (hard)":""}`:e.openedInNewTab?`${n} (new tab)`:n}if(e.type==="scroll"){if(e.target)return`to ${e.target}`;const n=e.x??0,r=e.y??0;return n?`to x=${n}, y=${r}`:`to y=${r}`}if(e.type==="wait"){const n=[];return e.condition&&n.push(`${e.condition.kind}${e.condition.value?`=${e.condition.value}`:""}`),e.waitedMs&&n.push(`${e.waitedMs}ms`),n.join(" · ")}if(e.type==="wait_observed"){const n=e.signals.map(r=>r.kind).join(",");return`${e.durationMs}ms${n?` [${n}]`:""}`}if(e.type==="screenshot")return e.fullPage?"full page":e.showToUser?t?`${t} (shown)`:"(shown to user)":t||"viewport";if(e.type==="extract"){const n=[];return e.snapshot?n.push("a11y snapshot"):t&&n.push(t),e.attr&&n.push(`attr=${e.attr}`),e.multi&&typeof e.count=="number"&&n.push(`${e.count}/${e.totalCount??e.count}`),n.join(" · ")}return""}function bm(e){if(e.textHint)return`"${et(e.textHint,60)}"`;const t=km(e.selectors);return t||""}function km(e){return e?e.text?`"${et(e.text,60)}"`:e.role?`role=${e.role}`:e.testid?`testid=${e.testid}`:e.css?et(e.css,60):e.xpath?et(e.xpath,60):"":""}function et(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}const ym={60:"macro_detail_sched_hourly",360:"macro_detail_sched_6h",1440:"macro_detail_sched_daily",10080:"macro_detail_sched_weekly"};function sa(e){const t=ym[e];return t?f(t):f("sched_every_min",String(e))}function _t(e){const t=Math.max(1,Math.round(Math.abs(e-Date.now())/6e4));if(t<60)return`${t}m`;const n=Math.round(t/60);return n<24?`${n}h`:`${Math.round(n/24)}d`}function wm(e){const[t,n]=_.useState(null),[r,s]=_.useState([]),[o,a]=_.useState([]),[l,c]=_.useState({}),[u,h]=_.useState(!1),d=_.useCallback(async()=>{const I=await Qt({});s(I),n(I.filter(v=>v.schedule!=null)),a(await $a());const T=await chrome.runtime.sendMessage({type:"macro:schedule:list"}).catch(()=>null);c((T==null?void 0:T.next)??{})},[]);_.useEffect(()=>{$n("scheduled_runs").then(I=>h(!I)),d()},[d]);async function x(I,T){await chrome.runtime.sendMessage({type:"macro:schedule:set",macroId:I.id,schedule:T}),n(v=>v&&(T==null?v.filter(F=>F.id!==I.id):v.map(F=>F.id===I.id?{...F,schedule:T}:F)))}async function p(I){await chrome.runtime.sendMessage({type:"macro:schedule:run-now",macroId:I.id}),await d()}async function m(I){await chrome.runtime.sendMessage({type:"prompt:schedule:set",task:I}),await d()}async function g(I){await chrome.runtime.sendMessage({type:"prompt:schedule:delete",id:I}),a(T=>T.filter(v=>v.id!==I))}async function w(I){await chrome.runtime.sendMessage({type:"prompt:schedule:run-now",id:I}),await d()}const y=t??[],E=y.length+o.length,C=y.filter(I=>{var T;return(T=I.schedule)==null?void 0:T.enabled}).length+o.filter(I=>I.schedule.enabled).length;return i.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[i.jsxs("div",{className:"px-4 py-2 border-b border-line flex items-center gap-2",children:[i.jsxs("button",{type:"button",onClick:e.onBack,className:"flex items-center gap-1.5 text-sm text-ink-3 hover:text-ink-1 transition-colors",children:[i.jsx(Bi,{size:14,strokeWidth:1.5}),f("macro_detail_back")]}),i.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-medium text-ink-1",children:[i.jsx(nt,{size:14,strokeWidth:1.5,className:"text-ink-3"}),f("sched_title")]}),!u&&E>0&&i.jsx("span",{className:"ml-auto font-mono text-xs text-ink-4",children:f("sched_count",[String(C),String(E)])})]}),i.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 bg-bg-soft border-b border-line-soft text-[11px] text-ink-3",children:[i.jsx(nt,{size:13,strokeWidth:1.5,className:"text-ink-4 shrink-0"}),i.jsx("span",{children:f("sched_note")})]}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:u?i.jsx(Cm,{}):t===null?i.jsx("div",{className:"p-5 text-sm text-ink-3",children:f("macros_loading")}):i.jsxs(i.Fragment,{children:[i.jsx(jm,{macros:r,onCreatePrompt:(I,T)=>void m({id:te(),prompt:I,schedule:T,createdAt:Date.now(),lastRunAt:null,lastRunStatus:null,failStreak:0}),onCreateMacro:(I,T)=>{const v=r.find(F=>F.id===I);v&&x(v,T)}}),E===0?i.jsx(Nm,{onBack:e.onBack}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"yk-sec-label",children:[i.jsx("span",{children:f("sched_scheduled")}),i.jsx("span",{className:"line"}),i.jsx("span",{className:"normal-case tracking-normal",children:f("sched_active_paused",[String(C),String(E-C)])})]}),o.map(I=>i.jsx(_m,{task:I,nextMs:l[I.id],onToggle:()=>void m({...I,schedule:{...I.schedule,enabled:!I.schedule.enabled}}),onRemove:()=>void g(I.id),onRetry:()=>w(I.id)},I.id)),y.map(I=>i.jsx(vm,{macro:I,nextMs:l[I.id],onToggle:()=>{var T;return x(I,{...I.schedule,enabled:!((T=I.schedule)!=null&&T.enabled)})},onRemove:()=>x(I,null),onOpen:()=>e.onOpenMacro(I.id),onRetry:()=>p(I)},I.id)),i.jsx("div",{className:"px-3.5 py-4 text-[10.5px] text-ink-4 leading-relaxed",children:f("sched_footnote")})]})]})})]})}function jm(e){const[t,n]=_.useState(""),[r,s]=_.useState(""),[o,a]=_.useState({everyMinutes:1440,enabled:!0}),l=(r!==""||t.trim().length>0)&&!!(o!=null&&o.enabled);function c(){o!=null&&o.enabled&&(r?e.onCreateMacro(r,o):t.trim()&&e.onCreatePrompt(t.trim(),o),n(""),s(""))}return i.jsxs("div",{className:"px-3.5 pt-3 pb-2 border-b border-line-soft space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-ink-2",children:[f("sched_new_title"),i.jsx(On,{})]}),i.jsx(_a,{}),r===""&&i.jsx("textarea",{value:t,onChange:u=>n(u.target.value),placeholder:f("sched_new_placeholder"),rows:2,className:"w-full px-2.5 py-2 text-sm bg-bg-app border border-line rounded-lg outline-none focus:border-brand-2 resize-none placeholder:text-ink-4"}),i.jsxs("select",{value:r,onChange:u=>s(u.target.value),className:"w-full px-2 py-1.5 text-xs bg-bg-app border border-line rounded-md outline-none text-ink-2",children:[i.jsx("option",{value:"",children:f("sched_new_type_text")}),e.macros.map(u=>i.jsxs("option",{value:u.id,children:[f("sched_new_macro_prefix")," ",u.name]},u.id))]}),i.jsx(ra,{value:o,onChange:a}),i.jsxs("button",{type:"button",onClick:c,disabled:!l,className:"yk-btn is-sm w-full disabled:opacity-40 disabled:cursor-not-allowed",children:[i.jsx(sn,{size:12,strokeWidth:2}),f("sched_create")]})]})}function _m(e){const{task:t,nextMs:n}=e,r=t.schedule.enabled,s=t.lastRunStatus==="failed",[o,a]=_.useState(!1);async function l(){a(!0);try{await e.onRetry()}finally{a(!1)}}return i.jsx("div",{className:`px-3.5 py-2.5 border-b border-line-soft ${r?"":"opacity-60"} ${s?"bg-err-bg border-b-transparent":""}`,children:i.jsxs("div",{className:"grid grid-cols-[30px_1fr_auto] gap-2.5 items-start",children:[i.jsx("div",{className:`w-[30px] h-[30px] rounded-md border flex items-center justify-center shrink-0 mt-px ${s?"bg-err-bg border-[#eccbc4] text-err":"bg-bg-soft border-line text-ink-2"}`,children:i.jsx(Ue,{size:15,strokeWidth:1.5})}),i.jsxs("div",{className:"min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-[12.5px] font-semibold text-ink-1",children:[i.jsx("span",{className:"truncate",title:t.prompt,children:t.prompt}),i.jsx("span",{className:"yk-chip yk-chip-A shrink-0",children:f("sched_ai_chip")}),i.jsx("span",{className:"yk-chip shrink-0",children:na(t.schedule,sa)}),s&&i.jsx("span",{className:"yk-chip yk-chip-err shrink-0",children:f("sched_failed_chip")}),!r&&i.jsx("span",{className:"text-[10px] text-ink-4",children:f("sched_paused")})]}),i.jsxs("div",{className:"mt-1 flex items-center gap-1.5 flex-wrap font-mono text-[10px] text-ink-3",children:[i.jsxs("span",{children:[f("sched_next")," ",r&&n?_t(n):"—"]}),i.jsx("span",{children:"·"}),i.jsxs("span",{className:s?"text-err":"text-ink-3",children:[f("sched_last")," ",t.lastRunAt?`${s?"✕":"✓"} ${_t(t.lastRunAt)}`:"—"]})]}),i.jsxs("div",{className:"mt-1.5 flex items-center gap-1",children:[i.jsx("button",{type:"button",onClick:l,disabled:o,className:"yk-btn is-sm disabled:opacity-50",children:o?f("sched_retrying"):f("sched_retry")}),i.jsx("button",{type:"button",onClick:e.onRemove,title:f("sched_remove"),className:"w-[25px] h-[25px] rounded-md border border-line bg-bg-app text-ink-3 hover:bg-[#fff8f6] hover:text-err hover:border-[#eccbc4] flex items-center justify-center transition-colors",children:i.jsx(dt,{size:13,strokeWidth:1.5})})]})]}),i.jsx(aa,{on:r,onClick:e.onToggle})]})})}function vm(e){var p,m;const{macro:t,nextMs:n}=e,r=!!((p=t.schedule)!=null&&p.enabled),[s,o]=_.useState(null),[a,l]=_.useState(!1),c=_.useCallback(async()=>(await Ba(t.id,20)).find(w=>w.triggeredBy==="schedule")??null,[t.id]);_.useEffect(()=>{let g=!0;return c().then(w=>{g&&o(w)}),()=>{g=!1}},[c]);const u=(s==null?void 0:s.status)==="failed",h=(s==null?void 0:s.endedAt)??(s==null?void 0:s.startedAt)??null,d=u?((m=s==null?void 0:s.steps.find(g=>g.index===s.failedStepIndex))==null?void 0:m.errorMessage)??null:null;async function x(){l(!0);try{await e.onRetry(),o(await c())}finally{l(!1)}}return i.jsxs("div",{className:`px-3.5 py-2.5 border-b border-line-soft ${r?"":"opacity-60"} ${u?"bg-err-bg border-b-transparent":""}`,children:[i.jsxs("div",{className:"grid grid-cols-[30px_1fr_auto] gap-2.5 items-start",children:[i.jsx("div",{className:`w-[30px] h-[30px] rounded-md border flex items-center justify-center shrink-0 mt-px ${u?"bg-err-bg border-[#eccbc4] text-err":"bg-bg-soft border-line text-ink-2"}`,children:i.jsx(nt,{size:15,strokeWidth:1.5})}),i.jsxs("div",{className:"min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-[12.5px] font-semibold text-ink-1",children:[i.jsx("span",{className:"truncate",children:t.name}),i.jsx("span",{className:"yk-chip shrink-0",children:t.schedule?na(t.schedule,sa):""}),u&&i.jsx("span",{className:"yk-chip yk-chip-err shrink-0",children:f("sched_failed_chip")}),!r&&i.jsx("span",{className:"text-[10px] text-ink-4",children:f("sched_paused")})]}),i.jsxs("div",{className:"mt-1 flex items-center gap-1.5 flex-wrap font-mono text-[10px] text-ink-3",children:[i.jsxs("span",{children:[f("sched_next")," ",r&&n?_t(n):"—"]}),i.jsx("span",{children:"·"}),i.jsxs("span",{className:u?"text-err":"text-ink-3",children:[f("sched_last")," ",h?`${u?"✕":"✓"} ${_t(h)}`:"—"]})]}),i.jsxs("div",{className:"mt-1.5 flex items-center gap-1",children:[i.jsx("button",{type:"button",onClick:e.onOpen,title:f("sched_open"),className:"w-[25px] h-[25px] rounded-md border border-line bg-bg-app text-ink-3 hover:bg-bg-soft hover:text-ink-1 flex items-center justify-center transition-colors",children:i.jsx(Ct,{size:13,strokeWidth:1.5})}),i.jsx("button",{type:"button",onClick:e.onRemove,title:f("sched_remove"),className:"w-[25px] h-[25px] rounded-md border border-line bg-bg-app text-ink-3 hover:bg-[#fff8f6] hover:text-err hover:border-[#eccbc4] flex items-center justify-center transition-colors",children:i.jsx(dt,{size:13,strokeWidth:1.5})})]})]}),i.jsx(aa,{on:r,onClick:e.onToggle})]}),u&&i.jsxs("div",{className:"mt-2 ml-[40px] p-2.5 bg-bg-app border border-[#eccbc4] rounded-md",children:[i.jsxs("div",{className:"font-mono text-[11px] text-err break-words",children:["✕ ",h?_t(h):"",d?` · ${d}`:` · ${f("sched_err_generic")}`]}),i.jsxs("div",{className:"mt-1 text-[10.5px] text-ink-3 leading-relaxed",children:["↳ ",f("sched_autopause_hint")]}),i.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:x,disabled:a,className:"yk-btn is-sm disabled:opacity-50",children:a?f("sched_retrying"):f("sched_retry")}),i.jsx("button",{type:"button",onClick:e.onOpen,className:"yk-btn is-sm",children:f("sched_logs")})]})]})]})}function aa(e){return i.jsx("button",{type:"button",onClick:e.onClick,title:e.on?f("sched_paused"):f("sched_scheduled"),className:`relative w-[30px] h-[18px] rounded-full transition-colors shrink-0 ${e.on?"bg-brand-2":"bg-ink-4"}`,children:i.jsx("span",{className:`absolute top-0.5 w-3.5 h-3.5 bg-white rounded-full transition-all ${e.on?"left-[14px]":"left-0.5"}`})})}function Nm(e){return i.jsxs("div",{className:"px-5 py-9 text-center",children:[i.jsx("div",{className:"w-[46px] h-[46px] rounded-xl mx-auto mb-3 bg-bg-soft border border-line text-ink-3 flex items-center justify-center",children:i.jsx(nt,{size:22,strokeWidth:1.5})}),i.jsx("div",{className:"text-base font-semibold text-ink-1",children:f("sched_empty_title")}),i.jsx("div",{className:"mt-1.5 text-sm text-ink-3 leading-relaxed",children:f("sched_empty_hint")}),i.jsx("button",{type:"button",onClick:e.onBack,className:"yk-btn mt-3.5 justify-center mx-auto",children:f("sched_empty_cta")})]})}function Cm(){const e=["sched_locked_b1","sched_locked_b2","sched_locked_b3"];return i.jsx("div",{className:"p-3.5",children:i.jsxs("div",{className:"p-4 rounded-xl border border-brand-2 bg-gradient-to-b from-brand-bg to-bg-app",children:[i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx("span",{className:"w-[34px] h-[34px] rounded-lg shrink-0 bg-brand border border-brand-2 text-brand-ink flex items-center justify-center",children:i.jsx(Ue,{size:16,strokeWidth:1.8})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"text-base font-bold text-brand-ink",children:f("sched_locked_title")}),i.jsx("div",{className:"text-[11px] text-ink-3 mt-0.5",children:f("sched_locked_sub")})]})]}),i.jsx("div",{className:"mt-3 flex flex-col gap-1.5",children:e.map(t=>i.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-2",children:[i.jsx("span",{className:"w-4 h-4 rounded-full bg-brand-2 text-brand-ink flex items-center justify-center shrink-0",children:i.jsx(We,{size:11,strokeWidth:2.5})}),f(t)]},t))}),i.jsxs("button",{type:"button",onClick:()=>void tt(),className:"yk-btn yk-btn-primary mt-3.5 w-full justify-center",children:[i.jsx(Ue,{size:13,strokeWidth:2}),f("sched_upgrade")]})]})})}function Sm(e){const t=Math.round((Date.now()-e)/6e4);if(t<1)return Sr()==="zh-CN"?"刚刚":"now";if(t<60)return`${t}m`;const n=Math.round(t/60);return n<24?`${n}h`:new Date(e).toLocaleDateString(Sr(),{month:"short",day:"numeric"})}const Em={running:"bg-modeA",idle:"bg-ink-3",done:"bg-ink-4",error:"bg-err"};function oa({status:e}){return i.jsx("span",{className:`w-[7px] h-[7px] rounded-full ${Em[e]} ${e==="running"?"animate-yk-pulse":""}`})}function Im(e){const{session:t,restored:n}=e,[r,s]=_.useState(!1),[o,a]=_.useState("");function l(){a(t.title),s(!0)}function c(){s(!1);const u=o.trim();u!==t.title&&e.onRename(u)}return i.jsxs("div",{className:`group grid grid-cols-[10px_1fr_auto] gap-[9px] items-center px-3 py-[7px] hover:bg-bg-soft ${e.active?"bg-bg-soft":""} ${r?"":"cursor-pointer"}`,children:[i.jsx(oa,{status:t.status}),r?i.jsx("input",{autoFocus:!0,value:o,onChange:u=>a(u.target.value),onBlur:c,onClick:u=>u.stopPropagation(),onKeyDown:u=>{u.key==="Enter"?(u.preventDefault(),c()):u.key==="Escape"&&s(!1)},placeholder:f("sessions_untitled"),className:"min-w-0 w-full bg-bg-app border border-brand-2 rounded px-1.5 py-0.5 text-[12.5px] text-ink-1 outline-none"}):i.jsxs("button",{type:"button",onClick:e.onSwitch,onDoubleClick:l,className:"min-w-0 text-left",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-[12.5px] text-ink-1 leading-[1.35]",children:[n&&i.jsx("span",{className:"shrink-0 inline-flex items-center justify-center w-[15px] h-[15px] rounded bg-brand-bg text-brand-ink border border-[#d8e8a8]",children:i.jsx(Li,{size:9,strokeWidth:1.6})}),i.jsx("span",{className:"truncate",children:t.title||f("sessions_untitled")})]}),i.jsxs("div",{className:"mt-px text-[10px] text-ink-3 font-mono truncate",children:[Sm(t.updatedAt)," · ",f("sessions_msgs",String(t.messageCount)),t.status==="running"&&i.jsxs("span",{className:"text-modeA",children:[" · ",f("sessions_running")]}),t.status==="error"&&i.jsxs("span",{className:"text-err",children:[" · ",f("sessions_failed")]})]})]}),!r&&i.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100",children:[i.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),l()},"aria-label":f("sessions_rename"),title:f("sessions_rename"),className:"w-6 h-6 rounded-md inline-flex items-center justify-center text-ink-4 hover:bg-bg-soft hover:text-ink-1",children:i.jsx(va,{size:12,strokeWidth:1.5})}),i.jsx("button",{type:"button",onClick:e.onDelete,"aria-label":f("sessions_delete"),title:f("sessions_delete"),className:"w-6 h-6 rounded-md inline-flex items-center justify-center text-ink-4 hover:bg-[#fff8f6] hover:text-err",children:i.jsx(dt,{size:13,strokeWidth:1.4})})]})]})}function Am(e){const{sessions:t,activeId:n,atLimit:r,canUpgrade:s}=e,o=t.length===0,a=(l,c)=>i.jsx(Im,{session:l,active:l.id===n,restored:c,onSwitch:()=>e.onSwitch(l.id),onDelete:()=>e.onDelete(l.id),onRename:u=>e.onRename(l.id,u)},l.id);return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button","aria-label":f("sessions_title"),className:"fixed inset-0 z-40 cursor-default",onClick:e.onClose}),i.jsxs("div",{className:"absolute right-2 top-full mt-1 z-50 w-72 rounded-lg border border-line bg-bg-app shadow-[0_14px_36px_-10px_rgba(40,40,30,0.28)] overflow-hidden",children:[i.jsxs("div",{className:"flex items-center gap-2 px-3 pt-[9px] pb-2 border-b border-line-soft",children:[i.jsx(Cr,{size:13,strokeWidth:1.6,className:"text-ink-3"}),i.jsx("span",{className:"text-[11px] font-bold tracking-[0.8px] uppercase text-ink-3",children:f("sessions_title")}),!o&&i.jsx("span",{className:"font-mono text-[10px] text-ink-4",children:t.length}),i.jsx("span",{className:"flex-1"}),i.jsx("button",{type:"button",onClick:e.onClose,"aria-label":"close",className:"w-[22px] h-[22px] inline-flex items-center justify-center rounded text-ink-3 hover:bg-bg-soft hover:text-ink-1",children:i.jsx(Fe,{size:13,strokeWidth:1.5})})]}),i.jsxs("button",{type:"button",disabled:r,onClick:()=>!r&&e.onNew(),className:`flex items-center gap-[9px] w-full px-3 py-[9px] text-left ${r?"cursor-not-allowed text-ink-4":"text-ink-1 hover:bg-bg-soft border-b border-line-soft"}`,children:[i.jsx("span",{className:`shrink-0 w-[18px] h-[18px] rounded-md inline-flex items-center justify-center border ${r?"bg-bg-soft border-line text-ink-4":"bg-bg-soft border-line text-ink-3"}`,children:i.jsx(sn,{size:12,strokeWidth:1.6})}),i.jsx("span",{className:"flex-1 text-[12.5px]",children:f("sessions_new")}),!r&&i.jsx("span",{className:"font-mono text-[10px] text-ink-4 bg-bg-soft px-1.5 rounded-sm border border-line",children:"⌘N"})]}),r&&i.jsxs("div",{className:"flex items-center gap-1.5 px-3 pt-0.5 pb-[9px] border-b border-line-soft text-[10.5px] text-err",children:[i.jsx("span",{className:"text-[11px]",children:"⚠"}),i.jsx("span",{className:"flex-1",children:f("sessions_limit_inline")}),s&&i.jsx("button",{type:"button",onClick:()=>void tt(),className:"shrink-0 font-semibold text-brand-ink hover:underline",children:f("sessions_limit_upgrade")})]}),o?i.jsxs("div",{className:"px-4 pt-[30px] pb-[34px] text-center",children:[i.jsx("div",{className:"w-[34px] h-[34px] rounded-lg mx-auto mb-2.5 bg-bg-soft border border-line text-ink-4 flex items-center justify-center",children:i.jsx(Cr,{size:16,strokeWidth:1.5})}),i.jsx("div",{className:"text-[12.5px] font-semibold text-ink-2",children:f("sessions_empty")}),i.jsx("div",{className:"text-[10.5px] text-ink-4 mt-[3px] leading-[1.5]",children:f("sessions_empty_hint")})]}):i.jsx("div",{className:"max-h-[360px] overflow-y-auto py-1",children:t.map(l=>a(l,!!l.interrupted))}),s&&i.jsxs("button",{type:"button",onClick:()=>void tt(),className:"flex items-start gap-1.5 w-full px-3 py-2 border-t border-line-soft text-left text-[10.5px] text-ink-3 hover:bg-bg-soft",children:[i.jsx(Ue,{size:12,strokeWidth:1.6,className:"shrink-0 mt-[1px] text-brand-ink"}),i.jsx("span",{className:"flex-1",children:f("sessions_pro_hint")})]})]})]})}const Dn=[{selector:'[data-tour="composer"]',titleKey:"tour_composer_title",bodyKey:"tour_composer_body",badge:{label:"A",cls:"bg-modeA-bg text-modeA"}},{selector:'[data-tour="picker"]',titleKey:"tour_picker_title",bodyKey:"tour_picker_body"},{selector:'[data-tour="record"]',titleKey:"tour_record_title",bodyKey:"tour_record_body",badge:{label:"B",cls:"bg-modeB-bg text-modeB"}},{selector:'[data-tour="macros"]',titleKey:"tour_macros_title",bodyKey:"tour_macros_body",badge:{label:"C",cls:"bg-modeC-bg text-modeC"}},{selector:'[data-tour="sessions"]',titleKey:"tour_sessions_title",bodyKey:"tour_sessions_body"},{selector:'[data-tour="scheduled"]',titleKey:"tour_scheduled_title",bodyKey:"tour_scheduled_body"},{selector:'[data-tour="pro"]',titleKey:"tour_pro_title",bodyKey:"tour_pro_body"}];function Tm(e,t){return e===null||t===null?e===t:e.top===t.top&&e.left===t.left&&e.width===t.width&&e.height===t.height}const Ht=6,lt=300,Ii=12;function zm({onClose:e}){const[t,n]=_.useState(0),[r,s]=_.useState(null),o=Dn.length-1,a=Dn[t];_.useEffect(()=>{if(!a)return;const w=()=>{const y=document.querySelector(a.selector);let E=null;if(y){const C=y.getBoundingClientRect();E={top:C.top,left:C.left,width:C.width,height:C.height}}s(C=>Tm(C,E)?C:E)};return w(),window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),()=>{window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0)}},[a]),_.useEffect(()=>{const w=y=>{y.key==="Escape"?(y.preventDefault(),e()):y.key==="Enter"||y.key==="ArrowRight"?(y.preventDefault(),t>=o?e():n(t+1)):y.key==="ArrowLeft"&&t>0&&(y.preventDefault(),n(t-1))};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[t,o,e]);const l=()=>t>=o?e():n(t+1),c=()=>t>0&&n(t-1),u=r?{top:Math.max(0,r.top-Ht),left:Math.max(0,r.left-Ht),width:r.width+Ht*2,height:r.height+Ht*2}:null,h=window.innerWidth,d=window.innerHeight,x=u?Math.min(Math.max(8,u.left+u.width/2-lt/2),h-lt-8):Math.max(8,h/2-lt/2),p=u?u.top+u.height+Ii:d/2,m=u!=null&&p>d-180,g=u?m?{left:x,bottom:d-(u.top-Ii),width:lt}:{left:x,top:p,width:lt}:{left:x,top:d/2-90,width:lt};return a?i.jsxs("div",{className:"fixed inset-0 z-[60]",children:[i.jsx("button",{type:"button","aria-label":f("tour_skip"),onClick:e,className:"absolute inset-0 w-full h-full cursor-default"}),u&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"absolute rounded-[10px] pointer-events-none transition-all duration-150",style:{top:u.top,left:u.left,width:u.width,height:u.height,boxShadow:"0 0 0 9999px rgba(20, 20, 16, 0.55)"}}),i.jsx("div",{className:"absolute rounded-[10px] pointer-events-none ring-2 ring-brand-2 transition-all duration-150",style:{top:u.top,left:u.left,width:u.width,height:u.height}})]}),i.jsxs("div",{className:"absolute rounded-xl border border-line bg-bg-app shadow-modal p-3.5 space-y-2.5",style:g,children:[i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsxs("h2",{className:"flex-1 text-md font-semibold text-ink-1 flex items-center gap-1.5 leading-snug",children:[a.badge&&i.jsx("span",{className:`yk-chip px-1.5 py-0 text-xs font-bold ${a.badge.cls}`,children:a.badge.label}),f(a.titleKey)]}),i.jsx("button",{type:"button",onClick:e,"aria-label":f("tour_skip"),title:f("tour_skip"),className:"w-5 h-5 -mr-1 -mt-0.5 shrink-0 rounded-md inline-flex items-center justify-center text-ink-3 hover:text-ink-1 hover:bg-bg-soft",children:i.jsx(Fe,{size:13,strokeWidth:1.6})})]}),i.jsx("p",{className:"text-sm text-ink-2 leading-relaxed",children:f(a.bodyKey)}),i.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[i.jsx("div",{className:"flex items-center gap-1",children:Dn.map((w,y)=>i.jsx("span",{className:`h-1.5 rounded-full transition-all ${y===t?"w-3.5 bg-brand":"w-1.5 bg-line"}`},w.selector))}),i.jsx("span",{className:"flex-1"}),t>0&&i.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-0.5 px-2 py-1 rounded-md text-sm text-ink-3 hover:text-ink-1 hover:bg-bg-soft",children:[i.jsx(qa,{size:13,strokeWidth:1.6}),f("tour_back")]}),i.jsxs("button",{type:"button",onClick:l,className:"inline-flex items-center gap-0.5 px-2.5 py-1 rounded-md text-sm font-medium bg-brand hover:bg-brand-2 text-brand-ink",children:[t>=o?f("tour_done"):f("tour_next"),t<o&&i.jsx(Ct,{size:13,strokeWidth:2})]})]})]})]}):null}function Pn(e){return typeof e=="string"?e:e.map(t=>t.type==="text"?t.text??"":"").filter(Boolean).join(`
`).trim()}function Ai(e){var r;const t=new Map;for(const s of e)s.role==="tool"&&s.tool_call_id&&t.set(s.tool_call_id,Pn(s.content));const n=[];for(const s of e){if(s.role==="system"||s.role==="tool")continue;if(s.role==="user"){const a=Pn(s.content);a&&!Er(a)&&n.push({id:te(),role:"user",text:a});continue}(r=s.reasoning_content)!=null&&r.trim()&&n.push({id:te(),role:"thinking",text:s.reasoning_content.trim()});const o=Pn(s.content);o&&!Er(o)&&n.push({id:te(),role:"assistant",text:o});for(const a of s.tool_calls??[])n.push({id:te(),role:"tool-call",tool:a.name,input:a.input,status:"success",data:t.get(a.id)})}return n}function Mm(){const[e,t]=_.useState([]),[n,r]=_.useState(null),[s,o]=_.useState(!1),[a,l]=_.useState(!1),[c,u]=_.useState([]),[h,d]=_.useState(""),[x,p]=_.useState("USD"),[m,g]=_.useState(null),[w,y]=_.useState("chat"),[E,C]=_.useState(!1),[I,T]=_.useState({mode:"normal"}),[v,F]=_.useState(!1),[Q,V]=_.useState(!1),[j,R]=_.useState(!1),[L,ee]=_.useState(!1),[se,K]=_.useState(!1),[ae,ue]=_.useState([]),[ye,fe]=_.useState(!1),[b,de]=_.useState(void 0),[we,k]=_.useState(15),[M,H]=_.useState(!1),[U,W]=_.useState({isGenerating:!1,reasoning:"",text:"",error:null}),Y=_.useRef(null),ve=_.useRef(()=>{}),G=_.useRef(void 0);G.current=b;const Te=_.useRef(0),ge=_.useRef(!1);_.useEffect(()=>{Aa().then($=>{var pe,Ee;u($.llm.providers),d($.llm.defaultProviderId),ee($.llm.providers.length>0),F(!$.onboarding.dismissed),R($.onboarding.tourSeen??!1),p($.llm.displayCurrency??"USD");const X=((pe=$.execution)==null?void 0:pe.headlessDefault)??!1;K(X),(Ee=Y.current)==null||Ee.setHeadless(X)}),Ta().then($=>k($.activeSessions));const N=dm(pn);Y.current=N,Ye().then(g),im().then($=>C($.ok&&$.isRecording));const P=()=>void Ye().then($=>{g(X=>(X==null?void 0:X.tabId)===($==null?void 0:$.tabId)&&(X==null?void 0:X.url)===($==null?void 0:$.url)&&(X==null?void 0:X.title)===($==null?void 0:$.title)?X:$)}),D=($,X)=>{(X.url||X.title||X.status==="complete")&&P()};chrome.tabs.onActivated.addListener(P),chrome.tabs.onUpdated.addListener(D);const ce=async()=>{const{sessions:$,activeId:X}=await Ci(),pe=X?$.find(De=>De.id===X):$.find(De=>De.status!=="done"&&De.messageCount>0);if(!pe)return;const Ee=++Te.current;G.current=pe.id,ge.current=!1,de(pe.id),await Ei(pe.id);const xe=await Si(pe.id);Te.current===Ee&&(t(xe?Ai(xe.messages):[]),o((xe==null?void 0:xe.status)==="running"))};return(async()=>{const $=await chrome.storage.session.get(["yank:pending-run","yank:pending-prompt"]).catch(()=>({})),X=$["yank:pending-run"];if(X&&(await chrome.storage.session.remove("yank:pending-run"),Date.now()-X.at<=3e4)){const Ee=await Xt(X.macroId),xe=(Ee==null?void 0:Ee.name)??X.macroId;o(!0),t(De=>[...De,{id:te(),role:"system",text:f("panel_starting_macro",xe)}]),ge.current=!G.current,N.startModeA(Fn(X.macroId,xe),X.tabId);return}const pe=$["yank:pending-prompt"];if(pe&&(await chrome.storage.session.remove("yank:pending-prompt"),Date.now()-pe.at<=3e4&&pe.text)){o(!0),t(Ee=>[...Ee,{id:te(),role:"user",text:pe.text}]),ge.current=!G.current,N.startModeA(pe.text,pe.tabId);return}await ce()})(),()=>{N.disconnect(),chrome.tabs.onActivated.removeListener(P),chrome.tabs.onUpdated.removeListener(D)}},[]);const me=_.useCallback(async()=>{const{sessions:N,activeId:P}=await Ci();ue(N),de(D=>P??D)},[]),pn=_.useCallback((N,P)=>{if(P&&!G.current&&ge.current)ge.current=!1,G.current=P,de(P);else if(P&&P!==G.current){me();return}if(N.kind==="gen-started"){W({isGenerating:!0,reasoning:"",text:"",error:null});return}if(N.kind==="gen-text-delta"){W(D=>({...D,text:D.text+N.text}));return}if(N.kind==="gen-reasoning-delta"){W(D=>({...D,reasoning:D.reasoning+N.text}));return}if(N.kind==="gen-done"){W({isGenerating:!1,reasoning:"",text:"",error:null}),ve.current(N.macro);return}if(N.kind==="gen-error"){W(D=>({...D,isGenerating:!1,error:N.error}));return}if(N.kind==="context-stats"){r(D=>D&&D.estTokens===N.estTokens&&D.ctxWindow===N.ctxWindow?D:{estTokens:N.estTokens,ctxWindow:N.ctxWindow});return}t(D=>Um(D,N)),(N.kind==="completed"||N.kind==="error"||N.kind==="aborted"||N.kind==="macro-run-finished")&&(o(!1),l(!1)),(N.kind==="started"||N.kind==="macro-run-started")&&o(!0)},[me]),At=_.useCallback(async(N,P)=>{var $,X,pe,Ee;const D=m??await Ye();if(!D){t(xe=>[...xe,{id:te(),role:"system",text:"No usable tab. Open a regular web page first."}]);return}if(s){t(xe=>[...xe,{id:te(),role:"user",text:N,images:P}]),($=Y.current)==null||$.interject(N,G.current);return}t(xe=>[...xe,{id:te(),role:"user",text:N,images:P}]);const ce=N.match(/^\/run\s+(.+)$/);if(ce){const xe=((X=ce[1])==null?void 0:X.trim())??"",De=await Fm(xe);if(!De){t(yn=>[...yn,{id:te(),role:"system",text:f("panel_macro_not_found",xe)}]);return}o(!0),t(yn=>[...yn,{id:te(),role:"system",text:f("panel_starting_macro",De.name)}]),ge.current=!G.current,(pe=Y.current)==null||pe.startModeA(Fn(De.id,De.name),D.tabId,G.current);return}o(!0),ge.current=!G.current,(Ee=Y.current)==null||Ee.startModeA(N,D.tabId,G.current,P)},[m,s]),Tt=_.useCallback(()=>{var N;l(!0),(N=Y.current)==null||N.abort(G.current)},[]),zt=_.useCallback(async()=>{const N=m??await Ye();return N?um(N.tabId):null},[m]),fn=_.useCallback(()=>{var P,D;const N=G.current;G.current=void 0,ge.current=!1,Te.current++,(P=Y.current)==null||P.abort(N),(D=Y.current)==null||D.resetConversation(N),t([]),r(null),o(!1),l(!1),de(void 0),me()},[me]),ft=_.useCallback(async N=>{fe(!1),G.current=N,ge.current=!1;const P=++Te.current;de(N),await Ei(N);const D=await Si(N);Te.current===P&&(t(D?Ai(D.messages):[]),r(null),o((D==null?void 0:D.status)==="running"),l(!1),me())},[me]),Mt=_.useCallback(async()=>{const N=await om();N.ok&&(fe(!1),G.current=N.id,ge.current=!1,Te.current++,t([]),r(null),o(!1),de(N.id),me())},[me]),mn=_.useCallback(async N=>{N===G.current&&(G.current=void 0,ge.current=!1,Te.current++),await lm(N),N===b&&(t([]),r(null),de(void 0)),me()},[b,me]),xn=_.useCallback(async(N,P)=>{await cm(N,P),me()},[me]);_.useEffect(()=>{me()},[me,s]);async function gn(){if(E){const N=await rm();C(!1),N.ok&&N.recordingId&&T({mode:"recording-detail",recordingId:N.recordingId})}else{const N=m??await Ye();if(!N){Rt(f("error_no_tab_record"));return}const P=await nm(N.tabId);P.ok?C(!0):Rt(P.error)}}function Rt(N){y("chat"),t(P=>[...P,{id:te(),role:"system",text:N}])}const bn=_.useCallback(N=>{T({mode:"normal"}),y("chat"),t(P=>[...P,{id:te(),role:"macro-card",macroId:N.id,macroName:N.name,stepCount:(N.markdown.match(/^`[^`]+`\s*$/gm)??[]).length},{id:te(),role:"system",text:f("panel_saved_as",N.name)}])},[]);ve.current=bn;function S(){T({mode:"normal"}),y("chat")}function z(){T({mode:"normal"})}async function B(N){F(!1);const P=!j;P&&(R(!0),y("chat"),V(!0)),(N||P)&&await at({onboarding:{...N?{dismissed:!0}:{},...P?{tourSeen:!0}:{}}})}function Z(){chrome.runtime.openOptionsPage()}function re(){F(!1),T({mode:"normal"}),y("chat"),V(!0),j||(R(!0),at({onboarding:{tourSeen:!0}}))}async function Se(N){d(N),await at({llm:{defaultProviderId:N}})}async function Be(N,P){var ce;F(!1),R(!0),await at({onboarding:{dismissed:!0,tourSeen:!0}}),y("chat");let D=m??await Ye();if((!D||!/^https?:/i.test(D.url))&&(D=await hm(P),D&&g(D)),!D){t([{id:te(),role:"user",text:N},{id:te(),role:"system",text:f("panel_need_tab")}]);return}t([{id:te(),role:"user",text:N}]),o(!0),ge.current=!G.current,(ce=Y.current)==null||ce.startModeA(N,D.tabId,G.current)}async function ze(N,P){var $;T({mode:"normal"}),y("chat"),o(!0);const D=await Xt(N),ce=(D==null?void 0:D.name)??N;t(X=>[...X,{id:te(),role:"system",text:f("panel_starting_macro",ce)}]),ge.current=!G.current,($=Y.current)==null||$.startModeA(Fn(N,ce),P,G.current)}function Ge(N){T({mode:"macro-detail",macroId:N})}const Xe=_.useCallback(N=>{var P;(P=Y.current)==null||P.resumeMacro(N),t(D=>D.map(ce=>ce.role==="macro-wait-user"&&ce.resumeId===N?{...ce,resumed:!0}:ce))},[]),je=_.useCallback(async(N,P)=>{var ce;t($=>$.filter(X=>X.id!==N));const D=m??await Ye();if(!D){t($=>[...$,{id:te(),role:"system",text:f("panel_save_no_tab")}]);return}o(!0),t($=>[...$,{id:te(),role:"system",text:f("panel_saving_macro")}]),ge.current=!G.current,(ce=Y.current)==null||ce.startModeA(Pm(P),D.tabId,G.current)},[m]),qe=_.useCallback(N=>{t(P=>P.filter(D=>D.id!==N))},[]),Le=_.useCallback((N,P)=>{var D;t(ce=>ce.map($=>$.role==="macro-patch-proposal"&&$.patchId===N?{...$,status:P==="accept"?"applying":"rejected"}:$)),(D=Y.current)==null||D.resolvePatch(N,P)},[]),la=_.useCallback((N,P,D)=>{var ce;(ce=Y.current)==null||ce.answerAsk(P,D),t($=>$.map(X=>X.role==="macro-ask"&&X.askId===N?{...X,answered:!0,answer:D}:X))},[]);if(v)return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-col h-screen",children:[i.jsx(qt,{target:m,onPopOut:Wt,onSettings:()=>chrome.runtime.openOptionsPage(),onStartTour:re}),i.jsx(tm,{hasApiKey:L,onDismiss:B,onOpenSettings:Z,onTryExample:Be,onStartTour:re})]}),i.jsx(Ot,{})]});if(I.mode==="recording-detail")return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-col h-screen",children:[i.jsx(qt,{target:m,onPopOut:Wt,onSettings:()=>chrome.runtime.openOptionsPage(),onStartTour:re}),i.jsx(pm,{recordingId:I.recordingId,generating:U,onGenerate:N=>{var P;return(P=Y.current)==null?void 0:P.generateMacroStream(I.recordingId,N)},onDiscard:S,onBack:z})]}),i.jsx(Ot,{})]});if(I.mode==="macro-detail")return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-col h-screen",children:[i.jsx(qt,{target:m,onPopOut:Wt,onSettings:()=>chrome.runtime.openOptionsPage(),onStartTour:re}),i.jsx(If,{macroId:I.macroId,canRun:!!m,onRun:()=>{m&&ze(I.macroId,m.tabId)},onBack:()=>{T({mode:"normal"}),y("macros")},onDeleted:()=>{T({mode:"normal"}),y("macros")}})]}),i.jsx(Ot,{})]});const ca=ae.filter(N=>N.status!=="done").length>=we,ua=ae.filter(N=>N.status==="running"&&N.id!==b).length,da=we>1,st=ae.find(N=>N.id===b),kn=ae.filter(N=>N.interrupted),ha=kn.length>0&&!M;return i.jsxs("div",{className:"flex flex-col h-screen",children:[i.jsx(qt,{target:m,onPopOut:Wt,onSettings:()=>chrome.runtime.openOptionsPage(),onStartTour:re}),i.jsxs("div",{className:"relative",children:[i.jsx(Dm,{tab:w,onTab:y,isRecording:E,onToggleRecording:gn,canResetChat:e.length>0&&w==="chat",onNewChat:fn,onOpenSessions:()=>{fe(N=>!N),me()},bgRunning:ua,canSwitch:da,activeTitle:(st==null?void 0:st.title)||f("sessions_untitled"),activeStatus:(st==null?void 0:st.status)??"idle"}),ye&&i.jsx(Am,{sessions:ae,activeId:b,atLimit:ca,canUpgrade:we<15,onSwitch:ft,onNew:Mt,onDelete:mn,onRename:xn,onClose:()=>fe(!1)})]}),ha&&i.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 border-b border-line-soft bg-brand-bg text-brand-ink text-[12px]",children:[i.jsx(Li,{size:13,strokeWidth:1.6,className:"shrink-0"}),i.jsx("span",{className:"flex-1 min-w-0",children:f("sessions_restored_banner",String(kn.length))}),i.jsx("button",{type:"button",onClick:()=>{const N=kn[0];H(!0),N&&ft(N.id)},className:"shrink-0 font-semibold px-2 py-0.5 rounded border border-[#d8e8a8] hover:bg-bg-app/40",children:f("sessions_resume")}),i.jsx("button",{type:"button",onClick:()=>H(!0),"aria-label":f("sessions_dismiss"),title:f("sessions_dismiss"),className:"shrink-0 w-5 h-5 inline-flex items-center justify-center rounded hover:bg-bg-app/40",children:i.jsx(Fe,{size:12,strokeWidth:1.6})})]}),w==="chat"?i.jsx(sf,{sessionKey:b,messages:e,contextStats:n,displayCurrency:x,providers:c,activeProviderId:h,onSelectModel:Se,onPickElement:zt,onSend:At,onAbort:Tt,busy:s,stopping:a,headless:se,onToggleHeadless:N=>{var P;K(N),(P=Y.current)==null||P.setHeadless(N,G.current),at({execution:{headlessDefault:N}})},onToggleThinking:N=>{const P=c.map(D=>D.id===h?{...D,thinking:N}:D);u(P),at({llm:{providers:P}})},onResumeMacro:Xe,onCreateMacro:je,onDismissMessage:qe,onResolvePatch:Le,onAnswerAsk:la}):w==="macros"?i.jsx(Yf,{target:m,onRun:ze,onOpen:Ge}):i.jsx(wm,{onBack:()=>y("chat"),onOpenMacro:N=>T({mode:"macro-detail",macroId:N})}),i.jsx(Ot,{}),Q&&i.jsx(zm,{onClose:()=>V(!1)})]})}function qt(e){const t=new URLSearchParams(window.location.search).has("popout")||window.location.hash.startsWith("#recording"),[n,r]=_.useState(!1);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"yk-panel-bar",children:[t&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"yk-logo",children:"Y"}),i.jsx("span",{className:"text-md font-semibold tracking-tight",children:"yank"})]}),i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"relative",children:[i.jsx("button",{type:"button",onClick:()=>r(s=>!s),"aria-label":f("login_account_aria"),title:f("login_account_aria"),className:"w-6 h-6 rounded-md inline-flex items-center justify-center text-ink-3 hover:bg-bg-soft hover:text-ink-1",children:i.jsx(oo,{size:14,strokeWidth:1.5})}),n&&i.jsx("div",{className:"absolute right-0 top-7 z-20 w-72 max-w-[90vw]",children:i.jsx(Na,{onLoggedIn:()=>r(!1)})})]}),!t&&i.jsx("button",{type:"button",onClick:e.onPopOut,"aria-label":f("panel_open_window"),title:f("panel_open_window"),className:"w-6 h-6 rounded-md inline-flex items-center justify-center text-ink-3 hover:bg-bg-soft hover:text-ink-1",children:i.jsx(Ya,{size:14,strokeWidth:1.5})}),i.jsx("button",{type:"button",onClick:e.onStartTour,"aria-label":f("panel_help_tour"),title:f("panel_help_tour"),className:"w-6 h-6 rounded-md inline-flex items-center justify-center text-ink-3 hover:bg-bg-soft hover:text-ink-1",children:i.jsx(Ka,{size:14,strokeWidth:1.5})}),i.jsx("button",{type:"button",onClick:e.onSettings,"aria-label":f("panel_settings"),title:f("panel_settings"),className:"w-6 h-6 rounded-md inline-flex items-center justify-center text-ink-3 hover:bg-bg-soft hover:text-ink-1",children:i.jsx(so,{size:14,strokeWidth:1.5})})]}),i.jsx(Rm,{target:e.target})]})}function Rm(e){const t=e.target?Om(e.target.url):null,n=e.target?Wm(e.target.url):null,r=t?Bm(t):"#1a1a17";return i.jsx("div",{className:"px-3.5 py-2.5 border-b border-line-soft bg-bg-app",children:i.jsxs("div",{className:"text-sm text-ink-3 flex items-center gap-1.5 flex-wrap",children:[i.jsx("span",{children:"Working on"}),t?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"text-ink-2 font-mono inline-flex items-center gap-1",children:[i.jsx("span",{className:"w-2 h-2 rounded-sm",style:{background:r},"aria-hidden":"true"}),t]}),n&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-ink-4",children:"›"}),i.jsx("span",{className:"text-ink-3 font-mono truncate max-w-[140px]",title:n,children:n})]})]}):i.jsx("span",{className:"italic text-ink-4",children:"no tab"}),i.jsx("span",{className:"flex-1"}),i.jsx("span",{className:"yk-chip px-1.5 py-px text-xs",children:"BYOK"})]})})}function Lm(e){const t=i.jsx(oa,{status:e.status});return e.canSwitch?i.jsxs("div",{className:"relative","data-tour":"sessions",children:[i.jsxs("button",{type:"button",onClick:e.onOpen,title:f("sessions_switch_tooltip"),className:"inline-flex items-center gap-1.5 max-w-[160px] h-7 px-2 rounded-md text-ink-2 hover:bg-bg-soft hover:text-ink-1",children:[t,i.jsx("span",{className:"truncate text-[12px]",children:e.title}),i.jsx(rn,{size:12,strokeWidth:1.6,className:"shrink-0 text-ink-4"})]}),e.bgRunning?i.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[14px] h-[14px] px-[3px] rounded-full bg-modeA text-white font-mono text-[9px] font-bold inline-flex items-center justify-center border-[1.5px] border-bg-app pointer-events-none",children:e.bgRunning}):null]}):i.jsxs("span",{"data-tour":"sessions",className:"inline-flex items-center gap-1.5 max-w-[150px] h-7 px-2 text-ink-3",title:e.title,children:[t,i.jsx("span",{className:"truncate text-[12px]",children:e.title})]})}function Dm(e){return i.jsxs("div",{className:"yk-tabs",children:[i.jsxs("button",{type:"button",className:`yk-tab ${e.tab==="chat"?"is-on":""}`,onClick:()=>e.onTab("chat"),children:[i.jsx(Zt,{size:13,strokeWidth:1.5}),f("panel_tab_chat"),i.jsx("span",{className:"yk-tab-badge",children:"A"})]}),i.jsxs("button",{type:"button","data-tour":"macros",className:`yk-tab ${e.tab==="macros"?"is-on":""}`,onClick:()=>e.onTab("macros"),children:[i.jsx(to,{size:13,strokeWidth:1.5}),f("panel_tab_macros"),typeof e.macroCount=="number"&&i.jsx("span",{className:"yk-tab-badge",children:e.macroCount})]}),i.jsxs("button",{type:"button","data-tour":"scheduled",className:`yk-tab ${e.tab==="schedule"?"is-on":""}`,onClick:()=>e.onTab("schedule"),children:[i.jsx(nt,{size:13,strokeWidth:1.5}),f("sched_tab")]}),i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"flex items-center gap-1 pb-1",children:[i.jsx(Lm,{title:e.activeTitle,status:e.activeStatus,bgRunning:e.bgRunning,canSwitch:e.canSwitch,onOpen:e.onOpenSessions}),e.canResetChat&&i.jsx("button",{type:"button",onClick:e.onNewChat,"aria-label":f("panel_new_chat"),title:f("panel_new_chat"),className:"w-7 h-7 inline-flex items-center justify-center rounded-md text-ink-3 hover:bg-bg-soft hover:text-ink-1",children:i.jsx(Ja,{size:14,strokeWidth:1.5})}),i.jsx("button",{type:"button","data-tour":"record",onClick:e.onToggleRecording,className:`yk-btn is-sm ${e.isRecording?"border-modeB text-modeB bg-modeB-bg":""}`,style:{paddingTop:3,paddingBottom:3},children:e.isRecording?i.jsxs(i.Fragment,{children:[i.jsx(Ga,{size:12,strokeWidth:2}),f("panel_stop")]}):i.jsxs(i.Fragment,{children:[i.jsx(Wi,{size:10,strokeWidth:0,fill:"currentColor",className:"text-modeB animate-yk-rec"}),f("panel_record")]})})]})]})}function Pm(e){return`[user requested macro save] The user clicked "Save as macro" on the work you just did in this conversation. Look at the tool calls you made and the user's original goal. Call create_macro with: a kebab-case name${e?` — the user wants the name EXACTLY "${e}", use that string`:' (e.g. "github-trending-rust")'}, a one-sentence description, a clean markdown body that keeps ONLY the meaningful steps (drop exploration, corrections, dead ends, any browsing detours), and 1-3 short tags. Where the user would want to vary an input on re-runs, replace the literal with ask("...") → $var. If — honestly — the task was a one-off lookup not worth saving, DON'T call create_macro and tell the user briefly why instead. After saving, reply with ONE short sentence in the user's language naming the macro.`}function Fn(e,t){return`[manual macro trigger] User clicked Run on the saved macro "${t}" (id="${e}"). Use the run_macro tool to execute it.

If the macro has required inputs (frontmatter \`inputs:\` or \`ask(...) → $var\` steps) you don't already have, call read_macro first to see what's needed, then either ask the user in ONE short sentence or use a sensible default if obvious.

After execution finishes, REPORT THE DELIVERABLE — the data the macro's \`description\` promised the user. The user clicked Run to get the OUTCOME, not a status report. Examples:
  - description "get weather for $city" → reply with the actual weather ("北京今天 22°C 多云"), not "macro ran in 4 steps"
  - description "scrape HN top 5" → reply with the 5 titles, not "extracted successfully"
  - description "submit expense $n" → reply with the confirmation number, not "clicked Submit"

Status info (success / "X steps ran" / timings) is at most a trailing aside, usually skip it. If the run failed, lead with what the user wanted that they didn't get ("没拿到天气,站点 captcha 挡了"), then the recovery action. Match the user's language and keep it under 2 short sentences.`}async function Fm(e){const t=await Xt(e);if(t)return t;const n=await Qt({includeArchived:!1});return n.find(r=>r.name===e)??n.find(r=>r.name.toLowerCase()===e.toLowerCase())??n.find(r=>r.id.toLowerCase()===e.toLowerCase())}function Om(e){try{return new URL(e).hostname}catch{return null}}const $m=["#1a1a17","#4870a8","#c96442","#2f8a4a","#8a6a17","#6c4ea3","#b53e2a","#c47a2a"];function Bm(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)>>>0;const n=$m;return n[t%n.length]}function Wm(e){try{const t=new URL(e).pathname;return t==="/"?null:t.replace(/^\//,"")}catch{return null}}function Ti(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r&&r.role===t&&r.streaming)return n;if(r&&(r.role==="tool-call"||r.role==="cost-summary"))return-1}return-1}function Um(e,t){var n;switch(t.kind){case"started":return[...e,{id:te(),role:"system",text:"Starting…"}];case"text-delta":{const r=Ti(e,"assistant");return r>=0?e.map((s,o)=>o===r&&s.role==="assistant"?{...s,text:s.text+t.text}:s):[...e,{id:te(),role:"assistant",text:t.text,streaming:!0}]}case"reasoning-delta":{const r=Ti(e,"thinking");return r>=0?e.map((s,o)=>o===r&&s.role==="thinking"?{...s,text:s.text+t.text}:s):[...e,{id:te(),role:"thinking",text:t.text,streaming:!0}]}case"tool-use-start":return[...xt(e),{id:t.toolUseId,role:"tool-call",tool:t.tool,input:t.input,status:"running"}];case"tool-use-result":return e.map(r=>r.id===t.toolUseId&&r.role==="tool-call"?{...r,status:t.result.ok?"success":"failed",error:t.result.error,data:t.result.data}:r);case"completed":{const r=xt(e);if(t.cost&&r.push(zi(t.cost)),t.recordingId){const s=r.filter(o=>!(o.role==="suggestions"&&o.recordingId===t.recordingId));return s.push({id:te(),role:"suggestions",recordingId:t.recordingId}),s}return t.cost||r.push({id:te(),role:"system",text:f("panel_done")}),r}case"error":{const r=xt(e);return r.push({id:te(),role:"system",text:`Error: ${t.error}`}),t.cost&&r.push(zi(t.cost)),r}case"aborted":return[...xt(e),{id:te(),role:"system",text:"Aborted."}];case"step-progress":return e;case"context-stats":return e;case"compression-start":return[...e,{id:te(),role:"compression",mode:t.mode,status:"running"}];case"compression-done":for(let r=e.length-1;r>=0;r--){const s=e[r];if(s&&s.role==="compression"&&s.status==="running"&&s.mode===t.mode){const o=[...e];return o[r]={...s,status:"done",savedTokens:t.savedTokens,compressedCount:t.compressedCount},o}}return[...e,{id:te(),role:"compression",mode:t.mode,status:"done",savedTokens:t.savedTokens,compressedCount:t.compressedCount}];case"macro-run-started":return[...e,{id:`macro-run-${t.runId}`,role:"macro-run",runId:t.runId,macroName:t.macroName,status:"running"}];case"macro-run-finished":{const r=`macro-run-${t.runId}`,s=t.result.ok?"success":"failed";return e.some(a=>a.id===r&&a.role==="macro-run")?e.map(a=>{var l;return a.id===r&&a.role==="macro-run"?{...a,status:s,durationMs:t.result.durationMs,failedReason:t.result.failedReason??void 0,failedProGate:t.result.proGate,failedStepSource:(l=t.failedStep)==null?void 0:l.source}:a}):[...e,{id:r,role:"macro-run",runId:t.runId,macroName:t.macroName,status:s,durationMs:t.result.durationMs,failedReason:t.result.failedReason??void 0,failedProGate:t.result.proGate,failedStepSource:(n=t.failedStep)==null?void 0:n.source}]}case"macro-step-start":{const r=t.step;return[...e,{id:`macro-step-${t.runId}-${t.index}`,role:"tool-call",tool:r.tool,input:{source:r.source,index:t.index},status:"running",runId:t.runId,...r.description?{description:r.description}:{}}]}case"macro-step-end":{const r=`macro-step-${t.runId}-${t.index}`,s=t.result;return e.map(o=>o.id===r&&o.role==="tool-call"?{...o,status:s.ok?"success":"failed",error:s.error,data:s.data}:o)}case"macro-notify":return[...e,{id:te(),role:"macro-notify",runId:t.runId,message:t.message,screenshotBase64:t.screenshotBase64,...t.description?{description:t.description}:{}}];case"macro-wait-user":return[...e,{id:te(),role:"macro-wait-user",runId:t.runId,reason:t.reason,screenshotBase64:t.screenshotBase64,resumeId:t.resumeId,resumed:!1,...t.description?{description:t.description}:{}}];case"macro-ask":{const s=t.askId.startsWith("mode-a:")?void 0:t.askId.indexOf(":")>0?t.askId.slice(0,t.askId.indexOf(":")):void 0;return[...e,{id:`ask-${t.askId}`,role:"macro-ask",askId:t.askId,varName:t.varName,question:t.question,...s?{runId:s}:{},...t.default?{defaultValue:t.default}:{},answered:!1}]}case"macro-patch-proposal":return[...e,{id:`patch-${t.patchId}`,role:"macro-patch-proposal",patchId:t.patchId,macroId:t.macroId,macroName:t.macroName,fromVersion:t.fromVersion,confidence:t.confidence,reasoning:t.reasoning,diff:t.diff,status:"pending"}];case"macro-patch-resolved":return e.map(r=>r.role==="macro-patch-proposal"&&r.patchId===t.patchId?{...r,status:t.status==="accepted"?"accepted":t.status==="superseded"?"superseded":"rejected",newVersion:t.newVersion,error:t.error}:r);case"macro-heal-status":return e.map(r=>r.id===`macro-run-${t.runId}`&&r.role==="macro-run"?{...r,healState:t.status,healError:t.error,healsUsed:t.healsUsed,healLimit:t.healLimit}:r);case"system-note":return[...xt(e),{id:te(),role:"system",text:t.text}];default:return e}}function zi(e){return{id:te(),role:"cost-summary",totalUsd:e.totalUsd,cacheSavedUsd:e.cacheSavedUsd,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cacheReadTokens:e.cacheReadTokens,cacheCreationTokens:e.cacheCreationTokens}}function xt(e){return e.map(t=>(t.role==="assistant"||t.role==="thinking")&&t.streaming?{...t,streaming:!1}:t)}async function Hm(){await Ea();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");Ca(e).render(i.jsx(Mm,{}))}Hm();
