| 3107 | `)+` |
| 3108 | |
| 3109 | `,this.references=[];return K}};qT.emphasis={filter:["em","i"],replacement:function(q,K,_){if(!q.trim())return"";return _.emDelimiter+q+_.emDelimiter}};qT.strong={filter:["strong","b"],replacement:function(q,K,_){if(!q.trim())return"";return _.strongDelimiter+q+_.strongDelimiter}};qT.code={filter:function(q){var K=q.previousSibling||q.nextSibling,_=q.parentNode.nodeName==="PRE"&&!K;return q.nodeName==="CODE"&&!_},replacement:function(q){if(!q)return"";q=q.replace(/\r?\n|\r/g," ");var K=/^`|^ .*?[^ ].* $|`$/.test(q)?" ":"",_="`",z=q.match(/`+/gm)||[];while(z.indexOf(_)!==-1)_=_+"`";return _+K+q+K+_}};qT.image={filter:"img",replacement:function(q,K){var _=Ym8(K.getAttribute("alt")),z=K.getAttribute("src")||"",Y=Ym8(K.getAttribute("title")),$=Y?' "'+Y+'"':"";return z?"":""}};function Ym8(q){return q?q.replace(/(\n+\s*)+/g,` |
| 3110 | `):""}function o2K(q){this.options=q,this._keep=[],this._remove=[],this.blankRule={replacement:q.blankReplacement},this.keepReplacement=q.keepReplacement,this.defaultRule={replacement:q.defaultReplacement},this.array=[];for(var K in q.rules)this.array.push(q.rules[K])}o2K.prototype={add:function(q,K){this.array.unshift(K)},keep:function(q){this._keep.unshift({filter:q,replacement:this.keepReplacement})},remove:function(q){this._remove.unshift({filter:q,replacement:function(){return""}})},forNode:function(q){if(q.isBlank)return this.blankRule;var K;if(K=Ye1(this.array,q,this.options))return K;if(K=Ye1(this._keep,q,this.options))return K;if(K=Ye1(this._remove,q,this.options))return K;return this.defaultRule},forEach:function(q){for(var K=0;K<this.array.length;K++)q(this.array[K],K)}};function Ye1(q,K,_){for(var z=0;z<q.length;z++){var Y=q[z];if(P8Y(Y,K,_))return Y}return}function P8Y(q,K,_){var z=q.filter;if(typeof z==="string"){if(z===K.nodeName.toLowerCase())return!0}else if(Array.isArray(z)){if(z.indexOf(K.nodeName.toLowerCase())>-1)return!0}else if(typeof z==="function"){if(z.call(q,K,_))return!0}else throw TypeError("`filter` needs to be a string, array, or function")}function W8Y(q){var{element:K,isBlock:_,isVoid:z}=q,Y=q.isPre||function(J){return J.nodeName==="PRE"};if(!K.firstChild||Y(K))return;var $=null,A=!1,O=null,w=d2K(O,K,Y);while(w!==K){if(w.nodeType===3||w.nodeType===4){var j=w.data.replace(/[ \r\n\t]+/g," ");if((!$||/ $/.test($.data))&&!A&&j[0]===" ")j=j.substr(1);if(!j){w=$e1(w);continue}w.data=j,$=w}else if(w.nodeType===1){if(_(w)||w.nodeName==="BR"){if($)$.data=$.data.replace(/ $/,"");$=null,A=!1}else if(z(w)||Y(w))$=null,A=!0;else if($)A=!1}else{w=$e1(w);continue}var H=d2K(O,w,Y);O=w,w=H}if($){if($.data=$.data.replace(/ $/,""),!$.data)$e1($)}}function $e1(q){var K=q.nextSibling||q.parentNode;return q.parentNode.removeChild(q),K}function d2K(q,K,_){if(q&&q.parentNode===K||_(K))return K.nextSibling||K.parentNode;return K.firstChild||K.nextSibling||K.parentNode}var a2K=typeof window<"u"?window:{};function D8Y(){var q=a2K.DOMParser,K=!1;try{if(new q().parseFromString("","text/html"))K=!0}catch(_){}return K}function f8Y(){var q=function(){};{var K=Q2K();q.prototype.parseFromString=function(_){return K.createDocument(_)}}return q}var Z8Y=D8Y()?a2K.DOMParser:f8Y();function G8Y(q,K){var _;if(typeof q==="string"){var z=T8Y().parseFromString('<x-turndown id="turndown-root">'+q+"</x-turndown>","text/html");_=z.getElementById("turndown-root")}else _=q.cloneNode(!0);return W8Y({element:_,isBlock:we1,isVoid:n2K,isPre:K.preformattedCode?v8Y:null}),_}var Ae1;function T8Y(){return Ae1=Ae1||new Z8Y,Ae1}function v8Y(q){return q.nodeName==="PRE"||q.nodeName==="CODE"}function k8Y(q,K){return q.isBlock=we1(q),q.isCode=q.nodeName==="CODE"||q.parentNode.isCode,q.isBlank=V8Y(q),q.flankingWhitespace=N8Y(q,K),q}function V8Y(q){return!n2K(q)&&!M8Y(q)&&/^\s*$/i.test(q.textContent)&&!J8Y(q)&&!X8Y(q)}function N8Y(q,K){if(q.isBlock||K.preformattedCode&&q.isCode)return{leading:"",trailing:""};var _=y8Y(q.textContent);if(_.leadingAscii&&c2K("left",q,K))_.leading=_.leadingNonAscii;if(_.trailingAscii&&c2K("right",q,K))_.trailing=_.trailingNonAscii;return{leading:_.leading,trailing:_.trailing}}function y8Y(q){var K=q.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);return{leading:K[1],leadingAscii:K[2],leadingNonAscii:K[3],trailing:K[4],trailingNonAscii:K[5],trailingAscii:K[6]}}function c2K(q,K,_){var z,Y,$;if(q==="left")z=K.previousSibling,Y=/ $/;else z=K.nextSibling,Y=/^ /;if(z){if(z.nodeType===3)$=Y.test(z.nodeValue);else if(_.preformattedCode&&z.nodeName==="CODE")$=!1;else if(z.nodeType===1&&!we1(z))$=Y.test(z.textContent)}return $}var E8Y=Array.prototype.reduce,L8Y=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function $m8(q){if(!(this instanceof $m8))return new $m8(q);var K={rules:qT,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:function(_,z){return z.isBlock?` |
| 3111 | |
| 3112 | `:""},keepReplacement:function(_,z){return z.isBlock?` |
| 3113 | |
| 3114 | `+z.outerHTML+` |
| 3115 | |
| 3116 | `:z.outerHTML},defaultReplacement:function(_,z){return z.isBlock?` |
| 3117 | |
| 3118 | `+_+` |
| 3119 | |
| 3120 | `:_}};this.options=O8Y({},K,q),this.rules=new o2K(this.options)}$m8.prototype={turndown:function(q){if(!S8Y(q))throw TypeError(q+" is not a string, or an element/document/fragment node.");if(q==="")return"";var K=s2K.call(this,new G8Y(q,this.options));return R8Y.call(this,K)},use:function(q){if(Array.isArray(q))for(var K=0;K<q.length;K++)this.use(q[K]);else if(typeof q==="function")q(this);else throw TypeError("plugin must be a Function or an Array of Functions");return this},addRule:function(q,K){return this.rules.add(q,K),this},keep:function(q){return this.rules.keep(q),this},remove:function(q){return this.rules.remove(q),this},escape:function(q){return L8Y.reduce(function(K,_){return K.replace(_[0],_[1])},q)}};function s2K(q){var K=this;return E8Y.call(q.childNodes,function(_,z){z=new k8Y(z,K.options);var Y="";if(z.nodeType===3)Y=z.isCode?z.nodeValue:K.escape(z.nodeValue);else if(z.nodeType===1)Y=h8Y.call(K,z);return t2K(_,Y)},"")}function R8Y(q){var K=this;return this.rules.forEach(function(_){if(typeof _.append==="function")q=t2K(q,_.append(K.options))}),q.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function h8Y(q){var K=this.rules.forNode(q),_=s2K.call(this,q),z=q.flankingWhitespace;if(z.leading||z.trailing)_=_.trim();return z.leading+K.replacement(_,q,this.options)+z.trailing}function t2K(q,K){var _=j8Y(q),z=w8Y(K),Y=Math.max(q.length-_.length,K.length-z.length),$=` |
| 3121 | |
| 3122 | `.substring(0,Y);return _+$+z}function S8Y(q){return q!=null&&(typeof q==="string"||q.nodeType&&(q.nodeType===1||q.nodeType===9||q.nodeType===11))}e2K.exports=$m8});var AjK={};T8(AjK,{validateURL:()=>zjK,isPreapprovedUrl:()=>Pe1,isPermittedRedirect:()=>$jK,getWithPermittedRedirects:()=>We1,getURLMarkdownContent:()=>De1,clearWebFetchCache:()=>x8Y,checkDomainBlocklist:()=>YjK,applyPromptToMarkdown:()=>fe1,MAX_MARKDOWN_LENGTH:()=>y88});function x8Y(){Me1.clear(),Xe1.clear()}function u8Y(){return I8Y??=Promise.resolve().then(() => O6(qjK(),1)).then((q)=>{return new q.default})}function Pe1(q){try{let K=new URL(q);return Vu8(K.hostname,K.pathname)}catch{return!1}}function zjK(q){if(q.length>m8Y)return!1;let K;try{K=new URL(q)}catch{return!1}if(K.username||K.password)return!1;if(K.hostname.split(".").length<2)return!1;return!0}async function YjK(q){if(Xe1.has(q))return{status:"allowed"};try{let K=await $1.get(`https://api.anthropic.com/api/web/domain_info?domain=${encodeURIComponent(q)}`,{timeout:g8Y});if(K.status===200){if(K.data.can_fetch===!0)return Xe1.set(q,!0),{status:"allowed"};return{status:"blocked"}}return{status:"check_failed",error:Error(`Domain check returned status ${K.status}`)}}catch(K){return H6(K),{status:"check_failed",error:K}}}function $jK(q,K){try{let _=new URL(q),z=new URL(K);if(z.protocol!==_.protocol)return!1;if(z.port!==_.port)return!1;if(z.username||z.password)return!1;let Y=(O)=>O.replace(/^www\./,""),$=Y(_.hostname),A=Y(z.hostname);return $===A}catch(_){return!1}}async function We1(q,K,_,z=0){if(z>KjK)throw Error(`Too many redirects (exceeded ${KjK})`);try{return await $1.get(q,{signal:K,timeout:B8Y,maxRedirects:0,responseType:"arraybuffer",maxContentLength:p8Y,headers:{Accept:"text/markdown, text/html, */*","User-Agent":tCq()}})}catch(Y){if($1.isAxiosError(Y)&&Y.response&&[301,302,307,308].includes(Y.response.status)){let $=Y.response.headers.location;if(!$)throw Error("Redirect missing Location header");let A=new URL($,q).toString();if(_(q,A))return We1(A,K,_,z+1);else return{type:"redirect",originalUrl:q,redirectUrl:A,statusCode:Y.response.status}}if($1.isAxiosError(Y)&&Y.response?.status===403&&Y.response.headers["x-proxy-error"]==="blocked-by-allowlist"){let $=new URL(q).hostname;throw new _jK($)}throw Y}}function F8Y(q){return"type"in q&&q.type==="redirect"}async function De1(q,K){if(!zjK(q))throw Error("Invalid URL");let _=Me1.get(q);if(_)return{bytes:_.bytes,code:_.code,codeText:_.codeText,content:_.content,contentType:_.contentType,persistedPath:_.persistedPath,persistedSize:_.persistedSize};let z,Y=q;try{if(z=new URL(q),z.protocol==="http:")z.protocol="https:",Y=z.toString();let W=z.hostname;if(!Z7().skipWebFetchPreflight)switch((await YjK(W)).status){case"allowed":break;case"blocked":throw new He1(W);case"check_failed":throw new Je1(W)}}catch(W){if(W instanceof He1||W instanceof Je1)throw W;H6(W)}let $=await We1(Y,K.signal,$jK);if(F8Y($))return $;let A=Buffer.from($.data);$.data=null;let O=$.headers["content-type"]??"",w,j;if(_h4(O)){let W=`webfetch-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,D=await ZN6(A,O,W);if(!("error"in D))w=D.filepath,j=D.size}let H=A.length,J=A.toString("utf-8"),M,X;if(O.includes("text/html"))M=(await u8Y()).turndown(J),X=Buffer.byteLength(M);else M=J,X=H;let P={bytes:H,code:$.status,codeText:$.statusText,content:M,contentType:O,persistedPath:w,persistedSize:j};return Me1.set(q,P,{size:Math.max(1,X)}),P}async function fe1(q,K,_,z,Y){let $=K.length>y88?K.slice(0,y88)+` |