var __spreadArray=this&&this.__spreadArray||function(r,a){for(var t=0,e=a.length,i=r.length;t<e;t++,i++)r[i]=a[t];return r};import{T as TextField}from"./index-403e215e.js";import{D as DataModel}from"./data-model-f5160369.js";import{C as Comparison}from"./filter-cbaa3d7d.js";import{r as replaceParamsInFilter,c as cloneFilter}from"./filter-8542e288.js";var ItemDataProvider=function(){function r(r,a,t,e,i,s){this.apiData=r;this.callback=s;this.params=a;this.table=t;this.fields=i;this.query=e}r.prototype.fetchData=function(r){var a=this;var t;if(r.isPending){return}this.callback(r.beforeFetch());var e=this.table.name;var i=((t=this.query)===null||t===void 0?void 0:t.filter)?replaceParamsInFilter(cloneFilter(this.query.filter),this.params):{comparison:Comparison.Eq,id:"_id",value:this.params.itemId};this.apiData.query(e,{fields:__spreadArray(__spreadArray([],this.fields),[new TextField("_id","ID")]),filter:i,limit:1,skip:0}).then((function(t){a.callback(r.afterFetch(t.results.length>0?t.results[0]:new DataModel))}),(function(t){a.callback(r.afterFetchError(t))}))};return r}();export{ItemDataProvider as I};