1import{r as t,ca as y,cb as pe,bb as ce,cc as de,u as ve,e as G,ai as H,j as Se,a2 as J}from"./index-1ZwnxBtP.js";import{_ as he,a as r,h as Oe,u as ge,S as me}from"./Select-ef7c0426.esm-DM0BruO7.js";import{d as _e}from"./index-v2WCNqB0.js";import"./assertThisInitialized-z10GUNcL.js";import"./setPrototypeOf-DgZC2w_0.js";import"./use-isomorphic-layout-effect.browser.esm-Dlv4p7Sx.js";var Ce=["defaultOptions","cacheOptions","loadOptions","options","isLoading","onInputChange","filterOption"];function be(n){var i=n.defaultOptions,a=i===void 0?!1:i,p=n.cacheOptions,f=p===void 0?!1:p,c=n.loadOptions;n.options;var m=n.isLoading,I=m===void 0?!1:m,v=n.onInputChange,_=n.filterOption,L=_===void 0?null:_,S=he(n,Ce),C=S.inputValue,e=t.useRef(void 0),o=t.useRef(!1),u=t.useState(Array.isArray(a)?a:void 0),l=r(u,2),K=l[0],j=l[1],N=t.useState(typeof C<"u"?C:""),w=r(N,2),$=w[0],x=w[1],Q=t.useState(a===!0),D=r(Q,2),U=D[0],h=D[1],X=t.useState(void 0),q=r(X,2),P=q[0],A=q[1],Y=t.useState([]),M=r(Y,2),Z=M[0],E=M[1],k=t.useState(!1),T=r(k,2),ee=T[0],b=T[1],te=t.useState({}),F=r(te,2),O=F[0],W=F[1],ae=t.useState(void 0),z=r(ae,2),se=z[0],ne=z[1],oe=t.useState(void 0),B=r(oe,2),re=B[0],ue=B[1];f!==re&&(W({}),ue(f)),a!==se&&(j(Array.isArray(a)?a:void 0),ne(a)),t.useEffect(function(){return o.current=!0,function(){o.current=!1}},[]);var V=t.useCallback(function(g,d){if(!c)return d();var s=c(g,d);s&&typeof s.then=="function"&&s.then(d,function(){return d()})},[c]);t.useEffect(function(){a===!0&&V($,function(g){o.current&&(j(g||[]),h(!!e.current))})},[]);var ie=t.useCallback(function(g,d){var s=Oe(g,d,v);if(!s){e.current=void 0,x(""),A(""),E([]),h(!1),b(!1);return}if(f&&O[s])x(s),A(s),E(O[s]),h(!1),b(!1);else{var le=e.current={};x(s),h(!0),b(!P),V(s,function(R){o&&le===e.current&&(e.current=void 0,h(!1),A(s),E(R||[]),b(!1),W(R?y(y({},O),{},pe({},s,R)):O))})}},[f,V,P,O,v]),fe=ee?[]:$&&P?Z:K||[];return y(y({},S),{},{options:fe,isLoading:U||I,onInputChange:ie,filterOption:L})}var ye=t.forwardRef(function(n,i){var a=be(n),p=ge(a);return t.createElement(me,ce({ref:i},p))}),Ie=ye;function Le({onChange:n,group_id:i}){const[a,p,f]=de(e=>[e.ref,e.setItem,e.removeItem]),c=ve(e=>e.settings.website_match),[m,I]=t.useState(!1),[v,_]=t.useState(null);t.useEffect(()=>{a&&v!==a&&G(H+"/v1/sdk/affiliate",{ref_code:a,group_id:i,fields:"name, ref_code","x-shop":c}).then(e=>{const{name:o,ref_code:u,error:l}=e||{};l?f("ref"):S({label:o,value:u})}).catch(e=>{})},[a]);const L=_e((e,o)=>{if(!e.trim())return o([]);G(H+"/v1/sdk/affiliates",{search:e.trim(),group_id:i,"x-shop":c}).then(u=>u.affiliates.map(l=>({label:l.name,value:l.ref_code}))).then(u=>{I(!1),o(u)}).catch(u=>o([]))},400),S=e=>{n({target:{value:e&&e.value}}),_(e),e&&e.value?(console.log("settomg item",a),p("ref",e.value)):(console.log("removing item",a),f("ref"))},C={container:(e,o)=>({...e,outline:0,"&:focus":{outline:0}}),control:(e,o)=>({...e,borderColor:"#ced4da",borderRadius:0,"&:focus":{borderColor:"#98c2f2",outline:0,boxShadow:"0 0 0 0.2rem rgba(39, 128, 227, 0.25)"},"&:hover":{borderColor:"#98c2f2",boxShadow:"0 0 0 0.2rem rgba(39, 128, 227, 0.25)"}})};return Se.jsx(Ie,{styles:C,loadOptions:L,value:v,cacheOptions:!0,defaultOptions:!0,isClearable:!0,isLoading:m,placeholder:"Search...",onChange:S})}Le.propTypes={onChange:J.func.isRequired,placeholder:J.string};export{Le as default}; 2//# sourceMappingURL=SponsorChooser-CA1dFcmw.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.