@piedata/pieui 1.2.7 → 1.2.8

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/index.js CHANGED
@@ -113,4 +113,4 @@ npm install @modelcontextprotocol/sdk
113
113
  Failed Guardrail Reason: ${$.guardrail.policyHint}.
114
114
  Failure Details: ${JSON.stringify($.output.outputInfo??{})}.
115
115
  Please respond again following policy. Apologize for not being able to answer the question (while avoiding the specific reason) and divert discussion back to an approved topic immediately and not invite more discussion.
116
- `.trim()}function l7($,X){return $ in X&&typeof X[$]!=="undefined"}function Kz$($){return l7("modalities",$)||l7("inputAudioFormat",$)||l7("outputAudioFormat",$)||l7("inputAudioTranscription",$)||l7("turnDetection",$)||l7("inputAudioNoiseReduction",$)||l7("speed",$)}function sa($){if(!Kz$($)){let X=$.audio?.input?{format:tq($.audio.input.format),noiseReduction:$.audio.input.noiseReduction??null,transcription:$.audio.input.transcription,turnDetection:$.audio.input.turnDetection}:void 0,Q=$.audio?.output?.voice??$.voice,J=$.audio?.output||typeof Q!=="undefined"?{format:tq($.audio?.output?.format),voice:Q,speed:$.audio?.output?.speed}:void 0;return{model:$.model,instructions:$.instructions,toolChoice:$.toolChoice,tools:$.tools,tracing:$.tracing,providerData:$.providerData,prompt:$.prompt,outputModalities:$.outputModalities,audio:X||J?{input:X,output:J}:void 0}}return{model:$.model,instructions:$.instructions,toolChoice:$.toolChoice,tools:$.tools,tracing:$.tracing,providerData:$.providerData,prompt:$.prompt,outputModalities:$.modalities,audio:{input:{format:tq($.inputAudioFormat),noiseReduction:$.inputAudioNoiseReduction??null,transcription:$.inputAudioTranscription,turnDetection:$.turnDetection},output:{format:tq($.outputAudioFormat),voice:$.voice,speed:$.speed}}}}function tq($){if(!$)return;if(typeof $==="object")return $;let X=String($);if(X==="pcm16")return{type:"audio/pcm",rate:24000};if(X==="g711_ulaw")return{type:"audio/pcmu"};if(X==="g711_alaw")return{type:"audio/pcma"};return{type:"audio/pcm",rate:24000}}var Bi$=B.object({itemId:B.string()}),mI=B.discriminatedUnion("role",[B.object({itemId:B.string(),previousItemId:B.string().nullable().optional(),type:B.literal("message"),role:B.literal("system"),content:B.array(B.object({type:B.literal("input_text"),text:B.string()}))}),B.object({itemId:B.string(),previousItemId:B.string().nullable().optional(),type:B.literal("message"),role:B.literal("user"),status:B.enum(["in_progress","completed"]),content:B.array(B.object({type:B.literal("input_text"),text:B.string()}).or(B.object({type:B.literal("input_audio"),audio:B.string().nullable().optional(),transcript:B.string().nullable()})))}),B.object({itemId:B.string(),previousItemId:B.string().nullable().optional(),type:B.literal("message"),role:B.literal("assistant"),status:B.enum(["in_progress","completed","incomplete"]),content:B.array(B.object({type:B.literal("output_text"),text:B.string()}).or(B.object({type:B.literal("output_audio"),audio:B.string().nullable().optional(),transcript:B.string().nullable().optional()})))})]),cI=B.object({itemId:B.string(),previousItemId:B.string().nullable().optional(),type:B.literal("function_call"),status:B.enum(["in_progress","completed","incomplete"]),arguments:B.string(),name:B.string(),output:B.string().nullable()}),iI=B.object({itemId:B.string(),previousItemId:B.string().nullable().optional(),type:B.enum(["mcp_call","mcp_tool_call"]),status:B.enum(["in_progress","completed","incomplete"]),arguments:B.string(),name:B.string(),output:B.string().nullable()}),ta=B.object({itemId:B.string(),type:B.literal("mcp_approval_request"),serverLabel:B.string(),name:B.string(),arguments:B.record(B.string(),B.any()),approved:B.boolean().optional().nullable()});var Vz$=F8("openai-agents:realtime"),H6=Vz$;var ea=B.object({id:B.string().optional().nullable(),conversation_id:B.string().optional().nullable(),max_output_tokens:B.number().or(B.literal("inf")).optional().nullable(),metadata:B.record(B.string(),B.any()).optional().nullable(),output_modalities:B.array(B.string()).optional().nullable(),object:B.literal("realtime.response").optional().nullable(),output:B.array(B.any()).optional().nullable(),audio:B.object({output:B.object({format:B.any().optional().nullable(),voice:B.string().optional().nullable()}).optional().nullable()}).optional().nullable(),status:B.enum(["completed","incomplete","failed","cancelled","in_progress"]).optional().nullable(),status_details:B.record(B.string(),B.any()).optional().nullable(),usage:B.object({input_tokens:B.number().optional(),input_token_details:B.record(B.string(),B.any()).optional().nullable(),output_tokens:B.number().optional(),output_token_details:B.record(B.string(),B.any()).optional().nullable()}).optional().nullable()}),Hz$=B.object({id:B.string().optional(),audio:B.string().nullable().optional(),text:B.string().nullable().optional(),transcript:B.string().nullable().optional(),type:B.union([B.literal("input_text"),B.literal("input_audio"),B.literal("item_reference"),B.literal("output_text"),B.literal("output_audio")])}),OQ=B.object({id:B.string().optional(),arguments:B.string().optional(),call_id:B.string().optional(),content:B.array(Hz$).optional(),name:B.string().optional(),output:B.string().nullable().optional(),role:B.enum(["user","assistant","system"]).optional(),status:B.enum(["completed","incomplete","in_progress"]).optional(),type:B.enum(["message","function_call","function_call_output","mcp_list_tools","mcp_tool_call","mcp_call","mcp_approval_request","mcp_approval_response"]).optional(),approval_request_id:B.string().nullable().optional(),approve:B.boolean().nullable().optional(),reason:B.string().nullable().optional(),server_label:B.string().optional(),error:B.any().nullable().optional(),tools:B.array(B.object({name:B.string(),description:B.string(),input_schema:B.record(B.string(),B.any()).optional()}).passthrough()).optional()}).passthrough(),Uz$=B.object({type:B.literal("conversation.created"),event_id:B.string(),conversation:B.object({id:B.string().optional(),object:B.literal("realtime.conversation").optional()})}),Bz$=B.object({type:B.literal("conversation.item.added"),event_id:B.string(),item:OQ,previous_item_id:B.string().nullable().optional()}),qz$=B.object({type:B.literal("conversation.item.done"),event_id:B.string(),item:OQ,previous_item_id:B.string().nullable().optional()}),zz$=B.object({type:B.literal("conversation.item.deleted"),event_id:B.string(),item_id:B.string()}),Nz$=B.object({type:B.literal("conversation.item.input_audio_transcription.completed"),event_id:B.string(),item_id:B.string(),content_index:B.number(),transcript:B.string(),logprobs:B.array(B.any()).nullable().optional(),usage:B.object({type:B.literal("tokens"),total_tokens:B.number(),input_tokens:B.number(),input_token_details:B.object({text_tokens:B.number(),audio_tokens:B.number()}),output_tokens:B.number()}).optional()}),Dz$=B.object({type:B.literal("conversation.item.input_audio_transcription.delta"),event_id:B.string(),item_id:B.string(),content_index:B.number().optional(),delta:B.string().optional(),logprobs:B.array(B.any()).nullable().optional()}),Lz$=B.object({type:B.literal("conversation.item.input_audio_transcription.failed"),event_id:B.string(),item_id:B.string(),content_index:B.number(),error:B.object({code:B.string().optional(),message:B.string().optional(),param:B.string().optional(),type:B.string().optional()})}),wz$=B.object({type:B.literal("conversation.item.retrieved"),event_id:B.string(),item:OQ}),Fz$=B.object({type:B.literal("conversation.item.truncated"),event_id:B.string(),item_id:B.string(),audio_end_ms:B.number(),content_index:B.number()}),Zz$=B.object({type:B.literal("conversation.item.create"),item:OQ,event_id:B.string().optional(),previous_item_id:B.string().nullable().optional()}),Oz$=B.object({type:B.literal("conversation.item.delete"),item_id:B.string(),event_id:B.string().optional()}),Mz$=B.object({type:B.literal("conversation.item.retrieve"),item_id:B.string(),event_id:B.string().optional()}),Az$=B.object({type:B.literal("conversation.item.truncate"),item_id:B.string(),audio_end_ms:B.number(),content_index:B.number(),event_id:B.string().optional()}),jz$=B.object({type:B.literal("error"),event_id:B.string().optional(),error:B.any().optional()}),Pz$=B.object({type:B.literal("input_audio_buffer.cleared"),event_id:B.string()}),vz$=B.object({type:B.literal("input_audio_buffer.append"),audio:B.string(),event_id:B.string().optional()}),Iz$=B.object({type:B.literal("input_audio_buffer.clear"),event_id:B.string().optional()}),xz$=B.object({type:B.literal("input_audio_buffer.commit"),event_id:B.string().optional()}),Rz$=B.object({type:B.literal("input_audio_buffer.committed"),event_id:B.string(),item_id:B.string(),previous_item_id:B.string().nullable().optional()}),_z$=B.object({type:B.literal("input_audio_buffer.speech_started"),event_id:B.string(),item_id:B.string(),audio_start_ms:B.number()}),Ez$=B.object({type:B.literal("input_audio_buffer.speech_stopped"),event_id:B.string(),item_id:B.string(),audio_end_ms:B.number()}),Tz$=B.object({type:B.literal("output_audio_buffer.started"),event_id:B.string()}).passthrough(),bz$=B.object({type:B.literal("output_audio_buffer.stopped"),event_id:B.string()}).passthrough(),Sz$=B.object({type:B.literal("output_audio_buffer.cleared"),event_id:B.string()}),kz$=B.object({type:B.literal("rate_limits.updated"),event_id:B.string(),rate_limits:B.array(B.object({limit:B.number().optional(),name:B.enum(["requests","tokens"]).optional(),remaining:B.number().optional(),reset_seconds:B.number().optional()}))}),Cz$=B.object({type:B.literal("response.output_audio.delta"),event_id:B.string(),item_id:B.string(),content_index:B.number(),delta:B.string(),output_index:B.number(),response_id:B.string()}),yz$=B.object({type:B.literal("response.output_audio.done"),event_id:B.string(),item_id:B.string(),content_index:B.number(),output_index:B.number(),response_id:B.string()}),fz$=B.object({type:B.literal("response.output_audio_transcript.delta"),event_id:B.string(),item_id:B.string(),content_index:B.number(),delta:B.string(),output_index:B.number(),response_id:B.string()}),gz$=B.object({type:B.literal("response.output_audio_transcript.done"),event_id:B.string(),item_id:B.string(),content_index:B.number(),transcript:B.string(),output_index:B.number(),response_id:B.string()}),hz$=B.object({type:B.literal("response.content_part.added"),event_id:B.string(),item_id:B.string(),content_index:B.number(),output_index:B.number(),response_id:B.string(),part:B.object({audio:B.string().optional(),text:B.string().optional(),transcript:B.string().optional(),type:B.enum(["text","audio"]).optional()})}),uz$=B.object({type:B.literal("response.content_part.done"),event_id:B.string(),item_id:B.string(),content_index:B.number(),output_index:B.number(),response_id:B.string(),part:B.object({audio:B.string().optional(),text:B.string().optional(),transcript:B.string().optional(),type:B.enum(["text","audio"]).optional()})}),mz$=B.object({type:B.literal("response.created"),event_id:B.string(),response:ea}),lI=B.object({type:B.literal("response.done"),event_id:B.string(),response:ea}),cz$=B.object({type:B.literal("response.function_call_arguments.delta"),event_id:B.string(),item_id:B.string(),call_id:B.string(),delta:B.string(),output_index:B.number(),response_id:B.string()}),iz$=B.object({type:B.literal("response.function_call_arguments.done"),event_id:B.string(),item_id:B.string(),call_id:B.string(),arguments:B.string(),output_index:B.number(),response_id:B.string()}),lz$=B.object({type:B.literal("response.output_item.added"),event_id:B.string(),item:OQ,output_index:B.number(),response_id:B.string()}),pz$=B.object({type:B.literal("response.output_item.done"),event_id:B.string(),item:OQ,output_index:B.number(),response_id:B.string()}),nz$=B.object({type:B.literal("response.output_text.delta"),event_id:B.string(),item_id:B.string(),content_index:B.number(),delta:B.string(),output_index:B.number(),response_id:B.string()}),dz$=B.object({type:B.literal("response.output_text.done"),event_id:B.string(),item_id:B.string(),content_index:B.number(),text:B.string(),output_index:B.number(),response_id:B.string()}),az$=B.object({type:B.literal("session.created"),event_id:B.string(),session:B.any()}),oz$=B.object({type:B.literal("session.updated"),event_id:B.string(),session:B.any()}),rz$=B.object({type:B.literal("response.cancel"),event_id:B.string().optional(),response_id:B.string().optional()}),sz$=B.object({type:B.literal("response.create"),event_id:B.string().optional(),response:B.any().optional()}),tz$=B.object({type:B.literal("session.update"),event_id:B.string().optional(),session:B.any()}),ez$=B.object({type:B.literal("mcp_list_tools.in_progress"),event_id:B.string().optional(),item_id:B.string().optional()}),$N$=B.object({type:B.literal("mcp_list_tools.completed"),event_id:B.string().optional(),item_id:B.string().optional()}),XN$=B.object({type:B.literal("response.mcp_call_arguments.delta"),event_id:B.string(),response_id:B.string(),item_id:B.string(),output_index:B.number(),delta:B.string(),obfuscation:B.string()}),QN$=B.object({type:B.literal("response.mcp_call_arguments.done"),event_id:B.string(),response_id:B.string(),item_id:B.string(),output_index:B.number(),arguments:B.string()}),YN$=B.object({type:B.literal("response.mcp_call.in_progress"),event_id:B.string(),output_index:B.number(),item_id:B.string()}),JN$=B.object({type:B.literal("response.mcp_call.completed"),event_id:B.string(),output_index:B.number(),item_id:B.string()}),GN$=B.object({type:B.literal("mcp_list_tools.failed"),event_id:B.string().optional(),item_id:B.string().optional()}),WN$=B.object({type:B.string(),event_id:B.string().optional().nullable()}).passthrough(),KN$=B.discriminatedUnion("type",[Uz$,Bz$,qz$,zz$,Nz$,Dz$,Lz$,wz$,Fz$,jz$,Pz$,Rz$,_z$,Ez$,Tz$,bz$,Sz$,kz$,Cz$,yz$,fz$,gz$,hz$,uz$,mz$,lI,cz$,iz$,lz$,pz$,nz$,dz$,az$,oz$,ez$,$N$,GN$,XN$,QN$,YN$,JN$]),Li$=B.discriminatedUnion("type",[Zz$,Oz$,Mz$,Az$,vz$,Iz$,xz$,rz$,sz$,tz$]);function MQ($){let X=JSON.parse($.data.toString()),Q=KN$.safeParse(X);if(!Q.success){let J=WN$.safeParse(X);if(J.success)return{data:J.data,isGeneric:!0};return{data:null,isGeneric:!0}}return{data:Q.data,isGeneric:!1}}var $o="gpt-realtime",D0={outputModalities:["audio"],audio:{input:{format:{type:"audio/pcm",rate:24000},transcription:{model:"gpt-4o-mini-transcribe"},turnDetection:{type:"semantic_vad"},noiseReduction:null},output:{format:{type:"audio/pcm",rate:24000},speed:1}}};class p7 extends FQ{#$;#X;#G=null;#Q=null;eventEmitter=new v8.EventEmitter;constructor($={}){super();this.#$=$.model??$o,this.#X=$.apiKey}get currentModel(){return this.#$}set currentModel($){this.#$=$}_afterAudioDoneEvent(){}get _rawSessionConfig(){return this.#Q??null}async _getApiKey($){let X=$.apiKey??this.#X;if(typeof X==="function")return await X();return X}_onMessage($){let{data:X,isGeneric:Q}=MQ($);if(X===null)return;if(this.emit("*",X),Q)return;if(X.type==="error")this.emit("error",{type:"error",error:X});else this.emit(X.type,X);if(X.type==="response.created"){this.emit("turn_started",{type:"response_started",providerData:{...X}});return}if(X.type==="session.updated")this.#Q=X.session;if(X.type==="response.done"){let J=lI.safeParse(X);if(!J.success){H6.error("Error parsing response done event",J.error);return}let Y=J.data.response.usage?.input_tokens??0,G=J.data.response.usage?.output_tokens??0,W=Y+G,K=new N0({inputTokens:Y,inputTokensDetails:J.data.response.usage?.input_token_details??{},outputTokens:G,outputTokensDetails:J.data.response.usage?.output_token_details??{},totalTokens:W});this.emit("usage_update",K),this.emit("turn_done",{type:"response_done",response:{id:J.data.response.id??"",output:J.data.response.output??[],usage:{inputTokens:Y,inputTokensDetails:J.data.response.usage?.input_token_details??{},outputTokens:G,outputTokensDetails:J.data.response.usage?.output_token_details??{},totalTokens:W}}});return}if(X.type==="response.output_audio.done"){this.emit("audio_done"),this._afterAudioDoneEvent();return}if(X.type==="conversation.item.deleted"){this.emit("item_deleted",{itemId:X.item_id});return}if(X.type==="conversation.item.input_audio_transcription.completed"||X.type==="conversation.item.truncated"){this.sendEvent({type:"conversation.item.retrieve",item_id:X.item_id});return}if(X.type==="conversation.item.input_audio_transcription.delta"||X.type==="response.output_text.delta"||X.type==="response.output_audio_transcript.delta"||X.type==="response.function_call_arguments.delta"){if(X.type==="response.output_audio_transcript.delta")this.emit("audio_transcript_delta",{type:"transcript_delta",delta:X.delta,itemId:X.item_id,responseId:X.response_id});return}if(X.type==="conversation.item.added"||X.type==="conversation.item.done"||X.type==="conversation.item.retrieved"){if(X.item.type==="mcp_list_tools"&&X.type==="conversation.item.done"){let J=X.item.server_label??"",Y=X.item.tools??[];try{this.emit("mcp_tools_listed",{serverLabel:J,tools:Y})}catch(G){H6.error("Error emitting mcp_tools_listed",G,X.item)}return}if(X.item.type==="message"){let J=X.type==="conversation.item.added"||X.type==="conversation.item.done"?X.previous_item_id:null,Y=mI.parse({itemId:X.item.id,previousItemId:J,type:X.item.type,role:X.item.role,content:X.item.content,status:X.item.status});this.emit("item_update",Y);return}if(X.item.type==="mcp_approval_request"&&X.type==="conversation.item.done"){let J=X.item,Y=ta.parse({itemId:J.id,type:J.type,serverLabel:J.server_label,name:J.name,arguments:JSON.parse(J.arguments||"{}"),approved:J.approved});this.emit("item_update",Y),this.emit("mcp_approval_request",Y);return}if(X.item.type==="mcp_tool_call"||X.item.type==="mcp_call"){let J=X.type==="conversation.item.done"?"completed":"in_progress",Y=iI.parse({itemId:X.item.id,type:X.item.type,status:J,arguments:X.item.arguments,name:X.item.name,output:X.item.output});if(this.emit("item_update",Y),X.type==="conversation.item.done")this.emit("mcp_tool_call_completed",Y);return}}if(X.type==="response.mcp_call.in_progress"){let J=X;this.sendEvent({type:"conversation.item.retrieve",item_id:J.item_id});return}if(X.type==="mcp_list_tools.in_progress"){let J=X;if(J.item_id)this.sendEvent({type:"conversation.item.retrieve",item_id:J.item_id});return}if(X.type==="response.output_item.done"||X.type==="response.output_item.added"){let J=X.item;if(J.type==="function_call"&&J.status==="completed"){let Y=cI.parse({itemId:J.id,type:J.type,status:"in_progress",arguments:J.arguments,name:J.name,output:null});this.emit("item_update",Y),this.emit("function_call",{id:J.id,type:"function_call",callId:J.call_id??"",arguments:J.arguments??"",name:J.name??""});return}if(J.type==="mcp_tool_call"||J.type==="mcp_call"){let Y=iI.parse({itemId:J.id,type:J.type,status:X.type==="response.output_item.done"?"completed":"in_progress",arguments:J.arguments,name:J.name,output:J.output});this.emit("item_update",Y);return}if(J.type==="message"){let Y=mI.parse({itemId:X.item.id,type:X.item.type,role:X.item.role,content:X.item.content,status:X.type==="response.output_item.done"?J.status??"completed":J.status??"in_progress"});this.emit("item_update",Y);return}}}_onError($){this.emit("error",{type:"error",error:$})}_onOpen(){this.emit("connected")}_onClose(){this.emit("disconnected")}sendMessage($,X,{triggerResponse:Q=!0}={}){let J=typeof $==="string"?[{type:"input_text",text:$}]:$.content.map((Y)=>{if(Y.type==="input_image")return{type:"input_image",image_url:Y.image,...Y.providerData??{}};return Y});if(this.sendEvent({type:"conversation.item.create",item:{type:"message",role:"user",content:J},...X}),Q)this.sendEvent({type:"response.create"})}addImage($,{triggerResponse:X=!0}={}){this.sendMessage({type:"message",role:"user",content:[{type:"input_image",image:$}]},{},{triggerResponse:X})}_getMergedSessionConfig($){let X=sa($),Q=X.audio?.input?.noiseReduction,J=X.audio?.input?.transcription,Y=p7.buildTurnDetectionConfig(X.audio?.input?.turnDetection),G={type:"realtime",instructions:X.instructions,model:X.model??this.#$,output_modalities:X.outputModalities??D0.outputModalities,audio:{input:{format:X.audio?.input?.format??D0.audio?.input?.format,noise_reduction:Q===void 0?D0.audio?.input?.noiseReduction:Q,transcription:J===void 0?D0.audio?.input?.transcription:J,turn_detection:Y===void 0?D0.audio?.input?.turnDetection:Y},output:{format:X.audio?.output?.format??D0.audio?.output?.format,voice:X.audio?.output?.voice??D0.audio?.output?.voice,speed:X.audio?.output?.speed??D0.audio?.output?.speed}},tool_choice:X.toolChoice??D0.toolChoice,...X.providerData??{}};if(X.prompt)G.prompt={id:X.prompt.promptId,version:X.prompt.version,variables:X.prompt.variables};if(X.tools&&X.tools.length>0)G.tools=X.tools.map((W)=>{let K=(V)=>Object.fromEntries(Object.entries(V).filter(([,H])=>typeof H!=="undefined"));if(W.type==="mcp")return K({type:"mcp",server_label:W.server_label,server_url:W.server_url,server_description:W.server_description,connector_id:W.connector_id,authorization:W.authorization,headers:W.headers,allowed_tools:W.allowed_tools,require_approval:W.require_approval});return K({type:W.type,name:W.name,description:W.description,parameters:W.parameters})});return G}buildSessionPayload($){return this._getMergedSessionConfig($)}static buildTurnDetectionConfig($){if(typeof $==="undefined")return;if($===null)return null;let{type:X,createResponse:Q,create_response:J,eagerness:Y,interruptResponse:G,interrupt_response:W,prefixPaddingMs:K,prefix_padding_ms:V,silenceDurationMs:H,silence_duration_ms:U,threshold:q,idleTimeoutMs:z,idle_timeout_ms:L,modelVersion:D,model_version:N,...w}=$,Z={type:X,create_response:Q??J,eagerness:Y,interrupt_response:G??W,prefix_padding_ms:K??V,silence_duration_ms:H??U,idle_timeout_ms:z??L,model_version:D??N,threshold:q,...w};return Object.keys(Z).forEach((O)=>{if(Z[O]===void 0)delete Z[O]}),Object.keys(Z).length>0?Z:void 0}set _tracingConfig($){this.#G=$}_updateTracingConfig($){if(typeof this.#G==="undefined")this.#G=null;if($==="auto"){this.sendEvent({type:"session.update",session:{type:"realtime",tracing:"auto"}});return}if(this.#G!==null&&typeof this.#G!=="string"&&typeof $!=="string"){H6.warn("Tracing config is already set, skipping setting it again. This likely happens when you already set a tracing config on session creation.");return}if($===null){H6.debug("Disabling tracing for this session. It cannot be turned on for this session from this point on."),this.sendEvent({type:"session.update",session:{type:"realtime",tracing:null}});return}if(this.#G===null||typeof this.#G==="string"){this.sendEvent({type:"session.update",session:{type:"realtime",tracing:$}});return}if($?.group_id!==this.#G?.group_id||$?.metadata!==this.#G?.metadata||$?.workflow_name!==this.#G?.workflow_name){H6.warn("Mismatch in tracing config. Ignoring the new tracing config. This likely happens when you already set a tracing config on session creation. Current tracing config: %s, new tracing config: %s",JSON.stringify(this.#G),JSON.stringify($));return}this.sendEvent({type:"session.update",session:{type:"realtime",tracing:$}})}updateSessionConfig($){let X=this.buildSessionPayload($);this.sendEvent({type:"session.update",session:X})}sendFunctionCallOutput($,X,Q=!0){this.sendEvent({type:"conversation.item.create",item:{type:"function_call_output",output:X,call_id:$.callId}});try{let J=cI.parse({itemId:$.id,previousItemId:$.previousItemId,type:"function_call",status:"completed",arguments:$.arguments,name:$.name,output:X});this.emit("item_update",J)}catch(J){H6.error("Error parsing tool call item",J,$)}if(Q)this.sendEvent({type:"response.create"})}sendAudio($,{commit:X=!1}={}){if(this.sendEvent({type:"input_audio_buffer.append",audio:fI($)}),X)this.sendEvent({type:"input_audio_buffer.commit"})}resetHistory($,X){let{removals:Q,additions:J,updates:Y}=la($,X),G=new Set(Q.map((K)=>K.itemId));for(let K of Y)G.add(K.itemId);if(G.size>0)for(let K of G)this.sendEvent({type:"conversation.item.delete",item_id:K});let W=[...J,...Y];for(let K of W)if(K.type==="message"){let V={type:"message",role:K.role,content:K.content,id:K.itemId};if(K.role!=="system"&&K.status)V.status=K.status;this.sendEvent({type:"conversation.item.create",item:V})}else if(K.type==="function_call")H6.warn("Function calls cannot be manually added or updated at the moment. Ignoring.")}sendMcpResponse($,X){this.sendEvent({type:"conversation.item.create",previous_item_id:$.itemId,item:{type:"mcp_approval_response",approval_request_id:$.itemId,approve:X}})}}class AQ extends p7{options;#$;#X={status:"disconnected",peerConnection:void 0,dataChannel:void 0,callId:void 0};#G;#Q=!1;#W=!1;#J;#K=0;constructor($={}){if(typeof RTCPeerConnection==="undefined")throw new Error("WebRTC is not supported in this environment");super($);this.options=$,this.#$=$.baseUrl??"https://api.openai.com/v1/realtime/calls",this.#G=$.useInsecureApiKey??!1}get callId(){return this.#X.callId}get status(){return this.#X.status}get connectionState(){return this.#X}get muted(){return this.#W}async connect($){if(this.#X.status==="connected")return;if(this.#X.status==="connecting"){if(this.#J)return this.#J;H6.warn("Realtime connection already in progress but no promise found");return}let X=$.model??this.currentModel;this.currentModel=X;let Q=$.url??this.#$,J=await this._getApiKey($),Y=typeof J==="string"&&J.startsWith("ek_");if(wG()&&!this.#G&&!Y)throw new U$("Using the WebRTC connection in a browser environment requires an ephemeral client key. If you need to use a regular API key, use the WebSocket transport or set the `useInsecureApiKey` option to true.");let G=++this.#K;return this.#J=new Promise(async(W,K)=>{try{let V={...$.initialSessionConfig||{},model:this.currentModel},H=new URL(Q),U=new RTCPeerConnection,q=U.createDataChannel("oai-events"),z=void 0,L=(F)=>{F.onconnectionstatechange=()=>{switch(F.connectionState){case"disconnected":case"failed":case"closed":this.close();break}}};L(U),this.#X={status:"connecting",peerConnection:U,dataChannel:q,callId:z},this.emit("connection_change",this.#X.status),q.addEventListener("open",()=>{this.#X={status:"connecting",peerConnection:U,dataChannel:q,callId:z};let F=!1,M,A=()=>{if(F)return;if(F=!0,M!==void 0)clearTimeout(M);if(q.removeEventListener("message",v),q.removeEventListener("close",T),this.#X.status!=="connecting"||this.#X.dataChannel!==q||q.readyState!=="open"){if(this.#X.dataChannel===q)this.close();K(new Error("Connection closed before session config was acknowledged"));return}this.#X={status:"connected",peerConnection:U,dataChannel:q,callId:z},this.emit("connection_change",this.#X.status),this._onOpen(),W()},v=(R)=>{if(JSON.parse(R.data).type==="session.updated")A()},T=()=>{A()};M=setTimeout(()=>{if(!F)H6.warn("Timed out waiting for session.updated ack — resolving connect() anyway"),A()},5000),q.addEventListener("message",v),q.addEventListener("close",T),q.addEventListener("message",(R)=>{this._onMessage(R);let{data:h,isGeneric:J$}=MQ(R);if(!h||J$)return;if(h.type==="response.created")this.#Q=!0;else if(h.type==="response.done")this.#Q=!1;if(h.type==="session.created"){this._tracingConfig=h.session.tracing;let B$=typeof V.tracing==="undefined"?"auto":V.tracing;this._updateTracingConfig(B$)}}),this.updateSessionConfig(V)}),q.addEventListener("error",(F)=>{this.close(),this._onError(F),K(F)});let D=this.options.audioElement??document.createElement("audio");D.autoplay=!0,U.ontrack=(F)=>{D.srcObject=F.streams[0]};let N=this.options.mediaStream??await navigator.mediaDevices.getUserMedia({audio:!0});if(U.addTrack(N.getAudioTracks()[0]),this.options.changePeerConnection){let F=U;if(U=await this.options.changePeerConnection(U),F!==U)F.onconnectionstatechange=null;L(U),this.#X={...this.#X,peerConnection:U}}let w=await U.createOffer();if(await U.setLocalDescription(w),!w.sdp)throw new Error("Failed to create offer");let Z=await fetch(H,{method:"POST",body:w.sdp,headers:{"Content-Type":"application/sdp",Authorization:`Bearer ${J}`,"X-OpenAI-Agents-SDK":rq["X-OpenAI-Agents-SDK"]}});z=Z.headers?.get("Location")?.split("/").pop(),this.#X={...this.#X,callId:z};let O={type:"answer",sdp:await Z.text()};await U.setRemoteDescription(O)}catch(V){this.close(),this._onError(V),K(V)}}).finally(()=>{if(this.#K===G)this.#J=void 0}),this.#J}sendEvent($){if(!this.#X.dataChannel||this.#X.dataChannel.readyState!=="open")throw new Error("WebRTC data channel is not connected. Make sure you call `connect()` before sending events.");this.#X.dataChannel.send(JSON.stringify($))}mute($){if(this.#W=$,this.#X.peerConnection)this.#X.peerConnection.getSenders().forEach((Q)=>{if(Q.track)Q.track.enabled=!$})}_afterAudioDoneEvent(){this.#Q=!1}close(){if(this.#X.dataChannel)this.#X.dataChannel.close();if(this.#X.peerConnection){let $=this.#X.peerConnection;$.onconnectionstatechange=null,$.getSenders().forEach((X)=>{X.track?.stop()}),$.close()}if(this.#X.status!=="disconnected")this.#X={status:"disconnected",peerConnection:void 0,dataChannel:void 0,callId:void 0},this.emit("connection_change",this.#X.status),this._onClose()}interrupt(){if(this.#Q)this.sendEvent({type:"response.cancel"}),this.#Q=!1;this.sendEvent({type:"output_audio_buffer.clear"})}}var x2$=V$(ro()),R2$=V$(Wz()),_2$=V$(vQ()),E2$=V$(rI()),T2$=V$(tI()),b2$=V$(Jx()),qz=V$(Uz()),S2$=V$(Qr());function Yr(){return!1}var Jr=!1;class IW extends p7{#$;#X;#G;#Q={status:"disconnected",websocket:void 0};#W;#J;#K;_firstAudioTimestamp;_audioLengthMs=0;#Y=!1;#V;#U;#H(){this.#J=void 0,this._firstAudioTimestamp=void 0,this._audioLengthMs=0,this.#K=void 0}constructor($={}){super($);this.#X=$.url,this.#G=$.url,this.#W=$.useInsecureApiKey??!1,this.#V=$.createWebSocket,this.#U=$.skipOpenEventListeners??!1}getCommonRequestHeaders(){return rq}get status(){return this.#Q.status}get connectionState(){return this.#Q}get muted(){return null}get currentItemId(){return this.#J}_onAudio($){this.emit("audio",$)}_afterAudioDoneEvent(){this.#H()}async#q($,X,Q){if(this.#Q.websocket){$();return}if(!this.#$)throw new U$("API key is not set. Please call `connect()` with an API key first.");if(Yr()&&!this.#$.startsWith("ek_")&&!this.#W)throw new U$("Using the WebSocket connection in a browser environment requires an ephemeral client key. If you have to use a regular API key, set the `useInsecureApiKey` option to true.");let J=null;if(this.#V)J=await this.#V({url:this.#X,apiKey:this.#$});else{let G=Jr?["realtime","openai-insecure-api-key."+this.#$,na]:{headers:{Authorization:`Bearer ${this.#$}`,...this.getCommonRequestHeaders()}};J=new qz.default(this.#X,G)}this.#Q={status:"connecting",websocket:J},this.emit("connection_change",this.#Q.status);let Y=()=>{this.#Q={status:"connected",websocket:J},this.emit("connection_change",this.#Q.status),this._onOpen(),$()};if(this.#U===!0)Y();else J.addEventListener("open",Y);J.addEventListener("error",(G)=>{this._onError(G),this.#Q={status:"disconnected",websocket:void 0},this.emit("connection_change",this.#Q.status),X(G)}),J.addEventListener("message",(G)=>{this._onMessage(G);let{data:W,isGeneric:K}=MQ(G);if(!W||K)return;if(W.type==="response.output_audio.delta"){if(this.#K=W.content_index,this.#J=W.item_id,this._firstAudioTimestamp===void 0)this._firstAudioTimestamp=Date.now(),this._audioLengthMs=0;let V=yI(W.delta),H=this._rawSessionConfig?.audio?.output?.format;if(H&&typeof H==="object"){let q=H.type;if(q==="audio/pcmu"||q==="audio/pcma")this._audioLengthMs+=V.byteLength/8;else if(q==="audio/pcm"){let z=H.rate??24000;this._audioLengthMs+=V.byteLength/2/z*1000}else this._audioLengthMs+=V.byteLength/24/2}else if(typeof H==="string")if(H.startsWith("g711_"))this._audioLengthMs+=V.byteLength/8;else this._audioLengthMs+=V.byteLength/24/2;else this._audioLengthMs+=V.byteLength/24/2;let U={type:"audio",data:V,responseId:W.response_id};this._onAudio(U)}else if(W.type==="input_audio_buffer.speech_started"){let V=this._rawSessionConfig?.audio?.input?.turn_detection?.interrupt_response??!1;this.interrupt(!V)}else if(W.type==="response.created")this.#Y=!0;else if(W.type==="response.done")this.#Y=!1;else if(W.type==="session.created"){this._tracingConfig=W.session.tracing;let V=typeof Q.tracing==="undefined"?"auto":Q.tracing;this._updateTracingConfig(V)}}),J.addEventListener("close",()=>{this.#Q={status:"disconnected",websocket:void 0},this.emit("connection_change",this.#Q.status),this._onClose()})}async connect($){let X=$.model??this.currentModel;this.currentModel=X,this.#$=await this._getApiKey($);let Q=$.callId,J;if($.url)J=$.url,this.#G=$.url;else if(Q)J=`wss://api.openai.com/v1/realtime?call_id=${Q}`;else if(this.#G)J=this.#G;else J=`wss://api.openai.com/v1/realtime?model=${this.currentModel}`;this.#X=J;let Y={...$.initialSessionConfig||{},model:this.currentModel};await new Promise((G,W)=>{this.#q(G,W,Y).catch(W)}),await this.updateSessionConfig(Y)}sendEvent($){if(!this.#Q.websocket)throw new Error("WebSocket is not connected. Make sure you call `connect()` before sending events.");this.#Q.websocket.send(JSON.stringify($))}close(){this.#Q.websocket?.close(),this.#J=void 0,this._firstAudioTimestamp=void 0,this._audioLengthMs=0,this.#K=void 0}mute($){throw new Error("Mute is not supported for the WebSocket transport. You have to mute the audio input yourself.")}sendAudio($,X={}){if(this.#Q.status==="connected")super.sendAudio($,X)}_cancelResponse(){if(this.#Y)this.sendEvent({type:"response.cancel"}),this.#Y=!1}_interrupt($,X=!0){if($<0)return;if(X)this._cancelResponse();let Q=this._audioLengthMs??Number.POSITIVE_INFINITY,J=Math.max(0,Math.floor(Math.min($,Q)));this.emit("audio_interrupted"),this.sendEvent({type:"conversation.item.truncate",item_id:this.#J,content_index:this.#K,audio_end_ms:J})}interrupt($=!0){if(!this.#J||typeof this._firstAudioTimestamp!=="number")return;let X=Date.now()-this._firstAudioTimestamp;if(X>=0)this._interrupt(X,$);this.#H()}}var k2$=Symbol("backgroundResult");function Gx($){return typeof $==="object"&&$!==null&&k2$ in $}function Gr($){return $.type==="function"||$.type==="hosted_tool"&&$.name==="hosted_mcp"}function Wr($){if($.type==="function")return $;if($.type==="hosted_tool"&&$.name==="hosted_mcp"){let X=$.providerData.server_url&&$.providerData.server_url.length>0?$.providerData.server_url:void 0;return{type:"mcp",server_label:$.providerData.server_label,server_url:X,headers:$.providerData.headers,allowed_tools:$.providerData.allowed_tools,require_approval:$.providerData.require_approval}}throw new U$(`Invalid tool type: ${$}`)}function C2$(){return JSON.parse(JSON.stringify(D0))}var Wx="Tool execution was not approved.";function y2$($){return $ instanceof Error?$.message:String($)}class TQ extends v8.EventEmitter{initialAgent;options;#$;#X;#G;#Q;#W=[];#J;#K={};#Y=[];#V;#U={};#H=!1;#q=new Map;#B=[];#N=C2$();#D=!0;#z=!1;constructor($,X={}){super();if(this.initialAgent=$,this.options=X,typeof X.transport==="undefined"&&pa()||X.transport==="webrtc")this.#$=new AQ;else if(X.transport==="websocket"||typeof X.transport==="undefined")this.#$=new IW;else this.#$=X.transport;this.#X=$,this.#Q=new O6({...X.context??{},history:this.#Y}),this.#W=(X.outputGuardrails??[]).map(oa),this.#J=aa(X.outputGuardrailSettings??{}),this.#V=X.historyStoreAudio??!1,this.#D=X.automaticallyTriggerResponseForMcpToolCalls??!0}get transport(){return this.#$}get currentAgent(){return this.#X}get usage(){return this.#Q.usage}get context(){return this.#Q}get muted(){return this.#$.muted}get history(){return this.#Y}get availableMcpTools(){return this.#B}async#L($){this.#X=$;let X=await this.#X.getEnabledHandoffs(this.#Q),Q=X.map((W)=>W.getHandoffAsFunctionTool()),J=(await this.#X.getAllTools(this.#Q)).filter(Gr).map(Wr),Y=typeof this.#X.tools!=="undefined"||typeof this.#X.mcpServers!=="undefined",G=X.length>0;this.#G=Y||G?[...J,...Q]:void 0,this.#O()}async#w($={}){let X=$??{},Q=this.options.config??{},J=await this.#X.getSystemPrompt(this.#Q),Y=(q)=>{return q.audio?.output?.voice},G=this.options.tracingDisabled?null:this.options.workflowName?{workflow_name:this.options.workflowName}:"auto";if(G!==null&&G!=="auto"){if(this.options.groupId)G.group_id=this.options.groupId;if(this.options.traceMetadata)G.metadata=this.options.traceMetadata}else if(this.options.groupId||this.options.traceMetadata)H6.warn("In order to set traceMetadata or a groupId you need to specify a workflowName.");let W=Y(X)??Y(Q),K=X.voice??Q.voice,V=typeof W!=="undefined"?W:typeof K!=="undefined"?K:this.#X.voice,U={...{...this.#N??{},...Q,...X},instructions:J,voice:V,model:this.options.model,tools:this.#G,tracing:G,prompt:typeof this.#X.prompt==="function"?await this.#X.prompt(this.#Q,this.#X):this.#X.prompt};return this.#N=U,U}async getInitialSessionConfig($={}){return await this.#L(this.initialAgent),this.#w({...this.options.config??{},...$??{}})}static async computeInitialSessionConfig($,X={},Q={}){let J=new TQ($,X);try{return await J.getInitialSessionConfig(Q)}finally{J.close()}}async updateAgent($){return this.#X.emit("agent_handoff",this.#Q,$),this.emit("agent_handoff",this.#Q,this.#X,$),await this.#L($),await this.#$.updateSessionConfig(await this.#w()),$}async#M($,X){let Q=await X.onInvokeHandoff(this.#Q,$.arguments);this.#X.emit("agent_handoff",this.#Q,Q),this.emit("agent_handoff",this.#Q,this.#X,Q),await this.#L(Q),await this.#$.updateSessionConfig(await this.#w());let J=BW(Q);return this.#$.sendFunctionCallOutput($,J,!0),Q}async#A($,X){let{toolErrorFormatter:Q}=this.options;if(!Q)return Wx;try{let J=await Q({kind:"approval_rejected",toolType:"function",toolName:$,callId:X,defaultMessage:Wx,runContext:this.#Q});if(typeof J==="string")return J;if(typeof J!=="undefined")H6.warn("toolErrorFormatter returned a non-string value. Falling back to the default tool approval rejection message.")}catch(J){H6.warn(`toolErrorFormatter threw while formatting approval rejection: ${y2$(J)}`)}return Wx}async#F($,X){this.#Q.context.history=JSON.parse(JSON.stringify(this.#Y));let Q=$.arguments;if(X.parameters)if($1(X.parameters))Q=X.parameters.parse(Q);else Q=JSON.parse(Q);if(await X.needsApproval(this.#Q,Q,$.callId)){let V=this.context.isToolApproved({toolName:X.name,callId:$.callId});if(V===!1){this.emit("agent_tool_start",this.#Q,this.#X,X,{toolCall:$}),this.#X.emit("agent_tool_start",this.#Q,X,{toolCall:$});let H=await this.#A(X.name,$.callId);this.#$.sendFunctionCallOutput($,H,!0),this.emit("agent_tool_end",this.#Q,this.#X,X,H,{toolCall:$}),this.#X.emit("agent_tool_end",this.#Q,X,H,{toolCall:$});return}else if(typeof V==="undefined"){this.emit("tool_approval_requested",this.#Q,this.#X,{type:"function_approval",tool:X,approvalItem:new l$($,this.#X)});return}}let Y=await NW({guardrails:X.inputGuardrails,context:this.#Q,agent:this.#X,toolCall:$});this.emit("agent_tool_start",this.#Q,this.#X,X,{toolCall:$}),this.#X.emit("agent_tool_start",this.#Q,X,{toolCall:$}),this.#Q.context.history=JSON.parse(JSON.stringify(this.#Y));let G=Y.type==="reject"?Y.message:await MG({tool:X,runContext:this.#Q,input:$.arguments,details:{toolCall:$}}),W=Y.type==="reject"?G:await DW({guardrails:X.outputGuardrails,context:this.#Q,agent:this.#X,toolCall:$,toolOutput:G}),K;if(Gx(W))K=i1(W.content),this.#$.sendFunctionCallOutput($,K,!1);else K=i1(W),this.#$.sendFunctionCallOutput($,K,!0);this.emit("agent_tool_end",this.#Q,this.#X,X,K,{toolCall:$}),this.#X.emit("agent_tool_end",this.#Q,X,K,{toolCall:$})}async#j($){let X=await this.#X.getEnabledHandoffs(this.#Q),Q=new Map(X.map((W)=>[W.toolName,W])),J=await this.#X.getAllTools(this.#Q),Y=new Map(J.map((W)=>[W.name,W])),G=Q.get($.name);if(G)await this.#M($,G);else{let W=Y.get($.name);if(W&&W.type==="function")await this.#F($,W);else throw new T4(`Tool ${$.name} not found`)}}async#Z($,X,Q){if(this.#W.length===0)return;let J={agent:this.#X,agentOutput:$,context:this.#Q},G=(await Promise.all(this.#W.map((W)=>W.run(J)))).find((W)=>W.output.tripwireTriggered);if(G){if(this.#U[X])return;this.#U[X]=!0;let W=new e9(`Output guardrail triggered: ${JSON.stringify(G.output.outputInfo)}`,G);this.emit("guardrail_tripped",this.#Q,this.#X,W,{itemId:Q}),this.interrupt();let K=ra(G);this.sendMessage(K);return}}#P(){this.#$.on("*",(Q)=>{if(this.emit("transport_event",Q),Q.type==="conversation.item.input_audio_transcription.completed")try{let J=Q;this.#Y=hI(this.#Y,J,this.#V),this.#Q.context.history=this.#Y,this.emit("history_updated",this.#Y)}catch(J){this.emit("error",{type:"error",error:J})}}),this.#$.on("mcp_tools_listed",({serverLabel:Q,tools:J})=>{try{this.#q.set(Q,J??[]),this.#O()}catch(Y){this.emit("error",{type:"error",error:Y})}}),this.#$.on("audio",(Q)=>{if(!this.#H)this.#H=!0,this.emit("audio_start",this.#Q,this.#X);this.emit("audio",Q)}),this.#$.on("turn_started",()=>{this.#H=!1,this.emit("agent_start",this.#Q,this.#X),this.#X.emit("agent_start",this.#Q,this.#X)}),this.#$.on("turn_done",(Q)=>{let J=Q.response.output??[],Y="",G="";for(let W=J.length-1;W>=0;W--){let K=J[W],V=gI(K);if(typeof V==="string"){Y=V;let H=K?.id;G=typeof H==="string"?H:"";break}}if(!G&&J.length>0){let W=J[J.length-1];G=typeof W?.id==="string"?W.id:""}this.emit("agent_end",this.#Q,this.#X,Y),this.#X.emit("agent_end",this.#Q,Y),this.#Z(Y,Q.response.id,G)}),this.#$.on("audio_done",()=>{if(this.#H)this.#H=!1;this.emit("audio_stopped",this.#Q,this.#X)});let $=0,X;this.#$.on("audio_transcript_delta",(Q)=>{try{let{delta:J,itemId:Y,responseId:G}=Q;if(X!==Y)X=Y,$=0;let K=(this.#K[Y]??"")+J;if(this.#K[Y]=K,this.#J.debounceTextLength<0)return;let V=Math.floor(K.length/this.#J.debounceTextLength);if(V>$)$=V,this.#Z(K,G,Y)}catch(J){this.emit("error",{type:"error",error:J})}}),this.#$.on("item_update",(Q)=>{try{let J=!this.#Y.some((Y)=>Y.itemId===Q.itemId);if(this.#Y=hI(this.#Y,Q,this.#V),this.#Q.context.history=this.#Y,J){let Y=this.#Y.find((G)=>G.itemId===Q.itemId);if(Y)this.emit("history_added",Y)}this.emit("history_updated",this.#Y)}catch(J){this.emit("error",{type:"error",error:J})}}),this.#$.on("item_deleted",(Q)=>{try{this.#Y=this.#Y.filter((J)=>J.itemId!==Q.itemId),this.#Q.context.history=this.#Y,this.emit("history_updated",this.#Y)}catch(J){this.emit("error",{type:"error",error:J})}}),this.#$.on("function_call",async(Q)=>{try{await this.#j(Q)}catch(J){H6.error("Error handling function call",J),this.emit("error",{type:"error",error:J})}}),this.#$.on("usage_update",(Q)=>{this.#Q.usage.add(Q)}),this.#$.on("audio_interrupted",()=>{if(this.#H)this.#H=!1;this.emit("audio_interrupted",this.#Q,this.#X)}),this.#$.on("error",(Q)=>{this.emit("error",Q)}),this.#$.on("mcp_tool_call_completed",(Q)=>{if(this.emit("mcp_tool_call_completed",this.#Q,this.#X,Q),this.#D)this.#$.sendEvent({type:"response.create"})}),this.#$.on("mcp_approval_request",(Q)=>{this.emit("tool_approval_requested",this.#Q,this.#X,{type:"mcp_approval_request",approvalItem:da(this.#X,Q)})})}#O(){let $=this.#G?.filter((W)=>W.type==="mcp"),X=(W)=>{let K=W.allowed_tools;if(!K)return;if(Array.isArray(K))return K;if(K&&Array.isArray(K.tool_names))return K.tool_names;return},Q=new Map;for(let W of $){let K=this.#q.get(W.server_label)??[],V=X(W);for(let H of K){if(V&&!V.includes(H.name))continue;if(!Q.has(H.name))Q.set(H.name,H)}}let J=Array.from(Q.values()),Y=this.#B;if(Y.length!==J.length||JSON.stringify(Y.map((W)=>W.name).sort())!==JSON.stringify(J.map((W)=>W.name).sort()))this.#B=J,this.emit("mcp_tools_changed",this.#B)}async connect($){if(await this.#L(this.initialAgent),!this.#z)this.#P(),this.#z=!0;await this.#$.connect({apiKey:$.apiKey??this.options.apiKey,model:this.options.model,url:$.url,callId:$.callId,initialSessionConfig:await this.#w(this.options.config)}),this.#Y=[],this.emit("history_updated",this.#Y)}updateHistory($){let X;if(typeof $==="function")X=$(this.#Y);else X=$;this.#$.resetHistory(this.#Y,X)}sendMessage($,X={}){this.#$.sendMessage($,X)}addImage($,{triggerResponse:X=!0}={}){this.#$.addImage($,{triggerResponse:X})}mute($){this.#$.mute($)}close(){this.#U={},this.#$.close()}sendAudio($,X={}){this.#$.sendAudio($,X)}interrupt(){this.#$.interrupt()}async approve($,X={alwaysApprove:!1}){this.#Q.approveTool($,X);let Q=$.toolName??$.rawItem.name,J=this.#X.tools.find((Y)=>Y.name===Q);if(J&&J.type==="function"&&$.rawItem.type==="function_call")await this.#F($.rawItem,J);else if($.rawItem.type==="hosted_tool_call"){if(X.alwaysApprove)H6.warn("Always approving MCP tools is not supported. Use the allowed tools configuration instead.");let Y=uI($);this.#$.sendMcpResponse(Y,!0)}else throw new T4(`Tool ${Q??"unknown"} not found`)}async reject($,X={alwaysReject:!1}){this.#Q.rejectTool($,X);let Q=$.toolName??$.rawItem.name,J=this.#X.tools.find((Y)=>Y.name===Q);if(J&&J.type==="function"&&$.rawItem.type==="function_call")await this.#F($.rawItem,J);else if($.rawItem.type==="hosted_tool_call"){if(X.alwaysReject)H6.warn("Always rejecting MCP tools is not supported. Use the allowed tools configuration instead.");let Y=uI($);this.#$.sendMcpResponse(Y,!1)}else throw new T4(`Tool ${Q??"unknown"} not found`)}}W6();W6();W6();W6();W6();W6();W6();W6();W6();W6();W6();W6();W6();W6();var f2$=class{apply($,X){if(!X.type)return;let Q=Array.isArray(X.type)?X.type:[X.type],J=new Set(Q);if(!J.has("string"))$.string=!1;if(!J.has("number")&&!J.has("integer"))$.number=!1;if(!J.has("boolean"))$.boolean=!1;if(!J.has("null"))$.null=!1;if(!J.has("array"))$.array=!1;if(!J.has("object"))$.object=!1;if(J.has("integer")&&$.number!==!1){let Y=$.number||B.number();if(Y instanceof B.ZodNumber)$.number=Y.int()}}},g2$=class{apply($,X){if(X.const===void 0)return;let Q=X.const;if($.string=!1,$.number=!1,$.boolean=!1,$.null=!1,$.array=!1,$.object=!1,typeof Q==="string")$.string=B.literal(Q);else if(typeof Q==="number")$.number=B.literal(Q);else if(typeof Q==="boolean")$.boolean=B.literal(Q);else if(Q===null)$.null=B.null();else if(Array.isArray(Q))$.array=void 0;else if(typeof Q==="object")$.object=void 0}},h2$=class{apply($,X){if(!X.enum)return;if(X.enum.length===0){if(!X.type)$.string=!1,$.number=!1,$.boolean=!1,$.null=!1,$.array=!1,$.object=!1;return}let Q={string:X.enum.filter((J)=>typeof J==="string"),number:X.enum.filter((J)=>typeof J==="number"),boolean:X.enum.filter((J)=>typeof J==="boolean"),null:X.enum.filter((J)=>J===null),array:X.enum.filter((J)=>Array.isArray(J)),object:X.enum.filter((J)=>typeof J==="object"&&J!==null&&!Array.isArray(J))};$.string=this.createTypeSchema(Q.string,"string"),$.number=this.createTypeSchema(Q.number,"number"),$.boolean=this.createTypeSchema(Q.boolean,"boolean"),$.null=Q.null.length>0?B.null():!1,$.array=Q.array.length>0?void 0:!1,$.object=Q.object.length>0?void 0:!1}createTypeSchema($,X){if($.length===0)return!1;if($.length===1)return B.literal($[0]);if(X==="string")return B.enum($);if(X==="number"){let[Q,J,...Y]=$;return B.union([B.literal(Q),B.literal(J),...Y.map((G)=>B.literal(G))])}if(X==="boolean")return B.union([B.literal(!0),B.literal(!1)]);return!1}},u2$=class{apply($,X){let Q=X;if(Q.type==="string"&&Q.format==="binary"&&Q.contentEncoding==="binary"){let J=B.file();if(Q.minLength!==void 0)J=J.min(Q.minLength);if(Q.maxLength!==void 0)J=J.max(Q.maxLength);if(Q.contentMediaType!==void 0)J=J.mime(Q.contentMediaType);$.file=J,$.string=!1}}},m2$=class{apply($,X){let Q=X;if(X.type===void 0&&(Q.minLength!==void 0||Q.maxLength!==void 0||Q.pattern!==void 0)){if($.string===void 0)$.string=B.string()}}},c2$=class{apply($,X){let Q=X;if(Q.minLength===void 0)return;if($.string!==!1){let J=$.string||B.string();if(J instanceof B.ZodString)$.string=J.refine((Y)=>{return Array.from(Y).length>=Q.minLength},{message:`String must be at least ${Q.minLength} characters long`})}}},i2$=class{apply($,X){let Q=X;if(Q.maxLength===void 0)return;if($.string!==!1){let J=$.string||B.string();if(J instanceof B.ZodString)$.string=J.refine((Y)=>{return Array.from(Y).length<=Q.maxLength},{message:`String must be at most ${Q.maxLength} characters long`})}}},l2$=class{apply($,X){let Q=X;if(!Q.pattern)return;if($.string!==!1){let J=$.string||B.string();if(J instanceof B.ZodString){let Y=new RegExp(Q.pattern);$.string=J.regex(Y)}}}},p2$=class{apply($,X){let Q=X;if(Q.minimum===void 0)return;if($.number!==!1){let J=$.number||B.number();if(J instanceof B.ZodNumber)$.number=J.min(Q.minimum)}}},n2$=class{apply($,X){let Q=X;if(Q.maximum===void 0)return;if($.number!==!1){let J=$.number||B.number();if(J instanceof B.ZodNumber)$.number=J.max(Q.maximum)}}},d2$=class{apply($,X){let Q=X;if(Q.exclusiveMinimum===void 0)return;if($.number!==!1){let J=$.number||B.number();if(J instanceof B.ZodNumber)if(typeof Q.exclusiveMinimum==="number")$.number=J.gt(Q.exclusiveMinimum);else $.number=!1}}},a2$=class{apply($,X){let Q=X;if(Q.exclusiveMaximum===void 0)return;if($.number!==!1){let J=$.number||B.number();if(J instanceof B.ZodNumber)if(typeof Q.exclusiveMaximum==="number")$.number=J.lt(Q.exclusiveMaximum);else $.number=!1}}},o2$=class{apply($,X){let Q=X;if(Q.multipleOf===void 0)return;if($.number!==!1){let J=$.number||B.number();if(J instanceof B.ZodNumber)$.number=J.refine((Y)=>{if(Q.multipleOf===0)return!1;let G=Y/Q.multipleOf,W=Math.round(G),K=Math.min(Math.abs(Y)*Number.EPSILON*10,Math.abs(Q.multipleOf)*Number.EPSILON*10);return Math.abs(G-W)<=K/Math.abs(Q.multipleOf)},{message:`Must be a multiple of ${Q.multipleOf}`})}}},r2$=class{apply($,X){let Q=X;if(X.type===void 0&&(Q.minItems!==void 0||Q.maxItems!==void 0||Q.items!==void 0||Q.prefixItems!==void 0)){if($.array===void 0)$.array=B.array(B.any())}}},s2$=class{apply($,X){let Q=X;if(Q.minItems===void 0)return;if($.array!==!1)$.array=($.array||B.array(B.any())).min(Q.minItems)}},t2$=class{apply($,X){let Q=X;if(Q.maxItems===void 0)return;if($.array!==!1)$.array=($.array||B.array(B.any())).max(Q.maxItems)}},e2$=class{apply($,X){let Q=X;if($.array===!1)return;if(Array.isArray(Q.items))$.array=$.array||B.array(B.any());else if(Q.items&&typeof Q.items!=="boolean"&&!Q.prefixItems){let J=k6(Q.items),Y=B.array(J);if($.array&&$.array instanceof B.ZodArray){let G=$.array._def;if(G.checks)G.checks.forEach((W)=>{if(W._zod&&W._zod.def){let K=W._zod.def;if(K.check==="min_length"&&K.minimum!==void 0)Y=Y.min(K.minimum);else if(K.check==="max_length"&&K.maximum!==void 0)Y=Y.max(K.maximum)}})}$.array=Y}else if(typeof Q.items==="boolean"&&Q.items===!1)if(!Q.prefixItems)$.array=B.array(B.any()).max(0);else $.array=$.array||B.array(B.any());else if(typeof Q.items==="boolean"&&Q.items===!0)$.array=$.array||B.array(B.any());else if(Q.prefixItems)$.array=$.array||B.array(B.any())}},$D$=class{apply($,X){if(X.type!=="array")return;let Q=X;if(!Array.isArray(Q.items))return;if($.array===!1)return;let J=Q.items.map((G)=>k6(G)),Y;if(J.length===0)Y=B.tuple([]);else Y=B.tuple(J);if(Q.minItems!==void 0&&Q.minItems>J.length)Y=!1;if(Q.maxItems!==void 0&&Q.maxItems<J.length)Y=!1;$.tuple=Y,$.array=!1}},XD$=class{apply($,X){let Q=X;if($.object===!1)return;if(Q.properties||Q.required||Q.additionalProperties!==void 0)$.object=$.object||B.object({}).passthrough()}},QD$=class{apply($,X){let Q=X;if(X.type===void 0&&(Q.maxProperties!==void 0||Q.minProperties!==void 0)){if($.object===void 0)$.object=B.object({}).passthrough()}}},YD$=class{apply($,X){let Q=X;if(Q.maxProperties===void 0)return;if($.object!==!1){let J=$.object||B.object({}).passthrough();$.object=J.refine((Y)=>Object.keys(Y).length<=Q.maxProperties,{message:`Object must have at most ${Q.maxProperties} properties`})}}},JD$=class{apply($,X){let Q=X;if(Q.minProperties===void 0)return;if($.object!==!1){let J=$.object||B.object({}).passthrough();$.object=J.refine((Y)=>Object.keys(Y).length>=Q.minProperties,{message:`Object must have at least ${Q.minProperties} properties`})}}};function xW($,X){if($===X)return!0;if($==null||X==null)return $===X;if(typeof $!==typeof X)return!1;if(Array.isArray($)&&Array.isArray(X)){if($.length!==X.length)return!1;return $.every((Q,J)=>xW(Q,X[J]))}if(typeof $==="object"&&typeof X==="object"){let Q=Object.keys($),J=Object.keys(X);if(Q.length!==J.length)return!1;return Q.every((Y)=>J.includes(Y)&&xW($[Y],X[Y]))}return!1}function GD$(){return($)=>{if(!Array.isArray($))return!0;let X=[];return $.every((Q)=>{if(X.some((Y)=>xW(Q,Y)))return!1;return X.push(Q),!0})}}function zz($,X){return $.safeParse(X).success}var WD$=class{apply($,X){if(!X.not)return $;let Q=k6(X.not);return $.refine((J)=>!zz(Q,J),{message:"Value must not match the 'not' schema"})}},KD$=class{apply($,X){if(X.uniqueItems!==!0)return $;return $.refine(GD$(),{message:"Array items must be unique"})}},VD$=class{apply($,X){if(!X.allOf||X.allOf.length===0)return $;return X.allOf.map((J)=>k6(J)).reduce((J,Y)=>B.intersection(J,Y),$)}},HD$=class{apply($,X){if(!X.anyOf||X.anyOf.length===0)return $;let Q=X.anyOf.length===1?k6(X.anyOf[0]):B.union([k6(X.anyOf[0]),k6(X.anyOf[1]),...X.anyOf.slice(2).map((J)=>k6(J))]);return B.intersection($,Q)}},UD$=class{apply($,X){if(!X.oneOf||X.oneOf.length===0)return $;let Q=X.oneOf.map((J)=>k6(J));return $.refine((J)=>{let Y=0;for(let G of Q)if(G.safeParse(J).success){if(Y++,Y>1)return!1}return Y===1},{message:"Value must match exactly one of the oneOf schemas"})}},BD$=class{apply($,X){let Q=X;if(Q.prefixItems&&Array.isArray(Q.prefixItems)){let Y=Q.prefixItems.map((G)=>k6(G));return $.refine((G)=>{if(!Array.isArray(G))return!0;for(let W=0;W<Math.min(G.length,Y.length);W++)if(!zz(Y[W],G[W]))return!1;if(G.length>Y.length){if(typeof Q.items==="boolean"&&Q.items===!1)return!1;else if(Q.items&&typeof Q.items==="object"&&!Array.isArray(Q.items)){let W=k6(Q.items);for(let K=Y.length;K<G.length;K++)if(!zz(W,G[K]))return!1}}return!0},{message:"Array does not match prefixItems schema"})}return $}},qD$=class{apply($,X){let Q=X;if(!Q.properties&&!Q.required&&Q.additionalProperties!==!1)return $;if($ instanceof B.ZodObject||$ instanceof B.ZodRecord){let J={};if(Q.properties){for(let[Y,G]of Object.entries(Q.properties))if(G!==void 0)J[Y]=k6(G)}if(Q.required&&Array.isArray(Q.required)){let Y=new Set(Q.required);for(let G of Object.keys(J))if(!Y.has(G))J[G]=J[G].optional()}else for(let Y of Object.keys(J))J[Y]=J[Y].optional();if(Q.additionalProperties===!1)return B.object(J);else return B.object(J).passthrough()}return $.refine((J)=>{if(typeof J!=="object"||J===null||Array.isArray(J))return!0;if(Q.properties){for(let[Y,G]of Object.entries(Q.properties))if(G!==void 0){if(Object.getOwnPropertyDescriptor(J,Y)!==void 0){if(!k6(G).safeParse(J[Y]).success)return!1}}}if(Q.required&&Array.isArray(Q.required)){for(let Y of Q.required)if(Object.getOwnPropertyDescriptor(J,Y)===void 0)return!1}if(Q.additionalProperties===!1&&Q.properties){let Y=new Set(Object.keys(Q.properties));for(let G in J)if(!Y.has(G))return!1}return!0},{message:"Object constraints validation failed"})}},zD$=class{apply($,X){if(!X.enum||X.enum.length===0)return $;let Q=X.enum.filter((J)=>Array.isArray(J)||typeof J==="object"&&J!==null);if(Q.length===0)return $;return $.refine((J)=>{if(typeof J!=="object"||J===null)return!0;return Q.some((Y)=>xW(J,Y))},{message:"Value must match one of the enum values"})}},ND$=class{apply($,X){if(X.const===void 0)return $;let Q=X.const;if(typeof Q!=="object"||Q===null)return $;return $.refine((J)=>xW(J,Q),{message:"Value must equal the const value"})}},DD$=class{apply($,X){if(X.description)$=$.describe(X.description);return $}},LD$=class{apply($,X){var Q;let J=X;if(!((Q=J.required)==null?void 0:Q.includes("__proto__"))||X.type!==void 0)return $;return B.any().refine((Y)=>this.validateRequired(Y,J.required),{message:"Missing required properties"})}validateRequired($,X){if(typeof $!=="object"||$===null||Array.isArray($))return!0;return X.every((Q)=>Object.prototype.hasOwnProperty.call($,Q))}},wD$=class{apply($,X){var Q;let J=X;if(J.contains===void 0)return $;let Y=k6(J.contains),G=(Q=J.minContains)!=null?Q:1,W=J.maxContains;return $.refine((K)=>{if(!Array.isArray(K))return!0;let V=0;for(let H of K)if(zz(Y,H))V++;if(V<G)return!1;if(W!==void 0&&V>W)return!1;return!0},{message:"Array must contain required items matching the schema"})}},FD$=class{apply($,X){let{default:Q}=X;if(Q===void 0)return $;if(!$.safeParse(Q).success)return $;return $.default(Q)}},ZD$=[new g2$,new h2$,new f2$,new u2$,new m2$,new r2$,new QD$,new c2$,new i2$,new l2$,new p2$,new n2$,new d2$,new a2$,new o2$,new $D$,new s2$,new t2$,new e2$,new YD$,new JD$,new XD$],OD$=[new LD$,new zD$,new ND$,new VD$,new HD$,new UD$,new BD$,new qD$,new wD$,new WD$,new KD$,new FD$,new DD$];function k6($){if(typeof $==="boolean")return $?B.any():B.never();let X={};for(let Y of ZD$)Y.apply(X,$);let Q=[];if(X.string!==!1)Q.push(X.string||B.string());if(X.number!==!1)Q.push(X.number||B.number());if(X.boolean!==!1)Q.push(X.boolean||B.boolean());if(X.null!==!1)Q.push(X.null||B.null());if(X.array!==!1)Q.push(X.array||B.array(B.any()));if(X.tuple!==!1&&X.tuple!==void 0)Q.push(X.tuple);if(X.object!==!1)if(X.object)Q.push(X.object);else{let Y=B.custom((G)=>{return typeof G==="object"&&G!==null&&!Array.isArray(G)},"Must be an object, not an array");Q.push(Y)}if(X.file!==!1&&X.file!==void 0)Q.push(X.file);let J;if(Q.length===0)J=B.never();else if(Q.length===1)J=Q[0];else if(!Object.keys($).some((G)=>G!=="$schema"&&G!=="title"&&G!=="description"))J=B.any();else J=B.union(Q);for(let Y of OD$)J=Y.apply(J,$);return J}var I5=require("react/jsx-runtime"),MD$=({data:$,setUiAjaxConfiguration:X})=>{let{name:Q,titles:J,instructions:Y,tools:G,token:W,autoStart:K,muted:V,language:H,outputModalities:U,sxMap:q,iconUrl:z,iconPosition:L,useSocketioSupport:D,useCentrifugeSupport:N,useMittSupport:w,centrifugeChannel:Z}=$,{apiServer:O,enableRenderingLog:F}=w9(),[M,A]=C6.useState(null),[v,T]=C6.useState(null),[R,h]=C6.useState(null),[J$,B$]=C6.useState(!1),[_$,s]=C6.useState([]),[,E$]=C6.useState(null),S$=C6.useRef(null),g=C6.useMemo(()=>{return G.map((c)=>{let q$=A2(X??(()=>{}),c.kwargs,c.depsNames,c.pathname,{apiServer:O,renderingLogEnabled:F});return Q9({name:c.name,description:c.description,parameters:k6(c.params),async execute(N4){console.log(`Calling tool: ${c.name} with: ${JSON.stringify(N4)}`);let L$=await q$(N4);if(!Array.isArray(L$))return[];return L$.filter((M$)=>M$.name===`pietoolOutput_${Q}`).map((M$)=>M$.data.output)}})})},[G,X]),r=()=>{if(console.log("Disconnecting session..."),v)v.close();T(null),A(null),B$(!1)},K$=async(c)=>{if(!v){console.error("Session not initialized");return}if(J$){console.log("Already connected, skipping...");return}try{v.on("history_updated",(q$)=>{s(q$)}),console.log("Connecting to session..."),E$(null),await v.connect({apiKey:c}),B$(!0),console.log("Connected successfully")}catch(q$){console.error("Failed to connect to session:",q$),E$(q$ instanceof Error?q$.message:"Failed to connect"),B$(!1)}};return C6.useEffect(()=>{if(!S$.current)return;if(!R)navigator.mediaDevices.getUserMedia({audio:!0}).then(async(c)=>{h(new AQ({mediaStream:c,audioElement:S$.current}))})},[S$]),C6.useEffect(()=>{if(!S$.current)return;if(!R)return;if(M===null||v===null){let c=new sq({name:Q,instructions:Y,tools:g}),q$=new TQ(c,{model:"gpt-realtime",transport:R,config:{outputModalities:U,audio:{input:{transcription:{language:H??void 0,model:"gpt-4o-mini-transcribe"}}},inputAudioTranscription:{language:H??void 0,model:"gpt-4o-mini-transcribe"}}});A(c),T(q$)}},[M,v,Q,Y,g,S$,R]),C6.useEffect(()=>{if(M!==null&&v!==null&&K&&W&&!J$)console.log("Auto-connecting..."),K$(W).catch((c)=>{console.error("Auto-connection failed:",c)})},[M,v]),C6.useEffect(()=>{return()=>{console.log("Disconnecting..."),r()}},[]),I5.jsxs(z4,{card:"VoiceAgentCard",data:$,methods:{initializeAI:async(c)=>{if(M!==null&&v!==null&&c.token&&!J$)console.log("Connecting via initialize event..."),await K$(c.token).catch((q$)=>{console.error("Auto-connection failed:",q$)})},stop:()=>{r()}},useCentrifugeSupport:N,useSocketioSupport:D,useMittSupport:w,centrifugeChannel:Z,children:[I5.jsxs("button",{id:Q,value:Q,onClick:async()=>{if(J$)r();else if(W)await K$(W)},style:J$?q.enabled:q.disabled,type:"button",children:[z&&L==="start"&&I5.jsx("img",{src:z,alt:""}),X0(J$?J.enabled:J.disabled),z&&L==="end"&&I5.jsx("img",{src:z,alt:""})]}),I5.jsx("input",{type:"hidden",name:Q,value:JSON.stringify(_$)}),I5.jsx("audio",{ref:S$,autoPlay:!0,muted:V,style:{display:"none"}})]})},Nz=MD$;var x5=require("react");var Kx=({data:$})=>{return X0($)};var Kr=require("react");var Vr=require("react/jsx-runtime"),Vx=({data:$,setUiAjaxConfiguration:X})=>{let Q=Kr.useContext(j6)??M4;return Vr.jsx(Q,{uiConfig:$,setUiAjaxConfiguration:X})};var Y1=require("react/jsx-runtime"),AD$=({name:$,headers:X,rows:Q,rowUrls:J,selected:Y,columnHeights:G,sx:W,sxMap:K,setUiAjaxConfiguration:V})=>{let H=x5.useContext(_4),U=(N,w)=>Array(N.length*w).fill(0).map((Z,O)=>N[O%N.length]),q=X.map((N)=>N.length),z=q.reduce((N,w)=>N*w,1),L=q.map((N,w)=>Math.floor(z/q.slice(0,w+1).reduce((Z,O)=>Z*O,1))),D=X.map((N,w)=>{return U(N,q.slice(0,w).reduce((Z,O)=>Z*O,1))});return Y1.jsxs("table",{id:$,className:"w-full table-auto border-collapse overflow-hidden text-left",style:{...K?.table,...W},children:[Y1.jsx("thead",{className:"bg-gray-100",children:D.map((N,w)=>Y1.jsx("tr",{className:"border-none",style:K?.row,children:N.map((Z,O)=>Y1.jsx("th",{colSpan:L[w],className:"border border-gray-200 px-4 py-2 text-gray-500",style:{width:G?G[O]:"auto",...K?.cell},children:typeof Z==="string"?Y1.jsx(Kx,{data:Z,setUiAjaxConfiguration:V}):Y1.jsx(Vx,{data:Z,setUiAjaxConfiguration:V})},O))},w))}),Y1.jsx("tbody",{children:Q.map((N,w)=>Y1.jsx("tr",{className:`border border-gray-200 bg-white ${J&&J[w]?"cursor-pointer":""} ${Y&&Y[w]?"bg-gray-200":""}`,style:K?.row,children:N.map((Z,O)=>Y1.jsx("td",{onClick:()=>{if(typeof Z==="string"&&J&&J[w])if(J[w].startsWith("http"))window.location.href=J[w];else H?.(J[w])},className:"border border-gray-200 px-4 py-2 text-gray-900",style:{width:G?G[O]:"auto",...K?.cell},children:typeof Z==="string"?Y1.jsx(Kx,{data:Z,setUiAjaxConfiguration:V}):Y1.jsx(Vx,{data:Z,setUiAjaxConfiguration:V})},O))},w))})]})},jD$=({data:$,setUiAjaxConfiguration:X})=>{let{name:Q,headers:J,rows:Y,rowUrls:G,sx:W,sxMap:K,useSocketioSupport:V,useCentrifugeSupport:H,useMittSupport:U,centrifugeChannel:q}=$,[z,L]=x5.useState([]),[D,N]=x5.useState([]);return x5.useEffect(()=>{L(Y)},[Y]),x5.useEffect(()=>{N(G)},[G]),Y1.jsx(z4,{card:"TableCard",data:$,methods:{addrow:(M)=>{L((A)=>[...A,M.row]),N((A)=>[...A,M.url??null])},insertrow:(M)=>{L((A)=>[...A.slice(0,M.idx),M.row,...A.slice(M.idx)]),N((A)=>[...A.slice(0,M.idx),M.url??null,...A.slice(M.idx)])},delrow:(M)=>{L((A)=>[...A.slice(0,M.idx),...A.slice(M.idx+1)]),N((A)=>[...A.slice(0,M.idx),...A.slice(M.idx+1)])},clear:()=>{L(()=>[]),N(()=>[])}},useSocketioSupport:V,useCentrifugeSupport:H,useMittSupport:U,centrifugeChannel:q,children:Y1.jsx(AD$,{name:Q,rows:z,rowUrls:D,headers:J,setUiAjaxConfiguration:X,sx:W,sxMap:K})})},Hx=jD$;var Ux=require("react");var Dz=require("react/jsx-runtime"),PD$=({data:$,content:X,setUiAjaxConfiguration:Q})=>{let{name:J,url:Y,sx:G}=$,W=Ux.useContext(_4),K=Ux.useContext(j6)??M4;return Dz.jsx(z4,{card:J,data:$,children:Dz.jsx("div",{style:G,id:J,onClick:(H)=>{if(Y)if(H.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(Y))window.location.href=Y;else W?.(Y)},children:Dz.jsx(K,{setUiAjaxConfiguration:Q,uiConfig:X})})})},Bx=PD$;var qx=!1;function R1(){if(qx)return;M6({name:"SequenceCard",component:Xk,metadata:{author:"PieData",description:"Simple div with styles joining few components"}}),M6({name:"BoxCard",component:Bx,metadata:{author:"PieData",description:"Simple div with styles joining few components"}}),M6({name:"UnionCard",component:Yk,metadata:{author:"PieData",description:"Renders one of many components"}}),M6({name:"AjaxGroupCard",component:Jk,metadata:{author:"PieData",description:"Group card with AJAX support"}}),M6({name:"AjaxButtonCard",component:aC,metadata:{author:"PieData",description:"Button with AJAX support"}}),M6({name:"RedirectButtonCard",component:iD,metadata:{author:"PieData",description:"Button with Redirect on click"}}),M6({name:"ChatCard",component:Uy,metadata:{author:"PieData"}}),M6({name:"HiddenCard",component:SD,metadata:{author:"PieData"}}),M6({name:"AutoRedirectCard",component:kD,metadata:{author:"PieData"}}),M6({name:"HTMLEmbedCard",component:CD,metadata:{author:"PieData"}}),M6({name:"IOEventsCard",component:cD,metadata:{author:"PieData"}}),M6({name:"OpenAIVoiceAgentCard",component:Nz,metadata:{author:"PieData"}}),M6({name:"TableCard",component:Hx,metadata:{author:"PieData"}}),qx=!0}function j4(){return qx}var Hr=require("react/jsx-runtime");function _8($,X,Q){if(!X)return Q;let J=$.replace(/^\//,""),Y=X[J];if(!Y)return Q;return Hr.jsx(kW,{uiConfig:Y})}var y6=require("react/jsx-runtime"),vD$=({location:$,fallback:X,piecache:Q,onError:J,initializePie:Y})=>{let G=A6(),W=d1(),K=t4();R5.useEffect(()=>{if(j4())return;R1(),Y()},[]);let V=R5.useMemo(()=>Ur.createAxiosDateTransformer({baseURL:G||""}),[G]),H=R5.useMemo(()=>a1(),[]),U=R5.useMemo(()=>G?r1(G):null,[G]),q=R5.useMemo(()=>G?s1(G,W):null,[G,W]),{data:z,isLoading:L,error:D}=bQ.useQuery({queryKey:["uiConfig",$.pathname+$.search,j4(),G],enabled:j4()&&!!G,queryFn:async()=>{let w=new URLSearchParams($.search);w.set("__pieroot","web");let Z="/api/content"+$.pathname+"?"+w.toString();if(K)console.log("[PieRoot] Fetching UI configuration from:",Z);let O=await V.get(Z,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(K)console.log("[PieRoot] Received UI configuration:",O.data);return O.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(w)=>Math.min(1000*2**w,30000)}),N=_8($.pathname,Q,X);if(!G)return N??null;if(K)console.log("[PieRoot] Rendering with location:",$),console.log("[PieRoot] API_SERVER:",G),console.log("[PieRoot] CENTRIFUGE_SERVER:",W),console.log("[PieRoot] Fallback provided:",!!X),console.log("[PieRoot] Piecache provided:",!!Q);if(D){if(K)console.error("[PieRoot] Error fetching UI configuration:",D),console.error("[PieRoot] Error details:",{message:D.message,status:D.response?.status,data:D.response?.data});return J?.(),N}if(L||!z){if(K)console.log("[PieRoot] Loading state:",{isLoading:L,hasUiConfiguration:!!z});return N}if(K)console.log("[PieRoot] UI configuration loaded successfully:",z),console.log("[PieRoot] Rendering UI with configuration");return y6.jsx(P6.Provider,{value:H,children:y6.jsx(v6.Provider,{value:U,children:y6.jsx(x6.Provider,{value:q,children:y6.jsx(s4.Provider,{value:X??y6.jsx(y6.Fragment,{}),children:y6.jsx(t1,{children:y6.jsx(e1,{children:y6.jsx("form",{id:"piedata_global_form",action:G+"api/process"+$.pathname,method:"post",encType:"multipart/form-data",children:y6.jsx(M4,{uiConfig:z})})})})})})})})},ID$=($)=>{let X=R5.useMemo(()=>new bQ.QueryClient,[]);return y6.jsx(_4.Provider,{value:$.onNavigate,children:y6.jsx(_1.Provider,{value:$.config,children:y6.jsx(bQ.QueryClientProvider,{client:X,children:y6.jsx(vD$,{...$})})})})},Br=ID$;var _5=require("react"),SQ=require("@tanstack/react-query");var zr=V$(AX());var Lz=require("react");var qr=()=>{let[$,X]=Lz.useState(null),Q=jx();return Lz.useEffect(()=>{if(typeof window==="undefined")return;let J=window.Telegram.WebApp;if(J.ready(),Q==="telegram_expanded"&&(J.platform==="ios"||J.platform==="android"))J.expand();X(J)},[]),$};var f6=require("react/jsx-runtime"),xD$=({location:$,fallback:X,piecache:Q,onError:J,initializePie:Y})=>{let G=A6(),W=d1(),K=t4();_5.useEffect(()=>{if(j4())return;R1(),Y()},[]);let V=_5.useMemo(()=>zr.createAxiosDateTransformer({baseURL:G}),[G]),H=_5.useMemo(()=>a1(),[]),U=_5.useMemo(()=>G?r1(G):null,[G]),q=_5.useMemo(()=>G?s1(G,W):null,[G,W]),z=qr(),{data:L,isLoading:D,error:N}=SQ.useQuery({queryKey:["uiConfig",$.pathname+$.search,z?.initData,j4()],enabled:j4()&&!!z?.initData,queryFn:async()=>{let Z=new URLSearchParams($.search);if(Z.set("__pieroot","telegram"),z?.initData)Z.set("initData",z.initData);let O="/api/content"+$.pathname+"?"+Z.toString();if(K)console.log("[PieRoot] Fetching UI configuration from:",O);let F=await V.get(O,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(K)console.log("[PieRoot] Received UI configuration:",F.data);return F.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Z)=>Math.min(1000*2**Z,30000)}),w=_8($.pathname,Q,X);if(!G)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(N&&K)return console.error("[PieRoot] Error fetching UI configuration:",N),console.error("[PieRoot] Error details:",{message:N.message,status:N.response?.status,data:N.response?.data}),J?.(),w;if(D||!L){if(K)console.log("[PieRoot] Loading state:",{isLoading:D,hasUiConfiguration:!!L});return w}if(K)console.log("[PieRoot] UI configuration loaded successfully:",L),console.log("[PieRoot] Rendering UI with configuration");return f6.jsx(P6.Provider,{value:H,children:f6.jsx(v6.Provider,{value:U,children:f6.jsx(x6.Provider,{value:q,children:f6.jsx(s4.Provider,{value:X??f6.jsx(f6.Fragment,{}),children:f6.jsx(t1,{children:f6.jsx(e1,{children:f6.jsx("form",{id:"piedata_global_form",action:G+"api/process"+$.pathname,method:"post",encType:"multipart/form-data",children:f6.jsx(M4,{uiConfig:L})})})})})})})})},RD$=($)=>{let X=_5.useMemo(()=>new SQ.QueryClient,[]);return f6.jsx(_4.Provider,{value:$.onNavigate,children:f6.jsx(_1.Provider,{value:$.config,children:f6.jsx(SQ.QueryClientProvider,{client:X,children:f6.jsx(xD$,{...$})})})})},Nr=RD$;var r7=require("react"),wz=require("@tanstack/react-query");var J1=require("react/jsx-runtime"),_D$=({location:$,fallback:X,initializePie:Q,children:J})=>{let Y=A6(),G=d1(),W=t4();r7.useEffect(()=>{if(j4())return;R1(),Q()},[]);let K=r7.useMemo(()=>a1(),[]),V=r7.useMemo(()=>Y?r1(Y):null,[Y]),H=r7.useMemo(()=>Y?s1(Y,G):null,[Y,G]);if(W)console.log("[PieRoot] Rendering with location:",$),console.log("[PieRoot] API_SERVER:",Y),console.log("[PieRoot] CENTRIFUGE_SERVER:",G),console.log("[PieRoot] Fallback provided:",!!X);return J1.jsx(P6.Provider,{value:K,children:J1.jsx(v6.Provider,{value:V,children:J1.jsx(x6.Provider,{value:H,children:J1.jsx(s4.Provider,{value:X??J1.jsx(J1.Fragment,{}),children:J1.jsx(t1,{children:J1.jsx(e1,{children:J1.jsx("form",{id:"piedata_global_form",action:Y+"api/process"+$.pathname,method:"post",encType:"multipart/form-data",children:J})})})})})})})},ED$=($)=>{let X=r7.useMemo(()=>new wz.QueryClient,[]);return J1.jsx(_4.Provider,{value:$.onNavigate,children:J1.jsx(_1.Provider,{value:$.config,children:J1.jsx(wz.QueryClientProvider,{client:X,children:J1.jsx(_D$,{...$})})})})},Dr=ED$;var E5=require("react"),kQ=require("@tanstack/react-query");var wr=V$(AX());var Fz=require("react"),Lr=()=>{let[$,X]=Fz.useState(null);return Fz.useEffect(()=>{if(typeof window==="undefined")return;let Q=window.WebApp;if(!Q)return;Q.ready(),X(Q)},[]),$};var g6=require("react/jsx-runtime"),TD$=({location:$,fallback:X,piecache:Q,onError:J,initializePie:Y})=>{let G=A6(),W=d1(),K=t4();E5.useEffect(()=>{if(j4())return;R1(),Y()},[]);let V=E5.useMemo(()=>wr.createAxiosDateTransformer({baseURL:G}),[G]),H=E5.useMemo(()=>a1(),[]),U=E5.useMemo(()=>G?r1(G):null,[G]),q=E5.useMemo(()=>G?s1(G,W):null,[G,W]),z=Lr(),{data:L,isLoading:D,error:N}=kQ.useQuery({queryKey:["uiConfig",$.pathname+$.search,z?.initData,j4()],queryFn:async()=>{let Z=new URLSearchParams($.search);if(Z.set("__pieroot","max"),z?.initData)Z.set("initData",z.initData);let O="/api/content"+$.pathname+"?"+Z.toString();if(K)console.log("[PieRoot] Fetching UI configuration from:",O);let F=await V.get(O,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(K)console.log("[PieRoot] Received UI configuration:",F.data);return F.data},enabled:j4()&&!!z?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Z)=>Math.min(1000*2**Z,30000)}),w=_8($.pathname,Q,X);if(!G)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(N&&K)return console.error("[PieRoot] Error fetching UI configuration:",N),console.error("[PieRoot] Error details:",{message:N.message,status:N.response?.status,data:N.response?.data}),J?.(),w;if(D||!L){if(K)console.log("[PieRoot] Loading state:",{isLoading:D,hasUiConfiguration:!!L});return w}if(K)console.log("[PieRoot] UI configuration loaded successfully:",L),console.log("[PieRoot] Rendering UI with configuration");return g6.jsx(P6.Provider,{value:H,children:g6.jsx(v6.Provider,{value:U,children:g6.jsx(x6.Provider,{value:q,children:g6.jsx(s4.Provider,{value:X??g6.jsx(g6.Fragment,{}),children:g6.jsx(t1,{children:g6.jsx(e1,{children:g6.jsx("form",{id:"piedata_global_form",action:G+"api/process"+$.pathname,method:"post",encType:"multipart/form-data",children:g6.jsx(M4,{uiConfig:L})})})})})})})})},bD$=($)=>{let X=E5.useMemo(()=>new kQ.QueryClient,[]);return g6.jsx(_4.Provider,{value:$.onNavigate,children:g6.jsx(_1.Provider,{value:$.config,children:g6.jsx(kQ.QueryClientProvider,{client:X,children:g6.jsx(TD$,{...$})})})})},Fr=bD$;var T5=require("react"),CQ=require("@tanstack/react-query");var Zr=V$(AX());var h6=require("react/jsx-runtime"),SD$=({location:$,fallback:X,piecache:Q,onError:J,initializePie:Y})=>{let G=A6(),W=d1(),K=t4();T5.useEffect(()=>{if(j4())return;R1(),Y()},[]);let V=T5.useMemo(()=>Zr.createAxiosDateTransformer({baseURL:G||""}),[G]),H=T5.useMemo(()=>a1(),[]),U=T5.useMemo(()=>G?r1(G):null,[G]),q=T5.useMemo(()=>G?s1(G,W):null,[G,W]),{data:z,isLoading:L,error:D}=CQ.useQuery({queryKey:["uiConfig",$.pathname+$.search,j4(),G],enabled:j4()&&!!G,queryFn:async()=>{let w=new URLSearchParams($.search);w.set("__pieroot","electron");let Z="/api/content"+$.pathname+"?"+w.toString();if(K)console.log("[PieElectronRoot] Fetching UI configuration from:",Z);let O=await V.get(Z,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(K)console.log("[PieElectronRoot] Received UI configuration:",O.data);return O.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(w)=>Math.min(1000*2**w,30000)}),N=_8($.pathname,Q,X);if(!G)return N??null;if(K)console.log("[PieElectronRoot] Rendering with location:",$),console.log("[PieElectronRoot] API_SERVER:",G),console.log("[PieElectronRoot] CENTRIFUGE_SERVER:",W),console.log("[PieElectronRoot] Fallback provided:",!!X),console.log("[PieElectronRoot] Piecache provided:",!!Q);if(D){if(K)console.error("[PieElectronRoot] Error fetching UI configuration:",D),console.error("[PieElectronRoot] Error details:",{message:D.message,status:D.response?.status,data:D.response?.data});return J?.(),N}if(L||!z){if(K)console.log("[PieElectronRoot] Loading state:",{isLoading:L,hasUiConfiguration:!!z});return N}if(K)console.log("[PieElectronRoot] UI configuration loaded successfully:",z),console.log("[PieElectronRoot] Rendering UI with configuration");return h6.jsx(P6.Provider,{value:H,children:h6.jsx(v6.Provider,{value:U,children:h6.jsx(x6.Provider,{value:q,children:h6.jsx(s4.Provider,{value:X??h6.jsx(h6.Fragment,{}),children:h6.jsx(t1,{children:h6.jsx(e1,{children:h6.jsx("form",{id:"piedata_global_form",action:G+"api/process"+$.pathname,method:"post",encType:"multipart/form-data",children:h6.jsx(M4,{uiConfig:z})})})})})})})})},kD$=($)=>{let X=T5.useMemo(()=>new CQ.QueryClient,[]);return h6.jsx(_4.Provider,{value:$.onNavigate,children:h6.jsx(_1.Provider,{value:$.config,children:h6.jsx(CQ.QueryClientProvider,{client:X,children:h6.jsx(SD$,{...$})})})})},Or=kD$;var b5=require("react"),yQ=require("@tanstack/react-query");var Mr=V$(AX());var G1=require("react/jsx-runtime"),CD$=({location:$,fallback:X,piecache:Q,onError:J,initializePie:Y})=>{let G=A6(),W=d1(),K=t4();b5.useEffect(()=>{if(j4())return;R1(),Y()},[]);let V=b5.useMemo(()=>Mr.createAxiosDateTransformer({baseURL:G||""}),[G]),H=b5.useMemo(()=>a1(),[]),U=b5.useMemo(()=>G?r1(G):null,[G]),q=b5.useMemo(()=>G?s1(G,W):null,[G,W]),{data:z,isLoading:L,error:D}=yQ.useQuery({queryKey:["uiConfig",$.pathname+$.search,j4(),G],enabled:j4()&&!!G,queryFn:async()=>{let w=new URLSearchParams($.search);w.set("__pieroot","expo");let Z="/api/content"+$.pathname+"?"+w.toString();if(K)console.log("[PieExpoRoot] Fetching UI configuration from:",Z);let O=await V.get(Z,{headers:{"Content-type":"application/json"}});if(K)console.log("[PieExpoRoot] Received UI configuration:",O.data);return O.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(w)=>Math.min(1000*2**w,30000)}),N=_8($.pathname,Q,X);if(!G)return N??null;if(K)console.log("[PieExpoRoot] Rendering with location:",$),console.log("[PieExpoRoot] API_SERVER:",G),console.log("[PieExpoRoot] CENTRIFUGE_SERVER:",W),console.log("[PieExpoRoot] Fallback provided:",!!X),console.log("[PieExpoRoot] Piecache provided:",!!Q);if(D){if(K)console.error("[PieExpoRoot] Error fetching UI configuration:",D),console.error("[PieExpoRoot] Error details:",{message:D.message,status:D.response?.status,data:D.response?.data});return J?.(),N}if(L||!z){if(K)console.log("[PieExpoRoot] Loading state:",{isLoading:L,hasUiConfiguration:!!z});return N}if(K)console.log("[PieExpoRoot] UI configuration loaded successfully:",z),console.log("[PieExpoRoot] Rendering UI with configuration");return G1.jsx(P6.Provider,{value:H,children:G1.jsx(v6.Provider,{value:U,children:G1.jsx(x6.Provider,{value:q,children:G1.jsx(s4.Provider,{value:X??G1.jsx(G1.Fragment,{}),children:G1.jsx(t1,{children:G1.jsx(e1,{children:G1.jsx(M4,{uiConfig:z})})})})})})})},yD$=($)=>{let X=b5.useMemo(()=>new yQ.QueryClient,[]);return G1.jsx(_4.Provider,{value:$.onNavigate,children:G1.jsx(_1.Provider,{value:$.config,children:G1.jsx(yQ.QueryClientProvider,{client:X,children:G1.jsx(CD$,{...$})})})})},Ar=yD$;function jr($){if(!$)return{};return{...$}}var fD$=($,X)=>{let Q=new Array($.length+X.length);for(let J=0;J<$.length;J++)Q[J]=$[J];for(let J=0;J<X.length;J++)Q[$.length+J]=X[J];return Q},gD$=($,X)=>({classGroupId:$,validator:X}),_r=($=new Map,X=null,Q)=>({nextPart:$,validators:X,classGroupId:Q});var Pr=[];var hD$=($)=>{let X=mD$($),{conflictingClassGroups:Q,conflictingClassGroupModifiers:J}=$;return{getClassGroupId:(W)=>{if(W.startsWith("[")&&W.endsWith("]"))return uD$(W);let K=W.split("-"),V=K[0]===""&&K.length>1?1:0;return Er(K,V,X)},getConflictingClassGroupIds:(W,K)=>{if(K){let V=J[W],H=Q[W];if(V){if(H)return fD$(H,V);return V}return H||Pr}return Q[W]||Pr}}},Er=($,X,Q)=>{if($.length-X===0)return Q.classGroupId;let Y=$[X],G=Q.nextPart.get(Y);if(G){let H=Er($,X+1,G);if(H)return H}let W=Q.validators;if(W===null)return;let K=X===0?$.join("-"):$.slice(X).join("-"),V=W.length;for(let H=0;H<V;H++){let U=W[H];if(U.validator(K))return U.classGroupId}return},uD$=($)=>$.slice(1,-1).indexOf(":")===-1?void 0:(()=>{let X=$.slice(1,-1),Q=X.indexOf(":"),J=X.slice(0,Q);return J?"arbitrary.."+J:void 0})(),mD$=($)=>{let{theme:X,classGroups:Q}=$;return cD$(Q,X)},cD$=($,X)=>{let Q=_r();for(let J in $){let Y=$[J];Nx(Y,Q,J,X)}return Q},Nx=($,X,Q,J)=>{let Y=$.length;for(let G=0;G<Y;G++){let W=$[G];iD$(W,X,Q,J)}},iD$=($,X,Q,J)=>{if(typeof $==="string"){lD$($,X,Q);return}if(typeof $==="function"){pD$($,X,Q,J);return}nD$($,X,Q,J)},lD$=($,X,Q)=>{let J=$===""?X:Tr(X,$);J.classGroupId=Q},pD$=($,X,Q,J)=>{if(dD$($)){Nx($(J),X,Q,J);return}if(X.validators===null)X.validators=[];X.validators.push(gD$(Q,$))},nD$=($,X,Q,J)=>{let Y=Object.entries($),G=Y.length;for(let W=0;W<G;W++){let[K,V]=Y[W];Nx(V,Tr(X,K),Q,J)}},Tr=($,X)=>{let Q=$,J=X.split("-"),Y=J.length;for(let G=0;G<Y;G++){let W=J[G],K=Q.nextPart.get(W);if(!K)K=_r(),Q.nextPart.set(W,K);Q=K}return Q},dD$=($)=>("isThemeGetter"in $)&&$.isThemeGetter===!0,aD$=($)=>{if($<1)return{get:()=>{return},set:()=>{}};let X=0,Q=Object.create(null),J=Object.create(null),Y=(G,W)=>{if(Q[G]=W,X++,X>$)X=0,J=Q,Q=Object.create(null)};return{get(G){let W=Q[G];if(W!==void 0)return W;if((W=J[G])!==void 0)return Y(G,W),W},set(G,W){if(G in Q)Q[G]=W;else Y(G,W)}}};var oD$=[],vr=($,X,Q,J,Y)=>({modifiers:$,hasImportantModifier:X,baseClassName:Q,maybePostfixModifierPosition:J,isExternal:Y}),rD$=($)=>{let{prefix:X,experimentalParseClassName:Q}=$,J=(Y)=>{let G=[],W=0,K=0,V=0,H,U=Y.length;for(let N=0;N<U;N++){let w=Y[N];if(W===0&&K===0){if(w===":"){G.push(Y.slice(V,N)),V=N+1;continue}if(w==="/"){H=N;continue}}if(w==="[")W++;else if(w==="]")W--;else if(w==="(")K++;else if(w===")")K--}let q=G.length===0?Y:Y.slice(V),z=q,L=!1;if(q.endsWith("!"))z=q.slice(0,-1),L=!0;else if(q.startsWith("!"))z=q.slice(1),L=!0;let D=H&&H>V?H-V:void 0;return vr(G,L,z,D)};if(X){let Y=X+":",G=J;J=(W)=>W.startsWith(Y)?G(W.slice(Y.length)):vr(oD$,!1,W,void 0,!0)}if(Q){let Y=J;J=(G)=>Q({className:G,parseClassName:Y})}return J},sD$=($)=>{let X=new Map;return $.orderSensitiveModifiers.forEach((Q,J)=>{X.set(Q,1e6+J)}),(Q)=>{let J=[],Y=[];for(let G=0;G<Q.length;G++){let W=Q[G],K=W[0]==="[",V=X.has(W);if(K||V){if(Y.length>0)Y.sort(),J.push(...Y),Y=[];J.push(W)}else Y.push(W)}if(Y.length>0)Y.sort(),J.push(...Y);return J}},tD$=($)=>({cache:aD$($.cacheSize),parseClassName:rD$($),sortModifiers:sD$($),...hD$($)}),eD$=/\s+/,$L$=($,X)=>{let{parseClassName:Q,getClassGroupId:J,getConflictingClassGroupIds:Y,sortModifiers:G}=X,W=[],K=$.trim().split(eD$),V="";for(let H=K.length-1;H>=0;H-=1){let U=K[H],{isExternal:q,modifiers:z,hasImportantModifier:L,baseClassName:D,maybePostfixModifierPosition:N}=Q(U);if(q){V=U+(V.length>0?" "+V:V);continue}let w=!!N,Z=J(w?D.substring(0,N):D);if(!Z){if(!w){V=U+(V.length>0?" "+V:V);continue}if(Z=J(D),!Z){V=U+(V.length>0?" "+V:V);continue}w=!1}let O=z.length===0?"":z.length===1?z[0]:G(z).join(":"),F=L?O+"!":O,M=F+Z;if(W.indexOf(M)>-1)continue;W.push(M);let A=Y(Z,w);for(let v=0;v<A.length;++v){let T=A[v];W.push(F+T)}V=U+(V.length>0?" "+V:V)}return V},XL$=(...$)=>{let X=0,Q,J,Y="";while(X<$.length)if(Q=$[X++]){if(J=br(Q))Y&&(Y+=" "),Y+=J}return Y},br=($)=>{if(typeof $==="string")return $;let X,Q="";for(let J=0;J<$.length;J++)if($[J]){if(X=br($[J]))Q&&(Q+=" "),Q+=X}return Q},QL$=($,...X)=>{let Q,J,Y,G,W=(V)=>{let H=X.reduce((U,q)=>q(U),$());return Q=tD$(H),J=Q.cache.get,Y=Q.cache.set,G=K,K(V)},K=(V)=>{let H=J(V);if(H)return H;let U=$L$(V,Q);return Y(V,U),U};return G=W,(...V)=>G(XL$(...V))},YL$=[],r4=($)=>{let X=(Q)=>Q[$]||YL$;return X.isThemeGetter=!0,X},Sr=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,kr=/^\((?:(\w[\w-]*):)?(.+)\)$/i,JL$=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,GL$=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,WL$=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,KL$=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,VL$=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,HL$=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,S5=($)=>JL$.test($),b$=($)=>!!$&&!Number.isNaN(Number($)),k5=($)=>!!$&&Number.isInteger(Number($)),zx=($)=>$.endsWith("%")&&b$($.slice(0,-1)),D9=($)=>GL$.test($),Cr=()=>!0,UL$=($)=>WL$.test($)&&!KL$.test($),Dx=()=>!1,BL$=($)=>VL$.test($),qL$=($)=>HL$.test($),zL$=($)=>!t($)&&!e($),NL$=($)=>C5($,gr,Dx),t=($)=>Sr.test($),s7=($)=>C5($,hr,UL$),Ir=($)=>C5($,AL$,b$),DL$=($)=>C5($,mr,Cr),LL$=($)=>C5($,ur,Dx),xr=($)=>C5($,yr,Dx),wL$=($)=>C5($,fr,qL$),Zz=($)=>C5($,cr,BL$),e=($)=>kr.test($),RW=($)=>t7($,hr),FL$=($)=>t7($,ur),Rr=($)=>t7($,yr),ZL$=($)=>t7($,gr),OL$=($)=>t7($,fr),Oz=($)=>t7($,cr,!0),ML$=($)=>t7($,mr,!0),C5=($,X,Q)=>{let J=Sr.exec($);if(J){if(J[1])return X(J[1]);return Q(J[2])}return!1},t7=($,X,Q=!1)=>{let J=kr.exec($);if(J){if(J[1])return X(J[1]);return Q}return!1},yr=($)=>$==="position"||$==="percentage",fr=($)=>$==="image"||$==="url",gr=($)=>$==="length"||$==="size"||$==="bg-size",hr=($)=>$==="length",AL$=($)=>$==="number",ur=($)=>$==="family-name",mr=($)=>$==="number"||$==="weight",cr=($)=>$==="shadow";var jL$=()=>{let $=r4("color"),X=r4("font"),Q=r4("text"),J=r4("font-weight"),Y=r4("tracking"),G=r4("leading"),W=r4("breakpoint"),K=r4("container"),V=r4("spacing"),H=r4("radius"),U=r4("shadow"),q=r4("inset-shadow"),z=r4("text-shadow"),L=r4("drop-shadow"),D=r4("blur"),N=r4("perspective"),w=r4("aspect"),Z=r4("ease"),O=r4("animate"),F=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...M(),e,t],v=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],R=()=>[e,t,V],h=()=>[S5,"full","auto",...R()],J$=()=>[k5,"none","subgrid",e,t],B$=()=>["auto",{span:["full",k5,e,t]},k5,e,t],_$=()=>[k5,"auto",e,t],s=()=>["auto","min","max","fr",e,t],E$=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],S$=()=>["start","end","center","stretch","center-safe","end-safe"],g=()=>["auto",...R()],r=()=>[S5,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],K$=()=>[S5,"screen","full","dvw","lvw","svw","min","max","fit",...R()],f4=()=>[S5,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],b=()=>[$,e,t],c=()=>[...M(),Rr,xr,{position:[e,t]}],q$=()=>["no-repeat",{repeat:["","x","y","space","round"]}],N4=()=>["auto","cover","contain",ZL$,NL$,{size:[e,t]}],L$=()=>[zx,RW,s7],M$=()=>["","none","full",H,e,t],m$=()=>["",b$,RW,s7],o$=()=>["solid","dashed","dotted","double"],w0=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],q4=()=>[b$,zx,Rr,xr],O4=()=>["","none",D,e,t],F0=()=>["none",b$,e,t],L9=()=>["none",b$,e,t],e7=()=>[b$,e,t],fQ=()=>[S5,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[D9],breakpoint:[D9],color:[Cr],container:[D9],"drop-shadow":[D9],ease:["in","out","in-out"],font:[zL$],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[D9],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[D9],shadow:[D9],spacing:["px",b$],text:[D9],"text-shadow":[D9],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",S5,t,e,w]}],container:["container"],columns:[{columns:[b$,t,e,K]}],"break-after":[{"break-after":F()}],"break-before":[{"break-before":F()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:v()}],"overflow-x":[{"overflow-x":v()}],"overflow-y":[{"overflow-y":v()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:h()}],"inset-x":[{"inset-x":h()}],"inset-y":[{"inset-y":h()}],start:[{"inset-s":h(),start:h()}],end:[{"inset-e":h(),end:h()}],"inset-bs":[{"inset-bs":h()}],"inset-be":[{"inset-be":h()}],top:[{top:h()}],right:[{right:h()}],bottom:[{bottom:h()}],left:[{left:h()}],visibility:["visible","invisible","collapse"],z:[{z:[k5,"auto",e,t]}],basis:[{basis:[S5,"full","auto",K,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[b$,S5,"auto","initial","none",t]}],grow:[{grow:["",b$,e,t]}],shrink:[{shrink:["",b$,e,t]}],order:[{order:[k5,"first","last","none",e,t]}],"grid-cols":[{"grid-cols":J$()}],"col-start-end":[{col:B$()}],"col-start":[{"col-start":_$()}],"col-end":[{"col-end":_$()}],"grid-rows":[{"grid-rows":J$()}],"row-start-end":[{row:B$()}],"row-start":[{"row-start":_$()}],"row-end":[{"row-end":_$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":s()}],"auto-rows":[{"auto-rows":s()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...E$(),"normal"]}],"justify-items":[{"justify-items":[...S$(),"normal"]}],"justify-self":[{"justify-self":["auto",...S$()]}],"align-content":[{content:["normal",...E$()]}],"align-items":[{items:[...S$(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...S$(),{baseline:["","last"]}]}],"place-content":[{"place-content":E$()}],"place-items":[{"place-items":[...S$(),"baseline"]}],"place-self":[{"place-self":["auto",...S$()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:g()}],mx:[{mx:g()}],my:[{my:g()}],ms:[{ms:g()}],me:[{me:g()}],mbs:[{mbs:g()}],mbe:[{mbe:g()}],mt:[{mt:g()}],mr:[{mr:g()}],mb:[{mb:g()}],ml:[{ml:g()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:r()}],"inline-size":[{inline:["auto",...K$()]}],"min-inline-size":[{"min-inline":["auto",...K$()]}],"max-inline-size":[{"max-inline":["none",...K$()]}],"block-size":[{block:["auto",...f4()]}],"min-block-size":[{"min-block":["auto",...f4()]}],"max-block-size":[{"max-block":["none",...f4()]}],w:[{w:[K,"screen",...r()]}],"min-w":[{"min-w":[K,"screen","none",...r()]}],"max-w":[{"max-w":[K,"screen","none","prose",{screen:[W]},...r()]}],h:[{h:["screen","lh",...r()]}],"min-h":[{"min-h":["screen","lh","none",...r()]}],"max-h":[{"max-h":["screen","lh",...r()]}],"font-size":[{text:["base",Q,RW,s7]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[J,ML$,DL$]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",zx,t]}],"font-family":[{font:[FL$,LL$,X]}],"font-features":[{"font-features":[t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[Y,e,t]}],"line-clamp":[{"line-clamp":[b$,"none",e,Ir]}],leading:[{leading:[G,...R()]}],"list-image":[{"list-image":["none",e,t]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",e,t]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:b()}],"text-color":[{text:b()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...o$(),"wavy"]}],"text-decoration-thickness":[{decoration:[b$,"from-font","auto",e,s7]}],"text-decoration-color":[{decoration:b()}],"underline-offset":[{"underline-offset":[b$,"auto",e,t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",e,t]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",e,t]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:c()}],"bg-repeat":[{bg:q$()}],"bg-size":[{bg:N4()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},k5,e,t],radial:["",e,t],conic:[k5,e,t]},OL$,wL$]}],"bg-color":[{bg:b()}],"gradient-from-pos":[{from:L$()}],"gradient-via-pos":[{via:L$()}],"gradient-to-pos":[{to:L$()}],"gradient-from":[{from:b()}],"gradient-via":[{via:b()}],"gradient-to":[{to:b()}],rounded:[{rounded:M$()}],"rounded-s":[{"rounded-s":M$()}],"rounded-e":[{"rounded-e":M$()}],"rounded-t":[{"rounded-t":M$()}],"rounded-r":[{"rounded-r":M$()}],"rounded-b":[{"rounded-b":M$()}],"rounded-l":[{"rounded-l":M$()}],"rounded-ss":[{"rounded-ss":M$()}],"rounded-se":[{"rounded-se":M$()}],"rounded-ee":[{"rounded-ee":M$()}],"rounded-es":[{"rounded-es":M$()}],"rounded-tl":[{"rounded-tl":M$()}],"rounded-tr":[{"rounded-tr":M$()}],"rounded-br":[{"rounded-br":M$()}],"rounded-bl":[{"rounded-bl":M$()}],"border-w":[{border:m$()}],"border-w-x":[{"border-x":m$()}],"border-w-y":[{"border-y":m$()}],"border-w-s":[{"border-s":m$()}],"border-w-e":[{"border-e":m$()}],"border-w-bs":[{"border-bs":m$()}],"border-w-be":[{"border-be":m$()}],"border-w-t":[{"border-t":m$()}],"border-w-r":[{"border-r":m$()}],"border-w-b":[{"border-b":m$()}],"border-w-l":[{"border-l":m$()}],"divide-x":[{"divide-x":m$()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":m$()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...o$(),"hidden","none"]}],"divide-style":[{divide:[...o$(),"hidden","none"]}],"border-color":[{border:b()}],"border-color-x":[{"border-x":b()}],"border-color-y":[{"border-y":b()}],"border-color-s":[{"border-s":b()}],"border-color-e":[{"border-e":b()}],"border-color-bs":[{"border-bs":b()}],"border-color-be":[{"border-be":b()}],"border-color-t":[{"border-t":b()}],"border-color-r":[{"border-r":b()}],"border-color-b":[{"border-b":b()}],"border-color-l":[{"border-l":b()}],"divide-color":[{divide:b()}],"outline-style":[{outline:[...o$(),"none","hidden"]}],"outline-offset":[{"outline-offset":[b$,e,t]}],"outline-w":[{outline:["",b$,RW,s7]}],"outline-color":[{outline:b()}],shadow:[{shadow:["","none",U,Oz,Zz]}],"shadow-color":[{shadow:b()}],"inset-shadow":[{"inset-shadow":["none",q,Oz,Zz]}],"inset-shadow-color":[{"inset-shadow":b()}],"ring-w":[{ring:m$()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:b()}],"ring-offset-w":[{"ring-offset":[b$,s7]}],"ring-offset-color":[{"ring-offset":b()}],"inset-ring-w":[{"inset-ring":m$()}],"inset-ring-color":[{"inset-ring":b()}],"text-shadow":[{"text-shadow":["none",z,Oz,Zz]}],"text-shadow-color":[{"text-shadow":b()}],opacity:[{opacity:[b$,e,t]}],"mix-blend":[{"mix-blend":[...w0(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":w0()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[b$]}],"mask-image-linear-from-pos":[{"mask-linear-from":q4()}],"mask-image-linear-to-pos":[{"mask-linear-to":q4()}],"mask-image-linear-from-color":[{"mask-linear-from":b()}],"mask-image-linear-to-color":[{"mask-linear-to":b()}],"mask-image-t-from-pos":[{"mask-t-from":q4()}],"mask-image-t-to-pos":[{"mask-t-to":q4()}],"mask-image-t-from-color":[{"mask-t-from":b()}],"mask-image-t-to-color":[{"mask-t-to":b()}],"mask-image-r-from-pos":[{"mask-r-from":q4()}],"mask-image-r-to-pos":[{"mask-r-to":q4()}],"mask-image-r-from-color":[{"mask-r-from":b()}],"mask-image-r-to-color":[{"mask-r-to":b()}],"mask-image-b-from-pos":[{"mask-b-from":q4()}],"mask-image-b-to-pos":[{"mask-b-to":q4()}],"mask-image-b-from-color":[{"mask-b-from":b()}],"mask-image-b-to-color":[{"mask-b-to":b()}],"mask-image-l-from-pos":[{"mask-l-from":q4()}],"mask-image-l-to-pos":[{"mask-l-to":q4()}],"mask-image-l-from-color":[{"mask-l-from":b()}],"mask-image-l-to-color":[{"mask-l-to":b()}],"mask-image-x-from-pos":[{"mask-x-from":q4()}],"mask-image-x-to-pos":[{"mask-x-to":q4()}],"mask-image-x-from-color":[{"mask-x-from":b()}],"mask-image-x-to-color":[{"mask-x-to":b()}],"mask-image-y-from-pos":[{"mask-y-from":q4()}],"mask-image-y-to-pos":[{"mask-y-to":q4()}],"mask-image-y-from-color":[{"mask-y-from":b()}],"mask-image-y-to-color":[{"mask-y-to":b()}],"mask-image-radial":[{"mask-radial":[e,t]}],"mask-image-radial-from-pos":[{"mask-radial-from":q4()}],"mask-image-radial-to-pos":[{"mask-radial-to":q4()}],"mask-image-radial-from-color":[{"mask-radial-from":b()}],"mask-image-radial-to-color":[{"mask-radial-to":b()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":M()}],"mask-image-conic-pos":[{"mask-conic":[b$]}],"mask-image-conic-from-pos":[{"mask-conic-from":q4()}],"mask-image-conic-to-pos":[{"mask-conic-to":q4()}],"mask-image-conic-from-color":[{"mask-conic-from":b()}],"mask-image-conic-to-color":[{"mask-conic-to":b()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:c()}],"mask-repeat":[{mask:q$()}],"mask-size":[{mask:N4()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",e,t]}],filter:[{filter:["","none",e,t]}],blur:[{blur:O4()}],brightness:[{brightness:[b$,e,t]}],contrast:[{contrast:[b$,e,t]}],"drop-shadow":[{"drop-shadow":["","none",L,Oz,Zz]}],"drop-shadow-color":[{"drop-shadow":b()}],grayscale:[{grayscale:["",b$,e,t]}],"hue-rotate":[{"hue-rotate":[b$,e,t]}],invert:[{invert:["",b$,e,t]}],saturate:[{saturate:[b$,e,t]}],sepia:[{sepia:["",b$,e,t]}],"backdrop-filter":[{"backdrop-filter":["","none",e,t]}],"backdrop-blur":[{"backdrop-blur":O4()}],"backdrop-brightness":[{"backdrop-brightness":[b$,e,t]}],"backdrop-contrast":[{"backdrop-contrast":[b$,e,t]}],"backdrop-grayscale":[{"backdrop-grayscale":["",b$,e,t]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[b$,e,t]}],"backdrop-invert":[{"backdrop-invert":["",b$,e,t]}],"backdrop-opacity":[{"backdrop-opacity":[b$,e,t]}],"backdrop-saturate":[{"backdrop-saturate":[b$,e,t]}],"backdrop-sepia":[{"backdrop-sepia":["",b$,e,t]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",e,t]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[b$,"initial",e,t]}],ease:[{ease:["linear","initial",Z,e,t]}],delay:[{delay:[b$,e,t]}],animate:[{animate:["none",O,e,t]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[N,e,t]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:F0()}],"rotate-x":[{"rotate-x":F0()}],"rotate-y":[{"rotate-y":F0()}],"rotate-z":[{"rotate-z":F0()}],scale:[{scale:L9()}],"scale-x":[{"scale-x":L9()}],"scale-y":[{"scale-y":L9()}],"scale-z":[{"scale-z":L9()}],"scale-3d":["scale-3d"],skew:[{skew:e7()}],"skew-x":[{"skew-x":e7()}],"skew-y":[{"skew-y":e7()}],transform:[{transform:[e,t,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:fQ()}],"translate-x":[{"translate-x":fQ()}],"translate-y":[{"translate-y":fQ()}],"translate-z":[{"translate-z":fQ()}],"translate-none":["translate-none"],accent:[{accent:b()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:b()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",e,t]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",e,t]}],fill:[{fill:["none",...b()]}],"stroke-w":[{stroke:[b$,RW,s7,Ir]}],stroke:[{stroke:["none",...b()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}};var ir=QL$(jL$);function lr(...$){return ir(yD($))}var pr=()=>{if(typeof document==="undefined")return;let $=document.getElementById("piedata_global_form");$&&$.submit()};
116
+ `.trim()}function l7($,X){return $ in X&&typeof X[$]!=="undefined"}function Kz$($){return l7("modalities",$)||l7("inputAudioFormat",$)||l7("outputAudioFormat",$)||l7("inputAudioTranscription",$)||l7("turnDetection",$)||l7("inputAudioNoiseReduction",$)||l7("speed",$)}function sa($){if(!Kz$($)){let X=$.audio?.input?{format:tq($.audio.input.format),noiseReduction:$.audio.input.noiseReduction??null,transcription:$.audio.input.transcription,turnDetection:$.audio.input.turnDetection}:void 0,Q=$.audio?.output?.voice??$.voice,J=$.audio?.output||typeof Q!=="undefined"?{format:tq($.audio?.output?.format),voice:Q,speed:$.audio?.output?.speed}:void 0;return{model:$.model,instructions:$.instructions,toolChoice:$.toolChoice,tools:$.tools,tracing:$.tracing,providerData:$.providerData,prompt:$.prompt,outputModalities:$.outputModalities,audio:X||J?{input:X,output:J}:void 0}}return{model:$.model,instructions:$.instructions,toolChoice:$.toolChoice,tools:$.tools,tracing:$.tracing,providerData:$.providerData,prompt:$.prompt,outputModalities:$.modalities,audio:{input:{format:tq($.inputAudioFormat),noiseReduction:$.inputAudioNoiseReduction??null,transcription:$.inputAudioTranscription,turnDetection:$.turnDetection},output:{format:tq($.outputAudioFormat),voice:$.voice,speed:$.speed}}}}function tq($){if(!$)return;if(typeof $==="object")return $;let X=String($);if(X==="pcm16")return{type:"audio/pcm",rate:24000};if(X==="g711_ulaw")return{type:"audio/pcmu"};if(X==="g711_alaw")return{type:"audio/pcma"};return{type:"audio/pcm",rate:24000}}var Bi$=B.object({itemId:B.string()}),mI=B.discriminatedUnion("role",[B.object({itemId:B.string(),previousItemId:B.string().nullable().optional(),type:B.literal("message"),role:B.literal("system"),content:B.array(B.object({type:B.literal("input_text"),text:B.string()}))}),B.object({itemId:B.string(),previousItemId:B.string().nullable().optional(),type:B.literal("message"),role:B.literal("user"),status:B.enum(["in_progress","completed"]),content:B.array(B.object({type:B.literal("input_text"),text:B.string()}).or(B.object({type:B.literal("input_audio"),audio:B.string().nullable().optional(),transcript:B.string().nullable()})))}),B.object({itemId:B.string(),previousItemId:B.string().nullable().optional(),type:B.literal("message"),role:B.literal("assistant"),status:B.enum(["in_progress","completed","incomplete"]),content:B.array(B.object({type:B.literal("output_text"),text:B.string()}).or(B.object({type:B.literal("output_audio"),audio:B.string().nullable().optional(),transcript:B.string().nullable().optional()})))})]),cI=B.object({itemId:B.string(),previousItemId:B.string().nullable().optional(),type:B.literal("function_call"),status:B.enum(["in_progress","completed","incomplete"]),arguments:B.string(),name:B.string(),output:B.string().nullable()}),iI=B.object({itemId:B.string(),previousItemId:B.string().nullable().optional(),type:B.enum(["mcp_call","mcp_tool_call"]),status:B.enum(["in_progress","completed","incomplete"]),arguments:B.string(),name:B.string(),output:B.string().nullable()}),ta=B.object({itemId:B.string(),type:B.literal("mcp_approval_request"),serverLabel:B.string(),name:B.string(),arguments:B.record(B.string(),B.any()),approved:B.boolean().optional().nullable()});var Vz$=F8("openai-agents:realtime"),H6=Vz$;var ea=B.object({id:B.string().optional().nullable(),conversation_id:B.string().optional().nullable(),max_output_tokens:B.number().or(B.literal("inf")).optional().nullable(),metadata:B.record(B.string(),B.any()).optional().nullable(),output_modalities:B.array(B.string()).optional().nullable(),object:B.literal("realtime.response").optional().nullable(),output:B.array(B.any()).optional().nullable(),audio:B.object({output:B.object({format:B.any().optional().nullable(),voice:B.string().optional().nullable()}).optional().nullable()}).optional().nullable(),status:B.enum(["completed","incomplete","failed","cancelled","in_progress"]).optional().nullable(),status_details:B.record(B.string(),B.any()).optional().nullable(),usage:B.object({input_tokens:B.number().optional(),input_token_details:B.record(B.string(),B.any()).optional().nullable(),output_tokens:B.number().optional(),output_token_details:B.record(B.string(),B.any()).optional().nullable()}).optional().nullable()}),Hz$=B.object({id:B.string().optional(),audio:B.string().nullable().optional(),text:B.string().nullable().optional(),transcript:B.string().nullable().optional(),type:B.union([B.literal("input_text"),B.literal("input_audio"),B.literal("item_reference"),B.literal("output_text"),B.literal("output_audio")])}),OQ=B.object({id:B.string().optional(),arguments:B.string().optional(),call_id:B.string().optional(),content:B.array(Hz$).optional(),name:B.string().optional(),output:B.string().nullable().optional(),role:B.enum(["user","assistant","system"]).optional(),status:B.enum(["completed","incomplete","in_progress"]).optional(),type:B.enum(["message","function_call","function_call_output","mcp_list_tools","mcp_tool_call","mcp_call","mcp_approval_request","mcp_approval_response"]).optional(),approval_request_id:B.string().nullable().optional(),approve:B.boolean().nullable().optional(),reason:B.string().nullable().optional(),server_label:B.string().optional(),error:B.any().nullable().optional(),tools:B.array(B.object({name:B.string(),description:B.string(),input_schema:B.record(B.string(),B.any()).optional()}).passthrough()).optional()}).passthrough(),Uz$=B.object({type:B.literal("conversation.created"),event_id:B.string(),conversation:B.object({id:B.string().optional(),object:B.literal("realtime.conversation").optional()})}),Bz$=B.object({type:B.literal("conversation.item.added"),event_id:B.string(),item:OQ,previous_item_id:B.string().nullable().optional()}),qz$=B.object({type:B.literal("conversation.item.done"),event_id:B.string(),item:OQ,previous_item_id:B.string().nullable().optional()}),zz$=B.object({type:B.literal("conversation.item.deleted"),event_id:B.string(),item_id:B.string()}),Nz$=B.object({type:B.literal("conversation.item.input_audio_transcription.completed"),event_id:B.string(),item_id:B.string(),content_index:B.number(),transcript:B.string(),logprobs:B.array(B.any()).nullable().optional(),usage:B.object({type:B.literal("tokens"),total_tokens:B.number(),input_tokens:B.number(),input_token_details:B.object({text_tokens:B.number(),audio_tokens:B.number()}),output_tokens:B.number()}).optional()}),Dz$=B.object({type:B.literal("conversation.item.input_audio_transcription.delta"),event_id:B.string(),item_id:B.string(),content_index:B.number().optional(),delta:B.string().optional(),logprobs:B.array(B.any()).nullable().optional()}),Lz$=B.object({type:B.literal("conversation.item.input_audio_transcription.failed"),event_id:B.string(),item_id:B.string(),content_index:B.number(),error:B.object({code:B.string().optional(),message:B.string().optional(),param:B.string().optional(),type:B.string().optional()})}),wz$=B.object({type:B.literal("conversation.item.retrieved"),event_id:B.string(),item:OQ}),Fz$=B.object({type:B.literal("conversation.item.truncated"),event_id:B.string(),item_id:B.string(),audio_end_ms:B.number(),content_index:B.number()}),Zz$=B.object({type:B.literal("conversation.item.create"),item:OQ,event_id:B.string().optional(),previous_item_id:B.string().nullable().optional()}),Oz$=B.object({type:B.literal("conversation.item.delete"),item_id:B.string(),event_id:B.string().optional()}),Mz$=B.object({type:B.literal("conversation.item.retrieve"),item_id:B.string(),event_id:B.string().optional()}),Az$=B.object({type:B.literal("conversation.item.truncate"),item_id:B.string(),audio_end_ms:B.number(),content_index:B.number(),event_id:B.string().optional()}),jz$=B.object({type:B.literal("error"),event_id:B.string().optional(),error:B.any().optional()}),Pz$=B.object({type:B.literal("input_audio_buffer.cleared"),event_id:B.string()}),vz$=B.object({type:B.literal("input_audio_buffer.append"),audio:B.string(),event_id:B.string().optional()}),Iz$=B.object({type:B.literal("input_audio_buffer.clear"),event_id:B.string().optional()}),xz$=B.object({type:B.literal("input_audio_buffer.commit"),event_id:B.string().optional()}),Rz$=B.object({type:B.literal("input_audio_buffer.committed"),event_id:B.string(),item_id:B.string(),previous_item_id:B.string().nullable().optional()}),_z$=B.object({type:B.literal("input_audio_buffer.speech_started"),event_id:B.string(),item_id:B.string(),audio_start_ms:B.number()}),Ez$=B.object({type:B.literal("input_audio_buffer.speech_stopped"),event_id:B.string(),item_id:B.string(),audio_end_ms:B.number()}),Tz$=B.object({type:B.literal("output_audio_buffer.started"),event_id:B.string()}).passthrough(),bz$=B.object({type:B.literal("output_audio_buffer.stopped"),event_id:B.string()}).passthrough(),Sz$=B.object({type:B.literal("output_audio_buffer.cleared"),event_id:B.string()}),kz$=B.object({type:B.literal("rate_limits.updated"),event_id:B.string(),rate_limits:B.array(B.object({limit:B.number().optional(),name:B.enum(["requests","tokens"]).optional(),remaining:B.number().optional(),reset_seconds:B.number().optional()}))}),Cz$=B.object({type:B.literal("response.output_audio.delta"),event_id:B.string(),item_id:B.string(),content_index:B.number(),delta:B.string(),output_index:B.number(),response_id:B.string()}),yz$=B.object({type:B.literal("response.output_audio.done"),event_id:B.string(),item_id:B.string(),content_index:B.number(),output_index:B.number(),response_id:B.string()}),fz$=B.object({type:B.literal("response.output_audio_transcript.delta"),event_id:B.string(),item_id:B.string(),content_index:B.number(),delta:B.string(),output_index:B.number(),response_id:B.string()}),gz$=B.object({type:B.literal("response.output_audio_transcript.done"),event_id:B.string(),item_id:B.string(),content_index:B.number(),transcript:B.string(),output_index:B.number(),response_id:B.string()}),hz$=B.object({type:B.literal("response.content_part.added"),event_id:B.string(),item_id:B.string(),content_index:B.number(),output_index:B.number(),response_id:B.string(),part:B.object({audio:B.string().optional(),text:B.string().optional(),transcript:B.string().optional(),type:B.enum(["text","audio"]).optional()})}),uz$=B.object({type:B.literal("response.content_part.done"),event_id:B.string(),item_id:B.string(),content_index:B.number(),output_index:B.number(),response_id:B.string(),part:B.object({audio:B.string().optional(),text:B.string().optional(),transcript:B.string().optional(),type:B.enum(["text","audio"]).optional()})}),mz$=B.object({type:B.literal("response.created"),event_id:B.string(),response:ea}),lI=B.object({type:B.literal("response.done"),event_id:B.string(),response:ea}),cz$=B.object({type:B.literal("response.function_call_arguments.delta"),event_id:B.string(),item_id:B.string(),call_id:B.string(),delta:B.string(),output_index:B.number(),response_id:B.string()}),iz$=B.object({type:B.literal("response.function_call_arguments.done"),event_id:B.string(),item_id:B.string(),call_id:B.string(),arguments:B.string(),output_index:B.number(),response_id:B.string()}),lz$=B.object({type:B.literal("response.output_item.added"),event_id:B.string(),item:OQ,output_index:B.number(),response_id:B.string()}),pz$=B.object({type:B.literal("response.output_item.done"),event_id:B.string(),item:OQ,output_index:B.number(),response_id:B.string()}),nz$=B.object({type:B.literal("response.output_text.delta"),event_id:B.string(),item_id:B.string(),content_index:B.number(),delta:B.string(),output_index:B.number(),response_id:B.string()}),dz$=B.object({type:B.literal("response.output_text.done"),event_id:B.string(),item_id:B.string(),content_index:B.number(),text:B.string(),output_index:B.number(),response_id:B.string()}),az$=B.object({type:B.literal("session.created"),event_id:B.string(),session:B.any()}),oz$=B.object({type:B.literal("session.updated"),event_id:B.string(),session:B.any()}),rz$=B.object({type:B.literal("response.cancel"),event_id:B.string().optional(),response_id:B.string().optional()}),sz$=B.object({type:B.literal("response.create"),event_id:B.string().optional(),response:B.any().optional()}),tz$=B.object({type:B.literal("session.update"),event_id:B.string().optional(),session:B.any()}),ez$=B.object({type:B.literal("mcp_list_tools.in_progress"),event_id:B.string().optional(),item_id:B.string().optional()}),$N$=B.object({type:B.literal("mcp_list_tools.completed"),event_id:B.string().optional(),item_id:B.string().optional()}),XN$=B.object({type:B.literal("response.mcp_call_arguments.delta"),event_id:B.string(),response_id:B.string(),item_id:B.string(),output_index:B.number(),delta:B.string(),obfuscation:B.string()}),QN$=B.object({type:B.literal("response.mcp_call_arguments.done"),event_id:B.string(),response_id:B.string(),item_id:B.string(),output_index:B.number(),arguments:B.string()}),YN$=B.object({type:B.literal("response.mcp_call.in_progress"),event_id:B.string(),output_index:B.number(),item_id:B.string()}),JN$=B.object({type:B.literal("response.mcp_call.completed"),event_id:B.string(),output_index:B.number(),item_id:B.string()}),GN$=B.object({type:B.literal("mcp_list_tools.failed"),event_id:B.string().optional(),item_id:B.string().optional()}),WN$=B.object({type:B.string(),event_id:B.string().optional().nullable()}).passthrough(),KN$=B.discriminatedUnion("type",[Uz$,Bz$,qz$,zz$,Nz$,Dz$,Lz$,wz$,Fz$,jz$,Pz$,Rz$,_z$,Ez$,Tz$,bz$,Sz$,kz$,Cz$,yz$,fz$,gz$,hz$,uz$,mz$,lI,cz$,iz$,lz$,pz$,nz$,dz$,az$,oz$,ez$,$N$,GN$,XN$,QN$,YN$,JN$]),Li$=B.discriminatedUnion("type",[Zz$,Oz$,Mz$,Az$,vz$,Iz$,xz$,rz$,sz$,tz$]);function MQ($){let X=JSON.parse($.data.toString()),Q=KN$.safeParse(X);if(!Q.success){let J=WN$.safeParse(X);if(J.success)return{data:J.data,isGeneric:!0};return{data:null,isGeneric:!0}}return{data:Q.data,isGeneric:!1}}var $o="gpt-realtime",D0={outputModalities:["audio"],audio:{input:{format:{type:"audio/pcm",rate:24000},transcription:{model:"gpt-4o-mini-transcribe"},turnDetection:{type:"semantic_vad"},noiseReduction:null},output:{format:{type:"audio/pcm",rate:24000},speed:1}}};class p7 extends FQ{#$;#X;#G=null;#Q=null;eventEmitter=new v8.EventEmitter;constructor($={}){super();this.#$=$.model??$o,this.#X=$.apiKey}get currentModel(){return this.#$}set currentModel($){this.#$=$}_afterAudioDoneEvent(){}get _rawSessionConfig(){return this.#Q??null}async _getApiKey($){let X=$.apiKey??this.#X;if(typeof X==="function")return await X();return X}_onMessage($){let{data:X,isGeneric:Q}=MQ($);if(X===null)return;if(this.emit("*",X),Q)return;if(X.type==="error")this.emit("error",{type:"error",error:X});else this.emit(X.type,X);if(X.type==="response.created"){this.emit("turn_started",{type:"response_started",providerData:{...X}});return}if(X.type==="session.updated")this.#Q=X.session;if(X.type==="response.done"){let J=lI.safeParse(X);if(!J.success){H6.error("Error parsing response done event",J.error);return}let Y=J.data.response.usage?.input_tokens??0,G=J.data.response.usage?.output_tokens??0,W=Y+G,K=new N0({inputTokens:Y,inputTokensDetails:J.data.response.usage?.input_token_details??{},outputTokens:G,outputTokensDetails:J.data.response.usage?.output_token_details??{},totalTokens:W});this.emit("usage_update",K),this.emit("turn_done",{type:"response_done",response:{id:J.data.response.id??"",output:J.data.response.output??[],usage:{inputTokens:Y,inputTokensDetails:J.data.response.usage?.input_token_details??{},outputTokens:G,outputTokensDetails:J.data.response.usage?.output_token_details??{},totalTokens:W}}});return}if(X.type==="response.output_audio.done"){this.emit("audio_done"),this._afterAudioDoneEvent();return}if(X.type==="conversation.item.deleted"){this.emit("item_deleted",{itemId:X.item_id});return}if(X.type==="conversation.item.input_audio_transcription.completed"||X.type==="conversation.item.truncated"){this.sendEvent({type:"conversation.item.retrieve",item_id:X.item_id});return}if(X.type==="conversation.item.input_audio_transcription.delta"||X.type==="response.output_text.delta"||X.type==="response.output_audio_transcript.delta"||X.type==="response.function_call_arguments.delta"){if(X.type==="response.output_audio_transcript.delta")this.emit("audio_transcript_delta",{type:"transcript_delta",delta:X.delta,itemId:X.item_id,responseId:X.response_id});return}if(X.type==="conversation.item.added"||X.type==="conversation.item.done"||X.type==="conversation.item.retrieved"){if(X.item.type==="mcp_list_tools"&&X.type==="conversation.item.done"){let J=X.item.server_label??"",Y=X.item.tools??[];try{this.emit("mcp_tools_listed",{serverLabel:J,tools:Y})}catch(G){H6.error("Error emitting mcp_tools_listed",G,X.item)}return}if(X.item.type==="message"){let J=X.type==="conversation.item.added"||X.type==="conversation.item.done"?X.previous_item_id:null,Y=mI.parse({itemId:X.item.id,previousItemId:J,type:X.item.type,role:X.item.role,content:X.item.content,status:X.item.status});this.emit("item_update",Y);return}if(X.item.type==="mcp_approval_request"&&X.type==="conversation.item.done"){let J=X.item,Y=ta.parse({itemId:J.id,type:J.type,serverLabel:J.server_label,name:J.name,arguments:JSON.parse(J.arguments||"{}"),approved:J.approved});this.emit("item_update",Y),this.emit("mcp_approval_request",Y);return}if(X.item.type==="mcp_tool_call"||X.item.type==="mcp_call"){let J=X.type==="conversation.item.done"?"completed":"in_progress",Y=iI.parse({itemId:X.item.id,type:X.item.type,status:J,arguments:X.item.arguments,name:X.item.name,output:X.item.output});if(this.emit("item_update",Y),X.type==="conversation.item.done")this.emit("mcp_tool_call_completed",Y);return}}if(X.type==="response.mcp_call.in_progress"){let J=X;this.sendEvent({type:"conversation.item.retrieve",item_id:J.item_id});return}if(X.type==="mcp_list_tools.in_progress"){let J=X;if(J.item_id)this.sendEvent({type:"conversation.item.retrieve",item_id:J.item_id});return}if(X.type==="response.output_item.done"||X.type==="response.output_item.added"){let J=X.item;if(J.type==="function_call"&&J.status==="completed"){let Y=cI.parse({itemId:J.id,type:J.type,status:"in_progress",arguments:J.arguments,name:J.name,output:null});this.emit("item_update",Y),this.emit("function_call",{id:J.id,type:"function_call",callId:J.call_id??"",arguments:J.arguments??"",name:J.name??""});return}if(J.type==="mcp_tool_call"||J.type==="mcp_call"){let Y=iI.parse({itemId:J.id,type:J.type,status:X.type==="response.output_item.done"?"completed":"in_progress",arguments:J.arguments,name:J.name,output:J.output});this.emit("item_update",Y);return}if(J.type==="message"){let Y=mI.parse({itemId:X.item.id,type:X.item.type,role:X.item.role,content:X.item.content,status:X.type==="response.output_item.done"?J.status??"completed":J.status??"in_progress"});this.emit("item_update",Y);return}}}_onError($){this.emit("error",{type:"error",error:$})}_onOpen(){this.emit("connected")}_onClose(){this.emit("disconnected")}sendMessage($,X,{triggerResponse:Q=!0}={}){let J=typeof $==="string"?[{type:"input_text",text:$}]:$.content.map((Y)=>{if(Y.type==="input_image")return{type:"input_image",image_url:Y.image,...Y.providerData??{}};return Y});if(this.sendEvent({type:"conversation.item.create",item:{type:"message",role:"user",content:J},...X}),Q)this.sendEvent({type:"response.create"})}addImage($,{triggerResponse:X=!0}={}){this.sendMessage({type:"message",role:"user",content:[{type:"input_image",image:$}]},{},{triggerResponse:X})}_getMergedSessionConfig($){let X=sa($),Q=X.audio?.input?.noiseReduction,J=X.audio?.input?.transcription,Y=p7.buildTurnDetectionConfig(X.audio?.input?.turnDetection),G={type:"realtime",instructions:X.instructions,model:X.model??this.#$,output_modalities:X.outputModalities??D0.outputModalities,audio:{input:{format:X.audio?.input?.format??D0.audio?.input?.format,noise_reduction:Q===void 0?D0.audio?.input?.noiseReduction:Q,transcription:J===void 0?D0.audio?.input?.transcription:J,turn_detection:Y===void 0?D0.audio?.input?.turnDetection:Y},output:{format:X.audio?.output?.format??D0.audio?.output?.format,voice:X.audio?.output?.voice??D0.audio?.output?.voice,speed:X.audio?.output?.speed??D0.audio?.output?.speed}},tool_choice:X.toolChoice??D0.toolChoice,...X.providerData??{}};if(X.prompt)G.prompt={id:X.prompt.promptId,version:X.prompt.version,variables:X.prompt.variables};if(X.tools&&X.tools.length>0)G.tools=X.tools.map((W)=>{let K=(V)=>Object.fromEntries(Object.entries(V).filter(([,H])=>typeof H!=="undefined"));if(W.type==="mcp")return K({type:"mcp",server_label:W.server_label,server_url:W.server_url,server_description:W.server_description,connector_id:W.connector_id,authorization:W.authorization,headers:W.headers,allowed_tools:W.allowed_tools,require_approval:W.require_approval});return K({type:W.type,name:W.name,description:W.description,parameters:W.parameters})});return G}buildSessionPayload($){return this._getMergedSessionConfig($)}static buildTurnDetectionConfig($){if(typeof $==="undefined")return;if($===null)return null;let{type:X,createResponse:Q,create_response:J,eagerness:Y,interruptResponse:G,interrupt_response:W,prefixPaddingMs:K,prefix_padding_ms:V,silenceDurationMs:H,silence_duration_ms:U,threshold:q,idleTimeoutMs:z,idle_timeout_ms:L,modelVersion:D,model_version:N,...w}=$,Z={type:X,create_response:Q??J,eagerness:Y,interrupt_response:G??W,prefix_padding_ms:K??V,silence_duration_ms:H??U,idle_timeout_ms:z??L,model_version:D??N,threshold:q,...w};return Object.keys(Z).forEach((O)=>{if(Z[O]===void 0)delete Z[O]}),Object.keys(Z).length>0?Z:void 0}set _tracingConfig($){this.#G=$}_updateTracingConfig($){if(typeof this.#G==="undefined")this.#G=null;if($==="auto"){this.sendEvent({type:"session.update",session:{type:"realtime",tracing:"auto"}});return}if(this.#G!==null&&typeof this.#G!=="string"&&typeof $!=="string"){H6.warn("Tracing config is already set, skipping setting it again. This likely happens when you already set a tracing config on session creation.");return}if($===null){H6.debug("Disabling tracing for this session. It cannot be turned on for this session from this point on."),this.sendEvent({type:"session.update",session:{type:"realtime",tracing:null}});return}if(this.#G===null||typeof this.#G==="string"){this.sendEvent({type:"session.update",session:{type:"realtime",tracing:$}});return}if($?.group_id!==this.#G?.group_id||$?.metadata!==this.#G?.metadata||$?.workflow_name!==this.#G?.workflow_name){H6.warn("Mismatch in tracing config. Ignoring the new tracing config. This likely happens when you already set a tracing config on session creation. Current tracing config: %s, new tracing config: %s",JSON.stringify(this.#G),JSON.stringify($));return}this.sendEvent({type:"session.update",session:{type:"realtime",tracing:$}})}updateSessionConfig($){let X=this.buildSessionPayload($);this.sendEvent({type:"session.update",session:X})}sendFunctionCallOutput($,X,Q=!0){this.sendEvent({type:"conversation.item.create",item:{type:"function_call_output",output:X,call_id:$.callId}});try{let J=cI.parse({itemId:$.id,previousItemId:$.previousItemId,type:"function_call",status:"completed",arguments:$.arguments,name:$.name,output:X});this.emit("item_update",J)}catch(J){H6.error("Error parsing tool call item",J,$)}if(Q)this.sendEvent({type:"response.create"})}sendAudio($,{commit:X=!1}={}){if(this.sendEvent({type:"input_audio_buffer.append",audio:fI($)}),X)this.sendEvent({type:"input_audio_buffer.commit"})}resetHistory($,X){let{removals:Q,additions:J,updates:Y}=la($,X),G=new Set(Q.map((K)=>K.itemId));for(let K of Y)G.add(K.itemId);if(G.size>0)for(let K of G)this.sendEvent({type:"conversation.item.delete",item_id:K});let W=[...J,...Y];for(let K of W)if(K.type==="message"){let V={type:"message",role:K.role,content:K.content,id:K.itemId};if(K.role!=="system"&&K.status)V.status=K.status;this.sendEvent({type:"conversation.item.create",item:V})}else if(K.type==="function_call")H6.warn("Function calls cannot be manually added or updated at the moment. Ignoring.")}sendMcpResponse($,X){this.sendEvent({type:"conversation.item.create",previous_item_id:$.itemId,item:{type:"mcp_approval_response",approval_request_id:$.itemId,approve:X}})}}class AQ extends p7{options;#$;#X={status:"disconnected",peerConnection:void 0,dataChannel:void 0,callId:void 0};#G;#Q=!1;#W=!1;#J;#K=0;constructor($={}){if(typeof RTCPeerConnection==="undefined")throw new Error("WebRTC is not supported in this environment");super($);this.options=$,this.#$=$.baseUrl??"https://api.openai.com/v1/realtime/calls",this.#G=$.useInsecureApiKey??!1}get callId(){return this.#X.callId}get status(){return this.#X.status}get connectionState(){return this.#X}get muted(){return this.#W}async connect($){if(this.#X.status==="connected")return;if(this.#X.status==="connecting"){if(this.#J)return this.#J;H6.warn("Realtime connection already in progress but no promise found");return}let X=$.model??this.currentModel;this.currentModel=X;let Q=$.url??this.#$,J=await this._getApiKey($),Y=typeof J==="string"&&J.startsWith("ek_");if(wG()&&!this.#G&&!Y)throw new U$("Using the WebRTC connection in a browser environment requires an ephemeral client key. If you need to use a regular API key, use the WebSocket transport or set the `useInsecureApiKey` option to true.");let G=++this.#K;return this.#J=new Promise(async(W,K)=>{try{let V={...$.initialSessionConfig||{},model:this.currentModel},H=new URL(Q),U=new RTCPeerConnection,q=U.createDataChannel("oai-events"),z=void 0,L=(F)=>{F.onconnectionstatechange=()=>{switch(F.connectionState){case"disconnected":case"failed":case"closed":this.close();break}}};L(U),this.#X={status:"connecting",peerConnection:U,dataChannel:q,callId:z},this.emit("connection_change",this.#X.status),q.addEventListener("open",()=>{this.#X={status:"connecting",peerConnection:U,dataChannel:q,callId:z};let F=!1,M,A=()=>{if(F)return;if(F=!0,M!==void 0)clearTimeout(M);if(q.removeEventListener("message",v),q.removeEventListener("close",T),this.#X.status!=="connecting"||this.#X.dataChannel!==q||q.readyState!=="open"){if(this.#X.dataChannel===q)this.close();K(new Error("Connection closed before session config was acknowledged"));return}this.#X={status:"connected",peerConnection:U,dataChannel:q,callId:z},this.emit("connection_change",this.#X.status),this._onOpen(),W()},v=(R)=>{if(JSON.parse(R.data).type==="session.updated")A()},T=()=>{A()};M=setTimeout(()=>{if(!F)H6.warn("Timed out waiting for session.updated ack — resolving connect() anyway"),A()},5000),q.addEventListener("message",v),q.addEventListener("close",T),q.addEventListener("message",(R)=>{this._onMessage(R);let{data:h,isGeneric:J$}=MQ(R);if(!h||J$)return;if(h.type==="response.created")this.#Q=!0;else if(h.type==="response.done")this.#Q=!1;if(h.type==="session.created"){this._tracingConfig=h.session.tracing;let B$=typeof V.tracing==="undefined"?"auto":V.tracing;this._updateTracingConfig(B$)}}),this.updateSessionConfig(V)}),q.addEventListener("error",(F)=>{this.close(),this._onError(F),K(F)});let D=this.options.audioElement??document.createElement("audio");D.autoplay=!0,U.ontrack=(F)=>{D.srcObject=F.streams[0]};let N=this.options.mediaStream??await navigator.mediaDevices.getUserMedia({audio:!0});if(U.addTrack(N.getAudioTracks()[0]),this.options.changePeerConnection){let F=U;if(U=await this.options.changePeerConnection(U),F!==U)F.onconnectionstatechange=null;L(U),this.#X={...this.#X,peerConnection:U}}let w=await U.createOffer();if(await U.setLocalDescription(w),!w.sdp)throw new Error("Failed to create offer");let Z=await fetch(H,{method:"POST",body:w.sdp,headers:{"Content-Type":"application/sdp",Authorization:`Bearer ${J}`,"X-OpenAI-Agents-SDK":rq["X-OpenAI-Agents-SDK"]}});z=Z.headers?.get("Location")?.split("/").pop(),this.#X={...this.#X,callId:z};let O={type:"answer",sdp:await Z.text()};await U.setRemoteDescription(O)}catch(V){this.close(),this._onError(V),K(V)}}).finally(()=>{if(this.#K===G)this.#J=void 0}),this.#J}sendEvent($){if(!this.#X.dataChannel||this.#X.dataChannel.readyState!=="open")throw new Error("WebRTC data channel is not connected. Make sure you call `connect()` before sending events.");this.#X.dataChannel.send(JSON.stringify($))}mute($){if(this.#W=$,this.#X.peerConnection)this.#X.peerConnection.getSenders().forEach((Q)=>{if(Q.track)Q.track.enabled=!$})}_afterAudioDoneEvent(){this.#Q=!1}close(){if(this.#X.dataChannel)this.#X.dataChannel.close();if(this.#X.peerConnection){let $=this.#X.peerConnection;$.onconnectionstatechange=null,$.getSenders().forEach((X)=>{X.track?.stop()}),$.close()}if(this.#X.status!=="disconnected")this.#X={status:"disconnected",peerConnection:void 0,dataChannel:void 0,callId:void 0},this.emit("connection_change",this.#X.status),this._onClose()}interrupt(){if(this.#Q)this.sendEvent({type:"response.cancel"}),this.#Q=!1;this.sendEvent({type:"output_audio_buffer.clear"})}}var x2$=V$(ro()),R2$=V$(Wz()),_2$=V$(vQ()),E2$=V$(rI()),T2$=V$(tI()),b2$=V$(Jx()),qz=V$(Uz()),S2$=V$(Qr());function Yr(){return!1}var Jr=!1;class IW extends p7{#$;#X;#G;#Q={status:"disconnected",websocket:void 0};#W;#J;#K;_firstAudioTimestamp;_audioLengthMs=0;#Y=!1;#V;#U;#H(){this.#J=void 0,this._firstAudioTimestamp=void 0,this._audioLengthMs=0,this.#K=void 0}constructor($={}){super($);this.#X=$.url,this.#G=$.url,this.#W=$.useInsecureApiKey??!1,this.#V=$.createWebSocket,this.#U=$.skipOpenEventListeners??!1}getCommonRequestHeaders(){return rq}get status(){return this.#Q.status}get connectionState(){return this.#Q}get muted(){return null}get currentItemId(){return this.#J}_onAudio($){this.emit("audio",$)}_afterAudioDoneEvent(){this.#H()}async#q($,X,Q){if(this.#Q.websocket){$();return}if(!this.#$)throw new U$("API key is not set. Please call `connect()` with an API key first.");if(Yr()&&!this.#$.startsWith("ek_")&&!this.#W)throw new U$("Using the WebSocket connection in a browser environment requires an ephemeral client key. If you have to use a regular API key, set the `useInsecureApiKey` option to true.");let J=null;if(this.#V)J=await this.#V({url:this.#X,apiKey:this.#$});else{let G=Jr?["realtime","openai-insecure-api-key."+this.#$,na]:{headers:{Authorization:`Bearer ${this.#$}`,...this.getCommonRequestHeaders()}};J=new qz.default(this.#X,G)}this.#Q={status:"connecting",websocket:J},this.emit("connection_change",this.#Q.status);let Y=()=>{this.#Q={status:"connected",websocket:J},this.emit("connection_change",this.#Q.status),this._onOpen(),$()};if(this.#U===!0)Y();else J.addEventListener("open",Y);J.addEventListener("error",(G)=>{this._onError(G),this.#Q={status:"disconnected",websocket:void 0},this.emit("connection_change",this.#Q.status),X(G)}),J.addEventListener("message",(G)=>{this._onMessage(G);let{data:W,isGeneric:K}=MQ(G);if(!W||K)return;if(W.type==="response.output_audio.delta"){if(this.#K=W.content_index,this.#J=W.item_id,this._firstAudioTimestamp===void 0)this._firstAudioTimestamp=Date.now(),this._audioLengthMs=0;let V=yI(W.delta),H=this._rawSessionConfig?.audio?.output?.format;if(H&&typeof H==="object"){let q=H.type;if(q==="audio/pcmu"||q==="audio/pcma")this._audioLengthMs+=V.byteLength/8;else if(q==="audio/pcm"){let z=H.rate??24000;this._audioLengthMs+=V.byteLength/2/z*1000}else this._audioLengthMs+=V.byteLength/24/2}else if(typeof H==="string")if(H.startsWith("g711_"))this._audioLengthMs+=V.byteLength/8;else this._audioLengthMs+=V.byteLength/24/2;else this._audioLengthMs+=V.byteLength/24/2;let U={type:"audio",data:V,responseId:W.response_id};this._onAudio(U)}else if(W.type==="input_audio_buffer.speech_started"){let V=this._rawSessionConfig?.audio?.input?.turn_detection?.interrupt_response??!1;this.interrupt(!V)}else if(W.type==="response.created")this.#Y=!0;else if(W.type==="response.done")this.#Y=!1;else if(W.type==="session.created"){this._tracingConfig=W.session.tracing;let V=typeof Q.tracing==="undefined"?"auto":Q.tracing;this._updateTracingConfig(V)}}),J.addEventListener("close",()=>{this.#Q={status:"disconnected",websocket:void 0},this.emit("connection_change",this.#Q.status),this._onClose()})}async connect($){let X=$.model??this.currentModel;this.currentModel=X,this.#$=await this._getApiKey($);let Q=$.callId,J;if($.url)J=$.url,this.#G=$.url;else if(Q)J=`wss://api.openai.com/v1/realtime?call_id=${Q}`;else if(this.#G)J=this.#G;else J=`wss://api.openai.com/v1/realtime?model=${this.currentModel}`;this.#X=J;let Y={...$.initialSessionConfig||{},model:this.currentModel};await new Promise((G,W)=>{this.#q(G,W,Y).catch(W)}),await this.updateSessionConfig(Y)}sendEvent($){if(!this.#Q.websocket)throw new Error("WebSocket is not connected. Make sure you call `connect()` before sending events.");this.#Q.websocket.send(JSON.stringify($))}close(){this.#Q.websocket?.close(),this.#J=void 0,this._firstAudioTimestamp=void 0,this._audioLengthMs=0,this.#K=void 0}mute($){throw new Error("Mute is not supported for the WebSocket transport. You have to mute the audio input yourself.")}sendAudio($,X={}){if(this.#Q.status==="connected")super.sendAudio($,X)}_cancelResponse(){if(this.#Y)this.sendEvent({type:"response.cancel"}),this.#Y=!1}_interrupt($,X=!0){if($<0)return;if(X)this._cancelResponse();let Q=this._audioLengthMs??Number.POSITIVE_INFINITY,J=Math.max(0,Math.floor(Math.min($,Q)));this.emit("audio_interrupted"),this.sendEvent({type:"conversation.item.truncate",item_id:this.#J,content_index:this.#K,audio_end_ms:J})}interrupt($=!0){if(!this.#J||typeof this._firstAudioTimestamp!=="number")return;let X=Date.now()-this._firstAudioTimestamp;if(X>=0)this._interrupt(X,$);this.#H()}}var k2$=Symbol("backgroundResult");function Gx($){return typeof $==="object"&&$!==null&&k2$ in $}function Gr($){return $.type==="function"||$.type==="hosted_tool"&&$.name==="hosted_mcp"}function Wr($){if($.type==="function")return $;if($.type==="hosted_tool"&&$.name==="hosted_mcp"){let X=$.providerData.server_url&&$.providerData.server_url.length>0?$.providerData.server_url:void 0;return{type:"mcp",server_label:$.providerData.server_label,server_url:X,headers:$.providerData.headers,allowed_tools:$.providerData.allowed_tools,require_approval:$.providerData.require_approval}}throw new U$(`Invalid tool type: ${$}`)}function C2$(){return JSON.parse(JSON.stringify(D0))}var Wx="Tool execution was not approved.";function y2$($){return $ instanceof Error?$.message:String($)}class TQ extends v8.EventEmitter{initialAgent;options;#$;#X;#G;#Q;#W=[];#J;#K={};#Y=[];#V;#U={};#H=!1;#q=new Map;#B=[];#N=C2$();#D=!0;#z=!1;constructor($,X={}){super();if(this.initialAgent=$,this.options=X,typeof X.transport==="undefined"&&pa()||X.transport==="webrtc")this.#$=new AQ;else if(X.transport==="websocket"||typeof X.transport==="undefined")this.#$=new IW;else this.#$=X.transport;this.#X=$,this.#Q=new O6({...X.context??{},history:this.#Y}),this.#W=(X.outputGuardrails??[]).map(oa),this.#J=aa(X.outputGuardrailSettings??{}),this.#V=X.historyStoreAudio??!1,this.#D=X.automaticallyTriggerResponseForMcpToolCalls??!0}get transport(){return this.#$}get currentAgent(){return this.#X}get usage(){return this.#Q.usage}get context(){return this.#Q}get muted(){return this.#$.muted}get history(){return this.#Y}get availableMcpTools(){return this.#B}async#L($){this.#X=$;let X=await this.#X.getEnabledHandoffs(this.#Q),Q=X.map((W)=>W.getHandoffAsFunctionTool()),J=(await this.#X.getAllTools(this.#Q)).filter(Gr).map(Wr),Y=typeof this.#X.tools!=="undefined"||typeof this.#X.mcpServers!=="undefined",G=X.length>0;this.#G=Y||G?[...J,...Q]:void 0,this.#O()}async#w($={}){let X=$??{},Q=this.options.config??{},J=await this.#X.getSystemPrompt(this.#Q),Y=(q)=>{return q.audio?.output?.voice},G=this.options.tracingDisabled?null:this.options.workflowName?{workflow_name:this.options.workflowName}:"auto";if(G!==null&&G!=="auto"){if(this.options.groupId)G.group_id=this.options.groupId;if(this.options.traceMetadata)G.metadata=this.options.traceMetadata}else if(this.options.groupId||this.options.traceMetadata)H6.warn("In order to set traceMetadata or a groupId you need to specify a workflowName.");let W=Y(X)??Y(Q),K=X.voice??Q.voice,V=typeof W!=="undefined"?W:typeof K!=="undefined"?K:this.#X.voice,U={...{...this.#N??{},...Q,...X},instructions:J,voice:V,model:this.options.model,tools:this.#G,tracing:G,prompt:typeof this.#X.prompt==="function"?await this.#X.prompt(this.#Q,this.#X):this.#X.prompt};return this.#N=U,U}async getInitialSessionConfig($={}){return await this.#L(this.initialAgent),this.#w({...this.options.config??{},...$??{}})}static async computeInitialSessionConfig($,X={},Q={}){let J=new TQ($,X);try{return await J.getInitialSessionConfig(Q)}finally{J.close()}}async updateAgent($){return this.#X.emit("agent_handoff",this.#Q,$),this.emit("agent_handoff",this.#Q,this.#X,$),await this.#L($),await this.#$.updateSessionConfig(await this.#w()),$}async#M($,X){let Q=await X.onInvokeHandoff(this.#Q,$.arguments);this.#X.emit("agent_handoff",this.#Q,Q),this.emit("agent_handoff",this.#Q,this.#X,Q),await this.#L(Q),await this.#$.updateSessionConfig(await this.#w());let J=BW(Q);return this.#$.sendFunctionCallOutput($,J,!0),Q}async#A($,X){let{toolErrorFormatter:Q}=this.options;if(!Q)return Wx;try{let J=await Q({kind:"approval_rejected",toolType:"function",toolName:$,callId:X,defaultMessage:Wx,runContext:this.#Q});if(typeof J==="string")return J;if(typeof J!=="undefined")H6.warn("toolErrorFormatter returned a non-string value. Falling back to the default tool approval rejection message.")}catch(J){H6.warn(`toolErrorFormatter threw while formatting approval rejection: ${y2$(J)}`)}return Wx}async#F($,X){this.#Q.context.history=JSON.parse(JSON.stringify(this.#Y));let Q=$.arguments;if(X.parameters)if($1(X.parameters))Q=X.parameters.parse(Q);else Q=JSON.parse(Q);if(await X.needsApproval(this.#Q,Q,$.callId)){let V=this.context.isToolApproved({toolName:X.name,callId:$.callId});if(V===!1){this.emit("agent_tool_start",this.#Q,this.#X,X,{toolCall:$}),this.#X.emit("agent_tool_start",this.#Q,X,{toolCall:$});let H=await this.#A(X.name,$.callId);this.#$.sendFunctionCallOutput($,H,!0),this.emit("agent_tool_end",this.#Q,this.#X,X,H,{toolCall:$}),this.#X.emit("agent_tool_end",this.#Q,X,H,{toolCall:$});return}else if(typeof V==="undefined"){this.emit("tool_approval_requested",this.#Q,this.#X,{type:"function_approval",tool:X,approvalItem:new l$($,this.#X)});return}}let Y=await NW({guardrails:X.inputGuardrails,context:this.#Q,agent:this.#X,toolCall:$});this.emit("agent_tool_start",this.#Q,this.#X,X,{toolCall:$}),this.#X.emit("agent_tool_start",this.#Q,X,{toolCall:$}),this.#Q.context.history=JSON.parse(JSON.stringify(this.#Y));let G=Y.type==="reject"?Y.message:await MG({tool:X,runContext:this.#Q,input:$.arguments,details:{toolCall:$}}),W=Y.type==="reject"?G:await DW({guardrails:X.outputGuardrails,context:this.#Q,agent:this.#X,toolCall:$,toolOutput:G}),K;if(Gx(W))K=i1(W.content),this.#$.sendFunctionCallOutput($,K,!1);else K=i1(W),this.#$.sendFunctionCallOutput($,K,!0);this.emit("agent_tool_end",this.#Q,this.#X,X,K,{toolCall:$}),this.#X.emit("agent_tool_end",this.#Q,X,K,{toolCall:$})}async#j($){let X=await this.#X.getEnabledHandoffs(this.#Q),Q=new Map(X.map((W)=>[W.toolName,W])),J=await this.#X.getAllTools(this.#Q),Y=new Map(J.map((W)=>[W.name,W])),G=Q.get($.name);if(G)await this.#M($,G);else{let W=Y.get($.name);if(W&&W.type==="function")await this.#F($,W);else throw new T4(`Tool ${$.name} not found`)}}async#Z($,X,Q){if(this.#W.length===0)return;let J={agent:this.#X,agentOutput:$,context:this.#Q},G=(await Promise.all(this.#W.map((W)=>W.run(J)))).find((W)=>W.output.tripwireTriggered);if(G){if(this.#U[X])return;this.#U[X]=!0;let W=new e9(`Output guardrail triggered: ${JSON.stringify(G.output.outputInfo)}`,G);this.emit("guardrail_tripped",this.#Q,this.#X,W,{itemId:Q}),this.interrupt();let K=ra(G);this.sendMessage(K);return}}#P(){this.#$.on("*",(Q)=>{if(this.emit("transport_event",Q),Q.type==="conversation.item.input_audio_transcription.completed")try{let J=Q;this.#Y=hI(this.#Y,J,this.#V),this.#Q.context.history=this.#Y,this.emit("history_updated",this.#Y)}catch(J){this.emit("error",{type:"error",error:J})}}),this.#$.on("mcp_tools_listed",({serverLabel:Q,tools:J})=>{try{this.#q.set(Q,J??[]),this.#O()}catch(Y){this.emit("error",{type:"error",error:Y})}}),this.#$.on("audio",(Q)=>{if(!this.#H)this.#H=!0,this.emit("audio_start",this.#Q,this.#X);this.emit("audio",Q)}),this.#$.on("turn_started",()=>{this.#H=!1,this.emit("agent_start",this.#Q,this.#X),this.#X.emit("agent_start",this.#Q,this.#X)}),this.#$.on("turn_done",(Q)=>{let J=Q.response.output??[],Y="",G="";for(let W=J.length-1;W>=0;W--){let K=J[W],V=gI(K);if(typeof V==="string"){Y=V;let H=K?.id;G=typeof H==="string"?H:"";break}}if(!G&&J.length>0){let W=J[J.length-1];G=typeof W?.id==="string"?W.id:""}this.emit("agent_end",this.#Q,this.#X,Y),this.#X.emit("agent_end",this.#Q,Y),this.#Z(Y,Q.response.id,G)}),this.#$.on("audio_done",()=>{if(this.#H)this.#H=!1;this.emit("audio_stopped",this.#Q,this.#X)});let $=0,X;this.#$.on("audio_transcript_delta",(Q)=>{try{let{delta:J,itemId:Y,responseId:G}=Q;if(X!==Y)X=Y,$=0;let K=(this.#K[Y]??"")+J;if(this.#K[Y]=K,this.#J.debounceTextLength<0)return;let V=Math.floor(K.length/this.#J.debounceTextLength);if(V>$)$=V,this.#Z(K,G,Y)}catch(J){this.emit("error",{type:"error",error:J})}}),this.#$.on("item_update",(Q)=>{try{let J=!this.#Y.some((Y)=>Y.itemId===Q.itemId);if(this.#Y=hI(this.#Y,Q,this.#V),this.#Q.context.history=this.#Y,J){let Y=this.#Y.find((G)=>G.itemId===Q.itemId);if(Y)this.emit("history_added",Y)}this.emit("history_updated",this.#Y)}catch(J){this.emit("error",{type:"error",error:J})}}),this.#$.on("item_deleted",(Q)=>{try{this.#Y=this.#Y.filter((J)=>J.itemId!==Q.itemId),this.#Q.context.history=this.#Y,this.emit("history_updated",this.#Y)}catch(J){this.emit("error",{type:"error",error:J})}}),this.#$.on("function_call",async(Q)=>{try{await this.#j(Q)}catch(J){H6.error("Error handling function call",J),this.emit("error",{type:"error",error:J})}}),this.#$.on("usage_update",(Q)=>{this.#Q.usage.add(Q)}),this.#$.on("audio_interrupted",()=>{if(this.#H)this.#H=!1;this.emit("audio_interrupted",this.#Q,this.#X)}),this.#$.on("error",(Q)=>{this.emit("error",Q)}),this.#$.on("mcp_tool_call_completed",(Q)=>{if(this.emit("mcp_tool_call_completed",this.#Q,this.#X,Q),this.#D)this.#$.sendEvent({type:"response.create"})}),this.#$.on("mcp_approval_request",(Q)=>{this.emit("tool_approval_requested",this.#Q,this.#X,{type:"mcp_approval_request",approvalItem:da(this.#X,Q)})})}#O(){let $=this.#G?.filter((W)=>W.type==="mcp"),X=(W)=>{let K=W.allowed_tools;if(!K)return;if(Array.isArray(K))return K;if(K&&Array.isArray(K.tool_names))return K.tool_names;return},Q=new Map;for(let W of $){let K=this.#q.get(W.server_label)??[],V=X(W);for(let H of K){if(V&&!V.includes(H.name))continue;if(!Q.has(H.name))Q.set(H.name,H)}}let J=Array.from(Q.values()),Y=this.#B;if(Y.length!==J.length||JSON.stringify(Y.map((W)=>W.name).sort())!==JSON.stringify(J.map((W)=>W.name).sort()))this.#B=J,this.emit("mcp_tools_changed",this.#B)}async connect($){if(await this.#L(this.initialAgent),!this.#z)this.#P(),this.#z=!0;await this.#$.connect({apiKey:$.apiKey??this.options.apiKey,model:this.options.model,url:$.url,callId:$.callId,initialSessionConfig:await this.#w(this.options.config)}),this.#Y=[],this.emit("history_updated",this.#Y)}updateHistory($){let X;if(typeof $==="function")X=$(this.#Y);else X=$;this.#$.resetHistory(this.#Y,X)}sendMessage($,X={}){this.#$.sendMessage($,X)}addImage($,{triggerResponse:X=!0}={}){this.#$.addImage($,{triggerResponse:X})}mute($){this.#$.mute($)}close(){this.#U={},this.#$.close()}sendAudio($,X={}){this.#$.sendAudio($,X)}interrupt(){this.#$.interrupt()}async approve($,X={alwaysApprove:!1}){this.#Q.approveTool($,X);let Q=$.toolName??$.rawItem.name,J=this.#X.tools.find((Y)=>Y.name===Q);if(J&&J.type==="function"&&$.rawItem.type==="function_call")await this.#F($.rawItem,J);else if($.rawItem.type==="hosted_tool_call"){if(X.alwaysApprove)H6.warn("Always approving MCP tools is not supported. Use the allowed tools configuration instead.");let Y=uI($);this.#$.sendMcpResponse(Y,!0)}else throw new T4(`Tool ${Q??"unknown"} not found`)}async reject($,X={alwaysReject:!1}){this.#Q.rejectTool($,X);let Q=$.toolName??$.rawItem.name,J=this.#X.tools.find((Y)=>Y.name===Q);if(J&&J.type==="function"&&$.rawItem.type==="function_call")await this.#F($.rawItem,J);else if($.rawItem.type==="hosted_tool_call"){if(X.alwaysReject)H6.warn("Always rejecting MCP tools is not supported. Use the allowed tools configuration instead.");let Y=uI($);this.#$.sendMcpResponse(Y,!1)}else throw new T4(`Tool ${Q??"unknown"} not found`)}}W6();W6();W6();W6();W6();W6();W6();W6();W6();W6();W6();W6();W6();W6();var f2$=class{apply($,X){if(!X.type)return;let Q=Array.isArray(X.type)?X.type:[X.type],J=new Set(Q);if(!J.has("string"))$.string=!1;if(!J.has("number")&&!J.has("integer"))$.number=!1;if(!J.has("boolean"))$.boolean=!1;if(!J.has("null"))$.null=!1;if(!J.has("array"))$.array=!1;if(!J.has("object"))$.object=!1;if(J.has("integer")&&$.number!==!1){let Y=$.number||B.number();if(Y instanceof B.ZodNumber)$.number=Y.int()}}},g2$=class{apply($,X){if(X.const===void 0)return;let Q=X.const;if($.string=!1,$.number=!1,$.boolean=!1,$.null=!1,$.array=!1,$.object=!1,typeof Q==="string")$.string=B.literal(Q);else if(typeof Q==="number")$.number=B.literal(Q);else if(typeof Q==="boolean")$.boolean=B.literal(Q);else if(Q===null)$.null=B.null();else if(Array.isArray(Q))$.array=void 0;else if(typeof Q==="object")$.object=void 0}},h2$=class{apply($,X){if(!X.enum)return;if(X.enum.length===0){if(!X.type)$.string=!1,$.number=!1,$.boolean=!1,$.null=!1,$.array=!1,$.object=!1;return}let Q={string:X.enum.filter((J)=>typeof J==="string"),number:X.enum.filter((J)=>typeof J==="number"),boolean:X.enum.filter((J)=>typeof J==="boolean"),null:X.enum.filter((J)=>J===null),array:X.enum.filter((J)=>Array.isArray(J)),object:X.enum.filter((J)=>typeof J==="object"&&J!==null&&!Array.isArray(J))};$.string=this.createTypeSchema(Q.string,"string"),$.number=this.createTypeSchema(Q.number,"number"),$.boolean=this.createTypeSchema(Q.boolean,"boolean"),$.null=Q.null.length>0?B.null():!1,$.array=Q.array.length>0?void 0:!1,$.object=Q.object.length>0?void 0:!1}createTypeSchema($,X){if($.length===0)return!1;if($.length===1)return B.literal($[0]);if(X==="string")return B.enum($);if(X==="number"){let[Q,J,...Y]=$;return B.union([B.literal(Q),B.literal(J),...Y.map((G)=>B.literal(G))])}if(X==="boolean")return B.union([B.literal(!0),B.literal(!1)]);return!1}},u2$=class{apply($,X){let Q=X;if(Q.type==="string"&&Q.format==="binary"&&Q.contentEncoding==="binary"){let J=B.file();if(Q.minLength!==void 0)J=J.min(Q.minLength);if(Q.maxLength!==void 0)J=J.max(Q.maxLength);if(Q.contentMediaType!==void 0)J=J.mime(Q.contentMediaType);$.file=J,$.string=!1}}},m2$=class{apply($,X){let Q=X;if(X.type===void 0&&(Q.minLength!==void 0||Q.maxLength!==void 0||Q.pattern!==void 0)){if($.string===void 0)$.string=B.string()}}},c2$=class{apply($,X){let Q=X;if(Q.minLength===void 0)return;if($.string!==!1){let J=$.string||B.string();if(J instanceof B.ZodString)$.string=J.refine((Y)=>{return Array.from(Y).length>=Q.minLength},{message:`String must be at least ${Q.minLength} characters long`})}}},i2$=class{apply($,X){let Q=X;if(Q.maxLength===void 0)return;if($.string!==!1){let J=$.string||B.string();if(J instanceof B.ZodString)$.string=J.refine((Y)=>{return Array.from(Y).length<=Q.maxLength},{message:`String must be at most ${Q.maxLength} characters long`})}}},l2$=class{apply($,X){let Q=X;if(!Q.pattern)return;if($.string!==!1){let J=$.string||B.string();if(J instanceof B.ZodString){let Y=new RegExp(Q.pattern);$.string=J.regex(Y)}}}},p2$=class{apply($,X){let Q=X;if(Q.minimum===void 0)return;if($.number!==!1){let J=$.number||B.number();if(J instanceof B.ZodNumber)$.number=J.min(Q.minimum)}}},n2$=class{apply($,X){let Q=X;if(Q.maximum===void 0)return;if($.number!==!1){let J=$.number||B.number();if(J instanceof B.ZodNumber)$.number=J.max(Q.maximum)}}},d2$=class{apply($,X){let Q=X;if(Q.exclusiveMinimum===void 0)return;if($.number!==!1){let J=$.number||B.number();if(J instanceof B.ZodNumber)if(typeof Q.exclusiveMinimum==="number")$.number=J.gt(Q.exclusiveMinimum);else $.number=!1}}},a2$=class{apply($,X){let Q=X;if(Q.exclusiveMaximum===void 0)return;if($.number!==!1){let J=$.number||B.number();if(J instanceof B.ZodNumber)if(typeof Q.exclusiveMaximum==="number")$.number=J.lt(Q.exclusiveMaximum);else $.number=!1}}},o2$=class{apply($,X){let Q=X;if(Q.multipleOf===void 0)return;if($.number!==!1){let J=$.number||B.number();if(J instanceof B.ZodNumber)$.number=J.refine((Y)=>{if(Q.multipleOf===0)return!1;let G=Y/Q.multipleOf,W=Math.round(G),K=Math.min(Math.abs(Y)*Number.EPSILON*10,Math.abs(Q.multipleOf)*Number.EPSILON*10);return Math.abs(G-W)<=K/Math.abs(Q.multipleOf)},{message:`Must be a multiple of ${Q.multipleOf}`})}}},r2$=class{apply($,X){let Q=X;if(X.type===void 0&&(Q.minItems!==void 0||Q.maxItems!==void 0||Q.items!==void 0||Q.prefixItems!==void 0)){if($.array===void 0)$.array=B.array(B.any())}}},s2$=class{apply($,X){let Q=X;if(Q.minItems===void 0)return;if($.array!==!1)$.array=($.array||B.array(B.any())).min(Q.minItems)}},t2$=class{apply($,X){let Q=X;if(Q.maxItems===void 0)return;if($.array!==!1)$.array=($.array||B.array(B.any())).max(Q.maxItems)}},e2$=class{apply($,X){let Q=X;if($.array===!1)return;if(Array.isArray(Q.items))$.array=$.array||B.array(B.any());else if(Q.items&&typeof Q.items!=="boolean"&&!Q.prefixItems){let J=k6(Q.items),Y=B.array(J);if($.array&&$.array instanceof B.ZodArray){let G=$.array._def;if(G.checks)G.checks.forEach((W)=>{if(W._zod&&W._zod.def){let K=W._zod.def;if(K.check==="min_length"&&K.minimum!==void 0)Y=Y.min(K.minimum);else if(K.check==="max_length"&&K.maximum!==void 0)Y=Y.max(K.maximum)}})}$.array=Y}else if(typeof Q.items==="boolean"&&Q.items===!1)if(!Q.prefixItems)$.array=B.array(B.any()).max(0);else $.array=$.array||B.array(B.any());else if(typeof Q.items==="boolean"&&Q.items===!0)$.array=$.array||B.array(B.any());else if(Q.prefixItems)$.array=$.array||B.array(B.any())}},$D$=class{apply($,X){if(X.type!=="array")return;let Q=X;if(!Array.isArray(Q.items))return;if($.array===!1)return;let J=Q.items.map((G)=>k6(G)),Y;if(J.length===0)Y=B.tuple([]);else Y=B.tuple(J);if(Q.minItems!==void 0&&Q.minItems>J.length)Y=!1;if(Q.maxItems!==void 0&&Q.maxItems<J.length)Y=!1;$.tuple=Y,$.array=!1}},XD$=class{apply($,X){let Q=X;if($.object===!1)return;if(Q.properties||Q.required||Q.additionalProperties!==void 0)$.object=$.object||B.object({}).passthrough()}},QD$=class{apply($,X){let Q=X;if(X.type===void 0&&(Q.maxProperties!==void 0||Q.minProperties!==void 0)){if($.object===void 0)$.object=B.object({}).passthrough()}}},YD$=class{apply($,X){let Q=X;if(Q.maxProperties===void 0)return;if($.object!==!1){let J=$.object||B.object({}).passthrough();$.object=J.refine((Y)=>Object.keys(Y).length<=Q.maxProperties,{message:`Object must have at most ${Q.maxProperties} properties`})}}},JD$=class{apply($,X){let Q=X;if(Q.minProperties===void 0)return;if($.object!==!1){let J=$.object||B.object({}).passthrough();$.object=J.refine((Y)=>Object.keys(Y).length>=Q.minProperties,{message:`Object must have at least ${Q.minProperties} properties`})}}};function xW($,X){if($===X)return!0;if($==null||X==null)return $===X;if(typeof $!==typeof X)return!1;if(Array.isArray($)&&Array.isArray(X)){if($.length!==X.length)return!1;return $.every((Q,J)=>xW(Q,X[J]))}if(typeof $==="object"&&typeof X==="object"){let Q=Object.keys($),J=Object.keys(X);if(Q.length!==J.length)return!1;return Q.every((Y)=>J.includes(Y)&&xW($[Y],X[Y]))}return!1}function GD$(){return($)=>{if(!Array.isArray($))return!0;let X=[];return $.every((Q)=>{if(X.some((Y)=>xW(Q,Y)))return!1;return X.push(Q),!0})}}function zz($,X){return $.safeParse(X).success}var WD$=class{apply($,X){if(!X.not)return $;let Q=k6(X.not);return $.refine((J)=>!zz(Q,J),{message:"Value must not match the 'not' schema"})}},KD$=class{apply($,X){if(X.uniqueItems!==!0)return $;return $.refine(GD$(),{message:"Array items must be unique"})}},VD$=class{apply($,X){if(!X.allOf||X.allOf.length===0)return $;return X.allOf.map((J)=>k6(J)).reduce((J,Y)=>B.intersection(J,Y),$)}},HD$=class{apply($,X){if(!X.anyOf||X.anyOf.length===0)return $;let Q=X.anyOf.length===1?k6(X.anyOf[0]):B.union([k6(X.anyOf[0]),k6(X.anyOf[1]),...X.anyOf.slice(2).map((J)=>k6(J))]);return B.intersection($,Q)}},UD$=class{apply($,X){if(!X.oneOf||X.oneOf.length===0)return $;let Q=X.oneOf.map((J)=>k6(J));return $.refine((J)=>{let Y=0;for(let G of Q)if(G.safeParse(J).success){if(Y++,Y>1)return!1}return Y===1},{message:"Value must match exactly one of the oneOf schemas"})}},BD$=class{apply($,X){let Q=X;if(Q.prefixItems&&Array.isArray(Q.prefixItems)){let Y=Q.prefixItems.map((G)=>k6(G));return $.refine((G)=>{if(!Array.isArray(G))return!0;for(let W=0;W<Math.min(G.length,Y.length);W++)if(!zz(Y[W],G[W]))return!1;if(G.length>Y.length){if(typeof Q.items==="boolean"&&Q.items===!1)return!1;else if(Q.items&&typeof Q.items==="object"&&!Array.isArray(Q.items)){let W=k6(Q.items);for(let K=Y.length;K<G.length;K++)if(!zz(W,G[K]))return!1}}return!0},{message:"Array does not match prefixItems schema"})}return $}},qD$=class{apply($,X){let Q=X;if(!Q.properties&&!Q.required&&Q.additionalProperties!==!1)return $;if($ instanceof B.ZodObject||$ instanceof B.ZodRecord){let J={};if(Q.properties){for(let[Y,G]of Object.entries(Q.properties))if(G!==void 0)J[Y]=k6(G)}if(Q.required&&Array.isArray(Q.required)){let Y=new Set(Q.required);for(let G of Object.keys(J))if(!Y.has(G))J[G]=J[G].optional()}else for(let Y of Object.keys(J))J[Y]=J[Y].optional();if(Q.additionalProperties===!1)return B.object(J);else return B.object(J).passthrough()}return $.refine((J)=>{if(typeof J!=="object"||J===null||Array.isArray(J))return!0;if(Q.properties){for(let[Y,G]of Object.entries(Q.properties))if(G!==void 0){if(Object.getOwnPropertyDescriptor(J,Y)!==void 0){if(!k6(G).safeParse(J[Y]).success)return!1}}}if(Q.required&&Array.isArray(Q.required)){for(let Y of Q.required)if(Object.getOwnPropertyDescriptor(J,Y)===void 0)return!1}if(Q.additionalProperties===!1&&Q.properties){let Y=new Set(Object.keys(Q.properties));for(let G in J)if(!Y.has(G))return!1}return!0},{message:"Object constraints validation failed"})}},zD$=class{apply($,X){if(!X.enum||X.enum.length===0)return $;let Q=X.enum.filter((J)=>Array.isArray(J)||typeof J==="object"&&J!==null);if(Q.length===0)return $;return $.refine((J)=>{if(typeof J!=="object"||J===null)return!0;return Q.some((Y)=>xW(J,Y))},{message:"Value must match one of the enum values"})}},ND$=class{apply($,X){if(X.const===void 0)return $;let Q=X.const;if(typeof Q!=="object"||Q===null)return $;return $.refine((J)=>xW(J,Q),{message:"Value must equal the const value"})}},DD$=class{apply($,X){if(X.description)$=$.describe(X.description);return $}},LD$=class{apply($,X){var Q;let J=X;if(!((Q=J.required)==null?void 0:Q.includes("__proto__"))||X.type!==void 0)return $;return B.any().refine((Y)=>this.validateRequired(Y,J.required),{message:"Missing required properties"})}validateRequired($,X){if(typeof $!=="object"||$===null||Array.isArray($))return!0;return X.every((Q)=>Object.prototype.hasOwnProperty.call($,Q))}},wD$=class{apply($,X){var Q;let J=X;if(J.contains===void 0)return $;let Y=k6(J.contains),G=(Q=J.minContains)!=null?Q:1,W=J.maxContains;return $.refine((K)=>{if(!Array.isArray(K))return!0;let V=0;for(let H of K)if(zz(Y,H))V++;if(V<G)return!1;if(W!==void 0&&V>W)return!1;return!0},{message:"Array must contain required items matching the schema"})}},FD$=class{apply($,X){let{default:Q}=X;if(Q===void 0)return $;if(!$.safeParse(Q).success)return $;return $.default(Q)}},ZD$=[new g2$,new h2$,new f2$,new u2$,new m2$,new r2$,new QD$,new c2$,new i2$,new l2$,new p2$,new n2$,new d2$,new a2$,new o2$,new $D$,new s2$,new t2$,new e2$,new YD$,new JD$,new XD$],OD$=[new LD$,new zD$,new ND$,new VD$,new HD$,new UD$,new BD$,new qD$,new wD$,new WD$,new KD$,new FD$,new DD$];function k6($){if(typeof $==="boolean")return $?B.any():B.never();let X={};for(let Y of ZD$)Y.apply(X,$);let Q=[];if(X.string!==!1)Q.push(X.string||B.string());if(X.number!==!1)Q.push(X.number||B.number());if(X.boolean!==!1)Q.push(X.boolean||B.boolean());if(X.null!==!1)Q.push(X.null||B.null());if(X.array!==!1)Q.push(X.array||B.array(B.any()));if(X.tuple!==!1&&X.tuple!==void 0)Q.push(X.tuple);if(X.object!==!1)if(X.object)Q.push(X.object);else{let Y=B.custom((G)=>{return typeof G==="object"&&G!==null&&!Array.isArray(G)},"Must be an object, not an array");Q.push(Y)}if(X.file!==!1&&X.file!==void 0)Q.push(X.file);let J;if(Q.length===0)J=B.never();else if(Q.length===1)J=Q[0];else if(!Object.keys($).some((G)=>G!=="$schema"&&G!=="title"&&G!=="description"))J=B.any();else J=B.union(Q);for(let Y of OD$)J=Y.apply(J,$);return J}var I5=require("react/jsx-runtime"),MD$=({data:$,setUiAjaxConfiguration:X})=>{let{name:Q,titles:J,instructions:Y,tools:G,token:W,autoStart:K,muted:V,language:H,outputModalities:U,sxMap:q,iconUrl:z,iconPosition:L,useSocketioSupport:D,useCentrifugeSupport:N,useMittSupport:w,centrifugeChannel:Z}=$,{apiServer:O,enableRenderingLog:F}=w9(),[M,A]=C6.useState(null),[v,T]=C6.useState(null),[R,h]=C6.useState(null),[J$,B$]=C6.useState(!1),[_$,s]=C6.useState([]),[,E$]=C6.useState(null),S$=C6.useRef(null),g=C6.useMemo(()=>{return G.map((c)=>{let q$=A2(X??(()=>{}),c.kwargs,c.depsNames,c.pathname,{apiServer:O,renderingLogEnabled:F});return Q9({name:c.name,description:c.description,parameters:k6(c.params),async execute(N4){console.log(`Calling tool: ${c.name} with: ${JSON.stringify(N4)}`);let L$=await q$(N4);if(!Array.isArray(L$))return[];return L$.filter((M$)=>M$.name===`pietoolOutput_${Q}`).map((M$)=>M$.data.output)}})})},[G,X]),r=()=>{if(console.log("Disconnecting session..."),v)v.close();T(null),A(null),B$(!1)},K$=async(c)=>{if(!v){console.error("Session not initialized");return}if(J$){console.log("Already connected, skipping...");return}try{v.on("history_updated",(q$)=>{s(q$)}),console.log("Connecting to session..."),E$(null),await v.connect({apiKey:c}),B$(!0),console.log("Connected successfully")}catch(q$){console.error("Failed to connect to session:",q$),E$(q$ instanceof Error?q$.message:"Failed to connect"),B$(!1)}};return C6.useEffect(()=>{if(!S$.current)return;if(!R)navigator.mediaDevices.getUserMedia({audio:!0}).then(async(c)=>{h(new AQ({mediaStream:c,audioElement:S$.current}))})},[S$]),C6.useEffect(()=>{if(!S$.current)return;if(!R)return;if(M===null||v===null){let c=new sq({name:Q,instructions:Y,tools:g}),q$=new TQ(c,{model:"gpt-realtime",transport:R,config:{outputModalities:U,audio:{input:{transcription:{language:H??void 0,model:"gpt-4o-mini-transcribe"}}},inputAudioTranscription:{language:H??void 0,model:"gpt-4o-mini-transcribe"}}});A(c),T(q$)}},[M,v,Q,Y,g,S$,R]),C6.useEffect(()=>{if(M!==null&&v!==null&&K&&W&&!J$)console.log("Auto-connecting..."),K$(W).catch((c)=>{console.error("Auto-connection failed:",c)})},[M,v]),C6.useEffect(()=>{return()=>{console.log("Disconnecting..."),r()}},[]),I5.jsxs(z4,{card:"VoiceAgentCard",data:$,methods:{initializeAI:async(c)=>{if(M!==null&&v!==null&&c.token&&!J$)console.log("Connecting via initialize event..."),await K$(c.token).catch((q$)=>{console.error("Auto-connection failed:",q$)})},stop:()=>{r()}},useCentrifugeSupport:N,useSocketioSupport:D,useMittSupport:w,centrifugeChannel:Z,children:[I5.jsxs("button",{id:Q,value:Q,onClick:async()=>{if(J$)r();else if(W)await K$(W)},style:J$?q.enabled:q.disabled,type:"button",children:[z&&L==="start"&&I5.jsx("img",{src:z,alt:""}),X0(J$?J.enabled:J.disabled),z&&L==="end"&&I5.jsx("img",{src:z,alt:""})]}),I5.jsx("input",{type:"hidden",name:Q,value:JSON.stringify(_$)}),I5.jsx("audio",{ref:S$,autoPlay:!0,muted:V,style:{display:"none"}})]})},Nz=MD$;var x5=require("react");var Kx=({data:$})=>{return X0($)};var Kr=require("react");var Vr=require("react/jsx-runtime"),Vx=({data:$,setUiAjaxConfiguration:X})=>{let Q=Kr.useContext(j6)??M4;return Vr.jsx(Q,{uiConfig:$,setUiAjaxConfiguration:X})};var Y1=require("react/jsx-runtime"),AD$=({name:$,headers:X,rows:Q,rowUrls:J,selected:Y,columnHeights:G,sx:W,sxMap:K,setUiAjaxConfiguration:V})=>{let H=x5.useContext(_4),U=(N,w)=>Array(N.length*w).fill(0).map((Z,O)=>N[O%N.length]),q=X.map((N)=>N.length),z=q.reduce((N,w)=>N*w,1),L=q.map((N,w)=>Math.floor(z/q.slice(0,w+1).reduce((Z,O)=>Z*O,1))),D=X.map((N,w)=>{return U(N,q.slice(0,w).reduce((Z,O)=>Z*O,1))});return Y1.jsxs("table",{id:$,className:"w-full table-auto border-collapse overflow-hidden text-left",style:{...K?.table,...W},children:[Y1.jsx("thead",{className:"bg-gray-100",children:D.map((N,w)=>Y1.jsx("tr",{className:"border-none",style:K?.row,children:N.map((Z,O)=>Y1.jsx("th",{colSpan:L[w],className:"border border-gray-200 px-4 py-2 text-gray-500",style:{width:G?G[O]:"auto",...K?.cell},children:typeof Z==="string"?Y1.jsx(Kx,{data:Z,setUiAjaxConfiguration:V}):Y1.jsx(Vx,{data:Z,setUiAjaxConfiguration:V})},O))},w))}),Y1.jsx("tbody",{children:Q.map((N,w)=>Y1.jsx("tr",{className:`border border-gray-200 bg-white ${J&&J[w]?"cursor-pointer":""} ${Y&&Y[w]?"bg-gray-200":""}`,style:K?.row,children:N.map((Z,O)=>Y1.jsx("td",{onClick:()=>{if(typeof Z==="string"&&J&&J[w])if(J[w].startsWith("http"))window.location.href=J[w];else H?.(J[w])},className:"border border-gray-200 px-4 py-2 text-gray-900",style:{width:G?G[O]:"auto",...K?.cell},children:typeof Z==="string"?Y1.jsx(Kx,{data:Z,setUiAjaxConfiguration:V}):Y1.jsx(Vx,{data:Z,setUiAjaxConfiguration:V})},O))},w))})]})},jD$=({data:$,setUiAjaxConfiguration:X})=>{let{name:Q,headers:J,rows:Y,rowUrls:G,sx:W,sxMap:K,useSocketioSupport:V,useCentrifugeSupport:H,useMittSupport:U,centrifugeChannel:q}=$,[z,L]=x5.useState([]),[D,N]=x5.useState([]);return x5.useEffect(()=>{L(Y)},[Y]),x5.useEffect(()=>{N(G)},[G]),Y1.jsx(z4,{card:"TableCard",data:$,methods:{addrow:(M)=>{L((A)=>[...A,M.row]),N((A)=>[...A,M.url??null])},insertrow:(M)=>{L((A)=>[...A.slice(0,M.idx),M.row,...A.slice(M.idx)]),N((A)=>[...A.slice(0,M.idx),M.url??null,...A.slice(M.idx)])},delrow:(M)=>{L((A)=>[...A.slice(0,M.idx),...A.slice(M.idx+1)]),N((A)=>[...A.slice(0,M.idx),...A.slice(M.idx+1)])},clear:()=>{L(()=>[]),N(()=>[])}},useSocketioSupport:V,useCentrifugeSupport:H,useMittSupport:U,centrifugeChannel:q,children:Y1.jsx(AD$,{name:Q,rows:z,rowUrls:D,headers:J,setUiAjaxConfiguration:X,sx:W,sxMap:K})})},Hx=jD$;var Ux=require("react");var Dz=require("react/jsx-runtime"),PD$=({data:$,content:X,setUiAjaxConfiguration:Q})=>{let{name:J,url:Y,sx:G}=$,W=Ux.useContext(_4),K=Ux.useContext(j6)??M4;return Dz.jsx(z4,{card:J,data:$,children:Dz.jsx("div",{style:G,id:J,onClick:(H)=>{if(Y)if(H.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(Y))window.location.href=Y;else W?.(Y)},children:Dz.jsx(K,{setUiAjaxConfiguration:Q,uiConfig:X})})})},Bx=PD$;var qx=!1;function R1(){if(qx)return;M6({name:"SequenceCard",component:Xk,metadata:{author:"PieData",description:"Simple div with styles joining few components"}}),M6({name:"BoxCard",component:Bx,metadata:{author:"PieData",description:"Simple div with styles joining few components"}}),M6({name:"UnionCard",component:Yk,metadata:{author:"PieData",description:"Renders one of many components"}}),M6({name:"AjaxGroupCard",component:Jk,metadata:{author:"PieData",description:"Group card with AJAX support"}}),M6({name:"AjaxButtonCard",component:aC,metadata:{author:"PieData",description:"Button with AJAX support"}}),M6({name:"RedirectButtonCard",component:iD,metadata:{author:"PieData",description:"Button with Redirect on click"}}),M6({name:"ChatCard",component:Uy,metadata:{author:"PieData"}}),M6({name:"HiddenCard",component:SD,metadata:{author:"PieData"}}),M6({name:"AutoRedirectCard",component:kD,metadata:{author:"PieData"}}),M6({name:"HTMLEmbedCard",component:CD,metadata:{author:"PieData"}}),M6({name:"IOEventsCard",component:cD,metadata:{author:"PieData"}}),M6({name:"OpenAIVoiceAgentCard",component:Nz,metadata:{author:"PieData"}}),M6({name:"TableCard",component:Hx,metadata:{author:"PieData"}}),qx=!0}function j4(){return qx}var Hr=require("react/jsx-runtime");function _8($,X,Q){if(!X)return Q;let J=$.replace(/^\//,""),Y=X[J];if(!Y)return Q;return Hr.jsx(kW,{uiConfig:Y})}var y6=require("react/jsx-runtime"),vD$=({location:$,fallback:X,piecache:Q,onError:J,initializePie:Y,queryOptions:G})=>{let W=A6(),K=d1(),V=t4();R5.useEffect(()=>{if(j4())return;R1(),Y()},[]);let H=R5.useMemo(()=>Ur.createAxiosDateTransformer({baseURL:W||""}),[W]),U=R5.useMemo(()=>a1(),[]),q=R5.useMemo(()=>W?r1(W):null,[W]),z=R5.useMemo(()=>W?s1(W,K):null,[W,K]),{data:L,isLoading:D,error:N}=bQ.useQuery({queryKey:["uiConfig",$.pathname+$.search,j4(),W],enabled:j4()&&!!W,queryFn:async()=>{let Z=new URLSearchParams($.search);Z.set("__pieroot","web");let O="/api/content"+$.pathname+"?"+Z.toString();if(V)console.log("[PieRoot] Fetching UI configuration from:",O);let F=await H.get(O,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(V)console.log("[PieRoot] Received UI configuration:",F.data);return F.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Z)=>Math.min(1000*2**Z,30000),...G}),w=_8($.pathname,Q,X);if(!W)return w??null;if(V)console.log("[PieRoot] Rendering with location:",$),console.log("[PieRoot] API_SERVER:",W),console.log("[PieRoot] CENTRIFUGE_SERVER:",K),console.log("[PieRoot] Fallback provided:",!!X),console.log("[PieRoot] Piecache provided:",!!Q);if(N){if(V)console.error("[PieRoot] Error fetching UI configuration:",N),console.error("[PieRoot] Error details:",{message:N.message,status:N.response?.status,data:N.response?.data});return J?.(),w}if(D||!L){if(V)console.log("[PieRoot] Loading state:",{isLoading:D,hasUiConfiguration:!!L});return w}if(V)console.log("[PieRoot] UI configuration loaded successfully:",L),console.log("[PieRoot] Rendering UI with configuration");return y6.jsx(P6.Provider,{value:U,children:y6.jsx(v6.Provider,{value:q,children:y6.jsx(x6.Provider,{value:z,children:y6.jsx(s4.Provider,{value:X??y6.jsx(y6.Fragment,{}),children:y6.jsx(t1,{children:y6.jsx(e1,{children:y6.jsx("form",{id:"piedata_global_form",action:W+"api/process"+$.pathname,method:"post",encType:"multipart/form-data",children:y6.jsx(M4,{uiConfig:L})})})})})})})})},ID$=($)=>{let X=R5.useMemo(()=>new bQ.QueryClient,[]);return y6.jsx(_4.Provider,{value:$.onNavigate,children:y6.jsx(_1.Provider,{value:$.config,children:y6.jsx(bQ.QueryClientProvider,{client:X,children:y6.jsx(vD$,{...$})})})})},Br=ID$;var _5=require("react"),SQ=require("@tanstack/react-query");var zr=V$(AX());var Lz=require("react");var qr=()=>{let[$,X]=Lz.useState(null),Q=jx();return Lz.useEffect(()=>{if(typeof window==="undefined")return;let J=window.Telegram.WebApp;if(J.ready(),Q==="telegram_expanded"&&(J.platform==="ios"||J.platform==="android"))J.expand();X(J)},[]),$};var f6=require("react/jsx-runtime"),xD$=({location:$,fallback:X,piecache:Q,onError:J,initializePie:Y,queryOptions:G})=>{let W=A6(),K=d1(),V=t4();_5.useEffect(()=>{if(j4())return;R1(),Y()},[]);let H=_5.useMemo(()=>zr.createAxiosDateTransformer({baseURL:W}),[W]),U=_5.useMemo(()=>a1(),[]),q=_5.useMemo(()=>W?r1(W):null,[W]),z=_5.useMemo(()=>W?s1(W,K):null,[W,K]),L=qr(),{data:D,isLoading:N,error:w}=SQ.useQuery({queryKey:["uiConfig",$.pathname+$.search,L?.initData,j4()],enabled:j4()&&!!L?.initData,queryFn:async()=>{let O=new URLSearchParams($.search);if(O.set("__pieroot","telegram"),L?.initData)O.set("initData",L.initData);let F="/api/content"+$.pathname+"?"+O.toString();if(V)console.log("[PieRoot] Fetching UI configuration from:",F);let M=await H.get(F,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(V)console.log("[PieRoot] Received UI configuration:",M.data);return M.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(O)=>Math.min(1000*2**O,30000),...G}),Z=_8($.pathname,Q,X);if(!W)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(w&&V)return console.error("[PieRoot] Error fetching UI configuration:",w),console.error("[PieRoot] Error details:",{message:w.message,status:w.response?.status,data:w.response?.data}),J?.(),Z;if(N||!D){if(V)console.log("[PieRoot] Loading state:",{isLoading:N,hasUiConfiguration:!!D});return Z}if(V)console.log("[PieRoot] UI configuration loaded successfully:",D),console.log("[PieRoot] Rendering UI with configuration");return f6.jsx(P6.Provider,{value:U,children:f6.jsx(v6.Provider,{value:q,children:f6.jsx(x6.Provider,{value:z,children:f6.jsx(s4.Provider,{value:X??f6.jsx(f6.Fragment,{}),children:f6.jsx(t1,{children:f6.jsx(e1,{children:f6.jsx("form",{id:"piedata_global_form",action:W+"api/process"+$.pathname,method:"post",encType:"multipart/form-data",children:f6.jsx(M4,{uiConfig:D})})})})})})})})},RD$=($)=>{let X=_5.useMemo(()=>new SQ.QueryClient,[]);return f6.jsx(_4.Provider,{value:$.onNavigate,children:f6.jsx(_1.Provider,{value:$.config,children:f6.jsx(SQ.QueryClientProvider,{client:X,children:f6.jsx(xD$,{...$})})})})},Nr=RD$;var r7=require("react"),wz=require("@tanstack/react-query");var J1=require("react/jsx-runtime"),_D$=({location:$,fallback:X,initializePie:Q,children:J})=>{let Y=A6(),G=d1(),W=t4();r7.useEffect(()=>{if(j4())return;R1(),Q()},[]);let K=r7.useMemo(()=>a1(),[]),V=r7.useMemo(()=>Y?r1(Y):null,[Y]),H=r7.useMemo(()=>Y?s1(Y,G):null,[Y,G]);if(W)console.log("[PieRoot] Rendering with location:",$),console.log("[PieRoot] API_SERVER:",Y),console.log("[PieRoot] CENTRIFUGE_SERVER:",G),console.log("[PieRoot] Fallback provided:",!!X);return J1.jsx(P6.Provider,{value:K,children:J1.jsx(v6.Provider,{value:V,children:J1.jsx(x6.Provider,{value:H,children:J1.jsx(s4.Provider,{value:X??J1.jsx(J1.Fragment,{}),children:J1.jsx(t1,{children:J1.jsx(e1,{children:J1.jsx("form",{id:"piedata_global_form",action:Y+"api/process"+$.pathname,method:"post",encType:"multipart/form-data",children:J})})})})})})})},ED$=($)=>{let X=r7.useMemo(()=>new wz.QueryClient,[]);return J1.jsx(_4.Provider,{value:$.onNavigate,children:J1.jsx(_1.Provider,{value:$.config,children:J1.jsx(wz.QueryClientProvider,{client:X,children:J1.jsx(_D$,{...$})})})})},Dr=ED$;var E5=require("react"),kQ=require("@tanstack/react-query");var wr=V$(AX());var Fz=require("react"),Lr=()=>{let[$,X]=Fz.useState(null);return Fz.useEffect(()=>{if(typeof window==="undefined")return;let Q=window.WebApp;if(!Q)return;Q.ready(),X(Q)},[]),$};var g6=require("react/jsx-runtime"),TD$=({location:$,fallback:X,piecache:Q,onError:J,initializePie:Y,queryOptions:G})=>{let W=A6(),K=d1(),V=t4();E5.useEffect(()=>{if(j4())return;R1(),Y()},[]);let H=E5.useMemo(()=>wr.createAxiosDateTransformer({baseURL:W}),[W]),U=E5.useMemo(()=>a1(),[]),q=E5.useMemo(()=>W?r1(W):null,[W]),z=E5.useMemo(()=>W?s1(W,K):null,[W,K]),L=Lr(),{data:D,isLoading:N,error:w}=kQ.useQuery({queryKey:["uiConfig",$.pathname+$.search,L?.initData,j4()],queryFn:async()=>{let O=new URLSearchParams($.search);if(O.set("__pieroot","max"),L?.initData)O.set("initData",L.initData);let F="/api/content"+$.pathname+"?"+O.toString();if(V)console.log("[PieRoot] Fetching UI configuration from:",F);let M=await H.get(F,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(V)console.log("[PieRoot] Received UI configuration:",M.data);return M.data},enabled:j4()&&!!L?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(O)=>Math.min(1000*2**O,30000),...G}),Z=_8($.pathname,Q,X);if(!W)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(w&&V)return console.error("[PieRoot] Error fetching UI configuration:",w),console.error("[PieRoot] Error details:",{message:w.message,status:w.response?.status,data:w.response?.data}),J?.(),Z;if(N||!D){if(V)console.log("[PieRoot] Loading state:",{isLoading:N,hasUiConfiguration:!!D});return Z}if(V)console.log("[PieRoot] UI configuration loaded successfully:",D),console.log("[PieRoot] Rendering UI with configuration");return g6.jsx(P6.Provider,{value:U,children:g6.jsx(v6.Provider,{value:q,children:g6.jsx(x6.Provider,{value:z,children:g6.jsx(s4.Provider,{value:X??g6.jsx(g6.Fragment,{}),children:g6.jsx(t1,{children:g6.jsx(e1,{children:g6.jsx("form",{id:"piedata_global_form",action:W+"api/process"+$.pathname,method:"post",encType:"multipart/form-data",children:g6.jsx(M4,{uiConfig:D})})})})})})})})},bD$=($)=>{let X=E5.useMemo(()=>new kQ.QueryClient,[]);return g6.jsx(_4.Provider,{value:$.onNavigate,children:g6.jsx(_1.Provider,{value:$.config,children:g6.jsx(kQ.QueryClientProvider,{client:X,children:g6.jsx(TD$,{...$})})})})},Fr=bD$;var T5=require("react"),CQ=require("@tanstack/react-query");var Zr=V$(AX());var h6=require("react/jsx-runtime"),SD$=({location:$,fallback:X,piecache:Q,onError:J,initializePie:Y,queryOptions:G})=>{let W=A6(),K=d1(),V=t4();T5.useEffect(()=>{if(j4())return;R1(),Y()},[]);let H=T5.useMemo(()=>Zr.createAxiosDateTransformer({baseURL:W||""}),[W]),U=T5.useMemo(()=>a1(),[]),q=T5.useMemo(()=>W?r1(W):null,[W]),z=T5.useMemo(()=>W?s1(W,K):null,[W,K]),{data:L,isLoading:D,error:N}=CQ.useQuery({queryKey:["uiConfig",$.pathname+$.search,j4(),W],enabled:j4()&&!!W,queryFn:async()=>{let Z=new URLSearchParams($.search);Z.set("__pieroot","electron");let O="/api/content"+$.pathname+"?"+Z.toString();if(V)console.log("[PieElectronRoot] Fetching UI configuration from:",O);let F=await H.get(O,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(V)console.log("[PieElectronRoot] Received UI configuration:",F.data);return F.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Z)=>Math.min(1000*2**Z,30000),...G}),w=_8($.pathname,Q,X);if(!W)return w??null;if(V)console.log("[PieElectronRoot] Rendering with location:",$),console.log("[PieElectronRoot] API_SERVER:",W),console.log("[PieElectronRoot] CENTRIFUGE_SERVER:",K),console.log("[PieElectronRoot] Fallback provided:",!!X),console.log("[PieElectronRoot] Piecache provided:",!!Q);if(N){if(V)console.error("[PieElectronRoot] Error fetching UI configuration:",N),console.error("[PieElectronRoot] Error details:",{message:N.message,status:N.response?.status,data:N.response?.data});return J?.(),w}if(D||!L){if(V)console.log("[PieElectronRoot] Loading state:",{isLoading:D,hasUiConfiguration:!!L});return w}if(V)console.log("[PieElectronRoot] UI configuration loaded successfully:",L),console.log("[PieElectronRoot] Rendering UI with configuration");return h6.jsx(P6.Provider,{value:U,children:h6.jsx(v6.Provider,{value:q,children:h6.jsx(x6.Provider,{value:z,children:h6.jsx(s4.Provider,{value:X??h6.jsx(h6.Fragment,{}),children:h6.jsx(t1,{children:h6.jsx(e1,{children:h6.jsx("form",{id:"piedata_global_form",action:W+"api/process"+$.pathname,method:"post",encType:"multipart/form-data",children:h6.jsx(M4,{uiConfig:L})})})})})})})})},kD$=($)=>{let X=T5.useMemo(()=>new CQ.QueryClient,[]);return h6.jsx(_4.Provider,{value:$.onNavigate,children:h6.jsx(_1.Provider,{value:$.config,children:h6.jsx(CQ.QueryClientProvider,{client:X,children:h6.jsx(SD$,{...$})})})})},Or=kD$;var b5=require("react"),yQ=require("@tanstack/react-query");var Mr=V$(AX());var G1=require("react/jsx-runtime"),CD$=({location:$,fallback:X,piecache:Q,onError:J,initializePie:Y,queryOptions:G})=>{let W=A6(),K=d1(),V=t4();b5.useEffect(()=>{if(j4())return;R1(),Y()},[]);let H=b5.useMemo(()=>Mr.createAxiosDateTransformer({baseURL:W||""}),[W]),U=b5.useMemo(()=>a1(),[]),q=b5.useMemo(()=>W?r1(W):null,[W]),z=b5.useMemo(()=>W?s1(W,K):null,[W,K]),{data:L,isLoading:D,error:N}=yQ.useQuery({queryKey:["uiConfig",$.pathname+$.search,j4(),W],enabled:j4()&&!!W,queryFn:async()=>{let Z=new URLSearchParams($.search);Z.set("__pieroot","expo");let O="/api/content"+$.pathname+"?"+Z.toString();if(V)console.log("[PieExpoRoot] Fetching UI configuration from:",O);let F=await H.get(O,{headers:{"Content-type":"application/json"}});if(V)console.log("[PieExpoRoot] Received UI configuration:",F.data);return F.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Z)=>Math.min(1000*2**Z,30000),...G}),w=_8($.pathname,Q,X);if(!W)return w??null;if(V)console.log("[PieExpoRoot] Rendering with location:",$),console.log("[PieExpoRoot] API_SERVER:",W),console.log("[PieExpoRoot] CENTRIFUGE_SERVER:",K),console.log("[PieExpoRoot] Fallback provided:",!!X),console.log("[PieExpoRoot] Piecache provided:",!!Q);if(N){if(V)console.error("[PieExpoRoot] Error fetching UI configuration:",N),console.error("[PieExpoRoot] Error details:",{message:N.message,status:N.response?.status,data:N.response?.data});return J?.(),w}if(D||!L){if(V)console.log("[PieExpoRoot] Loading state:",{isLoading:D,hasUiConfiguration:!!L});return w}if(V)console.log("[PieExpoRoot] UI configuration loaded successfully:",L),console.log("[PieExpoRoot] Rendering UI with configuration");return G1.jsx(P6.Provider,{value:U,children:G1.jsx(v6.Provider,{value:q,children:G1.jsx(x6.Provider,{value:z,children:G1.jsx(s4.Provider,{value:X??G1.jsx(G1.Fragment,{}),children:G1.jsx(t1,{children:G1.jsx(e1,{children:G1.jsx(M4,{uiConfig:L})})})})})})})},yD$=($)=>{let X=b5.useMemo(()=>new yQ.QueryClient,[]);return G1.jsx(_4.Provider,{value:$.onNavigate,children:G1.jsx(_1.Provider,{value:$.config,children:G1.jsx(yQ.QueryClientProvider,{client:X,children:G1.jsx(CD$,{...$})})})})},Ar=yD$;function jr($){if(!$)return{};return{...$}}var fD$=($,X)=>{let Q=new Array($.length+X.length);for(let J=0;J<$.length;J++)Q[J]=$[J];for(let J=0;J<X.length;J++)Q[$.length+J]=X[J];return Q},gD$=($,X)=>({classGroupId:$,validator:X}),_r=($=new Map,X=null,Q)=>({nextPart:$,validators:X,classGroupId:Q});var Pr=[];var hD$=($)=>{let X=mD$($),{conflictingClassGroups:Q,conflictingClassGroupModifiers:J}=$;return{getClassGroupId:(W)=>{if(W.startsWith("[")&&W.endsWith("]"))return uD$(W);let K=W.split("-"),V=K[0]===""&&K.length>1?1:0;return Er(K,V,X)},getConflictingClassGroupIds:(W,K)=>{if(K){let V=J[W],H=Q[W];if(V){if(H)return fD$(H,V);return V}return H||Pr}return Q[W]||Pr}}},Er=($,X,Q)=>{if($.length-X===0)return Q.classGroupId;let Y=$[X],G=Q.nextPart.get(Y);if(G){let H=Er($,X+1,G);if(H)return H}let W=Q.validators;if(W===null)return;let K=X===0?$.join("-"):$.slice(X).join("-"),V=W.length;for(let H=0;H<V;H++){let U=W[H];if(U.validator(K))return U.classGroupId}return},uD$=($)=>$.slice(1,-1).indexOf(":")===-1?void 0:(()=>{let X=$.slice(1,-1),Q=X.indexOf(":"),J=X.slice(0,Q);return J?"arbitrary.."+J:void 0})(),mD$=($)=>{let{theme:X,classGroups:Q}=$;return cD$(Q,X)},cD$=($,X)=>{let Q=_r();for(let J in $){let Y=$[J];Nx(Y,Q,J,X)}return Q},Nx=($,X,Q,J)=>{let Y=$.length;for(let G=0;G<Y;G++){let W=$[G];iD$(W,X,Q,J)}},iD$=($,X,Q,J)=>{if(typeof $==="string"){lD$($,X,Q);return}if(typeof $==="function"){pD$($,X,Q,J);return}nD$($,X,Q,J)},lD$=($,X,Q)=>{let J=$===""?X:Tr(X,$);J.classGroupId=Q},pD$=($,X,Q,J)=>{if(dD$($)){Nx($(J),X,Q,J);return}if(X.validators===null)X.validators=[];X.validators.push(gD$(Q,$))},nD$=($,X,Q,J)=>{let Y=Object.entries($),G=Y.length;for(let W=0;W<G;W++){let[K,V]=Y[W];Nx(V,Tr(X,K),Q,J)}},Tr=($,X)=>{let Q=$,J=X.split("-"),Y=J.length;for(let G=0;G<Y;G++){let W=J[G],K=Q.nextPart.get(W);if(!K)K=_r(),Q.nextPart.set(W,K);Q=K}return Q},dD$=($)=>("isThemeGetter"in $)&&$.isThemeGetter===!0,aD$=($)=>{if($<1)return{get:()=>{return},set:()=>{}};let X=0,Q=Object.create(null),J=Object.create(null),Y=(G,W)=>{if(Q[G]=W,X++,X>$)X=0,J=Q,Q=Object.create(null)};return{get(G){let W=Q[G];if(W!==void 0)return W;if((W=J[G])!==void 0)return Y(G,W),W},set(G,W){if(G in Q)Q[G]=W;else Y(G,W)}}};var oD$=[],vr=($,X,Q,J,Y)=>({modifiers:$,hasImportantModifier:X,baseClassName:Q,maybePostfixModifierPosition:J,isExternal:Y}),rD$=($)=>{let{prefix:X,experimentalParseClassName:Q}=$,J=(Y)=>{let G=[],W=0,K=0,V=0,H,U=Y.length;for(let N=0;N<U;N++){let w=Y[N];if(W===0&&K===0){if(w===":"){G.push(Y.slice(V,N)),V=N+1;continue}if(w==="/"){H=N;continue}}if(w==="[")W++;else if(w==="]")W--;else if(w==="(")K++;else if(w===")")K--}let q=G.length===0?Y:Y.slice(V),z=q,L=!1;if(q.endsWith("!"))z=q.slice(0,-1),L=!0;else if(q.startsWith("!"))z=q.slice(1),L=!0;let D=H&&H>V?H-V:void 0;return vr(G,L,z,D)};if(X){let Y=X+":",G=J;J=(W)=>W.startsWith(Y)?G(W.slice(Y.length)):vr(oD$,!1,W,void 0,!0)}if(Q){let Y=J;J=(G)=>Q({className:G,parseClassName:Y})}return J},sD$=($)=>{let X=new Map;return $.orderSensitiveModifiers.forEach((Q,J)=>{X.set(Q,1e6+J)}),(Q)=>{let J=[],Y=[];for(let G=0;G<Q.length;G++){let W=Q[G],K=W[0]==="[",V=X.has(W);if(K||V){if(Y.length>0)Y.sort(),J.push(...Y),Y=[];J.push(W)}else Y.push(W)}if(Y.length>0)Y.sort(),J.push(...Y);return J}},tD$=($)=>({cache:aD$($.cacheSize),parseClassName:rD$($),sortModifiers:sD$($),...hD$($)}),eD$=/\s+/,$L$=($,X)=>{let{parseClassName:Q,getClassGroupId:J,getConflictingClassGroupIds:Y,sortModifiers:G}=X,W=[],K=$.trim().split(eD$),V="";for(let H=K.length-1;H>=0;H-=1){let U=K[H],{isExternal:q,modifiers:z,hasImportantModifier:L,baseClassName:D,maybePostfixModifierPosition:N}=Q(U);if(q){V=U+(V.length>0?" "+V:V);continue}let w=!!N,Z=J(w?D.substring(0,N):D);if(!Z){if(!w){V=U+(V.length>0?" "+V:V);continue}if(Z=J(D),!Z){V=U+(V.length>0?" "+V:V);continue}w=!1}let O=z.length===0?"":z.length===1?z[0]:G(z).join(":"),F=L?O+"!":O,M=F+Z;if(W.indexOf(M)>-1)continue;W.push(M);let A=Y(Z,w);for(let v=0;v<A.length;++v){let T=A[v];W.push(F+T)}V=U+(V.length>0?" "+V:V)}return V},XL$=(...$)=>{let X=0,Q,J,Y="";while(X<$.length)if(Q=$[X++]){if(J=br(Q))Y&&(Y+=" "),Y+=J}return Y},br=($)=>{if(typeof $==="string")return $;let X,Q="";for(let J=0;J<$.length;J++)if($[J]){if(X=br($[J]))Q&&(Q+=" "),Q+=X}return Q},QL$=($,...X)=>{let Q,J,Y,G,W=(V)=>{let H=X.reduce((U,q)=>q(U),$());return Q=tD$(H),J=Q.cache.get,Y=Q.cache.set,G=K,K(V)},K=(V)=>{let H=J(V);if(H)return H;let U=$L$(V,Q);return Y(V,U),U};return G=W,(...V)=>G(XL$(...V))},YL$=[],r4=($)=>{let X=(Q)=>Q[$]||YL$;return X.isThemeGetter=!0,X},Sr=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,kr=/^\((?:(\w[\w-]*):)?(.+)\)$/i,JL$=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,GL$=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,WL$=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,KL$=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,VL$=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,HL$=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,S5=($)=>JL$.test($),b$=($)=>!!$&&!Number.isNaN(Number($)),k5=($)=>!!$&&Number.isInteger(Number($)),zx=($)=>$.endsWith("%")&&b$($.slice(0,-1)),D9=($)=>GL$.test($),Cr=()=>!0,UL$=($)=>WL$.test($)&&!KL$.test($),Dx=()=>!1,BL$=($)=>VL$.test($),qL$=($)=>HL$.test($),zL$=($)=>!t($)&&!e($),NL$=($)=>C5($,gr,Dx),t=($)=>Sr.test($),s7=($)=>C5($,hr,UL$),Ir=($)=>C5($,AL$,b$),DL$=($)=>C5($,mr,Cr),LL$=($)=>C5($,ur,Dx),xr=($)=>C5($,yr,Dx),wL$=($)=>C5($,fr,qL$),Zz=($)=>C5($,cr,BL$),e=($)=>kr.test($),RW=($)=>t7($,hr),FL$=($)=>t7($,ur),Rr=($)=>t7($,yr),ZL$=($)=>t7($,gr),OL$=($)=>t7($,fr),Oz=($)=>t7($,cr,!0),ML$=($)=>t7($,mr,!0),C5=($,X,Q)=>{let J=Sr.exec($);if(J){if(J[1])return X(J[1]);return Q(J[2])}return!1},t7=($,X,Q=!1)=>{let J=kr.exec($);if(J){if(J[1])return X(J[1]);return Q}return!1},yr=($)=>$==="position"||$==="percentage",fr=($)=>$==="image"||$==="url",gr=($)=>$==="length"||$==="size"||$==="bg-size",hr=($)=>$==="length",AL$=($)=>$==="number",ur=($)=>$==="family-name",mr=($)=>$==="number"||$==="weight",cr=($)=>$==="shadow";var jL$=()=>{let $=r4("color"),X=r4("font"),Q=r4("text"),J=r4("font-weight"),Y=r4("tracking"),G=r4("leading"),W=r4("breakpoint"),K=r4("container"),V=r4("spacing"),H=r4("radius"),U=r4("shadow"),q=r4("inset-shadow"),z=r4("text-shadow"),L=r4("drop-shadow"),D=r4("blur"),N=r4("perspective"),w=r4("aspect"),Z=r4("ease"),O=r4("animate"),F=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...M(),e,t],v=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],R=()=>[e,t,V],h=()=>[S5,"full","auto",...R()],J$=()=>[k5,"none","subgrid",e,t],B$=()=>["auto",{span:["full",k5,e,t]},k5,e,t],_$=()=>[k5,"auto",e,t],s=()=>["auto","min","max","fr",e,t],E$=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],S$=()=>["start","end","center","stretch","center-safe","end-safe"],g=()=>["auto",...R()],r=()=>[S5,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],K$=()=>[S5,"screen","full","dvw","lvw","svw","min","max","fit",...R()],f4=()=>[S5,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],b=()=>[$,e,t],c=()=>[...M(),Rr,xr,{position:[e,t]}],q$=()=>["no-repeat",{repeat:["","x","y","space","round"]}],N4=()=>["auto","cover","contain",ZL$,NL$,{size:[e,t]}],L$=()=>[zx,RW,s7],M$=()=>["","none","full",H,e,t],m$=()=>["",b$,RW,s7],o$=()=>["solid","dashed","dotted","double"],w0=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],q4=()=>[b$,zx,Rr,xr],O4=()=>["","none",D,e,t],F0=()=>["none",b$,e,t],L9=()=>["none",b$,e,t],e7=()=>[b$,e,t],fQ=()=>[S5,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[D9],breakpoint:[D9],color:[Cr],container:[D9],"drop-shadow":[D9],ease:["in","out","in-out"],font:[zL$],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[D9],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[D9],shadow:[D9],spacing:["px",b$],text:[D9],"text-shadow":[D9],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",S5,t,e,w]}],container:["container"],columns:[{columns:[b$,t,e,K]}],"break-after":[{"break-after":F()}],"break-before":[{"break-before":F()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:v()}],"overflow-x":[{"overflow-x":v()}],"overflow-y":[{"overflow-y":v()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:h()}],"inset-x":[{"inset-x":h()}],"inset-y":[{"inset-y":h()}],start:[{"inset-s":h(),start:h()}],end:[{"inset-e":h(),end:h()}],"inset-bs":[{"inset-bs":h()}],"inset-be":[{"inset-be":h()}],top:[{top:h()}],right:[{right:h()}],bottom:[{bottom:h()}],left:[{left:h()}],visibility:["visible","invisible","collapse"],z:[{z:[k5,"auto",e,t]}],basis:[{basis:[S5,"full","auto",K,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[b$,S5,"auto","initial","none",t]}],grow:[{grow:["",b$,e,t]}],shrink:[{shrink:["",b$,e,t]}],order:[{order:[k5,"first","last","none",e,t]}],"grid-cols":[{"grid-cols":J$()}],"col-start-end":[{col:B$()}],"col-start":[{"col-start":_$()}],"col-end":[{"col-end":_$()}],"grid-rows":[{"grid-rows":J$()}],"row-start-end":[{row:B$()}],"row-start":[{"row-start":_$()}],"row-end":[{"row-end":_$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":s()}],"auto-rows":[{"auto-rows":s()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...E$(),"normal"]}],"justify-items":[{"justify-items":[...S$(),"normal"]}],"justify-self":[{"justify-self":["auto",...S$()]}],"align-content":[{content:["normal",...E$()]}],"align-items":[{items:[...S$(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...S$(),{baseline:["","last"]}]}],"place-content":[{"place-content":E$()}],"place-items":[{"place-items":[...S$(),"baseline"]}],"place-self":[{"place-self":["auto",...S$()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:g()}],mx:[{mx:g()}],my:[{my:g()}],ms:[{ms:g()}],me:[{me:g()}],mbs:[{mbs:g()}],mbe:[{mbe:g()}],mt:[{mt:g()}],mr:[{mr:g()}],mb:[{mb:g()}],ml:[{ml:g()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:r()}],"inline-size":[{inline:["auto",...K$()]}],"min-inline-size":[{"min-inline":["auto",...K$()]}],"max-inline-size":[{"max-inline":["none",...K$()]}],"block-size":[{block:["auto",...f4()]}],"min-block-size":[{"min-block":["auto",...f4()]}],"max-block-size":[{"max-block":["none",...f4()]}],w:[{w:[K,"screen",...r()]}],"min-w":[{"min-w":[K,"screen","none",...r()]}],"max-w":[{"max-w":[K,"screen","none","prose",{screen:[W]},...r()]}],h:[{h:["screen","lh",...r()]}],"min-h":[{"min-h":["screen","lh","none",...r()]}],"max-h":[{"max-h":["screen","lh",...r()]}],"font-size":[{text:["base",Q,RW,s7]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[J,ML$,DL$]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",zx,t]}],"font-family":[{font:[FL$,LL$,X]}],"font-features":[{"font-features":[t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[Y,e,t]}],"line-clamp":[{"line-clamp":[b$,"none",e,Ir]}],leading:[{leading:[G,...R()]}],"list-image":[{"list-image":["none",e,t]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",e,t]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:b()}],"text-color":[{text:b()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...o$(),"wavy"]}],"text-decoration-thickness":[{decoration:[b$,"from-font","auto",e,s7]}],"text-decoration-color":[{decoration:b()}],"underline-offset":[{"underline-offset":[b$,"auto",e,t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",e,t]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",e,t]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:c()}],"bg-repeat":[{bg:q$()}],"bg-size":[{bg:N4()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},k5,e,t],radial:["",e,t],conic:[k5,e,t]},OL$,wL$]}],"bg-color":[{bg:b()}],"gradient-from-pos":[{from:L$()}],"gradient-via-pos":[{via:L$()}],"gradient-to-pos":[{to:L$()}],"gradient-from":[{from:b()}],"gradient-via":[{via:b()}],"gradient-to":[{to:b()}],rounded:[{rounded:M$()}],"rounded-s":[{"rounded-s":M$()}],"rounded-e":[{"rounded-e":M$()}],"rounded-t":[{"rounded-t":M$()}],"rounded-r":[{"rounded-r":M$()}],"rounded-b":[{"rounded-b":M$()}],"rounded-l":[{"rounded-l":M$()}],"rounded-ss":[{"rounded-ss":M$()}],"rounded-se":[{"rounded-se":M$()}],"rounded-ee":[{"rounded-ee":M$()}],"rounded-es":[{"rounded-es":M$()}],"rounded-tl":[{"rounded-tl":M$()}],"rounded-tr":[{"rounded-tr":M$()}],"rounded-br":[{"rounded-br":M$()}],"rounded-bl":[{"rounded-bl":M$()}],"border-w":[{border:m$()}],"border-w-x":[{"border-x":m$()}],"border-w-y":[{"border-y":m$()}],"border-w-s":[{"border-s":m$()}],"border-w-e":[{"border-e":m$()}],"border-w-bs":[{"border-bs":m$()}],"border-w-be":[{"border-be":m$()}],"border-w-t":[{"border-t":m$()}],"border-w-r":[{"border-r":m$()}],"border-w-b":[{"border-b":m$()}],"border-w-l":[{"border-l":m$()}],"divide-x":[{"divide-x":m$()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":m$()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...o$(),"hidden","none"]}],"divide-style":[{divide:[...o$(),"hidden","none"]}],"border-color":[{border:b()}],"border-color-x":[{"border-x":b()}],"border-color-y":[{"border-y":b()}],"border-color-s":[{"border-s":b()}],"border-color-e":[{"border-e":b()}],"border-color-bs":[{"border-bs":b()}],"border-color-be":[{"border-be":b()}],"border-color-t":[{"border-t":b()}],"border-color-r":[{"border-r":b()}],"border-color-b":[{"border-b":b()}],"border-color-l":[{"border-l":b()}],"divide-color":[{divide:b()}],"outline-style":[{outline:[...o$(),"none","hidden"]}],"outline-offset":[{"outline-offset":[b$,e,t]}],"outline-w":[{outline:["",b$,RW,s7]}],"outline-color":[{outline:b()}],shadow:[{shadow:["","none",U,Oz,Zz]}],"shadow-color":[{shadow:b()}],"inset-shadow":[{"inset-shadow":["none",q,Oz,Zz]}],"inset-shadow-color":[{"inset-shadow":b()}],"ring-w":[{ring:m$()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:b()}],"ring-offset-w":[{"ring-offset":[b$,s7]}],"ring-offset-color":[{"ring-offset":b()}],"inset-ring-w":[{"inset-ring":m$()}],"inset-ring-color":[{"inset-ring":b()}],"text-shadow":[{"text-shadow":["none",z,Oz,Zz]}],"text-shadow-color":[{"text-shadow":b()}],opacity:[{opacity:[b$,e,t]}],"mix-blend":[{"mix-blend":[...w0(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":w0()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[b$]}],"mask-image-linear-from-pos":[{"mask-linear-from":q4()}],"mask-image-linear-to-pos":[{"mask-linear-to":q4()}],"mask-image-linear-from-color":[{"mask-linear-from":b()}],"mask-image-linear-to-color":[{"mask-linear-to":b()}],"mask-image-t-from-pos":[{"mask-t-from":q4()}],"mask-image-t-to-pos":[{"mask-t-to":q4()}],"mask-image-t-from-color":[{"mask-t-from":b()}],"mask-image-t-to-color":[{"mask-t-to":b()}],"mask-image-r-from-pos":[{"mask-r-from":q4()}],"mask-image-r-to-pos":[{"mask-r-to":q4()}],"mask-image-r-from-color":[{"mask-r-from":b()}],"mask-image-r-to-color":[{"mask-r-to":b()}],"mask-image-b-from-pos":[{"mask-b-from":q4()}],"mask-image-b-to-pos":[{"mask-b-to":q4()}],"mask-image-b-from-color":[{"mask-b-from":b()}],"mask-image-b-to-color":[{"mask-b-to":b()}],"mask-image-l-from-pos":[{"mask-l-from":q4()}],"mask-image-l-to-pos":[{"mask-l-to":q4()}],"mask-image-l-from-color":[{"mask-l-from":b()}],"mask-image-l-to-color":[{"mask-l-to":b()}],"mask-image-x-from-pos":[{"mask-x-from":q4()}],"mask-image-x-to-pos":[{"mask-x-to":q4()}],"mask-image-x-from-color":[{"mask-x-from":b()}],"mask-image-x-to-color":[{"mask-x-to":b()}],"mask-image-y-from-pos":[{"mask-y-from":q4()}],"mask-image-y-to-pos":[{"mask-y-to":q4()}],"mask-image-y-from-color":[{"mask-y-from":b()}],"mask-image-y-to-color":[{"mask-y-to":b()}],"mask-image-radial":[{"mask-radial":[e,t]}],"mask-image-radial-from-pos":[{"mask-radial-from":q4()}],"mask-image-radial-to-pos":[{"mask-radial-to":q4()}],"mask-image-radial-from-color":[{"mask-radial-from":b()}],"mask-image-radial-to-color":[{"mask-radial-to":b()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":M()}],"mask-image-conic-pos":[{"mask-conic":[b$]}],"mask-image-conic-from-pos":[{"mask-conic-from":q4()}],"mask-image-conic-to-pos":[{"mask-conic-to":q4()}],"mask-image-conic-from-color":[{"mask-conic-from":b()}],"mask-image-conic-to-color":[{"mask-conic-to":b()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:c()}],"mask-repeat":[{mask:q$()}],"mask-size":[{mask:N4()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",e,t]}],filter:[{filter:["","none",e,t]}],blur:[{blur:O4()}],brightness:[{brightness:[b$,e,t]}],contrast:[{contrast:[b$,e,t]}],"drop-shadow":[{"drop-shadow":["","none",L,Oz,Zz]}],"drop-shadow-color":[{"drop-shadow":b()}],grayscale:[{grayscale:["",b$,e,t]}],"hue-rotate":[{"hue-rotate":[b$,e,t]}],invert:[{invert:["",b$,e,t]}],saturate:[{saturate:[b$,e,t]}],sepia:[{sepia:["",b$,e,t]}],"backdrop-filter":[{"backdrop-filter":["","none",e,t]}],"backdrop-blur":[{"backdrop-blur":O4()}],"backdrop-brightness":[{"backdrop-brightness":[b$,e,t]}],"backdrop-contrast":[{"backdrop-contrast":[b$,e,t]}],"backdrop-grayscale":[{"backdrop-grayscale":["",b$,e,t]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[b$,e,t]}],"backdrop-invert":[{"backdrop-invert":["",b$,e,t]}],"backdrop-opacity":[{"backdrop-opacity":[b$,e,t]}],"backdrop-saturate":[{"backdrop-saturate":[b$,e,t]}],"backdrop-sepia":[{"backdrop-sepia":["",b$,e,t]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",e,t]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[b$,"initial",e,t]}],ease:[{ease:["linear","initial",Z,e,t]}],delay:[{delay:[b$,e,t]}],animate:[{animate:["none",O,e,t]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[N,e,t]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:F0()}],"rotate-x":[{"rotate-x":F0()}],"rotate-y":[{"rotate-y":F0()}],"rotate-z":[{"rotate-z":F0()}],scale:[{scale:L9()}],"scale-x":[{"scale-x":L9()}],"scale-y":[{"scale-y":L9()}],"scale-z":[{"scale-z":L9()}],"scale-3d":["scale-3d"],skew:[{skew:e7()}],"skew-x":[{"skew-x":e7()}],"skew-y":[{"skew-y":e7()}],transform:[{transform:[e,t,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:fQ()}],"translate-x":[{"translate-x":fQ()}],"translate-y":[{"translate-y":fQ()}],"translate-z":[{"translate-z":fQ()}],"translate-none":["translate-none"],accent:[{accent:b()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:b()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",e,t]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",e,t]}],fill:[{fill:["none",...b()]}],"stroke-w":[{stroke:[b$,RW,s7,Ir]}],stroke:[{stroke:["none",...b()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}};var ir=QL$(jL$);function lr(...$){return ir(yD($))}var pr=()=>{if(typeof document==="undefined")return;let $=document.getElementById("piedata_global_form");$&&$.submit()};