signalpilot-ai-internal 0.10.0__py3-none-any.whl → 0.11.24__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 (85) hide show
  1. signalpilot_ai_internal/__init__.py +1 -0
  2. signalpilot_ai_internal/_version.py +1 -1
  3. signalpilot_ai_internal/cache_service.py +22 -21
  4. signalpilot_ai_internal/composio_handlers.py +224 -0
  5. signalpilot_ai_internal/composio_service.py +511 -0
  6. signalpilot_ai_internal/database_config_handlers.py +182 -0
  7. signalpilot_ai_internal/database_config_service.py +166 -0
  8. signalpilot_ai_internal/databricks_schema_service.py +907 -0
  9. signalpilot_ai_internal/file_scanner_service.py +5 -146
  10. signalpilot_ai_internal/handlers.py +388 -9
  11. signalpilot_ai_internal/integrations_config.py +256 -0
  12. signalpilot_ai_internal/log_utils.py +31 -0
  13. signalpilot_ai_internal/mcp_handlers.py +532 -0
  14. signalpilot_ai_internal/mcp_server_manager.py +298 -0
  15. signalpilot_ai_internal/mcp_service.py +1255 -0
  16. signalpilot_ai_internal/oauth_token_store.py +141 -0
  17. signalpilot_ai_internal/schema_search_config.yml +17 -11
  18. signalpilot_ai_internal/schema_search_service.py +85 -4
  19. signalpilot_ai_internal/signalpilot_home.py +961 -0
  20. signalpilot_ai_internal/snowflake_schema_service.py +2 -0
  21. signalpilot_ai_internal/test_dbt_mcp_server.py +180 -0
  22. signalpilot_ai_internal/unified_database_schema_service.py +2 -0
  23. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/schemas/signalpilot-ai-internal/package.json.orig → signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/package.json +15 -48
  24. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/package.json → signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/schemas/signalpilot-ai-internal/package.json.orig +9 -52
  25. {signalpilot_ai_internal-0.10.0.data → signalpilot_ai_internal-0.11.24.data}/data/share/jupyter/labextensions/signalpilot-ai-internal/schemas/signalpilot-ai-internal/plugin.json +7 -1
  26. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/122.bab318d6caadb055e29c.js +1 -0
  27. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/129.868ca665e6fc225c20a0.js +1 -0
  28. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/179.fd45a2e75d471d0aa3b9.js +7 -0
  29. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/220.81105a94aa873fc51a94.js +1 -0
  30. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/262.a002dd4630d3b6404a90.js +1 -0
  31. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/353.cc6f6ecacd703bcdb468.js +1 -0
  32. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/364.817a883549d55a0e0576.js +1 -0
  33. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/384.a4daecd44f1e9364e44a.js +1 -0
  34. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/439.667225aab294fb5ed161.js +1 -0
  35. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/447.8138af2522716e5a926f.js +1 -0
  36. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/476.925c73e32f3c07448da0.js +1 -0
  37. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/477.aaa4cc9e87801fb45f5b.js +1 -0
  38. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/481.370056149a59022b700c.js +1 -0
  39. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/510.868ca665e6fc225c20a0.js +1 -0
  40. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/512.835f97f7ccfc70ff5c93.js +1 -0
  41. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/57.6c13335f73de089d6b1e.js +1 -0
  42. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/574.ad2709e91ebcac5bbe68.js +1 -0
  43. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/635.bddbab8e464fe31f0393.js +1 -0
  44. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/713.fda1bcdb10497b0a6ade.js +1 -0
  45. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/741.d046701f475fcbf6697d.js +1 -0
  46. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/785.c306dffd4cfe8a613d13.js +1 -0
  47. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/801.e39898b6f336539f228c.js +1 -0
  48. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/880.77cc0ca10a1860df1b52.js +1 -0
  49. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/936.4e2850b2af985ed0d378.js +1 -0
  50. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/956.eeffe67d7781fd63ef4b.js +2 -0
  51. signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/remoteEntry.055f50d20a31f3068c72.js +1 -0
  52. {signalpilot_ai_internal-0.10.0.data → signalpilot_ai_internal-0.11.24.data}/data/share/jupyter/labextensions/signalpilot-ai-internal/static/third-party-licenses.json +47 -29
  53. {signalpilot_ai_internal-0.10.0.dist-info → signalpilot_ai_internal-0.11.24.dist-info}/METADATA +14 -31
  54. signalpilot_ai_internal-0.11.24.dist-info/RECORD +66 -0
  55. signalpilot_ai_internal-0.11.24.dist-info/licenses/LICENSE +7 -0
  56. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/122.e2dadf63dc64d7b5f1ee.js +0 -1
  57. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/220.328403b5545f268b95c6.js +0 -1
  58. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/262.726e1da31a50868cb297.js +0 -1
  59. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/330.af2e9cb5def5ae2b84d5.js +0 -1
  60. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/353.972abe1d2d66f083f9cc.js +0 -1
  61. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/364.dbec4c2dc12e7b050dcc.js +0 -1
  62. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/384.fa432bdb7fb6b1c95ad6.js +0 -1
  63. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/439.37e271d7a80336daabe2.js +0 -1
  64. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/476.ad22ccddd74ee306fb56.js +0 -1
  65. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/481.73c7a9290b7d35a8b9c1.js +0 -1
  66. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/512.b58fc0093d080b8ee61c.js +0 -1
  67. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/553.b4042a795c91d9ff71ef.js +0 -2
  68. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/57.e9acd2e1f9739037f1ab.js +0 -1
  69. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/635.9720593ee20b768da3ca.js +0 -1
  70. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/713.8e6edc9a965bdd578ca7.js +0 -1
  71. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/741.dc49867fafb03ea2ba4d.js +0 -1
  72. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/742.91e7b516c8699eea3373.js +0 -1
  73. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/785.2d75de1a8d2c3131a8db.js +0 -1
  74. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/786.770dc7bcab77e14cc135.js +0 -7
  75. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/801.ca9e114a30896b669a3c.js +0 -1
  76. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/880.25ddd15aca09421d3765.js +0 -1
  77. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/888.34054db17bcf6e87ec95.js +0 -1
  78. signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/remoteEntry.b05b2f0c9617ba28370d.js +0 -1
  79. signalpilot_ai_internal-0.10.0.dist-info/RECORD +0 -50
  80. signalpilot_ai_internal-0.10.0.dist-info/licenses/LICENSE +0 -29
  81. {signalpilot_ai_internal-0.10.0.data → signalpilot_ai_internal-0.11.24.data}/data/etc/jupyter/jupyter_server_config.d/signalpilot_ai.json +0 -0
  82. {signalpilot_ai_internal-0.10.0.data → signalpilot_ai_internal-0.11.24.data}/data/share/jupyter/labextensions/signalpilot-ai-internal/install.json +0 -0
  83. /signalpilot_ai_internal-0.10.0.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/553.b4042a795c91d9ff71ef.js.LICENSE.txt → /signalpilot_ai_internal-0.11.24.data/data/share/jupyter/labextensions/signalpilot-ai-internal/static/956.eeffe67d7781fd63ef4b.js.LICENSE.txt +0 -0
  84. {signalpilot_ai_internal-0.10.0.data → signalpilot_ai_internal-0.11.24.data}/data/share/jupyter/labextensions/signalpilot-ai-internal/static/style.js +0 -0
  85. {signalpilot_ai_internal-0.10.0.dist-info → signalpilot_ai_internal-0.11.24.dist-info}/WHEEL +0 -0
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunksignalpilot_ai_internal=self.webpackChunksignalpilot_ai_internal||[]).push([[635],{67635:(e,t,n)=>{n.r(t),n.d(t,{Change:()=>m,Chunk:()=>X,MergeView:()=>Oe,acceptAllChunks:()=>$e,acceptChunk:()=>Ye,applyGeneratedCode:()=>He,diff:()=>U,generateCodeEffect:()=>Pe,getChunks:()=>$,getOriginalDoc:()=>Ie,goToNextChunk:()=>K,goToPreviousChunk:()=>Q,originalDocChangeEffect:()=>_e,presentableDiff:()=>W,rejectAllChunks:()=>Je,rejectChunk:()=>Ze,uncollapseUnchanged:()=>we,unifiedMergeView:()=>Ne,updateOriginalDoc:()=>Ge});var r=n(45024),o=n(60195);const i="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),s="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class a{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function o(e,t,i,s){let l=[],a=/^@(\w+)\b/.exec(e[0]),c=a&&"keyframes"==a[1];if(a&&null==t)return i.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))o(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),s,i);else if(s&&"object"==typeof s){if(!a)throw new RangeError("The value of a property ("+n+") should be a primitive value.");o(r(n),s,l,c)}else null!=s&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+s+";")}(l.length||c)&&i.push((!n||a||s?e:e.map(n)).join(", ")+" {"+l.join(" ")+"}")}for(let t in e)o(r(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=l[i]||1;return l[i]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let r=e[s],o=n&&n.nonce;r?o&&r.setNonce(o):r=new f(e,o),r.mount(Array.isArray(t)?t:[t],e)}}let c=new Map;class f{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=c.get(n);if(t)return e[s]=t;this.sheet=new r.CSSStyleSheet,c.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[s]=this}mount(e,t){let n=this.sheet,r=0,o=0;for(let t=0;t<e.length;t++){let i=e[t],s=this.modules.indexOf(i);if(s<o&&s>-1&&(this.modules.splice(s,1),o--,s=-1),-1==s){if(this.modules.splice(o++,0,i),n)for(let e=0;e<i.rules.length;e++)n.insertRule(i.rules[e],r++)}else{for(;o<s;)r+=this.modules[o++].rules.length;r+=i.rules.length,o++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var h=n(44353),d=n(72084),u=n(51839);class m{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(e,t=e){return new m(this.fromA+e,this.toA+e,this.fromB+t,this.toB+t)}}function g(e,t,n,r,o,i){if(e==r)return[];let s=x(e,t,n,r,o,i),l=S(e,t+s,n,r,o+s,i),a=(n-=l)-(t+=s),c=(i-=l)-(o+=s);if(!a||!c)return[new m(t,n,o,i)];if(a>c){let s=e.slice(t,n).indexOf(r.slice(o,i));if(s>-1)return[new m(t,t+s,o,o),new m(t+s+c,n,i,i)]}else if(c>a){let s=r.slice(o,i).indexOf(e.slice(t,n));if(s>-1)return[new m(t,t,o,o+s),new m(n,n,o+s+a,i)]}if(1==a||1==c)return[new m(t,n,o,i)];let f=D(e,t,n,r,o,i);if(f){let[s,l,a]=f;return g(e,t,s,r,o,l).concat(g(e,s+a,n,r,l+a,i))}return function(e,t,n,r,o,i){let s=n-t,l=i-o;if(p<1e9&&Math.min(s,l)>16*p||A>0&&Date.now()>A)return Math.min(s,l)>64*p?[new m(t,n,o,i)]:E(e,t,n,r,o,i);let a=Math.ceil((s+l)/2);b.reset(a),C.reset(a);let c=(n,i)=>e.charCodeAt(t+n)==r.charCodeAt(o+i),f=(t,o)=>e.charCodeAt(n-t-1)==r.charCodeAt(i-o-1),h=(s-l)%2!=0?C:null,d=h?null:b;for(let u=0;u<a;u++){if(u>p||A>0&&!(63&u)&&Date.now()>A)return E(e,t,n,r,o,i);let m=b.advance(u,s,l,a,h,!1,c)||C.advance(u,s,l,a,d,!0,f);if(m)return w(e,t,n,t+m[0],r,o,i,o+m[1])}return[new m(t,n,o,i)]}(e,t,n,r,o,i)}let p=1e9,A=0,v=!1;class B{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,o,i,s){for(let l=-e+this.start;l<=e-this.end;l+=2){let a=r+l,c=l==-e||l!=e&&this.vec[a-1]<this.vec[a+1]?this.vec[a+1]:this.vec[a-1]+1,f=c-l;for(;c<t&&f<n&&s(c,f);)c++,f++;if(this.vec[a]=c,c>t)this.end+=2;else if(f>n)this.start+=2;else if(o){let e=r+(t-n)-l;if(e>=0&&e<this.len&&-1!=o.vec[e])if(i){let n=o.vec[e];if(n>=t-c)return[n,r+n-e]}else if(c>=t-o.vec[e])return[c,f]}}return null}}const b=new B,C=new B;function w(e,t,n,r,o,i,s,l){let a=!1;return H(e,r)||++r!=n||(a=!0),H(o,l)||++l!=s||(a=!0),a?[new m(t,n,i,s)]:g(e,t,r,o,i,l).concat(g(e,r,n,o,l,s))}function k(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function x(e,t,n,r,o,i){if(t==n||t==i||e.charCodeAt(t)!=r.charCodeAt(o))return 0;let s=k(n-t,i-o);for(let l=t,a=o;;){let o=l+s,c=a+s;if(o>n||c>i||e.slice(l,o)!=r.slice(a,c)){if(1==s)return l-t-(H(e,l)?0:1);s>>=1}else{if(o==n||c==i)return o-t;l=o,a=c}}}function S(e,t,n,r,o,i){if(t==n||o==i||e.charCodeAt(n-1)!=r.charCodeAt(i-1))return 0;let s=k(n-t,i-o);for(let l=n,a=i;;){let i=l-s,c=a-s;if(i<t||c<o||e.slice(i,l)!=r.slice(c,a)){if(1==s)return n-l-(H(e,l)?0:1);s>>=1}else{if(i==t||c==o)return n-i;l=i,a=c}}}function M(e,t,n,r,o,i,s,l){let a=r.slice(o,i),c=null;for(;;){if(c||s<l)return c;for(let l=t+s;;){H(e,l)||l++;let f=l+s;if(H(e,f)||(f+=f==l+1?1:-1),f>=n)break;let h=e.slice(l,f),d=-1;for(;-1!=(d=a.indexOf(h,d+1));){let s=x(e,f,n,r,o+d+h.length,i),a=S(e,t,l,r,o,o+d),u=h.length+s+a;(!c||c[2]<u)&&(c=[l-a,o+d-a,u])}l=f}if(l<0)return c;s>>=1}}function D(e,t,n,r,o,i){let s=n-t,l=i-o;if(s<l){let s=D(r,o,i,e,t,n);return s&&[s[1],s[0],s[2]]}return s<4||2*l<s?null:M(e,t,n,r,o,i,Math.floor(s/4),-1)}function E(e,t,n,r,o,i){v=!0;let s,l=n-t,a=i-o;if(l<a){let a=M(r,o,i,e,t,n,Math.floor(l/6),50);s=a&&[a[1],a[0],a[2]]}else s=M(e,t,n,r,o,i,Math.floor(a/6),50);if(!s)return[new m(t,n,o,i)];let[c,f,h]=s;return g(e,t,c,r,o,f).concat(g(e,c+h,n,r,f+h,i))}function y(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],o=e[n];r.toA>o.fromA-t&&r.toB>o.fromB-t&&(e[n-1]=new m(r.fromA,o.toA,r.fromB,o.toB),e.splice(n--,1))}}let T;try{T=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch(e){}function O(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function L(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?O(n)?1:0:T?P(n)&&t!=e.length-1?T.test(e.slice(t,t+2))?2:0:T.test(String.fromCharCode(n))?1:0:0}function R(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?O(n)?1:0:T?_(n)&&1!=t?T.test(e.slice(t-2,t))?2:0:T.test(String.fromCharCode(n))?1:0:0}const V=8;function N(e,t,n){if(t==e.length||!R(e,t))return t;for(let r=t,o=t+n,i=0;i<V;i++){let t=L(e,r);if(!t||r+t>o)return r;r+=t}return t}function G(e,t,n){if(!t||!L(e,t))return t;for(let r=t,o=t-n,i=0;i<V;i++){let t=R(e,r);if(!t||r-t<o)return r;r-=t}return t}function F(e,t,n){for(;t!=n;t--)if(10==e.charCodeAt(t-1))return t;return-1}function j(e,t,n){for(;t!=n;t++)if(10==e.charCodeAt(t))return t;return-1}const P=e=>e>=55296&&e<=56319,_=e=>e>=56320&&e<=57343;function H(e,t){return!t||t==e.length||!P(e.charCodeAt(t-1))||!_(e.charCodeAt(t))}function U(e,t,n){var r;return p=(null!==(r=null==n?void 0:n.scanLimit)&&void 0!==r?r:1e9)>>1,A=(null==n?void 0:n.timeout)?Date.now()+n.timeout:0,v=!1,function(e,t,n){for(;;){y(n,1);let r=!1;for(let o=0;o<n.length;o++){let i,s,l=n[o];(i=x(e,l.fromA,l.toA,t,l.fromB,l.toB))&&(l=n[o]=new m(l.fromA+i,l.toA,l.fromB+i,l.toB)),(s=S(e,l.fromA,l.toA,t,l.fromB,l.toB))&&(l=n[o]=new m(l.fromA,l.toA-s,l.fromB,l.toB-s));let a=l.toA-l.fromA,c=l.toB-l.fromB;if(a&&c)continue;let f=l.fromA-(o?n[o-1].toA:0),h=(o<n.length-1?n[o+1].fromA:e.length)-l.toA;if(!f||!h)continue;let d=a?e.slice(l.fromA,l.toA):t.slice(l.fromB,l.toB);f<=d.length&&e.slice(l.fromA-f,l.fromA)==d.slice(d.length-f)?(n[o]=new m(l.fromA-f,l.toA-f,l.fromB-f,l.toB-f),r=!0):h<=d.length&&e.slice(l.toA,l.toA+h)==d.slice(0,h)&&(n[o]=new m(l.fromA+h,l.toA+h,l.fromB+h,l.toB+h),r=!0)}if(!r)break}return n}(e,t,g(e,0,e.length,t,0,t.length))}function I(){return!v}function W(e,t,n){return function(e,t,n){for(let r=0,o=0;o<e.length;o++){let i=e[o],s=i.toA-i.fromA,l=i.toB-i.fromB;if(s&&l||s>3||l>3){let a=o==e.length-1?t.length:e[o+1].fromA,c=i.fromA-r,f=a-i.toA,h=G(t,i.fromA,c),d=N(t,i.toA,f),u=i.fromA-h,g=d-i.toA;if((!s||!l)&&u&&g){let c=Math.max(s,l),[f,p,A]=s?[t,i.fromA,i.toA]:[n,i.fromB,i.toB];c>u&&t.slice(h,i.fromA)==f.slice(A-u,A)?(i=e[o]=new m(h,h+s,i.fromB-u,i.toB-u),h=i.fromA,d=N(t,i.toA,a-i.toA)):c>g&&t.slice(i.toA,d)==f.slice(p,p+g)&&(i=e[o]=new m(d-s,d,i.fromB+g,i.toB+g),d=i.toA,h=G(t,i.fromA,i.fromA-r)),u=i.fromA-h,g=d-i.toA}if(u||g)i=e[o]=new m(i.fromA-u,i.toA+g,i.fromB-u,i.toB+g);else if(s){if(!l){let n,r=j(t,i.fromA,i.toA),s=r<0?-1:F(t,i.toA,i.fromA);r>-1&&(n=r-i.fromA)<=f&&t.slice(i.fromA,r)==t.slice(i.toA,i.toA+n)?i=e[o]=i.offset(n):s>-1&&(n=i.toA-s)<=c&&t.slice(i.fromA-n,i.fromA)==t.slice(s,i.toA)&&(i=e[o]=i.offset(-n))}}else{let t,r=j(n,i.fromB,i.toB),s=r<0?-1:F(n,i.toB,i.fromB);r>-1&&(t=r-i.fromB)<=f&&n.slice(i.fromB,r)==n.slice(i.toB,i.toB+t)?i=e[o]=i.offset(t):s>-1&&(t=i.toB-s)<=c&&n.slice(i.fromB-t,i.fromB)==n.slice(s,i.toB)&&(i=e[o]=i.offset(-t))}}r=i.toA}return y(e,3),e}(U(e,t,n),e,t)}const q=o.Facet.define({combine:e=>e[0]}),z=o.StateEffect.define(),Y=o.Facet.define(),Z=o.StateField.define({create:e=>null,update(e,t){for(let n of t.effects)n.is(z)&&(e=n.value);for(let n of t.state.facet(Y))e=n(e,t);return e}});function $(e){let t=e.field(Z,!1);if(!t)return null;let n=e.facet(q);return{chunks:t,side:n?n.side:null}}let J=e=>({state:t,dispatch:n})=>{let i=t.field(Z,!1),s=t.facet(q);if(!i||!i.length||!s)return!1;let{head:l}=t.selection.main,a=0;for(let t=i.length-1;t>=0;t--){let n=i[t],[r,o]="b"==s.side?[n.fromB,n.toB]:[n.fromA,n.toA];if(o<l){a=t+1;break}if(r<=l){if(1==i.length)return!1;a=t+(e<0?0:1);break}}let c=i[(a+(e<0?i.length-1:0))%i.length],[f,h]="b"==s.side?[c.fromB,c.toB]:[c.fromA,c.toA];return n(t.update({selection:{anchor:f},userEvent:"select.byChunk",effects:r.EditorView.scrollIntoView(o.EditorSelection.range(h,f))})),!0};const K=J(1),Q=J(-1);class X{constructor(e,t,n,r,o,i=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=o,this.precise=i}offset(e,t){return e||t?new X(this.changes,this.fromA+e,this.toA+e,this.fromB+t,this.toB+t,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return ne(W(e.toString(),t.toString(),n),e,t,0,0,I())}static updateA(e,t,n,r,o){return se(ie(e,r,!0,n.length),e,t,n,o)}static updateB(e,t,n,r,o){return se(ie(e,r,!1,t.length),e,t,n,o)}}function ee(e,t,n,r){let o=n.lineAt(e),i=r.lineAt(t);return o.to==e&&i.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[o.from,i.from]}function te(e,t,n,r){let o=n.lineAt(e),i=r.lineAt(t);return o.from==e&&i.from==t?[e,t]:[o.to+1,i.to+1]}function ne(e,t,n,r,o,i){let s=[];for(let l=0;l<e.length;l++){let a=e[l],[c,f]=ee(a.fromA+r,a.fromB+o,t,n),[h,d]=te(a.toA+r,a.toB+o,t,n),u=[a.offset(-c+r,-f+o)];for(;l<e.length-1;){let i=e[l+1],[s,a]=ee(i.fromA+r,i.fromB+o,t,n);if(s>h+1&&a>d+1)break;u.push(i.offset(-c+r,-f+o)),[h,d]=te(i.toA+r,i.toB+o,t,n),l++}s.push(new X(u,c,Math.max(c,h),f,Math.max(f,d),i))}return s}const re=1e3;function oe(e,t,n,r){let o=0,i=e.length;for(;;){if(o==i){let r=0,i=0;o&&({toA:r,toB:i}=e[o-1]);let s=t-(n?r:i);return[r+s,i+s]}let s=o+i>>1,l=e[s],[a,c]=n?[l.fromA,l.toA]:[l.fromB,l.toB];if(a>t)i=s;else{if(!(c<=t))return r?[l.fromA,l.fromB]:[l.toA,l.toB];o=s+1}}}function ie(e,t,n,r){let o=[];return t.iterChangedRanges((i,s,l,a)=>{let c=0,f=n?t.length:r,h=0,d=n?r:t.length;i>re&&([c,h]=oe(e,i-re,n,!0)),s<t.length-re&&([f,d]=oe(e,s+re,n,!1));let u,m=a-l-(s-i),[g,p]=n?[m,0]:[0,m];o.length&&(u=o[o.length-1]).toA>=c?o[o.length-1]={fromA:u.fromA,fromB:u.fromB,toA:f,toB:d,diffA:u.diffA+g,diffB:u.diffB+p}:o.push({fromA:c,toA:f,fromB:h,toB:d,diffA:g,diffB:p})}),o}function se(e,t,n,r,o){if(!e.length)return t;let i=[];for(let s=0,l=0,a=0,c=0;;s++){let f=s==e.length?null:e[s],h=f?f.fromA+l:n.length,d=f?f.fromB+a:r.length;for(;c<t.length;){let e=t[c];if(e.toA+l>h||e.toB+a>d)break;i.push(e.offset(l,a)),c++}if(!f)break;let u=f.toA+l+f.diffA,m=f.toB+a+f.diffB,g=W(n.sliceString(h,u),r.sliceString(d,m),o);for(let e of ne(g,n,r,h,d,I()))i.push(e);for(l+=f.diffA,a+=f.diffB;c<t.length;){let e=t[c];if(e.fromA+l>u&&e.fromB+a>m)break;c++}}return i}const le={scanLimit:500},ae=r.ViewPlugin.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=pe(e))}update(e){var t,n;(e.docChanged||e.viewportChanged||(t=e.startState,n=e.state,t.field(Z,!1)!=n.field(Z,!1))||function(e,t){return e.facet(q)!=t.facet(q)}(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=pe(e.view))}},{decorations:e=>e.deco}),ce=o.Prec.low((0,r.gutter)({class:"cm-changeGutter",markers:e=>{var t;return(null===(t=e.plugin(ae))||void 0===t?void 0:t.gutter)||o.RangeSet.empty}})),fe=r.Decoration.line({class:"cm-changedLine"}),he=r.Decoration.mark({class:"cm-changedText"}),de=r.Decoration.mark({tagName:"ins",class:"cm-insertedLine"}),ue=r.Decoration.mark({tagName:"del",class:"cm-deletedLine"}),me=new class extends r.GutterMarker{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function ge(e,t,n,r,o,i){let s=n?e.fromA:e.fromB,l=n?e.toA:e.toB,a=0;if(s!=l){o.add(s,s,fe),o.add(s,l,n?ue:de),i&&i.add(s,s,me);for(let c=t.iterRange(s,l-1),f=s;!c.next().done;){if(c.lineBreak){f++,o.add(f,f,fe),i&&i.add(f,f,me);continue}let t=f+c.value.length;if(r)for(;a<e.changes.length;){let r=e.changes[a],i=s+(n?r.fromA:r.fromB),l=s+(n?r.toA:r.toB),c=Math.max(f,i),h=Math.min(t,l);if(c<h&&o.add(c,h,he),!(l<t))break;a++}f=t}}}function pe(e){let t=e.state.field(Z),{side:n,highlightChanges:r,markGutter:i,overrideChunk:s}=e.state.facet(q),l="a"==n,a=new o.RangeSetBuilder,c=i?new o.RangeSetBuilder:null,{from:f,to:h}=e.viewport;for(let n of t){if((l?n.fromA:n.fromB)>=h)break;(l?n.toA:n.toB)>f&&(s&&s(e.state,n,a,c)||ge(n,e.state.doc,l,r,a,c))}return{deco:a.finish(),gutter:c&&c.finish()}}class Ae extends r.WidgetType{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const ve=o.StateEffect.define({map:(e,t)=>e.map(t)}),Be=o.StateField.define({create:()=>r.Decoration.none,update:(e,t)=>{for(let e of t.effects)if(e.is(ve))return e.value;return e.map(t.changes)},provide:e=>r.EditorView.decorations.from(e)}),be=.01;function Ce(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}const we=o.StateEffect.define({map:(e,t)=>t.mapPos(e)});class ke extends r.WidgetType{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement("div");return t.className="cm-collapsedLines",t.textContent=e.state.phrase("$ unchanged lines",this.lines),t.addEventListener("click",t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:we.of(n)});let{side:r,sibling:o}=e.state.facet(q);o&&o().dispatch({effects:we.of(xe(n,e.state.field(Z),"a"==r))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function xe(e,t,n){let r=0,o=0;for(let i=0;;i++){let s=i<t.length?t[i]:null;if(!s||(n?s.fromA:s.fromB)>=e)return o+(e-r);[r,o]=n?[s.toA,s.toB]:[s.toB,s.toA]}}const Se=o.StateField.define({create:e=>r.Decoration.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(we)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>r.EditorView.decorations.from(e)});function Me({margin:e=3,minSize:t=4}){return Se.init(n=>function(e,t,n){let i=new o.RangeSetBuilder,s="a"==e.facet(q).side,l=e.field(Z),a=1;for(let o=0;;o++){let c=o<l.length?l[o]:null,f=o?a+t:1,h=c?e.doc.lineAt(s?c.fromA:c.fromB).number-1-t:e.doc.lines,d=h-f+1;if(d>=n&&i.add(e.doc.line(f).from,e.doc.line(h).to,r.Decoration.replace({widget:new ke(d),block:!0})),!c)break;a=e.doc.lineAt(Math.min(e.doc.length,s?c.toA:c.toB)).number}return i.finish()}(n,e,t))}const De=r.EditorView.styleModule.of(new a({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),Ee=r.EditorView.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),ye=new o.Compartment,Te=new o.Compartment;class Oe{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||le;let t=[o.Prec.low(ae),Ee,De,Be,r.EditorView.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(ve)))&&this.measure()})],n=[q.of({side:"a",sibling:()=>this.b,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&n.push(ce);let i=o.EditorState.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],r.EditorView.editorAttributes.of({class:"cm-merge-a"}),Te.of(n),t]}),s=[q.of({side:"b",sibling:()=>this.a,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&s.push(ce);let l=o.EditorState.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],r.EditorView.editorAttributes.of({class:"cm-merge-b"}),Te.of(s),t]});this.chunks=X.build(i.doc,l.doc,this.diffConf);let a=[Z.init(()=>this.chunks),ye.of(e.collapseUnchanged?Me(e.collapseUnchanged):[])];i=i.update({effects:o.StateEffect.appendConfig.of(a)}).state,l=l.update({effects:o.StateEffect.appendConfig.of(a)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let c=e.orientation||"a-b",f=document.createElement("div");f.className="cm-mergeViewEditor";let h=document.createElement("div");h.className="cm-mergeViewEditor",this.editorDOM.appendChild("a-b"==c?f:h),this.editorDOM.appendChild("a-b"==c?h:f),this.a=new r.EditorView({state:i,parent:f,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new r.EditorView({state:l,parent:h,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,"b-to-a"==e.revertControls,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),o.ChangeSet.empty(e[0].startState.doc.length));this.chunks=t==this.a?X.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):X.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:z.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:z.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let t="b-a"!=e.orientation;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;"revertControls"in e&&(t=!!e.revertControls,n="b-to-a"==e.revertControls),"renderRevertControl"in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t="highlightChanges"in e,n="gutter"in e,r="collapseUnchanged"in e;if(t||n||r){let o=[],i=[];if(t||n){let r=this.a.state.facet(q),s=n?!1!==e.gutter:r.markGutter,l=t?!1!==e.highlightChanges:r.highlightChanges;o.push(Te.reconfigure([q.of({side:"a",sibling:()=>this.b,highlightChanges:l,markGutter:s}),s?ce:[]])),i.push(Te.reconfigure([q.of({side:"b",sibling:()=>this.a,highlightChanges:l,markGutter:s}),s?ce:[]]))}if(r){let t=ye.reconfigure(e.collapseUnchanged?Me(e.collapseUnchanged):[]);o.push(t),i.push(t)}this.a.dispatch({effects:o}),this.b.dispatch({effects:i})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",e=>this.revertClicked(e)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){!function(e,t,n){let i=new o.RangeSetBuilder,s=new o.RangeSetBuilder,l=e.state.field(Be).iter(),a=t.state.field(Be).iter(),c=0,f=0,h=0,d=0,u=e.viewport,m=t.viewport;for(let o=0;;o++){let g=o<n.length?n[o]:null,p=g?g.fromA:e.state.doc.length,A=g?g.fromB:t.state.doc.length;if(c<p){let n=e.lineBlockAt(c).top+h-(t.lineBlockAt(f).top+d);n<-.01?(h-=n,i.add(c,c,r.Decoration.widget({widget:new Ae(-n),block:!0,side:-1}))):n>be&&(d+=n,s.add(f,f,r.Decoration.widget({widget:new Ae(n),block:!0,side:-1})))}if(p>c+1e3&&c<u.from&&p>u.from&&f<m.from&&A>m.from){let e=Math.min(u.from-c,m.from-f);c+=e,f+=e,o--}else{if(!g)break;c=g.toA,f=g.toB}for(;l.value&&l.from<c;)h-=l.value.spec.widget.height,l.next();for(;a.value&&a.from<f;)d-=a.value.spec.widget.height,a.next()}for(;l.value;)h-=l.value.spec.widget.height,l.next();for(;a.value;)d-=a.value.spec.widget.height,a.next();let g=e.contentHeight+h-(t.contentHeight+d);g<be?i.add(e.state.doc.length,e.state.doc.length,r.Decoration.widget({widget:new Ae(-g),block:!0,side:1})):g>be&&s.add(t.state.doc.length,t.state.doc.length,r.Decoration.widget({widget:new Ae(g),block:!0,side:1}));let p=i.finish(),A=s.finish();Ce(p,e.state.field(Be))||e.dispatch({effects:ve.of(p)}),Ce(A,t.state.field(Be))||t.dispatch({effects:ve.of(A)})}(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let o=0;o<this.chunks.length;o++){let i=this.chunks[o];if(i.fromA>n.to||i.fromB>r.to)break;if(i.fromA<n.from||i.fromB<r.from)continue;let s=this.a.lineBlockAt(i.fromA).top+"px";for(;t&&+t.dataset.chunk<o;)t=Le(t);t&&t.dataset.chunk==String(o)?(t.style.top!=s&&(t.style.top=s),t=t.nextSibling):e.insertBefore(this.renderRevertButton(s,o),t)}for(;t;)t=Le(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement("button");let e=this.a.state.phrase("Revert this chunk");n.setAttribute("aria-label",e),n.setAttribute("title",e),n.textContent=this.revertToLeft?"⇜":"⇝"}return n.style.top=e,n.setAttribute("data-chunk",String(t)),n}revertClicked(e){let t,n=e.target;for(;n&&n.parentNode!=this.revertDOM;)n=n.parentNode;if(n&&(t=this.chunks[n.dataset.chunk])){let[n,r,o,i,s,l]=this.revertToA?[this.b,this.a,t.fromB,t.toB,t.fromA,t.toA]:[this.a,this.b,t.fromA,t.toA,t.fromB,t.toB],a=n.state.sliceDoc(o,Math.max(o,i-1));o!=i&&l<=r.state.doc.length&&(a+=n.state.lineBreak),r.dispatch({changes:{from:s,to:Math.min(r.state.doc.length,l),insert:a},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function Le(e){let t=e.nextSibling;return e.remove(),t}const Re=new class extends r.GutterMarker{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Ve=o.Prec.low((0,r.gutter)({class:"cm-changeGutter",markers:e=>{var t;return(null===(t=e.plugin(ae))||void 0===t?void 0:t.gutter)||o.RangeSet.empty},widgetMarker:(e,t)=>t instanceof qe?Re:null}));function Ne(e){var t;let n="string"==typeof e.original?o.Text.of(e.original.split(/\r?\n/)):e.original,i=e.diffConfig||le;const s=(e.invertedEffects||h.g_).of(e=>{let t=[];for(let n of e.effects)if(n.is(Fe))t.push(Ge.of({doc:n.value.originalDoc,changes:n.value.changes.invert(e.startState.field(Ue))}));else if(n.is(Ge)){const r=e.startState.field(Ue);t.push(Ge.of({doc:r,changes:n.value.changes.invert(r)}))}else n.is(je)&&t.push(je.of({chunkFromA:n.value.chunkFromA,chunkToA:n.value.chunkToA,chunkFromB:n.value.chunkFromB,chunkToB:n.value.chunkToB,originalContent:n.value.currentContent,currentContent:n.value.originalContent,changes:n.value.changes.invert(e.startState.doc)}));return t});return[o.Prec.low(ae),Qe,Ee,s,r.EditorView.editorAttributes.of({class:"cm-merge-b"}),Y.of((e,t)=>{let n=t.effects.find(e=>e.is(Ge)),r=t.effects.find(e=>e.is(Fe)),o=t.effects.find(e=>e.is(je)),s=t.effects.find(e=>e.is(Pe));return n&&(e=X.updateA(e,n.value.doc,t.startState.doc,n.value.changes,i)),r&&(e=X.updateA(e,r.value.changes.apply(t.startState.field(Ue)),t.startState.doc,r.value.changes,i)),s&&(e=X.build(t.state.field(Ue),t.newDoc,i)),(o||e.length&&t.docChanged)&&(e=X.updateB(e,t.state.field(Ue),t.newDoc,t.changes,i)),e}),q.of({highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter,syntaxHighlightDeletions:!1!==e.syntaxHighlightDeletions,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:null===(t=e.mergeControls)||void 0===t||t,overrideChunk:e.allowInlineDiffs?ot:void 0,side:"b"}),Ue.init(()=>n),!1!==e.gutter?Ve:[],e.collapseUnchanged?Me(e.collapseUnchanged):[],Z.init(e=>X.build(n,e.doc,i))]}const Ge=o.StateEffect.define(),Fe=o.StateEffect.define({map:(e,t)=>{let n=t.mapPos(e.chunkFromB),r=t.mapPos(e.chunkToB);return n<r?Object.assign(Object.assign({},e),{chunkFromB:n,chunkToB:r}):void 0}}),je=o.StateEffect.define({map:(e,t)=>{let n=t.mapPos(e.chunkFromB),r=t.mapPos(e.chunkToB);return n<r?Object.assign(Object.assign({},e),{chunkFromB:n,chunkToB:r}):void 0}}),Pe=o.StateEffect.define();function _e(e,t){return Ge.of({doc:t.apply(Ie(e)),changes:t})}function He(e,t,n={}){const{replaceAll:r=!0,insertAt:o}=n;let i;if(r)i={from:0,to:e.state.doc.length,insert:t};else if(void 0!==o)i={from:o,to:o,insert:t};else{const n=e.state.selection.main.head;i={from:n,to:n,insert:t}}e.dispatch({changes:i,effects:Pe.of({generatedCode:t,replaceAll:r,insertAt:o}),userEvent:"generate.code"})}const Ue=o.StateField.define({create:()=>o.Text.empty,update(e,t){for(let n of t.effects)n.is(Ge)?e=n.value.doc:n.is(Fe)?e=n.value.changes.apply(e):n.is(je);return e}});function Ie(e){return e.field(Ue)}const We=new WeakMap;class qe extends r.WidgetType{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function ze(e,t,n){let o=We.get(t.changes);if(o)return o;let i=r.Decoration.widget({block:!0,side:-1,widget:new qe(r=>{let{highlightChanges:o,syntaxHighlightDeletions:i,syntaxHighlightDeletionsMaxLength:s,mergeControls:l}=e.facet(q),a=document.createElement("div");if(a.className="cm-deletedChunk",l){let t=a.appendChild(document.createElement("div"));t.className="cm-chunkButtons";let n=e=>{e.preventDefault(),Ye(r,r.posAtDOM(a))},o=e=>{e.preventDefault(),Ze(r,r.posAtDOM(a))};if("function"==typeof l)t.appendChild(l("accept",n)),t.appendChild(l("reject",o));else{let r=t.appendChild(document.createElement("button"));r.name="accept",r.textContent=e.phrase("Accept"),r.onmousedown=n;let i=t.appendChild(document.createElement("button"));i.name="reject",i.textContent=e.phrase("Reject"),i.onmousedown=o}}if(n||t.fromA>=t.toA)return a;let c=r.state.field(Ue).sliceString(t.fromA,t.endA),f=i&&e.facet(d.language),h=A(),m=t.changes,g=0,p=!1;function A(){let e=a.appendChild(document.createElement("div"));return e.className="cm-deletedLine",e.appendChild(document.createElement("del"))}function v(e,t,n){for(let r=e;r<t;){if("\n"==c.charAt(r)){h.firstChild||h.appendChild(document.createElement("br")),h=A(),r++;continue}let e=t,i=n+(p?" cm-deletedText":""),s=!1,l=c.indexOf("\n",r);if(l>-1&&l<t&&(e=l),o&&g<m.length){let t=Math.max(0,p?m[g].toA:m[g].fromA);t<=e&&(e=t,p&&g++,s=!0)}if(e>r){let t=document.createTextNode(c.slice(r,e));if(i){let e=h.appendChild(document.createElement("span"));e.className=i,e.appendChild(t)}else h.appendChild(t);r=e}s&&(p=!p)}}if(f&&t.toA-t.fromA<=s){let t=f.parser.parse(c),n=0;(0,u.highlightTree)(t,{style:t=>(0,d.highlightingFor)(e,t)},(e,t,r)=>{e>n&&v(n,e,""),v(e,t,r),n=t}),v(n,c.length,"")}else v(0,c.length,"");return h.firstChild||h.appendChild(document.createElement("br")),a})});return We.set(t.changes,i),i}function Ye(e,t){let{state:n}=e,r=null!=t?t:n.selection.main.head,i=e.state.field(Z).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let s=e.state.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),l=e.state.field(Ue);i.fromB!=i.toB&&i.toA<=l.length&&(s+=e.state.lineBreak);let a=o.ChangeSet.of({from:i.fromA,to:Math.min(l.length,i.toA),insert:s},l.length);return e.dispatch({effects:Fe.of({chunkFromA:i.fromA,chunkToA:i.toA,chunkFromB:i.fromB,chunkToB:i.toB,originalDoc:l,currentContent:s,changes:a}),userEvent:"accept"}),!0}function Ze(e,t){let{state:n}=e,r=null!=t?t:n.selection.main.head,i=n.field(Z).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let s=n.field(Ue).sliceString(i.fromA,Math.max(i.fromA,i.toA-1));i.fromA!=i.toA&&i.toB<=n.doc.length&&(s+=n.lineBreak);let l=n.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),a=o.ChangeSet.of({from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:s},n.doc.length);return e.dispatch({changes:{from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:s},effects:je.of({chunkFromA:i.fromA,chunkToA:i.toA,chunkFromB:i.fromB,chunkToB:i.toB,originalContent:s,currentContent:l,changes:a}),userEvent:"revert"}),!0}function $e(e){const t=e.state,n=t.field(Ue),r=t.doc.toString(),i=o.ChangeSet.of({from:0,to:n.length,insert:r},n.length);return e.dispatch({effects:Ge.of({doc:i.apply(n),changes:i}),userEvent:"accept.all"}),!0}function Je(e){const t=e.state,n=t.field(Ue).toString();return e.dispatch({changes:{from:0,to:t.doc.length,insert:n},userEvent:"revert.all"}),!0}function Ke(e){let t=new o.RangeSetBuilder;for(let n of e.field(Z)){let r=e.facet(q).overrideChunk&&et(e,n);t.add(n.fromB,n.fromB,ze(e,n,!!r))}return t.finish()}const Qe=o.StateField.define({create:e=>Ke(e),update:(e,t)=>t.state.field(Z,!1)!=t.startState.field(Z,!1)?Ke(t.state):e,provide:e=>r.EditorView.decorations.from(e)}),Xe=new WeakMap;function et(e,t){let n=Xe.get(t);if(void 0!==n)return n;n=null;let o=e.field(Ue),i=e.doc,s=o.lineAt(t.endA).number-o.lineAt(t.fromA).number+1;e:if(s==i.lineAt(t.endB).number-i.lineAt(t.fromB).number+1&&s<10){let e=[],i=0,l=t.fromA,a=t.fromB;for(let n of t.changes){if(n.fromA<n.toA){i+=n.toA-n.fromA;let t=o.sliceString(l+n.fromA,l+n.toA);if(/\n/.test(t))break e;e.push(r.Decoration.widget({widget:new tt(t),side:-1}).range(a+n.fromB))}n.fromB<n.toB&&e.push(he.range(a+n.fromB,a+n.toB))}i<t.endA-t.fromA-2*s&&(n=e)}return Xe.set(t,n),n}class tt extends r.WidgetType{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let t=document.createElement("del");return t.className="cm-deletedText",t.textContent=this.text,t}}const nt=new class extends r.GutterMarker{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},rt=r.Decoration.line({class:"cm-inlineChangedLine"});function ot(e,t,n,r){let o=et(e,t),i=0;if(!o)return!1;for(let s=e.doc.lineAt(t.fromB);;){for(r&&r.add(s.from,s.from,nt),n.add(s.from,s.from,rt);i<o.length&&o[i].to<=s.to;){let e=o[i++];n.add(e.from,e.to,e.value)}if(s.to>=t.endB)break;s=e.doc.lineAt(s.to+1)}return!0}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunksignalpilot_ai_internal=self.webpackChunksignalpilot_ai_internal||[]).push([[713],{85713:(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}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunksignalpilot_ai_internal=self.webpackChunksignalpilot_ai_internal||[]).push([[741],{69741:(e,t,o)=>{o.r(t),o.d(t,{driver:()=>M});let n,i={};function r(e={}){i={animate:!0,allowClose:!0,overlayClickBehavior:"close",overlayOpacity:.7,smoothScroll:!1,disableActiveInteraction:!1,showProgress:!1,stagePadding:10,stageRadius:5,popoverOffset:10,showButtons:["next","previous","close"],disableButtons:[],overlayColor:"#000",...e}}function s(e){return e?i[e]:i}function l(){return n}let d={};function a(e,t){d[e]=t}function p(e){var t;null==(t=d[e])||t.call(d)}function c(e,t,o,n){return(e/=n/2)<1?o/2*e*e+t:-o/2*(--e*(e-2)-1)+t}function v(e){const t='a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])';return e.flatMap(e=>{const o=e.matches(t),n=Array.from(e.querySelectorAll(t));return[...o?[e]:[],...n]}).filter(e=>"none"!==getComputedStyle(e).pointerEvents&&function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}(e))}function u(e){if(!e||function(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}(e))return;const t=s("smoothScroll"),o=e.offsetHeight>window.innerHeight;e.scrollIntoView({behavior:!t||h(e)?"auto":"smooth",inline:"center",block:o?"start":"center"})}function h(e){if(!e||!e.parentElement)return;const t=e.parentElement;return t.scrollHeight>t.clientHeight}let m={};function w(e,t){m[e]=t}function g(e){return e?m[e]:m}function f(){m={}}function y(e){if(!e)return;const t=e.getBoundingClientRect(),o={x:t.x,y:t.y,width:t.width,height:t.height};w("__activeStagePosition",o),b(o)}function b(e){const t=g("__overlaySvg");if(!t)return void function(e){const t=function(e){const t=window.innerWidth,o=window.innerHeight,n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("driver-overlay","driver-overlay-animated"),n.setAttribute("viewBox",`0 0 ${t} ${o}`),n.setAttribute("xmlSpace","preserve"),n.setAttribute("xmlnsXlink","http://www.w3.org/1999/xlink"),n.setAttribute("version","1.1"),n.setAttribute("preserveAspectRatio","xMinYMin slice"),n.style.fillRule="evenodd",n.style.clipRule="evenodd",n.style.strokeLinejoin="round",n.style.strokeMiterlimit="2",n.style.zIndex="10000",n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%";const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",x(e)),i.style.fill=s("overlayColor")||"rgb(0,0,0)",i.style.opacity=`${s("overlayOpacity")}`,i.style.pointerEvents="auto",i.style.cursor="auto",n.appendChild(i),n}(e);document.body.appendChild(t),$(t,e=>{"path"===e.target.tagName&&p("overlayClick")}),w("__overlaySvg",t)}(e);const o=t.firstElementChild;if("path"!==(null==o?void 0:o.tagName))throw new Error("no path element found in stage svg");o.setAttribute("d",x(e))}function x(e){const t=window.innerWidth,o=window.innerHeight,n=s("stagePadding")||0,i=s("stageRadius")||0,r=e.width+2*n,l=e.height+2*n,d=Math.min(i,r/2,l/2),a=Math.floor(Math.max(d,0)),p=r-2*a,c=l-2*a;return`M${t},0L0,0L0,${o}L${t},${o}L${t},0Z\n M${e.x-n+a},${e.y-n} h${p} a${a},${a} 0 0 1 ${a},${a} v${c} a${a},${a} 0 0 1 -${a},${a} h-${p} a${a},${a} 0 0 1 -${a},-${a} v-${c} a${a},${a} 0 0 1 ${a},-${a} z`}function C(e){const{element:t}=e;let o="function"==typeof t?t():"string"==typeof t?document.querySelector(t):t;o||(o=function(){const e=document.getElementById("driver-dummy-element");if(e)return e;let t=document.createElement("div");return t.id="driver-dummy-element",t.style.width="0",t.style.height="0",t.style.pointerEvents="none",t.style.opacity="0",t.style.position="fixed",t.style.top="50%",t.style.left="50%",document.body.appendChild(t),t}()),function(e,t){var o;const n=Date.now(),i=g("__activeStep"),r=g("__activeElement")||e,d=!r||r===e,a="driver-dummy-element"===e.id,p="driver-dummy-element"===r.id,v=s("animate"),h=t.onHighlightStarted||s("onHighlightStarted"),m=(null==t?void 0:t.onHighlighted)||s("onHighlighted"),f=(null==i?void 0:i.onDeselected)||s("onDeselected"),x=s(),C=g();!d&&f&&f(p?void 0:r,i,{config:x,state:C,driver:l()}),h&&h(a?void 0:e,t,{config:x,state:C,driver:l()});const _=!d&&v;let k=!1;(function(){const e=g("popover");e&&(e.wrapper.style.display="none")})(),w("previousStep",i),w("previousElement",r),w("activeStep",t),w("activeElement",e);const E=()=>{if(g("__transitionCallback")!==E)return;const o=Date.now()-n,d=400-o<=200;t.popover&&d&&!k&&_&&(B(e,t),k=!0),s("animate")&&o<400?function(e,t,o,n){let i=g("__activeStagePosition");const r=i||o.getBoundingClientRect(),s=n.getBoundingClientRect();i={x:c(e,r.x,s.x-r.x,t),y:c(e,r.y,s.y-r.y,t),width:c(e,r.width,s.width-r.width,t),height:c(e,r.height,s.height-r.height,t)},b(i),w("__activeStagePosition",i)}(o,400,r,e):(y(e),m&&m(a?void 0:e,t,{config:s(),state:g(),driver:l()}),w("__transitionCallback",void 0),w("__previousStep",i),w("__previousElement",r),w("__activeStep",t),w("__activeElement",e)),window.requestAnimationFrame(E)};w("__transitionCallback",E),window.requestAnimationFrame(E),u(e),!_&&t.popover&&B(e,t),r.classList.remove("driver-active-element","driver-no-interaction"),r.removeAttribute("aria-haspopup"),r.removeAttribute("aria-expanded"),r.removeAttribute("aria-controls"),(null!=(o=t.disableActiveInteraction)?o:s("disableActiveInteraction"))&&e.classList.add("driver-no-interaction"),e.classList.add("driver-active-element"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","true"),e.setAttribute("aria-controls","driver-popover-content")}(o,e)}function _(){const e=g("__activeElement"),t=g("__activeStep");e&&(y(e),function(){const e=g("__activeStagePosition"),t=g("__overlaySvg");if(!e)return;if(!t)return void console.warn("No stage svg found.");const o=window.innerWidth,n=window.innerHeight;t.setAttribute("viewBox",`0 0 ${o} ${n}`)}(),S(e,t))}function k(){const e=g("__resizeTimeout");e&&window.cancelAnimationFrame(e),w("__resizeTimeout",window.requestAnimationFrame(_))}function E(e){var t;if(!g("isInitialized")||"Tab"!==e.key&&9!==e.keyCode)return;const o=g("__activeElement"),n=null==(t=g("popover"))?void 0:t.wrapper,i=v([...n?[n]:[],...o?[o]:[]]),r=i[0],s=i[i.length-1];if(e.preventDefault(),e.shiftKey){const e=i[i.indexOf(document.activeElement)-1]||s;null==e||e.focus()}else{const e=i[i.indexOf(document.activeElement)+1]||r;null==e||e.focus()}}function L(e){var t;(null==(t=s("allowKeyboardControl"))||t)&&("Escape"===e.key?p("escapePress"):"ArrowRight"===e.key?p("arrowRightPress"):"ArrowLeft"===e.key&&p("arrowLeftPress"))}function $(e,t,o){const n=(t,n)=>{const i=t.target;e.contains(i)&&((!o||o(i))&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),null==n||n(t))};document.addEventListener("pointerdown",n,!0),document.addEventListener("mousedown",n,!0),document.addEventListener("pointerup",n,!0),document.addEventListener("mouseup",n,!0),document.addEventListener("click",e=>{n(e,t)},!0)}function B(e,t){var o,n;let i=g("popover");i&&document.body.removeChild(i.wrapper),i=function(){const e=document.createElement("div");e.classList.add("driver-popover");const t=document.createElement("div");t.classList.add("driver-popover-arrow");const o=document.createElement("header");o.id="driver-popover-title",o.classList.add("driver-popover-title"),o.style.display="none",o.innerText="Popover Title";const n=document.createElement("div");n.id="driver-popover-description",n.classList.add("driver-popover-description"),n.style.display="none",n.innerText="Popover description is here";const i=document.createElement("button");i.type="button",i.classList.add("driver-popover-close-btn"),i.setAttribute("aria-label","Close"),i.innerHTML="&times;";const r=document.createElement("footer");r.classList.add("driver-popover-footer");const s=document.createElement("span");s.classList.add("driver-popover-progress-text"),s.innerText="";const l=document.createElement("span");l.classList.add("driver-popover-navigation-btns");const d=document.createElement("button");d.type="button",d.classList.add("driver-popover-prev-btn"),d.innerHTML="&larr; Previous";const a=document.createElement("button");return a.type="button",a.classList.add("driver-popover-next-btn"),a.innerHTML="Next &rarr;",l.appendChild(d),l.appendChild(a),r.appendChild(s),r.appendChild(l),e.appendChild(i),e.appendChild(t),e.appendChild(o),e.appendChild(n),e.appendChild(r),{wrapper:e,arrow:t,title:o,description:n,footer:r,previousButton:d,nextButton:a,closeButton:i,footerButtons:l,progress:s}}(),document.body.appendChild(i.wrapper);const{title:r,description:d,showButtons:a,disableButtons:c,showProgress:h,nextBtnText:m=s("nextBtnText")||"Next &rarr;",prevBtnText:f=s("prevBtnText")||"&larr; Previous",progressText:y=s("progressText")||"{current} of {total}"}=t.popover||{};i.nextButton.innerHTML=m,i.previousButton.innerHTML=f,i.progress.innerHTML=y,r?(i.title.innerHTML=r,i.title.style.display="block"):i.title.style.display="none",d?(i.description.innerHTML=d,i.description.style.display="block"):i.description.style.display="none";const b=a||s("showButtons"),x=h||s("showProgress")||!1,C=(null==b?void 0:b.includes("next"))||(null==b?void 0:b.includes("previous"))||x;i.closeButton.style.display=b.includes("close")?"block":"none",C?(i.footer.style.display="flex",i.progress.style.display=x?"block":"none",i.nextButton.style.display=b.includes("next")?"block":"none",i.previousButton.style.display=b.includes("previous")?"block":"none"):i.footer.style.display="none";const _=c||s("disableButtons")||[];null!=_&&_.includes("next")&&(i.nextButton.disabled=!0,i.nextButton.classList.add("driver-popover-btn-disabled")),null!=_&&_.includes("previous")&&(i.previousButton.disabled=!0,i.previousButton.classList.add("driver-popover-btn-disabled")),null!=_&&_.includes("close")&&(i.closeButton.disabled=!0,i.closeButton.classList.add("driver-popover-btn-disabled"));const k=i.wrapper;k.style.display="block",k.style.left="",k.style.top="",k.style.bottom="",k.style.right="",k.id="driver-popover-content",k.setAttribute("role","dialog"),k.setAttribute("aria-labelledby","driver-popover-title"),k.setAttribute("aria-describedby","driver-popover-description"),i.arrow.className="driver-popover-arrow";const E=(null==(o=t.popover)?void 0:o.popoverClass)||s("popoverClass")||"";k.className=`driver-popover ${E}`.trim(),$(i.wrapper,o=>{var n,i,r;const d=o.target,a=(null==(n=t.popover)?void 0:n.onNextClick)||s("onNextClick"),c=(null==(i=t.popover)?void 0:i.onPrevClick)||s("onPrevClick"),v=(null==(r=t.popover)?void 0:r.onCloseClick)||s("onCloseClick");return d.closest(".driver-popover-next-btn")?a?a(e,t,{config:s(),state:g(),driver:l()}):p("nextClick"):d.closest(".driver-popover-prev-btn")?c?c(e,t,{config:s(),state:g(),driver:l()}):p("prevClick"):d.closest(".driver-popover-close-btn")?v?v(e,t,{config:s(),state:g(),driver:l()}):p("closeClick"):void 0},e=>!(null!=i&&i.description.contains(e))&&!(null!=i&&i.title.contains(e))&&"string"==typeof e.className&&e.className.includes("driver-popover")),w("popover",i);const L=(null==(n=t.popover)?void 0:n.onPopoverRender)||s("onPopoverRender");L&&L(i,{config:s(),state:g(),driver:l()}),S(e,t),u(k);const B=v([k,...e.classList.contains("driver-dummy-element")?[]:[e]]);B.length>0&&B[0].focus()}function P(){const e=g("popover");if(null==e||!e.wrapper)return;const t=e.wrapper.getBoundingClientRect(),o=s("stagePadding")||0,n=s("popoverOffset")||0;return{width:t.width+o+n,height:t.height+o+n,realWidth:t.width,realHeight:t.height}}function A(e,t){const{elementDimensions:o,popoverDimensions:n,popoverPadding:i,popoverArrowDimensions:r}=t;return"start"===e?Math.max(Math.min(o.top-i,window.innerHeight-n.realHeight-r.width),r.width):"end"===e?Math.max(Math.min(o.top-(null==n?void 0:n.realHeight)+o.height+i,window.innerHeight-(null==n?void 0:n.realHeight)-r.width),r.width):"center"===e?Math.max(Math.min(o.top+o.height/2-(null==n?void 0:n.realHeight)/2,window.innerHeight-(null==n?void 0:n.realHeight)-r.width),r.width):0}function H(e,t){const{elementDimensions:o,popoverDimensions:n,popoverPadding:i,popoverArrowDimensions:r}=t;return"start"===e?Math.max(Math.min(o.left-i,window.innerWidth-n.realWidth-r.width),r.width):"end"===e?Math.max(Math.min(o.left-(null==n?void 0:n.realWidth)+o.width+i,window.innerWidth-(null==n?void 0:n.realWidth)-r.width),r.width):"center"===e?Math.max(Math.min(o.left+o.width/2-(null==n?void 0:n.realWidth)/2,window.innerWidth-(null==n?void 0:n.realWidth)-r.width),r.width):0}function S(e,t){const o=g("popover");if(!o)return;const{align:n="start",side:i="left"}=(null==t?void 0:t.popover)||{},r=n,l="driver-dummy-element"===e.id?"over":i,d=s("stagePadding")||0,a=P(),p=o.arrow.getBoundingClientRect(),c=e.getBoundingClientRect(),v=c.top-a.height;let u=v>=0;const h=window.innerHeight-(c.bottom+a.height);let m=h>=0;const w=c.left-a.width;let f=w>=0;const y=window.innerWidth-(c.right+a.width);let b=y>=0;const x=!(u||m||f||b);let C=l;if("top"===l&&u?b=f=m=!1:"bottom"===l&&m?b=f=u=!1:"left"===l&&f?b=u=m=!1:"right"===l&&b&&(f=u=m=!1),"over"===l){const e=window.innerWidth/2-a.realWidth/2,t=window.innerHeight/2-a.realHeight/2;o.wrapper.style.left=`${e}px`,o.wrapper.style.right="auto",o.wrapper.style.top=`${t}px`,o.wrapper.style.bottom="auto"}else if(x){const e=window.innerWidth/2-(null==a?void 0:a.realWidth)/2,t=10;o.wrapper.style.left=`${e}px`,o.wrapper.style.right="auto",o.wrapper.style.bottom=`${t}px`,o.wrapper.style.top="auto"}else if(f){const e=Math.min(w,window.innerWidth-(null==a?void 0:a.realWidth)-p.width),t=A(r,{elementDimensions:c,popoverDimensions:a,popoverPadding:d,popoverArrowDimensions:p});o.wrapper.style.left=`${e}px`,o.wrapper.style.top=`${t}px`,o.wrapper.style.bottom="auto",o.wrapper.style.right="auto",C="left"}else if(b){const e=Math.min(y,window.innerWidth-(null==a?void 0:a.realWidth)-p.width),t=A(r,{elementDimensions:c,popoverDimensions:a,popoverPadding:d,popoverArrowDimensions:p});o.wrapper.style.right=`${e}px`,o.wrapper.style.top=`${t}px`,o.wrapper.style.bottom="auto",o.wrapper.style.left="auto",C="right"}else if(u){const e=Math.min(v,window.innerHeight-a.realHeight-p.width);let t=H(r,{elementDimensions:c,popoverDimensions:a,popoverPadding:d,popoverArrowDimensions:p});o.wrapper.style.top=`${e}px`,o.wrapper.style.left=`${t}px`,o.wrapper.style.bottom="auto",o.wrapper.style.right="auto",C="top"}else if(m){const e=Math.min(h,window.innerHeight-(null==a?void 0:a.realHeight)-p.width);let t=H(r,{elementDimensions:c,popoverDimensions:a,popoverPadding:d,popoverArrowDimensions:p});o.wrapper.style.left=`${t}px`,o.wrapper.style.bottom=`${e}px`,o.wrapper.style.top="auto",o.wrapper.style.right="auto",C="bottom"}x?o.arrow.classList.add("driver-popover-arrow-none"):function(e,t,o){const n=g("popover");if(!n)return;const i=o.getBoundingClientRect(),r=P(),l=n.arrow,d=r.width,a=window.innerWidth,p=i.width,c=i.left,v=r.height,u=window.innerHeight,h=i.top,m=i.height;l.className="driver-popover-arrow";let w=t,f=e;if("top"===t?(c+p<=0?(w="right",f="end"):c+p-d<=0&&(w="top",f="start"),c>=a?(w="left",f="end"):c+d>=a&&(w="top",f="end")):"bottom"===t?(c+p<=0?(w="right",f="start"):c+p-d<=0&&(w="bottom",f="start"),c>=a?(w="left",f="start"):c+d>=a&&(w="bottom",f="end")):"left"===t?(h+m<=0?(w="bottom",f="end"):h+m-v<=0&&(w="left",f="start"),h>=u?(w="top",f="end"):h+v>=u&&(w="left",f="end")):"right"===t&&(h+m<=0?(w="bottom",f="start"):h+m-v<=0&&(w="right",f="start"),h>=u?(w="top",f="start"):h+v>=u&&(w="right",f="end")),w){l.classList.add(`driver-popover-arrow-side-${w}`),l.classList.add(`driver-popover-arrow-align-${f}`);const e=o.getBoundingClientRect(),i=l.getBoundingClientRect(),r=s("stagePadding")||0,d=e.left-r<window.innerWidth&&e.right+r>0&&e.top-r<window.innerHeight&&e.bottom+r>0;"bottom"===t&&d&&(i.x>e.x&&i.x+i.width<e.x+e.width?n.wrapper.style.transform="translateY(0)":(l.classList.remove(`driver-popover-arrow-align-${f}`),l.classList.add("driver-popover-arrow-none"),n.wrapper.style.transform=`translateY(-${r/2}px)`))}else l.classList.add("driver-popover-arrow-none")}(r,C,e)}function M(e={}){function t(){s("allowClose")&&m()}function o(){const e=s("overlayClickBehavior");s("allowClose")&&"close"===e?m():"nextStep"===e&&i()}function i(){const e=g("activeIndex"),t=s("steps")||[];if(void 0===e)return;const o=e+1;t[o]?h(o):m()}function p(){const e=g("activeIndex"),t=s("steps")||[];if(void 0===e)return;const o=e-1;t[o]?h(o):m()}function c(){var e;if(g("__transitionCallback"))return;const t=g("activeIndex"),o=g("__activeStep"),n=g("__activeElement");if(void 0===t||void 0===o||void 0===g("activeIndex"))return;const i=(null==(e=o.popover)?void 0:e.onPrevClick)||s("onPrevClick");if(i)return i(n,o,{config:s(),state:g(),driver:l()});p()}function v(){var e;if(g("__transitionCallback"))return;const t=g("activeIndex"),o=g("__activeStep"),n=g("__activeElement");if(void 0===t||void 0===o)return;const r=(null==(e=o.popover)?void 0:e.onNextClick)||s("onNextClick");if(r)return r(n,o,{config:s(),state:g(),driver:l()});i()}function u(){g("isInitialized")||(w("isInitialized",!0),document.body.classList.add("driver-active",s("animate")?"driver-fade":"driver-simple"),window.addEventListener("keyup",L,!1),window.addEventListener("keydown",E,!1),window.addEventListener("resize",k),window.addEventListener("scroll",k),a("overlayClick",o),a("escapePress",t),a("arrowLeftPress",c),a("arrowRightPress",v))}function h(e=0){var t,o,n,i,r,l,d,a;const p=s("steps");if(!p)return console.error("No steps to drive through"),void m();if(!p[e])return void m();w("__activeOnDestroyed",document.activeElement),w("activeIndex",e);const c=p[e],v=p[e+1],u=p[e-1],g=(null==(t=c.popover)?void 0:t.doneBtnText)||s("doneBtnText")||"Done",f=s("allowClose"),y=void 0!==(null==(o=c.popover)?void 0:o.showProgress)?null==(n=c.popover)?void 0:n.showProgress:s("showProgress"),b=((null==(i=c.popover)?void 0:i.progressText)||s("progressText")||"{{current}} of {{total}}").replace("{{current}}",`${e+1}`).replace("{{total}}",`${p.length}`),x=(null==(r=c.popover)?void 0:r.showButtons)||s("showButtons"),_=["next","previous",...f?["close"]:[]].filter(e=>!(null!=x&&x.length)||x.includes(e)),k=(null==(l=c.popover)?void 0:l.onNextClick)||s("onNextClick"),E=(null==(d=c.popover)?void 0:d.onPrevClick)||s("onPrevClick"),L=(null==(a=c.popover)?void 0:a.onCloseClick)||s("onCloseClick");C({...c,popover:{showButtons:_,nextBtnText:v?void 0:g,disableButtons:[...u?[]:["previous"]],showProgress:y,progressText:b,onNextClick:k||(()=>{v?h(e+1):m()}),onPrevClick:E||(()=>{h(e-1)}),onCloseClick:L||(()=>{m()}),...(null==c?void 0:c.popover)||{}}})}function m(e=!0){const t=g("__activeElement"),o=g("__activeStep"),n=g("__activeOnDestroyed"),i=s("onDestroyStarted");if(e&&i)return void i(t&&"driver-dummy-element"!==(null==t?void 0:t.id)?t:void 0,o,{config:s(),state:g(),driver:l()});const r=(null==o?void 0:o.onDeselected)||s("onDeselected"),a=s("onDestroyed");if(document.body.classList.remove("driver-active","driver-fade","driver-simple"),window.removeEventListener("keyup",L),window.removeEventListener("resize",k),window.removeEventListener("scroll",k),function(){var e;const t=g("popover");t&&(null==(e=t.wrapper.parentElement)||e.removeChild(t.wrapper))}(),function(){var e;null==(e=document.getElementById("driver-dummy-element"))||e.remove(),document.querySelectorAll(".driver-active-element").forEach(e=>{e.classList.remove("driver-active-element","driver-no-interaction"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls")})}(),function(){const e=g("__overlaySvg");e&&e.remove()}(),d={},f(),t&&o){const e="driver-dummy-element"===t.id;r&&r(e?void 0:t,o,{config:s(),state:g(),driver:l()}),a&&a(e?void 0:t,o,{config:s(),state:g(),driver:l()})}n&&n.focus()}r(e);const y={isActive:()=>g("isInitialized")||!1,refresh:k,drive:(e=0)=>{u(),h(e)},setConfig:r,setSteps:e=>{f(),r({...s(),steps:e})},getConfig:s,getState:g,getActiveIndex:()=>g("activeIndex"),isFirstStep:()=>0===g("activeIndex"),isLastStep:()=>{const e=s("steps")||[],t=g("activeIndex");return void 0!==t&&t===e.length-1},getActiveStep:()=>g("activeStep"),getActiveElement:()=>g("activeElement"),getPreviousElement:()=>g("previousElement"),getPreviousStep:()=>g("previousStep"),moveNext:i,movePrevious:p,moveTo:function(e){(s("steps")||[])[e]?h(e):m()},hasNextStep:()=>{const e=s("steps")||[],t=g("activeIndex");return void 0!==t&&!!e[t+1]},hasPreviousStep:()=>{const e=s("steps")||[],t=g("activeIndex");return void 0!==t&&!!e[t-1]},highlight:e=>{u(),C({...e,popover:e.popover?{showButtons:[],showProgress:!1,progressText:"",...e.popover}:void 0})},destroy:()=>{m(!1)}};return function(e){n=e}(y),y}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunksignalpilot_ai_internal=self.webpackChunksignalpilot_ai_internal||[]).push([[742],{32742:(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}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunksignalpilot_ai_internal=self.webpackChunksignalpilot_ai_internal||[]).push([[785],{45785:(e,t,i)=>{i.r(t),i.d(t,{EditorView:()=>o.EditorView,basicSetup:()=>Ht,minimalSetup:()=>Ut});var o=i(45024),n=i(60195),s=i(72084),r=i(44353);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 o in i)if(Object.prototype.hasOwnProperty.call(i,o)){var n=i[o];"string"==typeof n?e.setAttribute(o,n):null!=n&&(e[o]=n)}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,o=e.length,n,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,o),this.bufferStart=i,this.normalize=n?e=>n(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,n.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,n.fromCodePoint)(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=(0,n.codePointSize)(e);let o=this.normalize(t);if(o.length)for(let e=0,n=i;;e++){let s=o.charCodeAt(e),r=this.match(s,n,this.bufferPos+this.bufferStart);if(e==o.length-1){if(r)return this.value=r,this;break}n==i&&e<t.length&&t.charCodeAt(e)==s&&n++}}}match(e,t,i){let o=null;for(let t=0;t<this.matches.length;t+=2){let n=this.matches[t],s=!1;this.query.charCodeAt(n)==e&&(n==this.query.length-1?o={from:this.matches[t+1],to:i}:(this.matches[t]++,s=!0)),s||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?o={from:t,to:i}:this.matches.push(1,t)),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}"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,o=0,n=e.length){if(this.text=e,this.to=n,this.curLine="",this.done=!1,this.value=d,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new g(e,t,i,o,n);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 s=e.lineAt(o);this.curLineStart=s.from,this.matchPos=v(e,o),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,o=i+t[0].length;if(this.matchPos=v(this.text,o+(i==o?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<o||i>this.value.to)&&(!this.test||this.test(i,o,t)))return this.value={from:i,to:o,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 p=new WeakMap;class m{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let o=p.get(e);if(!o||o.from>=i||o.to<=t){let o=new m(t,e.sliceString(t,i));return p.set(e,o),o}if(o.from==t&&o.to==i)return o;let{text:n,from:s}=o;return s>t&&(n=e.sliceString(t,s)+n,s=t),o.to<i&&(n+=e.sliceString(o.to,i)),p.set(e,new m(s,n)),new m(t,n.slice(t-s,i-s))}}class g{constructor(e,t,i,o,n){this.text=e,this.to=n,this.done=!1,this.value=d,this.matchPos=v(e,o),this.re=new RegExp(t,u+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=m.get(e,o,this.chunkEnd(o+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=m.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,o=e.lineAt(t);for(;t<o.to&&(i=o.text.charCodeAt(t-o.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:s}=e,r=s.doc.lineAt(s.selection.main.head),[,l,a,c,h]=i,d=c?+c.slice(1):0,u=a?+a:r.number;if(a&&h){let e=u/100;l&&(e=e*("-"==l?-1:1)+r.number/s.doc.lines),u=Math.round(s.doc.lines*e)}else a&&l&&(u=u*("-"==l?-1:1)+r.number);let f=s.doc.line(Math.max(1,Math.min(s.doc.lines,u))),p=n.EditorSelection.cursor(f.from+Math.max(0,Math.min(d,f.length)));e.dispatch({effects:[w.of(!1),o.EditorView.scrollIntoView(p.from,{y:"center"})],selection:p}),e.focus()}return{dom:l("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:w.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:w.of(!1)}),e.focus()},"aria-label":e.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(f.prototype[Symbol.iterator]=g.prototype[Symbol.iterator]=function(){return this});const w=n.StateEffect.define(),y=n.StateField.define({create:()=>!0,update(e,t){for(let i of t.effects)i.is(w)&&(e=i.value);return e},provide:e=>o.showPanel.from(e,e=>e?b:null)}),x=o.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"}}}),C={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},S=n.Facet.define({combine:e=>(0,n.combineConfig)(e,C,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});function k(e){let t=[P,D];return e&&t.push(S.of(e)),t}const M=o.Decoration.mark({class:"cm-selectionMatch"}),E=o.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function A(e,t,i,o){return!(0!=i&&e(t.sliceDoc(i-1,i))==n.CharCategory.Word||o!=t.doc.length&&e(t.sliceDoc(o,o+1))==n.CharCategory.Word)}const D=o.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,s=i.selection;if(s.ranges.length>1)return o.Decoration.none;let r,l=s.main,a=null;if(l.empty){if(!t.highlightWordAroundCursor)return o.Decoration.none;let e=i.wordAt(l.head);if(!e)return o.Decoration.none;a=i.charCategorizer(l.head),r=i.sliceDoc(e.from,e.to)}else{let e=l.to-l.from;if(e<t.minSelectionLength||e>200)return o.Decoration.none;if(t.wholeWords){if(r=i.sliceDoc(l.from,l.to),a=i.charCategorizer(l.head),!A(a,i,l.from,l.to)||!function(e,t,i,o){return e(t.sliceDoc(i,i+1))==n.CharCategory.Word&&e(t.sliceDoc(o-1,o))==n.CharCategory.Word}(a,i,l.from,l.to))return o.Decoration.none}else if(r=i.sliceDoc(l.from,l.to),!r)return o.Decoration.none}let c=[];for(let n of e.visibleRanges){let e=new h(i.doc,r,n.from,n.to);for(;!e.next().done;){let{from:n,to:s}=e.value;if((!a||A(a,i,n,s))&&(l.empty&&n<=l.from&&s>=l.to?c.push(E.range(n,s)):(n>=l.to||s<=l.from)&&c.push(M.range(n,s)),c.length>t.maxMatches))return o.Decoration.none}}return o.Decoration.set(c)}},{decorations:e=>e.decorations}),P=o.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),I=n.Facet.define({combine:e=>(0,n.combineConfig)(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new se(e),scrollToMatch:e=>o.EditorView.scrollIntoView(e)})});class L{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 B(this):new T(this)}getCursor(e,t=0,i){let o=e.doc?e:n.EditorState.create({doc:e});return null==i&&(i=o.doc.length),this.regexp?F(this,o,t,i):O(this,o,t,i)}}class R{constructor(e){this.spec=e}}function O(e,t,i,o){return new h(t.doc,e.unquoted,i,o,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(s=t.doc,r=t.charCategorizer(t.selection.main.head),(e,t,i,o)=>((o>e||o+i.length<t)&&(o=Math.max(0,e-2),i=s.sliceString(o,Math.min(s.length,t+2))),!(r(q(i,e-o))==n.CharCategory.Word&&r(W(i,e-o))==n.CharCategory.Word||r(W(i,t-o))==n.CharCategory.Word&&r(q(i,t-o))==n.CharCategory.Word))):void 0);var s,r}class T extends R{constructor(e){super(e)}nextMatch(e,t,i){let o=O(this.spec,e,i,e.doc.length).nextOverlapping();if(o.done){let i=Math.min(e.doc.length,t+this.spec.unquoted.length);o=O(this.spec,e,0,i).nextOverlapping()}return o.done||o.value.from==t&&o.value.to==i?null:o.value}prevMatchInRange(e,t,i){for(let o=i;;){let i=Math.max(t,o-1e4-this.spec.unquoted.length),n=O(this.spec,e,i,o),s=null;for(;!n.nextOverlapping().done;)s=n.value;if(s)return s;if(i==t)return null;o-=1e4}}prevMatch(e,t,i){let o=this.prevMatchInRange(e,0,t);return o||(o=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),!o||o.from==t&&o.to==i?null:o}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=O(this.spec,e,0,e.doc.length),o=[];for(;!i.next().done;){if(o.length>=t)return null;o.push(i.value)}return o}highlight(e,t,i,o){let n=O(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!n.next().done;)o(n.value.from,n.value.to)}}function F(e,t,i,o){return new f(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(s=t.charCategorizer(t.selection.main.head),(e,t,i)=>!i[0].length||(s(q(i.input,i.index))!=n.CharCategory.Word||s(W(i.input,i.index))!=n.CharCategory.Word)&&(s(W(i.input,i.index+i[0].length))!=n.CharCategory.Word||s(q(i.input,i.index+i[0].length))!=n.CharCategory.Word)):void 0},i,o);var s}function q(e,t){return e.slice((0,n.findClusterBreak)(e,t,!1),t)}function W(e,t){return e.slice(t,(0,n.findClusterBreak)(e,t))}class B extends R{nextMatch(e,t,i){let o=F(this.spec,e,i,e.doc.length).next();return o.done&&(o=F(this.spec,e,0,t).next()),o.done?null:o.value}prevMatchInRange(e,t,i){for(let o=1;;o++){let n=Math.max(t,i-1e4*o),s=F(this.spec,e,n,i),r=null;for(;!s.next().done;)r=s.value;if(r&&(n==t||r.from>n+10))return r;if(n==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 o=+i.slice(0,t);if(o>0&&o<e.match.length)return e.match[o]+i.slice(t)}return t})}matchAll(e,t){let i=F(this.spec,e,0,e.doc.length),o=[];for(;!i.next().done;){if(o.length>=t)return null;o.push(i.value)}return o}highlight(e,t,i,o){let n=F(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!n.next().done;)o(n.value.from,n.value.to)}}const $=n.StateEffect.define(),V=n.StateEffect.define(),z=n.StateField.define({create:e=>new N(J(e).create(),null),update(e,t){for(let i of t.effects)i.is($)?e=new N(i.value.create(),e.panel):i.is(V)&&(e=new N(e.query,i.value?Z:null));return e},provide:e=>o.showPanel.from(e,e=>e.panel)});class N{constructor(e,t){this.query=e,this.panel=t}}const H=o.Decoration.mark({class:"cm-searchMatch"}),U=o.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),j=o.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(z))}update(e){let t=e.state.field(z);(t!=e.startState.field(z)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return o.Decoration.none;let{view:i}=this,s=new n.RangeSetBuilder;for(let t=0,o=i.visibleRanges,n=o.length;t<n;t++){let{from:r,to:l}=o[t];for(;t<n-1&&l>o[t+1].from-500;)l=o[++t].to;e.highlight(i.state,r,l,(e,t)=>{let o=i.state.selection.ranges.some(i=>i.from==e&&i.to==t);s.add(e,t,o?U:H)})}return s.finish()}},{decorations:e=>e.decorations});function K(e){return t=>{let i=t.state.field(z,!1);return i&&i.query.spec.valid?e(t,i):ie(t)}}const _=K((e,{query:t})=>{let{to:i}=e.state.selection.main,o=t.nextMatch(e.state,i,i);if(!o)return!1;let s=n.EditorSelection.single(o.from,o.to),r=e.state.facet(I);return e.dispatch({selection:s,effects:[ce(e,o),r.scrollToMatch(s.main,e)],userEvent:"select.search"}),te(e),!0}),Q=K((e,{query:t})=>{let{state:i}=e,{from:o}=i.selection.main,s=t.prevMatch(i,o,o);if(!s)return!1;let r=n.EditorSelection.single(s.from,s.to),l=e.state.facet(I);return e.dispatch({selection:r,effects:[ce(e,s),l.scrollToMatch(r.main,e)],userEvent:"select.search"}),te(e),!0}),G=K((e,{query:t})=>{let i=t.matchAll(e.state,1e3);return!(!i||!i.length||(e.dispatch({selection:n.EditorSelection.create(i.map(e=>n.EditorSelection.range(e.from,e.to))),userEvent:"select.search.matches"}),0))}),X=K((e,{query:t})=>{let{state:i}=e,{from:s,to:r}=i.selection.main;if(i.readOnly)return!1;let l=t.nextMatch(i,s,s);if(!l)return!1;let a,c,h=l,d=[],u=[];h.from==s&&h.to==r&&(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(o.EditorView.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(s).number)+".")));let f=e.state.changes(d);return h&&(a=n.EditorSelection.single(h.from,h.to).map(f),u.push(ce(e,h)),u.push(i.facet(I).scrollToMatch(a.main,e))),e.dispatch({changes:f,selection:a,effects:u,userEvent:"input.replace"}),!0}),Y=K((e,{query:t})=>{if(e.state.readOnly)return!1;let i=t.matchAll(e.state,1e9).map(e=>{let{from:i,to:o}=e;return{from:i,to:o,insert:t.getReplacement(e)}});if(!i.length)return!1;let n=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:o.EditorView.announce.of(n),userEvent:"input.replace.all"}),!0});function Z(e){return e.state.facet(I).createPanel(e)}function J(e,t){var i,o,n,s,r;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(I);return new L({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(o=null==t?void 0:t.caseSensitive)&&void 0!==o?o:c.caseSensitive,literal:null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal,regexp:null!==(s=null==t?void 0:t.regexp)&&void 0!==s?s:c.regexp,wholeWord:null!==(r=null==t?void 0:t.wholeWord)&&void 0!==r?r:c.wholeWord})}function ee(e){let t=(0,o.getPanel)(e,Z);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(z,!1);if(t&&t.panel){let i=ee(e);if(i&&i!=e.root.activeElement){let o=J(e.state,t.query.spec);o.valid&&e.dispatch({effects:$.of(o)}),i.focus(),i.select()}}else e.dispatch({effects:[V.of(!0),t?$.of(J(e.state,t.query.spec)):n.StateEffect.appendConfig.of(de)]});return!0},oe=e=>{let t=e.state.field(z,!1);if(!t||!t.panel)return!1;let i=(0,o.getPanel)(e,Z);return i&&i.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:V.of(!1)}),!0},ne=[{key:"Mod-f",run:ie,scope:"editor search-panel"},{key:"F3",run:_,shift:Q,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:_,shift:Q,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:oe,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:o,to:s}=i.main,r=[],l=0;for(let t=new h(e.doc,e.sliceDoc(o,s));!t.next().done;){if(r.length>1e3)return!1;t.value.from==o&&(l=r.length),r.push(n.EditorSelection.range(t.value.from,t.value.to))}return t(e.update({selection:n.EditorSelection.create(r,l),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let t=(0,o.getPanel)(e,b);if(!t){let i=[w.of(!0)];null==e.state.field(y,!1)&&i.push(n.StateEffect.appendConfig.of([y,x])),e.dispatch({effects:i}),t=(0,o.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,o=n.EditorSelection.create(i.ranges.map(t=>e.wordAt(t.head)||n.EditorSelection.cursor(t.head)),i.mainIndex);return!o.eq(i)&&(t(e.update({selection:o})),!0)})({state:e,dispatch:t});let s=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=s))return!1;let r=function(e,t){let{main:i,ranges:o}=e.selection,n=e.wordAt(i.head),s=n&&n.from==i.from&&n.to==i.to;for(let i=!1,n=new h(e.doc,t,o[o.length-1].to);;){if(n.next(),!n.done){if(i&&o.some(e=>e.from==n.value.from))continue;if(s){let t=e.wordAt(n.value.from);if(!t||t.from!=n.value.from||t.to!=n.value.to)continue}return n.value}if(i)return null;n=new h(e.doc,t,0,Math.max(0,o[o.length-1].from-1)),i=!0}}(e,s);return!!r&&(t(e.update({selection:e.selection.addRange(n.EditorSelection.range(r.from,r.to),!1),effects:o.EditorView.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class se{constructor(e){this.view=e;let t=this.query=e.state.field(z).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:re(e,"Find"),"aria-label":re(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:re(e,"Replace"),"aria-label":re(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",()=>_(e),[re(e,"next")]),i("prev",()=>Q(e),[re(e,"previous")]),i("select",()=>G(e),[re(e,"all")]),l("label",null,[this.caseField,re(e,"match case")]),l("label",null,[this.reField,re(e,"regexp")]),l("label",null,[this.wordField,re(e,"by word")]),...e.state.readOnly?[]:[l("br"),this.replaceField,i("replace",()=>X(e),[re(e,"replace")]),i("replaceAll",()=>Y(e),[re(e,"replace all")])],l("button",{name:"close",onclick:()=>oe(e),"aria-label":re(e,"close"),type:"button"},["×"])])}commit(){let e=new L({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,o.runScopeHandlers)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Q:_)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),X(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(I).top}}function re(e,t){return e.state.phrase(t)}const le=30,ae=/[\s\.,:;?!]/;function ce(e,{from:t,to:i}){let n=e.state.doc.lineAt(t),s=e.state.doc.lineAt(i).to,r=Math.max(n.from,t-le),l=Math.min(s,i+le),a=e.state.sliceDoc(r,l);if(r!=n.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!=s)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 o.EditorView.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${n.number}.`)}const he=o.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=[z,n.Prec.low(j),he];class ue{constructor(e,t,i,o){this.state=e,this.pos=t,this.explicit=i,this.view=o,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=(0,s.syntaxTree)(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),o=t.text.slice(i-t.from,this.pos-t.from),n=o.search(ge(e,!1));return n<0?null:{from:i+n,to:this.pos,text:o.slice(n)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,i){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function fe(e){let t=Object.keys(e).join(""),i=/\w/.test(t);return i&&(t=t.replace(/\w/g,"")),`[${i?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}class pe{constructor(e,t,i,o){this.completion=e,this.source=t,this.match=i,this.score=o}}function me(e){return e.selection.main.from}function ge(e,t){var i;let{source:o}=e,n=t&&"^"!=o[0],s="$"!=o[o.length-1];return n||s?new RegExp(`${n?"^":""}(?:${o})${s?"$":""}`,null!==(i=e.flags)&&void 0!==i?i:e.ignoreCase?"i":""):e}const ve=n.Annotation.define();function be(e,t,i,o){let{main:s}=e.selection,r=i-s.from,l=o-s.from;return{...e.changeByRange(a=>{if(a!=s&&i!=o&&e.sliceDoc(a.from+r,a.from+l)!=e.sliceDoc(i,o))return{range:a};let c=e.toText(t);return{changes:{from:a.from+r,to:o==s.from?a.to:a.from+l,insert:c},range:n.EditorSelection.cursor(a.from+r+c.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const we=new WeakMap;function ye(e){if(!Array.isArray(e))return e;let t=we.get(e);return t||we.set(e,t=function(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[i,o]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),i=Object.create(null);for(let{label:o}of e){t[o[0]]=!0;for(let e=1;e<o.length;e++)i[o[e]]=!0}let o=fe(t)+fe(i)+"*$";return[new RegExp("^"+o),new RegExp(o)]}(t);return e=>{let n=e.matchBefore(o);return n||e.explicit?{from:n?n.from:e.pos,options:t,validFor:i}:null}}(e)),t}const xe=n.StateEffect.define(),Ce=n.StateEffect.define();class Se{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=(0,n.codePointAt)(e,t),o=(0,n.codePointSize)(i);this.chars.push(i);let s=e.slice(t,t+o),r=s.toUpperCase();this.folded.push((0,n.codePointAt)(r==s?s.toLowerCase():r,0)),t+=o}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:o,precise:s,byWord:r}=this;if(1==t.length){let o=(0,n.codePointAt)(e,0),s=(0,n.codePointSize)(o),r=s==e.length?0:-100;if(o==t[0]);else{if(o!=i[0])return null;r+=-200}return this.ret(r,[0,s])}let l=e.indexOf(this.pattern);if(0==l)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,c=0;if(l<0){for(let s=0,r=Math.min(e.length,200);s<r&&c<a;){let r=(0,n.codePointAt)(e,s);r!=t[c]&&r!=i[c]||(o[c++]=s),s+=(0,n.codePointSize)(r)}if(c<a)return null}let h=0,d=0,u=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(e),v=!0;for(let o=0,c=Math.min(e.length,200),b=0;o<c&&d<a;){let c=(0,n.codePointAt)(e,o);l<0&&(h<a&&c==t[h]&&(s[h++]=o),f<a&&(c==t[f]||c==i[f]?(0==f&&(p=o),m=o+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,n.fromCodePoint)(c))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!o||1==y&&g||0==b&&0!=y)&&(t[d]==c||i[d]==c&&(u=!0)?r[d++]=o:r.length&&(v=!1)),b=y,o+=(0,n.codePointSize)(c)}return d==a&&0==r[0]&&v?this.result((u?-200:0)-100,r,e):f==a&&0==p?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):f==a?this.ret(-900-e.length,[p,m]):d==a?this.result((u?-200:0)-100-700+(v?0:-1100),r,e):2==t.length?null:this.result((o[0]?-700:0)-200-1100,o,e)}result(e,t,i){let o=[],s=0;for(let e of t){let t=e+(this.astral?(0,n.codePointSize)((0,n.codePointAt)(i,e)):1);s&&o[s-1]==e?o[s-1]=t:(o[s++]=e,o[s++]=t)}return this.ret(e-i.length,o)}}class ke{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const Me=n.Facet.define({combine:e=>(0,n.combineConfig)(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Ae,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Ee(e(i),t(i)),optionClass:(e,t)=>i=>Ee(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function Ee(e,t){return e?t?e+" "+t:e:t}function Ae(e,t,i,n,s,r){let l,a,c=e.textDirection==o.Direction.RTL,h=c,d=!1,u="top",f=t.left-s.left,p=s.right-t.right,m=n.right-n.left,g=n.bottom-n.top;if(h&&f<Math.min(m,p)?h=!1:!h&&p<Math.min(m,f)&&(h=!0),m<=(h?f:p))l=Math.max(s.top,Math.min(i.top,s.bottom-g))-t.top,a=Math.min(400,h?f:p);else{d=!0,a=Math.min(400,(c?t.right:s.right-t.left)-30);let e=s.bottom-t.bottom;e>=g||e>t.top?l=i.bottom-t.top:(u="bottom",l=t.bottom-i.top)}return{style:`${u}: ${l/((t.bottom-t.top)/r.offsetHeight)}px; max-width: ${a/((t.right-t.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(d?c?"left-narrow":"right-narrow":h?"left":"right")}}function De(e,t,i){if(e<=i)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/i);return{from:e*i,to:(e+1)*i}}let o=Math.floor((e-t)/i);return{from:e-(o+1)*i,to:e-o*i}}class Pe{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let o=e.state.field(t),{options:n,selected:s}=o.open,r=e.state.facet(Me);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,i,o){let n=document.createElement("span");n.className="cm-completionLabel";let s=e.displayLabel||e.label,r=0;for(let e=0;e<o.length;){let t=o[e++],i=o[e++];t>r&&n.appendChild(document.createTextNode(s.slice(r,t)));let l=n.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(s.slice(t,i))),l.className="cm-completionMatchedText",r=i}return r<s.length&&n.appendChild(document.createTextNode(s.slice(r))),n},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(r),this.optionClass=r.optionClass,this.tooltipClass=r.tooltipClass,this.range=De(n.length,s,r.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",i=>{let{options:o}=e.state.field(t).open;for(let t,n=i.target;n&&n!=this.dom;n=n.parentNode)if("LI"==n.nodeName&&(t=/-(\d+)$/.exec(n.id))&&+t[1]<o.length)return this.applyCompletion(e,o[+t[1]]),void i.preventDefault()}),this.dom.addEventListener("focusout",t=>{let i=e.state.field(this.stateField,!1);i&&i.tooltip&&e.state.facet(Me).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:Ce.of(null)})}),this.showOptions(n,o.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),o=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=o){let{options:n,selected:s,disabled:r}=i.open;o.open&&o.open.options==n||(this.range=De(n.length,s,e.state.facet(Me).maxRenderedOptions),this.showOptions(n,i.id)),this.updateSel(),r!=(null===(t=o.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!r)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=De(t.options.length,t.selected,this.view.state.facet(Me).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:s}=n;if(!s)return;let r="string"==typeof s?document.createTextNode(s):s(n);if(!r)return;"then"in r?r.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,n)}).catch(e=>(0,o.logException)(this.view.state,e,"completion info")):(this.addInfoPane(r,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=e.nodeType)i.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:o}=e;i.appendChild(t),this.infoDestroy=o||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,o=this.range.from;i;i=i.nextSibling,o++)"LI"==i.nodeName&&i.id?o==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby")):o--;return t&&function(e,t){let i=e.getBoundingClientRect(),o=t.getBoundingClientRect(),n=i.height/e.offsetHeight;o.top<i.top?e.scrollTop-=(i.top-o.top)/n:o.bottom>i.bottom&&(e.scrollTop+=(o.bottom-i.bottom)/n)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),o=e.getBoundingClientRect(),n=this.space;if(!n){let e=this.dom.ownerDocument.documentElement;n={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return o.top>Math.min(n.bottom,t.bottom)-10||o.bottom<Math.max(n.top,t.top)+10?null:this.view.state.facet(Me).positionInfo(this.view,t,o,i,n,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const o=document.createElement("ul");o.id=t,o.setAttribute("role","listbox"),o.setAttribute("aria-expanded","true"),o.setAttribute("aria-label",this.view.state.phrase("Completions")),o.addEventListener("mousedown",e=>{e.target==o&&e.preventDefault()});let n=null;for(let s=i.from;s<i.to;s++){let{completion:r,match:l}=e[s],{section:a}=r;if(a){let e="string"==typeof a?a:a.name;e!=n&&(s>i.from||0==i.from)&&(n=e,"string"!=typeof a&&a.header?o.appendChild(a.header(a)):o.appendChild(document.createElement("completion-section")).textContent=e)}const c=o.appendChild(document.createElement("li"));c.id=t+"-"+s,c.setAttribute("role","option");let h=this.optionClass(r);h&&(c.className=h);for(let e of this.optionContent){let t=e(r,this.view.state,this.view,l);t&&c.appendChild(t)}}return i.from&&o.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&o.classList.add("cm-completionListIncompleteBottom"),o}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Ie(e,t){return i=>new Pe(i,e,t)}function Le(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class Re{constructor(e,t,i,o,n,s){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=o,this.selected=n,this.disabled=s}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Re(this.options,qe(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,o,n,s){if(o&&!s&&e.some(e=>e.isPending))return o.setDisabled();let r=function(e,t){let i=[],o=null,n=null,s=e=>{i.push(e);let{section:t}=e.completion;if(t){o||(o=[]);let e="string"==typeof t?t:t.name;o.some(t=>t.name==e)||o.push("string"==typeof t?{name:e}:t)}},r=t.facet(Me);for(let o of e)if(o.hasResult()){let e=o.result.getMatch;if(!1===o.result.filter)for(let t of o.result.options)s(new pe(t,o.source,e?e(t):[],1e9-i.length));else{let i,l=t.sliceDoc(o.from,o.to),a=r.filterStrict?new ke(l):new Se(l);for(let t of o.result.options)if(i=a.match(t.label)){let r=t.displayLabel?e?e(t,i.matched):[]:i.matched,l=i.score+(t.boost||0);if(s(new pe(t,o.source,r,l)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;n||(n=Object.create(null)),n[e]=Math.max(l,n[e]||-1e9)}}}}if(o){let e=Object.create(null),t=0,s=(e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?n[t.name]-n[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1);for(let i of o.sort(s))t-=1e5,e[i.name]=t;for(let t of i){let{section:i}=t.completion;i&&(t.score+=e["string"==typeof i?i:i.name])}}let l=[],a=null,c=r.compareCompletions;for(let e of i.sort((e,t)=>t.score-e.score||c(e.completion,t.completion))){let t=e.completion;!a||a.label!=t.label||a.detail!=t.detail||null!=a.type&&null!=t.type&&a.type!=t.type||a.apply!=t.apply||a.boost!=t.boost?l.push(e):Le(e.completion)>Le(a)&&(l[l.length-1]=e),a=e.completion}return l}(e,t);if(!r.length)return o&&e.some(e=>e.isPending)?o.setDisabled():null;let l=t.facet(Me).selectOnOpen?0:-1;if(o&&o.selected!=l&&-1!=o.selected){let e=o.options[o.selected].completion;for(let t=0;t<r.length;t++)if(r[t].completion==e){l=t;break}}return new Re(r,qe(i,l),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:je,above:n.aboveCursor},o?o.timestamp:Date.now(),l,!1)}map(e){return new Re(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Re(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Oe{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Oe(We,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Me),o=(i.override||t.languageDataAt("autocomplete",me(t)).map(ye)).map(t=>(this.active.find(e=>e.source==t)||new $e(t,this.active.some(e=>0!=e.state)?1:0)).update(e,i));o.length==this.active.length&&o.every((e,t)=>e==this.active[t])&&(o=this.active);let n=this.open,s=e.effects.some(e=>e.is(ze));n&&e.docChanged&&(n=n.map(e.changes)),e.selection||o.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let i=0,o=0;;){for(;i<e.length&&!e[i].hasResult();)i++;for(;o<t.length&&!t[o].hasResult();)o++;let n=i==e.length,s=o==t.length;if(n||s)return n==s;if(e[i++].result!=t[o++].result)return!1}}(o,this.active)||s?n=Re.build(o,t,this.id,n,i,s):n&&n.disabled&&!o.some(e=>e.isPending)&&(n=null),!n&&o.every(e=>!e.isPending)&&o.some(e=>e.hasResult())&&(o=o.map(e=>e.hasResult()?new $e(e.source,0):e));for(let t of e.effects)t.is(Ne)&&(n=n&&n.setSelected(t.value,this.id));return o==this.active&&n==this.open?this:new Oe(o,this.id,n)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Te:Fe}}const Te={"aria-autocomplete":"list"},Fe={};function qe(e,t){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(i["aria-activedescendant"]=e+"-"+t),i}const We=[];function Be(e,t){if(e.isUserEvent("input.complete")){let i=e.annotation(ve);if(i&&t.activateOnCompletion(i))return 12}let i=e.isUserEvent("input.type");return i&&t.activateOnTyping?5:i?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class $e{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let i=Be(e,t),o=this;(8&i||16&i&&this.touches(e))&&(o=new $e(o.source,0)),4&i&&0==o.state&&(o=new $e(this.source,1)),o=o.updateFor(e,i);for(let t of e.effects)if(t.is(xe))o=new $e(o.source,1,t.value);else if(t.is(Ce))o=new $e(o.source,0);else if(t.is(ze))for(let e of t.value)e.source==o.source&&(o=e);return o}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(me(e.state))}}class Ve extends $e{constructor(e,t,i,o,n,s){super(e,3,t),this.limit=i,this.result=o,this.from=n,this.to=s}hasResult(){return!0}updateFor(e,t){var i;if(!(3&t))return this.map(e.changes);let o=this.result;o.map&&!e.changes.empty&&(o=o.map(o,e.changes));let n=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),r=me(e.state);if(r>s||!o||2&t&&(me(e.startState)==this.from||r<this.limit))return new $e(this.source,4&t?1:0);let l=e.changes.mapPos(this.limit);return function(e,t,i,o){if(!e)return!1;let n=t.sliceDoc(i,o);return"function"==typeof e?e(n,i,o,t):ge(e,!0).test(n)}(o.validFor,e.state,n,s)?new Ve(this.source,this.explicit,l,o,n,s):o.update&&(o=o.update(o,n,s,new ue(e.state,r,!1)))?new Ve(this.source,this.explicit,l,o,o.from,null!==(i=o.to)&&void 0!==i?i:me(e.state)):new $e(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Ve(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new $e(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const ze=n.StateEffect.define({map:(e,t)=>e.map(e=>e.map(t))}),Ne=n.StateEffect.define(),He=n.StateField.define({create:()=>Oe.start(),update:(e,t)=>e.update(t),provide:e=>[o.showTooltip.from(e,e=>e.tooltip),o.EditorView.contentAttributes.from(e,e=>e.attrs)]});function Ue(e,t){const i=t.completion.apply||t.completion.label;let o=e.state.field(He).active.find(e=>e.source==t.source);return o instanceof Ve&&("string"==typeof i?e.dispatch({...be(e.state,i,o.from,o.to),annotations:ve.of(t.completion)}):i(e,t.completion,o.from,o.to),!0)}const je=Ie(He,Ue);function Ke(e,t="option"){return i=>{let n=i.state.field(He,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(Me).interactionDelay)return!1;let s,r=1;"page"==t&&(s=(0,o.getTooltip)(i,n.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:l}=n.open.options,a=n.open.selected>-1?n.open.selected+r*(e?1:-1):e?0:l-1;return a<0?a="page"==t?0:l-1:a>=l&&(a="page"==t?l-1:0),i.dispatch({effects:Ne.of(a)}),!0}}const _e=e=>!!e.state.field(He,!1)&&(e.dispatch({effects:xe.of(!0)}),!0);class Qe{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ge=o.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(He).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(He),i=e.state.facet(Me);if(!e.selectionSet&&!e.docChanged&&e.startState.field(He)==t)return;let n=e.transactions.some(e=>{let t=Be(e,i);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let i=this.running[t];if(n||i.context.abortOnDocChange&&e.docChanged||i.updates.length+e.transactions.length>50&&Date.now()-i.time>1e3){for(let e of i.context.abortListeners)try{e()}catch(e){(0,o.logException)(this.view.state,e)}i.context.abortListeners=null,this.running.splice(t--,1)}else i.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(xe)))&&(this.pendingStart=!0);let s=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),s):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(He);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Me).updateSyncTime))}startQuery(e){let{state:t}=this.view,i=me(t),n=new ue(t,i,e.explicit,this.view),s=new Qe(e,n);this.running.push(s),Promise.resolve(e.source(n)).then(e=>{s.context.aborted||(s.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:Ce.of(null)}),(0,o.logException)(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Me).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],i=this.view.state.facet(Me),o=this.view.state.field(He);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=me(s.updates.length?s.updates[0].startState:this.view.state),n=Math.min(o,s.done.from+(s.active.explicit?0:1)),r=new Ve(s.active.source,s.active.explicit,n,s.done,s.done.from,null!==(e=s.done.to)&&void 0!==e?e:o);for(let e of s.updates)r=r.update(e,i);if(r.hasResult()){t.push(r);continue}}let r=o.active.find(e=>e.source==s.active.source);if(r&&r.isPending)if(null==s.done){let e=new $e(s.active.source,0);for(let t of s.updates)e=e.update(t,i);e.isPending||t.push(e)}else this.startQuery(r)}(t.length||o.open&&o.open.disabled)&&this.view.dispatch({effects:ze.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(He,!1);if(t&&t.tooltip&&this.view.state.facet(Me).closeOnBlur){let i=t.open&&(0,o.getTooltip)(this.view,t.open.tooltip);i&&i.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:Ce.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:xe.of(!1)}),20),this.composing=0}}}),Xe="object"==typeof navigator&&/Win/.test(navigator.platform),Ye=n.Prec.highest(o.EditorView.domEventHandlers({keydown(e,t){let i=t.state.field(He,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||e.key.length>1||e.ctrlKey&&(!Xe||!e.altKey)||e.metaKey)return!1;let o=i.open.options[i.open.selected],n=i.active.find(e=>e.source==o.source),s=o.completion.commitCharacters||n.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&Ue(t,o),!1}})),Ze=o.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"}}}),Je={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},et=n.StateEffect.define({map(e,t){let i=t.mapPos(e,-1,n.MapMode.TrackAfter);return null==i?void 0:i}}),tt=new class extends n.RangeValue{};tt.startSide=1,tt.endSide=-1;const it=n.StateField.define({create:()=>n.RangeSet.empty,update(e,t){if(e=e.map(t.changes),t.selection){let i=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=i.from&&e<=i.to})}for(let i of t.effects)i.is(et)&&(e=e.update({add:[tt.range(i.value,i.value+1)]}));return e}}),ot="()[]{}<>«»»«[]{}";function nt(e){for(let t=0;t<16;t+=2)if(ot.charCodeAt(t)==e)return ot.charAt(t+1);return(0,n.fromCodePoint)(e<128?e:e+1)}function st(e,t){return e.languageDataAt("closeBrackets",t)[0]||Je}const rt="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),lt=o.EditorView.inputHandler.of((e,t,i,o)=>{if((rt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let s=e.state.selection.main;if(o.length>2||2==o.length&&1==(0,n.codePointSize)((0,n.codePointAt)(o,0))||t!=s.from||i!=s.to)return!1;let r=function(e,t){let i=st(e,e.selection.main.head),o=i.brackets||Je.brackets;for(let s of o){let r=nt((0,n.codePointAt)(s,0));if(t==s)return r==s?ft(e,s,o.indexOf(s+s+s)>-1,i):dt(e,s,r,i.before||Je.before);if(t==r&&ct(e,e.selection.main.from))return ut(e,0,r)}return null}(e.state,o);return!!r&&(e.dispatch(r),!0)}),at=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=st(e,e.selection.main.head).brackets||Je.brackets,o=null,s=e.changeByRange(t=>{if(t.empty){let o=function(e,t){let i=e.sliceString(t-2,t);return(0,n.codePointSize)((0,n.codePointAt)(i,0))==i.length?i:i.slice(1)}(e.doc,t.head);for(let s of i)if(s==o&&ht(e.doc,t.head)==nt((0,n.codePointAt)(s,0)))return{changes:{from:t.head-s.length,to:t.head+s.length},range:n.EditorSelection.cursor(t.head-s.length)}}return{range:o=t}});return o||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!o}}];function ct(e,t){let i=!1;return e.field(it).between(0,e.doc.length,e=>{e==t&&(i=!0)}),i}function ht(e,t){let i=e.sliceString(t,t+2);return i.slice(0,(0,n.codePointSize)((0,n.codePointAt)(i,0)))}function dt(e,t,i,o){let s=null,r=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:i,from:r.to}],effects:et.of(r.to+t.length),range:n.EditorSelection.range(r.anchor+t.length,r.head+t.length)};let l=ht(e.doc,r.head);return!l||/\s/.test(l)||o.indexOf(l)>-1?{changes:{insert:t+i,from:r.head},effects:et.of(r.head+t.length),range:n.EditorSelection.cursor(r.head+t.length)}:{range:s=r}});return s?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function ut(e,t,i){let o=null,s=e.changeByRange(t=>t.empty&&ht(e.doc,t.head)==i?{changes:{from:t.head,to:t.head+i.length,insert:i},range:n.EditorSelection.cursor(t.head+i.length)}:o={range:t});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ft(e,t,i,o){let r=o.stringPrefixes||Je.stringPrefixes,l=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:et.of(o.to+t.length),range:n.EditorSelection.range(o.anchor+t.length,o.head+t.length)};let a,c=o.head,h=ht(e.doc,c);if(h==t){if(pt(e,c))return{changes:{insert:t+t,from:c},effects:et.of(c+t.length),range:n.EditorSelection.cursor(c+t.length)};if(ct(e,c)){let o=i&&e.sliceDoc(c,c+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:c,to:c+o.length,insert:o},range:n.EditorSelection.cursor(c+o.length)}}}else{if(i&&e.sliceDoc(c-2*t.length,c)==t+t&&(a=mt(e,c-2*t.length,r))>-1&&pt(e,a))return{changes:{insert:t+t+t+t,from:c},effects:et.of(c+t.length),range:n.EditorSelection.cursor(c+t.length)};if(e.charCategorizer(c)(h)!=n.CharCategory.Word&&mt(e,c,r)>-1&&!function(e,t,i,o){let n=(0,s.syntaxTree)(e).resolveInner(t,-1),r=o.reduce((e,t)=>Math.max(e,t.length),0);for(let s=0;s<5;s++){let s=e.sliceDoc(n.from,Math.min(n.to,n.from+i.length+r)),l=s.indexOf(i);if(!l||l>-1&&o.indexOf(s.slice(0,l))>-1){let t=n.firstChild;for(;t&&t.from==n.from&&t.to-t.from>i.length+l;){if(e.sliceDoc(t.to-i.length,t.to)==i)return!1;t=t.firstChild}return!0}let a=n.to==t&&n.parent;if(!a)break;n=a}return!1}(e,c,t,r))return{changes:{insert:t+t,from:c},effects:et.of(c+t.length),range:n.EditorSelection.cursor(c+t.length)}}return{range:l=o}});return l?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function pt(e,t){let i=(0,s.syntaxTree)(e).resolveInner(t+1);return i.parent&&i.from==t}function mt(e,t,i){let o=e.charCategorizer(t);if(o(e.sliceDoc(t-1,t))!=n.CharCategory.Word)return t;for(let s of i){let i=t-s.length;if(e.sliceDoc(i,t)==s&&o(e.sliceDoc(i-1,i))!=n.CharCategory.Word)return i}return-1}function gt(e={}){return[Ye,He,Me.of(e),Ge,bt,Ze]}const vt=[{key:"Ctrl-Space",run:_e},{mac:"Alt-`",run:_e},{mac:"Alt-i",run:_e},{key:"Escape",run:e=>{let t=e.state.field(He,!1);return!(!t||!t.active.some(e=>0!=e.state)||(e.dispatch({effects:Ce.of(null)}),0))}},{key:"ArrowDown",run:Ke(!0)},{key:"ArrowUp",run:Ke(!1)},{key:"PageDown",run:Ke(!0,"page")},{key:"PageUp",run:Ke(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(He,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Me).interactionDelay)&&Ue(e,t.open.options[t.open.selected])}}],bt=n.Prec.highest(o.keymap.computeN([Me],e=>e.facet(Me).defaultKeymap?[vt]:[]));class wt{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class yt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=i.facet(Lt).markerFilter;s&&(e=s(e,i));let r=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),l=new n.RangeSetBuilder,a=[],c=0,h=i.doc.iter(),d=0,u=i.doc.length;for(let e=0;;){let t,i,n=e==r.length?null:r[e];if(!n&&!a.length)break;if(a.length)t=c,i=a.reduce((e,t)=>Math.min(e,t.to),n&&n.from>t?n.from:1e8);else{if(t=n.from,t>u)break;i=n.to,a.push(n),e++}for(;e<r.length;){let o=r[e];if(o.from!=t||!(o.to>o.from||o.to==t)){i=Math.min(o.from,i);break}a.push(o),e++,i=Math.min(o.to,i)}i=Math.min(i,u);let s=!1;if(a.some(e=>e.from==t&&(e.to==i||i==u))&&(s=t==i,!s&&i-t<10)){let e=t-(d+h.value.length);e>0&&(h.next(e),d=t);for(let e=t;;){if(e>=i){s=!0;break}if(!h.lineBreak&&d+h.value.length>e)break;e=d+h.value.length,d+=h.value.length,h.next()}}let f=zt(a);if(s)l.add(t,t,o.Decoration.widget({widget:new Ft(f),diagnostics:a.slice()}));else{let e=a.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");l.add(t,i,o.Decoration.mark({class:"cm-lintRange cm-lintRange-"+f+e,diagnostics:a.slice(),inclusiveEnd:a.some(e=>e.to>i)}))}if(c=i,c==u)break;for(let e=0;e<a.length;e++)a[e].to<=c&&a.splice(e--,1)}let f=l.finish();return new yt(f,t,xt(f))}}function xt(e,t=null,i=0){let o=null;return e.between(i,1e9,(e,i,{spec:n})=>{if(!(t&&n.diagnostics.indexOf(t)<0))if(o){if(n.diagnostics.indexOf(o.diagnostic)<0)return!1;o=new wt(o.from,i,o.diagnostic)}else o=new wt(e,i,t||n.diagnostics[0])}),o}const Ct=n.StateEffect.define(),St=n.StateEffect.define(),kt=n.StateEffect.define(),Mt=n.StateField.define({create:()=>new yt(o.Decoration.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let i=e.diagnostics.map(t.changes),o=null,n=e.panel;if(e.selected){let n=t.changes.mapPos(e.selected.from,1);o=xt(i,e.selected.diagnostic,n)||xt(i,null,n)}!i.size&&n&&t.state.facet(Lt).autoPanel&&(n=null),e=new yt(i,n,o)}for(let i of t.effects)if(i.is(Ct)){let o=t.state.facet(Lt).autoPanel?i.value.length?Wt.open:null:e.panel;e=yt.init(i.value,o,t.state)}else i.is(St)?e=new yt(e.diagnostics,i.value?Wt.open:null,e.selected):i.is(kt)&&(e=new yt(e.diagnostics,e.panel,i.value));return e},provide:e=>[o.showPanel.from(e,e=>e.panel),o.EditorView.decorations.from(e,e=>e.diagnostics)]}),Et=o.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function At(e,t,i){let o,{diagnostics:n}=e.state.field(Mt),s=-1,r=-1;n.between(t-(i<0?1:0),t+(i>0?1:0),(e,n,{spec:l})=>{if(t>=e&&t<=n&&(e==n||(t>e||i>0)&&(t<n||i<0)))return o=l.diagnostics,s=e,r=n,!1});let l=e.state.facet(Lt).tooltipFilter;return o&&l&&(o=l(o,e.state)),o?{pos:s,end:r,above:e.state.doc.lineAt(s).to<r,create:()=>({dom:Dt(e,o)})}:null}function Dt(e,t){return l("ul",{class:"cm-tooltip-lint"},t.map(t=>Tt(e,t,!1)))}const Pt=e=>{let t=e.state.field(Mt,!1);return!(!t||!t.panel||(e.dispatch({effects:St.of(!1)}),0))},It=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(Mt,!1);var i,s;t&&t.panel||e.dispatch({effects:(i=e.state,s=[St.of(!0)],i.field(Mt,!1)?s:s.concat(n.StateEffect.appendConfig.of(Nt)))});let r=(0,o.getPanel)(e,Wt.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(Mt,!1);if(!t)return!1;let i=e.state.selection.main,o=t.diagnostics.iter(i.to+1);return!(!o.value&&(o=t.diagnostics.iter(0),!o.value||o.from==i.from&&o.to==i.to)||(e.dispatch({selection:{anchor:o.from,head:o.to},scrollIntoView:!0}),0))}}],Lt=n.Facet.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...(0,n.combineConfig)(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Rt,tooltipFilter:Rt,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,o,n)=>e(i,o,n)||t(i,o,n):e:t,autoPanel:(e,t)=>e||t})})});function Rt(e,t){return e?t?(i,o)=>t(e(i,o),o):e:t}function Ot(e){let t=[];if(e)e:for(let{name:i}of e){for(let e=0;e<i.length;e++){let o=i[e];if(/[a-zA-Z]/.test(o)&&!t.some(e=>e.toLowerCase()==o.toLowerCase())){t.push(o);continue e}}t.push("")}return t}function Tt(e,t,i){var o;let n=i?Ot(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===(o=t.actions)||void 0===o?void 0:o.map((i,o)=>{let s=!1,r=o=>{if(o.preventDefault(),s)return;s=!0;let n=xt(e.state.field(Mt).diagnostics,t);n&&i.apply(e,n.from,n.to)},{name:a}=i,c=n[o]?a.indexOf(n[o]):-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"+(i.markClass?" "+i.markClass:""),onclick:r,onmousedown:r,"aria-label":` Action: ${a}${c<0?"":` (access key "${n[o]})"`}.`},h)}),t.source&&l("div",{class:"cm-diagnosticSource"},t.source))}class Ft extends o.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 qt{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=Tt(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Wt{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)Pt(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],o=Ot(i.actions);for(let n=0;n<o.length;n++)if(o[n].toUpperCase().charCodeAt(0)==t.keyCode){let t=xt(this.view.state.field(Mt).diagnostics,i);t&&i.actions[n].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:()=>Pt(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Mt).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(Mt),i=0,o=!1,n=null,s=new Set;for(e.between(0,this.view.state.doc.length,(e,r,{spec:l})=>{for(let e of l.diagnostics){if(s.has(e))continue;s.add(e);let r,l=-1;for(let t=i;t<this.items.length;t++)if(this.items[t].diagnostic==e){l=t;break}l<0?(r=new qt(this.view,e),this.items.splice(i,0,r),o=!0):(r=this.items[l],l>i&&(this.items.splice(i,l-i),o=!0)),t&&r.diagnostic==t.diagnostic?r.dom.hasAttribute("aria-selected")||(r.dom.setAttribute("aria-selected","true"),n=r):r.dom.hasAttribute("aria-selected")&&r.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();0==this.items.length&&(this.items.push(new qt(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!0),n?(this.list.setAttribute("aria-activedescendant",n.id),this.view.requestMeasure({key:this,read:()=>({sel:n.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"),o&&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=xt(this.view.state.field(Mt).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:kt.of(t)})}static open(e){return new Wt(e)}}function Bt(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 $t=o.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:Bt("#d11")},".cm-lintRange-warning":{backgroundImage:Bt("orange")},".cm-lintRange-info":{backgroundImage:Bt("#999")},".cm-lintRange-hint":{backgroundImage:Bt("#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 Vt(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function zt(e){let t="hint",i=1;for(let o of e){let e=Vt(o.severity);e>i&&(i=e,t=o.severity)}return t}o.GutterMarker;const Nt=[Mt,o.EditorView.decorations.compute([Mt],e=>{let{selected:t,panel:i}=e.field(Mt);return t&&i&&t.from!=t.to?o.Decoration.set([Et.range(t.from,t.to)]):o.Decoration.none}),(0,o.hoverTooltip)(At,{hideOn:function(e,t){let i=t.pos,o=t.end||i,n=e.state.facet(Lt).hideOn(e,i,o);if(null!=n)return n;let s=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(Ct))&&!e.changes.touchesRange(s.from,Math.max(s.to,o)))}}),$t],Ht=(()=>[(0,o.lineNumbers)(),(0,o.highlightActiveLineGutter)(),(0,o.highlightSpecialChars)(),(0,r.b6)(),(0,s.foldGutter)(),(0,o.drawSelection)(),(0,o.dropCursor)(),n.EditorState.allowMultipleSelections.of(!0),(0,s.indentOnInput)(),(0,s.syntaxHighlighting)(s.defaultHighlightStyle,{fallback:!0}),(0,s.bracketMatching)(),[lt,it],gt(),(0,o.rectangularSelection)(),(0,o.crosshairCursor)(),(0,o.highlightActiveLine)(),k(),o.keymap.of([...at,...r.pw,...ne,...r.cL,...s.foldKeymap,...vt,...It])])(),Ut=(()=>[(0,o.highlightSpecialChars)(),(0,r.b6)(),(0,o.drawSelection)(),(0,s.syntaxHighlighting)(s.defaultHighlightStyle,{fallback:!0}),o.keymap.of([...r.pw,...r.cL])])()}}]);