import{aC as A,L as x,ao as a,a_ as p,bl as G,bc as O,aX as _,ay as H,az as V,b4 as $,aZ as h}from"./app-k0jcl5PQ.js";import{S as r}from"./Boh3c6zT.chunk.js";import{S as g}from"./q-a0Zpry.chunk.js";import{u as z}from"./CX-R8N_3.chunk.js";import{u as J}from"./C8ys3yUG.chunk.js";import{S as m}from"./D-iHOjjO.chunk.js";const U="sharev2.getSharePrivacyConfig",i=x.encloseNamespace(U);function b(e){const t=g.getShareLinkAccessType(e.entityPrivacy),s=g.getRespectRatingText(e.entity,e.yearGroups,e.hasStudentExp);return{[r.JustMySchool]:{title:i("respectRatings"),description:s,predicate:()=>t!=="protected"},[r.Protected]:{title:i("respectRatings"),description:s,predicate:()=>t==="protected"},[r.JustMySchoolOverrideRestriction]:{title:i("justMySchool"),description:i("justMySchoolDescription"),predicate:()=>t!=="protected"},[r.ProtectedOverrideRestriction]:{title:i("clickViewOnly"),description:i("clickViewOnlyDescription"),predicate:()=>t==="protected"},[r.Public]:{title:i("public"),description:i("publicDescription"),predicate:()=>t==="owner"},[r.Direct]:{title:"",description:"",predicate:()=>!1},[r.PasswordProtected]:{title:i("passwordProtectedTitle"),description:i("passwordProtectedDescription"),predicate:()=>e._showPasswordProtected},[r.PinCode]:{title:i("pinCode"),description:i("pinCodeDescription"),predicate:()=>!1}}}function te(e){const t=b(e),s=Object.entries(t).filter(([,n])=>n.predicate());if(s.length)return A.first(s)[0]}const q="_active_flovw_1",B={active:q};function F(e){const t=e.activePrivacy===e.sharePrivacy;function s(){t||e.onClick(e.sharePrivacy)}return a.jsx("li",{children:a.jsxs("button",{className:`${t?B.active:""} dropdown-item d-flex align-items-center justify-content-between py-2`,onClick:s,children:[a.jsxs("div",{className:"me-4",children:[a.jsx("p",{className:"font-label mb-1",children:e.title}),a.jsx("p",{className:"font-size-sm mb-0",children:e.description})]}),t&&a.jsx(p,{svg:G})]})})}function ae(e){const t=e.shareOverrideRestrictions&&!e.hasStudentExp,s=b({entity:e.entity,entityPrivacy:e.entityPrivacy,hasStudentExp:e.hasStudentExp,yearGroups:e.yearGroups,_showPasswordProtected:e.sharePrivacy===r.PasswordProtected}),{icon:n,text:l}=g.getPrivateIconAndText({privacy:e.sharePrivacy,entityTypeId:e.entityTypeId,hasStudentExp:e.hasStudentExp,entity:e.entity,yearGroups:e.yearGroups});return t?a.jsxs("div",{className:"btn-group",children:[a.jsxs("button",{className:"btn border-0 info-link dropdown-toggle p-1 bg-light-blue-hover","data-bs-toggle":"dropdown",children:[a.jsx(p,{svg:n,className:"svg-container me-1"}),a.jsx("span",{className:"me-1",children:l})]}),a.jsx("ul",{className:"dropdown-menu cursor-pointer",children:Object.values(r).map(d=>{const{title:y,description:c,predicate:o}=s[d];if(o())return a.jsx(F,{sharePrivacy:d,activePrivacy:e.sharePrivacy,title:y,description:c,onClick:e.onClickSavePrivacy},d)})})]}):a.jsxs("div",{className:"d-flex align-items-center",children:[a.jsx(p,{svg:n,className:"svg-container me-1"}),a.jsx("span",{children:l})]})}const X="sharev2.useMainShareData",f=x.encloseNamespace(X);function se(e){const t=O(),{hasPermissions:s}=_(),{shareToGoogleClassroom:n,shareToMicrosoftTeams:l,isLoadingSettings:d,shareOverrideRestrictions:y}=H(null),{currentUser:c,entity:o,privacy:v,share:u,config:S}=J({entityId:e.entityId,entityType:e.entityType}),{loaded:j,updateShareLink:w}=z({entityId:e.entityId}),P=V(c.data&&$.yearGroups(c.data.customerId));async function k(R){try{const D=await w(u.data.shareId,{privacy:R});e.log({type:"update-share-link",share:D}),t.success(f("privaciesSuccess",{name:o.data.name,escapeText:!0}))}catch{t.error(f("privaciesError",{name:o.data.name,escapeText:!0}))}}const C=m.canEmbed(e.entityType),T=m.getEnabledIntegrations(n,l),I=s(h.ManageIntegrations),N=s(h.StudentExperience),E=s(h.ManageShareLinkSettings),L=u.data&&m.canAddPolicies(e.entityType),M=j&&!!u.data&&!!o.data&&!!v.data&&!!S.data&&!!c.data&&!!P&&!d;return{data:{share:u,loaded:M,entity:o,privacy:v,config:S,yearGroups:P,shareOverrideRestrictions:y,currentUser:c},canEmbed:C,integrations:T,hasStudentExp:N,canAccessSettings:L,hasManageShareLinkSettings:E,hasManageIntegrationsPermission:I,onClickSavePrivacy:k}}export{ae as S,te as g,se as u};
//# sourceMappingURL=0F_Hqfey.chunk.js.map
