import{j as u}from"./assertThisInitialized-ClXgY4BW.js";import{a as M}from"./dataProvider-BSMCbdJg.js";import{G as Q,r as A}from"./api-D469Uxm1.js";import{r as B}from"./ideExtension-Duoj5XVI.js";import{r as d}from"./index-BP8_t0zE.js";import{o as T,p as v,a2 as k,d as K}from"./defaultI18nProvider-C_r1y4tu.js";import{u as N}from"./useQuery-DJhJ3Hj4.js";import{u as V}from"./useDataProvider-BTi1EEZL.js";import{L as H}from"./RefreshIconButton-Y4b9u9mV.js";import{T as U}from"./TextField-n0Myx-gm.js";import{B as z}from"./Button-C3j8Wgdd.js";import{A as J}from"./AdminContext-jMMnnv4u.js";import"./index-BCKAMao3.js";import"./useLogout-DAYYFX4P.js";import"./useRefresh-BVYjI9Ho.js";import"./CircularProgress-CoZCnRya.js";import"./createSvgIcon-BeVLBbd8.js";import"./createSvgIcon-C1LdFc73.js";import"./Typography-E7d16C50.js";import"./useRecordContext-CmNI-aHo.js";import"./PreferencesEditorContext-oPOmBo-a.js";import"./index-qEiLzbkV.js";var h=function(){return h=Object.assign||function(r){for(var o,n=1,e=arguments.length;n<e;n++){o=arguments[n];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(r[a]=o[a])}return r},h.apply(this,arguments)},W=function(r,o){var n={};for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&o.indexOf(e)<0&&(n[e]=r[e]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,e=Object.getOwnPropertySymbols(r);a<e.length;a++)o.indexOf(e[a])<0&&Object.prototype.propertyIsEnumerable.call(r,e[a])&&(n[e[a]]=r[e[a]]);return n},X=function(r,o,n){n===void 0&&(n={});var e=o.ids,a=o.meta,y=V(),l=T(),I=l.getQueryCache(),x=n.onError,D=x===void 0?g:x,E=n.onSuccess,L=E===void 0?g:E,b=n.onSettled,R=b===void 0?g:b,m=n.enabled,q=W(n,["onError","onSuccess","onSettled","enabled"]),O=v(L),j=v(D),S=v(R),t=N(h({queryKey:[r,"getMany",{ids:!e||e.length===0?[]:e.map(function(i){return String(i)}),meta:a}],queryFn:function(i){return!e||e.length===0?Promise.resolve([]):y.getMany(r,{ids:e,meta:a,signal:y.supportAbortSignal===!0?i.signal:void 0}).then(function(s){var c=s.data;return c})},placeholderData:function(){var i=!e||e.length===0?[]:e.map(function(s){var c,p,w=k([r,"getOne",{id:String(s),meta:a}]);return(p=(c=I.get(w))===null||c===void 0?void 0:c.state)===null||p===void 0?void 0:p.data});if(!i.some(function(s){return s===void 0}))return i},retry:!1,enabled:m??e!=null},q)),_=d.useRef(a),P=d.useRef(r);return d.useEffect(function(){_.current=a},[a]),d.useEffect(function(){P.current=r},[r]),d.useEffect(function(){t.data===void 0||t.error!=null||t.isFetching||(t.data.forEach(function(i){l.setQueryData([P.current,"getOne",{id:String(i.id),meta:_.current}],function(s){return s??i})}),O(t.data))},[l,O,t.data,t.error,t.isFetching]),d.useEffect(function(){t.error==null||t.isFetching||j(t.error)},[j,t.error,t.isFetching]),d.useEffect(function(){t.status==="pending"||t.isFetching||S(t.data,t.error)},[S,t.data,t.error,t.status,t.isFetching]),t},g=function(){};const be={title:"DataProvider/UseGetMany",parameters:{layout:"centered"},decorators:[r=>Z(r)]};function Y(){return Math.random()>.5?[3,2,1]:[1,2,3]}const f={render:()=>{let{data:r,isLoading:o,isRefetching:n,refetch:e}=X(B("users",{allowContext:!1}),{ids:A(Y())});return u.jsxs(Q.Exclude,{children:[(o||n)&&u.jsx(H,{}),!o&&!n&&(r||[]).map(a=>u.jsxs(u.Fragment,{children:[u.jsx(U,{record:a,source:"name"}),u.jsx("p",{})]})),!o&&!n&&u.jsx(z,{label:"Reload",onClick:()=>e()})]})}},Z=r=>u.jsx(J,{dataProvider:M,i18nProvider:K,children:u.jsx(r,{})});var F,C,G;f.parameters={...f.parameters,docs:{...(F=f.parameters)==null?void 0:F.docs,source:{originalSource:`{
  render: () => {
    let {
      data,
      isLoading,
      isRefetching,
      refetch
    } = useGetMany(resourceName('users', {
      allowContext: false
    }), {
      ids: replaceOnGenerate(randomIds(), [])
    });
    return <GenerationInstructions.Exclude>
            {(isLoading || isRefetching) && <LoadingIndicator />}
            {!isLoading && !isRefetching && (data || []).map(value => <>
                    <TextField record={value} source="name" />
                    <p />
                </>)}
            {!isLoading && !isRefetching && <Button label="Reload" onClick={() => refetch()} />}
        </GenerationInstructions.Exclude>;
  }
}`,...(G=(C=f.parameters)==null?void 0:C.docs)==null?void 0:G.source}}};const Oe=["Default"];export{f as Default,Oe as __namedExportsOrder,be as default};
