randmarcomps 1.153.0 → 1.154.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.
@@ -58885,7 +58885,7 @@ function AiGeneratedContent(e) {
58885
58885
  }), () => {
58886
58886
  u = !0;
58887
58887
  };
58888
- }, [e.prompt, e.data, o]), n ? /* @__PURE__ */ jsx(
58888
+ }, [e.prompt, e.data, o, l]), n ? /* @__PURE__ */ jsx(
58889
58889
  source_default,
58890
58890
  {
58891
58891
  bindings: {
@@ -850,6 +850,6 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
850
850
  `&&++this.pos;case`
851
851
  `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},pp.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
852
852
  `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var o=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],l=parseInt(o,8);return l>255&&(o=o.slice(0,-1),l=parseInt(o,8)),this.pos+=o.length-1,t=this.input.charCodeAt(this.pos),(o!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-o.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(l)}return isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},pp.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,o=this.options.ecmaVersion>=6;this.pos<this.input.length;){var l=this.fullCharCodeAtPos();if(isIdentifierChar(l,o))this.pos+=l<=65535?1:2;else if(l===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var u=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var p=this.readCodePoint();(t?isIdentifierStart:isIdentifierChar)(p,o)||this.invalidStringToken(u,"Invalid Unicode escape"),e+=codePointToString(p),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},pp.readWord=function(){var e=this.readWord1(),t=types$1.name;return this.keywords.test(e)&&(t=keywords[e]),this.finishToken(t,e)};var version="8.12.1";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node:Node$1,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};var AcornJSX=__toESM(require_acorn_jsx()),attributeNames_default={acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",colspan:"colSpan",contenteditable:"contentEditable",crossorigin:"crossOrigin",datetime:"dateTime",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",httpequiv:"httpEquiv",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],NO_WHITESPACE=["table","tbody","tfoot","thead","tr"];function canHaveChildren(e){return VOID_ELEMENTS.indexOf(e.toLowerCase())===-1}function canHaveWhitespace(e){return NO_WHITESPACE.indexOf(e.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(t="Nullish value encountered"){super(t),this.name="NullishShortCircuit"}}var hash=(e="",t=16)=>{const n=String(e);let o=0;return n.split("").forEach(l=>{o=(o<<5)-o+l.charCodeAt(0),o&=o}),Math.abs(o).toString(t)},randomHash=()=>hash(Math.random().toString()),camelCase=e=>e.replace(/([A-Z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z\u00C0-\u00ff]/g," ").toLowerCase().split(" ").filter(t=>t).map((t,n)=>n>0?t[0].toUpperCase()+t.slice(1):t).join(""),parseStyle=e=>{switch(typeof e){case"string":return e.split(";").filter(t=>t).reduce((t,n)=>{const o=n.slice(0,n.indexOf(":")).trim(),l=n.slice(n.indexOf(":")+1).trim();return{...t,[camelCase(o)]:l}},{});case"object":return e;default:return}},pathToArrayPath=e=>e==null||e===""?[]:e.split("."),resolveArrayPath=(e,t)=>{const[n,...o]=t;if(!(e==null||n==null))return o.length===0?e[n]:resolveArrayPath(e[n],o)},resolvePath=(e,t)=>resolveArrayPath(e,pathToArrayPath(t));function handleNaN(e){return Number.isNaN(e)?"NaN":e}class JsxParser extends React.Component{constructor(){super(...arguments);je(this,"ParsedChildren",null);st(this,Be,n=>{const o=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),l=`<root>${n}</root>`;let u=[];try{u=o.parse(l,{ecmaVersion:"latest"}),u=u.body[0].expression.children||[]}catch(p){return this.props.showWarnings&&console.warn(p),this.props.onError&&this.props.onError(p),this.props.renderError?this.props.renderError({error:String(p)}):null}return u.map(p=>De(this,Ae).call(this,p)).filter(Boolean)});st(this,Ae,(n,o)=>{var l,u;switch(n.type){case"JSXAttribute":return n.value===null?!0:De(this,Ae).call(this,n.value,o);case"JSXElement":case"JSXFragment":return De(this,dt).call(this,n,o);case"JSXExpressionContainer":return De(this,Ae).call(this,n.expression,o);case"JSXText":const p=this.props.disableKeyGeneration?void 0:randomHash();return this.props.disableFragments?n.value:React.createElement(React.Fragment,{key:p},n.value);case"ArrayExpression":return n.elements.map(E=>De(this,Ae).call(this,E,o));case"BinaryExpression":const d=De(this,Ae).call(this,n.left,o),f=De(this,Ae).call(this,n.right,o);let m;switch(n.operator){case"-":m=d-f;break;case"!=":m=d!=f;break;case"!==":m=d!==f;break;case"*":m=d*f;break;case"**":m=d**f;break;case"/":m=d/f;break;case"%":m=d%f;break;case"+":m=d+f;break;case"<":m=d<f;break;case"<=":m=d<=f;break;case"==":m=d==f;break;case"===":m=d===f;break;case">":m=d>f;break;case">=":m=d>=f;break;default:this.props.onError(new Error(`Unsupported binary operator: ${n.operator}`));return}return handleNaN(m);case"CallExpression":const g=De(this,Ae).call(this,n.callee,o);if(g===void 0){if(n.optional)throw new NullishShortCircuit;this.props.onError(new Error(`The expression '${n.callee}' could not be resolved, resulting in an undefined return value.`));return}return g(...n.arguments.map(E=>De(this,Ae).call(this,E,o)));case"ConditionalExpression":return De(this,Ae).call(this,n.test,o)?De(this,Ae).call(this,n.consequent,o):De(this,Ae).call(this,n.alternate,o);case"ExpressionStatement":return De(this,Ae).call(this,n.expression,o);case"Identifier":return n.name==="Infinity"?1/0:n.name==="-Infinity"?-1/0:n.name==="NaN"?NaN:o&&n.name in o?handleNaN(o[n.name]):handleNaN((this.props.bindings||{})[n.name]);case"Literal":return n.value;case"LogicalExpression":const b=De(this,Ae).call(this,n.left,o);return n.operator==="||"&&b?b:n.operator==="&&"&&b||n.operator==="||"&&!b?De(this,Ae).call(this,n.right,o):!1;case"MemberExpression":return De(this,It).call(this,n,o);case"ChainExpression":return De(this,Ke).call(this,n,o);case"ObjectExpression":const _={};return n.properties.forEach(E=>{_[E.key.name||E.key.value]=De(this,Ae).call(this,E.value,o)}),_;case"TemplateElement":return n.value.cooked;case"TemplateLiteral":return[...n.expressions,...n.quasis].sort((E,C)=>E.start<C.start?-1:1).map(E=>De(this,Ae).call(this,E,o)).join("");case"UnaryExpression":const S=De(this,Ae).call(this,n.argument,o);switch(n.operator){case"+":return+S;case"-":return-S;case"!":return!S}return;case"ArrowFunctionExpression":return(n.async||n.generator)&&((u=(l=this.props).onError)==null||u.call(l,new Error("Async and generator arrow functions are not supported."))),(...E)=>{const C={...o};return n.params.forEach((R,I)=>{C[R.name]=E[I]}),De(this,Ae).call(this,n.body,C)};default:this.props.onError(new Error(`The expression type '${n.type}' is not supported.`));return}});st(this,Ke,(n,o)=>{try{return De(this,Ae).call(this,n.expression,o)}catch(l){if(l instanceof NullishShortCircuit)return;throw l}});st(this,It,(n,o)=>{const l=De(this,Ae).call(this,n.object,o);let u;if(n.computed)u=De(this,Ae).call(this,n.property,o);else if(n.property.type==="Identifier")u=n.property.name;else{this.props.onError(new Error("Only simple MemberExpressions are supported."));return}if(l==null&&n.optional)throw new NullishShortCircuit;let p;try{p=l[u]}catch{this.props.onError(new Error(`The property '${u}' could not be resolved on the object '${l}'.`));return}return typeof p=="function"?p.bind(l):p});st(this,ot,n=>n.type==="JSXIdentifier"?n.name:`${De(this,ot).call(this,n.object)}.${De(this,ot).call(this,n.property)}`);st(this,dt,(n,o)=>{const{allowUnknownElements:l,components:u,componentsOnly:p,onError:d}=this.props,{children:f=[]}=n,m=n.type==="JSXElement"?n.openingElement:n.openingFragment,{attributes:g=[]}=m,b=n.type==="JSXElement"?De(this,ot).call(this,m.name):"",_=(this.props.blacklistedAttrs||[]).map(O=>O instanceof RegExp?O:new RegExp(O,"i")),S=(this.props.blacklistedTags||[]).map(O=>O.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(b))return f.map(O=>De(this,dt).call(this,O,o));const E=b.trim().toLowerCase();if(S.indexOf(E)!==-1)return d(new Error(`The tag <${b}> is blacklisted, and will not be rendered.`)),null;if(b!==""&&!resolvePath(u,b)){if(p)return d(new Error(`The component <${b}> is unrecognized, and will not be rendered.`)),this.props.renderUnrecognized(b);if(!l&&document.createElement(b)instanceof HTMLUnknownElement)return d(new Error(`The tag <${b}> is unrecognized in this browser, and will not be rendered.`)),this.props.renderUnrecognized(b)}let C,R=n.type==="JSXElement"?resolvePath(u,b):React.Fragment;if(R||canHaveChildren(b)){if(C=f.map(V=>De(this,Ae).call(this,V,o)),b.includes(".")){const M=b.split(".").reduce((A,j)=>A?A[j]:u==null?void 0:u[j],null);M&&(R=M)}!R&&!canHaveWhitespace(b)&&(C=C.filter(V=>typeof V!="string"||!/^\s*$/.test(V)));const O=C.find(V=>typeof V=="function");C.length===0?C=void 0:O?C=O:C.length===1?[C]=C:C.length>1&&!this.props.disableKeyGeneration&&(C=C.map((V,M)=>V!=null&&V.type&&!(V!=null&&V.key)?{...V,key:V.key||M}:V))}const I={key:this.props.disableKeyGeneration?void 0:randomHash()};g.forEach(O=>{if(O.type==="JSXAttribute"){const V=O.name.name,M=attributeNames_default[V]||V,A=De(this,Ae).call(this,O,o);_.filter(B=>B.test(M)).length===0&&(I[M]=A)}else if(O.type==="JSXSpreadAttribute"&&O.argument.type==="Identifier"||O.argument.type==="MemberExpression"){const V=De(this,Ae).call(this,O.argument,o);typeof V=="object"&&Object.keys(V).forEach(M=>{const A=attributeNames_default[M]||M;_.filter(B=>B.test(A)).length===0&&(I[A]=V[M])})}}),typeof I.style=="string"&&(I.style=parseStyle(I.style));const N=b.toLowerCase();return N==="option"&&(C=C.props.children),React.createElement(R||N,I,C)})}render(){const n=(this.props.jsx||"").trim().replace(/<!DOCTYPE([^>]*)>/g,"");this.ParsedChildren=De(this,Be).call(this,n);const o=[...new Set(["jsx-parser",...String(this.props.className).split(" ")])].filter(Boolean).join(" ");return this.props.renderInWrapper?React.createElement("div",{className:o},this.ParsedChildren):this.ParsedChildren}}Be=new WeakMap,Ae=new WeakMap,Ke=new WeakMap,It=new WeakMap,ot=new WeakMap,dt=new WeakMap,je(JsxParser,"displayName","JsxParser"),je(JsxParser,"defaultProps",{allowUnknownElements:!0,autoCloseVoidElements:!1,bindings:{},blacklistedAttrs:[/^on.+/i],blacklistedTags:["script"],className:"",components:{},componentsOnly:!1,disableFragments:!1,disableKeyGeneration:!1,jsx:"",onError:()=>{},showWarnings:!1,renderError:void 0,renderInWrapper:!0,renderUnrecognized:()=>null});var source_default=JsxParser;const GetJSXFromAI=async(e,t,n,o=3)=>{const l="In addition to basic html tags, You have access to these beautiful Handmade Components: Button.",u="Here is the data to display to the user (If a Handmade Component is a perfect fit for the data, use it. Otherwise, use regular html tags):",p="Only output a single JSX code snippet. Start with <> and end with </>. All other code will be ignored, so make sure to place all CSS styles inline. Use CSS flex layouts when there is a lot of stuff to display.",d=JSON.stringify(n),f=[t,l,p,u,d,p].join(`\r
853
- `),b=await new GoogleGenAI({apiKey:e}).chats.create({model:"gemini-2.0-flash-lite"}).sendMessage({message:f}),_=trimJSXString(b.text??"");return _||(o==0?"<p>Failed to generate. Reload the page.</p>":await GetJSXFromAI(e,t,n,o-1))};function trimJSXString(e){const t=e.indexOf("<"),n=e.lastIndexOf("</");return t===-1||n===-1?"":e.slice(t,e.indexOf(">",n)+1)}function AiGeneratedContent(e){const{appID:t}=reactRouterDom.useParams(),[n,o]=React.useState(""),{apiKey:l}=useApiKey();return React.useEffect(()=>{if(!l||!e.prompt||!e.data)return;o("");let u=!1;return GetJSXFromAI(l,e.prompt,e.data).then(p=>{u||o(p)}),()=>{u=!0}},[e.prompt,e.data,o]),n?jsxRuntime.jsx(source_default,{bindings:{appID:t},components:{Button},jsx:n}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(Skeleton,{className:"h-32 w-32",children:jsxRuntime.jsx(Bot,{className:"m-auto align-middle h-full"})})})}const CountryFlag=({countryCode:e,className:t=""})=>{const[n,o]=React.useState(null),[l,u]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const d=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(d,{method:"HEAD"}).then(f=>{f.ok?(o(d),u(!1)):u(!0)}).catch(()=>{u(!0)})},[e]),l||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})};function GeneralDocumentCard({document:e,loading:t=!1}){return t?jsxRuntime.jsx("div",{children:"loading..."}):jsxRuntime.jsxs("div",{children:["GENERAL DOCUMENT CARD - ",e==null?void 0:e.OrderNumber," for P.O. ",e==null?void 0:e.PONumber]})}const Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,withRandmarAssistant:o,chatUserName:l,chatApiKey:u},p)=>{const{appID:d}=reactRouterDom.useParams(),f=e.filter(_=>_.showInNav),m=React.useRef(null),g=React.useRef(null),b=React.useRef(null);return React.useImperativeHandle(p,()=>({setActiveChatAndSendMessage:(_,S)=>{var E;return(E=b.current)==null||E.click(),setTimeout(()=>{var C;(C=m.current)==null||C.focus(),g.current&&g.current.setActiveChatAndSendMessage(_,S)},100),!0}})),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("img",{src:"https://api.randmar.io/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:jsxRuntime.jsx(SidebarMenu,{children:f.map(_=>{const S=_.icon,E=`/${_.path.replace(":appID",d??"")}`;return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:E,className:"transition-colors hover:bg-muted px-6",children:[S&&jsxRuntime.jsx(S,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:_.label})]})})},_.key)})})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground",children:[o===!0&&jsxRuntime.jsxs(Dialog,{children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:b,size:"lg",className:"collapse md:visible",onClick:()=>setTimeout(()=>{var _;return(_=m.current)==null?void 0:_.focus()},50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(DialogContent,{className:"max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,children:jsxRuntime.jsx(ChatLayout,{ref:g,inputRef:m,userId:d??"2",userName:l??"Unknown user",apiKey:u??""})})]}),t]})]})}),Layout=React.forwardRef(({children:e,rightMenu:t,routes:n,footer:o,handleValidSearch:l,dashboardTitle:u,onSignOut:p,searchPlaceholder:d,withRandmarAssistant:f,chatUserName:m,chatApiKey:g,chatRef:b},_)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{routes:n,footer:o,dashboardTitle:u,withRandmarAssistant:f,chatUserName:m,chatApiKey:g,ref:b}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[jsxRuntime.jsx(Topbar,{ref:_,onSignOut:p,rightMenu:t,handleValidSearch:l,searchPlaceholder:d}),jsxRuntime.jsx("main",{className:"flex-1 overflow-auto mt-16",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";function usePrevious(e){const t=React__namespace.useRef({value:e,previous:e});return React__namespace.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection,useCollection,createCollectionScope]=createCollection(SELECT_NAME),[createSelectContext,createSelectScope]=createContextScope(SELECT_NAME,[createCollectionScope,createPopperScope]),usePopperScope=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$1=e=>{const{__scopeSelect:t,children:n,open:o,defaultOpen:l,onOpenChange:u,value:p,defaultValue:d,onValueChange:f,dir:m,name:g,autoComplete:b,disabled:_,required:S,form:E}=e,C=usePopperScope(t),[R,I]=React__namespace.useState(null),[N,O]=React__namespace.useState(null),[V,M]=React__namespace.useState(!1),A=useDirection(m),[j,B]=useControllableState({prop:o,defaultProp:l??!1,onChange:u,caller:SELECT_NAME}),[L,q]=useControllableState({prop:p,defaultProp:d,onChange:f,caller:SELECT_NAME}),F=React__namespace.useRef(null),H=R?E||!!R.closest("form"):!0,[U,G]=React__namespace.useState(new Set),J=Array.from(U).map(Z=>Z.props.value).join(";");return jsxRuntime.jsx(Root2$4,{...C,children:jsxRuntime.jsxs(SelectProvider,{required:S,scope:t,trigger:R,onTriggerChange:I,valueNode:N,onValueNodeChange:O,valueNodeHasChildren:V,onValueNodeHasChildrenChange:M,contentId:useId(),value:L,onValueChange:q,open:j,onOpenChange:B,dir:A,triggerPointerDownPosRef:F,disabled:_,children:[jsxRuntime.jsx(Collection.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Z=>{G(ae=>new Set(ae).add(Z))},[]),onNativeOptionRemove:React__namespace.useCallback(Z=>{G(ae=>{const W=new Set(ae);return W.delete(Z),W})},[]),children:n})}),H?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:S,tabIndex:-1,name:g,autoComplete:b,value:L,onChange:Z=>q(Z.target.value),disabled:_,form:E,children:[L===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(U)]},J):null]})})};Select$1.displayName=SELECT_NAME;var TRIGGER_NAME="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:o=!1,...l}=e,u=usePopperScope(n),p=useSelectContext(TRIGGER_NAME,n),d=p.disabled||o,f=useComposedRefs(t,p.onTriggerChange),m=useCollection(n),g=React__namespace.useRef("touch"),[b,_,S]=useTypeaheadSearch(C=>{const R=m().filter(O=>!O.disabled),I=R.find(O=>O.value===p.value),N=findNextItem(R,C,I);N!==void 0&&p.onValueChange(N.value)}),E=C=>{d||(p.onOpenChange(!0),S()),C&&(p.triggerPointerDownPosRef.current={x:Math.round(C.pageX),y:Math.round(C.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...u,children:jsxRuntime.jsx(Primitive.button,{type:"button",role:"combobox","aria-controls":p.contentId,"aria-expanded":p.open,"aria-required":p.required,"aria-autocomplete":"none",dir:p.dir,"data-state":p.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":shouldShowPlaceholder(p.value)?"":void 0,...l,ref:f,onClick:composeEventHandlers(l.onClick,C=>{C.currentTarget.focus(),g.current!=="mouse"&&E(C)}),onPointerDown:composeEventHandlers(l.onPointerDown,C=>{g.current=C.pointerType;const R=C.target;R.hasPointerCapture(C.pointerId)&&R.releasePointerCapture(C.pointerId),C.button===0&&C.ctrlKey===!1&&C.pointerType==="mouse"&&(E(C),C.preventDefault())}),onKeyDown:composeEventHandlers(l.onKeyDown,C=>{const R=b.current!=="";!(C.ctrlKey||C.altKey||C.metaKey)&&C.key.length===1&&_(C.key),!(R&&C.key===" ")&&OPEN_KEYS.includes(C.key)&&(E(),C.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:l,children:u,placeholder:p="",...d}=e,f=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:m}=f,g=u!==void 0,b=useComposedRefs(t,f.onValueNodeChange);return useLayoutEffect2(()=>{m(g)},[m,g]),jsxRuntime.jsx(Primitive.span,{...d,ref:b,style:{pointerEvents:"none"},children:shouldShowPlaceholder(f.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:p}):u})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:o,...l}=e;return jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...l,ref:t,children:o||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$4,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME;var CONTENT_NAME="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME,e.__scopeSelect),[o,l]=React__namespace.useState();if(useLayoutEffect2(()=>{l(new DocumentFragment)},[]),!n.open){const u=o;return u?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),u):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME),CONTENT_IMPL_NAME="SelectContentImpl",Slot=createSlot("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:o="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:u,onPointerDownOutside:p,side:d,sideOffset:f,align:m,alignOffset:g,arrowPadding:b,collisionBoundary:_,collisionPadding:S,sticky:E,hideWhenDetached:C,avoidCollisions:R,...I}=e,N=useSelectContext(CONTENT_NAME,n),[O,V]=React__namespace.useState(null),[M,A]=React__namespace.useState(null),j=useComposedRefs(t,he=>V(he)),[B,L]=React__namespace.useState(null),[q,F]=React__namespace.useState(null),H=useCollection(n),[U,G]=React__namespace.useState(!1),J=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(O)return hideOthers(O)},[O]),useFocusGuards();const Z=React__namespace.useCallback(he=>{const[ye,...de]=H().map(te=>te.ref.current),[le]=de.slice(-1),se=document.activeElement;for(const te of he)if(te===se||(te==null||te.scrollIntoView({block:"nearest"}),te===ye&&M&&(M.scrollTop=0),te===le&&M&&(M.scrollTop=M.scrollHeight),te==null||te.focus(),document.activeElement!==se))return},[H,M]),ae=React__namespace.useCallback(()=>Z([B,O]),[Z,B,O]);React__namespace.useEffect(()=>{U&&ae()},[U,ae]);const{onOpenChange:W,triggerPointerDownPosRef:Q}=N;React__namespace.useEffect(()=>{if(O){let he={x:0,y:0};const ye=le=>{var se,te;he={x:Math.abs(Math.round(le.pageX)-(((se=Q.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(le.pageY)-(((te=Q.current)==null?void 0:te.y)??0))}},de=le=>{he.x<=10&&he.y<=10?le.preventDefault():O.contains(le.target)||W(!1),document.removeEventListener("pointermove",ye),Q.current=null};return Q.current!==null&&(document.addEventListener("pointermove",ye),document.addEventListener("pointerup",de,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ye),document.removeEventListener("pointerup",de,{capture:!0})}}},[O,W,Q]),React__namespace.useEffect(()=>{const he=()=>W(!1);return window.addEventListener("blur",he),window.addEventListener("resize",he),()=>{window.removeEventListener("blur",he),window.removeEventListener("resize",he)}},[W]);const[ee,ie]=useTypeaheadSearch(he=>{const ye=H().filter(se=>!se.disabled),de=ye.find(se=>se.ref.current===document.activeElement),le=findNextItem(ye,he,de);le&&setTimeout(()=>le.ref.current.focus())}),ce=React__namespace.useCallback((he,ye,de)=>{const le=!J.current&&!de;(N.value!==void 0&&N.value===ye||le)&&(L(he),le&&(J.current=!0))},[N.value]),ue=React__namespace.useCallback(()=>O==null?void 0:O.focus(),[O]),fe=React__namespace.useCallback((he,ye,de)=>{const le=!J.current&&!de;(N.value!==void 0&&N.value===ye||le)&&F(he)},[N.value]),pe=o==="popper"?SelectPopperPosition:SelectItemAlignedPosition,ve=pe===SelectPopperPosition?{side:d,sideOffset:f,align:m,alignOffset:g,arrowPadding:b,collisionBoundary:_,collisionPadding:S,sticky:E,hideWhenDetached:C,avoidCollisions:R}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:O,viewport:M,onViewportChange:A,itemRefCallback:ce,selectedItem:B,onItemLeave:ue,itemTextRefCallback:fe,focusSelectedItem:ae,selectedItemText:q,position:o,isPositioned:U,searchRef:ee,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:N.open,onMountAutoFocus:he=>{he.preventDefault()},onUnmountAutoFocus:composeEventHandlers(l,he=>{var ye;(ye=N.trigger)==null||ye.focus({preventScroll:!0}),he.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:he=>he.preventDefault(),onDismiss:()=>N.onOpenChange(!1),children:jsxRuntime.jsx(pe,{role:"listbox",id:N.contentId,"data-state":N.open?"open":"closed",dir:N.dir,onContextMenu:he=>he.preventDefault(),...I,...ve,onPlaced:()=>G(!0),ref:j,style:{display:"flex",flexDirection:"column",outline:"none",...I.style},onKeyDown:composeEventHandlers(I.onKeyDown,he=>{const ye=he.ctrlKey||he.altKey||he.metaKey;if(he.key==="Tab"&&he.preventDefault(),!ye&&he.key.length===1&&ie(he.key),["ArrowUp","ArrowDown","Home","End"].includes(he.key)){let le=H().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(he.key)&&(le=le.slice().reverse()),["ArrowUp","ArrowDown"].includes(he.key)){const se=he.target,te=le.indexOf(se);le=le.slice(te+1)}setTimeout(()=>Z(le)),he.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:o,...l}=e,u=useSelectContext(CONTENT_NAME,n),p=useSelectContentContext(CONTENT_NAME,n),[d,f]=React__namespace.useState(null),[m,g]=React__namespace.useState(null),b=useComposedRefs(t,j=>g(j)),_=useCollection(n),S=React__namespace.useRef(!1),E=React__namespace.useRef(!0),{viewport:C,selectedItem:R,selectedItemText:I,focusSelectedItem:N}=p,O=React__namespace.useCallback(()=>{if(u.trigger&&u.valueNode&&d&&m&&C&&R&&I){const j=u.trigger.getBoundingClientRect(),B=m.getBoundingClientRect(),L=u.valueNode.getBoundingClientRect(),q=I.getBoundingClientRect();if(u.dir!=="rtl"){const se=q.left-B.left,te=L.left-se,xe=j.left-te,oe=j.width+xe,be=Math.max(oe,B.width),_e=window.innerWidth-CONTENT_MARGIN,Ce=clamp(te,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,_e-be)]);d.style.minWidth=oe+"px",d.style.left=Ce+"px"}else{const se=B.right-q.right,te=window.innerWidth-L.right-se,xe=window.innerWidth-j.right-te,oe=j.width+xe,be=Math.max(oe,B.width),_e=window.innerWidth-CONTENT_MARGIN,Ce=clamp(te,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,_e-be)]);d.style.minWidth=oe+"px",d.style.right=Ce+"px"}const F=_(),H=window.innerHeight-CONTENT_MARGIN*2,U=C.scrollHeight,G=window.getComputedStyle(m),J=parseInt(G.borderTopWidth,10),Z=parseInt(G.paddingTop,10),ae=parseInt(G.borderBottomWidth,10),W=parseInt(G.paddingBottom,10),Q=J+Z+U+W+ae,ee=Math.min(R.offsetHeight*5,Q),ie=window.getComputedStyle(C),ce=parseInt(ie.paddingTop,10),ue=parseInt(ie.paddingBottom,10),fe=j.top+j.height/2-CONTENT_MARGIN,pe=H-fe,ve=R.offsetHeight/2,he=R.offsetTop+ve,ye=J+Z+he,de=Q-ye;if(ye<=fe){const se=F.length>0&&R===F[F.length-1].ref.current;d.style.bottom="0px";const te=m.clientHeight-C.offsetTop-C.offsetHeight,xe=Math.max(pe,ve+(se?ue:0)+te+ae),oe=ye+xe;d.style.height=oe+"px"}else{const se=F.length>0&&R===F[0].ref.current;d.style.top="0px";const xe=Math.max(fe,J+C.offsetTop+(se?ce:0)+ve)+de;d.style.height=xe+"px",C.scrollTop=ye-fe+C.offsetTop}d.style.margin=`${CONTENT_MARGIN}px 0`,d.style.minHeight=ee+"px",d.style.maxHeight=H+"px",o==null||o(),requestAnimationFrame(()=>S.current=!0)}},[_,u.trigger,u.valueNode,d,m,C,R,I,u.dir,o]);useLayoutEffect2(()=>O(),[O]);const[V,M]=React__namespace.useState();useLayoutEffect2(()=>{m&&M(window.getComputedStyle(m).zIndex)},[m]);const A=React__namespace.useCallback(j=>{j&&E.current===!0&&(O(),N==null||N(),E.current=!1)},[O,N]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:S,onScrollButtonChange:A,children:jsxRuntime.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:V},children:jsxRuntime.jsx(Primitive.div,{...l,ref:b,style:{boxSizing:"border-box",maxHeight:"100%",...l.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:o="start",collisionPadding:l=CONTENT_MARGIN,...u}=e,p=usePopperScope(n);return jsxRuntime.jsx(Content$1,{...p,...u,ref:t,align:o,collisionPadding:l,style:{boxSizing:"border-box",...u.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:o,...l}=e,u=useSelectContentContext(VIEWPORT_NAME,n),p=useSelectViewportContext(VIEWPORT_NAME,n),d=useComposedRefs(t,u.onViewportChange),f=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...l,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...l.style},onScroll:composeEventHandlers(l.onScroll,m=>{const g=m.currentTarget,{contentWrapper:b,shouldExpandOnScrollRef:_}=p;if(_!=null&&_.current&&b){const S=Math.abs(f.current-g.scrollTop);if(S>0){const E=window.innerHeight-CONTENT_MARGIN*2,C=parseFloat(b.style.minHeight),R=parseFloat(b.style.height),I=Math.max(C,R);if(I<E){const N=I+S,O=Math.min(E,N),V=N-O;b.style.height=O+"px",b.style.bottom==="0px"&&(g.scrollTop=V>0?V:0,b.style.justifyContent="flex-end")}}}f.current=g.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=useId();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:l,children:jsxRuntime.jsx(Primitive.div,{role:"group","aria-labelledby":l,...o,ref:t})})});SelectGroup.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive.div,{id:l.id,...o,ref:t})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME),SelectItem$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,value:o,disabled:l=!1,textValue:u,...p}=e,d=useSelectContext(ITEM_NAME,n),f=useSelectContentContext(ITEM_NAME,n),m=d.value===o,[g,b]=React__namespace.useState(u??""),[_,S]=React__namespace.useState(!1),E=useComposedRefs(t,N=>{var O;return(O=f.itemRefCallback)==null?void 0:O.call(f,N,o,l)}),C=useId(),R=React__namespace.useRef("touch"),I=()=>{l||(d.onValueChange(o),d.onOpenChange(!1))};if(o==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:o,disabled:l,textId:C,isSelected:m,onItemTextChange:React__namespace.useCallback(N=>{b(O=>O||((N==null?void 0:N.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection.ItemSlot,{scope:n,value:o,disabled:l,textValue:g,children:jsxRuntime.jsx(Primitive.div,{role:"option","aria-labelledby":C,"data-highlighted":_?"":void 0,"aria-selected":m&&_,"data-state":m?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...p,ref:E,onFocus:composeEventHandlers(p.onFocus,()=>S(!0)),onBlur:composeEventHandlers(p.onBlur,()=>S(!1)),onClick:composeEventHandlers(p.onClick,()=>{R.current!=="mouse"&&I()}),onPointerUp:composeEventHandlers(p.onPointerUp,()=>{R.current==="mouse"&&I()}),onPointerDown:composeEventHandlers(p.onPointerDown,N=>{R.current=N.pointerType}),onPointerMove:composeEventHandlers(p.onPointerMove,N=>{var O;R.current=N.pointerType,l?(O=f.onItemLeave)==null||O.call(f):R.current==="mouse"&&N.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(p.onPointerLeave,N=>{var O;N.currentTarget===document.activeElement&&((O=f.onItemLeave)==null||O.call(f))}),onKeyDown:composeEventHandlers(p.onKeyDown,N=>{var V;((V=f.searchRef)==null?void 0:V.current)!==""&&N.key===" "||(SELECTION_KEYS.includes(N.key)&&I(),N.key===" "&&N.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:l,...u}=e,p=useSelectContext(ITEM_TEXT_NAME,n),d=useSelectContentContext(ITEM_TEXT_NAME,n),f=useSelectItemContext(ITEM_TEXT_NAME,n),m=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[g,b]=React__namespace.useState(null),_=useComposedRefs(t,I=>b(I),f.onItemTextChange,I=>{var N;return(N=d.itemTextRefCallback)==null?void 0:N.call(d,I,f.value,f.disabled)}),S=g==null?void 0:g.textContent,E=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:f.value,disabled:f.disabled,children:S},f.value),[f.disabled,f.value,S]),{onNativeOptionAdd:C,onNativeOptionRemove:R}=m;return useLayoutEffect2(()=>(C(E),()=>R(E)),[C,R,E]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive.span,{id:f.textId,...u,ref:_}),f.isSelected&&p.valueNode&&!p.valueNodeHasChildren?ReactDOM__namespace.createPortal(u.children,p.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...o,ref:t}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),o=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[l,u]=React__namespace.useState(!1),p=useComposedRefs(t,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let d=function(){const m=f.scrollTop>0;u(m)};const f=n.viewport;return d(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:p,onAutoScroll:()=>{const{viewport:d,selectedItem:f}=n;d&&f&&(d.scrollTop=d.scrollTop-f.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),o=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[l,u]=React__namespace.useState(!1),p=useComposedRefs(t,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let d=function(){const m=f.scrollHeight-f.clientHeight,g=Math.ceil(f.scrollTop)<m;u(g)};const f=n.viewport;return d(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:p,onAutoScroll:()=>{const{viewport:d,selectedItem:f}=n;d&&f&&(d.scrollTop=d.scrollTop+f.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:o,...l}=e,u=useSelectContentContext("SelectScrollButton",n),p=React__namespace.useRef(null),d=useCollection(n),f=React__namespace.useCallback(()=>{p.current!==null&&(window.clearInterval(p.current),p.current=null)},[]);return React__namespace.useEffect(()=>()=>f(),[f]),useLayoutEffect2(()=>{var g;const m=d().find(b=>b.ref.current===document.activeElement);(g=m==null?void 0:m.ref.current)==null||g.scrollIntoView({block:"nearest"})},[d]),jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...l,ref:t,style:{flexShrink:0,...l.style},onPointerDown:composeEventHandlers(l.onPointerDown,()=>{p.current===null&&(p.current=window.setInterval(o,50))}),onPointerMove:composeEventHandlers(l.onPointerMove,()=>{var m;(m=u.onItemLeave)==null||m.call(u),p.current===null&&(p.current=window.setInterval(o,50))}),onPointerLeave:composeEventHandlers(l.onPointerLeave,()=>{f()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...o,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=usePopperScope(n),u=useSelectContext(ARROW_NAME,n),p=useSelectContentContext(ARROW_NAME,n);return u.open&&p.position==="popper"?jsxRuntime.jsx(Arrow,{...l,...o,ref:t}):null});SelectArrow.displayName=ARROW_NAME;var BUBBLE_INPUT_NAME$1="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:e,value:t,...n},o)=>{const l=React__namespace.useRef(null),u=useComposedRefs(o,l),p=usePrevious(t);return React__namespace.useEffect(()=>{const d=l.current;if(!d)return;const f=window.HTMLSelectElement.prototype,g=Object.getOwnPropertyDescriptor(f,"value").set;if(p!==t&&g){const b=new Event("change",{bubbles:!0});g.call(d,t),d.dispatchEvent(b)}},[p,t]),jsxRuntime.jsx(Primitive.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:u,defaultValue:t})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function shouldShowPlaceholder(e){return e===""||e===void 0}function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),o=React__namespace.useRef(0),l=React__namespace.useCallback(p=>{const d=n.current+p;t(d),function f(m){n.current=m,window.clearTimeout(o.current),m!==""&&(o.current=window.setTimeout(()=>f(""),1e3))}(d)},[t]),u=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(o.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(o.current),[]),[n,l,u]}function findNextItem(e,t,n){const l=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,u=n?e.indexOf(n):-1;let p=wrapArray(e,Math.max(u,0));l.length===1&&(p=p.filter(m=>m!==n));const f=p.find(m=>m.textValue.toLowerCase().startsWith(l.toLowerCase()));return f!==n?f:void 0}function wrapArray(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var Root2=Select$1,Trigger=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal=SelectPortal,Content2=SelectContent$1,Viewport=SelectViewport,Label=SelectLabel$1,Item=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select=Root2,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsxs(Trigger,{ref:o,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:e,children:t,position:n="popper",...o},l)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsxs(Content2,{ref:l,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...o,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2.displayName;const SelectLabel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",e),...t}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsxs(Item,{ref:o,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:t})]}));SelectItem.displayName=Item.displayName;const SelectSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",e),...t}));SelectSeparator.displayName=Separator.displayName;var SWITCH_NAME="Switch",[createSwitchContext,createSwitchScope]=createContextScope(SWITCH_NAME),[SwitchProvider,useSwitchContext]=createSwitchContext(SWITCH_NAME),Switch$1=React__namespace.forwardRef((e,t)=>{const{__scopeSwitch:n,name:o,checked:l,defaultChecked:u,required:p,disabled:d,value:f="on",onCheckedChange:m,form:g,...b}=e,[_,S]=React__namespace.useState(null),E=useComposedRefs(t,O=>S(O)),C=React__namespace.useRef(!1),R=_?g||!!_.closest("form"):!0,[I,N]=useControllableState({prop:l,defaultProp:u??!1,onChange:m,caller:SWITCH_NAME});return jsxRuntime.jsxs(SwitchProvider,{scope:n,checked:I,disabled:d,children:[jsxRuntime.jsx(Primitive.button,{type:"button",role:"switch","aria-checked":I,"aria-required":p,"data-state":getState(I),"data-disabled":d?"":void 0,disabled:d,value:f,...b,ref:E,onClick:composeEventHandlers(e.onClick,O=>{N(V=>!V),R&&(C.current=O.isPropagationStopped(),C.current||O.stopPropagation())})}),R&&jsxRuntime.jsx(SwitchBubbleInput,{control:_,bubbles:!C.current,name:o,value:f,checked:I,required:p,disabled:d,form:g,style:{transform:"translateX(-100%)"}})]})});Switch$1.displayName=SWITCH_NAME;var THUMB_NAME="SwitchThumb",SwitchThumb=React__namespace.forwardRef((e,t)=>{const{__scopeSwitch:n,...o}=e,l=useSwitchContext(THUMB_NAME,n);return jsxRuntime.jsx(Primitive.span,{"data-state":getState(l.checked),"data-disabled":l.disabled?"":void 0,...o,ref:t})});SwitchThumb.displayName=THUMB_NAME;var BUBBLE_INPUT_NAME="SwitchBubbleInput",SwitchBubbleInput=React__namespace.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:o=!0,...l},u)=>{const p=React__namespace.useRef(null),d=useComposedRefs(p,u),f=usePrevious(n),m=useSize(t);return React__namespace.useEffect(()=>{const g=p.current;if(!g)return;const b=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(b,"checked").set;if(f!==n&&S){const E=new Event("click",{bubbles:o});S.call(g,n),g.dispatchEvent(E)}},[f,n,o]),jsxRuntime.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...l,tabIndex:-1,ref:d,style:{...l.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});SwitchBubbleInput.displayName=BUBBLE_INPUT_NAME;function getState(e){return e?"checked":"unchecked"}var Root=Switch$1,Thumb=SwitchThumb;const Switch=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Root,{className:cn("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:jsxRuntime.jsx(Thumb,{className:cn("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Switch.displayName=Root.displayName;const DAYS_OF_WEEK=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ManufacturerReorderingCard({manufacturer:e,onSave:t,loading:n=!1,saving:o=!1}){const[l,u]=React.useState({...e}),p=(_,S)=>{u(E=>({...E,[_]:S}))},d=(_,S)=>{u(E=>({...E,[_]:S}))},f=(_,S)=>{u(E=>({...E,[_]:S}))},m=()=>{o||t(l)},g=_=>_===-1?"ASAP":_===void 0||_<0||_>6?"Sunday":DAYS_OF_WEEK[_],b=_=>_==="ASAP"?-1:DAYS_OF_WEEK.indexOf(_);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:l.AutoUpdate,onCheckedChange:_=>p("AutoUpdate",_),disabled:o}),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,{value:g(l.AutoReorderDate),onValueChange:_=>d("AutoReorderDate",b(_)),disabled:o,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(_=>jsxRuntime.jsx(SelectItem,{value:_,children:_},_))]})]})]}),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:l.DefaultWeeksOfStocking||"",onChange:_=>d("DefaultWeeksOfStocking",Number(_.target.value)),disabled:o}),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:l.DefaultMinimumOrder||"",onChange:_=>d("DefaultMinimumOrder",Number(_.target.value)),disabled:o})]})]}),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:l.DefaultLeadTime||"",onChange:_=>d("DefaultLeadTime",Number(_.target.value)),disabled:o}),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:l.DefaultMaxInventoryValue||"",onChange:_=>d("DefaultMaxInventoryValue",Number(_.target.value)),disabled:o})]})]}),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:l.POEmail||"",onChange:_=>f("POEmail",_.target.value),placeholder:"email@example.com",disabled:o})]})]})]})}),jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button,{onClick:m,disabled:o,children:[o&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}const imgSizeMap={sm:100,md:200,lg:300,xl:400};function ProductImage({randmarSKU:e,size:t="md",alt:n,secondaryContent:o}){const[l,u]=React__namespace.useState(!1),[p,d]=React__namespace.useState(!1),[f,m]=React__namespace.useState(!1),[g,b]=React__namespace.useState(!1),_=`https://api.randmar.io/Product/${e}/Video`;React__namespace.useEffect(()=>{(async()=>{try{const O=await(await fetch(_+"/Exists")).json();d(O)}catch(N){console.error("Error checking for video:",N),d(!1)}})()},[e,_]);async function S(){if(p){b(!0);try{const N=await(await fetch(_)).blob(),O=window.URL.createObjectURL(N),V=document.createElement("a");V.href=O,V.download=`${e||"product"}-video.mp4`,document.body.appendChild(V),V.click(),document.body.removeChild(V),window.URL.revokeObjectURL(O)}catch(I){console.error("Error downloading video:",I)}finally{b(!1)}}}function E(){navigator.clipboard.writeText(_),m(!0),setTimeout(()=>{m(!1)},2e3)}function C(){u(!0)}const R=imgSizeMap[t||"xl"];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:l,onOpenChange:u,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:o?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:_,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:o})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:_,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:E,children:f?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:S,disabled:g,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",children:[jsxRuntime.jsx("img",{alt:n||`Product ${e}`,className:`rounded-md ${p?"cursor-pointer":""}`,onClick:p?C:void 0,src:`https://api.randmar.io/Product/${e}/Image?width=${R*1.5}&height=${R*1.5}`,width:R,height:R}),p&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:C,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}function ProductCard({item:e,addToCart:t=!1,syncToShopify:n=!1,customAction:o=jsxRuntime.jsx(jsxRuntime.Fragment,{}),defaultOpportunityNumber:l="",viewProductLink:u,addToCartAction:p,isAddToCartActionLoading:d=!1,syncToShopifyAction:f,isSyncToShopifyActionLoading:m=!1}){var Q,ee,ie,ce,ue,fe,pe,ve,he,ye,de;const[g,b]=React.useState(1),[_,S]=React.useState(null),[E,C]=React.useState(0),[R,I]=React.useState(!1),N=((Q=e==null?void 0:e.Distribution)==null?void 0:Q.Cost)||0,O=((ee=e==null?void 0:e.Distribution)==null?void 0:ee.RegularPrice)||0,V=((ie=e==null?void 0:e.Distribution)==null?void 0:ie.Price)||0;React.useEffect(()=>{b(1),S(null),C(0),I(!1)},[e==null?void 0:e.RandmarSKU]);const[M,A]=React.useState(null),[j,B]=React.useState(!1);React.useEffect(()=>{const le=async()=>{if(e!=null&&e.ManufacturerId){B(!0);try{const se=await fetch(`https://api.randmar.io/V4/Partner/${e.ManufacturerId}/Account/Logo?width=60&height=40`);if(se.ok){const te=await se.blob();A(URL.createObjectURL(te))}}catch(se){console.error("Failed to load logo:",se)}finally{B(!1)}}};e!=null&&e.ManufacturerId&&le()},[e==null?void 0:e.ManufacturerId]),React.useEffect(()=>{var le;if(e&&l){const se=(le=e.Opportunities)==null?void 0:le.find(te=>te.BidNumber==l);se&&S(se)}},[e,l]),React.useEffect(()=>{if(!e)return;const le=_!=null&&_.Price?_.Price:V;C(O>0?Math.round((O-le)/O*100):0)},[e,_,V,O]),React.useEffect(()=>{d||b(1)},[d]);const L=le=>{if(le.Active!==!0)return!1;const se=new Date().toISOString().split("T")[0];return!(le.EndDate&&le.EndDate.split("T")[0]<se||le.StartDate&&le.StartDate.split("T")[0]>se)};if(!e)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"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 q=(e==null?void 0:e.Opportunities)||[],F=q.length>0,H=()=>{if(g==null){b(1);return}g>1&&b(g-1)},U=()=>{if(g==null){b(1);return}b(g+1)},G=le=>{const se=parseInt(le.target.value,10);if(!isNaN(se)&&se>0){b(se);return}b(void 0)},J=()=>{(g==null||g<1)&&b(1)},Z=((ue=(ce=e.Distribution)==null?void 0:ce.Inventory)==null?void 0:ue.reduce((le,se)=>le+(se.AvailableQuantity||0),0))||0,ae=le=>{try{return new Date(le).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(se){return console.error(se),le.split("T")[0]||"N/A"}},W=()=>{p&&p({quantity:g??1,bidNumber:(_==null?void 0:_.BidNumber)??null})};return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:j?jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}):M&&jsxRuntime.jsx("img",{src:M,alt:e.ManufacturerName??"",className:"max-h-10 max-w-24 object-contain"})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",e.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",e.SerialNumber?"Serialized":"Unserialized"]}),e.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),e.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",e.AvailableToBuy?"Available":"Unavailable"]}),e.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(fe=e.ManufacturerCategory)!=null&&fe.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(pe=e.ManufacturerCategory)!=null&&pe.QualificationRequired?"Qualified Only":"Available to all"]}),e.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",e.AutoUpdate?`Automatic Reorder (${e.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.BodyHTML&&e.Title&&e.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",e.BodyHTML&&e.Title&&e.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:e.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:e.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:e.UnitWeight?`${e.UnitWeight} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MAP"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MAP?"$"+e.MAP.toFixed(2):"N/A"})]}),e.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:e.CountryCodeOfOrigin,className:"mr-2"}),e.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:F&&e.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+q.length+(q.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:q.map((le,se)=>{var te;return jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
853
+ `),b=await new GoogleGenAI({apiKey:e}).chats.create({model:"gemini-2.0-flash-lite"}).sendMessage({message:f}),_=trimJSXString(b.text??"");return _||(o==0?"<p>Failed to generate. Reload the page.</p>":await GetJSXFromAI(e,t,n,o-1))};function trimJSXString(e){const t=e.indexOf("<"),n=e.lastIndexOf("</");return t===-1||n===-1?"":e.slice(t,e.indexOf(">",n)+1)}function AiGeneratedContent(e){const{appID:t}=reactRouterDom.useParams(),[n,o]=React.useState(""),{apiKey:l}=useApiKey();return React.useEffect(()=>{if(!l||!e.prompt||!e.data)return;o("");let u=!1;return GetJSXFromAI(l,e.prompt,e.data).then(p=>{u||o(p)}),()=>{u=!0}},[e.prompt,e.data,o,l]),n?jsxRuntime.jsx(source_default,{bindings:{appID:t},components:{Button},jsx:n}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(Skeleton,{className:"h-32 w-32",children:jsxRuntime.jsx(Bot,{className:"m-auto align-middle h-full"})})})}const CountryFlag=({countryCode:e,className:t=""})=>{const[n,o]=React.useState(null),[l,u]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const d=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(d,{method:"HEAD"}).then(f=>{f.ok?(o(d),u(!1)):u(!0)}).catch(()=>{u(!0)})},[e]),l||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})};function GeneralDocumentCard({document:e,loading:t=!1}){return t?jsxRuntime.jsx("div",{children:"loading..."}):jsxRuntime.jsxs("div",{children:["GENERAL DOCUMENT CARD - ",e==null?void 0:e.OrderNumber," for P.O. ",e==null?void 0:e.PONumber]})}const Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,withRandmarAssistant:o,chatUserName:l,chatApiKey:u},p)=>{const{appID:d}=reactRouterDom.useParams(),f=e.filter(_=>_.showInNav),m=React.useRef(null),g=React.useRef(null),b=React.useRef(null);return React.useImperativeHandle(p,()=>({setActiveChatAndSendMessage:(_,S)=>{var E;return(E=b.current)==null||E.click(),setTimeout(()=>{var C;(C=m.current)==null||C.focus(),g.current&&g.current.setActiveChatAndSendMessage(_,S)},100),!0}})),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("img",{src:"https://api.randmar.io/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:jsxRuntime.jsx(SidebarMenu,{children:f.map(_=>{const S=_.icon,E=`/${_.path.replace(":appID",d??"")}`;return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:E,className:"transition-colors hover:bg-muted px-6",children:[S&&jsxRuntime.jsx(S,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:_.label})]})})},_.key)})})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground",children:[o===!0&&jsxRuntime.jsxs(Dialog,{children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:b,size:"lg",className:"collapse md:visible",onClick:()=>setTimeout(()=>{var _;return(_=m.current)==null?void 0:_.focus()},50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(DialogContent,{className:"max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,children:jsxRuntime.jsx(ChatLayout,{ref:g,inputRef:m,userId:d??"2",userName:l??"Unknown user",apiKey:u??""})})]}),t]})]})}),Layout=React.forwardRef(({children:e,rightMenu:t,routes:n,footer:o,handleValidSearch:l,dashboardTitle:u,onSignOut:p,searchPlaceholder:d,withRandmarAssistant:f,chatUserName:m,chatApiKey:g,chatRef:b},_)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{routes:n,footer:o,dashboardTitle:u,withRandmarAssistant:f,chatUserName:m,chatApiKey:g,ref:b}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[jsxRuntime.jsx(Topbar,{ref:_,onSignOut:p,rightMenu:t,handleValidSearch:l,searchPlaceholder:d}),jsxRuntime.jsx("main",{className:"flex-1 overflow-auto mt-16",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";function usePrevious(e){const t=React__namespace.useRef({value:e,previous:e});return React__namespace.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection,useCollection,createCollectionScope]=createCollection(SELECT_NAME),[createSelectContext,createSelectScope]=createContextScope(SELECT_NAME,[createCollectionScope,createPopperScope]),usePopperScope=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$1=e=>{const{__scopeSelect:t,children:n,open:o,defaultOpen:l,onOpenChange:u,value:p,defaultValue:d,onValueChange:f,dir:m,name:g,autoComplete:b,disabled:_,required:S,form:E}=e,C=usePopperScope(t),[R,I]=React__namespace.useState(null),[N,O]=React__namespace.useState(null),[V,M]=React__namespace.useState(!1),A=useDirection(m),[j,B]=useControllableState({prop:o,defaultProp:l??!1,onChange:u,caller:SELECT_NAME}),[L,q]=useControllableState({prop:p,defaultProp:d,onChange:f,caller:SELECT_NAME}),F=React__namespace.useRef(null),H=R?E||!!R.closest("form"):!0,[U,G]=React__namespace.useState(new Set),J=Array.from(U).map(Z=>Z.props.value).join(";");return jsxRuntime.jsx(Root2$4,{...C,children:jsxRuntime.jsxs(SelectProvider,{required:S,scope:t,trigger:R,onTriggerChange:I,valueNode:N,onValueNodeChange:O,valueNodeHasChildren:V,onValueNodeHasChildrenChange:M,contentId:useId(),value:L,onValueChange:q,open:j,onOpenChange:B,dir:A,triggerPointerDownPosRef:F,disabled:_,children:[jsxRuntime.jsx(Collection.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Z=>{G(ae=>new Set(ae).add(Z))},[]),onNativeOptionRemove:React__namespace.useCallback(Z=>{G(ae=>{const W=new Set(ae);return W.delete(Z),W})},[]),children:n})}),H?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:S,tabIndex:-1,name:g,autoComplete:b,value:L,onChange:Z=>q(Z.target.value),disabled:_,form:E,children:[L===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(U)]},J):null]})})};Select$1.displayName=SELECT_NAME;var TRIGGER_NAME="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:o=!1,...l}=e,u=usePopperScope(n),p=useSelectContext(TRIGGER_NAME,n),d=p.disabled||o,f=useComposedRefs(t,p.onTriggerChange),m=useCollection(n),g=React__namespace.useRef("touch"),[b,_,S]=useTypeaheadSearch(C=>{const R=m().filter(O=>!O.disabled),I=R.find(O=>O.value===p.value),N=findNextItem(R,C,I);N!==void 0&&p.onValueChange(N.value)}),E=C=>{d||(p.onOpenChange(!0),S()),C&&(p.triggerPointerDownPosRef.current={x:Math.round(C.pageX),y:Math.round(C.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...u,children:jsxRuntime.jsx(Primitive.button,{type:"button",role:"combobox","aria-controls":p.contentId,"aria-expanded":p.open,"aria-required":p.required,"aria-autocomplete":"none",dir:p.dir,"data-state":p.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":shouldShowPlaceholder(p.value)?"":void 0,...l,ref:f,onClick:composeEventHandlers(l.onClick,C=>{C.currentTarget.focus(),g.current!=="mouse"&&E(C)}),onPointerDown:composeEventHandlers(l.onPointerDown,C=>{g.current=C.pointerType;const R=C.target;R.hasPointerCapture(C.pointerId)&&R.releasePointerCapture(C.pointerId),C.button===0&&C.ctrlKey===!1&&C.pointerType==="mouse"&&(E(C),C.preventDefault())}),onKeyDown:composeEventHandlers(l.onKeyDown,C=>{const R=b.current!=="";!(C.ctrlKey||C.altKey||C.metaKey)&&C.key.length===1&&_(C.key),!(R&&C.key===" ")&&OPEN_KEYS.includes(C.key)&&(E(),C.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:l,children:u,placeholder:p="",...d}=e,f=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:m}=f,g=u!==void 0,b=useComposedRefs(t,f.onValueNodeChange);return useLayoutEffect2(()=>{m(g)},[m,g]),jsxRuntime.jsx(Primitive.span,{...d,ref:b,style:{pointerEvents:"none"},children:shouldShowPlaceholder(f.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:p}):u})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:o,...l}=e;return jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...l,ref:t,children:o||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$4,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME;var CONTENT_NAME="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME,e.__scopeSelect),[o,l]=React__namespace.useState();if(useLayoutEffect2(()=>{l(new DocumentFragment)},[]),!n.open){const u=o;return u?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),u):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME),CONTENT_IMPL_NAME="SelectContentImpl",Slot=createSlot("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:o="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:u,onPointerDownOutside:p,side:d,sideOffset:f,align:m,alignOffset:g,arrowPadding:b,collisionBoundary:_,collisionPadding:S,sticky:E,hideWhenDetached:C,avoidCollisions:R,...I}=e,N=useSelectContext(CONTENT_NAME,n),[O,V]=React__namespace.useState(null),[M,A]=React__namespace.useState(null),j=useComposedRefs(t,he=>V(he)),[B,L]=React__namespace.useState(null),[q,F]=React__namespace.useState(null),H=useCollection(n),[U,G]=React__namespace.useState(!1),J=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(O)return hideOthers(O)},[O]),useFocusGuards();const Z=React__namespace.useCallback(he=>{const[ye,...de]=H().map(te=>te.ref.current),[le]=de.slice(-1),se=document.activeElement;for(const te of he)if(te===se||(te==null||te.scrollIntoView({block:"nearest"}),te===ye&&M&&(M.scrollTop=0),te===le&&M&&(M.scrollTop=M.scrollHeight),te==null||te.focus(),document.activeElement!==se))return},[H,M]),ae=React__namespace.useCallback(()=>Z([B,O]),[Z,B,O]);React__namespace.useEffect(()=>{U&&ae()},[U,ae]);const{onOpenChange:W,triggerPointerDownPosRef:Q}=N;React__namespace.useEffect(()=>{if(O){let he={x:0,y:0};const ye=le=>{var se,te;he={x:Math.abs(Math.round(le.pageX)-(((se=Q.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(le.pageY)-(((te=Q.current)==null?void 0:te.y)??0))}},de=le=>{he.x<=10&&he.y<=10?le.preventDefault():O.contains(le.target)||W(!1),document.removeEventListener("pointermove",ye),Q.current=null};return Q.current!==null&&(document.addEventListener("pointermove",ye),document.addEventListener("pointerup",de,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ye),document.removeEventListener("pointerup",de,{capture:!0})}}},[O,W,Q]),React__namespace.useEffect(()=>{const he=()=>W(!1);return window.addEventListener("blur",he),window.addEventListener("resize",he),()=>{window.removeEventListener("blur",he),window.removeEventListener("resize",he)}},[W]);const[ee,ie]=useTypeaheadSearch(he=>{const ye=H().filter(se=>!se.disabled),de=ye.find(se=>se.ref.current===document.activeElement),le=findNextItem(ye,he,de);le&&setTimeout(()=>le.ref.current.focus())}),ce=React__namespace.useCallback((he,ye,de)=>{const le=!J.current&&!de;(N.value!==void 0&&N.value===ye||le)&&(L(he),le&&(J.current=!0))},[N.value]),ue=React__namespace.useCallback(()=>O==null?void 0:O.focus(),[O]),fe=React__namespace.useCallback((he,ye,de)=>{const le=!J.current&&!de;(N.value!==void 0&&N.value===ye||le)&&F(he)},[N.value]),pe=o==="popper"?SelectPopperPosition:SelectItemAlignedPosition,ve=pe===SelectPopperPosition?{side:d,sideOffset:f,align:m,alignOffset:g,arrowPadding:b,collisionBoundary:_,collisionPadding:S,sticky:E,hideWhenDetached:C,avoidCollisions:R}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:O,viewport:M,onViewportChange:A,itemRefCallback:ce,selectedItem:B,onItemLeave:ue,itemTextRefCallback:fe,focusSelectedItem:ae,selectedItemText:q,position:o,isPositioned:U,searchRef:ee,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:N.open,onMountAutoFocus:he=>{he.preventDefault()},onUnmountAutoFocus:composeEventHandlers(l,he=>{var ye;(ye=N.trigger)==null||ye.focus({preventScroll:!0}),he.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:he=>he.preventDefault(),onDismiss:()=>N.onOpenChange(!1),children:jsxRuntime.jsx(pe,{role:"listbox",id:N.contentId,"data-state":N.open?"open":"closed",dir:N.dir,onContextMenu:he=>he.preventDefault(),...I,...ve,onPlaced:()=>G(!0),ref:j,style:{display:"flex",flexDirection:"column",outline:"none",...I.style},onKeyDown:composeEventHandlers(I.onKeyDown,he=>{const ye=he.ctrlKey||he.altKey||he.metaKey;if(he.key==="Tab"&&he.preventDefault(),!ye&&he.key.length===1&&ie(he.key),["ArrowUp","ArrowDown","Home","End"].includes(he.key)){let le=H().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(he.key)&&(le=le.slice().reverse()),["ArrowUp","ArrowDown"].includes(he.key)){const se=he.target,te=le.indexOf(se);le=le.slice(te+1)}setTimeout(()=>Z(le)),he.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:o,...l}=e,u=useSelectContext(CONTENT_NAME,n),p=useSelectContentContext(CONTENT_NAME,n),[d,f]=React__namespace.useState(null),[m,g]=React__namespace.useState(null),b=useComposedRefs(t,j=>g(j)),_=useCollection(n),S=React__namespace.useRef(!1),E=React__namespace.useRef(!0),{viewport:C,selectedItem:R,selectedItemText:I,focusSelectedItem:N}=p,O=React__namespace.useCallback(()=>{if(u.trigger&&u.valueNode&&d&&m&&C&&R&&I){const j=u.trigger.getBoundingClientRect(),B=m.getBoundingClientRect(),L=u.valueNode.getBoundingClientRect(),q=I.getBoundingClientRect();if(u.dir!=="rtl"){const se=q.left-B.left,te=L.left-se,xe=j.left-te,oe=j.width+xe,be=Math.max(oe,B.width),_e=window.innerWidth-CONTENT_MARGIN,Ce=clamp(te,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,_e-be)]);d.style.minWidth=oe+"px",d.style.left=Ce+"px"}else{const se=B.right-q.right,te=window.innerWidth-L.right-se,xe=window.innerWidth-j.right-te,oe=j.width+xe,be=Math.max(oe,B.width),_e=window.innerWidth-CONTENT_MARGIN,Ce=clamp(te,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,_e-be)]);d.style.minWidth=oe+"px",d.style.right=Ce+"px"}const F=_(),H=window.innerHeight-CONTENT_MARGIN*2,U=C.scrollHeight,G=window.getComputedStyle(m),J=parseInt(G.borderTopWidth,10),Z=parseInt(G.paddingTop,10),ae=parseInt(G.borderBottomWidth,10),W=parseInt(G.paddingBottom,10),Q=J+Z+U+W+ae,ee=Math.min(R.offsetHeight*5,Q),ie=window.getComputedStyle(C),ce=parseInt(ie.paddingTop,10),ue=parseInt(ie.paddingBottom,10),fe=j.top+j.height/2-CONTENT_MARGIN,pe=H-fe,ve=R.offsetHeight/2,he=R.offsetTop+ve,ye=J+Z+he,de=Q-ye;if(ye<=fe){const se=F.length>0&&R===F[F.length-1].ref.current;d.style.bottom="0px";const te=m.clientHeight-C.offsetTop-C.offsetHeight,xe=Math.max(pe,ve+(se?ue:0)+te+ae),oe=ye+xe;d.style.height=oe+"px"}else{const se=F.length>0&&R===F[0].ref.current;d.style.top="0px";const xe=Math.max(fe,J+C.offsetTop+(se?ce:0)+ve)+de;d.style.height=xe+"px",C.scrollTop=ye-fe+C.offsetTop}d.style.margin=`${CONTENT_MARGIN}px 0`,d.style.minHeight=ee+"px",d.style.maxHeight=H+"px",o==null||o(),requestAnimationFrame(()=>S.current=!0)}},[_,u.trigger,u.valueNode,d,m,C,R,I,u.dir,o]);useLayoutEffect2(()=>O(),[O]);const[V,M]=React__namespace.useState();useLayoutEffect2(()=>{m&&M(window.getComputedStyle(m).zIndex)},[m]);const A=React__namespace.useCallback(j=>{j&&E.current===!0&&(O(),N==null||N(),E.current=!1)},[O,N]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:S,onScrollButtonChange:A,children:jsxRuntime.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:V},children:jsxRuntime.jsx(Primitive.div,{...l,ref:b,style:{boxSizing:"border-box",maxHeight:"100%",...l.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:o="start",collisionPadding:l=CONTENT_MARGIN,...u}=e,p=usePopperScope(n);return jsxRuntime.jsx(Content$1,{...p,...u,ref:t,align:o,collisionPadding:l,style:{boxSizing:"border-box",...u.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:o,...l}=e,u=useSelectContentContext(VIEWPORT_NAME,n),p=useSelectViewportContext(VIEWPORT_NAME,n),d=useComposedRefs(t,u.onViewportChange),f=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...l,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...l.style},onScroll:composeEventHandlers(l.onScroll,m=>{const g=m.currentTarget,{contentWrapper:b,shouldExpandOnScrollRef:_}=p;if(_!=null&&_.current&&b){const S=Math.abs(f.current-g.scrollTop);if(S>0){const E=window.innerHeight-CONTENT_MARGIN*2,C=parseFloat(b.style.minHeight),R=parseFloat(b.style.height),I=Math.max(C,R);if(I<E){const N=I+S,O=Math.min(E,N),V=N-O;b.style.height=O+"px",b.style.bottom==="0px"&&(g.scrollTop=V>0?V:0,b.style.justifyContent="flex-end")}}}f.current=g.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=useId();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:l,children:jsxRuntime.jsx(Primitive.div,{role:"group","aria-labelledby":l,...o,ref:t})})});SelectGroup.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive.div,{id:l.id,...o,ref:t})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME),SelectItem$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,value:o,disabled:l=!1,textValue:u,...p}=e,d=useSelectContext(ITEM_NAME,n),f=useSelectContentContext(ITEM_NAME,n),m=d.value===o,[g,b]=React__namespace.useState(u??""),[_,S]=React__namespace.useState(!1),E=useComposedRefs(t,N=>{var O;return(O=f.itemRefCallback)==null?void 0:O.call(f,N,o,l)}),C=useId(),R=React__namespace.useRef("touch"),I=()=>{l||(d.onValueChange(o),d.onOpenChange(!1))};if(o==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:o,disabled:l,textId:C,isSelected:m,onItemTextChange:React__namespace.useCallback(N=>{b(O=>O||((N==null?void 0:N.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection.ItemSlot,{scope:n,value:o,disabled:l,textValue:g,children:jsxRuntime.jsx(Primitive.div,{role:"option","aria-labelledby":C,"data-highlighted":_?"":void 0,"aria-selected":m&&_,"data-state":m?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...p,ref:E,onFocus:composeEventHandlers(p.onFocus,()=>S(!0)),onBlur:composeEventHandlers(p.onBlur,()=>S(!1)),onClick:composeEventHandlers(p.onClick,()=>{R.current!=="mouse"&&I()}),onPointerUp:composeEventHandlers(p.onPointerUp,()=>{R.current==="mouse"&&I()}),onPointerDown:composeEventHandlers(p.onPointerDown,N=>{R.current=N.pointerType}),onPointerMove:composeEventHandlers(p.onPointerMove,N=>{var O;R.current=N.pointerType,l?(O=f.onItemLeave)==null||O.call(f):R.current==="mouse"&&N.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(p.onPointerLeave,N=>{var O;N.currentTarget===document.activeElement&&((O=f.onItemLeave)==null||O.call(f))}),onKeyDown:composeEventHandlers(p.onKeyDown,N=>{var V;((V=f.searchRef)==null?void 0:V.current)!==""&&N.key===" "||(SELECTION_KEYS.includes(N.key)&&I(),N.key===" "&&N.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:l,...u}=e,p=useSelectContext(ITEM_TEXT_NAME,n),d=useSelectContentContext(ITEM_TEXT_NAME,n),f=useSelectItemContext(ITEM_TEXT_NAME,n),m=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[g,b]=React__namespace.useState(null),_=useComposedRefs(t,I=>b(I),f.onItemTextChange,I=>{var N;return(N=d.itemTextRefCallback)==null?void 0:N.call(d,I,f.value,f.disabled)}),S=g==null?void 0:g.textContent,E=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:f.value,disabled:f.disabled,children:S},f.value),[f.disabled,f.value,S]),{onNativeOptionAdd:C,onNativeOptionRemove:R}=m;return useLayoutEffect2(()=>(C(E),()=>R(E)),[C,R,E]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive.span,{id:f.textId,...u,ref:_}),f.isSelected&&p.valueNode&&!p.valueNodeHasChildren?ReactDOM__namespace.createPortal(u.children,p.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...o,ref:t}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),o=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[l,u]=React__namespace.useState(!1),p=useComposedRefs(t,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let d=function(){const m=f.scrollTop>0;u(m)};const f=n.viewport;return d(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:p,onAutoScroll:()=>{const{viewport:d,selectedItem:f}=n;d&&f&&(d.scrollTop=d.scrollTop-f.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),o=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[l,u]=React__namespace.useState(!1),p=useComposedRefs(t,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let d=function(){const m=f.scrollHeight-f.clientHeight,g=Math.ceil(f.scrollTop)<m;u(g)};const f=n.viewport;return d(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:p,onAutoScroll:()=>{const{viewport:d,selectedItem:f}=n;d&&f&&(d.scrollTop=d.scrollTop+f.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:o,...l}=e,u=useSelectContentContext("SelectScrollButton",n),p=React__namespace.useRef(null),d=useCollection(n),f=React__namespace.useCallback(()=>{p.current!==null&&(window.clearInterval(p.current),p.current=null)},[]);return React__namespace.useEffect(()=>()=>f(),[f]),useLayoutEffect2(()=>{var g;const m=d().find(b=>b.ref.current===document.activeElement);(g=m==null?void 0:m.ref.current)==null||g.scrollIntoView({block:"nearest"})},[d]),jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...l,ref:t,style:{flexShrink:0,...l.style},onPointerDown:composeEventHandlers(l.onPointerDown,()=>{p.current===null&&(p.current=window.setInterval(o,50))}),onPointerMove:composeEventHandlers(l.onPointerMove,()=>{var m;(m=u.onItemLeave)==null||m.call(u),p.current===null&&(p.current=window.setInterval(o,50))}),onPointerLeave:composeEventHandlers(l.onPointerLeave,()=>{f()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...o,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=usePopperScope(n),u=useSelectContext(ARROW_NAME,n),p=useSelectContentContext(ARROW_NAME,n);return u.open&&p.position==="popper"?jsxRuntime.jsx(Arrow,{...l,...o,ref:t}):null});SelectArrow.displayName=ARROW_NAME;var BUBBLE_INPUT_NAME$1="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:e,value:t,...n},o)=>{const l=React__namespace.useRef(null),u=useComposedRefs(o,l),p=usePrevious(t);return React__namespace.useEffect(()=>{const d=l.current;if(!d)return;const f=window.HTMLSelectElement.prototype,g=Object.getOwnPropertyDescriptor(f,"value").set;if(p!==t&&g){const b=new Event("change",{bubbles:!0});g.call(d,t),d.dispatchEvent(b)}},[p,t]),jsxRuntime.jsx(Primitive.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:u,defaultValue:t})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function shouldShowPlaceholder(e){return e===""||e===void 0}function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),o=React__namespace.useRef(0),l=React__namespace.useCallback(p=>{const d=n.current+p;t(d),function f(m){n.current=m,window.clearTimeout(o.current),m!==""&&(o.current=window.setTimeout(()=>f(""),1e3))}(d)},[t]),u=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(o.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(o.current),[]),[n,l,u]}function findNextItem(e,t,n){const l=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,u=n?e.indexOf(n):-1;let p=wrapArray(e,Math.max(u,0));l.length===1&&(p=p.filter(m=>m!==n));const f=p.find(m=>m.textValue.toLowerCase().startsWith(l.toLowerCase()));return f!==n?f:void 0}function wrapArray(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var Root2=Select$1,Trigger=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal=SelectPortal,Content2=SelectContent$1,Viewport=SelectViewport,Label=SelectLabel$1,Item=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select=Root2,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsxs(Trigger,{ref:o,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:e,children:t,position:n="popper",...o},l)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsxs(Content2,{ref:l,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...o,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2.displayName;const SelectLabel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",e),...t}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsxs(Item,{ref:o,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:t})]}));SelectItem.displayName=Item.displayName;const SelectSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",e),...t}));SelectSeparator.displayName=Separator.displayName;var SWITCH_NAME="Switch",[createSwitchContext,createSwitchScope]=createContextScope(SWITCH_NAME),[SwitchProvider,useSwitchContext]=createSwitchContext(SWITCH_NAME),Switch$1=React__namespace.forwardRef((e,t)=>{const{__scopeSwitch:n,name:o,checked:l,defaultChecked:u,required:p,disabled:d,value:f="on",onCheckedChange:m,form:g,...b}=e,[_,S]=React__namespace.useState(null),E=useComposedRefs(t,O=>S(O)),C=React__namespace.useRef(!1),R=_?g||!!_.closest("form"):!0,[I,N]=useControllableState({prop:l,defaultProp:u??!1,onChange:m,caller:SWITCH_NAME});return jsxRuntime.jsxs(SwitchProvider,{scope:n,checked:I,disabled:d,children:[jsxRuntime.jsx(Primitive.button,{type:"button",role:"switch","aria-checked":I,"aria-required":p,"data-state":getState(I),"data-disabled":d?"":void 0,disabled:d,value:f,...b,ref:E,onClick:composeEventHandlers(e.onClick,O=>{N(V=>!V),R&&(C.current=O.isPropagationStopped(),C.current||O.stopPropagation())})}),R&&jsxRuntime.jsx(SwitchBubbleInput,{control:_,bubbles:!C.current,name:o,value:f,checked:I,required:p,disabled:d,form:g,style:{transform:"translateX(-100%)"}})]})});Switch$1.displayName=SWITCH_NAME;var THUMB_NAME="SwitchThumb",SwitchThumb=React__namespace.forwardRef((e,t)=>{const{__scopeSwitch:n,...o}=e,l=useSwitchContext(THUMB_NAME,n);return jsxRuntime.jsx(Primitive.span,{"data-state":getState(l.checked),"data-disabled":l.disabled?"":void 0,...o,ref:t})});SwitchThumb.displayName=THUMB_NAME;var BUBBLE_INPUT_NAME="SwitchBubbleInput",SwitchBubbleInput=React__namespace.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:o=!0,...l},u)=>{const p=React__namespace.useRef(null),d=useComposedRefs(p,u),f=usePrevious(n),m=useSize(t);return React__namespace.useEffect(()=>{const g=p.current;if(!g)return;const b=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(b,"checked").set;if(f!==n&&S){const E=new Event("click",{bubbles:o});S.call(g,n),g.dispatchEvent(E)}},[f,n,o]),jsxRuntime.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...l,tabIndex:-1,ref:d,style:{...l.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});SwitchBubbleInput.displayName=BUBBLE_INPUT_NAME;function getState(e){return e?"checked":"unchecked"}var Root=Switch$1,Thumb=SwitchThumb;const Switch=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Root,{className:cn("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:jsxRuntime.jsx(Thumb,{className:cn("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Switch.displayName=Root.displayName;const DAYS_OF_WEEK=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ManufacturerReorderingCard({manufacturer:e,onSave:t,loading:n=!1,saving:o=!1}){const[l,u]=React.useState({...e}),p=(_,S)=>{u(E=>({...E,[_]:S}))},d=(_,S)=>{u(E=>({...E,[_]:S}))},f=(_,S)=>{u(E=>({...E,[_]:S}))},m=()=>{o||t(l)},g=_=>_===-1?"ASAP":_===void 0||_<0||_>6?"Sunday":DAYS_OF_WEEK[_],b=_=>_==="ASAP"?-1:DAYS_OF_WEEK.indexOf(_);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:l.AutoUpdate,onCheckedChange:_=>p("AutoUpdate",_),disabled:o}),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,{value:g(l.AutoReorderDate),onValueChange:_=>d("AutoReorderDate",b(_)),disabled:o,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(_=>jsxRuntime.jsx(SelectItem,{value:_,children:_},_))]})]})]}),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:l.DefaultWeeksOfStocking||"",onChange:_=>d("DefaultWeeksOfStocking",Number(_.target.value)),disabled:o}),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:l.DefaultMinimumOrder||"",onChange:_=>d("DefaultMinimumOrder",Number(_.target.value)),disabled:o})]})]}),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:l.DefaultLeadTime||"",onChange:_=>d("DefaultLeadTime",Number(_.target.value)),disabled:o}),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:l.DefaultMaxInventoryValue||"",onChange:_=>d("DefaultMaxInventoryValue",Number(_.target.value)),disabled:o})]})]}),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:l.POEmail||"",onChange:_=>f("POEmail",_.target.value),placeholder:"email@example.com",disabled:o})]})]})]})}),jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button,{onClick:m,disabled:o,children:[o&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}const imgSizeMap={sm:100,md:200,lg:300,xl:400};function ProductImage({randmarSKU:e,size:t="md",alt:n,secondaryContent:o}){const[l,u]=React__namespace.useState(!1),[p,d]=React__namespace.useState(!1),[f,m]=React__namespace.useState(!1),[g,b]=React__namespace.useState(!1),_=`https://api.randmar.io/Product/${e}/Video`;React__namespace.useEffect(()=>{(async()=>{try{const O=await(await fetch(_+"/Exists")).json();d(O)}catch(N){console.error("Error checking for video:",N),d(!1)}})()},[e,_]);async function S(){if(p){b(!0);try{const N=await(await fetch(_)).blob(),O=window.URL.createObjectURL(N),V=document.createElement("a");V.href=O,V.download=`${e||"product"}-video.mp4`,document.body.appendChild(V),V.click(),document.body.removeChild(V),window.URL.revokeObjectURL(O)}catch(I){console.error("Error downloading video:",I)}finally{b(!1)}}}function E(){navigator.clipboard.writeText(_),m(!0),setTimeout(()=>{m(!1)},2e3)}function C(){u(!0)}const R=imgSizeMap[t||"xl"];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:l,onOpenChange:u,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:o?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:_,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:o})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:_,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:E,children:f?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:S,disabled:g,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",children:[jsxRuntime.jsx("img",{alt:n||`Product ${e}`,className:`rounded-md ${p?"cursor-pointer":""}`,onClick:p?C:void 0,src:`https://api.randmar.io/Product/${e}/Image?width=${R*1.5}&height=${R*1.5}`,width:R,height:R}),p&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:C,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}function ProductCard({item:e,addToCart:t=!1,syncToShopify:n=!1,customAction:o=jsxRuntime.jsx(jsxRuntime.Fragment,{}),defaultOpportunityNumber:l="",viewProductLink:u,addToCartAction:p,isAddToCartActionLoading:d=!1,syncToShopifyAction:f,isSyncToShopifyActionLoading:m=!1}){var Q,ee,ie,ce,ue,fe,pe,ve,he,ye,de;const[g,b]=React.useState(1),[_,S]=React.useState(null),[E,C]=React.useState(0),[R,I]=React.useState(!1),N=((Q=e==null?void 0:e.Distribution)==null?void 0:Q.Cost)||0,O=((ee=e==null?void 0:e.Distribution)==null?void 0:ee.RegularPrice)||0,V=((ie=e==null?void 0:e.Distribution)==null?void 0:ie.Price)||0;React.useEffect(()=>{b(1),S(null),C(0),I(!1)},[e==null?void 0:e.RandmarSKU]);const[M,A]=React.useState(null),[j,B]=React.useState(!1);React.useEffect(()=>{const le=async()=>{if(e!=null&&e.ManufacturerId){B(!0);try{const se=await fetch(`https://api.randmar.io/V4/Partner/${e.ManufacturerId}/Account/Logo?width=60&height=40`);if(se.ok){const te=await se.blob();A(URL.createObjectURL(te))}}catch(se){console.error("Failed to load logo:",se)}finally{B(!1)}}};e!=null&&e.ManufacturerId&&le()},[e==null?void 0:e.ManufacturerId]),React.useEffect(()=>{var le;if(e&&l){const se=(le=e.Opportunities)==null?void 0:le.find(te=>te.BidNumber==l);se&&S(se)}},[e,l]),React.useEffect(()=>{if(!e)return;const le=_!=null&&_.Price?_.Price:V;C(O>0?Math.round((O-le)/O*100):0)},[e,_,V,O]),React.useEffect(()=>{d||b(1)},[d]);const L=le=>{if(le.Active!==!0)return!1;const se=new Date().toISOString().split("T")[0];return!(le.EndDate&&le.EndDate.split("T")[0]<se||le.StartDate&&le.StartDate.split("T")[0]>se)};if(!e)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"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 q=(e==null?void 0:e.Opportunities)||[],F=q.length>0,H=()=>{if(g==null){b(1);return}g>1&&b(g-1)},U=()=>{if(g==null){b(1);return}b(g+1)},G=le=>{const se=parseInt(le.target.value,10);if(!isNaN(se)&&se>0){b(se);return}b(void 0)},J=()=>{(g==null||g<1)&&b(1)},Z=((ue=(ce=e.Distribution)==null?void 0:ce.Inventory)==null?void 0:ue.reduce((le,se)=>le+(se.AvailableQuantity||0),0))||0,ae=le=>{try{return new Date(le).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(se){return console.error(se),le.split("T")[0]||"N/A"}},W=()=>{p&&p({quantity:g??1,bidNumber:(_==null?void 0:_.BidNumber)??null})};return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:j?jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}):M&&jsxRuntime.jsx("img",{src:M,alt:e.ManufacturerName??"",className:"max-h-10 max-w-24 object-contain"})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",e.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",e.SerialNumber?"Serialized":"Unserialized"]}),e.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),e.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",e.AvailableToBuy?"Available":"Unavailable"]}),e.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(fe=e.ManufacturerCategory)!=null&&fe.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(pe=e.ManufacturerCategory)!=null&&pe.QualificationRequired?"Qualified Only":"Available to all"]}),e.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",e.AutoUpdate?`Automatic Reorder (${e.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.BodyHTML&&e.Title&&e.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",e.BodyHTML&&e.Title&&e.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:e.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:e.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:e.UnitWeight?`${e.UnitWeight} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MAP"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MAP?"$"+e.MAP.toFixed(2):"N/A"})]}),e.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:e.CountryCodeOfOrigin,className:"mr-2"}),e.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:F&&e.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+q.length+(q.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:q.map((le,se)=>{var te;return jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
854
854
  ${le.BidNumber==(_==null?void 0:_.BidNumber)?"cursor-pointer border-2 border-purple-900":L(le)?"hover:bg-purple-200 cursor-pointer":"!bg-neutral-50"}
