PageSourceSearch

https://brik.space/assets/ToolViewerSwitch-Dxe_3ULv.js

js brik.space collected 2026-09-25 19:07:04 UTC 81,410 bytes, 6 lines download raw bytes

1import{ad as Ns,r as s,j as e,e as X,c0 as Cn,a2 as Rt,at as En,fp as Cs,gc as Tn,gd as Qe,Q as Ie,k as Jt,bV as nn,ig as Es,bX as sn,ih as Ts,bZ as ut,b5 as Rn,fD as Rs,b3 as pt,fC as Ls,b4 as Ps,gH as Ms,h$ as Os,i2 as As,i3 as Fs,b8 as Ds,ii as $s,ij as Bs,ax as Qt,cs as Vs,cM as Ln,ik as Hs,gE as Lt,ib as rn,ic as on,il as an,aa as Is,fG as Us,b as Zt,d as ct,fH as zs,ia as Gs,ff as ln,ee as Ks,$ as Ws,a4 as qs,a1 as Xs,f as Pn,x as Mn,ai as Je,F as On,G as An,m as _t,im as Fn,c as Dn,io as $n,ip as Bn,l as Vn,iq as Hn,i as Ys,L as Pe,fF as In,T as Js,fg as Un,S as St,d1 as Qs,b$ as zn,O as cn,cl as dn,cW as Zs,cX as er,cY as tr,aq as nr,cZ as sr,c$ as rr,u as or}from"./appBoot-DBJ5ahS-.js";import{u as Gn}from"./appMenuStyles-5xG4t4vY.js";import{d as ir,f as ar,r as lr,s as cr,t as Kn,v as dr,w as ur,x as pr,y as xr,T as mr,z as Wn,A as hr,B as fr,D as br,F as qn,g as Xn,h as gr,G as wr,H as vr,J as Yn,j as Jn,S as Qn,K as Zn,W as yr,N as kr,k as jr,a as _r,o as Sr,M as Nr,p as Cr,l as Er,m as Tr,c as Rr,i as Lr}from"./RenderQueueButton-3ZJG_Kp8.js";import{H as es}from"./MediaManagerHost-BZkm0ppg.js";import{L as Pr,p as Mr,t as Or,R as Ar,T as Nt,a as Ye,S as Fr,w as Dr}from"./ToolControlsPanel-BbgmHVue.js";import{H as un}from"./HomeHeader-2DaHh80L.js";import{t as ge}from"./toast-D7mIkDp8.js";import{R as dt}from"./RemixIcon-nWMPugOJ.js";import{k as $r}from"./SettingsModal-Bv96OYTI.js";import{A as ts}from"./timeline-CCJAy-E_.js";import{T as ns,D as ss}from"./toolControls-CYSc6lnV.js";import{u as Br,a as Vr}from"./toolStillCapture-B-qCfsAo.js";import{a as rs}from"./fontPreviewLoader-B4CegDxY.js";import{u as Hr}from"./useNavHide-Bw6GZ-Lq.js";import{u as os}from"./useStructuredData-Bx_4WyJF.js";import{r as is}from"./recentlyOpened-BGCMeDm0.js";import{i as He}from"./toolVisibility-C7K8osz3.js";import{t as as}from"./toolInteractions-B0MJJi4D.js";import{u as Ir}from"./useRemixTool-Cieq9I6K.js";import{u as Ur,e as zr}from"./isTypingTarget-CCUyq5t2.js";import{B as Wt}from"./bookmark-Gq_I3p7G.js";import{C as qt}from"./chevron-left-D2Oa25lU.js";import{T as ls}from"./trash-2-CafyFSBh.js";import{C as cs}from"./chevron-right-OW5kRsB0.js";import{P as Gr,a as Kr,b as Wr}from"./popover-CmdtPS_f.js";import{X as qr}from"./TextBadge-Db4WDafm.js";import{T as Xr}from"./TikTokIcon-BrdNoo_f.js";import{R as Yr}from"./CreateToolIcon-Bq31l9gm.js";import{B as Jr}from"./BookmarkBorderIcon-D36EzqTi.js";import"./index-Jq0mIgmH.js";import"./ControlRenderer-BNQv_RWY.js";import"./mediaManager-DB55-abD.js";import"./useMutation-CVbFNMDW.js";import"./media-manager.data-hooks-Dw7yvSdn.js";import"./color-5hdXErkH.js";import"./chevron-down-BYZ3KCAq.js";import"./fontUrls-QOAwkfmO.js";import"./upload-BL-MVQb1.js";import"./link-CFnmRDl_.js";import"./plus-B9Rowqz7.js";import"./check-fawfteD7.js";import"./dropdown-menu-CrOP99rX.js";import"./index-C1psWGM9.js";import"./index-C5GYCJi6.js";import"./switch-IOfMfd7I.js";import"./index-CvgpAMRp.js";import"./menuChrome-COhsT6e1.js";import"./eye-off-DiIjT93E.js";import"./eye-DCWNi5ZW.js";import"./EditPencilIcon-BDq6aUPt.js";import"./play-BueORstv.js";import"./DisabledReasonTooltip-DItpBETh.js";import"./BrikLoader-Bo90r9Lm.js";import"./usePlanCheckout-x8DXJsbW.js";import"./PlanChangePreviewDialog-C23Skg0g.js";import"./brand-BR0WcRE0.js";import"./index-BpR0y34i.js";import"./billingAnalytics-Bnz1JGZ4.js";import"./arrow-right-BxNQ9qxu.js";import"./PlanCard-DRtdLSWM.js";import"./info-Cuh2X9ye.js";import"./CustomPlanModal-BREC5qBa.js";import"./reactExport-BVzVRrLr.js";import"./select-mYfN2Yhb.js";import"./chevron-up-BPq_fwxF.js";import"./copy-C5y9_lBu.js";import"./ControlRendererV2-B3F0T2tm.js";import"./TextInput-Gs4WX3rx.js";import"./useInfiniteQuery-D8I9l9N1.js";import"./TextArea-CVpKQ4m9.js";import"./SegmentedButtons-DQqH3UzN.js";import"./Badge-phHZR525.js";import"./search-BEvRKCBB.js";import"./box-7pAX9Wdr.js";import"./file-text-BjQi5VFk.js";import"./sparkles-C0yk9Y3H.js";import"./atom-CYbIbger.js";import"./textarea-m42LLlJd.js";import"./download-CJzqyR4n.js";import"./square-Bvjfp-i8.js";import"./UserMenuQuota-D9Ehdw55.js";import"./gem-CoBlSF31.js";import"./save-CrsZ3hp7.js";import"./UserAvatar-DKeljiE9.js";import"./workspace-CgMtad6L.js";import"./docs-CCdFHTo2.js";import"./music-ehrWv10W.js";import"./film-gODazmK4.js";import"./formatBytes-BUdPTGxu.js";import"./biButtons-CAjKF8Lv.js";import"./grip-vertical-KTht7oFY.js";import"./ChevronRightIcon-jNDHrE4b.js";import"./folder-BzG562IW.js";import"./InlineAlert-CmjZ0mJH.js";import"./circle-alert-DCik7gyE.js";import"./ConfirmDialog-DTes442I.js";import"./sharedUserMedia-BkQoJR7s.js";import"./usePricingCheckout-DezcXkx8.js";import"./PricingPlanCard-C9upKWjI.js";import"./ArrowForwardIcon-C9SQ-6Ub.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Qr=[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],ds=Ns("Settings2",Qr),Zr={switch:{loading:"tool-viewer-switch-loading"}},pn="For the full Brik experience, switch to desktop.",us="brik-desktop-nudge-seen";function eo(){try{return window.localStorage.getItem(us)==="1"}catch{return!1}}function Ct({message:t=pn,chromeVariant:o="legacy"}){const n=t===pn,[r,a]=s.useState(()=>n&&eo());if(s.useEffect(()=>{if(!(!n||r))try{window.localStorage.setItem(us,"1")}catch{}},[n,r]),r)return null;const l=o==="v2";return e.jsxs("div",{role:"status",className:X("lg:hidden shrink-0 flex items-start gap-[10px]",l?"mx-[16px] mb-[15px] border border-[var(--product-grey-02-legacy)] bg-[var(--product-white-00)] px-[14px] py-[12px]":"mx-[20px] mb-[15px] rounded-[12px] bg-white px-[14px] py-[12px] shadow-[0_1px_6px_rgba(0,0,0,0.1)]"),children:[e.jsx("span",{className:X("flex-1",l?"text-product-text text-[var(--product-black-00)]":"text-[13px] leading-[1.35] tracking-[-0.26px] text-[#1a1a1a]"),children:t}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(!0),className:X("shrink-0 flex h-[20px] w-[20px] items-center justify-center",l?"text-[var(--product-grey-05)]":"text-[#7d7d7d]"),children:l?e.jsx(Cn,{className:"size-[14px]"}):e.jsx(Rt,{className:"h-[14px] w-[14px]",strokeWidth:2})})]})}const to=[{id:"whatsapp",label:"WhatsApp",color:"#25D366",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"
6currentColor",children:e.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})})},{id:"telegram",label:"Telegram",color:"#2AABEE",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"})})},{id:"x",label:"X",color:"#000000",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})})},{id:"facebook",label:"Facebook",color:"#1877F2",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})})},{id:"email",label:"Email",color:"#7d7d7d",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})},{id:"more",label:"More",color:"#a3a3a3",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"5",cy:"12",r:"2.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"2.5"}),e.jsx("circle",{cx:"19",cy:"12",r:"2.5"})]})}];function no({open:t,toolName:o,toolSlug:n,toolId:r,onClose:a}){En({open:t,modalName:"mobile_share_sheet"});const{sendModalClicked:l}=Cs(),h=s.useRef(null),c=s.useRef(null);s.useEffect(()=>{var b;if(!t)return;c.current=document.activeElement,(b=h.current)==null||b.focus();const d=document.body.style.overflow;document.body.style.overflow="hidden";const j=()=>{const u=h.current;if(!u)return[];const k=u.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');return Array.from(k).filter(N=>!N.hasAttribute("aria-hidden")&&N.offsetParent!==null)},P=u=>{var R,v;if(u.key==="Escape"){a();return}if(u.key!=="Tab")return;const k=j();if(k.length===0){u.preventDefault(),(R=h.current)==null||R.focus();return}const N=k[0],O=k[k.length-1],A=document.activeElement;u.shiftKey?(A===N||!((v=h.current)!=null&&v.contains(A)))&&(u.preventDefault(),O.focus()):A===O&&(u.preventDefault(),N.focus())};return window.addEventListener("keydown",P),()=>{var u,k;window.removeEventListener("keydown",P),document.body.style.overflow=d,(k=(u=c.current)==null?void 0:u.focus)==null||k.call(u)}},[t,a]);const p=n?Tn(n,Qe.appId):r?`${window.location.origin}${Ie({id:r,slug:null})}`:window.location.href,x=`${o||"Check this out"} — ${p}`,S=s.useCallback(async()=>
6{l({modal_name:"mobile_share_sheet",button_name:"mobile_share_sheet_copy_link",button_type:"button",button_value:"copy_link"});try{await navigator.clipboard.writeText(p),ge.success("Link copied!",{duration:1500})}catch{ge.error("Could not copy link")}a()},[p,a,l]),g=s.useCallback(async d=>{if(l({modal_name:"mobile_share_sheet",button_name:`mobile_share_sheet_${d}`,button_type:"button",button_value:d}),d==="more"){try{await navigator.share({title:o||"Check this out",url:p})}catch{}a();return}const j={whatsapp:`https://wa.me/?text=${encodeURIComponent(p)}`,telegram:`https://t.me/share/url?url=${encodeURIComponent(p)}&text=${encodeURIComponent(o||"")}`,x:`https://x.com/intent/tweet?url=${encodeURIComponent(p)}&text=${encodeURIComponent(o||"")}`,facebook:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(p)}`,email:`mailto:?subject=${encodeURIComponent(o||"Check this out")}&body=${encodeURIComponent(x)}`};window.open(j[d],"_blank","noopener,noreferrer"),a()},[o,p,x,a,l]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:X("fixed inset-0 z-[55] bg-black/50 backdrop-blur-sm transition-opacity duration-200",t?"opacity-100":"opacity-0 pointer-events-none"),onClick:a,"aria-hidden":!0}),e.jsxs("div",{ref:h,role:"dialog","aria-modal":"true","aria-label":"Share","aria-hidden":!t,tabIndex:-1,className:X("fixed left-0 right-0 bottom-0 z-[60] bg-white rounded-t-[15px] p-[15px] pb-[max(15px,env(safe-area-inset-bottom))] flex flex-col gap-[10px] shadow-[0_-8px_30px_rgba(0,0,0,0.2)] transition-transform duration-300 ease-out focus:outline-none",t?"translate-y-0":"translate-y-[100dvh] pointer-events-none"),children:[e.jsxs("div",{className:"flex items-center justify-between mb-[5px]",children:[e.jsxs("span",{className:"text-[12px] font-medium text-black tracking-[-0.24px]",children:["Share ",o||""]}),e.jsx("button",{type:"button",onClick:a,className:"w-[26px] h-[26px] flex items-center justify-center rounded-[5px] hover:bg-[#E8E8E8] transition-colors",children:e.jsx(Rt,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"flex justify-between px-[10px] py-[5px]",children:to.map(d=>e.jsxs("button",{type:"button",onClick:()=>g(d.id),className:"flex flex-col items-center gap-[6px] w-[52px] active:opacity-70 transition-opacity",children:[e.jsx("div",{className:"w-[44px] h-[44px] rounded-full flex items-center justify-center",style:{background:d.color},children:e.jsx("div",{className:"w-[20px] h-[20px] text-white",children:d.icon})}),e.jsx("span",{className:"text-[10px] text-[#7d7d7d] tracking-[-0.2px]",children:d.label})]},d.id))}),e.jsxs("div",{className:"flex items-center gap-[8px]",children:[e.jsxs("div",{className:"flex flex-1 min-w-0 items-center gap-[8px] h-[44px] rounded-[10px] bg-[#E8E8E8] px-[15px]",children:[e.jsx(Pr,{className:"w-[15px] h-[15px] shrink-0 text-black"}),e.jsx("span",{className:"flex-1 text-[12px] text-[#7d7d7d] tracking-[-0.24px] truncate min-w-0",children:p})]}),e.jsx("button",{type:"button",onClick:S,className:"shrink-0 h-[44px] px-[15px] rounded-[10px] bg-black text-white text-[12px] font-medium tracking-[-0.24px] active:opacity-80 transition-opacity",children:"Copy link"})]})]})]})}function ps({toolId:t}
6){const{anonymousUserId:o,isAnonymous:n,loading:r,sessionId:a,userId:l}=Jt(),h=ir(),c=s.useRef(!1);return s.useEffect(()=>{if(r||c.current||!t)return;c.current=!0;const x={anon_uuid:n?o:void 0,referral:h,session_id:a,tool_id:t,userId:n?void 0:l};nn(sn.TOOL_VIEWED,Es(x),x)},[o,n,r,h,a,t,l]),{sendToolViewAction:s.useCallback(x=>{if(r||!t)return;const S={action_name:x,anon_uuid:n?o:void 0,session_id:a,tool_id:t??void 0,userId:n?void 0:l};nn(sn.TOOL_VIEW_ACTION,Ts(S),S)},[o,n,r,a,t,l])}}function xs(t){const[o,n]=s.useState(!1),r=s.useMemo(()=>t?t.slug?Tn(t.slug,Qe.appId):`${window.location.origin}${Ie(t)}`:"",[t]),a=s.useMemo(()=>`${(t==null?void 0:t.name)||"Check this out"} — ${r}`,[t==null?void 0:t.name,r]),l=s.useCallback(()=>{t&&n(!0)},[t]),h=s.useCallback(async()=>{try{await navigator.clipboard.writeText(r),ge.success("Link copied.",{duration:1500}),ut.capture("tool_shared",{tool_id:t==null?void 0:t.id,tool_name:t==null?void 0:t.name,action:"copy_link",url:r})}catch{ge.error("Link wasn't copied. Try again.")}n(!1)},[r,t]),c=s.useCallback(async p=>{if(ut.capture("tool_shared",{tool_id:t==null?void 0:t.id,tool_name:t==null?void 0:t.name,action:p,url:r}),p==="more"){try{await navigator.share({title:(t==null?void 0:t.name)||"Check this out",url:r})}catch{}n(!1);return}const x={whatsapp:`https://wa.me/?text=${encodeURIComponent(r)}`,telegram:`https://t.me/share/url?url=${encodeURIComponent(r)}&text=${encodeURIComponent((t==null?void 0:t.name)||"")}`,x:`https://x.com/intent/tweet?url=${encodeURIComponent(r)}&text=${encodeURIComponent((t==null?void 0:t.name)||"")}`,facebook:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(r)}`,email:`mailto:?subject=${encodeURIComponent((t==null?void 0:t.name)||"Check this out")}&body=${encodeURIComponent(a)}`};window.open(x[p],"_blank","noopener,noreferrer"),n(!1)},[a,r,t==null?void 0:t.id,t==null?void 0:t.name]);return{shareUrl:r,shareText:a,showShareModal:o,setShowShareModal:n,handleShare:l,handleCopyLink:h,handleShareTo:c}}function ms(){const[t,o]=s.useState(!1),[n,r]=s.useState(0),[a,l]=s.useState(320),[h,c]=s.useState(!1),[p,x]=s.useState(!1),[S,g]=s.useState(()=>{try{return localStorage.getItem("clay_admin_mobile_view")==="1"}catch{return!1}}),d=s.useCallback(()=>{g(A=>{const R=!A;try{localStorage.setItem("clay_admin_mobile_view",R?"1":"0")}catch{}return R})},[]),[j,P]=s.useState({active:!1,tracked:[]}),b=s.useCallback(A=>{P(R=>R.active===A.active&&R.tracked.join("\0")===A.trackedKeys.join("\0")?R:{active:A.active,tracked:A.trackedKeys})},[]),[u,k]=s.useState(null),N=s.useRef(null),O=s.useCallback(A=>{k(R=>({key:A,nonce:((R==null?void 0:R.nonce)??0)+1})),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>k(null),2200)},[]);return s.useEffect(()=>()=>{N.current&&clearTimeout(N.current)},[]),{controlsOpen:t,setControlsOpen:o,controlsDrawerHeight:n,setControlsDrawerHeight:r,panelWidth:a,setPanelWidth:l,timelineTrackKeys:j,handleTrackKeysChange:b,revealControlTarget:u,handleRevealControl:O,iframeReady:h,setIframeReady:c,controlsTouched:p,setControlsTouched:x,adminMobileView:S,toggleAdminMobileView:d}}const en="brik_pending_controls",tn="brik_pending_controls_nonce",hs="cnonce";function xn(t,o,{reopenExport:n=!1}={}){const r=crypto.randomUUID();sessionStorage.setItem(en,JSON.stringify({toolId:t,values:o,reopenExport:n})),sessionStorage.setItem(tn,r);const a=new URL(window.location.href);return a.searchParams.set(hs,r),a.toString()}function so(){sessionStorage.removeItem(en),sessionStorage.removeItem(tn)}function ro(){const t=new URLSearchParams(window.location.search).get(hs);if(!t)return null;const o=sessionStorage.getItem(tn);if(t!==o)return null;const n=sessionStorage.getItem(en);if(!n)return null;try{const r=JSON.parse(n);return!(r!=null&&r.toolId)||typeof r.values!="object"||r.values===null?null:{...r,reopenExport:!!r.reopenExport}}catch{return null}}function fs({tool:t,iframeRef:o,iframeReady:n,openAuthModal:r,registerOAuthRedirectProvider:a,setShowExport:l,setControlsTouched:h,user:c,profileLoading:p}){const[x]=s.useState(()=>ro()),[S,g]=s.useState(!1),d=s.useRef(!1),j=s.useRef(!1),P=s.useCallback(()=>new Promise(u=>{var O;if(!((O=o.current)!=null&&O.contentWindow)){u(null);return}let k=!1;const N=Rn(A=>{A.type===Rs&&!k&&(k=!0,N(),u(A.payload??null))});pt(o,Ls),setTimeout(()=>{k||(k=!0,N(),u(null))},500)}),[o]),b=s.useCallback(async u=>{let k;try{if(t!=null&&t.id){const N=await P();N&&Object.keys(N).length>0&&(k=xn(t.id,N,{reopenExport:!0}))}}catch{}r(()=>l(!0),u,k)},[t==null?void 0:t.id,P,r,l]);return s.useEffect(()=>(a(async()=>
6{if(!(t!=null&&t.id))return;const u=await P();if(u&&Object.keys(u).length>0)return xn(t.id,u,{reopenExport:!1})}),()=>a(null)),[t==null?void 0:t.id,P,a]),s.useEffect(()=>{if(!n||!x||d.current||(t==null?void 0:t.id)!==x.toolId)return;d.current=!0,Object.entries(x.values).forEach(([k,N])=>{pt(o,Ps,{key:k,value:N})}),h(!0),so();const u=new URL(window.location.href);u.searchParams.delete("cnonce"),window.history.replaceState({},"",`${u.pathname}${u.search}${u.hash}`),g(!0)},[n,x,t==null?void 0:t.id,h,o]),s.useEffect(()=>{!S||j.current||p||(j.current=!0,c&&(x!=null&&x.reopenExport)&&l(!0))},[S,p,c,x,l]),{openExportAuthWall:b}}function bs({animationTimelineEnabled:t,liveTimeline:o,publishedTimeline:n}){return s.useMemo(()=>t?o!==void 0?o:n??null:null,[t,o,n])}function gs({tool:t,toolUuid:o,navigate:n,sendToolViewAction:r,setPanelWidth:a,setControlsTouched:l,setIframeReady:h,iframeRef:c,iframeReady:p,originalTool:x,originalCreatorName:S,onToggleControlsPanelCollapsed:g}){s.useEffect(()=>Rn(j=>{var P,b,u;if(j.type===Ms&&(g==null||g()),j.type===Os){const k=(P=j.payload)==null?void 0:P.width;typeof k=="number"&&k>0&&a(k)}if(j.type===As){const k=Fs((b=j.payload)==null?void 0:b.action_name);k&&(r(k),ut.capture("tool_run",{tool_id:t==null?void 0:t.id,tool_uuid:o,action_name:k}))}if(j.type===Ds){const k=(u=j.payload)==null?void 0:u.dirty;l(typeof k=="boolean"?k:!0)}if(j.type===$s){const{toolId:k,toolSlug:N}=j.payload??{};k&&n(Ie({id:k,slug:N??void 0}))}if(j.type===Bs){const{userId:k}=j.payload??{};k&&n(Qt(k))}j.type===Vs&&h(!0)}),[r,n,t==null?void 0:t.id,o,a,l,h,g]),s.useEffect(()=>{o&&(as("view",o).catch(d=>{console.warn("[ToolViewer] Failed to track view:",d)}),ut.capture("tool_previewed",{tool_id:t==null?void 0:t.id,tool_uuid:o,tool_name:t==null?void 0:t.name,slug:t==null?void 0:t.slug,is_public:t==null?void 0:t.is_public}))},[o,t==null?void 0:t.id,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.is_public]),s.useEffect(()=>{if(!p)return;const d=!!x&&He(x);pt(c,Hs,{name:(x==null?void 0:x.name)??null,id:(x==null?void 0:x.id)??null,slug:(x==null?void 0:x.slug)??null,isPublic:d,creatorName:S??null,creatorId:x?Ln(x):null})},[p,x,S,c])}const Pt="brik_pending_remix",Mt="brik_pending_remix_nonce",Et="rnonce";let Tt=!1;function oo(t){Tt=!1;const o=crypto.randomUUID();try{sessionStorage.setItem(Pt,t),sessionStorage.setItem(Mt,o)}catch{}return o}function io(){const t=new URLSearchParams(window.location.search).get(Et);if(!t)return null;try{return sessionStorage.getItem(Mt)!==t?null:sessionStorage.getItem(Pt)}catch{return null}}function ao(){const t=new URL(window.location.href);t.searchParams.has(Et)&&(t.searchParams.delete(Et),window.history.replaceState({},"",`${t.pathname}${t.search}${t.hash}`))}function mn(){if(Tt)return!1;Tt=!0;try{sessionStorage.removeItem(Pt),sessionStorage.removeItem(Mt)}catch{}return!0}function Xt(){Tt=!1;try{sessionStorage.removeItem(Pt),sessionStorage.removeItem(Mt)}catch{}}function ws({tool:t,user:o,navigate:n,openAuthModal:r,sendToolViewAction:a}){const[l,h]=s.useState(!1),{mutateAsync:c}=Ir(),p=async()=>{if(!(l||!t)){h(!0);try{const g=!!(o!=null&&o.id)&&o.id===t.user_id,{tool:d}=await c({toolId:t.id,options:{source:g?"draft":"published"}});d&&n(`/tooleditor/${d.id}`)}catch(g){console.error("Remix failed:",g),ge.error(g instanceof Error?g.message:"Tool wasn't remixed due to a technical issue. Try again.")}finally{h(!1)}}},x=s.useRef(p);return x.current=p,s.useEffect(()=>{!(o!=null&&o.id)||!(t!=null&&t.id)||io()===t.id&&mn()&&(ao(),x.current())},[o==null?void 0:o.id,t==null?void 0:t.id]),{remixing:l,handleRemix:()=>{if(!(l||!t)){if(a("Remix"),ut.capture("tool_remixed_client",{tool_id:t.id,tool_uuid:t.uuid,tool_name:t.name,is_authenticated:!!o}),!o){const g=oo(t.id),d=new URL(window.location.href);d.searchParams.set(Et,g),r(()=>{mn()&&p()},"tool_viewer_remix_button",d.toString(),()=>Xt());return}p()}}}}function lo(t){const{animationTimelineEnabled:o,isMobile:n,timeline:r}=t;return!o||!Lt(r)?{mountDock:!1,autoplayTimeline:null}:n?{mountDock:!1,autoplayTimeline:r??null}:{mountDock:!0,autoplayTimeline:null}}function vs({tool:t,resolvedCode:o,resolvedImpl:n,resolvedSchema:r,initialImplementation:a,creatorName:l,isMobile:h,useNewControl
6sPanel:c,animationTimelineEnabled:p,chromeVariant:x="legacy",setIframeReady:S,iframeRef:g,timelineDockRef:d}){const j=x==="v2",P=j,b=j&&!h,[u,k]=s.useState(null),[N,O]=s.useState(null),A=s.useMemo(()=>Mr((n==null?void 0:n.presets)??(a==null?void 0:a.presets)),[a==null?void 0:a.presets,n==null?void 0:n.presets]),R=s.useMemo(()=>lo({animationTimelineEnabled:p,isMobile:h,timeline:n==null?void 0:n.timeline}),[p,h,n]),v=R.mountDock||!h&&p&&A.some(F=>Lt(F.timeline)),f=(n==null?void 0:n.timeline)??null,E=(n==null?void 0:n.uuid)??null,U=s.useMemo(()=>Or(f),[E]),J=s.useMemo(()=>{if(!t||o===null)return null;const F=t,W=rn(r,n,F),ne=on(n,F),H=an(F);return Is({name:t.name,controlsSchema:W,canvasCode:o,libraries:ne,customCss:H,canvasConfig:Us(n),creatorName:l,creatorId:Ln(t)??void 0,timeline:R.autoplayTimeline,hideControlsOnMobile:c?!1:h,externalControls:c,showCanvasGuides:P,showToolFrameBar:b,showFullscreenInFrameBar:b})},[t,o,n,r,l,h,c,R,P,b]),z=s.useMemo(()=>{if(!t||o===null)return null;const F=t,W=rn(r,n,F),ne=on(n,F);return{id:t.id,uuid:t.uuid??null,controlsSchema:W,canvasCode:o,libraries:ne,customCss:an(F),slug:t.slug??void 0,visibility:t.visibility??"public",isPublic:t.is_public}},[t,o,n,r]),B=(n==null?void 0:n.id)??(a==null?void 0:a.id)??null,D=s.useMemo(()=>{const F=(n==null?void 0:n.canvas_width)??(a==null?void 0:a.canvas_width),W=(n==null?void 0:n.canvas_height)??(a==null?void 0:a.canvas_height);return typeof F=="number"&&F>0&&typeof W=="number"&&W>0?{width:F,height:W}:null},[a==null?void 0:a.canvas_height,a==null?void 0:a.canvas_width,n==null?void 0:n.canvas_height,n==null?void 0:n.canvas_width]),Y=(u==null?void 0:u.implId)===B?u.size:D,ce=s.useCallback(F=>{var W;(W=d.current)==null||W.replaceTimeline(F)},[d]),Ce=s.useCallback(F=>{k({implId:B,size:F}),ar(g,F)},[B,g]),xe=s.useMemo(()=>({versionKey:B,presets:A,timeline:f,canvasSize:Y,applyTimeline:ce,applyCanvasSize:Ce}),[Ce,ce,f,Y,B,A]);return s.useEffect(()=>{if(!J){O(null);return}S(!1);const F=new Blob([J],{type:"text/html"}),W=URL.createObjectURL(F);return O(W),()=>{URL.revokeObjectURL(W)}},[J,S]),{toolHtml:J,toolData:z,iframeSrc:N,mountViewerTimelineDock:v,publishedTimeline:f,viewerPresets:A,initialDockTimeline:U,viewerCanvasSize:Y,viewerPresetController:xe}}function co(t){const{data:o,isLoading:n}=Zt({queryKey:["original-tool",t==null?void 0:t.remixed_from],queryFn:async()=>{let r=t;for(let l=0;l<10&&(r!=null&&r.remixed_from);l++)r=await ct.entities.Tool.get(r.remixed_from);if(!r||r.id===t.id)return null;const a=r.creator_name||r.created_by;return{originalTool:r,originalCreatorName:a??null}},enabled:!!(t!=null&&t.remixed_from),staleTime:6e4});return{originalTool:(o==null?void 0:o.originalTool)??null,originalCreatorName:(o==null?void 0:o.originalCreatorName)??null,isLoading:n}}function ys({slug:t,toolId:o}){const{data:n,isLoading:r,error:a,refetch:l}=Zt({queryKey:["tool-viewer",t,o],queryFn:async()=>!t&&!o?null:Ks({id:o,slug:t}),enabled:!!(t||o),staleTime:6e4}),h=a instanceof Error&&a.message.toLowerCase().includes("authentication required"),c=(n==null?void 0:n.tool)??null,p=(n==null?void 0:n.implementation)??null,x=c==null?void 0:c.uuid,[S,g]=s.useState(null),[d,j]=s.useState(null),[P,b]=s.useState(null);s.useEffect(()=>{if(!c)return;let v=!1;return(async()=>{try{const{code:f,controlsSchema:E}=await zs(c,p);v||(j(p),g(f),b(E))}catch(f){if(console.error("[ToolViewer] Failed to resolve canvas code:",f),!v){const E=Gs(c);g(U=>U===E?U:E)}}})(),()=>{v=!0}},[p,c]);const u=(c==null?void 0:c.creator_name)||(c==null?void 0:c.created_by),k=c?ln(c):null,{originalTool:N,originalCreatorName:O}=co(c),A=N?ln(N):null,R=s.useMemo(()=>N?{name:N.name,href:He(N)?Ie({id:N.id,slug:N.slug??void 0}):void 0,creatorName:O??void 0,creatorHref:O&&N.creator_id?Qt(N.creator_id):void 0}:null,[N,O]);return{tool:c,isLoading:r,error:a,isAuthRequired:h,initialImplementation:p,toolUuid:x,resolvedCode:S,resolvedImpl:d,resolvedSchema:P,creatorName:u,creatorHref:k,originalTool:N,originalCreatorName:O,originalCreatorHref:A,desktopRemixInfo:R,refetchToolData:()=>void l()}}function ks({iframeRef:t,timelineDockRef:o,toolNameForExport:n,toolUuid:r,userId:a,isMobile:l,showDevModeFeatures:h,sendAssetExported:c,setShowExport:p,setExportedFile:x}){const S=Ws(),[g,d]=s.useState(-1),[j,P]=s.useState(!1),b=s.useRef(!1),{recording:u,recordingProgress:k,startRecording:N,stopRecording:O}=Ur(t,n,f=>{if(c({assetData:"video",exportData:{method:"screen-recording",format:f.format,fps:f.fps,duration:f.duration,qual
6ity:f.quality,action:"download",filename:f.filename,mime_type:f.mimeType},exportType:"video"}),b.current&&f.blob&&r&&a){const E=f.blob,U=r;(async()=>{try{const J=E.type.includes("mp4")?"mp4":"webm",z=new File([E],`export-${Date.now()}.${J}`,{type:E.type}),B=await qs(z,{awaitStream:!1}),{export:D}=await lr({tool_uuid:U,file_url:B.file_url,export_kind:"video",file_size_bytes:E.size});ge.success("Saved to exports gallery."),S.invalidateQueries({queryKey:["tool-exports",U]}),D!=null&&D.id&&Xs(B.file_url,{requestPayload:{tool_export_id:D.id}}).then(async Y=>{if(!Y.ok){console.warn("[ToolViewer] Export video stream was not created:",Y);return}const ce=await ct.entities.ToolExport.get(D.id).catch(()=>null);(ce==null?void 0:ce.file_url)===B.file_url&&(await ct.entities.ToolExport.update(D.id,{stream_format:Y.stream.stream_format,stream_url:Y.stream.stream_url}),S.invalidateQueries({queryKey:["tool-exports",U]}))}).catch(Y=>{console.warn("[ToolViewer] Failed to attach export video stream:",Y)})}catch{ge.error("Export wasn't saved due to a technical issue. Try again.")}})()}b.current=!1},(f,E)=>{if(p(!1),l)return;const U=zr(E),J=n.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-"),z=new Date().toISOString().slice(0,10);x(new File([f],`${J}-${z}.${U}`,{type:E}))}),A=s.useCallback(f=>{var E;b.current=f.saveToGallery??!1,(E=o.current)==null||E.playFromStart(),N(f)},[N,o]),{data:R=[]}=Zt({queryKey:["tool-exports",r],enabled:h&&!!r,staleTime:3e4,queryFn:async()=>await ct.entities.ToolExport.filter({tool_uuid:r,archived:!1},"-created_date",100)}),v=s.useCallback(async f=>{try{await ct.entities.ToolExport.update(f,{archived:!0}),d(E=>{const U=E-1;return U<-1?-1:U}),S.invalidateQueries({queryKey:["tool-exports",r]})}catch{ge.error("Export wasn't deleted due to a technical issue. Try again.")}},[S,r]);return s.useEffect(()=>{if(g<0)return;const f=E=>{E.key==="Escape"&&d(-1)};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[g]),{recording:u,recordingProgress:k,handleStartRecording:A,stopRecording:O,toolExports:R,handleDeleteExport:v,exportIndex:g,setExportIndex:d,galleryOpen:j,setGalleryOpen:P}}function js({tool:t,user:o,profile:n,setProfile:r,openAuthModal:a,onWillSave:l}){const[h,c]=s.useState(!1),p=s.useMemo(()=>{var g;return!!(t&&((g=n==null?void 0:n.saved_tools)!=null&&g.includes(t.id)))},[t,n==null?void 0:n.saved_tools]),x=s.useCallback(async()=>{if(!t)return;if(!o||!n){a(()=>S.current(),"tool_viewer_save");return}const g=!p,d=g?[...n.saved_tools??[],t.id]:(n.saved_tools??[]).filter(j=>j!==t.id);r({...n,saved_tools:d}),g&&(l==null||l(),c(!0),setTimeout(()=>c(!1),1400));try{t.uuid&&await as(g?"save":"unsave",t.uuid)}catch{r({...n,saved_tools:n.saved_tools??[]}),ge.error("Tool wasn't saved due to a technical issue. Try again.")}},[t,o,n,r,p,a,l]),S=s.useRef(x);return S.current=x,{isSaved:p,showSavedPopup:h,handleToggleSave:x}}function uo(){var Xe;const t=Pn(),o=Hr(),[n]=Mn(),r=n.get("slug"),a=n.get("id"),l=r&&r!=="undefined"?r:null,h=a&&a!=="undefined"?a:null,[c,p]=s.useState(!1),[x,S]=s.useState(null),[g,d]=s.useState("controls"),j=Je(ns),P=Je(ss),b=Je(ts),{user:u}=Jt(),{profile:k,setProfile:N,loading:O}=Gn(),{sendPageClicked:A}=On(),v=(u==null?void 0:u.role)==="admin"||P,f=An(),{controlsOpen:E,setControlsOpen:U,controlsDrawerHeight:J,setControlsDrawerHeight:z,panelWidth:B,setPanelWidth:D,timelineTrackKeys:Y,handleTrackKeysChange:ce,revealControlTarget:Ce,handleRevealControl:xe,iframeReady:F,setIframeReady:W,controlsTouched:ne,setControlsTouched:H,adminMobileView:me,toggleAdminMobileView:pe}=ms(),[Ee,Me]=s.useState(!1),[Ze,he]=s.useState("canvas"),ie=s.useRef(null),y=s.useRef(null),_=s.useRef(null);s.useLayoutEffect(()=>{if(!Ee||!y.current)return;const M=_t.fromTo(y.current,{opacity:0,y:40,scale:.95},{opacity:1,y:0,scale:1,duration:.35,ease:"back.out(1.7)"});return()=>{M.kill()}},[Ee,Ze]);const w=s.useRef(null),i=s.useRef(null),{fullscreenRef:$,isFullscreen:G,isFillScreen:we,isToolbarVisible:I,enter:ve,exit:Oe,toggleFillScreen:de,pinToolbar:Ot,unpinToolbar:Te}=cr(w);s.useEffect(()=>{window.scrollTo(0,0);const M=document.documentElement,T=document.body,te={htmlOverflow:M.style.overflow,bodyOverflow:T.style.overflow,htmlScrollbarGutter:M.style.scrollbarGutter,bodyPosition:T.style.position,bodyTop:T.style.top,bodyLeft:T.style.left,bodyRight:T.style.right,bodyWidth:T.style.width};return M.style.overflow="hidden",T.style.overflow="hidden",M.style.scrollbarGutter="auto",f&&(T.style.position="fixed",T.style.top="0",T.style.left="0",T.style.right="0",T.style.width="100%"),()=>{M.style.overflow=te.htmlOverflow,T.style.overflow=te.bodyOverflow,M.style.scrollbarGutter=te.htmlScrollbarGutter,T.style.position=te.bodyPosition,T.style.top=te.bodyTop,T.style.left=te.bodyLeft,T.
6style.right=te.bodyRight,T.style.width=te.bodyWidth}},[f]);const{tool:m,isLoading:Q,error:Ae,isAuthRequired:Ue,initialImplementation:At,toolUuid:ze,resolvedCode:se,resolvedImpl:ye,resolvedSchema:Ft,creatorName:ue,creatorHref:ke,originalTool:ae,originalCreatorName:et,originalCreatorHref:xt,desktopRemixInfo:q,refetchToolData:Dt}=ys({slug:l,toolId:h});s.useEffect(()=>{u!=null&&u.id&&(m!=null&&m.id)&&is(u.id,m.id)},[u==null?void 0:u.id,m==null?void 0:m.id]);const{sendToolViewAction:V}=ps({toolId:m==null?void 0:m.id}),{sendAssetExported:Fe}=Kn({toolId:m==null?void 0:m.id,toolViewMode:"viewer"}),De=m?`${(((Xe=m.description)==null?void 0:Xe.trim())||Fn(m)).slice(0,150)} · Made with Brik`:void 0;Dn("ToolViewer",{title:m?`${m.name} -- Brik`:void 0,description:De,image:$n(m,Qe.appId),url:typeof window>"u"?void 0:`${window.location.origin}${window.location.pathname}${window.location.search}`}),os(He(m)?Bn(m,window.location.origin,Qe.appId):null);const je=(m==null?void 0:m.name)||"tool",{recording:_e,recordingProgress:Re,handleStartRecording:Se,stopRecording:$t,toolExports:K,handleDeleteExport:fe,exportIndex:Z,setExportIndex:Le,galleryOpen:$e,setGalleryOpen:Bt}=ks({iframeRef:w,timelineDockRef:i,toolNameForExport:je,toolUuid:ze,userId:u==null?void 0:u.id,isMobile:f,showDevModeFeatures:v,sendAssetExported:Fe,setShowExport:p,setExportedFile:S}),[Vt,tt]=s.useState(void 0);s.useEffect(()=>{tt(void 0)},[ye==null?void 0:ye.uuid]);const{openAuthModal:Ge,registerOAuthRedirectProvider:Ht}=Vn(),{toolHtml:mt,toolData:re,iframeSrc:ee,mountViewerTimelineDock:nt,publishedTimeline:ht,viewerPresets:st,initialDockTimeline:rt,viewerCanvasSize:Ne,viewerPresetController:ot}=vs({tool:m,resolvedCode:se,resolvedImpl:ye,resolvedSchema:Ft,initialImplementation:At,creatorName:ue,isMobile:f,useNewControlsPanel:j,animationTimelineEnabled:b,setIframeReady:W,iframeRef:w,timelineDockRef:i});gs({tool:m,toolUuid:ze,navigate:t,sendToolViewAction:V,setPanelWidth:D,setControlsTouched:H,setIframeReady:W,iframeRef:w,iframeReady:F,originalTool:ae,originalCreatorName:et}),s.useEffect(()=>{H(!1)},[ee,H]),s.useEffect(()=>{D(320)},[l,h,m==null?void 0:m.id,D]);const{activeStream:ft}=Br(w,ee),{visible:bt,toggle:It}=dr();Vr(w,ee),rs(),s.useEffect(()=>{if(!(!f||!ee))return he("canvas"),Me(!0),ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>Me(!1),5e3),()=>{ie.current&&clearTimeout(ie.current)}},[f,ee]);const{openExportAuthWall:Ke}=fs({tool:m,iframeRef:w,iframeReady:F,openAuthModal:Ge,registerOAuthRedirectProvider:Ht,setShowExport:p,setControlsTouched:H,user:u,profileLoading:O}),{isSaved:Be,showSavedPopup:We,handleToggleSave:Ut}=js({tool:m,user:u,profile:k,setProfile:N,openAuthModal:Ge,onWillSave:()=>Me(!1)});s.useLayoutEffect(()=>{if(!We||!_.current)return;const M=_t.fromTo(_.current,{opacity:0,y:12,scale:.9},{opacity:1,y:0,scale:1,duration:.4,ease:"back.out(2)"}),T=_t.to(_.current,{opacity:0,y:-8,delay:1,duration:.35,ease:"power2.in"});return()=>{M.kill(),T.kill()}},[We]);const{showShareModal:gt,setShowShareModal:qe,handleShare:it}=xs(m??void 0),C=m==null?void 0:m.id,{remixing:L,handleRemix:oe}=ws({tool:m,user:u,navigate:t,openAuthModal:Ge,sendToolViewAction:V}),wt=bs({animationTimelineEnabled:b,liveTimeline:Vt,publishedTimeline:ht});if(Ue)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center px-4",style:{background:f?"#ffffff":"#E8E8E8"},children:[e.jsx("h2",{className:"text-lg font-medium text-[#1a1a1a] mb-1 tracking-[-0.24px]",children:"Private Tool"}),e.jsx("p",{className:"text-sm text-[#7d7d7d] mb-4",children:"Login to view this tool."}),e.jsx("button",{onClick:()=>{A({button_name:"tool_viewer_login"}),Ge(Dt,"tool_viewer_login")},className:"flex h-[36px] items-center justify-center rounded-[10px] bg-black px-[15px] text-[12px] font-medium tracking-[-0.24px] text-white transition-opacity hover:opacity-90",children:"Login"})]});if(Ae||!Q&&!m)return e.jsx(Hn,{});const Ve=!f&&j&&!!re;return e.jsxs(es,{children:[m&&e.jsxs("div",{className:X("flex flex-col",f?"h-[100dvh] overflow-hidden transition-[padding] duration-300 ease-out":"pt-[100px] lg:pt-0",!f&&(Ve?"h-[100dvh] overflow-hidden":"min-h-[100dvh]")),style:{background:f?"#ffffff"
6:"#E8E8E8",paddingBottom:f&&E?J:void 0},children:[f?E?null:e.jsx("div",{className:X("shrink-0 transition-opacity",_e&&"pointer-events-none opacity-50"),"aria-hidden":_e||void 0,style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:e.jsx(un,{inverted:!0,buildButtonStyle:"secondary",mobileSlimLeadingAction:e.jsx("button",{type:"button",onClick:()=>{var T;V("Back"),(((T=window.history.state)==null?void 0:T.idx)??0)>0?t(-1):t(Ys("Home"))},"aria-label":"Back",className:"lg:hidden flex items-center justify-center shrink-0 h-[40px] w-[40px] rounded-[10px] bg-transparent text-black hover:bg-black/5 transition-colors",children:e.jsx(qt,{className:"w-[20px] h-[20px]",strokeWidth:2})}),mobileSlimAction:e.jsxs("div",{className:"flex items-center gap-[6px]",children:[e.jsxs("div",{className:"flex items-center gap-0",children:[e.jsx("button",{type:"button",onClick:()=>{V("Save"),Ut()},"aria-label":Be?"Unsave":"Save",title:Be?"Unsave":"Save",className:"flex items-center justify-center shrink-0 h-[36px] w-[36px] rounded-[10px] bg-transparent text-black hover:bg-black/5 transition-colors",children:e.jsx(Wt,{className:X("w-[16px] h-[16px]",Be&&"fill-current"),strokeWidth:2})}),e.jsx("button",{type:"button",onClick:()=>{V("Share"),it()},"aria-label":"Share",title:"Share",className:"flex items-center justify-center shrink-0 h-[36px] w-[36px] rounded-[10px] bg-transparent text-black hover:bg-black/5 transition-colors",children:e.jsx(ur,{className:"w-[16px] h-[16px]",strokeWidth:2})})]}),e.jsxs("button",{type:"button",onClick:()=>{V("Remix"),oe()},disabled:L,"aria-label":"Remix",className:"flex items-center justify-center shrink-0 h-[36px] px-[12px] gap-[6px] rounded-[10px] bg-white border border-solid border-[#e1e1e1] text-black text-[12px] font-medium tracking-[-0.24px] hover:bg-neutral-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(dt,{size:12}),L?"Cloning...":"Remix"]}),e.jsxs("button",{type:"button",onClick:()=>{if(V("Export"),!u){Ke("tool_viewer_mobile_topbar");return}p(!0)},"aria-label":"Export",className:"flex items-center justify-center shrink-0 h-[36px] px-[12px] gap-[6px] rounded-[10px] text-white border border-solid border-transparent text-[12px] font-medium tracking-[-0.24px] shadow-[0_6px_16px_rgba(255,89,241,0.25),inset_0_1px_4px_0_#ffd9e8]",style:{background:"linear-gradient(180deg, #FF4447 0%, #FF59F1 100%) padding-box, linear-gradient(180deg, #FFB8BA 0%, #FFB8F8 100%) border-box"},children:[e.jsx(pr,{className:"size-[14px] shrink-0"}),"Export"]})]})})}):e.jsx("div",{className:`fixed lg:static left-0 right-0 z-20 flex justify-center lg:justify-stretch pointer-events-none lg:pointer-events-auto px-[20px] top-[20px] lg:top-auto lg:transition-[transform,opacity] lg:duration-300 ${o?"lg:-translate-y-full lg:opacity-0":""}`,children:e.jsx("div",{className:"pointer-events-auto w-full",children:e.jsx(un,{inverted:!0,buildButtonStyle:"secondary",slimDesktopLeading:m?e.jsx("span",{className:"text-[12px] font-medium tracking-[-0.24px] text-black whitespace-nowrap",children:m.name}):null,children:m&&e.jsxs("div",{className:"hidden lg:flex shrink-0 items-center gap-[5px]",children:[v&&e.jsx("button",{type:"button",onClick:()=>{V("Edit"),t(`/tooleditor/${m.id}`)},className:"flex h-[40px] shrink-0 items-center gap-[8px] rounded-[10px] border border-[#e1e1e1] bg-amber-600 px-[15px] text-[12px] font-medium tracking-[-0.24px] text-white whitespace-nowrap transition-opacity hover:opacity-80",style:{borderStyle:"solid"},children:"Edit (Admin)"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-[5px]",children:[e.jsx($r,{}),e.jsx(xr,{onClick:()=>{V("Share"),it()}}),e.jsxs("button",{type:"button",onClick:oe,disabled:L,className:"flex h-[40px] items-center justify-center gap-[8px] rounded-[10px] border border-[#e1e1e1] bg-white px-[15px] text-[12px] font-medium tracking-[-0.24px] text-black whitespace-nowrap transition-colors hover:bg-neutral-50 disabled:opacity-50 disabled:cursor-not-allowed",style:{borderStyle:"solid"},children:[e.jsx(dt,{size:12}),L?"Cloning...":"Remix"]}),e.jsx(mr,{biButtonName:"tool_viewer_export",onExport:()=>{if(V("Export"),!u){Ke("tool_viewer_topbar");return}p(!0)}})]})]})})})}),f&&(m==null?void 0:m.name)&&e.jsxs("div",{className:"shrink-0 px-[30px] pt-[15px] pb-[20px] flex items-center justify-between gap-[8px]",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"text-[16px] font-medium text-black tracking-[-0.32px] truncate",children:m.name}),ue&&e.jsxs("span",{className:"text-[14px] text-[#686868] tracking-[-0.28px] truncate",children:["by"," ",ke?e.jsx(Pe,{to:ke,className:"hover:underline",children:ue}):ue]}),ae&&e.jsxs("span",{className:"flex items-center gap-[3px] text-[10px] text-[#888] tracking-[-0.2px] truncate",children:[e.jsx(dt,{size:8,className:"mr-[3px]"}),e.jsx("span",{children:"Remixed:"}),He(ae)?e.jsx(Pe,{to:Ie({id:ae.id,slug:ae.slug??void 0}),className:"hover:underline",children:ae.name}):e.jsx("span",{children:ae.name}),et&&xt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"by"}),e.jsx(Pe,{to:xt,className:"hover:underline",children:et})]})]})]}),v&&e.jsxs("button",{type:"button",onClick:pe,title:me?"Switch to user view":"Switch to admin view","aria-pressed":me,className:X("shrink-0 flex items-center gap-[5px] h-[28px] px-[10px] rounded-[8px] text-[11px] font-medium tracking-[-0.22px] transition-colors",me?"bg-amber-600 text-white":"bg-[#E8E8E8] text-[#555]"),children:[e.jsx(ds,{className:"w-3 h-3 shrink-0"}),me?"Admin view":"User view"]}),ne&&e.jsxs("button",{type:"button",onClick:()=>{A({button_name:"tool_viewer_mobile_reset"}),pt(w,In),H(!1)},className:"shrink-0 flex items-center gap-[4px] h-[28px] px-[10px] rounded-[8px] text-[12px] font-medium text-[#666] tracking-[-0.24px] hover:bg-black/5 transition-colors",children:[e.jsx(Ar,{className:"w-[12px] h-[12px]",strokeWidth:2}),"Reset"]})]}),e.jsx("div",{className:X("flex flex-col min-h-0",f?"mx-[20px]":"ml-[20px] mr-[20px] mt-[10px] mb-[20px]",$e&&K.length>0?"hidden":"flex-1"),children:e.jsx(Wn,{initialConfig:{},children:e.jsx("div",{className:"tool-stage flex-1 flex flex-col min-h-0 relative overflow-hidden",style:{border:"none",borderRadius:"10px",background:"transparent"},children:mt?e.jsx(e.Fragment,{children:e.jsxs("div",{ref:$,className:X("relative flex-1 min-h-0 w-full overflow-hidden transition-colors duration-150 ease-out",f?"flex items-center justify-center pb-[16
6px]":"",Ve?"flex flex-row gap-[10px]":"",G?"fixed inset-0 z-[9999] rounded-none bg-[#E8E8E8]":""),style:f&&!G?{containerType:"size"}:void 0,tabIndex:G?-1:void 0,"aria-label":G?"Fullscreen tool viewer":void 0,children:[e.jsxs("div",{className:X(Ve?"relative flex-1 min-w-0 h-full":"contents"),children:[(()=>{const M=f&&!G,T=Ne==null?void 0:Ne.width,te=Ne==null?void 0:Ne.height,vt=T&&T>0?T:1200,yt=te&&te>0?te:800;return e.jsxs("div",{className:X("relative",M?"rounded-[10px] overflow-hidden bg-white":"absolute inset-0 z-0 h-full w-full"),style:M?{aspectRatio:`${vt} / ${yt}`,width:`min(100cqw, calc(100cqh * ${vt} / ${yt}))`,height:"auto"}:void 0,children:[e.jsx("iframe",{ref:w,src:ee??void 0,sandbox:Js,title:m.name,className:X("border-0",M?"absolute inset-0 h-full w-full":"absolute inset-0 z-0 h-full w-full")}),M&&_e&&e.jsxs("div",{className:"absolute top-[10px] right-[10px] z-10 flex items-center gap-[6px] pointer-events-none","aria-live":"polite",children:[e.jsx("span",{className:"w-[7px] h-[7px] rounded-full bg-[#FF3B30] animate-pulse shadow-[0_0_8px_rgba(255,59,48,0.6)]"}),e.jsxs("span",{className:"text-[11px] font-semibold tracking-[-0.22px] text-[#7d7d7d]",children:["REC IN PROGRESS",Re.duration?` ${Math.max(0,Math.ceil(Re.duration-Re.elapsed))}s`:""]})]})]})})(),e.jsx(hr,{stream:ft,visible:bt,onToggle:It}),!f&&e.jsx(fr,{panelWidth:B,visible:!G,trackPageClick:!1,viewerLayout:!0,onFullscreenClick:ve}),!f&&G?e.jsx(br,{visible:I,isFillScreen:we,onExit:Oe,onFillToggle:de,onHold:Ot,onRelease:Te}):null,!f&&_e&&!G?e.jsx(qn,{elapsed:Re.elapsed,duration:Re.duration,onStop:$t}):null,nt&&re?e.jsx(Xn,{ref:i,controlsSchema:re.controlsSchema,iframeRef:w,toolLoadKey:ee,chatCollapsed:!0,draftImplId:null,initialTimeline:rt,controlsPanelWidth:Ve?0:B,onTimelineChange:tt,onTrackKeysChange:ce,onRevealControl:xe,playbackLocked:_e}):null]}),Ve&&re?e.jsx(Nt,{mode:"desktop",controlsSchema:re.controlsSchema,iframeRef:w,toolLoadKey:ee,toolId:(m==null?void 0:m.id)??null,open:!0,toolName:m.name,creatorName:ue??void 0,creatorHref:m.creator_id?Qt(m.creator_id):void 0,remix:q,presetController:ot,timelineActive:nt&&Y.active,trackedControlKeys:Y.tracked,onToggleTrack:M=>{var T;return(T=i.current)==null?void 0:T.addOrRevealTrack(M)},revealControl:Ce,onPresetBiAction:V}):null]})}):e.jsx("div",{className:"flex-1"})})})}),v&&K.length>0&&e.jsxs("div",{className:`mx-[20px] mb-[20px] ${$e?"flex-1 flex flex-col min-h-0":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>Bt(M=>!M),className:"flex items-center gap-2 px-4 py-2 bg-white border border-[#e1e1e1] rounded-[8px] text-[12px] font-medium text-black hover:bg-[#f5f5f5] transition-colors",children:[e.jsx(Un,{className:"w-3.5 h-3.5"}),$e?"Hide Gallery":`Show Gallery (${K.length})`]}),$e&&e.jsx("div",{className:`mt-3 flex-1 overflow-y-auto grid gap-2 ${K.length===1?"grid-cols-1":K.length<=4?"grid-cols-2":"grid-cols-3"}`,children:K.map((M,T)=>e.jsxs("div",{className:"relative group/export aspect-video rounded-[8px] overflow-hidden cursor-pointer bg-[#111] border border-[#222] hover:border-[#444] transition-colors",onClick:()=>Le(T),children:[M.export_kind==="video"?e.jsx(St,{fallbackUrl:M.file_url,streamFormat:M.stream_format,streamUrl:M.stream_url,muted:!0,className:"absolute inset-0 w-full h-full object-cover"}):e.jsx("img",{src:M.file_url,alt:"",className:"absolute inset-0 w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:te=>{te.stopPropagation(),fe(M.id)},className:"absolute top-2 right-2 opacity-0 group-hover/export:opacity-100 transition-opacity flex items-center gap-1 px-2 py-1 rounded-[4px] bg-black/60 text-white text-[10px] hover:bg-red-600/80",children:e.jsx(ls,{className:"w-3 h-3"})})]},M.id))})]}),f&&m&&!E&&!($e&&K.length>0)&&e.jsxs(e.Fragment,{children:[e.jsx(Ct,{}),b&&Lt(ye==null?void 0:ye.timeline)&&e.jsx(Ct,{message:"This tool contains a timeline animation. Switch to desktop."}),e.jsx("div",{className:"shrink-0 px-[20px] pb-[20px]",style:{paddingBottom:"calc(20px + env(safe-area-inset-bottom, 0px))"},children:e.jsxs("div",{className:"flex w-full gap-[10px]",children:[e.jsxs("button",{type:"button","data-testid":Ye.viewerBottomBar.controls,onClick:()=>{V("Edit"),d("controls"),U(!0)},className:"flex h-[48px] flex-1 items-center justify-center gap-[8px] rounded-[10px] border border-solid border-[#e1e1e1] bg-white text-[12px] font-medium tracking-[-0.24px] text-black transition-colors hover:bg-[#fafafa]",children:[e.jsx(Fr,{className:"w-[12px] h-[12px]",strokeWidth:2}),"Edit Controls"]}
6),st.length>0?e.jsxs("button",{type:"button","data-testid":Ye.viewerBottomBar.presets,onClick:()=>{V("Presets"),d("presets"),U(!0)},className:"flex h-[48px] flex-1 items-center justify-center gap-[8px] rounded-[10px] border border-solid border-[#e1e1e1] bg-white text-[12px] font-medium tracking-[-0.24px] text-black transition-colors hover:bg-[#fafafa]",children:[e.jsx(Dr,{className:"size-[12px]"}),"Presets"]}):null]})})]}),v&&Z>=0&&K[Z]&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/90 flex items-center justify-center",onClick:()=>Le(-1),children:[e.jsx("button",{type:"button",onClick:()=>Le(-1),className:"absolute top-4 right-4 flex items-center justify-center w-8 h-8 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors",children:e.jsx(Rt,{className:"w-4 h-4"})}),K.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),Le(T=>T<=0?K.length-1:T-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 flex items-center justify-center w-10 h-10 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors",children:e.jsx(qt,{className:"w-5 h-5"})}),e.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),Le(T=>T>=K.length-1?0:T+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 flex items-center justify-center w-10 h-10 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors",children:e.jsx(cs,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"max-w-[90vw] max-h-[85vh] flex items-center justify-center",onClick:M=>M.stopPropagation(),children:K[Z].export_kind==="video"?e.jsx(St,{fallbackUrl:K[Z].file_url,streamFormat:K[Z].stream_format,streamUrl:K[Z].stream_url,controls:!0,autoPlay:!0,loop:!0,muted:!0,className:"max-w-full max-h-[85vh] rounded-[8px]"}):e.jsx("img",{src:K[Z].file_url,alt:`Export ${Z+1}`,className:"max-w-full max-h-[85vh] rounded-[8px] object-contain"})}),K.length>1&&e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white/50 text-[12px] tabular-nums",children:[Z+1," / ",K.length]})]}),f&&re&&(j||st.length>0?(console.info("[ToolViewer] rendering new ToolControlsPanel mobile",{controlsOpen:E,iframeSrc:ee,schemaCount:re.controlsSchema.length}),e.jsx(Nt,{mode:"mobile",controlsSchema:re.controlsSchema,iframeRef:w,toolLoadKey:ee,toolId:(m==null?void 0:m.id)??null,open:E,onClose:()=>U(!1),onHeightChange:z,presetController:ot,view:g,onPresetBiAction:V})):(console.info("[ToolViewer] rendering legacy MobileControlsDrawer",{controlsOpen:E,iframeSrc:ee,schemaCount:re.controlsSchema.length}),e.jsx(gr,{controlsSchema:re.controlsSchema,iframeRef:w,toolLoadKey:ee,toolId:(m==null?void 0:m.id)??null,open:E,onClose:()=>U(!1),onHeightChange:z}))),f?e.jsx(wr,{open:c,onClose:()=>p(!1),children:e.jsx(vr,{open:c,onClose:()=>p(!1),iframeRef:w,toolName:je,toolData:re??void 0,toolUuid:ze,isAdmin:v,modalOrigin:"tool_viewer_mobile_topbar",onStartRecording:Se,recording:_e,toolViewMode:"viewer",timeline:wt,onImageReady:()=>{p(!1)}})}):e.jsx(Yn,{open:c,onClose:()=>p(!1),iframeRef:w,toolName:je,toolData:re??void 0,toolUuid:ze,isAdmin:v,isOwner:!!(u!=null&&u.id)&&!!m&&u.id===m.user_id,modalOrigin:"tool_viewer_canvas_toolbar",onStartRecording:Se,recording:_e,toolViewMode:"viewer",timeline:wt,onImageReady:(M,T)=>{const te=`image/${T}`,vt=je.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-"),yt=new Date().toISOString().slice(0,10);fetch(M).then(zt=>zt.blob()).then(zt=>{p(!1),S(new File([zt],`${vt}-${yt}.${T}`,{type:te}))}).catch(()=>{p(!1)})}}),e.jsx(Jn,{file:x,toolName:je,toolSlug:(m==null?void 0:m.slug)??l,onClose:()=>S(null)}),f?e.jsx(no,{open:gt,toolName:je,toolSlug:(m==null?void 0:m.slug)??l,toolId:C,onClose:()=>qe(!1)}):e.jsx(Qn,{open:gt,autoDismissMs:3e4,toolName:je,toolSlug:(m==null?void 0:m.slug)??l,onClose:()=>qe(!1)}),We&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:e.jsxs("div",{ref:_,className:"flex items-center gap-[8px] bg-white/90 backdrop-blur-xl text-black border border-white/50 px-[20px] py-[12px] rounded-[12px] shadow-lg",children:[e.jsx(Wt,{className:"w-5 h-5 fill-current"}),e.jsx("span",{className:"text-[14px] font-medium tracking-[-0.28px]",children:"Saved to your collection"})]})})]}
6),e.jsx(Zn,{position:"fixed",background:f?"#ffffff":"#E8E8E8",visible:Q||!F})]})}const Gt="flex h-[30px] flex-1 items-center justify-center border border-[var(--product-grey-02)] bg-[var(--product-white-00)] text-[var(--product-black-00)] transition-colors hover:bg-[var(--product-grey-01)]";function po({shareUrl:t,copied:o,onCopyLink:n,onWhatsApp:r,onX:a,onTikTok:l,onClose:h}){return e.jsxs("div",{className:"flex w-[455px] flex-col border border-[var(--product-grey-03)] bg-[var(--product-white-00)]",children:[e.jsxs("div",{className:"flex items-start justify-between p-[12px]",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-[3px]",children:[e.jsx("p",{className:"text-[14px] leading-[1.2] tracking-[-0.14px] text-[var(--product-black-00)]",children:"Share this tool"}),e.jsx("p",{className:"text-[12px] leading-[1.3] tracking-[-0.12px] text-[var(--product-grey-04)]",children:"Share a link or post it directly to your channels"})]}),e.jsx("button",{type:"button",onClick:h,"aria-label":"Close",className:"flex size-[24px] shrink-0 items-center justify-center text-[var(--product-black-00)]",children:e.jsx(Cn,{className:"size-[15px]"})})]}),e.jsx(Qs,{}),e.jsx("div",{className:"border border-[var(--product-grey-02)] p-[12px]",children:e.jsxs("div",{className:"flex h-[36px] flex-1 items-center gap-[12px] border border-[var(--product-grey-02)] bg-[var(--product-white-00)] p-[8px]",children:[e.jsx("span",{className:"flex-1 truncate text-[12px] tracking-[-0.12px] text-[var(--product-grey-04)]",children:t??"Publish the tool first to get a shareable link."}),e.jsx("button",{type:"button",onClick:n,className:"shrink-0 whitespace-nowrap bg-[var(--product-black-00)] px-[8px] py-[4px] text-[12px] tracking-[-0.12px] text-[var(--product-white-00)] transition-opacity hover:opacity-90",children:o?"Copied!":"Copy Link"})]})}),e.jsxs("div",{className:"flex items-center py-[12px]",children:[e.jsx("p",{className:"flex-1 px-[24px] text-[12px] tracking-[-0.12px] text-[var(--product-black-00)]",children:"Or share directly"}),e.jsxs("div",{className:"flex flex-1 gap-[4px] px-[24px]",children:[e.jsx("button",{type:"button","aria-label":"Share on WhatsApp",onClick:r,className:Gt,children:e.jsx(yr,{className:"size-[22px]"})}),e.jsx("button",{type:"button","aria-label":"Share on X",onClick:a,className:Gt,children:e.jsx(qr,{className:"size-[22px]"})}),e.jsx("button",{type:"button","aria-label":"Share on TikTok",onClick:l,className:Gt,children:e.jsx(Xr,{className:"size-[22px]"})})]})]})]})}function xo({open:t,onOpenChange:o,toolName:n,toolSlug:r,toolId:a}){En({open:t,modalName:"share_tool_modal"});const{shareUrl:l,copied:h,handleCopyLink:c,handleWhatsApp:p,handleX:x,handleTikTok:S}=kr({toolName:n,toolSlug:r,toolId:a});return e.jsxs(Gr,{open:t,onOpenChange:o,children:[e.jsx(Kr,{asChild:!0,children:e.jsx(zn,{size:"big",skin:"ghost",priority:"primary","aria-label":"Share",className:"border-l border-[var(--product-grey-02)]",glyphClassName:"size-[18px]",icon:e.jsx(jr,{className:"size-full shrink-0"})})}),e.jsx(Wr,{align:"end",side:"bottom",sideOffset:0,className:"w-auto rounded-none border-0 bg-transparent p-0 shadow-none",onOpenAutoFocus:g=>g.preventDefault(),children:e.jsx(po,{shareUrl:l,copied:h,onCopyLink:c,onWhatsApp:p,onX:x,onTikTok:S,onClose:()=>o(!1)})})]})}const hn=35,mo=500,ho=5e3,fn="Join Brik",fo=({onClick:t})=>{const o=s.useRef(null);return s.useEffect(()=>{const n=o.current;if(!n||matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=[...n.querySelectorAll(".brik-nav-flip-letter")];if(!r[r.length-1])return;let l=!1,h=0,c=0;const p=mo+(r.length-1)*hn,x=()=>{window.clearTimeout(h),!l&&(h=window.setTimeout(()=>{if(l||n.matches(":hover")||n.classList.contains("is-flipping")){x();return}n.classList.add("is-flipping"),c=window.setTimeout(()=>{l||n.classList.remove("is-flipping"),x()},p)},ho))};return x(),()=>{l=!0,window.clearTimeout(h),window.clearTimeout(c),n.classList.remove("is-flipping")}},[]),e.jsx("button",{ref:o,type:"button",className:"jbt brik-nav-flip text-product-title","aria-label":fn,onClick:t,children:[...fn].map((n,r)=>e.jsx("span",{className:"brik-nav-flip-letter inline-block whitespace-pre",style:{animationDelay:`${r*hn}ms`},children:n},`${n}-${r}`))})},at="Join Brik",be=6,bn=.85,gn=.7,wn=.4,kt=740,bo=800,go=440,vn=100,wo=300,vo=90,yo=5e3,ko=.16,jo=.34,_o=.9,So=400,No=950,Kt=70,Yt="#193EF9",yn="#ffffff",kn={bg:"transparent",ink:Yt},jt=[{bg:Yt,ink:yn},{bg:yn,ink:Yt}];function _s(t,o,n,r){const a=3*t,l=3*(n-t)-a,h=1-a-l,c=3*o,p=3*(r-o)-c,x=1-c-p,S=d=>((h*d+l)*d+a)*d,g=d=>(3*h*d+2*l)*d+a;return d=>{if(d<=0)return 0;if(d>=1)return 1;let j=d;for(let P=0;P<8;P++){const b=S(j)-d;if(Math.abs(b)<1e-6)break;const u=g(j);if(Math.abs(u)<1e-6)break;j-=b/u}return((x*j+p)*j+c)*j}}const Co=_s(.62,0,.38,1),jn=_s(.23,1,.32,1);function lt(t,o,n,r,a){let l=0,h=!1;const c=performance.now();let p=()=>{};const x=new Promise(g=>{p=g}),S=g=>{if(h)return;const d=n<=0?1:Math.min(1,(g-c)/n);a(t+(o-t)*(r?r(d):d)),d<1?l=requestAnimationFrame(S):p(!0)};return l=requestAnimationFrame(S),{finished:x,stop:()=>{h=!0,cancelAnimationFrame(l),p(!1)}}}function _n(t){let o=()=>{};const n=new Promise(a=>{o=a}
6),r=window.setTimeout(()=>o(!0),t);return{finished:n,stop:()=>{window.clearTimeout(r),o(!1)}}}function Ss(t){return t<0?0:t>1?1:t}function Sn(t,o,n){const r=n-1-o,a=n-1,l=bn*Math.pow(r,gn),h=bn*Math.pow(a,gn),c=1-wn*(r/a),p=h+(1-wn),x=Ss((t*p-l)/c);return x*x*(3-2*x)}function le(t,o,n){const r=document.createElement(t);return r.className=o,n&&(r.textContent=n),r}function Eo(t){const o=matchMedia("(prefers-reduced-motion: reduce)").matches,n=matchMedia("(hover: hover) and (pointer: fine)").matches,r=le("span","jn-shell"),a=le("span","jn-cube");r.appendChild(a),t.appendChild(r);const l=[],h=[];let c=null,p=null,x=null,S=null;for(let y=0;y<4;y++){const _=le("span","jn-face");if(_.style.setProperty("--k",String(y)),y===0){const w=le("span","jn-fill");p=le("span","jn-base"),w.appendChild(p),x=le("span","jn-lbl jn-ink",at),w.appendChild(x);for(let i=0;i<be;i++){const $=le("span","jn-slice jn-slice-ink"),G=le("span","jn-lbl",at);$.appendChild(G),w.appendChild($),l.push({el:$,lbl:G})}S=le("span","jn-revbg"),w.appendChild(S);for(let i=0;i<be;i++){const $=le("span","jn-slice jn-slice-rev"),G=le("span","jn-lbl",at);$.appendChild(G),w.appendChild($),h.push({el:$,lbl:G})}c=w,_.appendChild(w),_.appendChild(le("span","jn-rest",at))}else _.className="jn-face jn-face-back",_.appendChild(le("span","jn-lbl",at));a.appendChild(_)}let g=0,d=0,j=1,P=-1,b=!1,u=!1,k=1,N=kt,O=null,A=0,R=null,v=null,f=null,E=null,U=null,J=!1,z=!1;const B=t.parentElement,D=[];function Y(y){const _=performance.now();for(D.push({x:y.clientX,y:y.clientY,t:_});D.length>1&&_-D[0].t>Kt;)D.shift()}function ce(){if(D.length<3)return null;const y=D[0],_=D[D.length-1];if(performance.now()-_.t>Kt)return null;const w=_.y-y.y;return Math.abs(w)<2?null:w>0?-1:1}function Ce(){if(D.length<3)return null;const y=D[0],_=D[D.length-1];if(performance.now()-_.t>Kt)return null;const w=Math.max(1,_.t-y.t);return Math.hypot(_.x-y.x,_.y-y.y)/w}function xe(){const y=Ce();if(y===null)return kt;const _=kt*_o/Math.max(y,.05);return Math.min(No,Math.max(So,_))}function F(y){J=y,B==null||B.classList.toggle("is-3d",y),y||(a.style.transform=""),H()}function W(y,_){const w=O;O=null,w==null||w.stop(),F(!0),g=0,A=performance.now()+_;const i=lt(0,y,_,Co,$=>{g=$,H()});O=i,i.finished.then($=>{O!==i||z||(O=null,$&&F(!1))})}function ne(){if(!c)return;const y=c.getBoundingClientRect();if(!y.height)return;const _=window.devicePixelRatio||1,w=[];for(let i=0;i<=be;i++){const $=y.top+y.height*i/be;w.push(Math.round($*_)/_-y.top)}w[0]=0,w[be]=y.height,E={h:y.height,e:w};for(let i=0;i<be;i++)l[i].el.style.clipPath=`inset(${w[i].toFixed(3)}px 0 ${(y.height-w[i+1]).toFixed(3)}px 0)`}function H(){if(a.style.transform=J?`rotateX(${g}
6deg)`:"",!E||!p||!S||!x)return;const y=P<0?kn:jt[P%jt.length],_=b?kn:y,w=b?y:jt[(P+1)%jt.length];p.style.background=_.bg,S.style.background=w.bg;const i=["100% 0%","100% 100%"];for(let I=be-1;I>=0;I--){const Oe=`${((1-Sn(d,I,be))*100).toFixed(3)}%`;i.push(`${Oe} ${(E.e[I+1]/E.h*100).toFixed(4)}%`),i.push(`${Oe} ${(E.e[I]/E.h*100).toFixed(4)}%`)}S.style.clipPath=`polygon(${i.join(",")})`;const $=d>0;if($!==U){U=$,x.style.display=$?"none":"";for(const I of l)I.el.style.display=$?"":"none"}x.style.color=_.ink;const G=(1-Math.cos(2*Math.PI*Ss(d)))/2,we=B&&parseFloat(getComputedStyle(B).fontSize)||0;for(let I=0;I<be;I++){const ve=Sn(d,I,be),de=`translateX(${(-((1-Math.cos(2*Math.PI*ve))/2*ko+G*jo)*j*we).toFixed(3)}px)`;$&&(l[I].lbl.style.color=_.ink,l[I].lbl.style.transform=de),h[I].el.style.clipPath=`inset(${E.e[I].toFixed(3)}px 0 ${(E.h-E.e[I+1]).toFixed(3)}px ${((1-ve)*100).toFixed(2)}%)`,h[I].lbl.style.color=w.ink,h[I].lbl.style.transform=de}}let me=0;function pe(){window.clearTimeout(me),me=window.setTimeout(Ee,yo)}function Ee(){if(z||o||u||b){z||pe();return}W(360,kt),pe()}async function Me(){if(u||z)return;u=!0,v==null||v.stop(),b=!1,j=1,t.classList.add("is-filling"),ne();const y=J?Math.max(0,A-performance.now()):null;y==null&&W(k*360,N);let _=!1;f=()=>{_=!0};const w=_n(Math.max(0,(y??N)-vo));R=w;const i=await w.finished;if(!(_||z||!i))for(let $=P+1;!_&&!z;$++){d=0;const G=lt(0,1,bo,null,I=>{d=I,H()});if(R=G,!await G.finished||_||z)return;P=$,d=0,H();const we=_n(go);if(R=we,!await we.finished||_||z)return}}async function Ze(){if(!u||z)return;u=!1,f==null||f(),R==null||R.stop();const y=lt(j,0,vn,jn,i=>{j=i,H()}),_=lt(d,0,vn,jn,i=>{d=i,H()});if(v=_,await Promise.all([_.finished,y.finished]),u||z)return;if(P<0){d=0,H(),t.classList.remove("is-filling"),pe();return}b=!0,d=1,H();const w=lt(1,0,wo,null,i=>{d=i,H()});v=w,await w.finished,!(u||z)&&(d=0,P=-1,b=!1,j=1,H(),t.classList.remove("is-filling"),pe())}function he(y){const _=t.getBoundingClientRect(),w=y.clientY<_.top+_.height/2?-1:1,i=ce();k=i!==null?i:w,N=xe(),pe(),Me()}function ie(){Ze()}return window.addEventListener("pointermove",Y,{passive:!0}),window.addEventListener("resize",ne),n&&!o&&(t.addEventListener("pointerenter",he),t.addEventListener("pointerleave",ie),t.addEventListener("blur",ie)),o||pe(),H(),()=>{z=!0,window.clearTimeout(me),O==null||O.stop(),R==null||R.stop(),v==null||v.stop(),window.removeEventListener("pointermove",Y),window.removeEventListener("resize",ne),t.removeEventListener("pointerenter",he),t.removeEventListener("pointerleave",ie),t.removeEventListener("blur",ie),t.classList.remove("is-filling"),t.replaceChildren(),B==null||B.classList.remove("is-3d")}}const To=({onClick:t,className:o})=>{const n=s.useRef(null);return s.useEffect(()=>{const r=n.current;if(r)return Eo(r)},[]),e.jsx("div",{className:o?`jn-stage ${o}`:"jn-stage",children:e.jsx("button",{ref:n,type:"button",className:"jn","aria-label":"Join Brik",onClick:t})})};function Ro({iframeRef:t,toolHtml:o}){const n=s.useRef(null);return s.useEffect(()=>{var r;t.current=((r=n.current)==null?void 0:r.getIframeRef())??null},[o,t]),{previewRef:n}}function Lo(t,o){const[n,r]=s.useState(null);return s.useLayoutEffect(()=>{const a=t.current;if(!a||!o)return;let l;const h=()=>{const c=a.querySelector(".tool-stage"),p=a.querySelector(`[data-testid="${_r.topBar.root}"]`);if(!(c instanceof HTMLElement)||!(p instanceof HTMLElement))return;l.observe(c);const x=c.getBoundingClientRect(),S=p.getBoundingClientRect(),g=x.left+x.width/2-S.left;r(d=>d!=null&&Math.abs(d-g)<.5?d:g)};return l=new ResizeObserver(()=>{h()}),l.observe(a),h(),()=>l.disconnect()},[t,o]),o?n:null}const Nn="w-[176px]";function Po(){var it;const t=Pn(),[o]=Mn(),n=o.get("slug"),r=o.get("id"),a=n&&n!=="undefined"?n:null,l=r&&r!=="undefined"?r:null,[h,c]=s.useState(!1),[p,x]=s.useState(null),[S,g]=s.useState("controls"),d=Je(ns),j=Je(ss),P=Je(ts),{user:b}=Jt(),{profile:u,setProfile:k,loading:N}=Gn(),{sendPageClicked:O}=On(),A=(b==null?void 0:b.role)==="admin",R=A||j,v=An(),{controlsOpen:f,setControlsOpen:E,controlsDrawerHeight:U,setControlsDrawerHe
6ight:J,panelWidth:z,setPanelWidth:B,timelineTrackKeys:D,handleTrackKeysChange:Y,revealControlTarget:ce,handleRevealControl:Ce,iframeReady:xe,setIframeReady:F,controlsTouched:W,setControlsTouched:ne,adminMobileView:H,toggleAdminMobileView:me}=ms(),[pe,Ee]=s.useState(!1),[Me,Ze]=s.useState("canvas"),he=s.useRef(null),ie=s.useRef(null);s.useLayoutEffect(()=>{if(!pe||!ie.current)return;const C=_t.fromTo(ie.current,{opacity:0,y:40,scale:.95},{opacity:1,y:0,scale:1,duration:.35,ease:"back.out(1.7)"});return()=>{C.kill()}},[pe,Me]);const y=s.useRef(null),_=s.useRef(null),w=s.useRef(null);s.useEffect(()=>{window.scrollTo(0,0);const C=document.documentElement,L=document.body,oe={htmlOverflow:C.style.overflow,bodyOverflow:L.style.overflow,htmlScrollbarGutter:C.style.scrollbarGutter,bodyPosition:L.style.position,bodyTop:L.style.top,bodyLeft:L.style.left,bodyRight:L.style.right,bodyWidth:L.style.width};return C.style.overflow="hidden",L.style.overflow="hidden",C.style.scrollbarGutter="auto",v&&(L.style.position="fixed",L.style.top="0",L.style.left="0",L.style.right="0",L.style.width="100%"),()=>{C.style.overflow=oe.htmlOverflow,L.style.overflow=oe.bodyOverflow,C.style.scrollbarGutter=oe.htmlScrollbarGutter,L.style.position=oe.bodyPosition,L.style.top=oe.bodyTop,L.style.left=oe.bodyLeft,L.style.right=oe.bodyRight,L.style.width=oe.bodyWidth}},[v]);const{tool:i,isLoading:$,error:G,isAuthRequired:we,initialImplementation:I,toolUuid:ve,resolvedCode:Oe,resolvedImpl:de,resolvedSchema:Ot,creatorName:Te,creatorHref:m,originalTool:Q,originalCreatorName:Ae,originalCreatorHref:Ue,desktopRemixInfo:At,refetchToolData:ze}=ys({slug:a,toolId:l});s.useEffect(()=>{b!=null&&b.id&&(i!=null&&i.id)&&is(b.id,i.id)},[b==null?void 0:b.id,i==null?void 0:i.id]);const{sendToolViewAction:se}=ps({toolId:i==null?void 0:i.id}),{sendAssetExported:ye}=Kn({toolId:i==null?void 0:i.id,toolViewMode:"viewer"}),Ft=i?`${(((it=i.description)==null?void 0:it.trim())||Fn(i)).slice(0,150)} · Made with Brik`:void 0;Dn("ToolViewer",{title:i?`${i.name} -- Brik`:void 0,description:Ft,image:$n(i,Qe.appId),url:typeof window>"u"?void 0:`${window.location.origin}${window.location.pathname}${window.location.search}`}),os(He(i)?Bn(i,window.location.origin,Qe.appId):null);const ue=(i==null?void 0:i.name)||"tool",{recording:ke,recordingProgress:ae,handleStartRecording:et,stopRecording:xt,toolExports:q,handleDeleteExport:Dt,exportIndex:V,setExportIndex:Fe,galleryOpen:De,setGalleryOpen:je}=ks({iframeRef:y,timelineDockRef:w,toolNameForExport:ue,toolUuid:ve,userId:b==null?void 0:b.id,isMobile:v,showDevModeFeatures:R,sendAssetExported:ye,setShowExport:c,setExportedFile:x}),[_e,Re]=s.useState(void 0);s.useEffect(()=>{Re(void 0)},[de==null?void 0:de.uuid]);const{openAuthModal:Se,registerOAuthRedirectProvider:$t}=Vn(),{toolHtml:K,toolData:fe,iframeSrc:Z,mountViewerTimelineDock:Le,publishedTimeline:$e,viewerPresets:Bt,initialDockTimeline:Vt,viewerPresetController:tt}=vs({tool:i,resolvedCode:Oe,resolvedImpl:de,resolvedSchema:Ot,initialImplementation:I,creatorName:Te,isMobile:v,useNewControlsPanel:d,animationTimelineEnabled:P,chromeVariant:"v2",setIframeReady:F,iframeRef:y,timelineDockRef:w}),{previewRef:Ge}=Ro({iframeRef:y,toolHtml:K}),[Ht,mt]=s.useState(!1);s.useEffect(()=>{mt(!1)},[i==null?void 0:i.id]),gs({tool:i,toolUuid:ve,navigate:t,sendToolViewAction:se,setPanelWidth:B,setControlsTouched:ne,setIframeReady:F,iframeRef:y,iframeReady:xe,originalTool:Q,originalCreatorName:Ae,onToggleControlsPanelCollapsed:()=>mt(C=>!C)}),s.useEffect(()=>{ne(!1)},[Z,ne]),s.useEffect(()=>{B(320)},[a,l,i==null?void 0:i.id,B]),rs(),s.useEffect(()=>{if(!(!v||!Z))return Ze("canvas"),Ee(!0),he.current&&clearTimeout(he.current),he.current=setTimeout(()=>Ee(!1),5e3),()=>{he.current&&clearTimeout(he.current)}},[v,Z]);const{openExportAuthWall:re}=fs({tool:i,iframeRef:y,iframeReady:xe,openAuthModal:Se,registerOAuthRedirectProvider:$t,setShowExport:c,setControlsTouched:ne,user:b,profileLoading:N}),{isSaved:ee,showSavedPopup:nt,handleToggleSave:ht}=js({tool:i,user:b,profile:u,setProfile:k,openAuthModal:Se,onWillSave:()=>Ee(!1)}),st=s.useRef(null);s.useEffect(()=>{var C;
6nt&&((C=st.current)==null||C.dismiss(),st.current=ge.success("Saved to your collection",{icon:e.jsx(Wt,{className:"h-4 w-4 fill-current","aria-hidden":!0})}))},[nt]);const{showShareModal:rt,setShowShareModal:Ne,handleShare:ot}=xs(i??void 0),ft=f||h||rt,bt=s.useRef(null),[It,Ke]=s.useState(0);s.useEffect(()=>{const C=bt.current;if(!C){Ke(0);return}const L=new ResizeObserver(()=>Ke(C.offsetHeight));return L.observe(C),Ke(C.offsetHeight),()=>L.disconnect()},[v,i]);const{remixing:Be,handleRemix:We}=ws({tool:i,user:b,navigate:t,openAuthModal:Se,sendToolViewAction:se}),Ut=bs({animationTimelineEnabled:P,liveTimeline:_e,publishedTimeline:$e}),gt=Lo(_,R&&!v&&!!i&&!G&&!we);if(we)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center px-4",style:{background:"var(--product-grey-01)"},children:[e.jsx("h2",{className:"text-lg font-medium text-[#1a1a1a] mb-1 tracking-[-0.24px]",children:"Private Tool"}),e.jsx("p",{className:"text-sm text-[#7d7d7d] mb-4",children:"Login to view this tool."}),e.jsx("button",{onClick:()=>{O({button_name:"tool_viewer_login"}),Se(ze,"tool_viewer_login")},className:"flex h-[36px] items-center justify-center rounded-[10px] bg-black px-[15px] text-[12px] font-medium tracking-[-0.24px] text-white transition-opacity hover:opacity-90",children:"Login"})]});if(G||!$&&!i)return e.jsx(Hn,{});const qe=!v&&d&&!!fe;return e.jsxs(es,{children:[i&&e.jsxs("div",{className:X(!v&&"flex h-[100dvh] overflow-hidden"),children:[!v&&e.jsx(Sr,{markFill:"var(--product-black-00)"}),e.jsxs("div",{ref:_,className:X("flex flex-col flex-1 min-w-0",v&&"h-[100dvh] overflow-hidden transition-[padding] duration-300 ease-out",!v&&(qe?"h-[100dvh] overflow-hidden":"min-h-[100dvh]")),style:{background:"var(--product-grey-01)",paddingBottom:v&&f?Math.max(0,U-It):void 0},children:[v?e.jsx("div",{className:X("shrink-0 transition-opacity",ke&&"pointer-events-none opacity-50"),"aria-hidden":ke||void 0,style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:e.jsx(Nr,{chromeVariant:"v2",surface:"viewer",toolName:i.name,thumbnailUrl:cn(i)??null,showCreator:!0,creatorName:Te??void 0,creatorHref:m??void 0,lineage:Q?e.jsxs("span",{"data-testid":Ye.viewerTopBar.lineage,className:"flex items-center gap-[3px] truncate text-[10px] tracking-[-0.2px] text-[var(--product-grey-05)]",children:[e.jsx(dt,{size:8,className:"mr-[3px]"}),e.jsx("span",{children:"Remixed:"}),He(Q)?e.jsx(Pe,{to:Ie({id:Q.id,slug:Q.slug??void 0}),className:"hover:underline",children:Q.name}):e.jsx("span",{children:Q.name}),Ae&&Ue&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"by"}),e.jsx(Pe,{to:Ue,className:"hover:underline",children:Ae})]})]}):null,publishLabel:Be?"Cloning...":"Remix",isBookmarked:ee,onToggleBookmark:()=>{se("Save"),ht()},onShare:()=>{se("Share"),ot()},onPublish:We,onExport:()=>{if(se("Export"),!b){re("tool_viewer_mobile_topbar");return}c(!0)},endSlot:b?null:e.jsx(fo,{onClick:()=>{O({button_name:"tool_viewer_join"}),Xt(),Se(void 0,"tool_viewer_join",window.location.href)}})})}):e.jsx(Cr,{toolName:i.name,nameSuffix:Te?e.jsxs(e.Fragment,{children:["by"," ",m?e.jsx(Pe,{to:m,className:"hover:underline",children:Te}):Te]}):null,center:R?e.jsx("button",{type:"button",onClick:()=>{se("Edit"),t(`/tooleditor/${i.id}`)},className:"flex h-[40px] shrink-0 items-center gap-[8px] rounded-[10px] border border-solid border-[#e1e1e1] bg-amber-600 px-[15px] text-[12px] font-medium tracking-[-0.24px] text-white whitespace-nowrap transition-opacity hover:opacity-80",children:"Edit (Admin)"}):null,centerX:gt,secondLine:Q?e.jsxs("span",{className:"inline-flex items-center gap-[3px]",children:[e.jsx(dt,{size:8}),e.jsx("span",{children:"Remixed:"}),He(Q)?e.jsx(Pe,{to:Ie({id:Q.id,slug:Q.slug??void 0}),className:"hover:underline",children:Q.name}):e.jsx("span",{children:Q.name}),Ae&&Ue&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"by"}),e.jsx(Pe,{to:Ue,className:"hover:underline",children:Ae})]})]}):"",actions:e.jsxs("div",{className:"flex h-full items-center",children:[!b&&e.jsx(To,{className:"-mr-px -translate-y-px self-start",onClick:()=>{O({button_name:"tool_viewer_join"}),Xt(),Se(void 0,"tool_viewer_join",window.location.href)}}),e.jsx(xo,{open:rt,onOpenChange:C=>{C?(se("Share"),ot()):Ne(!1)},toolName:ue,toolSlug:(i==null?void 0:i.slug)??a,toolId:(i==null?void 0:i.id)??l}),e.jsx(zn,{size:"big",skin:ee?"standard":"ghost",priority:"primary","aria-label":ee?"Unsave":"Save",onClick:()=>{se("Save"),ht()},className:"border-l border-[var(--product-grey-02)]",glyphClassName:"size-[18px]",icon:e.jsx(Jr,{className:"size-full shrink-0"})}),b?e.jsx(Er,{}):null,e.jsxs(dn,{size:"big",skin:"standard",priority:"secondary",onClick:We,disabled:Be,className:X(Nn,"border-y-0 border-[var(--product-grey-02)]",b&&"border-l-0","disabled:border-y-0",b&&"disabled:border-l-0"),children:[e.jsx(Yr,{className:"size-[20px] shrink-0"}),e.jsx("span",{children:Be?"Cloning...":"Remix"})]}),e.jsxs(dn,{size:"big",skin:"standard",priority:"primary",onClick:()=>
6{if(se("Export"),O({button_name:"tool_viewer_export"}),!b){re("tool_viewer_topbar");return}c(!0)},className:Nn,children:[e.jsx(Tr,{className:"size-[20px] shrink-0"}),e.jsx("span",{children:"Export"})]})]})}),e.jsxs("div",{className:X("flex min-h-0",v?"flex-col":"flex-row",De&&q.length>0?"hidden":"flex-1"),children:[e.jsx("div",{className:"flex flex-col min-h-0 flex-1 min-w-0",children:e.jsx(Wn,{initialConfig:{},children:e.jsx("div",{className:"tool-stage flex-1 flex flex-col min-h-0 relative overflow-hidden",style:{border:"none",borderRadius:0,background:"transparent"},children:K?e.jsx(e.Fragment,{children:e.jsx("div",{className:"relative flex-1 min-h-0 w-full overflow-hidden transition-colors duration-150 ease-out",children:e.jsxs("div",{className:"contents",children:[e.jsxs("div",{className:"relative h-full min-h-0 flex flex-col overflow-hidden",children:[e.jsx(Rr,{ref:Ge,toolHtml:K,toolName:i.name,isAdmin:A,toolLoaded:xe,chatCollapsed:!0,newDesignLayout:!0}),v&&ke&&e.jsxs("div",{className:"absolute top-[10px] right-[10px] z-10 flex items-center gap-[6px] pointer-events-none","aria-live":"polite",children:[e.jsx("span",{className:"w-[7px] h-[7px] rounded-full bg-[#FF3B30] animate-pulse shadow-[0_0_8px_rgba(255,59,48,0.6)]"}),e.jsxs("span",{className:"text-[11px] font-semibold tracking-[-0.22px] text-[#7d7d7d]",children:["REC IN PROGRESS",ae.duration?` ${Math.max(0,Math.ceil(ae.duration-ae.elapsed))}s`:""]})]})]}),!v&&ke?e.jsx(qn,{elapsed:ae.elapsed,duration:ae.duration,onStop:xt}):null,Le&&fe?e.jsx(Xn,{ref:w,chromeVariant:"v2",forceExpandedOnArrival:!0,controlsSchema:fe.controlsSchema,iframeRef:y,toolLoadKey:Z,chatCollapsed:!0,draftImplId:null,initialTimeline:Vt,controlsPanelWidth:qe?0:z,onTimelineChange:Re,onTrackKeysChange:Y,onRevealControl:Ce,playbackLocked:ke}):null]})})}):e.jsx("div",{className:"flex-1"})})})}),!v&&qe&&fe?e.jsx(Nt,{mode:"desktop",chromeVariant:"v2",controlsSchema:fe.controlsSchema,iframeRef:y,toolLoadKey:Z,toolId:(i==null?void 0:i.id)??null,open:!0,toolName:i.name,creatorName:Te??void 0,creatorHref:m??void 0,remix:At,presetController:tt,timelineActive:Le&&D.active,trackedControlKeys:D.tracked,onToggleTrack:C=>{var L;return(L=w.current)==null?void 0:L.addOrRevealTrack(C)},revealControl:ce,onPresetBiAction:se,collapsed:Ht}):null]}),R&&q.length>0&&e.jsxs("div",{className:`mx-[20px] mb-[20px] ${De?"flex-1 flex flex-col min-h-0":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>je(C=>!C),className:"flex items-center gap-2 px-4 py-2 bg-white border border-[#e1e1e1] rounded-[8px] text-[12px] font-medium text-black hover:bg-[#f5f5f5] transition-colors",children:[e.jsx(Un,{className:"w-3.5 h-3.5"}),De?"Hide Gallery":`Show Gallery (${q.length})`]}),De&&e.jsx("div",{className:`mt-3 flex-1 overflow-y-auto grid gap-2 ${q.length===1?"grid-cols-1":q.length<=4?"grid-cols-2":"grid-cols-3"}`,children:q.map((C,L)=>e.jsxs("div",{className:"relative group/export aspect-video rounded-[8px] overflow-hidden cursor-pointer bg-[#111] border border-[#222] hover:border-[#444] transition-colors",onClick:()=>Fe(L),children:[C.export_kind==="video"?e.jsx(St,{fallbackUrl:C.file_url,streamFormat:C.stream_format,streamUrl:C.stream_url,muted:!0,className:"absolute inset-0 w-full h-full object-cover"}):e.jsx("img",{src:C.file_url,alt:"",className:"absolute inset-0 w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:oe=>{oe.stopPropagation(),Dt(C.id)},className:"absolute top-2 right-2 opacity-0 group-hover/export:opacity-100 transition-opacity flex items-center gap-1 px-2 py-1 rounded-[4px] bg-black/60 text-white text-[10px] hover:bg-red-600/80",children:e.jsx(ls,{className:"w-3 h-3"})})]},C.id))})]}),v&&i&&!(De&&q.length>0)&&e.jsxs("div",{ref:bt,className:`lg:hidden shrink-0 transition-[opacity,transform] ease-out motion-reduce:transition-none ${ft?"pointer-events-none translate-y-[8px] opacity-0 duration-0":"translate-y-0 opacity-100 delay-300 duration-200"}`,"aria-hidden":ft||void 0,children:[e.jsx(Ct,{chromeVariant:"v2"}),P&&Lt(de==null?void 0:de.timeline)&&e.jsx(Ct,{chromeVariant:"v2",message:"This tool contains a timeline animation. Switch to desktop."}),e.jsx(Lr,{chromeVariant:"v2",onChat:()=>{},onControls:()=>{},cells:[{label:"Controls",testId:Ye.viewerBottomBar.controls,onClick:()=>{se("Edit"),g("controls"),E(!0)}},...Bt.length>0?[{label:"Presets",testId:Ye.viewerBottomBar.presets,onClick:()=>{se("Presets"),g("presets"),E(!0)}}]:[]]})]}),R&&q[V]&&e.jsx(Zs,{open:V>=0,onOpenChange:C=>{C||Fe(-1)},children:e.jsxs(er,{children:[e.jsx(tr,{className:"fixed inset-0 z-50 bg-black/90"}),e.jsxs(nr,{"aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center focus:outline-none",onClick:()=>Fe(-1),children:[e.jsx(sr,{className:"sr-only",children:`Export ${V+1} of ${q.length}`}),e.jsx(rr,{className:"absolute top-4 right-4 flex items-center justify-center w-8 h-8 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors","aria-label":"Close",children:e.jsx(Rt,{className:"w-4 h-4"})}),q.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),Fe(L=>L<=0?q.length-1:L-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 flex items-center justify-center w-10 h-10 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors",children:e.jsx(qt,{className:"w-5 h-5"})}),e.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),Fe(L=>L>=q.length-1?0:L+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 flex items-center justify-center w-10 h-10 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors",children:e.jsx(cs,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"max-w-[90vw] max-h-[85vh] flex items-center justify-center",onClick:C=>C.stopPropagation(),children:q[V].export_kind==="video"?e.jsx(St,{fallbackUrl:q[V].file_url,streamFormat:q[V].stream_format,streamUrl:q[V].stream_url,controls:!0,autoPlay:!0,loop:!0,muted:!0,className:"max-w-full max-h-[85vh] rounded-[8px]"}):e.jsx("img",{src:q[V].file_url,alt:`Export ${V+1}`,className:"max-w-full max-h-[85vh] rounded-[8px] object-contain"})}),q.length>1&&e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white/50 text-[12px] tabular-nums",children:[V+1," / ",q.length]})]})]})}),v&&fe&&e.jsx(Nt,{mode:"mobile",chromeVariant:"v2",controlsSchema:fe.controlsSchema,iframeRef:y,toolLoadKey:Z,toolId:(i==null?void 0:i.id)??null,open:f,onClose:()=>E(!1),onHeightChange:J,presetController:tt,view:S,onPresetBiAction:se,headerSlot:e.jsxs(e.Fragment,{children:[R&&e.jsxs("button",{type:"button",onClick:me,title:H?"Switch to user view":"Switch to admin view","aria-pressed":H,className:X("shrink-0 flex items-center gap-[5px] h-[28px] px-[10px] rounded-[8px] text-[11px] font-medium tracking-[-0.22px] transition-colors",H?"bg-amber-600 text-white":"bg-[#E8E8E8] text-[#555]"),children:[e.jsx(ds,{className:"w-3 h-3 shrink-0"}),H?"Admin view":"User view"]}),W&&e.jsx("button",{type:"button","data-testid":Ye.controlsDrawer.resetAll,onClick:()=>{O({button_name:"tool_viewer_mobile_reset"}),pt(y,In),ne(!1)},className:"shrink-0 flex items-center gap-[4px] h-[28px] px-[10px] rounded-[8px] text-[12px] font-medium text-[#666] tracking-[-0.24px] hover:bg-black/5 transition-colors",children:"Reset"})]})}),e.jsx(Yn,{chromeVariant:"v2",open:h,onClose:()=>c(!1),iframeRef:y,toolName:ue,toolData:fe??void 0,toolUuid:ve,isAdmin:R,isOwner:!v&&!!(b!=null&&b.id)&&!!i&&b.id===i.user_id,modalOrigin:v?"tool_viewer_mobile_topbar":"tool_viewer_canvas_toolbar",onStartRecording:C=>{et(C),v&&c(!1)},recording:ke,toolViewMode:"viewer",timeline:Ut,onImageReady:(C,L)=>{if(v){c(!1);return}const oe=`image/${L}`,wt=ue.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-"),Ve=new Date().toISOString().slice(0,10);fetch(C).then(Xe=>Xe.blob()).then(Xe=>{c(!1),x(new File([Xe],`${wt}-${Ve}.${L}`,{type:oe}))}).catch(()=>{c(!1)})}}),e.jsx(Jn,{file:p,toolName:ue,toolSlug:(i==null?void 0:i.slug)??a,onClose:()=>x(null)}),v&&e.jsx(Qn,{open:rt,chromeVariant:"v2",allowNativeShare:!0,autoDismissMs:3e4,toolName:ue,toolSlug:(i==null?void 0:i.slug)??a,toolId:(i==null?void 0:i.id)??l,coverUrl:cn(i),onClose:()=>Ne(!1)})]})]}),e.jsx(Zn,{position:"fixed",chromeVariant:"v2",background:"var(--product-grey-01)",visible:$||!xe})]})}function Mo(){return e.jsx("div",{"data-testid":Zr.switch.loading,className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"w-6 h-6 border-2 border-[#333] border-t-[#888] rounded-full animate-spin"})})}function Na(){const t=or();return t===void 0?e.jsx(Mo,{}):t?e.jsx(Po,{}):e.jsx(uo,{})}export{Na as default};

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