1var oe=Object.defineProperty,se=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var V=(e,n,t)=>n in e?oe(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,k=(e,n)=>{for(var t in n||(n={}))ce.call(n,t)&&V(e,t,n[t]);if(L)for(var t of L(n))de.call(n,t)&&V(e,t,n[t]);return e},I=(e,n)=>se(e,le(n));var O=(e,n,t)=>new Promise((r,l)=>{var u=i=>{try{c(t.next(i))}catch(o){l(o)}},d=i=>{try{c(t.throw(i))}catch(o){l(o)}},c=i=>i.done?r(i.value):Promise.resolve(i.value).then(u,d);c((t=t.apply(e,n)).next())});import{j as a,P as w,i as B,C as G,I as D,b as ue,Y as me,M as P,N as z,x as pe,J as ye,ao as fe,B as ge}from"./npm.sellpy-design-system.sUaPRvy7.bundle.js";import{r as g,b as R,u as S,C as $}from"./npm.react-hook-form.C-gy3V91.bundle.js";import{J,co as _,cp as U,cq as xe,cr as K,cs as he,ct as Y,cu as be,cv as X,cw as ve,cx as ke,cy as q,R as C,cz as Z,cA as ee,cB as Ie,cC as W,cD as je,cE as Se,cj as Te,b as Ce}from"./index.OKbXaoKY.bundle.js";import{h as ne}from"./npm.apollo-client.D2roezfX.bundle.js";import{u as N}from"./npm.react-i18next.DBIOEc1H.bundle.js";import{bc as te,bd as Ne,b6 as Ee}from"./npm.sellpy-commons.CqmbWWp3.bundle.js";import{g as A,s as ae}from"./npm.styled-components.CXmCnM24.bundle.js";import"./npm.lodash.B-mb_ip_.bundle.js";import{f as Fe}from"./helpers.GrCBTlqa.bundle.js";try{let e=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:{},n=new e.Error().stack;
1n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="925e6aa7-304c-4e16-9e2b-7aff35d84818",e._sentryDebugIdIdentifier="sentry-dbid-925e6aa7-304c-4e16-9e2b-7aff35d84818")}catch(e){}{let e=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=Object.assign({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:sellpy-market":!0})}const re=({label:e,subLabel:n,options:t,disabled:r,name:l,control:u,required:d,searchFunction:c,validate:i,loading:o,noResult:p,defaultValue:m,placeholder:s})=>{const f=g.useRef(),{field:{value:y,onChange:x,onBlur:T},fieldState:{error:h}}=R({name:l,control:u,rules:{required:d,validate:i}}),[b,j]=g.useState(!1),E=g.useRef(null);J(E,()=>{b&&T(),j(!1)});const M=()=>{!r&&j(!b),f.current.focus()};g.useEffect(()=>{o&&j(!0)},[o]);const ie=F=>{c&&(c(F),j(!0))},v=t.find(F=>_(y,F.value));return a.jsxs(U,{ref:E,erroneous:h,disabled:r,expanded:b,children:[a.jsx(w,{noMargin:!0,design:"body3",children:e}),a.jsxs(xe,{design:"body1",noMargin:!0,erroneous:h,disabled:r,onClick:M,expanded:b,children:[a.jsxs(K,{children:[(v==null?void 0:v.icon)&&a.jsx(he,{children:v==null?void 0:v.icon}),a.jsx(Y,{disabled:r,noMargin:!0,type:"text",onBlur:T,defaultValue:m,onChange:F=>ie(F.target.value),design:"body3",isSearchSelector:!0,ref:f,placeholder:s||(v==null?void 0:v.label)||y!==null&&typeof y=="object"&&y[l]||y})]}),a.jsx(be,{expanded:b}),b&&a.jsxs(X,{children:[o&&a.jsx(ve,{}),a.jsx(ke,{options:t,onChange:x,value:y,inputRef:f,noResult:!o&&!t.length&&p})]})]}),a.jsx(q,{errors:{[l]:h},name:l,label:n,disabled:r})]})},we=`query TypeInputField($forType: String!, $locale: String!) { 2 itemIO: fetchItemIOFromType(forType: $forType, locale: $locale) { 3 objectId 4 } 5} 6`,De={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"TypeInputField"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"forType"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"locale"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:{kind:"Name",value:"itemIO"},name:{kind:"Name",value:"fetchItemIOFromType"},arguments:[{kind:"Argument",name:{kind:"Name",value:"forType"},value:{kind:"Variable",name:{kind:"Name",value:"forType"}}},{kind:"Argument",name:{kind:"Name",value:"locale"},value:{kind:"Variable",name:{kind:"Name",value:"locale"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"objectId"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:185,source:{name:"GraphQL request",locationOffset:{line:1,column:1},body:we}}},Me=De,{searchSingleIndex:Oe,getItemTypeIndex:$e}=Z(),bn=()=>{var m;const{t:e}=N(["itemEdit","common"]),{control:n,watch:t}=S(),r=(m=t("type"))==null?void 0:m.type,{data:l}=ne(Me,{variables:{forType:r,locale:C},skip:!r}),u=l==null?void 0:l.itemIO,[d,c]=g.useState([]);g.useEffect(()=>{var s;i((s=t("type"))==null?void 0:s.type)},[t]);const i=s=>O(null,null,function*(){const y=(yield Oe({indexName:$e(C),searchParams:{query:s,hitsPerPage:50}})).hits;c(y.map(x=>({value:{type:x.type,itemTypeId:x.objectID,itemTypeCanonicalName:x.typeId},label:`${x.type} (${x.itemCategoryName})`})))}),o=t("type")&&!d.some(({value:s})=>Be(s,t("type"))),p=!(u!=null&&u.objectId);return a.jsx(re,{label:e("itemEdit:fieldLabel.type"),name:"type",control:n,options:d,searchFunction:i,required:e("common:genericErrors.required"),noResult:e("common:genericErrors.noResult"),validate:()=>{if(o||p)return e("itemEdit:error.itemTypeRequired")}})},Be=(e,n)=>e.itemTypeId===n.itemTypeId,vn=()=>{const{t:e}=N("itemEdit"),{register:n,formState:{errors:t}}=S();return a.jsx(B,I(k({},n("sellerComment",{maxLength:{value:H,message:e("error.tooLongInputText",{maxLength:H})}})),{errors:t,label:e("fieldLabel.sellerComment")}))},H=300,_e=A.div` 7 min-height: 32px; 8 width: 100%; 9 margin: 8px; 10 display: flex; 11 flex-wrap: wrap; 12 gap: 8px; 13 align-items: center; 14`,Re=A.div` 15 text-overflow: ellipsis; 16 position: relative; 17 display: flex; 18 flex-direction: column; 19 & p { 20 color: ${Ie}; 21 } 22 &:focus-within { 23 & p { 24 color: ${W}; 25 } 26 } 27 &:hover { 28 & p { 29 color: ${W}; 30 } 31 } 32 width: 100%; 33`,qe=A(Y)` 34 padding: 0 8px; 35`,Ae=({label:e,subLabel:n,disabled:t,name:r,control:l,required:u,validate:d})=>{const[c,i]=g.useState(""),{field:{value:o=[],onChange:p},fieldState:{error:m}}=R({name:r,control:l,rules:{required:u,validate:d}}),s=g.useRef(),f=g.useCallback(y=>{y.key==="Enter"&&(y.preventDefault(),s.current.blur(),s.current.focus())},[s]);return a.jsxs(Re,{onClick:()=>s.current.focus(),erroneous:m,disabled:t,children:[a.jsx(w,{noMargin:!0,design:"body3",children:e}),a.jsx(ee,{children:a.jsxs(_e,{children:[o==null?void 0:o.map(y=>a.jsx(Le,{type:"button",label:y,onClick:()=>{p(o.filter(x=>x!==y))}}
35,y)),a.jsx("div",{children:a.jsx(qe,{ref:s,type:"text","data-role":"taginput",value:c,disabled:t,onFocus:()=>{window.addEventListener("keydown",f)},onBlur:()=>{Ve(c)&&!o.includes(c)&&p([...o,c]),i(""),window.removeEventListener("keydown",f)},onChange:y=>{i(y.target.value)}})})]})}),a.jsx(q,{errors:{[r]:m},name:r,label:n,disabled:t})]})},Le=({label:e,onClick:n})=>a.jsx(G,{title:e,rightIcon:D.CLOSE,color:"blue",onClick:n,variant:"filled"}),Ve=e=>!!e.split(" ").join(""),Pe={restrictedModel:({name:e,brand:n})=>({value:e,label:`${e}${n?` (${n})`:""}`})},ze=({suggestions:e,name:n})=>{const t=Pe[n];return t?e.map(t):e.map(r=>({value:r[n],label:r[n]}))},{brandIndex:We,searchSingleIndex:He,getItemTypeIndex:Qe,modelIndex:Ge}=Z(),Je=({algoliaIndex:e,name:n,label:t,validate:r,subLabel:l})=>{const{t:u}=N("common"),{control:d,watch:c,setValue:i}=S(),[o,p]=g.useState([]),[m,s]=g.useState(!1),f=m&&c(n)&&!o.some(x=>x.value===c(n));g.useEffect(()=>{f&&i(n,null)},[n,f,i]);const y=g.useCallback(x=>O(null,null,function*(){const T={brand:We,type:Qe(C),model:Ge}[e],h=yield He({indexName:T,searchParams:{query:x,hitsPerPage:50}}),b=ze({suggestions:h.hits,name:n});p(b),s(!0)}),[n,e]);return g.useEffect(()=>{y(c(n))},[c,n,y]),a.jsx(re,{control:d,options:o,name:n,searchFunction:y,label:t,validate:r,subLabel:l,noResult:u("genericErrors.noResult")})},Ue=({label:e,subLabel:n,options:t,disabled:r,name:l,control:u,required:d,validate:c})=>{const{field:{value:i,onChange:o,onBlur:p},fieldState:{error:m}}=R({name:l,control:u,rules:{required:d,validate:c}}),[s,f]=g.useState(!1),y=g.useRef(null);J(y,()=>{s&&p(),f(!1)});const x=t.filter(({value:h})=>i?!i.includes(h):t),T=x.length>0;return a.jsxs(U,{ref:y,erroneous:m,disabled:r,expanded:s,children:[a.jsx(w,{noMargin:!0,design:"body3",children:e}),a.jsxs(ee,{noMargin:!0,erroneous:m,disabled:r,onClick:()=>!r&&T&&f(!s),expanded:s,expandable:T,children:[a.jsx(je,{children:i==null?void 0:i.map(h=>{var b;return a.jsx(Ye,{label:(b=t.find(j=>_(h,j.value)))==null?void 0:b.label,onClick:j=>{const E=i.filter(M=>!_(M,h));o(E.length>0?E:[]),j.stopPropagation(),p()}},h)})}),a.jsx(Ke,{expanded:s,disabled:r}),s&&a.jsx(X,{children:a.jsx(Xe,{availableOptions:x,onChange:o,selectedValues:i})})]}),a.jsx(q,{errors:{[l]:m},name:l,label:n,disabled:r})]})},Ke=({expanded:e,disabled:n})=>{const t=ae();return a.jsx(ue,{name:e?D.CHEVRON_UP:D.CHEVRON_DOWN,style:{fontSize:"1.5rem",paddingRight:"8px",color:n?t.color.grey.shade6:t.color.grey.shade2}})},Ye=({label:e,onClick:n})=>a.jsx(G,{title:e,rightIcon:D.CLOSE,color:"blue",onClick:n,variant:"filled"}),Xe=({availableOptions:e,onChange:n,selectedValues:t})=>e.map(({value:r,label:l},u)=>a.jsx(Se,{onClick:()=>n(t!=null&&t.length?[...t,r]:[r]),children:a.jsx(K,{children:a.jsx(w,{noMargin:!0,design:"body3",children:l})})},r+u)),Ze=({options:e,name:n,filterOptionsWith:t,label:r,subLabel:l,validate:u,disabled:d})=>{const{watch:c,control:i,setValue:o}=S();t&&(e=e.filter(te[t]({metadata:c()})));const p=c(n)&&!c(n).every(m=>e.some(({value:s})=>s===m));return g.useEffect(()=>{p&&o(n,[])},[n,p,o]),a.jsx(Ue,{name:n,options:e,control:i,label:r,validate:u,subLabel:l,disabled:d})},en=({options:e,name:n,filterOptionsWith:t,label:r,subLabel:l,validate:u})=>{const{watch:d,control:c,setValue:i}=S();t&&(e=e.filter(te[t]({metadata:d()})));const o=d(n)&&!e.some(p=>p.value===d(n));return g.useEffect(()=>{o&&i(n,null)},[n,o,i]),a.jsx(Te,{name:n,options:e,control:c,label:r,validate:u,subLabel:l})},nn=`query DynamicInputFields($forType: String!, $locale: String!) { 36 fetchItemIOFromType(forType: $forType, locale: $locale) { 37 objectId 38 overridingFieldData 39 inputOrder { 40 ... on Element { 41 value 42 } 43 } 44 } 45} 46`,tn={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"DynamicInputFields"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"forType"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"locale"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"fetchItemIOFromType"},arguments:[{kind:"Argument",name:{kind:"Name",value:"forType"},value:{kind:"Variable",name:{kind:"Name",value:"forType"}}},{kind:"Argument",name:{kind:"Name",value:"locale"},value:{kind:"Variable",name:{kind:"Name",value:"locale"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"objectId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"overridingFieldData"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"inputOrder"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"Element"}},directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"value"},arguments:[],directives:[]}]}}]}}]}}]}}],loc:{start:0,end:273,source:{name:"GraphQL request",locationOffset:{line:1,column:1},body:nn}}},an=tn,rn=e=>{const{watch:n}=S(),t=n("type"),{loading:r,data:l,previousData:u}=ne(an,{variables:{forType:t==null?void 0:t.type,locale:C},skip:!(t!=null&&t.type)}),d=(l==null?void 0:l.fetchItemIOFromType)||(u==null?void 0:u.fetchItemIOFromType);return d?{dynamicInputFields:Ne({locale:C,excludeAdminOnly:!0,overridingFieldData:d.overridingFieldData,inputOrder:e||Fe(d.inputOrder)}),loading:r,overridingFieldData:d.overridingFieldData,itemIOId:d.objectId}:{dynamicInputFields:[],loading:r,overridingFieldData:{}}},kn=({materialCompositionsArray:e,isRegularItem:n,setChangeRequestModalOpen:t,itemHasSizeBottom:r})=>{const{dynamicInputFields:l,loading:u,overridingFieldData:d}=rn(),c=ln(e);return a.jsxs(a.Fragment,{children:[u&&a.jsx(me,{}),l.map(i=>{const o=i.group==="material"&&i.label==="Material"&&c,p=i.name==="sizeBottom"&&r;return o||p?null:a.jsx(on,{field:i,isRegularItem:n,overridingFieldData:d,setChangeRequestModalOpen:t},`field-${i.name}`)})]})},on=({field:e,overridingFieldData:n,isRegularItem:t,setChangeRequestModalOpen:r})=>{const{t:l,i18n:u}=N(["common","itemEdit"]),{register:d,unregister:c,control:i,formState:o}=S(),p=u.exists(`itemEdit:itemEdit.${e.name}.sublabel`,{ns:"itemEdit"})?l(`itemEdit:itemEdit.${e.name}.sublabel`):null,m=sn(I(k({},e),{defaultValues:o.defaultValues,isRegularItem:t,overridingFieldData:n}));return g.useEffect(()=>()=>c(e.name),[e.name,c]),e.algoliaIndex?a.jsxs(a.Fragment,{children:[a.jsx(Je,I(k({},e),{validate:m,subLabel:p}
46)),a.jsx(Q,{fieldName:e.name,setChangeRequestModalOpen:r})]}):e.dataType==="boolean"&&e.checkbox?a.jsx($,{name:e.name,control:i,rules:{validate:m},render:({field:s})=>{var f;return a.jsx(P,{name:s.name,erroneous:!!o.errors[e.name],errorMessage:(f=o.errors[e.name])==null?void 0:f.message,checked:s.value||!1,onChange:s.onChange,onBlur:s.onBlur,labelComponent:a.jsx(z,{label:e.label})})}}):e.dataType==="boolean"&&e.dataType.checkbox?a.jsx($,{name:e.name,control:i,rules:{validate:m},render:({field:s})=>{var f;return a.jsx(P,{name:s.name,erroneous:!!o.errors[e.name],errorMessage:(f=o.errors[e.name])==null?void 0:f.message,checked:s.value||!1,onChange:s.onChange,onBlur:s.onBlur,labelComponent:a.jsx(z,{label:e.label})})}}):e.dataType==="boolean"?a.jsx($,{name:e.name,control:i,rules:{validate:m},render:({field:s})=>a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx(pe,{name:s.name,checked:s.value||!1,onChange:s.onChange}),a.jsx(w,{design:"body2",noMargin:!0,children:e.label})]})}):e.dataType==="array"&&e.options?a.jsxs(a.Fragment,{children:[a.jsx(Ze,I(k({},e),{validate:m,subLabel:p})),a.jsx(Q,{fieldName:e.name,setChangeRequestModalOpen:r})]}):e.dataType==="array"?a.jsx(Ae,I(k({control:i},e),{validate:m})):e.options?a.jsx(en,I(k({},e),{validate:m,subLabel:p})):e.dataType==="number"?a.jsx(B,I(k({type:e.dataType,label:e.label},d(e.name,{validate:m,setValueAs:s=>Number(s)})),{errors:o.errors,helpText:p})):a.jsx(B,I(k({label:e.label},d(e.name,{validate:m})),{errors:o.errors,helpText:p}))},Q=({fieldName:e,setChangeRequestModalOpen:n})=>{var c;const t=ae(),{t:r}=N("itemEdit"),{isMobile:l}=Ce(),{getFieldState:u}=S(),d=(c=u(e))==null?void 0:c.error;return!d||!["validateBrandWithType","validateMaterialWithType","validateNotableBrand"].includes(d.type)?null:a.jsx(ye,{addon:a.jsx(ge,{color:"white",fullWidth:!0,label:r("itemEdit:qualityControlInfobox.button.label"),onClick:()=>n(!0),size:"small",variant:"filled"}),backgroundColor:"red",column:l,headline:r("itemEdit:qualityControlInfobox.headline"),subHeadline:r(`itemEdit:qualityControlInfobox.subheadline.${e}`),icon:a.jsx(fe,{style:{width:36,height:36},color:t.color.grey.shade2},"qualityCheck")})},sn=({validateWith:e=[],customerValidateWith:n=[],name:t,defaultValues:r,isRegularItem:l,overridingFieldData:u})=>{const{t:d}=N("itemEdit"),c=o=>[o,(p,m)=>Ee[o](p,{metadata:m,formValues:m,defaultValues:r,isRegularItem:l},{t:d,tNamespace:"itemEdit",language:C,overridingFieldData:u},t)],i=e.concat(n).map(c);return Object.fromEntries(i)},ln=e=>Array.isArray(e)&&e.some(n=>{var t;return Array.isArray((t=n==null?void 0:n.value)==null?void 0:t.composition)&&n.value.composition.length>0});export{kn as D,vn as S,bn as T,rn as u}; 47//# sourceMappingURL=DynamicInputFields.Boya5cm9.bundle.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.