sage-agent-internal 0.1.30__py3-none-any.whl → 0.1.31rc0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. sage_agent_internal/__init__.py +16 -0
  2. {sage_agent → sage_agent_internal}/_version.py +1 -1
  3. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/install.json +5 -0
  4. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/package.json +229 -0
  5. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/schemas/sage-agent-internal/package.json.orig +224 -0
  6. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/schemas/sage-agent-internal/plugin.json +101 -0
  7. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/122.3c2c200586e65203b674.js +1 -0
  8. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/220.d384edfd5bbcfda33a2a.js +1 -0
  9. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/262.3fc4ad88e6f8c273d4ad.js +1 -0
  10. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/353.2c285601a208c3735929.js +1 -0
  11. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/363.d6c25400a011b62fbae6.js +1 -0
  12. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/364.c2fb82c6f484097228c6.js +1 -0
  13. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/439.3cb9ac7022c8a6074647.js +1 -0
  14. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/481.96b91d018df31d54d173.js +1 -0
  15. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/553.b7906877d98a62265533.js +2 -0
  16. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/553.b7906877d98a62265533.js.LICENSE.txt +15 -0
  17. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/635.8c395c854aa2b140b668.js +1 -0
  18. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/713.103cb5ae248be385b08a.js +1 -0
  19. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/742.b204789055ded4e07883.js +1 -0
  20. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/747.b8e9485ebcbb3066eb4b.js +1 -0
  21. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/821.b58f29814f5900f1f6f8.js +1 -0
  22. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/833.1509794f6b586558f96c.js +1 -0
  23. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/845.cc2bc80fbfea6d20a396.js +1 -0
  24. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/888.09382cc93a2ad3932b31.js +1 -0
  25. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/973.38ee5148a3908e41c2dd.js +2 -0
  26. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/973.38ee5148a3908e41c2dd.js.LICENSE.txt +1 -0
  27. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/remoteEntry.b4d298844205dc8d9771.js +1 -0
  28. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/style.js +4 -0
  29. sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/third-party-licenses.json +298 -0
  30. {sage_agent_internal-0.1.30.dist-info → sage_agent_internal-0.1.31rc0.dist-info}/METADATA +12 -12
  31. sage_agent_internal-0.1.31rc0.dist-info/RECORD +33 -0
  32. sage_agent_internal-0.1.30.data/data/share/jupyter/labextensions/sage-agent/install.json +0 -5
  33. sage_agent_internal-0.1.30.dist-info/RECORD +0 -6
  34. {sage_agent_internal-0.1.30.dist-info → sage_agent_internal-0.1.31rc0.dist-info}/WHEEL +0 -0
  35. {sage_agent_internal-0.1.30.dist-info → sage_agent_internal-0.1.31rc0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunksage_agent_internal=self.webpackChunksage_agent_internal||[]).push([[713],{5713:(e,n,t)=>{function r(){}function i(e,n,t,r,i){for(var o,l=[];n;)l.push(n),o=n.previousComponent,delete n.previousComponent,n=o;l.reverse();for(var a=0,u=l.length,s=0,f=0;a<u;a++){var c=l[a];if(c.removed)c.value=e.join(r.slice(f,f+c.count)),f+=c.count;else{if(!c.added&&i){var d=t.slice(s,s+c.count);d=d.map(function(e,n){var t=r[f+n];return t.length>e.length?t:e}),c.value=e.join(d)}else c.value=e.join(t.slice(s,s+c.count));s+=c.count,c.added||(f+=c.count)}}return l}t.r(n),t.d(n,{Diff:()=>r,applyPatch:()=>q,applyPatches:()=>R,canonicalize:()=>W,convertChangesToDMP:()=>he,convertChangesToXML:()=>ve,createPatch:()=>Z,createTwoFilesPatch:()=>X,diffArrays:()=>z,diffChars:()=>l,diffCss:()=>N,diffJson:()=>T,diffLines:()=>L,diffSentences:()=>P,diffTrimmedLines:()=>S,diffWords:()=>m,diffWordsWithSpace:()=>b,formatPatch:()=>U,merge:()=>K,parsePatch:()=>$,reversePatch:()=>de,structuredPatch:()=>_}),r.prototype={diff:function(e,n){var t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.callback;"function"==typeof r&&(o=r,r={});var l=this;function a(e){return e=l.postProcess(e,r),o?(setTimeout(function(){o(e)},0),!0):e}e=this.castInput(e,r),n=this.castInput(n,r),e=this.removeEmpty(this.tokenize(e,r));var u=(n=this.removeEmpty(this.tokenize(n,r))).length,s=e.length,f=1,c=u+s;null!=r.maxEditLength&&(c=Math.min(c,r.maxEditLength));var d=null!==(t=r.timeout)&&void 0!==t?t:1/0,h=Date.now()+d,v=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(v[0],n,e,0,r);if(v[0].oldPos+1>=s&&p+1>=u)return a(i(l,v[0].lastComponent,n,e,l.useLongestToken));var g=-1/0,m=1/0;function w(){for(var t=Math.max(g,-f);t<=Math.min(m,f);t+=2){var o=void 0,c=v[t-1],d=v[t+1];c&&(v[t-1]=void 0);var h=!1;if(d){var w=d.oldPos-t;h=d&&0<=w&&w<u}var y=c&&c.oldPos+1<s;if(h||y){if(o=!y||h&&c.oldPos<d.oldPos?l.addToPath(d,!0,!1,0,r):l.addToPath(c,!1,!0,1,r),p=l.extractCommon(o,n,e,t,r),o.oldPos+1>=s&&p+1>=u)return a(i(l,o.lastComponent,n,e,l.useLongestToken));v[t]=o,o.oldPos+1>=s&&(m=Math.min(m,t-1)),p+1>=u&&(g=Math.max(g,t+1))}else v[t]=void 0}f++}if(o)!function e(){setTimeout(function(){if(f>c||Date.now()>h)return o();w()||e()},0)}();else for(;f<=c&&Date.now()<=h;){var y=w();if(y)return y}},addToPath:function(e,n,t,r,i){var o=e.lastComponent;return o&&!i.oneChangePerToken&&o.added===n&&o.removed===t?{oldPos:e.oldPos+r,lastComponent:{count:o.count+1,added:n,removed:t,previousComponent:o.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:n,removed:t,previousComponent:o}}},extractCommon:function(e,n,t,r,i){for(var o=n.length,l=t.length,a=e.oldPos,u=a-r,s=0;u+1<o&&a+1<l&&this.equals(t[a+1],n[u+1],i);)u++,a++,s++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return s&&!i.oneChangePerToken&&(e.lastComponent={count:s,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,u},equals:function(e,n,t){return t.comparator?t.comparator(e,n):e===n||t.ignoreCase&&e.toLowerCase()===n.toLowerCase()},removeEmpty:function(e){for(var n=[],t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n},castInput:function(e){return e},tokenize:function(e){return Array.from(e)},join:function(e){return e.join("")},postProcess:function(e){return e}};var o=new r;function l(e,n,t){return o.diff(e,n,t)}function a(e,n){var t;for(t=0;t<e.length&&t<n.length;t++)if(e[t]!=n[t])return e.slice(0,t);return e.slice(0,t)}function u(e,n){var t;if(!e||!n||e[e.length-1]!=n[n.length-1])return"";for(t=0;t<e.length&&t<n.length;t++)if(e[e.length-(t+1)]!=n[n.length-(t+1)])return e.slice(-t);return e.slice(-t)}function s(e,n,t){if(e.slice(0,n.length)!=n)throw Error("string ".concat(JSON.stringify(e)," doesn't start with prefix ").concat(JSON.stringify(n),"; this is a bug"));return t+e.slice(n.length)}function f(e,n,t){if(!n)return e+t;if(e.slice(-n.length)!=n)throw Error("string ".concat(JSON.stringify(e)," doesn't end with suffix ").concat(JSON.stringify(n),"; this is a bug"));return e.slice(0,-n.length)+t}function c(e,n){return s(e,n,"")}function d(e,n){return f(e,n,"")}function h(e,n){return n.slice(0,function(e,n){var t=0;e.length>n.length&&(t=e.length-n.length);var r=n.length;e.length<n.length&&(r=e.length);var i=Array(r),o=0;i[0]=0;for(var l=1;l<r;l++){for(n[l]==n[o]?i[l]=i[o]:i[l]=o;o>0&&n[l]!=n[o];)o=i[o];n[l]==n[o]&&o++}o=0;for(var a=t;a<e.length;a++){for(;o>0&&e[a]!=n[o];)o=i[o];e[a]==n[o]&&o++}return o}(e,n))}var v="a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",p=new RegExp("[".concat(v,"]+|\\s+|[^").concat(v,"]"),"ug"),g=new r;function m(e,n,t){return null==(null==t?void 0:t.ignoreWhitespace)||t.ignoreWhitespace?g.diff(e,n,t):b(e,n,t)}function w(e,n,t,r){if(n&&t){var i=n.value.match(/^\s*/)[0],o=n.value.match(/\s*$/)[0],l=t.value.match(/^\s*/)[0],v=t.value.match(/\s*$/)[0];if(e){var p=a(i,l);e.value=f(e.value,l,p),n.value=c(n.value,p),t.value=c(t.value,p)}if(r){var g=u(o,v);r.value=s(r.value,v,g),n.value=d(n.value,g),t.value=d(t.value,g)}}else if(t)e&&(t.value=t.value.replace(/^\s*/,"")),r&&(r.value=r.value.replace(/^\s*/,""));else if(e&&r){var m=r.value.match(/^\s*/)[0],w=n.value.match(/^\s*/)[0],y=n.value.match(/\s*$/)[0],b=a(m,w);n.value=c(n.value,b);var k=u(c(m,b),y);n.value=d(n.value,k),r.value=s(r.value,m,k),e.value=f(e.value,m,m.slice(0,m.length-k.length))}else if(r){var L=r.value.match(/^\s*/)[0],S=h(n.value.match(/\s*$/)[0],L);n.value=d(n.value,S)}else if(e){var x=h(e.value.match(/\s*$/)[0],n.value.match(/^\s*/)[0]);n.value=c(n.value,x)}}g.equals=function(e,n,t){return t.ignoreCase&&(e=e.toLowerCase(),n=n.toLowerCase()),e.trim()===n.trim()},g.tokenize=function(e){var n,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.intlSegmenter){if("word"!=t.intlSegmenter.resolvedOptions().granularity)throw new Error('The segmenter passed must have a granularity of "word"');n=Array.from(t.intlSegmenter.segment(e),function(e){return e.segment})}else n=e.match(p)||[];var r=[],i=null;return n.forEach(function(e){/\s/.test(e)?null==i?r.push(e):r.push(r.pop()+e):/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r},g.join=function(e){return e.map(function(e,n){return 0==n?e:e.replace(/^\s+/,"")}).join("")},g.postProcess=function(e,n){if(!e||n.oneChangePerToken)return e;var t=null,r=null,i=null;return e.forEach(function(e){e.added?r=e:e.removed?i=e:((r||i)&&w(t,i,r,e),t=e,r=null,i=null)}),(r||i)&&w(t,i,r,null),e};var y=new r;function b(e,n,t){return y.diff(e,n,t)}y.tokenize=function(e){var n=new RegExp("(\\r?\\n)|[".concat(v,"]+|[^\\S\\n\\r]+|[^").concat(v,"]"),"ug");return e.match(n)||[]};var k=new r;function L(e,n,t){return k.diff(e,n,t)}function S(e,n,t){var r=function(e,n){if("function"==typeof e)n.callback=e;else if(e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}(t,{ignoreWhitespace:!0});return k.diff(e,n,r)}k.tokenize=function(e,n){n.stripTrailingCr&&(e=e.replace(/\r\n/g,"\n"));var t=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(var i=0;i<r.length;i++){var o=r[i];i%2&&!n.newlineIsToken?t[t.length-1]+=o:t.push(o)}return t},k.equals=function(e,n,t){return t.ignoreWhitespace?(t.newlineIsToken&&e.includes("\n")||(e=e.trim()),t.newlineIsToken&&n.includes("\n")||(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith("\n")&&(e=e.slice(0,-1)),n.endsWith("\n")&&(n=n.slice(0,-1))),r.prototype.equals.call(this,e,n,t)};var x=new r;function P(e,n,t){return x.diff(e,n,t)}x.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var F=new r;function N(e,n,t){return F.diff(e,n,t)}function C(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function j(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?C(Object(t),!0).forEach(function(n){var r,i,o;r=e,i=n,o=t[n],(i=function(e){var n=function(e,n){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:n+""}(i))in r?Object.defineProperty(r,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[i]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):C(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function O(e){return O="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},O(e)}function E(e){return function(e){if(Array.isArray(e))return A(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return A(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?A(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}F.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};var H=new r;function T(e,n,t){return H.diff(e,n,t)}function W(e,n,t,r,i){var o,l;for(n=n||[],t=t||[],r&&(e=r(i,e)),o=0;o<n.length;o+=1)if(n[o]===e)return t[o];if("[object Array]"===Object.prototype.toString.call(e)){for(n.push(e),l=new Array(e.length),t.push(l),o=0;o<e.length;o+=1)l[o]=W(e[o],n,t,r,i);return n.pop(),t.pop(),l}if(e&&e.toJSON&&(e=e.toJSON()),"object"===O(e)&&null!==e){n.push(e),l={},t.push(l);var a,u=[];for(a in e)Object.prototype.hasOwnProperty.call(e,a)&&u.push(a);for(u.sort(),o=0;o<u.length;o+=1)l[a=u[o]]=W(e[a],n,t,r,a);n.pop(),t.pop()}else l=e;return l}H.useLongestToken=!0,H.tokenize=k.tokenize,H.castInput=function(e,n){var t=n.undefinedReplacement,r=n.stringifyReplacer,i=void 0===r?function(e,n){return void 0===n?t:n}:r;return"string"==typeof e?e:JSON.stringify(W(e,null,null,i),i," ")},H.equals=function(e,n,t){return r.prototype.equals.call(H,e.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"),t)};var I=new r;function z(e,n,t){return I.diff(e,n,t)}function D(e){return Array.isArray(e)?e.map(D):j(j({},e),{},{hunks:e.hunks.map(function(e){return j(j({},e),{},{lines:e.lines.map(function(n,t){var r;return n.startsWith("\\")||n.endsWith("\r")||null!==(r=e.lines[t+1])&&void 0!==r&&r.startsWith("\\")?n:n+"\r"})})})})}function M(e){return Array.isArray(e)?e.map(M):j(j({},e),{},{hunks:e.hunks.map(function(e){return j(j({},e),{},{lines:e.lines.map(function(e){return e.endsWith("\r")?e.substring(0,e.length-1):e})})})})}function $(e){var n=e.split(/\n/),t=[],r=0;function i(){var e={};for(t.push(e);r<n.length;){var i=n[r];if(/^(\-\-\-|\+\+\+|@@)\s/.test(i))break;var a=/^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(i);a&&(e.index=a[1]),r++}for(o(e),o(e),e.hunks=[];r<n.length;){var u=n[r];if(/^(Index:\s|diff\s|\-\-\-\s|\+\+\+\s|===================================================================)/.test(u))break;if(/^@@/.test(u))e.hunks.push(l());else{if(u)throw new Error("Unknown line "+(r+1)+" "+JSON.stringify(u));r++}}}function o(e){var t=/^(---|\+\+\+)\s+(.*)\r?$/.exec(n[r]);if(t){var i="---"===t[1]?"old":"new",o=t[2].split("\t",2),l=o[0].replace(/\\\\/g,"\\");/^".*"$/.test(l)&&(l=l.substr(1,l.length-2)),e[i+"FileName"]=l,e[i+"Header"]=(o[1]||"").trim(),r++}}function l(){var e=r,t=n[r++].split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),i={oldStart:+t[1],oldLines:void 0===t[2]?1:+t[2],newStart:+t[3],newLines:void 0===t[4]?1:+t[4],lines:[]};0===i.oldLines&&(i.oldStart+=1),0===i.newLines&&(i.newStart+=1);for(var o=0,l=0;r<n.length&&(l<i.oldLines||o<i.newLines||null!==(a=n[r])&&void 0!==a&&a.startsWith("\\"));r++){var a,u=0==n[r].length&&r!=n.length-1?" ":n[r][0];if("+"!==u&&"-"!==u&&" "!==u&&"\\"!==u)throw new Error("Hunk at line ".concat(e+1," contained invalid line ").concat(n[r]));i.lines.push(n[r]),"+"===u?o++:"-"===u?l++:" "===u&&(o++,l++)}if(o||1!==i.newLines||(i.newLines=0),l||1!==i.oldLines||(i.oldLines=0),o!==i.newLines)throw new Error("Added line count did not match for hunk at line "+(e+1));if(l!==i.oldLines)throw new Error("Removed line count did not match for hunk at line "+(e+1));return i}for(;r<n.length;)i();return t}function J(e,n,t){var r=!0,i=!1,o=!1,l=1;return function a(){if(r&&!o){if(i?l++:r=!1,e+l<=t)return e+l;o=!0}if(!i)return o||(r=!0),n<=e-l?e-l++:(i=!0,a())}}function q(e,n){var t,r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("string"==typeof n&&(n=$(n)),Array.isArray(n)){if(n.length>1)throw new Error("applyPatch only works with a single input.");n=n[0]}(i.autoConvertLineEndings||null==i.autoConvertLineEndings)&&(!(r=e).includes("\r\n")||r.startsWith("\n")||r.match(/[^\r]\n/)||(t=n,Array.isArray(t)||(t=[t]),t.some(function(e){return e.hunks.some(function(e){return e.lines.some(function(e){return!e.startsWith("\\")&&e.endsWith("\r")})})}))?function(e){return!e.includes("\r\n")&&e.includes("\n")}(e)&&function(e){return Array.isArray(e)||(e=[e]),e.some(function(e){return e.hunks.some(function(e){return e.lines.some(function(e){return e.endsWith("\r")})})})&&e.every(function(e){return e.hunks.every(function(e){return e.lines.every(function(n,t){var r;return n.startsWith("\\")||n.endsWith("\r")||(null===(r=e.lines[t+1])||void 0===r?void 0:r.startsWith("\\"))})})})}(n)&&(n=M(n)):n=D(n));var o=e.split("\n"),l=n.hunks,a=i.compareLine||function(e,n,t,r){return n===r},u=i.fuzzFactor||0,s=0;if(u<0||!Number.isInteger(u))throw new Error("fuzzFactor must be a non-negative integer");if(!l.length)return e;for(var f="",c=!1,d=!1,h=0;h<l[l.length-1].lines.length;h++){var v=l[l.length-1].lines[h];"\\"==v[0]&&("+"==f[0]?c=!0:"-"==f[0]&&(d=!0)),f=v}if(c){if(d){if(!u&&""==o[o.length-1])return!1}else if(""==o[o.length-1])o.pop();else if(!u)return!1}else if(d)if(""!=o[o.length-1])o.push("");else if(!u)return!1;function p(e,n,t){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[],u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,s=0,f=!1;r<e.length;r++){var c=e[r],d=c.length>0?c[0]:" ",h=c.length>0?c.substr(1):c;if("-"===d){if(!a(n+1,o[n],d,h))return t&&null!=o[n]?(l[u]=o[n],p(e,n+1,t-1,r,!1,l,u+1)):null;n++,s=0}if("+"===d){if(!i)return null;l[u]=h,u++,s=0,f=!0}if(" "===d){if(s++,l[u]=o[n],!a(n+1,o[n],d,h))return f||!t?null:o[n]&&(p(e,n+1,t-1,r+1,!1,l,u+1)||p(e,n+1,t-1,r,!1,l,u+1))||p(e,n,t-1,r+1,!1,l,u);u++,i=!0,f=!1,n++}}return u-=s,n-=s,l.length=u,{patchedLines:l,oldLineLastI:n-1}}for(var g=[],m=0,w=0;w<l.length;w++){for(var y=l[w],b=void 0,k=o.length-y.oldLines+u,L=void 0,S=0;S<=u;S++){for(var x=J(L=y.oldStart+m-1,s,k);void 0!==L&&!(b=p(y.lines,L,S));L=x());if(b)break}if(!b)return!1;for(var P=s;P<L;P++)g.push(o[P]);for(var F=0;F<b.patchedLines.length;F++){var N=b.patchedLines[F];g.push(N)}s=b.oldLineLastI+1,m=L+1-y.oldStart}for(var C=s;C<o.length;C++)g.push(o[C]);return g.join("\n")}function R(e,n){"string"==typeof e&&(e=$(e));var t=0;!function r(){var i=e[t++];if(!i)return n.complete();n.loadFile(i,function(e,t){if(e)return n.complete(e);var o=q(t,i,n);n.patched(i,o,function(e){if(e)return n.complete(e);r()})})}()}function _(e,n,t,r,i,o,l){if(l||(l={}),"function"==typeof l&&(l={callback:l}),void 0===l.context&&(l.context=4),l.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(!l.callback)return u(L(t,r,l));var a=l.callback;function u(t){if(t){t.push({value:"",lines:[]});for(var r=[],a=0,u=0,s=[],f=1,c=1,d=function(){var e,n,i,o=t[h],d=o.lines||(e=o.value,n=e.endsWith("\n"),i=e.split("\n").map(function(e){return e+"\n"}),n?i.pop():i.push(i.pop().slice(0,-1)),i);if(o.lines=d,o.added||o.removed){var v;if(!a){var p=t[h-1];a=f,u=c,p&&(s=l.context>0?w(p.lines.slice(-l.context)):[],a-=s.length,u-=s.length)}(v=s).push.apply(v,E(d.map(function(e){return(o.added?"+":"-")+e}))),o.added?c+=d.length:f+=d.length}else{if(a)if(d.length<=2*l.context&&h<t.length-2){var g;(g=s).push.apply(g,E(w(d)))}else{var m,y=Math.min(d.length,l.context);(m=s).push.apply(m,E(w(d.slice(0,y))));var b={oldStart:a,oldLines:f-a+y,newStart:u,newLines:c-u+y,lines:s};r.push(b),a=0,u=0,s=[]}f+=d.length,c+=d.length}},h=0;h<t.length;h++)d();for(var v=0,p=r;v<p.length;v++)for(var g=p[v],m=0;m<g.lines.length;m++)g.lines[m].endsWith("\n")?g.lines[m]=g.lines[m].slice(0,-1):(g.lines.splice(m+1,0,"\"),m++);return{oldFileName:e,newFileName:n,oldHeader:i,newHeader:o,hunks:r}}function w(e){return e.map(function(e){return" "+e})}}L(t,r,j(j({},l),{},{callback:function(e){var n=u(e);a(n)}}))}function U(e){if(Array.isArray(e))return e.map(U).join("\n");var n=[];e.oldFileName==e.newFileName&&n.push("Index: "+e.oldFileName),n.push("==================================================================="),n.push("--- "+e.oldFileName+(void 0===e.oldHeader?"":"\t"+e.oldHeader)),n.push("+++ "+e.newFileName+(void 0===e.newHeader?"":"\t"+e.newHeader));for(var t=0;t<e.hunks.length;t++){var r=e.hunks[t];0===r.oldLines&&(r.oldStart-=1),0===r.newLines&&(r.newStart-=1),n.push("@@ -"+r.oldStart+","+r.oldLines+" +"+r.newStart+","+r.newLines+" @@"),n.push.apply(n,r.lines)}return n.join("\n")+"\n"}function X(e,n,t,r,i,o,l){var a;if("function"==typeof l&&(l={callback:l}),null===(a=l)||void 0===a||!a.callback){var u=_(e,n,t,r,i,o,l);if(!u)return;return U(u)}var s=l.callback;_(e,n,t,r,i,o,j(j({},l),{},{callback:function(e){e?s(U(e)):s()}}))}function Z(e,n,t,r,i,o){return X(e,e,n,t,r,i,o)}function B(e,n){if(n.length>e.length)return!1;for(var t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function G(e){var n=ce(e.lines),t=n.oldLines,r=n.newLines;void 0!==t?e.oldLines=t:delete e.oldLines,void 0!==r?e.newLines=r:delete e.newLines}function K(e,n,t){e=Q(e,t),n=Q(n,t);var r={};(e.index||n.index)&&(r.index=e.index||n.index),(e.newFileName||n.newFileName)&&(V(e)?V(n)?(r.oldFileName=Y(r,e.oldFileName,n.oldFileName),r.newFileName=Y(r,e.newFileName,n.newFileName),r.oldHeader=Y(r,e.oldHeader,n.oldHeader),r.newHeader=Y(r,e.newHeader,n.newHeader)):(r.oldFileName=e.oldFileName,r.newFileName=e.newFileName,r.oldHeader=e.oldHeader,r.newHeader=e.newHeader):(r.oldFileName=n.oldFileName||e.oldFileName,r.newFileName=n.newFileName||e.newFileName,r.oldHeader=n.oldHeader||e.oldHeader,r.newHeader=n.newHeader||e.newHeader)),r.hunks=[];for(var i=0,o=0,l=0,a=0;i<e.hunks.length||o<n.hunks.length;){var u=e.hunks[i]||{oldStart:1/0},s=n.hunks[o]||{oldStart:1/0};if(ee(u,s))r.hunks.push(ne(u,l)),i++,a+=u.newLines-u.oldLines;else if(ee(s,u))r.hunks.push(ne(s,a)),o++,l+=s.newLines-s.oldLines;else{var f={oldStart:Math.min(u.oldStart,s.oldStart),oldLines:0,newStart:Math.min(u.newStart+l,s.oldStart+a),newLines:0,lines:[]};te(f,u.oldStart,u.lines,s.oldStart,s.lines),o++,i++,r.hunks.push(f)}}return r}function Q(e,n){if("string"==typeof e){if(/^@@/m.test(e)||/^Index:/m.test(e))return $(e)[0];if(!n)throw new Error("Must provide a base reference or pass in a patch");return _(void 0,void 0,n,e)}return e}function V(e){return e.newFileName&&e.newFileName!==e.oldFileName}function Y(e,n,t){return n===t?n:(e.conflict=!0,{mine:n,theirs:t})}function ee(e,n){return e.oldStart<n.oldStart&&e.oldStart+e.oldLines<n.oldStart}function ne(e,n){return{oldStart:e.oldStart,oldLines:e.oldLines,newStart:e.newStart+n,newLines:e.newLines,lines:e.lines}}function te(e,n,t,r,i){var o={offset:n,lines:t,index:0},l={offset:r,lines:i,index:0};for(le(e,o,l),le(e,l,o);o.index<o.lines.length&&l.index<l.lines.length;){var a=o.lines[o.index],u=l.lines[l.index];if("-"!==a[0]&&"+"!==a[0]||"-"!==u[0]&&"+"!==u[0])if("+"===a[0]&&" "===u[0]){var s;(s=e.lines).push.apply(s,E(ue(o)))}else if("+"===u[0]&&" "===a[0]){var f;(f=e.lines).push.apply(f,E(ue(l)))}else"-"===a[0]&&" "===u[0]?ie(e,o,l):"-"===u[0]&&" "===a[0]?ie(e,l,o,!0):a===u?(e.lines.push(a),o.index++,l.index++):oe(e,ue(o),ue(l));else re(e,o,l)}ae(e,o),ae(e,l),G(e)}function re(e,n,t){var r,i,o=ue(n),l=ue(t);if(se(o)&&se(l)){var a,u;if(B(o,l)&&fe(t,o,o.length-l.length))return void(a=e.lines).push.apply(a,E(o));if(B(l,o)&&fe(n,l,l.length-o.length))return void(u=e.lines).push.apply(u,E(l))}else if(i=l,(r=o).length===i.length&&B(r,i)){var s;return void(s=e.lines).push.apply(s,E(o))}oe(e,o,l)}function ie(e,n,t,r){var i,o=ue(n),l=function(e,n){for(var t=[],r=[],i=0,o=!1,l=!1;i<n.length&&e.index<e.lines.length;){var a=e.lines[e.index],u=n[i];if("+"===u[0])break;if(o=o||" "!==a[0],r.push(u),i++,"+"===a[0])for(l=!0;"+"===a[0];)t.push(a),a=e.lines[++e.index];u.substr(1)===a.substr(1)?(t.push(a),e.index++):l=!0}if("+"===(n[i]||"")[0]&&o&&(l=!0),l)return t;for(;i<n.length;)r.push(n[i++]);return{merged:r,changes:t}}(t,o);l.merged?(i=e.lines).push.apply(i,E(l.merged)):oe(e,r?l:o,r?o:l)}function oe(e,n,t){e.conflict=!0,e.lines.push({conflict:!0,mine:n,theirs:t})}function le(e,n,t){for(;n.offset<t.offset&&n.index<n.lines.length;){var r=n.lines[n.index++];e.lines.push(r),n.offset++}}function ae(e,n){for(;n.index<n.lines.length;){var t=n.lines[n.index++];e.lines.push(t)}}function ue(e){for(var n=[],t=e.lines[e.index][0];e.index<e.lines.length;){var r=e.lines[e.index];if("-"===t&&"+"===r[0]&&(t="+"),t!==r[0])break;n.push(r),e.index++}return n}function se(e){return e.reduce(function(e,n){return e&&"-"===n[0]},!0)}function fe(e,n,t){for(var r=0;r<t;r++){var i=n[n.length-t+r].substr(1);if(e.lines[e.index+r]!==" "+i)return!1}return e.index+=t,!0}function ce(e){var n=0,t=0;return e.forEach(function(e){if("string"!=typeof e){var r=ce(e.mine),i=ce(e.theirs);void 0!==n&&(r.oldLines===i.oldLines?n+=r.oldLines:n=void 0),void 0!==t&&(r.newLines===i.newLines?t+=r.newLines:t=void 0)}else void 0===t||"+"!==e[0]&&" "!==e[0]||t++,void 0===n||"-"!==e[0]&&" "!==e[0]||n++}),{oldLines:n,newLines:t}}function de(e){return Array.isArray(e)?e.map(de).reverse():j(j({},e),{},{oldFileName:e.newFileName,oldHeader:e.newHeader,newFileName:e.oldFileName,newHeader:e.oldHeader,hunks:e.hunks.map(function(e){return{oldLines:e.newLines,oldStart:e.newStart,newLines:e.oldLines,newStart:e.oldStart,lines:e.lines.map(function(e){return e.startsWith("-")?"+".concat(e.slice(1)):e.startsWith("+")?"-".concat(e.slice(1)):e})}})})}function he(e){for(var n,t,r=[],i=0;i<e.length;i++)t=(n=e[i]).added?1:n.removed?-1:0,r.push([t,n.value]);return r}function ve(e){for(var n=[],t=0;t<e.length;t++){var r=e[t];r.added?n.push("<ins>"):r.removed&&n.push("<del>"),n.push(pe(r.value)),r.added?n.push("</ins>"):r.removed&&n.push("</del>")}return n.join("")}function pe(e){var n=e;return(n=(n=(n=n.replace(/&/g,"&amp;")).replace(/</g,"&lt;")).replace(/>/g,"&gt;")).replace(/"/g,"&quot;")}I.tokenize=function(e){return e.slice()},I.join=I.removeEmpty=function(e){return e}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunksage_agent_internal=self.webpackChunksage_agent_internal||[]).push([[742],{2742:(e,t,s)=>{function n(e,t,s,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,s):r?r.value=s:t.set(e,s),s}function r(e,t,s,n){if("a"===s&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?n:"a"===s?n.call(e):n?n.value:t.get(e)}s.r(t),s.d(t,{AI_PROMPT:()=>Xt,APIConnectionError:()=>u,APIConnectionTimeoutError:()=>d,APIError:()=>l,APIPromise:()=>se,APIUserAbortError:()=>h,Anthropic:()=>Ct,AnthropicError:()=>c,AuthenticationError:()=>p,BadRequestError:()=>f,BaseAnthropic:()=>Wt,ConflictError:()=>y,HUMAN_PROMPT:()=>Dt,InternalServerError:()=>_,NotFoundError:()=>m,PagePromise:()=>re,PermissionDeniedError:()=>g,RateLimitError:()=>w,UnprocessableEntityError:()=>b,default:()=>Ct,toFile:()=>me});let i=function(){const{crypto:e}=globalThis;if(e?.randomUUID)return i=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),s=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^s()&15>>+e/4).toString(16))};function o(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e.name||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const a=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e){try{if("[object Error]"===Object.prototype.toString.call(e)){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};class c extends Error{}class l extends c{constructor(e,t,s,n){super(`${l.makeMessage(e,t,s)}`),this.status=e,this.headers=n,this.requestID=n?.get("request-id"),this.error=t}static makeMessage(e,t,s){const n=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):s;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(e,t,s,n){if(!e||!n)return new u({message:s,cause:a(t)});const r=t;return 400===e?new f(e,r,s,n):401===e?new p(e,r,s,n):403===e?new g(e,r,s,n):404===e?new m(e,r,s,n):409===e?new y(e,r,s,n):422===e?new b(e,r,s,n):429===e?new w(e,r,s,n):e>=500?new _(e,r,s,n):new l(e,r,s,n)}}class h extends l{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class u extends l{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class d extends u{constructor({message:e}={}){super({message:e??"Request timed out."})}}class f extends l{}class p extends l{}class g extends l{}class m extends l{}class y extends l{}class b extends l{}class w extends l{}class _ extends l{}const v=/^[a-z][a-z0-9+.-]*:/i;function k(e){return"object"!=typeof e?{}:e??{}}const S=e=>{try{return JSON.parse(e)}catch(e){return}},R={off:0,error:200,warn:300,info:400,debug:500},x=(e,t,s)=>{var n,r;if(e)return n=R,r=e,Object.prototype.hasOwnProperty.call(n,r)?e:void E(s).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(R))}`)};function M(){}function P(e,t,s){return!t||R[e]>R[s]?M:t[e].bind(t)}const A={error:M,warn:M,info:M,debug:M};let T=new WeakMap;function E(e){const t=e.logger,s=e.logLevel??"off";if(!t)return A;const n=T.get(t);if(n&&n[0]===s)return n[1];const r={error:P("error",t,s),warn:P("warn",t,s),info:P("info",t,s),debug:P("debug",t,s)};return T.set(t,[s,r]),r}const $=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,"x-api-key"===e.toLowerCase()||"authorization"===e.toLowerCase()||"cookie"===e.toLowerCase()||"set-cookie"===e.toLowerCase()?"***":t]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),I="0.54.0",O=()=>{const e="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":I,"X-Stainless-OS":L(Deno.build.os),"X-Stainless-Arch":q(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":I,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":I,"X-Stainless-OS":L(globalThis.process.platform??"unknown"),"X-Stainless-Arch":q(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const t=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:s}of e){const e=s.exec(navigator.userAgent);if(e)return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":I,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":I,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},q=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",L=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let j;function N(...e){const t=globalThis.ReadableStream;if(void 0===t)throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function U(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return N({start(){},async pull(e){const{done:s,value:n}=await t.next();s?e.close():e.enqueue(n)},async cancel(){await(t.return?.())}})}function W(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}const C=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});let D,X;function H(e){let t;return(D??(t=new globalThis.TextEncoder,D=t.encode.bind(t)))(e)}function B(e){let t;return(X??(t=new globalThis.TextDecoder,X=t.decode.bind(t)))(e)}var F,J,K,V;class z{constructor(){F.set(this,void 0),J.set(this,void 0),n(this,F,new Uint8Array,"f"),n(this,J,null,"f")}decode(e){if(null==e)return[];const t=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?H(e):e;n(this,F,function(e){let t=0;for(const s of e)t+=s.length;const s=new Uint8Array(t);let n=0;for(const t of e)s.set(t,n),n+=t.length;return s}([r(this,F,"f"),t]),"f");const s=[];let i;for(;null!=(i=G(r(this,F,"f"),r(this,J,"f")));){if(i.carriage&&null==r(this,J,"f")){n(this,J,i.index,"f");continue}if(null!=r(this,J,"f")&&(i.index!==r(this,J,"f")+1||i.carriage)){s.push(B(r(this,F,"f").subarray(0,r(this,J,"f")-1))),n(this,F,r(this,F,"f").subarray(r(this,J,"f")),"f"),n(this,J,null,"f");continue}const e=null!==r(this,J,"f")?i.preceding-1:i.preceding,t=B(r(this,F,"f").subarray(0,e));s.push(t),n(this,F,r(this,F,"f").subarray(i.index),"f"),n(this,J,null,"f")}return s}flush(){return r(this,F,"f").length?this.decode("\n"):[]}}function G(e,t){for(let s=t??0;s<e.length;s++){if(10===e[s])return{preceding:s,index:s+1,carriage:!1};if(13===e[s])return{preceding:s,index:s+1,carriage:!0}}return null}function Q(e){for(let t=0;t<e.length-1;t++){if(10===e[t]&&10===e[t+1])return t+2;if(13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return-1}F=new WeakMap,J=new WeakMap,z.NEWLINE_CHARS=new Set(["\n","\r"]),z.NEWLINE_REGEXP=/\r\n|[\n\r]/g;class Y{constructor(e,t){this.iterator=e,this.controller=t}static fromSSEResponse(e,t){let s=!1;return new Y(async function*(){if(s)throw new c("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let n=!1;try{for await(const s of async function*(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new c("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new c("Attempted to iterate over a response with no body")}const s=new Z,n=new z,r=W(e.body);for await(const e of async function*(e){let t=new Uint8Array;for await(const s of e){if(null==s)continue;const e=s instanceof ArrayBuffer?new Uint8Array(s):"string"==typeof s?H(s):s;let n,r=new Uint8Array(t.length+e.length);for(r.set(t),r.set(e,t.length),t=r;-1!==(n=Q(t));)yield t.slice(0,n),t=t.slice(n)}t.length>0&&(yield t)}(r))for(const t of n.decode(e)){const e=s.decode(t);e&&(yield e)}for(const e of n.flush()){const t=s.decode(e);t&&(yield t)}}(e,t)){if("completion"===s.event)try{yield JSON.parse(s.data)}catch(e){throw console.error("Could not parse message into JSON:",s.data),console.error("From chunk:",s.raw),e}if("message_start"===s.event||"message_delta"===s.event||"message_stop"===s.event||"content_block_start"===s.event||"content_block_delta"===s.event||"content_block_stop"===s.event)try{yield JSON.parse(s.data)}catch(e){throw console.error("Could not parse message into JSON:",s.data),console.error("From chunk:",s.raw),e}if("ping"!==s.event&&"error"===s.event)throw new l(void 0,S(s.data)??s.data,void 0,e.headers)}n=!0}catch(e){if(o(e))return;throw e}finally{n||t.abort()}},t)}static fromReadableStream(e,t){let s=!1;return new Y(async function*(){if(s)throw new c("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let n=!1;try{for await(const t of async function*(){const t=new z,s=W(e);for await(const e of s)for(const s of t.decode(e))yield s;for(const e of t.flush())yield e}())n||t&&(yield JSON.parse(t));n=!0}catch(e){if(o(e))return;throw e}finally{n||t.abort()}},t)}[Symbol.asyncIterator](){return this.iterator()}tee(){const e=[],t=[],s=this.iterator(),n=n=>({next:()=>{if(0===n.length){const n=s.next();e.push(n),t.push(n)}return n.shift()}});return[new Y(()=>n(e),this.controller),new Y(()=>n(t),this.controller)]}toReadableStream(){const e=this;let t;return N({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{const{value:s,done:n}=await t.next();if(n)return e.close();const r=H(JSON.stringify(s)+"\n");e.enqueue(r)}catch(t){e.error(t)}},async cancel(){await(t.return?.())}})}}class Z{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,s,n]=function(e){const t=e.indexOf(":");return-1!==t?[e.substring(0,t),":",e.substring(t+1)]:[e,"",""]}(e);return n.startsWith(" ")&&(n=n.substring(1)),"event"===t?this.event=n:"data"===t&&this.data.push(n),null}}async function ee(e,t){const{response:s,requestLogID:n,retryOfRequestLogID:r,startTime:i}=t,o=await(async()=>{if(t.options.stream)return E(e).debug("response",s.status,s.url,s.headers,s.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(s,t.controller):Y.fromSSEResponse(s,t.controller);if(204===s.status)return null;if(t.options.__binaryResponse)return s;const n=s.headers.get("content-type"),r=n?.split(";")[0]?.trim();return r?.includes("application/json")||r?.endsWith("+json")?te(await s.json(),s):await s.text()})();return E(e).debug(`[${n}] response parsed`,$({retryOfRequestLogID:r,url:s.url,status:s.status,body:o,durationMs:Date.now()-i})),o}function te(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("request-id"),enumerable:!1})}class se extends Promise{constructor(e,t,s=ee){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=s,K.set(this,void 0),n(this,K,e,"f")}_thenUnwrap(e){return new se(r(this,K,"f"),this.responsePromise,async(t,s)=>te(e(await this.parseResponse(t,s),s),s.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(r(this,K,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}K=new WeakMap;class ne{constructor(e,t,s,r){V.set(this,void 0),n(this,V,e,"f"),this.options=r,this.response=t,this.body=s}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){const e=this.nextPageRequestOptions();if(!e)throw new c("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await r(this,V,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(V=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const t of e.getPaginatedItems())yield t}}class re extends se{constructor(e,t,s){super(e,t,async(e,t)=>new s(e,t.response,await ee(e,t),t.options))}async*[Symbol.asyncIterator](){const e=await(this);for await(const t of e)yield t}}class ie extends ne{constructor(e,t,s,n){super(e,t,s,n),this.data=s.data||[],this.has_more=s.has_more||!1,this.first_id=s.first_id||null,this.last_id=s.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){const e=this.first_id;return e?{...this.options,query:{...k(this.options.query),before_id:e}}:null}const e=this.last_id;return e?{...this.options,query:{...k(this.options.query),after_id:e}}:null}}const oe=()=>{if("undefined"==typeof File){const{process:e}=globalThis,t="string"==typeof e?.versions?.node&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function ae(e,t,s){return oe(),new File(e,t??"unknown_file",s)}function ce(e){return("object"==typeof e&&null!==e&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}const le=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],he=new WeakMap,ue=async(e,t)=>{if(!await function(e){const t="function"==typeof e?e:e.fetch,s=he.get(t);if(s)return s;const n=(async()=>{try{const e="Response"in t?t.Response:(await t("data:,")).constructor,s=new FormData;return s.toString()!==await new e(s).text()}catch{return!0}})();return he.set(t,n),n}(t))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const s=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>de(s,e,t))),s},de=async(e,t,s)=>{if(void 0!==s){if(null==s)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof s||"number"==typeof s||"boolean"==typeof s)e.append(t,String(s));else if(s instanceof Response){let n={};const r=s.headers.get("Content-Type");r&&(n={type:r}),e.append(t,ae([await s.blob()],ce(s),n))}else if(le(s))e.append(t,ae([await new Response(U(s)).blob()],ce(s)));else if((e=>e instanceof Blob&&"name"in e)(s))e.append(t,ae([s],ce(s),{type:s.type}));else if(Array.isArray(s))await Promise.all(s.map(s=>de(e,t+"[]",s)));else{if("object"!=typeof s)throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${s} instead`);await Promise.all(Object.entries(s).map(([s,n])=>de(e,`${t}[${s}]`,n)))}}},fe=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer,pe=e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&fe(e),ge=e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob;async function me(e,t,s){if(oe(),e=await e,t||(t=ce(e)),pe(e))return e instanceof File&&null==t&&null==s?e:ae([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...s});if(ge(e)){const n=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),ae(await ye(n),t,s)}const n=await ye(e);if(!s?.type){const e=n.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(s={...s,type:e})}return ae(n,t,s)}async function ye(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(fe(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else{if(!le(e)){const t=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";return`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(", ")}]`}(e)}`)}for await(const s of e)t.push(...await ye(s))}return t}class be{constructor(e){this._client=e}}const we=Symbol.for("brand.privateNullableHeaders"),_e=Array.isArray;function*ve(e){if(!e)return;if(we in e){const{values:t,nulls:s}=e;yield*t.entries();for(const e of s)yield[e,null];return}let t,s=!1;e instanceof Headers?t=e.entries():_e(e)?t=e:(s=!0,t=Object.entries(e??{}));for(let e of t){const t=e[0];if("string"!=typeof t)throw new TypeError("expected header name to be a string");const n=_e(e[1])?e[1]:[e[1]];let r=!1;for(const e of n)void 0!==e&&(s&&!r&&(r=!0,yield[t,null]),yield[t,e])}}const ke=e=>{const t=new Headers,s=new Set;for(const n of e){const e=new Set;for(const[r,i]of ve(n)){const n=r.toLowerCase();e.has(n)||(t.delete(r),e.add(n)),null===i?(t.delete(r),s.add(n)):(t.append(r,i),s.delete(n))}}return{[we]:!0,values:t,nulls:s}};function Se(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const Re=((e=Se)=>function(t,...s){if(1===t.length)return t[0];let n=!1;const r=t.reduce((t,r,i)=>(/[?#]/.test(r)&&(n=!0),t+r+(i===s.length?"":(n?encodeURIComponent:e)(String(s[i])))),""),i=r.split(/[?#]/,1)[0],o=[],a=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let l;for(;null!==(l=a.exec(i));)o.push({start:l.index,length:l[0].length});if(o.length>0){let e=0;const t=o.reduce((t,s)=>{const n=" ".repeat(s.start-e),r="^".repeat(s.length);return e=s.start+s.length,t+n+r},"");throw new c(`Path parameters result in path with invalid segments:\n${r}\n${t}`)}return r})(Se);class xe extends be{list(e={},t){const{betas:s,...n}=e??{};return this._client.getAPIList("/v1/files",ie,{query:n,...t,headers:ke([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString()},t?.headers])})}delete(e,t={},s){const{betas:n}=t??{};return this._client.delete(Re`/v1/files/${e}`,{...s,headers:ke([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},s?.headers])})}download(e,t={},s){const{betas:n}=t??{};return this._client.get(Re`/v1/files/${e}/content`,{...s,headers:ke([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},s){const{betas:n}=t??{};return this._client.get(Re`/v1/files/${e}`,{...s,headers:ke([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},s?.headers])})}upload(e,t){const{betas:s,...n}=e;return this._client.post("/v1/files",(async(e,t)=>({...e,body:await ue(e.body,t)}))({body:n,...t,headers:ke([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString()},t?.headers])},this._client))}}class Me extends be{retrieve(e,t={},s){const{betas:n}=t??{};return this._client.get(Re`/v1/models/${e}?beta=true`,{...s,headers:ke([{...null!=n?.toString()?{"anthropic-beta":n?.toString()}:void 0},s?.headers])})}list(e={},t){const{betas:s,...n}=e??{};return this._client.getAPIList("/v1/models?beta=true",ie,{query:n,...t,headers:ke([{...null!=s?.toString()?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}}class Pe{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){const e=new z;for await(const t of this.iterator)for(const s of e.decode(t))yield JSON.parse(s);for(const t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new c("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new c("Attempted to iterate over a response with no body")}return new Pe(W(e.body),t)}}class Ae extends be{create(e,t){const{betas:s,...n}=e;return this._client.post("/v1/messages/batches?beta=true",{body:n,...t,headers:ke([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},t?.headers])})}retrieve(e,t={},s){const{betas:n}=t??{};return this._client.get(Re`/v1/messages/batches/${e}?beta=true`,{...s,headers:ke([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},s?.headers])})}list(e={},t){const{betas:s,...n}=e??{};return this._client.getAPIList("/v1/messages/batches?beta=true",ie,{query:n,...t,headers:ke([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},t?.headers])})}delete(e,t={},s){const{betas:n}=t??{};return this._client.delete(Re`/v1/messages/batches/${e}?beta=true`,{...s,headers:ke([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},s?.headers])})}cancel(e,t={},s){const{betas:n}=t??{};return this._client.post(Re`/v1/messages/batches/${e}/cancel?beta=true`,{...s,headers:ke([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},s?.headers])})}async results(e,t={},s){const n=await this.retrieve(e);if(!n.results_url)throw new c(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);const{betas:r}=t??{};return this._client.get(n.results_url,{...s,headers:ke([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},s?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Pe.fromResponse(t.response,t.controller))}}const Te=e=>{if(0===e.length)return e;let t=e[e.length-1];switch(t.type){case"separator":return e=e.slice(0,e.length-1),Te(e);case"number":let s=t.value[t.value.length-1];if("."===s||"-"===s)return e=e.slice(0,e.length-1),Te(e);case"string":let n=e[e.length-2];if("delimiter"===n?.type)return e=e.slice(0,e.length-1),Te(e);if("brace"===n?.type&&"{"===n.value)return e=e.slice(0,e.length-1),Te(e);break;case"delimiter":return e=e.slice(0,e.length-1),Te(e)}return e},Ee=e=>JSON.parse((e=>{let t="";return e.map(e=>{"string"===e.type?t+='"'+e.value+'"':t+=e.value}),t})((e=>{let t=[];return e.map(e=>{"brace"===e.type&&("{"===e.value?t.push("}"):t.splice(t.lastIndexOf("}"),1)),"paren"===e.type&&("["===e.value?t.push("]"):t.splice(t.lastIndexOf("]"),1))}),t.length>0&&t.reverse().map(t=>{"}"===t?e.push({type:"brace",value:"}"}):"]"===t&&e.push({type:"paren",value:"]"})}),e})(Te((e=>{let t=0,s=[];for(;t<e.length;){let n=e[t];if("\\"===n){t++;continue}if("{"===n){s.push({type:"brace",value:"{"}),t++;continue}if("}"===n){s.push({type:"brace",value:"}"}),t++;continue}if("["===n){s.push({type:"paren",value:"["}),t++;continue}if("]"===n){s.push({type:"paren",value:"]"}),t++;continue}if(":"===n){s.push({type:"separator",value:":"}),t++;continue}if(","===n){s.push({type:"delimiter",value:","}),t++;continue}if('"'===n){let r="",i=!1;for(n=e[++t];'"'!==n;){if(t===e.length){i=!0;break}if("\\"===n){if(t++,t===e.length){i=!0;break}r+=n+e[t],n=e[++t]}else r+=n,n=e[++t]}n=e[++t],i||s.push({type:"string",value:r});continue}if(n&&/\s/.test(n)){t++;continue}let r=/[0-9]/;if(n&&r.test(n)||"-"===n||"."===n){let i="";for("-"===n&&(i+=n,n=e[++t]);n&&r.test(n)||"."===n;)i+=n,n=e[++t];s.push({type:"number",value:i});continue}let i=/[a-z]/i;if(n&&i.test(n)){let r="";for(;n&&i.test(n)&&t!==e.length;)r+=n,n=e[++t];if("true"!=r&&"false"!=r&&"null"!==r){t++;continue}s.push({type:"name",value:r});continue}t++}return s})(e)))));var $e,Ie,Oe,qe,Le,je,Ne,Ue,We,Ce,De,Xe,He,Be,Fe,Je,Ke,Ve,ze,Ge,Qe,Ye;const Ze="__json_buf";function et(e){return"tool_use"===e.type||"server_tool_use"===e.type||"mcp_tool_use"===e.type}class tt{constructor(){$e.add(this),this.messages=[],this.receivedMessages=[],Ie.set(this,void 0),this.controller=new AbortController,Oe.set(this,void 0),qe.set(this,()=>{}),Le.set(this,()=>{}),je.set(this,void 0),Ne.set(this,()=>{}),Ue.set(this,()=>{}),We.set(this,{}),Ce.set(this,!1),De.set(this,!1),Xe.set(this,!1),He.set(this,!1),Be.set(this,void 0),Fe.set(this,void 0),Ve.set(this,e=>{if(n(this,De,!0,"f"),o(e)&&(e=new h),e instanceof h)return n(this,Xe,!0,"f"),this._emit("abort",e);if(e instanceof c)return this._emit("error",e);if(e instanceof Error){const t=new c(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new c(String(e)))}),n(this,Oe,new Promise((e,t)=>{n(this,qe,e,"f"),n(this,Le,t,"f")}),"f"),n(this,je,new Promise((e,t)=>{n(this,Ne,e,"f"),n(this,Ue,t,"f")}),"f"),r(this,Oe,"f").catch(()=>{}),r(this,je,"f").catch(()=>{})}get response(){return r(this,Be,"f")}get request_id(){return r(this,Fe,"f")}async withResponse(){const e=await r(this,Oe,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){const t=new tt;return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,s){const n=new tt;for(const e of t.messages)n._addMessageParam(e);return n._run(()=>n._createMessage(e,{...t,stream:!0},{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),n}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},r(this,Ve,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,s){const n=s?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),r(this,$e,"m",ze).call(this);const{response:i,data:o}=await e.create({...t,stream:!0},{...s,signal:this.controller.signal}).withResponse();this._connected(i);for await(const e of o)r(this,$e,"m",Ge).call(this,e);if(o.controller.signal?.aborted)throw new h;r(this,$e,"m",Qe).call(this)}_connected(e){this.ended||(n(this,Be,e,"f"),n(this,Fe,e?.headers.get("request-id"),"f"),r(this,qe,"f").call(this,e),this._emit("connect"))}get ended(){return r(this,Ce,"f")}get errored(){return r(this,De,"f")}get aborted(){return r(this,Xe,"f")}abort(){this.controller.abort()}on(e,t){return(r(this,We,"f")[e]||(r(this,We,"f")[e]=[])).push({listener:t}),this}off(e,t){const s=r(this,We,"f")[e];if(!s)return this;const n=s.findIndex(e=>e.listener===t);return n>=0&&s.splice(n,1),this}once(e,t){return(r(this,We,"f")[e]||(r(this,We,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,s)=>{n(this,He,!0,"f"),"error"!==e&&this.once("error",s),this.once(e,t)})}async done(){n(this,He,!0,"f"),await r(this,je,"f")}get currentMessage(){return r(this,Ie,"f")}async finalMessage(){return await this.done(),r(this,$e,"m",Je).call(this)}async finalText(){return await this.done(),r(this,$e,"m",Ke).call(this)}_emit(e,...t){if(r(this,Ce,"f"))return;"end"===e&&(n(this,Ce,!0,"f"),r(this,Ne,"f").call(this));const s=r(this,We,"f")[e];if(s&&(r(this,We,"f")[e]=s.filter(e=>!e.once),s.forEach(({listener:e})=>e(...t))),"abort"===e){const e=t[0];return r(this,He,"f")||s?.length||Promise.reject(e),r(this,Le,"f").call(this,e),r(this,Ue,"f").call(this,e),void this._emit("end")}if("error"===e){const e=t[0];r(this,He,"f")||s?.length||Promise.reject(e),r(this,Le,"f").call(this,e),r(this,Ue,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",r(this,$e,"m",Je).call(this))}async _fromReadableStream(e,t){const s=t?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),r(this,$e,"m",ze).call(this),this._connected(null);const n=Y.fromReadableStream(e,this.controller);for await(const e of n)r(this,$e,"m",Ge).call(this,e);if(n.controller.signal?.aborted)throw new h;r(this,$e,"m",Qe).call(this)}[(Ie=new WeakMap,Oe=new WeakMap,qe=new WeakMap,Le=new WeakMap,je=new WeakMap,Ne=new WeakMap,Ue=new WeakMap,We=new WeakMap,Ce=new WeakMap,De=new WeakMap,Xe=new WeakMap,He=new WeakMap,Be=new WeakMap,Fe=new WeakMap,Ve=new WeakMap,$e=new WeakSet,Je=function(){if(0===this.receivedMessages.length)throw new c("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},Ke=function(){if(0===this.receivedMessages.length)throw new c("stream ended without producing a Message with role=assistant");const e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new c("stream ended without producing a content block with type=text");return e.join(" ")},ze=function(){this.ended||n(this,Ie,void 0,"f")},Ge=function(e){if(this.ended)return;const t=r(this,$e,"m",Ye).call(this,e);switch(this._emit("streamEvent",e,t),e.type){case"content_block_delta":{const s=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===s.type&&this._emit("text",e.delta.text,s.text||"");break;case"citations_delta":"text"===s.type&&this._emit("citation",e.delta.citation,s.citations??[]);break;case"input_json_delta":et(s)&&s.input&&this._emit("inputJson",e.delta.partial_json,s.input);break;case"thinking_delta":"thinking"===s.type&&this._emit("thinking",e.delta.thinking,s.thinking);break;case"signature_delta":"thinking"===s.type&&this._emit("signature",s.signature);break;default:e.delta}break}case"message_stop":this._addMessageParam(t),this._addMessage(t,!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":n(this,Ie,t,"f")}},Qe=function(){if(this.ended)throw new c("stream has ended, this shouldn't happen");const e=r(this,Ie,"f");if(!e)throw new c("request ended without sending any chunks");return n(this,Ie,void 0,"f"),e},Ye=function(e){let t=r(this,Ie,"f");if("message_start"===e.type){if(t)throw new c(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new c(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case"message_stop":case"content_block_stop":return t;case"message_delta":return t.container=e.delta.container,t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),t;case"content_block_start":return t.content.push(e.content_block),t;case"content_block_delta":{const s=t.content.at(e.index);switch(e.delta.type){case"text_delta":"text"===s?.type&&(s.text+=e.delta.text);break;case"citations_delta":"text"===s?.type&&(s.citations??(s.citations=[]),s.citations.push(e.delta.citation));break;case"input_json_delta":if(s&&et(s)){let t=s[Ze]||"";if(t+=e.delta.partial_json,Object.defineProperty(s,Ze,{value:t,enumerable:!1,writable:!0}),t)try{s.input=Ee(t)}catch(e){const s=new c(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${e}. JSON: ${t}`);r(this,Ve,"f").call(this,s)}}break;case"thinking_delta":"thinking"===s?.type&&(s.thinking+=e.delta.thinking);break;case"signature_delta":"thinking"===s?.type&&(s.signature=e.delta.signature);break;default:e.delta}return t}}},Symbol.asyncIterator)](){const e=[],t=[];let s=!1;return this.on("streamEvent",s=>{const n=t.shift();n?n.resolve(s):e.push(s)}),this.on("end",()=>{s=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{s=!0;for(const s of t)s.reject(e);t.length=0}),this.on("error",e=>{s=!0;for(const s of t)s.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((e,s)=>t.push({resolve:e,reject:s})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Y(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}const st={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192},nt={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};class rt extends be{constructor(){super(...arguments),this.batches=new Ae(this._client)}create(e,t){const{betas:s,...n}=e;n.model in nt&&console.warn(`The model '${n.model}' is deprecated and will reach end-of-life on ${nt[n.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);let r=this._client._options.timeout;if(!n.stream&&null==r){const e=st[n.model]??void 0;r=this._client.calculateNonstreamingTimeout(n.max_tokens,e)}return this._client.post("/v1/messages?beta=true",{body:n,timeout:r??6e5,...t,headers:ke([{...null!=s?.toString()?{"anthropic-beta":s?.toString()}:void 0},t?.headers]),stream:e.stream??!1})}stream(e,t){return tt.createMessage(this,e,t)}countTokens(e,t){const{betas:s,...n}=e;return this._client.post("/v1/messages/count_tokens?beta=true",{body:n,...t,headers:ke([{"anthropic-beta":[...s??[],"token-counting-2024-11-01"].toString()},t?.headers])})}}rt.Batches=Ae;class it extends be{constructor(){super(...arguments),this.models=new Me(this._client),this.messages=new rt(this._client),this.files=new xe(this._client)}}it.Models=Me,it.Messages=rt,it.Files=xe;class ot extends be{create(e,t){const{betas:s,...n}=e;return this._client.post("/v1/complete",{body:n,timeout:this._client._options.timeout??6e5,...t,headers:ke([{...null!=s?.toString()?{"anthropic-beta":s?.toString()}:void 0},t?.headers]),stream:e.stream??!1})}}var at,ct,lt,ht,ut,dt,ft,pt,gt,mt,yt,bt,wt,_t,vt,kt,St,Rt,xt,Mt,Pt,At;const Tt="__json_buf";function Et(e){return"tool_use"===e.type||"server_tool_use"===e.type}class $t{constructor(){at.add(this),this.messages=[],this.receivedMessages=[],ct.set(this,void 0),this.controller=new AbortController,lt.set(this,void 0),ht.set(this,()=>{}),ut.set(this,()=>{}),dt.set(this,void 0),ft.set(this,()=>{}),pt.set(this,()=>{}),gt.set(this,{}),mt.set(this,!1),yt.set(this,!1),bt.set(this,!1),wt.set(this,!1),_t.set(this,void 0),vt.set(this,void 0),Rt.set(this,e=>{if(n(this,yt,!0,"f"),o(e)&&(e=new h),e instanceof h)return n(this,bt,!0,"f"),this._emit("abort",e);if(e instanceof c)return this._emit("error",e);if(e instanceof Error){const t=new c(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new c(String(e)))}),n(this,lt,new Promise((e,t)=>{n(this,ht,e,"f"),n(this,ut,t,"f")}),"f"),n(this,dt,new Promise((e,t)=>{n(this,ft,e,"f"),n(this,pt,t,"f")}),"f"),r(this,lt,"f").catch(()=>{}),r(this,dt,"f").catch(()=>{})}get response(){return r(this,_t,"f")}get request_id(){return r(this,vt,"f")}async withResponse(){const e=await r(this,lt,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){const t=new $t;return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,s){const n=new $t;for(const e of t.messages)n._addMessageParam(e);return n._run(()=>n._createMessage(e,{...t,stream:!0},{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),n}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},r(this,Rt,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,s){const n=s?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),r(this,at,"m",xt).call(this);const{response:i,data:o}=await e.create({...t,stream:!0},{...s,signal:this.controller.signal}).withResponse();this._connected(i);for await(const e of o)r(this,at,"m",Mt).call(this,e);if(o.controller.signal?.aborted)throw new h;r(this,at,"m",Pt).call(this)}_connected(e){this.ended||(n(this,_t,e,"f"),n(this,vt,e?.headers.get("request-id"),"f"),r(this,ht,"f").call(this,e),this._emit("connect"))}get ended(){return r(this,mt,"f")}get errored(){return r(this,yt,"f")}get aborted(){return r(this,bt,"f")}abort(){this.controller.abort()}on(e,t){return(r(this,gt,"f")[e]||(r(this,gt,"f")[e]=[])).push({listener:t}),this}off(e,t){const s=r(this,gt,"f")[e];if(!s)return this;const n=s.findIndex(e=>e.listener===t);return n>=0&&s.splice(n,1),this}once(e,t){return(r(this,gt,"f")[e]||(r(this,gt,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,s)=>{n(this,wt,!0,"f"),"error"!==e&&this.once("error",s),this.once(e,t)})}async done(){n(this,wt,!0,"f"),await r(this,dt,"f")}get currentMessage(){return r(this,ct,"f")}async finalMessage(){return await this.done(),r(this,at,"m",kt).call(this)}async finalText(){return await this.done(),r(this,at,"m",St).call(this)}_emit(e,...t){if(r(this,mt,"f"))return;"end"===e&&(n(this,mt,!0,"f"),r(this,ft,"f").call(this));const s=r(this,gt,"f")[e];if(s&&(r(this,gt,"f")[e]=s.filter(e=>!e.once),s.forEach(({listener:e})=>e(...t))),"abort"===e){const e=t[0];return r(this,wt,"f")||s?.length||Promise.reject(e),r(this,ut,"f").call(this,e),r(this,pt,"f").call(this,e),void this._emit("end")}if("error"===e){const e=t[0];r(this,wt,"f")||s?.length||Promise.reject(e),r(this,ut,"f").call(this,e),r(this,pt,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",r(this,at,"m",kt).call(this))}async _fromReadableStream(e,t){const s=t?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),r(this,at,"m",xt).call(this),this._connected(null);const n=Y.fromReadableStream(e,this.controller);for await(const e of n)r(this,at,"m",Mt).call(this,e);if(n.controller.signal?.aborted)throw new h;r(this,at,"m",Pt).call(this)}[(ct=new WeakMap,lt=new WeakMap,ht=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,pt=new WeakMap,gt=new WeakMap,mt=new WeakMap,yt=new WeakMap,bt=new WeakMap,wt=new WeakMap,_t=new WeakMap,vt=new WeakMap,Rt=new WeakMap,at=new WeakSet,kt=function(){if(0===this.receivedMessages.length)throw new c("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},St=function(){if(0===this.receivedMessages.length)throw new c("stream ended without producing a Message with role=assistant");const e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new c("stream ended without producing a content block with type=text");return e.join(" ")},xt=function(){this.ended||n(this,ct,void 0,"f")},Mt=function(e){if(this.ended)return;const t=r(this,at,"m",At).call(this,e);switch(this._emit("streamEvent",e,t),e.type){case"content_block_delta":{const s=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===s.type&&this._emit("text",e.delta.text,s.text||"");break;case"citations_delta":"text"===s.type&&this._emit("citation",e.delta.citation,s.citations??[]);break;case"input_json_delta":Et(s)&&s.input&&this._emit("inputJson",e.delta.partial_json,s.input);break;case"thinking_delta":"thinking"===s.type&&this._emit("thinking",e.delta.thinking,s.thinking);break;case"signature_delta":"thinking"===s.type&&this._emit("signature",s.signature);break;default:e.delta}break}case"message_stop":this._addMessageParam(t),this._addMessage(t,!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":n(this,ct,t,"f")}},Pt=function(){if(this.ended)throw new c("stream has ended, this shouldn't happen");const e=r(this,ct,"f");if(!e)throw new c("request ended without sending any chunks");return n(this,ct,void 0,"f"),e},At=function(e){let t=r(this,ct,"f");if("message_start"===e.type){if(t)throw new c(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new c(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case"message_stop":case"content_block_stop":return t;case"message_delta":return t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),t;case"content_block_start":return t.content.push(e.content_block),t;case"content_block_delta":{const s=t.content.at(e.index);switch(e.delta.type){case"text_delta":"text"===s?.type&&(s.text+=e.delta.text);break;case"citations_delta":"text"===s?.type&&(s.citations??(s.citations=[]),s.citations.push(e.delta.citation));break;case"input_json_delta":if(s&&Et(s)){let t=s[Tt]||"";t+=e.delta.partial_json,Object.defineProperty(s,Tt,{value:t,enumerable:!1,writable:!0}),t&&(s.input=Ee(t))}break;case"thinking_delta":"thinking"===s?.type&&(s.thinking+=e.delta.thinking);break;case"signature_delta":"thinking"===s?.type&&(s.signature=e.delta.signature);break;default:e.delta}return t}}},Symbol.asyncIterator)](){const e=[],t=[];let s=!1;return this.on("streamEvent",s=>{const n=t.shift();n?n.resolve(s):e.push(s)}),this.on("end",()=>{s=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{s=!0;for(const s of t)s.reject(e);t.length=0}),this.on("error",e=>{s=!0;for(const s of t)s.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((e,s)=>t.push({resolve:e,reject:s})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Y(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}class It extends be{create(e,t){return this._client.post("/v1/messages/batches",{body:e,...t})}retrieve(e,t){return this._client.get(Re`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/v1/messages/batches",ie,{query:e,...t})}delete(e,t){return this._client.delete(Re`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(Re`/v1/messages/batches/${e}/cancel`,t)}async results(e,t){const s=await this.retrieve(e);if(!s.results_url)throw new c(`No batch \`results_url\`; Has it finished processing? ${s.processing_status} - ${s.id}`);return this._client.get(s.results_url,{...t,headers:ke([{Accept:"application/binary"},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Pe.fromResponse(t.response,t.controller))}}class Ot extends be{constructor(){super(...arguments),this.batches=new It(this._client)}create(e,t){e.model in qt&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${qt[e.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);let s=this._client._options.timeout;if(!e.stream&&null==s){const t=st[e.model]??void 0;s=this._client.calculateNonstreamingTimeout(e.max_tokens,t)}return this._client.post("/v1/messages",{body:e,timeout:s??6e5,...t,stream:e.stream??!1})}stream(e,t){return $t.createMessage(this,e,t)}countTokens(e,t){return this._client.post("/v1/messages/count_tokens",{body:e,...t})}}const qt={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};Ot.Batches=It;class Lt extends be{retrieve(e,t={},s){const{betas:n}=t??{};return this._client.get(Re`/v1/models/${e}`,{...s,headers:ke([{...null!=n?.toString()?{"anthropic-beta":n?.toString()}:void 0},s?.headers])})}list(e={},t){const{betas:s,...n}=e??{};return this._client.getAPIList("/v1/models",ie,{query:n,...t,headers:ke([{...null!=s?.toString()?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}}const jt=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;var Nt,Ut;class Wt{constructor({baseURL:e=jt("ANTHROPIC_BASE_URL"),apiKey:t=jt("ANTHROPIC_API_KEY")??null,authToken:s=jt("ANTHROPIC_AUTH_TOKEN")??null,...r}={}){Ut.set(this,void 0);const i={apiKey:t,authToken:s,...r,baseURL:e||"https://api.anthropic.com"};if(!i.dangerouslyAllowBrowser&&"undefined"!=typeof window&&void 0!==window.document&&"undefined"!=typeof navigator)throw new c("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Anthropic({ apiKey, dangerouslyAllowBrowser: true });\n");this.baseURL=i.baseURL,this.timeout=i.timeout??Ct.DEFAULT_TIMEOUT,this.logger=i.logger??console;const o="warn";this.logLevel=o,this.logLevel=x(i.logLevel,"ClientOptions.logLevel",this)??x(jt("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??o,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??2,this.fetch=i.fetch??function(){if("undefined"!=typeof fetch)return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),n(this,Ut,C,"f"),this._options=i,this.apiKey=t,this.authToken=s}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(this.apiKey&&e.get("x-api-key")||t.has("x-api-key")||this.authToken&&e.get("authorization")||t.has("authorization")))throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}authHeaders(e){return ke([this.apiKeyAuth(e),this.bearerAuth(e)])}apiKeyAuth(e){if(null!=this.apiKey)return ke([{"X-Api-Key":this.apiKey}])}bearerAuth(e){if(null!=this.authToken)return ke([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Object.entries(e).filter(([e,t])=>void 0!==t).map(([e,t])=>{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(null===t)return`${encodeURIComponent(e)}=`;throw new c(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${I}`}defaultIdempotencyKey(){return`stainless-node-retry-${i()}`}makeStatusError(e,t,s,n){return l.generate(e,t,s,n)}buildURL(e,t){const s=(e=>v.test(e))(e)?new URL(e):new URL(this.baseURL+(this.baseURL.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),n=this.defaultQuery();return function(e){if(!e)return!0;for(const t in e)return!1;return!0}(n)||(t={...n,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(s.search=this.stringifyQuery(t)),s.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new c("Streaming is strongly recommended for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 6e5}async prepareOptions(e){}async prepareRequest(e,{url:t,options:s}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,s){return this.request(Promise.resolve(s).then(s=>({method:e,path:t,...s})))}request(e,t=null){return new se(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,s){const n=await e,r=n.maxRetries??this.maxRetries;null==t&&(t=r),await this.prepareOptions(n);const{req:i,url:c,timeout:l}=this.buildRequest(n,{retryCount:r-t});await this.prepareRequest(i,{url:c,options:n});const f="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),p=void 0===s?"":`, retryOf: ${s}`,g=Date.now();if(E(this).debug(`[${f}] sending request`,$({retryOfRequestLogID:s,method:n.method,url:c,options:n,headers:i.headers})),n.signal?.aborted)throw new h;const m=new AbortController,y=await this.fetchWithTimeout(c,i,l,m).catch(a),b=Date.now();if(y instanceof Error){const e=`retrying, ${t} attempts remaining`;if(n.signal?.aborted)throw new h;const r=o(y)||/timed? ?out/i.test(String(y)+("cause"in y?String(y.cause):""));if(t)return E(this).info(`[${f}] connection ${r?"timed out":"failed"} - ${e}`),E(this).debug(`[${f}] connection ${r?"timed out":"failed"} (${e})`,$({retryOfRequestLogID:s,url:c,durationMs:b-g,message:y.message})),this.retryRequest(n,t,s??f);if(E(this).info(`[${f}] connection ${r?"timed out":"failed"} - error; no more retries left`),E(this).debug(`[${f}] connection ${r?"timed out":"failed"} (error; no more retries left)`,$({retryOfRequestLogID:s,url:c,durationMs:b-g,message:y.message})),r)throw new d;throw new u({cause:y})}const w=`[${f}${p}${[...y.headers.entries()].filter(([e])=>"request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join("")}] ${i.method} ${c} ${y.ok?"succeeded":"failed"} with status ${y.status} in ${b-g}ms`;if(!y.ok){const e=this.shouldRetry(y);if(t&&e){const e=`retrying, ${t} attempts remaining`;return await async function(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await(e[Symbol.asyncIterator]().return?.());const t=e.getReader(),s=t.cancel();t.releaseLock(),await s}(y.body),E(this).info(`${w} - ${e}`),E(this).debug(`[${f}] response error (${e})`,$({retryOfRequestLogID:s,url:y.url,status:y.status,headers:y.headers,durationMs:b-g})),this.retryRequest(n,t,s??f,y.headers)}const r=e?"error; no more retries left":"error; not retryable";E(this).info(`${w} - ${r}`);const i=await y.text().catch(e=>a(e).message),o=S(i),c=o?void 0:i;throw E(this).debug(`[${f}] response error (${r})`,$({retryOfRequestLogID:s,url:y.url,status:y.status,headers:y.headers,message:c,durationMs:Date.now()-g})),this.makeStatusError(y.status,o,c,y.headers)}return E(this).info(w),E(this).debug(`[${f}] response start`,$({retryOfRequestLogID:s,url:y.url,status:y.status,headers:y.headers,durationMs:b-g})),{response:y,options:n,controller:m,requestLogID:f,retryOfRequestLogID:s,startTime:g}}getAPIList(e,t,s){return this.requestAPIList(t,{method:"get",path:e,...s})}requestAPIList(e,t){const s=this.makeRequest(t,null,void 0);return new re(this,s,e)}async fetchWithTimeout(e,t,s,n){const{signal:r,method:i,...o}=t||{};r&&r.addEventListener("abort",()=>n.abort());const a=setTimeout(()=>n.abort(),s),c=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||"object"==typeof o.body&&null!==o.body&&Symbol.asyncIterator in o.body,l={signal:n.signal,...c?{duplex:"half"}:{},method:"GET",...o};i&&(l.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,l)}finally{clearTimeout(a)}}shouldRetry(e){const t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||409===e.status||429===e.status||e.status>=500)}async retryRequest(e,t,s,n){let r;const i=n?.get("retry-after-ms");if(i){const e=parseFloat(i);Number.isNaN(e)||(r=e)}const o=n?.get("retry-after");if(o&&!r){const e=parseFloat(o);r=Number.isNaN(e)?Date.parse(o)-Date.now():1e3*e}if(!(r&&0<=r&&r<6e4)){const s=e.maxRetries??this.maxRetries;r=this.calculateDefaultRetryTimeoutMillis(t,s)}var a;return await(a=r,new Promise(e=>setTimeout(e,a))),this.makeRequest(e,t-1,s)}calculateDefaultRetryTimeoutMillis(e,t){const s=t-e;return Math.min(.5*Math.pow(2,s),8)*(1-.25*Math.random())*1e3}calculateNonstreamingTimeout(e,t){const s=6e5;if(36e5*e/128e3>s||null!=t&&e>t)throw new c("Streaming is strongly recommended for operations that may token longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return s}buildRequest(e,{retryCount:t=0}={}){const s={...e},{method:n,path:r,query:i}=s,o=this.buildURL(r,i);"timeout"in s&&((e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new c(`${e} must be an integer`);if(t<0)throw new c(`${e} must be a positive integer`)})("timeout",s.timeout),s.timeout=s.timeout??this.timeout;const{bodyHeaders:a,body:l}=this.buildBody({options:s});return{req:{method:n,headers:this.buildHeaders({options:e,method:n,bodyHeaders:a,retryCount:t}),...s.signal&&{signal:s.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:"half"},...l&&{body:l},...this.fetchOptions??{},...s.fetchOptions??{}},url:o,timeout:s.timeout}}buildHeaders({options:e,method:t,bodyHeaders:s,retryCount:n}){let r={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),r[this.idempotencyHeader]=e.idempotencyKey);const i=ke([r,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(n),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...j??(j=O()),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},this.authHeaders(e),this._options.defaultHeaders,s,e.headers]);return this.validateHeaders(i),i.values}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};const s=ke([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&s.values.has("content-type")||e instanceof Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:U(e)}:r(this,Ut,"f").call(this,{body:e,headers:s})}}Nt=Wt,Ut=new WeakMap,Wt.Anthropic=Nt,Wt.HUMAN_PROMPT="\n\nHuman:",Wt.AI_PROMPT="\n\nAssistant:",Wt.DEFAULT_TIMEOUT=6e5,Wt.AnthropicError=c,Wt.APIError=l,Wt.APIConnectionError=u,Wt.APIConnectionTimeoutError=d,Wt.APIUserAbortError=h,Wt.NotFoundError=m,Wt.ConflictError=y,Wt.RateLimitError=w,Wt.BadRequestError=f,Wt.AuthenticationError=p,Wt.InternalServerError=_,Wt.PermissionDeniedError=g,Wt.UnprocessableEntityError=b,Wt.toFile=me;class Ct extends Wt{constructor(){super(...arguments),this.completions=new ot(this),this.messages=new Ot(this),this.models=new Lt(this),this.beta=new it(this)}}Ct.Completions=ot,Ct.Messages=Ot,Ct.Models=Lt,Ct.Beta=it;const{HUMAN_PROMPT:Dt,AI_PROMPT:Xt}=Ct}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunksage_agent_internal=self.webpackChunksage_agent_internal||[]).push([[747],{2747:(t,e,i)=>{i.d(e,{Ar:()=>c,Bc:()=>xt,Gw:()=>ct,OO:()=>Tt,et:()=>a,wm:()=>mt,yU:()=>Dt});var o=i(195),n=i(5024),s=i(2084);class l{constructor(t,e,i,o){this.state=t,this.pos=e,this.explicit=i,this.view=o,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=(0,s.syntaxTree)(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),o=e.text.slice(i-e.from,this.pos-e.from),n=o.search(d(t,!1));return n<0?null:{from:i+n,to:this.pos,text:o.slice(n)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function r(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function a(t){let e=t.map(t=>"string"==typeof t?{label:t}:t),[i,o]=e.every(t=>/^\w+$/.test(t.label))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:o}of t){e[o[0]]=!0;for(let t=1;t<o.length;t++)i[o[t]]=!0}let o=r(e)+r(i)+"*$";return[new RegExp("^"+o),new RegExp(o)]}(e);return t=>{let n=t.matchBefore(o);return n||t.explicit?{from:n?n.from:t.pos,options:e,validFor:i}:null}}function c(t,e){return i=>{for(let e=(0,s.syntaxTree)(i.state).resolveInner(i.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(i)}}class h{constructor(t,e,i,o){this.completion=t,this.source=e,this.match=i,this.score=o}}function p(t){return t.selection.main.from}function d(t,e){var i;let{source:o}=t,n=e&&"^"!=o[0],s="$"!=o[o.length-1];return n||s?new RegExp(`${n?"^":""}(?:${o})${s?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const f=o.Annotation.define(),u=new WeakMap;function m(t){if(!Array.isArray(t))return t;let e=u.get(t);return e||u.set(t,e=a(t)),e}const g=o.StateEffect.define(),v=o.StateEffect.define();class b{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=(0,o.codePointAt)(t,e),n=(0,o.codePointSize)(i);this.chars.push(i);let s=t.slice(e,e+n),l=s.toUpperCase();this.folded.push((0,o.codePointAt)(l==s?s.toLowerCase():l,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:s,byWord:l}=this;if(1==e.length){let n=(0,o.codePointAt)(t,0),s=(0,o.codePointSize)(n),l=s==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;l+=-200}return this.ret(l,[0,s])}let r=t.indexOf(this.pattern);if(0==r)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,c=0;if(r<0){for(let s=0,l=Math.min(t.length,200);s<l&&c<a;){let l=(0,o.codePointAt)(t,s);l!=e[c]&&l!=i[c]||(n[c++]=s),s+=(0,o.codePointSize)(l)}if(c<a)return null}let h=0,p=0,d=!1,f=0,u=-1,m=-1,g=/[a-z]/.test(t),v=!0;for(let n=0,c=Math.min(t.length,200),b=0;n<c&&p<a;){let c=(0,o.codePointAt)(t,n);r<0&&(h<a&&c==e[h]&&(s[h++]=n),f<a&&(c==e[f]||c==i[f]?(0==f&&(u=n),m=n+1,f++):f=0));let w,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:c>=65&&c<=90?1:0:(w=(0,o.fromCodePoint)(c))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!n||1==y&&g||0==b&&0!=y)&&(e[p]==c||i[p]==c&&(d=!0)?l[p++]=n:l.length&&(v=!1)),b=y,n+=(0,o.codePointSize)(c)}return p==a&&0==l[0]&&v?this.result((d?-200:0)-100,l,t):f==a&&0==u?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):r>-1?this.ret(-700-t.length,[r,r+this.pattern.length]):f==a?this.ret(-900-t.length,[u,m]):p==a?this.result((d?-200:0)-100-700+(v?0:-1100),l,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],s=0;for(let t of e){let e=t+(this.astral?(0,o.codePointSize)((0,o.codePointAt)(i,t)):1);s&&n[s-1]==t?n[s-1]=e:(n[s++]=t,n[s++]=e)}return this.ret(t-i.length,n)}}class w{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const y=o.Facet.define({combine:t=>(0,o.combineConfig)(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:C,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>x(t(i),e(i)),optionClass:(t,e)=>i=>x(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function x(t,e){return t?e?t+" "+e:t:e}function C(t,e,i,o,s,l){let r,a,c=t.textDirection==n.Direction.RTL,h=c,p=!1,d="top",f=e.left-s.left,u=s.right-e.right,m=o.right-o.left,g=o.bottom-o.top;if(h&&f<Math.min(m,u)?h=!1:!h&&u<Math.min(m,f)&&(h=!0),m<=(h?f:u))r=Math.max(s.top,Math.min(i.top,s.bottom-g))-e.top,a=Math.min(400,h?f:u);else{p=!0,a=Math.min(400,(c?e.right:s.right-e.left)-30);let t=s.bottom-e.bottom;t>=g||t>e.top?r=i.bottom-e.top:(d="bottom",r=e.bottom-i.top)}return{style:`${d}: ${r/((e.bottom-e.top)/l.offsetHeight)}px; max-width: ${a/((e.right-e.left)/l.offsetWidth)}px`,class:"cm-completionInfo-"+(p?c?"left-narrow":"right-narrow":h?"left":"right")}}function S(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let o=Math.floor((t-e)/i);return{from:t-(o+1)*i,to:t-o*i}}class E{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let o=t.state.field(e),{options:n,selected:s}=o.open,l=t.state.facet(y);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map(t=>"cm-completionIcon-"+t)),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,o){let n=document.createElement("span");n.className="cm-completionLabel";let s=t.displayLabel||t.label,l=0;for(let t=0;t<o.length;){let e=o[t++],i=o[t++];e>l&&n.appendChild(document.createTextNode(s.slice(l,e)));let r=n.appendChild(document.createElement("span"));r.appendChild(document.createTextNode(s.slice(e,i))),r.className="cm-completionMatchedText",l=i}return l<s.length&&n.appendChild(document.createTextNode(s.slice(l))),n},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort((t,e)=>t.position-e.position).map(t=>t.render)}(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=S(n.length,s,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",i=>{let{options:o}=t.state.field(e).open;for(let e,n=i.target;n&&n!=this.dom;n=n.parentNode)if("LI"==n.nodeName&&(e=/-(\d+)$/.exec(n.id))&&+e[1]<o.length)return this.applyCompletion(t,o[+e[1]]),void i.preventDefault()}),this.dom.addEventListener("focusout",e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(y).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:v.of(null)})}),this.showOptions(n,o.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var e;let i=t.state.field(this.stateField),o=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=o){let{options:n,selected:s,disabled:l}=i.open;o.open&&o.open.options==n||(this.range=S(n.length,s,t.state.facet(y).maxRenderedOptions),this.showOptions(n,i.id)),this.updateSel(),l!=(null===(e=o.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=S(e.options.length,e.selected,this.view.state.facet(y).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:i}=e.options[e.selected],{info:o}=i;if(!o)return;let s="string"==typeof o?document.createTextNode(o):o(i);if(!s)return;"then"in s?s.then(e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,i)}).catch(t=>(0,n.logException)(this.view.state,t,"completion info")):this.addInfoPane(s,i)}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:o}=t;i.appendChild(e),this.infoDestroy=o||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,o=this.range.from;i;i=i.nextSibling,o++)"LI"==i.nodeName&&i.id?o==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected"):o--;return e&&function(t,e){let i=t.getBoundingClientRect(),o=e.getBoundingClientRect(),n=i.height/t.offsetHeight;o.top<i.top?t.scrollTop-=(i.top-o.top)/n:o.bottom>i.bottom&&(t.scrollTop+=(o.bottom-i.bottom)/n)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),o=t.getBoundingClientRect(),n=this.space;if(!n){let t=this.dom.ownerDocument.documentElement;n={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return o.top>Math.min(n.bottom,e.bottom)-10||o.bottom<Math.max(n.top,e.top)+10?null:this.view.state.facet(y).positionInfo(this.view,e,o,i,n,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const o=document.createElement("ul");o.id=e,o.setAttribute("role","listbox"),o.setAttribute("aria-expanded","true"),o.setAttribute("aria-label",this.view.state.phrase("Completions")),o.addEventListener("mousedown",t=>{t.target==o&&t.preventDefault()});let n=null;for(let s=i.from;s<i.to;s++){let{completion:l,match:r}=t[s],{section:a}=l;if(a){let t="string"==typeof a?a:a.name;t!=n&&(s>i.from||0==i.from)&&(n=t,"string"!=typeof a&&a.header?o.appendChild(a.header(a)):o.appendChild(document.createElement("completion-section")).textContent=t)}const c=o.appendChild(document.createElement("li"));c.id=e+"-"+s,c.setAttribute("role","option");let h=this.optionClass(l);h&&(c.className=h);for(let t of this.optionContent){let e=t(l,this.view.state,this.view,r);e&&c.appendChild(e)}}return i.from&&o.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&o.classList.add("cm-completionListIncompleteBottom"),o}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function I(t,e){return i=>new E(i,t,e)}function O(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class P{constructor(t,e,i,o,n,s){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=o,this.selected=n,this.disabled=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new P(this.options,A(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,o,n,s){if(o&&!s&&t.some(t=>t.isPending))return o.setDisabled();let l=function(t,e){let i=[],o=null,n=t=>{i.push(t);let{section:e}=t.completion;if(e){o||(o=[]);let t="string"==typeof e?e:e.name;o.some(e=>e.name==t)||o.push("string"==typeof e?{name:t}:e)}},s=e.facet(y);for(let o of t)if(o.hasResult()){let t=o.result.getMatch;if(!1===o.result.filter)for(let e of o.result.options)n(new h(e,o.source,t?t(e):[],1e9-i.length));else{let i,l=e.sliceDoc(o.from,o.to),r=s.filterStrict?new w(l):new b(l);for(let e of o.result.options)if(i=r.match(e.label)){let s=e.displayLabel?t?t(e,i.matched):[]:i.matched;n(new h(e,o.source,s,i.score+(e.boost||0)))}}}if(o){let t=Object.create(null),e=0,n=(t,e)=>{var i,o;return(null!==(i=t.rank)&&void 0!==i?i:1e9)-(null!==(o=e.rank)&&void 0!==o?o:1e9)||(t.name<e.name?-1:1)};for(let i of o.sort(n))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let l=[],r=null,a=s.compareCompletions;for(let t of i.sort((t,e)=>e.score-t.score||a(t.completion,e.completion))){let e=t.completion;!r||r.label!=e.label||r.detail!=e.detail||null!=r.type&&null!=e.type&&r.type!=e.type||r.apply!=e.apply||r.boost!=e.boost?l.push(t):O(t.completion)>O(r)&&(l[l.length-1]=t),r=t.completion}return l}(t,e);if(!l.length)return o&&t.some(t=>t.isPending)?o.setDisabled():null;let r=e.facet(y).selectOnOpen?0:-1;if(o&&o.selected!=r&&-1!=o.selected){let t=o.options[o.selected].completion;for(let e=0;e<l.length;e++)if(l[e].completion==t){r=e;break}}return new P(l,A(i,r),{pos:t.reduce((t,e)=>e.hasResult()?Math.min(t,e.from):t,1e8),create:V,above:n.aboveCursor},o?o.timestamp:Date.now(),r,!1)}map(t){return new P(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new P(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class k{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new k(R,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(y),o=(i.override||e.languageDataAt("autocomplete",p(e)).map(m)).map(e=>(this.active.find(t=>t.source==e)||new M(e,this.active.some(t=>0!=t.state)?1:0)).update(t,i));o.length==this.active.length&&o.every((t,e)=>t==this.active[e])&&(o=this.active);let n=this.open,s=t.effects.some(t=>t.is(F));n&&t.docChanged&&(n=n.map(t.changes)),t.selection||o.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!function(t,e){if(t==e)return!0;for(let i=0,o=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;o<e.length&&!e[o].hasResult();)o++;let n=i==t.length,s=o==e.length;if(n||s)return n==s;if(t[i++].result!=e[o++].result)return!1}}(o,this.active)||s?n=P.build(o,e,this.id,n,i,s):n&&n.disabled&&!o.some(t=>t.isPending)&&(n=null),!n&&o.every(t=>!t.isPending)&&o.some(t=>t.hasResult())&&(o=o.map(t=>t.hasResult()?new M(t.source,0):t));for(let e of t.effects)e.is(U)&&(n=n&&n.setSelected(e.value,this.id));return o==this.active&&n==this.open?this:new k(o,this.id,n)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?D:T}}const D={"aria-autocomplete":"list"},T={};function A(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const R=[];function L(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(f);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class M{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=L(t,e),o=this;(8&i||16&i&&this.touches(t))&&(o=new M(o.source,0)),4&i&&0==o.state&&(o=new M(this.source,1)),o=o.updateFor(t,i);for(let e of t.effects)if(e.is(g))o=new M(o.source,1,e.value);else if(e.is(v))o=new M(o.source,0);else if(e.is(F))for(let t of e.value)t.source==o.source&&(o=t);return o}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(p(t.state))}}class B extends M{constructor(t,e,i,o,n,s){super(t,3,e),this.limit=i,this.result=o,this.from=n,this.to=s}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let o=this.result;o.map&&!t.changes.empty&&(o=o.map(o,t.changes));let n=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),r=p(t.state);if(r>s||!o||2&e&&(p(t.startState)==this.from||r<this.limit))return new M(this.source,4&e?1:0);let a=t.changes.mapPos(this.limit);return function(t,e,i,o){if(!t)return!1;let n=e.sliceDoc(i,o);return"function"==typeof t?t(n,i,o,e):d(t,!0).test(n)}(o.validFor,t.state,n,s)?new B(this.source,this.explicit,a,o,n,s):o.update&&(o=o.update(o,n,s,new l(t.state,r,!1)))?new B(this.source,this.explicit,a,o,o.from,null!==(i=o.to)&&void 0!==i?i:p(t.state)):new M(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new B(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new M(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const F=o.StateEffect.define({map:(t,e)=>t.map(t=>t.map(e))}),U=o.StateEffect.define(),$=o.StateField.define({create:()=>k.start(),update:(t,e)=>t.update(e),provide:t=>[n.showTooltip.from(t,t=>t.tooltip),n.EditorView.contentAttributes.from(t,t=>t.attrs)]});function N(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field($).active.find(t=>t.source==e.source);return n instanceof B&&("string"==typeof i?t.dispatch(Object.assign(Object.assign({},function(t,e,i,n){let{main:s}=t.selection,l=i-s.from,r=n-s.from;return Object.assign(Object.assign({},t.changeByRange(a=>{if(a!=s&&i!=n&&t.sliceDoc(a.from+l,a.from+r)!=t.sliceDoc(i,n))return{range:a};let c=t.toText(e);return{changes:{from:a.from+l,to:n==s.from?a.to:a.from+r,insert:c},range:o.EditorSelection.cursor(a.from+l+c.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,i,n.from,n.to)),{annotations:f.of(e.completion)})):i(t,e.completion,n.from,n.to),!0)}const V=I($,N);function j(t,e="option"){return i=>{let o=i.state.field($,!1);if(!o||!o.open||o.open.disabled||Date.now()-o.open.timestamp<i.state.facet(y).interactionDelay)return!1;let s,l=1;"page"==e&&(s=(0,n.getTooltip)(i,o.open.tooltip))&&(l=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:r}=o.open.options,a=o.open.selected>-1?o.open.selected+l*(t?1:-1):t?0:r-1;return a<0?a="page"==e?0:r-1:a>=r&&(a="page"==e?r-1:0),i.dispatch({effects:U.of(a)}),!0}}const z=t=>!!t.state.field($,!1)&&(t.dispatch({effects:g.of(!0)}),!0);class W{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const q=n.ViewPlugin.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field($).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field($),i=t.state.facet(y);if(!t.selectionSet&&!t.docChanged&&t.startState.field($)==e)return;let o=t.transactions.some(t=>{let e=L(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)});for(let e=0;e<this.running.length;e++){let i=this.running[e];if(o||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){(0,n.logException)(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(t=>t.effects.some(t=>t.is(g)))&&(this.pendingStart=!0);let s=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(t=>t.isPending&&!this.running.some(e=>e.active.source==t.source))?setTimeout(()=>this.startUpdate(),s):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field($);for(let t of e.active)t.isPending&&!this.running.some(e=>e.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(y).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=p(e),o=new l(e,i,t.explicit,this.view),s=new W(t,o);this.running.push(s),Promise.resolve(t.source(o)).then(t=>{s.context.aborted||(s.done=t||null,this.scheduleAccept())},t=>{this.view.dispatch({effects:v.of(null)}),(0,n.logException)(this.view.state,t)})}scheduleAccept(){this.running.every(t=>void 0!==t.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(y).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(y),o=this.view.state.field($);for(let n=0;n<this.running.length;n++){let s=this.running[n];if(void 0===s.done)continue;if(this.running.splice(n--,1),s.done){let o=p(s.updates.length?s.updates[0].startState:this.view.state),n=Math.min(o,s.done.from+(s.active.explicit?0:1)),l=new B(s.active.source,s.active.explicit,n,s.done,s.done.from,null!==(t=s.done.to)&&void 0!==t?t:o);for(let t of s.updates)l=l.update(t,i);if(l.hasResult()){e.push(l);continue}}let l=o.active.find(t=>t.source==s.active.source);if(l&&l.isPending)if(null==s.done){let t=new M(s.active.source,0);for(let e of s.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(l)}(e.length||o.open&&o.open.disabled)&&this.view.dispatch({effects:F.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field($,!1);if(e&&e.tooltip&&this.view.state.facet(y).closeOnBlur){let i=e.open&&(0,n.getTooltip)(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:v.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:g.of(!1)}),20),this.composing=0}}}),H="object"==typeof navigator&&/Win/.test(navigator.platform),K=o.Prec.highest(n.EditorView.domEventHandlers({keydown(t,e){let i=e.state.field($,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!H||!t.altKey)||t.metaKey)return!1;let o=i.open.options[i.open.selected],n=i.active.find(t=>t.source==o.source),s=o.completion.commitCharacters||n.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&N(e,o),!1}})),_=n.EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Q{constructor(t,e,i,o){this.field=t,this.line=e,this.from=i,this.to=o}}class X{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,o.MapMode.TrackDel),i=t.mapPos(this.to,1,o.MapMode.TrackDel);return null==e||null==i?null:new X(this.field,e,i)}}class G{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],o=[e],n=t.doc.lineAt(e),l=/^\s*/.exec(n.text)[0];for(let n of this.lines){if(i.length){let i=l,r=/^\t*/.exec(n)[0].length;for(let e=0;e<r;e++)i+=t.facet(s.indentUnit);o.push(e+i.length-r),n=i+n.slice(r)}i.push(n),e+=n.length+1}let r=this.fieldPositions.map(t=>new X(t.field,o[t.line]+t.from,o[t.line]+t.to));return{text:i,ranges:r}}static parse(t){let e,i=[],o=[],n=[];for(let s of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let t=e[1]?+e[1]:null,l=e[2]||e[3]||"",r=-1,a=l.replace(/\\[{}]/g,t=>t[1]);for(let e=0;e<i.length;e++)(null!=t?i[e].seq==t:a&&i[e].name==a)&&(r=e);if(r<0){let e=0;for(;e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t);)e++;i.splice(e,0,{seq:t,name:a}),r=e;for(let t of n)t.field>=r&&t.field++}n.push(new Q(r,o.length,e.index,e.index+a.length)),s=s.slice(0,e.index)+l+s.slice(e.index+e[0].length)}s=s.replace(/\\([{}])/g,(t,e,i)=>{for(let t of n)t.line==o.length&&t.from>i&&(t.from--,t.to--);return e}),o.push(s)}return new G(o,n)}}let Y=n.Decoration.widget({widget:new class extends n.WidgetType{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),J=n.Decoration.mark({class:"cm-snippetField"});class Z{constructor(t,e){this.ranges=t,this.active=e,this.deco=n.Decoration.set(t.map(t=>(t.from==t.to?Y:J).range(t.from,t.to)))}map(t){let e=[];for(let i of this.ranges){let o=i.map(t);if(!o)return null;e.push(o)}return new Z(e,this.active)}selectionInsideField(t){return t.ranges.every(t=>this.ranges.some(e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))}}const tt=o.StateEffect.define({map:(t,e)=>t&&t.map(e)}),et=o.StateEffect.define(),it=o.StateField.define({create:()=>null,update(t,e){for(let i of e.effects){if(i.is(tt))return i.value;if(i.is(et)&&t)return new Z(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>n.EditorView.decorations.from(t,t=>t?t.deco:n.Decoration.none)});function ot(t,e){return o.EditorSelection.create(t.filter(t=>t.field==e).map(t=>o.EditorSelection.range(t.from,t.to)))}function nt(t){let e=G.parse(t);return(t,i,n,s)=>{let{text:l,ranges:r}=e.instantiate(t.state,n),{main:a}=t.state.selection,c={changes:{from:n,to:s==a.from?a.to:s,insert:o.Text.of(l)},scrollIntoView:!0,annotations:i?[f.of(i),o.Transaction.userEvent.of("input.complete")]:void 0};if(r.length&&(c.selection=ot(r,0)),r.some(t=>t.field>0)){let e=new Z(r,0),i=c.effects=[tt.of(e)];void 0===t.state.field(it,!1)&&i.push(o.StateEffect.appendConfig.of([it,at,ht,_]))}t.dispatch(t.state.update(c))}}function st(t){return({state:e,dispatch:i})=>{let o=e.field(it,!1);if(!o||t<0&&0==o.active)return!1;let n=o.active+t,s=t>0&&!o.ranges.some(e=>e.field==n+t);return i(e.update({selection:ot(o.ranges,n),effects:tt.of(s?null:new Z(o.ranges,n)),scrollIntoView:!0})),!0}}const lt=[{key:"Tab",run:st(1),shift:st(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(it,!1)&&(e(t.update({effects:tt.of(null)})),!0)}],rt=o.Facet.define({combine:t=>t.length?t[0]:lt}),at=o.Prec.highest(n.keymap.compute([rt],t=>t.facet(rt)));function ct(t,e){return Object.assign(Object.assign({},e),{apply:nt(t)})}const ht=n.EditorView.domEventHandlers({mousedown(t,e){let i,o=e.state.field(it,!1);if(!o||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let n=o.ranges.find(t=>t.from<=i&&t.to>=i);return!(!n||n.field==o.active||(e.dispatch({selection:ot(o.ranges,n.field),effects:tt.of(o.ranges.some(t=>t.field>n.field)?new Z(o.ranges,n.field):null),scrollIntoView:!0}),0))}}),pt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},dt=o.StateEffect.define({map(t,e){let i=e.mapPos(t,-1,o.MapMode.TrackAfter);return null==i?void 0:i}}),ft=new class extends o.RangeValue{};ft.startSide=1,ft.endSide=-1;const ut=o.StateField.define({create:()=>o.RangeSet.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(dt)&&(t=t.update({add:[ft.range(i.value,i.value+1)]}));return t}});function mt(){return[yt,ut]}const gt="()[]{}<>«»»«[]{}";function vt(t){for(let e=0;e<16;e+=2)if(gt.charCodeAt(e)==t)return gt.charAt(e+1);return(0,o.fromCodePoint)(t<128?t:t+1)}function bt(t,e){return t.languageDataAt("closeBrackets",e)[0]||pt}const wt="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),yt=n.EditorView.inputHandler.of((t,e,i,n)=>{if((wt?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let s=t.state.selection.main;if(n.length>2||2==n.length&&1==(0,o.codePointSize)((0,o.codePointAt)(n,0))||e!=s.from||i!=s.to)return!1;let l=function(t,e){let i=bt(t,t.selection.main.head),n=i.brackets||pt.brackets;for(let s of n){let l=vt((0,o.codePointAt)(s,0));if(e==s)return l==s?Ot(t,s,n.indexOf(s+s+s)>-1,i):Et(t,s,l,i.before||pt.before);if(e==l&&Ct(t,t.selection.main.from))return It(t,0,l)}return null}(t.state,n);return!!l&&(t.dispatch(l),!0)}),xt=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=bt(t,t.selection.main.head).brackets||pt.brackets,n=null,s=t.changeByRange(e=>{if(e.empty){let n=function(t,e){let i=t.sliceString(e-2,e);return(0,o.codePointSize)((0,o.codePointAt)(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let s of i)if(s==n&&St(t.doc,e.head)==vt((0,o.codePointAt)(s,0)))return{changes:{from:e.head-s.length,to:e.head+s.length},range:o.EditorSelection.cursor(e.head-s.length)}}return{range:n=e}});return n||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!n}}];function Ct(t,e){let i=!1;return t.field(ut).between(0,t.doc.length,t=>{t==e&&(i=!0)}),i}function St(t,e){let i=t.sliceString(e,e+2);return i.slice(0,(0,o.codePointSize)((0,o.codePointAt)(i,0)))}function Et(t,e,i,n){let s=null,l=t.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:i,from:l.to}],effects:dt.of(l.to+e.length),range:o.EditorSelection.range(l.anchor+e.length,l.head+e.length)};let r=St(t.doc,l.head);return!r||/\s/.test(r)||n.indexOf(r)>-1?{changes:{insert:e+i,from:l.head},effects:dt.of(l.head+e.length),range:o.EditorSelection.cursor(l.head+e.length)}:{range:s=l}});return s?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function It(t,e,i){let n=null,s=t.changeByRange(e=>e.empty&&St(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:o.EditorSelection.cursor(e.head+i.length)}:n={range:e});return n?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Ot(t,e,i,n){let l=n.stringPrefixes||pt.stringPrefixes,r=null,a=t.changeByRange(n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:dt.of(n.to+e.length),range:o.EditorSelection.range(n.anchor+e.length,n.head+e.length)};let a,c=n.head,h=St(t.doc,c);if(h==e){if(Pt(t,c))return{changes:{insert:e+e,from:c},effects:dt.of(c+e.length),range:o.EditorSelection.cursor(c+e.length)};if(Ct(t,c)){let n=i&&t.sliceDoc(c,c+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+n.length,insert:n},range:o.EditorSelection.cursor(c+n.length)}}}else{if(i&&t.sliceDoc(c-2*e.length,c)==e+e&&(a=kt(t,c-2*e.length,l))>-1&&Pt(t,a))return{changes:{insert:e+e+e+e,from:c},effects:dt.of(c+e.length),range:o.EditorSelection.cursor(c+e.length)};if(t.charCategorizer(c)(h)!=o.CharCategory.Word&&kt(t,c,l)>-1&&!function(t,e,i,o){let n=(0,s.syntaxTree)(t).resolveInner(e,-1),l=o.reduce((t,e)=>Math.max(t,e.length),0);for(let s=0;s<5;s++){let s=t.sliceDoc(n.from,Math.min(n.to,n.from+i.length+l)),r=s.indexOf(i);if(!r||r>-1&&o.indexOf(s.slice(0,r))>-1){let e=n.firstChild;for(;e&&e.from==n.from&&e.to-e.from>i.length+r;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let a=n.to==e&&n.parent;if(!a)break;n=a}return!1}(t,c,e,l))return{changes:{insert:e+e,from:c},effects:dt.of(c+e.length),range:o.EditorSelection.cursor(c+e.length)}}return{range:r=n}});return r?null:t.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Pt(t,e){let i=(0,s.syntaxTree)(t).resolveInner(e+1);return i.parent&&i.from==e}function kt(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=o.CharCategory.Word)return e;for(let s of i){let i=e-s.length;if(t.sliceDoc(i,e)==s&&n(t.sliceDoc(i-1,i))!=o.CharCategory.Word)return i}return-1}function Dt(t={}){return[K,$,y.of(t),q,At,_]}const Tt=[{key:"Ctrl-Space",run:z},{mac:"Alt-`",run:z},{key:"Escape",run:t=>{let e=t.state.field($,!1);return!(!e||!e.active.some(t=>0!=t.state)||(t.dispatch({effects:v.of(null)}),0))}},{key:"ArrowDown",run:j(!0)},{key:"ArrowUp",run:j(!1)},{key:"PageDown",run:j(!0,"page")},{key:"PageUp",run:j(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field($,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(y).interactionDelay)&&N(t,e.open.options[e.open.selected])}}],At=o.Prec.highest(n.keymap.computeN([y],t=>t.facet(y).defaultKeymap?[Tt]:[]))}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunksage_agent_internal=self.webpackChunksage_agent_internal||[]).push([[821],{8821:(e,t,i)=>{i.r(t),i.d(t,{EditorView:()=>n.EditorView,basicSetup:()=>Oe,minimalSetup:()=>Ve});var n=i(5024),o=i(195),r=i(2084),s=i(4353);function l(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var o=i[n];"string"==typeof o?e.setAttribute(n,o):null!=o&&(e[n]=o)}t++}for(;t<arguments.length;t++)a(e,arguments[t]);return e}function a(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var i=0;i<t.length;i++)a(e,t[i])}}const c="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class h{constructor(e,t,i=0,n=e.length,o,r){this.test=r,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,n),this.bufferStart=i,this.normalize=o?e=>o(c(e)):c,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return(0,o.codePointAt)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=(0,o.fromCodePoint)(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=(0,o.codePointSize)(e);let n=this.normalize(t);if(n.length)for(let e=0,o=i;;e++){let r=n.charCodeAt(e),s=this.match(r,o,this.bufferPos+this.bufferStart);if(e==n.length-1){if(s)return this.value=s,this;break}o==i&&e<t.length&&t.charCodeAt(e)==r&&o++}}}match(e,t,i){let n=null;for(let t=0;t<this.matches.length;t+=2){let o=this.matches[t],r=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?n={from:this.matches[t+1],to:i}:(this.matches[t]++,r=!0)),r||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?n={from:t,to:i}:this.matches.push(1,t)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}"undefined"!=typeof Symbol&&(h.prototype[Symbol.iterator]=function(){return this});const d={from:-1,to:-1,match:/.*/.exec("")},u="gm"+(null==/x/.unicode?"":"u");class f{constructor(e,t,i,n=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=d,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new p(e,t,i,n,o);this.re=new RegExp(t,u+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=e.iter();let r=e.lineAt(n);this.curLineStart=r.from,this.matchPos=v(e,n),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,n=i+t[0].length;if(this.matchPos=v(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const m=new WeakMap;class g{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let n=m.get(e);if(!n||n.from>=i||n.to<=t){let n=new g(t,e.sliceString(t,i));return m.set(e,n),n}if(n.from==t&&n.to==i)return n;let{text:o,from:r}=n;return r>t&&(o=e.sliceString(t,r)+o,r=t),n.to<i&&(o+=e.sliceString(n.to,i)),m.set(e,new g(r,o)),new g(t,o.slice(t-r,i-r))}}class p{constructor(e,t,i,n,o){this.text=e,this.to=o,this.done=!1,this.value=d,this.matchPos=v(e,n),this.re=new RegExp(t,u+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=g.get(e,n,this.chunkEnd(n+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,i=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,i,t)))return this.value={from:e,to:i,match:t},this.matchPos=v(this.text,i+(e==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=g.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function v(e,t){if(t>=e.length)return t;let i,n=e.lineAt(t);for(;t<n.to&&(i=n.text.charCodeAt(t-n.from))>=56320&&i<57344;)t++;return t}function b(e){let t=l("input",{class:"cm-textfield",name:"line",value:String(e.state.doc.lineAt(e.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!i)return;let{state:r}=e,s=r.doc.lineAt(r.selection.main.head),[,l,a,c,h]=i,d=c?+c.slice(1):0,u=a?+a:s.number;if(a&&h){let e=u/100;l&&(e=e*("-"==l?-1:1)+s.number/r.doc.lines),u=Math.round(r.doc.lines*e)}else a&&l&&(u=u*("-"==l?-1:1)+s.number);let f=r.doc.line(Math.max(1,Math.min(r.doc.lines,u))),m=o.EditorSelection.cursor(f.from+Math.max(0,Math.min(d,f.length)));e.dispatch({effects:[x.of(!1),n.EditorView.scrollIntoView(m.from,{y:"center"})],selection:m}),e.focus()}return{dom:l("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:x.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),i())},onsubmit:e=>{e.preventDefault(),i()}},l("label",e.state.phrase("Go to line"),": ",t)," ",l("button",{class:"cm-button",type:"submit"},e.state.phrase("go")),l("button",{name:"close",onclick:()=>{e.dispatch({effects:x.of(!1)}),e.focus()},"aria-label":e.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(f.prototype[Symbol.iterator]=p.prototype[Symbol.iterator]=function(){return this});const x=o.StateEffect.define(),w=o.StateField.define({create:()=>!0,update(e,t){for(let i of t.effects)i.is(x)&&(e=i.value);return e},provide:e=>n.showPanel.from(e,e=>e?b:null)}),y=n.EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),k={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},S=o.Facet.define({combine:e=>(0,o.combineConfig)(e,k,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});function C(e){let t=[L,A];return e&&t.push(S.of(e)),t}const M=n.Decoration.mark({class:"cm-selectionMatch"}),E=n.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function D(e,t,i,n){return!(0!=i&&e(t.sliceDoc(i-1,i))==o.CharCategory.Word||n!=t.doc.length&&e(t.sliceDoc(n,n+1))==o.CharCategory.Word)}const A=n.ViewPlugin.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(S),{state:i}=e,r=i.selection;if(r.ranges.length>1)return n.Decoration.none;let s,l=r.main,a=null;if(l.empty){if(!t.highlightWordAroundCursor)return n.Decoration.none;let e=i.wordAt(l.head);if(!e)return n.Decoration.none;a=i.charCategorizer(l.head),s=i.sliceDoc(e.from,e.to)}else{let e=l.to-l.from;if(e<t.minSelectionLength||e>200)return n.Decoration.none;if(t.wholeWords){if(s=i.sliceDoc(l.from,l.to),a=i.charCategorizer(l.head),!D(a,i,l.from,l.to)||!function(e,t,i,n){return e(t.sliceDoc(i,i+1))==o.CharCategory.Word&&e(t.sliceDoc(n-1,n))==o.CharCategory.Word}(a,i,l.from,l.to))return n.Decoration.none}else if(s=i.sliceDoc(l.from,l.to),!s)return n.Decoration.none}let c=[];for(let o of e.visibleRanges){let e=new h(i.doc,s,o.from,o.to);for(;!e.next().done;){let{from:o,to:r}=e.value;if((!a||D(a,i,o,r))&&(l.empty&&o<=l.from&&r>=l.to?c.push(E.range(o,r)):(o>=l.to||r<=l.from)&&c.push(M.range(o,r)),c.length>t.maxMatches))return n.Decoration.none}}return n.Decoration.set(c)}},{decorations:e=>e.decorations}),L=n.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),q=o.Facet.define({combine:e=>(0,o.combineConfig)(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new re(e),scrollToMatch:e=>n.EditorView.scrollIntoView(e)})});class P{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,u),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new T(this):new W(this)}getCursor(e,t=0,i){let n=e.doc?e:o.EditorState.create({doc:e});return null==i&&(i=n.doc.length),this.regexp?I(this,n,t,i):F(this,n,t,i)}}class R{constructor(e){this.spec=e}}function F(e,t,i,n){return new h(t.doc,e.unquoted,i,n,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(r=t.doc,s=t.charCategorizer(t.selection.main.head),(e,t,i,n)=>((n>e||n+i.length<t)&&(n=Math.max(0,e-2),i=r.sliceString(n,Math.min(r.length,t+2))),!(s(O(i,e-n))==o.CharCategory.Word&&s(V(i,e-n))==o.CharCategory.Word||s(V(i,t-n))==o.CharCategory.Word&&s(O(i,t-n))==o.CharCategory.Word))):void 0);var r,s}class W extends R{constructor(e){super(e)}nextMatch(e,t,i){let n=F(this.spec,e,i,e.doc.length).nextOverlapping();if(n.done){let i=Math.min(e.doc.length,t+this.spec.unquoted.length);n=F(this.spec,e,0,i).nextOverlapping()}return n.done||n.value.from==t&&n.value.to==i?null:n.value}prevMatchInRange(e,t,i){for(let n=i;;){let i=Math.max(t,n-1e4-this.spec.unquoted.length),o=F(this.spec,e,i,n),r=null;for(;!o.nextOverlapping().done;)r=o.value;if(r)return r;if(i==t)return null;n-=1e4}}prevMatch(e,t,i){let n=this.prevMatchInRange(e,0,t);return n||(n=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),!n||n.from==t&&n.to==i?null:n}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=F(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let o=F(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)n(o.value.from,o.value.to)}}function I(e,t,i,n){return new f(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(r=t.charCategorizer(t.selection.main.head),(e,t,i)=>!i[0].length||(r(O(i.input,i.index))!=o.CharCategory.Word||r(V(i.input,i.index))!=o.CharCategory.Word)&&(r(V(i.input,i.index+i[0].length))!=o.CharCategory.Word||r(O(i.input,i.index+i[0].length))!=o.CharCategory.Word)):void 0},i,n);var r}function O(e,t){return e.slice((0,o.findClusterBreak)(e,t,!1),t)}function V(e,t){return e.slice(t,(0,o.findClusterBreak)(e,t))}class T extends R{nextMatch(e,t,i){let n=I(this.spec,e,i,e.doc.length).next();return n.done&&(n=I(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let o=Math.max(t,i-1e4*n),r=I(this.spec,e,o,i),s=null;for(;!r.next().done;)s=r.value;if(s&&(o==t||s.from>o+10))return s;if(o==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if("&"==i)return e.match[0];if("$"==i)return"$";for(let t=i.length;t>0;t--){let n=+i.slice(0,t);if(n>0&&n<e.match.length)return e.match[n]+i.slice(t)}return t})}matchAll(e,t){let i=I(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let o=I(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!o.next().done;)n(o.value.from,o.value.to)}}const $=o.StateEffect.define(),z=o.StateEffect.define(),B=o.StateField.define({create:e=>new H(X(e).create(),null),update(e,t){for(let i of t.effects)i.is($)?e=new H(i.value.create(),e.panel):i.is(z)&&(e=new H(e.query,i.value?J:null));return e},provide:e=>n.showPanel.from(e,e=>e.panel)});class H{constructor(e,t){this.query=e,this.panel=t}}const _=n.Decoration.mark({class:"cm-searchMatch"}),N=n.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),G=n.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(B))}update(e){let t=e.state.field(B);(t!=e.startState.field(B)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return n.Decoration.none;let{view:i}=this,r=new o.RangeSetBuilder;for(let t=0,n=i.visibleRanges,o=n.length;t<o;t++){let{from:s,to:l}=n[t];for(;t<o-1&&l>n[t+1].from-500;)l=n[++t].to;e.highlight(i.state,s,l,(e,t)=>{let n=i.state.selection.ranges.some(i=>i.from==e&&i.to==t);r.add(e,t,n?N:_)})}return r.finish()}},{decorations:e=>e.decorations});function U(e){return t=>{let i=t.state.field(B,!1);return i&&i.query.spec.valid?e(t,i):ie(t)}}const j=U((e,{query:t})=>{let{to:i}=e.state.selection.main,n=t.nextMatch(e.state,i,i);if(!n)return!1;let r=o.EditorSelection.single(n.from,n.to),s=e.state.facet(q);return e.dispatch({selection:r,effects:[ce(e,n),s.scrollToMatch(r.main,e)],userEvent:"select.search"}),te(e),!0}),K=U((e,{query:t})=>{let{state:i}=e,{from:n}=i.selection.main,r=t.prevMatch(i,n,n);if(!r)return!1;let s=o.EditorSelection.single(r.from,r.to),l=e.state.facet(q);return e.dispatch({selection:s,effects:[ce(e,r),l.scrollToMatch(s.main,e)],userEvent:"select.search"}),te(e),!0}),Q=U((e,{query:t})=>{let i=t.matchAll(e.state,1e3);return!(!i||!i.length||(e.dispatch({selection:o.EditorSelection.create(i.map(e=>o.EditorSelection.range(e.from,e.to))),userEvent:"select.search.matches"}),0))}),Y=U((e,{query:t})=>{let{state:i}=e,{from:r,to:s}=i.selection.main;if(i.readOnly)return!1;let l=t.nextMatch(i,r,r);if(!l)return!1;let a,c,h=l,d=[],u=[];h.from==r&&h.to==s&&(c=i.toText(t.getReplacement(h)),d.push({from:h.from,to:h.to,insert:c}),h=t.nextMatch(i,h.from,h.to),u.push(n.EditorView.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(r).number)+".")));let f=e.state.changes(d);return h&&(a=o.EditorSelection.single(h.from,h.to).map(f),u.push(ce(e,h)),u.push(i.facet(q).scrollToMatch(a.main,e))),e.dispatch({changes:f,selection:a,effects:u,userEvent:"input.replace"}),!0}),Z=U((e,{query:t})=>{if(e.state.readOnly)return!1;let i=t.matchAll(e.state,1e9).map(e=>{let{from:i,to:n}=e;return{from:i,to:n,insert:t.getReplacement(e)}});if(!i.length)return!1;let o=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:n.EditorView.announce.of(o),userEvent:"input.replace.all"}),!0});function J(e){return e.state.facet(q).createPanel(e)}function X(e,t){var i,n,o,r,s;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let c=e.facet(q);return new P({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==t?void 0:t.caseSensitive)&&void 0!==n?n:c.caseSensitive,literal:null!==(o=null==t?void 0:t.literal)&&void 0!==o?o:c.literal,regexp:null!==(r=null==t?void 0:t.regexp)&&void 0!==r?r:c.regexp,wholeWord:null!==(s=null==t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function ee(e){let t=(0,n.getPanel)(e,J);return t&&t.dom.querySelector("[main-field]")}function te(e){let t=ee(e);t&&t==e.root.activeElement&&t.select()}const ie=e=>{let t=e.state.field(B,!1);if(t&&t.panel){let i=ee(e);if(i&&i!=e.root.activeElement){let n=X(e.state,t.query.spec);n.valid&&e.dispatch({effects:$.of(n)}),i.focus(),i.select()}}else e.dispatch({effects:[z.of(!0),t?$.of(X(e.state,t.query.spec)):o.StateEffect.appendConfig.of(de)]});return!0},ne=e=>{let t=e.state.field(B,!1);if(!t||!t.panel)return!1;let i=(0,n.getPanel)(e,J);return i&&i.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:z.of(!1)}),!0},oe=[{key:"Mod-f",run:ie,scope:"editor search-panel"},{key:"F3",run:j,shift:K,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:j,shift:K,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ne,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let i=e.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:r}=i.main,s=[],l=0;for(let t=new h(e.doc,e.sliceDoc(n,r));!t.next().done;){if(s.length>1e3)return!1;t.value.from==n&&(l=s.length),s.push(o.EditorSelection.range(t.value.from,t.value.to))}return t(e.update({selection:o.EditorSelection.create(s,l),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let t=(0,n.getPanel)(e,b);if(!t){let i=[x.of(!0)];null==e.state.field(w,!1)&&i.push(o.StateEffect.appendConfig.of([w,y])),e.dispatch({effects:i}),t=(0,n.getPanel)(e,b)}return t&&t.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:i}=e.selection;if(i.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:i}=e,n=o.EditorSelection.create(i.ranges.map(t=>e.wordAt(t.head)||o.EditorSelection.cursor(t.head)),i.mainIndex);return!n.eq(i)&&(t(e.update({selection:n})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let s=function(e,t){let{main:i,ranges:n}=e.selection,o=e.wordAt(i.head),r=o&&o.from==i.from&&o.to==i.to;for(let i=!1,o=new h(e.doc,t,n[n.length-1].to);;){if(o.next(),!o.done){if(i&&n.some(e=>e.from==o.value.from))continue;if(r){let t=e.wordAt(o.value.from);if(!t||t.from!=o.value.from||t.to!=o.value.to)continue}return o.value}if(i)return null;o=new h(e.doc,t,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(e,r);return!!s&&(t(e.update({selection:e.selection.addRange(o.EditorSelection.range(s.from,s.to),!1),effects:n.EditorView.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class re{constructor(e){this.view=e;let t=this.query=e.state.field(B).query.spec;function i(e,t,i){return l("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=l("input",{value:t.search,placeholder:se(e,"Find"),"aria-label":se(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=l("input",{value:t.replace,placeholder:se(e,"Replace"),"aria-label":se(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=l("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=l("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=l("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=l("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",()=>j(e),[se(e,"next")]),i("prev",()=>K(e),[se(e,"previous")]),i("select",()=>Q(e),[se(e,"all")]),l("label",null,[this.caseField,se(e,"match case")]),l("label",null,[this.reField,se(e,"regexp")]),l("label",null,[this.wordField,se(e,"by word")]),...e.state.readOnly?[]:[l("br"),this.replaceField,i("replace",()=>Y(e),[se(e,"replace")]),i("replaceAll",()=>Z(e),[se(e,"replace all")])],l("button",{name:"close",onclick:()=>ne(e),"aria-label":se(e,"close"),type:"button"},["×"])])}commit(){let e=new P({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:$.of(e)}))}keydown(e){(0,n.runScopeHandlers)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?K:j)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),Y(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is($)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(q).top}}function se(e,t){return e.state.phrase(t)}const le=30,ae=/[\s\.,:;?!]/;function ce(e,{from:t,to:i}){let o=e.state.doc.lineAt(t),r=e.state.doc.lineAt(i).to,s=Math.max(o.from,t-le),l=Math.min(r,i+le),a=e.state.sliceDoc(s,l);if(s!=o.from)for(let e=0;e<le;e++)if(!ae.test(a[e+1])&&ae.test(a[e])){a=a.slice(e);break}if(l!=r)for(let e=a.length-1;e>a.length-le;e--)if(!ae.test(a[e-1])&&ae.test(a[e])){a=a.slice(0,e);break}return n.EditorView.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${o.number}.`)}const he=n.EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),de=[B,o.Prec.low(G),he];var ue=i(2747);class fe{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class me{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(Me).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),l=new o.RangeSetBuilder,a=[],c=0;for(let e=0;;){let t,o,r=e==s.length?null:s[e];if(!r&&!a.length)break;for(a.length?(t=c,o=a.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8)):(t=r.from,o=r.to,a.push(r),e++);e<s.length;){let i=s[e];if(i.from!=t||!(i.to>i.from||i.to==t)){o=Math.min(i.from,o);break}a.push(i),e++,o=Math.min(i.to,o)}let h=We(a);if(a.some(e=>e.from==e.to||e.from==e.to-1&&i.doc.lineAt(e.from).to==e.from))l.add(t,t,n.Decoration.widget({widget:new Ae(h),diagnostics:a.slice()}));else{let e=a.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");l.add(t,o,n.Decoration.mark({class:"cm-lintRange cm-lintRange-"+h+e,diagnostics:a.slice(),inclusiveEnd:a.some(e=>e.to>o)}))}c=o;for(let e=0;e<a.length;e++)a[e].to<=c&&a.splice(e--,1)}let h=l.finish();return new me(h,t,ge(h))}}function ge(e,t=null,i=0){let n=null;return e.between(i,1e9,(e,i,{spec:o})=>{if(!(t&&o.diagnostics.indexOf(t)<0))if(n){if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new fe(n.from,i,n.diagnostic)}else n=new fe(e,i,t||o.diagnostics[0])}),n}const pe=o.StateEffect.define(),ve=o.StateEffect.define(),be=o.StateEffect.define(),xe=o.StateField.define({create:()=>new me(n.Decoration.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let i=e.diagnostics.map(t.changes),n=null,o=e.panel;if(e.selected){let o=t.changes.mapPos(e.selected.from,1);n=ge(i,e.selected.diagnostic,o)||ge(i,null,o)}!i.size&&o&&t.state.facet(Me).autoPanel&&(o=null),e=new me(i,o,n)}for(let i of t.effects)if(i.is(pe)){let n=t.state.facet(Me).autoPanel?i.value.length?qe.open:null:e.panel;e=me.init(i.value,n,t.state)}else i.is(ve)?e=new me(e.diagnostics,i.value?qe.open:null,e.selected):i.is(be)&&(e=new me(e.diagnostics,e.panel,i.value));return e},provide:e=>[n.showPanel.from(e,e=>e.panel),n.EditorView.decorations.from(e,e=>e.diagnostics)]}),we=n.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function ye(e,t,i){let n,{diagnostics:o}=e.state.field(xe),r=-1,s=-1;o.between(t-(i<0?1:0),t+(i>0?1:0),(e,o,{spec:l})=>{if(t>=e&&t<=o&&(e==o||(t>e||i>0)&&(t<o||i<0)))return n=l.diagnostics,r=e,s=o,!1});let l=e.state.facet(Me).tooltipFilter;return n&&l&&(n=l(n,e.state)),n?{pos:r,end:s,above:e.state.doc.lineAt(r).to<s,create:()=>({dom:ke(e,n)})}:null}function ke(e,t){return l("ul",{class:"cm-tooltip-lint"},t.map(t=>De(e,t,!1)))}const Se=e=>{let t=e.state.field(xe,!1);return!(!t||!t.panel||(e.dispatch({effects:ve.of(!1)}),0))},Ce=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(xe,!1);var i,r;t&&t.panel||e.dispatch({effects:(i=e.state,r=[ve.of(!0)],i.field(xe,!1)?r:r.concat(o.StateEffect.appendConfig.of(Ie)))});let s=(0,n.getPanel)(e,qe.open);return s&&s.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(xe,!1);if(!t)return!1;let i=e.state.selection.main,n=t.diagnostics.iter(i.to+1);return!(!n.value&&(n=t.diagnostics.iter(0),!n.value||n.from==i.from&&n.to==i.to)||(e.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),0))}}],Me=o.Facet.define({combine:e=>Object.assign({sources:e.map(e=>e.source).filter(e=>null!=e)},(0,o.combineConfig)(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))});function Ee(e){let t=[];if(e)e:for(let{name:i}of e){for(let e=0;e<i.length;e++){let n=i[e];if(/[a-zA-Z]/.test(n)&&!t.some(e=>e.toLowerCase()==n.toLowerCase())){t.push(n);continue e}}t.push("")}return t}function De(e,t,i){var n;let o=i?Ee(t.actions):[];return l("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},l("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(n=t.actions)||void 0===n?void 0:n.map((i,n)=>{let r=!1,s=n=>{if(n.preventDefault(),r)return;r=!0;let o=ge(e.state.field(xe).diagnostics,t);o&&i.apply(e,o.from,o.to)},{name:a}=i,c=o[n]?a.indexOf(o[n]):-1,h=c<0?a:[a.slice(0,c),l("u",a.slice(c,c+1)),a.slice(c+1)];return l("button",{type:"button",class:"cm-diagnosticAction",onclick:s,onmousedown:s,"aria-label":` Action: ${a}${c<0?"":` (access key "${o[n]})"`}.`},h)}),t.source&&l("div",{class:"cm-diagnosticSource"},t.source))}class Ae extends n.WidgetType{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return l("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Le{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=De(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class qe{constructor(e){this.view=e,this.items=[],this.list=l("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)Se(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],n=Ee(i.actions);for(let o=0;o<n.length;o++)if(n[o].toUpperCase().charCodeAt(0)==t.keyCode){let t=ge(this.view.state.field(xe).diagnostics,i);t&&i.actions[o].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=l("div",{class:"cm-panel-lint"},this.list,l("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Se(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(xe).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(xe),i=0,n=!1,o=null,r=new Set;for(e.between(0,this.view.state.doc.length,(e,s,{spec:l})=>{for(let e of l.diagnostics){if(r.has(e))continue;r.add(e);let s,l=-1;for(let t=i;t<this.items.length;t++)if(this.items[t].diagnostic==e){l=t;break}l<0?(s=new Le(this.view,e),this.items.splice(i,0,s),n=!0):(s=this.items[l],l>i&&(this.items.splice(i,l-i),n=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute("aria-selected")||(s.dom.setAttribute("aria-selected","true"),o=s):s.dom.hasAttribute("aria-selected")&&s.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();0==this.items.length&&(this.items.push(new Le(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let i=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/i:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=ge(this.view.state.field(xe).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:be.of(t)})}static open(e){return new qe(e)}}function Pe(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Re=n.EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Pe("#d11")},".cm-lintRange-warning":{backgroundImage:Pe("orange")},".cm-lintRange-info":{backgroundImage:Pe("#999")},".cm-lintRange-hint":{backgroundImage:Pe("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Fe(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function We(e){let t="hint",i=1;for(let n of e){let e=Fe(n.severity);e>i&&(i=e,t=n.severity)}return t}n.GutterMarker;const Ie=[xe,n.EditorView.decorations.compute([xe],e=>{let{selected:t,panel:i}=e.field(xe);return t&&i&&t.from!=t.to?n.Decoration.set([we.range(t.from,t.to)]):n.Decoration.none}),(0,n.hoverTooltip)(ye,{hideOn:function(e,t){let i=t.pos,n=t.end||i,o=e.state.facet(Me).hideOn(e,i,n);if(null!=o)return o;let r=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(pe))&&!e.changes.touchesRange(r.from,Math.max(r.to,n)))}}),Re],Oe=(()=>[(0,n.lineNumbers)(),(0,n.highlightActiveLineGutter)(),(0,n.highlightSpecialChars)(),(0,s.b6)(),(0,r.foldGutter)(),(0,n.drawSelection)(),(0,n.dropCursor)(),o.EditorState.allowMultipleSelections.of(!0),(0,r.indentOnInput)(),(0,r.syntaxHighlighting)(r.defaultHighlightStyle,{fallback:!0}),(0,r.bracketMatching)(),(0,ue.wm)(),(0,ue.yU)(),(0,n.rectangularSelection)(),(0,n.crosshairCursor)(),(0,n.highlightActiveLine)(),C(),n.keymap.of([...ue.Bc,...s.pw,...oe,...s.cL,...r.foldKeymap,...ue.OO,...Ce])])(),Ve=(()=>[(0,n.highlightSpecialChars)(),(0,s.b6)(),(0,n.drawSelection)(),(0,r.syntaxHighlighting)(r.defaultHighlightStyle,{fallback:!0}),n.keymap.of([...s.pw,...s.cL])])()}}]);