855
855
  `,onClick:()=>{L(le)&&S(le.BidNumber!=(_==null?void 0:_.BidNumber)?le: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:le.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[le.BidNumber," ",!L(le)&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-semibold",children:["$",(te=le.Price)==null?void 0:te.toFixed(2)]}),le.Rebate&&le.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: $",le.Rebate.toFixed(2)]}),le.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",ae(le.EndDate)]})]})]},se)})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[u&&jsxRuntime.jsx(reactRouterDom.Link,{to:u,children:jsxRuntime.jsxs(Button,{variant:"secondary",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})}),((ve=e.Distribution)==null?void 0:ve.Inventory)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsxs(Dialog,{open:R,onOpenChange:I,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:`flex items-center text-sm ${Z>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),Z>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Z," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:e.Distribution.Inventory})]})]})})]})]}),e.Distribution&&jsxRuntime.jsxs("div",{className:"flex justify-between items-end mt-4",children:[jsxRuntime.jsx("div",{className:"flex-shrink-1 flex flex-col items-start gap-1",children:N>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"Cost: $"}),N.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"$"}),_?(ye=(he=e.Opportunities)==null?void 0:he.find(le=>le.BidNumber==_.BidNumber))==null?void 0:ye.Price:V.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]}),E>0&&jsxRuntime.jsxs("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:["$",O.toFixed(2)]})]}),E>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"outline",className:"bg-red-50 text-red-700 rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[E,"% OFF"]}),((de=e.InstantRebate)==null?void 0:de.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",e.InstantRebate.EndDate.split("T")[0]]}),(_==null?void 0:_.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",_.EndDate.split("T")[0]]})]})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 gap-2 ml-4",children:[typeof t<"u"&&t&&jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:H,disabled:typeof g<"u"&&(g<=1||!e.AvailableToBuy||d||!p),children:"-"}),jsxRuntime.jsx("input",{value:g,onChange:G,onBlur:J,onClick:le=>le.currentTarget.select(),className:`w-12 text-center border-0 focus:ring-0 focus:outline-none ${!e.AvailableToBuy||d||!p?"text-gray-400":""}`,disabled:!e.AvailableToBuy||d||!p}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:U,disabled:!e.AvailableToBuy||d||!p,children:"+"})]}),typeof t<"u"&&t&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap",onClick:W,disabled:!e.AvailableToBuy||d||!p,children:d?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"]})}),n&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:f,disabled:m||!f,children:m?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"]})}),o]})]})]})})}function ResellerBillingOverviewCard({reseller:e,actions:t,loading:n=!1}){return n||!e?jsxRuntime.jsx(ResellerBillingOverviewSkeleton,{}):jsxRuntime.jsx(ResellerBillingOverviewData,{reseller:e,actions:t})}function ResellerBillingOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-40"})})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:Array(3).fill(0).map((e,t)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},t))}),jsxRuntime.jsx("div",{className:"space-y-4",children:Array(2).fill(0).map((e,t)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},t))})]}),jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-28 rounded-md"})})]})]})}function ResellerBillingOverviewData({reseller:e,actions:t}){const n=p=>p===void 0?"$0.00":new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2,maximumFractionDigits:2}).format(p),o=e.Statement||{},l=[{title:"0 - 30 Days",amount:o.Over0||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"31 - 45 Days",amount:o.Over30||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"45+ Days",amount:o.Over45||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"}],u=[{title:"Total",amount:o.Total||0,icon:jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-white"}),color:"bg-green-500"},{title:"Credit Limit",amount:e.CreditLimit||0,icon:jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:l.map((p,d)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:p.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${p.color}`,children:p.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:n(p.amount)})})]},d))}),jsxRuntime.jsx("div",{className:"space-y-4",children:u.map((p,d)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:p.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${p.color}`,children:p.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:n(p.amount)})})]},d))})]}),t&&jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:t})]})]})}function ResellerQualificationsCard({qualifications:e=[],loading:t=!1}){return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{className:"p-6",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 gap-y-8",children:Array.from({length:10}).map((n,o)=>jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]},o))})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{className:"p-6",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 gap-y-8",children:e.map((n,o)=>jsxRuntime.jsx(ManufacturerLogo,{manufacturerId:n.ManufacturerId,opportunityNumber:n.DefaultOpportunityNumber},`${n.ManufacturerId}-${o}`))})})]})}function ManufacturerLogo({manufacturerId:e,opportunityNumber:t}){const[n,o]=React.useState(null),[l,u]=React.useState(!0),[p,d]=React.useState(!1),[f,m]=React.useState(null),g=React.useMemo(()=>e?{logoUrl:`https://api.randmar.io/V4/Partner/${e}/Account/Logo?width=96&height=48`,logoExistsUrl:`https://api.randmar.io/V4/Partner/${e}/Account/Logo/Exists`}:null,[e]);return React.useEffect(()=>{if(!g)return;let b=!0;m(null);const _=async()=>{try{const C=await fetch(g.logoExistsUrl);if(C.ok){const I=(await C.text()).toLowerCase()==="true";return b&&d(I),I}return!1}catch(C){return console.error("Failed to check if logo exists:",C),b&&d(!1),!1}},S=async()=>{b&&u(!0);try{const C=await fetch(g.logoUrl);if(C.ok){const R=await C.blob();b&&(n&&URL.revokeObjectURL(n),o(URL.createObjectURL(R)))}else throw new Error(`Failed to load logo: ${C.status}`)}catch(C){console.error("Failed to load logo:",C),b&&m("Failed to load manufacturer logo")}finally{b&&u(!1)}};return(async()=>{await _()?S():u(!1)})(),()=>{b=!1,n&&URL.revokeObjectURL(n)}},[g]),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx("div",{className:"h-12 flex items-center justify-center mb-2",children:l?jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md"}):p&&n?jsxRuntime.jsx("img",{src:n,alt:"Manufacturer logo",className:"max-h-12 max-w-24 object-contain",onError:()=>m("Failed to load logo")}):jsxRuntime.jsx("div",{className:"h-12 w-24 flex items-center justify-center bg-slate-100 rounded-md text-xs text-slate-500",children:e?e.substring(0,8):"No ID"})}),t&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs",children:t}),f&&jsxRuntime.jsx("div",{className:"text-red-500 text-xs mt-1",role:"alert",children:f})]})}function SalesOverviewCard({salesData:e,salesStatistics:t=[],loading:n=!1}){return n||!e?jsxRuntime.jsx(SalesOverviewSkeleton,{}):jsxRuntime.jsx(SalesOverviewData,{salesData:e,salesStatistics:t})}function SalesOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg sm:text-xl",children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})})}),jsxRuntime.jsxs(CardContent,{className:"pt-4 px-3 sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Array(3).fill(0).map((e,t)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},t))}),jsxRuntime.jsx("div",{className:"mt-6",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-[250px] w-full rounded-lg"})]})})]})]})}function SalesOverviewData({salesData:e,salesStatistics:t=[]}){const n=u=>new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2,maximumFractionDigits:2}).format(u),o=[{title:"Last 30 days",amount:e.SalesLast30Days||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"},{title:"Last 3 months",amount:e.SalesLast3Months||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-amber-500"},{title:"Year to date",amount:e.SalesYearToDay||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-emerald-500"}],l=React.useMemo(()=>{const u=new Map;return t.forEach(p=>{var f;const d=((f=p.Day)==null?void 0:f.toString())||"";if(d.length===8){const m=parseInt(d.substring(0,4),10),g=parseInt(d.substring(4,6),10)-1,b=parseInt(d.substring(6,8),10),_=new Date(m,g,b),S=new Date(_),E=_.getDay();S.setDate(_.getDate()-E);const C=`${S.getFullYear()}-${String(S.getMonth()+1).padStart(2,"0")}-${String(S.getDate()).padStart(2,"0")}`,R=p.ExtendedPrice||0;u.has(C)?u.set(C,u.get(C)+R):u.set(C,R)}}),Array.from(u).sort(([p],[d])=>p.localeCompare(d)).map(([p,d])=>({date:`${p.substring(5,7)}/${p.substring(8,10)}`,amount:d}))},[t]);return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg sm:text-xl",children:"Sales Overview"})}),jsxRuntime.jsxs(CardContent,{className:"pt-4 px-3 sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:o.map((u,p)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:u.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${u.color}`,children:u.icon})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:n(u.amount)})]})]},p))}),jsxRuntime.jsx("div",{className:"mt-6",children:t&&t.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-4",children:"Sales Trend"}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsx(AreaChart,{data:l,units:"$",unitsPosition:"left",height:200})})]})})]})]})}exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.ApiKeyProvider=ApiKeyProvider,exports.AreaChart=AreaChart,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.CountryFlag=CountryFlag,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.Navbar=Navbar,exports.PartnerCard=PartnerCard,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.Topbar=Topbar,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useApiKey=useApiKey,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.153.0",
4
+ "version": "1.154.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [