var{defineProperty:C,getOwnPropertyNames:E,getOwnPropertyDescriptor:G}=Object,I=Object.prototype.hasOwnProperty;function J(j){return this[j]}var Q=(j)=>{var q=(D??=new WeakMap).get(j),z;if(q)return q;if(q=C({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var A of E(j))if(!I.call(q,A))C(q,A,{get:J.bind(j,A),enumerable:!(z=G(j,A))||z.enumerable})}return D.set(j,q),q},D;var K=(j)=>j;function L(j,q){this[j]=K.bind(null,q)}var S=(j,q)=>{for(var z in q)C(j,z,{get:q[z],enumerable:!0,configurable:!0,set:L.bind(q,z)})};var T=(j,q)=>()=>(j&&(q=j(j=0)),q);function M(j){return typeof j==="object"&&j!==null&&"items"in j&&Array.isArray(j.items)}class O{config;cache=new Map;subscriptions=new Map;constructor(j){this.config=j}register(j){this.config.registry.register(j)}getSpec(j,q){return this.config.registry.get(j,q)}async executeQuery(j,q,z){let A=this.getSpec(j);if(!A)throw Error(`DataView spec not found: ${j}`);let B=A.source.primary;if(!B)throw Error(`DataView spec ${j} missing primary source`);try{let y=await this.config.operationRegistry.execute(B.key,B.version,q,z);if(Array.isArray(y))return{data:y,total:y.length,loading:!1};if(M(y))return{data:y.items,total:y.total??y.items.length,loading:!1};return{data:[y],total:1,loading:!1}}catch(y){return{data:[],total:0,loading:!1,error:y instanceof Error?y:Error(String(y))}}}invalidate(j){this.cache.delete(j),this.notifySubscribers(j)}subscribe(j,q){if(!this.subscriptions.has(j))this.subscriptions.set(j,new Set);return this.subscriptions.get(j)?.add(q),()=>{this.subscriptions.get(j)?.delete(q)}}notifySubscribers(j){this.subscriptions.get(j)?.forEach((q)=>q())}}export{O as DataViewRuntime};
