1import{c as Pe,K as De,r as a,j as e,S as f,T as q,y as G,z as V}from"./app-DDm4dLCY.js";import{E as Te}from"./ElementClicks-kW2hk5aq.js";import{P as Ie}from"./Placeholder-W1UKt5jG.js";import{S as W}from"./SubscribePopup-BIs2wKL_.js";import{A as oe,a as ne,b as ae,c as ie,d as le,e as de,f as ce}from"./alert-dialog-DOvnI9Cl.js";import{B as v}from"./button-D9X3vUxO.js";import{D as Le,a as $e,b as Ae,c as Re,e as Fe}from"./dialog-CEzzDisZ.js";import{S as ze}from"./switch-BT-Lzq3Z.js";import{u as Be,a as He,D as Me,c as Oe,S as Ue,v as Qe,P as Ke,b as qe,d as Ge,C as Ve,G as We,F as Xe}from"./sortable.esm-Tr8sBFKY.js";import{P as ue}from"./plus-BXg4Gnan.js";import{X as Ye}from"./x-CHtAT9W1.js";import{S as me}from"./square-pen-C2HK8B_v.js";import{T as Je}from"./trash-2-pwk1GwC3.js";import{C as Ze}from"./chart-column-Bw2FzsCp.js";/* empty css */import"./dayjs.min-BSRjg0LM.js";import"./index-Cdxa91Ef.js";import"./index-AnRJGDGt.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const es=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ss=Pe("Image",es);function rs({element:t,linksDraggable:c,editing:T,showAnalytics:i,errors:h,linkAnalytics:j,inputRefs:k,imageInputRefs:y,onEditName:l,onEditUrl:u,onNameChange:b,onUrlChange:p,onNameBlur:S,onUrlBlur:I,onDeleteLink:L,onToggleDisplay:x,onSelectImage:$,onUpdateImage:N,onRemoveImage:A,onToggleShowAnalytics:_,onToggleDownloadEnabled:R}){const{attributes:C,listeners:F,setNodeRef:m,transform:z,transition:w,isDragging:B}=Ge({id:t.id,disabled:!c}),E={transform:Ve.Transform.toString(z),transition:w},g=T[t.id]||{};return e.jsxs("div",{ref:m,style:E,className:`bg-card border-border mt-3 flex items-center overflow-hidden border sm:rounded-xl ${B?"ring-primary/40 relative z-10 shadow-lg ring-1":""}`,children:[e.jsx("div",{className:"px-2 sm:px-2",...C,...c?F:{},children:e.jsx(We,{className:`${c?"text-muted-foreground cursor-grab":"text-muted-foreground/40 cursor-not-allowed"} h-4 w-4`})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"py-4 pr-4 pl-2 sm:pr-6 sm:pl-4",children:[e.jsxs("div",{className:"items-between flex w-full",children:[e.jsx("div",{className:"flex-shrink-0",children:t.image&&e.jsx("div",{className:"group relative mr-3 h-12 w-12 flex-shrink-0 overflow-hidden rounded-xl bg-cover bg-center",style:{backgroundImage:`url(${t.image})`},children:e.jsx("div",{className:"absolute inset-0 flex cursor-pointer items-center justify-center bg-white/50 opacity-0 group-hover:opacity-100",children:e.jsx(Ye,{className:"text-foreground h-6 w-6",onClick:o=>{o.stopPropagation(),A(t)},"aria-hidden":"true"})})})}),e.jsxs("div",{className:"flex-1 flex-shrink truncate overflow-hidden",children:[e.jsxs("div",{onClick:()=>l(t),children:[e.jsx("input",{ref:o=>k.current[`name-${t.id}`]=o,type:"text",value:t.name??"",onChange:o=>b(t,o.target.value),onKeyDown:o=>{o.key==="Enter"&&o.currentTarget.blur()},onBlur:()=>S(t),placeholder:"Title",className:`text-foreground placeholder:text-muted-foreground w-full max-w-xs appearance-none border-0 bg-transparent p-0 text-sm font-medium outline-none focus:ring-0 ${g.name?"":"hidden"}`}),e.jsxs("div",{className:`flex items-center justify-start ${g.name?"hidden":""}`,children:[e.jsx("p",{className:"text-foreground cursor-pointer truncate text-sm font-medium",onClick:o=>{o.stopPropagation(),l(t)},children:t.name?t.name:"Title"}),e.jsx(me,{className:"text-muted-foreground ml-2 h-4 w-4 flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),l(t)},"aria-hidden":"true"})]})]}),t.type!=="header"&&e.jsxs("div",{className:"mt-2",onClick:()=>u(t),children:[e.jsx("input",{ref:o=>k.current[`url-${t.id}`]=o,type:"text",value:t.content??"",onChange:o=>p(t,o.target.value),onKeyDown:o=>{o.key==="Enter"&&o.currentTarget.blur()},onBlur:()=>I(t),placeholder:"Url",className:`text-muted-foreground placeholder:text-muted-foreground w-full max-w-xs appearance-none border-0 bg-transparent p-0 text-sm outline-none focus:ring-0 ${g.url?"":"hidden"}`}),e.jsxs("div",{className:`flex items-center justify-start ${g.url?"hidden":""}`,children:[e.jsx("p",{className:"text-muted-foreground max-w-xs cursor-pointer truncate text-sm",onClick:o=>{o.stopPropagation(),u(t)},children:t.content?t.content:"Url"}),e.jsx(me,{className:"text-muted-foreground ml-2 h-4 w-4 flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),u(t)},"aria-hidden":"true"})]})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-start justify-center pl-2",children:[e.jsx("div",{className:`mr-2 flex-shrink-0 ${t.enabled_for_display?"hidden":""}`,children:e.jsx(Je,{className:"text-muted-foreground hover:text-destructive mt-0.5 h-4 w-4 cursor-pointer",onClick:o=>{o.stopPropagation(),L(t)},"aria-hidden":"true"})}),e.jsx(ze,{size:"sm",checked:!!t.enabled_for_display,onCheckedChange:o=>x(t,o)})]})]}),t.type!=="header"&&e.jsxs("div",{className:"mt-2 flex items-center gap-1 pt-1",style:{marginLeft:"-6px"},children:[e.jsxs(q,{children:[e.jsx(G,{asChild:!0,children:e.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground hover:bg-muted rounded-md p-1.5 transition-colors",onClick:o=>{o.stopPropagation(),$(t)},children:[e.jsx(ss,{className:"size-4","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:"Add an image"})]})}),e.jsx(V,{children:"Add an image"})]}),e.jsxs(q,{children:[e.jsx(G,{asChild:!0,children:e.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground hover:bg-muted rounded-md p-1.5 transition-colors",onClick:o=>{o.stopPropagation(),_(t)},children:[e.jsx(Ze,{className:"size-4","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:"Show analytics"})]})}),e.jsx(V,{children:"Show analytics"})]}),t.type!=="contactcard"&&e.jsxs(q,{children:[e.jsx(G,{asChild:!0,children:e.jsxs("button",{type:"button",className:`${t.enabled_for_download?"text-primary":"text-muted-foreground
6/40"} hover:text-foreground hover:bg-muted rounded-md p-1.5 transition-colors`,onClick:o=>{o.stopPropagation(),R(t)},children:[e.jsx(Xe,{className:"size-4","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:"Include in contact card"})]})}),e.jsx(V,{children:"Include in contact card"})]})]}),h[t.id]&&h[t.id].image&&e.jsx("p",{className:"text-destructive mt-2 text-sm",children:h[t.id].image})]}),i[t.id]&&e.jsx("div",{children:j[t.id]?e.jsx(Te,{analytics:j[t.id]}):e.jsx(Ie,{type:"element-clicks-preview",size:"small"})})]}),e.jsx("input",{type:"file",ref:o=>y.current[`image-input-${t.id}`]=o,accept:"image/x-png,image/gif,image/jpeg",onChange:()=>N(t),className:"hidden"})]})}function ws({profile:t,links:c,linkAnalytics:T,onUpdated:i,onAddToBio:h,onPublishProfile:j,ref:k}){const y=De(),[l,u]=a.useState(c),[b,p]=a.useState({}),[S,I]=a.useState({}),[L,x]=a.useState(!0),[$,N]=a.useState(!1),[A,_]=a.useState(!1),[R,C]=a.useState(!1),[F,m]=a.useState(!1),[z,w]=a.useState(!1),[B,E]=a.useState(!1),[g,o]=a.useState({}),H=a.useRef({}),M=a.useRef({}),P=a.useRef({}),fe=Be(He(Ke));a.useEffect(()=>{u(c)},[c]);const he=y.props.auth.user.features.allow_element_image,O=y.props.auth.user.features.link_limit,X=y.props.auth.user.plan_name,d=s=>{u(r=>r.map(n=>n.id===s.id?s:n))},pe=()=>{const s={profile_id:t.id,enabled_for_display:!1,enabled_for_download:!1,order:1,type:"header"};f.post(route("element.store"),s,{preserveScroll:!0,onSuccess:()=>{},onError:()=>{}})},Y=()=>{if(l.length>=O)return N(!0),!1;const s={profile_id:t.id,enabled_for_display:!1,enabled_for_download:!1,order:1,type:"link"};f.post(route("element.store"),s,{preserveScroll:!0,onSuccess:()=>{},onError:()=>{}})};a.useImperativeHandle(k,()=>({addLink:Y}));const xe=()=>{m(!1),h&&h()},ge=()=>{m(!1),j&&j()},je=s=>{f.delete(route("element.destroy"),{data:s,preserveScroll:!0,onSuccess:()=>{i&&i()},onError:()=>{}})},J=s=>{requestAnimationFrame(()=>{H.current[s]&&H.current[s].focus()})},Z=s=>{x(!1),P.current[`name-${s.id}`]=s.name,p(r=>({...r,[s.id]:{...r[s.id],name:!0}})),J(`name-${s.id}`)},ee=s=>{x(!1),P.current[`url-${s.id}`]=s.content,p(r=>({...r,[s.id]:{...r[s.id],url:!0}})),J(`url-${s.id}`)},ye=s=>{p(r=>({...r,[s.id]:{...r[s.id],name:!1}})),s.name!==P.current[`name-${s.id}`]&&se(s)},be=s=>{p(r=>({...r,[s.id]:{...r[s.id],url:!1}})),s.content!==P.current[`url-${s.id}`]&&se(s)},we=({active:s,over:r})=>{if(!r||s.id===r.id)return;const n=l.findIndex(K=>K.id===s.id),Q=l.findIndex(K=>K.id===r.id),te=qe(l,n,Q);u(te),ve(te)},ve=s=>{const r={profile_id:t.id,elements:s};f.post(route("element.reorder"),r,{preserveScroll:!0,onSuccess:()=>{i&&i()},onError:()=>{}})},ke=(s,r)=>{const n={...s,enabled_for_display:r};if(d(n),n.type==="link"&&(!n.content||!n.name)){setTimeout(()=>{d({...n,enabled_for_display:!1,enabled_for_download:!1}),w(!0)},250);return}if(n.type==="header"&&!n.name){setTimeout(()=>{d({...n,enabled_for_display:!1}),E(!0)},250);return}U(n)},Se=s=>{const r={...s,enabled_for_download:!s.enabled_for_download};if(d(r),!r.content||!r.name){setTimeout(()=>{d({...r,enabled_for_download:!1}),w(!0)},250);return}if(X=="free"&&!r.enabled_for_display){_(!0),setTimeout(()=>{d({...r,enabled_for_download:!r.enabled_for_download})},250);return}U(r)},Ne=s=>{const r=!S[s.id];I(n=>({...n,[s.id]:r})),x(!r)},se=s=>{const r={...s};r.content&&r.name||r.type==="header"&&r.name?r.enabled_for_display=!0:r.enabled_for_display=!1,d(r),U(r)},U=s=>{x(!0);const r={...s};if(X=="free"&&r.enabled_for_display==!1&&(r.enabled_for_download=!1),r.content&&r.content.substr(0,4)!="http"&&(r.content="https://"+r.content),r.type==="link"&&(!r.content||!r.name)){setTimeout(()=>{const n={...r,enabled_for_display:!1,enabled_for_download:!1};d(n),re(n)},250);return}d(r),re(r)},_e=s=>{if(!he){C(!0);return}M.current[`image-input-${s.id}`].click()},Ce=s=>{const r=M.current[`image-input-${s.id}`],n=new FileReader;n.onload=()=>{o({}),f.post(route("element.image.update",{element:s.id}),{_method:"PUT",image:r.files[0]},{preserveScroll:!0,onSuccess:()=>{i&&i()},onError:Q=>{o({[s.id]:Q})}})},n.readAsDataURL(r.files[0])},Ee=s=>{f.post(route("element.image.remove",{element:s.id}),{_method:"DELETE"},{preserveScroll:!0,onSuccess:()=>{i&&i()},onError:()=>{}})},re=s=>{const r=(b[s.id]||{}).name,n=(b[s.id]||{}).url;f.put(route("element.update"),s,{preserveScroll:!0,onSuccess:()=>{s.enabled_for_display&&localStorage.getItem("snapto.newprofile")===t.url&&(m(!0),localStorage.setItem("snapto.newprofile",!1)),r&&Z(s),n&&ee(s),i&&i()},onError:()=>{}})},D=()=>{w(!1),E(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"lg:pb-24",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between px-4 sm:px-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h2",{className:"text-foreground text-base font-semibold",children:"Links"}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:[l.length," ",l.length===1?"item":"items"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:pe,children:[e.jsx(ue,{"aria-hidden":"true"}),e.jsx("span",{children:"Add Header"})]}),e.jsxs(v,{size:"sm",onClick:Y,children:[e.jsx(ue,{"aria-hidden":"true"}),e.jsx("span",{children:"New Link"})]})]})]}),e.jsx(Me,{sensors:fe,collisionDetection:Oe,onDragEnd:we,children:e.jsx(Ue,{items:l.map(s=>s.id),strategy:Qe,children:e.jsx("div",{className:"w-full",children:l.map(s=>e.jsx(rs,{element:s,linksDraggable:L,editing:b,showAnalytics:S,errors:g,linkAnalytics:T,inputRefs:H,imageInputRefs:M,onEditName:Z,onEditUrl:ee,onNameChange:(r,n)=>d({...r,name:n}),onUrlChange:(r,n)=>d({...r,content:n}),onNameBlur:ye,onUrlBlur:be,onDeleteLink:je,onToggleDisplay:ke,onSelectImage:_e,onUpdateImage:Ce,onRemoveImage:Ee,onToggleShowAnalytics:Ne,onToggleDownloadEnabled:Se},s.id))})})})]}),e.jsxs(W,{show:$,onClose:()=>N(!1),children:["The Snapto Free Plan allows you to create only ",O," link",O>1&&e.jsx("span",{children:"s"}),". Upgrade to the Snapto Pro Plan for only $5 per month to unlock unlimited links and much more!"]}),e.jsx(W,{show:A,onClose:()=>_(!1),children:"With the Snapto Free Plan you can only include items for download in your contact c
6ard if those items are visible on your home page. Upgrade to the Snapto Pro Plan for only $5 per month to unlock this feature and much more!"}),e.jsx(W,{show:R,onClose:()=>C(!1),children:"With the Snapto Free Plan you are not able to add images to links. Upgrade to the Snapto Pro Plan for only $5 per month to unlock images for links and much more!"}),e.jsx(Le,{open:F,onOpenChange:s=>!s&&m(!1),children:e.jsxs($e,{className:"bg-cover",style:{backgroundImage:"url('/img/confetti-background.png')"},children:[e.jsx(Ae,{children:e.jsx(Re,{className:"text-center leading-normal",children:"Success! You've created your first link."})}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm",children:"Only 2 more steps to go to start driving traffic from Instagram, Twitter, TikTok and more."}),e.jsxs("div",{className:"my-8 flex flex-col space-y-10 text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"1. Publish your profile to make it visible."}),e.jsx(v,{variant:"secondary",className:"mt-2 w-full",onClick:ge,children:"Publish Profile"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"2. Add your Snapto URL to your Instagram bio."}),e.jsx(v,{variant:"secondary",className:"mt-2 w-full",onClick:xe,children:"Add to Instagram"})]})]})]}),e.jsx(Fe,{children:e.jsx(v,{variant:"outline",className:"w-full",onClick:()=>m(!1),children:"Close"})})]})}),e.jsx(oe,{open:z,onOpenChange:s=>!s&&D(),children:e.jsxs(ne,{children:[e.jsxs(ae,{children:[e.jsx(ie,{children:"Please enter the title and URL to enable the link"}),e.jsx(le,{children:"To enable your link and display it on your Snapto profile you will need to enter the title and URL."})]}),e.jsx(de,{children:e.jsx(ce,{onClick:D,children:"Ok"})})]})}),e.jsx(oe,{open:B,onOpenChange:s=>!s&&D(),children:e.jsxs(ne,{children:[e.jsxs(ae,{children:[e.jsx(ie,{children:"Please enter the title to enable the link"}),e.jsx(le,{children:"To enable your header and display it on your Snapto profile you will need to enter the title."})]}),e.jsx(de,{children:e.jsx(ce,{onClick:D,children:"Ok"})})]})})]})}export{ws as default};
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.