1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[18803],{4970:(e,t,r)=>{r.d(t,{$V:()=>eB});var a,n,s,o,i,l,u,c,m,d,p=r(24021),h=r(70903),f=r(75452),y=r(17696),v=Object.defineProperty,g=(e,t)=>{for(var r in t)v(e,r,{get:t[r],enumerable:!0})};async function b(e){return void 0===e?Promise.resolve():new Promise(t=>setTimeout(t,e))}var w="AI_RetryError",z=`vercel.ai.error.${w}`,S=Symbol.for(z),x=class extends p.bD{constructor({message:e,reason:t,errors:r}){super({name:w,message:e}),this[a]=!0,this.reason=t,this.errors=r,this.lastError=r[r.length-1]}static isInstance(e){return p.bD.hasMarker(e,z)}static isRetryError(e){return e instanceof Error&&e.name===w&&"string"==typeof e.reason&&Array.isArray(e.errors)}toJSON(){return{name:this.name,message:this.message,reason:this.reason,lastError:this.lastError,errors:this.errors}}};a=S;async function T(e,{maxRetries:t,delayInMs:r,backoffFactor:a},n=[]){try{return await e()}catch(l){if(isAbortError(l)||0===t)throw l;let s=getErrorMessage(l),o=[...n,l],i=o.length;if(i>t)throw new x({message:`Failed after ${i} attempts. Last error: ${s}`,reason:"maxRetriesExceeded",errors:o});if(l instanceof Error&&APICallError.isAPICallError(l)&&!0===l.isRetryable&&i<=t)return await b(r),T(e,{maxRetries:t,delayInMs:a*r,backoffFactor:a},o);if(1===i)throw l;throw new x({message:`Failed after ${i} attempts with non-retryable error: '${s}'`,reason:"errorNotRetryable",errors:o})}}var E={startSpan:()=>j,startActiveSpan:(e,t,r,a)=>"function"==typeof t?t(j):"function"==typeof r?r(j):"function"==typeof a?a(j):void 0},j={spanContext:()=>I,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:()=>!1,recordException(){return this}},I={traceId:"",spanId:"",traceFlags:0};function A({telemetry:e,attributes:t}){return(null==e?void 0:e.isEnabled)!==!0?{}:Object.entries(t).reduce((t,[r,a])=>{if(void 0===a)return t;if("object"==typeof a&&"input"in a&&"function"==typeof a.input){if((null==e?void 0:e.recordInputs)===!1)return t;let n=a.input();return void 0===n?t:{...t,[r]:n}}if("object"==typeof a&&"output"in a&&"function"==typeof a.output){if((null==e?void 0:e.recordOutputs)===!1)return t;let n=a.output();return void 0===n?t:{...t,[r]:n}}return{...t,[r]:a}},{})}var k="AI_DownloadError",N=`vercel.ai.error.${k}`,_=Symbol.for(N),$=class extends p.bD{constructor({url:e,statusCode:t,statusText:r,cause:a,message:s=null==a?`Failed to download ${e}: ${t} ${r}`:`Failed to download ${e}: ${a}`}){super({name:k,message:s,cause:a}),this[n]=!0,this.url=e,this.statusCode=t,this.statusText=r}static isInstance(e){return p.bD.hasMarker(e,N)}static isDownloadError(e){return e instanceof Error&&e.name===k&&"string"==typeof e.url&&(null==e.statusCode||"number"==typeof e.statusCode)&&(null==e.statusText||"string"==typeof e.statusText)}toJSON(){return{name:this.name,message:this.message,url:this.url,statusCode:this.statusCode,statusText:this.statusText,cause:this.cause}}};async function D({url:e,fetchImplementation:t=fetch}){var r;let a=e.toString();try{let e=await t(a);if(!e.ok)throw new $({url:a,statusCode:e.status,statusText:e.statusText});return{data:new Uint8Array(await e.arrayBuffer()),mimeType:null!=(r=e.headers.get("content-type"))?r:void 0}}catch(e){if($.isInstance(e))throw e;throw new $({url:a,cause:e})}}n=_;var R=[{mimeType:"image/gif",bytes:[71,73,70]},{mimeType:"image/png",bytes:[137,80,78,71]},{mimeType:"image/jpeg",bytes:[255,216]},{mimeType:"image/webp",bytes:[82,73,70,70]}],M="AI_InvalidDataContentError",O=`vercel.ai.error.${M}`,C=Symbol.for(O),P=class extends p.bD{constructor({content:e,cause:t,message:r=`Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof e}.`}){super({name:M,message:r,cause:t}),this[s]=!0,this.content=e}static isInstance(e){return p.bD.hasMarker(e,O)}static isInvalidDataContentError(e){return e instanceof Error&&e.name===M&&null!=e.content}toJSON(){return{name:this.name,message:this.message,stack:this.stack,cause:this.cause,content:this.content}}};s=C;var J=f.z.union([f.z.string(),f.z.instanceof(Uint8Array),f.z.instanceof(ArrayBuffer),f.z.custom(e=>{var t,r;return null!=(r=null==(t=globalThis.Buffer)?void 0:t.isBuffer(e))&&r},{message:"Must be a Buffer"})]);function F(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)try{return convertBase64ToUint8Array(e)}catch(t){throw new P({message:"Invalid data content. Content string is not a base64-encoded media.",content:e,cause:t})}if(e instanceof ArrayBuffer)return new Uint8Array(e);throw new P({content:e})}var q="AI_InvalidMessageRoleError",U=`vercel.ai.error.${q}`,V=Symbol.for(U),B=class extends p.bD{constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:q,message:t}),this[o]=!0,this.role=e}static isInstance(e){return p.bD.hasMarker(e,U)}static isInvalidMessageRoleError(e){return e instanceof Error&&e.name===q&&"string"==typeof e.role}toJSON(){return{name:this.name,message:this.message,stack:this.stack,role:this.role}}};o=V;async function L(e,t,r,a){let n=e.filter(e=>"user"===e.role).map(e=>e.content).filter(e=>Array.isArray(e)).flat().filter(e=>"image"===e.type||"file"===e.type).filter(e=>"image"!==e.type||!0!==r).map(e=>"image"===e.type?e.image:e.data).map(e=>"string"==typeof e&&(e.startsWith("http:")||e.startsWith("https:"))?new URL(e):e).filter(e=>e instanceof URL).filter(e=>!a(e));return Object.fromEntries((await Promise.all(n.map(async e=>({url:e,data:await t({url:e})})))).map(({url:e,data:t})=>[e.toString(),t]))}var K="AI_InvalidArgumentError",G=`vercel.ai.error.${K}`,H=Symbol.for(G),W=class extends p.bD{constructor({parameter:e,value:t,message:r}){super({name:K,message:`Invalid argument for parameter ${e}: ${r}`}),this[i]=!0,this.parameter=e,this.value=t}static isInstance(e){return p.bD.hasMarker(e,G)}static isInvalidArgumentError(e){return e instanceof Error&&e.name===K&&"string"==typeof e.parameter&&"string"==typeof e.value}toJSON(){return{name:this.name,message:this.message,stack:this.stack,parameter:this.parameter,value:this.value}}};i=H;var X=f.z.lazy(()=>f.z.union([f.z.null(),f.z.string(),f.z.number(),f.z.boolean(),f.z.record(f.z.string(),X),f.z.array(X)])),Q=f.z.record(f.z.string(),f.z.record(f.z.string(),X)),Y=f.z.array(f.z.union([f.z.object({type:f.z.literal("text"),text:f.z.string()}),f.z.object({type:f.z.literal("image"),data:f.z.string(),mimeType:f.z.string().optional()})])),Z=f.z.object({type:f.z.literal("text"),text:f.z.string(),experimental_providerMetadata:Q.optional()}),ee=f.z.object({type:f.z.literal("image"),image:f.z.union([J,f.z.instanceof(URL)]),mimeType:f.z.string().optional(),experimental_providerMetadata:Q.optional()}),et=f.z.object({type:f.z.literal("file"),data:f.z.union([J,f.z.instanceof(URL)]),mimeType:f.z.string(),experimental_providerMetadata:Q.optional()}),er=f.z.object({type:f.z.literal("tool-call"),toolCallId:f.z.string(),toolName:f.z.string(),args:f.z.unknown()}),ea=f.z.object({type:f.z.literal("tool-result"),toolCallId:f.z.string(),toolName:f.z.string(),result:f.z.unknown(),content:Y.optional(),isError:f.z.boolean().optional(),experimental_providerMetadata:Q.optional()}),en=f.z.object({role:f.z.literal("system"),content:f.z.string(),experimental_providerMetadata:Q.optional()}),es=f.z.object({role:f.z.literal("user"),content:f.z.union([f.z.string(),f.z.array(f.z.union([Z,ee,et]))]),experimental_providerMetadata:Q.optional()}),eo=f.z.object({role:f.z.literal("assistant"),content:f.z.union([f.z.string(),f.z.array(f.z.union([Z,er]))]),experimental_providerMetadata:Q.optional()}),ei=f.z.object({role:f.z.literal("tool"),content:f.z.array(ea),experimental_providerMetadata:Q.optional()}),el=f.z.union([en,es,eo,ei]);function eu(e){return"object"==typeof e&&null!==e&&("function"===e.role||"data"===e.role||"toolInvocations"in e||"experimental_attachments"in e)?"has-ui-specific-parts":"object"==typeof e&&null!==e&&"content"in e&&(Array.isArray(e.content)||"experimental_providerMetadata"in e)?"has-core-specific-parts":"object"==typeof e&&null!==e&&"role"in e&&"content"in e&&"string"==typeof e.content&&["system","user","assistant","tool"].includes(e.role)?"message":"other"}var ec="AI_MessageConversionError",em=`vercel.ai.error.${ec}`,ed=Symbol.for(em),ep=class extends p.bD{constructor({originalMessage:e,message:t}){super({name:ec,message:t}),this[l]=!0,this.originalMessage=e}static isInstance(e){return p.bD.hasMarker(e,em)}};l=ed;function eh(e,{contentType:t,dataStreamVersion:r}){var a;let n=new Headers(null!=(a=null==e?void 0:e.headers)?a:{});return n.has("Content-Type")||n.set("Content-Type",t),void 0!==r&&n.set("X-Vercel-AI-Data-Stream",r),n}var ef="AI_NoObjectGeneratedError",ey=`vercel.ai.error.${ef}`,ev=Symbol.for(ey),eg=class extends p.bD{constructor({message:e="No object generated."}={}){super({name:ef,message:e}),this[u]=!0}static isInstance(e){return p.bD.hasMarker(e,ey)}static isNoObjectGeneratedError(e){return e instanceof Error&&e.name===ef}toJSON(){return{name:this.name,cause:this.cause,message:this.message,stack:this.stack}}};function eb(e,t){let r=e.pipeThrough(new TransformStream(t));return r[Symbol.asyncIterator]=()=>{let e=r.getReader();return{async next(){let{done:t,value:r}=await e.read();return t?{done:!0,value:void 0}:{done:!1,value:r}}}},r}u=ev;var ew={type:"no-schema",jsonSchema:void 0,validatePartialResult:({value:e,textDelta:t})=>({success:!0,value:{partial:e,textDelta:t}}
1),validateFinalResult:e=>void 0===e?{success:!1,error:new eg}:{success:!0,value:e},createElementStream(){throw new p.b8({functionality:"element streams in no-schema mode"})}},ez=e=>({type:"object",jsonSchema:e.jsonSchema,validatePartialResult:({value:e,textDelta:t})=>({success:!0,value:{partial:e,textDelta:t}}),validateFinalResult:t=>safeValidateTypes2({value:t,schema:e}),createElementStream(){throw new UnsupportedFunctionalityError({functionality:"element streams in object mode"})}}),eS=e=>{let{$schema:t,...r}=e.jsonSchema;return{type:"enum",jsonSchema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:r}},required:["elements"],additionalProperties:!1},validatePartialResult({value:t,latestObject:r,isFirstDelta:a,isFinalDelta:n}){var s;if(!isJSONObject(t)||!isJSONArray(t.elements))return{success:!1,error:new TypeValidationError({value:t,cause:"value must be an object that contains an array of elements"})};let o=t.elements,i=[];for(let t=0;t<o.length;t++){let r=safeValidateTypes2({value:o[t],schema:e});if(t!==o.length-1||n){if(!r.success)return r;i.push(r.value)}}let l=null!=(s=null==r?void 0:r.length)?s:0,u="";return a&&(u+="["),l>0&&(u+=","),u+=i.slice(l).map(e=>JSON.stringify(e)).join(","),n&&(u+="]"),{success:!0,value:{partial:i,textDelta:u}}},validateFinalResult(t){if(!isJSONObject(t)||!isJSONArray(t.elements))return{success:!1,error:new TypeValidationError({value:t,cause:"value must be an object that contains an array of elements"})};let r=t.elements;for(let t of r){let r=safeValidateTypes2({value:t,schema:e});if(!r.success)return r}return{success:!0,value:r}},createElementStream(e){let t=0;return eb(e,{transform(e,r){switch(e.type){case"object":{let a=e.object;for(;t<a.length;t++)r.enqueue(a[t]);break}case"text-delta":case"finish":break;case"error":r.error(e.error);break;default:throw Error(`Unsupported chunk type: ${e}`)}}})}}},ex=e=>({type:"enum",jsonSchema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:e}},required:["result"],additionalProperties:!1},validateFinalResult(t){if(!isJSONObject(t)||"string"!=typeof t.result)return{success:!1,error:new TypeValidationError({value:t,cause:'value must be an object that contains a string in the "result" property.'})};let r=t.result;return e.includes(r)?{success:!0,value:r}:{success:!1,error:new TypeValidationError({value:t,cause:"value must be a string in the enum"})}},validatePartialResult(){throw new UnsupportedFunctionalityError({functionality:"partial results in enum mode"})},createElementStream(){throw new UnsupportedFunctionalityError({functionality:"element streams in enum mode"})}});function eT(){let e,t;return{promise:new Promise((r,a)=>{e=r,t=a}),resolve:e,reject:t}}(0,h.hK)({prefix:"aiobj",size:24});var eE=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get value(){return this.promise||(this.promise=new Promise((e,t)=>{"resolved"===this.status.type?e(this.status.value):"rejected"===this.status.type&&t(this.status.error),this._resolve=e,this._reject=t})),this.promise}resolve(e){var t;this.status={type:"resolved",value:e},this.promise&&(null==(t=this._resolve)||t.call(this,e))}reject(e){var t;this.status={type:"rejected",error:e},this.promise&&(null==(t=this._reject)||t.call(this,e))}};function ej(e,{contentType:t,dataStreamVersion:r}){let a={};if((null==e?void 0:e.headers)!=null)for(let[t,r]of Object.entries(e.headers))a[t]=r;return null==a["Content-Type"]&&(a["Content-Type"]=t),void 0!==r&&(a["X-Vercel-AI-Data-Stream"]=r),a}function eI({response:e,status:t,statusText:r,headers:a,stream:n}){e.writeHead(null!=t?t:200,r,a);let s=n.getReader();(async()=>{try{for(;;){let{done:t,value:r}=await s.read();if(t)break;e.write(r)}}catch(e){throw e}finally{e.end()}})()}(0,h.hK)({prefix:"aiobj",size:24});var eA="AI_InvalidToolArgumentsError",ek=`vercel.ai.error.${eA}`,eN=Symbol.for(ek),e_=class extends p.bD{constructor({toolArgs:e,toolName:t,cause:r,message:a=`Invalid arguments for tool ${t}: ${(0,p.u1)(r)}`}){super({name:eA,message:a,cause:r}),this[c]=!0,this.toolArgs=e,this.toolName=t}static isInstance(e){return p.bD.hasMarker(e,ek)}static isInvalidToolArgumentsError(e){return e instanceof Error&&e.name===eA&&"string"==typeof e.toolName&&"string"==typeof e.toolArgs}toJSON(){return{name:this.name,message:this.message,cause:this.cause,stack:this.stack,toolName:this.toolName,toolArgs:this.toolArgs}}};c=eN;var e$="AI_NoSuchToolError",eD=`vercel.ai.error.${e$}`,eR=Symbol.for(eD),eM=class extends p.bD{constructor({toolName:e,availableTools:t,message:r=`Model tried to call unavailable tool '${e}'. ${void 0===t?"No tools are available.":`Available tools: ${t.join(", ")}.`}`}){super({name:e$,message:r}),this[m]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return p.bD.hasMarker(e,eD)}static isNoSuchToolError(e){return e instanceof Error&&e.name===e$&&"toolName"in e&&void 0!=e.toolName&&"string"==typeof e.name}toJSON(){return{name:this.name,message:this.message,stack:this.stack,toolName:this.toolName,availableTools:this.availableTools}}};m=eR;var eO=/^([\s\S]*?)(\s+)(\S*)$/;(0,h.hK)({prefix:"aitxt",size:24});function eC(e,t){let r,a;let n=e.getReader(),s=t.getReader(),o=!1,i=!1;async function l(e){try{null==r&&(r=n.read());let t=await r;r=void 0,t.done?e.close():e.enqueue(t.value)}catch(t){e.error(t)}}async function u(e){try{null==a&&(a=s.read());let t=await a;a=void 0,t.done?e.close():e.enqueue(t.value)}catch(t){e.error(t)}}return new ReadableStream({async pull(e){try{if(o){await u(e);return}if(i){await l(e);return}null==r&&(r=n.read()),null==a&&(a=s.read());let{result:t,reader:c}=await Promise.race([r.then(e=>({result:e,reader:n})),a.then(e=>({result:e,reader:s}))]);t.done||e.enqueue(t.value),c===n?(r=void 0,t.done&&(await u(e),o=!0)):(a=void 0,t.done&&(i=!0,await l(e)))}catch(t){e.error(t)}},cancel(){n.cancel(),s.cancel()}})}(0,h.hK)({prefix:"aitxt",size:24});
1var eP="AI_NoSuchProviderError",eJ=`vercel.ai.error.${eP}`,eF=Symbol.for(eJ),eq=class extends p.eM{constructor({modelId:e,modelType:t,providerId:r,availableProviders:a,message:n=`No such provider: ${r} (available providers: ${a.join()})`}){super({errorName:eP,modelId:e,modelType:t,message:n}),this[d]=!0,this.providerId=r,this.availableProviders=a}static isInstance(e){return p.bD.hasMarker(e,eJ)}static isNoSuchProviderError(e){return e instanceof Error&&e.name===eP&&"string"==typeof e.providerId&&Array.isArray(e.availableProviders)}toJSON(){return{name:this.name,message:this.message,stack:this.stack,modelId:this.modelId,modelType:this.modelType,providerId:this.providerId,availableProviders:this.availableProviders}}};d=eF;function eU(e){let t=new TextEncoder,r="",a=e||{};return new TransformStream({async start(){a.onStart&&await a.onStart()},async transform(e,n){let s="string"==typeof e?e:e.content;n.enqueue(t.encode(s)),r+=s,a.onToken&&await a.onToken(s),a.onText&&"string"==typeof e&&await a.onText(e)},async flush(){let e="experimental_onFunctionCall"in a;a.onCompletion&&await a.onCompletion(r),a.onFinal&&!e&&await a.onFinal(r)}})}function eV(){let e=!0;return t=>(e&&(t=t.trimStart())&&(e=!1),t)}function eB(e){let t=e[Symbol.asyncIterator]();return new ReadableStream({async pull(e){let{done:r,value:a}=await t.next();r?e.close():e.enqueue(a)},async cancel(e){var r;await (null==(r=t.return)?void 0:r.call(t,e))}})}function eL(){let e=new TextEncoder,t=new TextDecoder;return new TransformStream({transform:async(r,a)=>{let n=t.decode(r);a.enqueue(e.encode((0,y.L6)("text",n)))}})}async function*eK(e,t){var r,a;let n=new TextDecoder;for await(let s of null!=(r=e.body)?r:[]){let e=null==(a=s.chunk)?void 0:a.bytes;if(null!=e){let r=t(JSON.parse(n.decode(e)));null!=r&&(yield r)}}}var eG=new TextDecoder("utf-8");async function eH(e,t){for(let r of e){let{text:e,is_finished:a}=JSON.parse(r);a||t.enqueue(e)}}function eW(e,t){return eX(e,t)}function eX(e,t){return e.pipeThrough(new TransformStream({transform:async(e,t)=>{var r;if("string"==typeof e){t.enqueue(e);return}if("event"in e){"on_chat_model_stream"===e.event&&eY(null==(r=e.data)?void 0:r.chunk,t);return}eY(e,t)}})).pipeThrough(eU(t)).pipeThrough(eL())}function eQ(e,t){var r;let a=eX(e,null==t?void 0:t.callbacks),n=null==t?void 0:t.data,s=null==t?void 0:t.init;return new Response(n?eC(n.stream,a):a,{status:null!=(r=null==s?void 0:s.status)?r:200,statusText:null==s?void 0:s.statusText,headers:eh(s,{contentType:"text/plain; charset=utf-8",dataStreamVersion:"v1"})})}function eY(e,t){if("string"==typeof e.content)t.enqueue(e.content);else for(let r of e.content)"text"===r.type&&t.enqueue(r.text)}function eZ(e,t){return(function(e){let t=e[Symbol.asyncIterator](),r=eV();return new ReadableStream({async pull(e){var a;let{value:n,done:s}=await t.next();if(s){e.close();return}let o=r(null!=(a=n.delta)?a:"");o&&e.enqueue(o)}})})(e).pipeThrough(eU(t)).pipeThrough(eL())}function e0(e,t={}){var r;let{init:a,data:n,callbacks:s}=t,o=eZ(e,s);return new Response(n?eC(n.stream,o):o,{status:null!=(r=null==a?void 0:a.status)?r:200,statusText:null==a?void 0:a.statusText,headers:eh(a,{contentType:"text/plain; charset=utf-8",dataStreamVersion:"v1"})})}g({},{toAIStream:()=>eW,toDataStream:()=>eX,toDataStreamResponse:()=>eQ}),g({},{toDataStream:()=>eZ,toDataStreamResponse:()=>e0});function e1(e){return"choices"in e&&e.choices&&e.choices[0]&&"delta"in e.choices[0]}Symbol("internal_openai_fn_messages"),Response}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.