@qratilabs/qrati-connect 2.15.0 → 2.16.0

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/element/{CWJf7mNz.js → BI8RhPVM.js} +1 -1
  3. package/element/{BeBNT9RQ.js → BhtZwJ7r.js} +1 -1
  4. package/element/{CMtkKIjI.js → BvDw8z0o.js} +1 -1
  5. package/element/{Bez3GA8y.js → CEsBzi55.js} +1 -1
  6. package/element/{BPD6evHs.js → CwqB3rqe.js} +1 -1
  7. package/element/{CNGkJRCP.js → Cy3iV9XH.js} +1 -1
  8. package/element/{FXirOp_Y.js → D0tOl2TC.js} +1 -1
  9. package/element/{BHwNoqYe.js → DAitYRY4.js} +1 -1
  10. package/element/{BQBx6JI7.js → Dlyq91q9.js} +1 -1
  11. package/element/{Bu-H5iRE.js → DuIwDwan.js} +1 -1
  12. package/element/{19c52mJB.js → MZuQhFbV.js} +1 -1
  13. package/element/{BU70X6zI.js → VGPc4EeK.js} +1 -1
  14. package/element/{t1REK11Z.js → jL1IhEDX.js} +3 -3
  15. package/element/web.es.js +3 -3
  16. package/package.json +1 -1
  17. package/react/{DCz37sa7.js → B8OuOa1d.js} +1 -1
  18. package/react/{CDiSbuj_.js → BG6d9dt3.js} +1 -1
  19. package/react/{CcGfpCV3.js → BiTDkR5y.js} +1 -1
  20. package/react/{CHSr2RxR.js → BkeCKRKb.js} +1 -1
  21. package/react/{BMzYiAN3.js → BlGHB1od.js} +1 -1
  22. package/react/{Cgm2azyl.js → BltPktiy.js} +1 -1
  23. package/react/{DvzgEfqA.js → C77XJYNh.js} +1 -1
  24. package/react/{DqVfSNOG.js → CPM5coLp.js} +1 -1
  25. package/react/CSHWW4FM.js +1 -0
  26. package/react/{B5em30k0.js → CY68wh8z.js} +1 -1
  27. package/react/{BJvO-E_0.js → CYntO9YI.js} +1 -1
  28. package/react/{TRIgeGAL.js → CZ9RIEEO.js} +1 -1
  29. package/react/{B100IxcO.js → D1CJDHfi.js} +1 -1
  30. package/react/{B1c5Cjsd.js → D9p5klRz.js} +1 -1
  31. package/react/{BB-zGb6J.js → DCS0HdZa.js} +1 -1
  32. package/react/{CX_Vz15p.js → DF_cfEUO.js} +1 -1
  33. package/react/DQVgvgo2.js +6 -0
  34. package/react/{D_KoEU5i.js → DVJkpJ9-.js} +1 -1
  35. package/react/{BlSQ-ODL.js → DXEzKDRE.js} +1 -1
  36. package/react/{DQWXCdfm.js → DZhlx4rT.js} +1 -1
  37. package/react/{DPezSfU3.js → D_47D6ly.js} +1 -1
  38. package/react/{eCa9bk8E.js → O7eIZSmq.js} +1 -1
  39. package/react/{BmbdEikc.js → P53QlFG0.js} +1 -1
  40. package/react/index.cjs +1 -1
  41. package/react/index.mjs +3 -3
  42. package/react/{EJU6024p.js → k7mNnMH1.js} +1 -1
  43. package/react/{CojsvC2N.js → vcPA0j_c.js} +3 -3
  44. package/react/{CB5M-zWX.js → yWdl62rI.js} +1 -1
  45. package/umd/web.umd.js +1 -1
  46. package/react/BsUU5VBO.js +0 -6
  47. package/react/JLXrD6OW.js +0 -1
