const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["https://assets-proxy.anthropic.com/claude-ai/v2/assets/v1/cbf688cef-Du5kDrAA.css","https://assets-proxy.anthropic.com/claude-ai/v2/assets/v1/c5aee9dbd-B-Ow-NeO.css","https://assets-proxy.anthropic.com/claude-ai/v2/assets/v1/vendor-ant-cds-G1fENYYx.css","https://assets-proxy.anthropic.com/claude-ai/v2/assets/v1/c818056db-BjS1Z-Ak.css"])))=>i.map(i=>d[i]);
import{r as e,j as t,_ as n,a as s}from"./vendor-react-RSDKEZ60.js";import{O as r}from"./cf8b75fc3-Bls3eu7n.js";import{u as o,M as i}from"./vendor-intl-BNW8a19h.js";import{xg as a,bb as l,a0 as c,xh as u,xi as d,y as f,cZ as h,jE as m,xj as p,g1 as g,xk as x,jH as y,jI as b,f as v,xl as w,jJ as k,b_ as S,xm as C,gI as N,gJ as E,xn as j,gD as M,gG as L,xo as T,gH as O,xp as A,xq as R,b9 as I,jx as _,c_ as D,ue as $,xr as F,xs as P,xt as q,xu as B,xv as K,uw as z,uu as H,xw as U,xx as W,fd as Y,xy as X,V,xz as J,xA as G,t as Q,xB as Z,wR as ee,uy as te,xC as ne,xD as se,xE as re,h as oe,jb as ie,uz as ae,xF as le,xG as ce,aq as ue,hz as de,xH as fe,xI as he,xJ as me,gt as pe,gu as ge,xK as xe,gv as ye,w as be,x as ve,hJ as we,xL as ke,xM as Se,xN as Ce,jz as Ne,ut as Ee,ur as je,m as Me,xO as Le,P as Te,fe as Oe,a2 as Ae}from"./c818056db-BBpc4u6S.js";import{t as Re,aJ as Ie}from"./vendor-icons-CjJMeNuY.js";import{R as _e}from"./c0e977562-Cl8xDjBD.js";import{p as De,u as $e,B as Fe,U as Pe,m as qe,d as Be,k as Ke,T as ze,I as He,G as Ue,f as We,i as Ye}from"./vendor-ant-cds-CBh5POw1.js";import{K as Xe,L as Ve}from"./vendor-lodash-wKOE1Xsv.js";import{A as Je,m as Ge,a as Qe,c as Ze,u as et,f as tt,g as nt,h as st}from"./vendor-motion-Bnihp5FA.js";import{C as rt}from"./cdd5b9598-yqo6iFZ3.js";import{K as ot,L as it,M as at,N as lt,O as ct,Q as ut,S as dt,U as ft,W as ht,X as mt,Y as pt,Z as gt,_ as xt,$ as yt}from"./vendor-radix-qP6Vhe7Y.js";import{D as bt}from"./vendor-luxon-CuMIhNDL.js";import{E as vt}from"./c9bba154c-C96xRtPW.js";import{C as wt}from"./c1f96d614-fszDh6Jj.js";import{u as kt}from"./cc2e285cb-C7M5SPGc.js";function St(t,n){const s="number"==typeof n?n:n.delay,r="number"!=typeof n&&n.flushOnUnmount,o="number"!=typeof n&&n.leading,i=function(t){const n=e.useRef(t);return e.useEffect(()=>{n.current=t}),e.useMemo(()=>(...e)=>n.current?.(...e),[])}(t),a=e.useRef(0),l=e.useRef(()=>{}),c=e.useRef(o),u=Object.assign(e.useCallback((...e)=>{if(window.clearTimeout(a.current),o&&c.current)return c.current=!1,void i(...e);const t=()=>{0!==a.current&&(a.current=0,c.current=!0,i(...e))};l.current=t,u.flush=t,a.current=window.setTimeout(t,s),c.current=!1},[i,s,o]),{flush:l.current});return e.useEffect(()=>()=>{window.clearTimeout(a.current),r&&u.flush()},[u,r]),u}function Ct(e){return a("localStorage","use-local-storage")(e)}const Nt=e=>t.jsx(l,{...e,children:t.jsx("path",{d:"M10 3a.5.5 0 0 1 .354.146l5 5a.5.5 0 0 1-.707.708L10.5 4.707V16.5a.5.5 0 0 1-1 0V4.707L5.354 8.854a.5.5 0 0 1-.708-.708l5-5 .077-.062A.5.5 0 0 1 10 3"})}),Et=e=>t.jsx(l,{...e,children:t.jsx("path",{d:"M4.5 8.5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3m5.5 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3m5.5 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3"})}),jt=e=>t.jsx(l,{...e,children:t.jsx("path",{d:"M3 4.605A1.5 1.5 0 0 1 5.161 3.26l10.983 5.394.101.055c.983.574.983 2.01 0 2.584l-.101.055L5.16 16.74A1.5 1.5 0 0 1 3 15.395zm1.72-.449a.5.5 0 0 0-.72.45V9.5h5.5a.5.5 0 0 1 0 1H4v4.895a.5.5 0 0 0 .72.449l10.982-5.395.066-.039a.5.5 0 0 0 0-.82l-.066-.04z"})}),Mt={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",xml:"xml",css:"css",scss:"scss",sass:"sass",less:"less",py:"python",pyw:"python",java:"java",kt:"kotlin",kts:"kotlin",c:"c",cpp:"cpp",cc:"cpp",cxx:"cpp",h:"c",hpp:"cpp",cs:"c_sharp",go:"go",rs:"rust",rb:"ruby",php:"php",swift:"swift",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",ini:"ini",md:"markdown",mdx:"markdown",sql:"sql",dockerfile:"dockerfile",makefile:"makefile",cmake:"cmake",graphql:"graphql",gql:"graphql"},Lt={typescript:"typescript",javascript:"javascript",python:"python",rust:"rust",go:"go",java:"java",cpp:"cpp",c:"c",c_sharp:"c_sharp",php:"php",ruby:"ruby",swift:"swift",kotlin:"kotlin",scala:"scala",html:"html",css:"css",json:"json",yaml:"yaml",toml:"toml",sql:"sql",bash:"bash",dockerfile:"dockerfile",markdown:"markdown",ts:"typescript",tsx:"tsx",js:"javascript",jsx:"javascript",py:"python",md:"markdown",sh:"bash",shell:"bash",csharp:"c_sharp"},Tt={typescript:"/tree-sitter/typescript/tree-sitter-typescript.wasm",tsx:"/tree-sitter/tsx/tree-sitter-tsx.wasm",javascript:"/tree-sitter/javascript/tree-sitter-javascript.wasm",python:"/tree-sitter/python/tree-sitter-python.wasm",rust:"/tree-sitter/rust/tree-sitter-rust.wasm",go:"/tree-sitter/go/tree-sitter-go.wasm",java:"/tree-sitter/java/tree-sitter-java.wasm",cpp:"/tree-sitter/cpp/tree-sitter-cpp.wasm",c:"/tree-sitter/c/tree-sitter-c.wasm",ruby:"/tree-sitter/ruby/tree-sitter-ruby.wasm",php:"/tree-sitter/php/tree-sitter-php.wasm",bash:"/tree-sitter/bash/tree-sitter-bash.wasm",css:"/tree-sitter/css/tree-sitter-css.wasm",html:"/tree-sitter/html/tree-sitter-html.wasm",json:"/tree-sitter/json/tree-sitter-json.wasm",yaml:"/tree-sitter/yaml/tree-sitter-yaml.wasm",markdown:"/tree-sitter/markdown/tree-sitter-markdown.wasm"},Ot={typescript:"/tree-sitter/typescript/highlights.scm",tsx:"/tree-sitter/tsx/highlights.scm",javascript:"/tree-sitter/javascript/highlights.scm",python:"/tree-sitter/python/highlights.scm",rust:"/tree-sitter/rust/highlights.scm",go:"/tree-sitter/go/highlights.scm",java:"/tree-sitter/java/highlights.scm",cpp:"/tree-sitter/cpp/highlights.scm",c:"/tree-sitter/c/highlights.scm",ruby:"/tree-sitter/ruby/highlights.scm",php:"/tree-sitter/php/highlights.scm",bash:"/tree-sitter/bash/highlights.scm",css:"/tree-sitter/css/highlights.scm",html:"/tree-sitter/html/highlights.scm",json:"/tree-sitter/json/highlights.scm",yaml:"/tree-sitter/yaml/highlights.scm",markdown:"/tree-sitter/markdown/highlights.scm"};function At(e){switch(e){case"remove":return"bg-danger-900/45 dark:bg-danger-900/35";case"add":return"bg-[hsla(130,35%,88%,0.45)] dark:bg-success-900/35";case null:return"bg-bg-100";default:return"bg-bg-000"}}function Rt(e){switch(e){case"remove":return"border-l-[3px] border-l-danger-100";case"add":return"border-l-[3px] border-l-success-100";default:return"border-l-[3px] border-l-transparent"}}function It(e){switch(e){case"add":return"text-success-100";case"remove":return"text-danger-100";default:return"text-text-400"}}function _t(e){switch(e){case"add":return"text-success-000 font-bold";case"remove":return"text-danger-000 font-bold";default:return"text-text-500"}}function Dt(e){switch(e){case"add":return"hover:bg-[hsla(130,35%,88%,0.9)] dark:hover:bg-success-900/60";case"remove":return"hover:bg-danger-900/90 dark:hover:bg-danger-900/60";default:return"hover:bg-bg-100"}}function $t(e,t,n){if(e)return{}}function Ft(e){return e?"relative":""}const Pt=({handleClose:e,title:n,description:s,inset:r,action:o})=>t.jsxs("div",{className:"border-border-300 shadow-sm w-[300px] max-w-full bg-bg-000 rounded-xl p-5 border relative",children:[t.jsx("div",{className:"text-left mb-2 font-medium text-sm",children:n}),t.jsx("p",{className:"mb-2 text-sm",children:s}),!!r&&t.jsx("div",{className:"flex flex-col rounded-md bg-text-000/5 p-4 font-mono text-xs text-text-300",children:r}),o&&t.jsx("div",{className:"flex justify-end",children:t.jsx(c,{variant:"primary",className:"mt-4 text-sm",onClick:o.onClick,disabled:o.disabled,loading:o.loading,children:o.label})}),t.jsx("div",{className:"absolute top-2 right-2",children:t.jsx(c,{variant:"ghost",onClick:e,className:"h-9 w-9 !min-w-9",children:t.jsx(Re,{})})})]});const qt=({error:n,handleClose:s,sendMessage:r,isStreaming:i})=>{const[a,l]=e.useState(!1),c=o(),u=function(e,t){switch(e.type){case"UnsupportedImports":return{title:t?t.formatMessage({defaultMessage:"Artifact failed to load",id:"NcDXiSfIPe"}):"Artifact failed to load",description:t?t.formatMessage({defaultMessage:"The generated artifact uses libraries we don\u2019t support:",id:"HG0Hu8xIQA"}):"The generated artifact uses libraries we don\u2019t support:",inset:[...e.unsupportedModules,...e.nonExistentIcons.map(e=>`{ ${e} } from "lucide-react"`)],subtext:t?t.formatMessage({defaultMessage:"The code itself may still work. To use it, you\u2019ll need a development setup with these libraries installed.",id:"Et/uvuRBba"}):"The code itself may still work. To use it, you\u2019ll need a development setup with these libraries installed."};case"RuntimeError":return{title:t?t.formatMessage({defaultMessage:"Error running artifact",id:"JU2kK1J3jY"}):"Error running artifact",description:t?t.formatMessage({defaultMessage:"An error occurred while trying to run the generated artifact.",id:"3RpkNRAyPc"}):"An error occurred while trying to run the generated artifact.",inset:[e.message],insetStyle:"danger"};case"FileNotFound":return{title:t?t.formatMessage({defaultMessage:"File not found",id:"gcaJtRf4b0"}):"File not found",description:t?t.formatMessage({defaultMessage:"The file \u201c{fileName}\u201d could not be found.",id:"0kOCGtB3eN"},{fileName:e.fileName}):`The file \u201c${e.fileName}\u201d could not be found.`,subtext:t?t.formatMessage({defaultMessage:"Please check the file name and try again.",id:"/fdYJU5SMC"}):"Please check the file name and try again."};case"ClaudeCompletionError":return{title:t?t.formatMessage({defaultMessage:"Error in Claude completion",id:"ya5HK9oB9T"}):"Error in Claude completion",description:e.message};case"ArtifactStorageError":return{title:t?t.formatMessage({defaultMessage:"Error accessing shared data",id:"hjqZygykww"}):"Error accessing shared data",description:e.message}}}(n.error,c),d=`> ${u.description}\n  ${u.inset?.map(e=>`> \`${e}\``).join("\n")??""}\n  \n\n  Can you fix this error in \`${n.artifactId}\`?`,f=r?{label:c.formatMessage({defaultMessage:"Try fixing with Claude",id:"wrcoZ2Zo0b"}),onClick:()=>{l(!0),r?.({prompt:d,attachments:[],files:[],syncSources:[]})},disabled:i,loading:a}:void 0;return t.jsx("div",{className:"absolute bottom-5 left-5 right-5",children:t.jsx(Pt,{title:u.title,description:u.description,handleClose:s,inset:u.inset?.length?u.inset?t.jsx("ul",{children:u.inset.map((e,n)=>t.jsx("li",{children:e},n))}):null:void 0,action:f})})},Bt=e.forwardRef(({className:n,children:s,disabled:r,noDefaultScroll:o,initialScrollState:i,onScrollChange:a},l)=>{const c=e.useRef(0),u=e.useRef(i?.isPinned??!0),d=e.useRef(!1),f=e.useRef(null),h=e.useCallback((e="auto")=>{f.current&&u.current&&(f.current.scrollHeight-f.current.clientHeight<f.current.scrollTop||f.current&&"function"==typeof f.current.scrollTo&&f.current?.scrollTo({top:f.current?.scrollHeight-f.current?.clientHeight+5,behavior:e}))},[]),m=e.useCallback(e=>{f.current&&f.current&&"function"==typeof f.current.scrollTo&&(f.current.style.overflow="hidden",f.current?.scrollTo({top:f.current?.scrollHeight*e-f.current?.clientHeight/2,behavior:"auto"}))},[]),p=e.useCallback(()=>{f.current&&(f.current.style.overflow="")},[]);e.useImperativeHandle(l,()=>({reset(){c.current=0,u.current=!0,o||h()},scrollToBottomIfPinned:h,scrollToPercentage:m,enableScrolling:p,getScrollContainer:()=>f.current}),[h,m,p,o]),e.useLayoutEffect(()=>{if(!r&&s&&!o)if(i&&!d.current){if(!f.current)return;const e=f.current.scrollHeight-f.current.clientHeight;i.isPinned?e>0&&(d.current=!0,h()):e>=i.scrollTop&&(d.current=!0,c.current=i.scrollTop,f.current.scrollTo({top:i.scrollTop,behavior:"auto"}))}else h()},[s,r,h,o,i]);return t.jsx("div",{className:n,onScroll:e=>{if(r)return;const t=e.currentTarget.scrollTop,n=function(e,t){if(e){const n=e.scrollHeight-8;return Math.ceil(t+e.offsetHeight)>=Math.floor(n)}return!1}(f.current,t),s=t>c.current;n&&s?u.current=!0:n||s||(u.current=!1),c.current=t,a&&a({scrollTop:t,isPinned:u.current})},ref:f,children:s})});Bt.displayName="AutoScroll";const Kt=Symbol.for("yaml.alias"),zt=Symbol.for("yaml.document"),Ht=Symbol.for("yaml.map"),Ut=Symbol.for("yaml.pair"),Wt=Symbol.for("yaml.scalar"),Yt=Symbol.for("yaml.seq"),Xt=Symbol.for("yaml.node.type"),Vt=e=>!!e&&"object"==typeof e&&e[Xt]===Kt,Jt=e=>!!e&&"object"==typeof e&&e[Xt]===zt,Gt=e=>!!e&&"object"==typeof e&&e[Xt]===Ht,Qt=e=>!!e&&"object"==typeof e&&e[Xt]===Ut,Zt=e=>!!e&&"object"==typeof e&&e[Xt]===Wt,en=e=>!!e&&"object"==typeof e&&e[Xt]===Yt;function tn(e){if(e&&"object"==typeof e)switch(e[Xt]){case Ht:case Yt:return!0}return!1}function nn(e){if(e&&"object"==typeof e)switch(e[Xt]){case Kt:case Ht:case Wt:case Yt:return!0}return!1}const sn=e=>(Zt(e)||tn(e))&&!!e.anchor,rn=Symbol("break visit"),on=Symbol("skip children"),an=Symbol("remove node");function ln(e,t){const n=function(e){if("object"==typeof e&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}(t);if(Jt(e)){cn(null,e.contents,n,Object.freeze([e]))===an&&(e.contents=null)}else cn(null,e,n,Object.freeze([]))}function cn(e,t,n,s){const r=function(e,t,n,s){return"function"==typeof n?n(e,t,s):Gt(t)?n.Map?.(e,t,s):en(t)?n.Seq?.(e,t,s):Qt(t)?n.Pair?.(e,t,s):Zt(t)?n.Scalar?.(e,t,s):Vt(t)?n.Alias?.(e,t,s):void 0}(e,t,n,s);if(nn(r)||Qt(r))return function(e,t,n){const s=t[t.length-1];if(tn(s))s.items[e]=n;else if(Qt(s))"key"===e?s.key=n:s.value=n;else{if(!Jt(s)){const e=Vt(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${e} parent`)}s.contents=n}}(e,s,r),cn(e,r,n,s);if("symbol"!=typeof r)if(tn(t)){s=Object.freeze(s.concat(t));for(let e=0;e<t.items.length;++e){const r=cn(e,t.items[e],n,s);if("number"==typeof r)e=r-1;else{if(r===rn)return rn;r===an&&(t.items.splice(e,1),e-=1)}}}else if(Qt(t)){s=Object.freeze(s.concat(t));const e=cn("key",t.key,n,s);if(e===rn)return rn;e===an&&(t.key=null);const r=cn("value",t.value,n,s);if(r===rn)return rn;r===an&&(t.value=null)}return r}ln.BREAK=rn,ln.SKIP=on,ln.REMOVE=an;const un={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},dn=e=>e.replace(/[!,[\]{}]/g,e=>un[e]);class fn{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},fn.defaultYaml,e),this.tags=Object.assign({},fn.defaultTags,t)}clone(){const e=new fn(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new fn(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:fn.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},fn.defaultTags)}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:fn.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},fn.defaultTags),this.atNextDocument=!1);const n=e.trim().split(/[ \t]+/),s=n.shift();switch(s){case"%TAG":{if(2!==n.length&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;const[e,s]=n;return this.tags[e]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==n.length)return t(0,"%YAML directive should contain exactly one part"),!1;const[e]=n;if("1.1"===e||"1.2"===e)return this.yaml.version=e,!0;return t(6,`Unsupported YAML version ${e}`,/^\d+\.\d+$/.test(e)),!1}default:return t(0,`Unknown directive ${s}`,!0),!1}}tagName(e,t){if("!"===e)return"!";if("!"!==e[0])return t(`Not a valid tag: ${e}`),null;if("<"===e[1]){const n=e.slice(2,-1);return"!"===n||"!!"===n?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(">"!==e[e.length-1]&&t("Verbatim tags must end with a >"),n)}const[,n,s]=e.match(/^(.*!)([^!]*)$/s);s||t(`The ${e} tag has no suffix`);const r=this.tags[n];if(r)try{return r+decodeURIComponent(s)}catch(o){return t(String(o)),null}return"!"===n?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(const[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+dn(e.substring(n.length));return"!"===e[0]?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags);let s;if(e&&n.length>0&&nn(e.contents)){const t={};ln(e.contents,(e,n)=>{nn(n)&&n.tag&&(t[n.tag]=!0)}),s=Object.keys(t)}else s=[];for(const[r,o]of n)"!!"===r&&"tag:yaml.org,2002:"===o||e&&!s.some(e=>e.startsWith(o))||t.push(`%TAG ${r} ${o}`);return t.join("\n")}}function hn(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const t=JSON.stringify(e);throw new Error(`Anchor must not contain whitespace or control characters: ${t}`)}return!0}function mn(e){const t=new Set;return ln(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function pn(e,t){for(let n=1;;++n){const s=`${e}${n}`;if(!t.has(s))return s}}function gn(e,t,n,s){if(s&&"object"==typeof s)if(Array.isArray(s))for(let r=0,o=s.length;r<o;++r){const t=s[r],n=gn(e,s,String(r),t);void 0===n?delete s[r]:n!==t&&(s[r]=n)}else if(s instanceof Map)for(const r of Array.from(s.keys())){const t=s.get(r),n=gn(e,s,r,t);void 0===n?s.delete(r):n!==t&&s.set(r,n)}else if(s instanceof Set)for(const r of Array.from(s)){const t=gn(e,s,r,r);void 0===t?s.delete(r):t!==r&&(s.delete(r),s.add(t))}else for(const[r,o]of Object.entries(s)){const t=gn(e,s,r,o);void 0===t?delete s[r]:t!==o&&(s[r]=t)}return e.call(t,n,s)}function xn(e,t,n){if(Array.isArray(e))return e.map((e,t)=>xn(e,String(t),n));if(e&&"function"==typeof e.toJSON){if(!n||!sn(e))return e.toJSON(t,n);const s={aliasCount:0,count:1,res:void 0};n.anchors.set(e,s),n.onCreate=e=>{s.res=e,delete n.onCreate};const r=e.toJSON(t,n);return n.onCreate&&n.onCreate(r),r}return"bigint"!=typeof e||n?.keep?e:Number(e)}fn.defaultYaml={explicit:!1,version:"1.2"},fn.defaultTags={"!!":"tag:yaml.org,2002:"};class yn{constructor(e){Object.defineProperty(this,Xt,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:s,reviver:r}={}){if(!Jt(e))throw new TypeError("A document argument is required");const o={anchors:new Map,doc:e,keep:!0,mapAsMap:!0===t,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},i=xn(this,"",o);if("function"==typeof s)for(const{count:a,res:l}of o.anchors.values())s(l,a);return"function"==typeof r?gn(r,{"":i},"",i):i}}class bn extends yn{constructor(e){super(Kt),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){if(0===t?.maxAliasCount)throw new ReferenceError("Alias resolution is disabled");let n,s;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],ln(e,{Node:(e,t)=>{(Vt(t)||sn(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));for(const r of n){if(r===this)break;r.anchor===this.source&&(s=r)}return s}toJSON(e,t){if(!t)return{source:this.source};const{anchors:n,doc:s,maxAliasCount:r}=t,o=this.resolve(s,t);if(!o){const e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(e)}let i=n.get(o);if(i||(xn(o,null,t),i=n.get(o)),void 0===i?.res){throw new ReferenceError("This should not happen: Alias anchor was not resolved?")}if(r>=0&&(i.count+=1,0===i.aliasCount&&(i.aliasCount=vn(s,o,n)),i.count*i.aliasCount>r)){throw new ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return i.res}toString(e,t,n){const s=`*${this.source}`;if(e){if(hn(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(e)}if(e.implicitKey)return`${s} `}return s}}function vn(e,t,n){if(Vt(t)){const s=t.resolve(e),r=n&&s&&n.get(s);return r?r.count*r.aliasCount:0}if(tn(t)){let s=0;for(const r of t.items){const t=vn(e,r,n);t>s&&(s=t)}return s}if(Qt(t)){const s=vn(e,t.key,n),r=vn(e,t.value,n);return Math.max(s,r)}return 1}const wn=e=>!e||"function"!=typeof e&&"object"!=typeof e;class kn extends yn{constructor(e){super(Wt),this.value=e}toJSON(e,t){return t?.keep?this.value:xn(this.value,e,t)}toString(){return String(this.value)}}kn.BLOCK_FOLDED="BLOCK_FOLDED",kn.BLOCK_LITERAL="BLOCK_LITERAL",kn.PLAIN="PLAIN",kn.QUOTE_DOUBLE="QUOTE_DOUBLE",kn.QUOTE_SINGLE="QUOTE_SINGLE";function Sn(e,t,n){if(Jt(e)&&(e=e.contents),nn(e))return e;if(Qt(e)){const t=n.schema[Ht].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||"undefined"!=typeof BigInt&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:s,onAnchor:r,onTagObj:o,schema:i,sourceObjects:a}=n;let l;if(s&&e&&"object"==typeof e){if(l=a.get(e),l)return l.anchor??(l.anchor=r(e)),new bn(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t="tag:yaml.org,2002:"+t.slice(2));let c=function(e,t,n){if(t){const e=n.filter(e=>e.tag===t),s=e.find(e=>!e.format)??e[0];if(!s)throw new Error(`Tag ${t} not found`);return s}return n.find(t=>t.identify?.(e)&&!t.format)}(e,t,i.tags);if(!c){if(e&&"function"==typeof e.toJSON&&(e=e.toJSON()),!e||"object"!=typeof e){const t=new kn(e);return l&&(l.node=t),t}c=e instanceof Map?i[Ht]:Symbol.iterator in Object(e)?i[Yt]:i[Ht]}o&&(o(c),delete n.onTagObj);const u=c?.createNode?c.createNode(n.schema,e,n):"function"==typeof c?.nodeClass?.from?c.nodeClass.from(n.schema,e,n):new kn(e);return t?u.tag=t:c.default||(u.tag=c.tag),l&&(l.node=u),u}function Cn(e,t,n){let s=n;for(let r=t.length-1;r>=0;--r){const e=t[r];if("number"==typeof e&&Number.isInteger(e)&&e>=0){const t=[];t[e]=s,s=t}else s=new Map([[e,s]])}return Sn(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const Nn=e=>null==e||"object"==typeof e&&!!e[Symbol.iterator]().next().done;class En extends yn{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>nn(t)||Qt(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Nn(e))this.add(t);else{const[n,...s]=e,r=this.get(n,!0);if(tn(r))r.addIn(s,t);else{if(void 0!==r||!this.schema)throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`);this.set(n,Cn(this.schema,s,t))}}}deleteIn(e){const[t,...n]=e;if(0===n.length)return this.delete(t);const s=this.get(t,!0);if(tn(s))return s.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){const[n,...s]=e,r=this.get(n,!0);return 0===s.length?!t&&Zt(r)?r.value:r:tn(r)?r.getIn(s,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!Qt(t))return!1;const n=t.value;return null==n||e&&Zt(n)&&null==n.value&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){const[t,...n]=e;if(0===n.length)return this.has(t);const s=this.get(t,!0);return!!tn(s)&&s.hasIn(n)}setIn(e,t){const[n,...s]=e;if(0===s.length)this.set(n,t);else{const e=this.get(n,!0);if(tn(e))e.setIn(s,t);else{if(void 0!==e||!this.schema)throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`);this.set(n,Cn(this.schema,s,t))}}}}const jn=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Mn(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const Ln=(e,t,n)=>e.endsWith("\n")?Mn(n,t):n.includes("\n")?"\n"+Mn(n,t):(e.endsWith(" ")?"":" ")+n,Tn="flow",On="block",An="quoted";function Rn(e,t,n="flow",{indentAtStart:s,lineWidth:r=80,minContentWidth:o=20,onFold:i,onOverflow:a}={}){if(!r||r<0)return e;r<o&&(o=0);const l=Math.max(1+o,1+r-t.length);if(e.length<=l)return e;const c=[],u={};let d,f,h=r-t.length;"number"==typeof s&&(s>r-Math.max(2,o)?c.push(0):h=r-s);let m=!1,p=-1,g=-1,x=-1;n===On&&(p=In(e,p,t.length),-1!==p&&(h=p+l));for(let b;b=e[p+=1];){if(n===An&&"\\"===b){switch(g=p,e[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}x=p}if("\n"===b)n===On&&(p=In(e,p,t.length)),h=p+t.length+l,d=void 0;else{if(" "===b&&f&&" "!==f&&"\n"!==f&&"\t"!==f){const t=e[p+1];t&&" "!==t&&"\n"!==t&&"\t"!==t&&(d=p)}if(p>=h)if(d)c.push(d),h=d+l,d=void 0;else if(n===An){for(;" "===f||"\t"===f;)f=b,b=e[p+=1],m=!0;const t=p>x+1?p-2:g-1;if(u[t])return e;c.push(t),u[t]=!0,h=t+l,d=void 0}else m=!0}f=b}if(m&&a&&a(),0===c.length)return e;i&&i();let y=e.slice(0,c[0]);for(let b=0;b<c.length;++b){const s=c[b],r=c[b+1]||e.length;0===s?y=`\n${t}${e.slice(0,r)}`:(n===An&&u[s]&&(y+=`${e[s]}\\`),y+=`\n${t}${e.slice(s+1,r)}`)}return y}function In(e,t,n){let s=t,r=t+1,o=e[r];for(;" "===o||"\t"===o;)if(t<r+n)o=e[++t];else{do{o=e[++t]}while(o&&"\n"!==o);s=t,r=t+1,o=e[r]}return s}const _n=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Dn=e=>/^(%|---|\.\.\.)/m.test(e);function $n(e,t){const n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;const{implicitKey:s}=t,r=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(Dn(e)?"  ":"");let i="",a=0;for(let l=0,c=n[l];c;c=n[++l])if(" "===c&&"\\"===n[l+1]&&"n"===n[l+2]&&(i+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),"\\"===c)switch(n[l+1]){case"u":{i+=n.slice(a,l);const e=n.substr(l+2,4);switch(e){case"0000":i+="\\0";break;case"0007":i+="\\a";break;case"000b":i+="\\v";break;case"001b":i+="\\e";break;case"0085":i+="\\N";break;case"00a0":i+="\\_";break;case"2028":i+="\\L";break;case"2029":i+="\\P";break;default:"00"===e.substr(0,2)?i+="\\x"+e.substr(2):i+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(s||'"'===n[l+2]||n.length<r)l+=1;else{for(i+=n.slice(a,l)+"\n\n";"\\"===n[l+2]&&"n"===n[l+3]&&'"'!==n[l+4];)i+="\n",l+=2;i+=o," "===n[l+2]&&(i+="\\"),l+=1,a=l+1}break;default:l+=1}return i=a?i+n.slice(a):n,s?i:Rn(i,o,An,_n(t,!1))}function Fn(e,t){if(!1===t.options.singleQuote||t.implicitKey&&e.includes("\n")||/[ \t]\n|\n[ \t]/.test(e))return $n(e,t);const n=t.indent||(Dn(e)?"  ":""),s="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&\n${n}`)+"'";return t.implicitKey?s:Rn(s,n,Tn,_n(t,!1))}function Pn(e,t){const{singleQuote:n}=t.options;let s;if(!1===n)s=$n;else{const t=e.includes('"'),r=e.includes("'");s=t&&!r?Fn:r&&!t?$n:n?Fn:$n}return s(e,t)}let qn;try{qn=new RegExp("(^|(?<!\n))\n+(?!\n|$)","g")}catch{qn=/\n+(?!\n|$)/g}function Bn({comment:e,type:t,value:n},s,r,o){const{blockQuote:i,commentString:a,lineWidth:l}=s.options;if(!i||/\n[\t ]+$/.test(n))return Pn(n,s);const c=s.indent||(s.forceBlockIndent||Dn(n)?"  ":""),u="literal"===i||"folded"!==i&&t!==kn.BLOCK_FOLDED&&(t===kn.BLOCK_LITERAL||!function(e,t,n){if(!t||t<0)return!1;const s=t-n,r=e.length;if(r<=s)return!1;for(let o=0,i=0;o<r;++o)if("\n"===e[o]){if(o-i>s)return!0;if(i=o+1,r-i<=s)return!1}return!0}(n,l,c.length));if(!n)return u?"|\n":">\n";let d,f;for(f=n.length;f>0;--f){const e=n[f-1];if("\n"!==e&&"\t"!==e&&" "!==e)break}let h=n.substring(f);const m=h.indexOf("\n");-1===m?d="-":n===h||m!==h.length-1?(d="+",o&&o()):d="",h&&(n=n.slice(0,-h.length),"\n"===h[h.length-1]&&(h=h.slice(0,-1)),h=h.replace(qn,`$&${c}`));let p,g=!1,x=-1;for(p=0;p<n.length;++p){const e=n[p];if(" "===e)g=!0;else{if("\n"!==e)break;x=p}}let y=n.substring(0,x<p?x+1:p);y&&(n=n.substring(y.length),y=y.replace(/\n+/g,`$&${c}`));let b=(g?c?"2":"1":"")+d;if(e&&(b+=" "+a(e.replace(/ ?[\r\n]+/g," ")),r&&r()),!u){const e=n.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`);let r=!1;const o=_n(s,!0);"folded"!==i&&t!==kn.BLOCK_FOLDED&&(o.onOverflow=()=>{r=!0});const a=Rn(`${y}${e}${h}`,c,On,o);if(!r)return`>${b}\n${c}${a}`}return`|${b}\n${c}${y}${n=n.replace(/\n+/g,`$&${c}`)}${h}`}function Kn(e,t,n,s){const{implicitKey:r,inFlow:o}=t,i="string"==typeof e.value?e:Object.assign({},e,{value:String(e.value)});let{type:a}=e;a!==kn.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(a=kn.QUOTE_DOUBLE);const l=e=>{switch(e){case kn.BLOCK_FOLDED:case kn.BLOCK_LITERAL:return r||o?Pn(i.value,t):Bn(i,t,n,s);case kn.QUOTE_DOUBLE:return $n(i.value,t);case kn.QUOTE_SINGLE:return Fn(i.value,t);case kn.PLAIN:return function(e,t,n,s){const{type:r,value:o}=e,{actualString:i,implicitKey:a,indent:l,indentStep:c,inFlow:u}=t;if(a&&o.includes("\n")||u&&/[[\]{},]/.test(o))return Pn(o,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||u||!o.includes("\n")?Pn(o,t):Bn(e,t,n,s);if(!a&&!u&&r!==kn.PLAIN&&o.includes("\n"))return Bn(e,t,n,s);if(Dn(o)){if(""===l)return t.forceBlockIndent=!0,Bn(e,t,n,s);if(a&&l===c)return Pn(o,t)}const d=o.replace(/\n+/g,`$&\n${l}`);if(i){const e=e=>e.default&&"tag:yaml.org,2002:str"!==e.tag&&e.test?.test(d),{compat:n,tags:s}=t.doc.schema;if(s.some(e)||n?.some(e))return Pn(o,t)}return a?d:Rn(d,l,Tn,_n(t,!1))}(i,t,n,s);default:return null}};let c=l(a);if(null===c){const{defaultKeyType:e,defaultStringType:n}=t.options,s=r&&e||n;if(c=l(s),null===c)throw new Error(`Unsupported default string type ${s}`)}return c}function zn(e,t){const n=Object.assign({blockQuote:!0,commentString:jn,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t);let s;switch(n.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:"number"==typeof n.indent?" ".repeat(n.indent):"  ",inFlow:s,options:n}}function Hn(e,t,n,s){if(Qt(e))return e.toString(t,n,s);if(Vt(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let r;const o=nn(e)?e:t.doc.createNode(e,{onTagObj:e=>r=e});r??(r=function(e,t){if(t.tag){const n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,s;if(Zt(t)){s=t.value;let r=e.filter(e=>e.identify?.(s));if(r.length>1){const e=r.filter(e=>e.test);e.length>0&&(r=e)}n=r.find(e=>e.format===t.format)??r.find(e=>!e.format)}else s=t,n=e.find(e=>e.nodeClass&&s instanceof e.nodeClass);if(!n)throw new Error(`Tag not resolved for ${s?.constructor?.name??(null===s?"null":typeof s)} value`);return n}(t.doc.schema.tags,o));const i=function(e,t,{anchors:n,doc:s}){if(!s.directives)return"";const r=[],o=(Zt(e)||tn(e))&&e.anchor;o&&hn(o)&&(n.add(o),r.push(`&${o}`));const i=e.tag??(t.default?null:t.tag);return i&&r.push(s.directives.tagString(i)),r.join(" ")}(o,r,t);i.length>0&&(t.indentAtStart=(t.indentAtStart??0)+i.length+1);const a="function"==typeof r.stringify?r.stringify(o,t,n,s):Zt(o)?Kn(o,t,n,s):o.toString(t,n,s);return i?Zt(o)||"{"===a[0]||"["===a[0]?`${i} ${a}`:`${i}\n${t.indent}${a}`:a}function Un(e,t){"debug"!==e&&"warn"!==e||console.warn(t)}const Wn="<<",Yn={identify:e=>e===Wn||"symbol"==typeof e&&e.description===Wn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new kn(Symbol(Wn)),{addToJSMap:Xn}),stringify:()=>Wn};function Xn(e,t,n){const s=Jn(e,n);if(en(s))for(const r of s.items)Vn(e,t,r);else if(Array.isArray(s))for(const r of s)Vn(e,t,r);else Vn(e,t,s)}function Vn(e,t,n){const s=Jn(e,n);if(!Gt(s))throw new Error("Merge sources must be maps or map aliases");const r=s.toJSON(null,e,Map);for(const[o,i]of r)t instanceof Map?t.has(o)||t.set(o,i):t instanceof Set?t.add(o):Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(t,o,{value:i,writable:!0,enumerable:!0,configurable:!0});return t}function Jn(e,t){return e&&Vt(t)?t.resolve(e.doc,e):t}function Gn(e,t,{key:n,value:s}){if(nn(n)&&n.addToJSMap)n.addToJSMap(e,t,s);else if(((e,t)=>(Yn.identify(t)||Zt(t)&&(!t.type||t.type===kn.PLAIN)&&Yn.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===Yn.tag&&e.default))(e,n))Xn(e,t,s);else{const r=xn(n,"",e);if(t instanceof Map)t.set(r,xn(s,r,e));else if(t instanceof Set)t.add(r);else{const o=function(e,t,n){if(null===t)return"";if("object"!=typeof t)return String(t);if(nn(e)&&n?.doc){const t=zn(n.doc,{});t.anchors=new Set;for(const e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;const s=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(s);e.length>40&&(e=e.substring(0,36)+'..."'),Un(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return s}return JSON.stringify(t)}(n,r,e),i=xn(s,o,e);o in t?Object.defineProperty(t,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):t[o]=i}}return t}function Qn(e,t,n){const s=Sn(e,void 0,n),r=Sn(t,void 0,n);return new Zn(s,r)}class Zn{constructor(e,t=null){Object.defineProperty(this,Xt,{value:Ut}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;return nn(t)&&(t=t.clone(e)),nn(n)&&(n=n.clone(e)),new Zn(t,n)}toJSON(e,t){return Gn(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?function({key:e,value:t},n,s,r){const{allNullValues:o,doc:i,indent:a,indentStep:l,options:{commentString:c,indentSeq:u,simpleKeys:d}}=n;let f=nn(e)&&e.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(tn(e)||!nn(e)&&"object"==typeof e)throw new Error("With simple keys, collection cannot be used as a key value")}let h=!d&&(!e||f&&null==t&&!n.inFlow||tn(e)||(Zt(e)?e.type===kn.BLOCK_FOLDED||e.type===kn.BLOCK_LITERAL:"object"==typeof e));n=Object.assign({},n,{allNullValues:!1,implicitKey:!h&&(d||!o),indent:a+l});let m,p,g,x=!1,y=!1,b=Hn(e,n,()=>x=!0,()=>y=!0);if(!h&&!n.inFlow&&b.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(n.inFlow){if(o||null==t)return x&&s&&s(),""===b?"?":h?`? ${b}`:b}else if(o&&!d||null==t&&h)return b=`? ${b}`,f&&!x?b+=Ln(b,n.indent,c(f)):y&&r&&r(),b;x&&(f=null),h?(f&&(b+=Ln(b,n.indent,c(f))),b=`? ${b}\n${a}:`):(b=`${b}:`,f&&(b+=Ln(b,n.indent,c(f)))),nn(t)?(m=!!t.spaceBefore,p=t.commentBefore,g=t.comment):(m=!1,p=null,g=null,t&&"object"==typeof t&&(t=i.createNode(t))),n.implicitKey=!1,h||f||!Zt(t)||(n.indentAtStart=b.length+1),y=!1,u||!(l.length>=2)||n.inFlow||h||!en(t)||t.flow||t.tag||t.anchor||(n.indent=n.indent.substring(2));let v=!1;const w=Hn(t,n,()=>v=!0,()=>y=!0);let k=" ";if(f||m||p)k=m?"\n":"",p&&(k+=`\n${Mn(c(p),n.indent)}`),""!==w||n.inFlow?k+=`\n${n.indent}`:"\n"===k&&g&&(k="\n\n");else if(!h&&tn(t)){const e=w[0],s=w.indexOf("\n"),r=-1!==s,o=n.inFlow??t.flow??0===t.items.length;if(r||!o){let t=!1;if(r&&("&"===e||"!"===e)){let n=w.indexOf(" ");"&"===e&&-1!==n&&n<s&&"!"===w[n+1]&&(n=w.indexOf(" ",n+1)),(-1===n||s<n)&&(t=!0)}t||(k=`\n${n.indent}`)}}else""!==w&&"\n"!==w[0]||(k="");return b+=k+w,n.inFlow?v&&s&&s():g&&!v?b+=Ln(b,n.indent,c(g)):y&&r&&r(),b}(this,e,t,n):JSON.stringify(this)}}function es(e,t,n){return(t.inFlow??e.flow?ns:ts)(e,t,n)}function ts({comment:e,items:t},n,{blockItemPrefix:s,flowChars:r,itemIndent:o,onChompKeep:i,onComment:a}){const{indent:l,options:{commentString:c}}=n,u=Object.assign({},n,{indent:o,type:null});let d=!1;const f=[];for(let m=0;m<t.length;++m){const e=t[m];let r=null;if(nn(e))!d&&e.spaceBefore&&f.push(""),ss(n,f,e.commentBefore,d),e.comment&&(r=e.comment);else if(Qt(e)){const t=nn(e.key)?e.key:null;t&&(!d&&t.spaceBefore&&f.push(""),ss(n,f,t.commentBefore,d))}d=!1;let i=Hn(e,u,()=>r=null,()=>d=!0);r&&(i+=Ln(i,o,c(r))),d&&r&&(d=!1),f.push(s+i)}let h;if(0===f.length)h=r.start+r.end;else{h=f[0];for(let e=1;e<f.length;++e){const t=f[e];h+=t?`\n${l}${t}`:"\n"}}return e?(h+="\n"+Mn(c(e),l),a&&a()):d&&i&&i(),h}function ns({items:e},t,{flowChars:n,itemIndent:s}){const{indent:r,indentStep:o,flowCollectionPadding:i,options:{commentString:a}}=t;s+=o;const l=Object.assign({},t,{indent:s,inFlow:!0,type:null});let c=!1,u=0;const d=[];for(let m=0;m<e.length;++m){const n=e[m];let r=null;if(nn(n))n.spaceBefore&&d.push(""),ss(t,d,n.commentBefore,!1),n.comment&&(r=n.comment);else if(Qt(n)){const e=nn(n.key)?n.key:null;e&&(e.spaceBefore&&d.push(""),ss(t,d,e.commentBefore,!1),e.comment&&(c=!0));const s=nn(n.value)?n.value:null;s?(s.comment&&(r=s.comment),s.commentBefore&&(c=!0)):null==n.value&&e?.comment&&(r=e.comment)}r&&(c=!0);let o=Hn(n,l,()=>r=null);c||(c=d.length>u||o.includes("\n")),m<e.length-1?o+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth)),c&&(o+=",")),r&&(o+=Ln(o,s,a(r))),d.push(o),u=d.length}const{start:f,end:h}=n;if(0===d.length)return f+h;if(!c){const e=d.reduce((e,t)=>e+t.length+2,2);c=t.options.lineWidth>0&&e>t.options.lineWidth}if(c){let e=f;for(const t of d)e+=t?`\n${o}${r}${t}`:"\n";return`${e}\n${r}${h}`}return`${f}${i}${d.join(" ")}${i}${h}`}function ss({indent:e,options:{commentString:t}},n,s,r){if(s&&r&&(s=s.replace(/^\n+/,"")),s){const r=Mn(t(s),e);n.push(r.trimStart())}}function rs(e,t){const n=Zt(t)?t.value:t;for(const s of e)if(Qt(s)){if(s.key===t||s.key===n)return s;if(Zt(s.key)&&s.key.value===n)return s}}class os extends En{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Ht,e),this.items=[]}static from(e,t,n){const{keepUndefined:s,replacer:r}=n,o=new this(e),i=(e,i)=>{if("function"==typeof r)i=r.call(t,e,i);else if(Array.isArray(r)&&!r.includes(e))return;(void 0!==i||s)&&o.items.push(Qn(e,i,n))};if(t instanceof Map)for(const[a,l]of t)i(a,l);else if(t&&"object"==typeof t)for(const a of Object.keys(t))i(a,t[a]);return"function"==typeof e.sortMapEntries&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=Qt(e)?e:e&&"object"==typeof e&&"key"in e?new Zn(e.key,e.value):new Zn(e,e?.value);const s=rs(this.items,n.key),r=this.schema?.sortMapEntries;if(s){if(!t)throw new Error(`Key ${n.key} already set`);Zt(s.value)&&wn(n.value)?s.value.value=n.value:s.value=n.value}else if(r){const e=this.items.findIndex(e=>r(n,e)<0);-1===e?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){const t=rs(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){const n=rs(this.items,e),s=n?.value;return(!t&&Zt(s)?s.value:s)??void 0}has(e){return!!rs(this.items,e)}set(e,t){this.add(new Zn(e,t),!0)}toJSON(e,t,n){const s=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(s);for(const r of this.items)Gn(t,s,r);return s}toString(e,t,n){if(!e)return JSON.stringify(this);for(const s of this.items)if(!Qt(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),es(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}const is={collection:"map",default:!0,nodeClass:os,tag:"tag:yaml.org,2002:map",resolve:(e,t)=>(Gt(e)||t("Expected a mapping for this tag"),e),createNode:(e,t,n)=>os.from(e,t,n)};class as extends En{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Yt,e),this.items=[]}add(e){this.items.push(e)}delete(e){const t=ls(e);if("number"!=typeof t)return!1;return this.items.splice(t,1).length>0}get(e,t){const n=ls(e);if("number"!=typeof n)return;const s=this.items[n];return!t&&Zt(s)?s.value:s}has(e){const t=ls(e);return"number"==typeof t&&t<this.items.length}set(e,t){const n=ls(e);if("number"!=typeof n)throw new Error(`Expected a valid index, not ${e}.`);const s=this.items[n];Zt(s)&&wn(t)?s.value=t:this.items[n]=t}toJSON(e,t){const n=[];t?.onCreate&&t.onCreate(n);let s=0;for(const r of this.items)n.push(xn(r,String(s++),t));return n}toString(e,t,n){return e?es(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+"  ",onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){const{replacer:s}=n,r=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let o of t){if("function"==typeof s){const n=t instanceof Set?o:String(e++);o=s.call(t,n,o)}r.items.push(Sn(o,void 0,n))}}return r}}function ls(e){let t=Zt(e)?e.value:e;return t&&"string"==typeof t&&(t=Number(t)),"number"==typeof t&&Number.isInteger(t)&&t>=0?t:null}const cs={collection:"seq",default:!0,nodeClass:as,tag:"tag:yaml.org,2002:seq",resolve:(e,t)=>(en(e)||t("Expected a sequence for this tag"),e),createNode:(e,t,n)=>as.from(e,t,n)},us={identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:(e,t,n,s)=>Kn(e,t=Object.assign({actualString:!0},t),n,s)},ds={identify:e=>null==e,createNode:()=>new kn(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new kn(null),stringify:({source:e},t)=>"string"==typeof e&&ds.test.test(e)?e:t.options.nullStr},fs={identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new kn("t"===e[0]||"T"===e[0]),stringify({source:e,value:t},n){if(e&&fs.test.test(e)){if(t===("t"===e[0]||"T"===e[0]))return e}return t?n.options.trueStr:n.options.falseStr}};function hs({format:e,minFractionDigits:t,tag:n,value:s}){if("bigint"==typeof s)return String(s);const r="number"==typeof s?s:Number(s);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let o=Object.is(s,-0)?"-0":JSON.stringify(s);if(!e&&t&&(!n||"tag:yaml.org,2002:float"===n)&&/^-?\d/.test(o)&&!o.includes("e")){let e=o.indexOf(".");e<0&&(e=o.length,o+=".");let n=t-(o.length-e-1);for(;n-- >0;)o+="0"}return o}const ms={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:hs},ps={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():hs(e)}},gs={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){const t=new kn(parseFloat(e)),n=e.indexOf(".");return-1!==n&&"0"===e[e.length-1]&&(t.minFractionDigits=e.length-n-1),t},stringify:hs},xs=e=>"bigint"==typeof e||Number.isInteger(e),ys=(e,t,n,{intAsBigInt:s})=>s?BigInt(e):parseInt(e.substring(t),n);function bs(e,t,n){const{value:s}=e;return xs(s)&&s>=0?n+s.toString(t):hs(e)}const vs={identify:e=>xs(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>ys(e,2,8,n),stringify:e=>bs(e,8,"0o")},ws={identify:xs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>ys(e,0,10,n),stringify:hs},ks={identify:e=>xs(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>ys(e,2,16,n),stringify:e=>bs(e,16,"0x")},Ss=[is,cs,us,ds,fs,vs,ws,ks,ms,ps,gs];function Cs(e){return"bigint"==typeof e||Number.isInteger(e)}const Ns=({value:e})=>JSON.stringify(e),Es=[is,cs].concat([{identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Ns},{identify:e=>null==e,createNode:()=>new kn(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Ns},{identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>"true"===e,stringify:Ns},{identify:Cs,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Cs(e)?e.toString():JSON.stringify(e)},{identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Ns}],{default:!0,tag:"",test:/^/,resolve:(e,t)=>(t(`Unresolved plain scalar ${JSON.stringify(e)}`),e)}),js={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if("function"==typeof atob){const t=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},s,r,o){if(!n)return"";const i=n;let a;if("function"!=typeof btoa)throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");{let e="";for(let t=0;t<i.length;++t)e+=String.fromCharCode(i[t]);a=btoa(e)}if(t??(t=kn.BLOCK_LITERAL),t!==kn.QUOTE_DOUBLE){const e=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),n=Math.ceil(a.length/e),r=new Array(n);for(let t=0,s=0;t<n;++t,s+=e)r[t]=a.substr(s,e);a=r.join(t===kn.BLOCK_LITERAL?"\n":" ")}return Kn({comment:e,type:t,value:a},s,r,o)}};function Ms(e,t){if(en(e))for(let n=0;n<e.items.length;++n){let s=e.items[n];if(!Qt(s)){if(Gt(s)){s.items.length>1&&t("Each pair must have its own sequence indicator");const e=s.items[0]||new Zn(new kn(null));if(s.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${s.commentBefore}\n${e.key.commentBefore}`:s.commentBefore),s.comment){const t=e.value??e.key;t.comment=t.comment?`${s.comment}\n${t.comment}`:s.comment}s=e}e.items[n]=Qt(s)?s:new Zn(s)}}else t("Expected a sequence for this tag");return e}function Ls(e,t,n){const{replacer:s}=n,r=new as(e);r.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let i of t){let e,a;if("function"==typeof s&&(i=s.call(t,String(o++),i)),Array.isArray(i)){if(2!==i.length)throw new TypeError(`Expected [key, value] tuple: ${i}`);e=i[0],a=i[1]}else if(i&&i instanceof Object){const t=Object.keys(i);if(1!==t.length)throw new TypeError(`Expected tuple with one key, not ${t.length} keys`);e=t[0],a=i[e]}else e=i;r.items.push(Qn(e,a,n))}return r}const Ts={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ms,createNode:Ls};class Os extends as{constructor(){super(),this.add=os.prototype.add.bind(this),this.delete=os.prototype.delete.bind(this),this.get=os.prototype.get.bind(this),this.has=os.prototype.has.bind(this),this.set=os.prototype.set.bind(this),this.tag=Os.tag}toJSON(e,t){if(!t)return super.toJSON(e);const n=new Map;t?.onCreate&&t.onCreate(n);for(const s of this.items){let e,r;if(Qt(s)?(e=xn(s.key,"",t),r=xn(s.value,e,t)):e=xn(s,"",t),n.has(e))throw new Error("Ordered maps must not include duplicate keys");n.set(e,r)}return n}static from(e,t,n){const s=Ls(e,t,n),r=new this;return r.items=s.items,r}}Os.tag="tag:yaml.org,2002:omap";const As={collection:"seq",identify:e=>e instanceof Map,nodeClass:Os,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){const n=Ms(e,t),s=[];for(const{key:r}of n.items)Zt(r)&&(s.includes(r.value)?t(`Ordered maps must not include duplicate keys: ${r.value}`):s.push(r.value));return Object.assign(new Os,n)},createNode:(e,t,n)=>Os.from(e,t,n)};function Rs({value:e,source:t},n){return t&&(e?Is:_s).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}const Is={identify:e=>!0===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new kn(!0),stringify:Rs},_s={identify:e=>!1===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new kn(!1),stringify:Rs},Ds={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:hs},$s={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():hs(e)}},Fs={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){const t=new kn(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(-1!==n){const s=e.substring(n+1).replace(/_/g,"");"0"===s[s.length-1]&&(t.minFractionDigits=s.length)}return t},stringify:hs},Ps=e=>"bigint"==typeof e||Number.isInteger(e);function qs(e,t,n,{intAsBigInt:s}){const r=e[0];if("-"!==r&&"+"!==r||(t+=1),e=e.substring(t).replace(/_/g,""),s){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}const t=BigInt(e);return"-"===r?BigInt(-1)*t:t}const o=parseInt(e,n);return"-"===r?-1*o:o}function Bs(e,t,n){const{value:s}=e;if(Ps(s)){const e=s.toString(t);return s<0?"-"+n+e.substr(1):n+e}return hs(e)}const Ks={identify:Ps,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>qs(e,2,2,n),stringify:e=>Bs(e,2,"0b")},zs={identify:Ps,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>qs(e,1,8,n),stringify:e=>Bs(e,8,"0")},Hs={identify:Ps,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>qs(e,0,10,n),stringify:hs},Us={identify:Ps,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>qs(e,2,16,n),stringify:e=>Bs(e,16,"0x")};class Ws extends os{constructor(e){super(e),this.tag=Ws.tag}add(e){let t;t=Qt(e)?e:e&&"object"==typeof e&&"key"in e&&"value"in e&&null===e.value?new Zn(e.key,null):new Zn(e,null);rs(this.items,t.key)||this.items.push(t)}get(e,t){const n=rs(this.items,e);return!t&&Qt(n)?Zt(n.key)?n.key.value:n.key:n}set(e,t){if("boolean"!=typeof t)throw new Error("Expected boolean value for set(key, value) in a YAML set, not "+typeof t);const n=rs(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new Zn(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw new Error("Set items must all have null values")}static from(e,t,n){const{replacer:s}=n,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t)"function"==typeof s&&(o=s.call(t,o,o)),r.items.push(Qn(o,null,n));return r}}Ws.tag="tag:yaml.org,2002:set";const Ys={collection:"map",identify:e=>e instanceof Set,nodeClass:Ws,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Ws.from(e,t,n),resolve(e,t){if(Gt(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ws,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};function Xs(e,t){const n=e[0],s="-"===n||"+"===n?e.substring(1):e,r=e=>t?BigInt(e):Number(e),o=s.replace(/_/g,"").split(":").reduce((e,t)=>e*r(60)+r(t),r(0));return"-"===n?r(-1)*o:o}function Vs(e){let{value:t}=e,n=e=>e;if("bigint"==typeof t)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return hs(e);let s="";t<0&&(s="-",t*=n(-1));const r=n(60),o=[t%r];return t<60?o.unshift(0):(t=(t-o[0])/r,o.unshift(t%r),t>=60&&(t=(t-o[0])/r,o.unshift(t))),s+o.map(e=>String(e).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const Js={identify:e=>"bigint"==typeof e||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>Xs(e,n),stringify:Vs},Gs={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Xs(e,!1),stringify:Vs},Qs={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){const t=e.match(Qs.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,n,s,r,o,i,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0;let c=Date.UTC(n,s-1,r,o||0,i||0,a||0,l);const u=t[8];if(u&&"Z"!==u){let e=Xs(u,!1);Math.abs(e)<30&&(e*=60),c-=6e4*e}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},Zs=[is,cs,us,ds,Is,_s,Ks,zs,Hs,Us,Ds,$s,Fs,js,Yn,As,Ts,Ys,Js,Gs,Qs],er=new Map([["core",Ss],["failsafe",[is,cs,us]],["json",Es],["yaml11",Zs],["yaml-1.1",Zs]]),tr={binary:js,bool:fs,float:gs,floatExp:ps,floatNaN:ms,floatTime:Gs,int:ws,intHex:ks,intOct:vs,intTime:Js,map:is,merge:Yn,null:ds,omap:As,pairs:Ts,seq:cs,set:Ys,timestamp:Qs},nr={"tag:yaml.org,2002:binary":js,"tag:yaml.org,2002:merge":Yn,"tag:yaml.org,2002:omap":As,"tag:yaml.org,2002:pairs":Ts,"tag:yaml.org,2002:set":Ys,"tag:yaml.org,2002:timestamp":Qs};function sr(e,t,n){const s=er.get(t);if(s&&!e)return n&&!s.includes(Yn)?s.concat(Yn):s.slice();let r=s;if(!r){if(!Array.isArray(e)){const e=Array.from(er.keys()).filter(e=>"yaml11"!==e).map(e=>JSON.stringify(e)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}r=[]}if(Array.isArray(e))for(const o of e)r=r.concat(o);else"function"==typeof e&&(r=e(r.slice()));return n&&(r=r.concat(Yn)),r.reduce((e,t)=>{const n="string"==typeof t?tr[t]:t;if(!n){const e=JSON.stringify(t),n=Object.keys(tr).map(e=>JSON.stringify(e)).join(", ");throw new Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}const rr=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class or{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:s,schema:r,sortMapEntries:o,toStringDefaults:i}){this.compat=Array.isArray(e)?sr(e,"compat"):e?sr(null,e):null,this.name="string"==typeof r&&r||"core",this.knownTags=s?nr:{},this.tags=sr(t,this.name,n),this.toStringOptions=i??null,Object.defineProperty(this,Ht,{value:is}),Object.defineProperty(this,Wt,{value:us}),Object.defineProperty(this,Yt,{value:cs}),this.sortMapEntries="function"==typeof o?o:!0===o?rr:null}clone(){const e=Object.create(or.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}class ir{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Xt,{value:zt});let s=null;"function"==typeof t||Array.isArray(t)?s=t:void 0===n&&t&&(n=t,t=void 0);const r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=r;let{version:o}=r;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new fn({version:o}),this.setSchema(o,n),this.contents=void 0===e?null:this.createNode(e,s,n)}clone(){const e=Object.create(ir.prototype,{[Xt]:{value:zt}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=nn(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){ar(this.contents)&&this.contents.add(e)}addIn(e,t){ar(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const n=mn(this);e.anchor=!t||n.has(t)?pn(t||"a",n):t}return new bn(e.anchor)}createNode(e,t,n){let s;if("function"==typeof t)e=t.call({"":e},"",e),s=t;else if(Array.isArray(t)){const e=e=>"number"==typeof e||e instanceof String||e instanceof Number,n=t.filter(e).map(String);n.length>0&&(t=t.concat(n)),s=t}else void 0===n&&t&&(n=t,t=void 0);const{aliasDuplicateObjects:r,anchorPrefix:o,flow:i,keepUndefined:a,onTagObj:l,tag:c}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=function(e,t){const n=[],s=new Map;let r=null;return{onAnchor:s=>{n.push(s),r??(r=mn(e));const o=pn(t,r);return r.add(o),o},setAnchors:()=>{for(const e of n){const t=s.get(e);if("object"!=typeof t||!t.anchor||!Zt(t.node)&&!tn(t.node)){const t=new Error("Failed to resolve repeated object (this should not happen)");throw t.source=e,t}t.node.anchor=t.anchor}},sourceObjects:s}}(this,o||"a"),h=Sn(e,c,{aliasDuplicateObjects:r??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:l,replacer:s,schema:this.schema,sourceObjects:f});return i&&tn(h)&&(h.flow=!0),d(),h}createPair(e,t,n={}){const s=this.createNode(e,null,n),r=this.createNode(t,null,n);return new Zn(s,r)}delete(e){return!!ar(this.contents)&&this.contents.delete(e)}deleteIn(e){return Nn(e)?null!=this.contents&&(this.contents=null,!0):!!ar(this.contents)&&this.contents.deleteIn(e)}get(e,t){return tn(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Nn(e)?!t&&Zt(this.contents)?this.contents.value:this.contents:tn(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!tn(this.contents)&&this.contents.has(e)}hasIn(e){return Nn(e)?void 0!==this.contents:!!tn(this.contents)&&this.contents.hasIn(e)}set(e,t){null==this.contents?this.contents=Cn(this.schema,[e],t):ar(this.contents)&&this.contents.set(e,t)}setIn(e,t){Nn(e)?this.contents=t:null==this.contents?this.contents=Cn(this.schema,Array.from(e),t):ar(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){let n;switch("number"==typeof e&&(e=String(e)),e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new fn({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new fn({version:e}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{const t=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else{if(!n)throw new Error("With a null YAML version, the { schema: Schema } option is required");this.schema=new or(Object.assign(n,t))}}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:s,onAnchor:r,reviver:o}={}){const i={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===n,mapKeyWarned:!1,maxAliasCount:"number"==typeof s?s:100},a=xn(this.contents,t??"",i);if("function"==typeof r)for(const{count:l,res:c}of i.anchors.values())r(c,l);return"function"==typeof o?gn(o,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){const t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return function(e,t){const n=[];let s=!0===t.directives;if(!1!==t.directives&&e.directives){const t=e.directives.toString(e);t?(n.push(t),s=!0):e.directives.docStart&&(s=!0)}s&&n.push("---");const r=zn(e,t),{commentString:o}=r.options;if(e.commentBefore){1!==n.length&&n.unshift("");const t=o(e.commentBefore);n.unshift(Mn(t,""))}let i=!1,a=null;if(e.contents){if(nn(e.contents)){if(e.contents.spaceBefore&&s&&n.push(""),e.contents.commentBefore){const t=o(e.contents.commentBefore);n.push(Mn(t,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}const t=a?void 0:()=>i=!0;let l=Hn(e.contents,r,()=>a=null,t);a&&(l+=Ln(l,"",o(a))),"|"!==l[0]&&">"!==l[0]||"---"!==n[n.length-1]?n.push(l):n[n.length-1]=`--- ${l}`}else n.push(Hn(e.contents,r));if(e.directives?.docEnd)if(e.comment){const t=o(e.comment);t.includes("\n")?(n.push("..."),n.push(Mn(t,""))):n.push(`... ${t}`)}else n.push("...");else{let t=e.comment;t&&i&&(t=t.replace(/^\n+/,"")),t&&(i&&!a||""===n[n.length-1]||n.push(""),n.push(Mn(o(t),"")))}return n.join("\n")+"\n"}(this,e)}}function ar(e){if(tn(e))return!0;throw new Error("Expected a YAML collection as document contents")}class lr extends Error{constructor(e,t,n,s){super(),this.name=e,this.code=n,this.message=s,this.pos=t}}class cr extends lr{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class ur extends lr{constructor(e,t,n){super("YAMLWarning",e,t,n)}}const dr=(e,t)=>n=>{if(-1===n.pos[0])return;n.linePos=n.pos.map(e=>t.linePos(e));const{line:s,col:r}=n.linePos[0];n.message+=` at line ${s}, column ${r}`;let o=r-1,i=e.substring(t.lineStarts[s-1],t.lineStarts[s]).replace(/[\n\r]+$/,"");if(o>=60&&i.length>80){const e=Math.min(o-39,i.length-79);i="\u2026"+i.substring(e),o-=e-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),s>1&&/^ *$/.test(i.substring(0,o))){let n=e.substring(t.lineStarts[s-2],t.lineStarts[s-1]);n.length>80&&(n=n.substring(0,79)+"\u2026\n"),i=n+i}if(/[^ ]/.test(i)){let e=1;const t=n.linePos[1];t?.line===s&&t.col>r&&(e=Math.max(1,Math.min(t.col-r,80-o)));const a=" ".repeat(o)+"^".repeat(e);n.message+=`:\n\n${i}\n${a}\n`}};function fr(e,{flow:t,indicator:n,next:s,offset:r,onError:o,parentIndent:i,startOnNewline:a}){let l=!1,c=a,u=a,d="",f="",h=!1,m=!1,p=null,g=null,x=null,y=null,b=null,v=null,w=null;for(const C of e)switch(m&&("space"!==C.type&&"newline"!==C.type&&"comma"!==C.type&&o(C.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),p&&(c&&"comment"!==C.type&&"newline"!==C.type&&o(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),C.type){case"space":t||"doc-start"===n&&"flow-collection"===s?.type||!C.source.includes("\t")||(p=C),u=!0;break;case"comment":{u||o(C,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const e=C.source.substring(1)||" ";d?d+=f+e:d=e,f="",c=!1;break}case"newline":c?d?d+=C.source:v&&"seq-item-ind"===n||(l=!0):f+=C.source,c=!0,h=!0,(g||x)&&(y=C),u=!0;break;case"anchor":g&&o(C,"MULTIPLE_ANCHORS","A node can have at most one anchor"),C.source.endsWith(":")&&o(C.offset+C.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=C,w??(w=C.offset),c=!1,u=!1,m=!0;break;case"tag":x&&o(C,"MULTIPLE_TAGS","A node can have at most one tag"),x=C,w??(w=C.offset),c=!1,u=!1,m=!0;break;case n:(g||x)&&o(C,"BAD_PROP_ORDER",`Anchors and tags must be after the ${C.source} indicator`),v&&o(C,"UNEXPECTED_TOKEN",`Unexpected ${C.source} in ${t??"collection"}`),v=C,c="seq-item-ind"===n||"explicit-key-ind"===n,u=!1;break;case"comma":if(t){b&&o(C,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),b=C,c=!1,u=!1;break}default:o(C,"UNEXPECTED_TOKEN",`Unexpected ${C.type} token`),c=!1,u=!1}const k=e[e.length-1],S=k?k.offset+k.source.length:r;return m&&s&&"space"!==s.type&&"newline"!==s.type&&"comma"!==s.type&&("scalar"!==s.type||""!==s.source)&&o(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(c&&p.indent<=i||"block-map"===s?.type||"block-seq"===s?.type)&&o(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:v,spaceBefore:l,comment:d,hasNewline:h,anchor:g,tag:x,newlineAfterProp:y,end:S,start:w??S}}function hr(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes("\n"))return!0;if(e.end)for(const t of e.end)if("newline"===t.type)return!0;return!1;case"flow-collection":for(const t of e.items){for(const e of t.start)if("newline"===e.type)return!0;if(t.sep)for(const e of t.sep)if("newline"===e.type)return!0;if(hr(t.key)||hr(t.value))return!0}return!1;default:return!0}}function mr(e,t,n){if("flow-collection"===t?.type){const s=t.end[0];if(s.indent===e&&("]"===s.source||"}"===s.source)&&hr(t)){n(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}}function pr(e,t,n){const{uniqueKeys:s}=e.options;if(!1===s)return!1;const r="function"==typeof s?s:(e,t)=>e===t||Zt(e)&&Zt(t)&&e.value===t.value;return t.some(e=>r(e.key,n))}const gr="All mapping items must start at the same column";function xr(e,t,n,s){let r="";if(e){let o=!1,i="";for(const a of e){const{source:e,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{n&&!o&&s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const t=e.substring(1)||" ";r?r+=i+t:r=t,i="";break}case"newline":r&&(i+=e),o=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=e.length}}return{comment:r,offset:t}}const yr="Block collections are not allowed within flow collections",br=e=>e&&("block-map"===e.type||"block-seq"===e.type);function vr(e,t,n,s,r,o){const i="block-map"===n.type?function({composeNode:e,composeEmptyNode:t},n,s,r,o){const i=new(o?.nodeClass??os)(n.schema);n.atRoot&&(n.atRoot=!1);let a=s.offset,l=null;for(const c of s.items){const{start:o,key:u,sep:d,value:f}=c,h=fr(o,{indicator:"explicit-key-ind",next:u??d?.[0],offset:a,onError:r,parentIndent:s.indent,startOnNewline:!0}),m=!h.found;if(m){if(u&&("block-seq"===u.type?r(a,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==s.indent&&r(a,"BAD_INDENT",gr)),!h.anchor&&!h.tag&&!d){l=h.end,h.comment&&(i.comment?i.comment+="\n"+h.comment:i.comment=h.comment);continue}(h.newlineAfterProp||hr(u))&&r(u??o[o.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==s.indent&&r(a,"BAD_INDENT",gr);n.atKey=!0;const p=h.end,g=u?e(n,u,h,r):t(n,p,o,null,h,r);n.schema.compat&&mr(s.indent,u,r),n.atKey=!1,pr(n,i.items,g)&&r(p,"DUPLICATE_KEY","Map keys must be unique");const x=fr(d??[],{indicator:"map-value-ind",next:f,offset:g.range[2],onError:r,parentIndent:s.indent,startOnNewline:!u||"block-scalar"===u.type});if(a=x.end,x.found){m&&("block-map"!==f?.type||x.hasNewline||r(a,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&h.start<x.found.offset-1024&&r(g.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const o=f?e(n,f,x,r):t(n,a,d,null,x,r);n.schema.compat&&mr(s.indent,f,r),a=o.range[2];const l=new Zn(g,o);n.options.keepSourceTokens&&(l.srcToken=c),i.items.push(l)}else{m&&r(g.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),x.comment&&(g.comment?g.comment+="\n"+x.comment:g.comment=x.comment);const e=new Zn(g);n.options.keepSourceTokens&&(e.srcToken=c),i.items.push(e)}}return l&&l<a&&r(l,"IMPOSSIBLE","Map comment with trailing content"),i.range=[s.offset,a,l??a],i}(e,t,n,s,o):"block-seq"===n.type?function({composeNode:e,composeEmptyNode:t},n,s,r,o){const i=new(o?.nodeClass??as)(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let a=s.offset,l=null;for(const{start:c,value:u}of s.items){const o=fr(c,{indicator:"seq-item-ind",next:u,offset:a,onError:r,parentIndent:s.indent,startOnNewline:!0});if(!o.found){if(!(o.anchor||o.tag||u)){l=o.end,o.comment&&(i.comment=o.comment);continue}"block-seq"===u?.type?r(o.end,"BAD_INDENT","All sequence items must start at the same column"):r(a,"MISSING_CHAR","Sequence item without - indicator")}const d=u?e(n,u,o,r):t(n,o.end,c,null,o,r);n.schema.compat&&mr(s.indent,u,r),a=d.range[2],i.items.push(d)}return i.range=[s.offset,a,l??a],i}(e,t,n,s,o):function({composeNode:e,composeEmptyNode:t},n,s,r,o){const i="{"===s.start.source,a=i?"flow map":"flow sequence",l=new(o?.nodeClass??(i?os:as))(n.schema);l.flow=!0;const c=n.atRoot;c&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let u=s.offset+s.start.source.length;for(let p=0;p<s.items.length;++p){const o=s.items[p],{start:c,key:d,sep:f,value:h}=o,m=fr(c,{flow:a,indicator:"explicit-key-ind",next:d??f?.[0],offset:u,onError:r,parentIndent:s.indent,startOnNewline:!1});if(!m.found){if(!(m.anchor||m.tag||f||h)){0===p&&m.comma?r(m.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):p<s.items.length-1&&r(m.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),m.comment&&(l.comment?l.comment+="\n"+m.comment:l.comment=m.comment),u=m.end;continue}!i&&n.options.strict&&hr(d)&&r(d,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(0===p)m.comma&&r(m.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(m.comma||r(m.start,"MISSING_CHAR",`Missing , between ${a} items`),m.comment){let e="";e:for(const t of c)switch(t.type){case"comma":case"space":break;case"comment":e=t.source.substring(1);break e;default:break e}if(e){let t=l.items[l.items.length-1];Qt(t)&&(t=t.value??t.key),t.comment?t.comment+="\n"+e:t.comment=e,m.comment=m.comment.substring(e.length+1)}}if(i||f||m.found){n.atKey=!0;const p=m.end,g=d?e(n,d,m,r):t(n,p,c,null,m,r);br(d)&&r(g.range,"BLOCK_IN_FLOW",yr),n.atKey=!1;const x=fr(f??[],{flow:a,indicator:"map-value-ind",next:h,offset:g.range[2],onError:r,parentIndent:s.indent,startOnNewline:!1});if(x.found){if(!i&&!m.found&&n.options.strict){if(f)for(const e of f){if(e===x.found)break;if("newline"===e.type){r(e,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}m.start<x.found.offset-1024&&r(x.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else h&&("source"in h&&":"===h.source?.[0]?r(h,"MISSING_CHAR",`Missing space after : in ${a}`):r(x.start,"MISSING_CHAR",`Missing , or : between ${a} items`));const y=h?e(n,h,x,r):x.found?t(n,x.end,f,null,x,r):null;y?br(h)&&r(y.range,"BLOCK_IN_FLOW",yr):x.comment&&(g.comment?g.comment+="\n"+x.comment:g.comment=x.comment);const b=new Zn(g,y);if(n.options.keepSourceTokens&&(b.srcToken=o),i){const e=l;pr(n,e.items,g)&&r(p,"DUPLICATE_KEY","Map keys must be unique"),e.items.push(b)}else{const e=new os(n.schema);e.flow=!0,e.items.push(b);const t=(y??g).range;e.range=[g.range[0],t[1],t[2]],l.items.push(e)}u=y?y.range[2]:x.end}else{const s=h?e(n,h,m,r):t(n,m.end,f,null,m,r);l.items.push(s),u=s.range[2],br(h)&&r(s.range,"BLOCK_IN_FLOW",yr)}}const d=i?"}":"]",[f,...h]=s.end;let m=u;if(f?.source===d)m=f.offset+f.source.length;else{const e=a[0].toUpperCase()+a.substring(1);r(u,c?"MISSING_CHAR":"BAD_INDENT",c?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`),f&&1!==f.source.length&&h.unshift(f)}if(h.length>0){const e=xr(h,m,n.options.strict,r);e.comment&&(l.comment?l.comment+="\n"+e.comment:l.comment=e.comment),l.range=[s.offset,m,e.offset]}else l.range=[s.offset,m,m];return l}(e,t,n,s,o),a=i.constructor;return"!"===r||r===a.tagName?(i.tag=a.tagName,i):(r&&(i.tag=r),i)}function wr(e,t,n){const s=t.offset,r=function({offset:e,props:t},n,s){if("block-scalar-header"!==t[0].type)return s(t[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:r}=t[0],o=r[0];let i=0,a="",l=-1;for(let f=1;f<r.length;++f){const t=r[f];if(a||"-"!==t&&"+"!==t){const n=Number(t);!i&&n?i=n:-1===l&&(l=e+f)}else a=t}-1!==l&&s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let c=!1,u="",d=r.length;for(let f=1;f<t.length;++f){const e=t[f];switch(e.type){case"space":c=!0;case"newline":d+=e.source.length;break;case"comment":if(n&&!c){s(e,"MISSING_CHAR","Comments must be separated from other tokens by white space characters")}d+=e.source.length,u=e.source.substring(1);break;case"error":s(e,"UNEXPECTED_TOKEN",e.message),d+=e.source.length;break;default:{s(e,"UNEXPECTED_TOKEN",`Unexpected token in block scalar header: ${e.type}`);const t=e.source;t&&"string"==typeof t&&(d+=t.length)}}}return{mode:o,indent:i,chomp:a,comment:u,length:d}}(t,e.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[s,s,s]};const o=">"===r.mode?kn.BLOCK_FOLDED:kn.BLOCK_LITERAL,i=t.source?function(e){const t=e.split(/\n( *)/),n=t[0],s=n.match(/^( *)/),r=[s?.[1]?[s[1],n.slice(s[1].length)]:["",n]];for(let o=1;o<t.length;o+=2)r.push([t[o],t[o+1]]);return r}(t.source):[];let a=i.length;for(let p=i.length-1;p>=0;--p){const e=i[p][1];if(""!==e&&"\r"!==e)break;a=p}if(0===a){const e="+"===r.chomp&&i.length>0?"\n".repeat(Math.max(1,i.length-1)):"";let n=s+r.length;return t.source&&(n+=t.source.length),{value:e,type:o,comment:r.comment,range:[s,n,n]}}let l=t.indent+r.indent,c=t.offset+r.length,u=0;for(let p=0;p<a;++p){const[t,s]=i[p];if(""!==s&&"\r"!==s){if(t.length<l){const e="Block scalars with more-indented leading empty lines must use an explicit indentation indicator";n(c+t.length,"MISSING_CHAR",e)}if(0===r.indent&&(l=t.length),u=p,0===l&&!e.atRoot){n(c,"BAD_INDENT","Block scalar values in collections must be indented")}break}0===r.indent&&t.length>l&&(l=t.length),c+=t.length+s.length+1}for(let p=i.length-1;p>=a;--p)i[p][0].length>l&&(a=p+1);let d="",f="",h=!1;for(let p=0;p<u;++p)d+=i[p][0].slice(l)+"\n";for(let p=u;p<a;++p){let[e,t]=i[p];c+=e.length+t.length+1;const s="\r"===t[t.length-1];if(s&&(t=t.slice(0,-1)),t&&e.length<l){const o=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;n(c-t.length-(s?2:1),"BAD_INDENT",o),e=""}o===kn.BLOCK_LITERAL?(d+=f+e.slice(l)+t,f="\n"):e.length>l||"\t"===t[0]?(" "===f?f="\n":h||"\n"!==f||(f="\n\n"),d+=f+e.slice(l)+t,f="\n",h=!0):""===t?"\n"===f?d+="\n":f="\n":(d+=f+t,f=" ",h=!1)}switch(r.chomp){case"-":break;case"+":for(let e=a;e<i.length;++e)d+="\n"+i[e][0].slice(l);"\n"!==d[d.length-1]&&(d+="\n");break;default:d+="\n"}const m=s+r.length+t.source.length;return{value:d,type:o,comment:r.comment,range:[s,m,m]}}function kr(e,t,n){const{offset:s,type:r,source:o,end:i}=e;let a,l;const c=(e,t,r)=>n(s+e,t,r);switch(r){case"scalar":a=kn.PLAIN,l=function(e,t){let n="";switch(e[0]){case"\t":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":n=`block scalar indicator ${e[0]}`;break;case"@":case"`":n=`reserved character ${e[0]}`}n&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`);return Sr(e)}(o,c);break;case"single-quoted-scalar":a=kn.QUOTE_SINGLE,l=function(e,t){"'"===e[e.length-1]&&1!==e.length||t(e.length,"MISSING_CHAR","Missing closing 'quote");return Sr(e.slice(1,-1)).replace(/''/g,"'")}(o,c);break;case"double-quoted-scalar":a=kn.QUOTE_DOUBLE,l=function(e,t){let n="";for(let s=1;s<e.length-1;++s){const r=e[s];if("\r"!==r||"\n"!==e[s+1])if("\n"===r){const{fold:t,offset:r}=Cr(e,s);n+=t,s=r}else if("\\"===r){let r=e[++s];const o=Nr[r];if(o)n+=o;else if("\n"===r)for(r=e[s+1];" "===r||"\t"===r;)r=e[1+ ++s];else if("\r"===r&&"\n"===e[s+1])for(r=e[1+ ++s];" "===r||"\t"===r;)r=e[1+ ++s];else if("x"===r||"u"===r||"U"===r){const o="x"===r?2:"u"===r?4:8;n+=Er(e,s+1,o,t),s+=o}else{const r=e.substr(s-1,2);t(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${r}`),n+=r}}else if(" "===r||"\t"===r){const t=s;let o=e[s+1];for(;" "===o||"\t"===o;)o=e[1+ ++s];"\n"===o||"\r"===o&&"\n"===e[s+2]||(n+=s>t?e.slice(t,s+1):r)}else n+=r}'"'===e[e.length-1]&&1!==e.length||t(e.length,"MISSING_CHAR",'Missing closing "quote');return n}(o,c);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[s,s+o.length,s+o.length]}}const u=s+o.length,d=xr(i,u,t,n);return{value:l,type:a,comment:d.comment,range:[s,u,d.offset]}}function Sr(e){let t,n;try{t=new RegExp("(.*?)(?<![ \t])[ \t]*\r?\n","sy"),n=new RegExp("[ \t]*(.*?)(?:(?<![ \t])[ \t]*)?\r?\n","sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let s=t.exec(e);if(!s)return e;let r=s[1],o=" ",i=t.lastIndex;for(n.lastIndex=i;s=n.exec(e);)""===s[1]?"\n"===o?r+=o:o="\n":(r+=o+s[1],o=" "),i=n.lastIndex;const a=/[ \t]*(.*)/sy;return a.lastIndex=i,s=a.exec(e),r+o+(s?.[1]??"")}function Cr(e,t){let n="",s=e[t+1];for(;!(" "!==s&&"\t"!==s&&"\n"!==s&&"\r"!==s||"\r"===s&&"\n"!==e[t+2]);)"\n"===s&&(n+="\n"),s=e[(t+=1)+1];return n||(n=" "),{fold:n,offset:t}}const Nr={0:"\0",a:"\x07",b:"\b",e:"\x1b",f:"\f",n:"\n",r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xa0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Er(e,t,n,s){const r=e.substr(t,n),o=r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(o)}catch{const r=e.substr(t-2,n+2);return s(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${r}`),r}}function jr(e,t,n,s){const{value:r,type:o,comment:i,range:a}="block-scalar"===t.type?wr(e,t,s):kr(t,e.options.strict,s),l=n?e.directives.tagName(n.source,e=>s(n,"TAG_RESOLVE_FAILED",e)):null;let c,u;c=e.options.stringKeys&&e.atKey?e.schema[Wt]:l?function(e,t,n,s,r){if("!"===n)return e[Wt];const o=[];for(const a of e.tags)if(!a.collection&&a.tag===n){if(!a.default||!a.test)return a;o.push(a)}for(const a of o)if(a.test?.test(t))return a;const i=e.knownTags[n];if(i&&!i.collection)return e.tags.push(Object.assign({},i,{default:!1,test:void 0})),i;return r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,"tag:yaml.org,2002:str"!==n),e[Wt]}(e.schema,r,l,n,s):"scalar"===t.type?function({atKey:e,directives:t,schema:n},s,r,o){const i=n.tags.find(t=>(!0===t.default||e&&"key"===t.default)&&t.test?.test(s))||n[Wt];if(n.compat){const e=n.compat.find(e=>e.default&&e.test?.test(s))??n[Wt];if(i.tag!==e.tag){o(r,"TAG_RESOLVE_FAILED",`Value may be parsed as either ${t.tagString(i.tag)} or ${t.tagString(e.tag)}`,!0)}}return i}(e,r,t,s):e.schema[Wt];try{const o=c.resolve(r,e=>s(n??t,"TAG_RESOLVE_FAILED",e),e.options);u=Zt(o)?o:new kn(o)}catch(d){const e=d instanceof Error?d.message:String(d);s(n??t,"TAG_RESOLVE_FAILED",e),u=new kn(r)}return u.range=a,u.source=r,o&&(u.type=o),l&&(u.tag=l),c.format&&(u.format=c.format),i&&(u.comment=i),u}function Mr(e,t,n){if(t){n??(n=t.length);for(let s=n-1;s>=0;--s){let n=t[s];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++s];"space"===n?.type;)e+=n.source.length,n=t[++s];break}}return e}const Lr={composeNode:Tr,composeEmptyNode:Or};function Tr(e,t,n,s){const r=e.atKey,{spaceBefore:o,comment:i,anchor:a,tag:l}=n;let c,u=!0;switch(t.type){case"alias":c=function({options:e},{offset:t,source:n,end:s},r){const o=new bn(n.substring(1));""===o.source&&r(t,"BAD_ALIAS","Alias cannot be an empty string");o.source.endsWith(":")&&r(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const i=t+n.length,a=xr(s,i,e.strict,r);o.range=[t,i,a.offset],a.comment&&(o.comment=a.comment);return o}(e,t,s),(a||l)&&s(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=jr(e,t,l,s),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=function(e,t,n,s,r){const o=s.tag,i=o?t.directives.tagName(o.source,e=>r(o,"TAG_RESOLVE_FAILED",e)):null;if("block-seq"===n.type){const{anchor:e,newlineAfterProp:t}=s,n=e&&o?e.offset>o.offset?e:o:e??o;n&&(!t||t.offset<n.offset)&&r(n,"MISSING_CHAR","Missing newline after block sequence props")}const a="block-map"===n.type?"map":"block-seq"===n.type?"seq":"{"===n.start.source?"map":"seq";if(!o||!i||"!"===i||i===os.tagName&&"map"===a||i===as.tagName&&"seq"===a)return vr(e,t,n,r,i);let l=t.schema.tags.find(e=>e.tag===i&&e.collection===a);if(!l){const s=t.schema.knownTags[i];if(s?.collection!==a)return s?r(o,"BAD_COLLECTION_TYPE",`${s.tag} used for ${a} collection, but expects ${s.collection??"scalar"}`,!0):r(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),vr(e,t,n,r,i);t.schema.tags.push(Object.assign({},s,{default:!1})),l=s}const c=vr(e,t,n,r,i,l),u=l.resolve?.(c,e=>r(o,"TAG_RESOLVE_FAILED",e),t.options)??c,d=nn(u)?u:new kn(u);return d.range=c.range,d.tag=i,l?.format&&(d.format=l.format),d}(Lr,e,t,n,s),a&&(c.anchor=a.source.substring(1))}catch(d){s(t,"RESOURCE_EXHAUSTION",d instanceof Error?d.message:String(d))}break;default:s(t,"UNEXPECTED_TOKEN","error"===t.type?t.message:`Unsupported token (type: ${t.type})`),u=!1}if(c??(c=Or(e,t.offset,void 0,null,n,s)),a&&""===c.anchor&&s(a,"BAD_ALIAS","Anchor cannot be an empty string"),r&&e.options.stringKeys&&(!Zt(c)||"string"!=typeof c.value||c.tag&&"tag:yaml.org,2002:str"!==c.tag)){s(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings")}return o&&(c.spaceBefore=!0),i&&("scalar"===t.type&&""===t.source?c.comment=i:c.commentBefore=i),e.options.keepSourceTokens&&u&&(c.srcToken=t),c}function Or(e,t,n,s,{spaceBefore:r,comment:o,anchor:i,tag:a,end:l},c){const u=jr(e,{type:"scalar",offset:Mr(t,n,s),indent:-1,source:""},a,c);return i&&(u.anchor=i.source.substring(1),""===u.anchor&&c(i,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(u.spaceBefore=!0),o&&(u.comment=o,u.range[2]=l),u}function Ar(e){if("number"==typeof e)return[e,e+1];if(Array.isArray(e))return 2===e.length?e:[e[0],e[1]];const{offset:t,source:n}=e;return[t,t+("string"==typeof n?n.length:1)]}function Rr(e){let t="",n=!1,s=!1;for(let r=0;r<e.length;++r){const o=e[r];switch(o[0]){case"#":t+=(""===t?"":s?"\n\n":"\n")+(o.substring(1)||" "),n=!0,s=!1;break;case"%":"#"!==e[r+1]?.[0]&&(r+=1),n=!1;break;default:n||(s=!0),n=!1}}return{comment:t,afterEmptyLine:s}}class Ir{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,s)=>{const r=Ar(e);s?this.warnings.push(new ur(r,t,n)):this.errors.push(new cr(r,t,n))},this.directives=new fn({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:n,afterEmptyLine:s}=Rr(this.prelude);if(n){const r=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(s||e.directives.docStart||!r)e.commentBefore=n;else if(tn(r)&&!r.flow&&r.items.length>0){let e=r.items[0];Qt(e)&&(e=e.key);const t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{const e=r.commentBefore;r.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Rr(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(const s of e)yield*this.next(s);yield*this.end(t,n)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,n,s)=>{const r=Ar(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",n,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=function(e,t,{offset:n,start:s,value:r,end:o},i){const a=Object.assign({_directives:t},e),l=new ir(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=fr(s,{indicator:"doc-start",next:r??o?.[0],offset:n,onError:i,parentIndent:0,startOnNewline:!0});u.found&&(l.directives.docStart=!0,!r||"block-map"!==r.type&&"block-seq"!==r.type||u.hasNewline||i(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=r?Tr(c,r,u,i):Or(c,u.end,s,null,u,i);const d=l.contents.range[2],f=xr(o,d,!1,i);return f.comment&&(l.comment=f.comment),l.range=[n,d,f.offset],l}(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{const t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new cr(Ar(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){const t="Unexpected doc-end without preceding document";this.errors.push(new cr(Ar(e),"UNEXPECTED_TOKEN",t));break}this.doc.directives.docEnd=!0;const t=xr(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new cr(Ar(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){const e=Object.assign({_directives:this.directives},this.options),n=new ir(void 0,e);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,t,t],this.decorate(n,!1),yield n}}}function _r(e){switch(e){case void 0:case" ":case"\n":case"\r":case"\t":return!0;default:return!1}}const Dr=new Set("0123456789ABCDEFabcdef"),$r=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Fr=new Set(",[]{}"),Pr=new Set(" ,[]{}\n\r\t"),qr=e=>!e||Pr.has(e);class Br{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if("string"!=typeof e)throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??"stream";for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;" "===t||"\t"===t;)t=this.buffer[++e];return!t||"#"===t||"\n"===t||"\r"===t&&"\n"===this.buffer[e+1]}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;" "===t;)t=this.buffer[++n+e];if("\r"===t){const t=this.buffer[n+e+1];if("\n"===t||!t&&!this.atEnd)return e+n+1}return"\n"===t||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if("-"===t||"."===t){const t=this.buffer.substr(e,3);if(("---"===t||"..."===t)&&_r(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return("number"!=typeof e||-1!==e&&e<this.pos)&&(e=this.buffer.indexOf("\n",this.pos),this.lineEndPos=e),-1===e?this.atEnd?this.buffer.substring(this.pos):null:("\r"===this.buffer[e-1]&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(null===e)return this.setNext("stream");if("\ufeff"===e[0]&&(yield*this.pushCount(1),e=e.substring(1)),"%"===e[0]){let t=e.length,n=e.indexOf("#");for(;-1!==n;){const s=e[n-1];if(" "===s||"\t"===s){t=n-1;break}n=e.indexOf("#",n+1)}for(;;){const n=e[t-1];if(" "!==n&&"\t"!==n)break;t-=1}const s=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){const t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield"\x02",yield*this.parseLineStart()}*parseLineStart(){const e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if("-"===e||"."===e){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");const e=this.peek(3);if(("---"===e||"..."===e)&&_r(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,"---"===e?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!_r(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if(("-"===e||"?"===e||":"===e)&&_r(t)){const e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const e=this.getLine();if(null===e)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(qr),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=(yield*this.parseBlockScalarHeader()),t+=(yield*this.pushSpaces(!0)),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do{e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=(yield*this.pushSpaces(!0))}while(e+t>0);const s=this.getLine();if(null===s)return this.setNext("flow");if(-1!==n&&n<this.indentNext&&"#"!==s[0]||0===n&&(s.startsWith("---")||s.startsWith("..."))&&_r(s[3])){if(!(n===this.indentNext-1&&1===this.flowLevel&&("]"===s[0]||"}"===s[0])))return this.flowLevel=0,yield"\x18",yield*this.parseLineStart()}let r=0;for(;","===s[r];)r+=(yield*this.pushCount(1)),r+=(yield*this.pushSpaces(!0)),this.flowKey=!1;switch(r+=(yield*this.pushIndicators()),s[r]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-r),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(qr),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const e=this.charAt(1);if(this.flowKey||_r(e)||","===e)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const e=this.charAt(0);let t=this.buffer.indexOf(e,this.pos+1);if("'"===e)for(;-1!==t&&"'"===this.buffer[t+1];)t=this.buffer.indexOf("'",t+2);else for(;-1!==t;){let e=0;for(;"\\"===this.buffer[t-1-e];)e+=1;if(e%2==0)break;t=this.buffer.indexOf('"',t+1)}const n=this.buffer.substring(0,t);let s=n.indexOf("\n",this.pos);if(-1!==s){for(;-1!==s;){const e=this.continueScalar(s+1);if(-1===e)break;s=n.indexOf("\n",e)}-1!==s&&(t=s-("\r"===n[s-1]?2:1))}if(-1===t){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){const t=this.buffer[++e];if("+"===t)this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if("-"!==t)break}return yield*this.pushUntil(e=>_r(e)||"#"===e)}*parseBlockScalar(){let e,t=this.pos-1,n=0;e:for(let r=this.pos;e=this.buffer[r];++r)switch(e){case" ":n+=1;break;case"\n":t=r,n=0;break;case"\r":{const e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext("block-scalar");if("\n"===e)break}default:break e}if(!e&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){-1===this.blockScalarIndent?this.indentNext=n:this.indentNext=this.blockScalarIndent+(0===this.indentNext?1:this.indentNext);do{const e=this.continueScalar(t+1);if(-1===e)break;t=this.buffer.indexOf("\n",e)}while(-1!==t);if(-1===t){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let s=t+1;for(e=this.buffer[s];" "===e;)e=this.buffer[++s];if("\t"===e){for(;"\t"===e||" "===e||"\r"===e||"\n"===e;)e=this.buffer[++s];t=s-1}else if(!this.blockScalarKeep)for(;;){let e=t-1,s=this.buffer[e];"\r"===s&&(s=this.buffer[--e]);const r=e;for(;" "===s;)s=this.buffer[--e];if(!("\n"===s&&e>=this.pos&&e+1+n>r))break;t=e}return yield"\x1f",yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const e=this.flowLevel>0;let t,n=this.pos-1,s=this.pos-1;for(;t=this.buffer[++s];)if(":"===t){const t=this.buffer[s+1];if(_r(t)||e&&Fr.has(t))break;n=s}else if(_r(t)){let r=this.buffer[s+1];if("\r"===t&&("\n"===r?(s+=1,t="\n",r=this.buffer[s+1]):n=s),"#"===r||e&&Fr.has(r))break;if("\n"===t){const e=this.continueScalar(s+1);if(-1===e)break;s=Math.max(s,e-2)}}else{if(e&&Fr.has(t))break;n=s}return t||this.atEnd?(yield"\x1f",yield*this.pushToIndex(n+1,!0),e?"flow":"doc"):this.setNext("plain-scalar")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){const n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=(yield*this.pushTag()),e+=(yield*this.pushSpaces(!0));continue e;case"&":e+=(yield*this.pushUntil(qr)),e+=(yield*this.pushSpaces(!0));continue e;case"-":case"?":case":":{const t=this.flowLevel>0,n=this.charAt(1);if(_r(n)||t&&Fr.has(n)){t?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=(yield*this.pushCount(1)),e+=(yield*this.pushSpaces(!0));continue e}}}break e}return e}*pushTag(){if("<"===this.charAt(1)){let e=this.pos+2,t=this.buffer[e];for(;!_r(t)&&">"!==t;)t=this.buffer[++e];return yield*this.pushToIndex(">"===t?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if($r.has(t))t=this.buffer[++e];else{if("%"!==t||!Dr.has(this.buffer[e+1])||!Dr.has(this.buffer[e+2]))break;t=this.buffer[e+=3]}return yield*this.pushToIndex(e,!1)}}*pushNewline(){const e=this.buffer[this.pos];return"\n"===e?yield*this.pushCount(1):"\r"===e&&"\n"===this.charAt(1)?yield*this.pushCount(2):0}*pushSpaces(e){let t,n=this.pos-1;do{t=this.buffer[++n]}while(" "===t||e&&"\t"===t);const s=n-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=n),s}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}class Kr{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){const s=t+n>>1;this.lineStarts[s]<e?t=s+1:n=s}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(0===t)return{line:0,col:e};return{line:t,col:e-this.lineStarts[t-1]+1}}}}function zr(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Hr(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Ur(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Wr(e){switch(e.type){case"document":return e.start;case"block-map":{const t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Yr(e){if(0===e.length)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;"space"===e[++t]?.type;);return e.splice(t,e.length)}function Xr(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function Vr(e){if("flow-seq-start"===e.start.type)for(const t of e.items)!t.sep||t.value||zr(t.start,"explicit-key-ind")||zr(t.sep,"map-value-ind")||(t.key&&(t.value=t.key),delete t.key,Ur(t.value)?t.value.end?Xr(t.value.end,t.sep):t.value.end=t.sep:Xr(t.start,t.sep),delete t.sep)}class Jr{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Br,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&0===this.offset&&this.onNewLine(0);for(const n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar)return this.atScalar=!1,yield*this.step(),void(this.offset+=e.length);const t=function(e){switch(e){case"\ufeff":return"byte-order-mark";case"\x02":return"doc-mode";case"\x18":return"flow-error-end";case"\x1f":return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case"\n":case"\r\n":return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}(e);if(t)if("scalar"===t)this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&" "===e[0]&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{const t=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:t,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const e=this.peek(1);if("doc-end"!==this.type||"doc-end"===e?.type){if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}else{for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source})}}peek(e){return this.stack[this.stack.length-e]}*pop(e){const t=e??this.stack.pop();if(t)if(0===this.stack.length)yield t;else{const e=this.peek(1);switch("block-scalar"===t.type?t.indent="indent"in e?e.indent:0:"flow-collection"===t.type&&"document"===e.type&&(t.indent=0),"flow-collection"===t.type&&Vr(t),e.type){case"document":e.value=t;break;case"block-scalar":e.props.push(t);break;case"block-map":{const n=e.items[e.items.length-1];if(n.value)return e.items.push({start:[],key:t,sep:[]}),void(this.onKeyLine=!0);if(!n.sep)return Object.assign(n,{key:t,sep:[]}),void(this.onKeyLine=!n.explicitKey);n.value=t;break}case"block-seq":{const n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case"flow-collection":{const n=e.items[e.items.length-1];return void(!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]}))}default:yield*this.pop(),yield*this.pop(t)}if(!("document"!==e.type&&"block-map"!==e.type&&"block-seq"!==e.type||"block-map"!==t.type&&"block-seq"!==t.type)){const n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&-1===Hr(n.start)&&(0===t.indent||n.start.every(e=>"comment"!==e.type||e.indent<t.indent))&&("document"===e.type?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}else{const e="Tried to pop an empty stack";yield{type:"error",offset:this.offset,source:"",message:e}}}*stream(){switch(this.type){case"directive-line":return void(yield{type:"directive",offset:this.offset,source:this.source});case"byte-order-mark":case"space":case"comment":case"newline":return void(yield this.sourceToken);case"doc-mode":case"doc-start":{const e={type:"document",offset:this.offset,start:[]};return"doc-start"===this.type&&e.start.push(this.sourceToken),void this.stack.push(e)}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":return void(-1!==Hr(e.start)?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken));case"anchor":case"tag":case"space":case"comment":case"newline":return void e.start.push(this.sourceToken)}const t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if("map-value-ind"===this.type){const t=Yr(Wr(this.peek(2)));let n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];const s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":return void e.props.push(this.sourceToken);case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const n="end"in t.value?t.value.end:void 0,s=Array.isArray(n)?n[n.length-1]:void 0;"comment"===s?.type?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const n=e.items[e.items.length-2],s=n?.value?.end;if(Array.isArray(s))return Xr(s,t.start),s.push(this.sourceToken),void e.items.pop()}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const n=!this.onKeyLine&&this.indent===e.indent,s=n&&(t.sep||t.explicitKey)&&"seq-item-ind"!==this.type;let r=[];if(s&&t.sep&&!t.value){const n=[];for(let s=0;s<t.sep.length;++s){const r=t.sep[s];switch(r.type){case"newline":n.push(s);break;case"space":break;case"comment":r.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(r=t.sep.splice(n[1]))}switch(this.type){case"anchor":case"tag":return void(s||t.value?(r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken));case"explicit-key-ind":return t.sep||t.explicitKey?s||t.value?(r.push(this.sourceToken),e.items.push({start:r,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}):(t.start.push(this.sourceToken),t.explicitKey=!0),void(this.onKeyLine=!0);case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(zr(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(Ur(t.key)&&!zr(t.sep,"newline")){const e=Yr(t.start),n=t.key,s=t.sep;s.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:s}]})}else r.length>0?t.sep=t.sep.concat(r,this.sourceToken):t.sep.push(this.sourceToken);else if(zr(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const e=Yr(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||s?e.items.push({start:r,key:null,sep:[this.sourceToken]}):zr(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return void(this.onKeyLine=!0);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const n=this.flowScalar(this.type);return void(s||t.value?(e.items.push({start:r,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0))}default:{const s=this.startBlockValue(e);if(s){if("block-seq"===s.type){if(!t.explicitKey&&t.sep&&!zr(t.sep,"newline"))return void(yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source}))}else n&&e.items.push({start:r});return void this.stack.push(s)}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){const n="end"in t.value?t.value.end:void 0,s=Array.isArray(n)?n[n.length-1]:void 0;"comment"===s?.type?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){const n=e.items[e.items.length-2],s=n?.value?.end;if(Array.isArray(s))return Xr(s,t.start),s.push(this.sourceToken),void e.items.pop()}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;return void t.start.push(this.sourceToken);case"seq-item-ind":if(this.indent!==e.indent)break;return void(t.value||zr(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken))}if(this.indent>e.indent){const t=this.startBlockValue(e);if(t)return void this.stack.push(t)}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if("flow-error-end"===this.type){let e;do{yield*this.pop(),e=this.peek(1)}while("flow-collection"===e?.type)}else if(0===e.end.length){switch(this.type){case"comma":case"explicit-key-ind":return void(!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken));case"map-value-ind":return void(!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]}));case"space":case"comment":case"newline":case"anchor":case"tag":return void(!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken));case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const n=this.flowScalar(this.type);return void(!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]}))}case"flow-map-end":case"flow-seq-end":return void e.end.push(this.sourceToken)}const n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{const t=this.peek(2);if("block-map"===t.type&&("map-value-ind"===this.type&&t.indent===e.indent||"newline"===this.type&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if("map-value-ind"===this.type&&"flow-collection"!==t.type){const n=Yr(Wr(t));Vr(e);const s=e.end.splice(1,e.end.length);s.push(this.sourceToken);const r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const t=Yr(Wr(e));return t.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const t=Yr(Wr(e));return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return"comment"===this.type&&(!(this.indent<=t)&&e.every(e=>"newline"===e.type||"space"===e.type))}*documentEnd(e){"doc-mode"!==this.type&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop())}}}function Gr(e,t={}){const{lineCounter:n,prettyErrors:s}=function(e){const t=!1!==e.prettyErrors;return{lineCounter:e.lineCounter||t&&new Kr||null,prettyErrors:t}}(t),r=new Jr(n?.addNewLine),o=new Ir(t);let i=null;for(const a of o.compose(r.parse(e),!0,e.length))if(i){if("silent"!==i.options.logLevel){i.errors.push(new cr(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}}else i=a;return s&&n&&(i.errors.forEach(dr(e,n)),i.warnings.forEach(dr(e,n))),i}function Qr(e,t,n){let s;const r=Gr(e,n);if(!r)return null;if(r.warnings.forEach(e=>Un(r.options.logLevel,e)),r.errors.length>0){if("silent"!==r.options.logLevel)throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:s},n))}const Zr=["user","feedback","project","reference"];function eo(e){return Zr.includes(e)}const to=new Set(["name","description","type"]);function no(e){if("string"==typeof e){const t=e.trim();return t.length>0?t:null}return"number"==typeof e||"boolean"==typeof e?String(e):null}function so(e){const t=e.match(/^---[ \t]*\r?\n([\s\S]*?)\n---[ \t]*(?:\r?\n([\s\S]*)|$)/),n={name:null,description:null,type:null,otherFields:[],content:e,hasFrontmatter:!1};if(!t)return n;const s=t[1],r=t[2]??"";let o;try{const e=Qr(s);if(null===e||"object"!=typeof e||Array.isArray(e))return n;o=e}catch{return n}const i=[];for(const[u,d]of Object.entries(o)){if(to.has(u))continue;const e=no(d);null!==e&&i.push({key:u,value:e})}const a=no(o.name),l=no(o.description),c=no(o.type);return null===a&&null===l&&null===c&&0===i.length?n:{name:a,description:l,type:c,otherFields:i,content:r,hasFrontmatter:!0}}let ro=null;function oo(){return ro||(ro=async function(){const e=await n(()=>import("./cc8af9271-B1MY0OBn.js").then(e=>e.e),__vite__mapDeps([0,1]),import.meta.url);return self.MonacoEnvironment={getWorker:(e,t)=>"json"===t?new Worker("/monaco-workers/json.worker.js"):new Worker("/monaco-workers/editor.worker.js")},e}().catch(e=>{throw ro=null,e})),ro}const io=e.memo(function({className:n}){const[s,r]=e.useState(!1);return e.useEffect(()=>{const e=window.setTimeout(()=>r(!0),150);return()=>window.clearTimeout(e)},[]),s?t.jsxs("div",{role:"status",className:n,children:[t.jsx(De,{size:"lg"}),t.jsx("span",{className:"sr-only",children:t.jsx(i,{defaultMessage:"Loading...",id:"gjBiyjshwX"})})]}):null}),ao="_editor_1sugz_4",lo={bash:"shell",fish:"shell",batch:"bat",docker:"dockerfile",svg:"xml",latex:"latex",plaintext:"plaintext",skill:"markdown",csv:"plaintext",tsv:"plaintext",asciidoc:"plaintext",mermaid:"plaintext"};function co(e){return e?lo[e]??e:"plaintext"}const uo={automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,lineHeight:22,fontFamily:"var(--font-mono)",fontLigatures:!1,lineNumbers:"on",lineNumbersMinChars:5,glyphMargin:!1,folding:!1,lineDecorationsWidth:12,renderLineHighlight:"none",overviewRulerLanes:0,hideCursorInOverviewRuler:!0,overviewRulerBorder:!1,guides:{indentation:!1},scrollbar:{vertical:"auto",horizontal:"hidden",verticalScrollbarSize:8,useShadows:!1},padding:{top:0,bottom:8},wordWrap:"on",wrappingStrategy:"advanced",tabSize:2};function fo({content:n,language:s,onSave:r,isSaving:o=!1}){const a="dark"===$e()?"vs-dark":"vs-light",l=e.useId(),c=e.useRef(null),u=e.useRef(null),d=e.useRef(null),f=e.useRef(!1),[h,m]=e.useState(!1),[p,g]=e.useState(!1),[x,y]=e.useState(n),[b,v]=e.useState(!1),w=x!==n,k=o||b,S=e.useRef(()=>{});e.useEffect(()=>{const e=c.current;if(!e)return;let t=!1;return oo().then(r=>{if(t)return;d.current=r;const o=r.editor.create(e,{...uo,value:n,language:co(s),theme:a,ariaLabel:"File contents. Press Escape then Tab to move focus out of the editor."});u.current=o,o.onDidChangeModelContent(()=>{f.current||(o.updateOptions({tabFocusMode:!1}),y(o.getValue()))}),o.onKeyDown(e=>{e.keyCode===r.KeyCode.Escape&&(o.updateOptions({tabFocusMode:!0}),e.browserEvent.stopPropagation(),e.browserEvent.preventDefault())}),o.onDidBlurEditorWidget(()=>{o.updateOptions({tabFocusMode:!1})}),o.addCommand(r.KeyMod.CtrlCmd|r.KeyCode.KeyS,()=>{S.current()}),m(!0)}).catch(e=>{t||(console.error("[Monaco] init failed:",e),g(!0))}),()=>{t=!0,u.current?.getModel()?.dispose(),u.current?.dispose(),u.current=null}},[]),e.useEffect(()=>{y(n);const e=u.current;e&&e.getValue()!==n&&(f.current=!0,e.setValue(n),f.current=!1)},[n,h]),e.useEffect(()=>{const e=u.current?.getModel();e&&d.current&&d.current.editor.setModelLanguage(e,co(s))},[s,h]),e.useEffect(()=>{d.current?.editor.setTheme(a)},[a,h]),e.useEffect(()=>{u.current?.updateOptions({readOnly:k})},[k,h]),e.useEffect(()=>{if(!w)return;const e=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[w]);const C=e.useCallback(async()=>{if(w&&!k){v(!0);try{await r(x)}finally{v(!1)}}},[w,k,r,x]);e.useEffect(()=>{S.current=()=>{C()}},[C]);const N=e.useCallback(()=>{const e=u.current;e&&(f.current=!0,e.setValue(n),f.current=!1,y(n))},[n]);return t.jsxs("div",{role:"group","aria-describedby":l,className:"flex h-full flex-col",children:[t.jsx("span",{id:l,className:"sr-only",children:t.jsx(i,{defaultMessage:"Press Escape then Tab to move focus out of the editor.",id:"37WGHZNGfH"})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[!h&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:p?t.jsx("span",{className:"text-text-300 text-sm",children:t.jsx(i,{defaultMessage:"Editor failed to load. Refresh to try again.",id:"LKg3IXHCco"})}):t.jsx(io,{})}),t.jsx("div",{ref:c,className:`h-full w-full pl-[3px] ${ao}`})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-border-300 bg-bg-000 px-3 py-2",children:[w&&t.jsx("span",{className:"mr-auto text-xs text-text-400",children:t.jsx(i,{defaultMessage:"Unsaved changes",id:"j7WSfaqwyX"})}),t.jsx(Fe,{variant:"ghost",size:"sm",onClick:N,disabled:!w||k,children:t.jsx(i,{defaultMessage:"Discard",id:"nmpevlUATU"})}),t.jsx(Fe,{variant:"primary",size:"sm",onClick:C,disabled:!w||k,busy:k,children:t.jsx(i,{defaultMessage:"Save",id:"jvo0vs3nF0"})})]})]})}const ho=["bat","cmd","com","exe","msi","ps1","vb","vbs","wsf","wsh","app","command","scpt","scptd","applescript","workflow","jar","jnlp"];function mo(e){return"skill"===e||"plugin"===e}function po(e,t){return mo(t)?{displayName:e.replace(/\.(skill|plugin)$/i,""),displayExt:null}:go(e)}function go(e){const t=function(e){if(/[\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/.test(e))return{valid:!1,error:"Filename contains invalid whitespace characters"};if(/[\x00-\x1F\x7F]/.test(e))return{valid:!1,error:"Filename contains control characters"};if(e.includes("\\"))return{valid:!1,error:"Filename contains invalid path characters"};if(/[.\s]$/.test(e))return{valid:!1,error:"Filename has invalid trailing characters"};const t=e.split(".");if(t.length>1){const e=t[t.length-1].toLowerCase();if(ho.includes(e))return{valid:!1,error:`Unsupported file type: .${e}`}}return{valid:!0}}(e);if(!t.valid)return{displayName:"",displayExt:null,error:t.error};const n=e.split("."),s=n.slice(0,-1).join("."),r=n.length>1?n.at(-1)??"":null,o=s.replaceAll(/[_-]/g," ");return{displayName:Xe(o),displayExt:r?r.toUpperCase():null}}function xo(e){if("SKILL.md"===e)return"skill";const t=e.split(".").pop()?.toLowerCase();return t?["skill"].includes(t)?"skill":"plugin"===t?"plugin":["csv","tsv"].includes(t)?"table":["xls","xlsx"].includes(t)?"spreadsheet":["pptx"].includes(t)?"preso":["pdf","md","docx"].includes(t)?"doc":["mermaid","mmd"].includes(t)?"diagram":["jsx","tsx"].includes(t)?"code":["svg"].includes(t)||u.includes(t)?"image":d.includes(t)?"code":null:null}const yo="_prose_6pqpd_8",bo="_portal_6pqpd_116",vo="_tableScroll_6pqpd_144",wo="_editor_6pqpd_202";let ko=null,So=null;function Co(){return So??=n(()=>import("./c2abd4ebb-C55uL3DR.js"),[],import.meta.url).then(async e=>(await e.default(),ko=e,e)).catch(e=>{throw So=null,e}),So}function No(){return ko}const Eo=e.memo(function({text:n,className:r,analyticsCtx:o}){const i=f(),a=h({analytics:i,analyticsCtx:o}),l=e.useRef({viewed:!1,renderFailed:!1,mountedAt:0}),c=e.useRef(null),u=e.useRef(null),[d,S]=e.useState(null),[C,N]=e.useState(!1),[E,j]=e.useState(!1),[M,L]=e.useState([]),[T,O]=e.useState(null),[A,R]=e.useState(0),{katex:I}=m();e.useEffect(()=>{let e=!0;return l.current.mountedAt=performance.now(),Co().then(t=>{e&&S(t)},t=>{if(e){N(!0);const e=a.current;e.analytics.track({event_key:"claudeai.brass_falcon.load_failed",...e.analyticsCtx,mode:"view",error_kind:p(t)})}}),()=>{e=!1}},[a]),e.useEffect(()=>()=>{u.current?.free(),u.current=null},[]),e.useLayoutEffect(()=>{const e=c.current;if(!d||!e)return;try{u.current??=new d.ClarkdownEditor,u.current.set_source(n),e.innerHTML=g.sanitize(u.current.render_html(),{USE_PROFILES:{html:!0},FORBID_TAGS:["img"]})}catch(s){if(console.error("ClarkdownMarkdown render failed",s),j(!0),!l.current.renderFailed){l.current.renderFailed=!0;const e=a.current;e.analytics.track({event_key:"claudeai.brass_falcon.render_failed",...e.analyticsCtx,content_length:n.length,error_kind:p(s)})}return}if(j(!1),!l.current.viewed){l.current.viewed=!0;const e=a.current;e.analytics.track({event_key:"claudeai.brass_falcon.viewed",...e.analyticsCtx,load_ms:Math.round(performance.now()-l.current.mountedAt),content_length:n.length})}for(const n of e.querySelectorAll("a[href]"))/^https?:/i.test(n.getAttribute("href")??"")&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"));for(const n of e.querySelectorAll("table")){const e=document.createElement("div");e.className=vo,n.replaceWith(e),e.append(n)}const t=[];for(const r of e.querySelectorAll("figure.ck-rich")){const e=Number(r.getAttribute("data-ck-s")),s=Number(r.getAttribute("data-ck-e"));if(!Number.isFinite(e)||!Number.isFinite(s))continue;const o=([...r.classList].find(e=>"ck-rich"!==e&&e.startsWith("ck-"))??"ck-code").slice(3),i=n.slice(e,s).replace(/^[~`]{3,}\S*\r?\n/,"").replace(/\r?\n[~`]{3,}\s*$/,""),a=document.createElement("div");a.className=bo,a.setAttribute("data-ck-s",String(e)),a.setAttribute("data-ck-e",String(s)),r.replaceWith(a),t.push({mount:a,code:i,className:`language-${o}`})}for(const n of e.querySelectorAll("pre > code")){const e=n.parentElement;if(!e)continue;const s=document.createElement("div");s.className=bo;for(const t of e.attributes)t.name.startsWith("data-")&&s.setAttribute(t.name,t.value);e.replaceWith(s),t.push({mount:s,code:n.textContent??"",className:n.className||void 0})}L(t),R(e=>e+1)},[d,n,a]),e.useEffect(()=>{const e=c.current;if(I&&e)for(const t of e.querySelectorAll(".math:not([data-ck-math])")){const e=t.textContent??"",n=t.classList.contains("math-display"),s=e.replace(/^\s*\\[([]/,"").replace(/\\[)\]]\s*$/,"");I.render(s,t,{displayMode:n,throwOnError:!1,errorColor:"inherit",output:"htmlAndMathml",strict:!1}),t.setAttribute("data-ck-math",""),t.setAttribute("role","math"),n&&(t.setAttribute("tabindex","0"),t.classList.add("can-focus"))}},[I,A]);const _=e.useCallback(e=>{const t=e.target.closest("a"),n=t?.getAttribute("href");t&&n&&c.current?.contains(t)&&(x(n)?e.preventDefault():y(n)||(e.metaKey||e.ctrlKey||e.shiftKey||0!==e.button)&&!b(n)||(e.preventDefault(),/^(https?:|mailto:|tel:)/i.test(n)&&O(n)))},[]),D=e.useCallback(()=>O(null),[]),$=e.useCallback(()=>{T&&window.open(T,"_blank","noopener,noreferrer"),O(null)},[T]),F=C||E;return t.jsxs(t.Fragment,{children:[F&&t.jsx("pre",{className:v("whitespace-pre-wrap break-words",r),children:n}),t.jsx("div",{ref:c,onClick:_,onAuxClick:e=>{1===e.button&&_(e)},hidden:F,className:v(yo,r)}),!F&&M.map((e,n)=>s.createPortal(t.jsx(w.pre,{className:e.className,children:e.code}),e.mount,`${n}:${e.className??""}`)),t.jsx(k,{isOpen:null!==T,url:T??"",onClose:D,onConfirm:$})]})}),jo={name:"TextStrikethrough",viewBox:256,paths:["M224,128a8,8,0,0,1-8,8H175.93c9.19,7.11,16.07,17.2,16.07,32,0,13.34-7,25.7-19.75,34.79C160.33,211.31,144.61,216,128,216s-32.33-4.69-44.25-13.21C71,193.7,64,181.34,64,168a8,8,0,0,1,16,0c0,17.35,22,32,48,32s48-14.65,48-32c0-14.85-10.54-23.58-38.77-32H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM76.33,104a8,8,0,0,0,7.61-10.49A17.3,17.3,0,0,1,83.11,88c0-18.24,19.3-32,44.89-32,18.84,0,34.16,7.42,41,19.85a8,8,0,0,0,14-7.7C173.33,50.52,152.77,40,128,40,93.29,40,67.11,60.63,67.11,88a33.73,33.73,0,0,0,1.62,10.49A8,8,0,0,0,76.33,104Z"]};function Mo(e){return e.startsWith("[")&&e.endsWith(")")&&-1!==e.lastIndexOf("](")}function Lo(e){const t=e.lastIndexOf("]("),n=e.lastIndexOf(")");return!(-1===t||n<=t)&&/\s["'(]/.test(e.slice(t+2,n))}function To({trigger:e,children:n,unstyledTrigger:s=!1,...r}){return t.jsx(t.Fragment,{children:t.jsx(Ao,{...r,trigger:s?t.jsx(ot,{asChild:!0,children:e}):t.jsx(Io,{asChild:!0,children:e}),children:n})})}function Oo({children:e,open:n,mainButtonText:s,onClickMainButton:r,triggerClassName:o,buttonClassName:i,mainButtonAriaLabel:a,mainButtonDisabled:l,dropdownAriaLabel:c,align:u="end",...d}){return t.jsx(t.Fragment,{children:t.jsx(Ao,{...d,align:u,trigger:t.jsxs("div",{className:S("flex h-8 whitespace-nowrap",o),children:[t.jsx("button",{className:S("font-base-bold !text-xs rounded-l-lg bg-bg-000 h-full flex items-center justify-center px-2 border-y-0.5 border-l-0.5 border-border-200 hover:bg-bg-200 disabled:opacity-50 disabled:hover:bg-bg-000",n&&"bg-bg-200",i),onClick:r,disabled:l,"aria-label":a,children:s}),t.jsx(ot,{asChild:!0,children:t.jsx("button",{className:S("bg-bg-000 flex items-center justify-center px-1 hover:bg-bg-200 rounded-r-lg border-0.5 border-border-200",i),"aria-label":c,children:t.jsx(rt,{size:16})})})]}),children:e})})}function Ao({matchTriggerWidth:e=!1,children:n,open:s,onOpenChange:r,trigger:o,modal:i,...a}){const l=e?{width:"var(--radix-dropdown-menu-trigger-width)"}:void 0;return t.jsx(t.Fragment,{children:t.jsxs(at,{open:s,onOpenChange:r,modal:i,children:[o,t.jsx(lt,{children:t.jsx(Pe,{children:t.jsx(Ro,{style:l,sideOffset:a.sideOffset??4,...a,children:n})})})]})})}e.forwardRef(({className:e,...n},s)=>t.jsx(it,{ref:s,className:S("outline-none py-2 px-1.5 -mx-1.5 -mt-1.5 mb-1 border-b-0.5 border-border-200",e),...n})).displayName="DropdownInputHeader";const Ro=e.forwardRef(({className:e,style:n,...s},r)=>{const o=M();return t.jsx(ut,{ref:r,className:S("p-1.5",L,T,e),style:void 0!==o?{zIndex:o,...n}:n,...s})});Ro.displayName="Content";const Io=e.forwardRef(({className:e,...n},s)=>t.jsx(ot,{ref:s,className:S("rounded py-1 px-2 max-w-full whitespace-nowrap text-ellipsis overflow-hidden",e),...n}));Io.displayName="Trigger";const _o=yt,Do=e.forwardRef(({className:e,...n},s)=>t.jsx(it,{ref:s,className:S(C,e),...n}));Do.displayName="DropdownLabel";const $o=e.forwardRef(({className:e,disabled:n,danger:s,onSelect:r,onClick:o,...i},a)=>t.jsx(ct,{ref:a,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,onSelect:n?e=>e.preventDefault():r,onClick:n?e=>{e.preventDefault(),e.stopPropagation()}:o,className:S(N,n&&E,s&&j,e),...i}));$o.displayName="BaseDropdownItem";const Fo=e.forwardRef(({children:e,icon:n,trailing:s,...r},o)=>n||s?t.jsx($o,{ref:o,...r,children:t.jsxs("div",{className:"flex items-center gap-2 w-full font-base group",children:[n,t.jsx("span",{className:"flex-1 truncate",children:e}),s&&t.jsx("div",{className:"flex items-center flex-shrink-0 -mr-2",children:s})]})}):t.jsx($o,{ref:o,...r,children:e}));Fo.displayName="DropdownItem";const Po=xt;function qo(e,n,s){return t.jsxs(t.Fragment,{children:[e?t.jsxs("div",{className:"flex items-center gap-2 w-full font-base group",children:[e,t.jsx("span",{className:"flex-1 truncate",children:n}),s]}):s?t.jsxs("div",{className:"flex items-center gap-2 w-full font-base group",children:[t.jsx("span",{className:"flex-1 truncate",children:n}),s]}):n,t.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:t.jsx(gt,{children:t.jsx(I,{size:16,"aria-hidden":"true"})})})]})}const Bo=e.forwardRef(({className:e,disabled:n,danger:s,icon:r,trailing:o,children:i,...a},l)=>t.jsx(ft,{ref:l,disabled:n,className:S(N,n&&E,s&&j,e),...a,children:qo(r,i,o)}));Bo.displayName="DropdownRadioItem";const Ko=e.forwardRef(({className:e,disabled:n,danger:s,icon:r,trailing:o,children:i,...a},l)=>t.jsx(ht,{ref:l,disabled:n,className:S(N,n&&E,s&&j,e),...a,children:qo(r,i,o)}));Ko.displayName="DropdownCheckboxItem";e.forwardRef(({className:e,...n},s)=>t.jsx(mt,{ref:s,className:S(A,e),...n})).displayName="DropdownSubTrigger";e.forwardRef(({className:e,style:n,...s},r)=>{const o=M();return t.jsx(pt,{ref:r,className:S("p-1.5",L,R,e),style:void 0!==o?{zIndex:o,...n}:n,...s})}).displayName="DropdownSubContent";const zo=e.forwardRef(({className:e,...n},s)=>t.jsx(dt,{ref:s,className:S(O,e),...n}));zo.displayName="DropdownSeparator";const Ho={timeZoneName:"short",...bt.DATETIME_MED},Uo=new Set;let Wo=null;function Yo(){"undefined"!=typeof document&&document.hidden||Uo.forEach(e=>e())}function Xo(){"undefined"==typeof document||document.hidden||Yo()}const Vo=e.memo(({datetime:n,locale:s,absoluteAfterHours:r,live:o=!1})=>{const[,i]=e.useReducer(e=>e+1,0);e.useEffect(()=>{var e;if(o)return e=i,Uo.add(e),1===Uo.size&&(Wo=setInterval(Yo,1e4),"undefined"!=typeof document&&document.addEventListener("visibilitychange",Xo)),()=>{Uo.delete(e),0===Uo.size&&(null!==Wo&&(clearInterval(Wo),Wo=null),"undefined"!=typeof document&&document.removeEventListener("visibilitychange",Xo))}},[o]);const a=void 0!==r&&Math.abs(bt.now().diff(n,"hours").hours)>=r;return t.jsx(_,{delayDuration:700,side:"bottom",tooltipContent:n.toLocaleString(Ho),children:t.jsx("span",{children:a?n.toLocaleString(bt.DATETIME_MED):n.toRelative({locale:s})})})});function Jo({name:e}){const n=e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("");return t.jsx("span",{"aria-hidden":!0,className:"flex size-5 shrink-0 select-none items-center justify-center rounded-full bg-bg-400 text-[8px] font-medium tracking-[-0.4px] text-text-500",children:n})}function Go(){}Vo.displayName="RelativeTime";const Qo=e.memo(function(n){const s=o(),{variant:r="inline",isEditing:a,existingComment:l,commentText:u,placeholder:d,onTextChange:f,onSubmit:h,onKeyDown:m,onBlur:p,onEditExisting:g,onDelete:x,onSendToClaude:y,sendDisabled:b=!1,onCancel:w,hideLineRange:k=!1}=n.readonly?{variant:n.variant,hideLineRange:n.hideLineRange,existingComment:n.existingComment,isEditing:!1,commentText:n.existingComment.text,placeholder:"",onTextChange:Go,onSubmit:Go,onKeyDown:Go}:n,[S,C]=e.useState(!1);if("popover"===r){const e=l?.author?.fullName??(!1===l?.isOwn?s.formatMessage({defaultMessage:"Reviewer",id:"Q058X+CmLx"}):s.formatMessage({defaultMessage:"You",id:"kJ5W29okWR"})),n=!l||!1!==l.isOwn,r=t.jsx("textarea",{"aria-label":s.formatMessage({defaultMessage:"Comment",id:"LgbKvU/n17"}),value:u,onChange:e=>f(e.target.value),onKeyDown:m,onBlur:p,onFocus:e=>{const t=e.target.value.length;e.target.setSelectionRange(t,t)},placeholder:d,className:v("min-h-10 flex-1 resize-none rounded border-none bg-transparent","font-ui text-sm leading-5 text-text-000 shadow-none outline-none","placeholder-text-500/80 hide-focus-ring"),style:{fieldSizing:"content"},rows:2,autoFocus:!0});if(!l)return t.jsxs("div",{className:"flex flex-col gap-2",children:[r,t.jsxs("div",{className:v("flex items-center gap-2",y?"justify-end":"justify-between"),children:[!y&&t.jsx(c,{variant:"secondary",size:"sm",onClick:h,disabled:!u.trim(),children:t.jsx(i,{defaultMessage:"Add comment",id:"eiaPxp89eC"})}),y?t.jsx("button",{type:"button",onClick:y,disabled:b||!u.trim(),"aria-label":s.formatMessage({defaultMessage:"Send to Claude",id:"xGC0T/NxhG"}),className:v("flex size-8 items-center justify-center rounded-lg","bg-text-000 text-bg-000 transition-opacity hover:opacity-90","disabled:cursor-not-allowed disabled:opacity-30"),children:t.jsx(Nt,{size:16})}):null]})]});const o=l.createdAt>0?t.jsx(Vo,{datetime:bt.fromMillis(l.createdAt),locale:s.locale}):null,k=t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Jo,{name:e}),t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs",children:[t.jsx("span",{className:"truncate font-semibold text-text-100",children:e}),t.jsx("span",{className:"shrink-0 text-text-500",children:o})]})]});if(a)return t.jsxs("div",{className:"flex flex-col gap-2",children:[k,r,t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(c,{variant:"secondary",size:"sm",onClick:w,children:t.jsx(i,{defaultMessage:"Cancel",id:"47FYwba+bI"})}),t.jsx(c,{variant:"primary",size:"sm",onClick:h,disabled:!u.trim(),children:t.jsx(i,{defaultMessage:"Save",id:"jvo0vs3nF0"})})]})]});const N=!!y||n&&(!!g||!!x);return t.jsxs("div",{tabIndex:0,className:"group/card flex flex-col gap-1",children:[t.jsxs("div",{className:"flex min-h-7 items-center justify-between",children:[k,N?t.jsxs("div",{className:v("flex shrink-0 items-center gap-1",S?"visible":"invisible group-hover/card:visible group-focus-within/card:visible"),children:[y?t.jsx("button",{type:"button",onClick:y,disabled:b,"aria-label":s.formatMessage({defaultMessage:"Send to Claude",id:"xGC0T/NxhG"}),className:v("flex size-7 items-center justify-center rounded-md","text-text-400 transition-colors","hover:bg-bg-200 hover:text-text-100","disabled:cursor-not-allowed disabled:opacity-30"),children:t.jsx(Nt,{size:20})}):null,n&&(g||x)?t.jsxs(To,{open:S,onOpenChange:C,trigger:t.jsx("button",{type:"button","aria-label":s.formatMessage({defaultMessage:"Comment actions",id:"aefFbqzQB/"}),className:v("flex size-7 items-center justify-center rounded-md","text-text-400 transition-colors","hover:bg-bg-200 hover:text-text-100","data-[state=open]:bg-bg-200","data-[state=open]:text-text-100"),children:t.jsx(Et,{size:20})}),children:[g?t.jsx(Fo,{icon:t.jsx(vt,{size:16}),onSelect:g,children:t.jsx(i,{defaultMessage:"Edit",id:"wEQDC6Wv3/"})}):null,x?t.jsx(Fo,{icon:t.jsx(D,{size:16}),danger:!0,onSelect:x,children:t.jsx(i,{defaultMessage:"Delete",id:"K3r6DQW7h+"})}):null]}):null]}):null]}),t.jsx("div",{className:"whitespace-pre-wrap pl-7 font-ui text-xs leading-[1.4] text-text-100",children:l.text})]})}const N=l?.target.anchor,E=!k&&"plaintext"===N?.kind&&N.endLine!==N.startLine,j=u!==(l?.text??"");return t.jsxs("div",{className:v("flex flex-col gap-0.5 pl-3 pr-1.5 py-1.5 rounded-lg border border-border-300","bg-bg-000 shadow-sm transition-colors duration-150",l&&!a&&g&&"cursor-text"),onClick:l&&!a?g:void 0,children:[E&&"plaintext"===N?.kind&&t.jsx("div",{className:"text-xs text-text-400 font-medium",children:s.formatMessage({defaultMessage:"Lines {start}-{end}",id:"YvzXG1OhzH"},{start:N.startLine,end:N.endLine})}),t.jsx("div",{className:"flex items-center gap-2 min-h-8",children:a?t.jsxs(t.Fragment,{children:[t.jsx("textarea",{"aria-label":s.formatMessage({defaultMessage:"Comment",id:"LgbKvU/n17"}),value:u,onChange:e=>f(e.target.value),onKeyDown:m,onBlur:p,onFocus:e=>{const t=e.target.value.length;e.target.setSelectionRange(t,t)},placeholder:d,className:"flex-1 bg-transparent text-sm text-text-000 placeholder-text-500/80 resize-none py-1 leading-5 block font-ui",style:{outline:"none",border:"none",boxShadow:"none",fieldSizing:"content"},rows:1,autoFocus:!0}),j&&t.jsxs("button",{type:"button",onClick:h,disabled:!u.trim(),className:v("flex items-center gap-1.5 px-2 py-1.5 rounded-lg","bg-brand-100 text-oncolor-100","hover:bg-brand-200 disabled:opacity-30","disabled:cursor-not-allowed transition-colors"),"aria-label":s.formatMessage({defaultMessage:"Submit comment",id:"lHfsz7RLjS"}),children:[t.jsx($,{size:16}),t.jsx(F,{shortcut:"enter",small:!0,onDark:!0})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 py-1",children:[!1===l?.isOwn&&t.jsx("div",{className:"truncate text-xs text-text-400",children:l.author?.fullName??s.formatMessage({defaultMessage:"Reviewer",id:"Q058X+CmLx"})}),t.jsx("div",{className:"text-sm text-text-200 leading-5 font-ui whitespace-pre-wrap",children:l?.text})]}),(y||x)&&t.jsxs("div",{className:"flex items-center shrink-0",children:[y&&t.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),y()},className:"p-1.5 rounded-lg text-text-400 hover:bg-bg-200 hover:text-text-100 transition-colors","aria-label":s.formatMessage({defaultMessage:"Send to Claude",id:"xGC0T/NxhG"}),children:t.jsx(jt,{size:14})}),x&&t.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),x()},className:"p-1.5 rounded-lg text-text-400 hover:bg-danger-100/20 transition-colors","aria-label":s.formatMessage({defaultMessage:"Delete comment",id:"wOZRKWT1/R"}),children:t.jsx(D,{size:14})})]})]})})]})});function Zo(){}function ei(e,t,n,s,r){for(var o,i=[];t;)i.push(t),o=t.previousComponent,delete t.previousComponent,t=o;i.reverse();for(var a=0,l=i.length,c=0,u=0;a<l;a++){var d=i[a];if(d.removed){if(d.value=e.join(s.slice(u,u+d.count)),u+=d.count,a&&i[a-1].added){var f=i[a-1];i[a-1]=i[a],i[a]=f}}else{if(!d.added&&r){var h=n.slice(c,c+d.count);h=h.map(function(e,t){var n=s[u+t];return n.length>e.length?n:e}),d.value=e.join(h)}else d.value=e.join(n.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}var m=i[l-1];return l>1&&"string"==typeof m.value&&(m.added||m.removed)&&e.equals("",m.value)&&(i[l-2].value+=m.value,i.pop()),i}Qo.displayName="DiffCommentCard",Zo.prototype={diff:function(e,t){var n,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=s.callback;"function"==typeof s&&(r=s,s={}),this.options=s;var o=this;function i(e){return r?(setTimeout(function(){r(void 0,e)},0),!0):e}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e));var a=(t=this.removeEmpty(this.tokenize(t))).length,l=e.length,c=1,u=a+l;s.maxEditLength&&(u=Math.min(u,s.maxEditLength));var d=null!==(n=s.timeout)&&void 0!==n?n:1/0,f=Date.now()+d,h=[{oldPos:-1,lastComponent:void 0}],m=this.extractCommon(h[0],t,e,0);if(h[0].oldPos+1>=l&&m+1>=a)return i([{value:this.join(t),count:t.length}]);var p=-1/0,g=1/0;function x(){for(var n=Math.max(p,-c);n<=Math.min(g,c);n+=2){var s=void 0,r=h[n-1],u=h[n+1];r&&(h[n-1]=void 0);var d=!1;if(u){var f=u.oldPos-n;d=u&&0<=f&&f<a}var x=r&&r.oldPos+1<l;if(d||x){if(s=!x||d&&r.oldPos+1<u.oldPos?o.addToPath(u,!0,void 0,0):o.addToPath(r,void 0,!0,1),m=o.extractCommon(s,t,e,n),s.oldPos+1>=l&&m+1>=a)return i(ei(o,s.lastComponent,t,e,o.useLongestToken));h[n]=s,s.oldPos+1>=l&&(g=Math.min(g,n-1)),m+1>=a&&(p=Math.max(p,n+1))}else h[n]=void 0}c++}if(r)!function e(){setTimeout(function(){if(c>u||Date.now()>f)return r();x()||e()},0)}();else for(;c<=u&&Date.now()<=f;){var y=x();if(y)return y}},addToPath:function(e,t,n,s){var r=e.lastComponent;return r&&r.added===t&&r.removed===n?{oldPos:e.oldPos+s,lastComponent:{count:r.count+1,added:t,removed:n,previousComponent:r.previousComponent}}:{oldPos:e.oldPos+s,lastComponent:{count:1,added:t,removed:n,previousComponent:r}}},extractCommon:function(e,t,n,s){for(var r=t.length,o=n.length,i=e.oldPos,a=i-s,l=0;a+1<r&&i+1<o&&this.equals(t[a+1],n[i+1]);)a++,i++,l++;return l&&(e.lastComponent={count:l,previousComponent:e.lastComponent}),e.oldPos=i,a},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};var ti=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,ni=/\S/,si=new Zo;si.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!ni.test(e)&&!ni.test(t)},si.tokenize=function(e){for(var t=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),n=0;n<t.length-1;n++)!t[n+1]&&t[n+2]&&ti.test(t[n])&&ti.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var ri=new Zo;function oi(e,t,n){return ri.diff(e,t,n)}function ii(e){return(ii="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}ri.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,"\n"));var t=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var s=0;s<n.length;s++){var r=n[s];s%2&&!this.options.newlineIsToken?t[t.length-1]+=r:(this.options.ignoreWhitespace&&(r=r.trim()),t.push(r))}return t},(new Zo).tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)},(new Zo).tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};var ai=Object.prototype.toString,li=new Zo;function ci(e,t,n,s,r){var o,i;for(t=t||[],n=n||[],s&&(e=s(r,e)),o=0;o<t.length;o+=1)if(t[o]===e)return n[o];if("[object Array]"===ai.call(e)){for(t.push(e),i=new Array(e.length),n.push(i),o=0;o<e.length;o+=1)i[o]=ci(e[o],t,n,s,r);return t.pop(),n.pop(),i}if(e&&e.toJSON&&(e=e.toJSON()),"object"===ii(e)&&null!==e){t.push(e),i={},n.push(i);var a,l=[];for(a in e)e.hasOwnProperty(a)&&l.push(a);for(l.sort(),o=0;o<l.length;o+=1)i[a=l[o]]=ci(e[a],t,n,s,a);t.pop(),n.pop()}else i=e;return i}li.useLongestToken=!0,li.tokenize=ri.tokenize,li.castInput=function(e){var t=this.options,n=t.undefinedReplacement,s=t.stringifyReplacer,r=void 0===s?function(e,t){return void 0===t?n:t}:s;return"string"==typeof e?e:JSON.stringify(ci(e,null,null,r),r,"  ")},li.equals=function(e,t){return Zo.prototype.equals.call(li,e.replace(/,([\r\n])/g,"$1"),t.replace(/,([\r\n])/g,"$1"))};var ui=new Zo;ui.tokenize=function(e){return e.slice()},ui.join=ui.removeEmpty=function(e){return e};const di="data-prose-comment-id",fi="data-prose-review-ignore",hi="prose-review-highlight",mi="prose-review-highlight-active",pi="prose-review-highlight-hover",gi="prose-review-highlight-pending";function xi(e){const t=document.createRange();return t.setStartBefore(e[0]),t.setEndAfter(e[e.length-1]),t}function yi(e){return null===(e.parentElement?.closest(`[${fi}]`)??null)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}const bi=`\n  .${hi} {\n    background-color: hsl(var(--accent-000) / 0.14);\n    color: inherit;\n    cursor: pointer;\n    border-radius: 2px;\n    transition: background-color 150ms ease;\n  }\n  .${hi}.${pi},\n  .${hi}.${mi},\n  .${hi}.${gi} {\n    background-color: hsl(var(--accent-000) / 0.24);\n  }\n  .${hi}.${gi} {\n    cursor: default;\n  }\n`;function vi(e){e.querySelectorAll(`mark[${di}]`).forEach(e=>{const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e),t.normalize()}})}function wi(e,t,n,s){try{const r=document.createRange();r.setStart(e,t),r.setEnd(e,n);const o=document.createElement("mark");return o.setAttribute(di,s),o.className=hi,r.surroundContents(o),o}catch{return null}}const ki=e.memo(function({containerRef:t,comments:n,onCommentClick:s,onCommentHover:r,onCommentHoverEnd:o}){const i=e.useRef(n);i.current=n;const a=e.useRef(s);a.current=s;const l=e.useRef(r);l.current=r;const c=e.useRef(o);return c.current=o,e.useLayoutEffect(()=>{const e=document.createElement("style");return e.textContent=bi,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[]),e.useLayoutEffect(()=>{const e=t.current;if(!e)return;let n=!1,s=0;let r=[];const o=t=>{const n=t.getAttribute(di),s=()=>{const e=i.current.find(e=>e.id===n);if(!e)return null;const s=document.createRange();return s.selectNodeContents(t),{comment:e,range:s}},r=()=>e.querySelectorAll(`mark[${di}="${n}"]`);t.addEventListener("click",e=>{e.stopPropagation();const t=s();t&&a.current?.(t.comment,t.range)}),t.addEventListener("mouseenter",()=>{r().forEach(e=>e.classList.add(pi));const e=s();e&&l.current?.(e.comment,e.range)}),t.addEventListener("mouseleave",()=>{r().forEach(e=>e.classList.remove(pi)),c.current?.()})},u=()=>{const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,yi);let s=0;for(let e=n.nextNode();e;){const r=e.data.length;t.push({node:e,start:s,end:s+r}),s+=r,e=n.nextNode()}return t},d=()=>{n=!0,r=[],vi(e);const t=i.current.filter(e=>null!==e.located);if(0===t.length)return void(n=!1);const s=[...t].sort((e,t)=>t.located.startOffset-e.located.startOffset);for(const e of s){const t=u(),{startOffset:n,endOffset:s}=e.located,i=[];for(const e of t)if(!(e.end<=n)){if(e.start>=s)break;i.push({node:e.node,from:Math.max(0,n-e.start),to:Math.min(e.end-e.start,s-e.start)})}for(let a=i.length-1;a>=0;a--){const{node:t,from:n,to:s}=i[a];if(!t.data.slice(n,s).trim())continue;const l=wi(t,n,s,e.id);l&&(o(l),r.push({origin:t,mark:l,suffix:l.nextSibling instanceof Text?l.nextSibling:null}))}}n=!1};d();const f=e=>{let t=!1;for(const n of e)if("characterData"===n.type)for(const e of r)n.target===e.origin&&e.mark.isConnected&&(e.mark.remove(),e.suffix?.remove(),t=!0);return t};let h=null;const m=new MutationObserver(t=>{if(n)return;const r=f(t);r&&(m.takeRecords(),s=0),0!==i.current.length&&(null!==h&&cancelAnimationFrame(h),h=requestAnimationFrame(()=>{h=null;const t=new Set(i.current.filter(e=>null!==e.located).map(e=>e.id));if(0===t.size)return;const n=new Set;e.querySelectorAll(`mark[${di}]`).forEach(e=>{const t=e.getAttribute(di);null!==t&&n.add(t)});let o=!1;for(const e of t)if(!n.has(e)){o=!0;break}(o||r)&&s<3&&(s++,d(),m.takeRecords())}))});return m.observe(e,{childList:!0,characterData:!0,subtree:!0}),()=>{f(m.takeRecords()),m.disconnect(),null!==h&&cancelAnimationFrame(h),vi(e)}},[t,n]),null});ki.displayName="ProseReviewHighlighter";const Si=e.memo(function({containerRef:t,range:n}){return e.useLayoutEffect(()=>{const e=t.current;if(!e||!n)return;const{startOffset:s,endOffset:r}=n;if(r<=s)return;let o=!1,i=0;let a=[];const l=()=>{for(const e of a){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e),t.normalize()}}a=[]},c=()=>{o=!0,l();const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,yi);let i=0;for(let e=n.nextNode();e;){const s=e.data.length;t.push({node:e,start:i,end:i+s}),i+=s,e=n.nextNode()}const c=[];for(const e of t)if(!(e.end<=s)){if(e.start>=r)break;c.push({node:e.node,from:Math.max(0,s-e.start),to:Math.min(e.end-e.start,r-e.start)})}for(let e=c.length-1;e>=0;e--){const{node:t,from:n,to:s}=c[e];if(t.data.slice(n,s).trim())try{const e=document.createRange();e.setStart(t,n),e.setEnd(t,s);const r=document.createElement("mark");r.className=`${hi} ${gi}`,e.surroundContents(r),a.push(r)}catch{}}o=!1};c();const u=new MutationObserver(()=>{o||a.length>0&&a.every(e=>e.isConnected)||++i>3||c()});return u.observe(e,{childList:!0,subtree:!0}),()=>{u.disconnect(),l()}},[t,n]),null});Si.displayName="PendingHighlight";const Ci=32;function Ni(e){let t="";const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,yi);for(let s=n.nextNode();s;)t+=s.data,s=n.nextNode();return t}function Ei(e,t,n){const s=t.nodeType===Node.ELEMENT_NODE,r=s?t.childNodes[n]??t:t,o=r===t&&t.nodeType===Node.TEXT_NODE,i=s&&r===t,a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,yi);let l=0;for(let c=a.nextNode();c;){if(o&&c===t)return l+n;if(!o){const e=r.compareDocumentPosition(c);if(!(e&Node.DOCUMENT_POSITION_PRECEDING||i&&e&Node.DOCUMENT_POSITION_CONTAINED_BY))return l}l+=c.data.length,c=a.nextNode()}return l}const ji=`[${P}],[data-ck-s]`,Mi=/^(A|ABBR|B|BR|CODE|DEL|EM|I|KBD|MARK|S|SMALL|SPAN|STRONG|SUB|SUP|U)$/;function Li(e){const t=e.getAttribute("data-ck-s"),n=e.getAttribute("data-ck-e");return null!==t&&null!==n?{start:Number(t),end:Number(n)}:q(e.getAttribute(P))}function Ti(e){const t=(e instanceof Element?e:e?.parentElement)?.closest(ji);return t?Li(t):null}const Oi=/[\p{L}\p{N}]/u;function Ai(e,t){const n=[];for(let s=e.indexOf(t);-1!==s;s=e.indexOf(t,s+1)){const r=s>0?e[s-1]:"",o=e[s+t.length]??"";Oi.test(r)||Oi.test(o)||n.push(s)}return n}function Ri(e,t,n=0){if(0===t.length)return null;const s=e.indexOf(t,Math.max(0,n)),r=-1!==s?s:e.indexOf(t);if(-1!==r)return{start:r,end:r+t.length};const o=t.match(/[\p{L}\p{N}]+/gu);if(!o||0===o.length)return null;const i=o[0],a=o[o.length-1],l=Ai(e,i);if(0===l.length)return null;if(1===o.length){let e=l[0],t=Math.abs(e-n);for(const s of l){const r=Math.abs(s-n);r<t&&(e=s,t=r)}return{start:e,end:e+i.length}}const c=a===i?l:Ai(e,a);if(0===c.length)return null;let u=null,d=1/0,f=1/0;for(const h of l)for(const e of c){if(a===i?e<h:e<=h)continue;const s=e+a.length,r=Math.abs(s-h-t.length),o=Math.abs(h-n);(r<d||r===d&&o<f)&&(u={start:h,end:s},d=r,f=o)}return u}function Ii(e,t,n){const s=t.toString(),r=Ei(e,t.startContainer,t.startOffset),o=Ei(e,t.endContainer,t.endOffset),i={startOffset:r,endOffset:o},a=Ti(t.startContainer),l=Ti(t.endContainer);let c,u,d;if(a){const e=Math.max(l?.end??a.end,a.end),t=Ri(n.slice(a.start,e),s);t?(c=a.start+t.start,u=a.start+t.end,d=n.slice(c,u)):(c=a.start,u=e,d=s)}else c=r,u=o,d=n.slice(c,u);return{anchor:{exact:d,prefix:n.slice(Math.max(0,c-Ci),c),suffix:n.slice(u,u+Ci),startOffset:c,endOffset:u,renderedExact:s},displayed:i}}function _i(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return n}function Di(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function $i(e,t,n,s,r){if(0===t.length)return null;if(e.slice(r,r+t.length)===t)return{start:r,end:r+t.length};let o=-1,i=-1,a=1/0;for(let l=e.indexOf(t);-1!==l;l=e.indexOf(t,l+1)){const c=e.slice(Math.max(0,l-Ci),l),u=e.slice(l+t.length,l+t.length+Ci),d=_i(n,c)+Di(s,u),f=Math.abs(l-r);(d>i||d===i&&f<a)&&(o=l,i=d,a=f)}return-1===o?null:{start:o,end:o+t.length}}function Fi(e,t){let n=null,s=1/0;for(const r of e){const e=Li(r);if(!e||t<e.start||t>=e.end)continue;const o=e.end-e.start;o<s&&(n=r,s=o)}return n}function Pi(e,t,n,s){const r=e.querySelectorAll(ji),o=Fi(r,t);if(!o)return null;const i=Fi(r,Math.max(t,n-1))??o,a=Ei(e,o,0),l=Ei(e,i,0)+Ni(i).length,c=Ri(Ni(e).slice(a,l),s);return c?{start:a+c.start,end:a+c.end}:{start:a,end:l}}function qi(e,t,n){const s=null!==n?.querySelector(ji)&&null!==n,r=[];for(const o of e){const e=o.target.anchor;if("text-quote"!==e.kind)continue;const i=s?e.renderedExact??e.exact:e.exact,a=s?e.exact:e.renderedExact;let l=$i(t,i,e.prefix,e.suffix,e.startOffset);!l&&a&&a!==i&&(l=$i(t,a,e.prefix,e.suffix,e.startOffset)),!l&&s&&n&&(l=Pi(n,e.startOffset,e.endOffset,e.exact));const{kind:c,...u}=e;r.push({...o,anchor:u,located:l?{startOffset:l.start,endOffset:l.end}:null})}return r}function Bi(e,t,n){return{exact:e.slice(t,n),prefix:e.slice(Math.max(0,t-Ci),t),suffix:e.slice(n,n+Ci),startOffset:t,endOffset:n}}function Ki(e,t,n){const{rangeOffset:s,rangeLength:r,text:o}=t,i=s+r,a=o.length-r;return e.map(e=>{if(void 0===e.anchor)return e;if(null===e.located)return e;const{startOffset:t,endOffset:n}=e.located;let r=t,l=n;if(s>=n);else if(i<=t)r+=a,l+=a;else{if(s<=t&&i>=n)return{...e,located:null};s>t&&i<n?l+=a:s<=t?(r=s+o.length,l+=a):l=s}if(l<=r)return{...e,located:null};const c={...e.anchor,startOffset:r,endOffset:l,renderedExact:void 0};return{...e,anchor:c,located:{startOffset:r,endOffset:l}}})}function zi(e,t){const n=oi(e,t),s=[];let r=0,o=0;for(;o<n.length;){const e=n[o];if(e.added)s.push({rangeOffset:r,rangeLength:0,text:e.value}),r+=e.value.length,o++;else if(e.removed){const t=n[o+1];t?.added?(s.push({rangeOffset:r,rangeLength:e.value.length,text:t.value}),r+=t.value.length,o+=2):(s.push({rangeOffset:r,rangeLength:e.value.length,text:""}),o++)}else r+=e.value.length,o++}return s}function Hi(e,t,n){let s=e.slice();for(const r of zi(t,n))s=Ki(s,r);return s=function(e,t){return e.map(e=>void 0===e.anchor||null===e.located?e:{...e,anchor:Bi(t,e.located.startOffset,e.located.endOffset)})}(s,n),s.map(e=>{if(null!==e.located)return e;const[t]=qi([e],n);return t??e})}const Ui={duration:.2,ease:[.4,0,.2,1]};const Wi=e.memo(function({containerRef:n,suppressed:s,onBlockClick:r}){const i=o(),[a,l]=e.useState(null);e.useEffect(()=>{const e=n.current;if(!e)return;const t=t=>{const n=t.target;if(n.closest("[data-prose-block-hover]"))return;const s=function(e){let t=e.closest(ji);for(;t&&Mi.test(t.tagName);)t=t.parentElement?.closest(ji)??null;return t}(n);if(!s)return;if(s.querySelector(`mark[${di}]`))return void l(e=>null===e?e:null);const r=s.getBoundingClientRect().top-e.getBoundingClientRect().top;l(e=>e?.el===s?e:{el:s,top:r})},s=()=>l(null);return e.addEventListener("mousemove",t),e.addEventListener("mouseleave",s),()=>{e.removeEventListener("mousemove",t),e.removeEventListener("mouseleave",s)}},[n]);const c=s?null:a,u=e.useCallback(()=>{c&&(r(c.el),l(null))},[c,r]);return t.jsx(Je,{mode:"wait",children:null!==c&&t.jsx(Ge.button,{type:"button","data-prose-block-hover":"",onClick:u,initial:{opacity:0},animate:{opacity:1,pointerEvents:"auto"},exit:{opacity:0,pointerEvents:"none"},transition:Ui,"aria-label":i.formatMessage({defaultMessage:"Add comment to this block",id:"4NklbBACH2"}),className:"absolute right-4 z-10 flex h-8 w-8 items-center justify-center rounded-lg text-text-400 transition-colors hover:bg-bg-200 hover:text-text-100",style:{top:`calc(${c.top}px + 0.5lh - 1rem)`},children:t.jsx($,{size:20})},c.el.getAttribute("data-sourcepos")??c.el.getAttribute("data-ck-s")??c.top)})});Wi.displayName="ProseReviewBlockHover";const Yi=e.memo(function({containerRef:n,comments:s,activeId:r,onCommentClick:i}){const a=o(),[l,c]=e.useState([]);e.useLayoutEffect(()=>{const e=n.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect().top,n=[];for(const r of s){if(!r.located)continue;const s=e.querySelector(`mark[${di}="${r.id}"]`);if(!s)continue;const o=s.getBoundingClientRect().top-t;n.push({comment:r,top:o})}n.sort((e,t)=>e.top-t.top);for(let e=1;e<n.length;e++){const t=n[e-1].top;n[e].top<t+36&&(n[e].top=t+36)}c(e=>e.length===n.length&&e.every((e,t)=>e.comment.id===n[t].comment.id&&e.comment.updatedAt===n[t].comment.updatedAt&&e.top===n[t].top)?e:n)};t();const r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[n,s]);const u=e.useCallback(e=>{const t=n.current;if(!t)return;const r=t.querySelector(`mark[${di}="${e.id}"]`);if(!r)return;const o=document.createRange();o.selectNodeContents(r);const a=s.find(t=>t.id===e.id)??e;i(a,o)},[n,s,i]);return 0===l.length?null:t.jsx(t.Fragment,{children:l.map(({comment:e,top:n})=>t.jsx("button",{type:"button","data-prose-comment-id":e.id,onClick:()=>u(e),"aria-label":a.formatMessage({defaultMessage:"Review comment: {snippet}",id:"5/4va7Rhw3"},{snippet:e.text.slice(0,60)}),className:v("absolute right-4 z-10 flex h-8 min-w-8 items-center","justify-center gap-1 rounded-lg px-1.5 font-base","transition-[color,background-color]",e.id===r?"bg-bg-200 text-text-100":"text-text-400 hover:bg-bg-200 hover:text-text-100"),style:{top:`calc(${n}px + 0.5lh - 1rem)`},children:t.jsx(wt,{size:20})},e.id))})});Yi.displayName="ProseReviewGutter";const Xi={type:"spring",stiffness:320,damping:28};let Vi=null;function Ji(e){Vi?.();const t=e+250,n=e=>{s(),e.timeStamp<=t&&(e.stopPropagation(),e.preventDefault())};function s(){window.removeEventListener("click",n,!0),Vi===s&&(Vi=null)}Vi=s,window.addEventListener("click",n,!0),window.setTimeout(s,300)}const Gi="input,textarea,a,[data-no-drag],button:not([data-drag-handle])";const Qi=e.memo(function({getRange:n,getRect:r,anchorRef:o,placement:i="below",dragWithinSelection:a=!1,"aria-label":l,children:c}){const u=e.useRef(null),d=e.useRef({dx:0,dy:0}),f=e.useRef(null),h=e.useRef(null);e.useLayoutEffect(()=>{const e=u.current;if(!n&&!r||!e)return void(f.current&&(f.current=null,e?.removeAttribute("data-dragging"),document.body.style.cursor=""));f.current||(d.current={dx:0,dy:0},h.current=null,e.removeAttribute("data-dragging"));let t=null,s=[];const l=()=>{s.forEach(e=>e.stop()),s=[]};let c=null;const m=(e,t)=>{if(!c)return null;const{x:n,y:s,sel:r,w:o,h:i}=c,a=o/2,l=r.left+r.width/2,u=[r.left-a-12,l,r.right+a+12],d=[r.top-12-i,r.top+r.height/2-i/2,r.bottom+12];return{dx:u[t]-n,dy:d[e]-s}},p=()=>{let t,o,a;const l=r?.();if(l)t=l,o=l,a=l;else{const e=n?.();if(!e||e.collapsed)return;const s=e.getClientRects();o=s.length>0?s[s.length-1]:e.getBoundingClientRect(),t=s.length>0?s[0]:o,a=e.getBoundingClientRect()}if(0===o.width&&0===o.height)return;const u=e.getBoundingClientRect(),p=window.innerWidth,g=window.innerHeight,x="above"===i?a:o;let y=x.left+x.width/2;const b="above"===i?12:6;let v;"above"===i?(v=t.top-b-u.height,v<8&&o.bottom+b+u.height<=g-8&&(v=o.bottom+b)):(v=o.bottom+b,v+u.height>g-8&&t.top-b-u.height>=8&&(v=t.top-b-u.height)),c={x:y,y:v,sel:a,w:u.width,h:u.height};const w=h.current;w&&!f.current&&0===s.length&&(d.current=m(w.row,w.col)??d.current),y+=d.current.dx,v+=d.current.dy,y=Math.min(Math.max(y,u.width/2+8),p-u.width/2-8),v=Math.min(Math.max(v,8),g-u.height-8),e.style.transform=`translate(${y}px, ${v}px) translateX(-50%)`,e.style.visibility="visible"},g=()=>{null===t&&(t=requestAnimationFrame(()=>{t=null,p()}))};p(),document.addEventListener("scroll",g,{capture:!0,passive:!0}),window.addEventListener("resize",g);const x=o.current;x?.addEventListener("scroll",g,{passive:!0});const y=new ResizeObserver(g);y.observe(e),x&&y.observe(x);const b=t=>{if(f.current||0!==t.button||!t.isPrimary)return;if(!(t.target instanceof Element)||t.target.closest(Gi))return;l();const n=h.current;h.current=null,f.current={id:t.pointerId,x:t.clientX,y:t.clientY,from:d.current,fromCell:n,downTarget:t.target instanceof Element?t.target:null,lastX:t.clientX,lastY:t.clientY,lastT:t.timeStamp,vx:0,vy:0};try{e.setPointerCapture(t.pointerId)}catch{}},v=t=>{const n=f.current;if(!n||t.pointerId!==n.id)return;const r=t.timeStamp-n.lastT>80,o=r?0:n.vx,i=r?0:n.vy,a="pointercancel"===t.type,l=!a&&(e.hasAttribute("data-dragging")||Math.abs(t.clientX-n.x)>4||Math.abs(t.clientY-n.y)>4),{from:c,fromCell:u,downTarget:x}=n;if(f.current=null,e.removeAttribute("data-dragging"),document.body.style.cursor="",e.hasPointerCapture(t.pointerId)&&e.releasePointerCapture(t.pointerId),!l){d.current=c,h.current=u,p();const e=a?null:x?.closest("[data-drag-handle]");return void(e&&(Vi?.(),e.click(),Ji(t.timeStamp)))}Ji(t.timeStamp),p();const y=(e=>{let t=null,n=1/0;for(let s=0;s<3;s++)for(let r=0;r<3;r++){if(1===s&&1===r)continue;const o=m(s,r);if(!o)return null;const i=(o.dx-e.dx)*(o.dx-e.dx)+(o.dy-e.dy)*(o.dy-e.dy);i<n&&(n=i,t={...o,row:s,col:r})}return t})({dx:d.current.dx+.12*o,dy:d.current.dy+.12*i});if(!y)return;h.current={row:y.row,col:y.col};const b=e=>Math.max(-4e3,Math.min(4e3,e));if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)d.current={dx:y.dx,dy:y.dy},p();else{let e=0;const t=()=>{2===++e&&(s=[])};s=[Qe(d.current.dx,y.dx,{...Xi,velocity:b(o),onUpdate:e=>{d.current.dx=e,g()},onComplete:t}),Qe(d.current.dy,y.dy,{...Xi,velocity:b(i),onUpdate:e=>{d.current.dy=e,g()},onComplete:t})]}},w=t=>{const n=f.current;if(!n||t.pointerId!==n.id)return;if(0===t.buttons)return void v(t);d.current={dx:n.from.dx+t.clientX-n.x,dy:n.from.dy+t.clientY-n.y},!e.hasAttribute("data-dragging")&&(Math.abs(t.clientX-n.x)>4||Math.abs(t.clientY-n.y)>4)&&e.setAttribute("data-dragging",""),e.hasAttribute("data-dragging")&&"grabbing"!==document.body.style.cursor&&(document.body.style.cursor="grabbing");const s=t.timeStamp-n.lastT;s>=1&&(n.vx=.5*n.vx+(t.clientX-n.lastX)/s*500,n.vy=.5*n.vy+(t.clientY-n.lastY)/s*500,n.lastX=t.clientX,n.lastY=t.clientY,n.lastT=t.timeStamp),g()};return a&&(e.addEventListener("pointerdown",b),window.addEventListener("pointermove",w),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v)),()=>{document.removeEventListener("scroll",g,{capture:!0}),window.removeEventListener("resize",g),x?.removeEventListener("scroll",g),y.disconnect(),null!==t&&cancelAnimationFrame(t),l(),a&&(e.removeEventListener("pointerdown",b),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),f.current&&(document.body.style.cursor=""))}},[n,r,o,i,a]);const m=qe(),p=Be(40);return!n&&!r||"undefined"==typeof document?null:s.createPortal(t.jsx("div",{ref:u,role:"dialog","aria-label":l,onMouseDown:e=>e.preventDefault(),className:"z-modal",style:{...m?{zIndex:p}:void 0,position:"fixed",top:0,left:0,willChange:"transform",visibility:"hidden"},children:c}),document.body)});function Zi(){}Qi.displayName="SelectionTooltip";const ea=[],ta="h-7 w-44 min-w-0 truncate px-1.5 text-footnote/7 text-secondary";function na(e){const t=e?.getContentRoot()?.getRootNode();return t instanceof ShadowRoot?t.host:null}function sa(e,t){const n=e.getContentRoot();if(!n)return null;let s=null;for(const r of n.querySelectorAll("a[data-ck-s][data-ck-e]")){const e=Number(r.getAttribute("data-ck-s")),n=Number(r.getAttribute("data-ck-e"));Number.isFinite(e)&&Number.isFinite(n)&&e<=t&&t<=n&&(null===s||n-e<s.end-s.start)&&(s={start:e,end:n})}return s}function ra(e,t,n){const s=sa(e,t);if(!s)return null;const r=(n??e.getSource()??"").slice(s.start,s.end);return r?{start:s.start,end:s.end,text:r}:null}const oa=Array.from({length:6},(e,n)=>t.jsx("i",{className:"size-[2px] rounded-full bg-current"},n));function ia({comment:e,quoted:n}){const s=o(),r=e.author?.fullName??s.formatMessage({defaultMessage:"Reviewer",id:"Q058X+CmLx"});return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs",children:[t.jsx(Jo,{name:r}),t.jsx("span",{className:"truncate font-semibold text-text-100",children:r}),n?t.jsx("span",{className:"truncate text-text-500 italic",children:n}):null]}),t.jsx("div",{className:"whitespace-pre-wrap pl-7 text-xs leading-[1.4] text-text-100",children:e.text})]})}const aa=e.memo(function({actions:e,active:n,onAction:s,pageRef:r,linkPrompt:i,linkCardHref:a,linkCardIsCallout:l,linkEditing:c,linkDraft:u,linkInputRef:d,onLinkPromptOpen:f,onLinkDraftChange:h,onLinkSubmit:m,onLinkCancel:p,onLinkEdit:g,onLinkHrefClick:x,onLinkRemove:y}){const b=o();return t.jsx("div",{ref:r,role:"toolbar",tabIndex:n?0:void 0,"aria-label":b.formatMessage({defaultMessage:"Text formatting",id:"08d23jEDrM"}),inert:!n||void 0,className:"prose-review-bar-focus-inset flex shrink-0 items-center gap-0.5 rounded",children:i?null!==a?t.jsxs("span",{"data-no-drag":!0,className:"contents",children:[t.jsx("button",{type:"button","aria-label":l?b.formatMessage({defaultMessage:"Close",id:"rbrahOGMC3"}):b.formatMessage({defaultMessage:"Back to formatting options",id:"6lWEiX3etI"}),onClick:p,className:v("flex size-7 shrink-0 items-center justify-center rounded","text-secondary transition-colors hover:bg-alpha-2","prose-review-bar-focus-inset outline-none"),children:t.jsx(He,{name:l?"X":"ArrowLeft",size:"sm"})}),/^(https?|mailto):/i.test(a)?t.jsx(ze,{content:b.formatMessage({defaultMessage:"Open link",id:"YtFTtANjPw"}),sideOffset:8,children:t.jsx(V,{href:a,target:"_blank",rel:"noopener noreferrer",title:a,onClick:x,onAuxClick:x,className:v(ta,"inline-block text-start hover:text-primary","prose-review-bar-focus-inset"),children:a})}):t.jsx("span",{className:ta,title:a,children:a}),t.jsx(ze,{content:b.formatMessage({defaultMessage:"Edit link",id:"sq+2TtFwI7"}),sideOffset:8,children:t.jsx("button",{type:"button","aria-label":b.formatMessage({defaultMessage:"Edit link",id:"sq+2TtFwI7"}),onClick:g,className:v("flex size-7 shrink-0 items-center justify-center rounded","text-secondary transition-colors hover:bg-alpha-2","prose-review-bar-focus-inset outline-none"),children:t.jsx(He,{name:"Edit",size:"sm"})})}),t.jsx(ze,{content:b.formatMessage({defaultMessage:"Remove link",id:"cr1jN833YB"}),sideOffset:8,children:t.jsx("button",{type:"button","aria-label":b.formatMessage({defaultMessage:"Remove link",id:"cr1jN833YB"}),onClick:y,className:v("flex size-7 shrink-0 items-center justify-center rounded","text-secondary transition-colors hover:bg-alpha-2","prose-review-bar-focus-inset outline-none"),children:t.jsx(Ie,{size:16})})})]}):t.jsxs("span",{"data-no-drag":!0,className:"contents",children:[t.jsx("button",{type:"button","aria-label":c?b.formatMessage({defaultMessage:"Back to link details",id:"lf6CZQLm9d"}):b.formatMessage({defaultMessage:"Back to formatting options",id:"6lWEiX3etI"}),onClick:p,className:v("flex size-7 shrink-0 items-center justify-center rounded","text-secondary transition-colors hover:bg-alpha-2","prose-review-bar-focus-inset outline-none"),children:t.jsx(He,{name:"ArrowLeft",size:"sm"})}),t.jsx("input",{ref:d,type:"url",autoFocus:!0,value:u,onChange:e=>h(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||("Enter"===e.key&&u.trim()?(e.preventDefault(),m()):"Escape"===e.key&&(e.stopPropagation(),p()))},placeholder:b.formatMessage({defaultMessage:"Type or paste a link",id:"CpE9ei2NF9"}),"aria-label":b.formatMessage({defaultMessage:"Link URL",id:"1e9zwhbnvk"}),className:v("h-7 w-52 min-w-0 bg-transparent px-1.5 cursor-text","text-footnote text-primary placeholder:text-muted","shadow-none outline-none hide-focus-ring")}),t.jsx("button",{type:"button","aria-label":c?b.formatMessage({defaultMessage:"Update link",id:"6K3b0v6tWw"}):b.formatMessage({defaultMessage:"Add link",id:"JnxkKMhrqm"}),disabled:!u.trim(),onClick:m,className:v("flex size-7 shrink-0 items-center justify-center rounded","transition-colors prose-review-bar-focus-inset outline-none","enabled:text-primary enabled:hover:bg-alpha-2","disabled:text-disabled disabled:cursor-default"),children:t.jsx(He,{name:"Check",size:"sm"})})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 h-5 w-px bg-alpha-3","aria-hidden":!0}),e.map(e=>{if(e.divider)return t.jsx("span",{className:"mx-0.5 h-5 w-px bg-alpha-3","aria-hidden":!0},e.id);const n=t.jsx("button",{type:"button","aria-label":e.label,"aria-pressed":e.toggle?e.active??!1:void 0,disabled:e.disabled,onClick:()=>{"url"!==e.prompt?s?.(e):f(e)},className:v("flex size-7 shrink-0 items-center justify-center rounded","text-secondary transition-colors","prose-review-bar-focus-inset outline-none","aria-pressed:bg-alpha-3 aria-pressed:text-primary","enabled:hover:bg-alpha-2 disabled:text-disabled disabled:pointer-events-none"),children:"string"==typeof e.icon?t.jsx(He,{name:e.icon,size:"sm"}):t.jsx(He,{customIcon:e.icon,size:"sm"})});return e.disabled?t.jsx("span",{"data-no-drag":!0,className:"contents",children:t.jsx(Ue,{reason:e.disabledReason??e.label,sideOffset:8,wrapperClassName:"prose-review-bar-focus-inset rounded",children:n})},e.id):t.jsx(ze,{content:e.label,shortcut:e.shortcut,sideOffset:8,children:n},e.id)})]})})});function la(e){return"view"===e?.kind||"edit"===e?.kind?e.comment:void 0}const ca=e.memo(function({reviewStoreKey:n,documentRef:r,source:a,className:l,children:u,analyticsCtx:d,displayMode:h="rendered",onSendToClaude:m,sendDisabled:p=!1,selectionAdapter:g,formatActions:x,onFormatAction:w}){const S=o(),C=f(),N=e.useRef(null),{comments:E,addComment:j,updateComment:M,removeComment:L,scrollTarget:T}=B(n),O=K(r),A=e.useMemo(()=>E.filter(e=>K(e.target.document)===O),[E,O]),R=e.useMemo(()=>z(A),[A]),[I,_]=e.useState(()=>({source:a,remapped:new Map}));if(I.source!==a){const e=function(e,t,n){return Hi(e.map(e=>{const t=e.target.anchor;if("text-quote"!==t.kind)return{...e,located:null};const{kind:n,...s}=t;return{...e,anchor:s,located:{startOffset:t.startOffset,endOffset:t.endOffset}}}),t,n).map(e=>void 0===e.anchor?e:{...e,target:{...e.target,anchor:{kind:"text-quote",...e.anchor}}})}(A.map(e=>I.remapped.get(e.id)??e),I.source,a);_({source:a,remapped:new Map(e.map(e=>[e.id,e]))})}const D=e.useMemo(()=>A.map(e=>{const t=I.remapped.get(e.id);return t?{...e,target:{...e.target,anchor:t.target.anchor}}:e}),[A,I.remapped]),$=e.useMemo(()=>D.filter(H),[D]),F=e.useCallback((e,t)=>{const n=U(r,e),s=j(n,t,{forceNew:!0,displayMode:"rendered",skipStage:!0});s.isNew&&C.track({event_key:"claudeai.review_comment.created",...d,comment_id:s.id,...W(n,t,{displayMode:h})})},[j,O,C,d,h]),P=e.useCallback(e=>{const t=E.find(t=>t.id===e);L(e),t&&C.track({event_key:"claudeai.review_comment.removed",...d,comment_id:t.id,...W(t.target,t.text,{source:t.source,replyToCommentUuid:t.replyToCommentUuid})})},[L,E,C,d]),[q,V]=e.useState("");e.useLayoutEffect(()=>{const e=g?.getContentRoot()??N.current;if(!e)return;const t=()=>{const t=Ni(e);V(e=>e===t?e:t)};t();let n=0;const s=new MutationObserver(()=>{n||(n=requestAnimationFrame(()=>{n=0,t()}))});return s.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{s.disconnect(),n&&cancelAnimationFrame(n)}},[u,g]);const J=e.useMemo(()=>qi($,q,g?.getContentRoot()??N.current),[$,q,g]),G=e.useMemo(()=>J.filter(e=>null===e.located),[J]),{selection:Q,clearSelection:Z}=function(t,n,s){const[r,o]=e.useState(null),i=e.useRef(n);i.current=n;const a=e.useRef(s);a.current=s;const l=e.useCallback(()=>{const e=a.current;if(e){const t=e.getSourceSelection();if(!t||t.end<=t.start)return void o(null);const n=e.getSource()??i.current,s=n.slice(t.start,t.end);if(0===s.trim().length)return void o(null);const r={exact:s,prefix:n.slice(Math.max(0,t.start-Ci),t.start),suffix:n.slice(t.end,t.end+Ci),startOffset:t.start,endOffset:t.end,renderedExact:s};return void o({range:null,rect:e.getSelectionRect(),anchor:r,displayed:{startOffset:t.start,endOffset:t.end}})}const n=t.current,s="undefined"!=typeof window?window.getSelection():null;if(!n||!s||s.isCollapsed||0===s.rangeCount)return void o(null);const r=s.getRangeAt(0);if(!n.contains(r.startContainer)||!n.contains(r.endContainer))return void o(null);const l=e=>null!==((e instanceof Element?e:e.parentElement)?.closest(`[${fi}]`)??null);if(l(r.startContainer)&&l(r.endContainer))return void o(null);if(0===r.toString().trim().length)return void o(null);const{anchor:c,displayed:u}=Ii(n,r,i.current);o({range:r.cloneRange(),rect:null,anchor:c,displayed:u})},[t]);return e.useEffect(()=>{const e=t.current;if(!e)return;const n=()=>{if(a.current)return;const t="undefined"!=typeof window?window.getSelection():null;if(!t||t.isCollapsed||0===t.rangeCount)return void o(null);const n=t.getRangeAt(0);e.contains(n.startContainer)&&e.contains(n.endContainer)||o(null)};return s?s.onSelectionChange(l):(e.addEventListener("mouseup",l),e.addEventListener("keyup",l),document.addEventListener("selectionchange",n),()=>{e.removeEventListener("mouseup",l),e.removeEventListener("keyup",l),document.removeEventListener("selectionchange",n)})},[t,l,s]),{selection:r,clearSelection:e.useCallback(()=>{a.current||window.getSelection()?.removeAllRanges(),o(null)},[])}}(N,a,g),[ee,te]=e.useState(null),[ne,se]=e.useState(a);if(ne!==a&&(se(a),"create"===ee?.kind||"select"===ee?.kind&&a.slice(ee.anchor.startOffset,ee.anchor.endOffset)!==ee.anchor.exact)){const e=function(e,t,n){let s=e.startOffset,r=e.endOffset,o=e.startOffset;for(const{rangeOffset:l,rangeLength:c,text:u}of zi(t,n)){const e=l+c,t=u.length-c;if(l>=r);else if(e<=s)s+=t,r+=t;else{if(l<=s&&e>=r){o=s,s=null;break}l>s&&e<r?r+=t:l<=s?(s=l+u.length,r+=t):r=l}if(r<=s){o=s,s=null;break}}if(null!==s)return Bi(n,s,r);if(0===e.exact.length)return null;let i=-1,a=1/0;for(let l=n.indexOf(e.exact);-1!==l;l=n.indexOf(e.exact,l+1)){const e=Math.abs(l-o);e<a&&(i=l,a=e)}return i>=0?Bi(n,i,i+e.exact.length):null}(ee.anchor,ne,a);null===e||e.startOffset===ee.anchor.startOffset&&e.endOffset===ee.anchor.endOffset&&e.exact===ee.anchor.exact||te({...ee,anchor:e})}const[re,oe]=Ct({key:"prose-review-bar-mode",defaultValue:"compose",getInitialValueInEffect:!1}),[ie,ae]=e.useState(null),le=e.useRef(null),ce=e.useRef(null),[ue,de]=e.useState(null),[fe,he]=e.useState(null),[me,pe]=e.useState(!1),ge=e.useRef(!1),[xe,ye]=e.useState(null),[be,ve]=e.useState(null),we=e.useRef(null),ke=e.useRef(null),Se=e.useRef(!1),[Ce,Ne]=e.useState(0),[Ee,je]=e.useState(""),Me=e.useRef(""),Le=e.useRef(null),Te=e.useRef(null),Oe=e.useRef(""),[Ae,Re]=e.useState(""),Ie=e.useRef(""),[_e,De]=e.useState(""),[$e,Fe]=e.useState(!1),[Pe,qe]=e.useState(!1),Be="format"===(ie??re)&&!!x,Ue=!!x&&!Be,We=e.useRef(null),Ye=e.useRef(null),[Xe,Ve]=e.useState(null),[Je,Ge]=e.useState(!1),Qe=null!==Xe;e.useEffect(()=>{if(!Qe)return void Ge(!1);let e=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>Ge(!0))});return()=>cancelAnimationFrame(e)},[Qe]);const Ze="select"===ee?.kind||"create"===ee?.kind?ee.anchor:null;e.useEffect(()=>{null!==we.current&&null!==Ze||(de(null),he(null),ye(null),je(""),Le.current=null)},[Ze?.exact]);const et=e.useCallback(()=>{te(e=>"select"===e?.kind?{...e,kind:"create"}:e)},[]),tt=e.useCallback(()=>{g?.focusEditor?.()},[g]),nt=Y(()=>{null!==ue&&(de(null),he(null),ye(null),je(""),Le.current=null,""===Oe.current.trim()&&te(e=>"create"!==e?.kind?e:Q?{kind:"select",range:Q.range,anchor:Q.anchor,displayed:Q.displayed}:e))}),st=e.useCallback(()=>{if(x){if(nt(),Be)return s.flushSync(()=>{ae(null),oe("compose")}),void ce.current?.focus({preventScroll:!0});ce.current?.blur(),ae(null),oe("format")}else ce.current?.focus({preventScroll:!0})},[x,nt,Be,oe]),rt=Y(e=>{if(e.active)return Le.current=null,et(),de(e),he(e.activeHref??""),pe(!1),ge.current=!0,void ye(null);const t=g?.getSourceSelection()??null;g&&!t||(Le.current=t?{...t,text:a.slice(t.start,t.end)}:null,et(),de(e),he(null),pe(!1),ye(null),je(""))}),ot=Y(e=>{ye(null),me?(e?.reopen&&(we.current=null),yt()):nt(),tt()}),it=Y(()=>{if(null!==xe)return ye(null),je(""),Me.current="",he(xe),void(ge.current=!0);ot()}),at=Y(()=>{ue&&w?.(ue,Ee.trim(),Le.current??void 0),ot({reopen:!0})}),lt=Y(()=>{if(null===fe||!g)return;const e=g.getSourceSelection(),t=[g.getCaretSourceOffset?.()??null,e?Math.max(e.start,e.end-1):null,e?.start??null],n=g.getSource()??"";let s=null;for(const r of t){if(null===r)continue;const e=ra(g,r,n);if(e?.text.includes(fe)&&Mo(e.text)&&!Lo(e.text)){s=e;break}}s&&(Le.current=s,ye(fe),je(fe),Me.current=fe,he(null))}),ct=Y(e=>{const t=fe;if(null!==t&&!y(t)){if("auxclick"===e.type){if(1!==e.button)return;return e.preventDefault(),void ve(t)}(e.metaKey||e.ctrlKey||e.shiftKey)&&!b(t)||(e.preventDefault(),ve(t))}}),ut=e.useCallback(()=>ve(null),[]),dt=e.useCallback(()=>{be&&/^(https?|mailto):/i.test(be)&&window.open(be,"_blank","noopener,noreferrer"),ve(null)},[be]),ft=Y(()=>{ue&&w?.(ue),ot()}),ht=x?.find(e=>"url"===e.prompt)?.activeHref,mt=Y(e=>{const t=g;if(!t?.getCaretSourceOffset)return!1;const n=x?.find(e=>"url"===e.prompt),s=n?.activeHref;if(!n||n.disabled||void 0===s)return!1;const r=t.getCaretSourceOffset();if(null===r)return!1;const o=t.getSource()??"",i=ra(t,r,o);return!!i&&(we.current=s,Le.current=null,ce.current?.blur(),ae("format"),te({kind:"create",range:null,anchor:{exact:i.text,prefix:o.slice(Math.max(0,i.start-Ci),i.start),suffix:o.slice(i.end,i.end+Ci),startOffset:i.start,endOffset:i.end,renderedExact:i.text},displayed:{startOffset:i.start,endOffset:i.end}}),de(n),he(s),je(""),pe(!0),ge.current=e,ye(null),!0)}),pt=e.useCallback(()=>{Ye.current?.querySelector("button")?.focus({preventScroll:!0})},[]),gt=Y(()=>{const e=na(g),t=document.activeElement;if(!(!!e&&(t===e||e.contains(t))||t instanceof HTMLElement&&!0===le.current?.contains(t)))return!1;if(ue)return null!==fe&&pt(),!0;if(null===ee)return ke.current=null,mt(!0);if("select"!==ee.kind&&"create"!==ee.kind)return!1;const n=x?.find(e=>"url"===e.prompt);return!(!n||n.disabled)&&(Be||(ce.current?.blur(),ae(null),oe("format")),rt(n),!0)}),xt="select"===ee?.kind||"create"===ee?.kind||!!g;e.useEffect(()=>{if(!xt)return;const e=e=>{"u"!==e.key.toLowerCase()||!e.shiftKey||!e.metaKey&&!e.ctrlKey||e.altKey||e.isComposing||gt()&&(e.preventDefault(),e.stopPropagation())};return document.addEventListener("keydown",e,{capture:!0}),()=>document.removeEventListener("keydown",e,{capture:!0})},[xt,gt]),e.useEffect(()=>{te(e=>e&&"select"!==e.kind?e:Q?{kind:"select",range:Q.range,anchor:Q.anchor,displayed:Q.displayed}:null)},[Q]),e.useEffect(()=>{Q&&null!==we.current&&null===xe&&(we.current=null,de(null),he(null),pe(!1),je(""),Le.current=null,te({kind:"select",range:Q.range,anchor:Q.anchor,displayed:Q.displayed}))},[Q,xe]);const yt=e.useCallback(()=>{te(null),Re(""),De(""),Fe(!1),Oe.current="",Ie.current="",de(null),he(null),ye(null),pe(!1),ge.current=!1,je(""),Me.current="",Le.current=null,Z()},[Z]);e.useEffect(()=>{if(null===fe)return;const e=na(g),t=!!e&&(document.activeElement===e||e.contains(document.activeElement));ht===fe||void 0===ht&&!t||(me?(we.current=null,yt()):nt())},[fe,me,ht,g,nt,yt]),e.useEffect(()=>{null===ue&&(ae(null),null!==we.current&&(ke.current=we.current,we.current=null,ge.current=!1,pe(!1)))},[ue]),e.useEffect(()=>{null!==ke.current&&ht!==ke.current&&(ke.current=null)},[ht]),e.useEffect(()=>{if(!g)return;const e=g.onSelectionChange(()=>{if(Se.current&&null===ke.current)return;const e=g.getCaretSourceOffset?.()??null;(null!==e?sa(g,e):null)?Se.current||null!==ke.current||Ne(e=>e+1):ke.current=null}),t=e=>{if(null===ke.current)return;const t=na(g);t&&e.composedPath().includes(t)&&(ke.current=null)};return document.addEventListener("pointerdown",t,{capture:!0}),()=>{e(),document.removeEventListener("pointerdown",t,{capture:!0})}},[g]);const bt=null===ee&&null===ue&&void 0!==ht;e.useEffect(()=>{bt&&ke.current!==ht&&mt(!1)},[bt,ht,Ce,mt]);const vt=e.useRef(null);e.useEffect(()=>{if(g)return;const e=vt.current;vt.current=q,null!==e&&e!==q&&te(e=>"create"!==e?.kind&&"select"!==e?.kind?e:(""!==Oe.current&&(Re(""),Oe.current=""),null))},[q,g]),e.useEffect(()=>{Oe.current=Ae},[Ae]),e.useEffect(()=>{Ie.current=_e},[_e]),e.useEffect(()=>{Me.current=Ee},[Ee]),e.useEffect(()=>{Se.current=null!==ee||null!==ue},[ee,ue]),e.useLayoutEffect(()=>{const e=ce.current;if(!e)return void qe(!1);const t=e.style.height;e.style.height="auto";const n=e.scrollHeight,s=e.clientHeight,r=`${n}px`;t&&t!==r&&(e.style.height=t,e.offsetHeight),e.style.height=r,qe(n>2*s)},[Ae,ee]),e.useLayoutEffect(()=>{const e=We.current;if(!e)return void Ve(null);const t=Ye.current,n=()=>{const n={cw:e.offsetWidth,ch:e.offsetHeight,fw:t?.offsetWidth??0,fh:t?.offsetHeight??0,fx:t?t.offsetLeft-e.offsetLeft:0};Ve(e=>e&&e.cw===n.cw&&e.ch===n.ch&&e.fw===n.fw&&e.fh===n.fh&&e.fx===n.fx?e:n)};n();const s=new ResizeObserver(n);return s.observe(e),t&&s.observe(t),()=>s.disconnect()},[ee,x]),e.useEffect(()=>{if(!ee||"select"===ee.kind)return;const e=e=>{if(null!==be)return;if(e.detail>1)return;if(0!==e.button)return;const t=e.target;if(le.current?.contains(t))return;if(t instanceof Element&&t.closest("[data-prose-comment-id], [data-radix-popper-content-wrapper]"))return;if(null!==we.current&&null!==fe){const t=na(g);if(t&&e.composedPath().includes(t))return}const n=document.activeElement;if(n instanceof HTMLElement&&le.current?.contains(n)){n.blur();if(""!==("view"===ee.kind?Ie.current:Oe.current.trim()||Me.current).trim())return}"view"===ee.kind&&""!==Ie.current.trim()||yt()},t=e=>{if("Escape"!==e.key)return;if(null!==be)return;if(e.isComposing)return;if(document.querySelector('[data-radix-popper-content-wrapper] :is([role="listbox"], [role="menu"])'))return;const t=document.activeElement,n=t instanceof HTMLElement&&!0===le.current?.contains(t);yt(),n&&tt()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[ee,yt,g,fe,be,tt]),e.useEffect(()=>{if(g||"select"!==ee?.kind&&"create"!==ee?.kind)return;const e=e=>{if(e.metaKey||e.ctrlKey||e.altKey||" "===e.key||1!==e.key.length)return;const t=ce.current;if(!t||document.activeElement===t)return;const n=e.target;if(!(n instanceof HTMLElement)||n.isContentEditable||n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return;const s=N.current;if(s&&(s.contains(n)||n.contains(s))){for(const e of document.querySelectorAll(X))if(!e.contains(le.current))return;e.preventDefault(),t.focus({preventScroll:!0}),Re(t=>t+e.key)}};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[ee,g]);const wt=e.useCallback(()=>{Fe(!0),et()},[et]),kt=e.useCallback(()=>{Fe(!1)},[]);"create"!==ee?.kind&&"edit"!==ee?.kind&&""!==Ae&&Re(""),e.useEffect(()=>{"create"===ee?.kind&&ce.current?.focus({preventScroll:!0})},[ee?.kind]),e.useEffect(()=>{null!==fe&&Qe&&ge.current&&(ge.current=!1,pt())},[fe,Qe,pt]);const St=e.useCallback(e=>{const t=N.current;if(!t)return;const n=document.createRange();n.selectNodeContents(e);const{anchor:s,displayed:r}=Ii(t,n,a);Re(""),te({kind:"create",range:n,anchor:s,displayed:r})},[a]),Nt=e.useCallback((e,t)=>{Re(""),De(""),Ie.current="",te({kind:"view",range:t,comment:e}),N.current?.querySelectorAll(`mark.${mi}`).forEach(e=>e.classList.remove(mi)),N.current?.querySelectorAll(`mark[data-prose-comment-id="${e.id}"]`).forEach(e=>e.classList.add(mi))},[]),Et=e.useRef(null);e.useEffect(()=>{if(!T||T.nonce===Et.current)return;const e=J.find(e=>e.id===T.commentId);if(!e)return;if(Et.current=T.nonce,g)return void Nt(e,null);const t=N.current?.querySelector(`mark[data-prose-comment-id="${e.id}"]`);if(!t)return;const n=document.createRange();n.selectNodeContents(t),Nt(e,n)},[T,J,Nt,g]),e.useEffect(()=>{if(la(ee))return;const e=N.current?.querySelectorAll(`mark.${mi}`);e?.forEach(e=>e.classList.remove(mi))},[ee]);const jt=la(ee)?.id??null;e.useLayoutEffect(()=>{if(null===jt)return;if(g)return void(J.some(e=>e.id===jt&&e.located)||te(null));const e=N.current?.querySelectorAll(`mark[${di}="${jt}"]`);e&&0!==e.length?e.forEach(e=>e.classList.add(mi)):te(null)},[J,jt,g]);const Mt=e.useMemo(()=>{const e=la(ee);if(e)return J.find(t=>t.id===e.id)??e},[ee,J]),Lt=e.useCallback(()=>{const e=Ae.trim();if(e){if("create"===ee?.kind)F(ee.anchor,e);else if("edit"===ee?.kind){M(ee.comment.id,e);const t=A.find(e=>e.id===ee.comment.id)??ee.comment;C.track({event_key:"claudeai.review_comment.edited",...d,comment_id:ee.comment.id,...W(t.target,e,{displayMode:h,source:t.source,replyToCommentUuid:t.replyToCommentUuid})})}yt()}},[Ae,ee,F,M,A,C,d,h,yt]),Tt=e.useCallback(()=>{const e=la(ee),t=_e.trim();if(!e||!t)return;const n=A.find(t=>t.id===e.id)??e,s=j(n.target,t,{forceNew:!0,displayMode:"rendered",skipStage:!0,replyToCommentUuid:e.id});s.isNew&&C.track({event_key:"claudeai.review_comment.created",...d,comment_id:s.id,...W(n.target,t,{displayMode:h,replyToCommentUuid:e.id})}),De(""),Ie.current=""},[ee,_e,A,j,C,d,h]),Ot=e.useCallback(e=>{e.nativeEvent.isComposing||("Enter"!==e.key||e.shiftKey?"Escape"===e.key&&(e.preventDefault(),yt()):(e.preventDefault(),Tt()))},[Tt,yt]),At=e.useCallback(()=>{te(e=>{if("view"!==e?.kind)return e;const t=J.find(t=>t.id===e.comment.id)??e.comment;return Re(t.text),{kind:"edit",range:e.range,comment:e.comment}})},[J]),Rt=e.useCallback(()=>{te(e=>"edit"!==e?.kind?e:(Re(""),{kind:"view",range:e.range,comment:e.comment}))},[]),It=e.useCallback(()=>{const e=la(ee);e&&P(e.id),yt()},[ee,P,yt]),_t=e.useCallback(()=>{if(!m)return;const e=Mt;if(e){const t=R.get(e.id)??ea,n=A.find(t=>t.id===e.id);m([e,...t],"view",{analyticsTarget:n?.target})}else{if("create"!==ee?.kind||!Ae.trim())return;m([{id:"",text:Ae.trim(),target:U(r,ee.anchor),createdAt:Date.now(),updatedAt:Date.now(),isOwn:!0}],"compose")}yt()},[m,ee,Mt,Ae,yt,O,R,A]),Dt=e.useCallback(()=>{m?p||_t():Lt()},[m,p,_t,Lt]),$t=e.useCallback(e=>{e.nativeEvent.isComposing||("Enter"!==e.key||e.shiftKey?"Escape"===e.key&&(e.preventDefault(),yt()):(e.preventDefault(),"create"===ee?.kind?Dt():Lt()))},[ee,Dt,Lt,yt]),Ft="view"===ee?.kind||"edit"===ee?.kind,Pt=Mt?R.get(Mt.id)??ea:ea,qt=m?S.formatMessage({defaultMessage:"Edit with Claude",id:"wdKoWlVN+G"}):S.formatMessage({defaultMessage:"Add review comment on selection",id:"xh+NLhMPNJ"}),Bt=m?S.formatMessage({defaultMessage:"Tell Claude what to change",id:"K15bjS+2Xf"}):S.formatMessage({defaultMessage:"Add a comment\u2026",id:"4oif0IPXeY"}),Kt=m?S.formatMessage({defaultMessage:"Send to Claude",id:"xGC0T/NxhG"}):S.formatMessage({defaultMessage:"Add comment",id:"eiaPxp89eC"}),zt=S.formatMessage({defaultMessage:"Discard comment",id:"iG1nblXH5y"}),Ht=Ue?S.formatMessage({defaultMessage:"Show formatting options",id:"I+T401ErUi"}):qt,Ut=x?Be?m?S.formatMessage({defaultMessage:"Ask Claude to revise this",id:"PeZezJ4Pqf"}):void 0:S.formatMessage({defaultMessage:"Format",id:"zQLEfzSzLe"}):m?S.formatMessage({defaultMessage:"Edit selected text with Claude",id:"xJOMr0YECA"}):void 0,Wt=!$e&&""!==Ae.trim(),Yt=e.useMemo(()=>"create"===ee?.kind?ee.displayed:null,[ee]),Xt="create"===ee?.kind||"select"===ee?.kind?ee.anchor:null;e.useEffect(()=>{const e=g?.setHighlights;if(!e)return;const t=J.flatMap(e=>e.anchor&&e.located&&!e.localOnly?[{id:e.id,start:e.anchor.startOffset,end:e.anchor.endOffset,className:e.id===jt?"active":"comment"}]:[]);return Xt&&t.push({id:"",start:Xt.startOffset,end:Xt.endOffset,className:"pending"}),e(t),g?.onHighlightsStale?.(()=>e(t))},[g,J,jt,Xt]),e.useEffect(()=>()=>g?.setHighlights?.([]),[g]),e.useEffect(()=>{if(g?.onHighlightClick)return g.onHighlightClick(e=>{const t=J.find(t=>t.id===e);if(!t?.anchor)return;const n=g.rangeForOffsets?.(t.anchor.startOffset,t.anchor.endOffset)??null;n&&Nt(t,n)})},[g,J,Nt]);const Vt=e.useMemo(()=>{if(!ee||g)return null;const e=ee;return()=>{const t=N.current;if(t)if("create"===e.kind){const e=t.querySelectorAll(`mark.${gi}`);if(e.length>0)return xi(e)}else if("view"===e.kind||"edit"===e.kind){const n=t.querySelectorAll(`mark[${di}="${e.comment.id}"]`);if(n.length>0)return xi(n)}return e.range}},[ee,g]),Jt=e.useMemo(()=>{if(!ee||!g)return null;const e=ee,t=g;return()=>{if("select"===e.kind||"create"===e.kind)return t.getSelectionRect()??t.rangeForOffsets?.(e.anchor.startOffset,e.anchor.endOffset)?.getBoundingClientRect()??null;const n=e.comment.anchor;return n?t.rangeForOffsets?.(n.startOffset,n.endOffset)?.getBoundingClientRect()??null:null}},[ee,g]);return t.jsxs("div",{ref:N,className:v("relative",l),"data-prose-review-dockey":O,"data-prose-review-counts":`${E.length}/${A.length}/${J.length}/${G.length}`,children:[u,g?null:t.jsxs(t.Fragment,{children:[t.jsx(ki,{containerRef:N,comments:J,onCommentClick:Nt}),t.jsx(Yi,{containerRef:N,comments:J,activeId:Mt?.id??null,onCommentClick:Nt}),t.jsx(Wi,{containerRef:N,suppressed:null!==ee,onBlockClick:St})]}),!g&&G.length>0&&t.jsxs("div",{"data-prose-review-ignore":!0,className:"mx-auto mt-4 w-full max-w-3xl border-t border-border-300 px-6 pb-6 pt-4 md:px-11",children:[t.jsx("div",{className:"mb-2 text-xs font-medium text-text-400",children:t.jsx(i,{defaultMessage:"{count, plural, one {# comment thread} other {# comment threads}} on text that's no longer here",id:"XdAiuncu2t",values:{count:G.length}})}),t.jsx("ul",{className:"flex flex-col gap-2",children:G.map(e=>{const n=e.anchor?.exact,s=n?`\u2014 \u201c${n.slice(0,60)}${n.length>60?"\u2026":""}\u201d`:null,r=R.get(e.id)??ea;return t.jsxs("li",{className:"rounded-lg border border-border-200 bg-bg-100 p-3",children:[t.jsx(ia,{comment:e,quoted:s}),r.length>0&&t.jsx("div",{className:"mt-3 flex flex-col gap-3",children:r.map(e=>t.jsx("div",{children:t.jsx(ia,{comment:e})},e.id))})]},e.id)})})]}),g?null:t.jsx(Si,{containerRef:N,range:Yt}),t.jsx(Qi,{getRange:Vt,getRect:Jt,anchorRef:N,placement:Ft?"below":"above",dragWithinSelection:!Ft,"aria-label":qt,children:Ft?t.jsxs("div",{ref:le,onMouseDown:e=>e.stopPropagation(),className:v("z-20 w-[270px] flex flex-col gap-5","rounded-xl border-0.5 border-border-300 bg-bg-000","px-3 pt-3 pb-4","shadow-[0_40px_80px_hsl(var(--always-black)/15%)]"),children:[t.jsx(Qo,{variant:"popover",isEditing:"view"!==ee?.kind,hideLineRange:!0,existingComment:Mt,commentText:Ae,placeholder:S.formatMessage({defaultMessage:"Add a comment\u2026",id:"4oif0IPXeY"}),onTextChange:Re,onSubmit:Lt,onKeyDown:$t,onEditExisting:At,onCancel:"edit"===ee?.kind?Rt:yt,onDelete:Mt?It:void 0,onSendToClaude:m?_t:void 0,sendDisabled:p}),Pt.length>0&&t.jsx("div",{className:"flex flex-col gap-5",children:Pt.map(e=>t.jsx(Qo,{variant:"popover",isEditing:!1,existingComment:e,commentText:"",placeholder:"",onTextChange:Zi,onSubmit:Zi,onKeyDown:Zi,onDelete:!1!==e.isOwn?()=>P(e.id):void 0},e.id))}),Mt&&"view"===ee?.kind&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"rounded-lg border border-border-300 p-2",children:t.jsx("textarea",{"aria-label":S.formatMessage({defaultMessage:"Reply",id:"9HU8vwHwVV"}),value:_e,onChange:e=>De(e.target.value),onKeyDown:Ot,placeholder:S.formatMessage({defaultMessage:"Reply\u2026",id:"p9MPkbVUdx"}),className:v("block w-full resize-none border-none bg-transparent","font-ui text-sm leading-[1.4] text-text-100","placeholder-text-500 shadow-none outline-none hide-focus-ring"),style:{fieldSizing:"content"},rows:1})}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(c,{variant:"secondary",size:"sm",onClick:yt,children:t.jsx(i,{defaultMessage:"Cancel",id:"47FYwba+bI"})}),t.jsx(c,{variant:"primary",size:"sm",onClick:Tt,disabled:!_e.trim(),children:t.jsx(i,{defaultMessage:"Reply",id:"9HU8vwHwVV"})})]})]})]},`${ee?.kind}:${Mt?.id??""}`):t.jsx(Ke,{mode:"dark",className:"contents",children:t.jsxs("div",{ref:le,onMouseDown:e=>{e.stopPropagation(),Be?e.target!==Te.current&&e.preventDefault():(e.target!==ce.current&&(e.preventDefault(),ce.current?.focus({preventScroll:!0})),et())},onPointerDown:e=>{(!Be||0===e.button&&e.isPrimary&&e.target instanceof Element&&!e.target.closest(Gi))&&et()},className:v("z-10 flex items-start gap-0.5 rounded p-1","border bg-surface-popover text-primary shadow-popover","prose-review-bar-enter"),children:[ue?null:t.jsx(ze,{sideOffset:8,content:Ut,children:t.jsxs("button",{type:"button","data-drag-handle":!0,"aria-label":Ht,"aria-expanded":x?Be:void 0,onClick:st,className:v("prose-review-bar-icon","touch-none","grid size-7 shrink-0 place-items-center rounded","text-secondary transition-colors hover:bg-alpha-2","outline-none focus-visible:shadow-focus","*:col-start-1 *:row-start-1"),children:[t.jsx("span",{className:"[[data-dragging]_&]:invisible",children:t.jsx(He,{name:Ue?"TextAa":"ChatAdd",size:"sm"})}),t.jsx("span",{"aria-hidden":!0,className:"invisible grid grid-cols-2 gap-[2px] [[data-dragging]_&]:visible",children:oa})]})}),t.jsx("div",{className:v("overflow-hidden",Je&&"transition-[width,height] duration-base ease-out motion-reduce:transition-none"),style:Xe?{width:Be?Xe.fw:Xe.cw,height:Be?Xe.fh:Xe.ch}:void 0,children:t.jsxs("div",{className:v("flex w-max items-start gap-0.5",Je&&"transition-transform duration-base ease-out motion-reduce:transition-none"),style:{transform:`translateX(${Be&&Xe?-Xe.fx:0}px)`},children:[t.jsxs("div",{ref:We,inert:!!Be||void 0,className:"flex shrink-0 items-start gap-0.5",children:[t.jsx("textarea",{ref:ce,value:Ae,onChange:e=>Re(e.target.value),onFocus:wt,onBlur:kt,onKeyDown:$t,placeholder:Bt,"aria-label":Bt,rows:1,className:v("min-h-7 max-h-24 w-52 min-w-0 resize-none bg-transparent","overflow-y-auto u-hidden-scrollbar","pl-1 pr-1.5 py-1.5 cursor-text","text-footnote text-primary placeholder:text-muted","placeholder:truncate","shadow-none outline-none hide-focus-ring","transition-[height] duration-150 ease-out motion-reduce:transition-none")}),t.jsxs("div",{className:v("flex shrink-0 gap-0.5",Pe?"flex-col-reverse self-stretch justify-between":"self-end"),children:[t.jsx("button",{type:"button","aria-label":Kt,disabled:!Ae.trim()||!!m&&p,onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onClick:Dt,className:v("flex size-7 shrink-0 items-center justify-center rounded","prose-review-bar-focus-inset transition-colors outline-none","enabled:text-primary enabled:hover:bg-alpha-2","disabled:text-disabled disabled:pointer-events-none"),children:t.jsx(He,{name:"ArrowUp",size:"sm"})}),t.jsx("button",{type:"button","aria-label":zt,inert:!Wt||void 0,"aria-hidden":!Wt,onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onClick:yt,className:v("flex h-7 shrink-0 items-center justify-center overflow-hidden rounded","text-secondary hover:bg-alpha-2","prose-review-bar-focus-inset outline-none","transition-[width,margin-left,opacity,color,background-color] duration-base ease-out",Wt?"w-7 opacity-100":Pe?"pointer-events-none w-7 opacity-0":"pointer-events-none -ml-0.5 w-0 opacity-0"),children:t.jsx(He,{name:"X",size:"sm"})})]})]}),x&&t.jsx(aa,{actions:x,active:Be,onAction:w,pageRef:Ye,linkPrompt:ue,linkCardHref:fe,linkCardIsCallout:me,linkEditing:null!==xe,linkDraft:Ee,linkInputRef:Te,onLinkPromptOpen:rt,onLinkDraftChange:je,onLinkSubmit:at,onLinkCancel:it,onLinkEdit:lt,onLinkHrefClick:ct,onLinkRemove:ft})]})})]})})}),t.jsx(k,{isOpen:null!==be,url:be??"",onClose:ut,onConfirm:dt})]})});ca.displayName="ProseReviewOverlay";const ua=Object.freeze([]),da={note:"Note",suggestion:"Suggestion"};function fa(e){const t=/^\s*(suggestion|note)\s*:\s*/i.exec(e);return t?{kind:"suggestion"===t[1].toLowerCase()?"suggestion":"note",body:e.slice(t[0].length)}:{kind:"note",body:e}}function ha(e){return`.comment-anchor[data-id="${CSS.escape(e)}"]`}function ma({id:e,n:n,kind:s,body:r,x:o,y:i}){return t.jsxs(Ge.div,{role:"note","data-doc-annotation-popover":e,initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:{duration:.12,ease:"easeOut"},style:{x:o,y:i},className:"pointer-events-none absolute left-0 top-0 z-20 flex w-72 flex-col gap-sm rounded-card border bg-surface-popover p-3 shadow-popover",children:[t.jsx("div",{className:"line-clamp-6 whitespace-pre-wrap text-footnote text-secondary",children:G(r)}),t.jsxs("div",{className:"flex items-center gap-xs",children:[t.jsx("span",{className:"text-footnote text-muted tabular-nums",children:n}),t.jsx(We,{variant:"neutral",size:"sm",children:da[s]})]})]})}const pa=e.memo(function({editorRef:n,editorReady:s,storeKey:r,documentRef:o}){const i=e.useRef(null),a=e.useCallback(e=>{const t=J(r);return t.listeners.add(e),()=>t.listeners.delete(e)},[r]),l=e.useCallback(()=>J(r).store.comments,[r]),c=e.useCallback(()=>ua,[]),u=e.useSyncExternalStore(a,l,c),d=K(o),f=e.useMemo(()=>{const e=e=>"text-quote"===e.target.anchor.kind?e.target.anchor.startOffset:Number.MAX_SAFE_INTEGER;return u.filter(e=>H(e)&&"resolved"!==e.status&&!!e.sourceAnchorId&&"text-quote"===e.target.anchor.kind&&K(e.target.document)===d).sort((t,n)=>e(t)-e(n)).map((e,t)=>({comment:e,anchorId:e.sourceAnchorId,n:t+1}))},[u,d]),[h,m]=e.useState([]);e.useLayoutEffect(()=>{const e=n.current?.contentRoot,t=n.current?.element,r=i.current?.closest("[data-clarkdown-scroll]");if(!(s&&e&&t&&r))return void m(e=>0===e.length?e:[]);const o=()=>{const t=r.getBoundingClientRect(),n=[];for(const s of f){const o=e.querySelector(ha(s.anchorId)),i=o?.getClientRects(),a=i?.[i.length-1];a&&n.push({...s,top:a.top-t.top+r.scrollTop,left:a.right-t.left+r.scrollLeft})}m(e=>{return s=n,(t=e).length===s.length&&t.every((e,t)=>e.comment.id===s[t].comment.id&&e.comment.text===s[t].comment.text&&e.comment.source===s[t].comment.source&&e.n===s[t].n&&e.top===s[t].top&&e.left===s[t].left)?e:n;var t,s})};let a=0;const l=()=>{0===a&&(a=requestAnimationFrame(()=>{a=0,o()}))};o();const c=new ResizeObserver(o);c.observe(t),c.observe(r),r.addEventListener("scroll",l,{passive:!0});const u=new MutationObserver(l);u.observe(e,{childList:!0,subtree:!0});let d=0,h=0;const p=()=>{d=0,o();f.some(t=>!e.querySelector(ha(t.anchorId)))&&h++<60&&(d=requestAnimationFrame(p))};return d=requestAnimationFrame(p),()=>{c.disconnect(),u.disconnect(),r.removeEventListener("scroll",l),a&&cancelAnimationFrame(a),d&&cancelAnimationFrame(d)}},[n,s,f]);const[p,g]=e.useState(null),x=e.useRef(!1),y=Ze(0),b=Ze(0),v=e.useCallback(e=>{const t=i.current?.closest("[data-clarkdown-scroll]");if(!t)return;const n=t.getBoundingClientRect(),s=t.scrollLeft,r=t.scrollTop;y.set(Ve(e.clientX-n.left+s+12,s+8,Math.max(s+8,s+t.clientWidth-288-8))),b.set(Ve(e.clientY-n.top+r+14,r+8,Math.max(r+8,r+t.clientHeight-180)))},[y,b]),w=e.useRef(0),k=e.useRef(!1),S=e.useCallback(e=>{window.clearTimeout(w.current),g(e)},[]),C=e.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>g(null),150)},[]);e.useEffect(()=>{if(!s)return;const e=new AbortController,t=e=>{0===e.button&&(k.current="pointerdown"===e.type)},r=()=>{k.current=!1};document.addEventListener("pointerdown",t,{capture:!0,signal:e.signal}),document.addEventListener("pointerup",t,{capture:!0,signal:e.signal}),document.addEventListener("pointercancel",r,{capture:!0,signal:e.signal}),document.addEventListener("dragstart",r,{capture:!0,signal:e.signal});const o=n.current?.subscribe("ckd-span-hover",e=>{const t=e.detail;if(t?.sid&&"comment"===t.kind){if(!k.current){const e=n.current?.contentRoot?.querySelector(ha(t.sid)),s=e?.getClientRects(),r=s?.[s.length-1];r&&v({clientX:r.left+r.width/2,clientY:r.bottom}),S(t.sid)}}else t?.sid||C()});return n.current?.element?.addEventListener("mousemove",e=>x.current&&v(e),{signal:e.signal}),()=>{o?.(),e.abort(),window.clearTimeout(w.current)}},[s,n,S,C,v]);const N=p?h.find(e=>e.anchorId===p):void 0,E="ai-review"===N?.comment.source?N:void 0;return x.current=void 0!==E,t.jsxs("div",{ref:i,className:"absolute left-0 top-0 size-0",children:[h.map(e=>t.jsx("sup",{"data-doc-annotation-id":e.comment.id,onMouseEnter:t=>{0===t.buttons&&(v(t),S(e.anchorId))},onMouseMove:v,onMouseLeave:C,className:"pointer-events-auto absolute z-10 select-none font-ui font-medium leading-none text-muted",style:{top:e.top,left:e.left,fontSize:"0.625rem"},children:e.n},e.comment.id)),E?t.jsx(ma,{id:E.comment.id,n:E.n,...fa(E.comment.text),x:y,y:b}):null]})});pa.displayName="AnnotationPopover";class ga extends Error{constructor(e){super("working file changed underneath this write"),this.currentSha256=e,this.name="WorkingFileConflict"}}let xa=null;function ya(){if(xa)return xa;const e=new CSSStyleSheet;return e.replaceSync(`\n    .ckd-scroller {\n      outline: none;\n      caret-color: hsl(var(--text-100));\n    }\n    /* The viewer uses display:grid + gap on .prose; the sink scroller has\n     * structural children (.ckd-spacer for virtual scroll) that mustn't take\n     * a gap, so space the rendered blocks with margin instead. */\n    .ckd-scroller > :not(.ckd-spacer) {\n      min-width: 0;\n      margin-block: 0 0.75rem;\n    }\n    .ckd-scroller h1, .ckd-scroller h2, .ckd-scroller h3,\n    .ckd-scroller h4, .ckd-scroller h5, .ckd-scroller h6 {\n      color: hsl(var(--text-100));\n      font-weight: 600;\n      margin: 0.75rem 0 -0.25rem;\n    }\n    .ckd-scroller h1 { font-size: 1.375rem; }\n    .ckd-scroller h2 { font-size: 1.125rem; }\n    .ckd-scroller h3, .ckd-scroller h4 { font-size: 1rem; margin-top: 0.5rem; }\n    .ckd-scroller h5, .ckd-scroller h6 { font-size: 0.875rem; margin-top: 0.5rem; }\n    .ckd-scroller p, .ckd-scroller li { font-size: 1rem; line-height: 1.5; }\n    .ckd-scroller p { overflow-wrap: break-word; margin: 0; }\n    .ckd-scroller ul, .ckd-scroller ol {\n      display: flex;\n      flex-direction: column;\n      gap: 0.25rem;\n      padding-left: 2rem;\n      margin: 0 0 0.75rem;\n    }\n    .ckd-scroller ul { list-style-type: disc; }\n    .ckd-scroller ol { list-style-type: decimal; }\n    .ckd-scroller li { padding-left: 0.5rem; overflow-wrap: break-word; }\n    .ckd-scroller li ul, .ckd-scroller li ol { margin-top: 0.25rem; margin-bottom: 0; }\n    .ckd-scroller li > p { display: contents; }\n    .ckd-scroller blockquote {\n      margin: 0 0 0 0.5rem;\n      padding-left: 1rem;\n      border-left: 4px solid hsl(var(--border-300) / 0.1);\n      color: hsl(var(--text-300));\n    }\n    .ckd-scroller code {\n      background: hsl(var(--text-200) / 0.05);\n      border: 0.5px solid hsl(var(--border-300) / 0.15);\n      color: hsl(var(--danger-000));\n      white-space: pre-wrap;\n      border-radius: 0.4rem;\n      padding: 1px 0.25rem;\n      font-size: 0.9rem;\n    }\n    .ckd-scroller pre {\n      background: hsl(var(--bg-000) / 0.5);\n      border: 0.5px solid hsl(var(--border-400) / 0.15);\n      border-radius: 0.5rem;\n      padding: 0.875rem;\n      overflow-x: auto;\n      margin: 0;\n    }\n    .ckd-scroller pre code {\n      background: none;\n      border: none;\n      color: inherit;\n      padding: 0;\n      font-size: 0.875rem;\n      line-height: 1.625;\n      white-space: pre;\n    }\n    .ckd-scroller table {\n      width: 100%;\n      border-collapse: collapse;\n      font-size: 0.875rem;\n      line-height: 1.7;\n    }\n    .ckd-scroller th {\n      color: hsl(var(--text-100));\n      border-bottom: 0.5px solid hsl(var(--border-300) / 0.6);\n      padding: 0.5rem 1rem 0.5rem 0;\n      text-align: left;\n      vertical-align: top;\n      font-weight: 600;\n    }\n    .ckd-scroller td {\n      border-bottom: 0.5px solid hsl(var(--border-300) / 0.3);\n      padding: 0.5rem 1rem 0.5rem 0;\n      vertical-align: top;\n    }\n    .ckd-scroller hr {\n      border: none;\n      border-top: 0.5px solid hsl(var(--border-200) / 0.3);\n      margin: 0.75rem 0.375rem;\n    }\n    .ckd-scroller a {\n      /* Custom properties pierce the shadow boundary \u2014 without this the\n       * UA default link blue shows instead of the CDS accent. */\n      color: ${Q.text.accent.cssVar};\n      /* Editable text, not navigation \u2014 clicking places the caret (and\n       * summons the link callout); only the callout's anchor navigates,\n       * so only it gets the pointer. */\n      cursor: text;\n      text-decoration: underline;\n      text-underline-offset: 2px;\n      text-decoration-thickness: 1px;\n      text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);\n    }\n    .ckd-scroller a:hover, .ckd-scroller a:focus-visible {\n      text-decoration-color: currentColor;\n    }\n    \n  .ckd-scroller .comment-anchor {\n    text-decoration-line: underline;\n    text-decoration-style: dotted;\n    text-decoration-thickness: 1px;\n    text-underline-offset: 3px;\n    text-decoration-color: hsl(var(--text-400));\n    /* The host-rendered <sup> counter is absolutely positioned at this\n     * span's last rect's right edge; the margin makes room between the\n     * counter and the next inline character. */\n    margin-inline-end: 0.3em;\n  }\n\n  `),xa=e,e}let ba=null;let va=null;function wa(e){return null!=e}const ka={actions:{ul:{enabled:!1,active:!1},ol:{enabled:!1,active:!1},indent:{enabled:!1,active:!1},codeblock:{enabled:!1,active:!1},link:{enabled:!1,active:!1}},activeMarks:[],capabilities:{paragraphToList:!1,toggleLink:!1}},Sa=["Strong","Emph","Underline","Code","Strike"];const Ca=e.memo(e.forwardRef(function({content:s,className:r,onSave:o,isSaving:a=!1,ephemeral:l=!1,autosaveSuspended:c=!1,readUpstreamContent:u,analyticsCtx:d,overlayChildren:m},g){const x=f(),y=h({analytics:x,analyticsCtx:d,ephemeral:l}),b=e.useRef(null),w=e.useRef(null),k=e.useRef(null),S=e.useRef(!1),C=e.useRef(!1),[N,E]=e.useState(!1),[j,M]=e.useState(!1),[L,T]=e.useState(s),[O,A]=e.useState("idle"),R=e.useRef(s),[I,_]=e.useState(!1),D=e.useRef(!1),$=e.useRef(null),F=e.useCallback(e=>{$.current=e,D.current=!0,_(!0)},[]),P=e.useCallback(()=>{$.current=null,D.current=!1,_(!1)},[]),q=h(c),B=h(u),K=e.useRef(()=>{}),z=e.useRef(()=>{}),H=e.useRef(()=>{}),U=e.useRef(0),W=e.useRef(s.length),Y=e.useRef(s);e.useLayoutEffect(()=>{Y.current=s},[s]),e.useLayoutEffect(()=>{const e=b.current;if(!e)return;let t=!1,s=null;const r=new AbortController,o=performance.now();return(ba??=n(()=>import("./c4517f799-Dv4g2wDn.js"),[],import.meta.url).then(e=>e.ready).catch(e=>{throw ba=null,e}),ba).then(()=>async function(){if(va)return va;try{const e=await n(()=>import("./c2abd4ebb-C55uL3DR.js"),[],import.meta.url),t=(t,n)=>{const s=new e.ClarkdownEditor;try{return s.set_source(t),void 0===JSON.parse(s.apply_op(new Uint32Array([0]),n)).error}catch{return!1}finally{s.free()}};va={paragraphToList:t("a\n",'{"SetListKind":"Bullet"}'),toggleLink:t("ab\n",'{"ToggleLink":{"from":0,"to":2,"dest":"https://probe.invalid"}}')}}catch{va={paragraphToList:!1,toggleLink:!1}}return va}()).then(()=>{t||(s=document.createElement("clarkdown-editor"),s.setAttribute("pipeline","sink"),s.setAttribute("surfaces","slash context_menu"),s.setAttribute("role","textbox"),s.setAttribute("aria-multiline","true"),s.setAttribute("spellcheck","false"),s.className=wo,e.append(s),s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,ya()],w.current=s,C.current=!0,s.editor.set_source(Y.current),s.rerender(),C.current=!1,s.addEventListener("selectionchange",e=>{k.current=e.detail?.context??null},{signal:r.signal}),s.addEventListener("ck-change",()=>{if(C.current||!w.current)return;const e=w.current.editor.source();T(e),W.current=e.length,U.current+=1,z.current(),e===R.current||D.current||(A("pending"),ee.current())},{signal:r.signal}),s.addEventListener("keydown",e=>{if((e.metaKey||e.ctrlKey)&&"s"===e.key)return e.preventDefault(),void K.current("manual");if("Escape"!==e.key){if("Tab"===e.key){if(S.current)return void(S.current=!1);e.preventDefault()}}else S.current=!0},{signal:r.signal}),E(!0),y.current.analytics.track({event_key:"claudeai.brass_falcon.edit_opened",...y.current.analyticsCtx,load_ms:Math.round(performance.now()-o),content_length:Y.current.length,ephemeral:y.current.ephemeral}))}).catch(e=>{t||(console.error("[clarkdown-editor] load failed:",e),M(!0),y.current.analytics.track({event_key:"claudeai.brass_falcon.load_failed",...y.current.analyticsCtx,mode:"edit",error_kind:p(e)}))}),()=>{t=!0,r.abort(),s?.remove(),w.current=null}},[]);const X=e.useCallback(e=>{const t=w.current;t&&(R.current=e,C.current=!0,t.editor.set_source(e),t.rerender(),C.current=!1,T(e),A("idle"),U.current=0,W.current=e.length,P())},[P]);e.useEffect(()=>{const e=w.current;if(!e)return void(R.current=s);if(s===R.current)return;const t=e.editor.source();return t===s?(R.current=s,void P()):t!==R.current?(F(s),void A(e=>"pending"===e||"saving"===e?"idle":e)):void X(s)},[s,N,X,F,P]);const J=e.useCallback(()=>{X(Y.current)},[X]),G=e.useCallback(()=>{K.current("manual")},[]),Q=e.useCallback(async e=>{if(q.current&&"auto"===e)return;if(D.current&&"manual"!==e)return;const t=w.current?.editor.source()??L;if(t===R.current&&!D.current)return void A(e=>"pending"===e||"saving"===e?"saved":e);if("manual"===e&&D.current&&B.current&&await B.current().catch(()=>null),"manual"!==e&&B.current){const e=await B.current().catch(()=>null);if(null!==e&&e!==R.current&&e!==t)return Y.current=e,F(e),void A(e=>"pending"===e||"saving"===e?"idle":e)}A("saving");const n=$.current;try{await o(t),R.current=t,("manual"===e&&null!==n&&$.current===n||Y.current===t)&&P();const s=w.current?.editor.source();void 0===s||s===t||D.current?A(s!==t?e=>"saving"===e?"idle":e:e=>"saving"===e?"saved":e):(A("pending"),ee.current())}catch(s){if(s instanceof ga){const e=B.current?await B.current().catch(()=>null):null;if(null!==e&&e!==t)return Y.current=e,F(e),void A(e=>"pending"===e||"saving"===e?"idle":e)}A("error");const n=y.current;n.analytics.track({event_key:"claudeai.brass_falcon.save_failed",...n.analyticsCtx,trigger:e,ephemeral:n.ephemeral,content_length:t.length,error_kind:p(s)})}},[o,L,y,q,B,F,P]),Z=St(()=>{Q("auto")},800),ee=e.useRef(Z);e.useEffect(()=>{ee.current=Z},[Z]),e.useEffect(()=>{K.current=e=>{Q(e)}},[Q]);const te=e.useRef(c);e.useEffect(()=>{te.current&&!c&&K.current("auto"),te.current=c},[c]);const ne=e.useCallback(()=>{const e=U.current;if(0===e)return;U.current=0;const t=y.current;t.analytics.track({event_key:"claudeai.brass_falcon.edited",...t.analyticsCtx,ephemeral:t.ephemeral,content_length:W.current,change_count:e})},[y]),se=St(ne,1e4);e.useEffect(()=>{z.current=se,H.current=ne},[se,ne]),e.useEffect(()=>{const e=()=>{"hidden"===document.visibilityState&&(H.current(),K.current("visibility"))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e),H.current(),K.current("unmount")}},[]);const re=!l&&("pending"===O||"saving"===O||"error"===O||I);e.useEffect(()=>{if(!re)return;const e=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[re]),e.useImperativeHandle(g,()=>({get element(){return w.current},get contentRoot(){return w.current?.shadowRoot?.querySelector(".ckd-scroller")??null},getSource:()=>w.current?.editor.source()??"",getSourceSelection:()=>{const e=w.current?.selection;return e&&e.anchor!==e.head?{start:Math.min(e.anchor,e.head),end:Math.max(e.anchor,e.head)}:null},getCaretSourceOffset:()=>{const e=w.current?.selection;return e&&e.anchor===e.head?e.head:null},getSelectionRect:()=>w.current?.selectionRect()??null,toggleMark:e=>{const t=w.current,n=t?.context??k.current,s=t?.selection;if(!t||!n||!s)return;const r=Math.min(s.anchor,s.head),o=Math.max(s.anchor,s.head);t.exec([[n.path,{ToggleMark:{from:r,to:o,mark:e}}]],s)},getFormatStates:()=>{const e=w.current,t=e?.context??k.current;if(!e||!t)return ka;const n=e.selection;return function(e,t,n,s){if(!e)return ka;const r=wa(e.list_path),o="Para"===e.block||"Header"===e.block,i="Rich"===e.block&&"code"===e.rich_kind,a=null!==t&&t.anchor!==t.head,l=!r&&"Para"===e.block&&!wa(e.quote_path)&&!!n?.paragraphToList,c=r&&"Bullet"===e.list_kind&&!wa(e.list_item_checked),u=r&&"object"==typeof e.list_kind&&null!==e.list_kind&&"Ordered"in e.list_kind&&!wa(e.list_item_checked),d=Sa.filter(t=>e.marks?.includes(t)||e.pending?.includes(t)),f=(r||l)&&s,h=!f&&!n?.paragraphToList&&!r&&"Para"===e.block&&!wa(e.quote_path)&&s,m=(i||o&&!wa(e.quote_path)&&!r)&&s,p=!!n?.toggleLink&&(wa(e.link)||o&&a&&s);return{actions:{ul:{enabled:f,active:f&&c,disabledByCapability:h},ol:{enabled:f,active:f&&u,disabledByCapability:h},indent:{enabled:r&&"Bullet"===e.list_kind&&("Para"===e.block||"Header"===e.block||"List"===e.block)&&(e.path[e.list_path?.length??0]??0)>0&&s,active:!1},codeblock:{enabled:m,active:m&&i},link:{enabled:p,active:p&&wa(e.link),disabledByCapability:!n?.toggleLink&&(wa(e.link)||o&&a&&s)}},activeMarks:d,capabilities:{paragraphToList:!!n?.paragraphToList,toggleLink:!!n?.toggleLink},linkHref:e.link?.href}}(t,n,va,function(e,t,n){if(!t||t.anchor===t.head)return!0;try{const s=Math.min(t.anchor,t.head),r=Math.max(t.anchor,t.head),o=JSON.parse(e.editor.context_at(s)),i=e.editor.source();let a=r-1;for(;a>s&&/\s/.test(i[a]??"");)a-=1;const l=JSON.parse(e.editor.context_at(a));if(!wa(o.path)||!wa(l.path))return!0;const[c,u]=o.path.length<=l.path.length?[o.path,l.path]:[l.path,o.path];if(0===c.length)return 0===u.length;if(!c.every((e,t)=>e===u[t]))return!1;if(!wa(n)||0===n.length)return!1;const[d,f]=n.length<=u.length?[n,u]:[u,n];return d.every((e,t)=>e===f[t])}catch{return!0}}(e,n,t.path))},applyFormatAction:(e,t,n)=>{const s=w.current,r=s?.context??k.current;if(!s||!r)return!1;if("link"===e&&n){const e=s.editor.source();if(!(n.start<n.end&&n.end<=e.length)||e.slice(n.start,n.end)!==n.text)return!1;try{const e=JSON.parse(s.editor.context_at(n.start));if(!wa(e.path))return!1;const r={ToggleLink:{from:n.start,to:n.end,dest:t??""}};return!0===s.exec([[e.path,r]],n.end)?.ok}catch{return!1}}const o=s.selection,i=function(e,t,n,s){switch(e){case"ul":return wa(t.list_path)&&"Bullet"===t.list_kind&&!wa(t.list_item_checked)?[t.path.slice(0,t.list_path.length+1),"OutdentListItem"]:[t.list_path??t.path,{SetListKind:"Bullet"}];case"ol":return wa(t.list_path)&&"object"==typeof t.list_kind&&null!==t.list_kind&&"Ordered"in t.list_kind&&!wa(t.list_item_checked)?[t.path.slice(0,t.list_path.length+1),"OutdentListItem"]:[t.list_path??t.path,{SetListKind:{Ordered:{start:1}}}];case"indent":return wa(t.list_path)?[t.path.slice(0,t.list_path.length+1),"IndentListItem"]:null;case"codeblock":return[t.path,{SetBlockKind:"Rich"===t.block&&"code"===t.rich_kind?"Para":{CodeBlock:{}}}];case"link":if(wa(t.link)){const e=n?n.head:t.sel?.offset;return wa(e)?[t.path,{ToggleLink:{from:e,to:e,dest:""}}]:null}return n?[t.path,{ToggleLink:{from:Math.min(n.anchor,n.head),to:Math.max(n.anchor,n.head),dest:s??""}}]:null}}(e,r,o,t);if(!i)return!1;const a=o?Math.max(o.anchor,o.head):r.sel?r.sel.offset+r.sel.delete:0;return!0===s.exec([i],a)?.ok},retargetLink:(e,t)=>{const n=w.current;if(!n||!t)return!1;const s=n.editor.source();if(!(e.start<e.end&&e.end<=s.length)||s.slice(e.start,e.end)!==e.text)return!1;if(!Mo(e.text)||Lo(e.text))return!1;try{const r=Math.floor((e.start+e.end)/2),o=JSON.parse(n.editor.context_at(r));if(!wa(o.path)||!wa(o.link))return!1;const i=o.link.href??"",a=s.length;if(!0!==n.exec([[o.path,{ToggleLink:{from:r,to:r,dest:""}}]],r)?.ok)return!1;const l=e.end-(a-n.editor.source().length),c=(t,s)=>{if(t<=e.start||!s)return!1;const r=JSON.parse(n.editor.context_at(e.start));return!!wa(r.path)&&!0===n.exec([[r.path,{ToggleLink:{from:e.start,to:t,dest:s}}]],t)?.ok};return!!c(l,t)||(c(l,i),!1)}catch{return!1}},focusEditor:()=>{const e=w.current,t=e?.shadowRoot?.querySelector(".ckd-sink");t?.focus({preventScroll:!0})},subscribe:(e,t)=>{const n=w.current;return n?(n.addEventListener(e,t),()=>n.removeEventListener(e,t)):()=>{}},setHighlights:"function"==typeof w.current?.setHighlights?e=>w.current?.setHighlights?.(e):void 0,setProviders:e=>{const t=w.current;t&&(t.providers={...t.providers,...e})}}),[N]);const oe="pending"===O||"saving"===O||a?t.jsx(i,{defaultMessage:"Saving\u2026",id:"WUV28A6Pf2"}):"saved"===O?l?t.jsx(i,{defaultMessage:"Edits apply to this conversation",id:"eCaTvU2T8T"}):t.jsx(i,{defaultMessage:"All changes saved",id:"q6Z3dII6Qi"}):"error"===O?t.jsx("span",{className:"text-danger-000",children:t.jsx(i,{defaultMessage:"Couldn't save changes",id:"ojMNJN5low"})}):null,ie=e.useCallback(e=>{if(0!==e.button)return;if(e.target!==e.currentTarget&&e.target!==b.current)return;const t=w.current;if(!t)return;const n=e.currentTarget;if(n.scrollHeight>n.clientHeight||e.clientY<t.getBoundingClientRect().bottom)return;e.preventDefault();const s=t.editor.source().length,r=e.shiftKey?t.selection?.anchor??s:s;window.setTimeout(()=>{t.shadowRoot?.querySelector(".ckd-sink")?.focus({preventScroll:!0}),t.setSelection(r,s,{reveal:!1})},0)},[]);return t.jsxs("div",{className:v("flex h-full flex-col",r),children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsxs("div",{"data-clarkdown-scroll":"",className:"relative h-full overflow-auto scroll-fade-y scroll-fade-size-6",onMouseDown:ie,children:[!N&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-body text-text-300",children:j?t.jsx(i,{defaultMessage:"Editor failed to load. Refresh to try again.",id:"LKg3IXHCco"}):t.jsx(io,{})}),t.jsx("div",{ref:b,"data-clarkdown-editor-host":"",className:"mx-auto w-full max-w-3xl py-4 pl-6 pr-6 md:py-6 md:pl-11 md:pr-11 font-claude-response"}),m]}),t.jsx("div",{"aria-live":"polite",className:"pointer-events-none absolute bottom-1.5 right-3 text-caption text-text-400",children:null!==oe&&t.jsx("span",{className:"rounded bg-surface-3/85 px-1.5 py-0.5 backdrop-blur-sm",children:oe})})]}),t.jsxs("div",{className:v("flex flex-wrap items-center justify-end gap-x-3 gap-y-1 px-3 text-caption text-secondary",I&&"border-t py-1.5"),children:[t.jsx("span",{role:"status",children:I&&t.jsx(i,{defaultMessage:"This file changed on disk.",id:"W0f2Z5b2vQ"})}),I&&t.jsxs(t.Fragment,{children:[t.jsx(V,{onClick:J,children:t.jsx(i,{defaultMessage:"Reload file",id:"yMEkuG7p6+"})}),t.jsx(V,{onClick:G,children:t.jsx(i,{defaultMessage:"Keep your edits",id:"czJhdFh6sE"})})]})]})]})}));function Na(e,t){const n=Math.min(e.length,t+256);for(let s=t;s<n;s++)if("}"===e[s])return e.slice(t,s);return null}function Ea(e){const t=/(?:^|\s)(?:id=|#)([^\s}]+)/.exec(e);return t?.[1]??null}const ja=/^\[\^([^\s\]]+)\]:[ \t]*(?:@(\S+)[ \t]+\d{4}-\d{2}-\d{2}:[ \t]*)?(.*)$/;function Ma(e,t){return`src:${e}:${t}`}const La=new Map,Ta=new Map;function Oa(e,t,n){const s=K(n),r=`${t}::${s}`,o=La.get(r)??new Set,i=Ta.get(r),a=function(e){const t=function(e){const t=e=>e.replace(/[^\n]/g," ");return e.replace(/^(```|~~~)[^\n]*\n[\s\S]*?^\1[^\n]*$/gm,t).replace(/(?<!\\)`[^`\n]+`/g,t)}(e),n=new Map;let s=-1;for(let a=0;a<t.length;a++){const r=t[a];if("["===r)s=a;else if("]"===r){if(-1!==s&&"{"===t[a+1]){const r=Na(t,a+2);if(null!==r&&/\bcomment-anchor\b/.test(r)){const t=Ea(r);if(t){const r=s+1;n.set(t,{start:r,end:a,exact:e.slice(r,a)})}}}s=-1}}const r=[],o=t.split("\n"),i=e.split("\n");for(let a=0;a<i.length;a++){if(!ja.test(o[a]))continue;const e=ja.exec(i[a]);if(!e)continue;const[,t,s,l]=e,c=n.get(t);if(!c)continue;const u=[l??""];for(;a+1<i.length&&/^ {2,}|^\t/.test(i[a+1]);)a++,u.push(i[a].replace(/^[ \t]+/,""));const d=u.join("\n").trim();d&&r.push({id:t,body:d,author:s??null,source:"claude"===s?.toLowerCase()?"ai-review":"human",anchor:c})}return r}(e),l=new Set(a.map(e=>Ma(s,e.id))),c=J(t),u=new Map(c.store.comments.map(e=>[e.id,e])),d=e=>c.store.comments.some(t=>t.replyToCommentUuid===e),f=new Set;let h=!1;const m=Date.now();for(const p of a){const t=Ma(s,p.id);if(i?.has(t))continue;const r=G(p.body);if(""===r)continue;const o=p.author?te(p.author,64):null,a=U(n,{exact:p.anchor.exact,prefix:e.slice(Math.max(0,p.anchor.start-32),p.anchor.start),suffix:e.slice(p.anchor.end,p.anchor.end+32),startOffset:p.anchor.start,endOffset:p.anchor.end}),l=u.get(t);f.add(t),l&&"open"===l.status&&l.text===r&&(l.author?.fullName??null)===o&&l.source===p.source&&"text-quote"===l.target.anchor.kind&&l.target.anchor.startOffset===p.anchor.start&&l.target.anchor.endOffset===p.anchor.end&&l.target.anchor.exact===p.anchor.exact||(u.set(t,{id:t,sourceAnchorId:p.id,text:r,target:a,createdAt:l?.createdAt??m,updatedAt:m,author:o?{uuid:o,fullName:o}:null,isOwn:!1,source:p.source,status:"open",localOnly:!0}),h=!0)}for(const p of o){if(l.has(p))continue;const e=u.get(p);e&&!0===e.localOnly&&(d(p)?("resolved"!==e.status&&(u.set(p,{...e,status:"resolved",updatedAt:m}),h=!0),f.add(p)):(u.delete(p),h=!0))}if(La.set(r,f),i)for(const p of i)l.has(p)||i.delete(p);h&&ne(t,Array.from(u.values()))}const Aa={id:"unknown",name:"Unknown"};function Ra(e){return{id:e.id,author:(t=e.author,t?{id:t.uuid,name:te(t.fullName??t.uuid,64)}:Aa),body:G(e.text),createdAt:new Date(e.createdAt).toISOString()};var t}function Ia(e){const{storeKey:t,documentRef:n,getSource:s,author:r}=e,o=K(n);function i(e){const n=J(t);re(t,{...n.store,comments:[...n.store.comments,e]})}return{list:()=>Promise.resolve(function(e){const t=z(e),n=[];for(const s of e){if(!H(s)||"resolved"===s.status)continue;const e=s.target.anchor;"text-quote"===e.kind&&n.push({id:s.id,anchor:{start:e.startOffset,end:e.endOffset},resolved:!1,comments:[s,...t.get(s.id)??[]].map(Ra)})}return n}(function(){const{store:e}=J(t);return e.comments.filter(e=>K(e.target.document)===o)}())),create:(e,t)=>{const o=s(),a=Math.max(0,Math.min(e.start,e.end)),l=Math.min(o.length,Math.max(e.start,e.end)),c=Date.now(),u={id:ee(),text:t,target:U(n,{exact:o.slice(a,l),prefix:o.slice(Math.max(0,a-32),a),suffix:o.slice(l,l+32),startOffset:a,endOffset:l}),createdAt:c,updatedAt:c,author:r,isOwn:!0,status:"open"};return i(u),Promise.resolve({id:u.id,anchor:{start:a,end:l},resolved:!1,comments:[Ra(u)]})},reply:(e,s)=>{const o=J(t).store.comments.find(t=>t.id===e),a=Date.now(),l={id:ee(),text:s,target:o?.target??U(n,{exact:"",prefix:"",suffix:"",startOffset:0,endOffset:0}),createdAt:a,updatedAt:a,author:r,isOwn:!0,replyToCommentUuid:e,status:"open",...Z(o)?{localOnly:!0}:{}};return o&&i(l),Promise.resolve(Ra(l))},resolve:(e,s)=>s?(function(e,t,n){const s=`${e}::${K(t)}`;let r=Ta.get(s);r||(r=new Set,Ta.set(s,r)),r.add(n),se(e,[n])}(t,n,e),Promise.resolve()):Promise.resolve(),subscribe:e=>{const n=J(t);return n.listeners.add(e),()=>{n.listeners.delete(e)}}}}const _a=e.memo(function({content:n,onSave:s,isSaving:r,ephemeral:i,autosaveSuspended:a,readUpstreamContent:l,reviewStoreKey:c,documentRef:u,analyticsCtx:d,onSendToClaude:h,sendDisabled:m}){const p=o(),g=f(),{account:x}=oe(),y=e.useRef(null),[b,v]=e.useState(!1),[w,k]=e.useState(n);e.useEffect(()=>{b&&void 0!==c&&y.current?.setProviders({comment:Ia({storeKey:c,documentRef:u,getSource:()=>y.current?.getSource()??"",author:x?{uuid:x.uuid,fullName:x.full_name??null}:null})})},[b,c,u,x]);const S=e.useRef(0);e.useEffect(()=>{if(void 0!==c)return window.clearTimeout(S.current),S.current=window.setTimeout(()=>Oa(w,c,u),120),()=>window.clearTimeout(S.current)},[w,c,u]);const C=void 0!==c?t.jsx(pa,{editorRef:y,editorReady:b,storeKey:c,documentRef:u}):null,N=e.useMemo(()=>{if(!b)return;return{getSourceSelection:()=>y.current?.getSourceSelection()??null,getCaretSourceOffset:()=>y.current?.getCaretSourceOffset()??null,getSource:()=>y.current?.getSource()??null,getSelectionRect:()=>y.current?.getSelectionRect()??null,getContentRoot:()=>y.current?.contentRoot??null,onSelectionChange:e=>y.current?.subscribe("selectionchange",e)??(()=>{}),setHighlights:y.current?.setHighlights,onHighlightClick:e=>y.current?.subscribe("ckd-highlight-click",t=>{e(String(t.detail?.id??""))})??(()=>{}),onHighlightsStale:e=>y.current?.subscribe("ckd-highlights-stale",e)??(()=>{}),focusEditor:()=>y.current?.focusEditor(),rangeForOffsets:(e,t)=>{const n=y.current?.contentRoot;if(!n)return null;let s=null;for(const o of n.querySelectorAll("[data-ck-s]")){const n=Number(o.getAttribute("data-ck-s")),r=Number(o.getAttribute("data-ck-e"));n<=e&&t<=r&&(s=o)}if(!s)return null;const r=document.createRange();return r.selectNodeContents(s),r}}},[b]),[E,j]=e.useState();e.useEffect(()=>{if(!b)return;const e=y.current;if(!e)return;let t="";const n=()=>{const n=e.getFormatStates(),s=JSON.stringify(n);s!==t&&(t=s,j(n))};n();const s=e.subscribe("selectionchange",n),r=e.subscribe("ck-change",n);return()=>{s(),r()}},[b]);const M=e.useMemo(()=>{const e=e=>E?.activeMarks.includes(e)??!1,t=e=>({op:e,disabled:!E?.actions[e].enabled,active:E?.actions[e].active??!1}),n=(e,t)=>!E||E.actions[e].disabledByCapability?{disabledReason:t}:{};return[{id:"bold",icon:"TextBold",label:p.formatMessage({defaultMessage:"Bold",id:"DkkmwmSdVr"}),mark:"Strong",shortcut:"cmd+b",toggle:!0,active:e("Strong")},{id:"italic",icon:"TextItalics",label:p.formatMessage({defaultMessage:"Italic",id:"g2V+esMawV"}),mark:"Emph",shortcut:"cmd+i",toggle:!0,active:e("Emph")},{id:"underline",icon:"TextUnderline",label:p.formatMessage({defaultMessage:"Underline",id:"SOtMvFFtD0"}),mark:"Underline",shortcut:"cmd+u",toggle:!0,active:e("Underline")},{id:"strike",icon:jo,label:p.formatMessage({defaultMessage:"Strikethrough",id:"lH8y+XQpfx"}),mark:"Strike",shortcut:"cmd+shift+x",toggle:!0,active:e("Strike")},{id:"div-marks",icon:"Code",label:"",divider:!0},{id:"link",icon:"Link",label:p.formatMessage({defaultMessage:"Link",id:"JBWS0clugK"}),shortcut:"cmd+shift+u",prompt:"url",toggle:!0,activeHref:E?.linkHref,...t("link"),...n("link",p.formatMessage({defaultMessage:"Links aren't available yet",id:"IFzzJ+rTy4"}))},{id:"ul",icon:"ListBullet",label:p.formatMessage({defaultMessage:"Bulleted list",id:"k1MVLcAb3B"}),toggle:!0,...t("ul"),...n("ul",p.formatMessage({defaultMessage:"Bulleted lists aren't available yet",id:"+lrrnE8+4q"}))},{id:"ol",icon:"ListNumbered",label:p.formatMessage({defaultMessage:"Numbered list",id:"lbsCQSfTG9"}),toggle:!0,...t("ol"),...n("ol",p.formatMessage({defaultMessage:"Numbered lists aren't available yet",id:"EXOi4SI/5K"}))},{id:"div-lists",icon:"Code",label:"",divider:!0},{id:"indent",icon:"Indent",label:p.formatMessage({defaultMessage:"Indent",id:"WrpuHk62Vt"}),...t("indent")},{id:"code",icon:"Code",label:p.formatMessage({defaultMessage:"Code",id:"h2vipunVVd"}),mark:"Code",shortcut:"cmd+e",toggle:!0,active:e("Code")},{id:"codeblock",icon:"CodeBlock",label:p.formatMessage({defaultMessage:"Code block",id:"8typ4gfVt/"}),toggle:!0,...t("codeblock")}]},[p,E]),L=e.useCallback((e,t,n)=>{let s=!1;if(e.mark)y.current?.toggleMark(e.mark),s=!0;else if("link"===e.op){if(!e.active&&void 0===t)return;if(e.active&&void 0!==t){if(!n)return;let r=t;if(t!==e.activeHref){const e=t.replace(/[\u0000-\u0020\u007f]/g,""),n=/^([a-z][a-z0-9+.-]*):/i.exec(e)?.[1]?.toLowerCase();(e!==t||void 0!==n&&"http"!==n&&"https"!==n&&"mailto"!==n)&&(r="")}if(""===r)return;s=y.current?.retargetLink(n,r)??!1}else if(e.active){if(!y.current?.getFormatStates().actions.link.active)return;s=y.current?.applyFormatAction("link","")??!1}else{const e=function(e){const t=e.trim();if(t.startsWith("#")||t.startsWith("/"))return t;if(/^(?:localhost|[a-z0-9-]+(?:\.[a-z0-9-]+)+):\d{1,5}(?:[/?#].*)?$/i.test(t))return`https://${t}`;const n=/^([a-z][a-z0-9+.-]*):/i.exec(t)?.[1]?.toLowerCase();return void 0!==n?"http"===n||"https"===n||"mailto"===n?t:"":`https://${t}`}(t??"");if(""===e)return;s=y.current?.applyFormatAction("link",e,n)??!1}}else e.op&&(s=y.current?.applyFormatAction(e.op)??!1);s&&g.track({event_key:"claudeai.brass_falcon.format_applied",...d,action:e.id})},[g,d]);(w!==n&&y.current?.getSource()===n||w!==n&&null===y.current)&&k(n);const T=e.useRef(()=>{}),O=e.useCallback(e=>{T.current(),y.current=e,v(!!e?.element),e?.element&&(T.current=e.subscribe("ck-change",()=>k(e.getSource())))},[]);return void 0===c?t.jsx(Ca,{ref:O,content:n,onSave:s,isSaving:r,ephemeral:i,autosaveSuspended:a,readUpstreamContent:l,analyticsCtx:d,className:"h-full"}):t.jsx(ca,{reviewStoreKey:c,documentRef:u,source:w,analyticsCtx:d,displayMode:"rendered",onSendToClaude:h,sendDisabled:m,selectionAdapter:N,formatActions:M,onFormatAction:L,className:"h-full",children:t.jsx(Ca,{ref:O,content:n,onSave:s,isSaving:r,ephemeral:i,autosaveSuspended:a,readUpstreamContent:l,analyticsCtx:d,overlayChildren:C})})}),Da="__cwhr_draft",$a=String.raw`
(function () {
  "use strict";
  if (window.__coworkHtmlReviewGuest) return;
  window.__coworkHtmlReviewGuest = true;

  var READY_TYPE = "__cowork_html_review_ready__";
  var SEL_CLASS = "__cwhr-sel";
  var CONTEXT_LEN = 32;
  var EXACT_CAP = 1000;
  var port = null;
  var mode = false;
  var pins = [];
  var quotes = [];
  // Resolved Range per quote id; invalidated on DOM mutation and on a
  // fresh quotes set. Scroll/resize re-reports just re-read
  // getClientRects() from the cached Range. Null prototype - ids are
  // collaborator-writable and must not collide with Object.prototype.
  var quoteRanges = Object.create(null);
  var hoverEl = null;
  var selected = null;
  var hasTextSel = false;
  var rafPending = false;
  // Capture before page body scripts can shadow them; start() defers
  // to DOMContentLoaded which page code can race.
  var _MessageChannel = window.MessageChannel;
  var _topPost = window.top.postMessage.bind(window.top);

  function visibleText(el) {
    // innerText drops display:none/visibility:hidden subtrees; keep an
    // empty innerText (icon-only el) rather than falling through to
    // textContent which would re-include hidden text.
    var t = typeof el.innerText === "string" ? el.innerText : (el.textContent || "");
    return t.replace(/\s+/g, " ").trim();
  }

  function injectStyle() {
    var style = document.createElement("style");
    // Hover box is painted by the host (from streamed rects); the guest
    // only marks the selected element. cursor:none - the host draws a
    // custom cursor (dot + comment bubble) over the iframe.
    style.textContent =
      "." + SEL_CLASS + "{outline:1px solid hsl(40 70% 40%) !important;outline-offset:0;}" +
      "body.__cwhr-mode, body.__cwhr-mode *{cursor:none !important;}";
    (document.head || document.documentElement).appendChild(style);
  }

  function isUnique(sel) {
    try {
      return document.querySelectorAll(sel).length === 1;
    } catch (e) {
      return false;
    }
  }

  // Mirrors the host's stripInvisibles ranges. The host strips these
  // from stored selectors, so a selector built on a value containing
  // them would validate here but never match again - skip those rungs
  // and fall through to the structural ladder instead.
  function hasInvisibles(s) {
    for (var i = 0; i < s.length; i++) {
      var c = s.codePointAt(i);
      if (c > 0xffff) i++;
      if (
        c <= 0x1f ||
        c === 0x061c ||
        c === 0x070f ||
        c === 0xad ||
        (c >= 0x7f && c <= 0x9f) ||
        c === 0x115f ||
        c === 0x1160 ||
        c === 0x180e ||
        (c >= 0x200b && c <= 0x200f) ||
        (c >= 0x202a && c <= 0x202e) ||
        (c >= 0x2060 && c <= 0x2064) ||
        (c >= 0x2066 && c <= 0x2069) ||
        c === 0x3164 ||
        c === 0xfeff ||
        (c >= 0xfff9 && c <= 0xfffb) ||
        c === 0xffa0 ||
        (c >= 0xe0000 && c <= 0xe007f)
      ) {
        return true;
      }
    }
    return false;
  }

  function escapeAttr(v) {
    return String(v).replace(/\\/g, "\\\\").replace(/"/g, '\\"');
  }

  // Selector ladder: unique #id -> unique [data-*] -> structural
  // tag:nth-of-type path rooted at the nearest unique-id ancestor.
  function selectorFor(el) {
    if (el.id && !hasInvisibles(el.id) && isUnique("#" + CSS.escape(el.id))) {
      return "#" + CSS.escape(el.id);
    }
    for (var i = 0; i < el.attributes.length; i++) {
      var attr = el.attributes[i];
      if (
        attr.name.indexOf("data-") === 0 &&
        attr.value &&
        !hasInvisibles(attr.value)
      ) {
        var dataSel = "[" + attr.name + '="' + escapeAttr(attr.value) + '"]';
        if (isUnique(dataSel)) return dataSel;
      }
    }
    var parts = [];
    var cur = el;
    while (cur && cur !== document.body && cur.nodeType === 1 && parts.length < 10) {
      var sel = cur.tagName.toLowerCase();
      var parent = cur.parentElement;
      if (parent) {
        var sameTag = [];
        for (var c = 0; c < parent.children.length; c++) {
          if (parent.children[c].tagName === cur.tagName) sameTag.push(parent.children[c]);
        }
        if (sameTag.length > 1) {
          sel += ":nth-of-type(" + (sameTag.indexOf(cur) + 1) + ")";
        }
      }
      parts.unshift(sel);
      if (
        parent &&
        parent.id &&
        !hasInvisibles(parent.id) &&
        isUnique("#" + CSS.escape(parent.id))
      ) {
        parts.unshift("#" + CSS.escape(parent.id));
        return parts.join(" > ");
      }
      cur = parent;
    }
    if (cur === document.body) {
      parts.unshift("body");
      return parts.join(" > ");
    }
    // Depth cap hit without a root - an unrooted chain would match the
    // first structural pattern anywhere in the document. Mark the pin
    // detached instead of attaching it to the wrong element.
    return ":not(*)";
  }

  function descriptorFor(el) {
    var tag = "<" + el.tagName.toLowerCase() + ">";
    var idPart = el.id ? " #" + el.id : "";
    var text = visibleText(el).slice(0, 60);
    var textPart = text ? ' "' + text + '"' : "";
    // Nearest id'd ancestor, skipping the UCR-injected
    // #artifacts-component-root-* wrapper which is implementation noise.
    var section = el.parentElement;
    while (
      section &&
      (!section.id || section.id.indexOf("artifacts-component-root") === 0)
    ) {
      section = section.parentElement;
    }
    var sectionPart = section && section.id ? " in #" + section.id : "";
    return (tag + idPart + textPart + sectionPart).slice(0, 400);
  }

  // textContent offset of (node, offset) within body - the coordinate
  // system text-quote anchors are stored in. -1 when the boundary
  // isn't under body (shadow root, detached).
  function textOffset(node, offset) {
    var body = document.body;
    if (!body) return -1;
    try {
      var pre = document.createRange();
      pre.selectNodeContents(body);
      pre.setEnd(node, offset);
      return pre.toString().length;
    } catch (e) {
      return -1;
    }
  }

  // Inverse: build a Range covering [start, end) in body.textContent.
  function rangeForOffsets(start, end) {
    var body = document.body;
    if (!body) return null;
    var walker = document.createTreeWalker(body, NodeFilter.SHOW_TEXT);
    var acc = 0;
    var range = document.createRange();
    var haveStart = false;
    var t;
    while ((t = walker.nextNode())) {
      var next = acc + t.length;
      if (!haveStart && start < next) {
        range.setStart(t, start - acc);
        haveStart = true;
      }
      if (haveStart && end <= next) {
        range.setEnd(t, end - acc);
        return range;
      }
      acc = next;
    }
    return null;
  }

  // Context-scored search (W3C text-quote resolution): slice-check the
  // hint, else pick the occurrence whose surrounding chars best match
  // prefix/suffix. MIRRORS locateTextQuote() above line-for-line - the
  // tested export is the contract; this copy is what the sandbox runs.
  function locateQuote(text, q) {
    var ex = q.exact;
    if (!ex) return null;
    var hint = q.startOffset >= 0 ? q.startOffset : 0;
    if (text.slice(hint, hint + ex.length) === ex) {
      return { start: hint, end: hint + ex.length };
    }
    var best = -1;
    var bestScore = -1;
    var bestDist = Infinity;
    var scanned = 0;
    for (var idx = text.indexOf(ex); idx !== -1 && ++scanned <= 1000; idx = text.indexOf(ex, idx + 1)) {
      var before = text.slice(Math.max(0, idx - CONTEXT_LEN), idx);
      var after = text.slice(idx + ex.length, idx + ex.length + CONTEXT_LEN);
      var sc = 0;
      for (var i = 1; i <= q.prefix.length && i <= before.length; i++) {
        if (q.prefix[q.prefix.length - i] !== before[before.length - i]) break;
        sc++;
      }
      for (var j = 0; j < q.suffix.length && j < after.length; j++) {
        if (q.suffix[j] !== after[j]) break;
        sc++;
      }
      var dist = Math.abs(idx - hint);
      if (sc > bestScore || (sc === bestScore && dist < bestDist)) {
        best = idx;
        bestScore = sc;
        bestDist = dist;
      }
    }
    return best === -1 ? null : { start: best, end: best + ex.length };
  }

  function collectLineRects(range, cap) {
    var out = [];
    var rects = range.getClientRects();
    for (var i = 0; i < rects.length && out.length < cap; i++) {
      var r = rects[i];
      if (r.width > 0 && r.height > 0) {
        out.push({ x: r.left, y: r.top, w: r.width, h: r.height });
      }
    }
    return out;
  }

  function reportTextSel(full) {
    if (!port) return;
    var sel = window.getSelection();
    var r = sel && !sel.isCollapsed && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;
    if (!r || !document.body || !document.body.contains(r.commonAncestorContainer)) {
      if (hasTextSel) {
        hasTextSel = false;
        port.postMessage({ type: "textClear" });
      }
      return;
    }
    hasTextSel = true;
    var br = r.getBoundingClientRect();
    var msg = {
      type: "textCapture",
      rect: { x: br.left, y: br.top, w: br.width, h: br.height },
      lineRects: collectLineRects(r, 80),
    };
    if (full) {
      var live = document.body.textContent || "";
      var so = textOffset(r.startContainer, r.startOffset);
      var eo = textOffset(r.endContainer, r.endOffset);
      if (so < 0 || eo < 0 || eo <= so) {
        // Unanchorable selection (shadow root, foreign node). A
        // rect-only post here would make the host pair the new rect
        // with a stale prior anchor - clear instead.
        hasTextSel = false;
        port.postMessage({ type: "textClear" });
        return;
      }
      // Denomination invariant: exact/prefix/suffix are byte-identical
      // slices of body.textContent. Truncation adjusts endOffset so
      // the host's (endOffset - startOffset === exact.length) shape
      // check holds. Cut points back off surrogate halves - a lone
      // surrogate would never relocate and fails UTF-8 persist.
      var capped = Math.min(eo, so + EXACT_CAP);
      if (capped < eo) {
        var hc = live.charCodeAt(capped - 1);
        if (hc >= 0xd800 && hc <= 0xdbff) capped--;
      }
      if (capped <= so) {
        port.postMessage(msg);
        return;
      }
      var pStart = Math.max(0, so - CONTEXT_LEN);
      var pc = live.charCodeAt(pStart);
      if (pc >= 0xdc00 && pc <= 0xdfff) pStart++;
      var sEnd = Math.min(live.length, capped + CONTEXT_LEN);
      if (sEnd < live.length) {
        var sc = live.charCodeAt(sEnd - 1);
        if (sc >= 0xd800 && sc <= 0xdbff) sEnd--;
      }
      msg.exact = live.slice(so, capped);
      msg.prefix = live.slice(pStart, so);
      msg.suffix = live.slice(capped, sEnd);
      msg.startOffset = so;
      msg.endOffset = capped;
    }
    port.postMessage(msg);
  }

  function clearSelection() {
    if (selected) {
      selected.classList.remove(SEL_CLASS);
      selected = null;
    }
  }

  // rAF-throttled cursor + hover-rect stream so the host can paint the
  // custom cursor and the inspector hover box while in comment mode.
  var cursorPending = false;
  var cursorX = -1;
  var cursorY = -1;
  function flushCursor() {
    cursorPending = false;
    if (!port) return;
    var hover = null;
    if (
      hoverEl &&
      hoverEl.nodeType === 1 &&
      hoverEl !== document.body &&
      hoverEl !== document.documentElement
    ) {
      var r = hoverEl.getBoundingClientRect();
      if (r.width > 0 || r.height > 0) {
        hover = { x: r.left, y: r.top, w: r.width, h: r.height };
      }
    }
    port.postMessage({ type: "cursor", x: cursorX, y: cursorY, hover: hover });
  }
  function scheduleCursor() {
    if (!cursorPending) {
      cursorPending = true;
      requestAnimationFrame(flushCursor);
    }
  }
  function onMouseMove(ev) {
    if (!mode || !port) return;
    // Over the scrollbar gutter (clientX/Y past the content box) the OS
    // cursor shows - hide the custom cursor/hover box like a leave.
    var de = document.documentElement;
    if (ev.clientX >= de.clientWidth || ev.clientY >= de.clientHeight) {
      cursorX = -1;
      cursorY = -1;
      hoverEl = null;
      scheduleCursor();
      return;
    }
    cursorX = ev.clientX;
    cursorY = ev.clientY;
    hoverEl = ev.target;
    scheduleCursor();
  }
  function onMouseLeave() {
    if (!mode || !port) return;
    cursorX = -1;
    cursorY = -1;
    hoverEl = null;
    scheduleCursor();
  }

  function onClick(ev) {
    if (!port) return;
    if (!mode) {
      // Mode off: don't intercept the page, just let the host close any
      // open popover (thread card click-away). A non-collapsed selection
      // means the click ended a drag-select - not a click-away.
      var s = window.getSelection();
      if (!s || s.isCollapsed) port.postMessage({ type: "clickAway" });
      return;
    }
    ev.preventDefault();
    ev.stopImmediatePropagation();
    var el = ev.target;
    if (!el || el.nodeType !== 1 || el === document.documentElement) return;
    if (el === document.body && el.firstElementChild) {
      // Pin on body is rarely intentional; keep it anyway but as body.
    }
    clearSelection();
    selected = el;
    el.classList.add(SEL_CLASS);
    var rect = el.getBoundingClientRect();
    var pinX = rect.width > 0 ? (ev.clientX - rect.left) / rect.width : 0.5;
    var pinY = rect.height > 0 ? (ev.clientY - rect.top) / rect.height : 0.5;
    port.postMessage({
      type: "capture",
      selector: selectorFor(el).slice(0, 1000),
      textHint: visibleText(el).slice(0, 300),
      descriptor: descriptorFor(el),
      pinX: Math.min(1, Math.max(0, pinX)),
      pinY: Math.min(1, Math.max(0, pinY)),
      clientX: ev.clientX,
      clientY: ev.clientY,
      rectLeft: rect.left,
      rectTop: rect.top,
    });
  }

  function reportRects() {
    rafPending = false;
    if (!port) return;
    // Selected element's live bounds - keeps the host's draft pin /
    // inspector tag / composer glued through scroll and reflow.
    if (selected) {
      var sr = selected.getBoundingClientRect();
      port.postMessage({
        type: "selRect",
        left: sr.left,
        top: sr.top,
        w: sr.width,
        h: sr.height,
        found:
          (sr.width > 0 || sr.height > 0) &&
          document.documentElement.contains(selected),
      });
    }
    var rects = [];
    for (var i = 0; i < pins.length; i++) {
      var p = pins[i];
      var el = null;
      try {
        el = document.querySelector(p.selector);
      } catch (e) {
        el = null;
      }
      if (!el) {
        rects.push({ id: p.id, x: 0, y: 0, found: false });
        continue;
      }
      var r = el.getBoundingClientRect();
      if (r.width === 0 && r.height === 0) {
        rects.push({ id: p.id, x: 0, y: 0, found: false });
        continue;
      }
      rects.push({
        id: p.id,
        x: r.left + p.pinX * r.width,
        y: r.top + p.pinY * r.height,
        found: true,
      });
    }
    var quoteRects = [];
    if (quotes.length > 0) {
      var live = null;
      for (var qi = 0; qi < quotes.length; qi++) {
        var q = quotes[qi];
        var qr = quoteRanges[q.id];
        if (qr === undefined) {
          if (live === null) {
            live = (document.body && document.body.textContent) || "";
          }
          var loc = locateQuote(live, q);
          qr = (loc && rangeForOffsets(loc.start, loc.end)) || null;
          quoteRanges[q.id] = qr;
        }
        // Zero paintable rects (display:none subtree) reports as
        // not-found so the host docks it as detached instead of
        // rendering nothing clickable.
        var qlr = qr ? collectLineRects(qr, 80) : [];
        quoteRects.push(
          qlr.length > 0
            ? { id: q.id, found: true, lineRects: qlr }
            : { id: q.id, found: false, lineRects: [] }
        );
      }
    }
    port.postMessage({
      type: "rects",
      rects: rects,
      quoteRects: quoteRects,
      scrollY: window.scrollY || 0,
    });
  }

  function scheduleRects() {
    if (rafPending) return;
    rafPending = true;
    var done = false;
    function run() {
      if (done) return;
      done = true;
      reportRects();
    }
    // rAF for paint alignment, with a timeout fallback - rAF is
    // suspended entirely in hidden tabs and pins must still settle
    // when the tab becomes visible after background loading.
    requestAnimationFrame(run);
    setTimeout(run, 150);
  }

  function setMode(on) {
    mode = !!on;
    if (document.body) {
      document.body.classList.toggle("__cwhr-mode", mode);
    }
    if (!mode) {
      hoverEl = null;
      clearSelection();
    }
  }

  function onPortMessage(ev) {
    var data = ev.data;
    if (!data) return;
    if (data.type === "mode") setMode(data.on);
    else if (data.type === "pins") {
      pins = Array.isArray(data.pins) ? data.pins : [];
      scheduleRects();
    } else if (data.type === "quotes") {
      quotes = Array.isArray(data.quotes) ? data.quotes : [];
      quoteRanges = Object.create(null);
      scheduleRects();
    } else if (data.type === "clearSelection") {
      clearSelection();
    } else if (data.type === "clearTextSel") {
      var ts = window.getSelection();
      if (ts) ts.removeAllRanges();
      hasTextSel = false;
    } else if (data.type === "restoreScroll") {
      var ry = Number(data.y);
      if (isFinite(ry) && ry > 0) {
        // Apply now and again at load - late images/fonts can grow the
        // document after the first attempt clamps short.
        window.scrollTo(0, ry);
        window.addEventListener("load", function () {
          window.scrollTo(0, ry);
        });
      }
    }
  }

  function start() {
    injectStyle();
    var channel = new _MessageChannel();
    port = channel.port1;
    port.onmessage = onPortMessage;
    // Sandboxed srcdoc origins can be opaque; "*" is required. The
    // payload carries only the mount token (multiple sandboxes can be
    // mounted at once - the token routes the port to the right overlay)
    // and the channel port itself is pairwise-secure.
    _topPost(
      { type: READY_TYPE, token: "__CWHR_TOKEN__" },
      "*",
      [channel.port2]
    );
    document.addEventListener("mousemove", onMouseMove, true);
    // documentElement (not document, capture) so this fires only when the
    // pointer leaves the viewport - capture-phase on document would fire for
    // every intra-document element-boundary crossing.
    document.documentElement.addEventListener("mouseleave", onMouseLeave);
    document.addEventListener("click", onClick, true);
    // Text-selection capture: commit on mouseup/keyup (Shift+Arrow),
    // clear on collapse. Not mode-gated; highlight-to-comment is
    // always on.
    function onSelCommit() { reportTextSel(true); }
    document.addEventListener("mouseup", onSelCommit, true);
    document.addEventListener("keyup", onSelCommit, true);
    document.addEventListener("selectionchange", function () {
      var s = window.getSelection();
      if (hasTextSel && (!s || s.isCollapsed)) reportTextSel(false);
    });
    document.addEventListener("keydown", function (ev) {
      if (ev.key === "Escape" && port) port.postMessage({ type: "dismiss" });
    }, true);
    // Scroll/resize move the hovered element under a stationary pointer -
    // re-report its rect so the host's inspector box tracks it. Mutations
    // stay rects-only (animating pages would chatter the cursor stream).
    var textSelPending = false;
    function scheduleTextSel() {
      if (textSelPending) return;
      textSelPending = true;
      requestAnimationFrame(function () {
        textSelPending = false;
        reportTextSel(false);
      });
    }
    function onLayoutChange() {
      scheduleRects();
      if (mode && hoverEl) scheduleCursor();
      if (hasTextSel) scheduleTextSel();
    }
    window.addEventListener("scroll", onLayoutChange, true);
    window.addEventListener("resize", onLayoutChange);
    // Full-cache invalidate per childList mutation is acceptable: CSS
    // animation doesn't fire the observer; JS writers at frame rate
    // would re-relocate every frame but are rare. characterData isn't
    // observed, so .data= edits leave highlights stale until the next
    // childList mutation.
    var observer = new MutationObserver(function () {
      quoteRanges = Object.create(null);
      scheduleRects();
      if (hasTextSel) scheduleTextSel();
    });
    function observe() {
      if (document.body) observer.observe(document.body, { childList: true, subtree: true });
    }
    if (document.body) observe();
    else document.addEventListener("DOMContentLoaded", observe);
    // Settle pins after late layout (fonts, images).
    setInterval(scheduleRects, 2000);
  }

  if (document.readyState === "loading") {
    document.addEventListener("DOMContentLoaded", start);
  } else {
    start();
  }
})();
`;function Fa(e,t){const n=t.replace(/[^a-zA-Z0-9-]/g,""),s=`<script>${$a.replace("__CWHR_TOKEN__",n)}<\/script>`,r=e=>" ".repeat(e.length),o=e.replace(/<!--[\s\S]*?-->/g,r).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,r).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,r).replace(/<(?:script|style)\b[^>]*>[\s\S]*$/i,r),i=/<head(?:\s[^>]*)?>/i.exec(o);if(i){const t=i.index+i[0].length;return e.slice(0,t)+s+e.slice(t)}const a=/<html(?:\s[^>]*)?>/i.exec(o);if(a){const t=a.index+a[0].length;return e.slice(0,t)+s+e.slice(t)}const l=/^\s*<!doctype[^>]*>/i.exec(o);if(l){const t=l.index+l[0].length;return e.slice(0,t)+s+e.slice(t)}return s+e}const Pa=24,qa="#D97757",Ba="rgba(0,0,0,0.12)",Ka="0 1px 3px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.08)",za="0 0 0 0.5px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.06), 0 16px 40px rgba(0,0,0,0.08)",Ha={initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1},transition:{duration:.16,ease:[.2,.7,.3,1]}};function Ua(e){const t=Wa(e.x+6,6,Math.max(6,e.boundsW-256-6)),n=e.y+6;return{left:t,top:n+56<=e.boundsH-6?n:Wa(e.y-Pa-6-56,6,Math.max(6,e.boundsH-56-6))}}function Wa(e,t,n){return Math.min(n,Math.max(t,e))}function Ya(e,t){const n=Number(e?.x)||0,s=Number(e?.y)||0,r=Wa(n,0,t.w),o=Wa(s,0,t.h),i=Wa(n+(Number(e?.w)||0),0,t.w),a=Wa(s+(Number(e?.h)||0),0,t.h);return i>r&&a>o?{x:r,y:o,w:i-r,h:a-o}:null}function Xa(e,t){if(!Array.isArray(e))return[];const n=[];for(const s of e.slice(0,80)){const e=Ya(s,t);e&&n.push(e)}return n}function Va(e){const t=(new DOMParser).parseFromString(e,"text/html");for(const r of t.querySelectorAll("script, style, noscript"))r.remove();const n=t.createTreeWalker(t.body??t,NodeFilter.SHOW_TEXT);let s="";for(;n.nextNode();)s+=(n.currentNode.textContent??"")+" ";return te(s,2e6)}const Ja=String.raw`#(?:[-\w\u0080-\uFFFF]|\\[0-9a-fA-F]{1,6} |\\[^0-9a-fA-F])+`,Ga=String.raw`\[data-[a-zA-Z0-9_.:-]+="(?:[^"\\]|\\.)*"\]`,Qa=String.raw`[a-z][a-z0-9-]*(?::nth-of-type\(\d+\))?`,Za=new RegExp(`^(?:${Ja}|${Ga}|:not\\(\\*\\)|(?:(?:${Ja}|body) > )?${Qa}(?: > ${Qa})*)$`),el=/"(?:[^"\\]|\\.){81,}"/,tl=/"[^"]*\s[^"]*"/,nl=new RegExp(String.raw`#(?:[-\w\u0080-\uFFFF]|\\[0-9a-fA-F]{1,6} |\\[^0-9a-fA-F]){65,}`),sl=/(?:^|> )[a-z][a-z0-9-]{32,}/,rl=/\[data-[a-zA-Z0-9_.:-]{33,}=/,ol=new RegExp(String.raw`^#(?:[-\w\u0080-\uFFFF]|\\[0-9a-fA-F]{1,6} |\\[^0-9a-fA-F]){33,} > `);const il=/^<([a-z][\w-]{0,31})>(?: #([^\s"]{1,64}))?(?: "([^"]{0,60})")?(?: in #(\S{1,64}))?$/,al=/^artifacts-component-root/,ll=e.memo(function({descriptor:e}){const n=il.exec(e);if(!n)return t.jsx("div",{className:"truncate text-xs text-text-400",children:e});const[,s,r,o,a]=n,l=a&&!al.test(a)?a:void 0,c=t.jsx("span",{className:"inline-flex shrink-0 items-center rounded border border-border-300 bg-bg-100 px-1 font-mono text-[11px] text-text-200",children:s});return t.jsxs("div",{className:"flex min-w-0 select-none items-center gap-1.5 text-xs text-text-400",children:[o?t.jsx(ze,{multiline:!0,content:t.jsx("span",{className:"line-clamp-3 break-words",children:`\u201c${o}\u201d`}),children:c}):c,r&&t.jsx("span",{className:"shrink-0 font-mono text-accent-pro-100",children:`#${r}`}),l&&t.jsx("span",{className:"shrink-0 truncate",children:t.jsx(i,{defaultMessage:"in <s>#{section}</s>",id:"6XJT5DKRek",values:{section:l,s:e=>t.jsx("span",{className:"font-mono text-text-300",children:e})}})})]})}),cl=e.memo(function({descriptor:e,x:n,y:s}){const r=il.exec(e),o=r?.[1]??e.slice(0,24),i=r?.[2],a=s<16;return t.jsxs("div",{className:"pointer-events-none absolute z-20 max-w-[16rem] truncate px-1 py-px font-mono text-[10px] leading-[14px]",style:{left:n-1,top:a?s:s-16,backgroundColor:qa,color:"#fff"},children:[o,i&&t.jsx("span",{style:{opacity:.8},children:` #${i}`})]})}),ul=e.memo(function({onFrame:e}){return st(e),null}),dl=e.memo(function({n:n,active:s,swingIn:r=!1}){const o=et()??!1,i=tt(o||!s&&!r?s?-90:0:-90,{stiffness:300,damping:22});e.useEffect(()=>{o?i.jump(s?-90:0):i.set(s?-90:0)},[s,i,o]);const a=nt(i,e=>-e);return t.jsx(Ge.div,{className:"flex size-6 items-center justify-center rounded-full rounded-bl-[2px]",style:{rotate:i,transformOrigin:"1px 23px",backgroundColor:s?qa:"#fff",boxShadow:`0 0 0 1px ${s?"#C6613F":Ba}, ${Ka}`},children:void 0!==n&&t.jsx(Ge.span,{className:"text-[11px] font-semibold leading-none",style:{rotate:a,color:s?"#fff":"#141413"},children:n})})});function fl(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const s=e[n],r=t[n];if(s.x!==r.x||s.y!==r.y||s.w!==r.w||s.h!==r.h)return!1}return!0}const hl=[],ml=e.memo(function({active:n,token:s,documentRef:r,commentProps:a,uiHidden:l=!1,commentMode:c,onCommentModeChange:u,pageTextIndex:d,className:f="relative h-full w-full",children:h}){const m=o(),{userContentRendererUrl:p}=ie(),g=kt("(hover: hover) and (pointer: fine)")??!0,x=et()??!1,y=e.useRef(!1);e.useEffect(()=>{y.current=x},[x]);const b=e.useRef(null),w=Ze(0),k=Ze(0),[S,C]=e.useState(!1),[N,E]=e.useState(null),[j,M]=e.useState(null),L=Ze(0),T=Ze(0),O=Ze(0),A=tt(0,{stiffness:380,damping:26}),R=Ze(0),I=tt(R,{stiffness:70,damping:19}),_=Ze(0),D=Ze(0),$=nt([A,I],([e,t])=>1-e*(1-Wa(t/5,0,1))),F=void 0!==u,[P,q]=e.useState(!1),B=F?c??!1:P,W=e.useCallback(e=>{u?u(e):q(e)},[u]),Y=e.useRef(!1);e.useEffect(()=>{Y.current=B},[B]),e.useEffect(()=>{ne.current=W},[W]);const X=e.useRef(!1),V=e.useRef(null);e.useEffect(()=>{const e=b.current;if(!e)return;const t=new ResizeObserver(([e])=>{V.current={w:e.contentRect.width,h:e.contentRect.height}});return t.observe(e),()=>t.disconnect()},[]);const[J,G]=e.useState(null),Q=e.useRef(null);e.useEffect(()=>{Q.current=J},[J]);const Z=e.useRef(0),ee=e.useRef(void 0);e.useEffect(()=>{ee.current=d},[d]);const ne=e.useRef(null),[se,re]=e.useState(null),[oe,ue]=e.useState(null),[de,fe]=e.useState(null),[he,me]=e.useState(null),pe=e.useRef(!1),ge=e.useRef(null);e.useEffect(()=>{pe.current=null!==he,ge.current=he?.kind??null},[he]);const[xe,ye]=e.useState(""),[be,ve]=e.useState(!1),[we,ke]=e.useState(null),[Se,Ce]=e.useState(null),Ne=e.useRef(0),Ee=e.useRef(!1);e.useEffect(()=>{Ee.current=null!==we},[we]);const je=e.useMemo(()=>K(r),[r]),Me="file"===r.kind,Le=e.useRef(Me);e.useEffect(()=>{Le.current=Me},[Me]);const Te=a?.comments??hl,Oe=e.useMemo(()=>Te.filter(e=>H(e)&&"open"===(e.status??"open")&&"element"===e.target.anchor.kind&&K(e.target.document)===je),[Te,je]),Ae=e.useMemo(()=>z(Te),[Te]),Re=e.useMemo(()=>Oe.map(e=>{const t=e.target.anchor;return{id:e.id,selector:t.selector,pinX:t.pinX,pinY:t.pinY}}),[Oe]),Ie=e.useRef(new Set);e.useEffect(()=>{Ie.current=new Set(Re.map(e=>e.id))},[Re]);const _e=e.useMemo(()=>Te.filter(e=>H(e)&&"open"===(e.status??"open")&&"text-quote"===e.target.anchor.kind&&e.id!==Da&&K(e.target.document)===je).slice(0,200),[Te,je]),De=e.useMemo(()=>_e.map(e=>{const t=e.target.anchor;return{id:e.id,exact:ae(t.exact.slice(0,1e3)),prefix:ae(t.prefix.slice(-32)),suffix:ae(t.suffix.slice(0,32)),startOffset:Math.max(0,Math.trunc(Number(t.startOffset))||0)}}),[_e]),$e="text"===he?.kind?he.anchor:null,Fe=e.useMemo(()=>$e?[...De,{id:Da,exact:$e.exact,prefix:$e.prefix,suffix:$e.suffix,startOffset:$e.startOffset}]:De,[De,$e]),Pe=e.useRef(new Set);e.useEffect(()=>{Pe.current=new Set(Fe.map(e=>e.id))},[Fe]);const qe=e.useMemo(()=>[...Oe,..._e],[Oe,_e]),Be=e.useCallback(e=>{const t=e;var n,s;if(t&&"object"==typeof t)if("capture"===t.type){if(!Y.current)return;if(pe.current||Ee.current)return Q.current?.postMessage({type:"clearSelection"}),me(e=>"element"===e?.kind?null:e),void ke(null);const e=V.current?.w??600,r=V.current?.h??400;let o=O.get();o-=360*Math.round((o- -90)/360);const i=(n=t.selector,s=1e3,"string"==typeof n?ce(n).slice(0,s):"");if(!Za.test(i))return void Q.current?.postMessage({type:"clearSelection"});const a=te(t.textHint,300),l=te(t.descriptor,400);me({kind:"element",captureId:++Ne.current,x:Wa(Number(t.clientX)||0,0,e),y:Wa(Number(t.clientY)||0,0,r),boundsW:e,boundsH:r,labelX:Wa(Number(t.rectLeft)||0,0,e),labelY:Wa(Number(t.rectTop)||0,0,r),fromRotate:o,anchor:{selector:i,textHint:a,descriptor:l,pinX:Wa(Number(t.pinX)||0,0,1),pinY:Wa(Number(t.pinY)||0,0,1)}}),ye("");const c=""!==a&&(void 0!==ee.current?!ee.current.includes(a):a.length>60),u=il.exec(l)?.[3]??"",d=""!==u&&!a.startsWith(u);ve(c||d||function(e){return el.test(e)||tl.test(e)||nl.test(e)||sl.test(e)||rl.test(e)||ol.test(e)}(i)||""!==l&&!il.test(l)),ke(null),E(null),M(null)}else if("rects"===t.type){if(!Array.isArray(t.rects))return;const e=Number(t.scrollY);if(Number.isFinite(e)&&e>=0&&(Z.current=e),re(e=>{const n=Ie.current,s=Math.max(2*n.size,16),r=t.rects.length>s?t.rects.slice(0,s):t.rects,o=new Map;for(const t of r)"string"==typeof t?.id&&n.has(t.id)&&o.set(t.id,{id:t.id,x:Number(t.x)||0,y:Number(t.y)||0,found:!0===t.found});return function(e,t){if(!e||e.size!==t.size)return!1;for(const[n,s]of t){const t=e.get(n);if(!t||t.x!==s.x||t.y!==s.y||t.found!==s.found)return!1}return!0}(e,o)?e:o}),Array.isArray(t.quoteRects)){const e=Pe.current,n=V.current??{w:600,h:400},s=t.quoteRects.slice(0,Math.max(2*e.size,16));ue(t=>{const r=new Map;for(const o of s)"string"==typeof o?.id&&e.has(o.id)&&r.set(o.id,{id:o.id,found:!0===o.found,lineRects:Xa(o.lineRects,n)});return t&&function(e,t){if(e.size!==t.size)return!1;for(const[n,s]of t){const t=e.get(n);if(!t||t.found!==s.found||!fl(t.lineRects,s.lineRects))return!1}return!0}(t,r)?t:r})}}else if("dismiss"===t.type){if(Ee.current&&ke(null),!Y.current)return;pe.current&&"element"===ge.current?(Q.current?.postMessage({type:"clearSelection"}),me(null)):Ee.current||ne.current?.(!1)}else if("clickAway"===t.type)ke(null);else if("selRect"===t.type){if(!pe.current||!0!==t.found)return;const e=Number(t.left),n=Number(t.top),s=Number(t.w),r=Number(t.h);if(!(Number.isFinite(e)&&Number.isFinite(n)&&Number.isFinite(s)&&Number.isFinite(r)))return;const o=V.current??{w:600,h:400};me(t=>{if("element"!==t?.kind)return t;const i=Wa(e+t.anchor.pinX*s,0,o.w),a=Wa(n+t.anchor.pinY*r,0,o.h);return i===t.x&&a===t.y?t:{...t,x:i,y:a,labelX:Wa(e,0,o.w),labelY:Wa(n,0,o.h)}})}else if("cursor"===t.type){if(!Y.current)return;const e=Number(t.x),n=Number(t.y);if(!Number.isFinite(e)||!Number.isFinite(n))return;const s=V.current??{w:600,h:400};if(e<0||n<0||e>s.w||n>s.h)return X.current=!1,C(!1),void E(null);X.current?(w.set(e),k.set(n)):(X.current=!0,w.jump(e),k.jump(n),L.jump(e),T.jump(n),R.jump(0)),C(!0);const r=t.hover;E(e=>{if(!r||"object"!=typeof r)return null===e?e:null;const t={x:Wa(Number(r.x)||0,0,s.w),y:Wa(Number(r.y)||0,0,s.h),w:Wa(Number(r.w)||0,0,s.w),h:Wa(Number(r.h)||0,0,s.h)};return e&&e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h?e:t})}else if("textCapture"===t.type){if(!Le.current)return;const e=V.current??{w:600,h:400},n=Ya(t.rect,e)??{x:0,y:0,w:0,h:0},s=Xa(t.lineRects,e);let r=null;if("string"==typeof t.exact){const e=ae(t.exact.slice(0,1e3)),n=Math.max(0,Math.trunc(Number(t.startOffset))||0),s=Math.max(0,Math.trunc(Number(t.endOffset))||0);e.length>0&&s-n===e.length&&(r={exact:e,prefix:ae("string"==typeof t.prefix?t.prefix.slice(-32):""),suffix:ae("string"==typeof t.suffix?t.suffix.slice(0,32):""),startOffset:n,endOffset:s})}fe(e=>{const t=r??e?.anchor??null;return t?e&&e.anchor.exact===t.exact&&e.anchor.prefix===t.prefix&&e.anchor.suffix===t.suffix&&e.anchor.startOffset===t.startOffset&&e.anchor.endOffset===t.endOffset&&e.rect.x===n.x&&e.rect.y===n.y&&e.rect.w===n.w&&e.rect.h===n.h&&fl(e.lineRects,s)?e:{rect:n,lineRects:s,anchor:t}:e})}else"textClear"===t.type&&fe(null)},[w,k,L,T,O,R]),Ke=e.useRef(Be);e.useEffect(()=>{Ke.current=Be},[Be]),e.useEffect(()=>{if(!s)return;let e=null;try{e=new URL(p).origin}catch{return}const t=t=>{if(t.origin!==e)return;const n=t.data;if(!n||"__cowork_html_review_ready__"!==n.type||n.token!==s)return;const r=t.ports[0];r&&(r.onmessage=e=>Ke.current(e.data),G(r),re(null),ue(null),fe(null))};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[s,p]),e.useEffect(()=>()=>J?.close(),[J]),e.useEffect(()=>{J?.postMessage({type:"mode",on:B})},[J,B]),e.useEffect(()=>{J?.postMessage({type:"pins",pins:Re})},[J,Re]),e.useEffect(()=>{J?.postMessage({type:"quotes",quotes:Fe})},[J,Fe]),e.useEffect(()=>{J&&Z.current>0&&J.postMessage({type:"restoreScroll",y:Z.current})},[J]),e.useEffect(()=>{null===he&&J?.postMessage({type:"clearSelection"})},[J,he]);const Ue=e.useCallback((e,t)=>{const n=w.get(),s=k.get();if(y.current)return L.set(n),T.set(s),void R.jump(0);const r=Math.min(t||16.7,50),o=1-Math.exp(-r/90),i=1-Math.exp(-r/50),a=L.get(),l=T.get();L.set(a+(n-a)*o),T.set(l+(s-l)*o);const c=n-L.get(),u=s-T.get(),d=Math.hypot(c,u);if(d>2){let e=Math.atan2(-u,-c)*(180/Math.PI)- -45;const t=O.get();e+=360*Math.round((t-e)/360),O.set(t+(e-t)*i)}R.set(d)},[w,k,L,T,O,R]),We=B&&S&&!he&&!we;e.useEffect(()=>{A.set(We?1:0)},[We,A]);const Ye=e.useCallback(()=>{W(!B)},[B,W]),Xe=e.useCallback(e=>{const t=b.current?.getBoundingClientRect();t&&(_.set(Wa(e.clientX-t.left+12,6,Math.max(6,t.width-224-6))),D.set(Wa(e.clientY-t.top+14,6,Math.max(6,t.height-80))))},[_,D]),Ve=e.useCallback(e=>{ke(t=>t===e?null:e),me(e=>"text"===e?.kind?e:null),M(null)},[]),Qe=e.useCallback(()=>{if(!de?.anchor)return;const e=V.current??{w:600,h:400};me({kind:"text",captureId:++Ne.current,boundsW:e.w,boundsH:e.h,anchor:de.anchor,fallbackX:Wa(de.rect.x+de.rect.w/2,0,e.w),fallbackY:de.rect.y}),ye(""),ve(de.anchor.exact.length>60||""===te(de.anchor.exact,300)),ke(null),fe(null),Q.current?.postMessage({type:"clearTextSel"})},[de]),st=null!==he;e.useEffect(()=>{if(!B&&!st&&!we)return;const e=e=>{"Escape"!==e.key||e.defaultPrevented||e.isComposing||(e.preventDefault(),st||we?(me(null),ke(null)):W(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[B,st,we,W]);const rt=e.useCallback(e=>{"Escape"!==e.key||e.nativeEvent.isComposing||(Y.current||pe.current||Ee.current)&&(e.preventDefault(),e.stopPropagation(),pe.current||Ee.current?(Q.current?.postMessage({type:"clearSelection"}),me(null),ke(null)):ne.current?.(!1))},[]);e.useEffect(()=>{me(e=>"text"===e?.kind?e:null),ke(null),!B&&Le.current&&(fe(null),Q.current?.postMessage({type:"clearTextSel"})),B||(X.current=!1,C(!1),E(null),M(null),A.jump(0),R.jump(0))},[B,A,R]),e.useEffect(()=>{M(e=>!e||Oe.some(t=>t.id===e)||_e.some(t=>t.id===e)?e:null)},[Oe,_e]),e.useEffect(()=>{Ce(e=>e&&Oe.some(t=>!e.knownIds.has(t.id)&&se?.has(t.id))?null:e)},[Oe,se]),e.useEffect(()=>{if(!Se)return;const e=Se.captureId,t=setTimeout(()=>{Ce(t=>t?.captureId===e?null:t)},2500);return()=>clearTimeout(t)},[Se]);const ot=e.useCallback(()=>{he&&xe.trim()&&a&&("element"===he.kind?(a.onCommentSubmit(le(r,he.anchor),xe.trim(),{displayMode:"rendered",forceNew:!0}),Ce({captureId:he.captureId,x:he.x,y:he.y,knownIds:new Set(Oe.map(e=>e.id))})):a.onCommentSubmit(U(r,he.anchor),xe.trim(),{displayMode:"rendered",forceNew:!0}),me(null),ye(""))},[he,xe,a,r,Oe]);e.useEffect(()=>{!l&&n||(W(!1),me(null),ke(null),Ce(null),fe(null))},[l,n,W]),e.useEffect(()=>{me(null),ye(""),ke(null),Ce(null),fe(null),ue(null)},[je]);if(!(n&&!!a&&!l))return t.jsx("div",{ref:b,className:n?f:"contents",children:h});const it=we?qe.find(e=>e.id===we):void 0,at=we?se?.get(we):void 0,lt=we?oe?.get(we):void 0,ct=lt?.found?lt.lineRects[0]:void 0,ut=j&&j!==we&&!he?qe.find(e=>e.id===j):void 0,dt=qe.filter(e=>{const t=se?.get(e.id)??oe?.get(e.id);return void 0!==t&&!t.found}),ft=V.current?.w??600,ht=V.current?.h??400,mt=oe?.get(Da),pt="text"===he?.kind?mt?.found&&mt.lineRects[0]?{x:Wa(mt.lineRects[0].x,0,ft),y:Wa(mt.lineRects[0].y+mt.lineRects[0].h,0,ht)}:{x:he.fallbackX,y:he.fallbackY}:null,gt=!B&&null!==de&&de.rect.w>0&&de.rect.h>0&&null===he&&null===we,xt="element"===he?.kind?{x:he.x,y:he.y}:pt,yt="element"===he?.kind?he.anchor.textHint:he?te(he.anchor.exact,300):"",bt="text"===he?.kind?te(`\u2026${he.anchor.prefix}\xab${he.anchor.exact}\xbb${he.anchor.suffix}\u2026`,1100):"";return t.jsxs("div",{ref:b,role:"presentation",className:f,onKeyDown:rt,children:[h,B&&t.jsx(ul,{onFrame:Ue}),t.jsx("div",{className:v("absolute top-2 right-2 z-20",F&&"hidden"),children:t.jsx("button",{type:"button","aria-pressed":B,onClick:Ye,className:v("rounded-md border px-3 py-1.5 text-sm font-medium shadow-md",B?"border-accent-pro-200 bg-accent-pro-100 text-oncolor-100":"border-border-300 bg-bg-000 text-text-100 hover:bg-bg-100"),children:B?t.jsx(i,{defaultMessage:"Done commenting",id:"cXIcxYfeiJ"}):t.jsx(i,{defaultMessage:"Comment",id:"LgbKvU/n17"})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 overflow-hidden",children:[We&&N&&t.jsx("div",{className:"pointer-events-none absolute",style:{left:N.x,top:N.y,width:N.w,height:N.h,border:`2px solid ${qa}`}}),_e.map((e,n)=>{const s=oe?.get(e.id);if(!s?.found||0===s.lineRects.length)return null;const r=s.lineRects[0];return t.jsxs("div",{className:"contents",children:[s.lineRects.map((e,n)=>t.jsx("div",{className:"pointer-events-none absolute",style:{left:e.x,top:e.y,width:e.w,height:e.h,backgroundColor:"rgba(253, 186, 116, 0.35)"}},n)),t.jsx("button",{type:"button",className:"pointer-events-auto absolute bg-transparent",style:{left:Wa(r.x-1,0,Math.max(0,ft-Pa)),top:Wa(r.y-23,0,Math.max(0,ht-Pa))},onClick:()=>Ve(e.id),onMouseEnter:t=>{Xe(t),M(e.id)},onMouseMove:Xe,onMouseLeave:()=>M(t=>t===e.id?null:t),"aria-label":m.formatMessage({defaultMessage:"Comment {number} on selected text",id:"c2nYJ59GyU"},{number:Oe.length+n+1}),children:t.jsx(dl,{n:Oe.length+n+1,active:we===e.id})})]},e.id)}),"text"===he?.kind&&mt?.found&&mt.lineRects.map((e,n)=>t.jsx("div",{className:"pointer-events-none absolute",style:{left:e.x,top:e.y,width:e.w,height:e.h,backgroundColor:"rgba(253, 186, 116, 0.55)"}},`draft-${n}`)),Oe.map((e,n)=>{const s=se?.get(e.id);return s&&s.found?t.jsx("button",{type:"button",className:"pointer-events-auto absolute bg-transparent",style:{left:Wa(s.x-1,0,Math.max(0,ft-Pa)),top:Wa(s.y-23,0,Math.max(0,ht-Pa))},onClick:()=>Ve(e.id),onMouseEnter:t=>{Xe(t),M(e.id)},onMouseMove:Xe,onMouseLeave:()=>M(t=>t===e.id?null:t),"aria-label":m.formatMessage({defaultMessage:"Comment {number}",id:"BV8rl3I9dc"},{number:n+1}),children:t.jsx(dl,{n:n+1,active:we===e.id,swingIn:null!==Se&&!Se.knownIds.has(e.id)})},e.id):null}),dt.length>0&&t.jsx("div",{className:"pointer-events-auto absolute bottom-2 left-2 flex max-h-40 flex-col gap-1 overflow-y-auto",children:dt.map(e=>t.jsx("button",{type:"button",className:"flex items-center gap-1.5 rounded-full border border-dashed border-border-300 bg-bg-000 px-2 py-0.5 text-xs text-text-300 hover:bg-bg-100",onClick:()=>Ve(e.id),children:t.jsx(i,{defaultMessage:"Detached comment",id:"//Wx7/3+2u"})},e.id))})]}),"element"===he?.kind&&he.anchor.descriptor&&t.jsx(cl,{descriptor:he.anchor.descriptor,x:he.labelX,y:he.labelY}),B&&S&&g&&t.jsxs(t.Fragment,{children:[t.jsx(Ge.div,{"aria-hidden":!0,className:"pointer-events-none absolute left-0 top-0 z-40 size-2 rounded-full bg-white",style:{x:w,y:k,scale:$,marginLeft:-4,marginTop:-4,boxShadow:"0 0 0 1px rgba(0,0,0,0.2)"}}),t.jsx(Ge.div,{"aria-hidden":!0,className:"pointer-events-none absolute left-0 top-0 z-40 size-6 rounded-full rounded-bl-[2px]",style:{x:L,y:T,rotate:O,scale:A,opacity:A,marginLeft:-1,marginTop:-23,transformOrigin:"1px 23px",backgroundColor:"#fff",boxShadow:`0 0 0 1px ${Ba}, ${Ka}`}})]}),t.jsx(Je,{children:gt&&de&&t.jsx(Ge.button,{type:"button",initial:{opacity:0,y:8,scale:.9},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.9,transition:{duration:.1}},transition:{duration:.18,ease:[.17,.84,.44,1]},className:"absolute z-30 flex size-7 items-center justify-center rounded-full rounded-bl-[2px]",style:{left:Wa(de.rect.x+de.rect.w/2-14,4,Math.max(4,ft-32)),top:Wa(de.rect.y-34,4,Math.max(4,ht-32)),backgroundColor:"#fff",boxShadow:`0 0 0 1px ${Ba}, ${Ka}`,transformOrigin:"1px 27px"},onClick:Qe,"aria-label":m.formatMessage({defaultMessage:"Comment on selection",id:"FOrqFcMnhI"}),children:t.jsx(He,{name:"ChatAdd",size:"sm"})})}),t.jsx(Je,{children:(("element"===he?.kind?he:null)??Se)&&t.jsx(Ge.div,{"aria-hidden":!0,className:"pointer-events-none absolute z-20 size-6 rounded-full rounded-bl-[2px]",initial:{rotate:"element"===he?.kind?he.fromRotate:-90,opacity:1},animate:{rotate:-90},exit:Se?{opacity:0,transition:{duration:.05}}:{opacity:0,scale:.6},transition:{type:"spring",stiffness:260,damping:16},style:{left:Wa((("element"===he?.kind?he.x:void 0)??Se?.x??0)-1,0,Math.max(0,ft-Pa)),top:Wa((("element"===he?.kind?he.y:void 0)??Se?.y??0)-23,0,Math.max(0,ht-Pa)),transformOrigin:"1px 23px",backgroundColor:"#fff",boxShadow:`0 0 0 1px ${Ba}, ${Ka}`}},he?.captureId??Se?.captureId)}),ut&&t.jsx(Ge.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:Ha.transition,className:"pointer-events-none absolute left-0 top-0 z-30 w-56 rounded-xl bg-bg-000 p-3",style:{x:_,y:D,boxShadow:za},children:t.jsx("div",{className:"line-clamp-4 whitespace-pre-wrap break-words text-[13px] leading-snug text-text-100",children:ut.text})}),t.jsx(Je,{children:he&&t.jsxs(Ge.div,{drag:!0,dragMomentum:!1,dragConstraints:b,dragElastic:.05,initial:{scale:.25,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",stiffness:420,damping:28},className:"absolute z-30 w-64 cursor-grab rounded-xl bg-bg-000 p-1.5 active:cursor-grabbing",style:{...Ua({x:xt?.x??0,y:xt?.y??0,boundsW:he.boundsW,boundsH:he.boundsH}),transformOrigin:"0px 0px",boxShadow:za},children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{autoFocus:!0,type:"text",className:"h-7 min-w-0 flex-1 cursor-text bg-transparent px-1.5 text-[13px] text-text-100 outline-none placeholder:text-text-400",value:xe,"aria-label":m.formatMessage({defaultMessage:"Leave a comment\u2026",id:"tmuGYb42BG"}),placeholder:m.formatMessage({defaultMessage:"Leave a comment\u2026",id:"tmuGYb42BG"}),onPointerDownCapture:e=>e.stopPropagation(),onChange:e=>ye(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||("Enter"===e.key?(e.preventDefault(),ot()):"Escape"===e.key&&pe.current&&(e.preventDefault(),e.stopPropagation(),me(null)))}}),"element"===he.kind?t.jsx(ze,{multiline:!0,content:t.jsxs("span",{className:"flex flex-col gap-0.5",children:[t.jsx("span",{className:"line-clamp-2 break-words",children:he.anchor.descriptor}),he.anchor.textHint&&t.jsx("span",{className:"line-clamp-2 break-words",children:`\u201c${he.anchor.textHint}\u201d`}),t.jsx("span",{className:"line-clamp-3 break-all font-mono",children:he.anchor.selector})]}),children:t.jsx("button",{type:"button",className:"mr-1 inline-flex h-5 shrink-0 select-none items-center rounded border border-border-300 bg-bg-100 px-1 font-mono text-[11px] text-text-200 transition-colors hover:bg-bg-200",onPointerDownCapture:e=>e.stopPropagation(),"aria-label":m.formatMessage({defaultMessage:"Element context",id:"ycjkaeJDDL"}),children:il.exec(he.anchor.descriptor)?.[1]??he.anchor.descriptor.slice(0,12)})}):t.jsx(ze,{multiline:!0,content:t.jsx("span",{className:"line-clamp-4 break-words",children:bt}),children:t.jsx("button",{type:"button",className:"mr-1 inline-flex h-5 shrink-0 select-none items-center rounded border border-border-300 bg-bg-100 px-1 text-text-200 transition-colors hover:bg-bg-200",onPointerDownCapture:e=>e.stopPropagation(),onClick:()=>ve(!0),"aria-label":m.formatMessage({defaultMessage:"Selection context",id:"e4jzojVazB"}),children:t.jsx(He,{name:"ChatAdd",size:"sm"})})}),xe.trim()&&t.jsx("button",{type:"button",className:"flex size-7 shrink-0 items-center justify-center rounded-lg text-white transition-[filter] hover:brightness-110",style:{backgroundColor:qa},onPointerDownCapture:e=>e.stopPropagation(),onClick:ot,"aria-label":m.formatMessage({defaultMessage:"Add comment",id:"eiaPxp89eC"}),children:t.jsx(He,{name:"ArrowUp",size:"sm"})})]}),("text"===he.kind?bt:yt)&&t.jsx("div",{className:"select-none truncate px-1.5 pb-0.5 text-[10px] leading-[14px] text-text-400",children:"text"===he.kind?bt:`\u201c${yt}\u201d`}),be&&t.jsx("div",{className:"mt-1 border-t border-border-200 px-1.5 pb-0.5 pt-1",onPointerDownCapture:e=>e.stopPropagation(),children:"element"===he.kind?t.jsxs(t.Fragment,{children:[he.anchor.descriptor&&t.jsx("div",{className:"max-h-8 overflow-y-auto text-[10px] leading-[14px] text-text-400",children:he.anchor.descriptor}),he.anchor.textHint&&t.jsx("div",{className:"max-h-8 overflow-y-auto text-[10px] leading-[14px] text-text-400",children:`\u201c${he.anchor.textHint}\u201d`}),t.jsx("div",{className:"max-h-8 overflow-y-auto break-all font-mono text-[10px] leading-[14px] text-text-500",children:he.anchor.selector})]}):t.jsx("div",{className:"max-h-16 overflow-y-auto whitespace-pre-wrap break-words text-[10px] leading-[14px] text-text-400",children:bt})})]},he.captureId)}),it&&t.jsx(pl,{comment:it,replies:Ae.get(it.id)??[],commentProps:a,x:Wa(at?.found?at.x+6:ct?ct.x+6:8,8,Math.max(8,ft-232)),y:Wa(at?.found?at.y+6:ct?ct.y+ct.h+6:8,8,Math.max(8,ht-160)),onClose:()=>ke(null)},it.id)]})}),pl=e.memo(function({comment:e,replies:n,commentProps:s,x:r,y:i,onClose:a}){const l=o(),c=e.target.anchor,u=s.stagedIds?.has(e.id)??!1;return t.jsxs(Ge.div,{...Ha,className:"absolute z-30 w-56 rounded-xl bg-bg-000 p-3",style:{left:r,top:i,boxShadow:za},children:[t.jsx("div",{className:"whitespace-pre-wrap break-words text-[13px] leading-snug text-text-100",children:e.text}),n.map(e=>t.jsx("div",{className:"mt-2 ml-2 border-l-2 border-border-300 pl-2 text-[13px] leading-snug text-text-200",children:e.text},e.id)),t.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-1.5",children:["element"===c.kind&&c.descriptor&&t.jsx(ll,{descriptor:c.descriptor}),"text-quote"===c.kind&&t.jsx("div",{className:"truncate text-xs text-text-400",children:`\u201c${te(c.exact,80)}\u201d`}),t.jsx("span",{className:"shrink-0 text-[11px] text-text-400",children:new Date(e.createdAt).toLocaleTimeString(l.locale,{hour:"numeric",minute:"2-digit"})}),t.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[s.onSendToClaude&&!u&&t.jsx(ze,{content:l.formatMessage({defaultMessage:"Send to Claude",id:"xGC0T/NxhG"}),children:t.jsx("button",{type:"button",className:"flex size-5 items-center justify-center rounded text-text-400 transition-colors hover:bg-bg-100 hover:text-text-100",onClick:()=>{s.onSendToClaude?.(e.id),a()},"aria-label":l.formatMessage({defaultMessage:"Send to Claude",id:"xGC0T/NxhG"}),children:t.jsx(He,{name:"ChatAdd",size:"sm"})})}),t.jsx("button",{type:"button",className:"flex size-5 items-center justify-center rounded text-text-400 transition-colors hover:bg-bg-100 hover:text-danger-100",onClick:()=>{s.onCommentDelete(e.id),a()},"aria-label":l.formatMessage({defaultMessage:"Delete comment",id:"wOZRKWT1/R"}),children:t.jsx(He,{name:"Trash",size:"sm"})}),t.jsx("button",{type:"button",className:"flex size-5 items-center justify-center rounded text-text-400 transition-colors hover:bg-bg-100 hover:text-text-100",onClick:a,"aria-label":l.formatMessage({defaultMessage:"Close",id:"rbrahOGMC3"}),children:t.jsx(He,{name:"X",size:"sm"})})]})]})]})});function gl(e){if(0===e.length)return null;const t=e[0].path.split("/").filter(Boolean);if(0===t.length)return null;const n=t[0];return e.every(e=>{const t=e.path.split("/").filter(Boolean);return t.length>1&&t[0]===n})?n:null}function xl(e){if(e.children){e.children.sort((e,t)=>"directory"===e.type&&"directory"!==t.type?-1:"directory"!==e.type&&"directory"===t.type?1:e.name.localeCompare(t.name));for(const t of e.children)xl(t)}}function yl(e,{skillConventions:t=!0}={}){const n=t?gl(e):null,s={name:"",path:"",type:"directory",children:[]};for(const r of e){const e=r.path.split("/").filter(Boolean);if(n&&e[0]===n&&e.shift(),0===e.length)continue;let t=s;for(let n=0;n<e.length;n++){const s=e[n],o=n===e.length-1,i=e.slice(0,n+1).join("/");t.children||(t.children=[]);let a=t.children.find(e=>e.name===s);a||(a={name:s,path:i,type:o?"file":"directory",children:o?void 0:[],content:o?r.content:void 0,contentsOmitted:o?r.contentsOmitted:void 0,size:o?r.size:void 0},t.children.push(a)),t=a}}return xl(s),t&&s.children&&function(e){const t=e.findIndex(e=>"SKILL.md"===e.name);if(t>0){const n=e[t];e.splice(t,1),e.unshift(n)}}(s.children),s}function bl(e){if("file"===e.type)return e.path;if(e.children)for(const t of e.children){const e=bl(t);if(e)return e}return null}function vl(e){const t=new Set;for(const n of e.children??[])"directory"===n.type&&t.add(n.path);return t}function wl(e,t=[]){for(const[n,s]of Object.entries(e))if(null===s||"object"!=typeof s||Array.isArray(s)){if(null!=s){const e=String(s).trim();e&&t.push({key:n,value:e})}}else wl(s,t);return t}function kl(e,t){const n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),s=new RegExp(`^\\s*${n}\\s*:`),r=e.split("\n");for(let o=0;o<r.length;o++)if(s.test(r[o]))return o+1;return null}function Sl(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!t)return{description:null,otherFields:[],hasExtraFrontmatterFields:!1,content:e,contentStartLine:1,frontmatterFieldLines:{}};const n=t[1],s=t[2].trim(),r=t[2].trimStart(),o=e.length-r.length,i=e.slice(0,o).split("\n").length;let a;try{a=Qr(n)??{}}catch{return{description:null,otherFields:[],hasExtraFrontmatterFields:!0,content:s,contentStartLine:i,frontmatterFieldLines:{}}}const l=wl(a),c={};for(const{key:d}of l){const e=kl(n,d);c[d]=e?e+1:2}const u=l.find(e=>"description"===e.key);return{description:u?.value??null,otherFields:l.filter(e=>"description"!==e.key&&"name"!==e.key&&"user-invocable"!==e.key&&"argument-hint"!==e.key),hasExtraFrontmatterFields:Object.keys(a).some(e=>"name"!==e&&"description"!==e),content:s,contentStartLine:i,frontmatterFieldLines:c}}const Cl=e.memo(({context:e,trailing:n,className:s})=>{const r=function(e){const t=o();switch(e){case"skills":return t.formatMessage({defaultMessage:"Claude uses these descriptions when deciding which skills to use in chat.",id:"g08yMBD/54"});case"commands":return t.formatMessage({defaultMessage:"Claude uses these descriptions when deciding which commands to use in chat.",id:"ZQliNTGFd9"});case"agents":return t.formatMessage({defaultMessage:"Claude uses these descriptions when deciding which agents to use in chat.",id:"gMyopeB//M"})}}(e);return t.jsxs("div",{className:v("flex items-center justify-between",s),children:[t.jsxs("div",{className:"flex items-center gap-0.5",children:[t.jsx("h3",{className:"font-small text-text-500",children:t.jsx(i,{defaultMessage:"Description",id:"Q8Qw5BZ1VA"})}),t.jsx(ze,{multiline:!0,className:"[overflow-wrap:anywhere]",content:r,children:t.jsx("span",{className:"flex items-center cursor-default",children:t.jsx(ue,{className:"w-4 h-4 text-text-500"})})})]}),n]})});function Nl({children:e}){return t.jsx("h3",{className:"font-small text-text-500",children:e})}function El(e){return Xe(e.replaceAll("-"," "))}Cl.displayName="CustomizeDescriptionSectionHeading";const jl=e.memo(({parsedContent:n,compact:s,hideDescriptionHeading:r,typography:o,proseInset:i})=>{const{description:a,otherFields:l,content:c}=n,u="inherit"===o?void 0:"font-claude-response";return t.jsxs("div",{className:v(s?v("leading-[1.65rem]",i&&"p-5"):"mx-auto w-full max-w-3xl leading-[1.65rem] py-4 pl-6 pr-6 md:py-6 md:pl-11 md:pr-11"),children:[a&&!r&&t.jsxs("div",{className:s?void 0:"mt-2",children:[t.jsx(Cl,{context:"skills",className:"mb-3"}),t.jsx(de,{text:a,className:u,typography:o})]}),l.length>0&&t.jsx("div",{className:"grid grid-cols-[max-content_1fr] items-baseline gap-x-8 gap-y-4 mt-6",children:l.map(({key:n,value:s},r)=>t.jsxs(e.Fragment,{children:[t.jsx(Nl,{children:El(n)}),t.jsx("p",{className:"text-text-100",children:s})]},`${n}-${r}`))}),(a&&!r||l.length>0)&&c&&t.jsx("div",{className:"mt-6"}),c&&t.jsx(de,{text:c,className:u,typography:o,normalizationMode:"markdown-document"})]})});jl.displayName="SkillMdContent";const Ml={add:"bg-success-100/20 dark:bg-success-000/25",remove:"bg-danger-100/20 dark:bg-danger-000/25"},Ll=new Set(["comment","prolog","doctype","cdata"]);function Tl(e){if(Ll.has(e.type))return{...e.style,color:"light-dark(hsl(220, 10%, 35%), hsl(220, 10%, 65%))"}}function Ol(e,t){return e&&t?"rounded-sm":e?"rounded-l-sm":t?"rounded-r-sm":""}function Al({initialText:t="",committedText:n="",onDraftChange:s,onDraftClear:r,onSubmit:o}){const[i,a]=e.useState(t),l=e.useRef(null),c=e.useRef(s);e.useEffect(()=>{c.current=s},[s]);const u=e.useCallback(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]);e.useEffect(()=>u,[u]);const d=e.useCallback(e=>{a(e),u(),l.current=setTimeout(()=>{c.current?.(e)},150)},[u]),f=e.useCallback(()=>{const e=i.trim();e&&(u(),e!==n&&o?.(e),a(""),r?.())},[i,n,o,r,u]),h=e.useCallback(e=>{if("Enter"!==e.key||e.shiftKey)"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),u(),a(""),r?.());else{if(e.metaKey||e.ctrlKey)return void f();e.preventDefault(),e.stopPropagation(),f()}},[f,r,u]),m=e.useCallback(()=>{i.trim()&&i!==n||(u(),r?.())},[i,n,r,u]);return{commentText:i,setCommentText:a,handleTextChange:d,handleSubmit:f,handleKeyDown:h,handleBlur:m}}const Rl=e.memo(function({line:n,lineNumberWidth:s,lineIndex:r,showLineNumbers:i=!0,diffView:a=!0,filePath:l,enableComments:c=!1,isSelectionModeActive:u=!1,activeLineKey:d,onAddCommentClick:f,onStartSelection:h,onCommentSubmit:m,onCommentCancel:p,onCommentDelete:g,existingComment:x,isSelected:y=!1,isSelectionStart:b=!1,isSelectionEnd:w=!1,onMouseDown:k,onMouseEnter:S,draftText:C,onDraftChange:N,onDraftClear:E}){const j=o(),M=n.newLineNumber||n.oldLineNumber,L=l&&M?fe(l,M,n.type):null,T=l&&M?he(me({filePath:l,startLine:M,lineType:n.type})):null,O=void 0!==C,{commentText:A,setCommentText:R,handleTextChange:I,handleSubmit:_,handleKeyDown:D,handleBlur:F}=Al({initialText:C??x?.text??"",committedText:x?.text??"",onDraftChange:N,onDraftClear:()=>{p?.(),E?.()},onSubmit:e=>{M&&m&&l&&m(me({filePath:l,startLine:M,lineType:n.type,snippet:n.content}),e)}});e.useEffect(()=>{void 0!==C&&R(C)},[C,R]);const P=e.useCallback(()=>{h?h(r,n):(void 0===C&&N?.(""),L&&f&&f(L))},[r,n,L,f,h,C,N]),q=e.useCallback(()=>{x&&void 0===C&&N?.(x.text)},[x,C,N]),B=e.useCallback(()=>{x&&g&&g(x.id)},[x,g]),K=Math.max(s,3),z=(e,s)=>{const r=e?.toString().padStart(K," ")||" ".repeat(K),o=.6*K+.5+"rem";return t.jsx("span",{className:v("flex items-start justify-end select-none pr-2 font-mono text-xs",a?"pl-4":"pl-1",It(n.type),!s&&"border-r border-border-400"),style:{minHeight:"1.375rem",lineHeight:"1.375rem",width:o},"data-line-number":e||"",[fi]:"",children:r})};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:v("group/line flex",y?"bg-[hsl(210,70%,50%)]/10 hover:bg-[hsl(210,70%,50%)]/20 border-l-[3px] border-l-[hsl(210,70%,50%)]":[a&&At(n.type),Rt(n.type)],!y&&c&&Dt(n.type),Ft(y),c&&"cursor-pointer",u&&"select-none"),style:{minHeight:"1.375rem",...$t(y)},"data-diff-type":n.type,"data-diff-line":n.newLineNumber??n.oldLineNumber,onMouseDown:k,onMouseEnter:S,children:[i&&t.jsxs(t.Fragment,{children:[a&&z(n.oldLineNumber,!0),z(n.newLineNumber,!1)]}),t.jsxs("span",{className:v("flex items-start justify-center font-mono text-xs select-none relative",a?"w-8":"w-3",_t(n.type)),style:{minHeight:"1.375rem",lineHeight:"1.375rem"},[fi]:"",children:[c&&M&&!x&&t.jsx("button",{className:"hidden group-hover/line:flex absolute top-[2px] left-0 -ml-2 w-fit h-fit items-center justify-center bg-accent-100 hover:bg-accent-000 text-oncolor-100 p-0.5 rounded shadow-md ring-1 ring-always-black/10 transition-colors",onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),P()},"aria-label":j.formatMessage({defaultMessage:"Add suggestion to line",id:"bNPPSkL602"}),title:j.formatMessage({defaultMessage:"Add suggestion to line {lineNumber}",id:"/Egk4bOq38"},{lineNumber:M}),children:t.jsx($,{size:14})}),t.jsx("span",{children:"add"===n.type?"+":"remove"===n.type?"-":" "})]}),t.jsxs("div",{className:"flex-1 flex items-start pl-0 pr-2 group-data-[scrollable]/overlay:pr-6 min-w-0 font-mono",style:{minHeight:"1.375rem"},children:[(()=>{const e=n.inlineHighlights;if(n.tokens&&n.tokens.length>0){const s=e&&e.length>0?function(e,t,n){if(0===t.length)return e;const s=Ml[n];if(!s)return e;const r=[];let o=0,i=0;for(const a of e){const e=o,n=o+a.content.length;let l=e;for(;i<t.length&&t[i].startIndex<n;){const o=t[i],c=Math.max(o.startIndex,e),u=Math.min(o.endIndex,n);if(l<c&&r.push({...a,content:a.content.substring(l-e,c-e)}),c<u){const t=Ol(c===o.startIndex,o.endIndex<=n),i=Tl(a);r.push({...a,content:a.content.substring(c-e,u-e),className:`${s} ${t}`.trim(),...i&&{style:i}})}if(l=u,!(o.endIndex<=n))break;i++}l<n&&r.push({...a,content:a.content.substring(l-e)}),o=n}return r}(n.tokens,e,n.type):n.tokens;return t.jsx("code",{className:"font-mono text-xs break-all",style:{lineHeight:"1.375rem",whiteSpace:"pre-wrap"},children:s.map((e,n)=>{const s=e.content||"";return s?t.jsx("span",{style:e.style||{},className:v(e.type&&`token-${e.type}`,e.className),children:s},n):null})})}if(e&&e.length>0&&n.content){const s=function(e,t,n){if(0===t.length||!e)return[{type:"",content:e}];const s=Ml[n];if(!s)return[{type:"",content:e}];const r=[];let o=0;for(const i of t){o<i.startIndex&&r.push({type:"",content:e.substring(o,i.startIndex)});const t=Math.min(i.endIndex,e.length);i.startIndex<t&&r.push({type:"",content:e.substring(i.startIndex,t),className:`${s} rounded-sm`}),o=t}return o<e.length&&r.push({type:"",content:e.substring(o)}),r}(n.content,e,n.type);return t.jsx("code",{className:"font-mono text-xs break-all",style:{lineHeight:"1.375rem",whiteSpace:"pre-wrap"},children:s.map((e,n)=>t.jsx("span",{style:e.style||{},className:e.className,children:e.content},n))})}return t.jsx("code",{className:"font-mono text-xs break-all",style:{lineHeight:"1.375rem",whiteSpace:"pre-wrap"},children:n.content||t.jsx("span",{[fi]:"",children:"\xa0"})})})(),"\n"]})]}),(O||x&&!O)&&t.jsx("div",{className:"m-2 rounded-lg","data-comment-line-key":T??void 0,"data-comment-id":x?.id,children:t.jsx(Qo,{isEditing:O,existingComment:x,commentText:A,placeholder:j.formatMessage({defaultMessage:"Add a comment to line {lineNumber}",id:"ZE5eWyHC5S"},{lineNumber:M}),onTextChange:I,onSubmit:_,onKeyDown:D,onBlur:F,onEditExisting:q,onDelete:B})})]})});Rl.displayName="DiffLineRenderer";const Il=e.memo(function({startLine:e,endLine:n,onSubmit:s,onCancel:r,initialText:i="",onTextChange:a}){const l=o(),{commentText:c,handleTextChange:u,handleSubmit:d,handleKeyDown:f,handleBlur:h}=Al({initialText:i,onDraftChange:a,onDraftClear:r,onSubmit:e=>{s(e)}}),m=e!==n?{id:"",text:"",target:me({filePath:"",startLine:e,endLine:n}),createdAt:0,updatedAt:0}:void 0;return t.jsx("div",{className:"m-2",children:t.jsx(Qo,{isEditing:!0,existingComment:m,commentText:c,placeholder:l.formatMessage({defaultMessage:"Add a suggestion to lines {startLine}-{endLine}",id:"YXg5v/Y4g6"},{startLine:e,endLine:n}),onTextChange:u,onSubmit:d,onKeyDown:f,onBlur:h})})});function _l(e){return"object"==typeof e&&null!==e&&"type"in e&&("add"===e.type||"remove"===e.type||"normal"===e.type)}Il.displayName="MultiLineCommentInput";let Dl=null;const $l=e.memo(({content:s,filePath:r,commentProps:o})=>{const{codeStyle:i}=pe(),{exceedsSizeLimit:a}=ge(s),l=e.useMemo(()=>function(e){const t=e.split(".").pop()?.toLowerCase()||"";return Mt[t]||"plaintext"}(r),[r]),c=e.useMemo(()=>s.split("\n").map((e,t)=>({type:"normal",content:e,oldLineNumber:t+1,newLineNumber:t+1})),[s]),[u,d]=e.useState(c);e.useEffect(()=>{if(d(c),a||"plaintext"===l||!s.trim())return;let e=!1;const t=Dl??=n(()=>import("./cda324202-B98zrC6F.js"),__vite__mapDeps([2,3]),import.meta.url).then(e=>e.treeSitterHighlighter).catch(e=>(be.error(ve.USER_CONTENT_RENDERER,"[TreeSitter] highlighter chunk failed to load:",e instanceof Error?e.message:String(e)),null)),r=window.setTimeout(()=>{(async()=>{try{const n=await t;if(e||null===n)return;const r=await n.highlight(s,l);if(e||!r)return;const o=[];for(const e of r){if(void 0===e.row)continue;const t=e.type&&i?i[e.type]:void 0;o[e.row]||(o[e.row]=[]),o[e.row].push({...e,style:t&&"object"==typeof t?t:{}})}d(c.map((e,t)=>{const n=o[t];return n&&n.length>0?{...e,tokens:n}:e}))}catch{}})()},100);return()=>{e=!0,window.clearTimeout(r)}},[c,s,l,i,a]);const f=e.useMemo(()=>function(e){let t=0;for(const n of e)n.oldLineNumber&&(t=Math.max(t,n.oldLineNumber)),n.newLineNumber&&(t=Math.max(t,n.newLineNumber));return t.toString().length}(c),[c]),h=void 0!==o,m=o?.comments,p=o?.drafts,g=e.useMemo(()=>{if(!m)return;const e=new Map;for(const t of m){if(xe(t.target)!==r)continue;const n=t.target.anchor;if("plaintext"!==n.kind||"normal"!==n.lineType)continue;const s=e.get(n.endLine);s?s.push(t):e.set(n.endLine,[t])}return e},[m,r]),x=o?.onDraftChange,y=o?.onDraftClear,b=o?.onCommentSubmit,v=o?.onCommentDelete,w=e.useCallback(e=>{if(!x)return;const t=me({filePath:r,startLine:e.startLine,endLine:e.endLine});x(he(t),{text:"",target:t,lineIndices:e.lineIndices})},[r,x]),k=e.useRef(p);k.current=p;const S=e.useCallback(e=>{const t=e.newLineNumber;if(!t||!x)return;const n=me({filePath:r,startLine:t}),s=he(n);k.current?.[s]||x(s,{text:"",target:n})},[r,x]),{selectedRange:C,isLineSelected:N,getLineMouseHandlers:E,clearSelection:j,startSelectionFromLine:M,isSelectionModeActive:L}=function({lines:t,enabled:n=!0,onSelectionComplete:s,onSingleLineClick:r}){const[o,i]=e.useState({isSelecting:!1,startLineIndex:null,endLineIndex:null,selectionLineType:null,hasDragged:!1}),[a,l]=e.useState(!1),c=e.useRef(s);c.current=s;const u=e.useRef(r);u.current=r;const d=e.useRef(null),f=e.useRef(t);f.current=t;const h=e.useMemo(()=>{if(null===o.startLineIndex||null===o.endLineIndex||null===o.selectionLineType)return null;const e=Math.min(o.startLineIndex,o.endLineIndex),n=Math.max(o.startLineIndex,o.endLineIndex),s=[];let r=null,i=null;for(let o=e;o<=n;o++){const e=t[o];if(e&&_l(e)){s.push(o);const t=e.newLineNumber??e.oldLineNumber;void 0!==t&&((null===r||t<r)&&(r=t),(null===i||t>i)&&(i=t))}}return null===r||null===i||0===s.length?null:{startLine:r,endLine:i,lineType:o.selectionLineType,lineIndices:s}},[o.startLineIndex,o.endLineIndex,o.selectionLineType,t]),m=e.useCallback(e=>!!h&&!!o.hasDragged&&h.lineIndices.includes(e),[h,o.hasDragged]),p=e.useCallback(()=>{const e=d.current;if(!e)return;const{startLineIndex:t,lineType:n,hasDragged:s,endLineIndex:r}=e;if(d.current=null,s){const e=Math.min(t,r),s=Math.max(t,r),o=[],a=[];let l=null,u=null;for(let t=e;t<=s;t++){const e=f.current[t];if(e&&_l(e)){o.push(e),a.push(t);const n=e.newLineNumber??e.oldLineNumber;void 0!==n&&((null===l||n<l)&&(l=n),(null===u||n>u)&&(u=n))}}null!==l&&null!==u&&o.length>0&&c.current?.({startLine:l,endLine:u,lineType:n,lineIndices:a},o),i({isSelecting:!1,startLineIndex:t,endLineIndex:r,selectionLineType:n,hasDragged:!0})}else{const e=f.current[t];e&&_l(e)&&u.current?.(e,t),i({isSelecting:!1,startLineIndex:null,endLineIndex:null,selectionLineType:null,hasDragged:!1})}l(!1)},[]),g=e.useCallback((e,t)=>{if(!n)return;if(!_l(t))return;d.current={startLineIndex:e,lineType:t.type,hasDragged:!1,endLineIndex:e},l(!0),i({isSelecting:!0,startLineIndex:e,endLineIndex:e,selectionLineType:t.type,hasDragged:!1});const s=()=>{document.removeEventListener("mouseup",s),p()};document.addEventListener("mouseup",s)},[n,p]),x=e.useCallback((e,t,s)=>{if(!n||!a)return;if(0!==s.button)return;const r=s.target;r.closest("button")||r.closest("textarea")||r.closest("input")||(s.preventDefault(),i(t=>({...t,isSelecting:!0,endLineIndex:e})))},[n,a]),y=e.useCallback(e=>{if(!o.isSelecting)return;const t=e!==o.startLineIndex;d.current&&(d.current.endLineIndex=e,d.current.hasDragged=d.current.hasDragged||t),i(n=>({...n,endLineIndex:e,hasDragged:n.hasDragged||t}))},[o.isSelecting,o.startLineIndex]),b=e.useCallback((e,t)=>({onMouseDown:n=>x(e,t,n),onMouseEnter:()=>y(e)}),[x,y]),v=e.useCallback(()=>{d.current=null,l(!1),i({isSelecting:!1,startLineIndex:null,endLineIndex:null,selectionLineType:null,hasDragged:!1})},[]);return{selectionState:o,selectedRange:h,isLineSelected:m,getLineMouseHandlers:b,clearSelection:v,startSelectionFromLine:g,isSelectionModeActive:a}}({lines:u,enabled:h,onSelectionComplete:w,onSingleLineClick:S}),T=e.useCallback((e,t,n)=>{if(!b)return;const s=n.target.anchor;if("plaintext"!==s.kind)return;const r=(n.lineIndices?n.lineIndices.map(e=>u[e]).filter(e=>!!e):u.slice(s.startLine-1,s.endLine)).map(e=>e.content).join("\n");b({...n.target,anchor:{...s,snippet:r}},e),y?.(t),j()},[b,y,u,j]);return a?t.jsx(ye,{code:s,codeClassName:"font-mono !text-sm !leading-relaxed p-4"}):t.jsx("div",{className:"min-w-0 max-w-full",children:u.map((n,s)=>{const i=n.newLineNumber??s+1,a=me({filePath:r,startLine:i}),l=he(a),c=g?.get(i)??[],u=c[0]??void 0,d=p?.[l],m=h?E(s,n):void 0,w=h&&N(s),k=w&&C?.lineIndices[0]===s,S=w&&C?.lineIndices[C.lineIndices.length-1]===s;return t.jsxs(e.Fragment,{children:[t.jsx(Rl,{line:n,lineIndex:s,lineNumberWidth:f,showLineNumbers:!0,diffView:!1,filePath:r,enableComments:h,isSelectionModeActive:L,onStartSelection:h?M:void 0,onCommentSubmit:b?(e,t)=>b(u?.target??e,t):void 0,onCommentDelete:v,existingComment:u,isSelected:w,isSelectionStart:k,isSelectionEnd:S,onMouseDown:m?.onMouseDown,onMouseEnter:m?.onMouseEnter,draftText:d?.text,onDraftChange:x?e=>x(l,{text:e,target:a}):void 0,onDraftClear:y?()=>y(l):void 0}),c.slice(1).map(e=>t.jsx(Fl,{comment:e,onUpdate:o?.onCommentUpdate,onDelete:v},e.id)),p&&Object.entries(p).map(([e,n])=>{const s=n.target.anchor;return"plaintext"===s.kind&&xe(n.target)===r&&s.endLine>s.startLine&&s.endLine===i?t.jsx(Il,{startLine:s.startLine,endLine:s.endLine,lineType:"normal",initialText:n.text,onTextChange:t=>x?.(e,{...n,text:t}),onSubmit:t=>T(t,e,n),onCancel:()=>{y?.(e),j()}},e):null})]},i)})})});$l.displayName="SyntaxHighlightedFile";const Fl=e.memo(function({comment:n,onUpdate:s,onDelete:r}){const[o,i]=e.useState(!1),{commentText:a,handleTextChange:l,handleSubmit:c,handleKeyDown:u,handleBlur:d}=Al({initialText:n.text,committedText:n.text,onSubmit:e=>{s?.(n.id,e),i(!1)},onDraftClear:()=>i(!1)});return t.jsx("div",{className:"m-2 rounded-lg","data-comment-id":n.id,children:t.jsx(Qo,{isEditing:o,existingComment:n,commentText:a,placeholder:"",onTextChange:l,onSubmit:c,onKeyDown:u,onBlur:d,onEditExisting:()=>{l(n.text),i(!0)},onDelete:()=>r?.(n.id)})})});function Pl(){return!we()}function ql(){return t.jsx(io,{className:"flex items-center justify-center h-full"})}function Bl({error:e,onRetry:n}){return t.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-300 gap-4",children:[t.jsx("div",{children:e}),n&&t.jsx(Fe,{variant:"secondary",size:"sm",onClick:n,children:t.jsx(i,{defaultMessage:"Try again",id:"FazwRldA7z"})})]})}function Kl({fileName:e,onOpenFile:n}){const{displayName:s,displayExt:o}=go(e),a=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"p-6",children:t.jsx(Te,{asset:r,size:"md"})}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-text-100 font-medium text-lg",children:s}),o&&t.jsx("div",{className:"text-text-300 text-sm",children:o})]}),t.jsx("div",{className:"text-text-300",children:n?t.jsx(i,{defaultMessage:"Click to open file",id:"fW6BGzVt9J"}):t.jsx(i,{defaultMessage:"No preview available",id:"vYALkaFo+6"})})]});return n?t.jsx("button",{type:"button",onClick:n,className:"flex flex-col items-center justify-center h-full gap-4 w-full cursor-pointer hover:bg-bg-100 transition-colors",children:a}):t.jsx("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:a})}function zl({content:n,language:s,displayFileType:r,viewing:o,richSandboxRef:a,onSandboxConfirmation:l,richSandboxCapabilities:c,fileName:u,onRefresh:d,mimeType:f,artifactContext:h,ArtifactMcpModal:m,noAutoScroll:p,compact:g,hideDescriptionHeading:x,typography:y,proseInset:b,scrollFade:w,filePath:k,archivePath:S,commentProps:C,htmlReviewCommentMode:N,onHtmlReviewCommentModeChange:E,proseReviewScope:j,proseReviewAnalyticsCtx:M,onProseReviewSendToClaude:L,proseReviewSendDisabled:T,editProps:O,onImageRendered:A}){const R="normal"!==o,I=void 0!==O&&"string"==typeof n,_="edit"===o&&I,[D,$]=e.useState(!1);e.useEffect(()=>{"edit"===o&&$(!0)},[o]);const F=I&&(_||D);if("image"===r){if(!(n instanceof Blob))throw new Error(`displayFileType is "${r}" but content is not Blob`)}else if("rich"===r){if("string"!=typeof n&&!(n instanceof ArrayBuffer))throw new Error('displayFileType is "rich" but content is not string or ArrayBuffer')}else if("nonrenderable"===r);else if("string"!=typeof n)throw new Error(`displayFileType is "${r}" but content is not a string`);const[P,q]=e.useState(null),[B,K]=e.useState(!0),[z,H]=e.useState(!1),[U,W]=e.useState(null),Y=void 0!==C,X=e.useMemo(()=>void 0!==k&&Ce(k),[k]),V=e.useMemo(()=>{if("markdown"!==s||"string"!=typeof n)return null;if(X)return null;const e=Sl(n);if(!(null!==e.description||e.otherFields.length>0))return null;if("SKILL.md"===u)return e;if(!Y)return null;const t=e.description?[{key:"description",value:e.description},...e.otherFields]:e.otherFields;return{description:null,otherFields:t,content:e.content,contentStartLine:e.contentStartLine,frontmatterFieldLines:e.frontmatterFieldLines,hasExtraFrontmatterFields:t.length>0}},[s,u,n,Y,X]),J=e.useMemo(()=>{if(!X||"string"!=typeof n)return null;const e=so(n);if(!e.hasFrontmatter)return null;const t=[];return e.name&&t.push(`# ${e.name}`),e.description&&t.push(`_${e.description}_`),t.length>0&&t.push("---"),t.push(e.content),t.join("\n\n")},[X,n]);e.useEffect(()=>{n&&"rich"===r&&(z||K(!0))},[n,r,z]);const G=e.useCallback((e,t)=>{if("json"===t&&e)try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch(n){return e}return e},[]),Q=e.useCallback(e=>{q({error:e,artifactId:u,artifactVersion:0})},[u]),Z=e.useCallback(()=>{q(null)},[]),te=e.useCallback(()=>{q(null),d?.()},[d]),ne=e.useRef(null),se=f||("rich"===r?Ne.Html:void 0),re="rich"===r&&!R&&void 0!==se,{htmlPreviewPinsEnabled:oe}=Ee(),ie=oe&&"rich"===r&&se===Ne.Html&&"string"==typeof n&&void 0!==C,[ae]=e.useState(()=>ee()),le=e.useMemo(()=>ie&&"string"==typeof n?Fa(n,ae):n,[ie,n,ae]),ce=e.useMemo(()=>ie&&"string"==typeof n?Va(n):void 0,[ie,n]),ue="markdown"===s,fe="string"==typeof n?n:"",he=k??u,me=e.useMemo(()=>je(fe,{nestedCodeBlockMode:"markdown-document"}),[fe]),pe=Me("__gb__2583723424"),ge=Y&&void 0!==M&&ue&&Le(he)!==Ne.Html&&void 0===S&&null===V&&null===J,xe=e.useMemo(()=>({kind:"file",archivePath:S,filePath:he}),[S,he]),ye=e.useMemo(()=>null!==V?t.jsx(jl,{parsedContent:V,compact:g,hideDescriptionHeading:x,typography:y,proseInset:b}):t.jsx("div",{tabIndex:0,id:"wiggle-file-content",className:v("outline-none focus-visible:shadow-focus",g?v("leading-[1.65rem]",b&&"p-5"):"mx-auto w-full max-w-3xl leading-[1.65rem] py-4 pl-6 md:py-6 md:pl-11",!g&&(ge?"pr-16":"pr-6 md:pr-11")),children:pe?t.jsx(Eo,{text:J??me,className:"inherit"===y?void 0:"font-claude-response",analyticsCtx:M}):t.jsx(de,{text:J??me,className:"inherit"===y?void 0:"font-claude-response",typography:y,normalizationMode:"markdown-document",emitSourcePositions:ge})}),[V,g,x,y,b,ge,pe,J,me,M]),be=ge?void 0:C,ve=e.useMemo(()=>t.jsx("div",{tabIndex:0,id:"wiggle-file-content",className:v("outline-none focus-visible:shadow-focus",ge&&"pr-16"),children:t.jsx($l,{content:G(ge?me:fe,s),filePath:he,commentProps:be})}),[ge,me,fe,s,he,be,G]),we=ge?t.jsx(ca,{reviewStoreKey:j,documentRef:xe,source:me,analyticsCtx:M,displayMode:R?"raw":"rendered",onSendToClaude:L,sendDisabled:T,children:R?ve:ye}):R?ve:ye;e.useEffect(()=>{if("image"===r){const e=URL.createObjectURL(n);return W(e),()=>{URL.revokeObjectURL(e)}}W(null)},[n,r]);const ke=e.useCallback(()=>{K(!1),H(!0),l?.()},[l]),Se=e.useCallback(()=>{A?.({ok:!0})},[A]),Te=e.useCallback(()=>{A?.({ok:!1,reason:"img_error"})},[A]);return t.jsxs(t.Fragment,{children:[re&&t.jsx(ml,{active:ie,token:ie?ae:null,documentRef:xe,commentProps:C,commentMode:N,onCommentModeChange:E,pageTextIndex:ce,children:t.jsxs("div",{className:"h-full w-full relative border-none",children:[B&&t.jsx(io,{className:"absolute inset-0 flex items-center justify-center z-20"}),t.jsx(_e,{ref:a,className:"h-full w-full border-none bg-bg-000",content:le,type:se,title:u,onSandboxConfirmation:ke,capabilities:c,onReportError:Q,onSetContent:Z,onRefresh:te,externalLinkBehavior:"ask",artifactContext:h,ArtifactMcpModal:m}),P&&t.jsx(qt,{error:P,handleClose:()=>q(null),isStreaming:!1})]})}),F&&t.jsx("div",{className:_?"h-full":"hidden",children:pe&&ue&&M?t.jsx(_a,{content:n,onSave:O.onSave,isSaving:O.isSaving,ephemeral:O.ephemeral,autosaveSuspended:O.autosaveSuspended,readUpstreamContent:O.readUpstreamContent,reviewStoreKey:ge?j:void 0,documentRef:xe,analyticsCtx:M,onSendToClaude:ge?L:void 0,sendDisabled:T}):t.jsx(fo,{content:n,language:s,onSave:O.onSave,isSaving:O.isSaving})}),!_&&("code"===r||R)&&t.jsx("div",{className:"relative h-full",children:t.jsx(Bt,{ref:ne,className:v("absolute inset-0 overflow-auto",w&&"scroll-fade-y scroll-fade-size-6"),noDefaultScroll:p,children:ue?we:ve})}),"image"===r&&U&&t.jsx("div",{className:"h-full p-5",children:t.jsx("div",{className:"flex items-center justify-center w-full h-full",children:t.jsx("img",{loading:"lazy",src:U,alt:u,width:0,height:0,sizes:"100vw",className:"w-auto h-auto max-w-full max-h-full object-contain",onLoad:Se,onError:Te})})}),"nonrenderable"===r&&t.jsx("div",{className:"flex items-start justify-center h-full pt-12 text-text-300",children:t.jsx(i,{defaultMessage:"File type cannot be displayed",id:"AZLJvXC/bK"})})]})}function Hl({isLoading:e,error:n,onRetry:s,content:r,displayFileType:o,mimeType:i,fileName:a,onOpenFile:l,...c}){const u=Pl(),d="rich"===o&&!u&&void 0!==i&&(ke(i)||Se(i));return e&&!r?t.jsx(ql,{}):n?t.jsx(Bl,{error:n,onRetry:s}):"nonrenderable"===o||d?t.jsx(Kl,{fileName:a,onOpenFile:l}):void 0===r?null:t.jsx("div",{className:"h-full",children:t.jsx(zl,{content:r,displayFileType:o,mimeType:i,fileName:a,onOpenFile:l,...c})})}const Ul=e.memo(({viewing:e,onViewingChange:n,editable:s=!1})=>{const r=o();return t.jsx(Oe,{size:"sm","aria-label":r.formatMessage({defaultMessage:"File view mode",id:"waTRV6VRNp"}),value:e,onChange:e=>n(e),segments:[{value:"normal",icon:"Eye",tooltip:r.formatMessage({defaultMessage:"Preview",id:"TJo5E6JuIN"})},...s?[{value:"edit",icon:"Edit",tooltip:r.formatMessage({defaultMessage:"Edit",id:"wEQDC6Wv3/"})}]:[],{value:"raw",icon:"Code",tooltip:r.formatMessage({defaultMessage:"Code",id:"h2vipunVVd"})}]})});Ul.displayName="FileViewModeToggle";const Wl=e.memo(({id:n,fileTree:s,selectedPath:r,expandedFolders:i,onFileSelect:a,onToggleFolder:l,className:c,variant:u="fileDetail"})=>{const d=o(),f="settings"===u?"hover:bg-bg-300":"hover:bg-bg-100",h="settings"===u?"bg-bg-400":"bg-bg-200",m=e.useCallback((e,n)=>{const s=Ae(e.name);if(!e.name)return t.jsx(t.Fragment,{children:e.children?.map(e=>t.jsx("div",{children:m(e,n)},e.path))});const o="directory"===e.type,c=i.has(e.path),u=r===e.path,p=16*n+8;return o?t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>l(e.path),"aria-label":d.formatMessage({defaultMessage:"{name}, folder",id:"/e5nr3MIv3"},{name:s}),"aria-expanded":c,className:v("w-full px-2 py-1 rounded-lg flex items-center justify-between transition-colors text-text-300 hover:text-text-100 -outline-offset-2",f),style:{paddingLeft:`${p}px`},children:[t.jsx(ze,{content:s,className:"max-w-none",side:"top",children:t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[t.jsx("div",{className:"flex-shrink-0 w-3.5 h-3.5",children:t.jsx(He,{name:"Folder",customSize:14})}),t.jsx("div",{className:"text-left text-sm font-normal truncate",children:s})]})}),t.jsx("div",{className:"w-3.5 h-3.5 flex-shrink-0 ml-1.5",children:t.jsx(He,{name:c?"CaretDown":"CaretRight",customSize:14})})]}),c&&e.children&&t.jsx("div",{className:"flex flex-col gap-1",children:e.children.map(e=>t.jsx("div",{children:m(e,n+1)},e.path))})]}):t.jsx(ze,{content:s,className:"max-w-none",side:"top",children:t.jsx("button",{onClick:()=>a(e.path,e),"aria-current":u?"page":void 0,className:v("w-full py-1 rounded-lg inline-flex justify-start items-center gap-2 transition-colors -outline-offset-2",u?`${h} text-text-100 font-semibold`:`${f} text-text-300 hover:text-text-100 font-normal`),style:{paddingLeft:`${0===n?p:p-16+20}px`},children:t.jsx("div",{className:"flex-1 min-w-0 text-left text-sm truncate",children:s})})})},[i,r,a,l,f,h,d]);return t.jsx("div",{id:n,className:Ye("w-60 flex-shrink-0 overflow-y-auto",c),children:t.jsx("div",{className:"flex flex-col gap-1",children:m(s,0)})})});function Yl(t=new Set){const[n,s]=e.useState(t);return[n,e.useCallback(e=>{s(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),s]}Wl.displayName="FileTreeSidebar";const Xl=e.memo(({viewing:e,onViewingChange:n,onCopy:s,didCopy:r,showToggle:i,inline:a,editable:l})=>{const c=o();return t.jsxs("div",{className:a?"flex items-center gap-2":"absolute top-3 right-4 z-10 flex items-center gap-1 opacity-0 group-hover:opacity-100 pointer-coarse:opacity-100 transition-opacity",children:[i&&t.jsx(Ul,{viewing:e,onViewingChange:n,editable:l}),t.jsx(Fe,{variant:"ghost",size:"sm",iconOnly:!0,icon:r?"Check":"Copy",onClick:s,"aria-label":r?c.formatMessage({defaultMessage:"Copied",id:"p556q3uvbn"}):c.formatMessage({defaultMessage:"Copy",id:"4l6vz1/eZ5"})})]})});Xl.displayName="FileViewerHoverActions";export{Nt as A,xo as B,po as C,Hl as D,St as E,Wl as F,Ct as G,_o as H,Co as I,Pl as J,No as K,Tt as L,qt as M,Bt as N,Fa as O,ca as P,Va as Q,Vo as R,io as S,ml as T,mo as U,di as V,ga as W,mi as X,gl as a,yl as b,Ul as c,Xl as d,Ot as e,bl as f,vl as g,Lt as h,go as i,To as j,zo as k,Fo as l,Et as m,Do as n,oi as o,Sl as p,Qo as q,Oo as r,Po as s,Bo as t,Yl as u,Ko as v,eo as w,so as x,Qr as y,oo as z};
