@fungi.computer/prints 0.18.1 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{audio-waveform-CKaaFNjh.js → audio-waveform-Be5wRu8s.js} +1 -1
- package/dist/assets/{audio-waveform-view-CqGGEmLT.js → audio-waveform-view-DbTyVH72.js} +1 -1
- package/dist/assets/{computer-Dlwsjq-K.js → computer-Bfe-Ioxr.js} +1 -1
- package/dist/assets/{dist-Cc0qB3Mq.js → dist-DAokFn5x.js} +1 -1
- package/dist/assets/{dropdown-menu-Bp_cc0HZ.js → dropdown-menu-CAHLGfkb.js} +1 -1
- package/dist/assets/{generation-quote-DLlxvJxr.js → generation-quote-DcaCSlvV.js} +1 -1
- package/dist/assets/index-D-LwJiG1.js +2 -0
- package/dist/assets/{library-rail-CA4Qg4FP.js → library-rail-DVjIWa9C.js} +2 -2
- package/dist/assets/{library-view--GUDH_qa.js → library-view-BBAeJjj6.js} +1 -1
- package/dist/assets/log-event-B3BGsDWO.js +1 -0
- package/dist/assets/{print-download-button-hClIKKJA.js → print-download-button-BNNi_aoW.js} +2 -2
- package/dist/assets/{print-info-drawer-CtimiOWW.js → print-info-drawer-DDZan_oj.js} +2 -2
- package/dist/assets/{print-viewer-APDEs41V.js → print-viewer-D7p4Tznx.js} +2 -2
- package/dist/assets/query-CYqgVHJ7.js +1 -0
- package/dist/assets/useMutation-DH-cbXIA.js +1 -0
- package/dist/index.html +11 -11
- package/package.json +5 -5
- package/dist/assets/index-0YeCF6OC.js +0 -2
- package/dist/assets/log-event-R2fM9w5a.js +0 -1
- package/dist/assets/query-CvXKo0g1.js +0 -1
- package/dist/assets/useMutation-RbhZiO3b.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,Cn as t,D as n,Dn as r,En as i,F as a,H as o,I as s,J as c,M as l,N as u,O as d,Q as f,T as p,Tn as m,V as ee,W as h,_n as g,at as te,ct as _,et as v,fn as y,gn as ne,it as b,k as x,lt as S,nt as re,ot as ie,rt as C,sn as w,st as ae,tt as T,w as E,wn as oe,yn as D}from"./button-oE2Hrd5D.js";import{Ft as se,Pt as ce,a as O,i as k,jt as A,n as le,o as ue,r as j,s as M,u as N}from"./dist-Cc0qB3Mq.js";var de=[`InferenceUpstreamError`,`AiInternalError`,`TypeError`,`AbortError`,`TimeoutError`,`Error`],fe=[`credits_exhausted`,`content_refused`,`invalid_input`,`rate_limited`,`provider_unavailable`,`timeout`,`spending_limit`],P={minimum:0,maximum:99999},F={minimum:0,maximum:599},pe=x(de),me=ee([s({category:pe,code:l(n.check(f(P))),reason:S(x(fe)),detail:S(a.check(b(160)))}),s({category:d(`result_download`),status:n.check(f(F))})]);m([t({category:w(de),code:D().int().min(P.minimum).max(P.maximum).nullable(),reason:w(fe).optional(),detail:oe().max(160).optional()}),t({category:g(`result_download`),status:D().int().min(F.minimum).max(F.maximum)})]);function he(e){return/\.mp3$/iu.test(e)}var ge=Object.freeze({width:4,height:3}),_e=`prints-generation-notices`;function ve(e){le.error(e,{id:`prints-playback-error`,toasterId:_e})}var I=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},L=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),R=class extends A{stage;provider;constructor(e){super(e.message,{code:e.code,retryable:e.retryable,...e.need!==void 0&&{need:e.need}}),this.stage=e.stage??null,this.provider=e.provider}},z=e=>a.pipe(h(te(1)),h(b(e))),B=s({requestId:z(256),computerId:z(256)}),V=u.pipe(h(re()),h(ae(Number.isSafeInteger,{message:`Expected a safe integer`}))),H=V.pipe(h(v(0))),U=V.pipe(h(T(0))),W=u.pipe(h(e()),h(T(0))),ye=u.pipe(h(e()),h(v(0))),G=x([`first-frame`,`last-frame`,`reference`]),K=x([`480p`,`720p`,`768p`,`1080p`,`4k`]),q=x([`16:9`,`4:3`,`1:1`,`3:4`,`9:16`,`21:9`,`9:21`]),be=s({computerId:_(z(256)),path:z(4096),role:_(G)}),xe=s({path:z(4096),role:G}),Se=s({computerId:z(256),path:z(4096)}),Ce=s({defaultHeight:H,defaultSteps:l(U),defaultWidth:H,dimensions:x([`none`,`own`]),guidance:l(s({default:W,max:ye,min:W})).pipe(S),maxDimension:l(H),maxDimensionDocumented:p,maxReferences:U,maxSteps:l(H),referenceDimension:l(H),referenceField:l(z(256)),referenceFormat:x([`png`,`webp`]),steps:x([`steps`,`num_steps`,`fixed`]),transport:x([`json`,`multipart`])}),we=s({minSeconds:H,maxSeconds:H,defaultSeconds:H,durations:E(H),provider:x([`seedance`,`veo`,`minimax`]),formats:E(s({resolution:K,aspectRatio:q,width:H,height:H})),defaultResolution:K,defaultAspectRatio:q,supportsAudio:p,defaultGenerateAudio:l(p),referenceRoles:E(G),maxReferenceImages:U,audioReferences:l(s({max:H,totalSeconds:H})),referenceResolutions:E(K),prices:E(s({resolution:K,silentMilliunitsPerSecond:H,audioMilliunitsPerSecond:H}))}),Te=s({provider:d(`elevenlabs`),mode:x([`speech`,`music`]),voices:E(s({id:z(64),label:z(128)})),defaultVoiceId:l(z(64)),seconds:l(s({min:H,max:H,default:H})),milliunitsPerUnit:H}),Ee=s({operation:x([`remove_background`,`upscale`]),source:s({formats:E(x([`png`,`jpeg`,`webp`])),maxBytes:H,maxPixels:H}),defaultMegapixels:l(H),milliunits:l(H),sizes:E(s({megapixels:H,milliunits:H}))}),De=s({id:z(256),input:Ce,kind:x([`image`,`video`,`audio`]),label:z(512),maxPromptLength:H,tier:x([`draft`,`balanced`,`premium`,`max`]),outputFormats:E(x([`png`,`jpeg`,`webp`])).pipe(h(b(3))),sizes:l(E(a.pipe(h(ie(/^\d+x\d+$/u))))),video:l(we),audio:l(Te),transform:l(Ee),billingUnit:x([`image`,`video_second`,`audio_second`,`audio_character_block`])}),J=E(De),Oe=s({[Symbol.dispose]:_(o),computerId:z(256),models:J,canGenerate:p}),ke=s({model:z(256),prompt:z(32e3),width:_(H.pipe(h(C(5040)))),height:_(H.pipe(h(C(5040)))),voiceId:_(z(64)),steps:_(H),durationSeconds:_(H),targetMegapixels:_(H),resolution:_(K),aspectRatio:_(q),generateAudio:_(p),references:_(E(be).pipe(h(b(16))))});s({model:z(256),prompt:z(2048),resolution:_(K),aspectRatio:_(q),durationSeconds:_(H.pipe(h(T(4)),h(C(15)))),generateAudio:_(p),references:_(E(xe).pipe(h(b(4))))});var Ae=[`admission`,`generation-authorization`,`settings`,`estimate`,`billing`,`operation`,`provider`,`normalization`,`artifact`,`destination-authorization`,`destination-write`],je=s({destination:s({path:z(4096)}),settings:o}),Y=s({[Symbol.dispose]:_(o),bytes:H,costMilliunits:U,destination:Se,format:x([`png`,`jpeg`,`gif`,`webp`,`mp4`,`mp3`]),height:_(H),model:z(256),width:_(H)});s({...Y.fields,format:d(`mp4`)});var Me=s({message:z(512),stage:_(x(Ae)),provider:_(me),code:x([`CANCELLED`,`CAPABILITY_DENIED`,`CAPABILITY_REVOKED`,`DAILY_LIMIT_REACHED`,`DISCONNECTED`,`HOST_FAILURE`,`IDENTITY`,`INSUFFICIENT_CREDIT`,`INVALID_ARGUMENT`,`MEDIA_PROVIDER_FAILURE`,`MEDIA_PROVIDER_FAILURE_UNCHARGED`,`PROTOCOL`,`SAFETY_FILTER_REFUSED`,`SETUP_REQUIRED`,`TIMEOUT`]),retryable:p,need:_(ce)}),Ne=ee([s({[Symbol.dispose]:_(o),kind:d(`succeeded`),result:Y}),s({[Symbol.dispose]:_(o),kind:d(`failed`),failure:Me})]),Pe=k({reference:O(j(i().transform(e=>c(B)(e)))),generate:O(j(i().transform(e=>{let t=c(Ne,{onExcessProperty:`error`})(e);return t.kind===`succeeded`?{kind:t.kind,result:{bytes:t.result.bytes,costMilliunits:t.result.costMilliunits,destination:t.result.destination,format:t.result.format,...t.result.height!==void 0&&{height:t.result.height},model:t.result.model,...t.result.width!==void 0&&{width:t.result.width}}}:{kind:t.kind,failure:t.failure}})))}),Fe=M(`media.generation`,5,ne(()=>k({describe:O(j(i().transform(e=>{let{computerId:t,canGenerate:n,models:r}=c(Oe,{onExcessProperty:`error`})(e);return{computerId:t,canGenerate:n,models:r}}))),quote:O(j(t({costMilliunits:D().int().nonnegative().max(2**53-1)}))).optional(),createAttempt:O(Pe),restoreAttempt:O(Pe),cancelAttempt:ue}))),X=m([t({shared:g(!1)}),t({shared:g(!0),url:r(),showPrompt:y()})]);t({requestId:oe().min(1).max(256),showPrompt:y()});var Ie=M(`media.share`,1,ne(()=>k({status:O(j(X)),share:O(j(X)),stop:O(j(X))})));function Z(e,t){try{return c(e,{onExcessProperty:`error`})(t)}catch(e){throw new A(`The Media capability returned malformed data`,{cause:e,code:`PROTOCOL`,retryable:!1})}}function Q(e){return e instanceof A?e:new A(`The Media capability failed`,{cause:e,code:`HOST_FAILURE`,retryable:!0})}function $(e){if(e?.aborted)throw new A(`Media generation was cancelled`,{code:`CANCELLED`,retryable:!1})}function Le(e){let t;try{t=c(je,{onExcessProperty:`error`})(e)}catch(e){throw new A(`Media generation input is invalid`,{cause:e,code:`INVALID_ARGUMENT`,retryable:!1})}let n;try{n=ze(c(ke,{onExcessProperty:`error`})(t.settings))}catch(e){throw new A(`Media generation settings are invalid`,{cause:e,code:`INVALID_ARGUMENT`,retryable:!1})}let r={path:t.destination.path.trim()};if(r.path.length===0)throw new A(`Media generation destination is invalid`,{code:`INVALID_ARGUMENT`,retryable:!1});return Object.freeze({destination:Object.freeze(r),settings:n})}function Re(e){try{return ze(c(ke,{onExcessProperty:`error`})(e))}catch(e){throw new A(`Media generation settings are invalid`,{cause:e,code:`INVALID_ARGUMENT`,retryable:!1})}}function ze(e){let t=(e,t)=>{let n=e.trim();if(n.length===0)throw Error(`${t} must not be blank`);return n},n={model:t(e.model,`model`),prompt:t(e.prompt,`prompt`)};return e.width!==void 0&&(n.width=e.width),e.height!==void 0&&(n.height=e.height),e.voiceId!==void 0&&(n.voiceId=t(e.voiceId,`voiceId`)),e.steps!==void 0&&(n.steps=e.steps),e.durationSeconds!==void 0&&(n.durationSeconds=e.durationSeconds),e.targetMegapixels!==void 0&&(n.targetMegapixels=e.targetMegapixels),e.resolution!==void 0&&(n.resolution=e.resolution),e.aspectRatio!==void 0&&(n.aspectRatio=e.aspectRatio),e.generateAudio!==void 0&&(n.generateAudio=e.generateAudio),e.references!==void 0&&(n.references=Object.freeze(e.references.map(e=>Object.freeze({...e,path:t(e.path,`reference`)})))),Object.freeze(n)}function Be(e){let t=Z(J,e),n=new Set;for(let e of t){if(n.has(e.id))throw new A(`The Media capability repeated a model`,{code:`PROTOCOL`,retryable:!1});n.add(e.id)}return Object.freeze(t.map(e=>Object.freeze(e)))}function Ve(e,t,n,r){let i=Z(Y,e);if(i.model!==t.settings.model||i.destination.computerId!==n||i.destination.path!==t.destination.path||i.width!==t.settings.width||i.height!==t.settings.height||!r&&t.settings.width===void 0!=(i.format===`mp3`))throw new A(`The Media capability returned an unrelated result`,{code:`PROTOCOL`,retryable:!1});return Object.freeze({bytes:i.bytes,costMilliunits:i.costMilliunits,destination:Object.freeze({...i.destination}),format:i.format,...i.height!==void 0&&{height:i.height},model:i.model,...i.width!==void 0&&{width:i.width}})}async function He(e){try{let t=e.require(Fe);{let e={stack:[],error:void 0,hasError:!1};try{let n=Z(Oe,I(e,N(await t.describe()),!1).value),r=n.computerId.trim();if(r.length===0)throw new A(`The Media capability returned no Computer`,{code:`PROTOCOL`,retryable:!1});let i=Be(n.models),a=t.quote?.bind(t),c=async e=>{let n=N(e),a;try{{let t={stack:[],error:void 0,hasError:!1};try{let n=I(t,N(await e.reference()),!1),i=Z(s({...B.fields,[Symbol.dispose]:_(o)}),n.value);if(a={requestId:i.requestId,computerId:i.computerId},a.computerId!==r)throw new A(`Media attempt belongs to another Computer`,{code:`IDENTITY`,retryable:!1})}catch(e){t.error=e,t.hasError=!0}finally{L(t)}}}catch(e){throw n[Symbol.dispose](),Q(e)}let c=!1;return{reference:Object.freeze(a),async generate(n,o={}){if(c)throw new A(`Media generation attempt is closed`,{code:`CAPABILITY_DENIED`,retryable:!1});$(o.signal);let s=Le(n),l=o.signal,u,d,f=()=>(d??=t.cancelAttempt(a),d);try{let t=e.generate(s),n=l===void 0?await t:await Promise.race([t,new Promise((e,t)=>{u=()=>{f().then(()=>{t(new A(`Media generation was cancelled`,{code:`CANCELLED`,retryable:!1}))},t)},l.addEventListener(`abort`,u,{once:!0}),l.aborted&&u()})]);l?.aborted&&(await f(),$(l)),$(l);{let e={stack:[],error:void 0,hasError:!1};try{let t=Z(Ne,I(e,N(n),!1).value);if(t.kind===`failed`)throw new R(t.failure);return Ve(t.result,s,r,i.find(e=>e.id===s.settings.model)?.transform!=null)}catch(t){e.error=t,e.hasError=!0}finally{L(e)}}}catch(e){throw l?.aborted&&(await f(),$(l)),Q(e)}finally{u!==void 0&&l?.removeEventListener(`abort`,u)}},[Symbol.dispose](){c||(c=!0,n[Symbol.dispose]())}}};return Object.freeze({computerId:r,canGenerate:n.canGenerate,models:i,async quote(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Re(e);if(a===void 0)return null;let r=I(t,N(await a(n)),!1);return Object.freeze({costMilliunits:r.value.costMilliunits})}catch(e){t.error=e,t.hasError=!0}finally{L(t)}},async createAttempt(){return c(await t.createAttempt())},async restoreAttempt(e){let n=Z(B,e);if(n.computerId!==r)throw new A(`Select the original Computer to retry this generation`,{code:`IDENTITY`,retryable:!1});let i=await c(await t.restoreAttempt(n));if(i.reference.requestId!==n.requestId)throw i[Symbol.dispose](),new A(`Media restore changed the request identity`,{code:`PROTOCOL`,retryable:!1});return i}})}catch(t){e.error=t,e.hasError=!0}finally{L(e)}}}catch(e){throw Q(e)}}function Ue(e,t){console.error(`Prints operation failed`,JSON.stringify({operation:e,errorKind:t instanceof Error?`error`:`non-error`,stage:t instanceof R?t.stage:null,provider:t instanceof R?t.provider:void 0}),se(t))}export{B as a,Le as c,ve as d,je as i,ge as l,R as n,Ie as o,Fe as r,He as s,Ue as t,he as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Vn as n,vn as r,yn as i}from"./button-oE2Hrd5D.js";import{Ct as a,Dt as o,Et as s,Ot as c,Q as l,Tt as u,_t as d,at as f,bt as p,ct as m,dt as h,et as g,ft as _,gt as v,ht as y,it as b,jt as x,lt as ee,mt as S,nt as te,ot as C,pt as w,rt as ne,st as T,tt as E,ut as D,vt as O,wt as k,xt as A,yt as j}from"./dist-Cc0qB3Mq.js";function re(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ee(e,()=>t.signal,()=>n=!0)},u=_(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?h:D;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?N:M,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:M(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function M(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function N(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function P(e,t){return t?M(e,t)!=null:!1}function F(e,t){return!t||!e.getPreviousPageParam?!1:N(e,t)!=null}var I=class extends g{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=z(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=z(this.options);e.data!==void 0&&(this.setState(R(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=A(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(j).catch(j):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>a(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===s||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>a(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!o(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=_(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?re(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=ne({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof E&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof E){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...L(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...R(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),f.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function L(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:te(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function R(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function z(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var ie=class extends T{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),B(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return V(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return V(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof a(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!k(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&H(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||a(this.options.enabled,this.#t)!==a(t.enabled,this.#t)||a(this.options.staleTime,this.#t)!==a(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||a(this.options.enabled,this.#t)!==a(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return k(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(j)),t}#h(e){return!m()&&a(this.options.enabled,this.#t)!==!1&&v(e)}#g(){this.#b();let e=a(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=o(this.#r.dataUpdatedAt,e)+1;this.#u=c.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#f=e,!(this.#f===0||!this.#h(this.#f))&&(this.#d=c.setInterval(()=>{(this.options.refetchIntervalInBackground||C.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(c.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(c.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,o=this.#i,s=this.#a,c=e===n?this.#n:e.state,{state:l}=e,u={...l},d=!1,f;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&B(e,t),o=i&&H(e,n,t,r);(a||o)&&(u={...u,...L(l.data,e.options)}),t._optimisticResults===`isRestoring`&&(u.fetchStatus=`idle`)}let{error:p,errorUpdatedAt:m,status:h}=u;f=u.data;let g=!1;if(t.placeholderData!==void 0&&f===void 0&&h===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===s?.placeholderData?(e=i.data,g=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(h=`success`,f=A(i?.data,e,t),d=!0)}if(t.select&&f!==void 0&&!g){if(i&&f===o?.data&&t.select===this.#s)f=this.#c;else try{this.#s=t.select,f=t.select(f),f=A(i?.data,f,t),this.#c=f,this.#o=null}catch(e){this.#o=e}}else f===void 0&&(this.#o=null);this.#o&&(p=this.#o,f=this.#c,m=Date.now(),h=`error`,d=!1);let _=u.fetchStatus===`fetching`,v=h===`pending`,y=h===`error`,b=v&&_,x=f!==void 0;return{status:h,fetchStatus:u.fetchStatus,isPending:v,isSuccess:h===`success`,isError:y,isInitialLoading:b,isLoading:b,data:f,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:m,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:_,isRefetching:_&&!v,isLoadingError:y&&!x,isPaused:u.fetchStatus===`paused`,isPlaceholderData:d,isRefetchError:y&&x,isStale:U(e,t),refetch:this.refetch,isEnabled:a(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),k(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();f.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function ae(e,t){return a(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||a(t.retryOnMount,e)!==!1)}function B(e,t){return ae(e,t)||e.state.data!==void 0&&V(e,t,t.refetchOnMount)}function V(e,t,n){if(a(t.enabled,e)!==!1&&a(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&U(e,t)}return!1}function H(e,t,n,r){return(e!==t||a(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&U(e,n)}function U(e,t){return a(t.enabled,e)!==!1&&e.isStaleByTime(a(t.staleTime,e))}var W=class extends T{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new l({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=G(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=G(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=G(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=G(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){f.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>d(t,e))}findAll(e={}){return this.getAll().filter(t=>d(e,t))}notify(e){f.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return f.batch(()=>Promise.all(e.map(e=>e.continue().catch(j))))}};function G(e){return e.options.scope?.id}var K=class extends T{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??y(r,t),a=this.get(i);return a||(a=new I({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){f.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>O(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>O(e,t)):t}notify(e){f.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){f.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){f.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},q=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new K,this.#t=e.mutationCache||new W,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=C.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=b.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(a(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=w(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return f.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;f.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return f.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=f.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(j).catch(j)}invalidateQueries(e,t={}){return f.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=f.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(j)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(j)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(a(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(a(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(j).catch(j)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(j).catch(j)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return b.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(S(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{p(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(S(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{p(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=y(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===s&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},J=e(n(),1),Y=J.createContext(!1),oe=()=>J.useContext(Y);Y.Provider,t();function se(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ce=J.createContext(se()),le=()=>J.useContext(ce),ue=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?u(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},de=e=>{J.useEffect(()=>{e.clearReset()},[e])},fe=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||u(n,[e.error,r])),pe=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},me=(e,t)=>e?.suspense&&t.isPending,he=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function X(e){return e}function ge(e){return e}var _e=r({status:i()}),ve=3,ye=/network ?(?:changed|error)|failed to fetch|load failed|network connection was lost/iu;function be(e){let t=[];for(let n=e;n!==void 0&&t.length<5;n=n instanceof Error?n.cause:void 0)t.push(n);return t}function xe(e){return be(e).some(e=>{if(e instanceof TypeError)return!0;if(e instanceof x)return e.code===`HOST_FAILURE`&&e.retryable;let t=_e.safeParse(e);return t.success?t.data.status>=500:e instanceof Error&&ye.test(e.message)})}function Se(e,t){return e<ve&&xe(t)}function Z(e){return 250*2**e}function Q(e){return e instanceof x?e:new x(`App operation failed`,{cause:e,code:`HOST_FAILURE`,retryable:!1})}var $=new WeakMap,Ce={of(e,...t){return[e?.identity.surfaceId??null,e?.context.get().computerId??null,...t]}};function we(e){let t={};return e&&$.set(t,e),t}function Te(){let e=new q({defaultOptions:{queries:{retry:!1,staleTime:3e4,refetchOnWindowFocus:!1},mutations:{retry:!1}}}),t=new Map;return e.getQueryCache().subscribe(n=>{let r=n.query;if(n.type===`removed`){t.get(r.queryHash)?.release(),t.delete(r.queryHash);return}let i=r.meta&&$.get(r.meta),a=t.get(r.queryHash);if(a?.app===i||(a?.release(),t.delete(r.queryHash),!i))return;let o=()=>{queueMicrotask(()=>{e.getQueryCache().get(r.queryHash)===r&&t.get(r.queryHash)?.app===i&&e.resetQueries({predicate:e=>e===r})})},s=i.capabilities.subscribe(o);t.set(r.queryHash,{app:i,release:s}),a&&o()}),e}function Ee(e,t,n,r){let i=e?.context.get().computerId;return X({queryKey:n,meta:we(e),enabled:e!==null,retry:Se,retryDelay:Z,queryFn:async({signal:n})=>{try{if(!e)throw new x(`No App connection`,{code:`DISCONNECTED`,retryable:!0});if(e.context.get().computerId!==i)throw new x(`The selected Computer changed`,{code:`SELECTION_CHANGED`,retryable:!1});return await r(e.capabilities.require(t),n)}catch(e){throw Q(e)}}})}function De(e){return ge({mutationKey:e.queryKey,scope:{id:S(e.queryKey)},mutationFn:async(t,n)=>{try{return await e.mutationFn(t,n)}catch(e){throw Q(e)}},onMutate:async(t,{client:n})=>{if(n.isMutating({mutationKey:e.queryKey,exact:!0})>1)return;await n.cancelQueries({queryKey:e.queryKey,exact:!0});let r=n.getQueryData(e.queryKey);if(r!==void 0)return n.setQueryData(e.queryKey,e.apply(r,t)),{previous:r,optimistic:n.getQueryData(e.queryKey)}},onError:(t,n,r,{client:i})=>{r&&i.getQueryData(e.queryKey)===r.optimistic&&i.setQueryData(e.queryKey,r.previous)},onSettled:(t,n,r,i,{client:a})=>a.invalidateQueries({queryKey:e.queryKey,exact:!0})})}export{X as a,me as c,de as d,le as f,F as g,P as h,Ce as i,ue as l,ie as m,Te as n,pe as o,oe as p,De as r,he as s,Ee as t,fe as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Vn as t}from"./button-oE2Hrd5D.js";import{$ as n,At as r,Tt as i,at as a,mt as o,st as s,wt as c,yt as l}from"./dist-Cc0qB3Mq.js";var u=class extends s{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),c(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&o(t.mutationKey)!==o(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??n();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){a.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},d=e(t(),1);function f(e,t){let n=r(t),[o]=d.useState(()=>new u(n,e));d.useEffect(()=>{o.setOptions(e)},[o,e]);let s=d.useSyncExternalStore(d.useCallback(e=>o.subscribe(a.batchCalls(e)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),c=d.useCallback((...e)=>{o.mutate(e[0],e[1]).catch(l)},[o]);if(s.error&&i(o.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:c,mutateAsync:s.mutate}}export{f as t};
|