1/*! For license information please see 8.19139dda.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[8],{10301(e,t,a){a.r(t),a.d(t,{default:()=>Qt});var s=a(65043),n=a(8729),r=a(73700),o=a(74403),i=a(1789),l=a(23384),c=a(9032),d=a(45847),u=a(71360),h=a(31212);const p=(0,h.A)("phone-call",[["path",{d:"M13 2a9 9 0 0 1 9 9",key:"1itnx2"}],["path",{d:"M13 6a5 5 0 0 1 5 5",key:"11nki7"}],["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);var g=a(97957),m=a(42269),y=a(33198),f=a(366),v=a(1346),w=a(93643),x=a(70579);function _(e){let{proteges:t=[],value:a=null,onChange:n}=e;const r=(0,s.useId)(),o="teach-scope-".concat(r),i=null===a||void 0===a?"":String(a);return(0,x.jsxs)("div",{className:"teach-scope",children:[(0,x.jsxs)("label",{className:"teach-scope__label",htmlFor:o,children:["Which ",c.Do," to teach"]}),(0,x.jsxs)("select",{id:o,className:"ds-input teach-scope__select",value:i,onChange:e=>{if(!n)return;const a=e.target.value;n(a&&t.find((e=>String(e.id)===a))||null)},children:[(0,x.jsxs)("option",{value:"",children:["All ",c.Ib]}),t.map((e=>(0,x.jsx)("option",{value:String(e.id),children:e.name||c.Do},e.id||e.protege_slug)))]}),(0,x.jsx)("span",{className:"teach-scope__note",children:""===i?"Shared knowledge. Every ".concat(c.Do," is briefed from it."):"Knowledge added here briefs this ".concat(c.Do,". Shared knowledge still applies.")})]})}var b=a(89379),j=a(41680);const k=(0,h.A)("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"}]]),N=(0,h.A)("audio-lines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);var A=a(58487);const S=(0,h.A)("rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]),C=(0,h.A)("messages-square",[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]]);var I=a(76996),T=a(37719),P=a(92090),q=a(30370),z=a(48179);const R={document:j.A,video:k,audio:N,page:A.A,feed:S,session:C,note:I.A},E=e=>"bad"===(0,w.o7)(e).tone,D=e=>E(e)||(0,w.S5)(e),M=(e,t)=>!t||String(e.title||e.source_uri||"").toLowerCase().includes(t);function F(e){let{sources:t=[],feeds:a=[],loading:n=!1,error:r=null,protegeName:i,scopeIsProtege:l=!1,onRemove:d,onDismiss:u,onRetry:h,onAddAgain:p,onRefresh:m}=e;const[y,f]=(0,s.useState)(""),[v,_]=(0,s.useState)((()=>new Set)),[j,k]=(0,s.useState)(!0),N=i||"your ".concat(c.Do),A=y.trim().toLowerCase(),S=(0,s.useMemo)((()=>{const e=t.filter(D);return[...e.filter(E),...e.filter((e=>!E(e)))]}),[t]),C=S.filter((e=>M(e,A))),P=(0,s.useMemo)((()=>A?a.filter((e=>"".concat(e.title||""," ").concat(e.url||e.rss_url||"").toLowerCase().includes(A))):a),[a,A]),F=(0,s.useMemo)((()=>{const e=new Map(w.GW.map((e=>[e.key,[]])));return t.filter((e=>!D(e))).forEach((t=>{const a=e.has(t.kind)?t.kind:"note";e.get(a).push(t)})),w.GW.map((t=>{const s=e.get(t.key),n="feed"===t.key?a:[],r=A?s.filter((e=>M(e,A))):s,o="feed"===t.key?P:[];return(0,b.A)((0,b.A)({},t),{},{rows:s,feedRows:n,shownRows:r,shownFeeds:o,count:s.length+n.length,matched:r.length+o.length})})).filter((e=>e.count>0))}),[t,a,P,A]),U=e=>A?e.matched>0:v.has(e.key);if(n)return(0,x.jsx)(q.A,{label:"Loading what ".concat(N," knows")});if(r)return(0,x.jsxs)("div",{className:"teach-error",role:"alert",children:[(0,x.jsx)("p",{style:{margin:0},children:r}),m&&(0,x.jsx)("div",{className:"teach-actions",children:(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:m,children:"Try again"})})]});if(0===t.length&&0===a.length)return(0,x.jsx)(o.A,{title:"".concat(i||"Your ".concat(c.Do)," has nothing to draw on yet"),body:"Add a document, a link, or a few notes above, and it will start answering from them."});const L=A&&0===C.length&&F.every((e=>0===e.matched)),Y={scopeIsProtege:l,onRemove:d,onDismiss:u,onRetry:h,onAddAgain:p};return(0,x.jsxs)("div",{children:[S.length>0&&(0,x.jsxs)("section",{className:"teach-attention","aria-labelledby":"teach-attention-heading",children:[(0,x.jsx)("h3",{id:"teach-attention-heading",className:"teach-attention__title",children:(0,x.jsxs)("button",{type:"button",className:"teach-attention__toggle","aria-expanded":j,"aria-controls":"teach-attention-list",onClick:()=>k((e=>!e)),children:[(0,x.jsx)(T.A,{size:18,"aria-hidden":"true"}),"Needs attention (".concat(S.length,")")]})}),j&&(0,x.jsxs)("ul",{id:"teach-attention-list",className:"teach-list",children:[C.map((e=>(0,x.jsx)(O,(0,b.A)({source:e},Y),e.source_uri))),0===C.length&&(0,x.jsx)("li",{className:"teach-row",children:(0,x.jsxs)("p",{className:"ds-dense ds-muted",style:{margin:0},children:['Nothing here matches "',y,'".']})})]})]}),F.length>0&&(0,x.jsx)("div",{className:"teach-kinds",role:"group","aria-label":"What it knows, by kind",children:F.map((e=>{const t=R[e.key]||I.A;return(0,x.jsxs)("button",{type:"button",className:"teach-kind","aria-expanded":U(e),"aria-controls":"teach-group-".concat(e.key),onClick:()=>{return t=e.key,_((e=>{const a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a}));var t},children:[(0,x.jsx)(t,{size:18,"aria-hidden":"true"}),(0,x.jsx)("span",{children:e.label}),(0,x.jsx)("span",{className:"teach-kind__count",children:e.count})]},e.key)}))}),(0,x.jsx)(z.Ay,{label:"Find a source",type:"search",value:y,onChange:e=>f(e.target.value),placeholder:"A file name, a page, a topic",autoComplete:"off"}),L&&(0,x.jsxs)("p",{className:"ds-dense ds-muted",role:"status",children:['Nothing matches "',y,'".']}),F.filter(U).map((e=>{const t=R[e.key]||I.A;return(0,x.jsxs)("section",{id:"teach-group-".concat(e.key),className:"teach-group","aria-labelledby":"teach-group-".concat(e.key,"-title"),children:[(0,x.jsxs)("h3",{id:"teach-group-".concat(e.key,"-title"),className:"teach-group__title",children:[(0,x.jsx)(t,{size:16,"aria-hidden":"true"}),e.label]}),(0,x.jsxs)("ul",{className:"teach-list",children:[e.shownFeeds.map((e=>(0,x.jsx)(W,{feed:e},e.url||e.rss_url||e.title))),e.shownRows.map((e=>(0,x.jsx)(O,(0,b.A)({source:e},Y),e.source_uri)))]})]},e.key)}))]})}function O(e){let{source:t,scopeIsProtege:a,onRemove:s,onDismiss:n,onRetry:r,onAddAgain:o}=e;const i=(0,w.o7)(t),l="bad"===i.tone,c=(0,w.S5)(t),d="Duplicate"===i.label,u=[t.added_at?"Added ".concat((0,w.Yc)(t.added_at)):null,t.size_bytes?(0,w.Xq)(t.size_bytes):null,null!==t.priority&&void 0!==t.priority?"Priority ".concat((0,w.z7)(t.priority)):null].filter(
2Boolean);return(0,x.jsxs)("li",{className:"teach-row",children:[(0,x.jsxs)("div",{className:"teach-row__main",children:[(0,x.jsxs)("div",{className:"teach-row__title",children:[(0,x.jsx)("span",{children:t.title}),a&&t.shared&&(0,x.jsx)(P.Ay,{tone:"neutral",children:"Shared"})]}),u.length>0&&(0,x.jsx)("p",{className:"teach-row__meta",children:u.map((e=>(0,x.jsx)("span",{children:e},e)))}),l&&(0,x.jsx)("p",{className:"teach-row__error",role:"alert",children:(0,w.dN)(t.error_message)}),d&&(0,x.jsx)("p",{className:"teach-row__meta",children:"Same file as one already in your knowledge, so nothing new was added."})]}),(0,x.jsxs)("div",{className:"teach-row__side",children:[(0,x.jsx)(P.Ay,{tone:i.tone,children:i.label}),l&&t.job_id&&r&&(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:()=>r(t),"aria-label":"Retry ".concat(t.title),children:"Retry"}),l&&!t.job_id&&o&&(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:()=>o(t),"aria-label":"Add ".concat(t.title," again"),children:"Add it again"}),l&&n&&(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>n(t),"aria-label":"Dismiss ".concat(t.title),children:"Dismiss"}),c&&n&&(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>n(t),"aria-label":"Cancel ".concat(t.title),children:"Cancel"}),d&&n&&(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>n(t),"aria-label":"Remove the copy ".concat(t.title," from the list"),children:"Remove this copy"}),!l&&!c&&!d&&s&&!String(t.source_uri||"").startsWith("job:")&&(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>s(t),"aria-label":"Remove ".concat(t.title),children:"Remove"})]})]})}function W(e){let{feed:t}=e;const a=String(t.status||(!1===t.is_active?"paused":"active")).toLowerCase(),s="error"===a||t.error_message?"bad":"paused"===a||"inactive"===a?"warn":"good",n="bad"===s?"Not reachable":"warn"===s?"Paused":"Following",r=Number(t.entry_count),o=[t.created_at?"Following since ".concat((0,w.Yc)(t.created_at)):null,Number.isFinite(r)?"".concat(r," ").concat(1===r?"article":"articles"):null,t.last_checked?"Checked ".concat((0,w.Yc)(t.last_checked)):null].filter(Boolean);return(0,x.jsxs)("li",{className:"teach-row",children:[(0,x.jsxs)("div",{className:"teach-row__main",children:[(0,x.jsx)("div",{className:"teach-row__title",children:(0,x.jsx)("span",{children:t.title||t.url||t.rss_url})}),o.length>0&&(0,x.jsx)("p",{className:"teach-row__meta",children:o.map((e=>(0,x.jsx)("span",{children:e},e)))}),t.error_message&&(0,x.jsxs)("p",{className:"teach-row__error",children:[t.error_message,". Check the address and follow it again."]})]}),(0,x.jsx)("div",{className:"teach-row__side",children:(0,x.jsx)(P.Ay,{tone:s,children:n})})]})}var U=a(50797),L=a(19733),Y=a(91832);const B=2e3,V=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{getAuthToken:a}=(0,n.A)(),{pollInterval:r=B,onComplete:o,onError:i}=t,[l,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(!1),[h,p]=(0,s.use
2State)(null),[g,m]=(0,s.useState)(0),y=(0,s.useRef)(null),f=(0,s.useRef)(!0),v=(0,s.useRef)(!1),w=(0,s.useRef)(null),x=(0,s.useCallback)((async()=>{if(e&&!v.current)try{u(!0),p(null);const t=await a(),s=await fetch("".concat("https://proxy-service-gateway-au4uagnd.uc.gateway.dev","/api/v1/knowledge/jobs/").concat(e),{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t),"X-Jwt-Token":t||""}});if(!s.ok)throw new Error("Failed to fetch job status: ".concat(s.status));const n=await s.json();if(!f.current)return;if(c(n),m(0),"completed"===n.status&&(v.current=!0,b(),o&&o(n)),"failed"===n.status){v.current=!0,b();const e=n.error_message||"Job failed";p(e),i&&i(new Error(e),n)}"cancelled"===n.status&&(v.current=!0,b(),p("Job was cancelled"))}catch(t){if(console.error("Error fetching job status:",t),!f.current)return;if(v.current)return void b();g<3?(m((e=>e+1)),console.log("Retrying... (".concat(g+1,"/").concat(3,")"))):(p(t.message),b(),i&&i(t,null))}finally{f.current&&u(!1)}}),[e,g,o,i,a]),_=(0,s.useCallback)((()=>{!e||y.current||v.current||w.current!==e&&(w.current=e,x(),y.current=setInterval((()=>{x()}),r),console.log("Started polling job ".concat(e," every ").concat(r,"ms")))}),[e,r,x]),b=(0,s.useCallback)((()=>{y.current&&(clearInterval(y.current),y.current=null,w.current=null,console.log("Stopped polling"))}),[]),j=(0,s.useCallback)((()=>{x()}),[x]),k=(0,s.useCallback)((()=>{v.current=!1,w.current=null,b(),c(null),p(null),m(0),u(!1)}),[b]);(0,s.useEffect)((()=>(e?w.current!==e&&(v.current=!1,w.current=null,b(),_()):b(),()=>{b()})),[e]),(0,s.useEffect)((()=>()=>{f.current=!1,b()}),[b]);const N="processing"===(null===l||void 0===l?void 0:l.status),A="pending"===(null===l||void 0===l?void 0:l.status),S="completed"===(null===l||void 0===l?void 0:l.status),C="failed"===(null===l||void 0===l?void 0:l.status),I="cancelled"===(null===l||void 0===l?void 0:l.status),T=(null===l||void 0===l?void 0:l.percent_complete)||0,P=(null===l||void 0===l?void 0:l.current_step)||"",q=(null===l||void 0===l?void 0:l.progress_message)||"";return{jobStatus:l,status:null===l||void 0===l?void 0:l.status,percentComplete:T,currentStep:P,progressMessage:q,resultData:null===l||void 0===l?void 0:l.result_data,knowledgeEntryId:null===l||void 0===l?void 0:l.knowledge_entry_id,errorMessage:null===l||void 0===l?void 0:l.error_message,errorDetails:null===l||void 0===l?void 0:l.error_details,loading:d,error:h,isProcessing:N,isPending:A,isCompleted:S,isFailed:C,isCancelled:I,isPolling:!!y.current,refresh:j,reset:k,startPolling:_,stopPolling:b,createdAt:null===l||void 0===l?void 0:l.created_at,startedAt:null===l||void 0===l?void 0:l.started_at,completedAt:null===l||void 0===l?void 0:l.completed_at}};var J=a(5771);const H={initializing:"Getting started",queued:"Waiting its turn",uploading:"Uploading",processing_file:"Reading the file",extracting_text:"Reading the file",fetching_url:"Reading the page",transcribing:"Transcribing the recording",removing_pii:"Removing personal details",chunking:"Splitting it into passages",embedding:"Making it searchable",storing:"Saving it",completed:"Done"};function K(e){if(!e)return"Working on it";const t=String(e).toLowerCase();return H[t]?H[t]:t.replace(/[_-]+/g," ").replace(/\bpii\b/i,"personal details").replace(/^./,(e=>e.toUpperCase()))}function G(e){let{jobStatus:t,onComplete:a,onRetry:n,readyText:r,className:o=""}=e;const i=null===t||void 0===t?void 0:t.status,l="completed"===i,c="failed"===i,d="cancelled"===i;(0,s.useEffect)((()=>{l&&a&&a(t)}),[l]);const u=(0,s.useMemo)((()=>{const e=(null===t||void 0===t?void 0:t.started_at)||(null===t||void 0===t?void 0:t.created_at),a=e?Date.parse(e):NaN;return Number.isNaN(a)?null:a}),[null===t||void 0===t?void 0:t.started_at,null===t||void 0===t?void 0:t.created_at]);if(!t)return null;if(l)return(0,x.jsxs)("div",{className:o,role:"status",children:[(0,x.jsx)(P.Ay,{tone:"good",children:"Ready"}),(0,x.jsx)("span",{className:"ds-dense",style:{marginLeft:12},children:r||"Added. Your Prot\xe9g\xe9 can use it now."})]});if(d)return(0,x.jsxs)("div",{className:o,role:"status",children:[(0,x.jsx)(P.Ay,{tone:"neutral",children:"Stopped"}),(0,x.jsx)("span",{className:"ds-dense",style:{marginLeft:12},children:"This was stopped before it finished. Add it again when you are ready."})]});const h=Number.isFinite(Number(t.percent_complete))?Number(t.percent_complete):null,p=c?t.error_message?"It stopped while ".concat(K(t.current_step).toLowerCase(),". ").concat((0,w.dN)(t.error_message)):null:t.progress_message&&!/pii|chunk|embed|vector|ingest/i.test(t.progress_message)?t.progress_message:K(t.current_step);return(0,x.jsx)(J.A,{className:o,percent:c?null:h,step:p,startedAt:u,state:c?"failed":"running",onRetry:c?n:void 0,label:t.source_name?"Adding ".concat(t.source_name):"Adding knowledge"})}const X={"application/pdf":".pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document":".docx","application/vnd.openxmlformats-officedocument.presentationml.presentation":".pptx","application/msword":".doc","text/plain":".txt","text/markdown":".md","application/json":".json","text/csv":".csv","audio/mpeg":".mp3","audio/mp3":".mp3","audio/wav":".wav","audio/wave":".wav","audio/x-wav":".wav","audio/flac":".flac","audio/ogg":".ogg","audio/webm":".webm","audio/mp4":".m4a","audio/x-m4a":".m4a","video/mp4":".mp4","video/x-m4v":".m4v"},$=".pdf,.docx,.doc,.pptx,.txt,.md,.json,.csv,.mp3,.m4a,.mp4,.m4v,.wav,.flac,.ogg,.webm,.amr";function Z(e){const t=String((null===e||void 0===e?void 0:e.type)||""),a=String((null===e||void 0===e?void 0:e.name)||"").toLowerCase();return t.startsWith("audio/")||"video/mp4"===t||"video/x-m4v"===t||/\.(mp3|wav|flac|ogg|webm|m4a|mp4|aac|amr)$/.test(a)}function Q(e){return Z(e)}function ee(e){var t;const a=Z(e),s=a?209715200:104857600;if(e.size>s)throw new Error("".concat(e.name," is too large. ").concat(a?"Recordings":"Documents"," can be up to ").concat(a?"200":"100"," MB."));const n=null===(t=String(e.name||"").toLowerCase().match(/\.[^.]+$/))||void 0===t?void 0:t[0];if(!(X[e.type]||n&&$.split(",").includes(n)))throw new Error("".concat(e.name," is not a type we can read yet. PDF, Word, PowerPoint, text, Markdown, JSON, CSV, and recordings (MP3, WAV, M4A, MP4) all work."));return!0}let te=0;function ae(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{getAuthToken:t}=(0,n.A)()||{},a=(0,s.useRef)(e);(0,s.useEffect)((()=>{a.current=e}),[e]);
2const[r,o]=(0,s.useState)([]),[i,l]=(0,s.useState)(""),c=(0,s.useRef)(r);(0,s.useEffect)((()=>{c.current=r}),[r]);const d=(0,s.useCallback)((async()=>{try{return"function"===typeof t?await t():null}catch(e){return null}}),[t]),u=(0,s.useCallback)(((e,t)=>{o((a=>a.map((a=>a.id===e?(0,b.A)((0,b.A)({},a),t):a))))}),[]),h=(0,s.useCallback)((e=>{const{protegeIds:t=[],weight:s=5,removePII:n=!0,contentType:r="general"}=a.current||{},o="file"===(null===e||void 0===e?void 0:e.type)&&Q(e.content);return(0,b.A)((0,b.A)({weight:s,content_type:r||"general",remove_pii:!1!==n},Array.isArray(t)&&t.length>0?{protege_ids:t}:{}),o?{client_visible:!0===e.clientVisible}:{})}),[]),p=(0,s.useCallback)(((e,t,s)=>{if(202===t.status)return u(e.id,{status:"processing",jobId:(null===s||void 0===s?void 0:s.job_id)||null,receipt:(0,w.oU)(null===s||void 0===s?void 0:s.estimated_completion)}),!0;if(t.ok&&s&&!1!==s.success){var n,r;const t=s.knowledge_entry_id||(null===(n=s.results)||void 0===n?void 0:n.knowledge_entry_id)||null,o={status:"completed",result:s,receipt:"Added. Your Prot\xe9g\xe9 can use it now.",knowledgeEntryId:t};u(e.id,o);const i=null===(r=a.current)||void 0===r?void 0:r.onJobDone;return i&&(t||s.job_id)&&i((0,b.A)((0,b.A)({},e),o),s),!0}return!1}),[u]),g=(0,s.useCallback)(((e,t)=>{u(e,{status:"error",error:(null===t||void 0===t?void 0:t.message)||"This did not go through."})}),[u]),m=(0,s.useCallback)((async e=>{const t=e.content,a=t.type||"application/octet-stream",s=await d();u(e.id,{status:"uploading"});const n=await fetch("".concat(Y.A.backendProxy,"/api/v1/upload-url"),{method:"POST",headers:{Authorization:"Bearer ".concat(s),"X-Jwt-Token":s,"Content-Type":"application/json"},body:JSON.stringify({filename:t.name,content_type:a})}),r=await n.json().catch((()=>({})));if(!n.ok||!r.success||!r.upload_url)throw new Error(r.error||r.message||"Could not start the upload. Try again in a moment.");if(!(await fetch(r.upload_url,{method:"PUT",headers:r.required_headers||{"Content-Type":a},body:t})).ok)throw new Error("The upload did not finish. Check your connection and add it again.");u(e.id,{status:"starting"});const o=await fetch("".concat(Y.A.backendProxy,"/api/v1/ingest"),{method:"POST",headers:{Authorization:"Bearer ".concat(s),"X-Jwt-Token":s,"Content-Type":"application/json"},body:JSON.stringify({content_type:"file",source_type:"file",async:!0,source_data:{gcs_url:r.gcs_url,filename:t.name,content_type:a},options:h(e)})}),i=await o.json().catch((()=>({})));if(!p(e,o,i))throw new Error(i.error||i.message||"The server could not start on this file. Add it again.")}),[d,u,h,p]),y=(0,s.useCallback)((async e=>{const t=await d();u(e.id,{status:"uploading"});const a=h(e),s=new FormData;s.append("file",e.content),s.append("async","true"),s.append("weight",String(a.weight)),s.append("content_type",a.content_type),s.append("remove_pii",String(a.remove_pii)),a.protege_ids&&s.append("protege_ids",JSON.stringify(a.protege_ids)),void 0!==a.client_visible&&s.append("client_visible",String(a.client_visible));const n=await fetch("".concat(Y.A.backendProxy,"/api/v1/ingest"),{method:"POST",headers:{Authorization:"Bearer ".concat(t),"X-Jwt-Token":t},body:s}),r=await n.json().catch((()=>({})));if(!p(e,n,r))throw new Error(r.error||r.message||"The server could not read this file. Add it again.")}),[d,u,h,p]),f=(0,s.useCallback)((async(e,t)=>{const a=await d();u(e.id,{status:"starting"});const s=await fetch("".concat(Y.A.backendProxy,"/api/v1/ingest"),{method:"POST",headers:{Authorization:"Bearer ".concat(a),"X-Jwt-Token":a,"Content-Type":"application/json"},body:JSON.stringify((0,b.A)((0,b.A)({},t),{},{async:!0,options:h(e)}))}),n=await s.json().catch((()=>({})));if(!p(e,s,n))throw new Error(n.error||n.message||"This did not go through. Add it again.")}),[d,u,h,p]),v=(0,s.useCallback)((async e=>{try{if("file"===e.type){e.content.size>=20971520||Z(e.content)?await m(e):await y(e)}else"url"===e.type?await f(e,{content_type:"url",url:e.source}):await f(e,{content_type:"text",source_type:"text",source_data:{text:e.textContent,title:e.textTitle||void 0}})}catch(t){g(e.id,t)}}),[m,y,f,g]),x=(0,s.useCallback)((e=>{const{protegeIds:t=[],clientVisible:s=!1}=a.current||{},n=(0,b.A)((0,b.A)({status:"pending",jobId:null,error:null,result:null,receipt:null,startedAt:Date.now(),protegeIds:[...t],clientVisible:"file"===e.type&&!0===s&&Q(e.content)},e),{},{id:"upload_".concat(Date.now(),"_").concat(te+=1)});return o((e=>[n,...e])),v(n),n.id}),[v]),_=(0,s.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=Array.from(e||[]);l("");try{a.forEach(ee)}catch(s){return l(s.message),[]}return a.map((e=>x((0,b.A)({type:"file",source:e.name,content:e},t))))}),[x]),j=(0,s.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=String(e||"").trim();return l(""),function(e){try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(t){return!1}}(a)?x((0,b.A)({type:"url",source:a},t)):(l("That does not look like a web address. It should start with http:// or https://."),null)}),[x]),k=(0,s.useCallback)((function(){let{title:e="",text:t=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=String(t||"").trim();return l(""),s?x((0,b.A)({type:"text",source:String(e||"").trim()||"Notes",textContent:s,textTitle:String(e||"").trim()},a)):(l("Write or paste something first."),null)}),[x]),N=(0,s.useCallback)((e=>{u(e.id,{status:"pending",error:null,jobId:null,receipt:null,startedAt:Date.now()}),v((0,b.A)((0,b.A)({},e),{},{status:"pending",error:null,jobId:null}))}),[v,u]),A=(0,s.useCallback)((e=>{o((t=>t.filter((t=>
2t.id!==e))))}),[]),S=(0,s.useCallback)(((e,t)=>{var s;o((a=>a.map((a=>a.id===e?(0,b.A)((0,b.A)({},a),{},{status:"completed",result:(null===t||void 0===t?void 0:t.result_data)||null,knowledgeEntryId:(null===t||void 0===t?void 0:t.knowledge_entry_id)||null}):a))));const n=null===(s=a.current)||void 0===s?void 0:s.onJobDone;if(n){const a=c.current.find((t=>t.id===e));n(a?(0,b.A)((0,b.A)({},a),{},{status:"completed",knowledgeEntryId:(null===t||void 0===t?void 0:t.knowledge_entry_id)||null}):{id:e},t)}}),[]),C=(0,s.useCallback)(((e,t)=>{u(e,{status:"error",error:t||"This did not finish."})}),[u]);return{uploads:r,error:i,clearError:()=>l(""),addFiles:_,addUrl:j,addText:k,retry:N,remove:A,markDone:S,markFailed:C}}function se(e){var t;let{upload:a,onDone:s,onFailed:n}=e;const r=V(a.jobId,{pollInterval:3e3,onComplete:e=>s(a.id,e),onError:(e,t)=>n(a.id,(null===t||void 0===t?void 0:t.error_message)||(null===e||void 0===e?void 0:e.message))});return(0,x.jsx)(G,{jobStatus:r.jobStatus,readyText:null!==(t=a.protegeIds)&&void 0!==t&&t.length?"Added. Your Prot\xe9g\xe9 can use it now.":"Added and shared with every Prot\xe9g\xe9."})}function ne(e){let{uploads:t=[],onRetry:a,onRemove:s,onDone:n,onFailed:r,className:o=""}=e;return 0===t.length?null:(0,x.jsx)("ul",{className:"teach-queue ".concat(o),"aria-label":"What you just added",children:t.map((e=>{var t;return(0,x.jsxs)("li",{className:"teach-queue__row",children:[(0,x.jsxs)("div",{className:"teach-queue__head",children:[(0,x.jsx)("span",{className:"teach-queue__title",children:e.source}),"file"===e.type&&null!==(t=e.content)&&void 0!==t&&t.size?(0,x.jsx)("span",{className:"ds-caption-app ds-muted",children:(0,w.Xq)(e.content.size)}):null,"pending"===e.status&&(0,x.jsx)(P.Ay,{tone:"neutral",children:"Waiting"}),("uploading"===e.status||"starting"===e.status)&&(0,x.jsx)(P.Ay,{tone:"warn",children:"Sending"}),"error"===e.status&&(0,x.jsx)(P.Ay,{tone:"bad",children:"Failed"}),"processing"===e.status&&!e.jobId&&(0,x.jsx)(P.Ay,{tone:"warn",children:"Processing"}),"completed"===e.status&&!e.jobId&&(0,x.jsx)(P.Ay,{tone:"good",children:"Ready"})]}),e.receipt&&"error"!==e.status&&(0,x.jsx)("p",{className:"ds-dense teach-queue__receipt",role:"status",children:e.receipt}),e.jobId&&"error"!==e.status&&(0,x.jsx)(se,{upload:e,onDone:n,onFailed:r}),"error"===e.status&&(0,x.jsxs)("div",{children:[(0,x.jsxs)("p",{className:"ds-dense teach-queue__error",role:"alert",children:[e.error," Nothing was saved."]}),(0,x.jsxs)("div",{className:"teach-actions",children:[a&&(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:()=>a(e),children:"Add it again"}),s&&(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>s(e.id),children:"Clear"})]})]}),"completed"===e.status&&s&&(0,x.jsx)("div",{className:"teach-actions",children:(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>s(e.id),children:"Clear"})})]},e.id)}))})}function re(e){let{onFiles:t,disabled:a=!1,hint:n}=e;
2const[r,o]=(0,s.useState)(!1),i=(0,s.useId)(),l=(0,s.useRef)(null);return(0,x.jsxs)("label",{htmlFor:i,className:"teach-drop".concat(r?" is-over":"").concat(a?" is-disabled":""),onDragOver:e=>{e.preventDefault(),a||o(!0)},onDragLeave:e=>{e.preventDefault(),o(!1)},onDrop:e=>{var s,n;e.preventDefault(),o(!1),a||null!==(s=e.dataTransfer)&&void 0!==s&&null!==(n=s.files)&&void 0!==n&&n.length&&t(e.dataTransfer.files)},children:[(0,x.jsx)("input",{id:i,ref:l,type:"file",multiple:!0,accept:$,className:"sr-only",disabled:a,onChange:e=>{var a;null!==(a=e.target.files)&&void 0!==a&&a.length&&t(e.target.files),e.target.value=""}}),(0,x.jsx)(U.A,{size:28,"aria-hidden":"true"}),(0,x.jsx)("span",{className:"teach-drop__title",children:r?"Drop them here":"Drop files here, or choose files"}),(0,x.jsx)("span",{className:"ds-caption-app ds-muted",children:n||"PDF, Word, PowerPoint, text, Markdown, JSON and CSV up to 100 MB. Recordings (MP3, WAV, M4A, MP4) up to 200 MB."})]})}var oe=a(67247);const ie=[{key:"files",label:"Drop files",Icon:U.A},{key:"link",label:"Paste a link",Icon:A.A},{key:"text",label:"Paste text",Icon:I.A},{key:"feed",label:"Follow a feed",Icon:S}],le=["Critical","High","Normal","Low"].filter((e=>e in w.KV)),ce=[{value:"general",label:"General"},{value:"methodology",label:"How I work (methodology)"},{value:"case_study",label:"A case study"},{value:"philosophy",label:"What I believe (philosophy)"},{value:"expertise_deep_dive",label:"A deep dive"},{value:"general_qa",label:"Questions and answers"},{value:"introduction",label:"An introduction"},{value:"feedback",label:"Feedback for my Prot\xe9g\xe9"}];function de(e){var t;let{protegeId:a=null,protegeName:n,protegeSlug:r,expertSlug:o,prefill:i=null,onAdded:l,onFollow:u,headingId:h="teach-add-heading"}=e;const[p,m]=(0,s.useState)("files"),[y,f]=(0,s.useState)("Normal"),[v,_]=(0,s.useState)("general"),[j,k]=(0,s.useState)(!0),[N,A]=(0,s.useState)(!1),[S,C]=(0,s.useState)(""),[I,T]=(0,s.useState)(""),[P,q]=(0,s.useState)(""),[R,E]=(0,s.useState)(null),[D,M]=(0,s.useState)(""),[F,O]=(0,s.useState)(!1),[W,U]=(0,s.useState)(""),[Y,B]=(0,s.use
2State)(""),V=(0,s.useRef)(null),J=(0,s.useRef)(!1),H=a?[a]:[],K=n||"your ".concat(c.Do),G=ae({protegeIds:H,weight:null!==(t=w.KV[y])&&void 0!==t?t:w.KV.Normal,removePII:j,contentType:v,clientVisible:N,onJobDone:l});(0,s.useEffect)((()=>{i&&(m("text"),T(i.title||""),q(""),E(i.suggestionId||null),J.current=!0)}),[i]),(0,s.useEffect)((()=>{"text"===p&&J.current&&V.current&&(J.current=!1,V.current.focus())}),[p]);const X=a?{protege_id:a,protege_name:n,protege_slug:r}:null;return(0,x.jsxs)("div",{className:"teach-panel",id:"add-knowledge",children:[(0,x.jsx)("p",{className:"ds-dense ds-muted",style:{margin:"0 0 12px"},children:a?"Everything you add here teaches ".concat(K,"."):"Everything you add here is shared with every ".concat(c.Do,".")}),(0,x.jsxs)(L.A,{value:p,onChange:m,"aria-label":"Ways to add knowledge",children:[(0,x.jsx)(L.A.List,{children:ie.map((e=>{let{key:t,label:a,Icon:s}=e;return(0,x.jsxs)(L.A.Trigger,{value:t,style:{minHeight:48},children:[(0,x.jsx)(s,{size:18,"aria-hidden":"true"}),a]},t)}))}),(0,x.jsxs)(L.A.Panel,{value:"files",children:[(0,x.jsx)("p",{className:"ds-dense ds-muted",style:{margin:"0 0 12px"},"data-testid":"drop-save-rule",children:"A file is added the moment you drop or choose it, with the choices on this panel. Set them first."}),(0,x.jsx)(re,{onFiles:e=>{const t=Array.from(e||[]);G.addFiles(t).length>0&&t.some(Q)&&A(!1)}}),(0,x.jsx)("div",{style:{marginTop:12},children:(0,x.jsx)(z.tu,{label:"Allow your prot\xe9g\xe9 to show this on screen during sessions",hint:"Only recordings can be shown today. Off means the prot\xe9g\xe9 can still learn from it but never plays it to a client.",checked:N,onChange:e=>A(e.target.checked)})})]}),(0,x.jsx)(L.A.Panel,{value:"link",children:(0,x.jsxs)("form",{onSubmit:e=>{e.preventDefault(),G.addUrl(S)&&C("")},noValidate:!0,children:[(0,x.jsx)(z.Ay,{label:"Web address",hint:"An article, a page from your site, a public document.",type:"url",value:S,onChange:e=>C(e.target.value),placeholder:"https://"}),(0,x.jsx)(g.A,{type:"submit",size:"lg",variant:"secondary",disabled:!S.trim(),children:"Add this page"})]})}),(0,x.jsx)(L.A.Panel,{value:"text",children:(0,x.jsxs)("form",{onSubmit:e=>{e.preventDefault();G.addText({title:I,text:P},R?{suggestionId:R}:{})&&(T(""),q(""),E(null))},noValidate:!0,children:[(null===i||void 0===i?void 0:i.quote)&&R&&(0,x.jsxs)("p",{className:"teach-notice",role:"note",children:["It was asked: ",(0,x.jsx)("q",{children:i.quote})," Write what ",K," should say."]}),(0,x.jsx)(z.Ay,{label:"Title",hint:"What this is about, in a few words.",value:I,onChange:e=>T(e.target.value),placeholder:"Handling a pricing objection",name:"title"}),(0,x.jsx)(z.Ay,{label:"What it should know",hint:"Notes, an answer, a method. Plain text is fine.",as:e=>(0,x.jsx)("textarea",(0,b.A)({ref:V,rows:8},e)),value:P,onChange:e=>q(e.target.value),name:"text",required:!0}),(0,x.jsx)(g.A,{type:"submit",size:"lg",variant:"secondary",disabled:!P.trim(),children:"Add these notes"})]})}),(0,x.jsx)(L.A.Panel,{value:"feed",children:(0,x.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),U(""),B(""),u){O(!0);try{await u({url:D.trim(),removePII:j}),U("Following. New articles are added as they are published."),M("")}catch(t){B((null===t||void 0===t?void 0:t.message)||"Could not follow that feed. Check the address and try again.")}finally{O(!1)}}},noValidate:!0,children:[(0,x.jsx)(z.Ay,{label:"Feed address",hint:"New articles from this feed are added to what ".concat(K," knows as they are published."),type:"url",value:D,onChange:e=>M(e.target.value),placeholder:"https://example.com/feed.xml",error:Y||void 0}),(0,x.jsx)(g.A,{type:"submit",size:"lg",variant:"secondary",disabled:!D.trim(),loading:F,children:"Follow this feed"}),W&&(0,x.jsx)("p",{className:"ds-dense",role:"status",style:{marginTop:12},children:W})]})})]}),"feed"!==p&&(0,x.jsxs)("div",{className:"teach-panel__options",children:[(0,x.jsx)(z.Ay,{label:"Priority",hint:"Higher priority is reached for first. Critical is for the few things it must never miss.",as:"select",value:y,onChange:e=>f(e.target.value),children:le.map((e=>(0,x.jsx)("option",{value:e,children:e},e)))}),(0,x.jsx)(z.Ay,{label:"What kind of knowledge this is",hint:"Optional. It helps the answers lean on the right material.",as:"select",value:v,onCh
2ange:e=>_(e.target.value),children:ce.map((e=>(0,x.jsx)("option",{value:e.value,children:e.label},e.value)))}),(0,x.jsx)(z.tu,{label:"Remove personal details first",hint:"Names, email addresses and phone numbers are taken out before it is saved.",checked:j,onChange:e=>k(e.target.checked)})]}),"feed"===p&&(0,x.jsx)(z.tu,{label:"Remove personal details from articles",hint:"Author contact details are taken out before each article is saved.",checked:j,onChange:e=>k(e.target.checked)}),G.error&&(0,x.jsx)("p",{className:"ds-dense teach-queue__error",role:"alert",children:G.error}),(0,x.jsx)(ne,{uploads:G.uploads,onRetry:G.retry,onRemove:G.remove,onDone:G.markDone,onFailed:G.markFailed}),(0,x.jsx)("div",{className:"teach-actions",style:{marginTop:20},children:(0,x.jsx)(oe.Ay,{protege:X,expertSlug:o,disabled:!X,description:oe.Kl})}),(0,x.jsx)("p",{className:"ds-dense ds-muted",style:{margin:"8px 0 0"},children:X?"Talk to your interviewer. It asks the questions; you answer in your own words.":"Choose a ".concat(c.Do," above to be interviewed about what it is missing.")}),(0,x.jsxs)("p",{className:"ds-dense ds-muted teach-older-session",style:{margin:"16px 0 0"},children:["Interviewer calls are added on their own. To add an older session by hand, open ",(0,x.jsx)(d.N_,{to:"/usage",children:"Usage"}),", find the session and choose Review insights."]})]})}var ue=a(59668);function he(e){let{gaps:t=[],loading:a=!1,error:n=null,onTeach:r,onAnalyze:i,analyzing:l=!1,canAnalyze:d=!1,analyzeError:u=null,onRefresh:h}=e;const[p,m]=(0,s.useState)("all"),y=(0,s.useMemo)((()=>(0,w.cl)(t)),[t]),f=(0,s.useMemo)((()=>({all:y.length,stated:y.filter((e=>"stated"===e.origin)).length,observed:y.filter((e=>"observed"===e.origin)).length})),[y]),v="all"===p?y:y.filter((e=>e.origin===p));if(a)return(0,x.jsx)(q.A,{label:"Looking for what it could not answer"});const _=i?(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:i,loading:l,disabled:!d,children:"Look at recent sessions"}):null;if(n)return(0,x.jsxs)("div",{className:"teach-error",role:"alert",children:[(0,x.jsx)("p",{style:{margin:0},children:n}),h&&(0,x.jsx)("div",{className:"teach-actions",children:(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:h,children:"Try again"})})]});const b=f.stated>0&&f.observed>0;return(0,x.jsxs)("div",{children:[u&&(0,x.jsx)("p",{className:"teach-error",role:"alert",children:u}),b&&(0,x.jsx)("div",{className:"teach-filter",role:"group","aria-label":"Filter by where this came from",children:[["all","All (".concat(f.all,")")],["stated","".concat(w.fy.stated," (").concat(f.stated,")")],["observed","".concat(w.fy.observed," (").concat(f.observed,")")]].map((e=>{let[t,a]=e;return(0,x.jsx)("button",{type:"button",className:"teach-filter__btn","aria-pressed":p===t,onClick:()=>m(t),children:a},t)}))}),0===v.length?(0,x.jsx)(o.A,{title:0===y.length?"Nothing your ".concat(c.Do," could not answer yet"):"Nothing under ".concat(w.fy[p]||"that filter"),body:y.length>0?"Everything here is under the other heading.":d?"That changes once clients start asking. Ask it to look at recent sessions and it will list what it missed.":"That changes once clients start asking. Choose a ".concat(c.Do," above to look at its recent sessions."),action:0===y.length?_:null}):(0,x.jsxs)("div",{children:[(0,x.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0},children:v.map((e=>{const t="stated"===e.origin,a=t?e.question||"A question it handed over":e.title||"Something worth a look",s=e.quote||(t?null:e.description)||null;return(0,x.jsxs)("li",{className:"teach-gap",children:[(0,x.jsxs)("div",{className:"teach-gap__tags",children:[(0,x.jsx)(ue.A,{tone:t?"accent":"info",children:t?w.fy.stated:w.fy.observed}),!t&&"number"===typeof e.confidence&&(0,x.jsxs)("span",{className:"teach-gap__conf",children:[Math.round(100*e.confidence),"% sure"]})]}),(0,x.jsx)("p",{className:"teach-gap__q",children:a}),t&&e.description&&(0,x.jsx)("p",{className:"teach-gap__why",children:e.description}),s&&(0,x.jsx)("blockquote",{className:"teach-gap__quote",children:s}),e.occurred_at&&(0,x.jsxs)("p",{className:"teach-gap__when",children:[t?"Asked":"Seen"," ",(0,w.Yc)(e.occurred_at)]}),(0,x.jsx)("div",{className:"teach-actions",children:(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:()=>
2r&&r(e.raw||e),children:"Teach this"})})]},"".concat(e.origin,":").concat(e.id))}))}),_&&(0,x.jsx)("div",{className:"teach-actions",children:_})]})]})}function pe(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("pending"===String(e.status||"").toLowerCase())return"Waiting to start";const t=String(e.progress_message||e.step||"").trim();return t?/vapi/i.test(t)?"Publishing the voice version":t.length<=90&&!/[{}[\]<>]/.test(t)?t.replace(/\.$/,""):"Updating":"Updating"}function ge(e){var t;let{name:a,state:n,missing:r,onPublish:o,pollJob:i,onRefetch:d}=e;const u=(0,l.dj)(),[h,p]=(0,s.useState)(null),[m,y]=(0,s.useState)(null),[f,v]=(0,s.useState)(null),[_,b]=(0,s.useState)(!1),[j,k]=(0,s.useState)(""),N=(0,s.useRef)(u);(0,s.useEffect)((()=>{N.current=u}),[u]);const A=(0,s.useRef)(d);(0,s.useEffect)((()=>{A.current=d}),[d]);const S=(0,s.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;k(""),y(t),v(Date.now()),p(e)}),[]);(0,s.useEffect)((()=>{const e=null===n||void 0===n?void 0:n.running_job;null!==e&&void 0!==e&&e.id&&!h&&S(e.id,{status:e.status,percent_complete:e.progress,progress_message:e.step})}),[n,h,S]),(0,s.useEffect)((()=>{if(!h)return;let e=!1,t=null;const a=Date.now(),s=()=>{p(null),y(null),A.current&&A.current()},n=async()=>{if(!e)if(Date.now()-a>6e5)s();else{try{const t=await i(h);if(e)return;y(t);if("completed"===String((null===t||void 0===t?void 0:t.status)||"").toLowerCase())return N.current.show({text:"Published. Your ".concat(c.Do," and its page are up to date."),tone:"success"}),void s();if((0,w.z4)(t))return N.current.show({text:(0,w.dN)(t.error_message||t.message||t.error||"It did not finish."),tone:"error"}),void s()}catch(r){}e||(t=setTimeout(n,3e3))}};return n(),()=>{e=!0,clearTimeout(t)}}),[h,i]);const C=(0,s.useCallback)((async()=>{b(!0),k("");try{const e=await o();null!==e&&void 0!==e&&e.jobId?(e.attached&&N.current.show({text:"It is already being updated. Watching that run."}),S(e.jobId)):A.current&&await A.current()}catch(e){k((null===e||void 0===e?void 0:e.message)||"Could not start it. Nothing was changed.")}finally{b(!1)}}),[o,S]);if(r||!n)return null;const I=Boolean(h),T=null!==(t=n.is_dirty)&&void 0!==t?t:Boolean(n.knowledge_dirty_at),q=(0,w.Zq)(n.last_refreshed_at||n.active_version_created_at);if(!I&&!T&&!q)return null;const z=function(e){let{running:t,dirty:a,when:s,name:n}=e;const r=n||"your ".concat(c.Do);return t?{tone:"warn",label:"Updating",text:"Updating ".concat(r," with what it has learned.")}:a?{tone:"warn",label:"Not yet published",text:"New knowledge since it was last published."}:{tone:"good",label:"Up to date",text:"Published ".concat(s,".")}}({running:I,dirty:T,when:q,name:a}),R=m&&void 0!==m.percent_complete&&null!==m.percent_complete?Number(m.percent_complete):null;return(0,x.jsxs)("div",{className:"teach-publish","data-testid":"teach-publish",children:[(0,x.jsxs)("div",{className:"teach-publish__line",children:[(0,x.jsx)(P.Ay,{tone:z.tone,children:z.label}),(0,x.jsx)("span",{className:"teach-publish__text",role:"status",children:z.text}),(T||I)&&(0,x.jsx)(g.A,{size:"lg",onClick:C,disabled:I||_,"aria-busy":_||void 0,children:I?"Updating\u2026":"Update and publish"})]}),I&&(0,x.jsx)(J.A,{className:"teach-publish__job",percent:Number.isFinite(R)?R:null,step:pe(m||{}),startedAt:f,maxWaitMs:3e5,label:"Updating and publishing"}),j&&(0,x.jsx)("p",{className:"teach-row__error",role:"alert",children:j})]})}var me=a(62529),ye=a(77309),fe=a(54866);const ve=[{key:"document",label:"Document"},{key:"video",label:"Video"},{key:"audio",label:"Audio"},{key:"page",label:"Web page"},{key:"text",label:"Note"},{key:"session",label:"Interview"},{key:"feed",label:"Feed article"}],we=["Ready","Processing","Failed","Duplicate"],xe=[{key:"all",label:"Yes"},{key:"some",label:"Some moments"},{key:"none",label:"No"},{key:"text",label:"Text only"}],_e=[25,50,100],be=e=>Boolean(e)&&("video"===e.kind||"audio"===e.kind);function je(e){return(ve.find((t=>t.key===e.kind))||{label:"Document"}).label}function ke(e){const t=Math.round(Number(e));if(null===e||void 0===e||!Number.isFinite(t)||t<0)return"";const a=Math.floor(t/3600),s=Math.floor(t%3600/60),n=String(t%60).padStart(2,"0");return a?"".concat(a,":").concat(String(s).padStart(2,"0"),":").concat(n):"".concat(s,":").concat(n)}function Ne(e){return(be(e)||"session"===e.kind)&&e.duration_s?ke(e.duration_s):(0,w.Xq)(e.size_bytes)||""}function Ae(e){return e.client_visible?(xe.find((t=>t.key===e.client_visible))||{label:"No"}).label:be(e)?"Not yet":"Text only"}function Se(e){return Object.values(e.protege_priorities||{}).map((e=>null===e||void 0===e?NaN:Number(e))).filter((e=>Number.isFinite(e)))}function Ce(e){if(e.priority_mixed)return!0;const t=Number(e.priority);return Se(e).some((e=>!Number.isFinite(t)||e!==t))}function Ie(e){if(Ce(e))return"Mixed, up to ".concat((0,w.Ix)(function(e){const t=[Number(e.priority),...Se(e)].filter((e=>Number.isFinite(e)));return t.length?Math.max(...t):e.priority}(e)));const t=(0,w.Ix)(e.priority);return"".concat((0,w.z7)(t)," ").concat(t)}function Te(e,t){const a=Array.isArray(e.protege_ids)?e.protege_ids:[],s=function(e){return(e.proteges||[]).map((e=>
2e.name)).filter(Boolean)}(e);return a.length||s.length?t>1&&a.length===t?"All ".concat(t):s.length?s.join(", "):"".concat(a.length," ").concat(1===a.length?"prot\xe9g\xe9":"prot\xe9g\xe9s"):"Shared"}function Pe(e){return(0,w.o7)(e)}const qe=e=>"duplicate"===String((null===e||void 0===e?void 0:e.status)||"").toLowerCase(),ze=e=>"failed"===String((null===e||void 0===e?void 0:e.status)||"").toLowerCase();function Re(e){return(0,w.Yc)(e.added_at)}function Ee(e){return!["text","session","feed"].includes(e.kind)}const De={name:{key:"title",first:"asc",asc:"A to Z",desc:"Z to A"},type:{key:"kind",first:"asc",asc:"A to Z",desc:"Z to A"},added:{key:"added_at",first:"desc",asc:"oldest first",desc:"newest first"},size:{key:"size_bytes",first:"desc",asc:"smallest first",desc:"largest first"},priority:{key:"priority",first:"desc",asc:"lowest first",desc:"highest first"},onscreen:{key:"client_visible",first:"desc",asc:"Text only first",desc:"Yes first"},proteges:{key:"proteges",first:"desc",asc:"fewest first",desc:"shared first"},status:{key:"status",first:"desc",asc:"Ready first",desc:"Failed first"}},Me={name:"Name",type:"Type",added:"Added",size:"Size / length",priority:"Priority",onscreen:"Shown on screen",proteges:"Prot\xe9g\xe9s",status:"Status"},Fe=Object.keys(De).filter((e=>De[e].key));function Oe(e,t){const a=De[t];if(a&&a.key)return e.sort!==a.key?"none":"asc"===e.order?"ascending":"descending"}const We="shared",Ue=Object.freeze({sort:"added_at",order:"desc",kind:"",status:"",onScreen:"",proteges:Object.freeze([]),q:"",limit:25,offset:0}),Le=Object.freeze({kind:"",status:"",onScreen:"",proteges:[],q:""});function Ye(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length?1===e.length?e[0]===We?"Shared":(t.find((t=>t.id===e[0]))||{}).name||"1 chosen":"".concat(e.length," chosen"):"Any"}function Be(e){let{col:t,query:a,onSort:s}=e;const n=De[t];if(!n.key)return(0,x.jsx)("span",{className:"adv-unsortable",children:Me[t]});const r=a.sort===n.key,o=r?"asc"===a.order?"\u25b2":"\u25bc":"\u2195";return(0,x.jsxs)("button",{type:"button",className:"adv-sort","data-active":r,onClick:()=>s(t),children:[Me[t],(0,x.jsx)("span",{className:"adv-sort__glyph","aria-hidden":"true",children:o}),r&&(0,x.jsx)("span",{className:"sr-only",children:", sorted ".concat(n[a.order])})]})}function Ve(e){let{value:t=[],proteges:a=[],onChange:n}=e;
2const[r,o]=(0,s.useState)(!1),i=(0,s.useId)(),l="adv-pf-".concat(i),c="adv-pf-label-".concat(i),d=[...a.map((e=>({id:e.id,name:e.name}))),{id:We,name:"Shared (no prot\xe9g\xe9 chosen)"}];return(0,x.jsxs)("div",{className:"ds-field adv-pfilter",onKeyDown:e=>{"Escape"===e.key&&r&&(e.stopPropagation(),o(!1))},children:[(0,x.jsx)("span",{className:"ds-field__label",id:c,children:"Prot\xe9g\xe9s"}),(0,x.jsxs)("button",{type:"button",className:"ds-input adv-pfilter__button","aria-expanded":r,"aria-controls":l,"aria-labelledby":"".concat(c," ").concat(l,"-value"),onClick:()=>o((e=>!e)),children:[(0,x.jsx)("span",{id:"".concat(l,"-value"),children:Ye(t,a)}),(0,x.jsx)("span",{"aria-hidden":"true",children:r?"\u25b2":"\u25bc"})]}),r&&(0,x.jsxs)("div",{className:"adv-pfilter__panel",id:l,role:"group","aria-labelledby":c,children:[d.map((e=>(0,x.jsx)(z.tu,{label:e.name,checked:t.includes(e.id),onChange:()=>(e=>{const a=t.includes(e)?t.filter((t=>t!==e)):[...t,e];n(a)})(e.id)},e.id))),(0,x.jsxs)("div",{className:"adv-detail__row",children:[(0,x.jsx)(g.A,{size:"md",variant:"secondary",onClick:()=>o(!1),children:"Done"}),t.length>0&&(0,x.jsx)(g.A,{size:"md",variant:"ghost",onClick:()=>n([]),children:"Any prot\xe9g\xe9"})]})]})]})}function Je(e){let{rows:t,selection:a,onSelect:n}=e;const r=(0,s.useRef)(null),o=t.filter((e=>a.has(e.source_uri))).length,i=t.length>0&&o===t.length;return(0,s.useEffect)((()=>{r.current&&(r.current.indeterminate=o>0&&!i)}),[o,i]),(0,x.jsx)("span",{className:"adv-check",children:(0,x.jsx)(fe.A,{ref:r,checked:i,disabled:0===t.length,onChange:()=>n(t,!i),"aria-label":i?"Clear the selection on this page":"Select every source on this page"})})}function He(e){let{source:t,onOpen:a}=e;const s=qe(t)&&t.duplicate_of&&t.duplicate_of[0]?(0,w.nV)(t.duplicate_of[0]):null;let n="";if("page"===t.kind)try{n=new URL(t.source_uri).hostname}catch(r){n=""}return(0,x.jsxs)("div",{className:"adv-name-cell",children:[(0,x.jsx)("button",{type:"button",className:"adv-name","data-source-uri":t.source_uri,onClick:()=>a(t),children:t.title}),s&&(0,x.jsx)("span",{className:"adv-sub",children:'Same file as "'.concat(s,'"')}),!s&&n&&(0,x.jsx)("span",{className:"adv-sub",children:n})]})}function Ke(e){let{data:t,proteges:a=[],protegeCount:s=a.length,onOpen:n,bulkBar:r=null}=e;const{query:i,setQuery:l,rows:c,total:d,grandTotal:u,state:h,loadError:p,reload:m,selection:y,select:f}=t,v=function(e,t,a){const s=Math.max(1,Math.ceil((a||0)/e.limit)),n=Math.floor(e.offset/e.limit)+1;return{from:a?e.offset+1:0,to:e.offset+t,page:n,pages:s,hasPrevious:n>1,hasNext:n<s}}(i,c.length,d),w=(e=>Boolean(e.kind||e.status||e.onScreen||e.proteges&&e.proteges.length||e.q&&e.q.trim()))(i),_="loading"===h,j=e=>l(function(e,t){const a=De[t];return a&&a.key?e.sort===a.key?{sort:a.key,order:"asc"===e.order?"desc":"asc"}:{sort:a.key,order:a.first}:{sort:e.sort,order:e.order}}(i,e));if("error"===h)return(0,x.jsxs)("div",{className:"teach-error",role:"alert",children:[(0,x.jsx)("p",{style:{margin:0}
2,children:p||"We could not load your sources just now. Nothing was changed."}),(0,x.jsx)("div",{className:"teach-actions",children:(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:()=>m(),children:"Try again"})})]});if(!_&&0===u&&!w)return(0,x.jsx)(o.A,{level:3,title:"Nothing here yet",body:"Every document, video, web page, note and interview you add will be listed here, one row per source."});const k=!_&&0===d,N=e=>(0,x.jsx)(Be,{col:e,query:i,onSort:j}),A=[{key:"select",header:(0,x.jsx)(Je,{rows:c,selection:y,onSelect:f}),width:56,render:e=>(0,x.jsx)("span",{className:"adv-check",children:(0,x.jsx)(fe.A,{checked:y.has(e.source_uri),onChange:()=>f([e],!y.has(e.source_uri)),"aria-label":"Select ".concat(e.title)})})},{key:"name",sort:Oe(i,"name"),header:N("name"),render:e=>(0,x.jsx)(He,{source:e,onOpen:n})},{key:"type",sort:Oe(i,"type"),header:N("type"),render:e=>je(e)},{key:"added",sort:Oe(i,"added"),header:N("added"),render:e=>(0,x.jsx)("span",{className:"adv-nowrap",children:Re(e)})},{key:"size",align:"right",sort:Oe(i,"size"),header:N("size"),render:e=>Ne(e)},{key:"priority",sort:Oe(i,"priority"),header:N("priority"),render:e=>(0,x.jsx)("span",{className:"adv-nowrap",children:Ie(e)})},{key:"onscreen",sort:Oe(i,"onscreen"),header:N("onscreen"),render:e=>Ae(e)},{key:"proteges",sort:Oe(i,"proteges"),header:N("proteges"),render:e=>(0,x.jsx)("span",{className:"adv-proteges-cell",children:Te(e,s)})},{key:"status",sort:Oe(i,"status"),header:N("status"),render:e=>{const t=Pe(e);return(0,x.jsx)(P.Ay,{tone:t.tone,children:t.label})}}],S=(C=i.sort,Fe.find((e=>De[e].key===C))||null);var C;return(0,x.jsxs)("div",{children:[(0,x.jsxs)("div",{className:"adv-filters",role:"search","aria-label":"Filter your sources",children:[(0,x.jsx)(z.Ay,{label:"Find a source",type:"search",value:i.q,placeholder:"A title, a file name, a web address",autoComplete:"off",onChange:e=>l({q:e.target.value})}),(0,x.jsxs)(z.Ay,{as:"select",label:"Type",value:i.kind,onChange:e=>l({kind:e.target.value}),children:[(0,x.jsx)("option",{value:"",children:"All types"}),ve.filter((e=>"feed"!==e.key)).map((e=>(0,x.jsx)("option",{value:e.key,children:e.label},e.key)))]}),(0,x.jsxs)(z.Ay,{as:"select",label:"Status",value:i.status,onChange:e=>l({status:e.target.value}),children:[(0,x.jsx)("option",{value:"",children:"Any status"}),we.map((e=>(0,x.jsx)("option",{value:e,children:e},e)))]}),(0,x.jsxs)(z.Ay,{as:"select",label:"Shown on screen",value:i.onScreen,onChange:e=>l({onScreen:e.target.value}),children:[(0,x.jsx)("option",{value:"",children:"Any"}),xe.map((e=>(0,x.jsx)("option",{value:e.key,children:e.label},e.key)))]}),(0,x.jsx)(Ve,{value:i.proteges,proteges:a,onChange:e=>l({proteges:e})})]}),(0,x.jsxs)("div",{className:"adv-countline",children:[(0,x.jsx)("p",{className:"adv-count",id:"adv-count",tabIndex:-1,role:"status","aria-live":"polite",children:_?"Loading your sources":k?"No sources match. ".concat(u.toLocaleString()," ").concat(1===u?"source":"sources"," in all."):(0,x.jsxs)(x.Fragment,{children:["Showing ",(0,x.jsx)("strong",{children:v.from.toLocaleString()})," to ",(0,x.jsx)("strong",{children:v.to.toLocaleString()})," of ",(0,x.jsx)("strong",{children:d.toLocaleString()})," ".concat(1===d?"source":"sources"),w?" (filtered from ".concat(u.toLocaleString(),")"):""]})}),w&&(0,x.jsx)(g.A,{size:"md",variant:"ghost",onClick:()=>l((0,b.A)({},Le)),children:"Clear filters"})]}),r,(0,x.jsx)("div",{className:"adv-table",children:(0,x.jsx)(ye.A,{caption:(0,x.jsx)("span",{className:"sr-only",children:"Your sources. Select a name to see and change one source."}),columns:A,rows:c,rowKey:e=>e.source_uri,loading:_,isSelected:e=>y.has(e.source_uri),empty:{title:"No sources match these filters",body:"Change a filter or clear them to see every source."}})}),(0,x.jsxs)("div",{className:"adv-stack",children:[(0,x.jsxs)("div",{className:"adv-stack__sort",children:[(0,x.jsx)(z.Ay,{as:"select",label:"Sort by",value:S||"",onChange:e=>l({sort:De[e.target.value].key,order:De[e.target.value].first}),children:Fe.map((e=>(0,x.jsx)("option",{value:e,children:Me[e]},e)))}),(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:()=>l({order:"asc"===i.order?"desc":"asc"}
2),children:S?"Order: ".concat(De[S][i.order]):"Reverse"})]}),_&&(0,x.jsx)("ul",{className:"adv-stack-list","aria-hidden":"true",children:[0,1,2].map((e=>(0,x.jsxs)("li",{className:"adv-stack-row",children:[(0,x.jsx)("span",{}),(0,x.jsxs)("div",{className:"adv-stack-row__main",children:[(0,x.jsx)(q.E,{height:16,width:"80%"}),(0,x.jsx)(q.E,{height:14,width:"60%"})]})]},e)))}),k&&(0,x.jsx)(o.A,{level:3,title:"No sources match these filters",body:"Change a filter or clear them to see every source."}),!_&&!k&&(0,x.jsx)("ul",{className:"adv-stack-list","aria-label":"Your sources",children:c.map((e=>{const t=Pe(e),a=y.has(e.source_uri),r=Ne(e);return(0,x.jsxs)("li",{className:"adv-stack-row".concat(a?" is-selected":""),children:[(0,x.jsx)("span",{className:"adv-check",style:{margin:0},children:(0,x.jsx)(fe.A,{checked:a,onChange:()=>f([e],!a),"aria-label":"Select ".concat(e.title)})}),(0,x.jsxs)("div",{className:"adv-stack-row__main",children:[(0,x.jsx)(He,{source:e,onOpen:n}),(0,x.jsxs)("p",{className:"adv-stack-row__meta",children:[(0,x.jsx)("span",{children:je(e)}),r&&(0,x.jsx)("span",{children:r}),(0,x.jsx)("span",{children:"Added ".concat(Re(e))})]}),(0,x.jsxs)("dl",{className:"adv-stack-row__facts",children:[(0,x.jsx)("dt",{children:"Priority"}),(0,x.jsx)("dd",{children:Ie(e)}),(0,x.jsx)("dt",{children:"Shown on screen"}),(0,x.jsx)("dd",{children:Ae(e)}),(0,x.jsx)("dt",{children:"Prot\xe9g\xe9s"}),(0,x.jsx)("dd",{children:Te(e,s)})]}),(0,x.jsx)("div",{children:(0,x.jsx)(P.Ay,{tone:t.tone,children:t.label})})]})]},e.source_uri)}))})]}),!k&&(0,x.jsxs)("nav",{className:"adv-pager","aria-label":"Pages of sources",children:[(0,x.jsx)("div",{className:"adv-pager__size",children:(0,x.jsx)(z.Ay,{as:"select",label:"Show per page",value:i.limit,onChange:e=>l({limit:Number(e.target.value)}),children:_e.map((e=>(0,x.jsx)("option",{value:e,children:e},e)))})}),(0,x.jsxs)("div",{className:"adv-pager__nav",children:[(0,x.jsx)(g.A,{size:"lg",variant:"secondary",disabled:_||!v.hasPrevious,onClick:()=>
2l({offset:Math.max(0,i.offset-i.limit)}),children:"Previous"}),(0,x.jsx)("span",{className:"adv-pager__where",children:"Page ".concat(v.page," of ").concat(v.pages)}),(0,x.jsx)(g.A,{size:"lg",variant:"secondary",disabled:_||!v.hasNext,onClick:()=>l({offset:i.offset+i.limit}),children:"Next"})]})]})]})}function Ge(e){let{count:t,mediaCount:a,mixedCount:n=0,someCount:r=0,proteges:o=[],onPriority:i,onOnScreen:l,onProtege:c,onDelete:d,onClear:u,busy:h=!1}=e;const[p,m]=(0,s.useState)(o[0]?o[0].id:"");if((0,s.useEffect)((()=>{o.some((e=>e.id===p))||m(o[0]?o[0].id:"")}),[o,p]),!t)return null;const y=1===t?"source":"sources";return(0,x.jsxs)("section",{className:"adv-bulk","aria-label":"Change the selected sources",children:[(0,x.jsxs)("div",{className:"adv-bulk__head",children:[(0,x.jsx)("p",{className:"adv-bulk__count",role:"status",children:"".concat(t.toLocaleString()," ").concat(y," selected")}),(0,x.jsx)(g.A,{size:"md",variant:"ghost",onClick:u,children:"Clear selection"})]}),(0,x.jsxs)("div",{className:"adv-bulk__rows",children:[(0,x.jsxs)("div",{className:"adv-bulk__group",role:"group","aria-labelledby":"adv-bulk-priority",children:[(0,x.jsx)("span",{id:"adv-bulk-priority",className:"adv-bulk__label",children:"Set Priority"}),(0,x.jsx)("div",{className:"adv-bulk__buttons",children:w.$8.map((e=>(0,x.jsx)("button",{type:"button",className:"adv-preset","aria-pressed":"false",disabled:h,onClick:()=>i(w.KV[e]),children:"".concat(e," ").concat(w.KV[e])},e)))})]}),(0,x.jsxs)("div",{className:"adv-bulk__group",role:"group","aria-labelledby":"adv-bulk-screen",children:[(0,x.jsx)("span",{id:"adv-bulk-screen",className:"adv-bulk__label",children:a?"Shown on screen (".concat(a," ").concat(1===a?"is":"are"," video or audio)"):"Shown on screen (no video or audio selected)"}),(0,x.jsxs)("div",{className:"adv-bulk__buttons",children:[(0,x.jsx)(g.A,{size:"md",variant:"secondary",disabled:!a||h,onClick:()=>l(!0),children:"Show"}),(0,x.jsx)(g.A,{size:"md",variant:"secondary",disabled:!a||h,onClick:()=>l(!1),children:"Hide"})]})]}),o.length>0&&(0,x.jsxs)("div",{className:"adv-bulk__group",children:[(0,x.jsx)("label",{htmlFor:"adv-bulk-protege",className:"adv-bulk__label",children:"Prot\xe9g\xe9s"}),(0,x.jsxs)("div",{className:"adv-bulk__buttons",children:[(0,x.jsx)("select",{id:"adv-bulk-protege",className:"ds-input adv-bulk__select",style:{width:"auto",maxWidth:"100%"},value:p,onChange:e=>m(e.target.value),children:o.map((e=>(0,x.jsx)("option",{value:e.id,children:e.name},e.id)))}),(0,x.jsx)(g.A,{size:"md",variant:"secondary",disabled:h||!p,onClick:()=>c(p,!0),children:"Add to it"}),(0,x.jsx)(g.A,{size:"md",variant:"secondary",disabled:h||!p,onClick:()=>c(p,!1),children:"Remove from it"})]})]}),(0,x.jsxs)("div",{className:"adv-bulk__group",children:[(0,x.jsx)("span",{className:"adv-bulk__label","aria-hidden":"true",children:"\xa0"}),(0,x.jsx)(g.A,{size:"md",variant:"destructive",disabled:h,onClick:d,children:"Delete ".concat(t.toLocaleString()," ").concat(y)})]})]}),(0,x.jsx)("p",{className:"adv-saverule",children:"Priority, Shown on screen and prot\xe9g\xe9s change at once, and you can undo for 8 seconds. Delete asks you first."}),n>0&&(0,x.jsx)("p",{className:"adv-saverule",children:"".concat(n," selected ").concat(1===n?"has":"have"," passages at more than one Priority. Undo puts every passage in ").concat(1===n?"it":"those"," back at ").concat(1===n?"its":"their"," highest, not the mixed values.")}),r>0&&(0,x.jsx)("p",{className:"adv-saverule",children:"".concat(r," selected ").concat(1===r?"shows":"show"," only some moments today. Hide cannot be undone for ").concat(1===r?"it":"them",", and after Show, Undo hides all of ").concat(1===r?"it":"them",".")})]})}const Xe=()=>Y.A.backendProxy;async function $e(e){try{return await e.json()}catch(t){return null}}function Ze(e){return e&&e.details&&e.details.upstream_body&&"object"===typeof e.details.upstream_body?(0,b.A)((0,b.A)({},e),e.details.upstream_body):e||{}}class Qe extends Error{constructor(e){let{status:t=0,kind:a="fault",applied:s=[],retryable:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e),this.name="SourcesError",this.status=t,this.kind=a,this.applied=s,this.retryable=n}}async function et(e){let t,{expertId:a,protegeId:s,query:n,token:r,request:o=fetch,signal:i}=e;try{t=await o("".concat(Xe(),"/knowledge/sources?").concat(function(e){let{expertId:t,protegeId:a=null,query:s}=e;const n=new URLSearchParams({expert_id:t,scope:"all"});return a&&n.set("protege_id",a),n.set("sort",s.sort),n.set("order",s.order),s.kind&&n.set("kind",s.kind),s.status&&n.set("status",s.status),s.onScreen&&n.set("client_visible",s.onScreen),s.proteges&&s.proteges.length&&n.set("protege",s.proteges.join(",")),s.q&&s.q.trim()&&n.set("q",s.q.trim()),n.set("limit",String(s.limit)),n.set("offset",String(s.offset)),n}({expertId:a,protegeId:s,query:n})),(0,b.A)({headers:(0,w.Pw)(r)},i?{signal:i}:{}))}catch(h){if(h&&"AbortError"===h.name)throw h;throw new Qe("We could not load your sources just now. Nothing was changed.",{kind:"network",retryable:!0})}const l=await $e(t);if(401===t.status)throw new Qe("You are signed out. Sign in again to see your sources.",{status:401,kind:"auth"});if(403===t.status)throw new Qe("One of the prot\xe9g\xe9s in the filter is not yours. Clear the filters to
2see your sources.",{status:403,kind:"forbidden"});if(!t.ok||!l||!Array.isArray(l.sources))throw new Qe("We could not load your sources just now. Nothing was changed.",{status:t.status,retryable:!0});const c=l.sources.map((e=>{var t;return(0,b.A)((0,b.A)({},e),{},{title:(0,w.nV)(e.source_uri,e),protege_ids:Array.isArray(e.protege_ids)?e.protege_ids:[],proteges:Array.isArray(e.proteges)?e.proteges:[],protege_priorities:e.protege_priorities&&"object"===typeof e.protege_priorities?e.protege_priorities:{},duplicate_of:Array.isArray(e.duplicate_of)?e.duplicate_of:[],shared:null!==(t=e.shared)&&void 0!==t?t:!(Array.isArray(e.protege_ids)&&e.protege_ids.length>0)})})),d=Number.isFinite(Number(l.total))?Number(l.total):c.length,u=Number(l.unfiltered_total);return{sources:c,total:d,unfilteredTotal:Number.isFinite(u)?u:d}}function tt(e){return 1===e.length?{source_uri:e[0]}:{source_uris:e}}async function at(e,t,a){const s=new Array(e.length);let n=0;return await Promise.all(Array.from({length:Math.max(1,Math.min(t,e.length))},(async()=>{for(;n<e.length;){const r=n;n+=1;try{s[r]={item:e[r],ok:!0,value:await a(e[r])}}catch(t){s[r]={item:e[r],ok:!1,error:t}}}}))),s}const st=e=>Math.min(w.gX,Math.max(w.Op,Number(e)));function nt(e,t){const a=new Map;return e.forEach((e=>{const s=t(e);null!==s&&(a.has(s)||a.set(s,[]),a.get(s).push(e))})),a}function rt(e,t){const a=[],s=e.length>1;if(void 0!==t.priority&&null!==t.priority){const t=e.filter((e=>e.priority_mixed)),n=e.filter((e=>!e.priority_mixed&&Number.isFinite(Number(e.priority))&&Number(e.priority)<w.Op));t.length&&a.push(s?"".concat(t.length," of them had passages at more than one Priority; every passage in those is back at its highest."):"Every passage is back at Priority ".concat(st(t[0].priority),"; they were mixed before.")),n.length&&a.push(s?"".concat(n.length," of them were below 1 and are back at Priority 1, the lowest there is."):"It is back at Priority 1, the lowest there is; it was below 1 before.")}if(!0===t.client_visible){const t=e.filter((e=>"some"===e.client_visible));t.length&&a.push(s?"".concat(t.length," of them showed only some moments before; they are hidden again."):"It is hidden again; before, only some moments were shown.")}return a.length?"Undone. ".concat(a.join(" ")):s?"Undone. They are back as they were.":"Undone. It is back as it was."}function ot(e){return{priority:e,protege_priority:e}}const it={fetchSourcesPage:et,fetchSourceByUri:async function(e){let{expertId:t,sourceUri:a,token:s,request:n=fetch}=e;const r={sort:"source_uri",order:"asc",kind:"",status:"",onScreen:"",proteges:[],q:a,limit:25,offset:0},{sources:o}=await et({expertId:t,query:r,token:s,request:n});return o.find((e=>e.source_uri===a))||null},fetchPassages:async function(e){var t,a,s;let{expertId:n,source:r,token:o,limit:i=12,request:l=fetch}=e;const c="video"===r.kind||"audio"===r.kind||"session"===r.kind,d=new URLSearchParams({expert_id:n,source_uri:r.source_uri,full_content:"true",sort_by:c?"t_start":"created_at",sort_order:"asc",limit:String(i),offset:"0"});let u;try{u=await l("".concat(Xe(),"/knowledge?").concat(d),{headers:(0,w.Pw)(o)})}catch(g){throw new Qe("We could not load the preview just now.",{kind:"network",retryable:!0})}const h=await $e(u);if(!u.ok||!h||!1===h.success||!Array.isArray(h.entries))throw new Qe("We could not load the preview just now.",{status:u.status,retryable:!0});const p=Number(null!==(t=null!==(a=null===(s=h.pagination)||void 0===s?void 0:s.total)&&void 0!==a?a:h.total)&&void 0!==t?t:h.entries.length);return{entries:h.entries,total:Number.isFinite(p)?p:h.entries.length}},fetchPlaybackUrl:async function(e){let{entryId:t,tStart:a,tEnd:s,token:n,request:r=fetch}=e;const o=await r("".concat(Xe(),"/api/v1/media/playback-url"),{method:"POST",headers:(0,w.Pw)(n),body:JSON.stringify((0,b.A)((0,b.A)({kb_entry_id:t},null!==a&&void 0!==a?{t_start:a}:{}),null!==s&&void 0!==s?{t_end:s}:{}))}),i=await $e(o);if(!o.ok||!i||!1===i.success||!i.playback_url)throw new Qe("This recording cannot be played here right now.",{status:(null===i||void 0===i?void 0:i.status_code)||o.status});return i},patchSources:async function(e){let t,{selector:a,changes:s,token:n,request:r=fetch}=e;try{t=await r("".concat(Xe(),"/knowledge/source"),{method:"PATCH",headers:(0,w.Pw)(n),body:JSON.stringify((0,b.A)((0,b.A)({},a),s))})}
2catch(i){throw new Qe("That change did not reach us. Check your connection; nothing was changed.",{kind:"network",retryable:!0})}const o=await $e(t);if(!t.ok||o&&!1===o.success)throw function(e,t){const a=Ze(t),s=Array.isArray(a.applied)?a.applied:[],n=String(a.message||a.error||"").trim(),r=n&&n.length<=140&&!/[{}[\]<>]|Traceback|PGRST|column|relation/i.test(n);switch(e){case 400:return new Qe(r?"That change was not accepted: ".concat(n.replace(/\.?$/,".")," Nothing was changed."):"That change was not accepted. Nothing was changed.",{status:e,kind:"invalid"});case 401:return new Qe("You are signed out. Sign in again, then make the change. Nothing was changed.",{status:e,kind:"auth"});case 403:return new Qe("That prot\xe9g\xe9 is not one of yours, so nothing was changed.",{status:e,kind:"forbidden"});case 404:return new Qe("That source is no longer there. Refresh the list to see what is.",{status:e,kind:"gone"});case 503:return new Qe("This change is not available yet. Nothing was changed.",{status:e,kind:"unavailable",retryable:!1});default:return s.length?new Qe("Part of this change was saved and part was not. Press Try again to finish it.",{status:e,kind:"partial",applied:s,retryable:!1!==a.retryable}):new Qe("That change did not go through. Nothing was changed. Try it again.",{status:e,kind:"fault",retryable:!0})}}(t.status||500,o);return o||{}},replaceSourceUpload:async function(e){let{file:t,source:a,token:s,request:n=fetch,onStage:r=()=>{}}=e;const o=t.type||"application/octet-stream";r("uploading");const i=await n("".concat(Xe(),"/api/v1/upload-url"),{method:"POST",headers:(0,w.Pw)(s),body:JSON.stringify({filename:t.name,content_type:o,size:t.size})}),l=await $e(i)||{};if(!i.ok||!l.success||!l.upload_url)throw new Qe("Could not start the upload. Nothing was changed. Try again in a moment.",{status:i.status,retryable:!0});const c=await n(l.upload_url,{method:"PUT",headers:l.required_headers||{"Content-Type":o},body:t});if(!c.ok)throw new Qe("The upload did not finish. Nothing was changed. Check your connection and try again.",{status:c.status,retryable:!0});r("starting");const d=await n("".concat(Xe(),"/api/v1/ingest"),{method:"POST",headers:(0,w.Pw)(s),body:JSON.stringify({content_type:"file",source_type:"file",async:!0,source_data:{gcs_url:l.gcs_url,filename:t.name,content_type:o,size:t.size},options:{replaces_source_uri:a.source_uri,remove_pii:!0}})}),u=await $e(d)||{};if(400===d.status){const e=Ze(u),t=String(e.message||e.error||"").trim();throw new Qe(t&&t.length<=140?"That file cannot replace this source: ".concat(t.replace(/\.?$/,".")," Nothing was changed."):"That file cannot replace this source. Nothing was changed.",{status:400,kind:"invalid"})}if(!d.ok||!1===u.success)throw new Qe("The server could not start on the new version. Nothing was changed. Try again.",{status:d.status,retryable:!0});return{jobId:u.job_id||null}},fetchJob:async function(e){let{jobId:t,token:a,request:s=fetch}=e;const n=await s("".concat(Xe(),"/api/v1/knowledge/jobs/").concat(encodeURIComponent(t)),{headers:(0,w.Pw)(a)}),r=await $e(n);if(!n.ok||!r)throw new Qe("Could not read how the new version is doing.",{status:n.status,retryable:!0});return r}};function lt(e){let{source:t,cue:a,api:n,token:o}=e;const[i,l]=(0,s.useState)(null),[c,d]=(0,s.useState)("idle"),u=a&&Number(a.t_start)||0,h=(0,s.useCallback)((async()=>{if(a){d("loading");try{const e=await o(),t=await n.fetchPlaybackUrl({entryId:a.id,tStart:a.t_start,tEnd:a.t_end,token:e}),s=t.media_fragment||(Number.isFinite(u)?"#t=".concat(u):"");l({src:"".concat(t.playback_url).concat(t.playback_url.includes("#")?"":s),entryId:a.id}),d("ready")}catch(e){d("error")}}}),[n,a,u,o]),p=(0,s.useRef)(!1);(0,s.useEffect)((()=>{"ready"===c&&(p.current=!0)}),[c]),(0,s.useEffect)((()=>{!p.current||!a||i&&i.entryId===a.id||h()}),[a&&a.id]);const m="audio"===t.kind;return(0,x.jsx)(r.Ay,{surface:"stage",className:"adv-player","aria-label":"".concat(je(t)," player"),children:"ready"===c&&i?m?(0,x.jsx)("audio",{src:i.src,controls:!0,autoPlay:!0,"aria-label":"".concat(t.title,", from ").concat(ke(u))}
2,i.src):(0,x.jsx)("video",{src:i.src,controls:!0,autoPlay:!0,playsInline:!0,"aria-label":"".concat(t.title,", from ").concat(ke(u))},i.src):(0,x.jsx)("div",{className:"adv-player__screen".concat(m?" adv-player__screen--audio":""),children:"error"===c?(0,x.jsx)("p",{className:"adv-player__note",role:"alert",children:"This recording cannot be played here right now. The transcript is below."}):(0,x.jsx)(g.A,{size:"lg",variant:"primary",loading:"loading"===c,disabled:!a,onClick:h,children:"Play from ".concat(ke(u))})})})}function ct(e){let{source:t,api:a,expertId:n,token:r,cueAt:o=null}=e;const i=be(t)||"session"===t.kind,[l,c]=(0,s.useState)({state:"loading",entries:[],total:0}),[d,u]=(0,s.useState)(null),h=(0,s.useCallback)((async()=>{c({state:"loading",entries:[],total:0});try{const e=await r(),s=await a.fetchPassages({expertId:n,source:t,token:e,limit:i?12:4});c({state:"ready",entries:s.entries,total:s.total})}catch(e){c({state:"error",entries:[],total:0})}}),[a,n,t.source_uri,i,r]);(0,s.useEffect)((()=>{h()}),[h]);const p=(0,s.useRef)(null);if((0,s.useEffect)((()=>{if(null===o||void 0===o||"ready"!==l.state||!p.current)return;const e=p.current.querySelector('[aria-current="true"]');e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}),[o,l.state]),"loading"===l.state)return(0,x.jsx)("p",{className:"adv-detail__p adv-detail__muted",role:"status",children:"Loading the preview"});if("error"===l.state)return(0,x.jsxs)("div",{role:"alert",children:[(0,x.jsx)("p",{className:"adv-detail__p",children:"We could not load the preview just now."}),(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:h,children:"Try again"})]});if(!l.entries.length)return(0,x.jsx)("p",{className:"adv-detail__p adv-detail__muted",children:"There is nothing to preview yet."});if(be(t)){const e=function(e){const t=e.filter((e=>"visual"!==e.modality));return t.length?t:e}(l.entries),s=e.filter((e=>e.playable)),n=e.find((e=>e.id===d))||function(e,t){const a=Number(t);if(null===t||void 0===t||!Number.isFinite(a))return null;const s=e.filter((e=>e.playable&&Number.isFinite(Number(e.t_start))));let n=null;return s.forEach((e=>{Number(e.t_start)<=a+.5&&(n=e)})),n||s[0]||null}(e,o)||s[0]||null;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(lt,{source:t,cue:n&&n.playable?n:s[0]||null,api:a,token:r}),(0,x.jsx)("h4",{className:"adv-detail__h",style:{marginTop:16},children:"Transcript"}),(0,x.jsx)("p",{className:"adv-detail__p adv-detail__muted",children:"Select a line to play the ".concat("video"===t.kind?"video":"recording"," from that moment.")}),(0,x.jsx)("ol",{className:"adv-transcript","aria-label":"Transcript",ref:p,children:e.map((e=>(0,x.jsx)("li",{children:(0,x.jsxs)("button",{type:"button",className:"adv-cue","aria-current":n&&e.id===n.id?"true":void 0,disabled:!e.playable,onClick:()=>u(e.id),children:[(0,x.jsx)("span",{className:"adv-cue__time",children:ke(e.t_start)}),(0,x.jsxs)("span",{children:[e.content||e.content_preview,!1===e.client_visible&&(0,x.jsx)("span",{className:"adv-cue__hidden",children:"Not shown on screen"})]})]})},e.id)))}),(0,x.jsx)("p",{className:"adv-detail__p adv-detail__muted",style:{marginTop:8},children:"Showing the first ".concat(e.length," of ").concat(l.total," moments.")})]})}return"session"===t.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("p",{className:"adv-detail__p adv-detail__muted",children:"The transcript of your conversation with the AI Interviewer."}),(0,x.jsx)("ol",{className:"adv-transcript","aria-label":"Transcript",tabIndex:0,children:l.entries.map((e=>(0,x.jsx)("li",{children:(0,x.jsxs)("div",{className:"adv-cue adv-cue--static",children:[(0,x.jsx)("span",{className:"adv-cue__time",children:ke(e.t_start)}),(0,x.jsx)("span",{children:e.content||e.content_preview})]})},e.id)))}),(0,x.jsx)("p",{className:"adv-detail__p adv-detail__muted",style:{marginTop:8},children:"Showing the first ".concat(l.entries.length," of ").concat(l.total," passages.")})]}):(0,x.jsxs)(x.Fragment,{children:[l.entries.map((e=>(0,x.jsx)("p",{className:"adv-passage",children:e.content||e.content_preview},e.id))),(0,x.jsx)("p",{className:"adv-detail__p adv-detail__muted",style:{marginTop:8},children:"Showing the first ".concat(l.entries.length," of ").concat(l.total," passages.")})]})}function dt(e){let{source:t,proteges:a,onChange:n}=e;
2const r=(0,w.Ix)(t.priority),o=Ce(t),[i,l]=(0,s.useState)(String(r)),c=Number(i),d=Number.isInteger(c)&&c>=w.Op&&c<=w.gX,u=e=>{l(String(e)),n(ot(e),'Priority for "'.concat(t.title,'" is now ').concat((0,w.z7)(e)," ").concat(e,"."))},h=(t.protege_ids||[]).map((e=>[e,(t.protege_priorities||{})[e]]));return(0,x.jsxs)("section",{className:"adv-detail__section","aria-labelledby":"adv-d-priority",children:[(0,x.jsx)("h3",{id:"adv-d-priority",className:"adv-detail__h",children:"Priority"}),(0,x.jsx)("p",{className:"adv-detail__p",children:"".concat((0,w.z7)(r)," (").concat(r," of ").concat(w.gX,"). Higher Priority material is used first when your prot\xe9g\xe9 answers.")}),o&&(0,x.jsx)("p",{className:"adv-detail__p",children:"This source has more than one Priority today. Choosing one here sets it for every passage and every prot\xe9g\xe9."}),t.priority_mixed&&(0,x.jsx)("p",{className:"adv-detail__p","data-testid":"undo-inexact-priority",children:"Undo cannot bring back the different values its passages have now: it puts every passage back at Priority ".concat((0,w.Ix)(t.priority),".")}),!t.priority_mixed&&Number.isFinite(Number(t.priority))&&Number(t.priority)<w.Op&&(0,x.jsx)("p",{className:"adv-detail__p","data-testid":"undo-inexact-priority",children:"Its Priority today is below 1, which can no longer be set. Undo puts it back at 1, the lowest there is."}),(0,x.jsx)("div",{className:"adv-detail__row",role:"group","aria-label":"Priority presets",children:w.$8.map((e=>(0,x.jsx)("button",{type:"button",className:"adv-preset","aria-pressed":!o&&r===w.KV[e],onClick:()=>u(w.KV[e]),children:"".concat(e," ").concat(w.KV[e])},e)))}),(0,x.jsxs)("div",{className:"adv-number",children:[(0,x.jsx)(z.Ay,{label:"Or a number from 1 to 10",type:"number",min:w.Op,max:w.gX,step:1,inputMode:"numeric",value:i,onChange:e=>l(e.target.value),error:d?void 0:"Use a whole number from 1 to 10."}),(0,x.jsx)(g.A,{size:"lg",variant:"secondary",disabled:!d||c===r&&!o,onClick:()=>u(c),children:"Set"})]}),h.length>1&&(0,x.jsx)("ul",{className:"adv-per-protege","aria-label":"Priority for each prot\xe9g\xe9",children:h.map((e=>{let[s,n]=e;const r=(a.find((e=>e.id===s))||(t.proteges||[]).find((e=>e.id===s))||{}).name||"A prot\xe9g\xe9",o=(0,w.Ix)(null===n||void 0===n?t.priority:n);return(0,x.jsxs)("li",{children:[(0,x.jsx)("span",{children:r}),(0,x.jsx)("span",{children:"".concat((0,w.z7)(o)," ").concat(o)})]},s)}))})]})}function ut(e){let{source:t,onChange:a}=e;if(!be(t))return(0,x.jsxs)("section",{className:"adv-detail__section","aria-labelledby":"adv-d-screen",children:[(0,x.jsx)("h3",{id:"adv-d-screen",className:"adv-detail__h",children:"Shown on screen"}),(0,x.jsx)("p",{className:"adv-detail__p adv-detail__muted",children:"Only videos and audio can be played to a client. This source is used as text."})]});const s="all"===t.client_visible||"some"===t.client_visible;return(0,x.jsxs)("section",{className:"adv-detail__section","aria-labelledby":"adv-d-screen",children:[(0,x.jsx)("h3",{id:"adv-d-screen",className:"adv-detail__h",children:"Shown on screen"}),(0,x.jsx)(m.A,{label:"Let your prot\xe9g\xe9 play moments from this ".concat("video"===t.kind?"video":"recording"," to a client"),description:"some"===t.client_visible?"Some moments are shown today. Turning this off hides all of them, and Undo cannot bring back only some. Turning it on shows all of them, and Undo then hides all of them.":"When this is off, your prot\xe9g\xe9 still learns from it but never plays it.",checked:s,disabled:!t.client_visible,onChange:e=>a({client_visible:e},'"'.concat(t.title,e?'" can be shown on screen.':'" is no longer shown on screen.'))})]})}function ht(e){let{source:t,proteges:a,onChange:s}=e;const n=new Set(t.protege_ids||[]),r=0===n.size;return(0,x.jsxs)("section",{className:"adv-detail__section","aria-labelledby":"adv-d-proteges",children:[(0,x.jsx)("h3",{id:"adv-d-proteges",className:"adv-detail__h",children:"Prot\xe9g\xe9s"}),(0,x.jsx)("p",{className:"adv-detail__p",children:r?"Shared: no prot\xe9g\xe9 is chosen, so it stays in your shared knowledge.":"Which prot\xe9g\xe9s draw on this source."}),0===a.length&&(0,x.jsx)("p",{className:"adv-detail__p adv-detail__muted",children:"You have no prot\xe9g\xe9s yet."}),r&&a.length>1&&(0,x.jsx)("p",{className:"adv-detail__p",id:"adv-d-proteges-shared",children:"Every prot\xe9g\xe9 draws on it today. Checking one means only the prot\xe9g\xe9s you check draw on it; the others stop."}),(0,x.jsx)("div",{role:"group","aria-labelledby":"adv-d-proteges",children:a.map(((e,o)=>(0,x.jsx)(z.tu,(0,b.A)({label:e.name,checked:n.has(e.id),onChange:()=>(e=>{const r=new Set(n),o=!r.has(e.id);o?r.add(e.id):r.delete(e.id);const i=a.filter((e=>r.has(e.id))).map((e=>e.id));s({protege_ids:i},function(e,t,a,s){const n=e.protege_ids||[];return a&&0===n.length&&s.length>1?"Only ".concat(t.name,' will draw on "').concat(e.title,'" now; it was shared with every prot\xe9g\xe9.'):!a&&1===n.length&&n[0]===t.id&&s.length>1?"".concat(t.name,' no longer draws on "').concat(e.title,'" on its own; it is shared with every prot\xe9g\xe9 again.'):a?"".concat(t.name,' now draws on "').concat(e.title,'".'):"".concat(t.name,' no longer draws on "').concat(e.title,'".')}(t,e,o,a))})(e)},0===o&&r&&a.length>1?{hint:"The others stop drawing on it once one is checked."}:{}),e.id)))})]})}function pt(e){let{source:t,replace:a=null,onStart:n,onReset:r}=e;
2const[o,i]=(0,s.useState)(null),[l,c]=(0,s.useState)(""),d=(0,s.useRef)(null),u=a&&!a.error,h=l||a&&a.error||"";return(0,x.jsxs)("section",{className:"adv-detail__section","aria-labelledby":"adv-d-replace",children:[(0,x.jsx)("h3",{id:"adv-d-replace",className:"adv-detail__h",children:"Replace with a new version"}),(0,x.jsx)("input",{ref:d,type:"file",accept:$,onChange:e=>{const t=e.target.files&&e.target.files[0];if(e.target.value="",t){try{ee(t)}catch(s){return void c(s.message)}c(""),a&&a.error&&r&&r(),i(t)}},hidden:!0,"aria-hidden":"true",tabIndex:-1,"data-testid":"replace-file"}),h&&(0,x.jsx)("p",{className:"adv-detail__p teach-row__error",role:"alert",children:h}),!u&&!o&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("p",{className:"adv-detail__p",children:"Upload the new version of this file. Passages that did not change are kept. Its Priority, prot\xe9g\xe9s and Shown on screen carry over."}),(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:()=>d.current&&d.current.click(),children:"Choose the new version"})]}),!u&&o&&(0,x.jsxs)("div",{className:"adv-replace",children:[(0,x.jsxs)("p",{className:"adv-detail__p",children:["New version: ",(0,x.jsx)("span",{className:"adv-file",children:o.name}),o.size?" (".concat((0,w.Xq)(o.size),")"):""]}),(0,x.jsx)("p",{className:"adv-detail__p",children:"Passages that did not change are kept. Its Priority, prot\xe9g\xe9s and Shown on screen carry over, and the old version is removed once the new one is ready."}),(0,x.jsx)("p",{className:"adv-detail__p adv-detail__muted",children:"Nothing changes until you press Replace."}),(0,x.jsxs)("div",{className:"adv-detail__row",children:[(0,x.jsx)(g.A,{size:"lg",variant:"primary",onClick:()=>{c(""),n(o),i(null)},children:"Replace"}),(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>{i(null),c("")},children:"Cancel"})]})]}),u&&(0,x.jsxs)("div",{className:"adv-replace",children:[(0,x.jsxs)("p",{className:"adv-detail__p",children:["Replacing with ",(0,x.jsx)("span",{className:"adv-file",children:a.fileName})]}),(0,x.jsx)(J.A,{percent:Number(a.percent)||0,step:a.jobId?"Reading the new version":"Uploading the new version",startedAt:a.startedAt,label:"Replacing this source"}),(0,x.jsx)("p",{className:"adv-detail__p",style:{marginTop:12},children:"Unchanged passages are kept. The rest are being read now. You can close this; it keeps going, and the list updates when it is done."})]})]})}function gt(e){let{source:t,proteges:a=[],api:s,expertId:n,token:r,toast:o,lastUndo:i=null,onClose:l,onChange:c,onDelete:d,onDismiss:u,onRetry:h,onOpenOriginal:p,replace:m=null,onReplaceStart:y,onReplaceReset:f,cueAt:v=null}=e;if(!t)return null;const _=Pe(t),b=qe(t)&&t.duplicate_of&&t.duplicate_of[0]?t.duplicate_of[0]:null,j=[je(t),Ne(t),t.added_at?"Added ".concat(Re(t)):""].filter(Boolean).join(", "),k=(N=t,"Ready"===(0,w.o7)(N).label);var N;const A="warn"===_.tone,S=i&&!i.done&&i.uris.includes(t.source_uri)?i:null;return(0,x.jsx)(me.A,{open:!0,onClose:l,title:t.title,description:j,initialFocus:"dialog",actions:(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:l,children:"Done"}),children:(0,x.jsxs)("div",{className:"adv-detail",children:[(0,x.jsxs)("section",{className:"adv-detail__section","aria-label":"Status",children:[(0,x.jsx)("div",{className:"adv-detail__row",children:(0,x.jsx)(P.Ay,{tone:_.tone,children:_.label})}),ze(t)&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("p",{className:"adv-detail__p",style:{marginTop:8},children:(0,w.dN)(t.error_message)}),(0,x.jsxs)("div",{className:"adv-detail__row",children:[t.job_id&&(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:()=>h(t),children:"Retry"}),(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>u(t),children:"Dismiss"})]})]}),A&&(0,x.jsxs)("div",{style:{marginTop:12},children:[(0,x.jsx)(J.A,{percent:Number(t.percent_complete)||0,step:be(t)?"Reading the ".concat("video"===t.kind?"video":"recording"," and writing its transcript"):"Reading it",label:"Processing this source"}),(0,x.jsx)("div",{className:"adv-detail__row",style:{marginTop:12},children:(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>u(t),children:"Cancel"})})]}),qe(t)&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("p",{className:"adv-detail__p",style:{marginTop:8},children:b?'This is the same file as "'.concat((0,w.nV)(b),'", which is already in your knowledge, so nothing new was added.'):"This is the same file as one already in your knowledge, so nothing new was added."}),(0,x.jsxs)("div",{className:"adv-detail__row",children:[b&&(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:()=>p(b),children:"Open the original"}),(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>u(t),children:"Remove this copy from the list"})]})]})]}
2),k&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)("section",{className:"adv-detail__section","aria-labelledby":"adv-d-preview",children:[(0,x.jsx)("h3",{id:"adv-d-preview",className:"adv-detail__h",children:"Preview"}),(0,x.jsx)(ct,{source:t,api:s,expertId:n,token:r,cueAt:v})]}),(0,x.jsx)("p",{className:"adv-saverule",style:{margin:0},children:"Priority, Shown on screen and Prot\xe9g\xe9s save as soon as you change them. You can undo each change for 8 seconds."}),(0,x.jsx)("div",{className:"adv-receipt-slot",role:"status","aria-live":"polite",children:S&&(0,x.jsxs)("div",{className:"adv-receipt",children:[(0,x.jsx)("p",{className:"adv-detail__p",style:{margin:0},children:S.text}),(0,x.jsx)(g.A,{size:"md",variant:"secondary",onClick:()=>S.run(),children:"Undo"})]})}),(0,x.jsx)(dt,{source:t,proteges:a,onChange:c},"".concat(t.source_uri,"-").concat(t.priority)),(0,x.jsx)(ut,{source:t,onChange:c}),(0,x.jsx)(ht,{source:t,proteges:a,onChange:c}),Ee(t)&&(0,x.jsx)(pt,{source:t,replace:m,onStart:y,onReset:f}),(0,x.jsxs)("section",{className:"adv-detail__section","aria-labelledby":"adv-d-delete",children:[(0,x.jsx)("h3",{id:"adv-d-delete",className:"adv-detail__h",children:"Delete"}),(0,x.jsx)("p",{className:"adv-detail__p",children:"Your prot\xe9g\xe9s stop drawing on it. You can undo for 8 seconds."}),(0,x.jsx)(g.A,{size:"lg",variant:"destructive",onClick:()=>d(t),children:"Delete this source"})]})]})]})})}function mt(e){let{adv:t,proteges:a=[],expertId:n,token:r,toast:o,onDelete:i,onDismiss:l,onRetry:c,openRequest:d=null,tableless:u=!1,onPanelClose:h=null}=e;const[p,m]=(0,s.useState)(null),[y,f]=(0,s.useState)(null),[v,_]=(0,s.useState)(!1),[j,k]=(0,s.useState)(void 0),N=function(e){let{api:t,token:a,toast:n,onSettled:r}=e;const[o,i]=(0,s.useState)((()=>new Map)),l=(0,s.useRef)(r);(0,s.useEffect)((()=>{l.current=r}),[r]);const c=(0,s.useCallback)(((e,t)=>i((a=>{const s=new Map(a);return null===t?s.delete(e):s.set(e,(0,b.A)((0,b.A)({},a.get(e)||{}),t)),s}))),[]),d=(0,s.useCallback)((async(e,s)=>{const r=e.source_uri;c(r,{fileName:s.name,title:e.title,jobId:null,percent:0,startedAt:Date.now(),error:""});try{const o=await a(),i=await t.replaceSourceUpload({file:s,source:e,token:o});if(!i.jobId)return c(r,null),n&&n.show({text:'Replacing "'.concat(e.title,'". The list updates when it is done.')}),void(l.current&&l.current());c(r,{jobId:i.jobId}),l.current&&l.current()}catch(o){c(r,{error:o.message})}}),[t,c,n,a]),u=(0,s.useCallback)((e=>c(e,null)),[c]),h=Array.from(o.entries()).filter((e=>{let[,t]=e;return t.jobId&&!t.error})).map((e=>{let[t,a]=e;return"".concat(t,"|").concat(a.jobId)})).sort().join(","),p=(0,s.useRef)(o);return(0,s.useEffect)((()=>{p.current=o}),[o]),(0,s.useEffect)((()=>{if(!h)return;let e=!1;const s=async()=>{const s=h.split(",").map((e=>e.split("|")));let r;try{r=await a()}catch(o){return}await Promise.all(s.map((async a=>{let s,[i,d]=a;try{s=await t.fetchJob({jobId:d,token:r})}catch(o){return}if(e)return;const u=p.current.get(i);if(u&&u.jobId===d)if("completed"===s.status){var h;const e=Number(null===(h=s.result_data)||void 0===h?void 0:h.carried_over);n&&n.show({text:Number.isFinite(e)?'Replaced "'.concat(u.title,'". ').concat(e," unchanged ").concat(1===e?"passage was":"passages were"," kept."):'Replaced "'.concat(u.title,'".')}),c(i,null),l.current&&l.current(i)}else if("failed"===s.status||"cancelled"===s.status){const e="The new version did not finish: ".concat((0,w.dN)(s.error_message)," The old version is still in place.");c(i,{error:e}),n&&n.show({text:'"'.concat(u.title,'" was not replaced. The old version is still in place.')}),l.current&&l.current()}else c(i,{percent:Number(s.percent_complete)||0})})))},r=setInterval(s,3e3);return s(),()=>{e=!0,clearInterval(r)}}),[h,t,c,n,a]),{jobs:o,start:d,reset:u}}({api:t.api,token:r,toast:o,onSettled:e=>{e&&m((t=>t&&t.source_uri===e?null:t)),t.reload({quiet:!0})}}),A=t.selected,S=A.length,C=1===S?"source":"sources",I=p?t.rows.find((e=>e.source_uri===p.source_uri))||t.overrideFor&&t.overrideFor(p.source_uri)||p:null;(0,s.useEffect)((()=>{if(void 0===j||p)return;const e=setTimeout((()=>{const e="undefined"!==typeof window&&window.matchMedia&&window.matchMedia("(max-width: 799px)").matches,t=document.querySelector(e?".adv-stack":".adv-table")||document,a=j&&Array.from(t.querySelectorAll("button.adv-name")).find((e=>e.dataset.sourceUri===j))||document.getElementById("adv-count")||document.getElementById("teach-knows-heading");a&&a.focus&&a.focus(),k(void 0)}),0);return()=>clearTimeout(e)}),[j,p]);const T=(0,s.useCallback)((async function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"The original is no longer in your knowledge.",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Could not open the original just now.";const i=t.rows.find((t=>t.source_uri===e));if(i)m(i);else try{const s=await r(),i=await t.api.fetchSourceByUri({expertId:n,sourceUri:e,token:s});i?m(i):o&&o.show({text:a})}catch(l){o&&o.show({text:s})}}),[t.rows,t.api,n,r,o]),P=(0,s.useCallback)((e=>T(e)),[T]);(0,s.useEffect)((()=>{var e;
2d&&d.uri&&(f(null!==(e=d.cueAt)&&void 0!==e?e:null),T(d.uri,"That source is no longer in your knowledge.","Could not open that source just now."))}),[d&&d.nonce]);const q=S>0?(0,x.jsx)(Ge,{count:S,mediaCount:A.filter(be).length,mixedCount:A.filter((e=>e.priority_mixed)).length,someCount:A.filter((e=>"some"===e.client_visible)).length,proteges:a,onClear:t.clearSelection,onPriority:e=>t.change(A,ot(e),"Priority is now ".concat((0,w.z7)(e)," ").concat(e," for ").concat(S," ").concat(C,".")),onOnScreen:e=>{const a=A.filter(be).filter((e=>e.client_visible)),s=S-a.length,n=e?"can now be shown on screen":1===a.length?"is no longer shown on screen":"are no longer shown on screen";t.change(a,{client_visible:e},"".concat(a.length," ").concat(n,".").concat(s?" The others are text and did not change.":""))},onProtege:(e,s)=>{const n=(a.find((t=>t.id===e))||{}).name||"That prot\xe9g\xe9",r=s&&a.length>1?A.filter((e=>!(e.protege_ids||[]).length)).length:0,o=r?" ".concat(r===S?1===S?"It was":"They were":"".concat(r," of them were")," shared with every prot\xe9g\xe9; only ").concat(n," draws on ").concat(1===r?"it":"those"," now."):"";t.change(A,s?{add_protege_ids:[e]}:{remove_protege_ids:[e]},s?"".concat(n," now draws on ").concat(S," more ").concat(C,".").concat(o):"".concat(n," no longer draws on these ").concat(S," ").concat(C,"."))},onDelete:()=>_(!0)}):null;return(0,x.jsxs)(x.Fragment,{children:[t.failure&&(0,x.jsxs)("div",{className:"teach-error adv-failure",role:"alert",children:[(0,x.jsx)("p",{children:t.failure.message}),(0,x.jsxs)("div",{className:"adv-detail__row",children:[t.failure.retry&&(0,x.jsx)(g.A,{size:"lg",variant:"secondary",onClick:()=>t.failure.retry(),children:"Try again"}),(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:t.clearFailure,children:"Close this message"})]})]}),!u&&(0,x.jsx)(Ke,{data:t,proteges:a,onOpen:e=>{f(null),m(e)},bulkBar:q}),I&&(0,x.jsx)(gt,{source:I,proteges:a,api:t.api,expertId:n,token:r,toast:o,lastUndo:t.lastUndo,cueAt:y,onClose:()=>{m(null),f(null),h&&h()},onChange:(e,a)=>t.change([I],e,a),onDelete:e=>{const a=t.rows.findIndex((t=>t.source_uri===e.source_uri)),s=t.rows[a+1]||t.rows[a-1]||null;k(s?s.source_uri:null),m(null);const n=(e.proteges||[]).map((e=>e.name)).filter(Boolean),r=1===n.length?n[0]:"Your prot\xe9g\xe9s";i([e],'Deleted "'.concat(e.title,'". ').concat(r," will stop drawing on it."))},onDismiss:e=>{m(null),l(e)},onRetry:e=>{m(null),c(e)},onOpenOriginal:P,replace:N.jobs.get(I.source_uri)||null,onReplaceStart:e=>N.start(I,e),onReplaceReset:()=>N.reset(I.source_uri)},I.source_uri),(0,x.jsx)(me.T,{open:v,verb:"Delete ".concat(S," ").concat(C),destructive:!0,consequence:"Your prot\xe9g\xe9s stop drawing on ".concat(1===S?"it":"them",". You can undo for 8 seconds after this."),onCancel:()=>_(!1),onConfirm:()=>{_(!1);const e=[...A];t.clearSelection(),i(e,"Deleted ".concat(e.length," ").concat(1===e.length?"source":"sources","."))}})]})}var yt=a(94116);const ft=()=>Y.A.backendProxy,vt=5,wt=2e3,xt="shared";async function _t(e){try{return await e.json()}catch(t){return null}}class bt extends Error{constructor(e){let{status:t=0,kind:a="fault",retryable:s=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e),this.name="ContentSearchError",this.status=t,this.kind=a,this.retryable=s}}function jt(e){let{query:t,as:a,count:s=null,topFixed:n=null,belowCut:r=0}=e;const o={query:String(t||"").trim().slice(0,wt)};return a&&a!==xt?(o.protege_id=a,o.scope="protege"):o.scope="shared_only",null!==s&&void 0!==s&&(o.count=s),null!==n&&void 0!==n&&null!==s&&void 0!==s&&(o.top_fixed=n),r>0&&(o.include_below_cut=!0,o.below_cut_count=r),o}function kt(e,t){const a=Ze(t),s=String(a.message||a.error||"").trim();switch(e){case 400:return new bt((e=>e&&e.length<=140&&!/[{}[\]<>]|Traceback|PGRST|column|relation|_id\b/i.test(e))(s)?"That search was not accepted: ".concat(s.replace(/\.?$/,".")):"That search was not accepted. Try shorter or different words.",{status:e,kind:"invalid"});case 401:return new bt("You are signed out. Sign in again to search what it knows.",{status:e,kind:"auth"});case 403:return new bt("That prot\xe9g\xe9 is not one of yours, so it cannot be searched here. Pick another in Search as.",{status:e,kind:"forbidden"});case 404:return new bt("That prot\xe9g\xe9 is no longer there. Pick another in Search as.",{status:e,kind:"gone"});case 502:return new bt("We could not search just now. Your knowledge is fine;
2 only this search stopped.",{status:e,kind:"upstream",retryable:!0});case 503:return new bt("Search is not available for a moment. Your knowledge is fine; try again shortly.",{status:e,kind:"unavailable",retryable:!0});default:return new bt("Something went wrong with this search. Your knowledge is fine; only this search stopped.",{status:e,kind:"fault",retryable:!0})}}function Nt(e){const t=Number(e&&e.live_call_defaults&&e.live_call_defaults.match_count);return Number.isInteger(t)&&t>0?t:vt}async function At(e){let{protegeId:t,token:a,limit:s=20,request:n=fetch}=e;const r=new URLSearchParams({protege_id:t,limit:String(s)});let o;try{o=await n("".concat(ft(),"/knowledge/recent-questions?").concat(r),{headers:(0,w.Pw)(a)})}catch(l){return{available:!1,reason:"failed"}}const i=await _t(o);if(501===o.status)return{available:!1,reason:"not_yet"};if(!o.ok||!i)return{available:!1,reason:"failed"};return{available:!0,questions:([i.questions,i.items,i.results,i.kb_searches,Array.isArray(i)?i:null].find(Array.isArray)||[]).map(((e,a)=>function(e,t,a){if(!e||"object"!==typeof e)return null;const s=String(e.searched||e.query||e.search_query||"").trim();if(!s)return null;const n=String(e.asked||e.client_question||e.question||"").trim();return{id:String(e.id||e.call_id||"".concat(t,"-").concat(a)),protege_id:e.protege_id||t,asked_at:e.asked_at||e.created_at||null,asked:n||null,searched:s}}(e,t,a))).filter(Boolean)}}const St={searchContent:async function(e){let t,{body:a,token:s,request:n=fetch}=e;try{t=await n("".concat(ft(),"/knowledge/search"),{method:"POST",headers:(0,w.Pw)(s),body:JSON.stringify(a)})}catch(o){throw new bt("We could not reach search just now. Your knowledge is fine; only this search stopped.",{kind:"network",retryable:!0})}const r=await _t(t);if(!t.ok||!r||!1===r.success)throw kt(t.ok?502:t.status,r);if(!Array.isArray(r.results))throw kt(502,r);return(0,b.A)((0,b.A)({},r),{},{below_cut:Array.isArray(r.below_cut)?r.below_cut:[],metadata:r.metadata&&"object"===typeof r.metadata?r.metadata:{}})},fetchRecentForProteges:async function(e){let{protegeIds:t,token:a,limit:s=20,request:n=fetch}=e;if(!t.length)return{available:!1,reason:"none"};const r=await Promise.all(t.map((e=>At({protegeId:e,token:a,limit:s,request:n})))),o=r.filter((e=>e.available));return o.length?{available:!0,questions:o.flatMap((e=>e.questions)).sort(((e,t)=>String(t.asked_at||"").localeCompare(String(e.asked_at||"")))).slice(0,s)}:{available:!1,reason:r.some((e=>"failed"===e.reason))?"failed":"not_yet"}}},Ct=Object.freeze([Object.freeze({min:.75,word:"Strong match"}),Object.freeze({min:.65,word:"Good match"}),Object.freeze({min:-1/0,word:"Weak match"})]);function It(e){const t=Number(e);return(Ct.find((e=>Number.isFinite(t)&&t>=e.min))||Ct[Ct.length-1]).word}const Tt=e=>Number(e).toFixed(2),Pt=new Set("a an and are as at be but by can do does for from how i if in is it its me my of on or our say should so that the their them then there they this to we what when where which who why will with you your would could i'm im get got about take any tips actually have good best".split(" "));function qt(e){return String(e||"").toLowerCase().split(/[^a-z0-9']+/).filter((e=>e.length>=3&&!Pt.has(e)))}function zt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Rt(e,t){if(!t.length)return[{t:e,m:!1}];const a=new RegExp("\\b(?:".concat(t.map(zt).join("|"),")[a-z']*"),"gi"),s=[];let n=0;return e.replace(a,((t,a)=>(a>n&&s.push({t:e.slice(n,a),m:!1}),s.push({t:t,m:!0}),n=a+t.length,t))),n<e.length&&s.push({t:e.slice(n),m:!1}),s}const Et=["first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth"],Dt=e=>Et[e-1]||"number ".concat(e);function Mt(e,t){return e===xt?"Your shared material":(t.find((t=>t.id===e))||{}).name||"Your prot\xe9g\xe9"}function Ft(e,t,a){return"threshold"===e.reason?"Too far in meaning. It is under the cutoff of ".concat(Tt(function(e){const t=e&&e.live_call_defaults,a=Number(t&&void 0!==t.match_threshold?t.match_threshold:e&&e.match_threshold);return Number.isFinite(a)?a:.2}(t)),"."):"priority"===e.reason?"Close on meaning, ".concat(Dt(e.meaning_rank)," on its own, but passages with a higher Priority came first."):"Came ".concat(Dt(a),". Your prot\xe9g\xe9 gets the top ").concat(Nt(t),".")}function Ot(e){let{parts:t}=e;return t.map(((e,t)=>e.m?(0,x.jsx)("mark",{className:"cs-mark",children:e.t},t):(0,x.jsx)(s.Fragment,{children:e.t},t)))}function Wt(e){var t;let{hit:a,rank:n,query:r,source:o,proteges:i,onOpenSource:l,dim:c=!1,reason:d=null}=e;
2const[u,h]=(0,s.useState)(!1),p=o?o.title:(0,w.nV)(a.source_uri,a),m=o?je(o):function(e){const t=(0,w.I)(e);return je({kind:"note"===t?"text":t})}(a),y=void 0!==a.t_start&&null!==a.t_start,f=y?ke(a.t_start):"",v=Boolean(a.media_uri)&&y,{parts:_,trimmed:b}=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:180;const s=qt(t),n=String(e||"");let r=0,o=n;if(n.length>a){const e=s.length?new RegExp("\\b(".concat(s.map(zt).join("|"),")"),"i"):null,t=e?n.search(e):-1;r=t>80?n.lastIndexOf(" ",t-60)+1:0,o=n.slice(r,r+a);const i=o.lastIndexOf(" ");r+a<n.length&&i>.6*a&&(o=o.slice(0,i))}const i=r>0?"...":"",l=r+o.length<n.length?"...":"";return{parts:Rt("".concat(i).concat(o).concat(l),s),trimmed:Boolean(i||l)}}(a.content,r),j=qt(r),k=null!==(t=a.weight)&&void 0!==t?t:5,N=!c&&n&&a.meaning_rank&&a.meaning_rank!==n?a.meaning_rank>n?"up":"down":null,A=function(e,t){if(!e)return"";const a=(e.proteges||[]).map((e=>e.name||(t.find((t=>t.id===e.id))||{}).name)).filter(Boolean);return e.shared||!a.length?(e.protege_ids||[]).length?"":"Shared with every prot\xe9g\xe9":t.length>1&&a.length===t.length?"Assigned to all ".concat(a.length):"Assigned to ".concat(a.join(" and "))}(o,i);return(0,x.jsxs)("li",{className:"cs-hit".concat(c?" cs-hit--dim":""),children:[n?(0,x.jsx)("span",{className:"cs-hit__rank","aria-label":"Passage ".concat(n),children:n}):null,(0,x.jsxs)("div",{className:"cs-hit__main",children:[d&&(0,x.jsx)("p",{className:"cs-hit__reason",children:d}),(0,x.jsx)("p",{className:"cs-hit__text",children:u?(0,x.jsx)(Ot,{parts:Rt(String(a.content||""),j)}):(0,x.jsx)(Ot,{parts:_})}),b&&(0,x.jsx)("button",{type:"button",className:"cs-link","aria-expanded":u,onClick:()=>h((e=>!e)),children:u?"Show less":"Show the whole passage"}),(0,x.jsxs)("div",{className:"cs-hit__meta",children:[a.source_uri?(0,x.jsx)("button",{type:"button",className:"adv-name cs-hit__source",onClick:()=>l({uri:a.source_uri,cueAt:null}),children:p}):(0,x.jsx)("span",{className:"cs-hit__source",children:p}),(0,x.jsxs)("span",{className:"cs-hit__facts",children:[(0,x.jsxs)("span",{children:[m,f?", at ".concat(f):""]}),(0,x.jsx)("span",{children:"Priority ".concat((0,w.z7)(k)," ").concat(k)}),(0,x.jsx)(yt.A,{content:"Similarity ".concat(Tt(a.similarity)," on a scale of 0 to 1: how close this passage is in meaning to the search."),children:(0,x.jsx)("span",{className:"cs-strength",tabIndex:0,children:"".concat(It(a.similarity),", ").concat(Tt(a.similarity))})}),A&&(0,x.jsx)("span",{children:A})]}),(v||a.client_visible)&&(0,x.jsxs)("span",{className:"cs-hit__actions",children:[v&&a.source_uri&&(0,x.jsx)(g.A,{size:"md",variant:"secondary",onClick:()=>l({uri:a.source_uri,cueAt:a.t_start}),children:"Play from ".concat(f)}),a.client_visible&&(0,x.jsx)(P.Ay,{tone:"good",children:"Shown on screen"})]}),N&&(0,x.jsx)("p",{className:"cs-hit__note",children:"Priority moved this ".concat(N,". On meaning alone it would be ").concat(Dt(a.meaning_rank),".")})]})]})]})}function Ut(e){let{label:t}=e;return(0,x.jsxs)("div",{className:"cs-status",role:"status","aria-live":"polite",children:[(0,x.jsx)("p",{className:"cs-line",children:t}),(0,x.jsx)("ul",{className:"cs-list","aria-hidden":"true",children:[0,1,2].map((e=>(0,x.jsx)("li",{className:"cs-hit",children:(0,x.jsxs)("div",{className:"cs-hit__main",children:[(0,x.jsx)(q.E,{height:18,width:"92%"}),(0,x.jsx)(q.E,{height:18,width:"70%",style:{marginTop:10}}),(0,x.jsx)(q.E,{height:16,width:"45%",style:{marginTop:14}})]})},e)))})]})}function Lt(e){let{meta:t}=e;return t&&t.priority_rerank?"on"===t.priority_rerank?(0,x.jsx)("p",{className:"cs-line",children:"Priority re-ranking is on. Meaning comes first, and a higher Priority can lift a passage a little."}):(0,x.jsx)("p",{className:"cs-line",children:"Priority re-ranking is off. Passages come in order of meaning alone."}):null}function Yt(e){let{value:t,onChange:a,proteges:s,id:n}=e;return(0,x.jsxs)(z.Ay,{label:"Search as",as:"select",id:n,value:t,onChange:e=>a(e.target.value),children:[s.map((e=>(0,x.jsx)("option",{value:e.id,children:e.name},e.id))),(0,x.jsx)("option",{value:xt,children:"All shared material"})]})}function Bt(e,t){if(e===xt)return"Only material not assigned to any prot\xe9g\xe9. Every prot\xe9g\xe9 can find it.";const a=Mt(e,t);
2return"".concat(a," finds the material assigned to it and your shared material. Material assigned only to your other prot\xe9g\xe9s is left out.")}function Vt(e){let{response:t,as:a,proteges:s}=e;const n=Mt(a,s);return t.metadata&&0===t.metadata.scope_passages?(0,x.jsxs)("div",{className:"cs-empty",role:"status",children:[(0,x.jsx)("p",{className:"cs-empty__title",children:a===xt?"You have no shared material yet.":"".concat(n," has nothing to search yet.")}),(0,x.jsx)("p",{className:"cs-line",children:a===xt?"Everything you have added is assigned to a prot\xe9g\xe9. Shared material is what every prot\xe9g\xe9 can find.":"Nothing is assigned to it and you have no shared material. Add knowledge, or assign sources to it in What it knows."})]}):(0,x.jsxs)("div",{className:"cs-empty",role:"status",children:[(0,x.jsx)("p",{className:"cs-empty__title",children:"Nothing close enough. Your prot\xe9g\xe9 would say it does not know."}),(0,x.jsx)("p",{className:"cs-line",children:"Try other words, or add knowledge that covers this."})]})}function Jt(e){let{error:t,onRetry:a}=e;const s=t&&t.message||"We could not search just now. Your knowledge is fine; only this search stopped.",n=!t||!1!==t.retryable;return(0,x.jsxs)("div",{className:"teach-error cs-failure",role:"alert",children:[(0,x.jsx)("p",{children:s}),n&&(0,x.jsx)(g.A,{size:"md",variant:"secondary",onClick:a,children:"Try again"})]})}const Ht=e=>{const t=e?new Date(e):null;return t&&!Number.isNaN(t.getTime())?t.toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):""};function Kt(e){let{proteges:t=[],defaultProtegeId:a=null,expertId:n,token:r,onOpenSource:o=()=>{},api:i=it,searchApi:l=St,request:c,initial:d={}}=e;const u=(0,s.useId)(),h=a||xt,[p,m]=(0,s.useState)("why"===d.mode?"why":"search"),y=(0,s.useCallback)((e=>c?(0,b.A)((0,b.A)({},e),{},{request:c}):e),[c]),[f,v]=(0,s.useState)("why"===d.mode?"":d.q||""),[w,_]=(0,s.useState)(d.as||h),[j,k]=(0,s.useState)(vt),[N,A]=(0,s.useState)({status:"idle"}),[S,C]=(0,s.useState)({status:"loading",questions:[]}),[I,T]=(0,s.useState)(""),[P,q]=(0,s.useState)(d.text||""),[R,E]=(0,s.useState)(d.as||h),[D,M]=(0,s.useState)({status:"idle"}),[F,O]=(0,s.useState)((()=>new Map)),W=(0,s.useRef)(new Set),U=(0,s.useRef)(0),Y=(0,s.useRef)(0),B=S.questions,V=B.find((e=>e.id===I))||null,J=(0,s.useCallback)((async e=>{const t=Array.from(new Set(e.map((e=>e.source_uri)).filter(Boolean))).filter((e=>!W.current.has(e)));if(!t.length||!i||!i.fetchSourceByUri)return;let a;t.forEach((e=>W.current.add(e)));try{a=await r()}catch(o){return}const s=await at(t,4,(e=>i.fetchSourceByUri({expertId:n,sourceUri:e,token:a})));O((e=>{const t=new Map(e);return s.forEach((e=>{e.ok?t.set(e.item,e.value||null):W.current.delete(e.item)})),t}))}),[i,n,r]),H=(0,s.useCallback)((async e=>{const t=await r();return l.searchContent(y({body:e,token:t}))}),[l,r,y]),K=(0,s.useCallback)((async(e,t,a,s)=>{const n=++U.current;A((n=>({status:"searching",q:t,as:a,body:e,count:s,previous:"ready"===n.status&&n.q===t&&n.as===a?n.response:null})));try{const r=await H(e);if(n!==U.current)return;A({status:"ready",q:t,as:a,body:e,count:s,response:r}),J(r.results)}catch(r){n===U.current&&A({status:"error",q:t,as:a,body:e,count:s,error:r})}}),[H,J]),G=(0,s.useCallback)((async(e,t,a)=>{const s=++Y.current;M({status:"searching",q:e,as:t,fromSession:a});try{const n=await H(jt({query:e,as:t,belowCut:3}));if(s!==Y.current)return;M({status:"ready",q:e,as:t,fromSession:a,response:n}),J([...n.results,...n.below_cut])}catch(n){s===Y.current&&M({status:"error",q:e,as:t,fromSession:a,error:n})}}),[H,J]);(0,s.useEffect)((()=>{let e=!0;const s=a?[a]:t.map((e=>e.id));return(async()=>{let t;try{t=await r()}catch(n){return void(e&&C({status:"unavailable",reason:"failed",questions:[]}))}const a=await l.fetchRecentForProteges(y({protegeIds:s,token:t}));e&&C(a.available?{status:"ready",questions:a.questions}:{status:"unavailable",reason:a.reason,questions:[]})})(),()=>{e=!1}}),[a,t.map((e=>e.id)).join(","),l,r]),(0,s.useEffect)((()=>{if("why"===d.mode&&d.text)G(d.text,d.as||h,null);else if("why"!==d.mode&&d.q){const e=d.as||h;K(jt({query:d.q,as:e}),d.q,e,vt)}}),[]);const X="ready"===N.status?Nt(N.response.metadata):vt,$="ready"===N.status?N.response.results:[],Z="ready"===N.status&&Number(N.response.metadata.top_fixed)||X,Q="ready"===N.status&&$.length>=j&&j<20,ee=Mt(D.as,t),te="ready"===S.status&&B.length>0,ae=Mt(N.as,t);return(0,x.jsxs)("section",{className:"teach-section cs","aria-labelledby":"".concat(u,"-h"),children:[(0,x.jsx)("div",{className:"teach-section__head",children:(0,x.jsxs)("div",{children:[(0,x.jsx)("h2",{id:"".concat(u,"-h"),className:"teach-section__title",children:"Search what it knows"}),(0,x.jsx)("p",{className:"teach-section__lead",children:"Finds passages by meaning, the same way your prot\xe9g\xe9 does during a call."})]})}),(0,x.jsx)("div",{className:"cs-box",children:(0,x.jsxs)(L.A,{value:p,onChange:m,"aria-label":"Search what it knows",children:[(0,x.jsxs)(L.A.List,{children:[(0,x.jsx)(L.A.Trigger,{value:"search",children:"Search"}),(0,x.jsx)(L.A.Trigger,{value:"why",children:"Why this answer?"})]}),(0,x.jsxs)(L.A.Panel,{value:"search",children:[(0,x.jsxs)("form",{className:"cs-form",onSubmit:e=>{e.preventDefault();const t=f.trim();t&&(k(vt),K(jt({query:t,as:w}),t,w,vt))},role:"search","aria-label":"Search what it knows",children:[(0,x.jsx)(z.Ay,{label:"What to look for",type:"search",id:"".concat(u,"-q"),value:f,maxLength:wt,placeholder:"For example: how long should the ask take",onChange:e=>v(e.target.value)}),(0,x.jsx)(Yt,{id:"".concat(u,"-as"),value:w,onChange:_,proteges:t}),(0,x.jsx)("div",{className:"cs-form__go",children:(0,x.jsx)(g.A,{type:"submit",size:"md",variant:"primary",disabled:!f.trim(),loading:"searching"===N.status,children:"Search"})})]}),(0,x.jsx)("p",{className:"cs-line cs-note",children:Bt(w,t)}),(0,x.jsxs)("div",{className:"cs-results","aria-live":"polite",children:["idle"===N.status&&(0,x.jsxs)("div",{className:"cs-empty",children:[(0,x.jsx)("p",{className:"cs-empty__title",children:"See what your prot\xe9g\xe9 would find."}),(0,x.jsx)("p",{className:"cs-line",children:"Type a question the way a client would ask it. You get the passages it would draw on, closest in meaning first, with the source of each one."})]}),"searching"===N.status&&(0,x.jsx)(Ut,{label:"Searching what ".concat(ae," knows")}),"error"===N.status&&(0,x.jsx)(Jt,{error:N.error,onRetry:()=>K(N.body,N.q,N.as,N.count)}
2),"ready"===N.status&&!$.length&&(0,x.jsx)(Vt,{response:N.response,as:N.as,proteges:t}),"ready"===N.status&&$.length>0&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)("p",{className:"cs-line cs-count",children:[(0,x.jsx)("strong",{children:1===$.length?"1 passage":"".concat($.length," passages")})," ".concat(N.as===xt?"in your shared material":"".concat(ae," would find"),' for "').concat(N.q,'", closest in meaning first.')]}),(0,x.jsx)(Lt,{meta:N.response.metadata}),(0,x.jsx)("p",{className:"cs-line cs-muted",children:"During a call your prot\xe9g\xe9 gets the top ".concat(X,".")}),(0,x.jsx)("ol",{className:"cs-list",children:$.map(((e,a)=>(0,x.jsxs)(s.Fragment,{children:[a===Z&&a>0&&(0,x.jsx)("li",{className:"cs-cut","aria-hidden":"true",children:(0,x.jsx)("span",{children:"Past the top ".concat(Z,": your prot\xe9g\xe9 would not get these during a call")})}),(0,x.jsx)(Wt,{hit:e,query:N.q,source:F.get(e.source_uri),proteges:t,onOpenSource:o})]},e.id||a)))}),$.length>Z&&(0,x.jsx)("p",{className:"sr-only",children:"Passages after number ".concat(Z," are past the top ").concat(Z,": your prot\xe9g\xe9 would not get them during a call.")}),Q&&(0,x.jsx)(g.A,{size:"md",variant:"secondary",onClick:()=>{const e=function(e){let{query:t,as:a,shown:s,callCount:n=vt}=e;return jt({query:t,as:a,count:Math.min(20,s+5),topFixed:n})}({query:N.q,as:N.as,shown:j,callCount:X});k(e.count),K(e,N.q,N.as,e.count)},children:"Show 5 more"}),!Q&&j>=20&&(0,x.jsx)("p",{className:"cs-line cs-muted",children:"That is the closest ".concat(20,". Search again with other words to see different passages.")})]})]})]}),(0,x.jsxs)(L.A.Panel,{value:"why",children:[(0,x.jsx)("p",{className:"cs-line cs-intro",children:"See the passages your prot\xe9g\xe9 gets for a question, in the order it gets them, and the ones it just misses."}),(0,x.jsxs)("form",{className:"cs-why",onSubmit:e=>{e.preventDefault(),V?G(V.searched,V.protege_id,V):P.trim()&&G(P.trim(),R,null)},"aria-label":"Why this answer?",children:[te&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(z.Ay,{label:"Pick a question from a recent session",as:"select",id:"".concat(u,"-recent"),value:I,onChange:e=>(e=>{T(e);const t=B.find((t=>t.id===e));t&&(q(""),E(t.protege_id))})(e.target.value),children:[(0,x.jsx)("option",{value:"",children:"Choose a question"}),B.map((e=>(0,x.jsx)("option",{value:e.id,children:"".concat([Ht(e.asked_at),Mt(e.protege_id,t)].filter(Boolean).join(", "),": ").concat(e.asked||e.searched)},e.id)))]}),(0,x.jsx)("p",{className:"cs-or",children:"or"})]}),"unavailable"===S.status&&(0,x.jsx)("p",{className:"cs-line cs-muted",children:"failed"===S.reason?"We could not load questions from recent sessions, so paste one a client asked.":"Questions from recent sessions are not available here yet, so paste one a client asked."}),(0,x.jsx)(z.Ay,{label:"Paste a question a client asked",as:"textarea",id:"".concat(u,"-text"),rows:3,maxLength:wt,value:P,onChange:e=>{q(e.target.value),e.target.value&&T("")}}),!V&&(0,x.jsx)(Yt,{id:"".concat(u,"-why-as"),value:R,onChange:E,proteges:t}),(0,x.jsx)("div",{children:(0,x.jsx)(g.A,{type:"submit",size:"md",variant:"primary",disabled:!V&&!P.trim(),loading:"searching"===D.status,children:"Show what it would find"})})]}),(0,x.jsxs)("div",{className:"cs-results","aria-live":"polite",children:["idle"===D.status&&(0,x.jsxs)("div",{className:"cs-empty",children:[(0,x.jsx)("p",{className:"cs-empty__title",children:"Why did it answer that?"}),(0,x.jsx)("p",{className:"cs-line",children:te?"Pick a question from a session, or paste one. You see what the same search finds in what your prot\xe9g\xe9 knows now.":"Paste a question a client asked. You see the passages your prot\xe9g\xe9 would have in front of it when it answers."})]}),"idle"!==D.status&&(0,x.jsx)("div",{className:"cs-asked",children:D.fromSession?(0,x.jsxs)(x.Fragment,{children:[D.fromSession.asked&&(0,x.jsxs)("p",{className:"cs-line",children:[(0,x.jsx)("span",{className:"cs-k",children:"The client asked"}),' "'.concat(D.fromSession.asked,'"')]}),(0,x.jsxs)("p",{className:"cs-line",children:[(0,x.jsx)("span",{className:"cs-k",children:"".concat(ee," searched for")}),' "'.concat(D.fromSession.searched,'"')]})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)("p",{className:"cs-line",children:[(0,x.jsxs)("span",{className:"cs-k",children:["Searched as ",ee," for"]}),' "'.concat(D.q,'"')]}),(0,x.jsx)("p",{className:"cs-line cs-muted",children:"During a call your prot\xe9g\xe9 picks its own search words, so a call can bring back slightly different passages."})]})}),"searching"===D.status&&(0,x.jsx)(Ut,{label:"Finding what ".concat(ee," would get")}),"error"===D.status&&(0,x.jsx)(Jt,{error:D.error,onRetry:()=>G(D.q,D.as,D.fromSession)}),"ready"===D.status&&(0,x.jsxs)(x.Fragment,{children:[D.response.results.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("h3",{className:"cs-
2h",children:"What ".concat(ee," gets, in order")}),(0,x.jsx)(Lt,{meta:D.response.metadata}),(0,x.jsx)("ol",{className:"cs-list",children:D.response.results.map(((e,a)=>(0,x.jsx)(Wt,{hit:e,rank:a+1,query:D.q,source:F.get(e.source_uri),proteges:t,onOpenSource:o},e.id||a)))})]}):(0,x.jsx)(Vt,{response:D.response,as:D.as,proteges:t}),D.response.below_cut.length>0&&(0,x.jsxs)("div",{className:"cs-missed",children:[(0,x.jsx)("h3",{className:"cs-h",children:"Close, but not seen"}),(0,x.jsx)("p",{className:"cs-line",children:"Your prot\xe9g\xe9 would not see these."}),(0,x.jsx)("ul",{className:"cs-list",children:D.response.below_cut.map(((e,a)=>(0,x.jsx)(Wt,{hit:e,dim:!0,query:D.q,source:F.get(e.source_uri),proteges:t,onOpenSource:o,reason:Ft(e,D.response.metadata,D.response.results.length+a+1)},e.id||a)))})]})]})]})]})]})})]})}const Gt="teach.advancedView";function Xt(){try{return"1"===window.localStorage.getItem(Gt)}catch(e){return!1}}function $t(e){let{expertId:t,protegeId:a=null,token:n,proteges:r=[],hidden:o=new Set,toast:i,api:l=it,enabled:c=!0}=e;
2const[d,u]=(0,s.useState)(Ue),[h,p]=(0,s.useState)(Ue),[g,m]=(0,s.useState)({rows:[],total:0}),[y,f]=(0,s.useState)(null),[v,w]=(0,s.useState)("loading"),[x,_]=(0,s.useState)(null),[j,k]=(0,s.useState)((()=>new Map)),[N,A]=(0,s.useState)((()=>new Map)),[S,C]=(0,s.useState)(null),[I,T]=(0,s.useState)(null),P=(0,s.useRef)(0),q=(0,s.useRef)(null),z=(0,s.useRef)(0),R=(0,s.useRef)(null),E=(0,s.useRef)(Ue);(0,s.useEffect)((()=>{E.current=(0,b.A)((0,b.A)({},E.current),{},{offset:0}),u(E.current),p(E.current),A(new Map),k(new Map)}),[a]);const D=(0,s.useCallback)((e=>{const t=function(e,t){const a=Object.keys(t).every((e=>"offset"===e)),s=(0,b.A)((0,b.A)({},e),t);return a||void 0!==t.offset||(s.offset=0),void 0!==t.limit&&t.limit!==e.limit&&(s.offset=0),s}(E.current,e);(function(e){return Object.keys(e).every((e=>"offset"===e))})(e)||A((e=>e.size?new Map:e)),E.current=t,u(t),clearTimeout(R.current),1===Object.keys(e).length&&void 0!==e.q?R.current=setTimeout((()=>p(t)),300):p(t)}),[]);(0,s.useEffect)((()=>()=>{clearTimeout(R.current),clearTimeout(q.current)}),[]);const M=(0,s.useCallback)((async function(){let{quiet:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!c||!t)return;const s=++z.current;e||(w("loading"),_(null));try{var r;const e=await n(),o=await l.fetchSourcesPage({expertId:t,protegeId:a,query:h,token:e});if(s!==z.current)return;m({rows:o.sources,total:o.total}),f(null!==(r=o.unfilteredTotal)&&void 0!==r?r:o.total),k(new Map),w("ready")}catch(o){if(s!==z.current)return;if(e)return;_(o.message||"We could not load your sources just now. Nothing was changed."),w("error")}}),[l,c,t,a,h,n]);(0,s.useEffect)((()=>{M()}),[M]);const F=(0,s.useMemo)((()=>g.rows.filter((e=>!o.has(e.source_uri))).map((e=>j.get(e.source_uri)||e))),[g.rows,o,j]),O=g.rows.length-F.length,W=Math.max(0,g.total-O),U=(0,s.useCallback)(((e,t)=>{A((a=>{const s=new Map(a);return e.forEach((e=>t?s.set(e.source_uri,e):s.delete(e.source_uri))),s}))}),[]),L=(0,s.useCallback)((()=>A(new Map)),[]),Y=(0,s.useMemo)((()=>Array.from(N.values()).filter((e=>!o.has(e.source_uri))).map((e=>j.get(e.source_uri)||F.find((t=>t.source_uri===e.source_uri))||e))),[N,o,j,F]),B=(0,s.useCallback)((e=>{k((t=>{const a=new Map(t);return e.forEach((e=>a.set(e.source_uri,e))),a})),A((t=>{if(!e.some((e=>t.has(e.source_uri))))return t;const a=new Map(t);return e.forEach((e=>{a.has(e.source_uri)&&a.set(e.source_uri,e)})),a}))}),[]),V=(0,s.useCallback)((async(e,t)=>{const a=await n();return l.patchSources({selector:e,changes:t,token:a})}),[l,n]),J=(0,s.useCallback)((async function(e,t,a){let{selector:s}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!e.length)return!1;const n=e.map((e=>j.get(e.source_uri)||e)),o=s||(1===n.length?{source_uri:n[0].source_uri}:{source_uris:n.map((e=>e.source_uri))});C(null),B(n.map((e=>function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const s=(0,b.A)({},e),n=e=>(a.find((t=>t.id===e))||{}).name||null;let r=Array.isArray(e.protege_ids)?[...e.protege_ids]:[];const o=new Set(r);Array.isArray(t.protege_ids)&&(r=[...t.protege_ids]),Array.isArray(t.add_protege_ids)&&t.add_protege_ids.forEach((e=>{r.includes(e)||r.push(e)})),Array.isArray(t.remove_protege_ids)&&(r=r.filter((e=>!t.remove_protege_ids.includes(e))));const i={};return r.forEach((a=>{var s;let n=o.has(a)?(e.protege_priorities||{})[a]:null!==(s=t.priority)&&void 0!==s?s:null;void 0===n&&(n=null),"number"===typeof t.protege_priority?n=t.protege_priority:t.protege_priority&&"object"===typeof t.protege_priority&&void 0!==t.protege_priority[a]&&(n=t.protege_priority[a]),i[a]=n})),s.protege_ids=r,s.proteges=r.map((t=>({id:t,name:n(t)||((e.proteges||[]).find((e=>e.id===t))||{}).name||null}))),s.protege_priorities=i,s.shared=0===r.length,void 0!==t.priority&&null!==t.priority&&(s.priority=t.priority,s.priority_mixed=!1),"boolean"!==typeof t.client_visible||"video"!==e.kind&&"audio"!==e.kind||!e.client_visible||(s.client_visible=t.client_visible?"all":"none"),s}(e,t,r))));try{await V(o,t)}catch(u){B(n);const r="partial"===u.kind?()=>J(e,t,a,{selector:s}):null;return C({message:u.message,kind:u.kind,retry:r}),"partial"!==u.kind&&"gone"!==u.kind||M({quiet:!0}),!1}const l=function(e,t){const a=[],s=e=>null!==e&&void 0!==e&&Number.isFinite(Number(e));void 0!==t.priority&&null!==t.priority&&nt(e,(e=>{if(!s(e.priority))return null;const t={};
2return(e.protege_ids||[]).forEach((a=>{const n=(e.protege_priorities||{})[a];t[a]=st(s(n)?n:e.priority)})),JSON.stringify({priority:st(e.priority),pp:t})})).forEach(((e,t)=>{const{priority:s,pp:n}=JSON.parse(t);a.push({selector:tt(e.map((e=>e.source_uri))),changes:(0,b.A)({priority:s},Object.keys(n).length?{protege_priority:n}:{})})}));"boolean"===typeof t.client_visible&&nt(e.filter((e=>e.client_visible)),(e=>"all"===e.client_visible?"true":"false")).forEach(((e,s)=>{"true"===s!==t.client_visible&&a.push({selector:tt(e.map((e=>e.source_uri))),changes:{client_visible:"true"===s}})}));return Array.isArray(t.protege_ids)&&e.forEach((e=>{const t={};(e.protege_ids||[]).forEach((a=>{const n=(e.protege_priorities||{})[a];s(n)&&(t[a]=st(n))})),a.push({selector:{source_uri:e.source_uri},changes:(0,b.A)({protege_ids:[...e.protege_ids||[]]},Object.keys(t).length?{protege_priority:t}:{})})})),Array.isArray(t.add_protege_ids)&&t.add_protege_ids.forEach((t=>{const s=e.filter((e=>!(e.protege_ids||[]).includes(t)));s.length&&a.push({selector:tt(s.map((e=>e.source_uri))),changes:{remove_protege_ids:[t]}})})),Array.isArray(t.remove_protege_ids)&&t.remove_protege_ids.forEach((t=>{nt(e.filter((e=>(e.protege_ids||[]).includes(t))),(e=>{const a=(e.protege_priorities||{})[t];return String(st(s(a)?a:s(e.priority)?e.priority:5))})).forEach(((e,s)=>{a.push({selector:tt(e.map((e=>e.source_uri))),changes:{add_protege_ids:[t],protege_priority:{[t]:Number(s)}}})}))})),a}(n,t);if(!l.length){const e="boolean"===typeof t.client_visible&&n.some((e=>"some"===e.client_visible));return i&&i.show({text:e?"".concat(a," This cannot be undone here: only some moments were shown before."):a}),!0}const c=++P.current,d={id:c,text:a,uris:n.map((e=>e.source_uri)),done:!1,toastId:null,run:async()=>{if(!d.done){d.done=!0,clearTimeout(q.current),T((e=>e&&e.id===c?null:e)),i&&d.toastId&&i.dismiss&&i.dismiss(d.toastId),B(n);try{for(const e of l)await V(e.selector,e.changes);i&&i.show({text:rt(n,t)}),M({quiet:!0})}catch(u){C({message:"Could not undo that. ".concat(u.message),kind:u.kind,retry:null}),M({quiet:!0})}}}};return i&&(d.toastId=i.show({text:a,onUndo:()=>d.run()})),clearTimeout(q.current),T(d),q.current=setTimeout((()=>{d.done=!0,T((e=>e&&e.id===c?null:e))}),8e3),!0}),[j,r,B,V,i,M]);return{query:d,setQuery:D,rows:F,total:W,grandTotal:null===y?W:Math.max(0,y-O),state:v,loadError:x,reload:M,selection:N,selected:Y,select:U,clearSelection:L,change:J,failure:S,lastUndo:I,clearFailure:()=>C(null),overrideFor:e=>j.get(e)||null,api:l}}function Zt(){var e;const{protegeSlug:t=null}=(0,d.g)(),a=(0,d.Zp)(),n=(0,l.dj)(),o=(0,w.Ay)({protegeSlug:t}),{proteges:i,protege:h,protegeId:b,unknownSlug:j,expertSlug:k,sources:N,sourcesLoading:A,sourcesError:S,feeds:C,refreshSources:I,remove:T,dismiss:P,retry:q,gaps:z,gapsLoading:R,gapsError:E,refreshGaps:D,apply:M,analyze:O,follow:W,token:U,publishState:L,publishMissing:Y,refetchPublishState:B,publish:V,pollJob:J}=o,H=(null===h||void 0===h?void 0:h.name)||"";(0,y.A)((0,f.xT)(H));const[K,G]=(0,s.useState)(null),[X,$]=(0,s.useState)((()=>
2new Set)),[Z,Q]=(0,s.useState)(""),[ee,te]=(0,s.useState)(!1),[ae,se]=(0,s.useState)(null),[ne,re]=(0,s.useState)(!1),[oe,ie]=(0,s.useState)(Xt),le=(0,s.useRef)(new Map),ce=(0,s.useRef)(null);(0,s.useEffect)((()=>{re(!1)}),[b]);const ue=(0,s.useCallback)((function(){let{focus:e=!0,scroll:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const a=ce.current;if(!a)return;if(t&&a.scrollIntoView&&a.scrollIntoView({behavior:"smooth",block:"start"}),!e)return;const s=a.querySelector('[role="tab"][aria-selected="true"]')||a.querySelector('[role="tab"]');s&&s.focus&&s.focus({preventScroll:t})}),[]),pe=(0,s.useCallback)((e=>{a(e&&e.protege_slug?"/knowledge/".concat(e.protege_slug):"/knowledge")}),[a]),me=$t({expertId:o.expertId,protegeId:b,token:U,proteges:i,hidden:X,toast:n,enabled:oe}),ye=me.reload,[fe,ve]=(0,s.useState)(null),we=(0,s.useCallback)((e=>{let{uri:t,cueAt:a=null}=e;return ve({uri:t,cueAt:a,nonce:Date.now()})}),[]),xe=(0,s.useCallback)((async(e,t)=>{let{perform:a,text:s,failure:r,receipt:o}=t;const i=e.map((e=>e.source_uri));$((e=>{const t=new Set(e);return i.forEach((e=>t.add(e))),t}));const l=e=>$((t=>{const a=new Set(t);return(e||i).forEach((e=>a.delete(e))),a})),c=await U(),d=setTimeout((async()=>{i.forEach((e=>le.current.delete(e)));const t=await at(e,4,(e=>a(e,{token:c}))),s=t.filter((e=>!e.ok));if(1===e.length&&t[0].ok){const e=o?o(t[0].value):"";e&&n.show({text:e})}var d;s.length&&(l(s.map((e=>e.item.source_uri))),Q(1===e.length?(null===(d=s[0].error)||void 0===d?void 0:d.message)||r:"".concat(s.length," of ").concat(e.length," could not be deleted. They are back in the list; try them again.")));I({quiet:!0}),ye({quiet:!0})}),8e3);e.forEach((e=>le.current.set(e.source_uri,{timer:d,source:e,token:c,perform:a}))),n.show({text:s,onUndo:()=>{clearTimeout(d),i.forEach((e=>le.current.delete(e))),l()}})}),[I,ye,n,U]),_e=(0,s.useCallback)(((e,t)=>xe([e],t)),[xe]),be=(0,s.useCallback)((e=>_e(e,{perform:T,text:'Removed "'.concat(e.title,'". ').concat(H||"Your ".concat(c.Do)," will stop drawing on it."),failure:"Could not remove it. Nothing was changed."})),[_e,T,H]),je=(0,s.useCallback)((e=>_e(e,{perform:P,text:(0,w.S5)(e)?'Stopped "'.concat(e.title,'".'):'Dismissed "'.concat(e.title,'".'),failure:(0,w.S5)(e)?"Could not stop it. It is still running.":"Could not dismiss it. Nothing was changed.",receipt:t=>"cancelled"===(null===t||void 0===t?void 0:t.status)?'Stopped "'.concat(e.title,'". Nothing was added.'):"dism
2issed"===(null===t||void 0===t?void 0:t.status)?'Dismissed "'.concat(e.title,'". It is off the list.'):""})),[_e,P]),ke=(0,s.useCallback)((()=>{const e=Array.from(le.current.values());le.current.clear(),e.forEach((e=>{let{timer:t,source:a,token:s,perform:n}=e;clearTimeout(t),n(a,{keepalive:!0,token:s}).catch((()=>{}))}))}),[]);(0,s.useEffect)((()=>(window.addEventListener("pagehide",ke),()=>{window.removeEventListener("pagehide",ke),ke()})),[ke]);const Ne=(0,s.useCallback)((async e=>{Q("");try{const s=await q(e.job_id);if(s.ok)n.show({text:'Started again on "'.concat(e.title,'".')}),I({quiet:!0}),ye({quiet:!0});else if(s.finished)n.show({text:'"'.concat(e.title,'" finished on its own.')}),I({quiet:!0}),ye({quiet:!0});else if(s.addAgain)Q('"'.concat(e.title,'" has to be added again from scratch. Add knowledge above is ready for it.')),ue({scroll:!0});else{var t,a;Q((null===(t=s.data)||void 0===t?void 0:t.error)||(null===(a=s.data)||void 0===a?void 0:a.message)||'Could not start "'.concat(e.title,'" again. Add it again above.'))}}catch(s){Q((null===s||void 0===s?void 0:s.message)||"Could not start it again. Add it again above.")}}),[q,I,ye,n,ue]),Ae=(0,s.useCallback)((e=>{Q('Add "'.concat(e.title,'" again above.')),ue({scroll:!0})}),[ue]),Se=(0,s.useCallback)((e=>{var t;G({key:Date.now(),title:e.title||"",quote:(null===(t=e.source_evidence)||void 0===t?void 0:t.quote)||e.description||"",suggestionId:e.id}),ue({focus:!1,scroll:!0})}),[ue]),Ce=(0,s.useCallback)((async(e,t)=>{if(null!==e&&void 0!==e&&e.suggestionId){var a;const s=(null===t||void 0===t?void 0:t.knowledge_entry_id)||e.knowledgeEntryId||null,n=(null===t||void 0===t||null===(a=t.result_data)||void 0===a?void 0:a.source_uri)||(null===t||void 0===t?void 0:t.source_uri)||null,r=s||n?{kb_entry_id:s,source_uri:n}:null;await M(e.suggestionId,r)}I({quiet:!0}),ye({quiet:!0}),B()}),[M,I,ye,B]),Ie=(0,s.useCallback)((async()=>{te(!0),se(null);try{await O()}catch(e){se((null===e||void 0===e?void 0:e.message)||"Could not look for gaps right now.")}finally{te(!1)}}),[O]),Te=N.filter((e=>!X.has(e.source_uri)));let Pe=null;oe?"ready"===me.state&&(Pe=me.grandTotal):A||S||(Pe=Te.length);const qe=(0,s.useCallback)(((e,t)=>xe(e,{perform:T,text:t,failure:"Could not delete it. Nothing was changed."})),[xe,T]),ze=H?"Teach ".concat(H):"Knowledge",Re=h&&k&&h.protege_slug?"/expert/".concat(k,"/protege/").concat(h.protege_slug,"#talk"):null,Ee=h||1!==i.length?null:i[0],De=Ee&&k&&Ee.protege_slug?"/expert/".concat(k,"/protege/").concat(Ee.protege_slug,"#talk"):null;return(0,x.jsx)(r.Ay,{className:"min-h-screen",children:(0,x.jsxs)("main",{className:"".concat(oe?"max-w-7xl":"max-w-5xl"," mx-auto px-4 py-ds-12"),children:[(0,x.jsxs)("header",{className:"teach-head",children:[(0,x.jsxs)("div",{className:"teach-head__title",children:[(0,x.jsx)("p",{className:"ds-page__eyebrow",children:"Knowledge"}),(0,x.jsx)("h1",{className:"ds-page__title",children:ze}),(0,x.jsx)("p",{className:"ds-page__lead",children:H?"What ".concat(H," knows, what to add next, and what it could not answer."):"What your ".concat(c.Do," knows, what to add next, and what it could not answer.")})]}),(0,x.jsxs)("div",{className:"teach-head__side",children:[(0,x.jsx)(_,{proteges:i,value:b,onChange:pe}),(0,x.jsx)(g.A,{size:"lg",variant:L&&!Y&&(null!==(e=L.is_dirty)&&void 0!==e?e:Boolean(L.knowledge_dirty_at))?"secondary":"primary",onClick:()=>ue(),leadingIcon:(0,x.jsx)(u.A,{size:18,"aria-hidden":"true"}),children:"Add knowledge"})]})]}),j&&(0,x.jsxs)("p",{className:"teach-notice",role:"status",children:["No ",c.Do," has that address. Showing shared knowledge instead."]}),Z&&(0,x.jsx)("p",{className:"teach-notice",role:"status",children:Z}),h&&(0,x.jsx)(ge,{name:H,state:L,missing:Y,onPublish:V,pollJob:J,onRefetch:B},b),(0,x.jsxs)("section",{className:"teach-section","aria-labelledby":"teach-add-heading",ref:ce,children:[(0,x.jsx)("div",{className:"teach-section__head",children:(0,x.jsx)("h2",{id:"teach-add-heading",className:"teach-section__title",children:"Add knowledge"})}),(0,x.jsx)(de,{protegeId:b,protegeName:H,protegeSlug:null===h||void 0===h?void 0:h.protege_slug,expertSlug:k,prefill:K,onAdded:Ce,onFollow:W})]}),(0,x.jsxs)("section",{className:"teach-section","aria-labelledby":"teach-gaps-heading",children:[(0,x.jsxs)("div",{className:"teach-section__head",children:[(0,x.jsxs)("div",{children:[(0,x.jsx)("h2",{id:"teach-gaps-heading",className:"teach-section__title",children:"What it could not answer"}),(0,x.jsxs)("p",{className:"teach-section__lead",children:["Questions from sessions that ",H||"your ".concat(c.Do)," had nothing to say about."]})]}),h&&h.active_version_id&&(0,x.jsx)(g.A,{size:"lg",variant:"ghost","aria-expanded":ne,"aria-controls":"teach-feedback",onClick:()=>re((e=>!e)),children:ne?"Hide feedback":"Give feedback on how it answers"})]}),(0,x.jsx)(he,{gaps:z,loading:R,error:E,onTeach:Se,onAnalyze:Ie,analyzing:ee,analyzeError:ae,canAnalyze:Boolean(null===h||void 0===h?void 0:h.active_version_id),onRefresh:D}),ne&&h&&(0,x.jsx)("div",{id:"teach-feedback",style:{marginTop:20},children:(0,x.jsx)(v.Ay,{expertId:o.expertId,protegeId:h.id,protegeName:h.name,activeVersionId:h.active_version_id})})]}),(0,x.jsx)(Kt,{proteges:i,defaultProtegeId:b,expertId:o.expertId,token:U,api:me.api,onOpenSource:we},"search-".concat(b||"all")),(0,x.jsxs)("section",{className:"teach-section","aria-labelledby":"teach-knows-heading",children:[(0,x.jsxs)("div",{className:"teach-section__head",children:[(0,x.jsxs)("div",{children:[(0,x.jsx)("h2",{id:"teach-knows-heading",className:"teach-section__title",tabIndex:-1,
2children:"What it knows"}),null!==Pe&&(0,x.jsx)("p",{className:"teach-section__lead",children:"".concat(Pe.toLocaleString()," ").concat(1===Pe?"source":"sources")})]}),(0,x.jsx)(g.A,{size:"lg",variant:"ghost",onClick:()=>oe?me.reload():I(),children:"Refresh"})]}),(0,x.jsx)("div",{className:"adv-advanced-toggle",children:(0,x.jsx)(m.A,{label:"Advanced view",description:"A table of every source, to sort, filter and change many at once. This browser remembers your choice.",checked:oe,onChange:e=>{ie(e),function(e){try{window.localStorage.setItem(Gt,e?"1":"0")}catch(t){}}(e)}})}),!oe&&(0,x.jsx)(F,{sources:Te,feeds:C,loading:A,error:S,protegeName:H,scopeIsProtege:Boolean(b),onRemove:be,onDismiss:je,onRetry:Ne,onAddAgain:Ae,onRefresh:()=>I()}),(0,x.jsx)(mt,{adv:me,proteges:i,expertId:o.expertId,token:U,toast:n,onDelete:qe,onDismiss:je,onRetry:Ne,openRequest:fe,tableless:!oe,onPanelClose:oe?null:()=>I({quiet:!0})})]}),(0,x.jsxs)("section",{className:"teach-section","aria-labelledby":"teach-try-heading",children:[(0,x.jsx)("div",{className:"teach-section__head",children:(0,x.jsxs)("div",{children:[(0,x.jsx)("h2",{id:"teach-try-heading",className:"teach-section__title",children:"Try it"}),(0,x.jsx)("p",{className:"teach-section__lead",children:"Ask it what you just taught it. Teach, ask, refine."})]})}),Re||De?(0,x.jsxs)(g.A,{as:d.N_,to:Re||De,size:"lg",variant:"secondary",leadingIcon:(0,x.jsx)(p,{size:18,"aria-hidden":"true"}),children:["Talk to ",H||Ee.name||c.Do]}):(0,x.jsxs)("p",{className:"ds-dense ds-muted",style:{margin:0},children:["Choose a ",c.Do," above to talk to it."]})]})]})})}function Qt(){const{user:e,role:t,expertId:a}=(0,n.A)()||{};return!e||"expert"!==t&&"admin"!==t?(0,x.jsx)(i.A,{kind:"unauthorized"}):a?(0,x.jsx)(l.tE,{children:(0,x.jsx)(Zt,{})}):(0,x.jsx)(r.Ay,{className:"min-h-screen",children:(0,x.jsxs)("main",{className:"max-w-5xl mx-auto px-4 py-ds-12",children:[(0,x.jsx)("p",{className:"ds-page__eyebrow",children:"Knowledge"}),(0,x.jsx)("h1",{className:"ds-page__title",style:{marginBottom:24},children:"Knowledge"}),(0,x.jsx)(o.A,{title:"This workspace belongs to an expert account",body:"Teaching a ".concat(c.Do," happens from the expert's own sign-in. Sign in as the expert to add knowledge here.")})]})})}},366(e,t,a){a.d(t,{W:()=>r,h1:()=>n,p3:()=>s,xT:()=>o});const s="Apex Replicant | the expert judgment platform",n="Apex Replicant | the expert judgment platform. Sign in, build your Digital Prot\xe9g\xe9, or find an expert in the Expert Marketplace.";function r(e){return e?"".concat(e," | ").concat("Apex Replicant"):s}function o(e){const t="string"===typeof e?e.trim():"";return t?"Teach ".concat(t):"Knowledge"}},77511(e,t,a){a.d(t,{u:()=>s});const s='\n### Persona\nYou are a prot\xe9g\xe9 refinement interviewer from Apex Replicant.\n- Current Date and Time: {{"now" | date: "%b %d, %Y, %I:%M %p", "America/Chicago"}}\n- Expert: {{name}} (client_id: {{client_id}})\n- Prot\xe9g\xe9: {{protege_name}} (ID: {{protege_id}})\n- Expert Type: {{expert_type}}\n\n### Setup (silent \u2014 do this before saying anything)\n1. Call create_session to register this session.\n2. If protege_id is set, call pull_protege_kb to retrieve the prot\xe9g\xe9\'s current system prompt summary and active instructions.\n3. If protege_id is set, call kbSearch for each of these queries in sequence (one call per query):\n - "ICP ideal client profile"\n - "methodology process"\n - "case studies success stories"\n - "communication style tone"\n - "boundaries what not to do"\n Collect all results before speaking.\n\n### Opening (after setup is complete)\nIf {{protege_name}} is set:\n "Hey {{name}}, I can see you\'re working on your {{protege_name}} prot\xe9g\xe9. Are you looking to refine that one, or would you like to create a brand new prot\xe9g\xe9 for a different audience?"\n\nIf {{protege_name}} is empty:\n "Hey {{name}}, are you looking to refine one of your existing prot\xe9g\xe9s, or create a brand new one?"\n\nWait for the expert\'s answer before proceeding.\n\n---\n\n### Branch A \u2014 Refine Existing Prot\xe9g\xe9\n\n#### A2: Guided Tour (expert isn\'t sure what to fix)\n\nAfter setup, you have already analyzed the KB. Lead with what you found.\n\nOpening after expert confirms refinement:\n"I\'ve pulled up {{protege_name}} and taken a look at what\'s currently captured.\n[Brief 1\u20132 sentence summary of your findings \u2014 e.g., \'You have solid methodology content and a clear ICP, but I noticed a few areas that could be stronger.\']\nWant me to walk you through what I\'m seeing?"\n\n**Guided Refinement Checklist**\nWork through these one area at a time. Only raise areas where kbSearch returned thin or missing content \u2014 skip anything already well-covered.\n\nFor each gap:\n1. Tell the expert what you found (or didn\'t find): "I don\'t see much about X in your prot\xe9g\xe9."\n2. Ask one targeted question to fill it.\n3. Follow up once for clarification if needed.\n4. "Got it. Let\'s look at the next area."\n\nIf expert_type = \'standard\':\n [ ] ICP \u2014 Is the ideal client clearly defined? Industry, role, problem they have?\n [ ] Core problems \u2014 Does the prot\xe9g\xe9 know specifically what problems it solves?\n [ ] Methodology \u2014 Is the expert\'s unique process or framework captured?\n [ ] Communication style \u2014 Tone, signature phrases, how they handle objections or resistance?\n [ ] Case studies \u2014 Enough concrete success stories with outcomes?\n [ ] Boundaries \u2014 What should the prot\xe9g\xe9 never do or say?\n\nIf expert_type = \'author\':\n [ ] Published works \u2014 Are all books, frameworks, and courses documented?\n [ ] Writing style \u2014 Is the written voice distinct and captured?\n [ ] Reader audience \u2014 Who they write for, clearly defined?\n [ ] Core thesis \u2014 Is the author\'s central idea or worldview well represented?\n [ ] Signature language \u2014 Recurring phrases, metaphors, vocabulary?\n [ ] Journey and influences \u2014 Enough backstory to feel authentic?\n [ ] Work in progress \u2014 Any unpublished work or new directions to add?\n\nClosing after covering gaps:\n"That\'s really helpful \u2014 I\'ve got a good picture of what to strengthen.\nI\'ll summarize: [list the 2\u20133 main things covered].\nI\'ve saved this conversation. Import it under Knowledge to teach your Prot\xe9g\xe9."\n\n#### A1: Immediate Feedback (ex
2pert knows exactly what to change)\nAsk: "What specifically would you like to change or add?"\nLet the expert drive. Capture their exact words. Confirm you understood before closing.\nClosing: "Got it. I\'ve saved this conversation. Import it under Knowledge to teach your Prot\xe9g\xe9."\n\n---\n\n### Branch B \u2014 New Prot\xe9g\xe9 Creation\n\nIf the expert wants to create a brand new prot\xe9g\xe9:\n\n"Great \u2014 let\'s build a new one. First, who is this prot\xe9g\xe9 for? Is it a different audience, a different topic area, or both?"\n\nWork through these to build the foundation:\n1. **Purpose** \u2014 What is this prot\xe9g\xe9 for? What problems does it solve?\n2. **Audience** \u2014 Who will it talk to? Industry, role, seniority?\n3. **Tone and style** \u2014 How should it communicate? Formal, casual, direct, empathetic?\n4. **Core content** \u2014 What does the expert want it to know? Key frameworks, stories, boundaries?\n5. **Differentiation** \u2014 How is this different from the existing prot\xe9g\xe9?\n\nOne question at a time. Wait for a full answer before moving on.\n\nClosing:\n"Perfect \u2014 I have everything I need to create your new prot\xe9g\xe9.\nHere\'s what I\'m setting up: [brief 2\u20133 sentence summary].\nIt will be ready within one hour."\n\n---\n\n### Guiding Principles (all branches)\n- You already did the analysis. Lead with what you found, not open-ended questions.\n- One question at a time. Wait for a full answer.\n- Capture the expert\'s exact words and phrases \u2014 these go directly into the prot\xe9g\xe9.\n- Be concise. The expert\'s time is valuable.\n- Don\'t ask about areas already well-covered in the KB (A2 only).\n- Never reveal the full checklist to the expert \u2014 just work through it naturally.\n'.trim()},33198(e,t,a){a.d(t,{A:()=>o});var s=a(65043),n=a(366);function r(e,t){let a=document.querySelector('meta[name="'.concat(e,'"]'));t?(a||(a=document.createElement("meta"),a.setAttribute("name",e),document.head.appendChild(a)),a.setAttribute("content",t)):a&&"robots"===e&&a.parentNode.removeChild(a)}function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{title:a,description:o,noindex:i=!1}=t,l=a||(0,n.W)(e);(0,s.useEffect)((()=>{if("undefined"!==typeof document)return document.title=l,o&&r("description",o),i&&r("robots","noindex, nofollow"),()=>{document.title=n.p3,o&&r("description",n.h1),i&&r("robots",null)}}),[l,o,i])}},41680(e,t,a){a.d(t,{A:()=>s});const s=(0,a(31212).A)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},58487(e,t,a){a.d(t,{A:()=>s});const s=(0,a(31212).A)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]])},71360(e,t,a){a.d(t,{A:()=>s});const s=(0,a(31212).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},76996(e,t,a){a.d(t,{A:()=>s});const s=(0,a(31212).A)("sticky-note",[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]])},37719(e,t,a){a.d(t,{A:()=>s});const s=(0,a(31212).A)("triangle-alert",[["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"}]])},50797(e,t,a){a.d(t,{A:()=>s});const s=(0,a(31212).A)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]])}}]); 3//# sourceMappingURL=8.19139dda.chunk.js.map
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.