1import{r as e,j as s,p as a,z as t,H as r,a as n,y as l,af as o,n as i,au as d,ai as c}from"./index-Cu6nzwse.js";import{S as p,a as x}from"./AppBottomSheet-DLyRu85K.js";import{C as m}from"./CardActions-V-_SRgyL.js";import{u as h,a as u}from"./usePublicAppSearch-DH3u0wJb.js";import{u as g}from"./useAppLauncher-D_1IsYjA.js";import{K as f,i as y}from"./keyboard-COaaXIZC.js";import"./MainCardButton-5CyrPA0a.js";import"./appBottomSheetHelpers-F2Pd06QK.js";const v=(e,s)=>{if(!s)return e;const a=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const t=new RegExp(`(${a})`,"gi");return e.replace(t,'<mark class="bg-[#A493D9]/10 text-[#A493D9] font-semibold">$1</mark>')},j=e.memo(({app:t,isActive:r,query:n,onSelect:l,appType:o})=>{var i;const d=e.useMemo(()=>v(t.name,n),[t.name,n]),c=e.useMemo(()=>{return v((e=t.description,s=120,e?e.length<=s?e:`${e.slice(0,s)}â¦`:""),n);var e,s},[t.description,n]),p=null==(i=null==o?void 0:o.ui_config)?void 0:i.icon,x=(m=o,h=t.app_type_name,(null==m?void 0:m.display_name)?m.display_name:(null==h?void 0:h.replace(/-/g," "))??"mini-app");var m,h;return s.jsxs("button",{type:"button",onClick:l,className:"group flex w-full items-center gap-2 sm:gap-3 rounded-lg sm:rounded-xl border px-3 sm:px-4 py-2 sm:py-3 text-left transition-all focus:outline-none focus:ring-2 focus:ring-[#A493D9]/40 "+(r?"border-[#A493D9]/30 bg-[#A493D9]/5 shadow-sm":"border-transparent bg-white hover:border-gray-200 hover:bg-gray-50"),"aria-pressed":r,children:[s.jsx("div",{className:"flex h-10 w-10 sm:h-12 sm:w-12 flex-shrink-0 items-center justify-center rounded-lg sm:rounded-xl bg-[#A493D9]/10 text-[#A493D9]",children:s.jsx(a,{iconName:p,className:"h-5 w-5 sm:h-6 sm:w-6 text-[#A493D9]"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm sm:text-base font-semibold text-gray-900 group-hover:text-[#A493D9] line-clamp-1",dangerouslySetInnerHTML:{__html:d}}),t.description&&s.jsx("div",{className:"mt-0.5 sm:mt-1 text-xs sm:text-sm text-gray-600 line-clamp-1 sm:line-clamp-2",dangerouslySetInnerHTML:{__html:c}})]}),s.jsx("span",{className:"hidden sm:inline-flex items-center rounded-full bg-[#A493D9]/10 px-2.5 py-1 text-xs font-medium text-[#A493D9]",children:x})]})});j.displayName="ResultItem";const b=({results:e,selectedIndex:a,query:t,loading:r,error:n,hasSearched:l,onSelect:o,appTypeMap:i})=>r?s.jsx("div",{className:"mt-10 text-center text-sm text-gray-500",children:"Searching public appsâ¦"}):n?s.jsx("div",{className:"mt-10 text-center text-sm text-red-500",children:n}):l&&0===e.length?s.jsxs("div",{className:"mt-10 text-center text-sm text-gray-500",children:["No apps match â",t,"â. Try a different keyword."]}):s.jsx("div",{className:"flex w-full flex-col gap-1.5 sm:gap-2",children:e.map((e,r)=>s.jsx(j,{app:e,query:t,isActive:r===a,onSelect:()=>o(e),appType:i.get(e.app_type_name)},e.id))}),N=({variations:a,outputFormat:n,outputSchema:l})=>{const[o,i]=e.useState("variation-1");return 0===a.length?null:1===a.length?s.jsx(p,{responses:a[0],outputSchema:l,outputFormat:n}):s.jsx("div",{className:"w-full bg-white/80 backdrop-blur-sm rounded-2xl border border-gray-200/60 shadow-[0_8px_30px_-8px_rgba(164,147,217,0.15)] overflow-hidden",children:s.jsxs(t,{value:o,onValueChange:i,children:[s.jsxs("div",{className:"flex items-center justify-between mb-4 px-6 pt-6",children:[s.jsx("div",{className:"flex items-center gap-1.5 sm:gap-2 w-full sm:w-auto",children:a.map((e,a)=>s.jsxs("button",{onClick:()=>i(`variation-${a+1}`),className:`\n flex-1 sm:flex-initial px-3 py-2 sm:px-4\n text-xs sm:text-sm font-medium \n rounded-xl transition-all duration-200\n ${o===`variation-${a+1}`?"bg-brand-primary text-white shadow-md shadow-brand-primary/20":"bg-gray-50 text-gray-600 hover:bg-gray-100 border border-gray-200"}\n `,children:[s.jsx("span",{className:"hidden sm:inline",children:"Output "}),s.jsx("span",{children:a+1})]},`variation-${a+1}`))}),s.jsxs("span",{className:"hidden sm:flex px-3 py-1.5 rounded-xl text-xs font-medium bg-brand-primary/10 text-brand-primary border border-brand-primary/20 shadow-sm",children:[a.length," variations"]})]}),s.jsx("div",{className:"px-6 pb-6",children:a.map((e,a)=>s.jsx(r,{value:`variation-${a+1}
1`,className:"mt-0",children:s.jsx(p,{responses:e,outputSchema:l,outputFormat:n})},`variation-${a+1}`))})]})})},w=({app:t,appType:r,onBack:i,onToggleSave:d,isSaved:c,isMobile:p})=>{var h;const u=n(),[g,f]=e.useState(!1),[y,v]=e.useState(!1),[j,b]=e.useState([]),[w,k]=e.useState([]),[S,C]=e.useState(!1);e.useEffect(()=>{k([]),b([]),C(!1)},[t.id]);const A=()=>{b([]),C(!0)},D=()=>{C(!1)},T=e=>{if(S){const s=[...j,e];b(s),3===s.length&&(k(e=>[s,...e]),b([]))}else k(s=>[[e],...s])};return p?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsx("section",{className:"px-4 py-6",children:s.jsx(x,{app:t,onResponse:T,onVariationStart:A,onVariationComplete:D,showVariations:!1})}),w.length>0&&s.jsx("section",{className:"px-4 pb-6",children:s.jsx(N,{variations:w,outputSchema:null==r?void 0:r.output_schema})}),s.jsx(m,{onSave:d,onEmbed:()=>f(!0),onTry:()=>{},isSaved:c,ctaText:"Try This AI",app:t,onShare:()=>v(!0),hideTryButton:!0})]}),s.jsx(l,{isOpen:g,onClose:()=>f(!1),app:t}),s.jsx(o,{isOpen:y,onClose:()=>v(!1),app:t,isSaved:c,useCase:"app_instance_share"})]}):s.jsxs("div",{className:"bg-white rounded-xl sm:rounded-2xl border border-gray-100 shadow-lg max-h-[85vh] sm:max-h-[80vh] flex flex-col overflow-hidden",children:[s.jsx("div",{className:"p-4 sm:p-5 bg-[#A493D9]/5 flex-shrink-0",children:s.jsxs("div",{className:"flex items-start gap-3 sm:gap-4",children:[s.jsx("button",{type:"button",onClick:i,className:"mt-1 p-1.5 hover:bg-white rounded-lg transition-colors","aria-label":"Back to search",children:s.jsx("svg",{className:"w-5 h-5 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 19l-7-7 7-7"})})}),s.jsx("div",{className:"w-12 h-12 sm:w-14 sm:h-14 bg-[#A493D9]/10 rounded-xl sm:rounded-2xl flex items-center justify-center flex-shrink-0",children:(null==(h=null==r?void 0:r.ui_config)?void 0:h.icon)&&s.jsx(a,{iconName:r.ui_config.icon,className:"w-6 sm:w-7 h-6 sm:h-7 text-[#A493D9] [&>path]:stroke-[1.5]"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"font-bold text-base sm:text-lg text-gray-900 transition-colors leading-snug cursor-pointer hover:text-[#A493D9]",onClick:()=>{u(`/app/${t.id}`)},children:t.name}),(t.description||(null==r?void 0:r.description))&&s.jsx("p",{className:"text-sm text-gray-600 mt-1 sm:mt-0.5 leading-relaxed sm:leading-tight",children:t.description||(null==r?void 0:r.description)})]})]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsx("div",{className:"px-5 py-4",children:s.jsx(x,{app:t,onResponse:T,onVariationStart:A,onVariationComplete:D,showVariations:!1})}),w.length>0&&s.jsx("div",{className:"px-5 pb-4",children:s.jsx(N,{variations:w,outputSchema:null==r?void 0:r.output_schema})}),s.jsx(m,{onSave:d,onEmbed:()=>f(!0),onTry:()=>{},isSaved:c,ctaText:"Try This AI",app:t,onShare:()=>v(!0),hideTryButton:!0})]}),s.jsxs("div",{className:"p-2 sm:p-3 border-t border-gray-100 flex items-center justify-between text-[10px] sm:text-xs text-gray-500 flex-shrink-0",children:[s.jsxs("span",{className:"flex items-center gap-0.5 sm:gap-1",children:[s.jsx("kbd",{className:"px-1 sm:px-1.5 py-0.5 bg-gray-100 rounded text-[10px] sm:text-xs",children:"â"}),s.jsx("span",{children:"back"}),s.jsx("span",{className:"hidden sm:inline",children:"or"}),s.jsx("kbd",{className:"hidden sm:inline-flex px-1 sm:px-1.5 py-0.5 bg-gray-100 rounded text-[10px] sm:text-xs",children:"0"}),s.jsx("span",{className:"hidden sm:inline",children:"to search"})]}),s.jsxs("span",{className:"flex items-center gap-0.5 sm:gap-1",children:[s.jsx("kbd",{className:"px-1 sm:px-1.5 py-0.5 bg-gray-100 rounded text-[10px] sm:text-xs",children:"esc"}),s.jsx("span",{className:"hidden sm:inline",children:"to"})," close"]})]}),s.jsx(l,{isOpen:g,onClose:()=>f(!1),app:t}),s.jsx(o,{isOpen:y,onClose:()=>v(!1),app:t,isSaved:c,useCase:"app_instance_share"})]})},k=({isOpen:a,onClose:t})=>{const r=e.useRef(null),[n,l]=e.useState(""),o=h(n,250),[c,p]=e.useState("search"),[x,m]=e.useState(0),[v,j]=e.useState(null),{results:N,loading:k,error:S,hasSearched:C}=u(o),{appTypes:A,loading:D}=i(),T=e.useMemo(()=>new Map(A.map(e=>[e.name,e])),[A]),{toggleSave:_,save:E,renderUpgradeModal:M}=g(),R=e.useMemo(()=>
1{if(v)return T.get(v.app_type_name)},[v,T]);e.useEffect(()=>(a?(p("search"),j(null),m(0),setTimeout(()=>{var e;return null==(e=r.current)?void 0:e.focus()},50),document.body.style.overflow="hidden"):(l(""),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[a]),e.useEffect(()=>{"search"===c&&m(0)},[c,N.length]);const L=e=>{0!==N.length&&m(s=>{const a=s+e;return a<0?0:a>=N.length?N.length-1:a})},I=e=>{if("app"!==c||["ArrowDown","ArrowUp","Enter","Escape"].includes(e.key)){if("search"===c)switch(e.key){case f.ARROW_DOWN:e.preventDefault(),L(1);break;case f.ARROW_UP:e.preventDefault(),L(-1);break;case f.ARROW_RIGHT:case f.ENTER:e.preventDefault(),N.length>0&&N[x]&&B(N[x]);break;case f.ESCAPE:e.preventDefault(),n?l(""):t()}}else O()},B=e.useCallback(e=>{j(e),p("app")},[]),O=e.useCallback(()=>{p("search"),j(null),setTimeout(()=>{var e;return null==(e=r.current)?void 0:e.focus()},50)},[]),$=e.useCallback(e=>{B(e)},[B]),z=e.useCallback(()=>{_(v)},[v,_]),W=e.useCallback(e=>{e.target===e.currentTarget&&t()},[t]);e.useEffect(()=>{const e=e=>{if(e.key!==f.ZERO||y(e.target)||a){if(a){if(e.key===f.ESCAPE)return e.preventDefault(),void("app"===c?O():t());"app"!==c||y(e.target)||(e.key===f.BACKSPACE||e.key===f.ARROW_LEFT||/^[a-zA-Z0-9]$/.test(e.key))&&(e.preventDefault(),O(),/^[a-zA-Z0-9]$/.test(e.key)&&"0"!==e.key&&setTimeout(()=>{var s;l(e.key),null==(s=r.current)||s.focus()},50)),"search"===c&&e.key===f.ARROW_RIGHT&&!y(e.target)&&N.length>0&&N[x]&&(e.preventDefault(),B(N[x]))}}else e.preventDefault()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[c,O,a,t,B,N,x]);const F=!!v&&E.savedApps.isSaved(v.id);return a?d.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("style",{children:"\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n \n @keyframes slideUp {\n from { \n opacity: 0;\n transform: translate(-50%, 10px) scale(0.98);\n }\n to { \n opacity: 1;\n transform: translate(-50%, 0) scale(1);\n }\n }\n \n @keyframes mobileSlideUp {\n from { \n opacity: 0;\n transform: translateY(100%);\n }\n to { \n opacity: 1;\n transform: translateY(0);\n }\n }\n "}),s.jsx("div",{className:"sm:hidden",children:s.jsx("div",{className:"fixed inset-0 z-50 bg-white flex flex-col",style:{animation:"mobileSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)"},children:"search"===c?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-100",children:[s.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Search mini-AI apps"}),s.jsx("button",{onClick:t,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors","aria-label":"Close search",children:s.jsx("svg",{className:"w-5 h-5 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("div",{className:"flex-1 flex flex-col-reverse overflow-hidden",children:s.jsx("div",{className:"flex-1 overflow-y-auto overscroll-contain",children:n||C?s.jsxs("div",{className:"p-3",children:[C&&s.jsx("p",{className:"px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-gray-600 mb-2",children:"Results"}),s.jsx(b,{results:N,selectedIndex:x,query:o,loading:k,error:S,hasSearched:C,onSelect:$,appTypeMap:T})]}):s.jsxs("div",{className:"p-3",children:[s.jsx("p",{className:"px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-gray-600 mb-2",children:"Featured"}),s.jsx(b,{results:N,selectedIndex:x,query:"",loading:!1,error:null,hasSearched:!1,onSelect:$,appTypeMap:T})]})})}),s.jsx("div",{className:"border-t border-gray-200 bg-white",children:s.jsx("div",{className:"p-4",children:s.jsxs("div",{className:"relative",children:[s.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),s.jsx("input",{ref:r,value:n,onChange:e=>l(e.target.value),onKeyDown:I,placeholder:"Type to search...",className:"w-full pl-10 pr-4 py-3 bg-gray-50 rounded-xl text-base text-gray-900 placeholder-gray-400 focus:bg-white focus:outline-none focus:ring-2 focus:ring-[#A493D9]/20 transition-all",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1})]})})})]}):s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center gap-3 p-4 border-b border-gray-100 bg-[#A493D9]/5",children:[s.jsx("button",{onClick:O,className:"p-2 hover:bg-white rounded-lg transition-colors","aria-label":"Back to search",children:s.jsx("svg",{className:"w-5 h-5 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 19l-7-7 7-7"})})}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("h3",{className:"font-semibold text-base text-gray-900 truncate",children:null==v?void 0:v.name})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx(w,{app:v,appType:D?void 0:R,onBack:O,onToggleSave:z,isSaved:F,isMobile:!0})})]})})}),s.jsx("div",{className:"hidden sm:block",children:s.jsx("div",{className:"fixed inset-0 z-50 bg-black/10",onClick:W,style:{animation:"fadeIn 0.15s ease-out"},children:s.jsx("div",{className:"fixed left-1/2 -translate-x-1/2 top-20 w-full max-w-2xl",style:{animation:"slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1)"},children:"search"===c?s.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-lg max-h-[70vh] flex flex-col overflow-hidden",children:[s.jsx("div",{className:"p-4 border-b border-gray-100",children:s.jsxs("div",{className:"relative",children:[s.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),s.jsx("input",{ref:r,value:n,onChange:e=>l(e.target.value),onKeyDown:I,placeholder:"Search mini-AI apps...",className:"w-full pl-10 pr-4 py-2.5 text-base bg-transparent placeholder-gray-400 focus:placeholder-gray-500 text-gray-900 focus:outline-none",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1})]})}),s.jsx("div",{className:"flex-1 overflow-y-auto overscroll-contain",children:n||C?s.jsxs("div",{className:"p-3",children:[C&&s.jsx("p",{className:"px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-gray-600 mb-2",children:"Results"}),s.jsx(b,{results:N,selectedIndex:x,query:o,loading:k,error:S,hasSearched:C,onSelect:$,appTypeMap:T})]}):s.jsxs("div",{className:"p-3",children:[s.jsx("p",{className:"px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-gray-600 mb-2",children:"Featured"}),s.jsx(b,{results:N,selectedIndex:x,query:"",loading:!1,error:null,hasSearched:!1,onSelect:$,appTypeMap:T})]})}),s.jsxs("div",{className:"p-3 border-t border-gray-100 flex items-center justify-between text-xs text-gray-500",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("kbd",{className:"px-1.5 py-0.5 bg-gray-100 rounded text-xs",children:"ââ"}),"navigate"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("kbd",{className:"px-1.5 py-0.5 bg-gray-100 rounded text-xs",children:"â"}),s.jsx("kbd",{className:"px-1.5 py-0.5 bg-gray-100 rounded text-xs",children:"âµ"}),"open"]})]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("kbd",{className:"px-1.5 py-0.5 bg-gray-100 rounded text-xs",children:"esc"}),"close"]})]})]}):s.jsx(w,{app:v,appType:D?void 0:R,onBack:O,onToggleSave:z,isSaved:F})})})}),M()]}),document.body):null},S=()=>{const{isOpen:a,open:t,close:r}=(()=>{const[s,a]=e.useState(!1),t=e.useCallback(()=>a(!0),[]),r=e.useCallback(()=>a(!1),[]),n=e.useCallback(()=>a(e=>!e),[]);return e.useEffect(()=>{const e=e=>{e.key!==f.ZERO||y(e.target)||s||(e.preventDefault(),t())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s,t]),{isOpen:s,open:t,close:r,toggle:n}})();return s.jsxs("div",{className:"flex min-h-screen flex-col items-center px-4 py-24",children:[s.jsxs("div",{className:"flex w-full max-w-3xl flex-col items-center text-center",children:[s.jsx("h1",{className:"text-4xl font-semibold text-gray-900",children:"Search"}),s.jsxs("p",{className:"mt-3 text-base text-gray-500",children:["Find the right mini-AI app in seconds. Press ",s.jsx("span",{className:"font-mono bg-[#A493D9]/10 px-2 py-1 rounded text-sm text-[#A493D9]",children:"0"})," to search."]})]}),s.jsxs("button",{onClick:t,className:"mt-12 px-6 sm:px-8 h-12 bg-white border border-gray-200 rounded-xl text-gray-600 hover:text-[#A493D9] hover:border-[#A493D9] transition-all duration-200 shadow-sm hover:shadow-md inline-flex items-center justify-center gap-3",children:[s.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),s.jsx("span",{className:"text-base font-medium",children:"Search mini-AI apps"}),s.jsx("span",{className:"ml-2 px-2 py-1 bg-[#A493D9]/10 rounded-lg text-xs font-semibold text-[#A493D9]",children:"0"})]}),s.jsx(k,{isOpen:a,onClose:r})]})},C=()=>s.jsxs("div",{className:"min-h-screen bg-white",children:[s.jsx(c,{children:s.jsx("title",{children:"Search AI products | Content Products"})}),s.jsx(S,{})]});
1export{C 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.