aicommits 1.12.0-develop.7 → 2.0.0-develop.1
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.
- package/dist/{cli-CEBBDznM.mjs → cli-CiS8kAU7.mjs} +96 -93
- package/dist/cli.mjs +1 -1
- package/dist/{token-CGM2J2PY.mjs → token-1RgIvzSg.mjs} +1 -1
- package/dist/{token-util-Btl7VWhB.mjs → token-util-BQstDXAi.mjs} +1 -1
- package/dist/{token-util--vfI4pq8.mjs → token-util-DrXRmuwy.mjs} +1 -1
- package/package.json +1 -1
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
var bp=Object.defineProperty;var a=(e,t)=>bp(e,"name",{value:t,configurable:!0});var Vt,It,Gt,Wt,Ht,Jt,Kt,Yt,Xt,Qt,ft,en,$t,Bt,tn,nn,rn,on,sn,an,un,ln,cn,dn,pn,Dn,fn,mn,hn,gn,vn,yn,_n,Fn,En,Cn,bn,wn,An,kn,xn,In,$n,Bn,Sn,Tn,On;import wp from"tty";import Ap from"update-notifier";import{Buffer as kp}from"node:buffer";import Tt from"node:path";import ki,{ChildProcess as xp}from"node:child_process";import fe,{stdin as xi,stdout as Ii}from"node:process";import Ip from"child_process";import Ve from"path";import so from"fs";import{fileURLToPath as $i}from"node:url";import $p,{constants as Bi}from"node:os";import Bp from"assert";import Sp from"events";import{createWriteStream as Tp,createReadStream as Op}from"node:fs";import Rp from"buffer";import io from"stream";import Pp from"util";import{debuglog as Np}from"node:util";import*as pr from"node:readline";import Si from"node:readline";import{Writable as Mp}from"node:stream";import be from"fs/promises";import Ti from"os";import jp from"crypto";import{fileURLToPath as zp,pathToFileURL as Zp}from"url";var Lp=Object.defineProperty,_e=a((e,t)=>Lp(e,"name",{value:t,configurable:!0}),"a");const Up="known-flag",qp="unknown-flag",Vp="argument",Gp=/\B([A-Z])/g,Wp=_e(e=>e.replaceAll(Gp,"-$1").toLowerCase(),"camelToKebab"),{hasOwnProperty:Hp}=Object.prototype,Pn=_e((e,t)=>Hp.call(e,t),"hasOwn"),ao=_e(e=>typeof e=="function"?[e,!1]:Array.isArray(e)?[e[0],!0]:ao(e.type),"parseFlagType"),Oi=_e((e,t)=>e===Boolean?t!=="false":t,"normalizeBoolean"),Ri=_e((e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),"applyParser"),Jp=/[\s.:=]/,Kp=_e(e=>{const t=`Flag name "${e}"`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const n=e.match(Jp);if(n)throw new Error(`${t} cannot contain "${n?.[0]}"`)},"validateFlagName"),uo=_e((e,t,n)=>{if(Pn(e,t))throw new Error(`Duplicate flags named "${t}"`);e[t]=n},"setFlag"),Yp=_e(e=>{const t={};for(const n in e){if(!Pn(e,n))continue;Kp(n);const r=e[n],s=[[],...ao(r),r];uo(t,n,s);const i=Wp(n);if(n!==i&&uo(t,i,s),"alias"in r&&typeof r.alias=="string"){const{alias:o}=r,u=`Flag alias "${o}" for flag "${n}"`;if(o.length===0)throw new Error(`${u} cannot be empty`);if(o.length>1)throw new Error(`${u} must be a single character`);uo(t,o,s)}}return t},"createRegistry"),Xp=_e((e,t)=>{const n={};for(const r in e){if(!Pn(e,r))continue;const[s,,i,o]=t[r];if(s.length===0&&"default"in o){let{default:u}=o;typeof u=="function"&&(u=u()),n[r]=u}else n[r]=i?s:s.pop()}return n},"finalizeFlags"),Dr="--",Qp=3,eD=/^-{1,2}\w/,Pi=_e(e=>{if(!eD.test(e))return;const t=!e.startsWith(Dr);let n=e.slice(t?1:2),r,s=-1;for(const i of["=",":","."]){const o=n.indexOf(i);o!==-1&&(s===-1||o<s)&&(s=o)}return s!==-1&&(r=n.slice(s+1),n=n.slice(0,s)),[n,r,t]},"parseFlagArgv"),Ni=_e((e,{onFlag:t,onArgument:n})=>{let r;const s=_e((i,o)=>{if(typeof r!="function")return!0;r(i,o),r=void 0},"triggerValueCallback");for(let i=0;i<e.length;i+=1){const o=e[i];if(o===Dr){s();const l=e.slice(i+1);n?.(l,[i],!0);break}const u=Pi(o);if(u){if(s(),!t)continue;const[l,c,d]=u;if(d)for(let p=0;p<l.length;p+=1){s();const h=p===l.length-1;r=t(l[p],h?c:void 0,[i,p+1,h])}else r=t(l,c,[i])}else s(o,[i])&&n?.([o],[i])}s()},"argvIterator"),Mi=_e((e,t)=>{for(let n=t.length-1;n>=0;n-=1){const[r,s,i]=t[n];if(s){const o=e[r];let u=o.slice(0,s);if(i||(u+=o.slice(s+1)),u!=="-"){e[r]=u;continue}}e.splice(r,1)}},"spliceFromArgv"),tD=_e((e,t=process.argv.slice(2),{ignore:n}={})=>{const r=[],s=Yp(e),i={},o=[];return o[Dr]=[],Ni(t,{onFlag(u,l,c){const d=(c.length===Qp||u.length>1)&&Pn(s,u);if(!n?.(d?Up:qp,u,l)){if(d){const[p,h]=s[u],f=Oi(h,l),D=_e((g,v)=>{r.push(c),v&&r.push(v),p.push(Ri(h,g||""))},"getFollowingValue");return f===void 0?D:D(f)}Pn(i,u)||(i[u]=[]),i[u].push(l===void 0?!0:l),r.push(c)}},onArgument:_e((u,l,c)=>{n?.(Vp,t[l[0]])||(o.push(...u),c?(o[Dr]=u,t.splice(l[0])):r.push(l))},"onArgument")}),Mi(t,r),{flags:Xp(e,s),unknownFlags:i,_:o}},"typeFlag");_e((e,t,n=process.argv.slice(2))=>{const r=new Set(e.split(",").map(l=>Pi(l)?.[0])),[s,i]=ao(t),o=[],u=[];return Ni(n,{onFlag:_e((l,c,d)=>{if(!r.has(l)||!i&&o.length>0)return;const p=Oi(s,c),h=_e((f,D)=>{u.push(d),D&&u.push(D),o.push(Ri(s,f||""))},"getFollowingValue");return p===void 0?h:h(p)},"onFlag")}),Mi(n,u),i?o:o[0]},"getFlag");var nD=Object.defineProperty,j=a((e,t)=>nD(e,"name",{value:t,configurable:!0}),"n");const rD=j(e=>{const t=process.stdout.columns??Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(t)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:t}:{columns:e.columns??[],stdoutColumns:e.stdoutColumns??t}},"getOptions");function ji({onlyFirst:e=!1}={}){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}a(ji,"j$1"),j(ji,"ansiRegex");const oD=ji();function lo(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(oD,"")}a(lo,"w$2"),j(lo,"stripAnsi");function zi(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}a(zi,"P$2"),j(zi,"isAmbiguous");function Zi(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}a(Zi,"z$2"),j(Zi,"isFullWidth");function Li(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101631&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129673||e>=129679&&e<=129734||e>=129742&&e<=129756||e>=129759&&e<=129769||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}a(Li,"G$3"),j(Li,"isWide");function Ui(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}a(Ui,"Z$1"),j(Ui,"validate");function qi(e,{ambiguousAsWide:t=!1}={}){return Ui(e),Zi(e)||Li(e)||t&&zi(e)?2:1}a(qi,"V$3"),j(qi,"eastAsianWidth");var sD=j(()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,"emojiRegex");const iD=new Intl.Segmenter,aD=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u");function at(e,t={}){if(typeof e!="string"||e.length===0)return 0;const{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(r||(e=lo(e)),e.length===0)return 0;let s=0;const i={ambiguousAsWide:!n};for(const{segment:o}of iD.segment(e)){const u=o.codePointAt(0);if(!(u<=31||u>=127&&u<=159)&&!(u>=8203&&u<=8207||u===65279)&&!(u>=768&&u<=879||u>=6832&&u<=6911||u>=7616&&u<=7679||u>=8400&&u<=8447||u>=65056&&u<=65071)&&!(u>=55296&&u<=57343)&&!(u>=65024&&u<=65039)&&!aD.test(o)){if(sD().test(o)){s+=2;continue}s+=qi(u,i)}}return s}a(at,"d$2"),j(at,"stringWidth");const Vi=j(e=>Math.max(...e.split(`
|
|
2
|
-
`).map(t=>
|
|
3
|
-
`),c=[...l];let d=0;for(const[p,h]of c.entries()){if(r+=h,
|
|
4
|
-
`?(i&&(r+=
|
|
5
|
-
`&&(s&&f&&(r+=
|
|
1
|
+
var Ap=Object.defineProperty;var a=(e,t)=>Ap(e,"name",{value:t,configurable:!0});var Jt,Tt,Kt,Yt,Xt,Qt,en,tn,nn,rn,ht,on,Ot,Rt,sn,an,un,ln,cn,dn,pn,Dn,fn,mn,hn,gn,vn,yn,_n,Fn,En,Cn,bn,wn,An,kn,xn,$n,In,Bn,Sn,Tn,On,Rn,Pn,Nn,Mn;import kp from"tty";import xp from"update-notifier";import{Buffer as $p}from"node:buffer";import Nt from"node:path";import Ii,{ChildProcess as Ip}from"node:child_process";import me,{stdin as Bi,stdout as Si}from"node:process";import Bp from"child_process";import Ve from"path";import lo from"fs";import{fileURLToPath as Ti}from"node:url";import Sp,{constants as Oi}from"node:os";import Tp from"assert";import Op from"events";import{createWriteStream as Rp,createReadStream as Pp}from"node:fs";import Np from"buffer";import co from"stream";import Mp from"util";import{debuglog as jp}from"node:util";import*as fr from"node:readline";import Ri from"node:readline";import{Writable as zp}from"node:stream";import we from"fs/promises";import Pi from"os";import Zp from"crypto";import{fileURLToPath as Lp,pathToFileURL as Up}from"url";var qp=Object.defineProperty,Fe=a((e,t)=>qp(e,"name",{value:t,configurable:!0}),"a");const Vp="known-flag",Gp="unknown-flag",Wp="argument",Hp=/\B([A-Z])/g,Jp=Fe(e=>e.replaceAll(Hp,"-$1").toLowerCase(),"camelToKebab"),{hasOwnProperty:Kp}=Object.prototype,zn=Fe((e,t)=>Kp.call(e,t),"hasOwn"),po=Fe(e=>typeof e=="function"?[e,!1]:Array.isArray(e)?[e[0],!0]:po(e.type),"parseFlagType"),Ni=Fe((e,t)=>e===Boolean?t!=="false":t,"normalizeBoolean"),Mi=Fe((e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),"applyParser"),Yp=/[\s.:=]/,Xp=Fe(e=>{const t=`Flag name "${e}"`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const n=e.match(Yp);if(n)throw new Error(`${t} cannot contain "${n?.[0]}"`)},"validateFlagName"),Do=Fe((e,t,n)=>{if(zn(e,t))throw new Error(`Duplicate flags named "${t}"`);e[t]=n},"setFlag"),Qp=Fe(e=>{const t={};for(const n in e){if(!zn(e,n))continue;Xp(n);const r=e[n],s=[[],...po(r),r];Do(t,n,s);const i=Jp(n);if(n!==i&&Do(t,i,s),"alias"in r&&typeof r.alias=="string"){const{alias:o}=r,u=`Flag alias "${o}" for flag "${n}"`;if(o.length===0)throw new Error(`${u} cannot be empty`);if(o.length>1)throw new Error(`${u} must be a single character`);Do(t,o,s)}}return t},"createRegistry"),eD=Fe((e,t)=>{const n={};for(const r in e){if(!zn(e,r))continue;const[s,,i,o]=t[r];if(s.length===0&&"default"in o){let{default:u}=o;typeof u=="function"&&(u=u()),n[r]=u}else n[r]=i?s:s.pop()}return n},"finalizeFlags"),mr="--",tD=3,nD=/^-{1,2}\w/,ji=Fe(e=>{if(!nD.test(e))return;const t=!e.startsWith(mr);let n=e.slice(t?1:2),r,s=-1;for(const i of["=",":","."]){const o=n.indexOf(i);o!==-1&&(s===-1||o<s)&&(s=o)}return s!==-1&&(r=n.slice(s+1),n=n.slice(0,s)),[n,r,t]},"parseFlagArgv"),zi=Fe((e,{onFlag:t,onArgument:n})=>{let r;const s=Fe((i,o)=>{if(typeof r!="function")return!0;r(i,o),r=void 0},"triggerValueCallback");for(let i=0;i<e.length;i+=1){const o=e[i];if(o===mr){s();const l=e.slice(i+1);n?.(l,[i],!0);break}const u=ji(o);if(u){if(s(),!t)continue;const[l,c,d]=u;if(d)for(let p=0;p<l.length;p+=1){s();const h=p===l.length-1;r=t(l[p],h?c:void 0,[i,p+1,h])}else r=t(l,c,[i])}else s(o,[i])&&n?.([o],[i])}s()},"argvIterator"),Zi=Fe((e,t)=>{for(let n=t.length-1;n>=0;n-=1){const[r,s,i]=t[n];if(s){const o=e[r];let u=o.slice(0,s);if(i||(u+=o.slice(s+1)),u!=="-"){e[r]=u;continue}}e.splice(r,1)}},"spliceFromArgv"),rD=Fe((e,t=process.argv.slice(2),{ignore:n}={})=>{const r=[],s=Qp(e),i={},o=[];return o[mr]=[],zi(t,{onFlag(u,l,c){const d=(c.length===tD||u.length>1)&&zn(s,u);if(!n?.(d?Vp:Gp,u,l)){if(d){const[p,h]=s[u],f=Ni(h,l),D=Fe((g,v)=>{r.push(c),v&&r.push(v),p.push(Mi(h,g||""))},"getFollowingValue");return f===void 0?D:D(f)}zn(i,u)||(i[u]=[]),i[u].push(l===void 0?!0:l),r.push(c)}},onArgument:Fe((u,l,c)=>{n?.(Wp,t[l[0]])||(o.push(...u),c?(o[mr]=u,t.splice(l[0])):r.push(l))},"onArgument")}),Zi(t,r),{flags:eD(e,s),unknownFlags:i,_:o}},"typeFlag");Fe((e,t,n=process.argv.slice(2))=>{const r=new Set(e.split(",").map(l=>ji(l)?.[0])),[s,i]=po(t),o=[],u=[];return zi(n,{onFlag:Fe((l,c,d)=>{if(!r.has(l)||!i&&o.length>0)return;const p=Ni(s,c),h=Fe((f,D)=>{u.push(d),D&&u.push(D),o.push(Mi(s,f||""))},"getFollowingValue");return p===void 0?h:h(p)},"onFlag")}),Zi(n,u),i?o:o[0]},"getFlag");var oD=Object.defineProperty,z=a((e,t)=>oD(e,"name",{value:t,configurable:!0}),"n");const sD=z(e=>{const t=process.stdout.columns??Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(t)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:t}:{columns:e.columns??[],stdoutColumns:e.stdoutColumns??t}},"getOptions");function Li({onlyFirst:e=!1}={}){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}a(Li,"j$1"),z(Li,"ansiRegex");const iD=Li();function fo(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(iD,"")}a(fo,"w$2"),z(fo,"stripAnsi");function Ui(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}a(Ui,"P$2"),z(Ui,"isAmbiguous");function qi(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}a(qi,"z$2"),z(qi,"isFullWidth");function Vi(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101631&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129673||e>=129679&&e<=129734||e>=129742&&e<=129756||e>=129759&&e<=129769||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}a(Vi,"G$3"),z(Vi,"isWide");function Gi(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}a(Gi,"Z$1"),z(Gi,"validate");function Wi(e,{ambiguousAsWide:t=!1}={}){return Gi(e),qi(e)||Vi(e)||t&&Ui(e)?2:1}a(Wi,"V$3"),z(Wi,"eastAsianWidth");var aD=z(()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,"emojiRegex");const uD=new Intl.Segmenter,lD=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u");function lt(e,t={}){if(typeof e!="string"||e.length===0)return 0;const{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(r||(e=fo(e)),e.length===0)return 0;let s=0;const i={ambiguousAsWide:!n};for(const{segment:o}of uD.segment(e)){const u=o.codePointAt(0);if(!(u<=31||u>=127&&u<=159)&&!(u>=8203&&u<=8207||u===65279)&&!(u>=768&&u<=879||u>=6832&&u<=6911||u>=7616&&u<=7679||u>=8400&&u<=8447||u>=65056&&u<=65071)&&!(u>=55296&&u<=57343)&&!(u>=65024&&u<=65039)&&!lD.test(o)){if(aD().test(o)){s+=2;continue}s+=Wi(u,i)}}return s}a(lt,"d$2"),z(lt,"stringWidth");const Hi=z(e=>Math.max(...e.split(`
|
|
2
|
+
`).map(t=>lt(t))),"getLongestLineWidth"),cD=z(e=>{const t=[];for(const n of e){const{length:r}=n,s=r-t.length;for(let i=0;i<s;i+=1)t.push(0);for(let i=0;i<r;i+=1){const o=Hi(n[i]);o>t[i]&&(t[i]=o)}}return t},"getColumnContentWidths"),Ji=/^\d+%$/,Ki={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},dD=z((e,t)=>{const n=[];for(let r=0;r<e.length;r+=1){const s=t[r]??"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&Ji.test(s)){n.push({...Ki,width:s,contentWidth:e[r]});continue}if(s&&typeof s=="object"){const i={...Ki,...s,contentWidth:e[r]};i.horizontalPadding=i.paddingLeft+i.paddingRight,n.push(i);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return n},"initColumns"),pD=z((e,t)=>{for(const n of e){const{width:r}=n;if(r==="content-width"&&(n.width=n.contentWidth),r==="auto"){const l=Math.min(20,n.contentWidth);n.width=l,n.autoOverflow=n.contentWidth-l}if(typeof r=="string"&&Ji.test(r)){const l=Number.parseFloat(r.slice(0,-1))/100;n.width=Math.floor(t*l)-(n.paddingLeft+n.paddingRight)}const{horizontalPadding:s}=n,i=1,o=i+s;if(o>=t){const l=o-t,c=Math.ceil(n.paddingLeft/s*l),d=l-c;n.paddingLeft-=c,n.paddingRight-=d,n.horizontalPadding=n.paddingLeft+n.paddingRight}n.paddingLeftString=n.paddingLeft?" ".repeat(n.paddingLeft):"",n.paddingRightString=n.paddingRight?" ".repeat(n.paddingRight):"";const u=t-n.horizontalPadding;n.width=Math.max(Math.min(n.width,u),i)}},"resolveColumnWidths"),Yi=z(()=>Object.assign([],{columns:0}),"makeRow"),DD=z((e,t)=>{const n=[Yi()];let[r]=n;for(const s of e){const i=s.width+s.horizontalPadding;r.columns+i>t&&(r=Yi(),n.push(r)),r.push(s),r.columns+=i}for(const s of n){const i=s.reduce((h,f)=>h+f.width+f.horizontalPadding,0);let o=t-i;if(o===0)continue;const u=s.filter(h=>"autoOverflow"in h),l=u.filter(h=>h.autoOverflow>0),c=l.reduce((h,f)=>h+f.autoOverflow,0),d=Math.min(c,o);for(const h of l){const f=Math.floor(h.autoOverflow/c*d);h.width+=f,o-=f}const p=Math.floor(o/u.length);for(let h=0;h<u.length;h+=1){const f=u[h];h===u.length-1?f.width+=o:f.width+=p,o-=p}}return n},"balanceAuto"),fD=z((e,t,n)=>{const r=dD(n,t);return pD(r,e),DD(r,e)},"computeColumnWidths"),mo=10,Xi=z((e=0)=>t=>`\x1B[${t+e}m`,"wrapAnsi16"),Qi=z((e=0)=>t=>`\x1B[${38+e};5;${t}m`,"wrapAnsi256"),ea=z((e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,"wrapAnsi16m"),ae={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(ae.modifier);const mD=Object.keys(ae.color),hD=Object.keys(ae.bgColor);[...mD,...hD];function ta(){const e=new Map;for(const[t,n]of Object.entries(ae)){for(const[r,s]of Object.entries(n))ae[r]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[r]=ae[r],e.set(s[0],s[1]);Object.defineProperty(ae,t,{value:n,enumerable:!1})}return Object.defineProperty(ae,"codes",{value:e,enumerable:!1}),ae.color.close="\x1B[39m",ae.bgColor.close="\x1B[49m",ae.color.ansi=Xi(),ae.color.ansi256=Qi(),ae.color.ansi16m=ea(),ae.bgColor.ansi=Xi(mo),ae.bgColor.ansi256=Qi(mo),ae.bgColor.ansi16m=ea(mo),Object.defineProperties(ae,{rgbToAnsi256:{value:z((t,n,r)=>t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5),"value"),enumerable:!1},hexToRgb:{value:z(t=>{const n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[r]=n;r.length===3&&(r=[...r].map(i=>i+i).join(""));const s=Number.parseInt(r,16);return[s>>16&255,s>>8&255,s&255]},"value"),enumerable:!1},hexToAnsi256:{value:z(t=>ae.rgbToAnsi256(...ae.hexToRgb(t)),"value"),enumerable:!1},ansi256ToAnsi:{value:z(t=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,r,s;if(t>=232)n=((t-232)*10+8)/255,r=n,s=n;else{t-=16;const u=t%36;n=Math.floor(t/36)/5,r=Math.floor(u/6)/5,s=u%6/5}const i=Math.max(n,r,s)*2;if(i===0)return 30;let o=30+(Math.round(s)<<2|Math.round(r)<<1|Math.round(n));return i===2&&(o+=60),o},"value"),enumerable:!1},rgbToAnsi:{value:z((t,n,r)=>ae.ansi256ToAnsi(ae.rgbToAnsi256(t,n,r)),"value"),enumerable:!1},hexToAnsi:{value:z(t=>ae.ansi256ToAnsi(ae.hexToAnsi256(t)),"value"),enumerable:!1}}),ae}a(ta,"FD$1"),z(ta,"assembleStyles");const gD=ta(),hr=new Set(["\x1B","\x9B"]),vD=39,ho="\x07",na="[",yD="]",ra="m",gr=`${yD}8;;`,oa=z(e=>`${hr.values().next().value}${na}${e}${ra}`,"wrapAnsiCode"),sa=z(e=>`${hr.values().next().value}${gr}${e}${ho}`,"wrapAnsiHyperlink"),_D=z(e=>e.split(" ").map(t=>lt(t)),"wordLengths"),go=z((e,t,n)=>{const r=[...t];let s=!1,i=!1,o=lt(fo(e.at(-1)));for(const[u,l]of r.entries()){const c=lt(l);if(o+c<=n?e[e.length-1]+=l:(e.push(l),o=0),hr.has(l)&&(s=!0,i=r.slice(u+1,u+1+gr.length).join("")===gr),s){i?l===ho&&(s=!1,i=!1):l===ra&&(s=!1);continue}o+=c,o===n&&u<r.length-1&&(e.push(""),o=0)}!o&&e.at(-1).length>0&&e.length>1&&(e[e.length-2]+=e.pop())},"wrapWord"),FD=z(e=>{const t=e.split(" ");let n=t.length;for(;n>0&&!(lt(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},"stringVisibleTrimSpacesRight"),ED=z((e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",s,i;const o=_D(e);let u=[""];for(const[p,h]of e.split(" ").entries()){n.trim!==!1&&(u[u.length-1]=u.at(-1).trimStart());let f=lt(u.at(-1));if(p!==0&&(f>=t&&(n.wordWrap===!1||n.trim===!1)&&(u.push(""),f=0),(f>0||n.trim===!1)&&(u[u.length-1]+=" ",f++)),n.hard&&o[p]>t){const D=t-f,g=1+Math.floor((o[p]-D-1)/t);Math.floor((o[p]-1)/t)<g&&u.push(""),go(u,h,t);continue}if(f+o[p]>t&&f>0&&o[p]>0){if(n.wordWrap===!1&&f<t){go(u,h,t);continue}u.push("")}if(f+o[p]>t&&n.wordWrap===!1){go(u,h,t);continue}u[u.length-1]+=h}n.trim!==!1&&(u=u.map(p=>FD(p)));const l=u.join(`
|
|
3
|
+
`),c=[...l];let d=0;for(const[p,h]of c.entries()){if(r+=h,hr.has(h)){const{groups:D}=new RegExp(`(?:\\${na}(?<code>\\d+)m|\\${gr}(?<uri>.*)${ho})`).exec(l.slice(d))||{groups:{}};if(D.code!==void 0){const g=Number.parseFloat(D.code);s=g===vD?void 0:g}else D.uri!==void 0&&(i=D.uri.length===0?void 0:D.uri)}const f=gD.codes.get(Number(s));c[p+1]===`
|
|
4
|
+
`?(i&&(r+=sa("")),s&&f&&(r+=oa(f))):h===`
|
|
5
|
+
`&&(s&&f&&(r+=oa(s)),i&&(r+=sa(i))),d+=h.length}return r},"exec");function ia(e,t,n){return String(e).normalize().replaceAll(`\r
|
|
6
6
|
`,`
|
|
7
7
|
`).split(`
|
|
8
|
-
`).map(r=>
|
|
9
|
-
`)}a(
|
|
10
|
-
`);if(l.postprocess){const{postprocess:p}=l;d=d.map((h,f)=>p.call(l,h,f))}return l.paddingTop&&d.unshift(...
|
|
8
|
+
`).map(r=>ED(r,t,n)).join(`
|
|
9
|
+
`)}a(ia,"BD$1"),z(ia,"wrapAnsi");const aa=z(e=>Array.from({length:e}).fill(""),"emptyLines"),CD=z((e,t)=>{const n=[];let r=0;for(const s of e){let i=0;const o=s.map(l=>{let c=t[r]??"";r+=1,l.preprocess&&(c=l.preprocess(c)),Hi(c)>l.width&&(c=ia(c,l.width,{hard:!0}));let d=c.split(`
|
|
10
|
+
`);if(l.postprocess){const{postprocess:p}=l;d=d.map((h,f)=>p.call(l,h,f))}return l.paddingTop&&d.unshift(...aa(l.paddingTop)),l.paddingBottom&&d.push(...aa(l.paddingBottom)),d.length>i&&(i=d.length),{...l,lines:d}}),u=[];for(let l=0;l<i;l+=1){const c=o.map(d=>{const p=d.lines[l]??"",h=Number.isFinite(d.width)?" ".repeat(d.width-lt(p)):"";let f=d.paddingLeftString;return d.align==="right"&&(f+=h),f+=p,d.align==="left"&&(f+=h),f+d.paddingRightString}).join("");u.push(c)}n.push(u.join(`
|
|
11
11
|
`))}return n.join(`
|
|
12
|
-
`)},"renderRow"),
|
|
13
|
-
`)},"terminalColumns"),
|
|
14
|
-
`}}a(
|
|
15
|
-
`}}a(
|
|
16
|
-
`):t.usage}}:void 0;if(e.name){const n=[],r=[
|
|
17
|
-
`)}}}}a(
|
|
18
|
-
`)),n)return{id:"examples",type:"section",data:{title:"Examples:",body:n}}}a(
|
|
12
|
+
`)},"renderRow"),bD=z((e,t)=>{if(!e||e.length===0)return"";const n=cD(e),r=n.length;if(r===0)return"";const{stdoutColumns:s,columns:i}=sD(t);if(i.length>r)throw new Error(`${i.length} columns defined, but only ${r} columns found`);const o=fD(s,i,n);return e.map(u=>CD(o,u)).join(`
|
|
13
|
+
`)},"terminalColumns"),wD=["<",">","=",">=","<="],AD=z(e=>{if(!wD.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)},"assertOperator"),kD=z(e=>{const t=Object.keys(e).map(n=>{const[r,s]=n.split(" ");AD(r);const i=Number.parseInt(s,10);if(Number.isNaN(i))throw new TypeError(`Invalid breakpoint value: ${s}`);const o=e[n];return{operator:r,breakpoint:i,value:o}}).sort((n,r)=>r.breakpoint-n.breakpoint);return n=>t.find(({operator:r,breakpoint:s})=>r==="="&&n===s||r===">"&&n>s||r==="<"&&n<s||r===">="&&n>=s||r==="<="&&n<=s)?.value},"breakpoints");var xD=Object.defineProperty,oe=a((e,t)=>xD(e,"name",{value:t,configurable:!0}),"s");const $D=oe(e=>e.replaceAll(/[\W_]([a-z\d])?/gi,(t,n)=>n?n.toUpperCase():""),"camelCase"),ID=oe(e=>e.replaceAll(/\B([A-Z])/g,"-$1").toLowerCase(),"kebabCase"),BD={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:oe(e=>e.trim(),"preprocess")},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function ua(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((n,r)=>n.localeCompare(r)).map(n=>{const r=e[n],s="alias"in r;return s&&(t=!0),{name:n,flag:r,flagFormatted:`--${ID(n)}`,aliasesEnabled:t,aliasFormatted:s?`-${r.alias}`:void 0}}).map(n=>(n.aliasesEnabled=t,[{type:"flagName",data:n},{type:"flagDescription",data:n}])),tableBreakpoints:BD}}}a(ua,"T"),oe(ua,"renderFlags");const la=oe(e=>!e||(e.version??(e.help?e.help.version:void 0)),"getVersion"),ca=oe(e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name},"getName");function da(e){const t=[];e.name&&t.push(ca(e));const n=la(e)??("parent"in e&&la(e.parent));if(n&&t.push(`v${n}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
|
|
14
|
+
`}}a(da,"k$2"),oe(da,"getNameAndVersion");function pa(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
|
|
15
|
+
`}}a(pa,"_$1"),oe(pa,"getDescription");function Da(e){const t=e.help||{};if("usage"in t)return t.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(t.usage)?t.usage.join(`
|
|
16
|
+
`):t.usage}}:void 0;if(e.name){const n=[],r=[ca(e)];if(e.flags&&Object.keys(e.flags).length>0&&r.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:s}=e,i=s.indexOf("--"),o=i!==-1&&s.slice(i+1).some(u=>u.startsWith("<"));r.push(s.map(u=>u!=="--"?u:o?"--":"[--]").join(" "))}if(r.length>1&&n.push(r.join(" ")),"commands"in e&&e.commands?.length&&n.push(`${e.name} <command>`),n.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:n.join(`
|
|
17
|
+
`)}}}}a(Da,"F"),oe(Da,"getUsage");function fa(e){return!("commands"in e)||!e.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:e.commands.map(t=>[t.options.name,t.options.help?t.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}a(fa,"H"),oe(fa,"getCommands");function ma(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:ua(e.flags),indentBody:0}}}a(ma,"U$1"),oe(ma,"getFlags");function ha(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:n}=t;if(Array.isArray(n)&&(n=n.join(`
|
|
18
|
+
`)),n)return{id:"examples",type:"section",data:{title:"Examples:",body:n}}}a(ha,"V$2"),oe(ha,"getExamples");function ga(e){if(!("alias"in e)||!e.alias)return;const{alias:t}=e;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(t)?t.join(", "):t}}}a(ga,"J$1"),oe(ga,"getAliases");const SD=oe(e=>[da,pa,Da,fa,ma,ha,ga].map(t=>t(e)).filter(Boolean),"generateHelp"),TD=kp.WriteStream.prototype.hasColors(),va=(Jt=class{text(t){return t}bold(t){return TD?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:n}){return t.replaceAll(/^/gm," ".repeat(n))}heading(t){return this.bold(t)}section({title:t,body:n,indentBody:r=2}){return`${(t?`${this.heading(t)}
|
|
19
19
|
`:"")+(n?this.indentText({text:this.render(n),spaces:r}):"")}
|
|
20
|
-
`}table({tableData:t,tableOptions:n,tableBreakpoints:r}){return
|
|
21
|
-
`);if("type"in t&&this[t.type]){const n=this[t.type];if(typeof n=="function")return n.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}},a(
|
|
22
|
-
`),r(),process.exit(1);e[l]=c}}a(gr,"v"),re(gr,"mapParametersToArguments");function ha(e){return e===void 0||e!==!1}a(ha,"G$2"),re(ha,"helpEnabled");function mo(e,t,n,r){const s={...t.flags},i=t.version&&!("version"in s);i&&(s.version={type:Boolean,description:"Show version"});const{help:o}=t,u=ha(o);u&&!("help"in s)&&(s.help={type:Boolean,alias:"h",description:"Show help"});const l=tD(s,r,{ignore:t.ignoreArgv}),c=re(()=>{console.log(t.version)},"showVersion");if(i&&l.flags.version===!0)return c(),process.exit(0);const d=new SD,p=u&&o?.render?o.render:g=>d.render(g),h=re(g=>{const v=$D({...t,...g?{help:g}:{},flags:s});console.log(p(v,d))},"showHelp");if(u&&l.flags.help===!0)return h(),process.exit(0);if(t.parameters){let{parameters:g}=t,v=l._;const F=g.indexOf("--"),C=g.slice(F+1),_=Object.create(null);if(F>-1&&C.length>0){g=g.slice(0,F);const b=l._["--"];v=v.slice(0,-b.length||void 0),gr(_,hr(g),v,h),gr(_,hr(C),b,h)}else gr(_,hr(g),v,h);Object.assign(l._,_)}const f={...l,showVersion:c,showHelp:h},D={command:e,...f};if(typeof n=="function"){const g=n(f);if(g&&"then"in g)return Object.assign(Promise.resolve(g),D)}return D}a(mo,"j"),re(mo,"cliBase");function ga(e,t){const n=new Map;for(const r of t){const s=[r.options.name],{alias:i}=r.options;i&&(Array.isArray(i)?s.push(...i):s.push(i));for(const o of s){if(n.has(o))throw new Error(`Duplicate command name found: ${Ye(o)}`);n.set(o,r)}}return n.get(e)}a(ga,"K$1"),re(ga,"getCommand");function va(e,t,n=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!fo(e.name)))throw new Error(`Invalid script name: ${Ye(e.name)}`);const r=n[0];if(e.commands&&r&&fo(r)){const s=ga(r,e.commands);if(s)return mo(s.options.name,{...s.options,parent:e},s.callback,n.slice(1))}return mo(void 0,e,t,n)}a(va,"Q"),re(va,"cli");function Nn(e,t){if(!e)throw new Error("Command options are required");const{name:n}=e;if(n===void 0)throw new Error("Command name is required");if(!fo(n))throw new Error(`Invalid command name ${JSON.stringify(n)}. Command names must be one word.`);return{options:e,callback:t}}a(Nn,"X"),re(Nn,"command");var OD="aicommits",RD="1.12.0-develop.7",PD="Writes your git commit messages for you with AI",ND=["ai","git","commit","code changes"],MD="MIT",jD="Nutlope/aicommits",zD="Hassan El Mghari (@nutlope)",ZD="module",LD=["dist"],UD={aicommits:"./dist/cli.mjs",aic:"./dist/cli.mjs"},qD={build:"pkgroll --minify",lint:"","type-check":"tsc",test:"tsx tests",prepack:"pnpm build && clean-pkg-json"},VD={"@clack/prompts":"^0.11.0","@types/ini":"^1.3.31","@types/node":"^24.10.1","@types/update-notifier":"^6.0.8","clean-pkg-json":"^1.3.0",cleye:"^2.0.0",clipboardy:"^5.0.0",execa:"^7.0.0","fs-fixture":"^1.2.0",ini:"^3.0.1",kolorist:"^1.8.0",manten:"^0.7.0",ai:"^5.0.104","@ai-sdk/openai":"^2.0.74","@ai-sdk/openai-compatible":"^1.0.28",pkgroll:"^2.20.1",tsx:"^4.20.6",typescript:"^5.9.3"},GD={branches:["main",{name:"develop",prerelease:!0}]},WD={"update-notifier":"^7.3.1"},ho={name:OD,version:RD,description:PD,keywords:ND,license:MD,repository:jD,author:zD,type:ZD,files:LD,bin:UD,scripts:qD,devDependencies:VD,release:GD,dependencies:WD},ut=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}a(gt,"getDefaultExportFromCjs");var vt={exports:{}},go,ya;function HD(){if(ya)return go;ya=1,go=r,r.sync=s;var e=so;function t(i,o){var u=o.pathExt!==void 0?o.pathExt:process.env.PATHEXT;if(!u||(u=u.split(";"),u.indexOf("")!==-1))return!0;for(var l=0;l<u.length;l++){var c=u[l].toLowerCase();if(c&&i.substr(-c.length).toLowerCase()===c)return!0}return!1}a(t,"checkPathExt");function n(i,o,u){return!i.isSymbolicLink()&&!i.isFile()?!1:t(o,u)}a(n,"checkStat");function r(i,o,u){e.stat(i,function(l,c){u(l,l?!1:n(c,i,o))})}a(r,"isexe");function s(i,o){return n(e.statSync(i),i,o)}return a(s,"sync"),go}a(HD,"requireWindows");var vo,_a;function JD(){if(_a)return vo;_a=1,vo=t,t.sync=n;var e=so;function t(i,o,u){e.stat(i,function(l,c){u(l,l?!1:r(c,o))})}a(t,"isexe");function n(i,o){return r(e.statSync(i),o)}a(n,"sync");function r(i,o){return i.isFile()&&s(i,o)}a(r,"checkStat");function s(i,o){var u=i.mode,l=i.uid,c=i.gid,d=o.uid!==void 0?o.uid:process.getuid&&process.getuid(),p=o.gid!==void 0?o.gid:process.getgid&&process.getgid(),h=parseInt("100",8),f=parseInt("010",8),D=parseInt("001",8),g=h|f,v=u&D||u&f&&c===p||u&h&&l===d||u&g&&d===0;return v}return a(s,"checkMode"),vo}a(JD,"requireMode");var yo,Fa;function KD(){if(Fa)return yo;Fa=1;var e;process.platform==="win32"||ut.TESTING_WINDOWS?e=HD():e=JD(),yo=t,t.sync=n;function t(r,s,i){if(typeof s=="function"&&(i=s,s={}),!i){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(o,u){t(r,s||{},function(l,c){l?u(l):o(c)})})}e(r,s||{},function(o,u){o&&(o.code==="EACCES"||s&&s.ignoreErrors)&&(o=null,u=!1),i(o,u)})}a(t,"isexe");function n(r,s){try{return e.sync(r,s||{})}catch(i){if(s&&s.ignoreErrors||i.code==="EACCES")return!1;throw i}}return a(n,"sync"),yo}a(KD,"requireIsexe");var _o,Ea;function YD(){if(Ea)return _o;Ea=1;const e=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",t=Ve,n=e?";":":",r=KD(),s=a(l=>Object.assign(new Error(`not found: ${l}`),{code:"ENOENT"}),"getNotFoundError"),i=a((l,c)=>{const d=c.colon||n,p=l.match(/\//)||e&&l.match(/\\/)?[""]:[...e?[process.cwd()]:[],...(c.path||process.env.PATH||"").split(d)],h=e?c.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",f=e?h.split(d):[""];return e&&l.indexOf(".")!==-1&&f[0]!==""&&f.unshift(""),{pathEnv:p,pathExt:f,pathExtExe:h}},"getPathInfo"),o=a((l,c,d)=>{typeof c=="function"&&(d=c,c={}),c||(c={});const{pathEnv:p,pathExt:h,pathExtExe:f}=i(l,c),D=[],g=a(F=>new Promise((C,_)=>{if(F===p.length)return c.all&&D.length?C(D):_(s(l));const b=p[F],B=/^".*"$/.test(b)?b.slice(1,-1):b,O=t.join(B,l),S=!B&&/^\.[\\\/]/.test(l)?l.slice(0,2)+O:O;C(v(S,F,0))}),"step"),v=a((F,C,_)=>new Promise((b,B)=>{if(_===h.length)return b(g(C+1));const O=h[_];r(F+O,{pathExt:f},(S,$)=>{if(!S&&$)if(c.all)D.push(F+O);else return b(F+O);return b(v(F,C,_+1))})}),"subStep");return d?g(0).then(F=>d(null,F),d):g(0)},"which"),u=a((l,c)=>{c=c||{};const{pathEnv:d,pathExt:p,pathExtExe:h}=i(l,c),f=[];for(let D=0;D<d.length;D++){const g=d[D],v=/^".*"$/.test(g)?g.slice(1,-1):g,F=t.join(v,l),C=!v&&/^\.[\\\/]/.test(l)?l.slice(0,2)+F:F;for(let _=0;_<p.length;_++){const b=C+p[_];try{if(r.sync(b,{pathExt:h}))if(c.all)f.push(b);else return b}catch{}}}if(c.all&&f.length)return f;if(c.nothrow)return null;throw s(l)},"whichSync");return _o=o,o.sync=u,_o}a(YD,"requireWhich");var vr={exports:{}},Ca;function XD(){if(Ca)return vr.exports;Ca=1;const e=a((t={})=>{const n=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(n).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"},"pathKey");return vr.exports=e,vr.exports.default=e,vr.exports}a(XD,"requirePathKey");var Fo,ba;function QD(){if(ba)return Fo;ba=1;const e=Ve,t=YD(),n=XD();function r(i,o){const u=i.options.env||process.env,l=process.cwd(),c=i.options.cwd!=null,d=c&&process.chdir!==void 0&&!process.chdir.disabled;if(d)try{process.chdir(i.options.cwd)}catch{}let p;try{p=t.sync(i.command,{path:u[n({env:u})],pathExt:o?e.delimiter:void 0})}catch{}finally{d&&process.chdir(l)}return p&&(p=e.resolve(c?i.options.cwd:"",p)),p}a(r,"resolveCommandAttempt");function s(i){return r(i)||r(i,!0)}return a(s,"resolveCommand"),Fo=s,Fo}a(QD,"requireResolveCommand");var yr={},wa;function ef(){if(wa)return yr;wa=1;const e=/([()\][%!^"`<>&|;, *?])/g;function t(r){return r=r.replace(e,"^$1"),r}a(t,"escapeCommand");function n(r,s){return r=`${r}`,r=r.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),r=r.replace(/(?=(\\+?)?)\1$/,"$1$1"),r=`"${r}"`,r=r.replace(e,"^$1"),s&&(r=r.replace(e,"^$1")),r}return a(n,"escapeArgument"),yr.command=t,yr.argument=n,yr}a(ef,"require_escape");var Eo,Aa;function tf(){return Aa||(Aa=1,Eo=/^#!(.*)/),Eo}a(tf,"requireShebangRegex");var Co,ka;function nf(){if(ka)return Co;ka=1;const e=tf();return Co=a((t="")=>{const n=t.match(e);if(!n)return null;const[r,s]=n[0].replace(/#! ?/,"").split(" "),i=r.split("/").pop();return i==="env"?s:s?`${i} ${s}`:i},"shebangCommand"),Co}a(nf,"requireShebangCommand");var bo,xa;function rf(){if(xa)return bo;xa=1;const e=so,t=nf();function n(r){const i=Buffer.alloc(150);let o;try{o=e.openSync(r,"r"),e.readSync(o,i,0,150,0),e.closeSync(o)}catch{}return t(i.toString())}return a(n,"readShebang"),bo=n,bo}a(rf,"requireReadShebang");var wo,Ia;function of(){if(Ia)return wo;Ia=1;const e=Ve,t=QD(),n=ef(),r=rf(),s=process.platform==="win32",i=/\.(?:com|exe)$/i,o=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function u(d){d.file=t(d);const p=d.file&&r(d.file);return p?(d.args.unshift(d.file),d.command=p,t(d)):d.file}a(u,"detectShebang");function l(d){if(!s)return d;const p=u(d),h=!i.test(p);if(d.options.forceShell||h){const f=o.test(p);d.command=e.normalize(d.command),d.command=n.command(d.command),d.args=d.args.map(g=>n.argument(g,f));const D=[d.command].concat(d.args).join(" ");d.args=["/d","/s","/c",`"${D}"`],d.command=process.env.comspec||"cmd.exe",d.options.windowsVerbatimArguments=!0}return d}a(l,"parseNonShell");function c(d,p,h){p&&!Array.isArray(p)&&(h=p,p=null),p=p?p.slice(0):[],h=Object.assign({},h);const f={command:d,args:p,options:h,file:void 0,original:{command:d,args:p}};return h.shell?f:l(f)}return a(c,"parse"),wo=c,wo}a(of,"requireParse");var Ao,$a;function sf(){if($a)return Ao;$a=1;const e=process.platform==="win32";function t(i,o){return Object.assign(new Error(`${o} ${i.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${o} ${i.command}`,path:i.command,spawnargs:i.args})}a(t,"notFoundError");function n(i,o){if(!e)return;const u=i.emit;i.emit=function(l,c){if(l==="exit"){const d=r(c,o);if(d)return u.call(i,"error",d)}return u.apply(i,arguments)}}a(n,"hookChildProcess");function r(i,o){return e&&i===1&&!o.file?t(o.original,"spawn"):null}a(r,"verifyENOENT");function s(i,o){return e&&i===1&&!o.file?t(o.original,"spawnSync"):null}return a(s,"verifyENOENTSync"),Ao={hookChildProcess:n,verifyENOENT:r,verifyENOENTSync:s,notFoundError:t},Ao}a(sf,"requireEnoent");var Ba;function af(){if(Ba)return vt.exports;Ba=1;const e=Ip,t=of(),n=sf();function r(i,o,u){const l=t(i,o,u),c=e.spawn(l.command,l.args,l.options);return n.hookChildProcess(c,l),c}a(r,"spawn");function s(i,o,u){const l=t(i,o,u),c=e.spawnSync(l.command,l.args,l.options);return c.error=c.error||n.verifyENOENTSync(c.status,l),c}return a(s,"spawnSync"),vt.exports=r,vt.exports.spawn=r,vt.exports.sync=s,vt.exports._parse=t,vt.exports._enoent=n,vt.exports}a(af,"requireCrossSpawn");var uf=af(),lf=gt(uf);function cf(e){const t=typeof e=="string"?`
|
|
23
|
-
`:10,n=typeof e=="string"?"\r":13;return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}a(
|
|
24
|
-
${t}`,"wrappedToString"),
|
|
20
|
+
`}table({tableData:t,tableOptions:n,tableBreakpoints:r}){return bD(t.map(s=>s.map(i=>this.render(i))),r?kD(r):n)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:n,flagFormatted:r,aliasesEnabled:s,aliasFormatted:i}=t;let o="";if(i?o+=`${i}, `:s&&(o+=" "),o+=r,"placeholder"in n&&typeof n.placeholder=="string")o+=`${this.flagOperator(t)}${n.placeholder}`;else{const u=this.flagParameter("type"in n?n.type:n);u&&(o+=`${this.flagOperator(t)}${u}`)}return o}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let n="description"in t?t.description??"":"";if("default"in t){let{default:r}=t;typeof r=="function"&&(r=r()),r&&(n+=` (default: ${this.flagDefault(r)})`)}return n}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(n=>this.render(n)).join(`
|
|
21
|
+
`);if("type"in t&&this[t.type]){const n=this[t.type];if(typeof n=="function")return n.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}},a(Jt,"_z"),Jt);oe(va,"Renderers");let OD=va;const vo=oe(e=>e.length>0&&!e.includes(" "),"isValidScriptName"),{stringify:Xe}=JSON,RD=/[|\\{}()[\]^$+*?.]/;function vr(e){const t=[];let n,r;for(const s of e){if(r)throw new Error(`Invalid parameter: Spread parameter ${Xe(r)} must be last`);const i=s[0],o=s.at(-1);let u;if(i==="<"&&o===">"&&(u=!0,n))throw new Error(`Invalid parameter: Required parameter ${Xe(s)} cannot come after optional parameter ${Xe(n)}`);if(i==="["&&o==="]"&&(u=!1,n=s),u===void 0)throw new Error(`Invalid parameter: ${Xe(s)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let l=s.slice(1,-1);const c=l.slice(-3)==="...";c&&(r=s,l=l.slice(0,-3));const d=l.match(RD);if(d)throw new Error(`Invalid parameter: ${Xe(s)}. Invalid character found ${Xe(d[0])}`);t.push({name:l,required:u,spread:c})}return t}a(vr,"b$1"),oe(vr,"parseParameters");function yr(e,t,n,r){for(let s=0;s<t.length;s+=1){const{name:i,required:o,spread:u}=t[s],l=$D(i);if(l in e)throw new Error(`Invalid parameter: ${Xe(i)} is used more than once.`);const c=u?n.slice(s):n[s];if(u&&(s=t.length),o&&(!c||u&&c.length===0))return console.error(`Error: Missing required parameter ${Xe(i)}
|
|
22
|
+
`),r(),process.exit(1);e[l]=c}}a(yr,"v"),oe(yr,"mapParametersToArguments");function ya(e){return e===void 0||e!==!1}a(ya,"G$2"),oe(ya,"helpEnabled");function yo(e,t,n,r){const s={...t.flags},i=t.version&&!("version"in s);i&&(s.version={type:Boolean,description:"Show version"});const{help:o}=t,u=ya(o);u&&!("help"in s)&&(s.help={type:Boolean,alias:"h",description:"Show help"});const l=rD(s,r,{ignore:t.ignoreArgv}),c=oe(()=>{console.log(t.version)},"showVersion");if(i&&l.flags.version===!0)return c(),process.exit(0);const d=new OD,p=u&&o?.render?o.render:g=>d.render(g),h=oe(g=>{const v=SD({...t,...g?{help:g}:{},flags:s});console.log(p(v,d))},"showHelp");if(u&&l.flags.help===!0)return h(),process.exit(0);if(t.parameters){let{parameters:g}=t,v=l._;const F=g.indexOf("--"),C=g.slice(F+1),_=Object.create(null);if(F>-1&&C.length>0){g=g.slice(0,F);const b=l._["--"];v=v.slice(0,-b.length||void 0),yr(_,vr(g),v,h),yr(_,vr(C),b,h)}else yr(_,vr(g),v,h);Object.assign(l._,_)}const f={...l,showVersion:c,showHelp:h},D={command:e,...f};if(typeof n=="function"){const g=n(f);if(g&&"then"in g)return Object.assign(Promise.resolve(g),D)}return D}a(yo,"j"),oe(yo,"cliBase");function _a(e,t){const n=new Map;for(const r of t){const s=[r.options.name],{alias:i}=r.options;i&&(Array.isArray(i)?s.push(...i):s.push(i));for(const o of s){if(n.has(o))throw new Error(`Duplicate command name found: ${Xe(o)}`);n.set(o,r)}}return n.get(e)}a(_a,"K$1"),oe(_a,"getCommand");function Fa(e,t,n=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!vo(e.name)))throw new Error(`Invalid script name: ${Xe(e.name)}`);const r=n[0];if(e.commands&&r&&vo(r)){const s=_a(r,e.commands);if(s)return yo(s.options.name,{...s.options,parent:e},s.callback,n.slice(1))}return yo(void 0,e,t,n)}a(Fa,"Q"),oe(Fa,"cli");function Mt(e,t){if(!e)throw new Error("Command options are required");const{name:n}=e;if(n===void 0)throw new Error("Command name is required");if(!vo(n))throw new Error(`Invalid command name ${JSON.stringify(n)}. Command names must be one word.`);return{options:e,callback:t}}a(Mt,"X"),oe(Mt,"command");var PD="aicommits",ND="2.0.0-develop.1",MD="Writes your git commit messages for you with AI",jD=["ai","git","commit","code changes"],zD="MIT",ZD="Nutlope/aicommits",LD="Hassan El Mghari (@nutlope)",UD="module",qD=["dist"],VD={aicommits:"./dist/cli.mjs",aic:"./dist/cli.mjs"},GD={build:"pkgroll --minify",lint:"","type-check":"tsc",test:"tsx tests",prepack:"pnpm build && clean-pkg-json"},WD={"@clack/prompts":"^0.11.0","@types/ini":"^1.3.31","@types/node":"^24.10.1","@types/update-notifier":"^6.0.8","clean-pkg-json":"^1.3.0",cleye:"^2.0.0",clipboardy:"^5.0.0",execa:"^7.0.0","fs-fixture":"^1.2.0",ini:"^3.0.1",kolorist:"^1.8.0",manten:"^0.7.0",ai:"^5.0.104","@ai-sdk/openai":"^2.0.74","@ai-sdk/openai-compatible":"^1.0.28",pkgroll:"^2.20.1",tsx:"^4.20.6",typescript:"^5.9.3"},HD={branches:["main",{name:"develop",prerelease:!0}]},JD={"update-notifier":"^7.3.1"},_o={name:PD,version:ND,description:MD,keywords:jD,license:zD,repository:ZD,author:LD,type:UD,files:qD,bin:VD,scripts:GD,devDependencies:WD,release:HD,dependencies:JD},ct=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}a(yt,"getDefaultExportFromCjs");var _t={exports:{}},Fo,Ea;function KD(){if(Ea)return Fo;Ea=1,Fo=r,r.sync=s;var e=lo;function t(i,o){var u=o.pathExt!==void 0?o.pathExt:process.env.PATHEXT;if(!u||(u=u.split(";"),u.indexOf("")!==-1))return!0;for(var l=0;l<u.length;l++){var c=u[l].toLowerCase();if(c&&i.substr(-c.length).toLowerCase()===c)return!0}return!1}a(t,"checkPathExt");function n(i,o,u){return!i.isSymbolicLink()&&!i.isFile()?!1:t(o,u)}a(n,"checkStat");function r(i,o,u){e.stat(i,function(l,c){u(l,l?!1:n(c,i,o))})}a(r,"isexe");function s(i,o){return n(e.statSync(i),i,o)}return a(s,"sync"),Fo}a(KD,"requireWindows");var Eo,Ca;function YD(){if(Ca)return Eo;Ca=1,Eo=t,t.sync=n;var e=lo;function t(i,o,u){e.stat(i,function(l,c){u(l,l?!1:r(c,o))})}a(t,"isexe");function n(i,o){return r(e.statSync(i),o)}a(n,"sync");function r(i,o){return i.isFile()&&s(i,o)}a(r,"checkStat");function s(i,o){var u=i.mode,l=i.uid,c=i.gid,d=o.uid!==void 0?o.uid:process.getuid&&process.getuid(),p=o.gid!==void 0?o.gid:process.getgid&&process.getgid(),h=parseInt("100",8),f=parseInt("010",8),D=parseInt("001",8),g=h|f,v=u&D||u&f&&c===p||u&h&&l===d||u&g&&d===0;return v}return a(s,"checkMode"),Eo}a(YD,"requireMode");var Co,ba;function XD(){if(ba)return Co;ba=1;var e;process.platform==="win32"||ct.TESTING_WINDOWS?e=KD():e=YD(),Co=t,t.sync=n;function t(r,s,i){if(typeof s=="function"&&(i=s,s={}),!i){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(o,u){t(r,s||{},function(l,c){l?u(l):o(c)})})}e(r,s||{},function(o,u){o&&(o.code==="EACCES"||s&&s.ignoreErrors)&&(o=null,u=!1),i(o,u)})}a(t,"isexe");function n(r,s){try{return e.sync(r,s||{})}catch(i){if(s&&s.ignoreErrors||i.code==="EACCES")return!1;throw i}}return a(n,"sync"),Co}a(XD,"requireIsexe");var bo,wa;function QD(){if(wa)return bo;wa=1;const e=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",t=Ve,n=e?";":":",r=XD(),s=a(l=>Object.assign(new Error(`not found: ${l}`),{code:"ENOENT"}),"getNotFoundError"),i=a((l,c)=>{const d=c.colon||n,p=l.match(/\//)||e&&l.match(/\\/)?[""]:[...e?[process.cwd()]:[],...(c.path||process.env.PATH||"").split(d)],h=e?c.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",f=e?h.split(d):[""];return e&&l.indexOf(".")!==-1&&f[0]!==""&&f.unshift(""),{pathEnv:p,pathExt:f,pathExtExe:h}},"getPathInfo"),o=a((l,c,d)=>{typeof c=="function"&&(d=c,c={}),c||(c={});const{pathEnv:p,pathExt:h,pathExtExe:f}=i(l,c),D=[],g=a(F=>new Promise((C,_)=>{if(F===p.length)return c.all&&D.length?C(D):_(s(l));const b=p[F],B=/^".*"$/.test(b)?b.slice(1,-1):b,O=t.join(B,l),S=!B&&/^\.[\\\/]/.test(l)?l.slice(0,2)+O:O;C(v(S,F,0))}),"step"),v=a((F,C,_)=>new Promise((b,B)=>{if(_===h.length)return b(g(C+1));const O=h[_];r(F+O,{pathExt:f},(S,x)=>{if(!S&&x)if(c.all)D.push(F+O);else return b(F+O);return b(v(F,C,_+1))})}),"subStep");return d?g(0).then(F=>d(null,F),d):g(0)},"which"),u=a((l,c)=>{c=c||{};const{pathEnv:d,pathExt:p,pathExtExe:h}=i(l,c),f=[];for(let D=0;D<d.length;D++){const g=d[D],v=/^".*"$/.test(g)?g.slice(1,-1):g,F=t.join(v,l),C=!v&&/^\.[\\\/]/.test(l)?l.slice(0,2)+F:F;for(let _=0;_<p.length;_++){const b=C+p[_];try{if(r.sync(b,{pathExt:h}))if(c.all)f.push(b);else return b}catch{}}}if(c.all&&f.length)return f;if(c.nothrow)return null;throw s(l)},"whichSync");return bo=o,o.sync=u,bo}a(QD,"requireWhich");var _r={exports:{}},Aa;function ef(){if(Aa)return _r.exports;Aa=1;const e=a((t={})=>{const n=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(n).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"},"pathKey");return _r.exports=e,_r.exports.default=e,_r.exports}a(ef,"requirePathKey");var wo,ka;function tf(){if(ka)return wo;ka=1;const e=Ve,t=QD(),n=ef();function r(i,o){const u=i.options.env||process.env,l=process.cwd(),c=i.options.cwd!=null,d=c&&process.chdir!==void 0&&!process.chdir.disabled;if(d)try{process.chdir(i.options.cwd)}catch{}let p;try{p=t.sync(i.command,{path:u[n({env:u})],pathExt:o?e.delimiter:void 0})}catch{}finally{d&&process.chdir(l)}return p&&(p=e.resolve(c?i.options.cwd:"",p)),p}a(r,"resolveCommandAttempt");function s(i){return r(i)||r(i,!0)}return a(s,"resolveCommand"),wo=s,wo}a(tf,"requireResolveCommand");var Fr={},xa;function nf(){if(xa)return Fr;xa=1;const e=/([()\][%!^"`<>&|;, *?])/g;function t(r){return r=r.replace(e,"^$1"),r}a(t,"escapeCommand");function n(r,s){return r=`${r}`,r=r.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),r=r.replace(/(?=(\\+?)?)\1$/,"$1$1"),r=`"${r}"`,r=r.replace(e,"^$1"),s&&(r=r.replace(e,"^$1")),r}return a(n,"escapeArgument"),Fr.command=t,Fr.argument=n,Fr}a(nf,"require_escape");var Ao,$a;function rf(){return $a||($a=1,Ao=/^#!(.*)/),Ao}a(rf,"requireShebangRegex");var ko,Ia;function of(){if(Ia)return ko;Ia=1;const e=rf();return ko=a((t="")=>{const n=t.match(e);if(!n)return null;const[r,s]=n[0].replace(/#! ?/,"").split(" "),i=r.split("/").pop();return i==="env"?s:s?`${i} ${s}`:i},"shebangCommand"),ko}a(of,"requireShebangCommand");var xo,Ba;function sf(){if(Ba)return xo;Ba=1;const e=lo,t=of();function n(r){const i=Buffer.alloc(150);let o;try{o=e.openSync(r,"r"),e.readSync(o,i,0,150,0),e.closeSync(o)}catch{}return t(i.toString())}return a(n,"readShebang"),xo=n,xo}a(sf,"requireReadShebang");var $o,Sa;function af(){if(Sa)return $o;Sa=1;const e=Ve,t=tf(),n=nf(),r=sf(),s=process.platform==="win32",i=/\.(?:com|exe)$/i,o=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function u(d){d.file=t(d);const p=d.file&&r(d.file);return p?(d.args.unshift(d.file),d.command=p,t(d)):d.file}a(u,"detectShebang");function l(d){if(!s)return d;const p=u(d),h=!i.test(p);if(d.options.forceShell||h){const f=o.test(p);d.command=e.normalize(d.command),d.command=n.command(d.command),d.args=d.args.map(g=>n.argument(g,f));const D=[d.command].concat(d.args).join(" ");d.args=["/d","/s","/c",`"${D}"`],d.command=process.env.comspec||"cmd.exe",d.options.windowsVerbatimArguments=!0}return d}a(l,"parseNonShell");function c(d,p,h){p&&!Array.isArray(p)&&(h=p,p=null),p=p?p.slice(0):[],h=Object.assign({},h);const f={command:d,args:p,options:h,file:void 0,original:{command:d,args:p}};return h.shell?f:l(f)}return a(c,"parse"),$o=c,$o}a(af,"requireParse");var Io,Ta;function uf(){if(Ta)return Io;Ta=1;const e=process.platform==="win32";function t(i,o){return Object.assign(new Error(`${o} ${i.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${o} ${i.command}`,path:i.command,spawnargs:i.args})}a(t,"notFoundError");function n(i,o){if(!e)return;const u=i.emit;i.emit=function(l,c){if(l==="exit"){const d=r(c,o);if(d)return u.call(i,"error",d)}return u.apply(i,arguments)}}a(n,"hookChildProcess");function r(i,o){return e&&i===1&&!o.file?t(o.original,"spawn"):null}a(r,"verifyENOENT");function s(i,o){return e&&i===1&&!o.file?t(o.original,"spawnSync"):null}return a(s,"verifyENOENTSync"),Io={hookChildProcess:n,verifyENOENT:r,verifyENOENTSync:s,notFoundError:t},Io}a(uf,"requireEnoent");var Oa;function lf(){if(Oa)return _t.exports;Oa=1;const e=Bp,t=af(),n=uf();function r(i,o,u){const l=t(i,o,u),c=e.spawn(l.command,l.args,l.options);return n.hookChildProcess(c,l),c}a(r,"spawn");function s(i,o,u){const l=t(i,o,u),c=e.spawnSync(l.command,l.args,l.options);return c.error=c.error||n.verifyENOENTSync(c.status,l),c}return a(s,"spawnSync"),_t.exports=r,_t.exports.spawn=r,_t.exports.sync=s,_t.exports._parse=t,_t.exports._enoent=n,_t.exports}a(lf,"requireCrossSpawn");var cf=lf(),df=yt(cf);function pf(e){const t=typeof e=="string"?`
|
|
23
|
+
`:10,n=typeof e=="string"?"\r":13;return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}a(pf,"stripFinalNewline");function Ra(e={}){const{env:t=process.env,platform:n=process.platform}=e;return n!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"}a(Ra,"pathKey");const Df=a(({cwd:e=me.cwd(),path:t=me.env[Ra()],preferLocal:n=!0,execPath:r=me.execPath,addExecPath:s=!0}={})=>{const i=e instanceof URL?Ti(e):e,o=Nt.resolve(i),u=[];return n&&ff(u,o),s&&mf(u,r,o),[...u,t].join(Nt.delimiter)},"npmRunPath"),ff=a((e,t)=>{let n;for(;n!==t;)e.push(Nt.join(t,"node_modules/.bin")),n=t,t=Nt.resolve(t,"..")},"applyPreferLocal"),mf=a((e,t,n)=>{const r=t instanceof URL?Ti(t):t;e.push(Nt.resolve(n,r,".."))},"applyExecPath"),hf=a(({env:e=me.env,...t}={})=>{e={...e};const n=Ra({env:e});return t.path=e[n],e[n]=Df(t),e},"npmRunPathEnv"),gf=a((e,t,n,r)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;const s=Object.getOwnPropertyDescriptor(e,n),i=Object.getOwnPropertyDescriptor(t,n);!vf(s,i)&&r||Object.defineProperty(e,n,i)},"copyProperty"),vf=a(function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},"canCopyProperty"),yf=a((e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},"changePrototype"),_f=a((e,t)=>`/* Wrapped ${e}*/
|
|
24
|
+
${t}`,"wrappedToString"),Ff=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Ef=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Cf=a((e,t,n)=>{const r=n===""?"":`with ${n.trim()}() `,s=_f.bind(null,r,t.toString());Object.defineProperty(s,"name",Ef),Object.defineProperty(e,"toString",{...Ff,value:s})},"changeToString");function bf(e,t,{ignoreNonConfigurable:n=!1}={}){const{name:r}=e;for(const s of Reflect.ownKeys(t))gf(e,t,s,n);return yf(e,t),Cf(e,t,r),e}a(bf,"mimicFunction");const Er=new WeakMap,Pa=a((e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,r=0;const s=e.displayName||e.name||"<anonymous>",i=a(function(...o){if(Er.set(i,++r),r===1)n=e.apply(this,o),e=null;else if(t.throw===!0)throw new Error(`Function \`${s}\` can only be called once`);return n},"onetime2");return bf(i,e),Er.set(i,r),i},"onetime");Pa.callCount=e=>{if(!Er.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Er.get(e)};const wf=a(()=>{const e=Ma-Na+1;return Array.from({length:e},Af)},"getRealtimeSignals"),Af=a((e,t)=>({name:`SIGRT${t+1}`,number:Na+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),"getRealtimeSignal"),Na=34,Ma=64,kf=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],ja=a(()=>{const e=wf();return[...kf,...e].map(xf)},"getSignals"),xf=a(({name:e,number:t,description:n,action:r,forced:s=!1,standard:i})=>{const{signals:{[e]:o}}=Oi,u=o!==void 0;return{name:e,number:u?o:t,description:n,supported:u,action:r,forced:s,standard:i}},"normalizeSignal"),$f=a(()=>{const e=ja();return Object.fromEntries(e.map(If))},"getSignalsByName"),If=a(({name:e,number:t,description:n,supported:r,action:s,forced:i,standard:o})=>[e,{name:e,number:t,description:n,supported:r,action:s,forced:i,standard:o}],"getSignalByName"),Bf=$f(),Sf=a(()=>{const e=ja(),t=Ma+1,n=Array.from({length:t},(r,s)=>Tf(s,e));return Object.assign({},...n)},"getSignalsByNumber"),Tf=a((e,t)=>{const n=Of(e,t);if(n===void 0)return{};const{name:r,description:s,supported:i,action:o,forced:u,standard:l}=n;return{[e]:{name:r,number:e,description:s,supported:i,action:o,forced:u,standard:l}}},"getSignalByNumber"),Of=a((e,t)=>{const n=t.find(({name:r})=>Oi.signals[r]===e);return n!==void 0?n:t.find(r=>r.number===e)},"findSignalByNumber");Sf();const Rf=a(({timedOut:e,timeout:t,errorCode:n,signal:r,signalDescription:s,exitCode:i,isCanceled:o})=>e?`timed out after ${t} milliseconds`:o?"was canceled":n!==void 0?`failed with ${n}`:r!==void 0?`was killed with ${r} (${s})`:i!==void 0?`failed with exit code ${i}`:"failed","getErrorPrefix"),za=a(({stdout:e,stderr:t,all:n,error:r,signal:s,exitCode:i,command:o,escapedCommand:u,timedOut:l,isCanceled:c,killed:d,parsed:{options:{timeout:p,cwd:h=me.cwd()}}})=>{i=i===null?void 0:i,s=s===null?void 0:s;const f=s===void 0?void 0:Bf[s].description,D=r&&r.code,v=`Command ${Rf({timedOut:l,timeout:p,errorCode:D,signal:s,signalDescription:f,exitCode:i,isCanceled:c})}: ${o}`,F=Object.prototype.toString.call(r)==="[object Error]",C=F?`${v}
|
|
25
25
|
${r.message}`:v,_=[C,t,e].filter(Boolean).join(`
|
|
26
|
-
`);return F?(r.originalMessage=r.message,r.message=_):r=new Error(_),r.shortMessage=C,r.command=o,r.escapedCommand=u,r.exitCode=i,r.signal=s,r.signalDescription=f,r.stdout=e,r.stderr=t,r.cwd=h,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!l,r.isCanceled=c,r.killed=d&&!l,r},"makeError"),
|
|
27
|
-
`)},"logCommand"),Fm=1e3*1e3*100,Em=a(({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:s})=>{const i=t?{...fe.env,...e}:e;return n?ff({env:i,cwd:r,execPath:s}):i},"getEnv"),Cm=a((e,t,n={})=>{const r=lf._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:Fm,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||fe.cwd(),execPath:fe.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:vm,...n},n.env=Em(n),n.stdio=Rf(n),fe.platform==="win32"&&Tt.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},"handleArguments"),To=a((e,t,n)=>typeof t!="string"&&!kp.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?cf(t):t,"handleOutput");function Mn(e,t,n){const r=Cm(e,t,n),s=hm(e,t),i=gm(e,t);_m(i,r.options),Jf(r.options);let o;try{o=ki.spawn(r.file,r.args,r.options)}catch(f){const D=new ki.ChildProcess,g=Promise.reject(Na({error:f,stdout:"",stderr:"",all:"",command:s,escapedCommand:i,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return Ga(D,g),D}const u=pm(o),l=Hf(o,r.options,u),c=Kf(o,r.options,l),d={isCanceled:!1};o.kill=Zf.bind(null,o.kill.bind(o)),o.cancel=Gf.bind(null,o,d);const h=Ta(a(async()=>{const[{error:f,exitCode:D,signal:g,timedOut:v},F,C,_]=await lm(o,r.options,c),b=To(r.options,F),B=To(r.options,C),O=To(r.options,_);if(f||D!==0||g!==null){const S=Na({error:f,exitCode:D,signal:g,stdout:b,stderr:B,all:O,command:s,escapedCommand:i,parsed:r,timedOut:v,isCanceled:d.isCanceled||(r.options.signal?r.options.signal.aborted:!1),killed:o.killed});if(!r.options.reject)return S;throw S}return{command:s,escapedCommand:i,exitCode:0,stdout:b,stderr:B,all:O,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return am(o,r.options),o.all=um(o,r.options),Xf(o),Ga(o,h),o}a(Mn,"execa");let _t=!0;const Rt=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let jn=0;if(Rt.process&&Rt.process.env&&Rt.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:n,TERM:r,COLORTERM:s}=Rt.process.env;t||n||e==="0"?_t=!1:e==="1"||e==="2"||e==="3"?_t=!0:r==="dumb"?_t=!1:"CI"in Rt.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(i=>i in Rt.process.env)?_t=!0:_t=process.stdout.isTTY,_t&&(process.platform==="win32"||s&&(s==="truecolor"||s==="24bit")?jn=3:r&&(r.endsWith("-256color")||r.endsWith("256"))?jn=2:jn=1)}let Oo={enabled:_t,supportLevel:jn};function zn(e,t,n=1){const r=`\x1B[${e}m`,s=`\x1B[${t}m`,i=new RegExp(`\\x1b\\[${t}m`,"g");return o=>Oo.enabled&&Oo.supportLevel>=n?r+(""+o).replace(i,r)+s:""+o}a(zn,"kolorist");const Ro=zn(2,22),Po=zn(30,39),No=zn(31,39),Pt=zn(32,39),Mo=zn(46,49);var bm=Object.freeze({__proto__:null,bgCyan:Mo,black:Po,dim:Ro,green:Pt,options:Oo,red:No});const Zn={};Zn.write=async e=>{await navigator.clipboard.writeText(e)},Zn.read=async()=>navigator.clipboard.readText(),Zn.readSync=()=>{throw new Error("`.readSync()` is not supported in browsers!")},Zn.writeSync=()=>{throw new Error("`.writeSync()` is not supported in browsers!")};var jo,Ha;function wm(){if(Ha)return jo;Ha=1;const e="\x1B",t=`${e}[`,n="\x07",r={to(o,u){return u?`${t}${u+1};${o+1}H`:`${t}${o+1}G`},move(o,u){let l="";return o<0?l+=`${t}${-o}D`:o>0&&(l+=`${t}${o}C`),u<0?l+=`${t}${-u}A`:u>0&&(l+=`${t}${u}B`),l},up:a((o=1)=>`${t}${o}A`,"up"),down:a((o=1)=>`${t}${o}B`,"down"),forward:a((o=1)=>`${t}${o}C`,"forward"),backward:a((o=1)=>`${t}${o}D`,"backward"),nextLine:a((o=1)=>`${t}E`.repeat(o),"nextLine"),prevLine:a((o=1)=>`${t}F`.repeat(o),"prevLine"),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${e}7`,restore:`${e}8`},s={up:a((o=1)=>`${t}S`.repeat(o),"up"),down:a((o=1)=>`${t}T`.repeat(o),"down")},i={screen:`${t}2J`,up:a((o=1)=>`${t}1J`.repeat(o),"up"),down:a((o=1)=>`${t}J`.repeat(o),"down"),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(o){let u="";for(let l=0;l<o;l++)u+=this.line+(l<o-1?r.up():"");return o&&(u+=r.left),u}};return jo={cursor:r,scroll:s,erase:i,beep:n},jo}a(wm,"requireSrc");var Ie=wm(),Cr={exports:{}},Ja;function Am(){if(Ja)return Cr.exports;Ja=1;let e=process||{},t=e.argv||[],n=e.env||{},r=!(n.NO_COLOR||t.includes("--no-color"))&&(!!n.FORCE_COLOR||t.includes("--color")||e.platform==="win32"||(e.stdout||{}).isTTY&&n.TERM!=="dumb"||!!n.CI),s=a((u,l,c=u)=>d=>{let p=""+d,h=p.indexOf(l,u.length);return~h?u+i(p,l,c,h)+l:u+p+l},"formatter"),i=a((u,l,c,d)=>{let p="",h=0;do p+=u.substring(h,d)+c,h=d+l.length,d=u.indexOf(l,h);while(~d);return p+u.substring(h)},"replaceClose"),o=a((u=r)=>{let l=u?s:()=>String;return{isColorSupported:u,reset:l("\x1B[0m","\x1B[0m"),bold:l("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:l("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:l("\x1B[3m","\x1B[23m"),underline:l("\x1B[4m","\x1B[24m"),inverse:l("\x1B[7m","\x1B[27m"),hidden:l("\x1B[8m","\x1B[28m"),strikethrough:l("\x1B[9m","\x1B[29m"),black:l("\x1B[30m","\x1B[39m"),red:l("\x1B[31m","\x1B[39m"),green:l("\x1B[32m","\x1B[39m"),yellow:l("\x1B[33m","\x1B[39m"),blue:l("\x1B[34m","\x1B[39m"),magenta:l("\x1B[35m","\x1B[39m"),cyan:l("\x1B[36m","\x1B[39m"),white:l("\x1B[37m","\x1B[39m"),gray:l("\x1B[90m","\x1B[39m"),bgBlack:l("\x1B[40m","\x1B[49m"),bgRed:l("\x1B[41m","\x1B[49m"),bgGreen:l("\x1B[42m","\x1B[49m"),bgYellow:l("\x1B[43m","\x1B[49m"),bgBlue:l("\x1B[44m","\x1B[49m"),bgMagenta:l("\x1B[45m","\x1B[49m"),bgCyan:l("\x1B[46m","\x1B[49m"),bgWhite:l("\x1B[47m","\x1B[49m"),blackBright:l("\x1B[90m","\x1B[39m"),redBright:l("\x1B[91m","\x1B[39m"),greenBright:l("\x1B[92m","\x1B[39m"),yellowBright:l("\x1B[93m","\x1B[39m"),blueBright:l("\x1B[94m","\x1B[39m"),magentaBright:l("\x1B[95m","\x1B[39m"),cyanBright:l("\x1B[96m","\x1B[39m"),whiteBright:l("\x1B[97m","\x1B[39m"),bgBlackBright:l("\x1B[100m","\x1B[49m"),bgRedBright:l("\x1B[101m","\x1B[49m"),bgGreenBright:l("\x1B[102m","\x1B[49m"),bgYellowBright:l("\x1B[103m","\x1B[49m"),bgBlueBright:l("\x1B[104m","\x1B[49m"),bgMagentaBright:l("\x1B[105m","\x1B[49m"),bgCyanBright:l("\x1B[106m","\x1B[49m"),bgWhiteBright:l("\x1B[107m","\x1B[49m")}},"createColors");return Cr.exports=o(),Cr.exports.createColors=o,Cr.exports}a(Am,"requirePicocolors");var km=Am(),I=gt(km);function xm({onlyFirst:e=!1}={}){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}a(xm,"DD");const Im=xm();function Ka(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Im,"")}a(Ka,"P$1");function Ya(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}a(Ya,"L$1");var Xa={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(r){var s=r.charCodeAt(0),i=r.length==2?r.charCodeAt(1):0,o=s;return 55296<=s&&s<=56319&&56320<=i&&i<=57343&&(s&=1023,i&=1023,o=s<<10|i,o+=65536),o==12288||65281<=o&&o<=65376||65504<=o&&o<=65510?"F":o==8361||65377<=o&&o<=65470||65474<=o&&o<=65479||65482<=o&&o<=65487||65490<=o&&o<=65495||65498<=o&&o<=65500||65512<=o&&o<=65518?"H":4352<=o&&o<=4447||4515<=o&&o<=4519||4602<=o&&o<=4607||9001<=o&&o<=9002||11904<=o&&o<=11929||11931<=o&&o<=12019||12032<=o&&o<=12245||12272<=o&&o<=12283||12289<=o&&o<=12350||12353<=o&&o<=12438||12441<=o&&o<=12543||12549<=o&&o<=12589||12593<=o&&o<=12686||12688<=o&&o<=12730||12736<=o&&o<=12771||12784<=o&&o<=12830||12832<=o&&o<=12871||12880<=o&&o<=13054||13056<=o&&o<=19903||19968<=o&&o<=42124||42128<=o&&o<=42182||43360<=o&&o<=43388||44032<=o&&o<=55203||55216<=o&&o<=55238||55243<=o&&o<=55291||63744<=o&&o<=64255||65040<=o&&o<=65049||65072<=o&&o<=65106||65108<=o&&o<=65126||65128<=o&&o<=65131||110592<=o&&o<=110593||127488<=o&&o<=127490||127504<=o&&o<=127546||127552<=o&&o<=127560||127568<=o&&o<=127569||131072<=o&&o<=194367||177984<=o&&o<=196605||196608<=o&&o<=262141?"W":32<=o&&o<=126||162<=o&&o<=163||165<=o&&o<=166||o==172||o==175||10214<=o&&o<=10221||10629<=o&&o<=10630?"Na":o==161||o==164||167<=o&&o<=168||o==170||173<=o&&o<=174||176<=o&&o<=180||182<=o&&o<=186||188<=o&&o<=191||o==198||o==208||215<=o&&o<=216||222<=o&&o<=225||o==230||232<=o&&o<=234||236<=o&&o<=237||o==240||242<=o&&o<=243||247<=o&&o<=250||o==252||o==254||o==257||o==273||o==275||o==283||294<=o&&o<=295||o==299||305<=o&&o<=307||o==312||319<=o&&o<=322||o==324||328<=o&&o<=331||o==333||338<=o&&o<=339||358<=o&&o<=359||o==363||o==462||o==464||o==466||o==468||o==470||o==472||o==474||o==476||o==593||o==609||o==708||o==711||713<=o&&o<=715||o==717||o==720||728<=o&&o<=731||o==733||o==735||768<=o&&o<=879||913<=o&&o<=929||931<=o&&o<=937||945<=o&&o<=961||963<=o&&o<=969||o==1025||1040<=o&&o<=1103||o==1105||o==8208||8211<=o&&o<=8214||8216<=o&&o<=8217||8220<=o&&o<=8221||8224<=o&&o<=8226||8228<=o&&o<=8231||o==8240||8242<=o&&o<=8243||o==8245||o==8251||o==8254||o==8308||o==8319||8321<=o&&o<=8324||o==8364||o==8451||o==8453||o==8457||o==8467||o==8470||8481<=o&&o<=8482||o==8486||o==8491||8531<=o&&o<=8532||8539<=o&&o<=8542||8544<=o&&o<=8555||8560<=o&&o<=8569||o==8585||8592<=o&&o<=8601||8632<=o&&o<=8633||o==8658||o==8660||o==8679||o==8704||8706<=o&&o<=8707||8711<=o&&o<=8712||o==8715||o==8719||o==8721||o==8725||o==8730||8733<=o&&o<=8736||o==8739||o==8741||8743<=o&&o<=8748||o==8750||8756<=o&&o<=8759||8764<=o&&o<=8765||o==8776||o==8780||o==8786||8800<=o&&o<=8801||8804<=o&&o<=8807||8810<=o&&o<=8811||8814<=o&&o<=8815||8834<=o&&o<=8835||8838<=o&&o<=8839||o==8853||o==8857||o==8869||o==8895||o==8978||9312<=o&&o<=9449||9451<=o&&o<=9547||9552<=o&&o<=9587||9600<=o&&o<=9615||9618<=o&&o<=9621||9632<=o&&o<=9633||9635<=o&&o<=9641||9650<=o&&o<=9651||9654<=o&&o<=9655||9660<=o&&o<=9661||9664<=o&&o<=9665||9670<=o&&o<=9672||o==9675||9678<=o&&o<=9681||9698<=o&&o<=9701||o==9711||9733<=o&&o<=9734||o==9737||9742<=o&&o<=9743||9748<=o&&o<=9749||o==9756||o==9758||o==9792||o==9794||9824<=o&&o<=9825||9827<=o&&o<=9829||9831<=o&&o<=9834||9836<=o&&o<=9837||o==9839||9886<=o&&o<=9887||9918<=o&&o<=9919||9924<=o&&o<=9933||9935<=o&&o<=9953||o==9955||9960<=o&&o<=9983||o==10045||o==10071||10102<=o&&o<=10111||11093<=o&&o<=11097||12872<=o&&o<=12879||57344<=o&&o<=63743||65024<=o&&o<=65039||o==65533||127232<=o&&o<=127242||127248<=o&&o<=127277||127280<=o&&o<=127337||127344<=o&&o<=127386||917760<=o&&o<=917999||983040<=o&&o<=1048573||1048576<=o&&o<=1114109?"A":"N"},t.characterLength=function(r){var s=this.eastAsianWidth(r);return s=="F"||s=="W"||s=="A"?2:1};function n(r){return r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}a(n,"t"),t.length=function(r){for(var s=n(r),i=0,o=0;o<s.length;o++)i=i+this.characterLength(s[o]);return i},t.slice=function(r,s,i){textLen=t.length(r),s=s||0,i=i||1,s<0&&(s=textLen+s),i<0&&(i=textLen+i);for(var o="",u=0,l=n(r),c=0;c<l.length;c++){var d=l[c],p=t.length(d);if(u>=s-(p==2?1:0))if(u+p<=i)o+=d;else break;u+=p}return o}})(Xa);var $m=Xa.exports;const Bm=Ya($m);var Sm=a(function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},"FD");const Tm=Ya(Sm);function Ln(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Ka(e),e.length===0))return 0;e=e.replace(Tm()," ");const n=t.ambiguousIsNarrow?1:2;let r=0;for(const s of e){const i=s.codePointAt(0);if(!(i<=31||i>=127&&i<=159||i>=768&&i<=879))switch(Bm.eastAsianWidth(s)){case"F":case"W":r+=2;break;case"A":r+=n;break;default:r+=1}}return r}a(Ln,"p");const zo=10,Qa=a((e=0)=>t=>`\x1B[${t+e}m`,"N"),eu=a((e=0)=>t=>`\x1B[${38+e};5;${t}m`,"I"),tu=a((e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,"R"),ae={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(ae.modifier);const Om=Object.keys(ae.color),Rm=Object.keys(ae.bgColor);[...Om,...Rm];function Pm(){const e=new Map;for(const[t,n]of Object.entries(ae)){for(const[r,s]of Object.entries(n))ae[r]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[r]=ae[r],e.set(s[0],s[1]);Object.defineProperty(ae,t,{value:n,enumerable:!1})}return Object.defineProperty(ae,"codes",{value:e,enumerable:!1}),ae.color.close="\x1B[39m",ae.bgColor.close="\x1B[49m",ae.color.ansi=Qa(),ae.color.ansi256=eu(),ae.color.ansi16m=tu(),ae.bgColor.ansi=Qa(zo),ae.bgColor.ansi256=eu(zo),ae.bgColor.ansi16m=tu(zo),Object.defineProperties(ae,{rgbToAnsi256:{value:a((t,n,r)=>t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5),"value"),enumerable:!1},hexToRgb:{value:a(t=>{const n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[r]=n;r.length===3&&(r=[...r].map(i=>i+i).join(""));const s=Number.parseInt(r,16);return[s>>16&255,s>>8&255,s&255]},"value"),enumerable:!1},hexToAnsi256:{value:a(t=>ae.rgbToAnsi256(...ae.hexToRgb(t)),"value"),enumerable:!1},ansi256ToAnsi:{value:a(t=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,r,s;if(t>=232)n=((t-232)*10+8)/255,r=n,s=n;else{t-=16;const u=t%36;n=Math.floor(t/36)/5,r=Math.floor(u/6)/5,s=u%6/5}const i=Math.max(n,r,s)*2;if(i===0)return 30;let o=30+(Math.round(s)<<2|Math.round(r)<<1|Math.round(n));return i===2&&(o+=60),o},"value"),enumerable:!1},rgbToAnsi:{value:a((t,n,r)=>ae.ansi256ToAnsi(ae.rgbToAnsi256(t,n,r)),"value"),enumerable:!1},hexToAnsi:{value:a(t=>ae.ansi256ToAnsi(ae.hexToAnsi256(t)),"value"),enumerable:!1}}),ae}a(Pm,"rD");const Nm=Pm(),br=new Set(["\x1B","\x9B"]),Mm=39,Zo="\x07",nu="[",jm="]",ru="m",Lo=`${jm}8;;`,ou=a(e=>`${br.values().next().value}${nu}${e}${ru}`,"z"),su=a(e=>`${br.values().next().value}${Lo}${e}${Zo}`,"K"),zm=a(e=>e.split(" ").map(t=>Ln(t)),"aD"),Uo=a((e,t,n)=>{const r=[...t];let s=!1,i=!1,o=Ln(Ka(e[e.length-1]));for(const[u,l]of r.entries()){const c=Ln(l);if(o+c<=n?e[e.length-1]+=l:(e.push(l),o=0),br.has(l)&&(s=!0,i=r.slice(u+1).join("").startsWith(Lo)),s){i?l===Zo&&(s=!1,i=!1):l===ru&&(s=!1);continue}o+=c,o===n&&u<r.length-1&&(e.push(""),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},"k$1"),Zm=a(e=>{const t=e.split(" ");let n=t.length;for(;n>0&&!(Ln(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},"hD"),Lm=a((e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",s,i;const o=zm(e);let u=[""];for(const[c,d]of e.split(" ").entries()){n.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let p=Ln(u[u.length-1]);if(c!==0&&(p>=t&&(n.wordWrap===!1||n.trim===!1)&&(u.push(""),p=0),(p>0||n.trim===!1)&&(u[u.length-1]+=" ",p++)),n.hard&&o[c]>t){const h=t-p,f=1+Math.floor((o[c]-h-1)/t);Math.floor((o[c]-1)/t)<f&&u.push(""),Uo(u,d,t);continue}if(p+o[c]>t&&p>0&&o[c]>0){if(n.wordWrap===!1&&p<t){Uo(u,d,t);continue}u.push("")}if(p+o[c]>t&&n.wordWrap===!1){Uo(u,d,t);continue}u[u.length-1]+=d}n.trim!==!1&&(u=u.map(c=>Zm(c)));const l=[...u.join(`
|
|
28
|
-
`)];for(const[c,d]of l.entries()){if(r+=d,
|
|
29
|
-
`?(i&&(r+=
|
|
30
|
-
`&&(s&&p&&(r+=
|
|
26
|
+
`);return F?(r.originalMessage=r.message,r.message=_):r=new Error(_),r.shortMessage=C,r.command=o,r.escapedCommand=u,r.exitCode=i,r.signal=s,r.signalDescription=f,r.stdout=e,r.stderr=t,r.cwd=h,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!l,r.isCanceled=c,r.killed=d&&!l,r},"makeError"),Cr=["stdin","stdout","stderr"],Pf=a(e=>Cr.some(t=>e[t]!==void 0),"hasAlias"),Nf=a(e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Cr.map(r=>e[r]);if(Pf(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Cr.map(r=>`\`${r}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const n=Math.max(t.length,Cr.length);return Array.from({length:n},(r,s)=>t[s])},"normalizeStdio");var Ft={exports:{}},Bo={exports:{}},Za;function Mf(){return Za||(Za=1,(function(e){e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")})(Bo)),Bo.exports}a(Mf,"requireSignals");var La;function jf(){if(La)return Ft.exports;La=1;var e=ct.process;const t=a(function(v){return v&&typeof v=="object"&&typeof v.removeListener=="function"&&typeof v.emit=="function"&&typeof v.reallyExit=="function"&&typeof v.listeners=="function"&&typeof v.kill=="function"&&typeof v.pid=="number"&&typeof v.on=="function"},"processOk");if(!t(e))Ft.exports=function(){return function(){}};else{var n=Tp,r=Mf(),s=/^win/i.test(e.platform),i=Op;typeof i!="function"&&(i=i.EventEmitter);var o;e.__signal_exit_emitter__?o=e.__signal_exit_emitter__:(o=e.__signal_exit_emitter__=new i,o.count=0,o.emitted={}),o.infinite||(o.setMaxListeners(1/0),o.infinite=!0),Ft.exports=function(v,F){if(!t(ct.process))return function(){};n.equal(typeof v,"function","a callback must be provided for exit handler"),d===!1&&p();var C="exit";F&&F.alwaysLast&&(C="afterexit");var _=a(function(){o.removeListener(C,v),o.listeners("exit").length===0&&o.listeners("afterexit").length===0&&u()},"remove");return o.on(C,v),_};var u=a(function(){!d||!t(ct.process)||(d=!1,r.forEach(function(F){try{e.removeListener(F,c[F])}catch{}}),e.emit=D,e.reallyExit=h,o.count-=1)},"unload2");Ft.exports.unload=u;var l=a(function(F,C,_){o.emitted[F]||(o.emitted[F]=!0,o.emit(F,C,_))},"emit2"),c={};r.forEach(function(v){c[v]=a(function(){if(t(ct.process)){var C=e.listeners(v);C.length===o.count&&(u(),l("exit",null,v),l("afterexit",null,v),s&&v==="SIGHUP"&&(v="SIGINT"),e.kill(e.pid,v))}},"listener")}),Ft.exports.signals=function(){return r};var d=!1,p=a(function(){d||!t(ct.process)||(d=!0,o.count+=1,r=r.filter(function(F){try{return e.on(F,c[F]),!0}catch{return!1}}),e.emit=g,e.reallyExit=f)},"load2");Ft.exports.load=p;var h=e.reallyExit,f=a(function(F){t(ct.process)&&(e.exitCode=F||0,l("exit",e.exitCode,null),l("afterexit",e.exitCode,null),h.call(e,e.exitCode))},"processReallyExit2"),D=e.emit,g=a(function(F,C){if(F==="exit"&&t(ct.process)){C!==void 0&&(e.exitCode=C);var _=D.apply(this,arguments);return l("exit",e.exitCode,null),l("afterexit",e.exitCode,null),_}else return D.apply(this,arguments)},"processEmit2")}return Ft.exports}a(jf,"requireSignalExit");var zf=jf(),Zf=yt(zf);const Lf=1e3*5,Uf=a((e,t="SIGTERM",n={})=>{const r=e(t);return qf(e,t,n,r),r},"spawnedKill"),qf=a((e,t,n,r)=>{if(!Vf(t,n,r))return;const s=Wf(n),i=setTimeout(()=>{e("SIGKILL")},s);i.unref&&i.unref()},"setKillTimeout"),Vf=a((e,{forceKillAfterTimeout:t},n)=>Gf(e)&&t!==!1&&n,"shouldForceKill"),Gf=a(e=>e===Sp.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM","isSigterm"),Wf=a(({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Lf;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},"getForceKillAfterTimeout"),Hf=a((e,t)=>{e.kill()&&(t.isCanceled=!0)},"spawnedCancel"),Jf=a((e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},"timeoutKill"),Kf=a((e,{timeout:t,killSignal:n="SIGTERM"},r)=>{if(t===0||t===void 0)return r;let s;const i=new Promise((u,l)=>{s=setTimeout(()=>{Jf(e,n,l)},t)}),o=r.finally(()=>{clearTimeout(s)});return Promise.race([i,o])},"setupTimeout"),Yf=a(({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},"validateTimeout"),Xf=a(async(e,{cleanup:t,detached:n},r)=>{if(!t||n)return r;const s=Zf(()=>{e.kill()});return r.finally(()=>{s()})},"setExitHandler");function Ua(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}a(Ua,"isStream");function qa(e){return Ua(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}a(qa,"isWritableStream");const Qf=a(e=>e instanceof Ip&&typeof e.then=="function","isExecaChildProcess"),So=a((e,t,n)=>{if(typeof n=="string")return e[t].pipe(Rp(n)),e;if(qa(n))return e[t].pipe(n),e;if(!Qf(n))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!qa(n.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(n.stdin),n},"pipeToTarget"),em=a(e=>{e.stdout!==null&&(e.pipeStdout=So.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=So.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=So.bind(void 0,e,"all"))},"addPipeMethods");var jt={exports:{}},To,Va;function tm(){if(Va)return To;Va=1;const{PassThrough:e}=co;return To=a(t=>{t={...t};const{array:n}=t;let{encoding:r}=t;const s=r==="buffer";let i=!1;n?i=!(r||s):r=r||"utf8",s&&(r=null);const o=new e({objectMode:i});r&&o.setEncoding(r);let u=0;const l=[];return o.on("data",c=>{l.push(c),i?u=l.length:u+=c.length}),o.getBufferedValue=()=>n?l:s?Buffer.concat(l,u):l.join(""),o.getBufferedLength=()=>u,o},"bufferStream"),To}a(tm,"requireBufferStream");var Ga;function nm(){if(Ga)return jt.exports;Ga=1;const{constants:e}=Np,t=co,{promisify:n}=Mp,r=tm(),s=n(t.pipeline),u=class u extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}};a(u,"MaxBufferError");let i=u;async function o(l,c){if(!l)throw new Error("Expected a stream");c={maxBuffer:1/0,...c};const{maxBuffer:d}=c,p=r(c);return await new Promise((h,f)=>{const D=a(g=>{g&&p.getBufferedLength()<=e.MAX_LENGTH&&(g.bufferedData=p.getBufferedValue()),f(g)},"rejectPromise");(async()=>{try{await s(l,p),h()}catch(g){D(g)}})(),p.on("data",()=>{p.getBufferedLength()>d&&D(new i)})}),p.getBufferedValue()}return a(o,"getStream"),jt.exports=o,jt.exports.buffer=(l,c)=>o(l,{...c,encoding:"buffer"}),jt.exports.array=(l,c)=>o(l,{...c,array:!0}),jt.exports.MaxBufferError=i,jt.exports}a(nm,"requireGetStream");var rm=nm(),Wa=yt(rm),Oo,Ha;function om(){if(Ha)return Oo;Ha=1;const{PassThrough:e}=co;return Oo=a(function(){var t=[],n=new e({objectMode:!0});return n.setMaxListeners(0),n.add=r,n.isEmpty=s,n.on("unpipe",i),Array.prototype.slice.call(arguments).forEach(r),n;function r(o){return Array.isArray(o)?(o.forEach(r),this):(t.push(o),o.once("end",i.bind(null,o)),o.once("error",n.emit.bind(n,"error")),o.pipe(n,{end:!1}),this)}a(r,"add");function s(){return t.length==0}a(s,"isEmpty");function i(o){t=t.filter(function(u){return u!==o}),!t.length&&n.readable&&n.end()}a(i,"remove")},"mergeStream$1"),Oo}a(om,"requireMergeStream");var sm=om(),im=yt(sm);const am=a(e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},"validateInputOptions"),um=a(({input:e,inputFile:t})=>typeof t!="string"?e:(am(e),Pp(t)),"getInput"),lm=a((e,t)=>{const n=um(t);n!==void 0&&(Ua(n)?n.pipe(e.stdin):e.stdin.end(n))},"handleInput"),cm=a((e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const n=im();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},"makeAllStream"),Ro=a(async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(n){return n.bufferedData}}},"getBufferedData"),Po=a((e,{encoding:t,buffer:n,maxBuffer:r})=>{if(!(!e||!n))return t?Wa(e,{encoding:t,maxBuffer:r}):Wa.buffer(e,{maxBuffer:r})},"getStreamPromise"),dm=a(async({stdout:e,stderr:t,all:n},{encoding:r,buffer:s,maxBuffer:i},o)=>{const u=Po(e,{encoding:r,buffer:s,maxBuffer:i}),l=Po(t,{encoding:r,buffer:s,maxBuffer:i}),c=Po(n,{encoding:r,buffer:s,maxBuffer:i*2});try{return await Promise.all([o,u,l,c])}catch(d){return Promise.all([{error:d,signal:d.signal,timedOut:d.timedOut},Ro(e,u),Ro(t,l),Ro(n,c)])}},"getSpawnedResult"),pm=(async()=>{})().constructor.prototype,Dm=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(pm,e)]),Ja=a((e,t)=>{for(const[n,r]of Dm){const s=typeof t=="function"?(...i)=>Reflect.apply(r.value,t(),i):r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:s})}},"mergePromise"),fm=a(e=>new Promise((t,n)=>{e.on("exit",(r,s)=>{t({exitCode:r,signal:s})}),e.on("error",r=>{n(r)}),e.stdin&&e.stdin.on("error",r=>{n(r)})}),"getSpawnedPromise"),Ka=a((e,t=[])=>Array.isArray(t)?[e,...t]:[e],"normalizeArgs"),mm=/^[\w.-]+$/,hm=/"/g,gm=a(e=>typeof e!="string"||mm.test(e)?e:`"${e.replace(hm,'\\"')}"`,"escapeArg"),vm=a((e,t)=>Ka(e,t).join(" "),"joinCommand"),ym=a((e,t)=>Ka(e,t).map(n=>gm(n)).join(" "),"getEscapedCommand"),_m=jp("execa").enabled,br=a((e,t)=>String(e).padStart(t,"0"),"padField"),Fm=a(()=>{const e=new Date;return`${br(e.getHours(),2)}:${br(e.getMinutes(),2)}:${br(e.getSeconds(),2)}.${br(e.getMilliseconds(),3)}`},"getTimestamp"),Em=a((e,{verbose:t})=>{t&&me.stderr.write(`[${Fm()}] ${e}
|
|
27
|
+
`)},"logCommand"),Cm=1e3*1e3*100,bm=a(({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:s})=>{const i=t?{...me.env,...e}:e;return n?hf({env:i,cwd:r,execPath:s}):i},"getEnv"),wm=a((e,t,n={})=>{const r=df._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:Cm,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||me.cwd(),execPath:me.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:_m,...n},n.env=bm(n),n.stdio=Nf(n),me.platform==="win32"&&Nt.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},"handleArguments"),No=a((e,t,n)=>typeof t!="string"&&!$p.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?pf(t):t,"handleOutput");function Ge(e,t,n){const r=wm(e,t,n),s=vm(e,t),i=ym(e,t);Em(i,r.options),Yf(r.options);let o;try{o=Ii.spawn(r.file,r.args,r.options)}catch(f){const D=new Ii.ChildProcess,g=Promise.reject(za({error:f,stdout:"",stderr:"",all:"",command:s,escapedCommand:i,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return Ja(D,g),D}const u=fm(o),l=Kf(o,r.options,u),c=Xf(o,r.options,l),d={isCanceled:!1};o.kill=Uf.bind(null,o.kill.bind(o)),o.cancel=Hf.bind(null,o,d);const h=Pa(a(async()=>{const[{error:f,exitCode:D,signal:g,timedOut:v},F,C,_]=await dm(o,r.options,c),b=No(r.options,F),B=No(r.options,C),O=No(r.options,_);if(f||D!==0||g!==null){const S=za({error:f,exitCode:D,signal:g,stdout:b,stderr:B,all:O,command:s,escapedCommand:i,parsed:r,timedOut:v,isCanceled:d.isCanceled||(r.options.signal?r.options.signal.aborted:!1),killed:o.killed});if(!r.options.reject)return S;throw S}return{command:s,escapedCommand:i,exitCode:0,stdout:b,stderr:B,all:O,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return lm(o,r.options),o.all=cm(o,r.options),em(o),Ja(o,h),o}a(Ge,"execa");let Et=!0;const zt=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let Zn=0;if(zt.process&&zt.process.env&&zt.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:n,TERM:r,COLORTERM:s}=zt.process.env;t||n||e==="0"?Et=!1:e==="1"||e==="2"||e==="3"?Et=!0:r==="dumb"?Et=!1:"CI"in zt.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(i=>i in zt.process.env)?Et=!0:Et=process.stdout.isTTY,Et&&(process.platform==="win32"||s&&(s==="truecolor"||s==="24bit")?Zn=3:r&&(r.endsWith("-256color")||r.endsWith("256"))?Zn=2:Zn=1)}let Mo={enabled:Et,supportLevel:Zn};function Ln(e,t,n=1){const r=`\x1B[${e}m`,s=`\x1B[${t}m`,i=new RegExp(`\\x1b\\[${t}m`,"g");return o=>Mo.enabled&&Mo.supportLevel>=n?r+(""+o).replace(i,r)+s:""+o}a(Ln,"kolorist");const jo=Ln(2,22),wr=Ln(30,39),zo=Ln(31,39),Qe=Ln(32,39),Ar=Ln(46,49);var Am=Object.freeze({__proto__:null,bgCyan:Ar,black:wr,dim:jo,green:Qe,options:Mo,red:zo});const Un={};Un.write=async e=>{await navigator.clipboard.writeText(e)},Un.read=async()=>navigator.clipboard.readText(),Un.readSync=()=>{throw new Error("`.readSync()` is not supported in browsers!")},Un.writeSync=()=>{throw new Error("`.writeSync()` is not supported in browsers!")};var Zo,Ya;function km(){if(Ya)return Zo;Ya=1;const e="\x1B",t=`${e}[`,n="\x07",r={to(o,u){return u?`${t}${u+1};${o+1}H`:`${t}${o+1}G`},move(o,u){let l="";return o<0?l+=`${t}${-o}D`:o>0&&(l+=`${t}${o}C`),u<0?l+=`${t}${-u}A`:u>0&&(l+=`${t}${u}B`),l},up:a((o=1)=>`${t}${o}A`,"up"),down:a((o=1)=>`${t}${o}B`,"down"),forward:a((o=1)=>`${t}${o}C`,"forward"),backward:a((o=1)=>`${t}${o}D`,"backward"),nextLine:a((o=1)=>`${t}E`.repeat(o),"nextLine"),prevLine:a((o=1)=>`${t}F`.repeat(o),"prevLine"),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${e}7`,restore:`${e}8`},s={up:a((o=1)=>`${t}S`.repeat(o),"up"),down:a((o=1)=>`${t}T`.repeat(o),"down")},i={screen:`${t}2J`,up:a((o=1)=>`${t}1J`.repeat(o),"up"),down:a((o=1)=>`${t}J`.repeat(o),"down"),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(o){let u="";for(let l=0;l<o;l++)u+=this.line+(l<o-1?r.up():"");return o&&(u+=r.left),u}};return Zo={cursor:r,scroll:s,erase:i,beep:n},Zo}a(km,"requireSrc");var $e=km(),kr={exports:{}},Xa;function xm(){if(Xa)return kr.exports;Xa=1;let e=process||{},t=e.argv||[],n=e.env||{},r=!(n.NO_COLOR||t.includes("--no-color"))&&(!!n.FORCE_COLOR||t.includes("--color")||e.platform==="win32"||(e.stdout||{}).isTTY&&n.TERM!=="dumb"||!!n.CI),s=a((u,l,c=u)=>d=>{let p=""+d,h=p.indexOf(l,u.length);return~h?u+i(p,l,c,h)+l:u+p+l},"formatter"),i=a((u,l,c,d)=>{let p="",h=0;do p+=u.substring(h,d)+c,h=d+l.length,d=u.indexOf(l,h);while(~d);return p+u.substring(h)},"replaceClose"),o=a((u=r)=>{let l=u?s:()=>String;return{isColorSupported:u,reset:l("\x1B[0m","\x1B[0m"),bold:l("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:l("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:l("\x1B[3m","\x1B[23m"),underline:l("\x1B[4m","\x1B[24m"),inverse:l("\x1B[7m","\x1B[27m"),hidden:l("\x1B[8m","\x1B[28m"),strikethrough:l("\x1B[9m","\x1B[29m"),black:l("\x1B[30m","\x1B[39m"),red:l("\x1B[31m","\x1B[39m"),green:l("\x1B[32m","\x1B[39m"),yellow:l("\x1B[33m","\x1B[39m"),blue:l("\x1B[34m","\x1B[39m"),magenta:l("\x1B[35m","\x1B[39m"),cyan:l("\x1B[36m","\x1B[39m"),white:l("\x1B[37m","\x1B[39m"),gray:l("\x1B[90m","\x1B[39m"),bgBlack:l("\x1B[40m","\x1B[49m"),bgRed:l("\x1B[41m","\x1B[49m"),bgGreen:l("\x1B[42m","\x1B[49m"),bgYellow:l("\x1B[43m","\x1B[49m"),bgBlue:l("\x1B[44m","\x1B[49m"),bgMagenta:l("\x1B[45m","\x1B[49m"),bgCyan:l("\x1B[46m","\x1B[49m"),bgWhite:l("\x1B[47m","\x1B[49m"),blackBright:l("\x1B[90m","\x1B[39m"),redBright:l("\x1B[91m","\x1B[39m"),greenBright:l("\x1B[92m","\x1B[39m"),yellowBright:l("\x1B[93m","\x1B[39m"),blueBright:l("\x1B[94m","\x1B[39m"),magentaBright:l("\x1B[95m","\x1B[39m"),cyanBright:l("\x1B[96m","\x1B[39m"),whiteBright:l("\x1B[97m","\x1B[39m"),bgBlackBright:l("\x1B[100m","\x1B[49m"),bgRedBright:l("\x1B[101m","\x1B[49m"),bgGreenBright:l("\x1B[102m","\x1B[49m"),bgYellowBright:l("\x1B[103m","\x1B[49m"),bgBlueBright:l("\x1B[104m","\x1B[49m"),bgMagentaBright:l("\x1B[105m","\x1B[49m"),bgCyanBright:l("\x1B[106m","\x1B[49m"),bgWhiteBright:l("\x1B[107m","\x1B[49m")}},"createColors");return kr.exports=o(),kr.exports.createColors=o,kr.exports}a(xm,"requirePicocolors");var $m=xm(),I=yt($m);function Im({onlyFirst:e=!1}={}){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}a(Im,"DD");const Bm=Im();function Qa(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Bm,"")}a(Qa,"P$1");function eu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}a(eu,"L$1");var tu={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(r){var s=r.charCodeAt(0),i=r.length==2?r.charCodeAt(1):0,o=s;return 55296<=s&&s<=56319&&56320<=i&&i<=57343&&(s&=1023,i&=1023,o=s<<10|i,o+=65536),o==12288||65281<=o&&o<=65376||65504<=o&&o<=65510?"F":o==8361||65377<=o&&o<=65470||65474<=o&&o<=65479||65482<=o&&o<=65487||65490<=o&&o<=65495||65498<=o&&o<=65500||65512<=o&&o<=65518?"H":4352<=o&&o<=4447||4515<=o&&o<=4519||4602<=o&&o<=4607||9001<=o&&o<=9002||11904<=o&&o<=11929||11931<=o&&o<=12019||12032<=o&&o<=12245||12272<=o&&o<=12283||12289<=o&&o<=12350||12353<=o&&o<=12438||12441<=o&&o<=12543||12549<=o&&o<=12589||12593<=o&&o<=12686||12688<=o&&o<=12730||12736<=o&&o<=12771||12784<=o&&o<=12830||12832<=o&&o<=12871||12880<=o&&o<=13054||13056<=o&&o<=19903||19968<=o&&o<=42124||42128<=o&&o<=42182||43360<=o&&o<=43388||44032<=o&&o<=55203||55216<=o&&o<=55238||55243<=o&&o<=55291||63744<=o&&o<=64255||65040<=o&&o<=65049||65072<=o&&o<=65106||65108<=o&&o<=65126||65128<=o&&o<=65131||110592<=o&&o<=110593||127488<=o&&o<=127490||127504<=o&&o<=127546||127552<=o&&o<=127560||127568<=o&&o<=127569||131072<=o&&o<=194367||177984<=o&&o<=196605||196608<=o&&o<=262141?"W":32<=o&&o<=126||162<=o&&o<=163||165<=o&&o<=166||o==172||o==175||10214<=o&&o<=10221||10629<=o&&o<=10630?"Na":o==161||o==164||167<=o&&o<=168||o==170||173<=o&&o<=174||176<=o&&o<=180||182<=o&&o<=186||188<=o&&o<=191||o==198||o==208||215<=o&&o<=216||222<=o&&o<=225||o==230||232<=o&&o<=234||236<=o&&o<=237||o==240||242<=o&&o<=243||247<=o&&o<=250||o==252||o==254||o==257||o==273||o==275||o==283||294<=o&&o<=295||o==299||305<=o&&o<=307||o==312||319<=o&&o<=322||o==324||328<=o&&o<=331||o==333||338<=o&&o<=339||358<=o&&o<=359||o==363||o==462||o==464||o==466||o==468||o==470||o==472||o==474||o==476||o==593||o==609||o==708||o==711||713<=o&&o<=715||o==717||o==720||728<=o&&o<=731||o==733||o==735||768<=o&&o<=879||913<=o&&o<=929||931<=o&&o<=937||945<=o&&o<=961||963<=o&&o<=969||o==1025||1040<=o&&o<=1103||o==1105||o==8208||8211<=o&&o<=8214||8216<=o&&o<=8217||8220<=o&&o<=8221||8224<=o&&o<=8226||8228<=o&&o<=8231||o==8240||8242<=o&&o<=8243||o==8245||o==8251||o==8254||o==8308||o==8319||8321<=o&&o<=8324||o==8364||o==8451||o==8453||o==8457||o==8467||o==8470||8481<=o&&o<=8482||o==8486||o==8491||8531<=o&&o<=8532||8539<=o&&o<=8542||8544<=o&&o<=8555||8560<=o&&o<=8569||o==8585||8592<=o&&o<=8601||8632<=o&&o<=8633||o==8658||o==8660||o==8679||o==8704||8706<=o&&o<=8707||8711<=o&&o<=8712||o==8715||o==8719||o==8721||o==8725||o==8730||8733<=o&&o<=8736||o==8739||o==8741||8743<=o&&o<=8748||o==8750||8756<=o&&o<=8759||8764<=o&&o<=8765||o==8776||o==8780||o==8786||8800<=o&&o<=8801||8804<=o&&o<=8807||8810<=o&&o<=8811||8814<=o&&o<=8815||8834<=o&&o<=8835||8838<=o&&o<=8839||o==8853||o==8857||o==8869||o==8895||o==8978||9312<=o&&o<=9449||9451<=o&&o<=9547||9552<=o&&o<=9587||9600<=o&&o<=9615||9618<=o&&o<=9621||9632<=o&&o<=9633||9635<=o&&o<=9641||9650<=o&&o<=9651||9654<=o&&o<=9655||9660<=o&&o<=9661||9664<=o&&o<=9665||9670<=o&&o<=9672||o==9675||9678<=o&&o<=9681||9698<=o&&o<=9701||o==9711||9733<=o&&o<=9734||o==9737||9742<=o&&o<=9743||9748<=o&&o<=9749||o==9756||o==9758||o==9792||o==9794||9824<=o&&o<=9825||9827<=o&&o<=9829||9831<=o&&o<=9834||9836<=o&&o<=9837||o==9839||9886<=o&&o<=9887||9918<=o&&o<=9919||9924<=o&&o<=9933||9935<=o&&o<=9953||o==9955||9960<=o&&o<=9983||o==10045||o==10071||10102<=o&&o<=10111||11093<=o&&o<=11097||12872<=o&&o<=12879||57344<=o&&o<=63743||65024<=o&&o<=65039||o==65533||127232<=o&&o<=127242||127248<=o&&o<=127277||127280<=o&&o<=127337||127344<=o&&o<=127386||917760<=o&&o<=917999||983040<=o&&o<=1048573||1048576<=o&&o<=1114109?"A":"N"},t.characterLength=function(r){var s=this.eastAsianWidth(r);return s=="F"||s=="W"||s=="A"?2:1};function n(r){return r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}a(n,"t"),t.length=function(r){for(var s=n(r),i=0,o=0;o<s.length;o++)i=i+this.characterLength(s[o]);return i},t.slice=function(r,s,i){textLen=t.length(r),s=s||0,i=i||1,s<0&&(s=textLen+s),i<0&&(i=textLen+i);for(var o="",u=0,l=n(r),c=0;c<l.length;c++){var d=l[c],p=t.length(d);if(u>=s-(p==2?1:0))if(u+p<=i)o+=d;else break;u+=p}return o}})(tu);var Sm=tu.exports;const Tm=eu(Sm);var Om=a(function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},"FD");const Rm=eu(Om);function qn(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Qa(e),e.length===0))return 0;e=e.replace(Rm()," ");const n=t.ambiguousIsNarrow?1:2;let r=0;for(const s of e){const i=s.codePointAt(0);if(!(i<=31||i>=127&&i<=159||i>=768&&i<=879))switch(Tm.eastAsianWidth(s)){case"F":case"W":r+=2;break;case"A":r+=n;break;default:r+=1}}return r}a(qn,"p");const Lo=10,nu=a((e=0)=>t=>`\x1B[${t+e}m`,"N"),ru=a((e=0)=>t=>`\x1B[${38+e};5;${t}m`,"I"),ou=a((e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,"R"),ue={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(ue.modifier);const Pm=Object.keys(ue.color),Nm=Object.keys(ue.bgColor);[...Pm,...Nm];function Mm(){const e=new Map;for(const[t,n]of Object.entries(ue)){for(const[r,s]of Object.entries(n))ue[r]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[r]=ue[r],e.set(s[0],s[1]);Object.defineProperty(ue,t,{value:n,enumerable:!1})}return Object.defineProperty(ue,"codes",{value:e,enumerable:!1}),ue.color.close="\x1B[39m",ue.bgColor.close="\x1B[49m",ue.color.ansi=nu(),ue.color.ansi256=ru(),ue.color.ansi16m=ou(),ue.bgColor.ansi=nu(Lo),ue.bgColor.ansi256=ru(Lo),ue.bgColor.ansi16m=ou(Lo),Object.defineProperties(ue,{rgbToAnsi256:{value:a((t,n,r)=>t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5),"value"),enumerable:!1},hexToRgb:{value:a(t=>{const n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[r]=n;r.length===3&&(r=[...r].map(i=>i+i).join(""));const s=Number.parseInt(r,16);return[s>>16&255,s>>8&255,s&255]},"value"),enumerable:!1},hexToAnsi256:{value:a(t=>ue.rgbToAnsi256(...ue.hexToRgb(t)),"value"),enumerable:!1},ansi256ToAnsi:{value:a(t=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,r,s;if(t>=232)n=((t-232)*10+8)/255,r=n,s=n;else{t-=16;const u=t%36;n=Math.floor(t/36)/5,r=Math.floor(u/6)/5,s=u%6/5}const i=Math.max(n,r,s)*2;if(i===0)return 30;let o=30+(Math.round(s)<<2|Math.round(r)<<1|Math.round(n));return i===2&&(o+=60),o},"value"),enumerable:!1},rgbToAnsi:{value:a((t,n,r)=>ue.ansi256ToAnsi(ue.rgbToAnsi256(t,n,r)),"value"),enumerable:!1},hexToAnsi:{value:a(t=>ue.ansi256ToAnsi(ue.hexToAnsi256(t)),"value"),enumerable:!1}}),ue}a(Mm,"rD");const jm=Mm(),xr=new Set(["\x1B","\x9B"]),zm=39,Uo="\x07",su="[",Zm="]",iu="m",qo=`${Zm}8;;`,au=a(e=>`${xr.values().next().value}${su}${e}${iu}`,"z"),uu=a(e=>`${xr.values().next().value}${qo}${e}${Uo}`,"K"),Lm=a(e=>e.split(" ").map(t=>qn(t)),"aD"),Vo=a((e,t,n)=>{const r=[...t];let s=!1,i=!1,o=qn(Qa(e[e.length-1]));for(const[u,l]of r.entries()){const c=qn(l);if(o+c<=n?e[e.length-1]+=l:(e.push(l),o=0),xr.has(l)&&(s=!0,i=r.slice(u+1).join("").startsWith(qo)),s){i?l===Uo&&(s=!1,i=!1):l===iu&&(s=!1);continue}o+=c,o===n&&u<r.length-1&&(e.push(""),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},"k$1"),Um=a(e=>{const t=e.split(" ");let n=t.length;for(;n>0&&!(qn(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},"hD"),qm=a((e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",s,i;const o=Lm(e);let u=[""];for(const[c,d]of e.split(" ").entries()){n.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let p=qn(u[u.length-1]);if(c!==0&&(p>=t&&(n.wordWrap===!1||n.trim===!1)&&(u.push(""),p=0),(p>0||n.trim===!1)&&(u[u.length-1]+=" ",p++)),n.hard&&o[c]>t){const h=t-p,f=1+Math.floor((o[c]-h-1)/t);Math.floor((o[c]-1)/t)<f&&u.push(""),Vo(u,d,t);continue}if(p+o[c]>t&&p>0&&o[c]>0){if(n.wordWrap===!1&&p<t){Vo(u,d,t);continue}u.push("")}if(p+o[c]>t&&n.wordWrap===!1){Vo(u,d,t);continue}u[u.length-1]+=d}n.trim!==!1&&(u=u.map(c=>Um(c)));const l=[...u.join(`
|
|
28
|
+
`)];for(const[c,d]of l.entries()){if(r+=d,xr.has(d)){const{groups:h}=new RegExp(`(?:\\${su}(?<code>\\d+)m|\\${qo}(?<uri>.*)${Uo})`).exec(l.slice(c).join(""))||{groups:{}};if(h.code!==void 0){const f=Number.parseFloat(h.code);s=f===zm?void 0:f}else h.uri!==void 0&&(i=h.uri.length===0?void 0:h.uri)}const p=jm.codes.get(Number(s));l[c+1]===`
|
|
29
|
+
`?(i&&(r+=uu("")),s&&p&&(r+=au(p))):d===`
|
|
30
|
+
`&&(s&&p&&(r+=au(s)),i&&(r+=uu(i)))}return r},"lD");function lu(e,t,n){return String(e).normalize().replace(/\r\n/g,`
|
|
31
31
|
`).split(`
|
|
32
|
-
`).map(r=>
|
|
33
|
-
`)}a(
|
|
32
|
+
`).map(r=>qm(r,t,n)).join(`
|
|
33
|
+
`)}a(lu,"Y$1");const Vm=["up","down","left","right","space","enter","cancel"],$r={actions:new Set(Vm),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};function Go(e,t){if(typeof e=="string")return $r.aliases.get(e)===t;for(const n of e)if(n!==void 0&&Go(n,t))return!0;return!1}a(Go,"$");function Gm(e,t){if(e===t)return;const n=e.split(`
|
|
34
34
|
`),r=t.split(`
|
|
35
|
-
`),s=[];for(let i=0;i<Math.max(n.length,r.length);i++)n[i]!==r[i]&&s.push(i);return s}a(
|
|
36
|
-
`),
|
|
37
|
-
`).length-1;this.output.write(
|
|
38
|
-
`);this.output.write(s[r]),this._prevFrame=t,this.output.write(
|
|
35
|
+
`),s=[];for(let i=0;i<Math.max(n.length,r.length);i++)n[i]!==r[i]&&s.push(i);return s}a(Gm,"BD");const Wm=globalThis.process.platform.startsWith("win"),Wo=Symbol("clack:cancel");function Vn(e){return e===Wo}a(Vn,"pD");function Ir(e,t){const n=e;n.isTTY&&n.setRawMode(t)}a(Ir,"m");function Hm({input:e=Bi,output:t=Si,overwrite:n=!0,hideCursor:r=!0}={}){const s=fr.createInterface({input:e,output:t,prompt:"",tabSize:1});fr.emitKeypressEvents(e,s),e.isTTY&&e.setRawMode(!0);const i=a((o,{name:u,sequence:l})=>{const c=String(o);if(Go([c,u,l],"cancel")){r&&t.write($e.cursor.show),process.exit(0);return}if(!n)return;const d=u==="return"?0:-1,p=u==="return"?-1:0;fr.moveCursor(t,d,p,()=>{fr.clearLine(t,1,()=>{e.once("keypress",i)})})},"i");return r&&t.write($e.cursor.hide),e.once("keypress",i),()=>{e.off("keypress",i),r&&t.write($e.cursor.show),e.isTTY&&!Wm&&e.setRawMode(!1),s.terminal=!1,s.close()}}a(Hm,"fD");var Jm=Object.defineProperty,Km=a((e,t,n)=>t in e?Jm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"vD"),Pe=a((e,t,n)=>(Km(e,typeof t!="symbol"?t+"":t,n),n),"h");const oi=class oi{constructor(t,n=!0){Pe(this,"input"),Pe(this,"output"),Pe(this,"_abortSignal"),Pe(this,"rl"),Pe(this,"opts"),Pe(this,"_render"),Pe(this,"_track",!1),Pe(this,"_prevFrame",""),Pe(this,"_subscribers",new Map),Pe(this,"_cursor",0),Pe(this,"state","initial"),Pe(this,"error",""),Pe(this,"value");const{input:r=Bi,output:s=Si,render:i,signal:o,...u}=t;this.opts=u,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=n,this._abortSignal=o,this.input=r,this.output=s}unsubscribe(){this._subscribers.clear()}setSubscriber(t,n){const r=this._subscribers.get(t)??[];r.push(n),this._subscribers.set(t,r)}on(t,n){this.setSubscriber(t,{cb:n})}once(t,n){this.setSubscriber(t,{cb:n,once:!0})}emit(t,...n){const r=this._subscribers.get(t)??[],s=[];for(const i of r)i.cb(...n),i.once&&s.push(()=>r.splice(r.indexOf(i),1));for(const i of s)i()}prompt(){return new Promise((t,n)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(Wo);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}const r=new zp;r._write=(s,i,o)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),o()},this.input.pipe(r),this.rl=Ri.createInterface({input:this.input,output:r,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),Ri.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),Ir(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write($e.cursor.show),this.output.off("resize",this.render),Ir(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write($e.cursor.show),this.output.off("resize",this.render),Ir(this.input,!1),t(Wo)})})}onKeypress(t,n){if(this.state==="error"&&(this.state="active"),n?.name&&(!this._track&&$r.aliases.has(n.name)&&this.emit("cursor",$r.aliases.get(n.name)),$r.actions.has(n.name)&&this.emit("cursor",n.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),t===" "&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),t&&this.emit("key",t.toLowerCase()),n?.name==="return"){if(this.opts.validate){const r=this.opts.validate(this.value);r&&(this.error=r instanceof Error?r.message:r,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}Go([t,n?.name,n?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
36
|
+
`),Ir(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const t=lu(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
37
|
+
`).length-1;this.output.write($e.cursor.move(-999,t*-1))}render(){const t=lu(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write($e.cursor.hide);else{const n=Gm(this._prevFrame,t);if(this.restoreCursor(),n&&n?.length===1){const r=n[0];this.output.write($e.cursor.move(0,r)),this.output.write($e.erase.lines(1));const s=t.split(`
|
|
38
|
+
`);this.output.write(s[r]),this._prevFrame=t,this.output.write($e.cursor.move(0,s.length-r-1));return}if(n&&n?.length>1){const r=n[0];this.output.write($e.cursor.move(0,r)),this.output.write($e.erase.down());const s=t.split(`
|
|
39
39
|
`).slice(r);this.output.write(s.join(`
|
|
40
|
-
`)),this._prevFrame=t;return}this.output.write(
|
|
41
|
-
${
|
|
40
|
+
`)),this._prevFrame=t;return}this.output.write($e.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}};a(oi,"x");let Zt=oi;const si=class si extends Zt{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",n=>{this.output.write($e.cursor.move(0,-1)),this.value=n,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};a(si,"dD");let Ho=si;var Ym=Object.defineProperty,Xm=a((e,t,n)=>t in e?Ym(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"jD"),cu=a((e,t,n)=>(Xm(e,typeof t!="symbol"?t+"":t,n),n),"U");const ii=class ii extends Zt{constructor({mask:t,...n}){super(n),cu(this,"valueWithCursor",""),cu(this,"_mask","\u2022"),this._mask=t??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${I.inverse(I.hidden("_"))}`;else{const r=this.masked.slice(0,this.cursor),s=this.masked.slice(this.cursor);this.valueWithCursor=`${r}${I.inverse(s[0])}${s.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};a(ii,"MD");let Jo=ii;var Qm=Object.defineProperty,eh=a((e,t,n)=>t in e?Qm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"PD"),du=a((e,t,n)=>(eh(e,typeof t!="symbol"?t+"":t,n),n),"J");const ai=class ai extends Zt{constructor(t){super(t,!1),du(this,"options"),du(this,"cursor",0),this.options=t.options,this.cursor=this.options.findIndex(({value:n})=>n===t.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};a(ai,"LD");let Ko=ai;const ui=class ui extends Zt{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;const t=this.value.slice(0,this.cursor),[n,...r]=this.value.slice(this.cursor);return`${t}${I.inverse(n)}${r.join("")}`}get cursor(){return this._cursor}constructor(t){super(t),this.on("finalize",()=>{this.value||(this.value=t.defaultValue)})}};a(ui,"RD");let Yo=ui;function th(){return me.platform!=="win32"?me.env.TERM!=="linux":!!me.env.CI||!!me.env.WT_SESSION||!!me.env.TERMINUS_SUBLIME||me.env.ConEmuTask==="{cmd::Cmder}"||me.env.TERM_PROGRAM==="Terminus-Sublime"||me.env.TERM_PROGRAM==="vscode"||me.env.TERM==="xterm-256color"||me.env.TERM==="alacritty"||me.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}a(th,"ce");const Xo=th(),et=a((e,t)=>Xo?e:t,"u"),nh=et("\u25C6","*"),pu=et("\u25A0","x"),Du=et("\u25B2","x"),fu=et("\u25C7","o"),rh=et("\u250C","T"),ee=et("\u2502","|"),Ct=et("\u2514","\u2014"),Qo=et("\u25CF",">"),es=et("\u25CB"," "),oh=et("\u25AA","\u2022"),Br=a(e=>{switch(e){case"initial":case"active":return I.cyan(nh);case"cancel":return I.red(pu);case"error":return I.yellow(Du);case"submit":return I.green(fu)}},"b"),sh=a(e=>{const{cursor:t,options:n,style:r}=e,s=e.maxItems??Number.POSITIVE_INFINITY,i=Math.max(process.stdout.rows-4,0),o=Math.min(i,Math.max(s,5));let u=0;t>=u+o-3?u=Math.max(Math.min(t-o+3,n.length-o),0):t<u+2&&(u=Math.max(t-2,0));const l=o<n.length&&u>0,c=o<n.length&&u+o<n.length;return n.slice(u,u+o).map((d,p,h)=>{const f=p===0&&l,D=p===h.length-1&&c;return f||D?I.dim("..."):r(d,p+u===t)})},"G"),mu=a(e=>new Yo({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){const t=`${I.gray(ee)}
|
|
41
|
+
${Br(this.state)} ${e.message}
|
|
42
42
|
`,n=e.placeholder?I.inverse(e.placeholder[0])+I.dim(e.placeholder.slice(1)):I.inverse(I.hidden("_")),r=this.value?this.valueWithCursor:n;switch(this.state){case"error":return`${t.trim()}
|
|
43
|
-
${I.yellow(
|
|
44
|
-
${I.yellow(
|
|
45
|
-
`;case"submit":return`${t}${I.gray(
|
|
46
|
-
${I.gray(
|
|
47
|
-
${I.cyan(
|
|
48
|
-
`}}}).prompt(),"he"),
|
|
49
|
-
${
|
|
43
|
+
${I.yellow(ee)} ${r}
|
|
44
|
+
${I.yellow(Ct)} ${I.yellow(this.error)}
|
|
45
|
+
`;case"submit":return`${t}${I.gray(ee)} ${I.dim(this.value||e.placeholder)}`;case"cancel":return`${t}${I.gray(ee)} ${I.strikethrough(I.dim(this.value??""))}${this.value?.trim()?`
|
|
46
|
+
${I.gray(ee)}`:""}`;default:return`${t}${I.cyan(ee)} ${r}
|
|
47
|
+
${I.cyan(Ct)}
|
|
48
|
+
`}}}).prompt(),"he"),ih=a(e=>new Jo({validate:e.validate,mask:e.mask??oh,render(){const t=`${I.gray(ee)}
|
|
49
|
+
${Br(this.state)} ${e.message}
|
|
50
50
|
`,n=this.valueWithCursor,r=this.masked;switch(this.state){case"error":return`${t.trim()}
|
|
51
|
-
${I.yellow(
|
|
52
|
-
${I.yellow(
|
|
53
|
-
`;case"submit":return`${t}${I.gray(
|
|
54
|
-
${I.gray(
|
|
55
|
-
${I.cyan(
|
|
56
|
-
`}}}).prompt(),"ge"),
|
|
57
|
-
${
|
|
58
|
-
`,s=this.value?t:n;switch(this.state){case"submit":return`${r}${I.gray(
|
|
59
|
-
${I.gray(
|
|
60
|
-
${I.cyan(
|
|
61
|
-
`}}}).prompt()},"ye"),
|
|
62
|
-
${
|
|
63
|
-
`;switch(this.state){case"submit":return`${n}${I.gray(
|
|
64
|
-
${I.gray(
|
|
65
|
-
${I.cyan(
|
|
66
|
-
${I.cyan(
|
|
67
|
-
`}}}).prompt()},"ve"),
|
|
68
|
-
`)},"Ie"),
|
|
69
|
-
${I.gray(
|
|
70
|
-
|
|
71
|
-
`)},"Se");`${I.gray(
|
|
51
|
+
${I.yellow(ee)} ${r}
|
|
52
|
+
${I.yellow(Ct)} ${I.yellow(this.error)}
|
|
53
|
+
`;case"submit":return`${t}${I.gray(ee)} ${I.dim(r)}`;case"cancel":return`${t}${I.gray(ee)} ${I.strikethrough(I.dim(r??""))}${r?`
|
|
54
|
+
${I.gray(ee)}`:""}`;default:return`${t}${I.cyan(ee)} ${n}
|
|
55
|
+
${I.cyan(Ct)}
|
|
56
|
+
`}}}).prompt(),"ge"),ah=a(e=>{const t=e.active??"Yes",n=e.inactive??"No";return new Ho({active:t,inactive:n,initialValue:e.initialValue??!0,render(){const r=`${I.gray(ee)}
|
|
57
|
+
${Br(this.state)} ${e.message}
|
|
58
|
+
`,s=this.value?t:n;switch(this.state){case"submit":return`${r}${I.gray(ee)} ${I.dim(s)}`;case"cancel":return`${r}${I.gray(ee)} ${I.strikethrough(I.dim(s))}
|
|
59
|
+
${I.gray(ee)}`;default:return`${r}${I.cyan(ee)} ${this.value?`${I.green(Qo)} ${t}`:`${I.dim(es)} ${I.dim(t)}`} ${I.dim("/")} ${this.value?`${I.dim(es)} ${I.dim(n)}`:`${I.green(Qo)} ${n}`}
|
|
60
|
+
${I.cyan(Ct)}
|
|
61
|
+
`}}}).prompt()},"ye"),hu=a(e=>{const t=a((n,r)=>{const s=n.label??String(n.value);switch(r){case"selected":return`${I.dim(s)}`;case"active":return`${I.green(Qo)} ${s} ${n.hint?I.dim(`(${n.hint})`):""}`;case"cancelled":return`${I.strikethrough(I.dim(s))}`;default:return`${I.dim(es)} ${I.dim(s)}`}},"n");return new Ko({options:e.options,initialValue:e.initialValue,render(){const n=`${I.gray(ee)}
|
|
62
|
+
${Br(this.state)} ${e.message}
|
|
63
|
+
`;switch(this.state){case"submit":return`${n}${I.gray(ee)} ${t(this.options[this.cursor],"selected")}`;case"cancel":return`${n}${I.gray(ee)} ${t(this.options[this.cursor],"cancelled")}
|
|
64
|
+
${I.gray(ee)}`;default:return`${n}${I.cyan(ee)} ${sh({cursor:this.cursor,options:this.options,maxItems:e.maxItems,style:a((r,s)=>t(r,s?"active":"inactive"),"style")}).join(`
|
|
65
|
+
${I.cyan(ee)} `)}
|
|
66
|
+
${I.cyan(Ct)}
|
|
67
|
+
`}}}).prompt()},"ve"),Sr=a((e="")=>{process.stdout.write(`${I.gray(rh)} ${e}
|
|
68
|
+
`)},"Ie"),he=a((e="")=>{process.stdout.write(`${I.gray(ee)}
|
|
69
|
+
${I.gray(Ct)} ${e}
|
|
70
|
+
|
|
71
|
+
`)},"Se");`${I.gray(ee)}`;const bt=a(({indicator:e="dots"}={})=>{const t=Xo?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=Xo?80:120,r=process.env.CI==="true";let s,i,o=!1,u="",l,c=performance.now();const d=a(b=>{const B=b>1?"Something went wrong":"Canceled";o&&_(B,b)},"p"),p=a(()=>d(2),"v"),h=a(()=>d(1),"f"),f=a(()=>{process.on("uncaughtExceptionMonitor",p),process.on("unhandledRejection",p),process.on("SIGINT",h),process.on("SIGTERM",h),process.on("exit",d)},"j"),D=a(()=>{process.removeListener("uncaughtExceptionMonitor",p),process.removeListener("unhandledRejection",p),process.removeListener("SIGINT",h),process.removeListener("SIGTERM",h),process.removeListener("exit",d)},"E"),g=a(()=>{if(l===void 0)return;r&&process.stdout.write(`
|
|
72
72
|
`);const b=l.split(`
|
|
73
|
-
`);process.stdout.write(
|
|
74
|
-
`);let B=0,O=0;f(),i=setInterval(()=>{if(r&&u===l)return;g(),l=u;const S=I.magenta(t[B]);if(r)process.stdout.write(`${S} ${u}...`);else if(e==="timer")process.stdout.write(`${S} ${u} ${F(c)}`);else{const
|
|
73
|
+
`);process.stdout.write($e.cursor.move(-999,b.length-1)),process.stdout.write($e.erase.down(b.length))},"B"),v=a(b=>b.replace(/\.+$/,""),"R"),F=a(b=>{const B=(performance.now()-b)/1e3,O=Math.floor(B/60),S=Math.floor(B%60);return O>0?`[${O}m ${S}s]`:`[${S}s]`},"O"),C=a((b="")=>{o=!0,s=Hm(),u=v(b),c=performance.now(),process.stdout.write(`${I.gray(ee)}
|
|
74
|
+
`);let B=0,O=0;f(),i=setInterval(()=>{if(r&&u===l)return;g(),l=u;const S=I.magenta(t[B]);if(r)process.stdout.write(`${S} ${u}...`);else if(e==="timer")process.stdout.write(`${S} ${u} ${F(c)}`);else{const x=".".repeat(Math.floor(O)).slice(0,3);process.stdout.write(`${S} ${u}${x}`)}B=B+1<t.length?B+1:0,O=O<t.length?O+.125:0},n)},"H"),_=a((b="",B=0)=>{o=!1,clearInterval(i),g();const O=B===0?I.green(fu):B===1?I.red(pu):I.red(Du);u=v(b??u),e==="timer"?process.stdout.write(`${O} ${u} ${F(c)}
|
|
75
75
|
`):process.stdout.write(`${O} ${u}
|
|
76
|
-
`),D(),s()},"N");return{start:C,stop:_,message:a((b="")=>{u=v(b??u)},"message")}},"Y");var
|
|
76
|
+
`),D(),s()},"N");return{start:C,stop:_,message:a((b="")=>{u=v(b??u)},"message")}},"Y");var Gn=Object.freeze({__proto__:null,confirm:ah,intro:Sr,isCancel:Vn,outro:he,password:ih,select:hu,spinner:bt,text:mu});const{version:uh}=_o,li=class li extends Error{};a(li,"KnownError");let K=li;const ts=" ",gu=a(e=>{e instanceof Error&&!(e instanceof K)&&(e.stack&&console.error(jo(e.stack.split(`
|
|
77
77
|
`).slice(1).join(`
|
|
78
78
|
`))),console.error(`
|
|
79
|
-
${
|
|
80
|
-
${
|
|
81
|
-
`),
|
|
82
|
-
`),diff:r}},"getStagedDiff"),
|
|
79
|
+
${ts}${jo(`aicommits v${uh}`)}`),console.error(`
|
|
80
|
+
${ts}Please open a Bug report with the information above:`),console.error(`${ts}https://github.com/Nutlope/aicommits/issues/new/choose`))},"handleCliError"),Tr=a(e=>{process.stderr.write(`${zo("\u2716")} ${e.message}
|
|
81
|
+
`),gu(e),process.exit(1)},"handleCommandError"),ns=a(async()=>{const{stdout:e,failed:t}=await Ge("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new K("The current directory must be a Git repository!");return e},"assertGitRepo"),rs=a(e=>`:(exclude)${e}`,"excludeFromDiff"),vu=["package-lock.json","pnpm-lock.yaml","*.lock"].map(rs),yu=a(async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:n}=await Ge("git",[...t,"--name-only",...vu,...e?e.map(rs):[]]);if(!n)return;const{stdout:r}=await Ge("git",[...t,...vu,...e?e.map(rs):[]]);return{files:n.split(`
|
|
82
|
+
`),diff:r}},"getStagedDiff"),_u=a(e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`,"getDetectedMessage");var os,Fu;function lh(){if(Fu)return os;Fu=1;const{hasOwnProperty:e}=Object.prototype,t=typeof process<"u"&&process.platform==="win32"?`\r
|
|
83
83
|
`:`
|
|
84
|
-
`,n=a((l,c)=>{const d=[];let p="";typeof c=="string"?c={section:c,whitespace:!1}:(c=c||Object.create(null),c.whitespace=c.whitespace===!0);const h=c.whitespace?" = ":"=";for(const f of Object.keys(l)){const D=l[f];if(D&&Array.isArray(D))for(const g of D)p+=o(f+"[]")+h+o(g)+t;else D&&typeof D=="object"?d.push(f):p+=o(f)+h+o(D)+t}c.section&&p.length&&(p="["+o(c.section)+"]"+t+p);for(const f of d){const D=r(f).join("\\."),g=(c.section?c.section+".":"")+D,{whitespace:v}=c,F=n(l[f],{section:g,whitespace:v});p.length&&F.length&&(p+=t),p+=F}return p},"encode"),r=a(l=>l.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(c=>c.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),"dotSplit"),s=a(l=>{const c=Object.create(null);let d=c,p=null;const h=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,f=l.split(/[\r\n]+/g);for(const g of f){if(!g||g.match(/^\s*[;#]/))continue;const v=g.match(h);if(!v)continue;if(v[1]!==void 0){if(p=u(v[1]),p==="__proto__"){d=Object.create(null);continue}d=c[p]=c[p]||Object.create(null);continue}const F=u(v[2]),C=F.length>2&&F.slice(-2)==="[]",_=C?F.slice(0,-2):F;if(_==="__proto__")continue;const b=v[3]?u(v[4]):!0,B=b==="true"||b==="false"||b==="null"?JSON.parse(b):b;C&&(e.call(d,_)?Array.isArray(d[_])||(d[_]=[d[_]]):d[_]=[]),Array.isArray(d[_])?d[_].push(B):d[_]=B}const D=[];for(const g of Object.keys(c)){if(!e.call(c,g)||typeof c[g]!="object"||Array.isArray(c[g]))continue;const v=r(g);d=c;const F=v.pop(),C=F.replace(/\\\./g,".");for(const _ of v)_!=="__proto__"&&((!e.call(d,_)||typeof d[_]!="object")&&(d[_]=Object.create(null)),d=d[_]);d===c&&C===F||(d[C]=c[g],D.push(g))}for(const g of D)delete c[g];return c},"decode"),i=a(l=>l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"),"isQuoted"),o=a(l=>typeof l!="string"||l.match(/[=\r\n]/)||l.match(/^\[/)||l.length>1&&i(l)||l!==l.trim()?JSON.stringify(l):l.split(";").join("\\;").split("#").join("\\#"),"safe"),u=a((l,c)=>{if(l=(l||"").trim(),i(l)){l.charAt(0)==="'"&&(l=l.slice(1,-1));try{l=JSON.parse(l)}catch{}}else{let d=!1,p="";for(let h=0,f=l.length;h<f;h++){const D=l.charAt(h);if(d)"\\;#".indexOf(D)!==-1?p+=D:p+="\\"+D,d=!1;else{if(";#".indexOf(D)!==-1)break;D==="\\"?d=!0:p+=D}}return d&&(p+="\\"),p.trim()}return l},"unsafe");return rs={parse:s,decode:s,stringify:n,encode:n,safe:o,unsafe:u},rs}a(ah,"requireIni");var uh=ah(),_u=gt(uh);const os=a(e=>be.lstat(e).then(()=>!0,()=>!1),"fileExists"),lh=["","conventional","gitmoji"],{hasOwnProperty:ch}=Object.prototype,Fu=a((e,t)=>ch.call(e,t),"hasOwn"),Qe=a((e,t,n)=>{if(!t)throw new me(`Invalid config property ${e}: ${n}`)},"parseAssert"),$r={OPENAI_API_KEY(e){return e},OPENAI_BASE_URL(e){return e},OPENAI_MODEL(e){return e||""},locale(e){return e?(Qe("locale",!!e,"Cannot be empty"),Qe("locale",/^[a-z-]+$/i.test(e),"Must be a valid locale (letters and dashes/underscores)."),e):"en"},generate(e){if(!e)return 1;Qe("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return Qe("generate",t>0,"Must be greater than 0"),Qe("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(Qe("type",lh.includes(e),"Invalid commit type"),e):""},proxy(e){if(!(!e||e.length===0))throw new me('The "proxy" config property is deprecated and no longer supported.')},timeout(e){if(!e)return;Qe("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return Qe("timeout",t>=500,"Must be greater than 500ms"),t},"max-length"(e){if(!e)return 72;Qe("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return Qe("max-length",t>=20,"Must be greater than 20 characters"),t}},dh={name:"togetherai",displayName:"Together AI (recommended)",baseUrl:"https://api.together.xyz/v1",apiKeyFormat:"tgp_",modelsFilter:a(e=>e.filter(t=>!t.type||t.type==="chat"||t.type==="language").map(t=>t.id),"modelsFilter"),defaultModel:"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",requiresApiKey:!0},ph={name:"openai",displayName:"OpenAI",baseUrl:"https://api.openai.com/v1",apiKeyFormat:"sk-",modelsFilter:a(e=>e.filter(t=>t.id&&(t.id.includes("gpt")||t.id.includes("o1")||t.id.includes("o3")||t.id.includes("o4")||t.id.includes("o5")||!t.type||t.type==="chat")).map(t=>t.id),"modelsFilter"),defaultModel:"gpt-4o-mini",requiresApiKey:!0},Dh={name:"ollama",displayName:"Ollama (local)",baseUrl:"http://localhost:11434/v1",modelsFilter:a(e=>e.filter(t=>t.name).map(t=>t.name),"modelsFilter"),defaultModel:"llama2",requiresApiKey:!1},fh={name:"custom",displayName:"Custom (OpenAI-compatible)",baseUrl:"",modelsFilter:a(e=>e.filter(t=>!t.type||t.type==="chat"||t.type==="language").map(t=>t.id),"modelsFilter"),defaultModel:"",requiresApiKey:!0},mh={name:"openrouter",displayName:"OpenRouter",baseUrl:"https://openrouter.ai/api/v1",apiKeyFormat:"sk-or-v1-",modelsFilter:a(e=>e.filter(t=>t.id&&(!t.type||t.type==="chat")).map(t=>t.id),"modelsFilter"),defaultModel:"x-ai/grok-4.1-fast:free",requiresApiKey:!0},qn=[dh,ph,Dh,mh,fh],hh=a(()=>qn.find(t=>t.name==="openai")?.baseUrl||"","getDefaultBaseUrl"),gh=a((e,t)=>{if(e){const n=qn.find(r=>r.baseUrl===e||r.name==="ollama"&&e.startsWith(r.baseUrl.slice(0,-3)));return n?n.name:"custom"}else if(t)return"openai"},"detectProvider"),ss=a(()=>Ve.join(Ti.homedir(),".aicommits"),"getConfigPath"),Eu=a(async()=>{if(!await os(ss()))return Object.create(null);const t=await be.readFile(ss(),"utf8");return _u.parse(t)},"readConfigFile"),Mt=a(async(e,t,n)=>{const r=await Eu(),s={},{env:i}=process,o=t??{OPENAI_API_KEY:i.OPENAI_API_KEY||i.OPENAI_KEY,OPENAI_BASE_URL:i.OPENAI_BASE_URL,OPENAI_MODEL:i.OPENAI_MODEL};for(const d of Object.keys($r)){const p=$r[d],h=e?.[d]??o?.[d]??r[d];if(n)try{s[d]=p(h)}catch{}else s[d]=p(h)}let u,l=s.OPENAI_BASE_URL;const c=s.OPENAI_API_KEY;return!l&&c&&(l=hh(),s.OPENAI_BASE_URL=l),u=gh(l,c),{...s,model:s.OPENAI_MODEL,provider:u}},"getConfig"),is=a(async e=>{const t=await Eu();for(const[n,r]of e){if(!Fu($r,n))throw new me(`Invalid config property: ${n}`);if(r==="")delete t[n];else{const s=$r[n](r);t[n]=s}}await be.writeFile(ss(),_u.stringify(t),"utf8")},"setConfigs"),Cu=a(e=>`[${e} - \u2705]`,"CURRENT_LABEL_FORMAT"),vh=3600*1e3,bu=a(()=>{const e=process.platform,t=Ti.homedir();if(e==="darwin")return Ve.join(t,"Library","Caches","aicommits","models");if(e==="win32")return Ve.join(t,"AppData","Local","aicommits","models");{const n=process.env.XDG_CACHE_HOME,r=n||Ve.join(t,".cache");return Ve.join(r,"aicommits","models")}},"getCacheDir"),yh=a(e=>{const t=jp.createHash("sha256");return t.update(e),t.digest("hex")},"getCacheKey"),wu=a(e=>Ve.join(bu(),`${e}.json`),"getCachePath"),_h=a(async e=>{const t=wu(e);try{if(!await os(t))return null;const n=await be.readFile(t,"utf8");return JSON.parse(n)}catch{return null}},"readCache"),Fh=a(async(e,t)=>{try{const n=bu();await be.mkdir(n,{recursive:!0});const r=wu(e);await be.writeFile(r,JSON.stringify(t),"utf8")}catch{}},"writeCache"),as=a(async(e,t)=>{const n=yh(e),r=Date.now(),s=await _h(n);if(s&&r-s.timestamp<vh)return s.data;try{const i=await fetch(`${e}/models`,{headers:{Authorization:`Bearer ${t}`}});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const o=await i.json(),u=(o.data?o.data:o)||[],l={models:u};return u.length>0&&await Fh(n,{data:l,timestamp:r}),l}catch(i){const o=i instanceof Error?i.message:"Request failed";return{models:[],error:o}}},"fetchModels"),Eh=a(async(e,t,n)=>{const r=await as(e,t);r.error&&console.error(`Failed to fetch models: ${r.error}`);let s=[];return n?.modelsFilter?s=n.modelsFilter(r.models):s=r.models.map(i=>i.id||i.name).filter(Boolean),s},"fetchAndFilterModels"),Ch=a((e,t,n)=>{let r=e.map(s=>({label:s,value:s}));if(t&&t!=="undefined"){const s=r.findIndex(i=>i.value===t);if(s>=0){if(r[s].label=Cu(r[s].value),s>0){const[i]=r.splice(s,1);r.unshift(i)}}else r.unshift({label:Cu(t),value:t})}return r},"prepareModelOptions"),bh=a(async(e,t,n,r)=>{const s=await n({message:"Enter search term for models:",placeholder:"e.g., gpt, llama"});if(r(s))return null;let i=e;s&&(i=e.filter(l=>l.toLowerCase().includes(s.toLowerCase())));let o=i.slice(0,20).map(l=>({label:l,value:l}));const u=await t({message:`Choose your model (filtered by "${s}"):`,options:[...o,{label:"Custom model name...",value:"custom"}]});return r(u)?null:u},"handleSearch"),wh=a(async e=>{const t=await e({message:"Enter your custom model name:",validate:a(n=>{if(!n)return"Model name is required"},"validate")});return Ar(t)?null:t},"handleCustom"),Au=a(async(e,t,n,r)=>{(!n||n==="undefined")&&(n=r?.defaultModel);const s=Un();s.start("Fetching available models...");const i=await Eh(e,t,r);s.stop();let o=null;if(i.length>0){const{select:u,text:l,isCancel:c}=await Promise.resolve().then(function(){return Ir});let d=Ch(i,n),p=await u({message:"Choose your model:",options:[{label:"\u{1F50D} Search models...",value:"search"},...d,{label:"Custom model name...",value:"custom"}],initialValue:d.length>0?d[0].value:void 0});if(c(p))return null;if(p==="search"){const h=await bh(i,u,l,c);if(h===null)return null;p=h}if(p==="custom"){if(o=await wh(l),o===null)return null}else o=p}else{console.log("Could not fetch available models. Please specify a model name manually.");const{text:u}=await Promise.resolve().then(function(){return Ir});try{o=await u({message:"Enter your model name:",validate:a(c=>{if(!c)return"Model name is required"},"validate")})}catch{return null}}return o},"selectModel");var Ah=Object.freeze({__proto__:null,fetchModels:as,selectModel:Au}),kh=Object.defineProperty,xh=a((e,t,n)=>t in e?kh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"__defNormalProp"),ku=a((e,t,n)=>xh(e,typeof t!="symbol"?t+"":t,n),"__publicField");const ai=class ai{constructor(t,n){ku(this,"config"),ku(this,"def"),this.def=t,this.config=n}get name(){return this.def.name}get displayName(){return this.def.displayName}getDefinition(){return this.def}async setup(){const{text:t,password:n}=await Promise.resolve().then(function(){return Ir}),r=[];if(this.def.requiresApiKey){const s=this.getApiKey(),i=await n({message:s?`Enter your API key (leave empty to keep current: ${s.substring(0,4)}****):`:"Enter your API key:",validate:a(o=>{if(!o&&!s)return"API key is required";if(o&&this.def.apiKeyFormat&&!o.startsWith(this.def.apiKeyFormat))return`Invalid API key format, must start with "${this.def.apiKeyFormat}"`},"validate")});i&&r.push(["OPENAI_API_KEY",i])}if(this.name==="ollama"){const s=this.getBaseUrl(),i=await t({message:"Enter Ollama endpoint (leave empty for default):",placeholder:s});i&&i!=="http://localhost:11434/v1"&&r.push(["OPENAI_BASE_URL",i])}return r}async getModels(){const t=this.getBaseUrl(),n=this.getApiKey()||"",r=await as(t,n);if(r.error)return{models:[],error:r.error};let s;return this.def.modelsFilter?s=this.def.modelsFilter(r.models):s=r.models.map(i=>i.id||i.name).filter(Boolean),{models:s}}getApiKey(){return this.def.requiresApiKey?this.config.OPENAI_API_KEY:void 0}getBaseUrl(){return this.name==="custom"?this.config.OPENAI_BASE_URL||"":this.def.baseUrl}getDefaultModel(){return this.def.defaultModel}validateConfig(){const t=[];return this.def.requiresApiKey&&!this.getApiKey()&&t.push(`${this.displayName} API key is required`),this.name==="custom"&&!this.getBaseUrl()&&t.push("Custom endpoint is required"),{valid:t.length===0,errors:t}}};a(ai,"Provider");let us=ai;function Vn(e){const t=e.provider,n=qn.find(r=>r.name===t);return n?new us(n,e):null}a(Vn,"getProvider");function Ih(){return qn.map(e=>({value:e.name,label:e.displayName}))}a(Ih,"getAvailableProviders");function $h(e){return qn.find(n=>n.name===e)?.baseUrl||""}a($h,"getProviderBaseUrl");var xu="vercel.ai.error",Bh=Symbol.for(xu),Iu,Sh=(It=class extends Error{constructor({name:t,message:n,cause:r}){super(n),this[Iu]=!0,this.name=t,this.cause=r}static isInstance(t){return It.hasMarker(t,xu)}static hasMarker(t,n){const r=Symbol.for(n);return t!=null&&typeof t=="object"&&r in t&&typeof t[r]=="boolean"&&t[r]===!0}},a(It,"_AISDKError2"),It);Iu=Bh;var N=Sh,$u="AI_APICallError",Bu=`vercel.ai.error.${$u}`,Th=Symbol.for(Bu),Su,Ce=(Gt=class extends N{constructor({message:t,url:n,requestBodyValues:r,statusCode:s,responseHeaders:i,responseBody:o,cause:u,isRetryable:l=s!=null&&(s===408||s===409||s===429||s>=500),data:c}){super({name:$u,message:t,cause:u}),this[Su]=!0,this.url=n,this.requestBodyValues=r,this.statusCode=s,this.responseHeaders=i,this.responseBody=o,this.isRetryable=l,this.data=c}static isInstance(t){return N.hasMarker(t,Bu)}},a(Gt,"APICallError"),Gt);Su=Th;var Tu="AI_EmptyResponseBodyError",Ou=`vercel.ai.error.${Tu}`,Oh=Symbol.for(Ou),Ru,Rh=(Wt=class extends N{constructor({message:t="Empty response body"}={}){super({name:Tu,message:t}),this[Ru]=!0}static isInstance(t){return N.hasMarker(t,Ou)}},a(Wt,"EmptyResponseBodyError"),Wt);Ru=Oh;function Gn(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}a(Gn,"getErrorMessage$1");var Pu="AI_InvalidArgumentError",Nu=`vercel.ai.error.${Pu}`,Ph=Symbol.for(Nu),Mu,ju=(Ht=class extends N{constructor({message:t,cause:n,argument:r}){super({name:Pu,message:t,cause:n}),this[Mu]=!0,this.argument=r}static isInstance(t){return N.hasMarker(t,Nu)}},a(Ht,"InvalidArgumentError"),Ht);Mu=Ph;var zu="AI_InvalidPromptError",Zu=`vercel.ai.error.${zu}`,Nh=Symbol.for(Zu),Lu,lt=(Jt=class extends N{constructor({prompt:t,message:n,cause:r}){super({name:zu,message:`Invalid prompt: ${n}`,cause:r}),this[Lu]=!0,this.prompt=t}static isInstance(t){return N.hasMarker(t,Zu)}},a(Jt,"InvalidPromptError"),Jt);Lu=Nh;var Uu="AI_InvalidResponseDataError",qu=`vercel.ai.error.${Uu}`,Mh=Symbol.for(qu),Vu,Wn=(Kt=class extends N{constructor({data:t,message:n=`Invalid response data: ${JSON.stringify(t)}.`}){super({name:Uu,message:n}),this[Vu]=!0,this.data=t}static isInstance(t){return N.hasMarker(t,qu)}},a(Kt,"InvalidResponseDataError"),Kt);Vu=Mh;var Gu="AI_JSONParseError",Wu=`vercel.ai.error.${Gu}`,jh=Symbol.for(Wu),Hu,Br=(Yt=class extends N{constructor({text:t,cause:n}){super({name:Gu,message:`JSON parsing failed: Text: ${t}.
|
|
85
|
-
Error message: ${
|
|
86
|
-
Error message: ${
|
|
87
|
-
`;break;case"id":u=v.includes("\0")?void 0:v;break;case"retry":/^\d+$/.test(v)?r(parseInt(v,10)):n(new
|
|
88
|
-
`)?l.slice(0,-1):l}),u=void 0,l="",c=""}a(f,"dispatchEvent");function D(g={}){i&&g.consume&&p(i),o=!0,u=void 0,l="",c="",i=""}return a(D,"reset"),{feed:d,reset:D}}a(
|
|
84
|
+
`,n=a((l,c)=>{const d=[];let p="";typeof c=="string"?c={section:c,whitespace:!1}:(c=c||Object.create(null),c.whitespace=c.whitespace===!0);const h=c.whitespace?" = ":"=";for(const f of Object.keys(l)){const D=l[f];if(D&&Array.isArray(D))for(const g of D)p+=o(f+"[]")+h+o(g)+t;else D&&typeof D=="object"?d.push(f):p+=o(f)+h+o(D)+t}c.section&&p.length&&(p="["+o(c.section)+"]"+t+p);for(const f of d){const D=r(f).join("\\."),g=(c.section?c.section+".":"")+D,{whitespace:v}=c,F=n(l[f],{section:g,whitespace:v});p.length&&F.length&&(p+=t),p+=F}return p},"encode"),r=a(l=>l.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(c=>c.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),"dotSplit"),s=a(l=>{const c=Object.create(null);let d=c,p=null;const h=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,f=l.split(/[\r\n]+/g);for(const g of f){if(!g||g.match(/^\s*[;#]/))continue;const v=g.match(h);if(!v)continue;if(v[1]!==void 0){if(p=u(v[1]),p==="__proto__"){d=Object.create(null);continue}d=c[p]=c[p]||Object.create(null);continue}const F=u(v[2]),C=F.length>2&&F.slice(-2)==="[]",_=C?F.slice(0,-2):F;if(_==="__proto__")continue;const b=v[3]?u(v[4]):!0,B=b==="true"||b==="false"||b==="null"?JSON.parse(b):b;C&&(e.call(d,_)?Array.isArray(d[_])||(d[_]=[d[_]]):d[_]=[]),Array.isArray(d[_])?d[_].push(B):d[_]=B}const D=[];for(const g of Object.keys(c)){if(!e.call(c,g)||typeof c[g]!="object"||Array.isArray(c[g]))continue;const v=r(g);d=c;const F=v.pop(),C=F.replace(/\\\./g,".");for(const _ of v)_!=="__proto__"&&((!e.call(d,_)||typeof d[_]!="object")&&(d[_]=Object.create(null)),d=d[_]);d===c&&C===F||(d[C]=c[g],D.push(g))}for(const g of D)delete c[g];return c},"decode"),i=a(l=>l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"),"isQuoted"),o=a(l=>typeof l!="string"||l.match(/[=\r\n]/)||l.match(/^\[/)||l.length>1&&i(l)||l!==l.trim()?JSON.stringify(l):l.split(";").join("\\;").split("#").join("\\#"),"safe"),u=a((l,c)=>{if(l=(l||"").trim(),i(l)){l.charAt(0)==="'"&&(l=l.slice(1,-1));try{l=JSON.parse(l)}catch{}}else{let d=!1,p="";for(let h=0,f=l.length;h<f;h++){const D=l.charAt(h);if(d)"\\;#".indexOf(D)!==-1?p+=D:p+="\\"+D,d=!1;else{if(";#".indexOf(D)!==-1)break;D==="\\"?d=!0:p+=D}}return d&&(p+="\\"),p.trim()}return l},"unsafe");return os={parse:s,decode:s,stringify:n,encode:n,safe:o,unsafe:u},os}a(lh,"requireIni");var ch=lh(),Eu=yt(ch);const ss=a(e=>we.lstat(e).then(()=>!0,()=>!1),"fileExists"),dh=["","conventional","gitmoji"],{hasOwnProperty:ph}=Object.prototype,Cu=a((e,t)=>ph.call(e,t),"hasOwn"),tt=a((e,t,n)=>{if(!t)throw new K(`Invalid config property ${e}: ${n}`)},"parseAssert"),Or={OPENAI_API_KEY(e){return e},OPENAI_BASE_URL(e){return e},OPENAI_MODEL(e){return e||""},locale(e){return e?(tt("locale",!!e,"Cannot be empty"),tt("locale",/^[a-z-]+$/i.test(e),"Must be a valid locale (letters and dashes/underscores)."),e):"en"},generate(e){if(!e)return 1;tt("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return tt("generate",t>0,"Must be greater than 0"),tt("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(tt("type",dh.includes(e),"Invalid commit type"),e):""},proxy(e){if(!(!e||e.length===0))throw new K('The "proxy" config property is deprecated and no longer supported.')},timeout(e){if(!e)return;tt("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return tt("timeout",t>=500,"Must be greater than 500ms"),t},"max-length"(e){if(!e)return 72;tt("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return tt("max-length",t>=20,"Must be greater than 20 characters"),t}},Dh={name:"togetherai",displayName:"Together AI (recommended)",baseUrl:"https://api.together.xyz/v1",apiKeyFormat:"tgp_",modelsFilter:a(e=>e.filter(t=>!t.type||t.type==="chat"||t.type==="language").map(t=>t.id),"modelsFilter"),defaultModels:["essentialai/rnj-1-instruct","meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo","meta-llama/Llama-3.2-3B-Instruct-Turbo","Qwen/Qwen3-Next-80B-A3B-Instruct"],requiresApiKey:!0},fh={name:"openai",displayName:"OpenAI",baseUrl:"https://api.openai.com/v1",apiKeyFormat:"sk-",modelsFilter:a(e=>e.filter(t=>t.id&&(t.id.includes("gpt")||t.id.includes("o1")||t.id.includes("o3")||t.id.includes("o4")||t.id.includes("o5")||!t.type||t.type==="chat")).map(t=>t.id),"modelsFilter"),defaultModels:["gpt-5-mini","gpt-4o-mini","gpt-4o","gpt-5-nano"],requiresApiKey:!0},mh={name:"ollama",displayName:"Ollama (local)",baseUrl:"http://localhost:11434/v1",modelsFilter:a(e=>e.filter(t=>t.name).map(t=>t.name),"modelsFilter"),defaultModels:["gpt-oss:latest","llama3.2:latest"],requiresApiKey:!1},hh={name:"custom",displayName:"Custom (OpenAI-compatible)",baseUrl:"",modelsFilter:a(e=>e.filter(t=>!t.type||t.type==="chat"||t.type==="language").map(t=>t.id),"modelsFilter"),defaultModels:[],requiresApiKey:!0},gh={name:"openrouter",displayName:"OpenRouter",baseUrl:"https://openrouter.ai/api/v1",apiKeyFormat:"sk-or-v1-",modelsFilter:a(e=>e.filter(t=>t.id&&(!t.type||t.type==="chat")).map(t=>t.id),"modelsFilter"),defaultModels:["openai/gpt-oss-20b:free","z-ai/glm-4.5-air:free"],requiresApiKey:!0},Wn=[Dh,fh,mh,gh,hh],vh=a(()=>Wn.find(t=>t.name==="openai")?.baseUrl||"","getDefaultBaseUrl"),yh=a((e,t)=>{if(e){const n=Wn.find(r=>r.baseUrl===e||r.name==="ollama"&&e.startsWith(r.baseUrl.slice(0,-3)));return n?n.name:"custom"}else if(t)return"openai"},"detectProvider"),is=a(()=>Ve.join(Pi.homedir(),".aicommits"),"getConfigPath"),bu=a(async()=>{if(!await ss(is()))return Object.create(null);const t=await we.readFile(is(),"utf8");return Eu.parse(t)},"readConfigFile"),wt=a(async(e,t,n)=>{const r=await bu(),s={},{env:i}=process,o=t??{OPENAI_API_KEY:i.OPENAI_API_KEY||i.OPENAI_KEY,OPENAI_BASE_URL:i.OPENAI_BASE_URL,OPENAI_MODEL:i.OPENAI_MODEL};for(const d of Object.keys(Or)){const p=Or[d],h=e?.[d]??o?.[d]??r[d];if(n)try{s[d]=p(h)}catch{}else s[d]=p(h)}let u,l=s.OPENAI_BASE_URL;const c=s.OPENAI_API_KEY;return!l&&c&&(l=vh(),s.OPENAI_BASE_URL=l),u=yh(l,c),{...s,model:s.OPENAI_MODEL,provider:u}},"getConfig"),as=a(async e=>{const t=await bu();for(const[n,r]of e){if(!Cu(Or,n))throw new K(`Invalid config property: ${n}`);if(r==="")delete t[n];else{const s=Or[n](r);t[n]=s}}await we.writeFile(is(),Eu.stringify(t),"utf8")},"setConfigs"),wu=a(e=>`[${e} - \u2705]`,"CURRENT_LABEL_FORMAT"),_h=3600*1e3,Au=a(()=>{const e=process.platform,t=Pi.homedir();if(e==="darwin")return Ve.join(t,"Library","Caches","aicommits","models");if(e==="win32")return Ve.join(t,"AppData","Local","aicommits","models");{const n=process.env.XDG_CACHE_HOME,r=n||Ve.join(t,".cache");return Ve.join(r,"aicommits","models")}},"getCacheDir"),Fh=a(e=>{const t=Zp.createHash("sha256");return t.update(e),t.digest("hex")},"getCacheKey"),ku=a(e=>Ve.join(Au(),`${e}.json`),"getCachePath"),Eh=a(async e=>{const t=ku(e);try{if(!await ss(t))return null;const n=await we.readFile(t,"utf8");return JSON.parse(n)}catch{return null}},"readCache"),Ch=a(async(e,t)=>{try{const n=Au();await we.mkdir(n,{recursive:!0});const r=ku(e);await we.writeFile(r,JSON.stringify(t),"utf8")}catch{}},"writeCache"),us=a(async(e,t)=>{const n=Fh(e),r=Date.now(),s=await Eh(n);if(s&&r-s.timestamp<_h)return s.data;try{const i=await fetch(`${e}/models`,{headers:{Authorization:`Bearer ${t}`}});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const o=await i.json(),u=(o.data?o.data:o)||[],l={models:u};return u.length>0&&await Ch(n,{data:l,timestamp:r}),l}catch(i){const o=i instanceof Error?i.message:"Request failed";return{models:[],error:o}}},"fetchModels"),bh=a(async(e,t,n)=>{const r=await us(e,t);r.error&&console.error(`Failed to fetch models: ${r.error}`);let s=[];return n?.modelsFilter?s=n.modelsFilter(r.models):s=r.models.map(i=>i.id||i.name).filter(Boolean),s},"fetchAndFilterModels"),wh=a((e,t,n)=>{let r=e.map(s=>({label:s,value:s}));if(n?.defaultModels&&n.defaultModels.length>0){const s=n.defaultModels.filter(i=>r.some(o=>o.value===i));s.forEach(i=>{const o=r.findIndex(u=>u.value===i);o>=0&&r.splice(o,1)}),s.forEach((i,o)=>{const l=o===0?`\u2B50 ${i} (default)`:`\u{1F525} ${i}`;r.unshift({label:l,value:i})})}if(t&&t!=="undefined"){const s=n?.defaultModels?.includes(t),i=r.findIndex(o=>o.value===t);if(i>=0&&!s){if(r[i].label=wu(r[i].value),i>0){const[o]=r.splice(i,1),u=n?.defaultModels?.length||0;r.splice(u,0,o)}}else if(i<0&&!s){const o=n?.defaultModels?.length||0;r.splice(o,0,{label:wu(t),value:t})}}return r},"prepareModelOptions"),Ah=a(async(e,t,n,r)=>{const s=await n({message:"Enter search term for models:",placeholder:"e.g., gpt, llama"});if(r(s))return null;let i=e;s&&(i=e.filter(l=>l.toLowerCase().includes(s.toLowerCase())));let o=i.slice(0,20).map(l=>({label:l,value:l}));const u=await t({message:`Choose your model (filtered by "${s}"):`,options:[...o,{label:"Custom model name...",value:"custom"}]});return r(u)?null:u},"handleSearch"),kh=a(async e=>{const t=await e({message:"Enter your custom model name:",validate:a(n=>{if(!n)return"Model name is required"},"validate")});return Vn(t)?null:t},"handleCustom"),xu=a(async(e,t,n,r)=>{(!n||n==="undefined")&&(n=r?.defaultModels?.[0]);const s=bt();s.start("Fetching available models...");const i=await bh(e,t,r);s.stop();let o=null;if(i.length>0){const{select:u,text:l,isCancel:c}=await Promise.resolve().then(function(){return Gn});let d=wh(i,n,r),p=await u({message:"Choose your model:",options:[{label:"\u{1F50D} Search models...",value:"search"},...d,{label:"Custom model name...",value:"custom"}],initialValue:d.length>0?d[0].value:void 0});if(c(p))return null;if(p==="search"){const h=await Ah(i,u,l,c);if(h===null)return null;p=h}if(p==="custom"){if(o=await kh(l),o===null)return null}else o=p}else{console.log("Could not fetch available models. Please specify a model name manually.");const{text:u}=await Promise.resolve().then(function(){return Gn});try{o=await u({message:"Enter your model name:",validate:a(c=>{if(!c)return"Model name is required"},"validate")})}catch{return null}}return o},"selectModel");var xh=Object.freeze({__proto__:null,fetchModels:us,selectModel:xu}),$h=Object.defineProperty,Ih=a((e,t,n)=>t in e?$h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"__defNormalProp"),$u=a((e,t,n)=>Ih(e,typeof t!="symbol"?t+"":t,n),"__publicField");const ci=class ci{constructor(t,n){$u(this,"config"),$u(this,"def"),this.def=t,this.config=n}get name(){return this.def.name}get displayName(){return this.def.displayName}getDefinition(){return this.def}async setup(){const{text:t,password:n}=await Promise.resolve().then(function(){return Gn}),r=[];if(this.def.requiresApiKey){const s=this.getApiKey(),i=await n({message:s?`Enter your API key (leave empty to keep current: ${s.substring(0,4)}****):`:"Enter your API key:",validate:a(o=>{if(!o&&!s)return"API key is required";if(o&&this.def.apiKeyFormat&&!o.startsWith(this.def.apiKeyFormat))return`Invalid API key format, must start with "${this.def.apiKeyFormat}"`},"validate")});i&&r.push(["OPENAI_API_KEY",i])}if(this.name==="ollama"){const s=this.getBaseUrl(),i=await t({message:"Enter Ollama endpoint (leave empty for default):",placeholder:s});i&&i!=="http://localhost:11434/v1"&&r.push(["OPENAI_BASE_URL",i])}return r}async getModels(){const t=this.getBaseUrl(),n=this.getApiKey()||"",r=await us(t,n);if(r.error)return{models:[],error:r.error};let s;return this.def.modelsFilter?s=this.def.modelsFilter(r.models):s=r.models.map(i=>i.id||i.name).filter(Boolean),{models:s}}getApiKey(){return this.def.requiresApiKey?this.config.OPENAI_API_KEY:void 0}getBaseUrl(){return this.name==="custom"?this.config.OPENAI_BASE_URL||"":this.def.baseUrl}getDefaultModel(){return this.def.defaultModels[0]||""}getHighlightedModels(){return this.def.defaultModels}validateConfig(){const t=[];return this.def.requiresApiKey&&!this.getApiKey()&&t.push(`${this.displayName} API key is required`),this.name==="custom"&&!this.getBaseUrl()&&t.push("Custom endpoint is required"),{valid:t.length===0,errors:t}}};a(ci,"Provider");let ls=ci;function Lt(e){const t=e.provider,n=Wn.find(r=>r.name===t);return n?new ls(n,e):null}a(Lt,"getProvider");function Bh(){return Wn.map(e=>({value:e.name,label:e.displayName}))}a(Bh,"getAvailableProviders");function Sh(e){return Wn.find(n=>n.name===e)?.baseUrl||""}a(Sh,"getProviderBaseUrl");var Iu="vercel.ai.error",Th=Symbol.for(Iu),Bu,Oh=(Tt=class extends Error{constructor({name:t,message:n,cause:r}){super(n),this[Bu]=!0,this.name=t,this.cause=r}static isInstance(t){return Tt.hasMarker(t,Iu)}static hasMarker(t,n){const r=Symbol.for(n);return t!=null&&typeof t=="object"&&r in t&&typeof t[r]=="boolean"&&t[r]===!0}},a(Tt,"_AISDKError2"),Tt);Bu=Th;var M=Oh,Su="AI_APICallError",Tu=`vercel.ai.error.${Su}`,Rh=Symbol.for(Tu),Ou,be=(Kt=class extends M{constructor({message:t,url:n,requestBodyValues:r,statusCode:s,responseHeaders:i,responseBody:o,cause:u,isRetryable:l=s!=null&&(s===408||s===409||s===429||s>=500),data:c}){super({name:Su,message:t,cause:u}),this[Ou]=!0,this.url=n,this.requestBodyValues=r,this.statusCode=s,this.responseHeaders=i,this.responseBody=o,this.isRetryable=l,this.data=c}static isInstance(t){return M.hasMarker(t,Tu)}},a(Kt,"APICallError"),Kt);Ou=Rh;var Ru="AI_EmptyResponseBodyError",Pu=`vercel.ai.error.${Ru}`,Ph=Symbol.for(Pu),Nu,Nh=(Yt=class extends M{constructor({message:t="Empty response body"}={}){super({name:Ru,message:t}),this[Nu]=!0}static isInstance(t){return M.hasMarker(t,Pu)}},a(Yt,"EmptyResponseBodyError"),Yt);Nu=Ph;function Hn(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}a(Hn,"getErrorMessage$1");var Mu="AI_InvalidArgumentError",ju=`vercel.ai.error.${Mu}`,Mh=Symbol.for(ju),zu,Zu=(Xt=class extends M{constructor({message:t,cause:n,argument:r}){super({name:Mu,message:t,cause:n}),this[zu]=!0,this.argument=r}static isInstance(t){return M.hasMarker(t,ju)}},a(Xt,"InvalidArgumentError"),Xt);zu=Mh;var Lu="AI_InvalidPromptError",Uu=`vercel.ai.error.${Lu}`,jh=Symbol.for(Uu),qu,dt=(Qt=class extends M{constructor({prompt:t,message:n,cause:r}){super({name:Lu,message:`Invalid prompt: ${n}`,cause:r}),this[qu]=!0,this.prompt=t}static isInstance(t){return M.hasMarker(t,Uu)}},a(Qt,"InvalidPromptError"),Qt);qu=jh;var Vu="AI_InvalidResponseDataError",Gu=`vercel.ai.error.${Vu}`,zh=Symbol.for(Gu),Wu,Jn=(en=class extends M{constructor({data:t,message:n=`Invalid response data: ${JSON.stringify(t)}.`}){super({name:Vu,message:n}),this[Wu]=!0,this.data=t}static isInstance(t){return M.hasMarker(t,Gu)}},a(en,"InvalidResponseDataError"),en);Wu=zh;var Hu="AI_JSONParseError",Ju=`vercel.ai.error.${Hu}`,Zh=Symbol.for(Ju),Ku,Rr=(tn=class extends M{constructor({text:t,cause:n}){super({name:Hu,message:`JSON parsing failed: Text: ${t}.
|
|
85
|
+
Error message: ${Hn(n)}`,cause:n}),this[Ku]=!0,this.text=t}static isInstance(t){return M.hasMarker(t,Ju)}},a(tn,"JSONParseError"),tn);Ku=Zh;var Yu="AI_LoadAPIKeyError",Xu=`vercel.ai.error.${Yu}`,Lh=Symbol.for(Xu),Qu,Pr=(nn=class extends M{constructor({message:t}){super({name:Yu,message:t}),this[Qu]=!0}static isInstance(t){return M.hasMarker(t,Xu)}},a(nn,"LoadAPIKeyError"),nn);Qu=Lh;var el="AI_TooManyEmbeddingValuesForCallError",tl=`vercel.ai.error.${el}`,Uh=Symbol.for(tl),nl,rl=(rn=class extends M{constructor(t){super({name:el,message:`Too many values for a single embedding call. The ${t.provider} model "${t.modelId}" can only embed up to ${t.maxEmbeddingsPerCall} values per call, but ${t.values.length} values were provided.`}),this[nl]=!0,this.provider=t.provider,this.modelId=t.modelId,this.maxEmbeddingsPerCall=t.maxEmbeddingsPerCall,this.values=t.values}static isInstance(t){return M.hasMarker(t,tl)}},a(rn,"TooManyEmbeddingValuesForCallError"),rn);nl=Uh;var ol="AI_TypeValidationError",sl=`vercel.ai.error.${ol}`,qh=Symbol.for(sl),il,Vh=(ht=class extends M{constructor({value:t,cause:n}){super({name:ol,message:`Type validation failed: Value: ${JSON.stringify(t)}.
|
|
86
|
+
Error message: ${Hn(n)}`,cause:n}),this[il]=!0,this.value=t}static isInstance(t){return M.hasMarker(t,sl)}static wrap({value:t,cause:n}){return ht.isInstance(n)&&n.value===t?n:new ht({value:t,cause:n})}},a(ht,"_TypeValidationError2"),ht);il=qh;var Kn=Vh,al="AI_UnsupportedFunctionalityError",ul=`vercel.ai.error.${al}`,Gh=Symbol.for(ul),ll,Ne=(on=class extends M{constructor({functionality:t,message:n=`'${t}' functionality not supported.`}){super({name:al,message:n}),this[ll]=!0,this.functionality=t}static isInstance(t){return M.hasMarker(t,ul)}},a(on,"UnsupportedFunctionalityError"),on);ll=Gh;const di=class di extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}};a(di,"ParseError");let Nr=di;function cs(e){}a(cs,"noop");function Wh(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=cs,onError:n=cs,onRetry:r=cs,onComment:s}=e;let i="",o=!0,u,l="",c="";function d(g){const v=o?g.replace(/^\xEF\xBB\xBF/,""):g,[F,C]=Hh(`${i}${v}`);for(const _ of F)p(_);i=C,o=!1}a(d,"feed");function p(g){if(g===""){f();return}if(g.startsWith(":")){s&&s(g.slice(g.startsWith(": ")?2:1));return}const v=g.indexOf(":");if(v!==-1){const F=g.slice(0,v),C=g[v+1]===" "?2:1,_=g.slice(v+C);h(F,_,g);return}h(g,"",g)}a(p,"parseLine");function h(g,v,F){switch(g){case"event":c=v;break;case"data":l=`${l}${v}
|
|
87
|
+
`;break;case"id":u=v.includes("\0")?void 0:v;break;case"retry":/^\d+$/.test(v)?r(parseInt(v,10)):n(new Nr(`Invalid \`retry\` value: "${v}"`,{type:"invalid-retry",value:v,line:F}));break;default:n(new Nr(`Unknown field "${g.length>20?`${g.slice(0,20)}\u2026`:g}"`,{type:"unknown-field",field:g,value:v,line:F}));break}}a(h,"processField");function f(){l.length>0&&t({id:u,event:c||void 0,data:l.endsWith(`
|
|
88
|
+
`)?l.slice(0,-1):l}),u=void 0,l="",c=""}a(f,"dispatchEvent");function D(g={}){i&&g.consume&&p(i),o=!0,u=void 0,l="",c="",i=""}return a(D,"reset"),{feed:d,reset:D}}a(Wh,"createParser");function Hh(e){const t=[];let n="",r=0;for(;r<e.length;){const s=e.indexOf("\r",r),i=e.indexOf(`
|
|
89
89
|
`,r);let o=-1;if(s!==-1&&i!==-1?o=Math.min(s,i):s!==-1?s===e.length-1?o=-1:o=s:i!==-1&&(o=i),o===-1){n=e.slice(r);break}else{const u=e.slice(r,o);t.push(u),r=o+1,e[r-1]==="\r"&&e[r]===`
|
|
90
|
-
`&&r++}}return[t,n]}a(Gh,"splitLines");const li=class li extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let s;super({start(i){s=Vh({onEvent:a(o=>{i.enqueue(o)},"onEvent"),onError(o){t==="terminate"?i.error(o):typeof t=="function"&&t(o)},onRetry:n,onComment:r})},transform(i){s.feed(i)}})}};a(li,"EventSourceParserStream");let cs=li;function A(e,t,n){function r(l,c){var d;Object.defineProperty(l,"_zod",{value:l._zod??{},enumerable:!1}),(d=l._zod).traits??(d.traits=new Set),l._zod.traits.add(e),t(l,c);for(const p in o.prototype)p in l||Object.defineProperty(l,p,{value:o.prototype[p].bind(l)});l._zod.constr=o,l._zod.def=c}a(r,"init");const s=n?.Parent??Object,u=class u extends s{};a(u,"Definition");let i=u;Object.defineProperty(i,"name",{value:e});function o(l){var c;const d=n?.Parent?new i:this;r(d,l),(c=d._zod).deferred??(c.deferred=[]);for(const p of d._zod.deferred)p();return d}return a(o,"_"),Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a(l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e),"value")}),Object.defineProperty(o,"name",{value:e}),o}a(A,"$constructor");const ci=class ci extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};a(ci,"$ZodAsyncError");let Et=ci;const ul={};function ct(e){return ul}a(ct,"config");function ll(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,s])=>t.indexOf(+r)===-1).map(([r,s])=>s)}a(ll,"getEnumValues");function Wh(e,t){return typeof t=="bigint"?t.toString():t}a(Wh,"jsonStringifyReplacer");function ds(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}a(ds,"cached");function ps(e){return e==null}a(ps,"nullish");function Ds(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}a(Ds,"cleanRegex");function Hh(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return i%o/10**s}a(Hh,"floatSafeRemainder");function H(e,t,n){Object.defineProperty(e,t,{get(){{const r=n();return e[t]=r,r}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}a(H,"defineLazy");function fs(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}a(fs,"assignProp");function Jn(e){return JSON.stringify(e)}a(Jn,"esc");const cl=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Or(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Or,"isObject");const Jh=ds(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Rr(e){if(Or(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(Or(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}a(Rr,"isPlainObject");const Kh=new Set(["string","number","symbol"]);function Kn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(Kn,"escapeRegex");function Ct(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}a(Ct,"clone");function T(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:a(()=>t,"error")};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:a(()=>t.error,"error")}:t}a(T,"normalizeParams");function Yh(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}a(Yh,"optionalKeys");const Xh={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Qh(e,t){const n={},r=e._zod.def;for(const s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(n[s]=r.shape[s])}return Ct(e,{...e._zod.def,shape:n,checks:[]})}a(Qh,"pick");function eg(e,t){const n={...e._zod.def.shape},r=e._zod.def;for(const s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete n[s]}return Ct(e,{...e._zod.def,shape:n,checks:[]})}a(eg,"omit");function tg(e,t){if(!Rr(t))throw new Error("Invalid input to extend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return fs(this,"shape",r),r},checks:[]};return Ct(e,n)}a(tg,"extend");function ng(e,t){return Ct(e,{...e._zod.def,get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return fs(this,"shape",n),n},catchall:t._zod.def.catchall,checks:[]})}a(ng,"merge");function rg(e,t,n){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in r))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=e?new e({type:"optional",innerType:r[i]}):r[i])}else for(const i in r)s[i]=e?new e({type:"optional",innerType:r[i]}):r[i];return Ct(t,{...t._zod.def,shape:s,checks:[]})}a(rg,"partial");function og(e,t,n){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)s[i]=new e({type:"nonoptional",innerType:r[i]});return Ct(t,{...t._zod.def,shape:s,checks:[]})}a(og,"required");function Yn(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}a(Yn,"aborted");function bt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}a(bt,"prefixIssues");function Pr(e){return typeof e=="string"?e:e?.message}a(Pr,"unwrapMessage");function dt(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const s=Pr(e.inst?._zod.def?.error?.(e))??Pr(t?.error?.(e))??Pr(n.customError?.(e))??Pr(n.localeError?.(e))??"Invalid input";r.message=s}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}a(dt,"finalizeIssue");function ms(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}a(ms,"getLengthableOrigin");function Xn(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}a(Xn,"issue");const dl=a((e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Wh,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:a(()=>e.message,"value"),enumerable:!1})},"initializer$1"),pl=A("$ZodError",dl),Dl=A("$ZodError",dl,{Parent:Error});function sg(e,t=n=>n.message){const n={},r=[];for(const s of e.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):r.push(t(s));return{formErrors:r,fieldErrors:n}}a(sg,"flattenError");function ig(e,t){const n=t||function(i){return i.message},r={_errors:[]},s=a(i=>{for(const o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(u=>s({issues:u}));else if(o.code==="invalid_key")s({issues:o.issues});else if(o.code==="invalid_element")s({issues:o.issues});else if(o.path.length===0)r._errors.push(n(o));else{let u=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(u[c]=u[c]||{_errors:[]},u[c]._errors.push(n(o))):u[c]=u[c]||{_errors:[]},u=u[c],l++}}},"processError");return s(e),r}a(ig,"formatError");const ag=a(e=>(t,n,r,s)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Et;if(o.issues.length){const u=new(s?.Err??e)(o.issues.map(l=>dt(l,i,ct())));throw cl(u,s?.callee),u}return o.value},"_parse$1"),ug=a(e=>async(t,n,r,s)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const u=new(s?.Err??e)(o.issues.map(l=>dt(l,i,ct())));throw cl(u,s?.callee),u}return o.value},"_parseAsync"),fl=a(e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new Et;return i.issues.length?{success:!1,error:new(e??pl)(i.issues.map(o=>dt(o,s,ct())))}:{success:!0,data:i.value}},"_safeParse"),lg=fl(Dl),ml=a(e=>async(t,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>dt(o,s,ct())))}:{success:!0,data:i.value}},"_safeParseAsync"),cg=ml(Dl),dg=/^[cC][^\s-]{8,}$/,pg=/^[0-9a-z]+$/,Dg=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,fg=/^[0-9a-vA-V]{20}$/,mg=/^[A-Za-z0-9]{27}$/,hg=/^[a-zA-Z0-9_-]{21}$/,gg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,vg=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,hl=a(e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,"uuid"),yg=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_g="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Fg(){return new RegExp(_g,"u")}a(Fg,"emoji");const Eg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Cg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,bg=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,wg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ag=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,gl=/^[A-Za-z0-9_-]*$/,kg=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,xg=/^\+(?:[0-9]){6,14}[0-9]$/,vl="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ig=new RegExp(`^${vl}$`);function yl(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}a(yl,"timeSource");function $g(e){return new RegExp(`^${yl(e)}$`)}a($g,"time$1");function Bg(e){const t=yl({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-]\\d{2}:\\d{2})");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${vl}T(?:${r})$`)}a(Bg,"datetime$1");const Sg=a(e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},"string$1"),Tg=/^\d+$/,Og=/^-?\d+(?:\.\d+)?/i,Rg=/true|false/i,Pg=/null/i,Ng=/^[^A-Z]*$/,Mg=/^[^a-z]*$/,Re=A("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),_l={number:"number",bigint:"bigint",object:"date"},Fl=A("$ZodCheckLessThan",(e,t)=>{Re.init(e,t);const n=_l[typeof t.value];e._zod.onattach.push(r=>{const s=r._zod.bag,i=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?s.maximum=t.value:s.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),El=A("$ZodCheckGreaterThan",(e,t)=>{Re.init(e,t);const n=_l[typeof t.value];e._zod.onattach.push(r=>{const s=r._zod.bag,i=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),jg=A("$ZodCheckMultipleOf",(e,t)=>{Re.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Hh(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),zg=A("$ZodCheckNumberFormat",(e,t)=>{Re.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[s,i]=Xh[t.format];e._zod.onattach.push(o=>{const u=o._zod.bag;u.format=t.format,u.minimum=s,u.maximum=i,n&&(u.pattern=Tg)}),e._zod.check=o=>{const u=o.value;if(n){if(!Number.isInteger(u)){o.issues.push({expected:r,format:t.format,code:"invalid_type",input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?o.issues.push({input:u,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):o.issues.push({input:u,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}u<s&&o.issues.push({origin:"number",input:u,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),u>i&&o.issues.push({origin:"number",input:u,code:"too_big",maximum:i,inst:e})}}),Zg=A("$ZodCheckMaxLength",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!ps(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const s=r.value;if(s.length<=t.maximum)return;const o=ms(s);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Lg=A("$ZodCheckMinLength",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!ps(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const s=r.value;if(s.length>=t.minimum)return;const o=ms(s);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Ug=A("$ZodCheckLengthEquals",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!ps(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=r=>{const s=r.value,i=s.length;if(i===t.length)return;const o=ms(s),u=i>t.length;r.issues.push({origin:o,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Nr=A("$ZodCheckStringFormat",(e,t)=>{var n,r;Re.init(e,t),e._zod.onattach.push(s=>{const i=s._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),qg=A("$ZodCheckRegex",(e,t)=>{Nr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Vg=A("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ng),Nr.init(e,t)}),Gg=A("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Mg),Nr.init(e,t)}),Wg=A("$ZodCheckIncludes",(e,t)=>{Re.init(e,t);const n=Kn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),Hg=A("$ZodCheckStartsWith",(e,t)=>{Re.init(e,t);const n=new RegExp(`^${Kn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Jg=A("$ZodCheckEndsWith",(e,t)=>{Re.init(e,t);const n=new RegExp(`.*${Kn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Kg=A("$ZodCheckOverwrite",(e,t)=>{Re.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}}),di=class di{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
90
|
+
`&&r++}}return[t,n]}a(Hh,"splitLines");const pi=class pi extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let s;super({start(i){s=Wh({onEvent:a(o=>{i.enqueue(o)},"onEvent"),onError(o){t==="terminate"?i.error(o):typeof t=="function"&&t(o)},onRetry:n,onComment:r})},transform(i){s.feed(i)}})}};a(pi,"EventSourceParserStream");let ds=pi;function A(e,t,n){function r(l,c){var d;Object.defineProperty(l,"_zod",{value:l._zod??{},enumerable:!1}),(d=l._zod).traits??(d.traits=new Set),l._zod.traits.add(e),t(l,c);for(const p in o.prototype)p in l||Object.defineProperty(l,p,{value:o.prototype[p].bind(l)});l._zod.constr=o,l._zod.def=c}a(r,"init");const s=n?.Parent??Object,u=class u extends s{};a(u,"Definition");let i=u;Object.defineProperty(i,"name",{value:e});function o(l){var c;const d=n?.Parent?new i:this;r(d,l),(c=d._zod).deferred??(c.deferred=[]);for(const p of d._zod.deferred)p();return d}return a(o,"_"),Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a(l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e),"value")}),Object.defineProperty(o,"name",{value:e}),o}a(A,"$constructor");const Di=class Di extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};a(Di,"$ZodAsyncError");let At=Di;const cl={};function pt(e){return cl}a(pt,"config");function dl(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,s])=>t.indexOf(+r)===-1).map(([r,s])=>s)}a(dl,"getEnumValues");function Jh(e,t){return typeof t=="bigint"?t.toString():t}a(Jh,"jsonStringifyReplacer");function ps(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}a(ps,"cached");function Ds(e){return e==null}a(Ds,"nullish");function fs(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}a(fs,"cleanRegex");function Kh(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return i%o/10**s}a(Kh,"floatSafeRemainder");function H(e,t,n){Object.defineProperty(e,t,{get(){{const r=n();return e[t]=r,r}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}a(H,"defineLazy");function ms(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}a(ms,"assignProp");function Yn(e){return JSON.stringify(e)}a(Yn,"esc");const pl=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Mr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Mr,"isObject");const Yh=ps(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function jr(e){if(Mr(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(Mr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}a(jr,"isPlainObject");const Xh=new Set(["string","number","symbol"]);function Xn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(Xn,"escapeRegex");function kt(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}a(kt,"clone");function T(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:a(()=>t,"error")};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:a(()=>t.error,"error")}:t}a(T,"normalizeParams");function Qh(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}a(Qh,"optionalKeys");const eg={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function tg(e,t){const n={},r=e._zod.def;for(const s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(n[s]=r.shape[s])}return kt(e,{...e._zod.def,shape:n,checks:[]})}a(tg,"pick");function ng(e,t){const n={...e._zod.def.shape},r=e._zod.def;for(const s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete n[s]}return kt(e,{...e._zod.def,shape:n,checks:[]})}a(ng,"omit");function rg(e,t){if(!jr(t))throw new Error("Invalid input to extend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return ms(this,"shape",r),r},checks:[]};return kt(e,n)}a(rg,"extend");function og(e,t){return kt(e,{...e._zod.def,get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return ms(this,"shape",n),n},catchall:t._zod.def.catchall,checks:[]})}a(og,"merge");function sg(e,t,n){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in r))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=e?new e({type:"optional",innerType:r[i]}):r[i])}else for(const i in r)s[i]=e?new e({type:"optional",innerType:r[i]}):r[i];return kt(t,{...t._zod.def,shape:s,checks:[]})}a(sg,"partial");function ig(e,t,n){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)s[i]=new e({type:"nonoptional",innerType:r[i]});return kt(t,{...t._zod.def,shape:s,checks:[]})}a(ig,"required");function Qn(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}a(Qn,"aborted");function xt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}a(xt,"prefixIssues");function zr(e){return typeof e=="string"?e:e?.message}a(zr,"unwrapMessage");function Dt(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const s=zr(e.inst?._zod.def?.error?.(e))??zr(t?.error?.(e))??zr(n.customError?.(e))??zr(n.localeError?.(e))??"Invalid input";r.message=s}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}a(Dt,"finalizeIssue");function hs(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}a(hs,"getLengthableOrigin");function er(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}a(er,"issue");const Dl=a((e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Jh,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:a(()=>e.message,"value"),enumerable:!1})},"initializer$1"),fl=A("$ZodError",Dl),ml=A("$ZodError",Dl,{Parent:Error});function ag(e,t=n=>n.message){const n={},r=[];for(const s of e.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):r.push(t(s));return{formErrors:r,fieldErrors:n}}a(ag,"flattenError");function ug(e,t){const n=t||function(i){return i.message},r={_errors:[]},s=a(i=>{for(const o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(u=>s({issues:u}));else if(o.code==="invalid_key")s({issues:o.issues});else if(o.code==="invalid_element")s({issues:o.issues});else if(o.path.length===0)r._errors.push(n(o));else{let u=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(u[c]=u[c]||{_errors:[]},u[c]._errors.push(n(o))):u[c]=u[c]||{_errors:[]},u=u[c],l++}}},"processError");return s(e),r}a(ug,"formatError");const lg=a(e=>(t,n,r,s)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new At;if(o.issues.length){const u=new(s?.Err??e)(o.issues.map(l=>Dt(l,i,pt())));throw pl(u,s?.callee),u}return o.value},"_parse$1"),cg=a(e=>async(t,n,r,s)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const u=new(s?.Err??e)(o.issues.map(l=>Dt(l,i,pt())));throw pl(u,s?.callee),u}return o.value},"_parseAsync"),hl=a(e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new At;return i.issues.length?{success:!1,error:new(e??fl)(i.issues.map(o=>Dt(o,s,pt())))}:{success:!0,data:i.value}},"_safeParse"),dg=hl(ml),gl=a(e=>async(t,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>Dt(o,s,pt())))}:{success:!0,data:i.value}},"_safeParseAsync"),pg=gl(ml),Dg=/^[cC][^\s-]{8,}$/,fg=/^[0-9a-z]+$/,mg=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hg=/^[0-9a-vA-V]{20}$/,gg=/^[A-Za-z0-9]{27}$/,vg=/^[a-zA-Z0-9_-]{21}$/,yg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,_g=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,vl=a(e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,"uuid"),Fg=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Eg="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Cg(){return new RegExp(Eg,"u")}a(Cg,"emoji");const bg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,wg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Ag=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,kg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yl=/^[A-Za-z0-9_-]*$/,$g=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Ig=/^\+(?:[0-9]){6,14}[0-9]$/,_l="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Bg=new RegExp(`^${_l}$`);function Fl(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}a(Fl,"timeSource");function Sg(e){return new RegExp(`^${Fl(e)}$`)}a(Sg,"time$1");function Tg(e){const t=Fl({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-]\\d{2}:\\d{2})");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${_l}T(?:${r})$`)}a(Tg,"datetime$1");const Og=a(e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},"string$1"),Rg=/^\d+$/,Pg=/^-?\d+(?:\.\d+)?/i,Ng=/true|false/i,Mg=/null/i,jg=/^[^A-Z]*$/,zg=/^[^a-z]*$/,Re=A("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),El={number:"number",bigint:"bigint",object:"date"},Cl=A("$ZodCheckLessThan",(e,t)=>{Re.init(e,t);const n=El[typeof t.value];e._zod.onattach.push(r=>{const s=r._zod.bag,i=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?s.maximum=t.value:s.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),bl=A("$ZodCheckGreaterThan",(e,t)=>{Re.init(e,t);const n=El[typeof t.value];e._zod.onattach.push(r=>{const s=r._zod.bag,i=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zg=A("$ZodCheckMultipleOf",(e,t)=>{Re.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Kh(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Lg=A("$ZodCheckNumberFormat",(e,t)=>{Re.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[s,i]=eg[t.format];e._zod.onattach.push(o=>{const u=o._zod.bag;u.format=t.format,u.minimum=s,u.maximum=i,n&&(u.pattern=Rg)}),e._zod.check=o=>{const u=o.value;if(n){if(!Number.isInteger(u)){o.issues.push({expected:r,format:t.format,code:"invalid_type",input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?o.issues.push({input:u,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):o.issues.push({input:u,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}u<s&&o.issues.push({origin:"number",input:u,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),u>i&&o.issues.push({origin:"number",input:u,code:"too_big",maximum:i,inst:e})}}),Ug=A("$ZodCheckMaxLength",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!Ds(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const s=r.value;if(s.length<=t.maximum)return;const o=hs(s);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),qg=A("$ZodCheckMinLength",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!Ds(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const s=r.value;if(s.length>=t.minimum)return;const o=hs(s);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Vg=A("$ZodCheckLengthEquals",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!Ds(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=r=>{const s=r.value,i=s.length;if(i===t.length)return;const o=hs(s),u=i>t.length;r.issues.push({origin:o,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Zr=A("$ZodCheckStringFormat",(e,t)=>{var n,r;Re.init(e,t),e._zod.onattach.push(s=>{const i=s._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Gg=A("$ZodCheckRegex",(e,t)=>{Zr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Wg=A("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=jg),Zr.init(e,t)}),Hg=A("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zg),Zr.init(e,t)}),Jg=A("$ZodCheckIncludes",(e,t)=>{Re.init(e,t);const n=Xn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),Kg=A("$ZodCheckStartsWith",(e,t)=>{Re.init(e,t);const n=new RegExp(`^${Xn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Yg=A("$ZodCheckEndsWith",(e,t)=>{Re.init(e,t);const n=new RegExp(`.*${Xn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Xg=A("$ZodCheckOverwrite",(e,t)=>{Re.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}}),fi=class fi{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
91
91
|
`).filter(o=>o),s=Math.min(...r.map(o=>o.length-o.trimStart().length)),i=r.map(o=>o.slice(s)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const t=Function,n=this?.args,s=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,s.join(`
|
|
92
|
-
`))}};a(
|
|
92
|
+
`))}};a(fi,"Doc");let gs=fi;const Qg={major:4,minor:0,patch:0},Q=A("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Qg;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const i of s._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const s=a((i,o,u)=>{let l=Qn(i),c;for(const d of o){if(d._zod.def.when){if(!d._zod.def.when(i))continue}else if(l)continue;const p=i.issues.length,h=d._zod.check(i);if(h instanceof Promise&&u?.async===!1)throw new At;if(c||h instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await h,i.issues.length!==p&&(l||(l=Qn(i,p)))});else{if(i.issues.length===p)continue;l||(l=Qn(i,p))}}return c?c.then(()=>i):i},"runChecks");e._zod.run=(i,o)=>{const u=e._zod.parse(i,o);if(u instanceof Promise){if(o.async===!1)throw new At;return u.then(l=>s(l,r,o))}return s(u,r,o)}}e["~standard"]={validate:a(s=>{try{const i=dg(e,s);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return pg(e,s).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},"validate"),vendor:"zod",version:1}}),vs=A("$ZodString",(e,t)=>{Q.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Og(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),le=A("$ZodStringFormat",(e,t)=>{Zr.init(e,t),vs.init(e,t)}),ev=A("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=_g),le.init(e,t)}),tv=A("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=vl(r))}else t.pattern??(t.pattern=vl());le.init(e,t)}),nv=A("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Fg),le.init(e,t)}),rv=A("$ZodURL",(e,t)=>{le.init(e,t),e._zod.check=n=>{try{const r=n.value,s=new URL(r),i=s.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:$g.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),!r.endsWith("/")&&i.endsWith("/")?n.value=i.slice(0,-1):n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ov=A("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Cg()),le.init(e,t)}),sv=A("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=vg),le.init(e,t)}),iv=A("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Dg),le.init(e,t)}),av=A("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=fg),le.init(e,t)}),uv=A("$ZodULID",(e,t)=>{t.pattern??(t.pattern=mg),le.init(e,t)}),lv=A("$ZodXID",(e,t)=>{t.pattern??(t.pattern=hg),le.init(e,t)}),cv=A("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=gg),le.init(e,t)}),dv=A("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Tg(t)),le.init(e,t)}),pv=A("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Bg),le.init(e,t)}),Dv=A("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Sg(t)),le.init(e,t)}),fv=A("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=yg),le.init(e,t)}),mv=A("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=bg),le.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv4"})}),hv=A("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=wg),le.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv6"}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),gv=A("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ag),le.init(e,t)}),vv=A("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=kg),le.init(e,t),e._zod.check=n=>{const[r,s]=n.value.split("/");try{if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function wl(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}a(wl,"isValidBase64");const yv=A("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xg),le.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{wl(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function _v(e){if(!yl.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return wl(n)}a(_v,"isValidBase64URL");const Fv=A("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=yl),le.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{_v(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ev=A("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ig),le.init(e,t)});function Cv(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const s=JSON.parse(atob(r));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}a(Cv,"isValidJWT");const bv=A("$ZodJWT",(e,t)=>{le.init(e,t),e._zod.check=n=>{Cv(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Al=A("$ZodNumber",(e,t)=>{Q.init(e,t),e._zod.pattern=e._zod.bag.pattern??Pg,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...i?{received:i}:{}}),n}}),wv=A("$ZodNumber",(e,t)=>{Lg.init(e,t),Al.init(e,t)}),Av=A("$ZodBoolean",(e,t)=>{Q.init(e,t),e._zod.pattern=Ng,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const s=n.value;return typeof s=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),n}}),kv=A("$ZodNull",(e,t)=>{Q.init(e,t),e._zod.pattern=Mg,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const s=n.value;return s===null||n.issues.push({expected:"null",code:"invalid_type",input:s,inst:e}),n}}),xv=A("$ZodAny",(e,t)=>{Q.init(e,t),e._zod.parse=n=>n}),$v=A("$ZodUnknown",(e,t)=>{Q.init(e,t),e._zod.parse=n=>n}),Iv=A("$ZodNever",(e,t)=>{Q.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function kl(e,t,n){e.issues.length&&t.issues.push(...xt(n,e.issues)),t.value[n]=e.value}a(kl,"handleArrayResult");const Bv=A("$ZodArray",(e,t)=>{Q.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const i=[];for(let o=0;o<s.length;o++){const u=s[o],l=t.element._zod.run({value:u,issues:[]},r);l instanceof Promise?i.push(l.then(c=>kl(c,n,o))):kl(l,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function Lr(e,t,n){e.issues.length&&t.issues.push(...xt(n,e.issues)),t.value[n]=e.value}a(Lr,"handleObjectResult");function xl(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...xt(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}a(xl,"handleOptionalObjectResult");const Sv=A("$ZodObject",(e,t)=>{Q.init(e,t);const n=ps(()=>{const p=Object.keys(t.shape);for(const f of p)if(!(t.shape[f]instanceof Q))throw new Error(`Invalid element at key "${f}": expected a Zod schema`);const h=Qh(t.shape);return{shape:t.shape,keys:p,keySet:new Set(p),numKeys:p.length,optionalKeys:new Set(h)}});H(e._zod,"propValues",()=>{const p=t.shape,h={};for(const f in p){const D=p[f]._zod;if(D.values){h[f]??(h[f]=new Set);for(const g of D.values)h[f].add(g)}}return h});const r=a(p=>{const h=new gs(["shape","payload","ctx"]),f=n.value,D=a(C=>{const _=Yn(C);return`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`},"parseStr");h.write("const input = payload.value;");const g=Object.create(null);let v=0;for(const C of f.keys)g[C]=`key_${v++}`;h.write("const newResult = {}");for(const C of f.keys)if(f.optionalKeys.has(C)){const _=g[C];h.write(`const ${_} = ${D(C)};`);const b=Yn(C);h.write(`
|
|
93
93
|
if (${_}.issues.length) {
|
|
94
94
|
if (input[${b}] === undefined) {
|
|
95
95
|
if (${b} in input) {
|
|
@@ -111,15 +111,15 @@ Error message: ${Gn(n)}`,cause:n}),this[ol]=!0,this.value=t}static isInstance(t)
|
|
|
111
111
|
`)}else{const _=g[C];h.write(`const ${_} = ${D(C)};`),h.write(`
|
|
112
112
|
if (${_}.issues.length) payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
|
|
113
113
|
...iss,
|
|
114
|
-
path: iss.path ? [${
|
|
115
|
-
})));`),h.write(`newResult[${Jn(C)}] = ${_}.value`)}h.write("payload.value = newResult;"),h.write("return payload;");const F=h.compile();return(C,_)=>F(p,C,_)},"generateFastpass");let s;const i=Or,o=!ul.jitless,l=o&&Jh.value,c=t.catchall;let d;e._zod.parse=(p,h)=>{d??(d=n.value);const f=p.value;if(!i(f))return p.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),p;const D=[];if(o&&l&&h?.async===!1&&h.jitless!==!0)s||(s=r(t.shape)),p=s(p,h);else{p.value={};const _=d.shape;for(const b of d.keys){const B=_[b],O=B._zod.run({value:f[b],issues:[]},h),S=B._zod.optin==="optional"&&B._zod.optout==="optional";O instanceof Promise?D.push(O.then($=>S?Al($,p,b,f):Mr($,p,b))):S?Al(O,p,b,f):Mr(O,p,b)}}if(!c)return D.length?Promise.all(D).then(()=>p):p;const g=[],v=d.keySet,F=c._zod,C=F.def.type;for(const _ of Object.keys(f)){if(v.has(_))continue;if(C==="never"){g.push(_);continue}const b=F.run({value:f[_],issues:[]},h);b instanceof Promise?D.push(b.then(B=>Mr(B,p,_))):Mr(b,p,_)}return g.length&&p.issues.push({code:"unrecognized_keys",keys:g,input:f,inst:e}),D.length?Promise.all(D).then(()=>p):p}});function kl(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>dt(i,r,ct())))}),t}a(kl,"handleUnionResults");const xl=A("$ZodUnion",(e,t)=>{X.init(e,t),H(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),H(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),H(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),H(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${n.map(r=>Ds(r.source)).join("|")})$`)}}),e._zod.parse=(n,r)=>{let s=!1;const i=[];for(const o of t.options){const u=o._zod.run({value:n.value,issues:[]},r);if(u instanceof Promise)i.push(u),s=!0;else{if(u.issues.length===0)return u;i.push(u)}}return s?Promise.all(i).then(o=>kl(o,n,e,r)):kl(i,n,e,r)}}),Bv=A("$ZodDiscriminatedUnion",(e,t)=>{xl.init(e,t);const n=e._zod.parse;H(e._zod,"propValues",()=>{const s={};for(const i of t.options){const o=i._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[u,l]of Object.entries(o)){s[u]||(s[u]=new Set);for(const c of l)s[u].add(c)}}return s});const r=ds(()=>{const s=t.options,i=new Map;for(const o of s){const u=o._zod.propValues[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const l of u){if(i.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);i.set(l,o)}}return i});e._zod.parse=(s,i)=>{const o=s.value;if(!Or(o))return s.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),s;const u=r.value.get(o?.[t.discriminator]);return u?u._zod.run(s,i):t.unionFallback?n(s,i):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:o,path:[t.discriminator],inst:e}),s)}}),Sv=A("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(n,r)=>{const s=n.value,i=t.left._zod.run({value:s,issues:[]},r),o=t.right._zod.run({value:s,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([l,c])=>Il(n,l,c)):Il(n,i,o)}});function vs(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Rr(e)&&Rr(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),s={...e,...t};for(const i of r){const o=vs(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r],o=vs(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}a(vs,"mergeValues");function Il(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Yn(e))return e;const r=vs(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}a(Il,"handleIntersectionResults");const Tv=A("$ZodRecord",(e,t)=>{X.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!Rr(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const i=[];if(t.keyType._zod.values){const o=t.keyType._zod.values;n.value={};for(const l of o)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){const c=t.valueType._zod.run({value:s[l],issues:[]},r);c instanceof Promise?i.push(c.then(d=>{d.issues.length&&n.issues.push(...bt(l,d.issues)),n.value[l]=d.value})):(c.issues.length&&n.issues.push(...bt(l,c.issues)),n.value[l]=c.value)}let u;for(const l in s)o.has(l)||(u=u??[],u.push(l));u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u})}else{n.value={};for(const o of Reflect.ownKeys(s)){if(o==="__proto__")continue;const u=t.keyType._zod.run({value:o,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){n.issues.push({origin:"record",code:"invalid_key",issues:u.issues.map(c=>dt(c,r,ct())),input:o,path:[o],inst:e}),n.value[u.value]=u.value;continue}const l=t.valueType._zod.run({value:s[o],issues:[]},r);l instanceof Promise?i.push(l.then(c=>{c.issues.length&&n.issues.push(...bt(o,c.issues)),n.value[u.value]=c.value})):(l.issues.length&&n.issues.push(...bt(o,l.issues)),n.value[u.value]=l.value)}}return i.length?Promise.all(i).then(()=>n):n}}),Ov=A("$ZodEnum",(e,t)=>{X.init(e,t);const n=ll(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(r=>Kh.has(typeof r)).map(r=>typeof r=="string"?Kn(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return e._zod.values.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),Rv=A("$ZodLiteral",(e,t)=>{X.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?Kn(n):n?n.toString():String(n)).join("|")})$`),e._zod.parse=(n,r)=>{const s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}}),Pv=A("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.parse=(n,r)=>{const s=t.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(n.value=o,n));if(s instanceof Promise)throw new Et;return n.value=s,n}}),Nv=A("$ZodOptional",(e,t)=>{X.init(e,t),e._zod.optin="optional",e._zod.optout="optional",H(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),H(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ds(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(n,r):n.value===void 0?n:t.innerType._zod.run(n,r)}),Mv=A("$ZodNullable",(e,t)=>{X.init(e,t),H(e._zod,"optin",()=>t.innerType._zod.optin),H(e._zod,"optout",()=>t.innerType._zod.optout),H(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ds(n.source)}|null)$`):void 0}),H(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),jv=A("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",H(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(n.value===void 0)return n.value=t.defaultValue,n;const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>$l(i,t)):$l(s,t)}});function $l(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}a($l,"handleDefaultResult");const zv=A("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",H(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Zv=A("$ZodNonOptional",(e,t)=>{X.init(e,t),H(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>Bl(i,e)):Bl(s,e)}});function Bl(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}a(Bl,"handleNonOptionalResult");const Lv=A("$ZodCatch",(e,t)=>{X.init(e,t),e._zod.optin="optional",H(e._zod,"optout",()=>t.innerType._zod.optout),H(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>dt(o,r,ct()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>dt(i,r,ct()))},input:n.value}),n.issues=[]),n)}}),Uv=A("$ZodPipe",(e,t)=>{X.init(e,t),H(e._zod,"values",()=>t.in._zod.values),H(e._zod,"optin",()=>t.in._zod.optin),H(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(n,r)=>{const s=t.in._zod.run(n,r);return s instanceof Promise?s.then(i=>Sl(i,t,r)):Sl(s,t,r)}});function Sl(e,t,n){return Yn(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}a(Sl,"handlePipeResult");const qv=A("$ZodReadonly",(e,t)=>{X.init(e,t),H(e._zod,"propValues",()=>t.innerType._zod.propValues),H(e._zod,"values",()=>t.innerType._zod.values),H(e._zod,"optin",()=>t.innerType._zod.optin),H(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(Tl):Tl(s)}});function Tl(e){return e.value=Object.freeze(e.value),e}a(Tl,"handleReadonlyResult");const Vv=A("$ZodLazy",(e,t)=>{X.init(e,t),H(e._zod,"innerType",()=>t.getter()),H(e._zod,"pattern",()=>e._zod.innerType._zod.pattern),H(e._zod,"propValues",()=>e._zod.innerType._zod.propValues),H(e._zod,"optin",()=>e._zod.innerType._zod.optin),H(e._zod,"optout",()=>e._zod.innerType._zod.optout),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Gv=A("$ZodCustom",(e,t)=>{Re.init(e,t),X.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,s=t.fn(r);if(s instanceof Promise)return s.then(i=>Ol(i,n,r,e));Ol(s,n,r,e)}});function Ol(e,t,n,r){if(!e){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),t.issues.push(Xn(s))}}a(Ol,"handleRefineResult");const pi=class pi{constructor(){this._map=new Map,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};return delete r.id,{...r,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};a(pi,"$ZodRegistry");let jr=pi;function Wv(){return new jr}a(Wv,"registry");const Qn=Wv();function Hv(e,t){return new e({type:"string",...T(t)})}a(Hv,"_string");function Jv(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}a(Jv,"_email");function Rl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...T(t)})}a(Rl,"_guid");function Kv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...T(t)})}a(Kv,"_uuid");function Yv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(t)})}a(Yv,"_uuidv4");function Xv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(t)})}a(Xv,"_uuidv6");function Qv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(t)})}a(Qv,"_uuidv7");function e0(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...T(t)})}a(e0,"_url");function t0(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...T(t)})}a(t0,"_emoji");function n0(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(t)})}a(n0,"_nanoid");function r0(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...T(t)})}a(r0,"_cuid");function o0(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(t)})}a(o0,"_cuid2");function s0(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...T(t)})}a(s0,"_ulid");function i0(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...T(t)})}a(i0,"_xid");function a0(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(t)})}a(a0,"_ksuid");function u0(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(t)})}a(u0,"_ipv4");function l0(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(t)})}a(l0,"_ipv6");function c0(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(t)})}a(c0,"_cidrv4");function d0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(t)})}a(d0,"_cidrv6");function p0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...T(t)})}a(p0,"_base64");function D0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...T(t)})}a(D0,"_base64url");function f0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...T(t)})}a(f0,"_e164");function m0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...T(t)})}a(m0,"_jwt");function h0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(t)})}a(h0,"_isoDateTime");function g0(e,t){return new e({type:"string",format:"date",check:"string_format",...T(t)})}a(g0,"_isoDate");function v0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...T(t)})}a(v0,"_isoTime");function y0(e,t){return new e({type:"string",format:"duration",check:"string_format",...T(t)})}a(y0,"_isoDuration");function _0(e,t){return new e({type:"number",checks:[],...T(t)})}a(_0,"_number");function F0(e,t){return new e({type:"number",coerce:!0,checks:[],...T(t)})}a(F0,"_coercedNumber");function E0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...T(t)})}a(E0,"_int");function C0(e,t){return new e({type:"boolean",...T(t)})}a(C0,"_boolean");function b0(e,t){return new e({type:"null",...T(t)})}a(b0,"_null$1");function w0(e){return new e({type:"any"})}a(w0,"_any");function A0(e){return new e({type:"unknown"})}a(A0,"_unknown");function k0(e,t){return new e({type:"never",...T(t)})}a(k0,"_never");function Pl(e,t){return new Fl({check:"less_than",...T(t),value:e,inclusive:!1})}a(Pl,"_lt");function ys(e,t){return new Fl({check:"less_than",...T(t),value:e,inclusive:!0})}a(ys,"_lte");function Nl(e,t){return new El({check:"greater_than",...T(t),value:e,inclusive:!1})}a(Nl,"_gt");function _s(e,t){return new El({check:"greater_than",...T(t),value:e,inclusive:!0})}a(_s,"_gte");function Ml(e,t){return new jg({check:"multiple_of",...T(t),value:e})}a(Ml,"_multipleOf");function jl(e,t){return new Zg({check:"max_length",...T(t),maximum:e})}a(jl,"_maxLength");function zr(e,t){return new Lg({check:"min_length",...T(t),minimum:e})}a(zr,"_minLength");function zl(e,t){return new Ug({check:"length_equals",...T(t),length:e})}a(zl,"_length");function x0(e,t){return new qg({check:"string_format",format:"regex",...T(t),pattern:e})}a(x0,"_regex");function I0(e){return new Vg({check:"string_format",format:"lowercase",...T(e)})}a(I0,"_lowercase");function $0(e){return new Gg({check:"string_format",format:"uppercase",...T(e)})}a($0,"_uppercase");function B0(e,t){return new Wg({check:"string_format",format:"includes",...T(t),includes:e})}a(B0,"_includes");function S0(e,t){return new Hg({check:"string_format",format:"starts_with",...T(t),prefix:e})}a(S0,"_startsWith");function T0(e,t){return new Jg({check:"string_format",format:"ends_with",...T(t),suffix:e})}a(T0,"_endsWith");function er(e){return new Kg({check:"overwrite",tx:e})}a(er,"_overwrite");function O0(e){return er(t=>t.normalize(e))}a(O0,"_normalize");function R0(){return er(e=>e.trim())}a(R0,"_trim");function P0(){return er(e=>e.toLowerCase())}a(P0,"_toLowerCase");function N0(){return er(e=>e.toUpperCase())}a(N0,"_toUpperCase");function M0(e,t,n){return new e({type:"array",element:t,...T(n)})}a(M0,"_array");function j0(e,t,n){const r=T(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}a(j0,"_custom");function z0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...T(n)})}a(z0,"_refine");const Di=class Di{constructor(t){this.counter=0,this.metadataRegistry=t?.metadata??Qn,this.target=t?.target??"draft-2020-12",this.unrepresentable=t?.unrepresentable??"throw",this.override=t?.override??(()=>{}),this.io=t?.io??"output",this.seen=new Map}process(t,n={path:[],schemaPath:[]}){var r;const s=t._zod.def,i={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},o=this.seen.get(t);if(o)return o.count++,n.schemaPath.includes(t)&&(o.cycle=n.path),o.schema;const u={schema:{},count:1,cycle:void 0,path:n.path};this.seen.set(t,u);const l=t._zod.toJSONSchema?.();if(l)u.schema=l;else{const p={...n,schemaPath:[...n.schemaPath,t],path:n.path},h=t._zod.parent;if(h)u.ref=h,this.process(h,p),this.seen.get(h).isParent=!0;else{const f=u.schema;switch(s.type){case"string":{const D=f;D.type="string";const{minimum:g,maximum:v,format:F,patterns:C,contentEncoding:_}=t._zod.bag;if(typeof g=="number"&&(D.minLength=g),typeof v=="number"&&(D.maxLength=v),F&&(D.format=i[F]??F,D.format===""&&delete D.format),_&&(D.contentEncoding=_),C&&C.size>0){const b=[...C];b.length===1?D.pattern=b[0].source:b.length>1&&(u.schema.allOf=[...b.map(B=>({...this.target==="draft-7"?{type:"string"}:{},pattern:B.source}))])}break}case"number":{const D=f,{minimum:g,maximum:v,format:F,multipleOf:C,exclusiveMaximum:_,exclusiveMinimum:b}=t._zod.bag;typeof F=="string"&&F.includes("int")?D.type="integer":D.type="number",typeof b=="number"&&(D.exclusiveMinimum=b),typeof g=="number"&&(D.minimum=g,typeof b=="number"&&(b>=g?delete D.minimum:delete D.exclusiveMinimum)),typeof _=="number"&&(D.exclusiveMaximum=_),typeof v=="number"&&(D.maximum=v,typeof _=="number"&&(_<=v?delete D.maximum:delete D.exclusiveMaximum)),typeof C=="number"&&(D.multipleOf=C);break}case"boolean":{const D=f;D.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{f.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{f.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const D=f,{minimum:g,maximum:v}=t._zod.bag;typeof g=="number"&&(D.minItems=g),typeof v=="number"&&(D.maxItems=v),D.type="array",D.items=this.process(s.element,{...p,path:[...p.path,"items"]});break}case"object":{const D=f;D.type="object",D.properties={};const g=s.shape;for(const C in g)D.properties[C]=this.process(g[C],{...p,path:[...p.path,"properties",C]});const v=new Set(Object.keys(g)),F=new Set([...v].filter(C=>{const _=s.shape[C]._zod;return this.io==="input"?_.optin===void 0:_.optout===void 0}));F.size>0&&(D.required=Array.from(F)),s.catchall?._zod.def.type==="never"?D.additionalProperties=!1:s.catchall?s.catchall&&(D.additionalProperties=this.process(s.catchall,{...p,path:[...p.path,"additionalProperties"]})):this.io==="output"&&(D.additionalProperties=!1);break}case"union":{const D=f;D.anyOf=s.options.map((g,v)=>this.process(g,{...p,path:[...p.path,"anyOf",v]}));break}case"intersection":{const D=f,g=this.process(s.left,{...p,path:[...p.path,"allOf",0]}),v=this.process(s.right,{...p,path:[...p.path,"allOf",1]}),F=a(_=>"allOf"in _&&Object.keys(_).length===1,"isSimpleIntersection"),C=[...F(g)?g.allOf:[g],...F(v)?v.allOf:[v]];D.allOf=C;break}case"tuple":{const D=f;D.type="array";const g=s.items.map((C,_)=>this.process(C,{...p,path:[...p.path,"prefixItems",_]}));if(this.target==="draft-2020-12"?D.prefixItems=g:D.items=g,s.rest){const C=this.process(s.rest,{...p,path:[...p.path,"items"]});this.target==="draft-2020-12"?D.items=C:D.additionalItems=C}s.rest&&(D.items=this.process(s.rest,{...p,path:[...p.path,"items"]}));const{minimum:v,maximum:F}=t._zod.bag;typeof v=="number"&&(D.minItems=v),typeof F=="number"&&(D.maxItems=F);break}case"record":{const D=f;D.type="object",D.propertyNames=this.process(s.keyType,{...p,path:[...p.path,"propertyNames"]}),D.additionalProperties=this.process(s.valueType,{...p,path:[...p.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const D=f,g=ll(s.entries);g.every(v=>typeof v=="number")&&(D.type="number"),g.every(v=>typeof v=="string")&&(D.type="string"),D.enum=g;break}case"literal":{const D=f,g=[];for(const v of s.values)if(v===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof v=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");g.push(Number(v))}else g.push(v);if(g.length!==0)if(g.length===1){const v=g[0];D.type=v===null?"null":typeof v,D.const=v}else g.every(v=>typeof v=="number")&&(D.type="number"),g.every(v=>typeof v=="string")&&(D.type="string"),g.every(v=>typeof v=="boolean")&&(D.type="string"),g.every(v=>v===null)&&(D.type="null"),D.enum=g;break}case"file":{const D=f,g={type:"string",format:"binary",contentEncoding:"binary"},{minimum:v,maximum:F,mime:C}=t._zod.bag;v!==void 0&&(g.minLength=v),F!==void 0&&(g.maxLength=F),C?C.length===1?(g.contentMediaType=C[0],Object.assign(D,g)):D.anyOf=C.map(_=>({...g,contentMediaType:_})):Object.assign(D,g);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const D=this.process(s.innerType,p);f.anyOf=[D,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,p),u.ref=s.innerType;break}case"success":{const D=f;D.type="boolean";break}case"default":{this.process(s.innerType,p),u.ref=s.innerType,f.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,p),u.ref=s.innerType,this.io==="input"&&(f._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,p),u.ref=s.innerType;let D;try{D=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}f.default=D;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const D=f,g=t._zod.pattern;if(!g)throw new Error("Pattern not found in template literal");D.type="string",D.pattern=g.source;break}case"pipe":{const D=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(D,p),u.ref=D;break}case"readonly":{this.process(s.innerType,p),u.ref=s.innerType,f.readOnly=!0;break}case"promise":{this.process(s.innerType,p),u.ref=s.innerType;break}case"optional":{this.process(s.innerType,p),u.ref=s.innerType;break}case"lazy":{const D=t._zod.innerType;this.process(D,p),u.ref=D;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const c=this.metadataRegistry.get(t);return c&&Object.assign(u.schema,c),this.io==="input"&&Fe(t)&&(delete u.schema.examples,delete u.schema.default),this.io==="input"&&u.schema._prefault&&((r=u.schema).default??(r.default=u.schema._prefault)),delete u.schema._prefault,this.seen.get(t).schema}emit(t,n){const r={cycles:n?.cycles??"ref",reused:n?.reused??"inline",external:n?.external??void 0},s=this.seen.get(t);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=a(d=>{const p=this.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const g=r.external.registry.get(d[0])?.id,v=r.external.uri??(C=>C);if(g)return{ref:v(g)};const F=d[1].defId??d[1].schema.id??`schema${this.counter++}`;return d[1].defId=F,{defId:F,ref:`${v("__shared")}#/${p}/${F}`}}if(d[1]===s)return{ref:"#"};const f=`#/${p}/`,D=d[1].schema.id??`__schema${this.counter++}`;return{defId:D,ref:f+D}},"makeURI"),o=a(d=>{if(d[1].schema.$ref)return;const p=d[1],{ref:h,defId:f}=i(d);p.def={...p.schema},f&&(p.defId=f);const D=p.schema;for(const g in D)delete D[g];D.$ref=h},"extractToDef");if(r.cycles==="throw")for(const d of this.seen.entries()){const p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${p.cycle?.join("/")}/<root>
|
|
114
|
+
path: iss.path ? [${Yn(C)}, ...iss.path] : [${Yn(C)}]
|
|
115
|
+
})));`),h.write(`newResult[${Yn(C)}] = ${_}.value`)}h.write("payload.value = newResult;"),h.write("return payload;");const F=h.compile();return(C,_)=>F(p,C,_)},"generateFastpass");let s;const i=Mr,o=!cl.jitless,l=o&&Yh.value,c=t.catchall;let d;e._zod.parse=(p,h)=>{d??(d=n.value);const f=p.value;if(!i(f))return p.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),p;const D=[];if(o&&l&&h?.async===!1&&h.jitless!==!0)s||(s=r(t.shape)),p=s(p,h);else{p.value={};const _=d.shape;for(const b of d.keys){const B=_[b],O=B._zod.run({value:f[b],issues:[]},h),S=B._zod.optin==="optional"&&B._zod.optout==="optional";O instanceof Promise?D.push(O.then(x=>S?xl(x,p,b,f):Lr(x,p,b))):S?xl(O,p,b,f):Lr(O,p,b)}}if(!c)return D.length?Promise.all(D).then(()=>p):p;const g=[],v=d.keySet,F=c._zod,C=F.def.type;for(const _ of Object.keys(f)){if(v.has(_))continue;if(C==="never"){g.push(_);continue}const b=F.run({value:f[_],issues:[]},h);b instanceof Promise?D.push(b.then(B=>Lr(B,p,_))):Lr(b,p,_)}return g.length&&p.issues.push({code:"unrecognized_keys",keys:g,input:f,inst:e}),D.length?Promise.all(D).then(()=>p):p}});function $l(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>Dt(i,r,pt())))}),t}a($l,"handleUnionResults");const Il=A("$ZodUnion",(e,t)=>{Q.init(e,t),H(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),H(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),H(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),H(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${n.map(r=>fs(r.source)).join("|")})$`)}}),e._zod.parse=(n,r)=>{let s=!1;const i=[];for(const o of t.options){const u=o._zod.run({value:n.value,issues:[]},r);if(u instanceof Promise)i.push(u),s=!0;else{if(u.issues.length===0)return u;i.push(u)}}return s?Promise.all(i).then(o=>$l(o,n,e,r)):$l(i,n,e,r)}}),Tv=A("$ZodDiscriminatedUnion",(e,t)=>{Il.init(e,t);const n=e._zod.parse;H(e._zod,"propValues",()=>{const s={};for(const i of t.options){const o=i._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[u,l]of Object.entries(o)){s[u]||(s[u]=new Set);for(const c of l)s[u].add(c)}}return s});const r=ps(()=>{const s=t.options,i=new Map;for(const o of s){const u=o._zod.propValues[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const l of u){if(i.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);i.set(l,o)}}return i});e._zod.parse=(s,i)=>{const o=s.value;if(!Mr(o))return s.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),s;const u=r.value.get(o?.[t.discriminator]);return u?u._zod.run(s,i):t.unionFallback?n(s,i):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:o,path:[t.discriminator],inst:e}),s)}}),Ov=A("$ZodIntersection",(e,t)=>{Q.init(e,t),e._zod.parse=(n,r)=>{const s=n.value,i=t.left._zod.run({value:s,issues:[]},r),o=t.right._zod.run({value:s,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([l,c])=>Bl(n,l,c)):Bl(n,i,o)}});function ys(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(jr(e)&&jr(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),s={...e,...t};for(const i of r){const o=ys(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r],o=ys(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}a(ys,"mergeValues");function Bl(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Qn(e))return e;const r=ys(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}a(Bl,"handleIntersectionResults");const Rv=A("$ZodRecord",(e,t)=>{Q.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!jr(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const i=[];if(t.keyType._zod.values){const o=t.keyType._zod.values;n.value={};for(const l of o)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){const c=t.valueType._zod.run({value:s[l],issues:[]},r);c instanceof Promise?i.push(c.then(d=>{d.issues.length&&n.issues.push(...xt(l,d.issues)),n.value[l]=d.value})):(c.issues.length&&n.issues.push(...xt(l,c.issues)),n.value[l]=c.value)}let u;for(const l in s)o.has(l)||(u=u??[],u.push(l));u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u})}else{n.value={};for(const o of Reflect.ownKeys(s)){if(o==="__proto__")continue;const u=t.keyType._zod.run({value:o,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){n.issues.push({origin:"record",code:"invalid_key",issues:u.issues.map(c=>Dt(c,r,pt())),input:o,path:[o],inst:e}),n.value[u.value]=u.value;continue}const l=t.valueType._zod.run({value:s[o],issues:[]},r);l instanceof Promise?i.push(l.then(c=>{c.issues.length&&n.issues.push(...xt(o,c.issues)),n.value[u.value]=c.value})):(l.issues.length&&n.issues.push(...xt(o,l.issues)),n.value[u.value]=l.value)}}return i.length?Promise.all(i).then(()=>n):n}}),Pv=A("$ZodEnum",(e,t)=>{Q.init(e,t);const n=dl(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(r=>Xh.has(typeof r)).map(r=>typeof r=="string"?Xn(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return e._zod.values.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),Nv=A("$ZodLiteral",(e,t)=>{Q.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?Xn(n):n?n.toString():String(n)).join("|")})$`),e._zod.parse=(n,r)=>{const s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}}),Mv=A("$ZodTransform",(e,t)=>{Q.init(e,t),e._zod.parse=(n,r)=>{const s=t.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(n.value=o,n));if(s instanceof Promise)throw new At;return n.value=s,n}}),jv=A("$ZodOptional",(e,t)=>{Q.init(e,t),e._zod.optin="optional",e._zod.optout="optional",H(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),H(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${fs(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(n,r):n.value===void 0?n:t.innerType._zod.run(n,r)}),zv=A("$ZodNullable",(e,t)=>{Q.init(e,t),H(e._zod,"optin",()=>t.innerType._zod.optin),H(e._zod,"optout",()=>t.innerType._zod.optout),H(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${fs(n.source)}|null)$`):void 0}),H(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Zv=A("$ZodDefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",H(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(n.value===void 0)return n.value=t.defaultValue,n;const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>Sl(i,t)):Sl(s,t)}});function Sl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}a(Sl,"handleDefaultResult");const Lv=A("$ZodPrefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",H(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Uv=A("$ZodNonOptional",(e,t)=>{Q.init(e,t),H(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>Tl(i,e)):Tl(s,e)}});function Tl(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}a(Tl,"handleNonOptionalResult");const qv=A("$ZodCatch",(e,t)=>{Q.init(e,t),e._zod.optin="optional",H(e._zod,"optout",()=>t.innerType._zod.optout),H(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>Dt(o,r,pt()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>Dt(i,r,pt()))},input:n.value}),n.issues=[]),n)}}),Vv=A("$ZodPipe",(e,t)=>{Q.init(e,t),H(e._zod,"values",()=>t.in._zod.values),H(e._zod,"optin",()=>t.in._zod.optin),H(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(n,r)=>{const s=t.in._zod.run(n,r);return s instanceof Promise?s.then(i=>Ol(i,t,r)):Ol(s,t,r)}});function Ol(e,t,n){return Qn(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}a(Ol,"handlePipeResult");const Gv=A("$ZodReadonly",(e,t)=>{Q.init(e,t),H(e._zod,"propValues",()=>t.innerType._zod.propValues),H(e._zod,"values",()=>t.innerType._zod.values),H(e._zod,"optin",()=>t.innerType._zod.optin),H(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(Rl):Rl(s)}});function Rl(e){return e.value=Object.freeze(e.value),e}a(Rl,"handleReadonlyResult");const Wv=A("$ZodLazy",(e,t)=>{Q.init(e,t),H(e._zod,"innerType",()=>t.getter()),H(e._zod,"pattern",()=>e._zod.innerType._zod.pattern),H(e._zod,"propValues",()=>e._zod.innerType._zod.propValues),H(e._zod,"optin",()=>e._zod.innerType._zod.optin),H(e._zod,"optout",()=>e._zod.innerType._zod.optout),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Hv=A("$ZodCustom",(e,t)=>{Re.init(e,t),Q.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,s=t.fn(r);if(s instanceof Promise)return s.then(i=>Pl(i,n,r,e));Pl(s,n,r,e)}});function Pl(e,t,n,r){if(!e){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),t.issues.push(er(s))}}a(Pl,"handleRefineResult");const mi=class mi{constructor(){this._map=new Map,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};return delete r.id,{...r,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};a(mi,"$ZodRegistry");let Ur=mi;function Jv(){return new Ur}a(Jv,"registry");const tr=Jv();function Kv(e,t){return new e({type:"string",...T(t)})}a(Kv,"_string");function Yv(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}a(Yv,"_email");function Nl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...T(t)})}a(Nl,"_guid");function Xv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...T(t)})}a(Xv,"_uuid");function Qv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(t)})}a(Qv,"_uuidv4");function e0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(t)})}a(e0,"_uuidv6");function t0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(t)})}a(t0,"_uuidv7");function n0(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...T(t)})}a(n0,"_url");function r0(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...T(t)})}a(r0,"_emoji");function o0(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(t)})}a(o0,"_nanoid");function s0(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...T(t)})}a(s0,"_cuid");function i0(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(t)})}a(i0,"_cuid2");function a0(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...T(t)})}a(a0,"_ulid");function u0(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...T(t)})}a(u0,"_xid");function l0(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(t)})}a(l0,"_ksuid");function c0(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(t)})}a(c0,"_ipv4");function d0(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(t)})}a(d0,"_ipv6");function p0(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(t)})}a(p0,"_cidrv4");function D0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(t)})}a(D0,"_cidrv6");function f0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...T(t)})}a(f0,"_base64");function m0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...T(t)})}a(m0,"_base64url");function h0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...T(t)})}a(h0,"_e164");function g0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...T(t)})}a(g0,"_jwt");function v0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(t)})}a(v0,"_isoDateTime");function y0(e,t){return new e({type:"string",format:"date",check:"string_format",...T(t)})}a(y0,"_isoDate");function _0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...T(t)})}a(_0,"_isoTime");function F0(e,t){return new e({type:"string",format:"duration",check:"string_format",...T(t)})}a(F0,"_isoDuration");function E0(e,t){return new e({type:"number",checks:[],...T(t)})}a(E0,"_number");function C0(e,t){return new e({type:"number",coerce:!0,checks:[],...T(t)})}a(C0,"_coercedNumber");function b0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...T(t)})}a(b0,"_int");function w0(e,t){return new e({type:"boolean",...T(t)})}a(w0,"_boolean");function A0(e,t){return new e({type:"null",...T(t)})}a(A0,"_null$1");function k0(e){return new e({type:"any"})}a(k0,"_any");function x0(e){return new e({type:"unknown"})}a(x0,"_unknown");function $0(e,t){return new e({type:"never",...T(t)})}a($0,"_never");function Ml(e,t){return new Cl({check:"less_than",...T(t),value:e,inclusive:!1})}a(Ml,"_lt");function _s(e,t){return new Cl({check:"less_than",...T(t),value:e,inclusive:!0})}a(_s,"_lte");function jl(e,t){return new bl({check:"greater_than",...T(t),value:e,inclusive:!1})}a(jl,"_gt");function Fs(e,t){return new bl({check:"greater_than",...T(t),value:e,inclusive:!0})}a(Fs,"_gte");function zl(e,t){return new Zg({check:"multiple_of",...T(t),value:e})}a(zl,"_multipleOf");function Zl(e,t){return new Ug({check:"max_length",...T(t),maximum:e})}a(Zl,"_maxLength");function qr(e,t){return new qg({check:"min_length",...T(t),minimum:e})}a(qr,"_minLength");function Ll(e,t){return new Vg({check:"length_equals",...T(t),length:e})}a(Ll,"_length");function I0(e,t){return new Gg({check:"string_format",format:"regex",...T(t),pattern:e})}a(I0,"_regex");function B0(e){return new Wg({check:"string_format",format:"lowercase",...T(e)})}a(B0,"_lowercase");function S0(e){return new Hg({check:"string_format",format:"uppercase",...T(e)})}a(S0,"_uppercase");function T0(e,t){return new Jg({check:"string_format",format:"includes",...T(t),includes:e})}a(T0,"_includes");function O0(e,t){return new Kg({check:"string_format",format:"starts_with",...T(t),prefix:e})}a(O0,"_startsWith");function R0(e,t){return new Yg({check:"string_format",format:"ends_with",...T(t),suffix:e})}a(R0,"_endsWith");function nr(e){return new Xg({check:"overwrite",tx:e})}a(nr,"_overwrite");function P0(e){return nr(t=>t.normalize(e))}a(P0,"_normalize");function N0(){return nr(e=>e.trim())}a(N0,"_trim");function M0(){return nr(e=>e.toLowerCase())}a(M0,"_toLowerCase");function j0(){return nr(e=>e.toUpperCase())}a(j0,"_toUpperCase");function z0(e,t,n){return new e({type:"array",element:t,...T(n)})}a(z0,"_array");function Z0(e,t,n){const r=T(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}a(Z0,"_custom");function L0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...T(n)})}a(L0,"_refine");const hi=class hi{constructor(t){this.counter=0,this.metadataRegistry=t?.metadata??tr,this.target=t?.target??"draft-2020-12",this.unrepresentable=t?.unrepresentable??"throw",this.override=t?.override??(()=>{}),this.io=t?.io??"output",this.seen=new Map}process(t,n={path:[],schemaPath:[]}){var r;const s=t._zod.def,i={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},o=this.seen.get(t);if(o)return o.count++,n.schemaPath.includes(t)&&(o.cycle=n.path),o.schema;const u={schema:{},count:1,cycle:void 0,path:n.path};this.seen.set(t,u);const l=t._zod.toJSONSchema?.();if(l)u.schema=l;else{const p={...n,schemaPath:[...n.schemaPath,t],path:n.path},h=t._zod.parent;if(h)u.ref=h,this.process(h,p),this.seen.get(h).isParent=!0;else{const f=u.schema;switch(s.type){case"string":{const D=f;D.type="string";const{minimum:g,maximum:v,format:F,patterns:C,contentEncoding:_}=t._zod.bag;if(typeof g=="number"&&(D.minLength=g),typeof v=="number"&&(D.maxLength=v),F&&(D.format=i[F]??F,D.format===""&&delete D.format),_&&(D.contentEncoding=_),C&&C.size>0){const b=[...C];b.length===1?D.pattern=b[0].source:b.length>1&&(u.schema.allOf=[...b.map(B=>({...this.target==="draft-7"?{type:"string"}:{},pattern:B.source}))])}break}case"number":{const D=f,{minimum:g,maximum:v,format:F,multipleOf:C,exclusiveMaximum:_,exclusiveMinimum:b}=t._zod.bag;typeof F=="string"&&F.includes("int")?D.type="integer":D.type="number",typeof b=="number"&&(D.exclusiveMinimum=b),typeof g=="number"&&(D.minimum=g,typeof b=="number"&&(b>=g?delete D.minimum:delete D.exclusiveMinimum)),typeof _=="number"&&(D.exclusiveMaximum=_),typeof v=="number"&&(D.maximum=v,typeof _=="number"&&(_<=v?delete D.maximum:delete D.exclusiveMaximum)),typeof C=="number"&&(D.multipleOf=C);break}case"boolean":{const D=f;D.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{f.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{f.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const D=f,{minimum:g,maximum:v}=t._zod.bag;typeof g=="number"&&(D.minItems=g),typeof v=="number"&&(D.maxItems=v),D.type="array",D.items=this.process(s.element,{...p,path:[...p.path,"items"]});break}case"object":{const D=f;D.type="object",D.properties={};const g=s.shape;for(const C in g)D.properties[C]=this.process(g[C],{...p,path:[...p.path,"properties",C]});const v=new Set(Object.keys(g)),F=new Set([...v].filter(C=>{const _=s.shape[C]._zod;return this.io==="input"?_.optin===void 0:_.optout===void 0}));F.size>0&&(D.required=Array.from(F)),s.catchall?._zod.def.type==="never"?D.additionalProperties=!1:s.catchall?s.catchall&&(D.additionalProperties=this.process(s.catchall,{...p,path:[...p.path,"additionalProperties"]})):this.io==="output"&&(D.additionalProperties=!1);break}case"union":{const D=f;D.anyOf=s.options.map((g,v)=>this.process(g,{...p,path:[...p.path,"anyOf",v]}));break}case"intersection":{const D=f,g=this.process(s.left,{...p,path:[...p.path,"allOf",0]}),v=this.process(s.right,{...p,path:[...p.path,"allOf",1]}),F=a(_=>"allOf"in _&&Object.keys(_).length===1,"isSimpleIntersection"),C=[...F(g)?g.allOf:[g],...F(v)?v.allOf:[v]];D.allOf=C;break}case"tuple":{const D=f;D.type="array";const g=s.items.map((C,_)=>this.process(C,{...p,path:[...p.path,"prefixItems",_]}));if(this.target==="draft-2020-12"?D.prefixItems=g:D.items=g,s.rest){const C=this.process(s.rest,{...p,path:[...p.path,"items"]});this.target==="draft-2020-12"?D.items=C:D.additionalItems=C}s.rest&&(D.items=this.process(s.rest,{...p,path:[...p.path,"items"]}));const{minimum:v,maximum:F}=t._zod.bag;typeof v=="number"&&(D.minItems=v),typeof F=="number"&&(D.maxItems=F);break}case"record":{const D=f;D.type="object",D.propertyNames=this.process(s.keyType,{...p,path:[...p.path,"propertyNames"]}),D.additionalProperties=this.process(s.valueType,{...p,path:[...p.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const D=f,g=dl(s.entries);g.every(v=>typeof v=="number")&&(D.type="number"),g.every(v=>typeof v=="string")&&(D.type="string"),D.enum=g;break}case"literal":{const D=f,g=[];for(const v of s.values)if(v===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof v=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");g.push(Number(v))}else g.push(v);if(g.length!==0)if(g.length===1){const v=g[0];D.type=v===null?"null":typeof v,D.const=v}else g.every(v=>typeof v=="number")&&(D.type="number"),g.every(v=>typeof v=="string")&&(D.type="string"),g.every(v=>typeof v=="boolean")&&(D.type="string"),g.every(v=>v===null)&&(D.type="null"),D.enum=g;break}case"file":{const D=f,g={type:"string",format:"binary",contentEncoding:"binary"},{minimum:v,maximum:F,mime:C}=t._zod.bag;v!==void 0&&(g.minLength=v),F!==void 0&&(g.maxLength=F),C?C.length===1?(g.contentMediaType=C[0],Object.assign(D,g)):D.anyOf=C.map(_=>({...g,contentMediaType:_})):Object.assign(D,g);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const D=this.process(s.innerType,p);f.anyOf=[D,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,p),u.ref=s.innerType;break}case"success":{const D=f;D.type="boolean";break}case"default":{this.process(s.innerType,p),u.ref=s.innerType,f.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,p),u.ref=s.innerType,this.io==="input"&&(f._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,p),u.ref=s.innerType;let D;try{D=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}f.default=D;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const D=f,g=t._zod.pattern;if(!g)throw new Error("Pattern not found in template literal");D.type="string",D.pattern=g.source;break}case"pipe":{const D=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(D,p),u.ref=D;break}case"readonly":{this.process(s.innerType,p),u.ref=s.innerType,f.readOnly=!0;break}case"promise":{this.process(s.innerType,p),u.ref=s.innerType;break}case"optional":{this.process(s.innerType,p),u.ref=s.innerType;break}case"lazy":{const D=t._zod.innerType;this.process(D,p),u.ref=D;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const c=this.metadataRegistry.get(t);return c&&Object.assign(u.schema,c),this.io==="input"&&Ee(t)&&(delete u.schema.examples,delete u.schema.default),this.io==="input"&&u.schema._prefault&&((r=u.schema).default??(r.default=u.schema._prefault)),delete u.schema._prefault,this.seen.get(t).schema}emit(t,n){const r={cycles:n?.cycles??"ref",reused:n?.reused??"inline",external:n?.external??void 0},s=this.seen.get(t);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=a(d=>{const p=this.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const g=r.external.registry.get(d[0])?.id,v=r.external.uri??(C=>C);if(g)return{ref:v(g)};const F=d[1].defId??d[1].schema.id??`schema${this.counter++}`;return d[1].defId=F,{defId:F,ref:`${v("__shared")}#/${p}/${F}`}}if(d[1]===s)return{ref:"#"};const f=`#/${p}/`,D=d[1].schema.id??`__schema${this.counter++}`;return{defId:D,ref:f+D}},"makeURI"),o=a(d=>{if(d[1].schema.$ref)return;const p=d[1],{ref:h,defId:f}=i(d);p.def={...p.schema},f&&(p.defId=f);const D=p.schema;for(const g in D)delete D[g];D.$ref=h},"extractToDef");if(r.cycles==="throw")for(const d of this.seen.entries()){const p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${p.cycle?.join("/")}/<root>
|
|
116
116
|
|
|
117
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of this.seen.entries()){const p=d[1];if(t===d[0]){o(d);continue}if(r.external){const f=r.external.registry.get(d[0])?.id;if(t!==d[0]&&f){o(d);continue}}if(this.metadataRegistry.get(d[0])?.id){o(d);continue}if(p.cycle){o(d);continue}if(p.count>1&&r.reused==="ref"){o(d);continue}}const u=a((d,p)=>{const h=this.seen.get(d),f=h.def??h.schema,D={...f};if(h.ref===null)return;const g=h.ref;if(h.ref=null,g){u(g,p);const v=this.seen.get(g).schema;v.$ref&&p.target==="draft-7"?(f.allOf=f.allOf??[],f.allOf.push(v)):(Object.assign(f,v),Object.assign(f,D))}h.isParent||this.override({zodSchema:d,jsonSchema:f,path:h.path??[]})},"flattenRef");for(const d of[...this.seen.entries()].reverse())u(d[0],{target:this.target});const l={};if(this.target==="draft-2020-12"?l.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?l.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),r.external?.uri){const d=r.external.registry.get(t)?.id;if(!d)throw new Error("Schema is missing an `id` property");l.$id=r.external.uri(d)}Object.assign(l,s.def);const c=r.external?.defs??{};for(const d of this.seen.entries()){const p=d[1];p.def&&p.defId&&(c[p.defId]=p.def)}r.external||Object.keys(c).length>0&&(this.target==="draft-2020-12"?l.$defs=c:l.definitions=c);try{return JSON.parse(JSON.stringify(l))}catch{throw new Error("Error converting schema to JSON.")}}};a(Di,"JSONSchemaGenerator");let Zr=Di;function Z0(e,t){if(e instanceof jr){const r=new Zr(t),s={};for(const u of e._idmap.entries()){const[l,c]=u;r.process(c)}const i={},o={registry:e,uri:t?.uri,defs:s};for(const u of e._idmap.entries()){const[l,c]=u;i[l]=r.emit(c,{...t,external:o})}if(Object.keys(s).length>0){const u=r.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[u]:s}}return{schemas:i}}const n=new Zr(t);return n.process(e),n.emit(e,t)}a(Z0,"toJSONSchema");function Fe(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;switch(s.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Fe(s.element,n);case"object":{for(const i in s.shape)if(Fe(s.shape[i],n))return!0;return!1}case"union":{for(const i of s.options)if(Fe(i,n))return!0;return!1}case"intersection":return Fe(s.left,n)||Fe(s.right,n);case"tuple":{for(const i of s.items)if(Fe(i,n))return!0;return!!(s.rest&&Fe(s.rest,n))}case"record":return Fe(s.keyType,n)||Fe(s.valueType,n);case"map":return Fe(s.keyType,n)||Fe(s.valueType,n);case"set":return Fe(s.valueType,n);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Fe(s.innerType,n);case"lazy":return Fe(s.getter(),n);case"default":return Fe(s.innerType,n);case"prefault":return Fe(s.innerType,n);case"custom":return!1;case"transform":return!0;case"pipe":return Fe(s.in,n)||Fe(s.out,n);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${s.type}`)}a(Fe,"isTransforming");const L0=A("ZodISODateTime",(e,t)=>{lv.init(e,t),De.init(e,t)});function U0(e){return h0(L0,e)}a(U0,"datetime");const q0=A("ZodISODate",(e,t)=>{cv.init(e,t),De.init(e,t)});function V0(e){return g0(q0,e)}a(V0,"date");const G0=A("ZodISOTime",(e,t)=>{dv.init(e,t),De.init(e,t)});function W0(e){return v0(G0,e)}a(W0,"time");const H0=A("ZodISODuration",(e,t)=>{pv.init(e,t),De.init(e,t)});function J0(e){return y0(H0,e)}a(J0,"duration");const K0=a((e,t)=>{pl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:a(n=>ig(e,n),"value")},flatten:{value:a(n=>sg(e,n),"value")},addIssue:{value:a(n=>e.issues.push(n),"value")},addIssues:{value:a(n=>e.issues.push(...n),"value")},isEmpty:{get(){return e.issues.length===0}}})},"initializer"),Lr=A("ZodError",K0,{Parent:Error}),Y0=ag(Lr),X0=ug(Lr),Q0=fl(Lr),Zl=ml(Lr),oe=A("ZodType",(e,t)=>(X.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),e.clone=(n,r)=>Ct(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>Y0(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Q0(e,n,r),e.parseAsync=async(n,r)=>X0(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Zl(e,n,r),e.spa=e.safeParseAsync,e.refine=(n,r)=>e.check(Jy(n,r)),e.superRefine=n=>e.check(Ky(n)),e.overwrite=n=>e.check(er(n)),e.optional=()=>Wl(e),e.nullable=()=>Hl(e),e.nullish=()=>Wl(Hl(e)),e.nonoptional=n=>zy(e,n),e.array=()=>x(e),e.or=n=>Y([e,n]),e.and=n=>$y(e,n),e.transform=n=>Kl(e,Oy(n)),e.default=n=>Ny(e,n),e.prefault=n=>jy(e,n),e.catch=n=>Ly(e,n),e.pipe=n=>Kl(e,n),e.readonly=()=>Vy(e),e.describe=n=>{const r=e.clone();return Qn.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return Qn.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Qn.get(e);const r=e.clone();return Qn.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Ll=A("_ZodString",(e,t)=>{gs.init(e,t),oe.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(x0(...r)),e.includes=(...r)=>e.check(B0(...r)),e.startsWith=(...r)=>e.check(S0(...r)),e.endsWith=(...r)=>e.check(T0(...r)),e.min=(...r)=>e.check(zr(...r)),e.max=(...r)=>e.check(jl(...r)),e.length=(...r)=>e.check(zl(...r)),e.nonempty=(...r)=>e.check(zr(1,...r)),e.lowercase=r=>e.check(I0(r)),e.uppercase=r=>e.check($0(r)),e.trim=()=>e.check(R0()),e.normalize=(...r)=>e.check(O0(...r)),e.toLowerCase=()=>e.check(P0()),e.toUpperCase=()=>e.check(N0())}),ey=A("ZodString",(e,t)=>{gs.init(e,t),Ll.init(e,t),e.email=n=>e.check(Jv(ty,n)),e.url=n=>e.check(e0(ny,n)),e.jwt=n=>e.check(m0(gy,n)),e.emoji=n=>e.check(t0(ry,n)),e.guid=n=>e.check(Rl(Ul,n)),e.uuid=n=>e.check(Kv(Ur,n)),e.uuidv4=n=>e.check(Yv(Ur,n)),e.uuidv6=n=>e.check(Xv(Ur,n)),e.uuidv7=n=>e.check(Qv(Ur,n)),e.nanoid=n=>e.check(n0(oy,n)),e.guid=n=>e.check(Rl(Ul,n)),e.cuid=n=>e.check(r0(sy,n)),e.cuid2=n=>e.check(o0(iy,n)),e.ulid=n=>e.check(s0(ay,n)),e.base64=n=>e.check(p0(fy,n)),e.base64url=n=>e.check(D0(my,n)),e.xid=n=>e.check(i0(uy,n)),e.ksuid=n=>e.check(a0(ly,n)),e.ipv4=n=>e.check(u0(cy,n)),e.ipv6=n=>e.check(l0(dy,n)),e.cidrv4=n=>e.check(c0(py,n)),e.cidrv6=n=>e.check(d0(Dy,n)),e.e164=n=>e.check(f0(hy,n)),e.datetime=n=>e.check(U0(n)),e.date=n=>e.check(V0(n)),e.time=n=>e.check(W0(n)),e.duration=n=>e.check(J0(n))});function m(e){return Hv(ey,e)}a(m,"string");const De=A("ZodStringFormat",(e,t)=>{ue.init(e,t),Ll.init(e,t)}),ty=A("ZodEmail",(e,t)=>{ev.init(e,t),De.init(e,t)}),Ul=A("ZodGUID",(e,t)=>{Xg.init(e,t),De.init(e,t)}),Ur=A("ZodUUID",(e,t)=>{Qg.init(e,t),De.init(e,t)}),ny=A("ZodURL",(e,t)=>{tv.init(e,t),De.init(e,t)}),ry=A("ZodEmoji",(e,t)=>{nv.init(e,t),De.init(e,t)}),oy=A("ZodNanoID",(e,t)=>{rv.init(e,t),De.init(e,t)}),sy=A("ZodCUID",(e,t)=>{ov.init(e,t),De.init(e,t)}),iy=A("ZodCUID2",(e,t)=>{sv.init(e,t),De.init(e,t)}),ay=A("ZodULID",(e,t)=>{iv.init(e,t),De.init(e,t)}),uy=A("ZodXID",(e,t)=>{av.init(e,t),De.init(e,t)}),ly=A("ZodKSUID",(e,t)=>{uv.init(e,t),De.init(e,t)}),cy=A("ZodIPv4",(e,t)=>{Dv.init(e,t),De.init(e,t)}),dy=A("ZodIPv6",(e,t)=>{fv.init(e,t),De.init(e,t)}),py=A("ZodCIDRv4",(e,t)=>{mv.init(e,t),De.init(e,t)}),Dy=A("ZodCIDRv6",(e,t)=>{hv.init(e,t),De.init(e,t)}),fy=A("ZodBase64",(e,t)=>{gv.init(e,t),De.init(e,t)}),my=A("ZodBase64URL",(e,t)=>{yv.init(e,t),De.init(e,t)}),hy=A("ZodE164",(e,t)=>{_v.init(e,t),De.init(e,t)}),gy=A("ZodJWT",(e,t)=>{Ev.init(e,t),De.init(e,t)}),Fs=A("ZodNumber",(e,t)=>{bl.init(e,t),oe.init(e,t),e.gt=(r,s)=>e.check(Nl(r,s)),e.gte=(r,s)=>e.check(_s(r,s)),e.min=(r,s)=>e.check(_s(r,s)),e.lt=(r,s)=>e.check(Pl(r,s)),e.lte=(r,s)=>e.check(ys(r,s)),e.max=(r,s)=>e.check(ys(r,s)),e.int=r=>e.check(ql(r)),e.safe=r=>e.check(ql(r)),e.positive=r=>e.check(Nl(0,r)),e.nonnegative=r=>e.check(_s(0,r)),e.negative=r=>e.check(Pl(0,r)),e.nonpositive=r=>e.check(ys(0,r)),e.multipleOf=(r,s)=>e.check(Ml(r,s)),e.step=(r,s)=>e.check(Ml(r,s)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function w(e){return _0(Fs,e)}a(w,"number$1");const vy=A("ZodNumberFormat",(e,t)=>{Cv.init(e,t),Fs.init(e,t)});function ql(e){return E0(vy,e)}a(ql,"int");const yy=A("ZodBoolean",(e,t)=>{bv.init(e,t),oe.init(e,t)});function Ae(e){return C0(yy,e)}a(Ae,"boolean");const _y=A("ZodNull",(e,t)=>{wv.init(e,t),oe.init(e,t)});function Fy(e){return b0(_y,e)}a(Fy,"_null");const Ey=A("ZodAny",(e,t)=>{Av.init(e,t),oe.init(e,t)});function Me(){return w0(Ey)}a(Me,"any");const Cy=A("ZodUnknown",(e,t)=>{kv.init(e,t),oe.init(e,t)});function rt(){return A0(Cy)}a(rt,"unknown");const by=A("ZodNever",(e,t)=>{xv.init(e,t),oe.init(e,t)});function wy(e){return k0(by,e)}a(wy,"never");const Ay=A("ZodArray",(e,t)=>{Iv.init(e,t),oe.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(zr(n,r)),e.nonempty=n=>e.check(zr(1,n)),e.max=(n,r)=>e.check(jl(n,r)),e.length=(n,r)=>e.check(zl(n,r)),e.unwrap=()=>e.element});function x(e,t){return M0(Ay,e,t)}a(x,"array");const ky=A("ZodObject",(e,t)=>{$v.init(e,t),oe.init(e,t),H(e,"shape",()=>t.shape),e.keyof=()=>se(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:rt()}),e.loose=()=>e.clone({...e._zod.def,catchall:rt()}),e.strict=()=>e.clone({...e._zod.def,catchall:wy()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>tg(e,n),e.merge=n=>ng(e,n),e.pick=n=>Qh(e,n),e.omit=n=>eg(e,n),e.partial=(...n)=>rg(Gl,e,n[0]),e.required=(...n)=>og(Jl,e,n[0])});function y(e,t){const n={type:"object",get shape(){return fs(this,"shape",{...e}),this.shape},...T(t)};return new ky(n)}a(y,"object$1");const Vl=A("ZodUnion",(e,t)=>{xl.init(e,t),oe.init(e,t),e.options=t.options});function Y(e,t){return new Vl({type:"union",options:e,...T(t)})}a(Y,"union");const xy=A("ZodDiscriminatedUnion",(e,t)=>{Vl.init(e,t),Bv.init(e,t)});function ke(e,t,n){return new xy({type:"union",options:t,discriminator:e,...T(n)})}a(ke,"discriminatedUnion");const Iy=A("ZodIntersection",(e,t)=>{Sv.init(e,t),oe.init(e,t)});function $y(e,t){return new Iy({type:"intersection",left:e,right:t})}a($y,"intersection");const By=A("ZodRecord",(e,t)=>{Tv.init(e,t),oe.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function he(e,t,n){return new By({type:"record",keyType:e,valueType:t,...T(n)})}a(he,"record");const Es=A("ZodEnum",(e,t)=>{Ov.init(e,t),oe.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,s)=>{const i={};for(const o of r)if(n.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Es({...t,checks:[],...T(s),entries:i})},e.exclude=(r,s)=>{const i={...t.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Es({...t,checks:[],...T(s),entries:i})}});function se(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Es({type:"enum",entries:n,...T(t)})}a(se,"_enum");const Sy=A("ZodLiteral",(e,t)=>{Rv.init(e,t),oe.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function k(e,t){return new Sy({type:"literal",values:Array.isArray(e)?e:[e],...T(t)})}a(k,"literal");const Ty=A("ZodTransform",(e,t)=>{Pv.init(e,t),oe.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=i=>{if(typeof i=="string")n.issues.push(Xn(i,n.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),o.continue??(o.continue=!0),n.issues.push(Xn(o))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function Oy(e){return new Ty({type:"transform",transform:e})}a(Oy,"transform");const Gl=A("ZodOptional",(e,t)=>{Nv.init(e,t),oe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Wl(e){return new Gl({type:"optional",innerType:e})}a(Wl,"optional");const Ry=A("ZodNullable",(e,t)=>{Mv.init(e,t),oe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Hl(e){return new Ry({type:"nullable",innerType:e})}a(Hl,"nullable");const Py=A("ZodDefault",(e,t)=>{jv.init(e,t),oe.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ny(e,t){return new Py({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}a(Ny,"_default");const My=A("ZodPrefault",(e,t)=>{zv.init(e,t),oe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function jy(e,t){return new My({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}a(jy,"prefault");const Jl=A("ZodNonOptional",(e,t)=>{Zv.init(e,t),oe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function zy(e,t){return new Jl({type:"nonoptional",innerType:e,...T(t)})}a(zy,"nonoptional");const Zy=A("ZodCatch",(e,t)=>{Lv.init(e,t),oe.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ly(e,t){return new Zy({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}a(Ly,"_catch");const Uy=A("ZodPipe",(e,t)=>{Uv.init(e,t),oe.init(e,t),e.in=t.in,e.out=t.out});function Kl(e,t){return new Uy({type:"pipe",in:e,out:t})}a(Kl,"pipe");const qy=A("ZodReadonly",(e,t)=>{qv.init(e,t),oe.init(e,t)});function Vy(e){return new qy({type:"readonly",innerType:e})}a(Vy,"readonly");const Gy=A("ZodLazy",(e,t)=>{Vv.init(e,t),oe.init(e,t),e.unwrap=()=>e._zod.def.getter()});function Yl(e){return new Gy({type:"lazy",getter:e})}a(Yl,"lazy");const Cs=A("ZodCustom",(e,t)=>{Gv.init(e,t),oe.init(e,t)});function Wy(e){const t=new Re({check:"custom"});return t._zod.check=e,t}a(Wy,"check");function Hy(e,t){return j0(Cs,e??(()=>!0),t)}a(Hy,"custom");function Jy(e,t={}){return z0(Cs,e,t)}a(Jy,"refine");function Ky(e){const t=Wy(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Xn(r,n.value,t._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),n.issues.push(Xn(s))}},e(n.value,n)));return t}a(Ky,"superRefine");function qr(e,t={error:`Input not instance of ${e.name}`}){const n=new Cs({type:"custom",check:"custom",fn:a(r=>r instanceof e,"fn"),abort:!0,...T(t)});return n._zod.bag.Class=e,n}a(qr,"_instanceof");function Yy(e){return F0(Fs,e)}a(Yy,"number");var P;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(P||(P={}));function ye(...e){return e.reduce((t,n)=>({...t,...n??{}}),{})}a(ye,"combineHeaders");async function Xy(e,t){if(e==null)return Promise.resolve();const n=t?.abortSignal;return new Promise((r,s)=>{if(n?.aborted){s(Xl());return}const i=setTimeout(()=>{o(),r()},e),o=a(()=>{clearTimeout(i),n?.removeEventListener("abort",u)},"cleanup"),u=a(()=>{o(),s(Xl())},"onAbort");n?.addEventListener("abort",u)})}a(Xy,"delay");function Xl(){return new DOMException("Delay was aborted","AbortError")}a(Xl,"createAbortError");function jt(e){return Object.fromEntries([...e.headers])}a(jt,"extractResponseHeaders");var tr=a(({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const s=a(()=>{const i=n.length,o=new Array(t);for(let u=0;u<t;u++)o[u]=n[Math.random()*i|0];return o.join("")},"generator");if(e==null)return s;if(n.includes(r))throw new ju({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${s()}`},"createIdGenerator"),je=tr();function Ql(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}a(Ql,"getErrorMessage");function zt(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}a(zt,"isAbortError");var Qy=["fetch failed","failed to fetch"];function ec({error:e,url:t,requestBodyValues:n}){if(zt(e))return e;if(e instanceof TypeError&&Qy.includes(e.message.toLowerCase())){const r=e.cause;if(r!=null)return new Ce({message:`Cannot connect to API: ${r.message}`,cause:r,url:t,requestBodyValues:n,isRetryable:!0})}return e}a(ec,"handleFetchError");function bs(e=globalThis){var t,n,r;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(r=(n=e.process)==null?void 0:n.versions)!=null&&r.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}a(bs,"getRuntimeEnvironmentUserAgent");function e_(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,r)=>{t[r.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}a(e_,"normalizeHeaders");function wt(e,...t){const n=new Headers(e_(e)),r=n.get("user-agent")||"";return n.set("user-agent",[r,...t].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}a(wt,"withUserAgentSuffix");var tc="3.0.18",t_=a(()=>globalThis.fetch,"getOriginalFetch"),nc=a(async({url:e,headers:t={},successfulResponseHandler:n,failedResponseHandler:r,abortSignal:s,fetch:i=t_()})=>{try{const o=await i(e,{method:"GET",headers:wt(t,`ai-sdk/provider-utils/${tc}`,bs()),signal:s}),u=jt(o);if(!o.ok){let l;try{l=await r({response:o,url:e,requestBodyValues:{}})}catch(c){throw zt(c)||Ce.isInstance(c)?c:new Ce({message:"Failed to process error response",cause:c,statusCode:o.status,url:e,responseHeaders:u,requestBodyValues:{}})}throw l.value}try{return await n({response:o,url:e,requestBodyValues:{}})}catch(l){throw l instanceof Error&&(zt(l)||Ce.isInstance(l))?l:new Ce({message:"Failed to process successful response",cause:l,statusCode:o.status,url:e,responseHeaders:u,requestBodyValues:{}})}}catch(o){throw ec({error:o,url:e,requestBodyValues:{}})}},"getFromApi");function n_({mediaType:e,url:t,supportedUrls:n}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(n).map(([r,s])=>{const i=r.toLowerCase();return i==="*"||i==="*/*"?{mediaTypePrefix:"",regexes:s}:{mediaTypePrefix:i.replace(/\*/,""),regexes:s}}).filter(({mediaTypePrefix:r})=>e.startsWith(r)).flatMap(({regexes:r})=>r).some(r=>r.test(t))}a(n_,"isUrlSupported");function r_({apiKey:e,environmentVariableName:t,apiKeyParameterName:n="apiKey",description:r}){if(typeof e=="string")return e;if(e!=null)throw new Sr({message:`${r} API key must be a string.`});if(typeof process>"u")throw new Sr({message:`${r} API key is missing. Pass it using the '${n}' parameter. Environment variables is not supported in this environment.`});if(e=process.env[t],e==null)throw new Sr({message:`${r} API key is missing. Pass it using the '${n}' parameter or the ${t} environment variable.`});if(typeof e!="string")throw new Sr({message:`${r} API key must be a string. The value of the ${t} environment variable is not a string.`});return e}a(r_,"loadApiKey");function nr({settingValue:e,environmentVariableName:t}){if(typeof e=="string")return e;if(!(e!=null||typeof process>"u")&&(e=process.env[t],!(e==null||typeof e!="string")))return e}a(nr,"loadOptionalSetting");function o_(e){var t;const[n,r=""]=e.toLowerCase().split("/");return(t={mpeg:"mp3","x-wav":"wav",opus:"ogg",mp4:"m4a","x-m4a":"m4a"}[r])!=null?t:r}a(o_,"mediaTypeToExtension");var s_=/"__proto__"\s*:/,i_=/"constructor"\s*:/;function rc(e){const t=JSON.parse(e);return t===null||typeof t!="object"||s_.test(e)===!1&&i_.test(e)===!1?t:a_(t)}a(rc,"_parse");function a_(e){let t=[e];for(;t.length;){const n=t;t=[];for(const r of n){if(Object.prototype.hasOwnProperty.call(r,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(r,"constructor")&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const s in r){const i=r[s];i&&typeof i=="object"&&t.push(i)}}}return e}a(a_,"filter");function ws(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return rc(e)}try{return rc(e)}finally{Error.stackTraceLimit=t}}a(ws,"secureJsonParse");var Vr=Symbol.for("vercel.ai.validator");function u_(e){return{[Vr]:!0,validate:e}}a(u_,"validator");function l_(e){return typeof e=="object"&&e!==null&&Vr in e&&e[Vr]===!0&&"validate"in e}a(l_,"isValidator");function ge(e){let t;return()=>(t==null&&(t=e()),t)}a(ge,"lazyValidator");function c_(e){return l_(e)?e:typeof e=="function"?e():d_(e)}a(c_,"asValidator");function d_(e){return u_(async t=>{const n=await e["~standard"].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new Hn({value:t,cause:n.issues})}})}a(d_,"standardSchemaValidator");async function pt({value:e,schema:t}){const n=await ot({value:e,schema:t});if(!n.success)throw Hn.wrap({value:e,cause:n.error});return n.value}a(pt,"validateTypes");async function ot({value:e,schema:t}){const n=c_(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};const r=await n.validate(e);return r.success?{success:!0,value:r.value,rawValue:e}:{success:!1,error:Hn.wrap({value:e,cause:r.error}),rawValue:e}}catch(r){return{success:!1,error:Hn.wrap({value:e,cause:r}),rawValue:e}}}a(ot,"safeValidateTypes");async function p_({text:e,schema:t}){try{const n=ws(e);return t==null?n:pt({value:n,schema:t})}catch(n){throw Br.isInstance(n)||Hn.isInstance(n)?n:new Br({text:e,cause:n})}}a(p_,"parseJSON");async function At({text:e,schema:t}){try{const n=ws(e);return t==null?{success:!0,value:n,rawValue:n}:await ot({value:n,schema:t})}catch(n){return{success:!1,error:Br.isInstance(n)?n:new Br({text:e,cause:n}),rawValue:void 0}}}a(At,"safeParseJSON");function Gr(e){try{return ws(e),!0}catch{return!1}}a(Gr,"isParsableJson");function D_({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new cs).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await At({text:n,schema:t}))}}))}a(D_,"parseJsonEventStream");async function ze({provider:e,providerOptions:t,schema:n}){if(t?.[e]==null)return;const r=await ot({value:t[e],schema:n});if(!r.success)throw new ju({argument:"providerOptions",message:`invalid ${e} provider options`,cause:r.error});return r.value}a(ze,"parseProviderOptions");var f_=a(()=>globalThis.fetch,"getOriginalFetch2"),Ee=a(async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:s,abortSignal:i,fetch:o})=>oc({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:s,abortSignal:i,fetch:o}),"postJsonToApi"),m_=a(async({url:e,headers:t,formData:n,failedResponseHandler:r,successfulResponseHandler:s,abortSignal:i,fetch:o})=>oc({url:e,headers:t,body:{content:n,values:Object.fromEntries(n.entries())},failedResponseHandler:r,successfulResponseHandler:s,abortSignal:i,fetch:o}),"postFormDataToApi"),oc=a(async({url:e,headers:t={},body:n,successfulResponseHandler:r,failedResponseHandler:s,abortSignal:i,fetch:o=f_()})=>{try{const u=await o(e,{method:"POST",headers:wt(t,`ai-sdk/provider-utils/${tc}`,bs()),body:n.content,signal:i}),l=jt(u);if(!u.ok){let c;try{c=await s({response:u,url:e,requestBodyValues:n.values})}catch(d){throw zt(d)||Ce.isInstance(d)?d:new Ce({message:"Failed to process error response",cause:d,statusCode:u.status,url:e,responseHeaders:l,requestBodyValues:n.values})}throw c.value}try{return await r({response:u,url:e,requestBodyValues:n.values})}catch(c){throw c instanceof Error&&(zt(c)||Ce.isInstance(c))?c:new Ce({message:"Failed to process successful response",cause:c,statusCode:u.status,url:e,responseHeaders:l,requestBodyValues:n.values})}}catch(u){throw ec({error:u,url:e,requestBodyValues:n.values})}},"postToApi");function s1(e){return e}a(s1,"tool");function Zt({id:e,name:t,inputSchema:n,outputSchema:r}){return({execute:s,toModelOutput:i,onInputStart:o,onInputDelta:u,onInputAvailable:l,...c})=>({type:"provider-defined",id:e,name:t,args:c,inputSchema:n,outputSchema:r,execute:s,toModelOutput:i,onInputStart:o,onInputDelta:u,onInputAvailable:l})}a(Zt,"createProviderDefinedToolFactoryWithOutputSchema");async function et(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}a(et,"resolve");var Ge=a(({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:r,url:s,requestBodyValues:i})=>{const o=await r.text(),u=jt(r);if(o.trim()==="")return{responseHeaders:u,value:new Ce({message:r.statusText,url:s,requestBodyValues:i,statusCode:r.status,responseHeaders:u,responseBody:o,isRetryable:n?.(r)})};try{const l=await p_({text:o,schema:e});return{responseHeaders:u,value:new Ce({message:t(l),url:s,requestBodyValues:i,statusCode:r.status,responseHeaders:u,responseBody:o,data:l,isRetryable:n?.(r,l)})}}catch{return{responseHeaders:u,value:new Ce({message:r.statusText,url:s,requestBodyValues:i,statusCode:r.status,responseHeaders:u,responseBody:o,isRetryable:n?.(r)})}}},"createJsonErrorResponseHandler"),Lt=a(e=>async({response:t})=>{const n=jt(t);if(t.body==null)throw new Rh({});return{responseHeaders:n,value:D_({stream:t.body,schema:e})}},"createEventSourceResponseHandler"),Te=a(e=>async({response:t,url:n,requestBodyValues:r})=>{const s=await t.text(),i=await At({text:s,schema:e}),o=jt(t);if(!i.success)throw new Ce({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:o,responseBody:s,url:n,requestBodyValues:r});return{responseHeaders:o,value:i.value,rawValue:i.rawValue}},"createJsonResponseHandler"),h_=a(()=>async({response:e,url:t,requestBodyValues:n})=>{const r=jt(e);if(!e.body)throw new Ce({message:"Response body is empty",url:t,requestBodyValues:n,statusCode:e.status,responseHeaders:r,responseBody:void 0});try{const s=await e.arrayBuffer();return{responseHeaders:r,value:new Uint8Array(s)}}catch(s){throw new Ce({message:"Failed to read response as array buffer",url:t,requestBodyValues:n,statusCode:e.status,responseHeaders:r,responseBody:void 0,cause:s})}},"createBinaryResponseHandler"),g_=a((e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")},"getRelativePath"),v_=Symbol("Let zodToJsonSchema decide on which parser to use"),sc={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},y_=a(e=>typeof e=="string"?{...sc,name:e}:{...sc,...e},"getDefaultOptions");function Ze(){return{}}a(Ze,"parseAnyDef");function __(e,t){var n,r,s;const i={type:"array"};return(n=e.type)!=null&&n._def&&((s=(r=e.type)==null?void 0:r._def)==null?void 0:s.typeName)!==P.ZodAny&&(i.items=K(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}a(__,"parseArrayDef");function F_(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}a(F_,"parseBigintDef");function E_(){return{type:"boolean"}}a(E_,"parseBooleanDef");function ic(e,t){return K(e.type._def,t)}a(ic,"parseBrandedDef");var C_=a((e,t)=>K(e.innerType._def,t),"parseCatchDef");function ac(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((s,i)=>ac(e,t,s))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return b_(e)}}a(ac,"parseDateDef");var b_=a(e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t},"integerDateParser");function w_(e,t){return{...K(e.innerType._def,t),default:e.defaultValue()}}a(w_,"parseDefaultDef");function A_(e,t){return t.effectStrategy==="input"?K(e.schema._def,t):Ze()}a(A_,"parseEffectsDef");function k_(e){return{type:"string",enum:Array.from(e.values)}}a(k_,"parseEnumDef");var x_=a(e=>"type"in e&&e.type==="string"?!1:"allOf"in e,"isJsonSchema7AllOfType");function I_(e,t){const n=[K(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),K(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(s=>!!s),r=[];return n.forEach(s=>{if(x_(s))r.push(...s.allOf);else{let i=s;if("additionalProperties"in s&&s.additionalProperties===!1){const{additionalProperties:o,...u}=s;i=u}r.push(i)}}),r.length?{allOf:r}:void 0}a(I_,"parseIntersectionDef");function $_(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}a($_,"parseLiteralDef");var As=void 0,We={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:a(()=>(As===void 0&&(As=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),As),"emoji"),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function uc(e,t){const n={type:"string"};if(e.checks)for(const r of e.checks)switch(r.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"email":switch(t.emailStrategy){case"format:email":He(n,"email",r.message,t);break;case"format:idn-email":He(n,"idn-email",r.message,t);break;case"pattern:zod":Oe(n,We.email,r.message,t);break}break;case"url":He(n,"uri",r.message,t);break;case"uuid":He(n,"uuid",r.message,t);break;case"regex":Oe(n,r.regex,r.message,t);break;case"cuid":Oe(n,We.cuid,r.message,t);break;case"cuid2":Oe(n,We.cuid2,r.message,t);break;case"startsWith":Oe(n,RegExp(`^${ks(r.value,t)}`),r.message,t);break;case"endsWith":Oe(n,RegExp(`${ks(r.value,t)}$`),r.message,t);break;case"datetime":He(n,"date-time",r.message,t);break;case"date":He(n,"date",r.message,t);break;case"time":He(n,"time",r.message,t);break;case"duration":He(n,"duration",r.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"includes":{Oe(n,RegExp(ks(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&He(n,"ipv4",r.message,t),r.version!=="v4"&&He(n,"ipv6",r.message,t);break}case"base64url":Oe(n,We.base64url,r.message,t);break;case"jwt":Oe(n,We.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&Oe(n,We.ipv4Cidr,r.message,t),r.version!=="v4"&&Oe(n,We.ipv6Cidr,r.message,t);break}case"emoji":Oe(n,We.emoji(),r.message,t);break;case"ulid":{Oe(n,We.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{He(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{Oe(n,We.base64,r.message,t);break}}break}case"nanoid":Oe(n,We.nanoid,r.message,t)}return n}a(uc,"parseStringDef");function ks(e,t){return t.patternStrategy==="escape"?S_(e):e}a(ks,"escapeLiteralCheckValue");var B_=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function S_(e){let t="";for(let n=0;n<e.length;n++)B_.has(e[n])||(t+="\\"),t+=e[n];return t}a(S_,"escapeNonAlphaNumeric");function He(e,t,n,r){var s;e.format||(s=e.anyOf)!=null&&s.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}a(He,"addFormat");function Oe(e,t,n,r){var s;e.pattern||(s=e.allOf)!=null&&s.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:lc(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=lc(t,r)}a(Oe,"addPattern");function lc(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},s=r.i?e.source.toLowerCase():e.source;let i="",o=!1,u=!1,l=!1;for(let c=0;c<s.length;c++){if(o){i+=s[c],o=!1;continue}if(r.i){if(u){if(s[c].match(/[a-z]/)){l?(i+=s[c],i+=`${s[c-2]}-${s[c]}`.toUpperCase(),l=!1):s[c+1]==="-"&&((n=s[c+2])!=null&&n.match(/[a-z]/))?(i+=s[c],l=!0):i+=`${s[c]}${s[c].toUpperCase()}`;continue}}else if(s[c].match(/[a-z]/)){i+=`[${s[c]}${s[c].toUpperCase()}]`;continue}}if(r.m){if(s[c]==="^"){i+=`(^|(?<=[\r
|
|
117
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of this.seen.entries()){const p=d[1];if(t===d[0]){o(d);continue}if(r.external){const f=r.external.registry.get(d[0])?.id;if(t!==d[0]&&f){o(d);continue}}if(this.metadataRegistry.get(d[0])?.id){o(d);continue}if(p.cycle){o(d);continue}if(p.count>1&&r.reused==="ref"){o(d);continue}}const u=a((d,p)=>{const h=this.seen.get(d),f=h.def??h.schema,D={...f};if(h.ref===null)return;const g=h.ref;if(h.ref=null,g){u(g,p);const v=this.seen.get(g).schema;v.$ref&&p.target==="draft-7"?(f.allOf=f.allOf??[],f.allOf.push(v)):(Object.assign(f,v),Object.assign(f,D))}h.isParent||this.override({zodSchema:d,jsonSchema:f,path:h.path??[]})},"flattenRef");for(const d of[...this.seen.entries()].reverse())u(d[0],{target:this.target});const l={};if(this.target==="draft-2020-12"?l.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?l.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),r.external?.uri){const d=r.external.registry.get(t)?.id;if(!d)throw new Error("Schema is missing an `id` property");l.$id=r.external.uri(d)}Object.assign(l,s.def);const c=r.external?.defs??{};for(const d of this.seen.entries()){const p=d[1];p.def&&p.defId&&(c[p.defId]=p.def)}r.external||Object.keys(c).length>0&&(this.target==="draft-2020-12"?l.$defs=c:l.definitions=c);try{return JSON.parse(JSON.stringify(l))}catch{throw new Error("Error converting schema to JSON.")}}};a(hi,"JSONSchemaGenerator");let Vr=hi;function U0(e,t){if(e instanceof Ur){const r=new Vr(t),s={};for(const u of e._idmap.entries()){const[l,c]=u;r.process(c)}const i={},o={registry:e,uri:t?.uri,defs:s};for(const u of e._idmap.entries()){const[l,c]=u;i[l]=r.emit(c,{...t,external:o})}if(Object.keys(s).length>0){const u=r.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[u]:s}}return{schemas:i}}const n=new Vr(t);return n.process(e),n.emit(e,t)}a(U0,"toJSONSchema");function Ee(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;switch(s.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Ee(s.element,n);case"object":{for(const i in s.shape)if(Ee(s.shape[i],n))return!0;return!1}case"union":{for(const i of s.options)if(Ee(i,n))return!0;return!1}case"intersection":return Ee(s.left,n)||Ee(s.right,n);case"tuple":{for(const i of s.items)if(Ee(i,n))return!0;return!!(s.rest&&Ee(s.rest,n))}case"record":return Ee(s.keyType,n)||Ee(s.valueType,n);case"map":return Ee(s.keyType,n)||Ee(s.valueType,n);case"set":return Ee(s.valueType,n);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ee(s.innerType,n);case"lazy":return Ee(s.getter(),n);case"default":return Ee(s.innerType,n);case"prefault":return Ee(s.innerType,n);case"custom":return!1;case"transform":return!0;case"pipe":return Ee(s.in,n)||Ee(s.out,n);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${s.type}`)}a(Ee,"isTransforming");const q0=A("ZodISODateTime",(e,t)=>{dv.init(e,t),fe.init(e,t)});function V0(e){return v0(q0,e)}a(V0,"datetime");const G0=A("ZodISODate",(e,t)=>{pv.init(e,t),fe.init(e,t)});function W0(e){return y0(G0,e)}a(W0,"date");const H0=A("ZodISOTime",(e,t)=>{Dv.init(e,t),fe.init(e,t)});function J0(e){return _0(H0,e)}a(J0,"time");const K0=A("ZodISODuration",(e,t)=>{fv.init(e,t),fe.init(e,t)});function Y0(e){return F0(K0,e)}a(Y0,"duration");const X0=a((e,t)=>{fl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:a(n=>ug(e,n),"value")},flatten:{value:a(n=>ag(e,n),"value")},addIssue:{value:a(n=>e.issues.push(n),"value")},addIssues:{value:a(n=>e.issues.push(...n),"value")},isEmpty:{get(){return e.issues.length===0}}})},"initializer"),Gr=A("ZodError",X0,{Parent:Error}),Q0=lg(Gr),ey=cg(Gr),ty=hl(Gr),Ul=gl(Gr),se=A("ZodType",(e,t)=>(Q.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),e.clone=(n,r)=>kt(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>Q0(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>ty(e,n,r),e.parseAsync=async(n,r)=>ey(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ul(e,n,r),e.spa=e.safeParseAsync,e.refine=(n,r)=>e.check(Yy(n,r)),e.superRefine=n=>e.check(Xy(n)),e.overwrite=n=>e.check(nr(n)),e.optional=()=>Jl(e),e.nullable=()=>Kl(e),e.nullish=()=>Jl(Kl(e)),e.nonoptional=n=>Ly(e,n),e.array=()=>$(e),e.or=n=>X([e,n]),e.and=n=>Sy(e,n),e.transform=n=>Xl(e,Py(n)),e.default=n=>jy(e,n),e.prefault=n=>Zy(e,n),e.catch=n=>qy(e,n),e.pipe=n=>Xl(e,n),e.readonly=()=>Wy(e),e.describe=n=>{const r=e.clone();return tr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return tr.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return tr.get(e);const r=e.clone();return tr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ql=A("_ZodString",(e,t)=>{vs.init(e,t),se.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(I0(...r)),e.includes=(...r)=>e.check(T0(...r)),e.startsWith=(...r)=>e.check(O0(...r)),e.endsWith=(...r)=>e.check(R0(...r)),e.min=(...r)=>e.check(qr(...r)),e.max=(...r)=>e.check(Zl(...r)),e.length=(...r)=>e.check(Ll(...r)),e.nonempty=(...r)=>e.check(qr(1,...r)),e.lowercase=r=>e.check(B0(r)),e.uppercase=r=>e.check(S0(r)),e.trim=()=>e.check(N0()),e.normalize=(...r)=>e.check(P0(...r)),e.toLowerCase=()=>e.check(M0()),e.toUpperCase=()=>e.check(j0())}),ny=A("ZodString",(e,t)=>{vs.init(e,t),ql.init(e,t),e.email=n=>e.check(Yv(ry,n)),e.url=n=>e.check(n0(oy,n)),e.jwt=n=>e.check(g0(yy,n)),e.emoji=n=>e.check(r0(sy,n)),e.guid=n=>e.check(Nl(Vl,n)),e.uuid=n=>e.check(Xv(Wr,n)),e.uuidv4=n=>e.check(Qv(Wr,n)),e.uuidv6=n=>e.check(e0(Wr,n)),e.uuidv7=n=>e.check(t0(Wr,n)),e.nanoid=n=>e.check(o0(iy,n)),e.guid=n=>e.check(Nl(Vl,n)),e.cuid=n=>e.check(s0(ay,n)),e.cuid2=n=>e.check(i0(uy,n)),e.ulid=n=>e.check(a0(ly,n)),e.base64=n=>e.check(f0(hy,n)),e.base64url=n=>e.check(m0(gy,n)),e.xid=n=>e.check(u0(cy,n)),e.ksuid=n=>e.check(l0(dy,n)),e.ipv4=n=>e.check(c0(py,n)),e.ipv6=n=>e.check(d0(Dy,n)),e.cidrv4=n=>e.check(p0(fy,n)),e.cidrv6=n=>e.check(D0(my,n)),e.e164=n=>e.check(h0(vy,n)),e.datetime=n=>e.check(V0(n)),e.date=n=>e.check(W0(n)),e.time=n=>e.check(J0(n)),e.duration=n=>e.check(Y0(n))});function m(e){return Kv(ny,e)}a(m,"string");const fe=A("ZodStringFormat",(e,t)=>{le.init(e,t),ql.init(e,t)}),ry=A("ZodEmail",(e,t)=>{nv.init(e,t),fe.init(e,t)}),Vl=A("ZodGUID",(e,t)=>{ev.init(e,t),fe.init(e,t)}),Wr=A("ZodUUID",(e,t)=>{tv.init(e,t),fe.init(e,t)}),oy=A("ZodURL",(e,t)=>{rv.init(e,t),fe.init(e,t)}),sy=A("ZodEmoji",(e,t)=>{ov.init(e,t),fe.init(e,t)}),iy=A("ZodNanoID",(e,t)=>{sv.init(e,t),fe.init(e,t)}),ay=A("ZodCUID",(e,t)=>{iv.init(e,t),fe.init(e,t)}),uy=A("ZodCUID2",(e,t)=>{av.init(e,t),fe.init(e,t)}),ly=A("ZodULID",(e,t)=>{uv.init(e,t),fe.init(e,t)}),cy=A("ZodXID",(e,t)=>{lv.init(e,t),fe.init(e,t)}),dy=A("ZodKSUID",(e,t)=>{cv.init(e,t),fe.init(e,t)}),py=A("ZodIPv4",(e,t)=>{mv.init(e,t),fe.init(e,t)}),Dy=A("ZodIPv6",(e,t)=>{hv.init(e,t),fe.init(e,t)}),fy=A("ZodCIDRv4",(e,t)=>{gv.init(e,t),fe.init(e,t)}),my=A("ZodCIDRv6",(e,t)=>{vv.init(e,t),fe.init(e,t)}),hy=A("ZodBase64",(e,t)=>{yv.init(e,t),fe.init(e,t)}),gy=A("ZodBase64URL",(e,t)=>{Fv.init(e,t),fe.init(e,t)}),vy=A("ZodE164",(e,t)=>{Ev.init(e,t),fe.init(e,t)}),yy=A("ZodJWT",(e,t)=>{bv.init(e,t),fe.init(e,t)}),Es=A("ZodNumber",(e,t)=>{Al.init(e,t),se.init(e,t),e.gt=(r,s)=>e.check(jl(r,s)),e.gte=(r,s)=>e.check(Fs(r,s)),e.min=(r,s)=>e.check(Fs(r,s)),e.lt=(r,s)=>e.check(Ml(r,s)),e.lte=(r,s)=>e.check(_s(r,s)),e.max=(r,s)=>e.check(_s(r,s)),e.int=r=>e.check(Gl(r)),e.safe=r=>e.check(Gl(r)),e.positive=r=>e.check(jl(0,r)),e.nonnegative=r=>e.check(Fs(0,r)),e.negative=r=>e.check(Ml(0,r)),e.nonpositive=r=>e.check(_s(0,r)),e.multipleOf=(r,s)=>e.check(zl(r,s)),e.step=(r,s)=>e.check(zl(r,s)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function w(e){return E0(Es,e)}a(w,"number$1");const _y=A("ZodNumberFormat",(e,t)=>{wv.init(e,t),Es.init(e,t)});function Gl(e){return b0(_y,e)}a(Gl,"int");const Fy=A("ZodBoolean",(e,t)=>{Av.init(e,t),se.init(e,t)});function Ae(e){return w0(Fy,e)}a(Ae,"boolean");const Ey=A("ZodNull",(e,t)=>{kv.init(e,t),se.init(e,t)});function Cy(e){return A0(Ey,e)}a(Cy,"_null");const by=A("ZodAny",(e,t)=>{xv.init(e,t),se.init(e,t)});function Me(){return k0(by)}a(Me,"any");const wy=A("ZodUnknown",(e,t)=>{$v.init(e,t),se.init(e,t)});function st(){return x0(wy)}a(st,"unknown");const Ay=A("ZodNever",(e,t)=>{Iv.init(e,t),se.init(e,t)});function ky(e){return $0(Ay,e)}a(ky,"never");const xy=A("ZodArray",(e,t)=>{Bv.init(e,t),se.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(qr(n,r)),e.nonempty=n=>e.check(qr(1,n)),e.max=(n,r)=>e.check(Zl(n,r)),e.length=(n,r)=>e.check(Ll(n,r)),e.unwrap=()=>e.element});function $(e,t){return z0(xy,e,t)}a($,"array");const $y=A("ZodObject",(e,t)=>{Sv.init(e,t),se.init(e,t),H(e,"shape",()=>t.shape),e.keyof=()=>ie(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:st()}),e.loose=()=>e.clone({...e._zod.def,catchall:st()}),e.strict=()=>e.clone({...e._zod.def,catchall:ky()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>rg(e,n),e.merge=n=>og(e,n),e.pick=n=>tg(e,n),e.omit=n=>ng(e,n),e.partial=(...n)=>sg(Hl,e,n[0]),e.required=(...n)=>ig(Yl,e,n[0])});function y(e,t){const n={type:"object",get shape(){return ms(this,"shape",{...e}),this.shape},...T(t)};return new $y(n)}a(y,"object$1");const Wl=A("ZodUnion",(e,t)=>{Il.init(e,t),se.init(e,t),e.options=t.options});function X(e,t){return new Wl({type:"union",options:e,...T(t)})}a(X,"union");const Iy=A("ZodDiscriminatedUnion",(e,t)=>{Wl.init(e,t),Tv.init(e,t)});function ke(e,t,n){return new Iy({type:"union",options:t,discriminator:e,...T(n)})}a(ke,"discriminatedUnion");const By=A("ZodIntersection",(e,t)=>{Ov.init(e,t),se.init(e,t)});function Sy(e,t){return new By({type:"intersection",left:e,right:t})}a(Sy,"intersection");const Ty=A("ZodRecord",(e,t)=>{Rv.init(e,t),se.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ge(e,t,n){return new Ty({type:"record",keyType:e,valueType:t,...T(n)})}a(ge,"record");const Cs=A("ZodEnum",(e,t)=>{Pv.init(e,t),se.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,s)=>{const i={};for(const o of r)if(n.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Cs({...t,checks:[],...T(s),entries:i})},e.exclude=(r,s)=>{const i={...t.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Cs({...t,checks:[],...T(s),entries:i})}});function ie(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Cs({type:"enum",entries:n,...T(t)})}a(ie,"_enum");const Oy=A("ZodLiteral",(e,t)=>{Nv.init(e,t),se.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function k(e,t){return new Oy({type:"literal",values:Array.isArray(e)?e:[e],...T(t)})}a(k,"literal");const Ry=A("ZodTransform",(e,t)=>{Mv.init(e,t),se.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=i=>{if(typeof i=="string")n.issues.push(er(i,n.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),o.continue??(o.continue=!0),n.issues.push(er(o))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function Py(e){return new Ry({type:"transform",transform:e})}a(Py,"transform");const Hl=A("ZodOptional",(e,t)=>{jv.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Jl(e){return new Hl({type:"optional",innerType:e})}a(Jl,"optional");const Ny=A("ZodNullable",(e,t)=>{zv.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Kl(e){return new Ny({type:"nullable",innerType:e})}a(Kl,"nullable");const My=A("ZodDefault",(e,t)=>{Zv.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function jy(e,t){return new My({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}a(jy,"_default");const zy=A("ZodPrefault",(e,t)=>{Lv.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Zy(e,t){return new zy({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}a(Zy,"prefault");const Yl=A("ZodNonOptional",(e,t)=>{Uv.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ly(e,t){return new Yl({type:"nonoptional",innerType:e,...T(t)})}a(Ly,"nonoptional");const Uy=A("ZodCatch",(e,t)=>{qv.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qy(e,t){return new Uy({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}a(qy,"_catch");const Vy=A("ZodPipe",(e,t)=>{Vv.init(e,t),se.init(e,t),e.in=t.in,e.out=t.out});function Xl(e,t){return new Vy({type:"pipe",in:e,out:t})}a(Xl,"pipe");const Gy=A("ZodReadonly",(e,t)=>{Gv.init(e,t),se.init(e,t)});function Wy(e){return new Gy({type:"readonly",innerType:e})}a(Wy,"readonly");const Hy=A("ZodLazy",(e,t)=>{Wv.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.getter()});function Ql(e){return new Hy({type:"lazy",getter:e})}a(Ql,"lazy");const bs=A("ZodCustom",(e,t)=>{Hv.init(e,t),se.init(e,t)});function Jy(e){const t=new Re({check:"custom"});return t._zod.check=e,t}a(Jy,"check");function Ky(e,t){return Z0(bs,e??(()=>!0),t)}a(Ky,"custom");function Yy(e,t={}){return L0(bs,e,t)}a(Yy,"refine");function Xy(e){const t=Jy(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(er(r,n.value,t._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),n.issues.push(er(s))}},e(n.value,n)));return t}a(Xy,"superRefine");function Hr(e,t={error:`Input not instance of ${e.name}`}){const n=new bs({type:"custom",check:"custom",fn:a(r=>r instanceof e,"fn"),abort:!0,...T(t)});return n._zod.bag.Class=e,n}a(Hr,"_instanceof");function Qy(e){return C0(Es,e)}a(Qy,"number");var N;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(N||(N={}));function _e(...e){return e.reduce((t,n)=>({...t,...n??{}}),{})}a(_e,"combineHeaders");async function e_(e,t){if(e==null)return Promise.resolve();const n=t?.abortSignal;return new Promise((r,s)=>{if(n?.aborted){s(ec());return}const i=setTimeout(()=>{o(),r()},e),o=a(()=>{clearTimeout(i),n?.removeEventListener("abort",u)},"cleanup"),u=a(()=>{o(),s(ec())},"onAbort");n?.addEventListener("abort",u)})}a(e_,"delay");function ec(){return new DOMException("Delay was aborted","AbortError")}a(ec,"createAbortError");function Ut(e){return Object.fromEntries([...e.headers])}a(Ut,"extractResponseHeaders");var rr=a(({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const s=a(()=>{const i=n.length,o=new Array(t);for(let u=0;u<t;u++)o[u]=n[Math.random()*i|0];return o.join("")},"generator");if(e==null)return s;if(n.includes(r))throw new Zu({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${s()}`},"createIdGenerator"),je=rr();function tc(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}a(tc,"getErrorMessage");function qt(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}a(qt,"isAbortError");var t_=["fetch failed","failed to fetch"];function nc({error:e,url:t,requestBodyValues:n}){if(qt(e))return e;if(e instanceof TypeError&&t_.includes(e.message.toLowerCase())){const r=e.cause;if(r!=null)return new be({message:`Cannot connect to API: ${r.message}`,cause:r,url:t,requestBodyValues:n,isRetryable:!0})}return e}a(nc,"handleFetchError");function ws(e=globalThis){var t,n,r;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(r=(n=e.process)==null?void 0:n.versions)!=null&&r.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}a(ws,"getRuntimeEnvironmentUserAgent");function n_(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,r)=>{t[r.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}a(n_,"normalizeHeaders");function $t(e,...t){const n=new Headers(n_(e)),r=n.get("user-agent")||"";return n.set("user-agent",[r,...t].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}a($t,"withUserAgentSuffix");var rc="3.0.18",r_=a(()=>globalThis.fetch,"getOriginalFetch"),oc=a(async({url:e,headers:t={},successfulResponseHandler:n,failedResponseHandler:r,abortSignal:s,fetch:i=r_()})=>{try{const o=await i(e,{method:"GET",headers:$t(t,`ai-sdk/provider-utils/${rc}`,ws()),signal:s}),u=Ut(o);if(!o.ok){let l;try{l=await r({response:o,url:e,requestBodyValues:{}})}catch(c){throw qt(c)||be.isInstance(c)?c:new be({message:"Failed to process error response",cause:c,statusCode:o.status,url:e,responseHeaders:u,requestBodyValues:{}})}throw l.value}try{return await n({response:o,url:e,requestBodyValues:{}})}catch(l){throw l instanceof Error&&(qt(l)||be.isInstance(l))?l:new be({message:"Failed to process successful response",cause:l,statusCode:o.status,url:e,responseHeaders:u,requestBodyValues:{}})}}catch(o){throw nc({error:o,url:e,requestBodyValues:{}})}},"getFromApi");function o_({mediaType:e,url:t,supportedUrls:n}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(n).map(([r,s])=>{const i=r.toLowerCase();return i==="*"||i==="*/*"?{mediaTypePrefix:"",regexes:s}:{mediaTypePrefix:i.replace(/\*/,""),regexes:s}}).filter(({mediaTypePrefix:r})=>e.startsWith(r)).flatMap(({regexes:r})=>r).some(r=>r.test(t))}a(o_,"isUrlSupported");function s_({apiKey:e,environmentVariableName:t,apiKeyParameterName:n="apiKey",description:r}){if(typeof e=="string")return e;if(e!=null)throw new Pr({message:`${r} API key must be a string.`});if(typeof process>"u")throw new Pr({message:`${r} API key is missing. Pass it using the '${n}' parameter. Environment variables is not supported in this environment.`});if(e=process.env[t],e==null)throw new Pr({message:`${r} API key is missing. Pass it using the '${n}' parameter or the ${t} environment variable.`});if(typeof e!="string")throw new Pr({message:`${r} API key must be a string. The value of the ${t} environment variable is not a string.`});return e}a(s_,"loadApiKey");function or({settingValue:e,environmentVariableName:t}){if(typeof e=="string")return e;if(!(e!=null||typeof process>"u")&&(e=process.env[t],!(e==null||typeof e!="string")))return e}a(or,"loadOptionalSetting");function i_(e){var t;const[n,r=""]=e.toLowerCase().split("/");return(t={mpeg:"mp3","x-wav":"wav",opus:"ogg",mp4:"m4a","x-m4a":"m4a"}[r])!=null?t:r}a(i_,"mediaTypeToExtension");var a_=/"__proto__"\s*:/,u_=/"constructor"\s*:/;function sc(e){const t=JSON.parse(e);return t===null||typeof t!="object"||a_.test(e)===!1&&u_.test(e)===!1?t:l_(t)}a(sc,"_parse");function l_(e){let t=[e];for(;t.length;){const n=t;t=[];for(const r of n){if(Object.prototype.hasOwnProperty.call(r,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(r,"constructor")&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const s in r){const i=r[s];i&&typeof i=="object"&&t.push(i)}}}return e}a(l_,"filter");function As(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return sc(e)}try{return sc(e)}finally{Error.stackTraceLimit=t}}a(As,"secureJsonParse");var Jr=Symbol.for("vercel.ai.validator");function c_(e){return{[Jr]:!0,validate:e}}a(c_,"validator");function d_(e){return typeof e=="object"&&e!==null&&Jr in e&&e[Jr]===!0&&"validate"in e}a(d_,"isValidator");function ve(e){let t;return()=>(t==null&&(t=e()),t)}a(ve,"lazyValidator");function p_(e){return d_(e)?e:typeof e=="function"?e():D_(e)}a(p_,"asValidator");function D_(e){return c_(async t=>{const n=await e["~standard"].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new Kn({value:t,cause:n.issues})}})}a(D_,"standardSchemaValidator");async function ft({value:e,schema:t}){const n=await it({value:e,schema:t});if(!n.success)throw Kn.wrap({value:e,cause:n.error});return n.value}a(ft,"validateTypes");async function it({value:e,schema:t}){const n=p_(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};const r=await n.validate(e);return r.success?{success:!0,value:r.value,rawValue:e}:{success:!1,error:Kn.wrap({value:e,cause:r.error}),rawValue:e}}catch(r){return{success:!1,error:Kn.wrap({value:e,cause:r}),rawValue:e}}}a(it,"safeValidateTypes");async function f_({text:e,schema:t}){try{const n=As(e);return t==null?n:ft({value:n,schema:t})}catch(n){throw Rr.isInstance(n)||Kn.isInstance(n)?n:new Rr({text:e,cause:n})}}a(f_,"parseJSON");async function It({text:e,schema:t}){try{const n=As(e);return t==null?{success:!0,value:n,rawValue:n}:await it({value:n,schema:t})}catch(n){return{success:!1,error:Rr.isInstance(n)?n:new Rr({text:e,cause:n}),rawValue:void 0}}}a(It,"safeParseJSON");function Kr(e){try{return As(e),!0}catch{return!1}}a(Kr,"isParsableJson");function m_({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new ds).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await It({text:n,schema:t}))}}))}a(m_,"parseJsonEventStream");async function ze({provider:e,providerOptions:t,schema:n}){if(t?.[e]==null)return;const r=await it({value:t[e],schema:n});if(!r.success)throw new Zu({argument:"providerOptions",message:`invalid ${e} provider options`,cause:r.error});return r.value}a(ze,"parseProviderOptions");var h_=a(()=>globalThis.fetch,"getOriginalFetch2"),Ce=a(async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:s,abortSignal:i,fetch:o})=>ic({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:s,abortSignal:i,fetch:o}),"postJsonToApi"),g_=a(async({url:e,headers:t,formData:n,failedResponseHandler:r,successfulResponseHandler:s,abortSignal:i,fetch:o})=>ic({url:e,headers:t,body:{content:n,values:Object.fromEntries(n.entries())},failedResponseHandler:r,successfulResponseHandler:s,abortSignal:i,fetch:o}),"postFormDataToApi"),ic=a(async({url:e,headers:t={},body:n,successfulResponseHandler:r,failedResponseHandler:s,abortSignal:i,fetch:o=h_()})=>{try{const u=await o(e,{method:"POST",headers:$t(t,`ai-sdk/provider-utils/${rc}`,ws()),body:n.content,signal:i}),l=Ut(u);if(!u.ok){let c;try{c=await s({response:u,url:e,requestBodyValues:n.values})}catch(d){throw qt(d)||be.isInstance(d)?d:new be({message:"Failed to process error response",cause:d,statusCode:u.status,url:e,responseHeaders:l,requestBodyValues:n.values})}throw c.value}try{return await r({response:u,url:e,requestBodyValues:n.values})}catch(c){throw c instanceof Error&&(qt(c)||be.isInstance(c))?c:new be({message:"Failed to process successful response",cause:c,statusCode:u.status,url:e,responseHeaders:l,requestBodyValues:n.values})}}catch(u){throw nc({error:u,url:e,requestBodyValues:n.values})}},"postToApi");function i1(e){return e}a(i1,"tool");function Vt({id:e,name:t,inputSchema:n,outputSchema:r}){return({execute:s,toModelOutput:i,onInputStart:o,onInputDelta:u,onInputAvailable:l,...c})=>({type:"provider-defined",id:e,name:t,args:c,inputSchema:n,outputSchema:r,execute:s,toModelOutput:i,onInputStart:o,onInputDelta:u,onInputAvailable:l})}a(Vt,"createProviderDefinedToolFactoryWithOutputSchema");async function nt(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}a(nt,"resolve");var We=a(({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:r,url:s,requestBodyValues:i})=>{const o=await r.text(),u=Ut(r);if(o.trim()==="")return{responseHeaders:u,value:new be({message:r.statusText,url:s,requestBodyValues:i,statusCode:r.status,responseHeaders:u,responseBody:o,isRetryable:n?.(r)})};try{const l=await f_({text:o,schema:e});return{responseHeaders:u,value:new be({message:t(l),url:s,requestBodyValues:i,statusCode:r.status,responseHeaders:u,responseBody:o,data:l,isRetryable:n?.(r,l)})}}catch{return{responseHeaders:u,value:new be({message:r.statusText,url:s,requestBodyValues:i,statusCode:r.status,responseHeaders:u,responseBody:o,isRetryable:n?.(r)})}}},"createJsonErrorResponseHandler"),Gt=a(e=>async({response:t})=>{const n=Ut(t);if(t.body==null)throw new Nh({});return{responseHeaders:n,value:m_({stream:t.body,schema:e})}},"createEventSourceResponseHandler"),Te=a(e=>async({response:t,url:n,requestBodyValues:r})=>{const s=await t.text(),i=await It({text:s,schema:e}),o=Ut(t);if(!i.success)throw new be({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:o,responseBody:s,url:n,requestBodyValues:r});return{responseHeaders:o,value:i.value,rawValue:i.rawValue}},"createJsonResponseHandler"),v_=a(()=>async({response:e,url:t,requestBodyValues:n})=>{const r=Ut(e);if(!e.body)throw new be({message:"Response body is empty",url:t,requestBodyValues:n,statusCode:e.status,responseHeaders:r,responseBody:void 0});try{const s=await e.arrayBuffer();return{responseHeaders:r,value:new Uint8Array(s)}}catch(s){throw new be({message:"Failed to read response as array buffer",url:t,requestBodyValues:n,statusCode:e.status,responseHeaders:r,responseBody:void 0,cause:s})}},"createBinaryResponseHandler"),y_=a((e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")},"getRelativePath"),__=Symbol("Let zodToJsonSchema decide on which parser to use"),ac={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},F_=a(e=>typeof e=="string"?{...ac,name:e}:{...ac,...e},"getDefaultOptions");function Ze(){return{}}a(Ze,"parseAnyDef");function E_(e,t){var n,r,s;const i={type:"array"};return(n=e.type)!=null&&n._def&&((s=(r=e.type)==null?void 0:r._def)==null?void 0:s.typeName)!==N.ZodAny&&(i.items=Y(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}a(E_,"parseArrayDef");function C_(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}a(C_,"parseBigintDef");function b_(){return{type:"boolean"}}a(b_,"parseBooleanDef");function uc(e,t){return Y(e.type._def,t)}a(uc,"parseBrandedDef");var w_=a((e,t)=>Y(e.innerType._def,t),"parseCatchDef");function lc(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((s,i)=>lc(e,t,s))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return A_(e)}}a(lc,"parseDateDef");var A_=a(e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t},"integerDateParser");function k_(e,t){return{...Y(e.innerType._def,t),default:e.defaultValue()}}a(k_,"parseDefaultDef");function x_(e,t){return t.effectStrategy==="input"?Y(e.schema._def,t):Ze()}a(x_,"parseEffectsDef");function $_(e){return{type:"string",enum:Array.from(e.values)}}a($_,"parseEnumDef");var I_=a(e=>"type"in e&&e.type==="string"?!1:"allOf"in e,"isJsonSchema7AllOfType");function B_(e,t){const n=[Y(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Y(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(s=>!!s),r=[];return n.forEach(s=>{if(I_(s))r.push(...s.allOf);else{let i=s;if("additionalProperties"in s&&s.additionalProperties===!1){const{additionalProperties:o,...u}=s;i=u}r.push(i)}}),r.length?{allOf:r}:void 0}a(B_,"parseIntersectionDef");function S_(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}a(S_,"parseLiteralDef");var ks=void 0,He={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:a(()=>(ks===void 0&&(ks=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ks),"emoji"),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function cc(e,t){const n={type:"string"};if(e.checks)for(const r of e.checks)switch(r.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"email":switch(t.emailStrategy){case"format:email":Je(n,"email",r.message,t);break;case"format:idn-email":Je(n,"idn-email",r.message,t);break;case"pattern:zod":Oe(n,He.email,r.message,t);break}break;case"url":Je(n,"uri",r.message,t);break;case"uuid":Je(n,"uuid",r.message,t);break;case"regex":Oe(n,r.regex,r.message,t);break;case"cuid":Oe(n,He.cuid,r.message,t);break;case"cuid2":Oe(n,He.cuid2,r.message,t);break;case"startsWith":Oe(n,RegExp(`^${xs(r.value,t)}`),r.message,t);break;case"endsWith":Oe(n,RegExp(`${xs(r.value,t)}$`),r.message,t);break;case"datetime":Je(n,"date-time",r.message,t);break;case"date":Je(n,"date",r.message,t);break;case"time":Je(n,"time",r.message,t);break;case"duration":Je(n,"duration",r.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"includes":{Oe(n,RegExp(xs(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&Je(n,"ipv4",r.message,t),r.version!=="v4"&&Je(n,"ipv6",r.message,t);break}case"base64url":Oe(n,He.base64url,r.message,t);break;case"jwt":Oe(n,He.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&Oe(n,He.ipv4Cidr,r.message,t),r.version!=="v4"&&Oe(n,He.ipv6Cidr,r.message,t);break}case"emoji":Oe(n,He.emoji(),r.message,t);break;case"ulid":{Oe(n,He.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Je(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{Oe(n,He.base64,r.message,t);break}}break}case"nanoid":Oe(n,He.nanoid,r.message,t)}return n}a(cc,"parseStringDef");function xs(e,t){return t.patternStrategy==="escape"?O_(e):e}a(xs,"escapeLiteralCheckValue");var T_=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function O_(e){let t="";for(let n=0;n<e.length;n++)T_.has(e[n])||(t+="\\"),t+=e[n];return t}a(O_,"escapeNonAlphaNumeric");function Je(e,t,n,r){var s;e.format||(s=e.anyOf)!=null&&s.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}a(Je,"addFormat");function Oe(e,t,n,r){var s;e.pattern||(s=e.allOf)!=null&&s.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:dc(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=dc(t,r)}a(Oe,"addPattern");function dc(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},s=r.i?e.source.toLowerCase():e.source;let i="",o=!1,u=!1,l=!1;for(let c=0;c<s.length;c++){if(o){i+=s[c],o=!1;continue}if(r.i){if(u){if(s[c].match(/[a-z]/)){l?(i+=s[c],i+=`${s[c-2]}-${s[c]}`.toUpperCase(),l=!1):s[c+1]==="-"&&((n=s[c+2])!=null&&n.match(/[a-z]/))?(i+=s[c],l=!0):i+=`${s[c]}${s[c].toUpperCase()}`;continue}}else if(s[c].match(/[a-z]/)){i+=`[${s[c]}${s[c].toUpperCase()}]`;continue}}if(r.m){if(s[c]==="^"){i+=`(^|(?<=[\r
|
|
118
118
|
]))`;continue}else if(s[c]==="$"){i+=`($|(?=[\r
|
|
119
119
|
]))`;continue}}if(r.s&&s[c]==="."){i+=u?`${s[c]}\r
|
|
120
120
|
`:`[${s[c]}\r
|
|
121
|
-
]`;continue}i+=s[c],s[c]==="\\"?o=!0:u&&s[c]==="]"?u=!1:!u&&s[c]==="["&&(u=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}a(lc,"stringifyRegExpWithFlags");function cc(e,t){var n,r,s,i,o,u;const l={type:"object",additionalProperties:(n=K(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===P.ZodString&&((s=e.keyType._def.checks)!=null&&s.length)){const{type:c,...d}=uc(e.keyType._def,t);return{...l,propertyNames:d}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===P.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((o=e.keyType)==null?void 0:o._def.typeName)===P.ZodBranded&&e.keyType._def.type._def.typeName===P.ZodString&&((u=e.keyType._def.type._def.checks)!=null&&u.length)){const{type:c,...d}=ic(e.keyType._def,t);return{...l,propertyNames:d}}}return l}a(cc,"parseRecordDef");function T_(e,t){if(t.mapStrategy==="record")return cc(e,t);const n=K(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Ze(),r=K(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Ze();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}a(T_,"parseMapDef");function O_(e){const t=e.values,r=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),s=Array.from(new Set(r.map(i=>typeof i)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:r}}a(O_,"parseNativeEnumDef");function R_(){return{not:Ze()}}a(R_,"parseNeverDef");function P_(){return{type:"null"}}a(P_,"parseNullDef");var xs={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function N_(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in xs&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((s,i)=>{const o=xs[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((s,i)=>{const o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(r.length===n.length){const s=r.filter((i,o,u)=>u.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:n.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,s)=>[...r,...s._def.values.filter(i=>!r.includes(i))],[])};return M_(e,t)}a(N_,"parseUnionDef");var M_=a((e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,s)=>K(r._def,{...t,currentPath:[...t.currentPath,"anyOf",`${s}`]})).filter(r=>!!r&&(!t.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0},"asAnyOf");function j_(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[xs[e.innerType._def.typeName],"null"]};const n=K(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}a(j_,"parseNullableDef");function z_(e){const t={type:"number"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"int":t.type="integer";break;case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}a(z_,"parseNumberDef");function Z_(e,t){const n={type:"object",properties:{}},r=[],s=e.shape();for(const o in s){let u=s[o];if(u===void 0||u._def===void 0)continue;const l=U_(u),c=K(u._def,{...t,currentPath:[...t.currentPath,"properties",o],propertyPath:[...t.currentPath,"properties",o]});c!==void 0&&(n.properties[o]=c,l||r.push(o))}r.length&&(n.required=r);const i=L_(e,t);return i!==void 0&&(n.additionalProperties=i),n}a(Z_,"parseObjectDef");function L_(e,t){if(e.catchall._def.typeName!=="ZodNever")return K(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}a(L_,"decideAdditionalProperties");function U_(e){try{return e.isOptional()}catch{return!0}}a(U_,"safeIsOptional");var q_=a((e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return K(e.innerType._def,t);const r=K(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ze()},r]}:Ze()},"parseOptionalDef"),V_=a((e,t)=>{if(t.pipeStrategy==="input")return K(e.in._def,t);if(t.pipeStrategy==="output")return K(e.out._def,t);const n=K(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=K(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(s=>s!==void 0)}},"parsePipelineDef");function G_(e,t){return K(e.type._def,t)}a(G_,"parsePromiseDef");function W_(e,t){const r={type:"array",uniqueItems:!0,items:K(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(r.minItems=e.minSize.value),e.maxSize&&(r.maxItems=e.maxSize.value),r}a(W_,"parseSetDef");function H_(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>K(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:K(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>K(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}a(H_,"parseTupleDef");function J_(){return{not:Ze()}}a(J_,"parseUndefinedDef");function K_(){return Ze()}a(K_,"parseUnknownDef");var Y_=a((e,t)=>K(e.innerType._def,t),"parseReadonlyDef"),X_=a((e,t,n)=>{switch(t){case P.ZodString:return uc(e,n);case P.ZodNumber:return z_(e);case P.ZodObject:return Z_(e,n);case P.ZodBigInt:return F_(e);case P.ZodBoolean:return E_();case P.ZodDate:return ac(e,n);case P.ZodUndefined:return J_();case P.ZodNull:return P_();case P.ZodArray:return __(e,n);case P.ZodUnion:case P.ZodDiscriminatedUnion:return N_(e,n);case P.ZodIntersection:return I_(e,n);case P.ZodTuple:return H_(e,n);case P.ZodRecord:return cc(e,n);case P.ZodLiteral:return $_(e);case P.ZodEnum:return k_(e);case P.ZodNativeEnum:return O_(e);case P.ZodNullable:return j_(e,n);case P.ZodOptional:return q_(e,n);case P.ZodMap:return T_(e,n);case P.ZodSet:return W_(e,n);case P.ZodLazy:return()=>e.getter()._def;case P.ZodPromise:return G_(e,n);case P.ZodNaN:case P.ZodNever:return R_();case P.ZodEffects:return A_(e,n);case P.ZodAny:return Ze();case P.ZodUnknown:return K_();case P.ZodDefault:return w_(e,n);case P.ZodBranded:return ic(e,n);case P.ZodReadonly:return Y_(e,n);case P.ZodCatch:return C_(e,n);case P.ZodPipeline:return V_(e,n);case P.ZodFunction:case P.ZodVoid:case P.ZodSymbol:return;default:return(r=>{})()}},"selectParser");function K(e,t,n=!1){var r;const s=t.seen.get(e);if(t.override){const l=(r=t.override)==null?void 0:r.call(t,e,t,s,n);if(l!==v_)return l}if(s&&!n){const l=Q_(s,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const o=X_(e,e.typeName,t),u=typeof o=="function"?K(o(),t):o;if(u&&e2(e,t,u),t.postProcess){const l=t.postProcess(u,e,t);return i.jsonSchema=u,l}return i.jsonSchema=u,u}a(K,"parseDef");var Q_=a((e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:g_(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,r)=>t.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Ze()):t.$refStrategy==="seen"?Ze():void 0}},"get$ref"),e2=a((e,t,n)=>(e.description&&(n.description=e.description),n),"addMeta"),t2=a(e=>{const t=y_(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([r,s])=>[s._def,{def:s._def,path:[...t.basePath,t.definitionPath,r],jsonSchema:void 0}]))}},"getRefs"),n2=a((e,t)=>{var n;const r=t2(t);let s=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[d,p])=>{var h;return{...c,[d]:(h=K(p._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0))!=null?h:Ze()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=(n=K(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1))!=null?n:Ze(),u=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;u!==void 0&&(o.title=u);const l=i===void 0?s?{...o,[r.definitionPath]:s}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...s,[i]:o}};return l.$schema="http://json-schema.org/draft-07/schema#",l},"zodToJsonSchema"),r2=n2;function o2(e,t){var n;const r=(n=void 0)!=null?n:!1;return $s(()=>r2(e,{$refStrategy:r?"root":"none"}),{validate:a(async s=>{const i=await e.safeParseAsync(s);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}},"validate")})}a(o2,"zod3Schema");function s2(e,t){var n;const r=(n=void 0)!=null?n:!1;return $s(()=>Z0(e,{target:"draft-7",io:"output",reused:r?"ref":"inline"}),{validate:a(async s=>{const i=await Zl(e,s);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}},"validate")})}a(s2,"zod4Schema");function i2(e){return"_zod"in e}a(i2,"isZod4Schema");function Z(e,t){return i2(e)?s2(e):o2(e)}a(Z,"zodSchema");var Is=Symbol.for("vercel.ai.schema");function $e(e){let t;return()=>(t==null&&(t=e()),t)}a($e,"lazySchema");function $s(e,{validate:t}={}){return{[Is]:!0,_type:void 0,[Vr]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}a($s,"jsonSchema");function a2(e){return typeof e=="object"&&e!==null&&Is in e&&e[Is]===!0&&"jsonSchema"in e&&"validate"in e}a(a2,"isSchema");function Wr(e){return e==null?$s({properties:{},additionalProperties:!1}):a2(e)?e:typeof e=="function"?e():Z(e)}a(Wr,"asSchema");var{btoa:u2,atob:l2}=globalThis;function Hr(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=l2(t);return Uint8Array.from(n,r=>r.codePointAt(0))}a(Hr,"convertBase64ToUint8Array");function Jr(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return u2(t)}a(Jr,"convertUint8ArrayToBase64");function kt(e){return e instanceof Uint8Array?Jr(e):e}a(kt,"convertToBase64");function Bs(e){return e?.replace(/\/$/,"")}a(Bs,"withoutTrailingSlash");function c2(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}a(c2,"isAsyncIterable");async function*d2({execute:e,input:t,options:n}){const r=e(t,n);if(c2(r)){let s;for await(const i of r)s=i,yield{type:"preliminary",output:i};yield{type:"final",output:s}}else yield{type:"final",output:await r}}a(d2,"executeTool");var Ss,dc;function pc(){if(dc)return Ss;dc=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=a((d,p)=>{for(var h in p)e(d,h,{get:p[h],enumerable:!0})},"__export"),i=a((d,p,h,f)=>{if(p&&typeof p=="object"||typeof p=="function")for(let D of n(p))!r.call(d,D)&&D!==h&&e(d,D,{get:a(()=>p[D],"get"),enumerable:!(f=t(p,D))||f.enumerable});return d},"__copyProps"),o=a(d=>i(e({},"__esModule",{value:!0}),d),"__toCommonJS"),u={};s(u,{SYMBOL_FOR_REQ_CONTEXT:a(()=>l,"SYMBOL_FOR_REQ_CONTEXT"),getContext:a(()=>c,"getContext")}),Ss=o(u);const l=Symbol.for("@vercel/request-context");function c(){return globalThis[l]?.get?.()??{}}return a(c,"getContext"),Ss}a(pc,"requireGetContext");var Ts,Dc;function fc(){if(Dc)return Ts;Dc=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=a((d,p)=>{for(var h in p)e(d,h,{get:p[h],enumerable:!0})},"__export"),i=a((d,p,h,f)=>{if(p&&typeof p=="object"||typeof p=="function")for(let D of n(p))!r.call(d,D)&&D!==h&&e(d,D,{get:a(()=>p[D],"get"),enumerable:!(f=t(p,D))||f.enumerable});return d},"__copyProps"),o=a(d=>i(e({},"__esModule",{value:!0}),d),"__toCommonJS"),u={};s(u,{VercelOidcTokenError:a(()=>l,"VercelOidcTokenError")}),Ts=o(u);const c=class c extends Error{constructor(p,h){super(p),this.name="VercelOidcTokenError",this.cause=h}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}};a(c,"VercelOidcTokenError");let l=c;return Ts}a(fc,"requireTokenError");var Os,mc;function p2(){if(mc)return Os;mc=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=a((h,f)=>{for(var D in f)e(h,D,{get:f[D],enumerable:!0})},"__export"),i=a((h,f,D,g)=>{if(f&&typeof f=="object"||typeof f=="function")for(let v of n(f))!r.call(h,v)&&v!==D&&e(h,v,{get:a(()=>f[v],"get"),enumerable:!(g=t(f,v))||g.enumerable});return h},"__copyProps"),o=a(h=>i(e({},"__esModule",{value:!0}),h),"__toCommonJS"),u={};s(u,{getVercelOidcToken:a(()=>d,"getVercelOidcToken"),getVercelOidcTokenSync:a(()=>p,"getVercelOidcTokenSync")}),Os=o(u);var l=pc(),c=fc();async function d(){let h="",f;try{h=p()}catch(D){f=D}try{const[{getTokenPayload:D,isExpired:g},{refreshToken:v}]=await Promise.all([await import("./token-util-Btl7VWhB.mjs").then(function(F){return F.t}),await import("./token-CGM2J2PY.mjs").then(function(F){return F.t})]);(!h||g(D(h)))&&(await v(),h=p())}catch(D){throw f?.message&&D instanceof Error&&(D.message=`${f.message}
|
|
122
|
-
${D.message}`),new c.VercelOidcTokenError("Failed to refresh OIDC token",D)}return h}a(d,"getVercelOidcToken");function p(){const h=(0,l.getContext)().headers?.["x-vercel-oidc-token"]??process.env.VERCEL_OIDC_TOKEN;if(!h)throw new Error("The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?");return h}return a(p,"getVercelOidcTokenSync"),
|
|
121
|
+
]`;continue}i+=s[c],s[c]==="\\"?o=!0:u&&s[c]==="]"?u=!1:!u&&s[c]==="["&&(u=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}a(dc,"stringifyRegExpWithFlags");function pc(e,t){var n,r,s,i,o,u;const l={type:"object",additionalProperties:(n=Y(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===N.ZodString&&((s=e.keyType._def.checks)!=null&&s.length)){const{type:c,...d}=cc(e.keyType._def,t);return{...l,propertyNames:d}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===N.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((o=e.keyType)==null?void 0:o._def.typeName)===N.ZodBranded&&e.keyType._def.type._def.typeName===N.ZodString&&((u=e.keyType._def.type._def.checks)!=null&&u.length)){const{type:c,...d}=uc(e.keyType._def,t);return{...l,propertyNames:d}}}return l}a(pc,"parseRecordDef");function R_(e,t){if(t.mapStrategy==="record")return pc(e,t);const n=Y(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Ze(),r=Y(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Ze();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}a(R_,"parseMapDef");function P_(e){const t=e.values,r=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),s=Array.from(new Set(r.map(i=>typeof i)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:r}}a(P_,"parseNativeEnumDef");function N_(){return{not:Ze()}}a(N_,"parseNeverDef");function M_(){return{type:"null"}}a(M_,"parseNullDef");var $s={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function j_(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in $s&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((s,i)=>{const o=$s[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((s,i)=>{const o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(r.length===n.length){const s=r.filter((i,o,u)=>u.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:n.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,s)=>[...r,...s._def.values.filter(i=>!r.includes(i))],[])};return z_(e,t)}a(j_,"parseUnionDef");var z_=a((e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,s)=>Y(r._def,{...t,currentPath:[...t.currentPath,"anyOf",`${s}`]})).filter(r=>!!r&&(!t.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0},"asAnyOf");function Z_(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[$s[e.innerType._def.typeName],"null"]};const n=Y(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}a(Z_,"parseNullableDef");function L_(e){const t={type:"number"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"int":t.type="integer";break;case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}a(L_,"parseNumberDef");function U_(e,t){const n={type:"object",properties:{}},r=[],s=e.shape();for(const o in s){let u=s[o];if(u===void 0||u._def===void 0)continue;const l=V_(u),c=Y(u._def,{...t,currentPath:[...t.currentPath,"properties",o],propertyPath:[...t.currentPath,"properties",o]});c!==void 0&&(n.properties[o]=c,l||r.push(o))}r.length&&(n.required=r);const i=q_(e,t);return i!==void 0&&(n.additionalProperties=i),n}a(U_,"parseObjectDef");function q_(e,t){if(e.catchall._def.typeName!=="ZodNever")return Y(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}a(q_,"decideAdditionalProperties");function V_(e){try{return e.isOptional()}catch{return!0}}a(V_,"safeIsOptional");var G_=a((e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Y(e.innerType._def,t);const r=Y(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ze()},r]}:Ze()},"parseOptionalDef"),W_=a((e,t)=>{if(t.pipeStrategy==="input")return Y(e.in._def,t);if(t.pipeStrategy==="output")return Y(e.out._def,t);const n=Y(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Y(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(s=>s!==void 0)}},"parsePipelineDef");function H_(e,t){return Y(e.type._def,t)}a(H_,"parsePromiseDef");function J_(e,t){const r={type:"array",uniqueItems:!0,items:Y(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(r.minItems=e.minSize.value),e.maxSize&&(r.maxItems=e.maxSize.value),r}a(J_,"parseSetDef");function K_(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Y(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Y(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Y(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}a(K_,"parseTupleDef");function Y_(){return{not:Ze()}}a(Y_,"parseUndefinedDef");function X_(){return Ze()}a(X_,"parseUnknownDef");var Q_=a((e,t)=>Y(e.innerType._def,t),"parseReadonlyDef"),e2=a((e,t,n)=>{switch(t){case N.ZodString:return cc(e,n);case N.ZodNumber:return L_(e);case N.ZodObject:return U_(e,n);case N.ZodBigInt:return C_(e);case N.ZodBoolean:return b_();case N.ZodDate:return lc(e,n);case N.ZodUndefined:return Y_();case N.ZodNull:return M_();case N.ZodArray:return E_(e,n);case N.ZodUnion:case N.ZodDiscriminatedUnion:return j_(e,n);case N.ZodIntersection:return B_(e,n);case N.ZodTuple:return K_(e,n);case N.ZodRecord:return pc(e,n);case N.ZodLiteral:return S_(e);case N.ZodEnum:return $_(e);case N.ZodNativeEnum:return P_(e);case N.ZodNullable:return Z_(e,n);case N.ZodOptional:return G_(e,n);case N.ZodMap:return R_(e,n);case N.ZodSet:return J_(e,n);case N.ZodLazy:return()=>e.getter()._def;case N.ZodPromise:return H_(e,n);case N.ZodNaN:case N.ZodNever:return N_();case N.ZodEffects:return x_(e,n);case N.ZodAny:return Ze();case N.ZodUnknown:return X_();case N.ZodDefault:return k_(e,n);case N.ZodBranded:return uc(e,n);case N.ZodReadonly:return Q_(e,n);case N.ZodCatch:return w_(e,n);case N.ZodPipeline:return W_(e,n);case N.ZodFunction:case N.ZodVoid:case N.ZodSymbol:return;default:return(r=>{})()}},"selectParser");function Y(e,t,n=!1){var r;const s=t.seen.get(e);if(t.override){const l=(r=t.override)==null?void 0:r.call(t,e,t,s,n);if(l!==__)return l}if(s&&!n){const l=t2(s,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const o=e2(e,e.typeName,t),u=typeof o=="function"?Y(o(),t):o;if(u&&n2(e,t,u),t.postProcess){const l=t.postProcess(u,e,t);return i.jsonSchema=u,l}return i.jsonSchema=u,u}a(Y,"parseDef");var t2=a((e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:y_(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,r)=>t.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Ze()):t.$refStrategy==="seen"?Ze():void 0}},"get$ref"),n2=a((e,t,n)=>(e.description&&(n.description=e.description),n),"addMeta"),r2=a(e=>{const t=F_(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([r,s])=>[s._def,{def:s._def,path:[...t.basePath,t.definitionPath,r],jsonSchema:void 0}]))}},"getRefs"),o2=a((e,t)=>{var n;const r=r2(t);let s=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[d,p])=>{var h;return{...c,[d]:(h=Y(p._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0))!=null?h:Ze()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=(n=Y(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1))!=null?n:Ze(),u=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;u!==void 0&&(o.title=u);const l=i===void 0?s?{...o,[r.definitionPath]:s}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...s,[i]:o}};return l.$schema="http://json-schema.org/draft-07/schema#",l},"zodToJsonSchema"),s2=o2;function i2(e,t){var n;const r=(n=void 0)!=null?n:!1;return Bs(()=>s2(e,{$refStrategy:r?"root":"none"}),{validate:a(async s=>{const i=await e.safeParseAsync(s);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}},"validate")})}a(i2,"zod3Schema");function a2(e,t){var n;const r=(n=void 0)!=null?n:!1;return Bs(()=>U0(e,{target:"draft-7",io:"output",reused:r?"ref":"inline"}),{validate:a(async s=>{const i=await Ul(e,s);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}},"validate")})}a(a2,"zod4Schema");function u2(e){return"_zod"in e}a(u2,"isZod4Schema");function Z(e,t){return u2(e)?a2(e):i2(e)}a(Z,"zodSchema");var Is=Symbol.for("vercel.ai.schema");function Ie(e){let t;return()=>(t==null&&(t=e()),t)}a(Ie,"lazySchema");function Bs(e,{validate:t}={}){return{[Is]:!0,_type:void 0,[Jr]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}a(Bs,"jsonSchema");function l2(e){return typeof e=="object"&&e!==null&&Is in e&&e[Is]===!0&&"jsonSchema"in e&&"validate"in e}a(l2,"isSchema");function Yr(e){return e==null?Bs({properties:{},additionalProperties:!1}):l2(e)?e:typeof e=="function"?e():Z(e)}a(Yr,"asSchema");var{btoa:c2,atob:d2}=globalThis;function Xr(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=d2(t);return Uint8Array.from(n,r=>r.codePointAt(0))}a(Xr,"convertBase64ToUint8Array");function Qr(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return c2(t)}a(Qr,"convertUint8ArrayToBase64");function Bt(e){return e instanceof Uint8Array?Qr(e):e}a(Bt,"convertToBase64");function Ss(e){return e?.replace(/\/$/,"")}a(Ss,"withoutTrailingSlash");function p2(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}a(p2,"isAsyncIterable");async function*D2({execute:e,input:t,options:n}){const r=e(t,n);if(p2(r)){let s;for await(const i of r)s=i,yield{type:"preliminary",output:i};yield{type:"final",output:s}}else yield{type:"final",output:await r}}a(D2,"executeTool");var Ts,Dc;function fc(){if(Dc)return Ts;Dc=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=a((d,p)=>{for(var h in p)e(d,h,{get:p[h],enumerable:!0})},"__export"),i=a((d,p,h,f)=>{if(p&&typeof p=="object"||typeof p=="function")for(let D of n(p))!r.call(d,D)&&D!==h&&e(d,D,{get:a(()=>p[D],"get"),enumerable:!(f=t(p,D))||f.enumerable});return d},"__copyProps"),o=a(d=>i(e({},"__esModule",{value:!0}),d),"__toCommonJS"),u={};s(u,{SYMBOL_FOR_REQ_CONTEXT:a(()=>l,"SYMBOL_FOR_REQ_CONTEXT"),getContext:a(()=>c,"getContext")}),Ts=o(u);const l=Symbol.for("@vercel/request-context");function c(){return globalThis[l]?.get?.()??{}}return a(c,"getContext"),Ts}a(fc,"requireGetContext");var Os,mc;function hc(){if(mc)return Os;mc=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=a((d,p)=>{for(var h in p)e(d,h,{get:p[h],enumerable:!0})},"__export"),i=a((d,p,h,f)=>{if(p&&typeof p=="object"||typeof p=="function")for(let D of n(p))!r.call(d,D)&&D!==h&&e(d,D,{get:a(()=>p[D],"get"),enumerable:!(f=t(p,D))||f.enumerable});return d},"__copyProps"),o=a(d=>i(e({},"__esModule",{value:!0}),d),"__toCommonJS"),u={};s(u,{VercelOidcTokenError:a(()=>l,"VercelOidcTokenError")}),Os=o(u);const c=class c extends Error{constructor(p,h){super(p),this.name="VercelOidcTokenError",this.cause=h}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}};a(c,"VercelOidcTokenError");let l=c;return Os}a(hc,"requireTokenError");var Rs,gc;function f2(){if(gc)return Rs;gc=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=a((h,f)=>{for(var D in f)e(h,D,{get:f[D],enumerable:!0})},"__export"),i=a((h,f,D,g)=>{if(f&&typeof f=="object"||typeof f=="function")for(let v of n(f))!r.call(h,v)&&v!==D&&e(h,v,{get:a(()=>f[v],"get"),enumerable:!(g=t(f,v))||g.enumerable});return h},"__copyProps"),o=a(h=>i(e({},"__esModule",{value:!0}),h),"__toCommonJS"),u={};s(u,{getVercelOidcToken:a(()=>d,"getVercelOidcToken"),getVercelOidcTokenSync:a(()=>p,"getVercelOidcTokenSync")}),Rs=o(u);var l=fc(),c=hc();async function d(){let h="",f;try{h=p()}catch(D){f=D}try{const[{getTokenPayload:D,isExpired:g},{refreshToken:v}]=await Promise.all([await import("./token-util-BQstDXAi.mjs").then(function(F){return F.t}),await import("./token-1RgIvzSg.mjs").then(function(F){return F.t})]);(!h||g(D(h)))&&(await v(),h=p())}catch(D){throw f?.message&&D instanceof Error&&(D.message=`${f.message}
|
|
122
|
+
${D.message}`),new c.VercelOidcTokenError("Failed to refresh OIDC token",D)}return h}a(d,"getVercelOidcToken");function p(){const h=(0,l.getContext)().headers?.["x-vercel-oidc-token"]??process.env.VERCEL_OIDC_TOKEN;if(!h)throw new Error("The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?");return h}return a(p,"getVercelOidcTokenSync"),Rs}a(f2,"requireGetVercelOidcToken");var Ps,vc;function m2(){if(vc)return Ps;vc=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=a((d,p)=>{for(var h in p)e(d,h,{get:p[h],enumerable:!0})},"__export"),i=a((d,p,h,f)=>{if(p&&typeof p=="object"||typeof p=="function")for(let D of n(p))!r.call(d,D)&&D!==h&&e(d,D,{get:a(()=>p[D],"get"),enumerable:!(f=t(p,D))||f.enumerable});return d},"__copyProps"),o=a(d=>i(e({},"__esModule",{value:!0}),d),"__toCommonJS"),u={};s(u,{getContext:a(()=>c.getContext,"getContext"),getVercelOidcToken:a(()=>l.getVercelOidcToken,"getVercelOidcToken"),getVercelOidcTokenSync:a(()=>l.getVercelOidcTokenSync,"getVercelOidcTokenSync")}),Ps=o(u);var l=f2(),c=fc();return Ps}a(m2,"requireDist");var yc=m2(),h2="vercel.ai.gateway.error",Ns=Symbol.for(h2),_c,Fc,Le=(Ot=class extends(Fc=Error,_c=Ns,Fc){constructor({message:t,statusCode:n=500,cause:r}){super(t),this[_c]=!0,this.statusCode=n,this.cause=r}static isInstance(t){return Ot.hasMarker(t)}static hasMarker(t){return typeof t=="object"&&t!==null&&Ns in t&&t[Ns]===!0}},a(Ot,"_GatewayError"),Ot),Ec="GatewayAuthenticationError",g2=`vercel.ai.gateway.error.${Ec}`,Cc=Symbol.for(g2),bc,wc,Ms=(Rt=class extends(wc=Le,bc=Cc,wc){constructor({message:t="Authentication failed",statusCode:n=401,cause:r}={}){super({message:t,statusCode:n,cause:r}),this[bc]=!0,this.name=Ec,this.type="authentication_error"}static isInstance(t){return Le.hasMarker(t)&&Cc in t}static createContextualError({apiKeyProvided:t,oidcTokenProvided:n,message:r="Authentication failed",statusCode:s=401,cause:i}){let o;return t?o=`AI Gateway authentication failed: Invalid API key.
|
|
123
123
|
|
|
124
124
|
Create a new API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
125
125
|
|
|
@@ -134,13 +134,13 @@ Create an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
|
134
134
|
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
|
|
135
135
|
|
|
136
136
|
Option 2 - OIDC token:
|
|
137
|
-
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,new Bt({message:o,statusCode:s,cause:i})}},a(Bt,"_GatewayAuthenticationError"),Bt),bc="GatewayInvalidRequestError",h2=`vercel.ai.gateway.error.${bc}`,wc=Symbol.for(h2),Ac,kc,g2=(tn=class extends(kc=Le,Ac=wc,kc){constructor({message:t="Invalid request",statusCode:n=400,cause:r}={}){super({message:t,statusCode:n,cause:r}),this[Ac]=!0,this.name=bc,this.type="invalid_request_error"}static isInstance(t){return Le.hasMarker(t)&&wc in t}},a(tn,"GatewayInvalidRequestError"),tn),xc="GatewayRateLimitError",v2=`vercel.ai.gateway.error.${xc}`,Ic=Symbol.for(v2),$c,Bc,y2=(nn=class extends(Bc=Le,$c=Ic,Bc){constructor({message:t="Rate limit exceeded",statusCode:n=429,cause:r}={}){super({message:t,statusCode:n,cause:r}),this[$c]=!0,this.name=xc,this.type="rate_limit_exceeded"}static isInstance(t){return Le.hasMarker(t)&&Ic in t}},a(nn,"GatewayRateLimitError"),nn),Sc="GatewayModelNotFoundError",_2=`vercel.ai.gateway.error.${Sc}`,Tc=Symbol.for(_2),F2=ge(()=>Z(y({modelId:m()}))),Oc,Rc,Pc=(rn=class extends(Rc=Le,Oc=Tc,Rc){constructor({message:t="Model not found",statusCode:n=404,modelId:r,cause:s}={}){super({message:t,statusCode:n,cause:s}),this[Oc]=!0,this.name=Sc,this.type="model_not_found",this.modelId=r}static isInstance(t){return Le.hasMarker(t)&&Tc in t}},a(rn,"GatewayModelNotFoundError"),rn),Nc="GatewayInternalServerError",E2=`vercel.ai.gateway.error.${Nc}`,Mc=Symbol.for(E2),jc,zc,Zc=(on=class extends(zc=Le,jc=Mc,zc){constructor({message:t="Internal server error",statusCode:n=500,cause:r}={}){super({message:t,statusCode:n,cause:r}),this[jc]=!0,this.name=Nc,this.type="internal_server_error"}static isInstance(t){return Le.hasMarker(t)&&Mc in t}},a(on,"GatewayInternalServerError"),on),Lc="GatewayResponseError",C2=`vercel.ai.gateway.error.${Lc}`,Uc=Symbol.for(C2),qc,Vc,b2=(sn=class extends(Vc=Le,qc=Uc,Vc){constructor({message:t="Invalid response from Gateway",statusCode:n=502,response:r,validationError:s,cause:i}={}){super({message:t,statusCode:n,cause:i}),this[qc]=!0,this.name=Lc,this.type="response_error",this.response=r,this.validationError=s}static isInstance(t){return Le.hasMarker(t)&&Uc in t}},a(sn,"GatewayResponseError"),sn);async function Gc({response:e,statusCode:t,defaultMessage:n="Gateway request failed",cause:r,authMethod:s}){const i=await ot({value:e,schema:w2});if(!i.success)return new b2({message:`Invalid error response format: ${n}`,statusCode:t,response:e,validationError:i.error,cause:r});const o=i.value,u=o.error.type,l=o.error.message;switch(u){case"authentication_error":return Ns.createContextualError({apiKeyProvided:s==="api-key",oidcTokenProvided:s==="oidc",statusCode:t,cause:r});case"invalid_request_error":return new g2({message:l,statusCode:t,cause:r});case"rate_limit_exceeded":return new y2({message:l,statusCode:t,cause:r});case"model_not_found":{const c=await ot({value:o.error.param,schema:F2});return new Pc({message:l,statusCode:t,modelId:c.success?c.value.modelId:void 0,cause:r})}case"internal_server_error":return new Zc({message:l,statusCode:t,cause:r});default:return new Zc({message:l,statusCode:t,cause:r})}}a(Gc,"createGatewayErrorFromResponse");var w2=ge(()=>Z(y({error:y({message:m(),type:m().nullish(),param:rt().nullish(),code:Y([m(),w()]).nullish()})})));function Dt(e,t){var n;return Le.isInstance(e)?e:Ce.isInstance(e)?Gc({response:A2(e),statusCode:(n=e.statusCode)!=null?n:500,defaultMessage:"Gateway request failed",cause:e,authMethod:t}):Gc({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:"Unknown Gateway error",cause:e,authMethod:t})}a(Dt,"asGatewayError");function A2(e){if(e.data!==void 0)return e.data;if(e.responseBody!=null)try{return JSON.parse(e.responseBody)}catch{return e.responseBody}return{}}a(A2,"extractApiCallResponse");var Wc="ai-gateway-auth-method";async function Ut(e){const t=await ot({value:e[Wc],schema:k2});return t.success?t.value:void 0}a(Ut,"parseAuthMethod");var k2=ge(()=>Z(Y([k("api-key"),k("oidc")]))),Hc=(an=class{constructor(t){this.config=t}async getAvailableModels(){try{const{value:t}=await nc({url:`${this.config.baseURL}/config`,headers:await et(this.config.headers()),successfulResponseHandler:Te(x2),failedResponseHandler:Ge({errorSchema:Me(),errorToMessage:a(n=>n,"errorToMessage")}),fetch:this.config.fetch});return t}catch(t){throw await Dt(t)}}async getCredits(){try{const t=new URL(this.config.baseURL),{value:n}=await nc({url:`${t.origin}/v1/credits`,headers:await et(this.config.headers()),successfulResponseHandler:Te(I2),failedResponseHandler:Ge({errorSchema:Me(),errorToMessage:a(r=>r,"errorToMessage")}),fetch:this.config.fetch});return n}catch(t){throw await Dt(t)}}},a(an,"GatewayFetchMetadata"),an),x2=ge(()=>Z(y({models:x(y({id:m(),name:m(),description:m().nullish(),pricing:y({input:m(),output:m(),input_cache_read:m().nullish(),input_cache_write:m().nullish()}).transform(({input:e,output:t,input_cache_read:n,input_cache_write:r})=>({input:e,output:t,...n?{cachedInputTokens:n}:{},...r?{cacheCreationInputTokens:r}:{}})).nullish(),specification:y({specificationVersion:k("v2"),provider:m(),modelId:m()}),modelType:se(["language","embedding","image"]).nullish()}))}))),I2=ge(()=>Z(y({balance:m(),total_used:m()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),$2=(un=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2",this.supportedUrls={"*/*":[/.*/]}}get provider(){return this.config.provider}async getArgs(t){const{abortSignal:n,...r}=t;return{args:this.maybeEncodeFileParts(r),warnings:[]}}async doGenerate(t){const{args:n,warnings:r}=await this.getArgs(t),{abortSignal:s}=t,i=await et(this.config.headers());try{const{responseHeaders:o,value:u,rawValue:l}=await Ee({url:this.getUrl(),headers:ye(i,t.headers,this.getModelConfigHeaders(this.modelId,!1),await et(this.config.o11yHeaders)),body:n,successfulResponseHandler:Te(Me()),failedResponseHandler:Ge({errorSchema:Me(),errorToMessage:a(c=>c,"errorToMessage")}),...s&&{abortSignal:s},fetch:this.config.fetch});return{...u,request:{body:n},response:{headers:o,body:l},warnings:r}}catch(o){throw await Dt(o,await Ut(i))}}async doStream(t){const{args:n,warnings:r}=await this.getArgs(t),{abortSignal:s}=t,i=await et(this.config.headers());try{const{value:o,responseHeaders:u}=await Ee({url:this.getUrl(),headers:ye(i,t.headers,this.getModelConfigHeaders(this.modelId,!0),await et(this.config.o11yHeaders)),body:n,successfulResponseHandler:Lt(Me()),failedResponseHandler:Ge({errorSchema:Me(),errorToMessage:a(l=>l,"errorToMessage")}),...s&&{abortSignal:s},fetch:this.config.fetch});return{stream:o.pipeThrough(new TransformStream({start(l){r.length>0&&l.enqueue({type:"stream-start",warnings:r})},transform(l,c){if(l.success){const d=l.value;if(d.type==="raw"&&!t.includeRawChunks)return;d.type==="response-metadata"&&d.timestamp&&typeof d.timestamp=="string"&&(d.timestamp=new Date(d.timestamp)),c.enqueue(d)}else c.error(l.error)}})),request:{body:n},response:{headers:u}}}catch(o){throw await Dt(o,await Ut(i))}}isFilePart(t){return t&&typeof t=="object"&&"type"in t&&t.type==="file"}maybeEncodeFileParts(t){for(const n of t.prompt)for(const r of n.content)if(this.isFilePart(r)){const s=r;if(s.data instanceof Uint8Array){const i=Uint8Array.from(s.data),o=Buffer.from(i).toString("base64");s.data=new URL(`data:${s.mediaType||"application/octet-stream"};base64,${o}`)}}return t}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(t,n){return{"ai-language-model-specification-version":"2","ai-language-model-id":t,"ai-language-model-streaming":String(n)}}},a(un,"GatewayLanguageModel"),un),B2=(ln=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}get provider(){return this.config.provider}async doEmbed({values:t,headers:n,abortSignal:r,providerOptions:s}){var i;const o=await et(this.config.headers());try{const{responseHeaders:u,value:l,rawValue:c}=await Ee({url:this.getUrl(),headers:ye(o,n??{},this.getModelConfigHeaders(),await et(this.config.o11yHeaders)),body:{input:t.length===1?t[0]:t,...s?{providerOptions:s}:{}},successfulResponseHandler:Te(S2),failedResponseHandler:Ge({errorSchema:Me(),errorToMessage:a(d=>d,"errorToMessage")}),...r&&{abortSignal:r},fetch:this.config.fetch});return{embeddings:l.embeddings,usage:(i=l.usage)!=null?i:void 0,providerMetadata:l.providerMetadata,response:{headers:u,body:c}}}catch(u){throw await Dt(u,await Ut(o))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":"2","ai-model-id":this.modelId}}},a(ln,"GatewayEmbeddingModel"),ln),S2=ge(()=>Z(y({embeddings:x(x(w())),usage:y({tokens:w()}).nullish(),providerMetadata:he(m(),he(m(),rt())).optional()}))),T2=(cn=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2",this.maxImagesPerCall=Number.MAX_SAFE_INTEGER}get provider(){return this.config.provider}async doGenerate({prompt:t,n,size:r,aspectRatio:s,seed:i,providerOptions:o,headers:u,abortSignal:l}){var c;const d=await et(this.config.headers());try{const{responseHeaders:p,value:h,rawValue:f}=await Ee({url:this.getUrl(),headers:ye(d,u??{},this.getModelConfigHeaders(),await et(this.config.o11yHeaders)),body:{prompt:t,n,...r&&{size:r},...s&&{aspectRatio:s},...i&&{seed:i},...o&&{providerOptions:o}},successfulResponseHandler:Te(R2),failedResponseHandler:Ge({errorSchema:Me(),errorToMessage:a(D=>D,"errorToMessage")}),...l&&{abortSignal:l},fetch:this.config.fetch});return{images:h.images,warnings:(c=h.warnings)!=null?c:[],providerMetadata:h.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:p}}}catch(p){throw Dt(p,await Ut(d))}}getUrl(){return`${this.config.baseURL}/image-model`}getModelConfigHeaders(){return{"ai-image-model-specification-version":"2","ai-model-id":this.modelId}}},a(cn,"GatewayImageModel"),cn),O2=y({images:x(rt()).optional()}).catchall(rt()),R2=y({images:x(m()),warnings:x(y({type:k("other"),message:m()})).optional(),providerMetadata:he(m(),O2).optional()});async function P2(){var e;return(e=gc.getContext().headers)==null?void 0:e["x-vercel-id"]}a(P2,"getVercelRequestId");var N2="2.0.17",M2="0.0.1";function j2(e={}){var t,n;let r=null,s=null;const i=(t=e.metadataCacheRefreshMillis)!=null?t:1e3*60*5;let o=0;const u=(n=Bs(e.baseURL))!=null?n:"https://ai-gateway.vercel.sh/v1/ai",l=a(async()=>{const D=await Z2(e);if(D)return wt({Authorization:`Bearer ${D.token}`,"ai-gateway-protocol-version":M2,[Wc]:D.authMethod,...e.headers},`ai-sdk/gateway/${N2}`);throw Ns.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401})},"getHeaders"),c=a(()=>{const D=nr({settingValue:void 0,environmentVariableName:"VERCEL_DEPLOYMENT_ID"}),g=nr({settingValue:void 0,environmentVariableName:"VERCEL_ENV"}),v=nr({settingValue:void 0,environmentVariableName:"VERCEL_REGION"});return async()=>{const F=await P2();return{...D&&{"ai-o11y-deployment-id":D},...g&&{"ai-o11y-environment":g},...v&&{"ai-o11y-region":v},...F&&{"ai-o11y-request-id":F}}}},"createO11yHeaders"),d=a(D=>new $2(D,{provider:"gateway",baseURL:u,headers:l,fetch:e.fetch,o11yHeaders:c()}),"createLanguageModel"),p=a(async()=>{var D,g,v;const F=(v=(g=(D=e._internal)==null?void 0:D.currentDate)==null?void 0:g.call(D).getTime())!=null?v:Date.now();return(!r||F-o>i)&&(o=F,r=new Hc({baseURL:u,headers:l,fetch:e.fetch}).getAvailableModels().then(C=>(s=C,C)).catch(async C=>{throw await Dt(C,await Ut(await l()))})),s?Promise.resolve(s):r},"getAvailableModels"),h=a(async()=>new Hc({baseURL:u,headers:l,fetch:e.fetch}).getCredits().catch(async D=>{throw await Dt(D,await Ut(await l()))}),"getCredits"),f=a(function(D){if(new.target)throw new Error("The Gateway Provider model function cannot be called with the new keyword.");return d(D)},"provider");return f.getAvailableModels=p,f.getCredits=h,f.imageModel=D=>new T2(D,{provider:"gateway",baseURL:u,headers:l,fetch:e.fetch,o11yHeaders:c()}),f.languageModel=d,f.textEmbeddingModel=D=>new B2(D,{provider:"gateway",baseURL:u,headers:l,fetch:e.fetch,o11yHeaders:c()}),f}a(j2,"createGatewayProvider");var z2=j2();async function Z2(e){const t=nr({settingValue:e.apiKey,environmentVariableName:"AI_GATEWAY_API_KEY"});if(t)return{token:t,authMethod:"api-key"};try{return{token:await gc.getVercelOidcToken(),authMethod:"oidc"}}catch{return null}}a(Z2,"getGatewayAuthToken");var L2=typeof globalThis=="object"?globalThis:global,xt="1.9.0",Jc=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function U2(e){var t=new Set([e]),n=new Set,r=e.match(Jc);if(!r)return function(){return!1};var s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(s.prerelease!=null)return a(function(l){return l===e},"isExactmatch");function i(u){return n.add(u),!1}a(i,"_reject");function o(u){return t.add(u),!0}return a(o,"_accept"),a(function(l){if(t.has(l))return!0;if(n.has(l))return!1;var c=l.match(Jc);if(!c)return i(l);var d={major:+c[1],minor:+c[2],patch:+c[3],prerelease:c[4]};return d.prerelease!=null||s.major!==d.major?i(l):s.major===0?s.minor===d.minor&&s.patch<=d.patch?o(l):i(l):s.minor<=d.minor?o(l):i(l)},"isCompatible2")}a(U2,"_makeCompatibilityCheck");var q2=U2(xt),V2=xt.split(".")[0],rr=Symbol.for("opentelemetry.js.api."+V2),or=L2;function Ms(e,t,n,r){var s;r===void 0&&(r=!1);var i=or[rr]=(s=or[rr])!==null&&s!==void 0?s:{version:xt};if(!r&&i[e]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return n.error(o.stack||o.message),!1}if(i.version!==xt){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+e+" does not match previously registered API v"+xt);return n.error(o.stack||o.message),!1}return i[e]=t,n.debug("@opentelemetry/api: Registered a global for "+e+" v"+xt+"."),!0}a(Ms,"registerGlobal");function sr(e){var t,n,r=(t=or[rr])===null||t===void 0?void 0:t.version;if(!(!r||!q2(r)))return(n=or[rr])===null||n===void 0?void 0:n[e]}a(sr,"getGlobal");function js(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+xt+".");var n=or[rr];n&&delete n[e]}a(js,"unregisterGlobal");var G2=a(function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(u){o={error:u}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},"__read$3"),W2=a(function(e,t,n){if(arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},"__spreadArray$3"),H2=(function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return a(e,"DiagComponentLogger2"),e.prototype.debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ir("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ir("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ir("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ir("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ir("verbose",this._namespace,t)},e})();function ir(e,t,n){var r=sr("diag");if(r)return n.unshift(t),r[e].apply(r,W2([],G2(n),!1))}a(ir,"logProxy");var Ue;(function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"})(Ue||(Ue={}));function J2(e,t){e<Ue.NONE?e=Ue.NONE:e>Ue.ALL&&(e=Ue.ALL),t=t||{};function n(r,s){var i=t[r];return typeof i=="function"&&e>=s?i.bind(t):function(){}}return a(n,"_filterFunc"),{error:n("error",Ue.ERROR),warn:n("warn",Ue.WARN),info:n("info",Ue.INFO),debug:n("debug",Ue.DEBUG),verbose:n("verbose",Ue.VERBOSE)}}a(J2,"createLogLevelDiagLogger");var K2=a(function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(u){o={error:u}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},"__read$2"),Y2=a(function(e,t,n){if(arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},"__spreadArray$2"),X2="diag",Kr=(function(){function e(){function t(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var u=sr("diag");if(u)return u[s].apply(u,Y2([],K2(i),!1))}}a(t,"_logProxy");var n=this,r=a(function(s,i){var o,u,l;if(i===void 0&&(i={logLevel:Ue.INFO}),s===n){var c=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return n.error((o=c.stack)!==null&&o!==void 0?o:c.message),!1}typeof i=="number"&&(i={logLevel:i});var d=sr("diag"),p=J2((u=i.logLevel)!==null&&u!==void 0?u:Ue.INFO,s);if(d&&!i.suppressOverrideMessage){var h=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";d.warn("Current logger will be overwritten from "+h),p.warn("Current logger will overwrite one already registered from "+h)}return Ms("diag",p,n,!0)},"setLogger");n.setLogger=r,n.disable=function(){js(X2,n)},n.createComponentLogger=function(s){return new H2(s)},n.verbose=t("verbose"),n.debug=t("debug"),n.info=t("info"),n.warn=t("warn"),n.error=t("error")}return a(e,"DiagAPI2"),e.instance=function(){return this._instance||(this._instance=new e),this._instance},e})();function Q2(e){return Symbol.for(e)}a(Q2,"createContextKey");var eF=(function(){function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(r){return n._currentContext.get(r)},n.setValue=function(r,s){var i=new e(n._currentContext);return i._currentContext.set(r,s),i},n.deleteValue=function(r){var s=new e(n._currentContext);return s._currentContext.delete(r),s}}return a(e,"BaseContext2"),e})(),tF=new eF,nF=a(function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(u){o={error:u}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},"__read$1"),rF=a(function(e,t,n){if(arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},"__spreadArray$1"),oF=(function(){function e(){}return a(e,"NoopContextManager2"),e.prototype.active=function(){return tF},e.prototype.with=function(t,n,r){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return n.call.apply(n,rF([r],nF(s),!1))},e.prototype.bind=function(t,n){return n},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e})(),sF=a(function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(u){o={error:u}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},"__read"),iF=a(function(e,t,n){if(arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},"__spreadArray"),zs="context",aF=new oF,Kc=(function(){function e(){}return a(e,"ContextAPI2"),e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return Ms(zs,t,Kr.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,n,r){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,iF([t,n,r],sF(i),!1))},e.prototype.bind=function(t,n){return this._getContextManager().bind(t,n)},e.prototype._getContextManager=function(){return sr(zs)||aF},e.prototype.disable=function(){this._getContextManager().disable(),js(zs,Kr.instance())},e})(),Zs;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(Zs||(Zs={}));var Yc="0000000000000000",Xc="00000000000000000000000000000000",uF={traceId:Xc,spanId:Yc,traceFlags:Zs.NONE},ar=(function(){function e(t){t===void 0&&(t=uF),this._spanContext=t}return a(e,"NonRecordingSpan2"),e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,n){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,n){return this},e.prototype.addLink=function(t){return this},e.prototype.addLinks=function(t){return this},e.prototype.setStatus=function(t){return this},e.prototype.updateName=function(t){return this},e.prototype.end=function(t){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(t,n){},e})(),Ls=Q2("OpenTelemetry Context Key SPAN");function Us(e){return e.getValue(Ls)||void 0}a(Us,"getSpan");function lF(){return Us(Kc.getInstance().active())}a(lF,"getActiveSpan");function qs(e,t){return e.setValue(Ls,t)}a(qs,"setSpan");function cF(e){return e.deleteValue(Ls)}a(cF,"deleteSpan");function dF(e,t){return qs(e,new ar(t))}a(dF,"setSpanContext");function Qc(e){var t;return(t=Us(e))===null||t===void 0?void 0:t.spanContext()}a(Qc,"getSpanContext");var pF=/^([0-9a-f]{32})$/i,DF=/^[0-9a-f]{16}$/i;function fF(e){return pF.test(e)&&e!==Xc}a(fF,"isValidTraceId");function mF(e){return DF.test(e)&&e!==Yc}a(mF,"isValidSpanId");function ed(e){return fF(e.traceId)&&mF(e.spanId)}a(ed,"isSpanContextValid");function hF(e){return new ar(e)}a(hF,"wrapSpanContext");var Vs=Kc.getInstance(),td=(function(){function e(){}return a(e,"NoopTracer2"),e.prototype.startSpan=function(t,n,r){r===void 0&&(r=Vs.active());var s=!!n?.root;if(s)return new ar;var i=r&&Qc(r);return gF(i)&&ed(i)?new ar(i):new ar},e.prototype.startActiveSpan=function(t,n,r,s){var i,o,u;if(!(arguments.length<2)){arguments.length===2?u=n:arguments.length===3?(i=n,u=r):(i=n,o=r,u=s);var l=o??Vs.active(),c=this.startSpan(t,i,l),d=qs(l,c);return Vs.with(d,u,void 0,c)}},e})();function gF(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}a(gF,"isSpanContext");var vF=new td,yF=(function(){function e(t,n,r,s){this._provider=t,this.name=n,this.version=r,this.options=s}return a(e,"ProxyTracer2"),e.prototype.startSpan=function(t,n,r){return this._getTracer().startSpan(t,n,r)},e.prototype.startActiveSpan=function(t,n,r,s){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):vF},e})(),_F=(function(){function e(){}return a(e,"NoopTracerProvider2"),e.prototype.getTracer=function(t,n,r){return new td},e})(),FF=new _F,nd=(function(){function e(){}return a(e,"ProxyTracerProvider2"),e.prototype.getTracer=function(t,n,r){var s;return(s=this.getDelegateTracer(t,n,r))!==null&&s!==void 0?s:new yF(this,t,n,r)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:FF},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,n,r){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(t,n,r)},e})(),Yr;(function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"})(Yr||(Yr={}));var Gs="trace",EF=(function(){function e(){this._proxyTracerProvider=new nd,this.wrapSpanContext=hF,this.isSpanContextValid=ed,this.deleteSpan=cF,this.getSpan=Us,this.getActiveSpan=lF,this.getSpanContext=Qc,this.setSpan=qs,this.setSpanContext=dF}return a(e,"TraceAPI2"),e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var n=Ms(Gs,this._proxyTracerProvider,Kr.instance());return n&&this._proxyTracerProvider.setDelegate(t),n},e.prototype.getTracerProvider=function(){return sr(Gs)||this._proxyTracerProvider},e.prototype.getTracer=function(t,n){return this.getTracerProvider().getTracer(t,n)},e.prototype.disable=function(){js(Gs,Kr.instance()),this._proxyTracerProvider=new nd},e})(),CF=EF.getInstance(),bF=Object.defineProperty,wF=a((e,t)=>{for(var n in t)bF(e,n,{get:t[n],enumerable:!0})},"__export"),rd="AI_NoOutputSpecifiedError",od=`vercel.ai.error.${rd}`,AF=Symbol.for(od),sd,kF=(dn=class extends N{constructor({message:t="No output specified."}={}){super({name:rd,message:t}),this[sd]=!0}static isInstance(t){return N.hasMarker(t,od)}},a(dn,"NoOutputSpecifiedError"),dn);sd=AF;function xF(e){const t="AI SDK Warning:";switch(e.type){case"unsupported-setting":{let n=`${t} The "${e.setting}" setting is not supported by this model`;return e.details&&(n+=` - ${e.details}`),n}case"unsupported-tool":{const n="name"in e.tool?e.tool.name:"unknown tool";let r=`${t} The tool "${n}" is not supported by this model`;return e.details&&(r+=` - ${e.details}`),r}case"other":return`${t} ${e.message}`;default:return`${t} ${JSON.stringify(e,null,2)}`}}a(xF,"formatWarning");var IF="AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",id=!1,$F=a(e=>{if(e.length===0)return;const t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t=="function"){t(e);return}id||(id=!0,console.info(IF));for(const n of e)console.warn(xF(n))}},"logWarnings"),ad="AI_InvalidArgumentError",ud=`vercel.ai.error.${ad}`,BF=Symbol.for(ud),ld,st=(pn=class extends N{constructor({parameter:t,value:n,message:r}){super({name:ad,message:`Invalid argument for parameter ${t}: ${r}`}),this[ld]=!0,this.parameter=t,this.value=n}static isInstance(t){return N.hasMarker(t,ud)}},a(pn,"InvalidArgumentError"),pn);ld=BF;var cd="AI_InvalidToolInputError",dd=`vercel.ai.error.${cd}`,SF=Symbol.for(dd),pd,Dd=(Dn=class extends N{constructor({toolInput:t,toolName:n,cause:r,message:s=`Invalid input for tool ${n}: ${Gn(r)}`}){super({name:cd,message:s,cause:r}),this[pd]=!0,this.toolInput=t,this.toolName=n}static isInstance(t){return N.hasMarker(t,dd)}},a(Dn,"InvalidToolInputError"),Dn);pd=SF;var fd="AI_NoObjectGeneratedError",md=`vercel.ai.error.${fd}`,TF=Symbol.for(md),hd,gd=(fn=class extends N{constructor({message:t="No object generated.",cause:n,text:r,response:s,usage:i,finishReason:o}){super({name:fd,message:t,cause:n}),this[hd]=!0,this.text=r,this.response=s,this.usage=i,this.finishReason=o}static isInstance(t){return N.hasMarker(t,md)}},a(fn,"NoObjectGeneratedError"),fn);hd=TF;var vd="AI_NoSuchToolError",yd=`vercel.ai.error.${vd}`,OF=Symbol.for(yd),_d,Ws=(mn=class extends N{constructor({toolName:t,availableTools:n=void 0,message:r=`Model tried to call unavailable tool '${t}'. ${n===void 0?"No tools are available.":`Available tools: ${n.join(", ")}.`}`}){super({name:vd,message:r}),this[_d]=!0,this.toolName=t,this.availableTools=n}static isInstance(t){return N.hasMarker(t,yd)}},a(mn,"NoSuchToolError"),mn);_d=OF;var Fd="AI_ToolCallRepairError",Ed=`vercel.ai.error.${Fd}`,RF=Symbol.for(Ed),Cd,PF=(hn=class extends N{constructor({cause:t,originalError:n,message:r=`Error repairing tool call: ${Gn(t)}`}){super({name:Fd,message:r,cause:t}),this[Cd]=!0,this.originalError=n}static isInstance(t){return N.hasMarker(t,Ed)}},a(hn,"ToolCallRepairError"),hn);Cd=RF;var NF=(gn=class extends N{constructor(t){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${t.version} for provider "${t.provider}" and model "${t.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=t.version,this.provider=t.provider,this.modelId=t.modelId}},a(gn,"UnsupportedModelVersionError"),gn),bd="AI_InvalidMessageRoleError",wd=`vercel.ai.error.${bd}`,MF=Symbol.for(wd),Ad,jF=(vn=class extends N{constructor({role:t,message:n=`Invalid message role: '${t}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:bd,message:n}),this[Ad]=!0,this.role=t}static isInstance(t){return N.hasMarker(t,wd)}},a(vn,"InvalidMessageRoleError"),vn);Ad=MF;var kd="AI_DownloadError",xd=`vercel.ai.error.${kd}`,zF=Symbol.for(xd),Id,Hs=(yn=class extends N{constructor({url:t,statusCode:n,statusText:r,cause:s,message:i=s==null?`Failed to download ${t}: ${n} ${r}`:`Failed to download ${t}: ${s}`}){super({name:kd,message:i,cause:s}),this[Id]=!0,this.url=t,this.statusCode=n,this.statusText=r}static isInstance(t){return N.hasMarker(t,xd)}},a(yn,"DownloadError"),yn);Id=zF;var $d="AI_RetryError",Bd=`vercel.ai.error.${$d}`,ZF=Symbol.for(Bd),Sd,Td=(_n=class extends N{constructor({message:t,reason:n,errors:r}){super({name:$d,message:t}),this[Sd]=!0,this.reason=n,this.errors=r,this.lastError=r[r.length-1]}static isInstance(t){return N.hasMarker(t,Bd)}},a(_n,"RetryError"),_n);Sd=ZF;function Od(e){if(typeof e!="string"){if(e.specificationVersion!=="v2")throw new NF({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return e}return LF().languageModel(e)}a(Od,"resolveLanguageModel");function LF(){var e;return(e=globalThis.AI_SDK_DEFAULT_PROVIDER)!=null?e:z2}a(LF,"getGlobalProvider");var UF=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],qF=a(e=>{const t=typeof e=="string"?Hr(e):e,n=(t[6]&127)<<21|(t[7]&127)<<14|(t[8]&127)<<7|t[9]&127;return t.slice(n+10)},"stripID3");function VF(e){return typeof e=="string"&&e.startsWith("SUQz")||typeof e!="string"&&e.length>10&&e[0]===73&&e[1]===68&&e[2]===51?qF(e):e}a(VF,"stripID3TagsIfPresent");function GF({data:e,signatures:t}){const n=VF(e),r=typeof n=="string"?Hr(n.substring(0,Math.min(n.length,24))):n;for(const s of t)if(r.length>=s.bytesPrefix.length&&s.bytesPrefix.every((i,o)=>i===null||r[o]===i))return s.mediaType}a(GF,"detectMediaType");var Rd="5.0.104",WF=a(async({url:e})=>{var t;const n=e.toString();try{const r=await fetch(n,{headers:wt({},`ai-sdk/${Rd}`,bs())});if(!r.ok)throw new Hs({url:n,statusCode:r.status,statusText:r.statusText});return{data:new Uint8Array(await r.arrayBuffer()),mediaType:(t=r.headers.get("content-type"))!=null?t:void 0}}catch(r){throw Hs.isInstance(r)?r:new Hs({url:n,cause:r})}},"download"),HF=a((e=WF)=>t=>Promise.all(t.map(async n=>n.isUrlSupportedByModel?null:e(n))),"createDefaultDownloadFunction");function JF(e){try{const[t,n]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:n}}catch{return{mediaType:void 0,base64Content:void 0}}}a(JF,"splitDataUrl");var Pd=Y([m(),qr(Uint8Array),qr(ArrayBuffer),Hy(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]);function Nd(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if(typeof e=="string")try{e=new URL(e)}catch{}if(e instanceof URL&&e.protocol==="data:"){const{mediaType:t,base64Content:n}=JF(e.toString());if(t==null||n==null)throw new N({name:"InvalidDataContentError",message:`Invalid data URL format in content ${e.toString()}`});return{data:n,mediaType:t}}return{data:e,mediaType:void 0}}a(Nd,"convertToLanguageModelV2DataContent");function KF(e){return typeof e=="string"?e:e instanceof ArrayBuffer?Jr(new Uint8Array(e)):Jr(e)}a(KF,"convertDataContentToBase64String");async function YF({prompt:e,supportedUrls:t,download:n=HF()}){const r=await QF(e.messages,n,t);return[...e.system!=null?[{role:"system",content:e.system}]:[],...e.messages.map(s=>XF({message:s,downloadedAssets:r}))]}a(YF,"convertToLanguageModelPrompt");function XF({message:e,downloadedAssets:t}){const n=e.role;switch(n){case"system":return{role:"system",content:e.content,providerOptions:e.providerOptions};case"user":return typeof e.content=="string"?{role:"user",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"user",content:e.content.map(r=>eE(r,t)).filter(r=>r.type!=="text"||r.text!==""),providerOptions:e.providerOptions};case"assistant":return typeof e.content=="string"?{role:"assistant",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"assistant",content:e.content.filter(r=>r.type!=="text"||r.text!==""||r.providerOptions!=null).map(r=>{const s=r.providerOptions;switch(r.type){case"file":{const{data:i,mediaType:o}=Nd(r.data);return{type:"file",data:i,filename:r.filename,mediaType:o??r.mediaType,providerOptions:s}}case"reasoning":return{type:"reasoning",text:r.text,providerOptions:s};case"text":return{type:"text",text:r.text,providerOptions:s};case"tool-call":return{type:"tool-call",toolCallId:r.toolCallId,toolName:r.toolName,input:r.input,providerExecuted:r.providerExecuted,providerOptions:s};case"tool-result":return{type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:r.output,providerOptions:s}}}),providerOptions:e.providerOptions};case"tool":return{role:"tool",content:e.content.map(r=>({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:r.output,providerOptions:r.providerOptions})),providerOptions:e.providerOptions};default:{const r=n;throw new jF({role:r})}}}a(XF,"convertToLanguageModelMessage");async function QF(e,t,n){const r=e.filter(i=>i.role==="user").map(i=>i.content).filter(i=>Array.isArray(i)).flat().filter(i=>i.type==="image"||i.type==="file").map(i=>{var o;const u=(o=i.mediaType)!=null?o:i.type==="image"?"image/*":void 0;let l=i.type==="image"?i.image:i.data;if(typeof l=="string")try{l=new URL(l)}catch{}return{mediaType:u,data:l}}).filter(i=>i.data instanceof URL).map(i=>({url:i.data,isUrlSupportedByModel:i.mediaType!=null&&n_({url:i.data.toString(),mediaType:i.mediaType,supportedUrls:n})})),s=await t(r);return Object.fromEntries(s.map((i,o)=>i==null?null:[r[o].url.toString(),{data:i.data,mediaType:i.mediaType}]).filter(i=>i!=null))}a(QF,"downloadAssets");function eE(e,t){var n;if(e.type==="text")return{type:"text",text:e.text,providerOptions:e.providerOptions};let r;const s=e.type;switch(s){case"image":r=e.image;break;case"file":r=e.data;break;default:throw new Error(`Unsupported part type: ${s}`)}const{data:i,mediaType:o}=Nd(r);let u=o??e.mediaType,l=i;if(l instanceof URL){const c=t[l.toString()];c&&(l=c.data,u??(u=c.mediaType))}switch(s){case"image":return(l instanceof Uint8Array||typeof l=="string")&&(u=(n=GF({data:l,signatures:UF}))!=null?n:u),{type:"file",mediaType:u??"image/*",filename:void 0,data:l,providerOptions:e.providerOptions};case"file":{if(u==null)throw new Error("Media type is missing for file part");return{type:"file",mediaType:u,filename:e.filename,data:l,providerOptions:e.providerOptions}}}}a(eE,"convertPartToLanguageModelPart");function Md({maxOutputTokens:e,temperature:t,topP:n,topK:r,presencePenalty:s,frequencyPenalty:i,seed:o,stopSequences:u}){if(e!=null){if(!Number.isInteger(e))throw new st({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be an integer"});if(e<1)throw new st({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be >= 1"})}if(t!=null&&typeof t!="number")throw new st({parameter:"temperature",value:t,message:"temperature must be a number"});if(n!=null&&typeof n!="number")throw new st({parameter:"topP",value:n,message:"topP must be a number"});if(r!=null&&typeof r!="number")throw new st({parameter:"topK",value:r,message:"topK must be a number"});if(s!=null&&typeof s!="number")throw new st({parameter:"presencePenalty",value:s,message:"presencePenalty must be a number"});if(i!=null&&typeof i!="number")throw new st({parameter:"frequencyPenalty",value:i,message:"frequencyPenalty must be a number"});if(o!=null&&!Number.isInteger(o))throw new st({parameter:"seed",value:o,message:"seed must be an integer"});return{maxOutputTokens:e,temperature:t,topP:n,topK:r,presencePenalty:s,frequencyPenalty:i,stopSequences:u,seed:o}}a(Md,"prepareCallSettings");function tE(e){return e!=null&&Object.keys(e).length>0}a(tE,"isNonEmptyObject");function nE({tools:e,toolChoice:t,activeTools:n}){return tE(e)?{tools:(n!=null?Object.entries(e).filter(([s])=>n.includes(s)):Object.entries(e)).map(([s,i])=>{const o=i.type;switch(o){case void 0:case"dynamic":case"function":return{type:"function",name:s,description:i.description,inputSchema:Wr(i.inputSchema).jsonSchema,providerOptions:i.providerOptions};case"provider-defined":return{type:"provider-defined",name:s,id:i.id,args:i.args};default:{const u=o;throw new Error(`Unsupported tool type: ${u}`)}}}),toolChoice:t==null?{type:"auto"}:typeof t=="string"?{type:t}:{type:"tool",toolName:t.toolName}}:{tools:void 0,toolChoice:void 0}}a(nE,"prepareToolsAndToolChoice");var ur=Yl(()=>Y([Fy(),m(),w(),Ae(),he(m(),ur),x(ur)])),tt=he(m(),he(m(),ur)),jd=y({type:k("text"),text:m(),providerOptions:tt.optional()}),rE=y({type:k("image"),image:Y([Pd,qr(URL)]),mediaType:m().optional(),providerOptions:tt.optional()}),zd=y({type:k("file"),data:Y([Pd,qr(URL)]),filename:m().optional(),mediaType:m(),providerOptions:tt.optional()}),oE=y({type:k("reasoning"),text:m(),providerOptions:tt.optional()}),sE=y({type:k("tool-call"),toolCallId:m(),toolName:m(),input:rt(),providerOptions:tt.optional(),providerExecuted:Ae().optional()}),iE=ke("type",[y({type:k("text"),value:m()}),y({type:k("json"),value:ur}),y({type:k("error-text"),value:m()}),y({type:k("error-json"),value:ur}),y({type:k("content"),value:x(Y([y({type:k("text"),text:m()}),y({type:k("media"),data:m(),mediaType:m()})]))})]),Zd=y({type:k("tool-result"),toolCallId:m(),toolName:m(),output:iE,providerOptions:tt.optional()}),aE=y({role:k("system"),content:m(),providerOptions:tt.optional()}),uE=y({role:k("user"),content:Y([m(),x(Y([jd,rE,zd]))]),providerOptions:tt.optional()}),lE=y({role:k("assistant"),content:Y([m(),x(Y([jd,zd,oE,sE,Zd]))]),providerOptions:tt.optional()}),cE=y({role:k("tool"),content:x(Zd),providerOptions:tt.optional()}),dE=Y([aE,uE,lE,cE]);async function pE(e){if(e.prompt==null&&e.messages==null)throw new lt({prompt:e,message:"prompt or messages must be defined"});if(e.prompt!=null&&e.messages!=null)throw new lt({prompt:e,message:"prompt and messages cannot be defined at the same time"});if(e.system!=null&&typeof e.system!="string")throw new lt({prompt:e,message:"system must be a string"});let t;if(e.prompt!=null&&typeof e.prompt=="string")t=[{role:"user",content:e.prompt}];else if(e.prompt!=null&&Array.isArray(e.prompt))t=e.prompt;else if(e.messages!=null)t=e.messages;else throw new lt({prompt:e,message:"prompt or messages must be defined"});if(t.length===0)throw new lt({prompt:e,message:"messages must not be empty"});const n=await ot({value:t,schema:x(dE)});if(!n.success)throw new lt({prompt:e,message:"The messages must be a ModelMessage[]. If you have passed a UIMessage[], you can use convertToModelMessages to convert them.",cause:n.error});return{messages:t,system:e.system}}a(pE,"standardizePrompt");function DE(e){return Ns.isInstance(e)||Pc.isInstance(e)?new N({name:"GatewayError",message:"Vercel AI Gateway access failed. If you want to use AI SDK providers directly, use the providers, e.g. @ai-sdk/openai, or register a different global default provider.",cause:e}):e}a(DE,"wrapGatewayError");function Js({operationId:e,telemetry:t}){return{"operation.name":`${e}${t?.functionId!=null?` ${t.functionId}`:""}`,"resource.name":t?.functionId,"ai.operationId":e,"ai.telemetry.functionId":t?.functionId}}a(Js,"assembleOperationName");function fE({model:e,settings:t,telemetry:n,headers:r}){var s;return{"ai.model.provider":e.provider,"ai.model.id":e.modelId,...Object.entries(t).reduce((i,[o,u])=>(i[`ai.settings.${o}`]=u,i),{}),...Object.entries((s=n?.metadata)!=null?s:{}).reduce((i,[o,u])=>(i[`ai.telemetry.metadata.${o}`]=u,i),{}),...Object.entries(r??{}).reduce((i,[o,u])=>(u!==void 0&&(i[`ai.request.headers.${o}`]=u),i),{})}}a(fE,"getBaseTelemetryAttributes");var mE={startSpan(){return Xr},startActiveSpan(e,t,n,r){if(typeof t=="function")return t(Xr);if(typeof n=="function")return n(Xr);if(typeof r=="function")return r(Xr)}},Xr={spanContext(){return hE},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this}},hE={traceId:"",spanId:"",traceFlags:0};function gE({isEnabled:e=!1,tracer:t}={}){return e?t||CF.getTracer("ai"):mE}a(gE,"getTracer");function Ks({name:e,tracer:t,attributes:n,fn:r,endWhenDone:s=!0}){return t.startActiveSpan(e,{attributes:n},async i=>{try{const o=await r(i);return s&&i.end(),o}catch(o){try{Ld(i,o)}finally{i.end()}throw o}})}a(Ks,"recordSpan");function Ld(e,t){t instanceof Error?(e.recordException({name:t.name,message:t.message,stack:t.stack}),e.setStatus({code:Yr.ERROR,message:t.message})):e.setStatus({code:Yr.ERROR})}a(Ld,"recordErrorOnSpan");function qt({telemetry:e,attributes:t}){return e?.isEnabled!==!0?{}:Object.entries(t).reduce((n,[r,s])=>{if(s==null)return n;if(typeof s=="object"&&"input"in s&&typeof s.input=="function"){if(e?.recordInputs===!1)return n;const i=s.input();return i==null?n:{...n,[r]:i}}if(typeof s=="object"&&"output"in s&&typeof s.output=="function"){if(e?.recordOutputs===!1)return n;const i=s.output();return i==null?n:{...n,[r]:i}}return{...n,[r]:s}},{})}a(qt,"selectTelemetryAttributes");function vE(e){return JSON.stringify(e.map(t=>({...t,content:typeof t.content=="string"?t.content:t.content.map(n=>n.type==="file"?{...n,data:n.data instanceof Uint8Array?KF(n.data):n.data}:n)})))}a(vE,"stringifyForTelemetry");function yE(e,t){return{inputTokens:lr(e.inputTokens,t.inputTokens),outputTokens:lr(e.outputTokens,t.outputTokens),totalTokens:lr(e.totalTokens,t.totalTokens),reasoningTokens:lr(e.reasoningTokens,t.reasoningTokens),cachedInputTokens:lr(e.cachedInputTokens,t.cachedInputTokens)}}a(yE,"addLanguageModelUsage");function lr(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}a(lr,"addTokenCounts");function _E(e){return e===void 0?[]:Array.isArray(e)?e:[e]}a(_E,"asArray");function FE({error:e,exponentialBackoffDelay:t}){const n=e.responseHeaders;if(!n)return t;let r;const s=n["retry-after-ms"];if(s){const o=parseFloat(s);Number.isNaN(o)||(r=o)}const i=n["retry-after"];if(i&&r===void 0){const o=parseFloat(i);Number.isNaN(o)?r=Date.parse(i)-Date.now():r=o*1e3}return r!=null&&!Number.isNaN(r)&&0<=r&&(r<60*1e3||r<t)?r:t}a(FE,"getRetryDelayInMs");var EE=a(({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:n=2,abortSignal:r}={})=>async s=>Ud(s,{maxRetries:e,delayInMs:t,backoffFactor:n,abortSignal:r}),"retryWithExponentialBackoffRespectingRetryHeaders");async function Ud(e,{maxRetries:t,delayInMs:n,backoffFactor:r,abortSignal:s},i=[]){try{return await e()}catch(o){if(zt(o)||t===0)throw o;const u=Ql(o),l=[...i,o],c=l.length;if(c>t)throw new Td({message:`Failed after ${c} attempts. Last error: ${u}`,reason:"maxRetriesExceeded",errors:l});if(o instanceof Error&&Ce.isInstance(o)&&o.isRetryable===!0&&c<=t)return await Xy(FE({error:o,exponentialBackoffDelay:n}),{abortSignal:s}),Ud(e,{maxRetries:t,delayInMs:r*n,backoffFactor:r,abortSignal:s},l);throw c===1?o:new Td({message:`Failed after ${c} attempts with non-retryable error: '${u}'`,reason:"errorNotRetryable",errors:l})}}a(Ud,"_retryWithExponentialBackoff");function CE({maxRetries:e,abortSignal:t}){if(!Number.isInteger(e))throw new st({parameter:"maxRetries",value:e,message:"maxRetries must be an integer"});const n=e;return{maxRetries:n,retry:EE({maxRetries:n,abortSignal:t})}}a(CE,"prepareRetries");function qd(e){const t=e.filter(n=>n.type==="text");if(t.length!==0)return t.map(n=>n.text).join("")}a(qd,"extractTextContent");var bE=(Fn=class{constructor({data:t,mediaType:n}){const r=t instanceof Uint8Array;this.base64Data=r?void 0:t,this.uint8ArrayData=r?t:void 0,this.mediaType=n}get base64(){return this.base64Data==null&&(this.base64Data=Jr(this.uint8ArrayData)),this.base64Data}get uint8Array(){return this.uint8ArrayData==null&&(this.uint8ArrayData=Hr(this.base64Data)),this.uint8ArrayData}},a(Fn,"DefaultGeneratedFile"),Fn);async function wE({toolCall:e,tools:t,repairToolCall:n,system:r,messages:s}){try{if(t==null)throw new Ws({toolName:e.toolName});try{return await Vd({toolCall:e,tools:t})}catch(i){if(n==null||!(Ws.isInstance(i)||Dd.isInstance(i)))throw i;let o=null;try{o=await n({toolCall:e,tools:t,inputSchema:a(({toolName:u})=>{const{inputSchema:l}=t[u];return Wr(l).jsonSchema},"inputSchema"),system:r,messages:s,error:i})}catch(u){throw new PF({cause:u,originalError:i})}if(o==null)throw i;return await Vd({toolCall:o,tools:t})}}catch(i){const o=await At({text:e.input}),u=o.success?o.value:e.input;return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:u,dynamic:!0,invalid:!0,error:i}}}a(wE,"parseToolCall");async function Vd({toolCall:e,tools:t}){const n=e.toolName,r=t[n];if(r==null)throw new Ws({toolName:e.toolName,availableTools:Object.keys(t)});const s=Wr(r.inputSchema),i=e.input.trim()===""?await ot({value:{},schema:s}):await At({text:e.input,schema:s});if(i.success===!1)throw new Dd({toolName:n,toolInput:e.input,cause:i.error});return r.type==="dynamic"?{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,dynamic:!0}:{type:"tool-call",toolCallId:e.toolCallId,toolName:n,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}}a(Vd,"doParseToolCall");var AE=(En=class{constructor({content:t,finishReason:n,usage:r,warnings:s,request:i,response:o,providerMetadata:u}){this.content=t,this.finishReason=n,this.usage=r,this.warnings=s,this.request=i,this.response=o,this.providerMetadata=u}get text(){return this.content.filter(t=>t.type==="text").map(t=>t.text).join("")}get reasoning(){return this.content.filter(t=>t.type==="reasoning")}get reasoningText(){return this.reasoning.length===0?void 0:this.reasoning.map(t=>t.text).join("")}get files(){return this.content.filter(t=>t.type==="file").map(t=>t.file)}get sources(){return this.content.filter(t=>t.type==="source")}get toolCalls(){return this.content.filter(t=>t.type==="tool-call")}get staticToolCalls(){return this.toolCalls.filter(t=>t.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(t=>t.dynamic===!0)}get toolResults(){return this.content.filter(t=>t.type==="tool-result")}get staticToolResults(){return this.toolResults.filter(t=>t.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(t=>t.dynamic===!0)}},a(En,"DefaultStepResult"),En);function kE(e){return({steps:t})=>t.length===e}a(kE,"stepCountIs");async function xE({stopConditions:e,steps:t}){return(await Promise.all(e.map(n=>n({steps:t})))).some(n=>n)}a(xE,"isStopConditionMet");function Ys({output:e,tool:t,errorMode:n}){return n==="text"?{type:"error-text",value:Gn(e)}:n==="json"?{type:"error-json",value:Gd(e)}:t?.toModelOutput?t.toModelOutput(e):typeof e=="string"?{type:"text",value:e}:{type:"json",value:Gd(e)}}a(Ys,"createToolModelOutput");function Gd(e){return e===void 0?null:e}a(Gd,"toJSONValue");function IE({content:e,tools:t}){const n=[],r=e.filter(i=>i.type!=="source").filter(i=>(i.type!=="tool-result"||i.providerExecuted)&&(i.type!=="tool-error"||i.providerExecuted)).filter(i=>i.type!=="text"||i.text.length>0).map(i=>{switch(i.type){case"text":return{type:"text",text:i.text,providerOptions:i.providerMetadata};case"reasoning":return{type:"reasoning",text:i.text,providerOptions:i.providerMetadata};case"file":return{type:"file",data:i.file.base64,mediaType:i.file.mediaType,providerOptions:i.providerMetadata};case"tool-call":return{type:"tool-call",toolCallId:i.toolCallId,toolName:i.toolName,input:i.input,providerExecuted:i.providerExecuted,providerOptions:i.providerMetadata};case"tool-result":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Ys({tool:t?.[i.toolName],output:i.output,errorMode:"none"}),providerExecuted:!0,providerOptions:i.providerMetadata};case"tool-error":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Ys({tool:t?.[i.toolName],output:i.error,errorMode:"json"}),providerOptions:i.providerMetadata}}});r.length>0&&n.push({role:"assistant",content:r});const s=e.filter(i=>i.type==="tool-result"||i.type==="tool-error").filter(i=>!i.providerExecuted).map(i=>({type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Ys({tool:t?.[i.toolName],output:i.type==="tool-result"?i.output:i.error,errorMode:i.type==="tool-error"?"text":"none"}),...i.providerMetadata!=null?{providerOptions:i.providerMetadata}:{}}));return s.length>0&&n.push({role:"tool",content:s}),n}a(IE,"toResponseMessages");var $E=tr({prefix:"aitxt",size:24});async function BE({model:e,tools:t,toolChoice:n,system:r,prompt:s,messages:i,maxRetries:o,abortSignal:u,headers:l,stopWhen:c=kE(1),experimental_output:d,experimental_telemetry:p,providerOptions:h,experimental_activeTools:f,activeTools:D=f,experimental_prepareStep:g,prepareStep:v=g,experimental_repairToolCall:F,experimental_download:C,experimental_context:_,_internal:{generateId:b=$E,currentDate:B=a(()=>new Date,"currentDate")}={},onStepFinish:O,...S}){const $=Od(e),G=_E(c),{maxRetries:z,retry:J}=CE({maxRetries:o,abortSignal:u}),L=Md(S),le=wt(l??{},`ai/${Rd}`),W=fE({model:$,telemetry:p,headers:le,settings:{...L,maxRetries:z}}),ee=await pE({system:r,prompt:s,messages:i}),te=gE(p);try{return await Ks({name:"ai.generateText",attributes:qt({telemetry:p,attributes:{...Js({operationId:"ai.generateText",telemetry:p}),...W,"ai.model.provider":$.provider,"ai.model.id":$.modelId,"ai.prompt":{input:a(()=>JSON.stringify({system:r,prompt:s,messages:i}),"input")}}}),tracer:te,fn:a(async R=>{var U,M,xe,ce,ne,q,Be;const qe=Md(S);let E,V=[],de=[];const ve=[],Je=[];do{const it=[...ee.messages,...ve],Ke=await v?.({model:$,steps:Je,stepNumber:Je.length,messages:it}),mt=Od((U=Ke?.model)!=null?U:$),mi=await YF({prompt:{system:(M=Ke?.system)!=null?M:ee.system,messages:(xe=Ke?.messages)!=null?xe:it},supportedUrls:await mt.supportedUrls,download:C}),{toolChoice:ro,tools:oo}=nE({tools:t,toolChoice:(ce=Ke?.toolChoice)!=null?ce:n,activeTools:(ne=Ke?.activeTools)!=null?ne:D});E=await J(()=>{var pe;return Ks({name:"ai.generateText.doGenerate",attributes:qt({telemetry:p,attributes:{...Js({operationId:"ai.generateText.doGenerate",telemetry:p}),...W,"ai.model.provider":mt.provider,"ai.model.id":mt.modelId,"ai.prompt.messages":{input:a(()=>vE(mi),"input")},"ai.prompt.tools":{input:a(()=>oo?.map(ht=>JSON.stringify(ht)),"input")},"ai.prompt.toolChoice":{input:a(()=>ro!=null?JSON.stringify(ro):void 0,"input")},"gen_ai.system":mt.provider,"gen_ai.request.model":mt.modelId,"gen_ai.request.frequency_penalty":S.frequencyPenalty,"gen_ai.request.max_tokens":S.maxOutputTokens,"gen_ai.request.presence_penalty":S.presencePenalty,"gen_ai.request.stop_sequences":S.stopSequences,"gen_ai.request.temperature":(pe=S.temperature)!=null?pe:void 0,"gen_ai.request.top_k":S.topK,"gen_ai.request.top_p":S.topP}}),tracer:te,fn:a(async ht=>{var vi,yi,_i,Fi,Ei,Ci,bi,wi;const Se=await mt.doGenerate({...qe,tools:oo,toolChoice:ro,responseFormat:d?.responseFormat,prompt:mi,providerOptions:h,abortSignal:u,headers:le}),St={id:(yi=(vi=Se.response)==null?void 0:vi.id)!=null?yi:b(),timestamp:(Fi=(_i=Se.response)==null?void 0:_i.timestamp)!=null?Fi:B(),modelId:(Ci=(Ei=Se.response)==null?void 0:Ei.modelId)!=null?Ci:mt.modelId,headers:(bi=Se.response)==null?void 0:bi.headers,body:(wi=Se.response)==null?void 0:wi.body};return ht.setAttributes(qt({telemetry:p,attributes:{"ai.response.finishReason":Se.finishReason,"ai.response.text":{output:a(()=>qd(Se.content),"output")},"ai.response.toolCalls":{output:a(()=>{const Ai=Wd(Se.content);return Ai==null?void 0:JSON.stringify(Ai)},"output")},"ai.response.id":St.id,"ai.response.model":St.modelId,"ai.response.timestamp":St.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(Se.providerMetadata),"ai.usage.promptTokens":Se.usage.inputTokens,"ai.usage.completionTokens":Se.usage.outputTokens,"gen_ai.response.finish_reasons":[Se.finishReason],"gen_ai.response.id":St.id,"gen_ai.response.model":St.modelId,"gen_ai.usage.input_tokens":Se.usage.inputTokens,"gen_ai.usage.output_tokens":Se.usage.outputTokens}})),{...Se,response:St}},"fn")})});const dr=await Promise.all(E.content.filter(pe=>pe.type==="tool-call").map(pe=>wE({toolCall:pe,tools:t,repairToolCall:F,system:r,messages:it})));for(const pe of dr){if(pe.invalid)continue;const ht=t[pe.toolName];ht?.onInputAvailable!=null&&await ht.onInputAvailable({input:pe.input,toolCallId:pe.toolCallId,messages:it,abortSignal:u,experimental_context:_})}const Cp=dr.filter(pe=>pe.invalid&&pe.dynamic);de=[];for(const pe of Cp)de.push({type:"tool-error",toolCallId:pe.toolCallId,toolName:pe.toolName,input:pe.input,error:Ql(pe.error),dynamic:!0});V=dr.filter(pe=>!pe.providerExecuted),t!=null&&de.push(...await SE({toolCalls:V.filter(pe=>!pe.invalid),tools:t,tracer:te,telemetry:p,messages:it,abortSignal:u,experimental_context:_}));const hi=OE({content:E.content,toolCalls:dr,toolOutputs:de});ve.push(...IE({content:hi,tools:t}));const gi=new AE({content:hi,finishReason:E.finishReason,usage:E.usage,warnings:E.warnings,providerMetadata:E.providerMetadata,request:(q=E.request)!=null?q:{},response:{...E.response,messages:structuredClone(ve)}});$F((Be=E.warnings)!=null?Be:[]),Je.push(gi),await O?.(gi)}while(V.length>0&&de.length===V.length&&!await xE({stopConditions:G,steps:Je}));R.setAttributes(qt({telemetry:p,attributes:{"ai.response.finishReason":E.finishReason,"ai.response.text":{output:a(()=>qd(E.content),"output")},"ai.response.toolCalls":{output:a(()=>{const it=Wd(E.content);return it==null?void 0:JSON.stringify(it)},"output")},"ai.response.providerMetadata":JSON.stringify(E.providerMetadata),"ai.usage.promptTokens":E.usage.inputTokens,"ai.usage.completionTokens":E.usage.outputTokens}}));const Rn=Je[Je.length-1];let fi;return Rn.finishReason==="stop"&&(fi=await d?.parseOutput({text:Rn.text},{response:Rn.response,usage:Rn.usage,finishReason:Rn.finishReason})),new TE({steps:Je,resolvedOutput:fi})},"fn")})}catch(R){throw DE(R)}}a(BE,"generateText");async function SE({toolCalls:e,tools:t,tracer:n,telemetry:r,messages:s,abortSignal:i,experimental_context:o}){return(await Promise.all(e.map(async({toolCallId:l,toolName:c,input:d})=>{const p=t[c];if(p?.execute!=null)return Ks({name:"ai.toolCall",attributes:qt({telemetry:r,attributes:{...Js({operationId:"ai.toolCall",telemetry:r}),"ai.toolCall.name":c,"ai.toolCall.id":l,"ai.toolCall.args":{output:a(()=>JSON.stringify(d),"output")}}}),tracer:n,fn:a(async h=>{try{const f=d2({execute:p.execute.bind(p),input:d,options:{toolCallId:l,messages:s,abortSignal:i,experimental_context:o}});let D;for await(const g of f)g.type==="final"&&(D=g.output);try{h.setAttributes(qt({telemetry:r,attributes:{"ai.toolCall.result":{output:a(()=>JSON.stringify(D),"output")}}}))}catch{}return{type:"tool-result",toolCallId:l,toolName:c,input:d,output:D,dynamic:p.type==="dynamic"}}catch(f){return Ld(h,f),{type:"tool-error",toolCallId:l,toolName:c,input:d,error:f,dynamic:p.type==="dynamic"}}},"fn")})}))).filter(l=>l!=null)}a(SE,"executeTools");var TE=(Cn=class{constructor(t){this.steps=t.steps,this.resolvedOutput=t.resolvedOutput}get finalStep(){return this.steps[this.steps.length-1]}get content(){return this.finalStep.content}get text(){return this.finalStep.text}get files(){return this.finalStep.files}get reasoningText(){return this.finalStep.reasoningText}get reasoning(){return this.finalStep.reasoning}get toolCalls(){return this.finalStep.toolCalls}get staticToolCalls(){return this.finalStep.staticToolCalls}get dynamicToolCalls(){return this.finalStep.dynamicToolCalls}get toolResults(){return this.finalStep.toolResults}get staticToolResults(){return this.finalStep.staticToolResults}get dynamicToolResults(){return this.finalStep.dynamicToolResults}get sources(){return this.finalStep.sources}get finishReason(){return this.finalStep.finishReason}get warnings(){return this.finalStep.warnings}get providerMetadata(){return this.finalStep.providerMetadata}get response(){return this.finalStep.response}get request(){return this.finalStep.request}get usage(){return this.finalStep.usage}get totalUsage(){return this.steps.reduce((t,n)=>yE(t,n.usage),{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0})}get experimental_output(){if(this.resolvedOutput==null)throw new kF;return this.resolvedOutput}},a(Cn,"DefaultGenerateTextResult"),Cn);function Wd(e){const t=e.filter(n=>n.type==="tool-call");if(t.length!==0)return t.map(n=>({toolCallId:n.toolCallId,toolName:n.toolName,input:n.input}))}a(Wd,"asToolCalls");function OE({content:e,toolCalls:t,toolOutputs:n}){return[...e.map(r=>{switch(r.type){case"text":case"reasoning":case"source":return r;case"file":return{type:"file",file:new bE(r)};case"tool-call":return t.find(s=>s.toolCallId===r.toolCallId);case"tool-result":{const s=t.find(i=>i.toolCallId===r.toolCallId);if(s==null)throw new Error(`Tool call ${r.toolCallId} not found.`);return r.isError?{type:"tool-error",toolCallId:r.toolCallId,toolName:r.toolName,input:s.input,error:r.result,providerExecuted:!0,dynamic:s.dynamic}:{type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,input:s.input,output:r.result,providerExecuted:!0,dynamic:s.dynamic}}}}),...n]}a(OE,"asContent"),class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
137
|
+
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,new Rt({message:o,statusCode:s,cause:i})}},a(Rt,"_GatewayAuthenticationError"),Rt),Ac="GatewayInvalidRequestError",v2=`vercel.ai.gateway.error.${Ac}`,kc=Symbol.for(v2),xc,$c,y2=(sn=class extends($c=Le,xc=kc,$c){constructor({message:t="Invalid request",statusCode:n=400,cause:r}={}){super({message:t,statusCode:n,cause:r}),this[xc]=!0,this.name=Ac,this.type="invalid_request_error"}static isInstance(t){return Le.hasMarker(t)&&kc in t}},a(sn,"GatewayInvalidRequestError"),sn),Ic="GatewayRateLimitError",_2=`vercel.ai.gateway.error.${Ic}`,Bc=Symbol.for(_2),Sc,Tc,F2=(an=class extends(Tc=Le,Sc=Bc,Tc){constructor({message:t="Rate limit exceeded",statusCode:n=429,cause:r}={}){super({message:t,statusCode:n,cause:r}),this[Sc]=!0,this.name=Ic,this.type="rate_limit_exceeded"}static isInstance(t){return Le.hasMarker(t)&&Bc in t}},a(an,"GatewayRateLimitError"),an),Oc="GatewayModelNotFoundError",E2=`vercel.ai.gateway.error.${Oc}`,Rc=Symbol.for(E2),C2=ve(()=>Z(y({modelId:m()}))),Pc,Nc,Mc=(un=class extends(Nc=Le,Pc=Rc,Nc){constructor({message:t="Model not found",statusCode:n=404,modelId:r,cause:s}={}){super({message:t,statusCode:n,cause:s}),this[Pc]=!0,this.name=Oc,this.type="model_not_found",this.modelId=r}static isInstance(t){return Le.hasMarker(t)&&Rc in t}},a(un,"GatewayModelNotFoundError"),un),jc="GatewayInternalServerError",b2=`vercel.ai.gateway.error.${jc}`,zc=Symbol.for(b2),Zc,Lc,Uc=(ln=class extends(Lc=Le,Zc=zc,Lc){constructor({message:t="Internal server error",statusCode:n=500,cause:r}={}){super({message:t,statusCode:n,cause:r}),this[Zc]=!0,this.name=jc,this.type="internal_server_error"}static isInstance(t){return Le.hasMarker(t)&&zc in t}},a(ln,"GatewayInternalServerError"),ln),qc="GatewayResponseError",w2=`vercel.ai.gateway.error.${qc}`,Vc=Symbol.for(w2),Gc,Wc,A2=(cn=class extends(Wc=Le,Gc=Vc,Wc){constructor({message:t="Invalid response from Gateway",statusCode:n=502,response:r,validationError:s,cause:i}={}){super({message:t,statusCode:n,cause:i}),this[Gc]=!0,this.name=qc,this.type="response_error",this.response=r,this.validationError=s}static isInstance(t){return Le.hasMarker(t)&&Vc in t}},a(cn,"GatewayResponseError"),cn);async function Hc({response:e,statusCode:t,defaultMessage:n="Gateway request failed",cause:r,authMethod:s}){const i=await it({value:e,schema:k2});if(!i.success)return new A2({message:`Invalid error response format: ${n}`,statusCode:t,response:e,validationError:i.error,cause:r});const o=i.value,u=o.error.type,l=o.error.message;switch(u){case"authentication_error":return Ms.createContextualError({apiKeyProvided:s==="api-key",oidcTokenProvided:s==="oidc",statusCode:t,cause:r});case"invalid_request_error":return new y2({message:l,statusCode:t,cause:r});case"rate_limit_exceeded":return new F2({message:l,statusCode:t,cause:r});case"model_not_found":{const c=await it({value:o.error.param,schema:C2});return new Mc({message:l,statusCode:t,modelId:c.success?c.value.modelId:void 0,cause:r})}case"internal_server_error":return new Uc({message:l,statusCode:t,cause:r});default:return new Uc({message:l,statusCode:t,cause:r})}}a(Hc,"createGatewayErrorFromResponse");var k2=ve(()=>Z(y({error:y({message:m(),type:m().nullish(),param:st().nullish(),code:X([m(),w()]).nullish()})})));function mt(e,t){var n;return Le.isInstance(e)?e:be.isInstance(e)?Hc({response:x2(e),statusCode:(n=e.statusCode)!=null?n:500,defaultMessage:"Gateway request failed",cause:e,authMethod:t}):Hc({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:"Unknown Gateway error",cause:e,authMethod:t})}a(mt,"asGatewayError");function x2(e){if(e.data!==void 0)return e.data;if(e.responseBody!=null)try{return JSON.parse(e.responseBody)}catch{return e.responseBody}return{}}a(x2,"extractApiCallResponse");var Jc="ai-gateway-auth-method";async function Wt(e){const t=await it({value:e[Jc],schema:$2});return t.success?t.value:void 0}a(Wt,"parseAuthMethod");var $2=ve(()=>Z(X([k("api-key"),k("oidc")]))),Kc=(dn=class{constructor(t){this.config=t}async getAvailableModels(){try{const{value:t}=await oc({url:`${this.config.baseURL}/config`,headers:await nt(this.config.headers()),successfulResponseHandler:Te(I2),failedResponseHandler:We({errorSchema:Me(),errorToMessage:a(n=>n,"errorToMessage")}),fetch:this.config.fetch});return t}catch(t){throw await mt(t)}}async getCredits(){try{const t=new URL(this.config.baseURL),{value:n}=await oc({url:`${t.origin}/v1/credits`,headers:await nt(this.config.headers()),successfulResponseHandler:Te(B2),failedResponseHandler:We({errorSchema:Me(),errorToMessage:a(r=>r,"errorToMessage")}),fetch:this.config.fetch});return n}catch(t){throw await mt(t)}}},a(dn,"GatewayFetchMetadata"),dn),I2=ve(()=>Z(y({models:$(y({id:m(),name:m(),description:m().nullish(),pricing:y({input:m(),output:m(),input_cache_read:m().nullish(),input_cache_write:m().nullish()}).transform(({input:e,output:t,input_cache_read:n,input_cache_write:r})=>({input:e,output:t,...n?{cachedInputTokens:n}:{},...r?{cacheCreationInputTokens:r}:{}})).nullish(),specification:y({specificationVersion:k("v2"),provider:m(),modelId:m()}),modelType:ie(["language","embedding","image"]).nullish()}))}))),B2=ve(()=>Z(y({balance:m(),total_used:m()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),S2=(pn=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2",this.supportedUrls={"*/*":[/.*/]}}get provider(){return this.config.provider}async getArgs(t){const{abortSignal:n,...r}=t;return{args:this.maybeEncodeFileParts(r),warnings:[]}}async doGenerate(t){const{args:n,warnings:r}=await this.getArgs(t),{abortSignal:s}=t,i=await nt(this.config.headers());try{const{responseHeaders:o,value:u,rawValue:l}=await Ce({url:this.getUrl(),headers:_e(i,t.headers,this.getModelConfigHeaders(this.modelId,!1),await nt(this.config.o11yHeaders)),body:n,successfulResponseHandler:Te(Me()),failedResponseHandler:We({errorSchema:Me(),errorToMessage:a(c=>c,"errorToMessage")}),...s&&{abortSignal:s},fetch:this.config.fetch});return{...u,request:{body:n},response:{headers:o,body:l},warnings:r}}catch(o){throw await mt(o,await Wt(i))}}async doStream(t){const{args:n,warnings:r}=await this.getArgs(t),{abortSignal:s}=t,i=await nt(this.config.headers());try{const{value:o,responseHeaders:u}=await Ce({url:this.getUrl(),headers:_e(i,t.headers,this.getModelConfigHeaders(this.modelId,!0),await nt(this.config.o11yHeaders)),body:n,successfulResponseHandler:Gt(Me()),failedResponseHandler:We({errorSchema:Me(),errorToMessage:a(l=>l,"errorToMessage")}),...s&&{abortSignal:s},fetch:this.config.fetch});return{stream:o.pipeThrough(new TransformStream({start(l){r.length>0&&l.enqueue({type:"stream-start",warnings:r})},transform(l,c){if(l.success){const d=l.value;if(d.type==="raw"&&!t.includeRawChunks)return;d.type==="response-metadata"&&d.timestamp&&typeof d.timestamp=="string"&&(d.timestamp=new Date(d.timestamp)),c.enqueue(d)}else c.error(l.error)}})),request:{body:n},response:{headers:u}}}catch(o){throw await mt(o,await Wt(i))}}isFilePart(t){return t&&typeof t=="object"&&"type"in t&&t.type==="file"}maybeEncodeFileParts(t){for(const n of t.prompt)for(const r of n.content)if(this.isFilePart(r)){const s=r;if(s.data instanceof Uint8Array){const i=Uint8Array.from(s.data),o=Buffer.from(i).toString("base64");s.data=new URL(`data:${s.mediaType||"application/octet-stream"};base64,${o}`)}}return t}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(t,n){return{"ai-language-model-specification-version":"2","ai-language-model-id":t,"ai-language-model-streaming":String(n)}}},a(pn,"GatewayLanguageModel"),pn),T2=(Dn=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}get provider(){return this.config.provider}async doEmbed({values:t,headers:n,abortSignal:r,providerOptions:s}){var i;const o=await nt(this.config.headers());try{const{responseHeaders:u,value:l,rawValue:c}=await Ce({url:this.getUrl(),headers:_e(o,n??{},this.getModelConfigHeaders(),await nt(this.config.o11yHeaders)),body:{input:t.length===1?t[0]:t,...s?{providerOptions:s}:{}},successfulResponseHandler:Te(O2),failedResponseHandler:We({errorSchema:Me(),errorToMessage:a(d=>d,"errorToMessage")}),...r&&{abortSignal:r},fetch:this.config.fetch});return{embeddings:l.embeddings,usage:(i=l.usage)!=null?i:void 0,providerMetadata:l.providerMetadata,response:{headers:u,body:c}}}catch(u){throw await mt(u,await Wt(o))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":"2","ai-model-id":this.modelId}}},a(Dn,"GatewayEmbeddingModel"),Dn),O2=ve(()=>Z(y({embeddings:$($(w())),usage:y({tokens:w()}).nullish(),providerMetadata:ge(m(),ge(m(),st())).optional()}))),R2=(fn=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2",this.maxImagesPerCall=Number.MAX_SAFE_INTEGER}get provider(){return this.config.provider}async doGenerate({prompt:t,n,size:r,aspectRatio:s,seed:i,providerOptions:o,headers:u,abortSignal:l}){var c;const d=await nt(this.config.headers());try{const{responseHeaders:p,value:h,rawValue:f}=await Ce({url:this.getUrl(),headers:_e(d,u??{},this.getModelConfigHeaders(),await nt(this.config.o11yHeaders)),body:{prompt:t,n,...r&&{size:r},...s&&{aspectRatio:s},...i&&{seed:i},...o&&{providerOptions:o}},successfulResponseHandler:Te(N2),failedResponseHandler:We({errorSchema:Me(),errorToMessage:a(D=>D,"errorToMessage")}),...l&&{abortSignal:l},fetch:this.config.fetch});return{images:h.images,warnings:(c=h.warnings)!=null?c:[],providerMetadata:h.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:p}}}catch(p){throw mt(p,await Wt(d))}}getUrl(){return`${this.config.baseURL}/image-model`}getModelConfigHeaders(){return{"ai-image-model-specification-version":"2","ai-model-id":this.modelId}}},a(fn,"GatewayImageModel"),fn),P2=y({images:$(st()).optional()}).catchall(st()),N2=y({images:$(m()),warnings:$(y({type:k("other"),message:m()})).optional(),providerMetadata:ge(m(),P2).optional()});async function M2(){var e;return(e=yc.getContext().headers)==null?void 0:e["x-vercel-id"]}a(M2,"getVercelRequestId");var j2="2.0.17",z2="0.0.1";function Z2(e={}){var t,n;let r=null,s=null;const i=(t=e.metadataCacheRefreshMillis)!=null?t:1e3*60*5;let o=0;const u=(n=Ss(e.baseURL))!=null?n:"https://ai-gateway.vercel.sh/v1/ai",l=a(async()=>{const D=await U2(e);if(D)return $t({Authorization:`Bearer ${D.token}`,"ai-gateway-protocol-version":z2,[Jc]:D.authMethod,...e.headers},`ai-sdk/gateway/${j2}`);throw Ms.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401})},"getHeaders"),c=a(()=>{const D=or({settingValue:void 0,environmentVariableName:"VERCEL_DEPLOYMENT_ID"}),g=or({settingValue:void 0,environmentVariableName:"VERCEL_ENV"}),v=or({settingValue:void 0,environmentVariableName:"VERCEL_REGION"});return async()=>{const F=await M2();return{...D&&{"ai-o11y-deployment-id":D},...g&&{"ai-o11y-environment":g},...v&&{"ai-o11y-region":v},...F&&{"ai-o11y-request-id":F}}}},"createO11yHeaders"),d=a(D=>new S2(D,{provider:"gateway",baseURL:u,headers:l,fetch:e.fetch,o11yHeaders:c()}),"createLanguageModel"),p=a(async()=>{var D,g,v;const F=(v=(g=(D=e._internal)==null?void 0:D.currentDate)==null?void 0:g.call(D).getTime())!=null?v:Date.now();return(!r||F-o>i)&&(o=F,r=new Kc({baseURL:u,headers:l,fetch:e.fetch}).getAvailableModels().then(C=>(s=C,C)).catch(async C=>{throw await mt(C,await Wt(await l()))})),s?Promise.resolve(s):r},"getAvailableModels"),h=a(async()=>new Kc({baseURL:u,headers:l,fetch:e.fetch}).getCredits().catch(async D=>{throw await mt(D,await Wt(await l()))}),"getCredits"),f=a(function(D){if(new.target)throw new Error("The Gateway Provider model function cannot be called with the new keyword.");return d(D)},"provider");return f.getAvailableModels=p,f.getCredits=h,f.imageModel=D=>new R2(D,{provider:"gateway",baseURL:u,headers:l,fetch:e.fetch,o11yHeaders:c()}),f.languageModel=d,f.textEmbeddingModel=D=>new T2(D,{provider:"gateway",baseURL:u,headers:l,fetch:e.fetch,o11yHeaders:c()}),f}a(Z2,"createGatewayProvider");var L2=Z2();async function U2(e){const t=or({settingValue:e.apiKey,environmentVariableName:"AI_GATEWAY_API_KEY"});if(t)return{token:t,authMethod:"api-key"};try{return{token:await yc.getVercelOidcToken(),authMethod:"oidc"}}catch{return null}}a(U2,"getGatewayAuthToken");var q2=typeof globalThis=="object"?globalThis:global,St="1.9.0",Yc=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function V2(e){var t=new Set([e]),n=new Set,r=e.match(Yc);if(!r)return function(){return!1};var s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(s.prerelease!=null)return a(function(l){return l===e},"isExactmatch");function i(u){return n.add(u),!1}a(i,"_reject");function o(u){return t.add(u),!0}return a(o,"_accept"),a(function(l){if(t.has(l))return!0;if(n.has(l))return!1;var c=l.match(Yc);if(!c)return i(l);var d={major:+c[1],minor:+c[2],patch:+c[3],prerelease:c[4]};return d.prerelease!=null||s.major!==d.major?i(l):s.major===0?s.minor===d.minor&&s.patch<=d.patch?o(l):i(l):s.minor<=d.minor?o(l):i(l)},"isCompatible2")}a(V2,"_makeCompatibilityCheck");var G2=V2(St),W2=St.split(".")[0],sr=Symbol.for("opentelemetry.js.api."+W2),ir=q2;function js(e,t,n,r){var s;r===void 0&&(r=!1);var i=ir[sr]=(s=ir[sr])!==null&&s!==void 0?s:{version:St};if(!r&&i[e]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return n.error(o.stack||o.message),!1}if(i.version!==St){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+e+" does not match previously registered API v"+St);return n.error(o.stack||o.message),!1}return i[e]=t,n.debug("@opentelemetry/api: Registered a global for "+e+" v"+St+"."),!0}a(js,"registerGlobal");function ar(e){var t,n,r=(t=ir[sr])===null||t===void 0?void 0:t.version;if(!(!r||!G2(r)))return(n=ir[sr])===null||n===void 0?void 0:n[e]}a(ar,"getGlobal");function zs(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+St+".");var n=ir[sr];n&&delete n[e]}a(zs,"unregisterGlobal");var H2=a(function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(u){o={error:u}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},"__read$3"),J2=a(function(e,t,n){if(arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},"__spreadArray$3"),K2=(function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return a(e,"DiagComponentLogger2"),e.prototype.debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ur("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ur("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ur("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ur("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ur("verbose",this._namespace,t)},e})();function ur(e,t,n){var r=ar("diag");if(r)return n.unshift(t),r[e].apply(r,J2([],H2(n),!1))}a(ur,"logProxy");var Ue;(function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"})(Ue||(Ue={}));function Y2(e,t){e<Ue.NONE?e=Ue.NONE:e>Ue.ALL&&(e=Ue.ALL),t=t||{};function n(r,s){var i=t[r];return typeof i=="function"&&e>=s?i.bind(t):function(){}}return a(n,"_filterFunc"),{error:n("error",Ue.ERROR),warn:n("warn",Ue.WARN),info:n("info",Ue.INFO),debug:n("debug",Ue.DEBUG),verbose:n("verbose",Ue.VERBOSE)}}a(Y2,"createLogLevelDiagLogger");var X2=a(function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(u){o={error:u}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},"__read$2"),Q2=a(function(e,t,n){if(arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},"__spreadArray$2"),eF="diag",eo=(function(){function e(){function t(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var u=ar("diag");if(u)return u[s].apply(u,Q2([],X2(i),!1))}}a(t,"_logProxy");var n=this,r=a(function(s,i){var o,u,l;if(i===void 0&&(i={logLevel:Ue.INFO}),s===n){var c=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return n.error((o=c.stack)!==null&&o!==void 0?o:c.message),!1}typeof i=="number"&&(i={logLevel:i});var d=ar("diag"),p=Y2((u=i.logLevel)!==null&&u!==void 0?u:Ue.INFO,s);if(d&&!i.suppressOverrideMessage){var h=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";d.warn("Current logger will be overwritten from "+h),p.warn("Current logger will overwrite one already registered from "+h)}return js("diag",p,n,!0)},"setLogger");n.setLogger=r,n.disable=function(){zs(eF,n)},n.createComponentLogger=function(s){return new K2(s)},n.verbose=t("verbose"),n.debug=t("debug"),n.info=t("info"),n.warn=t("warn"),n.error=t("error")}return a(e,"DiagAPI2"),e.instance=function(){return this._instance||(this._instance=new e),this._instance},e})();function tF(e){return Symbol.for(e)}a(tF,"createContextKey");var nF=(function(){function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(r){return n._currentContext.get(r)},n.setValue=function(r,s){var i=new e(n._currentContext);return i._currentContext.set(r,s),i},n.deleteValue=function(r){var s=new e(n._currentContext);return s._currentContext.delete(r),s}}return a(e,"BaseContext2"),e})(),rF=new nF,oF=a(function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(u){o={error:u}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},"__read$1"),sF=a(function(e,t,n){if(arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},"__spreadArray$1"),iF=(function(){function e(){}return a(e,"NoopContextManager2"),e.prototype.active=function(){return rF},e.prototype.with=function(t,n,r){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return n.call.apply(n,sF([r],oF(s),!1))},e.prototype.bind=function(t,n){return n},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e})(),aF=a(function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(u){o={error:u}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},"__read"),uF=a(function(e,t,n){if(arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},"__spreadArray"),Zs="context",lF=new iF,Xc=(function(){function e(){}return a(e,"ContextAPI2"),e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return js(Zs,t,eo.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,n,r){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,uF([t,n,r],aF(i),!1))},e.prototype.bind=function(t,n){return this._getContextManager().bind(t,n)},e.prototype._getContextManager=function(){return ar(Zs)||lF},e.prototype.disable=function(){this._getContextManager().disable(),zs(Zs,eo.instance())},e})(),Ls;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(Ls||(Ls={}));var Qc="0000000000000000",ed="00000000000000000000000000000000",cF={traceId:ed,spanId:Qc,traceFlags:Ls.NONE},lr=(function(){function e(t){t===void 0&&(t=cF),this._spanContext=t}return a(e,"NonRecordingSpan2"),e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,n){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,n){return this},e.prototype.addLink=function(t){return this},e.prototype.addLinks=function(t){return this},e.prototype.setStatus=function(t){return this},e.prototype.updateName=function(t){return this},e.prototype.end=function(t){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(t,n){},e})(),Us=tF("OpenTelemetry Context Key SPAN");function qs(e){return e.getValue(Us)||void 0}a(qs,"getSpan");function dF(){return qs(Xc.getInstance().active())}a(dF,"getActiveSpan");function Vs(e,t){return e.setValue(Us,t)}a(Vs,"setSpan");function pF(e){return e.deleteValue(Us)}a(pF,"deleteSpan");function DF(e,t){return Vs(e,new lr(t))}a(DF,"setSpanContext");function td(e){var t;return(t=qs(e))===null||t===void 0?void 0:t.spanContext()}a(td,"getSpanContext");var fF=/^([0-9a-f]{32})$/i,mF=/^[0-9a-f]{16}$/i;function hF(e){return fF.test(e)&&e!==ed}a(hF,"isValidTraceId");function gF(e){return mF.test(e)&&e!==Qc}a(gF,"isValidSpanId");function nd(e){return hF(e.traceId)&&gF(e.spanId)}a(nd,"isSpanContextValid");function vF(e){return new lr(e)}a(vF,"wrapSpanContext");var Gs=Xc.getInstance(),rd=(function(){function e(){}return a(e,"NoopTracer2"),e.prototype.startSpan=function(t,n,r){r===void 0&&(r=Gs.active());var s=!!n?.root;if(s)return new lr;var i=r&&td(r);return yF(i)&&nd(i)?new lr(i):new lr},e.prototype.startActiveSpan=function(t,n,r,s){var i,o,u;if(!(arguments.length<2)){arguments.length===2?u=n:arguments.length===3?(i=n,u=r):(i=n,o=r,u=s);var l=o??Gs.active(),c=this.startSpan(t,i,l),d=Vs(l,c);return Gs.with(d,u,void 0,c)}},e})();function yF(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}a(yF,"isSpanContext");var _F=new rd,FF=(function(){function e(t,n,r,s){this._provider=t,this.name=n,this.version=r,this.options=s}return a(e,"ProxyTracer2"),e.prototype.startSpan=function(t,n,r){return this._getTracer().startSpan(t,n,r)},e.prototype.startActiveSpan=function(t,n,r,s){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):_F},e})(),EF=(function(){function e(){}return a(e,"NoopTracerProvider2"),e.prototype.getTracer=function(t,n,r){return new rd},e})(),CF=new EF,od=(function(){function e(){}return a(e,"ProxyTracerProvider2"),e.prototype.getTracer=function(t,n,r){var s;return(s=this.getDelegateTracer(t,n,r))!==null&&s!==void 0?s:new FF(this,t,n,r)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:CF},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,n,r){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(t,n,r)},e})(),to;(function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"})(to||(to={}));var Ws="trace",bF=(function(){function e(){this._proxyTracerProvider=new od,this.wrapSpanContext=vF,this.isSpanContextValid=nd,this.deleteSpan=pF,this.getSpan=qs,this.getActiveSpan=dF,this.getSpanContext=td,this.setSpan=Vs,this.setSpanContext=DF}return a(e,"TraceAPI2"),e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var n=js(Ws,this._proxyTracerProvider,eo.instance());return n&&this._proxyTracerProvider.setDelegate(t),n},e.prototype.getTracerProvider=function(){return ar(Ws)||this._proxyTracerProvider},e.prototype.getTracer=function(t,n){return this.getTracerProvider().getTracer(t,n)},e.prototype.disable=function(){zs(Ws,eo.instance()),this._proxyTracerProvider=new od},e})(),wF=bF.getInstance(),AF=Object.defineProperty,kF=a((e,t)=>{for(var n in t)AF(e,n,{get:t[n],enumerable:!0})},"__export"),sd="AI_NoOutputSpecifiedError",id=`vercel.ai.error.${sd}`,xF=Symbol.for(id),ad,$F=(mn=class extends M{constructor({message:t="No output specified."}={}){super({name:sd,message:t}),this[ad]=!0}static isInstance(t){return M.hasMarker(t,id)}},a(mn,"NoOutputSpecifiedError"),mn);ad=xF;function IF(e){const t="AI SDK Warning:";switch(e.type){case"unsupported-setting":{let n=`${t} The "${e.setting}" setting is not supported by this model`;return e.details&&(n+=` - ${e.details}`),n}case"unsupported-tool":{const n="name"in e.tool?e.tool.name:"unknown tool";let r=`${t} The tool "${n}" is not supported by this model`;return e.details&&(r+=` - ${e.details}`),r}case"other":return`${t} ${e.message}`;default:return`${t} ${JSON.stringify(e,null,2)}`}}a(IF,"formatWarning");var BF="AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",ud=!1,SF=a(e=>{if(e.length===0)return;const t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t=="function"){t(e);return}ud||(ud=!0,console.info(BF));for(const n of e)console.warn(IF(n))}},"logWarnings"),ld="AI_InvalidArgumentError",cd=`vercel.ai.error.${ld}`,TF=Symbol.for(cd),dd,at=(hn=class extends M{constructor({parameter:t,value:n,message:r}){super({name:ld,message:`Invalid argument for parameter ${t}: ${r}`}),this[dd]=!0,this.parameter=t,this.value=n}static isInstance(t){return M.hasMarker(t,cd)}},a(hn,"InvalidArgumentError"),hn);dd=TF;var pd="AI_InvalidToolInputError",Dd=`vercel.ai.error.${pd}`,OF=Symbol.for(Dd),fd,md=(gn=class extends M{constructor({toolInput:t,toolName:n,cause:r,message:s=`Invalid input for tool ${n}: ${Hn(r)}`}){super({name:pd,message:s,cause:r}),this[fd]=!0,this.toolInput=t,this.toolName=n}static isInstance(t){return M.hasMarker(t,Dd)}},a(gn,"InvalidToolInputError"),gn);fd=OF;var hd="AI_NoObjectGeneratedError",gd=`vercel.ai.error.${hd}`,RF=Symbol.for(gd),vd,yd=(vn=class extends M{constructor({message:t="No object generated.",cause:n,text:r,response:s,usage:i,finishReason:o}){super({name:hd,message:t,cause:n}),this[vd]=!0,this.text=r,this.response=s,this.usage=i,this.finishReason=o}static isInstance(t){return M.hasMarker(t,gd)}},a(vn,"NoObjectGeneratedError"),vn);vd=RF;var _d="AI_NoSuchToolError",Fd=`vercel.ai.error.${_d}`,PF=Symbol.for(Fd),Ed,Hs=(yn=class extends M{constructor({toolName:t,availableTools:n=void 0,message:r=`Model tried to call unavailable tool '${t}'. ${n===void 0?"No tools are available.":`Available tools: ${n.join(", ")}.`}`}){super({name:_d,message:r}),this[Ed]=!0,this.toolName=t,this.availableTools=n}static isInstance(t){return M.hasMarker(t,Fd)}},a(yn,"NoSuchToolError"),yn);Ed=PF;var Cd="AI_ToolCallRepairError",bd=`vercel.ai.error.${Cd}`,NF=Symbol.for(bd),wd,MF=(_n=class extends M{constructor({cause:t,originalError:n,message:r=`Error repairing tool call: ${Hn(t)}`}){super({name:Cd,message:r,cause:t}),this[wd]=!0,this.originalError=n}static isInstance(t){return M.hasMarker(t,bd)}},a(_n,"ToolCallRepairError"),_n);wd=NF;var jF=(Fn=class extends M{constructor(t){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${t.version} for provider "${t.provider}" and model "${t.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=t.version,this.provider=t.provider,this.modelId=t.modelId}},a(Fn,"UnsupportedModelVersionError"),Fn),Ad="AI_InvalidMessageRoleError",kd=`vercel.ai.error.${Ad}`,zF=Symbol.for(kd),xd,ZF=(En=class extends M{constructor({role:t,message:n=`Invalid message role: '${t}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:Ad,message:n}),this[xd]=!0,this.role=t}static isInstance(t){return M.hasMarker(t,kd)}},a(En,"InvalidMessageRoleError"),En);xd=zF;var $d="AI_DownloadError",Id=`vercel.ai.error.${$d}`,LF=Symbol.for(Id),Bd,Js=(Cn=class extends M{constructor({url:t,statusCode:n,statusText:r,cause:s,message:i=s==null?`Failed to download ${t}: ${n} ${r}`:`Failed to download ${t}: ${s}`}){super({name:$d,message:i,cause:s}),this[Bd]=!0,this.url=t,this.statusCode=n,this.statusText=r}static isInstance(t){return M.hasMarker(t,Id)}},a(Cn,"DownloadError"),Cn);Bd=LF;var Sd="AI_RetryError",Td=`vercel.ai.error.${Sd}`,UF=Symbol.for(Td),Od,Rd=(bn=class extends M{constructor({message:t,reason:n,errors:r}){super({name:Sd,message:t}),this[Od]=!0,this.reason=n,this.errors=r,this.lastError=r[r.length-1]}static isInstance(t){return M.hasMarker(t,Td)}},a(bn,"RetryError"),bn);Od=UF;function Pd(e){if(typeof e!="string"){if(e.specificationVersion!=="v2")throw new jF({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return e}return qF().languageModel(e)}a(Pd,"resolveLanguageModel");function qF(){var e;return(e=globalThis.AI_SDK_DEFAULT_PROVIDER)!=null?e:L2}a(qF,"getGlobalProvider");var VF=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],GF=a(e=>{const t=typeof e=="string"?Xr(e):e,n=(t[6]&127)<<21|(t[7]&127)<<14|(t[8]&127)<<7|t[9]&127;return t.slice(n+10)},"stripID3");function WF(e){return typeof e=="string"&&e.startsWith("SUQz")||typeof e!="string"&&e.length>10&&e[0]===73&&e[1]===68&&e[2]===51?GF(e):e}a(WF,"stripID3TagsIfPresent");function HF({data:e,signatures:t}){const n=WF(e),r=typeof n=="string"?Xr(n.substring(0,Math.min(n.length,24))):n;for(const s of t)if(r.length>=s.bytesPrefix.length&&s.bytesPrefix.every((i,o)=>i===null||r[o]===i))return s.mediaType}a(HF,"detectMediaType");var Nd="5.0.104",JF=a(async({url:e})=>{var t;const n=e.toString();try{const r=await fetch(n,{headers:$t({},`ai-sdk/${Nd}`,ws())});if(!r.ok)throw new Js({url:n,statusCode:r.status,statusText:r.statusText});return{data:new Uint8Array(await r.arrayBuffer()),mediaType:(t=r.headers.get("content-type"))!=null?t:void 0}}catch(r){throw Js.isInstance(r)?r:new Js({url:n,cause:r})}},"download"),KF=a((e=JF)=>t=>Promise.all(t.map(async n=>n.isUrlSupportedByModel?null:e(n))),"createDefaultDownloadFunction");function YF(e){try{const[t,n]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:n}}catch{return{mediaType:void 0,base64Content:void 0}}}a(YF,"splitDataUrl");var Md=X([m(),Hr(Uint8Array),Hr(ArrayBuffer),Ky(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]);function jd(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if(typeof e=="string")try{e=new URL(e)}catch{}if(e instanceof URL&&e.protocol==="data:"){const{mediaType:t,base64Content:n}=YF(e.toString());if(t==null||n==null)throw new M({name:"InvalidDataContentError",message:`Invalid data URL format in content ${e.toString()}`});return{data:n,mediaType:t}}return{data:e,mediaType:void 0}}a(jd,"convertToLanguageModelV2DataContent");function XF(e){return typeof e=="string"?e:e instanceof ArrayBuffer?Qr(new Uint8Array(e)):Qr(e)}a(XF,"convertDataContentToBase64String");async function QF({prompt:e,supportedUrls:t,download:n=KF()}){const r=await tE(e.messages,n,t);return[...e.system!=null?[{role:"system",content:e.system}]:[],...e.messages.map(s=>eE({message:s,downloadedAssets:r}))]}a(QF,"convertToLanguageModelPrompt");function eE({message:e,downloadedAssets:t}){const n=e.role;switch(n){case"system":return{role:"system",content:e.content,providerOptions:e.providerOptions};case"user":return typeof e.content=="string"?{role:"user",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"user",content:e.content.map(r=>nE(r,t)).filter(r=>r.type!=="text"||r.text!==""),providerOptions:e.providerOptions};case"assistant":return typeof e.content=="string"?{role:"assistant",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"assistant",content:e.content.filter(r=>r.type!=="text"||r.text!==""||r.providerOptions!=null).map(r=>{const s=r.providerOptions;switch(r.type){case"file":{const{data:i,mediaType:o}=jd(r.data);return{type:"file",data:i,filename:r.filename,mediaType:o??r.mediaType,providerOptions:s}}case"reasoning":return{type:"reasoning",text:r.text,providerOptions:s};case"text":return{type:"text",text:r.text,providerOptions:s};case"tool-call":return{type:"tool-call",toolCallId:r.toolCallId,toolName:r.toolName,input:r.input,providerExecuted:r.providerExecuted,providerOptions:s};case"tool-result":return{type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:r.output,providerOptions:s}}}),providerOptions:e.providerOptions};case"tool":return{role:"tool",content:e.content.map(r=>({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:r.output,providerOptions:r.providerOptions})),providerOptions:e.providerOptions};default:{const r=n;throw new ZF({role:r})}}}a(eE,"convertToLanguageModelMessage");async function tE(e,t,n){const r=e.filter(i=>i.role==="user").map(i=>i.content).filter(i=>Array.isArray(i)).flat().filter(i=>i.type==="image"||i.type==="file").map(i=>{var o;const u=(o=i.mediaType)!=null?o:i.type==="image"?"image/*":void 0;let l=i.type==="image"?i.image:i.data;if(typeof l=="string")try{l=new URL(l)}catch{}return{mediaType:u,data:l}}).filter(i=>i.data instanceof URL).map(i=>({url:i.data,isUrlSupportedByModel:i.mediaType!=null&&o_({url:i.data.toString(),mediaType:i.mediaType,supportedUrls:n})})),s=await t(r);return Object.fromEntries(s.map((i,o)=>i==null?null:[r[o].url.toString(),{data:i.data,mediaType:i.mediaType}]).filter(i=>i!=null))}a(tE,"downloadAssets");function nE(e,t){var n;if(e.type==="text")return{type:"text",text:e.text,providerOptions:e.providerOptions};let r;const s=e.type;switch(s){case"image":r=e.image;break;case"file":r=e.data;break;default:throw new Error(`Unsupported part type: ${s}`)}const{data:i,mediaType:o}=jd(r);let u=o??e.mediaType,l=i;if(l instanceof URL){const c=t[l.toString()];c&&(l=c.data,u??(u=c.mediaType))}switch(s){case"image":return(l instanceof Uint8Array||typeof l=="string")&&(u=(n=HF({data:l,signatures:VF}))!=null?n:u),{type:"file",mediaType:u??"image/*",filename:void 0,data:l,providerOptions:e.providerOptions};case"file":{if(u==null)throw new Error("Media type is missing for file part");return{type:"file",mediaType:u,filename:e.filename,data:l,providerOptions:e.providerOptions}}}}a(nE,"convertPartToLanguageModelPart");function zd({maxOutputTokens:e,temperature:t,topP:n,topK:r,presencePenalty:s,frequencyPenalty:i,seed:o,stopSequences:u}){if(e!=null){if(!Number.isInteger(e))throw new at({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be an integer"});if(e<1)throw new at({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be >= 1"})}if(t!=null&&typeof t!="number")throw new at({parameter:"temperature",value:t,message:"temperature must be a number"});if(n!=null&&typeof n!="number")throw new at({parameter:"topP",value:n,message:"topP must be a number"});if(r!=null&&typeof r!="number")throw new at({parameter:"topK",value:r,message:"topK must be a number"});if(s!=null&&typeof s!="number")throw new at({parameter:"presencePenalty",value:s,message:"presencePenalty must be a number"});if(i!=null&&typeof i!="number")throw new at({parameter:"frequencyPenalty",value:i,message:"frequencyPenalty must be a number"});if(o!=null&&!Number.isInteger(o))throw new at({parameter:"seed",value:o,message:"seed must be an integer"});return{maxOutputTokens:e,temperature:t,topP:n,topK:r,presencePenalty:s,frequencyPenalty:i,stopSequences:u,seed:o}}a(zd,"prepareCallSettings");function rE(e){return e!=null&&Object.keys(e).length>0}a(rE,"isNonEmptyObject");function oE({tools:e,toolChoice:t,activeTools:n}){return rE(e)?{tools:(n!=null?Object.entries(e).filter(([s])=>n.includes(s)):Object.entries(e)).map(([s,i])=>{const o=i.type;switch(o){case void 0:case"dynamic":case"function":return{type:"function",name:s,description:i.description,inputSchema:Yr(i.inputSchema).jsonSchema,providerOptions:i.providerOptions};case"provider-defined":return{type:"provider-defined",name:s,id:i.id,args:i.args};default:{const u=o;throw new Error(`Unsupported tool type: ${u}`)}}}),toolChoice:t==null?{type:"auto"}:typeof t=="string"?{type:t}:{type:"tool",toolName:t.toolName}}:{tools:void 0,toolChoice:void 0}}a(oE,"prepareToolsAndToolChoice");var cr=Ql(()=>X([Cy(),m(),w(),Ae(),ge(m(),cr),$(cr)])),rt=ge(m(),ge(m(),cr)),Zd=y({type:k("text"),text:m(),providerOptions:rt.optional()}),sE=y({type:k("image"),image:X([Md,Hr(URL)]),mediaType:m().optional(),providerOptions:rt.optional()}),Ld=y({type:k("file"),data:X([Md,Hr(URL)]),filename:m().optional(),mediaType:m(),providerOptions:rt.optional()}),iE=y({type:k("reasoning"),text:m(),providerOptions:rt.optional()}),aE=y({type:k("tool-call"),toolCallId:m(),toolName:m(),input:st(),providerOptions:rt.optional(),providerExecuted:Ae().optional()}),uE=ke("type",[y({type:k("text"),value:m()}),y({type:k("json"),value:cr}),y({type:k("error-text"),value:m()}),y({type:k("error-json"),value:cr}),y({type:k("content"),value:$(X([y({type:k("text"),text:m()}),y({type:k("media"),data:m(),mediaType:m()})]))})]),Ud=y({type:k("tool-result"),toolCallId:m(),toolName:m(),output:uE,providerOptions:rt.optional()}),lE=y({role:k("system"),content:m(),providerOptions:rt.optional()}),cE=y({role:k("user"),content:X([m(),$(X([Zd,sE,Ld]))]),providerOptions:rt.optional()}),dE=y({role:k("assistant"),content:X([m(),$(X([Zd,Ld,iE,aE,Ud]))]),providerOptions:rt.optional()}),pE=y({role:k("tool"),content:$(Ud),providerOptions:rt.optional()}),DE=X([lE,cE,dE,pE]);async function fE(e){if(e.prompt==null&&e.messages==null)throw new dt({prompt:e,message:"prompt or messages must be defined"});if(e.prompt!=null&&e.messages!=null)throw new dt({prompt:e,message:"prompt and messages cannot be defined at the same time"});if(e.system!=null&&typeof e.system!="string")throw new dt({prompt:e,message:"system must be a string"});let t;if(e.prompt!=null&&typeof e.prompt=="string")t=[{role:"user",content:e.prompt}];else if(e.prompt!=null&&Array.isArray(e.prompt))t=e.prompt;else if(e.messages!=null)t=e.messages;else throw new dt({prompt:e,message:"prompt or messages must be defined"});if(t.length===0)throw new dt({prompt:e,message:"messages must not be empty"});const n=await it({value:t,schema:$(DE)});if(!n.success)throw new dt({prompt:e,message:"The messages must be a ModelMessage[]. If you have passed a UIMessage[], you can use convertToModelMessages to convert them.",cause:n.error});return{messages:t,system:e.system}}a(fE,"standardizePrompt");function mE(e){return Ms.isInstance(e)||Mc.isInstance(e)?new M({name:"GatewayError",message:"Vercel AI Gateway access failed. If you want to use AI SDK providers directly, use the providers, e.g. @ai-sdk/openai, or register a different global default provider.",cause:e}):e}a(mE,"wrapGatewayError");function Ks({operationId:e,telemetry:t}){return{"operation.name":`${e}${t?.functionId!=null?` ${t.functionId}`:""}`,"resource.name":t?.functionId,"ai.operationId":e,"ai.telemetry.functionId":t?.functionId}}a(Ks,"assembleOperationName");function hE({model:e,settings:t,telemetry:n,headers:r}){var s;return{"ai.model.provider":e.provider,"ai.model.id":e.modelId,...Object.entries(t).reduce((i,[o,u])=>(i[`ai.settings.${o}`]=u,i),{}),...Object.entries((s=n?.metadata)!=null?s:{}).reduce((i,[o,u])=>(i[`ai.telemetry.metadata.${o}`]=u,i),{}),...Object.entries(r??{}).reduce((i,[o,u])=>(u!==void 0&&(i[`ai.request.headers.${o}`]=u),i),{})}}a(hE,"getBaseTelemetryAttributes");var gE={startSpan(){return no},startActiveSpan(e,t,n,r){if(typeof t=="function")return t(no);if(typeof n=="function")return n(no);if(typeof r=="function")return r(no)}},no={spanContext(){return vE},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this}},vE={traceId:"",spanId:"",traceFlags:0};function yE({isEnabled:e=!1,tracer:t}={}){return e?t||wF.getTracer("ai"):gE}a(yE,"getTracer");function Ys({name:e,tracer:t,attributes:n,fn:r,endWhenDone:s=!0}){return t.startActiveSpan(e,{attributes:n},async i=>{try{const o=await r(i);return s&&i.end(),o}catch(o){try{qd(i,o)}finally{i.end()}throw o}})}a(Ys,"recordSpan");function qd(e,t){t instanceof Error?(e.recordException({name:t.name,message:t.message,stack:t.stack}),e.setStatus({code:to.ERROR,message:t.message})):e.setStatus({code:to.ERROR})}a(qd,"recordErrorOnSpan");function Ht({telemetry:e,attributes:t}){return e?.isEnabled!==!0?{}:Object.entries(t).reduce((n,[r,s])=>{if(s==null)return n;if(typeof s=="object"&&"input"in s&&typeof s.input=="function"){if(e?.recordInputs===!1)return n;const i=s.input();return i==null?n:{...n,[r]:i}}if(typeof s=="object"&&"output"in s&&typeof s.output=="function"){if(e?.recordOutputs===!1)return n;const i=s.output();return i==null?n:{...n,[r]:i}}return{...n,[r]:s}},{})}a(Ht,"selectTelemetryAttributes");function _E(e){return JSON.stringify(e.map(t=>({...t,content:typeof t.content=="string"?t.content:t.content.map(n=>n.type==="file"?{...n,data:n.data instanceof Uint8Array?XF(n.data):n.data}:n)})))}a(_E,"stringifyForTelemetry");function FE(e,t){return{inputTokens:dr(e.inputTokens,t.inputTokens),outputTokens:dr(e.outputTokens,t.outputTokens),totalTokens:dr(e.totalTokens,t.totalTokens),reasoningTokens:dr(e.reasoningTokens,t.reasoningTokens),cachedInputTokens:dr(e.cachedInputTokens,t.cachedInputTokens)}}a(FE,"addLanguageModelUsage");function dr(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}a(dr,"addTokenCounts");function EE(e){return e===void 0?[]:Array.isArray(e)?e:[e]}a(EE,"asArray");function CE({error:e,exponentialBackoffDelay:t}){const n=e.responseHeaders;if(!n)return t;let r;const s=n["retry-after-ms"];if(s){const o=parseFloat(s);Number.isNaN(o)||(r=o)}const i=n["retry-after"];if(i&&r===void 0){const o=parseFloat(i);Number.isNaN(o)?r=Date.parse(i)-Date.now():r=o*1e3}return r!=null&&!Number.isNaN(r)&&0<=r&&(r<60*1e3||r<t)?r:t}a(CE,"getRetryDelayInMs");var bE=a(({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:n=2,abortSignal:r}={})=>async s=>Vd(s,{maxRetries:e,delayInMs:t,backoffFactor:n,abortSignal:r}),"retryWithExponentialBackoffRespectingRetryHeaders");async function Vd(e,{maxRetries:t,delayInMs:n,backoffFactor:r,abortSignal:s},i=[]){try{return await e()}catch(o){if(qt(o)||t===0)throw o;const u=tc(o),l=[...i,o],c=l.length;if(c>t)throw new Rd({message:`Failed after ${c} attempts. Last error: ${u}`,reason:"maxRetriesExceeded",errors:l});if(o instanceof Error&&be.isInstance(o)&&o.isRetryable===!0&&c<=t)return await e_(CE({error:o,exponentialBackoffDelay:n}),{abortSignal:s}),Vd(e,{maxRetries:t,delayInMs:r*n,backoffFactor:r,abortSignal:s},l);throw c===1?o:new Rd({message:`Failed after ${c} attempts with non-retryable error: '${u}'`,reason:"errorNotRetryable",errors:l})}}a(Vd,"_retryWithExponentialBackoff");function wE({maxRetries:e,abortSignal:t}){if(!Number.isInteger(e))throw new at({parameter:"maxRetries",value:e,message:"maxRetries must be an integer"});const n=e;return{maxRetries:n,retry:bE({maxRetries:n,abortSignal:t})}}a(wE,"prepareRetries");function Gd(e){const t=e.filter(n=>n.type==="text");if(t.length!==0)return t.map(n=>n.text).join("")}a(Gd,"extractTextContent");var AE=(wn=class{constructor({data:t,mediaType:n}){const r=t instanceof Uint8Array;this.base64Data=r?void 0:t,this.uint8ArrayData=r?t:void 0,this.mediaType=n}get base64(){return this.base64Data==null&&(this.base64Data=Qr(this.uint8ArrayData)),this.base64Data}get uint8Array(){return this.uint8ArrayData==null&&(this.uint8ArrayData=Xr(this.base64Data)),this.uint8ArrayData}},a(wn,"DefaultGeneratedFile"),wn);async function kE({toolCall:e,tools:t,repairToolCall:n,system:r,messages:s}){try{if(t==null)throw new Hs({toolName:e.toolName});try{return await Wd({toolCall:e,tools:t})}catch(i){if(n==null||!(Hs.isInstance(i)||md.isInstance(i)))throw i;let o=null;try{o=await n({toolCall:e,tools:t,inputSchema:a(({toolName:u})=>{const{inputSchema:l}=t[u];return Yr(l).jsonSchema},"inputSchema"),system:r,messages:s,error:i})}catch(u){throw new MF({cause:u,originalError:i})}if(o==null)throw i;return await Wd({toolCall:o,tools:t})}}catch(i){const o=await It({text:e.input}),u=o.success?o.value:e.input;return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:u,dynamic:!0,invalid:!0,error:i}}}a(kE,"parseToolCall");async function Wd({toolCall:e,tools:t}){const n=e.toolName,r=t[n];if(r==null)throw new Hs({toolName:e.toolName,availableTools:Object.keys(t)});const s=Yr(r.inputSchema),i=e.input.trim()===""?await it({value:{},schema:s}):await It({text:e.input,schema:s});if(i.success===!1)throw new md({toolName:n,toolInput:e.input,cause:i.error});return r.type==="dynamic"?{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,dynamic:!0}:{type:"tool-call",toolCallId:e.toolCallId,toolName:n,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}}a(Wd,"doParseToolCall");var xE=(An=class{constructor({content:t,finishReason:n,usage:r,warnings:s,request:i,response:o,providerMetadata:u}){this.content=t,this.finishReason=n,this.usage=r,this.warnings=s,this.request=i,this.response=o,this.providerMetadata=u}get text(){return this.content.filter(t=>t.type==="text").map(t=>t.text).join("")}get reasoning(){return this.content.filter(t=>t.type==="reasoning")}get reasoningText(){return this.reasoning.length===0?void 0:this.reasoning.map(t=>t.text).join("")}get files(){return this.content.filter(t=>t.type==="file").map(t=>t.file)}get sources(){return this.content.filter(t=>t.type==="source")}get toolCalls(){return this.content.filter(t=>t.type==="tool-call")}get staticToolCalls(){return this.toolCalls.filter(t=>t.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(t=>t.dynamic===!0)}get toolResults(){return this.content.filter(t=>t.type==="tool-result")}get staticToolResults(){return this.toolResults.filter(t=>t.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(t=>t.dynamic===!0)}},a(An,"DefaultStepResult"),An);function $E(e){return({steps:t})=>t.length===e}a($E,"stepCountIs");async function IE({stopConditions:e,steps:t}){return(await Promise.all(e.map(n=>n({steps:t})))).some(n=>n)}a(IE,"isStopConditionMet");function Xs({output:e,tool:t,errorMode:n}){return n==="text"?{type:"error-text",value:Hn(e)}:n==="json"?{type:"error-json",value:Hd(e)}:t?.toModelOutput?t.toModelOutput(e):typeof e=="string"?{type:"text",value:e}:{type:"json",value:Hd(e)}}a(Xs,"createToolModelOutput");function Hd(e){return e===void 0?null:e}a(Hd,"toJSONValue");function BE({content:e,tools:t}){const n=[],r=e.filter(i=>i.type!=="source").filter(i=>(i.type!=="tool-result"||i.providerExecuted)&&(i.type!=="tool-error"||i.providerExecuted)).filter(i=>i.type!=="text"||i.text.length>0).map(i=>{switch(i.type){case"text":return{type:"text",text:i.text,providerOptions:i.providerMetadata};case"reasoning":return{type:"reasoning",text:i.text,providerOptions:i.providerMetadata};case"file":return{type:"file",data:i.file.base64,mediaType:i.file.mediaType,providerOptions:i.providerMetadata};case"tool-call":return{type:"tool-call",toolCallId:i.toolCallId,toolName:i.toolName,input:i.input,providerExecuted:i.providerExecuted,providerOptions:i.providerMetadata};case"tool-result":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Xs({tool:t?.[i.toolName],output:i.output,errorMode:"none"}),providerExecuted:!0,providerOptions:i.providerMetadata};case"tool-error":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Xs({tool:t?.[i.toolName],output:i.error,errorMode:"json"}),providerOptions:i.providerMetadata}}});r.length>0&&n.push({role:"assistant",content:r});const s=e.filter(i=>i.type==="tool-result"||i.type==="tool-error").filter(i=>!i.providerExecuted).map(i=>({type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Xs({tool:t?.[i.toolName],output:i.type==="tool-result"?i.output:i.error,errorMode:i.type==="tool-error"?"text":"none"}),...i.providerMetadata!=null?{providerOptions:i.providerMetadata}:{}}));return s.length>0&&n.push({role:"tool",content:s}),n}a(BE,"toResponseMessages");var SE=rr({prefix:"aitxt",size:24});async function Qs({model:e,tools:t,toolChoice:n,system:r,prompt:s,messages:i,maxRetries:o,abortSignal:u,headers:l,stopWhen:c=$E(1),experimental_output:d,experimental_telemetry:p,providerOptions:h,experimental_activeTools:f,activeTools:D=f,experimental_prepareStep:g,prepareStep:v=g,experimental_repairToolCall:F,experimental_download:C,experimental_context:_,_internal:{generateId:b=SE,currentDate:B=a(()=>new Date,"currentDate")}={},onStepFinish:O,...S}){const x=Pd(e),L=EE(c),{maxRetries:P,retry:J}=wE({maxRetries:o,abortSignal:u}),U=zd(S),ce=$t(l??{},`ai/${Nd}`),W=hE({model:x,telemetry:p,headers:ce,settings:{...U,maxRetries:P}}),te=await fE({system:r,prompt:s,messages:i}),ne=yE(p);try{return await Ys({name:"ai.generateText",attributes:Ht({telemetry:p,attributes:{...Ks({operationId:"ai.generateText",telemetry:p}),...W,"ai.model.provider":x.provider,"ai.model.id":x.modelId,"ai.prompt":{input:a(()=>JSON.stringify({system:r,prompt:s,messages:i}),"input")}}}),tracer:ne,fn:a(async R=>{var q,j,xe,de,re,V,Be;const qe=zd(S);let E,G=[],pe=[];const ye=[],Ke=[];do{const ut=[...te.messages,...ye],Ye=await v?.({model:x,steps:Ke,stepNumber:Ke.length,messages:ut}),gt=Pd((q=Ye?.model)!=null?q:x),vi=await QF({prompt:{system:(j=Ye?.system)!=null?j:te.system,messages:(xe=Ye?.messages)!=null?xe:ut},supportedUrls:await gt.supportedUrls,download:C}),{toolChoice:ao,tools:uo}=oE({tools:t,toolChoice:(de=Ye?.toolChoice)!=null?de:n,activeTools:(re=Ye?.activeTools)!=null?re:D});E=await J(()=>{var De;return Ys({name:"ai.generateText.doGenerate",attributes:Ht({telemetry:p,attributes:{...Ks({operationId:"ai.generateText.doGenerate",telemetry:p}),...W,"ai.model.provider":gt.provider,"ai.model.id":gt.modelId,"ai.prompt.messages":{input:a(()=>_E(vi),"input")},"ai.prompt.tools":{input:a(()=>uo?.map(vt=>JSON.stringify(vt)),"input")},"ai.prompt.toolChoice":{input:a(()=>ao!=null?JSON.stringify(ao):void 0,"input")},"gen_ai.system":gt.provider,"gen_ai.request.model":gt.modelId,"gen_ai.request.frequency_penalty":S.frequencyPenalty,"gen_ai.request.max_tokens":S.maxOutputTokens,"gen_ai.request.presence_penalty":S.presencePenalty,"gen_ai.request.stop_sequences":S.stopSequences,"gen_ai.request.temperature":(De=S.temperature)!=null?De:void 0,"gen_ai.request.top_k":S.topK,"gen_ai.request.top_p":S.topP}}),tracer:ne,fn:a(async vt=>{var Fi,Ei,Ci,bi,wi,Ai,ki,xi;const Se=await gt.doGenerate({...qe,tools:uo,toolChoice:ao,responseFormat:d?.responseFormat,prompt:vi,providerOptions:h,abortSignal:u,headers:ce}),Pt={id:(Ei=(Fi=Se.response)==null?void 0:Fi.id)!=null?Ei:b(),timestamp:(bi=(Ci=Se.response)==null?void 0:Ci.timestamp)!=null?bi:B(),modelId:(Ai=(wi=Se.response)==null?void 0:wi.modelId)!=null?Ai:gt.modelId,headers:(ki=Se.response)==null?void 0:ki.headers,body:(xi=Se.response)==null?void 0:xi.body};return vt.setAttributes(Ht({telemetry:p,attributes:{"ai.response.finishReason":Se.finishReason,"ai.response.text":{output:a(()=>Gd(Se.content),"output")},"ai.response.toolCalls":{output:a(()=>{const $i=Jd(Se.content);return $i==null?void 0:JSON.stringify($i)},"output")},"ai.response.id":Pt.id,"ai.response.model":Pt.modelId,"ai.response.timestamp":Pt.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(Se.providerMetadata),"ai.usage.promptTokens":Se.usage.inputTokens,"ai.usage.completionTokens":Se.usage.outputTokens,"gen_ai.response.finish_reasons":[Se.finishReason],"gen_ai.response.id":Pt.id,"gen_ai.response.model":Pt.modelId,"gen_ai.usage.input_tokens":Se.usage.inputTokens,"gen_ai.usage.output_tokens":Se.usage.outputTokens}})),{...Se,response:Pt}},"fn")})});const Dr=await Promise.all(E.content.filter(De=>De.type==="tool-call").map(De=>kE({toolCall:De,tools:t,repairToolCall:F,system:r,messages:ut})));for(const De of Dr){if(De.invalid)continue;const vt=t[De.toolName];vt?.onInputAvailable!=null&&await vt.onInputAvailable({input:De.input,toolCallId:De.toolCallId,messages:ut,abortSignal:u,experimental_context:_})}const wp=Dr.filter(De=>De.invalid&&De.dynamic);pe=[];for(const De of wp)pe.push({type:"tool-error",toolCallId:De.toolCallId,toolName:De.toolName,input:De.input,error:tc(De.error),dynamic:!0});G=Dr.filter(De=>!De.providerExecuted),t!=null&&pe.push(...await TE({toolCalls:G.filter(De=>!De.invalid),tools:t,tracer:ne,telemetry:p,messages:ut,abortSignal:u,experimental_context:_}));const yi=RE({content:E.content,toolCalls:Dr,toolOutputs:pe});ye.push(...BE({content:yi,tools:t}));const _i=new xE({content:yi,finishReason:E.finishReason,usage:E.usage,warnings:E.warnings,providerMetadata:E.providerMetadata,request:(V=E.request)!=null?V:{},response:{...E.response,messages:structuredClone(ye)}});SF((Be=E.warnings)!=null?Be:[]),Ke.push(_i),await O?.(_i)}while(G.length>0&&pe.length===G.length&&!await IE({stopConditions:L,steps:Ke}));R.setAttributes(Ht({telemetry:p,attributes:{"ai.response.finishReason":E.finishReason,"ai.response.text":{output:a(()=>Gd(E.content),"output")},"ai.response.toolCalls":{output:a(()=>{const ut=Jd(E.content);return ut==null?void 0:JSON.stringify(ut)},"output")},"ai.response.providerMetadata":JSON.stringify(E.providerMetadata),"ai.usage.promptTokens":E.usage.inputTokens,"ai.usage.completionTokens":E.usage.outputTokens}}));const jn=Ke[Ke.length-1];let gi;return jn.finishReason==="stop"&&(gi=await d?.parseOutput({text:jn.text},{response:jn.response,usage:jn.usage,finishReason:jn.finishReason})),new OE({steps:Ke,resolvedOutput:gi})},"fn")})}catch(R){throw mE(R)}}a(Qs,"generateText");async function TE({toolCalls:e,tools:t,tracer:n,telemetry:r,messages:s,abortSignal:i,experimental_context:o}){return(await Promise.all(e.map(async({toolCallId:l,toolName:c,input:d})=>{const p=t[c];if(p?.execute!=null)return Ys({name:"ai.toolCall",attributes:Ht({telemetry:r,attributes:{...Ks({operationId:"ai.toolCall",telemetry:r}),"ai.toolCall.name":c,"ai.toolCall.id":l,"ai.toolCall.args":{output:a(()=>JSON.stringify(d),"output")}}}),tracer:n,fn:a(async h=>{try{const f=D2({execute:p.execute.bind(p),input:d,options:{toolCallId:l,messages:s,abortSignal:i,experimental_context:o}});let D;for await(const g of f)g.type==="final"&&(D=g.output);try{h.setAttributes(Ht({telemetry:r,attributes:{"ai.toolCall.result":{output:a(()=>JSON.stringify(D),"output")}}}))}catch{}return{type:"tool-result",toolCallId:l,toolName:c,input:d,output:D,dynamic:p.type==="dynamic"}}catch(f){return qd(h,f),{type:"tool-error",toolCallId:l,toolName:c,input:d,error:f,dynamic:p.type==="dynamic"}}},"fn")})}))).filter(l=>l!=null)}a(TE,"executeTools");var OE=(kn=class{constructor(t){this.steps=t.steps,this.resolvedOutput=t.resolvedOutput}get finalStep(){return this.steps[this.steps.length-1]}get content(){return this.finalStep.content}get text(){return this.finalStep.text}get files(){return this.finalStep.files}get reasoningText(){return this.finalStep.reasoningText}get reasoning(){return this.finalStep.reasoning}get toolCalls(){return this.finalStep.toolCalls}get staticToolCalls(){return this.finalStep.staticToolCalls}get dynamicToolCalls(){return this.finalStep.dynamicToolCalls}get toolResults(){return this.finalStep.toolResults}get staticToolResults(){return this.finalStep.staticToolResults}get dynamicToolResults(){return this.finalStep.dynamicToolResults}get sources(){return this.finalStep.sources}get finishReason(){return this.finalStep.finishReason}get warnings(){return this.finalStep.warnings}get providerMetadata(){return this.finalStep.providerMetadata}get response(){return this.finalStep.response}get request(){return this.finalStep.request}get usage(){return this.finalStep.usage}get totalUsage(){return this.steps.reduce((t,n)=>FE(t,n.usage),{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0})}get experimental_output(){if(this.resolvedOutput==null)throw new $F;return this.resolvedOutput}},a(kn,"DefaultGenerateTextResult"),kn);function Jd(e){const t=e.filter(n=>n.type==="tool-call");if(t.length!==0)return t.map(n=>({toolCallId:n.toolCallId,toolName:n.toolName,input:n.input}))}a(Jd,"asToolCalls");function RE({content:e,toolCalls:t,toolOutputs:n}){return[...e.map(r=>{switch(r.type){case"text":case"reasoning":case"source":return r;case"file":return{type:"file",file:new AE(r)};case"tool-call":return t.find(s=>s.toolCallId===r.toolCallId);case"tool-result":{const s=t.find(i=>i.toolCallId===r.toolCallId);if(s==null)throw new Error(`Tool call ${r.toolCallId} not found.`);return r.isError?{type:"tool-error",toolCallId:r.toolCallId,toolName:r.toolName,input:s.input,error:r.result,providerExecuted:!0,dynamic:s.dynamic}:{type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,input:s.input,output:r.result,providerExecuted:!0,dynamic:s.dynamic}}}}),...n]}a(RE,"asContent"),class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
138
138
|
|
|
139
139
|
`)},flush(e){e.enqueue(`data: [DONE]
|
|
140
140
|
|
|
141
|
-
`)}})}};function RE(e){const t=["ROOT"];let n=-1,r=null;function s(l,c,d){switch(l){case'"':{n=c,t.pop(),t.push(d),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=c,r=c,t.pop(),t.push(d),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=c,t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"{":{n=c,t.pop(),t.push(d),t.push("INSIDE_OBJECT_START");break}case"[":{n=c,t.pop(),t.push(d),t.push("INSIDE_ARRAY_START");break}}}a(s,"processValueStart");function i(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=c,t.pop();break}}}a(i,"processAfterObjectValue");function o(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}}}a(o,"processAfterArrayValue");for(let l=0;l<e.length;l++){const c=e[l];switch(t[t.length-1]){case"ROOT":s(c,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(c){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{s(c,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(c,l);break}case"INSIDE_STRING":{switch(c){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(c){case"]":{n=l,t.pop();break}default:{n=l,s(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{s(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(c){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(c,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(c,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(c,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(c,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const p=e.substring(r,l+1);!"false".startsWith(p)&&!"true".startsWith(p)&&!"null".startsWith(p)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(c,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(c,l)):n=l;break}}}let u=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{u+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{u+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{u+="]";break}case"INSIDE_LITERAL":{const d=e.substring(r,e.length);"true".startsWith(d)?u+="true".slice(d.length):"false".startsWith(d)?u+="false".slice(d.length):"null".startsWith(d)&&(u+="null".slice(d.length))}}return u}a(RE,"fixJson");async function PE(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await At({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await At({text:RE(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}a(PE,"parsePartialJson"),tr({prefix:"aitxt",size:24}),tr({prefix:"aiobj",size:24}),tr({prefix:"aiobj",size:24});var NE={};wF(NE,{object:a(()=>jE,"object"),text:a(()=>ME,"text")});var ME=a(()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),"text"),jE=a(({schema:e})=>{const t=Wr(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:n}){const r=await PE(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:r.value};default:{const s=r.state;throw new Error(`Unsupported parse state: ${s}`)}}},async parseOutput({text:n},r){const s=await At({text:n});if(!s.success)throw new gd({message:"No object generated: could not parse the response.",cause:s.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});const i=await ot({value:s.value,schema:t});if(!i.success)throw new gd({message:"No object generated: response did not match schema.",cause:i.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value}}},"object"),Xs=y({error:y({message:m(),type:m().nullish(),param:Me().nullish(),code:Y([m(),w()]).nullish()})}),nt=Ge({errorSchema:Xs,errorToMessage:a(e=>e.error.message,"errorToMessage")});function zE({prompt:e,systemMessageMode:t="system"}){const n=[],r=[];for(const{role:s,content:i}of e)switch(s){case"system":{switch(t){case"system":{n.push({role:"system",content:i});break}case"developer":{n.push({role:"developer",content:i});break}case"remove":{r.push({type:"other",message:"system messages are removed for this model"});break}default:{const o=t;throw new Error(`Unsupported system message mode: ${o}`)}}break}case"user":{if(i.length===1&&i[0].type==="text"){n.push({role:"user",content:i[0].text});break}n.push({role:"user",content:i.map((o,u)=>{var l,c,d;switch(o.type){case"text":return{type:"text",text:o.text};case"file":if(o.mediaType.startsWith("image/")){const p=o.mediaType==="image/*"?"image/jpeg":o.mediaType;return{type:"image_url",image_url:{url:o.data instanceof URL?o.data.toString():`data:${p};base64,${kt(o.data)}`,detail:(c=(l=o.providerOptions)==null?void 0:l.openai)==null?void 0:c.imageDetail}}}else if(o.mediaType.startsWith("audio/")){if(o.data instanceof URL)throw new Ne({functionality:"audio file parts with URLs"});switch(o.mediaType){case"audio/wav":return{type:"input_audio",input_audio:{data:kt(o.data),format:"wav"}};case"audio/mp3":case"audio/mpeg":return{type:"input_audio",input_audio:{data:kt(o.data),format:"mp3"}};default:throw new Ne({functionality:`audio content parts with media type ${o.mediaType}`})}}else if(o.mediaType==="application/pdf"){if(o.data instanceof URL)throw new Ne({functionality:"PDF file parts with URLs"});return{type:"file",file:typeof o.data=="string"&&o.data.startsWith("file-")?{file_id:o.data}:{filename:(d=o.filename)!=null?d:`part-${u}.pdf`,file_data:`data:application/pdf;base64,${kt(o.data)}`}}}else throw new Ne({functionality:`file part media type ${o.mediaType}`})}})});break}case"assistant":{let o="";const u=[];for(const l of i)switch(l.type){case"text":{o+=l.text;break}case"tool-call":{u.push({id:l.toolCallId,type:"function",function:{name:l.toolName,arguments:JSON.stringify(l.input)}});break}}n.push({role:"assistant",content:o,tool_calls:u.length>0?u:void 0});break}case"tool":{for(const o of i){const u=o.output;let l;switch(u.type){case"text":case"error-text":l=u.value;break;case"content":case"json":case"error-json":l=JSON.stringify(u.value);break}n.push({role:"tool",tool_call_id:o.toolCallId,content:l})}break}default:{const o=s;throw new Error(`Unsupported role: ${o}`)}}return{messages:n,warnings:r}}a(zE,"convertToOpenAIChatMessages");function Qs({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n?new Date(n*1e3):void 0}}a(Qs,"getResponseMetadata$1");function Hd(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}a(Hd,"mapOpenAIFinishReason");var ZE=ge(()=>Z(y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:x(y({message:y({role:k("assistant").nullish(),content:m().nullish(),tool_calls:x(y({id:m().nullish(),type:k("function"),function:y({name:m(),arguments:m()})})).nullish(),annotations:x(y({type:k("url_citation"),start_index:w(),end_index:w(),url:m(),title:m()})).nullish()}),index:w(),logprobs:y({content:x(y({token:m(),logprob:w(),top_logprobs:x(y({token:m(),logprob:w()}))})).nullish()}).nullish(),finish_reason:m().nullish()})),usage:y({prompt_tokens:w().nullish(),completion_tokens:w().nullish(),total_tokens:w().nullish(),prompt_tokens_details:y({cached_tokens:w().nullish()}).nullish(),completion_tokens_details:y({reasoning_tokens:w().nullish(),accepted_prediction_tokens:w().nullish(),rejected_prediction_tokens:w().nullish()}).nullish()}).nullish()}))),LE=ge(()=>Z(Y([y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:x(y({delta:y({role:se(["assistant"]).nullish(),content:m().nullish(),tool_calls:x(y({index:w(),id:m().nullish(),type:k("function").nullish(),function:y({name:m().nullish(),arguments:m().nullish()})})).nullish(),annotations:x(y({type:k("url_citation"),start_index:w(),end_index:w(),url:m(),title:m()})).nullish()}).nullish(),logprobs:y({content:x(y({token:m(),logprob:w(),top_logprobs:x(y({token:m(),logprob:w()}))})).nullish()}).nullish(),finish_reason:m().nullish(),index:w()})),usage:y({prompt_tokens:w().nullish(),completion_tokens:w().nullish(),total_tokens:w().nullish(),prompt_tokens_details:y({cached_tokens:w().nullish()}).nullish(),completion_tokens_details:y({reasoning_tokens:w().nullish(),accepted_prediction_tokens:w().nullish(),rejected_prediction_tokens:w().nullish()}).nullish()}).nullish()}),Xs]))),UE=ge(()=>Z(y({logitBias:he(Yy(),w()).optional(),logprobs:Y([Ae(),w()]).optional(),parallelToolCalls:Ae().optional(),user:m().optional(),reasoningEffort:se(["none","minimal","low","medium","high"]).optional(),maxCompletionTokens:w().optional(),store:Ae().optional(),metadata:he(m().max(64),m().max(512)).optional(),prediction:he(m(),Me()).optional(),structuredOutputs:Ae().optional(),serviceTier:se(["auto","flex","priority","default"]).optional(),strictJsonSchema:Ae().optional(),textVerbosity:se(["low","medium","high"]).optional(),promptCacheKey:m().optional(),promptCacheRetention:se(["in_memory","24h"]).optional(),safetyIdentifier:m().optional()})));function qE({tools:e,toolChoice:t,structuredOutputs:n,strictJsonSchema:r}){e=e?.length?e:void 0;const s=[];if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:s};const i=[];for(const u of e)switch(u.type){case"function":i.push({type:"function",function:{name:u.name,description:u.description,parameters:u.inputSchema,strict:n?r:void 0}});break;default:s.push({type:"unsupported-tool",tool:u});break}if(t==null)return{tools:i,toolChoice:void 0,toolWarnings:s};const o=t.type;switch(o){case"auto":case"none":case"required":return{tools:i,toolChoice:o,toolWarnings:s};case"tool":return{tools:i,toolChoice:{type:"function",function:{name:t.toolName}},toolWarnings:s};default:{const u=o;throw new Ne({functionality:`tool choice type: ${u}`})}}}a(qE,"prepareChatTools");var VE=(bn=class{constructor(t,n){this.specificationVersion="v2",this.supportedUrls={"image/*":[/^https?:\/\/.*$/]},this.modelId=t,this.config=n}get provider(){return this.config.provider}async getArgs({prompt:t,maxOutputTokens:n,temperature:r,topP:s,topK:i,frequencyPenalty:o,presencePenalty:u,stopSequences:l,responseFormat:c,seed:d,tools:p,toolChoice:h,providerOptions:f}){var D,g,v,F;const C=[],_=(D=await ze({provider:"openai",providerOptions:f,schema:UE}))!=null?D:{},b=(g=_.structuredOutputs)!=null?g:!0;i!=null&&C.push({type:"unsupported-setting",setting:"topK"}),c?.type==="json"&&c.schema!=null&&!b&&C.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});const{messages:B,warnings:O}=zE({prompt:t,systemMessageMode:HE(this.modelId)});C.push(...O);const S=(v=_.strictJsonSchema)!=null?v:!1,$={model:this.modelId,logit_bias:_.logitBias,logprobs:_.logprobs===!0||typeof _.logprobs=="number"?!0:void 0,top_logprobs:typeof _.logprobs=="number"?_.logprobs:typeof _.logprobs=="boolean"&&_.logprobs?0:void 0,user:_.user,parallel_tool_calls:_.parallelToolCalls,max_tokens:n,temperature:r,top_p:s,frequency_penalty:o,presence_penalty:u,response_format:c?.type==="json"?b&&c.schema!=null?{type:"json_schema",json_schema:{schema:c.schema,strict:S,name:(F=c.name)!=null?F:"response",description:c.description}}:{type:"json_object"}:void 0,stop:l,seed:d,verbosity:_.textVerbosity,max_completion_tokens:_.maxCompletionTokens,store:_.store,metadata:_.metadata,prediction:_.prediction,reasoning_effort:_.reasoningEffort,service_tier:_.serviceTier,prompt_cache_key:_.promptCacheKey,prompt_cache_retention:_.promptCacheRetention,safety_identifier:_.safetyIdentifier,messages:B};Jd(this.modelId)?($.temperature!=null&&($.temperature=void 0,C.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for reasoning models"})),$.top_p!=null&&($.top_p=void 0,C.push({type:"unsupported-setting",setting:"topP",details:"topP is not supported for reasoning models"})),$.frequency_penalty!=null&&($.frequency_penalty=void 0,C.push({type:"unsupported-setting",setting:"frequencyPenalty",details:"frequencyPenalty is not supported for reasoning models"})),$.presence_penalty!=null&&($.presence_penalty=void 0,C.push({type:"unsupported-setting",setting:"presencePenalty",details:"presencePenalty is not supported for reasoning models"})),$.logit_bias!=null&&($.logit_bias=void 0,C.push({type:"other",message:"logitBias is not supported for reasoning models"})),$.logprobs!=null&&($.logprobs=void 0,C.push({type:"other",message:"logprobs is not supported for reasoning models"})),$.top_logprobs!=null&&($.top_logprobs=void 0,C.push({type:"other",message:"topLogprobs is not supported for reasoning models"})),$.max_tokens!=null&&($.max_completion_tokens==null&&($.max_completion_tokens=$.max_tokens),$.max_tokens=void 0)):(this.modelId.startsWith("gpt-4o-search-preview")||this.modelId.startsWith("gpt-4o-mini-search-preview"))&&$.temperature!=null&&($.temperature=void 0,C.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for the search preview models and has been removed."})),_.serviceTier==="flex"&&!GE(this.modelId)&&(C.push({type:"unsupported-setting",setting:"serviceTier",details:"flex processing is only available for o3, o4-mini, and gpt-5 models"}),$.service_tier=void 0),_.serviceTier==="priority"&&!WE(this.modelId)&&(C.push({type:"unsupported-setting",setting:"serviceTier",details:"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"}),$.service_tier=void 0);const{tools:G,toolChoice:z,toolWarnings:J}=qE({tools:p,toolChoice:h,structuredOutputs:b,strictJsonSchema:S});return{args:{...$,tools:G,tool_choice:z},warnings:[...C,...J]}}async doGenerate(t){var n,r,s,i,o,u,l,c,d,p,h,f,D,g;const{args:v,warnings:F}=await this.getArgs(t),{responseHeaders:C,value:_,rawValue:b}=await Ee({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:ye(this.config.headers(),t.headers),body:v,failedResponseHandler:nt,successfulResponseHandler:Te(ZE),abortSignal:t.abortSignal,fetch:this.config.fetch}),B=_.choices[0],O=[],S=B.message.content;S!=null&&S.length>0&&O.push({type:"text",text:S});for(const J of(n=B.message.tool_calls)!=null?n:[])O.push({type:"tool-call",toolCallId:(r=J.id)!=null?r:je(),toolName:J.function.name,input:J.function.arguments});for(const J of(s=B.message.annotations)!=null?s:[])O.push({type:"source",sourceType:"url",id:je(),url:J.url,title:J.title});const $=(i=_.usage)==null?void 0:i.completion_tokens_details,G=(o=_.usage)==null?void 0:o.prompt_tokens_details,z={openai:{}};return $?.accepted_prediction_tokens!=null&&(z.openai.acceptedPredictionTokens=$?.accepted_prediction_tokens),$?.rejected_prediction_tokens!=null&&(z.openai.rejectedPredictionTokens=$?.rejected_prediction_tokens),((u=B.logprobs)==null?void 0:u.content)!=null&&(z.openai.logprobs=B.logprobs.content),{content:O,finishReason:Hd(B.finish_reason),usage:{inputTokens:(c=(l=_.usage)==null?void 0:l.prompt_tokens)!=null?c:void 0,outputTokens:(p=(d=_.usage)==null?void 0:d.completion_tokens)!=null?p:void 0,totalTokens:(f=(h=_.usage)==null?void 0:h.total_tokens)!=null?f:void 0,reasoningTokens:(D=$?.reasoning_tokens)!=null?D:void 0,cachedInputTokens:(g=G?.cached_tokens)!=null?g:void 0},request:{body:v},response:{...Qs(_),headers:C,body:b},warnings:F,providerMetadata:z}}async doStream(t){const{args:n,warnings:r}=await this.getArgs(t),s={...n,stream:!0,stream_options:{include_usage:!0}},{responseHeaders:i,value:o}=await Ee({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:ye(this.config.headers(),t.headers),body:s,failedResponseHandler:nt,successfulResponseHandler:Lt(LE),abortSignal:t.abortSignal,fetch:this.config.fetch}),u=[];let l="unknown";const c={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};let d=!1,p=!1;const h={openai:{}};return{stream:o.pipeThrough(new TransformStream({start(f){f.enqueue({type:"stream-start",warnings:r})},transform(f,D){var g,v,F,C,_,b,B,O,S,$,G,z,J,L,le,W,ee,te,R,U,M,xe,ce,ne;if(t.includeRawChunks&&D.enqueue({type:"raw",rawValue:f.rawValue}),!f.success){l="error",D.enqueue({type:"error",error:f.error});return}const q=f.value;if("error"in q){l="error",D.enqueue({type:"error",error:q.error});return}if(!d){const E=Qs(q);Object.values(E).some(Boolean)&&(d=!0,D.enqueue({type:"response-metadata",...Qs(q)}))}q.usage!=null&&(c.inputTokens=(g=q.usage.prompt_tokens)!=null?g:void 0,c.outputTokens=(v=q.usage.completion_tokens)!=null?v:void 0,c.totalTokens=(F=q.usage.total_tokens)!=null?F:void 0,c.reasoningTokens=(_=(C=q.usage.completion_tokens_details)==null?void 0:C.reasoning_tokens)!=null?_:void 0,c.cachedInputTokens=(B=(b=q.usage.prompt_tokens_details)==null?void 0:b.cached_tokens)!=null?B:void 0,((O=q.usage.completion_tokens_details)==null?void 0:O.accepted_prediction_tokens)!=null&&(h.openai.acceptedPredictionTokens=(S=q.usage.completion_tokens_details)==null?void 0:S.accepted_prediction_tokens),(($=q.usage.completion_tokens_details)==null?void 0:$.rejected_prediction_tokens)!=null&&(h.openai.rejectedPredictionTokens=(G=q.usage.completion_tokens_details)==null?void 0:G.rejected_prediction_tokens));const Be=q.choices[0];if(Be?.finish_reason!=null&&(l=Hd(Be.finish_reason)),((z=Be?.logprobs)==null?void 0:z.content)!=null&&(h.openai.logprobs=Be.logprobs.content),Be?.delta==null)return;const qe=Be.delta;if(qe.content!=null&&(p||(D.enqueue({type:"text-start",id:"0"}),p=!0),D.enqueue({type:"text-delta",id:"0",delta:qe.content})),qe.tool_calls!=null)for(const E of qe.tool_calls){const V=E.index;if(u[V]==null){if(E.type!=="function")throw new Wn({data:E,message:"Expected 'function' type."});if(E.id==null)throw new Wn({data:E,message:"Expected 'id' to be a string."});if(((J=E.function)==null?void 0:J.name)==null)throw new Wn({data:E,message:"Expected 'function.name' to be a string."});D.enqueue({type:"tool-input-start",id:E.id,toolName:E.function.name}),u[V]={id:E.id,type:"function",function:{name:E.function.name,arguments:(L=E.function.arguments)!=null?L:""},hasFinished:!1};const ve=u[V];((le=ve.function)==null?void 0:le.name)!=null&&((W=ve.function)==null?void 0:W.arguments)!=null&&(ve.function.arguments.length>0&&D.enqueue({type:"tool-input-delta",id:ve.id,delta:ve.function.arguments}),Gr(ve.function.arguments)&&(D.enqueue({type:"tool-input-end",id:ve.id}),D.enqueue({type:"tool-call",toolCallId:(ee=ve.id)!=null?ee:je(),toolName:ve.function.name,input:ve.function.arguments}),ve.hasFinished=!0));continue}const de=u[V];de.hasFinished||(((te=E.function)==null?void 0:te.arguments)!=null&&(de.function.arguments+=(U=(R=E.function)==null?void 0:R.arguments)!=null?U:""),D.enqueue({type:"tool-input-delta",id:de.id,delta:(M=E.function.arguments)!=null?M:""}),((xe=de.function)==null?void 0:xe.name)!=null&&((ce=de.function)==null?void 0:ce.arguments)!=null&&Gr(de.function.arguments)&&(D.enqueue({type:"tool-input-end",id:de.id}),D.enqueue({type:"tool-call",toolCallId:(ne=de.id)!=null?ne:je(),toolName:de.function.name,input:de.function.arguments}),de.hasFinished=!0))}if(qe.annotations!=null)for(const E of qe.annotations)D.enqueue({type:"source",sourceType:"url",id:je(),url:E.url,title:E.title})},flush(f){p&&f.enqueue({type:"text-end",id:"0"}),f.enqueue({type:"finish",finishReason:l,usage:c,...h!=null?{providerMetadata:h}:{}})}})),request:{body:s},response:{headers:i}}}},a(bn,"OpenAIChatLanguageModel"),bn);function Jd(e){return(e.startsWith("o")||e.startsWith("gpt-5"))&&!e.startsWith("gpt-5-chat")}a(Jd,"isReasoningModel");function GE(e){return e.startsWith("o3")||e.startsWith("o4-mini")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-chat")}a(GE,"supportsFlexProcessing");function WE(e){return e.startsWith("gpt-4")||e.startsWith("gpt-5-mini")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-nano")&&!e.startsWith("gpt-5-chat")||e.startsWith("o3")||e.startsWith("o4-mini")}a(WE,"supportsPriorityProcessing");function HE(e){var t,n;return Jd(e)?(n=(t=JE[e])==null?void 0:t.systemMessageMode)!=null?n:"developer":"system"}a(HE,"getSystemMessageMode");var JE={o3:{systemMessageMode:"developer"},"o3-2025-04-16":{systemMessageMode:"developer"},"o3-mini":{systemMessageMode:"developer"},"o3-mini-2025-01-31":{systemMessageMode:"developer"},"o4-mini":{systemMessageMode:"developer"},"o4-mini-2025-04-16":{systemMessageMode:"developer"}};function KE({prompt:e,user:t="user",assistant:n="assistant"}){let r="";e[0].role==="system"&&(r+=`${e[0].content}
|
|
141
|
+
`)}})}};function PE(e){const t=["ROOT"];let n=-1,r=null;function s(l,c,d){switch(l){case'"':{n=c,t.pop(),t.push(d),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=c,r=c,t.pop(),t.push(d),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=c,t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"{":{n=c,t.pop(),t.push(d),t.push("INSIDE_OBJECT_START");break}case"[":{n=c,t.pop(),t.push(d),t.push("INSIDE_ARRAY_START");break}}}a(s,"processValueStart");function i(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=c,t.pop();break}}}a(i,"processAfterObjectValue");function o(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}}}a(o,"processAfterArrayValue");for(let l=0;l<e.length;l++){const c=e[l];switch(t[t.length-1]){case"ROOT":s(c,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(c){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{s(c,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(c,l);break}case"INSIDE_STRING":{switch(c){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(c){case"]":{n=l,t.pop();break}default:{n=l,s(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{s(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(c){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(c,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(c,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(c,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(c,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const p=e.substring(r,l+1);!"false".startsWith(p)&&!"true".startsWith(p)&&!"null".startsWith(p)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(c,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(c,l)):n=l;break}}}let u=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{u+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{u+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{u+="]";break}case"INSIDE_LITERAL":{const d=e.substring(r,e.length);"true".startsWith(d)?u+="true".slice(d.length):"false".startsWith(d)?u+="false".slice(d.length):"null".startsWith(d)&&(u+="null".slice(d.length))}}return u}a(PE,"fixJson");async function NE(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await It({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await It({text:PE(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}a(NE,"parsePartialJson"),rr({prefix:"aitxt",size:24}),rr({prefix:"aiobj",size:24}),rr({prefix:"aiobj",size:24});var ME={};kF(ME,{object:a(()=>zE,"object"),text:a(()=>jE,"text")});var jE=a(()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),"text"),zE=a(({schema:e})=>{const t=Yr(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:n}){const r=await NE(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:r.value};default:{const s=r.state;throw new Error(`Unsupported parse state: ${s}`)}}},async parseOutput({text:n},r){const s=await It({text:n});if(!s.success)throw new yd({message:"No object generated: could not parse the response.",cause:s.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});const i=await it({value:s.value,schema:t});if(!i.success)throw new yd({message:"No object generated: response did not match schema.",cause:i.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value}}},"object"),ei=y({error:y({message:m(),type:m().nullish(),param:Me().nullish(),code:X([m(),w()]).nullish()})}),ot=We({errorSchema:ei,errorToMessage:a(e=>e.error.message,"errorToMessage")});function ZE({prompt:e,systemMessageMode:t="system"}){const n=[],r=[];for(const{role:s,content:i}of e)switch(s){case"system":{switch(t){case"system":{n.push({role:"system",content:i});break}case"developer":{n.push({role:"developer",content:i});break}case"remove":{r.push({type:"other",message:"system messages are removed for this model"});break}default:{const o=t;throw new Error(`Unsupported system message mode: ${o}`)}}break}case"user":{if(i.length===1&&i[0].type==="text"){n.push({role:"user",content:i[0].text});break}n.push({role:"user",content:i.map((o,u)=>{var l,c,d;switch(o.type){case"text":return{type:"text",text:o.text};case"file":if(o.mediaType.startsWith("image/")){const p=o.mediaType==="image/*"?"image/jpeg":o.mediaType;return{type:"image_url",image_url:{url:o.data instanceof URL?o.data.toString():`data:${p};base64,${Bt(o.data)}`,detail:(c=(l=o.providerOptions)==null?void 0:l.openai)==null?void 0:c.imageDetail}}}else if(o.mediaType.startsWith("audio/")){if(o.data instanceof URL)throw new Ne({functionality:"audio file parts with URLs"});switch(o.mediaType){case"audio/wav":return{type:"input_audio",input_audio:{data:Bt(o.data),format:"wav"}};case"audio/mp3":case"audio/mpeg":return{type:"input_audio",input_audio:{data:Bt(o.data),format:"mp3"}};default:throw new Ne({functionality:`audio content parts with media type ${o.mediaType}`})}}else if(o.mediaType==="application/pdf"){if(o.data instanceof URL)throw new Ne({functionality:"PDF file parts with URLs"});return{type:"file",file:typeof o.data=="string"&&o.data.startsWith("file-")?{file_id:o.data}:{filename:(d=o.filename)!=null?d:`part-${u}.pdf`,file_data:`data:application/pdf;base64,${Bt(o.data)}`}}}else throw new Ne({functionality:`file part media type ${o.mediaType}`})}})});break}case"assistant":{let o="";const u=[];for(const l of i)switch(l.type){case"text":{o+=l.text;break}case"tool-call":{u.push({id:l.toolCallId,type:"function",function:{name:l.toolName,arguments:JSON.stringify(l.input)}});break}}n.push({role:"assistant",content:o,tool_calls:u.length>0?u:void 0});break}case"tool":{for(const o of i){const u=o.output;let l;switch(u.type){case"text":case"error-text":l=u.value;break;case"content":case"json":case"error-json":l=JSON.stringify(u.value);break}n.push({role:"tool",tool_call_id:o.toolCallId,content:l})}break}default:{const o=s;throw new Error(`Unsupported role: ${o}`)}}return{messages:n,warnings:r}}a(ZE,"convertToOpenAIChatMessages");function ti({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n?new Date(n*1e3):void 0}}a(ti,"getResponseMetadata$1");function Kd(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}a(Kd,"mapOpenAIFinishReason");var LE=ve(()=>Z(y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:$(y({message:y({role:k("assistant").nullish(),content:m().nullish(),tool_calls:$(y({id:m().nullish(),type:k("function"),function:y({name:m(),arguments:m()})})).nullish(),annotations:$(y({type:k("url_citation"),start_index:w(),end_index:w(),url:m(),title:m()})).nullish()}),index:w(),logprobs:y({content:$(y({token:m(),logprob:w(),top_logprobs:$(y({token:m(),logprob:w()}))})).nullish()}).nullish(),finish_reason:m().nullish()})),usage:y({prompt_tokens:w().nullish(),completion_tokens:w().nullish(),total_tokens:w().nullish(),prompt_tokens_details:y({cached_tokens:w().nullish()}).nullish(),completion_tokens_details:y({reasoning_tokens:w().nullish(),accepted_prediction_tokens:w().nullish(),rejected_prediction_tokens:w().nullish()}).nullish()}).nullish()}))),UE=ve(()=>Z(X([y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:$(y({delta:y({role:ie(["assistant"]).nullish(),content:m().nullish(),tool_calls:$(y({index:w(),id:m().nullish(),type:k("function").nullish(),function:y({name:m().nullish(),arguments:m().nullish()})})).nullish(),annotations:$(y({type:k("url_citation"),start_index:w(),end_index:w(),url:m(),title:m()})).nullish()}).nullish(),logprobs:y({content:$(y({token:m(),logprob:w(),top_logprobs:$(y({token:m(),logprob:w()}))})).nullish()}).nullish(),finish_reason:m().nullish(),index:w()})),usage:y({prompt_tokens:w().nullish(),completion_tokens:w().nullish(),total_tokens:w().nullish(),prompt_tokens_details:y({cached_tokens:w().nullish()}).nullish(),completion_tokens_details:y({reasoning_tokens:w().nullish(),accepted_prediction_tokens:w().nullish(),rejected_prediction_tokens:w().nullish()}).nullish()}).nullish()}),ei]))),qE=ve(()=>Z(y({logitBias:ge(Qy(),w()).optional(),logprobs:X([Ae(),w()]).optional(),parallelToolCalls:Ae().optional(),user:m().optional(),reasoningEffort:ie(["none","minimal","low","medium","high"]).optional(),maxCompletionTokens:w().optional(),store:Ae().optional(),metadata:ge(m().max(64),m().max(512)).optional(),prediction:ge(m(),Me()).optional(),structuredOutputs:Ae().optional(),serviceTier:ie(["auto","flex","priority","default"]).optional(),strictJsonSchema:Ae().optional(),textVerbosity:ie(["low","medium","high"]).optional(),promptCacheKey:m().optional(),promptCacheRetention:ie(["in_memory","24h"]).optional(),safetyIdentifier:m().optional()})));function VE({tools:e,toolChoice:t,structuredOutputs:n,strictJsonSchema:r}){e=e?.length?e:void 0;const s=[];if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:s};const i=[];for(const u of e)switch(u.type){case"function":i.push({type:"function",function:{name:u.name,description:u.description,parameters:u.inputSchema,strict:n?r:void 0}});break;default:s.push({type:"unsupported-tool",tool:u});break}if(t==null)return{tools:i,toolChoice:void 0,toolWarnings:s};const o=t.type;switch(o){case"auto":case"none":case"required":return{tools:i,toolChoice:o,toolWarnings:s};case"tool":return{tools:i,toolChoice:{type:"function",function:{name:t.toolName}},toolWarnings:s};default:{const u=o;throw new Ne({functionality:`tool choice type: ${u}`})}}}a(VE,"prepareChatTools");var GE=(xn=class{constructor(t,n){this.specificationVersion="v2",this.supportedUrls={"image/*":[/^https?:\/\/.*$/]},this.modelId=t,this.config=n}get provider(){return this.config.provider}async getArgs({prompt:t,maxOutputTokens:n,temperature:r,topP:s,topK:i,frequencyPenalty:o,presencePenalty:u,stopSequences:l,responseFormat:c,seed:d,tools:p,toolChoice:h,providerOptions:f}){var D,g,v,F;const C=[],_=(D=await ze({provider:"openai",providerOptions:f,schema:qE}))!=null?D:{},b=(g=_.structuredOutputs)!=null?g:!0;i!=null&&C.push({type:"unsupported-setting",setting:"topK"}),c?.type==="json"&&c.schema!=null&&!b&&C.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});const{messages:B,warnings:O}=ZE({prompt:t,systemMessageMode:JE(this.modelId)});C.push(...O);const S=(v=_.strictJsonSchema)!=null?v:!1,x={model:this.modelId,logit_bias:_.logitBias,logprobs:_.logprobs===!0||typeof _.logprobs=="number"?!0:void 0,top_logprobs:typeof _.logprobs=="number"?_.logprobs:typeof _.logprobs=="boolean"&&_.logprobs?0:void 0,user:_.user,parallel_tool_calls:_.parallelToolCalls,max_tokens:n,temperature:r,top_p:s,frequency_penalty:o,presence_penalty:u,response_format:c?.type==="json"?b&&c.schema!=null?{type:"json_schema",json_schema:{schema:c.schema,strict:S,name:(F=c.name)!=null?F:"response",description:c.description}}:{type:"json_object"}:void 0,stop:l,seed:d,verbosity:_.textVerbosity,max_completion_tokens:_.maxCompletionTokens,store:_.store,metadata:_.metadata,prediction:_.prediction,reasoning_effort:_.reasoningEffort,service_tier:_.serviceTier,prompt_cache_key:_.promptCacheKey,prompt_cache_retention:_.promptCacheRetention,safety_identifier:_.safetyIdentifier,messages:B};Yd(this.modelId)?(x.temperature!=null&&(x.temperature=void 0,C.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for reasoning models"})),x.top_p!=null&&(x.top_p=void 0,C.push({type:"unsupported-setting",setting:"topP",details:"topP is not supported for reasoning models"})),x.frequency_penalty!=null&&(x.frequency_penalty=void 0,C.push({type:"unsupported-setting",setting:"frequencyPenalty",details:"frequencyPenalty is not supported for reasoning models"})),x.presence_penalty!=null&&(x.presence_penalty=void 0,C.push({type:"unsupported-setting",setting:"presencePenalty",details:"presencePenalty is not supported for reasoning models"})),x.logit_bias!=null&&(x.logit_bias=void 0,C.push({type:"other",message:"logitBias is not supported for reasoning models"})),x.logprobs!=null&&(x.logprobs=void 0,C.push({type:"other",message:"logprobs is not supported for reasoning models"})),x.top_logprobs!=null&&(x.top_logprobs=void 0,C.push({type:"other",message:"topLogprobs is not supported for reasoning models"})),x.max_tokens!=null&&(x.max_completion_tokens==null&&(x.max_completion_tokens=x.max_tokens),x.max_tokens=void 0)):(this.modelId.startsWith("gpt-4o-search-preview")||this.modelId.startsWith("gpt-4o-mini-search-preview"))&&x.temperature!=null&&(x.temperature=void 0,C.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for the search preview models and has been removed."})),_.serviceTier==="flex"&&!WE(this.modelId)&&(C.push({type:"unsupported-setting",setting:"serviceTier",details:"flex processing is only available for o3, o4-mini, and gpt-5 models"}),x.service_tier=void 0),_.serviceTier==="priority"&&!HE(this.modelId)&&(C.push({type:"unsupported-setting",setting:"serviceTier",details:"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"}),x.service_tier=void 0);const{tools:L,toolChoice:P,toolWarnings:J}=VE({tools:p,toolChoice:h,structuredOutputs:b,strictJsonSchema:S});return{args:{...x,tools:L,tool_choice:P},warnings:[...C,...J]}}async doGenerate(t){var n,r,s,i,o,u,l,c,d,p,h,f,D,g;const{args:v,warnings:F}=await this.getArgs(t),{responseHeaders:C,value:_,rawValue:b}=await Ce({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),body:v,failedResponseHandler:ot,successfulResponseHandler:Te(LE),abortSignal:t.abortSignal,fetch:this.config.fetch}),B=_.choices[0],O=[],S=B.message.content;S!=null&&S.length>0&&O.push({type:"text",text:S});for(const J of(n=B.message.tool_calls)!=null?n:[])O.push({type:"tool-call",toolCallId:(r=J.id)!=null?r:je(),toolName:J.function.name,input:J.function.arguments});for(const J of(s=B.message.annotations)!=null?s:[])O.push({type:"source",sourceType:"url",id:je(),url:J.url,title:J.title});const x=(i=_.usage)==null?void 0:i.completion_tokens_details,L=(o=_.usage)==null?void 0:o.prompt_tokens_details,P={openai:{}};return x?.accepted_prediction_tokens!=null&&(P.openai.acceptedPredictionTokens=x?.accepted_prediction_tokens),x?.rejected_prediction_tokens!=null&&(P.openai.rejectedPredictionTokens=x?.rejected_prediction_tokens),((u=B.logprobs)==null?void 0:u.content)!=null&&(P.openai.logprobs=B.logprobs.content),{content:O,finishReason:Kd(B.finish_reason),usage:{inputTokens:(c=(l=_.usage)==null?void 0:l.prompt_tokens)!=null?c:void 0,outputTokens:(p=(d=_.usage)==null?void 0:d.completion_tokens)!=null?p:void 0,totalTokens:(f=(h=_.usage)==null?void 0:h.total_tokens)!=null?f:void 0,reasoningTokens:(D=x?.reasoning_tokens)!=null?D:void 0,cachedInputTokens:(g=L?.cached_tokens)!=null?g:void 0},request:{body:v},response:{...ti(_),headers:C,body:b},warnings:F,providerMetadata:P}}async doStream(t){const{args:n,warnings:r}=await this.getArgs(t),s={...n,stream:!0,stream_options:{include_usage:!0}},{responseHeaders:i,value:o}=await Ce({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),body:s,failedResponseHandler:ot,successfulResponseHandler:Gt(UE),abortSignal:t.abortSignal,fetch:this.config.fetch}),u=[];let l="unknown";const c={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};let d=!1,p=!1;const h={openai:{}};return{stream:o.pipeThrough(new TransformStream({start(f){f.enqueue({type:"stream-start",warnings:r})},transform(f,D){var g,v,F,C,_,b,B,O,S,x,L,P,J,U,ce,W,te,ne,R,q,j,xe,de,re;if(t.includeRawChunks&&D.enqueue({type:"raw",rawValue:f.rawValue}),!f.success){l="error",D.enqueue({type:"error",error:f.error});return}const V=f.value;if("error"in V){l="error",D.enqueue({type:"error",error:V.error});return}if(!d){const E=ti(V);Object.values(E).some(Boolean)&&(d=!0,D.enqueue({type:"response-metadata",...ti(V)}))}V.usage!=null&&(c.inputTokens=(g=V.usage.prompt_tokens)!=null?g:void 0,c.outputTokens=(v=V.usage.completion_tokens)!=null?v:void 0,c.totalTokens=(F=V.usage.total_tokens)!=null?F:void 0,c.reasoningTokens=(_=(C=V.usage.completion_tokens_details)==null?void 0:C.reasoning_tokens)!=null?_:void 0,c.cachedInputTokens=(B=(b=V.usage.prompt_tokens_details)==null?void 0:b.cached_tokens)!=null?B:void 0,((O=V.usage.completion_tokens_details)==null?void 0:O.accepted_prediction_tokens)!=null&&(h.openai.acceptedPredictionTokens=(S=V.usage.completion_tokens_details)==null?void 0:S.accepted_prediction_tokens),((x=V.usage.completion_tokens_details)==null?void 0:x.rejected_prediction_tokens)!=null&&(h.openai.rejectedPredictionTokens=(L=V.usage.completion_tokens_details)==null?void 0:L.rejected_prediction_tokens));const Be=V.choices[0];if(Be?.finish_reason!=null&&(l=Kd(Be.finish_reason)),((P=Be?.logprobs)==null?void 0:P.content)!=null&&(h.openai.logprobs=Be.logprobs.content),Be?.delta==null)return;const qe=Be.delta;if(qe.content!=null&&(p||(D.enqueue({type:"text-start",id:"0"}),p=!0),D.enqueue({type:"text-delta",id:"0",delta:qe.content})),qe.tool_calls!=null)for(const E of qe.tool_calls){const G=E.index;if(u[G]==null){if(E.type!=="function")throw new Jn({data:E,message:"Expected 'function' type."});if(E.id==null)throw new Jn({data:E,message:"Expected 'id' to be a string."});if(((J=E.function)==null?void 0:J.name)==null)throw new Jn({data:E,message:"Expected 'function.name' to be a string."});D.enqueue({type:"tool-input-start",id:E.id,toolName:E.function.name}),u[G]={id:E.id,type:"function",function:{name:E.function.name,arguments:(U=E.function.arguments)!=null?U:""},hasFinished:!1};const ye=u[G];((ce=ye.function)==null?void 0:ce.name)!=null&&((W=ye.function)==null?void 0:W.arguments)!=null&&(ye.function.arguments.length>0&&D.enqueue({type:"tool-input-delta",id:ye.id,delta:ye.function.arguments}),Kr(ye.function.arguments)&&(D.enqueue({type:"tool-input-end",id:ye.id}),D.enqueue({type:"tool-call",toolCallId:(te=ye.id)!=null?te:je(),toolName:ye.function.name,input:ye.function.arguments}),ye.hasFinished=!0));continue}const pe=u[G];pe.hasFinished||(((ne=E.function)==null?void 0:ne.arguments)!=null&&(pe.function.arguments+=(q=(R=E.function)==null?void 0:R.arguments)!=null?q:""),D.enqueue({type:"tool-input-delta",id:pe.id,delta:(j=E.function.arguments)!=null?j:""}),((xe=pe.function)==null?void 0:xe.name)!=null&&((de=pe.function)==null?void 0:de.arguments)!=null&&Kr(pe.function.arguments)&&(D.enqueue({type:"tool-input-end",id:pe.id}),D.enqueue({type:"tool-call",toolCallId:(re=pe.id)!=null?re:je(),toolName:pe.function.name,input:pe.function.arguments}),pe.hasFinished=!0))}if(qe.annotations!=null)for(const E of qe.annotations)D.enqueue({type:"source",sourceType:"url",id:je(),url:E.url,title:E.title})},flush(f){p&&f.enqueue({type:"text-end",id:"0"}),f.enqueue({type:"finish",finishReason:l,usage:c,...h!=null?{providerMetadata:h}:{}})}})),request:{body:s},response:{headers:i}}}},a(xn,"OpenAIChatLanguageModel"),xn);function Yd(e){return(e.startsWith("o")||e.startsWith("gpt-5"))&&!e.startsWith("gpt-5-chat")}a(Yd,"isReasoningModel");function WE(e){return e.startsWith("o3")||e.startsWith("o4-mini")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-chat")}a(WE,"supportsFlexProcessing");function HE(e){return e.startsWith("gpt-4")||e.startsWith("gpt-5-mini")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-nano")&&!e.startsWith("gpt-5-chat")||e.startsWith("o3")||e.startsWith("o4-mini")}a(HE,"supportsPriorityProcessing");function JE(e){var t,n;return Yd(e)?(n=(t=KE[e])==null?void 0:t.systemMessageMode)!=null?n:"developer":"system"}a(JE,"getSystemMessageMode");var KE={o3:{systemMessageMode:"developer"},"o3-2025-04-16":{systemMessageMode:"developer"},"o3-mini":{systemMessageMode:"developer"},"o3-mini-2025-01-31":{systemMessageMode:"developer"},"o4-mini":{systemMessageMode:"developer"},"o4-mini-2025-04-16":{systemMessageMode:"developer"}};function YE({prompt:e,user:t="user",assistant:n="assistant"}){let r="";e[0].role==="system"&&(r+=`${e[0].content}
|
|
142
142
|
|
|
143
|
-
`,e=e.slice(1));for(const{role:s,content:i}of e)switch(s){case"system":throw new
|
|
143
|
+
`,e=e.slice(1));for(const{role:s,content:i}of e)switch(s){case"system":throw new dt({message:"Unexpected system message in prompt: ${content}",prompt:e});case"user":{const o=i.map(u=>{switch(u.type){case"text":return u.text}}).filter(Boolean).join("");r+=`${t}:
|
|
144
144
|
${o}
|
|
145
145
|
|
|
146
146
|
`;break}case"assistant":{const o=i.map(u=>{switch(u.type){case"text":return u.text;case"tool-call":throw new Ne({functionality:"tool-call messages"})}}).join("");r+=`${n}:
|
|
@@ -148,9 +148,9 @@ ${o}
|
|
|
148
148
|
|
|
149
149
|
`;break}case"tool":throw new Ne({functionality:"tool messages"});default:{const o=s;throw new Error(`Unsupported role: ${o}`)}}return r+=`${n}:
|
|
150
150
|
`,{prompt:r,stopSequences:[`
|
|
151
|
-
${t}:`]}}a(KE,"convertToOpenAICompletionPrompt");function Kd({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n!=null?new Date(n*1e3):void 0}}a(Kd,"getResponseMetadata2$1");function Yd(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}a(Yd,"mapOpenAIFinishReason2");var YE=ge(()=>Z(y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:x(y({text:m(),finish_reason:m(),logprobs:y({tokens:x(m()),token_logprobs:x(w()),top_logprobs:x(he(m(),w())).nullish()}).nullish()})),usage:y({prompt_tokens:w(),completion_tokens:w(),total_tokens:w()}).nullish()}))),XE=ge(()=>Z(Y([y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:x(y({text:m(),finish_reason:m().nullish(),index:w(),logprobs:y({tokens:x(m()),token_logprobs:x(w()),top_logprobs:x(he(m(),w())).nullish()}).nullish()})),usage:y({prompt_tokens:w(),completion_tokens:w(),total_tokens:w()}).nullish()}),Xs]))),Xd=ge(()=>Z(y({echo:Ae().optional(),logitBias:he(m(),w()).optional(),suffix:m().optional(),user:m().optional(),logprobs:Y([Ae(),w()]).optional()}))),QE=(wn=class{constructor(t,n){this.specificationVersion="v2",this.supportedUrls={},this.modelId=t,this.config=n}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get provider(){return this.config.provider}async getArgs({prompt:t,maxOutputTokens:n,temperature:r,topP:s,topK:i,frequencyPenalty:o,presencePenalty:u,stopSequences:l,responseFormat:c,tools:d,toolChoice:p,seed:h,providerOptions:f}){const D=[],g={...await ze({provider:"openai",providerOptions:f,schema:Xd}),...await ze({provider:this.providerOptionsName,providerOptions:f,schema:Xd})};i!=null&&D.push({type:"unsupported-setting",setting:"topK"}),d?.length&&D.push({type:"unsupported-setting",setting:"tools"}),p!=null&&D.push({type:"unsupported-setting",setting:"toolChoice"}),c!=null&&c.type!=="text"&&D.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format is not supported."});const{prompt:v,stopSequences:F}=KE({prompt:t}),C=[...F??[],...l??[]];return{args:{model:this.modelId,echo:g.echo,logit_bias:g.logitBias,logprobs:g?.logprobs===!0?0:g?.logprobs===!1?void 0:g?.logprobs,suffix:g.suffix,user:g.user,max_tokens:n,temperature:r,top_p:s,frequency_penalty:o,presence_penalty:u,seed:h,prompt:v,stop:C.length>0?C:void 0},warnings:D}}async doGenerate(t){var n,r,s;const{args:i,warnings:o}=await this.getArgs(t),{responseHeaders:u,value:l,rawValue:c}=await Ee({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:ye(this.config.headers(),t.headers),body:i,failedResponseHandler:nt,successfulResponseHandler:Te(YE),abortSignal:t.abortSignal,fetch:this.config.fetch}),d=l.choices[0],p={openai:{}};return d.logprobs!=null&&(p.openai.logprobs=d.logprobs),{content:[{type:"text",text:d.text}],usage:{inputTokens:(n=l.usage)==null?void 0:n.prompt_tokens,outputTokens:(r=l.usage)==null?void 0:r.completion_tokens,totalTokens:(s=l.usage)==null?void 0:s.total_tokens},finishReason:Yd(d.finish_reason),request:{body:i},response:{...Kd(l),headers:u,body:c},providerMetadata:p,warnings:o}}async doStream(t){const{args:n,warnings:r}=await this.getArgs(t),s={...n,stream:!0,stream_options:{include_usage:!0}},{responseHeaders:i,value:o}=await Ee({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:ye(this.config.headers(),t.headers),body:s,failedResponseHandler:nt,successfulResponseHandler:Lt(XE),abortSignal:t.abortSignal,fetch:this.config.fetch});let u="unknown";const l={openai:{}},c={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};let d=!0;return{stream:o.pipeThrough(new TransformStream({start(p){p.enqueue({type:"stream-start",warnings:r})},transform(p,h){if(t.includeRawChunks&&h.enqueue({type:"raw",rawValue:p.rawValue}),!p.success){u="error",h.enqueue({type:"error",error:p.error});return}const f=p.value;if("error"in f){u="error",h.enqueue({type:"error",error:f.error});return}d&&(d=!1,h.enqueue({type:"response-metadata",...Kd(f)}),h.enqueue({type:"text-start",id:"0"})),f.usage!=null&&(c.inputTokens=f.usage.prompt_tokens,c.outputTokens=f.usage.completion_tokens,c.totalTokens=f.usage.total_tokens);const D=f.choices[0];D?.finish_reason!=null&&(u=Yd(D.finish_reason)),D?.logprobs!=null&&(l.openai.logprobs=D.logprobs),D?.text!=null&&D.text.length>0&&h.enqueue({type:"text-delta",id:"0",delta:D.text})},flush(p){d||p.enqueue({type:"text-end",id:"0"}),p.enqueue({type:"finish",finishReason:u,providerMetadata:l,usage:c})}})),request:{body:s},response:{headers:i}}}},a(wn,"OpenAICompletionLanguageModel"),wn),eC=ge(()=>Z(y({dimensions:w().optional(),user:m().optional()}))),tC=ge(()=>Z(y({data:x(y({embedding:x(w())})),usage:y({prompt_tokens:w()}).nullish()}))),nC=(An=class{constructor(t,n){this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0,this.modelId=t,this.config=n}get provider(){return this.config.provider}async doEmbed({values:t,headers:n,abortSignal:r,providerOptions:s}){var i;if(t.length>this.maxEmbeddingsPerCall)throw new tl({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:t});const o=(i=await ze({provider:"openai",providerOptions:s,schema:eC}))!=null?i:{},{responseHeaders:u,value:l,rawValue:c}=await Ee({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:ye(this.config.headers(),n),body:{model:this.modelId,input:t,encoding_format:"float",dimensions:o.dimensions,user:o.user},failedResponseHandler:nt,successfulResponseHandler:Te(tC),abortSignal:r,fetch:this.config.fetch});return{embeddings:l.data.map(d=>d.embedding),usage:l.usage?{tokens:l.usage.prompt_tokens}:void 0,response:{headers:u,body:c}}}},a(An,"OpenAIEmbeddingModel"),An),rC=ge(()=>Z(y({data:x(y({b64_json:m(),revised_prompt:m().nullish()}))}))),oC={"dall-e-3":1,"dall-e-2":10,"gpt-image-1":10,"gpt-image-1-mini":10},sC=new Set(["gpt-image-1","gpt-image-1-mini"]),iC=(kn=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2"}get maxImagesPerCall(){var t;return(t=oC[this.modelId])!=null?t:1}get provider(){return this.config.provider}async doGenerate({prompt:t,n,size:r,aspectRatio:s,seed:i,providerOptions:o,headers:u,abortSignal:l}){var c,d,p,h;const f=[];s!=null&&f.push({type:"unsupported-setting",setting:"aspectRatio",details:"This model does not support aspect ratio. Use `size` instead."}),i!=null&&f.push({type:"unsupported-setting",setting:"seed"});const D=(p=(d=(c=this.config._internal)==null?void 0:c.currentDate)==null?void 0:d.call(c))!=null?p:new Date,{value:g,responseHeaders:v}=await Ee({url:this.config.url({path:"/images/generations",modelId:this.modelId}),headers:ye(this.config.headers(),u),body:{model:this.modelId,prompt:t,n,size:r,...(h=o.openai)!=null?h:{},...sC.has(this.modelId)?{}:{response_format:"b64_json"}},failedResponseHandler:nt,successfulResponseHandler:Te(rC),abortSignal:l,fetch:this.config.fetch});return{images:g.data.map(F=>F.b64_json),warnings:f,response:{timestamp:D,modelId:this.modelId,headers:v},providerMetadata:{openai:{images:g.data.map(F=>F.revised_prompt?{revisedPrompt:F.revised_prompt}:null)}}}}},a(kn,"OpenAIImageModel"),kn),aC=$e(()=>Z(y({code:m().nullish(),containerId:m()}))),uC=$e(()=>Z(y({outputs:x(ke("type",[y({type:k("logs"),logs:m()}),y({type:k("image"),url:m()})])).nullish()}))),lC=$e(()=>Z(y({container:Y([m(),y({fileIds:x(m()).optional()})]).optional()}))),cC=Zt({id:"openai.code_interpreter",name:"code_interpreter",inputSchema:aC,outputSchema:uC}),dC=a((e={})=>cC(e),"codeInterpreter"),Qd=y({key:m(),type:se(["eq","ne","gt","gte","lt","lte"]),value:Y([m(),w(),Ae()])}),ep=y({type:se(["and","or"]),filters:x(Y([Qd,Yl(()=>ep)]))}),pC=$e(()=>Z(y({vectorStoreIds:x(m()),maxNumResults:w().optional(),ranking:y({ranker:m().optional(),scoreThreshold:w().optional()}).optional(),filters:Y([Qd,ep]).optional()}))),DC=$e(()=>Z(y({queries:x(m()),results:x(y({attributes:he(m(),rt()),fileId:m(),filename:m(),score:w(),text:m()})).nullable()}))),fC=Zt({id:"openai.file_search",name:"file_search",inputSchema:y({}),outputSchema:DC}),mC=$e(()=>Z(y({background:se(["auto","opaque","transparent"]).optional(),inputFidelity:se(["low","high"]).optional(),inputImageMask:y({fileId:m().optional(),imageUrl:m().optional()}).optional(),model:m().optional(),moderation:se(["auto"]).optional(),outputCompression:w().int().min(0).max(100).optional(),outputFormat:se(["png","jpeg","webp"]).optional(),partialImages:w().int().min(0).max(3).optional(),quality:se(["auto","low","medium","high"]).optional(),size:se(["1024x1024","1024x1536","1536x1024","auto"]).optional()}).strict())),hC=$e(()=>Z(y({}))),gC=$e(()=>Z(y({result:m()}))),vC=Zt({id:"openai.image_generation",name:"image_generation",inputSchema:hC,outputSchema:gC}),yC=a((e={})=>vC(e),"imageGeneration"),tp=$e(()=>Z(y({action:y({type:k("exec"),command:x(m()),timeoutMs:w().optional(),user:m().optional(),workingDirectory:m().optional(),env:he(m(),m()).optional()})}))),np=$e(()=>Z(y({output:m()}))),_C=Zt({id:"openai.local_shell",name:"local_shell",inputSchema:tp,outputSchema:np}),FC=$e(()=>Z(y({externalWebAccess:Ae().optional(),filters:y({allowedDomains:x(m()).optional()}).optional(),searchContextSize:se(["low","medium","high"]).optional(),userLocation:y({type:k("approximate"),country:m().optional(),city:m().optional(),region:m().optional(),timezone:m().optional()}).optional()}))),EC=$e(()=>Z(y({}))),CC=$e(()=>Z(y({action:ke("type",[y({type:k("search"),query:m().optional()}),y({type:k("openPage"),url:m()}),y({type:k("find"),url:m(),pattern:m()})]),sources:x(ke("type",[y({type:k("url"),url:m()}),y({type:k("api"),name:m()})])).optional()}))),bC=Zt({id:"openai.web_search",name:"web_search",inputSchema:EC,outputSchema:CC}),wC=a((e={})=>bC(e),"webSearch"),AC=$e(()=>Z(y({searchContextSize:se(["low","medium","high"]).optional(),userLocation:y({type:k("approximate"),country:m().optional(),city:m().optional(),region:m().optional(),timezone:m().optional()}).optional()}))),kC=$e(()=>Z(y({}))),xC=$e(()=>Z(y({action:ke("type",[y({type:k("search"),query:m().optional()}),y({type:k("openPage"),url:m()}),y({type:k("find"),url:m(),pattern:m()})])}))),IC=Zt({id:"openai.web_search_preview",name:"web_search_preview",inputSchema:kC,outputSchema:xC}),$C={codeInterpreter:dC,fileSearch:fC,imageGeneration:yC,localShell:_C,webSearchPreview:IC,webSearch:wC};function rp(e,t){return t?t.some(n=>e.startsWith(n)):!1}a(rp,"isFileId");async function BC({prompt:e,systemMessageMode:t,fileIdPrefixes:n,store:r,hasLocalShellTool:s=!1}){var i,o,u,l;const c=[],d=[];for(const{role:p,content:h}of e)switch(p){case"system":{switch(t){case"system":{c.push({role:"system",content:h});break}case"developer":{c.push({role:"developer",content:h});break}case"remove":{d.push({type:"other",message:"system messages are removed for this model"});break}default:{const f=t;throw new Error(`Unsupported system message mode: ${f}`)}}break}case"user":{c.push({role:"user",content:h.map((f,D)=>{var g,v,F;switch(f.type){case"text":return{type:"input_text",text:f.text};case"file":if(f.mediaType.startsWith("image/")){const C=f.mediaType==="image/*"?"image/jpeg":f.mediaType;return{type:"input_image",...f.data instanceof URL?{image_url:f.data.toString()}:typeof f.data=="string"&&rp(f.data,n)?{file_id:f.data}:{image_url:`data:${C};base64,${kt(f.data)}`},detail:(v=(g=f.providerOptions)==null?void 0:g.openai)==null?void 0:v.imageDetail}}else{if(f.mediaType==="application/pdf")return f.data instanceof URL?{type:"input_file",file_url:f.data.toString()}:{type:"input_file",...typeof f.data=="string"&&rp(f.data,n)?{file_id:f.data}:{filename:(F=f.filename)!=null?F:`part-${D}.pdf`,file_data:`data:application/pdf;base64,${kt(f.data)}`}};throw new Ne({functionality:`file part media type ${f.mediaType}`})}}})});break}case"assistant":{const f={},D={};for(const g of h)switch(g.type){case"text":{const v=(o=(i=g.providerOptions)==null?void 0:i.openai)==null?void 0:o.itemId;if(r&&v!=null){c.push({type:"item_reference",id:v});break}c.push({role:"assistant",content:[{type:"output_text",text:g.text}],id:v});break}case"tool-call":{if(D[g.toolCallId]=g,g.providerExecuted)break;const v=(l=(u=g.providerOptions)==null?void 0:u.openai)==null?void 0:l.itemId;if(r&&v!=null){c.push({type:"item_reference",id:v});break}if(s&&g.toolName==="local_shell"){const F=await pt({value:g.input,schema:tp});c.push({type:"local_shell_call",call_id:g.toolCallId,id:v,action:{type:"exec",command:F.action.command,timeout_ms:F.action.timeoutMs,user:F.action.user,working_directory:F.action.workingDirectory,env:F.action.env}});break}c.push({type:"function_call",call_id:g.toolCallId,name:g.toolName,arguments:JSON.stringify(g.input),id:v});break}case"tool-result":{r?c.push({type:"item_reference",id:g.toolCallId}):d.push({type:"other",message:`Results for OpenAI tool ${g.toolName} are not sent to the API when store is false`});break}case"reasoning":{const v=await ze({provider:"openai",providerOptions:g.providerOptions,schema:SC}),F=v?.itemId;if(F!=null){const C=f[F];if(r)C===void 0&&(c.push({type:"item_reference",id:F}),f[F]={type:"reasoning",id:F,summary:[]});else{const _=[];g.text.length>0?_.push({type:"summary_text",text:g.text}):C!==void 0&&d.push({type:"other",message:`Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(g)}.`}),C===void 0?(f[F]={type:"reasoning",id:F,encrypted_content:v?.reasoningEncryptedContent,summary:_},c.push(f[F])):(C.summary.push(..._),v?.reasoningEncryptedContent!=null&&(C.encrypted_content=v.reasoningEncryptedContent))}}else d.push({type:"other",message:`Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(g)}.`});break}}break}case"tool":{for(const f of h){const D=f.output;if(s&&f.toolName==="local_shell"&&D.type==="json"){const v=await pt({value:D.value,schema:np});c.push({type:"local_shell_call_output",call_id:f.toolCallId,output:v.output});break}let g;switch(D.type){case"text":case"error-text":g=D.value;break;case"json":case"error-json":g=JSON.stringify(D.value);break;case"content":g=D.value.map(v=>{switch(v.type){case"text":return{type:"input_text",text:v.text};case"media":return v.mediaType.startsWith("image/")?{type:"input_image",image_url:`data:${v.mediaType};base64,${v.data}`}:{type:"input_file",filename:"data",file_data:`data:${v.mediaType};base64,${v.data}`}}});break}c.push({type:"function_call_output",call_id:f.toolCallId,output:g})}break}default:{const f=p;throw new Error(`Unsupported role: ${f}`)}}return{input:c,warnings:d}}a(BC,"convertToOpenAIResponsesInput");var SC=y({itemId:m().nullish(),reasoningEncryptedContent:m().nullish()});function op({finishReason:e,hasFunctionCall:t}){switch(e){case void 0:case null:return t?"tool-calls":"stop";case"max_output_tokens":return"length";case"content_filter":return"content-filter";default:return t?"tool-calls":"unknown"}}a(op,"mapOpenAIResponseFinishReason");var TC=ge(()=>Z(Y([y({type:k("response.output_text.delta"),item_id:m(),delta:m(),logprobs:x(y({token:m(),logprob:w(),top_logprobs:x(y({token:m(),logprob:w()}))})).nullish()}),y({type:se(["response.completed","response.incomplete"]),response:y({incomplete_details:y({reason:m()}).nullish(),usage:y({input_tokens:w(),input_tokens_details:y({cached_tokens:w().nullish()}).nullish(),output_tokens:w(),output_tokens_details:y({reasoning_tokens:w().nullish()}).nullish()}),service_tier:m().nullish()})}),y({type:k("response.created"),response:y({id:m(),created_at:w(),model:m(),service_tier:m().nullish()})}),y({type:k("response.output_item.added"),output_index:w(),item:ke("type",[y({type:k("message"),id:m()}),y({type:k("reasoning"),id:m(),encrypted_content:m().nullish()}),y({type:k("function_call"),id:m(),call_id:m(),name:m(),arguments:m()}),y({type:k("web_search_call"),id:m(),status:m()}),y({type:k("computer_call"),id:m(),status:m()}),y({type:k("file_search_call"),id:m()}),y({type:k("image_generation_call"),id:m()}),y({type:k("code_interpreter_call"),id:m(),container_id:m(),code:m().nullable(),outputs:x(ke("type",[y({type:k("logs"),logs:m()}),y({type:k("image"),url:m()})])).nullable(),status:m()})])}),y({type:k("response.output_item.done"),output_index:w(),item:ke("type",[y({type:k("message"),id:m()}),y({type:k("reasoning"),id:m(),encrypted_content:m().nullish()}),y({type:k("function_call"),id:m(),call_id:m(),name:m(),arguments:m(),status:k("completed")}),y({type:k("code_interpreter_call"),id:m(),code:m().nullable(),container_id:m(),outputs:x(ke("type",[y({type:k("logs"),logs:m()}),y({type:k("image"),url:m()})])).nullable()}),y({type:k("image_generation_call"),id:m(),result:m()}),y({type:k("web_search_call"),id:m(),status:m(),action:ke("type",[y({type:k("search"),query:m().nullish(),sources:x(ke("type",[y({type:k("url"),url:m()}),y({type:k("api"),name:m()})])).nullish()}),y({type:k("open_page"),url:m()}),y({type:k("find"),url:m(),pattern:m()})])}),y({type:k("file_search_call"),id:m(),queries:x(m()),results:x(y({attributes:he(m(),rt()),file_id:m(),filename:m(),score:w(),text:m()})).nullish()}),y({type:k("local_shell_call"),id:m(),call_id:m(),action:y({type:k("exec"),command:x(m()),timeout_ms:w().optional(),user:m().optional(),working_directory:m().optional(),env:he(m(),m()).optional()})}),y({type:k("computer_call"),id:m(),status:k("completed")})])}),y({type:k("response.function_call_arguments.delta"),item_id:m(),output_index:w(),delta:m()}),y({type:k("response.image_generation_call.partial_image"),item_id:m(),output_index:w(),partial_image_b64:m()}),y({type:k("response.code_interpreter_call_code.delta"),item_id:m(),output_index:w(),delta:m()}),y({type:k("response.code_interpreter_call_code.done"),item_id:m(),output_index:w(),code:m()}),y({type:k("response.output_text.annotation.added"),annotation:ke("type",[y({type:k("url_citation"),start_index:w(),end_index:w(),url:m(),title:m()}),y({type:k("file_citation"),file_id:m(),filename:m().nullish(),index:w().nullish(),start_index:w().nullish(),end_index:w().nullish(),quote:m().nullish()})])}),y({type:k("response.reasoning_summary_part.added"),item_id:m(),summary_index:w()}),y({type:k("response.reasoning_summary_text.delta"),item_id:m(),summary_index:w(),delta:m()}),y({type:k("response.reasoning_summary_part.done"),item_id:m(),summary_index:w()}),y({type:k("error"),sequence_number:w(),error:y({type:m(),code:m(),message:m(),param:m().nullish()})}),y({type:m()}).loose().transform(e=>({type:"unknown_chunk",message:e.type}))]))),OC=ge(()=>Z(y({id:m().optional(),created_at:w().optional(),error:y({message:m(),type:m(),param:m().nullish(),code:m()}).nullish(),model:m().optional(),output:x(ke("type",[y({type:k("message"),role:k("assistant"),id:m(),content:x(y({type:k("output_text"),text:m(),logprobs:x(y({token:m(),logprob:w(),top_logprobs:x(y({token:m(),logprob:w()}))})).nullish(),annotations:x(ke("type",[y({type:k("url_citation"),start_index:w(),end_index:w(),url:m(),title:m()}),y({type:k("file_citation"),file_id:m(),filename:m().nullish(),index:w().nullish(),start_index:w().nullish(),end_index:w().nullish(),quote:m().nullish()}),y({type:k("container_file_citation"),container_id:m(),file_id:m(),filename:m().nullish(),start_index:w().nullish(),end_index:w().nullish(),index:w().nullish()}),y({type:k("file_path"),file_id:m(),index:w().nullish()})]))}))}),y({type:k("web_search_call"),id:m(),status:m(),action:ke("type",[y({type:k("search"),query:m().nullish(),sources:x(ke("type",[y({type:k("url"),url:m()}),y({type:k("api"),name:m()})])).nullish()}),y({type:k("open_page"),url:m()}),y({type:k("find"),url:m(),pattern:m()})])}),y({type:k("file_search_call"),id:m(),queries:x(m()),results:x(y({attributes:he(m(),Y([m(),w(),Ae()])),file_id:m(),filename:m(),score:w(),text:m()})).nullish()}),y({type:k("code_interpreter_call"),id:m(),code:m().nullable(),container_id:m(),outputs:x(ke("type",[y({type:k("logs"),logs:m()}),y({type:k("image"),url:m()})])).nullable()}),y({type:k("image_generation_call"),id:m(),result:m()}),y({type:k("local_shell_call"),id:m(),call_id:m(),action:y({type:k("exec"),command:x(m()),timeout_ms:w().optional(),user:m().optional(),working_directory:m().optional(),env:he(m(),m()).optional()})}),y({type:k("function_call"),call_id:m(),name:m(),arguments:m(),id:m()}),y({type:k("computer_call"),id:m(),status:m().optional()}),y({type:k("reasoning"),id:m(),encrypted_content:m().nullish(),summary:x(y({type:k("summary_text"),text:m()}))})])).optional(),service_tier:m().nullish(),incomplete_details:y({reason:m()}).nullish(),usage:y({input_tokens:w(),input_tokens_details:y({cached_tokens:w().nullish()}).nullish(),output_tokens:w(),output_tokens_details:y({reasoning_tokens:w().nullish()}).nullish()}).optional()}))),sp=20,RC=ge(()=>Z(y({conversation:m().nullish(),include:x(se(["reasoning.encrypted_content","file_search_call.results","message.output_text.logprobs"])).nullish(),instructions:m().nullish(),logprobs:Y([Ae(),w().min(1).max(sp)]).optional(),maxToolCalls:w().nullish(),metadata:Me().nullish(),parallelToolCalls:Ae().nullish(),previousResponseId:m().nullish(),promptCacheKey:m().nullish(),promptCacheRetention:se(["in_memory","24h"]).nullish(),reasoningEffort:m().nullish(),reasoningSummary:m().nullish(),safetyIdentifier:m().nullish(),serviceTier:se(["auto","flex","priority","default"]).nullish(),store:Ae().nullish(),strictJsonSchema:Ae().nullish(),textVerbosity:se(["low","medium","high"]).nullish(),truncation:se(["auto","disabled"]).nullish(),user:m().nullish()})));async function PC({tools:e,toolChoice:t,strictJsonSchema:n}){e=e?.length?e:void 0;const r=[];if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:r};const s=[];for(const o of e)switch(o.type){case"function":s.push({type:"function",name:o.name,description:o.description,parameters:o.inputSchema,strict:n});break;case"provider-defined":{switch(o.id){case"openai.file_search":{const u=await pt({value:o.args,schema:pC});s.push({type:"file_search",vector_store_ids:u.vectorStoreIds,max_num_results:u.maxNumResults,ranking_options:u.ranking?{ranker:u.ranking.ranker,score_threshold:u.ranking.scoreThreshold}:void 0,filters:u.filters});break}case"openai.local_shell":{s.push({type:"local_shell"});break}case"openai.web_search_preview":{const u=await pt({value:o.args,schema:AC});s.push({type:"web_search_preview",search_context_size:u.searchContextSize,user_location:u.userLocation});break}case"openai.web_search":{const u=await pt({value:o.args,schema:FC});s.push({type:"web_search",filters:u.filters!=null?{allowed_domains:u.filters.allowedDomains}:void 0,external_web_access:u.externalWebAccess,search_context_size:u.searchContextSize,user_location:u.userLocation});break}case"openai.code_interpreter":{const u=await pt({value:o.args,schema:lC});s.push({type:"code_interpreter",container:u.container==null?{type:"auto",file_ids:void 0}:typeof u.container=="string"?u.container:{type:"auto",file_ids:u.container.fileIds}});break}case"openai.image_generation":{const u=await pt({value:o.args,schema:mC});s.push({type:"image_generation",background:u.background,input_fidelity:u.inputFidelity,input_image_mask:u.inputImageMask?{file_id:u.inputImageMask.fileId,image_url:u.inputImageMask.imageUrl}:void 0,model:u.model,size:u.size,quality:u.quality,moderation:u.moderation,output_format:u.outputFormat,output_compression:u.outputCompression});break}}break}default:r.push({type:"unsupported-tool",tool:o});break}if(t==null)return{tools:s,toolChoice:void 0,toolWarnings:r};const i=t.type;switch(i){case"auto":case"none":case"required":return{tools:s,toolChoice:i,toolWarnings:r};case"tool":return{tools:s,toolChoice:t.toolName==="code_interpreter"||t.toolName==="file_search"||t.toolName==="image_generation"||t.toolName==="web_search_preview"||t.toolName==="web_search"?{type:t.toolName}:{type:"function",name:t.toolName},toolWarnings:r};default:{const o=i;throw new Ne({functionality:`tool choice type: ${o}`})}}}a(PC,"prepareResponsesTools");var NC=(xn=class{constructor(t,n){this.specificationVersion="v2",this.supportedUrls={"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]},this.modelId=t,this.config=n}get provider(){return this.config.provider}async getArgs({maxOutputTokens:t,temperature:n,stopSequences:r,topP:s,topK:i,presencePenalty:o,frequencyPenalty:u,seed:l,prompt:c,providerOptions:d,tools:p,toolChoice:h,responseFormat:f}){var D,g,v,F;const C=[],_=WC(this.modelId);i!=null&&C.push({type:"unsupported-setting",setting:"topK"}),l!=null&&C.push({type:"unsupported-setting",setting:"seed"}),o!=null&&C.push({type:"unsupported-setting",setting:"presencePenalty"}),u!=null&&C.push({type:"unsupported-setting",setting:"frequencyPenalty"}),r!=null&&C.push({type:"unsupported-setting",setting:"stopSequences"});const b=await ze({provider:"openai",providerOptions:d,schema:RC});b?.conversation&&b?.previousResponseId&&C.push({type:"unsupported-setting",setting:"conversation",details:"conversation and previousResponseId cannot be used together"});const{input:B,warnings:O}=await BC({prompt:c,systemMessageMode:_.systemMessageMode,fileIdPrefixes:this.config.fileIdPrefixes,store:(D=b?.store)!=null?D:!0,hasLocalShellTool:z("openai.local_shell")});C.push(...O);const S=(g=b?.strictJsonSchema)!=null?g:!1;let $=b?.include;function G(U){$==null?$=[U]:$.includes(U)||($=[...$,U])}a(G,"addInclude");function z(U){return p?.find(M=>M.type==="provider-defined"&&M.id===U)!=null}a(z,"hasOpenAITool");const J=typeof b?.logprobs=="number"?b?.logprobs:b?.logprobs===!0?sp:void 0;J&&G("message.output_text.logprobs");const L=(v=p?.find(U=>U.type==="provider-defined"&&(U.id==="openai.web_search"||U.id==="openai.web_search_preview")))==null?void 0:v.name;L&&G("web_search_call.action.sources"),z("openai.code_interpreter")&&G("code_interpreter_call.outputs");const le=b?.store;le===!1&&_.isReasoningModel&&G("reasoning.encrypted_content");const W={model:this.modelId,input:B,temperature:n,top_p:s,max_output_tokens:t,...(f?.type==="json"||b?.textVerbosity)&&{text:{...f?.type==="json"&&{format:f.schema!=null?{type:"json_schema",strict:S,name:(F=f.name)!=null?F:"response",description:f.description,schema:f.schema}:{type:"json_object"}},...b?.textVerbosity&&{verbosity:b.textVerbosity}}},conversation:b?.conversation,max_tool_calls:b?.maxToolCalls,metadata:b?.metadata,parallel_tool_calls:b?.parallelToolCalls,previous_response_id:b?.previousResponseId,store:le,user:b?.user,instructions:b?.instructions,service_tier:b?.serviceTier,include:$,prompt_cache_key:b?.promptCacheKey,prompt_cache_retention:b?.promptCacheRetention,safety_identifier:b?.safetyIdentifier,top_logprobs:J,truncation:b?.truncation,..._.isReasoningModel&&(b?.reasoningEffort!=null||b?.reasoningSummary!=null)&&{reasoning:{...b?.reasoningEffort!=null&&{effort:b.reasoningEffort},...b?.reasoningSummary!=null&&{summary:b.reasoningSummary}}}};_.isReasoningModel?(W.temperature!=null&&(W.temperature=void 0,C.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for reasoning models"})),W.top_p!=null&&(W.top_p=void 0,C.push({type:"unsupported-setting",setting:"topP",details:"topP is not supported for reasoning models"}))):(b?.reasoningEffort!=null&&C.push({type:"unsupported-setting",setting:"reasoningEffort",details:"reasoningEffort is not supported for non-reasoning models"}),b?.reasoningSummary!=null&&C.push({type:"unsupported-setting",setting:"reasoningSummary",details:"reasoningSummary is not supported for non-reasoning models"})),b?.serviceTier==="flex"&&!_.supportsFlexProcessing&&(C.push({type:"unsupported-setting",setting:"serviceTier",details:"flex processing is only available for o3, o4-mini, and gpt-5 models"}),delete W.service_tier),b?.serviceTier==="priority"&&!_.supportsPriorityProcessing&&(C.push({type:"unsupported-setting",setting:"serviceTier",details:"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"}),delete W.service_tier);const{tools:ee,toolChoice:te,toolWarnings:R}=await PC({tools:p,toolChoice:h,strictJsonSchema:S});return{webSearchToolName:L,args:{...W,tools:ee,tool_choice:te},warnings:[...C,...R],store:le}}async doGenerate(t){var n,r,s,i,o,u,l,c,d,p,h,f,D,g,v,F,C,_,b;const{args:B,warnings:O,webSearchToolName:S}=await this.getArgs(t),$=this.config.url({path:"/responses",modelId:this.modelId}),{responseHeaders:G,value:z,rawValue:J}=await Ee({url:$,headers:ye(this.config.headers(),t.headers),body:B,failedResponseHandler:nt,successfulResponseHandler:Te(OC),abortSignal:t.abortSignal,fetch:this.config.fetch});if(z.error)throw new Ce({message:z.error.message,url:$,requestBodyValues:B,statusCode:400,responseHeaders:G,responseBody:J,isRetryable:!1});const L=[],le=[];let W=!1;for(const R of z.output)switch(R.type){case"reasoning":{R.summary.length===0&&R.summary.push({type:"summary_text",text:""});for(const U of R.summary)L.push({type:"reasoning",text:U.text,providerMetadata:{openai:{itemId:R.id,reasoningEncryptedContent:(n=R.encrypted_content)!=null?n:null}}});break}case"image_generation_call":{L.push({type:"tool-call",toolCallId:R.id,toolName:"image_generation",input:"{}",providerExecuted:!0}),L.push({type:"tool-result",toolCallId:R.id,toolName:"image_generation",result:{result:R.result},providerExecuted:!0});break}case"local_shell_call":{L.push({type:"tool-call",toolCallId:R.call_id,toolName:"local_shell",input:JSON.stringify({action:R.action}),providerMetadata:{openai:{itemId:R.id}}});break}case"message":{for(const U of R.content){(s=(r=t.providerOptions)==null?void 0:r.openai)!=null&&s.logprobs&&U.logprobs&&le.push(U.logprobs),L.push({type:"text",text:U.text,providerMetadata:{openai:{itemId:R.id}}});for(const M of U.annotations)M.type==="url_citation"?L.push({type:"source",sourceType:"url",id:(u=(o=(i=this.config).generateId)==null?void 0:o.call(i))!=null?u:je(),url:M.url,title:M.title}):M.type==="file_citation"&&L.push({type:"source",sourceType:"document",id:(d=(c=(l=this.config).generateId)==null?void 0:c.call(l))!=null?d:je(),mediaType:"text/plain",title:(h=(p=M.quote)!=null?p:M.filename)!=null?h:"Document",filename:(f=M.filename)!=null?f:M.file_id,...M.file_id?{providerMetadata:{openai:{fileId:M.file_id}}}:{}})}break}case"function_call":{W=!0,L.push({type:"tool-call",toolCallId:R.call_id,toolName:R.name,input:R.arguments,providerMetadata:{openai:{itemId:R.id}}});break}case"web_search_call":{L.push({type:"tool-call",toolCallId:R.id,toolName:S??"web_search",input:JSON.stringify({}),providerExecuted:!0}),L.push({type:"tool-result",toolCallId:R.id,toolName:S??"web_search",result:ap(R.action),providerExecuted:!0});break}case"computer_call":{L.push({type:"tool-call",toolCallId:R.id,toolName:"computer_use",input:"",providerExecuted:!0}),L.push({type:"tool-result",toolCallId:R.id,toolName:"computer_use",result:{type:"computer_use_tool_result",status:R.status||"completed"},providerExecuted:!0});break}case"file_search_call":{L.push({type:"tool-call",toolCallId:R.id,toolName:"file_search",input:"{}",providerExecuted:!0}),L.push({type:"tool-result",toolCallId:R.id,toolName:"file_search",result:{queries:R.queries,results:(g=(D=R.results)==null?void 0:D.map(U=>({attributes:U.attributes,fileId:U.file_id,filename:U.filename,score:U.score,text:U.text})))!=null?g:null},providerExecuted:!0});break}case"code_interpreter_call":{L.push({type:"tool-call",toolCallId:R.id,toolName:"code_interpreter",input:JSON.stringify({code:R.code,containerId:R.container_id}),providerExecuted:!0}),L.push({type:"tool-result",toolCallId:R.id,toolName:"code_interpreter",result:{outputs:R.outputs},providerExecuted:!0});break}}const ee={openai:{...z.id!=null?{responseId:z.id}:{}}};le.length>0&&(ee.openai.logprobs=le),typeof z.service_tier=="string"&&(ee.openai.serviceTier=z.service_tier);const te=z.usage;return{content:L,finishReason:op({finishReason:(v=z.incomplete_details)==null?void 0:v.reason,hasFunctionCall:W}),usage:{inputTokens:te.input_tokens,outputTokens:te.output_tokens,totalTokens:te.input_tokens+te.output_tokens,reasoningTokens:(C=(F=te.output_tokens_details)==null?void 0:F.reasoning_tokens)!=null?C:void 0,cachedInputTokens:(b=(_=te.input_tokens_details)==null?void 0:_.cached_tokens)!=null?b:void 0},request:{body:B},response:{id:z.id,timestamp:new Date(z.created_at*1e3),modelId:z.model,headers:G,body:J},providerMetadata:ee,warnings:O}}async doStream(t){const{args:n,warnings:r,webSearchToolName:s,store:i}=await this.getArgs(t),{responseHeaders:o,value:u}=await Ee({url:this.config.url({path:"/responses",modelId:this.modelId}),headers:ye(this.config.headers(),t.headers),body:{...n,stream:!0},failedResponseHandler:nt,successfulResponseHandler:Lt(TC),abortSignal:t.abortSignal,fetch:this.config.fetch}),l=this;let c="unknown";const d={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},p=[];let h=null;const f={},D=[];let g=!1;const v={};let F;return{stream:u.pipeThrough(new TransformStream({start(C){C.enqueue({type:"stream-start",warnings:r})},transform(C,_){var b,B,O,S,$,G,z,J,L,le,W,ee,te,R,U,M,xe,ce,ne,q,Be,qe;if(t.includeRawChunks&&_.enqueue({type:"raw",rawValue:C.rawValue}),!C.success){c="error",_.enqueue({type:"error",error:C.error});return}const E=C.value;if(ip(E))E.item.type==="function_call"?(f[E.output_index]={toolName:E.item.name,toolCallId:E.item.call_id},_.enqueue({type:"tool-input-start",id:E.item.call_id,toolName:E.item.name})):E.item.type==="web_search_call"?(f[E.output_index]={toolName:s??"web_search",toolCallId:E.item.id},_.enqueue({type:"tool-input-start",id:E.item.id,toolName:s??"web_search",providerExecuted:!0}),_.enqueue({type:"tool-input-end",id:E.item.id}),_.enqueue({type:"tool-call",toolCallId:E.item.id,toolName:s??"web_search",input:JSON.stringify({}),providerExecuted:!0})):E.item.type==="computer_call"?(f[E.output_index]={toolName:"computer_use",toolCallId:E.item.id},_.enqueue({type:"tool-input-start",id:E.item.id,toolName:"computer_use",providerExecuted:!0})):E.item.type==="code_interpreter_call"?(f[E.output_index]={toolName:"code_interpreter",toolCallId:E.item.id,codeInterpreter:{containerId:E.item.container_id}},_.enqueue({type:"tool-input-start",id:E.item.id,toolName:"code_interpreter",providerExecuted:!0}),_.enqueue({type:"tool-input-delta",id:E.item.id,delta:`{"containerId":"${E.item.container_id}","code":"`})):E.item.type==="file_search_call"?_.enqueue({type:"tool-call",toolCallId:E.item.id,toolName:"file_search",input:"{}",providerExecuted:!0}):E.item.type==="image_generation_call"?_.enqueue({type:"tool-call",toolCallId:E.item.id,toolName:"image_generation",input:"{}",providerExecuted:!0}):E.item.type==="message"?(D.splice(0,D.length),_.enqueue({type:"text-start",id:E.item.id,providerMetadata:{openai:{itemId:E.item.id}}})):ip(E)&&E.item.type==="reasoning"&&(v[E.item.id]={encryptedContent:E.item.encrypted_content,summaryParts:{0:"active"}},_.enqueue({type:"reasoning-start",id:`${E.item.id}:0`,providerMetadata:{openai:{itemId:E.item.id,reasoningEncryptedContent:(b=E.item.encrypted_content)!=null?b:null}}}));else if(jC(E)){if(E.item.type==="message")_.enqueue({type:"text-end",id:E.item.id,providerMetadata:{openai:{itemId:E.item.id,...D.length>0&&{annotations:D}}}});else if(E.item.type==="function_call")f[E.output_index]=void 0,g=!0,_.enqueue({type:"tool-input-end",id:E.item.call_id}),_.enqueue({type:"tool-call",toolCallId:E.item.call_id,toolName:E.item.name,input:E.item.arguments,providerMetadata:{openai:{itemId:E.item.id}}});else if(E.item.type==="web_search_call")f[E.output_index]=void 0,_.enqueue({type:"tool-result",toolCallId:E.item.id,toolName:s??"web_search",result:ap(E.item.action),providerExecuted:!0});else if(E.item.type==="computer_call")f[E.output_index]=void 0,_.enqueue({type:"tool-input-end",id:E.item.id}),_.enqueue({type:"tool-call",toolCallId:E.item.id,toolName:"computer_use",input:"",providerExecuted:!0}),_.enqueue({type:"tool-result",toolCallId:E.item.id,toolName:"computer_use",result:{type:"computer_use_tool_result",status:E.item.status||"completed"},providerExecuted:!0});else if(E.item.type==="file_search_call")f[E.output_index]=void 0,_.enqueue({type:"tool-result",toolCallId:E.item.id,toolName:"file_search",result:{queries:E.item.queries,results:(O=(B=E.item.results)==null?void 0:B.map(V=>({attributes:V.attributes,fileId:V.file_id,filename:V.filename,score:V.score,text:V.text})))!=null?O:null},providerExecuted:!0});else if(E.item.type==="code_interpreter_call")f[E.output_index]=void 0,_.enqueue({type:"tool-result",toolCallId:E.item.id,toolName:"code_interpreter",result:{outputs:E.item.outputs},providerExecuted:!0});else if(E.item.type==="image_generation_call")_.enqueue({type:"tool-result",toolCallId:E.item.id,toolName:"image_generation",result:{result:E.item.result},providerExecuted:!0});else if(E.item.type==="local_shell_call")f[E.output_index]=void 0,_.enqueue({type:"tool-call",toolCallId:E.item.call_id,toolName:"local_shell",input:JSON.stringify({action:{type:"exec",command:E.item.action.command,timeoutMs:E.item.action.timeout_ms,user:E.item.action.user,workingDirectory:E.item.action.working_directory,env:E.item.action.env}}),providerMetadata:{openai:{itemId:E.item.id}}});else if(E.item.type==="reasoning"){const V=v[E.item.id],de=Object.entries(V.summaryParts).filter(([ve,Je])=>Je==="active"||Je==="can-conclude").map(([ve])=>ve);for(const ve of de)_.enqueue({type:"reasoning-end",id:`${E.item.id}:${ve}`,providerMetadata:{openai:{itemId:E.item.id,reasoningEncryptedContent:(S=E.item.encrypted_content)!=null?S:null}}});delete v[E.item.id]}}else if(LC(E)){const V=f[E.output_index];V!=null&&_.enqueue({type:"tool-input-delta",id:V.toolCallId,delta:E.delta})}else if(UC(E)){const V=f[E.output_index];V!=null&&_.enqueue({type:"tool-input-delta",id:V.toolCallId,delta:JSON.stringify(E.delta).slice(1,-1)})}else if(qC(E)){const V=f[E.output_index];V!=null&&(_.enqueue({type:"tool-input-delta",id:V.toolCallId,delta:'"}'}),_.enqueue({type:"tool-input-end",id:V.toolCallId}),_.enqueue({type:"tool-call",toolCallId:V.toolCallId,toolName:"code_interpreter",input:JSON.stringify({code:E.code,containerId:V.codeInterpreter.containerId}),providerExecuted:!0}))}else if(ZC(E))h=E.response.id,_.enqueue({type:"response-metadata",id:E.response.id,timestamp:new Date(E.response.created_at*1e3),modelId:E.response.model});else if(MC(E))_.enqueue({type:"text-delta",id:E.item_id,delta:E.delta}),(G=($=t.providerOptions)==null?void 0:$.openai)!=null&&G.logprobs&&E.logprobs&&p.push(E.logprobs);else if(E.type==="response.reasoning_summary_part.added"){if(E.summary_index>0){const V=v[E.item_id];V.summaryParts[E.summary_index]="active";for(const de of Object.keys(V.summaryParts))V.summaryParts[de]==="can-conclude"&&(_.enqueue({type:"reasoning-end",id:`${E.item_id}:${de}`,providerMetadata:{openai:{itemId:E.item_id}}}),V.summaryParts[de]="concluded");_.enqueue({type:"reasoning-start",id:`${E.item_id}:${E.summary_index}`,providerMetadata:{openai:{itemId:E.item_id,reasoningEncryptedContent:(J=(z=v[E.item_id])==null?void 0:z.encryptedContent)!=null?J:null}}})}}else E.type==="response.reasoning_summary_text.delta"?_.enqueue({type:"reasoning-delta",id:`${E.item_id}:${E.summary_index}`,delta:E.delta,providerMetadata:{openai:{itemId:E.item_id}}}):E.type==="response.reasoning_summary_part.done"?i?(_.enqueue({type:"reasoning-end",id:`${E.item_id}:${E.summary_index}`,providerMetadata:{openai:{itemId:E.item_id}}}),v[E.item_id].summaryParts[E.summary_index]="concluded"):v[E.item_id].summaryParts[E.summary_index]="can-conclude":zC(E)?(c=op({finishReason:(L=E.response.incomplete_details)==null?void 0:L.reason,hasFunctionCall:g}),d.inputTokens=E.response.usage.input_tokens,d.outputTokens=E.response.usage.output_tokens,d.totalTokens=E.response.usage.input_tokens+E.response.usage.output_tokens,d.reasoningTokens=(W=(le=E.response.usage.output_tokens_details)==null?void 0:le.reasoning_tokens)!=null?W:void 0,d.cachedInputTokens=(te=(ee=E.response.usage.input_tokens_details)==null?void 0:ee.cached_tokens)!=null?te:void 0,typeof E.response.service_tier=="string"&&(F=E.response.service_tier)):VC(E)?(D.push(E.annotation),E.annotation.type==="url_citation"?_.enqueue({type:"source",sourceType:"url",id:(M=(U=(R=l.config).generateId)==null?void 0:U.call(R))!=null?M:je(),url:E.annotation.url,title:E.annotation.title}):E.annotation.type==="file_citation"&&_.enqueue({type:"source",sourceType:"document",id:(ne=(ce=(xe=l.config).generateId)==null?void 0:ce.call(xe))!=null?ne:je(),mediaType:"text/plain",title:(Be=(q=E.annotation.quote)!=null?q:E.annotation.filename)!=null?Be:"Document",filename:(qe=E.annotation.filename)!=null?qe:E.annotation.file_id,...E.annotation.file_id?{providerMetadata:{openai:{fileId:E.annotation.file_id}}}:{}})):GC(E)&&_.enqueue({type:"error",error:E})},flush(C){const _={openai:{responseId:h}};p.length>0&&(_.openai.logprobs=p),F!==void 0&&(_.openai.serviceTier=F),C.enqueue({type:"finish",finishReason:c,usage:d,providerMetadata:_})}})),request:{body:n},response:{headers:o}}}},a(xn,"OpenAIResponsesLanguageModel"),xn);function MC(e){return e.type==="response.output_text.delta"}a(MC,"isTextDeltaChunk");function jC(e){return e.type==="response.output_item.done"}a(jC,"isResponseOutputItemDoneChunk");function zC(e){return e.type==="response.completed"||e.type==="response.incomplete"}a(zC,"isResponseFinishedChunk");function ZC(e){return e.type==="response.created"}a(ZC,"isResponseCreatedChunk");function LC(e){return e.type==="response.function_call_arguments.delta"}a(LC,"isResponseFunctionCallArgumentsDeltaChunk");function UC(e){return e.type==="response.code_interpreter_call_code.delta"}a(UC,"isResponseCodeInterpreterCallCodeDeltaChunk");function qC(e){return e.type==="response.code_interpreter_call_code.done"}a(qC,"isResponseCodeInterpreterCallCodeDoneChunk");function ip(e){return e.type==="response.output_item.added"}a(ip,"isResponseOutputItemAddedChunk");function VC(e){return e.type==="response.output_text.annotation.added"}a(VC,"isResponseAnnotationAddedChunk");function GC(e){return e.type==="error"}a(GC,"isErrorChunk");function WC(e){const t=e.startsWith("o3")||e.startsWith("o4-mini")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-chat"),n=e.startsWith("gpt-4")||e.startsWith("gpt-5-mini")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-nano")&&!e.startsWith("gpt-5-chat")||e.startsWith("o3")||e.startsWith("o4-mini"),r={systemMessageMode:"system",supportsFlexProcessing:t,supportsPriorityProcessing:n};return e.startsWith("gpt-5-chat")?{...r,isReasoningModel:!1}:e.startsWith("o")||e.startsWith("gpt-5")||e.startsWith("codex-")||e.startsWith("computer-use")?{...r,isReasoningModel:!0,systemMessageMode:"developer"}:{...r,isReasoningModel:!1}}a(WC,"getResponsesModelConfig");function ap(e){var t;switch(e.type){case"search":return{action:{type:"search",query:(t=e.query)!=null?t:void 0},...e.sources!=null&&{sources:e.sources}};case"open_page":return{action:{type:"openPage",url:e.url}};case"find":return{action:{type:"find",url:e.url,pattern:e.pattern}}}}a(ap,"mapWebSearchOutput");var HC=ge(()=>Z(y({instructions:m().nullish(),speed:w().min(.25).max(4).default(1).nullish()}))),JC=(In=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2"}get provider(){return this.config.provider}async getArgs({text:t,voice:n="alloy",outputFormat:r="mp3",speed:s,instructions:i,language:o,providerOptions:u}){const l=[],c=await ze({provider:"openai",providerOptions:u,schema:HC}),d={model:this.modelId,input:t,voice:n,response_format:"mp3",speed:s,instructions:i};if(r&&(["mp3","opus","aac","flac","wav","pcm"].includes(r)?d.response_format=r:l.push({type:"unsupported-setting",setting:"outputFormat",details:`Unsupported output format: ${r}. Using mp3 instead.`})),c){const p={};for(const h in p){const f=p[h];f!==void 0&&(d[h]=f)}}return o&&l.push({type:"unsupported-setting",setting:"language",details:`OpenAI speech models do not support language selection. Language parameter "${o}" was ignored.`}),{requestBody:d,warnings:l}}async doGenerate(t){var n,r,s;const i=(s=(r=(n=this.config._internal)==null?void 0:n.currentDate)==null?void 0:r.call(n))!=null?s:new Date,{requestBody:o,warnings:u}=await this.getArgs(t),{value:l,responseHeaders:c,rawValue:d}=await Ee({url:this.config.url({path:"/audio/speech",modelId:this.modelId}),headers:ye(this.config.headers(),t.headers),body:o,failedResponseHandler:nt,successfulResponseHandler:h_(),abortSignal:t.abortSignal,fetch:this.config.fetch});return{audio:l,warnings:u,request:{body:JSON.stringify(o)},response:{timestamp:i,modelId:this.modelId,headers:c,body:d}}}},a(In,"OpenAISpeechModel"),In),KC=ge(()=>Z(y({text:m(),language:m().nullish(),duration:w().nullish(),words:x(y({word:m(),start:w(),end:w()})).nullish(),segments:x(y({id:w(),seek:w(),start:w(),end:w(),text:m(),tokens:x(w()),temperature:w(),avg_logprob:w(),compression_ratio:w(),no_speech_prob:w()})).nullish()}))),YC=ge(()=>Z(y({include:x(m()).optional(),language:m().optional(),prompt:m().optional(),temperature:w().min(0).max(1).default(0).optional(),timestampGranularities:x(se(["word","segment"])).default(["segment"]).optional()}))),up={afrikaans:"af",arabic:"ar",armenian:"hy",azerbaijani:"az",belarusian:"be",bosnian:"bs",bulgarian:"bg",catalan:"ca",chinese:"zh",croatian:"hr",czech:"cs",danish:"da",dutch:"nl",english:"en",estonian:"et",finnish:"fi",french:"fr",galician:"gl",german:"de",greek:"el",hebrew:"he",hindi:"hi",hungarian:"hu",icelandic:"is",indonesian:"id",italian:"it",japanese:"ja",kannada:"kn",kazakh:"kk",korean:"ko",latvian:"lv",lithuanian:"lt",macedonian:"mk",malay:"ms",marathi:"mr",maori:"mi",nepali:"ne",norwegian:"no",persian:"fa",polish:"pl",portuguese:"pt",romanian:"ro",russian:"ru",serbian:"sr",slovak:"sk",slovenian:"sl",spanish:"es",swahili:"sw",swedish:"sv",tagalog:"tl",tamil:"ta",thai:"th",turkish:"tr",ukrainian:"uk",urdu:"ur",vietnamese:"vi",welsh:"cy"},XC=($n=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2"}get provider(){return this.config.provider}async getArgs({audio:t,mediaType:n,providerOptions:r}){const s=[],i=await ze({provider:"openai",providerOptions:r,schema:YC}),o=new FormData,u=t instanceof Uint8Array?new Blob([t]):new Blob([Hr(t)]);o.append("model",this.modelId);const l=o_(n);if(o.append("file",new File([u],"audio",{type:n}),`audio.${l}`),i){const c={include:i.include,language:i.language,prompt:i.prompt,response_format:["gpt-4o-transcribe","gpt-4o-mini-transcribe"].includes(this.modelId)?"json":"verbose_json",temperature:i.temperature,timestamp_granularities:i.timestampGranularities};for(const[d,p]of Object.entries(c))if(p!=null)if(Array.isArray(p))for(const h of p)o.append(`${d}[]`,String(h));else o.append(d,String(p))}return{formData:o,warnings:s}}async doGenerate(t){var n,r,s,i,o,u,l,c;const d=(s=(r=(n=this.config._internal)==null?void 0:n.currentDate)==null?void 0:r.call(n))!=null?s:new Date,{formData:p,warnings:h}=await this.getArgs(t),{value:f,responseHeaders:D,rawValue:g}=await m_({url:this.config.url({path:"/audio/transcriptions",modelId:this.modelId}),headers:ye(this.config.headers(),t.headers),formData:p,failedResponseHandler:nt,successfulResponseHandler:Te(KC),abortSignal:t.abortSignal,fetch:this.config.fetch}),v=f.language!=null&&f.language in up?up[f.language]:void 0;return{text:f.text,segments:(l=(u=(i=f.segments)==null?void 0:i.map(F=>({text:F.text,startSecond:F.start,endSecond:F.end})))!=null?u:(o=f.words)==null?void 0:o.map(F=>({text:F.word,startSecond:F.start,endSecond:F.end})))!=null?l:[],language:v,durationInSeconds:(c=f.duration)!=null?c:void 0,warnings:h,response:{timestamp:d,modelId:this.modelId,headers:D,body:g}}}},a($n,"OpenAITranscriptionModel"),$n),QC="2.0.74";function lp(e={}){var t,n;const r=(t=Bs(nr({settingValue:e.baseURL,environmentVariableName:"OPENAI_BASE_URL"})))!=null?t:"https://api.openai.com/v1",s=(n=e.name)!=null?n:"openai",i=a(()=>wt({Authorization:`Bearer ${r_({apiKey:e.apiKey,environmentVariableName:"OPENAI_API_KEY",description:"OpenAI"})}`,"OpenAI-Organization":e.organization,"OpenAI-Project":e.project,...e.headers},`ai-sdk/openai/${QC}`),"getHeaders"),o=a(g=>new VE(g,{provider:`${s}.chat`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createChatModel"),u=a(g=>new QE(g,{provider:`${s}.completion`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createCompletionModel"),l=a(g=>new nC(g,{provider:`${s}.embedding`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createEmbeddingModel"),c=a(g=>new iC(g,{provider:`${s}.image`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createImageModel"),d=a(g=>new XC(g,{provider:`${s}.transcription`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createTranscriptionModel"),p=a(g=>new JC(g,{provider:`${s}.speech`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createSpeechModel"),h=a(g=>{if(new.target)throw new Error("The OpenAI model function cannot be called with the new keyword.");return f(g)},"createLanguageModel"),f=a(g=>new NC(g,{provider:`${s}.responses`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch,fileIdPrefixes:["file-"]}),"createResponsesModel"),D=a(function(g){return h(g)},"provider");return D.languageModel=h,D.chat=o,D.completion=u,D.responses=f,D.embedding=l,D.textEmbedding=l,D.textEmbeddingModel=l,D.image=c,D.imageModel=c,D.transcription=d,D.transcriptionModel=d,D.speech=p,D.speechModel=p,D.tools=$C,D}a(lp,"createOpenAI"),lp();function cr(e){var t,n;return(n=(t=e?.providerOptions)==null?void 0:t.openaiCompatible)!=null?n:{}}a(cr,"getOpenAIMetadata");function eb(e){const t=[];for(const{role:n,content:r,...s}of e){const i=cr({...s});switch(n){case"system":{t.push({role:"system",content:r,...i});break}case"user":{if(r.length===1&&r[0].type==="text"){t.push({role:"user",content:r[0].text,...cr(r[0])});break}t.push({role:"user",content:r.map(o=>{const u=cr(o);switch(o.type){case"text":return{type:"text",text:o.text,...u};case"file":if(o.mediaType.startsWith("image/")){const l=o.mediaType==="image/*"?"image/jpeg":o.mediaType;return{type:"image_url",image_url:{url:o.data instanceof URL?o.data.toString():`data:${l};base64,${kt(o.data)}`},...u}}else throw new Ne({functionality:`file part media type ${o.mediaType}`})}}),...i});break}case"assistant":{let o="";const u=[];for(const l of r){const c=cr(l);switch(l.type){case"text":{o+=l.text;break}case"tool-call":{u.push({id:l.toolCallId,type:"function",function:{name:l.toolName,arguments:JSON.stringify(l.input)},...c});break}}}t.push({role:"assistant",content:o,tool_calls:u.length>0?u:void 0,...i});break}case"tool":{for(const o of r){const u=o.output;let l;switch(u.type){case"text":case"error-text":l=u.value;break;case"content":case"json":case"error-json":l=JSON.stringify(u.value);break}const c=cr(o);t.push({role:"tool",tool_call_id:o.toolCallId,content:l,...c})}break}default:{const o=n;throw new Error(`Unsupported role: ${o}`)}}}return t}a(eb,"convertToOpenAICompatibleChatMessages");function cp({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n!=null?new Date(n*1e3):void 0}}a(cp,"getResponseMetadata");function dp(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}a(dp,"mapOpenAICompatibleFinishReason");var ei=y({user:m().optional(),reasoningEffort:m().optional(),textVerbosity:m().optional()}),tb=y({error:y({message:m(),type:m().nullish(),param:Me().nullish(),code:Y([m(),w()]).nullish()})}),Qr={errorSchema:tb,errorToMessage:a(e=>e.error.message,"errorToMessage")};function nb({tools:e,toolChoice:t}){e=e?.length?e:void 0;const n=[];if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:n};const r=[];for(const i of e)i.type==="provider-defined"?n.push({type:"unsupported-tool",tool:i}):r.push({type:"function",function:{name:i.name,description:i.description,parameters:i.inputSchema}});if(t==null)return{tools:r,toolChoice:void 0,toolWarnings:n};const s=t.type;switch(s){case"auto":case"none":case"required":return{tools:r,toolChoice:s,toolWarnings:n};case"tool":return{tools:r,toolChoice:{type:"function",function:{name:t.toolName}},toolWarnings:n};default:{const i=s;throw new Ne({functionality:`tool choice type: ${i}`})}}}a(nb,"prepareTools");var rb=(Bn=class{constructor(t,n){this.specificationVersion="v2";var r,s;this.modelId=t,this.config=n;const i=(r=n.errorStructure)!=null?r:Qr;this.chunkSchema=sb(i.errorSchema),this.failedResponseHandler=Ge(i),this.supportsStructuredOutputs=(s=n.supportsStructuredOutputs)!=null?s:!1}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get supportedUrls(){var t,n,r;return(r=(n=(t=this.config).supportedUrls)==null?void 0:n.call(t))!=null?r:{}}async getArgs({prompt:t,maxOutputTokens:n,temperature:r,topP:s,topK:i,frequencyPenalty:o,presencePenalty:u,providerOptions:l,stopSequences:c,responseFormat:d,seed:p,toolChoice:h,tools:f}){var D,g,v,F;const C=[],_=Object.assign((D=await ze({provider:"openai-compatible",providerOptions:l,schema:ei}))!=null?D:{},(g=await ze({provider:this.providerOptionsName,providerOptions:l,schema:ei}))!=null?g:{});i!=null&&C.push({type:"unsupported-setting",setting:"topK"}),d?.type==="json"&&d.schema!=null&&!this.supportsStructuredOutputs&&C.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});const{tools:b,toolChoice:B,toolWarnings:O}=nb({tools:f,toolChoice:h});return{args:{model:this.modelId,user:_.user,max_tokens:n,temperature:r,top_p:s,frequency_penalty:o,presence_penalty:u,response_format:d?.type==="json"?this.supportsStructuredOutputs===!0&&d.schema!=null?{type:"json_schema",json_schema:{schema:d.schema,name:(v=d.name)!=null?v:"response",description:d.description}}:{type:"json_object"}:void 0,stop:c,seed:p,...Object.fromEntries(Object.entries((F=l?.[this.providerOptionsName])!=null?F:{}).filter(([S])=>!Object.keys(ei.shape).includes(S))),reasoning_effort:_.reasoningEffort,verbosity:_.textVerbosity,messages:eb(t),tools:b,tool_choice:B},warnings:[...C,...O]}}async doGenerate(t){var n,r,s,i,o,u,l,c,d,p,h,f,D,g,v,F,C;const{args:_,warnings:b}=await this.getArgs({...t}),B=JSON.stringify(_),{responseHeaders:O,value:S,rawValue:$}=await Ee({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:ye(this.config.headers(),t.headers),body:_,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Te(ob),abortSignal:t.abortSignal,fetch:this.config.fetch}),G=S.choices[0],z=[],J=G.message.content;J!=null&&J.length>0&&z.push({type:"text",text:J});const L=(n=G.message.reasoning_content)!=null?n:G.message.reasoning;if(L!=null&&L.length>0&&z.push({type:"reasoning",text:L}),G.message.tool_calls!=null)for(const ee of G.message.tool_calls)z.push({type:"tool-call",toolCallId:(r=ee.id)!=null?r:je(),toolName:ee.function.name,input:ee.function.arguments});const le={[this.providerOptionsName]:{},...await((i=(s=this.config.metadataExtractor)==null?void 0:s.extractMetadata)==null?void 0:i.call(s,{parsedBody:$}))},W=(o=S.usage)==null?void 0:o.completion_tokens_details;return W?.accepted_prediction_tokens!=null&&(le[this.providerOptionsName].acceptedPredictionTokens=W?.accepted_prediction_tokens),W?.rejected_prediction_tokens!=null&&(le[this.providerOptionsName].rejectedPredictionTokens=W?.rejected_prediction_tokens),{content:z,finishReason:dp(G.finish_reason),usage:{inputTokens:(l=(u=S.usage)==null?void 0:u.prompt_tokens)!=null?l:void 0,outputTokens:(d=(c=S.usage)==null?void 0:c.completion_tokens)!=null?d:void 0,totalTokens:(h=(p=S.usage)==null?void 0:p.total_tokens)!=null?h:void 0,reasoningTokens:(g=(D=(f=S.usage)==null?void 0:f.completion_tokens_details)==null?void 0:D.reasoning_tokens)!=null?g:void 0,cachedInputTokens:(C=(F=(v=S.usage)==null?void 0:v.prompt_tokens_details)==null?void 0:F.cached_tokens)!=null?C:void 0},providerMetadata:le,request:{body:B},response:{...cp(S),headers:O,body:$},warnings:b}}async doStream(t){var n;const{args:r,warnings:s}=await this.getArgs({...t}),i={...r,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},o=(n=this.config.metadataExtractor)==null?void 0:n.createStreamExtractor(),{responseHeaders:u,value:l}=await Ee({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:ye(this.config.headers(),t.headers),body:i,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Lt(this.chunkSchema),abortSignal:t.abortSignal,fetch:this.config.fetch}),c=[];let d="unknown";const p={completionTokens:void 0,completionTokensDetails:{reasoningTokens:void 0,acceptedPredictionTokens:void 0,rejectedPredictionTokens:void 0},promptTokens:void 0,promptTokensDetails:{cachedTokens:void 0},totalTokens:void 0};let h=!0;const f=this.providerOptionsName;let D=!1,g=!1;return{stream:l.pipeThrough(new TransformStream({start(v){v.enqueue({type:"stream-start",warnings:s})},transform(v,F){var C,_,b,B,O,S,$,G,z,J,L,le,W;if(t.includeRawChunks&&F.enqueue({type:"raw",rawValue:v.rawValue}),!v.success){d="error",F.enqueue({type:"error",error:v.error});return}const ee=v.value;if(o?.processChunk(v.rawValue),"error"in ee){d="error",F.enqueue({type:"error",error:ee.error.message});return}if(h&&(h=!1,F.enqueue({type:"response-metadata",...cp(ee)})),ee.usage!=null){const{prompt_tokens:M,completion_tokens:xe,total_tokens:ce,prompt_tokens_details:ne,completion_tokens_details:q}=ee.usage;p.promptTokens=M??void 0,p.completionTokens=xe??void 0,p.totalTokens=ce??void 0,q?.reasoning_tokens!=null&&(p.completionTokensDetails.reasoningTokens=q?.reasoning_tokens),q?.accepted_prediction_tokens!=null&&(p.completionTokensDetails.acceptedPredictionTokens=q?.accepted_prediction_tokens),q?.rejected_prediction_tokens!=null&&(p.completionTokensDetails.rejectedPredictionTokens=q?.rejected_prediction_tokens),ne?.cached_tokens!=null&&(p.promptTokensDetails.cachedTokens=ne?.cached_tokens)}const te=ee.choices[0];if(te?.finish_reason!=null&&(d=dp(te.finish_reason)),te?.delta==null)return;const R=te.delta,U=(C=R.reasoning_content)!=null?C:R.reasoning;if(U&&(D||(F.enqueue({type:"reasoning-start",id:"reasoning-0"}),D=!0),F.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:U})),R.content&&(g||(F.enqueue({type:"text-start",id:"txt-0"}),g=!0),F.enqueue({type:"text-delta",id:"txt-0",delta:R.content})),R.tool_calls!=null)for(const M of R.tool_calls){const xe=M.index;if(c[xe]==null){if(M.id==null)throw new Wn({data:M,message:"Expected 'id' to be a string."});if(((_=M.function)==null?void 0:_.name)==null)throw new Wn({data:M,message:"Expected 'function.name' to be a string."});F.enqueue({type:"tool-input-start",id:M.id,toolName:M.function.name}),c[xe]={id:M.id,type:"function",function:{name:M.function.name,arguments:(b=M.function.arguments)!=null?b:""},hasFinished:!1};const ne=c[xe];((B=ne.function)==null?void 0:B.name)!=null&&((O=ne.function)==null?void 0:O.arguments)!=null&&(ne.function.arguments.length>0&&F.enqueue({type:"tool-input-delta",id:ne.id,delta:ne.function.arguments}),Gr(ne.function.arguments)&&(F.enqueue({type:"tool-input-end",id:ne.id}),F.enqueue({type:"tool-call",toolCallId:(S=ne.id)!=null?S:je(),toolName:ne.function.name,input:ne.function.arguments}),ne.hasFinished=!0));continue}const ce=c[xe];ce.hasFinished||((($=M.function)==null?void 0:$.arguments)!=null&&(ce.function.arguments+=(z=(G=M.function)==null?void 0:G.arguments)!=null?z:""),F.enqueue({type:"tool-input-delta",id:ce.id,delta:(J=M.function.arguments)!=null?J:""}),((L=ce.function)==null?void 0:L.name)!=null&&((le=ce.function)==null?void 0:le.arguments)!=null&&Gr(ce.function.arguments)&&(F.enqueue({type:"tool-input-end",id:ce.id}),F.enqueue({type:"tool-call",toolCallId:(W=ce.id)!=null?W:je(),toolName:ce.function.name,input:ce.function.arguments}),ce.hasFinished=!0))}},flush(v){var F,C,_,b,B,O;D&&v.enqueue({type:"reasoning-end",id:"reasoning-0"}),g&&v.enqueue({type:"text-end",id:"txt-0"});for(const $ of c.filter(G=>!G.hasFinished))v.enqueue({type:"tool-input-end",id:$.id}),v.enqueue({type:"tool-call",toolCallId:(F=$.id)!=null?F:je(),toolName:$.function.name,input:$.function.arguments});const S={[f]:{},...o?.buildMetadata()};p.completionTokensDetails.acceptedPredictionTokens!=null&&(S[f].acceptedPredictionTokens=p.completionTokensDetails.acceptedPredictionTokens),p.completionTokensDetails.rejectedPredictionTokens!=null&&(S[f].rejectedPredictionTokens=p.completionTokensDetails.rejectedPredictionTokens),v.enqueue({type:"finish",finishReason:d,usage:{inputTokens:(C=p.promptTokens)!=null?C:void 0,outputTokens:(_=p.completionTokens)!=null?_:void 0,totalTokens:(b=p.totalTokens)!=null?b:void 0,reasoningTokens:(B=p.completionTokensDetails.reasoningTokens)!=null?B:void 0,cachedInputTokens:(O=p.promptTokensDetails.cachedTokens)!=null?O:void 0},providerMetadata:S})}})),request:{body:i},response:{headers:u}}}},a(Bn,"OpenAICompatibleChatLanguageModel"),Bn),pp=y({prompt_tokens:w().nullish(),completion_tokens:w().nullish(),total_tokens:w().nullish(),prompt_tokens_details:y({cached_tokens:w().nullish()}).nullish(),completion_tokens_details:y({reasoning_tokens:w().nullish(),accepted_prediction_tokens:w().nullish(),rejected_prediction_tokens:w().nullish()}).nullish()}).nullish(),ob=y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:x(y({message:y({role:k("assistant").nullish(),content:m().nullish(),reasoning_content:m().nullish(),reasoning:m().nullish(),tool_calls:x(y({id:m().nullish(),function:y({name:m(),arguments:m()})})).nullish()}),finish_reason:m().nullish()})),usage:pp}),sb=a(e=>Y([y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:x(y({delta:y({role:se(["assistant"]).nullish(),content:m().nullish(),reasoning_content:m().nullish(),reasoning:m().nullish(),tool_calls:x(y({index:w(),id:m().nullish(),function:y({name:m().nullish(),arguments:m().nullish()})})).nullish()}).nullish(),finish_reason:m().nullish()})),usage:pp}),e]),"createOpenAICompatibleChatChunkSchema");function ib({prompt:e,user:t="user",assistant:n="assistant"}){let r="";e[0].role==="system"&&(r+=`${e[0].content}
|
|
151
|
+
${t}:`]}}a(YE,"convertToOpenAICompletionPrompt");function Xd({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n!=null?new Date(n*1e3):void 0}}a(Xd,"getResponseMetadata2$1");function Qd(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}a(Qd,"mapOpenAIFinishReason2");var XE=ve(()=>Z(y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:$(y({text:m(),finish_reason:m(),logprobs:y({tokens:$(m()),token_logprobs:$(w()),top_logprobs:$(ge(m(),w())).nullish()}).nullish()})),usage:y({prompt_tokens:w(),completion_tokens:w(),total_tokens:w()}).nullish()}))),QE=ve(()=>Z(X([y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:$(y({text:m(),finish_reason:m().nullish(),index:w(),logprobs:y({tokens:$(m()),token_logprobs:$(w()),top_logprobs:$(ge(m(),w())).nullish()}).nullish()})),usage:y({prompt_tokens:w(),completion_tokens:w(),total_tokens:w()}).nullish()}),ei]))),ep=ve(()=>Z(y({echo:Ae().optional(),logitBias:ge(m(),w()).optional(),suffix:m().optional(),user:m().optional(),logprobs:X([Ae(),w()]).optional()}))),eC=($n=class{constructor(t,n){this.specificationVersion="v2",this.supportedUrls={},this.modelId=t,this.config=n}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get provider(){return this.config.provider}async getArgs({prompt:t,maxOutputTokens:n,temperature:r,topP:s,topK:i,frequencyPenalty:o,presencePenalty:u,stopSequences:l,responseFormat:c,tools:d,toolChoice:p,seed:h,providerOptions:f}){const D=[],g={...await ze({provider:"openai",providerOptions:f,schema:ep}),...await ze({provider:this.providerOptionsName,providerOptions:f,schema:ep})};i!=null&&D.push({type:"unsupported-setting",setting:"topK"}),d?.length&&D.push({type:"unsupported-setting",setting:"tools"}),p!=null&&D.push({type:"unsupported-setting",setting:"toolChoice"}),c!=null&&c.type!=="text"&&D.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format is not supported."});const{prompt:v,stopSequences:F}=YE({prompt:t}),C=[...F??[],...l??[]];return{args:{model:this.modelId,echo:g.echo,logit_bias:g.logitBias,logprobs:g?.logprobs===!0?0:g?.logprobs===!1?void 0:g?.logprobs,suffix:g.suffix,user:g.user,max_tokens:n,temperature:r,top_p:s,frequency_penalty:o,presence_penalty:u,seed:h,prompt:v,stop:C.length>0?C:void 0},warnings:D}}async doGenerate(t){var n,r,s;const{args:i,warnings:o}=await this.getArgs(t),{responseHeaders:u,value:l,rawValue:c}=await Ce({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),body:i,failedResponseHandler:ot,successfulResponseHandler:Te(XE),abortSignal:t.abortSignal,fetch:this.config.fetch}),d=l.choices[0],p={openai:{}};return d.logprobs!=null&&(p.openai.logprobs=d.logprobs),{content:[{type:"text",text:d.text}],usage:{inputTokens:(n=l.usage)==null?void 0:n.prompt_tokens,outputTokens:(r=l.usage)==null?void 0:r.completion_tokens,totalTokens:(s=l.usage)==null?void 0:s.total_tokens},finishReason:Qd(d.finish_reason),request:{body:i},response:{...Xd(l),headers:u,body:c},providerMetadata:p,warnings:o}}async doStream(t){const{args:n,warnings:r}=await this.getArgs(t),s={...n,stream:!0,stream_options:{include_usage:!0}},{responseHeaders:i,value:o}=await Ce({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),body:s,failedResponseHandler:ot,successfulResponseHandler:Gt(QE),abortSignal:t.abortSignal,fetch:this.config.fetch});let u="unknown";const l={openai:{}},c={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};let d=!0;return{stream:o.pipeThrough(new TransformStream({start(p){p.enqueue({type:"stream-start",warnings:r})},transform(p,h){if(t.includeRawChunks&&h.enqueue({type:"raw",rawValue:p.rawValue}),!p.success){u="error",h.enqueue({type:"error",error:p.error});return}const f=p.value;if("error"in f){u="error",h.enqueue({type:"error",error:f.error});return}d&&(d=!1,h.enqueue({type:"response-metadata",...Xd(f)}),h.enqueue({type:"text-start",id:"0"})),f.usage!=null&&(c.inputTokens=f.usage.prompt_tokens,c.outputTokens=f.usage.completion_tokens,c.totalTokens=f.usage.total_tokens);const D=f.choices[0];D?.finish_reason!=null&&(u=Qd(D.finish_reason)),D?.logprobs!=null&&(l.openai.logprobs=D.logprobs),D?.text!=null&&D.text.length>0&&h.enqueue({type:"text-delta",id:"0",delta:D.text})},flush(p){d||p.enqueue({type:"text-end",id:"0"}),p.enqueue({type:"finish",finishReason:u,providerMetadata:l,usage:c})}})),request:{body:s},response:{headers:i}}}},a($n,"OpenAICompletionLanguageModel"),$n),tC=ve(()=>Z(y({dimensions:w().optional(),user:m().optional()}))),nC=ve(()=>Z(y({data:$(y({embedding:$(w())})),usage:y({prompt_tokens:w()}).nullish()}))),rC=(In=class{constructor(t,n){this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0,this.modelId=t,this.config=n}get provider(){return this.config.provider}async doEmbed({values:t,headers:n,abortSignal:r,providerOptions:s}){var i;if(t.length>this.maxEmbeddingsPerCall)throw new rl({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:t});const o=(i=await ze({provider:"openai",providerOptions:s,schema:tC}))!=null?i:{},{responseHeaders:u,value:l,rawValue:c}=await Ce({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:_e(this.config.headers(),n),body:{model:this.modelId,input:t,encoding_format:"float",dimensions:o.dimensions,user:o.user},failedResponseHandler:ot,successfulResponseHandler:Te(nC),abortSignal:r,fetch:this.config.fetch});return{embeddings:l.data.map(d=>d.embedding),usage:l.usage?{tokens:l.usage.prompt_tokens}:void 0,response:{headers:u,body:c}}}},a(In,"OpenAIEmbeddingModel"),In),oC=ve(()=>Z(y({data:$(y({b64_json:m(),revised_prompt:m().nullish()}))}))),sC={"dall-e-3":1,"dall-e-2":10,"gpt-image-1":10,"gpt-image-1-mini":10},iC=new Set(["gpt-image-1","gpt-image-1-mini"]),aC=(Bn=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2"}get maxImagesPerCall(){var t;return(t=sC[this.modelId])!=null?t:1}get provider(){return this.config.provider}async doGenerate({prompt:t,n,size:r,aspectRatio:s,seed:i,providerOptions:o,headers:u,abortSignal:l}){var c,d,p,h;const f=[];s!=null&&f.push({type:"unsupported-setting",setting:"aspectRatio",details:"This model does not support aspect ratio. Use `size` instead."}),i!=null&&f.push({type:"unsupported-setting",setting:"seed"});const D=(p=(d=(c=this.config._internal)==null?void 0:c.currentDate)==null?void 0:d.call(c))!=null?p:new Date,{value:g,responseHeaders:v}=await Ce({url:this.config.url({path:"/images/generations",modelId:this.modelId}),headers:_e(this.config.headers(),u),body:{model:this.modelId,prompt:t,n,size:r,...(h=o.openai)!=null?h:{},...iC.has(this.modelId)?{}:{response_format:"b64_json"}},failedResponseHandler:ot,successfulResponseHandler:Te(oC),abortSignal:l,fetch:this.config.fetch});return{images:g.data.map(F=>F.b64_json),warnings:f,response:{timestamp:D,modelId:this.modelId,headers:v},providerMetadata:{openai:{images:g.data.map(F=>F.revised_prompt?{revisedPrompt:F.revised_prompt}:null)}}}}},a(Bn,"OpenAIImageModel"),Bn),uC=Ie(()=>Z(y({code:m().nullish(),containerId:m()}))),lC=Ie(()=>Z(y({outputs:$(ke("type",[y({type:k("logs"),logs:m()}),y({type:k("image"),url:m()})])).nullish()}))),cC=Ie(()=>Z(y({container:X([m(),y({fileIds:$(m()).optional()})]).optional()}))),dC=Vt({id:"openai.code_interpreter",name:"code_interpreter",inputSchema:uC,outputSchema:lC}),pC=a((e={})=>dC(e),"codeInterpreter"),tp=y({key:m(),type:ie(["eq","ne","gt","gte","lt","lte"]),value:X([m(),w(),Ae()])}),np=y({type:ie(["and","or"]),filters:$(X([tp,Ql(()=>np)]))}),DC=Ie(()=>Z(y({vectorStoreIds:$(m()),maxNumResults:w().optional(),ranking:y({ranker:m().optional(),scoreThreshold:w().optional()}).optional(),filters:X([tp,np]).optional()}))),fC=Ie(()=>Z(y({queries:$(m()),results:$(y({attributes:ge(m(),st()),fileId:m(),filename:m(),score:w(),text:m()})).nullable()}))),mC=Vt({id:"openai.file_search",name:"file_search",inputSchema:y({}),outputSchema:fC}),hC=Ie(()=>Z(y({background:ie(["auto","opaque","transparent"]).optional(),inputFidelity:ie(["low","high"]).optional(),inputImageMask:y({fileId:m().optional(),imageUrl:m().optional()}).optional(),model:m().optional(),moderation:ie(["auto"]).optional(),outputCompression:w().int().min(0).max(100).optional(),outputFormat:ie(["png","jpeg","webp"]).optional(),partialImages:w().int().min(0).max(3).optional(),quality:ie(["auto","low","medium","high"]).optional(),size:ie(["1024x1024","1024x1536","1536x1024","auto"]).optional()}).strict())),gC=Ie(()=>Z(y({}))),vC=Ie(()=>Z(y({result:m()}))),yC=Vt({id:"openai.image_generation",name:"image_generation",inputSchema:gC,outputSchema:vC}),_C=a((e={})=>yC(e),"imageGeneration"),rp=Ie(()=>Z(y({action:y({type:k("exec"),command:$(m()),timeoutMs:w().optional(),user:m().optional(),workingDirectory:m().optional(),env:ge(m(),m()).optional()})}))),op=Ie(()=>Z(y({output:m()}))),FC=Vt({id:"openai.local_shell",name:"local_shell",inputSchema:rp,outputSchema:op}),EC=Ie(()=>Z(y({externalWebAccess:Ae().optional(),filters:y({allowedDomains:$(m()).optional()}).optional(),searchContextSize:ie(["low","medium","high"]).optional(),userLocation:y({type:k("approximate"),country:m().optional(),city:m().optional(),region:m().optional(),timezone:m().optional()}).optional()}))),CC=Ie(()=>Z(y({}))),bC=Ie(()=>Z(y({action:ke("type",[y({type:k("search"),query:m().optional()}),y({type:k("openPage"),url:m()}),y({type:k("find"),url:m(),pattern:m()})]),sources:$(ke("type",[y({type:k("url"),url:m()}),y({type:k("api"),name:m()})])).optional()}))),wC=Vt({id:"openai.web_search",name:"web_search",inputSchema:CC,outputSchema:bC}),AC=a((e={})=>wC(e),"webSearch"),kC=Ie(()=>Z(y({searchContextSize:ie(["low","medium","high"]).optional(),userLocation:y({type:k("approximate"),country:m().optional(),city:m().optional(),region:m().optional(),timezone:m().optional()}).optional()}))),xC=Ie(()=>Z(y({}))),$C=Ie(()=>Z(y({action:ke("type",[y({type:k("search"),query:m().optional()}),y({type:k("openPage"),url:m()}),y({type:k("find"),url:m(),pattern:m()})])}))),IC=Vt({id:"openai.web_search_preview",name:"web_search_preview",inputSchema:xC,outputSchema:$C}),BC={codeInterpreter:pC,fileSearch:mC,imageGeneration:_C,localShell:FC,webSearchPreview:IC,webSearch:AC};function sp(e,t){return t?t.some(n=>e.startsWith(n)):!1}a(sp,"isFileId");async function SC({prompt:e,systemMessageMode:t,fileIdPrefixes:n,store:r,hasLocalShellTool:s=!1}){var i,o,u,l;const c=[],d=[];for(const{role:p,content:h}of e)switch(p){case"system":{switch(t){case"system":{c.push({role:"system",content:h});break}case"developer":{c.push({role:"developer",content:h});break}case"remove":{d.push({type:"other",message:"system messages are removed for this model"});break}default:{const f=t;throw new Error(`Unsupported system message mode: ${f}`)}}break}case"user":{c.push({role:"user",content:h.map((f,D)=>{var g,v,F;switch(f.type){case"text":return{type:"input_text",text:f.text};case"file":if(f.mediaType.startsWith("image/")){const C=f.mediaType==="image/*"?"image/jpeg":f.mediaType;return{type:"input_image",...f.data instanceof URL?{image_url:f.data.toString()}:typeof f.data=="string"&&sp(f.data,n)?{file_id:f.data}:{image_url:`data:${C};base64,${Bt(f.data)}`},detail:(v=(g=f.providerOptions)==null?void 0:g.openai)==null?void 0:v.imageDetail}}else{if(f.mediaType==="application/pdf")return f.data instanceof URL?{type:"input_file",file_url:f.data.toString()}:{type:"input_file",...typeof f.data=="string"&&sp(f.data,n)?{file_id:f.data}:{filename:(F=f.filename)!=null?F:`part-${D}.pdf`,file_data:`data:application/pdf;base64,${Bt(f.data)}`}};throw new Ne({functionality:`file part media type ${f.mediaType}`})}}})});break}case"assistant":{const f={},D={};for(const g of h)switch(g.type){case"text":{const v=(o=(i=g.providerOptions)==null?void 0:i.openai)==null?void 0:o.itemId;if(r&&v!=null){c.push({type:"item_reference",id:v});break}c.push({role:"assistant",content:[{type:"output_text",text:g.text}],id:v});break}case"tool-call":{if(D[g.toolCallId]=g,g.providerExecuted)break;const v=(l=(u=g.providerOptions)==null?void 0:u.openai)==null?void 0:l.itemId;if(r&&v!=null){c.push({type:"item_reference",id:v});break}if(s&&g.toolName==="local_shell"){const F=await ft({value:g.input,schema:rp});c.push({type:"local_shell_call",call_id:g.toolCallId,id:v,action:{type:"exec",command:F.action.command,timeout_ms:F.action.timeoutMs,user:F.action.user,working_directory:F.action.workingDirectory,env:F.action.env}});break}c.push({type:"function_call",call_id:g.toolCallId,name:g.toolName,arguments:JSON.stringify(g.input),id:v});break}case"tool-result":{r?c.push({type:"item_reference",id:g.toolCallId}):d.push({type:"other",message:`Results for OpenAI tool ${g.toolName} are not sent to the API when store is false`});break}case"reasoning":{const v=await ze({provider:"openai",providerOptions:g.providerOptions,schema:TC}),F=v?.itemId;if(F!=null){const C=f[F];if(r)C===void 0&&(c.push({type:"item_reference",id:F}),f[F]={type:"reasoning",id:F,summary:[]});else{const _=[];g.text.length>0?_.push({type:"summary_text",text:g.text}):C!==void 0&&d.push({type:"other",message:`Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(g)}.`}),C===void 0?(f[F]={type:"reasoning",id:F,encrypted_content:v?.reasoningEncryptedContent,summary:_},c.push(f[F])):(C.summary.push(..._),v?.reasoningEncryptedContent!=null&&(C.encrypted_content=v.reasoningEncryptedContent))}}else d.push({type:"other",message:`Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(g)}.`});break}}break}case"tool":{for(const f of h){const D=f.output;if(s&&f.toolName==="local_shell"&&D.type==="json"){const v=await ft({value:D.value,schema:op});c.push({type:"local_shell_call_output",call_id:f.toolCallId,output:v.output});break}let g;switch(D.type){case"text":case"error-text":g=D.value;break;case"json":case"error-json":g=JSON.stringify(D.value);break;case"content":g=D.value.map(v=>{switch(v.type){case"text":return{type:"input_text",text:v.text};case"media":return v.mediaType.startsWith("image/")?{type:"input_image",image_url:`data:${v.mediaType};base64,${v.data}`}:{type:"input_file",filename:"data",file_data:`data:${v.mediaType};base64,${v.data}`}}});break}c.push({type:"function_call_output",call_id:f.toolCallId,output:g})}break}default:{const f=p;throw new Error(`Unsupported role: ${f}`)}}return{input:c,warnings:d}}a(SC,"convertToOpenAIResponsesInput");var TC=y({itemId:m().nullish(),reasoningEncryptedContent:m().nullish()});function ip({finishReason:e,hasFunctionCall:t}){switch(e){case void 0:case null:return t?"tool-calls":"stop";case"max_output_tokens":return"length";case"content_filter":return"content-filter";default:return t?"tool-calls":"unknown"}}a(ip,"mapOpenAIResponseFinishReason");var OC=ve(()=>Z(X([y({type:k("response.output_text.delta"),item_id:m(),delta:m(),logprobs:$(y({token:m(),logprob:w(),top_logprobs:$(y({token:m(),logprob:w()}))})).nullish()}),y({type:ie(["response.completed","response.incomplete"]),response:y({incomplete_details:y({reason:m()}).nullish(),usage:y({input_tokens:w(),input_tokens_details:y({cached_tokens:w().nullish()}).nullish(),output_tokens:w(),output_tokens_details:y({reasoning_tokens:w().nullish()}).nullish()}),service_tier:m().nullish()})}),y({type:k("response.created"),response:y({id:m(),created_at:w(),model:m(),service_tier:m().nullish()})}),y({type:k("response.output_item.added"),output_index:w(),item:ke("type",[y({type:k("message"),id:m()}),y({type:k("reasoning"),id:m(),encrypted_content:m().nullish()}),y({type:k("function_call"),id:m(),call_id:m(),name:m(),arguments:m()}),y({type:k("web_search_call"),id:m(),status:m()}),y({type:k("computer_call"),id:m(),status:m()}),y({type:k("file_search_call"),id:m()}),y({type:k("image_generation_call"),id:m()}),y({type:k("code_interpreter_call"),id:m(),container_id:m(),code:m().nullable(),outputs:$(ke("type",[y({type:k("logs"),logs:m()}),y({type:k("image"),url:m()})])).nullable(),status:m()})])}),y({type:k("response.output_item.done"),output_index:w(),item:ke("type",[y({type:k("message"),id:m()}),y({type:k("reasoning"),id:m(),encrypted_content:m().nullish()}),y({type:k("function_call"),id:m(),call_id:m(),name:m(),arguments:m(),status:k("completed")}),y({type:k("code_interpreter_call"),id:m(),code:m().nullable(),container_id:m(),outputs:$(ke("type",[y({type:k("logs"),logs:m()}),y({type:k("image"),url:m()})])).nullable()}),y({type:k("image_generation_call"),id:m(),result:m()}),y({type:k("web_search_call"),id:m(),status:m(),action:ke("type",[y({type:k("search"),query:m().nullish(),sources:$(ke("type",[y({type:k("url"),url:m()}),y({type:k("api"),name:m()})])).nullish()}),y({type:k("open_page"),url:m()}),y({type:k("find"),url:m(),pattern:m()})])}),y({type:k("file_search_call"),id:m(),queries:$(m()),results:$(y({attributes:ge(m(),st()),file_id:m(),filename:m(),score:w(),text:m()})).nullish()}),y({type:k("local_shell_call"),id:m(),call_id:m(),action:y({type:k("exec"),command:$(m()),timeout_ms:w().optional(),user:m().optional(),working_directory:m().optional(),env:ge(m(),m()).optional()})}),y({type:k("computer_call"),id:m(),status:k("completed")})])}),y({type:k("response.function_call_arguments.delta"),item_id:m(),output_index:w(),delta:m()}),y({type:k("response.image_generation_call.partial_image"),item_id:m(),output_index:w(),partial_image_b64:m()}),y({type:k("response.code_interpreter_call_code.delta"),item_id:m(),output_index:w(),delta:m()}),y({type:k("response.code_interpreter_call_code.done"),item_id:m(),output_index:w(),code:m()}),y({type:k("response.output_text.annotation.added"),annotation:ke("type",[y({type:k("url_citation"),start_index:w(),end_index:w(),url:m(),title:m()}),y({type:k("file_citation"),file_id:m(),filename:m().nullish(),index:w().nullish(),start_index:w().nullish(),end_index:w().nullish(),quote:m().nullish()})])}),y({type:k("response.reasoning_summary_part.added"),item_id:m(),summary_index:w()}),y({type:k("response.reasoning_summary_text.delta"),item_id:m(),summary_index:w(),delta:m()}),y({type:k("response.reasoning_summary_part.done"),item_id:m(),summary_index:w()}),y({type:k("error"),sequence_number:w(),error:y({type:m(),code:m(),message:m(),param:m().nullish()})}),y({type:m()}).loose().transform(e=>({type:"unknown_chunk",message:e.type}))]))),RC=ve(()=>Z(y({id:m().optional(),created_at:w().optional(),error:y({message:m(),type:m(),param:m().nullish(),code:m()}).nullish(),model:m().optional(),output:$(ke("type",[y({type:k("message"),role:k("assistant"),id:m(),content:$(y({type:k("output_text"),text:m(),logprobs:$(y({token:m(),logprob:w(),top_logprobs:$(y({token:m(),logprob:w()}))})).nullish(),annotations:$(ke("type",[y({type:k("url_citation"),start_index:w(),end_index:w(),url:m(),title:m()}),y({type:k("file_citation"),file_id:m(),filename:m().nullish(),index:w().nullish(),start_index:w().nullish(),end_index:w().nullish(),quote:m().nullish()}),y({type:k("container_file_citation"),container_id:m(),file_id:m(),filename:m().nullish(),start_index:w().nullish(),end_index:w().nullish(),index:w().nullish()}),y({type:k("file_path"),file_id:m(),index:w().nullish()})]))}))}),y({type:k("web_search_call"),id:m(),status:m(),action:ke("type",[y({type:k("search"),query:m().nullish(),sources:$(ke("type",[y({type:k("url"),url:m()}),y({type:k("api"),name:m()})])).nullish()}),y({type:k("open_page"),url:m()}),y({type:k("find"),url:m(),pattern:m()})])}),y({type:k("file_search_call"),id:m(),queries:$(m()),results:$(y({attributes:ge(m(),X([m(),w(),Ae()])),file_id:m(),filename:m(),score:w(),text:m()})).nullish()}),y({type:k("code_interpreter_call"),id:m(),code:m().nullable(),container_id:m(),outputs:$(ke("type",[y({type:k("logs"),logs:m()}),y({type:k("image"),url:m()})])).nullable()}),y({type:k("image_generation_call"),id:m(),result:m()}),y({type:k("local_shell_call"),id:m(),call_id:m(),action:y({type:k("exec"),command:$(m()),timeout_ms:w().optional(),user:m().optional(),working_directory:m().optional(),env:ge(m(),m()).optional()})}),y({type:k("function_call"),call_id:m(),name:m(),arguments:m(),id:m()}),y({type:k("computer_call"),id:m(),status:m().optional()}),y({type:k("reasoning"),id:m(),encrypted_content:m().nullish(),summary:$(y({type:k("summary_text"),text:m()}))})])).optional(),service_tier:m().nullish(),incomplete_details:y({reason:m()}).nullish(),usage:y({input_tokens:w(),input_tokens_details:y({cached_tokens:w().nullish()}).nullish(),output_tokens:w(),output_tokens_details:y({reasoning_tokens:w().nullish()}).nullish()}).optional()}))),ap=20,PC=ve(()=>Z(y({conversation:m().nullish(),include:$(ie(["reasoning.encrypted_content","file_search_call.results","message.output_text.logprobs"])).nullish(),instructions:m().nullish(),logprobs:X([Ae(),w().min(1).max(ap)]).optional(),maxToolCalls:w().nullish(),metadata:Me().nullish(),parallelToolCalls:Ae().nullish(),previousResponseId:m().nullish(),promptCacheKey:m().nullish(),promptCacheRetention:ie(["in_memory","24h"]).nullish(),reasoningEffort:m().nullish(),reasoningSummary:m().nullish(),safetyIdentifier:m().nullish(),serviceTier:ie(["auto","flex","priority","default"]).nullish(),store:Ae().nullish(),strictJsonSchema:Ae().nullish(),textVerbosity:ie(["low","medium","high"]).nullish(),truncation:ie(["auto","disabled"]).nullish(),user:m().nullish()})));async function NC({tools:e,toolChoice:t,strictJsonSchema:n}){e=e?.length?e:void 0;const r=[];if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:r};const s=[];for(const o of e)switch(o.type){case"function":s.push({type:"function",name:o.name,description:o.description,parameters:o.inputSchema,strict:n});break;case"provider-defined":{switch(o.id){case"openai.file_search":{const u=await ft({value:o.args,schema:DC});s.push({type:"file_search",vector_store_ids:u.vectorStoreIds,max_num_results:u.maxNumResults,ranking_options:u.ranking?{ranker:u.ranking.ranker,score_threshold:u.ranking.scoreThreshold}:void 0,filters:u.filters});break}case"openai.local_shell":{s.push({type:"local_shell"});break}case"openai.web_search_preview":{const u=await ft({value:o.args,schema:kC});s.push({type:"web_search_preview",search_context_size:u.searchContextSize,user_location:u.userLocation});break}case"openai.web_search":{const u=await ft({value:o.args,schema:EC});s.push({type:"web_search",filters:u.filters!=null?{allowed_domains:u.filters.allowedDomains}:void 0,external_web_access:u.externalWebAccess,search_context_size:u.searchContextSize,user_location:u.userLocation});break}case"openai.code_interpreter":{const u=await ft({value:o.args,schema:cC});s.push({type:"code_interpreter",container:u.container==null?{type:"auto",file_ids:void 0}:typeof u.container=="string"?u.container:{type:"auto",file_ids:u.container.fileIds}});break}case"openai.image_generation":{const u=await ft({value:o.args,schema:hC});s.push({type:"image_generation",background:u.background,input_fidelity:u.inputFidelity,input_image_mask:u.inputImageMask?{file_id:u.inputImageMask.fileId,image_url:u.inputImageMask.imageUrl}:void 0,model:u.model,size:u.size,quality:u.quality,moderation:u.moderation,output_format:u.outputFormat,output_compression:u.outputCompression});break}}break}default:r.push({type:"unsupported-tool",tool:o});break}if(t==null)return{tools:s,toolChoice:void 0,toolWarnings:r};const i=t.type;switch(i){case"auto":case"none":case"required":return{tools:s,toolChoice:i,toolWarnings:r};case"tool":return{tools:s,toolChoice:t.toolName==="code_interpreter"||t.toolName==="file_search"||t.toolName==="image_generation"||t.toolName==="web_search_preview"||t.toolName==="web_search"?{type:t.toolName}:{type:"function",name:t.toolName},toolWarnings:r};default:{const o=i;throw new Ne({functionality:`tool choice type: ${o}`})}}}a(NC,"prepareResponsesTools");var MC=(Sn=class{constructor(t,n){this.specificationVersion="v2",this.supportedUrls={"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]},this.modelId=t,this.config=n}get provider(){return this.config.provider}async getArgs({maxOutputTokens:t,temperature:n,stopSequences:r,topP:s,topK:i,presencePenalty:o,frequencyPenalty:u,seed:l,prompt:c,providerOptions:d,tools:p,toolChoice:h,responseFormat:f}){var D,g,v,F;const C=[],_=HC(this.modelId);i!=null&&C.push({type:"unsupported-setting",setting:"topK"}),l!=null&&C.push({type:"unsupported-setting",setting:"seed"}),o!=null&&C.push({type:"unsupported-setting",setting:"presencePenalty"}),u!=null&&C.push({type:"unsupported-setting",setting:"frequencyPenalty"}),r!=null&&C.push({type:"unsupported-setting",setting:"stopSequences"});const b=await ze({provider:"openai",providerOptions:d,schema:PC});b?.conversation&&b?.previousResponseId&&C.push({type:"unsupported-setting",setting:"conversation",details:"conversation and previousResponseId cannot be used together"});const{input:B,warnings:O}=await SC({prompt:c,systemMessageMode:_.systemMessageMode,fileIdPrefixes:this.config.fileIdPrefixes,store:(D=b?.store)!=null?D:!0,hasLocalShellTool:P("openai.local_shell")});C.push(...O);const S=(g=b?.strictJsonSchema)!=null?g:!1;let x=b?.include;function L(q){x==null?x=[q]:x.includes(q)||(x=[...x,q])}a(L,"addInclude");function P(q){return p?.find(j=>j.type==="provider-defined"&&j.id===q)!=null}a(P,"hasOpenAITool");const J=typeof b?.logprobs=="number"?b?.logprobs:b?.logprobs===!0?ap:void 0;J&&L("message.output_text.logprobs");const U=(v=p?.find(q=>q.type==="provider-defined"&&(q.id==="openai.web_search"||q.id==="openai.web_search_preview")))==null?void 0:v.name;U&&L("web_search_call.action.sources"),P("openai.code_interpreter")&&L("code_interpreter_call.outputs");const ce=b?.store;ce===!1&&_.isReasoningModel&&L("reasoning.encrypted_content");const W={model:this.modelId,input:B,temperature:n,top_p:s,max_output_tokens:t,...(f?.type==="json"||b?.textVerbosity)&&{text:{...f?.type==="json"&&{format:f.schema!=null?{type:"json_schema",strict:S,name:(F=f.name)!=null?F:"response",description:f.description,schema:f.schema}:{type:"json_object"}},...b?.textVerbosity&&{verbosity:b.textVerbosity}}},conversation:b?.conversation,max_tool_calls:b?.maxToolCalls,metadata:b?.metadata,parallel_tool_calls:b?.parallelToolCalls,previous_response_id:b?.previousResponseId,store:ce,user:b?.user,instructions:b?.instructions,service_tier:b?.serviceTier,include:x,prompt_cache_key:b?.promptCacheKey,prompt_cache_retention:b?.promptCacheRetention,safety_identifier:b?.safetyIdentifier,top_logprobs:J,truncation:b?.truncation,..._.isReasoningModel&&(b?.reasoningEffort!=null||b?.reasoningSummary!=null)&&{reasoning:{...b?.reasoningEffort!=null&&{effort:b.reasoningEffort},...b?.reasoningSummary!=null&&{summary:b.reasoningSummary}}}};_.isReasoningModel?(W.temperature!=null&&(W.temperature=void 0,C.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for reasoning models"})),W.top_p!=null&&(W.top_p=void 0,C.push({type:"unsupported-setting",setting:"topP",details:"topP is not supported for reasoning models"}))):(b?.reasoningEffort!=null&&C.push({type:"unsupported-setting",setting:"reasoningEffort",details:"reasoningEffort is not supported for non-reasoning models"}),b?.reasoningSummary!=null&&C.push({type:"unsupported-setting",setting:"reasoningSummary",details:"reasoningSummary is not supported for non-reasoning models"})),b?.serviceTier==="flex"&&!_.supportsFlexProcessing&&(C.push({type:"unsupported-setting",setting:"serviceTier",details:"flex processing is only available for o3, o4-mini, and gpt-5 models"}),delete W.service_tier),b?.serviceTier==="priority"&&!_.supportsPriorityProcessing&&(C.push({type:"unsupported-setting",setting:"serviceTier",details:"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"}),delete W.service_tier);const{tools:te,toolChoice:ne,toolWarnings:R}=await NC({tools:p,toolChoice:h,strictJsonSchema:S});return{webSearchToolName:U,args:{...W,tools:te,tool_choice:ne},warnings:[...C,...R],store:ce}}async doGenerate(t){var n,r,s,i,o,u,l,c,d,p,h,f,D,g,v,F,C,_,b;const{args:B,warnings:O,webSearchToolName:S}=await this.getArgs(t),x=this.config.url({path:"/responses",modelId:this.modelId}),{responseHeaders:L,value:P,rawValue:J}=await Ce({url:x,headers:_e(this.config.headers(),t.headers),body:B,failedResponseHandler:ot,successfulResponseHandler:Te(RC),abortSignal:t.abortSignal,fetch:this.config.fetch});if(P.error)throw new be({message:P.error.message,url:x,requestBodyValues:B,statusCode:400,responseHeaders:L,responseBody:J,isRetryable:!1});const U=[],ce=[];let W=!1;for(const R of P.output)switch(R.type){case"reasoning":{R.summary.length===0&&R.summary.push({type:"summary_text",text:""});for(const q of R.summary)U.push({type:"reasoning",text:q.text,providerMetadata:{openai:{itemId:R.id,reasoningEncryptedContent:(n=R.encrypted_content)!=null?n:null}}});break}case"image_generation_call":{U.push({type:"tool-call",toolCallId:R.id,toolName:"image_generation",input:"{}",providerExecuted:!0}),U.push({type:"tool-result",toolCallId:R.id,toolName:"image_generation",result:{result:R.result},providerExecuted:!0});break}case"local_shell_call":{U.push({type:"tool-call",toolCallId:R.call_id,toolName:"local_shell",input:JSON.stringify({action:R.action}),providerMetadata:{openai:{itemId:R.id}}});break}case"message":{for(const q of R.content){(s=(r=t.providerOptions)==null?void 0:r.openai)!=null&&s.logprobs&&q.logprobs&&ce.push(q.logprobs),U.push({type:"text",text:q.text,providerMetadata:{openai:{itemId:R.id}}});for(const j of q.annotations)j.type==="url_citation"?U.push({type:"source",sourceType:"url",id:(u=(o=(i=this.config).generateId)==null?void 0:o.call(i))!=null?u:je(),url:j.url,title:j.title}):j.type==="file_citation"&&U.push({type:"source",sourceType:"document",id:(d=(c=(l=this.config).generateId)==null?void 0:c.call(l))!=null?d:je(),mediaType:"text/plain",title:(h=(p=j.quote)!=null?p:j.filename)!=null?h:"Document",filename:(f=j.filename)!=null?f:j.file_id,...j.file_id?{providerMetadata:{openai:{fileId:j.file_id}}}:{}})}break}case"function_call":{W=!0,U.push({type:"tool-call",toolCallId:R.call_id,toolName:R.name,input:R.arguments,providerMetadata:{openai:{itemId:R.id}}});break}case"web_search_call":{U.push({type:"tool-call",toolCallId:R.id,toolName:S??"web_search",input:JSON.stringify({}),providerExecuted:!0}),U.push({type:"tool-result",toolCallId:R.id,toolName:S??"web_search",result:lp(R.action),providerExecuted:!0});break}case"computer_call":{U.push({type:"tool-call",toolCallId:R.id,toolName:"computer_use",input:"",providerExecuted:!0}),U.push({type:"tool-result",toolCallId:R.id,toolName:"computer_use",result:{type:"computer_use_tool_result",status:R.status||"completed"},providerExecuted:!0});break}case"file_search_call":{U.push({type:"tool-call",toolCallId:R.id,toolName:"file_search",input:"{}",providerExecuted:!0}),U.push({type:"tool-result",toolCallId:R.id,toolName:"file_search",result:{queries:R.queries,results:(g=(D=R.results)==null?void 0:D.map(q=>({attributes:q.attributes,fileId:q.file_id,filename:q.filename,score:q.score,text:q.text})))!=null?g:null},providerExecuted:!0});break}case"code_interpreter_call":{U.push({type:"tool-call",toolCallId:R.id,toolName:"code_interpreter",input:JSON.stringify({code:R.code,containerId:R.container_id}),providerExecuted:!0}),U.push({type:"tool-result",toolCallId:R.id,toolName:"code_interpreter",result:{outputs:R.outputs},providerExecuted:!0});break}}const te={openai:{...P.id!=null?{responseId:P.id}:{}}};ce.length>0&&(te.openai.logprobs=ce),typeof P.service_tier=="string"&&(te.openai.serviceTier=P.service_tier);const ne=P.usage;return{content:U,finishReason:ip({finishReason:(v=P.incomplete_details)==null?void 0:v.reason,hasFunctionCall:W}),usage:{inputTokens:ne.input_tokens,outputTokens:ne.output_tokens,totalTokens:ne.input_tokens+ne.output_tokens,reasoningTokens:(C=(F=ne.output_tokens_details)==null?void 0:F.reasoning_tokens)!=null?C:void 0,cachedInputTokens:(b=(_=ne.input_tokens_details)==null?void 0:_.cached_tokens)!=null?b:void 0},request:{body:B},response:{id:P.id,timestamp:new Date(P.created_at*1e3),modelId:P.model,headers:L,body:J},providerMetadata:te,warnings:O}}async doStream(t){const{args:n,warnings:r,webSearchToolName:s,store:i}=await this.getArgs(t),{responseHeaders:o,value:u}=await Ce({url:this.config.url({path:"/responses",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),body:{...n,stream:!0},failedResponseHandler:ot,successfulResponseHandler:Gt(OC),abortSignal:t.abortSignal,fetch:this.config.fetch}),l=this;let c="unknown";const d={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},p=[];let h=null;const f={},D=[];let g=!1;const v={};let F;return{stream:u.pipeThrough(new TransformStream({start(C){C.enqueue({type:"stream-start",warnings:r})},transform(C,_){var b,B,O,S,x,L,P,J,U,ce,W,te,ne,R,q,j,xe,de,re,V,Be,qe;if(t.includeRawChunks&&_.enqueue({type:"raw",rawValue:C.rawValue}),!C.success){c="error",_.enqueue({type:"error",error:C.error});return}const E=C.value;if(up(E))E.item.type==="function_call"?(f[E.output_index]={toolName:E.item.name,toolCallId:E.item.call_id},_.enqueue({type:"tool-input-start",id:E.item.call_id,toolName:E.item.name})):E.item.type==="web_search_call"?(f[E.output_index]={toolName:s??"web_search",toolCallId:E.item.id},_.enqueue({type:"tool-input-start",id:E.item.id,toolName:s??"web_search",providerExecuted:!0}),_.enqueue({type:"tool-input-end",id:E.item.id}),_.enqueue({type:"tool-call",toolCallId:E.item.id,toolName:s??"web_search",input:JSON.stringify({}),providerExecuted:!0})):E.item.type==="computer_call"?(f[E.output_index]={toolName:"computer_use",toolCallId:E.item.id},_.enqueue({type:"tool-input-start",id:E.item.id,toolName:"computer_use",providerExecuted:!0})):E.item.type==="code_interpreter_call"?(f[E.output_index]={toolName:"code_interpreter",toolCallId:E.item.id,codeInterpreter:{containerId:E.item.container_id}},_.enqueue({type:"tool-input-start",id:E.item.id,toolName:"code_interpreter",providerExecuted:!0}),_.enqueue({type:"tool-input-delta",id:E.item.id,delta:`{"containerId":"${E.item.container_id}","code":"`})):E.item.type==="file_search_call"?_.enqueue({type:"tool-call",toolCallId:E.item.id,toolName:"file_search",input:"{}",providerExecuted:!0}):E.item.type==="image_generation_call"?_.enqueue({type:"tool-call",toolCallId:E.item.id,toolName:"image_generation",input:"{}",providerExecuted:!0}):E.item.type==="message"?(D.splice(0,D.length),_.enqueue({type:"text-start",id:E.item.id,providerMetadata:{openai:{itemId:E.item.id}}})):up(E)&&E.item.type==="reasoning"&&(v[E.item.id]={encryptedContent:E.item.encrypted_content,summaryParts:{0:"active"}},_.enqueue({type:"reasoning-start",id:`${E.item.id}:0`,providerMetadata:{openai:{itemId:E.item.id,reasoningEncryptedContent:(b=E.item.encrypted_content)!=null?b:null}}}));else if(zC(E)){if(E.item.type==="message")_.enqueue({type:"text-end",id:E.item.id,providerMetadata:{openai:{itemId:E.item.id,...D.length>0&&{annotations:D}}}});else if(E.item.type==="function_call")f[E.output_index]=void 0,g=!0,_.enqueue({type:"tool-input-end",id:E.item.call_id}),_.enqueue({type:"tool-call",toolCallId:E.item.call_id,toolName:E.item.name,input:E.item.arguments,providerMetadata:{openai:{itemId:E.item.id}}});else if(E.item.type==="web_search_call")f[E.output_index]=void 0,_.enqueue({type:"tool-result",toolCallId:E.item.id,toolName:s??"web_search",result:lp(E.item.action),providerExecuted:!0});else if(E.item.type==="computer_call")f[E.output_index]=void 0,_.enqueue({type:"tool-input-end",id:E.item.id}),_.enqueue({type:"tool-call",toolCallId:E.item.id,toolName:"computer_use",input:"",providerExecuted:!0}),_.enqueue({type:"tool-result",toolCallId:E.item.id,toolName:"computer_use",result:{type:"computer_use_tool_result",status:E.item.status||"completed"},providerExecuted:!0});else if(E.item.type==="file_search_call")f[E.output_index]=void 0,_.enqueue({type:"tool-result",toolCallId:E.item.id,toolName:"file_search",result:{queries:E.item.queries,results:(O=(B=E.item.results)==null?void 0:B.map(G=>({attributes:G.attributes,fileId:G.file_id,filename:G.filename,score:G.score,text:G.text})))!=null?O:null},providerExecuted:!0});else if(E.item.type==="code_interpreter_call")f[E.output_index]=void 0,_.enqueue({type:"tool-result",toolCallId:E.item.id,toolName:"code_interpreter",result:{outputs:E.item.outputs},providerExecuted:!0});else if(E.item.type==="image_generation_call")_.enqueue({type:"tool-result",toolCallId:E.item.id,toolName:"image_generation",result:{result:E.item.result},providerExecuted:!0});else if(E.item.type==="local_shell_call")f[E.output_index]=void 0,_.enqueue({type:"tool-call",toolCallId:E.item.call_id,toolName:"local_shell",input:JSON.stringify({action:{type:"exec",command:E.item.action.command,timeoutMs:E.item.action.timeout_ms,user:E.item.action.user,workingDirectory:E.item.action.working_directory,env:E.item.action.env}}),providerMetadata:{openai:{itemId:E.item.id}}});else if(E.item.type==="reasoning"){const G=v[E.item.id],pe=Object.entries(G.summaryParts).filter(([ye,Ke])=>Ke==="active"||Ke==="can-conclude").map(([ye])=>ye);for(const ye of pe)_.enqueue({type:"reasoning-end",id:`${E.item.id}:${ye}`,providerMetadata:{openai:{itemId:E.item.id,reasoningEncryptedContent:(S=E.item.encrypted_content)!=null?S:null}}});delete v[E.item.id]}}else if(UC(E)){const G=f[E.output_index];G!=null&&_.enqueue({type:"tool-input-delta",id:G.toolCallId,delta:E.delta})}else if(qC(E)){const G=f[E.output_index];G!=null&&_.enqueue({type:"tool-input-delta",id:G.toolCallId,delta:JSON.stringify(E.delta).slice(1,-1)})}else if(VC(E)){const G=f[E.output_index];G!=null&&(_.enqueue({type:"tool-input-delta",id:G.toolCallId,delta:'"}'}),_.enqueue({type:"tool-input-end",id:G.toolCallId}),_.enqueue({type:"tool-call",toolCallId:G.toolCallId,toolName:"code_interpreter",input:JSON.stringify({code:E.code,containerId:G.codeInterpreter.containerId}),providerExecuted:!0}))}else if(LC(E))h=E.response.id,_.enqueue({type:"response-metadata",id:E.response.id,timestamp:new Date(E.response.created_at*1e3),modelId:E.response.model});else if(jC(E))_.enqueue({type:"text-delta",id:E.item_id,delta:E.delta}),(L=(x=t.providerOptions)==null?void 0:x.openai)!=null&&L.logprobs&&E.logprobs&&p.push(E.logprobs);else if(E.type==="response.reasoning_summary_part.added"){if(E.summary_index>0){const G=v[E.item_id];G.summaryParts[E.summary_index]="active";for(const pe of Object.keys(G.summaryParts))G.summaryParts[pe]==="can-conclude"&&(_.enqueue({type:"reasoning-end",id:`${E.item_id}:${pe}`,providerMetadata:{openai:{itemId:E.item_id}}}),G.summaryParts[pe]="concluded");_.enqueue({type:"reasoning-start",id:`${E.item_id}:${E.summary_index}`,providerMetadata:{openai:{itemId:E.item_id,reasoningEncryptedContent:(J=(P=v[E.item_id])==null?void 0:P.encryptedContent)!=null?J:null}}})}}else E.type==="response.reasoning_summary_text.delta"?_.enqueue({type:"reasoning-delta",id:`${E.item_id}:${E.summary_index}`,delta:E.delta,providerMetadata:{openai:{itemId:E.item_id}}}):E.type==="response.reasoning_summary_part.done"?i?(_.enqueue({type:"reasoning-end",id:`${E.item_id}:${E.summary_index}`,providerMetadata:{openai:{itemId:E.item_id}}}),v[E.item_id].summaryParts[E.summary_index]="concluded"):v[E.item_id].summaryParts[E.summary_index]="can-conclude":ZC(E)?(c=ip({finishReason:(U=E.response.incomplete_details)==null?void 0:U.reason,hasFunctionCall:g}),d.inputTokens=E.response.usage.input_tokens,d.outputTokens=E.response.usage.output_tokens,d.totalTokens=E.response.usage.input_tokens+E.response.usage.output_tokens,d.reasoningTokens=(W=(ce=E.response.usage.output_tokens_details)==null?void 0:ce.reasoning_tokens)!=null?W:void 0,d.cachedInputTokens=(ne=(te=E.response.usage.input_tokens_details)==null?void 0:te.cached_tokens)!=null?ne:void 0,typeof E.response.service_tier=="string"&&(F=E.response.service_tier)):GC(E)?(D.push(E.annotation),E.annotation.type==="url_citation"?_.enqueue({type:"source",sourceType:"url",id:(j=(q=(R=l.config).generateId)==null?void 0:q.call(R))!=null?j:je(),url:E.annotation.url,title:E.annotation.title}):E.annotation.type==="file_citation"&&_.enqueue({type:"source",sourceType:"document",id:(re=(de=(xe=l.config).generateId)==null?void 0:de.call(xe))!=null?re:je(),mediaType:"text/plain",title:(Be=(V=E.annotation.quote)!=null?V:E.annotation.filename)!=null?Be:"Document",filename:(qe=E.annotation.filename)!=null?qe:E.annotation.file_id,...E.annotation.file_id?{providerMetadata:{openai:{fileId:E.annotation.file_id}}}:{}})):WC(E)&&_.enqueue({type:"error",error:E})},flush(C){const _={openai:{responseId:h}};p.length>0&&(_.openai.logprobs=p),F!==void 0&&(_.openai.serviceTier=F),C.enqueue({type:"finish",finishReason:c,usage:d,providerMetadata:_})}})),request:{body:n},response:{headers:o}}}},a(Sn,"OpenAIResponsesLanguageModel"),Sn);function jC(e){return e.type==="response.output_text.delta"}a(jC,"isTextDeltaChunk");function zC(e){return e.type==="response.output_item.done"}a(zC,"isResponseOutputItemDoneChunk");function ZC(e){return e.type==="response.completed"||e.type==="response.incomplete"}a(ZC,"isResponseFinishedChunk");function LC(e){return e.type==="response.created"}a(LC,"isResponseCreatedChunk");function UC(e){return e.type==="response.function_call_arguments.delta"}a(UC,"isResponseFunctionCallArgumentsDeltaChunk");function qC(e){return e.type==="response.code_interpreter_call_code.delta"}a(qC,"isResponseCodeInterpreterCallCodeDeltaChunk");function VC(e){return e.type==="response.code_interpreter_call_code.done"}a(VC,"isResponseCodeInterpreterCallCodeDoneChunk");function up(e){return e.type==="response.output_item.added"}a(up,"isResponseOutputItemAddedChunk");function GC(e){return e.type==="response.output_text.annotation.added"}a(GC,"isResponseAnnotationAddedChunk");function WC(e){return e.type==="error"}a(WC,"isErrorChunk");function HC(e){const t=e.startsWith("o3")||e.startsWith("o4-mini")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-chat"),n=e.startsWith("gpt-4")||e.startsWith("gpt-5-mini")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-nano")&&!e.startsWith("gpt-5-chat")||e.startsWith("o3")||e.startsWith("o4-mini"),r={systemMessageMode:"system",supportsFlexProcessing:t,supportsPriorityProcessing:n};return e.startsWith("gpt-5-chat")?{...r,isReasoningModel:!1}:e.startsWith("o")||e.startsWith("gpt-5")||e.startsWith("codex-")||e.startsWith("computer-use")?{...r,isReasoningModel:!0,systemMessageMode:"developer"}:{...r,isReasoningModel:!1}}a(HC,"getResponsesModelConfig");function lp(e){var t;switch(e.type){case"search":return{action:{type:"search",query:(t=e.query)!=null?t:void 0},...e.sources!=null&&{sources:e.sources}};case"open_page":return{action:{type:"openPage",url:e.url}};case"find":return{action:{type:"find",url:e.url,pattern:e.pattern}}}}a(lp,"mapWebSearchOutput");var JC=ve(()=>Z(y({instructions:m().nullish(),speed:w().min(.25).max(4).default(1).nullish()}))),KC=(Tn=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2"}get provider(){return this.config.provider}async getArgs({text:t,voice:n="alloy",outputFormat:r="mp3",speed:s,instructions:i,language:o,providerOptions:u}){const l=[],c=await ze({provider:"openai",providerOptions:u,schema:JC}),d={model:this.modelId,input:t,voice:n,response_format:"mp3",speed:s,instructions:i};if(r&&(["mp3","opus","aac","flac","wav","pcm"].includes(r)?d.response_format=r:l.push({type:"unsupported-setting",setting:"outputFormat",details:`Unsupported output format: ${r}. Using mp3 instead.`})),c){const p={};for(const h in p){const f=p[h];f!==void 0&&(d[h]=f)}}return o&&l.push({type:"unsupported-setting",setting:"language",details:`OpenAI speech models do not support language selection. Language parameter "${o}" was ignored.`}),{requestBody:d,warnings:l}}async doGenerate(t){var n,r,s;const i=(s=(r=(n=this.config._internal)==null?void 0:n.currentDate)==null?void 0:r.call(n))!=null?s:new Date,{requestBody:o,warnings:u}=await this.getArgs(t),{value:l,responseHeaders:c,rawValue:d}=await Ce({url:this.config.url({path:"/audio/speech",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),body:o,failedResponseHandler:ot,successfulResponseHandler:v_(),abortSignal:t.abortSignal,fetch:this.config.fetch});return{audio:l,warnings:u,request:{body:JSON.stringify(o)},response:{timestamp:i,modelId:this.modelId,headers:c,body:d}}}},a(Tn,"OpenAISpeechModel"),Tn),YC=ve(()=>Z(y({text:m(),language:m().nullish(),duration:w().nullish(),words:$(y({word:m(),start:w(),end:w()})).nullish(),segments:$(y({id:w(),seek:w(),start:w(),end:w(),text:m(),tokens:$(w()),temperature:w(),avg_logprob:w(),compression_ratio:w(),no_speech_prob:w()})).nullish()}))),XC=ve(()=>Z(y({include:$(m()).optional(),language:m().optional(),prompt:m().optional(),temperature:w().min(0).max(1).default(0).optional(),timestampGranularities:$(ie(["word","segment"])).default(["segment"]).optional()}))),cp={afrikaans:"af",arabic:"ar",armenian:"hy",azerbaijani:"az",belarusian:"be",bosnian:"bs",bulgarian:"bg",catalan:"ca",chinese:"zh",croatian:"hr",czech:"cs",danish:"da",dutch:"nl",english:"en",estonian:"et",finnish:"fi",french:"fr",galician:"gl",german:"de",greek:"el",hebrew:"he",hindi:"hi",hungarian:"hu",icelandic:"is",indonesian:"id",italian:"it",japanese:"ja",kannada:"kn",kazakh:"kk",korean:"ko",latvian:"lv",lithuanian:"lt",macedonian:"mk",malay:"ms",marathi:"mr",maori:"mi",nepali:"ne",norwegian:"no",persian:"fa",polish:"pl",portuguese:"pt",romanian:"ro",russian:"ru",serbian:"sr",slovak:"sk",slovenian:"sl",spanish:"es",swahili:"sw",swedish:"sv",tagalog:"tl",tamil:"ta",thai:"th",turkish:"tr",ukrainian:"uk",urdu:"ur",vietnamese:"vi",welsh:"cy"},QC=(On=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2"}get provider(){return this.config.provider}async getArgs({audio:t,mediaType:n,providerOptions:r}){const s=[],i=await ze({provider:"openai",providerOptions:r,schema:XC}),o=new FormData,u=t instanceof Uint8Array?new Blob([t]):new Blob([Xr(t)]);o.append("model",this.modelId);const l=i_(n);if(o.append("file",new File([u],"audio",{type:n}),`audio.${l}`),i){const c={include:i.include,language:i.language,prompt:i.prompt,response_format:["gpt-4o-transcribe","gpt-4o-mini-transcribe"].includes(this.modelId)?"json":"verbose_json",temperature:i.temperature,timestamp_granularities:i.timestampGranularities};for(const[d,p]of Object.entries(c))if(p!=null)if(Array.isArray(p))for(const h of p)o.append(`${d}[]`,String(h));else o.append(d,String(p))}return{formData:o,warnings:s}}async doGenerate(t){var n,r,s,i,o,u,l,c;const d=(s=(r=(n=this.config._internal)==null?void 0:n.currentDate)==null?void 0:r.call(n))!=null?s:new Date,{formData:p,warnings:h}=await this.getArgs(t),{value:f,responseHeaders:D,rawValue:g}=await g_({url:this.config.url({path:"/audio/transcriptions",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),formData:p,failedResponseHandler:ot,successfulResponseHandler:Te(YC),abortSignal:t.abortSignal,fetch:this.config.fetch}),v=f.language!=null&&f.language in cp?cp[f.language]:void 0;return{text:f.text,segments:(l=(u=(i=f.segments)==null?void 0:i.map(F=>({text:F.text,startSecond:F.start,endSecond:F.end})))!=null?u:(o=f.words)==null?void 0:o.map(F=>({text:F.word,startSecond:F.start,endSecond:F.end})))!=null?l:[],language:v,durationInSeconds:(c=f.duration)!=null?c:void 0,warnings:h,response:{timestamp:d,modelId:this.modelId,headers:D,body:g}}}},a(On,"OpenAITranscriptionModel"),On),eb="2.0.74";function ni(e={}){var t,n;const r=(t=Ss(or({settingValue:e.baseURL,environmentVariableName:"OPENAI_BASE_URL"})))!=null?t:"https://api.openai.com/v1",s=(n=e.name)!=null?n:"openai",i=a(()=>$t({Authorization:`Bearer ${s_({apiKey:e.apiKey,environmentVariableName:"OPENAI_API_KEY",description:"OpenAI"})}`,"OpenAI-Organization":e.organization,"OpenAI-Project":e.project,...e.headers},`ai-sdk/openai/${eb}`),"getHeaders"),o=a(g=>new GE(g,{provider:`${s}.chat`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createChatModel"),u=a(g=>new eC(g,{provider:`${s}.completion`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createCompletionModel"),l=a(g=>new rC(g,{provider:`${s}.embedding`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createEmbeddingModel"),c=a(g=>new aC(g,{provider:`${s}.image`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createImageModel"),d=a(g=>new QC(g,{provider:`${s}.transcription`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createTranscriptionModel"),p=a(g=>new KC(g,{provider:`${s}.speech`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch}),"createSpeechModel"),h=a(g=>{if(new.target)throw new Error("The OpenAI model function cannot be called with the new keyword.");return f(g)},"createLanguageModel"),f=a(g=>new MC(g,{provider:`${s}.responses`,url:a(({path:v})=>`${r}${v}`,"url"),headers:i,fetch:e.fetch,fileIdPrefixes:["file-"]}),"createResponsesModel"),D=a(function(g){return h(g)},"provider");return D.languageModel=h,D.chat=o,D.completion=u,D.responses=f,D.embedding=l,D.textEmbedding=l,D.textEmbeddingModel=l,D.image=c,D.imageModel=c,D.transcription=d,D.transcriptionModel=d,D.speech=p,D.speechModel=p,D.tools=BC,D}a(ni,"createOpenAI"),ni();function pr(e){var t,n;return(n=(t=e?.providerOptions)==null?void 0:t.openaiCompatible)!=null?n:{}}a(pr,"getOpenAIMetadata");function tb(e){const t=[];for(const{role:n,content:r,...s}of e){const i=pr({...s});switch(n){case"system":{t.push({role:"system",content:r,...i});break}case"user":{if(r.length===1&&r[0].type==="text"){t.push({role:"user",content:r[0].text,...pr(r[0])});break}t.push({role:"user",content:r.map(o=>{const u=pr(o);switch(o.type){case"text":return{type:"text",text:o.text,...u};case"file":if(o.mediaType.startsWith("image/")){const l=o.mediaType==="image/*"?"image/jpeg":o.mediaType;return{type:"image_url",image_url:{url:o.data instanceof URL?o.data.toString():`data:${l};base64,${Bt(o.data)}`},...u}}else throw new Ne({functionality:`file part media type ${o.mediaType}`})}}),...i});break}case"assistant":{let o="";const u=[];for(const l of r){const c=pr(l);switch(l.type){case"text":{o+=l.text;break}case"tool-call":{u.push({id:l.toolCallId,type:"function",function:{name:l.toolName,arguments:JSON.stringify(l.input)},...c});break}}}t.push({role:"assistant",content:o,tool_calls:u.length>0?u:void 0,...i});break}case"tool":{for(const o of r){const u=o.output;let l;switch(u.type){case"text":case"error-text":l=u.value;break;case"content":case"json":case"error-json":l=JSON.stringify(u.value);break}const c=pr(o);t.push({role:"tool",tool_call_id:o.toolCallId,content:l,...c})}break}default:{const o=n;throw new Error(`Unsupported role: ${o}`)}}}return t}a(tb,"convertToOpenAICompatibleChatMessages");function dp({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n!=null?new Date(n*1e3):void 0}}a(dp,"getResponseMetadata");function pp(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}a(pp,"mapOpenAICompatibleFinishReason");var ri=y({user:m().optional(),reasoningEffort:m().optional(),textVerbosity:m().optional()}),nb=y({error:y({message:m(),type:m().nullish(),param:Me().nullish(),code:X([m(),w()]).nullish()})}),ro={errorSchema:nb,errorToMessage:a(e=>e.error.message,"errorToMessage")};function rb({tools:e,toolChoice:t}){e=e?.length?e:void 0;const n=[];if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:n};const r=[];for(const i of e)i.type==="provider-defined"?n.push({type:"unsupported-tool",tool:i}):r.push({type:"function",function:{name:i.name,description:i.description,parameters:i.inputSchema}});if(t==null)return{tools:r,toolChoice:void 0,toolWarnings:n};const s=t.type;switch(s){case"auto":case"none":case"required":return{tools:r,toolChoice:s,toolWarnings:n};case"tool":return{tools:r,toolChoice:{type:"function",function:{name:t.toolName}},toolWarnings:n};default:{const i=s;throw new Ne({functionality:`tool choice type: ${i}`})}}}a(rb,"prepareTools");var ob=(Rn=class{constructor(t,n){this.specificationVersion="v2";var r,s;this.modelId=t,this.config=n;const i=(r=n.errorStructure)!=null?r:ro;this.chunkSchema=ib(i.errorSchema),this.failedResponseHandler=We(i),this.supportsStructuredOutputs=(s=n.supportsStructuredOutputs)!=null?s:!1}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get supportedUrls(){var t,n,r;return(r=(n=(t=this.config).supportedUrls)==null?void 0:n.call(t))!=null?r:{}}async getArgs({prompt:t,maxOutputTokens:n,temperature:r,topP:s,topK:i,frequencyPenalty:o,presencePenalty:u,providerOptions:l,stopSequences:c,responseFormat:d,seed:p,toolChoice:h,tools:f}){var D,g,v,F;const C=[],_=Object.assign((D=await ze({provider:"openai-compatible",providerOptions:l,schema:ri}))!=null?D:{},(g=await ze({provider:this.providerOptionsName,providerOptions:l,schema:ri}))!=null?g:{});i!=null&&C.push({type:"unsupported-setting",setting:"topK"}),d?.type==="json"&&d.schema!=null&&!this.supportsStructuredOutputs&&C.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});const{tools:b,toolChoice:B,toolWarnings:O}=rb({tools:f,toolChoice:h});return{args:{model:this.modelId,user:_.user,max_tokens:n,temperature:r,top_p:s,frequency_penalty:o,presence_penalty:u,response_format:d?.type==="json"?this.supportsStructuredOutputs===!0&&d.schema!=null?{type:"json_schema",json_schema:{schema:d.schema,name:(v=d.name)!=null?v:"response",description:d.description}}:{type:"json_object"}:void 0,stop:c,seed:p,...Object.fromEntries(Object.entries((F=l?.[this.providerOptionsName])!=null?F:{}).filter(([S])=>!Object.keys(ri.shape).includes(S))),reasoning_effort:_.reasoningEffort,verbosity:_.textVerbosity,messages:tb(t),tools:b,tool_choice:B},warnings:[...C,...O]}}async doGenerate(t){var n,r,s,i,o,u,l,c,d,p,h,f,D,g,v,F,C;const{args:_,warnings:b}=await this.getArgs({...t}),B=JSON.stringify(_),{responseHeaders:O,value:S,rawValue:x}=await Ce({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),body:_,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Te(sb),abortSignal:t.abortSignal,fetch:this.config.fetch}),L=S.choices[0],P=[],J=L.message.content;J!=null&&J.length>0&&P.push({type:"text",text:J});const U=(n=L.message.reasoning_content)!=null?n:L.message.reasoning;if(U!=null&&U.length>0&&P.push({type:"reasoning",text:U}),L.message.tool_calls!=null)for(const te of L.message.tool_calls)P.push({type:"tool-call",toolCallId:(r=te.id)!=null?r:je(),toolName:te.function.name,input:te.function.arguments});const ce={[this.providerOptionsName]:{},...await((i=(s=this.config.metadataExtractor)==null?void 0:s.extractMetadata)==null?void 0:i.call(s,{parsedBody:x}))},W=(o=S.usage)==null?void 0:o.completion_tokens_details;return W?.accepted_prediction_tokens!=null&&(ce[this.providerOptionsName].acceptedPredictionTokens=W?.accepted_prediction_tokens),W?.rejected_prediction_tokens!=null&&(ce[this.providerOptionsName].rejectedPredictionTokens=W?.rejected_prediction_tokens),{content:P,finishReason:pp(L.finish_reason),usage:{inputTokens:(l=(u=S.usage)==null?void 0:u.prompt_tokens)!=null?l:void 0,outputTokens:(d=(c=S.usage)==null?void 0:c.completion_tokens)!=null?d:void 0,totalTokens:(h=(p=S.usage)==null?void 0:p.total_tokens)!=null?h:void 0,reasoningTokens:(g=(D=(f=S.usage)==null?void 0:f.completion_tokens_details)==null?void 0:D.reasoning_tokens)!=null?g:void 0,cachedInputTokens:(C=(F=(v=S.usage)==null?void 0:v.prompt_tokens_details)==null?void 0:F.cached_tokens)!=null?C:void 0},providerMetadata:ce,request:{body:B},response:{...dp(S),headers:O,body:x},warnings:b}}async doStream(t){var n;const{args:r,warnings:s}=await this.getArgs({...t}),i={...r,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},o=(n=this.config.metadataExtractor)==null?void 0:n.createStreamExtractor(),{responseHeaders:u,value:l}=await Ce({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),body:i,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Gt(this.chunkSchema),abortSignal:t.abortSignal,fetch:this.config.fetch}),c=[];let d="unknown";const p={completionTokens:void 0,completionTokensDetails:{reasoningTokens:void 0,acceptedPredictionTokens:void 0,rejectedPredictionTokens:void 0},promptTokens:void 0,promptTokensDetails:{cachedTokens:void 0},totalTokens:void 0};let h=!0;const f=this.providerOptionsName;let D=!1,g=!1;return{stream:l.pipeThrough(new TransformStream({start(v){v.enqueue({type:"stream-start",warnings:s})},transform(v,F){var C,_,b,B,O,S,x,L,P,J,U,ce,W;if(t.includeRawChunks&&F.enqueue({type:"raw",rawValue:v.rawValue}),!v.success){d="error",F.enqueue({type:"error",error:v.error});return}const te=v.value;if(o?.processChunk(v.rawValue),"error"in te){d="error",F.enqueue({type:"error",error:te.error.message});return}if(h&&(h=!1,F.enqueue({type:"response-metadata",...dp(te)})),te.usage!=null){const{prompt_tokens:j,completion_tokens:xe,total_tokens:de,prompt_tokens_details:re,completion_tokens_details:V}=te.usage;p.promptTokens=j??void 0,p.completionTokens=xe??void 0,p.totalTokens=de??void 0,V?.reasoning_tokens!=null&&(p.completionTokensDetails.reasoningTokens=V?.reasoning_tokens),V?.accepted_prediction_tokens!=null&&(p.completionTokensDetails.acceptedPredictionTokens=V?.accepted_prediction_tokens),V?.rejected_prediction_tokens!=null&&(p.completionTokensDetails.rejectedPredictionTokens=V?.rejected_prediction_tokens),re?.cached_tokens!=null&&(p.promptTokensDetails.cachedTokens=re?.cached_tokens)}const ne=te.choices[0];if(ne?.finish_reason!=null&&(d=pp(ne.finish_reason)),ne?.delta==null)return;const R=ne.delta,q=(C=R.reasoning_content)!=null?C:R.reasoning;if(q&&(D||(F.enqueue({type:"reasoning-start",id:"reasoning-0"}),D=!0),F.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:q})),R.content&&(g||(F.enqueue({type:"text-start",id:"txt-0"}),g=!0),F.enqueue({type:"text-delta",id:"txt-0",delta:R.content})),R.tool_calls!=null)for(const j of R.tool_calls){const xe=j.index;if(c[xe]==null){if(j.id==null)throw new Jn({data:j,message:"Expected 'id' to be a string."});if(((_=j.function)==null?void 0:_.name)==null)throw new Jn({data:j,message:"Expected 'function.name' to be a string."});F.enqueue({type:"tool-input-start",id:j.id,toolName:j.function.name}),c[xe]={id:j.id,type:"function",function:{name:j.function.name,arguments:(b=j.function.arguments)!=null?b:""},hasFinished:!1};const re=c[xe];((B=re.function)==null?void 0:B.name)!=null&&((O=re.function)==null?void 0:O.arguments)!=null&&(re.function.arguments.length>0&&F.enqueue({type:"tool-input-delta",id:re.id,delta:re.function.arguments}),Kr(re.function.arguments)&&(F.enqueue({type:"tool-input-end",id:re.id}),F.enqueue({type:"tool-call",toolCallId:(S=re.id)!=null?S:je(),toolName:re.function.name,input:re.function.arguments}),re.hasFinished=!0));continue}const de=c[xe];de.hasFinished||(((x=j.function)==null?void 0:x.arguments)!=null&&(de.function.arguments+=(P=(L=j.function)==null?void 0:L.arguments)!=null?P:""),F.enqueue({type:"tool-input-delta",id:de.id,delta:(J=j.function.arguments)!=null?J:""}),((U=de.function)==null?void 0:U.name)!=null&&((ce=de.function)==null?void 0:ce.arguments)!=null&&Kr(de.function.arguments)&&(F.enqueue({type:"tool-input-end",id:de.id}),F.enqueue({type:"tool-call",toolCallId:(W=de.id)!=null?W:je(),toolName:de.function.name,input:de.function.arguments}),de.hasFinished=!0))}},flush(v){var F,C,_,b,B,O;D&&v.enqueue({type:"reasoning-end",id:"reasoning-0"}),g&&v.enqueue({type:"text-end",id:"txt-0"});for(const x of c.filter(L=>!L.hasFinished))v.enqueue({type:"tool-input-end",id:x.id}),v.enqueue({type:"tool-call",toolCallId:(F=x.id)!=null?F:je(),toolName:x.function.name,input:x.function.arguments});const S={[f]:{},...o?.buildMetadata()};p.completionTokensDetails.acceptedPredictionTokens!=null&&(S[f].acceptedPredictionTokens=p.completionTokensDetails.acceptedPredictionTokens),p.completionTokensDetails.rejectedPredictionTokens!=null&&(S[f].rejectedPredictionTokens=p.completionTokensDetails.rejectedPredictionTokens),v.enqueue({type:"finish",finishReason:d,usage:{inputTokens:(C=p.promptTokens)!=null?C:void 0,outputTokens:(_=p.completionTokens)!=null?_:void 0,totalTokens:(b=p.totalTokens)!=null?b:void 0,reasoningTokens:(B=p.completionTokensDetails.reasoningTokens)!=null?B:void 0,cachedInputTokens:(O=p.promptTokensDetails.cachedTokens)!=null?O:void 0},providerMetadata:S})}})),request:{body:i},response:{headers:u}}}},a(Rn,"OpenAICompatibleChatLanguageModel"),Rn),Dp=y({prompt_tokens:w().nullish(),completion_tokens:w().nullish(),total_tokens:w().nullish(),prompt_tokens_details:y({cached_tokens:w().nullish()}).nullish(),completion_tokens_details:y({reasoning_tokens:w().nullish(),accepted_prediction_tokens:w().nullish(),rejected_prediction_tokens:w().nullish()}).nullish()}).nullish(),sb=y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:$(y({message:y({role:k("assistant").nullish(),content:m().nullish(),reasoning_content:m().nullish(),reasoning:m().nullish(),tool_calls:$(y({id:m().nullish(),function:y({name:m(),arguments:m()})})).nullish()}),finish_reason:m().nullish()})),usage:Dp}),ib=a(e=>X([y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:$(y({delta:y({role:ie(["assistant"]).nullish(),content:m().nullish(),reasoning_content:m().nullish(),reasoning:m().nullish(),tool_calls:$(y({index:w(),id:m().nullish(),function:y({name:m().nullish(),arguments:m().nullish()})})).nullish()}).nullish(),finish_reason:m().nullish()})),usage:Dp}),e]),"createOpenAICompatibleChatChunkSchema");function ab({prompt:e,user:t="user",assistant:n="assistant"}){let r="";e[0].role==="system"&&(r+=`${e[0].content}
|
|
152
152
|
|
|
153
|
-
`,e=e.slice(1));for(const{role:s,content:i}of e)switch(s){case"system":throw new
|
|
153
|
+
`,e=e.slice(1));for(const{role:s,content:i}of e)switch(s){case"system":throw new dt({message:"Unexpected system message in prompt: ${content}",prompt:e});case"user":{const o=i.map(u=>{switch(u.type){case"text":return u.text}}).filter(Boolean).join("");r+=`${t}:
|
|
154
154
|
${o}
|
|
155
155
|
|
|
156
156
|
`;break}case"assistant":{const o=i.map(u=>{switch(u.type){case"text":return u.text;case"tool-call":throw new Ne({functionality:"tool-call messages"})}}).join("");r+=`${n}:
|
|
@@ -158,24 +158,27 @@ ${o}
|
|
|
158
158
|
|
|
159
159
|
`;break}case"tool":throw new Ne({functionality:"tool messages"});default:{const o=s;throw new Error(`Unsupported role: ${o}`)}}return r+=`${n}:
|
|
160
160
|
`,{prompt:r,stopSequences:[`
|
|
161
|
-
${t}:`]}}a(
|
|
161
|
+
${t}:`]}}a(ab,"convertToOpenAICompatibleCompletionPrompt");function fp({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n!=null?new Date(n*1e3):void 0}}a(fp,"getResponseMetadata2");function mp(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}a(mp,"mapOpenAICompatibleFinishReason2");var ub=y({echo:Ae().optional(),logitBias:ge(m(),w()).optional(),suffix:m().optional(),user:m().optional()}),lb=(Pn=class{constructor(t,n){this.specificationVersion="v2";var r;this.modelId=t,this.config=n;const s=(r=n.errorStructure)!=null?r:ro;this.chunkSchema=db(s.errorSchema),this.failedResponseHandler=We(s)}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get supportedUrls(){var t,n,r;return(r=(n=(t=this.config).supportedUrls)==null?void 0:n.call(t))!=null?r:{}}async getArgs({prompt:t,maxOutputTokens:n,temperature:r,topP:s,topK:i,frequencyPenalty:o,presencePenalty:u,stopSequences:l,responseFormat:c,seed:d,providerOptions:p,tools:h,toolChoice:f}){var D;const g=[],v=(D=await ze({provider:this.providerOptionsName,providerOptions:p,schema:ub}))!=null?D:{};i!=null&&g.push({type:"unsupported-setting",setting:"topK"}),h?.length&&g.push({type:"unsupported-setting",setting:"tools"}),f!=null&&g.push({type:"unsupported-setting",setting:"toolChoice"}),c!=null&&c.type!=="text"&&g.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format is not supported."});const{prompt:F,stopSequences:C}=ab({prompt:t}),_=[...C??[],...l??[]];return{args:{model:this.modelId,echo:v.echo,logit_bias:v.logitBias,suffix:v.suffix,user:v.user,max_tokens:n,temperature:r,top_p:s,frequency_penalty:o,presence_penalty:u,seed:d,...p?.[this.providerOptionsName],prompt:F,stop:_.length>0?_:void 0},warnings:g}}async doGenerate(t){var n,r,s,i,o,u;const{args:l,warnings:c}=await this.getArgs(t),{responseHeaders:d,value:p,rawValue:h}=await Ce({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),body:l,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Te(cb),abortSignal:t.abortSignal,fetch:this.config.fetch}),f=p.choices[0],D=[];return f.text!=null&&f.text.length>0&&D.push({type:"text",text:f.text}),{content:D,usage:{inputTokens:(r=(n=p.usage)==null?void 0:n.prompt_tokens)!=null?r:void 0,outputTokens:(i=(s=p.usage)==null?void 0:s.completion_tokens)!=null?i:void 0,totalTokens:(u=(o=p.usage)==null?void 0:o.total_tokens)!=null?u:void 0},finishReason:mp(f.finish_reason),request:{body:l},response:{...fp(p),headers:d,body:h},warnings:c}}async doStream(t){const{args:n,warnings:r}=await this.getArgs(t),s={...n,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},{responseHeaders:i,value:o}=await Ce({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:_e(this.config.headers(),t.headers),body:s,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Gt(this.chunkSchema),abortSignal:t.abortSignal,fetch:this.config.fetch});let u="unknown";const l={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};let c=!0;return{stream:o.pipeThrough(new TransformStream({start(d){d.enqueue({type:"stream-start",warnings:r})},transform(d,p){var h,f,D;if(t.includeRawChunks&&p.enqueue({type:"raw",rawValue:d.rawValue}),!d.success){u="error",p.enqueue({type:"error",error:d.error});return}const g=d.value;if("error"in g){u="error",p.enqueue({type:"error",error:g.error});return}c&&(c=!1,p.enqueue({type:"response-metadata",...fp(g)}),p.enqueue({type:"text-start",id:"0"})),g.usage!=null&&(l.inputTokens=(h=g.usage.prompt_tokens)!=null?h:void 0,l.outputTokens=(f=g.usage.completion_tokens)!=null?f:void 0,l.totalTokens=(D=g.usage.total_tokens)!=null?D:void 0);const v=g.choices[0];v?.finish_reason!=null&&(u=mp(v.finish_reason)),v?.text!=null&&p.enqueue({type:"text-delta",id:"0",delta:v.text})},flush(d){c||d.enqueue({type:"text-end",id:"0"}),d.enqueue({type:"finish",finishReason:u,usage:l})}})),request:{body:s},response:{headers:i}}}},a(Pn,"OpenAICompatibleCompletionLanguageModel"),Pn),hp=y({prompt_tokens:w(),completion_tokens:w(),total_tokens:w()}),cb=y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:$(y({text:m(),finish_reason:m()})),usage:hp.nullish()}),db=a(e=>X([y({id:m().nullish(),created:w().nullish(),model:m().nullish(),choices:$(y({text:m(),finish_reason:m().nullish(),index:w()})),usage:hp.nullish()}),e]),"createOpenAICompatibleCompletionChunkSchema"),gp=y({dimensions:w().optional(),user:m().optional()}),pb=(Nn=class{constructor(t,n){this.specificationVersion="v2",this.modelId=t,this.config=n}get provider(){return this.config.provider}get maxEmbeddingsPerCall(){var t;return(t=this.config.maxEmbeddingsPerCall)!=null?t:2048}get supportsParallelCalls(){var t;return(t=this.config.supportsParallelCalls)!=null?t:!0}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}async doEmbed({values:t,headers:n,abortSignal:r,providerOptions:s}){var i,o,u;const l=Object.assign((i=await ze({provider:"openai-compatible",providerOptions:s,schema:gp}))!=null?i:{},(o=await ze({provider:this.providerOptionsName,providerOptions:s,schema:gp}))!=null?o:{});if(t.length>this.maxEmbeddingsPerCall)throw new rl({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:t});const{responseHeaders:c,value:d,rawValue:p}=await Ce({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:_e(this.config.headers(),n),body:{model:this.modelId,input:t,encoding_format:"float",dimensions:l.dimensions,user:l.user},failedResponseHandler:We((u=this.config.errorStructure)!=null?u:ro),successfulResponseHandler:Te(Db),abortSignal:r,fetch:this.config.fetch});return{embeddings:d.data.map(h=>h.embedding),usage:d.usage?{tokens:d.usage.prompt_tokens}:void 0,providerMetadata:d.providerMetadata,response:{headers:c,body:p}}}},a(Nn,"OpenAICompatibleEmbeddingModel"),Nn),Db=y({data:$(y({embedding:$(w())})),usage:y({prompt_tokens:w()}).nullish(),providerMetadata:ge(m(),ge(m(),Me())).optional()}),fb=(Mn=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2",this.maxImagesPerCall=10}get provider(){return this.config.provider}async doGenerate({prompt:t,n,size:r,aspectRatio:s,seed:i,providerOptions:o,headers:u,abortSignal:l}){var c,d,p,h,f;const D=[];s!=null&&D.push({type:"unsupported-setting",setting:"aspectRatio",details:"This model does not support aspect ratio. Use `size` instead."}),i!=null&&D.push({type:"unsupported-setting",setting:"seed"});const g=(p=(d=(c=this.config._internal)==null?void 0:c.currentDate)==null?void 0:d.call(c))!=null?p:new Date,{value:v,responseHeaders:F}=await Ce({url:this.config.url({path:"/images/generations",modelId:this.modelId}),headers:_e(this.config.headers(),u),body:{model:this.modelId,prompt:t,n,size:r,...(h=o.openai)!=null?h:{},response_format:"b64_json"},failedResponseHandler:We((f=this.config.errorStructure)!=null?f:ro),successfulResponseHandler:Te(mb),abortSignal:l,fetch:this.config.fetch});return{images:v.data.map(C=>C.b64_json),warnings:D,response:{timestamp:g,modelId:this.modelId,headers:F}}}},a(Mn,"OpenAICompatibleImageModel"),Mn),mb=y({data:$(y({b64_json:m()}))}),hb="1.0.28";function vp(e){const t=Ss(e.baseURL),n=e.name,r={...e.apiKey&&{Authorization:`Bearer ${e.apiKey}`},...e.headers},s=a(()=>$t(r,`ai-sdk/openai-compatible/${hb}`),"getHeaders"),i=a(h=>({provider:`${n}.${h}`,url:a(({path:f})=>{const D=new URL(`${t}${f}`);return e.queryParams&&(D.search=new URLSearchParams(e.queryParams).toString()),D.toString()},"url"),headers:s,fetch:e.fetch}),"getCommonModelConfig"),o=a(h=>u(h),"createLanguageModel"),u=a(h=>new ob(h,{...i("chat"),includeUsage:e.includeUsage,supportsStructuredOutputs:e.supportsStructuredOutputs}),"createChatModel"),l=a(h=>new lb(h,{...i("completion"),includeUsage:e.includeUsage}),"createCompletionModel"),c=a(h=>new pb(h,{...i("embedding")}),"createEmbeddingModel"),d=a(h=>new fb(h,i("image")),"createImageModel"),p=a(h=>o(h),"provider");return p.languageModel=o,p.chatModel=u,p.completionModel=l,p.textEmbeddingModel=c,p.imageModel=d,p}a(vp,"createOpenAICompatible");const gb={"":"<commit message>",conventional:"<type>[optional (<scope>)]: <commit message>",gitmoji:":emoji: <commit message>"},vb=a(e=>`The output response must be in format:
|
|
162
162
|
${gb[e]}`,"specifyCommitFormat"),yb={"":"",conventional:`Choose a type from the type-to-description JSON below that best describes the git diff:
|
|
163
163
|
${JSON.stringify({docs:"Documentation only changes",style:"Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",refactor:"A code change that improves code structure without changing functionality (renaming, restructuring classes/methods, extracting functions, etc)",perf:"A code change that improves performance",test:"Adding missing tests or correcting existing tests",build:"Changes that affect the build system or external dependencies",ci:"Changes to our CI configuration files and scripts",chore:"Other changes that don't modify src or test files",revert:"Reverts a previous commit",feat:"A new feature",fix:"A bug fix"},null,2)}`,gitmoji:`Choose an emoji from the emoji-to-description JSON below that best describes the git diff:
|
|
164
164
|
${JSON.stringify({"\u{1F3A8}":"Improve structure / format of the code","\u26A1":"Improve performance","\u{1F525}":"Remove code or files","\u{1F41B}":"Fix a bug","\u{1F691}":"Critical hotfix","\u2728":"Introduce new features","\u{1F4DD}":"Add or update documentation","\u{1F680}":"Deploy stuff","\u{1F484}":"Add or update the UI and style files","\u{1F389}":"Begin a project","\u2705":"Add, update, or pass tests","\u{1F512}":"Fix security or privacy issues","\u{1F510}":"Add or update secrets","\u{1F516}":"Release / Version tags","\u{1F6A8}":"Fix compiler / linter warnings","\u{1F6A7}":"Work in progress","\u{1F49A}":"Fix CI Build","\u2B07\uFE0F":"Downgrade dependencies","\u2B06\uFE0F":"Upgrade dependencies","\u{1F4CC}":"Pin dependencies to specific versions","\u{1F477}":"Add or update CI build system","\u{1F4C8}":"Add or update analytics or track code","\u267B\uFE0F":"Refactor code","\u2795":"Add a dependency","\u2796":"Remove a dependency","\u{1F527}":"Add or update configuration files","\u{1F528}":"Add or update development scripts","\u{1F310}":"Internationalization and localization","\u270F\uFE0F":"Fix typos","\u{1F4A9}":"Write bad code that needs to be improved","\u23EA":"Revert changes","\u{1F500}":"Merge branches","\u{1F4E6}":"Add or update compiled files or packages","\u{1F47D}":"Update code due to external API changes","\u{1F69A}":"Move or rename resources (e.g.: files, paths, routes)","\u{1F4C4}":"Add or update license","\u{1F4A5}":"Introduce breaking changes","\u{1F371}":"Add or update assets","\u267F":"Improve accessibility","\u{1F4A1}":"Add or update comments in source code","\u{1F37B}":"Write code drunkenly","\u{1F4AC}":"Add or update text and literals","\u{1F5C3}":"Perform database related changes","\u{1F50A}":"Add or update logs","\u{1F507}":"Remove logs","\u{1F465}":"Add or update contributor(s)","\u{1F6B8}":"Improve user experience / usability","\u{1F3D7}":"Make architectural changes","\u{1F4F1}":"Work on responsive design","\u{1F921}":"Mock things","\u{1F95A}":"Add or update an easter egg","\u{1F648}":"Add or update a .gitignore file","\u{1F4F8}":"Add or update snapshots","\u2697":"Perform experiments","\u{1F50D}":"Improve SEO","\u{1F3F7}":"Add or update types","\u{1F331}":"Add or update seed files","\u{1F6A9}":"Add, update, or remove feature flags","\u{1F945}":"Catch errors","\u{1F4AB}":"Add or update animations and transitions","\u{1F5D1}":"Deprecate code that needs to be cleaned up","\u{1F6C2}":"Work on code related to authorization, roles and permissions","\u{1FA79}":"Simple fix for a non-critical issue","\u{1F9D0}":"Data exploration/inspection","\u26B0":"Remove dead code","\u{1F9EA}":"Add a failing test","\u{1F454}":"Add or update business logic","\u{1FA7A}":"Add or update healthcheck","\u{1F9F1}":"Infrastructure related changes","\u{1F9D1}\u200D\u{1F4BB}":"Improve developer experience","\u{1F4B8}":"Add sponsorships or money related infrastructure","\u{1F9F5}":"Add or update code related to multithreading or concurrency","\u{1F9BA}":"Add or update code related to validation"},null,2)}`},_b=a((e,t,n)=>["Generate a concise git commit message title in present tense that precisely describes the key changes in the following code diff. Focus on what was changed, not just file names. Provide only the title, no description or body.",`Message language: ${e}`,`Commit message must be a maximum of ${t} characters.`,"Exclude anything unnecessary such as translation. Your entire response will be passed directly into git commit.","IMPORTANT: Do not include any explanations, introductions, or additional text. Do not wrap the commit message in quotes or any other formatting. Respond with ONLY the commit message text.",yb[n],vb(n)].filter(Boolean).join(`
|
|
165
165
|
`),"generatePrompt"),Fb=a((e,t)=>e.trim().split(`
|
|
166
|
-
`)[0].replace(/(\w)\.$/,"$1").replace(/^["'`]|["'`]$/g,"").substring(0,t),"sanitizeMessage"),Eb=a(e=>Array.from(new Set(e)),"deduplicateMessages"),
|
|
166
|
+
`)[0].replace(/(\w)\.$/,"$1").replace(/^["'`]|["'`]$/g,"").substring(0,t),"sanitizeMessage"),Eb=a(e=>Array.from(new Set(e)),"deduplicateMessages"),yp=a(async(e,t,n,r,s,i,o,u,l)=>{process.env.DEBUG&&(console.log("Diff being sent to AI:"),console.log(s));try{const c=e==="https://api.openai.com/v1"?ni({apiKey:t}):vp({name:"custom",apiKey:t,baseURL:e}),d=new AbortController,p=setTimeout(()=>d.abort(),l),h=Array.from({length:i},()=>Qs({model:c(n),system:_b(r,o,u),prompt:s,temperature:.4,maxRetries:2}).finally(()=>clearTimeout(p))),f=await Promise.all(h),D=f.map(F=>F.text),g=Eb(D.map(F=>Fb(F,o))),v={prompt_tokens:f.reduce((F,C)=>F+(C.usage.promptTokens||0),0),completion_tokens:f.reduce((F,C)=>F+(C.usage.completionTokens||0),0),total_tokens:f.reduce((F,C)=>F+(C.usage.totalTokens||0),0)};return{messages:g,usage:v}}catch(c){const d=c;if(console.log(d),d.code==="ENOTFOUND")throw new K(`Error connecting to ${d.hostname} (${d.syscall}). Are you connected to the internet?`);if(d.status===429){const p=d.headers?.get("x-ratelimit-reset");let h="Rate limit exceeded";if(p){const f=parseInt(p),D=Date.now(),g=f-D,v=Math.ceil(g/1e3);if(v>0){let F;if(v<60)F=`${v} second${v===1?"":"s"}`;else if(v<3600){const C=Math.ceil(v/60);F=`${C} minute${C===1?"":"s"}`}else{const C=Math.ceil(v/3600);F=`${C} hour${C===1?"":"s"}`}h+=`. Retry in ${F}.`}}throw new K(h)}throw d}},"generateCommitMessage"),Cb=a(async(e,t)=>{const{select:n,confirm:r,isCancel:s}=await Promise.resolve().then(function(){return Gn}),{dim:i}=await Promise.resolve().then(function(){return Am}),o=process.stdout.isTTY&&!process.env.CI;if(e.length===1){const[l]=e;if(t)return l;if(!o)throw new K("Interactive terminal required for commit message confirmation. Use --confirm flag to skip confirmation.");console.log(`
|
|
167
167
|
\x1B[1m${l}\x1B[0m
|
|
168
|
-
`);const c=await r({message:"Use this commit message?"});return c&&!s(c)?l:null}if(t)return e[0];if(!o)throw new
|
|
168
|
+
`);const c=await r({message:"Use this commit message?"});return c&&!s(c)?l:null}if(t)return e[0];if(!o)throw new K("Interactive terminal required for commit message selection. Use --confirm flag to skip selection and use the first message.");const u=await n({message:`Pick a commit message to use: ${i("(Ctrl+c to exit)")}`,options:e.map(l=>({label:l,value:l}))});return s(u)?null:u},"getCommitMessage");var bb=a(async(e,t,n,r,s,i,o)=>(async()=>{Sr(Ar(wr(" aicommits "))),await ns();const u=bt();n&&await Ge("git",["add","--update"]),u.start("Detecting staged files");const l=await yu(t);if(!l)throw u.stop("Detecting staged files"),new K("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");l.files.length<=10?u.stop(`\u{1F4C1} ${_u(l.files)}:
|
|
169
169
|
${l.files.map(_=>` ${_}`).join(`
|
|
170
|
-
`)}`):u.stop(`\u{1F4C1} ${
|
|
170
|
+
`)}`):u.stop(`\u{1F4C1} ${_u(l.files)}`);const{env:c}=process,d=await wt({generate:e?.toString(),type:r?.toString()}),p=Lt(d);if(!p)if(process.stdout.isTTY&&!process.env.CI){console.log("Welcome to aicommits! Let's set up your AI provider."),console.log("Run `aicommits setup` to configure your provider."),he("Setup required. Please run: aicommits setup");return}else throw new K("No configuration found. Run `aicommits setup` in an interactive terminal, or set environment variables (OPENAI_API_KEY, etc.)");const h=d.timeout||(p.name==="ollama"?3e4:1e4),f=p.validateConfig();if(!f.valid)throw new K(`Provider configuration issues: ${f.errors.join(", ")}. Run \`aicommits setup\` to reconfigure.`);d.model=d.OPENAI_MODEL||p.getDefaultModel();const D=bt();D.start(`\u{1F50D} Analyzing changes in ${l.files.length} file${l.files.length===1?"":"s"}`);const g=Date.now();let v,F;try{const _=p.getBaseUrl(),b=p.getApiKey()||"",B=await yp(_,b,d.model,d.locale,l.diff,d.generate,d["max-length"],d.type,h);v=B.messages,F=B.usage}finally{const _=Date.now()-g;let b="";if(F?.total_tokens){const B=F.total_tokens,O=B>=1e3?`${(B/1e3).toFixed(0)}k`:B.toString(),S=Math.round(B/(_/1e3));b=`, ${O} tokens (${S} tokens/s)`}D.stop(`\u2705 Changes analyzed in ${(_/1e3).toFixed(1)}s${b}`)}if(v.length===0)throw new K("No commit messages were generated. Try again.");const C=await Cb(v,s);if(!C){he("Commit cancelled");return}if(i){try{process.platform==="darwin"?await Ge("pbcopy",{input:C}):await Un.write(C),he(`${Qe("\u2714")} Message copied to clipboard`)}catch{}return}await Ge("git",["commit","-m",C,...o]),he(`${Qe("\u2714")} Successfully committed!`)})().catch(Tr),"aicommits");const[oo,wb]=process.argv.slice(2);var Ab=a(()=>(async()=>{if(!oo)throw new K('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(wb)return;const e=await yu();if(!e)return;Sr(Ar(wr(" aicommits ")));const t=await wt({}),n=Lt(t);if(!n)throw new K("Invalid provider configuration. Run `aicommits setup` to reconfigure.");const r=n.validateConfig();if(!r.valid)throw new K(`Provider configuration issues: ${r.errors.join(", ")}. Run \`aicommits setup\` to reconfigure.`);const s=n.getBaseUrl(),i=n.getApiKey()||"",o=t.timeout||(n.name==="ollama"?3e4:1e4);let u=t.OPENAI_MODEL||n.getDefaultModel();const l=bt();l.start("The AI is analyzing your changes");let c;try{c=(await yp(s,i,u,t.locale,e.diff,t.generate,t["max-length"],t.type,o)).messages}finally{l.stop("Changes analyzed")}const p=await we.readFile(oo,"utf8")!=="",h=c.length>1;let f="";p&&(f=`# \u{1F916} AI generated commit${h?"s":""}
|
|
171
171
|
`),h?(p&&(f+=`# Select one of the following messages by uncommenting:
|
|
172
172
|
`),f+=`
|
|
173
173
|
${c.map(v=>`# ${v}`).join(`
|
|
174
174
|
`)}`):(p&&(f+=`# Edit the message below and commit:
|
|
175
175
|
`),f+=`
|
|
176
176
|
${c[0]}
|
|
177
|
-
`);const D=await
|
|
178
|
-
`+D;await
|
|
177
|
+
`);const D=await we.readFile(oo,"utf8"),g=f+`
|
|
178
|
+
`+D;await we.writeFile(oo,g),he(`${Qe("\u2714")} Saved commit message!`)})().catch(Tr),"prepareCommitMessageHook"),kb=Mt({name:"config",description:"View or modify configuration settings",help:{description:"View or modify configuration settings"},parameters:["[mode]","[key=value...]"]},e=>{(async()=>{const[t,...n]=e._;if(!t){const r=await wt({},{},!0);console.log("Provider:",r.provider),r.OPENAI_API_KEY&&console.log("API Key:",`${r.OPENAI_API_KEY.substring(0,4)}****`),r.OPENAI_BASE_URL&&console.log("Base URL:",r.OPENAI_BASE_URL),r.OPENAI_MODEL&&console.log("Model:",r.OPENAI_MODEL);return}if(t==="get"){const r=await wt({},{},!0),s=["OPENAI_API_KEY","TOGETHER_API_KEY","api-key"];for(const i of n)if(Cu(r,i)){const o=r[i],u=s.includes(i)?`${String(o).substring(0,4)}****`:String(o);console.log(`${i}=${u}`)}return}if(t==="set"){await as(n.map(r=>r.split("=")));return}throw new K(`Invalid mode: ${t}`)})().catch(Tr)}),xb=Mt({name:"setup",description:"Configure your AI provider and settings",help:{description:"Configure your AI provider and settings"}},e=>{(async()=>{let t=await wt();const n=Bh(),r=await hu({message:"Choose your AI provider:",options:n,initialValue:t.provider});if(Vn(r)){he("Setup cancelled");return}const s=r;let i="";if(s==="custom"){const f=await mu({message:"Enter your custom API endpoint:",validate:a(D=>{if(!D)return"Endpoint is required";try{new URL(D)}catch{return"Invalid URL format"}},"validate")});if(Vn(f)){he("Setup cancelled");return}i=f}let o=i||Sh(s);t.OPENAI_BASE_URL=o,t.OPENAI_API_KEY="",t.OPENAI_MODEL="";let u=Lt({...t,provider:s});if(!u){he("Invalid provider selected");return}const l=await u.setup();for(const[f,D]of l)t[f]=D;if(u=Lt({...t,provider:s}),!u){he("Invalid provider selected");return}const c=u.validateConfig();if(!c.valid){he(`Setup cancelled: ${c.errors.join(", ")}`);return}const{selectModel:d}=await Promise.resolve().then(function(){return xh}),p=await d(u.getBaseUrl(),u.getApiKey()||"",void 0,u.getDefinition());p?(t.OPENAI_MODEL=p,console.log(`Model selected: ${p}`)):console.log("Model selection cancelled.");const h=Object.entries(t).filter(([f,D])=>f!=="provider"&&f!=="model"&&D!==void 0&&D!==""&&typeof D=="string");await as(h),he(`\u2705 Setup complete! You're now using ${u.displayName}.`)})().catch(t=>{console.error(`\u274C Setup failed: ${t.message}`),process.exit(1)})}),$b=Mt({name:"model",description:"Select or change your AI model",help:{description:"Select or change your AI model"},alias:["-m","models"]},()=>{(async()=>{const e=await wt();if(!e.provider){he("No provider configured. Run `aicommits setup` first.");return}const t=Lt(e);if(!t){he("Invalid provider configured. Run `aicommits setup` to reconfigure.");return}console.log(`Current provider: ${t.displayName}`);const n=e.OPENAI_MODEL;console.log(`Current model: ${n&&n!=="undefined"?n:"not set"}`);const r=t.validateConfig();if(!r.valid){he(`Configuration issues: ${r.errors.join(", ")}. Run \`aicommits setup\` to reconfigure.`);return}const s=await xu(t.getBaseUrl(),t.getApiKey()||"",n,t.getDefinition());s?(await as([["OPENAI_MODEL",s]]),he(`\u2705 Model updated to: ${s}`)):he("Model selection cancelled")})().catch(e=>{console.error(`\u274C Model selection failed: ${e.message}`),process.exit(1)})});const _p="prepare-commit-msg",Fp=`.git/hooks/${_p}`,so=Lp(new URL("cli.mjs",import.meta.url)),Ib=process.argv[1].replace(/\\/g,"/").endsWith(`/${Fp}`),Ep=process.platform==="win32",Cp=`
|
|
179
179
|
#!/usr/bin/env node
|
|
180
|
-
import(${JSON.stringify(
|
|
181
|
-
`.trim();var Bb=
|
|
180
|
+
import(${JSON.stringify(Up(so))})
|
|
181
|
+
`.trim();var Bb=Mt({name:"hook",description:"Install or uninstall the Git hook for automatic commit messages",help:{description:"Install or uninstall the Git hook for automatic commit messages"},parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await ns(),{installUninstall:n}=e._,r=Ve.join(t,Fp),s=await ss(r);if(n==="install"){if(s){if(await we.realpath(r).catch(()=>{})===so){console.warn("The hook is already installed");return}throw new K(`A different ${_p} hook seems to be installed. Please remove it before installing aicommits.`)}await we.mkdir(Ve.dirname(r),{recursive:!0}),Ep?await we.writeFile(r,Cp):(await we.symlink(so,r,"file"),await we.chmod(r,493)),console.log(`${Qe("\u2714")} Hook installed`);return}if(n==="uninstall"){if(!s){console.warn("Hook is not installed");return}if(Ep){if(await we.readFile(r,"utf8")!==Cp){console.warn("Hook is not installed");return}}else if(await we.realpath(r)!==so){console.warn("Hook is not installed");return}await we.rm(r),console.log(`${Qe("\u2714")} Hook uninstalled`);return}throw new K(`Invalid mode: ${n}`)})().catch(t=>{console.error(`${zo("\u2716")} ${t.message}`),gu(t),process.exit(1)})}),Sb=Mt({name:"pr",description:"[beta \u{1F6A7}] Generate and create a PR on GitHub based on branch diff",help:{description:"[beta \u{1F6A7}] Generate and create a PR on GitHub based on branch diff"}},()=>{(async()=>{Sr(Ar(wr(" aicommits pr "))),await ns();const{stdout:e}=await Ge("git",["branch","--show-current"]);if(!e.trim())throw new K("Not on a branch");const{stdout:t}=await Ge("git",["remote","get-url","origin"]),n=t.match(/github\.com[\/:]([^\/]+)\/([^\/\.]+)/);if(!n)throw new K("Could not determine GitHub repository from remote URL");const[,r,s]=n;let i="main";try{const{stdout:P}=await Ge("git",["symbolic-ref","refs/remotes/origin/HEAD"]);i=P.trim().replace("refs/remotes/origin/","")}catch{}if(e.trim()===i)throw new K("PR creation requires being on a feature branch, not the default branch. Please switch to a feature branch with changes.");let o;try{const{stdout:P}=await Ge("git",["diff",`origin/${i}..HEAD`]);o=P}catch{throw new K(`Could not get diff from origin/${i}`)}if(!o)throw new K("No changes to create PR from");const u=o.split(`
|
|
182
|
+
`).filter(P=>P.startsWith("diff --git")).length,l=3e4;o.length>l&&(o=o.substring(0,l)+`
|
|
183
|
+
|
|
184
|
+
[Diff truncated due to size]`);const c=await wt(),d=await Lt(c);if(!d)throw new K("No provider configured");let p=d.getBaseUrl();if(!p||p==="")throw new K("Base URL not configured. Please run `aicommits setup` to configure your provider.");p.endsWith("/v1")||(p+="/v1");const h=d.getApiKey();if(!h)throw new K("API key not configured. Please run `aicommits setup` to configure your provider.");const f=p==="https://api.openai.com/v1"?ni({apiKey:h}):vp({name:"custom",apiKey:h,baseURL:p}),D=bt();D.start(`Generating PR title and description (${u} files changed)`);const g=Date.now(),F=(await Qs({model:f(c.model),system:"Generate a concise PR title based on the following git diff. The title should be under 72 characters.",prompt:o,maxRetries:2})).text,_=(await Qs({model:f(c.model),system:"Generate a concise PR description based on the following git diff. Format using Markdown with headings like ### Summary, ### Changes, ### Review Notes. Provide a high-level summary of the changes, what was implemented or fixed, and any specific details reviewers should consider. Avoid listing individual files.",prompt:o,maxRetries:2})).text,b=Date.now(),B=Math.round((b-g)/1e3);D.stop(`Generated PR content for ${u} files in ${B}s`),console.log(`${Qe("Title:")} ${F.replace(/\n/g," ")}`),console.log(`${Qe("Body:")} ${_.length>100?_.substring(0,100)+"...":_}`);const{text:O}=await Promise.resolve().then(function(){return Gn}),S=await O({message:"Press Enter to open PR creation in browser, or Ctrl+C to cancel",placeholder:"Press Enter"});if(Vn(S)){he("PR creation cancelled");return}const x=`https://github.com/${r}/${s}/compare/${i}...${e.trim()}?expand=1&title=${encodeURIComponent(F)}&body=${encodeURIComponent(_)}`,L=bt();L.start("Opening PR creation page in browser");try{const P=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";await Ge(P,[x]),L.stop("PR creation page opened in browser"),he(Qe("PR creation page opened! Please review and submit the PR."))}catch{L.stop("Failed to open browser"),he(`${Qe("PR URL:")} ${x}`),he("Please open the URL above in your browser to create the PR.")}})().catch(e=>{Tr(e)})});const{description:Tb,version:io}=_o,Ob=xp({pkg:_o,distTag:io.includes("-")?"develop":"latest"});io!=="0.0.0-semantic-release"&&io.includes("-")&&Ob.notify();const bp=process.argv.slice(2);Fa({name:"aicommits",flags:{generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Git commit message format (default: conventional). Supports conventional and gitmoji",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard instead of committing (default: false)",alias:"c",default:!1},version:{type:Boolean,description:"Show version number",alias:"v"}},commands:[kb,xb,$b,Bb,Sb],help:{description:Tb},ignoreArgv:a(e=>e==="unknown-flag"||e==="argument","ignoreArgv")},e=>{e.flags.version&&(console.log(io),process.exit(0)),Ib?Ab():bb(e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,bp)},bp);export{yt as g,hc as r};
|