import{a as b,b as k,d as C,e as M,f as A,g as T,h as N}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-RH7K7YQU.js";import{a as F}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-BMLPKF64.js";import{a as D}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-LL6AKNEK.js";import{a as P}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-LQ2PFFE3.js";import{b as L,d as E}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-H7QMOPDN.js";var q=L(_=>{"use strict";var w=P();function G(n,i){return n===i&&(n!==0||1/n===1/i)||n!==n&&i!==i}var J=typeof Object.is=="function"?Object.is:G,K=w.useSyncExternalStore,U=w.useRef,W=w.useEffect,z=w.useMemo,R=w.useDebugValue;_.useSyncExternalStoreWithSelector=function(n,i,a,f,m){var t=U(null);if(t.current===null){var o={hasValue:!1,value:null};t.current=o}else o=t.current;t=z(function(){function v(r){if(!c){if(c=!0,d=r,r=f(r),m!==void 0&&o.hasValue){var l=o.value;if(m(l,r))return s=l}return s=r}if(l=s,J(d,r))return l;var y=f(r);return m!==void 0&&m(l,y)?l:(d=r,s=y)}var c=!1,d,s,h=a===void 0?null:a;return[function(){return v(i())},h===null?void 0:function(){return v(h())}]},[i,a,f,m]);var u=K(n,t[0],t[1]);return W(function(){o.hasValue=!0,o.value=u},[u]),R(u),u}});var Q=L((Z,O)=>{"use strict";O.exports=q()});var e=E(P(),1),j=E(F(),1),I=E(Q(),1);var S=E(D(),1);function re(n,i,a,f){let{isEqual:m=j.default}=f||{},t=(0,e.useContext)(A),o=k(a),u=(0,e.useMemo)(()=>t(n,i,o),[t,n,o,i]),[v]=(0,e.useState)(()=>{if(n===void 0)throw new Error("initialSnapshot can't be undefined, if you don't want an initial value use null instead");try{return JSON.parse(JSON.stringify(n))}catch(r){return console.warn("Failed to deep clone initialSnapshot, this is likely an error and an indication that the snapshot isn't JSON serializable",{initialSnapshot:n,error:r}),n}}),c=(0,e.useCallback)(()=>v,[v]),d=(0,e.useCallback)(r=>r,[]),s=(0,I.useSyncExternalStoreWithSelector)(u.subscribe,u.getSnapshot,c,d,m),h=B(i,o);return[s,h]}function B(n,i){let a=(0,e.useContext)(T),f=(0,e.useMemo)(()=>b(n,i),[i,n]);return(0,e.useMemo)(()=>Array.isArray(a)?!a.includes(f):!1,[f,a])}function te(){return(0,e.useContext)(N)}function X(n){let{GroqStoreProvider:i,LiveStoreProvider:a}=n,f=(0,e.memo)(t=>{var o;let{children:u,refreshInterval:v,client:c,cache:d,logger:s}=t,h=(o=d?.maxDocuments)!=null?o:C,[r,l]=(0,e.useState)(null),[y,V]=(0,e.useState)(null),[x]=(0,e.useState)(()=>{var p;return(p=d?.includeTypes)!=null?p:[]});if(y)throw y;if((0,e.useEffect)(()=>{if(r!==null)return;s?.log("[@sanity/preview-kit]: fetch documents count");let p=new AbortController;return c.fetch(x.length>0?"count(*[_type in $includeTypes])":"count(*)",{includeTypes:x},{filterResponse:!0,signal:p.signal}).then(g=>{s?.log("[@sanity/preview-kit]: documents count",g),l(g)}).catch(g=>{g.name!=="AbortError"&&V(g)}),()=>{p.abort()}},[c,r,x,s]),r===null)return u;if(v&&r>=h)return(0,S.jsx)(e.Suspense,{fallback:u,children:(0,S.jsx)(a,{client:c,refreshInterval:v,turboSourceMap:!1,logger:s,children:u})});if(r>=h)throw new Error("[@sanity/preview-kit]: You have ".concat(r," documents in your dataset, which is more than the maximum of ").concat(h," documents. Please reduce the number of documents in your dataset or increase the limit."));return(0,S.jsx)(e.Suspense,{fallback:u,children:(0,S.jsx)(i,{...t,children:u})})});f.displayName="SelectStoreProvider";let m=(0,e.memo)(t=>{let{children:o,refreshInterval:u=1e4,token:v}=t;if(!t.client)throw new Error("Missing a `client` prop with a configured Sanity client instance");let[c]=(0,e.useState)(()=>{let{requestTagPrefix:r,resultSourceMap:l}=t.client.config();return t.client.withConfig({requestTagPrefix:r||M,resultSourceMap:l||"withKeyArraySelector",...v&&{token:v,useCdn:!1,perspective:"previewDrafts",ignoreBrowserTokenWarning:!0}})}),[d]=(0,e.useState)(()=>t.cache),[s]=(0,e.useState)(()=>t.logger),h=(0,e.useMemo)(()=>{var r;let{resultSourceMap:l}=c.config();return(r=t.turboSourceMap)!=null?r:l==="withKeyArraySelector"||l},[c,t.turboSourceMap]);return h?(0,S.jsx)(e.Suspense,{fallback:o,children:(0,S.jsx)(a,{client:c,logger:s,refreshInterval:u,turboSourceMap:h,children:o})}):(0,S.jsx)(e.Suspense,{fallback:o,children:(0,S.jsx)(f,{client:c,cache:d,logger:s,refreshInterval:u,children:o})})});return m.displayName="LiveQueryProvider",m}var Y=(0,e.lazy)(()=>import("https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/index-nUf8MZeB-XX3NHQ2J.js")),$=(0,e.lazy)(()=>import("https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/index-qPm-_dZE-QPH7J533.js")),ne=X({GroqStoreProvider:Y,LiveStoreProvider:$});export{re as a,te as b,X as c,ne as d}; /*! Bundled license information: use-sync-external-store/cjs/use-sync-external-store-with-selector.production.min.js: (** * @license React * use-sync-external-store-with-selector.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. *) */