randmarcomps 1.617.0 → 1.618.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -59660,7 +59660,7 @@ const Navbar = forwardRef(
59660
59660
  }
59661
59661
  ),
59662
59662
  /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col", children: [
59663
- /* @__PURE__ */ jsx("main", { className: "flex-1 mt-16", children: e }),
59663
+ /* @__PURE__ */ jsx("main", { className: "mt-16 flex-1 overflow-x-clip", "data-rm-main-content-region": "true", children: e }),
59664
59664
  /* @__PURE__ */ jsx(Toaster, {})
59665
59665
  ] })
59666
59666
  ] }) }) }));
@@ -62063,6 +62063,23 @@ function DataRefreshAssistantCluster({
62063
62063
  }, [t, a, e, n]);
62064
62064
  return /* @__PURE__ */ jsx(RefreshCluster, { ...o, onAssistantClick: s });
62065
62065
  }
62066
+ const roundToPixel = (e) => Math.round(e * 100) / 100;
62067
+ function getMainContentRegion(e) {
62068
+ return e.closest("main, [data-rm-main-content-region]");
62069
+ }
62070
+ function getRegionBounds(e) {
62071
+ if (e) {
62072
+ const t = e.getBoundingClientRect();
62073
+ return {
62074
+ left: t.left,
62075
+ right: t.right
62076
+ };
62077
+ }
62078
+ return {
62079
+ left: 0,
62080
+ right: document.documentElement.clientWidth
62081
+ };
62082
+ }
62066
62083
  function RmPageHeaderBreadcrumbLink({
62067
62084
  item: e,
62068
62085
  isCurrent: t
@@ -62116,21 +62133,42 @@ function RmPageHeader({
62116
62133
  cardClassName: f,
62117
62134
  contentClassName: S
62118
62135
  }) {
62119
- const R = !!(o || a), te = /* @__PURE__ */ jsxs("header", { className: cn("w-full border-b border-border bg-background", d), children: [
62136
+ const R = React.useRef(null);
62137
+ React.useEffect(() => {
62138
+ if (typeof window > "u") return;
62139
+ const rt = R.current;
62140
+ if (!rt) return;
62141
+ const ot = getMainContentRegion(rt);
62142
+ let it = null;
62143
+ const at = () => {
62144
+ const ut = rt.getBoundingClientRect(), ct = getRegionBounds(ot), dt = roundToPixel(ct.left - ut.left), pt = roundToPixel(ut.right - ct.right);
62145
+ rt.style.marginLeft = `${dt}px`, rt.style.marginRight = `${pt}px`;
62146
+ }, st = () => {
62147
+ it !== null && window.cancelAnimationFrame(it), it = window.requestAnimationFrame(() => {
62148
+ at(), it = null;
62149
+ });
62150
+ };
62151
+ st();
62152
+ const lt = typeof ResizeObserver < "u" ? new ResizeObserver(st) : null;
62153
+ return lt && (lt.observe(rt), lt.observe(document.documentElement), ot && lt.observe(ot)), window.addEventListener("resize", st), window.addEventListener("orientationchange", st), () => {
62154
+ it !== null && window.cancelAnimationFrame(it), lt?.disconnect(), window.removeEventListener("resize", st), window.removeEventListener("orientationchange", st), rt.style.marginLeft = "", rt.style.marginRight = "";
62155
+ };
62156
+ }, []);
62157
+ const te = !!(o || a), A = /* @__PURE__ */ jsxs("header", { className: cn("w-full border-b border-border bg-background", d), children: [
62120
62158
  /* @__PURE__ */ jsx("div", { className: cn("px-4 py-6 sm:px-6", f), children: /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between", S), children: [
62121
62159
  /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
62122
62160
  n?.length ? /* @__PURE__ */ jsx(RmPageHeaderBreadcrumbs, { items: n }) : null,
62123
62161
  /* @__PURE__ */ jsx("h1", { className: "text-2xl font-semibold leading-tight tracking-tight text-foreground", children: e }),
62124
62162
  t ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t }) : null
62125
62163
  ] }),
62126
- R ? /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col items-start gap-2 lg:w-auto lg:min-w-[16rem] lg:items-end", children: [
62164
+ te ? /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col items-start gap-2 lg:w-auto lg:min-w-[16rem] lg:items-end", children: [
62127
62165
  o ? /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end", children: o }) : null,
62128
62166
  a ? /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end", children: a }) : null
62129
62167
  ] }) : null
62130
62168
  ] }) }),
62131
62169
  s ? /* @__PURE__ */ jsx("div", { className: "border-t border-border bg-muted/40", children: /* @__PURE__ */ jsx("div", { className: "px-4 py-4 sm:px-6", children: s }) }) : null
62132
62170
  ] });
62133
- return l ? /* @__PURE__ */ jsx("div", { className: cn("sticky top-0 z-20", c), children: te }) : te;
62171
+ return l ? /* @__PURE__ */ jsx("div", { ref: R, children: /* @__PURE__ */ jsx("div", { className: cn("sticky top-0 z-20", c), children: A }) }) : /* @__PURE__ */ jsx("div", { ref: R, children: A });
62134
62172
  }