@@ -1,4 +1,4 @@
1
- import{G as e,L as t,M as r,P as s,R as n,_ as o,b as i,f as a,g as c,h as l,j as u,p as h,v as d,w as p,z as f}from"./19c52mJB.js";var y=class{constructor(){this.listeners=/* @__PURE__ */new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},m=new class extends y{#e;#t;#r;constructor(){super(),this.#r=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#e?this.#e:"hidden"!==globalThis.document?.visibilityState}},g={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},w=new class{#s=g;#n=!1;setTimeoutProvider(e){this.#s=e}setTimeout(e,t){return this.#s.setTimeout(e,t)}clearTimeout(e){this.#s.clearTimeout(e)}setInterval(e,t){return this.#s.setInterval(e,t)}clearInterval(e){this.#s.clearInterval(e)}},b="undefined"==typeof window||"Deno"in globalThis;function v(){}function E(e,t){return"function"==typeof e?e(t):e}function R(e){return"number"==typeof e&&e>=0&&e!==1/0}function S(e,t){return Math.max(e+(t||0)-Date.now(),0)}function T(e,t){return"function"==typeof e?e(t):e}function O(e,t){return"function"==typeof e?e(t):e}function A(e,t){const{type:r="all",exact:s,fetchStatus:n,predicate:o,queryKey:i,stale:a}=e;if(i)if(s){if(t.queryHash!==C(i,t.options))return!1}else if(!N(t.queryKey,i))return!1;if("all"!==r){const e=t.isActive();if("active"===r&&!e)return!1;if("inactive"===r&&e)return!1}return!("boolean"==typeof a&&t.isStale()!==a||n&&n!==t.state.fetchStatus||o&&!o(t))}function I(e,t){const{exact:r,status:s,predicate:n,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(r){if(P(t.options.mutationKey)!==P(o))return!1}else if(!N(t.options.mutationKey,o))return!1}return!(s&&t.state.status!==s||n&&!n(t))}function C(e,t){return(t?.queryKeyHashFn||P)(e)}function P(e){return JSON.stringify(e,(e,t)=>L(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function N(e,t){return e===t||typeof e==typeof t&&!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every(r=>N(e[r],t[r]))}var D=Object.prototype.hasOwnProperty;function _(e,t,r=0){if(e===t)return e;if(r>500)return t;const s=q(e)&&q(t);if(!(s||L(e)&&L(t)))return t;const n=(s?e:Object.keys(e)).length,o=s?t:Object.keys(t),i=o.length,a=s?new Array(i):{};let c=0;for(let l=0;l<i;l++){const i=s?l:o[l],u=e[i],h=t[i];if(u===h){a[i]=u,(s?l<n:D.call(e,i))&&c++;continue}if(null===u||null===h||"object"!=typeof u||"object"!=typeof h){a[i]=h;continue}const d=_(u,h,r+1);a[i]=d,d===u&&c++}return n===i&&c===n?e:a}function x(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function q(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function L(e){if(!U(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!!U(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function U(e){return"[object Object]"===Object.prototype.toString.call(e)}function M(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?_(e,t):t}function F(e,t,r=0){const s=[...e,t];return r&&s.length>r?s.slice(1):s}function k(e,t,r=0){const s=[t,...e];return r&&s.length>r?s.slice(0,-1):s}var j=/* @__PURE__ */Symbol();function G(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==j?e.queryFn:()=>Promise.reject(/* @__PURE__ */new Error(`Missing queryFn: '${e.queryHash}'`))}function $(e,t){return"function"==typeof e?e(...t):!!e}function V(e,t,r){let s,n=!1;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??=t(),n||(n=!0,s.aborted?r():s.addEventListener("abort",r,{once:!0})),s)}),e}var Q=/* @__PURE__ */(()=>{let e=()=>b;return{isServer:()=>e(),setIsServer(t){e=t}}})();function H(){let e,t;const r=new Promise((r,s)=>{e=r,t=s});function s(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{s({status:"fulfilled",value:t}),e(t)},r.reject=e=>{s({status:"rejected",reason:e}),t(e)},r}var W=function(e){setTimeout(e,0)},z=function(){let e=[],t=0,r=e=>{e()},s=e=>{e()},n=W;const o=s=>{t?e.push(s):n(()=>{r(s)})};return{batch:o=>{let i;t++;try{i=o()}finally{t--,t||(()=>{const t=e;e=[],t.length&&n(()=>{s(()=>{t.forEach(e=>{r(e)})})})})()}return i},batchCalls:e=>(...t)=>{o(()=>{e(...t)})},schedule:o,setNotifyFunction:e=>{r=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{n=e}}}(),B=new class extends y{#o=!0;#t;#r;constructor(){super(),this.#r=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#o!==e&&(this.#o=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#o}};function Z(e){return Math.min(1e3*2**e,3e4)}function K(e){return"online"!==(e??"online")||B.isOnline()}var J=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Y(e){let t,r=!1,s=0;const n=H(),o=()=>"pending"!==n.status,i=()=>m.isFocused()&&("always"===e.networkMode||B.isOnline())&&e.canRun(),a=()=>K(e.networkMode)&&e.canRun(),c=e=>{o()||(t?.(),n.resolve(e))},l=e=>{o()||(t?.(),n.reject(e))},u=()=>new Promise(r=>{t=e=>{(o()||i())&&r(e)},e.onPause?.()}).then(()=>{t=void 0,o()||e.onContinue?.()}),h=()=>{if(o())return;let t;const n=0===s?e.initialPromise:void 0;try{t=n??e.fn()}catch(a){t=Promise.reject(a)}Promise.resolve(t).then(c).catch(t=>{if(o())return;const n=e.retry??(Q.isServer()?0:3),a=e.retryDelay??Z,c="function"==typeof a?a(s,t):a,d=!0===n||"number"==typeof n&&s<n||"function"==typeof n&&n(s,t);var p;!r&&d?(s++,e.onFail?.(s,t),(p=c,new Promise(e=>{w.setTimeout(e,p)})).then(()=>i()?void 0:u()).then(()=>{r?l(t):h()})):l(t)})};return{promise:n,status:()=>n.status,cancel:t=>{if(!o()){const r=new J(t);l(r),e.onCancel?.(r)}},continue:()=>(t?.(),n),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:a,start:()=>(a()?h():u().then(h),n)}}var X=class{#i;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),R(this.gcTime)&&(this.#i=w.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Q.isServer()?1/0:3e5))}clearGcTimeout(){void 0!==this.#i&&(w.clearTimeout(this.#i),this.#i=void 0)}},ee=class extends X{#a;#c;#l;#u;#h;#d;#p;constructor(e){super(),this.#p=!1,this.#d=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#u=e.client,this.#l=this.#u.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#a=se(this.options),this.state=e.state??this.#a,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#h?.promise}setOptions(e){if(this.options={...this.#d,...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){const e=se(this.options);void 0!==e.data&&(this.setState(re(e.data,e.dataUpdatedAt)),this.#a=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#l.remove(this)}setData(e,t){const r=M(this.state.data,e,this.options);return this.#f({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#f({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#h?.promise;return this.#h?.cancel(e),t?t.then(v).catch(v):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#a}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>!1!==O(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===j||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===T(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!S(this.state.dataUpdatedAt,e))}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#h?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#h?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#l.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#h&&(this.#p||this.#y()?this.#h.cancel({revert:!0}):this.#h.cancelRetry()),this.scheduleGc()),this.#l.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#y(){return"paused"===this.state.fetchStatus&&"pending"===this.state.status}invalidate(){this.state.isInvalidated||this.#f({type:"invalidate"})}async fetch(e,t){if("idle"!==this.state.fetchStatus&&"rejected"!==this.#h?.status())if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#h)return this.#h.continueRetry(),this.#h.promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}const r=new AbortController,s=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#p=!0,r.signal)})},n=()=>{const e=G(this.options,t),r=(()=>{const e={client:this.#u,queryKey:this.queryKey,meta:this.meta};return s(e),e})();return this.#p=!1,this.options.persister?this.options.persister(e,r,this):e(r)},o=(()=>{const e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#u,state:this.state,fetchFn:n};return s(e),e})();this.options.behavior?.onFetch(o,this),this.#c=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===o.fetchOptions?.meta||this.#f({type:"fetch",meta:o.fetchOptions?.meta}),this.#h=Y({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:e=>{e instanceof J&&e.revert&&this.setState({...this.#c,fetchStatus:"idle"}),r.abort()},onFail:(e,t)=>{this.#f({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#f({type:"pause"})},onContinue:()=>{this.#f({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const e=await this.#h.start();if(void 0===e)throw new Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#l.config.onSuccess?.(e,this),this.#l.config.onSettled?.(e,this.state.error,this),e}catch(i){if(i instanceof J){if(i.silent)return this.#h.promise;if(i.revert){if(void 0===this.state.data)throw i;return this.state.data}}throw this.#f({type:"error",error:i}),this.#l.config.onError?.(i,this),this.#l.config.onSettled?.(this.state.data,i,this),i}finally{this.scheduleGc()}}#f(e){this.state=(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,...te(t.data,this.options),fetchMeta:e.meta??null};case"success":const r={...t,...re(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#c=e.manual?r:void 0,r;case"error":const s=e.error;return{...t,error:s,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),z.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#l.notify({query:this,type:"updated",action:e})})}};function te(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:K(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function re(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function se(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,s=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var ne=class extends y{constructor(e,t){super(),this.options=t,this.#u=e,this.#m=null,this.#g=H(),this.bindMethods(),this.setOptions(t)}#u;#w=void 0;#b=void 0;#v=void 0;#E;#R;#g;#m;#S;#T;#O;#A;#I;#C;#P=/* @__PURE__ */new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#w.addObserver(this),oe(this.#w,this.options)?this.#N():this.updateResult(),this.#D())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ie(this.#w,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ie(this.#w,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=/* @__PURE__ */new Set,this.#_(),this.#x(),this.#w.removeObserver(this)}setOptions(e){const t=this.options,r=this.#w;if(this.options=this.#u.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof O(this.options.enabled,this.#w))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#q(),this.#w.setOptions(this.options),t._defaulted&&!x(this.options,t)&&this.#u.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#w,observer:this});const s=this.hasListeners();s&&ae(this.#w,r,this.options,t)&&this.#N(),this.updateResult(),!s||this.#w===r&&O(this.options.enabled,this.#w)===O(t.enabled,this.#w)&&T(this.options.staleTime,this.#w)===T(t.staleTime,this.#w)||this.#L();const n=this.#U();!s||this.#w===r&&O(this.options.enabled,this.#w)===O(t.enabled,this.#w)&&n===this.#C||this.#M(n)}getOptimisticResult(e){const t=this.#u.getQueryCache().build(this.#u,e),r=this.createResult(t,e);var s;return s=r,x(this.getCurrentResult(),s)||(this.#v=r,this.#R=this.options,this.#E=this.#w.state),r}getCurrentResult(){return this.#v}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#g.status||this.#g.reject(/* @__PURE__ */new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#P.add(e)}getCurrentQuery(){return this.#w}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#u.defaultQueryOptions(e),r=this.#u.getQueryCache().build(this.#u,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#N({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#v))}#N(e){this.#q();let t=this.#w.fetch(this.options,e);return e?.throwOnError||(t=t.catch(v)),t}#L(){this.#_();const e=T(this.options.staleTime,this.#w);if(Q.isServer()||this.#v.isStale||!R(e))return;const t=S(this.#v.dataUpdatedAt,e)+1;this.#A=w.setTimeout(()=>{this.#v.isStale||this.updateResult()},t)}#U(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#w):this.options.refetchInterval)??!1}#M(e){this.#x(),this.#C=e,!Q.isServer()&&!1!==O(this.options.enabled,this.#w)&&R(this.#C)&&0!==this.#C&&(this.#I=w.setInterval(()=>{(this.options.refetchIntervalInBackground||m.isFocused())&&this.#N()},this.#C))}#D(){this.#L(),this.#M(this.#U())}#_(){void 0!==this.#A&&(w.clearTimeout(this.#A),this.#A=void 0)}#x(){void 0!==this.#I&&(w.clearInterval(this.#I),this.#I=void 0)}createResult(e,t){const r=this.#w,s=this.options,n=this.#v,o=this.#E,i=this.#R,a=e!==r?e.state:this.#b,{state:c}=e;let l,u={...c},h=!1;if(t._optimisticResults){const n=this.hasListeners(),o=!n&&oe(e,t),i=n&&ae(e,r,t,s);(o||i)&&(u={...u,...te(c.data,e.options)}),"isRestoring"===t._optimisticResults&&(u.fetchStatus="idle")}let{error:d,errorUpdatedAt:p,status:f}=u;l=u.data;let y=!1;if(void 0!==t.placeholderData&&void 0===l&&"pending"===f){let e;n?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(e=n.data,y=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#O?.state.data,this.#O):t.placeholderData,void 0!==e&&(f="success",l=M(n?.data,e,t),h=!0)}if(t.select&&void 0!==l&&!y)if(n&&l===o?.data&&t.select===this.#S)l=this.#T;else try{this.#S=t.select,l=t.select(l),l=M(n?.data,l,t),this.#T=l,this.#m=null}catch(R){this.#m=R}this.#m&&(d=this.#m,l=this.#T,p=Date.now(),f="error");const m="fetching"===u.fetchStatus,g="pending"===f,w="error"===f,b=g&&m,v=void 0!==l,E={status:f,fetchStatus:u.fetchStatus,isPending:g,isSuccess:"success"===f,isError:w,isInitialLoading:b,isLoading:b,data:l,dataUpdatedAt:u.dataUpdatedAt,error:d,errorUpdatedAt:p,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>a.dataUpdateCount||u.errorUpdateCount>a.errorUpdateCount,isFetching:m,isRefetching:m&&!g,isLoadingError:w&&!v,isPaused:"paused"===u.fetchStatus,isPlaceholderData:h,isRefetchError:w&&v,isStale:ce(e,t),refetch:this.refetch,promise:this.#g,isEnabled:!1!==O(t.enabled,e)};if(this.options.experimental_prefetchInRender){const t=void 0!==E.data,s="error"===E.status&&!t,n=e=>{s?e.reject(E.error):t&&e.resolve(E.data)},o=()=>{n(this.#g=E.promise=H())},i=this.#g;switch(i.status){case"pending":e.queryHash===r.queryHash&&n(i);break;case"fulfilled":(s||E.data!==i.value)&&o();break;case"rejected":s&&E.error===i.reason||o()}}return E}updateResult(){const e=this.#v,t=this.createResult(this.#w,this.options);this.#E=this.#w.state,this.#R=this.options,void 0!==this.#E.data&&(this.#O=this.#w),x(t,e)||(this.#v=t,this.#F({listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#P.size)return!0;const s=new Set(r??this.#P);return this.options.throwOnError&&s.add("error"),Object.keys(this.#v).some(t=>{const r=t;return this.#v[r]!==e[r]&&s.has(r)})})()}))}#q(){const e=this.#u.getQueryCache().build(this.#u,this.options);if(e===this.#w)return;const t=this.#w;this.#w=e,this.#b=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#D()}#F(e){z.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#v)}),this.#u.getQueryCache().notify({query:this.#w,type:"observerResultsUpdated"})})}};function oe(e,t){return function(e,t){return!1!==O(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===t.retryOnMount)}(e,t)||void 0!==e.state.data&&ie(e,t,t.refetchOnMount)}function ie(e,t,r){if(!1!==O(t.enabled,e)&&"static"!==T(t.staleTime,e)){const s="function"==typeof r?r(e):r;return"always"===s||!1!==s&&ce(e,t)}return!1}function ae(e,t,r,s){return(e!==t||!1===O(s.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&ce(e,r)}function ce(e,t){return!1!==O(t.enabled,e)&&e.isStaleByTime(T(t.staleTime,e))}var le=e(void 0),ue=e=>{const t=n(le);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},he=({client:e,children:t})=>(f(()=>(e.mount(),()=>{e.unmount()}),[e]),/* @__PURE__ */d(le.Provider,{value:e,children:t})),de=e(!1);de.Provider;var pe=e(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),fe=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function ye(e,r,o){const a=n(de),c=n(pe),l=ue(o),u=l.defaultQueryOptions(e);l.getDefaultOptions().queries?._experimental_beforeQuery?.(u);const h=l.getQueryCache().get(u.queryHash);u._optimisticResults=a?"isRestoring":"optimistic",(e=>{if(e.suspense){const t=1e3,r=e=>"static"===e?e:Math.max(e??t,t),s=e.staleTime;e.staleTime="function"==typeof s?(...e)=>r(s(...e)):r(s),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,t))}})(u),((e,t,r)=>{const s=r?.state.error&&"function"==typeof e.throwOnError?$(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))})(u,c,h),(e=>{f(()=>{e.clearReset()},[e])})(c);const d=!l.getQueryCache().get(u.queryHash),[p]=s(()=>new r(l,u)),y=p.getOptimisticResult(u),m=!a&&!1!==e.subscribed;if(i(t(e=>{const t=m?p.subscribe(z.batchCalls(e)):v;return p.updateResult(),t},[p,m]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),f(()=>{p.setOptions(u)},[u,p]),((e,t)=>e?.suspense&&t.isPending)(u,y))throw fe(u,p,c);if((({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(n&&void 0===e.data||$(r,[e.error,s])))({result:y,errorResetBoundary:c,throwOnError:u.throwOnError,query:h,suspense:u.suspense}))throw y.error;return l.getDefaultOptions().queries?._experimental_afterQuery?.(u,y),u.experimental_prefetchInRender&&!Q.isServer()&&((e,t)=>e.isLoading&&e.isFetching&&!t)(y,a)&&(d?fe(u,p,c):h?.promise)?.catch(v).finally(()=>{p.updateResult()}),u.notifyOnChangeProps?y:p.trackResult(y)}function me(e,t){return ye(e,ne,t)}var ge=class extends Error{response;request;options;constructor(e,t,r){const s=`${e.status||0===e.status?e.status:""} ${e.statusText??""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}: ${t.method} ${t.url}`),this.name="HTTPError",this.response=e,this.request=t,this.options=r}},we=class extends Error{name="NonError";value;constructor(e){let t="Non-error value was thrown";try{"string"==typeof e?t=e:e&&"object"==typeof e&&"message"in e&&"string"==typeof e.message&&(t=e.message)}catch{}super(t),this.value=e}},be=class extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const t=e?.cause?e.cause instanceof Error?e.cause:new we(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",t?{cause:t}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}},ve=(()=>{let e=!1,t=!1;const r="function"==typeof globalThis.ReadableStream,s="function"==typeof globalThis.Request;if(r&&s)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&"unsupported BodyInit type"===n.message)return!1;throw n}return e&&!t})(),Ee="function"==typeof globalThis.AbortController,Re="function"==typeof globalThis.AbortSignal&&"function"==typeof globalThis.AbortSignal.any,Se="function"==typeof globalThis.ReadableStream,Te="function"==typeof globalThis.FormData,Oe=["get","post","put","patch","head","delete"],Ae={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Ie=(new TextEncoder).encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Ce=Symbol("stop"),Pe=class{options;constructor(e){this.options=e}},Ne=e=>new Pe(e),De={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},_e={next:!0},xe={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},qe=(e,t,r)=>{let s,n=0;return e.pipeThrough(new TransformStream({transform(e,o){if(o.enqueue(e),s){n+=s.byteLength;let e=0===t?0:n/t;e>=1&&(e=1-Number.EPSILON),r?.({percent:e,totalBytes:Math.max(t,n),transferredBytes:n},s)}s=e},flush(){s&&(n+=s.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},s))}}))},Le=e=>null!==e&&"object"==typeof e,Ue=(...e)=>{for(const t of e)if((!Le(t)||Array.isArray(t))&&void 0!==t)throw new TypeError("The `options` argument must be an object");return Ge({},...e)},Me=(e={},t={})=>{const r=new globalThis.Headers(e),s=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(const[o,i]of n.entries())s&&"undefined"===i||void 0===i?r.delete(o):r.set(o,i);return r};function Fe(e,t,r){return Object.hasOwn(t,r)&&void 0===t[r]?[]:Ge(e[r]??[],t[r]??[])}var ke=(e={},t={})=>({beforeRequest:Fe(e,t,"beforeRequest"),beforeRetry:Fe(e,t,"beforeRetry"),afterResponse:Fe(e,t,"afterResponse"),beforeError:Fe(e,t,"beforeError")}),je=(e,t)=>{const r=new URLSearchParams;for(const s of[e,t])if(void 0!==s)if(s instanceof URLSearchParams)for(const[e,t]of s.entries())r.append(e,t);else if(Array.isArray(s))for(const e of s){if(!Array.isArray(e)||2!==e.length)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");r.append(String(e[0]),String(e[1]))}else if(Le(s))for(const[e,t]of Object.entries(s))void 0!==t&&r.append(e,String(t));else{const e=new URLSearchParams(s);for(const[t,s]of e.entries())r.append(t,s)}return r},Ge=(...e)=>{let t,r={},s={},n={};const o=[];for(const i of e)if(Array.isArray(i))Array.isArray(r)||(r=[]),r=[...r,...i];else if(Le(i)){for(let[e,s]of Object.entries(i))if("signal"===e&&s instanceof globalThis.AbortSignal)o.push(s);else if("context"!==e)"searchParams"!==e?(Le(s)&&e in r&&(s=Ge(r[e],s)),r={...r,[e]:s}):t=null==s?void 0:void 0===t?s:je(t,s);else{if(null!=s&&(!Le(s)||Array.isArray(s)))throw new TypeError("The `context` option must be an object");r={...r,context:null==s?{}:{...r.context,...s}}}Le(i.hooks)&&(n=ke(n,i.hooks),r.hooks=n),Le(i.headers)&&(s=Me(s,i.headers),r.headers=s)}return void 0!==t&&(r.searchParams=t),o.length>0&&(1===o.length?r.signal=o[0]:r.signal=Re?AbortSignal.any(o):o.at(-1)),r},$e=e=>Oe.includes(e)?e.toUpperCase():e,Ve={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},Qe=(e={})=>{if("number"==typeof e)return{...Ve,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.methods&&=e.methods.map(e=>e.toLowerCase()),e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");const t=Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e));return{...Ve,...t}},He=class extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}},We=class e{static create(t,r){const s=new e(t,r),n=s.#k(async()=>{if("number"==typeof s.#j.timeout&&s.#j.timeout>2147483647)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let e=await s.#G();for(const r of s.#j.hooks.afterResponse){const n=s.#$(e.clone());let o;try{o=await r(s.request,s.#V(),n,{retryCount:s.#Q})}catch(t){throw s.#H(n),s.#H(e),t}if(o instanceof Pe)throw s.#H(n),s.#H(e),new be(o.options);const i=o instanceof globalThis.Response?o:e;n!==i&&s.#H(n),e!==i&&s.#H(e),e=i}if(s.#$(e),!e.ok&&("function"==typeof s.#j.throwHttpErrors?s.#j.throwHttpErrors(e.status):s.#j.throwHttpErrors)){let t=new ge(e,s.request,s.#V());for(const e of s.#j.hooks.beforeError)t=await e(t,{retryCount:s.#Q});throw t}if(s.#j.onDownloadProgress){if("function"!=typeof s.#j.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!Se)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const t=e.clone();return s.#H(e),((e,t)=>{if(!e.body)return e;if(204===e.status)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});const r=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(qe(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})})(t,s.#j.onDownloadProgress)}return e}).finally(()=>{const e=s.#W;s.#z(e?.body??void 0),s.#z(s.request.body??void 0)});for(const[e,o]of Object.entries(Ae))"bytes"===e&&"function"!=typeof globalThis.Response?.prototype?.bytes||(n[e]=async()=>{s.request.headers.set("accept",s.request.headers.get("accept")||o);const t=await n;if("json"===e){if(204===t.status)return"";const e=await t.text();return""===e?"":r.parseJson?r.parseJson(e):JSON.parse(e)}return t[e]()});return n}static#B(e){return!e||"object"!=typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}request;#Z;#Q=0;#K;#j;#W;#J;#Y;constructor(t,r={}){if(this.#K=t,this.#j={...r,headers:Me(this.#K.headers,r.headers),hooks:ke({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:$e(r.method??this.#K.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Qe(r.retry),throwHttpErrors:r.throwHttpErrors??!0,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis),context:r.context??{}},"string"!=typeof this.#K&&!(this.#K instanceof URL||this.#K instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#j.prefixUrl&&"string"==typeof this.#K){if(this.#K.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#j.prefixUrl.endsWith("/")||(this.#j.prefixUrl+="/"),this.#K=this.#j.prefixUrl+this.#K}Ee&&Re&&(this.#J=this.#j.signal??this.#K.signal,this.#Z=new globalThis.AbortController,this.#j.signal=this.#J?AbortSignal.any([this.#J,this.#Z.signal]):this.#Z.signal),ve&&(this.#j.duplex="half"),void 0!==this.#j.json&&(this.#j.body=this.#j.stringifyJson?.(this.#j.json)??JSON.stringify(this.#j.json),this.#j.headers.set("content-type",this.#j.headers.get("content-type")??"application/json"));const s=r.headers&&new globalThis.Headers(r.headers).has("content-type");if(this.#K instanceof globalThis.Request&&(Te&&this.#j.body instanceof globalThis.FormData||this.#j.body instanceof URLSearchParams)&&!s&&this.#j.headers.delete("content-type"),this.request=new globalThis.Request(this.#K,this.#j),void 0!==(n=this.#j.searchParams)&&(Array.isArray(n)?n.length>0:n instanceof URLSearchParams?n.size>0:"object"==typeof n?Object.keys(n).length>0:"string"==typeof n?n.trim().length>0:Boolean(n))){const t="?"+("string"==typeof this.#j.searchParams?this.#j.searchParams.replace(/^\?/,""):new URLSearchParams(e.#B(this.#j.searchParams)).toString()),r=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,t);this.request=new globalThis.Request(r,this.#j)}var n;if(this.#j.onUploadProgress){if("function"!=typeof this.#j.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");if(!ve)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#X(this.request,this.#j.body??void 0)}}#ee(){const e=this.#j.retry.delay(this.#Q);let t=e;!0===this.#j.retry.jitter?t=Math.random()*e:"function"==typeof this.#j.retry.jitter&&(t=this.#j.retry.jitter(e),(!Number.isFinite(t)||t<0)&&(t=e));const r=this.#j.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(r,t)}async#te(e){if(this.#Q++,this.#Q>this.#j.retry.limit)throw e;const t=e instanceof Error?e:new we(e);if(t instanceof be)return t.customDelay??this.#ee();if(!this.#j.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(void 0!==this.#j.retry.shouldRetry){const r=await this.#j.retry.shouldRetry({error:t,retryCount:this.#Q});if(!1===r)throw e;if(!0===r)return this.#ee()}if(function(e){return e instanceof He||e?.name===He.name}(e)&&!this.#j.retry.retryOnTimeout)throw e;if(function(e){return e instanceof ge||e?.name===ge.name}(e)){if(!this.#j.retry.statusCodes.includes(e.response.status))throw e;const t=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(t&&this.#j.retry.afterStatusCodes.includes(e.response.status)){let e=1e3*Number(t);Number.isNaN(e)?e=Date.parse(t)-Date.now():e>=Date.parse("2024-01-01")&&(e-=Date.now());const r=this.#j.retry.maxRetryAfter??e;return e<r?e:r}if(413===e.response.status)throw e}return this.#ee()}#$(e){return this.#j.parseJson&&(e.json=async()=>this.#j.parseJson(await e.text())),e}#z(e){e&&e.cancel().catch(()=>{})}#H(e){this.#z(e.body??void 0)}async#k(e){try{return await e()}catch(t){const r=Math.min(await this.#te(t),2147483647);if(this.#Q<1)throw t;if(await async function(e,{signal:t}){return new Promise((r,s)=>{function n(){clearTimeout(o),s(t.reason)}t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));const o=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}(r,this.#J?{signal:this.#J}:{}),t instanceof be&&t.customRequest){const e=this.#j.signal?new globalThis.Request(t.customRequest,{signal:this.#j.signal}):new globalThis.Request(t.customRequest);this.#re(e)}for(const e of this.#j.hooks.beforeRetry){const r=await e({request:this.request,options:this.#V(),error:t,retryCount:this.#Q});if(r instanceof globalThis.Request){this.#re(r);break}if(r instanceof globalThis.Response)return r;if(r===Ce)return}return this.#k(e)}}async#G(){this.#Z?.signal.aborted&&(this.#Z=new globalThis.AbortController,this.#j.signal=this.#J?AbortSignal.any([this.#J,this.#Z.signal]):this.#Z.signal,this.request=new globalThis.Request(this.request,{signal:this.#j.signal}));for(const t of this.#j.hooks.beforeRequest){const e=await t(this.request,this.#V(),{retryCount:this.#Q});if(e instanceof Response)return e;if(e instanceof globalThis.Request){this.#re(e);break}}const e=((e,t)=>{const r={};for(const s in t)Object.hasOwn(t,s)&&(s in xe||s in De||s in e&&!(s in _e)||(r[s]=t[s]));return r})(this.request,this.#j);return this.#W=this.request,this.request=this.#W.clone(),!1===this.#j.timeout?this.#j.fetch(this.#W,e):async function(e,t,r,s){return new Promise((n,o)=>{const i=setTimeout(()=>{r&&r.abort(),o(new He(e))},s.timeout);s.fetch(e,t).then(n).catch(o).then(()=>{clearTimeout(i)})})}(this.#W,e,this.#Z,this.#j)}#V(){if(!this.#Y){const{hooks:e,...t}=this.#j;this.#Y=Object.freeze(t)}return this.#Y}#re(e){this.#Y=void 0,this.request=this.#X(e)}#X(e,t){return this.#j.onUploadProgress&&e.body?((e,t,r)=>{if(!e.body)return e;const s=(e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[r,s]of e)t+=Ie,t+=(new TextEncoder).encode(`Content-Disposition: form-data; name="${r}"`).length,t+="string"==typeof s?(new TextEncoder).encode(s).length:s.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if("string"==typeof e)return(new TextEncoder).encode(e).length;if(e instanceof URLSearchParams)return(new TextEncoder).encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if("object"==typeof e&&null!==e)try{const t=JSON.stringify(e);return(new TextEncoder).encode(t).length}catch{return 0}return 0})(r??e.body);return new Request(e,{duplex:"half",body:qe(e.body,s,t)})})(e,this.#j.onUploadProgress,t??this.#j.body??void 0):e}},ze=e=>{const t=(t,r)=>We.create(t,Ue(e,r));for(const r of Oe)t[r]=(t,s)=>We.create(t,Ue(e,s,{method:r}));return t.create=e=>ze(Ue(e)),t.extend=t=>("function"==typeof t&&(t=t(e??{})),ze(Ue(e,t))),t.stop=Ce,t.retry=Ne,t},Be=ze(),Ze={PUBLIC_EVENTS:"/",FOLDER_EVENTS:e=>`/${e}`,LOGIN:"/auth/login",REGISTER:"/auth/register",FORGOT_PASSWORD:"/auth/forgot-password",RESET_PASSWORD:"/auth/reset-password",VERIFY_EMAIL:"/auth/verify-email",GALLERY:e=>`/event/${e}`,UPLOAD:e=>`/event/${e}/upload`,CURATE:e=>`/event/${e}/curate`,LEADERBOARD:e=>`/event/${e}/leaderboard`},Ke={ORGANIZATION_SETTINGS:e=>`https://qrati.com/org/${e}/settings`,ORGANIZATION_SETTINGS_INTEGRATION:e=>`https://qrati.com/org/${e}/settings/integration`,ORGANIZATION_DASHBOARD:e=>`https://qrati.com/org/${e}/dashboard`,ORGANIZATION_ADMINS:e=>`https://qrati.com/org/${e}/admins`,EVENT_SETTINGS_BASIC_DETAILS:e=>`https://qrati.com/event/${e}/settings`,EVENT_REVIEW_CONTENTS:e=>`https://qrati.com/event/${e}/review-contents`,EVENT_DEEP_SEARCH:e=>`https://qrati.com/event/${e}/deep-search`,EVENT_GENERATE_ARTICLE:e=>`https://qrati.com/event/${e}/generate-article`,EVENT_ACCESS_REQUESTS:e=>`https://qrati.com/event/${e}/access-requests`,EVENT_SHOT_INSPECTOR:e=>`https://qrati.com/event/${e}/shot-inspector`,EVENT_CURATION_DETAILS:e=>`https://qrati.com/event/${e}/curation-details`},Je={PUBLIC:"PUBLIC",PRIVATE:"PRIVATE",SECRET:"SECRET"},Ye="https://qrati.com/api/connect",Xe={INITIALIZE_SESSION:`${Ye}/session/initialize`,REGISTER:`${Ye}/auth/register`,LOGIN:`${Ye}/auth/login`,LOGOUT:`${Ye}/auth/logout`,UPDATE_SESSION:`${Ye}/session/update`,ACCEPT_TERMS:`${Ye}/auth/accept-terms`,EXTERNAL_LOGIN:`${Ye}/auth/external-login`,PUBLIC_EVENTS:`${Ye}/event/public-events`,SEARCH_EVENTS:`${Ye}/event/search`,FOLDER_DETAILS:`${Ye}/folder/details`,NESTED_FOLDERS:`${Ye}/folder/nested-folders`,GET_EVENT_POINTS:`${Ye}/event/points`,ELIGIBLE_TO_CURATE:`${Ye}/content/curation-eligibility`,CONTENT_FOR_CURATION:`${Ye}/content/for-curation`,CURATE_CONTENT:`${Ye}/content/curate`,GET_LEADERBOARD:`${Ye}/event/leaderboard`,GET_UPLOAD_COUNT:`${Ye}/event/upload-count`,SINGLE_UPLOAD:`${Ye}/content/single-upload`,UPDATE_REACTION:`${Ye}/content/update-reaction`,EVENT_DATA:`${Ye}/event/details-with-ads-parameters`,UPDATE_EVENT_LAYOUT:`${Ye}/event/update-layout`,GET_EVENT_STATISTICS:`${Ye}/event/statistics`,GET_CONTENTS:`${Ye}/content/for-gallery`,SEARCH_CONTENTS:`${Ye}/content/search`,GET_CONTENTS_COUNT:`${Ye}/content/count`,UPDATE_AD_ANALYTICS:`${Ye}/event/update-ad-analytics`,UPDATE_GAM_ANALYTICS:`${Ye}/event/update-gam-analytics`,INCREMENT_EVENT_VIEW:`${Ye}/event/increment-view`,SEND_PASSWORD_RESET_CODE:`${Ye}/auth/send-password-reset-code`,VERIFY_PASSWORD_RESET_CODE:`${Ye}/auth/verify-password-reset-code`,RESET_PASSWORD:`${Ye}/auth/reset-password`,REPORT_ERROR:`${Ye}/session/report-error`},et={OWNER:"owner",ADMIN:"admin",MODERATOR:"moderator"},tt={IMAGE:"IMAGE",VIDEO:"VIDEO",AD:"AD",GAM_AD:"GAM_AD"},rt={GAM_IMPRESSION:"gam_impression",GAM_VIEWABLE:"gam_viewable",GAM_CLICK:"gam_click"},st={ROW:"ROW",COLUMN:"COLUMN",MASONRY:"MASONRY"},nt={IN_REVIEW:"IN_REVIEW",APPROVED:"APPROVED",REJECTED:"REJECTED"},ot={WAITING:"Waiting",UPLOADING:"Uploading",RETRYING:"Retrying",DONE:"Done",FAILED:"Failed",ERROR:"Error"},it=1048576,at={CLOSED:"CLOSED",OPEN:"OPEN",UPCOMING:"UPCOMING"},ct={WAITING:"Waiting",PROCESSING:"Processing",DONE:"Done"},lt={TEXT:"text",IMAGE:"image",LOTTIE:"lottie"},ut={CONTEST:"CONTEST",REACTION:"REACTION"},ht={GRID:"grid",SINGLE:"single"},dt={POPULAR:"popular",UPLOAD_TIME:"upload",CAPTURE_TIME:"capture"},pt={[dt.POPULAR]:{label:"Popular",sortField:"score"},[dt.UPLOAD_TIME]:{label:"Uploaded",sortField:"createdAt"},[dt.CAPTURE_TIME]:{label:"Captured",sortField:"capturedAt"}},ft="map-view-state",yt=dt.UPLOAD_TIME,mt={ASC:"asc",DESC:"desc"},gt={[mt.ASC]:{label:"Ascending",sortOrder:""},[mt.DESC]:{label:"Descending",sortOrder:"-"}},wt=mt.DESC,bt={OWN:"own",CURATED:"curated",ELIGIBLE:"eligible"},vt={NONE:null,LINK:"LINK",EMAIL:"EMAIL",PHONE:"PHONE",SMS:"SMS",WHATSAPP:"WHATSAPP",MESSENGER:"MESSENGER"},Et={[vt.LINK]:"material-symbols:open-in-new-rounded",[vt.EMAIL]:"material-symbols:alternate-email-rounded",[vt.PHONE]:"material-symbols:call-outline",[vt.SMS]:"material-symbols:sms-outline-rounded",[vt.WHATSAPP]:"logos:whatsapp-icon",[vt.MESSENGER]:"logos:messenger"},Rt={AD_IMPRESSION:"impression",AD_ENGAGEMENT:"engagement",AD_CLICK:"click"},St={QRATI_CONNECT_SESSION:"qrati-connect-session",EVENT_IN_REVIEW_COUNT:e=>`in-review-count-${e}`,CONTENTS_BY_EVENT:e=>`contents-by-event-${e}`};function Tt({title:e,children:t}){/* @__PURE__ */
1
+ import{G as e,L as t,M as r,P as s,R as n,_ as o,b as i,f as a,g as c,h as l,j as u,p as h,v as d,w as p,z as f}from"./MZuQhFbV.js";var y=class{constructor(){this.listeners=/* @__PURE__ */new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},m=new class extends y{#e;#t;#r;constructor(){super(),this.#r=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#e?this.#e:"hidden"!==globalThis.document?.visibilityState}},g={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},w=new class{#s=g;#n=!1;setTimeoutProvider(e){this.#s=e}setTimeout(e,t){return this.#s.setTimeout(e,t)}clearTimeout(e){this.#s.clearTimeout(e)}setInterval(e,t){return this.#s.setInterval(e,t)}clearInterval(e){this.#s.clearInterval(e)}},b="undefined"==typeof window||"Deno"in globalThis;function v(){}function E(e,t){return"function"==typeof e?e(t):e}function R(e){return"number"==typeof e&&e>=0&&e!==1/0}function S(e,t){return Math.max(e+(t||0)-Date.now(),0)}function T(e,t){return"function"==typeof e?e(t):e}function O(e,t){return"function"==typeof e?e(t):e}function A(e,t){const{type:r="all",exact:s,fetchStatus:n,predicate:o,queryKey:i,stale:a}=e;if(i)if(s){if(t.queryHash!==C(i,t.options))return!1}else if(!N(t.queryKey,i))return!1;if("all"!==r){const e=t.isActive();if("active"===r&&!e)return!1;if("inactive"===r&&e)return!1}return!("boolean"==typeof a&&t.isStale()!==a||n&&n!==t.state.fetchStatus||o&&!o(t))}function I(e,t){const{exact:r,status:s,predicate:n,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(r){if(P(t.options.mutationKey)!==P(o))return!1}else if(!N(t.options.mutationKey,o))return!1}return!(s&&t.state.status!==s||n&&!n(t))}function C(e,t){return(t?.queryKeyHashFn||P)(e)}function P(e){return JSON.stringify(e,(e,t)=>L(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function N(e,t){return e===t||typeof e==typeof t&&!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every(r=>N(e[r],t[r]))}var D=Object.prototype.hasOwnProperty;function _(e,t,r=0){if(e===t)return e;if(r>500)return t;const s=q(e)&&q(t);if(!(s||L(e)&&L(t)))return t;const n=(s?e:Object.keys(e)).length,o=s?t:Object.keys(t),i=o.length,a=s?new Array(i):{};let c=0;for(let l=0;l<i;l++){const i=s?l:o[l],u=e[i],h=t[i];if(u===h){a[i]=u,(s?l<n:D.call(e,i))&&c++;continue}if(null===u||null===h||"object"!=typeof u||"object"!=typeof h){a[i]=h;continue}const d=_(u,h,r+1);a[i]=d,d===u&&c++}return n===i&&c===n?e:a}function x(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function q(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function L(e){if(!U(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!!U(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function U(e){return"[object Object]"===Object.prototype.toString.call(e)}function M(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?_(e,t):t}function F(e,t,r=0){const s=[...e,t];return r&&s.length>r?s.slice(1):s}function k(e,t,r=0){const s=[t,...e];return r&&s.length>r?s.slice(0,-1):s}var j=/* @__PURE__ */Symbol();function $(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==j?e.queryFn:()=>Promise.reject(/* @__PURE__ */new Error(`Missing queryFn: '${e.queryHash}'`))}function G(e,t){return"function"==typeof e?e(...t):!!e}function V(e,t,r){let s,n=!1;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??=t(),n||(n=!0,s.aborted?r():s.addEventListener("abort",r,{once:!0})),s)}),e}var Q=/* @__PURE__ */(()=>{let e=()=>b;return{isServer:()=>e(),setIsServer(t){e=t}}})();function H(){let e,t;const r=new Promise((r,s)=>{e=r,t=s});function s(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{s({status:"fulfilled",value:t}),e(t)},r.reject=e=>{s({status:"rejected",reason:e}),t(e)},r}var W=function(e){setTimeout(e,0)},z=function(){let e=[],t=0,r=e=>{e()},s=e=>{e()},n=W;const o=s=>{t?e.push(s):n(()=>{r(s)})};return{batch:o=>{let i;t++;try{i=o()}finally{t--,t||(()=>{const t=e;e=[],t.length&&n(()=>{s(()=>{t.forEach(e=>{r(e)})})})})()}return i},batchCalls:e=>(...t)=>{o(()=>{e(...t)})},schedule:o,setNotifyFunction:e=>{r=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{n=e}}}(),B=new class extends y{#o=!0;#t;#r;constructor(){super(),this.#r=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#o!==e&&(this.#o=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#o}};function Z(e){return Math.min(1e3*2**e,3e4)}function K(e){return"online"!==(e??"online")||B.isOnline()}var J=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Y(e){let t,r=!1,s=0;const n=H(),o=()=>"pending"!==n.status,i=()=>m.isFocused()&&("always"===e.networkMode||B.isOnline())&&e.canRun(),a=()=>K(e.networkMode)&&e.canRun(),c=e=>{o()||(t?.(),n.resolve(e))},l=e=>{o()||(t?.(),n.reject(e))},u=()=>new Promise(r=>{t=e=>{(o()||i())&&r(e)},e.onPause?.()}).then(()=>{t=void 0,o()||e.onContinue?.()}),h=()=>{if(o())return;let t;const n=0===s?e.initialPromise:void 0;try{t=n??e.fn()}catch(a){t=Promise.reject(a)}Promise.resolve(t).then(c).catch(t=>{if(o())return;const n=e.retry??(Q.isServer()?0:3),a=e.retryDelay??Z,c="function"==typeof a?a(s,t):a,d=!0===n||"number"==typeof n&&s<n||"function"==typeof n&&n(s,t);var p;!r&&d?(s++,e.onFail?.(s,t),(p=c,new Promise(e=>{w.setTimeout(e,p)})).then(()=>i()?void 0:u()).then(()=>{r?l(t):h()})):l(t)})};return{promise:n,status:()=>n.status,cancel:t=>{if(!o()){const r=new J(t);l(r),e.onCancel?.(r)}},continue:()=>(t?.(),n),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:a,start:()=>(a()?h():u().then(h),n)}}var X=class{#i;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),R(this.gcTime)&&(this.#i=w.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Q.isServer()?1/0:3e5))}clearGcTimeout(){void 0!==this.#i&&(w.clearTimeout(this.#i),this.#i=void 0)}},ee=class extends X{#a;#c;#l;#u;#h;#d;#p;constructor(e){super(),this.#p=!1,this.#d=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#u=e.client,this.#l=this.#u.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#a=se(this.options),this.state=e.state??this.#a,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#h?.promise}setOptions(e){if(this.options={...this.#d,...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){const e=se(this.options);void 0!==e.data&&(this.setState(re(e.data,e.dataUpdatedAt)),this.#a=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#l.remove(this)}setData(e,t){const r=M(this.state.data,e,this.options);return this.#f({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#f({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#h?.promise;return this.#h?.cancel(e),t?t.then(v).catch(v):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#a}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>!1!==O(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===j||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===T(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!S(this.state.dataUpdatedAt,e))}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#h?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#h?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#l.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#h&&(this.#p||this.#y()?this.#h.cancel({revert:!0}):this.#h.cancelRetry()),this.scheduleGc()),this.#l.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#y(){return"paused"===this.state.fetchStatus&&"pending"===this.state.status}invalidate(){this.state.isInvalidated||this.#f({type:"invalidate"})}async fetch(e,t){if("idle"!==this.state.fetchStatus&&"rejected"!==this.#h?.status())if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#h)return this.#h.continueRetry(),this.#h.promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}const r=new AbortController,s=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#p=!0,r.signal)})},n=()=>{const e=$(this.options,t),r=(()=>{const e={client:this.#u,queryKey:this.queryKey,meta:this.meta};return s(e),e})();return this.#p=!1,this.options.persister?this.options.persister(e,r,this):e(r)},o=(()=>{const e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#u,state:this.state,fetchFn:n};return s(e),e})();this.options.behavior?.onFetch(o,this),this.#c=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===o.fetchOptions?.meta||this.#f({type:"fetch",meta:o.fetchOptions?.meta}),this.#h=Y({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:e=>{e instanceof J&&e.revert&&this.setState({...this.#c,fetchStatus:"idle"}),r.abort()},onFail:(e,t)=>{this.#f({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#f({type:"pause"})},onContinue:()=>{this.#f({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const e=await this.#h.start();if(void 0===e)throw new Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#l.config.onSuccess?.(e,this),this.#l.config.onSettled?.(e,this.state.error,this),e}catch(i){if(i instanceof J){if(i.silent)return this.#h.promise;if(i.revert){if(void 0===this.state.data)throw i;return this.state.data}}throw this.#f({type:"error",error:i}),this.#l.config.onError?.(i,this),this.#l.config.onSettled?.(this.state.data,i,this),i}finally{this.scheduleGc()}}#f(e){this.state=(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,...te(t.data,this.options),fetchMeta:e.meta??null};case"success":const r={...t,...re(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#c=e.manual?r:void 0,r;case"error":const s=e.error;return{...t,error:s,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),z.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#l.notify({query:this,type:"updated",action:e})})}};function te(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:K(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function re(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function se(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,s=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var ne=class extends y{constructor(e,t){super(),this.options=t,this.#u=e,this.#m=null,this.#g=H(),this.bindMethods(),this.setOptions(t)}#u;#w=void 0;#b=void 0;#v=void 0;#E;#R;#g;#m;#S;#T;#O;#A;#I;#C;#P=/* @__PURE__ */new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#w.addObserver(this),oe(this.#w,this.options)?this.#N():this.updateResult(),this.#D())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ie(this.#w,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ie(this.#w,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=/* @__PURE__ */new Set,this.#_(),this.#x(),this.#w.removeObserver(this)}setOptions(e){const t=this.options,r=this.#w;if(this.options=this.#u.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof O(this.options.enabled,this.#w))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#q(),this.#w.setOptions(this.options),t._defaulted&&!x(this.options,t)&&this.#u.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#w,observer:this});const s=this.hasListeners();s&&ae(this.#w,r,this.options,t)&&this.#N(),this.updateResult(),!s||this.#w===r&&O(this.options.enabled,this.#w)===O(t.enabled,this.#w)&&T(this.options.staleTime,this.#w)===T(t.staleTime,this.#w)||this.#L();const n=this.#U();!s||this.#w===r&&O(this.options.enabled,this.#w)===O(t.enabled,this.#w)&&n===this.#C||this.#M(n)}getOptimisticResult(e){const t=this.#u.getQueryCache().build(this.#u,e),r=this.createResult(t,e);var s;return s=r,x(this.getCurrentResult(),s)||(this.#v=r,this.#R=this.options,this.#E=this.#w.state),r}getCurrentResult(){return this.#v}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#g.status||this.#g.reject(/* @__PURE__ */new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#P.add(e)}getCurrentQuery(){return this.#w}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#u.defaultQueryOptions(e),r=this.#u.getQueryCache().build(this.#u,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#N({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#v))}#N(e){this.#q();let t=this.#w.fetch(this.options,e);return e?.throwOnError||(t=t.catch(v)),t}#L(){this.#_();const e=T(this.options.staleTime,this.#w);if(Q.isServer()||this.#v.isStale||!R(e))return;const t=S(this.#v.dataUpdatedAt,e)+1;this.#A=w.setTimeout(()=>{this.#v.isStale||this.updateResult()},t)}#U(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#w):this.options.refetchInterval)??!1}#M(e){this.#x(),this.#C=e,!Q.isServer()&&!1!==O(this.options.enabled,this.#w)&&R(this.#C)&&0!==this.#C&&(this.#I=w.setInterval(()=>{(this.options.refetchIntervalInBackground||m.isFocused())&&this.#N()},this.#C))}#D(){this.#L(),this.#M(this.#U())}#_(){void 0!==this.#A&&(w.clearTimeout(this.#A),this.#A=void 0)}#x(){void 0!==this.#I&&(w.clearInterval(this.#I),this.#I=void 0)}createResult(e,t){const r=this.#w,s=this.options,n=this.#v,o=this.#E,i=this.#R,a=e!==r?e.state:this.#b,{state:c}=e;let l,u={...c},h=!1;if(t._optimisticResults){const n=this.hasListeners(),o=!n&&oe(e,t),i=n&&ae(e,r,t,s);(o||i)&&(u={...u,...te(c.data,e.options)}),"isRestoring"===t._optimisticResults&&(u.fetchStatus="idle")}let{error:d,errorUpdatedAt:p,status:f}=u;l=u.data;let y=!1;if(void 0!==t.placeholderData&&void 0===l&&"pending"===f){let e;n?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(e=n.data,y=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#O?.state.data,this.#O):t.placeholderData,void 0!==e&&(f="success",l=M(n?.data,e,t),h=!0)}if(t.select&&void 0!==l&&!y)if(n&&l===o?.data&&t.select===this.#S)l=this.#T;else try{this.#S=t.select,l=t.select(l),l=M(n?.data,l,t),this.#T=l,this.#m=null}catch(R){this.#m=R}this.#m&&(d=this.#m,l=this.#T,p=Date.now(),f="error");const m="fetching"===u.fetchStatus,g="pending"===f,w="error"===f,b=g&&m,v=void 0!==l,E={status:f,fetchStatus:u.fetchStatus,isPending:g,isSuccess:"success"===f,isError:w,isInitialLoading:b,isLoading:b,data:l,dataUpdatedAt:u.dataUpdatedAt,error:d,errorUpdatedAt:p,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>a.dataUpdateCount||u.errorUpdateCount>a.errorUpdateCount,isFetching:m,isRefetching:m&&!g,isLoadingError:w&&!v,isPaused:"paused"===u.fetchStatus,isPlaceholderData:h,isRefetchError:w&&v,isStale:ce(e,t),refetch:this.refetch,promise:this.#g,isEnabled:!1!==O(t.enabled,e)};if(this.options.experimental_prefetchInRender){const t=void 0!==E.data,s="error"===E.status&&!t,n=e=>{s?e.reject(E.error):t&&e.resolve(E.data)},o=()=>{n(this.#g=E.promise=H())},i=this.#g;switch(i.status){case"pending":e.queryHash===r.queryHash&&n(i);break;case"fulfilled":(s||E.data!==i.value)&&o();break;case"rejected":s&&E.error===i.reason||o()}}return E}updateResult(){const e=this.#v,t=this.createResult(this.#w,this.options);this.#E=this.#w.state,this.#R=this.options,void 0!==this.#E.data&&(this.#O=this.#w),x(t,e)||(this.#v=t,this.#F({listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#P.size)return!0;const s=new Set(r??this.#P);return this.options.throwOnError&&s.add("error"),Object.keys(this.#v).some(t=>{const r=t;return this.#v[r]!==e[r]&&s.has(r)})})()}))}#q(){const e=this.#u.getQueryCache().build(this.#u,this.options);if(e===this.#w)return;const t=this.#w;this.#w=e,this.#b=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#D()}#F(e){z.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#v)}),this.#u.getQueryCache().notify({query:this.#w,type:"observerResultsUpdated"})})}};function oe(e,t){return function(e,t){return!1!==O(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===t.retryOnMount)}(e,t)||void 0!==e.state.data&&ie(e,t,t.refetchOnMount)}function ie(e,t,r){if(!1!==O(t.enabled,e)&&"static"!==T(t.staleTime,e)){const s="function"==typeof r?r(e):r;return"always"===s||!1!==s&&ce(e,t)}return!1}function ae(e,t,r,s){return(e!==t||!1===O(s.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&ce(e,r)}function ce(e,t){return!1!==O(t.enabled,e)&&e.isStaleByTime(T(t.staleTime,e))}var le=e(void 0),ue=e=>{const t=n(le);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},he=({client:e,children:t})=>(f(()=>(e.mount(),()=>{e.unmount()}),[e]),/* @__PURE__ */d(le.Provider,{value:e,children:t})),de=e(!1);de.Provider;var pe=e(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),fe=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function ye(e,r,o){const a=n(de),c=n(pe),l=ue(o),u=l.defaultQueryOptions(e);l.getDefaultOptions().queries?._experimental_beforeQuery?.(u);const h=l.getQueryCache().get(u.queryHash);u._optimisticResults=a?"isRestoring":"optimistic",(e=>{if(e.suspense){const t=1e3,r=e=>"static"===e?e:Math.max(e??t,t),s=e.staleTime;e.staleTime="function"==typeof s?(...e)=>r(s(...e)):r(s),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,t))}})(u),((e,t,r)=>{const s=r?.state.error&&"function"==typeof e.throwOnError?G(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))})(u,c,h),(e=>{f(()=>{e.clearReset()},[e])})(c);const d=!l.getQueryCache().get(u.queryHash),[p]=s(()=>new r(l,u)),y=p.getOptimisticResult(u),m=!a&&!1!==e.subscribed;if(i(t(e=>{const t=m?p.subscribe(z.batchCalls(e)):v;return p.updateResult(),t},[p,m]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),f(()=>{p.setOptions(u)},[u,p]),((e,t)=>e?.suspense&&t.isPending)(u,y))throw fe(u,p,c);if((({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(n&&void 0===e.data||G(r,[e.error,s])))({result:y,errorResetBoundary:c,throwOnError:u.throwOnError,query:h,suspense:u.suspense}))throw y.error;return l.getDefaultOptions().queries?._experimental_afterQuery?.(u,y),u.experimental_prefetchInRender&&!Q.isServer()&&((e,t)=>e.isLoading&&e.isFetching&&!t)(y,a)&&(d?fe(u,p,c):h?.promise)?.catch(v).finally(()=>{p.updateResult()}),u.notifyOnChangeProps?y:p.trackResult(y)}function me(e,t){return ye(e,ne,t)}var ge=class extends Error{response;request;options;constructor(e,t,r){const s=`${e.status||0===e.status?e.status:""} ${e.statusText??""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}: ${t.method} ${t.url}`),this.name="HTTPError",this.response=e,this.request=t,this.options=r}},we=class extends Error{name="NonError";value;constructor(e){let t="Non-error value was thrown";try{"string"==typeof e?t=e:e&&"object"==typeof e&&"message"in e&&"string"==typeof e.message&&(t=e.message)}catch{}super(t),this.value=e}},be=class extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const t=e?.cause?e.cause instanceof Error?e.cause:new we(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",t?{cause:t}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}},ve=(()=>{let e=!1,t=!1;const r="function"==typeof globalThis.ReadableStream,s="function"==typeof globalThis.Request;if(r&&s)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&"unsupported BodyInit type"===n.message)return!1;throw n}return e&&!t})(),Ee="function"==typeof globalThis.AbortController,Re="function"==typeof globalThis.AbortSignal&&"function"==typeof globalThis.AbortSignal.any,Se="function"==typeof globalThis.ReadableStream,Te="function"==typeof globalThis.FormData,Oe=["get","post","put","patch","head","delete"],Ae={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Ie=(new TextEncoder).encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Ce=Symbol("stop"),Pe=class{options;constructor(e){this.options=e}},Ne=e=>new Pe(e),De={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},_e={next:!0},xe={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},qe=(e,t,r)=>{let s,n=0;return e.pipeThrough(new TransformStream({transform(e,o){if(o.enqueue(e),s){n+=s.byteLength;let e=0===t?0:n/t;e>=1&&(e=1-Number.EPSILON),r?.({percent:e,totalBytes:Math.max(t,n),transferredBytes:n},s)}s=e},flush(){s&&(n+=s.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},s))}}))},Le=e=>null!==e&&"object"==typeof e,Ue=(...e)=>{for(const t of e)if((!Le(t)||Array.isArray(t))&&void 0!==t)throw new TypeError("The `options` argument must be an object");return $e({},...e)},Me=(e={},t={})=>{const r=new globalThis.Headers(e),s=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(const[o,i]of n.entries())s&&"undefined"===i||void 0===i?r.delete(o):r.set(o,i);return r};function Fe(e,t,r){return Object.hasOwn(t,r)&&void 0===t[r]?[]:$e(e[r]??[],t[r]??[])}var ke=(e={},t={})=>({beforeRequest:Fe(e,t,"beforeRequest"),beforeRetry:Fe(e,t,"beforeRetry"),afterResponse:Fe(e,t,"afterResponse"),beforeError:Fe(e,t,"beforeError")}),je=(e,t)=>{const r=new URLSearchParams;for(const s of[e,t])if(void 0!==s)if(s instanceof URLSearchParams)for(const[e,t]of s.entries())r.append(e,t);else if(Array.isArray(s))for(const e of s){if(!Array.isArray(e)||2!==e.length)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");r.append(String(e[0]),String(e[1]))}else if(Le(s))for(const[e,t]of Object.entries(s))void 0!==t&&r.append(e,String(t));else{const e=new URLSearchParams(s);for(const[t,s]of e.entries())r.append(t,s)}return r},$e=(...e)=>{let t,r={},s={},n={};const o=[];for(const i of e)if(Array.isArray(i))Array.isArray(r)||(r=[]),r=[...r,...i];else if(Le(i)){for(let[e,s]of Object.entries(i))if("signal"===e&&s instanceof globalThis.AbortSignal)o.push(s);else if("context"!==e)"searchParams"!==e?(Le(s)&&e in r&&(s=$e(r[e],s)),r={...r,[e]:s}):t=null==s?void 0:void 0===t?s:je(t,s);else{if(null!=s&&(!Le(s)||Array.isArray(s)))throw new TypeError("The `context` option must be an object");r={...r,context:null==s?{}:{...r.context,...s}}}Le(i.hooks)&&(n=ke(n,i.hooks),r.hooks=n),Le(i.headers)&&(s=Me(s,i.headers),r.headers=s)}return void 0!==t&&(r.searchParams=t),o.length>0&&(1===o.length?r.signal=o[0]:r.signal=Re?AbortSignal.any(o):o.at(-1)),r},Ge=e=>Oe.includes(e)?e.toUpperCase():e,Ve={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},Qe=(e={})=>{if("number"==typeof e)return{...Ve,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.methods&&=e.methods.map(e=>e.toLowerCase()),e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");const t=Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e));return{...Ve,...t}},He=class extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}},We=class e{static create(t,r){const s=new e(t,r),n=s.#k(async()=>{if("number"==typeof s.#j.timeout&&s.#j.timeout>2147483647)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let e=await s.#$();for(const r of s.#j.hooks.afterResponse){const n=s.#G(e.clone());let o;try{o=await r(s.request,s.#V(),n,{retryCount:s.#Q})}catch(t){throw s.#H(n),s.#H(e),t}if(o instanceof Pe)throw s.#H(n),s.#H(e),new be(o.options);const i=o instanceof globalThis.Response?o:e;n!==i&&s.#H(n),e!==i&&s.#H(e),e=i}if(s.#G(e),!e.ok&&("function"==typeof s.#j.throwHttpErrors?s.#j.throwHttpErrors(e.status):s.#j.throwHttpErrors)){let t=new ge(e,s.request,s.#V());for(const e of s.#j.hooks.beforeError)t=await e(t,{retryCount:s.#Q});throw t}if(s.#j.onDownloadProgress){if("function"!=typeof s.#j.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!Se)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const t=e.clone();return s.#H(e),((e,t)=>{if(!e.body)return e;if(204===e.status)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});const r=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(qe(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})})(t,s.#j.onDownloadProgress)}return e}).finally(()=>{const e=s.#W;s.#z(e?.body??void 0),s.#z(s.request.body??void 0)});for(const[e,o]of Object.entries(Ae))"bytes"===e&&"function"!=typeof globalThis.Response?.prototype?.bytes||(n[e]=async()=>{s.request.headers.set("accept",s.request.headers.get("accept")||o);const t=await n;if("json"===e){if(204===t.status)return"";const e=await t.text();return""===e?"":r.parseJson?r.parseJson(e):JSON.parse(e)}return t[e]()});return n}static#B(e){return!e||"object"!=typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}request;#Z;#Q=0;#K;#j;#W;#J;#Y;constructor(t,r={}){if(this.#K=t,this.#j={...r,headers:Me(this.#K.headers,r.headers),hooks:ke({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Ge(r.method??this.#K.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Qe(r.retry),throwHttpErrors:r.throwHttpErrors??!0,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis),context:r.context??{}},"string"!=typeof this.#K&&!(this.#K instanceof URL||this.#K instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#j.prefixUrl&&"string"==typeof this.#K){if(this.#K.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#j.prefixUrl.endsWith("/")||(this.#j.prefixUrl+="/"),this.#K=this.#j.prefixUrl+this.#K}Ee&&Re&&(this.#J=this.#j.signal??this.#K.signal,this.#Z=new globalThis.AbortController,this.#j.signal=this.#J?AbortSignal.any([this.#J,this.#Z.signal]):this.#Z.signal),ve&&(this.#j.duplex="half"),void 0!==this.#j.json&&(this.#j.body=this.#j.stringifyJson?.(this.#j.json)??JSON.stringify(this.#j.json),this.#j.headers.set("content-type",this.#j.headers.get("content-type")??"application/json"));const s=r.headers&&new globalThis.Headers(r.headers).has("content-type");if(this.#K instanceof globalThis.Request&&(Te&&this.#j.body instanceof globalThis.FormData||this.#j.body instanceof URLSearchParams)&&!s&&this.#j.headers.delete("content-type"),this.request=new globalThis.Request(this.#K,this.#j),void 0!==(n=this.#j.searchParams)&&(Array.isArray(n)?n.length>0:n instanceof URLSearchParams?n.size>0:"object"==typeof n?Object.keys(n).length>0:"string"==typeof n?n.trim().length>0:Boolean(n))){const t="?"+("string"==typeof this.#j.searchParams?this.#j.searchParams.replace(/^\?/,""):new URLSearchParams(e.#B(this.#j.searchParams)).toString()),r=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,t);this.request=new globalThis.Request(r,this.#j)}var n;if(this.#j.onUploadProgress){if("function"!=typeof this.#j.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");if(!ve)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#X(this.request,this.#j.body??void 0)}}#ee(){const e=this.#j.retry.delay(this.#Q);let t=e;!0===this.#j.retry.jitter?t=Math.random()*e:"function"==typeof this.#j.retry.jitter&&(t=this.#j.retry.jitter(e),(!Number.isFinite(t)||t<0)&&(t=e));const r=this.#j.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(r,t)}async#te(e){if(this.#Q++,this.#Q>this.#j.retry.limit)throw e;const t=e instanceof Error?e:new we(e);if(t instanceof be)return t.customDelay??this.#ee();if(!this.#j.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(void 0!==this.#j.retry.shouldRetry){const r=await this.#j.retry.shouldRetry({error:t,retryCount:this.#Q});if(!1===r)throw e;if(!0===r)return this.#ee()}if(function(e){return e instanceof He||e?.name===He.name}(e)&&!this.#j.retry.retryOnTimeout)throw e;if(function(e){return e instanceof ge||e?.name===ge.name}(e)){if(!this.#j.retry.statusCodes.includes(e.response.status))throw e;const t=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(t&&this.#j.retry.afterStatusCodes.includes(e.response.status)){let e=1e3*Number(t);Number.isNaN(e)?e=Date.parse(t)-Date.now():e>=Date.parse("2024-01-01")&&(e-=Date.now());const r=this.#j.retry.maxRetryAfter??e;return e<r?e:r}if(413===e.response.status)throw e}return this.#ee()}#G(e){return this.#j.parseJson&&(e.json=async()=>this.#j.parseJson(await e.text())),e}#z(e){e&&e.cancel().catch(()=>{})}#H(e){this.#z(e.body??void 0)}async#k(e){try{return await e()}catch(t){const r=Math.min(await this.#te(t),2147483647);if(this.#Q<1)throw t;if(await async function(e,{signal:t}){return new Promise((r,s)=>{function n(){clearTimeout(o),s(t.reason)}t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));const o=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}(r,this.#J?{signal:this.#J}:{}),t instanceof be&&t.customRequest){const e=this.#j.signal?new globalThis.Request(t.customRequest,{signal:this.#j.signal}):new globalThis.Request(t.customRequest);this.#re(e)}for(const e of this.#j.hooks.beforeRetry){const r=await e({request:this.request,options:this.#V(),error:t,retryCount:this.#Q});if(r instanceof globalThis.Request){this.#re(r);break}if(r instanceof globalThis.Response)return r;if(r===Ce)return}return this.#k(e)}}async#$(){this.#Z?.signal.aborted&&(this.#Z=new globalThis.AbortController,this.#j.signal=this.#J?AbortSignal.any([this.#J,this.#Z.signal]):this.#Z.signal,this.request=new globalThis.Request(this.request,{signal:this.#j.signal}));for(const t of this.#j.hooks.beforeRequest){const e=await t(this.request,this.#V(),{retryCount:this.#Q});if(e instanceof Response)return e;if(e instanceof globalThis.Request){this.#re(e);break}}const e=((e,t)=>{const r={};for(const s in t)Object.hasOwn(t,s)&&(s in xe||s in De||s in e&&!(s in _e)||(r[s]=t[s]));return r})(this.request,this.#j);return this.#W=this.request,this.request=this.#W.clone(),!1===this.#j.timeout?this.#j.fetch(this.#W,e):async function(e,t,r,s){return new Promise((n,o)=>{const i=setTimeout(()=>{r&&r.abort(),o(new He(e))},s.timeout);s.fetch(e,t).then(n).catch(o).then(()=>{clearTimeout(i)})})}(this.#W,e,this.#Z,this.#j)}#V(){if(!this.#Y){const{hooks:e,...t}=this.#j;this.#Y=Object.freeze(t)}return this.#Y}#re(e){this.#Y=void 0,this.request=this.#X(e)}#X(e,t){return this.#j.onUploadProgress&&e.body?((e,t,r)=>{if(!e.body)return e;const s=(e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[r,s]of e)t+=Ie,t+=(new TextEncoder).encode(`Content-Disposition: form-data; name="${r}"`).length,t+="string"==typeof s?(new TextEncoder).encode(s).length:s.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if("string"==typeof e)return(new TextEncoder).encode(e).length;if(e instanceof URLSearchParams)return(new TextEncoder).encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if("object"==typeof e&&null!==e)try{const t=JSON.stringify(e);return(new TextEncoder).encode(t).length}catch{return 0}return 0})(r??e.body);return new Request(e,{duplex:"half",body:qe(e.body,s,t)})})(e,this.#j.onUploadProgress,t??this.#j.body??void 0):e}},ze=e=>{const t=(t,r)=>We.create(t,Ue(e,r));for(const r of Oe)t[r]=(t,s)=>We.create(t,Ue(e,s,{method:r}));return t.create=e=>ze(Ue(e)),t.extend=t=>("function"==typeof t&&(t=t(e??{})),ze(Ue(e,t))),t.stop=Ce,t.retry=Ne,t},Be=ze(),Ze={PUBLIC_EVENTS:"/",FOLDER_EVENTS:e=>`/${e}`,LOGIN:"/auth/login",REGISTER:"/auth/register",FORGOT_PASSWORD:"/auth/forgot-password",RESET_PASSWORD:"/auth/reset-password",VERIFY_EMAIL:"/auth/verify-email",GALLERY:e=>`/event/${e}`,UPLOAD:e=>`/event/${e}/upload`,CURATE:e=>`/event/${e}/curate`,LEADERBOARD:e=>`/event/${e}/leaderboard`},Ke={ORGANIZATION_SETTINGS:e=>`https://qrati.com/org/${e}/settings`,ORGANIZATION_SETTINGS_INTEGRATION:e=>`https://qrati.com/org/${e}/settings/integration`,ORGANIZATION_DASHBOARD:e=>`https://qrati.com/org/${e}/dashboard`,ORGANIZATION_ADMINS:e=>`https://qrati.com/org/${e}/admins`,EVENT_SETTINGS_BASIC_DETAILS:e=>`https://qrati.com/event/${e}/settings`,EVENT_REVIEW_CONTENTS:e=>`https://qrati.com/event/${e}/review-contents`,EVENT_DEEP_SEARCH:e=>`https://qrati.com/event/${e}/deep-search`,EVENT_GENERATE_ARTICLE:e=>`https://qrati.com/event/${e}/generate-article`,EVENT_ACCESS_REQUESTS:e=>`https://qrati.com/event/${e}/access-requests`,EVENT_SHOT_INSPECTOR:e=>`https://qrati.com/event/${e}/shot-inspector`,EVENT_CURATION_DETAILS:e=>`https://qrati.com/event/${e}/curation-details`},Je={PUBLIC:"PUBLIC",PRIVATE:"PRIVATE",SECRET:"SECRET"},Ye="https://qrati.com/api/connect",Xe={INITIALIZE_SESSION:`${Ye}/session/initialize`,REGISTER:`${Ye}/auth/register`,LOGIN:`${Ye}/auth/login`,LOGOUT:`${Ye}/auth/logout`,UPDATE_SESSION:`${Ye}/session/update`,ACCEPT_TERMS:`${Ye}/auth/accept-terms`,EXTERNAL_LOGIN:`${Ye}/auth/external-login`,PUBLIC_EVENTS:`${Ye}/event/public-events`,SEARCH_EVENTS:`${Ye}/event/search`,FOLDER_DETAILS:`${Ye}/folder/details`,NESTED_FOLDERS:`${Ye}/folder/nested-folders`,GET_EVENT_POINTS:`${Ye}/event/points`,ELIGIBLE_TO_CURATE:`${Ye}/content/curation-eligibility`,CONTENT_FOR_CURATION:`${Ye}/content/for-curation`,CURATE_CONTENT:`${Ye}/content/curate`,GET_LEADERBOARD:`${Ye}/event/leaderboard`,GET_UPLOAD_COUNT:`${Ye}/event/upload-count`,SINGLE_UPLOAD:`${Ye}/content/single-upload`,UPDATE_REACTION:`${Ye}/content/update-reaction`,EVENT_DATA:`${Ye}/event/details-with-ads-parameters`,UPDATE_EVENT_LAYOUT:`${Ye}/event/update-layout`,GET_EVENT_STATISTICS:`${Ye}/event/statistics`,GET_CONTENTS:`${Ye}/content/for-gallery`,SEARCH_CONTENTS:`${Ye}/content/search`,GET_CONTENTS_COUNT:`${Ye}/content/count`,UPDATE_AD_ANALYTICS:`${Ye}/event/update-ad-analytics`,UPDATE_GAM_ANALYTICS:`${Ye}/event/update-gam-analytics`,INCREMENT_EVENT_VIEW:`${Ye}/event/increment-view`,SEND_PASSWORD_RESET_CODE:`${Ye}/auth/send-password-reset-code`,VERIFY_PASSWORD_RESET_CODE:`${Ye}/auth/verify-password-reset-code`,RESET_PASSWORD:`${Ye}/auth/reset-password`,REPORT_ERROR:`${Ye}/session/report-error`},et={OWNER:"owner",ADMIN:"admin",MODERATOR:"moderator"},tt={IMAGE:"IMAGE",VIDEO:"VIDEO",AD:"AD",GAM_AD:"GAM_AD"},rt={GAM_IMPRESSION:"gam_impression",GAM_VIEWABLE:"gam_viewable",GAM_CLICK:"gam_click"},st={ROW:"ROW",COLUMN:"COLUMN",MASONRY:"MASONRY"},nt={IN_REVIEW:"IN_REVIEW",APPROVED:"APPROVED",REJECTED:"REJECTED"},ot={WAITING:"Waiting",UPLOADING:"Uploading",RETRYING:"Retrying",DONE:"Done",FAILED:"Failed",ERROR:"Error"},it=1048576,at={CLOSED:"CLOSED",OPEN:"OPEN",UPCOMING:"UPCOMING"},ct={WAITING:"Waiting",PROCESSING:"Processing",DONE:"Done"},lt={TEXT:"text",IMAGE:"image",LOTTIE:"lottie"},ut={CONTEST:"CONTEST",REACTION:"REACTION"},ht={GRID:"grid",SINGLE:"single"},dt={POPULAR:"popular",UPLOAD_TIME:"upload",CAPTURE_TIME:"capture"},pt={[dt.POPULAR]:{label:"Popular",sortField:"score"},[dt.UPLOAD_TIME]:{label:"Uploaded",sortField:"createdAt"},[dt.CAPTURE_TIME]:{label:"Captured",sortField:"capturedAt"}},ft="map-view-state",yt=dt.UPLOAD_TIME,mt={ASC:"asc",DESC:"desc"},gt={[mt.ASC]:{label:"Ascending",sortOrder:""},[mt.DESC]:{label:"Descending",sortOrder:"-"}},wt=mt.DESC,bt={OWN:"own",CURATED:"curated",ELIGIBLE:"eligible"},vt={NONE:null,LINK:"LINK",EMAIL:"EMAIL",PHONE:"PHONE",SMS:"SMS",WHATSAPP:"WHATSAPP",MESSENGER:"MESSENGER"},Et={[vt.LINK]:"material-symbols:open-in-new-rounded",[vt.EMAIL]:"material-symbols:alternate-email-rounded",[vt.PHONE]:"material-symbols:call-outline",[vt.SMS]:"material-symbols:sms-outline-rounded",[vt.WHATSAPP]:"logos:whatsapp-icon",[vt.MESSENGER]:"logos:messenger"},Rt={AD_IMPRESSION:"impression",AD_ENGAGEMENT:"engagement",AD_CLICK:"click"},St={QRATI_CONNECT_SESSION:"qrati-connect-session",EVENT_IN_REVIEW_COUNT:e=>`in-review-count-${e}`,CONTENTS_BY_EVENT:e=>`contents-by-event-${e}`};function Tt({title:e,children:t}){/* @__PURE__ */
2
2
  return d("div",{className:"mx-auto mt-24 w-fit max-w-xl space-y-8",children:[/* @__PURE__ */d("svg",{xmlns:"http://www.w3.org/2000/svg",className:"mx-auto h-64 w-fit text-[#ff4800]",width:"800",height:"469.317",viewBox:"0 0 800 469.317",role:"img","aria-label":"Error illustration",children:/* @__PURE__ */d("g",{transform:"translate(-443.142 -257.876)",children:[
3
3
  /* @__PURE__ */d("path",{d:"M898.247,664.1H371.155a30.276,30.276,0,0,1-30.241-30.241V352.525a30.276,30.276,0,0,1,30.241-30.241H898.247a30.276,30.276,0,0,1,30.241,30.241V633.862A30.276,30.276,0,0,1,898.247,664.1Z",transform:"translate(308.867 25.517)",fill:"#fff"}),
4
4
  /* @__PURE__ */d("path",{d:"M557.334,341.82H30.241A30.276,30.276,0,0,1,0,311.578V30.241A30.276,30.276,0,0,1,30.241,0H557.334a30.276,30.276,0,0,1,30.241,30.241V311.578A30.276,30.276,0,0,1,557.334,341.82ZM30.241,1.833A28.441,28.441,0,0,0,1.833,30.241V311.578a28.441,28.441,0,0,0,28.409,28.409H557.334a28.441,28.441,0,0,0,28.409-28.409V30.241A28.441,28.441,0,0,0,557.334,1.833Z",transform:"matrix(0.999, -0.035, 0.035, 0.999, 643.995, 358.158)",fill:"#d6d6e3"}),
@@ -29,5 +29,5 @@ return d("div",{className:"mx-auto mt-24 w-fit max-w-xl space-y-8",children:[/*
29
29
  /* @__PURE__ */d("path",{d:"M630.131,617.508a2.452,2.452,0,0,0-3.312-1.027l-9.931,5.228-3.4-195h-.272L608.039,707.89h10.353l-1.408-80.69,12.119-6.38A2.452,2.452,0,0,0,630.131,617.508Z",transform:"translate(-422.315 -280.9)",fill:"#3f3d56"})]})]})}),/* @__PURE__ */d("div",{className:"space-y-4",children:[/* @__PURE__ */d("h4",{className:"text-foreground text-center text-lg font-semibold",children:e}),/* @__PURE__ */d("p",{className:"text-muted-foreground text-center",children:t})]})]})}function Ot({organizationId:e,errorType:t}){/* @__PURE__ */
30
30
  return d(Tt,"custom-auth-invalid"===t?{title:"Invalid input",children:"Custom auth mode requires uid, fname, lname. For more details please contact Qrati support."}:"service-unavailable"===t?{title:"We'll be right back!",children:"Our service is getting a quick tune-up. Hang tight — great things are coming your way soon!"}:{title:"page-not-registered"===t?"Page not registered":"Something went wrong",children:["If you are an admin of this organization, please add the current page URL in Allowed URLs under"," ",
31
31
  /* @__PURE__ */d("a",{className:"font-medium text-blue-500",href:Ke.ORGANIZATION_SETTINGS(e),target:"_blank",rel:"noreferrer",children:"Organization Settings"})," ","⇨"," ",
32
- /* @__PURE__ */d("a",{className:"font-medium text-blue-500",href:Ke.ORGANIZATION_SETTINGS_INTEGRATION(e),target:"_blank",rel:"noreferrer",children:"Integration Settings"}),". For more details please contact Qrati support."]})}var At=e=>({google:"Google",apple:"Apple"}[e]||e.charAt(0).toUpperCase()+e.slice(1)),It=async e=>{try{return await e()}catch{return null}},Ct=(e,t=1)=>{const r=(new TextEncoder).encode(e),s=3432918353,n=461845907;let o=t>>>0;const i=Math.floor(r.length/4),a=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let h=0;h<i;h++){let e=a.getUint32(4*h,!0);e=Math.imul(e,s),e=e<<15|e>>>17,e=Math.imul(e,n),o^=e,o=o<<13|o>>>19,o=Math.imul(o,5)+3864292196>>>0}let c=0;const l=4*i,u=3&r.length;return 3===u&&(c^=r[l+2]<<16),u>=2&&(c^=r[l+1]<<8),u>=1&&(c^=r[l],c=Math.imul(c,s),c=c<<15|c>>>17,c=Math.imul(c,n),o^=c),o^=r.length,o^=o>>>16,o=Math.imul(o,2246822507)>>>0,o^=o>>>13,o=Math.imul(o,3266489909)>>>0,o^=o>>>16,o.toString(16).padStart(8,"0")},Pt=e=>{if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Pt).join(",")}]`;const t=Object.keys(e).sort(),r=[];for(const s of t){const t=e[s];void 0!==t&&r.push(`${Pt(s)}:${Pt(t)}`)}return`{${r.join(",")}}`},Nt=async({debug:e=!1}={})=>{const t=performance.now(),r=await It(async()=>window.navigator.userAgentData&&"function"==typeof window.navigator.userAgentData.getHighEntropyValues?Pt(await window.navigator.userAgentData.getHighEntropyValues(["architecture","bitness","platformVersion","model","fullVersionList"])):null),s=await It(()=>(()=>{const e=document.createElement("video"),t=["video/webm","video/mp4","video/ogg","audio/mp4","audio/webm","audio/ogg","audio/mpeg"],r={};for(const s of t){const t=e.canPlayType(s);r[s]=""===t?"no":t}return Pt(r)})()),n=await It(()=>(()=>{const e=["monospace","serif","sans-serif"],t=["Arial","Helvetica","Verdana","Trebuchet MS","Comic Sans MS","Georgia","Times New Roman","Courier New","Segoe UI","Roboto","Open Sans","Noto Sans","system-ui","-apple-system","BlinkMacSystemFont"],r=document.createElement("span");r.style.fontSize="72px",r.style.position="absolute",r.style.visibility="hidden",r.style.whiteSpace="nowrap",r.textContent="mmmmmmmmmwwwwwww",document.body.appendChild(r);const s={};for(const o of e)r.style.fontFamily=o,s[o]=r.offsetWidth;const n=[];for(const o of t){let t=!1;for(const i of e)if(r.style.fontFamily=`"${o}", ${i}`,r.offsetWidth!==s[i]){n.push(o),t=!0;break}t||(r.style.fontFamily=`"${o}"`,r.offsetWidth!==s.monospace&&r.offsetWidth!==s.serif&&n.push(o))}return document.body.removeChild(r),n.length?n.sort().join(","):null})()),o=await It(()=>new Intl.NumberFormat(window.navigator.languages?.[0]||"en").resolvedOptions().numberingSystem),i=window.navigator.languages?Array.from(window.navigator.languages).join(","):window.navigator.language||null,a=Intl.DateTimeFormat().resolvedOptions(),c=a.timeZone,l=/* @__PURE__ */(new Date).getTimezoneOffset(),u=a.calendar||null,h=void 0!==a.hour12?a.hour12?"h12":"h23":a.hourCycle||null,d=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"reduce":"no-preference",p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",f=window.matchMedia("(prefers-contrast: more)").matches?"more":window.matchMedia("(prefers-contrast: less)").matches?"less":window.matchMedia("(prefers-contrast: custom)").matches?"custom":"no-preference",y=window.matchMedia("(prefers-reduced-transparency: reduce)").matches?"reduce":"no-preference",m=window.matchMedia("(forced-colors: active)").matches?"active":null,g="number"==typeof window.devicePixelRatio?Math.round(100*window.devicePixelRatio)/100:null,{pixelDepth:w,colorDepth:b}=window.screen,v="ontouchstart"in window||window.navigator.maxTouchPoints>0,E=await It(()=>(async e=>{const t=document.createElement("canvas");t.width=280,t.height=100;const r=t.getContext("2d"),s=r.createLinearGradient(0,0,280,100);return s.addColorStop(0,"#f60"),s.addColorStop(.4,"#09f"),s.addColorStop(.7,"#f09"),s.addColorStop(1,"#0f9"),r.fillStyle=s,r.fillRect(0,0,280,100),r.font='18px "Arial","Helvetica","DejaVu Sans",sans-serif',r.fillStyle="#000",r.textBaseline="alphabetic",r.fillText("Fingerprint ¼½¾™©®∆π∑€¶§",12,45),r.font='bold 22px "Georgia","Times New Roman",serif',r.fillStyle="#222",r.fillText("🦊🐱🚀 2026",12,78),r.globalAlpha=.7,r.fillStyle="rgba(255, 80, 0, 0.35)",r.fillRect(180,20,80,60),r.beginPath(),r.arc(220,50,32,0,2*Math.PI),r.strokeStyle="#fff",r.lineWidth=4,r.stroke(),r.beginPath(),r.moveTo(30,85),r.quadraticCurveTo(140,20,240,85),r.strokeStyle="#00f",r.lineWidth=3,r.stroke(),e&&(t.style.border="1px solid #444",document.body.appendChild(t)),Ct(t.toDataURL("image/png"))})(e)),R=await It(()=>(async()=>{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl"),r=t.getExtension("WEBGL_debug_renderer_info");return Ct(Pt({vendor:r?t.getParameter(r.UNMASKED_VENDOR_WEBGL):t.getParameter(t.VENDOR),renderer:r?t.getParameter(r.UNMASKED_RENDERER_WEBGL):t.getParameter(t.RENDERER)}))})()),S=await It(()=>(async e=>{const t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),r={vendor:t.info?.vendor??"",architecture:t.info?.architecture??"",description:t.info?.description??"",features:Array.from(t.features).sort(),limits:Array.from(t.limits).sort()};if(e){const e=document.createElement("pre");e.style.margin="10px 0",e.style.padding="10px",e.style.border="1px solid #444",e.style.background="#111",e.style.color="#0f8",e.style.fontFamily="monospace",e.textContent=`WebGPU:\n${JSON.stringify(r,null,2)}`,document.body.appendChild(e)}return Ct(Pt(r))})(e)),T=await It(()=>(async e=>{const t=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,6e3,44100),r=t.createOscillator();r.type="sawtooth",r.frequency.value=8800;const s=t.createDynamicsCompressor();s.threshold.value=-48,s.knee.value=30,s.ratio.value=14,s.attack.value=0,s.release.value=.3;const n=t.createGain();n.gain.value=.4,r.connect(s),s.connect(n),n.connect(t.destination),r.start(0);const o=(await t.startRendering()).getChannelData(0);let i=0,a=0;for(let l=3e3;l<5800;l+=2){const e=o[l];i=31*i+Math.floor(1e5*(e+1))|0,a=Math.imul(a^Math.floor(98765*e),2246822519)}const c=i>>>0^a>>>0;if(e){const e=document.createElement("canvas");e.width=500,e.height=120,e.style.border="1px solid #444",e.style.margin="10px 0",e.title="Audio buffer snippet (4500–5000 samples)";const t=e.getContext("2d");t.fillStyle="#111",t.fillRect(0,0,e.width,e.height),t.font="14px monospace",t.fillStyle="#0f8",t.textAlign="left",t.fillText("AudioID",10,20),t.strokeStyle="#0f8",t.lineWidth=1.5,t.beginPath();const r=Array.from(o.slice(4500,5e3)),s=e.width/r.length;for(let n=0;n<r.length;n++){const o=n*s,i=(r[n]+1)/2*e.height;0===n?t.moveTo(o,i):t.lineTo(o,i)}t.stroke(),document.body.appendChild(e)}return Ct(c.toString(16))})(e)),O=window.screen.width&&window.screen.height?(window.screen.width/window.screen.height).toFixed(4):null,A=await It(()=>window.screen.orientation?.type||null),I=window.navigator.connection||window.navigator.mozConnection||window.navigator.webkitConnection,C=I&&I.type||null,P=I?.effectiveType||null,N=!0===I?.saveData,D="boolean"==typeof window.navigator.pdfViewerEnabled?window.navigator.pdfViewerEnabled:null,_="boolean"==typeof window.navigator.webdriver?window.navigator.webdriver:null,x=await It(()=>"function"!=typeof Intl.supportedValuesOf?null:Intl.supportedValuesOf("calendar").join(",")),q=await It(async()=>{if(!window.navigator.permissions||"function"!=typeof window.navigator.permissions.query)return null;const e=["geolocation","notifications"],t={};for(const r of e)try{t[r]=(await window.navigator.permissions.query({name:r})).state}catch{t[r]="unsupported"}return Pt(t)}),L={vendor:window.navigator.vendor||null,platform:window.navigator.platform||null,userAgentHighEntropy:r||null,mediaCodecs:s||null,fonts:n,numberingSystem:o,languages:i,timezone:c,timezoneOffset:l,intlCalendar:u,hourCycle:h,reducedMotion:d,colorScheme:p,prefersContrast:f,prefersReducedTransparency:y,pdfViewerEnabled:D,webdriver:_,intlSupportedCalendars:x||null,permissionsState:q||null,hardwareConcurrency:window.navigator.hardwareConcurrency||null,deviceMemory:window.navigator.deviceMemory||null,forcedColors:m,devicePixelRatio:g,pixelDepth:w,colorDepth:b,touchSupport:v,screenOrientation:A||null,connectionType:C,effectiveType:P,saveData:N,canvasID:E,webglID:R,webgpuID:S,audioID:T},U={aspectRatio:O,width:window.screen.width,height:window.screen.height,maxTouchPoints:window.navigator.maxTouchPoints};(!0===navigator.userAgentData?.mobile||/Mobi|Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone/i.test(navigator.userAgent)||navigator.maxTouchPoints>0&&matchMedia("(pointer:coarse)").matches&&innerWidth<=1024)&&Object.assign(L,U);const M=Ct(Pt(L)),F=Math.round(performance.now()-t);return{fingerprint:M,...L,elapsedMs:F}};"undefined"!=typeof window&&(window.getBrowserFingerprint=Nt);var Dt=async(e,t)=>{if(e instanceof ge){try{const t=await e.response.json();if(t?.error)return t.error;if(t?.message)return t.message;if("INVALID_EMAIL_OR_PASSWORD"===t?.code)return"Invalid email or password"}catch{return t||e.message}return t||e.message}return e instanceof Error?t||e.message:t||String(e)},_t=e(void 0),xt=({props:e={},children:t})=>{const{organizationId:n,uid:i,fname:y,lname:m,theme:g="light"}=e,w=u(null),[b,v]=s(()=>{if("undefined"==typeof window)return null;if(i||y||m)return null;const e=localStorage.getItem("qrati_token");return e?{token:e}:null}),{isLoading:E,data:R,error:S}=me({queryKey:[St.QRATI_CONNECT_SESSION,n,i??null,y??null,m??null],queryFn:async()=>{const e=await(async()=>{const e=await Nt();return"string"==typeof e?e:e?.fingerprint})();return(await Be.post(Xe.INITIALIZE_SESSION,{json:{uid:i,fname:y,lname:m,browserFingerprint:e},headers:{"x-org-id":n,Authorization:i||y||m||!localStorage.getItem("qrati_token")?void 0:`Bearer ${localStorage.getItem("qrati_token")}`}}).json()).data},enabled:!!n});f(()=>{const e=R?.authSession?.session?.token,t=R?.authSession?.user;t&&e?(v({...t,token:e}),R?.organization?.customAuth||localStorage.setItem("qrati_token",e)):R?.organization?.customAuth&&i&&y&&m&&v(e=>e??{uid:i,name:`${y} ${m}`,fname:y,lname:m})},[R]);const T=r(()=>{const e=R?.organization?.integrationSettings?.fontFamily,t=c("https://qrati.com",e),r=l("https://qrati.com",n);return o(R?.organization?.integrationSettings,R?.organization?.customFontUrl?r||R.organization.customFontUrl:void 0,t||void 0)},[R?.organization?.integrationSettings,R?.organization?.customFontUrl,n]),O=async e=>{try{const t=await((e,t,r)=>new Promise((s,n)=>{if(!e)return void n(/* @__PURE__ */new Error("Provider is required"));if(!t)return void n(/* @__PURE__ */new Error("Organization ID is required"));const o=new URL(`${r}/qc-social-auth`);o.searchParams.set("provider",e),o.searchParams.set("organizationId",t),o.searchParams.set("origin",window.location.origin);const i=(window.screen.width-500)/2,a=(window.screen.height-600)/2,c=window.open(o.toString(),"qrati_social_auth",`width=500,height=600,left=${i},top=${a},scrollbars=yes,resizable=yes,status=yes`);if(!c)return void n(/* @__PURE__ */new Error("Failed to open popup window. Please allow popups and try again."));const l=()=>{clearInterval(h),clearTimeout(d),window.removeEventListener("message",u)},u=e=>{try{const t=new URL(r).origin;if(e.origin!==t)return void console.warn("Origin mismatch:",e.origin,"expected:",t)}catch(h){console.warn("Could not parse origin for verification")}const{type:o,data:i,error:a,organizationId:u}=e.data||{};if(u===t)switch(o){case"QRATI_SOCIAL_AUTH_SUCCESS":l(),c.close(),s({user:i.user,session:i.session,token:i.token});break;case"QRATI_SOCIAL_AUTH_ERROR":console.error("Authentication error:",a),l(),c.close(),n(new Error(a||"Social authentication failed"));break;case"QRATI_SOCIAL_AUTH_CANCELLED":l(),c.close(),n(/* @__PURE__ */new Error("Authentication was cancelled"))}else console.warn("Organization ID mismatch:",u,"expected:",t)},h=setInterval(()=>{try{c.closed&&(l(),n(/* @__PURE__ */new Error("Authentication was cancelled")))}catch(e){}},1e3);window.addEventListener("message",u);const d=setTimeout(()=>{l(),c.closed||c.close(),n(/* @__PURE__ */new Error("Authentication timeout. Please try again."))},3e5)}))(e,n??"","https://qrati.com");return t?.user&&t?.token&&(v({...t.user,token:t.token}),localStorage.setItem("qrati_token",t.token)),t}catch(S){throw console.error("Social login error:",S),S}};if(S){const e=S;/* @__PURE__ */
33
- return d(p,{fallback:null,children:/* @__PURE__ */d(Ot,{organizationId:n??"",errorType:401===e?.response?.status?"page-not-registered":e?.response?"generic-error":"service-unavailable"})})}return!R?.organization?.customAuth||i&&y&&m?/* @__PURE__ */d(_t.Provider,{value:{props:e,initializing:E,sessionId:R?.sessionId,organization:R?.organization,folders:R?.folders,loadingUser:E,user:b,updateUser:async e=>{v(t=>{const r={...t,...e};return r?.token&&localStorage.setItem("qrati_token",r.token),r})},registerUsingEmail:async(e,t,r,s)=>{try{const o=await Be.post(Xe.REGISTER,{json:{email:e,password:t,fname:r,lname:s},headers:{"x-org-id":n}}).json();return o.error?{error:o.error}:(v({...o.user,token:o.token}),localStorage.setItem("qrati_token",o.token),o)}catch(S){return{error:await Dt(S,"Registration failed")}}},loginWithGoogle:async()=>{try{return await O("google")}catch(S){throw console.error("Google login error:",S),S}},loginWithApple:async()=>{try{return await O("apple")}catch(S){throw console.error("Apple login error:",S),S}},loginUsingEmail:async(e,t)=>{try{const r=await Be.post(Xe.LOGIN,{json:{email:e,password:t},headers:{"x-org-id":n}}).json();return r.error?{error:r.error}:(v({...r.user,token:r.token}),localStorage.setItem("qrati_token",r.token),r)}catch(S){return{error:await Dt(S,"Invalid email or password")}}},sendPasswordResetCode:async e=>{try{const t=await Be.post(Xe.SEND_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase()},headers:{"x-org-id":n}}).json();return t.error?{error:t.error}:t}catch(S){return{error:await Dt(S,"Failed to send password reset code")}}},verifyPasswordResetCode:async(e,t)=>{try{const r=await Be.post(Xe.VERIFY_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase(),code:t},headers:{"x-org-id":n}}).json();return r.error?{error:r.error}:r}catch(S){return{error:await Dt(S,"Invalid code, please check your email")}}},resetPassword:async(e,t)=>{try{const r=await Be.post(Xe.RESET_PASSWORD,{json:{passwordResetCodeId:e,newPassword:t},headers:{"x-org-id":n}}).json();return r.error?{error:r.error}:r}catch(S){return{error:S?.message}}},signout:async()=>{try{const e=await Be.post(Xe.LOGOUT,{headers:{"x-org-id":n,Authorization:`Bearer ${b?.token}`}}).json();return e.error?{error:e.error}:(localStorage.removeItem("qrati_token"),v(null),e)}catch(S){return console.error(S),{error:S?.message}}},error:S,portalContainer:w.current},children:/* @__PURE__ */d("div",{ref:w,id:"qrati-connect-container",style:{...h(R?.organization,g),fontFamily:"var(--font-family)"},className:a("bg-background text-foreground relative min-h-[80vh]"),children:[T?/* @__PURE__ */d("style",{children:T}):null,t]})}):/* @__PURE__ */d(p,{fallback:null,children:/* @__PURE__ */d(Ot,{organizationId:n??"",errorType:"custom-auth-invalid"})})},qt=()=>{const e=n(_t);if(void 0===e)throw new Error("useSession must be used within SessionProvider");return e};export{v as $,lt as A,X as B,it as C,Ze as D,ft as E,ye as F,F as G,B as H,he as I,E as J,k as K,ue as L,gt as M,Be as N,St as O,me as P,A as Q,ne as R,Ke as S,rt as T,z as U,Y as V,V as W,C as X,P as Y,I as Z,yt as _,et as a,at as b,Et as c,dt as d,N as et,pt as f,ht as g,ot as h,At as i,y as it,mt as j,bt as k,Xe as l,tt as m,qt as n,j as nt,Rt as o,nt as p,G as q,Nt as r,m as rt,vt as s,xt as t,T as tt,ct as u,wt as v,st as w,Je as x,ut as y,ee as z};
32
+ /* @__PURE__ */d("a",{className:"font-medium text-blue-500",href:Ke.ORGANIZATION_SETTINGS_INTEGRATION(e),target:"_blank",rel:"noreferrer",children:"Integration Settings"}),". For more details please contact Qrati support."]})}var At=e=>({google:"Google",apple:"Apple"}[e]||e.charAt(0).toUpperCase()+e.slice(1)),It=async e=>{try{return await e()}catch{return null}},Ct=(e,t=1)=>{const r=(new TextEncoder).encode(e),s=3432918353,n=461845907;let o=t>>>0;const i=Math.floor(r.length/4),a=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let h=0;h<i;h++){let e=a.getUint32(4*h,!0);e=Math.imul(e,s),e=e<<15|e>>>17,e=Math.imul(e,n),o^=e,o=o<<13|o>>>19,o=Math.imul(o,5)+3864292196>>>0}let c=0;const l=4*i,u=3&r.length;return 3===u&&(c^=r[l+2]<<16),u>=2&&(c^=r[l+1]<<8),u>=1&&(c^=r[l],c=Math.imul(c,s),c=c<<15|c>>>17,c=Math.imul(c,n),o^=c),o^=r.length,o^=o>>>16,o=Math.imul(o,2246822507)>>>0,o^=o>>>13,o=Math.imul(o,3266489909)>>>0,o^=o>>>16,o.toString(16).padStart(8,"0")},Pt=e=>{if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Pt).join(",")}]`;const t=Object.keys(e).sort(),r=[];for(const s of t){const t=e[s];void 0!==t&&r.push(`${Pt(s)}:${Pt(t)}`)}return`{${r.join(",")}}`},Nt=async({debug:e=!1}={})=>{const t=performance.now(),r=await It(async()=>window.navigator.userAgentData&&"function"==typeof window.navigator.userAgentData.getHighEntropyValues?Pt(await window.navigator.userAgentData.getHighEntropyValues(["architecture","bitness","platformVersion","model","fullVersionList"])):null),s=await It(()=>(()=>{const e=document.createElement("video"),t=["video/webm","video/mp4","video/ogg","audio/mp4","audio/webm","audio/ogg","audio/mpeg"],r={};for(const s of t){const t=e.canPlayType(s);r[s]=""===t?"no":t}return Pt(r)})()),n=await It(()=>(()=>{const e=["monospace","serif","sans-serif"],t=["Arial","Helvetica","Verdana","Trebuchet MS","Comic Sans MS","Georgia","Times New Roman","Courier New","Segoe UI","Roboto","Open Sans","Noto Sans","system-ui","-apple-system","BlinkMacSystemFont"],r=document.createElement("span");r.style.fontSize="72px",r.style.position="absolute",r.style.visibility="hidden",r.style.whiteSpace="nowrap",r.textContent="mmmmmmmmmwwwwwww",document.body.appendChild(r);const s={};for(const o of e)r.style.fontFamily=o,s[o]=r.offsetWidth;const n=[];for(const o of t){let t=!1;for(const i of e)if(r.style.fontFamily=`"${o}", ${i}`,r.offsetWidth!==s[i]){n.push(o),t=!0;break}t||(r.style.fontFamily=`"${o}"`,r.offsetWidth!==s.monospace&&r.offsetWidth!==s.serif&&n.push(o))}return document.body.removeChild(r),n.length?n.sort().join(","):null})()),o=await It(()=>new Intl.NumberFormat(window.navigator.languages?.[0]||"en").resolvedOptions().numberingSystem),i=window.navigator.languages?Array.from(window.navigator.languages).join(","):window.navigator.language||null,a=Intl.DateTimeFormat().resolvedOptions(),c=a.timeZone,l=/* @__PURE__ */(new Date).getTimezoneOffset(),u=a.calendar||null,h=void 0!==a.hour12?a.hour12?"h12":"h23":a.hourCycle||null,d=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"reduce":"no-preference",p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",f=window.matchMedia("(prefers-contrast: more)").matches?"more":window.matchMedia("(prefers-contrast: less)").matches?"less":window.matchMedia("(prefers-contrast: custom)").matches?"custom":"no-preference",y=window.matchMedia("(prefers-reduced-transparency: reduce)").matches?"reduce":"no-preference",m=window.matchMedia("(forced-colors: active)").matches?"active":null,g="number"==typeof window.devicePixelRatio?Math.round(100*window.devicePixelRatio)/100:null,{pixelDepth:w,colorDepth:b}=window.screen,v="ontouchstart"in window||window.navigator.maxTouchPoints>0,E=await It(()=>(async e=>{const t=document.createElement("canvas");t.width=280,t.height=100;const r=t.getContext("2d"),s=r.createLinearGradient(0,0,280,100);return s.addColorStop(0,"#f60"),s.addColorStop(.4,"#09f"),s.addColorStop(.7,"#f09"),s.addColorStop(1,"#0f9"),r.fillStyle=s,r.fillRect(0,0,280,100),r.font='18px "Arial","Helvetica","DejaVu Sans",sans-serif',r.fillStyle="#000",r.textBaseline="alphabetic",r.fillText("Fingerprint ¼½¾™©®∆π∑€¶§",12,45),r.font='bold 22px "Georgia","Times New Roman",serif',r.fillStyle="#222",r.fillText("🦊🐱🚀 2026",12,78),r.globalAlpha=.7,r.fillStyle="rgba(255, 80, 0, 0.35)",r.fillRect(180,20,80,60),r.beginPath(),r.arc(220,50,32,0,2*Math.PI),r.strokeStyle="#fff",r.lineWidth=4,r.stroke(),r.beginPath(),r.moveTo(30,85),r.quadraticCurveTo(140,20,240,85),r.strokeStyle="#00f",r.lineWidth=3,r.stroke(),e&&(t.style.border="1px solid #444",document.body.appendChild(t)),Ct(t.toDataURL("image/png"))})(e)),R=await It(()=>(async()=>{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl"),r=t.getExtension("WEBGL_debug_renderer_info");return Ct(Pt({vendor:r?t.getParameter(r.UNMASKED_VENDOR_WEBGL):t.getParameter(t.VENDOR),renderer:r?t.getParameter(r.UNMASKED_RENDERER_WEBGL):t.getParameter(t.RENDERER)}))})()),S=await It(()=>(async e=>{const t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),r={vendor:t.info?.vendor??"",architecture:t.info?.architecture??"",description:t.info?.description??"",features:Array.from(t.features).sort(),limits:Array.from(t.limits).sort()};if(e){const e=document.createElement("pre");e.style.margin="10px 0",e.style.padding="10px",e.style.border="1px solid #444",e.style.background="#111",e.style.color="#0f8",e.style.fontFamily="monospace",e.textContent=`WebGPU:\n${JSON.stringify(r,null,2)}`,document.body.appendChild(e)}return Ct(Pt(r))})(e)),T=await It(()=>(async e=>{const t=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,6e3,44100),r=t.createOscillator();r.type="sawtooth",r.frequency.value=8800;const s=t.createDynamicsCompressor();s.threshold.value=-48,s.knee.value=30,s.ratio.value=14,s.attack.value=0,s.release.value=.3;const n=t.createGain();n.gain.value=.4,r.connect(s),s.connect(n),n.connect(t.destination),r.start(0);const o=(await t.startRendering()).getChannelData(0);let i=0,a=0;for(let l=3e3;l<5800;l+=2){const e=o[l];i=31*i+Math.floor(1e5*(e+1))|0,a=Math.imul(a^Math.floor(98765*e),2246822519)}const c=i>>>0^a>>>0;if(e){const e=document.createElement("canvas");e.width=500,e.height=120,e.style.border="1px solid #444",e.style.margin="10px 0",e.title="Audio buffer snippet (4500–5000 samples)";const t=e.getContext("2d");t.fillStyle="#111",t.fillRect(0,0,e.width,e.height),t.font="14px monospace",t.fillStyle="#0f8",t.textAlign="left",t.fillText("AudioID",10,20),t.strokeStyle="#0f8",t.lineWidth=1.5,t.beginPath();const r=Array.from(o.slice(4500,5e3)),s=e.width/r.length;for(let n=0;n<r.length;n++){const o=n*s,i=(r[n]+1)/2*e.height;0===n?t.moveTo(o,i):t.lineTo(o,i)}t.stroke(),document.body.appendChild(e)}return Ct(c.toString(16))})(e)),O=window.screen.width&&window.screen.height?(window.screen.width/window.screen.height).toFixed(4):null,A=await It(()=>window.screen.orientation?.type||null),I=window.navigator.connection||window.navigator.mozConnection||window.navigator.webkitConnection,C=I&&I.type||null,P=I?.effectiveType||null,N=!0===I?.saveData,D="boolean"==typeof window.navigator.pdfViewerEnabled?window.navigator.pdfViewerEnabled:null,_="boolean"==typeof window.navigator.webdriver?window.navigator.webdriver:null,x=await It(()=>"function"!=typeof Intl.supportedValuesOf?null:Intl.supportedValuesOf("calendar").join(",")),q=await It(async()=>{if(!window.navigator.permissions||"function"!=typeof window.navigator.permissions.query)return null;const e=["geolocation","notifications"],t={};for(const r of e)try{t[r]=(await window.navigator.permissions.query({name:r})).state}catch{t[r]="unsupported"}return Pt(t)}),L={vendor:window.navigator.vendor||null,platform:window.navigator.platform||null,userAgentHighEntropy:r||null,mediaCodecs:s||null,fonts:n,numberingSystem:o,languages:i,timezone:c,timezoneOffset:l,intlCalendar:u,hourCycle:h,reducedMotion:d,colorScheme:p,prefersContrast:f,prefersReducedTransparency:y,pdfViewerEnabled:D,webdriver:_,intlSupportedCalendars:x||null,permissionsState:q||null,hardwareConcurrency:window.navigator.hardwareConcurrency||null,deviceMemory:window.navigator.deviceMemory||null,forcedColors:m,devicePixelRatio:g,pixelDepth:w,colorDepth:b,touchSupport:v,screenOrientation:A||null,connectionType:C,effectiveType:P,saveData:N,canvasID:E,webglID:R,webgpuID:S,audioID:T},U={aspectRatio:O,width:window.screen.width,height:window.screen.height,maxTouchPoints:window.navigator.maxTouchPoints};(!0===navigator.userAgentData?.mobile||/Mobi|Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone/i.test(navigator.userAgent)||navigator.maxTouchPoints>0&&matchMedia("(pointer:coarse)").matches&&innerWidth<=1024)&&Object.assign(L,U);const M=Ct(Pt(L)),F=Math.round(performance.now()-t);return{fingerprint:M,...L,elapsedMs:F}};"undefined"!=typeof window&&(window.getBrowserFingerprint=Nt);var Dt=async(e,t)=>{if(e instanceof ge){try{const t=await e.response.json();if(t?.error)return t.error;if(t?.message)return t.message;if("INVALID_EMAIL_OR_PASSWORD"===t?.code)return"Invalid email or password"}catch{return t||e.message}return t||e.message}return e instanceof Error?t||e.message:t||String(e)},_t=e(void 0),xt=({props:e={},children:t})=>{const{organizationId:n,uid:i,fname:y,lname:m,theme:g="light"}=e,w=u(null),[b,v]=s(()=>{if("undefined"==typeof window)return null;if(i||y||m)return null;const e=localStorage.getItem("qrati_token");return e?{token:e}:null}),{isLoading:E,data:R,error:S}=me({queryKey:[St.QRATI_CONNECT_SESSION,n,i??null,y??null,m??null],queryFn:async()=>{const e=await(async()=>{const e=await Nt();return"string"==typeof e?e:e?.fingerprint})();return(await Be.post(Xe.INITIALIZE_SESSION,{json:{uid:i,fname:y,lname:m,browserFingerprint:e},headers:{"x-org-id":n,Authorization:i||y||m||!localStorage.getItem("qrati_token")?void 0:`Bearer ${localStorage.getItem("qrati_token")}`}}).json()).data},enabled:!!n});f(()=>{const e=R?.authSession?.session?.token,t=R?.authSession?.user;t&&e?(v({...t,token:e}),R?.organization?.customAuth||localStorage.setItem("qrati_token",e)):R?.organization?.customAuth&&i&&y&&m&&v(e=>e??{uid:i,name:`${y} ${m}`,fname:y,lname:m})},[R]);const T=r(()=>{const e=R?.organization?.integrationSettings?.fontFamily,t=c("https://qrati.com",e),r=l("https://qrati.com",n);return o(R?.organization?.integrationSettings,R?.organization?.customFontUrl?r||R.organization.customFontUrl:void 0,t||void 0)},[R?.organization?.integrationSettings,R?.organization?.customFontUrl,n]);f(()=>{const e=`data-qrati-font-${n}`;if(document.head.querySelector(`[${e}]`)?.remove(),T){if(T.startsWith("@import")){const t=T.match(/@import url\("([^"]+)"\)/);if(!t?.[1])return;const r=document.createElement("link");r.rel="stylesheet",r.href=t[1],r.setAttribute(e,""),document.head.appendChild(r)}else{const t=document.createElement("style");t.textContent=T,t.setAttribute(e,""),document.head.appendChild(t)}return()=>{document.head.querySelector(`[${e}]`)?.remove()}}},[T,n]);const O=async e=>{try{const t=await((e,t,r)=>new Promise((s,n)=>{if(!e)return void n(/* @__PURE__ */new Error("Provider is required"));if(!t)return void n(/* @__PURE__ */new Error("Organization ID is required"));const o=new URL(`${r}/qc-social-auth`);o.searchParams.set("provider",e),o.searchParams.set("organizationId",t),o.searchParams.set("origin",window.location.origin);const i=(window.screen.width-500)/2,a=(window.screen.height-600)/2,c=window.open(o.toString(),"qrati_social_auth",`width=500,height=600,left=${i},top=${a},scrollbars=yes,resizable=yes,status=yes`);if(!c)return void n(/* @__PURE__ */new Error("Failed to open popup window. Please allow popups and try again."));const l=()=>{clearInterval(h),clearTimeout(d),window.removeEventListener("message",u)},u=e=>{try{const t=new URL(r).origin;if(e.origin!==t)return void console.warn("Origin mismatch:",e.origin,"expected:",t)}catch(h){console.warn("Could not parse origin for verification")}const{type:o,data:i,error:a,organizationId:u}=e.data||{};if(u===t)switch(o){case"QRATI_SOCIAL_AUTH_SUCCESS":l(),c.close(),s({user:i.user,session:i.session,token:i.token});break;case"QRATI_SOCIAL_AUTH_ERROR":console.error("Authentication error:",a),l(),c.close(),n(new Error(a||"Social authentication failed"));break;case"QRATI_SOCIAL_AUTH_CANCELLED":l(),c.close(),n(/* @__PURE__ */new Error("Authentication was cancelled"))}else console.warn("Organization ID mismatch:",u,"expected:",t)},h=setInterval(()=>{try{c.closed&&(l(),n(/* @__PURE__ */new Error("Authentication was cancelled")))}catch(e){}},1e3);window.addEventListener("message",u);const d=setTimeout(()=>{l(),c.closed||c.close(),n(/* @__PURE__ */new Error("Authentication timeout. Please try again."))},3e5)}))(e,n??"","https://qrati.com");return t?.user&&t?.token&&(v({...t.user,token:t.token}),localStorage.setItem("qrati_token",t.token)),t}catch(S){throw console.error("Social login error:",S),S}};if(S){const e=S;/* @__PURE__ */
33
+ return d(p,{fallback:null,children:/* @__PURE__ */d(Ot,{organizationId:n??"",errorType:401===e?.response?.status?"page-not-registered":e?.response?"generic-error":"service-unavailable"})})}return!R?.organization?.customAuth||i&&y&&m?/* @__PURE__ */d(_t.Provider,{value:{props:e,initializing:E,sessionId:R?.sessionId,organization:R?.organization,folders:R?.folders,loadingUser:E,user:b,updateUser:async e=>{v(t=>{const r={...t,...e};return r?.token&&localStorage.setItem("qrati_token",r.token),r})},registerUsingEmail:async(e,t,r,s)=>{try{const o=await Be.post(Xe.REGISTER,{json:{email:e,password:t,fname:r,lname:s},headers:{"x-org-id":n}}).json();return o.error?{error:o.error}:(v({...o.user,token:o.token}),localStorage.setItem("qrati_token",o.token),o)}catch(S){return{error:await Dt(S,"Registration failed")}}},loginWithGoogle:async()=>{try{return await O("google")}catch(S){throw console.error("Google login error:",S),S}},loginWithApple:async()=>{try{return await O("apple")}catch(S){throw console.error("Apple login error:",S),S}},loginUsingEmail:async(e,t)=>{try{const r=await Be.post(Xe.LOGIN,{json:{email:e,password:t},headers:{"x-org-id":n}}).json();return r.error?{error:r.error}:(v({...r.user,token:r.token}),localStorage.setItem("qrati_token",r.token),r)}catch(S){return{error:await Dt(S,"Invalid email or password")}}},sendPasswordResetCode:async e=>{try{const t=await Be.post(Xe.SEND_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase()},headers:{"x-org-id":n}}).json();return t.error?{error:t.error}:t}catch(S){return{error:await Dt(S,"Failed to send password reset code")}}},verifyPasswordResetCode:async(e,t)=>{try{const r=await Be.post(Xe.VERIFY_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase(),code:t},headers:{"x-org-id":n}}).json();return r.error?{error:r.error}:r}catch(S){return{error:await Dt(S,"Invalid code, please check your email")}}},resetPassword:async(e,t)=>{try{const r=await Be.post(Xe.RESET_PASSWORD,{json:{passwordResetCodeId:e,newPassword:t},headers:{"x-org-id":n}}).json();return r.error?{error:r.error}:r}catch(S){return{error:S?.message}}},signout:async()=>{try{const e=await Be.post(Xe.LOGOUT,{headers:{"x-org-id":n,Authorization:`Bearer ${b?.token}`}}).json();return e.error?{error:e.error}:(localStorage.removeItem("qrati_token"),v(null),e)}catch(S){return console.error(S),{error:S?.message}}},error:S,portalContainer:w.current},children:/* @__PURE__ */d("div",{ref:w,id:"qrati-connect-container",style:{...h(R?.organization,g),fontFamily:"var(--font-family)"},className:a("bg-background text-foreground relative min-h-[80vh]"),children:t})}):/* @__PURE__ */d(p,{fallback:null,children:/* @__PURE__ */d(Ot,{organizationId:n??"",errorType:"custom-auth-invalid"})})},qt=()=>{const e=n(_t);if(void 0===e)throw new Error("useSession must be used within SessionProvider");return e};export{v as $,lt as A,X as B,it as C,Ze as D,ft as E,ye as F,F as G,B as H,he as I,E as J,k as K,ue as L,gt as M,Be as N,St as O,me as P,A as Q,ne as R,Ke as S,rt as T,z as U,Y as V,V as W,C as X,P as Y,I as Z,yt as _,et as a,at as b,Et as c,dt as d,N as et,pt as f,ht as g,ot as h,At as i,y as it,mt as j,bt as k,Xe as l,tt as m,qt as n,j as nt,Rt as o,nt as p,$ as q,Nt as r,m as rt,vt as s,xt as t,T as tt,ct as u,wt as v,st as w,Je as x,ut as y,ee as z};
package/element/web.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as e,t}from"./CsohJ1Yu.js";import{A as r,B as n,D as o,E as a,G as i,H as s,I as l,K as c,L as d,M as u,N as p,O as h,P as m,R as g,S as f,T as v,U as w,V as b,a as y,c as _,d as x,f as C,i as k,j as E,k as S,l as A,n as M,o as L,p as N,r as I,s as P,t as T,u as z,v as R,w as O,x as F,z as D}from"./19c52mJB.js";import{A as U,C as j,D as B,F as W,I as q,L as H,M as G,N as V,O as Z,P as K,R as Q,S as Y,T as J,_ as X,a as $,b as ee,d as te,f as re,g as ne,h as oe,i as ae,j as ie,k as se,l as le,m as ce,n as de,p as ue,t as pe,u as he,v as me,w as ge,x as fe,y as ve}from"./t1REK11Z.js";import{a as we,i as be,n as ye,r as _e,t as xe}from"./BQBx6JI7.js";import{_ as Ce,a as ke,b as Ee,c as Se,d as Ae,f as Me,g as Le,h as Ne,i as Ie,l as Pe,m as Te,n as ze,o as Re,p as Oe,r as Fe,s as De,t as Ue,u as je,v as Be,y as We}from"./BPD6evHs.js";import{t as qe}from"./Bu-H5iRE.js";var He=class extends Q{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:we()})}getOptimisticResult(e){return e.behavior=we(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:r}=e,n=super.createResult(e,t),{isFetching:o,isRefetching:a,isError:i,isRefetchError:s}=n,l=r.fetchMeta?.fetchMore?.direction,c=i&&"forward"===l,d=o&&"forward"===l,u=i&&"backward"===l,p=o&&"backward"===l;return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:_e(t,r.data),hasPreviousPage:be(t,r.data),isFetchNextPageError:c,isFetchingNextPage:d,isFetchPreviousPageError:u,isFetchingPreviousPage:p,isRefetchError:s&&!c&&!u,isRefetching:a&&!d&&!p}}},Ge=({className:e,rounded:t=!1,...r})=>/* @__PURE__ */R("div",{className:C("bg-border animate-pulse",t?"rounded-full":"rounded",e),...r}),Ve=()=>/* @__PURE__ */R("div",{className:"text-muted-foreground text-center text-sm",children:["Powered by"," ",
1
+ import{a as e,t}from"./CsohJ1Yu.js";import{A as r,B as n,D as o,E as a,G as i,H as s,I as l,K as c,L as d,M as u,N as p,O as h,P as m,R as g,S as f,T as v,U as w,V as b,a as y,c as _,d as x,f as C,i as k,j as E,k as S,l as A,n as M,o as L,p as N,r as I,s as P,t as T,u as z,v as R,w as O,x as F,z as D}from"./MZuQhFbV.js";import{A as U,C as j,D as B,F as W,I as q,L as H,M as G,N as V,O as Z,P as K,R as Q,S as Y,T as J,_ as X,a as $,b as ee,d as te,f as re,g as ne,h as oe,i as ae,j as ie,k as se,l as le,m as ce,n as de,p as ue,t as pe,u as he,v as me,w as ge,x as fe,y as ve}from"./jL1IhEDX.js";import{a as we,i as be,n as ye,r as _e,t as xe}from"./Dlyq91q9.js";import{_ as Ce,a as ke,b as Ee,c as Se,d as Ae,f as Me,g as Le,h as Ne,i as Ie,l as Pe,m as Te,n as ze,o as Re,p as Oe,r as Fe,s as De,t as Ue,u as je,v as Be,y as We}from"./CwqB3rqe.js";import{t as qe}from"./DuIwDwan.js";var He=class extends Q{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:we()})}getOptimisticResult(e){return e.behavior=we(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:r}=e,n=super.createResult(e,t),{isFetching:o,isRefetching:a,isError:i,isRefetchError:s}=n,l=r.fetchMeta?.fetchMore?.direction,c=i&&"forward"===l,d=o&&"forward"===l,u=i&&"backward"===l,p=o&&"backward"===l;return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:_e(t,r.data),hasPreviousPage:be(t,r.data),isFetchNextPageError:c,isFetchingNextPage:d,isFetchPreviousPageError:u,isFetchingPreviousPage:p,isRefetchError:s&&!c&&!u,isRefetching:a&&!d&&!p}}},Ge=({className:e,rounded:t=!1,...r})=>/* @__PURE__ */R("div",{className:C("bg-border animate-pulse",t?"rounded-full":"rounded",e),...r}),Ve=()=>/* @__PURE__ */R("div",{className:"text-muted-foreground text-center text-sm",children:["Powered by"," ",
2
2
  /* @__PURE__ */R("a",{href:"https://qrati.com",target:"_blank",rel:"noopener noreferrer",children:/* @__PURE__ */R("strong",{children:"Qrati"})})]}),Ze=()=>{const e=A(),t=z(),{initializing:r,organization:n,user:o}=de();return D(()=>{if(o){const r=e.state?.referrer;t(r||"/")}},[o]),r?/* @__PURE__ */R("div",{className:"mx-auto max-w-lg space-y-8 py-8",children:[
3
3
  /* @__PURE__ */R(Ge,{className:"h-8"}),
4
4
  /* @__PURE__ */R(Ge,{className:"h-8"}),
@@ -83,7 +83,7 @@ return R("div",{className:"relative flex w-auto items-center gap-2",children:[/*
83
83
  /* @__PURE__ */R(ss,{placeholder:u("content.search_placeholder","Search using text"),value:h,className:"py-2",onChange:e=>g(e.target.value),onKeyUp:e=>{const t=e.key;"Enter"===t?l&&l(h.length>0?h:""):"Escape"===t&&(g(""),l&&l(""))}}),h?.length>0&&/* @__PURE__ */R("button",{className:"absolute inset-y-0 right-10 flex items-center",onClick:()=>{g(""),l&&l("")},children:/* @__PURE__ */R(We,{name:"material-symbols:close-rounded",className:"text-foreground w-5"})}),
84
84
  /* @__PURE__ */R("button",{className:"absolute inset-y-0 right-3 flex items-center",onClick:()=>l&&l(h),children:/* @__PURE__ */R(We,{name:"material-symbols:search-rounded",className:"text-foreground w-5"})})]})}),p?.integrationSettings?.showFacialSearch&&/* @__PURE__ */R(Ws,{value:f,onChange:e=>{v(e),d?.(e?URL.createObjectURL(e):void 0)}})]}),
