PageSourceSearch

https://poerava.ai/_next/static/chunks/012d1f649d7d96ca.js

js poerava.ai collected 2026-10-05 12:28:03 UTC 24,550 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,793479,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(975157);let s=a.forwardRef(({className:e,type:a,...s},i)=>(0,t.jsx)("input",{type:a,className:(0,r.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:i,...s}));s.displayName="Input",e.s(["Input",()=>s])},107233,e=>{"use strict";let t=(0,e.i(475254).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);e.s(["Plus",()=>t],107233)},999682,e=>{"use strict";var t=e.i(271645);function a(e){let a=t.useRef({value:e,previous:e});return t.useMemo(()=>(a.current.value!==e&&(a.current.previous=a.current.value,a.current.value=e),a.current.previous),[e])}e.s(["usePrevious",()=>a])},257428,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(820783),s=e.i(30030),i=e.i(981140),n=e.i(369340),l=e.i(999682),o=e.i(635804),c=e.i(296626),d=e.i(248425),u="Checkbox",[m,h]=(0,s.createContextScope)(u),[p,x]=m(u);function f(e){let{__scopeCheckbox:r,checked:s,children:i,defaultChecked:l,disabled:o,form:c,name:d,onCheckedChange:m,required:h,value:x="on",internal_do_not_use_render:f}=e,[g,b]=(0,n.useControllableState)({prop:s,defaultProp:l??!1,onChange:m,caller:u}),[v,j]=a.useState(null),[w,y]=a.useState(null),N=a.useRef(!1),C=!v||!!c||!!v.closest("form"),S={checked:g,disabled:o,setChecked:b,control:v,setControl:j,name:d,form:c,value:x,hasConsumerStoppedPropagationRef:N,required:h,defaultChecked:!k(l)&&l,isFormControl:C,bubbleInput:w,setBubbleInput:y};return(0,t.jsx)(p,{scope:r,...S,children:"function"==typeof f?f(S):i})}var g="CheckboxTrigger",b=a.forwardRef(({__scopeCheckbox:e,onKeyDown:s,onClick:n,...l},o)=>{let{control:c,value:u,disabled:m,checked:h,required:p,setControl:f,setChecked:b,hasConsumerStoppedPropagationRef:v,isFormControl:j,bubbleInput:w}=x(g,e),y=(0,r.useComposedRefs)(o,f),N=a.useRef(h);return a.useEffect(()=>{let e=c?.form;if(e){let t=()=>b(N.current);return e.addEventListener("reset",t),()=>e.removeEventListener("reset",t)}},[c,b]),(0,t.jsx)(d.Primitive.button,{type:"button",role:"checkbox","aria-checked":k(h)?"mixed":h,"aria-required":p,"data-state":C(h),"data-disabled":m?"":void 0,disabled:m,value:u,...l,ref:y,onKeyDown:(0,i.composeEventHandlers)(s,e=>{"Enter"===e.key&&e.preventDefault()}),onClick:(0,i.composeEventHandlers)(n,e=>{b(e=>!!k(e)||!e),w&&j&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())})})});b.displayName=g;var v=a.forwardRef((e,a)=>{let{__scopeCheckbox:r,name:s,checked:i,defaultChecked:n,required:l,disabled:o,value:c,onCheckedChange:d,form:u,...m}=e;return(0,t.jsx)(f,{__scopeCheckbox:r,checked:i,defaultChecked:n,disabled:o,required:l,onCheckedChange:d,name:s,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(b,{...m,ref:a,__scopeCheckbox:r}),e&&(0,t.jsx)(N,{__scopeCheckbox:r})]})})});v.displayName=u;var j="CheckboxIndicator",w=a.forwardRef((e,a)=>{let{__scopeCheckbox:r,forceMount:s,...i}=e,n=x(j,r);return(0,t.jsx)(c.Presence,{present:s||k(n.checked)||!0===n.checked,children:(0,t.jsx)(d.Primitive.span,{"data-state":C(n.checked),"data-disabled":n.disabled?"":void 0,...i,ref:a,style:{pointerEvents:"none",...e.style}})})});w.displayName=j;var y="CheckboxBubbleInput",N=a.forwardRef(({__scopeCheckbox:e,...s},i)=>{let{control:n,hasConsumerStoppedPropagationRef:c,checked:u,defaultChecked:m,required:h,disabled:p,name:f,value:g,form:b,bubbleInput:v,setBubbleInput:j}=x(y,e),w=(0,r.useComposedRefs)(i,j),N=(0,l.usePrevious)(u),C=(0,o.useSize)(n);a.useEffect(()=>{if(!v)return;let e=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set,t=!c.current;if(N!==u&&e){let a=new Event("click",{bubbles:t});v.indeterminate=k(u),e.call(v,!k(u)&&u),v.dispatchEvent(a)}},[v,N,u,c]);let S=a.useRef(!k(u)&&u);return(0,t.jsx)(d.Primitive.input,{type:"checkbox","aria-hidden":!0,defaultChecked:m??S.current,required:h,disabled:p,name:f,value:g,form:b,...s,tabIndex:-1,ref:w,style:{...s.style,...C,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});function k(e){return"indeterminate"===e}function C(e){return k(e)?"indeterminate":e?"checked":"unchecked"}N.displayName=y;var S=e.i(643531),T=e.i(975157);let E=a.forwardRef(({className:e,...a},r)=>(0,t.jsx)(v,{ref:r,className:(0,T.cn)("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...a,children:(0,t.jsx)(w,{className:(0,T.cn)("flex items-center justify-center text-current"),children:(0,t.jsx)(S.Check,{className:"h-4 w-4"})})}));E.displayName=v.displayName,e.s(["Checkbox",()=>E],257428)},991810,e=>{"use strict";let t=(0,e.i(475254).default)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);e.s(["RotateCw",()=>t],991810)},373375,e=>{"use strict";let t=(0,e.i(475254).default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);e.s(["ChevronLeft",()=>t],373375)},878894,e=>{"use strict";let t=(0,e.i(475254).default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);e.s(["AlertTriangle",()=>t],878894)},541071,e=>{"use strict";let t=(0,e.i(475254).default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);e.s(["MoreHorizontal",()=>t],541071)},722915,e=>{"use strict";let t=(0,e.i(475254).default)("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);e.s(["Archive",()=>t],722915)},931977,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(618566),s=e.i(107233),i=e.i(531278),n=e.i(519455),l=e.i(776639),o=e.i(793479),c=e.i(110204),d=e.i(624687),u=e.i(846696);function m({parentOptions:e=[],orgOptions:m=[],activeOrgId:h=null,variant:p="subordinate"}){let x=(0,r.useRouter)(),[f,g]=(0,a.useState)(!1),[b,v]=(0,a.useState)(!1),[j,w]=(0,a.useState)(""),[y,N]=(0,a.useState)(""),[k,C]=(0,a.useState)(""),[S,T]=(0,a.useState)(""),[E,I]=(0,a.useState)(h&&m.some(e=>e.orgId===h)?h:""),L=""!==S,M=!L&&m.length>=2,D=!!j.trim()&&!b&&(!M||!!E),P=async e=>{if(e.preventDefault(),!D)return;let t=M&&E||null;v(!0);try{let e=await fetch("/api/teams",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j.trim(),description:y.trim()||null,location:k.trim()||null,parent_team_id:S||null,organization_id:t})});if(!e.ok){let t=await e.json().catch(()=>({error:"Unknown error"}));throw Error(t.error??`Request failed: ${e.status}`)}let a=(await e.json()).team_id;if(!a)throw Error("Team created but no ID returned");u.toast.success(`Team "${j.trim()}" created. Let's set it up.`),g(!1),x.push(`/routines/teams/${a}/onboarding`)}catch(t){let e=t instanceof Error?t.message:String(t);u.toast.error(`Failed to create team: ${e}`)}finally{v(!1)}};return(0,t.jsxs)(l.Dialog,{open:f,onOpenChange:g,children:[(0,t.jsx)(l.DialogTrigger,{asChild:!0,children:"dominant"===p?(0,t.jsxs)(n.Button,{size:"lg",className:"text-base px-6 py-6",children:[(0,t.jsx)(s.Plus,{className:"h-5 w-5 mr-2"}),"Create your team"]}):"icon"===p?(0,t.jsx)("button",{type:"button","aria-label":"Create team",title:"Create team",className:"rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground",children:(0,t.jsx)(s.Plus,{className:"h-4 w-4"})}):(0,t.jsxs)(n.Button,{size:"sm",variant:"outline",children:[(0,t.jsx)(s.Plus,{className:"h-4 w-4 mr-1.5"}),"Create team"]})}),(0,t.jsx)(l.DialogContent,{children:(0,t.jsxs)("form",{onSubmit:P,children:[(0,t.jsxs)(l.DialogHeader,{children:[(0,t.jsx)(l.DialogTitle,{children:"Tell us about your team"}),(0,t.jsx)(l.DialogDescription,{children:"We'll set up your team workspace and walk you through a quick onboarding."})]}),(0,t.jsxs)("div",{className:"space-y-4 py-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(c.Label,{htmlFor:"team-name",children:"Team name *"}),(0,t.jsx)(o.Input,{id:"team-name",value:j,onChange:e=>w(e.target.value),placeholder:"e.g. Production Line A",autoFocus:!0,required:!0,maxLength:120,disabled:b})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(c.Label,{htmlFor:"team-description",children:"Description"}),(0,t.jsx)(d.Textarea,{id:"team-description",value:y,onChange:e=>N(e.target.value),placeholder:"What does this team do?",rows:2,maxLength:2e3,disabled:b})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(c.Label,{htmlFor:"team-location",children:"Location"}),(0,t.jsx)(o.Input,{id:"team-location",value:k,onChange:e=>C(e.target.value),placeholder:"e.g. Lyon Plant, Line 3",maxLength:200,disabled:b})]}),e.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(c.Label,{htmlFor:"parent-team",children:"Parent team (optional)"}),(0,t.jsxs)("select",{id:"parent-team",value:S,onChange:e=>T(e.target.value),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",disabled:b,children:[(0,t.jsx)("option",{value:"",children:"No parent — top-level team"}),e.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),L?m.length>0&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"This team inherits its parent team's organization."}):M?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(c.Label,{htmlFor:"team-org",children:"Organization *"}),(0,t.jsxs)("select",{id:"team-org",value:E,onChange:e=>I(e.target.value),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",disabled:b,required:!0,children:[(0,t.jsx)("option",{value:"",disabled:!0,children:"Select an organization"}),m.map(e=>(0,t.jsx)("option",{value:e.orgId,children:e.name},e.orgId))]})]}):1===m.length?(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Organization:"," ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:m[0].name})]}):null]}),(0,t.jsxs)(l.DialogFooter,{children:[(0,t.jsx)(n.Button,{type:"button",variant:"outline",onClick:()=>g(!1),disabled:b,children:"Cancel"}),(0,t.jsx)(n.Button,{type:"submit",disabled:!D,children:b?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.Loader2,{className:"h-4 w-4 mr-2 animate-spin"}),"Creating..."]}):"Create team"})]})]})})]})}e.s(["CreateTeamButton",()=>m])},305622,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(522016),s=e.i(618566),i=e.i(373375),n=e.i(463059),l=e.i(664659),o=e.i(761911),c=e.i(541071),d=e.i(531278),u=e.i(722915),m=e.i(975157),h=e.i(755146),p=e.i(931977);let x="routinesSidebarCollapsed",f="routinesSidebarManagerCollapsed",g="routinesSidebarMemberCollapsed";function b({teams:e,activeTeamId:r,orgOptions:s=[],activeOrgId:l=null}){let[o,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(!1),[h,b]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{"true"===window.localStorage.getItem(x)&&c(!0),"true"===window.localStorage.getItem(f)&&u(!0),"true"===window.localStorage.getItem(g)&&b(!0)}catch{}},[]);let w=e=>{let t="manager"===e?f:g;("manager"===e?u:b)(e=>{let a=!e;try{window.localStorage.setItem(t,String(a))}catch{}return a})};(0,a.useEffect)(()=>
1{if(r)try{window.localStorage.setItem("lastActiveTeamId",r)}catch{}},[r]);let y=e.filter(e=>"admin"===e.role),N=e.filter(e=>"member"===e.role||"platform_admin"===e.role),k=e.filter(e=>"admin"===e.role||"platform_admin"===e.role).map(e=>({id:e.id,name:e.name}));return(0,t.jsxs)("aside",{className:(0,m.cn)("flex h-full flex-col border-r bg-background transition-all",o?"w-[56px]":"w-[240px]"),"aria-label":"Team navigation",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[!o&&(0,t.jsx)("span",{className:"text-xs font-medium uppercase text-muted-foreground",children:"Teams"}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5",children:[!o&&(0,t.jsx)(p.CreateTeamButton,{parentOptions:k,orgOptions:s,activeOrgId:l,variant:"icon"}),(0,t.jsx)("button",{type:"button",onClick:()=>{c(e=>{let t=!e;try{window.localStorage.setItem(x,String(t))}catch{}return t})},className:"rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground","aria-label":o?"Expand sidebar":"Collapse sidebar",children:o?(0,t.jsx)(n.ChevronRight,{className:"h-4 w-4"}):(0,t.jsx)(i.ChevronLeft,{className:"h-4 w-4"})})]})]}),(0,t.jsxs)("nav",{className:"flex-1 overflow-y-auto",children:[y.length>0&&(0,t.jsxs)("ul",{className:"py-2",children:[!o&&(0,t.jsx)(v,{collapsed:d,onToggle:()=>w("manager"),children:"Manager"}),(o||!d)&&y.map(e=>(0,t.jsx)(j,{team:e,active:e.id===r,collapsed:o},e.id))]}),y.length>0&&N.length>0&&(0,t.jsx)("div",{className:"mx-3 my-1 border-t","aria-hidden":"true"}),N.length>0&&(0,t.jsxs)("ul",{className:"py-2",children:[!o&&(0,t.jsx)(v,{collapsed:h,onToggle:()=>w("member"),children:"Member"}),(o||!h)&&N.map(e=>(0,t.jsx)(j,{team:e,active:e.id===r,collapsed:o},e.id))]})]})]})}function v({children:e,collapsed:a,onToggle:r}){return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",onClick:r,"aria-expanded":!a,className:"flex w-full items-center gap-1 px-3 pb-1 pt-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70 hover:text-foreground",children:[a?(0,t.jsx)(n.ChevronRight,{className:"h-3 w-3 flex-shrink-0","aria-hidden":"true"}):(0,t.jsx)(l.ChevronDown,{className:"h-3 w-3 flex-shrink-0","aria-hidden":"true"}),e]})})}function j({team:e,active:i,collapsed:n}){let l=(0,s.useRouter)(),p="admin"===e.role||"platform_admin"===e.role,[x,f]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1);async function v(t){if(t.preventDefault(),window.confirm(`Archive team "${e.name}"? It'll be hidden from the sidebar but can be restored from the admin panel.`)){f(!0);try{let t=await fetch(`/api/teams/${e.id}/archive`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({archived:!0})});if(!t.ok){let e=await t.json().catch(()=>({}));window.alert(e.error??"Failed to archive team");return}try{window.localStorage.getItem("lastActiveTeamId")===e.id&&window.localStorage.removeItem("lastActiveTeamId")}catch{}b(!1),l.push("/routines"),l.refresh()}catch(e){window.alert(e instanceof Error?e.message:"Failed to archive team")}finally{f(!1)}}}return(0,t.jsx)("li",{children:(0,t.jsxs)("div",{className:(0,m.cn)("group flex items-center gap-1 pr-1",i?"bg-accent":"hover:bg-accent/50"),children:[(0,t.jsxs)(r.default,{href:`/routines/teams/${e.id}`,className:(0,m.cn)("flex flex-1 items-center gap-2 px-3 py-2 text-sm min-w-0",i?"font-medium text-foreground":"text-muted-foreground group-hover:text-foreground"),title:n?e.name:void 0,children:[(0,t.jsx)(o.Users,{className:"h-4 w-4 flex-shrink-0","aria-hidden":"true"}),!n&&(0,t.jsx)("span",{className:"truncate",children:e.name})]}),!n&&p&&(0,t.jsxs)(h.DropdownMenu,{open:g,onOpenChange:b,children:[(0,t.jsx)(h.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button","aria-label":`Actions for ${e.name}`,className:(0,m.cn)("flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground",i||g?"opacity-100":"opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),onClick:e=>e.preventDefault(),children:x?(0,t.jsx)(d.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(c.MoreHorizontal,{className:"h-4 w-4"})})}),(0,t.jsx)(h.DropdownMenuContent,{align:"end",className:"w-44",children:(0,t.jsxs)(h.DropdownMenuItem,{onSelect:v,disabled:x,children:[(0,t.jsx)(u.Archive,{className:"h-4 w-4"}),"Archive team"]})})]})]})})}e.s(["SidebarTeamSwitcher",()=>b])},785856,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(975558),s=e.i(531278),i=e.i(387951),n=e.i(687246),l=e.i(176516),o=e.i(752044),c=e.i(37727),d=e.i(519455),u=e.i(624687),m=e.i(975157),h=e.i(967738),p=e.i(740693);let x="(prefers-reduced-motion: reduce)";function f(e){if("function"!=typeof window.matchMedia)return()=>{};let t=window.matchMedia(x);return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):()=>{}}function g(){return"function"==typeof window.matchMedia&&window.matchMedia(x).matches}function b({text:e}){return(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e})}function v({reduced:e}){return(0,t.jsxs)("p",{"data-testid":"thinking-indicator","aria-live":"polite",className:"flex items-center gap-2 text-sm font-semibold uppercase tracking-wide text-amber-600 dar
1k:text-amber-400",children:[(0,t.jsx)("span",{children:"Thinking"}),e?(0,t.jsx)("span",{"aria-hidden":"true",children:"..."}):(0,t.jsx)("span",{className:"inline-flex items-end gap-1","aria-hidden":"true",children:[0,1,2].map(e=>(0,t.jsx)("span",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-current",style:{animationDelay:`${.15*e}s`}},e))})]})}function j({progress:e}){let a=Array.from({length:Math.max(0,e.total)},(e,t)=>t),r=e.labels??[];return(0,t.jsx)("ol",{"data-testid":"stage-progress","aria-label":"Onboarding progress",className:"flex items-center justify-center gap-2",children:a.map(a=>{let s=a===e.index,i=a<e.index;return(0,t.jsxs)("li",{"data-active":s?"true":void 0,"data-done":i?"true":void 0,"aria-current":s?"step":void 0,className:"flex items-center gap-1.5",title:r[a],children:[(0,t.jsx)("span",{"aria-hidden":"true",className:(0,m.cn)("h-2 w-2 rounded-full transition-colors",s&&"scale-125 bg-amber-500 shadow-[0_0_8px_2px] shadow-amber-400/50",i&&"bg-amber-400/70",!s&&!i&&"bg-muted-foreground/30")}),r[a]&&(0,t.jsx)("span",{className:(0,m.cn)("hidden text-xs sm:inline",s?"text-foreground":"text-muted-foreground"),children:r[a]})]},a)})})}function w({open:e,messages:r,onClose:s}){return((0,a.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&s()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,s]),e)?(0,t.jsxs)("div",{className:"absolute inset-0 z-20 flex flex-col justify-end",children:[(0,t.jsx)("button",{type:"button","aria-label":"Dismiss transcript",onClick:s,className:"absolute inset-0 cursor-default bg-background/60 backdrop-blur-sm"}),(0,t.jsxs)("div",{role:"dialog","aria-label":"Conversation transcript","data-testid":"transcript",className:"relative max-h-[70%] overflow-y-auto rounded-t-2xl border border-border bg-background p-4 shadow-2xl",children:[(0,t.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold",children:"Transcript"}),(0,t.jsx)(d.Button,{type:"button",variant:"ghost",size:"icon",onClick:s,"aria-label":"Close transcript",children:(0,t.jsx)(c.X,{className:"h-4 w-4","aria-hidden":!0})})]}),0===r.length?(0,t.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Nothing said yet."}):(0,t.jsx)("ol",{className:"space-y-3",children:r.map((e,a)=>(0,t.jsxs)("li",{className:(0,m.cn)("flex flex-col gap-0.5"),children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:e.who}),(0,t.jsx)("span",{className:(0,m.cn)("whitespace-pre-wrap rounded-lg px-3 py-2 text-sm","user"===e.role?"self-end bg-primary text-primary-foreground":"self-start bg-muted text-foreground"),children:e.text})]},a))})]})]}):null}function y({messages:e,caption:c,state:x,awaiting:y,onUserUtterance:N,progress:k,banner:C,headerAction:S,footerHint:T,placeholder:E,voiceField:I="onboarding",className:L}){let[M,D]=(0,a.useState)(""),[P,R]=(0,a.useState)(!1),z=(0,a.useSyncExternalStore)(f,g,()=>!1),O=(0,a.useRef)(!!y);(0,a.useEffect)(()=>{O.current=!!y},[y]);let A=(0,a.useCallback)(async e=>{let t=e.trim();t&&!O.current&&(D(""),await N(t))},[N]),_=(0,p.useDictation)({onTranscription:e=>{A(e)},field:I}),B="recording"===_.status,F="transcribing"===_.status,$=!1===_.reachable,q=B?"listening":x,H="thinking"===q,K=$||!!y,U=K||F,V=(0,a.useCallback)(()=>{K||F||_.toggle()},[K,F,_]),J=(0,a.useCallback)(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),A(M))},[M,A]),W=!c.typing&&!z,X=function(e,t){let[r,s]=(0,a.useState)(t?"":e),[i,n]=(0,a.useState)({text:e,animate:t});return(i.text!==e||i.animate!==t)&&(n({text:e,animate:t}),s(t?"":e)),(0,a.useEffect)(()=>{if(!t||!e)return;let a=0,r=setInterval(()=>{s((a+=2)>=e.length?e:e.slice(0,a)),a>=e.length&&clearInterval(r)},18);return()=>clearInterval(r)},[e,t]),r}(c.text,W),Y=F?"Transcribing":"listening"===q?"Listening":"speaking"===q?"Speaking":$?"Type your answer":"Tap to talk, or type",G=$?"Voice input unavailable (transcription service unreachable)":B?"Stop recording":F?"Transcribing":"Start recording",Q=$?"Voice unavailable. Type below.":F?"Transcribing...":B?"Tap to stop":y?"":"Tap to talk",Z=$?n.MicOff:F?s.Loader2:B?o.Square:i.Mic;return(0,t.jsxs)("div",{className:(0,m.cn)("relative flex h-full min-h-0 w-full flex-col",L),children:[(S||k)&&(0,t.jsxs)("header",{className:"flex items-center justify-between gap-3 px-1 pb-2",children:[(0,t.jsx)("div",{className:"min-w-0 flex-1",children:k&&(0,t.jsx)(j,{progress:k})}),S&&(0,t.jsx)("div",{className:"shrink-0",children:S})]}),C&&(0,t.jsx)("div",{className:"px-1 pb-2",children:C}),(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4 py-4",children:[(0,t.jsx)("div",{className:"relative aspect-square w-full max-w-[min(52vh,20rem)]",children:(0,t.jsx)(h.CoachNebula,{state:q,amplitude:"listening"===q?_.amplitude:void 0})}),(0,t.jsxs)("div",{className:"flex min-h-[2rem] flex-col items-center gap-2 text-center",children:[H?(0,t.jsx)(v,{reduced:z}):(0,t.jsx)(b,{text:Y}),(0,t.jsxs)("div",{"aria-live":"polite","data-testid":"stage-caption",className:"min-h-[3.5rem] max-w-xl px-2",children:[c.who&&(0,t.jsx)("span",{className:"mr-1.5 text-sm font-semibold text-amber-600 dar
1k:text-amber-400",children:c.who}),(0,t.jsx)("span",{className:"whitespace-pre-wrap text-base text-foreground sm:text-lg",children:X})]})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,t.jsxs)("div",{className:"relative flex h-16 w-16 items-center justify-center",children:[B&&!z&&(0,t.jsx)("span",{"aria-hidden":"true",className:"absolute inset-0 rounded-full bg-red-500/25",style:{transform:`scale(${1+.7*_.amplitude})`}}),(0,t.jsx)("button",{type:"button",onClick:V,disabled:U,"aria-label":G,"aria-pressed":B,title:G,"data-testid":"mic-toggle","data-recording":B?"true":void 0,"data-unreachable":$?"true":void 0,className:(0,m.cn)("relative flex h-16 w-16 items-center justify-center rounded-full shadow-lg transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-400 focus-visible:ring-offset-2 focus-visible:ring-offset-background",B?"bg-red-500 text-white shadow-red-500/30":$?"cursor-not-allowed bg-muted text-muted-foreground shadow-none":"bg-amber-500 text-white shadow-amber-500/30 hover:bg-amber-600",U&&!B&&!$&&"opacity-50"),children:(0,t.jsx)(Z,{className:(0,m.cn)("h-6 w-6",F&&"animate-spin"),"aria-hidden":!0})})]}),(0,t.jsx)("span",{className:"h-4 text-xs text-muted-foreground",children:Q})]})]}),(0,t.jsxs)("div",{className:"border-t pt-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-end gap-2",children:[(0,t.jsx)(u.Textarea,{value:M,onChange:e=>D(e.target.value),onKeyDown:J,placeholder:E??"Type your answer, or tap the mic to talk","aria-label":"Your answer",rows:1,disabled:!!y,className:"min-h-[2.5rem] flex-1 resize-none"}),(0,t.jsx)(d.Button,{type:"button",onClick:()=>void A(M),disabled:!!y||!M.trim(),size:"icon","aria-label":"Send",children:(0,t.jsx)(r.ArrowUp,{className:"h-4 w-4","aria-hidden":!0})}),(0,t.jsx)(d.Button,{type:"button",variant:"outline",size:"icon",onClick:()=>R(!0),"aria-label":"Open transcript",title:"Transcript",children:(0,t.jsx)(l.ScrollText,{className:"h-4 w-4","aria-hidden":!0})})]}),T&&(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground",children:T})]}),(0,t.jsx)(w,{open:P,messages:e,onClose:()=>R(!1)})]})}e.s(["ConversationStage",()=>y])}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.