PIMS/public/build/assets/Show-BND-fsBv.js

2 lines
6.6 KiB
JavaScript
Raw Permalink Normal View History

import{d as R,n as z,c as j,r,e as B,p as E,a as o,f as w,u as D,h as O,w as A,b as e,i,o as l,t as d,q as I,v as X,s as Y,F as h,g as M,l as k,T as Z}from"./app-BXYcVHqk.js";import{_ as H}from"./AppLayout.vue_vue_type_script_setup_true_lang-86gE95Fg.js";import{_ as W}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./AppLogoIcon.vue_vue_type_script_setup_true_lang-BzXwPo6R.js";import"./useForwardExpose-Djbxsgaa.js";import"./VisuallyHidden-BvthYHr5.js";import"./RovingFocusGroup-dmigQ6Dy.js";import"./useArrowNavigation-C6Y-ieo6.js";import"./index-C4J_hXM0.js";import"./createLucideIcon-BlA39rtn.js";const G={class:"flex h-full flex-1 flex-col gap-4 overflow-x-auto rounded-xl p-4"},J={key:0,class:"flex items-center gap-3"},K={class:"flex items-center gap-3"},Q={class:"h-12 w-12 shrink-0 overflow-hidden rounded-full bg-muted"},ee=["src","alt"],te={class:"min-w-0 flex-1"},se={class:"truncate text-lg font-semibold"},ae={class:"flex items-center gap-2"},oe={key:1,class:"rounded-md border border-red-300 bg-red-50 p-3 text-red-800 dark:border-red-800 dark:bg-red-950 dark:text-red-200"},le=["aria-busy"],re=["href"],ne={class:"h-20 w-14 shrink-0 overflow-hidden rounded bg-muted"},ue=["src","alt"],ie={class:"flex min-w-0 flex-1 flex-col"},de={class:"flex items-center justify-between gap-2"},ce={class:"truncate font-medium"},ve={class:"text-xs text-muted-foreground"},fe={class:"mt-1 text-xs text-muted-foreground"},pe={key:0,class:"mr-2 rounded border px-1 py-0.5"},me={key:1},he={class:"mt-2 text-sm text-foreground/90"},ge={key:0,class:"fixed bottom-4 left-1/2 z-50 -translate-x-1/2 rounded bg-foreground px-3 py-2 text-sm text-background shadow-lg"},_e=R({__name:"Show",setup(xe){const N=z(),T=j(()=>N.props.entityId),c=r(""),v=r("title_asc"),f=r([]),C=r(0),P=r(1),g=r(1),u=r(!1),_=r(null),b=r(!1),S=r(""),n=r(null);let $=null;const q=j(()=>g.value<P.value&&!u.value);function L(a,s=50){if(!a)return"";const t=a.split(/\s+/);return t.length<=s?a:t.slice(0,s).join(" ")+"…"}async function x(a=!1){if(!u.value){u.value=!0,_.value=null;try{const s=new URLSearchParams;c.value&&s.set("q",c.value),v.value&&s.set("sort",v.value),s.set("per_page","20"),s.set("page",String(g.value));const t=await fetch(`/api/actors/${T.value}?${s.toString()}`,{headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest"},credentials:"same-origin"});if(!t.ok)throw new Error(`Fetch failed: ${t.status}`);const p=await t.json();n.value=p.entity,C.value=p.movies.total,P.value=p.movies.last_page,a?f.value=p.movies.data:f.value=f.value.concat(p.movies.data)}catch(s){_.value=s?.message??"Unexpected error",S.value=_.value,b.value=!0,setTimeout(()=>b.value=!1,2500)}finally{u.value=!1}}}function U(){clearTimeout($),$=setTimeout(()=>{g.value=1,x(!0)},300)}function V(){const a=new URL(window.location.href);c.value?a.searchParams.set("q",c.value):a.searchParams.delete("q"),v.value?a.searchParams.set("sort",v.value):a.searchParams.delete("sort"),window.history.replaceState({},"",a.toString()),g.value=1,x(!0)}async function F(){q.value&&(g.value+=1,await x(!1))}const y=r(null);let m=null;return B(()=>{const a=new URL(window.location.href);c.value=a.searchParams.get("q")??"",v.value=a.searchParams.get("sort")??"title_asc",x(!0),m=new IntersectionObserver(s=>{for(const t of s)t.isIntersecting&&F()},{root:null,rootMargin:"200px",threshold:0}),y.value&&m.observe(y.value)}),E(y,(a,s)=>{s&&m&&m.unobserve(s),a&&m&&m.observe(a)}),(a,s)=>(l(),o(h,null,[w(D(O),{title:n.value?.name?`${n.value.name} · Actor`:"Actor"},null,8,["title"]),w(H,{breadcrumbs:[{title:"Actors",href:"/actors"},{title:n.value?.name??"…",href:`/actors/${T.value}`}]},{default:A(()=>[e("div",G,[!n.value&&u.value?(l(),o("div",J,[...s[2]||(s[2]=[e("div",{class:"h-12 w-12 shrink-0 rounded-full bg-muted animate-pulse"},null,-1),e("div",{class:"h-4 w-40 rounded bg-muted animate-pulse"},null,-1)])])):i("",!0),e("div",K,[e("div",Q,[n.value?.profile_path?(l(),o("img",{key:0,src:n.value.profile_path,alt:n.value?.name?`${n.value.name} profile photo`:"Actor profile photo",loading:"lazy",class:"h-full w-full object-cove