AdditionalSection-oqynIyS4.js 39 KB

1
  1. import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{A as t,E as n,T as r}from"./client-CI_mRuxq.js";import{a as i,i as a}from"./info-BNmQbMxB.js";import{n as o}from"./ToastContext-HhLLmSZv.js";import{t as s}from"./clock-uIAVFPqu.js";import{t as c}from"./cloud-off-CXDF7UVb.js";import{t as l}from"./cloud-BAIfDgUC.js";import{t as u}from"./loader-circle-DUxlVQ2M.js";import{t as d}from"./scale-2x1uMllI.js";import{t as f}from"./search-O3kvZEQc.js";import{t as p}from"./sparkles-CO1li--h.js";import{t as m}from"./x-BXE5NeAR.js";import{y as h}from"./date-G9KUauqz.js";import{a as g}from"./colors-D_-ITfUn.js";import{t as _}from"./NumberInput-Ch9lKbOs.js";import{n as v,t as y}from"./filamentSwatchHelpers-C3r5m07g.js";import{t as b}from"./FilamentSwatch-AN4JnOMA.js";import{_ as x,u as S,x as C,y as w}from"./utils-CmAEpDlt.js";var T={material:``,subtype:``,brand:``,color_name:``,rgba:`808080FF`,extra_colors:``,effect_type:``,label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:``,note:``,cost_per_kg:null,category:``,low_stock_threshold_pct:null,material_number:``,location_id:null,last_dried_at:``,spoolman_filament_id:null},E=new Set([`material`,`subtype`,`brand`,`rgba`,`color_name`,`label_weight`]);function D(e,t=!1,n=!1,r=`create`){let i={};return t||n||r!==`create`?(!e.material&&!e.spoolman_filament_id&&(i.material=`Material is required`),{isValid:Object.keys(i).length===0,errors:i}):(e.slicer_filament||(i.slicer_filament=`Slicer preset is required`),e.material||(i.material=`Material is required`),e.brand||(i.brand=`Brand is required`),e.subtype||(i.subtype=`Subtype is required`),{isValid:Object.keys(i).length===0,errors:i})}var O=e(t(),1),k=r(),A={local:`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400`,orca_cloud:`bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-400`,cloud:`bg-bambu-blue/20 text-bambu-blue`,builtin:`bg-amber-100 dark:bg-amber-500/20 text-amber-700 dark:text-amber-400`};function j({source:e}){let{t}=n(),r={local:t(`profiles.localProfiles.badge`),orca_cloud:t(`configureAmsSlot.orcaCloud`),cloud:t(`configureAmsSlot.bambuCloud`),builtin:t(`configureAmsSlot.builtin`)}[e];return(0,k.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded whitespace-nowrap ${A[e]}`,children:r})}function M({value:e,options:t,inheritLabel:r,onChange:a,disabled:o=!1,ariaLabel:s}){let{t:c}=n(),[l,u]=(0,O.useState)(!1),[d,p]=(0,O.useState)(``),h=(0,O.useRef)(null),g=t.find(t=>t.code===e);(0,O.useEffect)(()=>{if(!l)return;let e=e=>{h.current&&!h.current.contains(e.target)&&u(!1)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),u(!1))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t,!0)}},[l]);let _=d.trim().toLowerCase(),v=_?t.filter(e=>e.displayName.toLowerCase().includes(_)):t,y=e=>{a(e),u(!1),p(``)};return(0,k.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,k.jsxs)(`button`,{type:`button`,"aria-label":s,"aria-haspopup":`listbox`,"aria-expanded":l,disabled:o,onClick:()=>u(e=>!e),className:`w-full flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-left focus:outline-none focus:border-bambu-green disabled:opacity-50`,children:[(0,k.jsx)(`span`,{className:`flex-1 min-w-0 truncate ${g?`text-white`:`text-bambu-gray italic`}`,children:g?g.displayName:r}),g&&(0,k.jsx)(j,{source:g.source}),(0,k.jsx)(i,{className:`w-3.5 h-3.5 text-bambu-gray shrink-0`})]}),l&&(0,k.jsxs)(`div`,{className:`absolute z-50 mt-1 w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl`,children:[(0,k.jsx)(`div`,{className:`p-2 border-b border-bambu-dark-tertiary`,children:(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(f,{className:`w-3.5 h-3.5 text-bambu-gray absolute left-2 top-1/2 -translate-y-1/2`}),(0,k.jsx)(`input`,{autoFocus:!0,type:`text`,value:d,onChange:e=>p(e.target.value),placeholder:c(`inventory.searchPresets`),className:`w-full pl-7 pr-7 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-md text-sm text-white placeholder:text-bambu-gray/60 focus:outline-none focus:border-bambu-green`}),d&&(0,k.jsx)(`button`,{type:`button`,"aria-label":c(`common.clear`),onClick:()=>p(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,k.jsx)(m,{className:`w-3.5 h-3.5`})})]})}),(0,k.jsxs)(`div`,{className:`max-h-56 overflow-y-auto p-1`,role:`listbox`,"aria-label":s,children:[(0,k.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":!g,onClick:()=>y(null),className:`w-full text-left px-2 py-1.5 rounded-md text-sm italic ${g?`text-bambu-gray hover:bg-bambu-dark`:`bg-bambu-green/15 text-bambu-green`}`,children:r}),v.length===0?(0,k.jsx)(`p`,{className:`px-2 py-2 text-sm text-bambu-gray`,children:c(`inventory.noResults`)}):v.map(t=>(0,k.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t.code===e,onClick:()=>y(t),className:`w-full flex items-center gap-2 text-left px-2 py-1.5 rounded-md text-sm ${t.code===e?`bg-bambu-green/15 text-bambu-green`:`text-white hover:bg-bambu-dark`}`,children:[(0,k.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,title:t.displayName,children:t.displayName}),(0,k.jsx)(j,{source:t.source})]},t.code))]})]})]})}function N(e,t){if(t.length===0)return{top:[],rest:e};let n=new Set(t.map(e=>e.toLowerCase()));return{top:e.filter(e=>n.has(e.toLowerCase())),rest:e.filter(e=>!n.has(e.toLowerCase()))}}function P({label:e}){return(0,k.jsx)(`div`,{className:`px-3 py-1 text-[11px] font-semibold uppercase tracking-wide text-bambu-gray/70 bg-bambu-dark-tertiary/40`,children:e})}function F({formData:e,updateField:t,cloudAuthenticated:r,loadingCloudPresets:a,presetInputValue:o,setPresetInputValue:s,selectedPresetOption:d,filamentOptions:p,availableBrands:h,availableMaterials:g,suggestedBrands:v,suggestedMaterials:y,quickAdd:b,detailsRequired:x,quantity:C,onQuantityChange:T,errors:E}){let{t:D}=n(),[A,M]=(0,O.useState)(!1),[F,I]=(0,O.useState)(``),[L,R]=(0,O.useState)(!1),[z,B]=(0,O.useState)(!1),[V,H]=(0,O.useState)(!1),[U,W]=(0,O.useState)(``),[G,K]=(0,O.useState)(``),[q,J]=(0,O.useState)(``),[ee,Y]=(0,O.useState)(String(e.label_weight)),[te,ne]=(0,O.useState)(!1),[re,ie]=(0,O.useState)(new Set),ae=(0,O.useRef)(null),oe=(0,O.useRef)(null),se=(0,O.useRef)(null),ce=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=e=>{ae.current&&!ae.current.contains(e.target)&&M(!1),ce.current&&!ce.current.contains(e.target)&&H(!1),oe.current&&!oe.current.contains(e.target)&&R(!1),se.current&&!se.current.contains(e.target)&&B(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let le=(0,O.useMemo)(()=>{if(!F)return p;let e=F.toLowerCase();return p.filter(t=>t.displayName.toLowerCase().includes(e)||t.code.toLowerCase().includes(e))},[p,F]),X=(0,O.useMemo)(()=>{if(!U)return h;let e=U.toLowerCase();return h.filter(t=>t.toLowerCase().includes(e)).sort((t,n)=>{let r=t.toLowerCase()===e,i=n.toLowerCase()===e;return r&&!i?-1:!r&&i?1:t.localeCompare(n)})},[h,U]),ue=(0,O.useMemo)(()=>{if(!G)return w;let e=G.toLowerCase();return w.filter(t=>t.toLowerCase().includes(e))},[G]),de=(0,O.useMemo)(()=>{if(!q)return g;let e=q.toLowerCase();return g.filter(t=>t.toLowerCase().includes(e)).sort((t,n)=>{let r=t.toLowerCase()===e,i=n.toLowerCase()===e;return r&&!i?-1:!r&&i?1:t.localeCompare(n)})},[q,g]),Z=(0,O.useMemo)(()=>N(X,v),[X,v]),Q=(0,O.useMemo)(()=>N(de,y),[de,y]);(0,O.useEffect)(()=>{te||Y(String(e.label_weight))},[e.label_weight,te]);let fe=n=>{t(`slicer_filament`,n.code),s(n.displayName),M(!1),I(``);let r=S(n.name),i=new Set,a=[[`material`,r.material],[`brand`,r.brand],[`subtype`,r.variant]];for(let[n,r]of a)r&&(e[n]&&!re.has(n)||(t(n,r),i.add(n)));ie(i)},$=(e,n)=>{re.has(e)&&ie(t=>{let n=new Set(t);return n.delete(e),n}),t(e,n)},pe=t=>(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.brand===t?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{$(`brand`,t),R(!1),W(``)},children:t},t),me=t=>(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.material===t?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{$(`material`,t),H(!1),J(``)},children:t},t);return(0,k.jsxs)(`div`,{className:`space-y-4`,children:[!b&&(0,k.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray`,children:a?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(u,{className:`w-3 h-3 animate-spin`}),` `,D(`inventory.loadingPresets`)]}):r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(l,{className:`w-3 h-3 text-bambu-green`}),` `,D(`inventory.cloudConnected`)]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(c,{className:`w-3 h-3`}),` `,D(`inventory.cloudNotConnected`)]})}),!b&&(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[D(`inventory.slicerPreset`),x&&` *`]}),(0,k.jsxs)(`div`,{className:`relative`,ref:ae,children:[(0,k.jsx)(f,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),(0,k.jsx)(`input`,{type:`text`,className:`w-full pl-9 ${e.slicer_filament?`pr-9`:`pr-3`} py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:D(`inventory.searchPresets`),value:A?F:o,onChange:e=>{I(e.target.value),M(!0)},onFocus:()=>{M(!0),I(``)}}),e.slicer_filament&&(0,k.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-bambu-gray hover:text-white`,title:D(`inventory.clearPreset`),"aria-label":D(`inventory.clearPreset`),onClick:()=>{t(`slicer_filament`,``),s(``),I(``),M(!1)},children:(0,k.jsx)(m,{className:`w-4 h-4`})}),A&&(0,k.jsx)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto`,children:le.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:D(`inventory.noPresetsFound`)}):le.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2 ${d?.code===e.code?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>fe(e),children:[(0,k.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,title:e.displayName,children:e.displayName}),(0,k.jsx)(j,{source:e.source})]},`${e.code}::${e.name}`))})]}),d&&(0,k.jsxs)(`div`,{className:`mt-1 text-xs text-bambu-gray`,children:[D(`inventory.selectedPreset`),`: `,(0,k.jsx)(`span`,{className:`font-mono text-bambu-green`,children:d.code})]}),E?.slicer_filament&&(0,k.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:E.slicer_filament})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[D(`inventory.material`),` *`]}),(0,k.jsxs)(`div`,{className:`relative`,ref:ce,children:[(0,k.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:D(`inventory.selectMaterial`),value:V?q:e.material,onChange:e=>{J(e.target.value),H(!0)},onFocus:()=>{H(!0),J(``)}}),(0,k.jsx)(i,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),V&&(0,k.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[de.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:D(`inventory.noResults`)}):(0,k.jsxs)(k.Fragment,{children:[Q.top.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(P,{label:D(`inventory.suggestedOptions`)}),Q.top.map(me)]}),Q.rest.length>0&&(0,k.jsxs)(k.Fragment,{children:[Q.top.length>0&&(0,k.jsx)(P,{label:D(`inventory.allOptions`)}),Q.rest.map(me)]})]}),q&&!de.includes(q)&&(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{$(`material`,q),H(!1),J(``)},children:D(`inventory.useCustomMaterial`,{material:q})})]})]}),E?.material&&(0,k.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:E.material})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[D(`inventory.brand`),x&&` *`]}),(0,k.jsxs)(`div`,{className:`relative`,ref:oe,children:[(0,k.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:D(`inventory.searchBrand`),value:L?U:e.brand,onChange:e=>{W(e.target.value),R(!0)},onFocus:()=>{R(!0),W(``)}}),(0,k.jsx)(i,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),L&&(0,k.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[X.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:D(`inventory.noResults`)}):(0,k.jsxs)(k.Fragment,{children:[Z.top.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(P,{label:D(`inventory.suggestedOptions`)}),Z.top.map(pe)]}),Z.rest.length>0&&(0,k.jsxs)(k.Fragment,{children:[Z.top.length>0&&(0,k.jsx)(P,{label:D(`inventory.allOptions`)}),Z.rest.map(pe)]})]}),U&&!X.includes(U)&&(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{$(`brand`,U),R(!1),W(``)},children:D(`inventory.useCustomBrand`,{brand:U})})]})]}),E?.brand&&(0,k.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:E.brand})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[D(`inventory.subtype`),x&&` *`]}),(0,k.jsxs)(`div`,{className:`relative`,ref:se,children:[(0,k.jsx)(`input`,{type:`text`,value:z?G:e.subtype,onChange:e=>{K(e.target.value),B(!0)},onFocus:()=>{B(!0),K(``)},placeholder:`Basic, Matte, Silk...`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`}),(0,k.jsx)(i,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),z&&(0,k.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[ue.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:D(`inventory.noResults`)}):ue.map(t=>(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.subtype===t?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{$(`subtype`,t),B(!1),K(``)},children:t},t)),G&&!w.some(e=>e.toLowerCase()===G.toLowerCase().trim())&&(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{$(`subtype`,G),B(!1),K(``)},children:D(`inventory.useCustomBrand`,{brand:G})})]})]}),E?.subtype&&(0,k.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:E.subtype})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:D(`inventory.labelWeight`)}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(`input`,{type:`number`,className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:ee,min:0,onFocus:()=>ne(!0),onChange:e=>Y(e.target.value),onBlur:()=>{ne(!1);let n=ee.trim(),r=Number(n);if(!n||!Number.isFinite(r)||r<0){Y(String(e.label_weight));return}let i=Math.round(r);t(`label_weight`,i),Y(String(i))}}),(0,k.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]})]}),b&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:D(`inventory.quantity`)}),(0,k.jsx)(_,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:C,min:1,max:100,onChange:T,fallback:1})]})]})}function I(e){let t=e.split(/[\s,]+/).map(e=>e.trim().replace(/^#/,``)).filter(Boolean),n=[],r=[];for(let e of t)(e.length===6||e.length===8)&&/^[0-9a-fA-F]+$/.test(e)?n.push(e.toLowerCase()):r.push(e);return{value:n.join(`,`),invalid:r}}function L({formData:e,updateField:t,recentColors:r,onColorUsed:o,catalogColors:c}){let{t:l}=n(),[u,d]=(0,O.useState)(!1),[m,h]=(0,O.useState)(``),_=(e.rgba.replace(`#`,``)+`FF`).substring(0,8).toUpperCase(),S=_.substring(0,6),w=_.substring(6,8)===`00`,[T,E]=(0,O.useState)(w?_:S);(0,O.useEffect)(()=>{E(w?_:S)},[S,_,w]);let D=e=>{let t=(e.replace(`#`,``)+`FF`).substring(0,8).toUpperCase();return _===t},A=e=>g(e),j=(e,n,r,i)=>{let a=e.replace(`#`,``).toUpperCase();if(t(`rgba`,a.length===8?a:a+`FF`),t(`color_name`,n),r!==void 0){let e=r??``;R(e),B([]),V.current=e,t(`extra_colors`,e)}i!==void 0&&t(`effect_type`,i??``),o({name:n,hex:e})},M=(0,O.useMemo)(()=>{if(c.length===0)return[];let t=e.brand?.trim(),n=e.material?.toLowerCase().trim(),r=e.subtype?.toLowerCase().trim();if(!t&&!n)return[];let i=t?t.toLowerCase().split(/[\s\-_]+/).filter(e=>e.length>=2):[],a=e=>{if(i.length===0)return!0;let t=e.toLowerCase();return i.some(e=>t.includes(e))};if(t&&!n){let e=c.filter(e=>a(e.manufacturer));if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}))}let o=n&&r?`${n} ${r}`:``;if(o){let e=c.filter(e=>a(e.manufacturer)&&e.material?.toLowerCase()===o);if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}));let t=o.replace(/\+$/,``);if(t!==o){let e=c.filter(e=>a(e.manufacturer)&&e.material?.toLowerCase()===t);if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0}))}}if(n){let e=c.filter(e=>a(e.manufacturer)&&(!e.material||e.material.toLowerCase().startsWith(n)));if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}))}return[]},[c,e.brand,e.material,e.subtype]),N=(0,O.useMemo)(()=>{if(!m)return M;if(M.length===0)return[];let e=m.toLowerCase();return M.filter(t=>t.name.toLowerCase().includes(e)||(t.manufacturer?.toLowerCase().includes(e)??!1)||(t.material?.toLowerCase().includes(e)??!1))},[m,M]),P=M.length>0,F=(0,O.useMemo)(()=>m?x.filter(e=>e.name.toLowerCase().includes(m.toLowerCase())):u?x:C,[m,u]),[L,R]=(0,O.useState)(e.extra_colors),[z,B]=(0,O.useState)([]),V=(0,O.useRef)(e.extra_colors);(0,O.useEffect)(()=>{e.extra_colors!==V.current&&(R(e.extra_colors),B([]),V.current=e.extra_colors)},[e.extra_colors]);let H=(0,O.useMemo)(()=>v({rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,subtype:e.subtype,effectSize:`bar`}),[e.rgba,e.extra_colors,e.effect_type,e.subtype]),U=e=>{if(R(e),!e.trim()){B([]),V.current=``,t(`extra_colors`,``);return}let{value:n,invalid:r}=I(e);B(r),V.current=n,t(`extra_colors`,n)};return(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsx)(`div`,{className:`h-10 rounded-lg border border-bambu-dark-tertiary`,style:H,"data-testid":`color-preview-banner`}),r.length>0&&(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-bambu-gray shrink-0`,children:[(0,k.jsx)(s,{className:`w-3 h-3`}),(0,k.jsx)(`span`,{children:l(`inventory.recentColors`)})]}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>j(e.hex,e.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${D(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:A(e.hex),title:e.name},e.hex))})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(f,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),(0,k.jsx)(`input`,{type:`text`,className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:l(`inventory.searchColors`),value:m,onChange:e=>h(e.target.value)})]}),P?(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:m?l(`inventory.searchResults`):`${e.brand}${e.material?` ${e.material}`:``}`}),(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[N.map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>j(e.hex,e.name,e.extra_colors,e.effect_type),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${D(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:A(e.hex),title:e.manufacturer&&e.material?`${e.name} (${e.manufacturer} — ${e.material})`:e.manufacturer?`${e.name} (${e.manufacturer})`:e.name,children:(0,k.jsx)(`span`,{className:`absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white`,children:e.manufacturer&&e.material?`${e.name} (${e.manufacturer} — ${e.material})`:e.manufacturer?`${e.name} (${e.manufacturer})`:e.name})},`${e.hex}-${e.name}-${e.manufacturer??``}`)),N.length===0&&(0,k.jsx)(`p`,{className:`text-sm text-bambu-gray py-1`,children:l(`inventory.noColorsFound`)})]})]}):(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-bambu-gray`,children:[(0,k.jsx)(`span`,{children:l(m?`inventory.searchResults`:u?`inventory.allColors`:`inventory.commonColors`)}),!m&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>d(!u),className:`flex items-center gap-1 hover:text-white transition-colors`,children:u?(0,k.jsxs)(k.Fragment,{children:[l(`inventory.showLess`),` `,(0,k.jsx)(a,{className:`w-3 h-3`})]}):(0,k.jsxs)(k.Fragment,{children:[l(`inventory.showAll`),` `,(0,k.jsx)(i,{className:`w-3 h-3`})]})})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[F.map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>j(e.hex,e.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${D(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:A(e.hex),title:e.name,children:(0,k.jsx)(`span`,{className:`absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white`,children:e.name})},e.hex)),F.length===0&&(0,k.jsx)(`p`,{className:`text-sm text-bambu-gray py-1`,children:l(`inventory.noColorsFound`)})]})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.colorName`)}),(0,k.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:l(`inventory.colorNamePlaceholder`),value:e.color_name,onChange:e=>t(`color_name`,e.target.value)})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.hexColor`)}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray`,children:`#`}),(0,k.jsx)(`input`,{type:`text`,className:`w-full pl-7 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono uppercase focus:outline-none focus:border-bambu-green`,placeholder:`RRGGBB`,value:T.toUpperCase(),onChange:e=>{let n=e.target.value.replace(`#`,``).replace(/[^0-9A-Fa-f]/g,``).toUpperCase(),r=n.length>8?n.substring(0,8):n;E(r),r.length===6?t(`rgba`,r+`FF`):r.length===8&&t(`rgba`,r)},onBlur:()=>{if(T.length===7){let e=T+`0`;E(e),t(`rgba`,e)}else if(T.length>0&&T.length<6){let e=T.padEnd(6,`0`);E(e),t(`rgba`,e+`FF`)}}})]}),(0,k.jsx)(`input`,{type:`color`,className:`w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent`,value:`#${S}`,onChange:e=>{t(`rgba`,e.target.value.replace(`#`,``).toUpperCase()+`FF`)},title:l(`inventory.pickColor`)})]})]})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-2 border-t border-bambu-dark-tertiary/50`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.extraColorsLabel`)}),(0,k.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:l(`inventory.extraColorsPlaceholder`),value:L,onChange:e=>U(e.target.value),"data-testid":`extra-colors-input`}),z.length>0&&(0,k.jsx)(`p`,{className:`text-xs text-red-700 dark:text-red-400 mt-1`,children:l(`inventory.extraColorsInvalid`,{tokens:z.join(`, `)})}),!z.length&&(0,k.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:l(`inventory.extraColorsHint`)})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1 flex items-center gap-1.5`,children:[(0,k.jsx)(p,{className:`w-3.5 h-3.5`}),l(`inventory.colorEffectLabel`)]}),(0,k.jsxs)(`div`,{className:`flex gap-2 items-stretch`,children:[(0,k.jsx)(`select`,{className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:e.effect_type,onChange:e=>t(`effect_type`,e.target.value),"data-testid":`effect-type-select`,children:y.map(e=>(0,k.jsx)(`option`,{value:e.value,children:l(e.labelKey)},e.value||`none`))}),(0,k.jsx)(b,{rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,subtype:e.subtype,effectSize:`preview`,className:`w-10 h-10`,shape:`square`})]})]})]})]})}function R({catalog:e,value:t,onChange:r,catalogId:i,onCatalogIdChange:a}){let{t:o}=n(),[s,c]=(0,O.useState)(!1),[l,u]=(0,O.useState)(``),f=(0,O.useRef)(null),p=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,O.useEffect)(()=>{if(e.length===0)return;let n=e.filter(e=>e.weight===t);if(i){let n=e.find(e=>e.id===i);if(n&&n.weight===t)return}n.length===1?a(n[0].id):n.length===0&&i!==null&&a(null)},[t,e,i,a]);let m=(0,O.useMemo)(()=>{if(!l)return e;let t=l.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.weight.toString().includes(t))},[e,l]),h=(0,O.useMemo)(()=>e.filter(e=>e.weight===t),[e,t]),g=(0,O.useMemo)(()=>{if(s)return l;if(i){let t=e.find(e=>e.id===i);if(t)return t.name}return h.length>0?h[0].name:``},[s,l,i,e,h]);return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:(0,k.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(d,{className:`w-3.5 h-3.5 text-bambu-gray`}),o(`inventory.coreWeight`)]})}),(0,k.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,k.jsxs)(`div`,{className:`flex-1 min-w-0 relative`,ref:f,children:[(0,k.jsx)(`input`,{ref:p,type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:o(`inventory.searchSpoolWeight`),value:g,onFocus:()=>{c(!0),u(``)},onChange:e=>{u(e.target.value),c(!0)}}),s&&(0,k.jsx)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto`,children:m.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:o(`inventory.noResults`)}):m.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${(i?e.id===i:e.weight===t)?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{a(e.id),r(e.weight),c(!1),u(``)},children:[(0,k.jsx)(`span`,{className:`truncate`,children:e.name}),(0,k.jsxs)(`span`,{className:`font-mono text-xs text-bambu-gray ml-2 shrink-0`,children:[e.weight,`g`]})]},e.id))})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,k.jsx)(`input`,{type:`number`,className:`w-16 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm text-center font-mono focus:outline-none focus:border-bambu-green`,value:t,min:0,max:2e3,onChange:e=>{let t=parseInt(e.target.value);!isNaN(t)&&t>=0&&r(t)}}),(0,k.jsx)(`span`,{className:`text-bambu-gray text-sm`,children:`g`})]})]})]})}function z({formData:e,updateField:t,spoolCatalog:r,currencySymbol:i,availableCategories:a,availableMaterialNumbers:s,availableLocations:c=[],onCreateLocation:l,globalLowStockThreshold:u,spoolmanMode:d=!1,showLastDried:f=!1}){let{t:p}=n(),{showToast:m}=o(),[g,_]=(0,O.useState)(``),[v,y]=(0,O.useState)(!1),[b,x]=(0,O.useState)(``),[S,C]=(0,O.useState)(!1),[w,T]=(0,O.useState)(``),[E,D]=(0,O.useState)(!1),A=Math.max(0,e.label_weight-e.weight_used),j=e.core_weight+A;return(0,O.useEffect)(()=>{v||_(String(j))},[v,j]),(0,O.useEffect)(()=>{S||x(String(A))},[S,A]),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-4`,children:[(0,k.jsx)(`div`,{className:`sm:col-span-2`,children:(0,k.jsx)(R,{catalog:r,value:e.core_weight,onChange:e=>t(`core_weight`,e),catalogId:e.core_weight_catalog_id,onCatalogIdChange:e=>t(`core_weight_catalog_id`,e)})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:p(`inventory.currentWeight`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(`input`,{type:`number`,value:b,min:0,max:e.label_weight,onFocus:()=>C(!0),onChange:e=>{x(e.target.value)},onBlur:()=>{C(!1);let n=b.trim(),r=Number(n);if(!n||!Number.isFinite(r)||r<0||r>e.label_weight){x(String(A));return}let i=Math.round(r);t(`weight_used`,Math.max(0,e.label_weight-i)),x(String(i))},className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,k.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]}),(0,k.jsxs)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:[`/ `,e.label_weight,`g`]})]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:p(`inventory.measuredWeight`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(`input`,{type:`number`,value:g,min:0,onFocus:()=>y(!0),onChange:e=>{_(e.target.value)},onBlur:()=>{y(!1);let n=g.trim(),r=Number(n),i=e.core_weight,a=e.core_weight+e.label_weight;if(!n||!Number.isFinite(r)||r<i||r>a){m(p(`inventory.measuredWeightError`,{min:i,max:a}),`error`),_(String(j));return}let o=Math.round(r),s=Math.max(0,Math.min(e.label_weight,o-e.core_weight));t(`weight_used`,Math.max(0,e.label_weight-s)),_(String(o))},className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,k.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]}),(0,k.jsxs)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:[`/ `,e.core_weight+e.label_weight,`g`]})]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:p(`inventory.costPerKg`,`Cost per kg`)}),(0,k.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:i}),(0,k.jsx)(`input`,{type:`number`,value:e.cost_per_kg??``,min:0,step:.01,placeholder:`0.00`,onChange:e=>{t(`cost_per_kg`,e.target.value===``?null:parseFloat(e.target.value))},style:{paddingLeft:`${Math.max(2,i.length*.6+1)}rem`},className:`w-full py-2 pr-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`})]})})]}),!d&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-material-number`,children:p(`inventory.materialNumber`)}),(0,k.jsx)(`input`,{id:`spool-material-number`,type:`text`,list:`spool-material-number-options`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:p(`inventory.materialNumberPlaceholder`),value:e.material_number,maxLength:64,onChange:e=>t(`material_number`,e.target.value)}),s.length>0&&(0,k.jsx)(`datalist`,{id:`spool-material-number-options`,children:s.map(e=>(0,k.jsx)(`option`,{value:e},e))}),(0,k.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:p(`inventory.materialNumberHelp`)})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-category`,children:p(`inventory.category`)}),(0,k.jsx)(`input`,{id:`spool-category`,type:`text`,list:`spool-category-options`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:p(`inventory.categoryPlaceholder`),value:e.category,maxLength:50,onChange:e=>t(`category`,e.target.value)}),a.length>0&&(0,k.jsx)(`datalist`,{id:`spool-category-options`,children:a.map(e=>(0,k.jsx)(`option`,{value:e},e))})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-low-stock-threshold`,children:p(`inventory.lowStockThresholdOverride`)}),(0,k.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(`input`,{id:`spool-low-stock-threshold`,type:`number`,className:`w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:String(u),value:e.low_stock_threshold_pct??``,min:1,max:99,step:1,onChange:e=>{let n=e.target.value;if(n===``){t(`low_stock_threshold_pct`,null);return}let r=Number(n);Number.isFinite(r)&&t(`low_stock_threshold_pct`,Math.min(99,Math.max(1,Math.round(r))))}}),(0,k.jsx)(`span`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-bambu-gray pointer-events-none`,children:`%`})]})}),(0,k.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:p(`inventory.lowStockThresholdOverrideHelp`,{global:u})})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-storage-location`,children:p(`inventory.storageLocation`)}),(0,k.jsxs)(`select`,{id:`spool-storage-location`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:e.location_id??``,onChange:e=>{let n=e.target.value;if(!n){t(`location_id`,null);return}t(`location_id`,Number(n))},children:[(0,k.jsx)(`option`,{value:``,children:p(`inventory.storageLocationNone`)}),c.map(e=>(0,k.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),l&&(0,k.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,k.jsx)(`input`,{type:`text`,maxLength:255,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:p(`locations.createPlaceholder`),value:w,onChange:e=>T(e.target.value)}),(0,k.jsx)(`button`,{type:`button`,className:`px-3 py-2 text-sm rounded-lg bg-bambu-dark-tertiary text-white hover:bg-bambu-gray-dark disabled:opacity-50`,disabled:!w.trim()||E,onClick:async()=>{let e=w.trim();if(!(!e||!l)){D(!0);try{let n=await l(e);n&&(t(`location_id`,n.id),T(``))}finally{D(!1)}}},children:p(`locations.addShort`)})]})]}),f&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-last-dried`,children:p(`inventory.lastDried`)}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{id:`spool-last-dried`,type:`datetime-local`,className:`flex-1 min-w-0 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:e.last_dried_at,onChange:e=>t(`last_dried_at`,e.target.value)}),(0,k.jsx)(`button`,{type:`button`,className:`px-3 py-2 text-sm rounded-lg bg-bambu-dark-tertiary text-white hover:bg-bambu-gray-dark`,onClick:()=>t(`last_dried_at`,h(new Date)),children:p(`inventory.lastDriedNow`)})]}),(0,k.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:p(`inventory.lastDriedHelp`)})]}),(0,k.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:p(`inventory.note`)}),(0,k.jsx)(`textarea`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green resize-none min-h-[80px]`,placeholder:p(`inventory.notePlaceholder`),value:e.note,onChange:e=>t(`note`,e.target.value)})]})]})}export{E as a,M as i,L as n,T as o,F as r,D as s,z as t};