PageSourceSearch

https://app.trailmory.com/_next/static/chunks/c9e77d420aaa5b63.js

js trailmory.com collected 2026-10-02 01:48:08 UTC 145,523 bytes, 30 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,431164,e=>{"use strict";var t=e.i(419915);e.s(["DEFAULT_LINK_PROPS",()=>t.a])},60611,176099,803692,528258,e=>{"use strict";var t=e.i(394298),s=e.i(993134),a=e.i(413365),r=e.i(656097),n=e.i(789320),l=e.i(237240),i=e.i(443601),o=e.i(698683),d=e.i(680735),c=e.i(672953),u=e.i(535361);function m({onLoad:e}){let{isMobile:i}=(0,r.useMediaQuery)(),{id:c}=(0,s.default)(),{data:m,isLoading:p}=(0,u.default)(c&&`/api/utm?workspaceId=${c}`,o.fetcher,{dedupingInterval:6e4}),[h,f]=(0,d.useState)(!1);return m&&m.length>0?(0,t.jsx)(a.Popover,{openPopover:h,setOpenPopover:f,side:"bottom",align:"start",onWheel:e=>{e.stopPropagation()},content:(0,t.jsx)(a.AnimatedSizeContainer,{width:!i,height:!0,children:m?(0,t.jsx)("div",{className:"text-sm",children:(0,t.jsx)("div",{className:"max-w-64",children:(0,t.jsx)(x,{data:m,onLoad:t=>{f(!1),e(t)}})})}):p?(0,t.jsx)("div",{className:"flex w-full items-center justify-center py-4 md:w-32",children:(0,t.jsx)(l.LoadingSpinner,{className:"size-4"})}):(0,t.jsx)("div",{className:"flex w-full items-center justify-center p-2 text-center text-xs text-neutral-500 md:w-32",children:"Failed to load templates"})}),children:(0,t.jsx)("div",{children:(0,t.jsx)(a.ButtonTooltip,{tabIndex:-1,tooltipProps:{content:"Load a UTM template"},className:"animate-fade-in size-6",children:(0,t.jsx)(n.DiamondTurnRight,{className:"size-4"})})})}):null}function x({data:e,onLoad:s}){let{setValue:a}=(0,c.useFormContext)();return e.length?(0,t.jsxs)("div",{className:"scrollbar-hide grid max-h-64 overflow-y-auto p-1 md:min-w-48",children:[(0,t.jsx)("span",{className:"block pb-2 pl-2.5 pt-2 text-xs font-medium text-neutral-500",children:"UTM Templates"}),e.map(e=>(0,t.jsx)(p,{template:e,onClick:()=>{let t=Object.entries(e).filter(([e])=>"ref"===e||e.startsWith("utm_")).map(([e,t])=>[e,(t||"").toString()]);t.forEach(([e,t])=>a(e,t,{shouldDirty:!0})),s(Object.fromEntries(t))}},e.id))]}):(0,t.jsx)("div",{className:"flex items-center justify-center p-3 text-center text-xs text-neutral-500",children:"No templates found"})}function p({template:e,onClick:s}){return(0,t.jsx)("div",{className:"group relative",children:(0,t.jsx)("button",{onClick:s,className:"flex w-full items-center justify-between gap-2 rounded-md p-2 text-neutral-700 outline-none hover:bg-neutral-100 focus-visible:ring-2 focus-visible:ring-neutral-500 active:bg-neutral-200 group-hover:bg-neutral-100",children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(i.Note,{className:"size-4 text-neutral-500"}),e.name]})})})}var h=e.i(283596);e.s(["constructURLFromUTMParams",()=>h.i],176099);var h=h,f=e.i(871391),g=h;e.s(["getParamsFromURL",()=>g.g],803692);var g=h,j=e.i(655693);e.i(658410);var b=e.i(535333),v=e.i(195104);let y=(0,d.forwardRef)(({_key:e,domain:s,domains:n,error:l,right:i,...o},u)=>{let m=(0,d.useId)(),{isMobile:x}=(0,r.useMediaQuery)(),p=(0,c.useFormContext)();return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("label",{htmlFor:m,className:"block text-sm font-medium text-neutral-700",children:"Destination URL"}),"_root"===e?(0,t.jsx)(v.ProBadgeTooltip,{content:(0,t.jsx)(a.SimpleTooltipContent,{title:"The URL your users will get redirected to when they visit your root domain link.",cta:"Learn more.",href:"https://trailmory.com/help/article/how-to-redirect-root-domain"})}):(0,t.jsx)(a.InfoTooltip,{content:(0,t.jsx)(a.SimpleTooltipContent,{title:"The URL your users will get redirected to when they visit your short link.",cta:"Learn more.",href:"https://trailmory.com/help/article/how-to-create-link"})})]}),i]}),(0,t.jsxs)("div",{className:"relative mt-2 flex rounded-md shadow-sm",children:[(0,t.jsx)("input",{ref:u,name:"url",id:m,placeholder:n?.find(({slug:e})=>e===s)?.placeholder||"https://trailmory.com/help/article/what-is-dub",autoFocus:!e&&!x,autoComplete:"off",className:`${l?"border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500":"border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500"} block w-full rounded-md focus:outline-none sm:text-sm`,"aria-invalid":"true",...o,...p&&{onChange:e=>{let t=e.target.value;p.setValue("url",t);let s=(0,g.g)(t);a.UTM_PARAMETERS.filter(e=>
1"ref"!==e.key).forEach(e=>p.setValue(e.key,s?.[e.key],{shouldDirty:!0}))}},onBlur:e=>{let t=(0,j.getUrlFromString)(e.target.value);t&&p.setValue("url",t.replace(/\/$/,""))}}),l&&(0,t.jsx)("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:(0,t.jsx)(b.AlertCircleFill,{className:"h-5 w-5 text-red-500","aria-hidden":"true"})})]}),l&&(0,t.jsx)("p",{className:"mt-2 text-sm text-red-600",id:"key-error",children:l})]})});var w=e.i(659903),k=e.i(865784),N=e.i(320923);let C=(e,t)=>e.sort((e,s)=>{if(t){if(e.slug===t&&s.slug!==t)return -1;if(e.slug!==t&&s.slug===t)return 1}return e.primary&&!s.primary?-1:!e.primary&&s.primary?1:e.slug.localeCompare(s.slug)});function S(e={}){let{currentDomain:t}=e,{activeWorkspaceDomains:s,activeDefaultDomains:a,allDomains:r,allWorkspaceDomains:n,loading:l,primaryDomain:i}=(0,w.default)({ignoreParams:!0,opts:e.search?{search:e.search}:void 0});return{domains:(0,d.useMemo)(()=>{if(e.onboarding)return k.DUB_DOMAINS.filter(e=>!e.archived);if(t&&!s?.find(({slug:e})=>e===t)&&!a.find(({slug:e})=>e===t)){let e=r.find(({slug:e})=>e===t);if(!e)return[...C(s||[]),...C(a,"dub.link")];let n=a.some(({id:t})=>t===e.id);return[...C(s||[]),...n?[]:[e],...C(a,"dub.link"),...n?[e]:[]]}return[...C(s||[]).map(e=>({...e,isWorkspaceDomain:!0})),...C(a,"dub.link").map(e=>({...e,isWorkspaceDomain:!1}))]},[e.onboarding,t,r,s,a]),allWorkspaceDomains:n,activeWorkspaceDomains:s,loading:!e.onboarding&&l,primaryDomain:e.onboarding?N.SHORT_DOMAIN:i}}e.s(["useAvailableDomains",()=>S],528258);let T=(0,d.memo)((0,d.forwardRef)((e,s)=>{let{control:a,setValue:r,clearErrors:n}=(0,c.useFormContext)(),{errors:l}=(0,c.useFormState)({control:a,name:["url"]}),[i,o,d]=(0,c.useWatch)({control:a,name:["domain","key","url","title","description"]}),{domains:u}=S({currentDomain:i});return(0,t.jsx)(c.Controller,{name:"url",control:a,render:({field:e})=>(0,t.jsx)(y,{ref:s,domain:i,_key:o,value:e.value,domains:u,onChange:t=>{n("url"),e.onChange(t.target.value)},required:"_root"!==o,error:l.url?.message||void 0,right:(0,t.jsx)("div",{className:"-mb-1 h-6",children:(0,f.isValidUrl)(d)&&(0,t.jsx)(m,{onLoad:e=>{r("url",(0,h.i)(d,e),{shouldDirty:!0})}})})})})}));T.displayName="LinkBuilderDestinationUrlInput",e.s(["LinkBuilderDestinationUrlInput",0,T],60611)},171845,185924,e=>{"use strict";var t=e.i(394298),s=e.i(588406),a=e.i(893239),r=e.i(753340),n=e.i(698683),l=e.i(535361),i=e.i(993134);function o({folderId:e,enabled:t=!0}){let{id:s,plan:a}=(0,i.default)(),{data:r,isValidating:o,isLoading:d}=(0,l.default)(t&&e&&"unsorted"!==e&&s&&"free"!==a?`/api/folders/${e}?workspaceId=${s}`:null,n.fetcher,{dedupingInterval:6e4,keepPreviousData:!0});return{folder:r,loading:d,isValidating:o}}e.s(["default",()=>o],185924);var d=e.i(634148),c=e.i(125047),u=e.i(524383),m=e.i(413365),x=e.i(165427),p=e.i(462861),h=e.i(520665),f=e.i(915394),g=e.i(774243),j=e.i(680735),b=e.i(72316),v=e.i(248724),y=e.i(123599);let w=()=>(0,t.jsx)("div",{className:"h-10 w-40 animate-pulse rounded-lg bg-neutral-200"});e.s(["FolderDropdown",0,({variant:e="inline",onFolderSelect:n,hideViewAll:l=!1,hideFolderIcon:k=!1,buttonClassName:N,buttonTextClassName:C,iconClassName:S,disableAutoRedirect:T=!1,selectedFolderId:L,loadingPlaceholder:D})=>{let M=(0,g.useRouter)(),{slug:P,plan:A,defaultFolderId:R}=(0,i.default)(),{searchParams:U,queryParams:I}=(0,m.useRouterStuff)(),[F,E]=(0,j.useState)(""),[B]=(0,b.useDebounce)(F,500),[z,_]=(0,j.useState)(!1),{folders:$,loading:O}=(0,d.default)({query:z?{search:B}:void 0,options:{keepPreviousData:!0}});(0,j.useEffect)(()=>{$&&!z&&$.length>=u.FOLDERS_MAX_PAGE_SIZE&&_(!0)},[$,z]);let{data:V}=(0,c.default)({query:{groupBy:"folderId"},ignoreParams:!0}
1),[W,q]=(0,j.useState)(!1),[Q,G]=(0,j.useState)(s.unsortedLinks),{folderId:H}=(0,r.default)(),K=L||H,{folder:Y}=o({folderId:K,enabled:!!K}),{AddFolderModal:X,setShowAddFolderModal:Z}=(0,v.useAddFolderModal)({onSuccess:e=>{G(e),n?.(e),T||M.push(`/${P}/links${K&&"unsorted"!==K?`?folderId=${e.id}`:""}`)}});(0,j.useEffect)(()=>{Y&&K===Y.id?(G(Y),n?.(Y)):K&&"unsorted"!==K||(G(s.unsortedLinks),n?.(s.unsortedLinks))},[K,Y]);let{canAddFolder:J}=(0,a.getPlanCapabilities)(A),ee=(0,j.useMemo)(()=>{let e=[s.unsortedLinks,...$||[],...!Y||B||$?.find(({id:e})=>e===Y.id)?[]:[Y]];return K&&M.prefetch(`/${P}/links?folderId=${K}`),[...e.map(e=>({value:e.id,label:e.name,icon:(0,t.jsx)(y.FolderIcon,{className:"mr-1",folder:e,shape:"square"}),meta:{...e,linksCount:V?.find(({folderId:t})=>t===e.id||"unsorted"===e.id&&null===t)?._count||0},first:"unsorted"===e.id})),{value:"create",label:"Create new folder",icon:(0,t.jsx)(y.FolderIcon,{className:"mr-1",folder:{id:"new",accessLevel:null},shape:"square"}),disabledTooltip:J?void 0:(0,t.jsx)(m.TooltipContent,{title:"You can only use Link Folders on a Pro plan and above. Upgrade to Pro to continue.",cta:"Upgrade to Pro",href:`/${P}/upgrade`})}]},[$,Y,J,P,B]),et=(0,j.useMemo)(()=>Q?{value:Q.id,label:Q.name,icon:(0,t.jsx)(y.FolderIcon,{className:"mr-1",folder:Q,shape:"square"}),meta:Q}:null,[Q]);return K&&"unsorted"!==K&&!Y?D??(0,t.jsx)(w,{}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(X,{}),(0,t.jsx)(m.Combobox,{selected:et,setSelected:e=>{if(e?.value==="create")return void Z(!0);let t=e?.meta;t&&(G(t),n?n(t):I({..."unsorted"===t.id&&!R?{del:"folderId"}:{set:{folderId:t.id}}}))},inputRight:l?void 0:(0,t.jsx)(f.default,{href:`/${P}/settings/library/folders`,onClick:()=>q(!1),className:"rounded-md border border-neutral-200 px-2 py-1 text-xs transition-colors hover:bg-neutral-100",children:"View All"}),options:O?void 0:ee,icon:!(Q?.id==="unsorted"&&k)&&Q?(0,t.jsx)(y.FolderIcon,{folder:Q,shape:"square",className:"hidden md:block",iconClassName:S}):void 0,optionRight:e=>e.meta&&e.meta.linksCount?(0,t.jsx)("span",{className:"text-xs text-neutral-500",children:"mega"===e.meta.type?"10,000+":(0,p.nFormatter)(e.meta.linksCount,{full:!0})}):void 0,caret:(0,t.jsx)(h.ChevronsUpDown,{className:"ml-2 size-4 shrink-0 text-neutral-400"}),buttonProps:{className:(0,x.cn)("group flex items-center gap-2 rounded-lg px-2 py-1 w-fit","inline"===e&&"border-none !ring-0 bg-transparent","transition-all hover:bg-neutral-100 active:bg-neutral-200 data-[state=open]:bg-neutral-100",N),textWrapperClassName:(0,x.cn)("min-w-0 truncate text-left text-lg font-semibold leading-7 text-content-emphasis",C)},optionClassName:"md:min-w-[250px]",searchPlaceholder:"Search folders...",matchTriggerWidth:"input"===e,emptyState:(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-2 py-4",children:["No folders found",(0,t.jsx)(m.Button,{onClick:()=>{q(!1),Z(!0)},variant:"primary",className:"h-7 w-fit px-2",disabledTooltip:J?void 0:(0,t.jsx)(m.TooltipContent,{title:"You can only use Link Folders on a Pro plan and above. Upgrade to Pro to continue.",cta:"Upgrade to Pro",href:`/${P}/upgrade`}),text:"Create folder"})]}),open:W,onOpenChange:q,shouldFilter:!z,onSearchChange:E,children:Q?Q.name:"Links"})]})}],171845)},803805,e=>{"use strict";var t=e.i(394298),s=e.i(171845),a=e.i(413365),r=e.i(672953);function n(){let{setValue:e}=(0,r.useFormContext)(),n=(0,r.useWatch)({name:"folderId"});return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"mb-1 flex items-center gap-2",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-neutral-700",children:"Folder"}),(0,t.jsx)(a.InfoTooltip,{content:(0,t.jsx)(a.SimpleTooltipContent,{title:"Use folders to organize and manage access to your links.",cta:"Learn more",href:"https://trailmory.com/help/article/link-folders"})})]}),(0,t.jsx)(s.FolderDropdown,{variant:"input",hideViewAll:!0,disableAutoRedirect:!0,onFolderSelect:t=>{e("folderId","unsorted"===t.id?null:t.id,{shouldDirty:!0})},buttonClassName:"w-full min-w-0 bg-transparent h-10 md:h-8 md:pl-1 rounded-md",buttonTextClassName:"text-sm md:text-sm font-medium",iconClassName:"size-3",selectedFolderId:n??void 0,loadingPlaceholder:(0,t.jsx)("div",{className:"my-px h-10 w-full animate-pulse rounded-lg bg-neutral-200 md:h-8"})})]})}e.s(["LinkBuilderFolderSelector",()=>n])},43567,e=>{"use strict";var t=e.i(217932),s=e.i(875242),a=e.i(452947),r=e.i(666396);let n=s.default.object({id:s.default.string().describe("The ID of the registered domain record."),autoRenewalDisabledAt:s.default.date().nullable().describe("The date the domain auto-renew is disabled."),createdAt:s.default.date().describe("The date the domain was created."),expiresAt:s.default.date().describe("The date the domain expires."),renewalFee:s.default.number().describe("The fee to renew the domain.")}
1);s.default.object({id:s.default.string().describe("The unique identifier of the domain."),slug:s.default.string().describe("The domain name.").openapi({example:"acme.com"}),verified:s.default.boolean().default(!1).describe("Whether the domain is verified."),primary:s.default.boolean().default(!1).describe("Whether the domain is the primary domain for the workspace."),archived:s.default.boolean().describe("Whether the domain is archived.").default(!1),placeholder:s.default.string().nullable().describe("Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened.").openapi({example:"https://trailmory.com/help/article/what-is-dub"}),expiredUrl:s.default.string().nullable().describe("The URL to redirect to when a link under this domain has expired.").openapi({example:"https://acme.com/expired"}),notFoundUrl:s.default.string().nullable().describe("The URL to redirect to when a link under this domain doesn't exist.").openapi({example:"https://acme.com/not-found"}),logo:s.default.string().nullable().describe("The logo of the domain."),assetLinks:s.default.string().nullable().default(null).describe("assetLinks.json configuration file (for deep link support on Android)."),appleAppSiteAssociation:s.default.string().nullable().default(null).describe("apple-app-site-association configuration file (for deep link support on iOS)."),createdAt:s.default.date().describe("The date the domain was created."),updatedAt:s.default.date().describe("The date the domain was last updated."),registeredDomain:n.nullable().describe("The registered domain record.")});let l=s.default.object({archived:a.booleanQuerySchema.optional().default(!1).describe("Whether to include archived domains in the response. Defaults to `false` if not provided."),search:s.default.string().optional().describe("The search term to filter the domains by.")}).merge((0,a.getPaginationQuerySchema)({pageSize:50}));l.merge(s.default.object({includeLink:a.booleanQuerySchema.default(!1)})),l.omit({page:!0}),l.pick({search:!0});let i=s.default.object({slug:s.default.string({error:"slug is required"}).min(1,"slug cannot be empty.").max(190,"slug cannot be longer than 190 characters.").trim().describe("Name of the domain.").openapi({example:"acme.com"}),expiredUrl:(0,r.parseUrlSchemaAllowEmpty)({trim:!0}).nullish().transform(e=>e||null).describe("Redirect users to a specific URL when any link under this domain has expired.").openapi({example:"https://acme.com/expired"}),notFoundUrl:(0,r.parseUrlSchemaAllowEmpty)({trim:!0}).nullish().transform(e=>e||null).describe("Redirect users to a specific URL when a link under this domain doesn't exist.").openapi({example:"https://acme.com/not-found"}),archived:s.default.boolean().optional().default(!1).describe("Whether to archive this domain. `false` will unarchive a previously archived domain.").openapi({example:!1}),placeholder:(0,r.parseUrlSchemaAllowEmpty)({maxLength:100,trim:!0}).nullish().transform(e=>e||null).describe("Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened.").openapi({example:"https://trailmory.com/help/article/what-is-dub"}),logo:a.uploadedImageSchema.nullish().describe("The logo of the domain."),assetLinks:s.default.string().nullish().describe("assetLinks.json configuration file (for deep link support on Android)."),appleAppSiteAssociation:s.default.string().nullish().describe("apple-app-site-association configuration file (for deep link support on iOS).")});i.extend({deepviewData:s.default.string().nullish()}),i.partial(),s.default.object({newWorkspaceId:s.default.string({error:"New workspace ID is required."}).min(1,"New workspace ID cannot be empty.").transform(e=>(0,t.normalizeWorkspaceId)(e)).describe("The ID of the new workspace to transfer the domain to.")}),s.default.object({domain:s.default.string().min(1,"Domain to register is required.").endsWith(".link").transform(e=>e.toLowerCase()).describe("The domain to claim. We only support .link domains for now.").openapi({example:"acme.link"})}),s.default.object({domains:s.default.union([s.default.string(),s.default.array(s.default.string())]).transform(e=>Array.isArray(e)?e:e.split(",")).transform(e=>e.map(e=>e.toLowerCase()).filter(e=>e.endsWith(".link"))).describe("The domains to search. We only support .link domains for now.").openapi({param:{style:"form",explode:!1},anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]})}),s.default.object({domain:s.default.string().describe("The domain name."),available:s.default.boolean().describe("Whether the domain is available."),price:s.default.string().nullable().describe("The price description."),premium:s.default.boolean().nullable().describe("Whether the domain is a premium domain.")}
1),s.default.object({domain:s.default.string().describe("The domain name."),status:s.default.string().describe("The status of the domain registration."),expiration:s.default.number().describe("The expiration timestamp of the domain (Unix timestamp in milliseconds).").nullable()}),e.s(["DOMAINS_MAX_PAGE_SIZE",0,50])},643790,248427,928818,766073,e=>{"use strict";var t=e.i(394298),s=e.i(993134),a=e.i(43567),r=e.i(413365),n=e.i(850195),l=e.i(446987);e.s(["LinkedIn",()=>l.B],248427);var l=l,i=e.i(173173),o=e.i(500107),d=e.i(992039),c=l;e.s(["Twitter",()=>c.G],928818);var c=l,u=e.i(165427),m=e.i(865784),x=e.i(501244),p=e.i(812094),h=e.i(291942),f=e.i(795455),g=e.i(280986),j=e.i(433295),b=e.i(435524),v=e.i(88508),v=v,y=e.i(774243),w=e.i(807166),k=e.i(680735),N=e.i(994955),C=e.i(72316),S=e.i(747821),T=e.i(734158);let L=({showModal:e,setShowModal:s})=>{let{queryParams:a}=(0,r.useRouterStuff)();return(0,t.jsxs)(r.Modal,{showModal:e,setShowModal:s,drawerRootProps:{repositionInputs:!1},children:[(0,t.jsx)("h3",{className:"border-b border-neutral-200 px-4 py-4 text-lg font-medium sm:px-6",children:"Claim .link domain"}),(0,t.jsx)("div",{className:"scrollbar-hide mt-6 max-h-[calc(100dvh-200px)] overflow-auto overflow-y-scroll",children:(0,t.jsx)(T.RegisterDomainForm,{variant:"modal",onSuccess:e=>{s(!1),a({set:{registered:e.toLowerCase()}})},onCancel:()=>s(!1)})})]})};function D(){let[e,s]=(0,k.useState)(!1),a=(0,k.useCallback)(()=>(0,t.jsx)(L,{showModal:e,setShowModal:s}),[e,s]);return(0,k.useMemo)(()=>({setShowRegisterDomainModal:s,RegisterDomainModal:a}),[s,a])}e.s(["useRegisterDomainModal",()=>D],766073),e.i(658410);var M=e.i(434016);function P(){let{id:e}=(0,s.default)(),[a,n]=(0,r.useLocalStorage)(`show-free-dot-link-banner:${e}`,!0),{RegisterDomainModal:l,setShowRegisterDomainModal:i}
1=D();return a&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l,{}),(0,t.jsxs)("div",{className:"relative isolate flex flex-col justify-between gap-3 overflow-hidden rounded-lg border border-green-600/15 bg-gradient-to-r from-lime-100/80 to-emerald-100/80 py-3 pl-4 pr-12 sm:flex-row sm:items-center sm:py-2",children:[(0,t.jsx)(r.Grid,{cellSize:13,patternOffset:[0,-1],className:"text-black/30 mix-blend-overlay [mask-image:linear-gradient(to_right,black,transparent)] md:[mask-image:linear-gradient(to_right,black_60%,transparent)]"}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"hidden rounded-full border border-green-600/50 bg-white/50 p-1 shadow-[inset_0_0_1px_1px_#fff] sm:block",children:(0,t.jsx)(S.LinkBroken,{className:"m-px size-4 text-green-800"})}),(0,t.jsxs)("p",{className:"text-sm text-neutral-900",children:["Claim a free ",(0,t.jsx)("span",{className:"font-semibold",children:".link"})," domain, free for 1 year."," ",(0,t.jsx)("a",{href:"https://trailmory.com/help/article/free-dot-link-domain",target:"_blank",className:"text-neutral-700 underline transition-colors hover:text-black",children:"Learn more"})]})]}),(0,t.jsx)("div",{className:"flex items-center sm:-my-1",children:(0,t.jsx)("button",{type:"button",className:"whitespace-nowrap rounded-md border border-green-700/50 px-3 py-1 text-sm text-neutral-800 transition-colors hover:bg-green-500/10",onClick:()=>i(!0),children:"Claim Domain"})}),(0,t.jsx)("button",{type:"button",className:"absolute inset-y-0 right-2.5 p-1 text-sm text-green-700 underline transition-colors hover:text-green-900",onClick:()=>n(!1),children:(0,t.jsx)(M.X,{className:"size-[18px]"})})]})]})}var A=e.i(535333),R=e.i(378944),R=R,U=e.i(709697),I=e.i(528258);let F=(0,k.forwardRef)(({domain:e,_key:a,existingLinkProps:n,error:m,onChange:x,data:p,saving:y,loading:S,onboarding:T,...L},D)=>{let M=!!n,I=(0,k.useId)(),F=(0,k.useMemo)(()=>(0,f.nanoid)(8),[]),{id:z,slug:_,mutate:$,exceededAI:O,nextPlan:V,dotLinkClaimed:W}=(0,s.default)(),[q,Q]=(0,k.useState)(M),[G,H]=(0,k.useState)(!1),[K,Y]=(0,k.useState)(null),X=K||m,Z=async()=>{Y(null),H(!0);let t=await fetch(`/api/links/random?domain=${e}&workspaceId=${z}`),s=await t.json();x?.({key:s}),H(!1)},[J,ee]=(0,k.useState)(!1);(0,k.useEffect)(()=>{!e||a||J||Z()},[e,a,J]);let et=async t=>{let s=await fetch(`/api/links/exists?domain=${e}&key=${t}&workspaceId=${z}`),{error:a}=await s.json();a?Y(a.message):Y(null)},[es]=(0,C.useDebounce)(a,500);(0,k.useEffect)(()=>{es&&z&&!M&&et(es)},[es,z,M]);let[ea,er]=(0,k.useState)(M&&a?[a]:[]),{completion:en,isLoading:el,complete:ei}=(0,b.useCompletion)({api:`/api/ai/completion?workspaceId=${z}`,onError:e=>{e.message.includes("Upgrade to Pro")?N.toast.custom(()=>(0,t.jsx)(U.UpgradeRequiredToast,{title:"You've exceeded your AI usage limit",message:e.message})):N.toast.error(e.message)},onFinish:(e,t)=>{er(e=>[...e,t]),$(),w.default.capture("ai_key_generated",{key:t,url:p.url})}});(0,k.useEffect)(()=>{en&&x?.({key:en})},[en]);let eo=(0,k.useCallback)(async()=>{Y(null),ei(`For the following URL, suggest a relevant short link slug that is at most ${Math.max(25-(e?.length||0),12)} characters long. 
2                  
3            - URL: ${p.url}
4            - Meta title: ${p.title}
5            - Meta description: ${p.description}. 
6    
7          Only respond with the short link slug and nothing else. Don't use quotation marks or special characters (dash and slash are allowed).
8          
9          Make sure your answer does not exist in this list of generated slugs: ${ea.join(", ")}`)},[p.url,p.title,p.description,ea]),ed=(0,k.useMemo)(()=>(0,h.linkConstructor)({key:a,domain:e,pretty:!0}),[a,e]);return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("label",{htmlFor:I,className:"block text-sm font-medium text-neutral-700",children:"Short Link"}),q?(0,t.jsx)("button",{className:"flex h-6 items-center space-x-2 text-sm text-neutral-500 transition-all duration-75 hover:text-black active:scale-95",type:"button",onClick:()=>{window.confirm("Editing an existing short link could potentially break existing links. Are you sure you want to continue?")&&Q(!1)},children:(0,t.jsx)(d.PenWriting,{className:"size-3.5"})}):(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(r.ButtonTooltip,{tabIndex:-1,tooltipProps:{content:"Generate a random key"},onClick:Z,disabled:G||el,children:G?(0,t.jsx)(i.LoadingCircle,{}):(0,t.jsx)(R.default,{className:"h-3 w-3"})}),(0,t.jsx)(r.ButtonTooltip,{tabIndex:-1,tooltipProps:{content:O?"You've exceeded your AI usage limit.":p.url?"Generate a key using AI.":"Enter a URL to generate a key using AI."},onClick:eo,disabled:G||el||O||!p.url,children:el?(0,t.jsx)(i.LoadingCircle,{}):(0,t.jsx)(o.Magic,{className:"h-4 w-4"})})]})]}),(0,t.jsxs)("div",{className:"relative mt-1 flex rounded-md shadow-sm",children:[(0,t.jsx)("div",{className:"z-[1]",children:(0,t.jsx)(B,{domain:e,setDomain:e=>{Y(null),x?.({domain:e})},loading:S})}),(0,t.jsx)("input",{ref:D,type:"text",name:"key",id:I,pattern:"[\\p{L}\\p{N}\\p{Pd}\\/\\p{Emoji}_.]+",onInvalid:e=>
9{e.currentTarget.setCustomValidity("Only letters, numbers, '-', '_', '/', and emojis are allowed.")},onFocus:()=>ee(!0),onBlur:()=>ee(!1),disabled:q,autoComplete:"off",autoCapitalize:"none",className:(0,u.cn)("block w-full rounded-r-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm","z-0 focus:z-[1]",{"border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500":X,"border-amber-300 pr-10 text-amber-900 placeholder-amber-300 focus:border-amber-500 focus:ring-amber-500":ed.length>25,"cursor-not-allowed border border-neutral-300 bg-neutral-100 text-neutral-500":q}),placeholder:"(optional)","aria-invalid":"true","aria-describedby":"key-error",value:(0,g.punycode)(a),onChange:e=>{Y(null),e.currentTarget.setCustomValidity(""),x?.({key:e.target.value})},...L}),(X||ed.length>25)&&(0,t.jsx)(r.Tooltip,{content:X||(0,t.jsxs)("div",{className:"flex max-w-xs items-start space-x-2 bg-white p-4",children:[(0,t.jsx)(v.default,{className:"mt-0.5 h-4 w-4 flex-none text-amber-500"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm text-neutral-700",children:"Short links longer than 25 characters will show up differently on some platforms."}),(0,t.jsxs)("div",{className:"mt-2 flex items-center space-x-2",children:[(0,t.jsx)(l.B,{className:"h-4 w-4"}),(0,t.jsx)("p",{className:"cursor-pointer text-sm font-semibold text-[#4783cf] hover:underline",children:(0,h.linkConstructor)({domain:"lnkd.in",key:F,pretty:!0})})]}),ed.length>25&&(0,t.jsxs)("div",{className:"mt-1 flex items-center space-x-2",children:[(0,t.jsx)(c.G,{className:"h-4 w-4"}),(0,t.jsx)("p",{className:"cursor-pointer text-sm text-[#34a2f1] hover:underline",children:(0,j.truncate)(ed,25)})]})]})]}),children:(0,t.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3",children:X?(0,t.jsx)(A.AlertCircleFill,{className:"h-5 w-5 text-red-500","aria-hidden":"true"}):ed.length>25?(0,t.jsx)(A.AlertCircleFill,{className:"h-5 w-5 text-amber-500"}):null})})]}),X?X.includes("Upgrade to")?(0,t.jsxs)("p",{className:"mt-2 text-sm text-red-600",id:"key-error",children:[X.split(`Upgrade to ${V.name}`)[0],(0,t.jsxs)("a",{className:"cursor-pointer underline",href:`/${_}/upgrade`,target:"_blank",children:["Upgrade to ",V.name]}),X.split(`Upgrade to ${V.name}`)[1]]}):(0,t.jsx)("p",{className:"mt-2 text-sm text-red-600",id:"key-error",children:X}):(0,t.jsx)(E,{domain:e,url:p.url,onChange:e=>x({domain:e})}),!T&&!W&&(0,t.jsx)(r.AnimatedSizeContainer,{height:!0,transition:{ease:"linear",duration:.1},className:"mt-2",children:(0,t.jsx)(P,{})})]})});function E({domain:e,url:s,onChange:a}){if(!s||!e)return null;let r=(0,p.getDomainWithoutWWW)(s),l=(0,x.getApexDomain)(s),i=m.DUB_DOMAINS.find(e=>!!e?.allowedHostnames&&(r&&e.allowedHostnames.includes(r)||e.allowedHostnames.includes(l))),o=i?.slug;return o&&e!==o?(0,t.jsxs)("button",{className:"flex items-center gap-1 p-2 text-xs text-neutral-500 transition-all duration-75 hover:text-neutral-700 active:scale-[0.98]",onClick:()=>a(o),type:"button",children:[(0,t.jsx)(n.ArrowTurnRight2,{className:"size-3.5"}),(0,t.jsxs)("p",{children:["Use ",(0,t.jsx)("strong",{className:"font-semibold",children:o})," domain instead?"]})]}):null}function B({domain:e,setDomain:s,loading:n}){let[l,i]=(0,k.useState)(""),[o]=(0,C.useDebounce)(l,500),[d,c]=(0,k.useState)(!1),{domains:m,allWorkspaceDomains:x,activeWorkspaceDomains:p,loading:h}=(0,I.useAvailableDomains)({search:d?o:void 0});(0,k.useEffect)(()=>{x&&!d&&x.length>=a.DOMAINS_MAX_PAGE_SIZE&&c(!0)},[x,d]);let[f,j]=(0,k.useState)(!1),{link:b}=(0,y.useParams)(),v=(0,y.usePathname)();(0,r.useKeyboardShortcut)("d",()=>j(!0),{modal:!b&&!v.startsWith("/onboarding")});let w=(0,k.useMemo)(()=>h?void 0:m?.reduce((e,{slug:t},s)=>(e.push({value:t,label:(0,g.punycode)(t),separatorAfter:p?.some(e=>e.slug===t)&&s===p.length-1}),e),[]),[h,m,p]);return(0,t.jsx)(r.Combobox,{selected:e&&!n?{value:e,label:(0,g.punycode)(e)}:null,setSelected:e=>{e&&s(e.value)},options:w,caret:!0,placeholder:(0,t.jsx)("div",{className:"h-4 w-3/4 animate-pulse rounded bg-neutral-200"}),searchPlaceholder:"Search domains...",shortcutHint:"D",buttonProps:{className:(0,u.cn)("w-32 sm:w-40 h-full rounded-r-none border-r-transparent justify-start px-2.5","data-[state=open]:ring-1 data-[state=open]:ring-neutral-500 data-[state=open]:border-neutral-500","focus:ring-1 focus:ring-neutral-500 focus:border-neutral-500 transition-none")},optionClassName:"sm:max-w-[225px]",shouldFilter:!d,open:f,onOpenChange:j,onSearchChange:i})}e.s(["ShortLinkInput",0,F],643790)},998255,203654,714608,962756,287247,495543,208543,843603,722725,735657,633923,996990,314259,671136,280230,602400,e=>{"use strict";var t=e.i(394298),s=e.i(993134),a=e.i(60611),r=e.i(803805),n=e.i(680735),l=e.i(672953),i=e.i(643790),o=e.i(528258),d=e.i(431164);let c=(0,n.createContext)(null);function u(){let e=(0,n.useContext)(c);if(!e)throw Error("useLinkBuilderContext must be used within a LinkBuilderProvider");return e}function m({children:e,...s}){let{plan:a,conversionEnabled:r}=s.workspace||{}
9,[i,o]=(0,n.useState)(!!s.props),u=(0,l.useForm)({defaultValues:s.props||s.duplicateProps||{...d.DEFAULT_LINK_PROPS,trackConversion:a&&"free"!==a&&"pro"!==a&&r||!1}});return(0,t.jsx)(c.Provider,{value:{...s,generatingMetatags:i,setGeneratingMetatags:o},children:(0,t.jsx)(l.FormProvider,{...u,children:e})})}e.s(["LinkBuilderProvider",()=>m,"useLinkBuilderContext",()=>u],203654);let x=(0,n.memo)((0,n.forwardRef)((e,s)=>{let{props:a}=u(),{control:r,setValue:n,clearErrors:d}=(0,l.useFormContext)(),{errors:c,isSubmitting:m,isSubmitSuccessful:x}=(0,l.useFormState)({control:r,name:["key"]}),[p,h,f,g,j]=(0,l.useWatch)({control:r,name:["domain","key","url","title","description"]}),{loading:b}=(0,o.useAvailableDomains)({currentDomain:p});return"_root"!==h?(0,t.jsx)(i.ShortLinkInput,{ref:s,domain:p,_key:h,existingLinkProps:a,error:c.key?.message||void 0,onChange:e=>{d("key"),void 0!==e.domain&&n("domain",e.domain,{shouldDirty:!0}),void 0!==e.key&&n("key",e.key,{shouldDirty:!0})},data:{url:f,title:g,description:j},saving:m||x,loading:b}):null}));x.displayName="LinkBuilderShortLinkInput",e.s(["LinkBuilderShortLinkInput",0,x],714608);var p=e.i(413365),h=e.i(517972);let f=(0,n.memo)(()=>{let{handleKeyDown:e}=(0,p.useEnterSubmit)();return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("label",{htmlFor:"comments",className:"block text-sm font-medium text-neutral-700",children:"Comments"}),(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Use comments to add context to your short links – for you and your team.",cta:"Learn more.",href:"https://trailmory.com/help/article/link-comments"})})]}),(0,t.jsx)(l.Controller,{name:"comments",render:({field:s})=>(0,t.jsx)(h.default,{id:"comments",name:"comments",minRows:3,className:"mt-2 block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",placeholder:"Add comments",value:s.value??"",onChange:e=>s.onChange(e.target.value),onKeyDown:e})})]})});f.displayName="LinkCommentsInput",e.s(["LinkCommentsInput",0,f],962756);var g=e.i(141987),j=e.i(446987),j=j;let b=(...e)=>{let{modal:t}=u();(0,p.useKeyboardShortcut)(e[0],e[1],{modal:t,...e[2]})},v=new Date().getTime()-new Date("2025-01-13").getTime()<2592e6,y=(0,n.memo)(()=>{let{slug:e,plan:a}=(0,s.default)(),{control:r,setValue:n}=(0,l.useFormContext)(),i=!!a&&"free"!==a&&"pro"!==a,[o,d]=(0,l.useWatch)({control:r,name:["trackConversion","testVariants"]});return b("c",()=>n("trackConversion",!o,{shouldDirty:!0}),{enabled:i}),(0,t.jsxs)("label",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[v&&(0,t.jsx)("div",{className:"rounded-full border border-green-200 bg-green-100 px-2 py-0.5 text-[0.625rem] uppercase leading-none text-green-900",children:"New"}),(0,t.jsxs)("span",{className:"flex select-none items-center gap-1 text-sm font-medium text-neutral-700",children:["Conversion Tracking",(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"View analytics on conversions from your short links.",cta:"Learn more.",href:"https://trailmory.com/docs/conversions/quickstart"})})]})]}),(0,t.jsx)(p.Switch,{checked:o,fn:e=>n("trackConversion",e,{shouldDirty:!0}),disabledTooltip:o&&d?(0,t.jsx)(p.TooltipContent,{title:"Conversion tracking must be enabled to use A/B testing."}):i?void 0:(0,t.jsx)(p.TooltipContent,{title:"Conversion tracking is only available on Business plans and above.",cta:"Upgrade to Business",href:e?`/${e}/upgrade`:"https://trailmory.com/pricing",target:"_blank"}),thumbIcon:o&&d?(0,t.jsx)("span",{className:"flex size-full items-center justify-center",children:(0,t.jsx)(j.jc,{className:"size-2 text-blue-500"})}):i?void 0:(0,t.jsx)(g.CrownSmall,{className:"size-full text-neutral-500"})})]})});e.s(["ConversionTrackingToggle",0,y],287247);var w=e.i(100217),k=e.i(656097),N=e.i(21432),C=e.i(8917),S=e.i(173173),T=e.i(296527),L=e.i(165427),D=e.i(795455),M=e.i(280986),P=e.i(581857),A=e.i(433295),R=e.i(914968),U=e.i(994955),I=e.i(72316);let F=(0,n.forwardRef)(({props:e,workspaceId:s},a)=>{let{isMobile:r}=(0,k.useMediaQuery)(),{watch:i,getValues:o,setValue:d,formState:{isDirty:c}}
9=(0,l.useFormContext)(),[u,m]=(0,n.useState)(()=>(0,D.nanoid)()),[x,h]=(0,n.useState)(!1),[f,g]=(0,n.useState)(!1),[j,b]=(0,n.useState)(!1),{drafts:v,saveDraft:y,removeDraft:T}=function({linkId:e,workspaceId:t}){let[s,a]=(0,p.useLocalStorage)(`link-drafts:${t}`,[]),r=(0,n.useCallback)(()=>{a(s.filter(e=>e.timestamp>(0,w.subDays)(new Date,7).getTime()).sort((e,t)=>t.timestamp-e.timestamp).slice(0,10))},[s]);return(0,n.useLayoutEffect)(()=>{Array.isArray(s)?r():a([])},[]),{drafts:(0,n.useMemo)(()=>e?s.filter(t=>t.link.id===e):s.filter(e=>!e.link.id),[s,e]),saveDraft:(e,t)=>{a([...s.filter(t=>t.id!==e),{id:e,link:t,timestamp:new Date().getTime()}])},removeDraft:e=>{a(s.filter(t=>t.id!==e))}}}({linkId:e?.id,workspaceId:s}),M=(0,n.useMemo)(()=>v.filter(e=>e.id!==u),[v,u]),P=(0,I.useDebouncedCallback)(()=>{y(u,o()),h(!1),g(!0)},1e3);return(0,n.useEffect)(()=>{let{unsubscribe:e}=i(()=>{let[e,t]=o(["url","key"]);(e||t)&&c&&(h(!0),P())});return()=>e()},[i,c]),(0,n.useImperativeHandle)(a,()=>({onSubmitSuccessful(){T(u)},onClose(){let[e,t]=o(["url","key"]);(e||t)&&c&&y(u,o())}}),[u,c]),c&&f||M.length>0?(0,t.jsx)(p.Popover,{content:(0,t.jsxs)("div",{className:"w-full min-w-36 px-1 py-1 sm:w-auto",children:[M.length>0?(0,t.jsx)("span",{className:"block pb-2 pl-2.5 pt-2 text-xs font-medium text-neutral-500",children:"Restore drafts"}):(0,t.jsxs)("span",{className:"flex gap-1 px-2.5 pb-2 pt-2 text-xs text-neutral-500",children:[(0,t.jsx)(C.CircleInfo,{className:"size-3.5"}),"Your drafts will appear here"]}),M.length>0&&(0,t.jsx)(p.AnimatedSizeContainer,{width:!r,height:!0,children:(0,t.jsx)("ul",{className:"scrollbar-hide grid max-h-40 overflow-y-auto",children:M.map(e=>(0,t.jsx)(E,{draft:e,onSelect:()=>{m(e.id),b(!1),Object.entries(e.link).forEach(([e,t])=>{d(e,t,{shouldDirty:!0})}),U.toast.success("Draft restored!")},onDelete:()=>T(e.id)},e.id))})})]}),align:"end",onWheel:e=>{e.stopPropagation()},openPopover:j,setOpenPopover:b,children:(0,t.jsx)(p.Button,{type:"button",variant:"outline",className:(0,L.cn)("animate-fade-in group h-7 w-fit text-sm transition-colors data-[state=open]:bg-neutral-100",c&&f?"pl-3 pr-4 text-neutral-400 hover:text-neutral-600":"pl-4 pr-3 text-neutral-500 hover:text-neutral-700"),text:c&&f?(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[x?(0,t.jsx)(S.LoadingCircle,{className:"size-3.5"}):(0,t.jsx)(N.CircleCheck,{className:"size-3.5"}),x?"Saving...":"Draft saved"]}):M.length>0?(0,t.jsxs)("div",{className:"flex items-center justify-end gap-1",children:["Drafts",(0,t.jsx)(R.ChevronDown,{className:"size-3.5 transition-transform duration-75 group-data-[state=open]:rotate-180"})]}):null})}):null});function E({draft:e,onSelect:s,onDelete:a}){let{isMobile:r}=(0,k.useMediaQuery)(),l=(0,n.useMemo)(()=>(0,P.timeAgo)(new Date(e.timestamp),{withAgo:!r}),[e.timestamp,r]);return(0,t.jsxs)("li",{role:"button",className:"group flex items-center justify-between gap-2 overflow-hidden rounded py-1.5 pl-2 pr-1.5 text-sm transition-colors hover:bg-neutral-100 sm:gap-1",onClick:()=>{s()},children:[(0,t.jsxs)("div",{className:"flex min-w-0 grow items-center justify-between gap-4 sm:gap-8",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 sm:gap-2.5",children:[(0,t.jsx)(B,{className:"size-3.5 shrink-0 text-neutral-400"}),(0,t.jsxs)("span",{className:"min-w-0 max-w-40 truncate text-neutral-800",children:[(0,A.truncate)((0,M.punycode)(e.link.domain),16),"/",e.link.key?(0,M.punycode)(e.link.key):(0,t.jsx)("span",{className:"text-neutral-400",children:"(link)"})]})]}),(0,t.jsx)("span",{className:"whitespace-nowrap text-xs text-neutral-500",children:l})]}),(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),window.confirm("Are you sure you want to delete this draft?")&&a()},className:"p-1 text-neutral-400 transition-colors hover:text-neutral-500",title:"Delete draft",children:(0,t.jsx)(T.Xmark,{className:"size-3.5"})})]},e.id)}function B(e){return(0,t.jsx)("svg",{height:"18",width:"18",viewBox:"0 0 18 18",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,t.jsxs)("g",{fill:"currentColor",children:[(0,t.jsx)("polyline",{fill:"none",points:"9 4.75 9 9 12.25 11.25",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"}),(0,t.jsxs)("g",{className:"origin-center group-hover:rotate-[360deg] group-hover:transition-transform group-hover:duration-500",children:[(0,t.jsx)("polyline",{fill:"none",points:"1.88 14.695 2.288 11.75 5.232 12.157",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"}),(0,t.jsx)("path",{d:"M1.75,9C1.75,4.996,4.996,1.75,9,1.75s7.25,3.246,7.25,7.25-3.246,7.25-7.25,7.25c-3.031,0-5.627-1.86-6.71-4.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})]})]})})}e.s(["DraftControls",0,F],495543);var z=e.i(588406),_=e.i(893239),$=e.i(185924),O=e.i(338401),V=e.i(123599),W=e.i(501244),q=e.i(253660),Q=e.i(673225),G=e.i(291942),H=e.i(35041),K=e.i(977967),Y=e.i(915394);function X({onClose:e,onSelectLink:s,children:a,className:r}){let{props:i,workspace:o}=u(),{isDirty:d}=(0,l.useFormState)(),[c,m,x,h]=(0,l.useWatch)({name:["url","key","domain","folderId"]}),[f]=(0,I.useDebounce)((0,Q.getUrlWithoutUTMParams)(c),500),g=(0,n.useMemo)(()=>(0,G.linkConstructor)({key:m,domain:x,pretty:!0}),[m,x]),{canAddFolder:j}=(0,_.getPlanCapabilities)(o.plan),{folder:b,loading:v}=(0,$.default)({folderId:h,enabled:!!h}),y=(0,n.useMemo)(()=>
9{if(h&&"unsorted"!==h&&b?.id!==h)return(0,t.jsx)("div",{className:"h-7 w-24 animate-pulse rounded-md bg-neutral-200"});let e=h&&"unsorted"!==h?b??z.unsortedLinks:z.unsortedLinks;return(0,t.jsxs)(t.Fragment,{children:[j&&(0,t.jsx)(V.FolderIcon,{folder:e,shape:"square"}),(0,t.jsx)("span",{className:"min-w-0 truncate text-sm font-semibold text-neutral-800",children:e.name})]})},[h,b,v]);return(0,t.jsxs)("div",{className:(0,L.cn)("flex flex-col items-start gap-2 px-6 py-3 md:flex-row md:items-center md:justify-between",r),children:[(0,t.jsxs)("div",{className:"flex min-w-0 max-w-full items-center gap-1",children:[j?(0,t.jsx)(Y.default,{href:`/${o.slug}/links?folderId=${h??"unsorted"}`,className:"flex min-w-0 items-center gap-2 rounded-md py-1 pl-1 pr-2 hover:bg-neutral-100",onClick:d?e=>{window.confirm("Are you sure you want to discard your changes and continue?")||e.preventDefault()}:void 0,children:y}):(0,t.jsx)("div",{className:"flex min-w-0 items-center gap-2 px-1.5",children:y}),(0,t.jsx)(H.ChevronRight,{className:"hidden size-4 shrink-0 text-neutral-500 md:block"}),s?(0,t.jsx)("div",{className:"min-w-0",children:(0,t.jsx)(J,{selectedLink:i,onSelect:s,folderId:h})}):(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-1",children:[(0,t.jsx)(p.LinkLogo,{apexDomain:(0,W.getApexDomain)(f),className:"size-5 shrink-0 sm:size-5 [&>*]:size-3 sm:[&>*]:size-4"}),(0,t.jsx)("h3",{className:"!mt-0 max-w-sm truncate text-sm font-medium",children:i?`Edit ${g}`:"New link"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[a,e&&(0,t.jsx)("button",{type:"button",onClick:e,className:"group hidden rounded-full p-2 text-neutral-500 transition-all duration-75 hover:bg-neutral-100 focus:outline-none active:bg-neutral-200 md:block",children:(0,t.jsx)(K.X,{className:"h-5 w-5"})})]})]})}let Z=e=>({value:e.id,label:(0,G.linkConstructor)({...e,pretty:!0}),icon:(0,t.jsx)(p.LinkLogo,{apexDomain:(0,W.getApexDomain)(e.url),className:"mr-1 size-4 shrink-0 sm:size-4"}),meta:{url:e.url}});function J({selectedLink:e,onSelect:s,disabled:a,folderId:r}){let[l,i]=(0,n.useState)(""),[o]=(0,I.useDebounce)(l,500),{links:d}=(0,O.default)({search:o,...r&&!o&&{folderId:r}},{keepPreviousData:!1}),c=(0,n.useMemo)(()=>d?.map(e=>Z(e)),[d]),[u,m]=(0,n.useState)(e),x=(0,n.useMemo)(()=>Z(u),[u]);return(0,t.jsx)(p.Combobox,{caret:!0,side:"top",options:c,selected:x,setSelected:e=>{let t=d?.find(t=>t.id===e.value);t&&(m(t),s(t))},shouldFilter:!1,onSearchChange:i,buttonProps:{disabled:a,className:(0,L.cn)("h-auto py-2 px-2 w-full max-w-full text-neutral-700 border-none items-start text-sm font-medium !ring-0","hover:bg-neutral-100 active:bg-neutral-200 data-[state=open]:bg-neutral-100")},children:u?(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(p.LinkLogo,{apexDomain:(0,W.getApexDomain)(u.url),className:"size-4 shrink-0 sm:size-4"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:(0,A.truncate)((0,q.getPrettyUrl)(u.shortLink),32)})]}):(0,t.jsx)("div",{className:"my-0.5 h-5 w-1/3 animate-pulse rounded bg-neutral-200"})})}e.s(["LinkBuilderHeader",()=>X],208543);var ee=e.i(119955);function et({showEndABTestingModal:e,setShowEndABTestingModal:s,onEndTest:a}){let{watch:r,setValue:i}=(0,l.useFormContext)(),o=r("testVariants"),[d,c]=(0,n.useState)(null);return(0,t.jsx)(p.Modal,{showModal:e,setShowModal:s,className:"sm:max-w-md",children:(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsx)("h3",{className:"text-lg font-medium",children:"End A/B test"}),(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("p",{className:"text-sm text-neutral-600",children:"Select which destination URL to use as the current destination URL, and end the test. Save your changes on the link editor to confirm the change."}),(0,t.jsx)("div",{className:"mt-4 flex flex-col gap-2",children:o?.map((e,s)=>(0,t.jsxs)("button",{onClick:()=>c(e.url),className:`relative flex w-full items-center rounded-md border bg-white p-0 text-left ring-0 ring-black transition-all duration-100 hover:bg-neutral-50 ${d===e.url?"border-black ring-1":"border-neutral-300"}`,children:[(0,t.jsxs)("div",{className:"flex grow items-center space-x-3 overflow-hidden",children:[(0,t.jsx)("span",{className:"flex h-9 w-8 shrink-0 items-center justify-center border-r border-neutral-300 text-center text-sm font-medium text-neutral-800",children:s+1}),(0,t.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:e.url})]}),(0,t.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center",children:(0,t.jsx)("div",{className:`size-4 rounded-full border transition-all ${d===e.url?"border-4 border-black":"border-neutral-400"}`})})]},s))})]}),(0,t.jsxs)("div",{className:"mt-9 flex justify-end gap-2",children:[(0,t.jsx)(p.Button,{text:"Cancel",variant:"secondary",className:"h-9 w-fit",onClick:()=>{c(null),s(!1)}}),(0,t.jsx)(p.Button,{text:"End test",variant:"primary",className:"h-9 w-fit",disabled:!d,onClick:()=>{d&&(i("url",d,{shouldDirty:!0}
9),i("testCompletedAt",new Date,{shouldDirty:!0}),s(!1),a?.())}})]})]})})}var es=e.i(82916);function ea(e){let{plan:a}=(0,s.default)();return["free","pro"].includes(a)?(0,t.jsx)(p.BadgeTooltip,{...e,children:(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,t.jsx)(es.Crown,{size:12}),(0,t.jsx)("p",{className:"uppercase",children:"Business"})]})}):(0,t.jsx)(p.InfoTooltip,{...e})}e.i(658410);var er=e.i(434016),en=j;e.s(["Flask",()=>en.ic],843603);var en=j,el=e.i(182355),ei=e.i(594858),eo=e.i(871391),ed=e.i(74507),ec=e.i(686353);let eu=new Date(Date.now()+12096e5);function em({showABTestingModal:e,setShowABTestingModal:s}){var a;let r,i,d=(0,n.useId)(),c=(0,n.useRef)(null),{watch:u,getValues:m,setValue:x}=(0,l.useFormContext)(),h=u("domain"),{domains:f}=(0,o.useAvailableDomains)({currentDomain:h}),{EndABTestingModal:g,setShowEndABTestingModal:j}=function({onEndTest:e}={}){let[s,a]=(0,n.useState)(!1),r=(0,n.useCallback)(()=>(0,t.jsx)(et,{showEndABTestingModal:s,setShowEndABTestingModal:a,onEndTest:e}),[s,a]);return(0,n.useMemo)(()=>({setShowEndABTestingModal:a,EndABTestingModal:r}),[a,r])}({onEndTest:()=>s(!1)}),{watch:b,register:v,setValue:y,getValues:w,reset:k,formState:{isDirty:N,isValid:C},handleSubmit:S}=(0,l.useForm)({mode:"onChange",values:{testVariants:(Array.isArray(r=m("testVariants"))?ee.ABTestVariantsSchema.parse(r):null)??[{url:m("url")||"",percentage:100}],testCompletedAt:m("testCompletedAt")??eu}}),T=b("testVariants")||[],L=b("testCompletedAt"),[D,M]=u(["id","testVariants"]);return(0,t.jsxs)(p.Modal,{showModal:e,setShowModal:s,className:"sm:max-w-md",children:[(0,t.jsx)(g,{}),(0,t.jsxs)("form",{className:"px-5 py-4",onSubmit:e=>{e.stopPropagation(),S(e=>{let t=e.testVariants;if(!t||t.length<=1){x("testVariants",null,{shouldDirty:!0}),x("testCompletedAt",null,{shouldDirty:!0});return}100!==t.reduce((e,t)=>e+t.percentage,0)?U.toast.error("Total percentage must equal 100%"):t.some(e=>!e.url)?U.toast.error("All test URLs must be filled"):(x("url",t[0].url,{shouldDirty:!0}),x("trackConversion",!0),x("testVariants",t,{shouldDirty:!0}),x("testCompletedAt",e.testCompletedAt,{shouldDirty:!0}),s(!1))})(e)},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-lg font-medium",children:"A/B Testing"}),(0,t.jsx)(ea,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Test different URLs against each other to optimize your conversion rates.",cta:"Learn more.",href:"https://trailmory.com/help/article/ab-testing"})})]}),(0,t.jsx)("div",{className:"max-md:hidden",children:(0,t.jsx)(p.Tooltip,{content:(0,t.jsxs)("div",{className:"px-2 py-1 text-xs text-neutral-700",children:["Press"," ",(0,t.jsx)("strong",{className:"font-medium text-neutral-950",children:"A"})," to open this quickly"]}),side:"right",children:(0,t.jsx)("kbd",{className:"flex size-6 cursor-default items-center justify-center rounded-md border border-neutral-200 font-sans text-xs text-neutral-950",children:"A"})})})]}),(0,t.jsxs)("div",{className:"mt-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-neutral-700",children:"Testing URLs"}),(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Add up to 3 additional destination URLs to test for this short link.",cta:"Learn more",href:"https://trailmory.com/help/article/ab-testing"})})]}),(0,t.jsxs)("div",{className:"mt-2",children:[(0,t.jsx)(p.AnimatedSizeContainer,{height:!0,transition:{ease:"easeInOut",duration:.2},className:"-m-1",children:(0,t.jsx)("div",{className:"flex flex-col gap-2 p-1",children:T.map((e,s)=>(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsxs)("label",{className:"relative flex grow items-center overflow-hidden rounded-md border border-neutral-300 focus-within:border-neutral-500 focus-within:ring-1 focus-within:ring-neutral-500",children:[(0,t.jsx)("span",{className:"flex h-9 w-8 items-center justify-center border-r border-neutral-300 text-center text-sm font-medium text-neutral-800",children:s+1}),(0,t.jsx)("input",{type:"url",placeholder:f?.find(({slug:e})=>e===h)?.placeholder||"https://trailmory.com/help/article/what-is-dub",className:"block h-9 grow border-none px-2 text-neutral-900 placeholder-neutral-400 focus:ring-0 sm:text-sm",...v(`testVariants.${s}.url`,{validate:(e,{testVariants:t})=>e?(0,eo.isValidUrl)(e)?t.length>1&&t.length<=ee.MAX_TEST_COUNT:"Invalid URL":"URL is required"})}),s>0&&(0,t.jsx)(p.Button,{onClick:()=>(e=>{if(!(T.length<2))if(T.every(({percentage:e})=>1>
9=Math.abs(e-T[0].percentage))){let t=Math.floor(100/(T.length-1)),s=100-t*(T.length-2);y("testVariants",T?.filter((t,s)=>s!==e).map((e,a,r)=>({...e,percentage:a===r.length-1?s:t}))??null,{shouldDirty:!0})}else{let t=T[e].percentage;y("testVariants",T?.filter((t,s)=>s!==e).map((e,s,a)=>({...e,percentage:s===a.length-1?e.percentage+t:e.percentage}))??null,{shouldDirty:!0})}})(s),variant:"outline",className:"mr-1 size-7 p-0",text:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"sr-only",children:"Remove"}),(0,t.jsx)(er.X,{className:"size-4"})]})})]})},s))})}),(0,t.jsx)(p.Button,{type:"button",variant:"primary",className:"mt-2 h-8",onClick:()=>{if(T.length&&!(T.length>=ee.MAX_TEST_COUNT))if(T.every(({percentage:e})=>1>=Math.abs(e-T[0].percentage))){let e=Math.floor(100/(T.length+1));y("testVariants",[...T.map(t=>({...t,percentage:e})),{url:"",percentage:100-e*T.length}],{shouldDirty:!0})}else{let e=T.findLastIndex(({percentage:e})=>e>=2*ee.MIN_TEST_PERCENTAGE),t=T[e],s=Math.floor(t.percentage/2),a=t.percentage-s;y("testVariants",[...T.map((t,a)=>({...t,percentage:a===e?s:t.percentage})),{url:"",percentage:a}],{shouldDirty:!0})}},disabledTooltip:T.length>=ee.MAX_TEST_COUNT?`You may only add up to ${ee.MAX_TEST_COUNT} URLs for an A/B test`:void 0,text:"Add URL"})]})]}),(0,t.jsxs)("div",{className:"mt-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-neutral-700",children:"Traffic Split"}),(0,t.jsx)(p.InfoTooltip,{content:`Adjust the percentage of traffic to each URL. The minimum is ${ee.MIN_TEST_PERCENTAGE}%`})]}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(ef,{testVariants:T,onChange:e=>{e.forEach((e,t)=>{y(`testVariants.${t}.percentage`,e,{shouldDirty:!0})})}})})]}),(0,t.jsxs)("div",{className:"mt-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("label",{htmlFor:`${d}-testCompletedAt`,className:"block text-sm font-medium text-neutral-700",children:"Completion Date"}),(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Set when the A/B test should complete. After this date, all traffic will go to the best performing URL.",cta:"Learn more.",href:"https://trailmory.com/help/article/ab-testing"})})]}),(0,t.jsxs)("div",{className:"mt-2 flex w-full items-center justify-between rounded-md border border-neutral-300 bg-white shadow-sm transition-all focus-within:border-neutral-800 focus-within:outline-none focus-within:ring-1 focus-within:ring-neutral-500",children:[(0,t.jsx)("input",{ref:c,id:`${d}-testCompletedAt`,type:"text",placeholder:'E.g. "in 2 weeks" or "next month"',defaultValue:w("testCompletedAt")?(0,ei.formatDateTime)(w("testCompletedAt")):"",onBlur:e=>{if(e.target.value.length>0){let t=(0,ed.parseDateTime)(e.target.value);t&&(y("testCompletedAt",t,{shouldDirty:!0}),e.target.value=(0,ei.formatDateTime)(t))}},className:"flex-1 border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-0 sm:text-sm"}),(0,t.jsx)("input",{type:"datetime-local",value:w("testCompletedAt")?"Invalid Date"===(i=(a=w("testCompletedAt"))?new Date(a):new Date).toString()?"":new Date(i.getTime()-6e4*i.getTimezoneOffset()).toISOString().split(":").slice(0,2).join(":"):"",onChange:e=>{let t=new Date(e.target.value);y("testCompletedAt",t,{shouldDirty:!0}),c.current&&(c.current.value=(0,ei.formatDateTime)(t))},className:"w-[40px] border-none bg-transparent text-neutral-500 focus:outline-none focus:ring-0 sm:text-sm"})]}),(0,t.jsx)("p",{className:"mt-1 text-xs text-neutral-500",children:"6 weeks maximum"})]}),M&&(0,t.jsxs)("div",{className:"mt-6 flex items-start gap-2 rounded-lg border border-amber-200 bg-amber-50 p-4",children:[(0,t.jsx)(el.TriangleWarning,{className:"mt-0.5 size-4 shrink-0 text-amber-500"}),(0,t.jsx)("p",{className:"text-sm font-medium text-amber-900",children:"Changing the original A/B test settings will impact your future analytics and event tracking."})]}),(0,t.jsxs)("div",{className:"mt-4 flex items-center justify-between",children:[(0,t.jsx)("div",{children:!!M&&(0,t.jsxs)("button",{type:"button",className:"text-xs font-medium text-neutral-700 transition-colors hover:text-neutral-950",onClick:()=>
9{D?j(!0):(["testVariants","testCompletedAt"].forEach(e=>x(e,null,{shouldDirty:!0})),s(!1))},children:[D?"End":"Remove"," A/B test"]})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",text:"Cancel",className:"h-9 w-fit",onClick:()=>{k(),s(!1)}}),(0,t.jsx)(p.Button,{type:"submit",variant:"primary",text:Array.isArray(M)&&M.length>1?"Save changes":"Start testing",className:"h-9 w-fit",disabled:!N||!C||!!(L&&((0,ec.differenceInDays)(L,new Date)>42||-1>(0,ec.differenceInDays)(L,new Date)))})]})]})]})]})}function ex({testVariants:e,testCompletedAt:t}){let s=!!(e&&t);return t&&new Date(t)<new Date?"Test Complete":s&&Array.isArray(e)?`${e?.length} URLs`:"A/B Test"}function ep({setShowABTestingModal:e}){let{watch:s}=(0,l.useFormContext)(),[a,r]=s(["testVariants","testCompletedAt"]);b("a",()=>e(!0));let i=!!(a&&r),o=(0,n.useMemo)(()=>ex({testVariants:a,testCompletedAt:r}),[a,r]);return(0,t.jsx)(p.Button,{variant:"secondary",text:o,icon:(0,t.jsx)(en.ic,{className:(0,L.cn)("size-4",i&&"text-blue-500")}),className:"h-8 w-fit gap-1.5 px-2.5 text-xs font-medium text-neutral-700",onClick:()=>e(!0)})}function eh(){let[e,s]=(0,n.useState)(!1),a=(0,n.useCallback)(()=>(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(em,{showABTestingModal:e,setShowABTestingModal:s})}),[e,s]),r=(0,n.useCallback)(()=>(0,t.jsx)(ep,{setShowABTestingModal:s}),[s]);return(0,n.useMemo)(()=>({setShowABTestingModal:s,ABTestingModal:a,ABTestingButton:r}),[s,a,r])}function ef({testVariants:e,onChange:s}){let[a,r]=(0,n.useState)(null),l=(0,n.useRef)(null),i=(0,n.useCallback)(t=>{if(null===a||!l.current)return;let r=l.current.getBoundingClientRect(),n=r.width,i=Math.round((t.clientX-r.x)/n*100),o=e.slice(0,Math.max(0,a)).reduce((e,{percentage:t})=>e+t,0),d=e.slice(a+2).reduce((e,{percentage:t})=>e+t,0),c=e.map(({percentage:e})=>e);c[a]=i-o,c[a+1]=100-d-i,c.every(e=>e>=ee.MIN_TEST_PERCENTAGE)&&s(c)},[a,e,s]),o=(0,n.useCallback)(()=>{r(null)},[]);return(0,n.useEffect)(()=>{if(null!==a)return window.addEventListener("mousemove",i),window.addEventListener("mouseup",o),()=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",o)}},[a,i,o]),(0,t.jsx)("div",{ref:l,className:(0,L.cn)("relative h-10",null!==a&&"cursor-col-resize"),children:(0,t.jsx)("div",{className:"absolute inset-0 flex h-full",children:e.map((s,n)=>(0,t.jsxs)("div",{className:"@container pointer-events-none relative flex h-full",style:{width:`${s.percentage}%`},children:[n>0&&(0,t.jsx)("div",{className:"w-1.5"}),(0,t.jsxs)("div",{className:"flex h-full grow items-center justify-center gap-2 rounded-md border border-neutral-300 text-xs",children:[(0,t.jsx)("span",{className:"text-xs font-semibold text-neutral-900",children:n+1}),(0,t.jsxs)("span",{className:"@[64px]:block hidden font-medium text-neutral-600",children:[s.percentage,"%"]})]}),n<e.length-1&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"w-1.5"}),(0,t.jsx)("div",{className:"group pointer-events-auto absolute -right-1.5 flex h-full w-3 cursor-col-resize items-center px-1",onMouseDown:e=>{e.preventDefault(),r(n)},children:(0,t.jsx)("div",{className:(0,L.cn)("h-2/3 w-1 rounded-full bg-neutral-200",a===n?"bg-neutral-400":"group-hover:bg-neutral-300")})})]})]},n))})})}function eg({showAdvancedModal:e,setShowAdvancedModal:s}){let a=(0,n.useId)(),{watch:r,getValues:i,setValue:o}=(0,l.useFormContext)(),{register:d,handleSubmit:c,formState:{isDirty:u}}=(0,l.useForm)({values:{externalId:i("externalId"),tenantId:i("tenantId")}}),[m,x]=r(["externalId","tenantId"]);return b("v",()=>s(!0)),(0,t.jsx)(p.Modal,{showModal:e,setShowModal:s,className:"sm:max-w-[500px]",children:(0,t.jsxs)("form",{className:"px-5 py-4",onSubmit:e=>{e.stopPropagation(),c(e=>{o("externalId",e.externalId,{shouldDirty:!0}),o("tenantId",e.tenantId,{shouldDirty:!0}),s(!1)})(e)},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h3",{className:"text-lg font-medium",children:"Advanced Options"}),(0,t.jsx)("div",{className:"max-md:hidden",children:(0,t.jsx)(p.Tooltip,{content:(0,t.jsxs)("div",{className:"px-2 py-1 text-xs text-neutral-700",children:["Press"," ",(0,t.jsx)("strong",{className:"font-medium text-neutral-950",children:"V"})," to open this quickly"]}),side:"right",children:(0,t.jsx)("kbd",{className:"flex size-6 cursor-default items-center justify-center gap-1 rounded-md border border-neutral-200 font-sans text-xs text-neutral-950",children:"V"})})})]}),(0,t.jsxs)("div",{className:"mt-6 flex flex-col gap-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("label",{htmlFor:`${a}-external-id`,className:"flex items-center gap-2 text-sm font-medium text-neutral-700",children:["External ID"," ",(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"A unique identifier for this link in your database.",cta:"Learn more about external IDs.",href:"https://d.to/externalId"})})]}),(0,t.jsx)(p.Tooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"A unique identifier for this link in your system.",cta:"Learn more about external IDs.",href:"https://d.to/externalId"})})]}),(0,t.jsx)("div",{className:"mt-2 rounded-md shadow-sm",children:(0,t.jsx)("input",{id:`${a}-external-id`,type:"text",placeholder:"Eg: 123456",className:"block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",...d("externalId")})})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("label",{htmlFor:`${a}-tenant-id`,className:"flex items-center gap-2 text-sm font-medium text-neutral-700",children:["Tenant ID"," ",(0,t.jsx)(p.InfoTooltip,{content:"The ID of the tenant that created the link inside your system. If set, it can be used to fetch all links for a tenant."})]}),(0,t.jsx)(p.Tooltip,{content:"The ID of the tenant that created the link inside your system. If set, it can be used to fetch all links for a tenant."})]}),(0,t.jsx)("div",{className:"mt-2 rounded-md shadow-sm",children:(0,t.jsx)("input",{id:`${a}-tenant-id`,type:"text",placeholder:"Eg: user_123",className:"block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",...d("tenantId")})})]})]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,t.jsx)("div",{children:!!(m||x)&&(0,t.jsx)("button",{type:"button",className:"text-xs font-medium text-neutral-700 transition-colors hover:text-neutral-950",onClick:()=>{o("externalId",null,{shouldDirty:!0}),s(!1)},children:"Remove advanced options"})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",text:"Cancel",className:"h-9 w-fit",onClick:()=>s(!1)}),(0,t.jsx)(p.Button,{type:"submit",variant:"primary",text:"Save",className:"h-9 w-fit",disabled:!u})]})]})]})})}var ej=e.i(195104),eb=e.i(78085);function ev({showExpirationModal:e,setShowExpirationModal:s}){let{isMobile:a}=(0,k.useMediaQuery)(),r=(0,n.useId)(),{watch:i,getValues:o,setValue:d}=(0,l.useFormContext)(),{watch:c,register:u,setValue:m,reset:x,formState:{isDirty:h,errors:f},handleSubmit:g}=(0,l.useForm)({values:{expiresAt:o("expiresAt"),expiredUrl:o("expiredUrl")}}),[j]=c(["expiresAt","expiredUrl"]),b=i("expiresAt"),v=(0,n.useRef)(null);return(0,n.useEffect)(()=>{v.current&&!a&&setTimeout(()=>{v.current?.focus()},10)},[]),(0,t.jsx)(p.Modal,{showModal:e,setShowModal:s,className:"sm:max-w-md",children:(0,t.jsxs)("form",{className:"px-5 py-4",onSubmit:e=>{e.stopPropagation(),g(e=>{d("expiresAt",e.expiresAt,{shouldDirty:!0}),d("expiredUrl",e.expiredUrl,{shouldDirty:!0}),s(!1)})(e)},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-lg font-medium",children:"Link Expiration"}),(0,t.jsx)(ej.ProBadgeTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Set an expiration date for your links – after which it won't be accessible.",cta:"Learn more.",href:"https://trailmory.com/help/article/link-expiration"})})]}),(0,t.jsx)("div",{className:"max-md:hidden",children:(0,t.jsx)(p.Tooltip,{content:(0,t.jsxs)("div",{className:"px-2 py-1 text-xs text-neutral-700",children:["Press"," ",(0,t.jsx)("strong",{className:"font-medium text-neutral-950",children:"E"})," to open this quickly"]}),side:"right",children:(0,t.jsx)("kbd",{className:"flex size-6 cursor-default items-center justify-center rounded-md border border-neutral-200 font-sans text-xs text-neutral-950",children:"E"})})})]}),(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(p.SmartDateTimePicker,{value:j,onChange:e=>{m("expiresAt",e,{shouldDirty:!0})},label:"Date and Time",autoFocus:!a})}),(0,t.jsxs)("div",{className:"mt-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("label",{htmlFor:`${r}-expiredUrl`,className:"block text-sm font-medium text-neutral-700",children:"Expiration URL"}),(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Redirect users to a 
9specific URL when the link has expired.",cta:"Learn more.",href:"https://trailmory.com/help/article/link-expiration#setting-a-custom-expiration-url"})})]}),(0,t.jsx)("div",{className:"mt-2 rounded-md shadow-sm",children:(0,t.jsx)("input",{id:`${r}-expiredUrl`,type:"text",autoFocus:!a,placeholder:"https://example.com",className:`${f.expiredUrl?"border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500":"border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500"} block w-full rounded-md focus:outline-none sm:text-sm`,...u("expiredUrl")})})]}),(0,t.jsx)("a",{href:"https://trailmory.com/help/article/link-expiration#setting-a-default-expiration-url-for-all-links-under-a-domain",target:"_blank",className:"group mt-2 flex items-center text-xs text-neutral-500 hover:text-neutral-700",children:"Set a default expiration URL for your domain"}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,t.jsx)("div",{children:!!b&&(0,t.jsx)("button",{type:"button",className:"text-xs font-medium text-neutral-700 transition-colors hover:text-neutral-950",onClick:()=>{d("expiresAt",null,{shouldDirty:!0}),d("expiredUrl",null,{shouldDirty:!0}),s(!1)},children:"Remove expiration"})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",text:"Cancel",className:"h-9 w-fit",onClick:()=>{x(),s(!1)}}),(0,t.jsx)(p.Button,{type:"submit",variant:"primary",text:b?"Save":"Add expiration",className:"h-9 w-fit",disabled:!h})]})]})]})})}function ey({expiresAt:e}){return e?(0,ei.formatDateTime)(e,{year:void 0}):"Expiration"}function ew({setShowExpirationModal:e}){let{control:s}=(0,l.useFormContext)(),a=(0,l.useWatch)({control:s,name:"expiresAt"});return b("e",()=>e(!0)),(0,t.jsx)(p.Button,{variant:"secondary",text:ey({expiresAt:a}),icon:(0,t.jsx)(eb.CircleHalfDottedClock,{className:(0,L.cn)("size-4",a&&"text-blue-500")}),className:"h-8 w-fit gap-1.5 px-2.5 text-xs font-medium text-neutral-700",onClick:()=>e(!0)})}function ek(){let[e,s]=(0,n.useState)(!1),a=(0,n.useCallback)(()=>(0,t.jsx)(ev,{showExpirationModal:e,setShowExpirationModal:s}),[e,s]),r=(0,n.useCallback)(()=>(0,t.jsx)(ew,{setShowExpirationModal:s}),[s]);return(0,n.useMemo)(()=>({setShowExpirationModal:s,ExpirationModal:a,ExpirationButton:r}),[s,a,r])}var eN=e.i(698683),eC=e.i(535361),eS=e.i(879093);function eT({query:e,enabled:t=!0}={},a={}){let{id:r}=(0,s.default)(),{data:n,isLoading:l,error:i}=(0,eC.default)(t&&r?`/api/partners?${new URLSearchParams({workspaceId:r,...e}).toString()}`:void 0,eN.fetcher,{keepPreviousData:!0,...a});return{partners:n,loading:l,error:i}}eS.getPartnersQuerySchemaExtended.partial();var eL=e.i(164556);function eD({selectedPartnerId:e,setSelectedPartnerId:s,disabled:a,variant:r="default",...l}){let[i,o]=(0,n.useState)(""),[d,c]=(0,n.useState)(!1),[u]=(0,I.useDebounce)(i,500),[m,x]=(0,n.useState)(!1),{partners:h,loading:f}=eT({query:d?{search:u}:void 0}),{partners:g,loading:j}=eT({query:e?{partnerIds:[e]}:void 0});(0,n.useEffect)(()=>{h&&!d&&h.length>=eS.PARTNERS_MAX_PAGE_SIZE&&c(!0)},[h,d]);let b=(0,n.useMemo)(()=>h?.map(e=>({value:e.id,label:e.name,icon:(0,t.jsx)("img",{src:e.image||`${eL.OG_AVATAR_URL}${e.name}`,className:"size-4 rounded-full"})})),[h]),v=(0,n.useMemo)(()=>{if(!e)return null;let s=[...h||[],...g||[]].find(t=>t.id===e);return s?{value:s.id,label:s.name,icon:(0,t.jsx)("img",{src:s.image||`${eL.OG_AVATAR_URL}${s.name}`,className:"size-4 rounded-full"})}:null},[h,g,e]);return(0,t.jsx)(p.Combobox,{options:f?void 0:b,setSelected:e=>{e&&s(e.value)},selected:v,icon:"header"!==r||v?.icon?v?.icon:(0,t.jsx)("div",{className:"size-5 flex-none animate-pulse rounded-full bg-neutral-200"}),caret:!0,placeholder:"header"===r?"":"Select partner",searchPlaceholder:"Search partners...",onSearchChange:o,shouldFilter:!d,matchTriggerWidth:!0,open:m,onOpenChange:x,..."header"===r?{popoverProps:{contentClassName:"min-w-[280px]"},labelProps:{className:"text-lg font-semibold leading-7 text-neutral-900"},iconProps:{className:"size-6"},buttonProps:{disabled:a,className:"w-full justify-start px-2 py-1 h-8 transition-none max-md:bg-bg-subtle hover:bg-bg-subtle md:hover:bg-subtle border-none rounded-lg"}}:{buttonProps:{disabled:a,className:(0,L.cn)("w-full justify-start border-neutral-300 px-3","data-[state=open]:ring-1 data-[state=open]:ring-neutral-500 data-[state=open]:border-neutral-500","focus:ring-1 focus:ring-neutral-500 focus:border-neutral-500 transition-none")}},...l,children:"header"!==r||v?.label?v?.label:(0,t.jsx)("div",{className:"h-6 w-[120px] animate-pulse rounded bg-neutral-100"})})}function eM({showPartnerModal:e,setShowPartnerModal:s}){return(0,t.jsx)(p.Modal,{showModal:e,setShowModal:s,className:"sm:max-w-md",children:(0,t.jsx)(eP,{setShowPartnerModal:s})})}function eP({setShowPartnerModal:e}){let{watch:s,getValues:a,setValue:r}=(0,l.useFormContext)(),{watch:n,setValue:i,reset:o,formState:{isDirty:d},handleSubmit:c}=(0,l.useForm)({values:{partnerId:a("partnerId")}
9}),u=s("partnerId"),m=n("partnerId");return(0,t.jsxs)("form",{className:"px-5 py-4",onSubmit:t=>{t.stopPropagation(),c(t=>{r("partnerId",t.partnerId,{shouldDirty:!0}),e(!1)})(t)},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)("h3",{className:"text-lg font-medium",children:"Assign to partner"})}),(0,t.jsx)("div",{className:"max-md:hidden",children:(0,t.jsx)(p.Tooltip,{content:(0,t.jsxs)("div",{className:"px-2 py-1 text-xs text-neutral-700",children:["Press"," ",(0,t.jsx)("strong",{className:"font-medium text-neutral-950",children:"B"})," to open this quickly"]}),side:"right",children:(0,t.jsx)("kbd",{className:"flex size-6 cursor-default items-center justify-center rounded-md border border-neutral-200 font-sans text-xs text-neutral-950",children:"B"})})})]}),(0,t.jsxs)("div",{className:"mt-6 flex flex-col gap-2",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-neutral-900",children:"Partner"}),(0,t.jsx)(eD,{selectedPartnerId:m||null,setSelectedPartnerId:e=>i("partnerId",e,{shouldDirty:!0})})]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,t.jsx)("div",{children:!!u&&(0,t.jsx)("button",{type:"button",className:"text-xs font-medium text-neutral-700 transition-colors hover:text-neutral-950",onClick:()=>{r("partnerId",null,{shouldDirty:!0}),e(!1)},children:"Remove partner"})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",text:"Cancel",className:"h-9 w-fit",onClick:()=>{o(),e(!1)}}),(0,t.jsx)(p.Button,{type:"submit",variant:"primary",text:"Save",className:"h-9 w-fit",disabled:!d})]})]})]})}var eA=j,eR=j,eU=e.i(243741),eI=j;function eF({showPasswordModal:e,setShowPasswordModal:s}){return(0,t.jsx)(p.Modal,{showModal:e,setShowModal:s,className:"sm:max-w-md",children:(0,t.jsx)(eE,{setShowPasswordModal:s})})}function eE({setShowPasswordModal:e}){let{isMobile:s}=(0,k.useMediaQuery)(),a=(0,n.useRef)(null),{watch:r,getValues:i,setValue:o}=(0,l.useFormContext)(),{register:d,setValue:c,reset:u,formState:{isDirty:m,errors:x},handleSubmit:h}=(0,l.useForm)({values:{password:i("password")}}),f=r("password"),[g,j]=(0,n.useState)(!1);(0,n.useEffect)(()=>{a.current&&!s&&setTimeout(()=>{a.current?.focus()},10)},[]);let{ref:b,...v}=d("password");return(0,t.jsxs)("form",{className:"px-5 py-4",onSubmit:t=>{t.stopPropagation(),h(t=>{o("password",t.password,{shouldDirty:!0}),e(!1)})(t)},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-lg font-medium",children:"Link Password"}),(0,t.jsx)(ej.ProBadgeTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Restrict access to your short links by encrypting it with a password.",cta:"Learn more.",href:"https://trailmory.com/help/article/password-protected-links"})})]}),(0,t.jsx)("div",{className:"max-md:hidden",children:(0,t.jsx)(p.Tooltip,{content:(0,t.jsxs)("div",{className:"px-2 py-1 text-xs text-neutral-700",children:["Press"," ",(0,t.jsx)("strong",{className:"font-medium text-neutral-950",children:"P"})," to open this quickly"]}),side:"right",children:(0,t.jsx)("kbd",{className:"flex size-6 cursor-default items-center justify-center rounded-md border border-neutral-200 font-sans text-xs text-neutral-950",children:"P"})})})]}),(0,t.jsxs)("div",{className:"mt-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-neutral-700",children:"Password"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.ButtonTooltip,{className:"text-neutral-500 transition-colors hover:text-neutral-800",tooltipProps:{content:g?"Hide password":"Reveal password"},onClick:()=>j(e=>!e),children:g?(0,t.jsx)(eR._b,{className:"size-4"}):(0,t.jsx)(eA.Zb,{className:"size-4"})}),(0,t.jsx)(p.ButtonTooltip,{tooltipProps:{content:"Generate a random password"},onClick:()=>{c("password",(0,D.nanoid)(24),{shouldDirty:!0})},children:(0,t.jsx)(eI._d,{className:"size-4"})})]})]}),(0,t.jsx)("div",{className:"mt-2 rounded-md shadow-sm",children:(0,t.jsx)("input",{type:g?"text":"password",placeholder:"Create password","data-1p-ignore":!0,className:`${x.password?"border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500":"border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500"} block w-full rounded-md focus:outline-none sm:text-sm`,...v,ref:e=>{b(e),a.current=e}})})]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,t.jsx)("div",{children:!!f&&(0,t.jsx)("button",{type:"button",className:"text-xs font-medium text-neutral-700 transition-colors hover:text-neutral-950",onClick:()=>{o("password",null,{shouldDirty:!0}
9),["title","description","image"].forEach(e=>o(e,null,{shouldDirty:!0})),e(!1)},children:"Remove password"})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",text:"Cancel",className:"h-9 w-fit",onClick:()=>{u(),e(!1)}}),(0,t.jsx)(p.Button,{type:"submit",variant:"primary",text:f?"Save":"Add password",className:"h-9 w-fit",disabled:!m})]})]})]})}function eB({password:e}){return e?"Protected":"Password"}function ez({setShowPasswordModal:e}){let{watch:s}=(0,l.useFormContext)(),a=s("password");return b("p",()=>e(!0)),(0,t.jsx)(p.Button,{variant:"secondary",text:eB({password:a}),icon:(0,t.jsx)(eU.InputPassword,{className:(0,L.cn)("size-4",a&&"text-blue-500")}),className:"h-8 w-fit gap-1.5 px-2.5 text-xs font-medium text-neutral-700",onClick:()=>e(!0)})}function e_(){let[e,s]=(0,n.useState)(!1),a=(0,n.useCallback)(()=>(0,t.jsx)(eF,{showPasswordModal:e,setShowPasswordModal:s}),[e,s]),r=(0,n.useCallback)(()=>(0,t.jsx)(ez,{setShowPasswordModal:s}),[s]);return(0,n.useMemo)(()=>({setShowPasswordModal:s,PasswordModal:a,PasswordButton:r}),[s,a,r])}var e$=j,eO=e.i(272270),eV=e.i(176099),eW=e.i(217142),eq=e.i(803692),eQ=e.i(821198);function eG({showTargetingModal:e,setShowTargetingModal:s}){let a=(0,n.useId)(),{watch:r,getValues:i,setValue:o}=(0,l.useFormContext)(),{watch:d,register:c,setValue:u,reset:m,handleSubmit:x,formState:{isDirty:h}}=(0,l.useForm)({values:{ios:i("ios"),android:i("android"),geo:i("geo")}}),f=d("geo"),[g,j,b]=r(["ios","android","geo"]),v=!!(g||j||Object.keys(b||{}).length>0),y=(0,n.useCallback)(e=>{if(!e?.trim()||!(0,eo.isValidUrl)(e))return;let t=i("url"),s=(0,eq.getParamsFromURL)(t),a=(0,eq.getParamsFromURL)(e),r=p.UTM_PARAMETERS.filter(({key:e})=>s?.[e]&&!a?.[e]).map(({key:e})=>[e,s[e]]);return r.length?Object.fromEntries(r):null},[i]);return(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(p.Modal,{showModal:e,setShowModal:s,className:"sm:max-w-[500px]",children:(0,t.jsxs)("form",{className:"px-5 py-4",onSubmit:e=>{e.stopPropagation(),x(e=>{o("ios",e.ios,{shouldDirty:!0}),o("android",e.android,{shouldDirty:!0});let t=Object.fromEntries(Object.entries(e.geo||{}).filter(([e,t])=>e?.trim()&&t?.trim()));o("geo",Object.keys(t).length>0?t:null,{shouldDirty:!0}),s(!1)})(e)},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h3",{className:"text-lg font-medium",children:"Targeting"}),(0,t.jsx)("div",{className:"max-md:hidden",children:(0,t.jsx)(p.Tooltip,{content:(0,t.jsxs)("div",{className:"px-2 py-1 text-xs text-neutral-700",children:["Press"," ",(0,t.jsx)("strong",{className:"font-medium text-neutral-950",children:"G"})," ","to open this quickly"]}),side:"right",children:(0,t.jsx)("kbd",{className:"flex size-6 cursor-default items-center justify-center gap-1 rounded-md border border-neutral-200 font-sans text-xs text-neutral-950",children:"G"})})})]}),(0,t.jsxs)("div",{className:"scrollbar-hide -m-1 mt-6 flex max-h-[calc(100dvh-250px)] flex-col gap-6 overflow-y-auto p-1",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-neutral-700",children:"Geo Targeting"}),(0,t.jsx)(ej.ProBadgeTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Redirect your users to different links based on their location.",cta:"Learn more about geo targeting.",href:"https://trailmory.com/help/article/geo-targeting"})})]}),(0,t.jsxs)("div",{className:"mt-2",children:[f&&(0,t.jsx)("div",{className:"relative mb-2 grid grid-cols-[min-content_1fr_min-content] gap-y-2",children:Object.entries(f).map(([e,s])=>(0,t.jsxs)(n.Fragment,{children:[(0,t.jsx)("div",{className:"z-[1]",children:(0,t.jsx)(p.Combobox,{selected:e?{value:e,label:eW.COUNTRIES[e]}
9:null,setSelected:t=>{if(!t)return;let a={};delete Object.assign(a,f,{[t.value]:s})[e],u("geo",a,{shouldDirty:!0})},options:Object.entries(eW.COUNTRIES).sort((e,t)=>"US"===e[0]?-1:+("US"===t[0])).filter(([t])=>t===e||!Object.keys(f).includes(t)).map(([e,s])=>({icon:(0,t.jsx)("img",{alt:s,src:`https://flag.vercel.app/m/${e}.svg`,className:"mr-1 h-2.5 w-4"}),value:e,label:s})),icon:e?(0,t.jsx)("img",{alt:eW.COUNTRIES[e],src:`https://flag.vercel.app/m/${e}.svg`,className:"h-2.5 w-4"}):void 0,caret:!0,placeholder:"Country",searchPlaceholder:"Search countries...",buttonProps:{className:(0,L.cn)("w-32 sm:w-40 rounded-r-none border-r-transparent justify-start px-2.5","data-[state=open]:ring-1 data-[state=open]:ring-neutral-500 data-[state=open]:border-neutral-500","focus:ring-1 focus:ring-neutral-500 focus:border-neutral-500 transition-none",!e&&"text-neutral-600")},optionClassName:"sm:max-w-[200px]"})}),(0,t.jsx)("input",{type:"text",id:`${a}-${e}`,placeholder:"https://example.com",className:"z-0 h-full grow rounded-r-md border border-neutral-300 text-sm placeholder-neutral-400 focus:z-[1] focus:border-neutral-500 focus:ring-neutral-500",value:s,onChange:t=>{u("geo",{...f||{},[e]:t.target.value},{shouldDirty:!0})},onBlur:t=>{let a=y(t.target.value);a&&u("geo",{...f||{},[e]:(0,eV.constructURLFromUTMParams)(s,a)},{shouldDirty:!0})}}),(0,t.jsx)("div",{className:"pl-1.5",children:(0,t.jsx)(p.Button,{variant:"danger-outline",icon:(0,t.jsx)(eO.Trash,{className:"size-4"}),className:"bg-red-600/5 px-3 text-red-600 hover:bg-red-600/10 hover:text-red-700",onClick:()=>{let t={...f||{}};delete t[e],u("geo",t,{shouldDirty:!0})}})})]},e))}),(0,t.jsx)(p.Button,{type:"button",variant:"secondary",text:"Add location",className:"h-9",onClick:()=>{u("geo",{...f||{},"":""},{shouldDirty:!0})},disabled:Object.keys(f||{}).includes("")})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("label",{htmlFor:`${a}-ios-url`,className:"block text-sm font-medium text-neutral-700",children:"iOS Targeting"}),(0,t.jsx)(ej.ProBadgeTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Redirect your iOS users to a different link.",cta:"Learn more about device targeting.",href:"https://trailmory.com/help/article/device-targeting"})})]}),(0,t.jsx)("div",{className:"mt-2 rounded-md shadow-sm",children:(0,t.jsx)("input",{id:`${a}-ios-url`,placeholder:"https://apps.apple.com/app/1611158928",className:"block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",...c("ios",{onBlur:e=>{let t=y(e.target.value);t&&u("ios",(0,eV.constructURLFromUTMParams)(e.target.value,t),{shouldDirty:!0})}})})})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("label",{htmlFor:`${a}-android-url`,className:"block text-sm font-medium text-neutral-700",children:"Android Targeting"}),(0,t.jsx)(ej.ProBadgeTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Redirect your Android users to a different link.",cta:"Learn more about device targeting.",href:"https://trailmory.com/help/article/device-targeting"})})]}),(0,t.jsx)("div",{className:"mt-2 rounded-md shadow-sm",children:(0,t.jsx)("input",{id:`${a}-android-url`,placeholder:"https://play.google.com/store/apps/details?id=com.disney.disneyplus",className:"block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",...c("android",{onBlur:e=>{let t=y(e.target.value);t&&u("android",(0,eV.constructURLFromUTMParams)(e.target.value,t),{shouldDirty:!0})}})})})]})]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,t.jsx)("div",{children:v&&(0,t.jsx)("button",{type:"button",className:"text-xs font-medium text-neutral-700 transition-colors hover:text-neutral-950",onClick:()=>{o("ios",null,{shouldDirty:!0}),o("android",null,{shouldDirty:!0}),o("geo",null,{shouldDirty:!0}),s(!1)},children:"Remove targeting"})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",text:"Cancel",className:"h-9 w-fit",onClick:()=>{m(),s(!1)}}),(0,t.jsx)(p.Button,{type:"submit",variant:"primary",text:v?"Save":"Add targeting",className:"h-9 w-fit",disabled:!h})]})]})]})})})}function eH({ios:e,android:t,geo:s}){let a=Object.keys(s||{}).length>0,r=[!!e,!!t,a],n=r.filter(Boolean).length,l=Object.keys(s||{});if(0===n)return"Targeting";if(1===n){let e=r.findIndex(Boolean);return e<=1?["iOS","Android"][e]:a?1===l.length&&l[0]?l[0]:`${l.length} ${(0,eQ.pluralize)("Target",l.length)}`:"Targeting"}return`${n+(l.length>1?l.length-1:0)} Targets`}function eK({setShowTargetingModal:e}){let{watch:s}=(0,l.useFormContext)(),[a,r,i]=s(["ios","android","geo"]);b("g",()=>e(!0));let o=Object.keys(i||{}).length>0,d=!!(a||r||o),c=(0,n.useMemo)(()=>eH({ios:a,android:r,geo:i}),[a,r,i]);return(0,t.jsx)(p.Button,{variant:"secondary",text:c,icon:(0,t.jsx)(e$.Ab,{className:(0,L.cn)("size-4",d&&"text-blue-500")}),className:"h-8 w-fit gap-1.5 px-2.5 text-xs font-medium text-neutral-700",onClick:()=>e(!0)})}
9function eY(){let[e,s]=(0,n.useState)(!1),a=(0,n.useCallback)(()=>(0,t.jsx)(eG,{showTargetingModal:e,setShowTargetingModal:s}),[e,s]),r=(0,n.useCallback)(()=>(0,t.jsx)(eK,{setShowTargetingModal:s}),[s]);return(0,n.useMemo)(()=>({setShowTargetingModal:s,TargetingModal:a,TargetingButton:r}),[s,a,r])}var eX=e.i(899928),e$=j,en=j,eZ=e.i(543961),eJ=j,e0=j;let e1=(0,e.i(639297).default)("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var e2=e.i(824283),e2=e2;let e5=[{key:"rewrite",icon:eZ.Incognito,label:"Link Cloaking",description:"Mask your destination URL so your users only see the short link in the browser address bar.",learnMoreUrl:"https://trailmory.com/help/article/link-cloaking",shortcutKey:"k",type:"boolean"},{key:"doIndex",icon:e0.Se,label:"Search Engine Indexing",description:"Allow search engines to index your short link. Disabled by default.",learnMoreUrl:"https://trailmory.com/help/article/how-noindex-works",shortcutKey:"s",type:"boolean"},{key:"linkRetentionCleanupDisabledAt",icon:eJ.Sc,label:"Permanent Retention",description:"Exclude this link from link retention settings.",shortcutKey:"r",type:"boolean",enabled:e=>!!e.linkRetentionCleanupDisabledAt,enable:e=>e("linkRetentionCleanupDisabledAt",new Date,{shouldDirty:!0}),remove:e=>e("linkRetentionCleanupDisabledAt",null,{shouldDirty:!0})},{key:"partnerId",icon:e2.default,label:"Assign to Partner",shortcutKey:"b",type:"modal",enabled:e=>!!e.partnerId,add:!1,description:"Assign this link to a partner.",learnMoreUrl:"https://trailmory.com/help/article/dub-partners"},{key:"advanced",icon:e1,label:"Advanced Settings",shortcutKey:"v",type:"modal",enabled:e=>!!(e.externalId||e.tenantId),add:!1}],e3=[{key:"expiresAt",icon:eb.CircleHalfDottedClock,label:"Link Expiration",badgeLabel:ey,description:"Set an expiration date for your links – after which it won't be accessible.",learnMoreUrl:"https://trailmory.com/help/article/link-expiration",shortcutKey:"e",enabled:e=>!!e.expiresAt,type:"modal"},{key:"targeting",icon:e$.Ab,label:"Targeting",badgeLabel:eH,description:"Target your links to specific audiences based on their location, device, or browser.",learnMoreUrl:"https://trailmory.com/help/article/geo-targeting",shortcutKey:"x",enabled:e=>!!(e.ios||e.android||Object.keys(e.geo||{}).length>0),type:"modal"},{key:"testVariants",icon:en.ic,label:"A/B Test",badgeLabel:ex,shortcutKey:"b",enabled:e=>!!(e.testVariants&&e.testCompletedAt),type:"modal"},{key:"password",icon:eU.InputPassword,label:"Password",badgeLabel:eB,description:"Protect your links with a password so only authorized users can access them.",learnMoreUrl:"https://trailmory.com/help/article/password-protected-links",shortcutKey:"l",enabled:e=>!!e.password,type:"modal"}];function e4({variant:e="page"}){let{domains:a,defaultProgramId:r}=(0,s.default)(),{isMobile:i}=(0,k.useMediaQuery)(),[o,d]=(0,n.useState)(!1),{watch:c,setValue:u}=(0,l.useFormContext)(),m=c(),x=(0,n.useMemo)(()=>[...i?e3:[],...e5].filter(t=>"partnerId"===t.key?!!r:"linkRetentionCleanupDisabledAt"!==t.key||!!a?.find(e=>e.slug===m.domain)?.linkRetentionDays&&"page"===e),[m,i,a,r,e]),{ABTestingModal:h,setShowABTestingModal:f}=eh(),{PasswordModal:g,setShowPasswordModal:j}=e_(),{TargetingModal:v,setShowTargetingModal:y}=eY(),{ExpirationModal:w,setShowExpirationModal:N}=ek(),{AdvancedModal:C,setShowAdvancedModal:S}=function(){let[e,s]=(0,n.useState)(!1),a=(0,n.useCallback)(()=>(0,t.jsx)(eg,{showAdvancedModal:e,setShowAdvancedModal:s}),[e,s]);return(0,n.useMemo)(()=>({setShowAdvancedModal:s,AdvancedModal:a}),[s,a])}(),{PartnersModal:T,setShowPartnerModal:D}
9=function(){let[e,s]=(0,n.useState)(!1),a=(0,n.useCallback)(()=>(0,t.jsx)(eM,{showPartnerModal:e,setShowPartnerModal:s}),[e,s]);return(0,n.useMemo)(()=>({setShowPartnerModal:s,PartnersModal:a}),[s,a])}(),M={testVariants:f,password:j,targeting:y,expiresAt:N,advanced:S,partnerId:D};return b(x.map(({shortcutKey:e})=>e),e=>{let t=x.find(({shortcutKey:t})=>t===e.key);if(!t)return;let s="enabled"in t&&"function"==typeof t.enabled?t.enabled(m):m[t.key];d(!1),"modal"===t.type?M[t.key]?.(!0):s&&t.remove?t.remove(u):!s&&t.enable?t.enable(u):u(t.key,!m[t.key],{shouldDirty:!0})},{priority:1}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h,{}),(0,t.jsx)(g,{}),(0,t.jsx)(v,{}),(0,t.jsx)(w,{}),(0,t.jsx)(C,{}),(0,t.jsx)(T,{}),(0,t.jsx)(p.Popover,{align:"start",content:(0,t.jsx)("div",{className:"grid p-1 max-sm:w-full md:min-w-80",children:x.map(e=>{let s="enabled"in e&&"function"==typeof e.enabled?e.enabled(m):m[e.key];return(0,t.jsx)(p.Button,{type:"button",variant:"outline",onClick:()=>{d(!1),"modal"===e.type?M[e.key]?.(!0):s&&e.remove?e.remove(u):!s&&e.enable?e.enable(u):u(e.key,!s,{shouldDirty:!0})},className:"h-9 w-full justify-start px-2 text-sm text-neutral-700",textWrapperClassName:"grow",text:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(e.icon,{className:(0,L.cn)("mr-1 size-4 text-neutral-950",s&&"text-blue-500")}),e.badgeLabel?.(m)??(0,t.jsxs)(t.Fragment,{children:["modal"===e.type?s||"add"in e&&!1===e.add?"":"Add ":s?"Remove ":"Add ",e.label]}),e.description&&(0,t.jsx)(ej.ProBadgeTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:e.description,...e.learnMoreUrl&&{cta:"Learn more.",href:e.learnMoreUrl}})})]}),(0,t.jsx)("kbd",{className:"hidden size-6 cursor-default items-center justify-center rounded-md border border-neutral-200 font-sans text-xs text-neutral-800 sm:flex",children:e.shortcutKey.toUpperCase()})]})},e.key)})}),openPopover:o,setOpenPopover:d,children:(0,t.jsx)(p.Button,{variant:"secondary",icon:(0,t.jsx)(eX.Dots,{className:"size-4"}),className:"h-8 w-fit px-2"})})]})}var e7=e.i(789320),e6=e.i(774243),e9=e.i(496379);function e8({onLoad:e,disabledTooltip:a}){let{id:r}=(0,s.default)(),{setValue:i,getValues:o}=(0,l.useFormContext)(),{data:d}=(0,eC.default)(r&&`/api/utm?workspaceId=${r}`,eN.fetcher,{dedupingInterval:6e4});return(0,t.jsx)(p.Combobox,{selected:null,setSelected:t=>{if(!t)return;let s=d?.find(e=>e.id===t.value);if(!s)return;let a=Object.entries(s).filter(([e])=>"ref"===e||e.startsWith("utm_")).map(([e,t])=>[e,(t||"").toString()]);a.forEach(([e,t])=>i(e,t,{shouldDirty:!0})),e(Object.fromEntries(a))},options:d?.map(e=>({label:e.name,value:e.id})),optionRight:({value:e})=>{let s=d?.find(t=>t.id===e);if(!s)return null;let a=p.UTM_PARAMETERS.filter(({key:e})=>s[e]);return(0,t.jsx)(p.Tooltip,{content:(0,t.jsx)("div",{className:"grid max-w-[225px] grid-cols-[1fr,minmax(0,min-content)] gap-x-2 gap-y-1 whitespace-nowrap p-2 text-sm sm:min-w-[150px]",children:a.map(({key:e,label:a,icon:r})=>(0,t.jsxs)(n.Fragment,{children:[(0,t.jsx)("span",{className:"font-medium text-neutral-600",children:a}),(0,t.jsx)("span",{className:"truncate text-neutral-500",children:s[e]})]},e))}),children:(0,t.jsx)("div",{className:"ml-4 flex shrink-0 items-center gap-1 text-neutral-500",children:a.map(({icon:e})=>(0,t.jsx)(e,{className:"size-3.5"}))})})},placeholder:"Templates",searchPlaceholder:"Load or save a template...",emptyState:(0,t.jsx)(te,{}),icon:e7.DiamondTurnRight,createLabel:e=>`Save new template: "${e}"`,onCreate:async e=>{try{let t=await fetch(`/api/utm?workspaceId=${r}`,{method:"POST",body:JSON.stringify({name:e,...(0,eq.getParamsFromURL)(o("url"))})});if(!t.ok){let{error:e}=await t.json();return U.toast.error(e.message),!1}return(0,e9.mutate)(`/api/utm?workspaceId=${r}`),U.toast.success("Template saved successfully"),!0}catch(e){console.error(e),U.toast.error("Failed to save UTM template")}return!1},buttonProps:{className:"w-fit px-2",disabledTooltip:a},inputClassName:"md:min-w-[200px]",optionClassName:"md:min-w-[250px] md:max-w-[350px]",caret:!0})}let te=()=>{(0,e6.useRouter)();let{slug:e}=(0,s.default)();return(0,t.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-2 py-4 text-center text-sm",children:[(0,t.jsx)("div",{className:"flex items-center justify-center rounded-2xl border border-neutral-200 bg-neutral-50 p-3",children:(0,t.jsx)(e7.DiamondTurnRight,{className:"size-6 text-neutral-700"})}),(0,t.jsx)("p",{className:"mt-2 font-medium text-neutral-950",children:"No UTM templates found"}),(0,t.jsx)("p",{className:"mx-auto mt-1 w-full max-w-[180px] text-neutral-700",children:"Add a UTM template to easily create links with the same UTM parameters."}),(0,t.jsx)("div",{children:(0,t.jsx)(p.Button,{className:"mt-1 h-8",onClick:()=>window.open(`/${e}/settings/library/utm`,"_blank"),text:"Add UTM template"})})]})};function tt(e){return(0,t.jsx)(p.Modal,{showModal:e.showUTMModal,setShowModal:e.setShowUTMModal,className:"px-5 py-4 sm:max-w-md",children:(0,t.jsx)(ts,{...e})})}function ts({setShowUTMModal:e}){let{getValues:s,setValue:a}=(0,l.useFormContext)(),r=(0,l.useForm)({values:{url:s("url"),utm_source:s("utm_source"),utm_medium:s("utm_medium"),utm_campaign:s("utm_campaign"),utm_term:s("utm_term"),utm_content:s("utm_content")}}),{watch:i,setValue:o,reset:d,formState:{isDirty:c},handleSubmit:u}=r,m=i("url"),x=(0,n.useMemo)(()=>(0,eq.getParamsFromURL)(m),[m]),h=(0,n.useCallback)(e=>{let[t,r,n,l]=s(["url","ios","android","geo"]),i=s=>{let a=(0,eq.getParamsFromURL)(t),r=(0,eq.getParamsFromURL)(s),n=p.UTM_PARAMETERS.filter(({key:e})=>a?.[e]===r?.[e]).map(({key:t})=>[t,e[t]??""]);return n.length?Object.fromEntries(n):null};if(Object.entries({ios:r,android:n}
9).forEach(([e,t])=>{if(!t)return;let s=i(t);s&&a(e,(0,eV.constructURLFromUTMParams)(t,s),{shouldDirty:!0})}),l&&Object.keys(l).length>0){let e=Object.entries(l).reduce((e,[t,s])=>{if(!t?.trim()||!s?.trim())return e;let a=i(s);return a?{...e,[t]:(0,eV.constructURLFromUTMParams)(s,a)}:e},{});Object.keys(e).length>0&&a("geo",{...l,...e},{shouldDirty:!0})}},[]);return(0,t.jsxs)("form",{onSubmit:t=>{t.stopPropagation(),u(t=>{h(t),a("url",t.url),p.UTM_PARAMETERS.filter(e=>"ref"!==e.key).forEach(e=>a(e.key,t[e.key],{shouldDirty:!0})),e(!1)})(t)},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-lg font-medium",children:"UTM Builder"}),(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Add UTM parameters to your short links for conversion tracking.",cta:"Learn more.",href:"https://trailmory.com/help/article/utm-builder"})})]}),(0,t.jsx)("div",{className:"max-md:hidden",children:(0,t.jsx)(p.Tooltip,{content:(0,t.jsxs)("div",{className:"px-2 py-1 text-xs text-neutral-700",children:["Press"," ",(0,t.jsx)("strong",{className:"font-medium text-neutral-950",children:"U"})," to open this quickly"]}),side:"right",children:(0,t.jsx)("kbd",{className:"flex size-6 cursor-default items-center justify-center rounded-md border border-neutral-200 font-sans text-xs text-neutral-950",children:"U"})})})]}),(0,t.jsx)("div",{className:"py-4",children:(0,t.jsx)(p.UTMBuilder,{values:x,onChange:(e,t)=>
9{"ref"!==e&&o(e,t,{shouldDirty:!0}),o("url",(0,eV.constructURLFromUTMParams)(m,{...x,[e]:t}),{shouldDirty:!0})},disabledTooltip:(0,eo.isValidUrl)(m)?void 0:"Enter a destination URL to add UTM parameters",autoFocus:!0})}),(0,eo.isValidUrl)(m)&&(0,t.jsxs)("div",{className:"mt-4 grid gap-y-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-neutral-700",children:"URL Preview"}),(0,t.jsx)("div",{className:"scrollbar-hide mt-2 overflow-scroll break-words rounded-lg border border-neutral-200 bg-neutral-50 px-2.5 py-2 font-mono text-xs text-neutral-500",children:m})]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{children:(0,t.jsx)(l.FormProvider,{...r,children:(0,t.jsx)(e8,{onLoad:e=>{o("url",(0,eV.constructURLFromUTMParams)(m,e),{shouldDirty:!0})},disabledTooltip:(0,eo.isValidUrl)(m)?void 0:"Enter a destination URL to use UTM templates"})})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",text:"Cancel",className:"h-9 w-fit",onClick:()=>{d(),e(!1)}}),(0,t.jsx)(p.Button,{type:"submit",variant:"primary",text:"Save",className:"h-9 w-fit",disabled:!c})]})]})]})}function ta({setShowUTMModal:e}){let{watch:s}=(0,l.useFormContext)(),a=s("url"),r=(0,n.useMemo)(()=>Object.keys((0,eq.getParamsFromURL)(a)).some(e=>-1!==p.UTM_PARAMETERS.findIndex(t=>t.key===e)),[a]);return b("u",()=>e(!0)),(0,t.jsx)(p.Button,{variant:"secondary",text:"UTM",icon:(0,t.jsx)(e7.DiamondTurnRight,{className:(0,L.cn)("size-4",r&&"text-blue-500")}),className:"h-8 w-fit gap-1.5 px-2.5 text-xs font-medium text-neutral-700",onClick:()=>e(!0)})}function tr({variant:e="page",className:a}){let{flags:r}=(0,s.default)(),{UTMModal:l,UTMButton:i}=function(){let[e,s]=(0,n.useState)(!1),a=(0,n.useCallback)(()=>(0,t.jsx)(tt,{showUTMModal:e,setShowUTMModal:s}),[e,s]),r=(0,n.useCallback)(()=>(0,t.jsx)(ta,{setShowUTMModal:s}),[s]);return(0,n.useMemo)(()=>({setShowUTMModal:s,UTMModal:a,UTMButton:r}),[s,a,r])}(),{ExpirationModal:o,ExpirationButton:d}=ek(),{TargetingModal:c,TargetingButton:u}=eY(),{PasswordModal:m,PasswordButton:x}=e_(),{ABTestingModal:p,ABTestingButton:h}=eh();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m,{}),(0,t.jsx)(l,{}),(0,t.jsx)(c,{}),(0,t.jsx)(o,{})," ",(0,t.jsx)(p,{}),(0,t.jsxs)("div",{className:(0,L.cn)("flex min-w-0 items-center gap-2",a),children:[(0,t.jsx)(i,{}),(0,t.jsx)("div",{className:"contents max-[380px]:hidden",children:(0,t.jsx)(u,{})}),(0,t.jsxs)("div",{className:(0,L.cn)("contents max-sm:hidden","page"===e&&"max-[960px]:hidden"),children:[(0,t.jsx)(h,{}),(0,t.jsx)(x,{}),(0,t.jsx)(d,{})]}),(0,t.jsx)(e4,{variant:e})]})]})}e.s(["LinkFeatureButtons",()=>tr],722725);var tn=e.i(838596),tl=e.i(709697),ti=e.i(500107),to=j,td=(e,t={width:1200,height:630,quality:1})=>new Promise((s,a)=>{let r=new FileReader;r.onload=e=>{let r=new Image;r.src=e.target?.result,r.onload=()=>{let e=t.width,a=t.height,n=document.createElement("canvas");n.width=e,n.height=a;let l=n.getContext("2d");l.imageSmoothingQuality="high";let i=r.width,o=r.height,d=e/a,c,u,m=0,x=0;i/o>d?(u=o,m=(i-(c=o*d))/2):(c=i,x=(o-(u=i/d))/2),l.drawImage(r,m,x,c,u,0,0,e,a),s(n.toDataURL("image/jpeg",t.quality))},r.onerror=e=>a(Error("Image loading error: "+e))},r.onerror=e=>a(Error("FileReader error: "+e)),r.readAsDataURL(e)}),tc=e.i(435524),tu=e.i(807166);function tm({showPromptModal:e,setShowPromptModal:s,title:a,label:r,description:l,onSubmit:i,inputProps:o,buttonProps:d}){let{isMobile:c}=(0,k.useMediaQuery)(),[u,m]=(0,n.useState)(""),[x,h]=(0,n.useState)(!1);return(0,t.jsxs)(p.Modal,{showModal:e,setShowModal:s,children:[(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-3 border-b border-neutral-200 px-4 py-4 pt-8 text-center sm:px-16",children:[(0,t.jsx)(p.LinkLogo,{}),(0,t.jsx)("h3",{className:"text-lg font-medium",children:a}),l&&(0,t.jsx)("p",{className:"text-sm text-neutral-500",children:l})]}),(0,t.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),e.stopPropagation(),h(!0),await i?.(u),h(!1),s(!1)},className:"flex flex-col space-y-3 bg-neutral-50 px-4 py-8 text-left sm:px-16",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("p",{className:"text-sm text-neutral-700",children:r}),(0,t.jsx)("div",{className:"relative mt-1 rounded-md shadow-sm",children:(0,t.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),required:!0,autoFocus:!c,autoComplete:"off",className:"block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",...o})})]}),(0,t.jsx)(p.Button,{variant:"primary",text:"Submit",loading:x,...d})]})]})}var tx=e.i(237240);function tp({onImageSelected:e,setOpenPopover:s}
9){let[a,r]=(0,n.useState)(""),[l]=(0,I.useDebounce)(a,500),{data:i}=(0,eC.default)(`/api/unsplash/search?query=${l.length>0?l:"beautiful landscape photos"}`,eN.fetcher,{onError:e=>{U.toast.error(e.message)}}),{isMobile:o}=(0,k.useMediaQuery)();return(0,t.jsxs)("div",{className:"h-[24rem] w-full overflow-auto p-3 md:w-[24rem]",style:{WebkitClipPath:"inset(0 0 0 0)"},children:[(0,t.jsx)("div",{className:"relative mt-1 rounded-md shadow-sm",children:(0,t.jsx)("input",{type:"text",name:"search",id:"search",placeholder:"Search for an image...",autoFocus:!o,autoComplete:"off",value:a,onChange:e=>r(e.target.value),className:"block w-full rounded-md border-neutral-300 py-1 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"})}),i?i.length>0?(0,t.jsx)("div",{className:"mt-3 grid grid-cols-2 gap-3",children:i.map(a=>(0,t.jsxs)("button",{type:"button",onClick:()=>{e(a.urls.regular),s(!1),fetch("/api/unsplash/download",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a.links.download_location})})},className:"relative flex h-24 w-full items-center justify-center overflow-hidden rounded-md bg-neutral-100 transition-all hover:brightness-75",children:[(0,t.jsx)("img",{src:a.urls.small,alt:a.alt_description||"Unsplash image",className:"absolute h-full w-full object-cover"}),(0,t.jsxs)("p",{className:"absolute bottom-0 left-0 right-0 line-clamp-1 w-full bg-black bg-opacity-10 p-1 text-xs text-white",children:["by"," ",(0,t.jsx)("a",{className:"underline underline-offset-2",target:"_blank",rel:"noopener noreferrer",href:`${a.user.links.html}?utm_source=dub.co&utm_medium=referral`,children:a.user.name})]})]},a.id))}):(0,t.jsx)("div",{className:"flex h-[90%] items-center justify-center",children:(0,t.jsxs)("p",{className:"text-center text-sm text-neutral-500",children:["No results found. ",(0,t.jsx)("br",{})," Maybe try tweaking your search query?"]})}):(0,t.jsx)("div",{className:"flex h-[90%] items-center justify-center",children:(0,t.jsx)(tx.LoadingSpinner,{})})]})}function th({showOGModal:e,setShowOGModal:s}){return e?(0,t.jsx)(tf,{showOGModal:e,setShowOGModal:s}):null}function tf({showOGModal:e,setShowOGModal:a}){let{id:r,plan:i,exceededAI:o,mutate:d}=(0,s.default)(),{generatingMetatags:c}=u(),{getValues:m,watch:x,setValue:f}=(0,l.useFormContext)(),{watch:g,setValue:j,reset:b,handleSubmit:v,formState:{isDirty:y}}=(0,l.useForm)({defaultValues:{image:m("image"),title:m("title"),description:m("description"),proxy:m("proxy")}}),w=x("url"),{image:k,title:N,description:C}=g(),{setShowPromptModal:T,PromptModal:L}=function(e){let[s,a]=(0,n.useState)(!1),r=(0,n.useCallback)(()=>e?(0,t.jsx)(tm,{showPromptModal:s,setShowPromptModal:a,...e}):null,[s,a]);return(0,n.useMemo)(()=>({setShowPromptModal:a,PromptModal:r}),[a,r])}({title:"Use image from URL",description:"Paste an image URL to use for your link's social media cards.",label:"Image URL",inputProps:{type:"url",placeholder:"https://example.com/og.png"},onSubmit:e=>{e&&(j("image",e,{shouldDirty:!0}),i&&"free"!==i&&j("proxy",!0,{shouldDirty:!0}))}}),[D,M]=(0,n.useState)(!1),[P,A]=(0,n.useState)(!1),{completion:R,isLoading:I,complete:F}=(0,tc.useCompletion)({api:`/api/ai/completion?workspaceId=${r}`,onError:e=>{e.message.includes("Upgrade to Pro")?U.toast.custom(()=>(0,t.jsx)(tl.UpgradeRequiredToast,{title:"You've exceeded your AI usage limit",message:e.message})):U.toast.error(e.message)},onFinish:(e,t)=>{d(),tu.default.capture("ai_meta_title_generated",{title:t,url:w})}}),E=async()=>{F(`You are an SEO expert. Generate an SEO-optimized meta title (max 120 characters) for the following URL:
10      
11      - URL: ${w}
12      - Meta title: ${N}
13      - Meta description: ${C}. 
14
15      Only respond with the title without quotation marks or special characters.
16      `)};(0,n.useEffect)(()=>{R&&(j("title",R,{shouldDirty:!0}),i&&"free"!==i&&j("proxy",!0,{shouldDirty:!0}))},[R]);let{completion:B,isLoading:z,complete:_}=(0,tc.useCompletion)({api:`/api/ai/completion?workspaceId=${r}`,onError:e=>{e.message.includes("Upgrade to Pro")?U.toast.custom(()=>(0,t.jsx)(tl.UpgradeRequiredToast,{title:"You've exceeded your AI usage limit",message:e.message})):U.toast.error(e.message)},onFinish:(e,t)=>{d(),tu.default.capture("ai_meta_description_generated",{description:t,url:w})}}),$=async()=>
16{_(`You are an SEO expert. Generate an SEO-optimized meta description (max 240 characters) for the following URL:
17
18      - URL: ${w}
19      - Meta title: ${N}
20      - Meta description: ${C}.
21
22      Only respond with the description without quotation marks or special characters.`)};return(0,n.useEffect)(()=>{B&&(j("description",B,{shouldDirty:!0}),i&&"free"!==i&&j("proxy",!0,{shouldDirty:!0}))},[B]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(L,{}),(0,t.jsx)(p.Modal,{showModal:e,setShowModal:a,className:"sm:max-w-[500px]",children:(0,t.jsxs)("form",{className:"px-5 py-4",onSubmit:e=>{e.stopPropagation(),v(async e=>{a(!1),["image","title","description","proxy"].forEach(t=>f(t,e[t],{shouldDirty:!0}))})(e)},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-lg font-medium",children:"Link Preview"}),(0,t.jsx)(ej.ProBadgeTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Customize how your links look when shared on social media to improve click-through rates. When enabled, the preview settings below will be shown publicly (instead of the URL's original metatags).",cta:"Learn more.",href:"https://trailmory.com/help/article/custom-link-previews"})})]}),(0,t.jsx)("div",{className:"max-md:hidden",children:(0,t.jsx)(p.Tooltip,{content:(0,t.jsxs)("div",{className:"px-2 py-1 text-xs text-neutral-700",children:["Press"," ",(0,t.jsx)("strong",{className:"font-medium text-neutral-950",children:"L"})," ","to open this quickly"]}),side:"right",children:(0,t.jsx)("kbd",{className:"flex size-6 cursor-default items-center justify-center rounded-md border border-neutral-200 font-sans text-xs text-neutral-950",children:"L"})})})]}),(0,t.jsxs)("div",{className:"scrollbar-hide -m-1 mt-6 flex max-h-[calc(100dvh-250px)] flex-col gap-6 overflow-y-auto p-1",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-neutral-700",children:"Image"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[k&&(0,t.jsx)("button",{type:"button",className:"text-xs font-medium text-neutral-700 transition-colors hover:text-neutral-950",onClick:()=>{j("image",null,{shouldDirty:!0}),j("proxy",!1,{shouldDirty:!0})},children:"Remove"}),(0,t.jsx)(p.ButtonTooltip,{onClick:()=>T(!0),tooltipProps:{content:"Paste a URL to an image"},children:(0,t.jsx)(tn.Link,{className:"size-4"})}),(0,t.jsx)(p.Popover,{content:(0,t.jsx)(tp,{onImageSelected:e=>{j("image",e,{shouldDirty:!0}),i&&"free"!==i&&j("proxy",!0,{shouldDirty:!0})},setOpenPopover:M}),openPopover:D,setOpenPopover:M,children:(0,t.jsx)("div",{children:(0,t.jsx)(p.ButtonTooltip,{onClick:()=>M(!0),tooltipProps:{content:"Choose an image from Unsplash"},children:(0,t.jsx)(to.H,{className:"size-3 text-neutral-500"})})})})]})]}),(0,t.jsx)(p.FileUpload,{accept:"images",variant:"default",imageSrc:k,onChange:async({file:e})=>{A(!0),j("image",await td(e),{shouldDirty:!0}),i&&"free"!==i&&j("proxy",!0,{shouldDirty:!0}),setTimeout(()=>A(!1),500)},loading:c||P,clickToUpload:!0,showHoverOverlay:!1,accessibilityLabel:"OG image upload",className:"mt-2",content:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{children:"Drag and drop or click to upload."}),(0,t.jsx)("p",{className:"mt-1",children:"Recommended: 1200 x 630 pixels"})]})})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("p",{className:"block text-sm font-medium text-neutral-700",children:"Title"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("p",{className:"text-sm text-neutral-500",children:[N?.length||0,"/120"]}),(0,t.jsx)(p.ButtonTooltip,{tooltipProps:{content:o?"You've exceeded your AI usage limit":N?"Generate an optimized title using AI.":"Enter a title to generate a preview"},onClick:E,disabled:I||o||!N,children:I?(0,t.jsx)(S.LoadingCircle,{}):(0,t.jsx)(ti.Magic,{className:"size-4"})})]})]}),(0,t.jsxs)("div",{className:"relative mt-1 flex rounded-md shadow-sm",children:[c&&(0,t.jsx)("div",{className:"absolute flex h-full w-full items-center justify-center rounded-md border border-neutral-300 bg-white",children:(0,t.jsx)(S.LoadingCircle,{})}),(0,t.jsx)(h.default,{name:"title",id:"title",minRows:2,maxLength:120,className:"block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",placeholder:"Add a title...",value:N||"",onChange:e=>{j("title",e.target.value,{shouldDirty:!0}),i&&"free"!==i&&j("proxy",!0,{shouldDirty:!0})},"aria-invalid":"true"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("p",{className:"block text-sm font-medium text-neutral-700",children:"Description"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("p",{className:"text-sm text-neutral-500",children:[C?.length||0,"/240"]}),(0,t.jsx)(p.ButtonTooltip,{tooltipProps:{content:o?"You've exceeded your AI usage limit":C?"Generate an optimized description using AI.":"Enter a description to generate a preview"},onClick:$,disabled:z||o||!C,children:z?(0,t.jsx)(S.LoadingCircle,{}):(0,t.jsx)(ti.Magic,{className:"size-4"})})]})]}),(0,t.jsxs)("div",{className:"relative mt-1 flex rounded-md shadow-sm",children:[c&&(0,t.jsx)("div",{className:"absolute flex h-full w-full items-center justify-center rounded-md border border-neutral-300 bg-white",children:(0,t.jsx)(S.LoadingCircle,{})}),(0,t.jsx)(h.default,{name:"description",id:"description",minRows:3,maxLength:240,className:"block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",placeholder:"Add a description...",value:C||"",onChange:e=>{j("description",e.target.value,{shouldDirty:!0}),i&&"free"!==i&&j("proxy",!0,{shouldDirty:!0})},"aria-invalid":"true"})]})]})]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,t.jsx)("button",{type:"button",className:"text-xs font-medium text-neutral-700 transition-colors hover:text-neutral-950",onClick:()=>{f("proxy",!1,{shouldDirty:!0}
22),["title","description","image"].forEach(e=>f(e,null,{shouldDirty:!0})),a(!1)},children:"Reset to default"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",text:"Cancel",className:"h-9 w-fit",onClick:()=>{b(),a(!1)}}),(0,t.jsx)(p.Button,{type:"submit",variant:"primary",text:"Save changes",className:"h-9 w-fit",disabled:!y})]})]})]})})]})}var tg=j,tj=e.i(842610),tb=e.i(248427),tv=j,ty=e.i(749073),tw=e.i(928818),tk=e.i(812094);let tN=["default","x","linkedin","facebook"],tC={default:"Default",facebook:"Facebook",linkedin:"LinkedIn",x:"X/Twitter"},tS={default:tj.GlobePointer,x:tw.Twitter,linkedin:tb.LinkedIn,facebook:tg.x},tT={default:function({title:e,description:a,children:r}){let{plan:n}=(0,s.default)(),{setValue:i}=(0,l.useFormContext)();return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"group relative overflow-hidden rounded-md border border-neutral-300",children:r}),(0,t.jsx)(h.default,{className:"mt-4 line-clamp-2 w-full resize-none border-none bg-transparent p-0 text-xs font-medium text-neutral-700 outline-none focus:ring-0",value:e||"Add a title...",maxRows:2,onChange:e=>{i("title",e.currentTarget.value,{shouldDirty:!0}),n&&"free"!==n&&i("proxy",!0,{shouldDirty:!0})}}),(0,t.jsx)(h.default,{className:"mt-1.5 line-clamp-2 w-full resize-none border-none bg-transparent p-0 text-xs text-neutral-700/80 outline-none focus:ring-0",value:a||"Add a description...",maxRows:2,onChange:e=>{i("description",e.currentTarget.value,{shouldDirty:!0}),n&&"free"!==n&&i("proxy",!0,{shouldDirty:!0})}})]})},x:function({title:e,hostname:s,children:a}){return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"group relative overflow-hidden rounded-2xl border border-neutral-300",children:[a,(0,t.jsx)("div",{className:"absolute bottom-2 left-0 w-full px-2",children:(0,t.jsx)("div",{className:"w-fit max-w-full rounded bg-black/[0.77] px-1.5 py-px",children:(0,t.jsx)("span",{className:"block max-w-sm truncate text-xs text-white",children:e||"Add a title..."})})})]}),s&&(0,t.jsxs)("p",{className:"mt-1 text-xs text-[#606770]",children:["From ",s]})]})},linkedin:function({title:e,hostname:a,children:r}){let{plan:n}=(0,s.default)(),{setValue:i}=(0,l.useFormContext)();return(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-[#8c8c8c33] px-4 py-3",children:[(0,t.jsx)("div",{className:"relative w-32 shrink-0 overflow-hidden rounded-lg",style:{"--aspect":"128/72"},children:r}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(h.default,{className:"line-clamp-2 w-full resize-none border-none p-0 text-sm font-semibold text-[#000000E6] outline-none focus:ring-0",value:e||"Add a title...",maxRows:2,onChange:e=>{i("title",e.currentTarget.value,{shouldDirty:!0}),n&&"free"!==n&&i("proxy",!0,{shouldDirty:!0})}}),(0,t.jsx)("p",{className:"text-xs text-[#00000099]",children:a||"domain.com"})]})]})},facebook:function({title:e,description:a,hostname:r,children:n}){let{plan:i}=(0,s.default)(),{setValue:o}=(0,l.useFormContext)();return(0,t.jsx)("div",{children:(0,t.jsxs)("div",{className:"relative border border-neutral-300",children:[n,(r||e||a)&&(0,t.jsxs)("div",{className:"grid gap-1 border-t border-neutral-300 bg-[#f2f3f5] p-2",children:[r&&(0,t.jsx)("p",{className:"text-xs uppercase text-[#606770]",children:r}),(0,t.jsx)("input",{className:"truncate border-none bg-transparent p-0 text-xs font-semibold text-[#1d2129] outline-none focus:ring-0",value:e||"Add a title...",onChange:e=>{o("title",e.currentTarget.value,{shouldDirty:!0}),i&&"free"!==i&&o("proxy",!0,{shouldDirty:!0})}}),(0,t.jsx)(h.default,{className:"mb-1 line-clamp-2 w-full resize-none rounded-md border-none bg-neutral-200 bg-transparent p-0 text-xs text-[#606770] outline-none focus:ring-0",value:a||"Add a description...",maxRows:2,onChange:e=>{o("description",e.currentTarget.value,{shouldDirty:!0}),i&&"free"!==i&&o("proxy",!0,{shouldDirty:!0})}})]})]})})}},tL=(0,n.memo)(()=>{let{slug:e,plan:a}=(0,s.default)(),{control:r,setValue:i}=(0,l.useFormContext)(),[o,d,c,u,m,x]=(0,l.useWatch)({control:r,
22name:["proxy","title","description","image","url","password"]}),[h]=(0,I.useDebounce)(m,500),f=(0,n.useMemo)(()=>x?"dub.co":(0,tk.getDomainWithoutWWW)(h)??null,[x,h]),{OGModal:j,setShowOGModal:v}=function(){let[e,s]=(0,n.useState)(!1),a=(0,n.useCallback)(()=>(0,t.jsx)(th,{showOGModal:e,setShowOGModal:s}),[e,s]);return(0,n.useMemo)(()=>({setShowOGModal:s,OGModal:a}),[s,a])}();b("l",()=>v(!0));let[y,w]=(0,n.useState)("default"),k=tT[y];return(0,t.jsxs)("div",{children:[(0,t.jsx)(j,{}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-neutral-700",children:"Custom Link Preview"}),(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Customize how your links look when shared on social media to improve click-through rates. When enabled, the preview settings below will be shown publicly (instead of the URL's original metatags).",cta:"Learn more.",href:"https://trailmory.com/help/article/custom-link-previews"})})]}),(0,t.jsx)(p.Switch,{checked:o,fn:e=>i("proxy",e,{shouldDirty:!0}),disabledTooltip:m?a&&"free"!==a?void 0:(0,t.jsx)(p.TooltipContent,{title:"Custom Link Previews are only available on the Pro plan and above.",cta:"Upgrade to Pro",href:e?`/${e}/upgrade`:"https://trailmory.com/pricing",target:"_blank"}):"Enter a URL to enable custom link previews.",thumbIcon:a&&"free"!==a?void 0:(0,t.jsx)(g.CrownSmall,{className:"size-full text-neutral-500"})})]}),(0,t.jsx)("div",{className:"mt-2.5 grid grid-cols-4 gap-2",children:tN.map(e=>{let s=tS[e];return(0,t.jsx)(p.Button,{variant:"secondary",onClick:()=>w(e),icon:(0,t.jsx)(s,{className:"size-4 text-current",fill:"currentColor"}),className:(0,L.cn)("h-7 text-neutral-800",e===y?"border-neutral-400 bg-white drop-shadow-sm":"border-neutral-300 bg-transparent hover:bg-white"),title:tC[e]},e)})}),(0,t.jsxs)("div",{className:"relative z-0 mt-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",icon:(0,t.jsx)(ty.Pen2,{className:"mx-px size-4"}),className:"absolute right-2 top-2 z-10 h-8 w-fit px-1.5",onClick:()=>v(!0)}),(0,t.jsx)(k,{title:d,description:c,hostname:f,password:x,children:(0,t.jsx)(tD,{image:u,onImageChange:e=>{i("image",e,{shouldDirty:!0}),i("proxy",!0)}})})]})]})});tL.displayName="LinkPreview";let tD=({image:e,onImageChange:s})=>{let{isMobile:a}=(0,k.useMediaQuery)(),{generatingMetatags:r}=u(),l=(0,n.useRef)(null),[i,o]=(0,n.useState)(!1),d=(0,n.useCallback)(async e=>{let t=e.target.files&&e.target.files[0];t&&(t.size/1024/1024>2?U.toast.error("File size too big (max 2 MB)"):(o(!0),s(await td(t)),setTimeout(()=>o(!1),500)))},[]),c=(0,n.useMemo)(()=>r||i?(0,t.jsx)("div",{className:"flex aspect-[var(--aspect,1200/630)] w-full flex-col items-center justify-center bg-neutral-100",children:(0,t.jsx)(S.LoadingCircle,{})}):e?(0,t.jsx)(p.FileUpload,{accept:"images",variant:"plain",imageSrc:e,onChange:async({file:e})=>{o(!0),s(await td(e)),setTimeout(()=>o(!1),500)},loading:r||i,clickToUpload:!1,showHoverOverlay:!1,accessibilityLabel:"OG image upload"}):(0,t.jsxs)("div",{className:"relative aspect-[var(--aspect,1200/630)] w-full bg-white",children:[(0,t.jsx)("div",{className:"absolute inset-0 opacity-0",children:(0,t.jsx)(p.FileUpload,{accept:"images",variant:"plain",imageSrc:e,onChange:async({file:e})=>{o(!0),s(await td(e)),setTimeout(()=>o(!1),500)},loading:r||i,clickToUpload:!1,showHoverOverlay:!1,accessibilityLabel:"OG image upload"})}),!a&&(0,t.jsx)(p.ShimmerDots,{className:"pointer-events-none opacity-30 [mask-image:radial-gradient(40%_80%,transparent_50%,black)]"}),(0,t.jsxs)("div",{className:"pointer-events-none relative flex size-full flex-col items-center justify-center gap-2",children:[(0,t.jsx)(tv.Hd,{className:"size-5 text-neutral-700"}),(0,t.jsx)("p",{className:"max-w-32 text-center text-xs text-neutral-700",children:"Enter a link to generate a preview"})]})]}),[e,r,i]);return(0,t.jsxs)(t.Fragment,{children:[c,(0,t.jsx)("input",{ref:l,onChange:d,type:"file",accept:"image/png,image/jpeg",className:"hidden"},e)]})};e.s(["LinkPreview",0,tL],735657);var tM=e.i(535333),tP=e.i(932501),tA=e.i(902754),tR=e.i(991489);let tU=e5.filter(({type:e})=>"boolean"===e);function tI(){let{isMobile:e}=(0,k.useMediaQuery)(),{control:s,setValue:a}=(0,l.useFormContext)(),r=(0,l.useWatch)({control:s}),i=(0,n.useMemo)(()=>tU.filter(({key:e,enabled:t})=>t?t(r):r[e]),[r]),o=(0,n.useMemo)(()=>[...i,...e?e3.filter(({enabled:e})=>e?.(r)).map(e=>({...e,label:e.badgeLabel?.(r)||e.label})):[]],[i,e,r]);return o.length?(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:(0,t.jsx)(tA.AnimatePresence,{children:o.map(e=>{let s="rewrite"===e.key?tE:tF;return(0,t.jsx)(tR.motion.div,{initial:{opacity:0}
22,animate:{opacity:1},transition:{duration:.1},children:(0,t.jsx)(s,{toggle:e,..."enabled"in e&&"function"==typeof e.enabled&&e.enabled(r)&&{icon:(0,t.jsx)(e.icon,{className:"size-3.5 text-blue-500"})},onRemove:()=>"remove"in e&&"function"==typeof e.remove?e.remove(a):a(e.key,!1,{shouldDirty:!0})})},e.key)})})}):null}function tF({toggle:e,onRemove:s,icon:a}){return(0,t.jsxs)("span",{className:"group flex cursor-default items-center gap-1.5 rounded-md border border-neutral-200 bg-neutral-50 pl-1.5 text-xs text-neutral-600",children:[a,e.label,(0,t.jsx)("button",{type:"button",onClick:s,className:"-ml-1 p-1 text-neutral-400 hover:text-neutral-500",children:(0,t.jsx)(er.X,{className:"size-3.5"})})]})}function tE({toggle:e,onRemove:s}){let{watch:a}=(0,l.useFormContext)(),[r,i]=a(["url","domain"]),[o]=(0,I.useDebounce)(r,500),d=(0,n.useMemo)(()=>o&&(0,eo.isValidUrl)(o),[o]),{data:c,isLoading:u}=(0,eC.default)(i&&d?`/api/links/iframeable?domain=${i}&url=${o}`:null,eN.fetcher),m=(0,n.useMemo)(()=>(0,t.jsx)(tF,{toggle:e,onRemove:s,icon:u?(0,t.jsx)(tx.LoadingSpinner,{className:"size-3.5"}):c?c.iframeable?(0,t.jsx)(tP.CheckCircleFill,{className:"size-3.5 text-green-500"}):(0,t.jsx)(tM.AlertCircleFill,{className:"size-3.5 text-amber-500"}):null}),[c,u]);return c?(0,t.jsx)(p.Tooltip,{content:c.iframeable?(0,t.jsxs)("div",{className:"grid max-w-lg gap-2 text-pretty p-4 text-center text-sm text-neutral-700",children:[(0,t.jsx)("div",{className:"h-[250px] w-[444px] overflow-hidden rounded-lg border border-neutral-200",children:(0,t.jsx)("iframe",{src:r,style:{zoom:.5},className:"h-[500px] w-[888px]"})}),(0,t.jsx)("p",{children:"Your link will be successfully cloaked."})]}):(0,t.jsx)(p.SimpleTooltipContent,{title:"Your link is not cloakable – make sure you have the right security headers set on your target URL.",cta:"Learn more",href:"https://trailmory.com/help/article/link-cloaking#link-cloaking-with-security-headers"}),children:(0,t.jsx)("div",{children:m})}):m}e.s(["OptionsList",()=>tI],633923);var tB=e.i(200912),tz=e.i(479461),t_=e.i(434188),t$=e.i(827549),tO=e.i(933778),tV=e.i(371976),tW=e.i(561636),tq=e.i(576851),tQ=e.i(835482),tG=e.i(640280),tH=e.i(851373),tK=e.i(23652),tK=tK,tY=e.i(838137);let tX=["#000000","#C73E33","#DF6547","#F4B3D7","#F6CF54","#49A065","#2146B7","#AE49BF"];function tZ(e){return(0,t.jsx)(p.Modal,{showModal:e.showLinkQRModal,setShowModal:e.setShowLinkQRModal,className:"max-w-[500px]",children:(0,t.jsx)(tJ,{...e})})}function tJ({props:e,onSave:a,showLinkQRModal:r,setShowLinkQRModal:l}){let{id:i,slug:o,plan:d,logo:c}=(0,s.default)(),u=(0,n.useId)(),{isMobile:m}=(0,k.useMediaQuery)(),{logo:x}=(0,tB.default)({slug:e.domain,enabled:r}),h=(0,n.useMemo)(()=>e.key&&e.domain?(0,G.linkConstructor)({key:e.key,domain:e.domain}):void 0,[e.key,e.domain]),[f,j]=(0,p.useLocalStorage)(`qr-code-design-${i}`,{fgColor:"#000000",hideLogo:!1}),[b,v]=(0,n.useState)(f),y=b.hideLogo&&"free"!==d,w="free"===d?t$.DUB_QR_LOGO:x||c||t$.DUB_QR_LOGO,N=(0,n.useMemo)(()=>h?(0,tO.getQRData)({url:h,fgColor:b.fgColor,hideLogo:y,logo:w}):null,[h,b,y,w]),C=(0,I.useDebouncedCallback)(e=>v(t=>({...t,fgColor:e})),500);return(0,t.jsxs)("form",{className:"flex flex-col gap-6 p-4",onSubmit:e=>{e.preventDefault(),e.stopPropagation(),l(!1),j(b),a?.(b)},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-lg font-medium",children:"QR Code"}),(0,t.jsx)(ej.ProBadgeTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Set a custom QR code design to improve click-through rates.",cta:"Learn more.",href:"https://trailmory.com/help/article/custom-qr-codes"})})]}),(0,t.jsx)("div",{className:"max-md:hidden",children:(0,t.jsx)(p.Tooltip,{content:(0,t.jsxs)("div",{className:"px-2 py-1 text-xs text-neutral-700",children:["Press"," ",(0,t.jsx)("strong",{className:"font-medium text-neutral-950",children:"Q"})," to open this quickly"]}),side:"right",children:(0,t.jsx)("kbd",{className:"flex size-6 cursor-default items-center justify-center rounded-md border border-neutral-200 font-sans text-xs text-neutral-950",children:"Q"})})})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-medium text-neutral-700",children:"QR Code Preview"}),(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Customize your QR code to fit your brand.",cta:"Learn more.",href:"https://trailmory.com/help/article/custom-qr-codes"})})]}),h&&N&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(t0,{qrData:N,props:e,children:(0,t.jsx)("div",{children:(0,t.jsx)(p.ButtonTooltip,{tooltipProps:{content:"Download QR code"},children:(0,t.jsx)(tQ.Download,{className:"h-4 w-4 text-neutral-500"})})})}),(0,t.jsx)(t1,{qrData:N,props:e,children:(0,t.jsx)("div",{children:(0,t.jsx)(p.ButtonTooltip,{tooltipProps:{content:"Copy QR code"},children:(0,t.jsx)(tq.Copy,{className:"h-4 w-4 text-neutral-500"})})})})]})]}),(0,t.jsxs)("div",{className:"relative mt-2 flex h-44 items-center justify-center overflow-hidden rounded-md border border-neutral-300",children:[!m&&(0,t.jsx)(p.ShimmerDots,{className:"opacity-30 [mask-image:radial-gradient(40%_80%,transparent_50%,black)]"}),h&&(0,t.jsx)(tA.AnimatePresence,{mode:"wait",children:(0,t.jsx)(tR.motion.div,{initial:{filter:"blur(2px)",opacity:.4},animate:{filter:"blur(0px)",opacity:1},exit:{filter:"blur(2px)",opacity:.4},transition:{duration:.1},className:"relative flex size-full items-center justify-center",children:(0,t.jsx)(tz.QRCode,{url:h,fgColor:b.fgColor,hideLogo:b.hideLogo,logo:w,scale:1})}
22,b.fgColor+b.hideLogo)})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-neutral-700",htmlFor:`${u}-show-logo`,children:"Logo"}),(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Display your logo in the center of the QR code.",cta:"Learn more.",href:"https://trailmory.com/help/article/custom-qr-codes"})})]}),(0,t.jsx)(p.Switch,{id:`${u}-hide-logo`,checked:!b.hideLogo,fn:()=>{v(e=>({...e,hideLogo:!e.hideLogo}))},disabledTooltip:d&&"free"!==d?void 0:(0,t.jsx)(p.TooltipContent,{title:"You need to be on the Pro plan and above to customize your QR Code logo.",cta:"Upgrade to Pro",href:o?`/${o}/upgrade`:"https://trailmory.com/pricing",target:"_blank"}),thumbIcon:d&&"free"!==d?void 0:(0,t.jsx)(g.CrownSmall,{className:"size-full text-neutral-500"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-neutral-700",children:"QR Code Color"}),(0,t.jsxs)("div",{className:"mt-2 flex gap-6",children:[(0,t.jsxs)("div",{className:"relative flex h-9 w-32 shrink-0 rounded-md shadow-sm",children:[(0,t.jsx)(p.Tooltip,{content:(0,t.jsx)("div",{className:"flex max-w-xs flex-col items-center space-y-3 p-5 text-center",children:(0,t.jsx)(tY.HexColorPicker,{color:b.fgColor,onChange:C})}),children:(0,t.jsx)("div",{className:"h-full w-12 rounded-l-md border",style:{backgroundColor:b.fgColor,borderColor:b.fgColor}})}),(0,t.jsx)(tY.HexColorInput,{id:"color",name:"color",color:b.fgColor,onChange:C,prefixed:!0,style:{borderColor:b.fgColor},className:"block w-full rounded-r-md border-2 border-l-0 pl-3 text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-black sm:text-sm"})]}),(0,t.jsx)("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:tX.map(e=>{let s=b.fgColor===e;return(0,t.jsx)("button",{type:"button","aria-pressed":s,onClick:()=>v(t=>({...t,fgColor:e})),className:(0,L.cn)("flex size-7 items-center justify-center rounded-full transition-all",s?"ring-1 ring-black ring-offset-[3px]":"ring-black/10 hover:ring-4"),style:{backgroundColor:e},children:s&&(0,t.jsx)(tW.Check2,{className:"size-4 text-white"})},e)})})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",text:"Cancel",className:"h-9 w-fit",onClick:()=>{l(!1)}}),(0,t.jsx)(p.Button,{type:"submit",variant:"primary",text:"Save changes",className:"h-9 w-fit"})]})]})}function t0({qrData:e,props:s,children:a}){let r=(0,n.useRef)(null);function l(e,t){r.current&&(r.current.href=e,r.current.download=`${s.key}-qrcode.${t}`,r.current.click(),o(!1))}let[i,o]=(0,n.useState)(!1);return(0,t.jsxs)("div",{children:[(0,t.jsx)(p.Popover,{content:(0,t.jsxs)("div",{className:"grid p-1 sm:min-w-48",children:[(0,t.jsx)("button",{type:"button",onClick:async()=>{l(await (0,tO.getQRAsSVGDataUri)(e),"svg")},className:"rounded-md p-2 text-left text-sm font-medium text-neutral-500 transition-all duration-75 hover:bg-neutral-100",children:(0,t.jsx)(p.IconMenu,{text:"Download SVG",icon:(0,t.jsx)(tH.Photo,{className:"h-4 w-4"})})}),(0,t.jsx)("button",{type:"button",onClick:async()=>{l(await (0,tO.getQRAsCanvas)(e,"image/png"),"png")},className:"rounded-md p-2 text-left text-sm font-medium text-neutral-500 transition-all duration-75 hover:bg-neutral-100",children:(0,t.jsx)(p.IconMenu,{text:"Download PNG",icon:(0,t.jsx)(tH.Photo,{className:"h-4 w-4"})})}),(0,t.jsx)("button",{type:"button",onClick:async()=>{l(await (0,tO.getQRAsCanvas)(e,"image/jpeg"),"jpg")},className:"rounded-md p-2 text-left text-sm font-medium text-neutral-500 transition-all duration-75 hover:bg-neutral-100",children:(0,t.jsx)(p.IconMenu,{text:"Download JPEG",icon:(0,t.jsx)(tH.Photo,{className:"h-4 w-4"})})})]}),openPopover:i,setOpenPopover:o,children:a}),(0,t.jsx)("a",{className:"hidden",download:`${s.key}-qrcode.svg`,ref:r})]})}function t1({qrData:e,props:s,children:a}){let[r,l]=(0,n.useState)(!1),[i,o]=(0,p.useCopyToClipboard)(2e3),[d,c]=(0,p.useCopyToClipboard)(2e3),u=async()=>{try{(await (0,tO.getQRAsCanvas)(e,"image/png",!0)).toBlob(async function(e){let t=new ClipboardItem({"image/png":e});await c(t),l(!1)})}catch(e){throw e}};return(0,t.jsx)(p.Popover,{content:(0,t.jsxs)("div",{className:"grid p-1 sm:min-w-48",children:[(0,t.jsx)("button",{type:"button",onClick:async()=>{U.toast.promise(u,{loading:"Copying QR code to clipboard...",success:"Copied QR code to clipboard!",error:"Failed to copy"})},className:"rounded-md p-2 text-left text-sm font-medium text-neutral-500 transition-all duration-75 hover:bg-neutral-100",children:(0,t.jsx)(p.IconMenu,{text:"Copy Image",icon:d?(0,t.jsx)(tV.Check,{className:"h-4 w-4"}):(0,t.jsx)(tH.Photo,{className:"h-4 w-4"})})}),(0,t.jsx)("button",{type:"button",onClick:()=>{let t=`${tK.g}/qr?url=${(0,G.linkConstructor)({key:s.key,domain:s.domain,searchParams:{qr
22:"1"}})}${e.hideLogo?"&hideLogo=true":""}`;U.toast.promise(o(t),{success:"Copied QR code URL to clipboard!"}),l(!1)},className:"rounded-md p-2 text-left text-sm font-medium text-neutral-500 transition-all duration-75 hover:bg-neutral-100",children:(0,t.jsx)(p.IconMenu,{text:"Copy URL",icon:i?(0,t.jsx)(tV.Check,{className:"h-4 w-4"}):(0,t.jsx)(tG.Hyperlink,{className:"h-4 w-4"})})})]}),openPopover:r,setOpenPopover:l,children:a})}function t2(e){let[s,a]=(0,n.useState)(!1),r=(0,n.useCallback)(()=>(0,t.jsx)(tZ,{showLinkQRModal:s,setShowLinkQRModal:a,...e}),[s,a]);return(0,n.useMemo)(()=>({setShowLinkQRModal:a,LinkQRModal:r}),[a,r])}function t5(){let{isMobile:e}=(0,k.useMediaQuery)(),{id:a,logo:r,plan:i}=(0,s.default)(),{control:o}=(0,l.useFormContext)(),[d,c]=(0,l.useWatch)({control:o,name:["key","domain"]}),[u]=(0,I.useDebounce)(d,500),[m]=(0,I.useDebounce)(c,500),x=(0,n.useRef)(null),h=(0,p.useInViewport)(x),{logo:f}=(0,tB.default)({slug:c,enabled:h}),[g,j]=(0,p.useLocalStorage)(`qr-code-design-${a}`,{fgColor:"#000000",hideLogo:!0}),v=(0,n.useMemo)(()=>u&&m?(0,G.linkConstructor)({key:u,domain:m}):void 0,[u,m]),y=g.hideLogo&&"free"!==i,w="free"===i?t$.DUB_QR_LOGO:f||r||t$.DUB_QR_LOGO,{LinkQRModal:N,setShowLinkQRModal:C}=t2({props:{domain:c,key:d},onSave:e=>j(e)});return b("q",()=>C(!0),{enabled:!!v}),(0,t.jsxs)("div",{ref:x,children:[(0,t.jsx)(N,{}),(0,t.jsx)("div",{className:"flex items-center justify-between",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-neutral-700",children:"QR Code"}),(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Set a custom QR code design to improve click-through rates.",cta:"Learn more.",href:"https://trailmory.com/help/article/custom-qr-codes"})})]})}),(0,t.jsxs)("div",{className:"relative z-0 mt-2 h-24 overflow-hidden rounded-md border border-neutral-300",children:[(0,t.jsx)(p.Button,{type:"button",variant:"secondary",icon:(0,t.jsx)(ty.Pen2,{className:"mx-px size-4"}),className:"absolute right-2 top-2 z-10 h-8 w-fit bg-white px-1.5",onClick:()=>C(!0)}),!e&&(0,t.jsx)(p.ShimmerDots,{className:"opacity-30 [mask-image:radial-gradient(40%_80%,transparent_50%,black)]"}),v?(0,t.jsx)(tA.AnimatePresence,{mode:"wait",children:(0,t.jsx)(tR.motion.div,{initial:{filter:"blur(2px)",opacity:.4},animate:{filter:"blur(0px)",opacity:1},exit:{filter:"blur(2px)",opacity:.4},transition:{duration:.1},className:"relative flex size-full items-center justify-center",children:(0,t.jsx)(tz.QRCode,{url:v,fgColor:g.fgColor,hideLogo:y,logo:w,scale:.5})},v)}):(0,t.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-2",children:[(0,t.jsx)(t_.QRCode,{className:"size-5 text-neutral-700"}),(0,t.jsx)("p",{className:"max-w-32 text-center text-xs text-neutral-700",children:"Enter a short link to generate a QR code"})]})]})]})}e.s(["useLinkQRModal",()=>t2],996990),e.s(["QRCodePreview",()=>t5],314259),e.i(52124);var t3=e.i(242776),t4=e.i(67777),t7=e.i(477248),t6=e.i(82283),t9=e.i(331328),t8=e.i(988131);function se({tags:e}){return(0,t.jsx)("svg",{height:"18",width:"18",viewBox:"0 0 18 18",xmlns:"http://www.w3.org/2000/svg",className:(0,L.cn)("size-4 shrink-0",e.length>0&&t8.RESOURCE_COLORS_DATA.find(({color:t})=>t===e[0].color)?.tagVariants,"bg-transparent",e.length<=1&&"-translate-y-px"),children:(0,t.jsxs)("g",{fill:"currentColor",children:[e.length>0&&(0,t.jsx)("path",{d:"M1.75 4.25H7.336C7.601 4.25 7.856 4.355 8.043 4.543L13.836 10.336C14.617 11.117 14.617 12.383 13.836 13.164L10.664 16.336C9.883 17.117 8.617 17.117 7.836 16.336L2.043 10.543C1.855 10.355 1.75 10.101 1.75 9.836V4.25Z",fill:"currentColor",fillOpacity:.15,stroke:"none"}),(0,t.jsx)("path",{d:"M1.75 4.25H7.336C7.601 4.25 7.856 4.355 8.043 4.543L13.836 10.336C14.617 11.117 14.617 12.383 13.836 13.164L10.664 16.336C9.883 17.117 8.617 17.117 7.836 16.336L2.043 10.543C1.855 10.355 1.75 10.101 1.75 9.836V4.25Z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"}),e.length>1&&(0,t.jsx)("path",{d:"M3.25 1.75V1.25H8.836C9.101 1.25 9.356 1.355 9.543 1.543L15.336 7.336C15.768 7.768 15.961 8.348 15.915 8.913",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",className:(0,L.cn)(t8.RESOURCE_COLORS_DATA.find(({color:t})=>t===e[1].color)?.tagVariants,"bg-transparent")}),(0,t.jsx)("path",{d:"M5.25 9C5.94036 9 6.5 8.44036 6.5 7.75C6.5 7.05964 5.94036 6.5 5.25 6.5C4.55964 6.5 4 7.05964 4 7.75C4 8.44036 4.55964 9 5.25 9Z",fill:"currentColor",stroke:"none"})]})})}function st(e){return{value:e.id,label:e.name,icon:(0,t.jsx)(se,{tags:[e]}),meta:{color:e.color}}}let ss=(0,n.memo)(()=>{let{id:e,slug:a,mutate:r,exceededAI:i}
22=(0,s.default)(),[o,d]=(0,n.useState)(""),[c]=(0,I.useDebounce)(o,500),{data:u}=(0,t4.default)(),m=u&&u>t7.TAGS_MAX_PAGE_SIZE,{tags:x,loading:h}=(0,t3.default)({query:{sortBy:"createdAt",sortOrder:"desc",...m?{search:c}:{}}}),{control:f,setValue:g}=(0,l.useFormContext)(),[j,v,y,w,k]=(0,l.useWatch)({control:f,name:["tags","id","url","title","description"]}),[N]=(0,I.useDebounce)(y,500),[C,S]=(0,n.useState)(!1),T=async t=>{let s=await fetch(`/api/tags?workspaceId=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:t})});if(s.ok)return g("tags",[...j,await s.json()],{shouldDirty:!0}),U.toast.success("Successfully created tag!"),S(!1),await (0,e9.mutate)(`/api/tags?workspaceId=${e}`),!0;{let{error:e}=await s.json();U.toast.error(e.message)}return!1},D=(0,n.useMemo)(()=>x?.map(e=>st(e)),[x]),M=(0,n.useMemo)(()=>j.map(e=>st(e)),[j]);b("t",()=>S(!0),{priority:2});let[P,A]=(0,n.useState)([]),{complete:R}=(0,tc.useCompletion)({api:`/api/ai/completion?workspaceId=${e}`,body:{model:"claude-3-5-haiku-latest"},onFinish:(e,t)=>{r(),t&&A(t.split(", ").map(e=>x?.find(({name:t})=>t===e)||null).filter(Boolean).slice(0,5))}});return(0,n.useEffect)(()=>{!v&&N&&w&&k&&!i&&0===j.length&&0===P.length&&x&&x.length>0&&R(`From the list of available tags below, suggest relevant tags for this link: 
23        
24        - URL: ${N}
25        - Meta title: ${w}
26        - Meta description: ${k}. 
27        
28        Only return the tag names in comma-separated format, and nothing else. If there are no relevant tags, return an empty string.
29        
30        Available tags: ${x.map(({name:e})=>e).join(", ")}`)},[v,N,w,k,j]),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-neutral-700",children:"Tags"}),(0,t.jsx)(p.InfoTooltip,{content:(0,t.jsx)(p.SimpleTooltipContent,{title:"Tags are used to organize your links in your Trailmory dashboard.",cta:"Learn more.",href:"https://trailmory.com/help/article/how-to-use-tags"})})]}),(0,t.jsx)("a",{href:`/${a}/settings/library/tags`,target:"_blank",className:"text-sm text-neutral-400 underline-offset-2 transition-all hover:text-neutral-600 hover:underline",children:"Manage"})]}),(0,t.jsx)(p.Combobox,{multiple:!0,selected:M,setSelected:e=>{let t=e.map(({value:e})=>e);g("tags",t.map(e=>[...x||[],...j||[]].find(t=>t.id===e)),{shouldDirty:!0}),A(e=>e.filter(({id:e})=>!t.includes(e)))},options:h?void 0:D,icon:(0,t.jsx)(t9.Tag,{className:"mt-[5px] size-4 text-neutral-500"}),searchPlaceholder:"Search or add tags...",shortcutHint:"T",buttonProps:{className:(0,L.cn)("h-auto py-1.5 px-2.5 w-full text-neutral-700 border-neutral-300 items-start",0===M.length&&"text-neutral-400")},onCreate:e=>T(e),open:C,onOpenChange:S,onSearchChange:d,shouldFilter:!m,matchTriggerWidth:!0,children:M.length>0?(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:M.slice(0,10).map(e=>(0,t.jsx)(t6.default,{name:e.label,color:e.meta.color,className:"animate-fade-in"},e.value))}):h&&void 0===x&&j.length?(0,t.jsx)("div",{className:"my-px h-6 w-1/4 animate-pulse rounded bg-neutral-200"}):(0,t.jsx)("span",{className:"my-px block py-0.5",children:"Select tags..."})}),(0,t.jsx)(p.AnimatedSizeContainer,{height:!0,transition:{ease:"linear",duration:.1},children:P.length>0&&(0,t.jsxs)("div",{className:"animate-fade-in flex flex-wrap items-center gap-2 pt-3",children:[(0,t.jsx)(p.Tooltip,{content:"AI-suggested tags based on the content of the link. Click a suggested tag to add it.",children:(0,t.jsx)("div",{className:"group",children:(0,t.jsx)(ti.Magic,{className:"size-4 text-neutral-600 transition-colors group-hover:text-neutral-500"})})}),P.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>{g("tags",[...j,e],{shouldDirty:!0}),A(t=>t.filter(({id:t})=>t!==e.id)),tu.default.capture("ai_suggested_tag_selected",{tag:e.name,url:y})},className:"group flex items-center transition-all active:scale-95",children:(0,t.jsx)(t6.default,{...e})},e.id))]})})]})});ss.displayName="TagSelect",e.s(["TagSelect",0,ss],671136);var sa=e.i(928968);function sr({onSuccess:e}={}){let s=(0,e6.useRouter)(),{workspace:a,props:r}=u(),{getValues:i,setError:o}=(0,l.useFormContext)(),[,d]=(0,p.useCopyToClipboard)();return(0,n.useCallback)(async n=>{let{user:l,tags:c,tagId:u,folderId:m,partnerId:x,...h}=n,f={...h,tagIds:c.map(({id:e})=>e),folderId:"unsorted"===m?null:m,expiredUrl:h.expiredUrl||null,ios:h.ios||null,android:h.android||null,...x?{programId:a.defaultProgramId,partnerId:x}:{}},g=r?.id?{method:"PATCH",url:`/api/links/${r.id}?workspaceId=${a.id}`}:{method:"POST",url:`/api/links?workspaceId=${a.id}`};try{let n=await fetch(g.url,{method:g.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(200===n.status){let l=await n.json();if(e?.(l),r&&(r.domain!==l.domain||r.key!==l.key)&&s.push(`/${a.slug}/links/${l.domain}/${l.key}`),await (0,sa.mutatePrefix)(["/api/links",..."_root"===i("key")?["/api/domains"]:[]]),tu.default.capture(r?"link_updated":"link_created",l),r)U.toast.success("Successfully updated short link!");else try{await d(l.shortLink,{throwOnError:!0}),U.toast.success("Copied short link to clipboard!")}catch(e){U.toast.success((0,t.jsxs)("div",{className:"flex grow items-center justify-between gap-4",children:[(0,t.jsx)("p",{className:"text-[0.8125rem] text-neutral-900",children:"Successfully created link!"}),(0,t.jsx)(p.Button,{type:"button",className:"-my-1 h-7 w-fit",text:"Copy link",onClick:async()=>{try{await d(l.shortLink,{throwOnError:!0}),U.toast.success("Copied short link to clipboard!")}catch(e){U.toast.error("Failed to copy short link to clipboard."),console.error("Failed to copy with manual button",e)}}})]}),{duration:5e3})}
30(0,e9.mutate)(`/api/workspaces/${a?.slug}`)}else{let{error:e}=await n.json();if(e){e.message.includes("Upgrade to")?U.toast.custom(()=>(0,t.jsx)(tl.UpgradeRequiredToast,{title:`You've discovered a ${a?.nextPlan?.name} feature!`,message:e.message})):U.toast.error(e.message);let s=e.message.toLowerCase();s.includes("key")?o("key",{message:e.message}):s.includes("url")?o("url",{message:e.message}):o("root",{message:"Failed to save link"})}else o("root",{message:"Failed to save link"}),U.toast.error("Failed to save link")}}catch(e){o("root",{message:"Failed to save link"}),console.error("Failed to save link",e),U.toast.error("Failed to save link")}},[a.id,a.slug,a.nextPlan,r,d,i,o,e])}function sn({enabled:e=!0}={}){let{control:t,setValue:s}=(0,l.useFormContext)(),[a,r,i,o,d,c]=(0,l.useWatch)({control:t,name:["url","password","proxy","title","description","image"]}),[m]=(0,I.useDebounce)((0,Q.getUrlWithoutUTMParams)(a),500),{generatingMetatags:x,setGeneratingMetatags:p}=u();return(0,n.useEffect)(()=>{if(i)return void p(!1);if(r){p(!1),s("title","Password Required"),s("description","This link is password protected. Please enter the password to view it."),s("image","https://assets.dub.co/misc/password-protected.png");return}if(!1!==e&&m.length>0)try{new URL(m),p(!0),fetch(`/api/links/metatags?url=${m}`).then(async e=>{if(200===e.status){let t=await e.json(),a=(0,A.truncate)(t.title,120),r=(0,A.truncate)(t.description,240);o||s("title",a),d||s("description",r),c||s("image",t.image)}setTimeout(()=>p(!1),200)})}catch(e){}else p(!1)},[m,r,e]),{generatingMetatags:x}}e.s(["useLinkBuilderSubmit",()=>sr],280230),e.s(["useMetatags",()=>sn],602400);var sl=e.i(768502);function si(e){return e.showLinkBuilder?(0,t.jsx)(so,{...e}):null}function so({showLinkBuilder:e,setShowLinkBuilder:s,homepageDemo:a,...r}){return(0,t.jsx)(m,{...r,children:(0,t.jsx)(sd,{showLinkBuilder:e,setShowLinkBuilder:s,homepageDemo:a})})}function sd({showLinkBuilder:e,setShowLinkBuilder:i,homepageDemo:d}){let c=(0,e6.useSearchParams)(),{queryParams:m}=(0,p.useRouterStuff)(),{id:h,slug:g,flags:j}=(0,s.default)(),{props:b,duplicateProps:v}=u(),{control:w,handleSubmit:k,setValue:N,formState:{isDirty:C,isSubmitting:S,isSubmitSuccessful:T}}=(0,l.useFormContext)(),[D,M]=(0,l.useWatch)({control:w,name:["domain","key"]});sn({enabled:e});let P=(0,n.useMemo)(()=>!!(!e||S||T||b&&!C),[e,S,T,b,C]),{loading:A,primaryDomain:R}=(0,o.useAvailableDomains)({currentDomain:D});(0,n.useEffect)(()=>{A||!R||b||v||N("domain",R,{shouldValidate:!0,shouldDirty:!1})},[A,R,b,v]);let U=(0,n.useRef)(null),{link:I}=(0,e6.useParams)(),E=(0,e6.useRouter)(),B=sr({onSuccess:(0,n.useCallback)(e=>{U.current?.onSubmitSuccessful(),I?E.push(`/${g}/links/${e.domain}/${e.key}`):e.folderId?m({set:{folderId:e.folderId}}):m({del:["folderId"]}),i(!1)},[])});return(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(p.Modal,{showModal:e,setShowModal:i,className:"max-w-screen-lg",onClose:()=>{c.has("newLink")&&m({del:["newLink","newLinkDomain"]}),U.current?.onClose()},children:(0,t.jsxs)("form",{onSubmit:k(B),children:[(0,t.jsx)(X,{onClose:()=>{i(!1),c.has("newLink")&&m({del:["newLink"]}),U.current?.onClose()},children:(0,t.jsx)(F,{ref:U,props:b,workspaceId:h})}),(0,t.jsxs)("div",{className:(0,L.cn)("grid w-full gap-y-6 max-md:overflow-auto md:grid-cols-[2fr_1fr]","max-md:max-h-[calc(100dvh-200px)] max-md:min-h-[min(566px,_calc(100dvh-200px))]","md:[&>div]:max-h-[calc(100dvh-200px)] md:[&>div]:min-h-[min(566px,_calc(100dvh-200px))]"),children:[(0,t.jsx)("div",{className:"scrollbar-hide px-6 md:overflow-auto",children:(0,t.jsxs)("div",{className:"flex min-h-full flex-col gap-6 py-4",children:[(0,t.jsx)(a.LinkBuilderDestinationUrlInput,{}),(0,t.jsx)(x,{}),(0,t.jsx)(ss,{}),(0,t.jsx)(f,{}),(0,t.jsx)(y,{}),(0,t.jsx)("div",{className:"flex grow flex-col justify-end",children:(0,t.jsx)(tI,{})})]})}),(0,t.jsx)("div",{className:"scrollbar-hide px-6 md:overflow-auto md:pl-0 md:pr-4",children:(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"absolute inset-0 rounded-xl border border-neutral-200 bg-neutral-50 [mask-image:linear-gradient(to_bottom,black,transparent)]"}),(0,t.jsxs)("div",{className:"relative flex flex-col gap-6 px-4 py-3",children:[(0,t.jsx)(r.LinkBuilderFolderSelector,{}),(0,t.jsx)(t5,{}),(0,t.jsx)(tL,{})]})]})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-neutral-100 bg-neutral-50 p-4",children:[(0,t.jsx)(tr,{}),d?(0,t.jsx)(p.Button,{disabledTooltip:"This is a demo link. You can't edit it.",text:"Save changes",className:"h-8 w-fit"}):(0,t.jsx)(p.Button,{type:"submit",disabled:P,loading:S||T,text:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[b?"Save changes":"Create link",(0,t.jsx)("div",{className:"rounded border border-white/20 p-1",children:(0,t.jsx)(sl.ArrowTurnLeft,{className:"size-3.5"})})]}),className:"h-8 w-fit pl-2.5 pr-1.5"})]})]})})})}function sc({setShowLinkBuilder:e,...a}){let{slug:r,plan:l,nextPlan:i,exceededLinks:o}=(0,s.default)();(0,p.useKeyboardShortcut)("c",()=>e(!0));let d=t=>{let s=t.clipboardData?.getData("text"),a=t.target,r=document.getElementById("modal-backdrop");s&&(0,eo.isValidUrl)(s)&&"INPUT"!==a.tagName&&"TEXTAREA"!==a.tagName&&!r&&!o&&e(!0)};return(0,n.useEffect)(()=>(document.addEventListener("paste",d),()=>document.removeEventListener("paste",d)),[]),(0,t.jsx)(p.Button,{text:"Create link",shortcut:"C",disabledTooltip:o&&"enterprise"!==l?(0,t.jsx)(p.TooltipContent,{title:"Your workspace has exceeded its monthly links limit. We're still collecting data on your existing links, but you need to upgrade to add more links.",cta:`Upgrade to ${i.name}`,href:`/${r}/upgrade`}):void 0,onClick:()=>e(!0),...a})}function su({props:e,duplicateProps:a,homepageDemo:r}={}
30){let l=(0,s.default)(),[i,o]=(0,n.useState)(!1),d=(0,n.useCallback)(()=>(0,t.jsx)(si,{showLinkBuilder:i,setShowLinkBuilder:o,props:e,duplicateProps:a,homepageDemo:r,workspace:l,modal:!0}),[i]),c=(0,n.useCallback)(e=>(0,t.jsx)(sc,{setShowLinkBuilder:o,...e}),[]);return(0,n.useMemo)(()=>({showLinkBuilder:i,setShowLinkBuilder:o,LinkBuilder:d,CreateLinkButton:c}),[i,d,c])}e.s(["useLinkBuilder",()=>su],998255)}]);

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.