import{r as e,j as t}from"./vendor-react-RSDKEZ60.js";import{u as s}from"./vendor-zustand-IIUY2Tf-.js";import{e as n,o as a,G as i,bc as o}from"./c40b9b8f5-FH3kS9Lp.js";import{Ln as r,GU as l,pi as d,V as c,cJ as u,B as m,a0 as h,gc as f}from"./c818056db-BBpc4u6S.js";import{M as g,d as p,u as x}from"./vendor-intl-BNW8a19h.js";import{B as w}from"./vendor-ant-cds-CBh5POw1.js";function b(e){return r(t=>{if(!e)return null;let s=null;for(const n of t.spaces)n.projects.some(t=>t.uuid===e)&&(!s||n.updatedAt>s.updatedAt)&&(s=n);return s})}function v(){const t=n(),i=a(s(e=>{const t=new Map;if(!e.isInitialized)return t;for(const s of e.sessions){if(!s.spaceId)continue;const e=s.lastActivityAt??s.createdAt??0;e>(t.get(s.spaceId)??0)&&t.set(s.spaceId,e)}return t})),o=e.useMemo(()=>{const e=new Map(i);for(const s of t){if(!s.spaceId)continue;const t=s.lastActivityAt??s.createdAt??0;t>(e.get(s.spaceId)??0)&&e.set(s.spaceId,t)}return e},[t,i]);return e.useCallback(e=>Math.max(e.updatedAt??e.createdAt??0,o.get(e.id)??0),[o])}const j=[],k=[];const y=[];function C(t,n){const o=function(t){const s=i();return e.useMemo(()=>t?s.filter(e=>e.spaceId===t).sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)):j,[s,t])}(t),r=n.ccdEnabled,l=a(s(e=>r&&t&&e.isInitialized?e.sessions.filter(e=>!e.isArchived&&e.spaceId===t):y));return e.useMemo(()=>{const e=o.map(e=>({kind:"cowork",session:e}));for(const t of l)e.push({kind:"ccd",session:t});return 0===e.length?k:e.sort((e,t)=>(t.session.createdAt??0)-(e.session.createdAt??0))},[o,l])}const _={bypassPermissions:"cowork-unsupervised-banner-dont-show",auto:"cowork-auto-banner-dont-show"};function M(e,t){return`${_[t]}:${e}`}function N(e,t){if("undefined"==typeof window||!e||!t)return!1;try{return"1"===window.localStorage.getItem(M(e,t))}catch{return!1}}function S(e,t){if(e)try{window.localStorage.setItem(M(e,t),"1")}catch{}}function A(e){return"auto"===e||"bypassPermissions"===e?e:void 0}function I(e){return t.jsx("span",{className:"font-bold",children:e})}const T=e.memo(function({mode:s="bypassPermissions",onDismiss:n,onDontShowAgain:a,chromeSkipAllPermissionChecks:i,surface:r="session"}){const h="auto"===s,f=l(),p=d(e=>e.hasBlockingWarning),x=o(),b="scheduled-task"===r?u:f?"https://support.claude.com/en/articles/14128542":u,v=e.useMemo(()=>function(e){return t.jsx(c,{external:!0,href:b,className:"!text-inherit",children:e})},[b]);return p||"session"===r&&x?null:t.jsx(m,{variant:h?"neutral":"warning",icon:null,onDismiss:n,action:a?t.jsx(w,{variant:"secondary",size:"sm",onClick:a,className:"shrink-0 whitespace-nowrap",children:t.jsx(g,{defaultMessage:"Don't show again",id:"OfQY5FgDMl"})}):void 0,className:"relative z-0 mx-2 -mb-5 items-center !rounded-b-none !rounded-t-[20px] !pb-8 !pt-3 !shadow-none md:mx-0 [&>div]:items-center",children:h?f?t.jsx(g,{defaultMessage:"<bold>Automatically approve is on.</bold> Claude approves most actions on its own, including using your connectors, Claude in Chrome, and apps on your computer. <link>Learn more</link>",id:"syNcpr6mOV",values:{bold:I,link:v}}):t.jsx(g,{defaultMessage:"<bold>Automatically approve is on.</bold> Claude approves most actions on its own, including using your connectors and Claude in Chrome. <link>Learn more</link>",id:"rt2Jq6HVTR",values:{bold:I,link:v}}):"scheduled-task"===r?t.jsx(g,{defaultMessage:"For this task, Claude will work and use connectors without pausing for approval. <link>See safe use tips</link>",id:"PEiYctxogE",values:{link:v}}):f?i?t.jsx(g,{defaultMessage:"<bold>Skip all approvals is on.</bold> Claude works, uses connectors, browses the web, and controls apps on your computer without pausing for approval. You can turn off individual connectors in the Add menu. <link>See safe use tips</link>",id:"76muZ34j0E",values:{bold:I,link:v}}):t.jsx(g,{defaultMessage:"<bold>Skip all approvals is on.</bold> Claude works, uses connectors, and controls apps on your computer without pausing for approval. You can turn off individual connectors in the Add menu. <link>See safe use tips</link>",id:"VQJ/NsF/Fz",values:{bold:I,link:v}}):i?t.jsx(g,{defaultMessage:"<bold>Skip all approvals is on.</bold> Claude works, uses connectors, and browses the web without pausing for approval. You can turn off individual connectors in the Add menu. <link>See safe use tips</link>",id:"3PzELBQnZa",values:{bold:I,link:v}}):t.jsx(g,{defaultMessage:"<bold>Skip all approvals is on.</bold> Claude works and uses connectors without pausing for approval. You can turn off individual connectors in the Add menu. <link>See safe use tips</link>",id:"OtlDf9GnNR",values:{bold:I,link:v}})})});T.displayName="CoworkUnsupervisedBanner";const L=p({unknown_platform:{id:"lti.err.unknown_platform",defaultMessage:"This Canvas instance is not registered with Claude. Ask your administrator to complete setup."},ambiguous_platform:{id:"lti.err.ambiguous_platform",defaultMessage:"Canvas setup is ambiguous for this organization. Ask your administrator to check the LTI configuration."},invalid_email_domain:{id:"lti.err.invalid_email_domain",defaultMessage:"Your Canvas email domain is not allowed for this organization."},state_mismatch:{id:"lti.err.state_mismatch",defaultMessage:"The launch could not be verified for this browser. Close this tab and launch again from Canvas."},invalid_state:{id:"lti.err.invalid_state",defaultMessage:"This launch link has expired. Launch again from Canvas."},missing_token:{id:"lti.err.missing_token",defaultMessage:"No launch token was received from Canvas."},internal_error:{id:"lti.err.internal_error",defaultMessage:"Something went wrong on our end. Try launching again in a moment."},existing_account_not_member:{id:"lti.err.existing_account_not_member",defaultMessage:"Your account exists but is not a member of this organization. Ask your administrator for an invite."},account_provisioning_required:{id:"lti.err.account_provisioning_required",defaultMessage:"Your administrator needs to finish setting up Claude for your organization."},nonce_mismatch:{id:"lti.err.nonce_mismatch",defaultMessage:"This launch link has expired. Launch again from Canvas."},validation_failed:{id:"lti.err.validation_failed",defaultMessage:"The launch could not be validated. Try again from Canvas."},invalid_token:{id:"lti.err.invalid_token",defaultMessage:"This launch link is not valid. Launch again from Canvas."},expired_token:{id:"lti.err.expired_token",defaultMessage:"This launch link has expired or was already used. Launch again from Canvas."},lti_launch_claimed:{id:"lti.err.lti_launch_claimed",defaultMessage:"This launch link was already opened in a different browser. Launch again from Canvas in this browser."},lti_email_mismatch:{id:"lti.err.lti_email_mismatch",defaultMessage:"You're signed in to Claude with a different email than your course roster uses. Sign in with the account your institution knows you by, then launch again from Canvas."},single_seat_team_org_cannot_add_members:{id:"lti.err.single_seat_team_org_cannot_add_members",defaultMessage:"This organization is a single-seat Claude for Education organization and cannot accept additional members. Ask your administrator to connect the course to the district organization."},lti_mapping_conflict:{id:"lti.err.lti_mapping_conflict",defaultMessage:"This launch identity is linked to a different Claude account. Ask your administrator to update the link before launching again."}}),R=/^[a-z_]{1,64}$/;const z=function(){const s=x(),[n,a]=e.useState(null),[i,o]=e.useState(null),[r,l]=e.useState(null),[d,c]=e.useState(!1),u=e.useRef(!1);e.useEffect(()=>{if(u.current)return;if(u.current=!0,window.self!==window.top)return void l("framed");const e=window.location.hash.substring(1),t=new URLSearchParams(e).get("token");if(!t)return void l("missing_token");window.history.replaceState(null,"",window.location.pathname+window.location.search),a(t);(async()=>{let e;try{e=await fetch(`/api/lti/land/preview?token=${encodeURIComponent(t)}`,{credentials:"include"})}catch{return void l("generic")}if(401===e.status)return void window.location.assign(`/login?returnTo=${encodeURIComponent(`/lti/continue?token=${encodeURIComponent(t)}`)}`);if(!e.ok){const t=await e.json().catch(()=>null),s=t?.error_code;return void l(s&&Object.hasOwn(L,s)?s:"generic")}const s=await e.json().catch(()=>null);null!==s?s.already_member?window.location.assign(`/api/lti/land?token=${encodeURIComponent(t)}`):o(s.organization_name):l("generic")})()},[]);const m=null===r?null:"generic"===r?s.formatMessage({defaultMessage:"The launch could not be completed. Close this tab and launch again from Canvas.",id:"EsEuZiSJL8"}):"framed"===r?s.formatMessage({defaultMessage:"This page can't run in an embedded view. Launch again from your course.",id:"9CsIqztOTy"}):s.formatMessage(L[r]);return t.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-1 p-4",children:t.jsxs("div",{className:"max-w-md rounded-lg bg-alpha-1 p-8 text-center shadow-lg",children:[t.jsx("h1",{className:"mb-4 text-heading font-semibold text-primary",children:null!==i?t.jsx(g,{defaultMessage:"Join {orgName} on Claude?",id:"y/dhnliJ1d",values:{orgName:i}}):t.jsx(g,{defaultMessage:"Connecting to Claude",id:"9gO3gUQIqY"})}),null!==m?t.jsx("p",{className:"mb-6 text-primary",children:m}):null!==i?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mb-6 text-primary",children:t.jsx(g,{defaultMessage:"Launching from your course will add your Claude account to {orgName}. Your organization's administrators will see you as a member.",id:"9RBRtLQhdD",values:{orgName:i}})}),t.jsx(h,{onClick:()=>{if(!n)return;c(!0);(async()=>{let e;try{e=await fetch("/api/lti/land/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:n}),credentials:"include"})}catch{return c(!1),void l("generic")}if(401===e.status)return void window.location.assign(`/login?returnTo=${encodeURIComponent(`/lti/continue?token=${encodeURIComponent(n)}`)}`);if(e.ok){const t=await e.json().catch(()=>null);return void window.location.assign(function(e,t){if(!e||!e.startsWith("/")||/[\x00-\x1f]/.test(e))return"/new";try{if(new URL(e,t).origin===t)return e}catch{}return"/new"}(t?.redirect,window.location.origin))}const t=await e.json().catch(()=>null),s=t?.error_code;c(!1),l(s&&Object.hasOwn(L,s)?s:"generic")})()},disabled:d,children:d?t.jsx(g,{defaultMessage:"Joining\u2026",id:"UCyyxThxSy"}):t.jsx(g,{defaultMessage:"Join and continue",id:"vfgqhcp0D2"})})]}):t.jsx("p",{className:"mb-6 text-primary",children:t.jsx(g,{defaultMessage:"One moment\u2026",id:"cv/8XlBdUj"})})]})})},P=function(){const[s,n]=e.useState(null),[a,i]=e.useState(null),o=e.useRef(!1);return e.useEffect(()=>{if(o.current)return;o.current=!0;const e=window.self!==window.top,t=window.location.hash.substring(1),s=new URLSearchParams(t).get("token"),a=new URLSearchParams(window.location.search).get("token");return s&&window.history.replaceState(null,"",window.location.pathname+window.location.search),a?e?void i("query-in-frame"):(window.history.replaceState(null,"",window.location.pathname),void window.location.assign(`/api/lti/land?token=${encodeURIComponent(a)}`)):s?e?void n(s):void i("framed-fragment-at-top"):void i("missing")},[]),t.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-1 p-4",children:t.jsxs("div",{className:"max-w-md rounded-lg bg-alpha-1 p-8 text-center shadow-lg",children:[t.jsx("h1",{className:"mb-4 text-heading font-semibold text-primary",children:t.jsx(g,{defaultMessage:"Continue to Claude",id:"CzXCARR8y/"})}),"missing"===a?t.jsx("p",{className:"mb-6 text-primary",children:t.jsx(g,{defaultMessage:"No launch token was received from Canvas. Close this view and launch again from your course.",id:"cxO6GDJCUP"})}):"framed-fragment-at-top"===a?t.jsx("p",{className:"mb-6 text-primary",children:t.jsx(g,{defaultMessage:"This page must be opened from within Canvas.",id:"RpaluJknJZ"})}):"query-in-frame"===a?t.jsx("p",{className:"mb-6 text-primary",children:t.jsx(g,{defaultMessage:"This page can't run in an embedded view. Launch again from your course.",id:"9CsIqztOTy"})}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mb-6 text-primary",children:t.jsx(g,{defaultMessage:"Claude will open full-size, replacing this Canvas view.",id:"EYB6BxBPSi"})}),null!==s&&t.jsx(w,{href:`/api/lti/land?token=${encodeURIComponent(s)}`,target:"_top",variant:"primary",children:t.jsx(g,{defaultMessage:"Continue to Claude",description:"Button label",id:"Yc8dJ4Orw9"})})]})]})})},E=function(){const e=f(),s=x(),{messageKey:n}=function(e){const t=e.get("code"),s=t&&R.test(t)?t:null;return{messageKey:null!==s&&Object.hasOwn(L,s)?s:null}}(e),a=null!==n?s.formatMessage(L[n]):null;return t.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-100 p-4",children:t.jsxs("div",{className:"max-w-md rounded-lg bg-bg-200 p-8 text-center shadow-lg",children:[t.jsx("div",{className:"mb-4 flex justify-center",children:t.jsx("div",{className:"rounded-full bg-bg-300 p-3",children:t.jsx("svg",{className:"h-8 w-8 text-bg-100",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})})}),t.jsx("h1",{className:"mb-4 text-2xl font-semibold text-text-100",children:t.jsx(g,{defaultMessage:"Unable to Launch from Canvas",id:"q31IeRUD48"})}),t.jsx("p",{className:"mb-6 text-text-200",children:a??t.jsx(g,{defaultMessage:"An unknown error occurred",id:"3VG8rbxa4v"})}),t.jsx("p",{className:"text-sm text-text-300",children:t.jsx(g,{defaultMessage:"Please try launching again from your Canvas course. If the problem persists, contact your instructor or system administrator.",id:"XDIZ4AcINI"})}),t.jsx("div",{className:"mt-8 border-t border-border-100 pt-4",children:t.jsx("p",{className:"text-xs text-text-300",children:t.jsx(g,{defaultMessage:"Error Code: {code}",id:"iK5IE4uYzo",values:{code:n??"LTI_LAUNCH_FAILED"}})})})]})})},Y=function(){const[s,n]=e.useState(!1);return e.useEffect(()=>{document.cookie="first_party_interaction=true; SameSite=Lax; Secure; max-age=2592000"},[]),t.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-100 p-4",children:t.jsxs("div",{className:"max-w-md w-full space-y-6 rounded-lg border border-border-200 bg-bg-000 p-8 shadow-sm text-center",children:[t.jsx("h1",{className:"text-2xl font-semibold text-text-100 mb-4",children:t.jsx(g,{defaultMessage:"Enable Canvas Integration",id:"5y5jlij80c"})}),s?t.jsxs("div",{children:[t.jsx("div",{className:"text-text-100 text-5xl mb-4",children:t.jsx(g,{defaultMessage:"\u2713",id:"gbNumd3Yx/"})}),t.jsx("p",{className:"text-lg font-medium text-text-100 mb-2",children:t.jsx(g,{defaultMessage:"Integration Enabled!",id:"aneKWsxHE9"})}),t.jsx("p",{className:"text-text-200",children:t.jsx(g,{defaultMessage:"You can now close this tab and return to Canvas.",id:"MYpbuYzwCe"})})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-text-200 mb-6",children:t.jsx(g,{defaultMessage:"To use Claude in Canvas, please click the button below to enable the integration. This is a one-time setup required by Safari.",id:"YDFGJP+eiC"})}),t.jsx(h,{onClick:()=>{n(!0),localStorage.setItem("hasFirstPartyInteraction","true"),setTimeout(()=>{window.close()},2e3)},size:"lg",variant:"primary",className:"w-full",children:t.jsx(g,{defaultMessage:"Enable Integration",id:"ZlGDsHsPE6"})}),t.jsx("p",{className:"text-xs text-text-300 mt-4",children:t.jsx(g,{defaultMessage:"After clicking, you can close this tab and return to Canvas.",id:"+mcl1P9X4f"})})]})]})})},U=function(){const[s,n]=e.useState(null),[a,i]=e.useState(!1),[o,r]=e.useState(null),[l,d]=e.useState(null),[c,u]=e.useState(null),m="lti_nonce_unbound"!==l;return e.useEffect(()=>{if(window.self===window.top)return r("This page must be opened from within Canvas."),void u(!1);const e=window.location.hash.substring(1),t=new URLSearchParams(e).get("token");n(t);document.cookie.includes("lti_setup_complete")||document.cookie.includes("lti_session")?window.location.assign("/new"):u(!0)},[]),null===c?null:!1===c?t.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-100 p-4",children:t.jsx("div",{className:"max-w-md w-full rounded-lg border border-border-200 bg-bg-000 p-8 shadow-sm",children:t.jsx("p",{className:"text-sm text-text-200",children:o})})}):t.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-100 p-4",children:t.jsxs("div",{className:"max-w-md w-full space-y-6 rounded-lg border border-border-200 bg-bg-000 p-8 shadow-sm",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("h1",{className:"text-2xl font-semibold text-text-100 mb-2",children:t.jsx(g,{defaultMessage:"Canvas Integration Setup",id:"nboKkj5ZR8"})}),t.jsx("p",{className:"text-text-200 mb-6",children:t.jsx(g,{defaultMessage:"To use Claude within Canvas, we need your permission to access your authentication.",id:"yncLssSJxI"})})]}),o&&t.jsxs("div",{className:"rounded-md bg-bg-300 border border-border-300 p-4",children:[t.jsx("p",{className:"text-sm text-text-200",children:o}),m&&t.jsxs("div",{className:"mt-3",children:[t.jsx("p",{className:"text-xs text-text-300 mb-2",children:t.jsx(g,{defaultMessage:"Alternative method:",id:"QWld+x6JhN"})}),t.jsx(h,{onClick:()=>{const e=window.location.origin+"/lti/first-party";window.open(e,"_blank","width=600,height=500"),r("After completing setup in the new window, click \u2018Allow Access\u2019 again.")},variant:"secondary",size:"sm",children:t.jsx(g,{defaultMessage:"Complete Safari Setup",id:"abo/YTSeBu"})})]})]}),t.jsx(h,{onClick:()=>{i(!0),r(null),"requestStorageAccess"in document?document.requestStorageAccess().then(async()=>{if(s)try{const e=await fetch("/lti/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:s}),credentials:"include"});if(e.ok){const t=await e.json();await new Promise(e=>setTimeout(e,100)),document.cookie.includes("lti_setup_complete")?window.location.assign(t.project_uuid?`/project/${encodeURIComponent(t.project_uuid)}`:"/new"):r("Authentication setup complete. Please refresh the page.")}else{const t=await e.json().catch(()=>({}));d(t.error_code??null),r("lti_nonce_unbound"===t.error_code?"This launch link has expired. Please relaunch Claude from Canvas. (Requires Safari 18.2 or later.)":"Failed to set authentication cookies.")}}catch(e){r("Error setting up authentication.")}else r("No authentication token provided.");i(!1)}).catch(e=>{e instanceof Error?e.message?.includes("user gesture")?r("Please click the button to grant permission. This requires user interaction."):e.message?.includes("denied")?r("Permission was denied. Please allow storage access when prompted."):r(`Storage access error: ${e.message}`):r("Safari requires you to interact with this site first. Please use the button below to complete setup."),i(!1)}):(r("Storage Access API not supported in this browser"),i(!1))},disabled:a||!m,className:"w-full",size:"lg",variant:"primary",children:a?t.jsx(g,{defaultMessage:"Requesting access...",id:"kDYzre2KOj"}):t.jsx(g,{defaultMessage:"Allow Access",id:"NLYkdN2vzK"})}),t.jsx("p",{className:"text-xs text-text-300 text-center",children:t.jsx(g,{defaultMessage:"This is required for Safari and other browsers with strict privacy settings.",id:"5Ye0IppGpk"})})]})})},O=Object.freeze(Object.defineProperty({__proto__:null,LtiConsentRoute:z,LtiContinueRoute:P,LtiErrorRoute:E,LtiFirstPartyRoute:Y,LtiStorageAccessRoute:U},Symbol.toStringTag,{value:"Module"}));export{T as C,O as L,C as a,v as b,A as c,N as r,b as u,S as w};
