1import{r as u,j as a,p as St,d as w,i as U,B as _,h as re,C as Ye,D as Ze,ch as _t,R as Et,q as Jt,ci as lt,cj as De,bg as ut,ck as dt,cl as Ot,o as X,l as Xt,e as Yt,f as Zt,cm as Le,cn as er,co as ht,E as tr,F as rr}from"./vendor-mui-DezmOZ5s.js";import{v as nr,ab as sr,ac as ir,ad as or,I as $e,x as ar,ae as cr,af as lr,ag as ur,z as Te}from"./mediaAudios-C_T2eoVm.js";import{_ as dr,g as Ue,K as R}from"./reInitTextObjectsDimensions-BLpgCpwr.js";import{a as Mt}from"./index-CkSVWyvq.js";import{c as hr,e as ce}from"./normalizeUrl-BGFTw3XD.js";import{G as fr,O as pr,N as ft,S as mr}from"./ContextMenu-bt3OOGbR.js";import"./useQueryParameterState-DusskCJu.js";import{u as yr}from"./routes-BtOTydZ7.js";import{O as gr}from"./highlightText-gj4hz-2Y.js";import{c as vr}from"./errors-b2M8BK2g.js";import{f as pt}from"./appSlice-CsNCl3XQ.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"c327cd2632af5bcae6e3b7a0bcba8e387e1442f9"};var e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="845246f6-53a8-4c30-92b2-a3b643efef44",t._sentryDebugIdIdentifier="sentry-dbid-845246f6-53a8-4c30-92b2-a3b643efef44")}catch{}})();const be=new Set;function br(t){be.add(t)}function wr(t){be.delete(t)}function xr(){be.forEach(t=>hr(t)),be.clear()}function Dt(t){const e=ce({...t,onClose:(r,n,s)=>{s&&wr(s)}});return e!==void 0&&br(e),e}const Qn=()=>{const{pathname:t}=yr();u.useEffect(()=>{xr()},[t])};var v=(t=>(t.Cancel="cancel",t.Authenticate="authenticate",t.Error="error",t.Select="select",t))(v||{});const we=t=>{const[e,r]=u.useState(!1),[n,s]=u.useState(),[i,c]=u.useState(t),[o,l]=u.useState(t);u.useEffect(()=>{c(t)},[t]);const h=u.useCallback(async m=>{const y=Promise.withResolvers();return l(m),s(y),r(!0),await y.promise},[]),f=u.useCallback((m,...y)=>{const[$]=y;r(!1),n?.resolve({action:m,payload:$})},[n]);return{isOpen:e,context:{...i,...o},open:h,close:f}};function $t(t){return a(St,{...t,children:a("svg",{fill:"none",height:"80",viewBox:"0 0 80 80",width:"80",xmlns:"http://www.w3.org/2000/svg",children:w("g",{clipRule:"evenodd",fillRule:"evenodd",children:[a("path",{d:"m40 68c15.464 0 28-12.536 28-28s-12.536-28-28-28-28 12.536-28 28 12.536 28 28 28zm2.0654-12.7898 14.7347-27.8103h-11.9185l-4.7714 8.5617-.9282-1.8465-4.8114-.0057 5.6224 10.7842 7.1742-13.1056h2.5573l-9.6343 18.2847-9.6372-18.2847h9.2954l2.3371-4.3881h-18.8854l14.8992 27.8103z",fill:"#fff"}),a("path",{d:"m40 68c15.464 0 28-12.536 28-28s-12.536-28-28-28-28 12.536-28 28 12.536 28 28 28zm2.0654-12.7898 14.7347-27.8103h-11.9185l-4.7714 8.5617-.9282-1.8465-4.8114-.0057 5.6224 10.7842 7.1742-13.1056h2.5573l-9.6343 18.2847-9.6372-18.2847h9.2954l2.3371-4.3881h-18.8854l14.8992 27.8103z",fill:"currentColor"})]})})})}function Tt(t){return a(St,{...t,children:w("svg",{fill:"none",height:"24",viewBox:"0 0 52 24",width:"52",xmlns:"http://www.w3.org/2000/svg",children:[a("path",{d:"m5 11.5v1h1.85l3.5 3.5h4.65v-8h-4.65l-3.5 3.5zm-2-2h3l3.5-3.5h5.5c.55 0 1.0208.19583 1.4125.5875s.5875.8625.5875 1.4125v1l-1-1h5v2h-4v4h4v2h-5l1-1v1c0 .55-.1958 1.0208-.5875 1.4125s-.8625.5875-1.4125.5875h-5.5l-3.5-3.5h-3z",fill:"currentColor"}),a("path",{d:"m47 12.5v-1h-1.85l-3.5-3.5h-4.65v8h4.65l3.5-3.5zm2 2h-3l-3.5 3.5h-5.5c-.55 0-1.0208-.1958-1.4125-.5875s-.5875-.8625-.5875-1.4125v-1l1 1h-5v-2h4v-4h-4v-2h5l-1 1v-1c0-.55.1958-1.02083.5875-1.4125s.8625-.5875 1.4125-.5875h5.5l3.5 3.5h3z",fill:"currentColor"})]})})}const kr=({onAuthorize:t,onClose:e,isAuthorizing:r,isOpen:n})=>w(Ze,{maxWidth:"sm",open:n,slotProps:{paper:{sx:{width:"100%",m:4,p:6,overflow:"hidden"}}},onClose:e,children:[a(U,{color:"text.secondary",sx:{mb:6},variant:"h6",children:"Google Drive"}),w(_,{sx:{display:"flex",flexDirection:"column",gap:6,alignItems:"center"},children:[w(_,{sx:{display:"flex",flexDirection:"row",gap:0,alignItems:"center",justifyContent:"center"},children:[a($t,{sx:{width:80,height:80,color:"primary.main"}}),a(Tt,{sx:{width:52,height:24}}),a(fr,{sx:{width:80,height:80}})]}),a(U,{variant:"body1",children:"Please authorize Vidoso below."}),w(_,{sx:{display:"flex",flexDirection:"row",gap:3,justifyContent:"center",p:5,pt:0},children:[a(re,{size:"medium",sx:{borderRadius:"8px"},variant:"text",onClick:e,children:"Cancel"}),a(re,{"data-testid":"apply-filter-button",disabled:r,size:"medium",startIcon:r?a(Ye,{size:20}):null,variant:"contained",onClick:t,children:"Authorize"})]})]})]}),Cr="https://accounts.google.com/gsi/client?prompt=consent",Ir=t=>{const e=document.createElement("script");e.src=t,document.body.appendChild(e)},Pr=()=>(window.google?.accounts?.oauth2||Ir(Cr),u.useCallback(async t=>new Promise((e,r)=>{const n="151509972957-lhd3v8bt64ot1iroc4ivhp6v0ol0nqvt.apps.googleusercontent.com";if(!window.google?.accounts?.oauth2){r(new Error("Google Identity Services is not ready"));return}window.google.accounts.oauth2.initCodeClient({client_id:n,scope:t,callback:e,error_callback:r,prompt:"consent",access_type:"offline",include_granted_scopes:!1}).requestCode()}),[]));function Rr(t,e){const{onPicked:r,onCanceled:n,onOauthError:s,onOauthResponse:i}=e;u.useEffect(()=>{const c=t.current;if(!c)return;const o={"picker-picked":r,"picker-canceled":n,"picker-oauth-error":s,"picker-oauth-response":i},l={};
1return Object.entries(o).forEach(([h,f])=>{if(f){const m=y=>f(y);l[h]=m,c.addEventListener(h,m)}}),()=>{Object.entries(l).forEach(([h,f])=>{c.removeEventListener(h,f)})}},[t,r,n,s,i])}var Sr=t=>{const{onPicked:e,onCanceled:r,onOauthError:n,onOauthResponse:s,children:i,...c}=t,o=u.useRef(null);return Rr(o,{onPicked:e,onCanceled:r,onOauthError:n,onOauthResponse:s}),u.useEffect(()=>{dr(()=>import("./index.iife.min-Bw0QywbL.js"),[],import.meta.url)},[]),_t.jsx("drive-picker",{ref:o,...c,children:i})},mt=t=>_t.jsx("drive-picker-docs-view",{...t});const _r=({mode:t,viewId:e,mimeTypes:r,isOpen:n,onCancel:s,onPicked:i,accessToken:c})=>{if(!c||!n)return null;const o={mode:t,"mime-types":r,"view-id":e};return w(Sr,{multiselect:!0,"developer-key":"AIzaSyDw51mddPrTM8XglW3IxlcNBKUk4-bBuxw","oauth-token":c,onCanceled:()=>{s()},onPicked:l=>{i(l.detail)},children:[a(mt,{...o,"owned-by-me":"true"}),a(mt,{...o,"owned-by-me":"false"})]})},Er="https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/drive.file",Ft=Et.createContext({pickFiles:async()=>[],getFiles:async()=>[],publishFile:async()=>({id:"",name:"",web_view_link:"",mime_type:"",created_time:""}),authorize:async()=>!1,isPublishing:!1}),Vn=()=>u.useContext(Ft),Kn=({children:t})=>{const[e,r]=u.useState(!1),{isOpen:n,open:s,close:i}=we(),{isOpen:c,open:o,close:l,context:h}=we(),f=Pr(),{data:m}=nr(),[y]=sr(),[$]=ir(),[M,{isLoading:T}={}]=or(),E=u.useCallback(async()=>{try{r(!0);const p=await f(Er);if(p.error)throw new Error(p.error);try{return await $({oAuthExchangePayload:{code:p.code}}).unwrap(),!0}catch(C){const k=Ue(C,"Unable to authorize");return ce(`Unable to authorize: ${k}`,{variant:"error"}),!1}}catch{return!1}finally{r(!1)}},[$,f]),F=u.useCallback(async p=>{if(m?.status!==$e.Connected){const S=await s();if(S.action===v.Cancel||S.action===v.Error)return[]}const C=await y().unwrap(),k=await o({mimeTypes:p?.mimeTypes?.join(","),mode:p?.mode,viewId:p?.viewId,accessToken:C?.access_token});return k.action===v.Select?k.payload:[]},[y,s,o,m?.status]),A=u.useCallback(async p=>{if(m?.status!==$e.Connected){const S=await s();if(S.action===v.Cancel||S.action===v.Error)return[]}const C=await y().unwrap(),k=await o({mimeTypes:p?.mimeTypes?.join(","),mode:p?.mode,viewId:p?.viewId,accessToken:C?.access_token});return k.action===v.Select?await Promise.all(k.payload.map(async S=>Mt.get(`https://www.googleapis.com/drive/v3/files/${encodeURIComponent(S.id)}?alt=media&supportsAllDrives=true`,{headers:{Authorization:`Bearer ${C?.access_token}`},responseType:"blob"}).then(pe=>new File([pe.data],S.name,{type:S.mimeType||pe.data.type})))):[]},[y,s,o,m?.status]),O=u.useCallback(async p=>{if(m?.status!==$e.Connected){const k=await s();if(k.action===v.Cancel||k.action===v.Error)return null}const C=await M({googleDrivePublishPayload:{context:p}}).unwrap();return Dt({url:C.web_view_link,variant:"publishGDrive",anchorOrigin:{vertical:"bottom",horizontal:"right"},persist:!0}),C},[s,m?.status,M]),B=u.useMemo(()=>({pickFiles:F,getFiles:A,publishFile:O,authorize:E,isPublishing:T??!1}),[F,A,O,E,T]),j=p=>{l(v.Select,p.docs)},G=()=>{l(v.Cancel)},ee=()=>{i(v.Cancel)},K=async()=>{try{await E()?i(v.Authenticate):i(v.Error)}catch(p){ce(p.message,{variant:"error"})}};return w(Ft.Provider,{value:B,children:[t,a(kr,{isAuthorizing:e,isOpen:n,onAuthorize:K,onClose:ee}),a(_r,{...h,isOpen:c,onCancel:G,onPicked:j})]})},Or=({onAuthorize:t,onClose:e,isAuthorizing:r,isOpen:n})=>w(Ze,{maxWidth:"sm",open:n,slotProps:{paper:{sx:{width:"100%",m:4,p:6,overflow:"hidden"}}},onClose:e,children:[a(U,{color:"text.secondary",sx:{mb:6},variant:"h6",children:"Microsoft OneDrive / SharePoint"}),w(_,{sx:{display:"flex",flexDirection:"column",gap:6,alignItems:"center"},children:[w(_,{sx:{display:"flex",flexDirection:"row",gap:0,alignItems:"center",justifyContent:"center"},children:[a($t,{sx:{width:80,height:80,color:"primary.main"}}),a(Tt,{sx:{width:52,height:24}}),a(pr,{sx:{width:80,height:80}})]}),a(U,{variant:"body1",children:"Please authorize Vidoso below."}),w(_,{sx:{display:"flex",flexDirection:"row",gap:3,justifyContent:"center",p:5,pt:0},children:[a(re,{size:"medium",sx:{borderRadius:"8px"},variant:"text",onClick:e,children:"Cancel"}),a(re,{"data-testid":"onedrive-authorize-button",disabled:r,size:"medium",startIcon:r?a(Ye,{size:20}):null,variant:"contained",onClick:t,children:"Authorize"})]})]})]}),Fe="https://graph.microsoft.com/v1.0";function Mr(t){return t.siteId?`${Fe}/sites/${encodeURIComponent(t.siteId)}/drive/items/${encodeURIComponent(t.id)}/content`:t.driveId?`${Fe}/drives/${encodeURIComponent(t.driveId)}/items/${encodeURIComponent(t.id)}/content`:`${Fe}/me/drive/items/${encodeURIComponent(t.id)}/content`}const Dr=async(t,e)=>{const r=Mr(e),n=await Mt.get(r,{headers:{Authorization:`Bearer ${t}`},responseType:"blob"});return new File([n.data],e.name,{type:e.mimeType||n.data.type})}
1,$r="https://login.microsoftonline.com/common/oauth2/v2.0/authorize",Tr=["offline_access","Files.ReadWrite.All","Sites.ReadWrite.All","User.Read"].join(" "),Fr=300*1e3,zr=()=>u.useCallback(async()=>{const t="d3a2a38d-0924-44aa-a452-a5b6ec2171c6",e="https://app.vidoso.ai/app/integration/outlook/callback",r=new URLSearchParams({client_id:t,response_type:"code",redirect_uri:e,scope:Tr,response_mode:"query"}),n=`${$r}?${r.toString()}`;return window.open(n,"onedrive-auth","width=600,height=700")?new Promise(i=>{const c=setTimeout(()=>{l(),i(null)},Fr),o=h=>{h.origin!==window.location.origin||h.data?.type!==gr||(l(),typeof h.data.code=="string"?i(h.data.code):i(null))},l=()=>{window.removeEventListener("message",o),clearTimeout(c)};window.addEventListener("message",o)}):null},[]),Lr=(t,e,r,n)=>({field:t,headerName:e,disableColumnMenu:!0,renderCell:s=>r(s),...n}),Ur=({value:t},{titleDateFormat:e="MM/dd/yy HH:mm",valueDateFormat:r="MM/dd/yy"})=>{if(!t)return"-";const n=pt(t,e),s=pt(t,r);return a("span",{title:n,children:s})},qr=(t,e,r={})=>({field:t,headerName:e,width:150,disableColumnMenu:!0,renderCell:n=>Ur(n,r)}),Ar=({value:t})=>t?w(_,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-start",alignItems:"center",gap:2,overflow:"clip"},children:[a(Jt,{alt:t?.name,src:t?.avatar_url??"",sx:{width:"32px",height:"32px"}}),a(U,{sx:{textOverflow:"ellipsis",whiteSpace:"pre",overflow:"clip"},variant:"body2",children:t?.name})]}):"-",Br=(t,e)=>({field:t,headerName:e,width:211,renderCell:Ar,disableColumnMenu:!0,sortComparator:(r,n)=>r?.name.localeCompare(n?.name)}),jr="image/";function Gr(t){return t.toLowerCase().startsWith(jr)}function Nr(t,e){const n=t.folder!=null?"application/vnd.microsoft.folder":t.file?.mimeType??"application/octet-stream",s=t.lastModifiedBy?.user?.displayName??t.createdBy?.user?.displayName??"",i=t.thumbnails?.[0]?.medium?.url??t.thumbnails?.[0]?.small?.url??void 0;return{id:t.id??"",name:t.name??"",mimeType:n,sizeBytes:t.size??0,driveId:t.parentReference?.driveId??"",sharepointEndpoint:"",webUrl:t.webUrl??"",owner:{name:s},lastModifiedDateTime:t.lastModifiedDateTime??"",thumbnailUrl:i,siteId:e}}const yt="__parent__",gt=({row:t,isSelectable:e,isSelected:r,onSelect:n})=>{const s=t.mimeType==="application/vnd.microsoft.folder";return w(rr,{children:[w(_,{sx:{aspectRatio:"1",backgroundColor:"action.hover",position:"relative",overflow:"hidden"},children:[t.thumbnailUrl?a(_,{alt:t.name,component:"img",src:t.thumbnailUrl,sx:{width:"100%",height:"100%",objectFit:"cover"}}):a(X,{alignItems:"center",justifyContent:"center",sx:{height:"100%"},children:s?a(Le,{sx:{color:"action.active",fontSize:48}}):a(ht,{sx:{color:"action.active",fontSize:48}})}),e&&n&&a(tr,{checked:r,sx:{position:"absolute",top:4,right:4,bgcolor:"background.paper","&:hover":{bgcolor:"background.paper"}},onChange:(i,c)=>n(c),onClick:i=>{i.stopPropagation(),n(!r)}})]}),w(X,{alignItems:"center",direction:"row",gap:1,p:1,spacing:0,children:[s?a(Le,{sx:{color:"action.active",fontSize:20}}):a(ht,{sx:{color:"action.active",fontSize:20}}),a(U,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},variant:"caption",children:t.name})]})]})},Wr=({row:t})=>{const e=t.mimeType==="application/vnd.microsoft.folder",s=t.isParentRow===!0?Ot:e?Le:er;return w(X,{alignItems:"center",direction:"row",gap:2,children:[a(s,{sx:{color:"action.active",fontSize:24}}),a(U,{sx:{color:"text.primary",wordBreak:"break-word",WebkitBoxOrient:"vertical",WebkitLineClamp:"2",overflow:"clip",display:"-webkit-box"},variant:"subtitle2",children:t.name})]})},Hr=(t,e)=>u.useMemo(()=>t!=="GRID"||e==null||e.length===0?!1:e.some(Gr),[t,e]),Qr=({isOpen:t,title:e,loadFiles:r,mode:n="LIST",mimeTypes:s,onCancel:i,onPicked:c,extraActions:o})=>{const[l,h]=u.useState([]),[f,m]=u.useState(!1),[y,$]=u.useState(null),[M,T]=u.useState([]),[E,F]=u.useState([]),A=Hr(n,s),O=u.useCallback(async d=>{m(!0),$(null);try{const x=await r(d);h(x)}catch(x){const N=x instanceof Error?x.message:"Failed to load files";$(N),h([])}finally{m(!1)}},[r]);u.useEffect(()=>{t&&(O(),T([]),F([]))},[t,O]);const B=u.useCallback(d=>{F(x=>[...x,d]),O(d)},[O]),j=u.useCallback(()=>{const d=E.slice(0,-1),x=d.length>0?d.at(-1):void 0;F(d),O(x)},[E,O]),G=u.useMemo(()=>{const d={id:yt,name:"..",mimeType:"",sizeBytes:0,driveId:"",sharepointEndpoint:"",webUrl:"",owner:{name:""},lastModifiedDateTime:"",isParentRow:!0};return E.length>0?[d,...l]:l},[l,E.length]),ee=u.useMemo(()=>M.filter(d=>d!==yt&&!l.some(x=>x.id===d&&x.mimeType==="application/vnd.microsoft.folder")),[M,l]),K=u.useMemo(()=>l.filter(d=>ee.includes(d.id)),[l,ee]),p=u.useCallback(d=>{const x=d.row;if(x.isParentRow){j();return}x.mimeType==="application/vnd.microsoft.folder"&&B(x.id)},[j,B]),C=u.useCallback(()=>{c(K)},[c,K]),k=u.useCallback(()=>{i()},[i]),S=u.useMemo(()=>[Lr("name","Name",({row:d})=>
1a(Wr,{row:d}),{flex:1}),Br("owner","Owner"),qr("lastModifiedDateTime","Last modified")],[]),pe=u.useCallback(()=>a(ft,{icon:lt,subtitle:"No files in this folder",sx:{maxWidth:400},title:"No files found"}),[]),Vt=u.useCallback(d=>{const x=d.row;return x.isParentRow?!1:x.mimeType!=="application/vnd.microsoft.folder"},[]),at=K.length,ct=u.useCallback(d=>{d.mimeType==="application/vnd.microsoft.folder"&&B(d.id)},[B]),Oe=u.useCallback((d,x)=>{d.mimeType!=="application/vnd.microsoft.folder"&&T(N=>x?[...N,d.id]:N.filter(Me=>Me!==d.id))},[]),Kt=u.useCallback(()=>G.length===0?a(ft,{icon:lt,subtitle:"No files in this folder",sx:{maxWidth:400},title:"No files found"}):a(_,{sx:{minHeight:400,overflow:"auto"},children:a(De,{container:!0,spacing:2,children:G.map(d=>{if(d.isParentRow)return a(De,{size:{xs:12},children:a(ut,{sx:{borderRadius:2,border:"1px solid",borderColor:"divider"},children:a(dt,{onClick:j,children:w(X,{alignItems:"center",direction:"row",gap:2,p:2,spacing:0,children:[a(Ot,{sx:{color:"action.active",fontSize:24}}),a(U,{variant:"subtitle2",children:d.name})]})})})},d.id);const x=d.mimeType==="application/vnd.microsoft.folder",N=M.includes(d.id);return a(De,{size:{xs:5,sm:4,md:2},children:a(ut,{sx:{borderRadius:2,border:"1px solid",borderColor:N?"primary.main":"divider",overflow:"hidden"},children:x?a(dt,{onClick:()=>{ct(d)},children:a(gt,{isSelectable:!1,isSelected:!1,row:d})}):a(_,{sx:{cursor:"pointer"},onClick:()=>{Oe(d,!N)},children:a(gt,{isSelectable:!0,isSelected:N,row:d,onSelect:Me=>{Oe(d,Me)}})})})},d.id)})})}),[G,M,j,ct,Oe]);return t?w(Ze,{fullWidth:!0,maxWidth:"md",open:t,onClose:k,children:[a(Xt,{children:e}),w(Yt,{sx:{display:"flex",flexDirection:"column",py:0},children:[f&&a(_,{display:"flex",justifyContent:"center",py:4,children:a(Ye,{})}),y!=null&&a(U,{color:"error",sx:{py:2},children:y}),!f&&y==null&&A&&Kt(),!f&&y==null&&!A&&a(_,{sx:{display:"flex",flexDirection:"column",flexGrow:1,overflow:"clip",minHeight:0,mx:-6},children:a(vr,{value:{highlight:""},children:a(mr,{autoHeight:!1,checkboxSelection:!0,pagination:!0,columns:S,disableRowSelectionOnClick:!1,initialState:{pagination:{paginationModel:{pageSize:25}}},isRowSelectable:Vt,rowSelectionModel:M,rows:G,slots:{noRowsOverlay:pe},onRowClick:p,onRowSelectionModelChange:d=>{T(d)}})})})]}),a(Zt,{children:w(X,{justifyContent:"space-between",direction:"row",sx:{width:"100%"},children:[a(X,{gap:2,direction:"row",children:o}),w(X,{gap:2,direction:"row",children:[a(re,{onClick:k,children:"Cancel"}),w(re,{disabled:at===0,variant:"contained",onClick:C,children:["Import selected (",at,")"]})]})]})})]}):null};function z(...t){return t.filter(e=>!xe(e)).map(e=>e.replace(/^[\\|/]/,"").replace(/[\\|/]$/,"")).join("/").replace(/\\/g,"/")}function Vr(){let t=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const r=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(e==="x"?r:r&3|8).toString(16)})}function et(t){return typeof t=="function"}function Ie(t){return Array.isArray(t)}function vt(t){return/^https?:\/\/|^\/\//i.test(t)}function xe(t){return typeof t>"u"||t===null||t.length<1}function qe(t){return typeof t<"u"&&t!==null}function Kr(t){return JSON.stringify(t)}function ye(t,e){return Object.hasOwnProperty.call(t,e)}function Jr(t){return new Promise(e=>{setTimeout(e,t)})}function zt(){return function(t,...e){const r=[...t];for(let n=0;n<r.length;n++)Reflect.apply(r[n],this,e)}}function Xr(){return function(t,...e){return[...t].reduce((n,s)=>Reflect.apply(s,this,n),e)}}function me(){return async function(t,...e){return[...t].reduce((n,s)=>n.then(i=>Reflect.apply(s,this,i)),Promise.resolve(e))}}function Yr(){return async function(t,...e){if(!Ie(t)||t.length<1)return;const r=t[0];return Reflect.apply(r,this,e)}}function Lt(){return function(t,...e){const r=[...t];for(let n=0;n<r.length;n++)Reflect.apply(r[n],this,e);return this}}const Zr=Symbol.for("ObserverLifecycleFlags"),Ut=t=>(e=>!((e[Zr]||0)&t));class en{constructor(e,r={}){this.moments=e,this.observers=r,this._onProxy=null,this._emitProxy=null,this._inheritingObservers=!0}using(...e){for(let r=0;r<e.length;r++)e[r](this);return this}get on(){return this._onProxy===null&&(this._onProxy=new Proxy(this,{get:(e,r)=>Object.assign(n=>(e.cloneObserversOnChange(),ze(e.observers,r,n,1),e),{toArray:()=>Reflect.has(e.observers,r)?[...Reflect.get(e.observers,r)]:[],replace:n=>(e.cloneObserversOnChange(),ze(e.observers,r,n,3),e),prepend:n=>(e.cloneObserversOnChange(),ze(e.observers,r,n,2),e),clear:()=>Reflect.has(e.observers,r)?(e.cloneObserversOnChange(),e.observers[r].length=0,!0):!1})})),this._onProxy}log(e,r=0){this.emit.log(e,r)}error(e){qe(e)&&this.emit.error(e)}get emit(){return this._emitProxy===null&&(this._emitProxy=new Proxy(this,{get:(e,r)=>(...n)=>{const s=Reflect.has(e.observers,r)?Reflect.get(e.observers,r):[];if((!Ie(s)||s.length<1)&&r==="error")throw Error(`Unhandled Exception: ${n[0]}`);try{const i=Reflect.has(e.moments,r)?Reflect.get(e.moments,r):r==="init"||r==="dispose"?Lt():zt();return Reflect.apply(i,e,[s,...n])}catch(i){if(r!=="error")this.error(i);else throw i}finally{s&&s.length>0&&Reflect.set(e.observers,r,s.filter(Ut(2)))}}})),this._emitProxy}start(e){this.emit.init();const r=this.execute(e);return r.finally(()=>{try{this.emit.dispose()}catch(n){const s=Object.assign(Error("Error in dispose."),{innerException:n});this.error(s)}}).catch(()=>{}),r}cloneObserversOnChange(){this._inheritingObservers&&(this._inheritingObservers=!1,this.observers=qt(this.observers))}}function ze(t,e,r,n){if(!et(r))throw Error("Observers must be functions.");if(!Reflect.has(t,e))t[e]=[r];else switch(n){case 1:t[e].push(r);break;case 2:t[e].unshift(r);break;case 3:t[e].length=0,t[e].push(r);break}return t[e]}function qt(t){return Reflect.ownKeys(t).reduce((e,r)=>(e[r]=[...t[r].filter(Ut(1))],e),{})}function tn(t){return e=>(e.observers=t.observers,e._inheritingObservers=!0,e)}function rn(t,e="append",r){return n=>Reflect.apply(nn,n,[t,e,r])}function nn(t,e,r){if(!qe(t)||!qe(t.observers))return this;et(r)||(r=()=>!0);const n=qt(t.observers),s=Object.keys(n).filter(r);for(let i=0;i<s.length;i++){const c=s[i],o=this.on[c];
1e==="replace"&&o.clear(),n[c].forEach(h=>o(h))}return this}const sn={construct:Lt(),pre:me(),auth:me(),send:Yr(),parse:me(),post:me(),data:zt()};let Ae=class extends en{constructor(e,r){super(sn),this.InternalResolve=Symbol.for("Queryable_Resolve"),this.InternalReject=Symbol.for("Queryable_Reject"),this.InternalPromise=Symbol.for("Queryable_Promise"),this._query=new URLSearchParams,this.moments[this.InternalPromise]=Xr();let n;if(typeof e=="string")this._url=z(e,r);else if(Ie(e)){if(e.length!==2)throw Error("When using the tuple param exactly two arguments are expected.");if(typeof e[1]!="string")throw Error("Expected second tuple param to be a string.");n=e[0],this._url=z(e[1],r)}else n=e,this._url=z(n._url,r);typeof n<"u"&&(this.observers=n.observers,this._inheritingObservers=!0)}concat(e){return this._url+=e,this}toRequestUrl(){let e=this.toUrl();const r=this.query.toString();return xe(r)||(e+=`${e.indexOf("?")>-1?"&":"?"}${r}`),e}get query(){return this._query}toUrl(){return this._url}execute(e){if(Reflect.ownKeys(this.observers).length<1)throw Error("No observers registered for this request. (https://pnp.github.io/pnpjs/queryable/queryable#no-observers-registered-for-this-request)");return setTimeout(async()=>{const r=Vr();let n;const s=(i,c)=>{this.log(`[${r}] ${i}`,c)};try{s("Beginning request",0);const i={...e,headers:{...e.headers,"X-PnPjs-RequestId":r}};let[c,o,l]=await this.emit.pre(this.toRequestUrl(),i,void 0);if(s(`Url: ${c}`,1),typeof l<"u"){s("Result returned from pre, Emitting data"),this.emit.data(l),s("Emitted data");return}s("Emitting auth"),[n,o]=await this.emit.auth(new URL(c),o),s("Emitted auth"),o={...o,...e,headers:{...o.headers,...e.headers}},s("Emitting send");let h=await this.emit.send(n,o);s("Emitted send"),s("Emitting parse"),[n,h,l]=await this.emit.parse(n,h,l),s("Emitted parse"),s("Emitting post"),[n,l]=await this.emit.post(n,l),s("Emitted post"),s("Emitting data"),this.emit.data(l),s("Emitted data")}catch(i){s(`Emitting error: "${i.message||i}"`,3),this.error(i),s("Emitted error",3)}finally{s("Finished request",0)}},0),this.emit[this.InternalPromise](new Promise((r,n)=>{this.on[this.InternalResolve].replace(r),this.on[this.InternalReject].replace(n)}))[0]}};Ae=R([dn()],Ae);function he(t,e={headers:{}}){return{method:t,...e,headers:{...e.headers}}}function At(t){return this.start(he("GET",t))}function on(t){return this.start(he("POST",t))}function an(t){return this.start(he("PUT",t))}function cn(t){return this.start(he("PATCH",t))}function ln(t){return this.start(he("DELETE",t))}function ie(t,e,r){return Reflect.apply(e,t,[r])}function un(t){return(e,r)=>{const n=new t(e,r);return n.emit.construct(e,r),n}}function dn(t){return e=>new Proxy(e,{construct(r,n,s){const i=Object.assign(function(c){return et(t)||(t=function(o){return ie(this,At,o)}),Reflect.apply(t,i,[c])},Reflect.construct(r,n,s));return Reflect.setPrototypeOf(i,s.prototype),i}})}function Y(t,e=!1){return r=>{const n=async function(s,i,c){return i.headers={...i.headers,...t},[s,i,c]};return e?r.on.pre.prepend(n):r.on.pre(n),r}}function hn(t){return e=>(e.using(Y({Authorization:`Bearer ${t}`})),e)}function fn(){return jt(async t=>{if(t.headers.has("Content-Length")&&parseFloat(t.headers.get("Content-Length"))===0||t.status===204)return{};const e=await t.text(),r=e.replace(/\s/ig,"").length>0?JSON.parse(e):{};return Bt(r)})}function bt(){return jt(t=>t.blob())}async function tt(t,e,r){if(!e.ok)throw await Pe.init(e);return[t,e,r]}function Bt(t){let e=t;return ye(t,"d")?ye(t.d,"results")?e=t.d.results:e=t.d:ye(t,"value")&&(e=t.value),e}function jt(t){return e=>(e.on.parse.replace(tt),e.on.parse(async(r,n,s)=>(n.ok&&typeof s>"u"&&(s=await t(n)),[r,n,s])),e)}class Pe extends Error{constructor(e,r,n=r.status,s=r.statusText){super(e),this.response=r,this.status=n,this.statusText=s,this.isHttpRequestError=!0}static async init(e){const r=await e.clone().text();return new Pe(`Error making HttpClient request in queryable [${e.status}] ${e.statusText} ::> ${r}`,e)}}function pn(t){const{interval:e,replace:r,retries:n}={replace:!0,interval:200,retries:3,...t};return s=>(r&&s.on.send.clear(),s.on.send(function(i,c){let o,l=e,h=0,f;const m=async()=>
1{if(h>=n)throw f||new Pe(`Retry count exceeded (${n}) for this request. ${o.status}: ${o.statusText};`,o);if(h++,typeof o>"u"||o?.status===429||o?.status===503||o?.status===504){typeof o<"u"&&(o.headers.has("Retry-After")?l=parseInt(o.headers.get("Retry-After"),10)*1e3:l*=2,this.log(`Attempt #${h} to retry request which failed with ${o.status}: ${o.statusText}`,0),await Jr(l));try{const y=i.toString();return this.log(`Fetch: ${c.method} ${y}`,0),o=await fetch(y,c),o.ok?o:m()}catch(y){if(/AbortError/.test(y.name))throw y;return f=y,m()}}else return o};return m()}),s)}function wt(){return t=>(t.on.pre.prepend(async function(e,r,n){return r.headers={...r.headers,"X-PnP-CacheNever":"1"},[e,r,n]}),t)}function mn(){return t=>(t.on.data(function(e){this.emit[this.InternalResolve](e)}),t)}function yn(){return t=>(t.on.error(function(e){this.emit[this.InternalReject](e)}),t)}function Q(t,e,r,n){Reflect.defineProperty(t.prototype,e,{configurable:!0,enumerable:!0,get:function(){return r(this,e)}})}function b(t,e){return Object.assign({body:Kr(t)},e)}function Be(t="eventual"){return e=>(e.on.pre(async function(r,n,s){return n.headers={...n.headers,ConsistencyLevel:t},[r,n,s]}),e)}async function gn(t){const e=L(t).using(Gt(),Be());return e.query.set("$count","true"),e.top(1),(await e()).count}function Gt(t=!1){return e=>(e.on.parse.replace(tt),e.on.parse(async(r,n,s)=>{const i=await n.text(),c=i.replace(/\s/ig,"").length>0?JSON.parse(i):{},o=c["@odata.nextLink"],l=c["@odata.deltaLink"],h=t&&ye(c,"@odata.count")?parseInt(c["@odata.count"],10):0,f=!xe(o),m=!xe(l);return s={count:h,hasNext:f,nextLink:f?o:null,deltaLink:m?l:null,value:Bt(c)},[r,n,s]}),e)}const I=t=>un(t);class rt extends Ae{constructor(e,r){super(e,r),this._query=new wn,typeof e=="string"?this.parentUrl=e:Ie(e)?this.parentUrl=e[0].toUrl():this.parentUrl=e.toUrl()}select(...e){return e.length>0&&this.query.set("$select",e.join(",")),this}expand(...e){return e.length>0&&this.query.set("$expand",e.join(",")),this}getParent(e,r,n=this.parentUrl){return e([this,n],r)}}const H=I(rt);class V extends rt{filter(e){return this.query.set("$filter",e),this}orderBy(e,r=!0){var n;const s="$orderby",i=((n=this.query.get(s))===null||n===void 0?void 0:n.split(","))||[];return i.push(`${e} ${r?"asc":"desc"}`),this.query.set(s,i.join(",")),this}top(e){return this.query.set("$top",e.toString()),this}skip(e){return this.query.set("$skip",e.toString()),this}search(e){return this.using(Be()),this.query.set("$search",e),this}skipToken(e){return this.query.set("$skiptoken",e),this}[Symbol.asyncIterator](){const e=L(this).using(Gt(),Be());for(const[r,n]of this.query)e.query.set(r,n);return{_next:e,async next(){if(this._next===null)return{done:!0,value:void 0};const r=await this._next();return r.hasNext?(this._next=L([this._next,r.nextLink]),{done:!1,value:r.value}):(this._next=null,{done:!1,value:r.value})}}}}const L=I(V);class q extends rt{}const vn=I(q),bn=(t,e)=>ie(t,At,e),g=(t,e)=>ie(t,on,e),Re=(t,e)=>ie(t,ln,e),ge=(t,e)=>ie(t,cn,e),nt=(t,e)=>ie(t,an,e);class wn extends Map{toString(){const e=new URLSearchParams,r=[];for(const n of this)/\/any\(.*?\)/i.test(n[1])?r.push(`${n[0]}=${n[1]}`):e.append(n[0],n[1]);return r.push(e.toString()),r.join("&")}}class Se{constructor(e=""){this._root=H(e)}using(...e){return this._root.using(...e),this}create(e,r){return e(this._root,r)}}function xn(t=""){return typeof t=="object"&&!Reflect.has(t,"length")&&(t=t._root),new Se(t)}function D(t){return function(e){return class extends e{constructor(...r){super(r[0],r.length>1&&r[1]!==void 0?r[1]:t)}}}}function oe(){return function(t){return class extends t{delete(){return Re(this)}}}}function fe(){return function(t){return class extends t{update(e){return ge(this,b(e))}}}}function kn(){return function(t){return class extends t{add(e){return g(this,b(e))}}}}function Z(t){return function(e){return class extends e{getById(r){return t(this,`${r}`)}}}}function Cn(){return function(t){return class extends t{delta(e={}){var r;const n=((r=Object.keys(e))===null||r===void 0?void 0:r.map(c=>`${c}=${e[c]}`).join("&"))||"",s=n.length>0?`delta?${n}`:"delta",i=L(this,s);return e?.maxPageSize&&i.using(Y({Prefer:`odata.maxpagesize=${e.maxPageSize}`})),i.on.parse.replace(tt),i.on.parse(async(c,o,l)=>{const h=await o.json(),f=h["@odata.nextLink"],m=h["@odata.deltaLink"];return l={next:()=>f?L([this,f]):null,delta:()=>m?L([i,m])():null,values:h.value},[c,o,l]}),i}}}}let le=class extends q{getMemberObjects(e=!1){return g(ve(this,"getMemberObjects"),b({securityEnabledOnly:e}))}getMemberGroups(e=!1){return g(ve(this,"getMemberGroups"),b({securityEnabledOnly:e}))}checkMemberGroups(e){return g(ve(this,"checkMemberGroups"),b({groupIds:e}))}};le=R([oe()],le);const ve=I(le);let ne=class extends V{getByIds(e,r=Ge.directoryObject){return g(je(this,"getByIds"),b({ids:e,type:r}))}async count(){return gn(this)}};ne=R([D("directoryObjects"),Z(ve)],ne);const je=I(ne);var Ge;(function(t){t[t.directoryObject=0]="directoryObject",t[t.user=1]="user",t[t.group=2]="group",t[t.device=3]="device"})(Ge||(Ge={}));let ue=class extends le{get memberOf(){return je(this,"memberOf")}get transitiveMemberOf(){return je(this,"transitiveMemberOf")}get people(){return xt(this)}get directReports(){return xt(this,"directReports")}get manager(){return st(this,"manager")}};ue=R([fe(),oe()],ue);const st=I(ue);let Ne=class extends ne{};Ne=R([D("users"),Z(st)],Ne);const In=I(Ne);let We=class extends ne{};We=R([D("people")],We);const xt=I(We);Reflect.defineProperty(Se.prototype,"me",{configurable:!0,enumerable:!0,get:function(){return this.create(st,"me")}});Reflect.defineProperty(Se.prototype,"users",{configurable:!0,enumerable:!0,get:function(){return this.create(In)}});async function Nt(t){let e="/content";t.filePathName&&(e=`:/${t.filePathName}:/content`);const r=P(this,null);if(r.concat(e),t.contentType&&r.using(Y({"Content-Type":t.contentType})),t.eTag){const n={};n[t.eTagMatch||"If-Match"]=t.eTag,r.using(Y(n))}return await nt(r,{body:t.content})}class Pn extends q{get status(){return H(this)}async upload(e,r,n){const s=n||`bytes 0-${e-1}/${e}`;return nt(this,{body:r,headers:{"Content-Length":e.toString(),"Content-Range":s}})}async cancel(){return Re(this,b(null))}}const Rn=I(Pn);async function Sn(t){const e=t.create!=null?t.create:!0,r=this.toRequestUrl(),n=H(`${r}${e?`:/${t.item.name}:/`:""}createUploadSession`).using(tn(this));if(t.eTag){const l={};l[t.eTagMatch||"If-Match"]=t.eTag,n.using(Y(l))}const s={};(t.conflictBehavior||t.item)&&(Object.defineProperty(s,"item",{value:{},writable:!0}),t.item&&(s.item=t.item),s.item["@microsoft.graph.conflictBehavior"]=t.conflictBehavior||"rename"),t.deferCommit&&Object.defineProperty(s,"deferCommit",{value:t.deferCommit});const i=await g(n,b(s)),c=H(i.uploadUrl).using(rn(this,"replace",l=>/(pre|init|send|parse|post|data|error)/i.test(l))),o=Rn(c);return{session:i,resumableUpload:o}}let se=class extends q{get root(){return _n(this)}get recent(){return W(this,"recent")}async sharedWithMe(e=null){const r=W(this,"sharedWithMe");return e?.allowExternal!=null&&r.query.set("allowexternal",e?.allowExternal.toString()),r()}getItemById(e){return P(this,z("items",e))}get following(){return W(this,"following")}
1getItemsByPath(e){return W(this,z("root:/",`${e}:/children`))}getItemByPath(e){return P(this,z("root:/",`${e}:`))}};se=R([D("drive")],se);const _e=I(se);let He=class extends V{};He=R([D("drives"),Z(_e)],He);const Ee=I(He);let Qe=class extends q{get children(){return W(this,"children")}search(e){return L(this,`search(q='${e}')`)}get thumbnails(){return vn(this,"thumbnails")}async upload(e){return Reflect.apply(Nt,this,[e])}};Qe=R([D("root"),Cn()],Qe);const _n=I(Qe);let ke=class extends q{get children(){return W(this,"children")}get items(){return W(this,"items")}get thumbnails(){return L(this,"thumbnails")}get versions(){return L(this,"versions")}async moveItem(e){return ge(this,b(e))}async getContent(){const e=await this(),r=H([this,e["@microsoft.graph.downloadUrl"]],null).using(bt()).using(wt());return r.on.pre(async(n,s,i)=>(s.responseType="arraybuffer",[n,s,i])),r()}async copyItem(e){const r=P(this,"copy").using(i=>(i.on.parse(async(c,o,l)=>(l=o.headers.has("location")?o.headers:o,[c,o,l])),i)),n=await g(r,b(e));let s=null;return n.has("location")&&(s=n.get("location")),s}async convertContent(e){const r=H(this,`content?format=${e}`).using(bt()).using(wt());return r.on.pre(async(n,s,i)=>(s.responseType="arraybuffer",[n,s,i])),r()}async follow(){return await g(P(this,"follow"),b(null))}async unfollow(){return await g(P(this,"unfollow"),b(null))}async upload(e){return Reflect.apply(Nt,this,[e])}async createUploadSession(e){return Reflect.apply(Sn,this,[e])}async preview(e){return g(P(this,"preview"),b(e))}async permanentDelete(){return g(P(this,"permanentDelete"),b(null))}async assignSensitivityLabel(e){const r=await g(P(this,"assignSensitivityLabel"),b(e));let n=null;return r.has("location")&&(n=r.get("location")),n}async extractSensitivityLabels(){return g(P(this,"extractSensitivityLabels"),b(null))}retentionLabel(){return H(this,"retentionLabel")}async recordLocked(e){const r={retentionSettings:{isRecordLocked:e}};return ge(P(this,"retentionLabel"),b(r))}async removeRetentionLabel(){return Re(P(this,"retentionLabel"))}async updateRetentionLabel(e){const r={name:e};return ge(P(this,"retentionLabel"),b(r))}async checkIn(e){return g(P(this,"checkin"),b(e))}async checkOut(){return g(P(this,"checkout"))}};ke=R([oe(),fe()],ke);const P=I(ke);let Ve=class extends V{async add(e){const r={name:e.filename,file:e.driveItem||{},"@microsoft.graph.conflictBehavior":e.conflictBehavior||"rename"},n=await g(this,b(r)),s=P([this,`${z("drives",n.parentReference.driveId,"items",n.id)}`],"content");return s.using(Y({"Content-Type":e.contentType||"application/json"})),await nt(s,{body:e.content})}async addFolder(e){const r={name:e.name,folder:e.driveItem||{},"@microsoft.graph.conflictBehavior":e.conflictBehavior||"rename"};return await g(this,b(r))}};Ve=R([Z(P)],Ve);const W=I(Ve);Q(ue,"drive",_e);Q(ue,"drives",Ee);Q(se,"following",W);se.prototype.special=function(e){return P(this,`special/${e}`)};var kt;(function(t){t.Documents="documents",t.Photos="photos",t.CameraRoll="cameraroll",t.AppRoot="approot",t.Music="music"})(kt||(kt={}));ke.prototype.restore=function(e){return g(P(this,"restore"),b(e))};var te;(function(t){t[t.Office365=0]="Office365",t[t.Dynamic=1]="Dynamic",t[t.Security=2]="Security"})(te||(te={}));let de=class extends le{addFavorite(){return g(J(this,"addFavorite"))}removeFavorite(){return g(J(this,"removeFavorite"))}resetUnseenCount(){return g(J(this,"resetUnseenCount"))}subscribeByMail(){return g(J(this,"subscribeByMail"))}unsubscribeByMail(){return g(J(this,"unsubscribeByMail"))}getCalendarView(e,r){const n=J(this,"calendarView");return n.query.set("startDateTime",e.toISOString()),n.query.set("endDateTime",r.toISOString()),n()}};de=R([oe(),fe()],de);const J=I(de);let Ct=class extends ne{async add(e,r,n,s={}){let i={displayName:e,mailEnabled:n===te.Office365,mailNickname:r,securityEnabled:n!==te.Office365,...s};return n!==te.Security&&(i={...i,groupTypes:n===te.Office365?["Unified"]:["DynamicMembership"]}),g(this,b(i))}};Ct=R([D("groups"),Z(J)],Ct);Q(de,"drive",_e);Q(de,"drives",Ee);let Ke=class extends V{get root(){return ae(this,"root")}getById(e){return ae(this,e)}async getByUrl(e,r){return ae(this,`${e}:${z("/",r)}:`).rebase()}getAllSites(){return Wt(this,"getAllSites")}};Ke=R([D("sites")],Ke);const Wt=I(Ke);class it extends q{get sites(){return Wt(this)}async rebase(){const e=await ae(this).select("id")();return ae([this,`sites/${e.id}`])}}const ae=I(it);let Je=class extends V{add(...e){return g(It(this,"add"),b({value:e.map(r=>({id:r}))}))}remove(...e){return g(It(this,"remove"),b({value:e.map(r=>({id:r}))}))}};Je=R([D("followedsites")],Je);const It=I(Je);let Ce=class extends q{};Ce=R([oe(),fe()],Ce);const ot=I(Ce);let Pt=class extends V{};Pt=R([D("lists"),Z(ot),kn()],Pt);Q(it,"drive",_e);Q(it,"drives",Ee);Q(se,"list",ot);Ce.prototype.drive=function(){return bn(ot(this,"drive"))};let Xe=class extends q{async addItem(e){return g(this,b({id:e}))}async removeItem(e){return Re(H(this,`/children/${e}`))}};Xe=R([oe(),fe()],Xe);const En=I(Xe);let Rt=class extends V{async create(e){return g(this,b(e))}};Rt=R([D("bundles"),Z(En)],Rt);Reflect.defineProperty(Se.prototype,"drives",{configurable:!0,enumerable:!0,get:function(){return this.create(Ee)}});function On(){return t=>(t.on.pre(async function(e,r,n){return r.headers={...r.headers,SdkVersion:"PnPCoreJS/4.18.0"},this.log(`Request Tag: ${r.headers.SdkVersion}`,0),[e,r,n]}),t)}function Mn(t=Ht){if(!vt(t))throw Error("Graph baseUrl must be absolute.");return e=>(e.using(On(),yn(),mn()),e.on.pre(async(r,n,s)=>(n.cache="default",n.credentials="same-origin",vt(r)||(r=z(t,r)),[r,n,s])),e)}function Dn(){return t=>(t.using(Y({"Content-Type":"application/json"})),t)}function $n(t){const{baseUrl:e}={baseUrl:Ht,...t};return r=>(r.using(Dn(),Mn(e),pn(),fn()),r)}const Ht="https://graph.microsoft.com/v1.0";async function Tn(t,e,r,n){if(!t?.trim())return[];const s=xn().using($n(),hn(t)),i=e?s.me.drive.getItemById(e).children:s.me.drive.root.children,l=((n?await i.expand("thumbnails")():await i())??[]).filter(f=>f?.id!=null).map(f=>Nr(f));if(r==null||r.length===0)return l;const h=new Set(r.map(f=>f.toLowerCase().trim()));return l.filter(f=>f.mimeType==="application/vnd.microsoft.folder"?!0:h.has(f.mimeType.toLowerCase()))}const Fn=({isOpen:t,accessToken:e,mimeTypes:r,mode:n="LIST",onCancel:s,onPicked:i})=>{const c=u.useCallback(async o=>e?Tn(e,o,r,n==="GRID"):[],[e,r,n]);return u.useEffect(()=>{}
1,[t]),a(Qr,{isOpen:t,loadFiles:c,mimeTypes:r,mode:n,title:"Select files from OneDrive",onCancel:s,onPicked:i})},Qt=Et.createContext({pickFiles:async()=>[],getFiles:async()=>[],publishFile:async()=>({url:""}),authorize:async()=>!1,isPublishing:!1}),ms=()=>u.useContext(Qt),ys=({children:t})=>{const[e,r]=u.useState(!1),{isOpen:n,open:s,close:i}=we(),{isOpen:c,open:o,close:l,context:h}=we(),f=zr(),{data:m}=ar(),[y]=cr(),[$]=lr(),[M,{isLoading:T}={}]=ur(),E=u.useCallback(async()=>{try{r(!0);const p=await f();return p?(await $({oAuthExchangePayload:{code:p}}).unwrap(),!0):!1}catch(p){const C=Ue(p,"Unable to authorize");return ce(C,{variant:"error"}),!1}finally{r(!1)}},[$,f]),F=u.useCallback(async p=>{if(m?.status!==Te.Connected){const S=await s();if(S.action===v.Cancel||S.action===v.Error)return[]}const C=await y().unwrap(),k=await o({...p,accessToken:C?.access_token});return k.action===v.Select?k.payload:[]},[y,s,o,m?.status]),A=u.useCallback(async p=>{if(m?.status!==Te.Connected){const S=await s();if(S.action===v.Cancel||S.action===v.Error)return[]}const C=await y().unwrap(),k=await o({...p,accessToken:C?.access_token});return k.action===v.Select?await Promise.all(k.payload.map(Dr.bind(void 0,C?.access_token??""))):[]},[y,s,o,m?.status]),O=u.useCallback(async p=>{if(m?.status!==Te.Connected){const k=await s();if(k.action===v.Cancel||k.action===v.Error)return null}const C=await M({outlookPublishPayloadSchema:{context:p}}).unwrap();return Dt({url:C.url,variant:"publishOneDrive",anchorOrigin:{vertical:"bottom",horizontal:"right"},persist:!0}),C},[s,m?.status,M]),B=u.useMemo(()=>({pickFiles:F,getFiles:A,publishFile:O,authorize:E,isPublishing:T??!1}),[F,A,O,E,T]),j=p=>{l(v.Select,p)},G=()=>{l(v.Cancel)},ee=()=>{i(v.Cancel)},K=async()=>{try{await E()?i(v.Authenticate):i(v.Error)}catch(p){ce(Ue(p,"Unable to authorize"),{variant:"error"})}};return w(Qt.Provider,{value:B,children:[t,a(Or,{isAuthorizing:e,isOpen:n,onAuthorize:K,onClose:ee}),a(Fn,{...h,isOpen:c,onCancel:G,onPicked:j})]})};export{Or as A,hn as B,It as F,Se as G,Tt as I,v as M,ys as P,Wt as S,$t as V,de as _,ms as a,qr as b,Br as c,Qn as d,Kn as e,Q as f,Lr as g,ue as h,xn as i,$n as j,Qr as k,we as l,Nr as m,zr as n,Dr as o,Dt as p,Vn as u};
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.