1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,233525,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"warnOnce",{enumerable:!0,get:function(){return n}});let n=e=>{}},818581,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"useMergedRef",{enumerable:!0,get:function(){return a}});let n=e.r(271645);function a(e,t){let r=(0,n.useRef)(null),a=(0,n.useRef)(null);return(0,n.useCallback)(n=>{if(null===n){let e=r.current;e&&(r.current=null,e());let t=a.current;t&&(a.current=null,t())}else e&&(r.current=s(e,n)),t&&(a.current=s(t,n))},[e,t])}function s(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},998183,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={assign:function(){return l},searchParamsToUrlQuery:function(){return s},urlQueryToSearchParams:function(){return o}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});function s(e){let t={};for(let[r,n]of e.entries()){let e=t[r];void 0===e?t[r]=n:Array.isArray(e)?e.push(n):t[r]=[e,n]}return t}function i(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function o(e){let t=new URLSearchParams;for(let[r,n]of Object.entries(e))if(Array.isArray(n))for(let e of n)t.append(r,i(e));else t.set(r,i(n));return t}function l(e,...t){for(let r of t){for(let t of r.keys())e.delete(t);for(let[t,n]of r.entries())e.append(t,n)}return e}},195057,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={formatUrl:function(){return o},formatWithValidation:function(){return c},urlObjectKeys:function(){return l}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let s=e.r(190809)._(e.r(998183)),i=/https?|ftp|gopher|file/;function o(e){let{auth:t,hostname:r}=e,n=e.protocol||"",a=e.pathname||"",o=e.hash||"",l=e.query||"",c=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?c=t+e.host:r&&(c=t+(~r.indexOf(":")?`[${r}]`:r),e.port&&(c+=":"+e.port)),l&&"object"==typeof l&&(l=String(s.urlQueryToSearchParams(l)));let u=e.search||l&&`?${l}`||"";return n&&!n.endsWith(":")&&(n+=":"),e.slashes||(!n||i.test(n))&&!1!==c?(c="//"+(c||""),a&&"/"!==a[0]&&(a="/"+a)):c||(c=""),o&&"#"!==o[0]&&(o="#"+o),u&&"?"!==u[0]&&(u="?"+u),a=a.replace(/[?#]/g,encodeURIComponent),u=u.replace("#","%23"),`${n}${c}${a}${u}${o}`}let l=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function c(e){return o(e)}},718967,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={DecodeError:function(){return x},MiddlewareNotFoundError:function(){return v},MissingStaticPage:function(){return b},NormalizeError:function(){return y},PageNotFoundError:function(){return j},SP:function(){return g},ST:function(){return m},WEB_VITALS:function(){return s},execOnce:function(){return i},getDisplayName:function(){return d},getLocationOrigin:function(){return c},getURL:function(){return u},isAbsoluteUrl:function(){return l},isResSent:function(){return f},loadGetInitialProps:function(){return p},normalizeRepeatedSlashes:function(){return h},stringifyError:function(){return w}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let s=["CLS","FCP","FID","INP","LCP","TTFB"];function i(e){let t,r=!1;return(...n)=>(r||(r=!0,t=e(...n)),t)}let o=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,l=e=>o.test(e);function c(){let{protocol:e,hostname:t,port:r}=window.location;return`${e}//${t}${r?":"+r:""}`}function u(){let{href:e}=window.location,t=c();return e.substring(t.length)}function d(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function f(e){return e.finished||e.headersSent}function h(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?`?${t.slice(1).join("?")}`:"")}async function p(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await p(t.Component,t.ctx)}:{};let n=await e.getInitialProps(t);if(r&&f(r))return n;if(!n)throw Object.defineProperty(Error(`"${d(e)}.getInitialProps()" should resolve to an object. But found "${n}
1" instead.`),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return n}let g="undefined"!=typeof performance,m=g&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class x extends Error{}class y extends Error{}class j extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message=`Cannot find module for page: ${e}`}}class b extends Error{constructor(e,t){super(),this.message=`Failed to load static file for page: ${e} ${t}`}}class v extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function w(e){return JSON.stringify({message:e.message,stack:e.stack})}},573668,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"isLocalURL",{enumerable:!0,get:function(){return s}});let n=e.r(718967),a=e.r(652817);function s(e){if(!(0,n.isAbsoluteUrl)(e))return!0;try{let t=(0,n.getLocationOrigin)(),r=new URL(e,t);return r.origin===t&&(0,a.hasBasePath)(r.pathname)}catch(e){return!1}}},284508,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"errorOnce",{enumerable:!0,get:function(){return n}});let n=e=>{}},522016,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={default:function(){return x},useLinkStatus:function(){return j}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let s=e.r(190809),i=e.r(843476),o=s._(e.r(271645)),l=e.r(195057),c=e.r(8372),u=e.r(818581),d=e.r(718967),f=e.r(405550);e.r(233525);let h=e.r(91949),p=e.r(573668),g=e.r(509396);function m(e){return"string"==typeof e?e:(0,l.formatUrl)(e)}function x(t){var r;let n,a,s,[l,x]=(0,o.useOptimistic)(h.IDLE_LINK_STATUS),j=(0,o.useRef)(null),{href:b,as:v,children:w,prefetch:N=null,passHref:D,replace:S,shallow:k,scroll:C,onClick:M,onMouseEnter:A,onTouchStart:P,legacyBehavior:T=!1,onNavigate:O,ref:_,unstable_dynamicOnHover:E,...R}=t;n=w,T&&("string"==typeof n||"number"==typeof n)&&(n=(0,i.jsx)("a",{children:n}));let I=o.default.useContext(c.AppRouterContext),z=!1!==N,$=!1!==N?null===(r=N)||"auto"===r?g.FetchStrategy.PPR:g.FetchStrategy.Full:g.FetchStrategy.PPR,{href:L,as:F}=o.default.useMemo(()=>{let e=m(b);return{href:e,as:v?m(v):e}},[b,v]);if(T){if(n?.$$typeof===Symbol.for("react.lazy"))throw Object.defineProperty(Error("`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag."),"__NEXT_ERROR_CODE",{value:"E863",enumerable:!1,configurable:!0});a=o.default.Children.only(n)}let U=T?a&&"object"==typeof a&&a.ref:_,B=o.default.useCallback(e=>(null!==I&&(j.current=(0,h.mountLinkInstance)(e,L,I,$,z,x)),()=>{j.current&&((0,h.unmountLinkForCurrentNavigation)(j.current),j.current=null),(0,h.unmountPrefetchableInstance)(e)}),[z,L,I,$,x]),q={ref:(0,u.useMergedRef)(B,U),onClick(t){T||"function"!=typeof M||M(t),T&&a.props&&"function"==typeof a.props.onClick&&a.props.onClick(t),!I||t.defaultPrevented||function(t,r,n,a,s,i,l){if("undefined"!=typeof window){let c,{nodeName:u}=t.currentTarget;if("A"===u.toUpperCase()&&((c=t.currentTarget.getAttribute("target"))&&"_self"!==c||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.nativeEvent&&2===t.nativeEvent.which)||t.currentTarget.hasAttribute("download"))return;if(!(0,p.isLocalURL)(r)){s&&(t.preventDefault(),location.replace(r));return}if(t.preventDefault(),l){let e=!1;if(l({preventDefault:()=>{e=!0}}),e)return}let{dispatchNavigateAction:d}=e.r(699781);o.default.startTransition(()=>{d(n||r,s?"replace":"push",i??!0,a.current)})}}(t,L,F,j,S,C,O)},onMouseEnter(e){T||"function"!=typeof A||A(e),T&&a.props&&"function"==typeof a.props.onMouseEnter&&a.props.onMouseEnter(e),I&&z&&(0,h.onNavigationIntent)(e.currentTarget,!0===E)},onTouchStart:function(e){T||"function"!=typeof P||P(e),T&&a.props&&"function"==typeof a.props.onTouchStart&&a.props.onTouchStart(e),I&&z&&(0,h.onNavigationIntent)(e.currentTarget,!0===E)}};return(0,d.isAbsoluteUrl)(F)?q.href=F:T&&!D&&("a"!==a.type||"href"in a.props)||(q.href=(0,f.addBasePath)(F)),s=T?o.default.cloneElement(a,q):(0,i.jsx)("a",{...R,...q,children:n}),(0,i.jsx)(y.Provider,{value:l,children:s})}e.r(284508);let y=(0,o.createContext)(h.IDLE_LINK_STATUS),j=()=>(0,o.useContext)(y);("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esMo
1dule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},647163,99246,e=>{"use strict";var t=e.i(207670),r=e.i(919056);let n="Rewritify";e.s(["SITE_NAME",0,"Rewritify","SITE_NAME_SHORT",0,n],99246);let a={database:"log",chat:"response",auth:"response",stream:"response",api:"response",history:"response",vote:"response",document:"response",settings:"response"};class s extends Error{type;surface;statusCode;constructor(e,t){super();const[r,a]=e.split(":");this.type=r,this.cause=t,this.surface=a,this.message=function(e){if(e.includes("database"))return"An error occurred while executing a database query.";switch(e){case"bad_request:api":return"The request couldn't be processed. Please check your input and try again.";case"unauthorized:auth":return"You need to sign in before continuing.";case"forbidden:auth":return"Your account does not have access to this feature.";case"abuse:auth":return`To keep using ${n}, please create a free account. It's quick and keeps your chat history safe!`;case"rate_limit:chat":return"You've reached your monthly message limit.";case"not_found:chat":return"The requested chat was not found. Please check the chat ID and try again.";case"forbidden:chat":return"This chat belongs to another user. Please check the chat ID and try again.";case"unauthorized:chat":return"You need to sign in to view this chat. Please sign in and try again.";case"offline:chat":return"We're having trouble sending your message. Please check your internet connection and try again.";case"not_found:document":return"The requested document was not found. Please check the document ID and try again.";case"forbidden:document":return"This document belongs to another user. Please check the document ID and try again.";case"unauthorized:document":return"You need to sign in to view this document. Please sign in and try again.";case"bad_request:document":return"The request to create or update the document was invali
1d. Please check your input and try again.";default:return"Something went wrong. Please try again later."}}(e),this.statusCode=function(e){switch(e){case"bad_request":return 400;case"unauthorized":return 401;case"forbidden":case"abuse":return 403;case"not_found":return 404;case"rate_limit":return 429;case"offline":return 503;default:return 500}}(this.type)}toResponse(){let e=`${this.type}:${this.surface}`,t=a[this.surface],{message:r,cause:n,statusCode:s}=this;return("rate_limit"!==this.type&&"abuse"!==this.type&&console.error("[ChatError]",{code:e,message:r,cause:n,statusCode:s}),"log"===t)?Response.json({code:"",message:"Something went wrong. Please try again later."},{status:s}):Response.json({code:e,message:r,cause:n},{status:s})}}function i(...e){return(0,r.twMerge)((0,t.clsx)(e))}async function o(e){let t=await fetch(e);if(!t.ok){let{code:e,cause:r}=await t.json();throw new s(e,r)}return t.json()}e.s(["cn",()=>i,"fetcher",()=>o],647163)},184762,e=>{"use strict";var t=e.i(843476),r=e.i(647163);function n({className:e,...n}){return(0,t.jsx)("textarea",{"data-slot":"textarea",className:(0,r.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...n})}e.s(["Textarea",()=>n])},330009,e=>{"use strict";let t;var r=e.i(843476),n=e.i(271645),a=e.i(30030),s=e.i(820783),i=e.i(326999),o=e.i(981140),l=Symbol("radix.slottable"),c="AlertDialog",[u,d]=(0,a.createContextScope)(c,[i.createDialogScope]),f=(0,i.createDialogScope)(),h=e=>{let{__scopeAlertDialog:t,...n}=e,a=f(t);return(0,r.jsx)(i.Root,{...a,...n,modal:!0})};h.displayName=c;var p=n.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...a}=e,s=f(n);return(0,r.jsx)(i.Trigger,{...s,...a,ref:t})});p.displayName="AlertDialogTrigger";var g=e=>{let{__scopeAlertDialog:t,...n}=e,a=f(t);return(0,r.jsx)(i.Portal,{...a,...n})};g.displayName="AlertDialogPortal";var m=n.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...a}=e,s=f(n);return(0,r.jsx)(i.Overlay,{...s,...a,ref:t})});m.displayName="AlertDialogOverlay";var x="AlertDialogContent",[y,j]=u(x),b=((t=({children:e})=>(0,r.jsx)(r.Fragment,{children:e})).displayName="AlertDialogContent.Slottable",t.__radixId=l,t),v=n.forwardRef((e,t)=>{let{__scopeAlertDialog:a,children:l,...c}=e,u=f(a),d=n.useRef(null),h=(0,s.useComposedRefs)(t,d),p=n.useRef(null);return(0,r.jsx)(i.WarningProvider,{contentName:x,titleName:w,docsSlug:"alert-dialog",children:(0,r.jsx)(y,{scope:a,cancelRef:p,children:(0,r.jsxs)(i.Content,{role:"alertdialog",...u,...c,ref:h,onOpenAutoFocus:(0,o.composeEventHandlers)(c.onOpenAutoFocus,e=>{e.preventDefault(),p.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,r.jsx)(b,{children:l}),(0,r.jsx)(A,{contentRef:d})]})})})});v.displayName=x;var w="AlertDialogTitle",N=n.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...a}=e,s=f(n);return(0,r.jsx)(i.Title,{...s,...a,ref:t})});N.displayName=w;var D="AlertDialogDescription",S=n.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...a}=e,s=f(n);return(0,r.jsx)(i.Description,{...s,...a,ref:t})});S.displayName=D;var k=n.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...a}=e,s=f(n);return(0,r.jsx)(i.Close,{...s,...a,ref:t})});k.displayName="AlertDialogAction";var C="AlertDialogCancel",M=n.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...a}=e,{cancelRef:o}=j(C,n),l=f(n),c=(0,s.useComposedRefs)(t,o);return(0,r.jsx)(i.Close,{...l,...a,ref:c})});M.displayName=C;var A=({contentRef:e})=>{let t=`\`${x}\` requires a description for the component to be accessible for screen reader users. 2 3You can add a description to the \`${x}\` by passing a \`${D}\` component as a child, which also benefits sighted users by adding visible context to the dialog. 4 5Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${x}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. 6 7For more information, see https://radix-ui.com/primitives/docs/components/
7alert-dialog`;return n.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},P=e.i(167881),T=e.i(647163);function O({...e}){return(0,r.jsx)(h,{"data-slot":"alert-dialog",...e})}function _({...e}){return(0,r.jsx)(p,{"data-slot":"alert-dialog-trigger",...e})}function E({...e}){return(0,r.jsx)(g,{"data-slot":"alert-dialog-portal",...e})}function R({className:e,...t}){return(0,r.jsx)(m,{"data-slot":"alert-dialog-overlay",className:(0,T.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function I({className:e,...t}){return(0,r.jsxs)(E,{children:[(0,r.jsx)(R,{}),(0,r.jsx)(v,{"data-slot":"alert-dialog-content",className:(0,T.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...t})]})}function z({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,T.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function $({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,T.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function L({className:e,...t}){return(0,r.jsx)(N,{"data-slot":"alert-dialog-title",className:(0,T.cn)("text-lg font-semibold",e),...t})}function F({className:e,...t}){return(0,r.jsx)(S,{"data-slot":"alert-dialog-description",className:(0,T.cn)("text-muted-foreground text-sm",e),...t})}function U({className:e,...t}){return(0,r.jsx)(k,{className:(0,T.cn)((0,P.buttonVariants)(),e),...t})}function B({className:e,...t}){return(0,r.jsx)(M,{className:(0,T.cn)((0,P.buttonVariants)({variant:"outline"}),e),...t})}e.s(["AlertDialog",()=>O,"AlertDialogAction",()=>U,"AlertDialogCancel",()=>B,"AlertDialogContent",()=>I,"AlertDialogDescription",()=>F,"AlertDialogFooter",()=>$,"AlertDialogHeader",()=>z,"AlertDialogTitle",()=>L,"AlertDialogTrigger",()=>_],330009)},237304,e=>{"use strict";var t=e.i(843476),r=e.i(534777);function n({children:e}){return(0,t.jsx)(r.AnonymousSessionProvider,{children:e})}e.s(["ChatLayoutWrapper",()=>n])},95187,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={callServer:function(){return s.callServer},createServerReference:function(){return o.createServerReference},findSourceMapURL:function(){return i.findSourceMapURL}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let s=e.r(132120),i=e.r(92245),o=e.r(235326)},87759,e=>{"use strict";var t=e.i(843476),r=e.i(54490),n=e.i(657688),a=e.i(522016),s=e.i(618566),i=e.i(475254);let o=(0,i.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var l=e.i(871631),l=l,c=e.i(568925),u=e.i(994179),d=e.i(167881),f=e.i(728231),h=e.i(192358),p=e.i(647163);function g({label:e,current:r,max:n}){let a=Math.min(r/n*100,100);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,t.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1",children:[e,(0,t.jsxs)(f.Tooltip,{children:[(0,t.jsx)(f.TooltipTrigger,{asChild:!0,children:(0,t.jsx)(o,{className:"size-3.5 text-muted-foreground/70"})}),(0,t.jsx)(f.TooltipContent,{side:"top",children:"Usage data is for the last 30 days"})]})]}),(0,t.jsxs)("span",{className:"text-muted-foreground tabular-nums",children:[r,"/",n]})]}),(0,t.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,t.jsx)("div",{className:(0,p.cn)("h-full rounded-full transition-all duration-300",a>=100?"bg-red-500":"bg-green-500"),style:{width:`${a}%`}})})]})}function m(){let{messages:e,plan:r,limit:n,isLoading:a,isAnonymous:s,isSubscribed:i}=(0,h.useUsage)();if(a||s)return null;let o=null!==n,f=r.charAt(0).toUpperCase()+r.slice(1);return(0,t.jsxs)("div",{className:"rounded-lg border bg-card p-3 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"font-medium text-sm",children:o?"Plan usage":"Plan"}),(0,t.jsx)(u.Badge,{variant:"secondary",className:(0,p.cn)("text-xs",i?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300":"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300"),children:f})]}),null!==n&&(0,t.jsx)(g,{label:"Rewrites/month",current:e,max:n}),!i&&(0,t.jsx)(c.PricingDialog,{children:(0,t.jsxs)(d.Button,{variant:"secondary","aria-label":"Upgrade to paid plan",className:"w-full rounded-full bg-violet-100 hover:bg-violet-200 text-violet-700",children:[(0,t.jsx)(l.default,{})," Upgrade"]})})]})}var x=e.i(811522),y=e.i(99246),j=e.i(631171),j=j;
7let b=(0,i.default)("credit-card",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]),v=(0,i.default)("life-buoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]),w=(0,i.default)("log-in",[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]),N=(0,i.default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),D=(0,i.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var S=e.i(539656),k=e.i(271645),C=e.i(846696),M=e.i(39839),A=e.i(534777),P=e.i(630374),T=e.i(743687),O=e.i(184762),_=e.i(95187);let E=(0,_.createServerReference)("40ba7040de2f2adf0a413e6b310d43002349302cf9",_.callServer,void 0,_.findSourceMapURL,"sendHelpRequestEmail");var R=e.i(64959);function I({children:e}){let[r,n]=(0,k.useState)(!1),[a,s]=(0,k.useState)(""),[i,o]=(0,k.useState)(!1),{session:l}=(0,A.useAnonymousSessionContext)(),c=(0,M.useMediaQuery)("(min-width: 768px)",{initializeWithValue:!1,defaultValue:!1}),u=async()=>{if(!a.trim())return void C.toast.error("Please enter a message",{position:"top-center"});o(!0);try{await E({userName:l?.user.name||void 0,userEmail:l?.user.email||void 0,message:a.trim()}),C.toast.success("Message sent successfully",{position:"top-center"}),s(""),n(!1)}catch(e){C.toast.error("Failed to send message. Please try again.",{position:"top-center"}),(0,R.logError)({event:"help_failed",surface:"help",message:e instanceof Error?e.message:"Failed to send help message"})}finally{o(!1)}};return c?(0,t.jsxs)(P.Dialog,{open:r,onOpenChange:n,children:[(0,t.jsx)(P.DialogTrigger,{asChild:!0,children:e}),(0,t.jsxs)(P.DialogContent,{"aria-describedby":void 0,children:[(0,t.jsxs)(P.DialogHeader,{children:[(0,t.jsx)(P.DialogTitle,{children:"Help"}),(0,t.jsx)(P.DialogDescription,{children:"Send us a message and we'll get back to you as soon as possible."})]}),(0,t.jsx)(O.Textarea,{className:"min-h-32",placeholder:"Describe your issue or question...",value:a,onChange:e=>s(e.target.value)}),(0,t.jsx)(P.DialogFooter,{children:(0,t.jsx)(d.Button,{onClick:u,disabled:i,children:i?"Sending...":"Send"})})]})]}):(0,t.jsxs)(T.Drawer,{open:r,onOpenChange:n,children:[(0,t.jsx)(T.DrawerTrigger,{asChild:!0,children:e}),(0,t.jsxs)(T.DrawerContent,{children:[(0,t.jsxs)(T.DrawerHeader,{className:"text-left",children:[(0,t.jsx)(T.DrawerTitle,{children:"Help"}),(0,t.jsx)(T.DrawerDescription,{children:"Send us a message and we'll get back to you as soon as possible."})]}),(0,t.jsx)("div",{className:"px-4",children:(0,t.jsx)(O.Textarea,{className:"min-h-36",placeholder:"Describe your issue or question...",value:a,onChange:e=>s(e.target.value),rows:4})}),(0,t.jsx)(T.DrawerFooter,{className:"mb-8",children:(0,t.jsx)(d.Button,{onClick:u,disabled:i,children:i?"Sending...":"Send"})})]})]})}var z=e.i(463415),$=e.i(672136);function L({name:e,size:r=24,className:a="",image:s}){let i,o=(i=function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(e),`linear-gradient(135deg, hsl(${i%360}, 70%, 50%), hsl(${(i+120)%360}, 70%, 60%))`);return s?(0,t.jsx)(n.default,{src:s,alt:e,width:r,height:r,className:`rounded-full object-cover ${a}`}):(0,t.jsx)("div",{className:`rounded-full ${a}`,style:{width:r,height:r,background:o}})}function F(){let e=(0,s.useRouter)(),{session:r,isPending:n}=(0,A.useAnonymousSessionContext)(),a=r?.user.isAnonymous||null;return n?(0,t.jsx)(d.Button,{variant:"ghost","data-testid":"signin-button",className:"h-10 px-3 justify-between gap-2",disabled:!0,children:(0,t.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,t.jsx)("div",{className:"flex items-center justify-center size-6 rounded-full bg-zinc-500/30 animate-pulse"}),(0,t.jsx)("span",{className:"truncate bg-zinc-500/30 text-transparent roun
7ded-md animate-pulse",children:"Loading"})]})}):!r||a?(0,t.jsx)(S.AuthDialog,{children:(0,t.jsx)(d.Button,{variant:"ghost","data-testid":"signin-button",className:"h-10 px-3 justify-between gap-2",children:(0,t.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,t.jsx)("div",{className:"flex items-center justify-center size-6 rounded-full",children:(0,t.jsx)(w,{})}),(0,t.jsx)("span",{className:"truncate",children:"Sign In"})]})})}):(0,t.jsxs)(z.DropdownMenu,{children:[(0,t.jsx)(z.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(d.Button,{variant:"ghost","data-testid":"user-nav-button",className:"h-10 px-3 justify-start gap-2",children:[(0,t.jsx)(L,{name:r.user.name||r.user.email||"User",size:24,image:r.user.image}),(0,t.jsx)("span",{"data-testid":"user-email",className:"truncate inline",children:r.user.name||r.user.email}),(0,t.jsx)(j.default,{className:"ml-auto size-4"})]})}),(0,t.jsxs)(z.DropdownMenuContent,{"data-testid":"user-nav-menu",align:"end",className:"w-60",children:[(0,t.jsx)(z.DropdownMenuItem,{asChild:!0,"data-testid":"user-nav-item-settings",children:(0,t.jsxs)("button",{type:"button",className:"w-full cursor-pointer",onClick:async()=>{e.push("/settings")},children:[(0,t.jsx)(D,{className:"size-4"}),"Settings"]})}),(0,t.jsx)(z.DropdownMenuItem,{asChild:!0,"data-testid":"user-nav-item-billing",children:(0,t.jsxs)("button",{type:"button",className:"w-full cursor-pointer",onClick:async()=>{let e=await fetch("/api/stripe/billing-portal",{method:"POST"}),t=await e.json();t.url&&(window.location.href=t.url)},children:[(0,t.jsx)(b,{className:"size-4"}),"Billing"]})}),(0,t.jsx)(I,{children:(0,t.jsx)(z.DropdownMenuItem,{asChild:!0,"data-testid":"user-nav-item-help",onSelect:e=>e.preventDefault(),children:(0,t.jsxs)("button",{type:"button",className:"w-full cursor-pointer",children:[(0,t.jsx)(v,{className:"size-4"}),"Help"]})})}),(0,t.jsx)(z.DropdownMenuItem,{asChild:!0,"data-testid":"user-nav-item-signout",children:(0,t.jsxs)("button",{type:"button",className:"w-full cursor-pointer",onClick:async()=>{await $.authClient.signOut({fetchOptions:{onSuccess:()=>{e.push("/")}}})},children:[(0,t.jsx)(N,{className:"size-4"}),"Sign out"]})})]})]})}let U=Symbol.for("constructDateFrom");function B(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&U in e?e[U](t):e instanceof Date?new e.constructor(t):new Date(t)}function q(e){return B(e,Date.now())}function H(e,t){let r=B(t?.in||e,e);return r.setHours(0,0,0,0),r}function W(e,t,r){let[n,a]=function(e,...t){let r=B.bind(null,e||t.find(e=>"object"==typeof e));return t.map(r)}(r?.in,e,t);return+H(n)==+H(a)}function V(e,t,r){let n=B(r?.in||e,e);return isNaN(t)?B(r?.in||e,NaN):(t&&n.setDate(n.getDate()+t),n)}var Y=e.i(846932);let K=(0,i.default)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);var G=e.i(330009),Q=e.i(735236);let X=(0,i.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),J=(0,i.default)("trash",[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),Z=(0,k.memo)(({chat:e,isActive:r,onDelete:n,setOpenMobile:s})=>(0,t.jsxs)(x.SidebarMenuItem,{children:[(0,t.jsx)(x.SidebarMenuButton,{asChild:!0,isActive:r,children:(0,t.jsx)(a.default,{href:`/chat/${e.id}`,onClick:()=>s(!1),children:(0,t.jsx)("span",{children:e.title})})}),(0,t.jsxs)(z.DropdownMenu,{modal:!0,children:[(0,t.jsx)(z.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(x.SidebarMenuAction,{className:"mr-0.5 data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",showOnHover:!r,children:[(0,t.jsx)(X,{}),(0,t.jsx)("span",{className:"sr-only",children:"More"})]})}),(0,t.jsx)(z.DropdownMenuContent,{align:"end",side:"bottom",children:(0,t.jsxs)(z.DropdownMenuItem,{className:"cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive dark:text-red-500",onSelect:()=>n(e.id),children:[(0,t.jsx)(J,{}),(0,t.jsx)("span",{children:"Delete"})]})})]})]}),(e,t)=>e.isActive===t.isActive);function ee(){var e;let r,n,a,i,{setOpenMobile:o}=(0,x.useSidebar)(),{id:l}=(0,s.useParams)(),{paginatedChatHistories:c,setSize:u,isValidating:d,isLoading:f,mutate:h,hasReachedEnd:p,hasEmptyChatHistory:g}=(0,Q.useChatHistory)(),m=(0,s.useRouter)(),[y,j]=(0,k.useState)(null),[b,v]=(0,k.useState)(!1);if(f)return(0,t.jsxs)(x.SidebarGroup,{children:[(0,t.jsx)("div",{className:"px-2 py-1 text-sidebar-foreground
7/50 text-xs",children:"Today"}),(0,t.jsx)(x.SidebarGroupContent,{children:(0,t.jsx)("div",{className:"flex flex-col",children:[44,32,28,64,52].map(e=>(0,t.jsx)("div",{className:"flex h-8 items-center gap-2 rounded-md px-2",children:(0,t.jsx)("div",{className:"h-4 max-w-(--skeleton-width) flex-1 rounded-md bg-sidebar-accent-foreground/10",style:{"--skeleton-width":`${e}%`}})},e))})})]});if(g)return(0,t.jsx)(x.SidebarGroup,{children:(0,t.jsx)(x.SidebarGroupContent,{children:(0,t.jsx)("div",{className:"flex w-full flex-row items-center justify-center gap-2 px-2 text-sm text-zinc-500",children:"Your conversations will appear here once you start chatting!"})})});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x.SidebarGroup,{children:(0,t.jsxs)(x.SidebarGroupContent,{children:[(0,t.jsx)(x.SidebarMenu,{children:c&&(e=c.flatMap(e=>e?.chats||[]),r=new Date,n=V(r,-7,void 0),a=function(e,t,r){let n=B(r?.in||e,e);if(isNaN(-1))return B(r?.in||e,NaN);0;let a=n.getDate(),s=B(r?.in||e,n.getTime());return(s.setMonth(n.getMonth()+-1+1,0),a>=s.getDate())?s:(n.setFullYear(s.getFullYear(),s.getMonth(),a),n)}(r,-1,void 0),i=e.reduce((e,t)=>{if(!t?.created_at)return e;let r=new Date(t.created_at);return W(B(r,r),q(r))?e.today.push(t):W(B(r,r),V(q(r),-1,void 0))?e.yesterday.push(t):r>n?e.lastWeek.push(t):r>a?e.lastMonth.push(t):e.older.push(t),e},{today:[],yesterday:[],lastWeek:[],lastMonth:[],older:[]}),(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[i.today.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"px-2 py-1 text-sidebar-foreground/50 text-xs",children:"Today"}),i.today.map(e=>(0,t.jsx)(Z,{chat:e,isActive:e.id===l,onDelete:e=>{j(e),v(!0)},setOpenMobile:o},e.id))]}),i.yesterday.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"px-2 py-1 text-sidebar-foreground/50 text-xs",children:"Yesterday"}),i.yesterday.map(e=>(0,t.jsx)(Z,{chat:e,isActive:e.id===l,onDelete:e=>{j(e),v(!0)},setOpenMobile:o},e.id))]}),i.lastWeek.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"px-2 py-1 text-sidebar-foreground/50 text-xs",children:"Last 7 days"}),i.lastWeek.map(e=>(0,t.jsx)(Z,{chat:e,isActive:e.id===l,onDelete:e=>{j(e),v(!0)},setOpenMobile:o},e.id))]}),i.lastMonth.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"px-2 py-1 text-sidebar-foreground/50 text-xs",children:"Last 30 days"}),i.lastMonth.map(e=>(0,t.jsx)(Z,{chat:e,isActive:e.id===l,onDelete:e=>{j(e),v(!0)},setOpenMobile:o},e.id))]}),i.older.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"px-2 py-1 text-sidebar-foreground/50 text-xs",children:"Older than last month"}),i.older.map(e=>(0,t.jsx)(Z,{chat:e,isActive:e.id===l,onDelete:e=>{j(e),v(!0)},setOpenMobile:o},e.id))]})]}))}),(0,t.jsx)(Y.motion.div,{onViewportEnter:()=>{d||p||u(e=>e+1)}}),!p&&(0,t.jsxs)("div",{className:"mt-8 flex flex-row items-center gap-2 p-2 text-zinc-500 dark:text-zinc-400",children:[(0,t.jsx)("div",{className:"animate-spin",children:(0,t.jsx)(K,{})}),(0,t.jsx)("div",{children:"Loading Chats..."})]})]})}),(0,t.jsx)(G.AlertDialog,{onOpenChange:v,open:b,children:(0,t.jsxs)(G.AlertDialogContent,{children:[(0,t.jsxs)(G.AlertDialogHeader,{children:[(0,t.jsx)(G.AlertDialogTitle,{children:"Are you absolutely sure?"}),(0,t.jsx)(G.AlertDialogDescription,{children:"This action cannot be undone. This will permanently delete your chat and remove it from our servers."})]}),(0,t.jsxs)(G.AlertDialogFooter,{children:[(0,t.jsx)(G.AlertDialogCancel,{children:"Cancel"}),(0,t.jsx)(G.AlertDialogAction,{onClick:()=>{let e=fetch(`/api/chat?id=${y}`,{method:"DELETE"});C.toast.promise(e,{loading:"Deleting chat...",success:()=>(h(e=>{if(e)return e.map(e=>({...e,chats:e?.chats?.filter(e=>e?.id!==y)||[]}))}),"Chat deleted successfully"),error:"Failed to delete chat"}),v(!1),y===l&&m.push("/")},children:"Continue"})]})]})})]})}function et(){let e=(0,s.useRouter)(),{setOpenMobile:i}=(0,x.useSidebar)();return(0,t.jsxs)(x.Sidebar,{className:"",children:[(0,t.jsx)(x.SidebarHeader,{children:(0,t.jsxs)(x.SidebarMenu,{children:[(0,t.jsx)("div",{className:"flex flex-row items-center pl-2 mt
7-1",children:(0,t.jsxs)(a.default,{className:"flex flex-row items-center gap-2",href:"/",onClick:()=>{i(!1)},children:[(0,t.jsx)(n.default,{src:"/logo.png",alt:y.SITE_NAME,width:32,height:32,className:"h-8 w-8"}),(0,t.jsx)("span",{className:"text-xl font-cal-sans",children:y.SITE_NAME})]})}),(0,t.jsx)(x.SidebarMenuItem,{className:"mt-4",children:(0,t.jsxs)(x.SidebarMenuButton,{onClick:()=>{e.push("/"),e.refresh(),i(!1)},children:[(0,t.jsx)(r.SquarePenIcon,{}),(0,t.jsx)("span",{children:"New rewrite"})]})})]})}),(0,t.jsx)(x.SidebarContent,{children:(0,t.jsx)(ee,{})}),(0,t.jsxs)(x.SidebarFooter,{children:[(0,t.jsx)(m,{}),(0,t.jsx)(F,{})]})]})}e.s(["AppSidebar",()=>et],87759)}]);
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.