1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Login-Bb-ilnbv.js","assets/ui-vendor-sd9EibYn.js","assets/react-vendor-CHx29PyI.js","assets/input-B-bVbcbu.js","assets/StoryOSLogo-2SMmvBkF.js","assets/external-link-D3PpyxhL.js","assets/eye-off-DS28Z__x.js","assets/utils-vendor-Cchy62ty.js","assets/supabase-vendor-DQD4jYU5.js","assets/Signup-OxiT418_.js","assets/password-CD4sTU1v.js","assets/AcceptTermsCheckbox-BaV7PaFL.js","assets/Account-ueFZCuYe.js","assets/YouTubeBadge-Bg0nz4p2.js","assets/aiFunctionLabels-C0gH0a6I.js","assets/switch-gDa-3w0A.js","assets/useYouTubeConnection-2QnPshBL.js","assets/circle-x-VSUniJG_.js","assets/circle-check-C52vZh_b.js","assets/credit-card-BlFRxDNd.js","assets/dollar-sign-BbSRxmUG.js","assets/mail-BLRHdblE.js","assets/sun-CjgIdou1.js","assets/YouTubeCallback-BLZNjUhe.js","assets/ResetPassword-qCPAL7FV.js","assets/SetPassword-CfHhWoEG.js","assets/ForgotPassword-DByjtv4i.js","assets/circle-check-big-TcasmMSE.js","assets/arrow-left-r0QswXBT.js","assets/NotFound-D6I-qL4Y.js","assets/ThumbnailBoard-N0F1CBCR.js","assets/card-D5QUQiSF.js","assets/dropdown-menu-Dy4YBrXq.js","assets/circle-MGYZ7_ei.js","assets/ThumbnailChatInterface-CnTdMKPJ.js","assets/useSmartScroll-3jNn2evi.js","assets/chatStorage-DdSqGdZo.js","assets/message-circle-BDUnns-9.js","assets/stageSteps-HL5zr3fu.js","assets/skeleton-Cfg2hoyJ.js","assets/api-CjNRIWFE.js","assets/plus-D7YOz1Db.js","assets/DoodleThumbnailBoard-DZ4G3A3S.js","assets/api-Clunlwc7.js","assets/VisionBoard-DH2_SAxt.js","assets/separator-B1ngHa2o.js","assets/popover-DmyaRYmy.js","assets/context-menu-BUXJy8dw.js","assets/imageCompression-DNGDb0xH.js","assets/tag-PL-USDzN.js","assets/image-ak06ZyGM.js","assets/ellipsis-BEA7QoVE.js","assets/arrow-right-Chwlwxx3.js","assets/BoardSelection-m15tEWFc.js","assets/SkyscraperBot-BmxKYEMc.js","assets/PointBot-DNLFvJsO.js","assets/PageHeader-CQok72LF.js","assets/PageContainer-BoQN3ZrA.js","assets/useBrainProfile-BdPamjKi.js","assets/IntroBot-DnlyMsEa.js","assets/IntroBotContent-Cai7fqCv.js","assets/useAutoResizeTextarea-Czr4YmC9.js","assets/mic-BjvdYRzW.js","assets/collapsible-oVDymtI8.js","assets/ScriptBot-CKiIgnHO.js","assets/ScriptEditorPanel-Bc28IqHo.js","assets/message-square-DDNaF74z.js","assets/BrainData-LvdXzJPA.js","assets/BrainDataForm-mgk7TZN8.js","assets/PageHeader-CQhLLGyf.js","assets/user-CVqE4H0x.js","assets/info-CFZLGmDC.js","assets/award-DTY5CpF-.js","assets/pencil-DvTvepU5.js","assets/MetricsDisclaimer-Dnsw9J5v.js","assets/SectionHeader-BOhXv2kO.js","assets/link-2-DkvM94oF.js","assets/dedupe-Bu1_r6Q6.js","assets/layers-DoBUFpDM.js","assets/DataBot-Buh74DFH.js","assets/checkbox-9Hm16XMw.js","assets/label-C4U9wmkh.js","assets/history-BFz_1zBo.js","assets/TwoPagePlannerBot-Csjq8fvQ.js","assets/PlanReferenceView-DCaMfJnL.js","assets/flame-BPmtS3B0.js","assets/list--6jXnmUT.js","assets/alert-dialog-Btn7N2Ot.js","assets/button-7spSmbHJ.js","assets/clock-BhbQk23q.js","assets/alert-C8ze1CfJ.js","assets/download-xCZ9aHP_.js","assets/Projects-CGDJCcNd.js","assets/core.esm-DNGqrA_F.js","assets/NewProjectDialog-CzTy2zwU.js","assets/TutorialDialog-GRkCKFAW.js","assets/CinematicVideoPlayer-dn_FC0Ks.js","assets/wistia-Bo18neXe.js","assets/useAccentColor-C9cufVF1.js","assets/play-D-gUxa0I.js","assets/rotate-ccw-CNjrRxxs.js","assets/ProjectWorkflow-D-TinkAH.js","assets/radio-group-BV2QMUMV.js","assets/useConfetti-DLpFhzhF.js","assets/select-p-iRORxZ.js","assets/save-DLGJdvJm.js","assets/lock-open-BC3nemAv.js","assets/panel-left-close-CLEEizgd.js","assets/upload-C4XvMB7v.js","assets/accordion--3_fzZ5U.js","assets/useAdminStatus-cydXeAZW.js","assets/ChannelAnalytics-BVR6ctU5.js","assets/Analytics-DZkLqOhA.js","assets/api-CeY2Yu9H.js","assets/AnalyticsShell-eOWcvje3.js","assets/chart-CC0dR42G.js","assets/PieChart-C94eMm99.js","assets/progress-Gw7_Tn_I.js","assets/trending-down-cKPMpgjH.js","assets/SharePie-BsNIDZVc.js","assets/BarChart-B1L26qpm.js","assets/shield-alert-B6E6qOrQ.js","assets/gauge-BYMM7r7g.js","assets/WebhookTest-GsNy4pkg.js","assets/LogoExport-Bfz_ysCi.js","assets/html2canvas.esm-CBrSDip1.js","assets/ValidationTest-D_hkDAz1.js","assets/HireHumanPage-Bl9YuCD2.js","assets/LiveReviews-B0gw_Ngg.js","assets/ReviewSubmissionForm-CQ1O3G3C.js","assets/api-AbGu1m4a.js","assets/CohortAssignments-C9BIAElo.js","assets/LockedWeek-8JSBVvMB.js","assets/StatePill-CuIydZZr.js","assets/api-DhW63x5N.js","assets/PreCohortChecklist-C9rCIUkg.js","assets/undo-2-BEkL8ejq.js","assets/CohortRecordings-DKpFhBhJ.js","assets/ReportDialog-BlHnA8hd.js","assets/heart-Xd_r2VtV.js","assets/party-popper-BnFJW7iG.js","assets/ThreadReplies-DTA8f8Ej.js","assets/CohortCommunity-aaK_PrTC.js","assets/FunnelTracker-xHRfB5_f.js","assets/sliders-horizontal-CRFDFQSx.js","assets/EmailUnsubscribe-DHpeN1uh.js","assets/CohortThread-TyFTKXkf.js","assets/CohortReviewBoard-Cowzqfz5.js","assets/teamApi-OzSS3_4Y.js","assets/CohortWorkDialog-CLn5cTz7.js","assets/CohortProgress-BMNp8f_Q.js","assets/CohortSetup-DhKPzXtF.js","assets/archive-N8cvAPqo.js","assets/Onboarding-CQ0W2InO.js","assets/onboardingShared-RiZR44eF.js","assets/NicheResearch-hYjkLuQj.js","assets/panels-top-left-CR03uX9y.js","assets/compass-xQ33P9kB.js","assets/CourseResources-CJ8OiXYL.js","assets/square-check-big-DUt0Fv-J.js","assets/api-BEnehsIZ.js","assets/DocsHub-CDsNrqXe.js","assets/sortable.esm-DPs6_cmX.js","assets/storageUrls-Dz3yJmRF.js","assets/SupportTickets-MbUjueFF.js","assets/table-BaqXb3Vu.js","assets/api-B6IsjCVy.js","assets/TicketChat-BP3C3NUy.js","assets/ticket-CXX7kRPP.js","assets/Announcements-DureCozK.js","assets/calendar-CkLkEPlm.js","assets/Settings-iVZT3SDE.js","assets/api-QjTFqmNI.js","assets/star-CyNS_1kg.js","assets/GrowthProof-DgYvjF4h.js","assets/TrendReports-lRTeVBcr.js","assets/AdminDashboard-B_pPxrGj.js","assets/trophy-Co4XCM8h.js","assets/database-DEQLYzgb.js","assets/shield-off-_anrvOzr.js","assets/ChannelRegistry-EFPM2TCG.js","assets/arrow-up-down-DsdgiV1F.js","assets/OutlierDatabase-DvJPxBcS.js","assets/NicheReports-B66cxMLa.js","assets/CourseManager-PIfEO60j.js","assets/LiveReviewsAdmin-NlPeVvxv.js","assets/Integrations-BpuWKKPv.js","assets/KartraSyncCard-DcCLN72n.js","assets/AccessRights-B__1jfGX.js","assets/AiSpendControl-U46-S41o.js","assets/shield-check-CTk7ZMyU.js","assets/wallet-CBQoPaE1.js","assets/VideoInsights-5D0
1pquAj.js","assets/ConversationBrowser-C9pbNAIR.js","assets/Testimonials-GTDE4RjE.js","assets/StarRating-CrjiEmNA.js","assets/SalesBotConversations-DyMTdy-F.js","assets/BannedUsers-DwoRJ5nf.js","assets/Users-C_1-FeH8.js","assets/PricingManager-D8QhfKhj.js","assets/FunnelAudit-DgR8eH2j.js","assets/OfferCreator-DhoyVSgD.js","assets/ChannelAuditWizard-X1XhwhkU.js","assets/FreeTools-CRH4dkRb.js","assets/data-BMsDPnsn.js","assets/mc-double-sales-DgLdPu8f.js","assets/ErrorDashboard-LZhLxpu4.js","assets/ResearchWrapper-NXPJ59XO.js","assets/AiAssistant-BK7W3jWA.js","assets/CoursePlayer-BoL9Q3R6.js","assets/PremiumCoursePlayer-Ci6hZS_W.js","assets/MyTickets-Bp1qCEJX.js","assets/AffiliateDashboard-BA-4kaTj.js","assets/StoryOSLanding-u2Frf3BJ.js","assets/charlie-morgan-x_06ZZrQ.js","assets/support-CYbXoYb5.js","assets/StoryOS2-CCfT-5-y.js","assets/revtrackTracker-C2JrJp2R.js","assets/Free-FscgEr60.js","assets/free-channel-review-CPXbWTsA.js","assets/Free2-stLcZdT8.js","assets/StoryOSFreeThankYou-Bea0sq8H.js","assets/FreeOfferTool-C_E8wogY.js","assets/FreeOfferToolThankYou-BzsZ8f4n.js","assets/revtrackEmailThankYou-Bh8BPL1c.js","assets/TrillionDollarStrategy-CdftXISc.js","assets/TrillionLive-BaRS1yWH.js","assets/Masterclass-B7eyU3yJ.js","assets/LaunchRoom-BbNMZvL5.js","assets/globals-CuFDM6T4.css","assets/LaunchRoomThankYou-MntwEFNA.js","assets/LaunchRoomApplicationThankYou-CSph6odK.js","assets/LaunchRoomWaitlistThankYou-Ca5B1-Zs.js","assets/PrivacyPolicy-CuOGtWlU.js","assets/TermsOfService-E-Mkojjm.js","assets/ThankYou-Bj179aqo.js","assets/ApplyThankYou--8S2VkUE.js","assets/WorkWithEd-DEnnXSN2.js","assets/StoryOSElite-tbqSrt9Q.js","assets/GrowthPartnerships-DhEdckYD.js","assets/GrowthPartnershipsThankYou-CHc4Jv64.js","assets/GrowthPartnershipsNewClient-B2qvQc2Z.js","assets/revtrackFunnelStep-DO4trxcz.js","assets/MasterclassPage-3d1L1-QR.js","assets/AccountLocked-DzmyVvRZ.js","assets/LateCheckout-z2zgaRmh.js","assets/WaitlistThankYou-C1U0aXFD.js","assets/WaitlistThankYouNew-zdUobmHW.js"])))=>i.map(i=>d[i]); 2var _y=Object.defineProperty;var Ay=(t,e,n)=>e in t?_y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var vn=(t,e,n)=>Ay(t,typeof e!="symbol"?e+"":e,n);import{j as d,V as Vh,R as Wh,A as Hh,C as qh,T as Uh,D as Kh,P as My,c as Ny,b as Yh,u as Jh,d as jy,e as wn,f as gr,g as Gh,h as Iy,i as Ry,k as Oy,l as Py,m as Dy,n as Ly,o as er,p as By,q as zy,O as qr,r as Ur,s as Qh,t as Fi,v as $i,w as ls,x as cs,y as Xh,z as vi,B as Zh,I as ef,F as tf,E as nf,G as Fy,H as $y,S as rf,J as Vy,L as of,K as sf,M as af,N as Wy}from"./ui-vendor-sd9EibYn.js";import{a as lf,r as y,R as Y,b as cf,L as Lr,u as It,N as et,d as Hy,e as qy,f as qn,g as Do,h as uf,O as Uy,B as Ky,i as Yy,j as $}from"./react-vendor-CHx29PyI.js";import{c as df,t as Jy,f as Gy,a as Qy,o as di,s as Tt,b as Lc,n as Xy}from"./utils-vendor-Cchy62ty.js";import{Q as Zy,c as ex,u as Ln,a as hf,b as Xi,d as tx}from"./supabase-vendor-DQD4jYU5.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();const nx="__storyos_storage_fallback__:",rx=()=>{const t=globalThis;return t.__storyosStorageFallbackMap__||(t.__storyosStorageFallbackMap__=new Map),t.__storyosStorageFallbackMap__},ff=t=>{if(typeof window>"u")return;const e=window[t],n=Object.getPrototypeOf(e);if(!n||n.__storyosGuarded__)return;const r=rx(),i=n.getItem,o=n.setItem,s=n.removeItem,a=n.clear,l=n.key,c=Object.getOwnPropertyDescriptor(n,"length"),u=`${n
2x}${t}:`;n.getItem=function(p){try{return i.call(this,p)}catch{return r.get(u+p)??null}},n.setItem=function(p,f){try{o.call(this,p,f),r.delete(u+p)}catch(m){r.set(u+p,String(f)),console.warn(`${t} setItem failed, using in-memory fallback for key "${p}"`,m)}},n.removeItem=function(p){try{s.call(this,p)}catch(f){console.warn(`${t} removeItem failed, clearing in-memory fallback for key "${p}"`,f)}finally{r.delete(u+p)}},n.clear=function(){try{a.call(this)}catch(p){console.warn(`${t} clear failed, clearing only in-memory fallback`,p)}finally{Array.from(r.keys()).filter(p=>p.startsWith(u)).forEach(p=>r.delete(p))}},n.key=function(p){try{return l.call(this,p)}catch{return Array.from(r.keys()).filter(g=>g.startsWith(u)).map(g=>g.slice(u.length))[p]??null}},Object.defineProperty(n,"length",{configurable:!0,get(){try{return c!=null&&c.get?c.get.call(this):0}catch{return Array.from(r.keys()).filter(p=>p.startsWith(u)).length}}}),n.__storyosGuarded__=!0};ff("localStorage");ff("sessionStorage");const pf=6,Bc="hotjar-tracking-code";let tr=!1;const ix=t=>{if(!t)return;const e=Object.entries(t).flatMap(([n,r])=>typeof r=="string"||typeof r=="number"||typeof r=="boolean"?[[n,r]]:[]);if(e.length!==0)return Object.fromEntries(e)},ox=t=>`https://static.hotjar.com/c/hotjar-${t}.js?sv=${pf}`,sx=()=>{const t="6678280".trim();if(!t)return null;const e=Number(t);return Number.isFinite(e)&&e>0?e:null},ax=()=>{if(typeof window>"u"||typeof document>"u")return;if(tr||document.getElementById(Bc)){tr=!0;return}const t=sx();if(!t)return;window.hj=window.hj||function(...i){var o;window.hj.q=window.hj.q||[],(o=window.hj.q)==null||o.push(i)},window._hjSettings={hjid:t,hjsv:pf};const e=document.createElement("script");e.id=Bc,e.async=!0,e.src=ox(t);const n=document.head||document.getElementsByTagName("head")[0];n==null||n.appendChild(e),tr=!0},lx=t=>{!tr||!window.hj||window.hj("stateChange",t)},mf=(t,e)=>{!tr||!window.hj||window.hj("identify",t,ix(e)??{})},za=()=>{!tr||!window.hj||window.hj("identify",null)},Tn=t=>{!tr||!window.hj||window.hj("event",t)},zc="rewardful-tracking-code",cx="955bf2";let wo=!1;const ux=()=>cx,dx=()=>
2{if(typeof window>"u"||typeof document>"u")return;if(wo||document.getElementById(zc)){wo=!0;return}window._rwq="rewardful",window.rewardful=window.rewardful||function(...r){var i;window.rewardful.q=window.rewardful.q||[],(i=window.rewardful.q)==null||i.push(r)};const t=document.createElement("script");t.id=zc,t.async=!0,t.src="https://r.wdfl.co/rw.js",t.setAttribute("data-rewardful",ux());const e=document.head||document.getElementsByTagName("head")[0];e==null||e.appendChild(t),wo=!0},DO=t=>{!wo||!window.rewardful||window.rewardful("convert",{email:t})},hx=()=>{var t;return(t=window.Rewardful)==null?void 0:t.referral},fx=new Set(["access_token","refresh_token","provider_token","provider_refresh_token","id_token","code","token","token_hash","state","secret","api_key","apikey","password","email"]);function px(t){if(!t||t==="?")return"";const e=new URLSearchParams(t.startsWith("?")?t.slice(1):t);for(const r of Array.from(e.keys()))fx.has(r.toLowerCase())&&e.delete(r);const n=e.toString();return n?`?${n}`:""}function mx(t){if(!t||t==="#")return"";const e=t.startsWith("#")?t.slice(1):t;return e.includes("=")||e.includes("&")?"":`#${e}`}function gf(t){return`${t.pathname}${px(t.search??"")}${mx(t.hash??"")}`}const gx="G-RLWJTF1QN6";function yx(){const t="".trim();return/^G-[A-Z0-9]+$/i.test(t)?t:gx}const yf=yx();let Fc=!1;function xx(){if(typeof document>"u"||document.querySelector('script[src*="googletagmanager.com/gtag/js"]'))return;const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${yf}`,document.head.appendChild(e)}function bx(){if(Fc||typeof window>"u")return;const t=window;t.dataLayer=t.dataLayer||[];function e(){t.dataLayer.push(arguments)}t.gtag=e,xx(),t.gtag("js",new Date),t.gtag("config",yf),Fc=!0}function wx(t){if(typeof window>"u")return;const e=window.gtag;e&&e("event","page_view",{page_path:t||gf(window.location)})}const Fa=new Set;let ki=null;function xf(){return`${Bo("analytics")?1:0}${Bo("marketing")?1:0}`}function Lo(t){const e=document.cookie.match(new RegExp(`(?:^|; )${t}=([^;]*)`));return e?decodeURIComponent(e[1]):null}function vx(){const t=window;return typeof t.Cookiebot<"u"||typeof t.CookieScript<"u"||Lo("cookieyes-consent")!==null||Lo("CookieConsent")!==null}function Bo(t){var s,a,l,c;const e=window,n=t==="analytics";if((s=e.Cookiebot)!=null&&s.consent)return!!(n?e.Cookiebot.consent.statistics:e.Cookiebot.consent.marketing);const r=Lo("CookieConsent");if(r)return n?/"?statistics"?:true/.test(r):/"?marketing"?:true/.test(r);const i=Lo("cookieyes-consent");if(i)return n?/analytics:yes/.test(i):/advertisement:yes/.test(i);const o=(c=(l=(a=e.CookieScript)==null?void 0:a.instance)==null?void 0:l.currentState)==null?void 0:c.call(l);return o!=null&&o.categories?o.categories.includes(n?"performance":"targeting"):!1}function Hn(){const t=xf();if(t===ki)return;ki=t;const e=t!=="00";
2Fa.forEach(n=>{try{n(e)}catch(r){console.error("Consent listener failed:",r)}})}function kx(t){return Fa.add(t),ki=xf(),t(ki!=="00"),()=>Fa.delete(t)}let $c=!1;function Sx(){if($c||typeof window>"u")return;$c=!0,document.addEventListener("cookieyes_consent_update",Hn),document.addEventListener("CookiebotOnAccept",Hn),document.addEventListener("CookiebotOnDecline",Hn),document.addEventListener("CookieScriptAccept",Hn),document.addEventListener("CookieScriptAcceptAll",Hn);let t=0;const e=window.setInterval(()=>{t+=1,Hn(),(ki==="11"||t>60)&&window.clearInterval(e)},1e3);Hn()}var bf,Vc=lf;bf=Vc.createRoot,Vc.hydrateRoot;const Cx="modulepreload",Ex=function(t){return"/"+t},Wc={},U=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),a=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));i=Promise.allSettled(n.map(l=>{if(l=Ex(l),l in Wc)return;Wc[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const h=document.createElement("link");if(h.rel=c?"stylesheet":Cx,c||(h.as="script"),h.crossOrigin="",h.href=l,a&&h.setAttribute("nonce",a),document.head.appendChild(h),c)return new Promise((p,f)=>{h.addEventListener("load",p),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return e().catch(o)})},Tx=1,_x=1e6;let Hs=0;function Ax(){return Hs=(Hs+1)%Number.MAX_SAFE_INTEGER,Hs.toString()}const qs=new Map,Hc=t=>{if(qs.has(t))return;const e=setTimeout(()=>{qs.delete(t),hi({type:"REMOVE_TOAST",toastId:t})},_x);qs.set(t,e)},Mx=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,Tx)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(n=>n.id===e.toast.id?{...n,...e.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=e;return n?Hc(n):t.toasts.forEach(r=>{Hc(r.id)}),{...t,toasts:t.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(n=>n.id!==e.toastId)}}},vo=[];let ko={toasts:[]};function hi(t){ko=Mx(ko,t),vo.forEach(e=>{e(ko)})}function Mt({...t}){const e=Ax(),n=i=>hi({type:"UPDATE_TOAST",toast:{...i,id:e}}),r=()=>hi({type:"DISMISS_TOAST",toastId:e});return hi({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:i=>{i||r()}}}),{id:e,dismiss:r,update:n}}function Vi(){const[t,e]=y.useState(ko);return y.useEffect(()=>(vo.push(e),()=>{const n=vo.indexOf(e);n>-1&&vo.splice(n,1)}),[t]),{...t,toast:Mt,dismiss:n=>hi({type:"DISMISS_TOAST",toastId:n})}}const qc=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Uc=df,Dl=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return Uc(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:o}=e,s=Object.keys(i).map(c=>{const u=n==null?void 0:n[c],h=o==null?void 0:o[c];if(u===null)return null;const p=qc(u)||qc(h);return i[c][p]}),a=n&&Object.entries(n).reduce((c,u)=>{let[h,p]=u;return p===void 0||(c[h]=p),c},{}),l=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:h,className:p,...f}=u;return Object.entries(f).every(m=>{let[g,x]=m;return Array.isArray(x)?x.includes({...o,...a}[g]):{...o,...a}[g]===x})?[...c,h,p]:c},[]);return Uc(t,s,l,n==null?void 0:n.class,n==null?void 0:n.className)};/** 3 * @license lucide-react v0.462.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const Nx=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),wf=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** 8 * @license lucide-react v0.462.0 - ISC 9 * 10 * This source code is licensed under the ISC license. 11 * See the LICENSE file in the root directory of this source tree. 12 */var jx={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** 13 * @license lucide-react v0.462.0 - ISC 14 * 15 * This source code is licensed under the ISC license. 16 * See the LICENSE file in the root directory of this source tree. 17 */const Ix=y.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:s,...a},l)=>y.createElement("svg",{ref:l,...jx,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:wf("lucide",i),...a},[...s.map(([c,u])=>y.createElement(c,u)),...Array.isArray(o)?o:[o]]));/** 18 * @license lucide-react v0.462.0 - ISC 19 * 20 * This source code is licensed under the ISC license. 21 * See the LICENSE file in the root directory of this source tree. 22 */const se=(t,e)=>{const n=y.forwardRef(({className:r,...i},o)=>y.createElement(Ix,{ref:o,iconNode:e,className:wf(`lucide-${Nx(t)}`,r),...i}));return n.displayName=`${t}`,n};/** 23 * @license lucide-react v0.462.0 - ISC 24 * 25 * This source code is licensed under the ISC license. 26 * See the LICENSE file in the root directory of this source tree. 27 */const Rx=se("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l
27-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** 28 * @license lucide-react v0.462.0 - ISC 29 * 30 * This source code is licensed under the ISC license. 31 * See the LICENSE file in the root directory of this source tree. 32 */const Ox=se("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** 33 * @license lucide-react v0.462.0 - ISC 34 * 35 * This source code is licensed under the ISC license. 36 * See the LICENSE file in the root directory of this source tree. 37 */const Px=se("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** 38 * @license lucide-react v0.462.0 - ISC 39 * 40 * This source code is licensed under the ISC license. 41 * See the LICENSE file in the root directory of this source tree. 42 */const Ll=se("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** 43 * @license lucide-react v0.462.0 - ISC 44 * 45 * This source code is licensed under the ISC license. 46 * See the LICENSE file in the root directory of this source tree. 47 */const $a=se("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** 48 * @license lucide-react v0.462.0 - ISC 49 * 50 * This source code is licensed under the ISC license. 51 * See the LICENSE file in the root directory of this source tree. 52 */const Wi=se("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** 53 * @license lucide-react v0.462.0 - ISC 54 * 55 * This source code is licensed under the ISC license. 56 * See the LICENSE file in the root directory of this source tree. 57 */const us=se("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** 58 * @license lucide-react v0.462.0 - ISC 59 * 60 * This source code is licensed under the ISC license. 61 * See the LICENSE file in the root directory of this source tree. 62 */const Dx=se("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** 63 * @license lucide-react v0.462.0 - ISC 64 * 65 * This source code is licensed under the ISC license. 66 * See the LICENSE file in the root directory of this source tree. 67 */const Si=se("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** 68 * @license lucide-react v0.462.0 - ISC 69 * 70 * This source code is licensed under the ISC license. 71 * See the LICENSE file in the root directory of this source tree. 72 */const vf=se("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** 73 * @license lucide-react v0.462.0 - ISC 74 * 75 * This source code is licensed under the ISC license. 76 * See the LICENSE file in the root directory of this source tree. 77 */const Lx=se("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** 78 * @license lucide-react v0.462.0 - ISC 79 * 80 * This source code is licensed under the ISC license. 81 * See the LICENSE file in the root directory of this source tree. 82 */const Bx=se("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** 83 * @license lucide-react v0.462.0 - ISC 84 * 85 * This source code is licensed under the ISC license. 86 * See the LICENSE file in the root directory of this source tree. 87 */const zx=se("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** 88 * @license lucide-react v0.462.0 - ISC 89 * 90 * This source code is licensed under the ISC license. 91 * See the LICENSE file in the root directory of this source tree. 92 */const Kc=se("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** 93 * @license lucide-react v0.462.0 - ISC 94 * 95 * This source code is licensed under the ISC license. 96 * See the LICENSE file in the root directory of this source tree. 97 */const Yc=se("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** 98 * @license lucide-react v0.462.0 - ISC 99 * 100 * This source code is licensed under the ISC license. 101 * See the LICENSE file in the root directory of this source tree. 102 */const Fx=se("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** 103 * @license lucide-react v0.462.0 - ISC 104 * 105 * This source code is licensed under the ISC license. 106 * See the LICENSE file in the root directory of this source tree. 107 */const Bl=se("CircleHelp",[["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"}]]);/** 108 * @license lucide-react v0.462.0 - ISC 109 * 110 * This source code is licensed under the ISC license. 111 * See the LICENSE file in the root directory of this source tree. 112 */const $x=se("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** 113 * @license lucide-react v0.462.0 - ISC 114 * 115 * This source code is licensed under the ISC license. 116 * See the LICENSE file in the root directory of this source tree. 117 */const Vx=se("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** 118 * @license lucide-react v0.462.0 - ISC 119 * 120 * This source code is licensed under the ISC license. 121 * See the LICENSE file in the root directory of this source tree.
122 */const Wx=se("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/** 123 * @license lucide-react v0.462.0 - ISC 124 * 125 * This source code is licensed under the ISC license. 126 * See the LICENSE file in the root directory of this source tree. 127 */const Hx=se("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** 128 * @license lucide-react v0.462.0 - ISC 129 * 130 * This source code is licensed under the ISC license. 131 * See the LICENSE file in the root directory of this source tree. 132 */const qx=se("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** 133 * @license lucide-react v0.462.0 - ISC 134 * 135 * This source code is licensed under the ISC license. 136 * See the LICENSE file in the root directory of this source tree. 137 */const kf=se("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** 138 * @license lucide-react v0.462.0 - ISC 139 * 140 * This source code is licensed under the ISC license. 141 * See the LICENSE file in the root directory of this source tree. 142 */const zl=se("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/** 143 * @license lucide-react v0.462.0 - ISC 144 * 145 * This source code is licensed under the ISC license. 146 * See the LICENSE file in the root directory of this source tree. 147 */const Ux=se("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** 148 * @license lucide-react v0.462.0 - ISC 149 * 150 * This source code is licensed under the ISC license. 151 * See the LICENSE file in the root directory of this source tree. 152 */const Jc=se("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** 153 * @license lucide-react v0.462.0 - ISC 154 * 155 * This source code is licensed under the ISC license. 156 * See the LICENSE file in the root directory of this source tree. 157 */const Ci=se("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);/** 158 * @license lucide-react v0.462.0 - ISC 159 * 160 * This source code is licensed under the ISC license. 161 * See the LICENSE file in the root directory of this source tree. 162 */const Ar=se("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** 163 * @license lucide-react v0.462.0 - ISC 164 * 165 * This source code is licensed under the ISC license. 166 * See the LICENSE file in the root directory of this source tree. 167 */const Sf=se("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** 168 * @license lucide-react v0.462.0 - ISC 169 * 170 * This source code is licensed under the ISC license. 171 * See the LICENSE file in the root directory of this source tree. 172 */const Cf=se("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** 173 * @license lucide-react v0.462.0 - ISC 174 * 175 * This source code is licensed under the ISC license. 176 * See the LICENSE file in the root directory of this source tree. 177 */const Kx=se("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/** 178 * @license lucide-react v0.462.0 - ISC 179 * 180 * This source code is licensed under the ISC license. 181 * See the LICENSE file in the root directory of this source tree. 182 */const Yx=se("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** 183 * @license lucide-react v0.462.0 - ISC 184 * 185 * This source code is licensed under the ISC license. 186 * See the LICENSE file in the root directory of this source tree. 187 */const Ef=se("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** 188 * @license lucide-react v0.462.0 - ISC 189 * 190 * This source code is licensed under the ISC license. 191 * See the LICENSE file in the root directory of this source tree. 192 */const Jx=se("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/** 193 * @license lucide-react v0.462.0 - ISC 194 * 195 * This source code is licensed under the ISC license. 196 * See the LICENSE file in the root directory of this source tree. 197 */const Va=se("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** 198 * @license lucide-react v0.462.0 - ISC 199 * 200 * This source code is licensed under the ISC license. 201 * See the LICENSE file in the root directory of this source tree. 202 */const Gx=se("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** 203 * @license lucide-react v0.462.0 - ISC 204 * 205 * This source code is licensed under the ISC license. 206 * See the LICENSE file in the root directory of this source tree. 207 */const ut=se("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** 208 * @license lucide-react v0.462.0 - ISC 209 * 210 * This source code is licensed under the ISC license. 211 * See the LICENSE file in the root directory of this source tree.
212 */const Qx=se("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** 213 * @license lucide-react v0.462.0 - ISC 214 * 215 * This source code is licensed under the ISC license. 216 * See the LICENSE file in the root directory of this source tree. 217 */const Xx=se("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** 218 * @license lucide-react v0.462.0 - ISC 219 * 220 * This source code is licensed under the ISC license. 221 * See the LICENSE file in the root directory of this source tree. 222 */const Zx=se("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** 223 * @license lucide-react v0.462.0 - ISC 224 * 225 * This source code is licensed under the ISC license. 226 * See the LICENSE file in the root directory of this source tree. 227 */const Gc=se("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["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"}]]);/** 228 * @license lucide-react v0.462.0 - ISC 229 * 230 * This source code is licensed under the ISC license. 231 * See the LICENSE file in the root directory of this source tree. 232 */const eb=se("MessagesSquare",[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]]);/** 233 * @license lucide-react v0.462.0 - ISC 234 * 235 * This source code is licensed under the ISC license. 236 * See the LICENSE file in the root directory of this source tree. 237 */const zo=se("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/** 238 * @license lucide-react v0.462.0 - ISC 239 * 240 * This source code is licensed under the ISC license. 241 * See the LICENSE file in the root directory of this source tree. 242 */const tb=se("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** 243 * @license lucide-react v0.462.0 - ISC 244 * 245 * This source code is licensed under the ISC license. 246 * See the LICENSE file in the root directory of this source tree. 247 */const Tf=se("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** 248 * @license lucide-react v0.462.0 - ISC 249 * 250 * This source code is licensed under the ISC license. 251 * See the LICENSE file in the root directory of this source tree. 252 */const Ei=se("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** 253 * @license lucide-react v0.462.0 - ISC 254 * 255 * This source code is licensed under the ISC license. 256 * See the LICENSE file in the root directory of this source tree. 257 */const Fl=se("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** 258 * @license lucide-react v0.462.0 - ISC 259 * 260 * This source code is licensed under the ISC license. 261 * See the LICENSE file in the root directory of this source tree. 262 */const nb=se("Settings2",[["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"}]]);/** 263 * @license lucide-react v0.462.0 - ISC 264 * 265 * This source code is licensed under the ISC license. 266 * See the LICENSE file in the root directory of this source tree. 267 */const _f=se("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** 268 * @license lucide-react v0.462.0 - ISC 269 * 270 * This source code is licensed under the ISC license. 271 * See the LICENSE file in the root directory of this source tree. 272 */const rb=se("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/** 273 * @license lucide-react v0.462.0 - ISC 274 * 275 * This source code is licensed under the ISC license. 276 * See the LICENSE file in the root directory of this source tree. 277 */const $l=se("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
277y:"oel41y"}]]);/** 278 * @license lucide-react v0.462.0 - ISC 279 * 280 * This source code is licensed under the ISC license. 281 * See the LICENSE file in the root directory of this source tree. 282 */const Ti=se("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** 283 * @license lucide-react v0.462.0 - ISC 284 * 285 * This source code is licensed under the ISC license. 286 * See the LICENSE file in the root directory of this source tree. 287 */const ib=se("SquarePlay",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 8 6 4-6 4Z",key:"f1r3lt"}]]);/** 288 * @license lucide-react v0.462.0 - ISC 289 * 290 * This source code is licensed under the ISC license. 291 * See the LICENSE file in the root directory of this source tree. 292 */const ob=se("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** 293 * @license lucide-react v0.462.0 - ISC 294 * 295 * This source code is licensed under the ISC license. 296 * See the LICENSE file in the root directory of this source tree. 297 */const sb=se("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/** 298 * @license lucide-react v0.462.0 - ISC 299 * 300 * This source code is licensed under the ISC license. 301 * See the LICENSE file in the root directory of this source tree. 302 */const ab=se("Table2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/** 303 * @license lucide-react v0.462.0 - ISC 304 * 305 * This source code is licensed under the ISC license. 306 * See the LICENSE file in the root directory of this source tree. 307 */const Af=se("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** 308 * @license lucide-react v0.462.0 - ISC 309 * 310 * This source code is licensed under the ISC license. 311 * See the LICENSE file in the root directory of this source tree. 312 */const lb=se("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/** 313 * @license lucide-react v0.462.0 - ISC 314 * 315 * This source code is licensed under the ISC license. 316 * See the LICENSE file in the root directory of this source tree. 317 */const cb=se("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/** 318 * @license lucide-react v0.462.0 - ISC 319 * 320 * This source code is licensed under the ISC license. 321 * See the LICENSE file in the root directory of this source tree. 322 */const ub=se("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** 323 * @license lucide-react v0.462.0 - ISC 324 * 325 * This source code is licensed under the ISC license. 326 * See the LICENSE file in the root directory of this source tree. 327 */const Vl=se("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** 328 * @license lucide-react v0.462.0 - ISC 329 * 330 * This source code is licensed under the ISC license. 331 * See the LICENSE file in the root directory of this source tree. 332 */const db=se("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** 333 * @license lucide-react v0.462.0 - ISC 334 * 335 * This source code is licensed under the ISC license. 336 * See the LICENSE file in the root directory of this source tree. 337 */const Mf=se("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** 338 * @license lucide-react v0.462.0 - ISC 339 * 340 * This source code is licensed under the ISC license. 341 * See the LICENSE file in the root directory of this source tree. 342 */const Nf=se("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** 343 * @license lucide-react v0.462.0 - ISC 344 * 345 * This source code is licensed under the ISC license. 346 * See the LICENSE file in the root directory of this source tree. 347 */const jf=se("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** 348 * @license lucide-react v0.462.0 - ISC 349 * 350 * This source code is licensed under the ISC license. 351 * See the LICENSE file in the root directory of this source tree. 352 */const hb=se("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** 353 * @license lucide-react v0.462.0 - ISC 354 * 355 * This source code is licensed under the ISC license. 356 * See the LICENSE file in the root directory of this source tree. 357 */const Bn=se("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}
357],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** 358 * @license lucide-react v0.462.0 - ISC 359 * 360 * This source code is licensed under the ISC license. 361 * See the LICENSE file in the root directory of this source tree. 362 */const fb=se("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/** 363 * @license lucide-react v0.462.0 - ISC 364 * 365 * This source code is licensed under the ISC license. 366 * See the LICENSE file in the root directory of this source tree. 367 */const pb=se("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function Ne(...t){return Jy(df(t))}const mb=My,If=y.forwardRef(({className:t,...e},n)=>d.jsx(Vh,{ref:n,className:Ne("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...e}));If.displayName=Vh.displayName;const gb=Dl("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Rf=y.forwardRef(({className:t,variant:e,...n},r)=>d.jsx(Wh,{ref:r,className:Ne(gb({variant:e}),t),...n}));Rf.displayName=Wh.displayName;const yb=y.forwardRef(({className:t,...e},n)=>d.jsx(Hh,{ref:n,className:Ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...e}));yb.displayName=Hh.displayName;const Of=y.forwardRef(({className:t,...e},n)=>d.jsx(qh,{ref:n,className:Ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...e,children:d.jsx(Bn,{className:"h-4 w-4"})}));Of.displayName=qh.displayName;const Pf=y.forwardRef(({className:t,...e},n)=>d.jsx(Uh,{ref:n,className:Ne("text-sm font-semibold",t),...e}));Pf.displayName=Uh.displayName;const Df=y.forwardRef(({className:t,...e},n)=>d.jsx(Kh,{ref:n,className:Ne("text-sm opacity-90",t),...e}));Df.displayName=Kh.displayName;function xb(){const{toasts:t}=Vi();return d.jsxs(mb,{children:[t.map(function({id:e,title:n,description:r,action:i,...o}){return d.jsxs(Rf,{...o,children:[d.jsxs("div",{className:"grid gap-1",children:[n&&d.jsx(Pf,{children:n}),r&&d.jsx(Df,{children:r})]}),i,d.jsx(Of,{})]},e)}),d.jsx(If,{})]})}var bb=(t,e,n,r,i,o,s,a)=>{let l=document.documentElement,c=["light","dark"];function u(f){(Array.isArray(t)?t:[t]).forEach(m=>{let g=m==="class",x=g&&o?i.map(b=>o[b]||b):i;g?(l.classList.remove(...x),l.classList.add(o&&o[f]?o[f]:f)):l.setAttribute(m,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function p(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dar
367k":"light"}if(r)u(r);else try{let f=localStorage.getItem(e)||n,m=s&&f==="system"?p():f;u(m)}catch{}},wb=y.createContext(void 0),vb={setTheme:t=>{},themes:[]},kb=()=>{var t;return(t=y.useContext(wb))!=null?t:vb};y.memo(({forcedTheme:t,storageKey:e,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:o,value:s,themes:a,nonce:l,scriptProps:c})=>{let u=JSON.stringify([n,e,o,t,a,s,r,i]).slice(1,-1);return y.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${bb.toString()})(${u})`}})});var Sb=t=>{switch(t){case"success":return Tb;case"info":return Ab;case"warning":return _b;case"error":return Mb;default:return null}},Cb=Array(12).fill(0),Eb=({visible:t,className:e})=>Y.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},Y.createElement("div",{className:"sonner-spinner"},Cb.map((n,r)=>Y.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),Tb=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),_b=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Ab=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Mb=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Nb=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Y.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Y.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),jb=()=>{let[t,e]=Y.useState(document.hidden);return Y.useEffect(()=>{let n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t},Wa=1,Ib=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:n,...r}=t,i=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:Wa++,o=this.toasts.find(a=>a.id===i),s=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),o?this.toasts=this.toasts.map(a=>a.id===i?(this.publish({...a,...t,id:i,title:n}),{...a,...t,id:i,dismissible:s,title:n}):a):this.addToast({title:n,...r,dismissible:s,id:i}),i},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(n=>n({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let n;e.loading!==void 0&&(n=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let r=t instanceof Promise?t:t(),i=n!==void 0,o,s=r.then(async l=>{if(o=["resolve",l],Y.isValidElement(l))i=!1,this.create({id:n,type:"default",message:l});else if(Ob(l)&&!l.ok){i=!1;let c=typeof e.error=="function"?await e.error(`HTTP error! status: ${l.status}`):e.error,u=typeof e.description=="function"?await e.description(`HTTP error! status: ${l.status}`):e.description;this.create({id:n,type:"error",message:c,description:u})}else if(e.success!==void 0){i=!1;let c=typeof e.success=="function"?await e.success(l):e.success,u=typeof e.description=="function"?await e.description(l):e.description;this.create({id:n,type:"success",message:c,description:u})}}).catch(async l=>{if(o=["reject",l],e.error!==void 0){i=!1;let c=typeof e.error=="function"?await e.error(l):e.error,u=typeof e.description=="function"?await e.description(l):e.description;this.create({id:n,type:"error",message:c,description:u})}}).finally(()=>{var l;i&&(this.dismiss(n),n=void 0),(l=e.finally)==null||l.call(e)}),a=()=>new Promise((l,c)=>s.then(()=>o[0]==="reject"?c(o[1]):l(o[1])).catch(c));
367return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(t,e)=>{let n=(e==null?void 0:e.id)||Wa++;return this.create({jsx:t(n),id:n,...e}),n},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},_t=new Ib,Rb=(t,e)=>{let n=(e==null?void 0:e.id)||Wa++;return _t.addToast({title:t,...e,id:n}),n},Ob=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Pb=Rb,Db=()=>_t.toasts,Lb=()=>_t.getActiveToasts(),Un=Object.assign(Pb,{success:_t.success,info:_t.info,warning:_t.warning,error:_t.error,custom:_t.custom,message:_t.message,promise:_t.promise,dismiss:_t.dismiss,loading:_t.loading},{getHistory:Db,getToasts:Lb});function Bb(t,{insertAt:e}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",e==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}Bb(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;
367left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}
367:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);
367--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} 368`);function Zi(t){return t.label!==void 0}var zb=3,Fb="32px",$b="16px",Qc=4e3,Vb=356,Wb=14,Hb=20,qb=200;function Gt(...t){return t.filter(Boolean).join(" ")}function Ub(t){let[e,n]=t.split("-"),r=[];return e&&r.push(e),n&&r.push(n),r}var Kb=t=>{var e,n,r,i,o,s,a,l,c,u,h;let{invert:p,toast:f,unstyled:m,interacting:g,setHeights:x,visibleToasts:b,heights:E,index:v,toasts:A,expanded:_,removeToast:S,defaultRichColors:N,closeButton:M,style:L,cancelButtonStyle:P,actionButtonStyle:T,className:O="",descriptionClassName:H="",duration:D,position:z,gap:ee,loadingIcon:Q,expandByDefault:F,classNames:V,icons:k,closeButtonAriaLabel:pe="Close toast",pauseWhenPageIsHidden:R}=t,[w,J]=Y.useState(null),[te,B]=Y.useState(null),[X,ne]=Y.useState(!1),[ue,je]=Y.useState(!1),[Le,Ue]=Y.useState(!1),[We,re]=Y.useState(!1),[me,he]=Y.useState(!1),[ae,ke]=Y.useState(0),[Ie,be]=Y.useState(0),Ee=Y.useRef(f.duration||D||Qc),De=Y.useRef(null),G=Y.useRef(null),le=v===0,de=v+1<=b,I=f.type,W=f.dismissible!==!1,ie=f.className||"",fe=f.descriptionClassName||"",ge=Y.useMemo(()=>E.findIndex(ve=>ve.toastId===f.id)||0,[E,f.id]),Me=Y.useMemo(()=>{var ve;return(ve=f.closeButton)!=null?ve:M},[f.closeButton,M]),Dt=Y.useMemo(()=>f.duration||D||Qc,[f.duration,D]),it=Y.useRef(0),ft=Y.useRef(0),fn=Y.useRef(0),He=Y.useRef(null),[Jt,Lt]=z.split("-"),Qr=Y.useMemo(()=>E.reduce((ve,Re,Fe)=>Fe>=ge?ve:ve+Re.height,0),[E,ge]),mr=jb(),Vs=f.invert||p,Xr=I==="loading";ft.current=Y.useMemo(()=>ge*ee+Qr,[ge,Qr]),Y.useEffect(()=>{Ee.current=Dt},[Dt]),Y.useEffect(()=>{ne(!0)},[]),Y.useEffect(()=>{let ve=G.current;if(ve){let Re=ve.getBoundingClientRect().height;return be(Re),x(Fe=>[{toastId:f.id,height:Re,position:f.position},...Fe]),()=>x(Fe=>Fe.filter(Oe=>Oe.toastId!==f.id))}},[x,f.id]),Y.useLayoutEffect(()=>{if(!X)return;let ve=G.current,Re=ve.style.height;ve.style.height="auto";let Fe=ve.getBoundingClientRect().height;ve.style.height=Re,be(Fe),x(Oe=>Oe.find(ot=>ot.toastId===f.id)?Oe.map(ot=>ot.toastId===f.id?{...ot,height:Fe}:ot):[{toastId:f.id,height:Fe,position:f.position},...Oe])},[X,f.title,f.description,x,f.id]);let rn=Y.useCallback(()=>{je(!0),ke(ft.current),x(ve=>ve.filter(Re=>Re.toastId!==f.id)),setTimeout(()=>{S(f)},qb)},[f,S,x,ft]);Y.useEffect(()=>{if(f.promise&&I==="loading"||f.duration===1/0||f.type==="loading")return;let ve;return _||g||R&&mr?(()=>{if(fn.current<it.current){let Re=new Date().getTime()-it.current;Ee.current=Ee.current-Re}
368fn.current=new Date().getTime()})():Ee.current!==1/0&&(it.current=new Date().getTime(),ve=setTimeout(()=>{var Re;(Re=f.onAutoClose)==null||Re.call(f,f),rn()},Ee.current)),()=>clearTimeout(ve)},[_,g,f,I,R,mr,rn]),Y.useEffect(()=>{f.delete&&rn()},[rn,f.delete]);function Ws(){var ve,Re,Fe;return k!=null&&k.loading?Y.createElement("div",{className:Gt(V==null?void 0:V.loader,(ve=f==null?void 0:f.classNames)==null?void 0:ve.loader,"sonner-loader"),"data-visible":I==="loading"},k.loading):Q?Y.createElement("div",{className:Gt(V==null?void 0:V.loader,(Re=f==null?void 0:f.classNames)==null?void 0:Re.loader,"sonner-loader"),"data-visible":I==="loading"},Q):Y.createElement(Eb,{className:Gt(V==null?void 0:V.loader,(Fe=f==null?void 0:f.classNames)==null?void 0:Fe.loader),visible:I==="loading"})}return Y.createElement("li",{tabIndex:0,ref:G,className:Gt(O,ie,V==null?void 0:V.toast,(e=f==null?void 0:f.classNames)==null?void 0:e.toast,V==null?void 0:V.default,V==null?void 0:V[I],(n=f==null?void 0:f.classNames)==null?void 0:n[I]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:N,"data-styled":!(f.jsx||f.unstyled||m),"data-mounted":X,"data-promise":!!f.promise,"data-swiped":me,"data-removed":ue,"data-visible":de,"data-y-position":Jt,"data-x-position":Lt,"data-index":v,"data-front":le,"data-swiping":Le,"data-dismissible":W,"data-type":I,"data-invert":Vs,"data-swipe-out":We,"data-swipe-direction":te,"data-expanded":!!(_||F&&X),style:{"--index":v,"--toasts-before":v,"--z-index":A.length-v,"--offset":`${ue?ae:ft.current}px`,"--initial-height":F?"auto":`${Ie}px`,...L,...f.style},onDragEnd:()=>{Ue(!1),J(null),He.current=null},onPointerDown:ve=>{Xr||!W||(De.current=new Date,ke(ft.current),ve.target.setPointerCapture(ve.pointerId),ve.target.tagName!=="BUTTON"&&(Ue(!0),He.current={x:ve.clientX,y:ve.clientY}))},onPointerUp:()=>{var ve,Re,Fe,Oe;if(We||!W)return;He.current=null;let ot=Number(((ve=G.current)==null?void 0:ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),st=Number(((Re=G.current)==null?void 0:Re.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),pt=new Date().getTime()-((Fe=De.current)==null?void 0:Fe.getTime()),Ze=w==="x"?ot:st,on=Math.abs(Ze)/pt;if(Math.abs(Ze)>=Hb||on>.11){ke(ft.current),(Oe=f.onDismiss)==null||Oe.call(f,f),B(w==="x"?ot>0?"right":"left":st>0?"down":"up"),rn(),re(!0),he(!1);return}Ue(!1),J(null)},onPointerMove:ve=>{var Re,Fe,Oe,ot;if(!He.current||!W||((Re=window.getSelection())==null?void 0:Re.toString().length)>0)return;let st=ve.clientY-He.current.y,pt=ve.clientX-He.current.x,Ze=(Fe=t.swipeDirections)!=null?Fe:Ub(z);!w&&(Math.abs(pt)>1||Math.abs(st)>1)&&J(Math.abs(pt)>Math.abs(st)?"x":"y");let on={x:0,y:0};w==="y"?(Ze.includes("top")||Ze.includes("bottom"))&&(Ze.includes("top")&&st<0||Ze.includes("bottom")&&st>0)&&(on.y=st):w==="x"&&(Ze.includes("left")||Ze.includes("right"))&&(Ze.includes("left")&&pt<0||Ze.includes("right")&&pt>0)&&(on.x=pt),(Math.abs(on.x)>0||Math.abs(on.y)>0)&&he(!0),(Oe=G.current)==null||Oe.style.setProperty("--swipe-amount-x",`${on.x}px`),(ot=G.current)==null||ot.style.setProperty("--swipe-amount-y",`${on.y}px`)}},Me&&!f.jsx?Y.createElement("button",{"aria-label":pe,"data-disabled":Xr,"data-close-button":!0,onClick:Xr||!W?()=>{}:()=>{var ve;rn(),(ve=f.onDismiss)==null||ve.call(f,f)},className:Gt(V==null?void 0:V.closeButton,(i=f==null?void 0:f.classNames)==null?void 0:i.closeButton)},(o=k==null?void 0:k.close)!=null?o:Nb):null,f.jsx||y.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:Y.createElement(Y.Fragment,null,I||f.icon||f.promise?Y.createElement("div",{"data-icon":"",className:Gt(V==null?void 0:V.icon,(s=f==null?void 0:f.classNames)==null?void 0:s.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||Ws():null,f.type!=="loading"?f.icon||(k==null?void 0:k[I])||Sb(I):null):null,Y.createElement("div",{"data-content":"",className:Gt(V==null?void 0:V.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},Y.createElement("div",{"data-title":"",className:Gt(V==null?void 0:V.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?Y.createElement("div",{"data-description":"",className:Gt(H,fe,V==null?void 0:V.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),y.isValidElement(f.cancel)?f.cancel:f.cancel&&Zi(f.cancel)?Y.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||P,onClick:ve=>{var Re,Fe;Zi(f.cancel)&&W&&((Fe=(Re=f.cancel).onClick)==null||Fe.call(Re,ve),rn())},className:Gt(V==null?void 0:V.cancelButton,(u=f==null?void 0:f.classNames)==null?void 0:u.cancelButton)},f.cancel.label):null,y.isValidElement(f.action)?f.action:f.action&&Zi(f.action)?Y.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||T,onClick:ve=>{var Re,Fe;Zi(f.action)&&((Fe=(Re=f.action).onClick)==null||Fe.call(Re,ve),!ve.defaultPrevented&&rn())},className:Gt(V==null?void 0:V.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function Xc(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function Yb(t,e){let n={};return[t,e].forEach((r,i)=>{let o=i===1,s=o?"--mobile-offset":"--offset",a=o?$b:Fb;function l(c){["top","right","bottom","left"].forEach(u=>{n[`${s}-${u}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${s}-${c}`]=a:n[`${s}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var Jb=y.forwardRef(function(t,e){let{invert:n,position:r="bottom-right",hotkey:i=["altKey","KeyT"],expand:o,closeButton:s,className:a,offset:l,mobileOffset:c,theme:u="light",richColors:h,duration:p,style:f,visibleToasts:m=zb,toastOptions:g,dir:x=Xc(),gap:b=Wb,loadingIcon:E,icons:v,containerAriaLabel:A="Notifications",pauseWhenPageIsHidden:_}=t,[S,N]=Y.useState([]),M=Y.useMemo(()=>Array.from(new Set([r].concat(S.filter(R=>R.position).map(R=>R.position)))),[S,r]),[L,P]=Y.useState([]),[T,O]=Y.useState(!1),[H,D]=Y.useState(!1),[z,ee]=Y.useState(u!=="system"?u:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dar
368k":"light"),Q=Y.useRef(null),F=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),V=Y.useRef(null),k=Y.useRef(!1),pe=Y.useCallback(R=>{N(w=>{var J;return(J=w.find(te=>te.id===R.id))!=null&&J.delete||_t.dismiss(R.id),w.filter(({id:te})=>te!==R.id)})},[]);return Y.useEffect(()=>_t.subscribe(R=>{if(R.dismiss){N(w=>w.map(J=>J.id===R.id?{...J,delete:!0}:J));return}setTimeout(()=>{cf.flushSync(()=>{N(w=>{let J=w.findIndex(te=>te.id===R.id);return J!==-1?[...w.slice(0,J),{...w[J],...R},...w.slice(J+1)]:[R,...w]})})})}),[]),Y.useEffect(()=>{if(u!=="system"){ee(u);return}if(u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ee("dark"):ee("light")),typeof window>"u")return;let R=window.matchMedia("(prefers-color-scheme: dark)");try{R.addEventListener("change",({matches:w})=>{ee(w?"dark":"light")})}catch{R.addListener(({matches:J})=>{try{ee(J?"dark":"light")}catch(te){console.error(te)}})}},[u]),Y.useEffect(()=>{S.length<=1&&O(!1)},[S]),Y.useEffect(()=>{let R=w=>{var J,te;i.every(B=>w[B]||w.code===B)&&(O(!0),(J=Q.current)==null||J.focus()),w.code==="Escape"&&(document.activeElement===Q.current||(te=Q.current)!=null&&te.contains(document.activeElement))&&O(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[i]),Y.useEffect(()=>{if(Q.current)return()=>{V.current&&(V.current.focus({preventScroll:!0}),V.current=null,k.current=!1)}},[Q.current]),Y.createElement("section",{ref:e,"aria-label":`${A} ${F}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((R,w)=>{var J;let[te,B]=R.split("-");return S.length?Y.createElement("ol",{key:R,dir:x==="auto"?Xc():x,tabIndex:-1,ref:Q,className:a,"data-sonner-toaster":!0,"data-theme":z,"data-y-position":te,"data-lifted":T&&S.length>1&&!o,"data-x-position":B,style:{"--front-toast-height":`${((J=L[0])==null?void 0:J.height)||0}px`,"--width":`${Vb}px`,"--gap":`${b}px`,...f,...Yb(l,c)},onBlur:X=>{k.current&&!X.currentTarget.contains(X.relatedTarget)&&(k.current=!1,V.current&&(V.current.focus({preventScroll:!0}),V.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||k.current||(k.current=!0,V.current=X.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{H||O(!1)},onDragEnd:()=>O(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||D(!0)},onPointerUp:()=>D(!1)},S.filter(X=>!X.position&&w===0||X.position===R).map((X,ne)=>{var ue,je;return Y.createElement(Kb,{key:X.id,icons:v,index:ne,toast:X,defaultRichColors:h,duration:(ue=g==null?void 0:g.duration)!=null?ue:p,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:m,closeButton:(je=g==null?void 0:g.closeButton)!=null?je:s,interacting:H,position:R,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:pe,toasts:S.filter(Le=>Le.position==X.position),heights:L.filter(Le=>Le.position==X.position),setHeights:P,expandByDefault:o,gap:b,loadingIcon:E,expanded:T,pauseWhenPageIsHidden:_,swipeDirections:t.swipeDirections})})):null}))});const Gb=({...t})=>{const{theme:e="system"}=kb();return d.jsx(Jb,{theme:e,className:"toaster group",position:"top-right",duration:2e3,toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})};var[ds,LO]=Ny("Tooltip",[Yh]),hs=Yh(),Lf="TooltipProvider",Qb=700,Ha="tooltip.open",[Xb,Wl]=ds(Lf),Bf=t=>{const{__scopeTooltip:e,delayDuration:n=Qb,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:o}=t,s=y.useRef(!0),a=y.useRef(!1),l=y.useRef(0);return y.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),d.jsx(Xb,{scope:e,isOpenDelayedRef:s,delayDuration:n,onOpen:y.useCallback(()=>{window.clearTimeout(l.current),s.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:y.useCallback(c=>{a.current=c}
vendor: 6,876 bytes, line 368
368,[]),disableHoverableContent:i,children:o})};Bf.displayName=Lf;var _i="Tooltip",[Zb,Hi]=ds(_i),zf=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i,onOpenChange:o,disableHoverableContent:s,delayDuration:a}=t,l=Wl(_i,t.__scopeTooltip),c=hs(e),[u,h]=y.useState(null),p=er(),f=y.useRef(0),m=s??l.disableHoverableContent,g=a??l.delayDuration,x=y.useRef(!1),[b,E]=By({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(Ha))):l.onClose(),o==null||o(N)},caller:_i}),v=y.useMemo(()=>b?x.current?"delayed-open":"instant-open":"closed",[b]),A=y.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,E(!0)},[E]),_=y.useCallback(()=>{window.clearTimeout(f.current),f.current=0,E(!1)},[E]),S=y.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,E(!0),f.current=0},g)},[g,E]);return y.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),d.jsx(zy,{...c,children:d.jsx(Zb,{scope:e,contentId:p,open:b,stateAttribute:v,trigger:u,onTriggerChange:h,onTriggerEnter:y.useCallback(()=>{l.isOpenDelayedRef.current?S():A()},[l.isOpenDelayedRef,S,A]),onTriggerLeave:y.useCallback(()=>{m?_():(window.clearTimeout(f.current),f.current=0)},[_,m]),onOpen:A,onClose:_,disableHoverableContent:m,children:n})})};zf.displayName=_i;var qa="TooltipTrigger",Ff=y.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Hi(qa,n),o=Wl(qa,n),s=hs(n),a=y.useRef(null),l=Jh(e,a,i.onTriggerChange),c=y.useRef(!1),u=y.useRef(!1),h=y.useCallback(()=>c.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),d.jsx(jy,{asChild:!0,...s,children:d.jsx(wn.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:gr(t.onPointerMove,p=>{p.pointerType!=="touch"&&!u.current&&!o.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:gr(t.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:gr(t.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:gr(t.onFocus,()=>{c.current||i.onOpen()}),onBlur:gr(t.onBlur,i.onClose),onClick:gr(t.onClick,i.onClose)})})});Ff.displayName=qa;var Hl="TooltipPortal",[e0,t0]=ds(Hl,{forceMount:void 0}),$f=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:i}=t,o=Hi(Hl,e);return d.jsx(e0,{scope:e,forceMount:n,children:d.jsx(Gh,{present:n||o.open,children:d.jsx(Dy,{asChild:!0,container:i,children:r})})})};$f.displayName=Hl;var Br="TooltipContent",Vf=y.forwardRef((t,e)=>{const n=t0(Br,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=t,s=Hi(Br,t.__scopeTooltip);return d.jsx(Gh,{present:r||s.open,children:s.disableHoverableContent?d.jsx(Wf,{side:i,...o,ref:e}):d.jsx(n0,{side:i,...o,ref:e})})}),n0=y.forwardRef((t,e)=>{const n=Hi(Br,t.__scopeTooltip),r=Wl(Br,t.__scopeTooltip),i=y.useRef(null),o=Jh(e,i),[s,a]=y.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:h}=r,p=y.useCallback(()=>{a(null),h(!1)},[h]),f=y.useCallback((m,g)=>{const x=m.currentTarget,b={x:m.clientX,y:m.clientY},E=a0(b,x.getBoundingClientRect()),v=l0(b,E),A=c0(g.getBoundingClientRect()),_=d0([...v,...A]);a(_),h(!0)},[h]);return y.useEffect(()=>()=>p(),[p]),y.useEffect(()=>{if(l&&u){const m=x=>f(x,u),g=x=>f(x,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",g)}}},[l,u,f,p]),y.useEffect(()=>{if(s){const m=g=>{const x=g.target,b={x:g.clientX,y:g.clientY},E=(l==null?void 0:l.contains(x))||(u==null?void 0:u.contains(x)),v=!u0(b,s);E?p():v&&(p(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,s,c,p]),d.jsx(Wf,{...t,ref:o})}),[r0,i0]=ds(_i,{isInside:!1}),o0=Ly("TooltipContent"),Wf=y.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:o,onPointerDownOutside:s,...a}=t,l=Hi(Br,n),c=hs(n),{onClose:u}=l;return y.useEffect(()=>(document.addEventListener(Ha,u),()=>document.removeEventListener(Ha,u)),[u]),y.useEffect(()=>{if(l.trigger){const h=p=>{const f=p.target;f!=null&&f.contains(l.trigger)&&u()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,u]),d.jsx(Iy,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:u,children:d.jsxs(Ry,{"data-state":l.stateAttribute,...c,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[d.jsx(o0,{children:r}),d.jsx(r0,{scope:n,isInside:!0,children:d.jsx(Oy,{id:l.contentId,role:"tooltip",children:i||r})})]})})});Vf.displayName=Br;var Hf="TooltipArrow",s0=y.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=hs(n);return i0(Hf,n).isInside?null:d.jsx(Py,{...i,...r,ref:e})});s0.displayName=Hf;function a0(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),o=Math.abs(e.left-t.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function l0(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function c0(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function u0(t,e){const{x:n,y:r}=t;let i=!1;for(let o=0,s=e.length-1;o<e.length;s=o++){const a=e[o],l=e[s],c=a.x,u=a.y,h=l.x,p=l.y;u>r!=p>r&&n<(h-c)*(r-u)/(p-u)+c&&(i=!i)}return i}function d0(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),h0(e)}function h0(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const o=e[e.length-1],s=e[e.length-2];if((o.x-s.x)*(i.y-s.y)>=(o.y-s.y)*(i.x-s.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const o=n[n.length-1],s=n[n.length-2];if((o.x-s.x)*(i.y-s.y)>=(o.y-s.y)*(i.x-s.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var f0=Bf,p0=zf,m0=Ff,g0=$f,qf=Vf;const Uf=f0,y0=p0,x0=m0,Kf=y.forwardRef(({className:t,sideOffset:e=4,...n},r)=>
368d.jsx(g0,{children:d.jsx(qf,{ref:r,sideOffset:e,collisionPadding:8,className:Ne("z-[9999] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));Kf.displayName=qf.displayName;const Ua=new Zy({defaultOptions:{queries:{staleTime:5*60*1e3,gcTime:30*60*1e3,refetchOnWindowFocus:!1,retry:1}}}),Xe={uiTheme:"ui-theme",lastSelectedBot:"lastSelectedBot",projectsSortPreference:"projects_sort_preference",courseSidebarCollapsed:"course-sidebar-collapsed",thumbnailBoardNavCollapsed:"thumbnailBoardNavCollapsed",researchGuideDismissed:"research_guide_dismissed",adminView:"storyos-admin-view",reviewPromptDismissed:"review_prompt_dismissed",useNewPlanner:"use-new-planner",stagingAdminBypass:"staging_admin_bypass",accountLocked:"account_locked",youtubeOAuthState:"youtube_oauth_state",youtubeOAuthDebug:"youtube_oauth_debug",plannerSessionId:"planner_session_id",analyticsSessionRowId:"analytics_session_row_id",analyticsSessionStartedAt:"analytics_session_started_at",analyticsSessionUserId:"analytics_session_user_id"},BO={checklist:t=>`checklist-${t}`,lessonAccordion:t=>`lesson-accordion-${t}`,quizProgress:t=>`quiz-progress-${t}`,wistiaPosition:t=>`wistia-pos-${t}`,lastLesson:t=>`course-last-lesson-${t}`},So=t=>typeof window>"u"?null:t==="session"?window.sessionStorage:window.localStorage,b0=(t,e)=>[t,...e||[]],Us=(t,e={})=>{const{scope:n="local",legacyKeys:r}=e,i=So(n);if(!i)return null;for(const o of b0(t,r))try{const s=i.getItem(o);if(s!==null)return{key:o,value:s}}catch(s){return console.warn(`Failed to read storage key "${o}"`,s),null}return null},xe={getString(t,e={}){const{scope:n="local",fallback:r=null,legacyKeys:i}=e,o=Us(t,{scope:n,legacyKeys:i,fallback:r});return(o==null?void 0:o.value)??r},getJSON(t,e={}){const{fallback:n=null,scope:r="local",legacyKeys:i}=e,o=Us(t,{scope:r,legacyKeys:i,fallback:null});if(!o)return n;try{return JSON.parse(o.value)}catch(s){return console.warn(`Failed to parse storage key "${o.key}"`,s),xe.remove(o.key,{scope:r}),n}},setString(t,e,n={}){const{scope:r="local"}=n,i=So(r);if(!i)return!1;try{return i.setItem(t,e),!0}catch(o){return console.warn(`Failed to write storage key "${t}"`,o),!1}},setJSON(t,e,n={}){try{return xe.setString(t,JSON.stringify(e),n)}catch(r){return console.warn(`Failed to serialize storage key "${t}"`,r),!1}},remove(t,e={}){const{scope:n="local"}=e,r=So(n);if(!r)return!1;try{return r.removeItem(t),!0}catch(i){return console.warn(`Failed to remove storage key "${t}"`,i),!1}},migrateLegacyKey(t,e,n={}){const{scope:r="local"}=n,i=So(r);if(!i)return null;const o=Us(t,{scope:r,fallback:null,legacyKeys:e});return o?(i.getItem(t)===null&&xe.setString(t,o.value,{scope:r}),o.value):null}},w0={theme:"system",setTheme:()=>null},Yf=y.createContext(w0);function v0({children:t,defaultTheme:e="system",storageKey:n="ui-theme",...r}){const[i,o]=y.useState(()=>xe.getString(n)||e);y.useEffect(()=>{const a=window.document.documentElement;if(a.classList.remove("light","dark"),i==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";a.classList.add(l);return}a.classList.add(i)},[i]);const s={theme:i,setTheme:a=>{xe.setString(n,a),o(a)}};return d.jsx(Yf.Provider,{...r,value:s,children:t})}const zO=()=>{const t=y.useContext(Yf);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t},k0={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_HOTJAR_SITE_ID:"6678280",VITE_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImFndmJ1aWNwbHVsdnNsdnhscmVkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTkxMjkyNTQsImV4cCI6MjA3NDcwNTI1NH0.ZUKZOwBMW3qGGcj2Tsjh_ySy9LZ-JWobZgK03iZWMtY",VITE_SUPABASE_PROJECT_ID:"agvbuicplulvslvxlred",VITE_SUPABASE_PUBLISHABLE_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImFndmJ1aWNwbHVsdnNsdnhscmVkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTkxMjkyNTQsImV4cCI6MjA3NDcwNTI1NH0.ZUKZOwBMW3qGGcj2Tsjh_ySy9LZ-JWobZgK03iZWMtY",VITE_SUPABASE_URL:"https://agvbuicplulvslvxlred.supabase.co"},S0="https://afsmcwwfkskormisqxam.supabase.co",C0="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImFmc21jd3dma3Nrb3JtaXNxeGFtIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2MTgwNDQsImV4cCI6MjA5MDE5NDA0NH0.AA1r_C-WcI2L28ZRvvw93kXIb8HwQ5Z4HkB5r07dgV0",E0=t=>{const e=k0[t],n=e==null?void 0:e.trim();if(!(!n||n==="undefined"||n==="null"))return n},T0=()=>
368{if(typeof window>"u")return!1;const t=window.location.hostname;return t.endsWith(".lovable.app")||t.endsWith(".lovableproject.com")},Zc=(t,e)=>{for(const n of t){const r=E0(n);if(r)return r}if(T0())return e;throw new Error(`Missing required Supabase environment variable. Expected one of: ${t.join(", ")}`)},Kr={URL:Zc(["VITE_SUPABASE_URL"],S0),ANON_KEY:Zc(["VITE_SUPABASE_ANON_KEY","VITE_SUPABASE_PUBLISHABLE_KEY"],C0)},eu="telemetry_session_id",ql=()=>{if(typeof window>"u")return null;const t=xe.getString(eu,{scope:"session"});if(t)return t;const e=crypto.randomUUID();return xe.setString(eu,e,{scope:"session"}),e},_0=[[/failed to send a request to the edge function/i,"We couldn't reach the server. Check your internet connection and try again."],[/relay error invoking the edge function/i,"Something went wrong on our side. Please try again."],[/edge function returned a non-2xx status code/i,"Something went wrong. Please try again."]],A0=t=>{if(!(!(t instanceof Error)||typeof t.message!="string")){for(const[e,n]of _0)if(e.test(t.message)){t.internalMessage=t.message,t.message=n;return}}},M0=t=>{const e=t==null?void 0:t.internalMessage;return typeof e=="string"&&e.trim()?e:t instanceof Error&&t.message.trim()||typeof t=="object"&&t!==null&&"message"in t&&typeof t.message=="string"&&t.message.trim()?t.message:"Supabase edge function returned a non-2xx status"},N0=t=>{if(typeof t!="object"||t===null||!("context"in t))return null;const e=t.context;return typeof e!="object"||e===null||!("status"in e)?null:typeof e.status=="number"?e.status:null};async function j0(t,e,n){try{const{data:{user:r}}=await t.auth.getUser();if(!r)return;await t.from("user_events").insert({user_id:r.id,event_type:"error",event_name:"SupabaseFunctionError",event_data:{appVersion:xe.getString("app_version"),isDirectInvoke:!0,message:M0(n),operationName:e,route:typeof window<"u"?window.location.pathname:null,source:"edge-function",stack:n instanceof Error?n.stack:void 0,status:N0(n),telemetrySessionId:ql(),timestamp:new Date().toISOString(),userAgent:typeof navigator<"u"?navigator.userAgent:null}})}catch(r){console.error("Failed to report edge function invoke error:",r)}}function I0(t){const e=t.functions.invoke.bind(t.functions);return t.functions.invoke=async(n,r)=>{const i=await e(n,r);return i.error&&(A0(i.error),j0(t,n,i.error)),i},t}function R0(){var x,b;if(typeof window>"u")return;const t=location.hostname,n=["lovableproject.com","lovableproject-dev.com","lovable.app","gpt-eng.com","gptengineer.run"].some(E=>t===E||t.endsWith("."+E)),r="[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}",i=n?((x=t.match(new RegExp("^(?:id-preview(?:-[a-z0-9]+)?|project)--("+r+")(?:-dev)?(?=\\.|$)","i")))==null?void 0:x[1])??((b=t.match(new RegExp("^("+r+")(?=[.-])","i")))==null?void 0:b[1]):void 0,o=window.parent&&window.parent!==window;if(!i||!o)return localStorage;const s=t.endsWith(".lovableproject-dev.com")||t.endsWith(".gpt-eng.com"),a=s?/^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$|^http:\/\/localhost:3000$/:/^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$/,l=location.ancestorOrigins&&location.ancestorOrigins[0]||(document.referrer?new URL(document.referrer).origin:""),c=l&&a.test(l)?[l]:s?["https://lovable.dev","http://localhost:3000"]:["https://lovable.dev"],u="lovable-preview-auth:result",h=2e3,p=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),f=(E,v,A)=>new Promise(_=>{const S=p();let N=!1,M;const L=O=>{N||(N=!0,clearTimeout(M),window.removeEventListener("message",P),_(O))},P=O=>{if(c.indexOf(O.origin)<0)return;const H=O.data;H&&H.type===u&&H.requestId===S&&L(H)};window.addEventListener("message",P);const T={type:E,requestId:S,projectId:i,key:v};A!==void 0&&(T.value=A);for(const O of c)window.parent.postMessage(T,O);M=setTimeout(()=>L(null),h)});let m=!0;const g=250;return{getItem:async E=>{let v=await f("lovable-preview-auth:get",E);return!v&&m&&(await new Promise(A=>setTimeout(A,g)),v=await f("lovable-preview-auth:get",E)),m=!1,v&&v.ok&&typeof v.value=="string"?v.value===""?(localStorage.removeItem(E),null):v.value:localStorage.getItem(E)},setItem:(E,v)=>(localStorage.setItem(E,v),f("lovable-preview-auth:set",E,v).then(A=>{A&&A.ok&&typeof A.value=="string"&&localStorage.getItem(E)===v&&(A.value===""?localStorage.removeItem(E):localStorage.setItem(E,A.value))})),removeItem:E=>(localStorage.removeItem(E),f("lovable-preview-auth:remove",E).then(()=>{}))}}const O0=Kr.URL,P0=Kr.ANON_KEY,D0=async(t,e,n)=>{var s;if(typeof navigator>"u"||!((s=navigator==null?void 0:navigator.locks)!=null&&s.request))return n();const r=new AbortController,i=Number.isFinite(e)?Math.max(e,3e4):3e4,o=setTimeout(()=>r.abort(),i);try{return await navigator.locks.request(t,{signal:r.signal},async()=>
368(clearTimeout(o),n()))}catch(a){if(clearTimeout(o),(a==null?void 0:a.name)==="AbortError")return console.warn(`[Auth] Lock "${t}" timed out after ${i}ms â proceeding without lock`),n();throw a}},j=I0(ex(O0,P0,{auth:{storage:R0(),persistSession:!0,autoRefreshToken:!0,lock:D0}})),Fo=`${Kr.URL}/functions/v1`,Rt={adminAccessConfig:"admin-access-config",adminSetAccessLevel:"admin-set-access-level",affiliateCreate:"affiliate-create",analyzeAdjacentNiche:"analyze-adjacent-niche",analyzeChannelInsights:"analyze-channel-insights",analyzeContentStrategy:"analyze-content-strategy",analyzeMultiChannel:"analyze-multi-channel",analyzeSupportTickets:"analyze-support-tickets",analyzeThumbnails:"analyze-thumbnails",appHelpBot:"app-help-bot",auditOwnChannel:"audit-own-channel",bulkUnbanUsers:"bulk-unban-users",chatWithAssistant:"chat-with-assistant",chatWithAssistantStream:"chat-with-assistant-stream",checkAdminRole:"check-admin-role",adminAiEnforcement:"admin-ai-enforcement",adminBackfillBilling:"admin-backfill-billing",checkKartraTags:"check-kartra-tags",checkUserAccess:"check-user-access",cogBotChat:"cog-bot-chat",cogBotRefine:"cog-bot-refine",createCheckout:"create-checkout",createUpgradeCheckout:"create-upgrade-checkout",createCreditsCheckout:"create-credits-checkout",customerPortal:"customer-portal",detectMilestones:"detect-milestones",diagnoseVideo:"diagnose-video",emailBot2:"email-bot-2",enhancedGuardrailsChat:"enhanced-guardrails-chat",expectationCheck:"expectation-check",fetchChannelOutliers:"fetch-channel-outliers",fetchYoutubeChannel:"fetch-youtube-channel",fetchYoutubeMetadata:"fetch-youtube-metadata",fetchYoutubeVideoData:"fetch-youtube-video-data",funnelAuditChannel:"funnel-audit-channel",funnelAuditWriter:"funnel-audit-writer",generateAdjacentTitleIdeas:"generate-adjacent-title-ideas",generateTitleIdeas:"generate-title-ideas",generateTrendReport:"generate-trend-report",generateVideoVariation:"generate-video-variation",getBrainContext:"get-brain-context",getCheckoutSessionEmail:"get-checkout-session-email",getCourseContent:"get-course-content",getCourseKnowledgeBase:"get-course-knowledge-base",getPublicSettings:"get-public-settings",getGoogleClientId:"get-google-client-id",getLessonContent:"get-lesson-content",getUserSessionsAdmin:"get-user-sessions-admin",getVideoInsights:"get-video-insights",guardrailsChat:"guardrails-chat",introBotV2Chat:"intro-bot-2-chat",guardrailsV2:"guardrails-v2",kartraSyncEntitlements:"kartra-sync-entitlements",liveReviewTopics:"live-review-topics",kartraWebhook:"kartra-webhook",listUsersAdmin:"list-users-admin",plannerAssistant:"planner-assistant",plannerChat:"planner-chat",planningCoach2:"planning-coach-2",pointBotChat:"point-bot-chat",pointBotFeedback:"point-bot-feedback",pointBotRewriteChat:"point-bot-rewrite-chat",salesBot:"sales-bot",researchIdeationChat:"research-ideation-chat",scrapeSalesPage:"scrape-sales-page",sendResetCode:"send-reset-code",setUserPassword:"set-user-password",signupWithAccessCheck:"signup-with-access-check",freeSignup:"free-signup",skyscraperChat:"skyscraper-chat",thumbnailFeedbackChat:"thumbnail-feedback-chat",tidyNotes:"tidy-notes",uploadCourseContent:"upload-course-content",validateUpload:"validate-upload",verifyResetCode:"verify-reset-code",videoLessonChat:"video-lesson-chat",wistiaExportProjectVideos:"wistia-export-project-videos",wistiaFetchVideoMetadata:"wistia-fetch-video-metadata",wistiaSyncCourseVideos:"wistia-sync-course-videos",wistiaTestConnection:"wistia-test-connection",youtubeAudienceWarmth:"youtube-audience-warmth",youtubeChannelStats:"youtube-channel-stats",youtubeContentBlueprint:"youtube-content-blueprint",youtubeDataCleanup:"youtube-data-cleanup",youtubeDisconnect:"youtube-disconnect",youtubeGetConnection:"youtube-get-connection",youtubeOauthCallback:"youtube-oauth-callback",youtubeReporting:"youtube-reporting",youtubeReportingSync:"youtube-reporting-sync",unifiedChat:"unified-chat"},Jf=t=>`${Fo}/${t}`,L0=()=>({appVersion:xe.getString("app_version"),route:typeof window<"u"?window.location.pathname:null,telemetrySessionId:ql(),userAgent:typeof navigator<"u"?navigator.userAgent:null}),B0=t=>t instanceof Error&&t.message?t.message:typeof t=="string"&&t.trim()?t:"Unknown Supabase error",Ge=async(t,e)=>{try{const{data:{user:n}}=await j.auth.getUser();if(!n)return;const r=L0(),i=t instanceof Error?t:void 0;await j.from("user_events").insert({user_id:n.id,event_type:"error",event_name:e.eventName,request_id:e.requestId??null,event_data:{message:B0(t),stack:i==null?void 0:i.stack,source:e.source,operationName:e.operationName??null,...r,...e.metadata??{},timestamp:new Date().toISOString()}})}catch(n){console.error("Failed to report client error:",n)}},Ka=Kr.ANON_KEY;async function z0(t){var f,m,g,x,b,E;const{functionName:e,body:n={},onChunk:r,onComplete:i,onError:o,timeoutMs:s=12e4,retryAttempts:a=2,noAuth:l=!1,signal:c}=t;let u=null,h=null;for(let v=0;v<a;v++){let A=!1;const _=new AbortController,S=setTimeout(()=>_.abort(),s),N=()=>_.abort();c==null||c.addEventListener("abort",N);try{let M;if(!l){const{data:Q}=await j.auth.getSession();if(M=(f=Q==null?void 0:Q.session)==null?void 0:f.access_token,!M&&(await new Promise(V=>setTimeout(V,500)),M=(g=(m=(await j.auth.getSession()).data)==null?void 0:m.session)==null?void 0:g.access_token,!M))throw new Error("Not authenticated. Please log in and try again.")}const L=await fetch(`${Fo}/${e}`,{method:"POST",headers:{"Content-Type":"application/json",apikey:Ka,...M?{Authorization:`Bearer ${M}`}:{}},body:JSON.stringify(n),signal:_.signal});if(h=L.headers.get("X-Request-Id")??h,clearTimeout(S),!L.ok){const Q=await L.text();let F="Request failed";try{const V=JSON.parse(Q);F=V.error||V.message||Q}catch{F=Q||`HTTP ${L.status}`}if(L.status===429){const V=new Error(F||"The server is busy right now. Please wait a moment and try again.");throw V.status=429,V}if(L.status===402){const V=new Error(F||"Usage limit reached. Please try again later.");throw V.status=402,V}throw new Error(F)}if(!(L.headers.get("content-type")||"").includes("text/event-stream")){const Q=await L.text();if(!Q.trim())throw new Error("Empty response from server");let F=null,V=!1;try{F=JSON.parse(Q),V=!0}catch{r(Q)}if(V&&F!==null){if((F==null?void 0:F.fallback)===!0||F!=null&&F.error&&!(F!=null&&F.content)&&!(F!=null&&F.message)&&!(F!=null&&F.text))throw new Error(typeof F.error=="string"?F.error:"An error occurred. Please try again.");const k=(typeof F=="string"?F:void 0)||(F==null?void 0:F.content)||(F==null?void 0:F.message)||(F==null?void 0:F.text)||(F==null?void 0:F.response)||((x=F==null?void 0:F.data)==null?void 0:x.content);r(typeof k=="string"?k:JSON.stringify(F))}i==null||i();return}const T=(b=L.body)==null?void 0:b.getReader();if(!T)throw new Error("No response stream available");const O=new TextDecoder;let H="",D=!1,z=!0;const ee=Q=>{var k,pe,R;let F=Q;if(F.endsWith("\r")&&(F=F.slice(0,-1)),F.startsWith(":")||F.trim()===""||!(F.startsWith("data: ")||F.startsWith("data:")))return!0;const V=F.startsWith("data: ")?F.slice(6).trim():F.slice(5).trim();if(V==="[DONE]")return!0;try{const w=JSON.parse(V);z&&(console.log("[invokeStream] First SSE chunk format:",JSON.stringify(w).slice(0,300)),z=!1);const J=(R=(pe=(k=w.choices)==null?void 0:k[0])==null?void 0:pe.delta)==null?void 0:R.content;return J?(D=!0,A=!0,r(J),!0):(w.chunk&&!w.done&&(D=!0,A=!0,r(w.chunk)),!0)}catch{return!1}};for(;;){const{done:Q,value:F}=await T.read();if(Q)break;H+=O.decode(F,{stream:!0});let V;for(;(V=H.indexOf(` 369`))!==-1;){const k=H.slice(0,V);if(H=H.slice(V+1),!ee(k)){H=k+` 370`+H;break}}}if(H.trim()){const Q=H.split(` 371`);for(const F of Q){if(!F)continue;if(!ee(F))break}}if(!D)throw new Error("Empty stream (no content received)");i==null||i();return}
371catch(M){if(clearTimeout(S),c==null||c.removeEventListener("abort",N),u=M,(M==null?void 0:M.name)==="AbortError"){c!=null&&c.aborted?u=M:u=new Error("Request timed out. Please check your connection and try again.");break}if((E=M==null?void 0:M.message)!=null&&E.includes("Not authenticated")||(M==null?void 0:M.status)===429||(M==null?void 0:M.status)===402||A)break;if(v<a-1){const L=Math.min(1e3*Math.pow(2,v),8e3);console.log(`Stream attempt ${v+1} failed, retrying in ${L}ms...`),await new Promise(P=>setTimeout(P,L))}}}const p=u||new Error("Request failed after retries");(p==null?void 0:p.name)!=="AbortError"&&Ge(p,{eventName:"EdgeFunctionStreamError",source:"edge-function",operationName:e,requestId:h,metadata:{feature:"invokeStream",attempts:a,status:p==null?void 0:p.status}}),o==null||o(p)}async function fs(t,e,n){var c,u;const r=(n==null?void 0:n.timeoutMs)??6e4,i=(n==null?void 0:n.reportErrors)!==!1;let o=null;const s=(h,p,f=!1)=>{!i||p===401||Ge(h,{eventName:"EdgeFunctionInvokeError",source:"edge-function",operationName:t,requestId:o,metadata:{feature:"invokeWithDetails",status:p,isTimeout:f}})},a=new AbortController,l=setTimeout(()=>a.abort(),r);try{let h=await j.auth.getSession();if(!h.data.session&&!(n!=null&&n.noAuth)&&(await new Promise(E=>setTimeout(E,500)),h=await j.auth.getSession(),!h.data.session))return{ok:!1,errorMessage:"Session not available. Please refresh the page.",requestId:o};const p=n!=null&&n.noAuth||(c=h.data.session)==null?void 0:c.access_token,f=await fetch(`${Fo}/${t}`,{method:"POST",headers:{"Content-Type":"application/json",apikey:Ka,...p?{Authorization:`Bearer ${p}`}:{}},body:JSON.stringify(e??{}),signal:a.signal});o=f.headers.get("X-Request-Id")??o;const m=f.status,g=await f.text();let x;try{x=g?JSON.parse(g):void 0}catch{}if(f.ok)return{ok:!0,data:x??void 0,status:m,requestId:o};if(m===401&&!(n!=null&&n.noAuth)){const{data:E}=await j.auth.refreshSession(),v=(u=E==null?void 0:E.session)==null?void 0:u.access_token;if(v){const A=await fetch(`${Fo}/${t}`,{method:"POST",headers:{"Content-Type":"application/json",apikey:Ka,Authorization:`Bearer ${v}`},body:JSON.stringify(e??{}),signal:a.signal});o=A.headers.get("X-Request-Id")??o;const _=await A.text();let S;try{S=_?JSON.parse(_):void 0}catch{}if(A.ok)return{ok:!0,data:S??void 0,status:A.status,requestId:o};const N=S&&(S.error||S.message)||_||"Request failed",M=A.status===401?"Your session expired, please refresh the page and sign in again.":N;return s(new Error(M),A.status),{ok:!1,errorMessage:M,status:A.status,data:S??null,requestId:o}}return{ok:!1,errorMessage:"Your session expired, please refresh the page and sign in again.",status:401,requestId:o}}const b=x&&(x.error||x.message)||g||"Request failed";return s(new Error(b),m),{ok:!1,errorMessage:b,status:m,data:x??null,requestId:o}}catch(h){if((h==null?void 0:h.name)==="AbortError"){const p=new Error(`${t} timed out after ${r}ms`);return s(p,void 0,!0),{ok:!1,errorMessage:"Request timed out. Please check your connection.",isTimeout:!0,requestId:o}}return s(h,h==null?void 0:h.status),{ok:!1,errorMessage:(h==null?void 0:h.message)||"Request failed",requestId:o}}finally{clearTimeout(l)}}class ps extends Error{constructor(n,r,i,o){super(n);vn(this,"source");vn(this,"operationName");vn(this,"metadata");this.name="AppSupabaseError",this.source=r,this.operationName=i,this.metadata=o}}const FO=async(t,e,n={})=>{const{data:r,error:i}=await j.rpc(t,e??{});if(i)throw n.skipErrorLogging||await Ge(i,{eventName:"SupabaseRpcError",source:"rpc",operationName:t,metadata:n.metadata}),new ps(i.message,"rpc",t,n.metadata);return r},Gf=async(t,e,n,r,i)=>{if(!n)return{ok:!0,data:e};const o=n.safeParse(e);if(o.success)return{ok:!0,data:o.data};const s=new ps(`Unexpected response shape from ${t}`,"edge-function",t,{validation:o.error.issues,...r??{}});return i||await Ge(s,{eventName:"SupabaseFunctionValidationError",source:"edge-function",operationName:t,metadata:{issues:o.error.issues,...r??{}}}),{ok:!1,error:s}},zn=async(t,e,n={})=>{const r=await fs(t,e,{noAuth:n.noAuth,timeoutMs:n.timeoutMs,reportErrors:!1});if(r.ok){const s=await Gf(t,r.data,n.schema,n.metadata,n.skipErrorLogging);if(!s.ok)throw s.error;return s.data}const i=r,o=new ps(i.errorMessage,"edge-function",t,{status:i.status,isTimeout:i.isTimeout??!1,...n.metadata??{}});throw n.skipErrorLogging||await Ge(o,{eventName:"SupabaseFunctionError",source:"edge-function",operationName:t,requestId:r.requestId,metadata:{status:i.status,isTimeout:i.isTimeout??!1,...n.metadata??{}}}),o},qi=async(t,e,n={})=>{const r=await fs(t,e,{timeoutMs:n.timeoutMs,reportErrors:!n.skipErrorLogging});if(r.ok){if(n.schema&&r.data!=null){const s=await Gf(t,r.data,n.schema,n.metadata,n.skipErrorLogging);return s.ok?{data:s.data,error:null}:{data:null,error:s.error}}return{data:r.data??null,error:null}}const i=r,o=new ps(i.errorMessage,"edge-function",t,{status:i.status,isTimeout:i.isTimeout??!1,...n.metadata??{}});return{data:i.data??null,error:o}};function $o(t){if(typeof t!="object"||t===null)return;const e=t;if(typeof e.status=="number")return e.status;const n=e.metadata;if(n&&typeof n.status=="number")return n.status}function Qf(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message??"";if(typeof t=="object"&&t!==null){const e=t;if(typeof e.message=="string")return e.message;if(typeof e.error=="string")return e.error;
371if(typeof e.error_description=="string")return e.error_description}return""}const F0=/edge function|non-2xx|relay error|supabase|postgrest|rls|service.?role|jwt malformed|fetch failed/i;function Xf(t){const e=t.trim();return!!(!e||e.startsWith("{")||e.startsWith("[")||e.startsWith("<")||/^[A-Z_]+_ERROR$/.test(e)||e.length>160||F0.test(e))}const $0=(t,e)=>(t==null?void 0:t.name)==="AbortError"||/time?d? ?out|aborted|deadline/i.test(e),V0=(t,e)=>t instanceof TypeError||(t==null?void 0:t.name)==="FunctionsFetchError"||/failed to send a request/i.test(e)||/failed to fetch|networkerror|load failed|network request failed|ecconn|err_network|offline/i.test(e);function Mr(t,e){const n=$o(t),r=Qf(t),i=r&&!Xf(r)?r:null;return n===429||/rate.?limit|too many requests|daily .*limit|usage limit|limit reached|quota/i.test(r)?{title:"Limit reached",description:i??"You've hit the usage limit for now. Please wait a little while and try again."}:n===402||/payment required|insufficient.*credit|upgrade/i.test(r)?{title:"Usage limit reached",description:"You've reached your plan's limit. Please try again later or upgrade your plan."}:n===401||n===403||/not authenticated|unauthori[sz]ed|forbidden|please sign in|jwt|session expired|invalid token/i.test(r)?{title:"Please sign in again",description:"Your session has expired. Sign in again to continue."}:$0(t,r)?{title:"This took too long",description:"The request timed out. Please check your connection and try again."}:V0(t,r)?{title:"Connection problem",description:"We couldn't reach the server. Check your internet connection and try again."}:n===404||/not found/i.test(r)?{title:(e==null?void 0:e.title)??"Not found",description:i??(e==null?void 0:e.description)??"We couldn't find what you were looking for."}:{title:(e==null?void 0:e.title)??"Something went wrong",description:i??(e==null?void 0:e.description)??"Something went wrong. Please try again."}}function W0(t,e){return console.error(`[${e.where}]`,t),Ge(t,{eventName:"ClientError",source:"client-error",operationName:e.where,metadata:e.metadata}),Mr(t,e.fallback)}function $O(t,e){const{title:n,description:r}=W0(t,e);return{title:n,description:r,variant:"destructive"}}function tu(t){const e=$o(t),n=Qf(t);return e!==429||!n||Xf(n)?null:/Account, Usage/i.test(n)?n:`${n} You can see your usage and add credits under Account, Usage.`}function nu(t){return t.trim().toLowerCase()}const C={home:"/",group1:"/group1",storyos2:"/storyos2",free:"/free",free2:"/free2",growthPartnerships:"/growthpartnerships",growthPartnershipsThankYou:"/growthpartnerships/thank-you",growthPartnershipsNewClient:"/growthpartnerships/new-client",storyosFreeThankYou:"/storyos-free-thank-you",freeOfferTool:"/freeoffertool",freeOfferToolThankYou:"/storyos-freeoffertool-thank-you",trillionDollarStrategy:"/trilliondollarstrategy",trillionLive:"/1trillionlive",masterclassPage:"/masterclass",privacy:"/privacy",terms:"/terms",emailUnsubscribe:"/email-unsubscribe",thankYou:"/thank-you",applyThankYou:"/apply/thank-you",login:"/login",signup:"/signup",setPassword:"/set-password",forgotPassword:"/forgot-password",resetPassword:"/reset-password",dashboard:"/dashboard",account:"/account",youtubeCallback:"/youtube-callback",brainData:"/brain-data",dataBot:"/data-bot",boardSelection:"/board-selection",thumbnailBoardPolished:"/thumbnail-board/polished",thumbnailBoardDoodle:"/thumbnail-board/doodle",thumbnailBoardVision:"/thumbnail-board/vision",thumbnailBoardRoot:"/thumbnail-board",skyscraper:"/skyscraper",point2:"/point-2",webhookTest:"/webhook-test",adminPricing:"/admin/pricing",analytics:"/analytics",projects:"/projects",videos:"/videos",projectPattern:"/project/:id",dashboardLegacy:"/dashboard-new",videoPlannerTwoPagePattern:"/video-planner/two-page/:projectId",introBotPattern:"/intro-bot/:projectId",scriptBotPattern:"/script-bot/:projectId",checklists:"/checklists",guides:"/guides",resources:"/resources",hireHuman:"/hire-human",liveReviews:"/live-reviews",liveReviewsRecordings:"/live-reviews/recordings",cohortAssignments:"/cohort/assignments",cohortRecordings:"/cohort/recordings",cohortCommunity:"/cohort/community",cohortFunnelTracker:"/cohort/tools/funnel-tracker",cohortThread:"/cohort/community/:postId",cohortReviewBoard:"/cohort/team/board",cohortProgress:"/cohort/team/progress",cohortSetup:"/cohort/team/setup",workWithEd:"/work-with-ed",storyOSElite:"/storyoselite",docs:"/docs",research:"/research",researchHub:"/research/hub",researchNiche:"/research/niche",researchAdjacent:"/research/adjacent",validationTest:"/validation-test",adminErrors:"/admin/errors",adminSupportTickets:"/admin/support-tickets",adminAnnouncements:"/admin/announcements",adminSettings:"/admin/settings",adminRoot:"/admin",adminGrowthProof:"/admin/growth-proof",adminTrendReports:"/admin/trend-reports",adminChannels:"/admin/channels",adminOutliers:"/admin/outliers",adminNicheReports:"/admin/niche-reports",adminCourseManager:"/admin/course-manager",adminLiveReviews:"/admin/live-reviews",adminAccessRights:"/admin/access",adminAiSpend:"/admin/ai-spend",adminIntegrations:"/admin/integrations",adminVideoInsights:"/admin/video-insights",adminConversations:"/admin/conversations",adminSalesConversations:"/admin/sales-conversations",adminTestimonials:"/admin/testimonials",adminAnalytics:"/admin/analytics",logoExport:"/logo-export",adminBannedUsers:"/admin/banned-users",adminUsers:"/admin/users",freeTools:"/freetools",masterclassPattern:"/masterclass/:slug",masterclass:t=>`/masterclass/${t}`,funnelAudit:"/tools/funnel-audit",offerCreator:"/tools/offer-creator",channelAudit:"/tools/channel-audit",affiliateDashboard:"/affiliate-dashboard",myTickets:"/my-tickets",channelAuditLegacy:"/channel-audit",audienceWarmthLegacy:"/audience-warmth",channelAnalytics:"/channel-analytics",coursePattern:"/academy/:lessonId?",storyOsLegacy:"/story-os",videoPlanners:"/video-planners",accountLocked:"/account-locked",lateCheckout:"/late-checkout",waitlistThankYou:"/waitlist-thank-you",waitlistThankYouMarch:"/waitlist-thank-you-march",aiAssistant:"/ai-assistant",onboarding:"/onboarding",launchRoom:"/launch-room",launchRoomThankYou:"/launch-room/thank-you",launchRoomApplicationThankYou:"/launch-room/application-thank-you",launchRoomWaitlistThankYou:"/launch-room-waitlist-thank-you"},At={project:"/project",course:"/academy",introBot:"/intro-bot",scriptBot:"/script-bot",videoPlannerTwoPage:"/video-planner/two-page"},eo=(t,e)=>{const n=new URLSearchParams;Object.entries(e).forEach(([i,o])=>{o==null||o===""||n.set(i,String(o))});const r=n.toString();return r?`${t}?${r}`:t},Co={project:t=>`${At.project}/${t}`,course:t=>t?`${At.course}/${t}`:At.course,introBot:t=>`${At.introBot}/${t}`,scriptBot:t=>`${At.scriptBot}/${t}`,videoPlannerTwoPage:t=>`${At.videoPlannerTwoPage}/${t}`,thumbnailBoardVision:(t,e)=>eo(C.thumbnailBoardVision,{board:t,type:e}),projectStage:(t,e,n)=>eo(Co.project(t),{stage:e,step:n}),projectStageStep:(t,e,n)=>eo(Co.project(t),{stage:e,step:n}),projectStageOnly:(t,e)=>eo(Co.project(t),{stage:e})},H0={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_HOTJAR_SITE_ID:"6678280",VITE_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImFndmJ1aWNwbHVsdnNsdnhscmVkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTkxMjkyNTQsImV4cCI6MjA3NDcwNTI1NH0.ZUKZOwBMW3qGGcj2Tsjh_ySy9LZ-JWobZgK03iZWMtY",VITE_SUPABASE_PROJECT_ID:"agvbuicplulvslvxlred",VITE_SUPABASE_PUBLISHABLE_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImFndmJ1aWNwbHVsdnNsdnhscmVkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTkxMjkyNTQsImV4cCI6MjA3NDcwNTI1NH0.ZUKZOwBMW3qGGcj2Tsjh_ySy9LZ-JWobZgK03iZWMtY",VITE_SUPABASE_URL:"https://agvbuicplulvslvxlred.supabase.co"},q0=t=>H0[t]||void 0,U0=t=>t.replace(/\/+$/,""),K0="https://story-os.ai",Y0=q0("VITE_APP_CANONICAL_ORIGIN"),ms=U0(Y0??K0),Eo=new URL(ms).hostname,J0=Eo.startsWith("www.")?Eo:`www.${Eo}`,G0=new Set([Eo,J0]),Q0=new Set(["localhost","127.0.0.1"]),X0=()=>window.location.origin,Zf=()=>window.location.hostname,VO=()=>G0.has(Zf()),Z0=()=>Q0.has(Zf()),e1=()=>`${ms}/login`,WO=()=>Z0()?X0():ms,Ai={app:{productionDomain:ms,productionLogin:e1(),freeUpgrade:"https://story-os.ai/?website=Free%20Upgrading%20To%20Paid&from=app"},google:{favicon:"https://www.google.com/favicon.ico",permissions:"https://myaccount.google.com/permissions",apiUserDataPolicy:"https://developers.google.com/terms/api-services-user-data-policy",youtubeApiServicesTerms:"https://developers.google.com/youtube/terms/api-services-terms-of-service",oauthRevoke:"https://oauth2.googleapis.com/revoke",cloudConsentScreen:"https://console.cloud.google.com/apis/credentials/consent",youtubeApiVerification:"https://support.google.com/cloud/contact/youtube_api_verification",apiKeyRestrictionsHelp:"https://support.google.com/cloud/answer/9110914",oauthAuthorizeBase:"https://accounts.google.com/o/oauth2/v2/auth",scopes:{youtubeReadonly:"https://www.googleapis.com/auth/youtube.readonly",y
371outubeAnalyticsReadonly:"https://www.googleapis.com/auth/yt-analytics.readonly"}},youtube:{base:"https://www.youtube.com",terms:"https://www.youtube.com/t/terms",studio:"https://studio.youtube.com",watch:t=>`https://www.youtube.com/watch?v=${t}`,channel:t=>`https://youtube.com/channel/${t}`,thumbnailImg:(t,e="mqdefault")=>`https://img.youtube.com/vi/${t}/${e}.jpg`,thumbnailI:(t,e="mqdefault")=>`https://i.ytimg.com/vi/${t}/${e}.jpg`},wistia:{playerScript:"https://fast.wistia.com/player.js",oembed:"https://fast.wistia.com/oembed",embedScript:t=>`https://fast.wistia.com/embed/${t}.js`,iframeBase:"https://fast.wistia.net/embed/iframe",mediaJsBase:"https://fast.wistia.com/embed/medias",externalPlayerScript:"https://fast.wistia.com/assets/external/E-v1.js",supportTokens:"https://wistia.com/support/developers/data-api#creating-and-managing-access-tokens",embedIframe:t=>`https://fast.wistia.net/embed/iframe/${t}`},kartra:{workWithEdOptinScript:"https://app.kartra.com/optin/VyOsCeZztuXc"},loom:{embedBase:"https://www.loom.com/embed",embed:t=>`https://www.loom.com/embed/${t}?hide_owner=true&hide_share=true&hide_title=true&hideEmbedTopBar=true`},googlePolicies:{privacy:"https://policies.google.com/privacy"},bookings:{resetRetreat:"http://the-reset-retreat.info",james:"https://calendly.com/jameskellystudio",karsten:"https://calendly.com/karsten-preneurstube/new-meeting",roosa:"https://cal.com/roosakor/youtube-mentoring",andrew:"https://www.asweeney.com/andrew-coaching.php",oren:"https://calendly.com/oren-lefkowits/30min"},appRoutes:{resetPassword:C.resetPassword}},Gn={auth:"auth",chatMessage:"chat_message",courseLesson:"course_lesson",courseResource:"course_resource",error:"error",featureUsed:"feature_used",pageViewed:"page_viewed"},to={accessCheckDenied:"access_check_denied",accessCheckGranted:"access_check_granted",loginFailed:"login_failed",loginSucceeded:"login_succeeded",lessonCompleted:"lesson_completed",lessonEnded:"lesson_ended",lessonStarted:"lesson_started",resourceInteraction:"resource_interaction",signOutCompleted:"sign_out_completed"},HO={channelAnalytics:"channel_analytics",cogBot:"cog_bot",dashboard:"dashboard",docsHub:"docs_hub",pointBot:"point_bot",projects:"projects",skyscraperBot:"skyscraper_bot",thumbnailBoard:"thumbnail_board",visionBoard:"vision_board"},qO={consultantClick:"consultant_click"},Ya=()=>({analyticsSessionId:xe.getString(Xe.analyticsSessionRowId,{scope:"session"}),appVersion:xe.getString("app_version"),route:typeof window<"u"?window.location.pathname:null,telemetrySessionId:ql(),timestamp:new Date().toISOString(),url:typeof window<"u"?window.location.href:null,userAgent:typeof navigator<"u"?navigator.userAgent:null}),si=async(t,e,n,r)=>{await j.from("user_events").insert({user_id:t,event_type:e,event_name:n,event_data:{...Ya(),...r??{}}})},t1=async(t,e,n,r,i)=>{await j.from("chat_analytics").insert({user_id:t,bot_type:e,user_message:n,assistant_response:r,conversation_length:i})},UO=async()=>zn(Rt.youtubeGetConnection,{},{metadata:{feature:"account",operation:"getYouTubeConnection"}}),KO=async()=>zn(Rt.youtubeDisconnect,{},{metadata:{feature:"account",operation:"disconnectYouTube"}}),n1=async()=>zn(Rt.createUpgradeCheckout,{},{metadata:{feature:"billing",operation:"createUpgradeCheckout"}}),YO=async t=>zn(Rt.createCreditsCheckout,{pack:t},{metadata:{feature:"billing",operation:"createCreditsCheckout"}}),JO=async(t="public",e)=>zn(Rt.createCheckout,{campaign:t,referral:hx(),...e?{currency:e}:{}},{noAuth:!0,metadata:{feature:"billing",operation:"createCheckoutSession"}}),r1=async()=>zn(Rt.customerPortal,{},{metadata:{feature:"billing",operation:"openCustomerPortal"}}),i1=async()=>zn(Rt.getGoogleClientId,{},{metadata:{feature:"account",operation:"getGoogleOauthClientId"}}),Ul=y.createContext(void 0),Ks=[Ai.google.scopes.youtubeReadonly,Ai.google.scopes.youtubeAnalyticsReadonly].join(" ");function o1({children:t}){const[e,n]=y.useState(null),[r,i]=y.useState(null),[o,s]=y.useState(!0),[a,l]=y.useState(!0),[c,u]=y.useState("full"),[h,p]=y.useState(!1),[f,m]=y.useState(!1),[g,x]=y.useState(!1),[b,E]=y.useState(null),[v,A]=y.useState(!1),[_,S]=y.useState(!1),[N,M]=y.useState(!1),[L,P]=y.useState({}),T=y.useRef(null),O=y.useRef(!1),H=y.useRef(!1),D=y.useRef(null),z=y.useRef(null),ee=y.useRef(null),Q=y.useRef(!1),F=y.useRef(null),{toast:V}=Vi(),k=5*60*1e3,pe=re=>{if(!re)return!0;const me=re,he=me.status,ae=(me.message||"").toLowerCase(),ke=(me.code||"").toLowerCase();return he===401||he===403?!1:ae.includes("network")||ae.includes("fetch")||ae.includes("failed to fetch")||ae.includes("timeout")||ae.includes("temporar")||ke.includes("network")?!0:!(ae.includes("jwt")||ae.includes("invalid token")||ae.includes("token has expired")||ae.includes("refresh token"))},R=async()=>
371{if(!O.current){O.current=!0,T.current=null,D.current=null,z.current=null,i(null),n(null),l(!1),u("none"),p(!1),m(!1),A(!0),s(!1);try{Q.current=!0,await j.auth.signOut({scope:"local"})}catch(re){console.error("Failed to sign out invalid session cleanly:",re)}}},w=async re=>{var ae;if(!(re!=null&&re.access_token))return null;const me=3;let he=null;for(let ke=1;ke<=me;ke++){const{data:Ie,error:be}=await j.auth.getUser(re.access_token);if(!be&&Ie.user)return re;if(he=be||new Error("No user returned while validating session"),!pe(he)){console.warn("Hard auth failure detected, attempting token refresh before sign-out:",he==null?void 0:he.message);const{data:Ee,error:De}=await j.auth.refreshSession();return!De&&((ae=Ee.session)!=null&&ae.access_token)?(console.log("Token refresh succeeded â session recovered without sign-out"),Ee.session):(await Ge(he,{eventName:"AuthSessionValidationFailed",source:"client-error",operationName:"getValidatedSession",metadata:{attempt:ke,classification:"hard-auth-failure",refreshAttempted:!0,refreshError:(De==null?void 0:De.message)??null}}),await R(),null)}if(ke<me){const Ee=300*ke;await new Promise(De=>setTimeout(De,Ee))}}return console.warn("Auth validation failed after retries; preserving current session.",he),await Ge(he??new Error("Auth validation failed after retries"),{eventName:"AuthSessionValidationFailed",source:"client-error",operationName:"getValidatedSession",metadata:{attempts:me,classification:"recoverable"}}),re},J=async()=>{try{return await fetch(Ai.google.favicon,{method:"HEAD",mode:"no-cors",cache:"no-cache"}),!0}catch{return!1}},te=async(re,me=3,he=1e3)=>{let ae;for(let ke=0;ke<me;ke++)try{return await re()}catch(Ie){if(ae=Ie,ke<me-1){const be=he*Math.pow(2,ke);console.log(`Retry attempt ${ke+1}/${me} after ${be}ms`),await new Promise(Ee=>setTimeout(Ee,be))}}throw ae},B=async(re,me=!1)=>{if(O.current)return!1;if(!(re!=null&&re.user))return D.current=null,z.current=null,l(!0),u("full"),A(!0),!0;if(D.current===re.user.id)return z.current??!0;D.current=re.user.id;const he=async()=>{const ae=re.user.email||"unknown",ke=new Date().toISOString();T.current!==re.user.id&&A(!1);try{console.log(`[${ke}] Checking access for user: ${ae}`);const Ie=async()=>{const Ee=await fs("check-user-access",{},{timeoutMs:12e3});if(!Ee.ok){const De="errorMessage"in Ee?Ee.errorMessage:"Access check failed",G=new Error(De);throw G.status=Ee.status,G}return Ee.data},be=me?await te(Ie):await Ie();return be.hasAccess?(l(!0),u(be.accessLevel??"full"),p(be.hasLiveReviews??!1),m(be.isCohortMember??!1),x(be.isCohortTeam??!1),E(Array.isArray(be.features)?be.features:null),A(!0),ee.current=null,await si(re.user.id,Gn.auth,to.accessCheckGranted,{accessLevel:be.accessLevel??"full"}),console.log(`[${ke}] Access granted for user: ${ae}`),!0):(l(!1),u(be.accessLevel??"none"),p(!1),m(!1),E([]),A(!0),console.log(`[${ke}] Access denied for user: ${ae}`),await si(re.user.id,Gn.auth,to.accessCheckDenied,{accessLevel:be.accessLevel??"none",message:be.message??null}),Tn("auth_access_denied"),Q.current=!0,j.auth.signOut({scope:"local"}),V({title:"Access revoked",description:be.message||"Your access has been revoked. Please contact support.",variant:"destructive"}),!1)}catch(Ie){if(await Ge(Ie,{eventName:"AuthAccessCheckFailed",source:"client-error",operationName:"check-user-access",metadata:{userEmail:ae,retriesEnabled:me,status:(Ie==null?void 0:Ie.status)??null}}),console.error(`[${ke}] Failed to verify user access for ${ae}:`,{error:Ie.message,stack:Ie.stack}),(Ie==null?void 0:Ie.status)===401)return await R(),V({title:"Session expired",description:"Please sign in again.",variant:"destructive"}),!1;const be=await J();be||V({title:"Network Error",description:"Please check your internet connection and try again.",variant:"destructive"});const Ee=Date.now();return ee.current||(ee.current=Ee),Ee-ee.current<k?(A(!0),V({title:be?"Access check failed":"Network Error",description:be?"We couldn't verify your access right now. Your session is kept active while we retry.":"Please check your internet connection and try again.",variant:"destructive"}),!0):(l(!1),u("none"),p(!1),m(!1),A(!0),V({title:"Session verification unavailable",description:"We could not verify your access for several minutes. Please sign in again.",variant:"destructive"}),Q.current=!0,await j.auth.signOut({scope:"local"}),!1)}
371finally{D.current=null,z.current=null}};return z.current=he(),z.current};y.useEffect(()=>{const re=async he=>{try{const{data:ae}=await j.from("prompt_injection_flags").select("is_locked").eq("user_id",he.user.id).maybeSingle();if(ae!=null&&ae.is_locked){xe.setString(Xe.accountLocked,"true"),l(!1),u("none"),p(!1),m(!1),A(!0),Q.current=!0,j.auth.signOut({scope:"local"});return}await B(he)&&!O.current&&(T.current=he.user.id)}catch(ae){console.error("Post-auth verification failed:",ae),O.current||(l(!1),u("none"),p(!1),m(!1),A(!0))}};j.auth.getSession().then(async({data:{session:he}})=>{try{if(O.current)return;const ae=await w(he);i(ae),n((ae==null?void 0:ae.user)??null),F.current=(ae==null?void 0:ae.refresh_token)??null,T.current=null,s(!1),ae?re(ae):(l(!0),u("full"),A(!0))}catch(ae){console.error("Auth bootstrap error:",ae),l(!0),u("full"),A(!0),s(!1)}finally{H.current=!0}});const{data:{subscription:me}}=j.auth.onAuthStateChange(async(he,ae)=>{var ke,Ie;try{if(he==="INITIAL_SESSION"&&H.current)return;if(he==="SIGNED_OUT"){const Ee=Q.current;if(Q.current=!1,!Ee&&F.current){console.warn("[Auth] Unexpected SIGNED_OUT â attempting session recovery via refresh token");try{const{data:De,error:G}=await j.auth.refreshSession({refresh_token:F.current});if(!G&&((ke=De.session)!=null&&ke.access_token)){console.log("[Auth] Session recovered after unexpected SIGNED_OUT"),Ge(new Error("Unexpected SIGNED_OUT recovered via refresh"),{eventName:"AuthLockContentionRecovered",source:"client-error",operationName:"onAuthStateChange",metadata:{userId:((Ie=De.session.user)==null?void 0:Ie.id)??null}}),F.current=De.session.refresh_token,i(De.session),n(De.session.user??null);return}}catch(De){console.error("[Auth] Session recovery after unexpected SIGNED_OUT failed:",De)}Ge(new Error("Unexpected SIGNED_OUT â recovery failed"),{eventName:"AuthUnexpectedSignOut",source:"client-error",operationName:"onAuthStateChange",metadata:{}})}za(),O.current=!1,D.current=null,z.current=null,F.current=null,i(null),n(null),T.current=null,l(!0),u("full"),A(!0);return}if(!(ae!=null&&ae.user)||O.current)return;const be=await w(ae);if(!(be!=null&&be.user))return;if(s(!1),he==="TOKEN_REFRESHED"&&be.user.id===T.current){i(be),n(be.user),F.current=be.refresh_token;return}i(be),n(be.user),F.current=be.refresh_token,mf(be.user.id,{accessLevel:c}),T.current!==be.user.id?re(be):A(!0)}catch(be){console.error("Auth state change handling failed:",be),O.current||(l(!0),u("full"),A(!0)),s(!1)}});return()=>me.unsubscribe()},[V]);const X=async(re,me)=>{const he=`${window.location.origin}/`,{error:ae}=await j.auth.signUp({email:nu(re),password:me,options:{emailRedirectTo:he}});return V(ae?{title:"Sign up failed",description:Mr(ae).description,variant:"destructive"}:{title:"Check your email",description:"We've sent you a confirmation link."}),{error:ae}},ne=async(re,me)=>{const he=new Date().toISOString();console.log(`[${he}] Sign in attempt for: ${re}`);try{const{error:ae}=await j.auth.signInWithPassword({email:nu(re),password:me});if(ae)return console.error(`[${he}] Sign in failed for ${re}:`,ae),Tn("auth_login_failed"),V({title:"Sign in failed",description:Mr(ae).description,variant:"destructive"}),{error:ae};console.log(`[${he}] Sign in successful for ${re}`);const{data:ke}=await j.auth.getUser();return ke.user&&(await si(ke.user.id,Gn.auth,to.loginSucceeded,{email:re}).catch(()=>{}),Tn("auth_login_succeeded")),V({title:"Welcome back!",description:"You've been signed in successfully."}),{error:null}}catch(ae){const ke=ae instanceof Error?ae:new Error("Unexpected sign in failure");return console.error(`[${he}] Sign in threw for ${re}:`,ke),Tn("auth_login_failed"),V({title:"Sign in failed",description:ke.message,variant:"destructive"}),{error:ke}}},ue=async()=>{V({title:"Connecting...",description:"Preparing YouTube connection..."});try{const re=await i1();if(!re.clientId){V({title:"Connection failed",description:"Unable to initialize YouTube connection. Please try again.",variant:"destructive"});return}const me=`${window.location.origin}/youtube-callback`,he=crypto.randomUUID();xe.setString(Xe.youtubeOAuthState,he);const ae=new URLSearchParams({client_id:re.clientId,redirect_uri:me,response_type:"code",scope:Ks,access_type:"offline",prompt:"consent select_account",include_granted_scopes:"true",state:he}),ke=`${Ai.google.oauthAuthorizeBase}?${ae.toString()}`;xe.setJSON(Xe.youtubeOAuthDebug,{createdAt:new Date().toISOString(),origin:window.location.origin,redirectUri:me,clientId:re.clientId,scopes:Ks,oauthUrl:ke}),console.log("=== YouTube OAuth Debug ==="),console.log("Origin:",window.location.origin),console.log("Redirect URI:",me),
371console.log("Client ID:",re.clientId),console.log("Scopes:",Ks),console.log("Full OAuth URL:",ke),console.log("===========================");try{sessionStorage.setItem("yt-connect-return",window.location.pathname+window.location.search)}catch{}window.location.href=ke}catch(re){console.error("Error connecting YouTube:",re),V({title:"Connection failed",description:"An unexpected error occurred. Please try again.",variant:"destructive"})}},je=async()=>{const re=(e==null?void 0:e.id)??null;Q.current=!0;const{error:me}=await j.auth.signOut({scope:"local"});if(me){V({title:"Sign out failed",description:Mr(me).description,variant:"destructive"});return}za(),re&&(await si(re,Gn.auth,to.signOutCompleted).catch(()=>{}),Tn("auth_sign_out_completed"))};y.useEffect(()=>{if(!(e!=null&&e.id)){S(!1),M(!1);return}let re=!1;return j.from("user_gamification").select("onboarding_completed, onboarding_progress").eq("user_id",e.id).maybeSingle().then(({data:me,error:he})=>{re||(S(he?!0:!!(me!=null&&me.onboarding_completed)),P(he?{}:(me==null?void 0:me.onboarding_progress)??{}),M(!0))}),()=>{re=!0}},[e==null?void 0:e.id]);const Le=y.useCallback(()=>{S(!0);const re=e==null?void 0:e.id;re&&j.from("user_gamification").upsert({user_id:re,onboarding_completed:!0},{onConflict:"user_id"}).then(({error:me})=>{me&&console.error("Failed to persist onboarding completion:",me)})},[e==null?void 0:e.id]),Ue=y.useCallback(re=>{P(re);const me=e==null?void 0:e.id;me&&j.from("user_gamification").upsert({user_id:me,onboarding_progress:re},{onConflict:"user_id"}).then(({error:he})=>{he&&console.error("Failed to persist onboarding progress:",he)})},[e==null?void 0:e.id]),We={user:e,session:r,loading:o,hasAccess:a,accessLevel:c,hasLiveReviews:h,isCohortMember:f,isCohortTeam:g,features:b,accessResolved:v,onboardingCompleted:_,onboardingResolved:N,markOnboardingCompleted:Le,onboardingProgress:L,saveOnboardingProgress:Ue,signUp:X,signIn:ne,signOut:je,connectYouTubeChannel:ue};return d.jsx(Ul.Provider,{value:We,children:t})}function St(){const t=y.useContext(Ul);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}function s1(){return y.useContext(Ul)}const ep=y.createContext(void 0);function a1({children:t}){const{user:e,accessLevel:n}=St(),[r,i]=y.useState([]),[o,s]=y.useState(null),[a,l]=y.useState(!0),[c,u]=y.useState({}),h=y.useRef(null),p=y.useRef(0),f=y.useCallback(()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},[]),m=y.useCallback(async(_=!1,S=!1)=>{var M;if(!e){i([]),s(null),l(!1);return}const N=Date.now();if(!(!S&&N-p.current<1e4)){p.current=N,_&&l(!0);try{const L=new Date().toISOString(),[{data:P},{data:T,error:O},{data:H}]=await Promise.all([j.from("user_announcement_reads").select("last_read_at").eq("user_id",e.id).maybeSingle(),j.from("platform_announcements").select("id, title, content, type, publish_at, created_at, priority, action_type, audience_levels, poll_question, poll_options, poll_allow_comment").eq("is_active",!0).lte("publish_at",L).or(`expires_at.is.null,expires_at.gt.${L}`).order("priority",{ascending:!1}).order("publish_at",{ascending:!1}).limit(50),j.from("platform_announcements").select("publish_at").eq("is_active",!0).gt("publish_at",L).order("publish_at",{ascending:!0}).limit(1)]);if(O){console.error("Error fetching announcements:",O),i([]),s((P==null?void 0:P.last_read_at)??"1970-01-01T00:00:00Z");return}i(T??[]),s((P==null?void 0:P.last_read_at)??"1970-01-01T00:00:00Z"),f();const D=(M=H==null?void 0:H[0])==null?void 0:M.publish_at;if(D){const z=new Date(D).getTime()-Date.now()+1e3;z>0&&(h.current=window.setTimeout(()=>{m(!1,!0)},z))}}catch(L){console.error("Error loading announcement data:",L)}finally{_&&l(!1)}}},[e,f]);y.useEffect(()=>{if(!e){i([]),s(null),l(!1);return}m(!0,!0);const _=j.channel("platform-announcements-changes").on("postgres_changes",{event:"*",schema:"public",table:"platform_announcements"},()=>{m()}).subscribe(),S=()=>{document.visibilityState==="visible"&&m()};document.addEventListener("visibilitychange",S);const N=window.setInterval(()=>{m()},12e4);return()=>{f(),document.removeEventListener("visibilitychange",S),window.clearInterval(N),j.removeChannel(_)}},[e,m,f]),y.useEffect(()=>{if(!e){u({});return}let _=!1;return(async()=>{const{data:S,error:N}=await j.from("announcement_poll_responses").select("announcement_id, option_index, comment").eq("user_id",e.id);if(_||N)return;const M={};for(const L of S??[])M[L.announcement_id]={option_index:L.option_index,comment:L.comment};u(M)})(),()=>{_=!0}},[e]);const g=y.useCallback(async(_,S,N)=>{if(!e)return!1;const M={announcement_id:_,user_id:e.id,option_index:S,comment:N.length>0?N.slice(0,500):null},{error:L}=await j.from("announcement_poll_responses").upsert(M,{onConflict:"announcement_id,user_id"});return L?(console.error("Error saving poll response:",L),!1):(u(P=>({...P,[_]:{option_index:M.option_index,comment:M.comment}})),!0)},[e]),x=async()=>
371{if(!e)return;const _=new Date().toISOString();try{const{error:S}=await j.from("user_announcement_reads").upsert({user_id:e.id,last_read_at:_},{onConflict:"user_id"});if(S){console.error("Error marking announcements read:",S);return}s(_)}catch(S){console.error("Error marking announcements read:",S)}},b=y.useMemo(()=>r.filter(_=>!_.audience_levels||_.audience_levels.length===0||_.audience_levels.includes(n??"none")),[r,n]),E=y.useMemo(()=>{const _=new Date;return _.setDate(_.getDate()-30),b.filter(S=>new Date(S.publish_at)>=_).slice(0,5)},[b]),v=y.useMemo(()=>{const _=o??"1970-01-01T00:00:00Z",S=(e==null?void 0:e.created_at)??"1970-01-01T00:00:00Z",N=new Date(_)>new Date(S)?_:S;return b.filter(M=>new Date(M.publish_at)>new Date(N))},[b,o,e==null?void 0:e.created_at]),A={allAnnouncements:b,recentAnnouncements:E,newAnnouncements:v,unreadAnnouncementsCount:v.length,lastReadAt:o,loading:a,markAnnouncementsRead:x,pollResponses:c,submitPollResponse:g};return d.jsx(ep.Provider,{value:A,children:t})}function tp(){const t=y.useContext(ep);if(!t)throw new Error("useAnnouncements must be used within an AnnouncementsProvider");return t}const np=y.createContext(void 0);function l1({children:t}){const e=s1(),n=e==null?void 0:e.user,r=e==null?void 0:e.session,i=(e==null?void 0:e.loading)??!0,o=(e==null?void 0:e.accessResolved)??!1,[s,a]=y.useState(!1),[l,c]=y.useState(!0),u=y.useRef(null),h=y.useRef(null),p=y.useRef(null),[f,m]=y.useState(0),[g,x]=y.useState(()=>{const v=xe.getString(Xe.adminView);return v===null?!0:v==="true"});y.useEffect(()=>{if(i||!o)return;if(!n){u.current=null,a(!1),c(!1);return}if(u.current===n.id){c(!1);return}if(h.current===n.id){p.current;return}const v=async()=>{var A;h.current=n.id;try{if(!(r!=null&&r.access_token)){h.current=null,a(!1),c(!1);return}const _=await fs("check-admin-role",{},{timeoutMs:1e4});if(_.ok)h.current=null,a(((A=_.data)==null?void 0:A.isAdmin)??!1),u.current=n.id,c(!1);else{const S=_.errorMessage;_.status===401||S!=null&&S.includes("Authentication")?console.log("Session expired or invalid, treating as non-admin"):console.error("Error checking admin status:",S),h.current=null,a(!1),u.current=n.id,c(!1)}}catch{h.current=null,console.log("Admin check failed, will retry"),a(!1),f<5?setTimeout(()=>m(S=>S+1),1500):c(!1)}};p.current=v(),p.current},[n,r,i,o,f]);const b=y.useCallback(()=>{x(v=>{const A=!v;return xe.setString(Xe.adminView,String(A)),A})},[]),E={isAdmin:s,isLoading:l,isAdminView:s&&g,toggleAdminView:b};return d.jsx(np.Provider,{value:E,children:t})}function Kl(){const t=y.useContext(np);if(t===void 0)throw new Error("useAdminContext must be used within an AdminStatusProvider");return t}function c1(t=(e,n)=>window.open(e,n)){let e=null;try{e=t("","_blank")}catch{return null}if(e)try{e.opener=null}catch{}return e}function u1(t){try{const e=document.createElement("a");return e.href=t,e.target="_blank",e.rel="noopener noreferrer",e.style.display="none",document.body.appendChild(e),e.click(),e.remove(),!0}catch{return!1}}function d1(t,{tab:e,navigate:n,openFallback:r}){if(e&&!e.closed)try{return e.location.href=t,"new-tab"}catch{rp({tab:e})}return(r??u1)(t)?"new-tab":((n??(i=>window.location.assign(i)))(t),"same-tab")}function rp({tab:t}){try{t&&!t.closed&&t.close()}catch{}}const h1=["full","platform"];function f1(t){return h1.includes(t)}const p1=["academy"];function m1(t){return p1.includes(t)}const g1=[];function y1(t){return g1.includes(t)}function GO(t){return t.filter(e=>!y1(e.key))}const x1=[{label:"Production tools",features:[{key:"videos",label:"Videos",description:"Project list and the full video workflow"},{key:"research",label:"Research",description:"Niche, adjacent niche, channel audit, banks and boards"},{key:"brain",label:"The Brain",description:"Viewer profile, outliers, research insights, lessons"},{key:"ai_coach",label:"AI Coach",description:"The coaching assistant"},{key:"ai_chat",label:"AI Chat",description:"General chat surface"},{key:"data_bot",label:"Data Bot",description:"Data analysis bot"}]},{label:"Live reviews",features:[{key:"live_reviews",label:"Live Reviews",description:"Submit an application and watch past recordings. The page itself stays visible to everyone as an upsell; this controls the content."},{key:"cohort",label:"Cohort workspace",description:"The eight-week live cohort: assignments, recordings and community. Granted by the StoryOS Launch Room Client tag in Kartra, not by level; ticking it here does nothing."},{key:"cohort_team",label:"Cohort team pages",description:"Review board, cohort progress and weekly setup. Held by admins and the cohort_team role, not by level; ticking it here does nothing."}]},{label:"Journey",features:[{key:"onboarding",label:"Onboarding",description:"The intake survey and setup flow after first sign-in. Unticked, members of this level skip straight to the app."}]},{label:"Learning and support",features:[{key:"academy",label:"Academy",description:"Course player and lessons"},{key:"resources",label:"Course Resources",description:"Downloadable course material"},{key:"docs",label:"Docs Hub"},{key:"guides",label:"Guides"},{key:"checklists",label:"Checklists"},{key:"inspiration",label:"Inspiration Bank"},{key:"hire_human",label:"Hire a Human"},{key:"tickets",label:"Support Tickets",description:"The member's own tickets"},{key:"channel_analytics",label:"Channel Analytics"},{key:"analytics",label:"Analytics",description:"Member-facing analytics, not the admin report"}]},{label:"Internal tools",features:[{key:"free_tools",label:"Free Tools hub",adminOnlyToday:!0},{key:"funnel_audit",label:"Funnel Audit",adminOnlyToday:!0},{key:"offer_creator",label:"Offer Creator",adminOnlyToday:!0},{key:"affiliate",label:"Affiliate Dashboard",adminOnlyToday:!0}]}],ip=x1.flatMap(t=>t.features);new Set(ip.map(t=>t.key));function b1(t){var e;return((e=ip.find(n=>n.key===t))==null?void 0:e.label)??t}const no=["academy","resources","docs","guides","checklists","inspiration","hire_human","tickets","channel_analytics","analytics"],Ja=["videos","research","brain","ai_coach","ai_chat","data_bot"],w1=Ja,v1={none:[],free:["free_tools",...no.filter(t=>t!=="academy")],academy:["onboarding","free_tools",...no],full:["onboarding","free_tools",...no,...Ja],platform:["onboarding","free_tools",...no,...Ja,"live_reviews"],launch_room:["tickets"]},k1=[{feature:"videos",route:C.videos},{feature:"academy",route:At.course},{feature:"free_tools",route:C.freeTools},{feature:"cohort",route:C.cohortRecordings},{feature:"tickets",route:C.myTickets}],op=t=>`storyos:login-first-visit:${t}`;function sp(t){if(!t)return!0;try{return localStorage.getItem(op(t))==="1"}catch{return!0}}function ap(t){if(t)try{localStorage.setItem(op(t),"1")}catch{}}function gs(t,e){const n=k1.find(r=>t(r.feature));return n?e!=null&&e.firstVisit&&n.feature==="free_tools"?C.offerCreator:n.route:C.account}const lp=y.createContext({accessLevel:"full",isFullAccess:!0,isAcademyOnly:!1,isFreeTier:!1,hasLiveReviews:!1,loading:!0,hasFeature:()=>!0,requireFullAccess:()=>!0,startUpgrade:async()=>{},openCustomerPortal:async()=>{},upgradeLoading:!1,portalLoading:!1});function S1({children:t}){const{user:e,accessLevel:n,hasLiveReviews:r,isCohortMember:i,isCohortTeam:o,features:s,accessResolved:a,loading:l}
371=St(),{isAdmin:c,isLoading:u}=Kl(),[h,p]=y.useState(!1),[f,m]=y.useState(!1),g=c?"full":n??"full",x=l||u||!!e&&!a,b=s??null,E=c||(b?w1.every(P=>b.includes(P)):f1(g)),v=!E&&(b?b.includes("academy"):m1(g)),A=!E&&!v&&((b==null?void 0:b.length)??0)>0,_=c||(r??!1)||((s==null?void 0:s.includes("live_reviews"))??!1),S=y.useCallback(P=>{if(c)return!0;if((P==="cohort"||P==="cohort_team")&&x)return!1;if(x)return!0;if(P==="live_reviews")return _;if(P==="cohort")return c||(i??!1)||(o??!1);if(P==="cohort_team")return c||(o??!1);if(s&&s.length>0)return s.includes(P);const T=v1[g];return T?T.includes(P):(console.warn(`[access] no feature data for level '${g}'; allowing '${P}'`),!0)},[c,x,s,g,_,i,o]),N=y.useCallback(async()=>{if(!x){if(!v){window.location.assign(Ai.app.freeUpgrade);return}p(!0);try{const P=await n1();if(!(P!=null&&P.url))throw new Error("No checkout URL returned");window.location.assign(P.url)}catch(P){console.error("Upgrade checkout error:",P),Un.error("Failed to start upgrade",{description:Mr(P,{description:"Please try again later."}).description}),p(!1)}}},[v,x]),M=y.useCallback(async()=>{m(!0);const P=c1();try{const T=await r1();if(T!=null&&T.url)d1(T.url,{tab:P});else throw new Error("No portal URL returned")}catch(T){rp({tab:P}),console.error("Customer portal error:",T),$o(T)===404?Un.info("No billing account yet",{description:"Billing management appears here once you have an active subscription."}):$o(T)===409?Un.info("We need to check your billing",{description:"Your account has more than one active subscription. Please contact support and we will sort it out.",duration:1e4}):Un.error("Failed to open subscription management",{description:Mr(T,{description:"Please try again later."}).description})}finally{m(!1)}},[]),L=P=>E||c?!0:(Un.info("Upgrade to access this feature",{description:P?`"${P}" requires a full subscription.`:"This feature requires a full subscription.",duration:8e3,action:{label:"Upgrade",onClick:()=>N()}}),!1);return d.jsx(lp.Provider,{value:{accessLevel:g,isFullAccess:E,isAcademyOnly:v,isFreeTier:A,hasLiveReviews:_,loading:x,hasFeature:S,requireFullAccess:L,startUpgrade:N,openCustomerPortal:M,upgradeLoading:h,portalLoading:f},children:t})}const hr=()=>y.useContext(lp),C1=[C.login,C.signup,C.setPassword,C.forgotPassword,C.resetPassword];function cp(t){if(!t)return null;const e=t.trim();return!e.startsWith("/")||e.startsWith("//")||e.startsWith("/\\")||C1.some(n=>e===n||e.startsWith(`${n}?`)||e.startsWith(`${n}/`))?null:e}const Vo={terms:"2026-08-03",privacy:"2026-08-03"};async function E1(t,e){const n={user_id:t,terms_version:Vo.terms,privacy_version:Vo.privacy,source:e},{error:r}=await j.from("user_agreements").insert(n);if(r)throw r}async function T1(t){const{data:e,error:n}=await j.from("user_agreements").select("terms_version, privacy_version").eq("user_id",t).eq("terms_version",Vo.terms).eq("privacy_version",Vo.privacy).limit(1);return n?(console.error("Agreement check failed:",n),!0):((e==null?void 0:e.length)??0)>0}function _1({children:t}){const{user:e}=St(),[n,r]=y.useState(!1),[i,o]=y.useState(!1),[s,a]=y.useState(!1),[l,c]=y.useState(!1);y.useEffect(()=>{if(!(e!=null&&e.id))return;let h=!1;return(async()=>{const p=await T1(e.id);h||(r(!p),o(!0))})(),()=>{h=!0}},[e==null?void 0:e.id]);const u=async()=>{if(!(!(e!=null&&e.id)||!s)){c(!0);try{await E1(e.id,"existing-user-prompt"),r(!1)}catch(h){console.error("Failed to record agreement:",h),Un.error("Could not save your acceptance",{description:"Please try again."})}finally{c(!1)}}};return d.jsxs(d.Fragment,{children:[t,i&&n&&d.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"agreement-title",style:{position:"fixed",inset:0,zIndex:200,background:"rgba(0,0,0,0.8)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:d.jsxs("div",{style:{width:"100%",maxWidth:480,background:"var(--bg-medium)",border:"1px solid var(--border-soft)",borderRadius:12,padding:"28px 26px"},children:[d.jsx("h2",{id:"agreement-title",style:{fontSize:18,fontWeight:600,color:"var(--text-primary)",margin:"0 0 10px"},children:"We've updated our Terms and Privacy Policy"}),d.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.65,margin:"0 0 18px"},children:"Please review and accept them to carry on using StoryOS. They cover how we handle your data, including the analytics tools we use."}),d.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",cursor:"pointer",marginBottom:20},children:[d.jsx("input",{type:"checkbox",checked:s,onChange:h=>a(h.target.checked),style:{marginTop:2,flexShrink:0,width:16,height:16,accentColor:"var(--accent)"}}),d.jsxs("span",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.6},children:["I agree to the"," ",d.jsx(Lr,{to:C.terms,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--text-primary)",textDecoration:"underline"},children:"Terms of Service"})," ","and"," ",d.jsx(Lr,{to:C.privacy,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--text-primary)",textDecoration:"underline"},children:"Privacy Policy"}),"."]})]}),d.jsxs("button",{type:"button",onClick:u,disabled:!s||l,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",height:40,background:"var(--accent)",border:"none",borderRadius:8,color:"#fff",fontSize:13,fontWeight:600,cursor:!s||l?"default":"pointer",opacity:!s||l?.5:1},children:[l&&d.jsx(ut,{size:14,className:"animate-spin"}),l?"Saving...":"Accept and continue"]})]})})]})}function wt({children:t}){var A;const{user:e,loading:n,hasAccess:r,accessLevel:i,features:o,accessResolved:s,onboardingCompleted:a,onboardingResolved:l}=St(),c=_=>(o==null?void 0:o.includes(_))??!0,u=It(),[h,p]=y.useState(!1),[f,m]=y.useState(!1);y.useEffect(()=>{if(!e||s){p(!1);return}const _=setTimeout(()=>p(!0),12e3);return()=>clearTimeout(_)},[e,s]);const g=n||e&&!s&&!h;if(y.useEffect(()=>{!f&&!g&&e&&r&&m(!0)},[f,g,e,r]),g&&!f)return d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:d.jsxs("div",{className:"text-center",children:[d.jsx(ut,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-primary"}),d.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})});if(!e){if(xe.getString(Xe.accountLocked)==="true")return d.jsx(et,{to:"/account-locked",replace:!0});const _=`${u.pathname}${u.search}`,S=_&&_!=="/"&&!_.startsWith(C.login)?`${C.login}?redirect=${encodeURIComponent(_)}`:C.login;return d.jsx(et,{to:S,state:{from:_},replace:!0})}if(!r)return d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background px-4",children:d.jsxs("div",{className:"max-w-md w-full text-center space-y-4",children:[d.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-muted flex items-center justify-center",children:d.jsx(ut,{className:"h-8 w-8 text-muted-foreground"})}),d.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Access Revoked"}),d.jsx("p",{className:"text-muted-foreground",children:"Your access to this platform has been removed. If you believe this is a mistake, please contact support."}),d.jsx("button",{onClick:()=>window.location.href=C.login,className:"inline-flex items-center justify-center rounded-md bg-primary px-6 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:"Back to Login"})]})});const x=u.pathname.startsWith(C.onboarding),b=u.pathname.startsWith(C.youtubeCallback),E=c("onboarding"),v=s||h;if(l&&!b){if(!a&&!x&&E&&v){const _=`${u.pathname}${u.search}`;return d.jsx(et,{to:C.onboarding,replace:!0,state:{returnTo:_}})}if((a||!E)&&x){const _=cp((A=u.state)==null?void 0:A.returnTo);return d.jsx(et,{to:_??gs(c),replace:!0})}}return d.jsx(_1,{children:t})}function Ae({feature:t,children:e}){const{hasFeature:n,loading:r,startUpgrade:i,accessLevel:o}=hr(),s=y.useRef(!1),[a,l]=y.useState(!1);y.useEffect(()=>{if(!r)return;const m=setTimeout(()=>l(!0),12e3);return()=>clearTimeout(m)},[r]);const c=r&&!a,u=n(t),p={free:"the free plan",academy:"Academy access",none:"your current plan"}[o]??"your current plan",f=t==="cohort"||t==="cohort_team";return y.useEffect(()=>{!c&&!u&&!f&&!s.current&&(s.current=!0,Un.info("Upgrade to access this feature",{description:`"${b1(t)}" isn't included in ${p}.`,duration:8e3,action:{label:"Upgrade",onClick:()=>i()}}))},[c,u,t,f]),c?d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:d.jsx(ut,{className:"h-8 w-8 animate-spin text-primary"})}):u?d.jsx(d.Fragment,{children:e}):d.jsx(et,{to:gs(n),replace:!0})}function A1(){try{for(let t=0;t<localStorage.length;t+=1){const e=localStorage.key(t);if(e!=null&&e.startsWith("sb-")&&e.endsWith("-auth-token"))return!0}}catch{}return!1}function ro({children:t,waitForAuth:e=!1}){var g;const{user:n,loading:r}=St(),{hasFeature:i,loading:o}=hr(),s=It(),[a]=Hy(),l=((g=a.get("tool"))==null?void 0:g.trim())||null,c=!!l&&!r&&!!n,[u,h]=y.useState(null);y.useEffect(()=>{if(!c)return;let x=!1;return j.from("free_resources").select("route").eq("key",l).eq("enabled",!0).maybeSingle().then(({data:b,error:E})=>{x||(E&&console.warn("Could not resolve tool link:",E.message),h(cp((b==null?void 0:b.route)??null)??""))}),()=>{x=!0}},[c,l]);const p=r||o,f=c&&u===null,m=p&&A1();if(e&&p||f||m)return d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:d.jsx(ut,{className:"h-8 w-8 animate-spin text-primary"})});if(!r&&n&&!o){if(u)return d.jsx(et,{to:u,replace:!0});
371const x=!sp(n.id);ap(n.id);const b=gs(i,{firstVisit:x}),E=s.search;return d.jsx(et,{to:E?`${b}${E}`:b,replace:!0})}return d.jsx(d.Fragment,{children:t})}function M1(){const{hasFeature:t,loading:e}=hr(),{user:n}=St(),r=It();if(e)return d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:d.jsx(ut,{className:"h-8 w-8 animate-spin text-primary"})});const i=!sp(n==null?void 0:n.id);ap(n==null?void 0:n.id);const o=gs(t,{firstVisit:i}),s=r.search;return d.jsx(et,{to:s?`${o}${s}`:o,replace:!0})}function Be({children:t}){const{isAdmin:e,isLoading:n}=Kl(),{toast:r}=Vi(),i=y.useRef(!1);return y.useEffect(()=>{!n&&!e&&!i.current&&(i.current=!0,r({title:"Access Denied",description:"You don't have permission to access this page.",variant:"destructive"})),e&&(i.current=!1)},[e,n,r]),d.jsx(wt,{children:n?d.jsx("div",{className:"flex items-center justify-center min-h-screen",children:d.jsx(ut,{className:"w-8 h-8 animate-spin text-primary"})}):e?t:d.jsx(et,{to:C.dashboard,replace:!0})})}const Ys="layout-sidebar-collapsed",io="layout-right-panel-open",Js="layout-subnav-open",ru="layout-right-panel-width",N1=512,iu=280,ou=800,up=y.createContext(null);function j1({children:t}){const[e,n]=y.useState(()=>xe.getString(Ys)==="true"),[r,i]=y.useState(()=>xe.getString(Js)!=="false"),o=typeof window<"u"&&window.matchMedia("(max-width: 1023px)").matches,s=y.useRef(!o&&xe.getString(io)==="true"),[a,l]=y.useState(()=>s.current),[c,u]=y.useState(null),[h,p]=y.useState(()=>{const D=parseInt(xe.getString(ru)??"",10);return Number.isFinite(D)?Math.max(iu,Math.min(ou,D)):N1}),[f,m]=y.useState([]),[g,x]=y.useState([]),[b,E]=y.useState(!1),v=y.useRef(!1),A=y.useCallback(D=>{E(!1),!D&&s.current&&(v.current=!0),n(D),xe.setString(Ys,String(D))},[]),_=y.useCallback(()=>{if(b){E(!1),v.current=!0;return}n(D=>{const z=!D;return!z&&s.current&&(v.current=!0),xe.setString(Ys,String(z)),z})},[b]),S=y.useCallback(()=>{v.current||E(!0)},[]),N=y.useCallback(D=>{i(D),xe.setString(Js,String(D))},[]),M=y.useCallback(()=>{i(D=>{const z=!D;return xe.setString(Js,String(z)),z})},[]),L=y.useCallback(D=>{s.current=D,l(D),xe.setString(io,String(D))},[]),P=y.useCallback(()=>u(null),[]),T=y.useCallback(D=>{s.current?window.dispatchEvent(new CustomEvent("rp-prefill",{detail:D})):(u(D),s.current=!0,l(!0),xe.setString(io,"true"))},[]);y.useEffect(()=>{const D=()=>L(!0);return window.addEventListener("open-right-panel",D),()=>window.removeEventListener("open-right-panel",D)},[L]),y.useEffect(()=>{a||(E(!1),v.current=!1)},[a]);const O=y.useCallback(D=>{const z=Math.max(iu,Math.min(ou,D));p(z),xe.setString(ru,String(z))},[]),H=y.useCallback(()=>{l(D=>{const z=!D;return s.current=z,xe.setString(io,String(z)),z})},[]);return d.jsx(up.Provider,{value:{sidebarCollapsed:e||b,toggleSidebar:_,setSidebarCollapsed:A,requestRoomForPanel:S,subNavOpen:r,toggleSubNav:M,setSubNavOpen:N,rightPanelOpen:a,toggleRightPanel:H,setRightPanelOpen:L,openPanelWithPrefill:T,pendingPrefill:c,clearPendingPrefill:P,panelWidth:h,setPanelWidth:O,projectCompletedStages:f,setProjectCompletedStages:m,toolbarBreadcrumbs:g,setToolbarBreadcrumbs:x},children:t})}function ys(){const t=y.useContext(up);if(!t)throw new Error("useLayout must be used within LayoutProvider");return t}const I1=cs,QO=Xh,R1=ls,dp=y.forwardRef(({className:t,...e},n)=>d.jsx(qr,{className:Ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:n}));dp.displayName=qr.displayName;const O1=Dl("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),hp=y.forwardRef(({side:t="right",className:e,children:n,...r},i)=>d.jsxs(R1,{children:[d.jsx(dp,{}),d.jsxs(Ur,{ref:i,className:Ne(O1({side:t}),e),...r,children:[n,d.jsxs(Qh,{className:"absolute right-4 top-4 roun
371ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[d.jsx(Bn,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hp.displayName=Ur.displayName;const fp=({className:t,...e})=>d.jsx("div",{className:Ne("flex flex-col space-y-2 text-center sm:text-left",t),...e});fp.displayName="SheetHeader";const pp=y.forwardRef(({className:t,...e},n)=>d.jsx(Fi,{ref:n,className:Ne("text-lg font-semibold text-foreground",t),...e}));pp.displayName=Fi.displayName;const mp=y.forwardRef(({className:t,...e},n)=>d.jsx($i,{ref:n,className:Ne("text-sm text-muted-foreground",t),...e}));mp.displayName=$i.displayName;const Gs=1024;function gp(){const[t,e]=y.useState(void 0);return y.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Gs-1}px)`),r=()=>{e(window.innerWidth<Gs)};return n.addEventListener("change",r),e(window.innerWidth<Gs),()=>n.removeEventListener("change",r)},[]),!!t}const yp=t=>["my-ai-usage",t],P1=["ok","approaching","over"];function xp(){const{user:t}=St();return Ln({queryKey:yp(t==null?void 0:t.id),enabled:!!(t!=null&&t.id),staleTime:5*60*1e3,refetchOnWindowFocus:!1,queryFn:async()=>{const{data:e,error:n}=await j.rpc("get_my_ai_usage");if(n)throw n;const r=e??{},i=r.band,o=r.percent_used;return{hasLimit:r.has_limit===!0,percentUsed:typeof o=="number"?o:null,band:P1.includes(i)?i:"ok",resetsAt:typeof r.resets_at=="string"?r.resets_at:"",percentWithCredits:typeof r.percent_with_credits=="number"?r.percent_with_credits:null,creditsRemaining:typeof r.credits_remaining=="number"?r.credits_remaining:0,creditsBuysActions:typeof r.credits_buys_actions=="number"?r.credits_buys_actions:0,activity:Array.isArray(r.activity)?r.activity:[]}}})}const D1=(t,e)=>`storyos:ai-allowance-dismissed:${t}:${e.slice(0,10)}`;function L1(){const{data:t}=xp(),[,e]=y.useState(0);if(!(t!=null&&t.hasLimit))return null;const n=t.creditsRemaining>0,r=t.percentWithCredits??t.percentUsed??0,i=r>=100?"over":r>=80?"approaching":"ok";if(i==="ok")return null;const o=D1(i,t.resetsAt);if(xe.getString(o)==="true")return null;const s=i==="over",a=t.resetsAt?Gy(new Date(t.resetsAt),"d MMM"):null;return d.jsxs("div",{role:"status",style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",flexShrink:0,borderBottom:"1px solid var(--border-soft)",background:s?"var(--pill-danger-bg)":"var(--pill-warning-bg)",color:s?"var(--danger)":"var(--warning)"},children:[n&&!s?d.jsx(qx,{style:{width:15,height:15,flexShrink:0}}):d.jsx(db,{style:{width:15,height:15,flexShrink:0}}),d.jsxs("span",{style:{fontSize:13,fontWeight:500,minWidth:0},children:[n?s?"You've used all your AI usage and credits for this cycle.":`You've used ${r}% of your AI usage, credits included (${t.creditsRemaining.toLocaleString()} left).`:s?"You've used all your AI usage for this cycle.":`You've used ${r}% of your AI usage.`,a&&d.jsxs("span",{style:{color:"var(--text-muted)",fontWeight:500},children:[" ","It resets on ",a,"."]})]}),d.jsx(Lr,{to:`${C.account}?tab=usage`,style:{fontSize:13,fontWeight:600,color:"inherit",textDecoration:"underline",whiteSpace:"nowrap"},children:"See usage"}),d.jsx("button",{onClick:()=>{xe.setString(o,"true"),e(l=>l+1)},"aria-label":"Dismiss",style:{marginLeft:"auto",display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,flexShrink:0,background:"transparent",border:"none",borderRadius:4,color:"inherit",cursor:"pointer",opacity:.7},children:d.jsx(Bn,{style:{width:14,height:14}})})]})}const B1=[{key:"celebrate",label:"Celebrate"},{key:"avatar",label:"Avatar"},{key:"offer_creation",label:"Offer Creation"},{key:"sales_pages",label:"Sales Pages"},{key:"email",label:"Email"},{key:"measuring_data",label:"Measuring data"},{key:"launch_week",label:"Launch Week"}],Yl="workshop_question",XO=t=>{var e;return t===Yl?"Workshop question":((e=B1.find(n=>n.key===t))==null?void 0:e.label)??t},ZO=t=>["cohort","community",t];async function Zt(t){const n=[];for(let r=0;;r+=1e3){const{data:i,error:o}=await t(r,r+1e3-1);if(o)throw o;const s=i??[];if(n.push(...s),s.length<1e3)return n}}const bp="id, author_id, author_name, author_is_team, category, week_id, title, body, reply_count, last_reply_at, hidden_at, created_at";function wp(t,e,n){const r=new Map;for(const o of n.unread)r.set(o.target_id,(r.get(o.target_id)??0)+1);const i=new Map;for(const o of n.reactions)i.has(o.post_id)||i.set(o.post_id,[]),i.get(o.post_id).push(o);return t.map(o=>{const s=i.get(o.id)??[],a=s.filter(c=>c.user_id===e),l=a.find(c=>c.kind!=="like");return{...o,category:o.category,likes:s.filter(c=>c.kind==="like").length,reactions:{helpful:s.filter(c=>c.kind==="helpful").length,love:s.filter(c=>c.kind==="love").length,celebrate:s.filter(c=>c.kind==="celebrate").length},myLike:a.some(c=>c.kind==="like"),myReaction:(l==null?void 0:l.kind)??null,saved:n.savedIds.has(o.id),involved:o.author_id===e||n.involvedIds.has(o.id),unread:r.get(o.id)??0}})}async function eP(t){const[e,n,r,i,o,s]=await Promise.all([Zt((a,l)=>j.from("cohort_posts").select(bp).order("created_at",{ascending:!1}).order("id").range(a,l)),Zt((a,l)=>j.from("cohort_reactions").select("post_id, user_id, kind").range(a,l)),Zt((a,l)=>j.from("cohort_saved_posts").select("post_id").eq("user_id",t).range(a,l)),Zt((a,l)=>j.from("cohort_replies").select("post_id").eq("author_id",t).range(a,l)),Zt((a,l)=>j.from("cohort_replies").select("post_id").eq("parent_author_id",t).range(a,l)),Zt((a,l)=>j.from("cohort_notifications").select("target_id").eq("user_id",t).eq("kind","reply").is("read_at",null).range(a,l))]);return wp(e,t,{reactions:n,savedIds:new Set(r.map(a=>a.post_id)),involvedIds:new Set([...i.map(a=>a.post_id),...o.map(a=>a.post_id)]),unread:s})}const tP=(t,e)=>["cohort","questions",t,e];function vp(t,e=100){const n=[];for(let r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n}async function ai(t,e){return(await Promise.all(vp(t).map(r=>Zt((i,o)=>e(r,i,o))))).flat()}const kp="intro";async function nP(t,e){const n=await Zt((u,h)=>{const p=j.from("cohort_posts").select(bp);return(e===kp?p.is("week_id",null).eq("category",Yl):p.eq("week_id",e)).order("created_at",{ascending:!1}).order("id").range(u,h)});if(!n.length)return[];const r=n.map(u=>u.id),[i,o,s,a]=await Promise.all([ai(r,(u,h,p)=>j.from("cohort_reactions").select("post_id, user_id, kind").in("post_id",u).range(h,p)),ai(r,(u,h,p)=>j.from("cohort_saved_posts").select("post_id").eq("user_id",t).in("post_id",u).range(h,p)),ai(r,(u,h,p)=>j.from("cohort_replies").select(Sp).in("post_id",u).order("created_at").order("id").range(h,p)).then(u=>Cp(u,t)),ai(r,(u,h,p)=>j.from("cohort_notifications").select("target_id").eq("user_id",t).eq("kind","reply").is("read_at",null).in("target_id",u).range(h,p))]),l=new Map;for(const u of s)l.has(u.post_id)||l.set(u.post_id,[]),l.get(u.post_id).push(u);const c=new Set(s.filter(u=>u.author_id===t||u.parent_author_id===t).map(u=>u.post_id));return wp(n,t,{reactions:i,savedIds:new Set(o.map(u=>u.post_id)),involvedIds:c,unread:a}).map(u=>({...u,replies:l.get(u.id)??[]}))}const rP=["cohort","week-positions"];async function iP(){const{data:t,error:e}=await j.from("cohort_weeks").select("id, position");if(e)throw e;return Object.fromEntries((t??[]).map(n=>[n.id,n.position]))}function oP(t,e){const n=t?e==null?void 0:e[t]:void 0;return t?n?`Week ${n} question`:"Workshop question":"Start here question"}function sP(t,e,n){const r=e?n==null?void 0:n[e]:void 0;return e?r?`${C.cohortRecordings}?week=${r}&q=${t}`:C.cohortRecordings:`${C.cohortRecordings}?week=0&q=${t}`}async function aP(t,e){const{data:n,error:r}=await j.rpc("cohort_question_ask",{p_week_id:t===kp?null:t,p_body:e.trim()});if(r)throw r;return n}async function lP(t,e){for(const n of vp(e)){const{error:r}=await j.from("cohort_notifications").update({read_at:new Date().toISOString()}).eq("user_id",t).eq("kind","reply").in("target_id",n).is("read_at",null);if(r)throw r}}async function cP(t){const e=t.trim().replace(/[%_\\]/g,r=>`\\${r}`);if(!e)return new Set;const n=await Zt((r,i)=>j.from("cohort_replies").select("post_id").ilike("body",`%${e}%`).range(r,i));return new Set(n.map(r=>r.post_id))}async function uP(t,e,n){const{data:r,error:i}=await j.rpc("cohort_post_create",{p_category:t,p_title:e.trim(),p_body:n.trim()});if(i)throw i;return r}async function dP(t,e,n){const{error:r}=await j.rpc("cohort_react",{p_post_id:t,p_kind:e,p_on:n});if(r)throw r}async function hP(t,e){const{error:n}=await j.rpc("cohort_save",{p_post_id:t,p_on:e});if(n)throw n}function fP(t){try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch{return null}}function pP(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function mP(t){try{localStorage.removeItem(t)}catch{}}const gP=t=>["cohort","community","replies",t],Sp="id, post_id, author_id, author_name, author_is_team, parent_reply_id, parent_author_id, body, hidden_at, created_at";async function yP(t,e){const n=await Zt((r,i)=>j.from("cohort_replies").select(Sp).eq("post_id",t).order("created_at").order("id").range(r,i));return Cp(n,e)}async function Cp(t,e){const n=t.map(o=>o.id),r=n.length?await ai(n,(o,s,a)=>j.from("cohort_reply_reactions").select("reply_id, user_id, kind").in("reply_id",o).range(s,a)):[],i=new Map;for(const o of r)i.has(o.reply_id)||i.set(o.reply_id,[]),i.get(o.reply_id).push(o);return t.map(o=>{const s=i.get(o.id)??[],a=s.find(l=>l.user_id===e&&l.kind!=="like");return{...o,likes:s.filter(l=>l.kind==="like").length,reactions:{helpful:s.filter(l=>l.kind==="helpful").length,love:s.filter(l=>l.kind==="love").length,celebrate:s.filter(l=>l.kind==="celebrate").length},myLike:s.some(l=>l.user_id===e&&l.kind==="like"),myReaction:(a==null?void 0:a.kind)??null}})}async function xP(t,e,n){const{error:r}=await j.rpc("cohort_react_reply",{p_reply_id:t,p_kind:e,p_on:n});if(r)throw r}async function bP(t,e,n){const{data:r,error:i}=await j.rpc("cohort_reply_create",{p_post_id:t,p_parent_reply_id:e,p_body:n.trim()});if(i)throw i;return r}async function wP(t,e){const{error:n}=await j.from("cohort_notifications").update({read_at:new Date().toISOString()}).eq("user_id",t).eq("kind","reply").eq("target_id",e).is("read_at",null);if(n)throw n}const z1=t=>["cohort","unread",t];async function F1(){const{data:t,error:e}=await j.rpc("cohort_unread_counts");if(e)throw e;const n=t??{};return{feedback:Number(n.feedback??0),replies:Number(n.replies??0),questions:Number(n.question_replies??0)}}async function vP(t,e){const{error:n}=await j.rpc("cohort_report",{p_post_id:t.postId??null,p_reply_id:t.replyId??null,p_reason:e.trim()});if(n)throw n}async function kP(t,e){const{error:n}=await j.rpc("cohort_hide",{p_post_id:t.postId??null,p_reply_id:t.replyId??null,p_hidden:e});if(n)throw n}async function SP(t){const{error:e}=await j.rpc("cohort_post_delete",{p_post_id:t});if(e)throw e}async function CP(t){const{error:e}=await j.rpc("cohort_resolve_report",{p_report_id:t});if(e)throw e}const EP=["cohort","community","reports"];async function TP(){const t=await Zt((a,l)=>j.from("cohort_reports").select("id, reason, created_at, reporter_id, post_id, reply_id").is("resolved_at",null).order("created_at").range(a,l));if(!t.length)return[];const e=t.map(a=>a.reply_id).filter(a=>!!a),n=e.length?(await j.from("cohort_replies").select("id, post_id, body, author_name").in("id",e)).data??[]:[],r=[...new Set([...t.map(a=>a.post_id),...n.map(a=>a.post_id)].filter(a=>!!a))],i=r.length?(await j.from("cohort_posts").select("id, title, body, author_name, week_id, category").in("id",r)).data??[]:[],o=(await j.rpc("cohort_team_members")).data??[],s=new Map(o.map(a=>[a.user_id,a.name]));return t.map(a=>{const l=a.reply_id?n.find(h=>h.id===a.reply_id):null,c=i.find(h=>h.id===((l==null?void 0:l.post_id)??a.post_id)),u=(l==null?void 0:l.body)??(c==null?void 0:c.body)??"";return{id:a.id,reason:a.reason,created_at:a.created_at,reporterName:s.get(a.reporter_id)??"a member",postId:(c==null?void 0:c.id)??a.post_id??"",postTitle:(c==null?void 0:c.title)??"Removed post",replyId:a.reply_id,postIsQuestion:(c==null?void 0:c.category)===Yl,postWeekId:(c==null?void 0:c.week_id)??null,excerpt:u.length>180?`${u.slice(0,180).trimEnd()}â¦`:u,authorName:(l==null?void 0:l.author_name)??(c==null?void 0:c.author_name)??""}})}const _P=t=>["cohort","my-email-prefs",t];function Ep(t){const e=t??{};return{feedback:e.feedback!==!1,reply:e.reply!==!1,submission:e.submission!==!1}}async function AP(){const{data:t,error:e}=await j.rpc("cohort_my_email_prefs");if(e)throw e;return Ep(t)}async function MP(t,e){const{data:n,error:r}=await j.rpc("cohort_set_my_email",{p_kind:t,p_on:e});if(r)throw r;return Ep(n)}function $1(){var i,o,s;const{user:t}=St(),{hasFeature:e}=hr(),n=!!(t!=null&&t.id)&&e("cohort"),r=Ln({queryKey:z1(t==null?void 0:t.id),enabled:n,queryFn:F1,refetchOnWindowFocus:!0,refetchInterval:6e4,staleTime:15e3});return{replies:((i=r.data)==null?void 0:i.replies)??0,feedback:((o=r.data)==null?void 0:o.feedback)??
3710,questions:((s=r.data)==null?void 0:s.questions)??0}}function xs(){Ua.invalidateQueries({queryKey:["brain-profile"]}),Ua.invalidateQueries({queryKey:["brain-profile-name"]})}async function NP(t){const{data:e,error:n}=await j.from("brain_profiles").select("*").eq("user_id",t).maybeSingle();if(n)throw n;return e??null}async function V1(t){const{data:e,error:n}=await j.from("brain_profiles").select("user_name").eq("user_id",t).maybeSingle();if(n)throw n;return(e==null?void 0:e.user_name)??null}async function jP(t,e){const{error:n}=await j.from("brain_profiles").update(e).eq("user_id",t);if(n)throw n;xs()}async function IP(t){const{error:e}=await j.from("brain_profiles").upsert(t,{onConflict:"user_id"});if(e)throw e;xs()}async function RP(t,e){const{error:n}=await j.from("brain_profiles").update(e).eq("id",t);if(n)throw n;xs()}async function OP(t){const{error:e}=await j.from("brain_profiles").insert(t);if(e)throw e;xs()}async function PP(t){const{data:e,error:n}=await j.from("channel_insights").select("thumbnail_patterns").eq("user_id",t).maybeSingle();if(n)throw n;return(e==null?void 0:e.thumbnail_patterns)??null}async function DP(t,e){const{error:n}=await j.from("channel_insights").upsert({user_id:t,thumbnail_patterns:e,updated_at:new Date().toISOString()},{onConflict:"user_id"});if(n)throw n}async function LP(t){const{count:e,error:n}=await j.from("brain_outlier_titles").select("*",{count:"exact",head:!0}).eq("user_id",t);if(n)throw n;return e??0}async function BP(t){const{error:e}=await j.from("brain_outlier_titles").insert(t);if(e)throw e}const W1=t=>["brain-profile-name",t];function H1(){const{user:t}=St();return Ln({queryKey:W1(t==null?void 0:t.id),queryFn:()=>V1(t.id),enabled:!!t})}async function q1(t){const{data:e,error:n}=await j.from("channel_profiles").select("*").eq("user_id",t).order("created_at",{ascending:!1});if(n)throw n;return e??[]}async function zP(t,e){const{data:n,error:r}=await j.from("channel_profiles").select("*").eq("user_id",t).eq("category",e).order("created_at",{ascending:!1});if(r)throw r;return n??[]}async function FP(t,e){const{data:n,error:r}=await j.from("channel_profiles").select("*").eq("user_id",e).eq("id",t).maybeSingle();if(r)throw r;return n??null}async function $P(t,e,n){const{data:r,error:i}=await j.from("channel_profiles").select("id").eq("user_id",t).eq("category",e).eq("channel_id",n).maybeSingle();if(i)throw i;return(r==null?void 0:r.id)??null}async function VP(t){const{data:e,error:n}=await j.from("channel_profiles").insert(t).select().single();if(n)throw n;return e??null}async function WP(t,e){const{error:n}=await j.from("channel_profiles").update(e).eq("id",t);if(n)throw n}async function HP(t){const{error:e}=await j.from("channel_profiles").delete().eq("id",t);if(e)throw e}async function qP(t){const e=new Date;e.setHours(0,0,0,0);const{count:n,error:r}=await j.from("channel_profiles").select("id",{count:"exact",head:!0}).eq("user_id",t).eq("source","api").gte("created_at",e.toISOString());if(r)throw r;return n??0}async function U1(t){const e={count:"exact",head:!0},[n,r,i,o]=await Promise.all([j.from("channel_profiles").select("id",e).eq("user_id",t).eq("category","niche"),j.from("channel_profiles").select("id",e).eq("user_id",t).eq("category","adjacent"),j.from("vision_board_videos").select("video_url").eq("user_id",t).in("board_name",["Video Bank","Research Vision Board","Niche Research Vision Board","Adjacent Niche Vision Board","Channel Audit Vision Board"]).eq("board_type","vision").in("content_type",["video","image"]),j.from("vision_board_videos").select("id",e).eq("user_id",t).eq("board_name","Idea Bank").eq("board_type","polished").eq("content_type","title")]),s=i.data??[],a=new Set(s.map(l=>l.video_url)).size;return{niche:n.count??0,adjacent:r.count??0,videoBank:a,titleBank:o.count??0}}async function UP(t,e,n){const{data:r,error:i}=await j.from("channel_research_sessions").select("*").eq("user_id",t).eq("status","complete").in("research_type",e).order("created_at",{ascending:!1}).limit(n);if(i)throw i;return r??[]}async function KP(t){const{data:e,error:n}=await j.from("channel_research_sessions").select("*").eq("id",t).single();if(n)throw n;return e??null}async function YP(t){const{error:e}=await j.from("channel_research_sessions").delete().eq("id",t);if(e)throw e}async function JP(t){const{data:e,error:n}=await j.from("channel_research_sessions").insert(t).select().single();if(n)throw n;return e}async function GP(t,e){const{error:n}=await j.from("channel_research_sessions").update(e).eq("id",t);if(n)throw n}async function QP(t,e){const{error:n}=await j.from("channel_research_sessions").update(e).eq("id",t);n&&Ge(n,{eventName:"ResearchSessionWriteError",source:"client-error",operationName:"updateResearchSessionQuiet"})}async function XP(t){const{error:e}=await j.from("vision_board_videos").delete().eq("id",t);e&&Ge(e,{eventName:"VisionBoardVideoWriteError",source:"client-error",operationName:"deleteVisionBoardVideoQuiet"})}async function ZP(t,e,n){const r=j.from("vision_board_videos").select("id, title, thumbnail,
vendor: 12,492 bytes, line 371
371channel, video_url, created_at, notes").eq("user_id",t).eq("board_name",e).eq("content_type","video"),i=n.sessionId?n.section==="audit"?r.eq("notes",n.sessionId):r.or(`notes.eq.${n.sessionId},notes.is.null`):r,{data:o,error:s}=await i.order("created_at",{ascending:!1});if(s)throw s;return o??[]}async function eD(t){const e=t.video_url?j.from("vision_board_videos").upsert(t,{onConflict:"user_id,board_name,board_type,video_url",ignoreDuplicates:!0}):j.from("vision_board_videos").insert(t),{error:n}=await e;if(n)throw n}async function tD(t){const e=t.video_url?j.from("vision_board_videos").upsert(t,{onConflict:"user_id,board_name,board_type,video_url",ignoreDuplicates:!0}):j.from("vision_board_videos").insert(t),{error:n}=await e;n&&Ge(n,{eventName:"VisionBoardVideoWriteError",source:"client-error",operationName:"insertVisionBoardVideoQuiet"})}const K1={niche:0,adjacent:0,videoBank:0,titleBank:0},Y1=t=>["research-nav-counts",t];function J1(t){const{user:e}=St(),{data:n}=Ln({queryKey:Y1(e==null?void 0:e.id),queryFn:()=>U1(e.id),enabled:!!e&&t,staleTime:0});return n??K1}var su=1,G1=.9,Q1=.8,X1=.17,Qs=.1,Xs=.999,Z1=.9999,ew=.99,tw=/[\\\/_+.#"@\[\(\{&]/,nw=/[\\\/_+.#"@\[\(\{&]/g,rw=/[\s-]/,Tp=/[\s-]/g;function Ga(t,e,n,r,i,o,s){if(o===e.length)return i===t.length?su:ew;var a=`${i},${o}`;if(s[a]!==void 0)return s[a];for(var l=r.charAt(o),c=n.indexOf(l,i),u=0,h,p,f,m;c>=0;)h=Ga(t,e,n,r,c+1,o+1,s),h>u&&(c===i?h*=su:tw.test(t.charAt(c-1))?(h*=Q1,f=t.slice(i,c-1).match(nw),f&&i>0&&(h*=Math.pow(Xs,f.length))):rw.test(t.charAt(c-1))?(h*=G1,m=t.slice(i,c-1).match(Tp),m&&i>0&&(h*=Math.pow(Xs,m.length))):(h*=X1,i>0&&(h*=Math.pow(Xs,c-i))),t.charAt(c)!==e.charAt(o)&&(h*=Z1)),(h<Qs&&n.charAt(c-1)===r.charAt(o+1)||r.charAt(o+1)===r.charAt(o)&&n.charAt(c-1)!==r.charAt(o))&&(p=Ga(t,e,n,r,c+1,o+2,s),p*Qs>h&&(h=p*Qs)),h>u&&(u=h),c=n.indexOf(l,c+1);return s[a]=u,u}function au(t){return t.toLowerCase().replace(Tp," ")}function iw(t,e,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Ga(t,e,au(t),au(e),0,0,{})}var Zr='[cmdk-group=""]',Zs='[cmdk-group-items=""]',ow='[cmdk-group-heading=""]',_p='[cmdk-item=""]',lu=`${_p}:not([aria-disabled="true"])`,Qa="cmdk-item-select",vr="data-value",sw=(t,e,n)=>iw(t,e,n),Ap=y.createContext(void 0),Ui=()=>y.useContext(Ap),Mp=y.createContext(void 0),Jl=()=>y.useContext(Mp),Np=y.createContext(void 0),jp=y.forwardRef((t,e)=>{let n=kr(()=>{var R,w;return{search:"",value:(w=(R=t.value)!=null?R:t.defaultValue)!=null?w:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=kr(()=>new Set),i=kr(()=>new Map),o=kr(()=>new Map),s=kr(()=>new Set),a=Ip(t),{label:l,children:c,value:u,onValueChange:h,filter:p,shouldFilter:f,loop:m,disablePointerSelection:g=!1,vimBindings:x=!0,...b}=t,E=er(),v=er(),A=er(),_=y.useRef(null),S=yw();ar(()=>{if(u!==void 0){let R=u.trim();n.current.value=R,N.emit()}},[u]),ar(()=>{S(6,H)},[]);let N=y.useMemo(()=>({subscribe:R=>(s.current.add(R),()=>s.current.delete(R)),snapshot:()=>n.current,setState:(R,w,J)=>{var te,B,X,ne;if(!Object.is(n.current[R],w)){if(n.current[R]=w,R==="search")O(),P(),S(1,T);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ue=document.getElementById(A);ue?ue.focus():(te=document.getElementById(E))==null||te.focus()}if(S(7,()=>{var ue;n.current.selectedItemId=(ue=D())==null?void 0:ue.id,N.emit()}),J||S(5,H),((B=a.current)==null?void 0:B.value)!==void 0){let ue=w??"";(ne=(X=a.current).onValueChange)==null||ne.call(X,ue);return}}N.emit()}},emit:()=>{s.current.forEach(R=>R())}}),[]),M=y.useMemo(()=>({value:(R,w,J)=>{var te;w!==((te=o.current.get(R))==null?void 0:te.value)&&(o.current.set(R,{value:w,keywords:J}),n.current.filtered.items.set(R,L(w,J)),S(2,()=>{P(),N.emit()}))},item:(R,w)=>(r.current.add(R),w&&(i.current.has(w)?i.current.get(w).add(R):i.current.set(w,new Set([R]))),S(3,()=>{O(),P(),n.current.value||T(),N.emit()}),()=>{o.current.delete(R),r.current.delete(R),n.current.filtered.items.delete(R);let J=D();S(4,()=>{O(),(J==null?void 0:J.getAttribute("id"))===R&&T(),N.emit()})}),group:R=>(i.current.has(R)||i.current.set(R,new Set),()=>{o.current.delete(R),i.current.delete(R)}),filter:()=>a.current.shouldFilter,label:l||t["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:E,inputId:A,labelId:v,listInnerRef:_}),[]);function L(R,w){var J,te;let B=(te=(J=a.current)==null?void 0:J.filter)!=null?te:sw;return R?B(R,n.current.search,w):0}function P(){if(!n.current.search||a.current.shouldFilter===!1)return;let R=n.current.filtered.items,w=[];n.current.filtered.groups.forEach(te=>{let B=i.current.get(te),X=0;B.forEach(ne=>{let ue=R.get(ne);X=Math.max(ue,X)}),w.push([te,X])});let J=_.current;z().sort((te,B)=>{var X,ne;let ue=te.getAttribute("id"),je=B.getAttribute("id");return((X=R.get(je))!=null?X:0)-((ne=R.get(ue))!=null?ne:0)}).forEach(te=>{let B=te.closest(Zs);B?B.appendChild(te.parentElement===B?te:te.closest(`${Zs} > *`)):J.appendChild(te.parentElement===J?te:te.closest(`${Zs} > *`))}),w.sort((te,B)=>B[1]-te[1]).forEach(te=>{var B;let X=(B=_.current)==null?void 0:B.querySelector(`${Zr}[${vr}="${encodeURIComponent(te[0])}"]`);X==null||X.parentElement.appendChild(X)})}function T(){let R=z().find(J=>J.getAttribute("aria-disabled")!=="true"),w=R==null?void 0:R.getAttribute(vr);N.setState("value",w||void 0)}function O(){var R,w,J,te;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let B=0;for(let X of r.current){let ne=(w=(R=o.current.get(X))==null?void 0:R.value)!=null?w:"",ue=(te=(J=o.current.get(X))==null?void 0:J.keywords)!=null?te:[],je=L(ne,ue);n.current.filtered.items.set(X,je),je>0&&B++}for(let[X,ne]of i.current)for(let ue of ne)if(n.current.filtered.items.get(ue)>0){n.current.filtered.groups.add(X);break}n.current.filtered.count=B}function H(){var R,w,J;let te=D();te&&(((R=te.parentElement)==null?void 0:R.firstChild)===te&&((J=(w=te.closest(Zr))==null?void 0:w.querySelector(ow))==null||J.scrollIntoView({block:"nearest"})),te.scrollIntoView({block:"nearest"}))}function D(){var R;return(R=_.current)==null?void 0:R.querySelector(`${_p}[aria-selected="true"]`)}function z(){var R;return Array.from(((R=_.current)==null?void 0:R.querySelectorAll(lu))||[])}function ee(R){let w=z()[R];w&&N.setState("value",w.getAttribute(vr))}function Q(R){var w;let J=D(),te=z(),B=te.findIndex(ne=>ne===J),X=te[B+R];(w=a.current)!=null&&w.loop&&(X=B+R<0?te[te.length-1]:B+R===te.length?te[0]:te[B+R]),X&&N.setState("value",X.getAttribute(vr))}function F(R){let w=D(),J=w==null?void 0:w.closest(Zr),te;for(;J&&!te;)J=R>0?mw(J,Zr):gw(J,Zr),te=J==null?void 0:J.querySelector(lu);te?N.setState("value",te.getAttribute(vr)):Q(R)}let V=()=>ee(z().length-1),k=R=>{R.preventDefault(),R.metaKey?V():R.altKey?F(1):Q(1)},pe=R=>{R.preventDefault(),R.metaKey?ee(0):R.altKey?F(-1):Q(-1)};return y.createElement(wn.div,{ref:e,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:R=>{var w;(w=b.onKeyDown)==null||w.call(b,R);let J=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||J))switch(R.key){case"n":case"j":{x&&R.ctrlKey&&k(R);break}case"ArrowDown":{k(R);break}case"p":case"k":{x&&R.ctrlKey&&pe(R);break}case"ArrowUp":{pe(R);break}case"Home":{R.preventDefault(),ee(0);break}case"End":{R.preventDefault(),V();break}case"Enter":{R.preventDefault();let te=D();if(te){let B=new Event(Qa);te.dispatchEvent(B)}}}}},y.createElement("label",{"cmdk-label":"",htmlFor:M.inputId,id:M.labelId,style:bw},l),bs(t,R=>y.createElement(Mp.Provider,{value:N},y.createElement(Ap.Provider,{value:M},R))))}),aw=y.forwardRef((t,e)=>{var n,r;let i=er(),o=y.useRef(null),s=y.useContext(Np),a=Ui(),l=Ip(t),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:s==null?void 0:s.forceMount;ar(()=>{if(!c)return a.item(i,s==null?void 0:s.id)},[c]);let u=Rp(i,o,[t.value,t.children,o],t.keywords),h=Jl(),p=Pn(S=>S.value&&S.value===u.current),f=Pn(S=>c||a.filter()===!1?!0:S.search?S.filtered.items.get(i)>0:!0);y.useEffect(()=>{let S=o.current;if(!(!S||t.disabled))return S.addEventListener(Qa,m),()=>S.removeEventListener(Qa,m)},[f,t.onSelect,t.disabled]);function m(){var S,N;g(),(N=(S=l.current).onSelect)==null||N.call(S,u.current)}function g(){h.setState("value",u.current,!0)}if(!f)return null;let{disabled:x,value:b,onSelect:E,forceMount:v,keywords:A,..._}=t;return y.createElement(wn.div,{ref:vi(o,e),..._,id:i,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!p,"data-disabled":!!x,"data-selected":!!p,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:m},t.children)}),lw=y.forwardRef((t,e)=>{let{heading:n,children:r,forceMount:i,...o}=t,s=er(),a=y.useRef(null),l=y.useRef(null),c=er(),u=Ui(),h=Pn(f=>i||u.filter()===!1?!0:f.search?f.filtered.groups.has(s):!0);ar(()=>u.group(s),[]),Rp(s,a,[t.value,t.heading,l]);let p=y.useMemo(()=>({id:s,forceMount:i}),[i]);return y.createElement(wn.div,{ref:vi(a,e),...o,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&y.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),bs(t,f=>y.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},y.createElement(Np.Provider,{value:p},f))))}),cw=y.forwardRef((t,e)=>{let{alwaysRender:n,...r}=t,i=y.useRef(null),o=Pn(s=>!s.search);return!n&&!o?null:y.createElement(wn.div,{ref:vi(i,e),...r,"cmdk-separator":"",role:"separator"})}),uw=y.forwardRef((t,e)=>{let{onValueChange:n,...r}=t,i=t.value!=null,o=Jl(),s=Pn(c=>c.search),a=Pn(c=>c.selectedItemId),l=Ui();return y.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),y.createElement(wn.input,{ref:e,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:i?t.value:s,onChange:c=>{i||o.setState("search",c.target.value),n==null||n(c.target.value)}})}),dw=y.forwardRef((t,e)=>{let{children:n,label:r="Suggestions",...i}=t,o=y.useRef(null),s=y.useRef(null),a=Pn(c=>c.selectedItemId),l=Ui();return y.useEffect(()=>{if(s.current&&o.current){let c=s.current,u=o.current,h,p=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;u.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return p.observe(c),()=>{cancelAnimationFrame(h),p.unobserve(c)}}},[]),y.createElement(wn.div,{ref:vi(o,e),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},bs(t,c=>y.createElement("div",{ref:vi(s,l.listInnerRef),"cmdk-list-sizer":""},c)))}),hw=y.forwardRef((t,e)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:o,container:s,...a}=t;return y.createElement(cs,{open:n,onOpenChange:r},y.createElement(ls,{container:s},y.createElement(qr,{"cmdk-overlay":"",className:i}),y.createElement(Ur,{"aria-label":t.label,"cmdk-dialog":"",className:o},y.createElement(jp,{ref:e,...a}))))}),fw=y.forwardRef((t,e)=>Pn(n=>n.filtered.count===0)?y.createElement(wn.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),pw=y.forwardRef((t,e)=>{let{progress:n,children:r,label:i="Loading...",...o}=t;return y.createElement(wn.div,{ref:e,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},bs(t,s=>y.createElement("div",{"aria-hidden":!0},s)))}),Ot=Object.assign(jp,{List:dw,Item:aw,Input:uw,Group:lw,Separator:cw,Dialog:hw,Empty:fw,Loading:pw});function mw(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function gw(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}function Ip(t){let e=y.useRef(t);return ar(()=>{e.current=t}),e}var ar=typeof window>"u"?y.useEffect:y.useLayoutEffect;function kr(t){let e=y.useRef();return e.current===void 0&&(e.current=t()),e}function Pn(t){let e=Jl(),n=()=>t(e.snapshot());return y.useSyncExternalStore(e.subscribe,n,n)}function Rp(t,e,n,r=[]){let i=y.useRef(),o=Ui();return ar(()=>{var s;let a=(()=>{var c;for(let u of n){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(c=u.current.textContent)==null?void 0:c.trim():i.current}})(),l=r.map(c=>c.trim());o.value(t,a,l),(s=e.current)==null||s.setAttribute(vr,a),i.current=a}),i}var yw=()=>{let[t,e]=y.useState(),n=kr(()=>new Map);return ar(()=>{n.current.forEach(r=>
371r()),n.current=new Map},[t]),(r,i)=>{n.current.set(r,i),e({})}};function xw(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function bs({asChild:t,children:e},n){return t&&y.isValidElement(e)?y.cloneElement(xw(e),{ref:e.ref},n(e.props.children)):n(e)}var bw={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Gl=cs,nD=Xh,ww=ls,Op=y.forwardRef(({className:t,...e},n)=>d.jsx(qr,{ref:n,className:Ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));Op.displayName=qr.displayName;const ws=y.forwardRef(({className:t,children:e,...n},r)=>d.jsxs(ww,{children:[d.jsx(Op,{}),d.jsxs(Ur,{ref:r,className:Ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[e,d.jsxs(Qh,{className:"absolute right-4 top-4 roun
371ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[d.jsx(Bn,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ws.displayName=Ur.displayName;const vs=({className:t,...e})=>d.jsx("div",{className:Ne("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});vs.displayName="DialogHeader";const vw=({className:t,...e})=>d.jsx("div",{className:Ne("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});vw.displayName="DialogFooter";const ks=y.forwardRef(({className:t,...e},n)=>d.jsx(Fi,{ref:n,className:Ne("text-lg font-semibold leading-none tracking-tight",t),...e}));ks.displayName=Fi.displayName;const kw=y.forwardRef(({className:t,...e},n)=>d.jsx($i,{ref:n,className:Ne("text-sm text-muted-foreground",t),...e}));kw.displayName=$i.displayName;const Pp=y.forwardRef(({className:t,...e},n)=>d.jsx(Ot,{ref:n,className:Ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e}));Pp.displayName=Ot.displayName;const Dp=y.forwardRef(({className:t,...e},n)=>d.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[d.jsx(Ei,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),d.jsx(Ot.Input,{ref:n,className:Ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...e})]}));Dp.displayName=Ot.Input.displayName;const Lp=y.forwardRef(({className:t,...e},n)=>d.jsx(Ot.List,{ref:n,className:Ne("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...e}));Lp.displayName=Ot.List.displayName;const Bp=y.forwardRef((t,e)=>d.jsx(Ot.Empty,{ref:e,className:"py-6 text-center text-sm",...t}));Bp.displayName=Ot.Empty.displayName;const To=y.forwardRef(({className:t,...e},n)=>d.jsx(Ot.Group,{ref:n,className:Ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...e}));To.displayName=Ot.Group.displayName;const Sw=y.forwardRef(({className:t,...e},n)=>d.jsx(Ot.Separator,{ref:n,className:Ne("-mx-1 h-px bg-border",t),...e}));Sw.displayName=Ot.Separator.displayName;const _o=y.forwardRef(({className:t,...e},n)=>d.jsx(Ot.Item,{ref:n,className:Ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",t),...e}));_o.displayName=Ot.Item.displayName;const Cw=t=>["projects",t],Ew="id, user_id, title, current_stage, completed_stages, completed_at, goal, ideation_pathway, planner_type, source_outlier_id, video_url, metrics, sort_order, created_at, updated_at, workflow_version";async function Tw(){var r;const t=()=>j.from("projects").select(Ew).order("updated_at",{ascending:!1});let{data:e,error:n}=await t();if(n&&(n.code==="PGRST301"||(r=n.message)!=null&&r.includes("JWT"))){const{error:i}=await j.auth.refreshSession();i||({data:e,error:n}=await t())}if(n)throw n;return e??[]}function _w(){const{user:t}=St();return Ln({queryKey:Cw(t==null?void 0:t.id),queryFn:Tw,enabled:!!t})}const Aw=t=>["channel-profiles",t];function Mw(){const{user:t}=St();return Ln({queryKey:Aw(t==null?void 0:t.id),queryFn:()=>q1(t.id),enabled:!!t,staleTime:0})}const zp=y.createContext(null);function Nw(){const t=y.useContext(zp);if(!t)throw new Error("useCommandPalette must be used within a CommandPaletteProvider");return t}function jw(t){const e=t;if(!e)return!1;const n=e.tagName;return n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||e.isContentEditable===!0}function Iw({children:t}){const[e,n]=y.useState(!1),r=y.useCallback(()=>n(!0),[]);return y.useEffect(()=>{e||(document.body.style.pointerEvents="")},[e]),y.useEffect(()=>{const i=o=>
371{if((o.metaKey||o.ctrlKey)&&(o.key==="k"||o.key==="K")){o.preventDefault(),n(s=>!s);return}o.key==="/"&&!o.metaKey&&!o.ctrlKey&&!o.altKey&&!jw(o.target)&&(o.preventDefault(),n(!0))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[]),d.jsxs(zp.Provider,{value:{openPalette:r},children:[t,d.jsx(Ow,{open:e,onOpenChange:n})]})}const Rw=[{label:"Videos",to:C.videos,icon:Ci},{label:"Onboarding",to:C.onboarding,icon:Tf},{label:"Niche Research",to:C.research+"?tab=research",icon:Af},{label:"Adjacent Niche",to:C.research+"?tab=adjacent",icon:Sf},{label:"Your Channel",to:C.research+"?tab=audit",icon:zo},{label:"Video Bank",to:C.research+"?tab=video-bank",icon:Ci},{label:"Title Bank",to:C.research+"?tab=title-bank",icon:Mf},{label:"The Brain · Viewer Profile",to:C.brainData,icon:us},{label:"The Brain · My Outliers",to:C.brainData+"?tab=outliers",icon:Vl},{label:"The Brain · Research Insights",to:C.brainData+"?tab=research",icon:Ei},{label:"The Brain · Lessons Learned",to:C.brainData+"?tab=lessons",icon:$a},{label:"AI Coach",to:C.aiAssistant,icon:Wi},{label:"Academy",to:At.course,icon:Cf},{label:"Hire a Human",to:C.hireHuman,icon:Nf},{label:"Account Settings",to:C.account,icon:_f},{label:"YouTube Channel",to:C.account+"?tab=youtube",icon:zo},{label:"Change Password",to:C.account+"?tab=password",icon:Ef},{label:"Notifications",to:C.account+"?tab=notifications",icon:Ll},{label:"Support",to:C.myTickets,icon:Bl}],ei=[{id:"all",label:"All"},{id:"pages",label:"Pages"},{id:"projects",label:"Projects"},{id:"research",label:"Research"}];function Ow({open:t,onOpenChange:e}){return d.jsx(cs,{open:t,onOpenChange:e,children:d.jsxs(ls,{children:[d.jsx(qr,{className:"fixed inset-0 z-[100] bg-black/70 backdrop-blur-sm data-[state=open]:animate-in data-[state=open]:fade-in-0"}),d.jsxs(Ur,{className:"fixed left-1/2 top-[12%] z-[101] w-[92vw] max-w-[600px] -translate-x-1/2 overflow-hidden data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 focus:outline-none",style:{background:"var(--bg-medium)",border:"1px solid var(--border-soft)",borderRadius:14,boxShadow:"0 24px 60px rgba(0,0,0,0.30)"},children:[d.jsx(Fi,{className:"sr-only",children:"Search"}),d.jsx($i,{className:"sr-only",children:"Search pages, projects and research. Use arrow keys to navigate, Enter to open."}),t&&d.jsx(Pw,{onClose:()=>e(!1)})]})]})})}const oo=6;function Pw({onClose:t}){const e=qy(),[n,r]=y.useState("all"),[i,o]=y.useState(""),{data:s=[]}=_w(),{data:a=[]}=Mw(),l=i.trim().length>0,c=l?s:s.slice(0,oo),u=l?a:a.slice(0,oo),h=!l&&s.length>oo?"Projects · recent":"Projects",p=!l&&a.length>oo?"Research · recent":"Research",f=y.useCallback(b=>{t(),setTimeout(()=>e(b),0)},[e,t]),m=y.useCallback(b=>{r(E=>{const A=(ei.findIndex(_=>_.id===E)+b+ei.length)%ei.length;return ei[A].id})},[]),g=b=>{b.key==="Tab"&&(b.preventDefault(),m(b.shiftKey?-1:1))},x=b=>n==="all"||n===b;return d.jsxs(Pp,{loop:!0,className:"bg-transparent",style:{color:"var(--text-primary)"},children:[d.jsxs("div",{style:{position:"relative"},children:[d.jsx(Dp,{autoFocus:!0,value:i,onValueChange:o,placeholder:"Search pages, projects, researchâ¦",onKeyDown:g,className:"pr-9"}),d.jsx("button",{type:"button","aria-label":"Close search",onClick:t,style:{position:"absolute",right:12,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:5,border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer"},onMouseEnter:b=>b.currentTarget.style.color="var(--text-primary)",onMouseLeave:b=>b.currentTarget.style.color="var(--text-muted)",children:d.jsx(Bn,{style:{width:15,height:15}})})]}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"10px 12px",borderBottom:"1px solid var(--border-soft)"},children:[ei.map(b=>{const E=n===b.id;return d.jsx("button",{type:"button",onClick:()=>r(b.id),style:{fontSize:12.5,fontWeight:600,padding:"4px 11px",borderRadius:999,border:"none",cursor:"pointer",background:E?"var(--accent-soft)":"transparent",color:E?"var(--accent)":"var(--text-muted)",transition:"background 0.15s, color 0.15s"},children:b.label},b.id)}),d.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted)"},children:[d.jsx(yr,{children:"Tab"})," to switch"]})]}),d.jsxs(Lp,{style:{maxHeight:360},children:[d.jsx(Bp,{children:d.jsx("span",{style:{color:"var(--text-muted)"},children:"No results found"})}),x("pages")&&d.jsx(To,{heading:"Pages",children:Rw.map(b=>{const E=b.icon;return d.jsxs(_o,{value:`page ${b.label} ${b.to}`,onSelect:()=>f(b.to),className:"gap-2.5",children:[d.jsx(E,{style:{width:16,height:16,color:"var(--text-muted)"}}),d.jsx("span",{style:{fontSize:13.5},children:b.label})]},b.to)})}),x("projects")&&c.length>0&&d.jsx(To,{heading:h,children:c.map(b=>d.jsxs(_o,{value:`project ${b.title} ${b.id}`,onSelect:()=>f(Co.project(b.id)),className:"gap-2.5",children:[d.jsx(Ci,{style:{width:16,height:16,color:"var(--text-muted)"}}),d.jsx("span",{style:{fontSize:13.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.title||"Untitled project"}),d.jsx("span",{style:{marginLeft:"auto",paddingLeft:12,fontSize:11.5,color:"var(--text-muted)",flexShrink:0},children:(b.updated_at??"").slice(0,10)})]},b.id))}),x("research")&&u.length>0&&d.jsx(To,{heading:p,children:u.map(b=>{const E=String(b.category??"").toLowerCase().includes("adjacent")||Str
371ing(b.source??"").toLowerCase().includes("adjacent"),v=C.research+(E?"?tab=adjacent":"?tab=research");return d.jsxs(_o,{value:`research ${b.channel_name} ${b.id}`,onSelect:()=>f(v),className:"gap-2.5",children:[d.jsx(Ar,{style:{width:16,height:16,color:"var(--text-muted)"}}),d.jsx("span",{style:{fontSize:13.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.channel_name}),d.jsx("span",{style:{marginLeft:"auto",paddingLeft:12,fontSize:11.5,color:"var(--text-muted)",flexShrink:0,textTransform:"capitalize"},children:E?"Adjacent":"Niche"})]},b.id)})})]}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"9px 14px",borderTop:"1px solid var(--border-soft)",fontSize:11.5,color:"var(--text-muted)"},children:[d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[d.jsx(yr,{children:d.jsx(Px,{style:{width:11,height:11}})}),d.jsx(yr,{children:d.jsx(Ox,{style:{width:11,height:11}})}),"Navigate"]}),d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[d.jsx(yr,{children:d.jsx(zl,{style:{width:11,height:11}})}),"Open"]}),d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[d.jsx(yr,{children:"Tab"}),"Filter"]}),d.jsxs("span",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:5},children:[d.jsx(yr,{children:"Esc"}),"Close"]})]})]})}function yr({children:t}){return d.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:18,height:18,padding:"0 5px",borderRadius:4,background:"var(--bg-light)",border:"1px solid var(--border-soft)",color:"var(--text-secondary)",fontSize:10.5,fontWeight:600,lineHeight:1},children:t})}const Fp=y.forwardRef(({className:t,...e},n)=>d.jsx(Zh,{ref:n,className:Ne("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...e}));Fp.displayName=Zh.displayName;const Dw=y.forwardRef(({className:t,...e},n)=>d.jsx(ef,{ref:n,className:Ne("aspect-square h-full w-full",t),...e}));Dw.displayName=ef.displayName;const $p=y.forwardRef(({className:t,...e},n)=>d.jsx(tf,{ref:n,className:Ne("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...e}));$p.displayName=tf.displayName;const Vp=[{id:"videos",icon:Ci,label:"Videos",to:C.videos,feature:"videos"},{id:"research",icon:Ar,label:"Research",to:C.research,feature:"research"},{id:"brain",icon:us,label:"The Brain",to:C.brainData,feature:"brain"},{id:"aicoach",icon:Wi,label:"AI Coach",to:C.aiAssistant,feature:"ai_coach"},{id:"livereviews",icon:jf,label:"Live Reviews",to:C.liveReviews,feature:"live_reviews"},{id:"academy",icon:Cf,label:"Academy",to:At.course,feature:"academy"},{id:"community",icon:Nf,label:"Hire a Human",to:C.hireHuman,feature:"hire_human"},{id:"earnmore",icon:Vl,label:"Earn more",to:C.launchRoom},{id:"launchroom",icon:Tf,label:"Launch Room",to:C.cohortRecordings,feature:"cohort",hideWhenLocked:!0},{id:"affiliate",icon:Kx,label:"Affiliate",to:C.affiliateDashboard,feature:"affiliate",hideWhenLocked:!0},{id:"freetools",icon:sb,label:"Free Library",to:C.freeTools,feature:"free_tools"}];function cu(t){return"type"in t&&t.type==="separator"}function uu(t){return"type"in t&&t.type==="subgroup"}const Ao={research:[{type:"separator",label:"Channel Sources"},{label:"Niche Research",to:C.research+"?tab=research",icon:Af,feature:"research",isDefault:!0,matchTab:"research",countKey:"niche"},{label:"Adjacent Niche",to:C.research+"?tab=adjacent",icon:Sf,feature:"research",matchTab:"adjacent",countKey:"adjacent"},{label:"Research Video",to:C.research+"?tab=research-video",icon:fb,feature:"research",matchTab:"research-video",adminOnly:!0},{label:"Your Channel",to:C.research+"?tab=audit",icon:zo,feature:"research",matchTab:"audit"},{type:"separator",label:"Banks"},{label:"Video Bank",to:C.research+"?tab=video-bank",icon:Ci,feature:"research",matchTab:"video-bank",countKey:"videoBank"},{label:"Title Bank",to:C.research+"?tab=title-bank",icon:Mf,feature:"research",matchTab:"title-bank",countKey:"titleBank"},{label:"Pattern Bank",to:C.research+"?tab=pattern-bank",icon:rb,feature:"research",matchTab:"pattern-bank",adminOnly:!0},{label:"Boards",to:C.research+"?tab=boards",icon:Jx,feature:"research",matchTab:"boards"}],brain:[{type:"separator",label:"The Brain",asTitle:!0},{label:"Viewer Profile",to:C.brainData,icon:Vx,feature:"brain"},{label:"My Outliers",to:C.brainData+"?tab=outliers",icon:Vl,feature:"brain"},{label:"Research Insights",to:C.brainData+"?tab=research",icon:Ei,feature:"brain"},{label:"Lessons Learned",to:C.brainData+"?tab=lessons",icon:$a,feature:"brain"}],launchroom:[{type:"separator",label:"Launch Room",asTitle:!0},{label:"Workshops",to:C.cohortRecordings,icon:$x,feature:"cohort",hideWhenLocked:!0,isDefault:!0,dotKey:"cohortQuestions"},{label:"Assignments",to:C.cohortAssignments,icon:Wx,feature:"cohort",hideWhenLocked:!0,dotKey:"cohortFeedback"},{label:"Community",to:C.cohortCommunity,icon:eb,feature:"cohort",hideWhenLocked:!0,dotKey:"cohortReplies"},{type:"separator",label:"Tools",feature:"cohort"},{label:"Funnel Tracker",to:C.cohortFunnelTracker,icon:Dx,feature:"cohort",hideWhenLocked:!0},{type:"separator",label:"Team",feature:"cohort_team"},{label:"Review board",to:C.cohortReviewBoard,icon:Gx,feature:"cohort_team",hideWhenLocked:!0},{label:"Cohort progress",to:C.cohortProgress,icon:ab,feature:"cohort_team",hideWhenLocked:!0},{label:"Weekly setup",to:C.cohortSetup,icon:nb,feature:"cohort_team",hideWhenLocked:!0}],livereviews:[{type:"separator",label:"Live Reviews",asTitle:!0},{label:"Submit",to:C.liveReviews,icon:Hx,feature:"live_reviews",isDefault:!0},{label:"Recordings",to:C.liveReviewsRecordings,icon:ib,feature:"live_reviews"}],academy:[],settings:[{type:"separator",label:"Settings"},{label:"Account Settings",to:C.account,icon:_f},{label:"Usage",to:C.account+"?tab=usage",icon:Rx},{label:"YouTube Channel",to:C.account+"?tab=youtube",icon:zo},{label:"Change Password",to:C.account+"?tab=password",icon:Ef},{type:"separator"},{label:"Resources",to:C.resources,icon:$a,feature:"resources",hideWhenLocked:!0},{label:"Notifications",to:C.account+"?tab=notifications",icon:Ll},{type:"separator",label:"Legal & Policies"},{label:"Privacy Policy",to:C.privacy,icon:$l},{label:"Terms of Service",to:C.terms,icon:Jc},{label:"YouTube Terms of Service",to:C.terms+"?tab=youtube",icon:Jc}]},Lw=[{label:"Masterclasses",tab:"masterclasses"},{label:"Free tools",tab:"tools"},{label:"Special offers",tab:"offers"},{label:"Free live reviews",tab:"reviews"}];function Bw(){var n;const t=It(),e=Wp();return t.pathname.startsWith(At.project+"/")?!1:(((n=Ao[e])==null?void 0:n.length)??0)>0}const zw=[{icon:$l,label:"Admin",to:C.adminRoot,adminOnly:!0},{icon:Bl,label:"Support",to:C.myTickets,feature:"tickets"},{icon:Ll,label:"News & Updates",to:C.account+"?tab=notifications"}],Fw=64,$w=220,ea=200;function Wp(){const t=It();if(t.pathname===C.account||t.pathname===C.privacy||t.pathname===C.terms)return"settings";if(t.pathname.startsWith(At.project+"/"))return"videos";if(t.pathname.startsWith(C.freeTools)||t.pathname.startsWith("/tools/"))return"freetools";if(t.pathname.startsWith("/cohort/"))return"launchroom";const n=Vp.filter(r=>r.to!=="#"&&t.pathname.startsWith(r.to)).sort((r,i)=>i.to.length-r.to.length)[0];return(n==null?void 0:n.id)??"videos"}function Hp(t,e){if(!t.preserveParams||t.preserveParams.length===0)return t.to;const n=t.to.indexOf("?"),r=n===-1?t.to:t.to.slice(0,n),i=new URLSearchParams(n===-1?"":t.to.slice(n+1)),o=new URLSearchParams(e);for(const a of t.preserveParams){const l=o.get(a);l!==null&&i.set(a,l)}const s=i.toString();return s?`${r}?${s}`:r}function du(t,e){const[n,r=""]=t.split("?"),[i,o=""]=e.split("?");if(n!==i)return!1;const s=new URLSearchParams(r),a=new URLSearchParams(o),l=[...s.keys()].sort(),c=[...a.keys()].sort();return l.length!==c.length?!1:l.every((u,h)=>u===c[h]&&s.get(u)===a.get(u))}function qp(t){var r;const e=It(),n=e.pathname+e.search;if(t.matchTab!==void 0){const i=t.to.split("?")[0];if(e.pathname===i){const o=new URLSearchParams(e.search).get("tab")??"";if(o===t.matchTab||t.matchTab==="research"&&o==="")return!0}}return!!(du(n,t.to)||!t.to.includes("?")&&e.pathname===t.to&&!e.search||t.isDefault&&e.pathname===t.to.split("?")[0]&&!e.search||(r=t.activeWhen)!=null&&r.some(i=>du(n,i)))}function fi({size:t=13}){return d.jsx(Qx,{"aria-hidden":!0,style:{width:t,height:t,flexShrink:0,marginLeft:"auto",color:"var(--text-muted)",opacity:.8}})}
371function Vw({item:t,isActive:e,locked:n,onClick:r}){const[i,o]=y.useState(!1),s=t.icon,a=e||i?"var(--bg-medium)":"transparent",l=e?"var(--text-primary)":"var(--text-secondary)",c=e?"var(--text-primary)":"var(--text-muted)";return d.jsxs(qn,{to:n?"#":t.to,onClick:r,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:10,padding:"9px 12px",borderRadius:6,marginBottom:1,background:a,color:n?"var(--text-muted)":l,border:"none",textDecoration:"none",transition:"background 0.15s, color 0.15s",cursor:"pointer",width:"100%",boxSizing:"border-box",flexShrink:0},children:[s&&d.jsx("span",{style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:d.jsx(s,{style:{width:14,height:14,color:c,opacity:n?.5:1}})}),d.jsx("span",{style:{fontSize:13,fontWeight:e?700:500,lineHeight:"15px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.label}),n&&d.jsx(fi,{}),t.dot&&d.jsx("span",{role:"img","aria-label":"Unread updates",style:{marginLeft:"auto",width:7,height:7,borderRadius:99,background:"var(--accent)",flexShrink:0}}),typeof t.count=="number"&&d.jsx("span",{style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:"var(--text-muted)",flexShrink:0},children:t.count})]})}function Ww({item:t,isActive:e,locked:n,onClick:r}){const[i,o]=y.useState(!1),s=t.icon,a=e||i?"var(--bg-light)":"transparent";return d.jsxs(qn,{to:n?"#":t.to,onClick:r,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:4,height:22,padding:"3px 8px",borderRadius:4,background:a,color:e?"var(--accent)":"var(--text-muted)",border:"none",textDecoration:"none",transition:"background 0.15s, color 0.15s",cursor:"pointer",width:"100%",boxSizing:"border-box",flexShrink:0},children:[s&&d.jsx("span",{style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:d.jsx(s,{style:{width:11,height:11,opacity:n?.5:1}})}),d.jsx("span",{style:{fontSize:11,fontWeight:e?600:500,lineHeight:"12px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.label}),n&&d.jsx(fi,{size:11})]})}function Up({label:t,asTitle:e}){return t?e?d.jsx("div",{style:{fontSize:11,fontWeight:700,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"1.5px",padding:"4px 12px 10px",flexShrink:0},children:t}):d.jsx("div",{style:{fontSize:10,fontWeight:700,lineHeight:"12px",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"1.5px",padding:"14px 12px 8px",flexShrink:0},children:t}):d.jsx("div",{style:{height:1,background:"var(--border-soft)",margin:"4px 0",flexShrink:0}})}function Hw({group:t,hasFeature:e,requireFullAccess:n}){return d.jsxs(d.Fragment,{children:[t.label&&d.jsx(Up,{label:t.label}),d.jsx("div",{style:{background:"var(--bg-light)",borderRadius:6,padding:4,display:"flex",flexDirection:"column",gap:1,flexShrink:0},children:t.items.map(r=>{const i=!!(r.feature&&!e(r.feature));return i&&r.hideWhenLocked?null:d.jsx(qw,{item:r,locked:i,requireFullAccess:n},r.label)})})]})}function qw({item:t,locked:e,requireFullAccess:n}){const r=It(),i=t.preserveParams?{...t,to:Hp(t,r.search)}:t,o=qp(i);return d.jsx(Ww,{item:i,isActive:o,locked:e,onClick:s=>{if(e){s.preventDefault(),n(i.label);return}i.action&&(s.preventDefault(),i.action())}})}function Uw({item:t,locked:e,requireFullAccess:n}){const r=It(),i=t.preserveParams?{...t,to:Hp(t,r.search)}:t,o=qp(i);return d.jsx(Vw,{item:i,isActive:o,locked:e,onClick:s=>{if(e){s.preventDefault(),n(i.label);return}i.action&&(s.preventDefault(),i.action())}})}function hu(){const{sidebarCollapsed:t,setSidebarCollapsed:e,toggleSidebar:n,subNavOpen:r,setSubNavOpen:i,projectCompletedStages:o}=ys(),{hasFeature:s,requireFullAccess:a,loading:l}=hr(),{isAdmin:c}=Kl(),{user:u}=St(),h=It(),p=Wp(),{openPalette:f}=Nw(),g=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||"")?"âK":"Ctrl K",{data:x=null}=H1(),b=J1(p==="research"),E=h.pathname.startsWith(At.project+"/")?h.pathname.slice(At.project.length+1):null,v=E?[]:Ao[p]??[],A=$1(),_=T=>T==="cohortReplies"?A.replies>0:T==="cohortFeedback"?A.feedback>0:T==="cohortQuestions"?A.questions>0:!1,S=v.map(T=>{if(cu(T)||uu(T))return T;let O=T;return O.countKey&&(O={...O,count:b[O.countKey]}),O.dotKey&&(O={...O,dot:_(O.dotKey)}),O}),M=S.length>0&&r,L=(T,O)=>{if(T){const H=T.trim().split(/\s+/);return H.length>=2?(H[0][0]+H[H.length-1][0]).toUpperCase():T.slice(0,2).toUpperCase()}return O?O.slice(0,2).toUpperCase():"U"},P=({label:T,children:O})=>t?d.jsxs(y0,{children:[d.jsx(x0,{asChild:!0,children:O}),d.jsx(Kf,{side:"right",sideOffset:8,children:T})]}):O;
371return d.jsx(Uf,{delayDuration:0,children:d.jsxs("div",{className:"flex h-full shrink-0",children:[d.jsxs("div",{className:"flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-out",style:{width:t?Fw:$w,background:"var(--bg-darkest)",borderRight:"1px solid var(--border-soft)"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"12px 8px 10px",gap:8,flexShrink:0},children:[d.jsx("div",{style:{width:24,height:24,borderRadius:"50%",border:"2.5px solid var(--accent)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:d.jsx("div",{style:{width:9,height:9,background:"var(--accent)",borderRadius:"50%"}})}),!t&&d.jsx("span",{style:{fontSize:16,fontWeight:700,letterSpacing:"-0.4px",color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1},children:"StoryOS"}),d.jsx("button",{onClick:n,"aria-label":t?"Expand sidebar":"Collapse sidebar",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,borderRadius:5,border:"1px solid var(--border-soft)",background:"transparent",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.15s, border-color 0.15s, color 0.15s",fontFamily:"inherit",marginLeft:t?"auto":0},onMouseEnter:T=>{const O=T.currentTarget;O.style.background="var(--bg-medium)",O.style.borderColor="var(--border)",O.style.color="var(--text-primary)"},onMouseLeave:T=>{const O=T.currentTarget;O.style.background="transparent",O.style.borderColor="var(--border-soft)",O.style.color="var(--text-muted)"},children:t?d.jsx(Bx,{style:{width:13,height:13}}):d.jsx(Lx,{style:{width:13,height:13}})})]}),d.jsx("div",{style:{padding:t?"0 8px 10px":"0 10px 10px",flexShrink:0},children:t?d.jsx(P,{label:`Search (${g})`,children:d.jsx("button",{onClick:f,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:32,borderRadius:6,border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",transition:"background 0.15s, color 0.15s",fontFamily:"inherit"},onMouseEnter:T=>{T.currentTarget.style.background="var(--bg-light)",T.currentTarget.style.color="var(--text-primary)"},onMouseLeave:T=>{T.currentTarget.style.background="transparent",T.currentTarget.style.color="var(--text-muted)"},children:d.jsx(Ei,{style:{width:15,height:15}})})}):d.jsxs("button",{type:"button",onClick:f,style:{position:"relative",display:"flex",alignItems:"center",gap:8,width:"100%",boxSizing:"border-box",background:"var(--bg-light)",border:"1px solid var(--border-soft)",borderRadius:6,padding:"7px 8px 7px 28px",color:"var(--text-muted)",fontSize:13,fontWeight:500,fontFamily:"inherit",cursor:"pointer",textAlign:"left",transition:"border-color 0.15s"},onMouseEnter:T=>T.currentTarget.style.borderColor="var(--border)",onMouseLeave:T=>T.currentTarget.style.borderColor="var(--border-soft)",children:[d.jsx(Ei,{style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)",width:12,height:12,color:"var(--text-muted)",pointerEvents:"none"}}),d.jsx("span",{style:{flex:1},children:"Search"}),d.jsx("span",{style:{flexShrink:0,padding:"1px 6px",borderRadius:4,background:"var(--bg-medium)",border:"1px solid var(--border-soft)",color:"var(--text-muted)",fontSize:10.5,fontWeight:600,lineHeight:"15px"},children:g})]})}),d.jsx("nav",{style:{flex:1,overflowY:"auto",padding:"0 8px",display:"flex",flexDirection:"column",gap:2},children:Vp.filter(T=>!T.adminOnly||c).filter(T=>!(T.hideWhenLocked&&T.feature!=null&&(l||!s(T.feature)))).map(T=>{const O=T.icon,H=p===T.id,D=T.comingSoon||T.feature!=null&&!s(T.feature),z=d.jsxs(qn,{to:D?"#":T.to,onClick:Q=>{if(T.comingSoon){Q.preventDefault();return}if(D&&!T.comingSoon){Q.preventDefault(),a(T.label);return}t?Ao[T.id]?i(!0):e(!1):Ao[T.id]&&(e(!0),i(!0))},style:{display:"flex",alignItems:"center",gap:10,height:36,minHeight:36,flexShrink:0,padding:t?"0":"0 10px",justifyContent:t?"center":"flex-start",borderRadius:6,textDecoration:"none",transition:"background 0.15s, color 0.15s",cursor:"pointer",opacity:T.comingSoon?.45:1,background:H?"var(--bg-medium)":"transparent",color:D?"var(--text-muted)":H?"var(--text-primary)":"var(--text-secondary)",width:"100%",boxSizing:"border-box"},onMouseEnter:Q=>{if(H)return;const F=Q.currentTarget;F.style.background="var(--bg-light)",D||(F.style.color="var(--text-primary)")},onMouseLeave:Q=>
371{if(H)return;const F=Q.currentTarget;F.style.background="transparent",F.style.color=D?"var(--text-muted)":"var(--text-secondary)"},children:[d.jsxs("span",{style:{position:"relative",display:"inline-flex",flexShrink:0},children:[d.jsx(O,{style:{width:16,height:16,flexShrink:0,opacity:D?.5:1}}),T.id==="launchroom"&&t&&A.replies+A.feedback>0&&d.jsx("span",{role:"img","aria-label":"Unread updates",style:{position:"absolute",top:-2,right:-3,width:7,height:7,borderRadius:99,background:"var(--accent)"}})]}),!t&&d.jsxs(d.Fragment,{children:[d.jsx("span",{style:{fontSize:13,fontWeight:H?700:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:T.label}),T.id==="launchroom"&&A.replies+A.feedback>0&&d.jsx("span",{role:"img","aria-label":"Unread updates",style:{marginLeft:"auto",width:7,height:7,borderRadius:99,background:"var(--accent)",flexShrink:0}}),D&&!T.comingSoon&&d.jsx(fi,{})]})]},T.id),ee=t?d.jsx(P,{label:T.label,children:z},T.id):z;if(T.id==="launchroom")return d.jsxs(Y.Fragment,{children:[d.jsx("div",{style:{height:1,background:"var(--border-soft)",margin:"6px 0",flexShrink:0}}),ee]},`${T.id}-wrap`);if(T.id==="affiliate")return d.jsxs(Y.Fragment,{children:[d.jsx("div",{style:{height:1,background:"var(--border-soft)",margin:"6px 0",flexShrink:0}}),ee]},`${T.id}-wrap`);if(T.id==="freetools"&&!D&&!t&&H){const Q=new URLSearchParams(h.search).get("tab"),F=h.pathname.startsWith(C.freeTools);return d.jsxs(Y.Fragment,{children:[ee,d.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2,margin:"2px 0 4px"},children:Lw.map(V=>{const k=F&&Q===V.tab;return d.jsx(qn,{to:`${C.freeTools}?tab=${V.tab}`,style:{display:"flex",alignItems:"center",height:30,minHeight:30,flexShrink:0,padding:"0 10px 0 36px",borderRadius:6,textDecoration:"none",fontSize:12.5,fontWeight:k?700:500,whiteSpace:"nowrap",background:k?"var(--bg-medium)":"transparent",color:k?"var(--text-primary)":"var(--text-muted)",transition:"background 0.15s, color 0.15s"},onMouseEnter:pe=>{k||(pe.currentTarget.style.background="var(--bg-light)",pe.currentTarget.style.color="var(--text-primary)")},onMouseLeave:pe=>{k||(pe.currentTarget.style.background="transparent",pe.currentTarget.style.color="var(--text-muted)")},children:V.label},V.tab)})})]},`${T.id}-wrap`)}return ee})}),d.jsx("div",{style:{borderTop:"1px solid var(--border-soft)",padding:"8px 8px 0",display:"flex",flexDirection:"column",gap:2,flexShrink:0},children:zw.filter(T=>!T.adminOnly||c).map(T=>{const O=T.icon,H=T.feature!=null&&!s(T.feature),D=T.to?d.jsxs(qn,{to:T.to,onClick:H?z=>{z.preventDefault(),a(T.label)}:void 0,style:{display:"flex",alignItems:"center",gap:10,height:36,padding:t?"0":"0 10px",justifyContent:t?"center":"flex-start",borderRadius:6,textDecoration:"none",transition:"background 0.15s, color 0.15s",color:H?"var(--text-muted)":T.accent?"var(--accent)":"var(--text-secondary)",width:"100%",boxSizing:"border-box",cursor:"pointer"},onMouseEnter:z=>{const ee=z.currentTarget;ee.style.background="var(--bg-light)",!T.accent&&!H&&(ee.style.color="var(--text-primary)")},onMouseLeave:z=>{const ee=z.currentTarget;ee.style.background="transparent",ee.style.color=H?"var(--text-muted)":T.accent?"var(--accent)":"var(--text-secondary)"},children:[d.jsx(O,{style:{width:16,height:16,flexShrink:0,opacity:H?.5:1}}),!t&&d.jsxs(d.Fragment,{children:[d.jsx("span",{style:{fontSize:13,fontWeight:T.accent?600:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:T.label}),H&&d.jsx(fi,{})]})]}):null;return D?t?d.jsx(P,{label:T.label,children:D},T.label):d.jsx(Y.Fragment,{children:D},T.label):null})}),d.jsx("div",{style:{borderTop:"1px solid var(--border-soft)",padding:"8px",flexShrink:0},children:d.jsx(P,{label:x||(u==null?void 0:u.email)||"Account",children:d.jsxs(qn,{to:C.account,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,textDecoration:"none",transition:"background 0.15s",justifyContent:t?"center":"flex-start"},onMouseEnter:T=>T.currentTarget.style.background="var(--bg-light)",onMouseLeave:T=>T.currentTarget.style.background="transparent",children:[d.jsx(Fp,{style:{width:26,height:26,flexShrink:0},children:d.jsx($p,{style:{background:"var(--accent)",color:"#ffffff",fontSize:10,fontWeight:700},children:L(x,(u==null?void 0:u.email)??void 0)})}),!t&&d.jsxs("div",{style:{overflow:"hidden"},children:[d.jsx("div",{style:{fontSize:13,fontWeight:500,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x||"Account"}),d.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u==null?void 0:u.email})]})]})})})]}),d.jsx("div",{className:Ne("overflow-hidden","transition-[width,border-width] duration-200 ease-out",M?"border-r":"border-r-0"),style:{width:M?ea:0,background:"var(--bg-darkest)",borderRightColor:"var(--border-soft)"},children:d.jsxs("div",{style:{width:ea,minWidth:ea,height:"100%",display:"flex",flexDirection:"column"},children:[p==="research"&&d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 12px 12px",flexShrink:0,fontSize:15,fontWeight:700,letterSpacing:"-0.2px",color:"var(--text-primary)"},children:[d.jsx(Ar,{style:{width:14,height:14,color:"var(--text-muted)",flexShrink:0}}),"Research"]}),d.jsx("nav",{style:{flex:1,overflowY:"auto",padding:p==="research"?"0 8px 8px":"12px 8px 8px",display:"flex",flexDirection:"column",gap:2},children:(()=>{const T=new URLSearchParams(h.search),O=T.get("tab")??"",H=D=>!D||D.length===0||D.some(z=>T.get(z)!==null);return S.map((D,z)=>{if(cu(D))return D.visibleForTab&&!D.visibleForTab.includes(O)||D.feature&&!s(D.feature)||!H(D.requiresAnyParam)?null:d.jsx(Up,{label:D.label,asTitle:D.asTitle},`sep-${z}`);if(uu(D))return D.visibleForTab&&!D.visibleForTab.includes(O)||!H(D.requiresAnyParam)?null:d.jsx(Hw,{group:D,hasFeature:s,requireFullAccess:a},`grp-${z}`);const ee=D;if(ee.adminOnly&&!c)return null;const Q=!!(ee.feature&&!s(ee.feature));if(Q&&ee.hideWhenLocked)return null;if(E&&!ee.icon){const F=ee.to.match(/[?&]stage=([^&]+)/),V=F?o.includes(F[1]):!1,k=h.pathname+h.search===ee.to||h.pathname===ee.to;return d.jsxs(qn,{to:Q?"#":ee.to,onClick:pe=>{Q&&(pe.preventDefault(),a(ee.label))},style:{display:"flex",alignItems:"center",gap:8,borderRadius:6,padding:"6px 8px",fontSize:12,textDecoration:"none",transition:"background 0.15s, color 0.15s",background:k?"var(--accent-soft)":"transparent",color:Q?"var(--text-muted)":k?"var(--accent)":"var(--text-secondary)",fontWeight:k?600:500,cursor:"pointer"},children:[d.jsx("span",{style:{width:6,height:6,flexShrink:0,borderRadius:"50%",background:k?"var(--accent)":V?"var(--success)":"var(--border)"}}
371),d.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ee.label}),Q&&d.jsx(fi,{size:11})]},ee.label)}return d.jsx(Uw,{item:ee,locked:Q,requireFullAccess:a},ee.label)})})()})]})})]})})}const Ss=y.forwardRef(({className:t,children:e,...n},r)=>d.jsxs(nf,{ref:r,className:Ne("relative overflow-hidden",t),...n,children:[d.jsx(Fy,{className:"h-full w-full max-w-full rounded-[inherit]",children:e}),d.jsx(Kp,{}),d.jsx($y,{})]}));Ss.displayName=nf.displayName;const Kp=y.forwardRef(({className:t,orientation:e="vertical",...n},r)=>d.jsx(rf,{ref:r,orientation:e,className:Ne("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...n,children:d.jsx(Vy,{className:"relative flex-1 rounded-full bg-border"})}));Kp.displayName=rf.displayName;const Xa="rp-research-focus";let Yp=null;function Kw(t){Yp=t,typeof window<"u"&&window.dispatchEvent(new CustomEvent(Xa,{detail:t}))}function rD(){Kw(null)}function fu(){return Yp}async function Yw(t){const{data:{user:e}}=await j.auth.getUser();if(!e)return null;if(t.priorId){const{error:i}=await j.from("ai_message_feedback").update({rating:t.rating,updated_at:new Date().toISOString()}).eq("id",t.priorId);return i?(console.error("[aiFeedback] update failed:",i),null):t.priorId}const{data:n,error:r}=await j.from("ai_message_feedback").insert({user_id:e.id,rating:t.rating,message_content:t.messageContent.slice(0,8e3),question_content:t.questionContent?t.questionContent.slice(0,2e3):null,bot_context:t.botContext,conversation_id:t.conversationId??null}).select("id").single();return r?(console.error("[aiFeedback] insert failed:",r),null):(n==null?void 0:n.id)??null}function Jw(t,e){const n={};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Gw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Qw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Xw={};function pu(t,e){return(Xw.jsx?Qw:Gw).test(t)}const Zw=/[ \t\n\f\r]/g;function ev(t){return typeof t=="object"?t.type==="text"?mu(t.value):!1:mu(t)}function mu(t){return t.replace(Zw,"")===""}let Ki=class{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}};Ki.prototype.normal={};Ki.prototype.property={};Ki.prototype.space=void 0;function Jp(t,e){const n={},r={};for(const i of t)Object.assign(n,i.property),Object.assign(r,i.normal);return new Ki(n,r,e)}function Za(t){return t.toLowerCase()}class Pt{constructor(e,n){this.attribute=n,this.property=e}}Pt.prototype.attribute="";Pt.prototype.booleanish=!1;Pt.prototype.boolean=!1;Pt.prototype.commaOrSpaceSeparated=!1;Pt.prototype.commaSeparated=!1;Pt.prototype.defined=!1;Pt.prototype.mustUseProperty=!1;Pt.prototype.number=!1;Pt.prototype.overloadedBoolean=!1;Pt.prototype.property="";Pt.prototype.spaceSeparated=!1;Pt.prototype.space=void 0;let tv=0;const Ce=fr(),Ke=fr(),el=fr(),Z=fr(),$e=fr(),Nr=fr(),Bt=fr();function fr(){return 2**++tv}const tl=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ce,booleanish:Ke,commaOrSpaceSeparated:Bt,commaSeparated:Nr,number:Z,overloadedBoolean:el,spaceSeparated:$e},Symbol.toStringTag,{value:"Module"})),ta=Object.keys(tl);class Ql extends Pt{constructor(e,n,r,i){let o=-1;if(super(e,n),gu(this,"space",i),typeof r=="number")for(;++o<ta.length;){const s=ta[o];gu(this,ta[o],(r&tl[s])===tl[s])}}}Ql.prototype.defined=!0;function gu(t,e,n){n&&(t[e]=n)}function Yr(t){const e={},n={};for(const[r,i]of Object.entries(t.properties)){const o=new Ql(r,t.transform(t.attributes||{},r),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),e[r]=o,n[Za(r)]=r,n[Za(o.attribute)]=r}return new Ki(e,n,t.space)}const Gp=Yr({properties:{ariaActiveDescendant:null,ariaAtomic:Ke,ariaAutoComplete:null,ariaBusy:Ke,ariaChecked:Ke,ariaColCount:Z,ariaColIndex:Z,ariaColSpan:Z,ariaControls:$e,ariaCurrent:null,ariaDescribedBy:$e,ariaDetails:null,ariaDisabled:Ke,ariaDropEffect:$e,ariaErrorMessage:null,ariaExpanded:Ke,ariaFlowTo:$e,ariaGrabbed:Ke,ariaHasPopup:null,ariaHidden:Ke,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:$e,ariaLevel:Z,ariaLive:null,ariaModal:Ke,ariaMultiLine:Ke,ariaMultiSelectable:Ke,ariaOrientation:null,ariaOwns:$e,ariaPlaceholder:null,ariaPosInSet:Z,ariaPressed:Ke,ariaReadOnly:Ke,ariaRelevant:null,ariaRequired:Ke,ariaRoleDescription:$e,ariaRowCount:Z,ariaRowIndex:Z,ariaRowSpan:Z,ariaSelected:Ke,ariaSetSize:Z,ariaSort:null,ariaValueMax:Z,ariaValueMin:Z,ariaValueNow:Z,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function Qp(t,e){return e in t?t[e]:e}function Xp(t,e){return Qp(t,e.toLowerCase())}const nv=Yr({attributes:{acceptcharset:"accept-charset",classname:"
371class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Nr,acceptCharset:$e,accessKey:$e,action:null,allow:null,allowFullScreen:Ce,allowPaymentRequest:Ce,allowUserMedia:Ce,alt:null,as:null,async:Ce,autoCapitalize:null,autoComplete:$e,autoFocus:Ce,autoPlay:Ce,blocking:$e,capture:null,charSet:null,checked:Ce,cite:null,className:$e,cols:Z,colSpan:null,content:null,contentEditable:Ke,controls:Ce,controlsList:$e,coords:Z|Nr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ce,defer:Ce,dir:null,dirName:null,disabled:Ce,download:el,draggable:Ke,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ce,formTarget:null,headers:$e,height:Z,hidden:el,high:Z,href:null,hrefLang:null,htmlFor:$e,httpEquiv:$e,id:null,imageSizes:null,imageSrcSet:null,inert:Ce,inputMode:null,integrity:null,is:null,isMap:Ce,itemId:null,itemProp:$e,itemRef:$e,itemScope:Ce,itemType:$e,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ce,low:Z,manifest:null,max:null,maxLength:Z,media:null,method:null,min:null,minLength:Z,multiple:Ce,muted:Ce,name:null,nonce:null,noModule:Ce,noValidate:Ce,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ce,optimum:Z,pattern:null,ping:$e,placeholder:null,playsInline:Ce,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ce,referrerPolicy:null,rel:$e,required:Ce,reversed:Ce,rows:Z,rowSpan:Z,sandbox:$e,scope:null,scoped:Ce,seamless:Ce,selected:Ce,shadowRootClonable:Ce,shadowRootDelegatesFocus:Ce,shadowRootMode:null,shape:null,size:Z,sizes:null,slot:null,span:Z,spellCheck:Ke,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Z,step:null,style:null,tabIndex:Z,target:null,title:null,translate:null,type:null,typeMustMatch:Ce,useMap:null,value:Ke,width:Z,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:$e,axis:null,background:null,bgColor:null,border:Z,borderColor:null,bottomMargin:Z,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ce,declare:Ce,event:null,face:null,frame:null,frameBorder:null,hSpace:Z,leftMargin:Z,link:null,longDesc:null,lowSrc:null,marginHeight:Z,marginWidth:Z,noResize:Ce,noHref:Ce,noShade:Ce,noWrap:Ce,object:null,profile:null,prompt:null,rev:null,rightMargin:Z,rules:null,scheme:null,scrolling:Ke,standby:null,summary:null,text:null,topMargin:Z,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Z,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ce,disableRemotePlayback:Ce,prefix:null,property:null,results:Z,security:null,unselectable:null},space:"html",transform:Xp}),rv=Yr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRen
371dering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Bt,accentHeight:Z,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Z,amplitude:Z,arabicForm:null,ascent:Z,attributeName:null,attributeType:null,azimuth:Z,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Z,by:null,calcMode:null,capHeight:Z,className:$e,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRen
371dering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Z,diffuseConstant:Z,direction:null,display:null,dur:null,divisor:Z,dominantBaseline:null,download:Ce,dx:null,dy:null,edgeMode:null,editable:null,elevation:Z,enableBackground:null,end:null,event:null,exponent:Z,externalResourcesRequired:null,fill:null,fillOpacity:Z,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Nr,g2:Nr,glyphName:Nr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Z,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Z,horizOriginX:Z,horizOriginY:Z,id:null,ideographic:Z,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Z,k:Z,k1:Z,k2:Z,k3:Z,k4:Z,kernelMatrix:Bt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Z,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Z,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Z,overlineThickness:Z,paintOrder:null,panose1:null,path:null,pathLength:Z,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:$e,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Z,pointsAtY:Z,pointsAtZ:Z,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Bt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Bt,rev:Bt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Bt,requiredFeatures:Bt,requiredFonts:Bt,requiredFormats:Bt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Z,specularExponent:Z,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Z,strikethroughThickness:Z,string:null,stroke:null,strokeDashArray:Bt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Z,strokeOpacity:Z,strokeWidth:null,style:null,surfaceScale:Z,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Bt,tabIndex:Z,tableValues:null,target:null,targetX:Z,targetY:Z,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Bt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Z,underlineThickness:Z,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Z,values:null,vAlphabetic:Z,vMathematical:Z,vectorEffect:null,vHanging:Z,vIdeographic:Z,version:null,vertAdvY:Z,vertOriginX:Z,vertOriginY:Z,viewB
vendor: 5,121 bytes, lines 371-372
371ox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Z,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Qp}),Zp=Yr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),em=Yr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xp}),tm=Yr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),iv={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},ov=/[A-Z]/g,yu=/-[a-z]/g,sv=/^data[-\w.:]+$/i;function av(t,e){const n=Za(e);let r=e,i=Pt;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&sv.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(yu,cv);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!yu.test(o)){let s=o.replace(ov,lv);s.charAt(0)!=="-"&&(s="-"+s),e="data"+s}}i=Ql}return new i(r,e)}function lv(t){return"-"+t.toLowerCase()}function cv(t){return t.charAt(1).toUpperCase()}const uv=Jp([Gp,nv,Zp,em,tm],"html"),Xl=Jp([Gp,rv,Zp,em,tm],"svg");function dv(t){return t.join(" ").trim()}var Zl={},xu=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,hv=/\n/g,fv=/^\s*/,pv=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,mv=/^:\s*/,gv=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,yv=/^[;\s]*/,xv=/^\s+|\s+$/g,bv=` 372`,bu="/",wu="*",Kn="",wv="comment",vv="declaration",kv=function(t,e){if(typeof t!="string")throw new TypeError("First argument must be a string");if(!t)return[];e=e||{};var n=1,r=1;function i(m){var g=m.match(hv);g&&(n+=g.length);var x=m.lastIndexOf(bv);r=~x?m.length-x:r+m.length}function o(){var m={line:n,column:r};return function(g){return g.position=new s(m),c(),g}}function s(m){this.start=m,this.end={line:n,column:r},this.source=e.source}s.prototype.content=t;function a(m){var g=new Error(e.source+":"+n+":"+r+": "+m);if(g.reason=m,g.filename=e.source,g.line=n,g.column=r,g.source=t,!e.silent)throw g}function l(m){var g=m.exec(t);if(g){var x=g[0];return i(x),t=t.slice(x.length),g}}function c(){l(fv)}function u(m){var g;for(m=m||[];g=h();)g!==!1&&m.push(g);return m}function h(){var m=o();if(!(bu!=t.charAt(0)||wu!=t.charAt(1))){for(var g=2;Kn!=t.charAt(g)&&(wu!=t.charAt(g)||bu!=t.charAt(g+1));)++g;if(g+=2,Kn===t.charAt(g-1))return a("End of comment missing");var x=t.slice(2,g-2);return r+=2,i(x),t=t.slice(g),r+=2,m({type:wv,comment:x})}}function p(){var m=o(),g=l(pv);if(g){if(h(),!l(mv))return a("property missing ':'");var x=l(gv),b=m({type:vv,property:vu(g[0].replace(xu,Kn)),value:x?vu(x[0].replace(xu,Kn)):Kn});return l(yv),b}}function f(){var m=[];u(m);for(var g;g=p();)g!==!1&&(m.push(g),u(m));return m}return c(),f()};function vu(t){return t?t.replace(xv,Kn):Kn}var Sv=Do&&Do.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Zl,"__esModule",{value:!0});Zl.default=Ev;var Cv=Sv(kv);function Ev(t,e){var n=null;if(!t||typeof t!="string")return n;var r=(0,Cv.default)(t),i=typeof e=="function";return r.forEach(function(o){if(o.type==="declaration"){var s=o.property,a=o.value;i?e(s,a,o):a&&(n=n||{},n[s]=a)}}),n}var Cs={};Object.defineProperty(Cs,"__esModule",{value:!0});Cs.camelCase=void 0;var Tv=/^--[a-zA-Z0-9_-]+$/,_v=/-([a-z])/g,Av=/^[^-]+$/,Mv=/^-(webkit|moz|ms|o|khtml)-/,Nv=/^-(ms)-/,jv=function(t){return!t||Av.test(t)||Tv.test(t)},Iv=function(t,e){return e.toUpperCase()},ku=function(t,e){return"".concat(e,"-")},Rv=function(t,e){return e===void 0&&(e={}),jv(t)?t:(t=t.toLowerCase(),e.reactCompat?t=t.replace(Nv,ku):t=t.replace(Mv,ku),t.replace(_v,Iv))};Cs.camelCase=Rv;var Ov=Do&&Do.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},Pv=Ov(Zl),Dv=Cs;function nl(t,e){var n={};return!t||typeof t!="string"||(0,Pv.default)(t,function(r,i){r&&i&&(n[(0,Dv.camelCase)(r,e)]=i)}),n}nl.default=nl;var Lv=nl;const Bv=uf(Lv),nm=rm("end"),ec=rm("start");function rm(t){return e;function e(n){const r=n&&n.position&&n.position[t]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function zv(t){const e=ec(t),n=nm(t);if(e&&n)return{start:e,end:n}}function pi(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?Su(t.position):"start"in t||"end"in t?Su(t):"line"in t||"column"in t?rl(t):""}function rl(t){return Cu(t&&t.line)+":"+Cu(t&&t.column)}function Su(t){return rl(t&&t.start)+"-"+rl(t&&t.end)}function Cu(t){return t&&typeof t=="number"?t:1}
vendor: 1,921 bytes, line 372
372class xt extends Error{constructor(e,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},s=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof e=="string"?i=e:!o.cause&&e&&(s=!0,i=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?o.ruleId=r:(o.source=r.slice(0,l),o.ruleId=r.slice(l+1))}if(!o.place&&o.ancestors&&o.ancestors){const l=o.ancestors[o.ancestors.length-1];l&&(o.place=l.position)}const a=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=pi(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}xt.prototype.file="";xt.prototype.name="";xt.prototype.reason="";xt.prototype.message="";xt.prototype.stack="";xt.prototype.column=void 0;xt.prototype.line=void 0;xt.prototype.ancestors=void 0;xt.prototype.cause=void 0;xt.prototype.fatal=void 0;xt.prototype.place=void 0;xt.prototype.ruleId=void 0;xt.prototype.source=void 0;const tc={}.hasOwnProperty,Fv=new Map,$v=/[A-Z]/g,Vv=new Set(["table","tbody","thead","tfoot","tr"]),Wv=new Set(["td","th"]),im="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Hv(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let r;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Xv(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");
vendor: 6,194 bytes, line 372
372if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Qv(n,e.jsx,e.jsxs)}const i={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:r,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?Xl:uv,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},o=om(i,t,void 0);return o&&typeof o!="string"?o:i.create(t,i.Fragment,{children:o||void 0},void 0)}function om(t,e,n){if(e.type==="element")return qv(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return Uv(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return Yv(t,e,n);if(e.type==="mdxjsEsm")return Kv(t,e);if(e.type==="root")return Jv(t,e,n);if(e.type==="text")return Gv(t,e)}function qv(t,e,n){const r=t.schema;let i=r;e.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Xl,t.schema=i),t.ancestors.push(e);const o=am(t,e.tagName,!1),s=Zv(t,e);let a=rc(t,e);return Vv.has(e.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!ev(l):!0})),sm(t,s,o,e),nc(s,a),t.ancestors.pop(),t.schema=r,t.create(e,o,s,n)}function Uv(t,e){if(e.data&&e.data.estree&&t.evaluater){const r=e.data.estree.body[0];return r.type,t.evaluater.evaluateExpression(r.expression)}Mi(t,e.position)}function Kv(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);Mi(t,e.position)}function Yv(t,e,n){const r=t.schema;let i=r;e.name==="svg"&&r.space==="html"&&(i=Xl,t.schema=i),t.ancestors.push(e);const o=e.name===null?t.Fragment:am(t,e.name,!0),s=ek(t,e),a=rc(t,e);return sm(t,s,o,e),nc(s,a),t.ancestors.pop(),t.schema=r,t.create(e,o,s,n)}function Jv(t,e,n){const r={};return nc(r,rc(t,e)),t.create(e,t.Fragment,r,n)}function Gv(t,e){return e.value}function sm(t,e,n,r){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=r)}function nc(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function Qv(t,e,n){return r;function r(i,o,s,a){const c=Array.isArray(s.children)?n:e;return a?c(o,s,a):c(o,s)}}function Xv(t,e){return n;function n(r,i,o,s){const a=Array.isArray(o.children),l=ec(r);return e(i,o,s,a,{columnNumber:l?l.column-1:void 0,fileName:t,lineNumber:l?l.line:void 0},void 0)}}function Zv(t,e){const n={};let r,i;for(i in e.properties)if(i!=="children"&&tc.call(e.properties,i)){const o=tk(t,i,e.properties[i]);if(o){const[s,a]=o;t.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&Wv.has(e.tagName)?r=a:n[s]=a}}if(r){const o=n.style||(n.style={});o[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function ek(t,e){const n={};for(const r of e.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&t.evaluater){const o=r.data.estree.body[0];o.type;const s=o.expression;s.type;const a=s.properties[0];a.type,Object.assign(n,t.evaluater.evaluateExpression(a.argument))}else Mi(t,e.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&t.evaluater){const a=r.value.data.estree.body[0];a.type,o=t.evaluater.evaluateExpression(a.expression)}else Mi(t,e.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function rc(t,e){const n=[];let r=-1;const i=t.passKeys?new Map:Fv;for(;++r<e.children.length;){const o=e.children[r];let s;if(t.passKeys){const l=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(l){const c=i.get(l)||0;s=l+"-"+c,i.set(l,c+1)}}const a=om(t,o,s);a!==void 0&&n.push(a)}return n}function tk(t,e,n){const r=av(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Jw(n):dv(n)),r.property==="style"){let i=typeof n=="object"?n:nk(t,String(n));return t.stylePropertyNameCase==="css"&&(i=rk(i)),["style",i]}return[t.elementAttributeNameCase==="react"&&r.space?iv[r.property]||r.property:r.attribute,n]}}function nk(t,e){try{return Bv(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const r=n,i=new xt("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=t.filePath||void 0,i.url=im+"#cannot-parse-style-attribute",i}}function am(t,e,n){let r;if(!n)r={type:"Literal",value:e};else if(e.includes(".")){const i=e.split(".");let o=-1,s;for(;++o<i.length;){const a=pu(i[o])?{type:"Identifier",name:i[o]}:{type:"Literal",value:i[o]};s=s?{type:"MemberExpression",object:s,property:a,computed:!!(o&&a.type==="Literal"),optional:!1}:a}r=s}else r=pu(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(r.type==="Literal"){const i=r.value;return tc.call(t.components,i)?t.components[i]:i}if(t.evaluater)return t.evaluater.evaluateExpression(r);Mi(t)}function Mi(t,e){const n=new xt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=im+"#cannot-handle-mdx-estrees-without-createevaluater",n}function rk(t){const e={};let n;for(n in t)tc.call(t,n)&&(e[ik(n)]=t[n]);return e}function ik(t){let e=t.replace($v,ok);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function ok(t){return"-"+t.toLowerCase()}const na={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},sk={};function ak(t,e){const n=sk,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return lm(t,r,i)}function lm(t,e,n){if(lk(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return Eu(t.children,e,n)}return Array.isArray(t)?Eu(t,e,n):""}function Eu(t,e,n){const r=[];let i=-1;for(;++i<t.length;)r[i]=lm(t[i],e,n);return r.join("")}function lk(t){return!!(t&&typeof t=="object")}
vendor: 10,988 bytes, line 372
372const Tu=document.createElement("i");function ic(t){const e="&"+t+";";Tu.innerHTML=e;const n=Tu.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function un(t,e,n,r){const i=t.length;let o=0,s;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(e,n),t.splice(...s);else for(n&&t.splice(e,n);o<r.length;)s=r.slice(o,o+1e4),s.unshift(e,0),t.splice(...s),o+=1e4,e+=1e4}function Ht(t,e){return t.length>0?(un(t,t.length,0,e),t):e}const _u={}.hasOwnProperty;function ck(t){const e={};let n=-1;for(;++n<t.length;)uk(e,t[n]);return e}function uk(t,e){let n;for(n in e){const i=(_u.call(t,n)?t[n]:void 0)||(t[n]={}),o=e[n];let s;if(o)for(s in o){_u.call(i,s)||(i[s]=[]);const a=o[s];dk(i[s],Array.isArray(a)?a:a?[a]:[])}}}function dk(t,e){let n=-1;const r=[];for(;++n<e.length;)(e[n].add==="after"?t:r).push(e[n]);un(t,0,0,r)}function cm(t,e){const n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function jr(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ln=Fn(/[A-Za-z]/),$t=Fn(/[\dA-Za-z]/),hk=Fn(/[#-'*+\--9=?A-Z^-~]/);function il(t){return t!==null&&(t<32||t===127)}const ol=Fn(/\d/),fk=Fn(/[\dA-Fa-f]/),pk=Fn(/[!-/:-@[-`{-~]/);function we(t){return t!==null&&t<-2}function Nt(t){return t!==null&&(t<0||t===32)}function Pe(t){return t===-2||t===-1||t===32}const mk=Fn(new RegExp("\\p{P}|\\p{S}","u")),gk=Fn(/\s/);function Fn(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function Jr(t){const e=[];let n=-1,r=0,i=0;for(;++n<t.length;){const o=t.charCodeAt(n);let s="";if(o===37&&$t(t.charCodeAt(n+1))&&$t(t.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(s=String.fromCharCode(o));else if(o>55295&&o<57344){const a=t.charCodeAt(n+1);o<56320&&a>56319&&a<57344?(s=String.fromCharCode(o,a),i=1):s="�"}else s=String.fromCharCode(o);s&&(e.push(t.slice(r,n),encodeURIComponent(s)),r=n+i+1,s=""),i&&(n+=i,i=0)}return e.join("")+t.slice(r)}function Ve(t,e,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return s;function s(l){return Pe(l)?(t.enter(n),a(l)):e(l)}function a(l){return Pe(l)&&o++<i?(t.consume(l),a):(t.exit(n),e(l))}}const yk={tokenize:xk};function xk(t){const e=t.attempt(this.parser.constructs.contentInitial,r,i);let n;return e;function r(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),Ve(t,e,"linePrefix")}function i(a){return t.enter("paragraph"),o(a)}function o(a){const l=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,s(a)}function s(a){if(a===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(a);return}return we(a)?(t.consume(a),t.exit("chunkText"),o):(t.consume(a),s)}}const bk={tokenize:wk},Au={tokenize:vk};function wk(t){const e=this,n=[];let r=0,i,o,s;return a;function a(v){if(r<n.length){const A=n[r];return e.containerState=A[1],t.attempt(A[0].continuation,l,c)(v)}return c(v)}function l(v){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&E();const A=e.events.length;let _=A,S;for(;_--;)if(e.events[_][0]==="exit"&&e.events[_][1].type==="chunkFlow"){S=e.events[_][1].end;break}b(r);let N=A;for(;N<e.events.length;)e.events[N][1].end={...S},N++;return un(e.events,_+1,0,e.events.slice(A)),e.events.length=N,c(v)}return a(v)}function c(v){if(r===n.length){if(!i)return p(v);if(i.currentConstruct&&i.currentConstruct.concrete)return m(v);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(Au,u,h)(v)}function u(v){return i&&E(),b(r),p(v)}function h(v){return e.parser.lazy[e.now().line]=r!==n.length,s=e.now().offset,m(v)}function p(v){return e.containerState={},t.attempt(Au,f,m)(v)}function f(v){return r++,n.push([e.currentConstruct,e.containerState]),p(v)}function m(v){if(v===null){i&&E(),b(0),t.consume(v);return}return i=i||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),g(v)}function g(v){if(v===null){x(t.exit("chunkFlow"),!0),b(0),t.consume(v);return}return we(v)?(t.consume(v),x(t.exit("chunkFlow")),r=0,e.interrupt=void 0,a):(t.consume(v),g)}function x(v,A){const _=e.sliceStream(v);if(A&&_.push(null),v.previous=o,o&&(o.next=v),o=v,i.defineSkip(v.start),i.write(_),e.parser.lazy[v.start.line]){let S=i.events.length;for(;S--;)if(i.events[S][1].start.offset<s&&(!i.events[S][1].end||i.events[S][1].end.offset>s))return;const N=e.events.length;let M=N,L,P;for(;M--;)if(e.events[M][0]==="exit"&&e.events[M][1].type==="chunkFlow"){if(L){P=e.events[M][1].end;break}L=!0}for(b(r),S=N;S<e.events.length;)e.events[S][1].end={...P},S++;un(e.events,M+1,0,e.events.slice(N)),e.events.length=S}}function b(v){let A=n.length;for(;A-- >v;){const _=n[A];e.containerState=_[1],_[0].exit.call(e,t)}n.length=v}function E(){i.write([null]),o=void 0,i=void 0,e.containerState._closeFlow=void 0}}function vk(t,e,n){return Ve(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Mu(t){if(t===null||Nt(t)||gk(t))return 1;if(mk(t))return 2}function oc(t,e,n){const r=[];let i=-1;for(;++i<t.length;){const o=t[i].resolveAll;o&&!r.includes(o)&&(e=o(e,n),r.push(o))}return e}const sl={name:"attention",resolveAll:kk,tokenize:Sk};function kk(t,e){let n=-1,r,i,o,s,a,l,c,u;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){for(r=n;r--;)if(t[r][0]==="exit"&&t[r][1].type==="attentionSequence"&&t[r][1]._open&&e.sliceSerialize(t[r][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[r][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[r][1].end.offset-t[r][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;l=t[r][1].end.offset-t[r][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;const h={...t[r][1].end},p={...t[n][1].start};Nu(h,-l),Nu(p,l),s={type:l>1?"strongSequence":"emphasisSequence",start:h,end:{...t[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:p},o={type:l>1?"strongText":"emphasisText",start:{...t[r][1].end},end:{...t[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},t[r][1].end={...s.start},t[n][1].start={...a.end},c=[],t[r][1].end.offset-t[r][1].start.offset&&(c=Ht(c,[["enter",t[r][1],e],["exit",t[r][1],e]])),c=Ht(c,[["enter",i,e],["enter",s,e],["exit",s,e],["enter",o,e]]),c=Ht(c,oc(e.parser.constructs.insideSpan.null,t.slice(r+1,n),e)),c=Ht(c,[["exit",o,e],["enter",a,e],["exit",a,e],["exit",i,e]]),t[n][1].end.offset-t[n][1].start.offset?(u=2,c=Ht(c,[["enter",t[n][1],e],["exit",t[n][1],e]])):u=0,un(t,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function Sk(t,e){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Mu(r);let o;return s;function s(l){return o=l,t.enter("attentionSequence"),a(l)}function a(l){if(l===o)return t.consume(l),a;const c=t.exit("attentionSequence"),u=Mu(l),h=!u||u===2&&i||n.includes(l),p=!i||i===2&&u||n.includes(r);return c._open=!!(o===42?h:h&&(i||!p)),c._close=!!(o===42?p:p&&(u||!h)),e(l)}}function Nu(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const Ck={name:"autolink",tokenize:Ek};function Ek(t,e,n){let r=0;return i;function i(f){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),o}function o(f){return ln(f)?(t.consume(f),s):f===64?n(f):c(f)}function s(f){return f===43||f===45||f===46||$t(f)?(r=1,a(f)):c(f)}function a(f){return f===58?(t.consume(f),r=0,l):(f===43||f===45||f===46||$t(f))&&r++<32?(t.consume(f),a):(r=0,c(f))}function l(f){return f===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):f===null||f===32||f===60||il(f)?n(f):(t.consume(f),l)}function c(f){return f===64?(t.consume(f),u):hk(f)?(t.consume(f),c):n(f)}function u(f){return $t(f)?h(f):n(f)}function h(f){return f===46?(t.consume(f),r=0,u):f===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):p(f)}function p(f){if((f===45||$t(f))&&r++<63){const m=f===45?p:h;return t.consume(f),m}return n(f)}}const Es={partial:!0,tokenize:Tk};function Tk(t,e,n){return r;function r(o){return Pe(o)?Ve(t,i,"linePrefix")(o):i(o)}function i(o){return o===null||we(o)?e(o):n(o)}}const um={continuation:{tokenize:Ak},exit:Mk,name:"blockQuote",tokenize:_k};function _k(t,e,n){const r=this;return i;function i(s){if(s===62){const a=r.containerState;return a.open||(t.enter("blockQuote",{_container:!0}),a.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(s),t.exit("blockQuoteMarker"),o}return n(s)}function o(s){return Pe(s)?(t.enter("blockQuotePrefixWhitespace"),t.consume(s),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(s))}}function Ak(t,e,n){const r=this;return i;function i(s){return Pe(s)?Ve(t,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):o(s)}function o(s){return t.attempt(um,e,n)(s)}}function Mk(t){t.exit("blockQuote")}const dm={name:"characterEscape",tokenize:Nk};function Nk(t,e,n){return r;function r(o){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(o),t.exit("escapeMarker"),i}function i(o){return pk(o)?(t.enter("characterEscapeValue"),t.consume(o),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(o)}}const hm={name:"characterReference",tokenize:jk};function jk(t,e,n){const r=this;let i=0,o,s;return a;function a(h){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(h),t.exit("characterReferenceMarker"),l}function l(h){return h===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(h),t.exit("characterReferenceMarkerNumeric"),c):(t.enter("characterReferenceValue"),o=31,s=$t,u(h))}function c(h){return h===88||h===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(h),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),o=6,s=fk,u):(t.enter("characterReferenceValue"),o=7,s=ol,u(h))}function u(h){if(h===59&&i){const p=t.exit("characterReferenceValue");return s===$t&&!ic(r.sliceSerialize(p))?n(h):(t.enter("characterReferenceMarker"),t.consume(h),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return s(h)&&i++<o?(t.consume(h),u):n(h)}}const ju={partial:!0,tokenize:Rk},Iu={concrete:!0,name:"codeFenced",tokenize:Ik};function Ik(t,e,n){const r=this,i={partial:!0,tokenize:_};let o=0,s=0,a;return l;function l(S){return c(S)}function c(S){const N=r.events[r.events.length-1];return o=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=S,t.enter("co
372deFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),u(S)}function u(S){return S===a?(s++,t.consume(S),u):s<3?n(S):(t.exit("codeFencedFenceSequence"),Pe(S)?Ve(t,h,"whitespace")(S):h(S))}function h(S){return S===null||we(S)?(t.exit("codeFencedFence"),r.interrupt?e(S):t.check(ju,g,A)(S)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),p(S))}function p(S){return S===null||we(S)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),h(S)):Pe(S)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Ve(t,f,"whitespace")(S)):S===96&&S===a?n(S):(t.consume(S),p)}function f(S){return S===null||we(S)?h(S):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),m(S))}function m(S){return S===null||we(S)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),h(S)):S===96&&S===a?n(S):(t.consume(S),m)}function g(S){return t.attempt(i,A,x)(S)}function x(S){return t.enter("lineEnding"),t.consume(S),t.exit("lineEnding"),b}function b(S){return o>0&&Pe(S)?Ve(t,E,"linePrefix",o+1)(S):E(S)}function E(S){return S===null||we(S)?t.check(ju,g,A)(S):(t.enter("codeFlowValue"),v(S))}function v(S){return S===null||we(S)?(t.exit("codeFlowValue"),E(S)):(t.consume(S),v)}function A(S){return t.exit("codeFenced"),e(S)}function _(S,N,M){let L=0;return P;function P(z){return S.enter("lineEnding"),S.consume(z),S.exit("lineEnding"),T}function T(z){return S.enter("codeFencedFence"),Pe(z)?Ve(S,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):O(z)}function O(z){return z===a?(S.enter("codeFencedFenceSequence"),H(z)):M(z)}function H(z){return z===a?(L++,S.consume(z),H):L>=s?(S.exit("codeFencedFenceSequence"),Pe(z)?Ve(S,D,"whitespace")(z):D(z)):M(z)}function D(z){return z===null||we(z)?(S.exit("codeFencedFence"),N(z)):M(z)}}}function Rk(t,e,n){const r=this;return i;function i(s){return s===null?n(s):(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),o)}function o(s){return r.parser.lazy[r.now().line]?n(s):e(s)}}const ra={name:"codeIndented",tokenize:Pk},Ok={partial:!0,tokenize:Dk};function Pk(t,e,n){const r=this;return i;function i(c){return t.enter("codeIndented"),Ve(t,o,"linePrefix",5)(c)}function o(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?s(c):n(c)}function s(c){return c===null?l(c):we(c)?t.attempt(Ok,s,l)(c):(t.enter("codeFlowValue"),a(c))}function a(c){return c===null||we(c)?(t.exit("codeFlowValue"),s(c)):(t.consume(c),a)}function l(c){return t.exit("codeIndented"),e(c)}}function Dk(t,e,n){const r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):we(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),i):Ve(t,o,"linePrefix",5)(s)}function o(s){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(s):we(s)?i(s):n(s)}}const Lk={name:"codeText",previous:zk,resolve:Bk,tokenize:Fk};function Bk(t){let e=t.length-4,n=3,r,i;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(r=n;++r<e;)if(t[r][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(r=n-1,e++;++r<=e;)i===void 0?r!==e&&t[r][1].type!=="lineEnding"&&(i=r):(r===e||t[r][1].type==="lineEnding")&&(t[i][1].type="codeTextData",r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return t}function zk(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Fk(t,e,n){let r=0,i,o;return s;function s(h){return t.enter("codeText"),t.enter("codeTextSequence"),a(h)}function a(h){return h===96?(t.consume(h),r++,a):(t.exit("codeTextSequence"),l(h))}function l(h){return h===null?n(h):h===32?(t.enter("space"),t.consume(h),t.exit("space"),l):h===96?(o=t.enter("codeTextSequence"),i=0,u(h)):we(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),l):(t.enter("codeTextData"),c(h))}function c(h){return h===null||h===32||h===96||we(h)?(t.exit("codeTextData"),l(h)):(t.consume(h),c)}function u(h){return h===96?(t.consume(h),i++,u):i===r?(t.exit("codeTextSequence"),t.exit("codeText"),e(h)):(o.type="codeTextData",c(h))}}class $k{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,n,r){const i=n||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&ti(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),ti(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),ti(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);ti(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);ti(this.left,n.reverse())}}}function ti(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function fm(t){const e={};let n=-1,r,i,o,s,a,l,c;const u=new $k(t);for(;++n<u.length;){for(;n in e;)n=e[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,o=0,o<l.length&&l[o][1].type==="lineEndingBlank"&&(o+=2),o<l.length&&l[o][1].type==="content"))for(;++o<l.length&&l[o][1].type!=="content";)l[o][1].type==="chunkText"&&(l[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,Vk(u,n)),n=e[n],c=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(s=u.get(o),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),s[1].type="lineEnding",i=o);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return un(t,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function Vk(t,e){const n=t.get(e)[1],r=t.get(e)[2];let i=e-1;const o=[];let s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._c
vendor: 5,596 bytes, line 372
372ontentTypeTextTrailing=!0));const a=s.events,l=[],c={};let u,h,p=-1,f=n,m=0,g=0;const x=[g];for(;f;){for(;t.get(++i)[1]!==f;);o.push(i),f._tokenizer||(u=r.sliceStream(f),f.next||u.push(null),h&&s.defineSkip(f.start),f._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(u),f._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),h=f,f=f.next}for(f=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(g=p+1,x.push(g),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(s.events=[],f?(f._tokenizer=void 0,f.previous=void 0):x.pop(),p=x.length;p--;){const b=a.slice(x[p],x[p+1]),E=o.pop();l.push([E,E+b.length-1]),t.splice(E,2,b)}for(l.reverse(),p=-1;++p<l.length;)c[m+l[p][0]]=m+l[p][1],m+=l[p][1]-l[p][0]-1;return c}const Wk={resolve:qk,tokenize:Uk},Hk={partial:!0,tokenize:Kk};function qk(t){return fm(t),t}function Uk(t,e){let n;return r;function r(a){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?o(a):we(a)?t.check(Hk,s,o)(a):(t.consume(a),i)}function o(a){return t.exit("chunkContent"),t.exit("content"),e(a)}function s(a){return t.consume(a),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Kk(t,e,n){const r=this;return i;function i(s){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),Ve(t,o,"linePrefix")}function o(s){if(s===null||we(s))return n(s);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(s):t.interrupt(r.parser.constructs.flow,n,e)(s)}}function pm(t,e,n,r,i,o,s,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return h;function h(b){return b===60?(t.enter(r),t.enter(i),t.enter(o),t.consume(b),t.exit(o),p):b===null||b===32||b===41||il(b)?n(b):(t.enter(r),t.enter(s),t.enter(a),t.enter("chunkString",{contentType:"string"}),g(b))}function p(b){return b===62?(t.enter(o),t.consume(b),t.exit(o),t.exit(i),t.exit(r),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),f(b))}function f(b){return b===62?(t.exit("chunkString"),t.exit(a),p(b)):b===null||b===60||we(b)?n(b):(t.consume(b),b===92?m:f)}function m(b){return b===60||b===62||b===92?(t.consume(b),f):f(b)}function g(b){return!u&&(b===null||b===41||Nt(b))?(t.exit("chunkString"),t.exit(a),t.exit(s),t.exit(r),e(b)):u<c&&b===40?(t.consume(b),u++,g):b===41?(t.consume(b),u--,g):b===null||b===32||b===40||il(b)?n(b):(t.consume(b),b===92?x:g)}function x(b){return b===40||b===41||b===92?(t.consume(b),g):g(b)}}function mm(t,e,n,r,i,o){const s=this;let a=0,l;return c;function c(f){return t.enter(r),t.enter(i),t.consume(f),t.exit(i),t.enter(o),u}function u(f){return a>999||f===null||f===91||f===93&&!l||f===94&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?n(f):f===93?(t.exit(o),t.enter(i),t.consume(f),t.exit(i),t.exit(r),e):we(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),u):(t.enter("chunkString",{contentType:"string"}),h(f))}function h(f){return f===null||f===91||f===93||we(f)||a++>999?(t.exit("chunkString"),u(f)):(t.consume(f),l||(l=!Pe(f)),f===92?p:h)}function p(f){return f===91||f===92||f===93?(t.consume(f),a++,h):h(f)}}function gm(t,e,n,r,i,o){let s;return a;function a(p){return p===34||p===39||p===40?(t.enter(r),t.enter(i),t.consume(p),t.exit(i),s=p===40?41:p,l):n(p)}function l(p){return p===s?(t.enter(i),t.consume(p),t.exit(i),t.exit(r),e):(t.enter(o),c(p))}function c(p){return p===s?(t.exit(o),l(s)):p===null?n(p):we(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),Ve(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),u(p))}function u(p){return p===s||p===null||we(p)?(t.exit("chunkString"),c(p)):(t.consume(p),p===92?h:u)}function h(p){return p===s||p===92?(t.consume(p),u):u(p)}}function mi(t,e){let n;return r;function r(i){return we(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n=!0,r):Pe(i)?Ve(t,r,n?"linePrefix":"lineSuffix")(i):e(i)}}const Yk={name:"definition",tokenize:Gk},Jk={partial:!0,tokenize:Qk};function Gk(t,e,n){const r=this;let i;return o;function o(f){return t.enter("definition"),s(f)}function s(f){return mm.call(r,t,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function a(f){return i=jr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(t.enter("definitionMarker"),t.consume(f),t.exit("definitionMarker"),l):n(f)}function l(f){return Nt(f)?mi(t,c)(f):c(f)}function c(f){return pm(t,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function u(f){return t.attempt(Jk,h,h)(f)}function h(f){return Pe(f)?Ve(t,p,"whitespace")(f):p(f)}function p(f){return f===null||we(f)?(t.exit("definition"),r.parser.defined.push(i),e(f)):n(f)}}function Qk(t,e,n){return r;function r(a){return Nt(a)?mi(t,i)(a):n(a)}function i(a){return gm(t,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return Pe(a)?Ve(t,s,"whitespace")(a):s(a)}function s(a){return a===null||we(a)?e(a):n(a)}}const Xk={name:"hardBreakEscape",tokenize:Zk};function Zk(t,e,n){return r;function r(o){return t.enter("hardBreakEscape"),t.consume(o),i}function i(o){return we(o)?(t.exit("hardBreakEscape"),e(o)):n(o)}}const eS={name:"headingAtx",resolve:tS,tokenize:nS};function tS(t,e){let n=t.length-2,r=3,i,o;return t[r][1].type==="whitespace"&&(r+=2),n-2>
vendor: 17,409 bytes, line 372
372r&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&t[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:t[r][1].start,end:t[n][1].end},o={type:"chunkText",start:t[r][1].start,end:t[n][1].end,contentType:"text"},un(t,r,n-r+1,[["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e]])),t}function nS(t,e,n){let r=0;return i;function i(u){return t.enter("atxHeading"),o(u)}function o(u){return t.enter("atxHeadingSequence"),s(u)}function s(u){return u===35&&r++<6?(t.consume(u),s):u===null||Nt(u)?(t.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(t.enter("atxHeadingSequence"),l(u)):u===null||we(u)?(t.exit("atxHeading"),e(u)):Pe(u)?Ve(t,a,"whitespace")(u):(t.enter("atxHeadingText"),c(u))}function l(u){return u===35?(t.consume(u),l):(t.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||Nt(u)?(t.exit("atxHeadingText"),a(u)):(t.consume(u),c)}}const rS=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Ru=["pre","script","style","textarea"],iS={concrete:!0,name:"htmlFlow",resolveTo:aS,tokenize:lS},oS={partial:!0,tokenize:uS},sS={partial:!0,tokenize:cS};function aS(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function lS(t,e,n){const r=this;let i,o,s,a,l;return c;function c(w){return u(w)}function u(w){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(w),h}function h(w){return w===33?(t.consume(w),p):w===47?(t.consume(w),o=!0,g):w===63?(t.consume(w),i=3,r.interrupt?e:k):ln(w)?(t.consume(w),s=String.fromCharCode(w),x):n(w)}function p(w){return w===45?(t.consume(w),i=2,f):w===91?(t.consume(w),i=5,a=0,m):ln(w)?(t.consume(w),i=4,r.interrupt?e:k):n(w)}function f(w){return w===45?(t.consume(w),r.interrupt?e:k):n(w)}function m(w){const J="CDATA[";return w===J.charCodeAt(a++)?(t.consume(w),a===J.length?r.interrupt?e:O:m):n(w)}function g(w){return ln(w)?(t.consume(w),s=String.fromCharCode(w),x):n(w)}function x(w){if(w===null||w===47||w===62||Nt(w)){const J=w===47,te=s.toLowerCase();return!J&&!o&&Ru.includes(te)?(i=1,r.interrupt?e(w):O(w)):rS.includes(s.toLowerCase())?(i=6,J?(t.consume(w),b):r.interrupt?e(w):O(w)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(w):o?E(w):v(w))}return w===45||$t(w)?(t.consume(w),s+=String.fromCharCode(w),x):n(w)}function b(w){return w===62?(t.consume(w),r.interrupt?e:O):n(w)}function E(w){return Pe(w)?(t.consume(w),E):P(w)}function v(w){return w===47?(t.consume(w),P):w===58||w===95||ln(w)?(t.consume(w),A):Pe(w)?(t.consume(w),v):P(w)}function A(w){return w===45||w===46||w===58||w===95||$t(w)?(t.consume(w),A):_(w)}function _(w){return w===61?(t.consume(w),S):Pe(w)?(t.consume(w),_):v(w)}function S(w){return w===null||w===60||w===61||w===62||w===96?n(w):w===34||w===39?(t.consume(w),l=w,N):Pe(w)?(t.consume(w),S):M(w)}function N(w){return w===l?(t.consume(w),l=null,L):w===null||we(w)?n(w):(t.consume(w),N)}function M(w){return w===null||w===34||w===39||w===47||w===60||w===61||w===62||w===96||Nt(w)?_(w):(t.consume(w),M)}function L(w){return w===47||w===62||Pe(w)?v(w):n(w)}function P(w){return w===62?(t.consume(w),T):n(w)}function T(w){return w===null||we(w)?O(w):Pe(w)?(t.consume(w),T):n(w)}function O(w){return w===45&&i===2?(t.consume(w),ee):w===60&&i===1?(t.consume(w),Q):w===62&&i===4?(t.consume(w),pe):w===63&&i===3?(t.consume(w),k):w===93&&i===5?(t.consume(w),V):we(w)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(oS,R,H)(w)):w===null||we(w)?(t.exit("htmlFlowData"),H(w)):(t.consume(w),O)}function H(w){return t.check(sS,D,R)(w)}function D(w){return t.enter("lineEnding"),t.consume(w),t.exit("lineEnding"),z}function z(w){return w===null||we(w)?H(w):(t.enter("htmlFlowData"),O(w))}function ee(w){return w===45?(t.consume(w),k):O(w)}function Q(w){return w===47?(t.consume(w),s="",F):O(w)}function F(w){if(w===62){const J=s.toLowerCase();return Ru.includes(J)?(t.consume(w),pe):O(w)}return ln(w)&&s.length<8?(t.consume(w),s+=String.fromCharCode(w),F):O(w)}function V(w){return w===93?(t.consume(w),k):O(w)}function k(w){return w===62?(t.consume(w),pe):w===45&&i===2?(t.consume(w),k):O(w)}function pe(w){return w===null||we(w)?(t.exit("htmlFlowData"),R(w)):(t.consume(w),pe)}function R(w){return t.exit("htmlFlow"),e(w)}}function cS(t,e,n){const r=this;return i;function i(s){return we(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),o):n(s)}function o(s){return r.parser.lazy[r.now().line]?n(s):e(s)}}function uS(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(Es,e,n)}}const dS={name:"htmlText",tokenize:hS};function hS(t,e,n){const r=this;let i,o,s;return a;function a(k){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(k),l}function l(k){return k===33?(t.consume(k),c):k===47?(t.consume(k),_):k===63?(t.consume(k),v):ln(k)?(t.consume(k),M):n(k)}function c(k){return k===45?(t.consume(k),u):k===91?(t.consume(k),o=0,m):ln(k)?(t.consume(k),E):n(k)}function u(k){return k===45?(t.consume(k),f):n(k)}function h(k){return k===null?n(k):k===45?(t.consume(k),p):we(k)?(s=h,Q(k)):(t.consume(k),h)}function p(k){return k===45?(t.consume(k),f):h(k)}function f(k){return k===62?ee(k):k===45?p(k):h(k)}function m(k){const pe="CDATA[";return k===pe.charCodeAt(o++)?(t.consume(k),o===pe.length?g:m):n(k)}function g(k){return k===null?n(k):k===93?(t.consume(k),x):we(k)?(s=g,Q(k)):(t.consume(k),g)}function x(k){return k===93?(t.consume(k),b):g(k)}function b(k){return k===62?ee(k):k===93?(t.consume(k),b):g(k)}function E(k){return k===null||k===62?ee(k):we(k)?(s=E,Q(k)):(t.consume(k),E)}function v(k){return k===null?n(k):k===63?(t.consume(k),A):we(k)?(s=v,Q(k)):(t.consume(k),v)}function A(k){return k===62?ee(k):v(k)}function _(k){return ln(k)?(t.consume(k),S):n(k)}function S(k){return k===45||$t(k)?(t.consume(k),S):N(k)}function N(k){return we(k)?(s=N,Q(k)):Pe(k)?(t.consume(k),N):ee(k)}function M(k){return k===45||$t(k)?(t.consume(k),M):k===47||k===62||Nt(k)?L(k):n(k)}function L(k){return k===47?(t.consume(k),ee):k===58||k===95||ln(k)?(t.consume(k),P):we(k)?(s=L,Q(k)):Pe(k)?(t.consume(k),L):ee(k)}function P(k){return k===45||k===46||k===58||k===95||$t(k)?(t.consume(k),P):T(k)}function T(k){return k===61?(t.consume(k),O):we(k)?(s=T,Q(k)):Pe(k)?(t.consume(k),T):L(k)}function O(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(t.consume(k),i=k,H):we(k)?(s=O,Q(k)):Pe(k)?(t.consume(k),O):(t.consume(k),D)}function H(k){return k===i?(t.consume(k),i=void 0,z):k===null?n(k):we(k)?(s=H,Q(k)):(t.consume(k),H)}function D(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||Nt(k)?L(k):(t.consume(k),D)}function z(k){return k===47||k===62||Nt(k)?L(k):n(k)}function ee(k){return k===62?(t.consume(k),t.exit("htmlTextData"),t.exit("htmlText"),e):n(k)}function Q(k){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),F}function F(k){return Pe(k)?Ve(t,V,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):V(k)}function V(k){return t.enter("htmlTextData"),s(k)}}const sc={name:"labelEnd",resolveAll:gS,resolveTo:yS,tokenize:xS},fS={tokenize:bS},pS={tokenize:wS},mS={tokenize:vS};function gS(t){let e=-1;const n=[];for(;++e<t.length;){const r=t[e][1];if(n.push(t[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return t.length!==n.length&&un(t,0,t.length,n),t}function yS(t,e){let n=t.length,r=0,i,o,s,a;for(;n--;)if(i=t[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;t[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(s){if(t[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(s=n);const l={type:t[o][1].type==="labelLink"?"link":"image",start:{...t[o][1].start},end:{...t[t.length-1][1].end}},c={type:"label",start:{...t[o][1].start},end:{...t[s][1].end}},u={type:"labelText",start:{...t[o+r+2][1].end},end:{...t[s-2][1].start}};return a=[["enter",l,e],["enter",c,e]],a=Ht(a,t.slice(o+1,o+r+3)),a=Ht(a,[["enter",u,e]]),a=Ht(a,oc(e.parser.constructs.insideSpan.null,t.slice(o+r+4,s-3),e)),a=Ht(a,[["exit",u,e],t[s-2],t[s-1],["exit",c,e]]),a=Ht(a,t.slice(s+1)),a=Ht(a,[["exit",l,e]]),un(t,o,t.length,a),t}function xS(t,e,n){const r=this;let i=r.events.length,o,s;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return a;function a(p){return o?o._inactive?h(p):(s=r.parser.defined.includes(jr(r.sliceSerialize({start:o.end,end:r.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(p),t.exit("labelMarker"),t.exit("labelEnd"),l):n(p)}function l(p){return p===40?t.attempt(fS,u,s?u:h)(p):p===91?t.attempt(pS,u,s?c:h)(p):s?u(p):h(p)}function c(p){return t.attempt(mS,u,h)(p)}function u(p){return e(p)}function h(p){return o._balanced=!0,n(p)}}function bS(t,e,n){return r;function r(h){return t.enter("resource"),t.enter("resourceMarker"),t.consume(h),t.exit("resourceMarker"),i}function i(h){return Nt(h)?mi(t,o)(h):o(h)}function o(h){return h===41?u(h):pm(t,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function s(h){return Nt(h)?mi(t,l)(h):u(h)}function a(h){return n(h)}function l(h){return h===34||h===39||h===40?gm(t,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):u(h)}function c(h){return Nt(h)?mi(t,u)(h):u(h)}function u(h){return h===41?(t.enter("resourceMarker"),t.consume(h),t.exit("resourceMarker"),t.exit("resource"),e):n(h)}}function wS(t,e,n){const r=this;return i;function i(a){return mm.call(r,t,o,s,"reference","referenceMarker","referenceString")(a)}function o(a){return r.parser.defined.includes(jr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(a):n(a)}function s(a){return n(a)}}function vS(t,e,n){return r;function r(o){return t.enter("reference"),t.enter("referenceMarker"),t.consume(o),t.exit("referenceMarker"),i}function i(o){return o===93?(t.enter("referenceMarker"),t.consume(o),t.exit("referenceMarker"),t.exit("reference"),e):n(o)}}const kS={name:"labelStartImage",resolveAll:sc.resolveAll,tokenize:SS};function SS(t,e,n){const r=this;return i;function i(a){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(a),t.exit("labelImageMarker"),o}function o(a){return a===91?(t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelImage"),s):n(a)}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):e(a)}}const CS={name:"labelStartLink",resolveAll:sc.resolveAll,tokenize:ES};function ES(t,e,n){const r=this;return i;function i(s){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(s),t.exit("labelMarker"),t.exit("labelLink"),o}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):e(s)}}const ia={name:"lineEnding",tokenize:TS};function TS(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),Ve(t,e,"linePrefix")}}const Mo={name:"thematicBreak",tokenize:_S};function _S(t,e,n){let r=0,i;return o;function o(c){return t.enter("thematicBreak"),s(c)}function s(c){return i=c,a(c)}function a(c){return c===i?(t.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||we(c))?(t.exit("thematicBreak"),e(c)):n(c)}function l(c){return c===i?(t.consume(c),r++,l):(t.exit("thematicBreakSequence"),Pe(c)?Ve(t,a,"whitespace")(c):a(c))}}const Et={continuation:{tokenize:jS},exit:RS,name:"list",tokenize:NS},AS={partial:!0,tokenize:OS},MS={partial:!0,tokenize:IS};function NS(t,e,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return a;function a(f){const m=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:ol(f)){if(r.containerState.type||(r.containerState.type=m,t.enter(m,{_container:!0})),m==="listUnordered")return t.enter("listItemPrefix"),f===42||f===45?t.check(Mo,n,c)(f):c(f);if(!r.interrupt||f===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),l(f)}return n(f)}function l(f){return ol(f)&&++s<10?(t.consume(f),l):(!r.interrupt||s<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(t.exit("listItemValue"),c(f)):n(f)}function c(f){return t.enter("listItemMarker"),t.consume(f),t.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,t.check(Es,r.interrupt?n:u,t.attempt(AS,p,h))}function u(f){return r.containerState.initialBlankLine=!0,o++,p(f)}function h(f){return Pe(f)?(t.enter("listItemPrefixWhitespace"),t.consume(f),t.exit("listItemPrefixWhitespace"),p):n(f)}function p(f){return r.containerState.size=o+r.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(f)}}function jS(t,e,n){const r=this;return r.containerState._closeFlow=void 0,t.check(Es,i,o);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ve(t,e,"listItemIndent",r.containerState.size+1)(a)}function o(a){return r.containerState.furtherBlankLines||!Pe(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,t.attempt(MS,e,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ve(t,t.attempt(Et,e,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function IS(t,e,n){const r=this;return Ve(t,i,"listItemIndent",r.containerState.size+1);function i(o){const s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?e(o):n(o)}}function RS(t){t.exit(this.containerState.type)}function OS(t,e,n){const r=this;return Ve(t,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const s=r.events[r.events.length-1];return!Pe(o)&&s&&s[1].type==="listItemPrefixWhitespace"?e(o):n(o)}}const Ou={name:"setextUnderline",resolveTo:PS,tokenize:DS};function PS(t,e){let n=t.length,r,i,o;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){r=n;break}t[n][1].type==="paragraph"&&(i=n)}else t[n][1].type==="content"&&t.splice(n,1),!o&&t[n][1].type==="definition"&&(o=n);const s={type:"setextHeading",start:{...t[r][1].start},end:{...t[t.length-1][1].end}};return t[i][1].type="setextHeadingText",o?(t.splice(i,0,["enter",s,e]),t.splice(o+1,0,["exit",t[r][1],e]),t[r][1].end={...t[o][1].end}):t[r][1]=s,t.push(["exit",s,e]),t}function DS(t,e,n){const r=this;let i;return o;function o(c){let u=r.events.length,h;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){h=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(t.enter("setextHeadingLine"),i=c,s(c)):n(c)}function s(c){return t.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(t.consume(c),a):(t.exit("setextHeadingLineSequence"),Pe(c)?Ve(t,l,"lineSuffix")(c):l(c))}function l(c){return c===null||we(c)?(t.exit("setextHeadingLine"),e(c)):n(c)}}const LS={tokenize:BS};function BS(t){const e=this,n=t.attempt(Es,r,t.attempt(this.parser.constructs.flowInitial,i,Ve(t,t.attempt(this.parser.constructs.flow,i,t.attempt(Wk,i)),"linePrefix")));return n;function r(o){if(o===null){t.consume(o);return}return t.enter("lineEndingBlank"),t.consume(o),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function i(o){if(o===null){t.consume(o);return}return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),e.currentConstruct=void 0,n}}const zS={resolveAll:xm()},FS=ym("string"),$S=ym("text");function ym(t){return{resolveAll:xm(t==="text"?VS:void 0),tokenize:e};function e(n){const r=this,i=this.parser.constructs[t],o=n.attempt(i,s,a);return s;function s(u){return c(u)?o(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),o(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const h=i[u];let p=-1;if(h)for(;++p<h.length;){const f=h[p];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function xm(t){return e;function e(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return t?t(n,r):n}}function VS(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){const r=t[n-1][1],i=e.sliceStream(r);let o=i.length,s=-1,a=0,l;for(;o--;){const c=i[o];if(typeof c=="string"){for(s=c.length;
vendor: 4,564 bytes, lines 372-374
372c.charCodeAt(s-1)===32;)a++,s--;if(s)break;s=-1}else if(c===-2)l=!0,a++;else if(c!==-1){o++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(a=0),a){const c={type:n===t.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?s:r.start._bufferIndex+s,_index:r.start._index+o,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(t.splice(n,0,["enter",c,e],["exit",c,e]),n+=2)}n++}return t}const WS={42:Et,43:Et,45:Et,48:Et,49:Et,50:Et,51:Et,52:Et,53:Et,54:Et,55:Et,56:Et,57:Et,62:um},HS={91:Yk},qS={[-2]:ra,[-1]:ra,32:ra},US={35:eS,42:Mo,45:[Ou,Mo],60:iS,61:Ou,95:Mo,96:Iu,126:Iu},KS={38:hm,92:dm},YS={[-5]:ia,[-4]:ia,[-3]:ia,33:kS,38:hm,42:sl,60:[Ck,dS],91:CS,92:[Xk,dm],93:sc,95:sl,96:Lk},JS={null:[sl,zS]},GS={null:[42,95]},QS={null:[]},XS=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:GS,contentInitial:HS,disable:QS,document:WS,flow:US,flowInitial:qS,insideSpan:JS,string:KS,text:YS},Symbol.toStringTag,{value:"Module"}));function ZS(t,e,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},o=[];let s=[],a=[];const l={attempt:N(_),check:N(S),consume:E,enter:v,exit:A,interrupt:N(S,{interrupt:!0})},c={code:null,containerState:{},defineSkip:g,events:[],now:m,parser:t,previous:null,sliceSerialize:p,sliceStream:f,write:h};let u=e.tokenize.call(c,l);return e.resolveAll&&o.push(e),c;function h(T){return s=Ht(s,T),x(),s[s.length-1]!==null?[]:(M(e,0),c.events=oc(o,c.events,c),c.events)}function p(T,O){return tC(f(T),O)}function f(T){return eC(s,T)}function m(){const{_bufferIndex:T,_index:O,line:H,column:D,offset:z}=r;return{_bufferIndex:T,_index:O,line:H,column:D,offset:z}}function g(T){i[T.line]=T.column,P()}function x(){let T;for(;r._index<s.length;){const O=s[r._index];if(typeof O=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<O.length;)b(O.charCodeAt(r._bufferIndex));else b(O)}}function b(T){u=u(T)}function E(T){we(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,P()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=T}function v(T,O){const H=O||{};return H.type=T,H.start=m(),c.events.push(["enter",H,c]),a.push(H),H}function A(T){const O=a.pop();return O.end=m(),c.events.push(["exit",O,c]),O}function _(T,O){M(T,O.from)}function S(T,O){O.restore()}function N(T,O){return H;function H(D,z,ee){let Q,F,V,k;return Array.isArray(D)?R(D):"tokenize"in D?R([D]):pe(D);function pe(B){return X;function X(ne){const ue=ne!==null&&B[ne],je=ne!==null&&B.null,Le=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(je)?je:je?[je]:[]];return R(Le)(ne)}}function R(B){return Q=B,F=0,B.length===0?ee:w(B[F])}function w(B){return X;function X(ne){return k=L(),V=B,B.partial||(c.currentConstruct=B),B.name&&c.parser.constructs.disable.null.includes(B.name)?te():B.tokenize.call(O?Object.assign(Object.create(c),O):c,l,J,te)(ne)}}function J(B){return T(V,k),z}function te(B){return k.restore(),++F<Q.length?w(Q[F]):ee}}}function M(T,O){T.resolveAll&&!o.includes(T)&&o.push(T),T.resolve&&un(c.events,O,c.events.length-O,T.resolve(c.events.slice(O),c)),T.resolveTo&&(c.events=T.resolveTo(c.events,c))}function L(){const T=m(),O=c.previous,H=c.currentConstruct,D=c.events.length,z=Array.from(a);return{from:D,restore:ee};function ee(){r=T,c.previous=O,c.currentConstruct=H,c.events.length=D,a=z,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function eC(t,e){const n=e.start._index,r=e.start._bufferIndex,i=e.end._index,o=e.end._bufferIndex;let s;if(n===i)s=[t[n].slice(r,o)];else{if(s=t.slice(n,i),r>-1){const a=s[0];typeof a=="string"?s[0]=a.slice(r):s.shift()}o>0&&s.push(t[i].slice(0,o))}return s}function tC(t,e){let n=-1;const r=[];let i;for(;++n<t.length;){const o=t[n];let s;if(typeof o=="string")s=o;else switch(o){case-5:{s="\r";break}case-4:{s=` 373`;break}case-3:{s=`\r 374`;break}case-2:{s=e?" ":" ";break}case-1:{if(!e&&i)continue;s=" ";break}default:s=String.fromCharCode(o)}i=o===-2,r.push(s)}return r.join("")}function nC(t){const r={constructs:ck([XS,...(t||{}).extensions||[]]),content:i(yk),defined:[],document:i(bk),flow:i(LS),lazy:{},string:i(FS),text:i($S)};return r;function i(o){return s;function s(a){return ZS(r,o,a)}}}function rC(t){for(;!fm(t););return t}const Pu=/[\0\t\n\r]/g;function iC(){let t=1,e="",n=!0,r;return i;function i(o,s,a){const l=[];let c,u,h,p,f;
vendor: 17,090 bytes, lines 374-378
374for(o=e+(typeof o=="string"?o.toString():new TextDecoder(s||void 0).decode(o)),h=0,e="",n&&(o.charCodeAt(0)===65279&&h++,n=void 0);h<o.length;){if(Pu.lastIndex=h,c=Pu.exec(o),p=c&&c.index!==void 0?c.index:o.length,f=o.charCodeAt(p),!c){e=o.slice(h);break}if(f===10&&h===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),h<p&&(l.push(o.slice(h,p)),t+=p-h),f){case 0:{l.push(65533),t++;break}case 9:{for(u=Math.ceil(t/4)*4,l.push(-2);t++<u;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:r=!0,t=1}h=p+1}return a&&(r&&l.push(-5),e&&l.push(e),l.push(null)),l}}const oC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function sC(t){return t.replace(oC,aC)}function aC(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return cm(n.slice(o?2:1),o?16:10)}return ic(n)||t}const bm={}.hasOwnProperty;function lC(t,e,n){return typeof e!="string"&&(n=e,e=void 0),cC(n)(rC(nC(n).document().write(iC()(t,e,!0))))}function cC(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ie),autolinkProtocol:L,autolinkEmail:L,atxHeading:o(me),blockQuote:o(je),characterEscape:L,characterReference:L,codeFenced:o(Le),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(Le,s),codeText:o(Ue,s),codeTextData:L,data:L,codeFlowValue:L,definition:o(We),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(re),hardBreakEscape:o(he),hardBreakTrailing:o(he),htmlFlow:o(ae,s),htmlFlowData:L,htmlText:o(ae,s),htmlTextData:L,image:o(ke),label:s,link:o(Ie),listItem:o(Ee),listItemValue:p,listOrdered:o(be,h),listUnordered:o(be),paragraph:o(De),reference:w,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(me),strong:o(G),thematicBreak:o(de)},exit:{atxHeading:l(),atxHeadingSequence:_,autolink:l(),autolinkEmail:ue,autolinkProtocol:ne,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:te,characterReferenceMarkerNumeric:te,characterReferenceValue:B,characterReference:X,codeFenced:l(x),codeFencedFence:g,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(b),codeText:l(z),codeTextData:P,data:P,definition:l(),definitionDestinationString:A,definitionLabelString:E,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(O),hardBreakTrailing:l(O),htmlFlow:l(H),htmlFlowData:P,htmlText:l(D),htmlTextData:P,image:l(Q),label:V,labelText:F,lineEnding:T,link:l(ee),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:J,resourceDestinationString:k,resourceTitleString:pe,resource:R,setextHeading:l(M),setextHeadingLineSequence:N,setextHeadingText:S,strong:l(),thematicBreak:l()}};wm(e,(t||{}).mdastExtensions||[]);const n={};return r;function r(I){let W={type:"root",children:[]};const ie={stack:[W],tokenStack:[],config:e,enter:a,exit:c,buffer:s,resume:u,data:n},fe=[];let ge=-1;for(;++ge<I.length;)if(I[ge][1].type==="listOrdered"||I[ge][1].type==="listUnordered")if(I[ge][0]==="enter")fe.push(ge);else{const Me=fe.pop();ge=i(I,Me,ge)}for(ge=-1;++ge<I.length;){const Me=e[I[ge][0]];bm.call(Me,I[ge][1].type)&&Me[I[ge][1].type].call(Object.assign({sliceSerialize:I[ge][2].sliceSerialize},ie),I[ge][1])}if(ie.tokenStack.length>0){const Me=ie.tokenStack[ie.tokenStack.length-1];(Me[1]||Du).call(ie,void 0,Me[0])}for(W.position={start:kn(I.length>0?I[0][1].start:{line:1,column:1,offset:0}),end:kn(I.length>0?I[I.length-2][1].end:{line:1,column:1,offset:0})},ge=-1;++ge<e.transforms.length;)W=e.transforms[ge](W)||W;return W}function i(I,W,ie){let fe=W-1,ge=-1,Me=!1,Dt,it,ft,fn;for(;++fe<=ie;){const He=I[fe];switch(He[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{He[0]==="enter"?ge++:ge--,fn=void 0;break}case"lineEndingBlank":{He[0]==="enter"&&(Dt&&!fn&&!ge&&!ft&&(ft=fe),fn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:fn=void 0}if(!ge&&He[0]==="enter"&&He[1].type==="listItemPrefix"||ge===-1&&He[0]==="exit"&&(He[1].type==="listUnordered"||He[1].type==="listOrdered")){if(Dt){let Jt=fe;for(it=void 0;Jt--;){const Lt=I[Jt];if(Lt[1].type==="lineEnding"||Lt[1].type==="lineEndingBlank"){if(Lt[0]==="exit")continue;it&&(I[it][1].type="lineEndingBlank",Me=!0),Lt[1].type="lineEnding",it=Jt}else if(!(Lt[1].type==="linePrefix"||Lt[1].type==="blockQuotePrefix"||Lt[1].type==="blockQuotePrefixWhitespace"||Lt[1].type==="blockQuoteMarker"||Lt[1].type==="listItemIndent"))break}ft&&(!it||ft<it)&&(Dt._spread=!0),Dt.end=Object.assign({},it?I[it][1].start:He[1].end),I.splice(it||fe,0,["exit",Dt,He[2]]),fe++,ie++}if(He[1].type==="listItemPrefix"){const Jt={type:"listItem",_spread:!1,start:Object.assign({},He[1].start),end:void 0};Dt=Jt,I.splice(fe,0,["enter",Jt,He[2]]),fe++,ie++,ft=void 0,fn=!0}}}return I[W][1]._spread=Me,ie}function o(I,W){return ie;function ie(fe){a.call(this,I(fe),fe),W&&W.call(this,fe)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(I,W,ie){this.stack[this.stack.length-1].children.push(I),this.stack.push(I),this.tokenStack.push([W,ie||void 0]),I.position={start:kn(W.start),end:void 0}}function l(I){return W;function W(ie){I&&I.call(this,ie),c.call(this,ie)}}function c(I,W){const ie=this.stack.pop(),fe=this.tokenStack.pop();if(fe)fe[0].type!==I.type&&(W?W.call(this,I,fe[0]):(fe[1]||Du).call(this,I,fe[0]));else throw new Error("Cannot close `"+I.type+"` ("+pi({start:I.start,end:I.end})+"): itâs not open");ie.position.end=kn(I.end)}function u(){return ak(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function p(I){if(this.data.expectingFirstListItemValue){const W=this.stack[this.stack.length-2];W.start=Number.parseInt(this.sliceSerialize(I),10),this.data.expectingFirstListItemValue=void 0}}function f(){const I=this.resume(),W=this.stack[this.stack.length-1];W.lang=I}function m(){const I=this.resume(),W=this.stack[this.stack.length-1];W.meta=I}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const I=this.resume(),W=this.stack[this.stack.length-1];W.value=I.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){const I=this.resume(),W=this.stack[this.stack.length-1];W.value=I.replace(/(\r?\n|\r)$/g,"")}function E(I){const W=this.resume(),ie=this.stack[this.stack.length-1];ie.label=W,ie.identifier=jr(this.sliceSerialize(I)).toLowerCase()}function v(){const I=this.resume(),W=this.stack[this.stack.length-1];W.title=I}function A(){const I=this.resume(),W=this.stack[this.stack.length-1];W.url=I}function _(I){const W=this.stack[this.stack.length-1];if(!W.depth){const ie=this.sliceSerialize(I).length;W.depth=ie}}function S(){this.data.setextHeadingSlurpLineEnding=!0}function N(I){const W=this.stack[this.stack.length-1];W.depth=this.sliceSerialize(I).codePointAt(0)===61?1:2}function M(){this.data.setextHeadingSlurpLineEnding=void 0}function L(I){const ie=this.stack[this.stack.length-1].children;let fe=ie[ie.length-1];(!fe||fe.type!=="text")&&(fe=le(),fe.position={start:kn(I.start),end:void 0},ie.push(fe)),this.stack.push(fe)}function P(I){const W=this.stack.pop();W.value+=this.sliceSerialize(I),W.position.end=kn(I.end)}function T(I){const W=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ie=W.children[W.children.length-1];ie.position.end=kn(I.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(W.type)&&(L.call(this,I),P.call(this,I))}function O(){this.data.atHardBreak=!0}function H(){const I=this.resume(),W=this.stack[this.stack.length-1];W.value=I}function D(){const I=this.resume(),W=this.stack[this.stack.length-1];W.value=I}function z(){const I=this.resume(),W=this.stack[this.stack.length-1];W.value=I}function ee(){const I=this.stack[this.stack.length-1];if(this.data.inReference){const W=this.data.referenceType||"shortcut";I.type+="Reference",I.referenceType=W,delete I.url,delete I.title}else delete I.identifier,delete I.label;this.data.referenceType=void 0}function Q(){const I=this.stack[this.stack.length-1];if(this.data.inReference){const W=this.data.referenceType||"shortcut";I.type+="Reference",I.referenceType=W,delete I.url,delete I.title}else delete I.identifier,delete I.label;this.data.referenceType=void 0}function F(I){const W=this.sliceSerialize(I),ie=this.stack[this.stack.length-2];ie.label=sC(W),ie.identifier=jr(W).toLowerCase()}function V(){const I=this.stack[this.stack.length-1],W=this.resume(),ie=this.stack[this.stack.length-1];if(this.data.inReference=!0,ie.type==="link"){const fe=I.children;ie.children=fe}else ie.alt=W}function k(){const I=this.resume(),W=this.stack[this.stack.length-1];W.url=I}function pe(){const I=this.resume(),W=this.stack[this.stack.length-1];W.title=I}function R(){this.data.inReference=void 0}function w(){this.data.referenceType="collapsed"}function J(I){const W=this.resume(),ie=this.stack[this.stack.length-1];ie.label=W,ie.identifier=jr(this.sliceSerialize(I)).toLowerCase(),this.data.referenceType="full"}function te(I){this.data.characterReferenceType=I.type}function B(I){const W=this.sliceSerialize(I),ie=this.data.characterReferenceType;let fe;ie?(fe=cm(W,ie==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):fe=ic(W);const ge=this.stack[this.stack.length-1];ge.value+=fe}function X(I){const W=this.stack.pop();W.position.end=kn(I.end)}function ne(I){P.call(this,I);const W=this.stack[this.stack.length-1];W.url=this.sliceSerialize(I)}function ue(I){P.call(this,I);const W=this.stack[this.stack.length-1];W.url="mailto:"+this.sliceSerialize(I)}function je(){return{type:"blockquote",children:[]}}function Le(){return{type:"code",lang:null,meta:null,value:""}}function Ue(){return{type:"inlineCode",value:""}}function We(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function re(){return{type:"emphasis",children:[]}}function me(){return{type:"heading",depth:0,children:[]}}function he(){return{type:"break"}}function ae(){return{type:"html",value:""}}function ke(){return{type:"image",title:null,url:"",alt:null}}function Ie(){return{type:"link",title:null,url:"",children:[]}}function be(I){return{type:"list",ordered:I.type==="listOrdered",start:null,spread:I._spread,children:[]}}function Ee(I){return{type:"listItem",spread:I._spread,checked:null,children:[]}}function De(){return{type:"paragraph",children:[]}}function G(){return{type:"strong",children:[]}}function le(){return{type:"text",value:""}}function de(){return{type:"thematicBreak"}}}function kn(t){return{line:t.line,column:t.column,offset:t.offset}}function wm(t,e){let n=-1;for(;++n<e.length;){const r=e[n];Array.isArray(r)?wm(t,r):uC(t,r)}}function uC(t,e){let n;for(n in e)if(bm.call(e,n))switch(n){case"canContainEols":{const r=e[n];r&&t[n].push(...r);break}case"transforms":{const r=e[n];r&&t[n].push(...r);break}case"enter":case"exit":{const r=e[n];r&&Object.assign(t[n],r);break}}}function Du(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+pi({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+pi({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+pi({start:e.start,end:e.end})+") is still open")}function dC(t){const e=this;e.parser=n;function n(r){return lC(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function hC(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function fC(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:` 375`}]}function pC(t,e){const n=e.value?e.value+` 376`:"",r={};e.lang&&(r.className=["language-"+e.lang]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return e.meta&&(i.data={meta:e.meta}),t.patch(e,i),i=t.applyData(e,i),i={type:"element",tagName:"pre",properties:{},children:[i]},t.patch(e,i),i}function mC(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function gC(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function yC(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",r=String(e.identifier).toUpperCase(),i=Jr(r.toLowerCase()),o=t.footnoteOrder.indexOf(r);let s,a=t.footnoteCounts.get(r);a===void 0?(a=0,t.footnoteOrder.push(r),s=t.footnoteOrder.length):s=o+1,a+=1,t.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};t.patch(e,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return t.patch(e,c),t.applyData(e,c)}function xC(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function bC(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function vm(t,e){const n=e.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+r}];const i=t.all(e),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const s=i[i.length-1];return s&&s.type==="text"?s.value+=r:i.push({type:"text",value:r}),i}function wC(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return vm(t,e);const i={src:Jr(r.url||""),alt:e.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return t.patch(e,o),t.applyData(e,o)}function vC(t,e){const n={src:Jr(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,r),t.applyData(e,r)}function kC(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,r),t.applyData(e,r)}function SC(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return vm(t,e);const i={href:Jr(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:t.all(e)};return t.patch(e,o),t.applyData(e,o)}function CC(t,e){const n={href:Jr(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function EC(t,e,n){const r=t.all(e),i=n?TC(n):km(e),o={},s=[];if(typeof e.checked=="boolean"){const u=r[0];let h;u&&u.type==="element"&&u.tagName==="p"?h=u:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const u=r[a];(i||a!==0||u.type!=="element"||u.tagName!=="p")&&s.push({type:"text",value:` 377`}),u.type==="element"&&u.tagName==="p"&&!i?s.push(...u.children):s.push(u)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&s.push({type:"text",value:` 378`});const c={type:"element",tagName:"li",properties:o,children:s};return t.patch(e,c),t.applyData(e,c)}function TC(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const n=t.children;let r=-1;for(;!e&&++r<n.length;)e=km(n[r])}return e}function km(t){const e=t.spread;return e??t.children.length>1}function _C(t,e){const n={},r=t.all(e);let i=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++i<r.length;){const s=r[i];if(s.type==="element"&&s.tagName==="li"&&s.properties&&Array.isArray(s.properties.className)&&s.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(r,!0)};return t.patch(e,o),t.applyData(e,o)}function AC(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function MC(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function NC(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function jC(t,e){const n=t.all(e),r=n.shift(),i=[];if(r){const s={type:"element",tagName:"thead",properties:{},children:t.wrap([r],!0)};t.patch(e.children[0],s),i.push(s)}if(n.length>0){const s={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},a=ec(e.children[1]),l=nm(e.children[e.children.length-1]);a&&l&&(s.position={start:a,end:l}),i.push(s)}const o={type:"element",tagName:"table",properties:{}
vendor: 6,190 bytes, lines 378-379
378,children:t.wrap(i,!0)};return t.patch(e,o),t.applyData(e,o)}function IC(t,e,n){const r=n?n.children:void 0,o=(r?r.indexOf(e):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,a=s?s.length:e.children.length;let l=-1;const c=[];for(;++l<a;){const h=e.children[l],p={},f=s?s[l]:void 0;f&&(p.align=f);let m={type:"element",tagName:o,properties:p,children:[]};h&&(m.children=t.all(h),t.patch(h,m),m=t.applyData(h,m)),c.push(m)}const u={type:"element",tagName:"tr",properties:{},children:t.wrap(c,!0)};return t.patch(e,u),t.applyData(e,u)}function RC(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}const Lu=9,Bu=32;function OC(t){const e=String(t),n=/\r?\n|\r/g;let r=n.exec(e),i=0;const o=[];for(;r;)o.push(zu(e.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(e);return o.push(zu(e.slice(i),i>0,!1)),o.join("")}function zu(t,e,n){let r=0,i=t.length;if(e){let o=t.codePointAt(r);for(;o===Lu||o===Bu;)r++,o=t.codePointAt(r)}if(n){let o=t.codePointAt(i-1);for(;o===Lu||o===Bu;)i--,o=t.codePointAt(i-1)}return i>r?t.slice(r,i):""}function PC(t,e){const n={type:"text",value:OC(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function DC(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const LC={blockquote:hC,break:fC,code:pC,delete:mC,emphasis:gC,footnoteReference:yC,heading:xC,html:bC,imageReference:wC,image:vC,inlineCode:kC,linkReference:SC,link:CC,listItem:EC,list:_C,paragraph:AC,root:MC,strong:NC,table:jC,tableCell:RC,tableRow:IC,text:PC,thematicBreak:DC,toml:so,yaml:so,definition:so,footnoteDefinition:so};function so(){}const Sm=-1,Ts=0,gi=1,Wo=2,ac=3,lc=4,cc=5,uc=6,Cm=7,Em=8,Fu=typeof self=="object"?self:globalThis,BC=(t,e)=>{const n=(i,o)=>(t.set(o,i),i),r=i=>{if(t.has(i))return t.get(i);const[o,s]=e[i];switch(o){case Ts:case Sm:return n(s,i);case gi:{const a=n([],i);for(const l of s)a.push(r(l));return a}case Wo:{const a=n({},i);for(const[l,c]of s)a[r(l)]=r(c);return a}case ac:return n(new Date(s),i);case lc:{const{source:a,flags:l}=s;return n(new RegExp(a,l),i)}case cc:{const a=n(new Map,i);for(const[l,c]of s)a.set(r(l),r(c));return a}case uc:{const a=n(new Set,i);for(const l of s)a.add(r(l));return a}case Cm:{const{name:a,message:l}=s;return n(new Fu[a](l),i)}case Em:return n(BigInt(s),i);case"BigInt":return n(Object(BigInt(s)),i);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:a}=new Uint8Array(s);return n(new DataView(a),s)}}return n(new Fu[o](s),i)};return r},$u=t=>BC(new Map,t)(0),xr="",{toString:zC}={},{keys:FC}=Object,ni=t=>{const e=typeof t;if(e!=="object"||!t)return[Ts,e];const n=zC.call(t).slice(8,-1);switch(n){case"Array":return[gi,xr];case"Object":return[Wo,xr];case"Date":return[ac,xr];case"RegExp":return[lc,xr];case"Map":return[cc,xr];case"Set":return[uc,xr];case"DataView":return[gi,n]}return n.includes("Array")?[gi,n]:n.includes("Error")?[Cm,n]:[Wo,n]},ao=([t,e])=>t===Ts&&(e==="function"||e==="symbol"),$C=(t,e,n,r)=>{const i=(s,a)=>{const l=r.push(s)-1;return n.set(a,l),l},o=s=>{if(n.has(s))return n.get(s);let[a,l]=ni(s);switch(a){case Ts:{let u=s;switch(l){case"bigint":a=Em,u=s.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+l);u=null;break;case"undefined":return i([Sm],s)}return i([a,u],s)}case gi:{if(l){let p=s;return l==="DataView"?p=new Uint8Array(s.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(s)),i([l,[...p]],s)}const u=[],h=i([a,u],s);for(const p of s)u.push(o(p));return h}case Wo:{if(l)switch(l){case"BigInt":return i([l,s.toString()],s);case"Boolean":case"Number":case"String":return i([l,s.valueOf()],s)}if(e&&"toJSON"in s)return o(s.toJSON());const u=[],h=i([a,u],s);for(const p of FC(s))(t||!ao(ni(s[p])))&&u.push([o(p),o(s[p])]);return h}case ac:return i([a,s.toISOString()],s);case lc:{const{source:u,flags:h}=s;return i([a,{source:u,flags:h}],s)}case cc:{const u=[],h=i([a,u],s);for(const[p,f]of s)(t||!(ao(ni(p))||ao(ni(f))))&&u.push([o(p),o(f)]);return h}case uc:{const u=[],h=i([a,u],s);for(const p of s)(t||!ao(ni(p)))&&u.push(o(p));return h}}const{message:c}=s;return i([a,{name:l,message:c}],s)};return o},Vu=(t,{json:e,lossy:n}={})=>{const r=[];return $C(!(e||n),!!e,new Map,r)(t),r},Ho=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?$u(Vu(t,e)):structuredClone(t):(t,e)=>$u(Vu(t,e));function VC(t,e){const n=[{type:"text",value:"â©"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function WC(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function HC(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||VC,r=t.options.footnoteBackLabel||WC,i=t.options.footnoteLabel||"Footnotes",o=t.options.footnoteLabelTagName||"h2",s=t.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<t.footnoteOrder.length;){const c=t.footnoteById.get(t.footnoteOrder[l]);if(!c)continue;const u=t.all(c),h=String(c.identifier).toUpperCase(),p=Jr(h.toLowerCase());let f=0;const m=[],g=t.footnoteCounts.get(h);for(;g!==void 0&&++f<=g;){m.length>0&&m.push({type:"text",value:" "});let E=typeof n=="string"?n:n(l,f);typeof E=="string"&&(E={type:"text",value:E}),m.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+p+(f>1?"-"+f:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,f),className:["data-footnote-backref"]},children:Array.isArray(E)?E:[E]})}const x=u[u.length-1];if(x&&x.type==="element"&&x.tagName==="p"){const E=x.children[x.children.length-1];E&&E.type==="text"?E.value+=" ":x.children.push({type:"text",value:" "}),x.children.push(...m)}else u.push(...m);const b={type:"element",tagName:"li",properties:{id:e+"fn-"+p},children:t.wrap(u,!0)};t.patch(c,b),a.push(b)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Ho(s),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:` 379`},{type:"element",tagName:"ol",properties:{},children:t.wrap(a,!0)}
vendor: 19,094 bytes, lines 379-384
379,{type:"text",value:` 380`}]}}const Tm=function(t){if(t==null)return YC;if(typeof t=="function")return _s(t);if(typeof t=="object")return Array.isArray(t)?qC(t):UC(t);if(typeof t=="string")return KC(t);throw new Error("Expected function, string, or object as test")};function qC(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=Tm(t[n]);return _s(r);function r(...i){let o=-1;for(;++o<e.length;)if(e[o].apply(this,i))return!0;return!1}}function UC(t){const e=t;return _s(n);function n(r){const i=r;let o;for(o in t)if(i[o]!==e[o])return!1;return!0}}function KC(t){return _s(e);function e(n){return n&&n.type===t}}function _s(t){return e;function e(n,r,i){return!!(JC(n)&&t.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function YC(){return!0}function JC(t){return t!==null&&typeof t=="object"&&"type"in t}const _m=[],GC=!0,Wu=!1,QC="skip";function XC(t,e,n,r){let i;typeof e=="function"&&typeof n!="function"?(r=n,n=e):i=e;const o=Tm(i),s=r?-1:1;a(t,void 0,[])();function a(l,c,u){const h=l&&typeof l=="object"?l:{};if(typeof h.type=="string"){const f=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(f?"<"+f+">":""))+")"})}return p;function p(){let f=_m,m,g,x;if((!e||o(l,c,u[u.length-1]||void 0))&&(f=ZC(n(l,u)),f[0]===Wu))return f;if("children"in l&&l.children){const b=l;if(b.children&&f[0]!==QC)for(g=(r?b.children.length:-1)+s,x=u.concat(b);g>-1&&g<b.children.length;){const E=b.children[g];if(m=a(E,g,x)(),m[0]===Wu)return m;g=typeof m[1]=="number"?m[1]:g+s}}return f}}}function ZC(t){return Array.isArray(t)?t:typeof t=="number"?[GC,t]:t==null?_m:[t]}function Am(t,e,n,r){let i,o,s;typeof e=="function"&&typeof n!="function"?(o=void 0,s=e,i=n):(o=e,s=n,i=r),XC(t,o,a,i);function a(l,c){const u=c[c.length-1],h=u?u.children.indexOf(l):void 0;return s(l,h,u)}}const al={}.hasOwnProperty,eE={};function tE(t,e){const n=e||eE,r=new Map,i=new Map,o=new Map,s={...LC,...n.handlers},a={all:c,applyData:rE,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:s,one:l,options:n,patch:nE,wrap:oE};return Am(t,function(u){if(u.type==="definition"||u.type==="footnoteDefinition"){const h=u.type==="definition"?r:i,p=String(u.identifier).toUpperCase();h.has(p)||h.set(p,u)}}),a;function l(u,h){const p=u.type,f=a.handlers[p];if(al.call(a.handlers,p)&&f)return f(a,u,h);if(a.options.passThrough&&a.options.passThrough.includes(p)){if("children"in u){const{children:g,...x}=u,b=Ho(x);return b.children=a.all(u),b}return Ho(u)}return(a.options.unknownHandler||iE)(a,u,h)}function c(u){const h=[];if("children"in u){const p=u.children;let f=-1;for(;++f<p.length;){const m=a.one(p[f],u);if(m){if(f&&p[f-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Hu(m.value)),!Array.isArray(m)&&m.type==="element")){const g=m.children[0];g&&g.type==="text"&&(g.value=Hu(g.value))}Array.isArray(m)?h.push(...m):h.push(m)}}}return h}}function nE(t,e){t.position&&(e.position=zv(t))}function rE(t,e){let n=e;if(t&&t.data){const r=t.data.hName,i=t.data.hChildren,o=t.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const s="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:s}}n.type==="element"&&o&&Object.assign(n.properties,Ho(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function iE(t,e){const n=e.data||{},r="value"in e&&!(al.call(n,"hProperties")||al.call(n,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function oE(t,e){const n=[];let r=-1;for(e&&n.push({type:"text",value:` 381`});++r<t.length;)r&&n.push({type:"text",value:` 382`}),n.push(t[r]);return e&&t.length>0&&n.push({type:"text",value:` 383`}),n}function Hu(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function qu(t,e){const n=tE(t,e),r=n.one(t,void 0),i=HC(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:` 384`},i),o}function sE(t,e){return t&&"run"in t?async function(n,r){const i=qu(n,{file:r,...e});await t.run(i,r)}:function(n,r){return qu(n,{file:r,...t||e})}}function Uu(t){if(t)throw t}var No=Object.prototype.hasOwnProperty,Mm=Object.prototype.toString,Ku=Object.defineProperty,Yu=Object.getOwnPropertyDescriptor,Ju=function(e){return typeof Array.isArray=="function"?Array.isArray(e):Mm.call(e)==="[object Array]"},Gu=function(e){if(!e||Mm.call(e)!=="[object Object]")return!1;var n=No.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&No.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!r)return!1;var i;for(i in e);return typeof i>"u"||No.call(e,i)},Qu=function(e,n){Ku&&n.name==="__proto__"?Ku(e,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):e[n.name]=n.newValue},Xu=function(e,n){if(n==="__proto__")if(No.call(e,n)){if(Yu)return Yu(e,n).value}else return;return e[n]},aE=function t(){var e,n,r,i,o,s,a=arguments[0],l=1,c=arguments.length,u=!1;for(typeof a=="boolean"&&(u=a,a=arguments[1]||{},l=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});l<c;++l)if(e=arguments[l],e!=null)for(n in e)r=Xu(a,n),i=Xu(e,n),a!==i&&(u&&i&&(Gu(i)||(o=Ju(i)))?(o?(o=!1,s=r&&Ju(r)?r:[]):s=r&&Gu(r)?r:{},Qu(a,{name:n,newValue:t(u,s,i)})):typeof i<"u"&&Qu(a,{name:n,newValue:i}));return a};const oa=uf(aE);function ll(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function lE(){const t=[],e={run:n,use:r};return e;function n(...i){let o=-1;const s=i.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);a(null,...i);function a(l,...c){const u=t[++o];let h=-1;if(l){s(l);return}for(;++h<i.length;)(c[h]===null||c[h]===void 0)&&(c[h]=i[h]);i=c,u?cE(u,a)(...c):s(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return t.push(i),e}}function cE(t,e){let n;return r;function r(...s){const a=t.length>s.length;let l;a&&s.push(i);try{l=t.apply(this,s)}catch(c){const u=c;if(a&&n)throw u;return i(u)}a||(l&&l.then&&typeof l.then=="function"?l.then(o,i):l instanceof Error?i(l):o(l))}function i(s,...a){n||(n=!0,e(s,...a))}function o(s){i(null,s)}}const sn={basename:uE,dirname:dE,extname:hE,join:fE,sep:"/"};function uE(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Yi(t);let n=0,r=-1,i=t.length,o;if(e===void 0||e.length===0||e.length>t.length){for(;i--;)if(t.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":t.slice(n,r)}if(e===t)return"";let s=-1,a=e.length-1;for(;i--;)if(t.codePointAt(i)===47){if(o){n=i+1;break}}else s<0&&(o=!0,s=i+1),a>-1&&(t.codePointAt(i)===e.codePointAt(a--)?a<0&&(r=i):(a=-1,r=s));return n===r?r=s:r<0&&(r=t.length),t.slice(n,r)}function dE(t){if(Yi(t),t.length===0)return".";let e=-1,n=t.length,r;for(;--n;)if(t.codePointAt(n)===47){if(r){e=n;break}}else r||(r=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function hE(t){Yi(t);let e=t.length,n=-1,r=0,i=-1,o=0,s;for(;e--;){const a=t.codePointAt(e);if(a===47){if(s){r=e+1;break}continue}n<0&&(s=!0,n=e+1),a===46?i<0?i=e:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":t.slice(i,n)}function fE(...t){let e=-1,n;for(;++e<t.length;)Yi(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":pE(n)}function pE(t){Yi(t);const e=t.codePointAt(0)===47;let n=mE(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function mE(t,e){let n="",r=0,i=-1,o=0,s=-1,a,l;for(;++s<=t.length;){if(s<t.length)a=t.codePointAt(s);else{if(a===47)break;a=47}if(a===47){if(!(i===s-1||o===1))if(i!==s-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=s,o=0;continue}}else if(n.length>0){n="",r=0,i=s,o=0;continue}}e&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+t.slice(i+1,s):n=t.slice(i+1,s),r=s-i-1;i=s,o=0}else a===46&&o>-1?o++:o=-1}return n}function Yi(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const gE={cwd:yE};function yE(){return"/"}function cl(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function xE(t){if(typeof t=="string")t=new URL(t);else if(!cl(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return bE(t)}function bE(t){if(t.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const r=e.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}const sa=["history","path","basename","stem","extname","dirname"];class Nm{constructor(e){let n;e?cl(e)?n={path:e}:typeof e=="string"||wE(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":gE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<sa.length;){const o=sa[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let i;for(i in n)sa.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?sn.basename(this.path):void 0}set basename(e){la(e,"basename"),aa(e,"basename"),this.path=sn.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?sn.dirname(this.path):void 0}set dirname(e){Zu(this.basename,"dirname"),this.path=sn.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?sn.extname(this.path):void 0}set extname(e){if(aa(e,"extname"),Zu(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=sn.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){cl(e)&&(e=xE(e)),la(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?sn.basename(this.path,this.extname):void 0}set stem(e){la(e,"stem"),aa(e,"stem"),this.path=sn.join(this.dirname||"",e+(this.extname||""))}fail(e,n,r){const i=this.message(e,n,r);throw i.fatal=!0,i}info(e,n,r){const i=this.message(e,n,r);return i.fatal=void 0,i}message(e,n,r){const i=new xt(e,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function aa(t,e){if(t&&t.includes(sn.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+sn.sep+"`")}function la(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function Zu(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function wE(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const vE=function(t){const r=this.constructor.prototype,i=r[t],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},kE={}.hasOwnProperty;class dc extends vE{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=lE()}copy(){const e=new dc;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];e.use(...r)}return e.data(oa(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(da("data",this.frozen),this.namespace[e]=n,this):kE.call(this.namespace,e)&&this.namespace[e]||void 0:e?(da("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(e,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=lo(e),r=this.parser||this.Parser;return ca("parse",r),r(String(n),n)}process(e,n){const r=this;return this.freeze(),ca("process",this.parser||this.Parser),ua("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,s){const a=lo(e),l=r.parse(a);r.run(l,a,function(u,h,p){if(u||!h||!p)return c(u);const f=h,m=r.stringify(f,p);EE(m)?p.value=m:p.result=m,c(u,p)});function c(u,h){u||!h?s(u):o?o(h):n(void 0,h)}}}processSync(e){let n=!1,r;return this.freeze(),ca("processSync",this.parser||this.Parser),ua("processSync",this.compiler||this.Compiler),this.process(e,i),td("processSync","process",n),r;function i(o,s){n=!0,Uu(o),r=s}}run(e,n,r){ed(e),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(s,a){const l=lo(n);i.run(e,l,c);function c(u,h,p){const f=h||e;u?a(u):s?s(f):r(void 0,f,p)}}}runSync(e,n){let r=!1,i;return this.run(e,n,o),td("runSync","run",r),i;function o(s,a){Uu(s),i=a,r=!0}}stringify(e,n){this.freeze();const r=lo(n),i=this.compiler||this.Compiler;return ua("stringify",i),ed(e),i(e,r)}use(e,...n){const r=this.attachers,i=this.namespace;if(da("use",this.frozen),e!=null)if(typeof e=="function")l(e,n);else if(typeof e=="object")Array.isArray(e)?a(e):s(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function o(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[u,...h]=c;l(u,h)}else s(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function s(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(c.plugins),c.settings&&(i.settings=oa(!0,i.settings,c.settings))}function a(c){let u=-1;if(c!=null)if(Array.isArray(c))for(;++u<c.length;){const h=c[u];o(h)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,u){let h=-1,p=-1;for(;++h<r.length;)if(r[h][0]===c){p=h;break}if(p===-1)r.push([c,...u]);else if(u.length>0){let[f,...m]=u;const g=r[p][1];ll(g)&&ll(f)&&(f=oa(!0,g,f)),r[p]=[c,f,...m]}}}}const SE=new dc().freeze();function ca(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function ua(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function da(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ed(t){if(!ll(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function td(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function lo(t){return CE(t)?t:new Nm(t)}function CE(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function EE(t){return typeof t=="string"||TE(t)}function TE(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const _E="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",nd=[],rd={allowDangerousHtml:!0},AE=/^(https?|ircs?|mailto|xmpp)$/i,ME=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function qo(t){const e=NE(t),n=jE(t);return IE(e.runSync(e.parse(n),n),t)}function NE(t){const e=t.rehypePlugins||nd,n=t.remarkPlugins||nd,r=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...rd}:rd;return SE().use(dC).use(n).use(sE,r).use(e)}function jE(t){const e=t.children||"",n=new Nm;return typeof e=="string"&&(n.value=e),n}function IE(t,e){const n=e.allowedElements,r=e.allowElement,i=e.components,o=e.disallowedElements,s=e.skipHtml,a=e.unwrapDisallowed,l=e.urlTransform||RE;for(const u of ME)Object.hasOwn(e,u.from)&&(""+u.from+(u.to?"use `"+u.to+"` instead":"remove it")+_E+u.id,void 0);return Am(t,c),Hv(t,{Fragment:d.Fragment,components:i,ignoreInvalidStyle:!0,jsx:d.jsx,jsxs:d.jsxs,passKeys:!0,passNode:!0});function c(u,h,p){if(u.type==="raw"&&p&&typeof h=="number")return s?p.children.splice(h,1):p.children[h]={type:"text",value:u.value},h;if(u.type==="element"){let f;for(f in na)if(Object.hasOwn(na,f)&&Object.hasOwn(u.properties,f)){const m=u.properties[f],g=na[f];(g===null||g.includes(u.tagName))&&(u.properties[f]=l(String(m||""),f,u))}}if(u.type==="element"){let f=n?!n.includes(u.tagName):o?o.includes(u.tagName):!1;if(!f&&r&&typeof h=="number"&&(f=!r(u,h,p)),f&&p&&typeof h=="number")return a&&u.children?p.children.splice(h,1,...u.children):p.children.splice(h,1),h}}}function RE(t){const e=t.indexOf(":"),n=t.indexOf("?"),r=t.indexOf("#"),i=t.indexOf("/");return e===-1||i!==-1&&e>i||n!==-1&&e>n||r!==-1&&e>r||AE.test(t.slice(0,e))?t:""}const OE=[{key:"channelAudit",label:"Your Channel",emptyHint:"Connect your YouTube channel to enable this",Icon:Ar},{key:"currentNiche",label:"Niche Research",emptyHint:"Run a Niche Research session first",Icon:Ar},{key:"currentAdjacent",label:"Adjacent Research",emptyHint:"Run an Adjacent Research session first",Icon:Ar},{key:"viewerProfile",label:"Brain",emptyHint:"Fill in Viewer Problems & Loves in your Brain Profile",Icon:us}],PE={currentNiche:"niche_research",currentAdjacent:"adjacent"};function DE(t){try{return new URL(t).pathname.split("/").filter(
384Boolean).find(n=>n.startsWith("@"))??null}catch{return null}}function id(t){var n,r;if(!t)return[];const e=t.channelsAnalyzed??((r=(n=t.analysis_results)==null?void 0:n.metadata)==null?void 0:r.channelsAnalyzed);if(Array.isArray(e)){const i=e.filter(o=>typeof o=="string"&&!!o.trim());if(i.length>0)return i}if(typeof e=="string"&&e.trim())return[e.trim()];if(Array.isArray(t.channel_urls)&&t.channel_urls.length>0){const i=t.channel_urls.map(DE).filter(o=>!!o);return i.length>0?i:[`${t.channel_urls.length} channel${t.channel_urls.length===1?"":"s"}`]}return typeof t.name=="string"&&t.name.trim()?[t.name.trim()]:[]}function LE(t){return Ln({queryKey:["ideation-sources",t],enabled:!!t,staleTime:60*1e3,gcTime:10*60*1e3,refetchInterval:5*60*1e3,queryFn:async()=>{const[e,n]=await Promise.all([j.from("brain_profiles").select("umbrella_statement, viewer_problems, viewers_love").eq("user_id",t).maybeSingle(),j.from("channel_research_sessions").select("research_type, channel_urls, name, channelsAnalyzed:analysis_results->metadata->channelsAnalyzed").eq("user_id",t).eq("status","complete").in("research_type",["niche_research","adjacent","channel_audit"]).order("created_at",{ascending:!1}).limit(10).returns()]);return{profile:e.data??null,sessions:n.data??[]}}})}const BE=({userId:t,selectedSources:e,onSourcesChange:n,researchFocus:r=null})=>{var x,b,E;const{data:i}=LE(t),[o,s]=y.useState(null),a=y.useRef(!1),l=y.useRef(null),c=y.useRef(e);y.useEffect(()=>{c.current=e},[e]);const u=(i==null?void 0:i.profile)??null,h=(i==null?void 0:i.sessions)??[],p=new Map;for(const v of h)p.has(v.research_type)||p.set(v.research_type,v);const f={channelAudit:p.has("channel_audit"),currentNiche:p.has("niche_research"),currentAdjacent:p.has("adjacent"),brainData:!!u,viewerProfile:!!((x=u==null?void 0:u.viewer_problems)!=null&&x.length||(b=u==null?void 0:u.viewers_love)!=null&&b.length)},m={currentNiche:id(p.get("niche_research")),currentAdjacent:id(p.get("adjacent"))};(E=h.find(v=>v.research_type==="niche_research"||v.research_type==="adjacent"))==null||E.research_type,y.useEffect(()=>{if(!i)return;const v=l.current;if(l.current={...f},!a.current){a.current=!0;const A={...f};(r==null?void 0:r.type)==="niche"?A.currentNiche=!0:(r==null?void 0:r.type)==="adjacent"&&(A.currentAdjacent=!0),n(A);return}if(v){const _=Object.keys(f).filter(S=>f[S]&&!v[S]);if(_.length>0){const S={...c.current};_.forEach(N=>{S[N]=!0}),n(S)}}},[i]);const g=v=>{n({...e,[v]:!e[v]})};return d.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",flex:1},children:OE.map(({key:v,label:A,emptyHint:_,Icon:S})=>{var D;const N=m[v]??[],M=r&&(v==="currentNiche"&&r.type==="niche"||v==="currentAdjacent"&&r.type==="adjacent")?r:null,L=((D=M==null?void 0:M.label)==null?void 0:D.trim())||null,P=((M==null?void 0:M.channels)??[]).filter(z=>z&&z!==L),T=f[v]||!!L,O=e[v],H=o===v&&!!PE[v]&&T&&(!!L||N.length>0);return d.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[d.jsxs("button",{onClick:()=>g(v),title:T?void 0:_,style:{display:"inline-flex",alignItems:"center",gap:5,padding:"5px 10px",borderRadius:14,background:O?"var(--bg-light)":"transparent",border:`1px solid ${O?"var(--border)":"var(--border-soft)"}`,color:O?"var(--text-primary)":"var(--text-muted)",fontSize:11,fontWeight:600,cursor:"pointer",opacity:O||T?1:.5,fontFamily:"inherit",transition:"border-color 0.15s, background 0.15s, color 0.15s"},onMouseEnter:z=>{s(v),O||(z.currentTarget.style.borderColor="var(--border)",z.currentTarget.style.color="var(--text-secondary)")},onMouseLeave:z=>{s(ee=>ee===v?null:ee),O||(z.currentTarget.style.borderColor="var(--border-soft)",z.currentTarget.style.color="var(--text-muted)")},children:[d.jsx(S,{style:{width:12,height:12,flexShrink:0,color:O&&T?"var(--success)":"var(--text-muted)"}}),A]}),H&&d.jsxs("div",{role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",left:0,zIndex:50,minWidth:160,maxWidth:240,background:"var(--bg-medium)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",boxShadow:"0 8px 24px rgba(0,0,0,0.35)",fontFamily:"inherit"},children:[d.jsx("p",{style:{margin:"0 0 6px",fontSize:10,fontWeight:700,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:L?"Focused on":"Channels used"}),L?d.jsxs(d.Fragment,{children:[d.jsx("p",{style:{margin:"0 0 4px",fontSize:13,fontWeight:700,color:"var(--text-primary)",lineHeight:"17px"},children:L}),P.length>0&&d.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[P.slice(0,8).map((z,ee)=>d.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--text-secondary)",lineHeight:"16px"},children:z},ee)),P.length>8&&d.jsxs("span",{style:{fontSize:11,fontWeight:500,color:"var(--text-muted)"},children:["+",P.length-8," more"]})]})]}):d.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[N.slice(0,8).map((z,ee)=>d.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--text-secondary)",lineHeight:"16px"},children:z},ee)),N.length>8&&d.jsxs("span",{style:{fontSize:11,fontWeight:500,color:"var(--text-muted)"},children:["+",N.length-8," more"]})]})]})]},v)})})},zE={p:({children:t})=>d.jsx("p",{style:{margin:"0 0 12px"},children:t}),ol:({children:t})=>d.jsx("ol",{style:{paddingLeft:22,margin:"0 0 12px"},children:t}),ul:({children:t})=>d.jsx("ul",{style:{paddingLeft:22,margin:"0 0 12px"},children:t}),li:({children:t})=>d.jsx("li",{style:{marginBottom:4},children:t}),hr:()=>d.jsx("hr",{style:{border:"none",borderTop:"1px solid var(--border-soft)",margin:"18px 0"}}),strong:({children:t})=>d.jsx("strong",{style:{color:"var(--text-primary)",fontWeight:700},children:t}),h1:({children:t})=>d.jsx("h1",{style:{fontSize:16,fontWeight:700,color:"var(--text-primary)",margin:"12px 0 8px",letterSpacing:"-0.2px"},children:t}),h2:({children:t})=>d.jsx("h2",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)",margin:"12px 0 6px"},children:t}),h3:({children:t})=>d.jsx("h3",{style:{fontSize:13,fontWeight:700,color:"var(--text-primary)",margin:"10px 0 4px"},children:t}),a:({children:t,href:e})=>d.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:t}),code:({children:t})=>d.jsx("code",{style:{fontFamily:"monospace",fontSize:12,background:"var(--bg-light)",padding:"1px 5px",borderRadius:4},children:t}),blockquote:({children:t})=>
384d.jsx("blockquote",{style:{borderLeft:"2px solid var(--border)",paddingLeft:12,margin:"0 0 12px",color:"var(--text-secondary)"},children:t})};function FE({content:t,canInsert:e,onInsert:n,feedback:r}){const[i,o]=y.useState(!1),[s,a]=y.useState(!1),[l,c]=y.useState(null),u=y.useRef(null),h=x=>{!r||l===x||(c(x),Yw({rating:x,messageContent:t,questionContent:r.question,botContext:r.botContext,conversationId:r.conversationId,priorId:u.current}).then(b=>{b&&(u.current=b)}))},p=x=>{x(!0),setTimeout(()=>x(!1),1600)},f={display:"flex",alignItems:"center",gap:5,background:"transparent",border:"1px solid var(--border-soft)",borderRadius:6,padding:"3px 8px",color:"var(--text-muted)",fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"border-color 0.15s, color 0.15s"},m=x=>{x.currentTarget.style.borderColor="var(--accent-border)",x.currentTarget.style.color="var(--accent)"},g=x=>{x.currentTarget.style.borderColor="var(--border-soft)",x.currentTarget.style.color="var(--text-muted)"};return d.jsxs("div",{style:{display:"flex",gap:6,marginTop:10},children:[d.jsxs("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(t).then(()=>p(o)).catch(()=>{})},style:f,onMouseEnter:m,onMouseLeave:g,title:"Copy this reply",children:[i?d.jsx(Si,{style:{width:11,height:11}}):d.jsx(kf,{style:{width:11,height:11}}),i?"Copied":"Copy"]}),e&&d.jsxs("button",{type:"button",onClick:()=>{n(t),p(a)},style:f,onMouseEnter:m,onMouseLeave:g,title:"Put this into the document you have open. Replaces your selection if you have one; cmd+z undoes it.",children:[s?d.jsx(Si,{style:{width:11,height:11}}):d.jsx(zl,{style:{width:11,height:11}}),s?"Added":"Add to document"]}),r&&d.jsxs("div",{style:{display:"flex",gap:2,marginLeft:4},children:[d.jsx("button",{type:"button",onClick:()=>h("up"),style:{...f,border:"none",padding:"3px 5px",color:l==="up"?"var(--success)":"var(--text-muted)"},title:"Good answer","aria-label":"Good answer",children:d.jsx(cb,{style:{width:12,height:12}})}),d.jsx("button",{type:"button",onClick:()=>h("down"),style:{...f,border:"none",padding:"3px 5px",color:l==="down"?"var(--danger)":"var(--text-muted)"},title:"Bad answer, this gets reviewed","aria-label":"Bad answer",children:d.jsx(lb,{style:{width:12,height:12}})}),l&&d.jsx("span",{style:{fontSize:11,color:"var(--text-muted)",alignSelf:"center",marginLeft:2},children:"Thanks"})]})]})}function jo({children:t}){return d.jsx(qo,{components:zE,children:t})}function $E({role:t,authorLabel:e,userInitial:n,wide:r,innerRef:i,children:o}){return d.jsxs("div",{ref:i,style:{...r?{maxWidth:800,margin:"0 auto 24px"}:{marginBottom:24},width:"100%",display:"flex",gap:14},children:[d.jsx("div",{style:{width:28,height:28,borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",...t==="user"?{background:"linear-gradient(135deg, #8d6f5a, #5d4a3a)",color:"#fff",fontSize:11,fontWeight:700}:{background:"var(--bg-medium)",border:"1px solid var(--accent-border)",color:"var(--accent)"}},children:t==="user"?n:d.jsx(Wi,{style:{width:14,height:14}})}),d.jsxs("div",{style:{flex:1,minWidth:0},children:[d.jsx("div",{style:{fontSize:11,fontWeight:700,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4},children:e}),d.jsx("div",{style:{fontSize:14,lineHeight:1.65,color:"var(--text-primary)"},children:o})]})]})}const od=/\n*!\[attached image\]\((\S+?)\)/g;function VE(t,e){return e?`${t} 385 386`:t}function jm(t){const e=[...t.matchAll(od)].map(n=>n[1]);return{text:t.replace(od,"").trim(),images:e}}function sd(t){return jm(t).text}function WE({content:t}){const{text:e,images:n}=jm(t);return d.jsxs(d.Fragment,{children:[e&&d.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:e}),n.length>0&&d.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:e?10:0},children:n.map(r=>d.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:d.jsx("img",{src:r,alt:"Attached",style:{width:160,borderRadius:8,display:"block",border:"1px solid var(--border-soft)"}})},r))})]})}function HE({wide:t}){return d.jsxs("div",{style:{...t?{maxWidth:800,margin:"0 auto 16px"}:{marginBottom:16},width:"100%",display:"flex",alignItems:"center",gap:6,paddingLeft:42},children:[d.jsx(ut,{className:"animate-spin",style:{width:13,height:13,color:"var(--text-muted)",flexShrink:0}}),d.jsx("span",{style:{fontSize:13,color:"var(--text-muted)",fontWeight:500,fontFamily:"inherit"},children:"Typingâ¦"})]})}function qE({title:t,description:e}){return d.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",minHeight:200,gap:16,textAlign:"center",padding:16},children:[d.jsx("div",{style:{width:56,height:56,borderRadius:"50%",background:"var(--accent-soft)",border:"1px solid var(--accent-border)",color:"var(--accent)",display:"flex",alignItems:"center",justifyContent:"center"},children:d.jsx(Wi,{style:{width:24,height:24}})}),d.jsxs("div",{children:[d.jsx("p",{style:{fontSize:16,fontWeight:600,color:"var(--text-primary)",margin:"0 0 6px"},children:t}),d.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",fontWeight:500,maxWidth:340,margin:0,lineHeight:1.55},children:e})]})]})}function UE({value:t,onChange:e,onSend:n,onStop:r,isLoading:i,canSend:o,locked:s=null,userId:a,selectedSources:l,onSourcesChange:c,researchFocus:u,placeholder:h="Ask AI Coach anythingâ¦",wide:p,hideSourcePanel:f,attachedImage:m,onAttachImage:g}){const x=o&&!s,b=y.useRef(null),E=y.useRef(null),[v,A]=y.useState(!1),[_,S]=y.useState(!1),N=async P=>{if(!(!P||!a||!g)){A(!0);try{const{compressImage:T}=await U(async()=>{const{compressImage:Q}=await import("./imageCompression-DNGDb0xH.js");return{compressImage:Q}},[]),O=await new Promise((Q,F)=>{const V=new FileReader;V.onload=()=>Q(String(V.result)),V.onerror=()=>F(new Error("read failed")),V.readAsDataURL(P)}),H=await T(O,800,.85),D=`${a}/chat/${Date.now()}.jpg`,{error:z}=await j.storage.from("thumbnails").upload(D,H,{contentType:"image/jpeg",upsert:!0});if(z)throw z;const{data:{publicUrl:ee}}
386=j.storage.from("thumbnails").getPublicUrl(D);g(ee)}catch{g(null)}finally{A(!1),E.current&&(E.current.value="")}}},M=()=>{const P=b.current;P&&(P.style.height="auto",P.style.height=`${Math.min(P.scrollHeight,160)}px`)};y.useEffect(()=>{t===""&&b.current&&(b.current.style.height="auto")},[t]);const L=P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),x&&n())};return d.jsx("div",{style:{borderTop:"1px solid var(--border-soft)",padding:p?"16px 24px 22px":"12px 12px 16px",flexShrink:0},children:d.jsxs("div",{onDragOver:P=>{g&&[...P.dataTransfer.items].some(T=>T.kind==="file"&&T.type.startsWith("image/"))&&(P.preventDefault(),S(!0))},onDragLeave:()=>S(!1),onDrop:P=>{if(!g)return;const T=[...P.dataTransfer.files].find(O=>O.type.startsWith("image/"));T&&(P.preventDefault(),S(!1),N(T))},style:{...p?{maxWidth:800,margin:"0 auto"}:{},background:"var(--bg-medium)",border:_?"1px dashed var(--accent-border)":"1px solid var(--border-soft)",borderRadius:12,padding:"14px 16px 10px"},children:[d.jsx("input",{ref:E,type:"file",accept:"image/*",style:{display:"none"},onChange:P=>{var T;return N(((T=P.target.files)==null?void 0:T[0])??null)}}),m&&d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10,padding:"6px 8px",background:"var(--bg-light)",border:"1px solid var(--border-soft)",borderRadius:8,width:"fit-content",maxWidth:"100%"},children:[d.jsx("img",{src:m,alt:"Attached",style:{width:40,height:23,objectFit:"cover",borderRadius:4,flexShrink:0}}),d.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-secondary)"},children:"Image attached"}),d.jsx("button",{type:"button",onClick:()=>g==null?void 0:g(null),"aria-label":"Remove image",style:{display:"flex",background:"transparent",border:"none",color:"var(--text-muted)",cursor:"pointer",padding:0},children:d.jsx(Bn,{style:{width:12,height:12}})})]}),s&&d.jsxs("div",{role:"status",style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,padding:"8px 12px",marginBottom:8,borderRadius:8,background:"var(--pill-danger-bg)",color:"var(--danger)",fontSize:13},children:[d.jsxs("span",{children:["You've used all your AI usage for this cycle",s.resetsAt?`. It resets on ${new Date(s.resetsAt).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:"","."]}),d.jsx(Lr,{to:`${C.account}?tab=usage`,style:{color:"inherit",fontWeight:600,whiteSpace:"nowrap"},children:"Add credits"})]}),d.jsx("textarea",{ref:b,value:t,onChange:P=>{e(P.target.value),M()},onKeyDown:L,placeholder:s?"You've used this cycle's AI usage. Add credits to keep going.":h,disabled:i||!!s,rows:2,style:{width:"100%",background:"transparent",border:"none",outline:"none",color:"var(--text-primary)",fontFamily:"inherit",fontSize:14,fontWeight:500,lineHeight:1.5,resize:"none",minHeight:52,maxHeight:160,marginBottom:10,display:"block",boxSizing:"border-box"}}),d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[f?d.jsx("div",{}):d.jsx(BE,{userId:a,selectedSources:l,onSourcesChange:c,researchFocus:u}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[g&&d.jsx("button",{type:"button",onClick:()=>{var P;return(P=E.current)==null?void 0:P.click()},disabled:i||v,title:"Attach an image (thumbnail, screenshot) for the coach to look at","aria-label":"Attach an image",style:{display:"flex",alignItems:"center",justifyContent:"center",width:30,height:30,borderRadius:8,background:"transparent",border:"1px solid var(--border-soft)",color:"var(--text-muted)",cursor:i||v?"default":"pointer"},children:v?d.jsx(ut,{style:{width:14,height:14,animation:"spin 1s linear infinite"}}):d.jsx(Yx,{style:{width:14,height:14}})}),i?d.jsx("button",{onClick:r,title:"Stop generating","aria-label":"Stop generating",style:{width:32,height:32,borderRadius:6,background:"var(--bg-light)",border:"1px solid var(--border-soft)",color:"var(--text-secondary)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"inherit",transition:"border-color 0.15s, color 0.15s"},onMouseEnter:P=>{P.currentTarget.style.borderColor="var(--border)",P.currentTarget.style.color="var(--text-primary)"},onMouseLeave:P=>{P.currentTarget.style.borderColor="var(--border-soft)",P.currentTarget.style.color="var(--text-secondary)"},children:d.jsx(ob,{style:{width:13,height:13}})}):d.jsx("button",{onClick:n,disabled:!x,title:"Send","aria-label":"Send",style:{width:32,height:32,borderRadius:6,background:x?"var(--text-primary)":"var(--bg-light)",border:`1px solid ${x?"var(--text-primary)":"var(--border-soft)"}`,color:x?"var(--bg-darkest)":"var(--text-muted)",cursor:x?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"inherit",transition:"background 0.15s, border-color 0.15s, color 0.15s"},children:d.jsx(Fl,{style:{width:14,height:14}})})]})]})]})})}const ad="unified-chat",ld="AI Coach",Qt={async createConversation(t,e,n){const{data:r,error:i}=await j.from("conversations").insert({user_id:t,bot_id:ad,bot_name:ld,title:e,project_id:n??null}).select().single();return i?(console.error("[conversationService] createConversation:",i),null):r},async getConversations(t){const{data:e,error:n}=await j.from("conversations").select("*").eq("user_id",t).order("updated_at",{ascending:!1});return n?(console.error("[conversationService] getConversations:",n),[]):e??[]}
386,async getMessages(t){const{data:e,error:n}=await j.from("messages").select("*").eq("conversation_id",t).order("timestamp",{ascending:!0});return n?(console.error("[conversationService] getMessages:",n),[]):e??[]},async saveMessage(t,e,n){const{error:r}=await j.from("messages").insert({conversation_id:t,role:e,content:n});r&&console.error("[conversationService] saveMessage:",r)},async updateTitle(t,e){const{error:n}=await j.from("conversations").update({title:e}).eq("id",t);n&&console.error("[conversationService] updateTitle:",n)},async migrateToCoach(t){const{error:e}=await j.from("conversations").update({bot_id:ad,bot_name:ld}).eq("id",t);e&&console.error("[conversationService] migrateToCoach:",e)},async linkToProject(t,e){const{error:n}=await j.from("conversations").update({project_id:e}).eq("id",t);n&&console.error("[conversationService] linkToProject:",n)},async deleteConversation(t){const{error:e}=await j.from("conversations").delete().eq("id",t);e&&console.error("[conversationService] deleteConversation:",e)},async getOrCreateProjectConversation(t,e,n){const{data:r,error:i}=await j.from("conversations").select("*").eq("user_id",t).eq("project_id",e).order("updated_at",{ascending:!1}).limit(1);return!i&&r&&r.length>0?r[0]:this.createConversation(t,n,e)}},oD=["goal","titles","videos","framework","basic-idea","research-idea","final-plan","intro","script","check","measure","repurpose"],sD={goal:"goal",titles:"ideate",videos:"ideate",framework:"planning","basic-idea":"planning","research-idea":"planning","final-plan":"planning",intro:"planning",script:"planning",check:"production",measure:"measurement",repurpose:"measurement","repurpose-newsletter":"measurement","repurpose-tweets":"measurement","repurpose-posts":"measurement","repurpose-hype-posts":"measurement"},aD={framework:1,"basic-idea":2,"research-idea":3,"final-plan":3,intro:4,script:5};function KE(t){switch(t.currentStage){case"goal":return"goal";case"ideate":return t.selectedIdeaTitle?"videos":"titles";case"feedback":return"framework";case"planning":return{0:"framework",1:"framework",2:"basic-idea",3:"research-idea",4:"intro",5:"script"}
386[t.planningWorkflow.currentStep]??"framework";case"production":return"check";case"measurement":return"measure";default:return"goal"}}const lD=()=>({goal:null,goalChecklist:{},selectedIdeaTitle:null,selectedIdeaThumbnail:null,sourceOutlierId:null,selectedTitle:null,selectedThumbnail:null,thumbnailWinners:[],uploadedThumbnailUrls:[],titleVariants:["","",""],viewerExpectations:"",planningWorkflow:{selectedFormat:null,step1:{goals:{sales:!1,emails:!1,views:!1},initialIdeas:""},step2:{expansionDoc:""},step3:{planningDoc:""},step4:{introText:"",questions:["","",""]},step5:{script:""},currentStep:0,highestStepReached:0},production:{filmingCompleted:!1,editingCompleted:!1,filmingChecklist:{},editingChecklist:{},filmingNotes:"",editingNotes:""},measurement:{videoUrl:null,analyzed:!1,notes:""},quickNotes:"",currentStage:"goal",completedStages:[],lastUpdated:new Date().toISOString()}),cD=t=>({goal:"goal","title-method":"goal","outlier-select":"ideate",thumbnail:"feedback",planning:"planning",filming:"production",editing:"production",measurement:"measurement"})[t]||"goal",ri=t=>`workflow_v2_${t}`,YE={getKey(t){return ri(t)},read(t){const e=xe.getString(ri(t));if(!e)return null;try{return JSON.parse(e)}catch(n){return console.warn(`Failed to parse workflow backup for "${t}"`,n),xe.remove(ri(t)),null}},write(t,e){return xe.setJSON(ri(t),e)},remove(t){return xe.remove(ri(t))}};function Im(t){return!!t&&/<\/?[a-z][\s\S]*>/i.test(t)}const JE=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");function co(t){let e=JE(t);return e=e.replace(/\{size:([\d.]+(?:px|pt|rem|em))\}(.*?)\{\/size\}/g,(n,r,i)=>`<span style="font-size: ${r}">${i}</span>`),e=e.replace(/`([^`]+)`/g,(n,r)=>`<code>${r}</code>`),e=e.replace(/\[([^\]]+)\]\((?:[^)]+)\)/g,"$1"),e=e.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),e=e.replace(/__([^_]+)__/g,"<strong>$1</strong>"),e=e.replace(new RegExp("(^|[^*\\w])\\*(?!\\s)([^*\\n]+?)(?<!\\s)\\*(?!\\*)","g"),"$1<em>$2</em>"),e=e.replace(new RegExp("(^|[^\\w_])_(?!\\s)([^_\\n]+?)(?<!\\s)_(?![\\w_])","g"),"$1<em>$2</em>"),e=e.replace(/~~([^~]+)~~/g,"<s>$1</s>"),e}function hc(t){if(!t)return"";const e=t.replace(/\r\n/g,` 387`).split(` 388`),n=[];let r=[],i=null,o=null;const s=()=>{r.length&&(n.push(`<p>${r.map(co).join("<br>")}</p>`),r=[])},a=()=>{i&&(n.push(`</${i}>`),i=null)},l=()=>{o&&(n.push(`<blockquote>${o.map(u=>`<p>${co(u)}</p>`).join("")}</blockquote>`),o=null)},c=()=>{s(),a(),l()};for(const u of e){const h=u.replace(/\s+$/,"");if(h.trim()===""){c();continue}const p=h.match(/^(#{1,6})(?:\s+(.*))?$/);if(p){c();const x=p[1].length;n.push(`<h${x}>${co(p[2]??"")}</h${x}>`);continue}if(/^([-*_])\1{2,}\s*$/.test(h)){c(),n.push("<hr>");continue}const f=h.match(/^>\s?(.*)$/);if(f){s(),a(),(o??(o=[])).push(f[1]);continue}l();const m=h.match(/^\s*[-*+]\s+(.*)$/),g=h.match(/^\s*\d+[.)]\s+(.*)$/);if(m||g){s();const x=m?"ul":"ol";i!==x&&(a(),n.push(`<${x}>`),i=x),n.push(`<li><p>${co((m??g)[1])}</p></li>`);continue}a(),r.push(h)}return c(),n.join("")}function GE(t){return t?Im(t)?t:hc(t):""}function Sr(t){if(!t)return"";if(!Im(t))return t;if(typeof DOMParser<"u"){const e=new DOMParser().parseFromString(t,"text/html");return e.querySelectorAll("br").forEach(n=>n.replaceWith(` 389`)),e.querySelectorAll("p, div, li, h1, h2, h3, h4, blockquote").forEach(n=>{n.append(` 390`)}),(e.body.textContent??"").replace(/\n{3,}/g,` 391 392`).trim()}return t.replace(/<br\s*\/?>/gi,` 393`).replace(/<\/(p|div|li|h[1-4]|blockquote)>/gi,` 394`).replace(/<[^>]+>/g,"").replace(/\n{3,}/g,` 395 396`).trim()}function uD(t){const e=Sr(t).trim();return e?e.split(/\s+/).length:0}const QE=/thumbnail|image|picture|look at|attached|on.?screen|text on|see it|show me|read it|extract/i,XE=/\baudit\s+(?:my\s+)?channel\b|\bchannel\s+audit\b|\breview\s+my\s+channel\b|\baudit\s+my\s+(?:positioning|sales\s+page)\b/i;function ha(t,e=6e3){const n=t.trim();return n.length<=e?`"${n}"`:`"${n.slice(0,e)}" [truncated, ${n.length-e} more characters saved in the document]`}function ZE(t,e){var a,l,c,u,h,p,f,m,g,x,b;if(!t||!e)return"";const n=[];e.selectedTitle&&n.push(`The user's selected video title is: "${e.selectedTitle}".`),e.goal&&n.push(`Their video goal is: ${e.goal}.`),e.selectedThumbnail&&n.push("The selected thumbnail for this video has been attached to this message as an image â look at it directly. Do NOT ask the user to share, upload, send, or attach the thumbnail; it is already there.");const r=["framework","basic-idea","research-idea","final-plan","intro","script"].includes(t)?6e3:2e3,i=Sr((l=(a=e.planningWorkflow)==null?void 0:a.step3)==null?void 0:l.planningDoc);i&&n.push(`The user's saved FINAL PLAN (read it, do not ask them to paste it): ${ha(i,r)}`);const o=Sr((u=(c=e.planningWorkflow)==null?void 0:c.step5)==null?void 0:u.script);
396o&&n.push(`The user's saved SCRIPT so far (read it, do not ask them to paste it): ${ha(o,r)}`);const s=Sr((p=(h=e.planningWorkflow)==null?void 0:h.step4)==null?void 0:p.introText);if(s&&n.push(`The user's saved INTRO: ${ha(s,Math.min(r,2e3))}`),t==="videos"){n.push("The user is on the Thumbnail & Videos step of their video production workflow.");const E=(e.uploadedThumbnailUrls??[]).length;if(E>0){const _=Array.from({length:E},(S,N)=>`#${N+1}`).join(", ");n.push(`${E} thumbnail image(s) are attached to this message in order: ${_}. Always refer to each by its number (#1, #2, etc.) â never say "the thumbnail" when multiple are present.`)}const A=(e.titleVariants??["","",""]).map((_,S)=>_!=null&&_.trim()?`T${S+1} (cards #${S*3+1}â#${S*3+3}): "${_.trim()}"`:null).filter(Boolean);A.length>0&&n.push(`Title variants being tested: ${A.join(" | ")}.`),e.selectedThumbnail&&e.selectedTitle?n.push(`The user has selected a winner: title "${e.selectedTitle}" with a thumbnail (attached). Reference this as their chosen winning combo when they ask.`):E===0&&e.thumbnailWinners.length===0&&n.push("No thumbnail has been uploaded yet â help them brainstorm a concept based on their title and goal.")}if(t==="titles"&&n.push("The user is on the Titles step â help them refine or generate title options."),t==="goal"&&n.push("The user is choosing what goal to optimise this video for (views, sales, or email signups)."),["framework","basic-idea","research-idea","final-plan","intro","script"].includes(t)){const E={framework:"Framework","basic-idea":"Basic Plan","research-idea":"Research","final-plan":"Final Plan",intro:"Intro",script:"Script"};n.push(`The user is on the ${E[t]??t} planning step.`);const v=Sr((m=(f=e.planningWorkflow)==null?void 0:f.step1)==null?void 0:m.initialIdeas);v&&n.push(`Initial ideas: ${v.slice(0,200)}.`);const A=Sr((x=(g=e.planningWorkflow)==null?void 0:g.step2)==null?void 0:x.expansionDoc);A&&n.push(`Expansion doc: ${A.slice(0,200)}.`)}if(t==="basic-idea"||t==="final-plan"||t==="intro"){const E=e.thumbnailWinners??[];if(E.length>0){const v=E.map((A,_)=>`Combo ${_+1}: title "${A.title}" â Thumbnail ${_+1} (attached)`).join(" | ");n.push(`The creator has saved ${E.length} winning title+thumbnail combo(s): ${v}.`)}else e.selectedTitle&&e.selectedThumbnail&&n.push(`The creator has a single selected winner: title "${e.selectedTitle}" with Thumbnail 1 (attached).`)}return t==="check"&&n.push("The user is on the Production / final check step."),(t==="measure"||t==="repurpose")&&(n.push("The user is on the Measurement & Repurpose step â the video has been published."),(b=e.measurement)!=null&&b.videoUrl&&n.push(`Published video URL: ${e.measurement.videoUrl}.`)),n.join(" ")}function eT(t){if(!t)return"";const e=[];return t.selectedTitle&&e.push(`Project title: "${t.selectedTitle}"`),t.goal&&e.push(`Goal: ${t.goal}`),t.selectedThumbnail&&e.push("A chosen thumbnail exists for this project."),e.join(" | ")}function tT(t,e){if(t){if(e==="videos"){const n=t.uploadedThumbnailUrls;return n&&n.length>0?n:t.selectedThumbnail?[t.selectedThumbnail]:void 0}if(e==="basic-idea"||e==="final-plan"){const n=(t.thumbnailWinners??[]).map(r=>r.thumbnail).filter(r=>!!r);return n.length>0?n:t.selectedThumbnail?[t.selectedThumbnail]:void 0}}}function nT(t,e,n,r){return r?{specialist:r}:XE.test(e)?{specialist:"guardrails"}:t==="videos"&&(n!=null&&n.length)?{specialist:"thumbnail"}:!!n&&QE.test(e)?{specialist:"thumbnail"}:{}}const rT=/\b(?:run|redo|do|get|start|trigger)\s+(?:(?:the|an?|my|another)\s+)?(?:ai\s+)?(?:analysis|analyze)\b|\banalyze\s+(?:my\s+|the\s+|these\s+|those\s+)?(?:thumbnails?|images?)\b|\bthumbnail\s+analysis\b|\banalyze\s+again\b/i,iT=/\bfind(?:ing)?\s+(?:the\s+)?gaps?\b|\bwhat(?:'?s|\s+is)\s+the\s+gap\b|\bgaps?\s+they\s+(?:all\s+)?miss\b/i;function dD(t){var i;const e=[],n=o=>{const s=[...o].sort((l,c)=>l-c);return s.length===0?"":s.every((l,c)=>c===0||l===s[c-1]+1)&&s.length>1?`#${s[0]}â#${s[s.length-1]}`:s.map(l=>`#${l}`).join(", ")};if(e.push("**Analysis complete.**"),t.warning&&e.push(`â ï¸ ${t.warning}`),t.topPicks.length>0){const o=["ð **Top Picks** â winning title + thumbnail combos",""];t.topPicks.forEach(s=>{o.push(`- **#${s.thumbnailIndex}**${s.reasoning?` â ${s.reasoning}`:""}`)}
396),(i=t.topPicksNote)!=null&&i.trim()&&o.push("",t.topPicksNote.trim()),e.push(o.join(` 397`))}const r=t.titles.filter(o=>o.classification||o.flags.length>0||o.thumbnails.length>0);if(r.length>0){const o=["**Title Analysis**",""];r.forEach(s=>{const a=s.flags.length>0?`â ï¸ ${s.flags.join("; ")}`:"â Clean",l=[n(s.thumbnails),s.classification??"",a].filter(Boolean);o.push(`- ${l.join(" · ")}`)}),e.push(o.join(` 398`))}if(t.problemsOnly.length>0){const o=[];t.problemsOnly.forEach(s=>{const a=[`**#${s.thumbnailIndex}**`];(s.problems??[]).slice(0,2).forEach((l,c)=>{a.push(`ð¨ ${l}`);const u=(s.solutions??[])[c];u&&a.push(`âï¸ ${u}`)}),o.push(a.join(` 399 400`))}),e.push(`**Thumbnail Analysis** 401 402${o.join(` 403 404--- 405 406`)}`)}else e.push(`**Thumbnail Analysis** 407 408â All thumbnails passed â no issues found.`);return e.join(` 409 410`)}function oT(t,e){return t?YE.read(t)??e:null}async function cd(t,e){const n=oT(t,e);if(n)return n;if(!t)return null;try{const{data:r,error:i}=await j.from("projects").select("workflow_data, thumbnail_data").eq("id",t).maybeSingle();if(i)return console.warn("[chatContext] failed to load workflow from DB:",i.message),null;const o=(r==null?void 0:r.workflow_data)??null;if(!o)return null;const s=(r==null?void 0:r.thumbnail_data)??null,a=typeof(s==null?void 0:s.selected_title)=="string"?s.selected_title:null,l=Array.isArray(s==null?void 0:s.winners)&&s.winners.length>0?s.winners[0].thumbnail:null;return!o.selectedTitle&&a&&(o.selectedTitle=a),!o.selectedThumbnail&&l&&(o.selectedThumbnail=l),o}catch(r){return console.warn("[chatContext] readFreshWorkflowAsync threw:",r),null}}const ul=`__THUMBNAIL_ANALYSIS_V1__ 411`;function sT(t){return ul+JSON.stringify(t)}function aT(t){if(typeof t!="string"||!t.startsWith(ul))return null;try{return JSON.parse(t.slice(ul.length))}catch{return null}}function lT({data:t}){const e=t.titleTexts??["","",""],n=t.titleAnalysis,r=t.titleFeedback,i=Array.isArray(n)?n:n?[n]:[],o=Array.isArray(r)?r:r?[r]:[],s=new Map;i.forEach((u,h)=>{const p=(u==null?void 0:u.titleIndex)??h+1;s.set(p,{...s.get(p)??{},analysis:u})}),o.forEach((u,h)=>{const p=(u==null?void 0:u.titleIndex)??h+1;s.set(p,{...s.get(p)??{},feedback:u})});const a=Array.from(s.entries()).sort((u,h)=>u[0]-h[0]).filter(([u])=>(e[u-1]??"").trim().length>0),l=t.topPicks??[],c=t.problemsOnly??[];return d.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[t.warning&&d.jsx("div",{style:{background:"rgba(203,96,64,0.1)",borderRadius:6,padding:12},children:d.jsx("p",{style:{color:"var(--accent-default, #CB6040)",fontSize:11,fontFamily:"Open Sans",fontWeight:300,lineHeight:"18px",margin:0},children:t.warning})}),a.length>0&&d.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:a.map(([u,{analysis:h,feedback:p}])=>{const f=e[u-1]??"",m=h!=null&&h.classification?String(h.classification).split("-").map(b=>b.charAt(0).toUpperCase()+b.slice(1)).join(" "):null,g=Array.isArray(p==null?void 0:p.flags)?p.flags:[],x=Array.isArray(p==null?void 0:p.suggestions)?p.suggestions:[];return d.jsxs("div",{style:{background:"rgba(21,179,146,0.08)",borderRadius:6,padding:12,border:"1px solid rgba(21,179,146,0.2)"},children:[d.jsxs("p",{style:{color:"var(--ink-3, #808074)",fontSize:10,fontFamily:"Open Sans",fontWeight:700,margin:"0 0 8px",letterSpacing:.5},children:["T",u,' â "',f,'"']}),m&&d.jsxs("p",{style:{color:"var(--ink-1, #B2B2A3)",fontSize:11,fontFamily:"Open Sans",fontWeight:600,lineHeight:"18px",margin:"0 0 8px"},children:["Title Strategy: ",m]}),(h==null?void 0:h.reasoning)&&d.jsxs("div",{style:{margin:"0 0 8px"},children:[d.jsx("p",{style:{color:"var(--ink-3, #808074)",fontSize:10,fontFamily:"Open Sans",fontWeight:700,margin:"0 0 2px",letterSpacing:.3},children:"Why"}),d.jsx("p",{style:{color:"var(--ink-2, #99988B)",fontSize:11,fontFamily:"Open Sans",fontWeight:300,lineHeight:"18px",margin:0},children:h.reasoning})]}),(h==null?void 0:h.audienceReach)&&d.jsxs("p",{style:{color:"var(--ink-2, #99988B)",fontSize:11,fontFamily:"Open Sans",fontWeight:300,lineHeight:"18px",margin:"0 0 8px"},children:["ð¯ Reach: ",d.jsx("span",{style:{fontWeight:600},children:String(h.audienceReach).toUpperCase()})]}),(h==null?void 0:h.strategicNote)&&d.jsxs("div",{style:{margin:"0 0 4px"},children:[d.jsx("p",{style:{color:"var(--ink-3, #808074)",fontSize:10,fontFamily:"Open Sans",fontWeight:700,margin:"0 0 2px",letterSpacing:.3},children:"ð¡ Note"}),d.jsx("p",{style:{color:"var(--ink-2, #99988B)",fontSize:11,fontFamily:"Open Sans",fontWeight:300,lineHeight:"18px",margin:0},children:h.strategicNote})]}),g.length>0&&d.jsxs("div",{style:{marginTop:10,paddingTop:10,borderTop:"1px solid rgba(203,96,64,0.3)"},children:[d.jsx("p",{style:{color:"var(--accent-default, #CB6040)",fontSize:10,fontFamily:"Open Sans",fontWeight:700,margin:"0 0 6px",letterSpacing:.3},children:"Title Issues"}),g.map((b,E)=>d.jsxs("p",{style:{color:"var(--ink-1, #B2B2A3)",fontSize:11,fontFamily:"Open Sans",fontWeight:300,lineHeight:"18px",margin:"0 0 4px"},children:["⢠",(b==null?void 0:b.message)??String(b)]},E))]}),x.length>0&&d.jsxs("div",{style:{marginTop:10,paddingTop:10,borderTop:"1px solid rgba(255,255,255,0.1)"},children:[d.jsx("p",{style:{color:"var(--ink-3, #808074)",fontSize:10,fontFamily:"Open Sans",fontWeight:700,margin:"0 0 6px",letterSpacing:.3},children:"Suggested alternatives"}),x.map((b,E)=>d.jsxs("p",{style:{color:"var(--ink-2, #99988B)",fontSize:11,fontFamily:"Open Sans",fontWeight:300,lineHeight:"18px",margin:"0 0 4px"},children:["â ",b]}
411,E)),(p==null?void 0:p.suggestionsNote)&&d.jsx("p",{style:{color:"var(--ink-3, #808074)",fontSize:10,fontFamily:"Open Sans",fontWeight:300,fontStyle:"italic",lineHeight:"16px",margin:"6px 0 0"},children:p.suggestionsNote})]})]},u)})}),l.length>0&&d.jsxs("div",{style:{background:"rgba(99,102,241,0.08)",borderRadius:6,padding:12,border:"1px solid rgba(99,102,241,0.2)"},children:[d.jsx("p",{style:{color:"var(--ink-1, #B2B2A3)",fontSize:11,fontFamily:"Open Sans",fontWeight:700,margin:"0 0 10px",letterSpacing:.3},children:"â Top Picks"}),l.map((u,h)=>d.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start",marginBottom:10},children:[d.jsx("span",{style:{flexShrink:0,width:18,height:18,borderRadius:"50%",background:"rgba(99,102,241,0.6)",color:"white",fontSize:10,fontFamily:"Open Sans",fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center"},children:u.rank??h+1}),d.jsxs("div",{style:{flex:1,minWidth:0},children:[d.jsxs("p",{style:{color:"var(--ink-1, #B2B2A3)",fontSize:11,fontFamily:"Open Sans",fontWeight:600,lineHeight:"18px",margin:"0 0 3px"},children:["Thumbnail #",u.thumbnailIndex," + T",u.titleIndex]}),u.reasoning&&d.jsx("p",{style:{color:"var(--ink-2, #99988B)",fontSize:11,fontFamily:"Open Sans",fontWeight:300,lineHeight:"18px",margin:0},children:u.reasoning})]})]},h)),t.topPicksReasoning&&d.jsx("p",{style:{color:"var(--ink-3, #808074)",fontSize:10,fontFamily:"Open Sans",fontWeight:300,fontStyle:"italic",lineHeight:"16px",margin:"4px 0 0",paddingTop:10,borderTop:"1px solid rgba(255,255,255,0.1)"},children:t.topPicksReasoning})]}),c.length>0&&d.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[d.jsxs("p",{style:{color:"var(--accent-default, #CB6040)",fontSize:11,fontFamily:"Open Sans",fontWeight:600,margin:0,letterSpacing:.3},children:["Issues (",c.length,")"]}),c.map((u,h)=>{const p=u.thumbnailIndex,f=u.titleIndex;return d.jsxs("div",{style:{background:"rgba(203,96,64,0.1)",borderRadius:6,padding:12},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[d.jsxs("span",{style:{color:"var(--accent-default, #CB6040)",fontSize:11,fontFamily:"Open Sans",fontWeight:700},children:["Thumbnail #",p]}),f&&d.jsxs("span",{style:{background:"rgba(203,96,64,0.2)",color:"var(--accent-default, #CB6040)",fontSize:9,fontFamily:"Open Sans",fontWeight:700,padding:"1px 5px",borderRadius:3},children:["paired with T",f]})]}),u.comboAnalysis&&d.jsx("p",{style:{color:"var(--ink-3, #808074)",fontSize:10,fontFamily:"Open Sans",fontWeight:300,lineHeight:"16px",margin:"0 0 8px",fontStyle:"italic"},children:u.comboAnalysis}),(u.problems??[]).map((m,g)=>{var x,b;return d.jsxs("div",{style:{marginBottom:g===(((x=u.problems)==null?void 0:x.length)??0)-1?0:10},children:[d.jsxs("p",{style:{color:"var(--ink-1, #B2B2A3)",fontSize:11,fontFamily:"Open Sans",fontWeight:300,lineHeight:"18px",margin:0},children:["ð ",m]}),((b=u.solutions)==null?void 0:b[g])&&d.jsxs("p",{style:{color:"var(--ink-2, #99988B)",fontSize:11,fontFamily:"Open Sans",fontWeight:300,lineHeight:"18px",margin:"4px 0 0"},children:["â ",u.solutions[g]]})]},g)})]},h)})]}),c.length===0&&l.length>0&&d.jsx("div",{style:{background:"rgba(21,179,146,0.1)",borderRadius:6,padding:12},children:d.jsx("p",{style:{color:"var(--success, #15B392)",fontSize:11,fontFamily:"Open Sans",fontWeight:600,margin:0,lineHeight:"18px"},children:"All Good! ð All your thumbnails look great!"})})]})}const Rm=["newsletter","tweets","posts","hype_posts"],cT=new Set(Rm),Om=/<!--\s*piece\s+type\s*=\s*["']([a-z_]+)["']\s*-->/i,Pm=/<!--\s*\/piece\s*-->/i;function uT(t){if(!t)return[];try{const e=[];let n=0;for(;n<t.length;){const r=t.slice(n),i=Om.exec(r);if(!i){fa(e,t.slice(n));break}const o=n+i.index,s=o+i[0].length;o>n&&fa(e,t.slice(n,o));const a=t.slice(s),l=Pm.exec(a);if(!l){n=s;break}const c=s+l.index,u=c+l[0].length,h=t.slice(s,c),p=fT(h).trim(),f=i[1].toLowerCase();cT.has(f)&&p.length>0?e.push({kind:"piece",type:f,content:p}):p.length>0&&fa(e,p),n=u}return e}catch{return[{kind:"text",content:t}]}}function dT(t){const e=[];for(const n of t){if(n.kind==="text"){e.push({kind:"text",content:n.content});continue}const r=e[e.length-1];r&&r.kind==="group"&&r.type===n.type?r.pieces.push(n.content):e.push({kind:"group",type:n.type,pieces:[n.content]}
411)}return e}function hT(t){return dT(uT(t))}function fT(t){return t.replace(new RegExp(Om,"gi"),"").replace(new RegExp(Pm,"gi"),"")}function fa(t,e){if(!e)return;const n=t[t.length-1];n&&n.kind==="text"?n.content+=e:t.push({kind:"text",content:e})}const dl={newsletter:"newsletter",tweets:"tweets",posts:"posts",hype_posts:"hype posts"},pT={newsletter:"Newsletter",tweets:"Tweet",posts:"Post",hype_posts:"Hype post"},ud=t=>["repurpose_saved",t];function fc(t){const e=hf(),n=Ln({queryKey:ud(t??""),enabled:!!t,queryFn:async()=>{const{data:l,error:c}=await j.from("repurpose_saved").select("*").eq("project_id",t).order("type",{ascending:!0}).order("order_index",{ascending:!0});if(c)throw c;return l??[]}}),r=()=>e.invalidateQueries({queryKey:ud(t??"")}),i=Xi({mutationFn:async({type:l,contents:c})=>{var x;if(!t)throw new Error("No project ID");const{data:u}=await j.auth.getUser(),h=(x=u.user)==null?void 0:x.id;if(!h)throw new Error("Not signed in");const{data:p}=await j.from("repurpose_saved").select("order_index").eq("project_id",t).eq("type",l).order("order_index",{ascending:!1}).limit(1),f=p&&p.length>0?p[0].order_index+1:0,m=c.map((b,E)=>({user_id:h,project_id:t,type:l,content:b,order_index:f+E})),{error:g}=await j.from("repurpose_saved").insert(m);if(g)throw g},onSuccess:r}),o=Xi({mutationFn:async({id:l,content:c})=>{const{error:u}=await j.from("repurpose_saved").update({content:c}).eq("id",l);if(u)throw u},onSuccess:r}),s=Xi({mutationFn:async l=>{const{error:c}=await j.from("repurpose_saved").delete().eq("id",l);if(c)throw c},onSuccess:r}),a=Xi({mutationFn:async({items:l})=>{var h;if(!t)throw new Error("No project ID");const{data:c}=await j.auth.getUser(),u=(h=c.user)==null?void 0:h.id;if(!u)throw new Error("Not signed in");for(const{type:p,contents:f}of l){const{data:m}=await j.from("repurpose_saved").select("order_index").eq("project_id",t).eq("type",p).order("order_index",{ascending:!1}).limit(1),g=m&&m.length>0?m[0].order_index+1:0,x=f.map((E,v)=>({user_id:u,project_id:t,type:p,content:E,order_index:g+v})),{error:b}=await j.from("repurpose_saved").insert(x);if(b)throw b}},onSuccess:r});return{rows:n.data??[],isLoading:n.isLoading,saveMany:i,saveAll:a,updateOne:o,deleteOne:s}}function hD(t){const e={newsletter:0,tweets:0,posts:0,hype_posts:0};for(const n of t)e[n.type]=(e[n.type]??0)+1;return e}function mT({content:t,projectId:e,enabled:n=!1}){if(!n)return d.jsx(jo,{children:t});const r=hT(t);if(!r.some(s=>s.kind==="group"))return d.jsxs(d.Fragment,{children:[d.jsx(jo,{children:t}),gT(t,!!e)&&d.jsx(yT,{content:t,projectId:e})]});const o=r.filter(s=>s.kind==="group");return d.jsxs(d.Fragment,{children:[r.map((s,a)=>s.kind==="text"?s.content.trim()?d.jsx(jo,{children:s.content},a):null:d.jsx(bT,{type:s.type,pieces:s.pieces,projectId:e,groupId:`${a}`},a)),o.length>1&&d.jsx(xT,{groups:o,projectId:e})]})}function gT(t,e){var o;if(!e)return!1;const n=t.trim();if(n.length<200||n.slice(-1)==="?"||/(What's working|What to fix|Step\s*\d+\s*[ââ-]|Here are\s+\d+|Story or Tip|Which (would|one|kind|format)|Want me to|Reply (with )?\d)/i.test(n))return!1;if(n.split(/\n\s*\n/).filter(s=>s.trim().length>0).length>=4){const s=/(^|\n)\s*\d+\.\s/.test(n),a=/(NEWSLETTER|SOCIAL POSTS|X \/ TWITTER|TWITTER QUOTES|HYPE POST|Subject:)/i,l=((o=n.match(new RegExp(a.source,"gi")))==null?void 0:o.length)??0;if(s||l>=2)return!1}return!0}function yT({content:t,projectId:e}){const{saveMany:n}=fc(e??void 0),[r,i]=y.useState(!1),[o,s]=y.useState(null),a=y.useRef(null);y.useEffect(()=>{if(!r)return;const c=u=>{var h;(h=a.current)!=null&&h.contains(u.target)||i(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]);const l=c=>{if(i(!1),!e){Mt({title:"Open this in a project to save",variant:"destructive"});return}n.mutate({type:c,contents:[t.trim()]},{onSuccess:()=>{s(c),Mt({title:`Saved to ${dl[c]}`})},onError:u=>{console.error("[repurpose] save-as fallback failed",u),Mt({title:"Could not save â try again",variant:"destructive"})}})};return o?d.jsx("div",{style:{marginTop:6,marginBottom:12},children:d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",color:"var(--accent)",border:"1px solid var(--accent)",borderRadius:999,padding:"5px 12px",fontSize:12,fontWeight:600,fontFamily:"inherit"},children:[d.jsx(Si,{style:{width:12,height:12}}),"Saved to ",dl[o]]})}):d.jsxs("div",{ref:a,style:{position:"relative",marginTop:6,marginBottom:12,display:"inline-block"},children:[d.jsxs("button",{onClick:()=>i(c=>!c),disabled:n.isPending,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",color:"var(--accent)",border:"1px solid var(--accent)",borderRadius:999,padding:"5px 12px",fontSize:12,fontWeight:600,cursor:n.isPending?"default":"pointer",fontFamily:"inherit",opacity:n.isPending?.6:1,transition:"opacity 0.15s"},children:["Save asâ¦",d.jsx(vf,{style:{width:12,height:12}})]}),r&&d.jsx("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"var(--background, white)",border:"1px solid var(--border, rgba(0,0,0,0.1))",borderRadius:8,padding:4,minWidth:160,boxShadow:"0 8px 24px rgba(0,0,0,0.12)"},children:Rm.map(c=>d.jsx("button",{onClick:()=>l(c),style:{display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none",padding:"7px 10px",borderRadius:6,fontSize:13,fontFamily:"inherit",curs
411or:"pointer",color:"var(--foreground, #111)"},onMouseEnter:u=>u.currentTarget.style.background="var(--bg-medium)",onMouseLeave:u=>u.currentTarget.style.background="transparent",children:pT[c]},c))})]})}function xT({groups:t,projectId:e}){const{saveAll:n}=fc(e??void 0),[r,i]=y.useState(!1),o=()=>{if(!e){Mt({title:"Open this in a project to save",variant:"destructive"});return}n.mutate({items:t.map(s=>({type:s.type,contents:s.pieces}))},{onSuccess:()=>{i(!0),Mt({title:"All pieces saved"})},onError:s=>{console.error("[repurpose] save-all failed",s),Mt({title:"Could not save all â try again",variant:"destructive"})}})};return d.jsx("div",{style:{marginTop:8,marginBottom:12},children:d.jsxs("button",{onClick:o,disabled:r||n.isPending||!e,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",color:"var(--accent)",border:"1px solid var(--accent)",borderRadius:999,padding:"5px 14px",fontSize:12,fontWeight:600,cursor:r||n.isPending||!e?"default":"pointer",fontFamily:"inherit",opacity:n.isPending||r?.6:1,transition:"opacity 0.15s"},children:[r&&d.jsx(Si,{style:{width:12,height:12}}),r?"All saved":n.isPending?"Savingâ¦":"Save all"]})})}function bT({type:t,pieces:e,projectId:n,groupId:r}){const{saveMany:i}=fc(n??void 0),[o,s]=y.useState(!1),a=dl[t],l=o?`Saved to ${a}`:`Save to ${a}`,c=o||!n||i.isPending,u=()=>{if(!n){Mt({title:"Open this in a project to save",variant:"destructive"});return}i.mutate({type:t,contents:e},{onSuccess:()=>{s(!0),Mt({title:`Saved ${e.length} ${e.length===1?a.replace(/s$/,""):a}`})},onError:h=>{console.error("[repurpose] save failed",h),Mt({title:"Could not save â try again",variant:"destructive"})}})};return d.jsxs("div",{style:{marginBottom:12},children:[e.map((h,p)=>d.jsx(jo,{children:h},`${r}-${p}`)),d.jsxs("button",{onClick:u,disabled:c,style:{display:"inline-flex",alignItems:"center",gap:6,marginTop:2,background:"transparent",color:"var(--accent)",border:"1px solid var(--accent)",borderRadius:999,padding:"5px 12px",fontSize:12,fontWeight:600,cursor:c?"default":"pointer",fontFamily:"inherit",opacity:i.isPending||o?.6:1,transition:"opacity 0.15s"},children:[o&&d.jsx(Si,{style:{width:12,height:12}}),l,e.length>1&&!o&&d.jsxs("span",{style:{opacity:.85,fontWeight:700},children:["· ",e.length]})]})]})}function at(t){this.content=t}at.prototype={constructor:at,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),o=r.content.slice();return i==-1?o.push(n||t,e):(o[i+1]=e,n&&(o[i]=n)),new at(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new at(n)},addToStart:function(t,e){return new at([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new at(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),o=r.find(t);return i.splice(o==-1?i.length:o,0,e,n),new at(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=at.from(t),t.size?new at(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=at.from(t),t.size?new at(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=at.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};at.from=function(t){if(t instanceof at)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new at(e)};function Dm(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)n++;return n}if(i.content.size||o.content.size){let s=Dm(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function Lm(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let s=t.child(--i),a=e.child(--o),l=s.nodeSize;if(s==a){n-=l,r-=l;continue}if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let c=0,u=Math.min(s.text.length,a.text.length);for(;c<u&&s.text[s.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let c=Lm(s.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class q{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,o){for(let s=0,a=0;a<n;s++){let l=this.content[s],c=a+l.nodeSize;if(c>e&&r(l,i+a,o||null,s)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,i+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}
vendor: 11,403 bytes, line 411
411textBetween(e,n,r,i){let o="",s=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new q(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let o=0,s=0;s<n;o++){let a=this.content[o],l=s+a.nodeSize;l>e&&((s<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-s),Math.min(a.text.length,n-s)):a=a.cut(Math.max(0,e-s-1),Math.min(a.content.size,n-s-1))),r.push(a),i+=a.nodeSize),s=l}return new q(r,i)}cutByIndex(e,n){return e==n?q.empty:e==0&&n==this.content.length?this:new q(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new q(i,o)}addToStart(e){return new q([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new q(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return Dm(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Lm(this,e,n,r)}findIndex(e){if(e==0)return uo(0,e);if(e==this.size)return uo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),o=r+i.nodeSize;if(o>=e)return o==e?uo(n+1,o):uo(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return q.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return q.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return q.empty;let n,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(n||(n=e.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new q(n||e,r)}static from(e){if(!e)return q.empty;if(e instanceof q)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new q([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}q.empty=new q([],0);const pa={index:0,offset:0};function uo(t,e){return pa.index=t,pa.offset=e,pa}function Uo(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Uo(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Uo(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ze=class hl{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Uo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return hl.none;if(e instanceof hl)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};ze.none=[];class Ko extends Error{}class oe{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=zm(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new oe(r,this.openStart,this.openEnd)}removeBetween(e,n){return new oe(Bm(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return oe.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new oe(q.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new oe(e,r,i)}}oe.empty=new oe(q.empty,0,0);function Bm(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:s,offset:a}=t.findIndex(n);if(i==e||o.isText){if(a!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(Bm(o.content,e-i-1,n-i-1)))}function zm(t,e,n,r,i,o){let{index:s,offset:a}=t.findIndex(e),l=t.maybeChild(s);if(a==e||l.isText)return o&&r<=0&&i<=0&&!o.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=zm(l.content,e-a-1,n,s==0?r-1:0,s==t.childCount-1?i-1:0,l);return c&&t.replaceChild(s,l.copy(c))}function wT(t,e,n){if(n.openStart>t.depth)throw new Ko("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Ko("Inconsistent open depths");return Fm(t,e,n,0)}function Fm(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=Fm(t,e,n,r+1);return o.copy(o.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,a=s.content;return rr(s,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=vT(n,t);return rr(o,Vm(t,s,a,e,r))}else return rr(o,Yo(t,e,r))}function $m(t,e){if(!e.type.compatibleContent(t.type))throw new Ko("Cannot join "+e.type.name+" onto "+t.type.name)}function fl(t,e,n){let r=t.node(n);return $m(r,e.node(n)),r}function nr(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function yi(t,e,n,r){let i=(e||t).node(n),o=0,s=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(nr(t.nodeAfter,r),o++));for(let a=o;a<s;a++)nr(i.child(a),r);e&&e.depth==n&&e.textOffset&&nr(e.nodeBefore,r)}function rr(t,e){return t.type.checkContent(e),t.copy(e)}function Vm(t,e,n,r,i){let o=t.depth>i&&fl(t,e,i+1),s=r.depth>i&&fl(n,r,i+1),a=[];return yi(null,t,i,a),o&&s&&e.index(i)==n.index(i)?($m(o,s),nr(rr(o,Vm(t,e,n,r,i+1)),a)):(o&&nr(rr(o,Yo(t,e,i+1)),a),yi(e,n,i,a),s&&nr(rr(s,Yo(n,r,i+1)),a)),yi(r,null,i,a),new q(a)}function Yo(t,e,n){let r=[];if(yi(null,t,n,r),t.depth>n){let i=fl(t,e,n+1);nr(rr(i,Yo(t,e,n+1)),r)}return yi(e,null,n,r),new q(r)}function vT(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(q.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Ni{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ze.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let a=r;r=i,i=a}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Jo(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let s=e;;){let{index:a,offset:l}=s.content.findIndex(o),c=o-l;if(r.push(s,a,i+l),!c||(s=s.child(a),s.isText))break;o=c-1,i+=l+1}return new Ni(n,r,o)}
vendor: 4,383 bytes, line 411
411static resolveCached(e,n){let r=dd.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==n)return s}else dd.set(e,r=new kT);let i=r.elts[r.i]=Ni.resolve(e,n);return r.i=(r.i+1)%ST,i}}class kT{constructor(){this.elts=[],this.i=0}}const ST=12,dd=new WeakMap;class Jo{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const CT=Object.create(null);let jn=class pl{constructor(e,n,r,i=ze.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||q.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Uo(this.attrs,n||e.defaultAttrs||CT)&&ze.sameSet(this.marks,r||ze.none)}copy(e=null){return e==this.content?this:new pl(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new pl(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return oe.empty;let i=this.resolve(e),o=this.resolve(n),s=r?0:i.sharedDepth(n),a=i.start(s),c=i.node(s).content.cut(i.pos-a,o.pos-a);return new oe(c,i.depth-s,o.depth-s)}replace(e,n,r){return wT(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return Ni.resolveCached(this,e)}resolveNoCache(e){return Ni.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Wm(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=q.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),a=s&&s.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;l<o;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ze.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ze.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}
411`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=q.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};jn.prototype.text=void 0;class Go extends jn{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Wm(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Go(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Go(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Wm(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class lr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new ET(e,n);if(r.next==null)return lr.empty;let i=Hm(r);r.next&&r.err("Unexpected trailing text");let o=IT(jT(i));return RT(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let o=n;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function o(s,a){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return q.from(a.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:h}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let p=o(h,a.concat(u));if(p)return p}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let a=i;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:l}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(` 412`)}}lr.empty=new lr(!0);class ET{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Hm(t){let e=[];do e.push(TT(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function TT(t){let e=[];do e.push(_T(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function _T(t){let e=NT(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=AT(t,e);else break;return e}function hd(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");
vendor: 4,721 bytes, line 412
412let e=Number(t.next);return t.pos++,e}function AT(t,e){let n=hd(t),r=n;return t.eat(",")&&(t.next!="}"?r=hd(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function MT(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let s=n[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function NT(t){if(t.eat("(")){let e=Hm(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=MT(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function jT(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(s,a,l){let c={term:l,to:a};return e[s].push(c),c}function i(s,a){s.forEach(l=>l.to=a)}function o(s,a){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(o(c,a)),[]);if(s.type=="seq")for(let l=0;;l++){let c=o(s.exprs[l],a);if(l==s.exprs.length-1)return c;i(c,a=n())}else if(s.type=="star"){let l=n();return r(a,l),i(o(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();return i(o(s.expr,a),l),i(o(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(a)].concat(o(s.expr,a));if(s.type=="range"){let l=a;for(let c=0;c<s.min;c++){let u=n();i(o(s.expr,l),u),l=u}if(s.max==-1)i(o(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let u=n();r(l,u),i(o(s.expr,l),u),l=u}return[r(l)]}else{if(s.type=="name")return[r(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function qm(t,e){return e-t}function fd(t,e){let n=[];return r(e),n.sort(qm);function r(i){let o=t[i];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(i);for(let s=0;s<o.length;s++){let{term:a,to:l}=o[s];!a&&n.indexOf(l)==-1&&r(l)}}}function IT(t){let e=Object.create(null);return n(fd(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u<i.length;u++)i[u][0]==a&&(c=i[u][1]);fd(t,l).forEach(u=>{c||i.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new lr(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(qm);o.next.push({type:i[s][0],next:e[a.join(",")]||n(a)})}return o}}function RT(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],o=!i.validEnd,s=[];for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];s.push(l.name),o&&!(l.isText||l.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Um(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Km(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let o=t[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function Ym(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let o=t[i];o.validate&&o.validate(e[i])}}function Jm(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new PT(t,r,e[r]);return n}let pd=class Gm{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Jm(e,r.attrs),this.defaultAttrs=Um(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==lr.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Km(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new jn(this,this.computeAttrs(e),q.from(n),ze.setFrom(r))}createChecked(e=null,n,r){return n=q.from(n),this.checkContent(n),new jn(this,this.computeAttrs(e),n,ze.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=q.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),o=i&&i.fillBefore(q.empty,!0);return o?new jn(this,e,n.append(o),ze.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);
vendor: 10,940 bytes, lines 412-414
412if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ym(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:ze.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,s)=>r[o]=new Gm(o,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function OT(t,e,n){let r=n.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}class PT{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?OT(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class As{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Jm(e,i.attrs),this.excluded=null;let o=Um(this.attrs);this.instance=o?new ze(this,o):null}create(e=null){return!e&&this.instance?this.instance:new ze(this,Km(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new As(o,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Ym(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Qm{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=at.from(e.nodes),n.marks=at.from(e.marks||{}),this.nodes=pd.compile(this.spec.nodes,this),this.marks=As.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",a=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=lr.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=a=="_"?null:a?md(this,a.split(" ")):a==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:md(this,s.split(" "))}this.nodeFromJSON=i=>jn.fromJSON(this,i),this.markFromJSON=i=>ze.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof pd){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new Go(r,r.defaultAttrs,e,ze.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function md(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],o=t.marks[i],s=o;if(o)n.push(o);else for(let a in t.marks){let l=t.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function DT(t){return t.tag!=null}function LT(t){return t.style!=null}let Ir=class ml{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(DT(i))this.tags.push(i);else if(LT(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new yd(this,n,!1);return r.addAll(e,ze.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new yd(this,n,!0);return r.addAll(e,ze.none,n.from,n.to),oe.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(FT(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,n,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],a=s.style;if(!(a.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let a=n[s];if((a.priority==null?50:a.priority)<o)break}n.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=xd(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=xd(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ml(e,ml.schemaRules(e)))}};const Xm={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},BT={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Zm={ol:!0,ul:!0},ji=1,gl=2,xi=4;function gd(t,e,n){return e!=null?(e?ji:0)|(e==="full"?gl:0):t&&t.whitespace=="pre"?ji|gl:n&~xi}class ho{constructor(e,n,r,i,o,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=ze.none,this.match=o||(s&xi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(q.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ji)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let n=q.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(q.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Xm.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class yd{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,o,s=gd(null,n.preserveWhitespace,0)|(r?xi:0);i?o=new ho(i.type,i.attrs,ze.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new ho(null,null,ze.none,!0,null,s):o=new ho(e.schema.topNodeType,null,ze.none,!0,null,s),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,o=i.options&gl?"full":this.localPreserveWS||(i.options&ji)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,` 413`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(s.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=i.content[i.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),a;Zm.hasOwnProperty(s)&&this.parser.normalizeLists&&zT(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:BT.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(Xm.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let h=l&&l.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` 414`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let a=void 0;;){let l=this.parser.matchStyle(o,s,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,i){let o,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(o=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEac
vendor: 4,075 bytes, line 414
414h(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}o&&this.sync(a)&&this.open--}addAll(e,n,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];s!=a;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,n);this.findAtPoint(e,o)}findPlace(e,n,r){let i,o;for(let s=this.open,a=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,o=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=ze.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):bd(a.type,e.type))&&(s=a.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let o=this.findPlace(e.create(n),r,!1);return o&&(o=this.enterInner(e,n,r,!0,i)),o}enterInner(e,n,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let a=gd(e,o,s.options);s.options&xi&&s.content.length==0&&(a|=xi);let l=ze.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):bd(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new ho(e,n,l,i,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=ji)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=o;l--)if(s(a-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:r&&l>=o?r.node(l-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function zT(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Zm.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function FT(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function xd(t){let e={};for(let n in t)e[n]=t[n];return e}
vendor: 3,852 bytes, line 414
414function bd(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],s=a=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}class pr{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=fo(n).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let a=0,l=0;for(;a<o.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(o[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<o.length;)i=o.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],u=this.serializeMark(c,s.isInline,n);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){if(e.isText)return fo(n).createTextNode(e.text);let{dom:r,contentDOM:i}=Io(fo(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Io(fo(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return typeof n=="string"?{dom:e.createTextNode(n)}:Io(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new pr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=wd(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return wd(e.marks)}}function wd(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function fo(t){return t.document||window.document}const vd=new WeakMap;function $T(t){let e=vd.get(t);return e===void 0&&vd.set(t,e=VT(t)),e}function VT(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function Io(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=$T(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let a,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let h in c)if(c[h]!=null){let p=h.indexOf(" ");p>0?l.setAttributeNS(h.slice(0,p),h.slice(p+1),c[h]):h=="style"&&l.style?l.style.cssText=c[h]:l.setAttribute(h,c[h])}}for(let h=u;h<e.length;h++){let p=e[h];if(p===0){if(h<e.length-1||h>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else if(typeof p=="string")l.appendChild(t.createTextNode(p));else{let{dom:f,contentDOM:m}=Io(t,p,n,r);if(l.appendChild(f),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const eg=65535,tg=Math.pow(2,16);function WT(t,e){return t+e*tg}function kd(t){return t&eg}function HT(t){return(t-(t&eg))/tg}const ng=1,rg=2,Ro=4,ig=8;class yl{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ig)>0}get deletedBefore(){return(this.delInfo&(ng|Ro))>0}get deletedAfter(){return(this.delInfo&(rg|Ro))>0}get deletedAcross(){return(this.delInfo&Ro)>0}}class Ft{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ft.empty)return Ft.empty}recover(e){let n=0,r=kd(e);if(!this.inverted)for(let i=0;i<r;
vendor: 3,657 bytes, line 414
414i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+HT(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+o],u=this.ranges[a+s],h=l+c;if(e<=h){let p=c?e==l?-1:e==h?1:n:n,f=l+i+(p<0?0:u);if(r)return f;let m=e==(n<0?l:h)?null:WT(a/3,e-l),g=e==l?rg:e==h?ng:Ro;return(n<0?e!=l:e!=h)&&(g|=ig),new yl(f,g,m)}i+=u-c}return r?e+i:new yl(e+i,0,null)}touches(e,n){let r=0,i=kd(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+o],u=l+c;if(e<=u&&a==i*3)return!0;r+=this.ranges[a+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],a=s-(this.inverted?o:0),l=s+(this.inverted?0:o),c=this.ranges[i+n],u=this.ranges[i+r];e(a,a+c,l,l+u),o+=u-c}}invert(){return new Ft(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ft.empty:new Ft(e<0?[0,-e,0]:[0,0,e])}}Ft.empty=new Ft([]);class Ii{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Ii(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Ii;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],a=s.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(o);if(l!=null&&l>o&&l<this.to){o=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return r?e:new yl(e,i,null)}}const ma=Object.create(null);class bt{getMap(){return Ft.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ma[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in ma)throw new RangeError("Duplicate use of step JSON ID "+e);return ma[e]=n,n.prototype.jsonID=e,n}}class Qe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Qe(e,null)}static fail(e){return new Qe(null,e)}static fromReplace(e,n,r,i){try{return Qe.ok(e.replace(n,r,i))}catch(o){if(o instanceof Ko)return Qe.fail(o.message);throw o}}}function pc(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(pc(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return q.fromArray(r)}class An extends bt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.no
vendor: 6,946 bytes, line 414
414de(r.sharedDepth(this.to)),o=new oe(pc(n.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return Qe.fromReplace(e,this.from,this.to,o)}invert(){return new cn(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new An(n.pos,r.pos,this.mark)}merge(e){return e instanceof An&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new An(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new An(n.from,n.to,e.markFromJSON(n.mark))}}bt.jsonID("addMark",An);class cn extends bt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new oe(pc(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Qe.fromReplace(e,this.from,this.to,r)}invert(){return new An(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new cn(n.pos,r.pos,this.mark)}merge(e){return e instanceof cn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new cn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new cn(n.from,n.to,e.markFromJSON(n.mark))}}bt.jsonID("removeMark",cn);class Mn extends bt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Qe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Qe.fromReplace(e,this.pos,this.pos+1,new oe(q.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Mn(this.pos,n.marks[i]);return new Mn(this.pos,this.mark)}}return new cr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Mn(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Mn(n.pos,e.markFromJSON(n.mark))}}bt.jsonID("addNodeMark",Mn);class cr extends bt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Qe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Qe.fromReplace(e,this.pos,this.pos+1,new oe(q.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Mn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new cr(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new cr(n.pos,e.markFromJSON(n.mark))}}bt.jsonID("removeNodeMark",cr);class Ye extends bt{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&xl(e,this.from,this.to)?Qe.fail("Structure replace would overwrite content"):Qe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ft([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ye(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&Ye.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Ye(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ye)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?oe.empty:new oe(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ye(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?oe.empty:new oe(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ye(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ye(n.from,n.to,oe.fromJSON(e,n.slice),!!n.structure)}}Ye.MAP_BIAS=1;bt.jsonID("replace",Ye);class tt extends bt{constructor(e,n,r,i,o,s,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=a}apply(e){if(this.structure&&(xl(e,this.from,this.gapFrom)||xl(e,this.gapTo,this.to)))return Qe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Qe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Qe.fromReplace(e,this.from,this.to,r):Qe.fail("Content does not fit in gap")}getMap(){return new Ft([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new tt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new tt(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new tt(n.from,n.to,n.gapFrom,n.gapTo,oe.fromJSON(e,n.slice),n.insert,!!n.structure)}}bt.jsonID("replaceAround",tt);function xl(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>
vendor: 1,068 bytes, line 414
4140&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function qT(t,e,n,r){let i=[],o=[],s,a;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let h=l.marks;if(!r.isInSet(h)&&u.type.allowsMarkType(r.type)){let p=Math.max(c,e),f=Math.min(c+l.nodeSize,n),m=r.addToSet(h);for(let g=0;g<h.length;g++)h[g].isInSet(m)||(s&&s.to==p&&s.mark.eq(h[g])?s.to=f:i.push(s=new cn(p,f,h[g])));a&&a.to==p?a.to=f:o.push(a=new An(p,f,r))}}),i.forEach(l=>t.step(l)),o.forEach(l=>t.step(l))}function UT(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,a)=>{if(!s.isInline)return;o++;let l=null;if(r instanceof As){let c=s.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,n);for(let u=0;u<l.length;u++){let h=l[u],p;for(let f=0;f<i.length;f++){let m=i[f];m.step==o-1&&h.eq(i[f].style)&&(p=m)}p?(p.to=c,p.step=o):i.push({style:h,from:Math.max(a,e),to:c,step:o})}}}
vendor: 4,401 bytes, lines 414-415
414),i.forEach(s=>t.step(new cn(s.from,s.to,s.style)))}function mc(t,e,n,r=n.contentMatch,i=!0){let o=t.doc.nodeAt(e),s=[],a=e+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),u=a+c.nodeSize,h=r.matchType(c.type);if(!h)s.push(new Ye(a,u,oe.empty));else{r=h;for(let p=0;p<c.marks.length;p++)n.allowsMarkType(c.marks[p].type)||t.step(new cn(a,u,c.marks[p]));if(i&&c.isText&&n.whitespace!="pre"){let p,f=/\r?\n|\r/g,m;for(;p=f.exec(c.text);)m||(m=new oe(q.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new Ye(a+p.index,a+p.index+p[0].length,m))}}a=u}if(!r.validEnd){let l=r.fillBefore(q.empty,!0);t.replace(a,a,new oe(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function KT(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Gr(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,o=0;;--r){let s=t.$from.node(r),a=t.$from.index(r)+i,l=t.$to.indexAfter(r)-o;if(r<t.depth&&s.canReplace(a,l,n))return r;if(r==0||s.type.spec.isolating||!KT(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function YT(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),a=i.after(o+1),l=s,c=a,u=q.empty,h=0;for(let m=o,g=!1;m>n;m--)g||r.index(m)>0?(g=!0,u=q.from(r.node(m).copy(u)),h++):l--;let p=q.empty,f=0;for(let m=o,g=!1;m>n;m--)g||i.after(m+1)<i.end(m)?(g=!0,p=q.from(i.node(m).copy(p)),f++):c++;t.step(new tt(l,c,s,a,new oe(u.append(p),h,f),u.size-h,!0))}function gc(t,e,n=null,r=t){let i=JT(t,e),o=i&>(r,e);return o?i.map(Sd).concat({type:e,attrs:n}).concat(o.map(Sd)):null}function Sd(t){return{type:t,attrs:null}}function JT(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return n.canReplaceWith(r,i,s)?o:null}function GT(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:s}function QT(t,e,n){let r=q.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let a=n[s].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=q.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new tt(i,o,i,o,new oe(r,0,0),n.length,!0))}function XT(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,a)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,l)&&ZT(t.doc,t.mapping.slice(o).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!m?c=!1:!f&&m&&(c=!0)}c===!1&&sg(t,s,a,o),mc(t,t.mapping.slice(o).map(a,1),r,void 0,c===null);let u=t.mapping.slice(o),h=u.map(a,1),p=u.map(a+s.nodeSize,1);return t.step(new tt(h,p,h+1,p-1,new oe(q.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&og(t,s,a,o),!1}})}function og(t,e,n,r){e.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let l=t.mapping.slice(r).map(n+1+o+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function sg(t,e,n,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+o);t.replaceWith(s,s+1,e.type.schema.text(` 415`))}})}function ZT(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function e_(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new tt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new oe(q.from(s),0,0),1,!0))}function Rr(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=n-2;c>o;c--,u--){let h=i.node(c),p=i.index(c);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(p,h.childCount),m=r&&r[u+1];m&&(f=f.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[u]||h;
vendor: 2,489 bytes, line 415
415if(!h.canReplace(p+1,h.childCount)||!g.type.validContent(f))return!1}let a=i.indexAfter(o),l=r&&r[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function t_(t,e,n=1,r){let i=t.doc.resolve(e),o=q.empty,s=q.empty;for(let a=i.depth,l=i.depth-n,c=n-1;a>l;a--,c--){o=q.from(i.node(a).copy(o));let u=r&&r[c];s=q.from(u?u.type.create(u.attrs,s):i.node(a).copy(s))}t.step(new Ye(e,e,new oe(o.append(s),n,n),!0))}function $n(t,e){let n=t.resolve(e),r=n.index();return ag(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function n_(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function ag(t,e){return!!(t&&e&&!t.isLeaf&&n_(t,e))}function Ms(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let o,s,a=r.index(i);if(i==r.depth?(o=r.nodeBefore,s=r.nodeAfter):n>0?(o=r.node(i+1),a++,s=r.node(i).maybeChild(a)):(o=r.node(i).maybeChild(a-1),s=r.node(i+1)),o&&!o.isTextblock&&ag(o,s)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function r_(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,o=t.doc.resolve(e-n),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",h=!!s.contentMatch.matchType(i);u&&!h?r=!1:!u&&h&&(r=!0)}let a=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);sg(t,u.node(),u.before(),a)}s.inlineContent&&mc(t,e+n-1,s,o.node().contentMatchAt(o.index()),r==null);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new Ye(c,l.map(e+n,-1),oe.empty,!0)),r===!0){let u=t.doc.resolve(c);og(t,u.node(),u.before(),t.steps.length)}return t}function i_(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function lg(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let o=0;o<n.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let s=r.depth;s>=0;s--){let a=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,l=r.
vendor: 7,554 bytes, line 415
415index(s)+(a>0?1:0),c=r.node(s),u=!1;if(o==1)u=c.canReplace(l,l,i);else{let h=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=h&&c.canReplaceWith(l,l,h[0])}if(u)return a==0?r.pos:a<0?r.before(s+1):r.after(s+1)}return null}function Ns(t,e,n=e,r=oe.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return cg(i,o,r)?new Ye(e,n,r):new o_(i,o,r).fit()}function cg(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class o_{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=q.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=q.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,a=i.depth;for(;s&&a&&o.childCount==1;)o=o.firstChild.content,s--,a--;let l=new oe(o,s,a);return e>-1?new tt(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Ye(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=ga(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,h=null;if(n==1&&(s?c.matchType(s.type)||(h=c.fillBefore(q.from(s),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:a,parent:o,inject:h};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:a,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=ga(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new oe(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=ga(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new oe(li(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new oe(li(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let g=0;g<o.length;g++)this.openFrontierNode(o[g]);let s=this.unplaced,a=r?r.content:s.content,l=s.openStart-e,c=0,u=[],{match:h,type:p}=this.frontier[n];if(i){for(let g=0;g<i.childCount;g++)u.push(i.child(g));h=h.matchFragment(i)}let f=a.size+e-(s.content.size-s.openEnd);for(;c<a.childCount;){let g=a.child(c),x=h.matchType(g.type);if(!x)break;c++,(c>1||l==0||g.content.size)&&(h=x,u.push(ug(g.mark(p.allowedMarks(g.marks)),c==1?l:0,c==a.childCount?f:-1)))}let m=c==a.childCount;m||(f=-1),this.placed=ci(this.placed,n,q.from(u)),this.frontier[n].match=h,m&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,x=a;g<f;g++){let b=x.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),x=b.content}this.unplaced=m?e==0?oe.empty:new oe(li(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new oe(li(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!ya(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=ya(e,n,i,r,o);if(s){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=ya(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=ci(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=ci(this.placed,this.depth,q.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(q.empty,!0);n.childCount&&(this.placed=ci(this.placed,this.frontier.length,n))}}function li(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(li(t.firstChild.content,e-1,n)))}function ci(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ci(t.lastChild.content,e-1,n)))}function ga(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function ug(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,ug(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(q.empty,!0)))),t.copy(r)}function ya(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!s_(n,o.content,s)?a:null}function s_(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function a_(t){return t.spec.defining||t.spec.definingForContent}function l_(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(cg(i,o,r))return t.step(new Ye(e,n,r));let s=hg(i,o);s[s.length-1]==0&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let p=i.depth,f=i.pos-1;p>0;p--,f--){let m=i.node(p).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;s.indexOf(p)>-1?a=p:i.before(p)==f&&s.splice(1,0,-p)}let l=s.indexOf(a),c=[],u=r.openStart;for(let p=r.content,f=0;;f++){let m=p.firstChild;if(c.push(m),f==r.openStart)break;p=m.content}for(let p=u-1;p>=0;p--){let f=c[p],m=a_(f.type);if(m&&!f.sameMarkup(i.node(Math.abs(a)-1)))u=p;else if(m||!f.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let f=(p+u+1)%(r.openStart+1),m=c[f];if(m)for(let g=0;g<s.length;g++){let x=s[(g+l)%s.length],b=!0;x<0&&(b=!1,x=-x);let E=i.node(x-1),v=i.index(x-1);if(E.canReplaceWith(v,v,m.type,m.marks))return t.replace(i.before(x),b?o.after(x):n,new oe(dg(r.content,0,r.openStart,f),f,r.openEnd))}}let h=t.steps.length;for(let p=s.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>h));p--){let f=s[p];f<0||(e=i.before(f),n=o.after(f))}}function dg(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(dg(o.content,e+1,n,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(q.empty,!0))}return t}function c_(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=i_(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new oe(q.from(r),0,0))}function u_(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let s=r.sharedDepth(n),a=!1;for(let l=r.depth;l>s;
vendor: 13,495 bytes, line 415
415l--)r.node(l).type.spec.isolating&&(a=!0);for(let l=i.depth;l>s;l--)i.node(l).type.spec.isolating&&(a=!0);if(!a){for(let l=r.depth;l>0&&e==r.start(l);l--)e=r.before(l);for(let l=i.depth;l>0&&n==i.start(l);l--)n=i.before(l);r=t.doc.resolve(e),i=t.doc.resolve(n)}}let o=hg(r,i);for(let s=0;s<o.length;s++){let a=o[s],l=s==o.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return t.delete(r.start(a),i.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return t.delete(r.before(a),i.after(a))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function hg(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(o<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class Or extends bt{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Qe.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Qe.fromReplace(e,this.pos,this.pos+1,new oe(q.from(i),0,n.isLeaf?0:1))}getMap(){return Ft.empty}invert(e){return new Or(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Or(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Or(n.pos,n.attr,n.value)}}bt.jsonID("attr",Or);class Ri extends bt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Qe.ok(r)}getMap(){return Ft.empty}invert(e){return new Ri(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ri(n.attr,n.value)}}bt.jsonID("docAttr",Ri);let zr=class extends Error{};zr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};zr.prototype=Object.create(Error.prototype);zr.prototype.constructor=zr;zr.prototype.name="TransformError";class d_{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ii}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new zr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((o,s,a,l)=>{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=oe.empty){let i=Ns(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new oe(q.from(r),0,0))}delete(e,n){return this.replace(e,n,oe.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return l_(this,e,n,r),this}replaceRangeWith(e,n,r){return c_(this,e,n,r),this}deleteRange(e,n){return u_(this,e,n),this}lift(e,n){return YT(this,e,n),this}join(e,n=1){return r_(this,e,n),this}wrap(e,n){return QT(this,e,n),this}setBlockType(e,n=e,r,i=null){return XT(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return e_(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Or(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ri(e,n)),this}addNodeMark(e,n){return this.step(new Mn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof ze)n.isInSet(r.marks)&&this.step(new cr(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new cr(e,o)),i=o.removeFromSet(i);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(e,n=1,r){return t_(this,e,n,r),this}addMark(e,n,r){return qT(this,e,n,r),this}removeMark(e,n,r){return UT(this,e,n,r),this}clearIncompatible(e,n,r){return mc(this,e,n,r),this}}const xa=Object.create(null);class Te{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new h_(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=oe.empty){let r=n.content.lastChild,i=null;for(let a=0;a<n.openEnd;a++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:l,$to:c}=s[a],u=e.mapping.slice(o);e.replaceRange(u.map(l.pos),u.map(c.pos),a?oe.empty:n),a==0&&Td(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:a}=i[o],l=e.mapping.slice(r),c=l.map(s.pos),u=l.map(a.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Td(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Se(e):Cr(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=n<0?Cr(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Cr(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ut(e.node(0))}static atStart(e){return Cr(e,e,0,0,1)||new Ut(e)}static atEnd(e){return Cr(e,e,e.content.size,e.childCount,-1)||new Ut(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=xa[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in xa)throw new RangeError("Duplicate use of selection JSON ID "+e);return xa[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Se.between(this.$anchor,this.$head).getBookmark()}}Te.prototype.visible=!0;class h_{constructor(e,n){this.$from=e,this.$to=n}}let Cd=!1;function Ed(t){!Cd&&!t.parent.inlineContent&&(Cd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Se extends Te{constructor(e,n=e){Ed(e),Ed(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Te.near(r);let i=e.resolve(n.map(this.anchor));return new Se(i.parent.inlineContent?i:r,r)}replace(e,n=oe.empty){if(super.replace(e,n),n==oe.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Se&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new js(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Se(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=Te.findFrom(n,r,!0)||Te.findFrom(n,-r,!0);if(o)n=o.$head;else return Te.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Te.findFrom(e,-r,!0)||Te.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Se(e,n)}}Te.jsonID("text",Se);class js{constructor(e,n){this.anchor=e,this.head=n}map(e){return new js(e.map(this.anchor),e.map(this.head))}resolve(e){return Se.between(e.resolve(this.anchor),e.resolve(this.head))}}class ye extends Te{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=e.resolve(i);return r?Te.near(o):new ye(o)}content(){return new oe(q.from(this.node),0,0)}eq(e){return e instanceof ye&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new yc(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ye(e.resolve(n.anchor))}static create(e,n){return new ye(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ye.prototype.visible=!1;Te.jsonID("node",ye);class yc{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new js(r,r):new yc(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ye.isSelectable(r)?new ye(n):Te.near(n)}}class Ut extends Te{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=oe.empty){if(n==oe.empty){e.delete(0,e.doc.content.size);let r=Te.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ut(e)}map(e){return new Ut(e)}eq(e){return e instanceof Ut}getBookmark(){return f_}}Te.jsonID("all",Ut);const f_={map(){return this},resolve(t){return new Ut(t)}};function Cr(t,e,n,r,i,o=!1){if(e.inlineContent)return Se.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let a=e.child(s);if(a.isAtom){if(!o&&ye.isSelectable(a))return ye.create(t,n-(i<0?a.nodeSize:0))}else{let l=Cr(t,a,n+i,i<0?a.childCount:0,i,o);if(l)return l}n+=a.nodeSize*i}return null}function Td(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ye||i instanceof tt))return;let o=t.mapping.maps[r],s;o.forEach((a,l,c,u)=>{s==null&&(s=u)}),t.setSelection(Te.near(t.doc.resolve(s),n))}const _d=1,po=2,Ad=4;class p_ extends d_{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|_d)&~po,this.storedMarks=null,this}get selectionSet(){return(this.updated&_d)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=po,this}ensureMarks(e){return ze.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&po)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~po,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ze.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Te.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ad,this}get scrolledIntoView(){return(this.updated&Ad)>0}}function Md(t,e){return!e||!t?t:t.bind(e)}class ui{constructor(e,n,r){this.name=e,this.init=Md(n.init,r),this.apply=Md(n.apply,r)}}const m_=[new ui("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new ui("selection",{init(t,e){return t.selection||Te.atStart(e.doc)},apply(t){return t.selection}}),new ui("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new ui("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ba{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=m_.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new ui(r.key,r.spec.state,r))})}}class Tr{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}
vendor: 4,185 bytes, line 415
415apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let a=this.config.plugins[s];if(a.spec.appendTransaction){let l=i?i[s].n:0,c=i?i[s].state:this,u=l<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),o=!0}i&&(i[s]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Tr(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new p_(this)}static create(e){let n=new ba(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Tr(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new ba(this.schema,e.plugins),r=n.fields,i=new Tr(n);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new ba(e.schema,e.plugins),o=new Tr(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=jn.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=Te.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){o[s.name]=c.fromJSON.call(l,e,n[a],o);return}}o[s.name]=s.init(e,o)}}),o}}function fg(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=fg(i,e,{})),n[r]=i}return n}class Ct{constructor(e){this.spec=e,this.props={},e.props&&fg(e.props,this,this.props),this.key=e.key?e.key.key:pg("plugin")}getState(e){return e[this.key]}}const wa=Object.create(null);function pg(t){return t in wa?t+"$"+ ++wa[t]:(wa[t]=0,t+"$")}class tn{constructor(e="key"){this.key=pg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const lt=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Fr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let bl=null;const mn=function(t,e,n){let r=bl||(bl=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},g_=function(){bl=null},ur=function(t,e,n,r){return n&&(Nd(t,e,n,r,-1)||Nd(t,e,n,r,1))},y_=/^(img|br|input|textarea|hr)$/i;function Nd(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:qt(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Ji(t)||y_.test(t.nodeName)||t.contentEditable=="false")return!1;e=lt(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?qt(t):0}else return!1}}function qt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function x_(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=qt(t)}else if(t.parentNode&&!Ji(t))e=lt(t),t=t.parentNode;else return null}}function b_(t,e){for(;;
vendor: 1,774 bytes, line 415
415){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Ji(t))e=lt(t)+1,t=t.parentNode;else return null}}function w_(t,e,n){for(let r=e==0,i=e==qt(t);r||i;){if(t==n)return!0;let o=lt(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==qt(t)}}function Ji(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Is=function(t){return t.focusNode&&ur(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Yn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function v_(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function k_(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(qt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(qt(r.startContainer),r.startOffset)}}}const dn=typeof navigator<"u"?navigator:null,jd=typeof document<"u"?document:null,Vn=dn&&dn.userAgent||"",wl=/Edge\/(\d+)/.exec(Vn),mg=/MSIE \d/.exec(Vn),vl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Vn),jt=!!(mg||vl||wl),In=mg?document.documentMode:vl?+vl[1]:wl?+wl[1]:0,Kt=!jt&&/gecko\/(\d+)/i.test(Vn);Kt&&+(/Firefox\/(\d+)/.exec(Vn)||[0,0])[1];const kl=!jt&&/Chrome\/(\d+)/.exec(Vn),dt=!!kl,gg=kl?+kl[1]:0,gt=!jt&&!!dn&&/Apple Computer/.test(dn.vendor),$r=gt&&(/Mobile\/\w+/.test(Vn)||!!dn&&dn.maxTouchPoints>2),Wt=$r||(dn?/Mac/.test(dn.platform):!1),yg=dn?/Win/.test(dn.platform):!1,yn=/Android \d/.test(Vn),Gi=!!jd&&"webkitFontSmoothing"in j
vendor: 4,154 bytes, line 415
415d.documentElement.style,S_=Gi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function C_(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function pn(t,e){return typeof t=="number"?t:t[e]}function E_(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Id(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=Fr(s);continue}let a=s,l=a==o.body,c=l?C_(o):E_(a),u=0,h=0;if(e.top<c.top+pn(r,"top")?h=-(c.top-e.top+pn(i,"top")):e.bottom>c.bottom-pn(r,"bottom")&&(h=e.bottom-e.top>c.bottom-c.top?e.top+pn(i,"top")-c.top:e.bottom-c.bottom+pn(i,"bottom")),e.left<c.left+pn(r,"left")?u=-(c.left-e.left+pn(i,"left")):e.right>c.right-pn(r,"right")&&(u=e.right-c.right+pn(i,"right")),u||h)if(l)o.defaultView.scrollBy(u,h);else{let f=a.scrollLeft,m=a.scrollTop;h&&(a.scrollTop+=h),u&&(a.scrollLeft+=u);let g=a.scrollLeft-f,x=a.scrollTop-m;e={left:e.left-g,top:e.top-x,right:e.right-g,bottom:e.bottom-x}}let p=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(p))break;s=p=="absolute"?s.offsetParent:Fr(s)}}function T_(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let a=t.root.elementFromPoint(o,s);if(!a||a==t.dom||!t.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:xg(t.dom)}}function xg(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Fr(r));return e}function __({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;bg(n,r==0?0:r-e)}function bg(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:o}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let br=null;function A_(t){if(t.setActive)return t.setActive();if(br)return t.focus(br);let e=xg(t);t.focus(br==null?{get preventScroll(){return br={preventScroll:!0},!0}}:void 0),br||(br=!1,bg(e,0))}function wg(t,e){let n,r=2e8,i,o=0,s=e.top,a=e.top,l,c;for(let u=t.firstChild,h=0;u;u=u.nextSibling,h++){let p;if(u.nodeType==1)p=u.getClientRects();else if(u.nodeType==3)p=mn(u).getClientRects();else continue;for(let f=0;f<p.length;f++){let m=p[f];if(m.top<=s&&m.bottom>=a){s=Math.max(m.bottom,s),a=Math.min(m.top,a);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<r){n=u,r=g,i=g&&n.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&g&&(o=h+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!l&&m.left<=e.left&&m.right>=e.left&&(l=u,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!n&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=h+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?M_(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:wg(n,i)}function M_(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let s=Sn(r,1);if(s.top!=s.bottom&&xc(e,s)){i={node:t,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function xc(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function N_(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function j_(t,e,n){let{node:r,offset:i}=wg(e,n),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function I_(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let a=t.docView.nearestDesc(o,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!s&&l.left>r.left||l.top>
vendor: 10,329 bytes, lines 415-416
415r.top?i=a.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(i=a.posAfter),s=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;o=a.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function vg(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let s=t.childNodes[o];if(s.nodeType==1){let a=s.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(xc(e,c))return vg(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function R_(t,e){let n=t.dom.ownerDocument,r,i=0,o=k_(n,e.left,e.top);o&&({node:r,offset:i}=o);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),a;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!xc(e,c)||(s=vg(t.dom,e,c),!s))return null}if(gt)for(let c=s;r&&c;c=Fr(c))c.draggable&&(r=void 0);if(s=N_(s,e),r){if(Kt&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],h;u.nodeName=="IMG"&&(h=u.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let c;Gi&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=I_(t,r,i,e))}a==null&&(a=j_(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Rd(t){return t.top<t.bottom||t.left<t.right}function Sn(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Rd(r))return r}return Array.prototype.find.call(n,Rd)||t.getBoundingClientRect()}const O_=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function kg(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=Gi||Kt;if(r.nodeType==3)if(s&&(O_.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=Sn(mn(r,i,i),n);if(Kt&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Sn(mn(r,i-1,i-1),-1);if(c.top==l.top){let u=Sn(mn(r,i,i+1),-1);if(u.top!=l.top)return ii(u,u.left<c.left)}}return l}else{let l=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(l--,u=1):n<0?l--:c++,ii(Sn(mn(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==qt(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return va(l.getBoundingClientRect(),!1)}if(o==null&&i<qt(r)){let l=r.childNodes[i];if(l.nodeType==1)return va(l.getBoundingClientRect(),!0)}return va(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==qt(r))){let l=r.childNodes[i-1],c=l.nodeType==3?mn(l,qt(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return ii(Sn(c,1),!1)}if(o==null&&i<qt(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?mn(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return ii(Sn(c,-1),!0)}return ii(Sn(r.nodeType==3?mn(r):r,-n),n>=0)}function ii(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function va(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Sg(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function P_(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Sg(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=kg(t,i.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=mn(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const D_=/[\u0590-\u08ac]/;function L_(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,a=t.domSelection();return a?!D_.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?o:s:Sg(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:h}=t.domSelectionRange(),p=a.caretBidiLevel;a.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:m,focusOffset:g}=t.domSelectionRange(),x=m&&!f.contains(m.nodeType==1?m:m.parentNode)||l==m&&c==g;try{a.collapse(u,h),l&&(l!=u||c!=h)&&a.extend&&a.extend(l,c)}catch{}return p!=null&&(a.caretBidiLevel=p),x}):r.pos==r.start()||r.pos==r.end()}let Od=null,Pd=null,Dd=!1;function B_(t,e,n){return Od==e&&Pd==n?Dd:(Od=e,Pd=n,Dd=n=="up"||n=="down"?P_(t,e,n):L_(t,e,n))}const Yt=0,Ld=1,Qn=2,hn=3;class Qi{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Yt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>lt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let a=i.children[s];if(a.size){i=a;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],a=o+s.size;if(a>e||s instanceof Eg){i=e-o;break}o=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Cg&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?lt(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?lt(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,a=0;;a++){let l=this.children[a],c=s+l.size;if(i==-1&&e<=c){let u=s+l.border;if(e>=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=s;for(let h=a;h>0;h--){let p=this.children[h-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){i=lt(p.dom)+1;break}e-=p.size}i==-1&&(i=0)}if(i>-1&&(c>n||a==this.children.length-1)){n=c;for(let u=a+1;u<this.children.length;u++){let h=this.children[u];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=lt(h.dom);break}n+=h.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let o=Math.min(e,n),s=Math.max(e,n);for(let f=0,m=0;f<this.children.length;f++){let g=this.children[f],x=m+g.size;if(o>m&&s<x)return g.setSelection(e-m-g.border,n-m-g.border,r,i);m=x}let a=this.domFromPos(e,e?-1:1),l=n==e?a:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),h=!1;if((Kt||gt)&&e==n){let{node:f,offset:m}=a;if(f.nodeType==3){if(h=!!(m&&f.nodeValue[m-1]==` 416`),h&&m==f.nodeValue.length)for(let g=f,x;g;g=g.parentNode){if(x=g.nextSibling){x.nodeName=="BR"&&(a=l={node:x.parentNode,offset:lt(x)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=f.childNodes[m-1];h=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Kt&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let f=u.focu
vendor: 2,552 bytes, line 416
416sNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||h&>)&&ur(a.node,a.offset,u.anchorNode,u.anchorOffset)&&ur(l.node,l.offset,u.focusNode,u.focusOffset))return;let p=!1;if((c.extend||e==n)&&!(h&&Kt)){c.collapse(a.node,a.offset);try{e!=n&&c.extend(l.node,l.offset),p=!0}catch{}}if(!p){if(e>n){let m=a;a=l,l=m}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let a=r+o.border,l=s-o.border;if(e>=a&&n<=l){this.dirty=e==r||n==s?Qn:Ld,e==a&&n==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=hn:o.markDirty(e-a,n-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Qn:hn}r=s}this.dirty=Qn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Qn:Ld;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Cg extends Qi{constructor(e,n,r,i){let o,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==Yt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class z_ extends Qi{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class dr extends Qi{constructor(e,n,r,i,o){super(e,[],r,i),this.mark=n,this.spec=o}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);
vendor: 2,322 bytes, line 416
416return(!s||!s.dom)&&(s=pr.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new dr(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&hn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=hn&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Yt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Yt}}slice(e,n,r){let i=dr.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=Cl(o,n,s,r)),e>0&&(o=Cl(o,0,e,r));for(let a=0;a<o.length;a++)o[a].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Rn extends Qi{constructor(e,n,r,i,o,s,a,l,c){super(e,[],o,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=a}static create(e,n,r,i,o,s){let a=o.nodeViews[n.type.name],l,c=a&&a(n,o,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),u=c&&c.dom,h=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=pr.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let p=u;return u=Ag(u,r,n),c?l=new F_(e,n,r,i,u,h||null,p,c,o,s+1):n.isText?new Rs(e,n,r,i,u,p,o):new Rn(e,n,r,i,u,h||null,p,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>q.empty)}return e}matchesNode(e,n,r){return this.dirty==Yt&&e.eq(this.node)&&Qo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}
vendor: 11,980 bytes, line 416
416updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new V_(this,s&&s.node,e);q_(this.node,this.innerDeco,(c,u,h)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!h&&l.syncToMarks(u==this.node.childCount?ze.none:this.node.child(u).marks,r,e,u),l.placeWidget(c,e,i)},(c,u,h,p)=>{l.syncToMarks(c.marks,r,e,p);let f;l.findNodeMatch(c,u,h,p)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(f=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(c,u,h,f,e)||l.updateNextNode(c,u,h,e,p,i)||l.addNode(c,u,h,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Qn)&&(s&&this.protectLocalComposition(e,s),Tg(this.contentDOM,this.children,e),$r&&U_(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Se)||r<n||i>n+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,a=K_(this.node.content,s,r-n,i-n);return a<0?null:{node:o,pos:a,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new z_(this,o,n,i);e.input.compositionNodes.push(s),this.children=Cl(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==hn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Yt}updateOuterDeco(e){if(Qo(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=_g(this.dom,this.nodeDOM,Sl(this.outerDeco,this.node,n),Sl(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Bd(t,e,n,r,i){Ag(r,e,t);let o=new Rn(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class Rs extends Rn{constructor(e,n,r,i,o,s,a){super(e,n,r,i,o,null,s,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==hn||this.dirty!=Yt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Yt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Yt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new Rs(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=hn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Eg extends Qi{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Yt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class F_ extends Rn{constructor(e,n,r,i,o,s,a,l,c,u){super(e,n,r,i,o,s,a,c,u),this.spec=l}update(e,n,r,i){if(this.dirty==hn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Tg(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=s.dom;if(a.parentNode==t){for(;a!=r;)r=zd(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(a,r);if(s instanceof dr){let l=r?r.previousSibling:t.lastChild;Tg(s.contentDOM,s.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=zd(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const bi=function(t){t&&(this.nodeName=t)};bi.prototype=Object.create(null);const Xn=[new bi];function Sl(t,e,n){if(t.length==0)return Xn;let r=n?Xn[0]:new bi,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new bi(s.nodeName));for(let a in s){let l=s[a];l!=null&&(n&&i.length==1&&i.push(r=new bi(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return i}function _g(t,e,n,r){if(n==Xn&&r==Xn)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],a=n[o];if(o){let l;a&&a.nodeName==s.nodeName&&i!=t&&(l=i.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=Xn[0]),i=l}$_(i,a||Xn[0],s)}return i}function $_(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&t.classList.add(i[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Ag(t,e,n){return _g(t,t,Xn,Sl(e,n,t.nodeType!=1))}function Qo(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function zd(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class V_{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=W_(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,i){let o=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;o<a&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Yt,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let h=this.top.children[u];if(h.matchesMark(e[s])&&!this.isLocked(h.dom)){l=u;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=dr.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){o=a;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,i,o){let s=this.top.children[i];return s.dirty==hn&&s.dom==s.contentDOM&&(s.dirty=Qn),s.update(e,n,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,o,s){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof Rn){let c=this.preMatch.matched.get(l);if(c!=null&&c!=o)return!1;let u=l.dom,h,p=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=hn&&Qo(n,l.outerDeco));if(!p&&l.update(e,n,r,i))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(h=this.recreateWrapper(l,e,n,r,i,s)))return this.destroyBetween(this.index,a),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=Qn,h.updateChildren(i,s+1),h.dirty=Yt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,o,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Qo(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=Rn.create(this.top,n,r,i,o,s);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,n,r,i,o){let s=Rn.create(this.top,e,n,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new Cg(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof dr;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Rs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((gt||dt)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Eg(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function W_(t,e){let n=e,r=n.children.length,i=t.childCount,o=new Map,s=[];e:for(;i>0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof dr)n=c,r=c.children.length;else{a=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function H_(t,e){return t.type.side-e.type.side}function q_(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let u,h;for(;s<i.length&&i[s].to==o;){let x=i[s++];x.widget&&(u?(h||(h=[u])).push(x):u=x)}if(u)if(h){h.sort(H_);for(let x=0;x<h.length;x++)n(h[x],c,!!l)}else n(u,c,!!l);let p,f;if(l)f=-1,p=l,l=null;else if(c<t.childCount)f=c,p=t.child(c++);else break;for(let x=0;x<a.length;
vendor: 9,941 bytes, line 416
416x++)a[x].to<=o&&a.splice(x--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let m=o+p.nodeSize;if(p.isText){let x=m;s<i.length&&i[s].from<x&&(x=i[s].from);for(let b=0;b<a.length;b++)a[b].to<x&&(x=a[b].to);x<m&&(l=p.cut(x-o),p=p.cut(0,x-o),m=x,f=-1)}else for(;s<i.length&&i[s].to<m;)s++;let g=p.isInline&&!p.isLeaf?a.filter(x=>!x.inline):a.slice();r(p,g,e.forChild(o,p),f),o=m}}function U_(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function K_(t,e,n,r){for(let i=0,o=0;i<t.childCount&&o<=r;){let s=t.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<t.childCount;){let c=t.child(i++);if(o+=c.nodeSize,!c.isText)break;l+=c.text}if(o>=n){if(o>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Cl(t,e,n,r,i){let o=[];for(let s=0,a=0;s<t.length;s++){let l=t[s],c=a,u=a+=l.size;c>=n||u<=e?o.push(l):(c<e&&o.push(l.slice(0,e-c,r)),i&&(o.push(i),i=void 0),u>n&&o.push(l.slice(n-c,l.size,r)))}return o}function bc(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(Is(n)){for(l=s;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&ye.isSelectable(h)&&i.parent&&!(h.isInline&&w_(n.focusNode,n.focusOffset,i.dom))){let p=i.posBefore;c=new ye(s==p?a:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=s,p=s;for(let f=0;f<n.rangeCount;f++){let m=n.getRangeAt(f);h=Math.min(h,t.docView.posFromDOM(m.startContainer,m.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(h<0)return null;[l,s]=p==t.state.selection.anchor?[p,h]:[h,p],a=r.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let h=e=="pointer"||t.state.selection.head<a.pos&&!o?1:-1;c=wc(t,u,a,h)}return c}function Mg(t){return t.editable?t.hasFocus():jg(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function xn(t,e=!1){let n=t.state.selection;if(Ng(t,n),!!Mg(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&dt){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&ur(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)J_(t);else{let{anchor:r,head:i}=n,o,s;Fd&&!(n instanceof Se)&&(n.$from.parent.inlineContent||(o=$d(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=$d(t,n.to))),t.docView.setSelection(r,i,t,e),Fd&&(o&&Vd(o),s&&Vd(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Y_(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Fd=gt||dt&&gg<63;function $d(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(gt&&i&&i.contentEditable=="false")return ka(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return ka(i);if(o)return ka(o)}}function ka(t){return t.contentEditable="true",gt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Vd(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Y_(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Mg(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function J_(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,lt(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&jt&&In<=11&&(n.disabled=!0,n.disabled=!1)}function Ng(t,e){if(e instanceof ye){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Wd(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Wd(t)}function Wd(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function wc(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Se.between(e,n,r)}function Hd(t){return t.editable&&!t.hasFocus()?!1:jg(t)}function jg(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function G_(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return ur(e.node,e.offset,n.anchorNode,n.anchorOffset)}function El(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&Te.findFrom(o,e)}function Cn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function qd(t,e,n){let r=t.state.selection;if(r instanceof Se)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Cn(t,new Se(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=El(t.state,e);return i&&i instanceof ye?Cn(t,i):!1}else if(!(Wt&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let a=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(a))&&!s.contentDOM?ye.isSelectable(o)?Cn(t,new ye(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):Gi?Cn(t,new Se(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ye&&r.node.isInline)return Cn(t,new Se(e>0?r.$to:r.$from));{let i=El(t.state,e);return i?Cn(t,i):!1}}}function Xo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function wi(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function wr(t,e){return e<0?Q_(t):X_(t)}function Q_(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(Kt&&n.nodeType==1&&r<Xo(n)&&wi(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(wi(a,-1))i=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(Ig(n))break;{let a=n.previousSibling;for(;a&&wi(a,-1);)i=n.parentNode,o=lt(a),a=a.previousSibling;if(a)n=a,r=Xo(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Tl(t,n,r):i&&Tl(t,i,o)}function X_(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Xo(n),o,s;for(;;)if(r<i){if(n.nodeType!=1)break;let a=n.childNodes[r];if(wi(a,1))o=n,s=++r;else break}else{if(Ig(n))break;{let a=n.nextSibling;for(;a&&wi(a,1);)o=a.parentNode,s=lt(a)+1,a=a.nextSibling;if(a)n=a,r=0,i=Xo(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&Tl(t,o,s)}function Ig(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Z_(t,e){for(;t&&e==t.childNodes.length&&!Ji(t);)e=lt(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function eA(t,e){for(;t&&!e&&!Ji(t);)e=lt(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Tl(t,e,n){if(e.nodeType!=3){let o,s;(s=Z_(e,n))?(e=s,n=0):(o=eA(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Is(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&xn(t)},50)}function Ud(t,e){let n=t.state.doc.resolve(e);if(!(dt||yg)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Kd(t,e,n){let r=t.state.selection;if(r instanceof Se&&!r.empty||n.indexOf("s")>-1||Wt&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=El(t.state,e);if(s&&s instanceof ye)return Cn(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof Ut?Te.near(s,e):Te.findFrom(s,e);return a?Cn(t,a):!1}return!1}function Yd(t,e){if(!(t.state.selection instanceof Se))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function Jd(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function tA(t){if(!gt||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Jd(t,r,"true"),setTimeout(()=>Jd(t,r,"false"),20)}return!1}function nA(t){let e="";
vendor: 4,151 bytes, lines 416-419
416return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function rA(t,e){let n=e.keyCode,r=nA(e);if(n==8||Wt&&n==72&&r=="c")return Yd(t,-1)||wr(t,-1);if(n==46&&!e.shiftKey||Wt&&n==68&&r=="c")return Yd(t,1)||wr(t,1);if(n==13||n==27)return!0;if(n==37||Wt&&n==66&&r=="c"){let i=n==37?Ud(t,t.state.selection.from)=="ltr"?-1:1:-1;return qd(t,i,r)||wr(t,i)}else if(n==39||Wt&&n==70&&r=="c"){let i=n==39?Ud(t,t.state.selection.from)=="ltr"?1:-1:1;return qd(t,i,r)||wr(t,i)}else{if(n==38||Wt&&n==80&&r=="c")return Kd(t,-1,r)||wr(t,-1);if(n==40||Wt&&n==78&&r=="c")return tA(t)||Kd(t,1,r)||wr(t,1);if(r==(Wt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function vc(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=t.someProp("clipboardSerializer")||pr.fromSchema(t.state.schema),a=Bg(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,u,h=0;for(;c&&c.nodeType==1&&(u=Lg[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let m=a.createElement(u[f]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),h++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${h?` -${h}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,` 417 418`);return{dom:l,text:p,slice:e}}function Rg(t,e,n,r,i){let o=i.parent.type.spec.code,s,a;if(!n&&!e)return null;let l=!!e&&(r||o||!n);if(l){if(t.someProp("transformPastedText",p=>{e=p(e,o||r,t)}),o)return a=new oe(q.from(t.state.schema.text(e.replace(/\r\n?/g,` 419`))),0,0),t.someProp("transformPasted",p=>{a=p(a,t,!0)}),a;let h=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(h)a=h;else{let p=i.marks(),{schema:f}=t.state,m=pr.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let x=s.appendChild(document.createElement("p"));g&&x.appendChild(m.serializeNode(f.text(g,p)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),s=aA(n),Gi&&lA(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let p=s.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;s=p}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||Ir.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!iA.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)a=cA(Gd(a,+u[1],+u[2]),u[4]);else if(a=oe.maxOpen(oA(a.content,i),!0),a.openStart||a.openEnd){let h=0,p=0;for(let f=a.content.firstChild;h<a.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=a.content.lastChild;p<a.openEnd&&!f.type.spec.isolating;p++,f=f.lastChild);a=Gd(a,h,p)}return t.someProp("transformPasted",h=>{a=h(a,t,l)}),a}const iA=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function oA(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(a=>{if(!s)return;let l=i.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&o.length&&Pg(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Dg(s[s.length-1],o.length));let u=Og(a,l);s.push(u),i=i.matchType(u.type),o=l}}),s)return q.from(s)}return t}function Og(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,q.from(t));return t}function Pg(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=Pg(t,e,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(q.from(Og(n,t,i+1))))}}function Dg(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Dg(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(q.empty,!0);return t.copy(n.append(r))}
vendor: 4,774 bytes, line 419
419function _l(t,e,n,r,i,o){let s=e<0?t.firstChild:t.lastChild,a=s.content;return t.childCount>1&&(o=0),i<r-1&&(a=_l(a,e,n,r,i+1,o)),i>=n&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(q.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}function Gd(t,e,n){return e<t.openStart&&(t=new oe(_l(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new oe(_l(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Lg={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Qd=null;function Bg(){return Qd||(Qd=document.implementation.createHTMLDocument("title"))}let Sa=null;function sA(t){let e=window.trustedTypes;return e?(Sa||(Sa=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Sa.createHTML(t)):t}function aA(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Bg().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Lg[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=sA(t),i)for(let o=0;o<i.length;o++)n=n.querySelector(i[o])||n;return n}function lA(t){let e=t.querySelectorAll(dt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent=="Â "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function cA(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:o,openEnd:s}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=q.from(l.create(r[a+1],i)),o++,s++}return new oe(i,o,s)}const vt={},kt={},uA={touchstart:!0,touchmove:!0};class dA{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function hA(t){for(let e in vt){let n=vt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{pA(t,r)&&!kc(t,r)&&(t.editable||!(r.type in kt))&&n(t,r)},uA[e]?{passive:!0}:void 0)}gt&&t.dom.addEventListener("input",()=>null),Al(t)}function Nn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function fA(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Al(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>kc(t,r))})}function kc(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function pA(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function mA(t,e){!kc(t,e)&&vt[e.type]&&(t.editable||!(e.type in kt))&&vt[e.type](t,e)}kt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Fg(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(yn&&dt&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),$r&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Yn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||rA(t,n)?n.preventDefault():Nn(t,"key")};kt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};kt.keypress=(t,e)=>{let n=e;if(Fg(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Wt&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Se)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,o))&&t.dispatch(o()),n.preventDefault()}};function Os(t){return{left:t.clientX,top:t.clientY}}function gA(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}
vendor: 6,330 bytes, line 419
419function Sc(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,a=>s>o.depth?a(t,n,o.nodeAfter,o.before(s),i,!0):a(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function Pr(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function yA(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ye.isSelectable(r)?(Pr(t,new ye(n)),!0):!1}function xA(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof ye&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(ye.isSelectable(a)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(Pr(t,ye.create(t.state.doc,i)),!0):!1}function bA(t,e,n,r,i){return Sc(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?xA(t,n):yA(t,n))}function wA(t,e,n,r){return Sc(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function vA(t,e,n,r){return Sc(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||kA(t,n,r)}function kA(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Pr(t,Se.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),a=i.before(o);if(s.inlineContent)Pr(t,Se.create(r,a+1,a+1+s.content.size));else if(ye.isSelectable(s))Pr(t,ye.create(r,a));else continue;return!0}}function Cc(t){return Zo(t)}const zg=Wt?"metaKey":"ctrlKey";vt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Cc(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&gA(n,t.input.lastClick)&&!n[zg]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button};let s=t.posAtCoords(Os(n));s&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new SA(t,s,n,!!r)):(o=="doubleClick"?wA:vA)(t,s.pos,s.inside,n)?n.preventDefault():Nn(t,"pointer"))};class SA{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[zg],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,s=u.depth?u.before():0}const a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof ye&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Kt&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Nn(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>xn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Os(e))),this.updateAllowDefault(e),this.allowDefault||!n?Nn(this.view,"pointer"):bA(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||gt&&this.mightDrag&&!this.mightDrag.node.isAtom||dt&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Pr(this.view,Te.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Nn(this.view,"pointer")}move(e){this.updateAllowDefault(e),Nn(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}vt.touchstart=t=>{t.input.lastTouch=Date.now(),Cc(t),Nn(t,"pointer")};vt.touchmove=t=>{t.input.lastTouch=Date.now(),Nn(t,"pointer")};vt.contextmenu=t=>Cc(t);function Fg(t,e){return t.composing?!0:gt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const CA=yn?5e3:-1;kt.compositionstart=kt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Se&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||dt&&yg&&EA(t)))t.markCursor=t.state.storedMarks||n.marks(),Zo(t,!0),t.markCursor=null;else if(Zo(t,!e.selection.empty),Kt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let a=t.domSelection();a&&a.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}$g(t,CA)};function EA(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}kt.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>
vendor: 5,033 bytes, line 419
419t.domObserver.flush()),t.input.compositionID++,$g(t,20))};function $g(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Zo(t),e))}function Vg(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=_A());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function TA(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=x_(e.focusNode,e.focusOffset),r=b_(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function _A(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Zo(t,e=!1){if(!(yn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Vg(t),e||t.docView&&t.docView.dirty){let n=bc(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function AA(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Oi=jt&&In<15||$r&&S_<604;vt.copy=kt.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Oi?null:n.clipboardData,s=r.content(),{dom:a,text:l}=vc(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):AA(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function MA(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function NA(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Pi(t,r.value,null,i,e):Pi(t,r.textContent,r.innerHTML,i,e)},50)}function Pi(t,e,n,r,i){let o=Rg(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,o||oe.empty)))return!0;if(!o)return!1;let s=MA(o),a=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Wg(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}kt.paste=(t,e)=>{let n=e;if(t.composing&&!yn)return;let r=Oi?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Pi(t,Wg(r),r.getData("text/html"),i,n)?n.preventDefault():NA(t,n)};class Hg{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const jA=Wt?"altKey":"ctrlKey";function qg(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[jA]}vt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(Os(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof ye?i.to-1:i.to))){if(r&&r.mightDrag)s=ye.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(s=ye.create(t.state.doc,h.posBefore))}}let a=(s||t.state.selection).content(),{dom:l,text:c,slice:u}=vc(t,a);(!n.dataTransfer.files.length||!dt||gg>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Oi?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Oi||n.dataTransfer.setData("text/plain",c),t.dragging=new Hg(u,qg(t,n),s)};vt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};kt.dragover=kt.dragenter=(t,e)=>e.preventDefault();kt.drop=(t,e)=>{try{IA(t,e,t.dragging)}finally{t.dragging=null}};function IA(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Os(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",f=>{o=f(o,t,!1)}):o=Rg(t,Wg(e.dataTransfer),Oi?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&qg(t,e));if(t.someProp("handleDrop",f=>f(t,e,o||oe.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?lg(t.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let l=t.state.tr;if(s){let{node:f}=n;f?f.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,h=l.doc;if(u?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(h))return;let p=l.doc.resolve(c);
vendor: 8,913 bytes, line 419
419if(u&&ye.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new ye(p));else{let f=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,g,x,b)=>f=b),l.setSelection(wc(t,p,l.doc.resolve(f)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}vt.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&xn(t)},20))};vt.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};vt.beforeinput=(t,e)=>{if(dt&&yn&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,Yn(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in kt)vt[t]=kt[t];function Di(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class es{constructor(e,n){this.toDOM=e,this.spec=n||ir,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new Vt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof es&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Di(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class On{constructor(e,n){this.attrs=e,this.spec=n||ir}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Vt(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof On&&Di(this.attrs,e.attrs)&&Di(this.spec,e.spec)}static is(e){return e.type instanceof On}destroy(){}}class Ec{constructor(e,n){this.attrs=e,this.spec=n||ir}map(e,n,r,i){let o=e.mapResult(n.from+i,1);if(o.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=o.pos?null:new Vt(o.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),o;return i==n.from&&!(o=e.child(r)).isText&&i+o.nodeSize==n.to}eq(e){return this==e||e instanceof Ec&&Di(this.attrs,e.attrs)&&Di(this.spec,e.spec)}destroy(){}}class Vt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Vt(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Vt(e,e,new es(n,r))}static inline(e,n,r,i){return new Vt(e,n,new On(r,i))}static node(e,n,r,i){return new Vt(e,n,new Ec(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof On}get widget(){return this.type instanceof es}}const Er=[],ir={};class Je{constructor(e,n){this.local=e.length?e:Er,this.children=n.length?n:Er}static create(e,n){return n.length?ts(n,e,0,ir):mt}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,o){for(let s=0;s<this.local.length;s++){let a=this.local[s];a.from<=n&&a.to>=e&&(!o||o(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let a=this.children[s]+1;this.children[s+2].findInner(e-a,n-a,r,i+a,o)}}map(e,n,r){return this==mt||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ir)}mapInner(e,n,r,i,o){let s;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,i);l&&l.type.valid(n,l)?(s||(s=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?RA(this.children,s||[],e,n,r,i,o):s?new Je(s.sort(or),Er):mt}add(e,n){return n.length?this==mt?Je.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,o=0;e.forEach((a,l)=>{let c=l+r,u;if(u=Kg(n,a,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<l;)o+=3;i[o]==l?i[o+2]=i[o+2].addInner(a,u,c+1):i.splice(o,0,l,l+a.nodeSize,ts(u,a,c+1,ir)),o+=3}});let s=Ug(o?Yg(n):n,-r);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new Je(s.length?this.local.concat(s).sort(or):this.local,i||this.children)}remove(e){return e.length==0||this==mt?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,a=r[o]+n,l=r[o+1]+n;for(let u=0,h;u<e.length;u++)(h=e[u])&&h.from>a&&h.to<l&&(e[u]=null,(s||(s=[])).push(h));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,a+1);c!=mt?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let a=0;a<i.length;a++)i[a].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Je(i,r):mt}forChild(e,n){if(this==mt)return this;if(n.isLeaf)return Je.empty;let r,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let o=e+1,s=o+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<s&&l.to>o&&l.type instanceof On){let c=Math.max(o,l.from)-o,u=Math.min(s,l.to)-o;c<u&&(i||(i=[])).push(l.copy(c,u))}}if(i){let a=new Je(i.sort(or),Er);return r?new _n([a,r]):a}return r||mt}eq(e){if(this==e)return!0;if(!(e instanceof Je)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Tc(this.localsInner(e))}localsInner(e){if(this==mt)return Er;if(e.inlineContent||!this.local.some(On.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof On||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Je.empty=new Je([],[]);Je.removeOverlap=Tc;const mt=Je.empty;class _n{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,ir));return _n.from(r)}forChild(e,n){if(n.isLeaf)return Je.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=mt&&(o instanceof _n?r=r.concat(o.members):r.push(o))}return _n.from(r)}eq(e){if(!(e instanceof _n)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let s=0;s<o.length;s++)n.push(o[s])}}return n?Tc(r?n:n.sort(or)):Er}static from(e){switch(e.length){case 0:return mt;case 1:return e[0];default:return new _n(e.every(n=>n instanceof Je)?e:e.reduce((n,r)=>n.concat(r instanceof Je?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function RA(t,e,n,r,i,o,s){let a=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let h=0;n.maps[c].forEach((p,f,m,g)=>{let x=g-m-(f-p);for(let b=0;b<a.length;b+=3){let E=a[b+1];if(E<0||p>E+u-h)continue;let v=a[b]+u-h;f>=v?a[b+1]=p<=v?-2:-1:p>=u&&x&&(a[b]+=x,a[b+1]+=x)}h+=x}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=n.map(t[c]+o),h=u-i;if(h<0||h>=r.content.size){l=!0;continue}let p=n.map(t[c+1]+o,-1),f=p-i,{index:m,offset:g}=r.content.findIndex(h),x=r.maybeChild(m);if(x&&g==h&&g+x.nodeSize==f){let b=a[c+2].mapInner(n,x,u+1,t[c]+o+1,s);b!=mt?(a[c]=h,a[c+1]=f,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=OA(a,t,e,n,i,o,s),u=ts(c,r,0,s);e=u.local;for(let h=0;h<a.length;h+=3)a[h+1]<0&&(a.splice(h,3),h-=3);for(let h=0,p=0;h<u.children.length;h+=3){let f=u.children[h];for(;p<a.length&&a[p]<f;)p+=3;a.splice(p,0,u.children[h],u.children[h+1],u.children[h+2])}}return new Je(e.sort(or),a)}function Ug(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Vt(i.from+e,i.to+e,i.type))}return n}function OA(t,e,n,r,i,o,s){function a(l,c){for(let u=0;u<l.local.length;u++){let h=l.local[u].map(r,i,c);h?n.push(h):s.onRemove&&s.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+o+1);return n}function Kg(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let o=0,s;o<t.length;o++)(s=t[o])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[o]=null);return i}function Yg(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function ts(t,e,n,r){let i=[],o=!1;e.forEach((a,l)=>{let c=Kg(t,a,l+n);if(c){o=!0;let u=ts(c,a,n+l+1,r);u!=mt&&i.push(l,l+a.nodeSize,u)}});
vendor: 11,105 bytes, line 419
419let s=Ug(o?Yg(t):t,-n).sort(or);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||i.length?new Je(s,i):mt}function or(t,e){return t.from-e.from||t.to-e.to}function Tc(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[i]=o.copy(o.from,r.to),Xd(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),Xd(e,i,r.copy(o.from,r.to)));break}}}return e}function Xd(t,e,n){for(;e<t.length&&or(n,t[e])>0;)e++;t.splice(e,0,n)}function Ca(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=mt&&e.push(r)}),t.cursorWrapper&&e.push(Je.create(t.state.doc,[t.cursorWrapper.deco])),_n.from(e)}const PA={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},DA=jt&&In<=11;class LA{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class BA{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new LA,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);jt&&In<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():gt&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),DA&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,PA)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Hd(this.view)){if(this.suppressingSelectionUpdates)return xn(this.view);if(jt&&In<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ur(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=Fr(o))n.add(o);for(let o=e.anchorNode;o;o=Fr(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Hd(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let u=0;u<n.length;u++){let h=this.registerMutation(n[u],l);h&&(o=o<0?h.from:Math.min(h.from,o),s=s<0?h.to:Math.max(h.to,s),h.typeOver&&(a=!0))}if(l.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let h=u.nextSibling;for(;h&&h.nodeType==1;){if(h.contentEditable=="false"){u.parentNode.removeChild(u);break}h=h.firstChild}}}else if(Kt&&l.length){let u=l.filter(h=>h.nodeName=="BR");if(u.length==2){let[h,p]=u;h.parentNode&&h.parentNode.parentNode==p.parentNode?p.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let p of u){let f=p.parentNode;f&&f.nodeName=="LI"&&(!h||$A(e,h)!=f)&&p.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Is(r)&&(c=bc(e))&&c.eq(Te.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,xn(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),zA(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,VA(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||xn(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let h=e.addedNodes[u];n.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(jt&&In<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:h,nextSibling:p}=e.addedNodes[u];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(o=p)}let s=i&&i.parentNode==e.target?lt(i)+1:0,a=r.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?lt(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Zd=new WeakMap,eh=!1;function zA(t){if(!Zd.has(t)&&(Zd.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Kt,eh)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),eh=!0}}function th(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return ur(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function FA(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return th(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?th(t,n):null}function $A(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function VA(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let o of e)if(((n=o.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let a=s;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(o,a.firstChild),r==o&&t.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function WA(t,e,n){let{node:r,fromOffset:i,toOffset:o,from:s,to:a}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,u=l.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],Is(l)||c.push({node:l.focusNode,offset:l.focusOffset})),dt&&t.input.lastKeyCode===8)for(let x=o;x>i;x--){let b=r.childNodes[x-1],E=b.pmViewDesc;if(b.nodeName=="BR"&&!E){o=x;break}if(!E||E.size)break}let h=t.state.doc,p=t.someProp("domParser")||Ir.fromSchema(t.state.schema),f=h.resolve(s),m=null,g=p.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:i,to:o,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:HA,context:f});if(c&&c[0].pos!=null){let x=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=x),m={anchor:x+s,head:b+s}}return{doc:g,sel:m,from:s,to:a}}function HA(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(gt&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||gt&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const qA=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function UA(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let N=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,M=bc(t,N);if(M&&!t.state.selection.eq(M)){if(dt&&yn&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",P=>P(t,Yn(13,"Enter"))))return;let L=t.state.tr.setSelection(M);N=="pointer"?L.setMeta("pointer",!0):N=="key"&&L.scrollIntoView(),o&&L.setMeta("composition",o),t.dispatch(L)}return}let s=t.state.doc.resolve(e),a=s.sharedDepth(n);e=s.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,c=WA(t,e,n),u=t.state.doc,h=u.slice(c.from,c.to),p,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,f="end"):(p=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let m=JA(h.content,c.doc.content,c.from,p,f);if(m&&t.input.domChangeCount++,($r&&t.input.lastIOSEnter>Date.now()-225||yn)&&i.some(N=>N.nodeType==1&&!qA.test(N.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",N=>N(t,Yn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof Se&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head)
vendor: 4,133 bytes, line 419
419)m={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let N=nh(t,t.state.doc,c.sel);if(N&&!N.eq(t.state.selection)){let M=t.state.tr.setSelection(N);o&&M.setMeta("composition",o),t.dispatch(M)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof Se&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),jt&&In<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)==" Â "&&(m.start--,m.endA--,m.endB--);let g=c.doc.resolveNoCache(m.start-c.from),x=c.doc.resolveNoCache(m.endB-c.from),b=u.resolve(m.start),E=g.sameParent(x)&&g.parent.inlineContent&&b.end()>=m.endA;if(($r&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!E&&g.pos<c.doc.content.size&&(!g.sameParent(x)||!g.parent.inlineContent)&&g.pos<x.pos&&!/\S/.test(c.doc.textBetween(g.pos,x.pos,"","")))&&t.someProp("handleKeyDown",N=>N(t,Yn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&YA(u,m.start,m.endA,g,x)&&t.someProp("handleKeyDown",N=>N(t,Yn(8,"Backspace")))){yn&&dt&&t.domObserver.suppressSelectionUpdates();return}dt&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),yn&&!E&&g.start()!=x.start()&&x.parentOffset==0&&g.depth==x.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,x=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,Yn(13,"Enter"))})},20));let v=m.start,A=m.endA,_=N=>{let M=N||t.state.tr.replace(v,A,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let L=nh(t,M.doc,c.sel);L&&!(dt&&t.composing&&L.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(L.head==v||L.head==M.mapping.map(A)-1)||jt&&L.empty&&L.head==v)&&M.setSelection(L)}return o&&M.setMeta("composition",o),M.scrollIntoView()},S;if(E)if(g.pos==x.pos){jt&&In<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>xn(t),20));let N=_(t.state.tr.delete(v,A)),M=u.resolve(m.start).marksAcross(u.resolve(m.endA));M&&N.ensureMarks(M),t.dispatch(N)}else if(m.endA==m.endB&&(S=KA(g.parent.content.cut(g.parentOffset,x.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let N=_(t.state.tr);S.type=="add"?N.addMark(v,A,S.mark):N.removeMark(v,A,S.mark),t.dispatch(N)}else if(g.parent.child(g.index()).isText&&g.index()==x.index()-(x.textOffset?0:1)){let N=g.parent.textBetween(g.parentOffset,x.parentOffset),M=()=>_(t.state.tr.insertText(N,v,A));t.someProp("handleTextInput",L=>L(t,v,A,N,M))||t.dispatch(M())}else t.dispatch(_());else t.dispatch(_())}function nh(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:wc(t,e.resolve(n.anchor),e.resolve(n.head))}function KA(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,a,l;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(i.length==1&&o.length==0)a=i[0],s="add",l=u=>u.mark(a.addToSet(u.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(q.from(c).eq(t))return{mark:a,type:s}}function YA(t,e,n,r,i){if(n-e<=i.pos-r.pos||Ea(r,!0,!1)<i.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let a=o.nodeAfter;return a!=null&&n==e+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=t.resolve(Ea(o,!0,!0));return!s.parent.isTextblock||s.pos>n||Ea(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Ea(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function JA(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:s,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);
vendor: 4,449 bytes, line 419
419if(i=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s<o&&t.size<e.size){let l=r<=o&&r>=s?o-r:0;o-=l,o&&o<e.size&&rh(e.textBetween(o-1,o+1))&&(o+=l?1:-1),a=o+(a-s),s=o}else if(a<o){let l=r<=o&&r>=a?o-r:0;o-=l,o&&o<t.size&&rh(t.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}function rh(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Jg{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new dA,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(lh),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=sh(this),oh(this),this.nodeViews=ah(this),this.docView=Bd(this.state.doc,ih(this),Ca(this),this.dom,this),this.domObserver=new BA(this,(r,i,o,s)=>UA(this,r,i,o,s)),this.domObserver.start(),hA(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Al(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(lh),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Vg(this),s=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=ah(this);QA(f,this.nodeViews)&&(this.nodeViews=f,o=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&Al(this),this.editable=sh(this),oh(this);let l=Ca(this),c=ih(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=o||!this.docView.matchesNode(e.doc,c,l);(h||!e.selection.eq(i.selection))&&(s=!0);let p=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&T_(this);if(s){this.domObserver.stop();let f=h&&(jt||dt)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&GA(i.selection,e.selection);if(h){let m=dt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=TA(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Bd(e.doc,c,l,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&G_(this))?xn(this,f):(Ng(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&__(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof ye){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Id(this,n.getBoundingClientRect(),e)}else Id(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;
vendor: 6,061 bytes, line 419
419if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new Hg(e.slice,e.move,i<0?void 0:ye.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let a=this.directPlugins[s].props[e];if(a!=null&&(i=n?n(a):a))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let a=o[s].props[e];if(a!=null&&(i=n?n(a):a))return i}}hasFocus(){if(jt){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&A_(this.dom),xn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return R_(this,e)}coordsAtPos(e,n=1){return kg(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return B_(this,n||this.state,e)}pasteHTML(e,n){return Pi(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Pi(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return vc(this,e)}destroy(){this.docView&&(fA(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ca(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,g_())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return mA(this,e)}domSelectionRange(){let e=this.domSelection();return e?gt&&this.root.nodeType===11&&v_(this.dom.ownerDocument)==this.dom&&FA(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Jg.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function ih(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Vt.node(0,t.state.doc.content.size,e)]}function oh(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Vt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function sh(t){return!t.someProp("editable",e=>e(t.state)===!1)}function GA(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function ah(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function QA(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function lh(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Dn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},ns={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},XA=typeof navigator<"u"&&/Mac/.test(navigator.platform),ZA=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ct=0;ct<10;ct++)Dn[48+ct]=Dn[96+ct]=String(ct);for(var ct=1;ct<=24;ct++)Dn[ct+111]="F"+ct;for(var ct=65;ct<=90;ct++)Dn[ct]=String.fromCharCode(ct+32),ns[ct]=String.fromCharCode(ct);for(var Ta in Dn)ns.hasOwnProperty(Ta)||(ns[Ta]=Dn[Ta]);function eM(t){var e=XA&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||ZA&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ns:Dn)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const tM=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),nM=typeof navigator<"u"&&/Win/.test(navigator.platform);function rM(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))tM?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function iM(t){let e=Object.create(null);for(let n in t)e[rM(n)]=t[n];return e}
vendor: 72,747 bytes, lines 419-499
419function _a(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function oM(t){return new Ct({props:{handleKeyDown:Gg(t)}})}function Gg(t){let e=iM(t);return function(n,r){let i=eM(r),o,s=e[_a(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[_a(i,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(nM&&r.ctrlKey&&r.altKey)&&(o=Dn[r.keyCode])&&o!=i){let a=e[_a(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const sM=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Qg(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const aM=(t,e,n)=>{let r=Qg(t,n);if(!r)return!1;let i=_c(r);if(!i){let s=r.blockRange(),a=s&&Gr(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(ty(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Vr(o,"end")||ye.isSelectable(o)))for(let s=r.depth;;s--){let a=Ns(t.doc,r.before(s),r.after(s),oe.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(Vr(o,"end")?Te.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):ye.create(l.doc,i.pos-o.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},lM=(t,e,n)=>{let r=Qg(t,n);if(!r)return!1;let i=_c(r);return i?Xg(t,i,e):!1},cM=(t,e,n)=>{let r=Zg(t,n);if(!r)return!1;let i=Ac(r);return i?Xg(t,i,e):!1};function Xg(t,e,n){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,a=s,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=Ns(t.doc,o,l,oe.empty);if(!c||c.from!=o||c instanceof Ye&&c.slice.size>=l-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(Se.create(u.doc,o)),n(u.scrollIntoView())}return!0}function Vr(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const uM=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=_c(r)}let s=o&&o.nodeBefore;return!s||!ye.isSelectable(s)?!1:(e&&e(t.tr.setSelection(ye.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function _c(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Zg(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const dM=(t,e,n)=>{let r=Zg(t,n);if(!r)return!1;let i=Ac(r);if(!i)return!1;let o=i.nodeAfter;if(ty(t,i,e,1))return!0;if(r.parent.content.size==0&&(Vr(o,"start")||ye.isSelectable(o))){let s=Ns(t.doc,r.before(),r.after(),oe.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=t.tr.step(s);a.setSelection(Vr(o,"start")?Te.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):ye.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},hM=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=Ac(r)}let s=o&&o.nodeAfter;return!s||!ye.isSelectable(s)?!1:(e&&e(t.tr.setSelection(ye.create(t.doc,o.pos)).scrollIntoView()),!0)};function Ac(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const fM=(t,e)=>{let n=t.selection,r=n instanceof ye,i;if(r){if(n.node.isTextblock||!$n(t.doc,n.from))return!1;i=n.from}else if(i=Ms(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(ye.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},pM=(t,e)=>{let n=t.selection,r;if(n instanceof ye){if(n.node.isTextblock||!$n(t.doc,n.to))return!1;r=n.to}else if(r=Ms(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},mM=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&Gr(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},gM=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` 420`).scrollIntoView()),!0)};function ey(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const yM=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=ey(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,s.createAndFill());l.setSelection(Te.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},xM=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ut||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=ey(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,a=t.tr.insert(s,o.createAndFill());a.setSelection(Se.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},bM=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(Rr(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Gr(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)},wM=(t,e)=>{let{$from:n,to:r}=t.selection,i,o=n.sharedDepth(r);return o==0?!1:(i=n.before(o),e&&e(t.tr.setSelection(ye.create(t.doc,i))),!0)};function vM(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||$n(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function ty(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&vM(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(a=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&a.matchType(s[0]||o.type).validEnd){if(n){let f=e.pos+o.nodeSize,m=q.empty;for(let b=s.length-1;b>=0;b--)m=q.from(s[b].create(null,m));m=q.from(i.copy(m));let g=t.tr.step(new tt(e.pos-1,f,e.pos,f,new oe(m,1,0),s.length,!0)),x=g.doc.resolve(f+2*s.length);x.nodeAfter&&x.nodeAfter.type==i.type&&$n(g.doc,x.pos)&&g.join(x.pos),n(g.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&l?null:Te.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),p=h&&Gr(h);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(h,p).scrollIntoView()),!0;if(c&&Vr(o,"start",!0)&&Vr(i,"end")){let f=i,m=[];for(;m.push(f),!f.isTextblock;)f=f.lastChild;let g=o,x=1;for(;!g.isTextblock;g=g.firstChild)x++;if(f.canReplace(f.childCount,f.childCount,g.content)){if(n){let b=q.empty;for(let v=m.length-1;v>=0;v--)b=q.from(m[v].copy(b));let E=t.tr.step(new tt(e.pos-m.length,e.pos+o.nodeSize,e.pos+x,e.pos+o.nodeSize-x,new oe(b,m.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function ny(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(Se.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const kM=ny(-1),SM=ny(1);function CM(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&gc(s,t,e);return a?(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0):!1}}function ch(t,e=null){return function(n,r){let i=!1;for(let o=0;o<n.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:a}}=n.selection.ranges[o];n.doc.nodesBetween(s,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let u=n.doc.resolve(c),h=u.index();i=u.parent.canReplaceWith(h,h+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[s];o.setBlockType(a,l,t,e)}r(o.scrollIntoView())}return!0}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function EM(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o);if(!s)return!1;let a=r?n.tr:null;return TM(a,s,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function TM(t,e,n,r=null){let i=!1,o=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=s.resolve(e.start-2);o=new Jo(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new Jo(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=gc(o,n,r,e);return a?(t&&_M(t,e,a,i,n),!0):!1}function _M(t,e,n,r,i){let o=q.empty;for(let u=n.length-1;u>=0;u--)o=q.from(n[u].type.create(n[u].attrs,o));t.step(new tt(e.start-(r?2:0),e.end,e.start,e.end,new oe(o,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==i&&(s=u+1);let a=n.length-s,l=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,h=e.endIndex,p=!0;u<h;u++,p=!1)!p&&Rr(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(u).nodeSize;return t}function AM(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?MM(e,n,t,o):NM(e,n,o):!0:!1}}function MM(t,e,n,r){let i=t.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new tt(o-1,s,o,s,new oe(q.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Jo(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=Gr(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return $n(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function NM(t,e,n){let r=t.tr,i=n.parent;for(let f=n.end,m=n.endIndex-1,g=n.startIndex;m>g;m--)f-=i.child(m).nodeSize,r.delete(f-1,f+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,s.content.append(l?q.empty:q.from(i))))return!1;let h=o.pos,p=h+s.nodeSize;return r.step(new tt(h-(a?1:0),p+(l?1:0),h+1,p-1,new oe((a?q.empty:q.from(i.copy(q.empty))).append(l?q.empty:q.from(i.copy(q.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function jM(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,u=q.from(c?t.create():null),h=new oe(q.from(t.create(null,q.from(a.type.create(null,u)))),c?3:1,0),p=o.start,f=o.end;n(e.tr.step(new tt(p-(c?3:1),f,p,f,h,1,!0)).scrollIntoView())}return!0}}function Ps(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}}}class Ds{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:n,state:r}=this,{view:i}=n,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...u)=>{const h=l(...u)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a=[],l=!!e,c=e||o.tr,u=()=>(!l&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),a.every(p=>p===!0)),h={...Object.fromEntries(Object.entries(r).map(([p,f])=>[p,(...g)=>{const x=this.buildProps(c,n),b=f(...g)(x);return a.push(b),h}])),run:u};return h}createCan(e){const{rawCommands:n,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a={tr:e,editor:i,view:s,state:Ps({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}}class IM{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}once(e,n){const r=(...i)=>{this.off(e,r),n.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function ce(t,e,n){return t.config[e]===void 0&&t.parent?ce(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?ce(t.parent,e,n):null}):t.config[e]}function Ls(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function ry(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ls(t),i=[...n,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage,extensions:i},l=ce(s,"addGlobalAttributes",a);if(!l)return;l().forEach(u=>{u.types.forEach(h=>{Object.entries(u.attributes).forEach(([p,f])=>{e.push({type:h,name:p,attribute:{...o,...f}})})})})}),i.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage},l=ce(s,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([u,h])=>{const p={...o,...h};typeof(p==null?void 0:p.default)=="function"&&(p.default=p.default()),p!=null&&p.isRequired&&(p==null?void 0:p.default)===void 0&&delete p.default,e.push({type:s.name,name:u,attribute:p})})}),e}function rt(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function yt(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){const a=o?String(o).split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(u=>!l.includes(u));r[i]=[...l,...c].join(" ")}else if(i==="style"){const a=o?o.split(";").map(u=>u.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{const[h,p]=u.split(":").map(f=>f.trim());c.set(h,p)}),a.forEach(u=>{const[h,p]=u.split(":").map(f=>f.trim());c.set(h,p)}),r[i]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[i]=o}),r},{})}function Ml(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>yt(n,r),{})}function iy(t){return typeof t=="function"}function _e(t,e=void 0,...n){return iy(t)?e?t.bind(e)(...n):t(...n):t}function RM(t={}){return Object.keys(t).length===0&&t.constructor===Object}function OM(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function uh(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((o,s)=>{const a=s.attribute.parseHTML?s.attribute.parseHTML(n):OM(n.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function dh(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&RM(n)?!1:n!=null))}function PM(t,e){var n;const r=ry(t),{nodeExtensions:i,markExtensions:o}=Ls(t),s=(n=i.find(c=>ce(c,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(i.map(c=>{const u=r.filter(b=>b.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:e},p=t.reduce((b,E)=>{const v=ce(E,"extendNodeSchema",h);return{...b,...v?v(c):{}}},{}),f=dh({...p,content:_e(ce(c,"content",h)),marks:_e(ce(c,"marks",h)),group:_e(ce(c,"group",h)),inline:_e(ce(c,"inline",h)),atom:_e(ce(c,"atom",h)),selectable:_e(ce(c,"selectable",h)),draggable:_e(ce(c,"draggable",h)),code:_e(ce(c,"code",h)),whitespace:_e(ce(c,"whitespace",h)),linebreakReplacement:_e(ce(c,"linebreakReplacement",h)),defining:_e(ce(c,"defining",h)),isolating:_e(ce(c,"isolating",h)),attrs:Object.fromEntries(u.map(b=>{var E;return[b.name,{default:(E=b==null?void 0:b.attribute)===null||E===void 0?void 0:E.default}]}))}),m=_e(ce(c,"parseHTML",h));m&&(f.parseDOM=m.map(b=>uh(b,u)));const g=ce(c,"renderHTML",h);g&&(f.toDOM=b=>g({node:b,HTMLAttributes:Ml(b,u)}));const x=ce(c,"renderText",h);return x&&(f.toText=x),[c.name,f]})),l=Object.fromEntries(o.map(c=>{const u=r.filter(x=>x.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:e},p=t.reduce((x,b)=>{const E=ce(b,"extendMarkSchema",h);return{...x,...E?E(c):{}}},{}),f=dh({...p,inclusive:_e(ce(c,"inclusive",h)),excludes:_e(ce(c,"excludes",h)),group:_e(ce(c,"group",h)),spanning:_e(ce(c,"spanning",h)),code:_e(ce(c,"code",h)),attrs:Object.fromEntries(u.map(x=>{var b;return[x.name,{default:(b=x==null?void 0:x.attribute)===null||b===void 0?void 0:b.default}]}))}),m=_e(ce(c,"parseHTML",h));m&&(f.parseDOM=m.map(x=>uh(x,u)));const g=ce(c,"renderHTML",h);return g&&(f.toDOM=x=>g({mark:x,HTMLAttributes:Ml(x,u)})),[c.name,f]}));return new Qm({topNode:s,nodes:a,marks:l})}function Aa(t,e){return e.nodes[t]||e.marks[t]||null}function hh(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Mc(t,e){const n=pr.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}const DM=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,a)=>{var l,c;const u=((c=(l=i.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:i,pos:o,parent:s,index:a}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-o))}),n};function Nc(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Bs{constructor(e){this.find=e.find,this.handler=e.handler}}const LM=(t,e)=>{if(Nc(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function mo(t){var e;const{editor:n,from:r,to:i,text:o,rules:s,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(p=>p.type.spec.code))return!1;let u=!1;const h=DM(c)+o;return s.forEach(p=>{if(u)return;const f=LM(h,p.find);if(!f)return;const m=l.state.tr,g=Ps({state:l.state,transaction:m}),x={from:r-(f[0].length-o.length),to:i},{commands:b,chain:E,can:v}=new Ds({editor:n,state:g});p.handler({state:g,range:x,match:f,commands:b,chain:E,can:v})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:i,text:o}),l.dispatch(m),u=!0)}),u}function BM(t){const{editor:e,rules:n}=t,r=new Ct({state:{init(){return null},apply(i,o,s){const a=i.getMeta(r);if(a)return a;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=Mc(q.from(u),s.schema);const{from:h}=l,p=h+u.length;mo({editor:e,from:h,to:p,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,a){return mo({editor:e,from:o,to:s,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&mo({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?mo({editor:e,from:s.pos,to:s.pos,text:` 421`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function zM(t){return Object.prototype.toString.call(t).slice(8,-1)}function go(t){return zM(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function zs(t,e){const n={...t};return go(t)&&go(e)&&Object.keys(e).forEach(r=>{go(e[r])&&go(t[r])?n[r]=zs(t[r],e[r]):n[r]=e[r]}),n}class bn{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=_e(ce(this,"addOptions",{name:this.name}))),this.storage=_e(ce(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new bn(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>zs(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new bn(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=_e(ce(n,"addOptions",{name:n.name})),n.storage=_e(ce(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const l=s.find(c=>(c==null?void 0:c.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}function FM(t){return typeof t=="number"}class $M{constructor(e){this.find=e.find,this.handler=e.handler}}const VM=(t,e,n)=>{if(Nc(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const o=[i.text];return o.index=i.index,o.input=t,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function WM(t){const{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:c,can:u}=new Ds({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,i,(f,m)=>{if(!f.isTextblock||f.type.spec.code)return;const g=Math.max(r,m),x=Math.min(i,m+f.content.size),b=f.textBetween(g-m,x-m,void 0,"");VM(b,o.find,s).forEach(v=>{if(v.index===void 0)return;const A=g+v.index+1,_=A+v[0].length,S={from:n.tr.mapping.map(A),to:n.tr.mapping.map(_)},N=o.handler({state:n,range:S,match:v,commands:l,chain:c,can:u,pasteEvent:s,dropEvent:a});h.push(N)})}),h.every(f=>f!==null)}let yo=null;const HM=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function qM(t){const{editor:e,rules:n}=t;let r=null,i=!1,o=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:u,from:h,to:p,rule:f,pasteEvt:m})=>{const g=u.tr,x=Ps({state:u,transaction:g});if(!(!WM({editor:e,state:x,from:Math.max(h-1,0),to:p.b-1,rule:f,pasteEvent:m,dropEvent:a})||!g.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return n.map(u=>new Ct({view(h){const p=m=>{var g;r=!((g=h.dom.parentElement)===null||g===void 0)&&g.contains(m.target)?h.dom.parentElement:null,r&&(yo=e)},f=()=>{yo&&(yo=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(h,p)=>{if(o=r===h.dom.parentElement,a=p,!o){const f=yo;f!=null&&f.isEditable&&setTimeout(()=>{const m=f.state.selection;m&&f.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(h,p)=>{var f;const m=(f=p.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return s=p,i=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(h,p,f)=>{const m=h[0],g=m.getMeta("uiEvent")==="paste"&&!i,x=m.getMeta("uiEvent")==="drop"&&!o,b=m.getMeta("applyPasteRules"),E=!!b;if(!g&&!x&&!E)return;if(E){let{text:_}=b;typeof _=="string"?_=_:_=Mc(q.from(_),f.schema);const{from:S}=b,N=S+_.length,M=HM(_);return l({rule:u,state:f,from:S,to:{b:N},pasteEvt:M})}const v=p.doc.content.findDiffStart(f.doc.content),A=p.doc.content.findDiffEnd(f.doc.content);if(!(!FM(v)||!A||v===A.b))return l({rule:u,state:f,from:v,to:A,pasteEvt:s})}}))}function UM(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}class _r{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=_r.resolve(e),this.schema=PM(this.extensions,n),this.setupExtensions()}static resolve(e){const n=_r.sort(_r.flatten(e)),r=UM(n.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),n}static flatten(e){return e.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},i=ce(n,"addExtensions",r);return i?[n,...this.flatten(i())]:n}).flat(10)}static sort(e){return e.sort((r,i)=>{const o=ce(r,"priority")||100,s=ce(i,"priority")||100;return o>s?-1:o<s?1:0})}get commands(){return this.extensions.reduce((e,n)=>{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Aa(n.name,this.schema)},i=ce(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,n=_r.sort([...this.extensions].reverse()),r=[],i=[],o=n.map(s=>{const a={name:s.name,options:s.options,storage:s.storage,editor:e,type:Aa(s.name,this.schema)},l=[],c=ce(s,"addKeyboardShortcuts",a);let u={};if(s.type==="mark"&&ce(s,"exitable",a)&&(u.ArrowRight=()=>bn.handleExit({editor:e,mark:s})),c){const g=Object.fromEntries(Object.entries(c()).map(([x,b])=>[x,()=>b({editor:e})]));u={...u,...g}}const h=oM(u);l.push(h);const p=ce(s,"addInputRules",a);hh(s,e.options.enableInputRules)&&p&&r.push(...p());const f=ce(s,"addPasteRules",a);hh(s,e.options.enablePasteRules)&&f&&i.push(...f());const m=ce(s,"addProseMirrorPlugins",a);if(m){const g=m();l.push(...g)}return l}).flat();return[BM({editor:e,rules:r}),...qM({editor:e,rules:i}),...o]}get attributes(){return ry(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:n}=Ls(this.extensions);return Object.fromEntries(n.filter(r=>!!ce(r,"addNodeView")).map(r=>{const i=this.attributes.filter(l=>l.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:e,type:rt(r.name,this.schema)},s=ce(r,"addNodeView",o);if(!s)return[];const a=(l,c,u,h,p)=>{const f=Ml(l,i);return s()({node:l,view:c,getPos:u,decorations:h,innerDecorations:p,editor:e,extension:r,HTMLAttributes:f})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var n;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Aa(e.name,this.schema)};e.type==="mark"&&(!((n=_e(ce(e,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(e.name);const i=ce(e,"onBeforeCreate",r),o=ce(e,"onCreate",r),s=ce(e,"onUpdate",r),a=ce(e,"onSelectionUpdate",r),l=ce(e,"onTransaction",r),c=ce(e,"onFocus",r),u=ce(e,"onBlur",r),h=ce(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),s&&this.editor.on("update",s),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),h&&this.editor.on("destroy",h)})}}class ht{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=_e(ce(this,"addOptions",{name:this.name}))),this.storage=_e(ce(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ht(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>zs(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new ht({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=_e(ce(n,"addOptions",{name:n.name})),n.storage=_e(ce(n,"addStorage",{name:n.name,options:n.options})),n}}function oy(t,e,n){const{from:r,to:i}=e,{blockSeparator:o=` 422 423`,textSerializers:s={}}=n||{};let a="";return t.nodesBetween(r,i,(l,c,u,h)=>{var p;l.isBlock&&c>r&&(a+=o);const f=s==null?void 0:s[l.type.name];if(f)return u&&(a+=f({node:l,pos:c,parent:u,index:h,range:e})),!1;l.isText&&(a+=(p=l==null?void 0:l.text)===null||p===void 0?void 0:p.slice(Math.max(r,c)-c,i-c))}),a}function sy(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}const KM=ht.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ct({key:new tn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(u=>u.$from.pos)),a=Math.max(...o.map(u=>u.$to.pos)),l=sy(n);return oy(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),YM=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),JM=(t=!1)=>({commands:e})=>e.setContent("",t),GM=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:o,$to:s})=>{t.doc.nodesBetween(o.pos,s.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:u}=e,h=c.resolve(u.map(l)),p=c.resolve(u.map(l+a.nodeSize)),f=h.blockRange(p);if(!f)return;const m=Gr(f);if(a.type.isTextblock){const{defaultType:g}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(f.start,g)}(m||m===0)&&e.lift(f,m)})}),!0},QM=t=>e=>t(e),XM=()=>({state:t,dispatch:e})=>xM(t,e),ZM=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,o=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new Se(r.doc.resolve(Math.max(s-1,0)))),!0},e2=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){const a=i.before(o),l=i.after(o);t.delete(a,l).scrollIntoView()}return!0}return!1},t2=t=>({tr:e,state:n,dispatch:r})=>{const i=rt(t,n.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){const l=o.before(s),c=o.after(s);e.delete(l,c).scrollIntoView()}return!0}return!1},n2=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},r2=()=>({state:t,dispatch:e})=>sM(t,e),i2=()=>({commands:t})=>t.keyboardShortcut("Enter"),o2=()=>({state:t,dispatch:e})=>yM(t,e);function rs(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Nc(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function ay(t,e,n={}){return t.find(r=>r.type===e&&rs(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function fh(t,e,n={}){return!!ay(t,e,n)}function jc(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(n=n||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!ay([...i.node.marks],e,n)))return;let s=i.index,a=t.start()+i.offset,l=s+1,c=a+i.node.nodeSize;for(;s>0&&fh([...t.parent.child(s-1).marks],e,n);)s-=1,a-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&fh([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function Wn(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}const s2=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const o=Wn(t,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){const h=jc(l,o,e);if(h&&h.from<=c&&h.to>=u){const p=Se.create(s,h.from,h.to);n.setSelection(p)}}return!0},a2=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function ly(t){return t instanceof Se}function Zn(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function cy(t,e=null){if(!e)return null;const n=Te.atStart(t),r=Te.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,o=r.to;return e==="all"?Se.create(t,Zn(0,i,o),Zn(t.content.size,i,o)):Se.create(t,Zn(e,i,o),Zn(e,i,o))}function ph(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function is(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function l2(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const c2=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(is()||ph())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),l2()&&!is()&&!ph()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!ly(n.state.selection))return s(),!0;const a=cy(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},u2=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),d2=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),uy=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&uy(r)}return t};function xo(t){const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return uy(n)}function Li(t,e,n){if(t instanceof jn||t instanceof q)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return q.fromArray(t.map(a=>e.nodeFromJSON(a)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),Li("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,a="";const l=new Qm({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Ir.fromSchema(l).parseSlice(xo(t),n.parseOptions):Ir.fromSchema(l).parse(xo(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=Ir.fromSchema(e);return n.slice?o.parseSlice(xo(t),n.parseOptions).content:o.parse(xo(t),n.parseOptions)}return Li("",e,n)}function h2(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ye||i instanceof tt))return;const o=t.mapping.maps[r];let s=0;o.forEach((a,l,c,u)=>{s===0&&(s=u)}),t.setSelection(Te.near(t.doc.resolve(s),n))}const f2=t=>!("type"in t),p2=(t,e,n)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const l=x=>{o.emit("contentError",{editor:o,error:x,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{Li(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(x){l(x)}try{a=Li(e,o.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(x){return l(x),!1}let{from:u,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,f=!0;if((f2(a)?a:[a]).forEach(x=>{x.check(),p=p?x.isText&&x.marks.length===0:!1,f=f?x.isBlock:!1}),u===h&&f){const{parent:x}=r.doc.resolve(u);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(u-=1,h+=1)}let g;if(p){if(Array.isArray(e))g=e.map(x=>x.text||"").join("");else if(e instanceof q){let x="";e.forEach(b=>{b.text&&(x+=b.text)}),g=x}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,h)}else g=a,r.replaceWith(u,h,g);n.updateSelection&&h2(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},m2=()=>({state:t,dispatch:e})=>fM(t,e),g2=()=>({state:t,dispatch:e})=>pM(t,e),y2=()=>({state:t,dispatch:e})=>aM(t,e),x2=()=>({state:t,dispatch:e})=>dM(t,e),b2=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ms(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},w2=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ms(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},v2=()=>({state:t,dispatch:e})=>lM(t,e),k2=()=>({state:t,dispatch:e})=>cM(t,e);function dy(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function S2(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,o,s;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))is()||dy()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const C2=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const o=S2(t).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l==null||l.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Bi(t,e,n={}){const{from:r,to:i,empty:o}=t.selection,s=e?rt(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,(h,p)=>{if(h.isText)return;const f=Math.max(r,p),m=Math.min(i,p+h.nodeSize);a.push({node:h,from:f,to:m})});const l=i-r,c=a.filter(h=>s?s.name===h.node.type.name:!0).filter(h=>rs(h.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((h,p)=>h+p.to-p.from,0)>=l}const E2=(t,e={})=>({state:n,dispatch:r})=>{const i=rt(t,n.schema);return Bi(n,i,e)?mM(n,r):!1},T2=()=>({state:t,dispatch:e})=>bM(t,e),_2=t=>({state:e,dispatch:n})=>{const r=rt(t,e.schema);return AM(r)(e,n)},A2=()=>({state:t,dispatch:e})=>gM(t,e);function Fs(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function mh(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const M2=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Fs(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=rt(t,r.schema)),a==="mark"&&(s=Wn(t,r.schema)),i&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,u)=>{o&&o===c.type&&n.setNodeMarkup(u,void 0,mh(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(h=>{s===h.type&&n.addMark(u,u+c.nodeSize,s.create(mh(h.attrs,e)))})})}),!0):!1},N2=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),j2=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ut(t.doc);t.setSelection(n)}return!0},I2=()=>({state:t,dispatch:e})=>uM(t,e),R2=()=>({state:t,dispatch:e})=>hM(t,e),O2=()=>({state:t,dispatch:e})=>wM(t,e),P2=()=>({state:t,dispatch:e})=>SM(t,e),D2=()=>({state:t,dispatch:e})=>kM(t,e);function Nl(t,e,n={},r={}){return Li(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const L2=(t,e=!1,n={},r={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{var l,c;const{doc:u}=o;if(n.preserveWhitespace!=="full"){const h=Nl(t,i.schema,n,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:i.options.enableContentCheck});return s&&o.replaceWith(0,u.content.size,h).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:u.content.size},t,{parseOptions:n,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function hy(t,e){const n=Wn(e,t.schema),{from:r,to:i,empty:o}=t.selection,s=[];o?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{s.push(...l.marks)});const a=s.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function B2(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function z2(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Ic(t){return e=>z2(e.$from,t)}function F2(t,e){const n={from:0,to:t.content.size};return oy(t,n,e)}function $2(t,e){const n=rt(e,t.schema),{from:r,to:i}=t.selection,o=[];t.doc.nodesBetween(r,i,a=>{o.push(a)});const s=o.reverse().find(a=>a.type.name===n.name);return s?{...s.attrs}:{}}function V2(t,e){const n=Fs(typeof e=="string"?e:e.name,t.schema);return n==="node"?$2(t,e):n==="mark"?hy(t,e):{}}function fy(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=n.resolve(t),s=jc(o,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,o)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}function Oo(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function jl(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?Wn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>o?o.name===h.type.name:!0).find(h=>rs(h.attrs,n,{strict:!1}));let s=0;const a=[];if(i.forEach(({$from:h,$to:p})=>{const f=h.pos,m=p.pos;t.doc.nodesBetween(f,m,(g,x)=>{if(!g.isText&&!g.marks.length)return;const b=Math.max(f,x),E=Math.min(m,x+g.nodeSize),v=E-b;s+=v,a.push(...g.marks.map(A=>({mark:A,from:b,to:E})))})}),s===0)return!1;const l=a.filter(h=>o?o.name===h.mark.type.name:!0).filter(h=>rs(h.mark.attrs,n,{strict:!1})).reduce((h,p)=>h+p.to-p.from,0),c=a.filter(h=>o?h.mark.type!==o&&h.mark.type.excludes(o):!0).reduce((h,p)=>h+p.to-p.from,0);return(l>0?l+c:l)>=s}function W2(t,e,n={}){if(!e)return Bi(t,null,n)||jl(t,null,n);const r=Fs(e,t.schema);return r==="node"?Bi(t,e,n):r==="mark"?jl(t,e,n):!1}function gh(t,e){const{nodeExtensions:n}=Ls(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=_e(ce(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function $s(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!==null&&r!==void 0?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(o=>{i!==!1&&($s(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function H2(t){return t instanceof ye}function q2(t,e,n){var r;const{selection:i}=e;let o=null;if(ly(i)&&(o=i.$cursor),o){const a=(r=t.storedMarks)!==null&&r!==void 0?r:o.marks();return!!n.isInSet(a)||!a.some(l=>l.type.excludes(n))}const{ranges:s}=i;return s.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(u,h,p)=>{if(c)return!1;if(u.isInline){const f=!p||p.type.allowsMarkType(n),m=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=f&&m}return!c}),c})}const U2=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=Wn(t,r.schema);if(i)if(s){const c=hy(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const u=c.$from.pos,h=c.$to.pos;r.doc.nodesBetween(u,h,(p,f)=>{const m=Math.max(f,u),g=Math.min(f+p.nodeSize,h);p.marks.find(b=>b.type===l)?p.marks.forEach(b=>{l===b.type&&n.addMark(m,g,l.create({...b.attrs,...e}))}):n.addMark(m,g,l.create(e))})});return q2(r,n,l)},K2=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Y2=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const o=rt(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:a})=>ch(o,{...s,...e})(n)?!0:a.clearNodes()).command(({state:a})=>ch(o,{...s,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},J2=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Zn(t,0,r.content.size),o=ye.create(r,i);e.setSelection(o)}return!0},G2=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,s=Se.atStart(r).from,a=Se.atEnd(r).to,l=Zn(i,s,a),c=Zn(o,s,a),u=Se.create(r,l,c);e.setSelection(u)}return!0},Q2=t=>({state:e,dispatch:n})=>{const r=rt(t,e.schema);return jM(r)(e,n)};function yh(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const X2=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=e,{$from:a,$to:l}=o,c=i.extensionManager.attributes,u=Oo(c,a.node().type.name,a.node().attrs);if(o instanceof ye&&o.node.isBlock)return!a.parentOffset||!Rr(s,a.pos)?!1:(r&&(t&&yh(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const h=l.parentOffset===l.parent.content.size,p=a.depth===0?void 0:B2(a.node(-1).contentMatchAt(a.indexAfter(-1)));let f=h&&p?[{type:p,attrs:u}]:void 0,m=Rr(e.doc,e.mapping.map(a.pos),1,f);if(!f&&!m&&Rr(e.doc,e.mapping.map(a.pos),1,p?[{type:p}]:void 0)&&(m=!0,f=p?[{type:p,attrs:u}]:void 0),r){if(m&&(o instanceof Se&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,f),p&&!h&&!a.parentOffset&&a.parent.type!==p)){const g=e.mapping.map(a.before()),x=e.doc.resolve(g);a.node(-1).canReplaceWith(x.index(),x.index()+1,p)&&e.setNodeMarkup(e.mapping.map(a.before()),p)}t&&yh(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},Z2=(t,e={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=rt(t,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const h=l.node(-1);if(h.type!==a)return!1;const p=o.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let b=q.empty;const E=l.index(-1)?1:l.index(-2)?2:3;for(let M=l.depth-E;M>=l.depth-3;M-=1)b=q.from(l.node(M).copy(b));const v=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,A={...Oo(p,l.node().type.name,l.node().attrs),...e},_=((s=a.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(A))||void 0;b=b.append(q.from(a.createAndFill(null,_)||void 0));const S=l.before(l.depth-(E-1));n.replace(S,l.after(-v),new oe(b,4-E,0));let N=-1;n.doc.nodesBetween(S,n.doc.content.size,(M,L)=>{if(N>-1)return!1;M.isTextblock&&M.content.size===0&&(N=L+1)}),N>-1&&n.setSelection(Se.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const f=c.pos===l.end()?h.contentMatchAt(0).defaultType:null,m={...Oo(p,h.type.name,h.attrs),...e},g={...Oo(p,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const x=f?[{type:a,attrs:m},{type:f,attrs:g}]:[{type:a,attrs:m}];if(!Rr(n.doc,l.pos,2))return!1;if(i){const{selection:b,storedMarks:E}=r,{splittableMarks:v}=o.extensionManager,A=E||b.$to.parentOffset&&b.$from.marks();if(n.split(l.pos,2,x).scrollIntoView(),!A||!i)return!0;const _=A.filter(S=>v.includes(S.type.name));n.ensureMarks(_)}return!0},Ma=(t,e)=>{const n=Ic(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&$n(t.doc,n.pos)&&t.join(n.pos),!0},Na=(t,e)=>{const n=Ic(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&$n(t.doc,r)&&t.join(r),!0},eN=(t,e,n,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:h,splittableMarks:p}=i.extensionManager,f=rt(t,s.schema),m=rt(e,s.schema),{selection:g,storedMarks:x}=s,{$from:b,$to:E}=g,v=b.blockRange(E),A=x||g.$to.parentOffset&&g.$from.marks();if(!v)return!1;const _=Ic(S=>gh(S.type.name,h))(g);if(v.depth>=1&&_&&v.depth-_.depth<=1){if(_.node.type===f)return c.liftListItem(m);if(gh(_.node.type.name,h)&&f.validContent(_.node.content)&&a)return l().command(()=>(o.setNodeMarkup(_.pos,f),!0)).command(()=>Ma(o,f)).command(()=>Na(o,f)).run()}return!n||!A||!a?l().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>Ma(o,f)).command(()=>Na(o,f)).run():l().command(()=>{const S=u().wrapInList(f,r),N=A.filter(M=>p.includes(M.type.name));return o.ensureMarks(N),S?!0:c.clearNodes()}).wrapInList(f,r).command(()=>Ma(o,f)).command(()=>Na(o,f)).run()},tN=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=Wn(t,r.schema);return jl(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},nN=(t,e,n={})=>({state:r,commands:i})=>{const o=rt(t,r.schema),s=rt(e,r.schema),a=Bi(r,o,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(s,l):i.setNode(o,{...l,...n})},rN=(t,e={})=>({state:n,commands:r})=>{const i=rt(t,n.schema);return Bi(n,i,e)?r.lift(i):r.wrapIn(i,e)},iN=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let o;if(i.spec.isInputRules&&(o=i.getState(t))){if(e){const s=t.tr,a=o.transform;for(let l=a.steps.length-1;l>=0;l-=1)s.step(a.steps[l].invert(a.docs[l]));if(o.text){const l=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,t.schema.text(o.text,l))}else s.delete(o.from,o.to)}return!0}}return!1},oN=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},sN=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=Wn(t,r.schema),{$from:c,empty:u,ranges:h}=a;if(!i)return!0;if(u&&s){let{from:p,to:f}=a;const m=(o=c.marks().find(x=>x.type===l))===null||o===void 0?void 0:o.attrs,g=jc(c,l,m);g&&(p=g.from,f=g.to),n.removeMark(p,f,l)}else h.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,l)});return n.removeStoredMark(l),!0},aN=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Fs(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=rt(t,r.schema)),a==="mark"&&(s=Wn(t,r.schema)),i&&n.selection.ranges.forEach(l=>{const c=l.$from.pos,u=l.$to.pos;let h,p,f,m;n.selection.empty?r.doc.nodesBetween(c,u,(g,x)=>{o&&o===g.type&&(f=Math.max(x,c),m=Math.min(x+g.nodeSize,u),h=x,p=g)}):r.doc.nodesBetween(c,u,(g,x)=>{x<c&&o&&o===g.type&&(f=Math.max(x,c),m=Math.min(x+g.nodeSize,u),h=x,p=g),x>=c&&x<=u&&(o&&o===g.type&&n.setNodeMarkup(x,void 0,{...g.attrs,...e}),s&&g.marks.length&&g.marks.forEach(b=>{if(s===b.type){const E=Math.max(x,c),v=Math.min(x+g.nodeSize,u);n.addMark(E,v,s.create({...b.attrs,...e}))}}))}),p&&(h!==void 0&&n.setNodeMarkup(h,void 0,{...p.attrs,...e}),s&&p.marks.length&&p.marks.forEach(g=>{s===g.type&&n.addMark(f,m,s.create({...g.attrs,...e}))}))}),!0):!1},lN=(t,e={})=>({state:n,dispatch:r})=>{const i=rt(t,n.schema);return CM(i,e)(n,r)},cN=(t,e={})=>({state:n,dispatch:r})=>{const i=rt(t,n.schema);return EM(i,e)(n,r)};var uN=Object.freeze({__proto__:null,blur:YM,clearContent:JM,clearNodes:GM,command:QM,createParagraphNear:XM,cut:ZM,deleteCurrentNode:e2,deleteNode:t2,deleteRange:n2,deleteSelection:r2,enter:i2,exitCode:o2,extendMarkRange:s2,first:a2,focus:c2,forEach:u2,insertContent:d2,insertContentAt:p2,joinBackward:y2,joinDown:g2,joinForward:x2,joinItemBackward:b2,joinItemForward:w2,joinTextblockBackward:v2,joinTextblockForward:k2,joinUp:m2,keyboardShortcut:C2,lift:E2,liftEmptyBlock:T2,liftListItem:_2,newlineInCode:A2,resetAttributes:M2,scrollIntoView:N2,selectAll:j2,selectNodeBackward:I2,selectNodeForward:R2,selectParentNode:O2,selectTextblockEnd:P2,selectTextblockStart:D2,setContent:L2,setMark:U2,setMeta:K2,setNode:Y2,setNodeSelection:J2,setTextSelection:G2,sinkListItem:Q2,splitBlock:X2,splitListItem:Z2,toggleList:eN,toggleMark:tN,toggleNode:nN,toggleWrap:rN,undoInputRule:iN,unsetAllMarks:oN,unsetMark:sN,updateAttributes:aN,wrapIn:lN,wrapInList:cN});const dN=ht.create({name:"commands",addCommands(){return{...uN}}}),hN=ht.create({name:"drop",addProseMirrorPlugins(){return[new Ct({key:new tn("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),fN=ht.create({name:"editable",addProseMirrorPlugins(){return[new Ct({key:new tn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),pN=new tn("focusEvents"),mN=ht.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ct({key:pN,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),gN=ht.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:u,$anchor:h}=l,{pos:p,parent:f}=h,m=h.parent.isTextblock&&p>0?a.doc.resolve(p-1):h,g=m.parent.type.spec.isolating,x=h.pos-h.parentOffset,b=g&&m.parent.childCount===1?x===h.pos:Te.atStart(c).from===p;return!u||!f.type.isTextblock||f.textContent.length||!b||b&&h.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return is()||dy()?o:i},addProseMirrorPlugins(){return[new Ct({key:new tn("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),i=t.some(g=>g.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:s,to:a}=e.selection,l=Te.atStart(e.doc).from,c=Te.atEnd(e.doc).to;if(o||!(s===l&&a===c)||!$s(n.doc))return;const p=n.tr,f=Ps({state:n,transaction:p}),{commands:m}=new Ds({editor:this.editor,state:f});if(m.clearNodes(),!!p.steps.length)return p}})]}}),yN=ht.create({name:"paste",addProseMirrorPlugins(){return[new Ct({key:new tn("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),xN=ht.create({name:"tabindex",addProseMirrorPlugins(){return[new Ct({key:new tn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Jn{get name(){return this.node.type.name}constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You canât set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Jn(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Jn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Jn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,s=this.pos+r+(o?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(s);if(!i&&a.depth<=this.depth)return;const l=new Jn(a,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new Jn(a,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const o=i.node.attrs,s=Object.keys(n);for(let a=0;a<s.length;a+=1){const l=s[a];if(o[l]!==n[l])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const o=Object.keys(n);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&o.every(l=>n[l]===s.node.attrs[l])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}}const bN=`.ProseMirror { 424 position: relative; 425} 426 427.ProseMirror { 428 word-wrap: break-word; 429 white-space: pre-wrap; 430 white-space: break-spaces; 431 -webkit-font-variant-ligatures: none; 432 font-variant-ligatures: none; 433 font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ 434} 435 436.ProseMirror [contenteditable="false"] { 437 white-space: normal; 438} 439 440.ProseMirror [contenteditable="false"] [contenteditable="true"] { 441 white-space: pre-wrap; 442} 443 444.ProseMirror pre { 445 white-space: pre-wrap; 446} 447 448img.ProseMirror-separator { 449 display: inline !important; 450 border: none !important; 451 margin: 0 !important; 452 width: 0 !important; 453 height: 0 !important; 454} 455 456.ProseMirror-gapcursor { 457 display: none; 458 pointer-events: none; 459 position: absolute; 460 margin: 0; 461} 462 463.ProseMirror-gapcursor:after { 464 content: ""; 465 display: block; 466 position: absolute; 467 top: -2px; 468 width: 20px; 469 border-top: 1px solid black; 470 animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; 471} 472 473@keyframes ProseMirror-cursor-blink { 474 to { 475 visibility: hidden; 476 } 477} 478 479.ProseMirror-hideselection *::selection { 480 background: transparent; 481} 482 483.ProseMirror-hideselection *::-moz-selection { 484 background: transparent; 485} 486 487.ProseMirror-hideselection * { 488 caret-color: transparent; 489} 490 491.ProseMirror-focused .ProseMirror-gapcursor { 492 display: block; 493} 494 495.tippy-box[data-animation=fade][data-state=hidden] { 496 opacity: 0 497}`;function wN(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}class vN extends IM{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:i})=>this.options.onDrop(n,r,i)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=wN(bN,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,n){const r=iy(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const n=this.state.plugins;let r=n;if([].concat(e).forEach(o=>{const s=typeof o=="string"?`${o}$`:o.key;r=r.filter(a=>!a.key.startsWith(s))}),n.length===r.length)return;const i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,n;const i=[...this.options.enableCoreExtensions?[fN,KM.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),dN,mN,gN,xN,hN,yN].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new _r(i,this)}createCommandManager(){this.commandManager=new Ds({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let n;try{n=Nl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),n=Nl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=cy(n,this.options.autofocus);this.view=new Jg(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:Tr.create({doc:n,selection:r||void 0})});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(s=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(s)});return}const n=this.state.apply(e),r=!this.state.selection.eq(n.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:n}),this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return V2(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,i=typeof e=="string"?n:e;return W2(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Mc(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=` 498 499`,textSerializers:r={}}=e||{};return F2(this.state.doc,{blockSeparator:n,textSerializers:{...sy(this.schema),...r}})}get isEmpty(){return $s(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e);return new Jn(n,this)}get $doc(){return this.$pos(0)}}function Wr(t){return new Bs({find:t.find,handler:({state:e,range:n,match:r})=>{const i=_e(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:o}=e,s=r[r.length-1],a=r[0];if(s){const l=a.search(/\S/),c=n.from+a.indexOf(s),u=c+s.length;if(fy(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(g=>g===t.type&&g!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+l,c);const p=n.from+l+s.length;o.addMark(n.from+l,p,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}function kN(t){return new Bs({find:t.find,handler:({state:e,range:n,match:r})=>{const i=_e(t.getAttributes,void 0,r)||{},{tr:o}=e,s=n.from;let a=n.to;const l=t.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=s+c;u>a?u=a:a=u+r[1].length;const h=r[0][r[0].length-1];o.insertText(h,s+r[0].length-1),o.replaceWith(u,a,l)}else if(r[0]){const c=t.type.isInline?s:s-1;o.insert(c,t.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()}})}function Il(t){return new Bs({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),o=_e(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)}})}function zi(t){return new Bs({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const o=_e(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),c=l&&gc(l,t.type,o);if(!c)return null;if(s.wrap(l,c),t.keepMarks&&t.editor){const{selection:h,storedMarks:p}=e,{splittableMarks:f}=t.editor.extensionManager,m=p||h.$to.parentOffset&&h.$from.marks();if(m){const g=m.filter(x=>f.includes(x.type.name));s.ensureMarks(g)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(h,o).run()}const u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&$n(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&s.join(n.from-1)}})}let nn=class Rl{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=_e(ce(this,"addOptions",{name:this.name}))),this.storage=_e(ce(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Rl(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>zs(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new Rl(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=_e(ce(n,"addOptions",{name:n.name})),n.storage=_e(ce(n,"addStorage",{name:n.name,options:n.options})),n}};function Hr(t){return new $M({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const o=_e(t.getAttributes,void 0,r,i);if(o===!1||o===null)return null;const{tr:s}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const u=l.search(/\S/),h=n.from+l.indexOf(a),p=h+a.length;if(fy(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(x=>x===t.type&&x!==m.mark.type)).filter(m=>m.to>h).length)return null;p<n.to&&s.delete(p,n.to),h>n.from&&s.delete(n.from+u,h),c=n.from+u+a.length,s.addMark(n.from+u,c,t.type.create(o||{})),s.removeStoredMark(t.type)}}})}function SN(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof ye){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let i=r.depth;for(;i>=0;){const o=r.index(i);if(r.node(i).contentMatchAt(o).matchType(e))return!0;
499i-=1}return!1}function CN(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var py={exports:{}},ja={};/** 500 * @license React 501 * use-sync-external-store-shim.production.min.js 502 * 503 * Copyright (c) Facebook, Inc. and its affiliates. 504 * 505 * This source code is licensed under the MIT license found in the 506 * LICENSE file in the root directory of this source tree. 507 */var xh;function EN(){if(xh)return ja;xh=1;var t=Y;function e(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function a(h,p){var f=p(),m=r({inst:{value:f,getSnapshot:p}}),g=m[0].inst,x=m[1];return o(function(){g.value=f,g.getSnapshot=p,l(g)&&x({inst:g})},[h,f,p]),i(function(){return l(g)&&x({inst:g}),h(function(){l(g)&&x({inst:g})})},[h]),s(f),f}function l(h){var p=h.getSnapshot;h=h.value;try{var f=p();return!n(h,f)}catch{return!0}}function c(h,p){return p()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return ja.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,ja}py.exports=EN();var Rc=py.exports;const TN=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},_N=({contentComponent:t})=>{const e=Rc.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return Y.createElement(Y.Fragment,null,Object.values(e))};function AN(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:cf.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}class MN extends Y.Component{constructor(e){var n;super(e),this.editorContentRef=Y.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((n=e.editor)===null||n===void 0)&&n.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.options.element.childNodes),e.setOptions({element:n}),e.contentComponent=AN(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const e=this.props.editor;if(!e||(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!e.options.element.firstChild))return;const n=document.createElement("div");n.append(...e.options.element.childNodes),e.setOptions({element:n})}render(){const{editor:e,innerRef:n,...r}=this.props;return Y.createElement(Y.Fragment,null,Y.createElement("div",{ref:TN(n,this.editorContentRef),...r}),(e==null?void 0:e.contentComponent)&&Y.createElement(_N,{contentComponent:e.contentComponent}))}}const NN=y.forwardRef((t,e)=>{const n=Y.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Y.createElement(MN,{key:n,innerRef:e,...t})}),jN=Y.memo(NN);var IN=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(o=Object.keys(e),r=o.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;i--!==0;){var s=o[i];if(!(s==="_owner"&&e.$$typeof)&&!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n},RN=CN(IN),my={exports:{}},Ia={};/** 508 * @license React 509 * use-sync-external-store-shim/with-selector.production.min.js 510 * 511 * Copyright (c) Facebook, Inc. and its affiliates. 512 * 513 * This source code is licensed under the MIT license found in the 514 * LICENSE file in the root directory of this source tree. 515 */var bh;
515function ON(){if(bh)return Ia;bh=1;var t=Y,e=Rc;function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,o=t.useRef,s=t.useEffect,a=t.useMemo,l=t.useDebugValue;return Ia.useSyncExternalStoreWithSelector=function(c,u,h,p,f){var m=o(null);if(m.current===null){var g={hasValue:!1,value:null};m.current=g}else g=m.current;m=a(function(){function b(S){if(!E){if(E=!0,v=S,S=p(S),f!==void 0&&g.hasValue){var N=g.value;if(f(N,S))return A=N}return A=S}if(N=A,r(v,S))return N;var M=p(S);return f!==void 0&&f(N,M)?N:(v=S,A=M)}var E=!1,v,A,_=h===void 0?null:h;return[function(){return b(u())},_===null?void 0:function(){return b(_())}]},[u,h,p,f]);var x=i(c,m[0],m[1]);return s(function(){g.hasValue=!0,g.value=x},[x]),l(x),x},Ia}my.exports=ON();var PN=my.exports;const DN=typeof window<"u"?y.useLayoutEffect:y.useEffect;class LN{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(i=>i())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function BN(t){var e;const[n]=y.useState(()=>new LN(t.editor)),r=PN.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:RN);return DN(()=>n.watch(t.editor),[t.editor,n]),y.useDebugValue(r),r}const zN=!1,Ol=typeof window>"u",FN=Ol||!!(typeof window<"u"&&window.next);class Oc{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Ol||FN?null:this.createEditor();if(this.options.current.immediatelyRender&&Ol&&zN)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,o;return(o=(i=this.options.current).onBeforeCreate)===null||o===void 0?void 0:o.call(i,...r)},onBlur:(...r)=>{var i,o;return(o=(i=this.options.current).onBlur)===null||o===void 0?void 0:o.call(i,...r)},onCreate:(...r)=>{var i,o;return(o=(i=this.options.current).onCreate)===null||o===void 0?void 0:o.call(i,...r)},onDestroy:(...r)=>{var i,o;return(o=(i=this.options.current).onDestroy)===null||o===void 0?void 0:o.call(i,...r)},onFocus:(...r)=>{var i,o;return(o=(i=this.options.current).onFocus)===null||o===void 0?void 0:o.call(i,...r)},onSelectionUpdate:(...r)=>{var i,o;return(o=(i=this.options.current).onSelectionUpdate)===null||o===void 0?void 0:o.call(i,...r)},onTransaction:(...r)=>{var i,o;return(o=(i=this.options.current).onTransaction)===null||o===void 0?void 0:o.call(i,...r)}
515,onUpdate:(...r)=>{var i,o;return(o=(i=this.options.current).onUpdate)===null||o===void 0?void 0:o.call(i,...r)},onContentError:(...r)=>{var i,o;return(o=(i=this.options.current).onContentError)===null||o===void 0?void 0:o.call(i,...r)},onDrop:(...r)=>{var i,o;return(o=(i=this.options.current).onDrop)===null||o===void 0?void 0:o.call(i,...r)},onPaste:(...r)=>{var i,o;return(o=(i=this.options.current).onPaste)===null||o===void 0?void 0:o.call(i,...r)}};return new vN(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,o)=>{var s;return i===((s=n.extensions)===null||s===void 0?void 0:s[o])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Oc.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function $N(t={},e=[]){const n=y.useRef(t);n.current=t;const[r]=y.useState(()=>new Oc(n)),i=Rc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return y.useDebugValue(i),y.useEffect(r.onRender(e)),BN({editor:i,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),i}const VN=y.createContext({editor:null});VN.Consumer;const WN=y.createContext({onDragStart:void 0}),HN=()=>y.useContext(WN);Y.forwardRef((t,e)=>{const{onDragStart:n}=HN(),r=t.as||"div";return Y.createElement(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});const qN=/^\s*>\s$/,UN=nn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",yt(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}}
vendor: 1,036 bytes, line 515
515,addInputRules(){return[zi({find:qN,type:this.type})]}}),KN=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,YN=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,JN=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,GN=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,QN=bn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",yt(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Wr({find:KN,type:this.type}),Wr({find:JN,type:this.t
vendor: 8,703 bytes, lines 515-518
515ype})]},addPasteRules(){return[Hr({find:YN,type:this.type}),Hr({find:GN,type:this.type})]}}),XN="listItem",wh="textStyle",vh=/^\s*([-+*])\s$/,ZN=nn.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",yt(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(XN,this.editor.getAttributes(wh)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=zi({find:vh,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=zi({find:vh,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(wh),editor:this.editor})),[t]}}),ej=/(^|[^`])`([^`]+)`(?!`)/,tj=/(^|[^`])`([^`]+)`(?!`)/g,nj=bn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",yt(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Wr({find:ej,type:this.type})]},addPasteRules(){return[Hr({find:tj,type:this.type})]}}),rj=/^```([a-z]+)?[\s\n]$/,ij=/^~~~([a-z]+)?[\s\n]$/,oj=nn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,o=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",yt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(` 516 517`);return!o||!s?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:o}=n;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const a=i.after();return a===void 0?!1:r.nodeAt(a)?t.commands.command(({tr:c})=>(c.setSelection(Te.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[Il({find:rj,type:this.type,getAttributes:t=>({language:t[1]})}),Il({find:ij,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ct({key:new tn("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i==null?void 0:i.mode;if(!n||!o)return!1;const{tr:s,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,` 518`));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(Se.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),sj=nn.create({name:"doc",topNode:!0,content:"block+"});function aj(t={}){return new Ct({view(e){return new lj(e,t)}})}class lj{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,a=o.height/i.offsetHeight;if(n){let h=e.nodeBefore,p=e.nodeAfter;if(h||p){let f=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(f){let m=f.getBoundingClientRect(),g=h?m.bottom:m.top;h&&p&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*a;r={left:m.left,right:m.right,top:g-x,bottom:g+x}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:h.left-p,right:h.left+p,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let h=l.getBoundingClientRect(),p=h.width/l.offsetWidth,f=h.height/l.offsetHeight;c=h.left-l.scrollLeft*p,u=h.top-l.scrollTop*f}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!o){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=lg(this.editorView.state.doc,s,this.editorView.dragging.slice);a!=null&&(s=a)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const cj=ht.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[aj(this.options)]}});class qe extends Te{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return qe.valid(r)?new qe(r):Te.near(r)}content(){return oe.empty}eq(e){return e instanceof qe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new qe(e.resolve(n.pos))}getBookmark(){return new Pc(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!uj(e)||!dj(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&qe.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let a=e.node(s);if(n>0?e.indexAfter(s)<a.childCount:e.index(s)>0){o=a.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let l=e.doc.resolve(i);if(qe.valid(l))return l}for(;;){let s=n>0?o.firstChild:o.lastChild;
518if(!s){if(o.isAtom&&!o.isText&&!ye.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=s,i+=n;let a=e.doc.resolve(i);if(qe.valid(a))return a}return null}}}qe.prototype.visible=!1;qe.findFrom=qe.findGapCursorFrom;Te.jsonID("gapcursor",qe);class Pc{constructor(e){this.pos=e}map(e){return new Pc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return qe.valid(n)?new qe(n):Te.near(n)}}function gy(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function uj(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||gy(i.type))return!0;if(i.inlineContent)return!1}}return!0}function dj(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||gy(i.type))return!0;if(i.inlineContent)return!1}}return!0}function hj(){return new Ct({props:{decorations:gj,createSelectionBetween(t,e,n){return e.pos==n.pos&&qe.valid(n)?new qe(n):null}
vendor: 3,514 bytes, lines 518-519
518,handleClick:pj,handleKeyDown:fj,handleDOMEvents:{beforeinput:mj}}})}const fj=Gg({ArrowLeft:bo("horiz",-1),ArrowRight:bo("horiz",1),ArrowUp:bo("vert",-1),ArrowDown:bo("vert",1)});function bo(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,a=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Se){if(!o.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=qe.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new qe(c))),!0):!1}}function pj(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!qe.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&ye.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new qe(r))),!0)}function mj(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof qe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=q.empty;for(let s=r.length-1;s>=0;s--)i=q.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new oe(i,0,0));return o.setSelection(Se.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function gj(t){if(!(t.selection instanceof qe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Je.create(t.doc,[Vt.widget(t.selection.head,e,{key:"gapcursor"})])}const yj=ht.create({name:"gapCursor",addProseMirrorPlugins(){return[hj()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=_e(ce(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),xj=nn.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",yt(this.options.HTMLAttributes,t)]},renderText(){return` 519`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:o}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:a}=r.extensionManager,l=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&s){const h=l.filter(p=>a.includes(p.type.name));c.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),bj=nn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,yt(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Il({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}}
519)\\s$`),type:this.type,getAttributes:{level:t}}))}});var ss=200,nt=function(){};nt.prototype.append=function(e){return e.length?(e=nt.from(e),!this.length&&e||e.length<ss&&this.leafAppend(e)||this.length<ss&&e.leafPrepend(this)||this.appendInner(e)):this};nt.prototype.prepend=function(e){return e.length?nt.from(e).append(this):this};nt.prototype.appendInner=function(e){return new wj(this,e)};nt.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?nt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};nt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};nt.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};nt.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},n,r),i};nt.from=function(e){return e instanceof nt?e:e&&e.length?new yy(e):nt.empty};var yy=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,a){for(var l=o;l<s;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,a){for(var l=o-1;l>=s;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ss)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ss)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(nt);nt.empty=new yy([]);var wj=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var a=this.left.length;if(i<a&&this.left.forEachInner(r,i,Math.min(o,a),s)===!1||o>a&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,o)-a,s+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(o,a)-a,s+a)===!1||o<a&&this.left.forEachInvertedInner(r,Math.min(i,a),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(nt);const vj=500;class en{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,a,l,c=[],u=[];return this.items.forEach((h,p)=>{if(!h.step){i||(i=this.remapping(r,p+1),o=i.maps.length),o--,u.push(h);return}if(i){u.push(new an(h.map));let f=h.step.map(i.slice(o)),m;f&&s.maybeStep(f).doc&&(m=s.mapping.maps[s.mapping.maps.length-1],c.push(new an(m,void 0,void 0,c.length+u.length))),o--,m&&i.appendMap(m,o)}else s.maybeStep(h.step);if(h.selection)return a=i?h.selection.map(i.slice(o)):h.selection,l=new en(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(e,n,r,i){let o=[],s=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let h=e.steps[u].invert(e.docs[u]),p=new an(e.mapping.maps[u],h,n),f;(f=l&&l.merge(p))&&(p=f,u?o.pop():a=a.slice(0,a.length-1)),o.push(p),n&&(s++,n=void 0),i||(l=p)}let c=s-r.depth;return c>Sj&&(a=kj(a,c),s-=c),new en(a.append(o),s)}remapping(e,n){let r=new Ii;
vendor: 1,061 bytes, line 519
519return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new en(this.items.append(e.map(n=>new an(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=e.mapping,s=e.steps.length,a=this.eventCount;this.items.forEach(p=>{p.selection&&a--},i);let l=n;this.items.forEach(p=>{let f=o.getMirror(--l);if(f==null)return;s=Math.min(s,f);let m=o.maps[f];if(p.step){let g=e.steps[f].invert(e.docs[f]),x=p.selection&&p.selection.map(o.slice(l+1,f));x&&a++,r.push(new an(m,g,x))}else r.push(new an(m))},i);let c=[];for(let p=n;p<s;p++)c.push(new an(o.maps[p]));let u=this.items.slice(0,i).append(c).append(r),h=new en(u,a);return h.emptyItemCount()>vj&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],o=0;return this.items.forEach((s,a)=>
vendor: 7,494 bytes, line 519
519{if(a>=e)i.push(s),s.selection&&o++;else if(s.step){let l=s.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=s.selection&&s.selection.map(n.slice(r));u&&o++;let h=new an(c.invert(),l,u),p,f=i.length-1;(p=i.length&&i[f].merge(h))?i[f]=p:i.push(h)}}else s.map&&r--},this.items.length,0),new en(nt.from(i.reverse()),o)}}en.empty=new en(nt.empty,0);function kj(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class an{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new an(n.getMap().invert(),n,this.selection)}}}class En{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const Sj=20;function Cj(t,e,n,r){let i=n.getMeta(sr),o;if(i)return i.historyState;n.getMeta(_j)&&(t=new En(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(sr))return s.getMeta(sr).redo?new En(t.done.addTransform(n,void 0,r,Po(e)),t.undone,kh(n.mapping.maps),t.prevTime,t.prevComposition):new En(t.done,t.undone.addTransform(n,void 0,r,Po(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Ej(n,t.prevRanges)),c=s?Ra(t.prevRanges,n.mapping):kh(n.mapping.maps);return new En(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,Po(e)),en.empty,c,n.time,a??t.prevComposition)}else return(o=n.getMeta("rebased"))?new En(t.done.rebased(n,o),t.undone.rebased(n,o),Ra(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new En(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Ra(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Ej(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(n=!0)}),n}function kh(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,o,s)=>e.push(o,s));return e}function Ra(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),o=e.map(t[r+1],-1);i<=o&&n.push(i,o)}return n}function Tj(t,e,n){let r=Po(e),i=sr.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),l=new En(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(sr,{redo:n,historyState:l})}let Oa=!1,Sh=null;function Po(t){let e=t.plugins;if(Sh!=e){Oa=!1,Sh=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Oa=!0;break}}return Oa}const sr=new tn("history"),_j=new tn("closeHistory");function Aj(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ct({key:sr,state:{init(){return new En(en.empty,en.empty,null,0,-1)},apply(e,n,r){return Cj(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?by:r=="historyRedo"?wy:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function xy(t,e){return(n,r)=>{let i=sr.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=Tj(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const by=xy(!1,!0),wy=xy(!0,!0),Mj=ht.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>by(t,e),redo:()=>({state:t,dispatch:e})=>wy(t,e)}},addProseMirrorPlugins(){return[Aj(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-Ñ":()=>this.editor.commands.undo(),"Shift-Mod-Ñ":()=>this.editor.commands.redo()}}}),Nj=nn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",yt(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!SN(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$from:r,$to:i}=n,o=t();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):H2(n)?o.insertContentAt(i.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:s,dispatch:a})=>{var l;if(a){const{$to:c}=s.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(Se.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(ye.create(s.doc,c.pos)):s.setSelection(Se.create(s.doc,c.pos));else{const h=(l=c.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();h&&(s.insert(u,h),s.setSelection(Se.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[kN({find:/^(?:---|â-|___\s|\*\*\*\s)$/,type:this.type})]}}),jj=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ij=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Rj=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Oj=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Pj=bn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",yt(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Wr({find:jj,type:this.type}),Wr({find:Rj,type:this.type})]},addPasteRules(){return[Hr({find:Ij,type:this.type}),Hr({find:Oj,type:this.type})]}}),Dj=nn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",yt(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Lj="listItem",Ch="textStyle",Eh=/^(\d+)\.\s$/,Bj=nn.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",yt(this.options.HTMLAttributes,n),0]:["ol",yt(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Lj,this.editor.getAttributes(Ch)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}}
vendor: 1,510 bytes, line 519
519,addInputRules(){let t=zi({find:Eh,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=zi({find:Eh,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Ch)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),zj=nn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",yt(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Fj=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,$j=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Vj=bn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",yt(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}}
519,addInputRules(){return[Wr({find:Fj,type:this.type})]},addPasteRules(){return[Hr({find:$j,type:this.type})]}}),Wj=nn.create({name:"text",group:"inline"}),Hj=ht.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(QN.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(UN.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(ZN.configure(this.options.bulletList)),this.options.code!==!1&&t.push(nj.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(oj.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(sj.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(cj.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(yj.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(xj.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(bj.configure(this.options.heading)),this.options.history!==!1&&t.push(Mj.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(Nj.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Pj.configure(this.options.italic)),this.options.listItem!==!1&&t.push(Dj.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(Bj.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(zj.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(Vj.configure(this.options.strike)),this.options.text!==!1&&t.push(Wj.configure(this.options.text)),t}}),qj=t=>{if(!t.children.length)return;const e=t.querySelectorAll("span");e&&e.forEach(n=>{var r,i;const o=n.getAttribute("style"),s=(i=(r=n.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||i===void 0?void 0:i.getAttribute("style");n.setAttribute("style",`${s};${o}`)})},Uj=bn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&qj(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",yt(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(o=>!!o))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Kj=ht.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something â¦",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Ct({key:new tn("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const o=this.editor.isEmpty;return t.descendants((s,a)=>{const l=r>=a&&r<=a+s.nodeSize,c=!s.isLeaf&&$s(s);if((l||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const h=Vt.node(a,a+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:a,hasAnchor:l}):this.options.placeholder});i.push(h)}return this.options.includeChildren}),Je.create(t,i)}}})]}}),Yj=String.raw`[\d.]+(?:px|pt|rem|em)`,fD=new RegExp(`\\{size:(${Yj})\\}`,"g");function Jj(t){const e=o=>o.tagName.toLowerCase()==="p"&&(/MsoListParagraph/i.test(o.className)||/mso-list:\s*l\d/i.test(o.getAttribute("style")??"")),n=Array.from(t.querySelectorAll("p")).filter(e);if(!n.length)return;const r=t.ownerDocument;let i=null;for(const o of n){let s="";if(o.querySelectorAll("span").forEach(h=>{/mso-list:\s*ignore/i.test(h.getAttribute("style")??"")&&(s=h.textContent??"",h.remove())}),!s){const h=(o.textContent??"").match(/^[\s\u00A0]*([·â¢âªÂ§o\-*]|\d+[.)])[\s\u00A0]+/);h&&(s=h[1],Gj(o,h[0].length))}const a=/^\s*\d+[.)]/.test(s.trim())?"ol":"ul",l=i!==null&&i.tagName.toLowerCase()===a&&o.previousElementSibling===i,c=l?i:r.createElement(a);l||o.before(c);const u=r.createElement("li");for(;o.firstChild;)u.appendChild(o.firstChild);c.appendChild(u),o.remove(),i=c}}function Gj(t,e){let n=e;const r=t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;n>0&&r.nextNode();){const i=r.currentNode,o=i.textContent??"",s=Math.min(o.length,n);i.textContent=o.slice(s),n-=s}}function Qj(t){try{const e=t.replace(/<!--[\s\S]*?-->/g,""),n=new DOMParser().parseFromString(e,"text/html"),r=n.body;r.querySelectorAll("style, script, meta, link, title").forEach(a=>a.remove()),r.querySelectorAll("o\\:p").forEach(a=>
519a.remove()),r.querySelectorAll('b[id^="docs-internal-guid"]').forEach(a=>a.replaceWith(...Array.from(a.childNodes))),Jj(r),r.querySelectorAll('[style*="font-weight"]').forEach(a=>{var p;const l=a,c=l.style.fontWeight,u=c==="bold"||c==="bolder"||Number.parseInt(c,10)>=600,h=l.tagName.toLowerCase();if(u&&h!=="b"&&h!=="strong"&&((p=l.textContent)!=null&&p.trim())){const f=n.createElement("strong");for(;l.firstChild;)f.appendChild(l.firstChild);l.appendChild(f)}else(c==="normal"||c==="400")&&(h==="b"||h==="strong")&&l.replaceWith(...Array.from(l.childNodes))}),r.querySelectorAll('[style*="italic"]').forEach(a=>{var u;const l=a,c=l.tagName.toLowerCase();if(l.style.fontStyle==="italic"&&c!=="i"&&c!=="em"&&((u=l.textContent)!=null&&u.trim())){const h=n.createElement("em");for(;l.firstChild;)h.appendChild(l.firstChild);l.appendChild(h)}}),r.querySelectorAll("span, font, u, mark, small, sub, sup, a, abbr, cite").forEach(a=>a.replaceWith(...Array.from(a.childNodes)));let i;for(;i=r.querySelector("div");)if(i.querySelector("div, p, ul, ol, h1, h2, h3, h4, h5, h6, blockquote, li, table"))i.replaceWith(...Array.from(i.childNodes));else{const a=n.createElement("p");for(;i.firstChild;)a.appendChild(i.firstChild);i.replaceWith(a)}const o=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),s=[];for(;o.nextNode();)s.push(o.currentNode);return s.forEach(a=>{a.textContent=(a.textContent??"").replace(/[\u00A0\u2007\u202F]/g," ").replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[ \t]{2,}/g," ")}),r.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote").forEach(a=>{var l;!((l=a.textContent)!=null&&l.trim())&&!a.querySelector("img")&&a.remove()}),r.querySelectorAll("ul, ol").forEach(a=>{a.querySelector("li")||a.remove()}),r.querySelectorAll("*").forEach(a=>{for(const l of Array.from(a.attributes))a.removeAttribute(l.name)}),r.innerHTML}catch{return t}}const Xj=ht.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize||null,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}});let Th=!1;function Zj(){if(Th||typeof document>"u")return;Th=!0;const t=document.createElement("style");t.setAttribute("data-wf-doc-editor",""),t.textContent=` 520 .wf-doc-editor .ProseMirror { 521 outline: none; color: var(--text-primary); 522 font-size: 16px; line-height: 1.85; font-weight: 500; 523 min-height: 300px; white-space: pre-wrap; word-wrap: break-word; 524 } 525 .wf-doc-editor .ProseMirror p { margin: 0 0 0.65em; } 526 .wf-doc-editor .ProseMirror p:last-child { margin-bottom: 0; } 527 .wf-doc-editor .ProseMirror strong { font-weight: 800; } 528 .wf-doc-editor .ProseMirror em { font-style: italic; } 529 /* Tailwind preflight strips these â restore so legacy/AI markdown reads right. */ 530 .wf-doc-editor .ProseMirror h1 { font-size: 1.6em; font-weight: 800; margin: 0.6em 0 0.3em; } 531 .wf-doc-editor .ProseMirror h2 { font-size: 1.35em; font-weight: 800; margin: 0.6em 0 0.3em; } 532 .wf-doc-editor .ProseMirror h3 { font-size: 1.15em; font-weight: 700; margin: 0.6em 0 0.3em; } 533 .wf-doc-editor .ProseMirror h4, 534 .wf-doc-editor .ProseMirror h5, 535 .wf-doc-editor .ProseMirror h6 { font-size: 1em; font-weight: 700; margin: 0.6em 0 0.3em; } 536 .wf-doc-editor .ProseMirror ul { list-style: disc; padding-left: 1.6em; margin: 0 0 0.65em; } 537 .wf-doc-editor .ProseMirror ol { list-style: decimal; padding-left: 1.8em; margin: 0 0 0.65em; } 538 .wf-doc-editor .ProseMirror li { margin: 0.15em 0; } 539 .wf-doc-editor .ProseMirror li > p { margin: 0; } 540 .wf-doc-editor .ProseMirror blockquote { 541 border-left: 3px solid var(--border); margin: 0 0 0.65em; padding-left: 0.9em; 542 color: var(--text-secondary); 543 } 544 .wf-doc-editor .ProseMirror code { 545 font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; 546 background: var(--bg-light); padding: 0.1em 0.35em; border-radius: 4px; 547 } 548 .wf-doc-editor .ProseMirror hr { 549 border: none; border-top: 1px solid var(--border); margin: 1em 0; 550 } 551 .wf-doc-editor .ProseMirror:focus { outline: none; } 552 .wf-doc-editor .ProseMirror p.is-editor-empty:first-child::before { 553 content: attr(data-placeholder); 554 color: var(--text-muted); 555 float: left; height: 0; pointer-events: none; 556 } 557 `,document.head.appendChild(t)}const _h=(t,e,n)=>t.state.doc.textBetween(e,n,` 558`,r=>r.type.name==="hardBreak"?` 559`:"").trim();function Ah(t){return GE(t)}const as="wf-doc-insert";function eI(){return window.__wfDocTargets??0}function pD(t){y.useEffect(()=>{if(!t)return;const e=window;e.__wfDocTargets=(e.__wfDocTargets??0)+1;const n=r=>{var o;const i=(o=r.detail)==null?void 0:o.text;
559typeof i!="string"||!i.trim()||t.chain().focus().insertContent(hc(i)).run()};return window.addEventListener(as,n),()=>{window.removeEventListener(as,n),e.__wfDocTargets=Math.max(0,(e.__wfDocTargets??1)-1)}},[t])}function mD({value:t,onChange:e,placeholder:n}){Zj();const r=$N({extensions:[Hj,Uj,Xj,Kj.configure({placeholder:n??""})],content:Ah(t),onUpdate:({editor:i})=>e(i.getHTML()),editorProps:{transformPastedHTML:Qj,clipboardTextParser(i,o,s,a){const l=document.createElement("div");return l.innerHTML=hc(i),Ir.fromSchema(a.state.schema).parseSlice(l,{preserveWhitespace:!0,context:o})},transformPasted(i,o){const s=[...o.state.selection.$from.marks(),...o.state.storedMarks??[]].find(l=>l.type.name==="textStyle"&&l.attrs.fontSize);if(!s)return i;const a=l=>{const c=[];return l.forEach(u=>{if(u.isText){const h=u.marks.some(p=>p.type.name==="textStyle"&&p.attrs.fontSize);c.push(h?u:u.mark([...u.marks,s]))}else c.push(u.content.childCount>0?u.copy(a(u.content)):u)}),q.fromArray(c)};return new oe(a(i.content),i.openStart,i.openEnd)}}});return y.useEffect(()=>{if(!r)return;const i=Ah(t);!r.isFocused&&i!==r.getHTML()&&r.commands.setContent(i,!1)},[t,r]),r}function gD({editor:t,style:e,onContextMenuSelection:n}){const r=y.useRef(""),i=y.useRef(""),[o,s]=y.useState(null);y.useEffect(()=>{if(!t)return;const u=()=>{const{from:h,to:p}=t.state.selection;if(h!==p){const f=_h(t,h,p);if(f){i.current=f;const m=window.getSelection();if(m&&m.rangeCount>0){const g=m.getRangeAt(0).getBoundingClientRect(),x=g.top-44;s({top:x<8?g.bottom+8:x,left:g.left+g.width/2,text:f})}}}else s(null)};return t.on("selectionUpdate",u),()=>{t.off("selectionUpdate",u)}},[t]);const a=()=>{if(!t)return"";const{from:u,to:h}=t.state.selection;return u!==h?_h(t,u,h):""},l=u=>{(u.button===2||u.button===0&&u.ctrlKey)&&(r.current=a())},c=u=>{if(!t||!n)return;const h=a()||r.current||i.current;n(u,h)};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"wf-doc-editor",style:e,onMouseDown:l,onContextMenu:c,children:d.jsx(jN,{editor:t})}),o&&lf.createPortal(d.jsxs("div",{onMouseDown:u=>{u.preventDefault();const h=o.text;s(null),window.dispatchEvent(new CustomEvent("rp-attach-context",{detail:{text:h}}))},style:{position:"fixed",top:o.top,left:o.left,transform:"translateX(-50%)",zIndex:9999,display:"inline-flex",alignItems:"center",gap:5,background:"var(--bg-darkest)",border:"1px solid var(--border-soft)",borderRadius:20,padding:"5px 12px",cursor:"pointer",boxShadow:"0 4px 20px rgba(0,0,0,0.4)",fontSize:12,fontWeight:600,color:"var(--accent)",userSelect:"none",whiteSpace:"nowrap"},children:[d.jsx(Ti,{style:{width:11,height:11}}),"Ask AI"]}),document.body)]})}const tI=[12,14,16,18,24,32],nI=16;function yD({editor:t}){const[,e]=y.useState(0),[n,r]=y.useState(!1),i=y.useRef(null);y.useEffect(()=>{const a=()=>e(l=>l+1);return t.on("selectionUpdate",a),t.on("transaction",a),()=>{t.off("selectionUpdate",a),t.off("transaction",a)}},[t]),y.useEffect(()=>{if(!n)return;const a=l=>{var c;(c=i.current)!=null&&c.contains(l.target)||r(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[n]);const o=parseInt(t.getAttributes("textStyle").fontSize||"",10)||nI,s=t.isActive("bold");return d.jsxs(d.Fragment,{children:[d.jsxs("div",{ref:i,style:{position:"relative"},children:[d.jsxs("span",{onClick:()=>r(a=>!a),style:{display:"flex",alignItems:"center",gap:5,cursor:"pointer",color:"var(--text-secondary)"},children:[o," ",d.jsx(vf,{style:{width:12,height:12}})]}),n&&d.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"var(--bg-medium)",border:"1px solid var(--border-soft)",borderRadius:6,padding:4,minWidth:56,boxShadow:"0 6px 20px rgba(0,0,0,0.25)"},children:tI.map(a=>d.jsx("div",{onMouseDown:l=>{l.preventDefault(),t.chain().focus().setFontSize(`${a}px`).run(),r(!1)},style:{padding:"5px 10px",fontSize:12,borderRadius:4,cursor:"pointer",fontWeight:o===a?700:500,color:o===a?"var(--accent)":"var(--text-secondary)"},children:a},a))})]}),d.jsx("span",{onMouseDown:a=>{a.preventDefault(),t.chain().focus().toggleBold().run()},title:"Bold (Cmd/Ctrl+B)",style:{fontWeight:700,cursor:"pointer",color:s?"var(--accent)":"var(--text-primary)"},children:"B"})]})}function rI(){const{user:t}=St(),e=hf(),{data:n}=xp(),r=y.useCallback(()=>
559{e.invalidateQueries({queryKey:yp(t==null?void 0:t.id)})},[e,t==null?void 0:t.id]);return n!=null&&n.hasLimit?{locked:(n.percentWithCredits??n.percentUsed??0)>=100,resetsAt:n.resetsAt||null,refresh:r}:{locked:!1,resetsAt:null,refresh:r}}const iI={goal:"What are we optimizing for â views, sales, or email signups? Tell me about the video and I'll help you work it out.",titles:"Let's nail the title â it shapes the entire video. Share what you have in mind, or ask me to generate options based on your research.",videos:"Describe your thumbnail or ask for feedback on your title and thumbnail combo â I can see the data you've saved in this step.",framework:"Which framework might work best for this video to match your viewers' expectations? Ask me to compare options.","basic-idea":"What would a viewer expect this video to include? Let's turn that into a short basic video plan.","research-idea":"How can I help you research and plan this video? Ask me anything.","final-plan":"Ready to plan the full video format? Tell me where you want to start.",intro:"Need help with your intro? Share what you have for feedback, or ask me to write one based on your title and thumbnail.",script:"Highlight any section of your script and right-click to get feedback, rewrites, or transition improvements. Or just ask me anything.",check:"Let's run a final alignment check â thumbnail, title, intro, and script all working together.",repurpose:"Your script is done. Want me to help turn it into newsletters, tweets, LinkedIn posts, or community content?"};function oI(t){return t.split(` 560`).filter(e=>/^\s*\d+[\.\)]\s+.{4,}/.test(e)).map(e=>e.replace(/^\s*\d+[\.\)]\s+/,"").replace(/\*\*/g,"").replace(/^["']|["']$/g,"").trim()).filter(e=>e.length>4&&e.length<250)}const sI=new Set(["basic-idea","research-idea","final-plan","intro","script"]);function Mh({projectId:t}){var be,Ee,De;const{user:e}=St(),n=rI(),{pendingPrefill:r,clearPendingPrefill:i}=ys(),o=It(),s=new URLSearchParams(o.search).get("step"),[a,l]=y.useState(null),c=s??(a?KE(a):null),u=c==="titles",h=t&&c?iI[c]??null:null,[p,f]=y.useState(!1),[m,g]=y.useState(!1),[x,b]=y.useState(null),[E,v]=y.useState([]),[A,_]=y.useState(!1),[S,N]=y.useState(null),[M,L]=y.useState(""),[P,T]=y.useState(null),[O,H]=y.useState(!1),[D,z]=y.useState(null),[ee,Q]=y.useState(!1),[F,V]=y.useState({channelAudit:!1,currentNiche:!1,currentAdjacent:!1,brainData:!1,viewerProfile:!1}),k=y.useRef(null),pe=y.useRef(null),R=y.useRef(!1),w=y.useRef(0),J=y.useRef(""),te=y.useRef(null),B=y.useRef(()=>{});y.useEffect(()=>{const G=()=>B.current();return window.addEventListener("rp-clear",G),()=>window.removeEventListener("rp-clear",G)},[]);const[X,ne]=y.useState(fu());y.useEffect(()=>{const G=le=>ne(le.detail??null);return window.addEventListener(Xa,G),()=>window.removeEventListener(Xa,G)},[]);const ue=y.useRef(null);y.useEffect(()=>{const G=X?`${X.type}|${X.sessionId??""}|${X.channelProfileId??""}|${(X.channelUrls??X.channels??[]).join(",")}`:null;if(G===ue.current||(ue.current=G,!X))return;const le=X.type==="niche",de=X.type==="adjacent";V(I=>I.currentNiche===le&&I.currentAdjacent===de?I:{...I,currentNiche:le,currentAdjacent:de})},[X]),y.useEffect(()=>{const G=le=>{const{loading:de}=le.detail;Q(de)};return window.addEventListener("rp-loading",G),()=>window.removeEventListener("rp-loading",G)},[]);const je=y.useRef(()=>{});y.useEffect(()=>{const G=le=>{const{prompt:de,specialist:I,extraBody:W,functionName:ie,hidden:fe,skipStepContext:ge}=le.detail;if(!de)return;const Me=fe!==!1;setTimeout(()=>je.current(de,{hidden:Me,specialist:I,extraBody:W,functionName:ie,skipStepContext:ge}),350)};return window.addEventListener("rp-prefill",G),()=>window.removeEventListener("rp-prefill",G)},[]),y.useEffect(()=>{const G=le=>{const{text:de}=le.detail;de&&T(de)};return window.addEventListener("rp-attach-context",G),()=>window.removeEventListener("rp-attach-context",G)},[]),y.useEffect(()=>{if(!r)return;const{prompt:G,specialist:le,extraBody:de,functionName:I,hidden:W,skipStepContext:ie}=r;i();const fe=W!==!1;setTimeout(()=>je.current(G,{hidden:fe,specialist:le,extraBody:de,functionName:I,skipStepContext:ie}),350)},[]),y.useEffect(()=>{const G=async le=>{const{content:de,functionName:I,extraBody:W}=le.detail;if(!de)return;const ie=w.current;setTimeout(async()=>
560{if(w.current!==ie)return;Q(!1),v(ge=>[...ge,{role:"assistant",content:de}]),(I||W)&&N({functionName:I,extraBody:W});let fe=x;if(!fe&&e){const ge=await Qt.createConversation(e.id,"New chat",t??null);ge&&(fe=ge.id,R.current=!0,b(fe))}fe&&Qt.saveMessage(fe,"assistant",de)},350)};return window.addEventListener("rp-inject-assistant",G),()=>window.removeEventListener("rp-inject-assistant",G)},[x,e,t]),y.useEffect(()=>{const G=async le=>{const{data:de,functionName:I,extraBody:W}=le.detail;if(!de)return;const ie=sT(de),fe=w.current;setTimeout(async()=>{if(w.current!==fe)return;Q(!1),v(Me=>[...Me,{role:"assistant",content:ie}]),(I||W)&&N({functionName:I,extraBody:W});let ge=x;if(!ge&&e){const Me=await Qt.createConversation(e.id,"New chat",t??null);Me&&(ge=Me.id,R.current=!0,b(ge))}ge&&Qt.saveMessage(ge,"assistant",ie)},350)};return window.addEventListener("rp-inject-analysis",G),()=>window.removeEventListener("rp-inject-analysis",G)},[x,e,t]),y.useEffect(()=>{const G=le=>{const de=le.detail;N(de?{functionName:de.functionName,extraBody:de.extraBody}:null)};return window.addEventListener("rp-pin-context",G),()=>window.removeEventListener("rp-pin-context",G)},[]);const Le=y.useRef(!1),Ue=y.useRef(null),We=y.useCallback(()=>{if(k.current){const G=k.current.querySelector("[data-radix-scroll-area-viewport]");G&&(G.scrollTop=G.scrollHeight)}},[]),re=y.useCallback(()=>{Ue.current&&Ue.current.scrollIntoView({behavior:"auto",block:"start"})},[]);y.useEffect(()=>{Le.current||We()},[E,We]),y.useEffect(()=>{if(!c)return;g(!0);const G=setTimeout(()=>g(!1),3e3);return()=>clearTimeout(G)},[c]),y.useEffect(()=>{if(!t){l(null);return}let G=!1;return cd(t,null).then(le=>{!G&&le&&l(le)}),()=>{G=!0}},[t,c]),y.useEffect(()=>{N(null)},[c]),y.useEffect(()=>{if(!e)return;if(!t){b(null),v([]);return}let G=!1;const le=w.current;async function de(){const{data:I}=await j.from("projects").select("title").eq("id",t).single();if(G||le!==w.current)return;const W=(I==null?void 0:I.title)??"Project Chat",ie=await Qt.getOrCreateProjectConversation(e.id,t,W);G||le!==w.current||!ie||b(ie.id)}return de(),()=>{G=!0}},[e==null?void 0:e.id,t]),y.useEffect(()=>{if(!x){v([]),_(!1),N(null);return}if(R.current){R.current=!1,_(!1);return}let G=!1;return _(!0),Qt.getMessages(x).then(le=>{G||(v(le.map(de=>({role:de.role,content:de.content}))),_(!1))}),()=>{G=!0}},[x]);const me=async(G,le)=>{const de=(G??M).trim();if(!de||O||!e)return;Q(!1);const I=VE(de,D),W={role:"user",content:I,...le!=null&&le.hidden?{hidden:!0}:{}},ie=[...E,W];v(ie),G||L(""),z(null);const fe=P;fe&&T(null),H(!0);let ge=x;if(!ge){const Oe=await Qt.createConversation(e.id,"New chat",t??null);if(!Oe){H(!1);return}ge=Oe.id,R.current=!0,b(ge)}await Qt.saveMessage(ge,"user",I);let Me="";const Dt=new AbortController;pe.current=Dt;const it=ge;J.current="",te.current=it;const ft=await cd(t,a),He=(le==null?void 0:le.skipStepContext)||c==="research-idea"&&iT.test(de)?"":ZE(c,ft),Jt=eT(ft),Lt=ie.map((Oe,ot)=>{const st=sd(Oe.content);if(ot===ie.length-1&&Oe.role==="user"){const pt=[];fe&&pt.push(`[Selected text from document] 561"${fe}" 562`),pt.push(st);const Ze=[];return Jt&&Ze.push(Jt),He&&Ze.push(He),Ze.length&&pt.push(` 563--- 564[Workflow context: ${Ze.join(" ")}]`),{role:Oe.role,content:pt.join(` 565`)}}return{role:Oe.role,content:st}}),Qr=tT(ft,c),mr=D?[D,...Qr??[]]:Qr,Vs=nT(c,de,mr,le==null?void 0:le.specialist),{functionName:Xr,...rn}=Vs;if(c==="videos"&&rT.test(de)&&!(le!=null&&le.hidden)){window.dispatchEvent(new CustomEvent("rp-analyze")),H(!1);return}const Ws=(le==null?void 0:le.functionName)??(S==null?void 0:S.functionName)??Xr??"unified-chat",ve={...(S==null?void 0:S.extraBody)??{},...(le==null?void 0:le.extraBody)??{}},Re=fu(),Fe=!!Re&&(Re.type==="niche"?F.currentNiche:F.currentAdjacent);try{await z0({functionName:Ws,body:{messages:Lt,selectedSources:F,...Fe?{researchFocus:Re}:{},...t?{projectId:t}:{},...mr?{projectImages:mr}:{},...rn,...ve},signal:Dt.signal,onChunk:Oe=>{Me+=Oe,J.current=Me;const ot=Me===Oe;Le.current=!0,v(st=>{const pt=st[st.length-1];return(pt==null?void 0:pt.role)==="assistant"?st.map((Ze,on)=>on===st.length-1?{...Ze,content:Me}:Ze):[...st,{role:"assistant",content:Me}]}),ot&&setTimeout(re,50)},onComplete:()=>{if(H(!1),pe.current=null,Le.current=!1,J.current="",te.current=null,Me&&it&&Qt.saveMessage(it,"assistant",Me),Me&&Me.includes("<!-- plan_confirmed -->")){const Oe=Me.split("<!-- plan_confirmed -->")[0].trim();window.dispatchEvent(new CustomEvent("script-bot-save-plan",{detail:{plan:Oe}}))}},onError:Oe=>{H(!1),pe.current=null,Le.current=!1,J.current="",te.current=null,(Oe==null?void 0:Oe.name)!=="AbortError"&&(console.error("[RightPanelChat] stream error:",Oe),Me||(tu(Oe)&&n.refresh(),v(ot=>[...ot,{role:"assistant",content:tu(Oe)??"Sorry, something went wrong. Please try again."}])))}})}catch{H(!1),pe.current=null}},he=()=>{O&&pe.current&&(pe.current.abort(),pe.current=null,H(!1),Le.current=!1,J.current="",te.current=null),w.current+=1,R.current=!1,v([]),L(""),N(null),T(null);const G=x;b(null),G&&Qt.deleteConversation(G)},ae=()=>{var de;(de=pe.current)==null||de.abort(),pe.current=null,H(!1),Le.current=!1;const G=J.current,le=te.current;G&&le&&Qt.saveMessage(le,"assistant",G),J.current="",te.current=null};je.current=(G,le)=>me(G,le),B.current=he;const ke=A&&E.length===0,Ie=((Ee=(be=e==null?void 0:e.email)==null?void 0:be[0])==null?void 0:Ee.toUpperCase())??"U";return d.jsxs("div",{className:"flex flex-col h-full",children:[!ke&&h&&(p?d.jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--border-soft)",flexShrink:0},children:d.jsx("button",{onClick:()=>{f(!1),g(!1)},"aria-label":"Show step hint",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,borderRadius:7,background:"var(--bg-medium)",border:`1px solid ${m?"var(--accent-border)":"var(--border-soft)"}`,cursor:"pointer",transition:"border-color 0.3s"},onMouseEnter:G=>G.currentTarget.style.borderColor="var(--border)",onMouseLeave:G=>G.currentTarget.style.borderColor=m?"var(--accent-border)":"var(--border-soft)",children:d.jsx(Va,{className:m?"animate-pulse":"",style:{width:14,height:14,color:m?"var(--accent)":"var(--text-muted)",transition:"color 0.3s"}})})}):d.jsx("div",{style:{padding:"10px 12px",borderBottom:"1px solid var(--border-soft)",flexShrink:0,background:"var(--bg-darkest)"},children:d.jsx("div",{style:{background:"var(--bg-medium)",border:"1px solid var(--border-soft)",borderRadius:8,padding:"10px 12px"},children:d.jsxs("div",{style:{display:"flex",alignItems:"flex-start",ga
565p:8},children:[d.jsx(Va,{style:{width:13,height:13,flexShrink:0,marginTop:1,color:"var(--accent)"}}),d.jsx("p",{style:{flex:1,fontSize:11,color:"var(--text-secondary)",fontWeight:500,lineHeight:1.6,margin:0},children:h}),d.jsx("button",{onClick:()=>{f(!0),g(!1)},"aria-label":"Collapse hint",style:{display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:1,padding:"2px",background:"transparent",border:"none",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",transition:"color 0.15s, background 0.15s"},onMouseEnter:G=>{G.currentTarget.style.color="var(--text-secondary)",G.currentTarget.style.background="var(--bg-light)"},onMouseLeave:G=>{G.currentTarget.style.color="var(--text-muted)",G.currentTarget.style.background="transparent"},children:d.jsx(zx,{style:{width:12,height:12}})})]})})})),d.jsx(Ss,{ref:k,className:"flex-1 min-h-0 overscroll-contain [&_[data-radix-scroll-area-viewport]>div]:!block [&>[data-radix-scroll-area-viewport]]:overscroll-contain",children:ke?d.jsx("div",{className:"flex items-center justify-center min-h-[200px]",children:d.jsx(ut,{className:"w-4 h-4 animate-spin text-muted-foreground"})}):d.jsxs(d.Fragment,{children:[E.filter(G=>!G.hidden).length===0&&!O&&!ee&&d.jsx(qE,{title:"AI Coach",description:t?"Your project coaching session. Ask anything about this video.":"Ask anything about your channel, content strategy, or get help with the platform."}),(E.filter(G=>!G.hidden).length>0||O||ee)&&d.jsxs("div",{style:{padding:16},children:[(()=>{const G=E.filter(de=>!de.hidden),le=G.map(de=>de.role).lastIndexOf("assistant");return G.map((de,I)=>d.jsx($E,{role:de.role,authorLabel:de.role==="user"?"You":"AI Coach",userInitial:Ie,innerRef:de.role==="assistant"&&I===le?Ue:void 0,children:de.role==="user"?d.jsx(WE,{content:de.content}):(()=>{const W=aT(de.content);return W?d.jsx(lT,{data:W}):d.jsxs(d.Fragment,{children:[d.jsx(mT,{content:de.content,projectId:t,enabled:c==="repurpose"}),d.jsx(FE,{content:de.content,canInsert:sI.has(c??""),onInsert:ie=>{window.dispatchEvent(new CustomEvent(as,{detail:{text:ie}}))},feedback:{question:(()=>{for(let ie=I-1;ie>=0;ie-=1)if(G[ie].role==="user")return sd(G[ie].content);return null})(),botContext:`panel:${c??"general"}`,conversationId:x}}),u&&(()=>{const ie=oI(de.content);return ie.length?d.jsxs("div",{style:{borderTop:"1px solid var(--border-soft)",marginTop:8,paddingTop:8,display:"flex",flexDirection:"column",gap:4},children:[d.jsx("span",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"1px",color:"var(--text-muted)",fontWeight:700},children:"Use as variant"}),ie.map((fe,ge)=>d.jsxs("button",{onClick:()=>window.dispatchEvent(new CustomEvent("title-variant-use",{detail:{title:fe}})),style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",textAlign:"left",background:"var(--bg-medium)",border:"1px solid var(--border-soft)",borderRadius:5,padding:"5px 8px",fontSize:10,fontWeight:500,color:"var(--text-secondary)",cursor:"pointer",fontFamily:"inherit",transition:"border-color 0.15s"},onMouseEnter:Me=>Me.currentTarget.style.borderColor="var(--accent-border)",onMouseLeave:Me=>Me.currentTarget.style.borderColor="var(--border-soft)",children:[d.jsx("span",{style:{flex:1,wordBreak:"break-word"},children:fe}),d.jsx("span",{style:{marginLeft:8,flexShrink:0,color:"var(--accent)",fontWeight:700},children:"+ Use"})]},ge))]}):null})()]})})()},I))})(),(ee||O&&((De=E[E.length-1])==null?void 0:De.role)!=="assistant")&&d.jsx(HE,{})]})]})}),P&&d.jsx("div",{style:{padding:"6px 12px 0",display:"flex"},children:d.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,background:"var(--bg-medium)",border:"1px solid var(--border-soft)",borderRadius:20,padding:"3px 8px 3px 7px",fontSize:11,fontWeight:500,color:"var(--text-secondary)",maxWidth:"100%",overflow:"hidden"},children:[d.jsx(Ti,{style:{width:10,height:10,color:"var(--accent)",flexShrink:0}}),d.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:P.length>80?`${P.slice(0,80)}â¦`:P}),d.jsx("button",{onClick:()=>T(null),style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"flex",alignItems:"center",color:"var(--text-muted)",flexShrink:0,marginLeft:2},children:d.jsx(Bn,{style:{width:9,height:9}})})]})}),d.jsx(UE,{value:M,onChange:L,onSend:()=>me(),onStop:ae,isLoading:O,canSend:!!M.trim()&&!O,attachedImage:D,onAttachImage:z,userId:e==null?void 0:e.id,selectedSources:F,onSourcesChange:V,researchFocus:X,placeholder:"Ask AI Coach anythingâ¦",locked:n.locked?{resetsAt:n.resetsAt}:null})]})}const aI=280,lI=800;function cI(){const{rightPanelOpen:t,toggleRightPanel:e,panelWidth:n,setPanelWidth:r}=ys(),i=It(),o=gp(),[s,a]=y.useState(!1),l=y.useCallback(p=>{p.preventDefault();const f=p.clientX,m=n,g=b=>{const E=Math.max(aI,Math.min(lI,m+(f-b.clientX)));r(E)},x=()=>{document.removeEventListener("mousemove",g),window.removeEventListener("mouseup",x),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",g),window.addEventListener("mouseup",x)},[n,r]);y.useEffect(()=>{a(!1)},[t,i.pathname,i.search]),y.useEffect(()=>{if(!s)return;const p=()=>a(!1),f=window.setTimeout(()=>window.addEventListener("click",p),0);return()=>{window.clearTimeout(f),window.removeEventListener("click",p)}},[s]);const c=i.pathname.match(/^\/project\/([^/?]+)/),u=c?c[1]:null;if(!t)return null;const h=d.jsx("div",{className:"flex items-center h-10 px-3 shrink-0 gap-2",style:{borderBottom:"1px solid var(--border-soft)"},children:s?d.jsxs(d.Fragment,{children:[d.jsx("span",{style:{flex:1,fontSize:12,color:"var(--text-secondary)",fontWeight:500},children:"Clear this chat?"}),d.jsx("button",{onClick:()=>a(!1),style:{fontSize:12,fontWeight:500,padding:"3px 8px",borderRadius:5,background:"transparent",border:"1px solid var(--border)",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:p=>{p.currentTarget.style.borderColor="var(--border-soft)",p.currentTarget.style.color="var(--text-primary)"},onMouseLeave:p=>{p.currentTarget.style.borderColor="var(--border)",p.currentTarget.style.color="var(--text-secondary)"},children:"Cancel"}),d.jsx("button",{onClick:()=>{window.dispatchEvent(new CustomEvent("rp-clear")),a(!1)},style:{fontSize:12,fontWeight:600,padding:"3px 8px",borderRadius:5,background:"var(--accent)",border:"1px solid var(--accent)",color:"#ffffff",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:p=>{p.currentTarget.style.background="#c66a4a"},onMouseLeave:p=>{p.currentTarget.style.background="var(--accent)"},children:"Clear"})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-xs font-semibold flex-1",style:{color:"var(--text-muted)"},children:"AI Bot"}),d.jsx("button",{onClick:()=>a(!0),"aria-label":"Clear chat",style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:5,background:"transparent",border:"none",color:"var(--text-muted)",cursor:"pointer",transition:"background 0.15s, color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.background="var(--bg-light)",p.currentTarget.style.color="var(--text-primary)"},onMouseLeave:p=>{p.currentTarget.style.background="transparent",p.currentTarget.style.color="var(--text-muted)"},children:d.jsx(ub,{style:{width:13,height:13}})}),d.jsx("button",{onClick:e,"aria-label":"Close AI Bot panel",style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:5,background:"transparent",border:"none",color:"var(--text-muted)",cursor:"pointer",transition:"background 0.15s, color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.background="var(--bg-light)",p.currentTarget.style.color="var(--text-primary)"},onMouseLeave:p=>{p.currentTarget.style.background="transparent",p.currentTarget.style.color="var(--text-muted)"},children:d.jsx(Bn,{style:{width:13,height:13}})})]})});return o?d.jsxs(d.Fragment,{children:[d.jsx("div",{onClick:e,"aria-hidden":!0,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:99}}),d.jsxs("aside",{className:"flex flex-col",style:{position:"fixed",top:0,right:0,bottom:0,width:"min(100vw, 440px)",maxWidth:"100vw",zIndex:100,background:"var(--bg-darkest)",borderLeft:"1px solid var(--border-soft)",boxShadow:"-8px 0 24px rgba(0,0,0,0.3)",overscrollBehavior:"contain"},children:[h,d.jsx(Mh,{projectId:u})]})]}):d.jsxs("aside",{className:"hidden lg:flex h-full shrink-0 flex-col",style:{width:n,minWidth:0,overflow:"hidden",background:"var(--bg-darkest)",borderLeft:"1px solid var(--border-soft)",position:"relative",overscrollBehavior:"contain"},children:[d.jsx("div",{onMouseDown:l,style:{position:"absolute",left:0,top:0,bottom:0,width:6,cursor:"col-resize",zIndex:10,background:"transparent",transition:"background 0.15s"},onMouseEnter:p=>{p.currentTarget.style.background="var(--accent-border)"},onMouseLeave:p=>{p.currentTarget.style.background="transparent"}}),h,d.jsx(Mh,{projectId:u})]})}const uI={primary:{idle:{background:"var(--accent)",color:"#ffffff",border:"none"},hover:{background:"#c66a4a",color:"#ffffff",border:"none"},disabled:{background:"var(--bg-light)",color:"var(--text-muted)",border:"none"},fontWeight:600},outline:{idle:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-soft)"},hover:{background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border)"},disabled:{background:"transparent",color:"var(--text-muted)",border:"1px solid var(--border-soft)"},fontWeight:600},"outline-accent":{idle:{background:"transparent",color:"var(--accent)",border:"1px solid var(--accent)"},hover:{background:"var(--accent-soft)",color:"var(--accent)",border:"1px solid var(--accent)"},disabled:{background:"transparent",color:"var(--text-muted)",border:"1px solid var(--border-soft)"},fontWeight:600},ghost:{idle:{background:"transparent",color:"var(--text-secondary)",border:"none"},hover:{background:"var(--bg-medium)",color:"var(--text-primary)",border:"none"},disabled:{background:"transparent",color:"var(--text-muted)",border:"none"},fontWeight:500},"icon-ghost":{idle:{background:"transparent",color:"var(--text-muted)",border:"none"},hover:{background:"var(--bg-light)",color:"var(--text-primary)",border:"none"},disabled:{background:"transparent",color:"var(--text-muted)",border:"none"},fontWeight:500},pill:{idle:{background:"var(--bg-darkest)",color:"var(--text-secondary)",border:"none"},hover:{background:"var(--bg-medium)",color:"var(--text-primary)",border:"none"},disabled:{background:"var(--bg-medium)",color:"var(--text-muted)",border:"none"},fontWeight:500}},dI={xs:{height:26,px:10,fontSize:12,radius:6,iconSize:11,gap:6},sm:{height:28,px:8,fontSize:12,radius:4,iconSize:13,gap:4}
565,md:{height:36,px:16,fontSize:13,radius:7,iconSize:16,gap:6},lg:{height:40,px:20,fontSize:13,radius:7,iconSize:16,gap:6}};function hI(t){return typeof t=="function"||typeof t=="object"&&t!==null&&typeof t.render=="function"}const Dr=y.forwardRef(function({variant:e="primary",size:n="md",children:r,icon:i,iconRight:o,iconOnly:s=!1,fullWidth:a=!1,loading:l=!1,disabled:c=!1,style:u,onClick:h,type:p="button",...f},m){const[g,x]=y.useState(!1),b=c||l,E=uI[e],v=dI[n],A=e==="pill",_=s||e==="icon-ghost",S=c?E.disabled:g&&!l?E.hover:E.idle,N={display:"inline-flex",alignItems:"center",justifyContent:"center",gap:_?0:v.gap,height:v.height,width:_?v.height:a?"100%":void 0,padding:_?0:`0 ${v.px}px`,borderRadius:A?99:v.radius,...S,fontFamily:"inherit",fontSize:v.fontSize,fontWeight:E.fontWeight,lineHeight:1,whiteSpace:"nowrap",cursor:c?"not-allowed":l?"progress":"pointer",opacity:c?.6:1,outline:"none",flexShrink:0,transition:"background 0.15s, border-color 0.15s, color 0.15s",...u};function M(L){if(!L)return null;if(hI(L)){const P=L,T=_?v.height-12:v.iconSize;return d.jsx(P,{style:{width:T,height:T,flexShrink:0}})}return d.jsx(d.Fragment,{children:L})}return d.jsxs("button",{ref:m,type:p,disabled:b,style:N,onMouseEnter:()=>!b&&x(!0),onMouseLeave:()=>x(!1),onClick:b?void 0:h,"aria-busy":l||void 0,...f,children:[l?d.jsx(ut,{className:"animate-spin",style:{width:_?v.height-12:v.iconSize,height:_?v.height-12:v.iconSize,flexShrink:0}}):i&&M(i),!_&&r&&d.jsx("span",{style:{display:"inline-flex",alignItems:"center"},children:r}),!_&&o&&M(o)]})});function xD(t){const{icon:e,title:n,danger:r=!1,size:i=26,radius:o=5,style:s,...a}=t,[l,c]=y.useState(!1),u={width:i,height:i,borderRadius:o,border:"none",background:l?"var(--bg-light)":"transparent",color:l?r?"var(--danger)":"var(--text-primary)":"var(--text-muted)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.1s, color 0.1s",fontFamily:"inherit",flexShrink:0,textDecoration:"none",...s};if("href"in t&&t.href!==void 0){const{href:m,target:g,rel:x,...b}=a;return d.jsx("a",{href:m,target:g,rel:x,title:n,style:u,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:e})}const{onClick:h,disabled:p,...f}=a;return d.jsx("button",{title:n,onClick:h,disabled:p,style:{...u,cursor:p?"not-allowed":"pointer",opacity:p?.4:1},onMouseEnter:()=>!p&&c(!0),onMouseLeave:()=>c(!1),...f,children:e})}function bD({icon:t,title:e,active:n=!1,style:r,disabled:i,onClick:o,...s}){const[a,l]=y.useState(!1);return d.jsx("button",{title:e,onClick:o,disabled:i,style:{width:22,height:22,borderRadius:5,background:"transparent",border:`1px solid ${a?"var(--border)":"var(--border-soft)"}`,color:n?"var(--success)":a?"var(--text-primary)":"var(--text-secondary)",cursor:i?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"inherit",flexShrink:0,transition:"border-color 0.1s, color 0.1s",opacity:i?.4:1,...r},onMouseEnter:()=>!i&&l(!0),onMouseLeave:()=>l(!1),...s,children:t})}const fI=Dl("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}}),vy=y.forwardRef(({className:t,variant:e,...n},r)=>d.jsx("div",{ref:r,className:Ne(fI({variant:e}),t),...n}));vy.displayName="Badge";const Nh=500;function pI({announcement:t}){const{pollResponses:e,submitPollResponse:n}=tp(),r=e[t.id],i=Array.isArray(t.poll_options)?t.poll_options:[],o=i.length>0,s=t.poll_allow_comment||!o,[a,l]=y.useState((r==null?void 0:r.option_index)??null),[c,u]=y.useState((r==null?void 0:r.comment)??""),[h,p]=y.useState(!1),[f,m]=y.useState(!1);if(y.useEffect(()=>{l((r==null?void 0:r.option_index)??null),u((r==null?void 0:r.comment)??"")},[r==null?void 0:r.option_index,r==null?void 0:r.comment]),!t.poll_question)return null;const g=!!r&&!f,x=async()=>
565{if(o&&a===null){Mt({title:"Pick an answer",description:"Choose one of the options first."});return}if(!o&&c.trim().length===0){Mt({title:"Write an answer",description:"Add a short answer first."});return}p(!0);const b=await n(t.id,a,c.trim().slice(0,Nh));p(!1),b?(m(!1),Mt({title:"Thanks",description:"Your answer is in."})):Mt({title:"Could not save",description:"Please try again in a moment.",variant:"destructive"})};return d.jsxs("div",{style:{marginTop:12,padding:"14px 16px",background:"var(--bg-light)",border:"1px solid var(--border-soft)",borderRadius:10},children:[d.jsx("p",{style:{margin:"0 0 10px",fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:t.poll_question}),g?d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[d.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--text-secondary)"},children:"Thanks, your answer is in."}),d.jsx("button",{type:"button",onClick:()=>m(!0),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:13,fontWeight:600,color:"var(--accent)",textDecoration:"underline"},children:"Change my answer"})]}):d.jsxs(d.Fragment,{children:[o&&d.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:12},children:i.map((b,E)=>{const v=a===E;return d.jsx("button",{type:"button",onClick:()=>l(E),style:{textAlign:"left",padding:"9px 12px",borderRadius:8,fontSize:13,fontWeight:500,cursor:"pointer",color:v?"var(--text-primary)":"var(--text-secondary)",background:v?"var(--bg-medium)":"transparent",border:`1px solid ${v?"var(--accent)":"var(--border-soft)"}`},children:b},E)})}),s&&d.jsx("textarea",{value:c,maxLength:Nh,onChange:b=>u(b.target.value),placeholder:o?"Anything to add? (optional)":"Your answer",rows:o?2:3,style:{width:"100%",marginBottom:12,padding:"9px 12px",borderRadius:8,fontSize:13,fontFamily:"inherit",color:"var(--text-primary)",background:"var(--bg-medium)",border:"1px solid var(--border-soft)",resize:"vertical"}}),d.jsx("button",{type:"button",onClick:x,disabled:h,style:{padding:"8px 16px",borderRadius:8,fontSize:13,fontWeight:600,cursor:h?"default":"pointer",color:"#ffffff",background:"var(--accent)",border:"none",opacity:h?.7:1},children:h?"Sendingâ¦":"Send answer"})]})]})}const mI="\\[([^\\]]+)\\]\\(\\s*([^)\\s]+)\\s*\\)",gI="(https?:\\/\\/[^\\s<]+|www\\.[^\\s<]+|[a-zA-Z0-9][a-zA-Z0-9-]*\\.(?:com|net|org|io|co|app|ai|dev|gg|tv|me|gl|ly|so|xyz|info|news|studio|page)(?:\\/[^\\s<]*)?)",jh=new RegExp(`${mI}|${gI}`,"gi"),Ih=t=>/^https?:\/\//i.test(t)?t:`https://${t}`,Rh="text-[var(--accent)] underline underline-offset-2 hover:opacity-80 break-words";function yI({text:t}){if(!t)return null;const e=[];let n=0,r=0;jh.lastIndex=0;let i;for(;(i=jh.exec(t))!==null;){const[o,s,a,l]=i;if(i.index>n&&e.push(d.jsx(Y.Fragment,{children:t.slice(n,i.index)},r++)),s&&a)e.push(d.jsx("a",{href:Ih(a),target:"_blank",rel:"noopener noreferrer",className:Rh,onClick:c=>{c.preventDefault(),c.stopPropagation(),window.open(c.currentTarget.href,"_blank","noopener,noreferrer")},children:s},r++));else if(l){const c=l.match(/[).,!?;:]+$/),u=c?c[0]:"",h=u?l.slice(0,l.length-u.length):l;e.push(d.jsx("a",{href:Ih(h),target:"_blank",rel:"noopener noreferrer",className:Rh,onClick:p=>{p.preventDefault(),p.stopPropagation(),window.open(p.currentTarget.href,"_blank","noopener,noreferrer")},children:h},r++)),u&&e.push(d.jsx(Y.Fragment,{children:u},r++))}n=i.index+o.length}return n<t.length&&e.push(d.jsx(Y.Fragment,{children:t.slice(n)},r++)),d.jsx(d.Fragment,{children:e})}const Oh={feature:{label:"New Feature",color:"bg-primary/20 text-primary border-primary/30",icon:Ti},improvement:{label:"Improvement",color:"bg-blue-500/20 text-blue-400 border-blue-500/30",icon:pb},fix:{label:"Bug Fix",color:"bg-green-500/20 text-green-400 border-green-500/30",icon:hb},announcement:{label:"Announcement",color:"bg-orange-500/20 text-orange-400 border-orange-500/30",icon:Xx}};function xI(){const{newAnnouncements:t,loading:e,markAnnouncementsRead:n}=tp(),[r,i]=y.useState(!1);y.useEffect(()=>{if(!e&&t.length>0){const s=setTimeout(()=>i(!0),200);return()=>clearTimeout(s)}},[e,t.length]);const o=async()=>{await n(),i(!1)};return e||t.length===0?null:d.jsx(Gl,{open:r,onOpenChange:s=>!s&&o(),modal:!1,children:d.jsxs(ws,{className:"sm:max-w-lg max-h-[80vh] flex flex-col overflow-hidden",children:[d.jsx(vs,{children:d.jsxs(ks,{className:"flex items-center gap-2 text-xl",children:[d.jsx(Ti,{className:"w-5 h-5 text-primary"}),"What's New"]})}),d.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto pr-4 -mr-4",children:d.jsx("div",{className:"space-y-4",children:t.map(s=>{const a=Oh[s.type]||Oh.announcement,l=a.icon;return d.jsxs("div",{className:"p-4 rounded-lg border border-border/50 bg-card/50 space-y-2",children:[d.jsxs("div",{className:"flex items-start justify-between gap-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(l,{className:"w-4 h-4 text-primary"}),d.jsx(vy,{variant:"outline",className:a.color,children:a.label})]}),d.jsx("span",{className:"text-xs text-muted-foreground",children:Qy(new Date(s.publish_at),{addSuffix:!0})})]}),d.jsx("h3",{className:"font-semibold text-foreground",children:s.title}),d.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:d.jsx(yI,{text:s.content})}),s.poll_question&&d.jsx(pI,{announcement:s})]},s.id)})})}),d.jsx("div",{className:"pt-4 border-t",children:d.jsx(Dr,{variant:"primary",fullWidth:!0,icon:Ti,onClick:o,children:"Got it!"})})]})})}const bI=700,wI=y.createContext(!1),vI=[C.account,C.aiAssistant,C.home,C.dashboard,C.privacy,C.terms,C.resources,C.myTickets,C.guides,C.brainData],kI=[C.brainData,C.aiAssistant],SI=[],CI=[C.aiAssistant,C.research,C.brainData],EI=[At.course];function TI(){const[t,e]=y.useState(!1),n=gp(),r=It(),{sidebarCollapsed:i,subNavOpen:o,toggleSubNav:s,toggleRightPanel:a,rightPanelOpen:l,toolbarBreadcrumbs:c,requestRoomForPanel:u}=ys(),h=Bw(),p=y.useRef(null);y.useLayoutEffect(()=>{if(n||!l||i)return;const v=p.current;v&&v.clientWidth<bI&&u()},[l,n]),y.useEffect(()=>{e(!1)},[r.pathname,r.search]);const{hasFeature:f,loading:m}=hr(),g=m||!f("ai_coach")||vI.includes(r.pathname)||SI.some(v=>r.pathname===v||r.pathname.startsWith(v+"/")),x=CI.includes(r.pathname)||EI.some(v=>r.pathname===v||r.pathname.startsWith(v+"/")),b=h,E=kI.includes(r.pathname);return d.jsx(wI.Provider,{value:!0,children:d.jsxs(Iw,{children:[d.jsxs("div",{style:{display:"flex",height:"100vh",width:"100vw",overflow:"hidden"},children:[!n&&d.jsx(hu,{}),n&&d.jsx(I1,{open:t,onOpenChange:e,children:d.jsxs(hp,{side:"left",className:"w-[280px] max-w-[92vw] p-0 data-[state=closed]:duration-0 data-[state=closed]:animate-none",style:{borderRight:"1px solid var(--border-soft)",background:"var(--bg-darkest)"},children:[d.jsxs(fp,{className:"sr-only",children:[d.jsx(pp,{children:"Navigation"}),d.jsx(mp,{children:"App navigation sidebar"})]}),d.jsx(hu,{})]})}),d.jsxs("main",{ref:p,style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--bg-darkest)"},children:[d.jsx(L1,{}),n&&d.jsxs("div",{style:{display:"flex",alignItems:"center",height:44,padding:"0 12px",flexShrink:0,gap:8,borderBottom:"1px solid var(--border-soft)",background:"var(--bg-medium)"},children:[d.jsx("button",{onClick:()=>e(!0),"aria-label":"Open navigation",style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,flexShrink:0,background:"transparent",border:"1px solid var(--border-soft)",borderRadius:6,cursor:"pointer",color:"var(--text-secondary)"},children:d.jsx(Zx,{style:{width:16,height:16}})}),c.length>0?d.jsx("nav",{style:{display:"flex",alignItems:"center",gap:4,flex:1,minWidth:0,fontSize:13,color:"var(--text-muted)"},children:c.map((v,A)=>d.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0},children:[A>0&&d.jsx("span",{style:{opacity:.4},children:"/"}),v.to?d.jsx(Lr,{to:v.to,style:{color:"inherit",textDecoration:"none",whiteSpace:"nowrap"},children:v.label}):d.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:A===c.length-1?"var(--text-primary)":"inherit"},children:v.label})]},A))}):d.jsx("div",{style:{flex:1}})]}),!n&&!E&&(b||c.length>0)&&d.jsxs("div",{style:{display:"flex",alignItems:"center",height:40,padding:"0 12px",flexShrink:0,gap:8,borderBottom:"1px solid var(--border-soft)",background:"var(--bg-medium)"},children:[d.jsx("div",{style:{width:28,flexShrink:0},children:b&&d.jsx("button",{onClick:s,"aria-label":o?"Collapse sub-navigation":"Expand sub-navigation",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:6,border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",transition:"background 0.15s, color 0.15s"},onMouseEnter:v=>{v.currentTarget.style.background="var(--bg-light)",v.currentTarget.style.color="var(--text-primary)"},onMouseLeave:v=>{v.currentTarget.style.background="transparent",v.currentTarget.style.color="var(--text-muted)"},children:o?d.jsx(Kc,{style:{width:14,height:14}}):d.jsx(Yc,{style:{width:14,height:14}})})}),c.length>0&&d.jsx("nav",{style:{display:"flex",alignItems:"center",gap:4,flex:1,minWidth:0,fontSize:13,color:"var(--text-muted)"},children:c.map((v,A)=>d.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0},children:[A>0&&d.jsx("span",{style:{opacity:.4},children:"/"}),v.to?d.jsx(Lr,{to:v.to,style:{color:"inherit",textDecoration:"none",whiteSpace:"nowrap"},onMouseEnter:_=>_.currentTarget.style.color="var(--text-primary)",onMouseLeave:_=>_.currentTarget.style.color="var(--text-muted)",children:v.label}):d.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:A===c.length-1?"var(--text-primary)":"inherit"},children:v.label})]},A))}),c.length===0&&d.jsx("div",{style:{flex:1}}),!g&&d.jsx("button",{onClick:a,"aria-label":"Toggle AI panel",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:6,border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.15s, color 0.15s"},onMouseEnter:v=>{v.currentTarget.style.background="var(--bg-light)",v.currentTarget.style.color="var(--text-primary)"},onMouseLeave:v=>{v.currentTarget.style.background="transparent",v.currentTarget.style.color="var(--text-muted)"},children:l?d.jsx(Kc,{style:{width:14,height:14}}):d.jsx(Yc,{style:{width:14,height:14}})})]}),d.jsx("div",{style:x?{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",minHeight:0}:{flex:1,overflowY:"auto"},children:d.jsx(Uy,{})})]}),d.jsx(xI,{}),!g&&d.jsx(cI,{})]}),!g&&!l&&d.jsxs("button",{onClick:a,"aria-label":"Open AI Bot panel",style:{position:"fixed",top:"50%",right:0,transform:"translateY(-50%)",background:"var(--bg-medium)",border:"1px solid var(--accent-border)",borderRight:"none",borderRadius:"8px 0 0 8px",padding:"16px 8px",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",gap:10,color:"var(--accent)",zIndex:45,transition:"background 0.2s"},onMouseEnter:v=>v.currentTarget.style.background="var(--accent-soft)",onMouseLeave:v=>v.currentTarget.style.background="var(--bg-medium)",children:[d.jsx(Wi,{style:{width:18,height:18}}),d.jsx("span",{style:{writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:700,letterSpacing:"1.5px",textTransform:"uppercase",fontFamily:"inherit"},children:"AI Bot"})]})]})})}let zt=null,Xt=null,gn=null;const _I=(t,e,n)=>{xe.setString(Xe.analyticsSessionRowId,e,{scope:"session"}),xe.setString(Xe.analyticsSessionStartedAt,String(n),{scope:"session"}),xe.setString(Xe.analyticsSessionUserId,t,{scope:"session"})},Pl=()=>{xe.remove(Xe.analyticsSessionRowId,{scope:"session"}),xe.remove(Xe.analyticsSessionStartedAt,{scope:"session"}),xe.remove(Xe.analyticsSessionUserId,{scope:"session"})},Pa=()=>
565{if(zt&&Xt&&gn)return;const t=xe.getString(Xe.analyticsSessionRowId,{scope:"session"}),e=xe.getString(Xe.analyticsSessionStartedAt,{scope:"session"}),n=xe.getString(Xe.analyticsSessionUserId,{scope:"session"});if(!t||!e||!n)return;const r=Number(e);if(!Number.isFinite(r)){Pl();return}zt=t,Xt=r,gn=n},Da=()=>({...Ya(),analyticsSessionId:zt??Ya().analyticsSessionId}),AI=()=>{const t=y.useCallback(async a=>{try{if(Pa(),zt&&Xt&&gn===a)return;zt&&gn&&gn!==a&&(await j.from("user_sessions").update({ended_at:new Date().toISOString(),duration_seconds:Xt?Math.floor((Date.now()-Xt)/1e3):null}).eq("id",zt),zt=null,Xt=null,gn=null,Pl());const{data:l,error:c}=await j.from("user_sessions").insert({user_id:a}).select().single();if(c)throw c;zt=l.id,Xt=Date.now(),gn=a,_I(a,l.id,Xt),mf(a,{analyticsSessionId:l.id}),console.log("Session started:",zt)}catch(l){console.error("Failed to start session:",l),await Ge(l,{eventName:"AnalyticsSessionStartError",source:"client-error",metadata:{trackedUserId:a}})}},[]),e=y.useCallback(async()=>{if(Pa(),!(!zt||!Xt))try{const a=Math.floor((Date.now()-Xt)/1e3);await j.from("user_sessions").update({ended_at:new Date().toISOString(),duration_seconds:a}).eq("id",zt),console.log("Session ended:",zt,"Duration:",a),za(),zt=null,Xt=null,gn=null,Pl()}catch(a){console.error("Failed to end session:",a),await Ge(a,{eventName:"AnalyticsSessionEndError",source:"client-error",metadata:{trackedUserId:gn,...Da()}})}},[]),n=y.useCallback(async(a,l,c,u)=>{try{Pa(),await si(a,l,c,{...Da(),...u??{}})}catch(h){console.error("Failed to track event:",h)}},[]),r=y.useCallback(async(a,l,c,u,h)=>{try{const p=Da();await t1(a,l,c,u,h),await n(a,Gn.chatMessage,l,{...p,botType:l,conversationLength:h??null,hasAssistantResponse:!!u,userMessageLength:c.length}),Tn(`chat_${l.replace(/[^a-z0-9_-]/gi,"_").toLowerCase()}`)}catch(p){console.error("Failed to track chat message:",p)}},[n]),i=y.useCallback(async(a,l)=>{await n(a,Gn.pageViewed,l,{pageKey:l,url:window.location.pathname}),Tn(`page_${l}`)},[n]),o=y.useCallback(async(a,l,c)=>{await n(a,Gn.featureUsed,l,{featureKey:l,...c??{}}),Tn(`feature_${l}`)},[n]),s=y.useCallback(async(a,l,c)=>{try{await Ge(l,{eventName:l.name||"UnknownError",source:"client-error",metadata:{trackedUserId:a,...c}})}catch(u){console.error("Failed to track error:",u)}},[]);return{startSession:t,endSession:e,trackEvent:n,trackChatMessage:r,trackPageView:i,trackFeatureUsage:o,trackError:s}},MI=()=>{const{startSession:t,endSession:e}=AI();y.useEffect(()=>{(async()=>{const{data:{user:o}}=await j.auth.getUser();o&&await t(o.id)})();const{data:{subscription:r}}=j.auth.onAuthStateChange((o,s)=>{var a;if((a=s==null?void 0:s.user)!=null&&a.id){t(s.user.id);return}e()}),i=()=>{e()};return window.addEventListener("beforeunload",i),window.addEventListener("pagehide",i),()=>{window.removeEventListener("beforeunload",i),window.removeEventListener("pagehide",i),r.unsubscribe(),e()}},[t,e])},La="1.0.0",NI=()=>{y.useEffect(()=>{const t=xe.getString("app_version");if(!t){xe.setString("app_version",La);return}t!==La&&xe.setString("app_version",La)},[])},oi={fontFamily:"Open Sans, sans-serif"};class jI extends y.Component{constructor(n){super(n);vn(this,"retryTimeout");vn(this,"clearTargetedStorage",()=>{try{xe.remove(Xe.youtubeOAuthState),xe.remove(Xe.youtubeOAuthDebug),xe.remove(Xe.reviewPromptDismissed,{scope:"session"});const n=["storyos_chat_","chat_messages_","chat_threadId_","last_message_","planner-chat-","workflow_v2_"],r=[];for(let i=0;i<localStorage.length;i+=1){const o=localStorage.key(i);o&&n.some(s=>o.startsWith(s))&&r.push(o)}r.forEach(i=>xe.remove(i))}catch(n){console.error("Failed to clear targeted storage:",n)}});vn(this,"handleReload",()=>{window.location.reload()});vn(this,"handleClearCacheAndReload",()=>{"caches"in window&&caches.keys().then(n=>{n.forEach(r=>caches.delete(r))}),this.clearTargetedStorage(),window.location.reload()});this.state={hasError:!1,error:null,retryCount:0,isModuleError:!1,isAutoRetrying:!1}}static getDerivedStateFromError(n){const r=n.message.includes("Failed to fetch")||n.message.includes("Importing a module script failed")||n.message.includes("dynamically imported module")||n.message.includes("module")||n.message.includes("Loading chunk");return{hasError:!0,error:n,isModuleError:r}}componentWillUnmount(){this.retryTimeout&&clearTimeout(this.retryTimeout)}async componentDidCatch(n,r){console.error("Error caught by boundary:",n,r);const i=n.message.includes("Failed to fetch")||n.message.includes("Importing a module script failed")||n.message.includes("dynamically imported module")||n.message.includes("module")||n.message.includes("Loading chunk");if(i&&this.state.retryCount===0){console.log("Module loading error detected - auto-reloading for fresh assets..."),this.setState({isAutoRetrying:!0}),this.retryTimeout=setTimeout(()=>{this.setState(o=>({retryCount:o.retryCount+1})),window.location.reload()},500);return}try{await Ge(n,{eventName:n.name||"UnknownError",source:"client-error",metadata:{componentStack:r.componentStack,isModuleError:i,retryCount:this.state.retryCount}})}catch(o){console.error("Failed to track error:",o)}}
565render(){if(this.state.isAutoRetrying)return d.jsxs(d.Fragment,{children:[d.jsx("style",{children:"@keyframes ebSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }"}),d.jsxs("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",background:"var(--bg-page)",padding:16,gap:16},children:[d.jsx(tb,{style:{width:32,height:32,color:"var(--accent-default)",animation:"ebSpin 0.8s linear infinite"}}),d.jsx("p",{style:{...oi,fontSize:13,fontWeight:300,color:"var(--ink-3)"},children:"Refreshing appâ¦"})]})]});if(this.state.hasError){const n=this.state.isModuleError;return d.jsx("div",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-page)",padding:16},children:d.jsxs("div",{style:{maxWidth:448,width:"100%",background:"var(--bg-1)",border:"1px solid var(--ink-5)",borderRadius:12,padding:32,textAlign:"center"},children:[d.jsx(Fx,{style:{width:64,height:64,color:"var(--ink-3)",margin:"0 auto 16px",opacity:.7}}),d.jsx("h1",{style:{...oi,fontSize:22,fontWeight:700,color:"var(--ink-3)",margin:"0 0 8px"},children:n?"App Update Available":"Something went wrong"}),d.jsx("p",{style:{...oi,fontSize:13,fontWeight:300,color:"var(--ink-3)",margin:"0 0 24px"},children:n?"A new version of the app is available. Clear your cache and reload to get the latest updates.":"We've logged the error and will look into it. Please try reloading the page."}),this.state.error&&d.jsxs("details",{style:{textAlign:"left",marginBottom:24,padding:16,background:"var(--bg-2)",borderRadius:8},children:[d.jsx("summary",{style:{...oi,fontSize:12,fontWeight:500,color:"var(--ink-3)",cursor:"pointer",marginBottom:8},children:"Error details"}),d.jsx("pre",{style:{...oi,fontSize:11,color:"var(--ink-3)",overflow:"auto",margin:0,opacity:.8},children:this.state.error.message})]}),d.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:n?d.jsxs(d.Fragment,{children:[d.jsx(Dr,{variant:"primary",size:"lg",fullWidth:!0,onClick:this.handleClearCacheAndReload,children:"Clear Cache & Reload"}),d.jsx(Dr,{variant:"outline",size:"lg",fullWidth:!0,onClick:this.handleReload,children:"Just Reload"})]}):d.jsx(Dr,{variant:"primary",size:"lg",fullWidth:!0,onClick:this.handleReload,children:"Reload Page"})})]})})}return this.props.children}}const II=Wy,ky=y.forwardRef(({className:t,...e},n)=>d.jsx(of,{ref:n,className:Ne("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));ky.displayName=of.displayName;const Sy=y.forwardRef(({className:t,...e},n)=>d.jsx(sf,{ref:n,className:Ne("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t),...e}));Sy.displayName=sf.displayName;const Cy=y.forwardRef(({className:t,...e},n)=>d.jsx(af,{ref:n,className:Ne("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Cy.displayName=af.displayName;const Dc=y.forwardRef(({className:t,...e},n)=>d.jsx("textarea",{className:Ne("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
565ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:n,...e}));Dc.displayName="Textarea";const Ba=[{id:"youtube-faq",name:"YouTube FAQ",endpoint:"app-help-bot",icon:d.jsx(Bl,{className:"h-4 w-4"})},{id:"guardrails",name:"Guardrails",endpoint:"guardrails-v2",icon:d.jsx($l,{className:"h-4 w-4"})}],Ey=Y.memo(({message:t})=>{const e=y.useDeferredValue(t.content);return d.jsx("div",{className:`flex ${t.role==="user"?"justify-end":"justify-start"}`,children:d.jsx("div",{className:`max-w-[85%] ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted"} rounded-xl px-3 py-2 text-sm`,children:t.role==="user"?d.jsx("p",{className:"whitespace-pre-wrap",children:t.content}):d.jsx(qo,{components:{p:n=>d.jsx("p",{className:"my-1.5 leading-relaxed",...n}),ul:n=>d.jsx("ul",{className:"list-disc pl-4 my-2 space-y-1",...n}),ol:n=>d.jsx("ol",{className:"list-decimal pl-4 my-2 space-y-1",...n}),li:n=>d.jsx("li",{className:"my-1 leading-relaxed",...n}),a:n=>d.jsx("a",{className:"underline text-primary",target:"_blank",rel:"noreferrer",...n}),code:({inline:n,children:r,...i})=>n?d.jsx("code",{className:"bg-background/50 rounded px-1",...i,children:r}):d.jsx("pre",{className:"bg-background/50 rounded p-2 overflow-auto text-xs my-1.5",...i,children:d.jsx("code",{children:r})})},children:e})})})},(t,e)=>t.message.content===e.message.content&&t.message.id===e.message.id);Ey.displayName="ChatMessage";function RI(){var N;const[t,e]=y.useState(!1),[n,r]=y.useState("youtube-faq"),[i,o]=y.useState({"youtube-faq":[],guardrails:[]}),[s,a]=y.useState({"youtube-faq":null,guardrails:null}),[l,c]=y.useState(""),[u,h]=y.useState(!1),p=y.useRef(null),f=y.useRef(null),{toast:m}=Vi(),{hasFeature:g,loading:x}=hr(),b=g("ai_coach")&&!x;y.useEffect(()=>{if(!b)return;const M=L=>{L.key==="j"&&L.ctrlKey&&!L.shiftKey&&!L.altKey&&(L.preventDefault(),e(P=>!P))};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[b]),y.useEffect(()=>{!b&&t&&e(!1)},[b,t]);const E=y.useCallback(async M=>{const{data:L}=await j.auth.getSession();if(!L.session)return;const{data:P}=await j.from("conversations").select("id").eq("bot_id",M).eq("user_id",L.session.user.id).order("updated_at",{ascending:!1}).limit(1);if(P&&P.length>0){const T=P[0].id;a(H=>({...H,[M]:T}));const{data:O}=await j.from("messages").select("*").eq("conversation_id",T).order("timestamp",{ascending:!0});if(O){const H=O.map(D=>({id:D.id,role:D.role,content:D.content,timestamp:new Date(D.timestamp)}));o(D=>({...D,[M]:H}))}}},[]);y.useEffect(()=>{t&&(E(n),setTimeout(()=>{var M;return(M=f.current)==null?void 0:M.focus()},100))},[t,n,E]),y.useEffect(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},[i,n]);const v=async M=>{if(s[M])return s[M];const{data:L}=await j.auth.getSession();if(!L.session)return null;const P=Ba.find(H=>H.id===M),{data:T,error:O}=await j.from("conversations").insert({user_id:L.session.user.id,bot_id:M,bot_name:(P==null?void 0:P.name)||M,title:"Quick Chat"}).select().single();return O||!T?(console.error("Failed to create conversation:",O),null):(a(H=>({...H,[M]:T.id})),T.id)},A=async()=>{var P,T,O,H,D;if(!l.trim()||u)return;const M=await v(n);if(!M){m({title:"Error",description:"Failed to create chat session",variant:"destructive"});return}const L={id:crypto.randomUUID(),role:"user",content:l.trim(),timestamp:new Date};o(z=>({...z,[n]:[...z[n],L]})),c(""),h(!0);try{await j.from("messages").insert({conversation_id:M,role:"user",content:L.content})}catch(z){console.error("Failed to save user message:",z)}try{const z=Ba.find(R=>R.id===n),ee=[...i[n],L].map(R=>({role:R.role,content:R.content})),{data:Q}=await j.auth.getSession(),F=(P=Q.session)==null?void 0:P.access_token,V=await fetch(Jf(z.endpoint),{method:"POST",headers:{"Content-Type":"application/json",apikey:Kr.ANON_KEY,...F?{Authorization:`Bearer ${F}`}:{}},body:JSON.stringify({messages:ee})});if(!V.ok){if(V.status===429)throw new Error("Rate limit exceeded. Try again in a moment.");if(V.status===402)throw new Error("Payment required. Add credits to your workspace.");let R=`HTTP ${V.status}: ${V.statusText}`;try{const w=await V.json();R=w.error||w.message||R}catch{}throw new Error(R)}const k=V.headers.get("content-type")||"";let pe="";if(k.includes("application/json")){const R=await V.json();if(pe=R.response||R.content||"",pe){const w={id:crypto.randomUUID(),role:"assistant",content:pe,timestamp:new Date};o(J=>({...J,[n]:[...J[n],w]}))}}else{const R=(T=V.body)==null?void 0:T.getReader();if(!R)throw new Error("No response body");const w=new TextDecoder;let J="";const te={id:crypto.randomUUID(),role:"assistant",content:"",timestamp:new Date};for(o(B=>({...B,[n]:[...B[n],te]}));;){const{done:B,value:X}=await R.read();
565if(B)break;J+=w.decode(X,{stream:!0});let ne;for(;(ne=J.indexOf(` 566`))!==-1;){let ue=J.slice(0,ne);if(J=J.slice(ne+1),ue.endsWith("\r")&&(ue=ue.slice(0,-1)),ue.startsWith(":")||ue.trim()===""||!ue.startsWith("data: "))continue;const je=ue.slice(6).trim();if(je==="[DONE]")break;try{const Ue=(D=(H=(O=JSON.parse(je).choices)==null?void 0:O[0])==null?void 0:H.delta)==null?void 0:D.content;Ue&&(pe+=Ue,o(We=>({...We,[n]:We[n].map((re,me)=>me===We[n].length-1&&re.role==="assistant"?{...re,content:pe}:re)})))}catch{J=ue+` 567`+J;break}}}}pe&&(await j.from("messages").insert({conversation_id:M,role:"assistant",content:pe}),await j.from("conversations").update({updated_at:new Date().toISOString()}).eq("id",M))}catch(z){console.error("Chat error:",z);const ee=z.message||"Failed to get response",Q=ee.includes("permanently locked"),F=Q||ee.includes("locked")||ee.includes("steal")||ee.includes("Warning:")||ee.includes("proprietary AI"),V={id:crypto.randomUUID(),role:"assistant",content:F?`ð **Account Blocked** 568 569${ee}`:`â **Error:** ${ee}`,timestamp:new Date};o(k=>({...k,[n]:[...k[n].filter(pe=>pe.content!==""||pe.role==="user"),V]})),Q?(xe.setString(Xe.accountLocked,"true"),await j.auth.signOut({scope:"local"})):F||m({title:"Error",description:ee,variant:"destructive"})}finally{h(!1)}},_=M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),A())},S=i[n]||[];return b?d.jsx(Gl,{open:t,onOpenChange:e,children:d.jsxs(ws,{className:"sm:max-w-[500px] h-[600px] flex flex-col p-0 gap-0",children:[d.jsx(vs,{className:"px-4 pt-4 pb-2 border-b",children:d.jsxs(ks,{className:"text-base flex items-center gap-2",children:["Quick Chat",d.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Ctrl+J"})]})}),d.jsxs(II,{value:n,onValueChange:r,className:"flex-1 flex flex-col min-h-0",children:[d.jsx(ky,{className:"mx-4 mt-2 grid grid-cols-2",children:Ba.map(M=>d.jsxs(Sy,{value:M.id,className:"flex items-center gap-1.5 text-xs",children:[M.icon,M.name]},M.id))}),d.jsxs(Cy,{value:n,className:"flex-1 flex flex-col min-h-0 m-0 mt-2",children:[d.jsx(Ss,{className:"flex-1 px-4",ref:p,children:d.jsxs("div",{className:"space-y-3 pb-4",children:[S.length===0?d.jsxs("div",{className:"text-center text-muted-foreground text-sm py-8",children:[d.jsx("p",{children:"Ask anything!"}),d.jsx("p",{className:"text-xs mt-1",children:n==="youtube-faq"?"Get answers about YouTube strategy and the platform":"Get feedback from your avatar's perspective"})]}):S.map(M=>d.jsx(Ey,{message:M},M.id)),u&&((N=S[S.length-1])==null?void 0:N.role)==="user"&&d.jsx("div",{className:"flex justify-start",children:d.jsx("div",{className:"bg-muted rounded-xl px-3 py-2",children:d.jsx(ut,{className:"h-4 w-4 animate-spin"})})})]})}),d.jsx("div",{className:"p-4 border-t",children:d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Dc,{ref:f,value:l,onChange:M=>c(M.target.value),onKeyDown:_,placeholder:"Type a message...",className:"min-h-[44px] max-h-[120px] resize-none text-sm",disabled:u}),d.jsx(Dr,{variant:"primary",iconOnly:!0,icon:u?ut:Fl,onClick:A,disabled:!l.trim()||u})]})})]})]})]})}):null}const OI=di({channel:di({channel_id:Tt().optional(),channel_name:Tt().optional(),channel_thumbnail:Tt().nullable().optional(),connected_at:Tt().optional()}).passthrough().nullable().optional(),connected:Lc().optional(),error:Tt().optional(),success:Lc().optional()}).passthrough(),PI=di({metadata:di({channelId:Tt().optional(),channelTitle:Tt().optional(),thumbnails:di({default:Tt().optional(),high:Tt().optional(),medium:Tt().optional()}).passthrough().optional(),title:Tt().optional(),viewCount:Xy().optional(),publishedAt:Tt().optional()}).passthrough().optional(),error:Tt().optional(),title:Tt().optional()}).passthrough(),wD=async()=>qi(Rt.youtubeGetConnection,{},{schema:OI,metadata:{feature:"youtube",operation:"getYoutubeConnectionResult"}}),DI=async t=>qi(Rt.fetchYoutubeMetadata,{videoUrl:t},{schema:PI,metadata:{feature:"youtube",operation:"fetchYoutubeMetadataResult",videoUrl:t}}),vD=async t=>qi(Rt.fetchYoutubeChannel,t,{metadata:{feature:"youtube",operation:"fetchYoutubeChannelResult"}}),kD=async()=>qi(Rt.youtubeChannelStats,{},{metadata:{feature:"youtube",operation:"getYoutubeChannelStatsResult"}}),SD=async()=>qi(Rt.youtubeContentBlueprint,{},{metadata:{feature:"youtube",operation:"getYoutubeContentBlueprintResult"}}),CD=async t=>zn(Rt.youtubeOauthCallback,t,{metadata:{feature:"youtube",operation:"completeYoutubeOauthCallback"}}),Ty="Video Bank",LI="Research Vision Board",BI=[Ty,LI],zI="vision";async function FI(t){var n,r;const e=(n=t.videoUrl)==null?void 0:n.trim();if(!e)return"error";try{const{data:{session:i}}=await j.auth.getSession(),o=(r=i==null?void 0:i.user)==null?void 0:r.id;if(!o)return"error";
569const{data:s}=await j.from("vision_board_videos").select("id").eq("user_id",o).in("board_name",BI).eq("video_url",e).limit(1);if(s&&s.length>0)return"duplicate";const{error:a}=await j.from("vision_board_videos").insert({user_id:o,board_name:Ty,board_type:zI,content_type:"video",title:t.title,thumbnail:t.thumbnailUrl??"",channel:t.channelName??"",video_url:e});if(a)throw a;return"saved"}catch(i){return console.error("[videoBank] saveVideoToBank failed",i),"error"}}function $I(){const[t,e]=y.useState(!1),[n,r]=y.useState({x:0,y:0}),[i,o]=y.useState(""),[s,a]=y.useState(""),[l,c]=y.useState(!1),[u,h]=y.useState(!1),{toast:p}=Vi(),[f,m]=y.useState(null),[g,x]=y.useState(!1),[b,E]=y.useState(!1),[v,A]=y.useState(""),[_,S]=y.useState([]),[N,M]=y.useState(!1),[L,P]=y.useState(""),T=y.useRef(null),O=y.useRef(null);y.useEffect(()=>{(async()=>{const{data:{session:ne}}=await j.auth.getSession();h(!!ne)})();const{data:{subscription:X}}=j.auth.onAuthStateChange((ne,ue)=>{h(!!ue)});return()=>X.unsubscribe()},[]);const H=B=>{const X=[/https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([^&\s]+)/,/https?:\/\/youtu\.be\/([^?\s]+)/,/https?:\/\/(?:www\.)?youtube\.com\/shorts\/([^?\s]+)/];for(const ne of X){const ue=B.match(ne);if(ue)return ue[0]}return null},[D,z]=y.useState("default"),ee=y.useCallback(B=>{var je;if(!u||typeof window<"u"&&((je=window.matchMedia)!=null&&je.call(window,"(pointer: coarse)").matches))return;const X=B.target;if(X.closest("a[href]"))return;if(X.closest('[data-context-menu="none"]')){e(!1);return}const ne=window.getSelection(),ue=ne==null?void 0:ne.toString().trim();if(ue&&ue.length>0){B.preventDefault();const Le=!!X.closest('[data-context-menu="expectations-only"]');z(Le?"expectations-only":"default");const Ue=Le?null:H(ue);m(Ue);const We=180,re=Le?50:Ue?165:130,me=Math.min(B.clientX,window.innerWidth-We-10),he=Math.min(B.clientY,window.innerHeight-re-10);r({x:me,y:he}),o(ue.slice(0,500)),a(ue),e(!0)}else e(!1),m(null)},[u]),Q=y.useCallback(()=>{e(!1)},[]),F=y.useCallback(B=>{B.key==="Escape"&&e(!1)},[]);y.useEffect(()=>(document.addEventListener("contextmenu",ee),document.addEventListener("keydown",F),()=>{document.removeEventListener("contextmenu",ee),document.removeEventListener("keydown",F)}),[ee,F]),y.useEffect(()=>{if(!t)return;const B=window.setTimeout(()=>document.addEventListener("click",Q),0);return()=>{window.clearTimeout(B),document.removeEventListener("click",Q)}},[t,Q]);const V=async()=>{if(!(!i||l)){c(!0);try{const{data:{user:B}}=await j.auth.getUser();if(!B){p({title:"Not signed in",description:"Please sign in to save ideas",variant:"destructive"}),e(!1),c(!1);return}const{data:X}=await j.from("vision_board_videos").select("id").eq("user_id",B.id).eq("title",i).eq("content_type","title").eq("board_name","Idea Bank").maybeSingle();if(X){p({title:"Already saved",description:"This title already exists in your Research Bank"}),e(!1),c(!1);return}const{error:ne}=await j.from("vision_board_videos").insert({user_id:B.id,title:i,board_name:"Idea Bank",content_type:"title",channel:"Quick Add",thumbnail:""});if(ne)throw ne;p({title:"Added to Title Ideas!",description:`"${i.slice(0,50)}${i.length>50?"...":""}" saved`})}catch(B){console.error("Error saving idea:",B),p({title:"Error saving",description:"Please try again",variant:"destructive"})}finally{e(!1),c(!1)}}},k=async()=>{if(!(!f||g)){x(!0);try{const{data:B,error:X}=await DI(f);if(X)throw X;const{metadata:ne}=B,ue=await FI({videoUrl:f,title:ne.title,thumbnailUrl:ne.thumbnails.high||ne.thumbnails.medium||ne.thumbnails.default,channelName:ne.channelTitle});p(ue==="error"?{title:"Error saving video",description:"Please sign in and try again",variant:"destructive"}:ue==="duplicate"?{title:"Already saved",description:"This video is already in your Video Bank"}:{title:"Added to Video Bank!",description:`"${ne.title.slice(0,40)}${ne.title.length>40?"...":""}" saved`})}catch(B){console.error("Error saving video:",B),p({title:"Error saving video",description:"Please try again",variant:"destructive"})}finally{e(!1),x(!1)}}},pe=async()=>{try{await navigator.clipboard.writeText(s),p({title:"Copied!",description:"Text copied to clipboard"})}catch(B){console.error("Copy failed:",B)}e(!1)},R=()=>{S([{role:"context",content:i}]),A(""),P(""),e(!1),E(!0),setTimeout(()=>{var B;return(B=T.current)==null?void 0:B.focus()},100)},w=()=>{O.current&&(O.current.scrollTop=O.current.scrollHeight)},J=async()=>{var ne,ue,je,Le,Ue;if(!v.trim()||N)return;const B={role:"user",content:v.trim()},X=[..._,B];S(X),A(""),M(!0),P(""),setTimeout(w,50);try{const{data:{session:We}}=await j.auth.getSession();if(!(We!=null&&We.access_token)){p({title:"Not signed in",description:"Please sign in to use this feature",variant:"destructive"}),M(!1);return}
569const re=((ne=_.find(Ee=>Ee.role==="context"))==null?void 0:ne.content)||"",me=X.filter(Ee=>Ee.role!=="context").map((Ee,De)=>De===0&&Ee.role==="user"?{role:Ee.role,content:`Regarding this text: "${re}" 570 571${Ee.content}`}:{role:Ee.role,content:Ee.content}),he=await fetch(Jf(Rt.appHelpBot),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${We.access_token}`,apikey:Kr.ANON_KEY},body:JSON.stringify({messages:me})});if(!he.ok)throw he.status===429?new Error("Rate limit exceeded. Please try again later."):he.status===402?new Error("Service temporarily unavailable."):new Error("Failed to get response");const ae=(ue=he.body)==null?void 0:ue.getReader();if(!ae)throw new Error("No response body");const ke=new TextDecoder;let Ie="",be="";for(;;){const{done:Ee,value:De}=await ae.read();if(Ee)break;Ie+=ke.decode(De,{stream:!0});let G;for(;(G=Ie.indexOf(` 572`))!==-1;){let le=Ie.slice(0,G);if(Ie=Ie.slice(G+1),le.endsWith("\r")&&(le=le.slice(0,-1)),le.startsWith(":")||le.trim()===""||!le.startsWith("data: "))continue;const de=le.slice(6).trim();if(de==="[DONE]")break;try{const W=(Ue=(Le=(je=JSON.parse(de).choices)==null?void 0:je[0])==null?void 0:Le.delta)==null?void 0:Ue.content;W&&(be+=W,P(be),setTimeout(w,10))}catch{Ie=le+` 573`+Ie;break}}}S([...X,{role:"assistant",content:be}]),P("")}catch(We){console.error("Ask error:",We);const re=We instanceof Error?We.message:"Failed to get response";S([...X,{role:"assistant",content:re}]),P(""),p({title:"Error",description:re,variant:"destructive"})}finally{M(!1)}},te=B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),J())};return!t&&!b?null:d.jsxs(d.Fragment,{children:[t&&d.jsxs("div",{className:"fixed z-[9999] min-w-[160px] rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95",style:{left:n.x,top:n.y},onClick:B=>B.stopPropagation(),children:[D!=="expectations-only"&&d.jsxs("button",{onClick:V,disabled:l,className:"relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:opacity-50",children:[l?d.jsx(ut,{className:"mr-2 h-4 w-4 animate-spin"}):d.jsx(Va,{className:"mr-2 h-4 w-4"}),l?"Saving...":"Add to Ideas"]}),D!=="expectations-only"&&f&&d.jsxs("button",{onClick:k,disabled:g,className:"relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:opacity-50",children:[g?d.jsx(ut,{className:"mr-2 h-4 w-4 animate-spin"}):d.jsx(jf,{className:"mr-2 h-4 w-4"}),g?"Saving...":"Add to Video Bank"]}),D!=="expectations-only"&&d.jsxs("button",{onClick:pe,className:"relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",children:[d.jsx(kf,{className:"mr-2 h-4 w-4"}),"Copy"]}),D!=="expectations-only"&&eI()>0&&d.jsxs("button",{onClick:()=>{window.dispatchEvent(new CustomEvent(as,{detail:{text:s||i}})),e(!1)},className:"relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",children:[d.jsx(zl,{className:"mr-2 h-4 w-4"}),"Add to document"]}),(D==="expectations-only"||/^\/project\/[^/]+/.test(window.location.pathname))&&d.jsxs("button",{onClick:()=>{if(D==="expectations-only")window.dispatchEvent(new CustomEvent("run-expectation-check",{detail:{plan:i}}));else{const B=`Does this basic plan match what a viewer might expect from the thumbnail and title? 574 575${i}`;window.dispatchEvent(new CustomEvent("open-right-panel")),window.dispatchEvent(new CustomEvent("rp-prefill",{detail:{prompt:B,hidden:!1}}))}e(!1)},className:"relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",children:[d.jsx(Ux,{className:"mr-2 h-4 w-4"}),"Expectations check"]}),D!=="expectations-only"&&d.jsxs("button",{onClick:R,className:"relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",children:[d.jsx(Gc,{
575className:"mr-2 h-4 w-4"}),"Ask FAQ Bot"]})]}),d.jsx(Gl,{open:b,onOpenChange:E,children:d.jsxs(ws,{className:"max-w-lg h-[500px] flex flex-col p-0",children:[d.jsxs(vs,{className:"px-6 pt-6 pb-2 space-y-1",children:[d.jsxs(ks,{className:"flex items-center gap-2",children:[d.jsx(Gc,{className:"h-5 w-5"}),"Ask FAQ Bot"]}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Ask general questions here"}),d.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-primary dark:text-primary/80",children:[d.jsx(us,{className:"h-3.5 w-3.5"}),d.jsx("span",{children:"Personalized with your Brain data"})]})]}),d.jsx(Ss,{className:"flex-1 px-6",ref:O,children:d.jsxs("div",{className:"space-y-3 pb-4",children:[_.map((B,X)=>d.jsx("div",{className:`flex ${B.role==="user"?"justify-end":"justify-start"}`,children:d.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 ${B.role==="user"?"bg-primary text-primary-foreground":B.role==="context"?"bg-muted/70 border border-border":"bg-muted"}`,children:B.role==="context"?d.jsxs("div",{children:[d.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground font-medium",children:"Context"}),d.jsxs("p",{className:"text-sm mt-1 italic",children:['"',B.content,'"']})]}):B.role==="user"?d.jsx("p",{className:"text-sm whitespace-pre-wrap",children:B.content}):d.jsx("div",{className:"text-sm leading-6",children:d.jsx(qo,{components:{h1:ne=>d.jsx("h1",{className:"text-base font-semibold mt-2 mb-1",...ne}),h2:ne=>d.jsx("h2",{className:"text-base font-semibold mt-2 mb-1",...ne}),h3:ne=>d.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1",...ne}),p:ne=>d.jsx("p",{className:"text-sm leading-6 my-2",...ne}),ul:ne=>d.jsx("ul",{className:"list-disc pl-5 my-2 space-y-1",...ne}),ol:ne=>d.jsx("ol",{className:"list-decimal pl-5 my-2 space-y-1",...ne}),li:ne=>d.jsx("li",{className:"my-0.5",...ne}),hr:()=>d.jsx("hr",{className:"my-3 border-muted-foreground/30"}),a:ne=>d.jsx("a",{className:"underline text-primary",target:"_blank",rel:"noreferrer",...ne}),code:({inline:ne,children:ue,...je})=>ne?d.jsx("code",{className:"bg-background/50 rounded px-1",...je,children:ue}):d.jsx("pre",{className:"bg-background/50 rounded p-2 overflow-auto text-xs",...je,children:d.jsx("code",{children:ue})})},children:B.content})})})},X)),N&&L&&d.jsx("div",{className:"flex justify-start",children:d.jsx("div",{className:"max-w-[85%] rounded-lg px-3 py-2 bg-muted",children:d.jsx("div",{className:"text-sm leading-6",children:d.jsx(qo,{components:{h1:B=>d.jsx("h1",{className:"text-base font-semibold mt-2 mb-1",...B}),h2:B=>d.jsx("h2",{className:"text-base font-semibold mt-2 mb-1",...B}),h3:B=>d.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1",...B}),p:B=>d.jsx("p",{className:"text-sm leading-6 my-2",...B}),ul:B=>d.jsx("ul",{className:"list-disc pl-5 my-2 space-y-1",...B}),ol:B=>d.jsx("ol",{className:"list-decimal pl-5 my-2 space-y-1",...B}),li:B=>d.jsx("li",{className:"my-0.5",...B}),hr:()=>d.jsx("hr",{className:"my-3 border-muted-foreground/30"}),a:B=>d.jsx("a",{className:"underline text-primary",target:"_blank",rel:"noreferrer",...B}),code:({inline:B,children:X,...ne})=>B?d.jsx("code",{className:"bg-background/50 rounded px-1",...ne,children:X}):d.jsx("pre",{className:"bg-background/50 rounded p-2 overflow-auto text-xs",...ne,children:d.jsx("code",{children:X})})},children:L})})})}),N&&!L&&d.jsx("div",{className:"flex justify-start",children:d.jsx("div",{className:"bg-muted rounded-lg px-3 py-2",children:d.jsx(ut,{className:"h-4 w-4 animate-spin"})})})]})}),d.jsxs("div",{className:"flex gap-2 p-4 border-t",children:[d.jsx(Dc,{ref:T,value:v,onChange:B=>A(B.target.value),onKeyDown:te,placeholder:"Ask a question about this text...",className:"min-h-[50px] max-h-[100px] resize-none",disabled:N}),d.jsx(Dr,{variant:"primary",iconOnly:!0,icon:N?ut:Fl,onClick:J,disabled:!v.trim()||N})]})]})})]})}const K=t=>y.lazy(async()=>{try{return await t()}catch(e){console.warn("Module load failed, retrying...",e),await new Promise(n=>setTimeout(n,500));try{return await t()}catch(n){throw console.error("Module load retry failed",n),window.location.reload(),n}}}),VI=K(()=>U(()=>import("./Login-Bb-ilnbv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),WI=K(()=>U(()=>import("./Signup-OxiT418_.js"),__vite__mapDeps([9,1,2,3,4,10,11,6,7,8]))),HI=K(()=>U(()=>import("./Account-ueFZCuYe.js"),__vite__mapDeps([12,1,2,8,10,13,14,7,15,16,17,18,19,20,21,22]))),qI=K(()=>U(()=>import("./YouTubeCallback-BLZNjUhe.js"),__vite__mapDeps([23,1,2,8,18,17,7]))),UI=K(()=>U(()=>import("./ResetPassword-qCPAL7FV.js"),__vite__mapDeps([24,1,2,3,10,4,6,7,8]))),KI=K(()=>U(()=>import("./SetPassword-CfHhWoEG.js"),__vite__mapDeps([25,1,2,3,4,10,11,6,7,8]))),YI=K(()=>U(()=>import("./ForgotPassword-DByjtv4i.js"),__vite__mapDeps([26,1,2,3,4,27,28,7,8]))),JI=K(()=>U(()=>import("./NotFound-D6I-qL4Y.js"),__vite__mapDeps([29,1,2,7,8]))),GI=K(()=>U(()=>import("./ThumbnailBoard-N0F1CBCR.js"),__vite__mapDeps([30,1,2,31,32,33,34,35,36,37,38,39,40,7,28,41,6,8]))),QI=K(()=>U(()=>
575import("./DoodleThumbnailBoard-DZ4G3A3S.js"),__vite__mapDeps([42,1,2,31,32,33,43,7,34,35,36,37,28,41,22,6,8]))),XI=K(()=>U(()=>import("./VisionBoard-DH2_SAxt.js"),__vite__mapDeps([44,1,2,31,3,45,32,33,46,47,48,40,7,49,50,51,52,41,5,8]))),Ph=K(()=>U(()=>import("./BoardSelection-m15tEWFc.js"),__vite__mapDeps([53,2,1,7,8]))),ZI=K(()=>U(()=>import("./SkyscraperBot-BmxKYEMc.js"),__vite__mapDeps([54,1,2,3,31,47,33,35,40,7,28,41,8]))),eR=K(()=>U(()=>import("./PointBot-DNLFvJsO.js"),__vite__mapDeps([55,1,2,56,57,58,8,7]))),tR=K(()=>U(()=>import("./IntroBot-DnlyMsEa.js"),__vite__mapDeps([59,1,2,57,60,31,58,8,61,35,36,37,62,52,63,7]))),nR=K(()=>U(()=>import("./ScriptBot-CKiIgnHO.js"),__vite__mapDeps([64,1,2,57,65,31,63,66,28,7,8]))),rR=K(()=>U(()=>import("./BrainData-LvdXzJPA.js"),__vite__mapDeps([67,1,2,68,8,58,69,70,71,72,73,7,74,41,75,76,52,5,77,78]))),iR=K(()=>U(()=>import("./DataBot-Buh74DFH.js"),__vite__mapDeps([79,1,2,31,3,80,81,63,61,28,82,71,50,7,8]))),oR=K(()=>U(()=>import("./TwoPagePlannerBot-Csjq8fvQ.js"),__vite__mapDeps([83,1,2,31,57,84,18,85,86,62,72,52,87,88,89,7,90,91,3,80,63,28,8]))),Dh=K(()=>U(()=>import("./Projects-CGDJCcNd.js"),__vite__mapDeps([92,1,2,8,93,94,95,96,97,98,41,86,99,100,18,51,73,7]))),sR=K(()=>U(()=>import("./ProjectWorkflow-D-TinkAH.js"),__vite__mapDeps([101,1,2,31,3,81,102,33,90,76,71,32,74,7,80,63,103,52,60,58,8,61,35,36,37,62,65,66,18,84,85,86,72,87,88,89,91,41,104,73,28,105,106,50,38,107,21,95,96,97,98,99,20,40,108,46,109,110]))),aR=K(()=>U(()=>import("./ChannelAnalytics-BVR6ctU5.js"),__vite__mapDeps([111,1,2,31,13,89,71,56,7,8]))),Lh=K(()=>U(()=>import("./Analytics-DZkLqOhA.js"),__vite__mapDeps([112,1,2,113,7,88,46,114,31,115,116,117,89,118,27,119,120,14,20,66,121,122,28,8]))),lR=K(()=>U(()=>import("./WebhookTest-GsNy4pkg.js"),__vite__mapDeps([123,1,2,3,31,81,7,8]))),cR=K(()=>U(()=>import("./LogoExport-Bfz_ysCi.js"),__vite__mapDeps([124,1,2,125,91,7,8]))),uR=K(()=>U(()=>import("./ValidationTest-D_hkDAz1.js"),__vite__mapDeps([126,1,2,31,90,43,7,99,100,91,28,8]))),dR=K(()=>U(()=>import("./HireHumanPage-Bl9YuCD2.js"),__vite__mapDeps([127,1,2,5,7,8]))),Bh=K(()=>U(()=>import("./LiveReviews-B0gw_Ngg.js"),__vite__mapDeps([128,1,2,129,130,97,18,108,41,76,7,8]))),hR=K(()=>U(()=>import("./CohortAssignments-C9BIAElo.js"),__vite__mapDeps([131,1,2,8,132,57,56,133,134,135,136,18,5,7]))),fR=K(()=>U(()=>import("./CohortRecordings-DKpFhBhJ.js"),__vite__mapDeps([137,1,2,8,57,56,96,97,98,132,138,32,33,110,51,6,37,139,140,7,141,134,52]))),pR=K(()=>U(()=>import("./CohortCommunity-aaK_PrTC.js"),__vite__mapDeps([142,1,2,8,138,32,33,110,51,6,37,139,140,7,57,41]))),mR=K(()=>U(()=>import("./FunnelTracker-xHRfB5_f.js"),__vite__mapDeps([143,1,2,8,57,80,46,32,33,3,81,102,28,52,41,51,82,21,144,100,7]))),gR=K(()=>U(()=>import("./EmailUnsubscribe-DHpeN1uh.js"),__vite__mapDeps([145,1,2,7,8]))),yR=K(()=>U(()=>import("./CohortThread-TyFTKXkf.js"),__vite__mapDeps([146,1,2,8,138,32,33,110,51,6,37,139,140,7,57,141,28]))),xR=K(()=>U(()=>import("./CohortReviewBoard-Cowzqfz5.js"),__vite__mapDeps([147,1,2,8,57,56,134,148,97,133,149,5,33,7]))),bR=K(()=>U(()=>import("./CohortProgress-BMNp8f_Q.js"),__vite__mapDeps([150,1,2,8,57,56,134,148,97,133,135,149,5,33,7]))),wR=K(()=>U(()=>import("./CohortSetup-DhKPzXtF.js"),__vite__mapDeps([151,1,2,8,57,56,15,134,148,97,7,106,152,41]))),vR=K(()=>U(()=>import("./Onboarding-CQ0W2InO.js"),__vite__mapDeps([153,1,2,154,16,8,68,58,69,70,71,72,73,7,98,155,5,41,77,87,88,86,50,27,17,139,66,156,37,157,28,78,140,52,100]))),kR=K(()=>U(()=>import("./CourseResources-CJ8OiXYL.js"),__vite__mapDeps([158,1,2,3,159,5,160,7,8]))),SR=K(()=>U(()=>import("./DocsHub-CDsNrqXe.js"),__vite__mapDeps([161,1,2,109,93,162,39,90,163,3,7,8]))),CR=K(()=>U(()=>import("./SupportTickets-MbUjueFF.js"),__vite__mapDeps([164,1,2,56,8,114,31,3,57,63,104,165,166,167,37,7,89,168,70,144,27,76]))),ER=K(()=>U(()=>import("./Announcements-DureCozK.js"),__vite__mapDeps([169,1,2,56,57,3,31,81,104,7,15,41,170,89,73,8]))),TR=K(()=>U(()=>import("./Settings-iVZT3SDE.js"),__vite__mapDeps([171,1,2,56,57,31,15,3,172,156,100,173,66,7,8]))),_R=K(()=>U(()=>import("./GrowthProof-DgYvjF4h.js"),__vite__mapDeps([174,1,2,8,56,57,31,104,165,91,72,7]))),AR=K(()=>U(()=>import("./TrendReports-lRTeVBcr.js"),__vite__mapDeps([175,1,2,8,166,56,57,31,104,99,7]))),MR=K(()=>U(()=>import("./AdminDashboard-B_pPxrGj.js"),__vite__mapDeps([176,1,2,56,57,31,115,116,7,177,170,19,120,66,99,178,173,122,168,179,8]))
575),NR=K(()=>U(()=>import("./ChannelRegistry-EFPM2TCG.js"),__vite__mapDeps([180,1,2,56,57,31,3,104,165,91,181,5,7,8]))),jR=K(()=>U(()=>import("./OutlierDatabase-DvJPxBcS.js"),__vite__mapDeps([182,1,2,56,57,31,3,104,165,91,181,5,7,8]))),IR=K(()=>U(()=>import("./NicheReports-B66cxMLa.js"),__vite__mapDeps([183,1,2,56,57,31,104,91,5,7,8]))),RR=K(()=>U(()=>import("./CourseManager-PIfEO60j.js"),__vite__mapDeps([184,1,2,56,57,31,63,3,81,15,102,33,166,80,46,93,162,41,91,89,73,163,108,50,104,52,6,7,8]))),OR=K(()=>U(()=>import("./LiveReviewsAdmin-NlPeVvxv.js"),__vite__mapDeps([185,1,2,97,130,56,57,31,165,3,81,104,41,6,73,7,8]))),PR=K(()=>U(()=>import("./Integrations-BpuWKKPv.js"),__vite__mapDeps([186,1,2,56,57,31,3,81,166,187,49,104,6,5,91,7,8]))),DR=K(()=>U(()=>import("./AccessRights-B__1jfGX.js"),__vite__mapDeps([188,1,2,8,56,57,3,81,109,104,166,187,31,49,91,105,41,7]))),LR=K(()=>U(()=>import("./AiSpendControl-U46-S41o.js"),__vite__mapDeps([189,1,2,8,56,57,114,31,3,14,166,121,190,122,191,78,7]))),BR=K(()=>U(()=>import("./VideoInsights-5D0pquAj.js"),__vite__mapDeps([192,1,2,56,57,31,165,39,109,166,89,78,7,8]))),zR=K(()=>U(()=>import("./ConversationBrowser-C9pbNAIR.js"),__vite__mapDeps([193,1,2,56,57,31,3,39,104,66,89,70,7,8]))),FR=K(()=>U(()=>import("./Testimonials-GTDE4RjE.js"),__vite__mapDeps([194,1,2,56,57,31,165,15,195,173,3,81,105,93,162,41,6,7,8]))),$R=K(()=>U(()=>import("./SalesBotConversations-DyMTdy-F.js"),__vite__mapDeps([196,1,2,56,57,31,3,7,91,66,70,8]))),VR=K(()=>U(()=>import("./BannedUsers-DwoRJ5nf.js"),__vite__mapDeps([197,1,2,56,57,31,3,190,41,179,121,7,8]))),WR=K(()=>U(()=>import("./Users-C_1-FeH8.js"),__vite__mapDeps([198,1,2,8,56,57,31,3,165,104,166,114,119,116,7,120,190,100,136,14,191,46,80,5]))),HR=K(()=>U(()=>import("./PricingManager-D8QhfKhj.js"),__vite__mapDeps([199,1,2,88,3,81,31,7,8]))),qR=K(()=>U(()=>import("./FunnelAudit-DgR8eH2j.js"),__vite__mapDeps([200,1,2,56,57,31,3,81,80,117,104,52,28,7,8]))),UR=K(()=>U(()=>import("./OfferCreator-DhoyVSgD.js").then(t=>t.O),__vite__mapDeps([201,1,2,8]))),KR=K(()=>U(()=>import("./ChannelAuditWizard-X1XhwhkU.js"),__vite__mapDeps([202,1,2,88,3,81,109,18,52,89,28,190,100,7,8]))),YR=K(()=>U(()=>import("./FreeTools-CRH4dkRb.js"),__vite__mapDeps([203,1,2,129,130,97,18,108,41,204,205,49,52,7,8]))),JR=K(()=>U(()=>import("./ErrorDashboard-LZhLxpu4.js"),__vite__mapDeps([206,1,2,113,7,88,46,114,31,115,116,8,165,3,104,28,121,181]))),GR=K(()=>U(()=>import("./ResearchWrapper-NXPJ59XO.js"),__vite__mapDeps([207,1,2,95,96,97,98,8,155,5,41,77,87,88,86,50,70,27,17,139,66,156,71,37,157,28,78,73,3,31,63,46,47,33,80,35,82,7,45,104,32,81,48,93,162,58,49,173,52,51,89,90,118,159,74,99,85,40,108,94,76]))),QR=K(()=>U(()=>import("./AiAssistant-BK7W3jWA.js"),__vite__mapDeps([208,1,2,41,37,152,50,76,52,73,7,8])));K(()=>U(()=>import("./CoursePlayer-BoL9Q3R6.js"),__vite__mapDeps([209,1,2,85,173,99,33,37,103,177,46,109,81,90,31,117,7,8])));const XR=K(()=>U(()=>import("./PremiumCoursePlayer-Ci6hZS_W.js"),__vite__mapDeps([210,1,2,63,163,46,91,81,195,173,90,107,109,31,103,117,177,18,17,100,99,5,159,96,97,98,89,160,154,16,8,68,58,69,70,71,72,73,7,155,41,77,87,88,86,50,27,139,66,156,37,157,28,78,140,52]))),ZR=K(()=>U(()=>import("./MyTickets-Bp1qCEJX.js"),__vite__mapDeps([211,1,2,167,37,7,69,41,89,18,8]))),eO=K(()=>U(()=>import("./AffiliateDashboard-BA-4kaTj.js"),__vite__mapDeps([212,1,2,57,56,75,8,20,7]))),tO=K(()=>U(()=>import("./StoryOSLanding-u2Frf3BJ.js"),__vite__mapDeps([213,1,2,214,31,98,109,4,13,215,66,172,173,52,178,20,72,157,50,99,7,8]))),zh=K(()=>U(()=>import("./StoryOS2-CCfT-5-y.js"),__vite__mapDeps([216,1,2,172,215,217,4,214,7,8]))),nO=K(()=>U(()=>import("./Free-FscgEr60.js"),__vite__mapDeps([218,1,2,205,219,21,7,8]))),rO=K(()=>U(()=>import("./Free2-stLcZdT8.js"),__vite__mapDeps([220,1,2,217,205,219,21,7,8]))),iO=K(()=>U(()=>import("./StoryOSFreeThankYou-Bea0sq8H.js"),__vite__mapDeps([221,1,2,4,215,27,21,7,8]))),oO=K(()=>U(()=>import("./FreeOfferTool-C_E8wogY.js"),__vite__mapDeps([222,1,2,217,18,7,8]))),sO=K(()=>U(()=>import("./FreeOfferToolThankYou-BzsZ8f4n.js"),__vite__mapDeps([223,1,2,224,215,21,7,8]))),aO=K(()=>U(()=>import("./TrillionDollarStrategy-CdftXISc.js"),__vite__mapDeps([225,1,2,217]))),lO=K(()=>U(()=>import("./TrillionLive-BaRS1yWH.js"),__vite__mapDeps([226,1,2]))),cO=K(()=>U(()=>import("./Masterclass-B7eyU3yJ.js"),__vite__mapDeps([227,1,2,224]))),uO=K(()=>U(()=>import("./LaunchRoom-BbNMZvL5.js"),__vite__mapDeps([228,1,2,217,229]))),dO=K(()=>U(()=>import("./LaunchRoomThankYou-MntwEFNA.js"),__vite__mapDeps([230,1,2,215,27,21,170,7,8,229]))),hO=K(()=>U(()=>import("./LaunchRoomApplicationThankYou-CSph6odK.js"),__vite__mapDeps([231,1,2,215,27,21,7,8,229]))),fO=K(()=>U(()=>import("./LaunchRoomWaitlistThankYou-Ca5B1-Zs.js"),__vite__mapDeps([232,1,2,27,7,8,229]))),pO=K(()=>U(()=>import("./PrivacyPolicy-CuOGtWlU.js"),__vite__mapDeps([233,1,2,4,215,28,7,8]))),mO=K(()=>U(()=>import("./TermsOfService-E-Mkojjm.js"),__vite__mapDeps([234,1,2,4,215,28,7,8]))),gO=K(()=>U(()=>import("./ThankYou-Bj179aqo.js"),__vite__mapDeps([235,1,2,4,215,27,89,7,8]))),yO=K(()=>U(()=>import("./ApplyThankYou--8S2VkUE.js"),__vite__mapDeps([236,1,2,4,89,21,7,8]))),xO=K(()=>U(()=>import("./WorkWithEd-DEnnXSN2.js"),__vite__mapDeps([237,1,2,7,8]))),bO=K(()=>U(()=>import("./StoryOSElite-tbqSrt9Q.js"),__vite__mapDeps([238,1,2]))),wO=K(()=>U(()=>import("./GrowthPartnerships-DhEdckYD.js"),__vite__mapDeps([239,1,2,7,8]))),vO=K(()=>U(()=>import("./GrowthPartnershipsThankYou-CHc4Jv64.js"),__vite__mapDeps([240,1,2,27,7,8]))),kO=K(()=>U(()=>import("./GrowthPartnershipsNewClient-B2qvQc2Z.js"),__vite__mapDeps([241,1,2,224,242,140,7,8]))),SO=K(()=>U(()=>import("./MasterclassPage-3d1L1-QR.js"),__vite__mapDeps([243,1,2,204,205,7,8]))),CO=K(()=>U(()=>import("./AccountLocked-DzmyVvRZ.js"),__vite__mapDeps([244,1,2,215,21,7,8]))),EO=K(()=>U(()=>import("./LateCheckout-z2zgaRmh.js"),__vite__mapDeps([245,1,2,173,27,37,170,52,7,8]))),TO=K(()=>U(()=>import("./WaitlistThankYou-C1U0aXFD.js"),__vite__mapDeps([246,1,2,4,27,7,8]))),_O=K(()=>U(()=>import("./WaitlistThankYouNew-zdUobmHW.js"),__vite__mapDeps([247,1,2,4,242,27,7,8]))),AO=()=>{const t=It(),e=new URLSearchParams(t.search),n=new URLSearchParams(t.hash.startsWith("#")?t.hash.slice(1):t.hash),r=e.get("type")??n.get("type"),i=!!e.get("
575code"),o=!!n.get("access_token")&&r==="recovery",s=r==="recovery"&&(i||o),a=t.pathname===C.home||t.pathname===C.login;return!s||!a?null:d.jsx(et,{to:{pathname:C.resetPassword,search:t.search,hash:t.hash},replace:!0})},MO=()=>{MI(),NI();const t=It();return y.useEffect(()=>{const e=gf(t);lx(e),wx(e)},[t.pathname,t.search,t.hash]),d.jsxs(d.Fragment,{children:[d.jsx(AO,{}),d.jsx(RI,{}),d.jsx($I,{}),d.jsx(jI,{children:d.jsx(y.Suspense,{fallback:d.jsx("div",{className:"flex items-center justify-center min-h-screen",children:d.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"})}),children:d.jsxs(Yy,{children:[d.jsx($,{path:C.home,element:d.jsx(zh,{})}),d.jsx($,{path:C.group1,element:d.jsx(tO,{})}),d.jsx($,{path:C.storyos2,element:d.jsx(zh,{})}),d.jsx($,{path:C.free,element:d.jsx(ro,{children:d.jsx(nO,{})})}),d.jsx($,{path:C.free2,element:d.jsx(ro,{children:d.jsx(rO,{})})}),d.jsx($,{path:C.storyosFreeThankYou,element:d.jsx(ro,{children:d.jsx(iO,{})})}),d.jsx($,{path:C.freeOfferTool,element:d.jsx(oO,{})}),d.jsx($,{path:C.freeOfferToolThankYou,element:d.jsx(sO,{})}),d.jsx($,{path:C.trillionDollarStrategy,element:d.jsx(aO,{})}),d.jsx($,{path:C.trillionLive,element:d.jsx(lO,{})}),d.jsx($,{path:C.masterclassPage,element:d.jsx(cO,{})}),d.jsx($,{path:C.launchRoom,element:d.jsx(uO,{})}),d.jsx($,{path:C.launchRoomThankYou,element:d.jsx(dO,{})}),d.jsx($,{path:C.launchRoomApplicationThankYou,element:d.jsx(hO,{})}),d.jsx($,{path:C.launchRoomWaitlistThankYou,element:d.jsx(fO,{})}),d.jsx($,{path:C.privacy,element:d.jsx(pO,{})}),d.jsx($,{path:C.terms,element:d.jsx(mO,{})}),d.jsx($,{path:C.emailUnsubscribe,element:d.jsx(gR,{})}),d.jsx($,{path:C.thankYou,element:d.jsx(gO,{})}),d.jsx($,{path:C.applyThankYou,element:d.jsx(yO,{})}),d.jsx($,{path:C.workWithEd,element:d.jsx(xO,{})}),d.jsx($,{path:C.storyOSElite,element:d.jsx(bO,{})}),d.jsx($,{path:C.growthPartnerships,element:d.jsx(wO,{})}),d.jsx($,{path:C.growthPartnershipsThankYou,element:d.jsx(vO,{})}),d.jsx($,{path:C.growthPartnershipsNewClient,element:d.jsx(kO,{})}),d.jsx($,{path:C.accountLocked,element:d.jsx(CO,{})}),d.jsx($,{path:C.waitlistThankYou,element:d.jsx(_O,{})}),d.jsx($,{path:C.waitlistThankYouMarch,element:d.jsx(TO,{})}),d.jsx($,{path:C.masterclassPattern,element:d.jsx(wt,{children:d.jsx(SO,{})})}),d.jsx($,{path:C.login,element:d.jsx(VI,{})}),d.jsx($,{path:C.signup,element:d.jsx(WI,{})}),d.jsx($,{path:C.setPassword,element:d.jsx(ro,{waitForAuth:!0,children:d.jsx(KI,{})})}),d.jsx($,{path:C.forgotPassword,element:d.jsx(YI,{})}),d.jsx($,{path:C.resetPassword,element:d.jsx(UI,{})}),d.jsxs($,{element:d.jsx(wt,{children:d.jsx(TI,{})}),children:[d.jsx($,{path:C.dashboard,element:d.jsx(M1,{})}),d.jsx($,{path:C.account,element:d.jsx(HI,{})}),d.jsx($,{path:C.brainData,element:d.jsx(Ae,{feature:"brain",children:d.jsx(rR,{})})}),d.jsx($,{path:C.projects,element:d.jsx(Ae,{feature:"videos",children:d.jsx(Dh,{})})}),d.jsx($,{path:C.videos,element:d.jsx(Ae,{feature:"videos",children:d.jsx(Dh,{})})}),d.jsx($,{path:C.projectPattern,element:d.jsx(Ae,{feature:"videos",children:d.jsx(sR,{})})}),d.jsx($,{path:C.channelAnalytics,element:d.jsx(Ae,{feature:"channel_analytics",children:d.jsx(aR,{})})}),d.jsx($,{path:C.research,element:d.jsx(Ae,{feature:"research",children:d.jsx(GR,{})})}),d.jsx($,{path:C.hireHuman,element:d.jsx(Ae,{feature:"hire_human",children:d.jsx(dR,{})})}),d.jsx($,{path:C.guides,element:d.jsx(et,{to:C.resources,replace:!0})}),d.jsx($,{path:C.aiAssistant,element:d.jsx(Ae,{feature:"ai_coach",children:d.jsx(QR,{})})}),d.jsx($,{path:C.liveReviews,element:d.jsx(Ae,{feature:"live_reviews",children:d.jsx(Bh,{view:"submit"})})}),d.jsx($,{path:C.liveReviewsRecordings,element:d.jsx(Ae,{feature:"live_reviews",children:d.jsx(Bh,{view:"recordings"})})}),d.jsx($,{path:C.cohortAssignments,element:d.jsx(Ae,{feature:"cohort",children:d.jsx(hR,{})})}),d.jsx($,{path:C.cohortRecordings,element:d.jsx(Ae,{feature:"cohort",children:d.jsx(fR,{})})}),d.jsx($,{path:C.cohortCommunity,element:d.jsx(Ae,{feature:"cohort",children:d.jsx(pR,{})})}),d.jsx($,{path:C.cohortThread,element:d.jsx(Ae,{feature:"cohort",children:d.jsx(yR,{})})}),d.jsx($,{path:C.cohortFunnelTracker,element:d.jsx(Ae,{feature:"cohort",children:d.jsx(mR,{})})}),d.jsx($,{path:C.cohortReviewBoard,element:d.jsx(Ae,{feature:"cohort_team",children:d.jsx(xR,{})})}),d.jsx($,{path:C.cohortProgress,element:d.jsx(Ae,{feature:"cohort_team",children:d.jsx(bR,{})})}),d.jsx($,{path:C.cohortSetup,element:d.jsx(Ae,{feature:"cohort_team",children:d.jsx(wR,{})})}),d.jsx($,{path:C.dataBot,element:d.jsx(Ae,{feature:"data_bot",children:d.jsx(iR,{})})}),d.jsx($,{path:C.checklists,element:d.jsx(et,{to:C.resources,replace:!0})}),d.jsx($,{path:C.resources,element:d.jsx(Ae,{feature:"resources",children:d.jsx(kR,{})})}),d.jsx($,{path:C.docs,element:d.jsx(Ae,{feature:"docs",children:d.jsx(SR,{})})}),d.jsx($,{path:C.analytics,element:d.jsx(Be,{children:d.jsx(Lh,{})})}),d.jsx($,{path:C.myTickets,element:d.jsx(Ae,{feature:"tickets",children:d.jsx(ZR,{})})}),d.jsx($,{path:C.affiliateDashboard,element:d.jsx(Ae,{feature:"affiliate",children:d.jsx(eO,{})})}),d.jsx($,{path:C.freeTools,element:d.jsx(Ae,{feature:"free_tools",children:d.jsx(YR,{})})}),d.jsx($,{path:C.funnelAudit,element:d.jsx(Ae,{feature:"funnel_audit",children:d.jsx(qR,{})})}),d.jsx($,{path:C.offerCreator,element:d.jsx(Ae,{feature:"offer_creator",children:d.jsx(UR,{})})}),d.jsx($,{path:C.channelAudit,element:d.jsx(Ae,{feature:"free_tools",children:d.jsx(KR,{})})}),d.jsx($,{path:C.coursePattern,element:d.jsx(Ae,{feature:"academy",children:d.jsx(XR,{})})}),d.jsx($,{path:C.lateCheckout,element:d.jsx(EO,{})})]}),d.jsx($,{path:C.onboarding,element:d.jsx(wt,{children:d.jsx(vR,{})})}),d.jsx($,{path:C.youtubeCallback,element:d.jsx(wt,{children:d.jsx(qI,{})})}),d.jsx($,{path:C.boardSelection,element:d.jsx(wt,{children:d.jsx(Ae,{feature:"videos",children:d.jsx(Ph,{})})})}),d.jsx($,{path:C.thumbnailBoardPolished,element:d.jsx(wt,{children:d.jsx(Ae,{feature:"videos",children:d.jsx(GI,{})})})}),d.jsx($,{path:C.thumbnailBoardDoodle,element:d.jsx(wt,{children:d.jsx(Ae,{feature:"videos",children:d.jsx(QI,{})})})}),d.jsx($,{path:C.thumbnailBoardVision,element:d.jsx(wt,{children:d.jsx(Ae,{feature:"videos",children:d.jsx(XI,{})})})}),d.jsx($,{path:C.thumbnailBoardRoot,element:d.jsx(wt,{children:d.jsx(Ae,{feature:"videos",children:d.jsx(Ph,{})})})}),d.jsx($,{path:C.skyscraper,element:d.jsx(wt,{children:d.jsx(Ae,{feature:"research",children:d.jsx(ZI,{})})})}),d.jsx($,{path:C.point2,element:d.jsx(wt,{children:d.jsx(Ae,{feature:"videos",children:d.jsx(eR,{})})})}),d.jsx($,{path:C.logoExport,element:d.jsx(Be,{children:d.jsx(cR,{})})}),d.jsx($,{path:C.webhookTest,element:d.jsx(Be,{children:d.jsx(lR,{})})}),d.jsx($,{path:C.adminPricing,element:d.jsx(Be,{children:d.jsx(HR,{})})}),d.jsx($,{path:C.dashboardLegacy,element:d.jsx(et,{to:C.dashboard,replace:!0})}),d.jsx($,{path:C.videoPlannerTwoPagePattern,element:d.jsx(wt,{children:d.jsx(Ae,{feature:"videos",children:d.jsx(oR,{})})})}),d.jsx($,{path:C.introBotPattern,element:d.jsx(wt,{children:d.jsx(Ae,{feature:"videos",children:d.jsx(tR,{})})})}),d.jsx($,{path:C.scriptBotPattern,element:d.jsx(wt,{children:d.jsx(Ae,{feature:"videos",children:d.jsx(nR,{})})})}),d.jsx($,{path:C.researchHub,element:d.jsx(et,{to:C.research,replace:!0})}),d.jsx($,{path:C.researchNiche,element:d.jsx(et,{to:C.research,replace:!0})}),d.jsx($,{path:C.researchAdjacent,element:d.jsx(et,{to:C.research,replace:!0})}),d.jsx($,{path:C.validationTest,element:d.jsx(Be,{children:d.jsx(uR,{})})}),d.jsx($,{path:C.adminErrors,element:d.jsx(Be,{children:d.jsx(JR,{})})}),d.jsx($,{path:C.adminSupportTickets,element:d.jsx(Be,{children:d.jsx(CR,{})})}),d.jsx($,{path:C.adminAnnouncements,element:d.jsx(Be,{children:d.jsx(ER,{})})}),d.jsx($,{path:C.adminSettings,element:d.jsx(Be,{children:d.jsx(TR,{})})}),d.jsx($,{path:C.adminRoot,element:d.jsx(Be,{children:d.jsx(MR,{})})}),d.jsx($,{path:C.adminGrowthProof,element:d.jsx(Be,{children:d.jsx(_R,{})})}),d.jsx($,{path:C.adminTrendReports,element:d.jsx(Be,{children:d.jsx(AR,{})})}),d.jsx($,{path:C.adminChannels,element:d.jsx(Be,{children:d.jsx(NR,{})})}),d.jsx($,{path:C.adminOutliers,element:d.jsx(Be,{children:d.jsx(jR,{})})}),d.jsx($,{path:C.adminNicheReports,element:d.jsx(Be,{children:d.jsx(IR,{})})}),d.jsx($,{path:C.adminCourseManager,element:d.jsx(Be,{children:d.jsx(RR,{})})}),d.jsx($,{path:C.adminLiveReviews,element:d.jsx(Be,{children:d.jsx(OR,{})})}),d.jsx($,{path:C.adminAccessRights,element:d.jsx(Be,{children:d.jsx(DR,{})})}),d.jsx($,{path:C.adminAiSpend,element:d.jsx(Be,{children:d.jsx(LR,{})})}),d.jsx($,{path:C.adminIntegrations,element:d.jsx(Be,{children:d.jsx(PR,{})})}),d.jsx($,{path:C.adminVideoInsights,element:d.jsx(Be,{children:d.jsx(BR,{})})}),d.jsx($,{path:C.adminConversations,element:d.jsx(Be,{children:d.jsx(zR,{})})}),d.jsx($,{path:C.adminTestimonials,element:d.jsx(Be,{children:d.jsx(FR,{})})}),d.jsx($,{path:C.adminSalesConversations,element:d.jsx(Be,{children:d.jsx($R,{})})}),d.jsx($,{path:C.adminAnalytics,element:d.jsx(Be,{children:d.jsx(Lh,{})})}),d.jsx($,{path:C.adminBannedUsers,element:d.jsx(Be,{children:d.jsx(VR,{})})}),d.jsx($,{path:C.adminUsers,element:d.jsx(Be,{children:d.jsx(WR,{})})}),d.jsx($,{path:C.channelAuditLegacy,element:d.jsx(et,{to:C.channelAnalytics,replace:!0})}),d.jsx($,{path:C.audienceWarmthLegacy,element:d.jsx(et,{to:C.channelAnalytics,replace:!0})}),d.jsx($,{path:"/course/:lessonId?",element:d.jsx(et,{to:"/academy",replace:!0})}),d.jsx($,{path:"*",element:d.jsx(JI,{})})]})})})]})},NO=()=>d.jsx(tx,{client:Ua,children:d.jsx(v0,{defaultTheme:"dark",storageKey:"ui-theme",children:d.jsxs(Uf,{children:[d.jsx(xb,{}),d.jsx(Gb,{}),d.jsx(Ky,{children:d.jsx(o1,{children:d.jsx(a1,{children:d.jsx(l1,{children:d.jsx(S1,{children:d.jsx(j1,{children:d.jsx(MO,{})})})})})})})]})})});window.onerror=async(t,e,n,r,i)=>{console.error("Global error:",{message:t,source:e,lineno:n,colno:r,error:i});try{await Ge(i??t,{eventName:"UncaughtError",source:"client-error",metadata:{sourceFile:e,lineno:n,colno:r}})}catch(o){console.error("Failed to track global error:",o)}};window.onunhandledrejection=async t=>{console.error("Unhandled promise rejection:",t.reason);try{await Ge(t.reason,{eventName:"UnhandledPromiseRejection",source:"client-error"})}catch(e){console.error("Failed to track promise rejection:",e)}};let Fh=!1,$h=!1;Sx();kx(t=>{t&&(!Fh&&Bo("analytics")&&(Fh=!0,bx(),ax()),!$h&&Bo("marketing")&&($h=!0,dx())
575)});vx()||console.warn("[consent] No cookie consent platform detected (CookieYes / Cookiebot / CookieScript). Hotjar and Rewardful will stay disabled until one is installed and accepted.");bf(document.getElementById("root")).render(d.jsx(NO,{}));export{HO as $,Vo as A,us as B,qx as C,Dr as D,Ai as E,Vx as F,Ll as G,zO as H,yI as I,pI as J,Ef as K,ut as L,KO as M,zo as N,CD as O,Fx as P,Si as Q,C as R,Xe as S,nu as T,WO as U,Bx as V,AI as W,eo as X,zx as Y,ub as Z,Bn as _,hr as a,Gl as a$,NP as a0,Co as a1,U as a2,Ne as a3,kf as a4,Dc as a5,Fl as a6,Jf as a7,Kr as a8,Va as a9,Qx as aA,W0 as aB,YE as aC,lD as aD,cD as aE,fc as aF,hD as aG,Vl as aH,zn as aI,dD as aJ,pb as aK,$a as aL,Xx as aM,Dx as aN,mD as aO,pD as aP,yD as aQ,gD as aR,Sr as aS,GE as aT,uD as aU,II as aV,ky as aW,Sy as aX,Hx as aY,Wi as aZ,Cy as a_,vy as aa,Ss as ab,qo as ac,z0 as ad,Lx as ae,xD as af,bD as ag,jf as ah,wD as ai,DI as aj,IP as ak,tb as al,y0 as am,x0 as an,Kf as ao,Mt as ap,Bl as aq,_w as ar,Cw as as,Jx as at,Uf as au,_f as av,Af as aw,Kl as ax,db as ay,Nf as az,xe as b,SP as b$,ws as b0,vs as b1,ks as b2,kw as b3,I1 as b4,hp as b5,fp as b6,pp as b7,pT as b8,gp as b9,kP as bA,EP as bB,pP as bC,aP as bD,mP as bE,dP as bF,hP as bG,kp as bH,B1 as bI,uP as bJ,eP as bK,rP as bL,iP as bM,cP as bN,Yl as bO,sP as bP,oP as bQ,CP as bR,TP as bS,kb as bT,UO as bU,Ge as bV,W1 as bW,Dl as bX,$O as bY,XO as bZ,cb as b_,KE as ba,oD as bb,sD as bc,aD as bd,Yx as be,Ox as bf,Jc as bg,Gx as bh,qi as bi,kD as bj,SD as bk,Cf as bl,hb as bm,fb as bn,FO as bo,$l as bp,qO as bq,$x as br,ib as bs,$1 as bt,z1 as bu,tP as bv,nP as bw,lP as bx,ZO as by,fP as bz,Ux as c,eD as c$,Ua as c0,vP as c1,bP as c2,xP as c3,vw as c4,nb as c5,wP as c6,gP as c7,yP as c8,Ar as c9,Mf as cA,JO as cB,Wx as cC,Pp as cD,Dp as cE,Lp as cF,Bp as cG,To as cH,_o as cI,Px as cJ,GO as cK,x1 as cL,Dw as cM,Sf as cN,mp as cO,sb as cP,RP as cQ,OP as cR,zP as cS,ob as cT,HP as cU,XP as cV,PP as cW,DP as cX,LP as cY,BP as cZ,ZP as c_,Ci as ca,qE as cb,$E as cc,WE as cd,jo as ce,HE as cf,UE as cg,lb as ch,jP as ci,FI as cj,FP as ck,Kw as cl,rD as cm,WP as cn,Mw as co,Aw as cp,Y1 as cq,vD as cr,$P as cs,VP as ct,H1 as cu,QO as cv,Zx as cw,Fp as cx,$p as cy,nD as cz,Vi as d,tD as d0,YP as d1,GP as d2,KP as d3,JP as d4,QP as d5,UP as d6,rb as d7,Qt as d8,rI as d9,cd as da,ZE as db,eT as dc,sd as dd,tT as de,nT as df,rT as dg,tu as dh,FE as di,VE as dj,iT as dk,BO as dl,Gn as dm,to as dn,Tn as dp,Fo as dq,s1 as dr,Tf as ds,DO as dt,fs as e,Rt as f,se as g,gs as h,VO as i,qP as j,j as k,xp as l,Un as m,Ti as n,vf as o,Ei as p,Rx as q,YO as r,cp as s,Mr as t,St as u,_P as v,AP as w,MP as x,ys as y,tp as z};
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.