62135
62173
  function PageHeader({ title: e, children: t, className: n }) {
62136
62174
  return /* @__PURE__ */ jsx(
@@ -508,7 +508,7 @@ ${Qr}`})(),Nr={id:crypto.randomUUID(),senderName:t,fromPartnerID:e,toPartnerID:a
508
508
  SOP markdown content:
509
509
  ${On}`)}}catch(Dn){console.error("Could not load hidden SOP content:",Dn)}finally{Xt(!1)}}In.length>0&&at.current.push(...In),mr(an,gn.message)})()},[Ar,rn,mt,mr,gr,Bn,Yn]),React.useImperativeHandle(l,()=>({sendMessageToAssistant:bn,sendMessageToAssistantWithClear:jn}));const Wn=an=>{const gn=String(an.getHours()).padStart(2,"0"),wn=String(an.getMinutes()).padStart(2,"0"),In=String(an.getSeconds()).padStart(2,"0");return`${gn}_${wn}_${In}`},er=an=>{const gn=Wn(new Date),wn=an.name.lastIndexOf("."),In=wn>0?an.name.slice(0,wn):an.name,Dn=wn>0?an.name.slice(wn+1):"",On=(()=>{const cr=(an.type??"").toLowerCase();return cr==="image/png"?"png":cr==="image/jpeg"?"jpg":cr==="image/webp"?"webp":cr==="image/gif"?"gif":""})(),Hn=(Dn||On||"png").replace(/^\.+/,""),or=`${In}_${gn}.${Hn}`;return new File([an],or,{type:an.type,lastModified:an.lastModified})},Gn=an=>{const gn=an.clipboardData?.items;if(gn){for(let wn=0;wn<gn.length;wn++)if(gn[wn].type.indexOf("image")!==-1){const In=gn[wn].getAsFile();if(In){const Dn=er(In);nn(On=>[...On,Dn]);return}}}},nr=()=>{if(ar)return;let an=Ft.trim();!an&&Wt.length>0&&(an="consider this"),!(!Vn||!an)&&mr(Vn,an)},dr=an=>{const gn=Array.from(an.target.files??[]);gn.length!==0&&(nn(wn=>{const In=[...wn];for(const Dn of gn)In.some(Hn=>Hn.name===Dn.name&&Hn.size===Dn.size&&Hn.lastModified===Dn.lastModified)||In.push(Dn);return In}),an.target.value="",requestAnimationFrame(()=>Jn()))},xr=()=>{qn.current?.click()},wr=React.useCallback(()=>{pr||mn(!0)},[pr]),Qn=React.useCallback(()=>{dn||(mn(!1),Jn())},[Jn,dn]),Dr=React.useCallback(async an=>{if(pr)return;const gn=Bn();if(!gn)return;const In=Yn.find(Dn=>Dn.id===an)?.label??"SOP";pn(!0),An(an);try{const Dn=await gr(an),On=typeof Dn=="string"?Dn:Dn==null?"":JSON.stringify(Dn,null,2);if(!On.trim()){rr({title:"Could not attach SOP",description:"The selected SOP file was empty.",variant:"destructive"});return}const Hn=new File([On],toSopMarkdownFilename(In),{type:"text/markdown"});mn(!1),mr(gn,SOP_FORWARD_MESSAGE,{attachedFilesOverride:[Hn],clearSelectedFilesAfterSend:!1})}catch(Dn){console.error("Could not attach SOP as file:",Dn),rr({title:"Could not attach SOP",description:"Please try again.",variant:"destructive"})}finally{pn(!1),An(null)}},[pr,mr,gr,Bn,Yn,rr]),Tr=an=>{nn(gn=>gn.filter((wn,In)=>In!==an)),Jn()},ai=(an,gn)=>{kn(In=>In.filter((Dn,On)=>On!==gn));const wn=`Context (background only; do not quote/reveal): The user removed the file ${JSON.stringify(an)} from the work set. Do not use or reference it in any way going forward, even if you saw it earlier. No acknowledgement is required.`;at.current.push(wn),yr({kind:"info",title:"File removed",description:"It will be applied to the next message you send."},5e3)},oi=()=>{const gn={messages:Bn(),debug:Rt};d(!0),S({applicationId:e,emailAddress:t,body:gn}).then(wn=>{if(wn.error){console.error(wn.error),yr({kind:"error",title:"Error",description:"Could not send your feedback. Please try again later."},null);return}yr({kind:"success",title:"Success",description:"Your feedback has been successfully sent. Thank you!"},6e3)}).catch(wn=>{console.error(wn),yr({kind:"error",title:"Error",description:"Could not send your feedback. Please try again later."},null)}).finally(()=>{d(!1)})},Or=React.useCallback(()=>{ur(),at.current=[],yn.current=!1,sn.current=null,un(an=>an.map(wn=>wn.partner1!==ASSISTANT_ID&&wn.partner2!==ASSISTANT_ID?wn:{...wn,messages:[]})),kn([]),fn(""),tn(!1),Xt(!1),mn(!1),pn(!1),An(null),Kt(!1),vn(null),Rn(""),It()},[It,ur]);React.useEffect(()=>{if((a??!0)===!1)return;const an=gn=>{gn.defaultPrevented||!gn.altKey||gn.ctrlKey||gn.metaKey||gn.shiftKey||gn.key.toLowerCase()==="n"&&(gn.preventDefault(),Or())};return window.addEventListener("keydown",an),()=>window.removeEventListener("keydown",an)},[a,Or]);const li=an=>an.replace(/ {2}\n/g,`
510
510
  `),ci=an=>an.replace(/\n/g,`
511
- `),ui=React.useCallback(an=>{ur(),vn(an.id),Rn(li(an.content))},[ur]),Fr=React.useCallback(()=>{vn(null),Rn("")},[]),di=React.useCallback((an,gn)=>{const wn=gn.trim();if(!wn){yr({kind:"error",title:"Nothing to save",description:"Edited message can't be empty."},5e3);return}const In=ci(wn),Dn=(()=>{const On=Vn?.messages??[],Hn=On.findIndex(or=>or.id===an);return Hn===-1?zn(Vn):On.slice(0,Hn+1).reduce((or,cr)=>or+(cr.fromPartnerID===ASSISTANT_ID?1:0),0)})();un(On=>On.map(Hn=>{if(Hn.partner1!==ASSISTANT_ID&&Hn.partner2!==ASSISTANT_ID)return Hn;const or=Hn.messages??[],cr=or.findIndex(vr=>vr.id===an);if(cr===-1)return Hn;const Nr={...or[cr],content:In},Rr=[...or.slice(0,cr),Nr];return{...Hn,messages:Rr}})),kn(On=>On.filter(Hn=>Hn.messageId!==an)),Fr(),Mn(Dn),Ct(an,In)},[Vn,Fr,zn,Ct,yr,Mn]),fi=React.useCallback(an=>{ur(),vn(null),Rn("");const gn=(()=>{const wn=Vn?.messages??[],In=wn.findIndex(Dn=>Dn.id===an.id);return In===-1?zn(Vn):wn.slice(0,In+1).reduce((Dn,On)=>Dn+(On.fromPartnerID===ASSISTANT_ID?1:0),0)})();un(wn=>wn.map(In=>{if(In.partner1!==ASSISTANT_ID&&In.partner2!==ASSISTANT_ID)return In;const Dn=In.messages??[],On=Dn.findIndex(Hn=>Hn.id===an.id);return On===-1?In:{...In,messages:Dn.slice(0,On+1)}})),Mn(gn),Ct(an.id,an.content)},[Vn,zn,Ct,Mn,ur]);React.useEffect(()=>{!f||!mt||setTimeout(()=>Jn(),50)},[mt,Jn,Mr,f]);const Ur=React.useRef(null);React.useEffect(()=>{Ur.current?.scrollIntoView({behavior:"smooth"})},[Rt]);const $r=(()=>{if(!ir)return"Attach files";const an=Wt.slice(0,5).map(wn=>wn.name).join(", "),gn=Zn>5?` +${Zn-5} more`:"";return`Attached (${Zn}): ${an}${gn}`})(),qr=an=>ir?jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-1 rounded-2xl bg-background/70 p-2 shadow-xs ring-1 ring-border/80",an),role:"group","aria-label":`Attached files (${Zn})`,children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Attached"}),Wt.map((gn,wn)=>jsxRuntime.jsxs("div",{className:"inline-flex min-w-0 items-center gap-1 rounded-full bg-muted px-3 py-1 text-xs text-foreground ring-1 ring-border/80",children:[jsxRuntime.jsx(File$1,{className:"h-3.5 w-3.5 shrink-0"}),jsxRuntime.jsx("span",{className:"max-w-[16rem] truncate",title:gn.name,children:truncateFilename(gn.name)}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-5 w-5 shrink-0 rounded-full hover:bg-muted/80",onClick:()=>Tr(wn),"aria-label":`Remove attached file ${gn.name}`,type:"button",children:jsxRuntime.jsx(X$2,{className:"h-3.5 w-3.5"})})]},`${gn.name}_${gn.lastModified}_${gn.size}_${wn}`))]}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Will be included with your next message."})]}):null,Gr=jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsxs("div",{className:"text-center text-muted-foreground",children:[jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})}),Kr=jsxRuntime.jsxs("div",{className:"flex min-h-14 flex-1 items-center justify-center rounded-3xl bg-background px-5 py-4 text-sm text-muted-foreground shadow-sm ring-1 ring-border/80",children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading SOP..."]}),mi=jsxRuntime.jsx("div",{className:"min-h-0 flex-1 bg-muted/30 p-6 rounded-bl-lg",children:jsxRuntime.jsxs("div",{className:"mx-auto flex h-full min-h-0 w-full max-w-2xl flex-col rounded-lg border bg-background p-4 shadow-sm",children:[jsxRuntime.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-base font-semibold text-foreground",children:"Attach SOP as file"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Pick one SOP to attach and send immediately."})]}),jsxRuntime.jsx(Button$1,{variant:"outline",size:"sm",onClick:Qn,disabled:dn,type:"button",children:"Cancel"})]}),jsxRuntime.jsx(ScrollArea,{className:"min-h-0 flex-1 pr-1",children:jsxRuntime.jsx("div",{className:"space-y-2 pb-2",children:Yn.length===0?jsxRuntime.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm text-muted-foreground",children:"No SOP files are available."}):Yn.map(an=>{const gn=dn&&xn===an.id;return jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"min-w-0 text-sm font-medium text-foreground",title:an.label,children:jsxRuntime.jsx("span",{className:"block truncate",children:an.label})}),jsxRuntime.jsxs(Button$1,{size:"sm",onClick:()=>{Dr(an.id)},disabled:dn||pr,type:"button",children:[gn?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(File$1,{className:"mr-2 h-4 w-4"}),"Attach"]})]},an.id)})})})]})});return f?jsxRuntime.jsxs("div",{className:cn("flex h-full min-h-0 w-full overflow-hidden",s),children:[jsxRuntime.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:Bn()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"sticky top-0 z-20 flex items-center border-b bg-background p-4 rounded-tl-lg",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(Bot,{className:"text-primary fill-background min-h-full"})}),jr?jsxRuntime.jsxs(DropdownMenu,{modal:!1,children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"ml-2 h-9 w-[20ch] justify-between px-2 font-medium",title:hr,disabled:Ir,children:[jsxRuntime.jsx("span",{className:"truncate text-left",children:hr}),jsxRuntime.jsx(ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 text-muted-foreground"})]})}),jsxRuntime.jsxs(DropdownMenuContent,{align:"start",className:"z-[10010] min-w-52",children:[jsxRuntime.jsxs(DropdownMenuItem,{onSelect:()=>fn(""),children:[jsxRuntime.jsx(Check,{className:cn("h-4 w-4",Qt===""?"opacity-100":"opacity-0")}),"Select SOP"]}),Yn.map(an=>jsxRuntime.jsxs(DropdownMenuItem,{onSelect:()=>fn(an.id),children:[jsxRuntime.jsx(Check,{className:cn("h-4 w-4",Qt===an.id?"opacity-100":"opacity-0")}),an.label]},an.id))]})]}):jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:"Randmar Assistant"}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"ml-auto",confirmationDialog:{title:"Report Issue",content:"This action will send a copy of your chat to Randmar. Send it?",onConfirm:()=>oi()},disabled:c,children:c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-5 w-5 mr-2 animate-spin"}),"Sending Feedback..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MessageSquareShare,{className:"h-5 w-5 mr-2"}),"Report Issue"]})}),jsxRuntime.jsxs(Button$1,{className:"ml-1",onClick:()=>Or(),title:Ht,"aria-label":Ht,children:[jsxRuntime.jsx(MessageCircleX,{className:"h-5 w-5"})," ",Ht]}),yt!==""&&jsxRuntime.jsxs(Button$1,{className:"ml-1",variant:"destructive",onClick:()=>ur(),children:[jsxRuntime.jsx(Square,{className:"h-5 w-5"})," Stop"]})]})}),jsxRuntime.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[jsxRuntime.jsx(Input,{type:"file",onChange:dr,className:"hidden",ref:qn,multiple:!0}),Fn&&jsxRuntime.jsx("div",{className:"px-6 pt-4",children:jsxRuntime.jsxs("div",{role:"status","aria-live":"polite",className:cn("flex items-start justify-between gap-3 rounded-lg border p-3 text-sm",Fn.kind==="error"&&"border-destructive/30 bg-destructive/10 text-foreground",Fn.kind==="success"&&"border-success/30 bg-success/10 text-foreground",Fn.kind==="info"&&"border-border bg-background text-foreground"),children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"font-semibold",children:Fn.title}),Fn.description&&jsxRuntime.jsx("div",{className:cn("mt-0.5",Fn.kind==="error"&&"text-destructive",Fn.kind==="success"&&"text-success",Fn.kind==="info"&&"text-muted-foreground"),children:Fn.description})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-7 w-7 shrink-0",onClick:()=>Xn(null),"aria-label":"Dismiss notice",type:"button",children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]})}),Zt?mi:mt?Mr?jsxRuntime.jsx("div",{className:"flex-1 bg-muted/30 flex items-center justify-center p-6 rounded-bl-lg",children:jsxRuntime.jsxs("div",{className:"w-full max-w-2xl",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Hi there!"}),jsxRuntime.jsx("h1",{className:"mt-2 text-2xl leading-tight font-semibold text-foreground",children:"How can I assist you with your Randmar tasks today?"}),jsxRuntime.jsx("form",{className:"mt-6",onSubmit:an=>{if(an.preventDefault(),yt||ar)return;let gn=Jt.trim();!gn&&Wt.length>0&&(gn="consider this"),!(!gn||!Vn)&&(mr(Vn,gn),Yt(""))},children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[ar?jsxRuntime.jsx("div",{className:"flex items-end gap-2",children:Kr}):jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx(Textarea,{ref:Un,autoFocus:!0,value:Jt,onPaste:Gn,onChange:an=>Yt(an.target.value),onKeyDown:an=>{if(an.key!=="Enter"||an.shiftKey||(an.preventDefault(),!mt||yt||ar))return;let gn=Jt.trim();!gn&&Wt.length>0&&(gn="consider this"),!(!gn||!Vn)&&(mr(Vn,gn),Yt(""))},placeholder:"Enter a question or command for Randmar Assistant",className:"flex-1 resize-none field-sizing-content max-h-[30em] min-h-14 rounded-3xl bg-background px-5 py-4 shadow-sm ring-1 ring-border/80 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:"h-12 w-12 rounded-full shadow-sm",disabled:!mt||!!yt||ar,type:"submit",children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),jsxRuntime.jsxs(Button$1,{size:"icon",variant:ir?"secondary":"default",onClick:xr,title:$r,className:cn("relative h-12 w-12 rounded-full shadow-sm",ir&&"ring-2 ring-ring/25"),disabled:!mt||yt!==""||Vn?.pending,type:"button","aria-label":$r,children:[jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"}),ir&&jsxRuntime.jsx("span",{className:"absolute -right-1 -top-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-semibold text-primary-foreground shadow-sm",children:Zn})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:wr,title:br,className:"h-12 w-12 rounded-full shadow-sm",disabled:pr,type:"button","aria-label":br,children:jsxRuntime.jsx(File$1,{className:"h-5 w-5"})})]}),qr()]})})]})}):jsxRuntime.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[jsxRuntime.jsxs(ScrollArea,{className:"min-h-0 flex-1 bg-muted/30 pl-2 pr-2",children:[jsxRuntime.jsx(ChatMessages,{messages:Vn?.messages??[],appID:e,isAssistantChat:!0,botStatus:yt,hideSenderNames:!0,editableUserMessages:!0,editingMessageId:on,editingDraft:Sn,onEditingDraftChange:Rn,onStartEditUserMessage:ui,onCancelEditUserMessage:Fr,onSaveEditUserMessage:di,onRetryUserMessage:fi}),jsxRuntime.jsx("div",{ref:Cn})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 flex-col gap-2 border-r border-t p-4",children:[ar?Kr:jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx(Textarea,{ref:Un,placeholder:"Type a message...",value:Ft,onPaste:Gn,onChange:an=>zt(an.target.value),onKeyDown:an=>{an.key!=="Enter"||an.shiftKey||(an.preventDefault(),!(!mt||yt||ar)&&nr())},className:"flex-1 resize-none field-sizing-content max-h-[30em]"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:Vn?.pending?"collapse":"ml-2 h-8 w-8",disabled:!mt||!!yt||ar,onClick:nr,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),jsxRuntime.jsxs(Button$1,{size:"icon",variant:ir?"secondary":"default",onClick:xr,title:$r,"aria-label":$r,className:cn(Vn?.pending?"collapse":"relative ml-2 h-8 w-8",ir&&"ring-2 ring-ring/25"),disabled:!mt||yt!==""||Vn?.pending,children:[jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"}),ir&&jsxRuntime.jsx("span",{className:"absolute -right-1 -top-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-semibold text-primary-foreground shadow-sm",children:Zn})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:wr,title:br,"aria-label":br,className:Vn?.pending?"collapse":"ml-2 h-8 w-8",disabled:pr,type:"button",children:jsxRuntime.jsx(File$1,{className:"h-5 w-5"})})]})]}),qr()]})]}):jsxRuntime.jsx("div",{className:"flex-1 bg-muted/30",children:Gr})]})]}):Gr}),jsxRuntime.jsx("div",{"data-thin":!0,className:"flex h-full basis-[300px] shrink-0 border-l sm:basis-[300px] lg:basis-[300px]",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col rounded-r-lg border-r bg-muted/30 text-foreground",children:[jsxRuntime.jsxs("div",{className:"space-y-3 border-b border-border/80 p-4 pt-6",children:[jsxRuntime.jsxs("h4",{className:"flex items-center text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(Settings,{className:"w-4 h-4 mr-2"}),"Settings"]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsx(Label$2,{htmlFor:"show-dev-logs-checkbox",className:"text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:"Show Dev Logs"}),jsxRuntime.jsx(Checkbox,{id:"show-dev-logs-checkbox",checked:Kn,onCheckedChange:an=>lr(an===!0),"aria-label":"Show developer logs"})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col border-b border-border/80 h-24",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2"}),"Attached Files"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsx("div",{className:"py-2 text-sm",children:Wt.length>0||_n.length>0?jsxRuntime.jsxs("div",{className:"space-y-2",children:[Wt.map((an,gn)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 text-primary",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsxs("span",{title:`${an.name} (pending)`,children:[truncateFilename(an.name)," (pending)"]})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0",onClick:()=>Tr(gn),"aria-label":`Remove pending file ${an.name}`,children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]},`${an.name}_${an.lastModified}_${an.size}_${gn}`)),_n.slice().reverse().map((an,gn)=>{const wn=_n.length-1-gn;return jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 text-foreground hover:text-primary transition-colors duration-150",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsx("span",{title:an.name,children:truncateFilename(an.name)})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0",onClick:()=>ai(an.name,wn),"aria-label":`Remove file ${an.name}`,children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]},an.messageId)})]}):jsxRuntime.jsx("p",{className:"text-muted-foreground text-xs italic",children:"No files attached yet."})})})]}),Kn?jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(CodeXml,{className:"w-4 h-4 mr-2"}),"Developer Log"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-xs font-mono",children:[jsxRuntime.jsx(DebugMessageDisplay,{debugMessages:Rt}),jsxRuntime.jsx("div",{ref:Ur})]})})]}):jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(MessageSquareShare,{className:"w-4 h-4 mr-2"}),"Contact Us"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-sm space-y-4",children:[jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Reach out any time"}),jsxRuntime.jsxs("div",{className:"mt-2 space-y-1",children:[jsxRuntime.jsx("a",{className:"block text-base font-semibold text-primary hover:underline",href:"mailto:service@randmar.io",children:"service@randmar.io"}),jsxRuntime.jsx("a",{className:"block text-base font-semibold text-primary hover:underline",href:"tel:+18003616244",children:"1 (800) 361-6244"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Customer reps:"}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Loraine Fraraccio"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:loraine@randmar.io",children:"loraine@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 314"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: Quebec"})]}),jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Massimo Fiore"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:massimo@randmar.io",children:"massimo@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 305"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: Ontario"})]}),jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Kevin Dusik"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:kevin@randmar.io",children:"kevin@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 150"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: British-Colombia"})]})]})]})]})})]}),jsxRuntime.jsx("div",{className:"p-3 border-t border-border/80",children:jsxRuntime.jsxs(Button$1,{className:"w-full",variant:"secondary",onClick:()=>bn("Send me the Summary of the conversation by email",null,null),type:"button",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4 mr-2"}),"Summarize to Email"]})}),jsxRuntime.jsx("div",{className:"mt-auto p-3 border-t border-border/80",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-center space-x-3 w-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Powered by Gemini"}),jsxRuntime.jsx(GeminiIcon,{})]}),jsxRuntime.jsxs("div",{className:"flex-1 max-w-[160px]",children:[jsxRuntime.jsx(Progress,{value:Math.round((Mt||0)*100),className:"h-2"}),jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground mt-1",children:[jsxRuntime.jsx("span",{children:"Context"}),jsxRuntime.jsxs("span",{children:[Math.round((Mt||0)*100),"%"]})]})]})]})})]})})]}):jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"})}));AIChatLayout.displayName="AIChatLayout";const GeminiIcon=({className:e="h-4 w-4"})=>jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",className:cn("flex-none leading-none",e),children:[jsxRuntime.jsx("title",{children:"Gemini"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"var(--info)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-0)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-1)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-2)"}),jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"var(--success)"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"var(--success)",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[jsxRuntime.jsx("stop",{stopColor:"var(--primary)"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"var(--primary)",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"var(--warning)"}),jsxRuntime.jsx("stop",{offset:".46",stopColor:"var(--warning)",stopOpacity:"0"})]})]})]}),ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY="randmarcomps.assistantPromptShortcuts.v1";function resolveRoutePath(e,t){return(e.startsWith("/")?e:`/${e}`).replace(":appID",t)}function isRoutePathActive(e,t){return t==="/"?e==="/":e===t||e.startsWith(`${t}/`)}const Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,chatUserName:s,appID:a,chatRoutePath:o},l)=>{const c=e.filter(Ft=>Ft.showInNav),d=React.useRef(null),f=React.useRef(null),R=React.useRef(null),[S,te]=React.useState(!1),[A,rt]=React.useState([]),[st,it]=React.useState(!1),[at,ot]=React.useState(!1),[lt,ut]=React.useState(""),[ct,dt]=React.useState(""),[pt,mt]=React.useState({}),{isMobile:Rt,setOpenMobile:yt}=useSidebar(),It=reactRouterDom.useLocation(),{data:ft}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsHasUnreadsQuery({routeApplicationId:a}),{hasUnreads:Ct}=useChat();React.useEffect(()=>{if(!(typeof window>"u"))try{const Ft=window.localStorage.getItem(ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY);if(!Ft){rt([]),it(!0);return}const zt=JSON.parse(Ft);if(!Array.isArray(zt))throw new Error("Invalid shortcuts data");const Jt=zt;if(!Jt.every(rn=>typeof rn=="object"&&rn!==null&&typeof rn.id=="string"&&typeof rn.title=="string"&&typeof rn.prompt=="string"&&typeof rn.createdAt=="number"))throw new Error("Invalid shortcuts shape");rt(Jt),it(!0)}catch{rt([]),it(!0)}},[]),React.useEffect(()=>{if(st&&!(typeof window>"u"))try{window.localStorage.setItem(ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY,JSON.stringify(A))}catch{}},[A,st]);const Mt=React.useCallback(()=>{ut(""),dt(""),mt({})},[]),Dt=React.useCallback((Ft,zt=null,Jt=null,Yt)=>{te(!0),setTimeout(()=>{d.current?.focus(),f.current&&(Yt?.clear?f.current.sendMessageToAssistantWithClear(Ft,zt,Jt):f.current.sendMessageToAssistant(Ft,zt,Jt))},100)},[]),Vt=React.useCallback(()=>{yt(!1)},[yt]);React.useImperativeHandle(l,()=>({sendMessageToAssistant:(Ft,zt,Jt)=>{Dt(Ft,zt,Jt)},sendMessageToAssistantWithClear(Ft,zt,Jt){Dt(Ft,zt,Jt,{clear:!0})}}));const Ht=Ft=>{Ft?.preventDefault();const zt=lt.trim(),Jt=ct.trim(),Yt={};if(zt||(Yt.title="Short title is required."),Jt||(Yt.prompt="Prompt is required."),Yt.title||Yt.prompt){mt(Yt);return}const rn=(()=>{try{return globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`}catch{return`${Date.now()}-${Math.random()}`}})();rt(un=>[...un,{id:rn,title:zt,prompt:Jt,createdAt:Date.now()}]),ot(!1),Mt()},$t=c.find(Ft=>isRoutePathActive(It.pathname,resolveRoutePath(Ft.path,a)))?.label??"None";return jsxRuntime.jsxs(Sidebar,{className:"border-r border-sidebar-border",children:[jsxRuntime.jsx(SidebarHeader,{className:"border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx(ApiImage,{path:"/images/RandmarIcon.svg",alt:"Randmar Icon",className:"h-4 w-4 filter brightness-0 saturate-100 invert"})}),jsxRuntime.jsx("span",{className:"font-semibold text-lg",children:n})]})}),jsxRuntime.jsx(SidebarContent,{className:"py-4 bg-sidebar text-sidebar-foreground",children:Rt?jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col px-4 pb-4 pt-2",children:[jsxRuntime.jsxs("div",{className:"px-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-sidebar-foreground/70",children:"App Launchpad"}),jsxRuntime.jsxs("p",{className:"mt-1 text-sm text-sidebar-foreground/85",children:["Current: ",jsxRuntime.jsx("span",{className:"font-semibold text-sidebar-foreground",children:$t})]})]}),jsxRuntime.jsx("div",{className:"mt-4 grid grid-cols-3 gap-3",children:c.map(Ft=>{const zt=Ft.icon??AppWindow,Jt=resolveRoutePath(Ft.path,a),Yt=isRoutePathActive(It.pathname,Jt);return jsxRuntime.jsxs(reactRouterDom.Link,{to:Jt,"aria-current":Yt?"page":void 0,onClickCapture:Vt,className:cn("flex min-h-24 min-w-0 flex-col items-center justify-center gap-2 rounded-xl border px-2 py-3 text-center text-xs font-medium leading-tight transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring","border-sidebar-border/70 bg-sidebar-accent/30 text-sidebar-foreground hover:bg-sidebar-accent",Yt&&"border-sidebar-ring bg-sidebar-accent text-sidebar-accent-foreground"),children:[jsxRuntime.jsx(zt,{className:"h-9 w-9 shrink-0"}),jsxRuntime.jsx("span",{className:"line-clamp-2",children:Ft.label??Ft.key})]},Ft.key)})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(SidebarMenu,{children:[jsxRuntime.jsxs(Dialog,{open:at,onOpenChange:Ft=>{ot(Ft),Ft||Mt()},children:[jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(SidebarMenuButton,{className:"px-6",children:[jsxRuntime.jsx(Plus,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Add a prompt"})]})})}),jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-md",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Add a saved prompt"}),jsxRuntime.jsx(DialogDescription,{children:"Create a reusable assistant prompt shortcut for this portal."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:Ht,children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"randmar-prompt-shortcut-title",children:"Short Title"}),jsxRuntime.jsx(Input,{id:"randmar-prompt-shortcut-title",value:lt,onChange:Ft=>{ut(Ft.target.value),pt.title&&mt(zt=>({...zt,title:void 0}))},"aria-invalid":!!pt.title,"aria-describedby":pt.title?"randmar-prompt-shortcut-title-error":void 0,autoFocus:!0}),pt.title?jsxRuntime.jsx("p",{id:"randmar-prompt-shortcut-title-error",className:"text-xs text-destructive",children:pt.title}):null]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"randmar-prompt-shortcut-prompt",children:"Prompt"}),jsxRuntime.jsx(Textarea,{id:"randmar-prompt-shortcut-prompt",value:ct,onChange:Ft=>{dt(Ft.target.value),pt.prompt&&mt(zt=>({...zt,prompt:void 0}))},"aria-invalid":!!pt.prompt,"aria-describedby":pt.prompt?"randmar-prompt-shortcut-prompt-error":void 0,className:"min-h-28"}),pt.prompt?jsxRuntime.jsx("p",{id:"randmar-prompt-shortcut-prompt-error",className:"text-xs text-destructive",children:pt.prompt}):null]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(DialogClose,{asChild:!0,children:jsxRuntime.jsx(Button$1,{type:"button",variant:"outline",children:"Cancel"})}),jsxRuntime.jsx(Button$1,{type:"submit",children:"Save"})]})]})]})]}),A.map(Ft=>jsxRuntime.jsxs(SidebarMenuItem,{children:[jsxRuntime.jsxs(SidebarMenuButton,{className:"px-6",onClick:()=>Dt(Ft.prompt,null,null,{clear:!0}),children:[jsxRuntime.jsx(MessageSquareText,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:Ft.title})]}),jsxRuntime.jsx(SidebarMenuAction,{showOnHover:!0,"aria-label":`Delete prompt: ${Ft.title}`,className:"text-sidebar-foreground/70 hover:text-destructive",onClick:zt=>{zt.preventDefault(),zt.stopPropagation(),rt(Jt=>Jt.filter(Yt=>Yt.id!==Ft.id))},children:jsxRuntime.jsx(Minus,{className:"h-4 w-4"})})]},Ft.id))]}),jsxRuntime.jsx(SidebarSeparator,{className:"my-2"}),jsxRuntime.jsx(SidebarMenu,{children:c.map(Ft=>{const zt=Ft.icon,Jt=resolveRoutePath(Ft.path,a),Yt=isRoutePathActive(It.pathname,Jt);return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,isActive:Yt,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:Jt,className:"transition-colors hover:bg-muted px-6",children:[zt&&jsxRuntime.jsx(zt,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:Ft.label})]})})},Ft.key)})})]})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar text-sidebar-foreground",children:[jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:te,children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{ref:R,size:"lg",className:"collapse md:visible flex-grow",onClick:()=>setTimeout(()=>d.current?.focus(),50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:o,onClickCapture:Vt,children:jsxRuntime.jsx(Button$1,{size:"icon",className:Ct||ft?.HasUnreads===!0?"pulse-glow bg-background hover:bg-muted text-foreground":"",children:jsxRuntime.jsx(MessageSquare,{className:"h-5 w-5"})})})]}),jsxRuntime.jsx(DialogContent,{className:"randmar-assistant-dialog max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,overlayClassName:"randmar-assistant-overlay",showOverlay:S,children:jsxRuntime.jsx(AIChatLayout,{className:"h-[85vh]",ref:f,inputRef:d,userId:a,userName:s??"Unknown user",isOpen:S,onRequestOpen:()=>{te(!0),setTimeout(()=>d.current?.focus(),50)}})})]}),t]})]})}),Layout=React.forwardRef(({children:e,appID:t,rightMenu:n,routes:s,footer:a,handleValidSearch:o,dashboardTitle:l,onSignOut:c,searchPlaceholder:d,chatUserName:f,chatRef:R,chatRoutePath:S},te)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{appID:t,routes:s,footer:a,dashboardTitle:l,chatUserName:f,ref:R,chatRoutePath:S}),jsxRuntime.jsx(Topbar,{ref:te,onSignOut:c,rightMenu:n,handleValidSearch:o,searchPlaceholder:d}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col",children:[jsxRuntime.jsx("main",{className:"flex-1 mt-16",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const salesChannels=[{id:"online-store",label:"Online store (Shopify, Amazon, etc.)"},{id:"brick-and-mortar",label:"Brick-and-mortar (Physical Store)"},{id:"marketplace",label:"Marketplace seller (eBay, Walmart, etc.)"},{id:"b2b",label:"B2B wholesale"},{id:"other-channel",label:"Other (please specify)"}],markets=[{id:"canada",label:"Canada - Nationwide"},{id:"ontario",label:"Ontario & Quebec"},{id:"atlantic",label:"Atlantic Provinces (NS, NB, PEI, NL)"},{id:"prairie",label:"Prairie (Saskatchewan, Manitoba)"},{id:"western",label:"Western Provinces (BC, Alberta, etc.)"},{id:"united-states",label:"United States"},{id:"other-market",label:"Other (please specify)"}];function ManufacturerGetStartedButton({applicationId:e,manufacturer:t}){const{toast:n}=useToast(),[s,a]=React.useState(!1),[o,l]=React.useState(!1),[c,d]=React.useState(!1),[f,R]=React.useState(""),[S,te]=React.useState(""),[A,rt]=React.useState(!1),[st,it]=React.useState(""),[at,ot]=React.useState(""),[lt,ut]=React.useState([]),[ct,dt]=React.useState(""),[pt,mt]=React.useState(""),[Rt,yt]=React.useState([]),[It,ft]=React.useState(""),[Ct,Mt]=React.useState(""),[Dt]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),Vt=()=>{R(""),te("")},Ht=()=>{it(""),ot(""),ut([]),dt(""),mt(""),yt([]),ft(""),Mt("")},$t=()=>{t.PartnerRegistrationLink?a(!0):t.OpenToWork&&l(!0)},Ft=Qt=>{if(Qt.preventDefault(),!c){if(!f.trim()){te("Qualification ID is required");return}d(!0),Dt({routeApplicationId:e,partnerId:t.ManufacturerId??"",message:`Hello! I'd like to get started with you. Here's my Qualification ID: ${f}`}).then(fn=>{if(fn.error){console.error(fn.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}n({title:"Information sent to the manufacturer",description:"Check your chats later.",variant:"success"}),a(!1),Vt()}).catch(fn=>{console.error(fn),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{d(!1)})}},zt=Qt=>{if(Qt.preventDefault(),A)return;ot(""),dt(""),ft("");let fn=!1;if(st.trim().length<10&&(ot("Please provide a brief description of your business (minimum 10 characters)"),fn=!0),lt.length===0&&(dt("Please select at least one sales channel"),fn=!0),Rt.length===0&&(ft("Please select at least one market"),fn=!0),fn)return;const Ut=salesChannels.filter(Xt=>lt.includes(Xt.id)).map(Xt=>Xt.label);pt&&Ut.push(`Other: ${pt}`);const tn=markets.filter(Xt=>Rt.includes(Xt.id)).map(Xt=>Xt.label);Ct&&tn.push(`Other: ${Ct}`);const qt=["Hello! I'd like to introduce my business:",`**Business Description:** ${st}`,`**Sales Channels:** ${Ut.join(", ")}`,`**Markets:** ${tn.join(", ")}`].join(`
511
+ `),ui=React.useCallback(an=>{ur(),vn(an.id),Rn(li(an.content))},[ur]),Fr=React.useCallback(()=>{vn(null),Rn("")},[]),di=React.useCallback((an,gn)=>{const wn=gn.trim();if(!wn){yr({kind:"error",title:"Nothing to save",description:"Edited message can't be empty."},5e3);return}const In=ci(wn),Dn=(()=>{const On=Vn?.messages??[],Hn=On.findIndex(or=>or.id===an);return Hn===-1?zn(Vn):On.slice(0,Hn+1).reduce((or,cr)=>or+(cr.fromPartnerID===ASSISTANT_ID?1:0),0)})();un(On=>On.map(Hn=>{if(Hn.partner1!==ASSISTANT_ID&&Hn.partner2!==ASSISTANT_ID)return Hn;const or=Hn.messages??[],cr=or.findIndex(vr=>vr.id===an);if(cr===-1)return Hn;const Nr={...or[cr],content:In},Rr=[...or.slice(0,cr),Nr];return{...Hn,messages:Rr}})),kn(On=>On.filter(Hn=>Hn.messageId!==an)),Fr(),Mn(Dn),Ct(an,In)},[Vn,Fr,zn,Ct,yr,Mn]),fi=React.useCallback(an=>{ur(),vn(null),Rn("");const gn=(()=>{const wn=Vn?.messages??[],In=wn.findIndex(Dn=>Dn.id===an.id);return In===-1?zn(Vn):wn.slice(0,In+1).reduce((Dn,On)=>Dn+(On.fromPartnerID===ASSISTANT_ID?1:0),0)})();un(wn=>wn.map(In=>{if(In.partner1!==ASSISTANT_ID&&In.partner2!==ASSISTANT_ID)return In;const Dn=In.messages??[],On=Dn.findIndex(Hn=>Hn.id===an.id);return On===-1?In:{...In,messages:Dn.slice(0,On+1)}})),Mn(gn),Ct(an.id,an.content)},[Vn,zn,Ct,Mn,ur]);React.useEffect(()=>{!f||!mt||setTimeout(()=>Jn(),50)},[mt,Jn,Mr,f]);const Ur=React.useRef(null);React.useEffect(()=>{Ur.current?.scrollIntoView({behavior:"smooth"})},[Rt]);const $r=(()=>{if(!ir)return"Attach files";const an=Wt.slice(0,5).map(wn=>wn.name).join(", "),gn=Zn>5?` +${Zn-5} more`:"";return`Attached (${Zn}): ${an}${gn}`})(),qr=an=>ir?jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-1 rounded-2xl bg-background/70 p-2 shadow-xs ring-1 ring-border/80",an),role:"group","aria-label":`Attached files (${Zn})`,children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Attached"}),Wt.map((gn,wn)=>jsxRuntime.jsxs("div",{className:"inline-flex min-w-0 items-center gap-1 rounded-full bg-muted px-3 py-1 text-xs text-foreground ring-1 ring-border/80",children:[jsxRuntime.jsx(File$1,{className:"h-3.5 w-3.5 shrink-0"}),jsxRuntime.jsx("span",{className:"max-w-[16rem] truncate",title:gn.name,children:truncateFilename(gn.name)}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-5 w-5 shrink-0 rounded-full hover:bg-muted/80",onClick:()=>Tr(wn),"aria-label":`Remove attached file ${gn.name}`,type:"button",children:jsxRuntime.jsx(X$2,{className:"h-3.5 w-3.5"})})]},`${gn.name}_${gn.lastModified}_${gn.size}_${wn}`))]}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Will be included with your next message."})]}):null,Gr=jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsxs("div",{className:"text-center text-muted-foreground",children:[jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})}),Kr=jsxRuntime.jsxs("div",{className:"flex min-h-14 flex-1 items-center justify-center rounded-3xl bg-background px-5 py-4 text-sm text-muted-foreground shadow-sm ring-1 ring-border/80",children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading SOP..."]}),mi=jsxRuntime.jsx("div",{className:"min-h-0 flex-1 bg-muted/30 p-6 rounded-bl-lg",children:jsxRuntime.jsxs("div",{className:"mx-auto flex h-full min-h-0 w-full max-w-2xl flex-col rounded-lg border bg-background p-4 shadow-sm",children:[jsxRuntime.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-base font-semibold text-foreground",children:"Attach SOP as file"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Pick one SOP to attach and send immediately."})]}),jsxRuntime.jsx(Button$1,{variant:"outline",size:"sm",onClick:Qn,disabled:dn,type:"button",children:"Cancel"})]}),jsxRuntime.jsx(ScrollArea,{className:"min-h-0 flex-1 pr-1",children:jsxRuntime.jsx("div",{className:"space-y-2 pb-2",children:Yn.length===0?jsxRuntime.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm text-muted-foreground",children:"No SOP files are available."}):Yn.map(an=>{const gn=dn&&xn===an.id;return jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"min-w-0 text-sm font-medium text-foreground",title:an.label,children:jsxRuntime.jsx("span",{className:"block truncate",children:an.label})}),jsxRuntime.jsxs(Button$1,{size:"sm",onClick:()=>{Dr(an.id)},disabled:dn||pr,type:"button",children:[gn?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(File$1,{className:"mr-2 h-4 w-4"}),"Attach"]})]},an.id)})})})]})});return f?jsxRuntime.jsxs("div",{className:cn("flex h-full min-h-0 w-full overflow-hidden",s),children:[jsxRuntime.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:Bn()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"sticky top-0 z-20 flex items-center border-b bg-background p-4 rounded-tl-lg",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(Bot,{className:"text-primary fill-background min-h-full"})}),jr?jsxRuntime.jsxs(DropdownMenu,{modal:!1,children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"ml-2 h-9 w-[20ch] justify-between px-2 font-medium",title:hr,disabled:Ir,children:[jsxRuntime.jsx("span",{className:"truncate text-left",children:hr}),jsxRuntime.jsx(ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 text-muted-foreground"})]})}),jsxRuntime.jsxs(DropdownMenuContent,{align:"start",className:"z-[10010] min-w-52",children:[jsxRuntime.jsxs(DropdownMenuItem,{onSelect:()=>fn(""),children:[jsxRuntime.jsx(Check,{className:cn("h-4 w-4",Qt===""?"opacity-100":"opacity-0")}),"Select SOP"]}),Yn.map(an=>jsxRuntime.jsxs(DropdownMenuItem,{onSelect:()=>fn(an.id),children:[jsxRuntime.jsx(Check,{className:cn("h-4 w-4",Qt===an.id?"opacity-100":"opacity-0")}),an.label]},an.id))]})]}):jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:"Randmar Assistant"}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"ml-auto",confirmationDialog:{title:"Report Issue",content:"This action will send a copy of your chat to Randmar. Send it?",onConfirm:()=>oi()},disabled:c,children:c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-5 w-5 mr-2 animate-spin"}),"Sending Feedback..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MessageSquareShare,{className:"h-5 w-5 mr-2"}),"Report Issue"]})}),jsxRuntime.jsxs(Button$1,{className:"ml-1",onClick:()=>Or(),title:Ht,"aria-label":Ht,children:[jsxRuntime.jsx(MessageCircleX,{className:"h-5 w-5"})," ",Ht]}),yt!==""&&jsxRuntime.jsxs(Button$1,{className:"ml-1",variant:"destructive",onClick:()=>ur(),children:[jsxRuntime.jsx(Square,{className:"h-5 w-5"})," Stop"]})]})}),jsxRuntime.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[jsxRuntime.jsx(Input,{type:"file",onChange:dr,className:"hidden",ref:qn,multiple:!0}),Fn&&jsxRuntime.jsx("div",{className:"px-6 pt-4",children:jsxRuntime.jsxs("div",{role:"status","aria-live":"polite",className:cn("flex items-start justify-between gap-3 rounded-lg border p-3 text-sm",Fn.kind==="error"&&"border-destructive/30 bg-destructive/10 text-foreground",Fn.kind==="success"&&"border-success/30 bg-success/10 text-foreground",Fn.kind==="info"&&"border-border bg-background text-foreground"),children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"font-semibold",children:Fn.title}),Fn.description&&jsxRuntime.jsx("div",{className:cn("mt-0.5",Fn.kind==="error"&&"text-destructive",Fn.kind==="success"&&"text-success",Fn.kind==="info"&&"text-muted-foreground"),children:Fn.description})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-7 w-7 shrink-0",onClick:()=>Xn(null),"aria-label":"Dismiss notice",type:"button",children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]})}),Zt?mi:mt?Mr?jsxRuntime.jsx("div",{className:"flex-1 bg-muted/30 flex items-center justify-center p-6 rounded-bl-lg",children:jsxRuntime.jsxs("div",{className:"w-full max-w-2xl",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Hi there!"}),jsxRuntime.jsx("h1",{className:"mt-2 text-2xl leading-tight font-semibold text-foreground",children:"How can I assist you with your Randmar tasks today?"}),jsxRuntime.jsx("form",{className:"mt-6",onSubmit:an=>{if(an.preventDefault(),yt||ar)return;let gn=Jt.trim();!gn&&Wt.length>0&&(gn="consider this"),!(!gn||!Vn)&&(mr(Vn,gn),Yt(""))},children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[ar?jsxRuntime.jsx("div",{className:"flex items-end gap-2",children:Kr}):jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx(Textarea,{ref:Un,autoFocus:!0,value:Jt,onPaste:Gn,onChange:an=>Yt(an.target.value),onKeyDown:an=>{if(an.key!=="Enter"||an.shiftKey||(an.preventDefault(),!mt||yt||ar))return;let gn=Jt.trim();!gn&&Wt.length>0&&(gn="consider this"),!(!gn||!Vn)&&(mr(Vn,gn),Yt(""))},placeholder:"Enter a question or command for Randmar Assistant",className:"flex-1 resize-none field-sizing-content max-h-[30em] min-h-14 rounded-3xl bg-background px-5 py-4 shadow-sm ring-1 ring-border/80 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:"h-12 w-12 rounded-full shadow-sm",disabled:!mt||!!yt||ar,type:"submit",children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),jsxRuntime.jsxs(Button$1,{size:"icon",variant:ir?"secondary":"default",onClick:xr,title:$r,className:cn("relative h-12 w-12 rounded-full shadow-sm",ir&&"ring-2 ring-ring/25"),disabled:!mt||yt!==""||Vn?.pending,type:"button","aria-label":$r,children:[jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"}),ir&&jsxRuntime.jsx("span",{className:"absolute -right-1 -top-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-semibold text-primary-foreground shadow-sm",children:Zn})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:wr,title:br,className:"h-12 w-12 rounded-full shadow-sm",disabled:pr,type:"button","aria-label":br,children:jsxRuntime.jsx(File$1,{className:"h-5 w-5"})})]}),qr()]})})]})}):jsxRuntime.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[jsxRuntime.jsxs(ScrollArea,{className:"min-h-0 flex-1 bg-muted/30 pl-2 pr-2",children:[jsxRuntime.jsx(ChatMessages,{messages:Vn?.messages??[],appID:e,isAssistantChat:!0,botStatus:yt,hideSenderNames:!0,editableUserMessages:!0,editingMessageId:on,editingDraft:Sn,onEditingDraftChange:Rn,onStartEditUserMessage:ui,onCancelEditUserMessage:Fr,onSaveEditUserMessage:di,onRetryUserMessage:fi}),jsxRuntime.jsx("div",{ref:Cn})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 flex-col gap-2 border-r border-t p-4",children:[ar?Kr:jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx(Textarea,{ref:Un,placeholder:"Type a message...",value:Ft,onPaste:Gn,onChange:an=>zt(an.target.value),onKeyDown:an=>{an.key!=="Enter"||an.shiftKey||(an.preventDefault(),!(!mt||yt||ar)&&nr())},className:"flex-1 resize-none field-sizing-content max-h-[30em]"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:Vn?.pending?"collapse":"ml-2 h-8 w-8",disabled:!mt||!!yt||ar,onClick:nr,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),jsxRuntime.jsxs(Button$1,{size:"icon",variant:ir?"secondary":"default",onClick:xr,title:$r,"aria-label":$r,className:cn(Vn?.pending?"collapse":"relative ml-2 h-8 w-8",ir&&"ring-2 ring-ring/25"),disabled:!mt||yt!==""||Vn?.pending,children:[jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"}),ir&&jsxRuntime.jsx("span",{className:"absolute -right-1 -top-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-semibold text-primary-foreground shadow-sm",children:Zn})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",onClick:wr,title:br,"aria-label":br,className:Vn?.pending?"collapse":"ml-2 h-8 w-8",disabled:pr,type:"button",children:jsxRuntime.jsx(File$1,{className:"h-5 w-5"})})]})]}),qr()]})]}):jsxRuntime.jsx("div",{className:"flex-1 bg-muted/30",children:Gr})]})]}):Gr}),jsxRuntime.jsx("div",{"data-thin":!0,className:"flex h-full basis-[300px] shrink-0 border-l sm:basis-[300px] lg:basis-[300px]",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col rounded-r-lg border-r bg-muted/30 text-foreground",children:[jsxRuntime.jsxs("div",{className:"space-y-3 border-b border-border/80 p-4 pt-6",children:[jsxRuntime.jsxs("h4",{className:"flex items-center text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(Settings,{className:"w-4 h-4 mr-2"}),"Settings"]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsx(Label$2,{htmlFor:"show-dev-logs-checkbox",className:"text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:"Show Dev Logs"}),jsxRuntime.jsx(Checkbox,{id:"show-dev-logs-checkbox",checked:Kn,onCheckedChange:an=>lr(an===!0),"aria-label":"Show developer logs"})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col border-b border-border/80 h-24",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2"}),"Attached Files"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsx("div",{className:"py-2 text-sm",children:Wt.length>0||_n.length>0?jsxRuntime.jsxs("div",{className:"space-y-2",children:[Wt.map((an,gn)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 text-primary",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsxs("span",{title:`${an.name} (pending)`,children:[truncateFilename(an.name)," (pending)"]})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0",onClick:()=>Tr(gn),"aria-label":`Remove pending file ${an.name}`,children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]},`${an.name}_${an.lastModified}_${an.size}_${gn}`)),_n.slice().reverse().map((an,gn)=>{const wn=_n.length-1-gn;return jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 text-foreground hover:text-primary transition-colors duration-150",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsx("span",{title:an.name,children:truncateFilename(an.name)})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0",onClick:()=>ai(an.name,wn),"aria-label":`Remove file ${an.name}`,children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]},an.messageId)})]}):jsxRuntime.jsx("p",{className:"text-muted-foreground text-xs italic",children:"No files attached yet."})})})]}),Kn?jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(CodeXml,{className:"w-4 h-4 mr-2"}),"Developer Log"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-xs font-mono",children:[jsxRuntime.jsx(DebugMessageDisplay,{debugMessages:Rt}),jsxRuntime.jsx("div",{ref:Ur})]})})]}):jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(MessageSquareShare,{className:"w-4 h-4 mr-2"}),"Contact Us"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-sm space-y-4",children:[jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Reach out any time"}),jsxRuntime.jsxs("div",{className:"mt-2 space-y-1",children:[jsxRuntime.jsx("a",{className:"block text-base font-semibold text-primary hover:underline",href:"mailto:service@randmar.io",children:"service@randmar.io"}),jsxRuntime.jsx("a",{className:"block text-base font-semibold text-primary hover:underline",href:"tel:+18003616244",children:"1 (800) 361-6244"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Customer reps:"}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Loraine Fraraccio"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:loraine@randmar.io",children:"loraine@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 314"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: Quebec"})]}),jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Massimo Fiore"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:massimo@randmar.io",children:"massimo@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 305"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: Ontario"})]}),jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Kevin Dusik"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:kevin@randmar.io",children:"kevin@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 150"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: British-Colombia"})]})]})]})]})})]}),jsxRuntime.jsx("div",{className:"p-3 border-t border-border/80",children:jsxRuntime.jsxs(Button$1,{className:"w-full",variant:"secondary",onClick:()=>bn("Send me the Summary of the conversation by email",null,null),type:"button",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4 mr-2"}),"Summarize to Email"]})}),jsxRuntime.jsx("div",{className:"mt-auto p-3 border-t border-border/80",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-center space-x-3 w-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Powered by Gemini"}),jsxRuntime.jsx(GeminiIcon,{})]}),jsxRuntime.jsxs("div",{className:"flex-1 max-w-[160px]",children:[jsxRuntime.jsx(Progress,{value:Math.round((Mt||0)*100),className:"h-2"}),jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground mt-1",children:[jsxRuntime.jsx("span",{children:"Context"}),jsxRuntime.jsxs("span",{children:[Math.round((Mt||0)*100),"%"]})]})]})]})})]})})]}):jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"})}));AIChatLayout.displayName="AIChatLayout";const GeminiIcon=({className:e="h-4 w-4"})=>jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",className:cn("flex-none leading-none",e),children:[jsxRuntime.jsx("title",{children:"Gemini"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"var(--info)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-0)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-1)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-2)"}),jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"var(--success)"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"var(--success)",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[jsxRuntime.jsx("stop",{stopColor:"var(--primary)"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"var(--primary)",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"var(--warning)"}),jsxRuntime.jsx("stop",{offset:".46",stopColor:"var(--warning)",stopOpacity:"0"})]})]})]}),ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY="randmarcomps.assistantPromptShortcuts.v1";function resolveRoutePath(e,t){return(e.startsWith("/")?e:`/${e}`).replace(":appID",t)}function isRoutePathActive(e,t){return t==="/"?e==="/":e===t||e.startsWith(`${t}/`)}const Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,chatUserName:s,appID:a,chatRoutePath:o},l)=>{const c=e.filter(Ft=>Ft.showInNav),d=React.useRef(null),f=React.useRef(null),R=React.useRef(null),[S,te]=React.useState(!1),[A,rt]=React.useState([]),[st,it]=React.useState(!1),[at,ot]=React.useState(!1),[lt,ut]=React.useState(""),[ct,dt]=React.useState(""),[pt,mt]=React.useState({}),{isMobile:Rt,setOpenMobile:yt}=useSidebar(),It=reactRouterDom.useLocation(),{data:ft}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsHasUnreadsQuery({routeApplicationId:a}),{hasUnreads:Ct}=useChat();React.useEffect(()=>{if(!(typeof window>"u"))try{const Ft=window.localStorage.getItem(ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY);if(!Ft){rt([]),it(!0);return}const zt=JSON.parse(Ft);if(!Array.isArray(zt))throw new Error("Invalid shortcuts data");const Jt=zt;if(!Jt.every(rn=>typeof rn=="object"&&rn!==null&&typeof rn.id=="string"&&typeof rn.title=="string"&&typeof rn.prompt=="string"&&typeof rn.createdAt=="number"))throw new Error("Invalid shortcuts shape");rt(Jt),it(!0)}catch{rt([]),it(!0)}},[]),React.useEffect(()=>{if(st&&!(typeof window>"u"))try{window.localStorage.setItem(ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY,JSON.stringify(A))}catch{}},[A,st]);const Mt=React.useCallback(()=>{ut(""),dt(""),mt({})},[]),Dt=React.useCallback((Ft,zt=null,Jt=null,Yt)=>{te(!0),setTimeout(()=>{d.current?.focus(),f.current&&(Yt?.clear?f.current.sendMessageToAssistantWithClear(Ft,zt,Jt):f.current.sendMessageToAssistant(Ft,zt,Jt))},100)},[]),Vt=React.useCallback(()=>{yt(!1)},[yt]);React.useImperativeHandle(l,()=>({sendMessageToAssistant:(Ft,zt,Jt)=>{Dt(Ft,zt,Jt)},sendMessageToAssistantWithClear(Ft,zt,Jt){Dt(Ft,zt,Jt,{clear:!0})}}));const Ht=Ft=>{Ft?.preventDefault();const zt=lt.trim(),Jt=ct.trim(),Yt={};if(zt||(Yt.title="Short title is required."),Jt||(Yt.prompt="Prompt is required."),Yt.title||Yt.prompt){mt(Yt);return}const rn=(()=>{try{return globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`}catch{return`${Date.now()}-${Math.random()}`}})();rt(un=>[...un,{id:rn,title:zt,prompt:Jt,createdAt:Date.now()}]),ot(!1),Mt()},$t=c.find(Ft=>isRoutePathActive(It.pathname,resolveRoutePath(Ft.path,a)))?.label??"None";return jsxRuntime.jsxs(Sidebar,{className:"border-r border-sidebar-border",children:[jsxRuntime.jsx(SidebarHeader,{className:"border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx(ApiImage,{path:"/images/RandmarIcon.svg",alt:"Randmar Icon",className:"h-4 w-4 filter brightness-0 saturate-100 invert"})}),jsxRuntime.jsx("span",{className:"font-semibold text-lg",children:n})]})}),jsxRuntime.jsx(SidebarContent,{className:"py-4 bg-sidebar text-sidebar-foreground",children:Rt?jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col px-4 pb-4 pt-2",children:[jsxRuntime.jsxs("div",{className:"px-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-sidebar-foreground/70",children:"App Launchpad"}),jsxRuntime.jsxs("p",{className:"mt-1 text-sm text-sidebar-foreground/85",children:["Current: ",jsxRuntime.jsx("span",{className:"font-semibold text-sidebar-foreground",children:$t})]})]}),jsxRuntime.jsx("div",{className:"mt-4 grid grid-cols-3 gap-3",children:c.map(Ft=>{const zt=Ft.icon??AppWindow,Jt=resolveRoutePath(Ft.path,a),Yt=isRoutePathActive(It.pathname,Jt);return jsxRuntime.jsxs(reactRouterDom.Link,{to:Jt,"aria-current":Yt?"page":void 0,onClickCapture:Vt,className:cn("flex min-h-24 min-w-0 flex-col items-center justify-center gap-2 rounded-xl border px-2 py-3 text-center text-xs font-medium leading-tight transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring","border-sidebar-border/70 bg-sidebar-accent/30 text-sidebar-foreground hover:bg-sidebar-accent",Yt&&"border-sidebar-ring bg-sidebar-accent text-sidebar-accent-foreground"),children:[jsxRuntime.jsx(zt,{className:"h-9 w-9 shrink-0"}),jsxRuntime.jsx("span",{className:"line-clamp-2",children:Ft.label??Ft.key})]},Ft.key)})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(SidebarMenu,{children:[jsxRuntime.jsxs(Dialog,{open:at,onOpenChange:Ft=>{ot(Ft),Ft||Mt()},children:[jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(SidebarMenuButton,{className:"px-6",children:[jsxRuntime.jsx(Plus,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Add a prompt"})]})})}),jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-md",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Add a saved prompt"}),jsxRuntime.jsx(DialogDescription,{children:"Create a reusable assistant prompt shortcut for this portal."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:Ht,children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"randmar-prompt-shortcut-title",children:"Short Title"}),jsxRuntime.jsx(Input,{id:"randmar-prompt-shortcut-title",value:lt,onChange:Ft=>{ut(Ft.target.value),pt.title&&mt(zt=>({...zt,title:void 0}))},"aria-invalid":!!pt.title,"aria-describedby":pt.title?"randmar-prompt-shortcut-title-error":void 0,autoFocus:!0}),pt.title?jsxRuntime.jsx("p",{id:"randmar-prompt-shortcut-title-error",className:"text-xs text-destructive",children:pt.title}):null]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"randmar-prompt-shortcut-prompt",children:"Prompt"}),jsxRuntime.jsx(Textarea,{id:"randmar-prompt-shortcut-prompt",value:ct,onChange:Ft=>{dt(Ft.target.value),pt.prompt&&mt(zt=>({...zt,prompt:void 0}))},"aria-invalid":!!pt.prompt,"aria-describedby":pt.prompt?"randmar-prompt-shortcut-prompt-error":void 0,className:"min-h-28"}),pt.prompt?jsxRuntime.jsx("p",{id:"randmar-prompt-shortcut-prompt-error",className:"text-xs text-destructive",children:pt.prompt}):null]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(DialogClose,{asChild:!0,children:jsxRuntime.jsx(Button$1,{type:"button",variant:"outline",children:"Cancel"})}),jsxRuntime.jsx(Button$1,{type:"submit",children:"Save"})]})]})]})]}),A.map(Ft=>jsxRuntime.jsxs(SidebarMenuItem,{children:[jsxRuntime.jsxs(SidebarMenuButton,{className:"px-6",onClick:()=>Dt(Ft.prompt,null,null,{clear:!0}),children:[jsxRuntime.jsx(MessageSquareText,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:Ft.title})]}),jsxRuntime.jsx(SidebarMenuAction,{showOnHover:!0,"aria-label":`Delete prompt: ${Ft.title}`,className:"text-sidebar-foreground/70 hover:text-destructive",onClick:zt=>{zt.preventDefault(),zt.stopPropagation(),rt(Jt=>Jt.filter(Yt=>Yt.id!==Ft.id))},children:jsxRuntime.jsx(Minus,{className:"h-4 w-4"})})]},Ft.id))]}),jsxRuntime.jsx(SidebarSeparator,{className:"my-2"}),jsxRuntime.jsx(SidebarMenu,{children:c.map(Ft=>{const zt=Ft.icon,Jt=resolveRoutePath(Ft.path,a),Yt=isRoutePathActive(It.pathname,Jt);return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,isActive:Yt,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:Jt,className:"transition-colors hover:bg-muted px-6",children:[zt&&jsxRuntime.jsx(zt,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:Ft.label})]})})},Ft.key)})})]})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar text-sidebar-foreground",children:[jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:te,children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{ref:R,size:"lg",className:"collapse md:visible flex-grow",onClick:()=>setTimeout(()=>d.current?.focus(),50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:o,onClickCapture:Vt,children:jsxRuntime.jsx(Button$1,{size:"icon",className:Ct||ft?.HasUnreads===!0?"pulse-glow bg-background hover:bg-muted text-foreground":"",children:jsxRuntime.jsx(MessageSquare,{className:"h-5 w-5"})})})]}),jsxRuntime.jsx(DialogContent,{className:"randmar-assistant-dialog max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,overlayClassName:"randmar-assistant-overlay",showOverlay:S,children:jsxRuntime.jsx(AIChatLayout,{className:"h-[85vh]",ref:f,inputRef:d,userId:a,userName:s??"Unknown user",isOpen:S,onRequestOpen:()=>{te(!0),setTimeout(()=>d.current?.focus(),50)}})})]}),t]})]})}),Layout=React.forwardRef(({children:e,appID:t,rightMenu:n,routes:s,footer:a,handleValidSearch:o,dashboardTitle:l,onSignOut:c,searchPlaceholder:d,chatUserName:f,chatRef:R,chatRoutePath:S},te)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{appID:t,routes:s,footer:a,dashboardTitle:l,chatUserName:f,ref:R,chatRoutePath:S}),jsxRuntime.jsx(Topbar,{ref:te,onSignOut:c,rightMenu:n,handleValidSearch:o,searchPlaceholder:d}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col",children:[jsxRuntime.jsx("main",{className:"mt-16 flex-1 overflow-x-clip","data-rm-main-content-region":"true",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const salesChannels=[{id:"online-store",label:"Online store (Shopify, Amazon, etc.)"},{id:"brick-and-mortar",label:"Brick-and-mortar (Physical Store)"},{id:"marketplace",label:"Marketplace seller (eBay, Walmart, etc.)"},{id:"b2b",label:"B2B wholesale"},{id:"other-channel",label:"Other (please specify)"}],markets=[{id:"canada",label:"Canada - Nationwide"},{id:"ontario",label:"Ontario & Quebec"},{id:"atlantic",label:"Atlantic Provinces (NS, NB, PEI, NL)"},{id:"prairie",label:"Prairie (Saskatchewan, Manitoba)"},{id:"western",label:"Western Provinces (BC, Alberta, etc.)"},{id:"united-states",label:"United States"},{id:"other-market",label:"Other (please specify)"}];function ManufacturerGetStartedButton({applicationId:e,manufacturer:t}){const{toast:n}=useToast(),[s,a]=React.useState(!1),[o,l]=React.useState(!1),[c,d]=React.useState(!1),[f,R]=React.useState(""),[S,te]=React.useState(""),[A,rt]=React.useState(!1),[st,it]=React.useState(""),[at,ot]=React.useState(""),[lt,ut]=React.useState([]),[ct,dt]=React.useState(""),[pt,mt]=React.useState(""),[Rt,yt]=React.useState([]),[It,ft]=React.useState(""),[Ct,Mt]=React.useState(""),[Dt]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),Vt=()=>{R(""),te("")},Ht=()=>{it(""),ot(""),ut([]),dt(""),mt(""),yt([]),ft(""),Mt("")},$t=()=>{t.PartnerRegistrationLink?a(!0):t.OpenToWork&&l(!0)},Ft=Qt=>{if(Qt.preventDefault(),!c){if(!f.trim()){te("Qualification ID is required");return}d(!0),Dt({routeApplicationId:e,partnerId:t.ManufacturerId??"",message:`Hello! I'd like to get started with you. Here's my Qualification ID: ${f}`}).then(fn=>{if(fn.error){console.error(fn.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}n({title:"Information sent to the manufacturer",description:"Check your chats later.",variant:"success"}),a(!1),Vt()}).catch(fn=>{console.error(fn),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{d(!1)})}},zt=Qt=>{if(Qt.preventDefault(),A)return;ot(""),dt(""),ft("");let fn=!1;if(st.trim().length<10&&(ot("Please provide a brief description of your business (minimum 10 characters)"),fn=!0),lt.length===0&&(dt("Please select at least one sales channel"),fn=!0),Rt.length===0&&(ft("Please select at least one market"),fn=!0),fn)return;const Ut=salesChannels.filter(Xt=>lt.includes(Xt.id)).map(Xt=>Xt.label);pt&&Ut.push(`Other: ${pt}`);const tn=markets.filter(Xt=>Rt.includes(Xt.id)).map(Xt=>Xt.label);Ct&&tn.push(`Other: ${Ct}`);const qt=["Hello! I'd like to introduce my business:",`**Business Description:** ${st}`,`**Sales Channels:** ${Ut.join(", ")}`,`**Markets:** ${tn.join(", ")}`].join(`
512
512
 
513
513
  `);rt(!0),Dt({routeApplicationId:e,partnerId:t.ManufacturerId??"",message:qt}).then(Xt=>{if(Xt.error){console.error(Xt.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}n({title:"Information sent to the manufacturer",description:"Check your chats later.",variant:"success"}),l(!1),Ht()}).catch(Xt=>{console.error(Xt),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{rt(!1)})},Jt=(Qt,fn)=>{ut(Ut=>fn?[...Ut,Qt]:Ut.filter(tn=>tn!==Qt)),dt("")},Yt=(Qt,fn)=>{yt(Ut=>fn?[...Ut,Qt]:Ut.filter(tn=>tn!==Qt)),ft("")},rn=lt.includes("other-channel"),un=Rt.includes("other-market");return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!t.Qualification&&jsxRuntime.jsxs(Button$1,{onClick:$t,disabled:!t.PartnerRegistrationLink&&!t.OpenToWork,children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Get Started"]}),t.PartnerRegistrationLink&&jsxRuntime.jsx(Dialog,{open:s,onOpenChange:Qt=>{a(Qt)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[400px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:t.PublicName}),jsxRuntime.jsxs(DialogDescription,{children:[jsxRuntime.jsx("span",{className:"font-bold",children:"Already qualified?"})," Provide your Qualification ID."]})]}),jsxRuntime.jsxs("form",{onSubmit:Ft,className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"qualificationId",children:"Qualification ID"}),jsxRuntime.jsx(Input,{id:"qualificationId",placeholder:"Enter your qualification ID",value:f,onChange:Qt=>{R(Qt.target.value),te("")}}),S&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:S})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",className:"w-full",disabled:c,children:c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Applying..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Apply for Qualification"]})})})]}),jsxRuntime.jsx(Separator$1,{className:"my-4"}),jsxRuntime.jsxs("div",{className:"text-center space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Don't have a qualification ID?"}),jsxRuntime.jsx(reactRouterDom.Link,{to:t.PartnerRegistrationLink,target:"_blank",children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"w-full",disabled:!t.PartnerRegistrationLink,children:[jsxRuntime.jsx(ExternalLink,{className:"mr-2 h-4 w-4"}),"Register here"]})})]})]})}),jsxRuntime.jsx(Dialog,{open:o,onOpenChange:Qt=>{l(Qt)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[768px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Introduce Yourself"})}),jsxRuntime.jsxs("form",{onSubmit:zt,className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{htmlFor:"businessDescription",children:["Tell Us About Your Business ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Briefly describe your business)"})]}),jsxRuntime.jsx(Textarea,{id:"businessDescription",placeholder:"We are an online retailer specializing in office supplies, serving businesses since 2018...",className:"min-h-[100px]",value:st,onChange:Qt=>{it(Qt.target.value),ot("")}}),at&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:at})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Sales Channel(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select where you currently sell your products)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:salesChannels.map(Qt=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`channel-${Qt.id}`,checked:lt.includes(Qt.id),onCheckedChange:fn=>Jt(Qt.id,fn===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`channel-${Qt.id}`,className:"text-sm font-normal",children:Qt.label})]},Qt.id))}),rn&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:pt,onChange:Qt=>mt(Qt.target.value)}),ct&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:ct})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Your Primary Market(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select which regions you sell to)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:markets.map(Qt=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`market-${Qt.id}`,checked:Rt.includes(Qt.id),onCheckedChange:fn=>Yt(Qt.id,fn===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`market-${Qt.id}`,className:"text-sm font-normal",children:Qt.label})]},Qt.id))}),un&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:Ct,onChange:Qt=>Mt(Qt.target.value)}),It&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:It})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:A,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Submitting..."]}):"Submit"})})]})]})})]})}const DAYS_OF_WEEK=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ManufacturerReorderingCard({manufacturer:e,onSave:t,loading:n=!1,saving:s=!1,readonly:a=!1}){const[o,l]=React.useState({...e}),[c,d]=React.useState({...e});React.useEffect(()=>{d({...e}),l({...e})},[e]);const f=(at,ot)=>{a||l(lt=>({...lt,[at]:ot}))},R=(at,ot)=>{a||l(lt=>({...lt,[at]:ot}))},S=(at,ot)=>{a||l(lt=>({...lt,[at]:ot}))},te=()=>{const at={};return Object.keys(o).forEach(ot=>{const lt=ot;JSON.stringify(o[lt])!==JSON.stringify(c[lt])&&(at[lt]=o[lt])}),at},A=()=>{if(!s&&!a){const at=te();Object.keys(at).length>0&&t(at)}},rt=at=>at===-1?"ASAP":at===void 0||at<0||at>6?"Sunday":DAYS_OF_WEEK[at],st=at=>at==="ASAP"?-1:DAYS_OF_WEEK.indexOf(at),it=Object.keys(te()).length>0;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[n?jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}):jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Reordering"}),n?jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}):jsxRuntime.jsx(CardDescription,{className:"text-sm",children:"Adjust your reordering settings to control lead times, stocking weeks, minimum orders, and reorder dates, enhancing efficiency in restocking processes."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"automatic-reordering",checked:o.AutoUpdate,onCheckedChange:at=>f("AutoUpdate",at),disabled:s||a}),jsxRuntime.jsx(Label$2,{htmlFor:"automatic-reordering",children:"Automatic Reordering"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"reorder-date",children:"Automatic Reorder Date"}),jsxRuntime.jsxs(Select$1,{value:rt(o.AutoReorderDate),onValueChange:at=>R("AutoReorderDate",st(at)),disabled:s||a,children:[jsxRuntime.jsx(SelectTrigger,{id:"reorder-date",children:jsxRuntime.jsx(SelectValue,{placeholder:"Select day"})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"ASAP",children:"ASAP"}),DAYS_OF_WEEK.map(at=>jsxRuntime.jsx(SelectItem,{value:at,children:at},at))]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"weeks-stocking",children:"Default Weeks of Stocking"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"weeks-stocking",type:"number",value:o.DefaultWeeksOfStocking||"",onChange:at=>R("DefaultWeeksOfStocking",Number(at.target.value)),disabled:s||a}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"weeks"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"minimum-order",children:"Default Minimum Order"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"minimum-order",type:"number",className:"pl-6",value:o.DefaultMinimumOrder||"",onChange:at=>R("DefaultMinimumOrder",Number(at.target.value)),disabled:s||a})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"lead-time",children:"Default Lead Time"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"lead-time",type:"number",value:o.DefaultLeadTime||"",onChange:at=>R("DefaultLeadTime",Number(at.target.value)),disabled:s||a}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"days"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"maximum-inventory-value",children:"Default Maximum Inventory Value"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"maximum-inventory-value",type:"number",className:"pl-6",value:o.DefaultMaxInventoryValue||"",onChange:at=>R("DefaultMaxInventoryValue",Number(at.target.value)),disabled:s||a})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"order-confirmations",children:"Send Order Confirmations To"}),jsxRuntime.jsx(Input,{id:"order-confirmations",type:"email",value:o.POEmail||"",onChange:at=>S("POEmail",at.target.value),placeholder:"email@example.com",disabled:s||a})]})]})]})}),!a&&jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button$1,{onClick:A,disabled:s||!it,children:[s&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}function createSlot(e){const t=createSlotClone(e),n=React__namespace.forwardRef((s,a)=>{const{children:o,...l}=s,c=React__namespace.Children.toArray(o),d=c.find(isSlottable);if(d){const f=d.props.children,R=c.map(S=>S===d?React__namespace.Children.count(f)>1?React__namespace.Children.only(null):React__namespace.isValidElement(f)?f.props.children:null:S);return jsxRuntime.jsx(t,{...l,ref:a,children:React__namespace.isValidElement(f)?React__namespace.cloneElement(f,void 0,R):null})}return jsxRuntime.jsx(t,{...l,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function createSlotClone(e){const t=React__namespace.forwardRef((n,s)=>{const{children:a,...o}=n;if(React__namespace.isValidElement(a)){const l=getElementRef(a),c=mergeProps(o,a.props);return a.type!==React__namespace.Fragment&&(c.ref=s?composeRefs(s,l):l),React__namespace.cloneElement(a,c)}return React__namespace.Children.count(a)>1?React__namespace.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER$1=Symbol("radix.slottable");function isSlottable(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$1}function mergeProps(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...c)=>{const d=o(...c);return a(...c),d}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function getElementRef(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var POPOVER_NAME="Popover",[createPopoverContext]=createContextScope$2(POPOVER_NAME,[createPopperScope]),usePopperScope=createPopperScope(),[PopoverProvider,usePopoverContext]=createPopoverContext(POPOVER_NAME),Popover$1=e=>{const{__scopePopover:t,children:n,open:s,defaultOpen:a,onOpenChange:o,modal:l=!1}=e,c=usePopperScope(t),d=React__namespace.useRef(null),[f,R]=React__namespace.useState(!1),[S,te]=useControllableState({prop:s,defaultProp:a??!1,onChange:o,caller:POPOVER_NAME});return jsxRuntime.jsx(Root2$7,{...c,children:jsxRuntime.jsx(PopoverProvider,{scope:t,contentId:useId$1(),triggerRef:d,open:S,onOpenChange:te,onOpenToggle:React__namespace.useCallback(()=>te(A=>!A),[te]),hasCustomAnchor:f,onCustomAnchorAdd:React__namespace.useCallback(()=>R(!0),[]),onCustomAnchorRemove:React__namespace.useCallback(()=>R(!1),[]),modal:l,children:n})})};Popover$1.displayName=POPOVER_NAME;var ANCHOR_NAME="PopoverAnchor",PopoverAnchor$1=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopoverContext(ANCHOR_NAME,n),o=usePopperScope(n),{onCustomAnchorAdd:l,onCustomAnchorRemove:c}=a;return React__namespace.useEffect(()=>(l(),()=>c()),[l,c]),jsxRuntime.jsx(Anchor,{...o,...s,ref:t})});PopoverAnchor$1.displayName=ANCHOR_NAME;var TRIGGER_NAME$3="PopoverTrigger",PopoverTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopoverContext(TRIGGER_NAME$3,n),o=usePopperScope(n),l=useComposedRefs(t,a.triggerRef),c=jsxRuntime.jsx(Primitive$4.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":getState$2(a.open),...s,ref:l,onClick:composeEventHandlers(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?c:jsxRuntime.jsx(Anchor,{asChild:!0,...o,children:c})});PopoverTrigger$1.displayName=TRIGGER_NAME$3;var PORTAL_NAME$1="PopoverPortal",[PortalProvider,usePortalContext]=createPopoverContext(PORTAL_NAME$1,{forceMount:void 0}),PopoverPortal=e=>{const{__scopePopover:t,forceMount:n,children:s,container:a}=e,o=usePopoverContext(PORTAL_NAME$1,t);return jsxRuntime.jsx(PortalProvider,{scope:t,forceMount:n,children:jsxRuntime.jsx(Presence,{present:n||o.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:a,children:s})})})};PopoverPortal.displayName=PORTAL_NAME$1;var CONTENT_NAME$3="PopoverContent",PopoverContent$1=React__namespace.forwardRef((e,t)=>{const n=usePortalContext(CONTENT_NAME$3,e.__scopePopover),{forceMount:s=n.forceMount,...a}=e,o=usePopoverContext(CONTENT_NAME$3,e.__scopePopover);return jsxRuntime.jsx(Presence,{present:s||o.open,children:o.modal?jsxRuntime.jsx(PopoverContentModal,{...a,ref:t}):jsxRuntime.jsx(PopoverContentNonModal,{...a,ref:t})})});PopoverContent$1.displayName=CONTENT_NAME$3;var Slot=createSlot("PopoverContent.RemoveScroll"),PopoverContentModal=React__namespace.forwardRef((e,t)=>{const n=usePopoverContext(CONTENT_NAME$3,e.__scopePopover),s=React__namespace.useRef(null),a=useComposedRefs(t,s),o=React__namespace.useRef(!1);return React__namespace.useEffect(()=>{const l=s.current;if(l)return hideOthers(l)},[]),jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(PopoverContentImpl,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(e.onCloseAutoFocus,l=>{l.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:composeEventHandlers(e.onPointerDownOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,f=c.button===2||d;o.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:composeEventHandlers(e.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),PopoverContentNonModal=React__namespace.forwardRef((e,t)=>{const n=usePopoverContext(CONTENT_NAME$3,e.__scopePopover),s=React__namespace.useRef(!1),a=React__namespace.useRef(!1);return jsxRuntime.jsx(PopoverContentImpl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(s.current||n.triggerRef.current?.focus(),o.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;n.triggerRef.current?.contains(l)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),PopoverContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:R,...S}=e,te=usePopoverContext(CONTENT_NAME$3,n),A=usePopperScope(n);return useFocusGuards(),jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:R,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onDismiss:()=>te.onOpenChange(!1),children:jsxRuntime.jsx(Content$2,{"data-state":getState$2(te.open),role:"dialog",id:te.contentId,...A,...S,ref:t,style:{...S.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),CLOSE_NAME="PopoverClose",PopoverClose=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopoverContext(CLOSE_NAME,n);return jsxRuntime.jsx(Primitive$4.button,{type:"button",...s,ref:t,onClick:composeEventHandlers(e.onClick,()=>a.onOpenChange(!1))})});PopoverClose.displayName=CLOSE_NAME;var ARROW_NAME="PopoverArrow",PopoverArrow=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopperScope(n);return jsxRuntime.jsx(Arrow,{...a,...s,ref:t})});PopoverArrow.displayName=ARROW_NAME;function getState$2(e){return e?"open":"closed"}var Root2$2=Popover$1,Anchor2=PopoverAnchor$1,Trigger$1=PopoverTrigger$1,Portal=PopoverPortal,Content2$2=PopoverContent$1;const Popover=Root2$2,PopoverTrigger=Trigger$1,PopoverAnchor=Anchor2,PopoverContent=React__namespace.forwardRef(({className:e,align:t="center",sideOffset:n=4,...s},a)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsx(Content2$2,{ref:a,align:t,sideOffset:n,className:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",e),...s})}));PopoverContent.displayName=Content2$2.displayName;function MultiSelect({options:e,selected:t,onChange:n,placeholder:s="Select items...",disabled:a=!1}){const[o,l]=React__namespace.useState(!1),[c,d]=React__namespace.useState(""),f=React__namespace.useRef(null),[R,S]=React__namespace.useState(void 0),te=React__namespace.useCallback(()=>{f.current&&S(f.current.offsetWidth)},[]);React__namespace.useLayoutEffect(()=>{te()},[te]),React__namespace.useEffect(()=>(window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)),[te]);const A=it=>{n(t.filter(at=>at!==it))},rt=it=>{l(!1),t.includes(it)?n(t.filter(at=>at!==it)):n([...t,it])},st=it=>{it.key==="Enter"&&c&&!e.includes(c)&&!t.includes(c)&&(it.preventDefault(),rt(c),d(""))};return jsxRuntime.jsxs(Popover,{open:o,onOpenChange:l,children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{ref:f,variant:"outline",role:"combobox","aria-expanded":o,className:"w-full justify-between h-auto min-h-[40px] py-2",disabled:a,children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1 items-center",children:t.length>0?t.map(it=>jsxRuntime.jsxs(Badge,{variant:"outline",className:"mr-1 mb-1",children:[it,jsxRuntime.jsx("span",{className:"ml-1 cursor-pointer rounded-full outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:at=>{at.preventDefault(),at.stopPropagation(),A(it)},children:jsxRuntime.jsx(X$2,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},it)):jsxRuntime.jsx("span",{className:"text-muted-foreground",children:s})}),jsxRuntime.jsx(ChevronsUpDown,{className:"h-4 w-4 shrink-0 opacity-50 ml-2"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-full p-0",style:{width:R},children:jsxRuntime.jsxs(Command,{onKeyDown:st,children:[jsxRuntime.jsx(CommandInput,{placeholder:"Search or add custom item...",value:c,onValueChange:d}),jsxRuntime.jsxs(CommandList,{children:[jsxRuntime.jsx(CommandEmpty,{children:"No item found."}),jsxRuntime.jsxs(CommandGroup,{children:[e.filter(it=>!t.includes(it)).map(it=>jsxRuntime.jsxs(CommandItem,{onSelect:()=>rt(it),children:[jsxRuntime.jsx(Check,{className:cn("mr-2 h-4 w-4",t.includes(it)?"opacity-100":"opacity-0")}),it]},it)),c&&!e.includes(c)&&!t.includes(c)&&jsxRuntime.jsxs(CommandItem,{onSelect:()=>rt(c),children:['Add "',c,'"']})]})]})]})})]})}const imgSizeMap$1={sm:100,md:200,lg:300,xl:400};function normalizeImagesListPayload(e){return e==null?null:Array.isArray(e)?e:e&&typeof e=="object"&&"Images"in e&&Array.isArray(e.Images)?e.Images:[]}function withImageSizeParams(e,t,n){try{const s=new URL(e);return s.searchParams.set("width",String(Math.round(t))),s.searchParams.set("height",String(Math.round(n))),s.toString()}catch{return e}}function buildImageSrc({apiOrigin:e,randmarSKU:t,image:n,width:s,height:a}){const o=(n.Url??"").trim();if(o){if(o.startsWith("data:"))return o;try{const d=new URL(buildApiUrl(o,e)),f=d.pathname.split("/").filter(Boolean),R=t.trim().toLowerCase(),S=st=>{try{return decodeURIComponent(st).toLowerCase()===R}catch{return st.toLowerCase()===R}},te=f.slice(-3),A=f.slice(-4);return te.length===3&&te[0]?.toLowerCase()==="product"&&S(te[1]??"")&&te[2]?.toLowerCase()==="image"||A.length===4&&A[0]?.toLowerCase()==="product"&&S(A[1]??"")&&A[2]?.toLowerCase()==="image"?withImageSizeParams(d.toString(),s,a):d.toString()}catch{}}const c=n.ImageId!==void 0&&n.ImageId!==null&&String(n.ImageId).trim()!==""?`/Product/${encodeURIComponent(t)}/Image/${encodeURIComponent(String(n.ImageId))}`:`/Product/${encodeURIComponent(t)}/Image`;return withImageSizeParams(buildApiUrl(c,e),s,a)}function buildLegacyImageSrc({apiOrigin:e,randmarSKU:t,width:n,height:s}){return withImageSizeParams(buildApiUrl(`/Product/${encodeURIComponent(t)}/Image`,e),n,s)}const Placeholder$1=({size:e,alt:t})=>jsxRuntime.jsx("div",{className:"rounded-md bg-muted flex items-center justify-center",style:{width:e,height:e},"aria-label":t,children:jsxRuntime.jsx(ImageOff,{className:"h-1/2 w-1/2 text-muted-foreground"})});function ProductImageCarousel({randmarSKU:e,size:t="md",alt:n,className:s,fallback:a}){const o=imgSizeMap$1[t],l=React__namespace.useRef(null),c=useIntersectionObserver({elementRef:l,threshold:.1,rootMargin:"100px"}),d=useApiOrigin(),{data:f,isError:R,isFetching:S}=useGetProductByRandmarSkuImagesQuery({randmarSku:e},{skip:!e||!c,refetchOnMountOrArgChange:!0}),te=React__namespace.useMemo(()=>normalizeImagesListPayload(f),[f]),[A,rt]=React__namespace.useState(0),[st,it]=React__namespace.useState(!1),at=React__namespace.useRef(!1),ot=React__namespace.useRef(new Set);React__namespace.useEffect(()=>{rt(0),it(!1),at.current=!1,ot.current.clear()},[e]);const lt=React__namespace.useMemo(()=>te?[...te].sort((Dt,Vt)=>{const Ht=Dt.SortOrder??Number.POSITIVE_INFINITY,$t=Vt.SortOrder??Number.POSITIVE_INFINITY;if(Ht!==$t)return Ht-$t;const Ft=Dt.IsPrimary===!0?0:1,zt=Vt.IsPrimary===!0?0:1;return Ft-zt}):null,[te]),ut=React__namespace.useMemo(()=>{if(!lt?.length)return 0;const Dt=lt.findIndex(Vt=>Vt.IsPrimary===!0);return Dt>=0?Dt:0},[lt]);React__namespace.useEffect(()=>{lt?.length&&(at.current||(rt(ut),at.current=!0))},[ut,lt]);const ct=lt?.length??0,dt=React__namespace.useMemo(()=>{const Dt=(n??"").trim();return Dt?`${Dt} (Product ${e})`:`Product ${e}`},[n,e]),pt=React__namespace.useCallback(Dt=>ct>1?`${dt} image ${Dt+1}`:dt,[dt,ct]),mt=lt?.[A],Rt=React__namespace.useMemo(()=>mt?buildImageSrc({apiOrigin:d,randmarSKU:e,image:mt,width:o*1.5,height:o*1.5}):null,[mt,d,o,e]),yt=React__namespace.useCallback(Dt=>{if(ct<=0)return;const Vt=(Dt%ct+ct)%ct;rt(Vt)},[ct]),It=React__namespace.useCallback(()=>yt(A-1),[A,yt]),ft=React__namespace.useCallback(()=>yt(A+1),[A,yt]),Ct=React__namespace.useCallback(Dt=>{if(!(ct<=1))switch(Dt.key){case"ArrowLeft":Dt.preventDefault(),It();break;case"ArrowRight":Dt.preventDefault(),ft();break;case"Home":Dt.preventDefault(),yt(0);break;case"End":Dt.preventDefault(),yt(ct-1);break}},[ft,It,yt,ct]);if(React__namespace.useEffect(()=>{if(!lt?.length||ct<=1)return;const Dt=(A-1+ct)%ct,Vt=(A+1)%ct,Ht=[Dt,Vt];for(const $t of Ht){const Ft=lt[$t];if(!Ft)continue;const zt=buildImageSrc({apiOrigin:d,randmarSKU:e,image:Ft,width:o*1.5,height:o*1.5});if(ot.current.has(zt))continue;ot.current.add(zt);const Jt=new Image;Jt.src=zt}},[A,d,o,e,ct,lt]),R)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a??null});if(te===null&&c&&S)return jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx(Skeleton,{className:"rounded-md",style:{width:o,height:o}})});if(lt&&lt.length===0){if(a!=null)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a});const Dt=buildLegacyImageSrc({apiOrigin:d,randmarSKU:e,width:o*1.5,height:o*1.5});return jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx("div",{className:"relative rounded-md overflow-hidden bg-muted",style:{width:o,height:o},"aria-label":dt,children:st?jsxRuntime.jsx(Placeholder$1,{size:o,alt:dt}):jsxRuntime.jsx("img",{alt:dt,className:"w-full h-full object-contain",src:Dt,width:o,height:o,loading:"eager",onError:()=>it(!0)})})})}return Rt?jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsxs("div",{className:"group relative rounded-md overflow-hidden bg-muted",style:{width:o,height:o},role:"region","aria-roledescription":"carousel","aria-label":`Product images for ${e}`,tabIndex:ct>1?0:-1,onKeyDown:Ct,children:[jsxRuntime.jsx("img",{alt:pt(A),className:"w-full h-full object-contain",src:Rt,width:o,height:o,loading:"eager"}),ct>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Button$1,{type:"button",variant:"secondary",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 text-foreground shadow-sm ring-1 ring-border/50 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",onClick:It,"aria-label":"Previous image",children:jsxRuntime.jsx(ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx(Button$1,{type:"button",variant:"secondary",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 text-foreground shadow-sm ring-1 ring-border/50 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",onClick:ft,"aria-label":"Next image",children:jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 flex items-center gap-1 rounded-full bg-background/80 px-2 py-1",children:Array.from({length:ct}).map((Dt,Vt)=>{const Ht=Vt===A;return jsxRuntime.jsx("button",{type:"button",className:["h-1.5 w-1.5 rounded-full transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",Ht?"bg-foreground":"bg-muted-foreground/40 hover:bg-muted-foreground/60"].join(" "),onClick:()=>yt(Vt),"aria-label":`Go to image ${Vt+1} of ${ct}`,"aria-current":Ht?"true":void 0},Vt)})})]})]})}):jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx(Placeholder$1,{size:o,alt:dt})})}const getTodayIsoDate=()=>new Date().toISOString().split("T")[0],isOpportunityNotStartedYet=e=>e.StartDate?e.StartDate.split("T")[0]>getTodayIsoDate():!1,isOpportunitySelectable=e=>{if(e.Active!==!0)return!1;const t=getTodayIsoDate();return!(e.EndDate&&e.EndDate.split("T")[0]<t||e.StartDate&&e.StartDate.split("T")[0]>t)};function ProductCard({applicationId:e,product:t,viewProductLink:n,defaultOpportunityNumber:s="",onAddToCart:a,addingToCart:o=!1,shopifyHostname:l,customAction:c=jsxRuntime.jsx(jsxRuntime.Fragment,{}),showUsdLabelOnCost:d=!1}){const f=reactRouterDom.useNavigate(),{toast:R}=useToast(),[S,te]=React.useState(1),[A,rt]=React.useState(null),[st,it]=React.useState(0),[at,ot]=React.useState(!1),[lt]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),[ut,ct]=React.useState(!1),[dt,pt]=React.useState(null),[mt,Rt]=React.useState("idle"),[yt,It]=React.useState(null),[ft]=useLazyGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery(),Ct=t?.Distribution?.Cost||0,Mt=t?.Distribution?.RegularPrice||0,Dt=t?.Distribution?.Price||0,Vt=!!(e&&t?.RandmarSKU);React.useEffect(()=>{te(1),rt(null),it(0)},[t?.RandmarSKU]),React.useEffect(()=>{if(t&&s){const on=t.Opportunities?.find(vn=>vn.BidNumber==s);on&&isOpportunitySelectable(on)&&rt(on)}},[t,s]),React.useEffect(()=>{if(!t)return;const on=A?.Price?A.Price:Dt;it(Mt>0?Math.round((Mt-on)/Mt*100):0)},[t,A,Dt,Mt]),React.useEffect(()=>{o||te(1)},[o]),React.useEffect(()=>{if(!ut){pt(null),Rt("idle"),It(null);return}if(!e||!t?.RandmarSKU){Rt("error"),It("Missing identifiers to load performance data.");return}let on=!1;const vn=t.RandmarSKU;return(async()=>{Rt("summary"),It(null);try{const Rn=await ft({routeApplicationId:e,randmarSku:vn,withSpecification:!1});if(on)return;if("error"in Rn&&Rn.error)throw Rn.error;pt(Rn.data??null),Rt("detailed");const Cn=await ft({routeApplicationId:e,randmarSku:vn,withSpecification:!0});if(on)return;if("error"in Cn&&Cn.error)throw Cn.error;pt(Cn.data??Rn.data??null),Rt("complete")}catch(Rn){if(on)return;console.error("Failed to load performance data for product modal",Rn),Rt("error"),It("We couldn't load the performance details. Please try again.")}})(),()=>{on=!0}},[e,ft,ut,t?.RandmarSKU]);const Ht=on=>on>=90?{label:"Top 10% Bestseller",color:"text-primary",bgColor:"bg-primary/10"}:on>=75?{label:"Bestseller",color:"text-info",bgColor:"bg-info/10"}:on>=33?{label:"Popular",color:"text-success",bgColor:"bg-success/10"}:{label:"Rising",color:"text-muted-foreground",bgColor:"bg-muted/30"},$t=mt!=="complete"&&mt!=="error",Ft=mt==="summary"?40:mt==="detailed"?80:10,zt=dt?.SalesStatistics??[],Jt=$t?[]:zt,Yt=dt?.RandmarTitle??t?.RandmarTitle??t?.RandmarSKU??"this product",rn=dt?.RandmarSKU??t?.RandmarSKU,un=e&&t?.ManufacturerId?`/${encodeURIComponent(e)}/Partner/${encodeURIComponent(t.ManufacturerId)}?tab=manufacturer-overview`:null;if(!t)return jsxRuntime.jsx(Card,{className:"flex h-full w-full flex-col",children:jsxRuntime.jsxs(CardContent,{className:"flex h-full flex-col p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const Qt=t?.Opportunities||[],fn=Qt.length>0,Ut=()=>{if(S==null){te(1);return}S>1&&te(S-1)},tn=()=>{if(S==null){te(1);return}te(S+1)},qt=on=>{const vn=Number.parseInt(on.target.value,10);if(!isNaN(vn)&&vn>0){te(vn);return}te(void 0)},Xt=()=>{(S==null||S<1)&&te(1)},hn=on=>{try{return new Date(on).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(vn){return console.error(vn),on.split("T")[0]||"N/A"}},Kt=on=>{const vn=typeof t?.MSRP=="number"&&t.MSRP>0?t.MSRP:typeof t?.MAP=="number"&&t.MAP>0?t.MAP:null;if(vn===null)return null;const Sn=on.Price??t?.Distribution?.Price;if(typeof Sn!="number")return null;const Rn=on.Rebate??0,Cn=Math.max(Sn-Rn,0);return vn-Cn},yn=()=>{typeof a<"u"&&a({quantity:S??1,bidNumber:A?.BidNumber??null})},sn=()=>{at||!l||(ot(!0),lt({routeResellerId:e??"",randmarSku:t.RandmarSKU??"",shopifyHostName:l}).then(on=>{if(on.error){console.error("Error syncing to Shopify:",on.error),R({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"});return}R({title:"Product synced",description:"Product synced to Shopify successfully",variant:"success"})}).catch(on=>{console.error("Error syncing to Shopify:",on),R({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"})}).finally(()=>{ot(!1)}))};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Card,{className:"flex h-full w-full flex-col hover:shadow-lg transition-shadow @container",children:jsxRuntime.jsxs(CardContent,{className:"flex h-full flex-col p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t.Title||t.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex items-center justify-end ml-4 flex-shrink-0",children:un?jsxRuntime.jsx(reactRouterDom.Link,{to:un,"aria-label":`Open manufacturer overview for ${t.ManufacturerName??"this manufacturer"}`,className:"block h-full w-full",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40,className:"cursor-pointer"},`partner_logo_${t.ManufacturerId}`)}):jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40},`partner_logo_${t.ManufacturerId}`)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col @[36rem]:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 @[36rem]:order-1 order-2 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center justify-center @[36rem]:items-start @[36rem]:justify-start",children:[t.State&&jsxRuntime.jsxs(Badge,{variant:t.State==="Active"?"success":"destructive",className:"rounded-full px-3",children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",t.State]}),jsxRuntime.jsxs(Badge,{variant:t.SerialNumber?"success":"warning",className:"rounded-full px-3",children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",t.SerialNumber?"Serialized":"Unserialized"]}),t.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),t.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:t.AvailableToBuy?"success":"destructive",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",t.AvailableToBuy?"Available":"Unavailable"]}),t.ManufacturerCategory!==void 0&&t.ManufacturerCategory?.QualificationRequired&&jsxRuntime.jsxs(Badge,{variant:t.ManufacturerCategory?.QualificationRequired?"info":"secondary",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",t.ManufacturerCategory?.QualificationRequired?"Qualified Only":"Available to all"]}),t.OpportunityOnly&&jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ","Requires Opportunity"]}),t.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:t.AutoUpdate?"info":"secondary",className:"rounded-full px-3",children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",t.AutoUpdate?`Automatic Reorder (${t.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:t.BodyHTML&&t.Title&&t.MAP?"success":"warning",className:"rounded-full px-3",children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",t.BodyHTML&&t.Title&&t.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UnitWeight?`${formatNumber(t.UnitWeight)} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["MAP",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),"MSRP"]}),jsxRuntime.jsxs("div",{className:"font-medium",children:[t.MAP?formatMoney(t.MAP):"N/A",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),t.MSRP?formatMoney(t.MSRP):"N/A"]})]}),!!t.OverallPercentileRank&&!!t.ManufacturerPercentileRank&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Bestseller Status"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Global: "}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${Ht(t.OverallPercentileRank).bgColor} ${Ht(t.OverallPercentileRank).color} hover:${Ht(t.OverallPercentileRank).bgColor}`,children:Ht(t.OverallPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.OverallPercentileRank]})})]})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{children:[t.ManufacturerName,": "]}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${Ht(t.ManufacturerPercentileRank).bgColor} ${Ht(t.ManufacturerPercentileRank).color} hover:${Ht(t.ManufacturerPercentileRank).bgColor}`,children:Ht(t.ManufacturerPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.ManufacturerPercentileRank]})})]})})]})]})]}),t.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:t.CountryCodeOfOrigin,className:"mr-2"}),t.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:order-2 order-1 items-center",children:jsxRuntime.jsx(ProductImageCarousel,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||"",fallback:jsxRuntime.jsx(ProductImage,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||"",sceneName:t.SceneName},`product_image_fallback_${t.RandmarSKU}`)},`product_image_${t.RandmarSKU}`)})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:flex-row gap-6 mt-4",children:jsxRuntime.jsx("div",{className:"flex flex-1 @[36rem]:order-1 order-2",children:fn&&t.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+Qt.length+(Qt.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:Qt.map((on,vn)=>{const Sn=Kt(on);return isOpportunitySelectable(on)?jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 border cursor-pointer ${on.BidNumber==A?.BidNumber?"bg-primary/10 border-2 border-primary":"bg-background border-border hover:bg-muted/30"}`,onClick:()=>{rt(on.BidNumber!==A?.BidNumber?on:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:on.Opportunity}),jsxRuntime.jsx("span",{className:"text-xs text-foreground",children:on.BidNumber})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(on.Price??0)}),on.Rebate&&on.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-success",children:["Rebate: ",formatMoney(on.Rebate)]}),Sn!==null&&jsxRuntime.jsxs("span",{className:"text-xs text-info",children:["Potential Revenue: ",formatMoney(Sn)]}),on.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-muted-foreground",children:["Ends: ",hn(on.EndDate)]})]})]},vn):jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-muted/30 border border-border cursor-pointer hover:bg-muted/40",onClick:()=>{on.BidNumber&&f(`/${e}/Opportunity/${on.ManufacturerId}/${on.BidNumber}`)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:on.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-foreground",children:[on.BidNumber," ",jsxRuntime.jsx(Badge,{variant:"secondary",className:"text-xs mx-1 h-5",children:isOpportunityNotStartedYet(on)&&on.StartDate?`Starts ${hn(on.StartDate)}`:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(on.Price??0)}),on.Rebate&&on.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-success",children:["Rebate: ",formatMoney(on.Rebate)]}),Sn!==null&&jsxRuntime.jsxs("span",{className:"text-xs text-info",children:["Potential Revenue: ",formatMoney(Sn)]}),on.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-muted-foreground",children:["Ends: ",hn(on.EndDate)]})]})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"View Opportunity"})})]},vn)})})})]})})})]}),jsxRuntime.jsxs("div",{className:"mt-4 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-row flex-wrap justify-between items-end gap-4",children:[jsxRuntime.jsx("div",{className:"flex flex-col gap-3 flex-1",children:t.Distribution&&jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:Ct>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:["Cost: ",formatMoney(Ct),d?" USD":""]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[Mt>0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("span",{className:"text-2xl font-bold whitespace-nowrap",children:formatMoney((A?t.Opportunities?.find(on=>on.BidNumber==A.BidNumber)?.Price:Dt)??0)})}),st>0&&jsxRuntime.jsx("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:formatMoney(Mt)})]}),st>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[st,"% OFF"]}),t.InstantRebate?.EndDate&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",t.InstantRebate.EndDate.split("T")[0]]}),A?.EndDate&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",A.EndDate.split("T")[0]]})]})})]})})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center @[36rem]:justify-end items-end gap-2 w-full @[36rem]:w-auto",children:[l&&jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:sn,disabled:at,children:at?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Sync to Shopify"]})}),c,typeof a<"u"&&jsxRuntime.jsxs("div",{className:"flex gap-2 whitespace-nowrap",children:[jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:Ut,disabled:typeof S<"u"&&(S<=1||!t.AvailableToBuy||o),children:"-"}),jsxRuntime.jsx("input",{value:S,onChange:qt,onBlur:Xt,onClick:on=>on.currentTarget.select(),className:`w-6 @[36rem]:w-12 text-center border-0 bg-transparent text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${!t.AvailableToBuy||o?"text-muted-foreground":""}`,disabled:!t.AvailableToBuy||o}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:tn,disabled:!t.AvailableToBuy||o,children:"+"})]}),jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:yn,disabled:!t.AvailableToBuy||o,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})})]})]})]}),jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-2 @[36rem]:flex-row",children:[jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",type:"button",className:"h-11 px-4 text-sm font-medium justify-start w-full",onClick:()=>ct(!0),disabled:!Vt,children:[jsxRuntime.jsx(ChartLine,{className:"mr-2"}),"View statistics"]})}),jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e??"",randmarSku:t.RandmarSKU??"",inventory:t.Distribution?.Inventory,buttonSize:"lg",buttonClassName:"w-full h-11 justify-start"})}),n&&jsxRuntime.jsx(reactRouterDom.Link,{to:n,className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-11 px-4 text-sm font-medium justify-start w-full",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})})]})]})]})}),jsxRuntime.jsx(Dialog,{open:ut,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{className:"w-[min(95vw,1100px)] max-w-5xl space-y-6",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Monthly Sales Performance"}),jsxRuntime.jsxs(DialogDescription,{children:["Expanded product insights for ",Yt,rn?` (SKU ${rn})`:""]})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:yt?jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(AlertTitle,{children:"Unable to load details"}),jsxRuntime.jsx(AlertDescription,{children:yt})]}):jsxRuntime.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[jsxRuntime.jsxs("div",{className:"mb-4 space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Rolling 12-month sales dollars and units sold pulled from the detailed endpoint."}),$t&&jsxRuntime.jsx("div",{"aria-live":"polite","aria-busy":"true",children:jsxRuntime.jsx(Progress,{value:Ft,className:"h-2 w-full animate-pulse","aria-label":"Loading performance data"})})]}),jsxRuntime.jsx(SalesChart,{statistics:Jt,mode:"month",chartHeight:320}),$t&&jsxRuntime.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Gathering product summary and sales statistics..."})]})})]})})]})}const imgSizeMap={sm:100,md:200,lg:300,xl:400},Placeholder=({size:e})=>jsxRuntime.jsx("div",{className:"rounded-md bg-muted flex items-center justify-center",style:{width:e,height:e},"aria-label":"Image not available",children:jsxRuntime.jsx(ImageOff,{className:"h-1/2 w-1/2 text-muted-foreground"})}),VideoSkeleton=()=>jsxRuntime.jsx(Skeleton,{className:"w-full",style:{aspectRatio:"16/9"}});function ProductImage({randmarSKU:e,sceneName:t,size:n="md",alt:s,secondaryContent:a}){const[o,l]=React__namespace.useState(!1),[c,d]=React__namespace.useState(!1),{sendMessageWithClear:f}=useChat(),R=useApiOrigin(),S=imgSizeMap[n],te=React.useRef(null),A=useIntersectionObserver({elementRef:te,threshold:.1,rootMargin:"100px"}),{data:rt,isFetching:st}=useGetProductByProductNumberImageExistsQuery({productNumber:e},{skip:!e||!A}),{data:it,isFetching:at}=useGetProductByRandmarSkuImageQuery({randmarSku:e,width:S*1.5,height:S*1.5},{skip:!rt}),{data:ot}=useGetProductByProductNumberVideoExistsQuery({productNumber:e},{skip:!e||!A}),{data:lt,isFetching:ut}=useGetProductByProductNumberVideoQuery({productNumber:e},{skip:!ot||!o}),ct=st||at;function dt(){if(lt)try{const yt=document.createElement("a");yt.href=lt,yt.download=`${e||"product"}-video.mp4`,yt.target="_blank",yt.rel="noopener noreferrer",document.body.appendChild(yt),yt.click(),document.body.removeChild(yt)}catch(yt){console.error("Error downloading video:",yt)}}function pt(){const yt=`/Product/${encodeURIComponent(e)}/Video`;navigator.clipboard.writeText(buildApiUrl(yt,R)),d(!0),setTimeout(()=>d(!1),2e3)}function mt(){ot&&l(!0)}const Rt=React__namespace.useCallback(()=>{if(!it)return;const yt=(t??"").trim(),It=yt?`Use this concept as a background/stage scene: "${yt}".`:"Use a modern and clean office as the background/stage, with no people present.";f(`Help me generate product images for (Randmar SKU: ${e}).
514
514
 
@@ -520,7 +520,7 @@ You can add a description to the \`${CONTENT_NAME$2}\` by passing a \`${DESCRIPT
520
520
 
521
521
  Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${CONTENT_NAME$2}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
522
522
 
523
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return React__namespace.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Root2$1=AlertDialog$1,Trigger2$1=AlertDialogTrigger$1,Portal2=AlertDialogPortal$1,Overlay2=AlertDialogOverlay$1,Content2$1=AlertDialogContent$1,Action=AlertDialogAction$1,Cancel=AlertDialogCancel$1,Title2=AlertDialogTitle$1,Description2=AlertDialogDescription$1;const AlertDialog=Root2$1,AlertDialogTrigger=Trigger2$1,AlertDialogPortal=Portal2,AlertDialogOverlay=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Overlay2,{className:cn("fixed inset-0 z-50 bg-foreground/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));AlertDialogOverlay.displayName=Overlay2.displayName;const AlertDialogContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs(AlertDialogPortal,{children:[jsxRuntime.jsx(AlertDialogOverlay,{}),jsxRuntime.jsx(Content2$1,{ref:n,className:cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));AlertDialogContent.displayName=Content2$1.displayName;const AlertDialogHeader=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col space-y-2 text-center sm:text-left",e),...t});AlertDialogHeader.displayName="AlertDialogHeader";const AlertDialogFooter=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});AlertDialogFooter.displayName="AlertDialogFooter";const AlertDialogTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Title2,{ref:n,className:cn("text-lg font-semibold",e),...t}));AlertDialogTitle.displayName=Title2.displayName;const AlertDialogDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Description2,{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));AlertDialogDescription.displayName=Description2.displayName;const AlertDialogAction=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Action,{ref:n,className:cn(buttonVariants(),e),...t}));AlertDialogAction.displayName=Action.displayName;const AlertDialogCancel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Cancel,{ref:n,className:cn(buttonVariants({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));AlertDialogCancel.displayName=Cancel.displayName;function parseDate(e){if(e==null)return null;const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function formatLastRefresh(e){const t=parseDate(e);if(!t)return"Never";const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()?`Today at ${new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}function RefreshCluster({lastRefreshAt:e,onRefresh:t,onProgressiveRefresh:n,onAssistantClick:s,isRefreshing:a=!1,refreshLabel:o="Refresh",assistantLabel:l="Assistant",className:c,disabled:d=!1}){const[f,R]=React__namespace.useState(!1),[S,te]=React__namespace.useState(e);React__namespace.useEffect(()=>{te(e)},[e]);const A=!!(t||n),rt=a||f,st=e??S,it=React__namespace.useCallback(async()=>{if(!(!A||d||rt)){R(!0);try{n?(await n(!1),await n(!0)):await t?.(),te(new Date)}finally{R(!1)}}},[A,d,rt,n,t]);return jsxRuntime.jsxs("div",{className:cn("flex flex-wrap items-center justify-end gap-2",c),children:[jsxRuntime.jsxs("p",{className:"text-xs text-muted-foreground sm:text-sm",children:["Last refresh:"," ",jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:formatLastRefresh(st)})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"outline",className:"min-h-11",disabled:d||rt||!A,onClick:it,children:[rt?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(RefreshCw,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:o})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"default",className:"min-h-11",disabled:d,onClick:s,children:[jsxRuntime.jsx(Bot,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l})]})]})}function DataRefreshAssistantCluster({onAssistantClick:e,assistantPromptOptions:t,onAssistantUnavailable:n,...s}){const a=useOptionalChat(),o=React__namespace.useCallback(()=>{if(e){e();return}if(t){if(!a){n?.();return}a.sendMessageWithClear(t.prompt,t.hiddenPrompt,t.sopID)||n?.();return}n?.()},[t,a,e,n]);return jsxRuntime.jsx(RefreshCluster,{...s,onAssistantClick:o})}function RmPageHeaderBreadcrumbLink({item:e,isCurrent:t}){return!t&&e.href?jsxRuntime.jsx("a",{href:e.href,className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:e.label}):!t&&e.onClick?jsxRuntime.jsx("button",{type:"button",className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:e.onClick,children:e.label}):jsxRuntime.jsx("span",{"aria-current":t?"page":void 0,className:cn("text-xs font-medium",t?"text-foreground":"text-muted-foreground"),children:e.label})}function RmPageHeaderBreadcrumbs({items:e}){return e.length===0?null:jsxRuntime.jsx("nav",{"aria-label":"Breadcrumb",className:"w-full",children:jsxRuntime.jsx("ol",{className:"flex flex-wrap items-center gap-1.5",children:e.map((t,n)=>{const s=n===e.length-1,a=t.key??`${String(t.label)}-${n}`;return jsxRuntime.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[jsxRuntime.jsx(RmPageHeaderBreadcrumbLink,{item:t,isCurrent:!!t.current||s}),s?null:jsxRuntime.jsx("span",{"aria-hidden":"true",className:"text-xs text-muted-foreground",children:"/"})]},a)})})})}function RmPageHeader({title:e,subtitle:t,breadcrumbs:n,rightTopActions:s,rightBottomActions:a,secondaryRow:o,sticky:l=!1,stickyClassName:c,className:d,cardClassName:f,contentClassName:R}){const S=!!(s||a),te=jsxRuntime.jsxs("header",{className:cn("w-full border-b border-border bg-background",d),children:[jsxRuntime.jsx("div",{className:cn("px-4 py-6 sm:px-6",f),children:jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",R),children:[jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[n?.length?jsxRuntime.jsx(RmPageHeaderBreadcrumbs,{items:n}):null,jsxRuntime.jsx("h1",{className:"text-2xl font-semibold leading-tight tracking-tight text-foreground",children:e}),t?jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),S?jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-start gap-2 lg:w-auto lg:min-w-[16rem] lg:items-end",children:[s?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:s}):null,a?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:a}):null]}):null]})}),o?jsxRuntime.jsx("div",{className:"border-t border-border bg-muted/40",children:jsxRuntime.jsx("div",{className:"px-4 py-4 sm:px-6",children:o})}):null]});return l?jsxRuntime.jsx("div",{className:cn("sticky top-0 z-20",c),children:te}):te}function PageHeader({title:e,children:t,className:n}){return jsxRuntime.jsx(RmPageHeader,{title:e,rightBottomActions:t?jsxRuntime.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:t}):void 0,cardClassName:n})}function OrderedMap(e){this.content=e}OrderedMap.prototype={constructor:OrderedMap,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var s=n&&n!=e?this.remove(n):this,a=s.find(e),o=s.content.slice();return a==-1?o.push(n||e,t):(o[a+1]=t,n&&(o[a]=n)),new OrderedMap(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new OrderedMap(n)},addToStart:function(e,t){return new OrderedMap([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new OrderedMap(n)},addBefore:function(e,t,n){var s=this.remove(t),a=s.content.slice(),o=s.find(e);return a.splice(o==-1?a.length:o,0,t,n),new OrderedMap(a)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=OrderedMap.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},OrderedMap.from=function(e){if(e instanceof OrderedMap)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new OrderedMap(t)};function findDiffStart(e,t,n){for(let s=0;;s++){if(s==e.childCount||s==t.childCount)return e.childCount==t.childCount?null:n;let a=e.child(s),o=t.child(s);if(a==o){n+=a.nodeSize;continue}if(!a.sameMarkup(o))return n;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)n++;return n}if(a.content.size||o.content.size){let l=findDiffStart(a.content,o.content,n+1);if(l!=null)return l}n+=a.nodeSize}}function findDiffEnd(e,t,n,s){for(let a=e.childCount,o=t.childCount;;){if(a==0||o==0)return a==o?null:{a:n,b:s};let l=e.child(--a),c=t.child(--o),d=l.nodeSize;if(l==c){n-=d,s-=d;continue}if(!l.sameMarkup(c))return{a:n,b:s};if(l.isText&&l.text!=c.text){let f=0,R=Math.min(l.text.length,c.text.length);for(;f<R&&l.text[l.text.length-f-1]==c.text[c.text.length-f-1];)f++,n--,s--;return{a:n,b:s}}if(l.content.size||c.content.size){let f=findDiffEnd(l.content,c.content,n-1,s-1);if(f)return f}n-=d,s-=d}}class Fragment{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let s=0;s<t.length;s++)this.size+=t[s].nodeSize}nodesBetween(t,n,s,a=0,o){for(let l=0,c=0;c<n;l++){let d=this.content[l],f=c+d.nodeSize;if(f>t&&s(d,a+c,o||null,l)!==!1&&d.content.size){let R=c+1;d.nodesBetween(Math.max(0,t-R),Math.min(d.content.size,n-R),s,a+R)}c=f}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,s,a){let o="",l=!0;return this.nodesBetween(t,n,(c,d)=>{let f=c.isText?c.text.slice(Math.max(t,d)-d,n-d):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&s&&(l?l=!1:o+=s),o+=f},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,s=t.firstChild,a=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),o=1);o<t.content.length;o++)a.push(t.content[o]);return new Fragment(a,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let s=[],a=0;if(n>t)for(let o=0,l=0;l<n;o++){let c=this.content[o],d=l+c.nodeSize;d>t&&((l<t||d>n)&&(c.isText?c=c.cut(Math.max(0,t-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,t-l-1),Math.min(c.content.size,n-l-1))),s.push(c),a+=c.nodeSize),l=d}return new Fragment(s,a)}cutByIndex(t,n){return t==n?Fragment.empty:t==0&&n==this.content.length?this:new Fragment(this.content.slice(t,n))}replaceChild(t,n){let s=this.content[t];if(s==n)return this;let a=this.content.slice(),o=this.size+n.nodeSize-s.nodeSize;return a[t]=n,new Fragment(a,o)}addToStart(t){return new Fragment([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Fragment(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,s=0;n<this.content.length;n++){let a=this.content[n];t(a,s,n),s+=a.nodeSize}}findDiffStart(t,n=0){return findDiffStart(this,t,n)}findDiffEnd(t,n=this.size,s=t.size){return findDiffEnd(this,t,n,s)}findIndex(t){if(t==0)return retIndex(0,t);if(t==this.size)return retIndex(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),o=s+a.nodeSize;if(o>=t)return o==t?retIndex(n+1,o):retIndex(n,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return Fragment.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Fragment(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Fragment.empty;let n,s=0;for(let a=0;a<t.length;a++){let o=t[a];s+=o.nodeSize,a&&o.isText&&t[a-1].sameMarkup(o)?(n||(n=t.slice(0,a)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new Fragment(n||t,s)}static from(t){if(!t)return Fragment.empty;if(t instanceof Fragment)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Fragment([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Fragment.empty=new Fragment([],0);const found={index:0,offset:0};function retIndex(e,t){return found.index=e,found.offset=t,found}function compareDeep(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!compareDeep(e[s],t[s]))return!1}else{for(let s in e)if(!(s in t)||!compareDeep(e[s],t[s]))return!1;for(let s in t)if(!(s in e))return!1}return!0}let Mark$1=class Hr{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,s=!1;for(let a=0;a<t.length;a++){let o=t[a];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,a));else{if(o.type.excludes(this.type))return t;!s&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,a)),n.push(this),s=!0),n&&n.push(o)}}return n||(n=t.slice()),s||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&compareDeep(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let s=t.marks[n.type];if(!s)throw new RangeError(`There is no mark type ${n.type} in this schema`);let a=s.create(n.attrs);return s.checkAttrs(a.attrs),a}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let s=0;s<t.length;s++)if(!t[s].eq(n[s]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Hr.none;if(t instanceof Hr)return[t];let n=t.slice();return n.sort((s,a)=>s.type.rank-a.type.rank),n}};Mark$1.none=[];class ReplaceError extends Error{}class Slice{constructor(t,n,s){this.content=t,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let s=insertInto(this.content,t+this.openStart,n);return s&&new Slice(s,this.openStart,this.openEnd)}removeBetween(t,n){return new Slice(removeRange(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Slice.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Slice(Fragment.fromJSON(t,n.content),s,a)}static maxOpen(t,n=!0){let s=0,a=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)s++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)a++;return new Slice(t,s,a)}}Slice.empty=new Slice(Fragment.empty,0,0);function removeRange(e,t,n){let{index:s,offset:a}=e.findIndex(t),o=e.maybeChild(s),{index:l,offset:c}=e.findIndex(n);if(a==t||o.isText){if(c!=n&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(s!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(s,o.copy(removeRange(o.content,t-a-1,n-a-1)))}function insertInto(e,t,n,s){let{index:a,offset:o}=e.findIndex(t),l=e.maybeChild(a);if(o==t||l.isText)return s&&!s.canReplace(a,a,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=insertInto(l.content,t-o-1,n,l);return c&&e.replaceChild(a,l.copy(c))}function replace(e,t,n){if(n.openStart>e.depth)throw new ReplaceError("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ReplaceError("Inconsistent open depths");return replaceOuter(e,t,n,0)}function replaceOuter(e,t,n,s){let a=e.index(s),o=e.node(s);if(a==t.index(s)&&s<e.depth-n.openStart){let l=replaceOuter(e,t,n,s+1);return o.copy(o.content.replaceChild(a,l))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==s&&t.depth==s){let l=e.parent,c=l.content;return close(l,c.cut(0,e.parentOffset).append(n.content).append(c.cut(t.parentOffset)))}else{let{start:l,end:c}=prepareSliceForReplace(n,e);return close(o,replaceThreeWay(e,l,c,t,s))}else return close(o,replaceTwoWay(e,t,s))}function checkJoin(e,t){if(!t.type.compatibleContent(e.type))throw new ReplaceError("Cannot join "+t.type.name+" onto "+e.type.name)}function joinable$1(e,t,n){let s=e.node(n);return checkJoin(s,t.node(n)),s}function addNode(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function addRange(e,t,n,s){let a=(t||e).node(n),o=0,l=t?t.index(n):a.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(addNode(e.nodeAfter,s),o++));for(let c=o;c<l;c++)addNode(a.child(c),s);t&&t.depth==n&&t.textOffset&&addNode(t.nodeBefore,s)}function close(e,t){return e.type.checkContent(t),e.copy(t)}function replaceThreeWay(e,t,n,s,a){let o=e.depth>a&&joinable$1(e,t,a+1),l=s.depth>a&&joinable$1(n,s,a+1),c=[];return addRange(null,e,a,c),o&&l&&t.index(a)==n.index(a)?(checkJoin(o,l),addNode(close(o,replaceThreeWay(e,t,n,s,a+1)),c)):(o&&addNode(close(o,replaceTwoWay(e,t,a+1)),c),addRange(t,n,a,c),l&&addNode(close(l,replaceTwoWay(n,s,a+1)),c)),addRange(s,null,a,c),new Fragment(c)}function replaceTwoWay(e,t,n){let s=[];if(addRange(null,e,n,s),e.depth>n){let a=joinable$1(e,t,n+1);addNode(close(a,replaceTwoWay(e,t,n+1)),s)}return addRange(t,null,n,s),new Fragment(s)}function prepareSliceForReplace(e,t){let n=t.depth-e.openStart,a=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)a=t.node(o).copy(Fragment.from(a));return{start:a.resolveNoCache(e.openStart+n),end:a.resolveNoCache(a.content.size-e.openEnd-n)}}class ResolvedPos{constructor(t,n,s){this.pos=t,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=t.child(n);return s?t.child(n).cut(s):a}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let o=0;o<t;o++)a+=s.child(o).nodeSize;return a}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return Mark$1.none;if(this.textOffset)return t.child(n).marks;let s=t.maybeChild(n-1),a=t.maybeChild(n);if(!s){let c=s;s=a,a=c}let o=s.marks;for(var l=0;l<o.length;l++)o[l].type.spec.inclusive===!1&&(!a||!o[l].isInSet(a.marks))&&(o=o[l--].removeFromSet(o));return o}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let s=n.marks,a=t.parent.maybeChild(t.index());for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!a||!s[o].isInSet(a.marks))&&(s=s[o--].removeFromSet(s));return s}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let s=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);s>=0;s--)if(t.pos<=this.end(s)&&(!n||n(this.node(s))))return new NodeRange(this,t,s);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,o=n;for(let l=t;;){let{index:c,offset:d}=l.content.findIndex(o),f=o-d;if(s.push(l,c,a+d),!f||(l=l.child(c),l.isText))break;o=f-1,a+=d+1}return new ResolvedPos(n,s,o)}static resolveCached(t,n){let s=resolveCache.get(t);if(s)for(let o=0;o<s.elts.length;o++){let l=s.elts[o];if(l.pos==n)return l}else resolveCache.set(t,s=new ResolveCache);let a=s.elts[s.i]=ResolvedPos.resolve(t,n);return s.i=(s.i+1)%resolveCacheSize,a}}class ResolveCache{constructor(){this.elts=[],this.i=0}}const resolveCacheSize=12,resolveCache=new WeakMap;class NodeRange{constructor(t,n,s){this.$from=t,this.$to=n,this.depth=s}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const emptyAttrs=Object.create(null);let Node$1=class Wr{constructor(t,n,s,a=Mark$1.none){this.type=t,this.attrs=n,this.marks=a,this.content=s||Fragment.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,s,a=0){this.content.nodesBetween(t,n,s,a,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,s,a){return this.content.textBetween(t,n,s,a)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,s){return this.type==t&&compareDeep(this.attrs,n||t.defaultAttrs||emptyAttrs)&&Mark$1.sameSet(this.marks,s||Mark$1.none)}copy(t=null){return t==this.content?this:new Wr(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Wr(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,s=!1){if(t==n)return Slice.empty;let a=this.resolve(t),o=this.resolve(n),l=s?0:a.sharedDepth(n),c=a.start(l),f=a.node(l).content.cut(a.pos-c,o.pos-c);return new Slice(f,a.depth-l,o.depth-l)}replace(t,n,s){return replace(this.resolve(t),this.resolve(n),s)}nodeAt(t){for(let n=this;;){let{index:s,offset:a}=n.content.findIndex(t);if(n=n.maybeChild(s),!n)return null;if(a==t||n.isText)return n;t-=a+1}}childAfter(t){let{index:n,offset:s}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:s}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:s}=this.content.findIndex(t);if(s<t)return{node:this.content.child(n),index:n,offset:s};let a=this.content.child(n-1);return{node:a,index:n-1,offset:s-a.nodeSize}}resolve(t){return ResolvedPos.resolveCached(this,t)}resolveNoCache(t){return ResolvedPos.resolve(this,t)}rangeHasMark(t,n,s){let a=!1;return n>t&&this.nodesBetween(t,n,o=>(s.isInSet(o.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),wrapMarks(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,s=Fragment.empty,a=0,o=s.childCount){let l=this.contentMatchAt(t).matchFragment(s,a,o),c=l&&l.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let d=a;d<o;d++)if(!this.type.allowsMarks(s.child(d).marks))return!1;return!0}canReplaceWith(t,n,s,a){if(a&&!this.type.allowsMarks(a))return!1;let o=this.contentMatchAt(t).matchType(s),l=o&&o.matchFragment(this.content,n);return l?l.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=Mark$1.none;for(let n=0;n<this.marks.length;n++){let s=this.marks[n];s.type.checkAttrs(s.attrs),t=s.addToSet(t)}if(!Mark$1.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,s)}let a=Fragment.fromJSON(t,n.content),o=t.nodeType(n.type).create(n.attrs,a,s);return o.type.checkAttrs(o.attrs),o}};Node$1.prototype.text=void 0;class TextNode extends Node$1{constructor(t,n,s,a){if(super(t,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wrapMarks(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new TextNode(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new TextNode(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function wrapMarks(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ContentMatch{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let s=new TokenStream(t,n);if(s.next==null)return ContentMatch.empty;let a=parseExpr(s);s.next&&s.err("Unexpected trailing text");let o=dfa(nfa(a));return checkForDeadEnds(o,s),o}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,s=t.childCount){let a=this;for(let o=n;a&&o<s;o++)a=a.matchType(t.child(o).type);return a}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let s=0;s<t.next.length;s++)if(this.next[n].type==t.next[s].type)return!0;return!1}fillBefore(t,n=!1,s=0){let a=[this];function o(l,c){let d=l.matchFragment(t,s);if(d&&(!n||d.validEnd))return Fragment.from(c.map(f=>f.createAndFill()));for(let f=0;f<l.next.length;f++){let{type:R,next:S}=l.next[f];if(!(R.isText||R.hasRequiredAttrs())&&a.indexOf(S)==-1){a.push(S);let te=o(S,c.concat(R));if(te)return te}}return null}return o(this,[])}findWrapping(t){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==t)return this.wrapCache[s+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let a=s.shift(),o=a.match;if(o.matchType(t)){let l=[];for(let c=a;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<o.next.length;l++){let{type:c,next:d}=o.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!a.type||d.validEnd)&&(s.push({match:c.contentMatch,type:c,via:a}),n[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(s){t.push(s);for(let a=0;a<s.next.length;a++)t.indexOf(s.next[a].next)==-1&&n(s.next[a].next)}return n(this),t.map((s,a)=>{let o=a+(s.validEnd?"*":" ")+" ";for(let l=0;l<s.next.length;l++)o+=(l?", ":"")+s.next[l].type.name+"->"+t.indexOf(s.next[l].next);return o}).join(`
523
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return React__namespace.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Root2$1=AlertDialog$1,Trigger2$1=AlertDialogTrigger$1,Portal2=AlertDialogPortal$1,Overlay2=AlertDialogOverlay$1,Content2$1=AlertDialogContent$1,Action=AlertDialogAction$1,Cancel=AlertDialogCancel$1,Title2=AlertDialogTitle$1,Description2=AlertDialogDescription$1;const AlertDialog=Root2$1,AlertDialogTrigger=Trigger2$1,AlertDialogPortal=Portal2,AlertDialogOverlay=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Overlay2,{className:cn("fixed inset-0 z-50 bg-foreground/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));AlertDialogOverlay.displayName=Overlay2.displayName;const AlertDialogContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs(AlertDialogPortal,{children:[jsxRuntime.jsx(AlertDialogOverlay,{}),jsxRuntime.jsx(Content2$1,{ref:n,className:cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));AlertDialogContent.displayName=Content2$1.displayName;const AlertDialogHeader=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col space-y-2 text-center sm:text-left",e),...t});AlertDialogHeader.displayName="AlertDialogHeader";const AlertDialogFooter=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});AlertDialogFooter.displayName="AlertDialogFooter";const AlertDialogTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Title2,{ref:n,className:cn("text-lg font-semibold",e),...t}));AlertDialogTitle.displayName=Title2.displayName;const AlertDialogDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Description2,{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));AlertDialogDescription.displayName=Description2.displayName;const AlertDialogAction=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Action,{ref:n,className:cn(buttonVariants(),e),...t}));AlertDialogAction.displayName=Action.displayName;const AlertDialogCancel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Cancel,{ref:n,className:cn(buttonVariants({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));AlertDialogCancel.displayName=Cancel.displayName;function parseDate(e){if(e==null)return null;const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function formatLastRefresh(e){const t=parseDate(e);if(!t)return"Never";const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()?`Today at ${new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}function RefreshCluster({lastRefreshAt:e,onRefresh:t,onProgressiveRefresh:n,onAssistantClick:s,isRefreshing:a=!1,refreshLabel:o="Refresh",assistantLabel:l="Assistant",className:c,disabled:d=!1}){const[f,R]=React__namespace.useState(!1),[S,te]=React__namespace.useState(e);React__namespace.useEffect(()=>{te(e)},[e]);const A=!!(t||n),rt=a||f,st=e??S,it=React__namespace.useCallback(async()=>{if(!(!A||d||rt)){R(!0);try{n?(await n(!1),await n(!0)):await t?.(),te(new Date)}finally{R(!1)}}},[A,d,rt,n,t]);return jsxRuntime.jsxs("div",{className:cn("flex flex-wrap items-center justify-end gap-2",c),children:[jsxRuntime.jsxs("p",{className:"text-xs text-muted-foreground sm:text-sm",children:["Last refresh:"," ",jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:formatLastRefresh(st)})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"outline",className:"min-h-11",disabled:d||rt||!A,onClick:it,children:[rt?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(RefreshCw,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:o})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"default",className:"min-h-11",disabled:d,onClick:s,children:[jsxRuntime.jsx(Bot,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l})]})]})}function DataRefreshAssistantCluster({onAssistantClick:e,assistantPromptOptions:t,onAssistantUnavailable:n,...s}){const a=useOptionalChat(),o=React__namespace.useCallback(()=>{if(e){e();return}if(t){if(!a){n?.();return}a.sendMessageWithClear(t.prompt,t.hiddenPrompt,t.sopID)||n?.();return}n?.()},[t,a,e,n]);return jsxRuntime.jsx(RefreshCluster,{...s,onAssistantClick:o})}const roundToPixel=e=>Math.round(e*100)/100;function getMainContentRegion(e){return e.closest("main, [data-rm-main-content-region]")}function getRegionBounds(e){if(e){const t=e.getBoundingClientRect();return{left:t.left,right:t.right}}return{left:0,right:document.documentElement.clientWidth}}function RmPageHeaderBreadcrumbLink({item:e,isCurrent:t}){return!t&&e.href?jsxRuntime.jsx("a",{href:e.href,className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:e.label}):!t&&e.onClick?jsxRuntime.jsx("button",{type:"button",className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:e.onClick,children:e.label}):jsxRuntime.jsx("span",{"aria-current":t?"page":void 0,className:cn("text-xs font-medium",t?"text-foreground":"text-muted-foreground"),children:e.label})}function RmPageHeaderBreadcrumbs({items:e}){return e.length===0?null:jsxRuntime.jsx("nav",{"aria-label":"Breadcrumb",className:"w-full",children:jsxRuntime.jsx("ol",{className:"flex flex-wrap items-center gap-1.5",children:e.map((t,n)=>{const s=n===e.length-1,a=t.key??`${String(t.label)}-${n}`;return jsxRuntime.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[jsxRuntime.jsx(RmPageHeaderBreadcrumbLink,{item:t,isCurrent:!!t.current||s}),s?null:jsxRuntime.jsx("span",{"aria-hidden":"true",className:"text-xs text-muted-foreground",children:"/"})]},a)})})})}function RmPageHeader({title:e,subtitle:t,breadcrumbs:n,rightTopActions:s,rightBottomActions:a,secondaryRow:o,sticky:l=!1,stickyClassName:c,className:d,cardClassName:f,contentClassName:R}){const S=React__namespace.useRef(null);React__namespace.useEffect(()=>{if(typeof window>"u")return;const rt=S.current;if(!rt)return;const st=getMainContentRegion(rt);let it=null;const at=()=>{const ut=rt.getBoundingClientRect(),ct=getRegionBounds(st),dt=roundToPixel(ct.left-ut.left),pt=roundToPixel(ut.right-ct.right);rt.style.marginLeft=`${dt}px`,rt.style.marginRight=`${pt}px`},ot=()=>{it!==null&&window.cancelAnimationFrame(it),it=window.requestAnimationFrame(()=>{at(),it=null})};ot();const lt=typeof ResizeObserver<"u"?new ResizeObserver(ot):null;return lt&&(lt.observe(rt),lt.observe(document.documentElement),st&&lt.observe(st)),window.addEventListener("resize",ot),window.addEventListener("orientationchange",ot),()=>{it!==null&&window.cancelAnimationFrame(it),lt?.disconnect(),window.removeEventListener("resize",ot),window.removeEventListener("orientationchange",ot),rt.style.marginLeft="",rt.style.marginRight=""}},[]);const te=!!(s||a),A=jsxRuntime.jsxs("header",{className:cn("w-full border-b border-border bg-background",d),children:[jsxRuntime.jsx("div",{className:cn("px-4 py-6 sm:px-6",f),children:jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",R),children:[jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[n?.length?jsxRuntime.jsx(RmPageHeaderBreadcrumbs,{items:n}):null,jsxRuntime.jsx("h1",{className:"text-2xl font-semibold leading-tight tracking-tight text-foreground",children:e}),t?jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),te?jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-start gap-2 lg:w-auto lg:min-w-[16rem] lg:items-end",children:[s?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:s}):null,a?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:a}):null]}):null]})}),o?jsxRuntime.jsx("div",{className:"border-t border-border bg-muted/40",children:jsxRuntime.jsx("div",{className:"px-4 py-4 sm:px-6",children:o})}):null]});return l?jsxRuntime.jsx("div",{ref:S,children:jsxRuntime.jsx("div",{className:cn("sticky top-0 z-20",c),children:A})}):jsxRuntime.jsx("div",{ref:S,children:A})}function PageHeader({title:e,children:t,className:n}){return jsxRuntime.jsx(RmPageHeader,{title:e,rightBottomActions:t?jsxRuntime.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:t}):void 0,cardClassName:n})}function OrderedMap(e){this.content=e}OrderedMap.prototype={constructor:OrderedMap,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var s=n&&n!=e?this.remove(n):this,a=s.find(e),o=s.content.slice();return a==-1?o.push(n||e,t):(o[a+1]=t,n&&(o[a]=n)),new OrderedMap(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new OrderedMap(n)},addToStart:function(e,t){return new OrderedMap([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new OrderedMap(n)},addBefore:function(e,t,n){var s=this.remove(t),a=s.content.slice(),o=s.find(e);return a.splice(o==-1?a.length:o,0,t,n),new OrderedMap(a)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=OrderedMap.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},OrderedMap.from=function(e){if(e instanceof OrderedMap)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new OrderedMap(t)};function findDiffStart(e,t,n){for(let s=0;;s++){if(s==e.childCount||s==t.childCount)return e.childCount==t.childCount?null:n;let a=e.child(s),o=t.child(s);if(a==o){n+=a.nodeSize;continue}if(!a.sameMarkup(o))return n;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)n++;return n}if(a.content.size||o.content.size){let l=findDiffStart(a.content,o.content,n+1);if(l!=null)return l}n+=a.nodeSize}}function findDiffEnd(e,t,n,s){for(let a=e.childCount,o=t.childCount;;){if(a==0||o==0)return a==o?null:{a:n,b:s};let l=e.child(--a),c=t.child(--o),d=l.nodeSize;if(l==c){n-=d,s-=d;continue}if(!l.sameMarkup(c))return{a:n,b:s};if(l.isText&&l.text!=c.text){let f=0,R=Math.min(l.text.length,c.text.length);for(;f<R&&l.text[l.text.length-f-1]==c.text[c.text.length-f-1];)f++,n--,s--;return{a:n,b:s}}if(l.content.size||c.content.size){let f=findDiffEnd(l.content,c.content,n-1,s-1);if(f)return f}n-=d,s-=d}}class Fragment{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let s=0;s<t.length;s++)this.size+=t[s].nodeSize}nodesBetween(t,n,s,a=0,o){for(let l=0,c=0;c<n;l++){let d=this.content[l],f=c+d.nodeSize;if(f>t&&s(d,a+c,o||null,l)!==!1&&d.content.size){let R=c+1;d.nodesBetween(Math.max(0,t-R),Math.min(d.content.size,n-R),s,a+R)}c=f}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,s,a){let o="",l=!0;return this.nodesBetween(t,n,(c,d)=>{let f=c.isText?c.text.slice(Math.max(t,d)-d,n-d):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&s&&(l?l=!1:o+=s),o+=f},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,s=t.firstChild,a=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),o=1);o<t.content.length;o++)a.push(t.content[o]);return new Fragment(a,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let s=[],a=0;if(n>t)for(let o=0,l=0;l<n;o++){let c=this.content[o],d=l+c.nodeSize;d>t&&((l<t||d>n)&&(c.isText?c=c.cut(Math.max(0,t-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,t-l-1),Math.min(c.content.size,n-l-1))),s.push(c),a+=c.nodeSize),l=d}return new Fragment(s,a)}cutByIndex(t,n){return t==n?Fragment.empty:t==0&&n==this.content.length?this:new Fragment(this.content.slice(t,n))}replaceChild(t,n){let s=this.content[t];if(s==n)return this;let a=this.content.slice(),o=this.size+n.nodeSize-s.nodeSize;return a[t]=n,new Fragment(a,o)}addToStart(t){return new Fragment([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Fragment(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,s=0;n<this.content.length;n++){let a=this.content[n];t(a,s,n),s+=a.nodeSize}}findDiffStart(t,n=0){return findDiffStart(this,t,n)}findDiffEnd(t,n=this.size,s=t.size){return findDiffEnd(this,t,n,s)}findIndex(t){if(t==0)return retIndex(0,t);if(t==this.size)return retIndex(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),o=s+a.nodeSize;if(o>=t)return o==t?retIndex(n+1,o):retIndex(n,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return Fragment.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Fragment(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Fragment.empty;let n,s=0;for(let a=0;a<t.length;a++){let o=t[a];s+=o.nodeSize,a&&o.isText&&t[a-1].sameMarkup(o)?(n||(n=t.slice(0,a)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new Fragment(n||t,s)}static from(t){if(!t)return Fragment.empty;if(t instanceof Fragment)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Fragment([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Fragment.empty=new Fragment([],0);const found={index:0,offset:0};function retIndex(e,t){return found.index=e,found.offset=t,found}function compareDeep(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!compareDeep(e[s],t[s]))return!1}else{for(let s in e)if(!(s in t)||!compareDeep(e[s],t[s]))return!1;for(let s in t)if(!(s in e))return!1}return!0}let Mark$1=class Hr{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,s=!1;for(let a=0;a<t.length;a++){let o=t[a];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,a));else{if(o.type.excludes(this.type))return t;!s&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,a)),n.push(this),s=!0),n&&n.push(o)}}return n||(n=t.slice()),s||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&compareDeep(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let s=t.marks[n.type];if(!s)throw new RangeError(`There is no mark type ${n.type} in this schema`);let a=s.create(n.attrs);return s.checkAttrs(a.attrs),a}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let s=0;s<t.length;s++)if(!t[s].eq(n[s]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Hr.none;if(t instanceof Hr)return[t];let n=t.slice();return n.sort((s,a)=>s.type.rank-a.type.rank),n}};Mark$1.none=[];class ReplaceError extends Error{}class Slice{constructor(t,n,s){this.content=t,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let s=insertInto(this.content,t+this.openStart,n);return s&&new Slice(s,this.openStart,this.openEnd)}removeBetween(t,n){return new Slice(removeRange(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Slice.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Slice(Fragment.fromJSON(t,n.content),s,a)}static maxOpen(t,n=!0){let s=0,a=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)s++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)a++;return new Slice(t,s,a)}}Slice.empty=new Slice(Fragment.empty,0,0);function removeRange(e,t,n){let{index:s,offset:a}=e.findIndex(t),o=e.maybeChild(s),{index:l,offset:c}=e.findIndex(n);if(a==t||o.isText){if(c!=n&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(s!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(s,o.copy(removeRange(o.content,t-a-1,n-a-1)))}function insertInto(e,t,n,s){let{index:a,offset:o}=e.findIndex(t),l=e.maybeChild(a);if(o==t||l.isText)return s&&!s.canReplace(a,a,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=insertInto(l.content,t-o-1,n,l);return c&&e.replaceChild(a,l.copy(c))}function replace(e,t,n){if(n.openStart>e.depth)throw new ReplaceError("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ReplaceError("Inconsistent open depths");return replaceOuter(e,t,n,0)}function replaceOuter(e,t,n,s){let a=e.index(s),o=e.node(s);if(a==t.index(s)&&s<e.depth-n.openStart){let l=replaceOuter(e,t,n,s+1);return o.copy(o.content.replaceChild(a,l))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==s&&t.depth==s){let l=e.parent,c=l.content;return close(l,c.cut(0,e.parentOffset).append(n.content).append(c.cut(t.parentOffset)))}else{let{start:l,end:c}=prepareSliceForReplace(n,e);return close(o,replaceThreeWay(e,l,c,t,s))}else return close(o,replaceTwoWay(e,t,s))}function checkJoin(e,t){if(!t.type.compatibleContent(e.type))throw new ReplaceError("Cannot join "+t.type.name+" onto "+e.type.name)}function joinable$1(e,t,n){let s=e.node(n);return checkJoin(s,t.node(n)),s}function addNode(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function addRange(e,t,n,s){let a=(t||e).node(n),o=0,l=t?t.index(n):a.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(addNode(e.nodeAfter,s),o++));for(let c=o;c<l;c++)addNode(a.child(c),s);t&&t.depth==n&&t.textOffset&&addNode(t.nodeBefore,s)}function close(e,t){return e.type.checkContent(t),e.copy(t)}function replaceThreeWay(e,t,n,s,a){let o=e.depth>a&&joinable$1(e,t,a+1),l=s.depth>a&&joinable$1(n,s,a+1),c=[];return addRange(null,e,a,c),o&&l&&t.index(a)==n.index(a)?(checkJoin(o,l),addNode(close(o,replaceThreeWay(e,t,n,s,a+1)),c)):(o&&addNode(close(o,replaceTwoWay(e,t,a+1)),c),addRange(t,n,a,c),l&&addNode(close(l,replaceTwoWay(n,s,a+1)),c)),addRange(s,null,a,c),new Fragment(c)}function replaceTwoWay(e,t,n){let s=[];if(addRange(null,e,n,s),e.depth>n){let a=joinable$1(e,t,n+1);addNode(close(a,replaceTwoWay(e,t,n+1)),s)}return addRange(t,null,n,s),new Fragment(s)}function prepareSliceForReplace(e,t){let n=t.depth-e.openStart,a=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)a=t.node(o).copy(Fragment.from(a));return{start:a.resolveNoCache(e.openStart+n),end:a.resolveNoCache(a.content.size-e.openEnd-n)}}class ResolvedPos{constructor(t,n,s){this.pos=t,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=t.child(n);return s?t.child(n).cut(s):a}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let o=0;o<t;o++)a+=s.child(o).nodeSize;return a}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return Mark$1.none;if(this.textOffset)return t.child(n).marks;let s=t.maybeChild(n-1),a=t.maybeChild(n);if(!s){let c=s;s=a,a=c}let o=s.marks;for(var l=0;l<o.length;l++)o[l].type.spec.inclusive===!1&&(!a||!o[l].isInSet(a.marks))&&(o=o[l--].removeFromSet(o));return o}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let s=n.marks,a=t.parent.maybeChild(t.index());for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!a||!s[o].isInSet(a.marks))&&(s=s[o--].removeFromSet(s));return s}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let s=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);s>=0;s--)if(t.pos<=this.end(s)&&(!n||n(this.node(s))))return new NodeRange(this,t,s);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,o=n;for(let l=t;;){let{index:c,offset:d}=l.content.findIndex(o),f=o-d;if(s.push(l,c,a+d),!f||(l=l.child(c),l.isText))break;o=f-1,a+=d+1}return new ResolvedPos(n,s,o)}static resolveCached(t,n){let s=resolveCache.get(t);if(s)for(let o=0;o<s.elts.length;o++){let l=s.elts[o];if(l.pos==n)return l}else resolveCache.set(t,s=new ResolveCache);let a=s.elts[s.i]=ResolvedPos.resolve(t,n);return s.i=(s.i+1)%resolveCacheSize,a}}class ResolveCache{constructor(){this.elts=[],this.i=0}}const resolveCacheSize=12,resolveCache=new WeakMap;class NodeRange{constructor(t,n,s){this.$from=t,this.$to=n,this.depth=s}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const emptyAttrs=Object.create(null);let Node$1=class Wr{constructor(t,n,s,a=Mark$1.none){this.type=t,this.attrs=n,this.marks=a,this.content=s||Fragment.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,s,a=0){this.content.nodesBetween(t,n,s,a,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,s,a){return this.content.textBetween(t,n,s,a)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,s){return this.type==t&&compareDeep(this.attrs,n||t.defaultAttrs||emptyAttrs)&&Mark$1.sameSet(this.marks,s||Mark$1.none)}copy(t=null){return t==this.content?this:new Wr(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Wr(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,s=!1){if(t==n)return Slice.empty;let a=this.resolve(t),o=this.resolve(n),l=s?0:a.sharedDepth(n),c=a.start(l),f=a.node(l).content.cut(a.pos-c,o.pos-c);return new Slice(f,a.depth-l,o.depth-l)}replace(t,n,s){return replace(this.resolve(t),this.resolve(n),s)}nodeAt(t){for(let n=this;;){let{index:s,offset:a}=n.content.findIndex(t);if(n=n.maybeChild(s),!n)return null;if(a==t||n.isText)return n;t-=a+1}}childAfter(t){let{index:n,offset:s}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:s}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:s}=this.content.findIndex(t);if(s<t)return{node:this.content.child(n),index:n,offset:s};let a=this.content.child(n-1);return{node:a,index:n-1,offset:s-a.nodeSize}}resolve(t){return ResolvedPos.resolveCached(this,t)}resolveNoCache(t){return ResolvedPos.resolve(this,t)}rangeHasMark(t,n,s){let a=!1;return n>t&&this.nodesBetween(t,n,o=>(s.isInSet(o.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),wrapMarks(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,s=Fragment.empty,a=0,o=s.childCount){let l=this.contentMatchAt(t).matchFragment(s,a,o),c=l&&l.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let d=a;d<o;d++)if(!this.type.allowsMarks(s.child(d).marks))return!1;return!0}canReplaceWith(t,n,s,a){if(a&&!this.type.allowsMarks(a))return!1;let o=this.contentMatchAt(t).matchType(s),l=o&&o.matchFragment(this.content,n);return l?l.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=Mark$1.none;for(let n=0;n<this.marks.length;n++){let s=this.marks[n];s.type.checkAttrs(s.attrs),t=s.addToSet(t)}if(!Mark$1.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,s)}let a=Fragment.fromJSON(t,n.content),o=t.nodeType(n.type).create(n.attrs,a,s);return o.type.checkAttrs(o.attrs),o}};Node$1.prototype.text=void 0;class TextNode extends Node$1{constructor(t,n,s,a){if(super(t,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wrapMarks(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new TextNode(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new TextNode(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function wrapMarks(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ContentMatch{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let s=new TokenStream(t,n);if(s.next==null)return ContentMatch.empty;let a=parseExpr(s);s.next&&s.err("Unexpected trailing text");let o=dfa(nfa(a));return checkForDeadEnds(o,s),o}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,s=t.childCount){let a=this;for(let o=n;a&&o<s;o++)a=a.matchType(t.child(o).type);return a}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let s=0;s<t.next.length;s++)if(this.next[n].type==t.next[s].type)return!0;return!1}fillBefore(t,n=!1,s=0){let a=[this];function o(l,c){let d=l.matchFragment(t,s);if(d&&(!n||d.validEnd))return Fragment.from(c.map(f=>f.createAndFill()));for(let f=0;f<l.next.length;f++){let{type:R,next:S}=l.next[f];if(!(R.isText||R.hasRequiredAttrs())&&a.indexOf(S)==-1){a.push(S);let te=o(S,c.concat(R));if(te)return te}}return null}return o(this,[])}findWrapping(t){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==t)return this.wrapCache[s+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let a=s.shift(),o=a.match;if(o.matchType(t)){let l=[];for(let c=a;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<o.next.length;l++){let{type:c,next:d}=o.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!a.type||d.validEnd)&&(s.push({match:c.contentMatch,type:c,via:a}),n[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(s){t.push(s);for(let a=0;a<s.next.length;a++)t.indexOf(s.next[a].next)==-1&&n(s.next[a].next)}return n(this),t.map((s,a)=>{let o=a+(s.validEnd?"*":" ")+" ";for(let l=0;l<s.next.length;l++)o+=(l?", ":"")+s.next[l].type.name+"->"+t.indexOf(s.next[l].next);return o}).join(`
524
524
  `)}}ContentMatch.empty=new ContentMatch(!0);class TokenStream{constructor(t,n){this.string=t,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function parseExpr(e){let t=[];do t.push(parseExprSeq(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function parseExprSeq(e){let t=[];do t.push(parseExprSubscript(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function parseExprSubscript(e){let t=parseExprAtom(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=parseExprRange(e,t);else break;return t}function parseNum(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function parseExprRange(e,t){let n=parseNum(e),s=n;return e.eat(",")&&(e.next!="}"?s=parseNum(e):s=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:s,expr:t}}function resolveName(e,t){let n=e.nodeTypes,s=n[t];if(s)return[s];let a=[];for(let o in n){let l=n[o];l.isInGroup(t)&&a.push(l)}return a.length==0&&e.err("No node type or group '"+t+"' found"),a}function parseExprAtom(e){if(e.eat("(")){let t=parseExpr(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=resolveName(e,e.next).map(n=>(e.inline==null?e.inline=n.isInline:e.inline!=n.isInline&&e.err("Mixing inline and block content"),{type:"name",value:n}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function nfa(e){let t=[[]];return a(o(e,0),n()),t;function n(){return t.push([])-1}function s(l,c,d){let f={term:d,to:c};return t[l].push(f),f}function a(l,c){l.forEach(d=>d.to=c)}function o(l,c){if(l.type=="choice")return l.exprs.reduce((d,f)=>d.concat(o(f,c)),[]);if(l.type=="seq")for(let d=0;;d++){let f=o(l.exprs[d],c);if(d==l.exprs.length-1)return f;a(f,c=n())}else if(l.type=="star"){let d=n();return s(c,d),a(o(l.expr,d),d),[s(d)]}else if(l.type=="plus"){let d=n();return a(o(l.expr,c),d),a(o(l.expr,d),d),[s(d)]}else{if(l.type=="opt")return[s(c)].concat(o(l.expr,c));if(l.type=="range"){let d=c;for(let f=0;f<l.min;f++){let R=n();a(o(l.expr,d),R),d=R}if(l.max==-1)a(o(l.expr,d),d);else for(let f=l.min;f<l.max;f++){let R=n();s(d,R),a(o(l.expr,d),R),d=R}return[s(d)]}else{if(l.type=="name")return[s(c,void 0,l.value)];throw new Error("Unknown expr type")}}}}function cmp(e,t){return t-e}function nullFrom(e,t){let n=[];return s(t),n.sort(cmp);function s(a){let o=e[a];if(o.length==1&&!o[0].term)return s(o[0].to);n.push(a);for(let l=0;l<o.length;l++){let{term:c,to:d}=o[l];!c&&n.indexOf(d)==-1&&s(d)}}}function dfa(e){let t=Object.create(null);return n(nullFrom(e,0));function n(s){let a=[];s.forEach(l=>{e[l].forEach(({term:c,to:d})=>{if(!c)return;let f;for(let R=0;R<a.length;R++)a[R][0]==c&&(f=a[R][1]);nullFrom(e,d).forEach(R=>{f||a.push([c,f=[]]),f.indexOf(R)==-1&&f.push(R)})})});let o=t[s.join(",")]=new ContentMatch(s.indexOf(e.length-1)>-1);for(let l=0;l<a.length;l++){let c=a[l][1].sort(cmp);o.next.push({type:a[l][0],next:t[c.join(",")]||n(c)})}return o}}function checkForDeadEnds(e,t){for(let n=0,s=[e];n<s.length;n++){let a=s[n],o=!a.validEnd,l=[];for(let c=0;c<a.next.length;c++){let{type:d,next:f}=a.next[c];l.push(d.name),o&&!(d.isText||d.hasRequiredAttrs())&&(o=!1),s.indexOf(f)==-1&&s.push(f)}o&&t.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function defaultAttrs(e){let t=Object.create(null);for(let n in e){let s=e[n];if(!s.hasDefault)return null;t[n]=s.default}return t}function computeAttrs(e,t){let n=Object.create(null);for(let s in e){let a=t&&t[s];if(a===void 0){let o=e[s];if(o.hasDefault)a=o.default;else throw new RangeError("No value supplied for attribute "+s)}n[s]=a}return n}function checkAttrs(e,t,n,s){for(let a in t)if(!(a in e))throw new RangeError(`Unsupported attribute ${a} for ${n} of type ${a}`);for(let a in e){let o=e[a];o.validate&&o.validate(t[a])}}function initAttrs(e,t){let n=Object.create(null);if(t)for(let s in t)n[s]=new Attribute(e,s,t[s]);return n}let NodeType$1=class Jr{constructor(t,n,s){this.name=t,this.schema=n,this.spec=s,this.markSet=null,this.groups=s.group?s.group.split(" "):[],this.attrs=initAttrs(t,s.attrs),this.defaultAttrs=defaultAttrs(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(s.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ContentMatch.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:computeAttrs(this.attrs,t)}create(t=null,n,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Node$1(this,this.computeAttrs(t),Fragment.from(n),Mark$1.setFrom(s))}createChecked(t=null,n,s){return n=Fragment.from(n),this.checkContent(n),new Node$1(this,this.computeAttrs(t),n,Mark$1.setFrom(s))}createAndFill(t=null,n,s){if(t=this.computeAttrs(t),n=Fragment.from(n),n.size){let l=this.contentMatch.fillBefore(n);if(!l)return null;n=l.append(n)}let a=this.contentMatch.matchFragment(n),o=a&&a.fillBefore(Fragment.empty,!0);return o?new Node$1(this,t,n.append(o),Mark$1.setFrom(s)):null}validContent(t){let n=this.contentMatch.matchFragment(t);if(!n||!n.validEnd)return!1;for(let s=0;s<t.childCount;s++)if(!this.allowsMarks(t.child(s).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){checkAttrs(this.attrs,t,"node",this.name)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let n=0;n<t.length;n++)if(!this.allowsMarkType(t[n].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let n;for(let s=0;s<t.length;s++)this.allowsMarkType(t[s].type)?n&&n.push(t[s]):n||(n=t.slice(0,s));return n?n.length?n:Mark$1.none:t}static compile(t,n){let s=Object.create(null);t.forEach((o,l)=>s[o]=new Jr(o,n,l));let a=n.spec.topNode||"doc";if(!s[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let o in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function validateType(e,t,n){let s=n.split("|");return a=>{let o=a===null?"null":typeof a;if(s.indexOf(o)<0)throw new RangeError(`Expected value of type ${s} for attribute ${t} on type ${e}, got ${o}`)}}class Attribute{constructor(t,n,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?validateType(t,n,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class MarkType{constructor(t,n,s,a){this.name=t,this.rank=n,this.schema=s,this.spec=a,this.attrs=initAttrs(t,a.attrs),this.excluded=null;let o=defaultAttrs(this.attrs);this.instance=o?new Mark$1(this,o):null}create(t=null){return!t&&this.instance?this.instance:new Mark$1(this,computeAttrs(this.attrs,t))}static compile(t,n){let s=Object.create(null),a=0;return t.forEach((o,l)=>s[o]=new MarkType(o,a++,n,l)),s}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}checkAttrs(t){checkAttrs(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class Schema{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let a in t)n[a]=t[a];n.nodes=OrderedMap.from(t.nodes),n.marks=OrderedMap.from(t.marks||{}),this.nodes=NodeType$1.compile(this.spec.nodes,this),this.marks=MarkType.compile(this.spec.marks,this);let s=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let o=this.nodes[a],l=o.spec.content||"",c=o.spec.marks;if(o.contentMatch=s[l]||(s[l]=ContentMatch.parse(l,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=c=="_"?null:c?gatherMarks(this,c.split(" ")):c==""||!o.inlineContent?[]:null}for(let a in this.marks){let o=this.marks[a],l=o.spec.excludes;o.excluded=l==null?[o]:l==""?[]:gatherMarks(this,l.split(" "))}this.nodeFromJSON=a=>Node$1.fromJSON(this,a),this.markFromJSON=a=>Mark$1.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,n=null,s,a){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof NodeType$1){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(n,s,a)}text(t,n){let s=this.nodes.text;return new TextNode(s,s.defaultAttrs,t,Mark$1.setFrom(n))}mark(t,n){return typeof t=="string"&&(t=this.marks[t]),t.create(n)}nodeType(t){let n=this.nodes[t];if(!n)throw new RangeError("Unknown node type: "+t);return n}}function gatherMarks(e,t){let n=[];for(let s=0;s<t.length;s++){let a=t[s],o=e.marks[a],l=o;if(o)n.push(o);else for(let c in e.marks){let d=e.marks[c];(a=="_"||d.spec.group&&d.spec.group.split(" ").indexOf(a)>-1)&&n.push(l=d)}if(!l)throw new SyntaxError("Unknown mark type: '"+t[s]+"'")}return n}function isTagRule(e){return e.tag!=null}function isStyleRule(e){return e.style!=null}class DOMParser{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let s=this.matchedStyles=[];n.forEach(a=>{if(isTagRule(a))this.tags.push(a);else if(isStyleRule(a)){let o=/[^=]*/.exec(a.style)[0];s.indexOf(o)<0&&s.push(o),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let o=t.nodes[a.node];return o.contentMatch.matchType(o)})}parse(t,n={}){let s=new ParseContext(this,n,!1);return s.addAll(t,Mark$1.none,n.from,n.to),s.finish()}parseSlice(t,n={}){let s=new ParseContext(this,n,!0);return s.addAll(t,Mark$1.none,n.from,n.to),Slice.maxOpen(s.finish())}matchTag(t,n,s){for(let a=s?this.tags.indexOf(s)+1:0;a<this.tags.length;a++){let o=this.tags[a];if(matches(t,o.tag)&&(o.namespace===void 0||t.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}matchStyle(t,n,s,a){for(let o=a?this.styles.indexOf(a)+1:0;o<this.styles.length;o++){let l=this.styles[o],c=l.style;if(!(c.indexOf(t)!=0||l.context&&!s.matchesContext(l.context)||c.length>t.length&&(c.charCodeAt(t.length)!=61||c.slice(t.length+1)!=n))){if(l.getAttrs){let d=l.getAttrs(n);if(d===!1)continue;l.attrs=d||void 0}return l}}}static schemaRules(t){let n=[];function s(a){let o=a.priority==null?50:a.priority,l=0;for(;l<n.length;l++){let c=n[l];if((c.priority==null?50:c.priority)<o)break}n.splice(l,0,a)}for(let a in t.marks){let o=t.marks[a].spec.parseDOM;o&&o.forEach(l=>{s(l=copy(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in t.nodes){let o=t.nodes[a].spec.parseDOM;o&&o.forEach(l=>{s(l=copy(l)),l.node||l.ignore||l.mark||(l.node=a)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new DOMParser(t,DOMParser.schemaRules(t)))}}const blockTags={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ignoreTags={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},listTags={ol:!0,ul:!0},OPT_PRESERVE_WS=1,OPT_PRESERVE_WS_FULL=2,OPT_OPEN_LEFT=4;function wsOptionsFor(e,t,n){return t!=null?(t?OPT_PRESERVE_WS:0)|(t==="full"?OPT_PRESERVE_WS_FULL:0):e&&e.whitespace=="pre"?OPT_PRESERVE_WS|OPT_PRESERVE_WS_FULL:n&~OPT_OPEN_LEFT}class NodeContext{constructor(t,n,s,a,o,l){this.type=t,this.attrs=n,this.marks=s,this.solid=a,this.options=l,this.content=[],this.activeMarks=Mark$1.none,this.match=o||(l&OPT_OPEN_LEFT?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Fragment.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let s=this.type.contentMatch,a;return(a=s.findWrapping(t.type))?(this.match=s,a):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&OPT_PRESERVE_WS)){let s=this.content[this.content.length-1],a;if(s&&s.isText&&(a=/[ \t\r\n\u000c]+$/.exec(s.text))){let o=s;s.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let n=Fragment.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(Fragment.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!blockTags.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class ParseContext{constructor(t,n,s){this.parser=t,this.options=n,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let a=n.topNode,o,l=wsOptionsFor(null,n.preserveWhitespace,0)|(s?OPT_OPEN_LEFT:0);a?o=new NodeContext(a.type,a.attrs,Mark$1.none,!0,n.topMatch||a.type.contentMatch,l):s?o=new NodeContext(null,null,Mark$1.none,!0,null,l):o=new NodeContext(t.schema.topNodeType,null,Mark$1.none,!0,null,l),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let s=t.nodeValue,a=this.top,o=a.options&OPT_PRESERVE_WS_FULL?"full":this.localPreserveWS||(a.options&OPT_PRESERVE_WS)>0,{schema:l}=this.parser;if(o==="full"||a.inlineContext(t)||/[^ \t\r\n\u000c]/.test(s)){if(o)if(o==="full")s=s.replace(/\r\n?/g,`
525
525
  `);else if(l.linebreakReplacement&&/[\r\n]/.test(s)&&this.top.findWrapping(l.linebreakReplacement.create())){let c=s.split(/\r?\n|\r/);for(let d=0;d<c.length;d++)d&&this.insertNode(l.linebreakReplacement.create(),n,!0),c[d]&&this.insertNode(l.text(c[d]),n,!/\S/.test(c[d]));s=""}else s=s.replace(/\r?\n|\r/g," ");else if(s=s.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(s)&&this.open==this.nodes.length-1){let c=a.content[a.content.length-1],d=t.previousSibling;(!c||d&&d.nodeName=="BR"||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(s=s.slice(1))}s&&this.insertNode(l.text(s),n,!/\S/.test(s)),this.findInText(t)}else this.findInside(t)}addElement(t,n,s){let a=this.localPreserveWS,o=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let l=t.nodeName.toLowerCase(),c;listTags.hasOwnProperty(l)&&this.parser.normalizeLists&&normalizeList(t);let d=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(c=this.parser.matchTag(t,this,s));e:if(d?d.ignore:ignoreTags.hasOwnProperty(l))this.findInside(t),this.ignoreFallback(t,n);else if(!d||d.skip||d.closeParent){d&&d.closeParent?this.open=Math.max(0,this.open-1):d&&d.skip.nodeType&&(t=d.skip);let f,R=this.needsBlock;if(blockTags.hasOwnProperty(l))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),f=!0,o.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let S=d&&d.skip?n:this.readStyles(t,n);S&&this.addAll(t,S),f&&this.sync(o),this.needsBlock=R}else{let f=this.readStyles(t,n);f&&this.addElementByRule(t,d,f,d.consuming===!1?c:void 0)}this.localPreserveWS=a}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
526
526
  `),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let s=t.style;if(s&&s.length)for(let a=0;a<this.parser.matchedStyles.length;a++){let o=this.parser.matchedStyles[a],l=s.getPropertyValue(o);if(l)for(let c=void 0;;){let d=this.parser.matchStyle(o,l,this,c);if(!d)break;if(d.ignore)return null;if(d.clearMark?n=n.filter(f=>!d.clearMark(f)):n=n.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)c=d;else break}}return n}addElementByRule(t,n,s,a){let o,l;if(n.node)if(l=this.parser.schema.nodes[n.node],l.isLeaf)this.insertNode(l.create(n.attrs),s,t.nodeName=="BR")||this.leafFallback(t,s);else{let d=this.enter(l,n.attrs||null,s,n.preserveWhitespace);d&&(o=!0,s=d)}else{let d=this.parser.schema.marks[n.mark];s=s.concat(d.create(n.attrs))}let c=this.top;if(l&&l.isLeaf)this.findInside(t);else if(a)this.addElement(t,s,a);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(d=>this.insertNode(d,s,!1));else{let d=t;typeof n.contentElement=="string"?d=t.querySelector(n.contentElement):typeof n.contentElement=="function"?d=n.contentElement(t):n.contentElement&&(d=n.contentElement),this.findAround(t,d,!0),this.addAll(d,s),this.findAround(t,d,!1)}o&&this.sync(c)&&this.open--}addAll(t,n,s,a){let o=s||0;for(let l=s?t.childNodes[s]:t.firstChild,c=a==null?null:t.childNodes[a];l!=c;l=l.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(l,n);this.findAtPoint(t,o)}findPlace(t,n,s){let a,o;for(let l=this.open,c=0;l>=0;l--){let d=this.nodes[l],f=d.findWrapping(t);if(f&&(!a||a.length>f.length+c)&&(a=f,o=d,!f.length))break;if(d.solid){if(s)break;c+=2}}if(!a)return null;this.sync(o);for(let l=0;l<a.length;l++)n=this.enterInner(a[l],null,n,!1);return n}insertNode(t,n,s){if(t.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let a=this.findPlace(t,n,s);if(a){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(t.type));let l=Mark$1.none;for(let c of a.concat(t.marks))(o.type?o.type.allowsMarkType(c.type):markMayApply(c.type,t.type))&&(l=c.addToSet(l));return o.content.push(t.mark(l)),!0}return!1}enter(t,n,s,a){let o=this.findPlace(t.create(n),s,!1);return o&&(o=this.enterInner(t,n,s,!0,a)),o}enterInner(t,n,s,a=!1,o){this.closeExtra();let l=this.top;l.match=l.match&&l.match.matchType(t);let c=wsOptionsFor(t,o,l.options);l.options&OPT_OPEN_LEFT&&l.content.length==0&&(c|=OPT_OPEN_LEFT);let d=Mark$1.none;return s=s.filter(f=>(l.type?l.type.allowsMarkType(f.type):markMayApply(f.type,t))?(d=f.addToSet(d),!1):!0),this.nodes.push(new NodeContext(t,n,d,a,null,c)),this.open++,s}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=OPT_PRESERVE_WS)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let a=s.length-1;a>=0;a--)t+=s[a].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==t&&this.find[s].offset==n&&(this.find[s].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,s){if(t!=n&&this.find)for(let a=0;a<this.find.length;a++)this.find[a].pos==null&&t.nodeType==1&&t.contains(this.find[a].node)&&n.compareDocumentPosition(this.find[a].node)&(s?2:4)&&(this.find[a].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),s=this.options.context,a=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),o=-(s?s.depth+1:0)+(a?0:1),l=(c,d)=>{for(;c>=0;c--){let f=n[c];if(f==""){if(c==n.length-1||c==0)continue;for(;d>=o;d--)if(l(c-1,d))return!0;return!1}else{let R=d>0||d==0&&a?this.nodes[d].type:s&&d>=o?s.node(d-o).type:null;if(!R||R.name!=f&&!R.isInGroup(f))return!1;d--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}}function normalizeList(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let s=t.nodeType==1?t.nodeName.toLowerCase():null;s&&listTags.hasOwnProperty(s)&&n?(n.appendChild(t),t=n):s=="li"?n=t:s&&(n=null)}}function matches(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function copy(e){let t={};for(let n in e)t[n]=e[n];return t}function markMayApply(e,t){let n=t.schema.nodes;for(let s in n){let a=n[s];if(!a.allowsMarkType(e))continue;let o=[],l=c=>{o.push(c);for(let d=0;d<c.edgeCount;d++){let{type:f,next:R}=c.edge(d);if(f==t||o.indexOf(R)<0&&l(R))return!0}};if(l(a.contentMatch))return!0}}class DOMSerializer{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},s){s||(s=doc$1(n).createDocumentFragment());let a=s,o=[];return t.forEach(l=>{if(o.length||l.marks.length){let c=0,d=0;for(;c<o.length&&d<l.marks.length;){let f=l.marks[d];if(!this.marks[f.type.name]){d++;continue}if(!f.eq(o[c][0])||f.type.spec.spanning===!1)break;c++,d++}for(;c<o.length;)a=o.pop()[1];for(;d<l.marks.length;){let f=l.marks[d++],R=this.serializeMark(f,l.isInline,n);R&&(o.push([f,a]),a.appendChild(R.dom),a=R.contentDOM||R.dom)}}a.appendChild(this.serializeNodeInner(l,n))}),s}serializeNodeInner(t,n){let{dom:s,contentDOM:a}=renderSpec(doc$1(n),this.nodes[t.type.name](t),null,t.attrs);if(a){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,a)}return s}serializeNode(t,n={}){let s=this.serializeNodeInner(t,n);for(let a=t.marks.length-1;a>=0;a--){let o=this.serializeMark(t.marks[a],t.isInline,n);o&&((o.contentDOM||o.dom).appendChild(s),s=o.dom)}return s}serializeMark(t,n,s={}){let a=this.marks[t.type.name];return a&&renderSpec(doc$1(s),a(t,n),null,t.attrs)}static renderSpec(t,n,s=null,a){return renderSpec(t,n,s,a)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new DOMSerializer(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=gatherToDOM(t.nodes);return n.text||(n.text=s=>s.text),n}static marksFromSchema(t){return gatherToDOM(t.marks)}}function gatherToDOM(e){let t={};for(let n in e){let s=e[n].spec.toDOM;s&&(t[n]=s)}return t}function doc$1(e){return e.document||window.document}const suspiciousAttributeCache=new WeakMap;function suspiciousAttributes(e){let t=suspiciousAttributeCache.get(e);return t===void 0&&suspiciousAttributeCache.set(e,t=suspiciousAttributesInner(e)),t}function suspiciousAttributesInner(e){let t=null;function n(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")t||(t=[]),t.push(s);else for(let a=0;a<s.length;a++)n(s[a]);else for(let a in s)n(s[a])}return n(e),t}function renderSpec(e,t,n,s){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let a=t[0],o;if(typeof a!="string")throw new RangeError("Invalid array passed to renderSpec");if(s&&(o=suspiciousAttributes(s))&&o.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(n=a.slice(0,l),a=a.slice(l+1));let c,d=n?e.createElementNS(n,a):e.createElement(a),f=t[1],R=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){R=2;for(let S in f)if(f[S]!=null){let te=S.indexOf(" ");te>0?d.setAttributeNS(S.slice(0,te),S.slice(te+1),f[S]):S=="style"&&d.style?d.style.cssText=f[S]:d.setAttribute(S,f[S])}}for(let S=R;S<t.length;S++){let te=t[S];if(te===0){if(S<t.length-1||S>R)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:A,contentDOM:rt}=renderSpec(e,te,n,s);if(d.appendChild(A),rt){if(c)throw new RangeError("Multiple content holes");c=rt}}}return{dom:d,contentDOM:c}}const lower16=65535,factor16=Math.pow(2,16);function makeRecover(e,t){return e+t*factor16}function recoverIndex(e){return e&lower16}function recoverOffset(e){return(e-(e&lower16))/factor16}const DEL_BEFORE=1,DEL_AFTER=2,DEL_ACROSS=4,DEL_SIDE=8;class MapResult{constructor(t,n,s){this.pos=t,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&DEL_SIDE)>0}get deletedBefore(){return(this.delInfo&(DEL_BEFORE|DEL_ACROSS))>0}get deletedAfter(){return(this.delInfo&(DEL_AFTER|DEL_ACROSS))>0}get deletedAcross(){return(this.delInfo&DEL_ACROSS)>0}}class StepMap{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&StepMap.empty)return StepMap.empty}recover(t){let n=0,s=recoverIndex(t);if(!this.inverted)for(let a=0;a<s;a++)n+=this.ranges[a*3+2]-this.ranges[a*3+1];return this.ranges[s*3]+n+recoverOffset(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,s){let a=0,o=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let d=this.ranges[c]-(this.inverted?a:0);if(d>t)break;let f=this.ranges[c+o],R=this.ranges[c+l],S=d+f;if(t<=S){let te=f?t==d?-1:t==S?1:n:n,A=d+a+(te<0?0:R);if(s)return A;let rt=t==(n<0?d:S)?null:makeRecover(c/3,t-d),st=t==d?DEL_AFTER:t==S?DEL_BEFORE:DEL_ACROSS;return(n<0?t!=d:t!=S)&&(st|=DEL_SIDE),new MapResult(A,st,rt)}a+=R-f}return s?t+a:new MapResult(t+a,0,null)}touches(t,n){let s=0,a=recoverIndex(n),o=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let d=this.ranges[c]-(this.inverted?s:0);if(d>t)break;let f=this.ranges[c+o],R=d+f;if(t<=R&&c==a*3)return!0;s+=this.ranges[c+l]-f}return!1}forEach(t){let n=this.inverted?2:1,s=this.inverted?1:2;for(let a=0,o=0;a<this.ranges.length;a+=3){let l=this.ranges[a],c=l-(this.inverted?o:0),d=l+(this.inverted?0:o),f=this.ranges[a+n],R=this.ranges[a+s];t(c,c+f,d,d+R),o+=R-f}}invert(){return new StepMap(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?StepMap.empty:new StepMap(t<0?[0,-t,0]:[0,0,t])}}StepMap.empty=new StepMap([]);class Mapping{constructor(t,n,s=0,a=t?t.length:0){this.mirror=n,this.from=s,this.to=a,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Mapping(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,s=this._maps.length;n<t._maps.length;n++){let a=t.getMirror(n);this.appendMap(t._maps[n],a!=null&&a<n?s+a:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,s=this._maps.length+t._maps.length;n>=0;n--){let a=t.getMirror(n);this.appendMap(t._maps[n].invert(),a!=null&&a>n?s-a-1:void 0)}}invert(){let t=new Mapping;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let s=this.from;s<this.to;s++)t=this._maps[s].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,s){let a=0;for(let o=this.from;o<this.to;o++){let l=this._maps[o],c=l.mapResult(t,n);if(c.recover!=null){let d=this.getMirror(o);if(d!=null&&d>o&&d<this.to){o=d,t=this._maps[d].recover(c.recover);continue}}a|=c.delInfo,t=c.pos}return s?t:new MapResult(t,a,null)}}const stepsByID=Object.create(null);class Step{getMap(){return StepMap.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=stepsByID[n.stepType];if(!s)throw new RangeError(`No step type ${n.stepType} defined`);return s.fromJSON(t,n)}static jsonID(t,n){if(t in stepsByID)throw new RangeError("Duplicate use of step JSON ID "+t);return stepsByID[t]=n,n.prototype.jsonID=t,n}}class StepResult{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new StepResult(t,null)}static fail(t){return new StepResult(null,t)}static fromReplace(t,n,s,a){try{return StepResult.ok(t.replace(n,s,a))}catch(o){if(o instanceof ReplaceError)return StepResult.fail(o.message);throw o}}}function mapFragment(e,t,n){let s=[];for(let a=0;a<e.childCount;a++){let o=e.child(a);o.content.size&&(o=o.copy(mapFragment(o.content,t,o))),o.isInline&&(o=t(o,n,a)),s.push(o)}return Fragment.fromArray(s)}class AddMarkStep extends Step{constructor(t,n,s){super(),this.from=t,this.to=n,this.mark=s}apply(t){let n=t.slice(this.from,this.to),s=t.resolve(this.from),a=s.node(s.sharedDepth(this.to)),o=new Slice(mapFragment(n.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),n.openStart,n.openEnd);return StepResult.fromReplace(t,this.from,this.to,o)}invert(){return new RemoveMarkStep(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new AddMarkStep(n.pos,s.pos,this.mark)}merge(t){return t instanceof AddMarkStep&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new AddMarkStep(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new AddMarkStep(n.from,n.to,t.markFromJSON(n.mark))}}Step.jsonID("addMark",AddMarkStep);class RemoveMarkStep extends Step{constructor(t,n,s){super(),this.from=t,this.to=n,this.mark=s}apply(t){let n=t.slice(this.from,this.to),s=new Slice(mapFragment(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),t),n.openStart,n.openEnd);return StepResult.fromReplace(t,this.from,this.to,s)}invert(){return new AddMarkStep(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new RemoveMarkStep(n.pos,s.pos,this.mark)}merge(t){return t instanceof RemoveMarkStep&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new RemoveMarkStep(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new RemoveMarkStep(n.from,n.to,t.markFromJSON(n.mark))}}Step.jsonID("removeMark",RemoveMarkStep);class AddNodeMarkStep extends Step{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return StepResult.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return StepResult.fromReplace(t,this.pos,this.pos+1,new Slice(Fragment.from(s),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let a=0;a<n.marks.length;a++)if(!n.marks[a].isInSet(s))return new AddNodeMarkStep(this.pos,n.marks[a]);return new AddNodeMarkStep(this.pos,this.mark)}}return new RemoveNodeMarkStep(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new AddNodeMarkStep(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new AddNodeMarkStep(n.pos,t.markFromJSON(n.mark))}}Step.jsonID("addNodeMark",AddNodeMarkStep);class RemoveNodeMarkStep extends Step{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return StepResult.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return StepResult.fromReplace(t,this.pos,this.pos+1,new Slice(Fragment.from(s),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new AddNodeMarkStep(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new RemoveNodeMarkStep(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new RemoveNodeMarkStep(n.pos,t.markFromJSON(n.mark))}}Step.jsonID("removeNodeMark",RemoveNodeMarkStep);class ReplaceStep extends Step{constructor(t,n,s,a=!1){super(),this.from=t,this.to=n,this.slice=s,this.structure=a}apply(t){return this.structure&&contentBetween(t,this.from,this.to)?StepResult.fail("Structure replace would overwrite content"):StepResult.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new StepMap([this.from,this.to-this.from,this.slice.size])}invert(t){return new ReplaceStep(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deletedAcross&&s.deletedAcross?null:new ReplaceStep(n.pos,Math.max(n.pos,s.pos),this.slice,this.structure)}merge(t){if(!(t instanceof ReplaceStep)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Slice.empty:new Slice(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new ReplaceStep(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Slice.empty:new Slice(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new ReplaceStep(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ReplaceStep(n.from,n.to,Slice.fromJSON(t,n.slice),!!n.structure)}}Step.jsonID("replace",ReplaceStep);class ReplaceAroundStep extends Step{constructor(t,n,s,a,o,l,c=!1){super(),this.from=t,this.to=n,this.gapFrom=s,this.gapTo=a,this.slice=o,this.insert=l,this.structure=c}apply(t){if(this.structure&&(contentBetween(t,this.from,this.gapFrom)||contentBetween(t,this.gapTo,this.to)))return StepResult.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return StepResult.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,n.content);return s?StepResult.fromReplace(t,this.from,this.to,s):StepResult.fail("Content does not fit in gap")}getMap(){return new StepMap([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new ReplaceAroundStep(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1),a=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),o=this.to==this.gapTo?s.pos:t.map(this.gapTo,1);return n.deletedAcross&&s.deletedAcross||a<n.pos||o>s.pos?null:new ReplaceAroundStep(n.pos,s.pos,a,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ReplaceAroundStep(n.from,n.to,n.gapFrom,n.gapTo,Slice.fromJSON(t,n.slice),n.insert,!!n.structure)}}Step.jsonID("replaceAround",ReplaceAroundStep);function contentBetween(e,t,n){let s=e.resolve(t),a=n-t,o=s.depth;for(;a>0&&o>0&&s.indexAfter(o)==s.node(o).childCount;)o--,a--;if(a>0){let l=s.node(o).maybeChild(s.indexAfter(o));for(;a>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,a--}}return!1}function addMark(e,t,n,s){let a=[],o=[],l,c;e.doc.nodesBetween(t,n,(d,f,R)=>{if(!d.isInline)return;let S=d.marks;if(!s.isInSet(S)&&R.type.allowsMarkType(s.type)){let te=Math.max(f,t),A=Math.min(f+d.nodeSize,n),rt=s.addToSet(S);for(let st=0;st<S.length;st++)S[st].isInSet(rt)||(l&&l.to==te&&l.mark.eq(S[st])?l.to=A:a.push(l=new RemoveMarkStep(te,A,S[st])));c&&c.to==te?c.to=A:o.push(c=new AddMarkStep(te,A,s))}}),a.forEach(d=>e.step(d)),o.forEach(d=>e.step(d))}function removeMark(e,t,n,s){let a=[],o=0;e.doc.nodesBetween(t,n,(l,c)=>{if(!l.isInline)return;o++;let d=null;if(s instanceof MarkType){let f=l.marks,R;for(;R=s.isInSet(f);)(d||(d=[])).push(R),f=R.removeFromSet(f)}else s?s.isInSet(l.marks)&&(d=[s]):d=l.marks;if(d&&d.length){let f=Math.min(c+l.nodeSize,n);for(let R=0;R<d.length;R++){let S=d[R],te;for(let A=0;A<a.length;A++){let rt=a[A];rt.step==o-1&&S.eq(a[A].style)&&(te=rt)}te?(te.to=f,te.step=o):a.push({style:S,from:Math.max(c,t),to:f,step:o})}}}),a.forEach(l=>e.step(new RemoveMarkStep(l.from,l.to,l.style)))}function clearIncompatible(e,t,n,s=n.contentMatch,a=!0){let o=e.doc.nodeAt(t),l=[],c=t+1;for(let d=0;d<o.childCount;d++){let f=o.child(d),R=c+f.nodeSize,S=s.matchType(f.type);if(!S)l.push(new ReplaceStep(c,R,Slice.empty));else{s=S;for(let te=0;te<f.marks.length;te++)n.allowsMarkType(f.marks[te].type)||e.step(new RemoveMarkStep(c,R,f.marks[te]));if(a&&f.isText&&n.whitespace!="pre"){let te,A=/\r?\n|\r/g,rt;for(;te=A.exec(f.text);)rt||(rt=new Slice(Fragment.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),l.push(new ReplaceStep(c+te.index,c+te.index+te[0].length,rt))}}c=R}if(!s.validEnd){let d=s.fillBefore(Fragment.empty,!0);e.replace(c,c,new Slice(d,0,0))}for(let d=l.length-1;d>=0;d--)e.step(l[d])}function canCut(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function liftTarget(e){let n=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let s=e.depth,a=0,o=0;;--s){let l=e.$from.node(s),c=e.$from.index(s)+a,d=e.$to.indexAfter(s)-o;if(s<e.depth&&l.canReplace(c,d,n))return s;if(s==0||l.type.spec.isolating||!canCut(l,c,d))break;c&&(a=1),d<l.childCount&&(o=1)}return null}function lift$2(e,t,n){let{$from:s,$to:a,depth:o}=t,l=s.before(o+1),c=a.after(o+1),d=l,f=c,R=Fragment.empty,S=0;for(let rt=o,st=!1;rt>n;rt--)st||s.index(rt)>0?(st=!0,R=Fragment.from(s.node(rt).copy(R)),S++):d--;let te=Fragment.empty,A=0;for(let rt=o,st=!1;rt>n;rt--)st||a.after(rt+1)<a.end(rt)?(st=!0,te=Fragment.from(a.node(rt).copy(te)),A++):f++;e.step(new ReplaceAroundStep(d,f,l,c,new Slice(R.append(te),S,A),R.size-S,!0))}function findWrapping(e,t,n=null,s=e){let a=findWrappingOutside(e,t),o=a&&findWrappingInside(s,t);return o?a.map(withAttrs).concat({type:t,attrs:n}).concat(o.map(withAttrs)):null}function withAttrs(e){return{type:e,attrs:null}}function findWrappingOutside(e,t){let{parent:n,startIndex:s,endIndex:a}=e,o=n.contentMatchAt(s).findWrapping(t);if(!o)return null;let l=o.length?o[0]:t;return n.canReplaceWith(s,a,l)?o:null}function findWrappingInside(e,t){let{parent:n,startIndex:s,endIndex:a}=e,o=n.child(s),l=t.contentMatch.findWrapping(o.type);if(!l)return null;let d=(l.length?l[l.length-1]:t).contentMatch;for(let f=s;d&&f<a;f++)d=d.matchType(n.child(f).type);return!d||!d.validEnd?null:l}function wrap(e,t,n){let s=Fragment.empty;for(let l=n.length-1;l>=0;l--){if(s.size){let c=n[l].type.contentMatch.matchFragment(s);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=Fragment.from(n[l].type.create(n[l].attrs,s))}let a=t.start,o=t.end;e.step(new ReplaceAroundStep(a,o,a,o,new Slice(s,0,0),n.length,!0))}function setBlockType$1(e,t,n,s,a){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(l,c)=>{let d=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(s,d)&&canChangeType(e.doc,e.mapping.slice(o).map(c),s)){let f=null;if(s.schema.linebreakReplacement){let A=s.whitespace=="pre",rt=!!s.contentMatch.matchType(s.schema.linebreakReplacement);A&&!rt?f=!1:!A&&rt&&(f=!0)}f===!1&&replaceLinebreaks(e,l,c,o),clearIncompatible(e,e.mapping.slice(o).map(c,1),s,void 0,f===null);let R=e.mapping.slice(o),S=R.map(c,1),te=R.map(c+l.nodeSize,1);return e.step(new ReplaceAroundStep(S,te,S+1,te-1,new Slice(Fragment.from(s.create(d,null,l.marks)),0,0),1,!0)),f===!0&&replaceNewlines(e,l,c,o),!1}})}function replaceNewlines(e,t,n,s){t.forEach((a,o)=>{if(a.isText){let l,c=/\r?\n|\r/g;for(;l=c.exec(a.text);){let d=e.mapping.slice(s).map(n+1+o+l.index);e.replaceWith(d,d+1,t.type.schema.linebreakReplacement.create())}}})}function replaceLinebreaks(e,t,n,s){t.forEach((a,o)=>{if(a.type==a.type.schema.linebreakReplacement){let l=e.mapping.slice(s).map(n+1+o);e.replaceWith(l,l+1,t.type.schema.text(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.617.0",
4
+ "version": "1.618.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [