import{o as i}from"./rolldown-runtime-iuO8RvI4.js";import{Eh as a}from"./shared-0-C4kdVF7Y.js";import{Mi as s,ki as e}from"./vendor-frame-CwiylG4Y.js";import{Xo as t}from"./shared-1-3-6x7RKF.js";import{nn as r}from"./vendor-all-2-BJdkbLSj.js";import{w as d}from"./shared-frame-DbQbH4Yr.js";import{r as u}from"./c147e6f61-W6WnVYX9.js";import{Po as o}from"./shared-4-6CEyRAHb.js";import{Zt as n,rt as l,st as h}from"./shared-8-C1HP2d2B.js";var c=i(s()),f=e();function p({artifactVersion:i,sharedVersions:s,onClose:e,onUpdate:p,projectUuid:_}){const m=t(_),{publishedArtifactsBaseUrl:b}=a(),{copyToClipboard:j}=o(),[g,v]=(0,c.useState)("latest"),{mutateAsync:x,isPending:k}=n(i.uuid),y=i.published_artifact_uuid?"publish":"share",C=l(y,{artifact_uuid:i.artifact_uuid,artifact_version_uuid:i.uuid,message_uuid:i.message_uuid,published_artifact_uuid:i.published_artifact_uuid},b,g);return"share"===y?(0,f.jsx)(h,{isOpen:!0,isProjectArtifact:!!m.data?.is_private,isLoading:k,sharedLink:C||"",isShared:"shared"===i.visibility,onClose:e,linkMode:g,onLinkModeChange:v,sharedVersions:s,handleClickShareButton:async()=>{await x({visibility:"shared"});const a=l(y,{artifact_uuid:i.artifact_uuid,artifact_version_uuid:i.uuid,message_uuid:i.message_uuid,published_artifact_uuid:i.published_artifact_uuid},b,g);await j(a||""),p()},updateSharedState:async i=>{"loading"!==i&&(await x({visibility:i}),p())}}):"publish"===y&&i.published_artifact_uuid&&!i.published_artifact_deleted_at?(0,f.jsx)(d.Root,{open:!0,onOpenChange:i=>!i&&e(),children:(0,f.jsxs)(d.Popup,{size:"md",children:[(0,f.jsx)(d.Header,{children:(0,f.jsx)(r,{defaultMessage:"Publish artifact",id:"D1fyBhklj/"})}),(0,f.jsx)("div",{className:"mt-2 flex flex-col gap-2.5",children:(0,f.jsx)(u,{artifactUuid:i.published_artifact_uuid,publishedLink:C||"",onUnpublish:p,onClose:e})})]})}):null}export{p as WiggleSharingModals};