85
85
  /* @__PURE__ */R("div",{className:"col-span-3 md:col-span-1"}),
86
- /* @__PURE__ */R("div",{className:"col-span-3 mt-3 md:col-span-1 md:mt-0 lg:justify-self-end",children:/* @__PURE__ */R(ls,{engagementStyle:e,sort:o,order:i,onSortChange:a,onSortOrderChange:s})})]})},Vs=({position:e,gamConfig:t,eventId:r,organizationId:n})=>{const{trackGamAnalytics:o}=Me(),a=E(null),i=`gam-${e}-banner-${r??"ev"}`,s=t.placementCategories?.[e];return D(()=>{let e=!1,l=null,c=null,d=null,u=null,p=null,h=null;const m=s?[s]:[],g=document.createElement("div");g.id=i,document.body.appendChild(g);const f=()=>{const e=a.current;if(!e)return;const t=e.getBoundingClientRect(),r=t.width>0&&t.height>0;g.style.display=r?"block":"none",r&&(g.style.position="fixed",g.style.top=`${t.top}px`,g.style.left=`${t.left}px`,g.style.width="728px",g.style.height="90px",g.style.zIndex="20")};return f(),window.addEventListener("scroll",f,{passive:!0}),window.addEventListener("resize",f),(async()=>{await Ne(),e||window.googletag.cmd.push(()=>{if(e)return;Oe(i);const a=window.googletag.defineSlot(t.adUnitPath,[[728,90]],i)?.addService(window.googletag.pubads());a&&(l=a,u=window.googletag.pubads(),r?a.setConfig({targeting:{qrati_event:r,...m.length>0?{qrati_category:m}:{}}}):m.length>0&&a.setConfig({targeting:{qrati_category:m}}),p=e=>{e.slot===a&&o({eventId:r,organizationId:n,type:J.GAM_IMPRESSION,creativeId:String(e.creativeId??""),lineItemId:String(e.lineItemId??""),advertiserId:String(e.advertiserId??""),isEmpty:e.isEmpty??!1})},u.addEventListener("slotRenderEnded",p),h=e=>{e.slot===a&&o({eventId:r,organizationId:n,type:J.GAM_VIEWABLE})},u.addEventListener("impressionViewable",h),d=Ae({container:g,onClick:()=>{o({eventId:r,organizationId:n,type:J.GAM_CLICK})}}),Te(),window.googletag.display(i),c=window.setTimeout(()=>{e||(f(),a.getResponseInformation?.()||window.googletag.pubads().refresh([a]))},1500))})})(),()=>{e=!0,window.removeEventListener("scroll",f),window.removeEventListener("resize",f),null!==c&&window.clearTimeout(c),d?.(),u&&"function"==typeof u.removeEventListener&&(p&&u.removeEventListener("slotRenderEnded",p),h&&u.removeEventListener("impressionViewable",h));const t=l;l=null,t&&window.googletag?.cmd?.push(()=>{window.googletag.destroySlots([t])}),g.parentNode&&g.parentNode.removeChild(g)}},[r,t.adUnitPath,n,s,e,i]),/* @__PURE__ */R("div",{className:"flex w-full items-center justify-center overflow-x-auto py-2",children:/* @__PURE__ */R("div",{ref:a,style:{width:728,height:90,minWidth:728}})})},Zs=({gamConfig:e,eventId:t,organizationId:r})=>{const{trackGamAnalytics:n}=Me(),o=E(null),a=`gam-sidebar-${t??"ev"}`,i=e.placementCategories?.sidebar;return D(()=>{let s=!1,l=null,c=null,d=null,u=null,p=null,h=null;const m=i?[i]:[],g=document.createElement("div");g.id=a,document.body.appendChild(g);const f=()=>{const e=o.current;if(!e)return;const t=e.getBoundingClientRect(),r=e.parentElement?.getBoundingClientRect(),n=t.width>0&&t.height>0;if(g.style.display=n?"block":"none",!n)return;const a=t.top<=0&&r?Math.min(0,r.bottom-600):t.top;g.style.position="fixed",g.style.top=`${a}px`,g.style.left=`${t.left}px`,g.style.width="160px",g.style.height="600px",g.style.zIndex="20"};return f(),window.addEventListener("scroll",f,{passive:!0}),window.addEventListener("resize",f),(async()=>{await Ne(),s||window.googletag.cmd.push(()=>{if(s)return;Oe(a);const o=window.googletag.defineSlot(e.adUnitPath,[[160,600]],a)?.addService(window.googletag.pubads());o&&(l=o,u=window.googletag.pubads(),t?o.setConfig({targeting:{qrati_event:t,...m.length>0?{qrati_category:m}:{}}}):m.length>0&&o.setConfig({targeting:{qrati_category:m}}),p=e=>{e.slot===o&&n({eventId:t,organizationId:r,type:J.GAM_IMPRESSION,creativeId:String(e.creativeId??""),lineItemId:String(e.lineItemId??""),advertiserId:String(e.advertiserId??""),isEmpty:e.isEmpty??!1})},u.addEventListener("slotRenderEnded",p),h=e=>{e.slot===o&&n({eventId:t,organizationId:r,type:J.GAM_VIEWABLE})},u.addEventListener("impressionViewable",h),d=Ae({container:g,onClick:()=>{n({eventId:t,organizationId:r,type:J.GAM_CLICK})}}),Te(),window.googletag.display(a),c=window.setTimeout(()=>{s||(f(),o.getResponseInformation?.()||window.googletag.pubads().refresh([o]))},1500))})})(),()=>{s=!0,window.removeEventListener("scroll",f),window.removeEventListener("resize",f),null!==c&&window.clearTimeout(c),d?.(),u&&"function"==typeof u.removeEventListener&&(p&&u.removeEventListener("slotRenderEnded",p),h&&u.removeEventListener("impressionViewable",h));const e=l;l=null,e&&window.googletag?.cmd?.push(()=>{window.googletag.destroySlots([e])}),g.parentNode&&g.parentNode.removeChild(g)}},[t,e.adUnitPath,r,i,a]),/* @__PURE__ */R("div",{ref:o,style:{width:160,height:600},className:"hidden shrink-0 self-start lg:block"})},Ks=e=>e?.meta?.currentPage<e?.meta?.totalPages?e.meta.currentPage+1:void 0,Qs=r(()=>import("./BeBNT9RQ.js")),Ys=()=>{const e=x().eventSlug,{loadingUser:t,organization:r}=de(),n=H(),[o,a]=m(""),[i,s]=m(void 0),[l,c]=m(X),[d,p]=m(me),[h,g]=m("undefined"!=typeof window&&window.innerWidth<768?ne.SINGLE:ne.GRID),f=E(null),{event:v,ads:b,gamConfig:y}=$e({eventSlug:e}),{loading:_,isError:k,error:S,refetch:A,contentsWithAds:M,hasNextPage:L,fetchNextPage:N,isFetchingNextPage:I}=(({event:e,ads:t=[],gamConfig:r,sort:n=X,order:o=me,keywords:a,face:i,limit:s=20,includeSummary:l=!1})=>{const{props:c,loadingUser:d,user:p}=de(),h=c?.organizationId,{isLoading:m,isError:g,error:f,data:v,hasNextPage:w,fetchNextPage:b,isFetchingNextPage:y,refetch:_}=function(e){return W(e,He,void 0)}({queryKey:[Z.CONTENTS_BY_EVENT(e?._id??""),n,o,a,i],queryFn:async({pageParam:t=1})=>{try{return await V.get(le.GET_CONTENTS,{searchParams:{eventId:e?._id,page:t,keywords:a,faceImageUrl:i,sort:`${G[o].sortOrder}${re[n].sortField}`,limit:s,includeSummary:l},headers:{"x-org-id":h,Authorization:p?`Bearer ${p.token}`:void 0}}).json()}catch(f){throw new Error(f instanceof Error?f.message:String(f)||"Failed to fetch contents")}},enabled:!d&&!!e,initialPageParam:1,getPreviousPageParam:e=>(e=>e?.meta?.currentPage>1?e.meta.currentPage-1:void 0)(e),getNextPageParam:Ks}),x=u(()=>v?.pages?.flatMap(e=>e?.data??[])??[],[v]);return{contents:x,contentsWithAds:u(()=>"gam"===e?.adMode?r?.inGalleryEnabled?((e=[],t,r)=>{if(!r||r<=0)return e;const[n,o]=t.sizes[0]??[300,250];let a=0;const i=[];for(let s=0;s<e.length;s++)i.push(e[s]),r>0&&(s+1)%r===0&&(i.push({_id:`gam-ad-slot-${a}`,type:ce.GAM_AD,slotIndex:a,width:n,height:o}),a++);return i})(x,r,e?.adPosition??5):x:((e=[],t=[],r)=>{if(!r||r<=0)return e;let n=0;const o=[];for(let a=0;a<(e?.length||0);a++)o.push(e[a]),t.length>0&&r>0&&(a+1)%r===0&&(o.push({...t[n],type:ce.AD,adType:t[n].type}),n=(n+1)%t.length);return o})(x,t,e?.adPosition),[t,x,e?.adMode,e?.adPosition,r]),loading:m,isError:g,error:f,refetch:_,hasNextPage:w,fetchNextPage:b,isFetchingNextPage:y}})({event:v,ads:b,gamConfig:y,sort:l,order:d,keywords:o,face:i,includeSummary:r?.integrationSettings?.showAIDescription}),{incrementEventView:P}=Me(),{start:T,initializing:z,running:F}=(({ref:e,onBottomReached:t,hasNextPage:r,fetchNextPage:n,isFetchingNextPage:o})=>{const a=E(1),i=E(null),s=E(null),l=E(null),[c,d]=m(!1),[u,p]=m(!1);D(()=>(c&&(s.current&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{i.current=window.requestAnimationFrame(h)},300)),()=>{i.current&&window.cancelAnimationFrame(i.current)}),[c,r,o,n,t]);const h=()=>{e.current&&(e.current.scrollTop+=a.current,r&&!o&&n&&e.current.scrollTop+e.current.clientHeight>=.5*e.current.scrollHeight&&n(),e.current.scrollTop+e.current.clientHeight>=e.current.scrollHeight?(d(!1),i.current&&window.cancelAnimationFrame(i.current),s.current=window.setTimeout(()=>{p(!0),t?.(),s.current=window.setTimeout(()=>{e.current&&(e.current.scrollTop=0),p(!1),d(!0)},1e3)},1e3)):i.current=window.requestAnimationFrame(h))},g=e=>{"+"===e.key&&(a.current=Math.min(a.current+1,10)),"-"===e.key&&(a.current=Math.max(a.current-1,1))},f=()=>{document.fullscreenElement||(null!==l.current?l.current.release().then(()=>(l.current=null,!0)).catch(e=>console.error(`Failed to release wake lock: ${e instanceof Error?e.message:String(e)}`)):console.error("No Wake Lock to release."),d(!1),p(!1),e.current&&(e.current.scrollTop=0),i.current&&window.cancelAnimationFrame(i.current),s.current&&window.clearTimeout(s.current),document.removeEventListener("keydown",g),document.removeEventListener("fullscreenchange",f))};return{start:()=>{if(e?.current?.requestFullscreen)e.current.requestFullscreen();else{const t=e.current;t?.webkitRequestFullscreen?t.webkitRequestFullscreen():t?.mozRequestFullScreen?t.mozRequestFullScreen():t?.msRequestFullscreen&&t.msRequestFullscreen()}(async()=>{try{"wakeLock"in navigator?(l.current=await navigator.wakeLock.request("screen"),document.addEventListener("visibilitychange",async()=>{null!==l.current&&"visible"===document.visibilityState&&(l.current=await navigator.wakeLock.request("screen"))})):console.error("Wake Lock API is not supported in this browser.")}catch(Md){console.error(`Failed to acquire wake lock: ${Md instanceof Error?Md.message:String(Md)}`)}})(),d(!0),document.addEventListener("keydown",g),document.addEventListener("fullscreenchange",f)},initializing:u,running:c}})({ref:f,hasNextPage:L,fetchNextPage:N,isFetchingNextPage:I,onBottomReached:()=>v?._id&&n.refetchQueries({queryKey:[Z.CONTENTS_BY_EVENT(v._id)]})});D(()=>{v?.slug&&P(v.slug)},[v]);const U=u(()=>h===ne.SINGLE,[h]),j=u(()=>/* @__PURE__ */R(os,{event:v,onAutoscrollClick:T}),[v?.galleryLayout,T]),q=E(null),K=E(null);D(()=>(q.current&&q.current.disconnect(),q.current=new IntersectionObserver(e=>{e[0].isIntersecting&&L&&!I&&!_&&N()},{rootMargin:"200px"}),K.current&&q.current.observe(K.current),()=>{q.current&&q.current.disconnect()}),[L,I,_,N]);const Q=y?.bannerPositions??[],Y=r?._id,J=y&&Q.includes("sidebar");/* @__PURE__ */
86
+ /* @__PURE__ */R("div",{className:"col-span-3 mt-3 md:col-span-1 md:mt-0 lg:justify-self-end",children:/* @__PURE__ */R(ls,{engagementStyle:e,sort:o,order:i,onSortChange:a,onSortOrderChange:s})})]})},Vs=({position:e,gamConfig:t,eventId:r,organizationId:n})=>{const{trackGamAnalytics:o}=Me(),a=E(null),i=`gam-${e}-banner-${r??"ev"}`,s=t.placementCategories?.[e];return D(()=>{let e=!1,l=null,c=null,d=null,u=null,p=null,h=null;const m=s?[s]:[],g=document.createElement("div");g.id=i,document.body.appendChild(g);const f=()=>{const e=a.current;if(!e)return;const t=e.getBoundingClientRect(),r=t.width>0&&t.height>0;g.style.display=r?"block":"none",r&&(g.style.position="fixed",g.style.top=`${t.top}px`,g.style.left=`${t.left}px`,g.style.width="728px",g.style.height="90px",g.style.zIndex="20")};return f(),window.addEventListener("scroll",f,{passive:!0}),window.addEventListener("resize",f),(async()=>{await Ne(),e||window.googletag.cmd.push(()=>{if(e)return;Oe(i);const a=window.googletag.defineSlot(t.adUnitPath,[[728,90]],i)?.addService(window.googletag.pubads());a&&(l=a,u=window.googletag.pubads(),r?a.setConfig({targeting:{qrati_event:r,...m.length>0?{qrati_category:m}:{}}}):m.length>0&&a.setConfig({targeting:{qrati_category:m}}),p=e=>{e.slot===a&&o({eventId:r,organizationId:n,type:J.GAM_IMPRESSION,creativeId:String(e.creativeId??""),lineItemId:String(e.lineItemId??""),advertiserId:String(e.advertiserId??""),isEmpty:e.isEmpty??!1})},u.addEventListener("slotRenderEnded",p),h=e=>{e.slot===a&&o({eventId:r,organizationId:n,type:J.GAM_VIEWABLE})},u.addEventListener("impressionViewable",h),d=Ae({container:g,onClick:()=>{o({eventId:r,organizationId:n,type:J.GAM_CLICK})}}),Te(),window.googletag.display(i),c=window.setTimeout(()=>{e||(f(),a.getResponseInformation?.()||window.googletag.pubads().refresh([a]))},1500))})})(),()=>{e=!0,window.removeEventListener("scroll",f),window.removeEventListener("resize",f),null!==c&&window.clearTimeout(c),d?.(),u&&"function"==typeof u.removeEventListener&&(p&&u.removeEventListener("slotRenderEnded",p),h&&u.removeEventListener("impressionViewable",h));const t=l;l=null,t&&window.googletag?.cmd?.push(()=>{window.googletag.destroySlots([t])}),g.parentNode&&g.parentNode.removeChild(g)}},[r,t.adUnitPath,n,s,e,i]),/* @__PURE__ */R("div",{className:"flex w-full items-center justify-center overflow-x-auto py-2",children:/* @__PURE__ */R("div",{ref:a,style:{width:728,height:90,minWidth:728}})})},Zs=({gamConfig:e,eventId:t,organizationId:r})=>{const{trackGamAnalytics:n}=Me(),o=E(null),a=`gam-sidebar-${t??"ev"}`,i=e.placementCategories?.sidebar;return D(()=>{let s=!1,l=null,c=null,d=null,u=null,p=null,h=null;const m=i?[i]:[],g=document.createElement("div");g.id=a,document.body.appendChild(g);const f=()=>{const e=o.current;if(!e)return;const t=e.getBoundingClientRect(),r=e.parentElement?.getBoundingClientRect(),n=t.width>0&&t.height>0;if(g.style.display=n?"block":"none",!n)return;const a=t.top<=0&&r?Math.min(0,r.bottom-600):t.top;g.style.position="fixed",g.style.top=`${a}px`,g.style.left=`${t.left}px`,g.style.width="160px",g.style.height="600px",g.style.zIndex="20"};return f(),window.addEventListener("scroll",f,{passive:!0}),window.addEventListener("resize",f),(async()=>{await Ne(),s||window.googletag.cmd.push(()=>{if(s)return;Oe(a);const o=window.googletag.defineSlot(e.adUnitPath,[[160,600]],a)?.addService(window.googletag.pubads());o&&(l=o,u=window.googletag.pubads(),t?o.setConfig({targeting:{qrati_event:t,...m.length>0?{qrati_category:m}:{}}}):m.length>0&&o.setConfig({targeting:{qrati_category:m}}),p=e=>{e.slot===o&&n({eventId:t,organizationId:r,type:J.GAM_IMPRESSION,creativeId:String(e.creativeId??""),lineItemId:String(e.lineItemId??""),advertiserId:String(e.advertiserId??""),isEmpty:e.isEmpty??!1})},u.addEventListener("slotRenderEnded",p),h=e=>{e.slot===o&&n({eventId:t,organizationId:r,type:J.GAM_VIEWABLE})},u.addEventListener("impressionViewable",h),d=Ae({container:g,onClick:()=>{n({eventId:t,organizationId:r,type:J.GAM_CLICK})}}),Te(),window.googletag.display(a),c=window.setTimeout(()=>{s||(f(),o.getResponseInformation?.()||window.googletag.pubads().refresh([o]))},1500))})})(),()=>{s=!0,window.removeEventListener("scroll",f),window.removeEventListener("resize",f),null!==c&&window.clearTimeout(c),d?.(),u&&"function"==typeof u.removeEventListener&&(p&&u.removeEventListener("slotRenderEnded",p),h&&u.removeEventListener("impressionViewable",h));const e=l;l=null,e&&window.googletag?.cmd?.push(()=>{window.googletag.destroySlots([e])}),g.parentNode&&g.parentNode.removeChild(g)}},[t,e.adUnitPath,r,i,a]),/* @__PURE__ */R("div",{ref:o,style:{width:160,height:600},className:"hidden shrink-0 self-start lg:block"})},Ks=e=>e?.meta?.currentPage<e?.meta?.totalPages?e.meta.currentPage+1:void 0,Qs=r(()=>import("./BhtZwJ7r.js")),Ys=()=>{const e=x().eventSlug,{loadingUser:t,organization:r}=de(),n=H(),[o,a]=m(""),[i,s]=m(void 0),[l,c]=m(X),[d,p]=m(me),[h,g]=m("undefined"!=typeof window&&window.innerWidth<768?ne.SINGLE:ne.GRID),f=E(null),{event:v,ads:b,gamConfig:y}=$e({eventSlug:e}),{loading:_,isError:k,error:S,refetch:A,contentsWithAds:M,hasNextPage:L,fetchNextPage:N,isFetchingNextPage:I}=(({event:e,ads:t=[],gamConfig:r,sort:n=X,order:o=me,keywords:a,face:i,limit:s=20,includeSummary:l=!1})=>{const{props:c,loadingUser:d,user:p}=de(),h=c?.organizationId,{isLoading:m,isError:g,error:f,data:v,hasNextPage:w,fetchNextPage:b,isFetchingNextPage:y,refetch:_}=function(e){return W(e,He,void 0)}({queryKey:[Z.CONTENTS_BY_EVENT(e?._id??""),n,o,a,i],queryFn:async({pageParam:t=1})=>{try{return await V.get(le.GET_CONTENTS,{searchParams:{eventId:e?._id,page:t,keywords:a,faceImageUrl:i,sort:`${G[o].sortOrder}${re[n].sortField}`,limit:s,includeSummary:l},headers:{"x-org-id":h,Authorization:p?`Bearer ${p.token}`:void 0}}).json()}catch(f){throw new Error(f instanceof Error?f.message:String(f)||"Failed to fetch contents")}},enabled:!d&&!!e,initialPageParam:1,getPreviousPageParam:e=>(e=>e?.meta?.currentPage>1?e.meta.currentPage-1:void 0)(e),getNextPageParam:Ks}),x=u(()=>v?.pages?.flatMap(e=>e?.data??[])??[],[v]);return{contents:x,contentsWithAds:u(()=>"gam"===e?.adMode?r?.inGalleryEnabled?((e=[],t,r)=>{if(!r||r<=0)return e;const[n,o]=t.sizes[0]??[300,250];let a=0;const i=[];for(let s=0;s<e.length;s++)i.push(e[s]),r>0&&(s+1)%r===0&&(i.push({_id:`gam-ad-slot-${a}`,type:ce.GAM_AD,slotIndex:a,width:n,height:o}),a++);return i})(x,r,e?.adPosition??5):x:((e=[],t=[],r)=>{if(!r||r<=0)return e;let n=0;const o=[];for(let a=0;a<(e?.length||0);a++)o.push(e[a]),t.length>0&&r>0&&(a+1)%r===0&&(o.push({...t[n],type:ce.AD,adType:t[n].type}),n=(n+1)%t.length);return o})(x,t,e?.adPosition),[t,x,e?.adMode,e?.adPosition,r]),loading:m,isError:g,error:f,refetch:_,hasNextPage:w,fetchNextPage:b,isFetchingNextPage:y}})({event:v,ads:b,gamConfig:y,sort:l,order:d,keywords:o,face:i,includeSummary:r?.integrationSettings?.showAIDescription}),{incrementEventView:P}=Me(),{start:T,initializing:z,running:F}=(({ref:e,onBottomReached:t,hasNextPage:r,fetchNextPage:n,isFetchingNextPage:o})=>{const a=E(1),i=E(null),s=E(null),l=E(null),[c,d]=m(!1),[u,p]=m(!1);D(()=>(c&&(s.current&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{i.current=window.requestAnimationFrame(h)},300)),()=>{i.current&&window.cancelAnimationFrame(i.current)}),[c,r,o,n,t]);const h=()=>{e.current&&(e.current.scrollTop+=a.current,r&&!o&&n&&e.current.scrollTop+e.current.clientHeight>=.5*e.current.scrollHeight&&n(),e.current.scrollTop+e.current.clientHeight>=e.current.scrollHeight?(d(!1),i.current&&window.cancelAnimationFrame(i.current),s.current=window.setTimeout(()=>{p(!0),t?.(),s.current=window.setTimeout(()=>{e.current&&(e.current.scrollTop=0),p(!1),d(!0)},1e3)},1e3)):i.current=window.requestAnimationFrame(h))},g=e=>{"+"===e.key&&(a.current=Math.min(a.current+1,10)),"-"===e.key&&(a.current=Math.max(a.current-1,1))},f=()=>{document.fullscreenElement||(null!==l.current?l.current.release().then(()=>(l.current=null,!0)).catch(e=>console.error(`Failed to release wake lock: ${e instanceof Error?e.message:String(e)}`)):console.error("No Wake Lock to release."),d(!1),p(!1),e.current&&(e.current.scrollTop=0),i.current&&window.cancelAnimationFrame(i.current),s.current&&window.clearTimeout(s.current),document.removeEventListener("keydown",g),document.removeEventListener("fullscreenchange",f))};return{start:()=>{if(e?.current?.requestFullscreen)e.current.requestFullscreen();else{const t=e.current;t?.webkitRequestFullscreen?t.webkitRequestFullscreen():t?.mozRequestFullScreen?t.mozRequestFullScreen():t?.msRequestFullscreen&&t.msRequestFullscreen()}(async()=>{try{"wakeLock"in navigator?(l.current=await navigator.wakeLock.request("screen"),document.addEventListener("visibilitychange",async()=>{null!==l.current&&"visible"===document.visibilityState&&(l.current=await navigator.wakeLock.request("screen"))})):console.error("Wake Lock API is not supported in this browser.")}catch(Md){console.error(`Failed to acquire wake lock: ${Md instanceof Error?Md.message:String(Md)}`)}})(),d(!0),document.addEventListener("keydown",g),document.addEventListener("fullscreenchange",f)},initializing:u,running:c}})({ref:f,hasNextPage:L,fetchNextPage:N,isFetchingNextPage:I,onBottomReached:()=>v?._id&&n.refetchQueries({queryKey:[Z.CONTENTS_BY_EVENT(v._id)]})});D(()=>{v?.slug&&P(v.slug)},[v]);const U=u(()=>h===ne.SINGLE,[h]),j=u(()=>/* @__PURE__ */R(os,{event:v,onAutoscrollClick:T}),[v?.galleryLayout,T]),q=E(null),K=E(null);D(()=>(q.current&&q.current.disconnect(),q.current=new IntersectionObserver(e=>{e[0].isIntersecting&&L&&!I&&!_&&N()},{rootMargin:"200px"}),K.current&&q.current.observe(K.current),()=>{q.current&&q.current.disconnect()}),[L,I,_,N]);const Q=y?.bannerPositions??[],Y=r?._id,J=y&&Q.includes("sidebar");/* @__PURE__ */
87
87
  return R("div",{className:"bg-background mx-auto min-h-[80vh]",children:[
88
88
  /* @__PURE__ */R("div",{className:"flex flex-row justify-end gap-4 pt-2",children:j}),
89
89
  /* @__PURE__ */R("div",{className:"pb-2",children:/* @__PURE__ */R(st,{})}),y&&Q.includes("top")&&/* @__PURE__ */R(Vs,{position:"top",gamConfig:y,eventId:v?._id,organizationId:Y}),
@@ -256,7 +256,7 @@ return R("div",{className:"mt-3 space-y-6 sm:mt-6",children:["content"===r&&f.le
256
256
  return R("div",{className:"space-y-4",children:[t===p[0]&&/* @__PURE__ */R(Le,{variant:"h3",className:"mb-4",children:["Events (",c.length,")"]}),
257
257
  /* @__PURE__ */R("div",{className:"flex items-center justify-between gap-3",children:[/* @__PURE__ */R("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */R("span",{className:"inline-block size-2 rounded-full",style:{backgroundColor:r.color||"#9ca3af"}}),/* @__PURE__ */R(Le,{variant:"h5",className:"text-sm sm:text-base",children:r.pathLabel})]}),/* @__PURE__ */R(Le,{variant:"body2",color:"muted",children:[n.length," ",1===n.length?"result":"results"]})]}),
258
258
  /* @__PURE__ */R("div",{className:"grid grid-cols-1 gap-4 gap-y-6 sm:grid-cols-2 lg:grid-cols-3",children:n.map(e=>/* @__PURE__ */R(C,{event:e},e._id))})]},`event-folder-${t}`)}):p.map(e=>{const r=g[e]||[];/* @__PURE__ */
259
- return R("div",{className:"space-y-4",children:[e===p[0]&&/* @__PURE__ */R(Le,{variant:"h3",className:"mb-4",children:["Contents (",u?.totalContentCount||d.length,") Events (",u?.totalEventCount||m.length,")"]}),/* @__PURE__ */R("div",{className:"space-y-6",children:r.map(e=>/* @__PURE__ */R("div",{className:"space-y-3",children:[/* @__PURE__ */R(C,{event:e.event}),/* @__PURE__ */R("div",{className:"grid grid-cols-3 gap-3",children:e.contents.map(r=>/* @__PURE__ */R(Ac,{content:r,timestampField:"captureTime",submittedQuery:t,onClick:()=>b(e.event._id,r._id)},r._id))})]},`content-event-${e.event._id}`))})]},`content-folder-${e}`)})),"content"===r&&i&&!o&&/* @__PURE__ */R("div",{ref:_,className:"h-4 w-full","aria-hidden":"true"}),"content"===r&&i&&n&&s>1&&!o&&/* @__PURE__ */R("div",{className:"flex justify-center pt-2",children:/* @__PURE__ */R(We,{name:"eos-icons:loading",className:"text-2xl"})}),"event"===r&&i&&a&&!o&&/* @__PURE__ */R("div",{className:"flex justify-center pt-2",children:/* @__PURE__ */R("button",{type:"button",disabled:n,className:"bg-primary text-primary-foreground disabled:bg-muted rounded px-4 py-2 text-sm font-medium disabled:cursor-not-allowed",onClick:l,children:n?"Loading...":"Load More"})})]})},Lc=r(()=>import("./CWJf7mNz.js")),Nc={grid:{icon:/* @__PURE__ */R("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-full text-inherit",width:24,height:24,viewBox:"0 0 24 24",children:/* @__PURE__ */R("path",{fill:"currentColor",d:"M5 11q-.825 0-1.412-.587T3 9V5q0-.825.588-1.412T5 3h4q.825 0 1.413.588T11 5v4q0 .825-.587 1.413T9 11zm0 10q-.825 0-1.412-.587T3 19v-4q0-.825.588-1.412T5 13h4q.825 0 1.413.588T11 15v4q0 .825-.587 1.413T9 21zm10-10q-.825 0-1.412-.587T13 9V5q0-.825.588-1.412T15 3h4q.825 0 1.413.588T21 5v4q0 .825-.587 1.413T19 11zm0 10q-.825 0-1.412-.587T13 19v-4q0-.825.588-1.412T15 13h4q.825 0 1.413.588T21 15v4q0 .825-.587 1.413T19 21zM5 9h4V5H5zm10 0h4V5h-4zm0 10h4v-4h-4zM5 19h4v-4H5zM9 9"})})},map:{icon:/* @__PURE__ */R("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-full text-inherit",width:24,height:24,viewBox:"0 0 24 24",children:/* @__PURE__ */R("path",{fill:"currentColor",d:"M14.35 20.775L9 18.9l-4.65 1.8q-.25.1-.488.063t-.437-.163t-.312-.337T3 19.775V5.75q0-.325.188-.575T3.7 4.8l4.65-1.575q.15-.05.313-.075T9 3.125t.338.025t.312.075L15 5.1l4.65-1.8q.25-.1.488-.062t.437.162t.313.338t.112.487V18.25q0 .325-.187.575t-.513.375l-4.65 1.575q-.15.05-.312.075t-.338.025t-.337-.025t-.313-.075M14 18.55V6.85l-4-1.4v11.7zm2 0l3-1V5.7l-3 1.15zM5 18.3l3-1.15V5.45l-3 1zM16 6.85v11.7zm-8-1.4v11.7z"})})}},Ic=Object.keys(Nc).map(e=>({icon:Nc[e].icon,value:e})),Pc=()=>{const e=x().folderId??"",t=de(),{folders:r,organization:n}=t,o=t.props?.organizationId,a=!1!==n?.integrationSettings?.enableGlobalSearch,i=((e,t)=>{const[r,n]=m(""),[o,a]=m("event"),[i,s]=m(1),[l,c]=m(!1),[d,p]=m(""),[h,g]=m(!1),[f,v]=m([]),[w,b]=m([]),[y,_]=m(null),x=E(0),C=E(null),k=E(null),S=u(()=>`org-inline-search-gallery-${e||"default"}`,[e]);D(()=>{if(!e||!r)return;const t=++x.current;(async()=>{c(!0),p("");try{const n="event"===o?le.SEARCH_EVENTS:le.SEARCH_CONTENTS,a=await V.get(n,{timeout:6e4,headers:{"x-org-id":e},searchParams:{query:r,page:String(i),limit:"event"===o?"12":"8"}}).json();if(t!==x.current)return;const s=a?.data||[];console.log("next data ",s);const l=a?.meta?.totalPages||0;g((a?.meta?.currentPage||0)<l),"event"===o?v(e=>1===i?s:[...e,...s]):(_({totalContentCount:a?.meta?.totalContentCount,totalEventCount:a?.meta?.totalEventCount}),b(e=>1===i?s:[...e,...s]))}catch(n){if(t!==x.current)return;p(n?.message||"Failed to search")}finally{t===x.current&&c(!1)}})()},[e,i,r,o]);const A=u(()=>{const e={};return f.forEach(t=>{const r=t.folderId||"root";e[r]||(e[r]=[]),e[r].push(t)}),Object.values(e).forEach(e=>{e.sort((e,t)=>(e.name||"").localeCompare(t.name||"",void 0,{sensitivity:"base"}))}),e},[f]),M=u(()=>{const e=/* @__PURE__ */new Map,t=/* @__PURE__ */new Set;return w.forEach(r=>{if(!r?._id||t.has(r._id))return;t.add(r._id);const n=r.event?._id||r.eventId;n&&r.event&&(e.has(n)||e.set(n,{event:r.event,contents:[]}),e.get(n)?.contents.push({...r}))}),Array.from(e.values()).sort((e,t)=>(e.event?.name||"").localeCompare(t.event?.name||"",void 0,{sensitivity:"base"}))},[w]),L=u(()=>{const e={};return M.forEach(t=>{const r=t.event?.folderId||"root";e[r]||(e[r]=[]),e[r].push(t)}),e},[M]),N=u(()=>{const e=Object.keys("event"===o?A:L);return e.sort((e,r)=>{if("root"===e)return-1;if("root"===r)return 1;const n=xe(t,e).map(e=>e.name).join("/"),o=xe(t,r).map(e=>e.name).join("/");return n.localeCompare(o)}),e},[L,A,t,o]),I=u(()=>{if("content"!==o)return[];const e=[];return N.forEach(t=>{(L[t]||[]).forEach(t=>{t.contents.forEach(r=>{e.push({event:t.event,content:r})})})}),e},[N,L,o]);return D(()=>{const e=k.current;if("content"!==o||!r||0===I.length||!e)return C.current?.destroy?.(),void(C.current=null);const t=new ze({gallery:e,children:"a.pswp-item",counter:!1,bgOpacity:1,wheelToZoom:!0,pinchToClose:!0,zoom:!1,pswpModule:Ue});return C.current=t,t.init(),()=>{C.current?.destroy?.(),C.current=null}},[I.length,S,r,o]),{handleSearch:(e,t)=>{s(1),p(""),g(!1),v([]),b([]),_(null),a(t),n(e)},clearSearch:()=>{n(""),p(""),g(!1),s(1),v([]),b([]),_(null)},isSearchActive:r.length>0,submittedQuery:r,submittedSearchType:o,isLoading:l,errorMessage:d,hasMore:h,page:i,setPage:s,eventResults:f,contentResults:w,contentMeta:y,activeFolderKeys:N,eventGroupsByFolder:A,contentGroups:M,contentGroupsByFolder:L,flattenedContentMedia:I,lightboxRef:C,galleryElementRef:k,galleryId:S,openMediaInLightbox:(e,t)=>{if(!C.current?.loadAndOpen)return;const r=I.findIndex(r=>r.event._id===e&&r.content._id===t);r>=0&&C.current.loadAndOpen(r)}}})(o,r||[]),s=!0===n?.integrationSettings?.enableMapView,[l,c]=m(()=>{try{return sessionStorage.getItem("qrati-view-mode")||"grid"}catch{return"grid"}}),{data:d,isLoading:p}=K({queryKey:[`public-events-map-${o}`,e||"all-folders"],enabled:s&&"map"===l,staleTime:3e5,queryFn:async()=>{const t=e.length>0?{folderId:e,limit:500,sort:"-views"}:{includeAllFolders:"true",limit:500,sort:"-views",contentLimit:3};return(await V.get(le.PUBLIC_EVENTS,{headers:{"x-org-id":o},searchParams:t}).json()).data}}),h=u(()=>{if("undefined"==typeof window)return null;if(window.history.state?.internalNavigation)return null;try{const e=new URLSearchParams(window.location?.search??"");let t=e.get("event"),r=e.get("page");if(!t&&!r&&window.location?.hash){const e=window.location.hash.split("?");if(e.length>1){const n=new URLSearchParams(e[1]);t=n.get("event"),r=n.get("page")}}if(t){if(r)switch(r.toLowerCase()){case"upload":return B.UPLOAD(t);case"curate":return B.CURATE(t);case"leaderboard":return B.LEADERBOARD(t);default:return B.GALLERY(t)}return B.GALLERY(t)}}catch(Md){console.error("Error parsing URL parameters:",Md)}return null},[]),g=(r??[]).filter(t=>t.parentFolderId===(e?.length>0?e:null)||t.parentFolderId===(e?.length>0?e:void 0)),{isLoading:f,data:v}=K({queryKey:[`public-events-${o}`,e],queryFn:async()=>(await V.get(le.PUBLIC_EVENTS,{headers:{"x-org-id":o},searchParams:{folderId:e,sort:"-createdAt"}}).json()).data});return h?/* @__PURE__ */R(y,{to:h,replace:!0}):/* @__PURE__ */R(w,f||!n?{children:[n?.navigationSettings?.enableNavbar&&/* @__PURE__ */R(tt,{}),/* @__PURE__ */R("div",{className:"min-h-screen w-full",children:[
259
+ return R("div",{className:"space-y-4",children:[e===p[0]&&/* @__PURE__ */R(Le,{variant:"h3",className:"mb-4",children:["Contents (",u?.totalContentCount||d.length,") Events (",u?.totalEventCount||m.length,")"]}),/* @__PURE__ */R("div",{className:"space-y-6",children:r.map(e=>/* @__PURE__ */R("div",{className:"space-y-3",children:[/* @__PURE__ */R(C,{event:e.event}),/* @__PURE__ */R("div",{className:"grid grid-cols-3 gap-3",children:e.contents.map(r=>/* @__PURE__ */R(Ac,{content:r,timestampField:"captureTime",submittedQuery:t,onClick:()=>b(e.event._id,r._id)},r._id))})]},`content-event-${e.event._id}`))})]},`content-folder-${e}`)})),"content"===r&&i&&!o&&/* @__PURE__ */R("div",{ref:_,className:"h-4 w-full","aria-hidden":"true"}),"content"===r&&i&&n&&s>1&&!o&&/* @__PURE__ */R("div",{className:"flex justify-center pt-2",children:/* @__PURE__ */R(We,{name:"eos-icons:loading",className:"text-2xl"})}),"event"===r&&i&&a&&!o&&/* @__PURE__ */R("div",{className:"flex justify-center pt-2",children:/* @__PURE__ */R("button",{type:"button",disabled:n,className:"bg-primary text-primary-foreground disabled:bg-muted rounded px-4 py-2 text-sm font-medium disabled:cursor-not-allowed",onClick:l,children:n?"Loading...":"Load More"})})]})},Lc=r(()=>import("./BI8RhPVM.js")),Nc={grid:{icon:/* @__PURE__ */R("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-full text-inherit",width:24,height:24,viewBox:"0 0 24 24",children:/* @__PURE__ */R("path",{fill:"currentColor",d:"M5 11q-.825 0-1.412-.587T3 9V5q0-.825.588-1.412T5 3h4q.825 0 1.413.588T11 5v4q0 .825-.587 1.413T9 11zm0 10q-.825 0-1.412-.587T3 19v-4q0-.825.588-1.412T5 13h4q.825 0 1.413.588T11 15v4q0 .825-.587 1.413T9 21zm10-10q-.825 0-1.412-.587T13 9V5q0-.825.588-1.412T15 3h4q.825 0 1.413.588T21 5v4q0 .825-.587 1.413T19 11zm0 10q-.825 0-1.412-.587T13 19v-4q0-.825.588-1.412T15 13h4q.825 0 1.413.588T21 15v4q0 .825-.587 1.413T19 21zM5 9h4V5H5zm10 0h4V5h-4zm0 10h4v-4h-4zM5 19h4v-4H5zM9 9"})})},map:{icon:/* @__PURE__ */R("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-full text-inherit",width:24,height:24,viewBox:"0 0 24 24",children:/* @__PURE__ */R("path",{fill:"currentColor",d:"M14.35 20.775L9 18.9l-4.65 1.8q-.25.1-.488.063t-.437-.163t-.312-.337T3 19.775V5.75q0-.325.188-.575T3.7 4.8l4.65-1.575q.15-.05.313-.075T9 3.125t.338.025t.312.075L15 5.1l4.65-1.8q.25-.1.488-.062t.437.162t.313.338t.112.487V18.25q0 .325-.187.575t-.513.375l-4.65 1.575q-.15.05-.312.075t-.338.025t-.337-.025t-.313-.075M14 18.55V6.85l-4-1.4v11.7zm2 0l3-1V5.7l-3 1.15zM5 18.3l3-1.15V5.45l-3 1zM16 6.85v11.7zm-8-1.4v11.7z"})})}},Ic=Object.keys(Nc).map(e=>({icon:Nc[e].icon,value:e})),Pc=()=>{const e=x().folderId??"",t=de(),{folders:r,organization:n}=t,o=t.props?.organizationId,a=!1!==n?.integrationSettings?.enableGlobalSearch,i=((e,t)=>{const[r,n]=m(""),[o,a]=m("event"),[i,s]=m(1),[l,c]=m(!1),[d,p]=m(""),[h,g]=m(!1),[f,v]=m([]),[w,b]=m([]),[y,_]=m(null),x=E(0),C=E(null),k=E(null),S=u(()=>`org-inline-search-gallery-${e||"default"}`,[e]);D(()=>{if(!e||!r)return;const t=++x.current;(async()=>{c(!0),p("");try{const n="event"===o?le.SEARCH_EVENTS:le.SEARCH_CONTENTS,a=await V.get(n,{timeout:6e4,headers:{"x-org-id":e},searchParams:{query:r,page:String(i),limit:"event"===o?"12":"8"}}).json();if(t!==x.current)return;const s=a?.data||[];console.log("next data ",s);const l=a?.meta?.totalPages||0;g((a?.meta?.currentPage||0)<l),"event"===o?v(e=>1===i?s:[...e,...s]):(_({totalContentCount:a?.meta?.totalContentCount,totalEventCount:a?.meta?.totalEventCount}),b(e=>1===i?s:[...e,...s]))}catch(n){if(t!==x.current)return;p(n?.message||"Failed to search")}finally{t===x.current&&c(!1)}})()},[e,i,r,o]);const A=u(()=>{const e={};return f.forEach(t=>{const r=t.folderId||"root";e[r]||(e[r]=[]),e[r].push(t)}),Object.values(e).forEach(e=>{e.sort((e,t)=>(e.name||"").localeCompare(t.name||"",void 0,{sensitivity:"base"}))}),e},[f]),M=u(()=>{const e=/* @__PURE__ */new Map,t=/* @__PURE__ */new Set;return w.forEach(r=>{if(!r?._id||t.has(r._id))return;t.add(r._id);const n=r.event?._id||r.eventId;n&&r.event&&(e.has(n)||e.set(n,{event:r.event,contents:[]}),e.get(n)?.contents.push({...r}))}),Array.from(e.values()).sort((e,t)=>(e.event?.name||"").localeCompare(t.event?.name||"",void 0,{sensitivity:"base"}))},[w]),L=u(()=>{const e={};return M.forEach(t=>{const r=t.event?.folderId||"root";e[r]||(e[r]=[]),e[r].push(t)}),e},[M]),N=u(()=>{const e=Object.keys("event"===o?A:L);return e.sort((e,r)=>{if("root"===e)return-1;if("root"===r)return 1;const n=xe(t,e).map(e=>e.name).join("/"),o=xe(t,r).map(e=>e.name).join("/");return n.localeCompare(o)}),e},[L,A,t,o]),I=u(()=>{if("content"!==o)return[];const e=[];return N.forEach(t=>{(L[t]||[]).forEach(t=>{t.contents.forEach(r=>{e.push({event:t.event,content:r})})})}),e},[N,L,o]);return D(()=>{const e=k.current;if("content"!==o||!r||0===I.length||!e)return C.current?.destroy?.(),void(C.current=null);const t=new ze({gallery:e,children:"a.pswp-item",counter:!1,bgOpacity:1,wheelToZoom:!0,pinchToClose:!0,zoom:!1,pswpModule:Ue});return C.current=t,t.init(),()=>{C.current?.destroy?.(),C.current=null}},[I.length,S,r,o]),{handleSearch:(e,t)=>{s(1),p(""),g(!1),v([]),b([]),_(null),a(t),n(e)},clearSearch:()=>{n(""),p(""),g(!1),s(1),v([]),b([]),_(null)},isSearchActive:r.length>0,submittedQuery:r,submittedSearchType:o,isLoading:l,errorMessage:d,hasMore:h,page:i,setPage:s,eventResults:f,contentResults:w,contentMeta:y,activeFolderKeys:N,eventGroupsByFolder:A,contentGroups:M,contentGroupsByFolder:L,flattenedContentMedia:I,lightboxRef:C,galleryElementRef:k,galleryId:S,openMediaInLightbox:(e,t)=>{if(!C.current?.loadAndOpen)return;const r=I.findIndex(r=>r.event._id===e&&r.content._id===t);r>=0&&C.current.loadAndOpen(r)}}})(o,r||[]),s=!0===n?.integrationSettings?.enableMapView,[l,c]=m(()=>{try{return sessionStorage.getItem("qrati-view-mode")||"grid"}catch{return"grid"}}),{data:d,isLoading:p}=K({queryKey:[`public-events-map-${o}`,e||"all-folders"],enabled:s&&"map"===l,staleTime:3e5,queryFn:async()=>{const t=e.length>0?{folderId:e,limit:500,sort:"-views"}:{includeAllFolders:"true",limit:500,sort:"-views",contentLimit:3};return(await V.get(le.PUBLIC_EVENTS,{headers:{"x-org-id":o},searchParams:t}).json()).data}}),h=u(()=>{if("undefined"==typeof window)return null;if(window.history.state?.internalNavigation)return null;try{const e=new URLSearchParams(window.location?.search??"");let t=e.get("event"),r=e.get("page");if(!t&&!r&&window.location?.hash){const e=window.location.hash.split("?");if(e.length>1){const n=new URLSearchParams(e[1]);t=n.get("event"),r=n.get("page")}}if(t){if(r)switch(r.toLowerCase()){case"upload":return B.UPLOAD(t);case"curate":return B.CURATE(t);case"leaderboard":return B.LEADERBOARD(t);default:return B.GALLERY(t)}return B.GALLERY(t)}}catch(Md){console.error("Error parsing URL parameters:",Md)}return null},[]),g=(r??[]).filter(t=>t.parentFolderId===(e?.length>0?e:null)||t.parentFolderId===(e?.length>0?e:void 0)),{isLoading:f,data:v}=K({queryKey:[`public-events-${o}`,e],queryFn:async()=>(await V.get(le.PUBLIC_EVENTS,{headers:{"x-org-id":o},searchParams:{folderId:e,sort:"-createdAt"}}).json()).data});return h?/* @__PURE__ */R(y,{to:h,replace:!0}):/* @__PURE__ */R(w,f||!n?{children:[n?.navigationSettings?.enableNavbar&&/* @__PURE__ */R(tt,{}),/* @__PURE__ */R("div",{className:"min-h-screen w-full",children:[
260
260
  /* @__PURE__ */R(kc,{organization:n}),
261
261
  /* @__PURE__ */R("div",{className:"mt-4 grid grid-cols-2 gap-3 md:grid-cols-3 lg:grid-cols-4 lg:gap-6",children:Array.from({length:4}).map((e,t)=>/* @__PURE__ */R(Ge,{className:"h-24 rounded"},`folder-${t}`))}),
262
262
  /* @__PURE__ */R("div",{className:"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-3",children:Array.from({length:6}).map((e,t)=>/* @__PURE__ */R("div",{className:"space-y-4",children:[/* @__PURE__ */R(Ge,{className:"h-72 overflow-hidden rounded sm:h-80"}),/* @__PURE__ */R(Ge,{className:"h-6 w-64 rounded"})]},t))})]})]}:{children:[n?.navigationSettings?.enableNavbar&&/* @__PURE__ */R(tt,{}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qratilabs/qrati-connect",
3
- "version": "2.15.0",
3
+ "version": "2.16.0",
4
4
  "description": "Qrati Connect - A React-based micro frontend component",
5
5
  "author": "Qrati Labs",
6
6
  "license": "MIT",
@@ -1 +1 @@
1
- import{a as e}from"./CsohJ1Yu.js";import{E as t,k as r,r as n,v as o,y as i}from"./BsUU5VBO.js";import{t as a}from"./BmbdEikc.js";var s=(e,t,i)=>{r(/* @__PURE__ */o(n,{children:/* @__PURE__ */o(a,{event:e,onExplore:i})}),t)},l=({events:r,apiKey:n,is3D:a,onExplore:l,logoUrl:c})=>{const d=i(null),u=i(null),p=i(a);return t(()=>{if(!d.current||u.current)return;let t;return(async()=>{const o=(await import("./BTZXR2Ef.js").then(t=>/* @__PURE__ */e(t.default,1))).default;if(!document.querySelector("link[data-qrati-maplibre-css]")){const e=document.createElement("link");e.rel="stylesheet",e.href="https://unpkg.com/maplibre-gl@5.21.0/dist/maplibre-gl.css",e.setAttribute("data-qrati-maplibre-css",""),document.head.appendChild(e)}if(!d.current)return;const i=new o.Map({container:d.current,style:`https://api.maptiler.com/maps/streets-v2/style.json?key=${n}`,center:[0,20],zoom:4,minZoom:2,pitch:0,bearing:0,projection:p.current?{type:"globe"}:{type:"mercator"},canvasContextAttributes:{antialias:!0}});u.current=i,i.on("load",()=>{const e=i.getStyle()?.layers??[];let t,n;for(const r of e){const e=r;"symbol"===e.type&&e.layout?.["text-field"]&&!t&&(t=r.id),"building"!==e["source-layer"]||n||(n=e.source)}n&&!i.getLayer("3d-buildings")&&i.addLayer({id:"3d-buildings",source:n,"source-layer":"building",filter:["has","render_height"],type:"fill-extrusion",minzoom:14,paint:{"fill-extrusion-color":["interpolate",["linear"],["get","render_height"],0,"lightgray",200,"royalblue",400,"lightblue"],"fill-extrusion-height":["interpolate",["linear"],["zoom"],14,0,15,["get","render_height"]],"fill-extrusion-base":["case",["has","render_min_height"],["get","render_min_height"],0],"fill-extrusion-opacity":.6}},t);const a=r.filter(e=>"number"==typeof e.location?.x&&"number"==typeof e.location?.y);if(0===a.length)return;const d=new o.LngLatBounds;for(const r of a){const e=r.location.x,t=r.location.y;d.extend([e,t]);const n=document.createElement("div");if(n.className="qrati-map-marker",n.style.cssText="\n width: 36px; height: 36px; cursor: pointer;\n background: var(--primary, #ff4800);\n border-radius: 50% 50% 50% 0;\n transform: rotate(-45deg);\n border: 2px solid white;\n box-shadow: 0 2px 8px rgba(0,0,0,0.3);\n display: flex; align-items: center; justify-content: center; overflow: hidden;\n ",c){const e=document.createElement("img");e.src=c,e.style.cssText="width: 24px; height: 24px; border-radius: 50%; object-fit: cover; transform: rotate(45deg);",n.appendChild(e)}const a=document.createElement("div");s(r,a,l);const u=new o.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-34]}).setDOMContent(a);new o.Marker({element:n}).setLngLat([e,t]).setPopup(u).addTo(i)}d.isEmpty()||i.fitBounds(d,{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,animate:!0,duration:1200})}),t=()=>{i.remove(),u.current=null}})(),()=>{t?.()}},[n]),t(()=>{u.current&&(p.current=a,u.current.setProjection(a?{type:"globe"}:{type:"mercator"}),u.current.easeTo({pitch:0,bearing:0,duration:600}))},[a]),/* @__PURE__ */o("div",{ref:d,class:"size-full"})};export{l as default};
1
+ import{a as e}from"./CsohJ1Yu.js";import{E as t,k as r,r as n,v as o,y as i}from"./DQVgvgo2.js";import{t as a}from"./P53QlFG0.js";var s=(e,t,i)=>{r(/* @__PURE__ */o(n,{children:/* @__PURE__ */o(a,{event:e,onExplore:i})}),t)},l=({events:r,apiKey:n,is3D:a,onExplore:l,logoUrl:c})=>{const d=i(null),u=i(null),p=i(a);return t(()=>{if(!d.current||u.current)return;let t;return(async()=>{const o=(await import("./BTZXR2Ef.js").then(t=>/* @__PURE__ */e(t.default,1))).default;if(!document.querySelector("link[data-qrati-maplibre-css]")){const e=document.createElement("link");e.rel="stylesheet",e.href="https://unpkg.com/maplibre-gl@5.21.0/dist/maplibre-gl.css",e.setAttribute("data-qrati-maplibre-css",""),document.head.appendChild(e)}if(!d.current)return;const i=new o.Map({container:d.current,style:`https://api.maptiler.com/maps/streets-v2/style.json?key=${n}`,center:[0,20],zoom:4,minZoom:2,pitch:0,bearing:0,projection:p.current?{type:"globe"}:{type:"mercator"},canvasContextAttributes:{antialias:!0}});u.current=i,i.on("load",()=>{const e=i.getStyle()?.layers??[];let t,n;for(const r of e){const e=r;"symbol"===e.type&&e.layout?.["text-field"]&&!t&&(t=r.id),"building"!==e["source-layer"]||n||(n=e.source)}n&&!i.getLayer("3d-buildings")&&i.addLayer({id:"3d-buildings",source:n,"source-layer":"building",filter:["has","render_height"],type:"fill-extrusion",minzoom:14,paint:{"fill-extrusion-color":["interpolate",["linear"],["get","render_height"],0,"lightgray",200,"royalblue",400,"lightblue"],"fill-extrusion-height":["interpolate",["linear"],["zoom"],14,0,15,["get","render_height"]],"fill-extrusion-base":["case",["has","render_min_height"],["get","render_min_height"],0],"fill-extrusion-opacity":.6}},t);const a=r.filter(e=>"number"==typeof e.location?.x&&"number"==typeof e.location?.y);if(0===a.length)return;const d=new o.LngLatBounds;for(const r of a){const e=r.location.x,t=r.location.y;d.extend([e,t]);const n=document.createElement("div");if(n.className="qrati-map-marker",n.style.cssText="\n width: 36px; height: 36px; cursor: pointer;\n background: var(--primary, #ff4800);\n border-radius: 50% 50% 50% 0;\n transform: rotate(-45deg);\n border: 2px solid white;\n box-shadow: 0 2px 8px rgba(0,0,0,0.3);\n display: flex; align-items: center; justify-content: center; overflow: hidden;\n ",c){const e=document.createElement("img");e.src=c,e.style.cssText="width: 24px; height: 24px; border-radius: 50%; object-fit: cover; transform: rotate(45deg);",n.appendChild(e)}const a=document.createElement("div");s(r,a,l);const u=new o.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-34]}).setDOMContent(a);new o.Marker({element:n}).setLngLat([e,t]).setPopup(u).addTo(i)}d.isEmpty()||i.fitBounds(d,{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,animate:!0,duration:1200})}),t=()=>{i.remove(),u.current=null}})(),()=>{t?.()}},[n]),t(()=>{u.current&&(p.current=a,u.current.setProjection(a?{type:"globe"}:{type:"mercator"}),u.current.easeTo({pitch:0,bearing:0,duration:600}))},[a]),/* @__PURE__ */o("div",{ref:d,class:"size-full"})};export{l as default};
@@ -1 +1 @@
1
- const e=require("./BkE18wvt.js"),t=require("./JLXrD6OW.js"),r=require("./CX_Vz15p.js"),o=require("./DPezSfU3.js"),n=require("./B100IxcO.js"),l=require("./EJU6024p.js");var s=new o.QueryClient,a=(e,o,l)=>{t.R(t.u(r.QueryClientProvider,{client:s,children:t.u(t.MemoryRouter,{children:t.u(n.EventPreviewCard,{event:e,onExplore:l})})}),o)};exports.default=({folderId:r,onExplore:o,apiKey:n,is3D:s,logoUrl:i})=>{const c=t.A(null),d=t.A(null),u=t.A(null),f=t.A(null),[p,m]=t.d(!1),{activeFolderId:h,visibleFolders:b,visibleEvents:x,folderFeatureCollection:v,breadcrumb:g,isBusy:y,setActiveFolderId:w,goBack:k,activeFolder:j,folderBounds:C}=l.useHierarchicalMap({folderId:r}),L=x?.filter(e=>"number"==typeof e.location?.x&&"number"==typeof e.location?.y);return t.y(()=>{if(!c.current||d.current)return;let t;return(async()=>{const r=(await Promise.resolve().then(()=>e.__toESM(require("./CyhPgIea.js").default,1))).default;if(!document.querySelector("link[data-qrati-mapbox-css]")){const e=document.createElement("link");e.rel="stylesheet",e.href="https://unpkg.com/mapbox-gl@3.20.0/dist/mapbox-gl.css",e.setAttribute("data-qrati-mapbox-css",""),document.head.appendChild(e)}if(!c.current)return;r.accessToken=n;const l=new r.Map({container:c.current,style:"mapbox://styles/mapbox/streets-v12",center:[0,20],zoom:3,minZoom:2,pitch:s?30:0,bearing:s?-20:0,antialias:!0});d.current=l,l.on("load",()=>{if(0===L.length)return;const e=new r.LngLatBounds;for(const n of L){const t=n.location.x,s=n.location.y;e.extend([t,s]);const c=document.createElement("div");if(c.style.cssText="\n width: 36px; height: 36px; cursor: pointer;\n background: var(--primary, #ff4800);\n border-radius: 50% 50% 50% 0;\n transform: rotate(-45deg);\n border: 2px solid white;\n box-shadow: 0 2px 8px rgba(0,0,0,0.3);\n display: flex; align-items: center; justify-content: center; overflow: hidden;\n ",i){const e=document.createElement("img");e.src=i,e.style.cssText="width: 24px; height: 24px; border-radius: 50%; object-fit: cover; transform: rotate(45deg);",c.appendChild(e)}const d=document.createElement("div");a(n,d,o);const u=new r.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-20]}).setDOMContent(d);new r.Marker({element:c}).setLngLat([t,s]).setPopup(u).addTo(l)}e.isEmpty()||l.fitBounds(e,{padding:60,maxZoom:14,duration:1200}),m(!0),l.addSource("folder-areas",{type:"geojson",data:v}),l.addLayer({id:"folder-fill",type:"fill",source:"folder-areas",paint:{"fill-color":["case",["boolean",["feature-state","hover"],!1],"#ffb703","#ffb703"],"fill-opacity":.28}}),l.addLayer({id:"folder-border",type:"line",source:"folder-areas",paint:{"line-color":["case",["boolean",["feature-state","hover"],!1],"#fb8500","#fb8500"],"line-width":["case",["boolean",["feature-state","hover"],!1],3,2]}}),l.addLayer({id:"folder-point",type:"circle",source:"folder-areas",filter:["==",["geometry-type"],"Point"],paint:{"circle-radius":10,"circle-color":["case",["boolean",["feature-state","hover"],!1],"#fb8500","#ffb703"],"circle-stroke-color":"#fff","circle-stroke-width":2}}),l.on("mousemove","folder-fill",e=>{const t=e.features?.[0];if(!t)return;const o=String(t.properties?.folderId);f.current!==o&&(f.current&&l.setFeatureState({source:"folder-areas",id:f.current},{hover:!1}),f.current=o,l.setFeatureState({source:"folder-areas",id:o},{hover:!0})),l.getCanvas().style.cursor="pointer",((e,t)=>{const o=e.properties??{},n=String(o.name??"Folder"),s=Number(o.eventCount??0);u.current||(u.current=new r.Popup({closeButton:!1,closeOnClick:!1,offset:12})),u.current.setLngLat(t).setHTML(`<div class='text-sm font-semibold text-slate-900'>${n}</div><div class='text-xs text-slate-700'>${s} event${1===s?"":"s"}</div>`).addTo(l)})(t,e.lngLat)}),l.on("mouseleave","folder-fill",()=>{f.current&&(l.setFeatureState({source:"folder-areas",id:f.current},{hover:!1}),f.current=null,u.current?.remove()),l.getCanvas().style.cursor=""});const t=e=>{const t=(e.features?.[0])?.properties?.folderId;t&&w(String(t))};l.on("click","folder-fill",t),l.on("click","folder-border",t),l.on("click","folder-point",t)}),t=()=>{l.remove(),d.current=null,u.current=null}})(),()=>{t?.()}},[n,s,o,w]),t.y(()=>{if(!d.current||!p)return;const e=d.current;try{e.getSource("folder-areas")?.setData(v)}catch{}},[v,p]),t.y(()=>{(()=>{const e=d.current;if(!e||!p)return;const t=C;if(!t)return;const[r,o,n,l]=t;e.fitBounds([[r,o],[n,l]],{padding:72,duration:800,maxZoom:14})})()},[C,p]),t.y(()=>{d.current&&d.current.easeTo({pitch:s?30:0,bearing:s?-20:0,duration:800})},[s]),t.u("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",children:[t.u("div",{class:"absolute top-4 left-4 z-20 flex w-[min(96%,420px)] flex-col gap-2 rounded-xl border border-slate-200 bg-white/95 p-3 shadow-lg backdrop-blur-sm",children:[t.u("div",{class:"flex items-center justify-between gap-3",children:[t.u("div",{children:[t.u("div",{class:"text-sm font-semibold text-slate-900",children:j?.name??"Home"}),t.u("div",{class:"text-xs text-slate-600",children:["Tap a folder region to drill into its contents. ",b?.length??0," folder",1===b?.length?"":"s",", ",L.length," event",1===L.length?"":"s"," total"]})]}),h&&t.u("button",{type:"button",onClick:k,class:"rounded bg-slate-100 px-3 py-1 text-xs font-semibold text-slate-700 hover:bg-slate-200",children:"Back"})]}),g.length>0&&t.u("div",{class:"flex flex-wrap gap-1 text-xs text-slate-500",children:[t.u("span",{children:"All folders"}),g.map(e=>t.u("span",{class:"inline-flex items-center gap-1",children:[t.u("span",{class:"text-slate-300",children:"/"}),t.u("span",{children:e.name})]},e._id))]})]}),y&&t.u("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/70",children:t.u("div",{class:"border-primary flex h-12 w-12 animate-spin items-center justify-center rounded-full border-4 border-t-transparent"})}),t.u("div",{ref:c,class:"h-full w-full rounded-xl border border-slate-200"})]})};
1
+ const e=require("./BkE18wvt.js"),t=require("./CSHWW4FM.js"),r=require("./DF_cfEUO.js"),o=require("./D_47D6ly.js"),n=require("./D1CJDHfi.js"),l=require("./k7mNnMH1.js");var s=new o.QueryClient,a=(e,o,l)=>{t.R(t.u(r.QueryClientProvider,{client:s,children:t.u(t.MemoryRouter,{children:t.u(n.EventPreviewCard,{event:e,onExplore:l})})}),o)};exports.default=({folderId:r,onExplore:o,apiKey:n,is3D:s,logoUrl:i})=>{const c=t.A(null),d=t.A(null),u=t.A(null),f=t.A(null),[p,m]=t.d(!1),{activeFolderId:h,visibleFolders:b,visibleEvents:x,folderFeatureCollection:v,breadcrumb:g,isBusy:y,setActiveFolderId:w,goBack:k,activeFolder:j,folderBounds:C}=l.useHierarchicalMap({folderId:r}),L=x?.filter(e=>"number"==typeof e.location?.x&&"number"==typeof e.location?.y);return t.y(()=>{if(!c.current||d.current)return;let t;return(async()=>{const r=(await Promise.resolve().then(()=>e.__toESM(require("./CyhPgIea.js").default,1))).default;if(!document.querySelector("link[data-qrati-mapbox-css]")){const e=document.createElement("link");e.rel="stylesheet",e.href="https://unpkg.com/mapbox-gl@3.20.0/dist/mapbox-gl.css",e.setAttribute("data-qrati-mapbox-css",""),document.head.appendChild(e)}if(!c.current)return;r.accessToken=n;const l=new r.Map({container:c.current,style:"mapbox://styles/mapbox/streets-v12",center:[0,20],zoom:3,minZoom:2,pitch:s?30:0,bearing:s?-20:0,antialias:!0});d.current=l,l.on("load",()=>{if(0===L.length)return;const e=new r.LngLatBounds;for(const n of L){const t=n.location.x,s=n.location.y;e.extend([t,s]);const c=document.createElement("div");if(c.style.cssText="\n width: 36px; height: 36px; cursor: pointer;\n background: var(--primary, #ff4800);\n border-radius: 50% 50% 50% 0;\n transform: rotate(-45deg);\n border: 2px solid white;\n box-shadow: 0 2px 8px rgba(0,0,0,0.3);\n display: flex; align-items: center; justify-content: center; overflow: hidden;\n ",i){const e=document.createElement("img");e.src=i,e.style.cssText="width: 24px; height: 24px; border-radius: 50%; object-fit: cover; transform: rotate(45deg);",c.appendChild(e)}const d=document.createElement("div");a(n,d,o);const u=new r.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-20]}).setDOMContent(d);new r.Marker({element:c}).setLngLat([t,s]).setPopup(u).addTo(l)}e.isEmpty()||l.fitBounds(e,{padding:60,maxZoom:14,duration:1200}),m(!0),l.addSource("folder-areas",{type:"geojson",data:v}),l.addLayer({id:"folder-fill",type:"fill",source:"folder-areas",paint:{"fill-color":["case",["boolean",["feature-state","hover"],!1],"#ffb703","#ffb703"],"fill-opacity":.28}}),l.addLayer({id:"folder-border",type:"line",source:"folder-areas",paint:{"line-color":["case",["boolean",["feature-state","hover"],!1],"#fb8500","#fb8500"],"line-width":["case",["boolean",["feature-state","hover"],!1],3,2]}}),l.addLayer({id:"folder-point",type:"circle",source:"folder-areas",filter:["==",["geometry-type"],"Point"],paint:{"circle-radius":10,"circle-color":["case",["boolean",["feature-state","hover"],!1],"#fb8500","#ffb703"],"circle-stroke-color":"#fff","circle-stroke-width":2}}),l.on("mousemove","folder-fill",e=>{const t=e.features?.[0];if(!t)return;const o=String(t.properties?.folderId);f.current!==o&&(f.current&&l.setFeatureState({source:"folder-areas",id:f.current},{hover:!1}),f.current=o,l.setFeatureState({source:"folder-areas",id:o},{hover:!0})),l.getCanvas().style.cursor="pointer",((e,t)=>{const o=e.properties??{},n=String(o.name??"Folder"),s=Number(o.eventCount??0);u.current||(u.current=new r.Popup({closeButton:!1,closeOnClick:!1,offset:12})),u.current.setLngLat(t).setHTML(`<div class='text-sm font-semibold text-slate-900'>${n}</div><div class='text-xs text-slate-700'>${s} event${1===s?"":"s"}</div>`).addTo(l)})(t,e.lngLat)}),l.on("mouseleave","folder-fill",()=>{f.current&&(l.setFeatureState({source:"folder-areas",id:f.current},{hover:!1}),f.current=null,u.current?.remove()),l.getCanvas().style.cursor=""});const t=e=>{const t=(e.features?.[0])?.properties?.folderId;t&&w(String(t))};l.on("click","folder-fill",t),l.on("click","folder-border",t),l.on("click","folder-point",t)}),t=()=>{l.remove(),d.current=null,u.current=null}})(),()=>{t?.()}},[n,s,o,w]),t.y(()=>{if(!d.current||!p)return;const e=d.current;try{e.getSource("folder-areas")?.setData(v)}catch{}},[v,p]),t.y(()=>{(()=>{const e=d.current;if(!e||!p)return;const t=C;if(!t)return;const[r,o,n,l]=t;e.fitBounds([[r,o],[n,l]],{padding:72,duration:800,maxZoom:14})})()},[C,p]),t.y(()=>{d.current&&d.current.easeTo({pitch:s?30:0,bearing:s?-20:0,duration:800})},[s]),t.u("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",children:[t.u("div",{class:"absolute top-4 left-4 z-20 flex w-[min(96%,420px)] flex-col gap-2 rounded-xl border border-slate-200 bg-white/95 p-3 shadow-lg backdrop-blur-sm",children:[t.u("div",{class:"flex items-center justify-between gap-3",children:[t.u("div",{children:[t.u("div",{class:"text-sm font-semibold text-slate-900",children:j?.name??"Home"}),t.u("div",{class:"text-xs text-slate-600",children:["Tap a folder region to drill into its contents. ",b?.length??0," folder",1===b?.length?"":"s",", ",L.length," event",1===L.length?"":"s"," total"]})]}),h&&t.u("button",{type:"button",onClick:k,class:"rounded bg-slate-100 px-3 py-1 text-xs font-semibold text-slate-700 hover:bg-slate-200",children:"Back"})]}),g.length>0&&t.u("div",{class:"flex flex-wrap gap-1 text-xs text-slate-500",children:[t.u("span",{children:"All folders"}),g.map(e=>t.u("span",{class:"inline-flex items-center gap-1",children:[t.u("span",{class:"text-slate-300",children:"/"}),t.u("span",{children:e.name})]},e._id))]})]}),y&&t.u("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/70",children:t.u("div",{class:"border-primary flex h-12 w-12 animate-spin items-center justify-center rounded-full border-4 border-t-transparent"})}),t.u("div",{ref:c,class:"h-full w-full rounded-xl border border-slate-200"})]})};