!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a099a4-b45b-71d0-9dae-0fd242a72828")}catch(e){}}();(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,964817,e=>{"use strict";var t=e.i(270401);let r=t.forwardRef(function({title:e,titleId:r,...n},a){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":r},n),e?t.createElement("title",{id:r},e):null,t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 8.25V18a2.25 2.25 0 0 0 2.25 2.25h13.5A2.25 2.25 0 0 0 21 18V8.25m-18 0V6a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 6v2.25m-18 0h18M5.25 6h.008v.008H5.25V6ZM7.5 6h.008v.008H7.5V6Zm2.25 0h.008v.008H9.75V6Z"}))});e.s(["WindowIcon",0,r],964817)},664514,e=>{"use strict";var t=e.i(270401);let r=(e,t)=>{let r=e instanceof Map?e:new Map(e.entries()),n=t instanceof Map?t:new Map(t.entries());if(r.size!==n.size)return!1;for(let[e,t]of r)if(!n.has(e)||!Object.is(t,n.get(e)))return!1;return!0};e.s(["useShallow",0,function(e){let n=t.default.useRef(void 0);return t=>{let a=e(t);return!function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(Symbol.iterator in e&&Symbol.iterator in t){if("entries"in e&&"entries"in t)return r(e,t);let n=e[Symbol.iterator](),a=t[Symbol.iterator](),s=n.next(),o=a.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=n.next(),o=a.next()}return!!s.done&&!!o.done}return r({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}(n.current,a)?n.current=a:n.current}}],664514)},457661,73284,827517,911189,612011,873151,967959,562443,958924,583603,558884,94814,797530,533515,23259,735729,e=>{"use strict";var t=e.i(217631),r=e.i(693697),n=e.i(204067),a=e.i(796805),s=e.i(321801),o=e.i(735162);e.i(798823);var l=e.i(429930),i=e.i(250855);let c=e=>e.items,d=(0,s.createSelector)([c,(e,t)=>t],(e,t)=>e[t]),u=(0,s.createSelector)([d],e=>e?.data.type==="function_call"?e.data:null),m=(0,s.createSelector)([d],e=>e?.data.type==="file_search_call"?e.data:null),p=(0,s.createSelector)([d],e=>e?.data.type==="image_generation_call"?e.data:null),f=(0,s.createSelector)([d],e=>e?.data.type==="video_generation_call"?e.data:null),h=new Set(["type","id","status"]);function x(e){return"status"in e&&"string"==typeof e.status?e.status:"in_progress"}function g(e){let t={};for(let[r,n]of Object.entries(e))h.has(r)||(t[r]=n);return Object.keys(t).length>0?JSON.stringify(t,null,2):""}function v(e,t){let a=(0,n.parseSchema)(e,t);if(!(0,r.isErr)(a)&&!Object.values(a.data).every(e=>void 0===e))return a.data}let b=a.z.object({error:a.z.string().optional(),responses:a.z.array(a.z.object({model:a.z.string()})).optional(),analysis:a.z.object({consensus:a.z.array(a.z.string()),contradictions:a.z.array(a.z.object({topic:a.z.string(),stances:a.z.array(a.z.object({model:a.z.string(),stance:a.z.string()}))})),partial_coverage:a.z.array(a.z.object({models:a.z.array(a.z.string()),point:a.z.string()})),unique_insights:a.z.array(a.z.object({model:a.z.string(),insight:a.z.string()})),blind_spots:a.z.array(a.z.string())}).optional()}),y=a.z.object({advice:a.z.string().optional(),model:a.z.string().optional(),error:a.z.string().optional(),prompt:a.z.string().optional()}),j=a.z.object({outcome:a.z.string().optional(),model:a.z.string().optional(),error:a.z.string().optional(),task_name:a.z.string().optional(),task_description:a.z.string().optional()}),S=a.z.object({type:a.z.literal("container_file_citation"),container_id:a.z.string(),file_id:a.z.string(),filename:a.z.string(),start_index:(0,n.zInt)(),end_index:(0,n.zInt)()}),w=a.z.array(S).optional().catch(void 0),N=a.z.object({command:a.z.string().optional(),stdout:a.z.string().optional(),stderr:a.z.string().optional(),exitCode:(0,n.zInt)().optional(),files:w,container_id:a.z.string().optional()}),C=a.z.object({stdout:a.z.string(),stderr:a.z.string(),outcome:a.z.discriminatedUnion("type",[a.z.object({type:a.z.literal("exit"),exit_code:(0,n.zInt)()}),a.z.object({type:a.z.literal("timeout")})])}),I=a.z.object({call_id:a.z.string().optional(),output:a.z.array(C),files:w,container_id:a.z.string().optional()}),_=a.z.object({call_id:a.z.string().optional(),action:a.z.object({commands:a.z.array(a.z.string())}).optional(),output:a.z.array(C).optional().catch(void 0),files:w,container_id:a.z.string().optional()}),k=(0,s.createSelector)([c],e=>Object.values(e).filter(e=>"shell_call"===e.data.type),{memoize:s.lruMemoize,memoizeOptions:{resultEqualityCheck:(e,t)=>e.length===t.length&&e.every((e,r)=>e===t[r])}});function A(e){let t=(0,n.parseSchema)(_,e);if((0,r.isErr)(t))return;let a=t.data.action?.commands??[],s=t.data.output??[];if(void 0!==t.data.action||0!==s.length)return{commands:a,output:s,files:t.data.files,container_id:t.data.container_id}}let M=a.z.object({url:a.z.string().regex(/^https?:\/\//i,"Only http(s) URLs allowed").optional().catch(void 0),title:a.z.string().nullish(),content:a.z.string().optional(),httpStatus:a.z.number().int().optional(),error:a.z.string().optional()}),T=a.z.object({action:a.z.object({type:a.z.literal("search"),query:a.z.string().optional(),sources:a.z.array(a.z.object({type:a.z.literal("url"),url:a.z.string()})).optional()}).optional()}),E=a.z.object({query:a.z.string()});function R(e,t){let a=(0,n.parseSchema)(T,e),s=(0,r.isOk)(a)?a.data.action:void 0,o=function(e,t){let a=(0,n.parseSchema)(T,e),s=(0,r.isOk)(a)?a.data.action?.query:void 0;if(s)return s;if(!t)return null;let o=(0,r.wrap)(()=>JSON.parse(t));if((0,r.isErr)(o))return null;let l=(0,n.parseSchema)(E,o.data);if((0,r.isOk)(l)&&l.data.query)return l.data.query;let i=(0,n.parseSchema)(T,o.data);return(0,r.isOk)(i)&&i.data.action?.query?i.data.action.query:null}(e,t);if(o||s?.sources?.length)return{query:o??void 0,sources:s?.sources}}let z=(0,s.createSelector)([d,k],(e,a)=>{if(!e)return null;let{data:s}=e;if("function_call"===s.type&&(0,t.isMember)(s.name,o.SERVER_TOOL_NAMES)){let t=s.arguments??"",r={};if("openrouter:web_search"===s.name){let e=R(s,t);e&&(r.webSearch=e)}return{toolName:s.name,itemType:s.type,status:s.status??"in_progress",arguments:t,messageId:e.messageId,outputData:Object.keys(r).length>0?r:void 0}}if(s.type&&(0,t.isMember)(s.type,o.SERVER_TOOL_NAMES)){let t="openrouter:web_search"===s.type?g(s):"arguments"in s&&"string"==typeof s.arguments?s.arguments:"",a={};if("openrouter:web_fetch"===s.type){let e=function(e){let t=(0,n.parseSchema)(M,e);if((0,r.isErr)(t))return;let{url:a,title:s,content:o,httpStatus:l,error:i}=t.data;if(a||s||o||l||i)return{url:a,title:s??void 0,content:o,httpStatus:l,error:i}}(s);e&&(a.webFetch=e)}if("openrouter:web_search"===s.type){let e=R(s,t);e&&(a.webSearch=e)}if("openrouter:fusion"===s.type){let e=v(b,s);e&&(a.fusion=e)}if("openrouter:advisor"===s.type){let e=v(y,s);e&&(a.advisor=e)}if("openrouter:subagent"===s.type){let e=v(j,s);e&&(a.subagent=e)}if("openrouter:bash"===s.type){let e=v(N,s);e&&(a.bash=e)}if("openrouter:shell"===s.type){let e=A(s);e&&(a.shell=e)}return{toolName:s.type,itemType:s.type,status:x(s),arguments:t,messageId:e.messageId,outputData:Object.keys(a).length>0?a:void 0}}if("web_search_call"===s.type){let t=g(s),r=R(s,t);return{toolName:"openrouter:web_search",itemType:s.type,status:x(s),arguments:t,messageId:e.messageId,outputData:r?{webSearch:r}:void 0}}if("shell_call"===s.type){let t=A(s);return{toolName:"openrouter:shell",itemType:s.type,status:x(s),arguments:"",messageId:e.messageId,outputData:t?{shell:t}:void 0}}if("shell_call_output"===s.type){let t=function(e,t){let a=(0,n.parseSchema)(I,e);if(!(0,r.isErr)(a))return{commands:function(e,t){if(e)for(let a of t){let t=(0,n.parseSchema)(_,a.data);if((0,r.isOk)(t)&&t.data.call_id===e)return t.data.action?.commands}}(a.data.call_id,t),output:a.data.output,files:a.data.files,container_id:a.data.container_id}}(s,a);return{toolName:"openrouter:shell",itemType:s.type,status:x(s),arguments:"",messageId:e.messageId,outputData:t?{shell:t}:void 0}}return"string"==typeof s.type&&(0,o.isOpenRouterTool)(s.type)?{toolName:s.type,itemType:s.type,status:x(s),arguments:g(s),messageId:e.messageId}:null}),O=a.z.object({type:a.z.literal("openrouter:image_generation"),imageUrl:a.z.string().optional(),result:a.z.string().nullish(),imageB64:a.z.string().optional()}),F=(0,s.createSelector)([d],e=>{if(!e)return null;let t=(0,n.parseSchema)(O,e.data);if((0,r.isErr)(t))return null;let{imageUrl:a,result:s,imageB64:l}=t.data;return a||(s?s.includes("://")?s:(0,o.toBase64DataUri)(s):l?(0,o.toBase64DataUri)(l):null)}),D=(0,s.createSelector)([d],e=>e?.data.type==="message"&&Array.isArray(e.data.content)?e.data.content:[]),L=(0,s.createSelector)([d],e=>e?.data.type==="message"&&Array.isArray(e.data.content)?e.data.content.flatMap(e=>"output_text"===e.type?e.annotations??[]:[]).filter(e=>"url_citation"===e.type):[]),P=(0,s.createSelector)([d],e=>e?.data.type==="reasoning"&&Array.isArray(e.data.content)?e.data.content.filter(e=>"reasoning_text"===e.type).map(e=>e.text).join(""):""),B=(0,s.createSelector)([d],e=>e?.data.type==="reasoning"&&Array.isArray(e.data.summary)?e.data.summary.filter(e=>"summary_text"===e.type).map(e=>e.text).join("\n"):""),V=new Set(["openrouter:bash","openrouter:shell","shell_call","shell_call_output"]),$=a.z.object({container_id:a.z.string().optional().catch(void 0)}),H=(0,s.createSelector)([c],e=>Object.values(e).some(e=>"string"==typeof e.data.type&&V.has(e.data.type))),U=(0,s.createSelector)([c],e=>{let t;for(let a of Object.values(e)){if("string"!=typeof a.data.type||!V.has(a.data.type))continue;let e=(0,n.parseSchema)($,a.data);(0,r.isOk)(e)&&void 0!==e.data.container_id&&(t=e.data.container_id)}return t});e.s(["makeSelectIsServerToolFunctionCall",0,()=>(0,s.createSelector)([u],e=>!!e&&(0,t.isMember)(e.name,o.SERVER_TOOL_NAMES)),"makeSelectSortedItemsByMessageId",0,()=>(0,s.createSelector)([(0,i.makeSelectMessageById)()],e=>e?.type!==l.MessageType.Assistant?[]:[...e.items??[]].sort((e,t)=>(e.outputIndex??e.sequenceIndex??0)-(t.outputIndex??t.sequenceIndex??0))),"selectContentPartsFromItem",0,D,"selectFileSearchCallData",0,m,"selectFunctionCallData",0,u,"selectHasSandboxToolItems",0,H,"selectImageGenerationCallData",0,p,"selectIsItemRevealing",0,(e,t)=>!0===e.revealingItemIds[t],"selectItemById",0,d,"selectLatestSandboxContainerId",0,U,"selectReasoningContentFromItem",0,P,"selectReasoningSummaryFromItem",0,B,"selectServerToolImageUrl",0,F,"selectServerToolOutputData",0,z,"selectUrlCitationsFromItem",0,L,"selectVideoGenerationCallData",0,f],457661);var G=e.i(780397),q=e.i(624621);function W(e){let t=(0,G.getCurrentRoomId)();if(!t)return null;let r=q.useChatroomStore.getState(),n=r.rooms[t]?.messages[e];if(!n||!Array.isArray(n.items))return null;let a=n.items.find(e=>"message"===e.type)??null;return a?a.id:null}e.s(["getPrimaryMessageItemId",0,W],73284);var K=e.i(505962),J=e.i(948810),Z=e.i(639241),Y=e.i(621036);let X=[{key:"violet",pillBg:"bg-chart-1/12",swatchBg:"bg-chart-1/60"},{key:"blue",pillBg:"bg-chart-2/12",swatchBg:"bg-chart-2/60"},{key:"green",pillBg:"bg-chart-3/12",swatchBg:"bg-chart-3/60"},{key:"amber",pillBg:"bg-chart-4/12",swatchBg:"bg-chart-4/60"},{key:"coral",pillBg:"bg-chart-5/12",swatchBg:"bg-chart-5/60"},{key:"orange",pillBg:"bg-chart-6/12",swatchBg:"bg-chart-6/60"}],Q=X.map(e=>e.key),ee=a.z.object({colorsBySlug:a.z.record(a.z.string(),a.z.string()).optional()}),et=(0,J.create)()((0,Z.persist)(e=>({colorsBySlug:{},setColor:(t,r)=>e(e=>{let n={...e.colorsBySlug};return null===r?delete n[t]:n[t]=r,{colorsBySlug:n}})}),{name:"playground-model-colors",version:1,storage:(0,Z.createJSONStorage)(Y.createSafeLocalStorage),migrate:e=>{let a=(0,n.parseSchema)(ee,e),s={};for(let[e,n]of Object.entries((0,r.isOk)(a)?a.data.colorsBySlug??{}:{}))(0,t.isMember)(n,Q)&&(s[e]=n);return{colorsBySlug:s}}}));e.s(["MESSAGE_COLOR_OPTIONS",0,X,"getMessageColorOption",0,function(e){return e?X.find(t=>t.key===e)??null:null},"getModelColorKey",0,function(e){return e?e.modelInfo?.endpoint?.model_variant_permaslug??e.modelInfo?.permaslug??e.model??null:null},"useModelColor",0,function(e){let t,r=(0,K.c)(2);return r[0]!==e?(t=t=>e?t.colorsBySlug[e]??null:null,r[0]=e,r[1]=t):t=r[1],et(t)},"useModelColorStore",0,et],827517);var er=e.i(222666),en=e.i(336422),ea=e.i(733442),es=e.i(22422),eo=e.i(671910);function el(e){return(0,eo.useRelativeTime)(e,"elapsed")}e.s(["useTimeAgo",0,el],911189);var ei=e.i(613889),ec=e.i(239718),ed=e.i(614991),eu=e.i(452473),em=e.i(956506),ep=e.i(648156);function ef(e){let t,r,n,a,s,o,i=(0,K.c)(15),{status:c,className:d}=e,u=ea.generationStatusTheme[c];i[0]!==d?(t=(0,eu.cn)("relative inline-flex h-2.5 w-2.5 items-center justify-center",d),i[0]=d,i[1]=t):t=i[1],i[2]!==u.ringBorder?(r=(0,eu.cn)("relative inline-flex h-2.5 w-2.5 items-center justify-center rounded-full border",u.ringBorder),i[2]=u.ringBorder,i[3]=r):r=i[3];let m=c===l.GenerationStatus.Generating&&"animate-pulse";return i[4]!==u.coreBg||i[5]!==m?(n=(0,eu.cn)("h-1.5 w-1.5 rounded-full",u.coreBg,m),i[4]=u.coreBg,i[5]=m,i[6]=n):n=i[6],i[7]!==n?(a=(0,er.jsx)("span",{className:n}),i[7]=n,i[8]=a):a=i[8],i[9]!==r||i[10]!==a?(s=(0,er.jsx)("span",{className:r,children:a}),i[9]=r,i[10]=a,i[11]=s):s=i[11],i[12]!==t||i[13]!==s?(o=(0,er.jsx)("span",{className:t,"aria-hidden":!0,children:s}),i[12]=t,i[13]=s,i[14]=o):o=i[14],o}function eh(e){let t,r,n,a,s=(0,K.c)(11),{status:o,label:l,className:i,title:c}=e,d=l??ea.generationStatusLabel[o];s[0]!==i?(t=(0,eu.cn)("inline-flex items-center gap-1.5 text-xs text-muted-foreground",i),s[0]=i,s[1]=t):t=s[1];let u=c??d;return s[2]!==o?(r=(0,er.jsx)(ef,{status:o}),s[2]=o,s[3]=r):r=s[3],s[4]!==d?(n=(0,er.jsx)("span",{className:"leading-none",children:d}),s[4]=d,s[5]=n):n=s[5],s[6]!==t||s[7]!==u||s[8]!==r||s[9]!==n?(a=(0,er.jsxs)("span",{className:t,title:u,children:[r,n]}),s[6]=t,s[7]=u,s[8]=r,s[9]=n,s[10]=a):a=s[10],a}let ex=[];function eg(e){let t,r,n,a,s,o,i,c,d,u,m,p,f,h,x,g,v,b,y,j,S=(0,K.c)(60),{type:w,title:N,subtitle:C,status:I,tags:_,filesCount:k,versionsCount:A,updatedLabel:M,loading:T,active:E,onClick:R,onMore:z,onOpen:O,className:F,ariaLabel:D}=e,L=void 0===_?ex:_,P=void 0!==E&&E,B=void 0!==T&&T,V=w===l.ArtifactType.Image?ed.PhotoIcon:ei.CodeBracketIcon,$="string"==typeof D?D:void 0,H=R??O,U=P&&"border-primary";return S[0]!==F||S[1]!==U?(t=(0,eu.cn)("w-full max-w-md","border border-border bg-card transition-colors","hover:bg-card-hover",U,F),S[0]=F,S[1]=U,S[2]=t):t=S[2],S[3]!==V||S[4]!==B?(r=(0,er.jsx)("div",{className:"flex h-8 w-8 flex-none items-center justify-center rounded-md bg-muted",children:B?(0,er.jsx)("div",{className:"h-4 w-4 animate-pulse rounded-sm bg-muted-foreground/30"}):(0,er.jsx)(V,{className:"h-4 w-4 text-muted-foreground"})}),S[3]=V,S[4]=B,S[5]=r):r=S[5],S[6]!==B||S[7]!==N?(n=B?(0,er.jsx)("span",{className:"inline-block h-3.5 w-40 animate-pulse rounded-sm bg-border"}):N,S[6]=B,S[7]=N,S[8]=n):n=S[8],S[9]!==n?(a=(0,er.jsx)(em.CardTitle,{className:"truncate text-sm font-medium text-foreground",children:n}),S[9]=n,S[10]=a):a=S[10],S[11]!==B||S[12]!==I?(s=!B&&(0,er.jsx)(eh,{status:I}),S[11]=B,S[12]=I,S[13]=s):s=S[13],S[14]!==z?(o=z&&(0,er.jsx)(ep.Tooltip,{content:"More",children:(0,er.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),z()},className:"rounded-sm p-1 text-muted-foreground hover:bg-muted","aria-label":"More actions",children:(0,er.jsx)(ec.EllipsisHorizontalIcon,{className:"h-5 w-5"})})}),S[14]=z,S[15]=o):o=S[15],S[16]!==s||S[17]!==o?(i=(0,er.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[s,o]}),S[16]=s,S[17]=o,S[18]=i):i=S[18],S[19]!==a||S[20]!==i?(c=(0,er.jsxs)("div",{className:"flex items-center gap-2",children:[a,i]}),S[19]=a,S[20]=i,S[21]=c):c=S[21],S[22]!==B||S[23]!==C?(d=C&&(0,er.jsx)(em.CardDescription,{className:"mt-0.5 line-clamp-1 text-xs",children:B?(0,er.jsx)("span",{className:"inline-block h-3 w-56 animate-pulse rounded-sm bg-border"}):C}),S[22]=B,S[23]=C,S[24]=d):d=S[24],S[25]!==c||S[26]!==d?(u=(0,er.jsxs)("div",{className:"min-w-0 flex-1",children:[c,d]}),S[25]=c,S[26]=d,S[27]=u):u=S[27],S[28]!==u||S[29]!==r?(m=(0,er.jsx)(em.CardHeader,{className:"py-3",children:(0,er.jsxs)("div",{className:"flex items-center gap-3",children:[r,u]})}),S[28]=u,S[29]=r,S[30]=m):m=S[30],S[31]!==L?(p=L.map(ev),S[31]=L,S[32]=p):p=S[32],S[33]!==p?(f=(0,er.jsx)("div",{className:"col-span-1 flex min-w-0 flex-wrap items-center gap-1.5",children:p}),S[33]=p,S[34]=f):f=S[34],S[35]!==k||S[36]!==w||S[37]!==A?(h=w===l.ArtifactType.App&&(0,er.jsxs)(er.Fragment,{children:[(0,er.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,er.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground"}),k," files"]}),(0,er.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,er.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground"}),A," versions"]})]}),S[35]=k,S[36]=w,S[37]=A,S[38]=h):h=S[38],S[39]!==h?(x=(0,er.jsx)("div",{className:"col-span-1 flex items-center justify-end gap-3 text-xs text-muted-foreground",children:h}),S[39]=h,S[40]=x):x=S[40],S[41]!==M?(g=(0,er.jsx)("div",{className:"col-span-1 text-xs text-muted-foreground",children:M}),S[41]=M,S[42]=g):g=S[42],S[43]!==O?(v=O&&(0,er.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),O()},className:(0,eu.cn)("rounded-md px-2 py-1 text-xs font-medium","text-foreground hover:bg-muted","border border-border"),children:"Open"}),S[43]=O,S[44]=v):v=S[44],S[45]!==v?(b=(0,er.jsx)("div",{className:"col-span-1 flex justify-end",children:v}),S[45]=v,S[46]=b):b=S[46],S[47]!==f||S[48]!==x||S[49]!==g||S[50]!==b?(y=(0,er.jsx)(em.CardContent,{className:"pt-0",children:(0,er.jsxs)("div",{className:"grid grid-cols-2 items-center gap-x-3 gap-y-2",children:[f,x,g,b]})}),S[47]=f,S[48]=x,S[49]=g,S[50]=b,S[51]=y):y=S[51],S[52]!==P||S[53]!==B||S[54]!==m||S[55]!==y||S[56]!==$||S[57]!==H||S[58]!==t?(j=(0,er.jsx)("div",{className:"w-full",children:(0,er.jsxs)(em.Card,{role:"button",tabIndex:0,"aria-pressed":P,"aria-busy":B,"aria-label":$,onClick:H,className:t,children:[m,y]})}),S[52]=P,S[53]=B,S[54]=m,S[55]=y,S[56]=$,S[57]=H,S[58]=t,S[59]=j):j=S[59],j}function ev(e){return(0,er.jsx)("span",{className:"truncate rounded-sm border border-border px-2 py-0.5 text-xs text-muted-foreground",title:e,children:e},e)}function eb(e){let t,r,n,a,s,o,i,c=(0,K.c)(28),{artifact:d}=e,u=d.headVersionId;c[0]!==u?(t=e=>u?e.artifactVersions[u]?.generationStatus:void 0,c[0]=u,c[1]=t):t=c[1];let m=(0,q.useChatroomStore)(t);c[2]!==u?(r=e=>u?e.artifactVersions[u]?.error:void 0,c[2]=u,c[3]=r):r=c[3];let p=(0,q.useChatroomStore)(r),f=m===l.GenerationStatus.Generating,h=m===l.GenerationStatus.Failed,x=!!u&&f;c[4]!==p?(n="string"==typeof p&&p.trim().length>0,c[4]=p,c[5]=n):n=c[5];let g=n;c[6]!==g||c[7]!==x||c[8]!==h?(a=function({isGenerating:e,isHeadFailed:t,hasError:r}){return e?l.GenerationStatus.Generating:t||r?l.GenerationStatus.Failed:l.GenerationStatus.Success}({isGenerating:x,isHeadFailed:h,hasError:g}),c[6]=g,c[7]=x,c[8]=h,c[9]=a):a=c[9];let v=a;if(c[10]!==d.archetype||c[11]!==d.stack){let e,t;s=[],c[13]!==d.archetype?(e=(0,ea.getAppArchetypeLabel)(d.archetype),c[13]=d.archetype,c[14]=e):e=c[14];let r=e;c[15]!==d.stack?(t=(0,ea.getAppStackLabel)(d.stack),c[15]=d.stack,c[16]=t):t=c[16];let n=t;r&&s.push(r),n&&s.push(n),c[10]=d.archetype,c[11]=d.stack,c[12]=s}else s=c[12];let b=el(d.updatedAt),y=b?`Updated ${b}`:void 0;c[17]!==d.id?(o=()=>{es.chatroomStoreActions.setActiveArtifactId({payload:{artifactId:d.id}})},c[17]=d.id,c[18]=o):o=c[18];let j=o,S=d.name||"Artifact",w=d.fileIds?.length??0,N=d.versionsCount??0;return c[19]!==d.archetype||c[20]!==j||c[21]!==v||c[22]!==S||c[23]!==w||c[24]!==N||c[25]!==s||c[26]!==y?(i=(0,er.jsx)(eg,{type:l.ArtifactType.App,title:S,status:v,tags:s,filesCount:w,versionsCount:N,updatedLabel:y,archetype:d.archetype,showPreview:!0,onOpen:j}),c[19]=d.archetype,c[20]=j,c[21]=v,c[22]=S,c[23]=w,c[24]=N,c[25]=s,c[26]=y,c[27]=i):i=c[27],i}function ey(){return null}e.s(["ArtifactMessageCard",0,function(e){let t,r=(0,K.c)(5),{artifactId:n}=e;r[0]!==n?(t=e=>e.artifacts[n],r[0]=n,r[1]=t):t=r[1];let a=(0,q.useChatroomStore)(t);if(!a)return null;let s=a.type;switch(s){case l.ArtifactType.App:{let e;return r[2]!==a?(e=(0,er.jsx)(eb,{artifact:a}),r[2]=a,r[3]=e):e=r[3],e}case l.ArtifactType.Image:{let e;return r[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,er.jsx)(ey,{}),r[4]=e):e=r[4],e}default:(0,en.assertNever)(s)}}],612011);var ej=e.i(586404),eS=e.i(270401),ew=e.i(733288),eN=e.i(970654),eC=e.i(528164);let eI=new Set,e_=null,ek=Date.now();function eA(e){return eI.add(e),1===eI.size&&null===e_&&(e_=window.setInterval(()=>{ek=Date.now(),eI.forEach(e=>{e()})},1e3)),()=>{eI.delete(e),0===eI.size&&null!==e_&&(clearInterval(e_),e_=null)}}function eM(){return ek}function eT(){return Date.now()}function eE(e){let t,r,n=(0,K.c)(4),{start:a}=e,s=(0,eS.useSyncExternalStore)(eA,eM,eT);if(!a)return null;let o=Math.max(0,Math.floor((s-a.getTime())/1e3));return n[0]!==o?(t=function(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),r=e%60;return 0===r?`${t}m`:`${t}m ${r}s`}(o),n[0]=o,n[1]=t):t=n[1],n[2]!==t?(r=(0,er.jsx)("span",{className:"text-xs text-muted-foreground",children:t}),n[2]=t,n[3]=r):r=n[3],r}e.s(["ElapsedTimer",0,eE],873151);let eR=[];function ez(e){let t,r,n,a,s,o,i,c,d,u,m,p,f,h,x,g,v,b,y,j,S,w,N,C,I=(0,K.c)(66),{versionNumber:_,status:k,isActive:A,subtitle:M,badges:T,stats:E,generationStartedAt:R,createdAtLabel:z,onOpen:O,errorMessage:F,actions:D,onSelect:L,className:P,ariaLabel:B}=e,V=void 0!==A&&A,$=void 0===T?eR:T,H=E?.durationMs,U=E?.filesChanged,G=k===l.GenerationStatus.Generating,q=!!O&&!V&&!D,W=V&&"border-primary hover:border-primary";I[0]!==P||I[1]!==W?(t=(0,eu.cn)("w-full border border-border bg-card transition-colors","hover:bg-card-hover","rounded-tl-none",W,P),I[0]=P,I[1]=W,I[2]=t):t=I[2];let J=V?"true":"false",Z="string"==typeof B?B:void 0;return I[3]!==L?(r=()=>L?.(),n=e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),L?.())},I[3]=L,I[4]=r,I[5]=n):(r=I[4],n=I[5]),I[6]===Symbol.for("react.memo_cache_sentinel")?(a=(0,er.jsx)("div",{className:"flex h-8 w-8 flex-none items-center justify-center rounded-md bg-muted",children:(0,er.jsx)(ew.SparklesIcon,{className:"h-4 w-4 text-muted-foreground"})}),I[6]=a):a=I[6],I[7]!==_?(s=(0,er.jsxs)(em.CardTitle,{className:"truncate text-sm font-medium text-foreground",children:["Version ",_]}),I[7]=_,I[8]=s):s=I[8],I[9]!==V?(o=V&&(0,er.jsx)(eN.Badge,{variant:"secondary",className:"text-2xs h-5 px-1.5",children:"Active"}),I[9]=V,I[10]=o):o=I[10],I[11]!==k?(i=(0,er.jsx)("div",{className:"ml-auto flex items-center gap-2",children:(0,er.jsx)(eh,{status:k})}),I[11]=k,I[12]=i):i=I[12],I[13]!==s||I[14]!==o||I[15]!==i?(c=(0,er.jsxs)("div",{className:"flex items-center gap-2",children:[s,o,i]}),I[13]=s,I[14]=o,I[15]=i,I[16]=c):c=I[16],I[17]!==M?(d=M?(0,er.jsx)(em.CardDescription,{className:"mt-0.5 line-clamp-1 text-xs ph-no-capture","data-dd-privacy":"hidden",children:M}):null,I[17]=M,I[18]=d):d=I[18],I[19]!==c||I[20]!==d?(u=(0,er.jsx)(em.CardHeader,{className:"p-4",children:(0,er.jsxs)("div",{className:"flex items-center gap-3",children:[a,(0,er.jsxs)("div",{className:"min-w-0 flex-1",children:[c,d]})]})}),I[19]=c,I[20]=d,I[21]=u):u=I[21],I[22]!==$?(m=$.map(eO),I[22]=$,I[23]=m):m=I[23],I[24]!==m?(p=(0,er.jsx)("div",{className:"col-span-1 flex min-w-0 flex-wrap items-center gap-1.5",children:m}),I[24]=m,I[25]=p):p=I[25],I[26]!==U?(f="number"==typeof U&&U>=0&&(0,er.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,er.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground"}),U," ",1===U?"file":"files"," changed"]}),I[26]=U,I[27]=f):f=I[27],I[28]!==R||I[29]!==G?(h=G&&R&&(0,er.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,er.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground"}),(0,er.jsx)(eE,{start:R})]}),I[28]=R,I[29]=G,I[30]=h):h=I[30],I[31]!==H||I[32]!==G?(x=!G&&"number"==typeof H&&H>0&&(0,er.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,er.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground"}),Math.round(H/1e3),"s"]}),I[31]=H,I[32]=G,I[33]=x):x=I[33],I[34]!==f||I[35]!==h||I[36]!==x?(g=(0,er.jsxs)("div",{className:"col-span-1 flex items-center justify-end gap-3 text-xs text-muted-foreground",children:[f,h,x]}),I[34]=f,I[35]=h,I[36]=x,I[37]=g):g=I[37],I[38]!==F?(v=F&&(0,er.jsx)("div",{className:"col-span-2 rounded-sm border border-border bg-muted p-2 text-xs text-foreground",children:F}),I[38]=F,I[39]=v):v=I[39],I[40]!==z?(b=(0,er.jsx)("div",{className:"col-span-1 text-xs text-muted-foreground",children:z}),I[40]=z,I[41]=b):b=I[41],I[42]!==D?(y=D?(0,er.jsx)("div",{className:"flex items-center gap-1",children:D}):null,I[42]=D,I[43]=y):y=I[43],I[44]!==O||I[45]!==q?(j=q&&(0,er.jsx)(eC.Button,{variant:"outline",size:"sm",onClick:e=>{e.stopPropagation(),O?.()},children:"View Version"}),I[44]=O,I[45]=q,I[46]=j):j=I[46],I[47]!==y||I[48]!==j?(S=(0,er.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[y,j]}),I[47]=y,I[48]=j,I[49]=S):S=I[49],I[50]!==p||I[51]!==g||I[52]!==v||I[53]!==b||I[54]!==S?(w=(0,er.jsx)(em.CardContent,{className:"px-4 pt-0 pb-3",children:(0,er.jsxs)("div",{className:"grid grid-cols-2 items-center gap-x-3 gap-y-2",children:[p,g,v,b,S]})}),I[50]=p,I[51]=g,I[52]=v,I[53]=b,I[54]=S,I[55]=w):w=I[55],I[56]!==u||I[57]!==w||I[58]!==J||I[59]!==Z||I[60]!==r||I[61]!==n?(N=(0,er.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":J,"aria-label":Z,onClick:r,onKeyDown:n,children:[u,w]}),I[56]=u,I[57]=w,I[58]=J,I[59]=Z,I[60]=r,I[61]=n,I[62]=N):N=I[62],I[63]!==N||I[64]!==t?(C=(0,er.jsx)(em.Card,{className:t,children:N}),I[63]=N,I[64]=t,I[65]=C):C=I[65],C}function eO(e){return(0,er.jsx)("span",{className:"truncate rounded-sm border border-border px-2 py-0.5 text-xs text-muted-foreground",title:e,children:e},e)}var eF=e.i(693946);function eD(e){let t,r,n,a,s,o,l,i,c,d=(0,K.c)(26),{artifactId:u,versionId:m,isLoading:p,isActive:f,onOpen:h}=e,x=(0,q.useChatroomStore)(eF.selectCurrentRoomId);d[0]!==m?(t=e=>e.artifactVersions[m],d[0]=m,d[1]=t):t=d[1];let g=(0,q.useChatroomStore)(t);d[2]!==g?(r="string"==typeof g?.error&&g.error.trim().length>0,d[2]=g,d[3]=r):r=d[3];let v=r;d[4]!==u||d[5]!==x||d[6]!==m?(n=e=>{e.stopPropagation(),x&&es.chatroomStoreActions.stopArtifactVersionGeneration({payload:{roomId:x,artifactId:u,versionId:m}})},d[4]=u,d[5]=x,d[6]=m,d[7]=n):n=d[7];let b=n;d[8]!==u||d[9]!==m?(a=e=>{e.stopPropagation(),es.chatroomStoreActions.fixArtifactVersionError({payload:{artifactId:u,versionId:m}})},d[8]=u,d[9]=m,d[10]=a):a=d[10];let y=a;d[11]!==h?(s=e=>{e.stopPropagation(),h()},d[11]=h,d[12]=s):s=d[12];let j=s;d[13]!==p||d[14]!==b?(o=p&&(0,er.jsx)(eC.Button,{variant:"destructive",size:"sm",onClick:b,children:"Stop & Delete"}),d[13]=p,d[14]=b,d[15]=o):o=d[15],d[16]!==y||d[17]!==v?(l=v&&(0,er.jsxs)(eC.Button,{variant:"default",size:"sm",onClick:y,children:[(0,er.jsx)(ew.SparklesIcon,{className:"w-4 h-4"}),"Try to Fix"]}),d[16]=y,d[17]=v,d[18]=l):l=d[18];let S=f?"Currently Viewing":"View Version";return d[19]!==j||d[20]!==S?(i=(0,er.jsx)(eC.Button,{variant:"outline",size:"sm",onClick:j,children:S}),d[19]=j,d[20]=S,d[21]=i):i=d[21],d[22]!==o||d[23]!==l||d[24]!==i?(c=(0,er.jsxs)("div",{className:"flex items-center gap-2",children:[o,l,i]}),d[22]=o,d[23]=l,d[24]=i,d[25]=c):c=d[25],c}let eL=(0,eS.memo)(e=>{let t,r,n,a,s,o,i,c,d,u,m,p,f,h,x,g,v,b=(0,K.c)(53),{artifactId:y,versionId:j}=e;b[0]!==j?(t=e=>e.artifactVersions[j]?.versionNumber,b[0]=j,b[1]=t):t=b[1];let S=(0,q.useChatroomStore)(t);b[2]!==j?(r=e=>e.artifactVersions[j]?.parentVersionId,b[2]=j,b[3]=r):r=b[3];let w=(0,q.useChatroomStore)(r);b[4]!==j?(n=e=>e.artifactVersions[j]?.characterName,b[4]=j,b[5]=n):n=b[5];let N=(0,q.useChatroomStore)(n);b[6]!==j?(a=e=>e.artifactVersions[j]?.prompt,b[6]=j,b[7]=a):a=b[7];let C=(0,q.useChatroomStore)(a);b[8]!==j?(s=e=>e.artifactVersions[j]?.generationStatus,b[8]=j,b[9]=s):s=b[9];let I=(0,q.useChatroomStore)(s);b[10]!==j?(o=e=>e.artifactVersions[j]?.error,b[10]=j,b[11]=o):o=b[11];let _=(0,q.useChatroomStore)(o);b[12]!==j?(i=e=>e.artifactVersions[j]?.createdAt,b[12]=j,b[13]=i):i=b[13];let k=(0,q.useChatroomStore)(i);b[14]!==j?(c=e=>e.artifactVersions[j]?.generationDurationMs,b[14]=j,b[15]=c):c=b[15];let A=(0,q.useChatroomStore)(c);b[16]!==y||b[17]!==j?(d=e=>e.artifactViewerState[y]?.activeVersionId===j,b[16]=y,b[17]=j,b[18]=d):d=b[18];let M=(0,q.useChatroomStore)(d);b[19]!==w?(u=e=>w?e.artifactVersions[w]?.versionNumber:null,b[19]=w,b[20]=u):u=b[20];let T=(0,q.useChatroomStore)(u),E=el(k);if(null==S)return null;b[21]!==y||b[22]!==j?(m=()=>{es.chatroomStoreActions.setActiveVersionId({payload:{artifactId:y,versionId:j}})},b[21]=y,b[22]=j,b[23]=m):m=b[23];let R=m,z=I===l.GenerationStatus.Generating,O=!!_&&_.length>0;b[24]!==I||b[25]!==O||b[26]!==z?(p=function({isGenerating:e,hasError:t,generationStatus:r}){return e?l.GenerationStatus.Generating:t||r===l.GenerationStatus.Failed?l.GenerationStatus.Failed:l.GenerationStatus.Success}({isGenerating:z,hasError:O,generationStatus:I}),b[24]=I,b[25]=O,b[26]=z,b[27]=p):p=b[27];let F=p;b[28]!==N?(f=[],N&&f.push(N),b[28]=N,b[29]=f):f=b[29];let D=S??"?";b[30]!==T||b[31]!==C?(h=function({parentVersionNumber:e,prompt:t}){return(0,ej.isDefinedAndNotNull)(e)?`From v${e}`:t?t.slice(0,120):void 0}({parentVersionNumber:T,prompt:C}),b[30]=T,b[31]=C,b[32]=h):h=b[32],b[33]!==A?(x={durationMs:A},b[33]=A,b[34]=x):x=b[34];let L="string"==typeof _?_:void 0;return b[35]!==y||b[36]!==R||b[37]!==M||b[38]!==z||b[39]!==j?(g=(0,er.jsx)(eD,{artifactId:y,versionId:j,isLoading:z,isActive:M,onOpen:R}),b[35]=y,b[36]=R,b[37]=M,b[38]=z,b[39]=j,b[40]=g):g=b[40],b[41]!==f||b[42]!==k||b[43]!==E||b[44]!==R||b[45]!==M||b[46]!==F||b[47]!==D||b[48]!==h||b[49]!==x||b[50]!==L||b[51]!==g?(v=(0,er.jsx)(ez,{versionNumber:D,status:F,isActive:M,subtitle:h,badges:f,stats:x,generationStartedAt:k,createdAtLabel:E,errorMessage:L,onSelect:R,onOpen:R,actions:g}),b[41]=f,b[42]=k,b[43]=E,b[44]=R,b[45]=M,b[46]=F,b[47]=D,b[48]=h,b[49]=x,b[50]=L,b[51]=g,b[52]=v):v=b[52],v},(e,t)=>e.artifactId===t.artifactId&&e.versionId===t.versionId);e.s(["VersionMessageCard",0,eL],967959);var eP=e.i(557225),eB=e.i(706527);let eV=[,,,,];function e$(){let e=eV[0]^eV[0]<<11;return eV[0]=eV[1],eV[1]=eV[2],eV[2]=eV[3],eV[3]=eV[3]^eV[3]>>19^e^e>>8,(eV[3]>>>0)/0x80000000}function eH(){return"hsl("+Math.floor(360*e$())+","+((60*e$()+40).toFixed(1)+"%")+","+((e$()+e$()+e$()+e$())*25).toFixed(1)+"%)"}let eU=Object.create(null);function eG(e){let{address:t,size:r=8,scale:n=10,caseSensitive:a=!1,defaultBackgroundColor:s="black"}=e,o=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);at.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r}(e,["address","size","scale","caseSensitive","defaultBackgroundColor"]),l=r*n,[i,c]=(0,eS.useState)(null),[d,u]=(0,eS.useState)(null);return(!a&&t&&(t=t.toLowerCase()),(0,eS.useEffect)(()=>{if(t)if(eU[t]&&eU[t].opts.size===r)c(eU[t].opts),u(eU[t].imageData);else{let e=function(e){var t=e.seed;eV.fill(0);for(let e=0;e{if(1===e){let e=a%r*n,s=Math.floor(a/r)*n;return(0,er.jsx)("rect",{width:n,height:n,x:e,y:s},`${t}-${a}`)}})})),(0,er.jsx)("g",Object.assign({fill:i.spotcolor},{children:null==d?void 0:d.map((e,a)=>{if(2===e){let e=a%r*n,s=Math.floor(a/r)*n;return(0,er.jsx)("rect",{width:n,height:n,x:e,y:s},`${t}-${a}`)}})}))]})):(0,er.jsx)("svg",Object.assign({},o,{width:l,height:l,viewBox:`0 0 ${l} ${l}`,xmlns:"http://www.w3.org/2000/svg"},{children:(0,er.jsx)("rect",{width:l,height:l,fill:"black"})})):(0,er.jsx)("svg",Object.assign({},o,{width:l,height:l,viewBox:`0 0 ${l} ${l}`,xmlns:"http://www.w3.org/2000/svg"},{children:(0,er.jsx)("rect",{width:l,height:l,fill:s})}))}let eq={};e.s(["ChatroomCharacterAvatar",0,e=>{let t,r,n,a=(0,K.c)(9),{character:s,className:o}=e,l=void 0===s?eq:s,i=void 0===o?"":o;return a[0]!==i?(t=(0,eu.cn)("flex items-center justify-center","size-6 shrink-0 rounded-full border border-border/50","bg-muted p-0.5",i),a[0]=i,a[1]=t):t=a[1],a[2]!==l.modelInfo||a[3]!==l.name||a[4]!==i?(r=!l.name&&l.modelInfo?.author?(0,er.jsx)(eP.AuthorIcon,{author:l.modelInfo.author,iconUri:l.modelInfo.author_icon_uri,className:i}):(0,er.jsx)(eG,{address:`${l.name}${l.modelInfo?(0,eB.getModelVariantSlug)(l.modelInfo):""}good`,defaultBackgroundColor:"var(--muted)",caseSensitive:!0,className:(0,eu.cn)("h-5 w-5 shrink-0 rounded-full border border-border/50 bg-muted",i)}),a[2]=l.modelInfo,a[3]=l.name,a[4]=i,a[5]=r):r=a[5],a[6]!==t||a[7]!==r?(n=(0,er.jsx)("div",{className:t,children:r}),a[6]=t,a[7]=r,a[8]=n):n=a[8],n}],562443),e.s(["NicknameTag",0,function(e){let t,r,n=(0,K.c)(5),{nickname:a,className:s}=e;return n[0]!==s?(t=(0,eu.cn)("min-w-0 shrink-0 truncate rounded-md px-1.5 py-0.5","bg-muted text-xs font-medium text-muted-foreground",s),n[0]=s,n[1]=t):t=n[1],n[2]!==a||n[3]!==t?(r=(0,er.jsx)("span",{className:t,children:a}),n[2]=a,n[3]=t,n[4]=r):r=n[4],r}],958924);var eW=e.i(646013),eK=e.i(174639),eJ=e.i(109917);e.i(530023);var eZ=e.i(612774),eY=e.i(784510),eX=e.i(197832),eQ=e.i(612960),e0=e.i(164588),e1=e.i(699937);let e2="w-8 h-8",e3="h-auto w-full justify-start gap-2 px-2 py-1.5";function e5(e){let t,r,n,a,s,o,l,i,c,d,u,m,p,f,h=(0,K.c)(47);h[0]!==e?({icon:a,tooltip:l,copyText:n,isSpinning:s,showLabel:o,"aria-label":t,...r}=e,h[0]=e,h[1]=t,h[2]=r,h[3]=n,h[4]=a,h[5]=s,h[6]=o,h[7]=l):(t=h[1],r=h[2],n=h[3],a=h[4],s=h[5],o=h[6],l=h[7]);let x=s&&"animate-spin ease-in-out";h[8]!==x?(i=(0,eu.cn)("w-4 h-4",x),h[8]=x,h[9]=i):i=h[9],h[10]!==a||h[11]!==i?(c=(0,er.jsx)("div",{className:i,children:a}),h[10]=a,h[11]=i,h[12]=c):c=h[12];let g=c,v="string"==typeof l?l:t;h[13]!==l?(d=(0,ej.isDefinedAndNotNull)(l)&&""!==l,h[13]=l,h[14]=d):d=h[14];let b=d,y=o&&"string"==typeof l?l:null;if(n){let e,t,a,s=o?"sm":"xs";h[15]!==r.className||h[16]!==o?(e=(0,eu.cn)(o?e3:(0,eu.cn)(e2,"p-1"),r.className),h[15]=r.className,h[16]=o,h[17]=e):e=h[17],h[18]!==v||h[19]!==n||h[20]!==g||h[21]!==y||h[22]!==s||h[23]!==e?(t=(0,er.jsx)(e4,{icon:g,getText:n,size:s,className:e,ariaLabel:v,label:y}),h[18]=v,h[19]=n,h[20]=g,h[21]=y,h[22]=s,h[23]=e,h[24]=t):t=h[24];let i=t;return h[25]!==i||h[26]!==b||h[27]!==o||h[28]!==l?(a=b&&!o?(0,er.jsx)(ep.Tooltip,{content:l,hoverable:!1,children:i}):i,h[25]=i,h[26]=b,h[27]=o,h[28]=l,h[29]=a):a=h[29],a}let j=o?"sm":"icon";h[30]!==r.className||h[31]!==o?(u=(0,eu.cn)(o?e3:(0,eu.cn)("p-1",e2),r.className),h[30]=r.className,h[31]=o,h[32]=u):u=h[32],h[33]!==y?(m=y?(0,er.jsx)("span",{className:"min-w-0 flex-1 truncate text-left text-sm",children:y}):null,h[33]=y,h[34]=m):m=h[34],h[35]!==v||h[36]!==r||h[37]!==g||h[38]!==j||h[39]!==u||h[40]!==m?(p=(0,er.jsxs)(eC.Button,{variant:"ghost",size:j,...r,"aria-label":v,className:u,children:[g,m]}),h[35]=v,h[36]=r,h[37]=g,h[38]=j,h[39]=u,h[40]=m,h[41]=p):p=h[41];let S=p;return h[42]!==S||h[43]!==b||h[44]!==o||h[45]!==l?(f=b&&!o?(0,er.jsx)(ep.Tooltip,{content:l,hoverable:!1,children:S}):S,h[42]=S,h[43]=b,h[44]=o,h[45]=l,h[46]=f):f=h[46],f}function e4(e){let t,r,n,a,s=(0,K.c)(15),{className:o,getText:l,icon:i,size:c,ariaLabel:d,label:u}=e,{isCopied:m,copyToClipboard:p}=(0,e0.useCopyToClipboard)();return s[0]!==p||s[1]!==l?(t=e=>{e.preventDefault(),p(l())},s[0]=p,s[1]=l,s[2]=t):t=s[2],s[3]!==i||s[4]!==m?(r=m?(0,er.jsx)(e1.Check,{className:"w-4 h-4 shrink-0"}):i,s[3]=i,s[4]=m,s[5]=r):r=s[5],s[6]!==u?(n=u?(0,er.jsx)("span",{className:"min-w-0 flex-1 truncate text-left text-sm",children:u}):null,s[6]=u,s[7]=n):n=s[7],s[8]!==d||s[9]!==o||s[10]!==c||s[11]!==t||s[12]!==r||s[13]!==n?(a=(0,er.jsxs)(eC.Button,{"aria-label":d,className:o,onClick:t,size:c,variant:"ghost",children:[r,n]}),s[8]=d,s[9]=o,s[10]=c,s[11]=t,s[12]=r,s[13]=n,s[14]=a):a=s[14],a}function e6({messageId:e,isRetrying:t}){let{getModelInfoByVariantSlug:r}=(0,eY.useGlobal)(),n=(0,eQ.useLocalizedRouter)(),a=(0,eS.useMemo)(i.makeSelectMessageById,[]),s=(0,q.useChatroomStore)(t=>a(t,e)),o=(0,q.useChatroomStore)(e=>e.artifacts[s?.type===l.MessageType.Assistant?s.artifactId??"":""]);return(0,er.jsx)(e5,{icon:(0,er.jsx)(eJ.ArrowPathIcon,{}),tooltip:"Regenerate",onClick:()=>{let t=(0,G.getCurrentRoomId)(),a=W(e),i=a?(0,eX.getTrimmedMessageContent)(a):"";if(!t||!i)return void(0,eZ.toast)({title:"Error",description:"Cannot regenerate: missing roomId or prompt.",variant:"destructive"});let c=s?.type===l.MessageType.Assistant?s.generatedArtifactType:l.ArtifactType.App;switch(c){case l.ArtifactType.Image:es.chatroomStoreActions.retryMessage({payload:{messageId:e,roomId:t}});break;case l.ArtifactType.App:es.chatroomStoreActions.generateArtifact({payload:{retryFromMessageId:e,roomId:t,name:o?.name??i,prompt:i,type:c},dependencies:{getModelInfoByVariantSlug:r,router:n}});break;case void 0:(0,eZ.toast)({title:"Error",description:"Unknown artifact type. Cannot regenerate.",variant:"destructive"});break;default:(0,en.assertNever)(c)}},disabled:t,isSpinning:t})}e.s(["ActionItem",0,e5],583603);var e7=e.i(543019),e8=e.i(561124);function e9(e){let t,r,n,a,s=(0,K.c)(9),[o,l]=(0,eS.useState)(!1);s[0]!==o?(t=()=>{if(!o)return;let e=()=>{l(!1)},t=setTimeout(()=>{document.addEventListener("click",e,{once:!0})},0);return()=>{clearTimeout(t),document.removeEventListener("click",e)}},r=[o],s[0]=o,s[1]=t,s[2]=r):(t=s[1],r=s[2]),(0,eS.useEffect)(t,r),s[3]!==e||s[4]!==o?(n=()=>{o?(e(),l(!1)):l(!0)},s[3]=e,s[4]=o,s[5]=n):n=s[5];let i=n;return s[6]!==i||s[7]!==o?(a={pendingDelete:o,handleDeleteClick:i},s[6]=i,s[7]=o,s[8]=a):a=s[8],a}function te({messageId:e}){let{getModelInfoByVariantSlug:t}=(0,eY.useGlobal)(),r=(0,eQ.useLocalizedRouter)(),n=(0,G.getCurrentRoomId)(),a=(0,eS.useMemo)(i.makeSelectMessageById,[]),s=(0,q.useChatroomStore)(t=>a(t,e)),o=(0,q.useChatroomStore)(t=>(0,e8.selectArtifactById)(t,{artifactId:e})),{pendingDelete:c,handleDeleteClick:d}=e9(()=>{n&&es.chatroomStoreActions.deleteArtifact({payload:{roomId:n,artifactId:e}})});return(0,er.jsxs)(er.Fragment,{children:[(0,er.jsx)(e5,{icon:(0,er.jsx)(eJ.ArrowPathIcon,{}),tooltip:"Regenerate",onClick:()=>{if(!n||!s||!s.parentMessageId||!s.characterId)return void(0,eZ.toast)({title:"Error",description:"Cannot regenerate: missing room, parent prompt, or model information.",variant:"destructive"});if(s.type!==l.MessageType.Assistant)return void(0,eZ.toast)({title:"Error",description:"Cannot regenerate this message type.",variant:"destructive"});let{parentMessageId:e,characterId:a}=s,i=q.useChatroomStore.getState().rooms[n]?.messages[e],c=i?.type===l.MessageType.User?i.content:"",d=q.useChatroomStore.getState().rooms[n]?.characters[a];if(!i||!c||!d)return void(0,eZ.toast)({title:"Error",description:"Cannot regenerate: original prompt content not found.",variant:"destructive"});let u=o?.type;switch(u){case l.ArtifactType.Image:es.chatroomStoreActions.retryMessage({payload:{roomId:n,messageId:i.id}});break;case l.ArtifactType.App:es.chatroomStoreActions.generateArtifact({payload:{retryFromMessageId:i.id,roomId:n,name:c.split("\n")[0]||"New Artifact",prompt:c,type:u,characterIds:[a]},dependencies:{getModelInfoByVariantSlug:t,router:r}});break;case void 0:(0,eZ.toast)({title:"Error",description:"Unknown artifact type. Cannot regenerate.",variant:"destructive"});break;default:(0,en.assertNever)(u)}},disabled:s?.type===l.MessageType.Assistant&&s.isGenerating,isSpinning:s?.type===l.MessageType.Assistant&&s.isGenerating}),(0,er.jsx)(e5,{icon:(0,er.jsx)(e7.TrashIcon,{}),tooltip:c?"Confirm delete":"Delete",onClick:d,variant:c?"destructive":"ghost"})]})}function tt(){return null}var tr=e.i(649188),tn=e.i(373855),ta=e.i(780314),ts=e.i(553215),to=e.i(252358),tl=e.i(169133),ti=e.i(528783);function tc(e,t=0){let r=e.replaceAll(/[^a-zA-Z0-9_-]+/g,"-").replaceAll(/^-+|-+$/g,""),n=t>0?`-${t}`:"";return`openrouter-video-${r||"generated"}${n}.mp4`}var td=e.i(735961);function tu(e){let t=q.useChatroomStore.getState(),r=t.currentRoomId;if(!r)return"";let n=t.rooms[r]?.messages[e],a=td.useItemStore.getState().items;return n?tm(n,a):""}function tm(e,t){if(!Array.isArray(e.items))return"";let r=e.items,n=e.type===l.MessageType.Assistant?[...r].sort((e,t)=>(e.outputIndex??0)-(t.outputIndex??0)):r,a=[];for(let e of n){let r=t[e.id];if(!r||"message"!==r.data.type||!Array.isArray(r.data.content))continue;let n=r.data.content.map(e=>"input_text"===e.type||"output_text"===e.type?e.text:"").filter(Boolean).join("");n.trim()&&a.push(n)}return a.join("\n\n")}e.s(["getMessageTextContent",0,tu,"getMessageTextContentFromItems",0,tm],558884);var tp=e.i(660298),tf=e.i(885686),th=e.i(50157),tx=e.i(778084),tg=e.i(360951),tv=e.i(150592),tb=e.i(558956),ty=e.i(379684),tj=e.i(864160),tS=e.i(839669),tw=e.i(779100),tN=e.i(196948),tC=e.i(190557);function tI(e){let t,r,n,a,s,o,l,i,c,d,u=(0,K.c)(33),{selectedProvider:m,routerMetadata:p,tokensPerSecond:f,tokensCount:h,reasoningDuration:x,cost:g,duration:v}=e,b=(0,tw.useLocale)();if(!function({selectedProvider:e,routerMetadata:t,tokensPerSecond:r,tokensCount:n,reasoningDuration:a,cost:s,duration:o}){return!!(e||t?.strategy||t?.region||r||n||a||s||o||t&&t.attempt>1)}({selectedProvider:m,routerMetadata:p,tokensPerSecond:f,tokensCount:h,reasoningDuration:x,cost:g,duration:v})){let e;return u[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,er.jsx)("p",{className:"text-sm text-muted-foreground",children:"No generation data available. Metadata is only captured for successful completions."}),u[0]=e):e=u[0],e}return u[1]!==m?(t=m&&(0,er.jsxs)("span",{className:"flex justify-between gap-4",children:[(0,er.jsx)(tb.Label,{className:"w-32",children:"Provider"}),(0,er.jsx)("span",{className:"font-medium",children:m})]}),u[1]=m,u[2]=t):t=u[2],u[3]!==p?(r=p?.strategy&&(0,er.jsxs)("span",{className:"flex justify-between gap-4",children:[(0,er.jsx)(tb.Label,{className:"w-32",children:"Strategy"}),(0,er.jsx)("span",{className:"font-medium",children:p.strategy})]}),u[3]=p,u[4]=r):r=u[4],u[5]!==p?(n=p?.region&&(0,er.jsxs)("span",{className:"flex justify-between gap-4",children:[(0,er.jsx)(tb.Label,{className:"w-32",children:"Region"}),(0,er.jsx)("span",{className:"font-medium",children:p.region})]}),u[5]=p,u[6]=n):n=u[6],u[7]!==b||u[8]!==f?(a=f&&(0,er.jsxs)("span",{className:"flex justify-between gap-4",children:[(0,er.jsx)(tb.Label,{className:"w-32",children:"Tokens per second"}),(0,er.jsxs)("span",{children:[(0,er.jsxs)("b",{className:"font-medium",children:["~",(0,tN.formatFixed)(f??0,{locale:b,fractionDigits:1})??"—"]})," ","tokens/s"]})]}),u[7]=b,u[8]=f,u[9]=a):a=u[9],u[10]!==h?(s=h&&(0,er.jsxs)("span",{className:"flex justify-between gap-4",children:[(0,er.jsx)(tb.Label,{className:"w-32",children:"Token count"}),(0,er.jsxs)("span",{children:[(0,er.jsx)("b",{className:"font-medium",children:h})," tokens"]})]}),u[10]=h,u[11]=s):s=u[11],u[12]!==b||u[13]!==x?(o=x&&(0,er.jsxs)("span",{className:"flex justify-between gap-4",children:[(0,er.jsx)(tb.Label,{className:"w-32",children:"Reasoning time"}),(0,er.jsxs)("span",{children:[(0,er.jsx)("b",{className:"font-medium",children:(0,tN.formatFixed)(x/1e3,{locale:b,fractionDigits:1})??"—"}),"s"]})]}),u[12]=b,u[13]=x,u[14]=o):o=u[14],u[15]!==g||u[16]!==b?(l=g&&(0,er.jsxs)("span",{className:"flex justify-between gap-4",children:[(0,er.jsx)(tb.Label,{className:"w-32",children:"Cost"}),(0,er.jsx)("span",{children:(0,er.jsx)("b",{className:"font-medium",children:(0,tC.formatUsd)(g,{locale:b,preset:"metadata-cost"})??"—"})})]}),u[15]=g,u[16]=b,u[17]=l):l=u[17],u[18]!==v||u[19]!==b?(i=v&&(0,er.jsxs)("span",{className:"flex justify-between gap-4",children:[(0,er.jsx)(tb.Label,{className:"w-32",children:"Duration"}),(0,er.jsxs)("span",{children:[(0,er.jsx)("b",{className:"font-medium",children:(0,tN.formatFixed)((v??0)/1e3,{locale:b,fractionDigits:1})??"—"}),"s"]})]}),u[18]=v,u[19]=b,u[20]=i):i=u[20],u[21]!==p?(c=p&&p.attempt>1&&(0,er.jsxs)("span",{className:"flex justify-between gap-4",children:[(0,er.jsx)(tb.Label,{className:"w-32",children:"Attempts"}),(0,er.jsx)("span",{className:"font-medium",children:p.attempt})]}),u[21]=p,u[22]=c):c=u[22],u[23]!==t||u[24]!==r||u[25]!==n||u[26]!==a||u[27]!==s||u[28]!==o||u[29]!==l||u[30]!==i||u[31]!==c?(d=(0,er.jsxs)("div",{className:"text-sm flex flex-col gap-2",children:[t,r,n,a,s,o,l,i,c]}),u[23]=t,u[24]=r,u[25]=n,u[26]=a,u[27]=s,u[28]=o,u[29]=l,u[30]=i,u[31]=c,u[32]=d):d=u[32],d}function t_({messageId:e}){let t=(0,eS.useMemo)(i.makeSelectMessageById,[]),r=(0,q.useChatroomStore)(r=>t(r,e)),n=(0,tS.usePostHog)(),a=(0,tj.useUserStore)(e=>e.entity?.clerk_user_id);if(!r||r.type!==l.MessageType.Assistant)return null;let{duration:s,tokensPerSecond:o,tokensCount:c,reasoningDuration:d,cost:u,generationId:m,variantSlug:p,routerMetadata:f}=r.metadata??{},h=function({generationId:e,variantSlug:t,clerkUserId:r}){if(e)return`/logs?generation_ids=${encodeURIComponent(e)}`;let n=new URLSearchParams;if(r&&n.set("user_id",r),t&&n.set("model_slug",t),0!==n.size)return`/logs?${n.toString()}`}({generationId:m,variantSlug:p,clerkUserId:a}),x=f?.pipeline?f.pipeline.filter(e=>"guardrail"===e.type):[],g=function(e){if(!e?.endpoints?.available)return;let t=e.endpoints.available.find(e=>e.selected);return t?.provider}(f);return(0,er.jsx)(tx.PopoverContent,{side:"top",className:"w-80",children:(0,er.jsxs)("div",{className:"my-2 flex flex-col gap-2",children:[(0,er.jsx)(tI,{selectedProvider:g,routerMetadata:f,tokensPerSecond:o,tokensCount:c,reasoningDuration:d,cost:u,duration:s}),x.length>0&&(0,er.jsxs)(er.Fragment,{children:[(0,er.jsx)("hr",{className:"my-1"}),(0,er.jsxs)("div",{className:"text-sm flex flex-col gap-1",children:[(0,er.jsx)(tb.Label,{className:"text-xs text-muted-foreground",children:"Guardrails"}),x.map(e=>{let t=function(e){if(!e.guardrail_id&&!e.guardrail_scope)return;let t=new URLSearchParams;return e.guardrail_id&&t.set("guardrail_guardrail_id",e.guardrail_id),e.guardrail_scope&&t.set("guardrail_scope",e.guardrail_scope),t.set("guardrail_outcome","blocked,redacted,flagged"),`/logs?${t.toString()}`}(e);return(0,er.jsxs)("span",{className:"flex items-center gap-1.5 text-xs",children:[(0,er.jsx)(tv.ShieldCheckIcon,{className:"h-3.5 w-3.5 shrink-0"}),(0,er.jsx)("span",{className:"truncate",children:e.name}),t&&(0,er.jsx)(ty.TextLink,{href:t,className:"shrink-0 no-underline text-xs",onClick:()=>n.capture(ts.PostHogEvent.ClickMetadataGuardrailLink,{guardrail_id:e.guardrail_id,guardrail_name:e.name}),children:(0,er.jsx)(tg.ArrowTopRightOnSquareIcon,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},`${e.guardrail_id??""}-${e.guardrail_scope??""}-${e.name}`)})]})]}),(0,er.jsx)("hr",{className:"my-1"}),(0,er.jsxs)("div",{className:"flex items-center justify-between",children:[(0,er.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Token count is estimated. Visit"," ",h?(0,er.jsx)(ty.TextLink,{href:h,onClick:()=>n.capture(ts.PostHogEvent.ClickMetadataLogsLink,{generation_id:m,model:p}),children:"your logs"}):(0,er.jsx)(ty.TextLink,{href:"/activity",children:"the activity page"})," ","for exact charges."]}),h&&(0,er.jsx)(ep.Tooltip,{content:"View in logs",children:(0,er.jsx)(ty.TextLink,{href:h,className:"ml-2 shrink-0 no-underline text-xs",onClick:()=>n.capture(ts.PostHogEvent.ClickMetadataLogsLink,{generation_id:m,model:p}),children:(0,er.jsx)(tg.ArrowTopRightOnSquareIcon,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})})]})]})})}function tk({messageId:e,showLabel:t=!1}){let r=(0,eS.useMemo)(i.makeSelectMessageById,[]),n=(0,q.useChatroomStore)(t=>r(t,e));return n&&n.type===l.MessageType.Assistant?(0,er.jsxs)(tx.Popover,{children:[t?(0,er.jsx)(tx.PopoverTrigger,{render:(0,er.jsxs)(eC.Button,{variant:"ghost",size:"sm",className:"h-auto w-full justify-start gap-2 px-2 py-1.5","aria-label":"Metadata",children:[(0,er.jsx)("div",{className:"h-4 w-4",children:(0,er.jsx)(th.ChartBarIcon,{className:"text-muted-foreground"})}),(0,er.jsx)("span",{className:"text-sm",children:"Metadata"})]})}):(0,er.jsx)(ep.Tooltip,{content:"Metadata",children:(0,er.jsx)(tx.PopoverTrigger,{render:(0,er.jsx)(eC.Button,{variant:"ghost",size:"icon",className:"h-8 w-8 p-1","aria-label":"Metadata",children:(0,er.jsx)("div",{className:"h-4 w-4",children:(0,er.jsx)(th.ChartBarIcon,{className:"text-muted-foreground"})})})})}),(0,er.jsx)(t_,{messageId:e})]}):null}e.s(["MessageMetadataPopoverContent",0,t_],94814),e.i(634160);var tA=e.i(488554);e.s(["VIDEO_CACHE_ANSWER_TIMEOUT_MS",0,3e3],797530);function tM(e,t,r=!1){let n=document.createElement("a");n.href=e,n.download=t,n.style.visibility="hidden",document.body.append(n),n.click(),n.remove(),r&&setTimeout(()=>URL.revokeObjectURL(e),4e4)}function tT({messageId:e,isRetrying:t,isGenerating:n,setIsEditing:a,hideRetry:s=!1,hideCopy:o=!1,primaryOnly:c=!1,showLabels:d=!1,hideEdit:u=!1,hideDelete:m=!1}){let p=(0,G.getCurrentRoomId)(),f=(0,eS.useMemo)(i.makeSelectMessageById,[]),h=(0,q.useChatroomStore)(t=>f(t,e)),x=(0,td.useItemStore)(e=>(function(e,t){if(!e||!Array.isArray(e.items))return null;for(let r of e.items){let e=t[r.id]?.data;if(e?.type===tf.VIDEO_GENERATION_CALL_TYPE&&"completed"===e.status)return e.jobId}return null})(h,e.items)),g=(0,to.usePosthogClient)(),v=function({jobId:e,onDownloaded:t}){return{saveFromCache:n=>{if(null===e)return;let a=tc(e),s=!1,o=()=>{s||(s=!0,tM((0,ti.buildVideoContentUrl)(e),a),t("api"))},l=setTimeout(o,3e3),i=async()=>{let n=await (0,r.wrap)(()=>(0,tA.hasCachedVideo)(e));if(clearTimeout(l),s)return;if((0,r.isErr)(n)||!n.data)return void o();let i=await (0,r.wrap)(()=>(0,tA.readCachedVideo)(e));if(!s){if((0,r.isErr)(i)||!i.data)return void o();s=!0,tM(URL.createObjectURL(i.data),a,!0),t("cache")}};n.preventDefault(),i()}}}({jobId:x,onDownloaded:e=>{g.capture(ts.PostHogEvent.DownloadChatVideo,{job_id:x,source:e})}}),b=h?.type===l.MessageType.Assistant?h.metadata?.generationId??"":"",y=h?.type===l.MessageType.Assistant&&h.metadata?.isFusionResponse===!0,{pendingDelete:j,handleDeleteClick:S}=e9(()=>{p&&es.chatroomStoreActions.removeMessage({payload:{messageId:e,roomId:p}})}),w=t||n,N=!s&&(0,er.jsx)(e5,{icon:(0,er.jsx)(eJ.ArrowPathIcon,{}),tooltip:"Retry",onClick:()=>{p&&es.chatroomStoreActions.retryMessage({payload:{messageId:e,roomId:p}})},disabled:w,isSpinning:w,showLabel:d}),C=!o&&(0,er.jsx)(e5,{icon:(0,er.jsx)(ta.Square2StackIcon,{}),tooltip:"Copy",copyText:()=>tu(e),showLabel:d}),I=!u&&(0,er.jsx)(e5,{icon:(0,er.jsx)(tn.PencilIcon,{}),tooltip:"Edit",onClick:()=>a(!0),showLabel:d}),_=!m&&(0,er.jsx)(e5,{icon:(0,er.jsx)(e7.TrashIcon,{}),tooltip:j?"Confirm delete":"Delete","aria-label":"Delete",onClick:S,variant:j?"destructive":"ghost",showLabel:d}),k=null!==x&&(0,er.jsx)(e5,{icon:(0,er.jsx)(tr.ArrowDownTrayIcon,{}),tooltip:(0,er.jsx)("span",{children:"Download to keep a copy. Generated videos are kept only by the provider and by this browser, and both drop them."}),"aria-label":"Download video",onClick:e=>{v.saveFromCache(e)},render:(0,er.jsx)("a",{href:(0,ti.buildVideoContentUrl)(x),download:tc(x)})});return c?(0,er.jsxs)(er.Fragment,{children:[N,C,I,_,k]}):(0,er.jsxs)(er.Fragment,{children:[N,C,I,y&&!n&&(0,er.jsx)(e5,{icon:(0,er.jsx)(tr.ArrowDownTrayIcon,{}),tooltip:"Download as Markdown",onClick:()=>{let t=tu(e);if(!t)return;let r=h?.createdAt?new Date(h.createdAt).toISOString().slice(0,10):new Date().toISOString().slice(0,10);(0,tp.downloadMarkdown)(t,{name:"fusion-response",date:r})},showLabel:d}),(0,er.jsx)(tk,{messageId:e,showLabel:d}),(0,er.jsx)(tl.ReportFeedbackButton,{variant:"icon",generationId:b,showLabel:d}),_]})}let tE=null;function tR(e,t){var r,n,a;let s,o,l,i,c,d,u=document.querySelector(`[data-message-id="${e}"]`);if(!u)return;let m=function(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t).overflowY;if("auto"===e||"scroll"===e||"overlay"===e)return t;t=t.parentElement}return null}(u);if(!m)return void u.scrollIntoView({behavior:"smooth",block:t});let p=function(e,t,r){if("start"===r)return"start";let n=tO(e);return e.getBoundingClientRect().height+n.topPx+n.bottomPx>t.clientHeight?"end":"start"}(u,m,t);if(tE?.(),globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches){m.scrollTop=tz(m,u,p);return}r=m,n=u,a=p,s=new AbortController,o=0,l=null,i=0,tE=c=()=>{globalThis.cancelAnimationFrame(o),s.abort(),tE===c&&(tE=null)},r.addEventListener("wheel",c,{passive:!0,signal:s.signal}),r.addEventListener("touchstart",c,{passive:!0,signal:s.signal}),o=globalThis.requestAnimationFrame(d=e=>{if(!n.isConnected)return void c();null===l&&(l=e,i=e);let t=tz(r,n,a),s=t-r.scrollTop;if(1>=Math.abs(s)||e-l>=2500){r.scrollTop=t,c();return}let u=1-Math.exp(-(e-i)/120);i=e;let m=s*u;r.scrollTop+=1>Math.abs(m)?+Math.sign(s):m,o=globalThis.requestAnimationFrame(d)})}function tz(e,t,r){let n=e.getBoundingClientRect(),a=t.getBoundingClientRect(),s=tO(t),o=n.top+e.clientTop,l="start"===r?a.top-s.topPx-o:a.bottom+s.bottomPx-(o+e.clientHeight),i=Math.max(0,e.scrollHeight-e.clientHeight);return Math.min(Math.max(e.scrollTop+l,0),i)}function tO(e){let t=getComputedStyle(e);return{topPx:Number.parseFloat(t.scrollMarginTop)||0,bottomPx:Number.parseFloat(t.scrollMarginBottom)||0}}function tF({messageId:e,isRetrying:t}){let r=(0,eS.useMemo)(i.makeSelectMessageById,[]),n=(0,q.useChatroomStore)(t=>r(t,e));return(0,er.jsx)(e5,{icon:(0,er.jsx)(eJ.ArrowPathIcon,{}),tooltip:"Retry",onClick:()=>{let e=(0,G.getCurrentRoomId)(),t=q.useChatroomStore.getState();if(!e||!n)return void(0,eZ.toast)({title:"Error",description:"Cannot retry: missing room or message context.",variant:"destructive"});let r=Object.values(t.rooms[e]?.messages??{}).find(e=>e.parentMessageId===n.id&&e.type===l.MessageType.Assistant),a=r?.type===l.MessageType.Assistant?r.artifactId:void 0;if(!a)return void(0,eZ.toast)({title:"Error",description:"Could not find the artifact associated with this prompt.",variant:"destructive"});let s=r?.type===l.MessageType.Assistant?r.versionContextId:void 0;s?es.chatroomStoreActions.retryArtifactVersion({payload:{roomId:e,artifactId:a,versionId:s}}):(0,eZ.toast)({title:"Error",description:"Could not find the artifact version generated by this prompt.",variant:"destructive"})},disabled:t,isSpinning:t})}e.s(["scrollMessageToEdge",0,tR],533515);var tD=e.i(936608);function tL(e){let t,r,n,a,s,o,l,i,c,d=(0,K.c)(35),{messageId:u,isRetrying:m,setIsEditing:p,hideRetry:f,hideCopy:h,hideEdit:x,hideDelete:g,hideCopyCode:v,showLabels:b}=e,y=void 0!==f&&f,j=void 0!==h&&h,S=void 0!==x&&x,w=void 0!==g&&g,N=void 0!==v&&v,C=void 0!==b&&b;d[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,G.getCurrentRoomId)(),d[0]=t):t=d[0];let I=t;d[1]!==u?(r=()=>{I&&es.chatroomStoreActions.retryMessage({payload:{messageId:u,roomId:I}})},d[1]=u,d[2]=r):r=d[2];let _=r;d[3]!==u?(n=()=>{I&&es.chatroomStoreActions.removeMessage({payload:{messageId:u,roomId:I}})},d[3]=u,d[4]=n):n=d[4];let{pendingDelete:k,handleDeleteClick:A}=e9(n),M=k?"Confirm delete":"Delete";return d[5]!==_||d[6]!==y||d[7]!==m||d[8]!==C?(a=!y&&(0,er.jsx)(e5,{icon:(0,er.jsx)(eJ.ArrowPathIcon,{}),tooltip:"Retry",onClick:_,disabled:m,isSpinning:m,showLabel:C}),d[5]=_,d[6]=y,d[7]=m,d[8]=C,d[9]=a):a=d[9],d[10]!==j||d[11]!==u||d[12]!==C?(s=!j&&(0,er.jsx)(e5,{icon:(0,er.jsx)(ta.Square2StackIcon,{}),tooltip:"Copy",copyText:()=>tu(u),showLabel:C}),d[10]=j,d[11]=u,d[12]=C,d[13]=s):s=d[13],d[14]!==S||d[15]!==m||d[16]!==p||d[17]!==C?(o=!S&&(0,er.jsx)(e5,{icon:(0,er.jsx)(tn.PencilIcon,{}),tooltip:"Edit",onClick:()=>p(!0),disabled:m,showLabel:C}),d[14]=S,d[15]=m,d[16]=p,d[17]=C,d[18]=o):o=d[18],d[19]!==N||d[20]!==u||d[21]!==C?(l=!N&&(0,er.jsx)(e5,{icon:(0,er.jsx)(ei.CodeBracketIcon,{}),tooltip:"Copy Code",showLabel:C,copyText:()=>{let e=W(u),t=e?(0,eX.getTrimmedMessageContent)(e):"";return(0,tD.getFetchExample)({prompt:t??""})}}),d[19]=N,d[20]=u,d[21]=C,d[22]=l):l=d[22],d[23]!==M||d[24]!==A||d[25]!==w||d[26]!==k||d[27]!==C?(i=!w&&(0,er.jsx)(e5,{icon:(0,er.jsx)(e7.TrashIcon,{}),tooltip:M,"aria-label":"Delete",onClick:A,variant:k?"destructive":"ghost",showLabel:C}),d[23]=M,d[24]=A,d[25]=w,d[26]=k,d[27]=C,d[28]=i):i=d[28],d[29]!==a||d[30]!==s||d[31]!==o||d[32]!==l||d[33]!==i?(c=(0,er.jsxs)(er.Fragment,{children:[a,s,o,l,i]}),d[29]=a,d[30]=s,d[31]=o,d[32]=l,d[33]=i,d[34]=c):c=d[34],c}function tP(e){let t=(0,K.c)(16),{message:r,messageId:n,isRetrying:a,setIsEditing:s,hideRetry:o,hideCopy:i,hideEdit:c,hideDelete:d,hideCopyCode:u,showLabels:m}=e,p=void 0!==o&&o,f=void 0!==i&&i,h=void 0!==c&&c,x=void 0!==d&&d,g=void 0!==u&&u,v=void 0!==m&&m;switch(r.contentType){case l.ContentType.Artifact:{let e;return t[0]!==a||t[1]!==n?(e=(0,er.jsx)(e6,{messageId:n,isRetrying:a}),t[0]=a,t[1]=n,t[2]=e):e=t[2],e}case l.ContentType.ArtifactVersion:{let e;return t[3]!==a||t[4]!==n?(e=(0,er.jsx)(tF,{messageId:n,isRetrying:a}),t[3]=a,t[4]=n,t[5]=e):e=t[5],e}case l.ContentType.Text:case void 0:{let e;return t[6]!==f||t[7]!==g||t[8]!==x||t[9]!==h||t[10]!==p||t[11]!==a||t[12]!==n||t[13]!==s||t[14]!==v?(e=(0,er.jsx)(tL,{messageId:n,isRetrying:a,setIsEditing:s,hideRetry:p,hideCopy:f,hideEdit:h,hideDelete:x,hideCopyCode:g,showLabels:v}),t[6]=f,t[7]=g,t[8]=x,t[9]=h,t[10]=p,t[11]=a,t[12]=n,t[13]=s,t[14]=v,t[15]=e):e=t[15],e}default:(0,en.assertNever)(r.contentType)}}function tB(e){let t=(0,K.c)(14),{message:r,messageId:n,isRetrying:a,isGenerating:s,setIsEditing:o,hideRetry:i,hideCopy:c,hideEdit:d,hideDelete:u,primaryOnly:m,showLabels:p}=e,f=void 0!==i&&i,h=void 0!==c&&c,x=void 0!==d&&d,g=void 0!==u&&u,v=void 0!==m&&m,b=void 0!==p&&p;switch(r.contentType){case l.ContentType.Artifact:{let e;return t[0]!==n?(e=(0,er.jsx)(te,{messageId:n}),t[0]=n,t[1]=e):e=t[1],e}case l.ContentType.ArtifactVersion:{let e;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,er.jsx)(tt,{}),t[2]=e):e=t[2],e}case l.ContentType.Text:case void 0:{let e;return t[3]!==h||t[4]!==g||t[5]!==x||t[6]!==f||t[7]!==s||t[8]!==a||t[9]!==n||t[10]!==v||t[11]!==o||t[12]!==b?(e=(0,er.jsx)(tT,{messageId:n,isRetrying:a,isGenerating:s,setIsEditing:o,hideRetry:f,hideCopy:h,hideEdit:x,hideDelete:g,primaryOnly:v,showLabels:b}),t[3]=h,t[4]=g,t[5]=x,t[6]=f,t[7]=s,t[8]=a,t[9]=n,t[10]=v,t[11]=o,t[12]=b,t[13]=e):e=t[13],e}default:(0,en.assertNever)(r.contentType)}}function tV(e){let t=(0,K.c)(24),{message:r,messageId:n,isRetrying:a,isGenerating:s,setIsEditing:o,hideRetry:i,hideCopy:c,hideEdit:d,hideDelete:u,hideCopyCode:m,primaryOnly:p,showLabels:f}=e,h=void 0!==i&&i,x=void 0!==c&&c,g=void 0!==d&&d,v=void 0!==u&&u,b=void 0!==m&&m,y=void 0!==p&&p,j=void 0!==f&&f,S=r.type;switch(S){case l.MessageType.User:{let e;return t[0]!==x||t[1]!==b||t[2]!==v||t[3]!==g||t[4]!==h||t[5]!==s||t[6]!==a||t[7]!==r||t[8]!==n||t[9]!==o||t[10]!==j?(e=(0,er.jsx)(tP,{message:r,messageId:n,isRetrying:a,isGenerating:s,setIsEditing:o,hideRetry:h,hideCopy:x,hideEdit:g,hideDelete:v,hideCopyCode:b,showLabels:j}),t[0]=x,t[1]=b,t[2]=v,t[3]=g,t[4]=h,t[5]=s,t[6]=a,t[7]=r,t[8]=n,t[9]=o,t[10]=j,t[11]=e):e=t[11],e}case l.MessageType.Assistant:{let e;return t[12]!==x||t[13]!==v||t[14]!==g||t[15]!==h||t[16]!==s||t[17]!==a||t[18]!==r||t[19]!==n||t[20]!==y||t[21]!==o||t[22]!==j?(e=(0,er.jsx)(tB,{message:r,messageId:n,isRetrying:a,isGenerating:s,setIsEditing:o,hideRetry:h,hideCopy:x,hideEdit:g,hideDelete:v,primaryOnly:y,showLabels:j}),t[12]=x,t[13]=v,t[14]=g,t[15]=h,t[16]=s,t[17]=a,t[18]=r,t[19]=n,t[20]=y,t[21]=o,t[22]=j,t[23]=e):e=t[23],e}case l.MessageType.System:return null;default:(0,en.assertNever)(S)}}e.s(["MessageActions",0,function({messageId:e,setIsEditing:t,isCompact:r=!1,hideRetry:n=!1,hideCopy:a=!1,hideEdit:s=!1,hideDelete:o=!1,hideCopyCode:c=!1,hideScrollToTop:d=!1,orientation:u="horizontal",primaryOnly:m=!1,showLabels:p=!1}){let f=(0,eS.useMemo)(i.makeSelectMessageById,[]),h=(0,q.useChatroomStore)(t=>f(t,e)),[x,g]=(0,eS.useState)(!1);(0,eS.useEffect)(()=>{let t=document.querySelector(`[data-message-id="${e}"]`);if(!t)return;let r=()=>{g(t.querySelectorAll("details").length>0)};r();let n=new MutationObserver(r);return n.observe(t,{childList:!0,subtree:!0}),()=>n.disconnect()},[e]);let v=(0,eS.useCallback)(()=>{let t=document.querySelector(`[data-message-id="${e}"]`);if(!t)return;let r=t.querySelectorAll("details");if(0===r.length)return;let n=[...r].some(e=>!e.open);r.forEach(e=>{e.open=n})},[e]),b=(0,eS.useCallback)(()=>{tR(e,"start")},[e]);if(!h)return null;let y=h.type===l.MessageType.User,j=h.isRetrying??!1,S=h.type===l.MessageType.Assistant&&(h.isGenerating??!1),w="vertical"===u;return(0,er.jsxs)("div",{className:(0,eu.cn)("flex","gap-0.5",w?"flex-col items-stretch":"items-center",!r&&!w&&(y?"md:justify-end":"md:justify-start")),children:[(0,er.jsx)(tV,{message:h,messageId:e,isRetrying:j,isGenerating:S,setIsEditing:t,hideRetry:n,hideCopy:a,hideEdit:s,hideDelete:o,hideCopyCode:c,primaryOnly:m,showLabels:p}),!r&&!w&&!m&&(0,er.jsx)("div",{className:"flex-1"}),!w&&!d&&(r||m)&&(0,er.jsx)("div",{className:"mx-1 h-5 w-px bg-border","aria-hidden":"true"}),!m&&x&&(0,er.jsx)(e5,{icon:(0,er.jsx)(eK.ChevronUpDownIcon,{}),tooltip:"Toggle sections",onClick:v,showLabel:p}),!d&&(0,er.jsx)(e5,{icon:(0,er.jsx)(eW.ArrowUpIcon,{}),tooltip:"Scroll to top",onClick:b,showLabel:p})]})}],23259);var t$=e.i(21053);e.s(["useAlwaysExpandMessages",0,function(){return(0,t$.usePersistedBoolean)("openrouter:chat-always-expand-messages",!1)}],735729)},250855,e=>{"use strict";var t=e.i(321801),r=e.i(22022),n=e.i(295654);e.i(798823);var a=e.i(429930),s=e.i(693946);let o=(e,t)=>t,l=(e,t,r)=>r,i=(e,t)=>e.length===t.length&&e.every((e,r)=>e===t[r]),c=()=>(0,t.createSelector)([s.selectCurrentMessages,o],(e,t)=>e[t]??null),d=(0,t.createSelector)([e=>e],e=>e?.type===a.MessageType.User?e?.attachments??[]:[]),u=s.selectCurrentSortedMessageIds,m=(0,t.createSelector)([u],e=>e.length>0),p=(0,t.createSelector)([s.selectCurrentSortedMessageIds,s.selectCurrentMessages,s.selectCurrentCharacters],(e,t,r)=>e.filter(e=>{let n=t[e];if(!n||n.context&&n.context!==a.MessageContext.MainChat)return!1;if(n.type===a.MessageType.Assistant){let e=r?.[n.characterId];return!e?.isDisabled}return!0}),{memoize:t.lruMemoize,memoizeOptions:{resultEqualityCheck:i}}),f=(0,t.createSelector)([p,s.selectCurrentMessages],function(e,t){let r=[],n=[],s=()=>{n.length>0&&(r.push({kind:"assistant-group",ids:n}),n=[])};for(let o of e){if(t[o]?.type===a.MessageType.Assistant){n.push(o);continue}s(),r.push({kind:"standalone",id:o})}return s(),r},{memoize:t.lruMemoize,memoizeOptions:{resultEqualityCheck:(e,t)=>e.length===t.length&&e.every((e,r)=>{let n=t[r];return!!n&&e.kind===n.kind&&("standalone"===e.kind&&"standalone"===n.kind?e.id===n.id:"assistant-group"===e.kind&&"assistant-group"===n.kind&&i(e.ids,n.ids))})}});e.s(["makeSelectCharacterIsDisabled",0,()=>(0,t.createSelector)([(0,t.createSelector)([s.selectCurrentCharacters,c()],(e,t)=>t?t.type===a.MessageType.User?n.userCharacter:t.type===a.MessageType.System?n.systemCharacter:e?.[t.characterId]??n.deletedCharacter:n.deletedCharacter)],e=>e.isDisabled),"makeSelectDisplayCharacterByMessageId",0,()=>(0,t.createSelector)([s.selectCurrentCharacters,c(),l],(e,t,s)=>{if(!t)return n.deletedCharacter;if(t.type===a.MessageType.User)return n.userCharacter;if(t.type===a.MessageType.System)return n.systemCharacter;let o=e?.[t.characterId];if(!o)return n.deletedCharacter;if(t.metadata?.isFusionResponse)return o;let l=t.metadata?.variantSlug;if(s&&l){let e=s(l);if(e?.endpoint||e&&(0,r.isChromeGeminiNanoModelSlug)(l))return{...o,model:e.endpoint?.model_variant_slug??e.slug,modelInfo:e}}return o}),"makeSelectFusionRespondingModelByMessageId",0,()=>(0,t.createSelector)([c()],e=>{if(e?.type===a.MessageType.Assistant&&e.metadata?.isFusionResponse)return e.metadata.variantSlug}),"makeSelectMessageById",0,c,"makeSelectServerToolEnginesByMessageId",0,()=>(0,t.createSelector)([c()],e=>e?.type!==a.MessageType.Assistant?null:e.metadata?.serverTools??null),"selectAttachmentsByMessageId",0,d,"selectHasMessages",0,m,"selectVisibleMessageBlocks",0,f,"selectVisibleSortedMessageIds",0,p])},570115,e=>{"use strict";var t=e.i(948810),r=e.i(639241),n=e.i(621036);let a={List:"list",Fanned:"fanned"},s=(0,t.create)()((0,r.persist)(e=>({layout:a.List,setLayout:t=>e({layout:t})}),{name:"playground-responses-layout",version:1,storage:(0,r.createJSONStorage)(n.createSafeLocalStorage),partialize:e=>({layout:e.layout})}));e.s(["ResponsesLayout",0,a,"useResponsesLayoutStore",0,s])},797913,e=>{"use strict";var t=e.i(505962);let r=(0,e.i(948810).create)()(e=>({isSelectionMode:!1,selectedRoomIds:new Set,enterSelectionMode:()=>e({isSelectionMode:!0}),exitSelectionMode:()=>e({isSelectionMode:!1,selectedRoomIds:new Set}),toggleRoom:t=>e(e=>{let r=new Set(e.selectedRoomIds);return r.has(t)?r.delete(t):r.add(t),{selectedRoomIds:r}}),selectAll:t=>e({selectedRoomIds:new Set(t)}),selectMany:t=>e(e=>{let r=new Set(e.selectedRoomIds);for(let e of t)r.add(e);return{selectedRoomIds:r}}),clear:()=>e({selectedRoomIds:new Set}),clearMany:t=>e(e=>{let r=new Set(e.selectedRoomIds);for(let e of t)r.delete(e);return{selectedRoomIds:r}})}));function n(e){return e.isSelectionMode}function a(e){return e.selectedRoomIds.size}e.s(["useIsRoomSelected",0,function(e){let n,a=(0,t.c)(2);return a[0]!==e?(n=t=>t.selectedRoomIds.has(e),a[0]=e,a[1]=n):n=a[1],r(n)},"useIsRoomSelectionMode",0,function(){return r(n)},"useRoomSelectionStore",0,r,"useSelectedRoomCount",0,function(){return r(a)}])},556427,120835,112100,623102,863842,284274,235045,8213,564353,e=>{"use strict";var t=e.i(222666),r=e.i(505962),n=e.i(510654),a=e.i(920248),s=e.i(614991),o=e.i(968311),l=e.i(964817),i=e.i(963),c=e.i(452473);e.i(742593);var d=e.i(571236);e.i(530023);var u=e.i(612774),m=e.i(691038),p=e.i(573503),f=e.i(358058),h=e.i(968076),x=e.i(784510),g=e.i(864160),v=e.i(838011),b=e.i(871565),y=e.i(706527),j=e.i(749509),S=e.i(621364),w=e.i(270401),N=e.i(664514),C=e.i(888887),I=e.i(811507),_=e.i(295654),k=e.i(463444),A=e.i(693946),M=e.i(22422),T=e.i(624621),E=e.i(91110),R=e.i(612960);e.i(798823);var z=e.i(429930),O=e.i(399695),F=e.i(570655),D=e.i(903121);let L=()=>void 0,P=(0,w.createContext)({isDragging:!1,isValid:!0,registerDropHandler:()=>L});function B(){return(0,w.useContext)(P)}e.s(["ComposerDropTargetOverlay",0,()=>{let e,n=(0,r.c)(2),{isDragging:a,isValid:s}=B();return a?(n[0]!==s?(e=(0,t.jsx)("div",{className:"pointer-events-auto absolute inset-0 z-10 p-2",children:(0,t.jsx)(D.ComposerDropZone,{className:"h-full",isValid:s})}),n[0]=s,n[1]=e):e=n[1],e):null},"ComposerDropTargetProvider",0,function(e){let n,a,s,o,l,i,d,u,m=(0,r.c)(17),{children:p,className:f,ref:h}=e,x=(0,w.useRef)(null),g=(0,w.useRef)(null);m[0]!==h?(n=e=>{var t,r;x.current=e,t=h,r=e,"function"==typeof t?t(r):t&&(t.current=r)},m[0]=h,m[1]=n):n=m[1];let v=n;m[2]===Symbol.for("react.memo_cache_sentinel")?(a=e=>{let t=g.current;if(t)return t((0,O.getFilesFromDragDrop)({dataTransfer:e.dataTransfer??void 0}))},m[2]=a):a=m[2];let b=a;m[3]===Symbol.for("react.memo_cache_sentinel")?(s={onDrop:b},m[3]=s):s=m[3];let{isDragging:y,isValid:j}=(0,F.useDragDrop)(x,s);m[4]===Symbol.for("react.memo_cache_sentinel")?(o=e=>(g.current=e,()=>{g.current===e&&(g.current=null)}),m[4]=o):o=m[4];let S=o;m[5]!==y||m[6]!==j?(l={isDragging:y,isValid:j,registerDropHandler:S},m[5]=y,m[6]=j,m[7]=l):l=m[7];let N=l;return m[8]!==f?(i=(0,c.cn)("relative",f),m[8]=f,m[9]=i):i=m[9],m[10]!==p||m[11]!==v||m[12]!==i?(d=(0,t.jsx)("div",{ref:v,className:i,children:p}),m[10]=p,m[11]=v,m[12]=i,m[13]=d):d=m[13],m[14]!==N||m[15]!==d?(u=(0,t.jsx)(P.Provider,{value:N,children:d}),m[14]=N,m[15]=d,m[16]=u):u=m[16],u},"useComposerDropTarget",0,B],120835);let V=(0,e.i(948810).create)()(e=>({prompt:"",setPrompt:t=>e({prompt:t})})),$=e=>e.prompt.trim().length>0;e.s(["selectHasPromptText",0,$,"useComposerStore",0,V],112100);var H=e.i(624900),U=e.i(705113),G=e.i(797677);let q=e=>{let n,a,s,o=(0,r.c)(7),{attachments:l}=e;if(!(l.list.length>0))return null;let i=l.list.length;return o[0]!==l?(n=l.list.map((e,r)=>(0,t.jsx)(U.AttachmentPreview,{attachment:e,onDismiss:()=>l.remove(e),isLoading:l.loadingKeys.has((0,H.getAttachmentKey)(e))},`input-attachment-${r}`)),o[0]=l,o[1]=n):n=o[1],o[2]!==n?(a=(0,t.jsx)("div",{className:"flex gap-2",children:n}),o[2]=n,o[3]=a):a=o[3],o[4]!==l.list.length||o[5]!==a?(s=(0,t.jsx)("div",{className:"flex w-full animate-in fade-in slide-in-from-bottom-12 bg-muted p-2 h-20",children:(0,t.jsx)(G.AutoScrollContainer,{className:"rounded-lg",itemCount:i,orientation:"horizontal",children:a})}),o[4]=l.list.length,o[5]=a,o[6]=s):s=o[6],s};e.s(["ComposerAttachments",0,q],623102);let W=w.forwardRef(function({title:e,titleId:t,...r},n){return w.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?w.createElement("title",{id:t},e):null,w.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 20.25c4.97 0 9-3.694 9-8.25s-4.03-8.25-9-8.25S3 7.444 3 12c0 2.104.859 4.023 2.273 5.48.432.447.74 1.04.586 1.641a4.483 4.483 0 0 1-.923 1.785A5.969 5.969 0 0 0 6 21c1.282 0 2.47-.402 3.445-1.087.81.22 1.668.337 2.555.337Z"}))});e.i(356120),e.i(734293);var K=e.i(980351),J=e.i(214857);let Z=(0,w.createContext)(null);function Y(e){let t,n=(0,r.c)(2),{children:a}=e;if(!(0,K.useHydrated)()||"u"{d||c(e),l&&l(e)},a[0]=d,a[1]=l,a[2]=t):t=a[2];let m=t;return a[3]!==m||a[4]!==u?(n=[u,m],a[3]=m,a[4]=u,a[5]=n):n=a[5],n}(n);i[4]!==p||i[5]!==f?(a=()=>{if(!p)return;let e=e=>{"Escape"===e.key&&f(!1)};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},s=[p,f],i[4]=p,i[5]=f,i[6]=a,i[7]=s):(a=i[6],s=i[7]),(0,w.useEffect)(a,s),i[8]!==p||i[9]!==f?(o={open:p,setOpen:f},i[8]=p,i[9]=f,i[10]=o):o=i[10];let h=o;return i[11]!==m||i[12]!==h?(l=(0,t.jsx)(Z.Provider,{value:h,children:m}),i[11]=m,i[12]=h,i[13]=l):l=i[13],l}function Q(e){let n,a=(0,r.c)(2),{children:s}=e;return a[0]!==s?(n=(0,t.jsx)(Y,{children:s}),a[0]=s,a[1]=n):n=a[1],n}let ee=e=>{let n,a,s,o,l,i,d,u,m,p,f,h,x,g,v,b,y,j,S,N,C=(0,r.c)(41);C[0]!==e?({className:a,children:n,showCloseButton:l,ref:o,...s}=e,C[0]=e,C[1]=n,C[2]=a,C[3]=s,C[4]=o,C[5]=l):(n=C[1],a=C[2],s=C[3],o=C[4],l=C[5]);let I=void 0===l||l,{open:_,setOpen:k}=function(){let e=(0,w.useContext)(Z);if(!e)throw Error("FloatingDialog components must be used within ");return e}(),A=(0,w.useRef)(null);if(C[6]!==_?(i=()=>{_&&A.current&&A.current.focus()},d=[_],C[6]=_,C[7]=i,C[8]=d):(i=C[7],d=C[8]),(0,w.useEffect)(i,d),!_)return null;C[9]===Symbol.for("react.memo_cache_sentinel")?(u=(0,c.cn)("absolute inset-0 bg-background/80","duration-0","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"),C[9]=u):u=C[9];let M=_?"open":"closed";C[10]!==M?(m=(0,t.jsx)("div",{"aria-hidden":"true",className:u,"data-state":M}),C[10]=M,C[11]=m):m=C[11],C[12]===Symbol.for("react.memo_cache_sentinel")?(p=(0,c.cn)("relative h-full overflow-y-auto overscroll-contain touch-pan-y"),f={WebkitOverflowScrolling:"touch"},C[12]=p,C[13]=f):(p=C[12],f=C[13]);let T=_?"open":"closed";C[14]!==k?(h=e=>{e.target===e.currentTarget&&k(!1)},x=e=>{e.currentTarget===document.activeElement&&(("Enter"===e.key||" "===e.key)&&(e.preventDefault(),k(!1)),"Escape"===e.key&&k(!1))},C[14]=k,C[15]=h,C[16]=x):(h=C[15],x=C[16]),C[17]!==o?(g=e=>{A.current=e,"function"==typeof o?o(e):o&&"object"==typeof o&&(o.current=e)},C[17]=o,C[18]=g):g=C[18],C[19]!==a?(v=(0,c.cn)("cursor-default","relative w-full max-w-lg border bg-background p-6 shadow-lg rounded-lg","duration-0","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=open]:slide-in-from-bottom-4 data-[state=closed]:slide-out-to-bottom-4","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),C[19]=a,C[20]=v):v=C[20];let E=_?"open":"closed";return C[21]!==k||C[22]!==I?(b=I?(0,t.jsxs)("button",{type:"button",onClick:()=>k(!1),"data-slot":"dialog-close",className:"absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-ring focus:ring-2 focus:ring-offset-2","aria-label":"Close",children:[(0,t.jsx)("span",{className:"sr-only",children:"Close"}),(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"size-4","aria-hidden":!0,children:[(0,t.jsx)("title",{children:"Close dialog"}),(0,t.jsx)("path",{d:"M6 6l12 12M18 6l-12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})]}):null,C[21]=k,C[22]=I,C[23]=b):b=C[23],C[24]!==n||C[25]!==s||C[26]!==g||C[27]!==v||C[28]!==E||C[29]!==b?(y=(0,t.jsxs)("div",{ref:g,role:"dialog","aria-modal":"true",tabIndex:-1,"data-slot":"dialog-content",className:v,"data-state":E,...s,children:[n,b]}),C[24]=n,C[25]=s,C[26]=g,C[27]=v,C[28]=E,C[29]=b,C[30]=y):y=C[30],C[31]!==h||C[32]!==x||C[33]!==y?(j=(0,t.jsx)("div",{className:"flex min-h-[100dvh] items-center justify-center p-4 cursor-pointer",role:"button",tabIndex:0,"aria-label":"Close dialog",onClick:h,onKeyDown:x,children:y}),C[31]=h,C[32]=x,C[33]=y,C[34]=j):j=C[34],C[35]!==j||C[36]!==T?(S=(0,t.jsx)("div",{className:p,style:f,"data-slot":"dialog-overlay","data-state":T,children:j}),C[35]=j,C[36]=T,C[37]=S):S=C[37],C[38]!==S||C[39]!==m?(N=(0,t.jsx)(Q,{children:(0,t.jsxs)("div",{className:"fixed inset-0 z-overlay",children:[m,S]})}),C[38]=S,C[39]=m,C[40]=N):N=C[40],N};function et(e){let n,a,s,o,l=(0,r.c)(8);return l[0]!==e?({className:n,...a}=e,l[0]=e,l[1]=n,l[2]=a):(n=l[1],a=l[2]),l[3]!==n?(s=(0,c.cn)("text-base leading-none font-semibold",n),l[3]=n,l[4]=s):s=l[4],l[5]!==a||l[6]!==s?(o=(0,t.jsx)("h2",{"data-slot":"dialog-title",className:s,...a,children:a.children}),l[5]=a,l[6]=s,l[7]=o):o=l[7],o}e.s(["Dialog",0,X,"DialogContent",0,ee,"DialogDescription",0,function(e){let n,a,s,o,l=(0,r.c)(8);return l[0]!==e?({className:n,...a}=e,l[0]=e,l[1]=n,l[2]=a):(n=l[1],a=l[2]),l[3]!==n?(s=(0,c.cn)("text-muted-foreground text-sm",n),l[3]=n,l[4]=s):s=l[4],l[5]!==a||l[6]!==s?(o=(0,t.jsx)("p",{"data-slot":"dialog-description",className:s,...a}),l[5]=a,l[6]=s,l[7]=o):o=l[7],o},"DialogFooter",0,function(e){let n,a,s,o,l=(0,r.c)(8);return l[0]!==e?({className:n,...a}=e,l[0]=e,l[1]=n,l[2]=a):(n=l[1],a=l[2]),l[3]!==n?(s=(0,c.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",n),l[3]=n,l[4]=s):s=l[4],l[5]!==a||l[6]!==s?(o=(0,t.jsx)("div",{"data-slot":"dialog-footer",className:s,...a}),l[5]=a,l[6]=s,l[7]=o):o=l[7],o},"DialogHeader",0,function(e){let n,a,s,o,l=(0,r.c)(8);return l[0]!==e?({className:n,...a}=e,l[0]=e,l[1]=n,l[2]=a):(n=l[1],a=l[2]),l[3]!==n?(s=(0,c.cn)("flex flex-col gap-2 text-center sm:text-left",n),l[3]=n,l[4]=s):s=l[4],l[5]!==a||l[6]!==s?(o=(0,t.jsx)("div",{"data-slot":"dialog-header",className:s,...a}),l[5]=a,l[6]=s,l[7]=o):o=l[7],o},"DialogTitle",0,et],863842);var er=e.i(778084),en=e.i(541962),ea=e.i(759024),es=e.i(810563),eo=e.i(558956),el=e.i(388095);let ei=/^([0-9]{1,})?(\.)?([0-9]{1,})?$/,ec=({onDone:e,floatingPoint:r=3,value:n,className:a,min:s,max:o,step:l,tooltips:i,maxLabel:d,ref:u,...m})=>{let[p,f]=(0,el.useResettableState)(`${n}:${r}`,()=>n.toFixed(r)),[h,x]=(0,w.useState)(!1),g=(0,w.useRef)(null),v=(0,w.useRef)(p),b=(0,w.useRef)(n),y=(0,w.useRef)(e),j=(0,w.useRef)(s);v.current=p,b.current=n,y.current=e,j.current=s;let S=(e,t)=>{let r=Number.parseFloat(e);return Number.isNaN(r)?t??0:r};return(0,w.useImperativeHandle)(u,()=>{if(!g.current)throw Error("Input ref is not available");return g.current}),(0,w.useEffect)(()=>()=>{let e=S(v.current,j.current);e!==b.current&&y.current?.(e)},[]),(0,t.jsxs)("div",{className:(0,c.cn)("flex flex-col gap-3",a),children:[(0,t.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,t.jsx)(ea.InfoTooltip,{contentClassName:"w-40",side:"left",icon:(0,t.jsx)(eo.Label,{htmlFor:m.id,className:"flex items-center gap-2",children:(0,t.jsx)("span",{className:"w-min truncate",children:m.name})}),children:i??m.name}),(0,t.jsx)(es.Input,{id:m.id,className:"h-5 w-16 rounded-lg border-0 px-2 text-right pointer-coarse:text-base pointer-coarse:leading-5 shadow-inner shadow-border focus-visible:shadow-inner",value:!h&&void 0!==d&&void 0!==o&&S(p,s)>=o?d:p,ref:g,onChange:e=>{let t=e.target.value;if(""===t)return void f("");if(ei.test(t)){let e=Number.parseFloat(t);(void 0===s||e>=s)&&(void 0===o||e<=o)&&f(t)}},onKeyDown:t=>{"Enter"===t.key&&(e?.(S(p,s)),g.current?.blur())},onBlur:()=>{x(!1),e?.(S(p,s))},onFocus:e=>{x(!0);let t=e.currentTarget,r=t.value.length;requestAnimationFrame(()=>t.setSelectionRange(r,r))}})]}),(0,t.jsx)(en.Slider.Root,{className:(0,c.cn)("relative flex w-full touch-none select-none items-center"),min:s,max:o,step:l,value:S(p,s),onValueChange:e=>{f(e.toFixed(r))},onValueCommitted:t=>{e?.(t)},children:(0,t.jsxs)(en.Slider.Control,{className:"relative flex w-full cursor-pointer items-center",children:[(0,t.jsx)(en.Slider.Track,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-slate-3",children:(0,t.jsx)(en.Slider.Indicator,{className:"absolute h-full bg-slate-8"})}),(0,t.jsx)(en.Slider.Thumb,{className:(0,c.cn)("block size-4 cursor-pointer rounded-full border border-slate-9 bg-white shadow-md focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-8 disabled:pointer-events-none disabled:opacity-50"),"aria-label":m.name})]})})]})};function ed(){let e=new Set,t=!1,r=()=>{for(let t of e)t()},n=t=>(e.add(t),()=>{e.delete(t)}),a=()=>t;return{requestOpen:()=>{0!==e.size&&(t=!0,r())},clearRequest:()=>{t=!1,r()},useShouldOpen:()=>(0,w.useSyncExternalStore)(n,a,a)}}e.s(["FloatSlider",0,ec],284274);let eu=ed(),em=eu.requestOpen,ep=eu.clearRequest,ef=eu.useShouldOpen;var eh=e.i(528164);function ex(e){let n,a,s,o,l,i,d=(0,r.c)(12);d[0]!==e?({className:n,isActive:s,isIconOnly:o,...a}=e,d[0]=e,d[1]=n,d[2]=a,d[3]=s,d[4]=o):(n=d[1],a=d[2],s=d[3],o=d[4]);let u=void 0!==o&&o?"w-9 px-0":"w-auto gap-1 px-2",m=void 0!==s&&s&&"bg-selected-bg text-foreground hover:bg-selected-bg";return d[5]!==n||d[6]!==u||d[7]!==m?(l=(0,c.cn)("transition-colors text-muted-foreground hover:text-foreground",u,m,n),d[5]=n,d[6]=u,d[7]=m,d[8]=l):l=d[8],d[9]!==a||d[10]!==l?(i=(0,t.jsx)(eh.Button,{...a,variant:"ghost",size:"icon",className:l}),d[9]=a,d[10]=l,d[11]=i):i=d[11],i}function eg(e){let n,a,s,o,l,i,c,d=(0,r.c)(35),{variant:u,onNavigate:m}=e,p=void 0===u?"footer":u,[f,h]=(0,w.useState)(!1),x=(0,T.useChatroomStore)(eb),g=x>=_.MAX_CHAT_MEMORY_COUNT,v=g?"∞":`${x}`,b=`Chat memory: ${g?"all":x} messages`,y=ef();if(d[0]!==y||d[1]!==p?(n=()=>{"host"===p&&y&&(h(!0),ep())},a=[p,y],d[0]=y,d[1]=p,d[2]=n,d[3]=a):(n=d[2],a=d[3]),(0,w.useEffect)(n,a),"menu"===p){let e,r,n,a,s;return d[4]!==m?(e=()=>{m?.(),em()},d[4]=m,d[5]=e):e=d[5],d[6]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(W,{className:"size-4 shrink-0"}),n=(0,t.jsx)("span",{className:"flex-1 text-left",children:"Chat memory"}),d[6]=r,d[7]=n):(r=d[6],n=d[7]),d[8]!==v?(a=(0,t.jsx)("span",{className:"flex h-4 min-w-4 items-center justify-center px-1 text-xs font-semibold leading-none text-muted-foreground",children:v}),d[8]=v,d[9]=a):a=d[9],d[10]!==b||d[11]!==e||d[12]!==a?(s=(0,t.jsxs)("button",{type:"button",onClick:e,className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-foreground transition-colors hover:bg-card-hover","aria-label":b,children:[r,n,a]}),d[10]=b,d[11]=e,d[12]=a,d[13]=s):s=d[13],s}if("host"===p){let e,r,n;return d[14]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(et,{children:"Chat memory"}),d[14]=e):e=d[14],d[15]!==x?(r=(0,t.jsxs)(ee,{className:"max-w-md",children:[e,(0,t.jsx)(ey,{chatMemoryCount:x})]}),d[15]=x,d[16]=r):r=d[16],d[17]!==f||d[18]!==r?(n=(0,t.jsx)(X,{open:f,onOpenChange:h,children:r}),d[17]=f,d[18]=r,d[19]=n):n=d[19],n}let j=f?void 0:b;return d[20]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(W,{className:"size-5"}),d[20]=s):s=d[20],d[21]!==v||d[22]!==g?(o=!g&&(0,t.jsx)("span",{className:"text-xs font-medium",children:v}),d[21]=v,d[22]=g,d[23]=o):o=d[23],d[24]!==b||d[25]!==f||d[26]!==j||d[27]!==o?(l=(0,t.jsx)(er.PopoverTrigger,{render:(0,t.jsxs)(ex,{"aria-label":b,"aria-haspopup":"dialog","aria-expanded":f,title:j,children:[s,o]})}),d[24]=b,d[25]=f,d[26]=j,d[27]=o,d[28]=l):l=d[28],d[29]!==x?(i=(0,t.jsx)(er.PopoverContent,{side:"top",align:"start",initialFocus:ev,className:"w-[92vw] max-w-[440px] p-3 sm:p-4",children:(0,t.jsx)(ey,{chatMemoryCount:x})}),d[29]=x,d[30]=i):i=d[30],d[31]!==f||d[32]!==l||d[33]!==i?(c=(0,t.jsxs)(er.Popover,{open:f,onOpenChange:h,children:[l,i]}),d[31]=f,d[32]=l,d[33]=i,d[34]=c):c=d[34],c}function ev(e){return"keyboard"===e}function eb(e){return e.chatMemoryCount}function ey(e){let n,a,s,o=(0,r.c)(7),{chatMemoryCount:l}=e;o[0]!==l?(n=(0,t.jsx)(ec,{floatingPoint:0,step:1,min:1,max:_.MAX_CHAT_MEMORY_COUNT,maxLabel:"∞",name:"Chat memory",tooltips:"Number of recent messages to include per request",id:"default-chat-memory",value:l,onDone:ej}),o[0]=l,o[1]=n):n=o[1];let i=l>=_.MAX_CHAT_MEMORY_COUNT?"Sends all messages from your conversation each request.":`Sends the last ${l} messages from your conversation each request.`;return o[2]!==i?(a=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),o[2]=i,o[3]=a):a=o[3],o[4]!==n||o[5]!==a?(s=(0,t.jsxs)("div",{className:"flex flex-col gap-y-3",children:[n,a]}),o[4]=n,o[5]=a,o[6]=s):s=o[6],s}function ej(e){return M.chatroomStoreActions.setChatMemoryCount({payload:{chatMemoryCount:e}})}e.s(["ComposerFooterButton",0,ex],235045);var eS=e.i(693697),ew=e.i(218812);let eN=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/mpeg","audio/wav"];function eC({className:r,convertingLabel:n="Converting recording",disabled:a,isLoading:s,onRecordingComplete:o,onRecordingError:l,recordingMimeTypes:i=eN,shouldConvertToWav:d=!0,size:u="icon",startLabel:m="Start recording",stopLabel:p="Stop recording",type:f="button",variant:h="ghost",...x}){let g=(0,w.useRef)(null),v=(0,w.useRef)(void 0),b=(0,w.useRef)([]),y=(0,w.useRef)(void 0),j=(0,w.useRef)(null),S=(0,w.useRef)(void 0),N=(0,w.useRef)(void 0),C=(0,w.useRef)(async()=>void 0),I=(0,w.useRef)(()=>void 0),[_,k]=(0,w.useState)(!1),[A,M]=(0,w.useState)(!1),T=(0,w.useCallback)(e=>{l?.(e)},[l]),E=(0,w.useCallback)(async t=>{let r=await (0,eS.wrap)(async()=>{let{BlobSource:r,BufferTarget:n,Conversion:a,Input:s,Output:o,WavOutputFormat:l,WEBM:i}=await e.A(434557),c=new s({source:new r(t),formats:[i]}),d=new n,u=new o({target:d,format:new l}),m=await a.init({input:c,output:u});await m.execute();let p=d.buffer;if(!p)throw Error("Conversion produced no buffer");return new Blob([p],{type:"audio/wav"})});return(0,eS.isOk)(r)?r.data:null},[]),R=(0,w.useCallback)(async e=>{k(!0);let t=new Blob(b.current,{type:e});b.current=[];let r=d&&e.includes("webm")?await E(t):null,n=r??t,a=r?"audio/wav":e,s=await (0,eS.wrap)(async()=>{await o?.(n,a)});(0,eS.isErr)(s)&&T(s.error),k(!1)},[E,o,T,d]),z=(0,w.useCallback)(()=>{let e=S.current;e&&"inactive"!==e.state&&e.stop(),N.current?.getTracks().forEach(e=>{e.stop()}),N.current=void 0;let t=y.current;t&&(t.close().catch(T),y.current=void 0),g.current=null,S.current=void 0,M(!1)},[T]),O=(0,w.useCallback)(async()=>{if("u"navigator.mediaDevices.getUserMedia({audio:!0}));if((0,eS.isErr)(e))return void T(e.error);let t=e.data;N.current=t;let r=new AudioContext;y.current=r;let n=r.createAnalyser();n.fftSize=256,n.smoothingTimeConstant=.8,g.current=n,r.createMediaStreamSource(t).connect(n);let a=function(e=eN){return"u"MediaRecorder.isTypeSupported(e))??"audio/webm"}(i),s=new MediaRecorder(t,{mimeType:a});S.current=s,b.current=[],s.ondataavailable=e=>{e.data.size>0&&b.current.push(e.data)},s.onstop=()=>{C.current(a).catch(T)},s.start(),M(!0)},[R,i,T]),F=(0,w.useCallback)(()=>{A?z():O().catch(T)},[A,T,O,z]);(0,w.useEffect)(()=>{let e=j.current;if(!e)return;let t=e.getContext("2d");if(!t)return;let r=window.devicePixelRatio||1;if(e.width=20*r,e.height=20*r,e.style.width="20px",e.style.height="20px",t.setTransform(r,0,0,r,0,0),!A||!g.current){t.clearRect(0,0,20,20),v.current&&(cancelAnimationFrame(v.current),v.current=void 0);return}let n=()=>{let r=g.current;if(!r||!A)return;v.current=requestAnimationFrame(n);let a=r.frequencyBinCount,s=new Uint8Array(a);r.getByteFrequencyData(s),t.clearRect(0,0,20,20),t.fillStyle=getComputedStyle(e).color;Array.from({length:5}).forEach((e,r)=>{let n=2+(s[Math.floor(r/5*a)]??0)/255*14;t.fillRect(1+4*r,(20-n)/2,2,n)})};return n(),()=>{v.current&&(cancelAnimationFrame(v.current),v.current=void 0)}},[A]),C.current=R,I.current=z,(0,w.useEffect)(()=>()=>{I.current()},[]);let D=_||!!s,L=function({convertingLabel:e,isBusy:t,isRecording:r,startLabel:n,stopLabel:a}){return t?e:r?a:n}({convertingLabel:n,isBusy:D,isRecording:A,startLabel:m,stopLabel:p}),P=function({isBusy:e,isRecording:t}){return e?"converting":t?"recording":"idle"}({isBusy:D,isRecording:A}),B=function({canvasRef:e,convertingLabel:r,isBusy:n,isRecording:a}){return n?(0,t.jsx)("span",{className:"sr-only",children:r}):a?(0,t.jsx)("canvas",{ref:e,className:"block text-current"}):(0,t.jsx)(ew.Mic,{})}({canvasRef:j,convertingLabel:n,isBusy:D,isRecording:A});return(0,t.jsxs)(eh.Button,{"aria-label":L,className:(0,c.cn)("relative rounded-full",A&&"text-negative hover:text-negative",r),"data-state":P,disabled:a||D,isLoading:D,onClick:F,size:u,type:f,variant:h,...x,children:[B,A&&(0,t.jsx)("span",{className:"absolute right-1.5 top-1.5 size-2 rounded-full bg-negative shadow-sm animate-pulse"})]})}function eI(e){let n,a,s=(0,r.c)(4),{attachments:o}=e;s[0]!==o?(n=async(e,t)=>{let r=t.includes("wav")?"wav":t.includes("mpeg")?"mp3":"audio",n=new File([e],`recording-${Date.now()}.${r}`,{type:t});await o.handleFiles(Promise.resolve((0,eS.ok)([n])))},s[0]=o,s[1]=n):n=s[1];let l=n;return s[2]!==l?(a=(0,t.jsx)(eC,{onRecordingComplete:l}),s[2]=l,s[3]=a):a=s[3],a}var e_=e.i(249656);let ek=e=>{let n,a,s,o,l,i=(0,r.c)(11),{label:d,Icon:u,onClear:m}=e;if(!d)return null;let p=`Clear ${d} mode`;return i[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,c.cn)("h-7 gap-1 rounded-full pl-2 pr-1","bg-muted text-foreground text-xs","hover:bg-card-hover hover:text-foreground"),i[0]=n):n=i[0],i[1]!==u?(a=(0,t.jsx)(u,{className:"size-3.5 shrink-0"}),i[1]=u,i[2]=a):a=i[2],i[3]!==d?(s=(0,t.jsx)("span",{className:"whitespace-nowrap",children:d}),i[3]=d,i[4]=s):s=i[4],i[5]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("span",{className:"inline-flex items-center justify-center rounded-full p-0.5 hover:bg-muted",children:(0,t.jsx)(e_.X,{className:"size-3.5"})}),i[5]=o):o=i[5],i[6]!==m||i[7]!==p||i[8]!==a||i[9]!==s?(l=(0,t.jsxs)(eh.Button,{variant:"ghost",size:"sm",onClick:m,"aria-label":p,className:n,children:[a,s,o]}),i[6]=m,i[7]=p,i[8]=a,i[9]=s,i[10]=l):l=i[10],l};var eA=e.i(699511),eM=e.i(43596),eT=e.i(408033),eE=e.i(797738);function eR(e){var n;let a,o,i,d,u,m,p,f,h=(0,r.c)(24),{attachments:x,activeMode:g,onSelectMode:v,disabled:b,internPresence:y,extraActions:j}=e,[S,N]=(0,w.useState)(!1),[C,I]=(0,w.useState)("main"),_=x.list.length>=x.limit,k=y?.hasOnlyInterns===!0;h[0]!==y?(n=y,a=n?.hasOnlyInterns?"Interns take text only for now.":n?.hasInterns?"Not applied to interns; they take text only.":void 0,h[0]=y,h[1]=a):a=h[1];let A=a,M=k?A:void 0;h[2]===Symbol.for("react.memo_cache_sentinel")?(o=e=>{N(e),e||I("main")},h[2]=o):o=h[2];let T=o;h[3]!==x?(i=async()=>{await x.handleFiles((0,O.getFilesFromSelectDialog)()),T(!1)},h[3]=x,h[4]=i):i=h[4];let E=i;h[5]!==v?(d=e=>{v(e),T(!1)},h[5]=v,h[6]=d):d=h[6];let R=d;return h[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(eE.PlusIcon,{className:"!size-5"}),h[7]=u):u=h[7],h[8]!==b?(m=(0,t.jsx)(er.PopoverTrigger,{render:(0,t.jsx)(eh.Button,{type:"button",size:"icon",variant:"ghost",disabled:b,"aria-label":"Add to message",className:"aspect-square shrink-0 rounded-full h-9 w-9 p-0 text-muted-foreground hover:text-foreground",children:u})}),h[8]=b,h[9]=m):m=h[9],h[10]!==g||h[11]!==_||h[12]!==j||h[13]!==E||h[14]!==R||h[15]!==A||h[16]!==M||h[17]!==k||h[18]!==C?(p=(0,t.jsx)(er.PopoverContent,{side:"top",align:"start",sideOffset:8,collisionPadding:8,className:"w-64 p-1.5",children:"main"===C?(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[j?(0,t.jsxs)(t.Fragment,{children:[j({closeMenu:()=>T(!1)}),(0,t.jsx)("div",{className:"my-1 h-px bg-border/60"})]}):null,(0,t.jsxs)(eh.Button,{type:"button",size:"sm",variant:"ghost",className:ez,disabled:_||k,title:M,onClick:E,"aria-label":"Attach files",children:[(0,t.jsx)(eT.PaperClipIcon,{className:"!size-5"}),(0,t.jsx)("span",{className:"truncate",children:"Attach files"})]}),(0,t.jsxs)(eh.Button,{type:"button",size:"sm",variant:g===z.ImageArchetype.Default?"outline":"ghost",className:ez,disabled:k,title:M,onClick:()=>R(z.ImageArchetype.Default),"aria-label":"Generate image",children:[(0,t.jsx)(s.PhotoIcon,{className:"!size-5"}),(0,t.jsx)("span",{className:"truncate",children:"Generate image"})]}),(0,t.jsxs)(eh.Button,{type:"button",size:"sm",variant:"ghost",className:ez,disabled:k,title:M,onClick:()=>I("artifact"),"aria-label":"Create artifact",children:[(0,t.jsx)(l.WindowIcon,{className:"!size-5"}),(0,t.jsx)("span",{className:"flex-1 truncate text-left",children:"Create Artifact"}),(0,t.jsx)(eM.ChevronRightIcon,{className:"size-4 text-muted-foreground"})]}),A?(0,t.jsx)("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:A}):null]}):(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(eh.Button,{type:"button",size:"sm",variant:"ghost",className:(0,c.cn)(ez,"text-muted-foreground"),onClick:()=>I("main"),"aria-label":"Back",children:[(0,t.jsx)(eA.ChevronLeftIcon,{className:"!size-5"}),(0,t.jsx)("span",{className:"truncate",children:"Back"})]}),(0,t.jsx)("div",{className:"my-1 h-px bg-border/60"}),eO.map(e=>{let{type:r,Icon:n,label:a}=e,s=r===g;return(0,t.jsxs)(eh.Button,{type:"button",size:"sm",variant:s?"outline":"ghost",className:ez,disabled:k,onClick:()=>R(r),"aria-label":a,children:[(0,t.jsx)(n,{className:"!size-5"}),(0,t.jsx)("span",{className:"truncate",children:a})]},r)}),A?(0,t.jsx)("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:A}):null]})}),h[10]=g,h[11]=_,h[12]=j,h[13]=E,h[14]=R,h[15]=A,h[16]=M,h[17]=k,h[18]=C,h[19]=p):p=h[19],h[20]!==S||h[21]!==m||h[22]!==p?(f=(0,t.jsxs)(er.Popover,{open:S,onOpenChange:T,children:[m,p]}),h[20]=S,h[21]=m,h[22]=p,h[23]=f):f=h[23],f}let ez="h-auto w-full justify-start gap-2.5 rounded-md px-3 py-2.5 text-body font-medium",eO=[{type:z.AppArchetype.InteractiveWebApp,Icon:l.WindowIcon,label:"Interactive App"},{type:z.AppArchetype.LandingPage,Icon:n.ComputerDesktopIcon,label:"Landing Page"},{type:z.AppArchetype.TwoDGame,Icon:o.Squares2X2Icon,label:"2D Game"},{type:z.AppArchetype.ThreeDGame,Icon:a.CubeIcon,label:"3D Game"}];var eF=e.i(823634);let eD="text/plain",eL=e=>{let n,a,s,o,l,i,d,u,p,f,h,x,g,b,y,j,S,N,C,I,_,k,A,M,T=(0,r.c)(43);T[0]!==e?({prompt:d,setPrompt:f,attachments:n,onSend:i,disabled:s,onKeyDown:l,className:a,inputClassName:o,ref:p,...u}=e,T[0]=e,T[1]=n,T[2]=a,T[3]=s,T[4]=o,T[5]=l,T[6]=i,T[7]=d,T[8]=u,T[9]=p,T[10]=f):(n=T[1],a=T[2],s=T[3],o=T[4],l=T[5],i=T[6],d=T[7],u=T[8],p=T[9],f=T[10]);let E=(0,m.useMediaMd)(),R=(0,w.useRef)(!1),z=(0,w.useRef)(null);T[11]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{let e=z.current;if(!e)return;e.style.height="0px";let t=Number.parseFloat(window.getComputedStyle(e).minHeight)||0;e.style.height=`${Math.max(e.scrollHeight,t)}px`},T[11]=h):h=T[11];let F=h;T[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{(0,v.isCoarsePointer)()||(z.current?.focus({preventScroll:!0}),F())},g=[F],T[12]=x,T[13]=g):(x=T[12],g=T[13]),(0,w.useEffect)(x,g),T[14]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{F()},T[14]=b):b=T[14],(0,w.useEffect)(b),T[15]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{R.current=!0},T[15]=y):y=T[15];let D=y;T[16]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{R.current=!1},T[16]=j):j=T[16];let L=j;T[17]!==f?(S=e=>{f(e.target.value),F()},T[17]=f,T[18]=S):S=T[18];let P=S;T[19]!==s||T[20]!==E||T[21]!==l||T[22]!==i?(N=e=>{s||(l?.(e),e.defaultPrevented||R.current||"Enter"===e.key&&!e.shiftKey&&E&&(e.preventDefault(),i()))},T[19]=s,T[20]=E,T[21]=l,T[22]=i,T[23]=N):N=T[23];let B=N;T[24]!==n?(C=async e=>{var t;let r,a,s;if(!e.clipboardData)return;let o=n.list.length"string"===e.kind&&e.type===eD),r.some(e=>"file"===e.kind)&&!a&&await n.handleFiles((0,O.getFilesFromClipboard)(e))},T[24]=n,T[25]=C):C=T[25];let V=C;T[26]!==p?(I=e=>{z.current=e,"function"==typeof p?p(e):p&&(p.current=e)},T[26]=p,T[27]=I):I=T[27];let $=I;return T[28]!==a?(_=(0,c.cn)("relative w-full flex flex-col gap-2",a),T[28]=a,T[29]=_):_=T[29],T[30]!==o?(k=(0,c.cn)("ph-no-capture max-h-96 !min-h-9 resize-none overflow-y-auto bg-transparent px-2 py-1.5 leading-6 placeholder:text-muted-foreground/50",o),T[30]=o,T[31]=k):k=T[31],T[32]!==P||T[33]!==B||T[34]!==V||T[35]!==d||T[36]!==u||T[37]!==$||T[38]!==k?(A=(0,t.jsx)(eF.Textarea,{...u,ref:$,"data-testid":"composer-input",className:k,"data-dd-privacy":"hidden",value:d,onCompositionStart:D,onCompositionEnd:L,onChange:P,onKeyDown:B,onPaste:V}),T[32]=P,T[33]=B,T[34]=V,T[35]=d,T[36]=u,T[37]=$,T[38]=k,T[39]=A):A=T[39],T[40]!==_||T[41]!==A?(M=(0,t.jsx)("div",{className:_,children:A}),T[40]=_,T[41]=A,T[42]=M):M=T[42],M};e.s(["ComposerInput",0,eL],8213);let eP=e=>{let n,a=(0,r.c)(4),s=V(eB),o=V(eV);return a[0]!==s||a[1]!==e||a[2]!==o?(n=(0,t.jsx)(eL,{...e,prompt:s,setPrompt:o}),a[0]=s,a[1]=e,a[2]=o,a[3]=n):n=a[3],n};function eB(e){return e.prompt}function eV(e){return e.setPrompt}var e$=e.i(646013),eH=e.i(733288);let eU=w.forwardRef(function({title:e,titleId:t,...r},n){return w.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?w.createElement("title",{id:t},e):null,w.createElement("path",{fillRule:"evenodd",d:"M4.5 7.5a3 3 0 0 1 3-3h9a3 3 0 0 1 3 3v9a3 3 0 0 1-3 3h-9a3 3 0 0 1-3-3v-9Z",clipRule:"evenodd"}))});var eG=e.i(648156);let eq=e=>{var n,a,s,o;let l,i,d,u,m,p=(0,r.c)(19),{attachmentCount:f,disabled:h,onSend:x,onStop:g,isCommandActive:v,isLoading:b}=e,y=void 0!==b&&b,j=V($)||f>0;p[0]!==h||p[1]!==v?(n=h,a=v,l=n?"Stop":a?"Create Artifact":"Send message",p[0]=h,p[1]=v,p[2]=l):l=p[2];let S=l;p[3]!==h||p[4]!==v?(s=h,o=v,i=s?(0,t.jsx)(eU,{className:"size-4"}):o?(0,t.jsx)(eH.SparklesIcon,{className:"size-4"}):(0,t.jsx)(e$.ArrowUpIcon,{className:"size-4 stroke-[2.5]"}),p[3]=h,p[4]=v,p[5]=i):i=p[5];let w=i,N=h?g:x,C=!h&&(!j||y),I=!h&&(!j||y)&&"opacity-40",_=h&&"bg-destructive text-destructive-foreground hover:bg-destructive/90",k=v&&!h&&"bg-primary text-primary-foreground hover:bg-primary/90";return p[6]!==I||p[7]!==_||p[8]!==k?(d=(0,c.cn)("h-9 w-9 shrink-0 transition-all",I,_,k),p[6]=I,p[7]=_,p[8]=k,p[9]=d):d=p[9],p[10]!==w||p[11]!==N||p[12]!==C||p[13]!==d||p[14]!==S?(u=(0,t.jsx)(eh.Button,{"data-testid":"send-button",size:"icon",onClick:N,disabled:C,"aria-label":S,className:d,children:w}),p[10]=w,p[11]=N,p[12]=C,p[13]=d,p[14]=S,p[15]=u):u=p[15],p[16]!==u||p[17]!==S?(m=(0,t.jsx)(eG.Tooltip,{content:S,children:u}),p[16]=u,p[17]=S,p[18]=m):m=p[18],m};var eW=e.i(378599),eK=e.i(117738),eJ=e.i(79247),eZ=e.i(607296),eY=e.i(379497),eX=e.i(510196),eQ=e.i(677121),e0=e.i(132736),e1=e.i(508862),e2=e.i(272785),e3=e.i(700050),e5=e.i(249191),e4=e.i(882968),e6=e.i(340966);let e7={webSearch:e=>M.chatroomStoreActions.setIsWebSearchEnabled({payload:{enabled:e}}),webFetch:e=>M.chatroomStoreActions.setIsWebFetchEnabled({payload:{enabled:e}}),imageGeneration:e=>M.chatroomStoreActions.setIsImageGenerationEnabled({payload:{enabled:e}}),datetime:e=>M.chatroomStoreActions.setIsDatetimeEnabled({payload:{enabled:e}}),fusion:e=>M.chatroomStoreActions.setIsFusionEnabled({payload:{enabled:e}}),advisor:e=>M.chatroomStoreActions.setIsAdvisorEnabled({payload:{enabled:e}}),subagent:e=>M.chatroomStoreActions.setIsSubagentEnabled({payload:{enabled:e}}),shell:e=>M.chatroomStoreActions.setIsShellEnabled({payload:{enabled:e}})};function e8(e,t){let r={};return Object.assign(r,{[e]:t}),r}let e9={webSearch:(e,t)=>M.chatroomStoreActions.setWebSearchConfig({payload:e8(e,t)}),webFetch:(e,t)=>M.chatroomStoreActions.setWebFetchConfig({payload:e8(e,t)}),imageGeneration:(e,t)=>M.chatroomStoreActions.setImageGenerationConfig({payload:e8(e,t)}),datetime:(e,t)=>M.chatroomStoreActions.setDatetimeConfig({payload:e8(e,t)}),fusion:(e,t)=>M.chatroomStoreActions.setFusionConfig({payload:e8(e,t)}),advisor:(e,t)=>M.chatroomStoreActions.setAdvisorConfig({payload:e8(e,t)}),subagent:(e,t)=>M.chatroomStoreActions.setSubagentConfig({payload:e8(e,t)}),shell:(e,t)=>M.chatroomStoreActions.setShellConfig({payload:e8(e,t)})};function te(e,t,r={}){e7[e]?.(t),!0===r.markAsUserPreference&&M.chatroomStoreActions.markToolAsUserConfigured({payload:{toolId:e}})}function tt(e,t,r){e9[e]?.(t,r)}var tr=e.i(578199),tn=e.i(854454);let ta=ed(),ts=ta.requestOpen,to=ta.clearRequest,tl=ta.useShouldOpen;var ti=e.i(850658),tc=e.i(906953),td=e.i(48318);let tu="min-h-[19rem]";function tm(e){let n,a,s,o,l,i,d,u,p,f,h,x,g,v,b,y,j,S,C,I,_,A,M,E,R,z,O,F,D,L,P,B,V,$,H,U,G,q,W,K,Z,Y,X=(0,r.c)(175),{variant:Q,onNavigate:ee}=e,et=void 0===Q?"footer":Q,[en,ea]=(0,w.useState)(!1),[es,eo]=(0,w.useState)(null);X[0]===Symbol.for("react.memo_cache_sentinel")?(n={},X[0]=n):n=X[0];let[el,ei]=(0,w.useState)(n),{contextEntityId:ec}=(0,eK.useEntity)(),ed=tl(),eu=(0,T.useChatroomStore)((0,N.useShallow)(tx)),em=(0,T.useChatroomStore)(th),ep=(0,T.useChatroomStore)(k.selectActiveCharacters),{hasInterns:ef,hasOnlyInterns:eg}=(0,T.useChatroomStore)((0,N.useShallow)(k.selectActiveCharacterKinds));X[1]!==ep?(a=ep.map(e5.getServerToolCapabilityContext),X[1]=ep,X[2]=a):a=X[2];let ev=a,{disabledToolIds:eb,isResolved:ey,workspaceServerToolsHref:ej}=function(){let e,t,n,a,s,o,l=(0,r.c)(18),{isSignedIn:i,isLoaded:c,userId:d}=(0,ti.useAuth)(),{contextEntityId:u,isOrg:m,isOrgAdmin:p,isOrgLoading:f}=(0,eK.useEntity)(),h=!0===i;l[0]!==h?(e={isEnabled:h},l[0]=h,l[1]=e):e=l[1];let{workspaces:x,activeWorkspaceId:g,defaultWorkspaceId:v}=(0,td.useUserWorkspaces)(e);l[2]!==g||l[3]!==i||l[4]!==x?(t=!0===i?x?.find(e=>e.id===g):void 0,l[2]=g,l[3]=i,l[4]=x,l[5]=t):t=l[5];let b=t,y=b?.id===v,j=u??"",S=y?null:g??null;l[6]!==j||l[7]!==S?(n=(0,td.workspaceMembersOptions)(j,S),l[6]=j,l[7]=S,l[8]=n):n=l[8];let w=!0===i&&c&&!1===f&&m&&!1===p&&void 0!==b&&!1===y&&null!==u;l[9]!==n||l[10]!==w?(a={...n,enabled:w},l[9]=n,l[10]=w,l[11]=a):a=l[11];let N=(0,eJ.useQuery)(a),C=N.data?.some(e=>e.user_id===d&&e.role===tc.WorkspaceRole.Admin)===!0,I=!0===i&&c&&!1===f&&(!m||p||!y&&C),_=b?.disabled_server_tools;if(l[12]!==_){var k;let e;k=tr.SERVER_TOOL_UI_DEFINITIONS,e=new Set(_??[]),s=new Set(k.filter(t=>e.has(t.apiType)).map(e=>e.id)),l[12]=_,l[13]=s}else s=l[13];let A=!0===i&&void 0!==x,M=I&&void 0!==b?`/workspaces/${b.slug}/tools`:void 0;return l[14]!==A||l[15]!==M||l[16]!==s?(o={disabledToolIds:s,isResolved:A,workspaceServerToolsHref:M},l[14]=A,l[15]=M,l[16]=s,l[17]=o):o=l[17],o}();X[3]!==eg||X[4]!==eb?(s=e=>eb.has(e)?"Disabled by workspace":eg?"Not applied to interns":null,X[3]=eg,X[4]=eb,X[5]=s):s=X[5];let eS=s;X[6]!==eu||X[7]!==eb?(o=()=>{for(let e of eb)eu[e].enabled&&te(e,!1)},l=[eb,eu],X[6]=eu,X[7]=eb,X[8]=o,X[9]=l):(o=X[8],l=X[9]),(0,w.useEffect)(o,l),X[10]!==es||X[11]!==eb?(i=()=>{null!==es&&eb.has(es)&&eo(null)},d=[es,eb],X[10]=es,X[11]=eb,X[12]=i,X[13]=d):(i=X[12],d=X[13]),(0,w.useEffect)(i,d),X[14]!==ey||X[15]!==eu||X[16]!==em||X[17]!==eb?(p=()=>{if(ey)for(let{id:e}of tr.SERVER_TOOL_UI_DEFINITIONS){if(eb.has(e))continue;let t=Object.entries(eu).find(t=>{let[r]=t;return r===e})?.[1];em.includes(e)||t?.enabled||te(e,!0)}},u=[ey,eu,em,tr.SERVER_TOOL_UI_DEFINITIONS,eb],X[14]=ey,X[15]=eu,X[16]=em,X[17]=eb,X[18]=u,X[19]=p):(u=X[18],p=X[19]),(0,w.useEffect)(p,u),X[20]!==ed?(f=()=>{ed&&(ea(!0),to())},h=[ed],X[20]=ed,X[21]=f,X[22]=h):(f=X[21],h=X[22]),(0,w.useEffect)(f,h);let ew="webSearch"===es||"webFetch"===es;X[23]!==ec?(x=(0,e1.firecrawlTosStatusOptions)(ec),X[23]=ec,X[24]=x):x=X[24],X[25]!==ew||X[26]!==x?(g={...x,enabled:ew},X[25]=ew,X[26]=x,X[27]=g):g=X[27];let{data:eN,isError:eC}=(0,eJ.useQuery)(g),eI=eN?.accepted;X[28]!==ec||X[29]!==eC||X[30]!==eI?(v=(0,e2.resolveFirecrawlAvailability)({entityId:ec,isStatusError:eC,accepted:eI}),X[28]=ec,X[29]=eC,X[30]=eI,X[31]=v):v=X[31];let ek=v;X[32]!==eg||X[33]!==eu||X[34]!==eb?(b=eg?0:tr.SERVER_TOOL_UI_DEFINITIONS.filter(e=>eu[e.id].enabled&&!eb.has(e.id)).length,X[32]=eg,X[33]=eu,X[34]=eb,X[35]=b):b=X[35];let eA=b;X[36]!==es?(y=null===es?void 0:tr.SERVER_TOOL_UI_DEFINITIONS.find(e=>e.id===es),X[36]=es,X[37]=y):y=X[37];let eM=y,eT=tf,eE=(0,m.useMediaMd)(),eR=(0,e6.usePortalContainer)();X[38]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{ea(!1),eo(null),ei({})},X[38]=j):j=X[38];let ez=j,[eO,eF]=(0,w.useState)(!1);X[39]!==en?(S=()=>{if(!en)return void eF(!1);let e=requestAnimationFrame(()=>eF(!0));return()=>cancelAnimationFrame(e)},C=[en],X[39]=en,X[40]=S,X[41]=C):(S=X[40],C=X[41]),(0,w.useEffect)(S,C),X[42]!==eE||X[43]!==en||X[44]!==es?(I=()=>{if(!en||eE)return;let e=e=>{if("Escape"===e.key){if(null!==es)return void eo(null);ez()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},_=[en,eE,es],X[42]=eE,X[43]=en,X[44]=es,X[45]=I,X[46]=_):(I=X[45],_=X[46]),(0,w.useEffect)(I,_),X[47]===Symbol.for("react.memo_cache_sentinel")?(A=(0,c.cn)("flex flex-col py-1",tu),X[47]=A):A=X[47],X[48]!==ef||X[49]!==eg?(M=ef?(0,t.jsx)(tg,{hasOnlyInterns:eg}):null,X[48]=ef,X[49]=eg,X[50]=M):M=X[50],X[51]!==eS||X[52]!==eE||X[53]!==es||X[54]!==eu?(E=tr.SERVER_TOOL_UI_DEFINITIONS.map(e=>(0,t.jsx)(tv,{definition:e,tools:eu,isDrawer:!eE,disabledReason:eS(e.id),isSelected:es===e.id,onSelect:()=>{eo(e.id)},onToggle:t=>eT(e,t)},e.id)),X[51]=eS,X[52]=eE,X[53]=es,X[54]=eu,X[55]=E):E=X[55],X[56]!==M||X[57]!==E?(R=(0,t.jsx)("div",{className:"flex w-1/2 shrink-0 flex-col overflow-y-auto",children:(0,t.jsxs)("div",{className:A,children:[M,E]})}),X[56]=M,X[57]=E,X[58]=R):R=X[58];let eD=R;X[59]!==ev||X[60]!==ek||X[61]!==el||X[62]!==eM||X[63]!==eu?(z=eM?(0,t.jsx)("div",{className:"absolute inset-0 flex flex-col overflow-y-auto",children:(0,t.jsx)(tn.ServerToolSettingsPanel,{definition:eM,tools:eu,capabilityContexts:ev,isFirecrawlEnabled:ek,isMoreOptionsOpen:el[eM.id],onMoreOptionsOpenChange:e=>{ei(t=>({...t,[eM.id]:e}))},onParameterChange:tt})}):null,X[59]=ev,X[60]=ek,X[61]=el,X[62]=eM,X[63]=eu,X[64]=z):z=X[64],X[65]!==z?(O=(0,t.jsx)("div",{className:"relative w-1/2 shrink-0",children:z}),X[65]=z,X[66]=O):O=X[66];let eL=O;if(!eE){let e,r,n,a,s,o,l,i,d,u,m,p,f,h,x,g,v,b,y;X[67]!==es?(e=()=>{null!==es?eo(null):ez()},X[67]=es,X[68]=e):e=X[68];let j=eO?"opacity-100":"pointer-events-none opacity-0";X[69]!==j?(r=(0,c.cn)(e4.MOBILE_DRAWER_BACKDROP,j),X[69]=j,X[70]=r):r=X[70],X[71]!==e||X[72]!==r?(n=(0,t.jsx)("div",{"aria-hidden":"true",onClick:e,className:r}),X[71]=e,X[72]=r,X[73]=n):n=X[73];let S=en?"open":"closed",w=eO?"translate-x-0":"pointer-events-none invisible translate-x-full";X[74]!==w?(a=(0,c.cn)(e4.MOBILE_DRAWER_INSET,e4.MOBILE_DRAWER_WIDTH,e4.MOBILE_DRAWER_SURFACE,"right-0 flex flex-col dark:border-l","transition-[transform,visibility] duration-200 will-change-transform",w),X[74]=w,X[75]=a):a=X[75],X[76]!==en?(s=en?{}:{inert:!0},X[76]=en,X[77]=s):s=X[77],X[78]!==eM?(o=eM?(0,t.jsx)(tb,{ariaLabel:"Back to server tools",onClick:()=>eo(null),children:(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(eZ.ChevronLeft,{className:"size-4 shrink-0"}),(0,t.jsx)(tS,{label:eM.label})]})}):(0,t.jsx)("div",{className:"min-w-0 flex-1 pl-2 text-foreground",children:(0,t.jsx)(ty,{label:"Server tools"})}),X[78]=eM,X[79]=o):o=X[79],X[80]!==ej?(l=(0,t.jsx)(tj,{href:ej}),X[80]=ej,X[81]=l):l=X[81],X[82]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)("button",{type:"button","aria-label":"Close server tools",onClick:ez,className:(0,c.cn)("ml-auto flex size-9 shrink-0 items-center justify-center rounded-md","text-muted-foreground transition-colors","hover:bg-card-hover hover:text-foreground"),children:(0,t.jsx)(e_.X,{className:"size-5"})}),X[82]=i):i=X[82],X[83]!==o||X[84]!==l?(d=(0,t.jsxs)("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-border py-2 pl-2 pr-2",children:[o,l,i]}),X[83]=o,X[84]=l,X[85]=d):d=X[85];let N=eM?"-translate-x-1/2":"translate-x-0";X[86]!==N?(u=(0,c.cn)("flex h-full w-[200%] transition-transform duration-200 ease-out",N),X[86]=N,X[87]=u):u=X[87],X[88]!==u||X[89]!==eD||X[90]!==eL?(m=(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:(0,t.jsxs)("div",{className:u,children:[eD,eL]})}),X[88]=u,X[89]=eD,X[90]=eL,X[91]=m):m=X[91],X[92]!==S||X[93]!==a||X[94]!==s||X[95]!==d||X[96]!==m?(p=(0,t.jsxs)("div",{role:"dialog","aria-label":"Server tools","data-state":S,className:a,...s,children:[d,m]}),X[92]=S,X[93]=a,X[94]=s,X[95]=d,X[96]=m,X[97]=p):p=X[97],X[98]!==n||X[99]!==p?(f=(0,t.jsxs)(t.Fragment,{children:[n,p]}),X[98]=n,X[99]=p,X[100]=f):f=X[100];let C=f;if("host"===et){let e;return X[101]!==eR||X[102]!==C?(e=eR?(0,J.createPortal)(C,eR):null,X[101]=eR,X[102]=C,X[103]=e):e=X[103],e}if("menu"===et){let e,r,n,a,s;X[104]!==ee?(e=()=>{ee?.(),ts()},X[104]=ee,X[105]=e):e=X[105];let o=`Server tools: ${eA} active`;return X[106]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(e0.Wrench,{className:"size-4 shrink-0"}),n=(0,t.jsx)("span",{className:"flex-1 text-left",children:"Server tools"}),X[106]=r,X[107]=n):(r=X[106],n=X[107]),X[108]!==eA?(a=eA>0?(0,t.jsx)("span",{className:"flex h-4 min-w-4 items-center justify-center px-1 text-xs font-semibold leading-none text-muted-foreground",children:eA}):null,X[108]=eA,X[109]=a):a=X[109],X[110]!==e||X[111]!==o||X[112]!==a?(s=(0,t.jsxs)("button",{type:"button",onClick:e,className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-foreground transition-colors hover:bg-card-hover","aria-label":o,children:[r,n,a]}),X[110]=e,X[111]=o,X[112]=a,X[113]=s):s=X[113],s}let I=eA>0,_=0===eA,k=`Tools: ${eA} active`,A=`Tools: ${eA} active`;return X[114]===Symbol.for("react.memo_cache_sentinel")?(h=()=>ea(!0),x=(0,t.jsx)(e0.Wrench,{className:"size-5"}),X[114]=h,X[115]=x):(h=X[114],x=X[115]),X[116]!==eA?(g=(0,t.jsx)(tw,{count:eA}),X[116]=eA,X[117]=g):g=X[117],X[118]!==en||X[119]!==I||X[120]!==_||X[121]!==k||X[122]!==A||X[123]!==g?(v=(0,t.jsxs)(ex,{isActive:I,isIconOnly:_,"aria-label":k,"aria-haspopup":"dialog","aria-expanded":en,title:A,onClick:h,children:[x,g]}),X[118]=en,X[119]=I,X[120]=_,X[121]=k,X[122]=A,X[123]=g,X[124]=v):v=X[124],X[125]!==eR||X[126]!==C?(b=eR?(0,J.createPortal)(C,eR):null,X[125]=eR,X[126]=C,X[127]=b):b=X[127],X[128]!==v||X[129]!==b?(y=(0,t.jsxs)(t.Fragment,{children:[v,b]}),X[128]=v,X[129]=b,X[130]=y):y=X[130],y}if("host"===et)return null;X[131]===Symbol.for("react.memo_cache_sentinel")?(F=e=>{ea(e),e||(eo(null),ei({}))},X[131]=F):F=X[131],X[132]!==eA||X[133]!==en||X[134]!==et?(D=(0,t.jsx)(er.PopoverTrigger,{render:"menu"===et?(0,t.jsxs)(eh.Button,{type:"button",size:"sm",variant:"ghost",className:"w-full justify-start gap-2","aria-label":`Server tools: ${eA} active`,children:[(0,t.jsx)(e0.Wrench,{className:"size-4"}),(0,t.jsx)("span",{className:"flex-1 truncate text-left",children:"Server tools"}),eA>0?(0,t.jsx)("span",{className:"flex h-4 min-w-4 items-center justify-center px-1 text-xs font-semibold leading-none text-muted-foreground",children:eA}):null]}):(0,t.jsxs)(ex,{isActive:eA>0,isIconOnly:0===eA,"aria-label":`Tools: ${eA} active`,"aria-haspopup":"dialog","aria-expanded":en,title:en?void 0:`Tools: ${eA} active`,children:[(0,t.jsx)(e0.Wrench,{className:"size-5"}),(0,t.jsx)(tw,{count:eA})]})}),X[132]=eA,X[133]=en,X[134]=et,X[135]=D):D=X[135],X[136]!==eM?(L=eM?(0,t.jsx)(tb,{ariaLabel:"Back to server tools",className:"-ml-2",onClick:()=>eo(null),children:(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(eZ.ChevronLeft,{className:"size-3.5 shrink-0"}),(0,t.jsx)(tS,{label:"Back"})]})}):(0,t.jsx)("div",{className:"min-w-0 flex-1 text-muted-foreground",children:(0,t.jsx)(ty,{label:"Server tools"})}),X[136]=eM,X[137]=L):L=X[137],X[138]!==ej?(P=(0,t.jsx)(tj,{href:ej}),X[138]=ej,X[139]=P):P=X[139],X[140]!==L||X[141]!==P?(B=(0,t.jsxs)("div",{className:"flex h-10 items-center justify-between border-b border-border px-3.5",children:[L,P]}),X[140]=L,X[141]=P,X[142]=B):B=X[142];let eP=eM?"-translate-x-1/2":"translate-x-0";return X[143]!==eP?(V=(0,c.cn)("flex w-[200%] transition-transform duration-200 ease-out",eP),X[143]=eP,X[144]=V):V=X[144],X[145]===Symbol.for("react.memo_cache_sentinel")?($=(0,c.cn)("flex flex-col py-1",tu),X[145]=$):$=X[145],X[146]!==ef||X[147]!==eg?(H=ef?(0,t.jsx)(tg,{hasOnlyInterns:eg}):null,X[146]=ef,X[147]=eg,X[148]=H):H=X[148],X[149]!==eS||X[150]!==es||X[151]!==eu?(U=tr.SERVER_TOOL_UI_DEFINITIONS.map(e=>(0,t.jsx)(tv,{definition:e,tools:eu,disabledReason:eS(e.id),isSelected:es===e.id,onSelect:()=>{eo(e.id)},onToggle:t=>eT(e,t)},e.id)),X[149]=eS,X[150]=es,X[151]=eu,X[152]=U):U=X[152],X[153]!==H||X[154]!==U?(G=(0,t.jsx)("div",{className:"flex w-1/2 shrink-0 flex-col",children:(0,t.jsxs)("div",{className:$,children:[H,U]})}),X[153]=H,X[154]=U,X[155]=G):G=X[155],X[156]!==ev||X[157]!==ek||X[158]!==el||X[159]!==eM||X[160]!==eu?(q=eM?(0,t.jsx)("div",{className:"flex flex-col",children:(0,t.jsx)(tn.ServerToolSettingsPanel,{definition:eM,tools:eu,capabilityContexts:ev,isFirecrawlEnabled:ek,isMoreOptionsOpen:el[eM.id],onMoreOptionsOpenChange:e=>{ei(t=>({...t,[eM.id]:e}))},onParameterChange:tt})}):null,X[156]=ev,X[157]=ek,X[158]=el,X[159]=eM,X[160]=eu,X[161]=q):q=X[161],X[162]!==q?(W=(0,t.jsx)("div",{className:"w-1/2 shrink-0",children:q}),X[162]=q,X[163]=W):W=X[163],X[164]!==V||X[165]!==G||X[166]!==W?(K=(0,t.jsxs)("div",{className:V,children:[G,W]}),X[164]=V,X[165]=G,X[166]=W,X[167]=K):K=X[167],X[168]!==B||X[169]!==K?(Z=(0,t.jsxs)(er.PopoverContent,{side:"top",align:"start",initialFocus:tp,className:"w-96 overflow-x-hidden p-0 sm:w-[26rem]",children:[B,K]}),X[168]=B,X[169]=K,X[170]=Z):Z=X[170],X[171]!==en||X[172]!==D||X[173]!==Z?(Y=(0,t.jsxs)(er.Popover,{open:en,onOpenChange:F,children:[D,Z]}),X[171]=en,X[172]=D,X[173]=Z,X[174]=Y):Y=X[174],Y}function tp(e){return"keyboard"===e}function tf(e,t){te(e.id,t,{markAsUserPreference:!0}),(0,e3.trackToolToggle)({tool:e.analyticsName,enabled:t})}function th(e){return e.userConfiguredToolIds}function tx(e){return e.tools}function tg(e){let n,a=(0,r.c)(2),{hasOnlyInterns:s}=e,o=s?"Interns bring their own tools; nothing here reaches them.":"Not applied to interns; they bring their own tools.";return a[0]!==o?(n=(0,t.jsx)("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:o}),a[0]=o,a[1]=n):n=a[1],n}function tv(e){let n,a,s,o,l,i,d,u,m,p,f,h,x,g,v,b,y,j=(0,r.c)(50),{definition:S,tools:w,isDrawer:N,disabledReason:C,isSelected:I,onSelect:_,onToggle:k}=e,A=w[S.id],M=S.icon;j[0]!==S||j[1]!==A.parameters?(n=S.getSummary(A.parameters),j[0]=S,j[1]=A.parameters,j[2]=n):n=j[2];let T=n,E=null!==C,R=I?"bg-selected-bg":"hover:bg-card-hover",z=E?"cursor-default text-muted-foreground opacity-50":R;j[3]!==z?(a=(0,c.cn)("flex items-center justify-between px-3.5 py-2.5 transition-colors",z),j[3]=z,j[4]=a):a=j[4];let O=E?"cursor-default text-muted-foreground hover:bg-transparent hover:text-muted-foreground":"hover:bg-transparent hover:text-foreground";j[5]!==O?(s=(0,c.cn)("h-auto min-w-0 flex-1 items-start justify-start gap-2.5 rounded-none bg-transparent p-0 text-left after:absolute after:inset-0 after:content-['']",O),j[5]=O,j[6]=s):s=j[6],j[7]!==E||j[8]!==_?(o=()=>{E||_()},j[7]=E,j[8]=_,j[9]=o):o=j[9];let F=E?"text-muted-foreground":"text-foreground";j[10]!==F?(l=(0,c.cn)("size-5",F),j[10]=F,j[11]=l):l=j[11],j[12]!==M||j[13]!==l?(i=(0,t.jsx)("div",{className:"shrink-0 mt-0.5 cursor-default",children:(0,t.jsx)(M,{className:l})}),j[12]=M,j[13]=l,j[14]=i):i=j[14],j[15]!==S.label?(d=(0,t.jsx)("span",{className:"text-sm font-medium",children:S.label}),j[15]=S.label,j[16]=d):d=j[16],j[17]!==S.description?(u=(0,t.jsx)("span",{className:"block truncate w-full mt-0.5 text-2xs leading-4 text-muted-foreground",children:S.description}),j[17]=S.description,j[18]=u):u=j[18],j[19]!==T?(m=T?(0,t.jsx)("span",{className:"text-2xs text-muted-foreground font-medium block truncate w-full mt-0.5",children:T}):null,j[19]=T,j[20]=m):m=j[20],j[21]!==C?(p=C?(0,t.jsx)("span",{className:"text-2xs text-muted-foreground block truncate w-full mt-0.5",children:C}):null,j[21]=C,j[22]=p):p=j[22],j[23]!==d||j[24]!==u||j[25]!==m||j[26]!==p?(f=(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[d,u,m,p]}),j[23]=d,j[24]=u,j[25]=m,j[26]=p,j[27]=f):f=j[27],j[28]!==E||j[29]!==I||j[30]!==f||j[31]!==s||j[32]!==o||j[33]!==i?(h=(0,t.jsxs)(eh.Button,{variant:"ghost",size:"sm",className:s,onClick:o,"aria-disabled":E,"aria-expanded":I,children:[i,f]}),j[28]=E,j[29]=I,j[30]=f,j[31]=s,j[32]=o,j[33]=i,j[34]=h):h=j[34];let D=!E&&A.enabled,L=`Toggle ${S.label}`,P=void 0!==N&&N?"scale-90":"scale-[0.8]";return j[35]!==P?(x=(0,c.cn)("origin-right md:scale-100",P),j[35]=P,j[36]=x):x=j[36],j[37]!==E||j[38]!==k||j[39]!==D||j[40]!==L||j[41]!==x?(g=(0,t.jsx)("div",{className:"relative z-10 -m-1 p-1",children:(0,t.jsx)(eW.Switch,{checked:D,disabled:E,onCheckedChange:k,"aria-label":L,className:x})}),j[37]=E,j[38]=k,j[39]=D,j[40]=L,j[41]=x,j[42]=g):g=j[42],j[43]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)(eY.ChevronRight,{className:"size-3.5 text-muted-foreground"}),j[43]=v):v=j[43],j[44]!==g?(b=(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[g,v]}),j[44]=g,j[45]=b):b=j[45],j[46]!==h||j[47]!==b||j[48]!==a?(y=(0,t.jsx)("div",{className:"relative",children:(0,t.jsxs)("div",{className:a,children:[h,b]})}),j[46]=h,j[47]=b,j[48]=a,j[49]=y):y=j[49],y}function tb(e){let n,a,s=(0,r.c)(15),{ariaLabel:o,children:l,className:i,href:d,onClick:u}=e;if(d){let e,r;return s[0]!==i?(e=(0,c.cn)("inline-flex items-center text-muted-foreground transition-colors hover:text-foreground",i),s[0]=i,s[1]=e):e=s[1],s[2]!==o||s[3]!==l||s[4]!==d||s[5]!==u||s[6]!==e?(r=(0,t.jsx)("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:e,"aria-label":o,onClick:u,children:l}),s[2]=o,s[3]=l,s[4]=d,s[5]=u,s[6]=e,s[7]=r):r=s[7],r}return s[8]!==i?(n=(0,c.cn)("inline-flex items-center text-muted-foreground transition-colors hover:text-foreground","px-2",i),s[8]=i,s[9]=n):n=s[9],s[10]!==o||s[11]!==l||s[12]!==u||s[13]!==n?(a=(0,t.jsx)(eh.Button,{variant:"ghost",size:"sm",className:n,"aria-label":o,onClick:u,children:l}),s[10]=o,s[11]=l,s[12]=u,s[13]=n,s[14]=a):a=s[14],a}function ty(e){let n,a,s,o=(0,r.c)(5),{label:l}=e;return o[0]!==l?(n=(0,t.jsx)(tS,{label:l}),o[0]=l,o[1]=n):n=o[1],o[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("a",{href:tr.TOOL_DOCS_URL,target:"_blank",rel:"noopener noreferrer",className:"inline-flex size-3.5 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:text-foreground","aria-label":"Server tools documentation",onClick:e3.trackToolDocsClick,children:(0,t.jsx)(eX.ExternalLink,{className:"size-3.5",strokeWidth:2})}),o[2]=a):a=o[2],o[3]!==n?(s=(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[n,a]}),o[3]=n,o[4]=s):s=o[4],s}function tj(e){let n,a,s,o=(0,r.c)(4),{href:l}=e;return void 0===l?null:(o[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)("span",{children:"Configure"}),a=(0,t.jsx)(eQ.Settings,{className:"size-3.5"}),o[0]=n,o[1]=a):(n=o[0],a=o[1]),o[2]!==l?(s=(0,t.jsxs)("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-label":"Configure workspace server tools",children:[n,a]}),o[2]=l,o[3]=s):s=o[3],s)}function tS(e){let n,a=(0,r.c)(2),{label:s}=e;return a[0]!==s?(n=(0,t.jsx)("span",{className:"min-w-0 truncate text-sm font-medium leading-none",children:s}),a[0]=s,a[1]=n):n=a[1],n}function tw(e){let n,a=(0,r.c)(2),{count:s}=e;return 0===s?null:(a[0]!==s?(n=(0,t.jsx)("span",{className:"flex h-4 min-w-4 items-center justify-center rounded-full bg-foreground px-1 text-xs font-semibold leading-none text-background",children:s}),a[0]=s,a[1]=n):n=a[1],n)}var tN=e.i(389097);let tC=(0,e.i(202913).default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);var tI=e.i(151960),t_=e.i(626824),tk=e.i(204067),tA=e.i(796805);let tM=tA.z.object({id:tA.z.string(),object:tA.z.literal("container.file"),container_id:tA.z.string(),bytes:(0,tk.zInt)(),created_at:(0,tk.zInt)(),path:tA.z.string(),source:tA.z.literal("assistant")});tA.z.object({object:tA.z.literal("list"),data:tA.z.array(tM),first_id:tA.z.string().nullable(),last_id:tA.z.string().nullable(),has_more:tA.z.boolean()});var tT=e.i(29154),tE=e.i(8842),tR=e.i(450740);let tz=tA.z.array(tT.FileMetadataSchema),tO=(0,t_.createQueryKeys)("playground-files",{list:e=>[{workspaceId:e}]});function tF(e){return(0,tE.queryOptions)({queryKey:tO.list(e),queryFn:void 0===e?tR.skipToken:({signal:e})=>(0,tI.fetchAPIQuery)("/api/frontend/v1/private/playground-files",{signal:e,schema:tz})})}let tD="/api/frontend/v1/private/container-files",tL=tA.z.array(tM),tP=(0,t_.createQueryKeys)("container-files",{list:e=>[{containerId:e}]});e.s(["containerFileContentPath",0,function(e,t){return`${tD}/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}/content`},"containerFilesOptions",0,function(e){return(0,tE.queryOptions)({queryKey:tP.list(e),queryFn:null===e?tR.skipToken:({signal:t})=>(0,tI.fetchAPIQuery)(`${tD}/${e}/files`,{signal:t,schema:tL})})},"playgroundFilesOptions",0,tF],564353);let tB=ed(),tV=tB.requestOpen,t$=tB.clearRequest,tH=tB.useShouldOpen;var tU=e.i(893694),tG=e.i(779100);function tq(e){let n,a,s=(0,r.c)(12),{isLoading:o,didFail:l,files:i,onSelect:c}=e,d=(0,tG.useLocale)();if(l){let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Could not load your workspace. Try again in a moment."}),s[0]=e):e=s[0],e}if(o){let e;return s[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Loading files…"}),s[1]=e):e=s[1],e}if(0===i.length){let e;return s[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No uploaded files found in this workspace."}),s[2]=e):e=s[2],e}if(s[3]!==i||s[4]!==d||s[5]!==c){let e;s[7]!==d||s[8]!==c?(e=e=>(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",onClick:()=>c(e),className:"flex w-full items-center justify-between gap-3 rounded-md px-3.5 py-2.5 text-left text-sm hover:bg-muted",children:[(0,t.jsx)("span",{className:"truncate font-medium text-foreground",children:e.filename}),(0,t.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:(0,tU.formatFileBytes)(e.size_bytes,{locale:d})??"—"})]})},e.id),s[7]=d,s[8]=c,s[9]=e):e=s[9],n=i.map(e),s[3]=i,s[4]=d,s[5]=c,s[6]=n}else n=s[6];return s[10]!==n?(a=(0,t.jsx)("ul",{className:"flex max-h-96 flex-col gap-1.5 overflow-y-auto",children:n}),s[10]=n,s[11]=a):a=s[11],a}function tW(e){let n,a,s,o,l,i,c,d,m,p,f,x,g,v,b,y=(0,r.c)(55),{attachments:j,variant:S,onNavigate:N}=e,C=void 0===S?"footer":S,[I,_]=(0,w.useState)(!1),k=j.list.length>=j.limit,{isSignedIn:A}=(0,ti.useAuth)(),M=!0===A;y[0]!==M?(n={isEnabled:M},y[0]=M,y[1]=n):n=y[1];let{activeWorkspaceId:T,didFetchFail:E}=(0,td.useUserWorkspaces)(n);y[2]!==T?(a=tF(T),y[2]=T,y[3]=a):a=y[3],y[4]!==I||y[5]!==a?(s={...a,enabled:I},y[4]=I,y[5]=a,y[6]=s):s=y[6];let{data:R,isLoading:z,error:O}=(0,eJ.useQuery)(s),F=void 0===T;y[7]!==O||y[8]!==I?(o=()=>{I&&O&&(0,u.toast)({title:"Could not load files",description:O.message,variant:"destructive"})},l=[I,O],y[7]=O,y[8]=I,y[9]=o,y[10]=l):(o=y[9],l=y[10]),(0,w.useEffect)(o,l);let D=tH();y[11]!==D||y[12]!==C?(i=()=>{"host"===C&&D&&(_(!0),t$())},c=[C,D],y[11]=D,y[12]=C,y[13]=i,y[14]=c):(i=y[13],c=y[14]),(0,w.useEffect)(i,c),y[15]!==j?(d=e=>{j.list.some(t=>t.fileId===e.id||t.name===e.filename&&t.size===e.size_bytes)||j.set([...j.list,{type:h.AttachmentType.File,name:e.filename,size:e.size_bytes,mime:e.mime_type,fileId:e.id}]),_(!1)},y[15]=j,y[16]=d):d=y[16];let L=d;if(!1===A)return null;if("menu"===C){let e,r,n,a;return y[17]!==N?(e=()=>{N?.(),tV()},y[17]=N,y[18]=e):e=y[18],y[19]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(tC,{className:"size-4 shrink-0"}),n=(0,t.jsx)("span",{className:"flex-1 truncate text-left",children:"Attach uploaded file"}),y[19]=r,y[20]=n):(r=y[19],n=y[20]),y[21]!==k||y[22]!==e?(a=(0,t.jsxs)("button",{type:"button",disabled:k,onClick:e,className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-foreground transition-colors hover:bg-card-hover disabled:cursor-not-allowed disabled:opacity-50","aria-label":"Attach uploaded file",children:[r,n]}),y[21]=k,y[22]=e,y[23]=a):a=y[23],a}if("host"===C){let e,r,n,a;y[24]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)(tN.DialogHeader,{children:[(0,t.jsx)(tN.DialogTitle,{children:"Attach an uploaded file"}),(0,t.jsx)(tN.DialogDescription,{children:"Reference a file already uploaded to your workspace. OpenRouter inlines its content for the model."})]}),y[24]=e):e=y[24];let s=z||F;return y[25]!==R?(r=R??[],y[25]=R,y[26]=r):r=y[26],y[27]!==L||y[28]!==E||y[29]!==s||y[30]!==r?(n=(0,t.jsxs)(tN.DialogContent,{className:"max-w-md",children:[e,(0,t.jsx)(tq,{isLoading:s,didFail:E,files:r,onSelect:L})]}),y[27]=L,y[28]=E,y[29]=s,y[30]=r,y[31]=n):n=y[31],y[32]!==I||y[33]!==n?(a=(0,t.jsx)(tN.Dialog,{open:I,onOpenChange:_,children:n}),y[32]=I,y[33]=n,y[34]=a):a=y[34],a}let P=k?`Maximum ${j.limit} attachments added.`:"Attach a file you previously uploaded to this workspace.";y[35]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(tC,{className:"size-5"}),y[35]=m):m=y[35],y[36]!==k||y[37]!==I?(p=(0,t.jsx)("span",{className:"inline-flex",children:(0,t.jsx)(er.PopoverTrigger,{render:(0,t.jsx)(ex,{isIconOnly:!0,disabled:k,"aria-label":"Attach uploaded file","aria-haspopup":"dialog","aria-expanded":I,children:m})})}),y[36]=k,y[37]=I,y[38]=p):p=y[38],y[39]!==I||y[40]!==P||y[41]!==p?(f=(0,t.jsx)(eG.Tooltip,{className:"w-44",disabled:I,content:P,children:p}),y[39]=I,y[40]=P,y[41]=p,y[42]=f):f=y[42],y[43]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsxs)("div",{className:"mb-4 flex flex-col gap-y-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Attach an uploaded file"}),(0,t.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Reference a file already uploaded to your workspace. OpenRouter inlines its content for the model."})]}),y[43]=x):x=y[43];let B=z||F;return y[44]!==R?(g=R??[],y[44]=R,y[45]=g):g=y[45],y[46]!==L||y[47]!==E||y[48]!==B||y[49]!==g?(v=(0,t.jsxs)(er.PopoverContent,{side:"top",align:"start",className:"w-[92vw] max-w-[480px] p-5",children:[x,(0,t.jsx)(tq,{isLoading:B,didFail:E,files:g,onSelect:L})]}),y[46]=L,y[47]=E,y[48]=B,y[49]=g,y[50]=v):v=y[50],y[51]!==I||y[52]!==f||y[53]!==v?(b=(0,t.jsxs)(er.Popover,{open:I,onOpenChange:_,children:[f,v]}),y[51]=I,y[52]=f,y[53]=v,y[54]=b):b=y[54],b}var tK=e.i(704318);let tJ=e=>{let n,a,s,o,l=(0,r.c)(9),{message:i,buttonLabel:c,onAdd:u}=e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(tK.InformationCircleIcon,{className:"size-5 shrink-0 text-warning"}),l[0]=n):n=l[0],l[1]!==i?(a=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[n,(0,t.jsx)("span",{children:i})]}),l[1]=i,l[2]=a):a=l[2],l[3]!==c||l[4]!==u?(s=(0,t.jsx)(eh.Button,{size:"sm",variant:"outline",className:"border-warning/30 text-warning-text hover:bg-warning-bg hover:text-warning-text",onClick:u,children:c}),l[3]=c,l[4]=u,l[5]=s):s=l[5],l[6]!==a||l[7]!==s?(o=(0,t.jsxs)(d.Fade,{inClassName:"slide-in-from-bottom-4",className:"flex items-center justify-between gap-2 rounded-lg border border-warning/30 bg-warning-bg px-2 py-2 text-sm text-warning-text mb-2",children:[a,s]}),l[6]=a,l[7]=s,l[8]=o):o=l[8],o};function tZ(e){if((0,v.isCoarsePointer)())return;let{target:t}=e;t instanceof HTMLElement&&t.closest('input, textarea, [contenteditable="true"]')||e.preventDefault()}let tY={[z.ImageArchetype.Default]:{label:"Image",Icon:s.PhotoIcon},[z.AppArchetype.InteractiveWebApp]:{label:"Web App",Icon:l.WindowIcon},[z.AppArchetype.LandingPage]:{label:"Landing Page",Icon:n.ComputerDesktopIcon},[z.AppArchetype.TwoDGame]:{label:"2D Game",Icon:o.Squares2X2Icon},[z.AppArchetype.ThreeDGame]:{label:"3D Game",Icon:a.CubeIcon}},tX=[];function tQ(e){var n;let a,s,o,l,i,h,O,F,D,L,P,$,H,U,G,W,K,J,Z,Y,X,Q,ee,et,er,en,ea,es,eo,el,ei,ec,ed,eu,em,ep,ef,eh,ex,ev,eb,ey,ej,eS=(0,r.c)(138),{isTextOnly:ew}=e,{getModelInfoByVariantSlug:eN}=(0,x.useGlobal)(),eC=(0,R.useLocalizedRouter)(),[e_]=(0,S.useQueryState)("message"),eA=(0,j.useSearchParams)();eS[0]!==eA?(a=(0,E.filterChatReferenceUrls)(eA?.getAll(E.CHAT_REFERENCE_PARAM)??[]),eS[0]=eA,eS[1]=a):a=eS[1];let eM=a,eT=(0,w.useRef)(null),[eE,ez]=(0,w.useState)(void 0),[eO,eF]=(0,w.useState)(!1),[eD,eL]=(0,w.useState)(!1),eB=(0,T.useChatroomStore)(A.selectCurrentRoomId),eV=(0,T.useChatroomStore)(A.selectCurrentIsProcessing),e$=(0,g.useUserStore)(t7),eH=(0,g.useUserStore)(t6),eU=(0,T.useChatroomStore)(k.selectActiveCharacters),eG=(0,T.useChatroomStore)((0,N.useShallow)(k.selectActiveCharacterKinds)),eW=(0,m.useMediaMd)(),eK=(0,f.useAttachments)(),eJ=eG.hasOnlyInterns||ew;eS[2]!==eJ||eS[3]!==eK?(s=eJ?{...eK,handleFiles:t9}:eK,eS[2]=eJ,eS[3]=eK,eS[4]=s):s=eS[4];let eZ=s,{set:eY}=eZ,{registerDropHandler:eX}=B();eS[5]!==eZ.handleFiles||eS[6]!==eX?(o=()=>eX(eZ.handleFiles),l=[eZ.handleFiles,eX],eS[5]=eZ.handleFiles,eS[6]=eX,eS[7]=o,eS[8]=l):(o=eS[7],l=eS[8]),(0,w.useEffect)(o,l),n=ew?tX:eM,ey=(0,r.c)(4),ej=(0,w.useRef)(!1),ey[0]!==n||ey[1]!==eY?(ev=()=>{ej.current||0===n.length||(ej.current=!0,eY((0,E.toChatReferenceAttachments)(n)))},eb=[n,eY],ey[0]=n,ey[1]=eY,ey[2]=ev,ey[3]=eb):(ev=ey[2],eb=ey[3]),(0,w.useEffect)(ev,eb),eS[9]!==eB||eS[10]!==eV?(i=()=>{!(0,v.isCoarsePointer)()&&eB&&eT.current&&!eV&&requestAnimationFrame(()=>{eT.current&&!eT.current.disabled&&eT.current.focus()})},h=[eB,eV],eS[9]=eB,eS[10]=eV,eS[11]=i,eS[12]=h):(i=eS[11],h=eS[12]),(0,w.useEffect)(i,h),eS[13]!==e_?(O=()=>{if(e_){V.getState().setPrompt((0,b.safeDecodeURIComponent)(e_)),T.useChatroomStore.getState().pendingMessage&&M.chatroomStoreActions.setPendingMessage({payload:{message:null,source:null}});return}let e=T.useChatroomStore.getState().pendingMessage;e&&(V.getState().setPrompt(e),M.chatroomStoreActions.setPendingMessage({payload:{message:null,source:null}}))},F=[e_],eS[13]=e_,eS[14]=O,eS[15]=F):(O=eS[14],F=eS[15]),(0,w.useEffect)(O,F),eS[16]!==eZ.list?(D=eZ.list.some(t4),eS[16]=eZ.list,eS[17]=D):D=eS[17];let eQ=D;eS[18]!==eU||eS[19]!==eQ?(L=eQ&&!eU.some(t5),eS[18]=eU,eS[19]=eQ,eS[20]=L):L=eS[20];let e0=L;eS[21]!==eZ.list?(P=eZ.list.some(t3),eS[21]=eZ.list,eS[22]=P):P=eS[22];let e1=P;eS[23]!==eU||eS[24]!==e1?($=e1&&!eU.some(t2),eS[23]=eU,eS[24]=e1,eS[25]=$):$=eS[25];let e2=$;eS[26]!==eZ?(H=()=>{V.getState().setPrompt(""),eZ.reset()},eS[26]=eZ,eS[27]=H):H=eS[27];let e3=H;eS[28]!==eB?(U=async e=>{eF(!1);let t=(0,y.getModelVariantSlug)(e);await M.chatroomStoreActions.addCharacters({payload:{roomId:eB,characters:{model:t,modelInfo:e,samplingParameters:{}}}})},eS[28]=eB,eS[29]=U):U=eS[29];let e5=U;eS[30]!==eB?(G=async e=>{eL(!1);let t=(0,y.getModelVariantSlug)(e);await M.chatroomStoreActions.addCharacters({payload:{roomId:eB,characters:{model:t,modelInfo:e,samplingParameters:{}}}})},eS[30]=eB,eS[31]=G):G=eS[31];let e4=G;eS[32]!==eZ.list||eS[33]!==eZ.loadingKeys.size||eS[34]!==eE||eS[35]!==eB||eS[36]!==eH?.default_text_model||eS[37]!==eN||eS[38]!==e$||eS[39]!==e3||eS[40]!==eC||eS[41]!==e0||eS[42]!==e2?(W=async()=>{if(eZ.loadingKeys.size>0)return;if(e0)return void(0,u.toast)({title:"No Audio Model Selected",description:"Could not find an active model to process audio input.",variant:"destructive"});if(e2)return void(0,u.toast)({title:"No Video Model Selected",description:"Could not find an active model to process video input.",variant:"destructive"});let e=V.getState().prompt,t=eZ.list;if(eE&&eE!==z.ImageArchetype.Default){if(M.chatroomStoreActions.setPendingMessage({payload:{message:e,source:z.PendingMessageSource.UserInput}}),eB&&M.chatroomStoreActions.setPendingRoomId({payload:{roomId:eB}}),!e$)return void M.chatroomStoreActions.setShowSignUpModal({payload:{show:!0}});let r=e.split("\n")[0]||_.DEFAULT_APP_NAME;return void await M.chatroomStoreActions.generateArtifact({payload:{roomId:eB,name:r,prompt:e,attachments:t,type:z.ArtifactType.App,archetype:eE,stack:z.AppStack.HTML,retryFromMessageId:null},dependencies:{getModelInfoByVariantSlug:eN,router:eC,resetComposer:e3}})}await M.chatroomStoreActions.sendMessage({payload:{roomId:eB,isSignedIn:!!e$,content:e,attachments:t,defaultModelSlug:eH?.default_text_model||_.defaultCharacterModelSlug||null},dependencies:{router:eC,getModelInfoByVariantSlug:eN,resetComposer:e3}})},eS[32]=eZ.list,eS[33]=eZ.loadingKeys.size,eS[34]=eE,eS[35]=eB,eS[36]=eH?.default_text_model,eS[37]=eN,eS[38]=e$,eS[39]=e3,eS[40]=eC,eS[41]=e0,eS[42]=e2,eS[43]=W):W=eS[43],eH?.default_text_model;let e6=W,e7=eE?tY[eE]:null,{isMultiline:e8,rowRef:e9,leftControlsRef:te,rightControlsRef:tt,mirrorRef:tr}=function(e,t){var n,a;let s,o,l,i,c,d,u=(0,r.c)(12),[m,p]=(0,w.useState)(!1),f=(0,w.useRef)(null),h=(0,w.useRef)(null),x=(0,w.useRef)(null),g=(0,w.useRef)(null);u[0]!==t?(s=()=>{let e=f.current,r=h.current,n=x.current,a=t.current,s=g.current;if(!e||!r||!n||!a||!s)return;let{prompt:o}=V.getState(),l=window.getComputedStyle(a),i=Number.parseFloat(l.lineHeight)||1.2*Number.parseFloat(l.fontSize)||20,c=e.clientWidth-r.offsetWidth-n.offsetWidth-12;c<=0||(s.style.width=`${c}px`,s.style.fontFamily=l.fontFamily,s.style.fontSize=l.fontSize,s.style.fontWeight=l.fontWeight,s.style.lineHeight=l.lineHeight,s.style.letterSpacing=l.letterSpacing,s.textContent=o,p(function({measuredHeightPx:e,lineHeightPx:t,text:r}){return Math.max(1,t>0?Math.round(e/t):1,r.length>0?r.split("\n").length:1)}({measuredHeightPx:s.scrollHeight,lineHeightPx:i,text:o})>=2))},u[0]=t,u[1]=s):s=u[1];let v=s;return u[2]!==e||u[3]!==v?(o=()=>e?(v(),V.subscribe((e,t)=>{e.prompt!==t.prompt&&v()})):void p(!1),l=[e,v],u[2]=e,u[3]=v,u[4]=o,u[5]=l):(o=u[4],l=u[5]),n=o,a=l,(0,w.useLayoutEffect)(n,a),u[6]!==e||u[7]!==v?(i=()=>{if(!e)return;let t=f.current,r=h.current,n=x.current;if(!t||!r||!n)return;let a=new ResizeObserver(()=>v());return a.observe(t),a.observe(r),a.observe(n),()=>a.disconnect()},c=[e,v],u[6]=e,u[7]=v,u[8]=i,u[9]=c):(i=u[8],c=u[9]),(0,w.useEffect)(i,c),u[10]!==m?(d={isMultiline:m,rowRef:f,leftControlsRef:h,rightControlsRef:x,mirrorRef:g},u[10]=m,u[11]=d):d=u[11],d}(!eE&&(!eW||ew),eT);eS[44]!==eE?(K={inputRef:eT,layoutKey:eE},eS[44]=eE,eS[45]=K):K=eS[45];let{captureCaret:tn,preserveFocusOnPointerDown:ta}=function(e){let t,n,a,s,o=(0,r.c)(9),{inputRef:l,layoutKey:i}=e,c=(0,w.useRef)(null);o[0]!==l?(t=()=>{let e=l.current;c.current=e?e.selectionStart:null},o[0]=l,o[1]=t):t=o[1];let d=t;return o[2]!==l?(n=()=>{let e=c.current;if(c.current=null,null===e||(0,v.isCoarsePointer)())return;let t=l.current;if(!t)return;t.focus({preventScroll:!0});let r=Math.min(Math.max(e,0),t.value.length);t.setSelectionRange(r,r)},o[2]=l,o[3]=n):n=o[3],o[4]!==l||o[5]!==i?(a=[i,l],o[4]=l,o[5]=i,o[6]=a):a=o[6],(0,w.useEffect)(n,a),o[7]!==d?(s={captureCaret:d,preserveFocusOnPointerDown:tZ},o[7]=d,o[8]=s):s=o[8],s}(K);eS[46]!==tn?(J=e=>{tn(),ez(e)},eS[46]=tn,eS[47]=J):J=eS[47];let ts=J;eS[48]!==tn?(Z=()=>{tn(),ez(void 0)},eS[48]=tn,eS[49]=Z):Z=eS[49];let to=Z,tl=eZ.list.length,ti=eZ.reset;eS[50]!==tl||eS[51]!==eE||eS[52]!==to||eS[53]!==eJ||eS[54]!==ti?(Y=()=>{eJ&&(void 0!==eE&&to(),tl>0&&ti())},X=[tl,eE,to,eJ,ti],eS[50]=tl,eS[51]=eE,eS[52]=to,eS[53]=eJ,eS[54]=ti,eS[55]=Y,eS[56]=X):(Y=eS[55],X=eS[56]),(0,w.useEffect)(Y,X);let tc=!!(eE&&e7)&&!ew,td=!tc&&eW&&!ew,tu=!tc&&(!eW||ew);return eS[57]===Symbol.for("react.memo_cache_sentinel")?(Q={isolation:"isolate",contain:"layout"},eS[57]=Q):Q=eS[57],eS[58]!==eW||eS[59]!==ew?(ee=!eW&&!ew&&(0,t.jsx)(tm,{variant:"host"}),eS[58]=eW,eS[59]=ew,eS[60]=ee):ee=eS[60],eS[61]!==eW||eS[62]!==ew?(et=!eW&&!ew&&(0,t.jsx)(eg,{variant:"host"}),eS[61]=eW,eS[62]=ew,eS[63]=et):et=eS[63],eS[64]!==eZ||eS[65]!==eW||eS[66]!==ew?(er=!eW&&!ew&&(0,t.jsx)(tW,{attachments:eZ,variant:"host"}),eS[64]=eZ,eS[65]=eW,eS[66]=ew,eS[67]=er):er=eS[67],eS[68]!==e0||eS[69]!==e2?(en=(e0||e2)&&(0,t.jsxs)("div",{children:[e0&&(0,t.jsx)(tJ,{message:"An audio input model is required.",buttonLabel:"Add Audio Model",onAdd:()=>eF(!0)}),e2&&(0,t.jsx)(tJ,{message:"A video input model is required.",buttonLabel:"Add Video Model",onAdd:()=>eL(!0)})]}),eS[68]=e0,eS[69]=e2,eS[70]=en):en=eS[70],eS[71]!==eZ?(ea=(0,t.jsx)(q,{attachments:eZ}),eS[71]=eZ,eS[72]=ea):ea=eS[72],eS[73]===Symbol.for("react.memo_cache_sentinel")?(es=(0,c.cn)("relative rounded-3xl border border-border bg-popover px-3 py-1.5 text-sm pointer-coarse:text-base","[&_button]:rounded-full transition-colors focus-within:border-border/80"),eS[73]=es):es=eS[73],eS[74]!==e7||eS[75]!==eZ||eS[76]!==eE||eS[77]!==to||eS[78]!==ts||eS[79]!==e6||eS[80]!==eG||eS[81]!==eW||eS[82]!==eV||eS[83]!==ew||eS[84]!==ta?(eo=eE&&e7&&(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)(eP,{ref:eT,placeholder:(e=>{if(!e)return"Start a new message...";let t=tY[e];return`Describe the ${t.label.toLowerCase()} you want to create...`})(eE),attachments:eZ,onSend:e6,disabled:eV,inputClassName:"border-none focus-visible:border-transparent focus-visible:shadow-none"}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",onMouseDown:ta,children:[(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,t.jsx)(eR,{attachments:eZ,internPresence:eG,activeMode:eE,onSelectMode:ts,disabled:eV,extraActions:eW?void 0:e=>{let{closeMenu:r}=e;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tm,{variant:"menu",onNavigate:r}),(0,t.jsx)(eg,{variant:"menu",onNavigate:r}),(0,t.jsx)(tW,{attachments:eZ,variant:"menu",onNavigate:r})]})}}),eW&&(0,t.jsx)(tm,{}),eW&&(0,t.jsx)(eg,{}),eW&&(0,t.jsx)(tW,{attachments:eZ})]}),(0,t.jsx)(ek,{label:e7.label,Icon:e7.Icon,onClear:to}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[ew?null:(0,t.jsx)(eI,{attachments:eZ}),(0,t.jsx)(eq,{attachmentCount:eZ.list.length,disabled:eV,isLoading:eZ.loadingKeys.size>0,onSend:e6,onStop:M.chatroomStoreActions.stopGeneration,isCommandActive:!!eE})]})]})]}),eS[74]=e7,eS[75]=eZ,eS[76]=eE,eS[77]=to,eS[78]=ts,eS[79]=e6,eS[80]=eG,eS[81]=eW,eS[82]=eV,eS[83]=ew,eS[84]=ta,eS[85]=eo):eo=eS[85],eS[86]!==eZ||eS[87]!==eE||eS[88]!==ts||eS[89]!==e6||eS[90]!==eG||eS[91]!==td||eS[92]!==eV||eS[93]!==ew||eS[94]!==ta?(el=td&&(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)(eP,{ref:eT,placeholder:"Ask anything…",attachments:eZ,onSend:e6,disabled:eV,inputClassName:"border-none focus-visible:border-transparent focus-visible:shadow-none"}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",onMouseDown:ta,children:[ew?null:(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,t.jsx)(eR,{attachments:eZ,internPresence:eG,activeMode:eE,onSelectMode:ts,disabled:eV}),(0,t.jsx)(tm,{}),(0,t.jsx)(eg,{}),(0,t.jsx)(tW,{attachments:eZ})]}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[ew?null:(0,t.jsx)(eI,{attachments:eZ}),(0,t.jsx)(eq,{attachmentCount:eZ.list.length,disabled:eV,isLoading:eZ.loadingKeys.size>0,onSend:e6,onStop:M.chatroomStoreActions.stopGeneration,isCommandActive:!!eE})]})]})]}),eS[86]=eZ,eS[87]=eE,eS[88]=ts,eS[89]=e6,eS[90]=eG,eS[91]=td,eS[92]=eV,eS[93]=ew,eS[94]=ta,eS[95]=el):el=eS[95],eS[96]!==eZ||eS[97]!==eE||eS[98]!==ts||eS[99]!==e6||eS[100]!==eG||eS[101]!==tu||eS[102]!==e8||eS[103]!==eV||eS[104]!==ew||eS[105]!==te||eS[106]!==tr||eS[107]!==ta||eS[108]!==tt||eS[109]!==e9?(ei=tu&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{ref:e9,className:(0,c.cn)("flex w-full gap-1.5",e8?"flex-wrap items-center":"items-center"),children:[(0,t.jsx)("div",{ref:te,className:(0,c.cn)("flex shrink-0 items-center gap-1",e8&&"order-2",ew&&"hidden"),onMouseDown:ta,children:(0,t.jsx)(eR,{attachments:eZ,internPresence:eG,activeMode:eE,onSelectMode:ts,disabled:eV,extraActions:e=>{let{closeMenu:r}=e;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tm,{variant:"menu",onNavigate:r}),(0,t.jsx)(eg,{variant:"menu",onNavigate:r}),(0,t.jsx)(tW,{attachments:eZ,variant:"menu",onNavigate:r})]})}})}),(0,t.jsx)("div",{className:(0,c.cn)("min-w-0",e8?"order-1 w-full grow basis-full":"flex-1"),children:(0,t.jsx)(eP,{ref:eT,placeholder:"Ask anything…",attachments:eZ,onSend:e6,disabled:eV,inputClassName:(0,c.cn)("border-none focus-visible:border-transparent focus-visible:shadow-none",e8&&"pl-2 pr-0")})}),(0,t.jsxs)("div",{ref:tt,className:(0,c.cn)("flex shrink-0 items-center gap-1",e8&&"order-3 ml-auto"),onMouseDown:ta,children:[(0,t.jsx)(eI,{attachments:eZ}),(0,t.jsx)(eq,{attachmentCount:eZ.list.length,disabled:eV,isLoading:eZ.loadingKeys.size>0,onSend:e6,onStop:M.chatroomStoreActions.stopGeneration,isCommandActive:!!eE})]})]}),(0,t.jsx)("div",{ref:tr,"aria-hidden":"true",className:"pointer-events-none invisible absolute left-0 top-0 -z-10 whitespace-pre-wrap break-words [overflow-wrap:anywhere]"})]}),eS[96]=eZ,eS[97]=eE,eS[98]=ts,eS[99]=e6,eS[100]=eG,eS[101]=tu,eS[102]=e8,eS[103]=eV,eS[104]=ew,eS[105]=te,eS[106]=tr,eS[107]=ta,eS[108]=tt,eS[109]=e9,eS[110]=ei):ei=eS[110],eS[111]!==e$||eS[112]!==eo||eS[113]!==el||eS[114]!==ei?(ec=(0,t.jsxs)(I.SignupIntentSurface,{isSignedIn:e$,className:es,children:[eo,el,ei]}),eS[111]=e$,eS[112]=eo,eS[113]=el,eS[114]=ei,eS[115]=ec):ec=eS[115],eS[116]!==en||eS[117]!==ea||eS[118]!==ec?(ed=(0,t.jsxs)(d.Fade,{inClassName:"slide-in-from-bottom-12",className:"relative flex w-full flex-col gap-2",children:[en,ea,ec]}),eS[116]=en,eS[117]=ea,eS[118]=ec,eS[119]=ed):ed=eS[119],eS[120]===Symbol.for("react.memo_cache_sentinel")?(eu=(0,t.jsx)(p.AiResponseDisclaimer,{}),eS[120]=eu):eu=eS[120],eS[121]===Symbol.for("react.memo_cache_sentinel")?(em=()=>eF(!1),eS[121]=em):em=eS[121],eS[122]!==e5||eS[123]!==eW||eS[124]!==eO?(ep=(0,t.jsx)(C.ModelSelect,{className:"hidden",isDialog:eW,isMobileSideDrawer:!0,isForceOpen:eO,onBlur:em,onDone:e5,filter:t1,title:"Select an Audio Input Model",description:"Choose a model with audio input capabilities to continue.",showGuardrailsWarning:!0,hideUnavailableByDefault:!0}),eS[122]=e5,eS[123]=eW,eS[124]=eO,eS[125]=ep):ep=eS[125],eS[126]===Symbol.for("react.memo_cache_sentinel")?(ef=()=>eL(!1),eS[126]=ef):ef=eS[126],eS[127]!==e4||eS[128]!==eW||eS[129]!==eD?(eh=(0,t.jsx)(C.ModelSelect,{className:"hidden",isDialog:eW,isMobileSideDrawer:!0,isForceOpen:eD,onBlur:ef,onDone:e4,filter:t0,title:"Select a Video Input Model",description:"Choose a model with video input capabilities to continue.",showGuardrailsWarning:!0,hideUnavailableByDefault:!0}),eS[127]=e4,eS[128]=eW,eS[129]=eD,eS[130]=eh):eh=eS[130],eS[131]!==ee||eS[132]!==et||eS[133]!==er||eS[134]!==ed||eS[135]!==ep||eS[136]!==eh?(ex=(0,t.jsxs)("div",{className:"w-full max-w-5xl mx-auto shrink-0",style:Q,children:[ee,et,er,ed,eu,ep,eh]}),eS[131]=ee,eS[132]=et,eS[133]=er,eS[134]=ed,eS[135]=ep,eS[136]=eh,eS[137]=ex):ex=eS[137],ex}function t0(e){return e.input_modalities?.includes(i.InputModality.Video)}function t1(e){return e.input_modalities?.includes(i.InputModality.Audio)}function t2(e){return e.modelInfo?.input_modalities?.includes(i.InputModality.Video)}function t3(e){return e.type===h.AttachmentType.Video}function t5(e){return e.modelInfo?.input_modalities?.includes(i.InputModality.Audio)}function t4(e){return e.type===h.AttachmentType.Audio}function t6(e){return e.entity}function t7(e){return e.isSignedIn}let t8=(0,w.memo)(({isTextOnly:e=!1})=>(0,t.jsx)(w.Suspense,{fallback:null,children:(0,t.jsx)(tQ,{isTextOnly:e})}),(e,t)=>e.isTextOnly===t.isTextOnly);async function t9(){(0,u.toast)({title:"Interns take text only",description:"Remove the attachment or add an OpenRouter model to the room.",variant:"destructive"})}e.s(["Composer",0,t8],556427)},796531,860658,767150,e=>{"use strict";var t=e.i(222666),r=e.i(505962),n=e.i(270401),a=e.i(318875),s=e.i(22422),o=e.i(624621);let l=(0,n.memo)(()=>{let e,n=(0,r.c)(2),s=(0,o.useChatroomStore)(i);return n[0]!==s?(e=(0,t.jsx)(a.InsufficientCreditsModal,{open:s,onOpenChange:c}),n[0]=s,n[1]=e):e=n[1],e},()=>!0);function i(e){return e.showInsufficientCreditsModal}function c(e){return s.chatroomStoreActions.setShowInsufficientCreditsModal({payload:{show:e}})}e.s(["InsufficientCreditsModal",0,l],796531);var d=e.i(980351),u=e.i(693697);let m="openrouter:chat-bubble-color-v2",p="openrouter:chat-bubble-color-v2-change";function f(){return globalThis.localStorage?.removeItem(m)}function h(){try{return localStorage.getItem(m)??void 0}catch{return}}e.s(["CHAT_BUBBLE_COLOR_OPTIONS",0,[{key:"default",label:"Default",value:null,swatchClass:"bg-[#a3a3a3]"},{key:"blue",label:"Blue",value:"#3b82f6",swatchClass:"bg-[#3b82f6]"},{key:"green",label:"Green",value:"#00C49F",swatchClass:"bg-[#00C49F]"},{key:"yellow",label:"Yellow",value:"#FFBB28",swatchClass:"bg-[#FFBB28]"},{key:"orange",label:"Orange",value:"#FF8042",swatchClass:"bg-[#FF8042]"},{key:"pink",label:"Pink",value:"#FF69B4",swatchClass:"bg-[#FF69B4]"},{key:"purple",label:"Purple",value:"#800080",swatchClass:"bg-[#800080]"}],"useChatBubbleColor",0,function(){let e,t,a,s,o=(0,r.c)(5),[l,i]=(0,n.useState)(h),c=(0,d.useHydrated)();o[0]===Symbol.for("react.memo_cache_sentinel")?(e=()=>{let e=e=>{e.key===m&&i(e.newValue??void 0)},t=e=>{e instanceof CustomEvent&&i(e.detail??void 0)};return window.addEventListener("storage",e),window.addEventListener(p,t),()=>{window.removeEventListener("storage",e),window.removeEventListener(p,t)}},t=[],o[0]=e,o[1]=t):(e=o[0],t=o[1]),(0,n.useEffect)(e,t),o[2]===Symbol.for("react.memo_cache_sentinel")?(a=e=>{null===e?((0,u.wrap)(f),i(void 0)):((0,u.wrap)(()=>globalThis.localStorage?.setItem(m,e)),i(e)),window.dispatchEvent(new CustomEvent(p,{detail:e}))},o[2]=a):a=o[2];let x=a,g=c?l:void 0;return o[3]!==g?(s=[g,x],o[3]=g,o[4]=s):s=o[4],s}],860658),e.s(["getTextColorForBackground",0,function(e){var t,r,n;let a,s,o,l=(a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),a?.[1]&&a?.[2]&&a?.[3]?{r:Number.parseInt(a[1],16),g:Number.parseInt(a[2],16),b:Number.parseInt(a[3],16)}:(a=/^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(e),a?.[1]&&a?.[2]&&a?.[3])?{r:Number.parseInt(a[1]+a[1],16),g:Number.parseInt(a[2]+a[2],16),b:Number.parseInt(a[3]+a[3],16)}:null);return l?(t=l.r,r=l.g,n=l.b,o=(s=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4})(t),.2126*o+.7152*s(r)+.0722*s(n)<.5)?"white":"black":"white"}],767150)},216294,780367,452142,309421,435799,459421,591397,e=>{"use strict";var t=e.i(222666),r=e.i(505962),n=e.i(452473),a=e.i(336422),s=e.i(270401);e.i(798823);var o=e.i(429930),l=e.i(250855),i=e.i(624621),c=e.i(706642),d=e.i(646013),u=e.i(528164),m=e.i(557225),p=e.i(778084),f=e.i(784510),h=e.i(261335),x=e.i(22022),g=e.i(463444),v=e.i(457661),b=e.i(73284),y=e.i(827517),j=e.i(780397),S=e.i(22422),w=e.i(612011),N=e.i(967959),C=e.i(562443),I=e.i(958924),_=e.i(23259),k=e.i(583603),A=e.i(533515),M=e.i(691038),T=e.i(553215),E=e.i(389097),R=e.i(648156),z=e.i(99074),O=e.i(477986),F=e.i(693004),D=e.i(839669),L=e.i(735729),P=e.i(511410);let B=(0,s.createContext)(!1),V=B.Provider;function $(){return(0,s.useContext)(B)}function H(e){let a,o,l,i,c,d,m,p,f,h,x,g,v,b,y,j,S,w,N,C,I,_,k,A,M=(0,r.c)(65),{children:B,title:V,ariaNoun:H,scrollClassName:U,fadeFromClassName:G,dialogChildren:q,dialogBodyClassName:W,shouldCollapse:K}=e,J=void 0===G?"from-background":G,Z=(0,D.usePostHog)(),[Y]=(0,L.useAlwaysExpandMessages)(),X=$(),Q=!X&&(void 0===K||K)&&!Y,ee=(0,s.useRef)(null),{ref:et,canScrollEnd:er}=(0,P.useScrollFade)("y"),[en,ea]=(0,s.useState)(!1),[es,eo]=(0,s.useState)(!1),[el,ei]=(0,s.useState)(!1);M[0]!==es||M[1]!==Q?(a=()=>{let e=ee.current;if(!e||!Q||es)return;let t=()=>{ea(e.scrollHeight-e.clientHeight>24)};t();let r=new globalThis.ResizeObserver(t);return r.observe(e),()=>r.disconnect()},o=[Q,es],M[0]=es,M[1]=Q,M[2]=a,M[3]=o):(a=M[2],o=M[3]),(0,s.useLayoutEffect)(a,o);let ec=Q&&en&&!es,ed=ec||X&&er;M[4]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let e=ee.current;e&&e.scrollBy({top:.8*e.clientHeight,behavior:"smooth"})},M[4]=l):l=M[4];let eu=l;M[5]!==et?(i=e=>{ee.current=e,et.current=e},M[5]=et,M[6]=i):i=M[6];let em=Q&&!es&&"md:max-h-[40vh] md:overflow-hidden",ep=X&&"md:max-h-[60vh] md:overflow-y-auto";M[7]!==U||M[8]!==em||M[9]!==ep?(c=(0,n.cn)("max-h-none overflow-x-clip",em,ep,U),M[7]=U,M[8]=em,M[9]=ep,M[10]=c):c=M[10],M[11]!==B||M[12]!==i||M[13]!==c?(d=(0,t.jsx)("div",{ref:i,"data-message-collapse-region":!0,className:c,children:B}),M[11]=B,M[12]=i,M[13]=c,M[14]=d):d=M[14];let ef=ed?"opacity-100":"opacity-0";M[15]!==ef?(m=(0,n.cn)("pointer-events-none absolute inset-x-0 bottom-0 hidden h-24 md:block","transition-opacity duration-150",ef),M[15]=ef,M[16]=m):m=M[16],M[17]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-background from-25% to-transparent"}),M[17]=p):p=M[17],M[18]!==J?(f=(0,n.cn)("absolute inset-0 bg-gradient-to-t from-25% to-transparent",J),M[18]=J,M[19]=f):f=M[19],M[20]!==f?(h=(0,t.jsx)("div",{className:f}),M[20]=f,M[21]=h):h=M[21],M[22]!==m||M[23]!==h?(x=(0,t.jsxs)("div",{"aria-hidden":"true",className:m,children:[p,h]}),M[22]=m,M[23]=h,M[24]=x):x=M[24],M[25]!==H||M[26]!==er||M[27]!==X?(g=X&&er&&(0,t.jsx)(u.Button,{type:"button",variant:"outline",size:"icon","aria-label":`Scroll ${H} down`,onClick:eu,className:"absolute bottom-2 left-1/2 hidden size-7 -translate-x-1/2 rounded-full bg-background p-1 md:inline-flex",children:(0,t.jsx)(z.ChevronDown,{className:"size-4"})}),M[25]=H,M[26]=er,M[27]=X,M[28]=g):g=M[28],M[29]!==H||M[30]!==ec||M[31]!==Z?(v=ec&&(0,t.jsxs)(u.Button,{type:"button",variant:"outline",size:"sm","aria-label":`Show full ${H}`,onClick:()=>{eo(!0),Z.capture(T.PostHogEvent.ExpandMessageInline,{kind:H})},className:"absolute bottom-2 left-1/2 hidden h-7 -translate-x-1/2 gap-1 rounded-full bg-background px-3 text-xs text-foreground hover:text-foreground md:inline-flex",children:[(0,t.jsx)(z.ChevronDown,{className:"size-3.5"}),"Show more"]}),M[29]=H,M[30]=ec,M[31]=Z,M[32]=v):v=M[32],M[33]!==H||M[34]!==en||M[35]!==es||M[36]!==Z||M[37]!==Q?(b=Q&&en&&es&&(0,t.jsx)("div",{className:"hidden justify-center pt-1 md:flex",children:(0,t.jsxs)(u.Button,{type:"button",variant:"outline",size:"sm","aria-label":`Collapse ${H}`,onClick:()=>{eo(!1),Z.capture(T.PostHogEvent.CollapseMessageInline,{kind:H})},className:"h-7 gap-1 rounded-full bg-background px-3 text-xs text-foreground hover:text-foreground",children:[(0,t.jsx)(O.ChevronUp,{className:"size-3.5"}),"Show less"]})}),M[33]=H,M[34]=en,M[35]=es,M[36]=Z,M[37]=Q,M[38]=b):b=M[38];let eh=`Expand ${H}`;M[39]===Symbol.for("react.memo_cache_sentinel")?(y=()=>ei(!0),j=(0,n.cn)("hidden md:inline-flex","absolute right-1 top-px z-20 size-7 rounded-full p-1 text-muted-foreground","bg-background/80 opacity-0 backdrop-blur-sm transition-opacity","group-hover/response:opacity-100 focus-visible:opacity-100"),S=(0,t.jsx)(F.Maximize2,{className:"size-4"}),M[39]=y,M[40]=j,M[41]=S):(y=M[39],j=M[40],S=M[41]),M[42]!==eh?(w=(0,t.jsx)(R.Tooltip,{content:"Expand",children:(0,t.jsx)(u.Button,{type:"button",variant:"ghost",size:"icon","aria-label":eh,onClick:y,className:j,children:S})}),M[42]=eh,M[43]=w):w=M[43],M[44]!==V?(N=(0,t.jsx)(E.DialogHeader,{children:(0,t.jsx)(E.DialogTitle,{children:V})}),M[44]=V,M[45]=N):N=M[45],M[46]!==W?(C=(0,n.cn)("min-h-0 flex-1 overflow-y-auto py-2 ph-no-capture",W),M[46]=W,M[47]=C):C=M[47];let ex=q??B;return M[48]!==C||M[49]!==ex?(I=(0,t.jsx)("div",{className:C,"data-dd-privacy":"hidden",children:ex}),M[48]=C,M[49]=ex,M[50]=I):I=M[50],M[51]!==N||M[52]!==I?(_=(0,t.jsxs)(E.DialogContent,{keepMounted:!1,className:"flex h-[90vh] w-full max-w-[90vw] flex-col gap-0",children:[N,I]}),M[51]=N,M[52]=I,M[53]=_):_=M[53],M[54]!==el||M[55]!==_?(k=(0,t.jsx)(E.Dialog,{open:el,onOpenChange:ei,children:_}),M[54]=el,M[55]=_,M[56]=k):k=M[56],M[57]!==d||M[58]!==x||M[59]!==g||M[60]!==v||M[61]!==b||M[62]!==w||M[63]!==k?(A=(0,t.jsxs)("div",{className:"group/response relative",children:[d,x,g,v,b,w,k]}),M[57]=d,M[58]=x,M[59]=g,M[60]=v,M[61]=b,M[62]=w,M[63]=k,M[64]=A):A=M[64],A}e.s(["ScrollCapProvider",0,V,"useIsScrollCapped",0,$],780367);let U="inline",G=(0,s.createContext)("panel"),q=G.Provider,W=(0,n.cn)("text-base leading-6","[&_p]:text-prose","[&_p]:my-3 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0","break-words [overflow-wrap:anywhere]","[&_pre]:whitespace-pre-wrap [&_pre]:break-words","[&_code]:whitespace-pre-wrap [&_code]:break-words"),K=()=>!1;function J(e){let a,o,l,i,c,d,u,m,p,f,h,x=(0,r.c)(28),{children:g,title:v,header:b,float:y}=e,j=void 0!==y&&y,S=(0,M.useMediaMd)(),w=(0,s.useRef)(null),[N,C]=(0,s.useState)(!1),I=!!b;x[0]!==I?(a=()=>{let e=w.current;if(!e||!I)return;let t=new IntersectionObserver(e=>{let t=e[0];t?.rootBounds&&C(t.boundingClientRect.top<=t.rootBounds.top+1)},{root:X(e),threshold:[0,1]});return t.observe(e),()=>t.disconnect()},o=[I],x[0]=I,x[1]=a,x[2]=o):(a=x[1],o=x[2]),(0,s.useEffect)(a,o);let _=(0,s.useRef)(null),k=(0,s.useRef)(null),A=(0,s.useRef)(!1);x[3]!==j||x[4]!==S?(l=e=>{let t=k.current,r=_.current;if(!j||S||!t||!r)return A.current=!1,t&&(t.style.transform=""),Y;let n=X(r);if(!n)return Z;let a=0,s=!0,o=()=>{if(a=0,!s)return;let o=r.getBoundingClientRect(),l=Math.max(0,o.height-150-t.offsetHeight),i=l>=100,c=A.current!==i;if(A.current=i,i){let e=Math.max(0,n.getBoundingClientRect().top-o.top-l);t.style.transform=e>0?`translateY(${-e}px)`:""}else t.style.transform="";c&&e()},l=()=>{a||(a=globalThis.requestAnimationFrame(o))},i=new IntersectionObserver(e=>{s=e[0]?.isIntersecting??!1,l()},{root:n});i.observe(r),n.addEventListener("scroll",l,{passive:!0});let c=new globalThis.ResizeObserver(l);return c.observe(r),o(),()=>{globalThis.cancelAnimationFrame(a),i.disconnect(),c.disconnect(),n.removeEventListener("scroll",l),t.style.transform=""}},x[3]=j,x[4]=S,x[5]=l):l=x[5];let T=l;x[6]===Symbol.for("react.memo_cache_sentinel")?(i=()=>A.current,x[6]=i):i=x[6];let E=i,R=(0,s.useSyncExternalStore)(T,E,K);x[7]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.cn)(W,"[overflow-anchor:none]"),x[7]=c):c=x[7],x[8]!==g?(d=(0,t.jsx)(q,{value:U,children:g}),x[8]=g,x[9]=d):d=x[9],x[10]!==j||x[11]!==b||x[12]!==N||x[13]!==S||x[14]!==R?(u=b?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{ref:w,"aria-hidden":"true",className:"h-px"}),(0,t.jsxs)("div",{ref:k,className:(0,n.cn)("relative z-10 bg-popover","md:sticky md:top-0",R&&"max-md:sticky max-md:top-0"),children:[(0,t.jsx)("div",{className:(0,n.cn)(j?(0,n.cn)("border-border px-4 pb-2 pt-2.5","max-md:rounded-t-xl max-md:border-x max-md:border-t md:px-0 md:pt-0"):(0,n.cn)("pb-3 md:pb-2",N&&"border-t border-border")),children:b}),N&&(S||R)&&(0,t.jsx)("div",{"aria-hidden":"true",className:(0,n.cn)("pointer-events-none absolute inset-x-px top-full h-4","bg-gradient-to-b from-popover to-transparent")})]})]}):null,x[10]=j,x[11]=b,x[12]=N,x[13]=S,x[14]=R,x[15]=u):u=x[15];let z=j&&"max-md:rounded-b-xl max-md:border-x max-md:border-b max-md:border-border max-md:bg-popover max-md:px-4 max-md:pb-3";return x[16]!==z?(m=(0,n.cn)(z),x[16]=z,x[17]=m):m=x[17],x[18]!==g||x[19]!==m?(p=(0,t.jsx)("div",{className:m,children:g}),x[18]=g,x[19]=m,x[20]=p):p=x[20],x[21]!==p||x[22]!==u?(f=(0,t.jsxs)("div",{ref:_,children:[u,p]}),x[21]=p,x[22]=u,x[23]=f):f=x[23],x[24]!==f||x[25]!==d||x[26]!==v?(h=(0,t.jsx)(H,{title:v,ariaNoun:"response",shouldCollapse:!1,scrollClassName:c,dialogBodyClassName:W,dialogChildren:d,children:f}),x[24]=f,x[25]=d,x[26]=v,x[27]=h):h=x[27],h}function Z(){}function Y(){}function X(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t).overflowY;if("auto"===e||"scroll"===e||"overlay"===e)return t;t=t.parentElement}return null}var Q=e.i(126154),ee=e.i(779100),et=e.i(21053);function er(){return(0,et.usePersistedBoolean)("openrouter:chat-show-metrics-inline",!0)}e.s(["useShowMetricsInline",0,er],452142);var en=e.i(94814),ea=e.i(44221),es=e.i(370066),eo=e.i(190557);let el="duration";function ei(e,t){return null===t?null:{kind:e,text:t}}function ec({messageId:e,className:r}){var a,c,d,u,m,f;let h,x=(0,ee.useLocale)(),g=(0,s.useMemo)(l.makeSelectMessageById,[]),v=(0,i.useChatroomStore)(t=>g(t,e)),[b]=er();if(!b||!v||v.type!==o.MessageType.Assistant)return null;let{cost:y,duration:j,tokensCount:S}=v.metadata??{},w=[ei("cost",void 0===(a={cost:y,duration:j,tokensCount:S}).cost?null:(c=x,!Number.isFinite(h=Number(a.cost))||h<0?null:(0,eo.formatUsd)(h,{locale:c,preset:"playground-cost"})??null)),ei("tokens",void 0===a.tokensCount?null:(d=x,!Number.isFinite(u=a.tokensCount)||u<=0?null:`${(0,es.formatNumber)(Math.round(u),{locale:d,preset:"integer"})??"—"} tok`)),ei(el,void 0===a.duration?null:(m=x,f=a.duration,(0,ea.formatDuration)(f,{locale:m,preset:"latency-trimmed-seconds"})??null))].filter(e=>null!==e);if(0===w.length)return null;let N=w.some(e=>e.kind!==el);return(0,t.jsxs)(p.Popover,{children:[(0,t.jsx)(p.PopoverTrigger,{openOnHover:!0,render:(0,t.jsx)("button",{type:"button","data-testid":"generation-cost-line","aria-label":"Generation metadata",className:(0,n.cn)("flex items-center gap-1.5 whitespace-nowrap text-sm tabular-nums text-foreground/70","-mx-1.5 -my-1 rounded-md px-1.5 py-1","cursor-pointer transition-colors hover:bg-muted/50 hover:text-foreground",!N&&"max-md:hidden",r),children:(0,t.jsx)("span",{className:"flex items-center gap-1.5 border-b border-dotted border-muted-foreground/50",children:w.map((e,r)=>(0,t.jsxs)("span",{className:(0,n.cn)("flex items-center gap-1.5",e.kind===el&&"max-md:hidden"),children:[r>0?(0,t.jsx)(Q.DotSeparator,{"data-testid":"cost-line-dot"}):null,(0,t.jsx)("span",{children:e.text})]},e.kind))})})}),(0,t.jsx)(en.MessageMetadataPopoverContent,{messageId:e})]})}let ed="skeleton",eu=new Set(["image_generation_call",e.i(885686).VIDEO_GENERATION_CALL_TYPE]);var em=e.i(920415),ep=e.i(700050),ef=e.i(735961),eh=e.i(777096),ex=e.i(956506),eg=e.i(837556),ev=e.i(188363);function eb(e){let a,s,o,l=(0,r.c)(7),{url:i,className:c}=e;return l[0]!==c?(a=(0,n.cn)("size-6",c),l[0]=c,l[1]=a):a=l[1],l[2]!==i?(s=(0,t.jsx)(ev.RemoteFavicon,{className:"size-full",faviconFor:i,size:64}),l[2]=i,l[3]=s):s=l[3],l[4]!==a||l[5]!==s?(o=(0,t.jsx)(eg.IconFrame,{className:a,children:s}),l[4]=a,l[5]=s,l[6]=o):o=l[6],o}function ey(e){let a,s,o,l,i,c,d,u,m,p,f,h=(0,r.c)(27),{urlCitation:x,cardClassName:g,contentClassName:v}=e,b=x.url;h[0]!==g?(a=(0,n.cn)("relative flex flex-col gap-2 h-full ph-no-capture",g),h[0]=g,h[1]=a):a=h[1],h[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(eh.ExternalLinkIconForMarkdown,{className:(0,n.cn)("bg-background absolute right-px top-px size-3.5","text-link transition-all","opacity-50 group-hover/card:opacity-100")}),h[2]=s):s=h[2];let y=x.title||x.url;return h[3]!==y?(o=(0,t.jsx)(ex.CardHeader,{className:"pb-0",children:(0,t.jsx)(ex.CardTitle,{className:"line-clamp-1",children:y})}),h[3]=y,h[4]=o):o=h[4],h[5]!==v?(l=(0,n.cn)("text-xs whitespace-normal break-words overflow-hidden line-clamp-2",v),h[5]=v,h[6]=l):l=h[6],h[7]!==l||h[8]!==x.url?(i=(0,t.jsx)(ex.CardContent,{className:"py-0 flex-1 min-h-0",children:(0,t.jsx)("span",{className:l,children:x.url})}),h[7]=l,h[8]=x.url,h[9]=i):i=h[9],h[10]!==x.url?(c=(0,t.jsx)(eb,{url:x.url,className:"border border-border"}),h[10]=x.url,h[11]=c):c=h[11],h[12]!==x.url?(d=new URL(x.url),h[12]=x.url,h[13]=d):d=h[13],h[14]!==d.hostname?(u=(0,t.jsx)("span",{className:"truncate text-xs w-full",children:d.hostname}),h[14]=d.hostname,h[15]=u):u=h[15],h[16]!==u||h[17]!==c?(m=(0,t.jsx)(ex.CardFooter,{className:"pt-0 mt-auto",children:(0,t.jsxs)("span",{className:"flex items-center gap-1 w-full",children:[c,u]})}),h[16]=u,h[17]=c,h[18]=m):m=h[18],h[19]!==m||h[20]!==a||h[21]!==o||h[22]!==i?(p=(0,t.jsxs)(ex.Card,{className:a,"data-dd-privacy":"hidden",children:[s,o,i,m]}),h[19]=m,h[20]=a,h[21]=o,h[22]=i,h[23]=p):p=h[23],h[24]!==p||h[25]!==x.url?(f=(0,t.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:b,className:"block h-full",children:p}),h[24]=p,h[25]=x.url,h[26]=f):f=h[26],f}function ej(e){let a,o,l,i,c,d,m,p,f,h,x=(0,r.c)(29),{itemId:g}=e;x[0]!==g?(a=e=>(0,v.selectUrlCitationsFromItem)(e,g),x[0]=g,x[1]=a):a=x[1];let b=(0,ef.useItemStore)(a),[y,j]=(0,s.useState)(!1);if(!b)return null;if(x[2]!==b||x[3]!==y){p=Symbol.for("react.early_return_sentinel");e:{let e,r,a,s=b.filter(eN);if(!s.length){p=null;break e}let f=s.length,h=`${f} citation${f>1?"s":""}`,g=f>5,v=s.map(ew),S=g&&!y?v.slice(0,3):v;x[11]===Symbol.for("react.memo_cache_sentinel")?(d=(0,n.cn)("w-full flex flex-col gap-2"),x[11]=d):d=x[11],x[12]!==h?(e=(0,t.jsx)("span",{className:"shrink-0",children:h}),x[12]=h,x[13]=e):e=x[13],x[14]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.cn)("flex","overflow-visible"),x[14]=r):r=x[14],x[15]!==f||x[16]!==g||x[17]!==y?(a=g&&!y&&(0,t.jsxs)(u.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{j(!0),(0,ep.trackCitationIconsExpand)({citationCount:f})},className:(0,n.cn)("size-6 rounded-lg border border-border bg-card p-0","text-xs font-medium text-muted-foreground hover:border-muted-foreground hover:bg-card hover:text-foreground","z-10"),children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"···"}),(0,t.jsx)("span",{className:"sr-only",children:"Show more citations"})]}),x[15]=f,x[16]=g,x[17]=y,x[18]=a):a=x[18],m=(0,t.jsxs)("div",{className:"flex items-center gap-1 text-sm",children:[e,(0,t.jsxs)("div",{className:r,children:[S,a]})]}),o=em.CardCarousel,l="w-full",x[19]===Symbol.for("react.memo_cache_sentinel")?(i={align:"start",loop:!1},x[19]=i):i=x[19],c=s.map(eS)}x[2]=b,x[3]=y,x[4]=o,x[5]=l,x[6]=i,x[7]=c,x[8]=d,x[9]=m,x[10]=p}else o=x[4],l=x[5],i=x[6],c=x[7],d=x[8],m=x[9],p=x[10];return p!==Symbol.for("react.early_return_sentinel")?p:(x[20]!==o||x[21]!==l||x[22]!==i||x[23]!==c?(f=(0,t.jsx)(o,{className:l,opts:i,items:c}),x[20]=o,x[21]=l,x[22]=i,x[23]=c,x[24]=f):f=x[24],x[25]!==d||x[26]!==m||x[27]!==f?(h=(0,t.jsxs)("div",{className:d,children:[m,f]}),x[25]=d,x[26]=m,x[27]=f,x[28]=h):h=x[28],h)}function eS(e,r){return{id:`${e.url}|${e.title}|${e.start_index}|${e.end_index}|${r}`,body:(0,t.jsx)(ey,{cardClassName:"rounded-tr-sm max-w-64",urlCitation:e})}}function ew(e,r){return(0,t.jsxs)(p.Popover,{children:[(0,t.jsx)(p.PopoverTrigger,{render:(0,t.jsx)(u.Button,{variant:"ghost",size:"icon-sm",className:"h-auto w-auto rounded-lg p-0 hover:bg-transparent -me-1 last:me-0",children:(0,t.jsx)(eb,{url:e.url,className:"border border-border transition-colors hover:border-muted-foreground"})})}),(0,t.jsx)(p.PopoverContent,{side:"top",className:"overflow-hidden p-0",children:(0,t.jsx)(ey,{cardClassName:"border-none rounded-none",urlCitation:e})})]},r)}function eN(e){return"url_citation"===e.type}var eC=e.i(624900),eI=e.i(705113);let e_=({messageId:e})=>{let r=(0,s.useMemo)(l.makeSelectMessageById,[]),n=(0,i.useChatroomStore)(t=>r(t,e)),a=(0,l.selectAttachmentsByMessageId)(n);return a&&0!==a.length?1===a.length?(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map((e,r)=>(0,t.jsx)(eI.AttachmentPreview,{attachment:e,attachments:a,initialIndex:r},(0,eC.getAttachmentKey)(e)))}):(0,t.jsx)(em.CardCarousel,{opts:{align:"end",loop:!1,dragFree:!0},items:a.map((e,r)=>({id:(0,eC.getAttachmentKey)(e),body:(0,t.jsx)(eI.AttachmentPreview,{attachment:e,attachments:a,initialIndex:r})}))}):null};function ek(){return(ek=Object.assign.bind()).apply(null,arguments)}var eA=s.useLayoutEffect,eM=function(e){var t=s.default.useRef(e);return eA(function(){t.current=e}),t},eT=function(e,t){"function"==typeof e?e(t):e.current=t},eE=function(e,t){var r=s.default.useRef();return s.default.useCallback(function(n){e.current=n,r.current&&eT(r.current,null),r.current=t,t&&eT(t,n)},[t])},eR={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},ez=function(e){Object.keys(eR).forEach(function(t){e.style.setProperty(t,eR[t],"important")})},eO=null,eF=function(e,t){var r=e.scrollHeight;return"border-box"===t.sizingStyle.boxSizing?r+t.borderSize:r-t.paddingSize},eD=function(){},eL=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],eP=!!document.documentElement.currentStyle,eB=function(e){var t=window.getComputedStyle(e);if(null===t)return null;var r=eL.reduce(function(e,r){return e[r]=t[r],e},{}),n=r.boxSizing;if(""===n)return null;eP&&"border-box"===n&&(r.width=parseFloat(r.width)+parseFloat(r.borderRightWidth)+parseFloat(r.borderLeftWidth)+parseFloat(r.paddingRight)+parseFloat(r.paddingLeft)+"px");var a=parseFloat(r.paddingBottom)+parseFloat(r.paddingTop),s=parseFloat(r.borderBottomWidth)+parseFloat(r.borderTopWidth);return{sizingStyle:r,paddingSize:a,borderSize:s}};function eV(e,t,r){var n=eM(r);s.useLayoutEffect(function(){var r=function(e){return n.current(e)};if(e)return e.addEventListener(t,r),function(){return e.removeEventListener(t,r)}},[])}var e$=function(e,t){eV(document.body,"reset",function(r){e.current.form===r.target&&t(r)})},eH=function(e){eV(window,"resize",e)},eU=function(e){eV(document.fonts,"loadingdone",e)},eG=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],eq=s.forwardRef(function(e,t){var r=e.cacheMeasurements,n=e.maxRows,a=e.minRows,o=e.onChange,l=void 0===o?eD:o,i=e.onHeightChange,c=void 0===i?eD:i,d=function(e,t){if(null==e)return{};var r={};for(var n in e)if(({}).hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,eG),u=void 0!==d.value,m=s.useRef(null),p=eE(m,t),f=s.useRef(0),h=s.useRef(),x=function(){var e=m.current,t=r&&h.current?h.current:eB(e);if(t){h.current=t;var s,o,l,i,d,u,p,x,g,v,b,y=(s=e.value||e.placeholder||"x",void 0===(o=a)&&(o=1),void 0===(l=n)&&(l=1/0),eO||((eO=document.createElement("textarea")).setAttribute("tabindex","-1"),eO.setAttribute("aria-hidden","true"),ez(eO)),null===eO.parentNode&&document.body.appendChild(eO),i=t.paddingSize,d=t.borderSize,p=(u=t.sizingStyle).boxSizing,Object.keys(u).forEach(function(e){eO.style[e]=u[e]}),ez(eO),eO.value=s,x=eF(eO,t),eO.value=s,x=eF(eO,t),eO.value="x",v=(g=eO.scrollHeight-i)*o,"border-box"===p&&(v=v+i+d),x=Math.max(v,x),b=g*l,"border-box"===p&&(b=b+i+d),[x=Math.min(b,x),g]),j=y[0],S=y[1];f.current!==j&&(f.current=j,e.style.setProperty("height",j+"px","important"),c(j,{rowHeight:S}))}};return s.useLayoutEffect(x),e$(m,function(){if(!u){var e=m.current.value;requestAnimationFrame(function(){var t=m.current;t&&e!==t.value&&x()})}}),eH(x),eU(x),s.createElement("textarea",ek({},d,{onChange:function(e){u||x(),l(e)},ref:p}))}),eW=e.i(980351),eK=e.i(823634);function eJ(e){let a,s,o,l,i,c,d=(0,r.c)(17);d[0]!==e?({className:a,inputClassName:s,ref:l,...o}=e,d[0]=e,d[1]=a,d[2]=s,d[3]=o,d[4]=l):(a=d[1],s=d[2],o=d[3],l=d[4]);let u=(0,eW.useHydrated)();d[5]!==a||d[6]!==s?(i=(0,n.cn)(eK.TEXTAREA_CLASSES,"resize-none",s,a),d[5]=a,d[6]=s,d[7]=i):i=d[7];let m=i;if(!u){let e,r;if(d[8]!==o){let{minRows:t,maxRows:r,cacheMeasurements:n,onHeightChange:a,...s}=o;e=s,d[8]=o,d[9]=e}else e=d[9];return d[10]!==m||d[11]!==e?(r=(0,t.jsx)("textarea",{className:m,...e}),d[10]=m,d[11]=e,d[12]=r):r=d[12],r}return d[13]!==m||d[14]!==o||d[15]!==l?(c=(0,t.jsx)(eq,{className:m,ref:l,...o}),d[13]=m,d[14]=o,d[15]=l,d[16]=c):c=d[16],c}var eZ=e.i(388095),eY=e.i(19379),eX=e.i(197832);function eQ(e){let a,o,l,i,c,d,m,p,f,h,x,g,v,b,y,w,N=(0,r.c)(42);N[0]!==e.itemId?(a=(0,eX.getTrimmedMessageContent)(e.itemId),N[0]=e.itemId,N[1]=a):a=N[1];let C=a,[I,_]=(0,eZ.useResettableState)(C,e1),k=(0,s.useRef)(!1);N[2]===Symbol.for("react.memo_cache_sentinel")?(o=e=>{if(!e||k.current)return;k.current=!0,e.focus();let t=e.value.length;e.setSelectionRange(t,t),window.setTimeout(()=>{e.scrollIntoView({block:"center"})},300)},N[2]=o):o=N[2];let A=o;N[3]!==I||N[4]!==e?(l=t=>{let r=(0,j.getCurrentRoomId)();if(r){if(t?.retry&&e.onSaveAndRetry){e.onSaveAndRetry(I),e.onCancel();return}S.chatroomStoreActions.editItem({payload:{roomId:r,messageId:e.messageId,itemId:e.itemId,newContent:I,opts:t}}),e.onCancel()}},N[3]=I,N[4]=e,N[5]=l):l=N[5];let M=l;N[6]!==M||N[7]!==e.onSaveAndRetry?(i=()=>{M({retry:!!e.onSaveAndRetry})},N[6]=M,N[7]=e.onSaveAndRetry,N[8]=i):i=N[8],(0,eY.useKeydown)(e0,i);let T="start"===e.align;N[9]!==e.lockedHeightPx||N[10]!==e.lockedWidthPx?(c=e.lockedWidthPx?{minWidth:`min(${e.lockedWidthPx}px, 100%)`,minHeight:e.lockedHeightPx?`${e.lockedHeightPx}px`:void 0}:void 0,N[9]=e.lockedHeightPx,N[10]=e.lockedWidthPx,N[11]=c):c=N[11];let E=c,R=T?"items-start":"items-end";N[12]!==e.className||N[13]!==R?(d=(0,n.cn)("flex flex-col gap-2",R,e.className),N[12]=e.className,N[13]=R,N[14]=d):d=N[14];let z=T?"w-full":"w-[min(80vw,36rem)] max-w-full";return N[15]!==z?(m=(0,n.cn)("flex flex-col rounded-2xl border border-transparent bg-slate-3 dark:bg-slate-4","px-4 py-2.5 shadow-none",z),N[15]=z,N[16]=m):m=N[16],N[17]!==_?(p=e=>_(e.target.value),N[17]=_,N[18]=p):p=N[18],N[19]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.cn)("border-0 shadow-none focus-inner:shadow-none scrollbar-hide ph-no-capture","bg-transparent focus-within:bg-transparent text-foreground"),N[19]=f):f=N[19],N[20]!==I||N[21]!==p?(h=(0,t.jsx)(eJ,{ref:A,value:I,onChange:p,className:f,inputClassName:"bg-transparent px-0 py-0 min-h-6 text-sm pointer-coarse:text-base leading-6 pointer-coarse:leading-6","data-dd-privacy":"hidden"}),N[20]=I,N[21]=p,N[22]=h):h=N[22],N[23]!==E||N[24]!==h||N[25]!==m?(x=(0,t.jsx)("div",{style:E,className:m,children:h}),N[23]=E,N[24]=h,N[25]=m,N[26]=x):x=N[26],N[27]!==e.onCancel?(g=(0,t.jsx)(u.Button,{onClick:e.onCancel,variant:"ghost",size:"sm",className:"rounded-full text-muted-foreground hover:text-foreground",children:"Cancel"}),N[27]=e.onCancel,N[28]=g):g=N[28],N[29]!==M?(v=(0,t.jsx)(u.Button,{id:"save-button",variant:"ghost",size:"sm",className:"rounded-full text-foreground hover:bg-background",onClick:()=>M(),children:"Save"}),N[29]=M,N[30]=v):v=N[30],N[31]!==M||N[32]!==e.onSaveAndRetry?(b=e.onSaveAndRetry&&(0,t.jsx)(u.Button,{id:"save-submit-button",variant:"default",size:"sm",className:"rounded-full",onClick:()=>M({retry:!0}),children:"Save & Generate"}),N[31]=M,N[32]=e.onSaveAndRetry,N[33]=b):b=N[33],N[34]!==g||N[35]!==v||N[36]!==b?(y=(0,t.jsxs)("div",{className:"flex justify-end gap-2 whitespace-nowrap",children:[g,v,b]}),N[34]=g,N[35]=v,N[36]=b,N[37]=y):y=N[37],N[38]!==x||N[39]!==y||N[40]!==d?(w=(0,t.jsxs)("div",{className:d,children:[x,y]}),N[38]=x,N[39]=y,N[40]=d,N[41]=w):w=N[41],w}function e0(e){return(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&!(e.target instanceof HTMLTextAreaElement&&e.shiftKey)}function e1(e){return e}var e2=e.i(795672),e3=e.i(150049);function e5(e){let n,a,s=(0,r.c)(7),{createdAt:o}=e,l=(0,e2.useFormatters)(),i=(0,e3.useResolvedDisplayTimeZone)(),c=(0,eW.useHydrated)();s[0]!==o||s[1]!==l||s[2]!==c||s[3]!==i?(n=c?l.dateTime(o,{timeZone:i,preset:"numeric-seconds"}):void 0,s[0]=o,s[1]=l,s[2]=c,s[3]=i,s[4]=n):n=s[4];let d=n??"—";return s[5]!==d?(a=(0,t.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:d}),s[5]=d,s[6]=a):a=s[6],a}var e4=e.i(735162);function e6(e){let n,a,s=(0,r.c)(4),{itemId:o}=e;s[0]!==o?(n=e=>(0,v.selectFileSearchCallData)(e,o),s[0]=o,s[1]=n):n=s[1];let l=(0,ef.useItemStore)(n);return l?(s[2]!==l.status?(a=(0,t.jsxs)("div",{className:"text-xs text-muted-foreground",children:["File search: ",(0,t.jsx)("span",{className:"font-medium",children:l.status})]}),s[2]=l.status,s[3]=a):a=s[3],a):null}var e7=e.i(859672),e8=e.i(379497),e9=e.i(81174),te=e.i(693697),tt=e.i(204067);let tr=tt.StringifiedJsonSchema.pipe(tt.JsonSchema);function tn(e){if(!e)return{formatted:"",isValid:!0,issueCount:0};let t=(0,tt.parseSchema)(tr,e);return(0,te.isErr)(t)?{formatted:e,isValid:!1,issueCount:t.error.issues.length}:{formatted:JSON.stringify(t.data,null,2),isValid:!0,issueCount:0}}function ta(e,t){let n,a,o,l=(0,r.c)(8);l[0]!==e?(n=tn(e),l[0]=e,l[1]=n):n=l[1];let{formatted:i,isValid:c,issueCount:d}=n;return l[2]!==e||l[3]!==c||l[4]!==d||l[5]!==t?(a=()=>{var r;c||void 0===(r=t)||"in_progress"===r||(0,e9.wLog)("tool call arguments are not valid JSON",{status:t,args_length:e.length,issue_count:d})},o=[e,t,c,d],l[2]=e,l[3]=c,l[4]=d,l[5]=t,l[6]=a,l[7]=o):(a=l[6],o=l[7]),(0,s.useEffect)(a,o),i}function ts(e){let a,o,l,i,c,d,m,p,f,h,x,g=(0,r.c)(23),{itemId:b}=e;g[0]!==b?(a=e=>(0,v.selectFunctionCallData)(e,b),g[0]=b,g[1]=a):a=g[1];let y=(0,ef.useItemStore)(a),[j,S]=(0,s.useState)(!1),w=ta(y?.arguments??"",y?.status);if(!y)return null;g[2]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.cn)("w-full overflow-hidden rounded-tr-lg rounded-br-lg border border-border bg-card ph-no-capture"),g[2]=o):o=g[2],g[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("div",{className:"py-3 px-4 text-sm font-medium text-foreground",children:"Tool Call"}),g[3]=l):l=g[3],g[4]===Symbol.for("react.memo_cache_sentinel")?(i=()=>S(to),g[4]=i):i=g[4];let N=j&&"border-b border-border";g[5]!==N?(c=(0,n.cn)("h-auto w-full justify-start gap-2 rounded-none px-4 py-3 text-sm hover:bg-muted hover:text-foreground",N),g[5]=N,g[6]=c):c=g[6];let C=j&&"rotate-90";return g[7]!==C?(d=(0,n.cn)("size-4 shrink-0 text-muted-foreground transition-transform duration-200",C),g[7]=C,g[8]=d):d=g[8],g[9]!==d?(m=(0,t.jsx)(e8.ChevronRight,{className:d}),g[9]=d,g[10]=m):m=g[10],g[11]!==y.name?(p=(0,t.jsx)("span",{className:"font-mono text-muted-foreground",children:y.name}),g[11]=y.name,g[12]=p):p=g[12],g[13]!==p||g[14]!==c||g[15]!==m?(f=(0,t.jsxs)(u.Button,{variant:"ghost",size:"sm",onClick:i,className:c,children:[m,p]}),g[13]=p,g[14]=c,g[15]=m,g[16]=f):f=g[16],g[17]!==w||g[18]!==j?(h=j&&(0,t.jsx)("div",{className:"max-h-96 overflow-y-auto p-4",children:w?(0,t.jsx)(e7.CodeBlock,{language:"json",value:w}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No arguments"})}),g[17]=w,g[18]=j,g[19]=h):h=g[19],g[20]!==f||g[21]!==h?(x=(0,t.jsxs)("div",{className:o,"data-dd-privacy":"hidden",children:[l,(0,t.jsxs)("div",{className:"border-t border-border",children:[f,h]})]}),g[20]=f,g[21]=h,g[22]=x):x=g[22],x}function to(e){return!e}var tl=e.i(536652),ti=e.i(789608),tc=e.i(652942),td=e.i(253167);function tu(e){let a,o,l,i,c,d,m,p,f,h=(0,r.c)(23),{itemId:x}=e;h[0]!==x?(a=e=>(0,v.selectImageGenerationCallData)(e,x),h[0]=x,h[1]=a):a=h[1];let g=(0,ef.useItemStore)(a),[b,y]=(0,s.useState)(null);if(!g)return null;if("in_progress"===g.status||"generating"===g.status){let e;return h[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(tp,{}),h[2]=e):e=h[2],e}if(!g.result){let e;return h[3]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(tm,{}),h[3]=e):e=h[3],e}h[4]!==g.result?(o={url:g.result,name:"Generated Image"},h[4]=g.result,h[5]=o):o=h[5];let j=o;if(b===j.url){let e;return h[6]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(tm,{}),h[6]=e):e=h[6],e}let S=j.url;return h[7]!==j?(l=[j],h[7]=j,h[8]=l):l=h[8],h[9]===Symbol.for("react.memo_cache_sentinel")?(i=(0,n.cn)("absolute bottom-1 right-1 z-10","opacity-0 group-hover:opacity-100"),h[9]=i):i=h[9],h[10]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(u.Button,{size:"icon-sm",variant:"outline",className:i,"aria-label":"Expand image",children:(0,t.jsx)(tl.ArrowsPointingOutIcon,{className:"text-foreground size-4"})}),h[10]=c):c=h[10],h[11]!==j.url?(d=()=>y(j.url),h[11]=j.url,h[12]=d):d=h[12],h[13]!==j.name||h[14]!==j.url||h[15]!==d?(m=(0,t.jsx)("picture",{className:"flex min-w-0 cursor-pointer",children:(0,t.jsx)("img",{alt:j.name,className:"aspect-auto h-96 max-w-full overflow-hidden rounded-lg border object-cover sm:max-w-xl",src:j.url,onError:d})}),h[13]=j.name,h[14]=j.url,h[15]=d,h[16]=m):m=h[16],h[17]!==l||h[18]!==m?(p=(0,t.jsx)("div",{className:"group relative flex min-w-0",children:(0,t.jsxs)(tc.ImagePreviewDialog,{images:l,initialIndex:0,children:[c,m]})}),h[17]=l,h[18]=m,h[19]=p):p=h[19],h[20]!==j.url||h[21]!==p?(f=(0,t.jsx)("div",{className:"flex flex-wrap gap-2 ph-no-capture","data-dd-privacy":"hidden",children:(0,t.jsx)("div",{className:"min-w-0 duration-200 animate-in fade-in slide-in-from-left-8",children:p},S)}),h[20]=j.url,h[21]=p,h[22]=f):f=h[22],f}function tm(){let e,a=(0,r.c)(1);return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)("div",{className:(0,n.cn)("flex h-96 w-96 max-w-full flex-col items-center justify-center gap-3","rounded-lg border bg-muted sm:max-w-xl"),children:[(0,t.jsx)(td.ImageOff,{className:"size-10 text-muted-foreground","aria-hidden":"true"}),(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"Image no longer available"})]}),a[0]=e):e=a[0],e}function tp(){let e,a,s=(0,r.c)(2);return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.cn)("flex h-96 w-96 max-w-full flex-col items-center justify-center gap-3 rounded-lg border bg-muted sm:max-w-xl"),s[0]=e):e=s[0],s[1]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsxs)("div",{className:e,children:[(0,t.jsx)("svg",{className:"size-10 text-muted-foreground","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 20 18",children:(0,t.jsx)("path",{d:"M18 0H2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm4.376 10.481A1 1 0 0 1 16 15H4a1 1 0 0 1-.895-1.447l3.5-7A1 1 0 0 1 7.468 6a.965.965 0 0 1 .9.5l2.775 4.757 1.546-1.887a1 1 0 0 1 1.618.1l2.541 4a1 1 0 0 1 .028 1.011Z"})}),(0,t.jsx)(ti.ProcessingIndicator,{label:"Generating image"})]}),s[1]=a):a=s[1],a}var tf=e.i(527315),th=e.i(331995),tx=e.i(965542),tg=e.i(394333),tv=e.i(968076),tb=e.i(568728);e.i(406201);var ty=e.i(806024);function tj(e){let a,s,o,l,i=(0,r.c)(21),{isUser:c,isExpanded:d,isScrollBounded:u,onContentMount:m,children:p,className:f,buttonSide:h,footer:x}=e,g=void 0!==u&&u,v=void 0===h?"none":h,b=!c,y=c?"user":"assistant",j=!d&&"max-h-80 overflow-hidden",S=g&&"overflow-hidden";return i[0]!==v||i[1]!==f||i[2]!==b||i[3]!==c||i[4]!==j||i[5]!==S?(a=(0,n.cn)("relative font-normal",j,S,!b&&["transition-colors border",c?"py-2 px-3.5":"py-3 px-4",c?"rounded-2xl":"rounded-xl","right"===v&&"rounded-r-none","left"===v&&"rounded-l-none",c?"border-transparent bg-[var(--bubble-color,hsl(var(--muted)))] text-[var(--bubble-text-color,hsl(var(--foreground)))] text-base leading-6 max-w-[70vw] md:max-w-xl [&_a]:text-[var(--bubble-text-color,hsl(var(--foreground)))] [&_a]:underline [&_p]:text-prose [&_p:last-child]:mb-0":"bg-card border-border text-foreground w-full"],b&&"w-full text-foreground",f),i[0]=v,i[1]=f,i[2]=b,i[3]=c,i[4]=j,i[5]=S,i[6]=a):a=i[6],i[7]!==p||i[8]!==x||i[9]!==g?(s=g?(0,t.jsxs)(H,{title:"Your message",ariaNoun:"message",fadeFromClassName:"from-[var(--bubble-color,hsl(var(--muted)))]",dialogBodyClassName:"text-base leading-6 break-words [&_p]:text-prose",children:[p,x]}):(0,t.jsxs)(t.Fragment,{children:[p,x]}),i[7]=p,i[8]=x,i[9]=g,i[10]=s):s=i[10],i[11]!==b||i[12]!==d||i[13]!==c?(o=!d&&(0,t.jsx)(tS,{isUser:c,isBareAssistant:b}),i[11]=b,i[12]=d,i[13]=c,i[14]=o):o=i[14],i[15]!==m||i[16]!==y||i[17]!==a||i[18]!==s||i[19]!==o?(l=(0,t.jsxs)("div",{ref:m,"data-message-bubble":y,className:a,children:[s,o]}),i[15]=m,i[16]=y,i[17]=a,i[18]=s,i[19]=o,i[20]=l):l=i[20],l}function tS(e){let a,s,o=(0,r.c)(6),{isUser:l,isBareAssistant:i}=e,c=!l&&!i;return o[0]!==i||o[1]!==l||o[2]!==c?(a=(0,n.cn)("absolute bottom-0 left-0 right-0 h-16 pointer-events-none",{"bg-gradient-to-t from-[var(--bubble-color,hsl(var(--muted)))] to-transparent":l,"bg-gradient-to-t from-background to-transparent":i,"bg-gradient-to-t from-card to-transparent dark:from-card":c}),o[0]=i,o[1]=l,o[2]=c,o[3]=a):a=o[3],o[4]!==a?(s=(0,t.jsx)("div",{className:a}),o[4]=a,o[5]=s):s=o[5],s}let tw=e=>{let n,a,s=(0,r.c)(7),{text:o,isUser:l,codeVariant:i}=e,c=!l,d=l?"hover:opacity-80":"text-foreground";if(s[0]!==o)n=!function(e){let t=e.trim();if(!(t.startsWith("{")&&t.endsWith("}"))&&!(t.startsWith("[")&&t.endsWith("]")))return!1;try{return JSON.parse(t),!0}catch{return!1}}(o)?o:`\`\`\`json ${o.trim()} \`\`\``,s[0]=o,s[1]=n;else n=s[1];return s[2]!==i||s[3]!==c||s[4]!==d||s[5]!==n?(a=(0,t.jsx)(tx.ChatroomMarkdownContainer,{shouldRenderRawHtml:c,linkClassName:d,codeVariant:i,children:n}),s[2]=i,s[3]=c,s[4]=d,s[5]=n,s[6]=a):a=s[6],a},tN=e=>{let n,a,s,o,l,i,c,d,u=(0,r.c)(17),{refusal:m}=e;if(u[0]!==m){let e=[th.ATTESTATION_SETTINGS_URL,th.ATTESTATION_SETTINGS_PATH].find(e=>m.includes(e)),r=e?m.indexOf(e):-1;s="flex w-full max-w-full items-start gap-2 rounded-md bg-red-3 dark:bg-red-4 p-3 text-sm text-red-12 dark:text-red-11 border border-red-6 ph-no-capture",o="hidden",u[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(tf.ExclamationTriangleIcon,{className:"size-5 shrink-0"}),u[7]=l):l=u[7],n="min-w-0 flex-1 break-words",a=-1!==r&&e?(0,t.jsxs)(t.Fragment,{children:[m.slice(0,r),(0,t.jsx)(ty.Link,{href:th.ATTESTATION_SETTINGS_PATH,className:"underline underline-offset-2",children:"settings"}),m.slice(r+e.length)]}):m,i=m.includes(tb.NO_ACTIVE_WORKSPACE_USER_MESSAGE)&&(0,t.jsxs)(t.Fragment,{children:[" ",(0,t.jsx)(ty.Link,{href:"/workspaces",className:"underline underline-offset-2",children:"Go to workspaces"})]}),u[0]=m,u[1]=n,u[2]=a,u[3]=s,u[4]=o,u[5]=l,u[6]=i}else n=u[1],a=u[2],s=u[3],o=u[4],l=u[5],i=u[6];return u[8]!==n||u[9]!==a||u[10]!==i?(c=(0,t.jsxs)("span",{className:n,children:[a,i]}),u[8]=n,u[9]=a,u[10]=i,u[11]=c):c=u[11],u[12]!==s||u[13]!==o||u[14]!==l||u[15]!==c?(d=(0,t.jsxs)("div",{className:s,"data-dd-privacy":o,children:[l,c]}),u[12]=s,u[13]=o,u[14]=l,u[15]=c,u[16]=d):d=u[16],d},tC=e=>{let n,s,o=(0,r.c)(9),{parts:l,isUser:i,attachmentMetadata:c}=e;if(o[0]!==c||o[1]!==i||o[2]!==l){s=Symbol.for("react.early_return_sentinel");e:{let e,r;o[5]!==c?(e=(e,t)=>{let r=function(e){switch(e.type){case"input_image":return e.image_url?{type:tv.AttachmentType.Image,url:e.image_url,name:"Image",size:0}:null;case"input_file":let t;return t=e.file_data??e.file_url,{type:tv.AttachmentType.File,url:t??"",content:t,name:e.filename||"File",size:0};case"input_audio":return e.input_audio.data?{type:tv.AttachmentType.Audio,url:e.input_audio.data,name:"Audio",size:0}:null;case"input_video":return e.video_url?{type:tv.AttachmentType.Video,url:e.video_url,name:"Video",size:0}:null;default:(0,a.assertNever)(e)}}(e);if(!r)return[];let n=c?.[t];return n&&n.type===r.type?[{...r,name:n.name,size:n.size}]:[r]},o[5]=c,o[6]=e):e=o[6];let d=l.flatMap(e);if(0===d.length){s=null;break e}if(1===d.length){let e=d[0];s=(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:(0,t.jsx)(eI.AttachmentPreview,{attachment:e,attachments:d,initialIndex:0},(0,eC.getAttachmentKey)(e))});break e}let u=i?"end":"start";o[7]!==u?(r={align:u,loop:!1,dragFree:!0},o[7]=u,o[8]=r):r=o[8],n=(0,t.jsx)(em.CardCarousel,{opts:r,items:d.map((e,r)=>({id:`${(0,eC.getAttachmentKey)(e)}-${r}`,body:(0,t.jsx)(eI.AttachmentPreview,{attachment:e,attachments:d,initialIndex:r})}))})}o[0]=c,o[1]=i,o[2]=l,o[3]=n,o[4]=s}else n=o[3],s=o[4];return s!==Symbol.for("react.early_return_sentinel")?s:n},tI=e=>{let s=(0,r.c)(9),{group:o,isUser:l,footer:i,codeVariant:c,attachmentMetadata:d}=e;switch(o.type){case"attachments":{let e;return s[0]!==d||s[1]!==o.parts||s[2]!==l?(e=(0,t.jsx)(tC,{parts:o.parts,isUser:l,attachmentMetadata:d}),s[0]=d,s[1]=o.parts,s[2]=l,s[3]=e):e=s[3],e}case"single":{let e;return s[4]!==c||s[5]!==i||s[6]!==o.part||s[7]!==l?(e=function({part:e,isUser:r,footer:s,codeVariant:o}){switch(e.type){case"input_text":case"output_text":return function({part:e,isUser:r,footer:a,codeVariant:s}){return(0,t.jsx)("div",{className:(0,n.cn)("w-full ph-no-capture",r?"flex justify-end":"flex justify-start"),"data-dd-privacy":"hidden",children:(0,t.jsx)(tj,{isUser:r,isExpanded:!0,isScrollBounded:r,className:(0,n.cn)("min-w-0",!r&&"w-full"),footer:a,children:(0,t.jsx)(tw,{text:e.text,isUser:r,codeVariant:s})})})}({part:e,isUser:r,footer:s,codeVariant:o});case"refusal":return(0,t.jsx)(tN,{refusal:e.refusal});default:(0,a.assertNever)(e)}}({part:o.part,isUser:l,footer:i,codeVariant:c}),s[4]=c,s[5]=i,s[6]=o.part,s[7]=l,s[8]=e):e=s[8],e}default:(0,a.assertNever)(o)}};function t_(){let e,n,a,s,o=(0,r.c)(4);return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(tg.Skeleton,{className:"h-3.5 w-[88%]"}),o[0]=e):e=o[0],o[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(tg.Skeleton,{className:"h-3.5 w-[96%]",style:{animationDelay:"50ms"}}),o[1]=n):n=o[1],o[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(tg.Skeleton,{className:"h-3.5 w-[72%]",style:{animationDelay:"100ms"}}),o[2]=a):a=o[2],o[3]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsxs)("div",{role:"status",className:"flex w-full flex-col gap-2.5","aria-live":"polite","aria-label":"Generating response",children:[e,n,a,(0,t.jsx)(tg.Skeleton,{className:"h-3.5 w-[40%]",style:{animationDelay:"150ms"}})]}),o[3]=s):s=o[3],s}function tk(){let e,n=(0,r.c)(1);return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("p",{className:"text-sm italic text-muted-foreground",children:"Response interrupted"}),n[0]=e):e=n[0],e}let tA=(0,s.memo)(({itemId:e,messageId:r})=>{let a=(0,ef.useItemStore)(t=>(0,v.selectContentPartsFromItem)(t,e)),c=(0,ef.useItemStore)(t=>(0,v.selectIsItemRevealing)(t,e)),d=(0,ef.useItemStore)(t=>(0,v.selectUrlCitationsFromItem)(t,e)),u=(0,s.useMemo)(l.makeSelectMessageById,[]),m=(0,i.useChatroomStore)(e=>u(e,r)),p=m?.type===o.MessageType.User,f=m?.type===o.MessageType.Assistant&&((m.isGenerating||m.isRetrying)??!1),h=(0,s.useMemo)(()=>(function(e){let t=[];if(!e)return t;let r=[];for(let n of e)if("input_image"===n.type||"input_file"===n.type||"input_audio"===n.type||"input_video"===n.type)r.push(n);else{if(("output_text"===n.type||"input_text"===n.type)&&!n.text.trim())continue;r.length>0&&(t.push({type:"attachments",parts:r}),r=[]),t.push({type:"single",part:n})}return r.length>0&&t.push({type:"attachments",parts:r}),t})(a),[a]),x=m?.type===o.MessageType.User?m.attachmentMetadata:void 0,g=(0,s.useMemo)(()=>{if(!x)return;let e=0;return h.map(t=>{if("attachments"!==t.type)return;let r=x.slice(e,e+t.parts.length);return e+=t.parts.length,r})},[h,x]),b=d&&d.length>0;if(0===h.length&&b||0===h.length&&!f&&p)return null;let y=f||c?(0,t.jsx)(t_,{}):(0,t.jsx)(tk,{});return(0,t.jsx)("div",{className:"flex w-full flex-col items-stretch gap-2",children:(0,t.jsxs)("div",{className:(0,n.cn)("flex w-full flex-col",p?"gap-2 items-end":"gap-1.5 items-start"),children:[h.map((e,r)=>(0,t.jsx)(tI,{group:e,isUser:!!p,codeVariant:"subtle",attachmentMetadata:g?.[r]},r)),0===h.length&&(f||!p)&&(0,t.jsx)("div",{className:(0,n.cn)("flex w-full items-stretch",p?"justify-end":"justify-start"),children:p?(0,t.jsx)(ti.ProcessingIndicator,{}):y})]})})});var tM=e.i(655648);let tT=(0,e.i(948810).create)()(e=>({target:null,open:t=>e({target:t}),close:()=>e({target:null})}));function tE(e){let t,n=(0,r.c)(2);return n[0]!==e?(t=t=>t.target?.itemId===e,n[0]=e,n[1]=t):t=n[1],tT(t)}function tR(e){let t=Math.round(e/1e3);if(t<60)return t<=0?"less than a second":`${t} second${1===t?"":"s"}`;let r=Math.floor(t/60);return`${r}:${(t%60).toString().padStart(2,"0")} minutes`}function tz({itemId:e,messageId:r}){let n=(0,s.useMemo)(l.makeSelectMessageById,[]),a=(0,i.useChatroomStore)(e=>n(e,r)),c=a?.type===o.MessageType.Assistant?a:void 0,d=c?.metadata?.reasoningDuration,u=c?.isGenerating??!1,m=(0,ef.useItemStore)(t=>(0,v.selectReasoningContentFromItem)(t,e)),p=(0,ef.useItemStore)(t=>(0,v.selectReasoningSummaryFromItem)(t,e)),f=m||p,h=!!d,x=u&&!h;return f||x?(0,t.jsx)(tO,{itemId:e,messageId:r,reasoningDurationMs:d??0,hasDuration:h,isReasoningGenerating:x,finalContent:f}):null}function tO(e){let n,a,o=(0,r.c)(13),{itemId:l,messageId:i,reasoningDurationMs:c,hasDuration:d,isReasoningGenerating:u,finalContent:m}=e,p=(0,s.useContext)(G);o[0]!==d||o[1]!==u||o[2]!==c?(n=function({isReasoningGenerating:e,hasDuration:t,reasoningDurationMs:r}){return e?"Thinking…":t?`Reasoned for ${tR(r)}`:"Reasoning"}({isReasoningGenerating:u,hasDuration:d,reasoningDurationMs:c}),o[0]=d,o[1]=u,o[2]=c,o[3]=n):n=o[3];let f=n;if(p===U){let e;return o[4]!==m||o[5]!==u||o[6]!==f?(e=(0,t.jsx)(tP,{label:f,finalContent:m,isReasoningGenerating:u}),o[4]=m,o[5]=u,o[6]=f,o[7]=e):e=o[7],e}return o[8]!==u||o[9]!==l||o[10]!==f||o[11]!==i?(a=(0,t.jsx)(tF,{itemId:l,messageId:i,label:f,isReasoningGenerating:u}),o[8]=u,o[9]=l,o[10]=f,o[11]=i,o[12]=a):a=o[12],a}function tF(e){let n,a,s=(0,r.c)(12),{itemId:o,messageId:l,label:i,isReasoningGenerating:c}=e,d=tE(o),u=tT(tL),m=tT(tD);s[0]!==m||s[1]!==d||s[2]!==o||s[3]!==l||s[4]!==u?(n=()=>{d?m():u({itemId:o,messageId:l})},s[0]=m,s[1]=d,s[2]=o,s[3]=l,s[4]=u,s[5]=n):n=s[5];let p=n,f=d?"Close reasoning panel":"Open reasoning panel";return s[6]!==p||s[7]!==d||s[8]!==c||s[9]!==i||s[10]!==f?(a=(0,t.jsx)(tV,{label:i,isActive:d,isPulsing:c,onClick:p,ariaExpanded:d,ariaLabel:f}),s[6]=p,s[7]=d,s[8]=c,s[9]=i,s[10]=f,s[11]=a):a=s[11],a}function tD(e){return e.close}function tL(e){return e.open}function tP(e){let a,o,l,i,c=(0,r.c)(13),{label:d,finalContent:u,isReasoningGenerating:m}=e,[p,f]=(0,s.useState)(!1);c[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>f(tB),c[0]=a):a=c[0];let h=p?"Hide reasoning":"Show reasoning";return c[1]!==p||c[2]!==m||c[3]!==d||c[4]!==h?(o=(0,t.jsx)(tV,{label:d,isActive:p,isPulsing:m,onClick:a,ariaExpanded:p,ariaLabel:h}),c[1]=p,c[2]=m,c[3]=d,c[4]=h,c[5]=o):o=c[5],c[6]!==u||c[7]!==p||c[8]!==m?(l=p&&(u||m)?(0,t.jsxs)("div",{className:(0,n.cn)("ph-no-capture max-h-[40vh] overflow-y-auto rounded-lg border border-border bg-muted/30 px-3 py-2","text-base leading-6","[&_p]:text-prose","[&_p]:my-3 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0"),"data-dd-privacy":"hidden",children:[(0,t.jsx)(tx.ChatroomMarkdownContainer,{children:u}),m&&(0,t.jsx)("div",{className:"mt-3 h-1 w-full overflow-hidden rounded-full bg-muted-foreground/20",children:(0,t.jsx)("div",{className:"h-full animate-pulse bg-muted-foreground/40"})})]}):null,c[6]=u,c[7]=p,c[8]=m,c[9]=l):l=c[9],c[10]!==o||c[11]!==l?(i=(0,t.jsxs)("div",{className:"flex w-full flex-col gap-2",children:[o,l]}),c[10]=o,c[11]=l,c[12]=i):i=c[12],i}function tB(e){return!e}function tV(e){let a,s,o,l,i=(0,r.c)(12),{label:c,isActive:d,isPulsing:m,onClick:p,ariaExpanded:f,ariaLabel:h}=e,x=d&&"bg-selected-bg text-foreground hover:bg-selected-bg hover:text-foreground",g=m&&"animate-pulse";return i[0]!==x||i[1]!==g?(a=(0,n.cn)("inline-flex items-center gap-1.5 self-start","h-7 rounded-full bg-muted pl-1.5 pr-2.5","text-xs text-muted-foreground","transition-colors hover:bg-card-hover hover:text-foreground",x,g),i[0]=x,i[1]=g,i[2]=a):a=i[2],i[3]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(tM.Sparkles,{className:"h-3.5 w-3.5"}),i[3]=s):s=i[3],i[4]!==c?(o=(0,t.jsx)("span",{children:c}),i[4]=c,i[5]=o):o=i[5],i[6]!==f||i[7]!==h||i[8]!==p||i[9]!==a||i[10]!==o?(l=(0,t.jsxs)(u.Button,{variant:"ghost",size:"sm",onClick:p,"aria-expanded":f,"aria-label":h,className:a,children:[s,o]}),i[6]=f,i[7]=h,i[8]=p,i[9]=a,i[10]=o,i[11]=l):l=i[11],l}e.s(["useIsReasoningItemOpen",0,tE,"useReasoningPanelStore",0,tT],309421),e.s(["formatReasoningDuration",0,tR],435799);var t$=e.i(704508),tH=e.i(698716),tU=e.i(202913);let tG=(0,tU.default)("video-off",[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var tq=e.i(19222),tW=e.i(479775),tK=e.i(508372),tJ=e.i(882026);e.i(634160);var tZ=e.i(402432),tY=e.i(528783),tX=e.i(488554),tQ=e.i(797530);let t0={src:null,isFromCache:!1},t1=[1e3,2e3,4e3,8e3];function t2(e){let n,a,o,l,c,d,u,m,p,f,h,x=(0,r.c)(33),{itemId:g}=e;x[0]!==g?(n=e=>(0,v.selectVideoGenerationCallData)(e,g),x[0]=g,x[1]=n):n=x[1];let b=(0,ef.useItemStore)(n);x[2]!==g?(a=e=>(0,v.selectItemById)(e,g)?.messageId,x[2]=g,x[3]=a):a=x[3];let y=(0,ef.useItemStore)(a),j=(0,i.useChatroomStore)(t5),[w,N]=(0,s.useState)(0),[C,I]=(0,s.useState)(!1),_=b?.jobId??null,{src:k,isFromCache:A,dropCachedSource:M}=function(e){let t,n,a,o,l,i=(0,r.c)(10),[c,d]=(0,s.useState)(t0),u=(0,s.useRef)(null);i[0]===Symbol.for("react.memo_cache_sentinel")?(t=()=>{null!==u.current&&(URL.revokeObjectURL(u.current),u.current=null)},i[0]=t):t=i[0];let m=t;i[1]!==e?(n=()=>{let t=!0;if(d(t0),null===e)return;let r=!1,n=()=>{t&&!r&&(r=!0,d({src:(0,tY.buildVideoContentUrl)(e),isFromCache:!1}))},a=setTimeout(n,tQ.VIDEO_CACHE_ANSWER_TIMEOUT_MS);return(async()=>{let s=await (0,te.wrap)(()=>(0,tX.hasCachedVideo)(e));if(clearTimeout(a),!t||r)return;if((0,te.isErr)(s)||!s.data)return n();let o=await (0,te.wrap)(()=>(0,tX.readCachedVideo)(e));if(t&&!r){if((0,te.isErr)(o)||!o.data)return n();r=!0,u.current=URL.createObjectURL(o.data),d({src:u.current,isFromCache:!0})}})(),()=>{t=!1,clearTimeout(a),m()}},a=[e],i[1]=e,i[2]=n,i[3]=a):(n=i[2],a=i[3]),(0,s.useEffect)(n,a),i[4]!==e||i[5]!==c?(o=()=>{null===e||c.isFromCache&&((0,tZ.refuseVideoCaching)({jobId:e}),(0,tX.deleteCachedVideo)(e),m(),d({src:(0,tY.buildVideoContentUrl)(e),isFromCache:!1}))},i[4]=e,i[5]=c,i[6]=o):o=i[6];let p=o;return i[7]!==p||i[8]!==c?(l={...c,dropCachedSource:p},i[7]=p,i[8]=c,i[9]=l):l=i[9],l}(_),T=b?.status==="queued"||b?.status==="processing";if(x[4]!==T||x[5]!==g||x[6]!==_||x[7]!==y||x[8]!==j?(o=()=>{if(!T||null===_||!j||!y)return;let e=new AbortController,t=`${location.origin}${location.pathname}`;return(0,tW.driveVideoJob)({itemId:g,messageId:y,jobId:_,referrer:t,itemActions:ef.useItemStore.getState().actions,abortController:e}).then(e=>{e?.kind===tK.VideoJobOutcomeKind.Completed&&((0,tJ.settleVideoMetadata)({roomId:j,messageId:y,generationId:e.generationId,cost:e.cost,getStoreState:S.getChatroomActionState}),void 0===e.cost&&(0,tJ.backfillVideoCostIntoMessage)({roomId:j,messageId:y,jobId:_,referrer:t,getStoreState:S.getChatroomActionState,abortController:new AbortController}))}),()=>(0,tq.abortVideoPoll)(g,e)},l=[T,_,j,y,g],x[4]=T,x[5]=g,x[6]=_,x[7]=y,x[8]=j,x[9]=o,x[10]=l):(o=x[9],l=x[10]),(0,s.useEffect)(o,l),x[11]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{I(!1),N(0)},x[11]=c):c=x[11],x[12]!==A||x[13]!==_?(d=[_,A],x[12]=A,x[13]=_,x[14]=d):d=x[14],(0,s.useEffect)(c,d),x[15]!==C||x[16]!==w?(u=()=>{if(!C)return;let e=t1[w];if(void 0===e)return;let t=setTimeout(()=>{I(!1),N(t3)},e);return()=>clearTimeout(t)},m=[C,w],x[15]=C,x[16]=w,x[17]=u,x[18]=m):(u=x[17],m=x[18]),(0,s.useEffect)(u,m),!b)return null;if("queued"===b.status||"processing"===b.status){let e,r=tH.VIDEO_JOB_STATUS_LABELS[b.status];return x[19]!==r?(e=(0,t.jsx)(t7,{label:r}),x[19]=r,x[20]=e):e=x[20],e}let E=C&&w>=t1.length;if("failed"===b.status||E){let e;return x[21]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(t6,{}),x[21]=e):e=x[21],e}return x[22]!==M||x[23]!==A||x[24]!==_||x[25]!==w||x[26]!==k?(p=null===k?(0,t.jsx)(t7,{label:"Loading video"}):(0,t.jsx)("video",{controls:!0,src:k,onLoadedData:()=>{A||null===_||(0,tZ.cacheVideo)({jobId:_})},onError:()=>{A?M():I(!0)},className:"aspect-auto h-96 max-w-full overflow-hidden rounded-lg border object-contain sm:max-w-xl"},`${w}:${k}`),x[22]=M,x[23]=A,x[24]=_,x[25]=w,x[26]=k,x[27]=p):p=x[27],x[28]!==A?(f=A&&(0,t.jsx)(t4,{}),x[28]=A,x[29]=f):f=x[29],x[30]!==f||x[31]!==p?(h=(0,t.jsx)("div",{className:"flex flex-wrap gap-2 ph-no-capture","data-dd-privacy":"hidden",children:(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1 duration-200 animate-in fade-in slide-in-from-left-8",children:[p,f]})}),x[30]=f,x[31]=p,x[32]=h):h=x[32],h}function t3(e){return e+1}function t5(e){return e.currentRoomId}function t4(){let e,n=(0,r.c)(1);return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(R.Tooltip,{content:(0,t.jsx)("span",{children:"The copy lives only in this browser, on this device. It is dropped after 30 days, when the cache fills, when storage runs short, or when you clear browsing data. Download anything you want to keep."}),children:(0,t.jsx)(R.TooltipNonInteractiveTrigger,{className:"w-fit text-xs text-muted-foreground underline decoration-dotted underline-offset-2",children:"Saved in this browser — not a backup"})}),n[0]=e):e=n[0],e}function t6(){let e,a=(0,r.c)(1);return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)("div",{className:(0,n.cn)("flex h-96 w-96 max-w-full flex-col items-center justify-center gap-3","rounded-lg border bg-muted sm:max-w-xl"),children:[(0,t.jsx)(tG,{className:"size-10 text-muted-foreground","aria-hidden":"true"}),(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"Video no longer available"})]}),a[0]=e):e=a[0],e}function t7(e){let n,a,s=(0,r.c)(3),{label:o}=e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(t$.FilmIcon,{className:"size-10 text-muted-foreground","aria-hidden":"true"}),s[0]=n):n=s[0],s[1]!==o?(a=(0,t.jsxs)("div",{className:"flex h-96 w-96 max-w-full flex-col items-center justify-center gap-3 rounded-lg border bg-muted sm:max-w-xl",children:[n,(0,t.jsx)(ti.ProcessingIndicator,{label:o})]}),s[1]=o,s[2]=a):a=s[2],a}var t8=e.i(634061),t9=e.i(682716),re=e.i(132736),rt=e.i(796805);let rr=rt.z.object({prompt:rt.z.string().optional(),model:rt.z.string().optional()});function rn(e){if(!e)return null;let t=(0,te.wrap)(()=>JSON.parse(e));if((0,te.isErr)(t))return null;let r=(0,tt.parseSchema)(rr,t.data);return(0,te.isOk)(r)?r.data:null}function ra(e){let t=rn(e);return t?.prompt?.trim()||null}var rs=e.i(217631),ro=e.i(301797),rl=e.i(847665),ri=e.i(213648),rc=e.i(890136);let rd=(0,tU.default)("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);e.s(["Lightbulb",0,rd],459421);let ru=(0,tU.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);var rm=e.i(926514);let rp=(0,tU.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);function rf(e){let n,a,s=(0,r.c)(5),{title:o,children:l}=e;return s[0]!==o?(n=(0,t.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o}),s[0]=o,s[1]=n):n=s[1],s[2]!==l||s[3]!==n?(a=(0,t.jsxs)("section",{className:"flex flex-col gap-1",children:[n,l]}),s[2]=l,s[3]=n,s[4]=a):a=s[4],a}let rh="shrink-0 rounded-sm border px-1.5 py-0.5 text-2xs font-medium",rx="border-negative/20 bg-negative-bg text-negative";function rg(e){let a,s,o=(0,r.c)(9),{outcome:l,className:i}=e;if("timeout"===l.kind){let e,r;return o[0]!==i?(e=(0,n.cn)(rh,rx,i),o[0]=i,o[1]=e):e=o[1],o[2]!==e?(r=(0,t.jsx)("span",{className:e,children:"timeout"}),o[2]=e,o[3]=r):r=o[3],r}if(0===l.code)return null;o[4]!==i?(a=(0,n.cn)(rh,rx,i),o[4]=i,o[5]=a):a=o[5];let c=`✗ exit ${l.code}`;return o[6]!==a||o[7]!==c?(s=(0,t.jsx)("span",{className:a,children:c}),o[6]=a,o[7]=c,o[8]=s):s=o[8],s}var rv=e.i(647732),rv=rv;function rb(){let e,n=(0,r.c)(1);return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(rv.default,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-negative"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-negative",children:"Malformed tool call input"})]}),n[0]=e):e=n[0],e}let ry=rt.z.object({command:rt.z.string().optional(),commands:rt.z.array(rt.z.string()).optional(),restart:rt.z.boolean().optional()});function rj(e){if(!e)return null;let t=(0,te.wrap)(()=>JSON.parse(e));if((0,te.isErr)(t))return null;let r=(0,tt.parseSchema)(ry,t.data);if((0,te.isErr)(r))return null;let{command:n,commands:a,restart:s}=r.data;return!0===s?null:n||(a&&a.length>0?a.join("\n"):null)}let rS="openrouter:";function rw(e){let n,a,s=(0,r.c)(4),{toolName:o}=e;s[0]!==o?(n=o.startsWith(rS)?o.slice(rS.length):o,s[0]=o,s[1]=n):n=s[1];let l=n;return s[2]!==l?(a=(0,t.jsx)("span",{className:"shrink-0 font-mono text-foreground",children:l}),s[2]=l,s[3]=a):a=s[3],a}let rN="openrouter:bash";var rC=e.i(649188),rI=e.i(252358),r_=e.i(893694),rk=e.i(564353);function rA(e){let n,a,s=(0,r.c)(11),{files:o,source:l}=e,i=(0,ee.useLocale)(),c=(0,rI.usePosthogClient)();if(0===o.length)return null;if(s[0]!==o||s[1]!==i||s[2]!==c||s[3]!==l){let e;s[5]!==i||s[6]!==c||s[7]!==l?(e=e=>(0,t.jsx)("li",{children:(0,t.jsxs)("a",{href:(0,rk.containerFileContentPath)(e.container_id,e.file_id),download:e.filename,className:"inline-flex min-w-0 items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground hover:underline",onClick:()=>{c.capture(T.PostHogEvent.ClickContainerFileDownload,{source:l,container_id:e.container_id,file_id:e.file_id})},children:[(0,t.jsx)(rC.ArrowDownTrayIcon,{className:"size-3.5 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:e.filename}),void 0!==e.bytes&&(0,t.jsx)("span",{className:"shrink-0 text-muted-foreground/60",children:(0,r_.formatFileBytes)(e.bytes,{locale:i})??"—"})]})},e.file_id),s[5]=i,s[6]=c,s[7]=l,s[8]=e):e=s[8],n=o.map(e),s[0]=o,s[1]=i,s[2]=c,s[3]=l,s[4]=n}else n=s[4];return s[9]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5 font-mono text-xs",children:n}),s[9]=n,s[10]=a):a=s[10],a}function rM(e){let n,a,s,o,l,i,c,d,u=(0,r.c)(18),{command:m,stdout:p,stderr:f,outcome:h}=e;return u[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)("span",{className:"select-none text-muted-foreground",children:"$ "}),u[0]=n):n=u[0],u[1]!==m?(a=m??(0,t.jsx)("span",{className:"text-muted-foreground",children:"(command unavailable)"}),u[1]=m,u[2]=a):a=u[2],u[3]!==a?(s=(0,t.jsxs)("span",{className:"min-w-0 flex-1 whitespace-pre-wrap break-all text-foreground",children:[n,a]}),u[3]=a,u[4]=s):s=u[4],u[5]!==h?(o=h&&(0,t.jsx)(rg,{outcome:h}),u[5]=h,u[6]=o):o=u[6],u[7]!==s||u[8]!==o?(l=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[s,o]}),u[7]=s,u[8]=o,u[9]=l):l=u[9],u[10]!==p?(i=p&&(0,t.jsx)("pre",{className:"whitespace-pre-wrap break-all text-muted-foreground",children:p}),u[10]=p,u[11]=i):i=u[11],u[12]!==f?(c=f&&(0,t.jsx)("pre",{className:"whitespace-pre-wrap break-all text-negative",children:f}),u[12]=f,u[13]=c):c=u[13],u[14]!==l||u[15]!==i||u[16]!==c?(d=(0,t.jsxs)("div",{className:"flex flex-col gap-1 font-mono text-xs",children:[l,i,c]}),u[14]=l,u[15]=i,u[16]=c,u[17]=d):d=u[17],d}e.s(["ContainerFileLinks",0,rA],591397);let rT=rt.z.object({timezone:rt.z.string().optional()});function rE(e){let n,a,s=(0,r.c)(5),{title:o,children:l}=e;return s[0]!==o?(n=(0,t.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o}),s[0]=o,s[1]=n):n=s[1],s[2]!==l||s[3]!==n?(a=(0,t.jsxs)("section",{className:"flex flex-col gap-1",children:[n,l]}),s[2]=l,s[3]=n,s[4]=a):a=s[4],a}function rR(e){let n,a,s=(0,r.c)(4),{items:o}=e;return s[0]!==o?(n=o.map(rz),s[0]=o,s[1]=n):n=s[1],s[2]!==n?(a=(0,t.jsx)("ul",{className:"list-inside list-disc text-foreground",children:n}),s[2]=n,s[3]=a):a=s[3],a}function rz(e,r){return(0,t.jsx)("li",{className:"mt-0.5 first:mt-0",children:e},r)}function rO(e,r){return(0,t.jsxs)("li",{className:"mt-1 first:mt-0",children:[e.point,e.models.length>0&&(0,t.jsxs)("span",{className:"ml-1 text-muted-foreground text-xs",children:["(",e.models.join(", "),")"]})]},r)}function rF(e,r){return(0,t.jsxs)("li",{className:"mt-1 first:mt-0",children:[(0,t.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:e.model}),":"," ",e.insight]},r)}function rD(e,r){return(0,t.jsxs)("li",{className:"mt-2 first:mt-0",children:[(0,t.jsx)("div",{className:"font-medium",children:e.topic}),(0,t.jsx)("ul",{className:"mt-1 list-inside list-disc",children:e.stances.map(rL)})]},r)}function rL(e,r){return(0,t.jsxs)("li",{className:"mt-0.5 first:mt-0",children:[(0,t.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:e.model}),":"," ",e.stance]},r)}function rP(e){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs",children:e},e)}function rB(e){return e.model}let rV=rt.z.object({prompt:rt.z.string()}),r$=rt.z.object({query:rt.z.string().optional()}),rH="openrouter:shell",rU=rt.z.object({task_name:rt.z.string().optional(),task_description:rt.z.string().optional()});function rG(e){if(!e)return null;let t=(0,te.wrap)(()=>JSON.parse(e));if((0,te.isErr)(t))return null;let r=(0,tt.parseSchema)(rU,t.data);return(0,te.isOk)(r)?r.data:null}function rq(e){let t=rG(e);return t?.task_name?.trim()||null}function rW(e){let t=rG(e);return t?.task_description?.trim()||null}function rK(e){let n,a,s=(0,r.c)(5),{title:o,children:l}=e;return s[0]!==o?(n=(0,t.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o}),s[0]=o,s[1]=n):n=s[1],s[2]!==l||s[3]!==n?(a=(0,t.jsxs)("section",{className:"flex flex-col gap-1",children:[n,l]}),s[2]=l,s[3]=n,s[4]=a):a=s[4],a}function rJ(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}let rZ={200:"OK",201:"Created",202:"Accepted",204:"No Content",301:"Redirect",302:"Redirect",304:"Cached",400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",408:"Timeout",410:"Gone",429:"Rate Limited",500:"Server Error",502:"Bad Gateway",503:"Unavailable",504:"Gateway Timeout"},rY=rt.z.object({url:rt.z.string().regex(/^https?:\/\//i,"url must be http(s)").optional().catch(void 0)});function rX(e){return e.stopPropagation()}function rQ(e){let n,a,s,o=(0,r.c)(5),{engine:l}=e;o[0]!==l?(n=rJ(l),o[0]=l,o[1]=n):n=o[1];let i=n;return i?(o[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("span",{children:"Engine:"}),o[2]=a):a=o[2],o[3]!==i?(s=(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[a,(0,t.jsx)("span",{className:"font-medium text-muted-foreground",children:i})]}),o[3]=i,o[4]=s):s=o[4],s):null}let r0={"openrouter:datetime":{label:"Date & Time",icon:ro.Clock,DescriptionComponent:function(e){let n,a,s,o=(0,r.c)(7),{args:l,isCompleted:i}=e;o[0]!==l?(n=function(e){if(!e)return null;let t=(0,te.wrap)(()=>JSON.parse(e));if((0,te.isErr)(t))return null;let r=(0,tt.parseSchema)(rT,t.data);return(0,te.isOk)(r)?r.data.timezone??null:null}(l),o[0]=l,o[1]=n):n=o[1];let c=n,d=i?"Retrieved current date & time":"Getting current date & time...";return o[2]!==c?(a=c&&(0,t.jsxs)(t.Fragment,{children:[" ",(0,t.jsxs)("span",{className:"font-medium text-foreground",children:["(",c,")"]})]}),o[2]=c,o[3]=a):a=o[3],o[4]!==d||o[5]!==a?(s=(0,t.jsxs)(t.Fragment,{children:[d,a]}),o[4]=d,o[5]=a,o[6]=s):s=o[6],s}},"openrouter:web_search":{label:"Web Search",icon:ri.Globe,DescriptionComponent:function(e){let n,a,s=(0,r.c)(10),{outputData:o,isCompleted:l,isFailed:i,isIncomplete:c}=e,d=o?.webSearch?.query,u=i||c;if(s[0]!==u||s[1]!==l)n=u?{prefix:"Search failed for",fallback:"Search failed"}:l?{prefix:"Searched for",fallback:"Search completed"}:{prefix:"Searching for",fallback:"Searching..."},s[0]=u,s[1]=l,s[2]=n;else n=s[2];let{prefix:m,fallback:p}=n;if(d){let e,r;return s[3]!==d?(e=(0,t.jsx)("span",{className:"font-medium text-foreground",children:d}),s[3]=d,s[4]=e):e=s[4],s[5]!==m||s[6]!==e?(r=(0,t.jsxs)(t.Fragment,{children:[m," ",e]}),s[5]=m,s[6]=e,s[7]=r):r=s[7],r}return s[8]!==p?(a=(0,t.jsx)(t.Fragment,{children:p}),s[8]=p,s[9]=a):a=s[9],a},MetadataComponent:function(e){let n,a=(0,r.c)(3),{outputData:s,isCompleted:o,isFailed:l,isIncomplete:i}=e,c=s?.webSearch?.sources?.length??0;if(!o||l||i||0===c)return null;let d=1===c?"result":"results";return a[0]!==c||a[1]!==d?(n=(0,t.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[c," ",d]}),a[0]=c,a[1]=d,a[2]=n):n=a[2],n},ExpandedComponent:function(e){let n,a,s,o,l=(0,r.c)(10),{data:i,engine:c}=e;l[0]!==i.arguments?(n=tn(i.arguments),l[0]=i.arguments,l[1]=n):n=l[1];let{formatted:d}=n,u=!!c;return l[2]!==c||l[3]!==u?(a=u&&c&&(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:(0,t.jsx)(rQ,{engine:c})}),l[2]=c,l[3]=u,l[4]=a):a=l[4],l[5]!==d?(s=d&&(0,t.jsx)(e7.CodeBlock,{language:"json",value:d}),l[5]=d,l[6]=s):s=l[6],l[7]!==a||l[8]!==s?(o=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[a,s]}),l[7]=a,l[8]=s,l[9]=o):o=l[9],o},hasRichExpandedContent:()=>!0},"openrouter:web_fetch":{label:"Web Fetch",icon:ru,DescriptionComponent:function(e){let n,a,s,o,l,i,c,d,u=(0,r.c)(28),{args:m,outputData:p,isCompleted:f,isFailed:h,engine:x}=e;u[0]!==m||u[1]!==p?.webFetch?.url?(n=p?.webFetch?.url??function(e){if(!e)return null;let t=(0,te.wrap)(()=>JSON.parse(e));if((0,te.isErr)(t))return null;let r=(0,tt.parseSchema)(rY,t.data);return(0,te.isErr)(r)?null:r.data.url??null}(m),u[0]=m,u[1]=p?.webFetch?.url,u[2]=n):n=u[2];let g=n,v=p?.webFetch?.httpStatus,b=p?.webFetch?.error,y=h||!!b;if(!g){let e,r;return u[3]!==y||u[4]!==f?(e=y?"Fetch failed":f?"Fetch completed":"Fetching...",u[3]=y,u[4]=f,u[5]=e):e=u[5],u[6]!==e?(r=(0,t.jsx)(t.Fragment,{children:e}),u[6]=e,u[7]=r):r=u[7],r}u[8]!==y||u[9]!==v?(a=y?function(e){let t;return void 0===e?"Error":e>=400?(t=rZ[e])||(e>=200&&e<300?"OK":e>=300&&e<400?"Redirect":e>=400&&e<500?"Client Error":e>=500&&e<600?"Server Error":`HTTP ${e}`):"Not Found"}(v):null,u[8]=y,u[9]=v,u[10]=a):a=u[10];let j=a;if(u[11]!==b||u[12]!==v){let e;e=[],void 0!==v&&e.push(`HTTP ${v}`),b&&e.push(b),s=e.length>0?e.join(" · "):void 0,u[11]=b,u[12]=v,u[13]=s}else s=u[13];let S=s;u[14]!==x?(o=x?rJ(x):null,u[14]=x,u[15]=o):o=u[15];let w=o;return u[16]!==g?(l=(0,t.jsx)("a",{href:g,target:"_blank",rel:"noreferrer noopener",onClick:rX,className:"min-w-0 truncate font-medium text-foreground decoration-muted-foreground underline-offset-2 hover:underline",children:g}),u[16]=g,u[17]=l):l=u[17],u[18]!==w||u[19]!==j?(i=w&&!j&&(0,t.jsx)("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:w}),u[18]=w,u[19]=j,u[20]=i):i=u[20],u[21]!==j?(c=j&&(0,t.jsx)("span",{className:"ml-auto shrink-0 rounded-sm border border-negative/20 bg-negative-bg px-1.5 py-0.5 text-2xs font-medium text-negative",children:j}),u[21]=j,u[22]=c):c=u[22],u[23]!==S||u[24]!==l||u[25]!==i||u[26]!==c?(d=(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",title:S,children:[l,i,c]}),u[23]=S,u[24]=l,u[25]=i,u[26]=c,u[27]=d):d=u[27],d},disableExpand:!0,hideStatusIndicator:!0},"openrouter:image_generation":{label:"Image Generation",icon:rc.Image,DescriptionComponent:function(e){let n,a,s=(0,r.c)(10),{args:o,isCompleted:l}=e;if(s[0]!==o||s[1]!==l){n=Symbol.for("react.early_return_sentinel");e:{let e=function(e){if(!e)return null;let t=(0,te.wrap)(()=>JSON.parse(e));if((0,te.isErr)(t))return null;let r=(0,tt.parseSchema)(rV,t.data);return(0,te.isOk)(r)?r.data.prompt:null}(o);if(e){let r,a,o=e.length>50?`${e.slice(0,50)}...`:e,i=l?"Generated":"Generating";s[3]!==o?(r=(0,t.jsx)("span",{className:"font-medium text-foreground",children:o}),s[3]=o,s[4]=r):r=s[4],s[5]!==i||s[6]!==r?(a=(0,t.jsxs)(t.Fragment,{children:[i," ",r]}),s[5]=i,s[6]=r,s[7]=a):a=s[7],n=a;break e}}s[0]=o,s[1]=l,s[2]=n}else n=s[2];if(n!==Symbol.for("react.early_return_sentinel"))return n;let i=l?"Image generated":"Generating image...";return s[8]!==i?(a=(0,t.jsx)(t.Fragment,{children:i}),s[8]=i,s[9]=a):a=s[9],a}},"openrouter:experimental__search_models":{label:"Search Models",icon:rm.Search,DescriptionComponent:function(e){let n,a,s=(0,r.c)(9),{args:o,isCompleted:l}=e;s[0]!==o?(n=function(e){if(!e)return null;let t=(0,te.wrap)(()=>JSON.parse(e));if((0,te.isErr)(t))return null;let r=(0,tt.parseSchema)(r$,t.data);return(0,te.isOk)(r)?r.data.query??null:null}(o),s[0]=o,s[1]=n):n=s[1];let i=n;if(i){let e,r,n=l?"Searched models for":"Searching models for";return s[2]!==i?(e=(0,t.jsx)("span",{className:"font-medium text-foreground",children:i}),s[2]=i,s[3]=e):e=s[3],s[4]!==n||s[5]!==e?(r=(0,t.jsxs)(t.Fragment,{children:[n," ",e]}),s[4]=n,s[5]=e,s[6]=r):r=s[6],r}let c=l?"Search completed":"Searching...";return s[7]!==c?(a=(0,t.jsx)(t.Fragment,{children:c}),s[7]=c,s[8]=a):a=s[8],a}},"openrouter:fusion":{label:"Fusion",icon:tM.Sparkles,DescriptionComponent:function(e){let n,a,s=(0,r.c)(11),{outputData:o,isCompleted:l,isFailed:i,isIncomplete:c,fusionRespondingModel:d}=e,{getModelInfoByVariantSlug:u}=(0,f.useGlobal)(),m=o?.fusion,p=m?.error,h=m?.responses?.length;s[0]!==d||s[1]!==u?(n=d?u(d):null,s[0]=d,s[1]=u,s[2]=n):n=s[2];let x=n,g=x?.short_name??d;if(i||c){let e,r=p?`Fusion failed — ${p}`:"Fusion failed";return s[3]!==r?(e=(0,t.jsx)(t.Fragment,{children:r}),s[3]=r,s[4]=e):e=s[4],e}if(l){let e;if(void 0!==h&&h>0){let e,r=g?` by ${g}`:"",n=1===h?"model":"models";return s[5]!==r||s[6]!==h||s[7]!==n?(e=(0,t.jsxs)(t.Fragment,{children:["Fusion: ",h," ",n," analyzed",r]}),s[5]=r,s[6]=h,s[7]=n,s[8]=e):e=s[8],e}return s[9]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(t.Fragment,{children:"Fusion analysis complete"}),s[9]=e):e=s[9],e}return s[10]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(t.Fragment,{children:"Fusion: Running multi-model analysis…"}),s[10]=a):a=s[10],a},ExpandedComponent:function(e){let n,a,s,o,l,i,c,d,u=(0,r.c)(21),{data:m}=e,p=m.outputData?.fusion;if(!p)return null;let{analysis:f,responses:h}=p;if(u[0]!==h){let e=h?.map(rB)??[];n="flex flex-col gap-3",a=e.length>0&&(0,t.jsx)(rE,{title:"Models consulted",children:(0,t.jsx)("ul",{className:"flex flex-wrap gap-x-2 gap-y-1 text-foreground",children:e.map(rP)})}),u[0]=h,u[1]=n,u[2]=a}else n=u[1],a=u[2];return u[3]!==f?(s=f?.consensus.length?(0,t.jsx)(rE,{title:"Consensus",children:(0,t.jsx)(rR,{items:f.consensus})}):null,u[3]=f,u[4]=s):s=u[4],u[5]!==f?(o=f?.contradictions.length?(0,t.jsx)(rE,{title:"Contradictions",children:(0,t.jsx)("ul",{className:"text-foreground",children:f.contradictions.map(rD)})}):null,u[5]=f,u[6]=o):o=u[6],u[7]!==f?(l=f?.unique_insights.length?(0,t.jsx)(rE,{title:"Unique insights",children:(0,t.jsx)("ul",{className:"text-foreground",children:f.unique_insights.map(rF)})}):null,u[7]=f,u[8]=l):l=u[8],u[9]!==f?(i=f?.partial_coverage.length?(0,t.jsx)(rE,{title:"Partial coverage",children:(0,t.jsx)("ul",{className:"text-foreground",children:f.partial_coverage.map(rO)})}):null,u[9]=f,u[10]=i):i=u[10],u[11]!==f?(c=f?.blind_spots.length?(0,t.jsx)(rE,{title:"Blind spots",children:(0,t.jsx)(rR,{items:f.blind_spots})}):null,u[11]=f,u[12]=c):c=u[12],u[13]!==n||u[14]!==a||u[15]!==s||u[16]!==o||u[17]!==l||u[18]!==i||u[19]!==c?(d=(0,t.jsxs)("div",{className:n,children:[a,s,o,l,i,c]}),u[13]=n,u[14]=a,u[15]=s,u[16]=o,u[17]=l,u[18]=i,u[19]=c,u[20]=d):d=u[20],d},hasRichExpandedContent:e=>{let t=e.outputData?.fusion;return!!t&&(!!t.analysis||(t.responses?.length??0)>0)}},"openrouter:advisor":{label:"Advisor",icon:rd,DescriptionComponent:function(e){let n,a,s,o,l=(0,r.c)(18),{advisorModelSlug:i,isCompleted:c,isFailed:d,isIncomplete:u}=e,{getModelInfoByVariantSlug:p}=(0,f.useGlobal)();l[0]!==i||l[1]!==p?(n=i?p(i):null,l[0]=i,l[1]=p,l[2]=n):n=l[2];let h=n,x=h?.short_name??i;l[3]!==h||l[4]!==x?(a=x?(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1 align-middle",children:[h?(0,t.jsx)(m.AuthorIcon,{author:h.author,iconUri:h.author_icon_uri,className:"size-4"}):null,(0,t.jsx)("span",{className:"truncate font-medium text-foreground",children:x})]}):null,l[3]=h,l[4]=x,l[5]=a):a=l[5];let g=a;if(d||u){let e,r;return l[6]!==g?(e=g?(0,t.jsxs)(t.Fragment,{children:["Advice from ",g," failed"]}):"Advisor failed",l[6]=g,l[7]=e):e=l[7],l[8]!==e?(r=(0,t.jsx)(t.Fragment,{children:e}),l[8]=e,l[9]=r):r=l[9],r}if(c){let e,r;return l[10]!==g?(e=g?(0,t.jsxs)(t.Fragment,{children:["Consulted ",g]}):"Advice received",l[10]=g,l[11]=e):e=l[11],l[12]!==e?(r=(0,t.jsx)(t.Fragment,{children:e}),l[12]=e,l[13]=r):r=l[13],r}return l[14]!==g?(s=g?(0,t.jsxs)(t.Fragment,{children:["Consulting ",g,"…"]}):"Consulting advisor…",l[14]=g,l[15]=s):s=l[15],l[16]!==s?(o=(0,t.jsx)(t.Fragment,{children:s}),l[16]=s,l[17]=o):o=l[17],o},ExpandedComponent:function(e){let n,a,s,o,l,i,c,d=(0,r.c)(18),{data:u}=e,m=u.outputData?.advisor;d[0]!==m?.prompt||d[1]!==u.arguments?(n=m?.prompt?.trim()||ra(u.arguments),d[0]=m?.prompt,d[1]=u.arguments,d[2]=n):n=d[2];let p=n;d[3]!==m?.advice?(a=m?.advice?.trim(),d[3]=m?.advice,d[4]=a):a=d[4];let f=a;d[5]!==m?.error?(s=m?.error?.trim(),d[5]=m?.error,d[6]=s):s=d[6];let h=s;return p||f||h?(d[7]!==p?(o=p&&(0,t.jsx)(rf,{title:"Prompt",children:(0,t.jsx)("p",{className:"whitespace-pre-wrap text-foreground",children:p})}),d[7]=p,d[8]=o):o=d[8],d[9]!==f?(l=f&&(0,t.jsx)(rf,{title:"Advice",children:(0,t.jsx)("p",{className:"whitespace-pre-wrap text-foreground",children:f})}),d[9]=f,d[10]=l):l=d[10],d[11]!==f||d[12]!==h?(i=h&&!f&&(0,t.jsx)(rf,{title:"Error",children:(0,t.jsx)("p",{className:"whitespace-pre-wrap text-warning",children:h})}),d[11]=f,d[12]=h,d[13]=i):i=d[13],d[14]!==o||d[15]!==l||d[16]!==i?(c=(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[o,l,i]}),d[14]=o,d[15]=l,d[16]=i,d[17]=c):c=d[17],c):null},hasRichExpandedContent:e=>{if(null!==ra(e.arguments))return!0;let t=e.outputData?.advisor;return!!t?.prompt?.trim()||!!t?.advice?.trim()||!!t?.error?.trim()}},"openrouter:subagent":{label:"Subagent",icon:rl.Cpu,DescriptionComponent:function(e){let n,a,s,o,l=(0,r.c)(17),{args:i,outputData:c,isCompleted:d,isFailed:u,isIncomplete:m}=e;l[0]!==i||l[1]!==c?.subagent?.task_name?(n=c?.subagent?.task_name?.trim()||rq(i),l[0]=i,l[1]=c?.subagent?.task_name,l[2]=n):n=l[2];let p=n;l[3]!==p?(a=p?(0,t.jsx)("span",{className:"truncate font-medium text-foreground",children:p}):null,l[3]=p,l[4]=a):a=l[4];let f=a;if(u||m){let e,r;return l[5]!==f?(e=f?(0,t.jsxs)(t.Fragment,{children:["Task ",f," failed"]}):"Subagent task failed",l[5]=f,l[6]=e):e=l[6],l[7]!==e?(r=(0,t.jsx)(t.Fragment,{children:e}),l[7]=e,l[8]=r):r=l[8],r}if(d){let e,r;return l[9]!==f?(e=f?(0,t.jsxs)(t.Fragment,{children:["Completed ",f]}):"Task completed",l[9]=f,l[10]=e):e=l[10],l[11]!==e?(r=(0,t.jsx)(t.Fragment,{children:e}),l[11]=e,l[12]=r):r=l[12],r}return l[13]!==f?(s=f?(0,t.jsxs)(t.Fragment,{children:["Running ",f,"…"]}):"Running subagent task…",l[13]=f,l[14]=s):s=l[14],l[15]!==s?(o=(0,t.jsx)(t.Fragment,{children:s}),l[15]=s,l[16]=o):o=l[16],o},ExpandedComponent:function(e){let n,a,s,o,l,i,c,d=(0,r.c)(18),{data:u}=e,m=u.outputData?.subagent;d[0]!==u.arguments||d[1]!==m?.task_description?(n=m?.task_description?.trim()||rW(u.arguments),d[0]=u.arguments,d[1]=m?.task_description,d[2]=n):n=d[2];let p=n;d[3]!==m?.outcome?(a=m?.outcome?.trim(),d[3]=m?.outcome,d[4]=a):a=d[4];let f=a;d[5]!==m?.error?(s=m?.error?.trim(),d[5]=m?.error,d[6]=s):s=d[6];let h=s;return p||f||h?(d[7]!==p?(o=p&&(0,t.jsx)(rK,{title:"Task",children:(0,t.jsx)("p",{className:"whitespace-pre-wrap text-foreground",children:p})}),d[7]=p,d[8]=o):o=d[8],d[9]!==f?(l=f&&(0,t.jsx)(rK,{title:"Outcome",children:(0,t.jsx)("p",{className:"whitespace-pre-wrap text-foreground",children:f})}),d[9]=f,d[10]=l):l=d[10],d[11]!==h||d[12]!==f?(i=h&&!f&&(0,t.jsx)(rK,{title:"Error",children:(0,t.jsx)("p",{className:"whitespace-pre-wrap text-warning",children:h})}),d[11]=h,d[12]=f,d[13]=i):i=d[13],d[14]!==o||d[15]!==l||d[16]!==i?(c=(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[o,l,i]}),d[14]=o,d[15]=l,d[16]=i,d[17]=c):c=d[17],c):null},hasRichExpandedContent:e=>{if(null!==rq(e.arguments)||null!==rW(e.arguments))return!0;let t=e.outputData?.subagent;return!!t?.task_description?.trim()||!!t?.outcome?.trim()||!!t?.error?.trim()}},"openrouter:bash":{label:"Bash",icon:rp,iconClassName:"text-foreground",DescriptionComponent:function(e){let a,s,o,l,i,c,d=(0,r.c)(22),{args:u,outputData:m,isCompleted:p,isFailed:f,isIncomplete:h}=e,x=m?.bash;d[0]!==u||d[1]!==x?.command?(a=x?.command??rj(u),d[0]=u,d[1]=x?.command,d[2]=a):a=d[2];let g=a,v=x?.exitCode,b=p||f||h,y=f||h||void 0!==v&&0!==v;if(b&&!x&&function(e){if(!e)return!1;let t=(0,te.wrap)(()=>JSON.parse(e));if((0,te.isErr)(t))return!0;let r=(0,tt.parseSchema)(ry,t.data);if((0,te.isErr)(r))return!0;let{command:n,commands:a,restart:s}=r.data;return!0!==s&&!n&&(void 0===a||0===a.length)}(u)){let e;return d[3]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,t.jsx)(rw,{toolName:rN}),(0,t.jsx)(rb,{})]}),d[3]=e):e=d[3],e}if(!g){let e,r,a,s;d[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(rw,{toolName:rN}),d[4]=e):e=d[4];let o=!b&&"text-muted-foreground";if(d[5]!==o?(r=(0,n.cn)("min-w-0 flex-1 truncate",o),d[5]=o,d[6]=r):r=d[6],d[7]!==y||d[8]!==p)a=y?"Command failed":p?"Command completed":"Running...",d[7]=y,d[8]=p,d[9]=a;else a=d[9];return d[10]!==r||d[11]!==a?(s=(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e,(0,t.jsx)("span",{className:r,children:a})]}),d[10]=r,d[11]=a,d[12]=s):s=d[12],s}return d[13]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(rw,{toolName:rN}),d[13]=s):s=d[13],d[14]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("span",{className:"select-none text-muted-foreground",children:"$ "}),d[14]=o):o=d[14],d[15]!==g?(l=(0,t.jsxs)("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:[o,g]}),d[15]=g,d[16]=l):l=d[16],d[17]!==v?(i=void 0!==v&&(0,t.jsx)(rg,{className:"ml-auto",outcome:{kind:"exit",code:v}}),d[17]=v,d[18]=i):i=d[18],d[19]!==l||d[20]!==i?(c=(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s,l,i]}),d[19]=l,d[20]=i,d[21]=c):c=d[21],c},ExpandedComponent:function(e){let n,a,s,o,l,i=(0,r.c)(15),{data:c}=e,d=c.outputData?.bash;i[0]!==d?.command||i[1]!==c.arguments?(n=d?.command??rj(c.arguments)??void 0,i[0]=d?.command,i[1]=c.arguments,i[2]=n):n=i[2];let u=n,m=d?.exitCode,p=d?.stdout,f=d?.stderr;return i[3]!==m?(a=void 0!==m?{kind:"exit",code:m}:void 0,i[3]=m,i[4]=a):a=i[4],i[5]!==u||i[6]!==p||i[7]!==f||i[8]!==a?(s=(0,t.jsx)(rM,{command:u,stdout:p,stderr:f,outcome:a}),i[5]=u,i[6]=p,i[7]=f,i[8]=a,i[9]=s):s=i[9],i[10]!==d?(o=d?.files?.length?(0,t.jsx)(rA,{files:d.files,source:"tool_output"}):null,i[10]=d,i[11]=o):o=i[11],i[12]!==s||i[13]!==o?(l=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[s,o]}),i[12]=s,i[13]=o,i[14]=l):l=i[14],l},hasRichExpandedContent:e=>!!e.outputData?.bash},"openrouter:shell":{label:"Shell",icon:rp,iconClassName:"text-foreground",DescriptionComponent:function(e){let a,s,o,l,i,c,d,u,m=(0,r.c)(31),{outputData:p,isCompleted:f,isFailed:h,isIncomplete:x}=e,g=p?.shell,v=g?.commands;m[0]!==g?.output?(a=g?.output??[],m[0]=g?.output,m[1]=a):a=m[1];let b=a;m[2]!==b?(s=function(e){if(0===e.length)return;let t=0;for(let{outcome:r}of e){if("timeout"===r.type)return{kind:"timeout"};0!==r.exit_code&&(t=r.exit_code)}return{kind:"exit",code:t}}(b),m[2]=b,m[3]=s):s=m[3];let y=s,j=void 0!==y&&("timeout"===y.kind||0!==y.code),S=h||x||j,w=f||h||x,N=v?.[0],C=v?.length??b.length;if(w&&void 0!==g&&0===b.length&&!N){let e;return m[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,t.jsx)(rw,{toolName:rH}),(0,t.jsx)(rb,{})]}),m[4]=e):e=m[4],e}if(!N){let e,r,a,s,o,l;m[5]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(rw,{toolName:rH}),m[5]=e):e=m[5];let i=!w&&"text-muted-foreground";if(m[6]!==i?(r=(0,n.cn)("min-w-0 flex-1 truncate",i),m[6]=i,m[7]=r):r=m[7],m[8]!==S||m[9]!==f)a=S?"Shell failed":f?"Shell completed":"Running...",m[8]=S,m[9]=f,m[10]=a;else a=m[10];return m[11]!==r||m[12]!==a?(s=(0,t.jsx)("span",{className:r,children:a}),m[11]=r,m[12]=a,m[13]=s):s=m[13],m[14]!==y?(o=y&&(0,t.jsx)(rg,{className:"ml-auto",outcome:y}),m[14]=y,m[15]=o):o=m[15],m[16]!==s||m[17]!==o?(l=(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e,s,o]}),m[16]=s,m[17]=o,m[18]=l):l=m[18],l}return m[19]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(rw,{toolName:rH}),m[19]=o):o=m[19],m[20]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("span",{className:"select-none text-muted-foreground",children:"$ "}),m[20]=l):l=m[20],m[21]!==C?(i=C>1&&(0,t.jsxs)("span",{className:"ml-1 font-sans text-muted-foreground",children:[(0,t.jsx)(Q.DotSeparator,{})," ",C," commands"]}),m[21]=C,m[22]=i):i=m[22],m[23]!==N||m[24]!==i?(c=(0,t.jsxs)("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:[l,N,i]}),m[23]=N,m[24]=i,m[25]=c):c=m[25],m[26]!==y?(d=y&&(0,t.jsx)(rg,{className:"ml-auto",outcome:y}),m[26]=y,m[27]=d):d=m[27],m[28]!==c||m[29]!==d?(u=(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[o,c,d]}),m[28]=c,m[29]=d,m[30]=u):u=m[30],u},ExpandedComponent:function(e){let n,a,s,o,l=(0,r.c)(14),{data:i}=e,c=i.outputData?.shell;if(!c)return null;let{commands:d,output:u}=c;l[0]!==d?(n=void 0===d?[]:d,l[0]=d,l[1]=n):n=l[1];let m=n,p=Math.max(m.length,u.length);if(l[2]!==m||l[3]!==u||l[4]!==p){let e;l[6]!==m||l[7]!==u?(e=(e,r)=>{let n=u[r];return(0,t.jsx)(rM,{command:m[r],stdout:n?.stdout,stderr:n?.stderr,outcome:n?"timeout"===n.outcome.type?{kind:"timeout"}:{kind:"exit",code:n.outcome.exit_code}:void 0},r)},l[6]=m,l[7]=u,l[8]=e):e=l[8],a=Array.from({length:p},e),l[2]=m,l[3]=u,l[4]=p,l[5]=a}else a=l[5];return l[9]!==c.files?(s=c.files?.length?(0,t.jsx)(rA,{files:c.files,source:"tool_output"}):null,l[9]=c.files,l[10]=s):s=l[10],l[11]!==a||l[12]!==s?(o=(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[a,s]}),l[11]=a,l[12]=s,l[13]=o):o=l[13],o},hasRichExpandedContent:e=>(e.outputData?.shell?.output.length??0)>0}};var r1=e.i(60628);function r2(e){let n=(0,r.c)(2),{isIncomplete:a,isFailed:s,isInFlight:o}=e;if(s||a){let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(t9.TriangleAlert,{className:"size-3.5 shrink-0 text-warning"}),n[0]=e):e=n[0],e}if(o){let e;return n[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(r3,{}),n[1]=e):e=n[1],e}return null}function r3(){let e,n=(0,r.c)(1);return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)("span",{className:"inline-flex items-center gap-2 leading-7",children:[(0,t.jsx)("span",{className:"size-2 animate-scale-pulse rounded-full bg-current"}),(0,t.jsx)("span",{className:"size-2 animate-scale-pulse rounded-full bg-current delay-150"}),(0,t.jsx)("span",{className:"size-2 animate-scale-pulse rounded-full bg-current delay-300"})]}),n[0]=e):e=n[0],e}function r5({itemId:e}){var r,a;let o=(0,ef.useItemStore)(t=>(0,v.selectServerToolOutputData)(t,e)),c=(0,s.useMemo)(l.makeSelectServerToolEnginesByMessageId,[]),d=(0,i.useChatroomStore)(e=>o?.messageId?c(e,o.messageId):null),m=(0,s.useMemo)(l.makeSelectFusionRespondingModelByMessageId,[]),p=(0,i.useChatroomStore)(e=>o?.toolName==="openrouter:fusion"&&o?.messageId?m(e,o.messageId):void 0),[f,h]=(0,s.useState)(!1),x=ta(o?.arguments??"",o?.status);if(!o)return null;let g=(r=o.toolName,(0,rs.isMember)(r,e4.SERVER_TOOL_NAMES)?r0[r]:null),b=g?.icon??re.Wrench,y=g?.label??((a=o.toolName).startsWith(r1.OPENROUTER_TOOL_PREFIX)?a.slice(r1.OPENROUTER_TOOL_PREFIX.length):a).replace(/^experimental__/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),j="completed"===o.status,S="incomplete"===o.status,w="failed"===o.status,N=o.arguments,C=function(e,t){if(t){if("openrouter:web_search"===e)return t.webSearchEngine;if("openrouter:web_fetch"===e)return t.webFetchEngine}}(o.toolName,d),I="openrouter:advisor"===o.toolName?function(e){let t=e.resultModel?.trim();if(t)return t;let r=rn(e.args);if(r?.model)return r.model;let n=e.snapshot?.advisor;if(n?.advisors?.length===1){let[e]=n.advisors;if(e?.model)return e.model}return n?.model}({args:N,resultModel:o.outputData?.advisor?.model,snapshot:d}):void 0,_=g?.DescriptionComponent,k=_?(0,t.jsx)(_,{args:N,outputData:o.outputData,isCompleted:j,isFailed:w,isIncomplete:S,engine:C,advisorModelSlug:I,fusionRespondingModel:p}):null,A=g?.MetadataComponent,M=A?(0,t.jsx)(A,{outputData:o.outputData,isCompleted:j,isFailed:w,isIncomplete:S}):null,T=g?.ExpandedComponent,E=g?.hasRichExpandedContent?.(o)??!1,R=!!T&&E,z=!g?.disableExpand&&(!!x||R),O="openrouter:image_generation"===o.itemType,F=z?(0,t.jsxs)("span",{className:"relative size-3.5 shrink-0","aria-hidden":"true",children:[(0,t.jsx)(b,{className:(0,n.cn)("absolute inset-0 size-3.5 text-muted-foreground transition-opacity duration-150",g?.iconClassName,f?"opacity-0":"opacity-100 group-hover/chip:opacity-0")}),(0,t.jsx)(e8.ChevronRight,{className:(0,n.cn)("absolute inset-0 m-auto size-3 text-muted-foreground transition-[opacity,transform] duration-150",f?"rotate-90 opacity-100":"opacity-0 group-hover/chip:opacity-100")})]}):(0,t.jsx)(b,{className:(0,n.cn)("size-3.5 shrink-0 text-muted-foreground",g?.iconClassName)}),D=(0,t.jsxs)(t.Fragment,{children:[F,(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-left text-sm text-foreground",children:k??y}),M,!g?.hideStatusIndicator&&(0,t.jsx)(r2,{isIncomplete:S,isFailed:w,isInFlight:!j&&!w&&!S})]}),L=(0,n.cn)("group/chip h-auto w-full justify-start gap-2 rounded-none px-3 py-2 text-left whitespace-normal",z&&"cursor-pointer hover:bg-muted");return(0,t.jsxs)("div",{className:"w-full ph-no-capture","data-dd-privacy":"hidden",children:[(0,t.jsxs)("div",{className:"overflow-hidden rounded-md border border-border bg-card",children:[z?(0,t.jsx)(u.Button,{variant:"ghost",size:"sm","aria-expanded":f,className:L,onClick:()=>{let e=!f;h(e),(0,ep.trackToolChipExpand)({tool:o.toolName,expanded:e})},children:D}):(0,t.jsx)("div",{className:(0,n.cn)(L,"flex items-center"),children:D}),f&&z&&(0,t.jsx)("div",{className:"max-h-64 overflow-y-auto border-t border-border px-3 py-2 text-xs",children:R&&T?(0,t.jsx)(T,{data:o,engine:C,advisorModelSlug:I}):(0,t.jsx)(e7.CodeBlock,{language:"json",value:x})})]}),O&&(0,t.jsx)(r4,{itemId:e,isCompleted:j})]})}function r4(e){let n,a,s,o,l,i,c,d=(0,r.c)(17),{itemId:m,isCompleted:p}=e;d[0]!==m?(n=e=>(0,v.selectServerToolImageUrl)(e,m),d[0]=m,d[1]=n):n=d[1];let f=(0,ef.useItemStore)(n);if(!f){if(!p){let e;return d[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(r6,{}),d[2]=e):e=d[2],e}return null}d[3]!==f?(a={url:f,name:"Generated Image"},d[3]=f,d[4]=a):a=d[4];let h=a;return d[5]!==h?(s=[h],d[5]=h,d[6]=s):s=d[6],d[7]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(u.Button,{size:"icon-sm",variant:"outline",className:"absolute bottom-1 right-1 z-10 opacity-0 group-hover:opacity-100","aria-label":"Expand image",children:(0,t.jsx)(t8.Expand,{className:"text-foreground size-4"})}),d[7]=o):o=d[7],d[8]!==h.name||d[9]!==h.url?(l=(0,t.jsx)("picture",{className:"flex shrink-0 cursor-pointer",children:(0,t.jsx)("img",{alt:h.name,className:"aspect-auto h-96 max-w-xl overflow-hidden rounded-lg border object-cover",src:h.url})}),d[8]=h.name,d[9]=h.url,d[10]=l):l=d[10],d[11]!==s||d[12]!==l?(i=(0,t.jsx)("div",{className:"group relative flex shrink-0",children:(0,t.jsxs)(tc.ImagePreviewDialog,{images:s,initialIndex:0,children:[o,l]})}),d[11]=s,d[12]=l,d[13]=i):i=d[13],d[14]!==f||d[15]!==i?(c=(0,t.jsx)("div",{className:"mt-2 shrink-0 duration-200 animate-in fade-in slide-in-from-left-8",children:i},f),d[14]=f,d[15]=i,d[16]=c):c=d[16],c}function r6(){let e,n=(0,r.c)(1);return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)("div",{className:"mt-2 flex h-96 w-96 max-w-xl flex-col items-center justify-center gap-3 rounded-lg border bg-muted",children:[(0,t.jsx)("svg",{className:"size-10 text-muted-foreground","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 20 18",children:(0,t.jsx)("path",{d:"M18 0H2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm4.376 10.481A1 1 0 0 1 16 15H4a1 1 0 0 1-.895-1.447l3.5-7A1 1 0 0 1 7.468 6a.965.965 0 0 1 .9.5l2.775 4.757 1.546-1.887a1 1 0 0 1 1.618.1l2.541 4a1 1 0 0 1 .028 1.011Z"})}),(0,t.jsx)(ti.ProcessingIndicator,{label:"Generating image"})]}),n[0]=e):e=n[0],e}function r7(e){let n,a=(0,r.c)(24),{itemId:s,messageId:o}=e;a[0]!==s?(n=e=>(0,v.selectItemById)(e,s),a[0]=s,a[1]=n):n=a[1];let l=(0,ef.useItemStore)(n),i=l?.data.type;if(!l||!i)return null;switch(i){case"message":{let e;return a[2]!==s||a[3]!==o?(e=(0,t.jsx)(tA,{itemId:s,messageId:o}),a[2]=s,a[3]=o,a[4]=e):e=a[4],e}case"reasoning":{let e;return a[5]!==s||a[6]!==o?(e=(0,t.jsx)(tz,{itemId:s,messageId:o}),a[5]=s,a[6]=o,a[7]=e):e=a[7],e}case"function_call":{let e;return a[8]!==s?(e=(0,t.jsx)(r9,{itemId:s}),a[8]=s,a[9]=e):e=a[9],e}case"web_search_call":{let e;return a[10]!==s?(e=(0,t.jsx)(r5,{itemId:s}),a[10]=s,a[11]=e):e=a[11],e}case"file_search_call":{let e;return a[12]!==s?(e=(0,t.jsx)(e6,{itemId:s}),a[12]=s,a[13]=e):e=a[13],e}case"image_generation_call":{let e;return a[14]!==s?(e=(0,t.jsx)(tu,{itemId:s}),a[14]=s,a[15]=e):e=a[15],e}case"video_generation_call":{let e;return a[16]!==s?(e=(0,t.jsx)(t2,{itemId:s}),a[16]=s,a[17]=e):e=a[17],e}case"function_call_output":return null;case"shell_call_output":{let e;return a[18]!==s?(e=(0,t.jsx)(r5,{itemId:s}),a[18]=s,a[19]=e):e=a[19],e}case"shell_call":{let e;return a[20]!==s?(e=(0,t.jsx)(r8,{itemId:s}),a[20]=s,a[21]=e):e=a[21],e}default:if((0,e4.isOpenRouterTool)(i)){let e;return a[22]!==s?(e=(0,t.jsx)(r5,{itemId:s}),a[22]=s,a[23]=e):e=a[23],e}return null}}function r8(e){let n,a,s=(0,r.c)(4),{itemId:o}=e;s[0]!==o?(n=e=>(0,v.selectServerToolOutputData)(e,o),s[0]=o,s[1]=n):n=s[1];let l=(0,ef.useItemStore)(n);return l&&"completed"!==l.status?(s[2]!==o?(a=(0,t.jsx)(r5,{itemId:o}),s[2]=o,s[3]=a):a=s[3],a):null}function r9({itemId:e}){let r=(0,s.useMemo)(v.makeSelectIsServerToolFunctionCall,[]);return(0,ef.useItemStore)(t=>r(t,e))?(0,t.jsx)(r5,{itemId:e}):(0,t.jsx)(ts,{itemId:e})}let ne=({messageId:e})=>{let r,a,[w,N]=(0,s.useState)(!1),{getModelInfoByVariantSlug:C,getModelInfoByVariantPermaslug:M}=(0,f.useGlobal)(),T=(0,s.useCallback)(e=>{if((0,x.isChromeGeminiNanoModelSlug)(e))return(0,x.getChromeGeminiNanoModelInfo)();let t=C(e)??M(e);if(!t)return null;let r=t.endpoint?{...t.endpoint,model:{...t.endpoint.model,default_stops:[...t.endpoint.model.default_stops]}}:null;return{...t,default_stops:[...t.default_stops],endpoint:r}},[C,M]),E=(0,s.useMemo)(l.makeSelectMessageById,[]),R=(0,s.useMemo)(l.makeSelectDisplayCharacterByMessageId,[]),z=(0,s.useMemo)(g.makeSelectCharacterById,[]),O=(0,s.useMemo)(v.makeSelectSortedItemsByMessageId,[]),F=(0,i.useChatroomStore)(t=>E(t,e)),D=(0,i.useChatroomStore)(t=>R(t,e,T)),L=(0,i.useChatroomStore)(e=>F?.type===o.MessageType.Assistant&&F.characterId?z(e,F.characterId):null),P=(0,i.useChatroomStore)(t=>O(t,e)),B=F?.createdAt,V=w?(0,b.getPrimaryMessageItemId)(e):null,$=(0,y.useModelColor)((0,y.getModelColorKey)(L??D)),H=function(e){let{message:t,isEditing:r,itemCount:n}=e;return t?.type!==o.MessageType.Assistant||r||n>0||t.contentType===o.ContentType.Artifact||t.contentType===o.ContentType.ArtifactVersion?null:t.isGenerating||t.isRetrying?ed:"notice"}({message:F,isEditing:w,itemCount:P.length}),U=H===ed?(0,t.jsx)(t_,{}):(0,t.jsx)(tk,{}),G=(0,t.jsx)("div",{className:"flex w-full flex-col items-start gap-3",children:w&&V?(0,t.jsx)(eQ,{messageId:e,itemId:V,onCancel:()=>N(!1),className:"w-full",align:"start"}):(0,t.jsxs)(t.Fragment,{children:[null===H?(0,t.jsx)(nt,{message:F,sortedItems:P}):U,(0,t.jsx)(e_,{messageId:e})]})}),q=D.modelInfo?.short_name??D.modelInfo?.name??D.name??null,W=D.name&&D.name!==q?D.name:null,K=F?.type===o.MessageType.Assistant?F.metadata?.internModel:void 0,Z=(0,y.getMessageColorOption)($),Y=D.isRemoved??!1,X=null!==Z&&!Y;return(0,t.jsxs)("div",{"data-testid":"assistant-message",className:(0,n.cn)("group relative flex w-full flex-col gap-1","slide-in-from-left-12"),children:[(0,t.jsx)("div",{className:(0,n.cn)("flex w-full flex-col gap-3 md:gap-2","bg-popover px-2","md:rounded-xl md:border md:border-slate-4 md:px-4 md:pt-3 md:pb-4 md:dark:border-slate-5"),children:(0,t.jsx)(J,{title:q??D.name??"Response",float:!0,header:(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-slate-4 pb-2.5 dark:border-slate-5 md:pb-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,t.jsxs)("div",{className:(0,n.cn)("flex min-w-0 items-center gap-2 rounded-md px-1.5 py-0 md:py-1",X&&Z?.pillBg),children:[(0,t.jsx)("div",{className:"flex size-4 shrink-0 items-center justify-center md:size-5",children:D.modelInfo?.author?(0,t.jsx)(m.AuthorIcon,{frame:!0,author:D.modelInfo.author,iconUri:D.modelInfo.author_icon_uri,className:"size-4 md:size-5"}):(0,t.jsx)(nr,{character:D})}),q?(0,t.jsx)("span",{className:(0,n.cn)("truncate text-sm font-semibold leading-4 text-foreground md:leading-5",Y&&"font-normal italic text-muted-foreground"),children:q}):null,K?(0,t.jsxs)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",title:`This turn ran on ${K}`,children:["via ",K]}):null]}),W?(0,t.jsx)(I.NicknameTag,{nickname:W,className:(0,n.cn)("min-w-0 truncate text-xs leading-none",Y&&"italic opacity-70")}):null,Y?(0,t.jsx)("button",{type:"button",onClick:()=>{let e=(0,j.getCurrentRoomId)(),t=F?.type===o.MessageType.Assistant?F.characterId:void 0;e&&t&&S.chatroomStoreActions.restoreCharacter({payload:{roomId:e,characterId:t}})},className:"shrink-0 text-sm text-link hover:underline",children:"Restore"}):null]}),(0,t.jsx)(k.ActionItem,{icon:(0,t.jsx)(c.ArrowDownIcon,{}),tooltip:"Scroll to bottom",onClick:()=>(0,A.scrollMessageToEdge)(e,"end"),className:"size-7 shrink-0 rounded-full text-muted-foreground md:mr-9"})]}),children:G})}),(0,t.jsxs)("div",{className:"flex items-center px-1 max-md:px-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-0.5 [&_button]:h-7 [&_button]:w-7 [&_button]:rounded-full",children:[(0,t.jsx)(_.MessageActions,{messageId:e,setIsEditing:N,primaryOnly:!0,hideEdit:(r=P.some(e=>void 0!==e.type&&eu.has(e.type)),a=P.some(e=>"message"===e.type),r&&!a),hideScrollToTop:!0}),(0,t.jsxs)(p.Popover,{children:[(0,t.jsx)(p.PopoverTrigger,{render:(0,t.jsx)(u.Button,{variant:"ghost",size:"icon","aria-label":"More actions",className:"h-7 w-7 shrink-0 p-1 text-muted-foreground",children:(0,t.jsx)(h.EllipsisVertical,{className:"h-4 w-4"})})}),(0,t.jsxs)(p.PopoverContent,{align:"start",side:"top",className:"w-52 p-1",children:[B?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e5,{createdAt:B}),(0,t.jsx)("div",{className:"my-1 h-px bg-border/60"})]}):null,(0,t.jsx)(_.MessageActions,{messageId:e,setIsEditing:N,hideRetry:!0,hideCopy:!0,hideEdit:!0,hideDelete:!0,hideScrollToTop:!0,orientation:"vertical",showLabels:!0})]})]}),(0,t.jsx)("div",{className:"mx-1 h-5 w-px bg-border/60","aria-hidden":"true"}),(0,t.jsx)(k.ActionItem,{icon:(0,t.jsx)(d.ArrowUpIcon,{}),tooltip:"Scroll to top",onClick:()=>(0,A.scrollMessageToEdge)(e,"start")})]}),(0,t.jsx)(ec,{messageId:e,className:"ml-auto min-w-0 pl-2"})]})]})},nt=(0,s.memo)(e=>{let n,s=(0,r.c)(25),{message:l,sortedItems:i}=e;s[0]!==l?(n=l?.type===o.MessageType.Assistant?l:{contentType:void 0,id:"",artifactId:void 0,versionContextId:void 0},s[0]=l,s[1]=n):n=s[1];let{contentType:c,id:d,artifactId:u,versionContextId:m}=n;if(!l||l.type!==o.MessageType.Assistant)return null;switch(c){case o.ContentType.Artifact:{let e;if(!u)return null;return s[2]!==u?(e=(0,t.jsx)(w.ArtifactMessageCard,{artifactId:u}),s[2]=u,s[3]=e):e=s[3],e}case o.ContentType.ArtifactVersion:{let e,r,n;if(!m||!u)return null;if(s[4]!==d||s[5]!==i){let r,n=i.filter(nn);s[7]!==d?(r=e=>(0,t.jsx)(r7,{itemId:e.id,messageId:d},e.id),s[7]=d,s[8]=r):r=s[8],e=n.map(r),s[4]=d,s[5]=i,s[6]=e}else e=s[6];return s[9]!==u||s[10]!==m?(r=(0,t.jsx)(N.VersionMessageCard,{artifactId:u,versionId:m}),s[9]=u,s[10]=m,s[11]=r):r=s[11],s[12]!==e||s[13]!==r?(n=(0,t.jsxs)(t.Fragment,{children:[e,r]}),s[12]=e,s[13]=r,s[14]=n):n=s[14],n}case o.ContentType.Text:case void 0:{let e,r,n;if(s[15]!==d||s[16]!==i){let r;s[18]!==d?(r=e=>(0,t.jsx)(r7,{itemId:e.id,messageId:d},e.id),s[18]=d,s[19]=r):r=s[19],e=i.map(r),s[15]=d,s[16]=i,s[17]=e}else e=s[17];return s[20]!==i?(r=i.filter(na).map(ns),s[20]=i,s[21]=r):r=s[21],s[22]!==e||s[23]!==r?(n=(0,t.jsxs)(t.Fragment,{children:[e,r]}),s[22]=e,s[23]=r,s[24]=n):n=s[24],n}default:(0,a.assertNever)(c)}});function nr(e){let n,a=(0,r.c)(4),{character:s}=e,o=s.modelInfo;if(!o){let e;return a[0]!==s?(e=(0,t.jsx)(C.ChatroomCharacterAvatar,{character:s}),a[0]=s,a[1]=e):e=a[1],e}return a[2]!==o?(n=(0,t.jsx)(C.ChatroomCharacterAvatar,{character:{modelInfo:o}}),a[2]=o,a[3]=n):n=a[3],n}function nn(e){return"reasoning"===e.type}function na(e){return"message"===e.type}function ns(e){return(0,t.jsx)(ej,{itemId:e.id},e.id)}let no=({messageId:e})=>{let r=(0,s.useMemo)(l.makeSelectMessageById,[]),a=(0,i.useChatroomStore)(t=>r(t,e)),c=a?.type===o.MessageType.System?a.items??[]:[],d=(0,ef.useItemStore)(e=>c.flatMap(t=>(0,v.selectContentPartsFromItem)(e,t.id)).filter(e=>"input_text"===e.type).map(e=>e.text).join(""));return d?(0,t.jsxs)("div",{"data-testid":"system-message",className:(0,n.cn)("group my-2 flex w-full flex-col items-start gap-2 md:my-0"),children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:"System"}),(0,t.jsx)("div",{className:(0,n.cn)("py-3 px-4 font-normal relative rounded-lg w-full","border border-border bg-muted text-foreground"),children:(0,t.jsx)(tx.ChatroomMarkdownContainer,{shouldRenderRawHtml:!1,children:d})})]}):null};var nl=e.i(871068),ni=e.i(117738);e.i(530023);var nc=e.i(612774);let nd=({messageId:e})=>{let[r,a]=(0,s.useState)(!1),[c,m]=(0,s.useState)(null),p=(0,s.useRef)(null),f=(0,s.useMemo)(l.makeSelectMessageById,[]),x=(0,i.useChatroomStore)(t=>f(t,e)),g=x?.createdAt,v=x?.type===o.MessageType.User?x.items??[]:[],y=r?(0,b.getPrimaryMessageItemId)(e):null,w=r&&y?((e,t,r)=>{switch(e?.contentType){case o.ContentType.Artifact:return e=>{let n=(0,j.getCurrentRoomId)();n&&S.chatroomStoreActions.editItem({payload:{roomId:n,messageId:t,itemId:r,newContent:e,opts:{retry:!0}}})};case o.ContentType.ArtifactVersion:return n=>{let a=(0,j.getCurrentRoomId)(),s=e?.artifactId,o=e?.versionContextId;a&&e&&s?(S.chatroomStoreActions.editItem({payload:{roomId:a,messageId:t,itemId:r,newContent:n}}),S.chatroomStoreActions.sendGenerationPromptToArtifact({payload:{roomId:a,artifactId:s,prompt:n,parentVersionId:o}})):(0,nc.toast)({title:"Error",description:"Artifact context not found, cannot regenerate version.",variant:"destructive"})};case o.ContentType.Text:default:return e=>{let n=(0,j.getCurrentRoomId)();n&&S.chatroomStoreActions.editItem({payload:{roomId:n,messageId:t,itemId:r,newContent:e,opts:{retry:!0}}})}}})(x,e,y):void 0,N=(0,s.useCallback)(e=>{if(!0===e){let e=p.current?.querySelector('[data-message-bubble="user"]');m(e?{widthPx:e.offsetWidth,heightPx:e.offsetHeight}:null)}else m(null);a(e)},[]),C=r&&y?(0,t.jsx)(eQ,{messageId:e,itemId:y,onCancel:()=>N(!1),lockedWidthPx:c?.widthPx??null,lockedHeightPx:c?.heightPx??null,onSaveAndRetry:w}):v.map(r=>(0,t.jsx)(r7,{itemId:r.id,messageId:e},r.id));return(0,t.jsxs)("div",{ref:p,"data-testid":"user-message",className:(0,n.cn)("group flex w-full flex-col items-end gap-1","slide-in-from-right-12"),children:[(0,t.jsxs)("div",{className:"flex w-full items-end justify-end gap-2",children:[(0,t.jsx)("div",{className:"flex min-w-0 flex-col items-end gap-2",children:C}),(0,t.jsx)("div",{className:"mb-0.5 shrink-0",children:(0,t.jsx)(nu,{})})]}),(0,t.jsxs)("div",{className:(0,n.cn)("flex items-center justify-end gap-0.5 pr-9","[&_button]:h-7 [&_button]:w-7 [&_button]:rounded-full","opacity-100 pointer-events-auto",r&&"invisible"),children:[(0,t.jsx)(_.MessageActions,{messageId:e,setIsEditing:N,isCompact:!0,hideCopyCode:!0,hideScrollToTop:!0}),x?.contentType!==o.ContentType.Artifact&&(0,t.jsxs)(nl.Popover,{children:[(0,t.jsx)(nl.PopoverTrigger,{render:(0,t.jsx)(u.Button,{variant:"ghost",size:"icon","aria-label":"More actions",className:"h-7 w-7 shrink-0 p-1 text-muted-foreground",children:(0,t.jsx)(h.EllipsisVertical,{className:"h-4 w-4"})})}),(0,t.jsxs)(nl.PopoverContent,{align:"end",side:"top",className:"w-52 p-1",children:[g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e5,{createdAt:g}),(0,t.jsx)("div",{className:"my-1 h-px bg-border/60"})]}):null,(0,t.jsx)(_.MessageActions,{messageId:e,setIsEditing:N,hideRetry:!0,hideCopy:!0,hideEdit:!0,hideDelete:!0,hideScrollToTop:!0,orientation:"vertical",showLabels:!0})]})]}),(0,t.jsx)("div",{className:"mx-1 h-5 w-px bg-border/60","aria-hidden":"true"}),(0,t.jsx)(k.ActionItem,{icon:(0,t.jsx)(d.ArrowUpIcon,{}),tooltip:"Scroll to top",onClick:()=>(0,A.scrollMessageToEdge)(e,"start")})]})]})};function nu(){let e,n=(0,r.c)(3),{entity:a}=(0,ni.useEntity)(),s=a.data?.image_url??void 0,o=a.data?.first_name||"";return n[0]!==s||n[1]!==o?(e=(0,t.jsx)(C.ChatroomCharacterAvatar,{character:{avatarUrl:s,name:o}}),n[0]=s,n[1]=o,n[2]=e):e=n[2],e}let nm=e=>{let n=(0,r.c)(7),{messageId:s,type:l,inGroup:i}=e;switch(l){case o.MessageType.User:{let e;return n[0]!==s?(e=(0,t.jsx)(nd,{messageId:s}),n[0]=s,n[1]=e):e=n[1],e}case o.MessageType.Assistant:{let e;return n[2]!==i||n[3]!==s?(e=(0,t.jsx)(ne,{messageId:s,inGroup:i}),n[2]=i,n[3]=s,n[4]=e):e=n[4],e}case o.MessageType.System:{let e;return n[5]!==s?(e=(0,t.jsx)(no,{messageId:s}),n[5]=s,n[6]=e):e=n[6],e}default:(0,a.assertNever)(l)}},np=e=>{let a,s,l,i,c,d=(0,r.c)(18),{messageId:u,messageType:m,characterIsDisabled:p,inGroup:f}=e,h=void 0!==f&&f;if(!m||m===o.MessageType.Assistant&&p)return null;let x=m===o.MessageType.Assistant,g=x?"max-w-[68rem]":"max-w-5xl";if(d[0]!==x||d[1]!==g||d[2]!==m){let e,t=function(e){if(e!==o.MessageType.Assistant)return"overflow-hidden"}(m);d[5]!==m?(e=function(e){if(e!==o.MessageType.Assistant)return"style"}(m),d[5]=m,d[6]=e):e=d[6],a=e,s=(0,n.cn)("w-full rounded-md mx-auto",t,g,"transition-colors duration-500 ease-in-out",!x&&"px-2 md:px-3","scroll-mt-3",x&&"scroll-mb-[var(--composer-clearance,8rem)]"),d[0]=x,d[1]=g,d[2]=m,d[3]=a,d[4]=s}else a=d[3],s=d[4];return d[7]!==a?(l={contain:a},d[7]=a,d[8]=l):l=d[8],d[9]!==h||d[10]!==u||d[11]!==m?(i=(0,t.jsx)(nm,{messageId:u,type:m,inGroup:h}),d[9]=h,d[10]=u,d[11]=m,d[12]=i):i=d[12],d[13]!==u||d[14]!==s||d[15]!==l||d[16]!==i?(c=(0,t.jsx)("div",{className:s,style:l,"data-message-id":u,children:i}),d[13]=u,d[14]=s,d[15]=l,d[16]=i,d[17]=c):c=d[17],c},nf=(0,s.memo)(({messageId:e,inGroup:r=!1})=>{let n=(0,s.useMemo)(l.makeSelectMessageById,[]),a=(0,s.useMemo)(l.makeSelectCharacterIsDisabled,[]),o=(0,i.useChatroomStore)(t=>n(t,e)),c=(0,i.useChatroomStore)(t=>a(t,e));return(0,t.jsx)(np,{messageId:e,messageType:o?.type??null,characterIsDisabled:c??!1,inGroup:r})},(e,t)=>e.messageId===t.messageId&&e.inGroup===t.inGroup);e.s(["MessageListItem",0,nf],216294)},219328,136004,e=>{"use strict";var t=e.i(222666),r=e.i(505962),n=e.i(452473),a=e.i(270401),s=e.i(860658),o=e.i(767150),l=e.i(729987),i=e.i(250855),c=e.i(624621),d=e.i(691038),u=e.i(570115),m=e.i(511410),p=e.i(216294),f=e.i(780367);function h(e){let a,s,o,l,i,c,d,u=(0,r.c)(19),{ids:h}=e,{ref:x,canScrollStart:g,canScrollEnd:v}=(0,m.useScrollFade)("x");if(u[0]!==h){let e;u[2]!==h.length?(e=(e,r)=>(0,t.jsx)("div",{className:(0,n.cn)("min-w-[400px] flex-1 basis-0","animate-in fade-in slide-in-from-left-3 fill-mode-both duration-300 ease-out"),style:{animationDelay:`${60*r}ms`},children:(0,t.jsx)(f.ScrollCapProvider,{value:h.length>1,children:(0,t.jsx)(p.MessageListItem,{messageId:e})})},e),u[2]=h.length,u[3]=e):e=u[3],a=h.map(e),u[0]=h,u[1]=a}else a=u[1];u[4]!==x||u[5]!==a?(s=(0,t.jsx)("div",{ref:x,className:"flex w-full flex-row gap-2 overflow-x-auto overflow-y-hidden overscroll-x-contain pb-2",children:a}),u[4]=x,u[5]=a,u[6]=s):s=u[6];let b=g?"opacity-100":"opacity-0";u[7]!==b?(o=(0,n.cn)("pointer-events-none absolute inset-y-0 left-0 w-10","bg-gradient-to-r from-background to-transparent","transition-opacity duration-150",b),u[7]=b,u[8]=o):o=u[8],u[9]!==o?(l=(0,t.jsx)("div",{"aria-hidden":"true",className:o}),u[9]=o,u[10]=l):l=u[10];let y=v?"opacity-100":"opacity-0";return u[11]!==y?(i=(0,n.cn)("pointer-events-none absolute inset-y-0 right-0 w-10","bg-gradient-to-l from-background to-transparent","transition-opacity duration-150",y),u[11]=y,u[12]=i):i=u[12],u[13]!==i?(c=(0,t.jsx)("div",{"aria-hidden":"true",className:i}),u[13]=i,u[14]=c):c=u[14],u[15]!==s||u[16]!==l||u[17]!==c?(d=(0,t.jsxs)("div",{className:"relative w-full",children:[s,l,c]}),u[15]=s,u[16]=l,u[17]=c,u[18]=d):d=u[18],d}function x(e){let n,a,s=(0,r.c)(8),{ids:o}=e,l=(0,u.useResponsesLayoutStore)(v),i=(0,d.useMediaMd)();if(o.length<=1){let e,[r]=o;return s[0]!==r?(e=r?(0,t.jsx)("div",{className:"mx-auto w-full max-w-5xl",children:(0,t.jsx)(p.MessageListItem,{messageId:r})}):null,s[0]=r,s[1]=e):e=s[1],e}if(l===u.ResponsesLayout.Fanned&&i){let e;return s[2]!==o?(e=(0,t.jsx)(h,{ids:o}),s[2]=o,s[3]=e):e=s[3],e}return s[4]!==o?(n=o.map(g),s[4]=o,s[5]=n):n=s[5],s[6]!==n?(a=(0,t.jsx)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4",children:n}),s[6]=n,s[7]=a):a=s[7],a}function g(e){return(0,t.jsx)("div",{children:(0,t.jsx)(p.MessageListItem,{messageId:e,inGroup:!0})},e)}function v(e){return e.layout}function b(e){let n,a,s,o,l=(0,r.c)(10),{children:i,bubbleColor:c,textColor:d}=e;l[0]!==c?(n=c&&{"--bubble-color":c},l[0]=c,l[1]=n):n=l[1],l[2]!==d?(a=d&&{"--bubble-text-color":d},l[2]=d,l[3]=a):a=l[3],l[4]!==n||l[5]!==a?(s={display:"contents",...n,...a},l[4]=n,l[5]=a,l[6]=s):s=l[6];let u=s;return l[7]!==i||l[8]!==u?(o=(0,t.jsx)("div",{"data-testid":"chat-bubble-color-scope",style:u,children:i}),l[7]=i,l[8]=u,l[9]=o):o=l[9],o}let y=new WeakMap,j=new WeakMap;function S(e,t,r){0!==r&&e.getBoundingClientRect().top{let e=c.current;if(!e)return;let t=e.closest("[data-scroll-container]"),r=t instanceof HTMLElement?function(e){if("u"{for(let t of e)y.get(t.target)?.handleRenderEntry(t)},{root:e,rootMargin:"200% 0px"}),retainObserver:new IntersectionObserver(e=>{for(let t of e)y.get(t.target)?.handleRetainEntry(t)},{root:e,rootMargin:"300% 0px"})};return j.set(e,r),r}(t):null;return t instanceof HTMLElement&&r?(y.set(e,{handleRenderEntry:r=>{if(r.isIntersecting){if(!d.current)return void i(!0);if("auto"===e.style.contentVisibility){let r=e.offsetHeight;e.style.contentVisibility="",e.style.boxSizing="",e.style.height="",e.style.containIntrinsicSize="",S(e,t,e.offsetHeight-r)}}},handleRetainEntry:t=>{var r;!t.isIntersecting&&d.current&&"auto"!==e.style.contentVisibility&&((r=t.boundingClientRect.height)>0&&(e.style.boxSizing="border-box",e.style.height=`${r}px`),e.style.contentVisibility="auto")}}),r.renderObserver.observe(e),r.retainObserver.observe(e),()=>{r.renderObserver.unobserve(e),r.retainObserver.unobserve(e),y.delete(e)}):void i(!0)},[]),(0,a.useLayoutEffect)(()=>{let t=c.current;if(!t)return;if(!l){u.current=!0;return}if(!u.current)return;let r=t.closest("[data-scroll-container]");r instanceof HTMLElement&&S(t,r,t.offsetHeight-e)},[l]),(0,t.jsx)("div",{ref:c,className:s,"data-lazy-ids":n.join(" "),style:l?void 0:{height:e},children:l?o:null})}let N=["bg-accent","dark:bg-accent/50"];function C(e,t){let r=e.querySelector(`[data-message-id="${t}"]`);return!!r&&(r.scrollIntoView({behavior:"instant",block:"center"}),r.classList.add(...N),setTimeout(()=>{r.isConnected&&r.classList.remove(...N)},800),!0)}function I(e,t){if(C(e,t))return;let r=e.querySelector(`[data-lazy-ids~="${CSS.escape(t)}"]`);r&&(r.scrollIntoView({behavior:"instant",block:"center"}),function e(t,r,n){requestAnimationFrame(()=>{!C(t,r)&&n>0&&e(t,r,n-1)})}(e,t,30))}e.s(["LAZY_MOUNT_RETRY_FRAMES",0,30,"scrollToMessage",0,I],136004);let _=(0,a.memo)(e=>{let d,u,m,f,h,g,v,y,j=(0,r.c)(16),{ref:S}=e,N=(0,a.useRef)(null),C=(0,a.useRef)(null),_=(0,c.useChatroomStore)(i.selectVisibleMessageBlocks),[k]=(0,s.useChatBubbleColor)();j[0]!==k?(d=k?(0,o.getTextColorForBackground)(k):void 0,j[0]=k,j[1]=d):d=j[1];let A=d;if(j[2]===Symbol.for("react.memo_cache_sentinel")?(u={scrollContainerRef:N,contentRef:C,initialStick:!0},j[2]=u):u=j[2],(0,l.useAutoScroll)(u),j[3]===Symbol.for("react.memo_cache_sentinel")?(m=()=>({scrollToMessage(e){let t=C.current;t&&I(t,e)}}),j[3]=m):m=j[3],(0,a.useImperativeHandle)(S,m),j[4]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.cn)("flex-1 min-h-0 w-full overflow-y-auto relative","overscroll-behavior-y-contain overscroll-x-none","[overflow-anchor:none]"),j[4]=f):f=j[4],j[5]===Symbol.for("react.memo_cache_sentinel")?(h=(0,n.cn)("flex flex-col items-center w-full duration-200 animate-in fade-in","gap-0.5 my-2 md:my-3","pb-[var(--composer-clearance,8rem)]"),j[5]=h):h=j[5],j[6]!==_){let e;j[8]!==_.length?(e=(e,r)=>"standalone"===e.kind?(0,t.jsx)(w,{eager:r>=_.length-8,estimatePx:120,messageIds:[e.id],className:"w-full scroll-mt-4 py-1.5",children:(0,t.jsx)(p.MessageListItem,{messageId:e.id})},e.id):(0,t.jsx)(w,{eager:r>=_.length-8,estimatePx:600*e.ids.length,messageIds:e.ids,className:"w-full scroll-mt-4 pb-2 md:px-6",children:(0,t.jsx)(x,{ids:e.ids})},`group:${e.ids.join(":")}`),j[8]=_.length,j[9]=e):e=j[9],g=_.map(e),j[6]=_,j[7]=g}else g=j[7];return j[10]!==g?(v=(0,t.jsx)("div",{ref:N,"data-testid":"message-list-scroll","data-scroll-container":"true",className:f,children:(0,t.jsx)("div",{ref:C,"data-testid":"message-list-content",children:(0,t.jsx)("div",{className:h,children:g})})}),j[10]=g,j[11]=v):v=j[11],j[12]!==k||j[13]!==v||j[14]!==A?(y=(0,t.jsx)(b,{bubbleColor:k,textColor:A,children:v}),j[12]=k,j[13]=v,j[14]=A,j[15]=y):y=j[15],y},()=>!0);e.s(["MessageListMemo",0,_],219328)},362942,649301,907781,329343,e=>{"use strict";var t=e.i(222666),r=e.i(505962),n=e.i(528164),a=e.i(57965),s=e.i(270401),o=e.i(649896),l=e.i(797913),i=e.i(936927),c=e.i(649188),d=e.i(543019),u=e.i(452473),m=e.i(22422),p=e.i(612960),f=e.i(120612);function h(e){let a,s,o,l,i,c,d,u=(0,r.c)(19),{open:m,onOpenChange:p,title:h,description:x,confirmLabel:g,variant:v,onConfirm:b}=e;u[0]!==h?(a=(0,t.jsx)(f.AlertDialogTitle,{children:h}),u[0]=h,u[1]=a):a=u[1],u[2]!==x?(s=(0,t.jsx)(f.AlertDialogDescription,{children:x}),u[2]=x,u[3]=s):s=u[3],u[4]!==a||u[5]!==s?(o=(0,t.jsxs)(f.AlertDialogHeader,{children:[a,s]}),u[4]=a,u[5]=s,u[6]=o):o=u[6],u[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(f.AlertDialogCancel,{children:"Cancel"}),u[7]=l):l=u[7];let y="destructive"===(void 0===v?"destructive":v)?"destructive":"default";return u[8]!==g||u[9]!==b||u[10]!==y?(i=(0,t.jsxs)(f.AlertDialogFooter,{children:[l,(0,t.jsx)(f.AlertDialogAction,{render:(0,t.jsx)(n.Button,{variant:y,onClick:b,children:g})})]}),u[8]=g,u[9]=b,u[10]=y,u[11]=i):i=u[11],u[12]!==o||u[13]!==i?(c=(0,t.jsxs)(f.AlertDialogContent,{children:[o,i]}),u[12]=o,u[13]=i,u[14]=c):c=u[14],u[15]!==p||u[16]!==m||u[17]!==c?(d=(0,t.jsx)(f.AlertDialog,{open:m,onOpenChange:p,children:c}),u[15]=p,u[16]=m,u[17]=c,u[18]=d):d=u[18],d}let x=(0,s.createContext)({roomHref:e=>`/chat?room=${e}`,deletedRoomHref:"/chat",canDuplicate:!0}),g=x.Provider;function v(){return(0,s.useContext)(x)}function b(){let e,a,o,i,f,x,g,b,j,S,w=(0,r.c)(27),N=(0,p.useLocalizedRouter)(),C=v(),I=(0,l.useSelectedRoomCount)(),_=(0,l.useRoomSelectionStore)(y),[k,A]=(0,s.useState)(!1),[M,T]=(0,s.useState)(!1);w[0]!==_?(e=()=>{let e=[...l.useRoomSelectionStore.getState().selectedRoomIds];T(!1),m.chatroomStoreActions.exportManyData({payload:{roomIds:e}}),_()},w[0]=_,w[1]=e):e=w[1];let E=e;w[2]!==_||w[3]!==C||w[4]!==N?(a=async()=>{let e=[...l.useRoomSelectionStore.getState().selectedRoomIds];for(let t of(A(!1),e))await m.chatroomStoreActions.deleteChatroom({payload:{roomId:t},dependencies:{deletedRoomHref:C.deletedRoomHref,router:N}});_()},w[2]=_,w[3]=C,w[4]=N,w[5]=a):a=w[5];let R=a;if(0===I)return null;w[6]===Symbol.for("react.memo_cache_sentinel")?(o=(0,u.cn)("shrink-0 flex flex-col gap-1.5","rounded-xl border border-border bg-background px-2.5 py-2"),w[6]=o):o=w[6],w[7]!==I?(i=(0,t.jsxs)("span",{className:"px-0.5 text-sm font-medium text-foreground",children:[I," selected"]}),w[7]=I,w[8]=i):i=w[8],w[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsxs)(n.Button,{type:"button",variant:"outline",size:"sm","aria-label":"Export selected chats",className:"flex-1 gap-1.5",onClick:()=>T(!0),children:[(0,t.jsx)(c.ArrowDownTrayIcon,{className:"size-4"}),"Export"]}),w[9]=f):f=w[9],w[10]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[f,(0,t.jsxs)(n.Button,{type:"button",variant:"outline",size:"sm","aria-label":"Delete selected chats",className:"flex-1 gap-1.5 border-negative/30 text-negative hover:bg-negative-bg hover:text-negative",onClick:()=>A(!0),children:[(0,t.jsx)(d.TrashIcon,{className:"size-4"}),"Delete"]})]}),w[10]=x):x=w[10],w[11]!==i?(g=(0,t.jsxs)("div",{role:"toolbar","aria-label":"Bulk chat actions",className:o,children:[i,x]}),w[11]=i,w[12]=g):g=w[12];let z=`This will download ${I} chat${1===I?"":"s"} as a single JSON file.`,O=`Export (${I})`;w[13]!==E||w[14]!==M||w[15]!==z||w[16]!==O?(b=(0,t.jsx)(h,{open:M,onOpenChange:T,title:"Export selected chats",description:z,confirmLabel:O,variant:"default",onConfirm:E}),w[13]=E,w[14]=M,w[15]=z,w[16]=O,w[17]=b):b=w[17];let F=`This will permanently delete ${I} chat${1===I?"":"s"}. This action cannot be undone.`,D=`Delete (${I})`;return w[18]!==R||w[19]!==k||w[20]!==F||w[21]!==D?(j=(0,t.jsx)(h,{open:k,onOpenChange:A,title:"Delete selected chats",description:F,confirmLabel:D,variant:"destructive",onConfirm:R}),w[18]=R,w[19]=k,w[20]=F,w[21]=D,w[22]=j):j=w[22],w[23]!==j||w[24]!==g||w[25]!==b?(S=(0,t.jsxs)(t.Fragment,{children:[g,b,j]}),w[23]=j,w[24]=g,w[25]=b,w[26]=S):S=w[26],S}function y(e){return e.exitSelectionMode}e.s(["RoomNavigationProvider",0,g,"useRoomNavigation",0,v],649301);var j=e.i(452447);let S=s.forwardRef(function({title:e,titleId:t,...r},n){return s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?s.createElement("title",{id:t},e):null,s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14"}))});function w(e){let n,a,s,o,i,c,d=(0,r.c)(29),{visibleRoomIds:m,className:p,label:f,labelClassName:h}=e,x=(0,l.useIsRoomSelectionMode)(),g=(0,l.useRoomSelectionStore)(I),v=(0,l.useRoomSelectionStore)(C),b=(0,l.useRoomSelectionStore)(N);if(0===m.length)return null;if(d[0]!==g||d[1]!==m){let e;d[3]!==g?(e=e=>g.has(e),d[3]=g,d[4]=e):e=d[4],n=m.filter(e),d[0]=g,d[1]=m,d[2]=n}else n=d[2];let y=n.length,w=y===m.length,_=0===y,k=!_&&!w;d[5]!==b||d[6]!==_||d[7]!==x||d[8]!==v||d[9]!==m?(a=()=>{if(x){if(_)return void v(m);b(m)}},d[5]=b,d[6]=_,d[7]=x,d[8]=v,d[9]=m,d[10]=a):a=d[10];let A=a,M=_?`Select all (${m.length})`:`Deselect ${y}`,T=k?"mixed":w,E=x?"transition-colors hover:bg-card-hover hover:text-accent-foreground":"cursor-default";return d[11]!==p||d[12]!==E?(s=(0,u.cn)("flex w-fit shrink-0 items-center gap-2 rounded-md p-1.5 text-muted-foreground",E,p),d[11]=p,d[12]=E,d[13]=s):s=d[13],d[14]!==w||d[15]!==_||d[16]!==k||d[17]!==x?(o=x?(0,t.jsxs)("span",{"aria-hidden":"true",className:(0,u.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border","transition-[background-color,border-color]",w&&"border-primary bg-primary text-primary-foreground",k&&"border-primary bg-primary text-primary-foreground",_&&"border-foreground/30 bg-muted"),children:[w?(0,t.jsx)(j.CheckIcon,{className:"h-3 w-3 stroke-[3]"}):null,k?(0,t.jsx)(S,{className:"h-3 w-3 stroke-[3]"}):null]}):null,d[14]=w,d[15]=_,d[16]=k,d[17]=x,d[18]=o):o=d[18],d[19]!==f||d[20]!==h?(i=f?(0,t.jsx)("span",{className:(0,u.cn)("text-xs leading-none",h),children:f}):null,d[19]=f,d[20]=h,d[21]=i):i=d[21],d[22]!==M||d[23]!==T||d[24]!==A||d[25]!==s||d[26]!==o||d[27]!==i?(c=(0,t.jsxs)("button",{type:"button",role:"checkbox","aria-checked":T,"aria-label":M,onClick:A,className:s,children:[o,i]}),d[22]=M,d[23]=T,d[24]=A,d[25]=s,d[26]=o,d[27]=i,d[28]=c):c=d[28],c}function N(e){return e.clearMany}function C(e){return e.selectMany}function I(e){return e.selectedRoomIds}let _=s.forwardRef(function({title:e,titleId:t,...r},n){return s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?s.createElement("title",{id:t},e):null,s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.593 3.322c1.1.128 1.907 1.077 1.907 2.185V21L12 17.25 4.5 21V5.507c0-1.108.806-2.057 1.907-2.185a48.507 48.507 0 0 1 11.186 0Z"}))});var k=e.i(492565),A=e.i(856255),M=e.i(373855),T=e.i(778084),E=e.i(379684),R=e.i(295654),z=e.i(693946),O=e.i(700050),F=e.i(624621),D=e.i(735625);function L(e){let n,a,s=(0,r.c)(7),{roomId:o}=e,i=(0,l.useIsRoomSelectionMode)(),c=(0,l.useIsRoomSelected)(o),d=(0,l.useRoomSelectionStore)(B);if(!i)return null;let u=c?`Deselect chat ${o}`:`Select chat ${o}`;return s[0]!==o||s[1]!==d?(n=()=>d(o),s[0]=o,s[1]=d,s[2]=n):n=s[2],s[3]!==c||s[4]!==u||s[5]!==n?(a=(0,t.jsx)(D.Checkbox,{checked:c,"aria-label":u,onClick:P,onCheckedChange:n}),s[3]=c,s[4]=u,s[5]=n,s[6]=a):a=s[6],a}function P(e){e.stopPropagation()}function B(e){return e.toggleRoom}function V(e){let a,o,i,c,f,x,g,b,y,j,S,w,N,C,I,D,P,B,V,H,U,G,q,W,K,J,Z,Y,X,Q,ee,et,er,en,ea,es,eo,el,ei,ec=(0,r.c)(104),{roomId:ed}=e,eu=(0,p.useLocalizedRouter)(),em=v(),ep=ed===(0,F.useChatroomStore)(z.selectCurrentRoomId);ec[0]!==ed?(a=e=>(0,z.selectRoomTitleById)(e,ed),ec[0]=ed,ec[1]=a):a=ec[1];let ef=(0,F.useChatroomStore)(a);ec[2]!==ed?(o=e=>(0,z.selectIsRoomPinnedById)(e,ed),ec[2]=ed,ec[3]=o):o=ec[3];let eh=(0,F.useChatroomStore)(o),ex=(0,l.useIsRoomSelectionMode)(),eg=(0,l.useRoomSelectionStore)($),[ev,eb]=(0,s.useState)(!1),[ey,ej]=(0,s.useState)(!1),eS=(0,s.useRef)(null),[ew,eN]=(0,s.useState)(!1);ec[4]!==ew?(i=()=>{if(!ew)return;let e=e=>{"Escape"===e.key&&(e.stopPropagation(),eN(!1))};return document.addEventListener("keydown",e,{capture:!0}),()=>document.removeEventListener("keydown",e,{capture:!0})},c=[ew],ec[4]=ew,ec[5]=i,ec[6]=c):(i=ec[5],c=ec[6]),(0,s.useEffect)(i,c),ec[7]!==em.deletedRoomHref||ec[8]!==ed||ec[9]!==eu?(f=()=>{eN(!1),m.chatroomStoreActions.deleteChatroom({payload:{roomId:ed},dependencies:{deletedRoomHref:em.deletedRoomHref,router:eu}})},ec[7]=em.deletedRoomHref,ec[8]=ed,ec[9]=eu,ec[10]=f):f=ec[10];let eC=f;ec[11]!==ev?(x=()=>{ev&&(eS.current?.focus(),eS.current?.select())},g=[ev],ec[11]=ev,ec[12]=x,ec[13]=g):(x=ec[12],g=ec[13]),(0,s.useEffect)(x,g),ec[14]!==ev||ec[15]!==ef?(b=()=>{eS.current&&!ev&&(eS.current.value=ef)},y=[ef,ev],ec[14]=ev,ec[15]=ef,ec[16]=b,ec[17]=y):(b=ec[16],y=ec[17]),(0,s.useEffect)(b,y),ec[18]!==ed||ec[19]!==ef?(j=()=>{let e=eS.current?.value.trim()??"";eb(!1),e&&e!==ef&&(m.chatroomStoreActions.updateRoom({payload:{roomId:ed,partialRoom:{title:e}}}),(0,O.trackRoomUpdateTitle)({oldTitleLength:ef.length,newTitleLength:e.length}))},ec[18]=ed,ec[19]=ef,ec[20]=j):j=ec[20];let eI=j;ec[21]!==ef?(S=()=>{eb(!1),eS.current&&(eS.current.value=ef)},ec[21]=ef,ec[22]=S):S=ec[22];let e_=S;ec[23]!==eh||ec[24]!==ed?(w=()=>{m.chatroomStoreActions.updateRoom({payload:{roomId:ed,partialRoom:{isPinned:!eh}}})},ec[23]=eh,ec[24]=ed,ec[25]=w):w=ec[25];let ek=w,eA=ep?"bg-accent text-accent-foreground":"hover:bg-card-hover",eM=(!eh||ex)&&"pl-3";ec[26]!==eA||ec[27]!==eM?(N=(0,u.cn)("group relative flex h-9 items-center rounded-lg",eA,"transition-colors",eM),ec[26]=eA,ec[27]=eM,ec[28]=N):N=ec[28],ec[29]!==ex||ec[30]!==ed?(C=ex&&(0,t.jsx)("div",{className:"pr-2",children:(0,t.jsx)(L,{roomId:ed})}),ec[29]=ex,ec[30]=ed,ec[31]=C):C=ec[31],ec[32]!==ek||ec[33]!==eh||ec[34]!==ex?(I=eh&&!ex&&(0,t.jsx)(n.Button,{variant:"ghost",size:"icon","aria-label":"Unpin room",title:"Unpin room",className:"shrink-0 rounded-sm hover:bg-transparent dark:hover:bg-transparent",onClick:ek,children:(0,t.jsx)(_,{className:"h-4 w-4 text-muted-foreground"})}),ec[32]=ek,ec[33]=eh,ec[34]=ex,ec[35]=I):I=ec[35],ec[36]!==em||ec[37]!==ed?(D=em.roomHref(ed),ec[36]=em,ec[37]=ed,ec[38]=D):D=ec[38],ec[39]!==ex||ec[40]!==ed||ec[41]!==eg?(P=e=>{ex&&(e.preventDefault(),eg(ed))},ec[39]=ex,ec[40]=ed,ec[41]=eg,ec[42]=P):P=ec[42];let eT=ep&&"text-accent-foreground";ec[43]!==eT?(B=(0,u.cn)("flex flex-1 items-center justify-between","h-full","min-w-0","no-underline text-muted-foreground hover:text-accent-foreground hover:no-underline",eT),ec[43]=eT,ec[44]=B):B=ec[44];let eE=ev&&"cursor-text",eR=ef===R.DEFAULT_CHAT_ROOM_TITLE&&!ev&&"italic text-faint";ec[45]!==eE||ec[46]!==eR?(V=(0,u.cn)("ph-no-capture w-full cursor-pointer truncate bg-transparent text-sm font-medium pointer-coarse:text-base leading-5 pointer-coarse:leading-5 focus:outline-hidden",eE,eR),ec[45]=eE,ec[46]=eR,ec[47]=V):V=ec[47],ec[48]!==e_||ec[49]!==eI?(H=e=>{"Enter"===e.key?eI():"Escape"===e.key&&e_()},ec[48]=e_,ec[49]=eI,ec[50]=H):H=ec[50];let ez=!ev;ec[51]===Symbol.for("react.memo_cache_sentinel")?(U=e=>{e.preventDefault(),eb(!0)},ec[51]=U):U=ec[51],ec[52]!==eI||ec[53]!==ef||ec[54]!==V||ec[55]!==H||ec[56]!==ez?(G=(0,t.jsx)("div",{className:"flex min-w-0 flex-1 items-center",children:(0,t.jsx)("input",{ref:eS,className:V,"data-dd-privacy":"hidden",placeholder:R.DEFAULT_CHAT_ROOM_TITLE,defaultValue:ef,onBlur:eI,onKeyDown:H,readOnly:ez,onDoubleClick:U})}),ec[52]=eI,ec[53]=ef,ec[54]=V,ec[55]=H,ec[56]=ez,ec[57]=G):G=ec[57],ec[58]!==D||ec[59]!==P||ec[60]!==B||ec[61]!==G?(q=(0,t.jsx)(E.TextLink,{href:D,scroll:!1,onClick:P,className:B,children:G}),ec[58]=D,ec[59]=P,ec[60]=B,ec[61]=G,ec[62]=q):q=ec[62];let eO=ex&&"hidden";ec[63]!==eO?(W=(0,u.cn)("flex shrink-0 items-center",eO),ec[63]=eO,ec[64]=W):W=ec[64];let eF=ep&&"opacity-100";ec[65]!==eF?(K=(0,u.cn)("group-hover:opacity-100 md:opacity-0","data-[state=open]:opacity-100",eF,"hover:bg-transparent dark:hover:bg-transparent"),ec[65]=eF,ec[66]=K):K=ec[66],ec[67]===Symbol.for("react.memo_cache_sentinel")?(J=(0,t.jsx)(A.EllipsisVerticalIcon,{className:"size-5"}),ec[67]=J):J=ec[67],ec[68]!==K?(Z=(0,t.jsx)(T.PopoverTrigger,{render:(0,t.jsx)(n.Button,{size:"icon",variant:"ghost",className:K,"aria-label":"Room actions",children:J})}),ec[68]=K,ec[69]=Z):Z=ec[69],ec[70]!==ek?(Y=()=>{ej(!1),ek()},ec[70]=ek,ec[71]=Y):Y=ec[71],ec[72]===Symbol.for("react.memo_cache_sentinel")?(X=(0,t.jsx)(_,{className:"h-4 w-4"}),ec[72]=X):X=ec[72];let eD=eh?"Unpin":"Pin";return ec[73]!==eD?(Q=(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[X,eD]}),ec[73]=eD,ec[74]=Q):Q=ec[74],ec[75]!==Y||ec[76]!==Q?(ee=(0,t.jsx)(n.Button,{size:"sm",variant:"ghost",className:"w-full justify-start",onClick:Y,children:Q}),ec[75]=Y,ec[76]=Q,ec[77]=ee):ee=ec[77],ec[78]===Symbol.for("react.memo_cache_sentinel")?(et=(0,t.jsxs)(n.Button,{size:"sm",variant:"ghost",className:"w-full justify-start",onClick:()=>{ej(!1),requestAnimationFrame(()=>eb(!0))},children:[(0,t.jsx)(M.PencilIcon,{className:"size-4"})," Rename"]}),ec[78]=et):et=ec[78],ec[79]!==em.canDuplicate||ec[80]!==ed||ec[81]!==eu?(er=em.canDuplicate?(0,t.jsxs)(n.Button,{size:"sm",variant:"ghost",className:"w-full justify-start",onClick:()=>{ej(!1),m.chatroomStoreActions.duplicateRoom({payload:{sourceRoomId:ed},dependencies:{router:eu}})},children:[(0,t.jsx)(k.DocumentDuplicateIcon,{className:"size-4"})," Duplicate"]}):null,ec[79]=em.canDuplicate,ec[80]=ed,ec[81]=eu,ec[82]=er):er=ec[82],ec[83]===Symbol.for("react.memo_cache_sentinel")?(en=(0,t.jsxs)(n.Button,{size:"sm",variant:"ghost",className:"w-full justify-start text-negative hover:text-negative",onClick:()=>{ej(!1),eN(!0)},children:[(0,t.jsx)(d.TrashIcon,{className:"size-4"})," Delete"]}),ec[83]=en):en=ec[83],ec[84]!==ee||ec[85]!==er?(ea=(0,t.jsx)(T.PopoverContent,{side:"right",className:"w-48 p-1.5 text-xs",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[ee,et,er,en]})}),ec[84]=ee,ec[85]=er,ec[86]=ea):ea=ec[86],ec[87]!==ey||ec[88]!==Z||ec[89]!==ea?(es=(0,t.jsxs)(T.Popover,{open:ey,onOpenChange:ej,children:[Z,ea]}),ec[87]=ey,ec[88]=Z,ec[89]=ea,ec[90]=es):es=ec[90],ec[91]!==W||ec[92]!==es?(eo=(0,t.jsx)("div",{className:W,children:es}),ec[91]=W,ec[92]=es,ec[93]=eo):eo=ec[93],ec[94]!==eC||ec[95]!==ew?(el=(0,t.jsx)(h,{open:ew,onOpenChange:eN,title:"Delete chat",description:"This will permanently delete this chat. This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:eC}),ec[94]=eC,ec[95]=ew,ec[96]=el):el=ec[96],ec[97]!==N||ec[98]!==C||ec[99]!==I||ec[100]!==q||ec[101]!==eo||ec[102]!==el?(ei=(0,t.jsxs)("div",{className:N,children:[C,I,q,eo,el]}),ec[97]=N,ec[98]=C,ec[99]=I,ec[100]=q,ec[101]=eo,ec[102]=el,ec[103]=ei):ei=ec[103],ei}function $(e){return e.toggleRoom}let H=(0,s.memo)(e=>(0,t.jsx)(s.Suspense,{fallback:null,children:(0,t.jsx)(V,{...e})}),(e,t)=>e.roomId===t.roomId);function U(e){let n,a,s,o=(0,r.c)(11),{rooms:l}=e,i=l.pinned.length>0,c=l.recent.length>0;if(!i&&!c){let e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"flex h-full items-center justify-center px-4 text-xs text-muted-foreground",children:"No matching rooms"}),o[0]=e):e=o[0],e}return o[1]!==i||o[2]!==l.pinned?(n=i&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:(0,u.cn)("flex items-center px-3","pt-2 pb-1"),children:(0,t.jsx)(w,{visibleRoomIds:l.pinned,label:"Pinned",labelClassName:"text-overline font-medium uppercase tracking-wider text-muted-foreground",className:"-ml-1.5"})}),(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:l.pinned.map(q)})]}),o[1]=i,o[2]=l.pinned,o[3]=n):n=o[3],o[4]!==i||o[5]!==c||o[6]!==l.recent?(a=c&&(0,t.jsx)("div",{className:"flex flex-col",children:l.recent.map((e,r)=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:(0,u.cn)("flex items-center gap-2 px-3",i||0!==r?"pt-4 pb-1":"pt-2 pb-1"),children:[(0,t.jsx)(w,{visibleRoomIds:e.roomIds,label:e.groupName,labelClassName:"text-overline font-medium uppercase tracking-wider text-muted-foreground",className:"-ml-1.5"}),(0,t.jsx)("div",{"aria-hidden":"true",className:"h-px flex-1 bg-border"})]}),(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:e.roomIds.map(G)})]},e.groupName))}),o[4]=i,o[5]=c,o[6]=l.recent,o[7]=a):a=o[7],o[8]!==n||o[9]!==a?(s=(0,t.jsxs)("div",{className:"flex flex-col",children:[n,a]}),o[8]=n,o[9]=a,o[10]=s):s=o[10],s}function G(e){return(0,t.jsx)(H,{roomId:e},e)}function q(e){return(0,t.jsx)(H,{roomId:e},e)}var W=e.i(779100),K=e.i(575292),J=e.i(150049),Z=e.i(664514);let Y=(0,s.memo)(e=>{let c,d,u,m,p,f,h,x,g,v,y,j,S,N,C,I,_,k=(0,r.c)(30),{internId:A}=e,[M,T]=(0,s.useState)(""),[E,R]=(0,s.useState)(M),O=(0,l.useIsRoomSelectionMode)(),D=(0,l.useRoomSelectionStore)(X),L=(0,l.useRoomSelectionStore)(Q);k[0]!==M?(c=()=>{let e=setTimeout(()=>{R(M)},250);return()=>clearTimeout(e)},d=[M],k[0]=M,k[1]=c,k[2]=d):(c=k[1],d=k[2]),(0,s.useEffect)(c,d);let P=(N=(0,r.c)(6),C=(0,W.useLocale)(),I=(0,J.useResolvedDisplayTimeZone)(),_=(0,K.useRelativeNow)(),N[0]!==E||N[1]!==A||N[2]!==C||N[3]!==_||N[4]!==I?(S=e=>void 0===A?(0,z.selectRoomsForSidebar)(e,E,C,{timeZone:I,nowMs:_}):(0,z.selectInternRoomsForSidebar)(e,A,E,C,{timeZone:I,nowMs:_}),N[0]=E,N[1]=A,N[2]=C,N[3]=_,N[4]=I,N[5]=S):S=N[5],(0,F.useChatroomStore)((0,Z.useShallow)(S))),B=void 0===A?"room":"conversation";k[3]!==P.pinned||k[4]!==P.recent?(u=[...P.pinned,...P.recent.flatMap(ee)],k[3]=P.pinned,k[4]=P.recent,k[5]=u):u=k[5];let V=u,$=void 0===A?"Search rooms...":"Search conversations...";k[6]!==M||k[7]!==$?(m=(0,t.jsx)(o.HistorySidebarSearchRow,{placeholder:$,value:M,onValueChange:T}),k[6]=M,k[7]=$,k[8]=m):m=k[8],k[9]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)("div",{"aria-hidden":"true",className:"shrink-0 -mx-2 py-4",children:(0,t.jsx)("div",{className:"h-px bg-border"})}),k[9]=p):p=k[9],k[10]!==O||k[11]!==B||k[12]!==V?(f=O?(0,t.jsx)(w,{visibleRoomIds:V,label:"Select all",className:"ml-1.5"}):(0,t.jsxs)("span",{className:"inline-flex h-7 items-center pl-3 text-xs font-medium text-muted-foreground",children:[V.length," ",1===V.length?B:`${B}s`]}),k[10]=O,k[11]=B,k[12]=V,k[13]=f):f=k[13];let H=O?L:D,G=O?"Done":"Select";return k[14]!==H||k[15]!==G?(h=(0,t.jsx)(n.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-1.5 text-muted-foreground",onClick:H,children:G}),k[14]=H,k[15]=G,k[16]=h):h=k[16],k[17]!==h||k[18]!==f?(x=(0,t.jsxs)("div",{className:"flex h-7 shrink-0 items-center justify-between gap-1.5 pr-1",children:[f,h]}),k[17]=h,k[18]=f,k[19]=x):x=k[19],k[20]!==P?(g=(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-hide",children:(0,t.jsx)(U,{rooms:P})}),k[20]=P,k[21]=g):g=k[21],k[22]!==A?(v=void 0===A?(0,t.jsx)(i.WorkspaceSwitcher,{className:"mb-2",surface:a.WorkspaceSwitchSurface.Chat}):null,k[22]=A,k[23]=v):v=k[23],k[24]===Symbol.for("react.memo_cache_sentinel")?(y=(0,t.jsx)(b,{}),k[24]=y):y=k[24],k[25]!==x||k[26]!==g||k[27]!==v||k[28]!==m?(j=(0,t.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col gap-2",children:[m,p,x,g,v,y]}),k[25]=x,k[26]=g,k[27]=v,k[28]=m,k[29]=j):j=k[29],j},(e,t)=>e.internId===t.internId);function X(e){return e.enterSelectionMode}function Q(e){return e.exitSelectionMode}function ee(e){return e.roomIds}e.s(["RoomManagerContent",0,Y],362942);var et=e.i(117738),er=e.i(215370),en=e.i(733442);e.s(["useExpectedPlaygroundNamespace",0,function(){let e,t=(0,r.c)(4),{isLoading:n,isOrgLoading:a,clerkOrg:s,isSignedIn:o}=(0,et.useEntity)(),l=(0,er.useActiveWorkspacePartition)();s?.id;e:{let r;if(!(!n&&!a)||!l.isReady){e=null;break e}let i=!0===o,c=s?.id;t[0]!==i||t[1]!==c||t[2]!==l.partitionId?(r=function(e){let{isSignedIn:t,clerkOrgId:r,workspacePartitionId:n}=e;if(!t)return`${en.BASE_NAMESPACE}:guest:${en.NAMESPACE_VERSION}`;let a=null===n?"":`:ws:${n}`;return r?`${en.BASE_NAMESPACE}:${r}${a}:${en.NAMESPACE_VERSION}`:`${en.BASE_NAMESPACE}${a}:${en.NAMESPACE_VERSION}`}({isSignedIn:i,clerkOrgId:c,workspacePartitionId:l.partitionId}),t[0]=i,t[1]=c,t[2]=l.partitionId,t[3]=r):r=t[3],e=r}return e}],907781),e.s(["usePlaygroundStoreInitializer",0,e=>{let t,n,a=(0,r.c)(4),{expectedInstanceId:o,hydratedInstanceId:l}=e;a[0]!==o||a[1]!==l?(t=()=>{o&&l!==o&&m.chatroomStoreActions.initStore({payload:{storageInstanceId:o}})},n=[o,l],a[0]=o,a[1]=l,a[2]=t,a[3]=n):(t=a[2],n=a[3]),(0,s.useEffect)(t,n)}],329343)},729987,e=>{"use strict";var t=e.i(505962),r=e.i(270401);e.s(["useAutoScroll",0,function(e){let n,a,s,o,l,i,c,d,u,m,p,f,h,x,g,v,b,y,j=(0,t.c)(39),{scrollContainerRef:S,contentRef:w,scrollTolerance:N,shouldStick:C,onStickChange:I,initialStick:_,dependencies:k}=e,A=void 0===N?100:N;j[0]!==k?(n=void 0===k?[]:k,j[0]=k,j[1]=n):n=j[1];let M=n,T=void 0!==C,[E,R]=(0,r.useState)(void 0===_||_),z=T?C:E,O=(0,r.useRef)(z),F=(0,r.useRef)(null),D=(0,r.useRef)(null),L=(0,r.useRef)(!1),P=(0,r.useRef)(null);j[2]!==z?(a=()=>{O.current=z},s=[z],j[2]=z,j[3]=a,j[4]=s):(a=j[3],s=j[4]),(0,r.useLayoutEffect)(a,s),j[5]!==T||j[6]!==I?(o=(e,t)=>{(void 0===t||t)&&(O.current=e),T?I?.(e):R(e)},j[5]=T,j[6]=I,j[7]=o):o=j[7];let B=o;j[8]!==B||j[9]!==S||j[10]!==A?(l=()=>{let e=S.current;if(!e)return;let t=D.current;if(null!==t&&1>Math.abs(e.scrollTop-t)){D.current=null,F.current=e.scrollTop;return}D.current=null;let r=F.current;L.current&&null!==r&&e.scrollTopr,s=e.scrollTop>=e.scrollHeight-e.clientHeight;n&&(a||s)&&!O.current?B(n,!1):!n&&O.current&&B(!1)},j[8]=B,j[9]=S,j[10]=A,j[11]=l):l=j[11];let V=l;j[12]!==V||j[13]!==S?(c=()=>{let e=S.current;if(e)return e.addEventListener("scroll",V,{passive:!0}),O.current||V(),()=>{e.removeEventListener("scroll",V)}},i=[S,V],j[12]=V,j[13]=S,j[14]=i,j[15]=c):(i=j[14],c=j[15]),(0,r.useLayoutEffect)(c,i),j[16]!==B?(d=e=>{e.deltaY<0&&B(!1)},j[16]=B,j[17]=d):d=j[17];let $=d;j[18]===Symbol.for("react.memo_cache_sentinel")?(u=e=>{L.current=!0,P.current=e.touches[0]?.clientY??null},j[18]=u):u=j[18];let H=u;j[19]!==B?(m=e=>{let t=e.touches[0]?.clientY,r=P.current;void 0!==t&&null!==r&&t>r&&B(!1),P.current=t??null},j[19]=B,j[20]=m):m=j[20];let U=m;j[21]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{L.current=!1,P.current=null},j[21]=p):p=j[21];let G=p;j[22]!==U||j[23]!==$||j[24]!==S?(f=()=>{let e=S.current;if(e)return e.addEventListener("wheel",$,{passive:!0}),e.addEventListener("touchstart",H,{passive:!0}),e.addEventListener("touchmove",U,{passive:!0}),e.addEventListener("touchend",G,{passive:!0}),e.addEventListener("touchcancel",G,{passive:!0}),()=>{e.removeEventListener("wheel",$),e.removeEventListener("touchstart",H),e.removeEventListener("touchmove",U),e.removeEventListener("touchend",G),e.removeEventListener("touchcancel",G)}},h=[S,$,H,U,G],j[22]=U,j[23]=$,j[24]=S,j[25]=f,j[26]=h):(f=j[25],h=j[26]),(0,r.useLayoutEffect)(f,h),j[27]!==S?(x=()=>{let e=S.current;e&&(D.current=Math.max(0,e.scrollHeight-e.clientHeight),e.scrollTop=e.scrollHeight)},j[27]=S,j[28]=x):x=j[28];let q=x;j[29]!==w||j[30]!==S||j[31]!==q?(g=()=>{let e=S.current,t=w?.current??e;if(!e||!t)return;let r=new globalThis.ResizeObserver(()=>{O.current&&q()});return r.observe(t),()=>{r.disconnect()}},v=[S,w,q],j[29]=w,j[30]=S,j[31]=q,j[32]=g,j[33]=v):(g=j[32],v=j[33]),(0,r.useLayoutEffect)(g,v),j[34]!==q?(b=()=>{O.current&&q()},j[34]=q,j[35]=b):b=j[35],j[36]!==M||j[37]!==q?(y=[q,...M],j[36]=M,j[37]=q,j[38]=y):y=j[38],(0,r.useLayoutEffect)(b,y)}])},511410,e=>{"use strict";var t=e.i(505962),r=e.i(270401);e.s(["useScrollFade",0,function(e){let n,a,s,o,l,i=(0,t.c)(9),c=(0,r.useRef)(null);i[0]===Symbol.for("react.memo_cache_sentinel")?(n={canScrollStart:!1,canScrollEnd:!1},i[0]=n):n=i[0];let[d,u]=(0,r.useState)(n);i[1]!==e?(a=()=>{let t=c.current;if(!t)return;let r="y"===e?t.scrollTop:t.scrollLeft,n="y"===e?t.clientHeight:t.clientWidth,a="y"===e?t.scrollHeight:t.scrollWidth,s=r>2,o=r+ne.canScrollStart===s&&e.canScrollEnd===o?e:{canScrollStart:s,canScrollEnd:o})},i[1]=e,i[2]=a):a=i[2];let m=a;return i[3]!==m?(s=()=>{let e=c.current;if(!e)return;m(),e.addEventListener("scroll",m,{passive:!0});let t=new globalThis.ResizeObserver(m);return t.observe(e),()=>{e.removeEventListener("scroll",m),t.disconnect()}},o=[m],i[3]=m,i[4]=s,i[5]=o):(s=i[4],o=i[5]),(0,r.useLayoutEffect)(s,o),i[6]!==d.canScrollEnd||i[7]!==d.canScrollStart?(l={ref:c,canScrollStart:d.canScrollStart,canScrollEnd:d.canScrollEnd},i[6]=d.canScrollEnd,i[7]=d.canScrollStart,i[8]=l):l=i[8],l}])}]); //# sourceMappingURL=3hlviylxgii65.js.map //# chunkId=01a099a4-b45b-71d0-9dae-0fd242a72828