@gram-ai/elements 1.18.4 → 1.18.5
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/elements.cjs +3 -3
- package/dist/elements.js +8 -8
- package/dist/lib/api.d.ts +2 -0
- package/dist/lib/api.test.d.ts +1 -0
- package/package.json +4 -1
package/dist/elements.cjs
CHANGED
|
@@ -85,15 +85,15 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
85
85
|
|
|
86
86
|
`)},flush(e){e.enqueue(`data: [DONE]
|
|
87
87
|
|
|
88
|
-
`)}})}},y$={"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive","x-vercel-ai-ui-message-stream":"v1","x-accel-buffering":"no"};function Bz({status:e,statusText:t,headers:r,stream:o,consumeSseStream:n}){let i=o.pipeThrough(new v$);if(n){const[a,s]=i.tee();i=a,n({stream:s})}return new Response(i.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:Wa(r,y$)})}function Jz({originalMessages:e,responseMessageId:t}){if(e==null)return;const r=e[e.length-1];return r?.role==="assistant"?r.id:typeof t=="function"?t():t}function Wz(e){return e.type.startsWith("data-")}function b$(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const r={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=t[o];if(n===void 0)continue;const i=o in e?e[o]:void 0,a=n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?r[o]=b$(i,n):r[o]=n}return r}function Hz(e){const t=["ROOT"];let r=-1,o=null;function n(l,u,c){switch(l){case'"':{r=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{r=u,o=u,t.pop(),t.push(c),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(c),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":{r=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{r=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{r=u,t.pop(),t.push(c),t.push("INSIDE_ARRAY_START");break}}}function i(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":n(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{r=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{n(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),r=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:r=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{r=l,t.pop();break}default:{r=l,n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=l,t.pop();break}default:{r=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),r=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(o,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):r=l;break}}}let s=e.slice(0,r+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{s+='"';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":{s+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{s+="]";break}case"INSIDE_LITERAL":{const c=e.substring(o,e.length);"true".startsWith(c)?s+="true".slice(c.length):"false".startsWith(c)?s+="false".slice(c.length):"null".startsWith(c)&&(s+="null".slice(c.length))}}return s}async function _$(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await xr({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await xr({text:Hz(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function Rs(e){return e.type.startsWith("data-")}function zs(e){return e.type==="text"}function Ms(e){return e.type==="file"}function Nf(e){return e.type==="reasoning"}function Fr(e){return e.type.startsWith("tool-")}function Hc(e){return e.type==="dynamic-tool"}function Pf(e){return Fr(e)||Hc(e)}function Mi(e){return e.type.split("-").slice(1).join("-")}function Gz(e){return Hc(e)?e.toolName:Mi(e)}function Kz({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Yz({stream:e,messageMetadataSchema:t,dataPartSchemas:r,runUpdateMessageJob:o,onError:n,onToolCall:i,onData:a}){return e.pipeThrough(new TransformStream({async transform(s,l){await o(async({state:u,write:c})=>{var d,f,p,g;function h(v){const N=u.message.parts.filter(Fr).find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function b(v){const N=u.message.parts.filter(I=>I.type==="dynamic-tool").find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function y(v){var k;const N=u.message.parts.find(z=>Fr(z)&&z.toolCallId===v.toolCallId),I=v,O=N;N!=null?(N.state=v.state,O.input=I.input,O.output=I.output,O.errorText=I.errorText,O.rawInput=I.rawInput,O.preliminary=I.preliminary,O.providerExecuted=(k=I.providerExecuted)!=null?k:N.providerExecuted,I.providerMetadata!=null&&N.state==="input-available"&&(N.callProviderMetadata=I.providerMetadata)):u.message.parts.push({type:`tool-${v.toolName}`,toolCallId:v.toolCallId,state:v.state,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}function x(v){var k,N;const I=u.message.parts.find(F=>F.type==="dynamic-tool"&&F.toolCallId===v.toolCallId),O=v,z=I;I!=null?(I.state=v.state,z.toolName=v.toolName,z.input=O.input,z.output=O.output,z.errorText=O.errorText,z.rawInput=(k=O.rawInput)!=null?k:z.rawInput,z.preliminary=O.preliminary,z.providerExecuted=(N=O.providerExecuted)!=null?N:I.providerExecuted,O.providerMetadata!=null&&I.state==="input-available"&&(I.callProviderMetadata=O.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:v.toolName,toolCallId:v.toolCallId,state:v.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,...O.providerMetadata!=null?{callProviderMetadata:O.providerMetadata}:{}})}async function $(v){if(v!=null){const k=u.message.metadata!=null?b$(u.message.metadata,v):v;t!=null&&await xu({value:k,schema:t}),u.message.metadata=k}}switch(s.type){case"text-start":{const v={type:"text",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeTextParts[s.id]=v,u.message.parts.push(v),c();break}case"text-delta":{const v=u.activeTextParts[s.id];v.text+=s.delta,v.providerMetadata=(d=s.providerMetadata)!=null?d:v.providerMetadata,c();break}case"text-end":{const v=u.activeTextParts[s.id];v.state="done",v.providerMetadata=(f=s.providerMetadata)!=null?f:v.providerMetadata,delete u.activeTextParts[s.id],c();break}case"reasoning-start":{const v={type:"reasoning",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeReasoningParts[s.id]=v,u.message.parts.push(v),c();break}case"reasoning-delta":{const v=u.activeReasoningParts[s.id];v.text+=s.delta,v.providerMetadata=(p=s.providerMetadata)!=null?p:v.providerMetadata,c();break}case"reasoning-end":{const v=u.activeReasoningParts[s.id];v.providerMetadata=(g=s.providerMetadata)!=null?g:v.providerMetadata,v.state="done",delete u.activeReasoningParts[s.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:s.mediaType,url:s.url}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:s.sourceId,url:s.url,title:s.title,providerMetadata:s.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:s.sourceId,mediaType:s.mediaType,title:s.title,filename:s.filename,providerMetadata:s.providerMetadata}),c();break}case"tool-input-start":{const v=u.message.parts.filter(Fr);u.partialToolCalls[s.toolCallId]={text:"",toolName:s.toolName,index:v.length,dynamic:s.dynamic},s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}),c();break}case"tool-input-delta":{const v=u.partialToolCalls[s.toolCallId];v.text+=s.inputTextDelta;const{value:k}=await _$(v.text);v.dynamic?x({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}):y({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}),c();break}case"tool-input-available":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c(),i&&!s.providerExecuted&&await i({toolCall:s});break}case"tool-input-error":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:void 0,rawInput:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c();break}case"tool-output-available":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-available",input:v.input,output:s.output,preliminary:s.preliminary})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Mi(v),state:"output-available",input:v.input,output:s.output,providerExecuted:s.providerExecuted,preliminary:s.preliminary})}c();break}case"tool-output-error":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-error",input:v.input,errorText:s.errorText,providerExecuted:s.providerExecuted})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Mi(v),state:"output-error",input:v.input,rawInput:v.rawInput,errorText:s.errorText,providerExecuted:s.providerExecuted})}c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{s.messageId!=null&&(u.message.id=s.messageId),await $(s.messageMetadata),(s.messageId!=null||s.messageMetadata!=null)&&c();break}case"finish":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"message-metadata":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"error":{n?.(new Error(s.errorText));break}default:if(Wz(s)){r?.[s.type]!=null&&await xu({value:s.data,schema:r[s.type]});const v=s;if(v.transient){a?.(v);break}const k=v.id!=null?u.message.parts.find(N=>v.type===N.type&&v.id===N.id):void 0;k!=null?k.data=v.data:u.message.parts.push(v),a?.(v),c()}}l.enqueue(s)})}}))}function Qz({messageId:e,originalMessages:t=[],onFinish:r,onError:o,stream:n}){let i=t?.[t.length-1];i?.role!=="assistant"?i=void 0:e=i.id;let a=!1;const s=n.pipeThrough(new TransformStream({transform(f,p){if(f.type==="start"){const g=f;g.messageId==null&&e!=null&&(g.messageId=e)}f.type==="abort"&&(a=!0),p.enqueue(f)}}));if(r==null)return s;const l=Kz({lastMessage:i?structuredClone(i):void 0,messageId:e??""}),u=async f=>{await f({state:l,write:()=>{}})};let c=!1;const d=async()=>{if(c||!r)return;c=!0;const f=l.message.id===i?.id;await r({isAborted:a,isContinuation:f,responseMessage:l.message,messages:[...f?t.slice(0,-1):t,l.message]})};return Yz({stream:s,runUpdateMessageJob:u,onError:o}).pipeThrough(new TransformStream({transform(f,p){p.enqueue(f)},async cancel(){await d()},async flush(){await d()}}))}function Xz({response:e,status:t,statusText:r,headers:o,stream:n,consumeSseStream:i}){let a=n.pipeThrough(new v$);if(i){const[s,l]=a.tee();a=s,i({stream:l})}g$({response:e,status:t,statusText:r,headers:Object.fromEntries(Wa(o,y$).entries()),stream:a.pipeThrough(new TextEncoderStream)})}function Wo(e){const t=e.pipeThrough(new TransformStream);return t[Symbol.asyncIterator]=function(){const r=this.getReader();let o=!1;async function n(i){var a;o=!0;try{i&&await((a=r.cancel)==null?void 0:a.call(r))}finally{try{r.releaseLock()}catch{}}}return{async next(){if(o)return{done:!0,value:void 0};const{done:i,value:a}=await r.read();return i?(await n(!0),{done:!0,value:void 0}):{done:!1,value:a}},async return(){return await n(!0),{done:!0,value:void 0}},async throw(i){throw await n(!0),i}}},t}async function eM({stream:e,onError:t}){const r=e.getReader();try{for(;;){const{done:o}=await r.read();if(o)break}}catch(o){t?.(o)}finally{r.releaseLock()}}function Cf(){let e,t;return{promise:new Promise((o,n)=>{e=o,t=n}),resolve:e,reject:t}}function tM(){let e=[],t=null,r=!1,o=Cf();const n=()=>{r=!0,o.resolve(),e.forEach(a=>a.cancel()),e=[],t?.close()},i=async()=>{if(r&&e.length===0){t?.close();return}if(e.length===0)return o=Cf(),await o.promise,i();try{const{value:a,done:s}=await e[0].read();s?(e.shift(),e.length>0?await i():r&&t?.close()):t?.enqueue(a)}catch(a){t?.error(a),e.shift(),n()}};return{stream:new ReadableStream({start(a){t=a},pull:i,async cancel(){for(const a of e)await a.cancel();e=[],r=!0}}),addStream:a=>{if(r)throw new Error("Cannot add inner stream: outer stream is closed");e.push(a.getReader()),o.resolve()},close:()=>{r=!0,o.resolve(),e.length===0&&t?.close()},terminate:n}}var Ho=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise?this._promise:(this._promise=new Promise((e,t)=>{this.status.type==="resolved"?e(this.status.value):this.status.type==="rejected"&&t(this.status.error),this._resolve=e,this._reject=t}),this._promise)}resolve(e){var t;this.status={type:"resolved",value:e},this._promise&&((t=this._resolve)==null||t.call(this,e))}reject(e){var t;this.status={type:"rejected",error:e},this._promise&&((t=this._reject)==null||t.call(this,e))}};function rM(){var e,t;return(t=(e=globalThis?.performance)==null?void 0:e.now())!=null?t:Date.now()}function nM({tools:e,generatorStream:t,tracer:r,telemetry:o,system:n,messages:i,abortSignal:a,repairToolCall:s,experimental_context:l}){let u=null;const c=new ReadableStream({start(y){u=y}}),d=new Set,f=new Map;let p=!1,g;function h(){p&&d.size===0&&(g!=null&&u.enqueue(g),u.close())}const b=new TransformStream({async transform(y,x){const $=y.type;switch($){case"stream-start":case"text-start":case"text-delta":case"text-end":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"tool-input-start":case"tool-input-delta":case"tool-input-end":case"source":case"response-metadata":case"error":case"raw":{x.enqueue(y);break}case"file":{x.enqueue({type:"file",file:new Uz({data:y.data,mediaType:y.mediaType})});break}case"finish":{g={type:"finish",finishReason:y.finishReason,usage:y.usage,providerMetadata:y.providerMetadata};break}case"tool-call":{try{const v=await Lz({toolCall:y,tools:e,repairToolCall:s,system:n,messages:i});if(x.enqueue(v),v.invalid){u.enqueue({type:"tool-error",toolCallId:v.toolCallId,toolName:v.toolName,input:v.input,error:ux(v.error),dynamic:!0});break}const k=e[v.toolName];if(f.set(v.toolCallId,v.input),k.onInputAvailable!=null&&await k.onInputAvailable({input:v.input,toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}),k.execute!=null&&v.providerExecuted!==!0){const N=J1();d.add(N),Ou({name:"ai.toolCall",attributes:Lr({telemetry:o,attributes:{...Tu({operationId:"ai.toolCall",telemetry:o}),"ai.toolCall.name":v.toolName,"ai.toolCall.id":v.toolCallId,"ai.toolCall.args":{output:()=>JSON.stringify(v.input)}}}),tracer:r,fn:async I=>{let O;try{const z=iR({execute:k.execute.bind(k),input:v.input,options:{toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}});for await(const F of z)u.enqueue({...v,type:"tool-result",output:F.output,...F.type==="preliminary"&&{preliminary:!0}}),F.type==="final"&&(O=F.output)}catch(z){f$(I,z),u.enqueue({...v,type:"tool-error",error:z}),d.delete(N),h();return}d.delete(N),h();try{I.setAttributes(Lr({telemetry:o,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(O)}}}))}catch{}}})}}catch(v){u.enqueue({type:"error",error:v})}break}case"tool-result":{const v=y.toolName;y.isError?u.enqueue({type:"tool-error",toolCallId:y.toolCallId,toolName:v,input:f.get(y.toolCallId),providerExecuted:y.providerExecuted,error:y.result}):x.enqueue({type:"tool-result",toolCallId:y.toolCallId,toolName:v,input:f.get(y.toolCallId),output:y.result,providerExecuted:y.providerExecuted});break}default:{const v=$;throw new Error(`Unhandled chunk type: ${v}`)}}},flush(){p=!0,h()}});return new ReadableStream({async start(y){return Promise.all([t.pipeThrough(b).pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){}})),c.pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){y.close()}}))])}})}var oM=No({prefix:"aitxt",size:24});function iM({model:e,tools:t,toolChoice:r,system:o,prompt:n,messages:i,maxRetries:a,abortSignal:s,headers:l,stopWhen:u=h$(1),experimental_output:c,experimental_telemetry:d,prepareStep:f,providerOptions:p,experimental_activeTools:g,activeTools:h=g,experimental_repairToolCall:b,experimental_transform:y,experimental_download:x,includeRawChunks:$=!1,onChunk:v,onError:k=({error:V})=>{console.error(V)},onFinish:N,onAbort:I,onStepFinish:O,experimental_context:z,_internal:{now:F=rM,generateId:te=oM,currentDate:ie=()=>new Date}={},...J}){return new sM({model:s$(e),telemetry:d,headers:l,settings:J,maxRetries:a,abortSignal:s,system:o,prompt:n,messages:i,tools:t,toolChoice:r,transforms:kf(y),activeTools:h,repairToolCall:b,stopConditions:kf(u),output:c,providerOptions:p,prepareStep:f,includeRawChunks:$,onChunk:v,onError:k,onFinish:N,onAbort:I,onStepFinish:O,now:F,currentDate:ie,generateId:te,experimental_context:z,download:x})}function aM(e){if(!e)return new TransformStream({transform(a,s){s.enqueue({part:a,partialOutput:void 0})}});let t,r="",o="",n="";function i({controller:a,partialOutput:s=void 0}){a.enqueue({part:{type:"text-delta",id:t,text:o},partialOutput:s}),o=""}return new TransformStream({async transform(a,s){if(a.type==="finish-step"&&o.length>0&&i({controller:s}),a.type!=="text-delta"&&a.type!=="text-start"&&a.type!=="text-end"){s.enqueue({part:a,partialOutput:void 0});return}if(t==null)t=a.id;else if(a.id!==t){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-start"){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-end"){o.length>0&&i({controller:s}),s.enqueue({part:a,partialOutput:void 0});return}r+=a.text,o+=a.text;const l=await e.parsePartial({text:r});if(l!=null){const u=JSON.stringify(l.partial);u!==n&&(i({controller:s,partialOutput:l.partial}),n=u)}}})}var sM=class{constructor({model:e,telemetry:t,headers:r,settings:o,maxRetries:n,abortSignal:i,system:a,prompt:s,messages:l,tools:u,toolChoice:c,transforms:d,activeTools:f,repairToolCall:p,stopConditions:g,output:h,providerOptions:b,prepareStep:y,includeRawChunks:x,now:$,currentDate:v,generateId:k,onChunk:N,onError:I,onFinish:O,onAbort:z,onStepFinish:F,experimental_context:te,download:ie}){this._totalUsage=new Ho,this._finishReason=new Ho,this._steps=new Ho,this.output=h,this.includeRawChunks=x,this.tools=u;let J,V=[];const we=[];let oe,de,K={},fe=[];const B=[];let Ue,ye={},Le={};const U=new TransformStream({async transform(Ee,Te){var Ae,ae,ft,mn;Te.enqueue(Ee);const{part:Z}=Ee;if((Z.type==="text-delta"||Z.type==="reasoning-delta"||Z.type==="source"||Z.type==="tool-call"||Z.type==="tool-result"||Z.type==="tool-input-start"||Z.type==="tool-input-delta"||Z.type==="raw")&&await N?.({chunk:Z}),Z.type==="error"&&await I({error:Tz(Z.error)}),Z.type==="text-start"&&(ye[Z.id]={type:"text",text:"",providerMetadata:Z.providerMetadata},V.push(ye[Z.id])),Z.type==="text-delta"){const Ie=ye[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`text part ${Z.id} not found`},partialOutput:void 0});return}Ie.text+=Z.text,Ie.providerMetadata=(Ae=Z.providerMetadata)!=null?Ae:Ie.providerMetadata}if(Z.type==="text-end"){const Ie=ye[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`text part ${Z.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(ae=Z.providerMetadata)!=null?ae:Ie.providerMetadata,delete ye[Z.id]}if(Z.type==="reasoning-start"&&(Le[Z.id]={type:"reasoning",text:"",providerMetadata:Z.providerMetadata},V.push(Le[Z.id])),Z.type==="reasoning-delta"){const Ie=Le[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`reasoning part ${Z.id} not found`},partialOutput:void 0});return}Ie.text+=Z.text,Ie.providerMetadata=(ft=Z.providerMetadata)!=null?ft:Ie.providerMetadata}if(Z.type==="reasoning-end"){const Ie=Le[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`reasoning part ${Z.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(mn=Z.providerMetadata)!=null?mn:Ie.providerMetadata,delete Le[Z.id]}if(Z.type==="file"&&V.push({type:"file",file:Z.file}),Z.type==="source"&&V.push(Z),Z.type==="tool-call"&&V.push(Z),Z.type==="tool-result"&&!Z.preliminary&&V.push(Z),Z.type==="tool-error"&&V.push(Z),Z.type==="start-step"&&(K=Z.request,fe=Z.warnings),Z.type==="finish-step"){const Ie=Of({content:V,tools:u}),hn=new Zz({content:V,finishReason:Z.finishReason,usage:Z.usage,warnings:fe,request:K,response:{...Z.response,messages:[...we,...Ie]},providerMetadata:Z.providerMetadata});await F?.(hn),UR(fe),B.push(hn),V=[],Le={},ye={},we.push(...Ie),J.resolve()}Z.type==="finish"&&(de=Z.totalUsage,oe=Z.finishReason)},async flush(Ee){try{if(B.length===0){const ft=new VR({message:"No output generated. Check the stream for errors."});je._finishReason.reject(ft),je._totalUsage.reject(ft),je._steps.reject(ft);return}const Te=oe??"unknown",Ae=de??{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};je._finishReason.resolve(Te),je._totalUsage.resolve(Ae),je._steps.resolve(B);const ae=B[B.length-1];await O?.({finishReason:Te,totalUsage:Ae,usage:ae.usage,content:ae.content,text:ae.text,reasoningText:ae.reasoningText,reasoning:ae.reasoning,files:ae.files,sources:ae.sources,toolCalls:ae.toolCalls,staticToolCalls:ae.staticToolCalls,dynamicToolCalls:ae.dynamicToolCalls,toolResults:ae.toolResults,staticToolResults:ae.staticToolResults,dynamicToolResults:ae.dynamicToolResults,request:ae.request,response:ae.response,warnings:ae.warnings,providerMetadata:ae.providerMetadata,steps:B}),Ue.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Te,"ai.response.text":{output:()=>ae.text},"ai.response.toolCalls":{output:()=>{var ft;return(ft=ae.toolCalls)!=null&&ft.length?JSON.stringify(ae.toolCalls):void 0}},"ai.response.providerMetadata":JSON.stringify(ae.providerMetadata),"ai.usage.inputTokens":Ae.inputTokens,"ai.usage.outputTokens":Ae.outputTokens,"ai.usage.totalTokens":Ae.totalTokens,"ai.usage.reasoningTokens":Ae.reasoningTokens,"ai.usage.cachedInputTokens":Ae.cachedInputTokens}}))}catch(Te){Ee.error(Te)}finally{Ue.end()}}}),Q=tM();this.addStream=Q.addStream,this.closeStream=Q.close;const me=Q.stream.getReader();let xe=new ReadableStream({async start(Ee){Ee.enqueue({type:"start"})},async pull(Ee){function Te(){z?.({steps:B}),Ee.enqueue({type:"abort"}),Ee.close()}try{const{done:Ae,value:ae}=await me.read();if(Ae){Ee.close();return}if(i?.aborted){Te();return}Ee.enqueue(ae)}catch(Ae){wr(Ae)&&i?.aborted?Te():Ee.error(Ae)}},cancel(Ee){return Q.stream.cancel(Ee)}});for(const Ee of d)xe=xe.pipeThrough(Ee({tools:u,stopStream(){Q.terminate()}}));this.baseStream=xe.pipeThrough(aM(h)).pipeThrough(U);const{maxRetries:Ro,retry:ss}=Mz({maxRetries:n,abortSignal:i}),fn=Cz(t),pt=hz(o),zo=Oz({model:e,telemetry:t,headers:r,settings:{...pt,maxRetries:Ro}}),je=this;Ou({name:"ai.streamText",attributes:Lr({telemetry:t,attributes:{...Tu({operationId:"ai.streamText",telemetry:t}),...zo,"ai.prompt":{input:()=>JSON.stringify({system:a,prompt:s,messages:l})}}}),tracer:fn,endWhenDone:!1,fn:async Ee=>{Ue=Ee;async function Te({currentStep:Ae,responseMessages:ae,usage:ft}){var mn,Z,Ie,hn,Id;const kd=je.includeRawChunks;J=new Ho;const Ed=await Ez({system:a,prompt:s,messages:l}),gn=[...Ed.messages,...ae],Et=await y?.({model:e,steps:B,stepNumber:B.length,messages:gn}),Nr=s$((mn=Et?.model)!=null?mn:e),Td=await dz({prompt:{system:(Z=Et?.system)!=null?Z:Ed.system,messages:(Ie=Et?.messages)!=null?Ie:gn},supportedUrls:await Nr.supportedUrls,download:ie}),{toolChoice:us,tools:ls}=vz({tools:u,toolChoice:(hn=Et?.toolChoice)!=null?hn:c,activeTools:(Id=Et?.activeTools)!=null?Id:f}),{result:{stream:g0,response:Od,request:Nd},doStreamSpan:Pr,startTimestampMs:Pd}=await ss(()=>Ou({name:"ai.streamText.doStream",attributes:Lr({telemetry:t,attributes:{...Tu({operationId:"ai.streamText.doStream",telemetry:t}),...zo,"ai.model.provider":Nr.provider,"ai.model.id":Nr.modelId,"ai.prompt.messages":{input:()=>jz(Td)},"ai.prompt.tools":{input:()=>ls?.map(W=>JSON.stringify(W))},"ai.prompt.toolChoice":{input:()=>us!=null?JSON.stringify(us):void 0},"gen_ai.system":Nr.provider,"gen_ai.request.model":Nr.modelId,"gen_ai.request.frequency_penalty":pt.frequencyPenalty,"gen_ai.request.max_tokens":pt.maxOutputTokens,"gen_ai.request.presence_penalty":pt.presencePenalty,"gen_ai.request.stop_sequences":pt.stopSequences,"gen_ai.request.temperature":pt.temperature,"gen_ai.request.top_k":pt.topK,"gen_ai.request.top_p":pt.topP}}),tracer:fn,endWhenDone:!1,fn:async W=>({startTimestampMs:$(),doStreamSpan:W,result:await Nr.doStream({...pt,tools:ls,toolChoice:us,responseFormat:h?.responseFormat,prompt:Td,providerOptions:b,abortSignal:i,headers:r,includeRawChunks:kd})})})),v0=nM({tools:u,generatorStream:g0,tracer:fn,telemetry:t,system:a,messages:gn,repairToolCall:p,abortSignal:i,experimental_context:te}),y0=Nd??{},Mo=[],cs=[];let ds;const ps={};let Cr="unknown",mt={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},fs,Cd=!0,Tt={id:k(),timestamp:v(),modelId:e.modelId},jd="";je.addStream(v0.pipeThrough(new TransformStream({async transform(W,Re){var vn,yn,Do,Ut;if(W.type==="stream-start"){ds=W.warnings;return}if(Cd){const Ze=$()-Pd;Cd=!1,Pr.addEvent("ai.stream.firstChunk",{"ai.response.msToFirstChunk":Ze}),Pr.setAttributes({"ai.response.msToFirstChunk":Ze}),Re.enqueue({type:"start-step",request:y0,warnings:ds??[]})}const Ad=W.type;switch(Ad){case"text-start":case"text-end":{Re.enqueue(W);break}case"text-delta":{W.delta.length>0&&(Re.enqueue({type:"text-delta",id:W.id,text:W.delta,providerMetadata:W.providerMetadata}),jd+=W.delta);break}case"reasoning-start":case"reasoning-end":{Re.enqueue(W);break}case"reasoning-delta":{Re.enqueue({type:"reasoning-delta",id:W.id,text:W.delta,providerMetadata:W.providerMetadata});break}case"tool-call":{Re.enqueue(W),Mo.push(W);break}case"tool-result":{Re.enqueue(W),W.preliminary||cs.push(W);break}case"tool-error":{Re.enqueue(W),cs.push(W);break}case"response-metadata":{Tt={id:(vn=W.id)!=null?vn:Tt.id,timestamp:(yn=W.timestamp)!=null?yn:Tt.timestamp,modelId:(Do=W.modelId)!=null?Do:Tt.modelId};break}case"finish":{mt=W.usage,Cr=W.finishReason,fs=W.providerMetadata;const Ze=$()-Pd;Pr.addEvent("ai.stream.finish"),Pr.setAttributes({"ai.response.msToFinish":Ze,"ai.response.avgOutputTokensPerSecond":1e3*((Ut=mt.outputTokens)!=null?Ut:0)/Ze});break}case"file":{Re.enqueue(W);break}case"source":{Re.enqueue(W);break}case"tool-input-start":{ps[W.id]=W.toolName;const Ze=u?.[W.toolName];Ze?.onInputStart!=null&&await Ze.onInputStart({toolCallId:W.id,messages:gn,abortSignal:i,experimental_context:te}),Re.enqueue({...W,dynamic:Ze?.type==="dynamic"});break}case"tool-input-end":{delete ps[W.id],Re.enqueue(W);break}case"tool-input-delta":{const Ze=ps[W.id],ms=u?.[Ze];ms?.onInputDelta!=null&&await ms.onInputDelta({inputTextDelta:W.delta,toolCallId:W.id,messages:gn,abortSignal:i,experimental_context:te}),Re.enqueue(W);break}case"error":{Re.enqueue(W),Cr="error";break}case"raw":{kd&&Re.enqueue(W);break}default:{const Ze=Ad;throw new Error(`Unknown chunk type: ${Ze}`)}}},async flush(W){const Re=Mo.length>0?JSON.stringify(Mo):void 0;try{Pr.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Cr,"ai.response.text":{output:()=>jd},"ai.response.toolCalls":{output:()=>Re},"ai.response.id":Tt.id,"ai.response.model":Tt.modelId,"ai.response.timestamp":Tt.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(fs),"ai.usage.inputTokens":mt.inputTokens,"ai.usage.outputTokens":mt.outputTokens,"ai.usage.totalTokens":mt.totalTokens,"ai.usage.reasoningTokens":mt.reasoningTokens,"ai.usage.cachedInputTokens":mt.cachedInputTokens,"gen_ai.response.finish_reasons":[Cr],"gen_ai.response.id":Tt.id,"gen_ai.response.model":Tt.modelId,"gen_ai.usage.input_tokens":mt.inputTokens,"gen_ai.usage.output_tokens":mt.outputTokens}}))}catch{}finally{Pr.end()}W.enqueue({type:"finish-step",finishReason:Cr,usage:mt,providerMetadata:fs,response:{...Tt,headers:Od?.headers}});const vn=Az(ft,mt);await J.promise;const yn=Mo.filter(Ut=>Ut.providerExecuted!==!0),Do=cs.filter(Ut=>Ut.providerExecuted!==!0);if(yn.length>0&&Do.length===yn.length&&!await Fz({stopConditions:g,steps:B})){ae.push(...Of({content:B[B.length-1].content,tools:u}));try{await Te({currentStep:Ae+1,responseMessages:ae,usage:vn})}catch(Ut){W.enqueue({type:"error",error:Ut}),je.closeStream()}}else W.enqueue({type:"finish",finishReason:Cr,totalUsage:vn}),je.closeStream()}})))}await Te({currentStep:0,responseMessages:[],usage:{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0}})}}).catch(Ee=>{je.addStream(new ReadableStream({start(Te){Te.enqueue({type:"error",error:Ee}),Te.close()}})),je.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(e=>e[e.length-1])}get content(){return this.finalStep.then(e=>e.content)}get warnings(){return this.finalStep.then(e=>e.warnings)}get providerMetadata(){return this.finalStep.then(e=>e.providerMetadata)}get text(){return this.finalStep.then(e=>e.text)}get reasoningText(){return this.finalStep.then(e=>e.reasoningText)}get reasoning(){return this.finalStep.then(e=>e.reasoning)}get sources(){return this.finalStep.then(e=>e.sources)}get files(){return this.finalStep.then(e=>e.files)}get toolCalls(){return this.finalStep.then(e=>e.toolCalls)}get staticToolCalls(){return this.finalStep.then(e=>e.staticToolCalls)}get dynamicToolCalls(){return this.finalStep.then(e=>e.dynamicToolCalls)}get toolResults(){return this.finalStep.then(e=>e.toolResults)}get staticToolResults(){return this.finalStep.then(e=>e.staticToolResults)}get dynamicToolResults(){return this.finalStep.then(e=>e.dynamicToolResults)}get usage(){return this.finalStep.then(e=>e.usage)}get request(){return this.finalStep.then(e=>e.request)}get response(){return this.finalStep.then(e=>e.response)}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}teeStream(){const[e,t]=this.baseStream.tee();return this.baseStream=t,e}get textStream(){return Wo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){e.type==="text-delta"&&t.enqueue(e.text)}})))}get fullStream(){return Wo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){t.enqueue(e)}})))}async consumeStream(e){var t;try{await eM({stream:this.fullStream,onError:e?.onError})}catch(r){(t=e?.onError)==null||t.call(e,r)}}get experimental_partialOutputStream(){if(this.output==null)throw new zR;return Wo(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:e},t){e!=null&&t.enqueue(e)}})))}toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n=!0,sendSources:i=!1,sendStart:a=!0,sendFinish:s=!0,onError:l=sn}={}){const u=t!=null?Jz({originalMessages:e,responseMessageId:t}):void 0,c={},d=p=>{var g,h;const b=c[p];return((h=(g=this.tools)==null?void 0:g[b])==null?void 0:h.type)==="dynamic"?!0:void 0},f=this.fullStream.pipeThrough(new TransformStream({transform:async(p,g)=>{const h=o?.({part:p}),b=p.type;switch(b){case"text-start":{g.enqueue({type:"text-start",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"text-delta":{g.enqueue({type:"text-delta",id:p.id,delta:p.text,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"text-end":{g.enqueue({type:"text-end",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-start":{g.enqueue({type:"reasoning-start",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-delta":{n&&g.enqueue({type:"reasoning-delta",id:p.id,delta:p.text,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-end":{g.enqueue({type:"reasoning-end",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"file":{g.enqueue({type:"file",mediaType:p.file.mediaType,url:`data:${p.file.mediaType};base64,${p.file.base64}`});break}case"source":{i&&p.sourceType==="url"&&g.enqueue({type:"source-url",sourceId:p.id,url:p.url,title:p.title,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}}),i&&p.sourceType==="document"&&g.enqueue({type:"source-document",sourceId:p.id,mediaType:p.mediaType,title:p.title,filename:p.filename,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"tool-input-start":{c[p.id]=p.toolName;const y=d(p.id);g.enqueue({type:"tool-input-start",toolCallId:p.id,toolName:p.toolName,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"tool-input-delta":{g.enqueue({type:"tool-input-delta",toolCallId:p.id,inputTextDelta:p.delta});break}case"tool-call":{c[p.toolCallId]=p.toolName;const y=d(p.toolCallId);p.invalid?g.enqueue({type:"tool-input-error",toolCallId:p.toolCallId,toolName:p.toolName,input:p.input,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{},...y!=null?{dynamic:y}:{},errorText:l(p.error)}):g.enqueue({type:"tool-input-available",toolCallId:p.toolCallId,toolName:p.toolName,input:p.input,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{},...y!=null?{dynamic:y}:{}});break}case"tool-result":{const y=d(p.toolCallId);g.enqueue({type:"tool-output-available",toolCallId:p.toolCallId,output:p.output,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.preliminary!=null?{preliminary:p.preliminary}:{},...y!=null?{dynamic:y}:{}});break}case"tool-error":{const y=d(p.toolCallId);g.enqueue({type:"tool-output-error",toolCallId:p.toolCallId,errorText:l(p.error),...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"error":{g.enqueue({type:"error",errorText:l(p.error)});break}case"start-step":{g.enqueue({type:"start-step"});break}case"finish-step":{g.enqueue({type:"finish-step"});break}case"start":{a&&g.enqueue({type:"start",...h!=null?{messageMetadata:h}:{},...u!=null?{messageId:u}:{}});break}case"finish":{s&&g.enqueue({type:"finish",...h!=null?{messageMetadata:h}:{}});break}case"abort":{g.enqueue(p);break}case"tool-input-end":break;case"raw":break;default:{const y=b;throw new Error(`Unknown chunk type: ${y}`)}}h!=null&&b!=="start"&&b!=="finish"&&g.enqueue({type:"message-metadata",messageMetadata:h})}}));return Wo(Qz({stream:f,messageId:u??t?.(),originalMessages:e,onFinish:r,onError:l}))}pipeUIMessageStreamToResponse(e,{originalMessages:t,generateMessageId:r,onFinish:o,messageMetadata:n,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u,...c}={}){Xz({response:e,stream:this.toUIMessageStream({originalMessages:t,generateMessageId:r,onFinish:o,messageMetadata:n,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u}),...c})}pipeTextStreamToResponse(e,t){Vz({response:e,textStream:this.textStream,...t})}toUIMessageStreamResponse({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n,sendSources:i,sendFinish:a,sendStart:s,onError:l,...u}={}){return Bz({stream:this.toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n,sendSources:i,sendFinish:a,sendStart:s,onError:l}),...u})}toTextStreamResponse(e){return qz({textStream:this.textStream,...e})}};function uM(e,t){const r=[];t?.ignoreIncompleteToolCalls&&(e=e.map(o=>({...o,parts:o.parts.filter(n=>!Pf(n)||n.state!=="input-streaming"&&n.state!=="input-available")})));for(const o of e)switch(o.role){case"system":{const n=o.parts.filter(a=>a.type==="text"),i=n.reduce((a,s)=>s.providerMetadata!=null?{...a,...s.providerMetadata}:a,{});r.push({role:"system",content:n.map(a=>a.text).join(""),...Object.keys(i).length>0?{providerOptions:i}:{}});break}case"user":{r.push({role:"user",content:o.parts.map(n=>{var i;if(zs(n))return{type:"text",text:n.text,...n.providerMetadata!=null?{providerOptions:n.providerMetadata}:{}};if(Ms(n))return{type:"file",mediaType:n.mediaType,filename:n.filename,data:n.url,...n.providerMetadata!=null?{providerOptions:n.providerMetadata}:{}};if(Rs(n))return(i=t?.convertDataPart)==null?void 0:i.call(t,n)}).filter(n=>n!=null)});break}case"assistant":{if(o.parts!=null){let n=function(){var a,s,l;if(i.length===0)return;const u=[];for(const d of i)if(zs(d))u.push({type:"text",text:d.text,...d.providerMetadata!=null?{providerOptions:d.providerMetadata}:{}});else if(Ms(d))u.push({type:"file",mediaType:d.mediaType,filename:d.filename,data:d.url});else if(Nf(d))u.push({type:"reasoning",text:d.text,providerOptions:d.providerMetadata});else if(Hc(d)){const f=d.toolName;d.state!=="input-streaming"&&u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:f,input:d.input,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}})}else if(Fr(d)){const f=Mi(d);d.state!=="input-streaming"&&(u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:f,input:d.state==="output-error"?(a=d.input)!=null?a:d.rawInput:d.input,providerExecuted:d.providerExecuted,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}}),d.providerExecuted===!0&&(d.state==="output-available"||d.state==="output-error")&&u.push({type:"tool-result",toolCallId:d.toolCallId,toolName:f,output:Nn({output:d.state==="output-error"?d.errorText:d.output,tool:(s=t?.tools)==null?void 0:s[f],errorMode:d.state==="output-error"?"json":"none"})}))}else if(Rs(d)){const f=(l=t?.convertDataPart)==null?void 0:l.call(t,d);f!=null&&u.push(f)}else{const f=d;throw new Error(`Unsupported part: ${f}`)}r.push({role:"assistant",content:u});const c=i.filter(d=>Fr(d)&&d.providerExecuted!==!0||d.type==="dynamic-tool");c.length>0&&r.push({role:"tool",content:c.map(d=>{var f;switch(d.state){case"output-error":case"output-available":{const p=Gz(d);return{type:"tool-result",toolCallId:d.toolCallId,toolName:p,output:Nn({output:d.state==="output-error"?d.errorText:d.output,tool:(f=t?.tools)==null?void 0:f[p],errorMode:d.state==="output-error"?"text":"none"})}}default:return null}}).filter(d=>d!=null)}),i=[]},i=[];for(const a of o.parts)zs(a)||Nf(a)||Ms(a)||Pf(a)||Rs(a)?i.push(a):a.type==="step-start"&&n();n();break}break}default:{const n=o.role;throw new QR({originalMessage:o,message:`Unsupported role: ${n}`})}}return r}No({prefix:"aiobj",size:24});No({prefix:"aiobj",size:24});var lM={};AR(lM,{object:()=>dM,text:()=>cM});var cM=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),dM=({schema:e})=>{const t=Ja(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:r}){const o=await _$(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const n=o.state;throw new Error(`Unsupported parse state: ${n}`)}}},async parseOutput({text:r},o){const n=await xr({text:r});if(!n.success)throw new Sf({message:"No object generated: could not parse the response.",cause:n.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await sr({value:n.value,schema:t});if(!i.success)throw new Sf({message:"No object generated: response did not match schema.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}},pM={word:/\S+\s+/m,line:/\n+/m};function fM({delayInMs:e=10,chunking:t="word",_internal:{delay:r=sx}={}}={}){let o;if(typeof t=="function")o=n=>{const i=t(n);if(i==null)return null;if(!i.length)throw new Error("Chunking function must return a non-empty string.");if(!n.startsWith(i))throw new Error(`Chunking function must return a match that is a prefix of the buffer. Received: "${i}" expected to start with "${n}"`);return i};else{const n=typeof t=="string"?pM[t]:t;if(n==null)throw new Vi({argument:"chunking",message:`Chunking must be "word" or "line" or a RegExp. Received: ${t}`});o=i=>{const a=n.exec(i);return a?i.slice(0,a.index)+a?.[0]:null}}return()=>{let n="",i="";return new TransformStream({async transform(a,s){if(a.type!=="text-delta"){n.length>0&&(s.enqueue({type:"text-delta",text:n,id:i}),n=""),s.enqueue(a);return}a.id!==i&&n.length>0&&(s.enqueue({type:"text-delta",text:n,id:i}),n=""),n+=a.text,i=a.id;let l;for(;(l=o(n))!=null;)s.enqueue({type:"text-delta",text:l,id:i}),n=n.slice(l.length),await r(e)}})}}function Ds(e){return!!e&&"UNSAFE_apiKey"in e}const mM=({getSession:e,projectSlug:t,enabled:r})=>{const o=q_(),n=["chatSession",t],i=o.getQueryState(n),a=i?.data!==void 0,s=i?.dataUpdatedAt??0,u=a&&Date.now()-s>1/0,c=!a||u,{data:d}=B_({queryKey:n,queryFn:()=>e({projectSlug:t}),enabled:r&&c&&e!==null,staleTime:1/0,gcTime:1/0});return d??null};async function hM(e){return(await(await fetch("/chat/session",{method:"POST",headers:{"Gram-Project":e.projectSlug}})).json()).client_token}const gM=({projectSlug:e,auth:t})=>{const r=mM({enabled:!Ds(t),getSession:Ds(t)?null:t?.sessionFn??hM,projectSlug:e});return Ds(t)?{headers:{"Gram-Project":e,"Gram-Key":t.UNSAFE_apiKey},isLoading:!1}:r?{headers:{"Gram-Project":e,"Gram-Chat-Session":r},isLoading:!1}:{isLoading:!0}};function vM({children:e}){const[t,r]=D.useState(new Map),[o,n]=D.useState(new Set),i=D.useCallback((d,f,p)=>new Promise(g=>{const h={toolCallId:f,toolName:d,args:p,resolve:g};r(b=>{const y=new Map(b);return y.set(f,h),y})}),[]),a=D.useCallback(d=>{n(f=>{const p=new Set(f);return p.add(d),p})},[]),s=D.useCallback(d=>{r(f=>{const p=f.get(d);if(p){p.resolve(!0);const g=new Map(f);return g.delete(d),g}return f})},[]),l=D.useCallback(d=>{r(f=>{const p=f.get(d);if(p){p.resolve(!1);const g=new Map(f);return g.delete(d),g}return f})},[]),u=D.useCallback(d=>o.has(d),[o]),c=D.useCallback(d=>t.get(d),[t]);return m.jsx(T.ToolApprovalContext.Provider,{value:{pendingApprovals:t,approvedTools:o,requestApproval:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l,isToolApproved:u,getPendingApproval:c},children:e})}const yM="You are a helpful assistant that can answer questions and help with tasks.";function bM(e,t){return`
|
|
89
|
-
${
|
|
88
|
+
`)}})}},y$={"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive","x-vercel-ai-ui-message-stream":"v1","x-accel-buffering":"no"};function Bz({status:e,statusText:t,headers:r,stream:o,consumeSseStream:n}){let i=o.pipeThrough(new v$);if(n){const[a,s]=i.tee();i=a,n({stream:s})}return new Response(i.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:Wa(r,y$)})}function Jz({originalMessages:e,responseMessageId:t}){if(e==null)return;const r=e[e.length-1];return r?.role==="assistant"?r.id:typeof t=="function"?t():t}function Wz(e){return e.type.startsWith("data-")}function b$(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const r={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=t[o];if(n===void 0)continue;const i=o in e?e[o]:void 0,a=n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?r[o]=b$(i,n):r[o]=n}return r}function Hz(e){const t=["ROOT"];let r=-1,o=null;function n(l,u,c){switch(l){case'"':{r=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{r=u,o=u,t.pop(),t.push(c),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(c),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":{r=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{r=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{r=u,t.pop(),t.push(c),t.push("INSIDE_ARRAY_START");break}}}function i(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":n(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{r=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{n(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),r=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:r=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{r=l,t.pop();break}default:{r=l,n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=l,t.pop();break}default:{r=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),r=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(o,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):r=l;break}}}let s=e.slice(0,r+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{s+='"';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":{s+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{s+="]";break}case"INSIDE_LITERAL":{const c=e.substring(o,e.length);"true".startsWith(c)?s+="true".slice(c.length):"false".startsWith(c)?s+="false".slice(c.length):"null".startsWith(c)&&(s+="null".slice(c.length))}}return s}async function _$(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await xr({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await xr({text:Hz(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function Rs(e){return e.type.startsWith("data-")}function zs(e){return e.type==="text"}function Ms(e){return e.type==="file"}function Nf(e){return e.type==="reasoning"}function Fr(e){return e.type.startsWith("tool-")}function Hc(e){return e.type==="dynamic-tool"}function Pf(e){return Fr(e)||Hc(e)}function Mi(e){return e.type.split("-").slice(1).join("-")}function Gz(e){return Hc(e)?e.toolName:Mi(e)}function Kz({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Yz({stream:e,messageMetadataSchema:t,dataPartSchemas:r,runUpdateMessageJob:o,onError:n,onToolCall:i,onData:a}){return e.pipeThrough(new TransformStream({async transform(s,l){await o(async({state:u,write:c})=>{var d,f,p,g;function h(v){const N=u.message.parts.filter(Fr).find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function b(v){const N=u.message.parts.filter(I=>I.type==="dynamic-tool").find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function y(v){var k;const N=u.message.parts.find(z=>Fr(z)&&z.toolCallId===v.toolCallId),I=v,O=N;N!=null?(N.state=v.state,O.input=I.input,O.output=I.output,O.errorText=I.errorText,O.rawInput=I.rawInput,O.preliminary=I.preliminary,O.providerExecuted=(k=I.providerExecuted)!=null?k:N.providerExecuted,I.providerMetadata!=null&&N.state==="input-available"&&(N.callProviderMetadata=I.providerMetadata)):u.message.parts.push({type:`tool-${v.toolName}`,toolCallId:v.toolCallId,state:v.state,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}function x(v){var k,N;const I=u.message.parts.find(F=>F.type==="dynamic-tool"&&F.toolCallId===v.toolCallId),O=v,z=I;I!=null?(I.state=v.state,z.toolName=v.toolName,z.input=O.input,z.output=O.output,z.errorText=O.errorText,z.rawInput=(k=O.rawInput)!=null?k:z.rawInput,z.preliminary=O.preliminary,z.providerExecuted=(N=O.providerExecuted)!=null?N:I.providerExecuted,O.providerMetadata!=null&&I.state==="input-available"&&(I.callProviderMetadata=O.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:v.toolName,toolCallId:v.toolCallId,state:v.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,...O.providerMetadata!=null?{callProviderMetadata:O.providerMetadata}:{}})}async function $(v){if(v!=null){const k=u.message.metadata!=null?b$(u.message.metadata,v):v;t!=null&&await xu({value:k,schema:t}),u.message.metadata=k}}switch(s.type){case"text-start":{const v={type:"text",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeTextParts[s.id]=v,u.message.parts.push(v),c();break}case"text-delta":{const v=u.activeTextParts[s.id];v.text+=s.delta,v.providerMetadata=(d=s.providerMetadata)!=null?d:v.providerMetadata,c();break}case"text-end":{const v=u.activeTextParts[s.id];v.state="done",v.providerMetadata=(f=s.providerMetadata)!=null?f:v.providerMetadata,delete u.activeTextParts[s.id],c();break}case"reasoning-start":{const v={type:"reasoning",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeReasoningParts[s.id]=v,u.message.parts.push(v),c();break}case"reasoning-delta":{const v=u.activeReasoningParts[s.id];v.text+=s.delta,v.providerMetadata=(p=s.providerMetadata)!=null?p:v.providerMetadata,c();break}case"reasoning-end":{const v=u.activeReasoningParts[s.id];v.providerMetadata=(g=s.providerMetadata)!=null?g:v.providerMetadata,v.state="done",delete u.activeReasoningParts[s.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:s.mediaType,url:s.url}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:s.sourceId,url:s.url,title:s.title,providerMetadata:s.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:s.sourceId,mediaType:s.mediaType,title:s.title,filename:s.filename,providerMetadata:s.providerMetadata}),c();break}case"tool-input-start":{const v=u.message.parts.filter(Fr);u.partialToolCalls[s.toolCallId]={text:"",toolName:s.toolName,index:v.length,dynamic:s.dynamic},s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}),c();break}case"tool-input-delta":{const v=u.partialToolCalls[s.toolCallId];v.text+=s.inputTextDelta;const{value:k}=await _$(v.text);v.dynamic?x({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}):y({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}),c();break}case"tool-input-available":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c(),i&&!s.providerExecuted&&await i({toolCall:s});break}case"tool-input-error":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:void 0,rawInput:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c();break}case"tool-output-available":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-available",input:v.input,output:s.output,preliminary:s.preliminary})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Mi(v),state:"output-available",input:v.input,output:s.output,providerExecuted:s.providerExecuted,preliminary:s.preliminary})}c();break}case"tool-output-error":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-error",input:v.input,errorText:s.errorText,providerExecuted:s.providerExecuted})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Mi(v),state:"output-error",input:v.input,rawInput:v.rawInput,errorText:s.errorText,providerExecuted:s.providerExecuted})}c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{s.messageId!=null&&(u.message.id=s.messageId),await $(s.messageMetadata),(s.messageId!=null||s.messageMetadata!=null)&&c();break}case"finish":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"message-metadata":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"error":{n?.(new Error(s.errorText));break}default:if(Wz(s)){r?.[s.type]!=null&&await xu({value:s.data,schema:r[s.type]});const v=s;if(v.transient){a?.(v);break}const k=v.id!=null?u.message.parts.find(N=>v.type===N.type&&v.id===N.id):void 0;k!=null?k.data=v.data:u.message.parts.push(v),a?.(v),c()}}l.enqueue(s)})}}))}function Qz({messageId:e,originalMessages:t=[],onFinish:r,onError:o,stream:n}){let i=t?.[t.length-1];i?.role!=="assistant"?i=void 0:e=i.id;let a=!1;const s=n.pipeThrough(new TransformStream({transform(f,p){if(f.type==="start"){const g=f;g.messageId==null&&e!=null&&(g.messageId=e)}f.type==="abort"&&(a=!0),p.enqueue(f)}}));if(r==null)return s;const l=Kz({lastMessage:i?structuredClone(i):void 0,messageId:e??""}),u=async f=>{await f({state:l,write:()=>{}})};let c=!1;const d=async()=>{if(c||!r)return;c=!0;const f=l.message.id===i?.id;await r({isAborted:a,isContinuation:f,responseMessage:l.message,messages:[...f?t.slice(0,-1):t,l.message]})};return Yz({stream:s,runUpdateMessageJob:u,onError:o}).pipeThrough(new TransformStream({transform(f,p){p.enqueue(f)},async cancel(){await d()},async flush(){await d()}}))}function Xz({response:e,status:t,statusText:r,headers:o,stream:n,consumeSseStream:i}){let a=n.pipeThrough(new v$);if(i){const[s,l]=a.tee();a=s,i({stream:l})}g$({response:e,status:t,statusText:r,headers:Object.fromEntries(Wa(o,y$).entries()),stream:a.pipeThrough(new TextEncoderStream)})}function Wo(e){const t=e.pipeThrough(new TransformStream);return t[Symbol.asyncIterator]=function(){const r=this.getReader();let o=!1;async function n(i){var a;o=!0;try{i&&await((a=r.cancel)==null?void 0:a.call(r))}finally{try{r.releaseLock()}catch{}}}return{async next(){if(o)return{done:!0,value:void 0};const{done:i,value:a}=await r.read();return i?(await n(!0),{done:!0,value:void 0}):{done:!1,value:a}},async return(){return await n(!0),{done:!0,value:void 0}},async throw(i){throw await n(!0),i}}},t}async function eM({stream:e,onError:t}){const r=e.getReader();try{for(;;){const{done:o}=await r.read();if(o)break}}catch(o){t?.(o)}finally{r.releaseLock()}}function Cf(){let e,t;return{promise:new Promise((o,n)=>{e=o,t=n}),resolve:e,reject:t}}function tM(){let e=[],t=null,r=!1,o=Cf();const n=()=>{r=!0,o.resolve(),e.forEach(a=>a.cancel()),e=[],t?.close()},i=async()=>{if(r&&e.length===0){t?.close();return}if(e.length===0)return o=Cf(),await o.promise,i();try{const{value:a,done:s}=await e[0].read();s?(e.shift(),e.length>0?await i():r&&t?.close()):t?.enqueue(a)}catch(a){t?.error(a),e.shift(),n()}};return{stream:new ReadableStream({start(a){t=a},pull:i,async cancel(){for(const a of e)await a.cancel();e=[],r=!0}}),addStream:a=>{if(r)throw new Error("Cannot add inner stream: outer stream is closed");e.push(a.getReader()),o.resolve()},close:()=>{r=!0,o.resolve(),e.length===0&&t?.close()},terminate:n}}var Ho=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise?this._promise:(this._promise=new Promise((e,t)=>{this.status.type==="resolved"?e(this.status.value):this.status.type==="rejected"&&t(this.status.error),this._resolve=e,this._reject=t}),this._promise)}resolve(e){var t;this.status={type:"resolved",value:e},this._promise&&((t=this._resolve)==null||t.call(this,e))}reject(e){var t;this.status={type:"rejected",error:e},this._promise&&((t=this._reject)==null||t.call(this,e))}};function rM(){var e,t;return(t=(e=globalThis?.performance)==null?void 0:e.now())!=null?t:Date.now()}function nM({tools:e,generatorStream:t,tracer:r,telemetry:o,system:n,messages:i,abortSignal:a,repairToolCall:s,experimental_context:l}){let u=null;const c=new ReadableStream({start(y){u=y}}),d=new Set,f=new Map;let p=!1,g;function h(){p&&d.size===0&&(g!=null&&u.enqueue(g),u.close())}const b=new TransformStream({async transform(y,x){const $=y.type;switch($){case"stream-start":case"text-start":case"text-delta":case"text-end":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"tool-input-start":case"tool-input-delta":case"tool-input-end":case"source":case"response-metadata":case"error":case"raw":{x.enqueue(y);break}case"file":{x.enqueue({type:"file",file:new Uz({data:y.data,mediaType:y.mediaType})});break}case"finish":{g={type:"finish",finishReason:y.finishReason,usage:y.usage,providerMetadata:y.providerMetadata};break}case"tool-call":{try{const v=await Lz({toolCall:y,tools:e,repairToolCall:s,system:n,messages:i});if(x.enqueue(v),v.invalid){u.enqueue({type:"tool-error",toolCallId:v.toolCallId,toolName:v.toolName,input:v.input,error:ux(v.error),dynamic:!0});break}const k=e[v.toolName];if(f.set(v.toolCallId,v.input),k.onInputAvailable!=null&&await k.onInputAvailable({input:v.input,toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}),k.execute!=null&&v.providerExecuted!==!0){const N=J1();d.add(N),Ou({name:"ai.toolCall",attributes:Lr({telemetry:o,attributes:{...Tu({operationId:"ai.toolCall",telemetry:o}),"ai.toolCall.name":v.toolName,"ai.toolCall.id":v.toolCallId,"ai.toolCall.args":{output:()=>JSON.stringify(v.input)}}}),tracer:r,fn:async I=>{let O;try{const z=iR({execute:k.execute.bind(k),input:v.input,options:{toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}});for await(const F of z)u.enqueue({...v,type:"tool-result",output:F.output,...F.type==="preliminary"&&{preliminary:!0}}),F.type==="final"&&(O=F.output)}catch(z){f$(I,z),u.enqueue({...v,type:"tool-error",error:z}),d.delete(N),h();return}d.delete(N),h();try{I.setAttributes(Lr({telemetry:o,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(O)}}}))}catch{}}})}}catch(v){u.enqueue({type:"error",error:v})}break}case"tool-result":{const v=y.toolName;y.isError?u.enqueue({type:"tool-error",toolCallId:y.toolCallId,toolName:v,input:f.get(y.toolCallId),providerExecuted:y.providerExecuted,error:y.result}):x.enqueue({type:"tool-result",toolCallId:y.toolCallId,toolName:v,input:f.get(y.toolCallId),output:y.result,providerExecuted:y.providerExecuted});break}default:{const v=$;throw new Error(`Unhandled chunk type: ${v}`)}}},flush(){p=!0,h()}});return new ReadableStream({async start(y){return Promise.all([t.pipeThrough(b).pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){}})),c.pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){y.close()}}))])}})}var oM=No({prefix:"aitxt",size:24});function iM({model:e,tools:t,toolChoice:r,system:o,prompt:n,messages:i,maxRetries:a,abortSignal:s,headers:l,stopWhen:u=h$(1),experimental_output:c,experimental_telemetry:d,prepareStep:f,providerOptions:p,experimental_activeTools:g,activeTools:h=g,experimental_repairToolCall:b,experimental_transform:y,experimental_download:x,includeRawChunks:$=!1,onChunk:v,onError:k=({error:V})=>{console.error(V)},onFinish:N,onAbort:I,onStepFinish:O,experimental_context:z,_internal:{now:F=rM,generateId:te=oM,currentDate:ie=()=>new Date}={},...J}){return new sM({model:s$(e),telemetry:d,headers:l,settings:J,maxRetries:a,abortSignal:s,system:o,prompt:n,messages:i,tools:t,toolChoice:r,transforms:kf(y),activeTools:h,repairToolCall:b,stopConditions:kf(u),output:c,providerOptions:p,prepareStep:f,includeRawChunks:$,onChunk:v,onError:k,onFinish:N,onAbort:I,onStepFinish:O,now:F,currentDate:ie,generateId:te,experimental_context:z,download:x})}function aM(e){if(!e)return new TransformStream({transform(a,s){s.enqueue({part:a,partialOutput:void 0})}});let t,r="",o="",n="";function i({controller:a,partialOutput:s=void 0}){a.enqueue({part:{type:"text-delta",id:t,text:o},partialOutput:s}),o=""}return new TransformStream({async transform(a,s){if(a.type==="finish-step"&&o.length>0&&i({controller:s}),a.type!=="text-delta"&&a.type!=="text-start"&&a.type!=="text-end"){s.enqueue({part:a,partialOutput:void 0});return}if(t==null)t=a.id;else if(a.id!==t){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-start"){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-end"){o.length>0&&i({controller:s}),s.enqueue({part:a,partialOutput:void 0});return}r+=a.text,o+=a.text;const l=await e.parsePartial({text:r});if(l!=null){const u=JSON.stringify(l.partial);u!==n&&(i({controller:s,partialOutput:l.partial}),n=u)}}})}var sM=class{constructor({model:e,telemetry:t,headers:r,settings:o,maxRetries:n,abortSignal:i,system:a,prompt:s,messages:l,tools:u,toolChoice:c,transforms:d,activeTools:f,repairToolCall:p,stopConditions:g,output:h,providerOptions:b,prepareStep:y,includeRawChunks:x,now:$,currentDate:v,generateId:k,onChunk:N,onError:I,onFinish:O,onAbort:z,onStepFinish:F,experimental_context:te,download:ie}){this._totalUsage=new Ho,this._finishReason=new Ho,this._steps=new Ho,this.output=h,this.includeRawChunks=x,this.tools=u;let J,V=[];const we=[];let oe,de,K={},fe=[];const B=[];let Ue,ye={},Le={};const U=new TransformStream({async transform(Ee,Te){var Ae,ae,ft,mn;Te.enqueue(Ee);const{part:Z}=Ee;if((Z.type==="text-delta"||Z.type==="reasoning-delta"||Z.type==="source"||Z.type==="tool-call"||Z.type==="tool-result"||Z.type==="tool-input-start"||Z.type==="tool-input-delta"||Z.type==="raw")&&await N?.({chunk:Z}),Z.type==="error"&&await I({error:Tz(Z.error)}),Z.type==="text-start"&&(ye[Z.id]={type:"text",text:"",providerMetadata:Z.providerMetadata},V.push(ye[Z.id])),Z.type==="text-delta"){const Ie=ye[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`text part ${Z.id} not found`},partialOutput:void 0});return}Ie.text+=Z.text,Ie.providerMetadata=(Ae=Z.providerMetadata)!=null?Ae:Ie.providerMetadata}if(Z.type==="text-end"){const Ie=ye[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`text part ${Z.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(ae=Z.providerMetadata)!=null?ae:Ie.providerMetadata,delete ye[Z.id]}if(Z.type==="reasoning-start"&&(Le[Z.id]={type:"reasoning",text:"",providerMetadata:Z.providerMetadata},V.push(Le[Z.id])),Z.type==="reasoning-delta"){const Ie=Le[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`reasoning part ${Z.id} not found`},partialOutput:void 0});return}Ie.text+=Z.text,Ie.providerMetadata=(ft=Z.providerMetadata)!=null?ft:Ie.providerMetadata}if(Z.type==="reasoning-end"){const Ie=Le[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`reasoning part ${Z.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(mn=Z.providerMetadata)!=null?mn:Ie.providerMetadata,delete Le[Z.id]}if(Z.type==="file"&&V.push({type:"file",file:Z.file}),Z.type==="source"&&V.push(Z),Z.type==="tool-call"&&V.push(Z),Z.type==="tool-result"&&!Z.preliminary&&V.push(Z),Z.type==="tool-error"&&V.push(Z),Z.type==="start-step"&&(K=Z.request,fe=Z.warnings),Z.type==="finish-step"){const Ie=Of({content:V,tools:u}),hn=new Zz({content:V,finishReason:Z.finishReason,usage:Z.usage,warnings:fe,request:K,response:{...Z.response,messages:[...we,...Ie]},providerMetadata:Z.providerMetadata});await F?.(hn),UR(fe),B.push(hn),V=[],Le={},ye={},we.push(...Ie),J.resolve()}Z.type==="finish"&&(de=Z.totalUsage,oe=Z.finishReason)},async flush(Ee){try{if(B.length===0){const ft=new VR({message:"No output generated. Check the stream for errors."});je._finishReason.reject(ft),je._totalUsage.reject(ft),je._steps.reject(ft);return}const Te=oe??"unknown",Ae=de??{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};je._finishReason.resolve(Te),je._totalUsage.resolve(Ae),je._steps.resolve(B);const ae=B[B.length-1];await O?.({finishReason:Te,totalUsage:Ae,usage:ae.usage,content:ae.content,text:ae.text,reasoningText:ae.reasoningText,reasoning:ae.reasoning,files:ae.files,sources:ae.sources,toolCalls:ae.toolCalls,staticToolCalls:ae.staticToolCalls,dynamicToolCalls:ae.dynamicToolCalls,toolResults:ae.toolResults,staticToolResults:ae.staticToolResults,dynamicToolResults:ae.dynamicToolResults,request:ae.request,response:ae.response,warnings:ae.warnings,providerMetadata:ae.providerMetadata,steps:B}),Ue.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Te,"ai.response.text":{output:()=>ae.text},"ai.response.toolCalls":{output:()=>{var ft;return(ft=ae.toolCalls)!=null&&ft.length?JSON.stringify(ae.toolCalls):void 0}},"ai.response.providerMetadata":JSON.stringify(ae.providerMetadata),"ai.usage.inputTokens":Ae.inputTokens,"ai.usage.outputTokens":Ae.outputTokens,"ai.usage.totalTokens":Ae.totalTokens,"ai.usage.reasoningTokens":Ae.reasoningTokens,"ai.usage.cachedInputTokens":Ae.cachedInputTokens}}))}catch(Te){Ee.error(Te)}finally{Ue.end()}}}),Q=tM();this.addStream=Q.addStream,this.closeStream=Q.close;const me=Q.stream.getReader();let xe=new ReadableStream({async start(Ee){Ee.enqueue({type:"start"})},async pull(Ee){function Te(){z?.({steps:B}),Ee.enqueue({type:"abort"}),Ee.close()}try{const{done:Ae,value:ae}=await me.read();if(Ae){Ee.close();return}if(i?.aborted){Te();return}Ee.enqueue(ae)}catch(Ae){wr(Ae)&&i?.aborted?Te():Ee.error(Ae)}},cancel(Ee){return Q.stream.cancel(Ee)}});for(const Ee of d)xe=xe.pipeThrough(Ee({tools:u,stopStream(){Q.terminate()}}));this.baseStream=xe.pipeThrough(aM(h)).pipeThrough(U);const{maxRetries:Ro,retry:ss}=Mz({maxRetries:n,abortSignal:i}),fn=Cz(t),pt=hz(o),zo=Oz({model:e,telemetry:t,headers:r,settings:{...pt,maxRetries:Ro}}),je=this;Ou({name:"ai.streamText",attributes:Lr({telemetry:t,attributes:{...Tu({operationId:"ai.streamText",telemetry:t}),...zo,"ai.prompt":{input:()=>JSON.stringify({system:a,prompt:s,messages:l})}}}),tracer:fn,endWhenDone:!1,fn:async Ee=>{Ue=Ee;async function Te({currentStep:Ae,responseMessages:ae,usage:ft}){var mn,Z,Ie,hn,Id;const kd=je.includeRawChunks;J=new Ho;const Ed=await Ez({system:a,prompt:s,messages:l}),gn=[...Ed.messages,...ae],Et=await y?.({model:e,steps:B,stepNumber:B.length,messages:gn}),Nr=s$((mn=Et?.model)!=null?mn:e),Td=await dz({prompt:{system:(Z=Et?.system)!=null?Z:Ed.system,messages:(Ie=Et?.messages)!=null?Ie:gn},supportedUrls:await Nr.supportedUrls,download:ie}),{toolChoice:us,tools:ls}=vz({tools:u,toolChoice:(hn=Et?.toolChoice)!=null?hn:c,activeTools:(Id=Et?.activeTools)!=null?Id:f}),{result:{stream:g0,response:Od,request:Nd},doStreamSpan:Pr,startTimestampMs:Pd}=await ss(()=>Ou({name:"ai.streamText.doStream",attributes:Lr({telemetry:t,attributes:{...Tu({operationId:"ai.streamText.doStream",telemetry:t}),...zo,"ai.model.provider":Nr.provider,"ai.model.id":Nr.modelId,"ai.prompt.messages":{input:()=>jz(Td)},"ai.prompt.tools":{input:()=>ls?.map(W=>JSON.stringify(W))},"ai.prompt.toolChoice":{input:()=>us!=null?JSON.stringify(us):void 0},"gen_ai.system":Nr.provider,"gen_ai.request.model":Nr.modelId,"gen_ai.request.frequency_penalty":pt.frequencyPenalty,"gen_ai.request.max_tokens":pt.maxOutputTokens,"gen_ai.request.presence_penalty":pt.presencePenalty,"gen_ai.request.stop_sequences":pt.stopSequences,"gen_ai.request.temperature":pt.temperature,"gen_ai.request.top_k":pt.topK,"gen_ai.request.top_p":pt.topP}}),tracer:fn,endWhenDone:!1,fn:async W=>({startTimestampMs:$(),doStreamSpan:W,result:await Nr.doStream({...pt,tools:ls,toolChoice:us,responseFormat:h?.responseFormat,prompt:Td,providerOptions:b,abortSignal:i,headers:r,includeRawChunks:kd})})})),v0=nM({tools:u,generatorStream:g0,tracer:fn,telemetry:t,system:a,messages:gn,repairToolCall:p,abortSignal:i,experimental_context:te}),y0=Nd??{},Mo=[],cs=[];let ds;const ps={};let Cr="unknown",mt={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},fs,Cd=!0,Tt={id:k(),timestamp:v(),modelId:e.modelId},jd="";je.addStream(v0.pipeThrough(new TransformStream({async transform(W,Re){var vn,yn,Do,Ut;if(W.type==="stream-start"){ds=W.warnings;return}if(Cd){const Ze=$()-Pd;Cd=!1,Pr.addEvent("ai.stream.firstChunk",{"ai.response.msToFirstChunk":Ze}),Pr.setAttributes({"ai.response.msToFirstChunk":Ze}),Re.enqueue({type:"start-step",request:y0,warnings:ds??[]})}const Ad=W.type;switch(Ad){case"text-start":case"text-end":{Re.enqueue(W);break}case"text-delta":{W.delta.length>0&&(Re.enqueue({type:"text-delta",id:W.id,text:W.delta,providerMetadata:W.providerMetadata}),jd+=W.delta);break}case"reasoning-start":case"reasoning-end":{Re.enqueue(W);break}case"reasoning-delta":{Re.enqueue({type:"reasoning-delta",id:W.id,text:W.delta,providerMetadata:W.providerMetadata});break}case"tool-call":{Re.enqueue(W),Mo.push(W);break}case"tool-result":{Re.enqueue(W),W.preliminary||cs.push(W);break}case"tool-error":{Re.enqueue(W),cs.push(W);break}case"response-metadata":{Tt={id:(vn=W.id)!=null?vn:Tt.id,timestamp:(yn=W.timestamp)!=null?yn:Tt.timestamp,modelId:(Do=W.modelId)!=null?Do:Tt.modelId};break}case"finish":{mt=W.usage,Cr=W.finishReason,fs=W.providerMetadata;const Ze=$()-Pd;Pr.addEvent("ai.stream.finish"),Pr.setAttributes({"ai.response.msToFinish":Ze,"ai.response.avgOutputTokensPerSecond":1e3*((Ut=mt.outputTokens)!=null?Ut:0)/Ze});break}case"file":{Re.enqueue(W);break}case"source":{Re.enqueue(W);break}case"tool-input-start":{ps[W.id]=W.toolName;const Ze=u?.[W.toolName];Ze?.onInputStart!=null&&await Ze.onInputStart({toolCallId:W.id,messages:gn,abortSignal:i,experimental_context:te}),Re.enqueue({...W,dynamic:Ze?.type==="dynamic"});break}case"tool-input-end":{delete ps[W.id],Re.enqueue(W);break}case"tool-input-delta":{const Ze=ps[W.id],ms=u?.[Ze];ms?.onInputDelta!=null&&await ms.onInputDelta({inputTextDelta:W.delta,toolCallId:W.id,messages:gn,abortSignal:i,experimental_context:te}),Re.enqueue(W);break}case"error":{Re.enqueue(W),Cr="error";break}case"raw":{kd&&Re.enqueue(W);break}default:{const Ze=Ad;throw new Error(`Unknown chunk type: ${Ze}`)}}},async flush(W){const Re=Mo.length>0?JSON.stringify(Mo):void 0;try{Pr.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Cr,"ai.response.text":{output:()=>jd},"ai.response.toolCalls":{output:()=>Re},"ai.response.id":Tt.id,"ai.response.model":Tt.modelId,"ai.response.timestamp":Tt.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(fs),"ai.usage.inputTokens":mt.inputTokens,"ai.usage.outputTokens":mt.outputTokens,"ai.usage.totalTokens":mt.totalTokens,"ai.usage.reasoningTokens":mt.reasoningTokens,"ai.usage.cachedInputTokens":mt.cachedInputTokens,"gen_ai.response.finish_reasons":[Cr],"gen_ai.response.id":Tt.id,"gen_ai.response.model":Tt.modelId,"gen_ai.usage.input_tokens":mt.inputTokens,"gen_ai.usage.output_tokens":mt.outputTokens}}))}catch{}finally{Pr.end()}W.enqueue({type:"finish-step",finishReason:Cr,usage:mt,providerMetadata:fs,response:{...Tt,headers:Od?.headers}});const vn=Az(ft,mt);await J.promise;const yn=Mo.filter(Ut=>Ut.providerExecuted!==!0),Do=cs.filter(Ut=>Ut.providerExecuted!==!0);if(yn.length>0&&Do.length===yn.length&&!await Fz({stopConditions:g,steps:B})){ae.push(...Of({content:B[B.length-1].content,tools:u}));try{await Te({currentStep:Ae+1,responseMessages:ae,usage:vn})}catch(Ut){W.enqueue({type:"error",error:Ut}),je.closeStream()}}else W.enqueue({type:"finish",finishReason:Cr,totalUsage:vn}),je.closeStream()}})))}await Te({currentStep:0,responseMessages:[],usage:{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0}})}}).catch(Ee=>{je.addStream(new ReadableStream({start(Te){Te.enqueue({type:"error",error:Ee}),Te.close()}})),je.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(e=>e[e.length-1])}get content(){return this.finalStep.then(e=>e.content)}get warnings(){return this.finalStep.then(e=>e.warnings)}get providerMetadata(){return this.finalStep.then(e=>e.providerMetadata)}get text(){return this.finalStep.then(e=>e.text)}get reasoningText(){return this.finalStep.then(e=>e.reasoningText)}get reasoning(){return this.finalStep.then(e=>e.reasoning)}get sources(){return this.finalStep.then(e=>e.sources)}get files(){return this.finalStep.then(e=>e.files)}get toolCalls(){return this.finalStep.then(e=>e.toolCalls)}get staticToolCalls(){return this.finalStep.then(e=>e.staticToolCalls)}get dynamicToolCalls(){return this.finalStep.then(e=>e.dynamicToolCalls)}get toolResults(){return this.finalStep.then(e=>e.toolResults)}get staticToolResults(){return this.finalStep.then(e=>e.staticToolResults)}get dynamicToolResults(){return this.finalStep.then(e=>e.dynamicToolResults)}get usage(){return this.finalStep.then(e=>e.usage)}get request(){return this.finalStep.then(e=>e.request)}get response(){return this.finalStep.then(e=>e.response)}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}teeStream(){const[e,t]=this.baseStream.tee();return this.baseStream=t,e}get textStream(){return Wo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){e.type==="text-delta"&&t.enqueue(e.text)}})))}get fullStream(){return Wo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){t.enqueue(e)}})))}async consumeStream(e){var t;try{await eM({stream:this.fullStream,onError:e?.onError})}catch(r){(t=e?.onError)==null||t.call(e,r)}}get experimental_partialOutputStream(){if(this.output==null)throw new zR;return Wo(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:e},t){e!=null&&t.enqueue(e)}})))}toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n=!0,sendSources:i=!1,sendStart:a=!0,sendFinish:s=!0,onError:l=sn}={}){const u=t!=null?Jz({originalMessages:e,responseMessageId:t}):void 0,c={},d=p=>{var g,h;const b=c[p];return((h=(g=this.tools)==null?void 0:g[b])==null?void 0:h.type)==="dynamic"?!0:void 0},f=this.fullStream.pipeThrough(new TransformStream({transform:async(p,g)=>{const h=o?.({part:p}),b=p.type;switch(b){case"text-start":{g.enqueue({type:"text-start",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"text-delta":{g.enqueue({type:"text-delta",id:p.id,delta:p.text,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"text-end":{g.enqueue({type:"text-end",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-start":{g.enqueue({type:"reasoning-start",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-delta":{n&&g.enqueue({type:"reasoning-delta",id:p.id,delta:p.text,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-end":{g.enqueue({type:"reasoning-end",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"file":{g.enqueue({type:"file",mediaType:p.file.mediaType,url:`data:${p.file.mediaType};base64,${p.file.base64}`});break}case"source":{i&&p.sourceType==="url"&&g.enqueue({type:"source-url",sourceId:p.id,url:p.url,title:p.title,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}}),i&&p.sourceType==="document"&&g.enqueue({type:"source-document",sourceId:p.id,mediaType:p.mediaType,title:p.title,filename:p.filename,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"tool-input-start":{c[p.id]=p.toolName;const y=d(p.id);g.enqueue({type:"tool-input-start",toolCallId:p.id,toolName:p.toolName,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"tool-input-delta":{g.enqueue({type:"tool-input-delta",toolCallId:p.id,inputTextDelta:p.delta});break}case"tool-call":{c[p.toolCallId]=p.toolName;const y=d(p.toolCallId);p.invalid?g.enqueue({type:"tool-input-error",toolCallId:p.toolCallId,toolName:p.toolName,input:p.input,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{},...y!=null?{dynamic:y}:{},errorText:l(p.error)}):g.enqueue({type:"tool-input-available",toolCallId:p.toolCallId,toolName:p.toolName,input:p.input,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{},...y!=null?{dynamic:y}:{}});break}case"tool-result":{const y=d(p.toolCallId);g.enqueue({type:"tool-output-available",toolCallId:p.toolCallId,output:p.output,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.preliminary!=null?{preliminary:p.preliminary}:{},...y!=null?{dynamic:y}:{}});break}case"tool-error":{const y=d(p.toolCallId);g.enqueue({type:"tool-output-error",toolCallId:p.toolCallId,errorText:l(p.error),...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"error":{g.enqueue({type:"error",errorText:l(p.error)});break}case"start-step":{g.enqueue({type:"start-step"});break}case"finish-step":{g.enqueue({type:"finish-step"});break}case"start":{a&&g.enqueue({type:"start",...h!=null?{messageMetadata:h}:{},...u!=null?{messageId:u}:{}});break}case"finish":{s&&g.enqueue({type:"finish",...h!=null?{messageMetadata:h}:{}});break}case"abort":{g.enqueue(p);break}case"tool-input-end":break;case"raw":break;default:{const y=b;throw new Error(`Unknown chunk type: ${y}`)}}h!=null&&b!=="start"&&b!=="finish"&&g.enqueue({type:"message-metadata",messageMetadata:h})}}));return Wo(Qz({stream:f,messageId:u??t?.(),originalMessages:e,onFinish:r,onError:l}))}pipeUIMessageStreamToResponse(e,{originalMessages:t,generateMessageId:r,onFinish:o,messageMetadata:n,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u,...c}={}){Xz({response:e,stream:this.toUIMessageStream({originalMessages:t,generateMessageId:r,onFinish:o,messageMetadata:n,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u}),...c})}pipeTextStreamToResponse(e,t){Vz({response:e,textStream:this.textStream,...t})}toUIMessageStreamResponse({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n,sendSources:i,sendFinish:a,sendStart:s,onError:l,...u}={}){return Bz({stream:this.toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n,sendSources:i,sendFinish:a,sendStart:s,onError:l}),...u})}toTextStreamResponse(e){return qz({textStream:this.textStream,...e})}};function uM(e,t){const r=[];t?.ignoreIncompleteToolCalls&&(e=e.map(o=>({...o,parts:o.parts.filter(n=>!Pf(n)||n.state!=="input-streaming"&&n.state!=="input-available")})));for(const o of e)switch(o.role){case"system":{const n=o.parts.filter(a=>a.type==="text"),i=n.reduce((a,s)=>s.providerMetadata!=null?{...a,...s.providerMetadata}:a,{});r.push({role:"system",content:n.map(a=>a.text).join(""),...Object.keys(i).length>0?{providerOptions:i}:{}});break}case"user":{r.push({role:"user",content:o.parts.map(n=>{var i;if(zs(n))return{type:"text",text:n.text,...n.providerMetadata!=null?{providerOptions:n.providerMetadata}:{}};if(Ms(n))return{type:"file",mediaType:n.mediaType,filename:n.filename,data:n.url,...n.providerMetadata!=null?{providerOptions:n.providerMetadata}:{}};if(Rs(n))return(i=t?.convertDataPart)==null?void 0:i.call(t,n)}).filter(n=>n!=null)});break}case"assistant":{if(o.parts!=null){let n=function(){var a,s,l;if(i.length===0)return;const u=[];for(const d of i)if(zs(d))u.push({type:"text",text:d.text,...d.providerMetadata!=null?{providerOptions:d.providerMetadata}:{}});else if(Ms(d))u.push({type:"file",mediaType:d.mediaType,filename:d.filename,data:d.url});else if(Nf(d))u.push({type:"reasoning",text:d.text,providerOptions:d.providerMetadata});else if(Hc(d)){const f=d.toolName;d.state!=="input-streaming"&&u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:f,input:d.input,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}})}else if(Fr(d)){const f=Mi(d);d.state!=="input-streaming"&&(u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:f,input:d.state==="output-error"?(a=d.input)!=null?a:d.rawInput:d.input,providerExecuted:d.providerExecuted,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}}),d.providerExecuted===!0&&(d.state==="output-available"||d.state==="output-error")&&u.push({type:"tool-result",toolCallId:d.toolCallId,toolName:f,output:Nn({output:d.state==="output-error"?d.errorText:d.output,tool:(s=t?.tools)==null?void 0:s[f],errorMode:d.state==="output-error"?"json":"none"})}))}else if(Rs(d)){const f=(l=t?.convertDataPart)==null?void 0:l.call(t,d);f!=null&&u.push(f)}else{const f=d;throw new Error(`Unsupported part: ${f}`)}r.push({role:"assistant",content:u});const c=i.filter(d=>Fr(d)&&d.providerExecuted!==!0||d.type==="dynamic-tool");c.length>0&&r.push({role:"tool",content:c.map(d=>{var f;switch(d.state){case"output-error":case"output-available":{const p=Gz(d);return{type:"tool-result",toolCallId:d.toolCallId,toolName:p,output:Nn({output:d.state==="output-error"?d.errorText:d.output,tool:(f=t?.tools)==null?void 0:f[p],errorMode:d.state==="output-error"?"text":"none"})}}default:return null}}).filter(d=>d!=null)}),i=[]},i=[];for(const a of o.parts)zs(a)||Nf(a)||Ms(a)||Pf(a)||Rs(a)?i.push(a):a.type==="step-start"&&n();n();break}break}default:{const n=o.role;throw new QR({originalMessage:o,message:`Unsupported role: ${n}`})}}return r}No({prefix:"aiobj",size:24});No({prefix:"aiobj",size:24});var lM={};AR(lM,{object:()=>dM,text:()=>cM});var cM=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),dM=({schema:e})=>{const t=Ja(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:r}){const o=await _$(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const n=o.state;throw new Error(`Unsupported parse state: ${n}`)}}},async parseOutput({text:r},o){const n=await xr({text:r});if(!n.success)throw new Sf({message:"No object generated: could not parse the response.",cause:n.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await sr({value:n.value,schema:t});if(!i.success)throw new Sf({message:"No object generated: response did not match schema.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}},pM={word:/\S+\s+/m,line:/\n+/m};function fM({delayInMs:e=10,chunking:t="word",_internal:{delay:r=sx}={}}={}){let o;if(typeof t=="function")o=n=>{const i=t(n);if(i==null)return null;if(!i.length)throw new Error("Chunking function must return a non-empty string.");if(!n.startsWith(i))throw new Error(`Chunking function must return a match that is a prefix of the buffer. Received: "${i}" expected to start with "${n}"`);return i};else{const n=typeof t=="string"?pM[t]:t;if(n==null)throw new Vi({argument:"chunking",message:`Chunking must be "word" or "line" or a RegExp. Received: ${t}`});o=i=>{const a=n.exec(i);return a?i.slice(0,a.index)+a?.[0]:null}}return()=>{let n="",i="";return new TransformStream({async transform(a,s){if(a.type!=="text-delta"){n.length>0&&(s.enqueue({type:"text-delta",text:n,id:i}),n=""),s.enqueue(a);return}a.id!==i&&n.length>0&&(s.enqueue({type:"text-delta",text:n,id:i}),n=""),n+=a.text,i=a.id;let l;for(;(l=o(n))!=null;)s.enqueue({type:"text-delta",text:l,id:i}),n=n.slice(l.length),await r(e)}})}}function Ds(e){return!!e&&"UNSAFE_apiKey"in e}const mM=({getSession:e,projectSlug:t,enabled:r})=>{const o=q_(),n=["chatSession",t],i=o.getQueryState(n),a=i?.data!==void 0,s=i?.dataUpdatedAt??0,u=a&&Date.now()-s>1/0,c=!a||u,{data:d}=B_({queryKey:n,queryFn:()=>e({projectSlug:t}),enabled:r&&c&&e!==null,staleTime:1/0,gcTime:1/0});return d??null};async function hM(e){return(await(await fetch("/chat/session",{method:"POST",headers:{"Gram-Project":e.projectSlug}})).json()).client_token}const gM=({projectSlug:e,auth:t})=>{const r=mM({enabled:!Ds(t),getSession:Ds(t)?null:t?.sessionFn??hM,projectSlug:e});return Ds(t)?{headers:{"Gram-Project":e,"Gram-Key":t.UNSAFE_apiKey},isLoading:!1}:r?{headers:{"Gram-Project":e,"Gram-Chat-Session":r},isLoading:!1}:{isLoading:!0}};function vM({children:e}){const[t,r]=D.useState(new Map),[o,n]=D.useState(new Set),i=D.useCallback((d,f,p)=>new Promise(g=>{const h={toolCallId:f,toolName:d,args:p,resolve:g};r(b=>{const y=new Map(b);return y.set(f,h),y})}),[]),a=D.useCallback(d=>{n(f=>{const p=new Set(f);return p.add(d),p})},[]),s=D.useCallback(d=>{r(f=>{const p=f.get(d);if(p){p.resolve(!0);const g=new Map(f);return g.delete(d),g}return f})},[]),l=D.useCallback(d=>{r(f=>{const p=f.get(d);if(p){p.resolve(!1);const g=new Map(f);return g.delete(d),g}return f})},[]),u=D.useCallback(d=>o.has(d),[o]),c=D.useCallback(d=>t.get(d),[t]);return m.jsx(T.ToolApprovalContext.Provider,{value:{pendingApprovals:t,approvedTools:o,requestApproval:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l,isToolApproved:u,getPendingApproval:c},children:e})}function yM(e){return(e.api?.url||""||"https://app.getgram.ai").replace(/\/+$/,"")}const bM="You are a helpful assistant that can answer questions and help with tasks.";function _M(e,t){return`
|
|
89
|
+
${bM}
|
|
90
90
|
|
|
91
91
|
User-provided System Prompt:
|
|
92
92
|
${e??"None provided"}
|
|
93
93
|
|
|
94
94
|
Utilities:
|
|
95
95
|
${t.map(r=>`- ${r.language}: ${r.prompt}`).join(`
|
|
96
|
-
`)}`}function _M(e){return(e.api?.url??""??"https://app.getgram.ai").replace(/\/+$/,"")}const wM=({children:e,config:t})=>{const r=_M(t),o=gM({auth:t.api,projectSlug:t.projectSlug}),n=J_(),[i,a]=D.useState(t.model?.defaultModel??Nc[0]),[s,l]=D.useState(t.modal?.defaultExpanded??!1),[u,c]=D.useState(t.modal?.defaultOpen),d=t.plugins??T.recommended,f=bM(t.systemPrompt,d),{data:p,isLoading:g}=sN({auth:o,mcp:t.mcp,environment:t.environment??{}}),h=D.useRef({requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool});h.current={requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool};const b=D.useCallback(()=>({requestApproval:(...$)=>h.current.requestApproval(...$),isToolApproved:(...$)=>h.current.isToolApproved(...$),whitelistTool:(...$)=>h.current.whitelistTool(...$)}),[]);D.useEffect(()=>(t.tools?.toolsRequiringApproval?.length&&dN(b(),t.tools.toolsRequiringApproval),()=>{pN()}),[t.tools?.toolsRequiringApproval,b]);const y=D.useMemo(()=>({sendMessages:async({messages:$,abortSignal:v})=>{const k=!!t.languageModel;if(o.isLoading)throw new Error("Session is laoding");const N=x.thread.getModelContext(),I=lN(cN(N?.tools??{})),O=k?null:ax({baseURL:r,apiKey:"unused, but must be set",headers:o.headers});t.languageModel&&console.log("Using custom language model",t.languageModel);const z={...p,...Nj(I)},F=mN(z,t.tools?.toolsRequiringApproval,b()),te=t.languageModel?t.languageModel:O.chat(i);try{return iM({system:f,model:te,messages:uM($),tools:F,stopWhen:h$(10),experimental_transform:fM({delayInMs:15}),abortSignal:v,onError:({error:J})=>{console.error("Stream error in onError callback:",J)}}).toUIMessageStream()}catch(ie){throw console.error("Error creating stream:",ie),ie}},reconnectToStream:async()=>{throw new Error("Stream reconnection not supported")}}),[t,t.languageModel,i,f,p,g,b,r,o.headers]),x=Oj({transport:y});return m.jsx(L.AssistantRuntimeProvider,{runtime:x,children:m.jsxs(T.ElementsContext.Provider,{value:{config:t,setModel:a,model:i,isExpanded:s,setIsExpanded:l,isOpen:u??!1,setIsOpen:c,plugins:d},children:[e,m.jsx($0,{tools:t.tools?.frontendTools??{}})]})})},xM=e=>{const t=new HO;return m.jsx(GO,{client:t,children:m.jsx(vM,{children:m.jsx(wM,{...e})})})};function Oe(e,t,{checkForDefaultPrevented:r=!0}={}){return function(n){if(e?.(n),r===!1||!n.defaultPrevented)return t?.(n)}}function jf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Gc(...e){return t=>{let r=!1;const o=e.map(n=>{const i=jf(n,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let n=0;n<o.length;n++){const i=o[n];typeof i=="function"?i():jf(e[n],null)}}}}function Ge(...e){return _.useCallback(Gc(...e),e)}function $M(e,t){const r=_.createContext(t),o=i=>{const{children:a,...s}=i,l=_.useMemo(()=>s,Object.values(s));return m.jsx(r.Provider,{value:l,children:a})};o.displayName=e+"Provider";function n(i){const a=_.useContext(r);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[o,n]}function Po(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a),l=r.length;r=[...r,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,SM(n,...t)]}function SM(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return r.scopeName=t.scopeName,r}function Kc(e){const t=IM(e),r=_.forwardRef((o,n)=>{const{children:i,...a}=o,s=_.Children.toArray(i),l=s.find(EM);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}function IM(e){const t=_.forwardRef((r,o)=>{const{children:n,...i}=r;if(_.isValidElement(n)){const a=OM(n),s=TM(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Gc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var w$=Symbol("radix.slottable");function kM(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=w$,t}function EM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===w$}function TM(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function OM(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var NM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=NM.reduce((e,t)=>{const r=Kc(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function PM(e,t){e&&um.flushSync(()=>e.dispatchEvent(t))}function Sr(e){const t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...r)=>t.current?.(...r),[])}function CM(e,t=globalThis?.document){const r=Sr(e);_.useEffect(()=>{const o=n=>{n.key==="Escape"&&r(n)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[r,t])}var jM="DismissableLayer",Nu="dismissableLayer.update",AM="dismissableLayer.pointerDownOutside",RM="dismissableLayer.focusOutside",Af,x$=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ha=_.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:n,onFocusOutside:i,onInteractOutside:a,onDismiss:s,...l}=e,u=_.useContext(x$),[c,d]=_.useState(null),f=c?.ownerDocument??globalThis?.document,[,p]=_.useState({}),g=Ge(t,I=>d(I)),h=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=h.indexOf(b),x=c?h.indexOf(c):-1,$=u.layersWithOutsidePointerEventsDisabled.size>0,v=x>=y,k=DM(I=>{const O=I.target,z=[...u.branches].some(F=>F.contains(O));!v||z||(n?.(I),a?.(I),I.defaultPrevented||s?.())},f),N=UM(I=>{const O=I.target;[...u.branches].some(F=>F.contains(O))||(i?.(I),a?.(I),I.defaultPrevented||s?.())},f);return CM(I=>{x===u.layers.size-1&&(o?.(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},f),_.useEffect(()=>{if(c)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Af=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),Rf(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Af)}},[c,f,r,u]),_.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),Rf())},[c,u]),_.useEffect(()=>{const I=()=>p({});return document.addEventListener(Nu,I),()=>document.removeEventListener(Nu,I)},[]),m.jsx(Ce.div,{...l,ref:g,style:{pointerEvents:$?v?"auto":"none":void 0,...e.style},onFocusCapture:Oe(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Oe(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Oe(e.onPointerDownCapture,k.onPointerDownCapture)})});Ha.displayName=jM;var zM="DismissableLayerBranch",MM=_.forwardRef((e,t)=>{const r=_.useContext(x$),o=_.useRef(null),n=Ge(t,o);return _.useEffect(()=>{const i=o.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),m.jsx(Ce.div,{...e,ref:n})});MM.displayName=zM;function DM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1),n=_.useRef(()=>{});return _.useEffect(()=>{const i=s=>{if(s.target&&!o.current){let l=function(){$$(AM,r,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",n.current),n.current=l,t.addEventListener("click",n.current,{once:!0})):l()}else t.removeEventListener("click",n.current);o.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",n.current)}},[t,r]),{onPointerDownCapture:()=>o.current=!0}}function UM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1);return _.useEffect(()=>{const n=i=>{i.target&&!o.current&&$$(RM,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",n),()=>t.removeEventListener("focusin",n)},[t,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Rf(){const e=new CustomEvent(Nu);document.dispatchEvent(e)}function $$(e,t,r,{discrete:o}){const n=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),o?PM(n,i):n.dispatchEvent(i)}var lt=globalThis?.document?_.useLayoutEffect:()=>{},LM=_[" useId ".trim().toString()]||(()=>{}),ZM=0;function qr(e){const[t,r]=_.useState(LM());return lt(()=>{r(o=>o??String(ZM++))},[e]),t?`radix-${t}`:""}const FM=["top","right","bottom","left"],ur=Math.min,Ye=Math.max,Di=Math.round,Go=Math.floor,At=e=>({x:e,y:e}),qM={left:"right",right:"left",bottom:"top",top:"bottom"},VM={start:"end",end:"start"};function Pu(e,t,r){return Ye(e,ur(t,r))}function Bt(e,t){return typeof e=="function"?e(t):e}function Jt(e){return e.split("-")[0]}function dn(e){return e.split("-")[1]}function Yc(e){return e==="x"?"y":"x"}function Qc(e){return e==="y"?"height":"width"}const BM=new Set(["top","bottom"]);function jt(e){return BM.has(Jt(e))?"y":"x"}function Xc(e){return Yc(jt(e))}function JM(e,t,r){r===void 0&&(r=!1);const o=dn(e),n=Xc(e),i=Qc(n);let a=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Ui(a)),[a,Ui(a)]}function WM(e){const t=Ui(e);return[Cu(e),t,Cu(t)]}function Cu(e){return e.replace(/start|end/g,t=>VM[t])}const zf=["left","right"],Mf=["right","left"],HM=["top","bottom"],GM=["bottom","top"];function KM(e,t,r){switch(e){case"top":case"bottom":return r?t?Mf:zf:t?zf:Mf;case"left":case"right":return t?HM:GM;default:return[]}}function YM(e,t,r,o){const n=dn(e);let i=KM(Jt(e),r==="start",o);return n&&(i=i.map(a=>a+"-"+n),t&&(i=i.concat(i.map(Cu)))),i}function Ui(e){return e.replace(/left|right|bottom|top/g,t=>qM[t])}function QM(e){return{top:0,right:0,bottom:0,left:0,...e}}function S$(e){return typeof e!="number"?QM(e):{top:e,right:e,bottom:e,left:e}}function Li(e){const{x:t,y:r,width:o,height:n}=e;return{width:o,height:n,top:r,left:t,right:t+o,bottom:r+n,x:t,y:r}}function Df(e,t,r){let{reference:o,floating:n}=e;const i=jt(t),a=Xc(t),s=Qc(a),l=Jt(t),u=i==="y",c=o.x+o.width/2-n.width/2,d=o.y+o.height/2-n.height/2,f=o[s]/2-n[s]/2;let p;switch(l){case"top":p={x:c,y:o.y-n.height};break;case"bottom":p={x:c,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-n.width,y:d};break;default:p={x:o.x,y:o.y}}switch(dn(t)){case"start":p[a]-=f*(r&&u?-1:1);break;case"end":p[a]+=f*(r&&u?-1:1);break}return p}const XM=async(e,t,r)=>{const{placement:o="bottom",strategy:n="absolute",middleware:i=[],platform:a}=r,s=i.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:n}),{x:c,y:d}=Df(u,o,l),f=o,p={},g=0;for(let h=0;h<s.length;h++){const{name:b,fn:y}=s[h],{x,y:$,data:v,reset:k}=await y({x:c,y:d,initialPlacement:o,placement:f,strategy:n,middlewareData:p,rects:u,platform:a,elements:{reference:e,floating:t}});c=x??c,d=$??d,p={...p,[b]:{...p[b],...v}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(u=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:n}):k.rects),{x:c,y:d}=Df(u,f,l)),h=-1)}return{x:c,y:d,placement:f,strategy:n,middlewareData:p}};async function Kn(e,t){var r;t===void 0&&(t={});const{x:o,y:n,platform:i,rects:a,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Bt(t,e),g=S$(p),b=s[f?d==="floating"?"reference":"floating":d],y=Li(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(b)))==null||r?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),x=d==="floating"?{x:o,y:n,width:a.floating.width,height:a.floating.height}:a.reference,$=await(i.getOffsetParent==null?void 0:i.getOffsetParent(s.floating)),v=await(i.isElement==null?void 0:i.isElement($))?await(i.getScale==null?void 0:i.getScale($))||{x:1,y:1}:{x:1,y:1},k=Li(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:$,strategy:l}):x);return{top:(y.top-k.top+g.top)/v.y,bottom:(k.bottom-y.bottom+g.bottom)/v.y,left:(y.left-k.left+g.left)/v.x,right:(k.right-y.right+g.right)/v.x}}const e4=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:o,placement:n,rects:i,platform:a,elements:s,middlewareData:l}=t,{element:u,padding:c=0}=Bt(e,t)||{};if(u==null)return{};const d=S$(c),f={x:r,y:o},p=Xc(n),g=Qc(p),h=await a.getDimensions(u),b=p==="y",y=b?"top":"left",x=b?"bottom":"right",$=b?"clientHeight":"clientWidth",v=i.reference[g]+i.reference[p]-f[p]-i.floating[g],k=f[p]-i.reference[p],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=N?N[$]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=s.floating[$]||i.floating[g]);const O=v/2-k/2,z=I/2-h[g]/2-1,F=ur(d[y],z),te=ur(d[x],z),ie=F,J=I-h[g]-te,V=I/2-h[g]/2+O,we=Pu(ie,V,J),oe=!l.arrow&&dn(n)!=null&&V!==we&&i.reference[g]/2-(V<ie?F:te)-h[g]/2<0,de=oe?V<ie?V-ie:V-J:0;return{[p]:f[p]+de,data:{[p]:we,centerOffset:V-we-de,...oe&&{alignmentOffset:de}},reset:oe}}}),t4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,o;const{placement:n,middlewareData:i,rects:a,initialPlacement:s,platform:l,elements:u}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=Bt(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const y=Jt(n),x=jt(s),$=Jt(s)===s,v=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=f||($||!h?[Ui(s)]:WM(s)),N=g!=="none";!f&&N&&k.push(...YM(s,h,g,v));const I=[s,...k],O=await Kn(t,b),z=[];let F=((o=i.flip)==null?void 0:o.overflows)||[];if(c&&z.push(O[y]),d){const V=JM(n,a,v);z.push(O[V[0]],O[V[1]])}if(F=[...F,{placement:n,overflows:z}],!z.every(V=>V<=0)){var te,ie;const V=(((te=i.flip)==null?void 0:te.index)||0)+1,we=I[V];if(we&&(!(d==="alignment"?x!==jt(we):!1)||F.every(K=>jt(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:V,overflows:F},reset:{placement:we}};let oe=(ie=F.filter(de=>de.overflows[0]<=0).sort((de,K)=>de.overflows[1]-K.overflows[1])[0])==null?void 0:ie.placement;if(!oe)switch(p){case"bestFit":{var J;const de=(J=F.filter(K=>{if(N){const fe=jt(K.placement);return fe===x||fe==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(fe=>fe>0).reduce((fe,B)=>fe+B,0)]).sort((K,fe)=>K[1]-fe[1])[0])==null?void 0:J[0];de&&(oe=de);break}case"initialPlacement":oe=s;break}if(n!==oe)return{reset:{placement:oe}}}return{}}}};function Uf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Lf(e){return FM.some(t=>e[t]>=0)}const r4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:o="referenceHidden",...n}=Bt(e,t);switch(o){case"referenceHidden":{const i=await Kn(t,{...n,elementContext:"reference"}),a=Uf(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Lf(a)}}}case"escaped":{const i=await Kn(t,{...n,altBoundary:!0}),a=Uf(i,r.floating);return{data:{escapedOffsets:a,escaped:Lf(a)}}}default:return{}}}}},I$=new Set(["left","top"]);async function n4(e,t){const{placement:r,platform:o,elements:n}=e,i=await(o.isRTL==null?void 0:o.isRTL(n.floating)),a=Jt(r),s=dn(r),l=jt(r)==="y",u=I$.has(a)?-1:1,c=i&&l?-1:1,d=Bt(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof g=="number"&&(p=s==="end"?g*-1:g),l?{x:p*c,y:f*u}:{x:f*u,y:p*c}}const o4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,o;const{x:n,y:i,placement:a,middlewareData:s}=t,l=await n4(t,e);return a===((r=s.offset)==null?void 0:r.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:n+l.x,y:i+l.y,data:{...l,placement:a}}}}},i4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:o,placement:n}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:s={fn:b=>{let{x:y,y:x}=b;return{x:y,y:x}}},...l}=Bt(e,t),u={x:r,y:o},c=await Kn(t,l),d=jt(Jt(n)),f=Yc(d);let p=u[f],g=u[d];if(i){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",x=p+c[b],$=p-c[y];p=Pu(x,p,$)}if(a){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",x=g+c[b],$=g-c[y];g=Pu(x,g,$)}const h=s.fn({...t,[f]:p,[d]:g});return{...h,data:{x:h.x-r,y:h.y-o,enabled:{[f]:i,[d]:a}}}}}},a4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:o,placement:n,rects:i,middlewareData:a}=t,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=Bt(e,t),c={x:r,y:o},d=jt(n),f=Yc(d);let p=c[f],g=c[d];const h=Bt(s,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(l){const $=f==="y"?"height":"width",v=i.reference[f]-i.floating[$]+b.mainAxis,k=i.reference[f]+i.reference[$]-b.mainAxis;p<v?p=v:p>k&&(p=k)}if(u){var y,x;const $=f==="y"?"width":"height",v=I$.has(Jt(n)),k=i.reference[d]-i.floating[$]+(v&&((y=a.offset)==null?void 0:y[d])||0)+(v?0:b.crossAxis),N=i.reference[d]+i.reference[$]+(v?0:((x=a.offset)==null?void 0:x[d])||0)-(v?b.crossAxis:0);g<k?g=k:g>N&&(g=N)}return{[f]:p,[d]:g}}}},s4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,o;const{placement:n,rects:i,platform:a,elements:s}=t,{apply:l=()=>{},...u}=Bt(e,t),c=await Kn(t,u),d=Jt(n),f=dn(n),p=jt(n)==="y",{width:g,height:h}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=f===(await(a.isRTL==null?void 0:a.isRTL(s.floating))?"start":"end")?"left":"right"):(y=d,b=f==="end"?"top":"bottom");const x=h-c.top-c.bottom,$=g-c.left-c.right,v=ur(h-c[b],x),k=ur(g-c[y],$),N=!t.middlewareData.shift;let I=v,O=k;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(O=$),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(I=x),N&&!f){const F=Ye(c.left,0),te=Ye(c.right,0),ie=Ye(c.top,0),J=Ye(c.bottom,0);p?O=g-2*(F!==0||te!==0?F+te:Ye(c.left,c.right)):I=h-2*(ie!==0||J!==0?ie+J:Ye(c.top,c.bottom))}await l({...t,availableWidth:O,availableHeight:I});const z=await a.getDimensions(s.floating);return g!==z.width||h!==z.height?{reset:{rects:!0}}:{}}}};function Ga(){return typeof window<"u"}function pn(e){return k$(e)?(e.nodeName||"").toLowerCase():"#document"}function Qe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dt(e){var t;return(t=(k$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function k$(e){return Ga()?e instanceof Node||e instanceof Qe(e).Node:!1}function St(e){return Ga()?e instanceof Element||e instanceof Qe(e).Element:!1}function zt(e){return Ga()?e instanceof HTMLElement||e instanceof Qe(e).HTMLElement:!1}function Zf(e){return!Ga()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qe(e).ShadowRoot}const u4=new Set(["inline","contents"]);function Co(e){const{overflow:t,overflowX:r,overflowY:o,display:n}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+r)&&!u4.has(n)}const l4=new Set(["table","td","th"]);function c4(e){return l4.has(pn(e))}const d4=[":popover-open",":modal"];function Ka(e){return d4.some(t=>{try{return e.matches(t)}catch{return!1}})}const p4=["transform","translate","scale","rotate","perspective"],f4=["transform","translate","scale","rotate","perspective","filter"],m4=["paint","layout","strict","content"];function ed(e){const t=td(),r=St(e)?It(e):e;return p4.some(o=>r[o]?r[o]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||f4.some(o=>(r.willChange||"").includes(o))||m4.some(o=>(r.contain||"").includes(o))}function h4(e){let t=lr(e);for(;zt(t)&&!nn(t);){if(ed(t))return t;if(Ka(t))return null;t=lr(t)}return null}function td(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const g4=new Set(["html","body","#document"]);function nn(e){return g4.has(pn(e))}function It(e){return Qe(e).getComputedStyle(e)}function Ya(e){return St(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lr(e){if(pn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Zf(e)&&e.host||Dt(e);return Zf(t)?t.host:t}function E$(e){const t=lr(e);return nn(t)?e.ownerDocument?e.ownerDocument.body:e.body:zt(t)&&Co(t)?t:E$(t)}function Yn(e,t,r){var o;t===void 0&&(t=[]),r===void 0&&(r=!0);const n=E$(e),i=n===((o=e.ownerDocument)==null?void 0:o.body),a=Qe(n);if(i){const s=ju(a);return t.concat(a,a.visualViewport||[],Co(n)?n:[],s&&r?Yn(s):[])}return t.concat(n,Yn(n,[],r))}function ju(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function T$(e){const t=It(e);let r=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const n=zt(e),i=n?e.offsetWidth:r,a=n?e.offsetHeight:o,s=Di(r)!==i||Di(o)!==a;return s&&(r=i,o=a),{width:r,height:o,$:s}}function rd(e){return St(e)?e:e.contextElement}function Vr(e){const t=rd(e);if(!zt(t))return At(1);const r=t.getBoundingClientRect(),{width:o,height:n,$:i}=T$(t);let a=(i?Di(r.width):r.width)/o,s=(i?Di(r.height):r.height)/n;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const v4=At(0);function O$(e){const t=Qe(e);return!td()||!t.visualViewport?v4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function y4(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Qe(e)?!1:t}function Ir(e,t,r,o){t===void 0&&(t=!1),r===void 0&&(r=!1);const n=e.getBoundingClientRect(),i=rd(e);let a=At(1);t&&(o?St(o)&&(a=Vr(o)):a=Vr(e));const s=y4(i,r,o)?O$(i):At(0);let l=(n.left+s.x)/a.x,u=(n.top+s.y)/a.y,c=n.width/a.x,d=n.height/a.y;if(i){const f=Qe(i),p=o&&St(o)?Qe(o):o;let g=f,h=ju(g);for(;h&&o&&p!==g;){const b=Vr(h),y=h.getBoundingClientRect(),x=It(h),$=y.left+(h.clientLeft+parseFloat(x.paddingLeft))*b.x,v=y.top+(h.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,u*=b.y,c*=b.x,d*=b.y,l+=$,u+=v,g=Qe(h),h=ju(g)}}return Li({width:c,height:d,x:l,y:u})}function nd(e,t){const r=Ya(e).scrollLeft;return t?t.left+r:Ir(Dt(e)).left+r}function N$(e,t,r){r===void 0&&(r=!1);const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-(r?0:nd(e,o)),i=o.top+t.scrollTop;return{x:n,y:i}}function b4(e){let{elements:t,rect:r,offsetParent:o,strategy:n}=e;const i=n==="fixed",a=Dt(o),s=t?Ka(t.floating):!1;if(o===a||s&&i)return r;let l={scrollLeft:0,scrollTop:0},u=At(1);const c=At(0),d=zt(o);if((d||!d&&!i)&&((pn(o)!=="body"||Co(a))&&(l=Ya(o)),zt(o))){const p=Ir(o);u=Vr(o),c.x=p.x+o.clientLeft,c.y=p.y+o.clientTop}const f=a&&!d&&!i?N$(a,l,!0):At(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:r.y*u.y-l.scrollTop*u.y+c.y+f.y}}function _4(e){return Array.from(e.getClientRects())}function w4(e){const t=Dt(e),r=Ya(e),o=e.ownerDocument.body,n=Ye(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),i=Ye(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let a=-r.scrollLeft+nd(e);const s=-r.scrollTop;return It(o).direction==="rtl"&&(a+=Ye(t.clientWidth,o.clientWidth)-n),{width:n,height:i,x:a,y:s}}function x4(e,t){const r=Qe(e),o=Dt(e),n=r.visualViewport;let i=o.clientWidth,a=o.clientHeight,s=0,l=0;if(n){i=n.width,a=n.height;const u=td();(!u||u&&t==="fixed")&&(s=n.offsetLeft,l=n.offsetTop)}return{width:i,height:a,x:s,y:l}}const $4=new Set(["absolute","fixed"]);function S4(e,t){const r=Ir(e,!0,t==="fixed"),o=r.top+e.clientTop,n=r.left+e.clientLeft,i=zt(e)?Vr(e):At(1),a=e.clientWidth*i.x,s=e.clientHeight*i.y,l=n*i.x,u=o*i.y;return{width:a,height:s,x:l,y:u}}function Ff(e,t,r){let o;if(t==="viewport")o=x4(e,r);else if(t==="document")o=w4(Dt(e));else if(St(t))o=S4(t,r);else{const n=O$(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Li(o)}function P$(e,t){const r=lr(e);return r===t||!St(r)||nn(r)?!1:It(r).position==="fixed"||P$(r,t)}function I4(e,t){const r=t.get(e);if(r)return r;let o=Yn(e,[],!1).filter(s=>St(s)&&pn(s)!=="body"),n=null;const i=It(e).position==="fixed";let a=i?lr(e):e;for(;St(a)&&!nn(a);){const s=It(a),l=ed(a);!l&&s.position==="fixed"&&(n=null),(i?!l&&!n:!l&&s.position==="static"&&!!n&&$4.has(n.position)||Co(a)&&!l&&P$(e,a))?o=o.filter(c=>c!==a):n=s,a=lr(a)}return t.set(e,o),o}function k4(e){let{element:t,boundary:r,rootBoundary:o,strategy:n}=e;const a=[...r==="clippingAncestors"?Ka(t)?[]:I4(t,this._c):[].concat(r),o],s=a[0],l=a.reduce((u,c)=>{const d=Ff(t,c,n);return u.top=Ye(d.top,u.top),u.right=ur(d.right,u.right),u.bottom=ur(d.bottom,u.bottom),u.left=Ye(d.left,u.left),u},Ff(t,s,n));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function E4(e){const{width:t,height:r}=T$(e);return{width:t,height:r}}function T4(e,t,r){const o=zt(t),n=Dt(t),i=r==="fixed",a=Ir(e,!0,i,t);let s={scrollLeft:0,scrollTop:0};const l=At(0);function u(){l.x=nd(n)}if(o||!o&&!i)if((pn(t)!=="body"||Co(n))&&(s=Ya(t)),o){const p=Ir(t,!0,i,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else n&&u();i&&!o&&n&&u();const c=n&&!o&&!i?N$(n,s):At(0),d=a.left+s.scrollLeft-l.x-c.x,f=a.top+s.scrollTop-l.y-c.y;return{x:d,y:f,width:a.width,height:a.height}}function Us(e){return It(e).position==="static"}function qf(e,t){if(!zt(e)||It(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Dt(e)===r&&(r=r.ownerDocument.body),r}function C$(e,t){const r=Qe(e);if(Ka(e))return r;if(!zt(e)){let n=lr(e);for(;n&&!nn(n);){if(St(n)&&!Us(n))return n;n=lr(n)}return r}let o=qf(e,t);for(;o&&c4(o)&&Us(o);)o=qf(o,t);return o&&nn(o)&&Us(o)&&!ed(o)?r:o||h4(e)||r}const O4=async function(e){const t=this.getOffsetParent||C$,r=this.getDimensions,o=await r(e.floating);return{reference:T4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function N4(e){return It(e).direction==="rtl"}const P4={convertOffsetParentRelativeRectToViewportRelativeRect:b4,getDocumentElement:Dt,getClippingRect:k4,getOffsetParent:C$,getElementRects:O4,getClientRects:_4,getDimensions:E4,getScale:Vr,isElement:St,isRTL:N4};function j$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function C4(e,t){let r=null,o;const n=Dt(e);function i(){var s;clearTimeout(o),(s=r)==null||s.disconnect(),r=null}function a(s,l){s===void 0&&(s=!1),l===void 0&&(l=1),i();const u=e.getBoundingClientRect(),{left:c,top:d,width:f,height:p}=u;if(s||t(),!f||!p)return;const g=Go(d),h=Go(n.clientWidth-(c+f)),b=Go(n.clientHeight-(d+p)),y=Go(c),$={rootMargin:-g+"px "+-h+"px "+-b+"px "+-y+"px",threshold:Ye(0,ur(1,l))||1};let v=!0;function k(N){const I=N[0].intersectionRatio;if(I!==l){if(!v)return a();I?a(!1,I):o=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!j$(u,e.getBoundingClientRect())&&a(),v=!1}try{r=new IntersectionObserver(k,{...$,root:n.ownerDocument})}catch{r=new IntersectionObserver(k,$)}r.observe(e)}return a(!0),i}function j4(e,t,r,o){o===void 0&&(o={});const{ancestorScroll:n=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,u=rd(e),c=n||i?[...u?Yn(u):[],...Yn(t)]:[];c.forEach(y=>{n&&y.addEventListener("scroll",r,{passive:!0}),i&&y.addEventListener("resize",r)});const d=u&&s?C4(u,r):null;let f=-1,p=null;a&&(p=new ResizeObserver(y=>{let[x]=y;x&&x.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var $;($=p)==null||$.observe(t)})),r()}),u&&!l&&p.observe(u),p.observe(t));let g,h=l?Ir(e):null;l&&b();function b(){const y=Ir(e);h&&!j$(h,y)&&r(),h=y,g=requestAnimationFrame(b)}return r(),()=>{var y;c.forEach(x=>{n&&x.removeEventListener("scroll",r),i&&x.removeEventListener("resize",r)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const A4=o4,R4=i4,z4=t4,M4=s4,D4=r4,Vf=e4,U4=a4,L4=(e,t,r)=>{const o=new Map,n={platform:P4,...r},i={...n.platform,_c:o};return XM(e,t,{...n,platform:i})};var Z4=typeof document<"u",F4=function(){},ai=Z4?D.useLayoutEffect:F4;function Zi(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,o,n;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(o=r;o--!==0;)if(!Zi(e[o],t[o]))return!1;return!0}if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(t,n[o]))return!1;for(o=r;o--!==0;){const i=n[o];if(!(i==="_owner"&&e.$$typeof)&&!Zi(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function A$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bf(e,t){const r=A$(e);return Math.round(t*r)/r}function Ls(e){const t=_.useRef(e);return ai(()=>{t.current=e}),t}function q4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:o=[],platform:n,elements:{reference:i,floating:a}={},transform:s=!0,whileElementsMounted:l,open:u}=e,[c,d]=_.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=_.useState(o);Zi(f,o)||p(o);const[g,h]=_.useState(null),[b,y]=_.useState(null),x=_.useCallback(K=>{K!==N.current&&(N.current=K,h(K))},[]),$=_.useCallback(K=>{K!==I.current&&(I.current=K,y(K))},[]),v=i||g,k=a||b,N=_.useRef(null),I=_.useRef(null),O=_.useRef(c),z=l!=null,F=Ls(l),te=Ls(n),ie=Ls(u),J=_.useCallback(()=>{if(!N.current||!I.current)return;const K={placement:t,strategy:r,middleware:f};te.current&&(K.platform=te.current),L4(N.current,I.current,K).then(fe=>{const B={...fe,isPositioned:ie.current!==!1};V.current&&!Zi(O.current,B)&&(O.current=B,um.flushSync(()=>{d(B)}))})},[f,t,r,te,ie]);ai(()=>{u===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(K=>({...K,isPositioned:!1})))},[u]);const V=_.useRef(!1);ai(()=>(V.current=!0,()=>{V.current=!1}),[]),ai(()=>{if(v&&(N.current=v),k&&(I.current=k),v&&k){if(F.current)return F.current(v,k,J);J()}},[v,k,J,F,z]);const we=_.useMemo(()=>({reference:N,floating:I,setReference:x,setFloating:$}),[x,$]),oe=_.useMemo(()=>({reference:v,floating:k}),[v,k]),de=_.useMemo(()=>{const K={position:r,left:0,top:0};if(!oe.floating)return K;const fe=Bf(oe.floating,c.x),B=Bf(oe.floating,c.y);return s?{...K,transform:"translate("+fe+"px, "+B+"px)",...A$(oe.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:fe,top:B}},[r,s,oe.floating,c.x,c.y]);return _.useMemo(()=>({...c,update:J,refs:we,elements:oe,floatingStyles:de}),[c,J,we,oe,de])}const V4=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:o,padding:n}=typeof e=="function"?e(r):e;return o&&t(o)?o.current!=null?Vf({element:o.current,padding:n}).fn(r):{}:o?Vf({element:o,padding:n}).fn(r):{}}}},B4=(e,t)=>({...A4(e),options:[e,t]}),J4=(e,t)=>({...R4(e),options:[e,t]}),W4=(e,t)=>({...U4(e),options:[e,t]}),H4=(e,t)=>({...z4(e),options:[e,t]}),G4=(e,t)=>({...M4(e),options:[e,t]}),K4=(e,t)=>({...D4(e),options:[e,t]}),Y4=(e,t)=>({...V4(e),options:[e,t]});var Q4="Arrow",R$=_.forwardRef((e,t)=>{const{children:r,width:o=10,height:n=5,...i}=e;return m.jsx(Ce.svg,{...i,ref:t,width:o,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});R$.displayName=Q4;var X4=R$;function eD(e){const[t,r]=_.useState(void 0);return lt(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(n=>{if(!Array.isArray(n)||!n.length)return;const i=n[0];let a,s;if("borderBoxSize"in i){const l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;a=u.inlineSize,s=u.blockSize}else a=e.offsetWidth,s=e.offsetHeight;r({width:a,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else r(void 0)},[e]),t}var od="Popper",[z$,Qa]=Po(od),[tD,M$]=z$(od),D$=e=>{const{__scopePopper:t,children:r}=e,[o,n]=_.useState(null);return m.jsx(tD,{scope:t,anchor:o,onAnchorChange:n,children:r})};D$.displayName=od;var U$="PopperAnchor",L$=_.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:o,...n}=e,i=M$(U$,r),a=_.useRef(null),s=Ge(t,a),l=_.useRef(null);return _.useEffect(()=>{const u=l.current;l.current=o?.current||a.current,u!==l.current&&i.onAnchorChange(l.current)}),o?null:m.jsx(Ce.div,{...n,ref:s})});L$.displayName=U$;var id="PopperContent",[rD,nD]=z$(id),Z$=_.forwardRef((e,t)=>{const{__scopePopper:r,side:o="bottom",sideOffset:n=0,align:i="center",alignOffset:a=0,arrowPadding:s=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:g,...h}=e,b=M$(id,r),[y,x]=_.useState(null),$=Ge(t,xe=>x(xe)),[v,k]=_.useState(null),N=eD(v),I=N?.width??0,O=N?.height??0,z=o+(i!=="center"?"-"+i:""),F=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},te=Array.isArray(u)?u:[u],ie=te.length>0,J={padding:F,boundary:te.filter(iD),altBoundary:ie},{refs:V,floatingStyles:we,placement:oe,isPositioned:de,middlewareData:K}=q4({strategy:"fixed",placement:z,whileElementsMounted:(...xe)=>j4(...xe,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[B4({mainAxis:n+O,alignmentAxis:a}),l&&J4({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?W4():void 0,...J}),l&&H4({...J}),G4({...J,apply:({elements:xe,rects:Ro,availableWidth:ss,availableHeight:fn})=>{const{width:pt,height:zo}=Ro.reference,je=xe.floating.style;je.setProperty("--radix-popper-available-width",`${ss}px`),je.setProperty("--radix-popper-available-height",`${fn}px`),je.setProperty("--radix-popper-anchor-width",`${pt}px`),je.setProperty("--radix-popper-anchor-height",`${zo}px`)}}),v&&Y4({element:v,padding:s}),aD({arrowWidth:I,arrowHeight:O}),f&&K4({strategy:"referenceHidden",...J})]}),[fe,B]=V$(oe),Ue=Sr(g);lt(()=>{de&&Ue?.()},[de,Ue]);const ye=K.arrow?.x,Le=K.arrow?.y,U=K.arrow?.centerOffset!==0,[Q,me]=_.useState();return lt(()=>{y&&me(window.getComputedStyle(y).zIndex)},[y]),m.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...we,transform:de?we.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[K.transformOrigin?.x,K.transformOrigin?.y].join(" "),...K.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(rD,{scope:r,placedSide:fe,onArrowChange:k,arrowX:ye,arrowY:Le,shouldHideArrow:U,children:m.jsx(Ce.div,{"data-side":fe,"data-align":B,...h,ref:$,style:{...h.style,animation:de?void 0:"none"}})})})});Z$.displayName=id;var F$="PopperArrow",oD={top:"bottom",right:"left",bottom:"top",left:"right"},q$=_.forwardRef(function(t,r){const{__scopePopper:o,...n}=t,i=nD(F$,o),a=oD[i.placedSide];return m.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:m.jsx(X4,{...n,ref:r,style:{...n.style,display:"block"}})})});q$.displayName=F$;function iD(e){return e!==null}var aD=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:o,middlewareData:n}=t,a=n.arrow?.centerOffset!==0,s=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[u,c]=V$(r),d={start:"0%",center:"50%",end:"100%"}[c],f=(n.arrow?.x??0)+s/2,p=(n.arrow?.y??0)+l/2;let g="",h="";return u==="bottom"?(g=a?d:`${f}px`,h=`${-l}px`):u==="top"?(g=a?d:`${f}px`,h=`${o.floating.height+l}px`):u==="right"?(g=`${-l}px`,h=a?d:`${p}px`):u==="left"&&(g=`${o.floating.width+l}px`,h=a?d:`${p}px`),{data:{x:g,y:h}}}});function V$(e){const[t,r="center"]=e.split("-");return[t,r]}var B$=D$,ad=L$,J$=Z$,W$=q$,sD="Portal",Xa=_.forwardRef((e,t)=>{const{container:r,...o}=e,[n,i]=_.useState(!1);lt(()=>i(!0),[]);const a=r||n&&globalThis?.document?.body;return a?sm.createPortal(m.jsx(Ce.div,{...o,ref:t}),a):null});Xa.displayName=sD;function uD(e,t){return _.useReducer((r,o)=>t[r][o]??r,e)}var Gt=e=>{const{present:t,children:r}=e,o=lD(t),n=typeof r=="function"?r({present:o.isPresent}):_.Children.only(r),i=Ge(o.ref,cD(n));return typeof r=="function"||o.isPresent?_.cloneElement(n,{ref:i}):null};Gt.displayName="Presence";function lD(e){const[t,r]=_.useState(),o=_.useRef(null),n=_.useRef(e),i=_.useRef("none"),a=e?"mounted":"unmounted",[s,l]=uD(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return _.useEffect(()=>{const u=Ko(o.current);i.current=s==="mounted"?u:"none"},[s]),lt(()=>{const u=o.current,c=n.current;if(c!==e){const f=i.current,p=Ko(u);e?l("MOUNT"):p==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&f!==p?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,l]),lt(()=>{if(t){let u;const c=t.ownerDocument.defaultView??window,d=p=>{const h=Ko(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&h&&(l("ANIMATION_END"),!n.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(i.current=Ko(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:_.useCallback(u=>{o.current=u?getComputedStyle(u):null,r(u)},[])}}function Ko(e){return e?.animationName||"none"}function cD(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var dD=_[" useInsertionEffect ".trim().toString()]||lt;function es({prop:e,defaultProp:t,onChange:r=()=>{},caller:o}){const[n,i,a]=pD({defaultProp:t,onChange:r}),s=e!==void 0,l=s?e:n;{const c=_.useRef(e!==void 0);_.useEffect(()=>{const d=c.current;d!==s&&console.warn(`${o} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=s},[s,o])}const u=_.useCallback(c=>{if(s){const d=fD(c)?c(e):c;d!==e&&a.current?.(d)}else i(c)},[s,e,i,a]);return[l,u]}function pD({defaultProp:e,onChange:t}){const[r,o]=_.useState(e),n=_.useRef(r),i=_.useRef(t);return dD(()=>{i.current=t},[t]),_.useEffect(()=>{n.current!==r&&(i.current?.(r),n.current=r)},[r,n]),[r,o,i]}function fD(e){return typeof e=="function"}var mD=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),hD="VisuallyHidden",H$=_.forwardRef((e,t)=>m.jsx(Ce.span,{...e,ref:t,style:{...mD,...e.style}}));H$.displayName=hD;var gD=H$,[ts]=Po("Tooltip",[Qa]),rs=Qa(),G$="TooltipProvider",vD=700,Au="tooltip.open",[yD,sd]=ts(G$),K$=e=>{const{__scopeTooltip:t,delayDuration:r=vD,skipDelayDuration:o=300,disableHoverableContent:n=!1,children:i}=e,a=_.useRef(!0),s=_.useRef(!1),l=_.useRef(0);return _.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),m.jsx(yD,{scope:t,isOpenDelayedRef:a,delayDuration:r,onOpen:_.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,o)},[o]),isPointerInTransitRef:s,onPointerInTransitChange:_.useCallback(u=>{s.current=u},[]),disableHoverableContent:n,children:i})};K$.displayName=G$;var Qn="Tooltip",[bD,jo]=ts(Qn),Y$=e=>{const{__scopeTooltip:t,children:r,open:o,defaultOpen:n,onOpenChange:i,disableHoverableContent:a,delayDuration:s}=e,l=sd(Qn,e.__scopeTooltip),u=rs(t),[c,d]=_.useState(null),f=qr(),p=_.useRef(0),g=a??l.disableHoverableContent,h=s??l.delayDuration,b=_.useRef(!1),[y,x]=es({prop:o,defaultProp:n??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(Au))):l.onClose(),i?.(I)},caller:Qn}),$=_.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),v=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,x(!0)},[x]),k=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),N=_.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,x(!0),p.current=0},h)},[h,x]);return _.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),m.jsx(B$,{...u,children:m.jsx(bD,{scope:t,contentId:f,open:y,stateAttribute:$,trigger:c,onTriggerChange:d,onTriggerEnter:_.useCallback(()=>{l.isOpenDelayedRef.current?N():v()},[l.isOpenDelayedRef,N,v]),onTriggerLeave:_.useCallback(()=>{g?k():(window.clearTimeout(p.current),p.current=0)},[k,g]),onOpen:v,onClose:k,disableHoverableContent:g,children:r})})};Y$.displayName=Qn;var Ru="TooltipTrigger",Q$=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=jo(Ru,r),i=sd(Ru,r),a=rs(r),s=_.useRef(null),l=Ge(t,s,n.onTriggerChange),u=_.useRef(!1),c=_.useRef(!1),d=_.useCallback(()=>u.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),m.jsx(ad,{asChild:!0,...a,children:m.jsx(Ce.button,{"aria-describedby":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...o,ref:l,onPointerMove:Oe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!c.current&&!i.isPointerInTransitRef.current&&(n.onTriggerEnter(),c.current=!0)}),onPointerLeave:Oe(e.onPointerLeave,()=>{n.onTriggerLeave(),c.current=!1}),onPointerDown:Oe(e.onPointerDown,()=>{n.open&&n.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Oe(e.onFocus,()=>{u.current||n.onOpen()}),onBlur:Oe(e.onBlur,n.onClose),onClick:Oe(e.onClick,n.onClose)})})});Q$.displayName=Ru;var ud="TooltipPortal",[_D,wD]=ts(ud,{forceMount:void 0}),X$=e=>{const{__scopeTooltip:t,forceMount:r,children:o,container:n}=e,i=jo(ud,t);return m.jsx(_D,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(Xa,{asChild:!0,container:n,children:o})})})};X$.displayName=ud;var on="TooltipContent",eS=_.forwardRef((e,t)=>{const r=wD(on,e.__scopeTooltip),{forceMount:o=r.forceMount,side:n="top",...i}=e,a=jo(on,e.__scopeTooltip);return m.jsx(Gt,{present:o||a.open,children:a.disableHoverableContent?m.jsx(tS,{side:n,...i,ref:t}):m.jsx(xD,{side:n,...i,ref:t})})}),xD=_.forwardRef((e,t)=>{const r=jo(on,e.__scopeTooltip),o=sd(on,e.__scopeTooltip),n=_.useRef(null),i=Ge(t,n),[a,s]=_.useState(null),{trigger:l,onClose:u}=r,c=n.current,{onPointerInTransitChange:d}=o,f=_.useCallback(()=>{s(null),d(!1)},[d]),p=_.useCallback((g,h)=>{const b=g.currentTarget,y={x:g.clientX,y:g.clientY},x=kD(y,b.getBoundingClientRect()),$=ED(y,x),v=TD(h.getBoundingClientRect()),k=ND([...$,...v]);s(k),d(!0)},[d]);return _.useEffect(()=>()=>f(),[f]),_.useEffect(()=>{if(l&&c){const g=b=>p(b,c),h=b=>p(b,l);return l.addEventListener("pointerleave",g),c.addEventListener("pointerleave",h),()=>{l.removeEventListener("pointerleave",g),c.removeEventListener("pointerleave",h)}}},[l,c,p,f]),_.useEffect(()=>{if(a){const g=h=>{const b=h.target,y={x:h.clientX,y:h.clientY},x=l?.contains(b)||c?.contains(b),$=!OD(y,a);x?f():$&&(f(),u())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,c,a,u,f]),m.jsx(tS,{...e,ref:i})}),[$D,SD]=ts(Qn,{isInside:!1}),ID=kM("TooltipContent"),tS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,children:o,"aria-label":n,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=jo(on,r),u=rs(r),{onClose:c}=l;return _.useEffect(()=>(document.addEventListener(Au,c),()=>document.removeEventListener(Au,c)),[c]),_.useEffect(()=>{if(l.trigger){const d=f=>{f.target?.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),m.jsx(Ha,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:m.jsxs(J$,{"data-state":l.stateAttribute,...u,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(ID,{children:o}),m.jsx($D,{scope:r,isInside:!0,children:m.jsx(gD,{id:l.contentId,role:"tooltip",children:n||o})})]})})});eS.displayName=on;var rS="TooltipArrow",nS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=rs(r);return SD(rS,r).isInside?null:m.jsx(W$,{...n,...o,ref:t})});nS.displayName=rS;function kD(e,t){const r=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),n=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,o,n,i)){case i:return"left";case n:return"right";case r:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function ED(e,t,r=5){const o=[];switch(t){case"top":o.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":o.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":o.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":o.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return o}function TD(e){const{top:t,right:r,bottom:o,left:n}=e;return[{x:n,y:t},{x:r,y:t},{x:r,y:o},{x:n,y:o}]}function OD(e,t){const{x:r,y:o}=e;let n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],u=s.x,c=s.y,d=l.x,f=l.y;c>o!=f>o&&r<(d-u)*(o-c)/(f-c)+u&&(n=!n)}return n}function ND(e){const t=e.slice();return t.sort((r,o)=>r.x<o.x?-1:r.x>o.x?1:r.y<o.y?-1:r.y>o.y?1:0),PD(t)}function PD(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const n=e[o];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))t.pop();else break}t.push(n)}t.pop();const r=[];for(let o=e.length-1;o>=0;o--){const n=e[o];for(;r.length>=2;){const i=r[r.length-1],a=r[r.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))r.pop();else break}r.push(n)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var CD=K$,jD=Y$,AD=Q$,RD=X$,zD=eS,MD=nS;function oS({delayDuration:e=0,...t}){return m.jsx(CD,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ld({...e}){return m.jsx(oS,{children:m.jsx(jD,{"data-slot":"tooltip",...e})})}function cd({...e}){return m.jsx(AD,{"data-slot":"tooltip-trigger",...e})}function dd({className:e,sideOffset:t=0,children:r,...o}){return m.jsx(RD,{children:m.jsxs(zD,{"data-slot":"tooltip-content",sideOffset:t,className:T.cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...o,children:[r,m.jsx(MD,{className:"bg-foreground fill-foreground z-20 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}var Zs="focusScope.autoFocusOnMount",Fs="focusScope.autoFocusOnUnmount",Jf={bubbles:!1,cancelable:!0},DD="FocusScope",pd=_.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:n,onUnmountAutoFocus:i,...a}=e,[s,l]=_.useState(null),u=Sr(n),c=Sr(i),d=_.useRef(null),f=Ge(t,h=>l(h)),p=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(o){let h=function($){if(p.paused||!s)return;const v=$.target;s.contains(v)?d.current=v:Qt(d.current,{select:!0})},b=function($){if(p.paused||!s)return;const v=$.relatedTarget;v!==null&&(s.contains(v)||Qt(d.current,{select:!0}))},y=function($){if(document.activeElement===document.body)for(const k of $)k.removedNodes.length>0&&Qt(s)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const x=new MutationObserver(y);return s&&x.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),x.disconnect()}}},[o,s,p.paused]),_.useEffect(()=>{if(s){Hf.add(p);const h=document.activeElement;if(!s.contains(h)){const y=new CustomEvent(Zs,Jf);s.addEventListener(Zs,u),s.dispatchEvent(y),y.defaultPrevented||(UD(VD(iS(s)),{select:!0}),document.activeElement===h&&Qt(s))}return()=>{s.removeEventListener(Zs,u),setTimeout(()=>{const y=new CustomEvent(Fs,Jf);s.addEventListener(Fs,c),s.dispatchEvent(y),y.defaultPrevented||Qt(h??document.body,{select:!0}),s.removeEventListener(Fs,c),Hf.remove(p)},0)}}},[s,u,c,p]);const g=_.useCallback(h=>{if(!r&&!o||p.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,y=document.activeElement;if(b&&y){const x=h.currentTarget,[$,v]=LD(x);$&&v?!h.shiftKey&&y===v?(h.preventDefault(),r&&Qt($,{select:!0})):h.shiftKey&&y===$&&(h.preventDefault(),r&&Qt(v,{select:!0})):y===x&&h.preventDefault()}},[r,o,p.paused]);return m.jsx(Ce.div,{tabIndex:-1,...a,ref:f,onKeyDown:g})});pd.displayName=DD;function UD(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(Qt(o,{select:t}),document.activeElement!==r)return}function LD(e){const t=iS(e),r=Wf(t,e),o=Wf(t.reverse(),e);return[r,o]}function iS(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const n=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||n?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Wf(e,t){for(const r of e)if(!ZD(r,{upTo:t}))return r}function ZD(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function FD(e){return e instanceof HTMLInputElement&&"select"in e}function Qt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&FD(e)&&t&&e.select()}}var Hf=qD();function qD(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Gf(e,t),e.unshift(t)},remove(t){e=Gf(e,t),e[0]?.resume()}}}function Gf(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function VD(e){return e.filter(t=>t.tagName!=="A")}var qs=0;function aS(){_.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Kf()),document.body.insertAdjacentElement("beforeend",e[1]??Kf()),qs++,()=>{qs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),qs--}},[])}function Kf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Pt=function(){return Pt=Object.assign||function(t){for(var r,o=1,n=arguments.length;o<n;o++){r=arguments[o];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Pt.apply(this,arguments)};function sS(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function BD(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}var si="right-scroll-bar-position",ui="width-before-scroll-bar",JD="with-scroll-bars-hidden",WD="--removed-body-scroll-bar-size";function Vs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function HD(e,t){var r=D.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(o){var n=r.value;n!==o&&(r.value=o,r.callback(o,n))}}}})[0];return r.callback=t,r.facade}var GD=typeof window<"u"?_.useLayoutEffect:_.useEffect,Yf=new WeakMap;function KD(e,t){var r=HD(null,function(o){return e.forEach(function(n){return Vs(n,o)})});return GD(function(){var o=Yf.get(r);if(o){var n=new Set(o),i=new Set(e),a=r.current;n.forEach(function(s){i.has(s)||Vs(s,null)}),i.forEach(function(s){n.has(s)||Vs(s,a)})}Yf.set(r,e)},[e]),r}function YD(e){return e}function QD(e,t){t===void 0&&(t=YD);var r=[],o=!1,n={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var a=t(i,o);return r.push(a),function(){r=r.filter(function(s){return s!==a})}},assignSyncMedium:function(i){for(o=!0;r.length;){var a=r;r=[],a.forEach(i)}r={push:function(s){return i(s)},filter:function(){return r}}},assignMedium:function(i){o=!0;var a=[];if(r.length){var s=r;r=[],s.forEach(i),a=r}var l=function(){var c=a;a=[],c.forEach(i)},u=function(){return Promise.resolve().then(l)};u(),r={push:function(c){a.push(c),u()},filter:function(c){return a=a.filter(c),r}}}};return n}function XD(e){e===void 0&&(e={});var t=QD(null);return t.options=Pt({async:!0,ssr:!1},e),t}var uS=function(e){var t=e.sideCar,r=sS(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return _.createElement(o,Pt({},r))};uS.isSideCarExport=!0;function eU(e,t){return e.useMedium(t),uS}var lS=XD(),Bs=function(){},ns=_.forwardRef(function(e,t){var r=_.useRef(null),o=_.useState({onScrollCapture:Bs,onWheelCapture:Bs,onTouchMoveCapture:Bs}),n=o[0],i=o[1],a=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,y=e.as,x=y===void 0?"div":y,$=e.gapMode,v=sS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,N=KD([r,t]),I=Pt(Pt({},v),n);return _.createElement(_.Fragment,null,c&&_.createElement(k,{sideCar:lS,removeScrollBar:u,shards:d,noRelative:p,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!b,lockRef:r,gapMode:$}),a?_.cloneElement(_.Children.only(s),Pt(Pt({},I),{ref:N})):_.createElement(x,Pt({},I,{className:l,ref:N}),s))});ns.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ns.classNames={fullWidth:ui,zeroRight:si};var tU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function rU(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=tU();return t&&e.setAttribute("nonce",t),e}function nU(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function oU(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var iU=function(){var e=0,t=null;return{add:function(r){e==0&&(t=rU())&&(nU(t,r),oU(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},aU=function(){var e=iU();return function(t,r){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},cS=function(){var e=aU(),t=function(r){var o=r.styles,n=r.dynamic;return e(o,n),null};return t},sU={left:0,top:0,right:0,gap:0},Js=function(e){return parseInt(e||"",10)||0},uU=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],n=t[e==="padding"?"paddingRight":"marginRight"];return[Js(r),Js(o),Js(n)]},lU=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return sU;var t=uU(e),r=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-r+t[2]-t[0])}},cU=cS(),Br="data-scroll-locked",dU=function(e,t,r,o){var n=e.left,i=e.top,a=e.right,s=e.gap;return r===void 0&&(r="margin"),`
|
|
96
|
+
`)}`}const wM=({children:e,config:t})=>{const r=yM(t),o=gM({auth:t.api,projectSlug:t.projectSlug}),n=J_(),[i,a]=D.useState(t.model?.defaultModel??Nc[0]),[s,l]=D.useState(t.modal?.defaultExpanded??!1),[u,c]=D.useState(t.modal?.defaultOpen),d=t.plugins??T.recommended,f=_M(t.systemPrompt,d),{data:p,isLoading:g}=sN({auth:o,mcp:t.mcp,environment:t.environment??{}}),h=D.useRef({requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool});h.current={requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool};const b=D.useCallback(()=>({requestApproval:(...$)=>h.current.requestApproval(...$),isToolApproved:(...$)=>h.current.isToolApproved(...$),whitelistTool:(...$)=>h.current.whitelistTool(...$)}),[]);D.useEffect(()=>(t.tools?.toolsRequiringApproval?.length&&dN(b(),t.tools.toolsRequiringApproval),()=>{pN()}),[t.tools?.toolsRequiringApproval,b]);const y=D.useMemo(()=>({sendMessages:async({messages:$,abortSignal:v})=>{const k=!!t.languageModel;if(o.isLoading)throw new Error("Session is laoding");const N=x.thread.getModelContext(),I=lN(cN(N?.tools??{})),O=k?null:ax({baseURL:r,apiKey:"unused, but must be set",headers:o.headers});t.languageModel&&console.log("Using custom language model",t.languageModel);const z={...p,...Nj(I)},F=mN(z,t.tools?.toolsRequiringApproval,b()),te=t.languageModel?t.languageModel:O.chat(i);try{return iM({system:f,model:te,messages:uM($),tools:F,stopWhen:h$(10),experimental_transform:fM({delayInMs:15}),abortSignal:v,onError:({error:J})=>{console.error("Stream error in onError callback:",J)}}).toUIMessageStream()}catch(ie){throw console.error("Error creating stream:",ie),ie}},reconnectToStream:async()=>{throw new Error("Stream reconnection not supported")}}),[t,t.languageModel,i,f,p,g,b,r,o.headers]),x=Oj({transport:y});return m.jsx(L.AssistantRuntimeProvider,{runtime:x,children:m.jsxs(T.ElementsContext.Provider,{value:{config:t,setModel:a,model:i,isExpanded:s,setIsExpanded:l,isOpen:u??!1,setIsOpen:c,plugins:d},children:[e,m.jsx($0,{tools:t.tools?.frontendTools??{}})]})})},xM=e=>{const t=new HO;return m.jsx(GO,{client:t,children:m.jsx(vM,{children:m.jsx(wM,{...e})})})};function Oe(e,t,{checkForDefaultPrevented:r=!0}={}){return function(n){if(e?.(n),r===!1||!n.defaultPrevented)return t?.(n)}}function jf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Gc(...e){return t=>{let r=!1;const o=e.map(n=>{const i=jf(n,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let n=0;n<o.length;n++){const i=o[n];typeof i=="function"?i():jf(e[n],null)}}}}function Ge(...e){return _.useCallback(Gc(...e),e)}function $M(e,t){const r=_.createContext(t),o=i=>{const{children:a,...s}=i,l=_.useMemo(()=>s,Object.values(s));return m.jsx(r.Provider,{value:l,children:a})};o.displayName=e+"Provider";function n(i){const a=_.useContext(r);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[o,n]}function Po(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a),l=r.length;r=[...r,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,SM(n,...t)]}function SM(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return r.scopeName=t.scopeName,r}function Kc(e){const t=IM(e),r=_.forwardRef((o,n)=>{const{children:i,...a}=o,s=_.Children.toArray(i),l=s.find(EM);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}function IM(e){const t=_.forwardRef((r,o)=>{const{children:n,...i}=r;if(_.isValidElement(n)){const a=OM(n),s=TM(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Gc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var w$=Symbol("radix.slottable");function kM(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=w$,t}function EM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===w$}function TM(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function OM(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var NM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=NM.reduce((e,t)=>{const r=Kc(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function PM(e,t){e&&um.flushSync(()=>e.dispatchEvent(t))}function Sr(e){const t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...r)=>t.current?.(...r),[])}function CM(e,t=globalThis?.document){const r=Sr(e);_.useEffect(()=>{const o=n=>{n.key==="Escape"&&r(n)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[r,t])}var jM="DismissableLayer",Nu="dismissableLayer.update",AM="dismissableLayer.pointerDownOutside",RM="dismissableLayer.focusOutside",Af,x$=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ha=_.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:n,onFocusOutside:i,onInteractOutside:a,onDismiss:s,...l}=e,u=_.useContext(x$),[c,d]=_.useState(null),f=c?.ownerDocument??globalThis?.document,[,p]=_.useState({}),g=Ge(t,I=>d(I)),h=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=h.indexOf(b),x=c?h.indexOf(c):-1,$=u.layersWithOutsidePointerEventsDisabled.size>0,v=x>=y,k=DM(I=>{const O=I.target,z=[...u.branches].some(F=>F.contains(O));!v||z||(n?.(I),a?.(I),I.defaultPrevented||s?.())},f),N=UM(I=>{const O=I.target;[...u.branches].some(F=>F.contains(O))||(i?.(I),a?.(I),I.defaultPrevented||s?.())},f);return CM(I=>{x===u.layers.size-1&&(o?.(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},f),_.useEffect(()=>{if(c)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Af=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),Rf(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Af)}},[c,f,r,u]),_.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),Rf())},[c,u]),_.useEffect(()=>{const I=()=>p({});return document.addEventListener(Nu,I),()=>document.removeEventListener(Nu,I)},[]),m.jsx(Ce.div,{...l,ref:g,style:{pointerEvents:$?v?"auto":"none":void 0,...e.style},onFocusCapture:Oe(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Oe(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Oe(e.onPointerDownCapture,k.onPointerDownCapture)})});Ha.displayName=jM;var zM="DismissableLayerBranch",MM=_.forwardRef((e,t)=>{const r=_.useContext(x$),o=_.useRef(null),n=Ge(t,o);return _.useEffect(()=>{const i=o.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),m.jsx(Ce.div,{...e,ref:n})});MM.displayName=zM;function DM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1),n=_.useRef(()=>{});return _.useEffect(()=>{const i=s=>{if(s.target&&!o.current){let l=function(){$$(AM,r,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",n.current),n.current=l,t.addEventListener("click",n.current,{once:!0})):l()}else t.removeEventListener("click",n.current);o.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",n.current)}},[t,r]),{onPointerDownCapture:()=>o.current=!0}}function UM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1);return _.useEffect(()=>{const n=i=>{i.target&&!o.current&&$$(RM,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",n),()=>t.removeEventListener("focusin",n)},[t,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Rf(){const e=new CustomEvent(Nu);document.dispatchEvent(e)}function $$(e,t,r,{discrete:o}){const n=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),o?PM(n,i):n.dispatchEvent(i)}var lt=globalThis?.document?_.useLayoutEffect:()=>{},LM=_[" useId ".trim().toString()]||(()=>{}),ZM=0;function qr(e){const[t,r]=_.useState(LM());return lt(()=>{r(o=>o??String(ZM++))},[e]),t?`radix-${t}`:""}const FM=["top","right","bottom","left"],ur=Math.min,Ye=Math.max,Di=Math.round,Go=Math.floor,At=e=>({x:e,y:e}),qM={left:"right",right:"left",bottom:"top",top:"bottom"},VM={start:"end",end:"start"};function Pu(e,t,r){return Ye(e,ur(t,r))}function Bt(e,t){return typeof e=="function"?e(t):e}function Jt(e){return e.split("-")[0]}function dn(e){return e.split("-")[1]}function Yc(e){return e==="x"?"y":"x"}function Qc(e){return e==="y"?"height":"width"}const BM=new Set(["top","bottom"]);function jt(e){return BM.has(Jt(e))?"y":"x"}function Xc(e){return Yc(jt(e))}function JM(e,t,r){r===void 0&&(r=!1);const o=dn(e),n=Xc(e),i=Qc(n);let a=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Ui(a)),[a,Ui(a)]}function WM(e){const t=Ui(e);return[Cu(e),t,Cu(t)]}function Cu(e){return e.replace(/start|end/g,t=>VM[t])}const zf=["left","right"],Mf=["right","left"],HM=["top","bottom"],GM=["bottom","top"];function KM(e,t,r){switch(e){case"top":case"bottom":return r?t?Mf:zf:t?zf:Mf;case"left":case"right":return t?HM:GM;default:return[]}}function YM(e,t,r,o){const n=dn(e);let i=KM(Jt(e),r==="start",o);return n&&(i=i.map(a=>a+"-"+n),t&&(i=i.concat(i.map(Cu)))),i}function Ui(e){return e.replace(/left|right|bottom|top/g,t=>qM[t])}function QM(e){return{top:0,right:0,bottom:0,left:0,...e}}function S$(e){return typeof e!="number"?QM(e):{top:e,right:e,bottom:e,left:e}}function Li(e){const{x:t,y:r,width:o,height:n}=e;return{width:o,height:n,top:r,left:t,right:t+o,bottom:r+n,x:t,y:r}}function Df(e,t,r){let{reference:o,floating:n}=e;const i=jt(t),a=Xc(t),s=Qc(a),l=Jt(t),u=i==="y",c=o.x+o.width/2-n.width/2,d=o.y+o.height/2-n.height/2,f=o[s]/2-n[s]/2;let p;switch(l){case"top":p={x:c,y:o.y-n.height};break;case"bottom":p={x:c,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-n.width,y:d};break;default:p={x:o.x,y:o.y}}switch(dn(t)){case"start":p[a]-=f*(r&&u?-1:1);break;case"end":p[a]+=f*(r&&u?-1:1);break}return p}const XM=async(e,t,r)=>{const{placement:o="bottom",strategy:n="absolute",middleware:i=[],platform:a}=r,s=i.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:n}),{x:c,y:d}=Df(u,o,l),f=o,p={},g=0;for(let h=0;h<s.length;h++){const{name:b,fn:y}=s[h],{x,y:$,data:v,reset:k}=await y({x:c,y:d,initialPlacement:o,placement:f,strategy:n,middlewareData:p,rects:u,platform:a,elements:{reference:e,floating:t}});c=x??c,d=$??d,p={...p,[b]:{...p[b],...v}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(u=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:n}):k.rects),{x:c,y:d}=Df(u,f,l)),h=-1)}return{x:c,y:d,placement:f,strategy:n,middlewareData:p}};async function Kn(e,t){var r;t===void 0&&(t={});const{x:o,y:n,platform:i,rects:a,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Bt(t,e),g=S$(p),b=s[f?d==="floating"?"reference":"floating":d],y=Li(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(b)))==null||r?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),x=d==="floating"?{x:o,y:n,width:a.floating.width,height:a.floating.height}:a.reference,$=await(i.getOffsetParent==null?void 0:i.getOffsetParent(s.floating)),v=await(i.isElement==null?void 0:i.isElement($))?await(i.getScale==null?void 0:i.getScale($))||{x:1,y:1}:{x:1,y:1},k=Li(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:$,strategy:l}):x);return{top:(y.top-k.top+g.top)/v.y,bottom:(k.bottom-y.bottom+g.bottom)/v.y,left:(y.left-k.left+g.left)/v.x,right:(k.right-y.right+g.right)/v.x}}const e4=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:o,placement:n,rects:i,platform:a,elements:s,middlewareData:l}=t,{element:u,padding:c=0}=Bt(e,t)||{};if(u==null)return{};const d=S$(c),f={x:r,y:o},p=Xc(n),g=Qc(p),h=await a.getDimensions(u),b=p==="y",y=b?"top":"left",x=b?"bottom":"right",$=b?"clientHeight":"clientWidth",v=i.reference[g]+i.reference[p]-f[p]-i.floating[g],k=f[p]-i.reference[p],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=N?N[$]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=s.floating[$]||i.floating[g]);const O=v/2-k/2,z=I/2-h[g]/2-1,F=ur(d[y],z),te=ur(d[x],z),ie=F,J=I-h[g]-te,V=I/2-h[g]/2+O,we=Pu(ie,V,J),oe=!l.arrow&&dn(n)!=null&&V!==we&&i.reference[g]/2-(V<ie?F:te)-h[g]/2<0,de=oe?V<ie?V-ie:V-J:0;return{[p]:f[p]+de,data:{[p]:we,centerOffset:V-we-de,...oe&&{alignmentOffset:de}},reset:oe}}}),t4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,o;const{placement:n,middlewareData:i,rects:a,initialPlacement:s,platform:l,elements:u}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=Bt(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const y=Jt(n),x=jt(s),$=Jt(s)===s,v=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=f||($||!h?[Ui(s)]:WM(s)),N=g!=="none";!f&&N&&k.push(...YM(s,h,g,v));const I=[s,...k],O=await Kn(t,b),z=[];let F=((o=i.flip)==null?void 0:o.overflows)||[];if(c&&z.push(O[y]),d){const V=JM(n,a,v);z.push(O[V[0]],O[V[1]])}if(F=[...F,{placement:n,overflows:z}],!z.every(V=>V<=0)){var te,ie;const V=(((te=i.flip)==null?void 0:te.index)||0)+1,we=I[V];if(we&&(!(d==="alignment"?x!==jt(we):!1)||F.every(K=>jt(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:V,overflows:F},reset:{placement:we}};let oe=(ie=F.filter(de=>de.overflows[0]<=0).sort((de,K)=>de.overflows[1]-K.overflows[1])[0])==null?void 0:ie.placement;if(!oe)switch(p){case"bestFit":{var J;const de=(J=F.filter(K=>{if(N){const fe=jt(K.placement);return fe===x||fe==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(fe=>fe>0).reduce((fe,B)=>fe+B,0)]).sort((K,fe)=>K[1]-fe[1])[0])==null?void 0:J[0];de&&(oe=de);break}case"initialPlacement":oe=s;break}if(n!==oe)return{reset:{placement:oe}}}return{}}}};function Uf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Lf(e){return FM.some(t=>e[t]>=0)}const r4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:o="referenceHidden",...n}=Bt(e,t);switch(o){case"referenceHidden":{const i=await Kn(t,{...n,elementContext:"reference"}),a=Uf(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Lf(a)}}}case"escaped":{const i=await Kn(t,{...n,altBoundary:!0}),a=Uf(i,r.floating);return{data:{escapedOffsets:a,escaped:Lf(a)}}}default:return{}}}}},I$=new Set(["left","top"]);async function n4(e,t){const{placement:r,platform:o,elements:n}=e,i=await(o.isRTL==null?void 0:o.isRTL(n.floating)),a=Jt(r),s=dn(r),l=jt(r)==="y",u=I$.has(a)?-1:1,c=i&&l?-1:1,d=Bt(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof g=="number"&&(p=s==="end"?g*-1:g),l?{x:p*c,y:f*u}:{x:f*u,y:p*c}}const o4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,o;const{x:n,y:i,placement:a,middlewareData:s}=t,l=await n4(t,e);return a===((r=s.offset)==null?void 0:r.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:n+l.x,y:i+l.y,data:{...l,placement:a}}}}},i4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:o,placement:n}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:s={fn:b=>{let{x:y,y:x}=b;return{x:y,y:x}}},...l}=Bt(e,t),u={x:r,y:o},c=await Kn(t,l),d=jt(Jt(n)),f=Yc(d);let p=u[f],g=u[d];if(i){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",x=p+c[b],$=p-c[y];p=Pu(x,p,$)}if(a){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",x=g+c[b],$=g-c[y];g=Pu(x,g,$)}const h=s.fn({...t,[f]:p,[d]:g});return{...h,data:{x:h.x-r,y:h.y-o,enabled:{[f]:i,[d]:a}}}}}},a4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:o,placement:n,rects:i,middlewareData:a}=t,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=Bt(e,t),c={x:r,y:o},d=jt(n),f=Yc(d);let p=c[f],g=c[d];const h=Bt(s,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(l){const $=f==="y"?"height":"width",v=i.reference[f]-i.floating[$]+b.mainAxis,k=i.reference[f]+i.reference[$]-b.mainAxis;p<v?p=v:p>k&&(p=k)}if(u){var y,x;const $=f==="y"?"width":"height",v=I$.has(Jt(n)),k=i.reference[d]-i.floating[$]+(v&&((y=a.offset)==null?void 0:y[d])||0)+(v?0:b.crossAxis),N=i.reference[d]+i.reference[$]+(v?0:((x=a.offset)==null?void 0:x[d])||0)-(v?b.crossAxis:0);g<k?g=k:g>N&&(g=N)}return{[f]:p,[d]:g}}}},s4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,o;const{placement:n,rects:i,platform:a,elements:s}=t,{apply:l=()=>{},...u}=Bt(e,t),c=await Kn(t,u),d=Jt(n),f=dn(n),p=jt(n)==="y",{width:g,height:h}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=f===(await(a.isRTL==null?void 0:a.isRTL(s.floating))?"start":"end")?"left":"right"):(y=d,b=f==="end"?"top":"bottom");const x=h-c.top-c.bottom,$=g-c.left-c.right,v=ur(h-c[b],x),k=ur(g-c[y],$),N=!t.middlewareData.shift;let I=v,O=k;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(O=$),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(I=x),N&&!f){const F=Ye(c.left,0),te=Ye(c.right,0),ie=Ye(c.top,0),J=Ye(c.bottom,0);p?O=g-2*(F!==0||te!==0?F+te:Ye(c.left,c.right)):I=h-2*(ie!==0||J!==0?ie+J:Ye(c.top,c.bottom))}await l({...t,availableWidth:O,availableHeight:I});const z=await a.getDimensions(s.floating);return g!==z.width||h!==z.height?{reset:{rects:!0}}:{}}}};function Ga(){return typeof window<"u"}function pn(e){return k$(e)?(e.nodeName||"").toLowerCase():"#document"}function Qe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dt(e){var t;return(t=(k$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function k$(e){return Ga()?e instanceof Node||e instanceof Qe(e).Node:!1}function St(e){return Ga()?e instanceof Element||e instanceof Qe(e).Element:!1}function zt(e){return Ga()?e instanceof HTMLElement||e instanceof Qe(e).HTMLElement:!1}function Zf(e){return!Ga()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qe(e).ShadowRoot}const u4=new Set(["inline","contents"]);function Co(e){const{overflow:t,overflowX:r,overflowY:o,display:n}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+r)&&!u4.has(n)}const l4=new Set(["table","td","th"]);function c4(e){return l4.has(pn(e))}const d4=[":popover-open",":modal"];function Ka(e){return d4.some(t=>{try{return e.matches(t)}catch{return!1}})}const p4=["transform","translate","scale","rotate","perspective"],f4=["transform","translate","scale","rotate","perspective","filter"],m4=["paint","layout","strict","content"];function ed(e){const t=td(),r=St(e)?It(e):e;return p4.some(o=>r[o]?r[o]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||f4.some(o=>(r.willChange||"").includes(o))||m4.some(o=>(r.contain||"").includes(o))}function h4(e){let t=lr(e);for(;zt(t)&&!nn(t);){if(ed(t))return t;if(Ka(t))return null;t=lr(t)}return null}function td(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const g4=new Set(["html","body","#document"]);function nn(e){return g4.has(pn(e))}function It(e){return Qe(e).getComputedStyle(e)}function Ya(e){return St(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lr(e){if(pn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Zf(e)&&e.host||Dt(e);return Zf(t)?t.host:t}function E$(e){const t=lr(e);return nn(t)?e.ownerDocument?e.ownerDocument.body:e.body:zt(t)&&Co(t)?t:E$(t)}function Yn(e,t,r){var o;t===void 0&&(t=[]),r===void 0&&(r=!0);const n=E$(e),i=n===((o=e.ownerDocument)==null?void 0:o.body),a=Qe(n);if(i){const s=ju(a);return t.concat(a,a.visualViewport||[],Co(n)?n:[],s&&r?Yn(s):[])}return t.concat(n,Yn(n,[],r))}function ju(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function T$(e){const t=It(e);let r=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const n=zt(e),i=n?e.offsetWidth:r,a=n?e.offsetHeight:o,s=Di(r)!==i||Di(o)!==a;return s&&(r=i,o=a),{width:r,height:o,$:s}}function rd(e){return St(e)?e:e.contextElement}function Vr(e){const t=rd(e);if(!zt(t))return At(1);const r=t.getBoundingClientRect(),{width:o,height:n,$:i}=T$(t);let a=(i?Di(r.width):r.width)/o,s=(i?Di(r.height):r.height)/n;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const v4=At(0);function O$(e){const t=Qe(e);return!td()||!t.visualViewport?v4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function y4(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Qe(e)?!1:t}function Ir(e,t,r,o){t===void 0&&(t=!1),r===void 0&&(r=!1);const n=e.getBoundingClientRect(),i=rd(e);let a=At(1);t&&(o?St(o)&&(a=Vr(o)):a=Vr(e));const s=y4(i,r,o)?O$(i):At(0);let l=(n.left+s.x)/a.x,u=(n.top+s.y)/a.y,c=n.width/a.x,d=n.height/a.y;if(i){const f=Qe(i),p=o&&St(o)?Qe(o):o;let g=f,h=ju(g);for(;h&&o&&p!==g;){const b=Vr(h),y=h.getBoundingClientRect(),x=It(h),$=y.left+(h.clientLeft+parseFloat(x.paddingLeft))*b.x,v=y.top+(h.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,u*=b.y,c*=b.x,d*=b.y,l+=$,u+=v,g=Qe(h),h=ju(g)}}return Li({width:c,height:d,x:l,y:u})}function nd(e,t){const r=Ya(e).scrollLeft;return t?t.left+r:Ir(Dt(e)).left+r}function N$(e,t,r){r===void 0&&(r=!1);const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-(r?0:nd(e,o)),i=o.top+t.scrollTop;return{x:n,y:i}}function b4(e){let{elements:t,rect:r,offsetParent:o,strategy:n}=e;const i=n==="fixed",a=Dt(o),s=t?Ka(t.floating):!1;if(o===a||s&&i)return r;let l={scrollLeft:0,scrollTop:0},u=At(1);const c=At(0),d=zt(o);if((d||!d&&!i)&&((pn(o)!=="body"||Co(a))&&(l=Ya(o)),zt(o))){const p=Ir(o);u=Vr(o),c.x=p.x+o.clientLeft,c.y=p.y+o.clientTop}const f=a&&!d&&!i?N$(a,l,!0):At(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:r.y*u.y-l.scrollTop*u.y+c.y+f.y}}function _4(e){return Array.from(e.getClientRects())}function w4(e){const t=Dt(e),r=Ya(e),o=e.ownerDocument.body,n=Ye(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),i=Ye(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let a=-r.scrollLeft+nd(e);const s=-r.scrollTop;return It(o).direction==="rtl"&&(a+=Ye(t.clientWidth,o.clientWidth)-n),{width:n,height:i,x:a,y:s}}function x4(e,t){const r=Qe(e),o=Dt(e),n=r.visualViewport;let i=o.clientWidth,a=o.clientHeight,s=0,l=0;if(n){i=n.width,a=n.height;const u=td();(!u||u&&t==="fixed")&&(s=n.offsetLeft,l=n.offsetTop)}return{width:i,height:a,x:s,y:l}}const $4=new Set(["absolute","fixed"]);function S4(e,t){const r=Ir(e,!0,t==="fixed"),o=r.top+e.clientTop,n=r.left+e.clientLeft,i=zt(e)?Vr(e):At(1),a=e.clientWidth*i.x,s=e.clientHeight*i.y,l=n*i.x,u=o*i.y;return{width:a,height:s,x:l,y:u}}function Ff(e,t,r){let o;if(t==="viewport")o=x4(e,r);else if(t==="document")o=w4(Dt(e));else if(St(t))o=S4(t,r);else{const n=O$(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Li(o)}function P$(e,t){const r=lr(e);return r===t||!St(r)||nn(r)?!1:It(r).position==="fixed"||P$(r,t)}function I4(e,t){const r=t.get(e);if(r)return r;let o=Yn(e,[],!1).filter(s=>St(s)&&pn(s)!=="body"),n=null;const i=It(e).position==="fixed";let a=i?lr(e):e;for(;St(a)&&!nn(a);){const s=It(a),l=ed(a);!l&&s.position==="fixed"&&(n=null),(i?!l&&!n:!l&&s.position==="static"&&!!n&&$4.has(n.position)||Co(a)&&!l&&P$(e,a))?o=o.filter(c=>c!==a):n=s,a=lr(a)}return t.set(e,o),o}function k4(e){let{element:t,boundary:r,rootBoundary:o,strategy:n}=e;const a=[...r==="clippingAncestors"?Ka(t)?[]:I4(t,this._c):[].concat(r),o],s=a[0],l=a.reduce((u,c)=>{const d=Ff(t,c,n);return u.top=Ye(d.top,u.top),u.right=ur(d.right,u.right),u.bottom=ur(d.bottom,u.bottom),u.left=Ye(d.left,u.left),u},Ff(t,s,n));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function E4(e){const{width:t,height:r}=T$(e);return{width:t,height:r}}function T4(e,t,r){const o=zt(t),n=Dt(t),i=r==="fixed",a=Ir(e,!0,i,t);let s={scrollLeft:0,scrollTop:0};const l=At(0);function u(){l.x=nd(n)}if(o||!o&&!i)if((pn(t)!=="body"||Co(n))&&(s=Ya(t)),o){const p=Ir(t,!0,i,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else n&&u();i&&!o&&n&&u();const c=n&&!o&&!i?N$(n,s):At(0),d=a.left+s.scrollLeft-l.x-c.x,f=a.top+s.scrollTop-l.y-c.y;return{x:d,y:f,width:a.width,height:a.height}}function Us(e){return It(e).position==="static"}function qf(e,t){if(!zt(e)||It(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Dt(e)===r&&(r=r.ownerDocument.body),r}function C$(e,t){const r=Qe(e);if(Ka(e))return r;if(!zt(e)){let n=lr(e);for(;n&&!nn(n);){if(St(n)&&!Us(n))return n;n=lr(n)}return r}let o=qf(e,t);for(;o&&c4(o)&&Us(o);)o=qf(o,t);return o&&nn(o)&&Us(o)&&!ed(o)?r:o||h4(e)||r}const O4=async function(e){const t=this.getOffsetParent||C$,r=this.getDimensions,o=await r(e.floating);return{reference:T4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function N4(e){return It(e).direction==="rtl"}const P4={convertOffsetParentRelativeRectToViewportRelativeRect:b4,getDocumentElement:Dt,getClippingRect:k4,getOffsetParent:C$,getElementRects:O4,getClientRects:_4,getDimensions:E4,getScale:Vr,isElement:St,isRTL:N4};function j$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function C4(e,t){let r=null,o;const n=Dt(e);function i(){var s;clearTimeout(o),(s=r)==null||s.disconnect(),r=null}function a(s,l){s===void 0&&(s=!1),l===void 0&&(l=1),i();const u=e.getBoundingClientRect(),{left:c,top:d,width:f,height:p}=u;if(s||t(),!f||!p)return;const g=Go(d),h=Go(n.clientWidth-(c+f)),b=Go(n.clientHeight-(d+p)),y=Go(c),$={rootMargin:-g+"px "+-h+"px "+-b+"px "+-y+"px",threshold:Ye(0,ur(1,l))||1};let v=!0;function k(N){const I=N[0].intersectionRatio;if(I!==l){if(!v)return a();I?a(!1,I):o=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!j$(u,e.getBoundingClientRect())&&a(),v=!1}try{r=new IntersectionObserver(k,{...$,root:n.ownerDocument})}catch{r=new IntersectionObserver(k,$)}r.observe(e)}return a(!0),i}function j4(e,t,r,o){o===void 0&&(o={});const{ancestorScroll:n=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,u=rd(e),c=n||i?[...u?Yn(u):[],...Yn(t)]:[];c.forEach(y=>{n&&y.addEventListener("scroll",r,{passive:!0}),i&&y.addEventListener("resize",r)});const d=u&&s?C4(u,r):null;let f=-1,p=null;a&&(p=new ResizeObserver(y=>{let[x]=y;x&&x.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var $;($=p)==null||$.observe(t)})),r()}),u&&!l&&p.observe(u),p.observe(t));let g,h=l?Ir(e):null;l&&b();function b(){const y=Ir(e);h&&!j$(h,y)&&r(),h=y,g=requestAnimationFrame(b)}return r(),()=>{var y;c.forEach(x=>{n&&x.removeEventListener("scroll",r),i&&x.removeEventListener("resize",r)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const A4=o4,R4=i4,z4=t4,M4=s4,D4=r4,Vf=e4,U4=a4,L4=(e,t,r)=>{const o=new Map,n={platform:P4,...r},i={...n.platform,_c:o};return XM(e,t,{...n,platform:i})};var Z4=typeof document<"u",F4=function(){},ai=Z4?D.useLayoutEffect:F4;function Zi(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,o,n;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(o=r;o--!==0;)if(!Zi(e[o],t[o]))return!1;return!0}if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(t,n[o]))return!1;for(o=r;o--!==0;){const i=n[o];if(!(i==="_owner"&&e.$$typeof)&&!Zi(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function A$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bf(e,t){const r=A$(e);return Math.round(t*r)/r}function Ls(e){const t=_.useRef(e);return ai(()=>{t.current=e}),t}function q4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:o=[],platform:n,elements:{reference:i,floating:a}={},transform:s=!0,whileElementsMounted:l,open:u}=e,[c,d]=_.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=_.useState(o);Zi(f,o)||p(o);const[g,h]=_.useState(null),[b,y]=_.useState(null),x=_.useCallback(K=>{K!==N.current&&(N.current=K,h(K))},[]),$=_.useCallback(K=>{K!==I.current&&(I.current=K,y(K))},[]),v=i||g,k=a||b,N=_.useRef(null),I=_.useRef(null),O=_.useRef(c),z=l!=null,F=Ls(l),te=Ls(n),ie=Ls(u),J=_.useCallback(()=>{if(!N.current||!I.current)return;const K={placement:t,strategy:r,middleware:f};te.current&&(K.platform=te.current),L4(N.current,I.current,K).then(fe=>{const B={...fe,isPositioned:ie.current!==!1};V.current&&!Zi(O.current,B)&&(O.current=B,um.flushSync(()=>{d(B)}))})},[f,t,r,te,ie]);ai(()=>{u===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(K=>({...K,isPositioned:!1})))},[u]);const V=_.useRef(!1);ai(()=>(V.current=!0,()=>{V.current=!1}),[]),ai(()=>{if(v&&(N.current=v),k&&(I.current=k),v&&k){if(F.current)return F.current(v,k,J);J()}},[v,k,J,F,z]);const we=_.useMemo(()=>({reference:N,floating:I,setReference:x,setFloating:$}),[x,$]),oe=_.useMemo(()=>({reference:v,floating:k}),[v,k]),de=_.useMemo(()=>{const K={position:r,left:0,top:0};if(!oe.floating)return K;const fe=Bf(oe.floating,c.x),B=Bf(oe.floating,c.y);return s?{...K,transform:"translate("+fe+"px, "+B+"px)",...A$(oe.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:fe,top:B}},[r,s,oe.floating,c.x,c.y]);return _.useMemo(()=>({...c,update:J,refs:we,elements:oe,floatingStyles:de}),[c,J,we,oe,de])}const V4=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:o,padding:n}=typeof e=="function"?e(r):e;return o&&t(o)?o.current!=null?Vf({element:o.current,padding:n}).fn(r):{}:o?Vf({element:o,padding:n}).fn(r):{}}}},B4=(e,t)=>({...A4(e),options:[e,t]}),J4=(e,t)=>({...R4(e),options:[e,t]}),W4=(e,t)=>({...U4(e),options:[e,t]}),H4=(e,t)=>({...z4(e),options:[e,t]}),G4=(e,t)=>({...M4(e),options:[e,t]}),K4=(e,t)=>({...D4(e),options:[e,t]}),Y4=(e,t)=>({...V4(e),options:[e,t]});var Q4="Arrow",R$=_.forwardRef((e,t)=>{const{children:r,width:o=10,height:n=5,...i}=e;return m.jsx(Ce.svg,{...i,ref:t,width:o,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});R$.displayName=Q4;var X4=R$;function eD(e){const[t,r]=_.useState(void 0);return lt(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(n=>{if(!Array.isArray(n)||!n.length)return;const i=n[0];let a,s;if("borderBoxSize"in i){const l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;a=u.inlineSize,s=u.blockSize}else a=e.offsetWidth,s=e.offsetHeight;r({width:a,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else r(void 0)},[e]),t}var od="Popper",[z$,Qa]=Po(od),[tD,M$]=z$(od),D$=e=>{const{__scopePopper:t,children:r}=e,[o,n]=_.useState(null);return m.jsx(tD,{scope:t,anchor:o,onAnchorChange:n,children:r})};D$.displayName=od;var U$="PopperAnchor",L$=_.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:o,...n}=e,i=M$(U$,r),a=_.useRef(null),s=Ge(t,a),l=_.useRef(null);return _.useEffect(()=>{const u=l.current;l.current=o?.current||a.current,u!==l.current&&i.onAnchorChange(l.current)}),o?null:m.jsx(Ce.div,{...n,ref:s})});L$.displayName=U$;var id="PopperContent",[rD,nD]=z$(id),Z$=_.forwardRef((e,t)=>{const{__scopePopper:r,side:o="bottom",sideOffset:n=0,align:i="center",alignOffset:a=0,arrowPadding:s=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:g,...h}=e,b=M$(id,r),[y,x]=_.useState(null),$=Ge(t,xe=>x(xe)),[v,k]=_.useState(null),N=eD(v),I=N?.width??0,O=N?.height??0,z=o+(i!=="center"?"-"+i:""),F=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},te=Array.isArray(u)?u:[u],ie=te.length>0,J={padding:F,boundary:te.filter(iD),altBoundary:ie},{refs:V,floatingStyles:we,placement:oe,isPositioned:de,middlewareData:K}=q4({strategy:"fixed",placement:z,whileElementsMounted:(...xe)=>j4(...xe,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[B4({mainAxis:n+O,alignmentAxis:a}),l&&J4({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?W4():void 0,...J}),l&&H4({...J}),G4({...J,apply:({elements:xe,rects:Ro,availableWidth:ss,availableHeight:fn})=>{const{width:pt,height:zo}=Ro.reference,je=xe.floating.style;je.setProperty("--radix-popper-available-width",`${ss}px`),je.setProperty("--radix-popper-available-height",`${fn}px`),je.setProperty("--radix-popper-anchor-width",`${pt}px`),je.setProperty("--radix-popper-anchor-height",`${zo}px`)}}),v&&Y4({element:v,padding:s}),aD({arrowWidth:I,arrowHeight:O}),f&&K4({strategy:"referenceHidden",...J})]}),[fe,B]=V$(oe),Ue=Sr(g);lt(()=>{de&&Ue?.()},[de,Ue]);const ye=K.arrow?.x,Le=K.arrow?.y,U=K.arrow?.centerOffset!==0,[Q,me]=_.useState();return lt(()=>{y&&me(window.getComputedStyle(y).zIndex)},[y]),m.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...we,transform:de?we.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[K.transformOrigin?.x,K.transformOrigin?.y].join(" "),...K.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(rD,{scope:r,placedSide:fe,onArrowChange:k,arrowX:ye,arrowY:Le,shouldHideArrow:U,children:m.jsx(Ce.div,{"data-side":fe,"data-align":B,...h,ref:$,style:{...h.style,animation:de?void 0:"none"}})})})});Z$.displayName=id;var F$="PopperArrow",oD={top:"bottom",right:"left",bottom:"top",left:"right"},q$=_.forwardRef(function(t,r){const{__scopePopper:o,...n}=t,i=nD(F$,o),a=oD[i.placedSide];return m.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:m.jsx(X4,{...n,ref:r,style:{...n.style,display:"block"}})})});q$.displayName=F$;function iD(e){return e!==null}var aD=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:o,middlewareData:n}=t,a=n.arrow?.centerOffset!==0,s=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[u,c]=V$(r),d={start:"0%",center:"50%",end:"100%"}[c],f=(n.arrow?.x??0)+s/2,p=(n.arrow?.y??0)+l/2;let g="",h="";return u==="bottom"?(g=a?d:`${f}px`,h=`${-l}px`):u==="top"?(g=a?d:`${f}px`,h=`${o.floating.height+l}px`):u==="right"?(g=`${-l}px`,h=a?d:`${p}px`):u==="left"&&(g=`${o.floating.width+l}px`,h=a?d:`${p}px`),{data:{x:g,y:h}}}});function V$(e){const[t,r="center"]=e.split("-");return[t,r]}var B$=D$,ad=L$,J$=Z$,W$=q$,sD="Portal",Xa=_.forwardRef((e,t)=>{const{container:r,...o}=e,[n,i]=_.useState(!1);lt(()=>i(!0),[]);const a=r||n&&globalThis?.document?.body;return a?sm.createPortal(m.jsx(Ce.div,{...o,ref:t}),a):null});Xa.displayName=sD;function uD(e,t){return _.useReducer((r,o)=>t[r][o]??r,e)}var Gt=e=>{const{present:t,children:r}=e,o=lD(t),n=typeof r=="function"?r({present:o.isPresent}):_.Children.only(r),i=Ge(o.ref,cD(n));return typeof r=="function"||o.isPresent?_.cloneElement(n,{ref:i}):null};Gt.displayName="Presence";function lD(e){const[t,r]=_.useState(),o=_.useRef(null),n=_.useRef(e),i=_.useRef("none"),a=e?"mounted":"unmounted",[s,l]=uD(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return _.useEffect(()=>{const u=Ko(o.current);i.current=s==="mounted"?u:"none"},[s]),lt(()=>{const u=o.current,c=n.current;if(c!==e){const f=i.current,p=Ko(u);e?l("MOUNT"):p==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&f!==p?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,l]),lt(()=>{if(t){let u;const c=t.ownerDocument.defaultView??window,d=p=>{const h=Ko(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&h&&(l("ANIMATION_END"),!n.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(i.current=Ko(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:_.useCallback(u=>{o.current=u?getComputedStyle(u):null,r(u)},[])}}function Ko(e){return e?.animationName||"none"}function cD(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var dD=_[" useInsertionEffect ".trim().toString()]||lt;function es({prop:e,defaultProp:t,onChange:r=()=>{},caller:o}){const[n,i,a]=pD({defaultProp:t,onChange:r}),s=e!==void 0,l=s?e:n;{const c=_.useRef(e!==void 0);_.useEffect(()=>{const d=c.current;d!==s&&console.warn(`${o} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=s},[s,o])}const u=_.useCallback(c=>{if(s){const d=fD(c)?c(e):c;d!==e&&a.current?.(d)}else i(c)},[s,e,i,a]);return[l,u]}function pD({defaultProp:e,onChange:t}){const[r,o]=_.useState(e),n=_.useRef(r),i=_.useRef(t);return dD(()=>{i.current=t},[t]),_.useEffect(()=>{n.current!==r&&(i.current?.(r),n.current=r)},[r,n]),[r,o,i]}function fD(e){return typeof e=="function"}var mD=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),hD="VisuallyHidden",H$=_.forwardRef((e,t)=>m.jsx(Ce.span,{...e,ref:t,style:{...mD,...e.style}}));H$.displayName=hD;var gD=H$,[ts]=Po("Tooltip",[Qa]),rs=Qa(),G$="TooltipProvider",vD=700,Au="tooltip.open",[yD,sd]=ts(G$),K$=e=>{const{__scopeTooltip:t,delayDuration:r=vD,skipDelayDuration:o=300,disableHoverableContent:n=!1,children:i}=e,a=_.useRef(!0),s=_.useRef(!1),l=_.useRef(0);return _.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),m.jsx(yD,{scope:t,isOpenDelayedRef:a,delayDuration:r,onOpen:_.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,o)},[o]),isPointerInTransitRef:s,onPointerInTransitChange:_.useCallback(u=>{s.current=u},[]),disableHoverableContent:n,children:i})};K$.displayName=G$;var Qn="Tooltip",[bD,jo]=ts(Qn),Y$=e=>{const{__scopeTooltip:t,children:r,open:o,defaultOpen:n,onOpenChange:i,disableHoverableContent:a,delayDuration:s}=e,l=sd(Qn,e.__scopeTooltip),u=rs(t),[c,d]=_.useState(null),f=qr(),p=_.useRef(0),g=a??l.disableHoverableContent,h=s??l.delayDuration,b=_.useRef(!1),[y,x]=es({prop:o,defaultProp:n??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(Au))):l.onClose(),i?.(I)},caller:Qn}),$=_.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),v=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,x(!0)},[x]),k=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),N=_.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,x(!0),p.current=0},h)},[h,x]);return _.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),m.jsx(B$,{...u,children:m.jsx(bD,{scope:t,contentId:f,open:y,stateAttribute:$,trigger:c,onTriggerChange:d,onTriggerEnter:_.useCallback(()=>{l.isOpenDelayedRef.current?N():v()},[l.isOpenDelayedRef,N,v]),onTriggerLeave:_.useCallback(()=>{g?k():(window.clearTimeout(p.current),p.current=0)},[k,g]),onOpen:v,onClose:k,disableHoverableContent:g,children:r})})};Y$.displayName=Qn;var Ru="TooltipTrigger",Q$=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=jo(Ru,r),i=sd(Ru,r),a=rs(r),s=_.useRef(null),l=Ge(t,s,n.onTriggerChange),u=_.useRef(!1),c=_.useRef(!1),d=_.useCallback(()=>u.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),m.jsx(ad,{asChild:!0,...a,children:m.jsx(Ce.button,{"aria-describedby":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...o,ref:l,onPointerMove:Oe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!c.current&&!i.isPointerInTransitRef.current&&(n.onTriggerEnter(),c.current=!0)}),onPointerLeave:Oe(e.onPointerLeave,()=>{n.onTriggerLeave(),c.current=!1}),onPointerDown:Oe(e.onPointerDown,()=>{n.open&&n.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Oe(e.onFocus,()=>{u.current||n.onOpen()}),onBlur:Oe(e.onBlur,n.onClose),onClick:Oe(e.onClick,n.onClose)})})});Q$.displayName=Ru;var ud="TooltipPortal",[_D,wD]=ts(ud,{forceMount:void 0}),X$=e=>{const{__scopeTooltip:t,forceMount:r,children:o,container:n}=e,i=jo(ud,t);return m.jsx(_D,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(Xa,{asChild:!0,container:n,children:o})})})};X$.displayName=ud;var on="TooltipContent",eS=_.forwardRef((e,t)=>{const r=wD(on,e.__scopeTooltip),{forceMount:o=r.forceMount,side:n="top",...i}=e,a=jo(on,e.__scopeTooltip);return m.jsx(Gt,{present:o||a.open,children:a.disableHoverableContent?m.jsx(tS,{side:n,...i,ref:t}):m.jsx(xD,{side:n,...i,ref:t})})}),xD=_.forwardRef((e,t)=>{const r=jo(on,e.__scopeTooltip),o=sd(on,e.__scopeTooltip),n=_.useRef(null),i=Ge(t,n),[a,s]=_.useState(null),{trigger:l,onClose:u}=r,c=n.current,{onPointerInTransitChange:d}=o,f=_.useCallback(()=>{s(null),d(!1)},[d]),p=_.useCallback((g,h)=>{const b=g.currentTarget,y={x:g.clientX,y:g.clientY},x=kD(y,b.getBoundingClientRect()),$=ED(y,x),v=TD(h.getBoundingClientRect()),k=ND([...$,...v]);s(k),d(!0)},[d]);return _.useEffect(()=>()=>f(),[f]),_.useEffect(()=>{if(l&&c){const g=b=>p(b,c),h=b=>p(b,l);return l.addEventListener("pointerleave",g),c.addEventListener("pointerleave",h),()=>{l.removeEventListener("pointerleave",g),c.removeEventListener("pointerleave",h)}}},[l,c,p,f]),_.useEffect(()=>{if(a){const g=h=>{const b=h.target,y={x:h.clientX,y:h.clientY},x=l?.contains(b)||c?.contains(b),$=!OD(y,a);x?f():$&&(f(),u())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,c,a,u,f]),m.jsx(tS,{...e,ref:i})}),[$D,SD]=ts(Qn,{isInside:!1}),ID=kM("TooltipContent"),tS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,children:o,"aria-label":n,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=jo(on,r),u=rs(r),{onClose:c}=l;return _.useEffect(()=>(document.addEventListener(Au,c),()=>document.removeEventListener(Au,c)),[c]),_.useEffect(()=>{if(l.trigger){const d=f=>{f.target?.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),m.jsx(Ha,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:m.jsxs(J$,{"data-state":l.stateAttribute,...u,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(ID,{children:o}),m.jsx($D,{scope:r,isInside:!0,children:m.jsx(gD,{id:l.contentId,role:"tooltip",children:n||o})})]})})});eS.displayName=on;var rS="TooltipArrow",nS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=rs(r);return SD(rS,r).isInside?null:m.jsx(W$,{...n,...o,ref:t})});nS.displayName=rS;function kD(e,t){const r=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),n=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,o,n,i)){case i:return"left";case n:return"right";case r:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function ED(e,t,r=5){const o=[];switch(t){case"top":o.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":o.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":o.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":o.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return o}function TD(e){const{top:t,right:r,bottom:o,left:n}=e;return[{x:n,y:t},{x:r,y:t},{x:r,y:o},{x:n,y:o}]}function OD(e,t){const{x:r,y:o}=e;let n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],u=s.x,c=s.y,d=l.x,f=l.y;c>o!=f>o&&r<(d-u)*(o-c)/(f-c)+u&&(n=!n)}return n}function ND(e){const t=e.slice();return t.sort((r,o)=>r.x<o.x?-1:r.x>o.x?1:r.y<o.y?-1:r.y>o.y?1:0),PD(t)}function PD(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const n=e[o];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))t.pop();else break}t.push(n)}t.pop();const r=[];for(let o=e.length-1;o>=0;o--){const n=e[o];for(;r.length>=2;){const i=r[r.length-1],a=r[r.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))r.pop();else break}r.push(n)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var CD=K$,jD=Y$,AD=Q$,RD=X$,zD=eS,MD=nS;function oS({delayDuration:e=0,...t}){return m.jsx(CD,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ld({...e}){return m.jsx(oS,{children:m.jsx(jD,{"data-slot":"tooltip",...e})})}function cd({...e}){return m.jsx(AD,{"data-slot":"tooltip-trigger",...e})}function dd({className:e,sideOffset:t=0,children:r,...o}){return m.jsx(RD,{children:m.jsxs(zD,{"data-slot":"tooltip-content",sideOffset:t,className:T.cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...o,children:[r,m.jsx(MD,{className:"bg-foreground fill-foreground z-20 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}var Zs="focusScope.autoFocusOnMount",Fs="focusScope.autoFocusOnUnmount",Jf={bubbles:!1,cancelable:!0},DD="FocusScope",pd=_.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:n,onUnmountAutoFocus:i,...a}=e,[s,l]=_.useState(null),u=Sr(n),c=Sr(i),d=_.useRef(null),f=Ge(t,h=>l(h)),p=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(o){let h=function($){if(p.paused||!s)return;const v=$.target;s.contains(v)?d.current=v:Qt(d.current,{select:!0})},b=function($){if(p.paused||!s)return;const v=$.relatedTarget;v!==null&&(s.contains(v)||Qt(d.current,{select:!0}))},y=function($){if(document.activeElement===document.body)for(const k of $)k.removedNodes.length>0&&Qt(s)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const x=new MutationObserver(y);return s&&x.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),x.disconnect()}}},[o,s,p.paused]),_.useEffect(()=>{if(s){Hf.add(p);const h=document.activeElement;if(!s.contains(h)){const y=new CustomEvent(Zs,Jf);s.addEventListener(Zs,u),s.dispatchEvent(y),y.defaultPrevented||(UD(VD(iS(s)),{select:!0}),document.activeElement===h&&Qt(s))}return()=>{s.removeEventListener(Zs,u),setTimeout(()=>{const y=new CustomEvent(Fs,Jf);s.addEventListener(Fs,c),s.dispatchEvent(y),y.defaultPrevented||Qt(h??document.body,{select:!0}),s.removeEventListener(Fs,c),Hf.remove(p)},0)}}},[s,u,c,p]);const g=_.useCallback(h=>{if(!r&&!o||p.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,y=document.activeElement;if(b&&y){const x=h.currentTarget,[$,v]=LD(x);$&&v?!h.shiftKey&&y===v?(h.preventDefault(),r&&Qt($,{select:!0})):h.shiftKey&&y===$&&(h.preventDefault(),r&&Qt(v,{select:!0})):y===x&&h.preventDefault()}},[r,o,p.paused]);return m.jsx(Ce.div,{tabIndex:-1,...a,ref:f,onKeyDown:g})});pd.displayName=DD;function UD(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(Qt(o,{select:t}),document.activeElement!==r)return}function LD(e){const t=iS(e),r=Wf(t,e),o=Wf(t.reverse(),e);return[r,o]}function iS(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const n=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||n?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Wf(e,t){for(const r of e)if(!ZD(r,{upTo:t}))return r}function ZD(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function FD(e){return e instanceof HTMLInputElement&&"select"in e}function Qt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&FD(e)&&t&&e.select()}}var Hf=qD();function qD(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Gf(e,t),e.unshift(t)},remove(t){e=Gf(e,t),e[0]?.resume()}}}function Gf(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function VD(e){return e.filter(t=>t.tagName!=="A")}var qs=0;function aS(){_.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Kf()),document.body.insertAdjacentElement("beforeend",e[1]??Kf()),qs++,()=>{qs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),qs--}},[])}function Kf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Pt=function(){return Pt=Object.assign||function(t){for(var r,o=1,n=arguments.length;o<n;o++){r=arguments[o];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Pt.apply(this,arguments)};function sS(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function BD(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}var si="right-scroll-bar-position",ui="width-before-scroll-bar",JD="with-scroll-bars-hidden",WD="--removed-body-scroll-bar-size";function Vs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function HD(e,t){var r=D.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(o){var n=r.value;n!==o&&(r.value=o,r.callback(o,n))}}}})[0];return r.callback=t,r.facade}var GD=typeof window<"u"?_.useLayoutEffect:_.useEffect,Yf=new WeakMap;function KD(e,t){var r=HD(null,function(o){return e.forEach(function(n){return Vs(n,o)})});return GD(function(){var o=Yf.get(r);if(o){var n=new Set(o),i=new Set(e),a=r.current;n.forEach(function(s){i.has(s)||Vs(s,null)}),i.forEach(function(s){n.has(s)||Vs(s,a)})}Yf.set(r,e)},[e]),r}function YD(e){return e}function QD(e,t){t===void 0&&(t=YD);var r=[],o=!1,n={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var a=t(i,o);return r.push(a),function(){r=r.filter(function(s){return s!==a})}},assignSyncMedium:function(i){for(o=!0;r.length;){var a=r;r=[],a.forEach(i)}r={push:function(s){return i(s)},filter:function(){return r}}},assignMedium:function(i){o=!0;var a=[];if(r.length){var s=r;r=[],s.forEach(i),a=r}var l=function(){var c=a;a=[],c.forEach(i)},u=function(){return Promise.resolve().then(l)};u(),r={push:function(c){a.push(c),u()},filter:function(c){return a=a.filter(c),r}}}};return n}function XD(e){e===void 0&&(e={});var t=QD(null);return t.options=Pt({async:!0,ssr:!1},e),t}var uS=function(e){var t=e.sideCar,r=sS(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return _.createElement(o,Pt({},r))};uS.isSideCarExport=!0;function eU(e,t){return e.useMedium(t),uS}var lS=XD(),Bs=function(){},ns=_.forwardRef(function(e,t){var r=_.useRef(null),o=_.useState({onScrollCapture:Bs,onWheelCapture:Bs,onTouchMoveCapture:Bs}),n=o[0],i=o[1],a=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,y=e.as,x=y===void 0?"div":y,$=e.gapMode,v=sS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,N=KD([r,t]),I=Pt(Pt({},v),n);return _.createElement(_.Fragment,null,c&&_.createElement(k,{sideCar:lS,removeScrollBar:u,shards:d,noRelative:p,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!b,lockRef:r,gapMode:$}),a?_.cloneElement(_.Children.only(s),Pt(Pt({},I),{ref:N})):_.createElement(x,Pt({},I,{className:l,ref:N}),s))});ns.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ns.classNames={fullWidth:ui,zeroRight:si};var tU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function rU(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=tU();return t&&e.setAttribute("nonce",t),e}function nU(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function oU(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var iU=function(){var e=0,t=null;return{add:function(r){e==0&&(t=rU())&&(nU(t,r),oU(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},aU=function(){var e=iU();return function(t,r){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},cS=function(){var e=aU(),t=function(r){var o=r.styles,n=r.dynamic;return e(o,n),null};return t},sU={left:0,top:0,right:0,gap:0},Js=function(e){return parseInt(e||"",10)||0},uU=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],n=t[e==="padding"?"paddingRight":"marginRight"];return[Js(r),Js(o),Js(n)]},lU=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return sU;var t=uU(e),r=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-r+t[2]-t[0])}},cU=cS(),Br="data-scroll-locked",dU=function(e,t,r,o){var n=e.left,i=e.top,a=e.right,s=e.gap;return r===void 0&&(r="margin"),`
|
|
97
97
|
.`.concat(JD,` {
|
|
98
98
|
overflow: hidden `).concat(o,`;
|
|
99
99
|
padding-right: `).concat(s,"px ").concat(o,`;
|
package/dist/elements.js
CHANGED
|
@@ -26720,10 +26720,13 @@ function aM({ children: e }) {
|
|
|
26720
26720
|
}
|
|
26721
26721
|
);
|
|
26722
26722
|
}
|
|
26723
|
-
|
|
26724
|
-
|
|
26723
|
+
function sM(e) {
|
|
26724
|
+
return (e.api?.url || "" || "https://app.getgram.ai").replace(/\/+$/, "");
|
|
26725
|
+
}
|
|
26726
|
+
const lM = "You are a helpful assistant that can answer questions and help with tasks.";
|
|
26727
|
+
function uM(e, t) {
|
|
26725
26728
|
return `
|
|
26726
|
-
${
|
|
26729
|
+
${lM}
|
|
26727
26730
|
|
|
26728
26731
|
User-provided System Prompt:
|
|
26729
26732
|
${e ?? "None provided"}
|
|
@@ -26732,21 +26735,18 @@ function lM(e, t) {
|
|
|
26732
26735
|
${t.map((n) => `- ${n.language}: ${n.prompt}`).join(`
|
|
26733
26736
|
`)}`;
|
|
26734
26737
|
}
|
|
26735
|
-
function uM(e) {
|
|
26736
|
-
return (e.api?.url ?? "" ?? "https://app.getgram.ai").replace(/\/+$/, "");
|
|
26737
|
-
}
|
|
26738
26738
|
const cM = ({
|
|
26739
26739
|
children: e,
|
|
26740
26740
|
config: t
|
|
26741
26741
|
}) => {
|
|
26742
|
-
const n =
|
|
26742
|
+
const n = sM(t), o = iM({
|
|
26743
26743
|
auth: t.api,
|
|
26744
26744
|
projectSlug: t.projectSlug
|
|
26745
26745
|
}), r = hw(), [i, a] = Ie(
|
|
26746
26746
|
t.model?.defaultModel ?? gw[0]
|
|
26747
26747
|
), [s, u] = Ie(
|
|
26748
26748
|
t.modal?.defaultExpanded ?? !1
|
|
26749
|
-
), [l, c] = Ie(t.modal?.defaultOpen), d = t.plugins ?? q0, f =
|
|
26749
|
+
), [l, c] = Ie(t.modal?.defaultOpen), d = t.plugins ?? q0, f = uM(
|
|
26750
26750
|
t.systemPrompt,
|
|
26751
26751
|
d
|
|
26752
26752
|
), { data: p, isLoading: h } = YN({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@gram-ai/elements",
|
|
3
3
|
"description": "Gram Elements is a library of UI primitives for building chat-like experiences for MCP Servers.",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.18.
|
|
5
|
+
"version": "1.18.5",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
@@ -134,10 +134,13 @@
|
|
|
134
134
|
"typescript-eslint": "^8.48.1",
|
|
135
135
|
"vite": "^7.1.6",
|
|
136
136
|
"vite-plugin-dts": "^4.5.4",
|
|
137
|
+
"vitest": "^4.0.13",
|
|
137
138
|
"zustand": "^5.0.8"
|
|
138
139
|
},
|
|
139
140
|
"scripts": {
|
|
140
141
|
"build": "vite build",
|
|
142
|
+
"test": "vitest run",
|
|
143
|
+
"test:watch": "vitest",
|
|
141
144
|
"lint": "eslint src",
|
|
142
145
|
"analyze": "pnpm dlx vite-bundle-visualizer",
|
|
143
146
|
"storybook": "storybook dev -p 6006",
|