PageSourceSearch

https://app.listingview.io/_next/static/chunks/8866.9aa4beb4209c05ac.js

js listingview.io collected 2026-09-24 14:26:30 UTC 61,317 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8866],{58866:function(e,t,l){l.r(t),l.d(t,{default:function(){return eq},regenerateTrayLaunch:function(){return eY}});var i=l(57437),n=l(2265),r=l(68575),a=l(7261),s=l(9871),o=l(66848),d=l(1974),c=l(98527),u=l(80863),x=l(15092),v=l(80188),p=l(65740),m=l(37914),g=l(42934),h=l(5969),f=l(29985),b=l(22135),y=l(40875),j=l(53113),w=l(96362),k=l(56475),C=l(44794),S=l(42449),z=l(31691),Z=l(82156),N=l(2069),I=l(37930),R=l(91931),A=l(23977),T=l(46387),D=l(12713),F=l(83316),E=l(72608),L=l(11953),W=l(41327),P=l(10020),U=l(46746),M=l(42187),_=l(73247),O=l(43792);function H(e){let{previewListing:t,selectedSlot:l,file:n,selectedCount:r,totalCount:a}=e;return t?(0,i.jsxs)(N.Z,{sx:{display:"flex",flex:1,flexDirection:"column",gap:1.5},children:[(0,i.jsxs)(T.Z,{variant:"caption",sx:{fontSize:"11px",color:"var(--lv-text-tertiary)",fontWeight:500},children:["Previewing:"," ",(0,i.jsx)("strong",{style:{color:"var(--lv-text-primary)"},children:t.title})," ","(",r," of ",a,")"]}),(0,i.jsx)(N.Z,{sx:{aspectRatio:"1 / 1",maxHeight:240,bgcolor:"var(--lv-bg-elevated)",borderRadius:"10px",border:"1px solid var(--lv-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:1},children:(null==n?void 0:n.thumbnailUrl)?(0,i.jsx)("img",{src:n.thumbnailUrl,alt:"Preview in slot ".concat(l),style:{width:"100%",height:"100%",objectFit:"contain",borderRadius:10}}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(j.Z,{size:32,color:"var(--lv-text-tertiary)"}),(0,i.jsxs)(T.Z,{variant:"caption",color:"text.secondary",sx:{fontSize:"11px"},children:["Slot ",l," preview"]})]})}),(0,i.jsx)(T.Z,{variant:"caption",sx:{fontSize:"11px",color:"var(--lv-text-tertiary)"},children:"Live image slot preview is coming soon."})]}):(0,i.jsx)(N.Z,{sx:{display:"flex",flex:1,alignItems:"center",justifyContent:"center",bgcolor:"var(--lv-bg-elevated)",borderRadius:"10px",border:"1px dashed var(--lv-border-default)",p:3,textAlign:"center"},children:(0,i.jsx)(T.Z,{variant:"body2",color:"text.secondary",sx:{fontSize:"13px"},children:"Select a listing to preview"})})}function B(e){var t;let{file:l,existingListingIds:r=[],selectedListingIds:a,onChange:s,onCancel:d,onNext:c}=e,u=(0,z.Z)(),x=(0,Z.Z)(u.breakpoints.down("sm")),[v,p]=(0,n.useState)(""),[m,g]=(0,n.useState)(!0),[h,f]=(0,n.useState)(1),[b,y]=(0,n.useState)(null),{listings:j}={listings:(0,n.useMemo)(()=>[{listingId:10001,title:"Custom Wedding Invitation SVG",status:"active",thumbnailUrl:null},{listingId:10002,title:"Boho Floral Clipart Bundle",status:"active",thumbnailUrl:null},{listingId:10003,title:"Minimalist Logo Template Pack",status:"active",thumbnailUrl:null},{listingId:10004,title:"Vintage Label Design Set",status:"inactive",thumbnailUrl:null},{listingId:10005,title:"Baby Shower Party Printables",status:"active",thumbnailUrl:null},{listingId:10006,title:"Modern Resume Template",status:"active",thumbnailUrl:null},{listingId:10007,title:"Christmas Card Templates",status:"active",thumbnailUrl:null},{listingId:10008,title:"Watercolor Flowers Clipart",status:"active",thumbnailUrl:null},{listingId:10009,title:"Business Card Design Template",status:"inactive",thumbnailUrl:null},{listingId:10010,title:"Social Media Story Templates",status:"active",thumbnailUrl:null}],[]),loading:!1},w=(0,n.useMemo)(()=>{let e=j;if(m&&(e=e.filter(e=>"active"===e.status)),v.trim()){let t=v.trim().toLowerCase();e=e.filter(e=>e.title.toLowerCase().includes(t))}return e},[j,m,v]),k=null!==(t=w.find(e=>e.listingId===b))&&void 0!==t?t:null,C=(0,n.useCallback)(e=>{s(a.includes(e)?a.filter(t=>t!==e):[...a,e]),a.includes(e)||y(e)},[a,s]),S=w.length>0&&w.every(e=>a.includes(e.listingId)),I=!S&&w.some(e=>a.includes(e.listingId)),R=(0,i.jsxs)(N.Z,{sx:{flex:x?"1":"0 0 60%",display:"flex",flexDirection:"column",minWidth:0,borderRight:x?"none":"1px solid var(--lv-border-default)",pr:x?0:2},children:[(0,i.jsxs)(N.Z,{sx:{display:"flex",flexDirection:"column",gap:1,mb:1.5},children:[(0,i.jsx)(D.Z,{size:"small",fullWidth:!0,placeholder:"Search listings…",value:v,onCh
1ange:e=>p(e.target.value),InputProps:{startAdornment:(0,i.jsx)(F.Z,{position:"start",children:(0,i.jsx)(_.Z,{size:14,color:"var(--lv-text-tertiary)"})})},sx:{fontSize:"13px"}}),(0,i.jsxs)(N.Z,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,i.jsx)(E.Z,{control:(0,i.jsx)(L.Z,{checked:m,onChange:e=>g(e.target.checked),size:"small"}),label:(0,i.jsx)(T.Z,{variant:"caption",sx:{fontSize:"12px",color:"var(--lv-text-secondary)"},children:"Active only"}),sx:{m:0}}),(0,i.jsxs)(W.Z,{size:"small",sx:{minWidth:100},children:[(0,i.jsx)(P.Z,{sx:{fontSize:"12px"},children:"Image slot"}),(0,i.jsx)(U.Z,{value:h,label:"Image slot",onChange:e=>f(e.target.value),sx:{fontSize:"12px"},children:Array.from({length:10},(e,t)=>t+1).map(e=>(0,i.jsxs)(M.Z,{value:e,sx:{fontSize:"12px"},children:["Slot ",e]},e))})]})]})]}),w.length>0&&(0,i.jsx)(N.Z,{sx:{mb:.5},children:(0,i.jsx)(E.Z,{control:(0,i.jsx)(L.Z,{checked:S,indeterminate:I,onChange:()=>{let e=w.map(e=>e.listingId);e.every(e=>a.includes(e))?s(a.filter(t=>!e.includes(t))):s(Array.from(new Set([...a,...e])))},size:"small"}),label:(0,i.jsxs)(T.Z,{variant:"caption",sx:{fontSize:"12px",fontWeight:500,color:"var(--lv-text-secondary)"},children:["Select all (",w.length,")"]}),sx:{m:0}})}),(0,i.jsxs)(N.Z,{sx:{flex:1,overflowY:"auto",maxHeight:320,display:"flex",flexDirection:"column",gap:.25},role:"listbox","aria-label":"Listings to assign","aria-multiselectable":"true",children:[0===w.length&&(0,i.jsx)(T.Z,{variant:"caption",color:"text.secondary",sx:{fontSize:"12px",py:2,textAlign:"center"},children:"No listings match your search."}),w.map(e=>{let t=a.includes(e.listingId),l=r.includes(e.listingId);
1return(0,i.jsxs)(N.Z,{role:"option","aria-selected":t,sx:{display:"flex",alignItems:"center",gap:1,px:1,py:.75,borderRadius:"8px",cursor:"pointer",bgcolor:t?"var(--lv-selected-light)":"transparent","&:hover":{bgcolor:t?"var(--lv-selected-light)":"var(--lv-bg-hover)"},transition:"background-color 0.1s"},onClick:()=>C(e.listingId),onMouseEnter:()=>y(e.listingId),children:[(0,i.jsx)(L.Z,{checked:t,size:"small",onChange:()=>C(e.listingId),onClick:e=>e.stopPropagation(),sx:{p:.5},inputProps:{"aria-label":"Select ".concat(e.title)}}),(0,i.jsxs)(N.Z,{sx:{flex:1,minWidth:0},children:[(0,i.jsx)(T.Z,{noWrap:!0,sx:{fontSize:"13px",fontWeight:500,color:"var(--lv-text-primary)"},children:e.title}),(0,i.jsxs)(T.Z,{variant:"caption",sx:{fontSize:"11px",color:"var(--lv-text-tertiary)"},children:["#",e.listingId,"active"!==e.status&&" \xb7 Inactive",l&&" \xb7 Already assigned"]})]}),l&&(0,i.jsx)(O.Z,{title:"This listing already has the file assigned",placement:"left",children:(0,i.jsx)(N.Z,{component:"span",sx:{fontSize:"10px",px:.75,py:.25,bgcolor:"var(--lv-bg-elevated)",border:"0.5px solid var(--lv-border-default)",borderRadius:"4px",color:"var(--lv-text-tertiary)",flexShrink:0},children:"Assigned"})})]},e.listingId)})]})]}),A=(0,i.jsxs)(N.Z,{sx:{flex:x?"1":"0 0 40%",pl:x?0:2,display:"flex",flexDirection:"column"},children:[(0,i.jsx)(T.Z,{variant:"caption",sx:{display:"block",fontWeight:600,color:"var(--lv-text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",fontSize:"10px",mb:1},children:"Live preview"}),(0,i.jsx)(H,{previewListing:k,selectedSlot:h,file:l,selectedCount:a.length,totalCount:w.length})]});return(0,i.jsxs)(N.Z,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,i.jsxs)(N.Z,{sx:{display:"flex",flexDirection:x?"column":"row",gap:0,flex:1,minHeight:0},children:[R,A]}),(0,i.jsxs)(N.Z,{sx:{display:"flex",justifyContent:"flex-end",gap:1,mt:2,pt:2,borderTop:"1px solid var(--lv-border-default)"},children:[(0,i.jsx)(o.f,{text:"Cancel",color:"white",width:"auto",padding:"px-3 py-1.5",textSize:"text-sm",noShadow:!0,onClick:d}),(0,i.jsx)(o.f,{text:"Next (".concat(a.length," selected)"),color:"purple",width:"auto",padding:"px-3 py-1.5",textSize:"text-sm",noShadow:!0,disabled:0===a.length,onClick:c})]})]})}function K(e){let{selectedListingIds:t,listings:l=[],currentReuseCount:n=0,onBack:r,onConfirm:a,submitting:s=!1}=e,d=t.length,c=n+d>500,u=Object.fromEntries(l.map(e=>[e.listingId,e])),x=t.slice(0,5),v=Math.max(0,d-5);return(0,i.jsxs)(N.Z,{role:"alertdialog","aria-modal":"true","aria-labelledby":"assign-confirm-title",children:[(0,i.jsxs)(T.Z,{id:"assign-confirm-title",variant:"h6",sx:{fontSize:"16px",fontWeight:700,color:"var(--lv-text-primary)",mb:.5},children:["Apply this image to ",d," listing",1!==d?"s":""]}),(0,i.jsxs)(T.Z,{variant:"body2",sx:{fontSize:"13px",color:"var(--lv-text-secondary)",mb:2},children:["This will update the selected image slot across all ",d," listing",1!==d?"s":"",". No listings will be deleted."]}),(0,i.jsxs)(N.Z,{sx:{display:"flex",alignItems:"center",gap:1,mb:2.5,flexWrap:"wrap"},children:[x.map(e=>{var t;let l=u[e];return(0,i.jsx)(N.Z,{sx:{width:48,height:48,borderRadius:"8px",overflow:"hidden",border:"1px solid var(--lv-border-default)",bgcolor:"var(--lv-bg-elevated)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(null==l?void 0:l.thumbnailUrl)?(0,i.jsx)("img",{src:l.thumbnailUrl,alt:null!==(t=l.title)&&void 0!==t?t:"Listing ".concat(e),style:{width:"100%",height:"100%",objectFit:"cover"}}):(0,i.jsx)(j.Z,{size:18,color:"var(--lv-text-tertiary)","aria-hidden":"true"})},e)}),v>0&&(0,i.jsx)(N.Z,{sx:{width:48,height:48,borderRadius:"8px",bgcolor:"var(--lv-bg-elevated)",border:"1px solid var(--lv-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,i.jsxs)(T.Z,{variant:"caption",sx:{fontSize:"11px",fontWeight:700,color:"var(--lv-text-secondary)"},children:["+",v]})})]}),(0,i.jsx)(N.Z,{sx:{p:1.5,bgcolor:"var(--lv-bg-elevated)",border:"0.5px solid var(--lv-border-default)",borderRadius:"8px",mb:c?1.5:2.5},children:(0,i.jsx)(T.Z,{variant:"caption",sx:{fontSize:"12px",color:"var(--lv-text-secondary)",lineHeight:1.5},children:"Etsy publishes updates over a few minutes. You can leave this window — we'll keep working in the background."})}),c&&(0,i.jsx)(N.Z,{sx:{p:1.5,bgcolor:"var(--lv-error-bg)",border:"0.5px solid var(--lv-error)",borderRadius:"8px",mb:2.5},role:"alert",children:(0,i.jsxs)(T.Z,{variant:"caption",sx:{fontSize:"12px",color:"var(--lv-error)",lineHeight:1.5},children:["This file is already used in ",n," listing",1!==n?"s":""," (max ",500,"). Unselect some to continue."]})}),(0,i.jsxs)(N.Z,{sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[(0,i.jsx)(o.f,{text:"Back",color:"white",width:"auto",padding:"px-3 py-1.5",textSize:"text-sm",noShadow:!0,disabled:s,onClick:r}
1),(0,i.jsx)(o.f,{text:"Apply to ".concat(d," listing").concat(1!==d?"s":""),color:"purple",width:"auto",padding:"px-3 py-1.5",textSize:"text-sm",noShadow:!0,loading:s,disabled:s||c,onClick:a,ariaLabel:"Apply image to ".concat(d," listing").concat(1!==d?"s":"")})]})]})}var Y=l(92934),G=l(99388),X=l(65690),q=l(52636),V=l(6428),$=l(48614),J=l(29266);let Q=[.1,.25,.5,.75,1],ee={pending:{color:"var(--lv-bg-elevated)",border:"var(--lv-border-default)",textColor:"var(--lv-text-tertiary)",icon:null},syncing:{color:"var(--lv-info-bg)",border:"var(--lv-info)",textColor:"var(--lv-info)",icon:"spinner"},synced:{color:"var(--lv-success-bg)",border:"var(--lv-success)",textColor:"var(--lv-success)",icon:"check"},failed:{color:"var(--lv-error-bg)",border:"var(--lv-error)",textColor:"var(--lv-error)",icon:"x"},rate_limited:{color:"var(--lv-warning-bg)",border:"var(--lv-warning)",textColor:"var(--lv-warning)",icon:"hourglass"}};function et(e){var t;let{listingId:l,state:n,index:r,totalCount:a}=e,o=null!==(t=ee[n])&&void 0!==t?t:ee.pending;return(0,i.jsx)(V.E.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,delay:r*(a>0?Math.min(40,100/a):0)*.001},children:(0,i.jsxs)(N.Z,{sx:{p:1,borderRadius:"8px",border:"0.5px solid ".concat(o.border),bgcolor:o.color,display:"flex",alignItems:"center",gap:.75,minHeight:40},children:[(0,i.jsxs)(N.Z,{sx:{flexShrink:0,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center"},children:["spinner"===o.icon&&(0,i.jsx)(s.D8,{size:14,sx:{color:o.textColor}}),"check"===o.icon&&(0,i.jsx)(Y.Z,{size:14,color:o.textColor}),"x"===o.icon&&(0,i.jsx)(G.Z,{size:14,color:o.textColor}),"hourglass"===o.icon&&(0,i.jsx)(X.Z,{size:14,color:o.textColor}),null===o.icon&&(0,i.jsx)(N.Z,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:"var(--lv-border-strong)"}})]}),(0,i.jsxs)(T.Z,{variant:"caption",noWrap:!0,sx:{fontSize:"11px",color:o.textColor,flex:1,minWidth:0},children:["#",l]}),"failed"===n&&(0,i.jsx)(q.Z,{size:12,color:o.textColor,"aria-label":"Failed — retry pending"})]})})}function el(e){var t,l;let{cascadeId:a,assignedListingIds:s=[],onUndo:d,onDone:c}=e,u=(0,z.Z)(),x=(0,Z.Z)(u.breakpoints.down("sm")),{listings:v,counts:p,total:m,allComplete:g}=function(e){var t,l,i,a,s;let o=(0,r.I0)(),d=(0,r.v9)(t=>{var l,i,n;return e?null===(n=t.assetLibraryV2)||void 0===n?void 0:null===(i=n.cascades)||void 0===i?void 0:null===(l=i.byId)||void 0===l?void 0:l[e]:null});return((0,n.useEffect)(()=>{e&&d&&!d.pollingActive&&(d.allComplete||o((0,A.tl)({cascadeId:e})))},[e,d,o]),(0,n.useEffect)(()=>{if(e)return()=>{o((0,J.A2)(e))}},[e,o]),d)?{counts:null!==(t=d.counts)&&void 0!==t?t:{pending:0,syncing:0,synced:0,failed:0,rate_limited:0},listings:null!==(l=d.listings)&&void 0!==l?l:[],total:null!==(i=d.total)&&void 0!==i?i:0,allComplete:null!==(a=d.allComplete)&&void 0!==a&&a,pollingActive:null!==(s=d.pollingActive)&&void 0!==s&&s}:{counts:{pending:0,syncing:0,synced:0,failed:0,rate_limited:0},listings:[],total:0,allComplete:!1,pollingActive:!1}}(a),[h,f]=(0,n.useState)(10),[b,y]=(0,n.useState)(!1),j=(0,n.useRef)(null),w=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=requestAnimationFrame(()=>{var e;null===(e=w.current)||void 0===e||e.focus()}),t=setInterval(()=>{f(e=>e<=1?(clearInterval(t),y(!0),0):e-1)},1e3);return j.current=t,()=>{clearInterval(t),cancelAnimationFrame(e)}},[]),(0,n.useEffect)(()=>{g&&(j.current&&clearInterval(j.current),y(!0))},[g]);let k=(0,n.useRef)(new Set),[C,S]=(0,n.useState)("");(0,n.useEffect)(()=>{var e;if(!m||0===m)return;let t=null!==(e=p.synced)&&void 0!==e?e:0,l=t/m;for(let e of Q)if(l>=e&&!k.current.has(e)){k.current.add(e),S("".concat(t," of ").concat(m," assigned"));break}},[p.synced,m]);let I=Object.fromEntries((null!=v?v:[]).map(e=>[e.listingId,e.state])),R=s.map(e=>{var t;return{listingId:e,state:null!==(t=I[e])&&void 0!==t?t:"pending"}}),D=(0,n.useCallback)(()=>{y(!0),j.current&&clearInterval(j.current),null==d||d()},[d]),F=b?"Undo assignment (expired)":"Undo assignment (".concat(h," second").concat(1!==h?"s":""," remaining)"),E=b||g;return(0,i.jsxs)(N.Z,{sx:{display:"flex",flexDirection:"column",gap:2},children:[(0,i.jsxs)(N.Z,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[(0,i.jsxs)(N.Z,{children:[(0,i.jsx)(T.Z,{variant:"body2",sx:{fontSize:"14px",fontWeight:600,color:"var(--lv-text-primary)"},children:g?"All done!":"Updating your listings…"}),(0,i.jsxs)(T.Z,{variant:"caption",sx:{fontSize:"12px",color:"var(--lv-text-secondary)"},children:[null!==(t=p.synced)&&void 0!==t?t:0," of ",m," synced with Etsy"]})]}),!b&&(0,i.jsx)("span",{ref:w,tabIndex:-1,style:{outline:"none"},children:(0,i.jsx)(o.f,{text:"Undo (".concat(h,"s)"),color:"white-outline",width:"auto",padding:"px-2.5 py-1",textSize:"text-xs",noShadow:!0,ariaLabel:F,onClick:D})})]}),(0,i.jsx)(N.Z,{role:"status","aria-live":"polite","aria-atomic":"true",sx:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:C}),(0,i.jsx)(N.Z,{sx:{display:"grid",gridTemplateColumns:x?"repeat(2, 1fr)":"repeat(5, 1fr)",gap:.75,maxHeight:320,overflowY:"auto"},children:(0,i.jsx)($.M,{children:R.map((e,t)=>{let{listingId:l,state:n}=e;return(0,i.jsx)(et,{listingId:l,state:n,index:t,totalCount:R.length},l)})})}),(null!==(l=p.failed)&&void 0!==l?l:0)>0&&g&&(0,i.jsx)(N.Z,{sx:{p:1.5,bgcolor:"var(--lv-warning-bg)",border:"0.5px solid var(--lv-warning)",borderRadius:"8px"},role:"alert",children:(0,i.jsxs)(T.Z,{variant:"caption",sx:{fontSize:"12px",color:"var(--lv-text-secondary)",lineHeight:1.5},children:[p.failed," listing",1!==p.failed?"s":""," couldn't sync with Etsy. Etsy may be rate-limiting updates — these will typically resolve within a few hours."]})}),E&&(0,i.jsx)(N.Z,{sx:{display:"flex",justifyContent:"flex-end"},children:(0,i.jsx)(o.f,{text:"Done",color:"purple",width:"auto",padding:"px-3 py-1.5",textSize:"text-sm",noShadow:!0,onClick:c})})]})}let ei={1:"Assign to listings",2:"Confirm assignment",3:"Updating listings…"},en=[{listingId:10001,title:"Custom Wedding Invitation SVG",status:"active",thumbnailUrl:null},{listingId:10002,title:"Boho Floral Clipart Bundle",status:"active",thumbnailUrl:null},{listingId:10003,title:"Minimalist Logo Template Pack",status:"active",thumbnailUrl:null},{listingId:10004,title:"Vintage Label Design Set",status:"inactive",thumbnailUrl:null},{listingId:10005,title:"Baby Shower Party Printables",status:"active",thumbnailUrl:null},{listingId:10006,title:"Modern Resume Template",status:"active",thumbnailUrl:null},{listingId:10007,title:"Christmas Card Templates",status:"active",thumbnailUrl:null},{listingId:10008,title:"Watercolor Flowers Clipart",status:"active",thumbnailUrl:null},{listingId:10009,title:"Business Card Design Template",status:"inactive",thumbnailUrl:null},{listingId:10010,title:"Social Media Story Templates",status:"active",thumbnailUrl:null}];function er(e){let{open:t,onClose:l,fileId:s,existingListingIds:o=[]}=e,d=(0,r.I0)(),{handleError:c,modal:u}=(0,R.R)(),x=(0,z.Z)(),v=(0,Z.Z)(x.breakpoints.down("sm")),[p,m]=(0,n.use
1State)(1),[g,h]=(0,n.useState)(o),[f,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(!1),w=(0,n.useRef)([]),k=(0,n.useCallback)(()=>{0!==g.length&&m(2)},[g.length]),C=(0,n.useCallback)(()=>{m(1)},[]),S=(0,n.useCallback)(async()=>{if(y)return;j(!0);let e=await d((0,A.Rl)({fileId:s,listingIds:g}));if(j(!1),A.Rl.fulfilled.match(e)){var t,l;let i=null!==(l=null===(t=e.payload)||void 0===t?void 0:t.cascadeId)&&void 0!==l?l:null;w.current=[...g],b(i),m(3)}else if(A.Rl.rejected.match(e)){let t=e.payload;((null==t?void 0:t.error)==="retention_locked"||(null==t?void 0:t.code)==="RETENTION_LOCKED")&&c({response:{status:403,data:t}})}},[d,s,g,y]),T=(0,n.useCallback)(()=>{y||(m(1),h(o),b(null),j(!1),w.current=[],null==l||l())},[y,o,l]),D=(0,n.useCallback)(async()=>{try{await d((0,A.bG)({fileId:s,listingIds:w.current})).unwrap(),a.Am.success("Assignment undone."),T()}catch(e){}},[d,s,T]),F=(0,n.useCallback)(()=>{T()},[T]),E=(0,n.useCallback)((e,t)=>{y||"backdropClick"===t&&3===p||T()},[y,p,T]);return(0,i.jsxs)(i.Fragment,{children:[u,(0,i.jsx)(I.Z,{open:t,onClose:E,title:ei[p],size:v?"fullscreen":1===p?"lg":"sm",fullWidth:!0,noPadding:!1,disableBackdropClose:3===p||y,disableEscapeKeyDown:y,children:(0,i.jsxs)(N.Z,{sx:{minHeight:1===p?440:"auto"},children:[1===p&&(0,i.jsx)(B,{file:{id:s},existingListingIds:o,selectedListingIds:g,onChange:h,onCancel:T,onNext:k}),2===p&&(0,i.jsx)(K,{selectedListingIds:g,listings:en,currentReuseCount:0,onBack:C,onConfirm:S,submitting:y}),3===p&&(0,i.jsx)(el,{cascadeId:f,assignedListingIds:w.current,onUndo:D,onDone:F})]})})]})}var ea=l(48702);function es(e){let{file:t,onClose:l}
1=e,s=(0,r.I0)(),[d,c]=(0,n.useState)(!1),[x,v]=(0,n.useState)(!1),[p,m]=(0,n.useState)((null==t?void 0:t.linkedListings)||[]),[g,h]=(0,n.useState)((null==t?void 0:t.collections)||[]);(0,n.useEffect)(()=>{m((null==t?void 0:t.linkedListings)||[]),h((null==t?void 0:t.collections)||[])},[null==t?void 0:t.linkedListings,null==t?void 0:t.collections]);let z=Array.isArray(null==t?void 0:t.podProducts)?t.podProducts:[],Z=Array.isArray(null==t?void 0:t.openOrders)?t.openOrders:[],N=p.length,I=g.length,R=N+I+z.length+Z.length;(0,n.useEffect)(()=>{0===R&&d&&c(!1)},[R,d]);let T=async e=>{m(t=>t.filter(t=>t.listingId!==e));try{await s((0,A.bG)({fileId:t.id,listingIds:[e],skipPolling:!0})).unwrap(),a.Am.success("Listing unassigned.")}catch(e){m(p)}},D=async e=>{h(t=>t.filter(t=>t.id!==e));try{await s((0,ea.Kn)({collectionId:e,fileId:t.id})).unwrap(),a.Am.success("Removed from collection.")}catch(e){h(g),a.Am.error((null==e?void 0:e.message)||"Failed to remove from collection. Please try again.")}},F=p.map(e=>e.listingId);return(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)("div",{className:"mb-2 flex min-h-[24px] items-center justify-between gap-2",children:[(0,i.jsxs)("button",{type:"button",onClick:0===R?void 0:()=>c(e=>!e),"aria-expanded":0===R?void 0:d,disabled:0===R,className:"flex items-center gap-1.5 rounded-lv-sm border-0 bg-transparent p-0 text-lv-btn uppercase tracking-wide text-lv-text-secondary outline-none focus-visible:ring-2 focus-visible:ring-lv-focus disabled:cursor-default enabled:cursor-pointer",children:[(0,i.jsx)(f.Z,{size:12,color:"var(--lv-text-tertiary)","aria-hidden":"true"}),"In use / Attached to",R>0?" \xb7 ".concat(R):"",R>0&&(d?(0,i.jsx)(b.Z,{size:12,color:"var(--lv-text-tertiary)","aria-hidden":"true"}):(0,i.jsx)(y.Z,{size:12,color:"var(--lv-text-tertiary)","aria-hidden":"true"}))]}),(0,i.jsx)(o.f,{text:"Assign to listings",color:"secondary",size:"xs",width:"auto",onClick:()=>v(!0)})]}),(0,i.jsx)(er,{open:x,onClose:()=>v(!1),fileId:t.id,existingListingIds:F}),d&&(0,i.jsxs)("div",{className:"flex flex-col gap-3 rounded-lv-md border border-lv-border bg-lv-elevated px-2.5 py-2",children:[N>0&&(0,i.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,i.jsx)(eo,{icon:f.Z,text:"Listings"}),p.map(e=>{let{deliverableId:t,listingId:l,title:n,thumbnailUrl:r}=e;return(0,i.jsxs)("div",{className:"flex items-center gap-2 py-1",children:[r?(0,i.jsx)("img",{src:r,alt:"",className:"h-8 w-8 shrink-0 rounded-lv-xs bg-lv-well",style:{objectFit:"cover"}}):(0,i.jsx)("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lv-xs border border-lv-border bg-lv-well",children:(0,i.jsx)(j.Z,{size:14,color:"var(--lv-text-tertiary)","aria-hidden":"true"})}),(0,i.jsx)("span",{className:"min-w-0 flex-1 truncate text-lv-caption text-lv-text-primary",children:n||"Listing #".concat(l)}),(0,i.jsx)(o.f,{text:"",icon:(0,i.jsx)(w.Z,{size:11}),color:"gray",size:"xs",href:"/dashboard/listing-optimizer/".concat(l),target:"_blank",width:"auto","aria-label":"Open listing ".concat(n||l)}),(0,i.jsx)(o.f,{text:"Unassign",color:"secondary",size:"xs",width:"auto",onClick:()=>T(l)})]},t||l)})]}),I>0&&(0,i.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,i.jsx)(eo,{icon:k.Z,text:"Collections"}),g.map(e=>{let{id:t,name:n}=e;return(0,i.jsxs)("div",{className:"flex items-center gap-2 py-1",children:[(0,i.jsx)("span",{className:"min-w-0 flex-1 truncate text-lv-caption text-lv-text-primary",children:n||"Collection #".concat(t)}),(0,i.jsx)(o.f,{text:"",icon:(0,i.jsx)(w.Z,{size:11}),color:"gray",size:"xs",width:"auto","aria-label":"Open collection ".concat(n||t),onClick:()=>{s((0,ea.af)(t)),s((0,u.rr)({collectionId:t,page:1})),null==l||l()}}),(0,i.jsx)(o.f,{text:"Remove",color:"secondary",size:"xs",width:"auto",onClick:()=>D(t)})]},t)})]}),z.length>0&&(0,i.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,i.jsx)(eo,{icon:C.Z,text:"POD products"}),z.map((e,t)=>{var l,n;return(0,i.jsx)("p",{className:"m-0 truncate py-1 text-lv-caption text-lv-text-primary",children:(null==e?void 0:e.title)||"POD product #".concat(null!==(l=null==e?void 0:e.catalogId)&&void 0!==l?l:t+1)},null!==(n=null==e?void 0:e.catalogId)&&void 0!==n?n:t)})]}),Z.length>0&&(0,i.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,i.jsx)(eo,{icon:S.Z,text:"Open orders"}),Z.map((e,t)=>{var l,n;return(0,i.jsxs)("p",{className:"m-0 truncate py-1 text-lv-caption text-lv-text-primary",children:["Order #",null!==(l=null==e?void 0:e.podOrderId)&&void 0!==l?l:t+1,(null==e?void 0:e.status)?" \xb7 ".concat(e.status):""]},null!==(n=null==e?void 0:e.podOrderId)&&void 0!==n?n:t)})]})]})]})}function eo(e){let{icon:t,text:l}=e;return(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)(t,{size:11,color:"var(--lv-text-tertiary)","aria-hidden":"true"}),(0,i.jsx)("span",{className:"text-lv-micro uppercase text-lv-text-tertiary",children:l})]})}function ed(e){let{title:t,action:l,children:r,className:a=""}=e,s=(0,n.useId)();return(0,i.jsxs)("section",{"aria-labelledby":s,className:["min-w-0",a].filter(
1Boolean).join(" "),children:[(0,i.jsxs)("div",{className:"mb-2 flex min-h-[24px] items-center justify-between gap-2",children:[(0,i.jsx)("h3",{id:s,className:"m-0 text-lv-btn uppercase tracking-wide text-lv-text-secondary",children:t}),l?(0,i.jsx)("div",{className:"shrink-0",children:l}):null]}),r]})}var ec=l(92573),eu=l(30401),ex=l(45675),ev=l(9932),ep=l(13213);function em(e){let{anchorEl:t,open:l,onClose:n,file:r,disabled:a=!1,onSelect:s}=e,o=function(e){let{disabled:t=!1,onSelect:l}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return g.Xj.map(n=>{let r=(0,g.r)(n),a=r.icon,s=(0,g.EE)(e,n);return{key:n,role:"menuitemradio",checked:s,label:r.label,description:r.description,icon:(0,i.jsx)(a,{size:14,"aria-hidden":"true"}),active:s,disabled:s||t,onClick:()=>null==l?void 0:l(n)}})}(r,{disabled:a,onSelect:s});return(0,i.jsx)(ep.Z,{anchorEl:t,open:l,onClose:n,items:o,minWidth:248,maxWidth:300,header:(0,i.jsx)("span",{className:"text-lv-btn uppercase tracking-wide text-lv-text-tertiary",children:"Change role"})})}function eg(e){let{file:t,name:l,extension:r,role:a,canRename:s=!0,canChangeRole:o=!1,changingRole:d=!1,onChangeRole:c,onRename:u}
1=e,[x,v]=(0,n.useState)(!1),[p,m]=(0,n.useState)(""),[g,h]=(0,n.useState)(!1),[f,b]=(0,n.useState)(null),y=(0,n.useRef)(null),j=(0,n.useRef)(!1);(0,n.useEffect)(()=>{var e;x&&(null===(e=y.current)||void 0===e||e.select())},[x]),(0,n.useEffect)(()=>{j.current=!1,v(!1),m("")},[l]);let w=(0,n.useCallback)(()=>{s&&(m(l),j.current=!0,v(!0))},[l,s]),k=(0,n.useCallback)(()=>{j.current=!1,v(!1),m("")},[]),C=(0,n.useCallback)(async()=>{if(!j.current)return;j.current=!1,v(!1);let e=p.trim();if(m(""),e&&e!==l){h(!0);try{await (null==u?void 0:u(e))}finally{h(!1)}}},[l,p,u]);return(0,i.jsxs)("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-x-2 gap-y-1.5",children:[(0,i.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[(0,i.jsx)("input",{ref:y,"data-testid":"file-detail-name","aria-label":"File name",value:x?p:l,readOnly:!x,disabled:g,onChange:e=>m(e.target.value),onKeyDown:e=>{if("Enter"===e.key&&x){e.preventDefault(),C();return}"Escape"===e.key&&x&&(e.preventDefault(),e.stopPropagation(),k())},onBlur:C,onClick:()=>{x||w()},className:"min-w-0 flex-1 rounded-lv-sm border border-solid bg-transparent px-1 py-0.5 text-lv-section text-lv-text-primary outline-none focus-visible:ring-2 focus-visible:ring-lv-focus",style:{borderColor:x?"var(--lv-selected)":"transparent",cursor:x?"text":s?"pointer":"default"}}),s&&(0,i.jsx)("button",{type:"button",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lv-sm border-0 bg-transparent text-lv-text-tertiary outline-none hover:text-lv-text-primary focus-visible:ring-2 focus-visible:ring-lv-focus","aria-label":x?"Save file name":"Rename file",onMouseDown:e=>e.preventDefault(),onClick:()=>x?C():w(),children:x?(0,i.jsx)(eu.Z,{size:16}):(0,i.jsx)(ex.Z,{size:14})})]}),(0,i.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[r&&(0,i.jsx)("span",{"data-testid":"file-detail-type-badge",className:"inline-flex h-5 items-center rounded-lv-md border border-lv-border bg-lv-chip px-2 text-lv-btn uppercase text-lv-text-secondary",children:r}),(0,i.jsx)(ev.Z,{role:a,size:"md",interactive:o,changeable:o,"aria-expanded":o?!!f:void 0,onClick:e=>b(e.currentTarget)})]}),o&&(0,i.jsx)(em,{anchorEl:f,open:!!f,onClose:()=>b(null),file:t,disabled:d,onSelect:e=>{b(null),null==c||c(e)}})]})}var eh=l(83646),ef=l(68380);function eb(e){let{file:t,isListingImage:l=!1}=e,r=function(e){let{isListingImage:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[];let l=[],i=(e,t,i)=>{null!=i&&""!==i&&l.push({key:e,label:t,value:String(i)})};i("size","Size",e.fileSize?(0,ef.td)(e.fileSize):null),i("type","Type",e.mimeType);let n=e.metadata||null,r=(0,ef.s1)(e.mimeType||"");if(n){if("image"===r){n.width&&n.height&&i("dimensions","Dimensions","".concat(n.width," \xd7 ").concat(n.height," px"));let e=(0,ef.BR)(n);e&&i("printSize","Max print size","".concat(e.widthIn," \xd7 ").concat(e.heightIn," in @ 300 DPI")),n.colorMode&&i("colorMode","Color mode",String(n.colorMode).toUpperCase()),void 0!==n.hasTransparency&&i("transparency","Transparency",n.hasTransparency?"Yes":"No"),i("bitDepth","Bit depth",n.bitDepth)}else"pdf"===r?i("pages","Pages",n.pageCount):"archive"===r&&(i("fileCount","Files inside",n.fileCount),i("uncompressed","Uncompressed",n.uncompressedSize?(0,ef.td)(n.uncompressedSize):null))}return i("uploaded","Uploaded",function(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString()}(e.createdAt)),e.originalFilename&&e.originalFilename!==e.sanitizedFilename&&i("originalFilename","Original file",e.originalFilename),t&&null!=e.rank&&i("rank","Rank",e.rank),e.uploadStatus&&"ready"!==e.uploadStatus&&i("status","Status",e.uploadStatus),l}(t,{isListingImage:l});return(0,i.jsxs)("div",{className:"min-w-0",children:[r.length>0&&(0,i.jsx)("dl",{"data-testid":"file-detail-facts",className:"m-0 grid items-baseline gap-x-3 gap-y-1",style:{gridTemplateColumns:"minmax(84px, max-content) minmax(0, 1fr)"},children:r.map(e=>{let{key:t,label:l,value:r}=e;return(0,i.jsxs)(n.Fragment,{children:[(0,i.jsx)("dt",{className:"text-lv-caption text-lv-text-tertiary",children:l}),(0,i.jsx)("dd",{className:"m-0 break-words text-lv-caption text-lv-text-primary",children:r})]},t)})}),(0,i.jsx)("div",{className:"mt-2 empty:mt-0",children:(0,i.jsx)(eh.Z,{file:t})})]})}var ey=l(43391),ej=l(45802),ew=l(69076),ek=l(74440),eC=l(77200);
1function eS(e){let{src:t,alt:l="",maxHeight:n=500,naturalWidth:r,naturalHeight:a,renderOverlay:s,onCollapse:d,collapseLabel:c="Shrink image"}=e,{viewportRef:u,zoomPercent:x,isZoomed:v,canPan:p,isPanning:m,naturalSize:g,viewportSize:h,transform:f,zoom:b,maxZoom:y,minZoom:j,zoomIn:w,zoomOut:k,reset:C,handleImageLoad:S,pointerHandlers:z}=(0,eC.ZP)({src:t,naturalWidth:r,naturalHeight:a}),{onKeyDown:Z,...I}=z;return(0,i.jsxs)(N.Z,{ref:u,role:"group","aria-label":l?"".concat(l," — zoomable preview"):"Zoomable image preview",tabIndex:0,onKeyDown:Z,...I,sx:{position:"relative",width:"100%",maxHeight:n,...g.width&&g.height?{aspectRatio:"".concat(g.width," / ").concat(g.height)}:{height:n},borderRadius:2,overflow:"hidden",border:"0.5px solid var(--lv-border-default)",boxShadow:"0px 1px 4px -2px rgba(0, 0, 0, 0.25)",backgroundImage:"linear-gradient(45deg, var(--lv-bg-checker) 25%, transparent 25%), linear-gradient(-45deg, var(--lv-bg-checker) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--lv-bg-checker) 75%), linear-gradient(-45deg, transparent 75%, var(--lv-bg-checker) 75%)",backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",cursor:m?"grabbing":p?"grab":"zoom
1-in",touchAction:"none",userSelect:"none",outline:"none","&:focus-visible":{boxShadow:"0px 1px 4px -2px rgba(0, 0, 0, 0.25), 0 0 0 2px var(--lv-focus-ring)"}},children:[(0,i.jsxs)(N.Z,{sx:{position:"absolute",inset:0,transformOrigin:"center center",willChange:"transform"},style:{transform:f,transition:m?"none":"transform 90ms ease-out"},children:[(0,i.jsx)("img",{src:t,alt:l,draggable:!1,onLoad:S,style:{width:"100%",height:"100%",objectFit:"contain",display:"block",pointerEvents:"none"}}),null==s?void 0:s({width:h.width,height:h.height})]}),(0,i.jsxs)(N.Z,{onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),sx:{position:"absolute",bottom:8,right:8,display:"flex",alignItems:"center",gap:.5,p:.5,borderRadius:"12px",bgcolor:"var(--lv-bg-card)",border:"0.5px solid var(--lv-border-default)",boxShadow:"0px 2px 8px -2px rgba(0, 0, 0, 0.3)",cursor:"default"},children:[(0,i.jsx)(o.f,{size:"xs",icon:(0,i.jsx)(ej.Z,{size:14}),ariaLabel:"Zoom out",disabled:b<=j,onClick:k}),(0,i.jsxs)(N.Z,{"aria-live":"polite",sx:{minWidth:44,textAlign:"center",fontSize:"12px",fontWeight:600,fontVariantNumeric:"tabular-nums",color:"var(--lv-text-secondary)"},children:[x,"%"]}),(0,i.jsx)(o.f,{size:"xs",icon:(0,i.jsx)(ey.Z,{size:14}),ariaLabel:"Zoom in",disabled:b>=y,onClick:w}),(0,i.jsx)(o.f,{size:"xs",icon:(0,i.jsx)(ew.Z,{size:14}),ariaLabel:"Reset zoom",disabled:!v,onClick:C}),d&&(0,i.jsx)(o.f,{size:"xs",icon:(0,i.jsx)(ek.Z,{size:14}),ariaLabel:c,onClick:d})]})]})}var ez=l(71399),eZ=l(3397),eN=l(61865);function eI(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:234;if(!e||!t)return null;let i=Math.min(l/e,l/t,1);return{width:Math.round(e*i),height:Math.round(t*i)}}function eR(e){var t;return(null==e?void 0:e.assetCategory)==="mockup_templates"&&!!((null==e?void 0:null===(t=e.regions)||void 0===t?void 0:t.length)||(null==e?void 0:e.mockupRegion))}function eA(e){let{file:t}=e,l=(null==t?void 0:t.fileExtension)||(0,x.mD)((null==t?void 0:t.sanitizedFilename)||(null==t?void 0:t.originalFilename)||"")||(0,x.su)((null==t?void 0:t.mimeType)||""),n=(0,x.XD)(l),r=n.icon;return(0,i.jsxs)("div",{className:"flex flex-col items-center gap-2","data-testid":"file-detail-type-glyph",children:[(0,i.jsx)(r,{size:56,strokeWidth:1.25,color:n.text,"aria-hidden":"true"}),l&&(0,i.jsx)("span",{className:"text-lv-btn uppercase tracking-wide text-lv-text-tertiary",children:l})]})}function eT(e){var t,l;let{file:n,alt:r,onCollapse:a,maxHeight:s=480}=e;return(0,i.jsx)(eS,{src:(0,eZ.Bp)(n)?null==n?void 0:n.thumbnailUrl:(null==n?void 0:n.s3Url)||(null==n?void 0:n.thumbnailUrl),alt:r,maxHeight:s,naturalWidth:null==n?void 0:null===(t=n.metadata)||void 0===t?void 0:t.width,naturalHeight:null==n?void 0:null===(l=n.metadata)||void 0===l?void 0:l.height,onCollapse:a,collapseLabel:"Shrink image",renderOverlay:e=>{let{width:t,height:l}=e;return eR(n)&&t>0&&l>0?(0,i.jsx)(ez.Z,{regions:n.regions,region:n.mockupRegion,containerWidth:t,containerHeight:l,fit:"contain"}):null}})}function eD(e){var t,l;let{file:r,alt:a,onExpand:s,hotspotRef:o}=e,[d,c]=(0,n.useState)(null),u=!!(0,eN.w)(r)&&(!!(0,eZ.Bp)(r)||"image"===(0,ef.s1)((null==r?void 0:r.mimeType)||"")),x=(0,eN.w)(r),v=eI(null==d?void 0:d.width,null==d?void 0:d.height)||eI(null==r?void 0:null===(t=r.metadata)||void 0===t?void 0:t.width,null==r?void 0:null===(l=r.metadata)||void 0===l?void 0:l.height);return(0,i.jsx)("div",{"data-testid":"file-detail-image-frame",className:"rounded-lv-lg border border-lv-border-media bg-lv-well",style:{width:260,height:260,maxWidth:"100%",boxSizing:"border-box",padding:12,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:u?(0,i.jsxs)("button",{type:"button",ref:o,"data-testid":"file-detail-image-hotspot",onClick:s,"aria-label":"Enlarge image",className:"group relative inline-flex cursor-zoom-in rounded-lv-sm border-0 bg-transparent p-0 leading-none outline-none focus-visible:ring-2 focus-visible:ring-lv-focus",children:[(0,i.jsx)("img",{src:x,alt:a,"data-testid":"file-detail-image",onLoad:e=>c({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),style:{maxWidth:234,maxHeight:234,width:"auto",height:"auto",objectFit:"contain",display:"block",borderRadius:"var(--lv-radius-sm)"}}),eR(r)&&v&&(0,i.jsx)(ez.Z,{regions:r.regions,region:r.mockupRegion,containerWidth:v.width,containerHeight:v.height,fit:"contain"}),(0,i.jsx)("span",{"data-testid":"file-detail-zoom-overlay",className:"pointer-events-none absolute inset-0 flex items-center justify-center rounded-lv-sm opacity-0 transition-opacity duration-lv-fast ease-lv group-hover:opacity-100 group-focus-visible:opacity-100 motion-reduce:transition-none",style:{backgroundColor:"color-mix(in srgb, var(--lv-bg-card) 62%, transparent)",color:"var(--lv-text-primary)"},children:(0,i.jsx)(ey.Z,{size:28,strokeWidth:1.75,"aria-hidden":"true"})})]}):(0,i.jsx)(eA,{file:r})})}var eF=l(41671),eE=l(76865),eL=l(33245),eW=l(29591);function eP(e){let{status:t}=e,l=ef.U[t]||"var(--lv-text-secondary)";switch(t){case"pass":return(0,i.jsx)(eF.Z,{size:16,color:l,"aria-hidden":"true"});case"fail":return(0,i.jsx)(G.Z,{size:16,color:l,"aria-hidden":"true"});case"warning":return(0,i.jsx)(eE.Z,{size:16,color:l,"aria-hidden":"true"});default:return(0,i.jsx)(eL.Z,{size:16,color:l,"aria-hidden":"true"})}}function eU(e){var t,l;let{file:n,assessing:r,onReassess:a}=e,s=(null==n?void 0:null===(t=n.podAssessment)||void 0===t?void 0:t.checks)||[];return(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsx)("div",{className:"flex items-center gap-2",children:(0,i.jsx)(eW.Z,{podStatus:null!==(l=null==n?void 0:n.podStatus)&&void 0!==l?l:null,assessing:r})}),s.map((e,t)=>(0,i.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,i.jsx)("span",{className:"mt-[1px] shrink-0",children:(0,i.jsx)(eP,{status:e.status})}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)("p",{className:"m-0 text-lv-caption font-semibold text-lv-text-primary",children:[e.name,void 0!==e.value&&(0,i.jsxs)("span",{className:"ml-1 font-normal text-lv-text-secondary",children:["(",String(e.value),")"]})]}),e.message&&(0,i.jsx)("p",{className:"m-0 text-lv-caption text-lv-text-secondary",children:e.message})]})]},e.name||t)),(0,i.jsx)("div",{children:(0,i.jsx)(o.f,{text:r?"":"Re-assess",loading:r,color:"secondary",size:"xs",width:"auto",disabled:r,onClick:a})})]})}l(75226),l(90884),l(25238),l(98137),l(72336),l(75986);var eM=l(10093);function e_(e){let{tags:t=[],onAddTag:l,onRemoveTag:r}
1=e,[a,s]=(0,n.useState)(""),[o,d]=(0,n.useState)(!1),c=async e=>{if("Enter"!==e.key)return;e.preventDefault();let i=a.trim().toLowerCase();if(i){if(t.includes(i)){s("");return}d(!0);try{await (null==l?void 0:l(i))&&s("")}finally{d(!1)}}};return(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[t.map(e=>(0,i.jsx)(eM.Z,{tagObj:{tag:e},onRemove:()=>null==r?void 0:r(e)},e)),(0,i.jsx)("input",{"aria-label":"Add tag",placeholder:"+ add tag",value:a,disabled:o,onChange:e=>s(e.target.value),onKeyDown:c,className:"w-[12ch] min-w-[9ch] cursor-text rounded-lv-sm border border-transparent bg-transparent px-1 py-0.5 text-lv-caption text-lv-text-tertiary outline-none focus-visible:ring-2 focus-visible:ring-lv-focus"})]})}l(32372),l(82950),l(47644),l(91003),l(65838),l(16273);var eO=l(82431);function eH(e){let{onRegenerate:t}=e;return(0,i.jsxs)("div",{"data-testid":"stale-mockup-banner",className:"flex items-center gap-2 rounded-lv-md border border-lv-warning-border bg-lv-warning-surface px-3 py-2.5",children:[(0,i.jsx)(eE.Z,{size:14,color:"var(--lv-warning)","aria-hidden":"true",style:{flexShrink:0}}),(0,i.jsx)("p",{className:"m-0 flex-1 text-lv-caption text-lv-warning-strong",children:"This mockup is out of date — the source design was updated."}),(0,i.jsx)(o.f,{text:"Regenerate",color:"secondary",size:"xs",width:"auto",icon:(0,i.jsx)(eO.Z,{size:12}),onClick:t})]})}function eB(e){var t,l,n,r;let{file:a}=e,s=Array.isArray(null==a?void 0:a.regions)&&a.regions.length?a.regions.length:(null==a?void 0:a.mockupRegion)?1:0;if(0===s)return null;let o=(null==a?void 0:null===(n=a.regions)||void 0===n?void 0:null===(l=n[0])||void 0===l?void 0:null===(t=l.quad)||void 0===t?void 0:t.source_dimensions)||(null==a?void 0:null===(r=a.mockupRegion)||void 0===r?void 0:r.source_dimensions);return(0,i.jsxs)("div",{"data-testid":"mockup-region-summary",className:"rounded-lv-md border border-lv-border bg-lv-well px-3 py-2.5",children:[(0,i.jsx)("p",{className:"m-0 text-lv-caption font-semibold text-lv-text-primary",children:1===s?"Mockup region defined":"".concat(s," mockup regions defined")}),(0,i.jsxs)("p",{className:"m-0 text-lv-caption text-lv-text-secondary",children:["Type: perspective_quad",o?" \xb7 ".concat(o.width_px," \xd7 ").concat(o.height_px," px"):""]}),Array.isArray(null==a?void 0:a.regions)&&a.regions.length>0&&(0,i.jsx)("p",{className:"m-0 mt-0.5 text-lv-caption text-lv-text-secondary",children:a.regions.map((e,t)=>{var l;return(null===(l=e.label)||void 0===l?void 0:l.trim())||"Region ".concat(t+1)}).join(" \xb7 ")})]})}function eK(e){let{file:t,onRegenerate:l}=e,n=null==t?void 0:t.generatedFrom;if(!n)return null;let r=n.generated_at?new Date(n.generated_at):null,a=r&&!Number.isNaN(r.getTime())?r.toLocaleDateString():null;return(0,i.jsxs)("div",{"data-testid":"generated-from-panel",className:"rounded-lv-md border border-lv-border bg-lv-well px-3 py-2.5",children:[(0,i.jsxs)("p",{className:"m-0 mb-1.5 text-lv-caption text-lv-text-secondary",children:["Generated from a template",a?" \xb7 ".concat(a):""]}),n.template_thumbnail&&(0,i.jsxs)("div",{className:"mb-2 flex gap-1.5",children:[(0,i.jsx)("img",{src:n.template_thumbnail,alt:"Source template",className:"h-12 w-12 shrink-0 rounded-lv-xs border border-lv-border-media bg-lv-well",style:{objectFit:"cover"}}),n.design_thumbnail&&(0,i.jsx)("img",{src:n.design_thumbnail,alt:"Source design",className:"h-12 w-12 shrink-0 rounded-lv-xs border border-lv-border-media bg-lv-well",style:{objectFit:"cover"}})]}),(0,i.jsx)(o.f,{text:"Regenerate",color:"secondary",size:"xs",width:"auto",icon:(0,i.jsx)(eO.Z,{size:12}),onClick:l})]})}let eY=e=>{let t=(null==e?void 0:e.generatedFrom)||{};return{designFile:{id:t.design_file_id||t.listing_image_id},options:{...null!=t.template_id?{preselectedTemplateIds:[t.template_id]}:{},isListingImage:!t.design_file_id&&null!=t.listing_image_id}}};function eG(e){var t,l;return(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.file)||(null==e?void 0:null===(l=e.data)||void 0===l?void 0:l.data)||(null==e?void 0:e.data)||null}function eX(e,t){return e?(0,c.G_)({...e,...t}):e}function eq(e){var t,l,f,b,y,j;let{fileId:w,assetCategory:k,open:C,onClose:S,onOpenMockupTray:z}=e,Z=(0,r.I0)(),N=(0,r.oR)(),I=(0,r.v9)(e=>e.assetLibrary.filters.listingImagesSubTab),R=(0,r.v9)(e=>
1e.assetLibrary.filters),[A,T]=(0,n.useState)(!1),[D,F]=(0,n.useState)(null),[E,L]=(0,n.useState)(!1),[W,P]=(0,n.useState)(!1),[U,M]=(0,n.useState)(!1),{changeRole:_,changing:O}=(0,m.ts)(),H=(0,n.useRef)(null),B=(0,n.useCallback)(e=>{let t="function"==typeof e?e(H.current):e;return H.current=t,F(t),t},[]),K=(0,n.useRef)(null),Y=(0,n.useRef)(null),G=(0,n.useRef)(!1),X=(0,n.useCallback)(()=>T(!1),[]);(0,n.useEffect)(()=>{var e,t;A?null===(e=K.current)||void 0===e||e.focus():G.current&&(null===(t=Y.current)||void 0===t||t.focus()),G.current=A},[A]);let q="listing_images"===R.assetCategory&&"user_marked"!==I,V=async()=>{var e,t,l,i;L(!0);try{let l=q?await (0,c.W7)(w):await (0,c.hn)(w),i=(null===(e=l.data)||void 0===e?void 0:e.data)||(null===(t=l.data)||void 0===t?void 0:t.file)||l.data,n=q?{...i,thumbnailUrl:i.activeUrl,s3Url:i.activeUrl,sanitizedFilename:i.listingTitle||"image-".concat(i.id),mimeType:"image/jpeg",assetCategory:"listing_images",uploadStatus:"ready"}:(0,c.G_)(i);B(n)}catch(e){a.Am.error((null==e?void 0:null===(i=e.response)||void 0===i?void 0:null===(l=i.data)||void 0===l?void 0:l.message)||"Failed to load file details.")}finally{L(!1)}};(0,n.useEffect)(()=>{C&&w&&(V(),T(!1))},[C,w]);let $=(null==D?void 0:D.sanitizedFilename)||(null==D?void 0:D.originalFilename)||"",{base:J,ext:Q}=(0,h.qW)($),ee=$.slice(J.length),et=(null==D?void 0:D.listingTitle)||$,el=D?q?et:(0,h.kR)(D):"",ei=(null==D?void 0:null===(t=D.collections)||void 0===t?void 0:t.length)||0,en=q?et:J,er=q?(0,x.su)((null==D?void 0:D.mimeType)||""):Q,ea=D?(0,g.yG)(D):g.rq.FILE,eo=(0,g.sF)(D,{isEtsyImageContext:q}),eu=(0,n.useCallback)(e=>{var t,l;let i=null===(l=N.getState())||void 0===l?void 0:null===(t=l.assetLibrary)||void 0===t?void 0:t.files,n=Array.isArray(i)&&i.some(t=>String(t.id)===String(e.id));return n&&Z((0,u.cT)(e)),n},[Z,N]),ex=(0,n.useCallback)(()=>{var e,t;Z((0,u.uB)(null===(t=N.getState())||void 0===t?void 0:null===(e=t.assetLibrary)||void 0===e?void 0:e.filters))},[Z,N]),ev=async e=>{try{let t=await (0,c.Dd)(w,{fileName:e+ee}),l=eG(t),i=B(t=>{var i;return eX(t,{sanitizedFilename:null!==(i=null==l?void 0:l.sanitizedFilename)&&void 0!==i?i:e+ee})});eu(i),ex(),a.Am.success("File renamed.")}catch(e){var t,l;a.Am.error((null==e?void 0:null===(l=e.response)||void 0===l?void 0:null===(t=l.data)||void 0===t?void 0:t.message)||"Failed to rename file.")}},ep=async e=>{let t=H.current;if(!t)return;let l=await _(t,e,{isEtsyImageContext:q}).catch(()=>null);l&&eu(B(e=>eX(e,{assetCategory:l.assetCategory})))},em=async e=>{try{var t,l;let i=await (0,c.Dd)(w,{tags:e}),n=eG(i),r=B(t=>{var l;return eX(t,{tags:null!==(l=null==n?void 0:n.tags)&&void 0!==l?l:e})});return eu(r),function(e){let t=null==e?void 0:e.tags;return Array.isArray(t)?t.length>0:!!t}(null===(l=N.getState())||void 0===l?void 0:null===(t=l.assetLibrary)||void 0===t?void 0:t.filters)&&ex(),!0}catch(e){return a.Am.error("Failed to update tags."),!1}},eh=async()=>{P(!0);try{await (0,c.xj)(w),await V(),a.Am.success("POD re-assessment complete.")}catch(l){var e,t;a.Am.error((null==l?void 0:null===(t=l.response)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.message)||"Failed to re-assess POD.")}finally{P(!1)}},{requestDelete:ef,isDeleting:ey,dialogProps:ej}=(0,p.Y)({onDeleted:()=>S()}),ew=async()=>{M(!1),await ef(D||{id:w})},ek=()=>{S();let e=eY(D);null==z||z(e.designFile,!0,e.options)},{actions:eC,modals:eS}=(0,v.a)(D,{context:"detail",isEtsyImageContext:q,onClose:S,onOpenMockupTray:z,onCategoryChanged:e=>B(t=>eX(t,{assetCategory:e})),onRegionSaved:S}),ez=!!D&&!q,eZ=ez&&ea===g.rq.DESIGN,eN=ea===g.rq.LISTING_IMAGE,eI=ea===g.rq.MOCKUP_TEMPLATE&&!!((null==D?void 0:null===(l=D.regions)||void 0===l?void 0:l.length)||(null==D?void 0:D.mockupRegion)),eR=!!((null==D?void 0:D.isStale)&&(null==D?void 0:D.generatedFrom)),eA=!!(null==D?void 0:D.generatedFrom),eF=eI||eR||eA,eE=!!((null==D?void 0:null===(f=D.linkedListings)||void 0===f?void 0:f.length)||(null==D?void 0:null===(b=D.collections)||void 0===b?void 0:b.length)||(null==D?void 0:null===(y=D.podProducts)||void 0===y?void 0:y.length)||(null==D?void 0:null===(j=D.openOrders)||void 0===j?void 0:j.length));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(d.Z,{open:C,onClose:(e,t)=>{if(A&&"escapeKeyDown"===t){X();return}null==S||S()},maxWidth:"md",fullWidth:!0,title:el||"File details",actions:(0,i.jsxs)(i.Fragment,{children:[ez&&(0,i.jsx)(o.f,{text:"Delete File",color:"black",width:"auto",disabled:ey,onClick:()=>M(!0)}),(0,i.jsx)("div",{className:"flex-1"}),(0,i.jsx)(o.f,{text:"Close",color:"white",width:"auto",onClick:S})]}),children:E?(0,i.jsx)("div",{className:"flex justify-center py-12",children:(0,i.jsx)(s.D8,{})}):D?(0,i.jsxs)("div",{className:"flex min-w-0 flex-col gap-4",children:[(0,i.jsx)(eg,{file:D,name:en,extension:er,role:ea,canRename:ez,canChangeRole:eo,changingRole:O,onChangeRole:ep,onRename:ev}),(0,i.jsxs)("div",{className:"relative min-h-[360px]",children:[(0,i.jsxs)("div",{className:"grid grid-cols-1 items-start gap-6 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]","data-testid":"file-detail-grid","aria-hidden":A||void 0,inert:A?"":void 0,children:[(0,i.jsxs)("div",{className:"flex min-w-0 flex-col gap-4",children:[(0,i.jsx)(eD,{file:D,alt:el,hotspotRef:Y,onExpand:()=>T(!0)}),(0,i.jsx)(ed,{title:"Details",children:(0,i.jsx)(eb,{file:D,isListingImage:eN})})]}),(0,i.jsxs)("div",{className:"flex min-w-0 flex-col gap-5",children:[eC.length>0&&(0,i.jsx)(ed,{title:"Actions",children:(0,i.jsx)(ec.Z,{actions:eC})}
1),eE&&(0,i.jsx)(es,{file:D,onClose:S}),ez&&(0,i.jsx)(ed,{title:"Tags",children:(0,i.jsx)(e_,{tags:D.tags||[],onAddTag:e=>em([...D.tags||[],e]),onRemoveTag:e=>em((D.tags||[]).filter(t=>t!==e))})}),eZ&&(0,i.jsx)(ed,{title:"Print readiness",children:(0,i.jsx)(eU,{file:D,assessing:W,onReassess:eh})}),eF&&(0,i.jsx)(ed,{title:"Mockup",children:(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[eR&&(0,i.jsx)(eH,{onRegenerate:ek}),eI&&(0,i.jsx)(eB,{file:D}),eA&&(0,i.jsx)(eK,{file:D,onRegenerate:ek})]})})]})]}),A&&(0,i.jsx)("div",{ref:K,"data-testid":"file-detail-expanded-layer",role:"group","aria-label":"Enlarged image",tabIndex:-1,onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),X())},className:"absolute inset-0 overflow-auto rounded-lv-lg bg-lv-card outline-none",children:(0,i.jsx)("div",{className:"flex min-h-full w-full items-center justify-center",children:(0,i.jsx)("div",{className:"w-full",children:(0,i.jsx)(eT,{file:D,alt:el,onCollapse:X})})})})]})]}):(0,i.jsx)("p",{className:"m-0 text-lv-body text-lv-text-secondary",children:"File not found."})}),(0,i.jsx)(d.Z,{open:U,onClose:()=>M(!1),onConfirm:ew,title:"Delete File?",message:['Are you sure you want to delete "'.concat(el||"this file",'"?'),ei>0?"It will be removed from ".concat(ei," collection").concat(ei>1?"s":"","."):"","This action cannot be undone."].filter(Boolean).join(" "),confirmText:"Delete",variant:"danger"}),(0,i.jsx)(p.Z,{...ej}),eS]})}},98137:function(e,t,l){l.d(t,{Z:function(){return x}});var i=l(57437),n=l(43792),r=l(77543),a=l(40875),s=l(10407);let o=r._$.metadata,d={neutral:{backgroundColor:r.oR.bgElevated,color:r.oR.textSecondary},brand:{backgroundColor:r.oR.brandLight,color:r.oR.brand},success:{backgroundColor:r.oR.successBg,color:r.oR.success},warning:{backgroundColor:r.oR.warningBg,color:r.oR.warning},error:{backgroundColor:r.oR.errorBg,color:r.oR.error},info:{backgroundColor:r.oR.infoBg,color:r.oR.info}};function c(e){let{value:t,label:l,tone:r="neutral",tooltip:a}=e,s=(0,i.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5",style:{...function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"neutral";return d[e]||d.neutral}(r),fontSize:10,fontWeight:600,lineHeight:1.2,fontFamily:o,letterSpacing:"0.01em"},children:[null!=t&&(0,i.jsx)("span",{style:{color:"inherit"},children:t}),l&&(0,i.jsx)("span",{style:{color:"inherit",opacity:t?.88:1},children:l})]});return a?(0,i.jsx)(n.Z,{title:a,children:s}):s}function u(e){let{item:t,isActive:l,onSectionClick:n}=e,a=t.icon,s=t.indicators||[];return(0,i.jsxs)("button",{type:"button",onClick:()=>!t.disabled&&n(t.id),disabled:t.disabled,className:"group flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left transition-colors duration-150 hover:bg-lv-elevated",style:{backgroundColor:l?r.oR.bgElevated:"transparent",opacity:t.disabled?.55:1,cursor:t.disabled?"not-allowed":"pointer"},"aria-current":l?"true":void 0,children:[a?(0,i.jsx)(a,{size:13,strokeWidth:2,style:{color:l?r.oR.textPrimary:r.oR.textSecondary,flexShrink:0}}):null,(0,i.jsxs)("span",{className:"min-w-0 flex-1 flex items-center gap-1.5",children:[(0,i.jsx)("span",{className:"block truncate text-xs",style:{color:r.oR.textPrimary,fontWeight:l?600:500},children:t.label}),t.meta&&(0,i.jsx)("span",{className:"hidden text-[10px] leading-4 xl:block",style:{color:r.oR.textSecondary},children:t.meta})]}),s.length>0&&(0,i.jsx)("span",{className:"ml-1 flex flex-shrink-0 items-center gap-1 whitespace-nowrap",children:s.map(e=>(0,i.jsx)(c,{value:e.value,label:e.label,tone:e.tone,tooltip:e.tooltip},"".concat(t.id,"-").concat(e.label||e.value||e.tone)))})]})}function x(e){var t;let{sections:l,activeSection:n,expandedSections:d,onToggleSection:x,onSectionClick:v,summary:p,widthClassName:m="w-[224px]"}=e;return(0,i.jsxs)("div",{className:"".concat(m," flex-shrink-0 p-2"),children:[p?(0,i.jsxs)("div",{className:"mb-3 space-y-2 px-1",children:[!p.compact&&p.eyebrow&&(0,i.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",style:{color:r.oR.textSecondary,fontFamily:o},children:p.eyebrow}),!p.compact&&(p.title||p.description)&&(0,i.jsxs)("div",{className:"space-y-1",children:[p.title&&(0,i.jsx)("div",{className:"text-sm font-semibold",style:{color:r.oR.textPrimary},children:p.title}),p.description&&(0,i.jsx)("p",{className:"m-0 text-xs leading-5",style:{color:r.oR.textSecondary},children:p.description})]}),(null===(t=p.stats)||void 0===t?void 0:t.length)>0&&(0,i.jsx)("div",{className:"flex flex-wrap gap-1",children:p.stats.map(e=>(0,i.jsx)(c,{value:e.value,label:e.label,tone:e.tone,tooltip:e.tooltip},"".concat(e.label,"-").concat(e.value)))}),p.actions]}):null,(0,i.jsx)("div",{children:l.map((e,t)=>{let l=null==d?void 0:d[e.title],p=e.indicators||[];return(0,i.jsxs)("div",{style:{paddingTop:t>0?32:0},children:[(0,i.jsxs)("button",{type:"button",onClick:()=>x(e.title),className:"mb-2 flex w-full items-center justify-between rounded px-1.5 py-1 text-left transition-colors duration-150 hover:bg-lv-elevated","aria-expanded":l,children:[(0,i.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[(0,i.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",style:{color:r.oR.textTertiary,fontFamily:o},children:e.title}),p.length>0&&(0,i.jsx)("span",{className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap",children:p.map(t=>(0,i.jsx)(c,{value:t.value,label:t.label,tone:t.tone,tooltip:t.tooltip},"".concat(e.title,"-").concat(t.label||t.value||t.tone)))})]}),l?(0,i.jsx)(a.Z,{size:12,strokeWidth:2,style:{color:r.oR.textTertiary}}):(0,i.jsx)(s.Z,{size:12,strokeWidth:2,style:{color:r.oR.textTertiary}})]}),l?(0,i.jsx)("div",{className:"space-y-px pt-0.5",children:e.items.map(e=>(0,i.jsx)(u,{item:e,isActive:e.id===n,onSectionClick:v},e.id))}):null]},e.key||e.title)})})]})}}
1,77200:function(e,t,l){l.d(t,{mi:function(){return a},rE:function(){return r}});var i=l(2265);let n="floored",r="native",a=.5,s=Object.freeze({x:0,y:0});function o(e,t,l){if(!Number.isFinite(e))return t;let i=Math.min(l,Math.max(t,e));return 0===i?0:i}function d(e){let{viewportWidth:t,viewportHeight:l,naturalWidth:i,naturalHeight:n}=e;if(!t||!l||!i||!n)return{width:0,height:0};let r=Math.min(t/i,l/n);return{width:i*r,height:n*r}}function c(e){let{zoom:t,viewportWidth:l,viewportHeight:i,contentWidth:n,contentHeight:r}=e;return{x:Math.max(0,(n*t-l)/2),y:Math.max(0,(r*t-i)/2)}}function u(e){let{offset:t,zoom:l,viewportWidth:i,viewportHeight:n,contentWidth:r,contentHeight:a}=e,s=c({zoom:l,viewportWidth:i,viewportHeight:n,contentWidth:r,contentHeight:a});return{x:o(t.x,-s.x,s.x),y:o(t.y,-s.y,s.y)}}function x(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function v(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}t.ZP=function(){let{src:e,naturalWidth:t,naturalHeight:l,zoomDisabled:a=!1,zoomRange:p=n,zoomOutFloor:m=1,zoomCapacityScale:g=1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},h=(0,i.useRef)(null),f=(0,i.useMemo)(()=>({width:Number(t)>0?Number(t):0,height:Number(l)>0?Number(l):0}),[t,l]),[b,y]=(0,i.useState)({width:0,height:0}),[j,w]=(0,i.useState)(f),[k,C]=(0,i.useState)({zoom:1,offset:s}),[S,z]=(0,i.useState)(!1),[Z,N]=(0,i.useState)(!1),I=(0,i.useRef)(!1),R=(0,i.useRef)(k),A=(0,i.useCallback)(e=>{R.current=e,C(e)},[]),T=(0,i.useMemo)(()=>{let e=d({viewportWidth:b.width,viewportHeight:b.height,naturalWidth:j.width,naturalHeight:j.height});return{viewportWidth:b.width,viewportHeight:b.height,contentWidth:e.width,contentHeight:e.height,minZoom:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return Number.isFinite(e)?o(e,.25,1):1}(m),maxZoom:a?1:function(e){let{viewportWidth:t,viewportHeight:l,naturalWidth:i,naturalHeight:a,zoomRange:s=n,capacityScale:c=1}=e,u=s===r,x=d({viewportWidth:t,viewportHeight:l,naturalWidth:i,naturalHeight:a});return x.width?o(i*(Number.isFinite(c)&&c>0?c:1)/x.width,u?1:8,32):u?1:8}({viewportWidth:b.width,viewportHeight:b.height,naturalWidth:j.width,naturalHeight:j.height,zoomRange:p,capacityScale:g})}},[b,j,g,a,p,m]),D=(0,i.useRef)(T);D.current=T;let F=function(e,t){var l;let i=o(e.zoom,null!==(l=t.minZoom)&&void 0!==l?l:1,t.maxZoom),n=u({offset:e.offset,zoom:i,...t});return .001>=Math.abs(i-e.zoom)&&n.x===e.offset.x&&n.y===e.offset.y?e:{zoom:i,offset:n}}(k,T);R.current=F,(0,i.useEffect)(()=>{F!==k&&C(F)},[F,k]);let E=(0,i.useCallback)(()=>{A({zoom:1,offset:s})},[A]),L=(0,i.useRef)(f);L.current=f,(0,i.useEffect)(()=>{I.current=!1,w(L.current),E()},[e,E]),(0,i.useEffect)(()=>{I.current||w(f)},[f]);let W=(0,i.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s,i=D.current,n=R.current,r=o(e,i.minZoom,i.maxZoom),a=function(e){let{zoom:t,offset:l,nextZoom:i,point:n}=e;if(!t)return l;let r=i/t;return{x:n.x-(n.x-l.x)*r,y:n.y-(n.y-l.y)*r}}({zoom:n.zoom,offset:n.offset,nextZoom:r,point:t}),d=u({offset:{x:a.x+l.x,y:a.y+l.y},zoom:r,...i});A({zoom:r,offset:d})},[A]),P=(0,i.useCallback)(e=>{let t=R.current;A({zoom:t.zoom,offset:u({offset:e,zoom:t.zoom,...D.current})})},[A]),U=(0,i.useCallback)((e,t)=>{let{offset:l}=R.current;P({x:l.x+e,y:l.y+t})},[P]),M=(0,i.useRef)(null),_=(0,i.useCallback)(()=>{N(!0),null!=M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{M.current=null,N(!1)},140)},[]);(0,i.useEffect)(()=>()=>{null!=M.current&&(clearTimeout(M.current),M.current=null)},[]);let O=(0,i.useCallback)(()=>{W(1.5*R.current.zoom)},[W]),H=(0,i.useCallback)(()=>{W(R.current.zoom/1.5)},[W]),B=(0,i.useCallback)(()=>{let e=h.current;e&&y(t=>t.width===e.clientWidth&&t.height===e.clientHeight?t:{width:e.clientWidth,height:e.clientHeight})},[]);(0,i.useEffect)(()=>{let e=h.current;if(!e||"undefined"==typeof ResizeObserver)return;B();let t=new ResizeObserver(B);return t.observe(e),()=>t.disconnect()},[B]);let K=(0,i.useCallback)(e=>{let t=(null==e?void 0:e.currentTarget)||(null==e?void 0:e.target);
1(null==t?void 0:t.naturalWidth)&&(null==t?void 0:t.naturalHeight)&&(I.current=!0,w({width:t.naturalWidth,height:t.naturalHeight})),B()},[B]),Y=(0,i.useCallback)((e,t)=>{let l=h.current;if(!l)return s;let i=l.getBoundingClientRect();return{x:e-i.left-i.width/2,y:t-i.top-i.height/2}},[]);(0,i.useEffect)(()=>{let e=h.current;if(!e)return;let t=e=>{e.preventDefault();let t=e.deltaY;1===e.deltaMode&&(t*=16);let l=.0025*(e.ctrlKey?4:1);_(),W(R.current.zoom*Math.exp(-t*l),Y(e.clientX,e.clientY))};return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t)},[W,_,Y]);let G=(0,i.useRef)(new Map),X=(0,i.useRef)(new Set),q=(0,i.useRef)(null),V=(0,i.useRef)(null),$=(0,i.useCallback)(e=>{G.current.delete(e.pointerId),X.current.delete(e.pointerId);try{var t,l;null===(l=e.currentTarget)||void 0===l||null===(t=l.releasePointerCapture)||void 0===t||t.call(l,e.pointerId)}catch(e){}G.current.size<2&&(V.current=null),0===G.current.size&&(q.current=null,z(!1))},[]),J=(0,i.useCallback)(e=>{if("mouse"===e.pointerType&&0!==e.button)return;let t=e.currentTarget;if("function"==typeof(null==t?void 0:t.hasPointerCapture))for(let l of[...X.current])l!==e.pointerId&&(t.hasPointerCapture(l)||(X.current.delete(l),G.current.delete(l)));G.current.set(e.pointerId,{x:e.clientX,y:e.clientY});try{e.currentTarget.setPointerCapture(e.pointerId),X.current.add(e.pointerId)}catch(e){}let l=[...G.current.values()];if(l.length>=2){q.current=null,V.current={distance:x(l[0],l[1]),midpoint:v(l[0],l[1])},z(!1);return}q.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startOffset:R.current.offset};let i=c({zoom:R.current.zoom,...D.current});(i.x>0||i.y>0)&&z(!0)},[]),Q=(0,i.useCallback)(e=>{let{pointerId:t,clientX:l,clientY:i}=null!=e?e:{};if(null==t||!Number.isFinite(l)||!Number.isFinite(i))return;let n=h.current;if("function"==typeof(null==n?void 0:n.setPointerCapture))try{n.setPointerCapture(t),X.current.add(t)}catch(e){return}G.current.set(t,{x:l,y:i})},[]),ee=(0,i.useCallback)(e=>{if(!G.current.has(e.pointerId))return;G.current.set(e.pointerId,{x:e.clientX,y:e.clientY});let t=[...G.current.values()];if(t.length>=2&&V.current){let e=x(t[0],t[1]),l=v(t[0],t[1]),i=V.current;if(V.current={distance:e,midpoint:l},!i.distance)return;let n=Y(i.midpoint.x,i.midpoint.y);_(),W(R.current.zoom*(e/i.distance),n,{x:l.x-i.midpoint.x,y:l.y-i.midpoint.y});return}let l=q.current;l&&l.pointerId===e.pointerId&&P({x:l.startOffset.x+(e.clientX-l.startX),y:l.startOffset.y+(e.clientY-l.startY)})},[W,_,P,Y]),et=(0,i.useCallback)(e=>{if(Math.abs(R.current.zoom-1)>.001){E();return}W(Math.min(3,D.current.maxZoom),Y(e.clientX,e.clientY))},[W,E,Y]),el=(0,i.useMemo)(()=>{let e=c({zoom:F.zoom,...T});return e.x>0||e.y>0},[F.zoom,T]),ei=(0,i.useCallback)(e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.shiftKey?144:48;switch(e.key){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":if(!el)return;e.preventDefault(),"ArrowLeft"===e.key?U(t,0):"ArrowRight"===e.key?U(-t,0):"ArrowUp"===e.key?U(0,t):U(0,-t);return;case"+":case"=":e.preventDefault(),O();return;case"-":case"_":e.preventDefault(),H();return;case"0":e.preventDefault(),E();return}},[el,U,E,O,H]),en=Math.abs(F.zoom-1)>.001;return{viewportRef:h,zoom:F.zoom,offset:F.offset,maxZoom:T.maxZoom,minZoom:T.minZoom,zoomPercent:Math.round(100*F.zoom),isZoomed:en,canPan:el,isPanning:S&&el,isZooming:Z,naturalSize:j,viewportSize:b,transform:"translate(".concat(F.offset.x,"px, ").concat(F.offset.y,"px) scale(").concat(F.zoom,")"),zoomIn:O,zoomOut:H,reset:E,panBy:U,handleImageLoad:K,adoptPointer:Q,pointerHandlers:{onPointerDown:J,onPointerMove:ee,onPointerUp:$,onPointerCancel:$,onDoubleClick:et,onKeyDown:ei}}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.