@qratilabs/qrati-connect 2.7.2 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/element/{BvkZOchm.js → KwvjdBxj.js} +1 -1
- package/element/web.es.js +2 -2
- package/package.json +1 -1
- package/react/{B-ttdr0n.js → BzMDry65.js} +1 -1
- package/react/index.cjs +1 -1
- package/react/index.mjs +2 -2
- package/react/{COVWNZNw.js → mNvBH-um.js} +1 -1
- package/umd/web.umd.js +1 -1
package/react/index.mjs
CHANGED
|
@@ -84,7 +84,7 @@ return N("div",{className:"mb-3 grid grid-cols-3 md:space-y-0 md:space-x-4",chil
|
|
|
84
84
|
/* @__PURE__ */N(Gi,{placeholder:"Search by keywords",value:p,className:"py-2",onChange:e=>m(e.target.value),onKeyUp:e=>{const t=e.key;"Enter"===t?l&&l(p.length>0?p:""):"Escape"===t&&(m(""),l&&l(""))}}),p?.length>0&&/* @__PURE__ */N("button",{className:"absolute inset-y-0 right-10 flex items-center",onClick:()=>{m(""),l&&l("")},children:/* @__PURE__ */N(c,{name:"material-symbols:close-rounded",className:"text-foreground w-5"})}),
|
|
85
85
|
/* @__PURE__ */N("button",{className:"absolute inset-y-0 right-3 flex items-center",onClick:()=>l&&l(p),children:/* @__PURE__ */N(c,{name:"material-symbols:search-rounded",className:"text-foreground w-5"})})]})}),h?.integrationSettings?.showFacialSearch&&/* @__PURE__ */N(Ms,{value:f,onChange:e=>{g(e),u?.(e?URL.createObjectURL(e):void 0)}})]}),
|
|
86
86
|
/* @__PURE__ */N("div",{className:"col-span-3 md:col-span-1"}),
|
|
87
|
-
/* @__PURE__ */N("div",{className:"col-span-3 mt-3 md:col-span-1 md:mt-0 lg:justify-self-end",children:/* @__PURE__ */N(Zi,{engagementStyle:e,sort:a,order:i,onSortChange:o,onSortOrderChange:s})})]})},Is=e=>e?.meta?.currentPage<e?.meta?.totalPages?e.meta.currentPage+1:void 0,Ps=ee(()=>import("./
|
|
87
|
+
/* @__PURE__ */N("div",{className:"col-span-3 mt-3 md:col-span-1 md:mt-0 lg:justify-self-end",children:/* @__PURE__ */N(Zi,{engagementStyle:e,sort:a,order:i,onSortChange:o,onSortOrderChange:s})})]})},Is=e=>e?.meta?.currentPage<e?.meta?.totalPages?e.meta.currentPage+1:void 0,Ps=ee(()=>import("./mNvBH-um.js")),Rs=()=>{const e=we().eventSlug,{loadingUser:t,organization:r}=ae(),n=C(),[o,i]=H(""),[s,l]=H(void 0),[d,u]=H(K),[p,m]=H(X),[f,v]=H("undefined"!=typeof window&&window.innerWidth<768?A.SINGLE:A.GRID),w=Z(null),{event:x,ads:k}=De({eventSlug:e}),{loading:E,contentsWithAds:S,hasNextPage:M,fetchNextPage:P,isFetchingNextPage:z}=(({event:e,ads:t=[],sort:r=K,order:n=X,keywords:a,face:o,limit:i=20,includeSummary:s=!1})=>{const{props:l,loadingUser:c,user:d}=ae(),u=l?.organizationId,{isLoading:h,data:p,hasNextPage:m,fetchNextPage:f,isFetchingNextPage:g}=function(e){return se(e,Te,void 0)}({queryKey:[_.CONTENTS_BY_EVENT(e?._id??""),r,n,a,o],queryFn:async({pageParam:t=1})=>{try{return await $.get(G.GET_CONTENTS,{searchParams:{eventId:e?._id,page:t,keywords:a,faceImageUrl:o,sort:`${D[n].sortOrder}${q[r].sortField}`,limit:i,includeSummary:s},headers:{"x-org-id":u,Authorization:d?`Bearer ${d.token}`:void 0}}).json()}catch(l){throw new Error(l instanceof Error?l.message:String(l)||"Failed to fetch contents")}},enabled:!c&&!!e,initialPageParam:1,getPreviousPageParam:e=>(e=>e?.meta?.currentPage>1?e.meta.currentPage-1:void 0)(e),getNextPageParam:Is}),v=R(()=>p?.pages?.flatMap(e=>e?.data??[])??[],[p]);return{contents:v,contentsWithAds:R(()=>((e=[],t=[],r)=>{if(!r||r<=0)return e;let n=0;const a=[];for(let o=0;o<(e?.length||0);o++)a.push(e[o]),t.length>0&&r>0&&(o+1)%r===0&&(a.push({...t[n],type:F.AD,adType:t[n].type}),n=(n+1)%t.length);return a})(v,t,e?.adPosition),[v,t,e?.adPosition]),loading:h,hasNextPage:m,fetchNextPage:f,isFetchingNextPage:g}})({event:x,ads:k,sort:d,order:p,keywords:o,face:s,includeSummary:r?.navigationSettings?.showAIDescription}),{incrementEventView:O}=g(),{start:U,initializing:j,running:B}=(({ref:e,onBottomReached:t,hasNextPage:r,fetchNextPage:n,isFetchingNextPage:a})=>{const o=Z(1),i=Z(null),s=Z(null),l=Z(null),[c,d]=H(!1),[u,h]=H(!1);L(()=>(c&&(s.current&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{i.current=window.requestAnimationFrame(p)},300)),()=>{i.current&&window.cancelAnimationFrame(i.current)}),[c,r,a,n,t]);const p=()=>{e.current&&(e.current.scrollTop+=o.current,r&&!a&&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(()=>{h(!0),t?.(),s.current=window.setTimeout(()=>{e.current&&(e.current.scrollTop=0),h(!1),d(!0)},1e3)},1e3)):i.current=window.requestAnimationFrame(p))},m=e=>{"+"===e.key&&(o.current=Math.min(o.current+1,10)),"-"===e.key&&(o.current=Math.max(o.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),h(!1),e.current&&(e.current.scrollTop=0),i.current&&window.cancelAnimationFrame(i.current),s.current&&window.clearTimeout(s.current),document.removeEventListener("keydown",m),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(ud){console.error(`Failed to acquire wake lock: ${ud instanceof Error?ud.message:String(ud)}`)}})(),d(!0),document.addEventListener("keydown",m),document.addEventListener("fullscreenchange",f)},initializing:u,running:c}})({ref:w,hasNextPage:M,fetchNextPage:P,isFetchingNextPage:z,onBottomReached:()=>x?._id&&n.refetchQueries({queryKey:[_.CONTENTS_BY_EVENT(x._id)]})});L(()=>{x?.slug&&O(x.slug)},[x]);const W=R(()=>f===A.SINGLE,[f]),Q=R(()=>/* @__PURE__ */N(qi,{event:x,onAutoscrollClick:U}),[x?.galleryLayout,U]),Y=Z(null),ee=Z(null);return L(()=>(Y.current&&Y.current.disconnect(),Y.current=new IntersectionObserver(e=>{e[0].isIntersecting&&M&&!z&&!E&&P()},{rootMargin:"200px"}),ee.current&&Y.current.observe(ee.current),()=>{Y.current&&Y.current.disconnect()}),[M,z,E,P]),/* @__PURE__ */N("div",{className:"bg-background mx-auto min-h-[80vh] space-y-2",children:[
|
|
88
88
|
/* @__PURE__ */N("div",{className:"flex flex-row justify-end",children:Q}),
|
|
89
89
|
/* @__PURE__ */N("div",{className:"pb-2",children:/* @__PURE__ */N(Ge,{})}),
|
|
90
90
|
/* @__PURE__ */N(Ns,{engagementStyle:x?.engagementStyle,disabled:t||E,mode:f,onModeChange:e=>v(e),sort:d,sortOrder:p,onSortChange:e=>u(e),onSortOrderChange:()=>m("asc"===p?"desc":"asc"),handleChange:i,face:s,onFaceImageChange:e=>l(e)}),s&&/* @__PURE__ */N("div",{className:"flex gap-4 py-2",children:[/* @__PURE__ */N("div",{className:"space-y-2",children:[/* @__PURE__ */N(a,{variant:"h4",children:"Searching using"}),/* @__PURE__ */N("img",{src:s,alt:"face",className:"h-32 rounded"})]}),/* @__PURE__ */N("div",{className:"flex flex-col justify-end gap-2",children:/* @__PURE__ */N(h,{color:"error",iconName:"material-symbols:close-rounded",onClick:()=>l(void 0),children:"Clear search"})})]}),t||E?/* @__PURE__ */N("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3",children:Array.from({length:8}).map((e,t)=>/* @__PURE__ */N(ze,{className:"h-72"},t))}):S?.length<=0?/* @__PURE__ */N("div",{className:"my-16 flex flex-col items-center gap-4",children:/* @__PURE__ */N(Ue,{title:"No Contents",description:"Check back soon for amazing contents.",iconSvg:/* @__PURE__ */N("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-full",width:"800",height:"469.317",viewBox:"0 0 800 469.317",role:"img",children:/* @__PURE__ */N("g",{transform:"translate(-443.142 -257.876)",children:[
|
|
@@ -259,7 +259,7 @@ return N("div",{className:"space-y-4",children:[e===f[0]&&/* @__PURE__ */N(a,{va
|
|
|
259
259
|
/* @__PURE__ */N("div",{className:"grid grid-cols-1 gap-4 gap-y-6 sm:grid-cols-2 lg:grid-cols-3",children:r.map(e=>/* @__PURE__ */N(S,{event:e},e._id))})]},`event-folder-${e}`)}):f.map(e=>{const r=k(e),n=w[e]||[],o=n.reduce((e,t)=>e+(t.contents?.length||0),0);/* @__PURE__ */
|
|
260
260
|
return N("div",{className:"space-y-4",children:[e===f[0]&&t&&/* @__PURE__ */N("div",{className:"mb-8 flex items-center gap-2",children:[/* @__PURE__ */N(a,{variant:"body1",className:"bg-primary/20 text-primary rounded px-2 py-1",children:t}),/* @__PURE__ */N("button",{type:"button","aria-label":"Clear search",className:"text-muted hover:text-primary",onClick:u,children:"×"})]}),e===f[0]&&/* @__PURE__ */N(a,{variant:"h3",className:"mb-4",children:["Contents (",m?.totalContentCount||p.length,") by Event (",m?.totalEventCount||v.length,")"]}),
|
|
261
261
|
/* @__PURE__ */N("div",{className:"flex items-center justify-between gap-3",children:[/* @__PURE__ */N("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */N("span",{className:"inline-block size-2 rounded-full",style:{backgroundColor:r.color||"#9ca3af"}}),/* @__PURE__ */N(a,{variant:"h5",className:"text-sm sm:text-base",children:r.pathLabel})]}),/* @__PURE__ */N(a,{variant:"body2",color:"muted",children:[o," media"]})]}),
|
|
262
|
-
/* @__PURE__ */N("div",{className:"space-y-6",children:n.map(e=>/* @__PURE__ */N("div",{className:"space-y-3",children:[/* @__PURE__ */N(S,{event:e.event}),/* @__PURE__ */N("div",{className:"grid grid-cols-3 gap-2",children:e.contents.slice(0,6).map(t=>/* @__PURE__ */N("button",{type:"button",className:"block overflow-hidden rounded",onClick:()=>C(e.event._id,t._id),children:/* @__PURE__ */N("img",{src:t.thumbnailUrl||t.url,alt:"Content preview",className:"w-full object-cover"})},t._id))})]},`content-event-${e.event._id}`))})]},`content-folder-${e}`)})),s&&i&&!o&&/* @__PURE__ */N("div",{className:"flex justify-center pt-2",children:/* @__PURE__ */N("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:d,children:n?"Loading...":"Load more"})})]})},uc=ee(()=>import("./DKvJBrWM.js")),hc={grid:{icon:/* @__PURE__ */N("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-full text-inherit",width:24,height:24,viewBox:"0 0 24 24",children:/* @__PURE__ */N("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__ */N("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-full text-inherit",width:24,height:24,viewBox:"0 0 24 24",children:/* @__PURE__ */N("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"})})}},pc=Object.keys(hc).map(e=>({icon:hc[e].icon,value:e})),mc=()=>{const e=we().folderId??"",t=ae(),{folders:r,organization:n}=t,a=t.props?.organizationId,o=!1!==n?.integrationSettings?.enableGlobalSearch,i=((e,t)=>{const[r,n]=H(""),[a,o]=H("event"),[i,s]=H(1),[l,c]=H(!1),[u,h]=H(""),[p,m]=H(!1),[g,v]=H([]),[w,b]=H([]),[_,y]=H(null),x=Z(0),C=Z(null),k=Z(null),E=R(()=>`org-inline-search-gallery-${e||"default"}`,[e]);L(()=>{if(!e||!r)return;const t=++x.current;(async()=>{c(!0),h("");try{const n="event"===a?G.SEARCH_EVENTS:G.SEARCH_CONTENTS,o=await $.get(n,{headers:{"x-org-id":e},searchParams:{query:r,page:String(i),limit:"event"===a?"12":"8"}}).json();if(t!==x.current)return;const s=o?.data||[],l=o?.meta?.totalPages||0;m((o?.meta?.currentPage||0)<l),"event"===a?v(e=>1===i?s:[...e,...s]):(y({totalContentCount:o?.meta?.totalContentCount,totalEventCount:o?.meta?.totalEventCount}),b(e=>1===i?s:[...e,...s]))}catch(n){if(t!==x.current)return;h(n?.message||"Failed to search")}finally{t===x.current&&c(!1)}})()},[e,i,r,a]);const S=R(()=>{const e={};return g.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},[g]),M=R(()=>{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({_id:r._id,thumbnailUrl:r.thumbnailUrl,url:r.url,caption:r.event?.name,type:"image"}))}),Array.from(e.values()).sort((e,t)=>(e.event?.name||"").localeCompare(t.event?.name||"",void 0,{sensitivity:"base"}))},[w]),A=R(()=>{const e={};return M.forEach(t=>{const r=t.event?.folderId||"root";e[r]||(e[r]=[]),e[r].push(t)}),e},[M]),N=R(()=>{const e=Object.keys("event"===a?S:A);return e.sort((e,r)=>{if("root"===e)return-1;if("root"===r)return 1;const n=nc(t,e).map(e=>e.name).join("/"),a=nc(t,r).map(e=>e.name).join("/");return n.localeCompare(a)}),e},[A,S,t,a]),I=R(()=>{if("content"!==a)return[];const e=[];return N.forEach(t=>{(A[t]||[]).forEach(t=>{t.contents.forEach(r=>{e.push({event:t.event,content:r})})})}),e},[N,A,a]);return L(()=>{const e=k.current;if("content"!==a||!r||0===I.length||!e)return C.current?.destroy?.(),void(C.current=null);const t=new d({gallery:e,children:"a.pswp-item",counter:!1,bgOpacity:1,wheelToZoom:!0,pinchToClose:!0,zoom:!1,pswpModule:f});return C.current=t,t.init(),()=>{C.current?.destroy?.(),C.current=null}},[I.length,E,r,a]),{handleSearch:(e,t)=>{s(1),h(""),m(!1),v([]),b([]),y(null),o(t),n(e)},clearSearch:()=>{n(""),h(""),m(!1),s(1),v([]),b([]),y(null)},isSearchActive:r.length>0,submittedQuery:r,submittedSearchType:a,isLoading:l,errorMessage:u,hasMore:p,page:i,setPage:s,eventResults:g,contentResults:w,contentMeta:_,activeFolderKeys:N,eventGroupsByFolder:S,contentGroups:M,contentGroupsByFolder:A,flattenedContentMedia:I,lightboxRef:C,galleryElementRef:k,galleryId:E,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)}}})(a,r||[]),s=!0===n?.integrationSettings?.enableMapView,[l,c]=H(()=>{try{return sessionStorage.getItem("qrati-view-mode")||"grid"}catch{return"grid"}}),{data:u,isLoading:h}=ne({queryKey:[`public-events-map-${a}
|
|
262
|
+
/* @__PURE__ */N("div",{className:"space-y-6",children:n.map(e=>/* @__PURE__ */N("div",{className:"space-y-3",children:[/* @__PURE__ */N(S,{event:e.event}),/* @__PURE__ */N("div",{className:"grid grid-cols-3 gap-2",children:e.contents.slice(0,6).map(t=>/* @__PURE__ */N("button",{type:"button",className:"block overflow-hidden rounded",onClick:()=>C(e.event._id,t._id),children:/* @__PURE__ */N("img",{src:t.thumbnailUrl||t.url,alt:"Content preview",className:"w-full object-cover"})},t._id))})]},`content-event-${e.event._id}`))})]},`content-folder-${e}`)})),s&&i&&!o&&/* @__PURE__ */N("div",{className:"flex justify-center pt-2",children:/* @__PURE__ */N("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:d,children:n?"Loading...":"Load more"})})]})},uc=ee(()=>import("./DKvJBrWM.js")),hc={grid:{icon:/* @__PURE__ */N("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-full text-inherit",width:24,height:24,viewBox:"0 0 24 24",children:/* @__PURE__ */N("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__ */N("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-full text-inherit",width:24,height:24,viewBox:"0 0 24 24",children:/* @__PURE__ */N("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"})})}},pc=Object.keys(hc).map(e=>({icon:hc[e].icon,value:e})),mc=()=>{const e=we().folderId??"",t=ae(),{folders:r,organization:n}=t,a=t.props?.organizationId,o=!1!==n?.integrationSettings?.enableGlobalSearch,i=((e,t)=>{const[r,n]=H(""),[a,o]=H("event"),[i,s]=H(1),[l,c]=H(!1),[u,h]=H(""),[p,m]=H(!1),[g,v]=H([]),[w,b]=H([]),[_,y]=H(null),x=Z(0),C=Z(null),k=Z(null),E=R(()=>`org-inline-search-gallery-${e||"default"}`,[e]);L(()=>{if(!e||!r)return;const t=++x.current;(async()=>{c(!0),h("");try{const n="event"===a?G.SEARCH_EVENTS:G.SEARCH_CONTENTS,o=await $.get(n,{headers:{"x-org-id":e},searchParams:{query:r,page:String(i),limit:"event"===a?"12":"8"}}).json();if(t!==x.current)return;const s=o?.data||[],l=o?.meta?.totalPages||0;m((o?.meta?.currentPage||0)<l),"event"===a?v(e=>1===i?s:[...e,...s]):(y({totalContentCount:o?.meta?.totalContentCount,totalEventCount:o?.meta?.totalEventCount}),b(e=>1===i?s:[...e,...s]))}catch(n){if(t!==x.current)return;h(n?.message||"Failed to search")}finally{t===x.current&&c(!1)}})()},[e,i,r,a]);const S=R(()=>{const e={};return g.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},[g]),M=R(()=>{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({_id:r._id,thumbnailUrl:r.thumbnailUrl,url:r.url,caption:r.event?.name,type:"image"}))}),Array.from(e.values()).sort((e,t)=>(e.event?.name||"").localeCompare(t.event?.name||"",void 0,{sensitivity:"base"}))},[w]),A=R(()=>{const e={};return M.forEach(t=>{const r=t.event?.folderId||"root";e[r]||(e[r]=[]),e[r].push(t)}),e},[M]),N=R(()=>{const e=Object.keys("event"===a?S:A);return e.sort((e,r)=>{if("root"===e)return-1;if("root"===r)return 1;const n=nc(t,e).map(e=>e.name).join("/"),a=nc(t,r).map(e=>e.name).join("/");return n.localeCompare(a)}),e},[A,S,t,a]),I=R(()=>{if("content"!==a)return[];const e=[];return N.forEach(t=>{(A[t]||[]).forEach(t=>{t.contents.forEach(r=>{e.push({event:t.event,content:r})})})}),e},[N,A,a]);return L(()=>{const e=k.current;if("content"!==a||!r||0===I.length||!e)return C.current?.destroy?.(),void(C.current=null);const t=new d({gallery:e,children:"a.pswp-item",counter:!1,bgOpacity:1,wheelToZoom:!0,pinchToClose:!0,zoom:!1,pswpModule:f});return C.current=t,t.init(),()=>{C.current?.destroy?.(),C.current=null}},[I.length,E,r,a]),{handleSearch:(e,t)=>{s(1),h(""),m(!1),v([]),b([]),y(null),o(t),n(e)},clearSearch:()=>{n(""),h(""),m(!1),s(1),v([]),b([]),y(null)},isSearchActive:r.length>0,submittedQuery:r,submittedSearchType:a,isLoading:l,errorMessage:u,hasMore:p,page:i,setPage:s,eventResults:g,contentResults:w,contentMeta:_,activeFolderKeys:N,eventGroupsByFolder:S,contentGroups:M,contentGroupsByFolder:A,flattenedContentMedia:I,lightboxRef:C,galleryElementRef:k,galleryId:E,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)}}})(a,r||[]),s=!0===n?.integrationSettings?.enableMapView,[l,c]=H(()=>{try{return sessionStorage.getItem("qrati-view-mode")||"grid"}catch{return"grid"}}),{data:u,isLoading:h}=ne({queryKey:[`public-events-map-${a}`,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"};return(await $.get(G.PUBLIC_EVENTS,{headers:{"x-org-id":a},searchParams:t}).json()).data}}),p=R(()=>{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 y.UPLOAD(t);case"curate":return y.CURATE(t);case"leaderboard":return y.LEADERBOARD(t);default:return y.GALLERY(t)}return y.GALLERY(t)}}catch(ud){console.error("Error parsing URL parameters:",ud)}return null},[]),m=(r??[]).filter(t=>t.parentFolderId===(e?.length>0?e:null)||t.parentFolderId===(e?.length>0?e:void 0)),{isLoading:g,data:v}=ne({queryKey:[`public-events-${a}`,e],queryFn:async()=>(await $.get(G.PUBLIC_EVENTS,{headers:{"x-org-id":a},searchParams:{folderId:e,sort:"-createdAt"}}).json()).data});return p?/* @__PURE__ */N(pe,{to:p,replace:!0}):/* @__PURE__ */N(b,g||!n?{children:[n?.navigationSettings?.enableNavbar&&/* @__PURE__ */N(je,{}),/* @__PURE__ */N("div",{className:"min-h-screen w-full",children:[
|
|
263
263
|
/* @__PURE__ */N(lc,{organization:n}),
|
|
264
264
|
/* @__PURE__ */N("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__ */N(ze,{className:"h-24 rounded"},`folder-${t}`))}),
|
|
265
265
|
/* @__PURE__ */N("div",{className:"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-3",children:Array.from({length:6}).map((e,t)=>/* @__PURE__ */N("div",{className:"space-y-4",children:[/* @__PURE__ */N(ze,{className:"h-72 overflow-hidden rounded sm:h-80"}),/* @__PURE__ */N(ze,{className:"h-6 w-64 rounded"})]},t))})]})]}:{children:[n?.navigationSettings?.enableNavbar&&/* @__PURE__ */N(je,{}),
|
|
@@ -2,7 +2,7 @@ import{a as t,c as e,d as n,i,l as s,m as o,n as r,o as a,p as l,r as c,t as d,u
|
|
|
2
2
|
/* @__PURE__ */y("img",{className:"h-auto max-h-96 w-full object-contain",src:r?.imageUrl,alt:"Image not found"}),
|
|
3
3
|
/* @__PURE__ */y("div",{className:"flex flex-col gap-2 p-3",children:[/* @__PURE__ */y(n,{variant:"h4",align:"center",lines:2,children:r?.title}),/* @__PURE__ */y(n,{variant:"body3",color:"secondary",align:"center",lines:6,children:r?.description})]}),
|
|
4
4
|
/* @__PURE__ */y(l,{fullWidth:!0,className:"rounded-t-none",onClick:()=>d?.(r?._id,r?.targetType??b.LINK,r?.targetUrl),icon:S[r?.targetType]??S[b.LINK],children:r?.targetText})]})]})}),Bt=({url:t,alt:e="",thumbnailUrl:n,blurhash:i,pswpData:s={},curateLink:o,onClick:r})=>{const a=/* @__PURE__ */y(p,{children:[/* @__PURE__ */y(P,{threshold:.1,src:n||t,blurhash:i,alt:e}),s.type===q.VIDEO&&/* @__PURE__ */y("div",{className:"absolute inset-0 top-0 left-0 flex items-center justify-center opacity-75",children:/* @__PURE__ */y("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-16 text-white lg:w-24",viewBox:"0 0 24 24",children:/* @__PURE__ */y("path",{fill:"currentColor",d:"M8 17.175V6.825q0-.425.3-.713t.7-.287q.125 0 .263.037t.262.113l8.15 5.175q.225.15.338.375t.112.475t-.112.475t-.338.375l-8.15 5.175q-.125.075-.262.113T9 18.175q-.4 0-.7-.288t-.3-.712"})})})]});return r?/* @__PURE__ */y("button",{className:"h-full w-full",onClick:r,children:a}):o?/* @__PURE__ */y(R,{to:o,className:"h-full w-full",children:a}):/* @__PURE__ */y("a",{href:t,className:"pswp-item block h-full w-full",...Object.keys(s).reduce((t,e)=>{var n;return t[`data-pswp-${n=e,n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}`]=String(s[e]),t},{}),target:"_blank",rel:"noreferrer",children:a})},Vt=({style:t,content:e,curateLink:n,onAdClick:i})=>{const{captureAdImpression:s,captureAdEngagement:o,captureAdClick:r}=h();/* @__PURE__ */
|
|
5
|
-
return y("div",{style:t,className:"group relative mb-1 overflow-hidden rounded",children:[/* @__PURE__ */y(D,{className:"size-full",threshold:.8,triggerOnce:!0,onChange:t=>{t&&s(e._id)},onClick:()=>o(e._id),children:/* @__PURE__ */y(Bt,{url:e.src,thumbnailUrl:e.src,blurhash:e.blurhash,alt:e.caption,onClick:n?i:void 0,pswpData:{id:e._id,type:q.AD,hash:e._id,width:e.width,height:e.height,title:e.title,description:e.description,targetType:e.targetType,targetText:e.targetText,targetUrl:e.targetUrl,thumbnailUrl:e.imageUrl,blurhash:e.blurhash}})}),/* @__PURE__ */y("div",{className:"transition-opacity duration-500 group-hover:opacity-100 sm:opacity-0",children:/* @__PURE__ */y("div",{className:"text-foreground bg-background bg-opacity-75 absolute bottom-0 w-full flex-col items-center justify-between sm:flex sm:flex-row",children:[/* @__PURE__ */y("h3",{className:"text-foreground line-clamp-2 p-2 text-sm font-medium sm:ml-3 sm:line-clamp-1 sm:p-0",children:e.title}),e?.targetType!==b.NONE&&/* @__PURE__ */y(l,{immutable:!0,className:"w-full rounded-t-none py-1 text-nowrap sm:w-auto sm:rounded-t-none sm:rounded-bl-none sm:py-2",onClick:()=>r(e._id,e.targetType,e.targetUrl),
|
|
5
|
+
return y("div",{style:t,className:"group relative mb-1 overflow-hidden rounded",children:[/* @__PURE__ */y(D,{className:"size-full",threshold:.8,triggerOnce:!0,onChange:t=>{t&&s(e._id)},onClick:()=>o(e._id),children:/* @__PURE__ */y(Bt,{url:e.src,thumbnailUrl:e.src,blurhash:e.blurhash,alt:e.caption,onClick:n?i:void 0,pswpData:{id:e._id,type:q.AD,hash:e._id,width:e.width,height:e.height,title:e.title,description:e.description,targetType:e.targetType,targetText:e.targetText,targetUrl:e.targetUrl,thumbnailUrl:e.imageUrl,blurhash:e.blurhash}})}),/* @__PURE__ */y("div",{className:"transition-opacity duration-500 group-hover:opacity-100 sm:opacity-0",children:/* @__PURE__ */y("div",{className:"text-foreground bg-background bg-opacity-75 absolute bottom-0 w-full flex-col items-center justify-between sm:flex sm:flex-row",children:[/* @__PURE__ */y("h3",{className:"text-foreground line-clamp-2 p-2 text-sm font-medium sm:ml-3 sm:line-clamp-1 sm:p-0",children:e.title}),e?.targetType!==b.NONE&&/* @__PURE__ */y(l,{immutable:!0,className:"w-full rounded-t-none py-1 text-nowrap sm:w-auto sm:rounded-t-none sm:rounded-bl-none sm:py-2",onClick:()=>r(e._id,e.targetType,e.targetUrl),iconName:S[e?.targetType??b.LINK],children:e?.targetText})]})})]})},zt=M(null),Rt=()=>{const t=_(zt);if(!t)throw new Error("Popover components must be used within a Popover");return t},Ot=({children:t,className:e,open:n,onOpenChange:i})=>{const[s,o]=I(!1),r="boolean"==typeof n,a=r?n:s,l=E(),c=`popover-trigger-${l}`,d=`popover-content-${l}`,h=N(null);/* @__PURE__ */
|
|
6
6
|
return y(zt.Provider,{value:{isOpen:a,setIsOpen:t=>{r||o(t),i?.(t)},triggerId:c,contentId:d,triggerRef:h},children:/* @__PURE__ */y("div",{"data-slot":"popover",className:L("relative inline-block",e),children:t})})},Dt=({children:t,asChild:e,className:n,onClick:i,...s})=>{const{isOpen:o,setIsOpen:r,triggerId:a,contentId:l,triggerRef:c}=Rt();if(w(()=>{if(!e)return;const t=document.getElementById(a);return c.current=t,()=>{c.current===t&&(c.current=null)}},[e,a,c]),e){const e=Array.isArray(t)?t[0]:t;if(e&&e.type){const t=e.props?.className;return v(e,{id:a,className:n?t?`${t} ${n}`:n:t,"aria-haspopup":"dialog","aria-expanded":o,"aria-controls":o?l:void 0,onClick:t=>{r(!o),e.props?.onClick?.(t)},"data-state":o?"open":"closed"})}}/* @__PURE__ */
|
|
7
7
|
return y("button",{ref:c,id:a,type:"button","aria-haspopup":"dialog","aria-expanded":o,"aria-controls":o?l:void 0,"data-slot":"popover-trigger","data-state":o?"open":"closed",className:n,onClick:t=>{r(!o),i?.(t)},...s,children:t})},Pt=({children:t,className:e,align:n="center",side:i="top",sideOffset:s=4,...o})=>{const{isOpen:r,setIsOpen:a,contentId:l,triggerRef:c}=Rt(),{organization:d}=V(),h=N(null),[p,u]=I(null);if(k(()=>{if(!r)return;const t=()=>{if(!c.current||!h.current)return;const t=c.current.getBoundingClientRect(),e=h.current.getBoundingClientRect();let o=t.left,r=t.bottom+s;"center"===n&&(o=t.left+t.width/2-e.width/2),"end"===n&&(o=t.right-e.width),"top"===i&&(r=t.top-e.height-s),"left"===i&&(o=t.left-e.width-s,r=t.top+t.height/2-e.height/2),"right"===i&&(o=t.right+s,r=t.top+t.height/2-e.height/2),"bottom"===i&&(r=t.bottom+s),u({top:r,left:o})},e=requestAnimationFrame(t);return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{cancelAnimationFrame(e),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[n,r,i,s,c]),w(()=>{if(!r)return;const t=t=>{const e=t.target;h.current&&!h.current.contains(e)&&c.current&&!c.current.contains(e)&&a(!1)},e=t=>{"Escape"===t.key&&(a(!1),c.current?.focus())},n=window.setTimeout(()=>{document.addEventListener("mousedown",t)},0);return document.addEventListener("keydown",e),()=>{window.clearTimeout(n),document.removeEventListener("mousedown",t),document.removeEventListener("keydown",e)}},[r,a,c]),!r)return null;const m=/* @__PURE__ */y("div",{ref:h,id:l,role:"dialog","aria-modal":"false","data-state":r?"open":"closed",className:L("bg-background text-foreground border-border shadow-outer rounded outline-none",e),style:{position:"fixed",top:p?.top??0,left:p?.left??0,zIndex:2010,...C(d)},...o,children:t});return"undefined"!=typeof document?z(m,document.body):m},$t=({eventId:t,contentId:e,emojis:n=[],counts:i={},userReaction:s})=>{const{user:o,props:r,organization:a}=V(),l=r?.loginUrl,{handleReactionClick:d}=(()=>{const t=g(),{props:e,user:n}=V(),i=e?.organizationId;return{handleReactionClick:async(e,s,o)=>{if(!e||!s||!o)return!1;if(!n)return c.error("Please login to react"),!1;const r=[u.CONTENTS_BY_EVENT(e)],a=t.getQueriesData({queryKey:r});t.setQueriesData({queryKey:r},t=>t?.pages&&Array.isArray(t.pages)?{...t,pages:t.pages.map(t=>t.data?{...t,data:t.data.map(t=>{if(t._id===s){const e={...t.reactionCounts};return t.userReaction&&t.userReaction!==o&&(e[t.userReaction]=Math.max(0,(e[t.userReaction]??1)-1)),t.userReaction===o?(e[o]=Math.max(0,(e[o]??1)-1),{...t,reactionCounts:e,userReaction:void 0}):(e[o]=(e[o]??0)+1,{...t,reactionCounts:e,userReaction:o})}return t})}:t)}:t);try{return await B.post(A.UPDATE_REACTION,{json:{eventId:e,contentId:s,reaction:o},headers:{"x-org-id":i,Authorization:`Bearer ${n.token}`}}),!0}catch(l){return a.forEach(([e,n])=>{t.setQueryData(e,n)}),c.error("Failed to add reaction"),console.error("Error handling reaction click:",l),!1}}}})(),[h,p]=I(!1),[f,w]=I(!1),T=Object.values(i).reduce((t,e)=>t+e,0);/* @__PURE__ */
|
|
8
8
|
return y(Ot,{open:h,onOpenChange:p,children:[/* @__PURE__ */y(Dt,{children:/* @__PURE__ */y("div",{className:L("bg-background/50 flex items-center gap-1 rounded px-2 py-1 backdrop-blur-sm transition-transform active:scale-90 sm:gap-2 sm:py-0",s&&"ring-primary ring-1"),children:[(n||[]).slice().sort((t,e)=>(i[e]||0)-(i[t]||0)).slice(0,1).map(t=>/* @__PURE__ */y("span",{className:"text-sm sm:text-lg",children:s||t},`${e}-${t}-1`)),T>0&&/* @__PURE__ */y("span",{className:"text-xs font-bold sm:text-sm",children:T||0})]})}),/* @__PURE__ */y(Pt,{side:"top",align:"end",children:[o?null:/* @__PURE__ */y("div",a?.customAuth?{className:"p-2 font-semibold",children:["Please"," ",
|