PageSourceSearch

https://neuml-txtai.hf.space/static/js/index.19XigCCW.js

js neuml-txtai.hf.space collected 2026-10-03 10:21:46 UTC 13,715 bytes, 1 lines download raw bytes

1import{r as t,E as L,_ as D,L as Te,e as de,n as P,W as ie,bU as Le,bN as De,bM as Be,x as d,j as n,Z as Ve,l as F,B as We,ax as ze,b as Me,m as Ne,T as qe,P as Oe,ac as He}from"./index.3bHSf9gi.js";import{u as $e}from"./useWaveformController.Bumwfqnl.js";import{T as je,a as ce}from"./Toolbar.0YdWjZhn.js";import{u as _e,F as Xe}from"./FormClearHelper.DyYuMYyM.js";import{c as Ge}from"./createDownloadLinkElement.ZaXNnPK4.js";import{E as Ke}from"./urls.BwSlolu9.js";import{F as Ze,D as Je}from"./FileDownload.esm.DllwCvQc.js";var ue=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("g",{fill:"none"},t.createElement("rect",{width:24,height:24}),t.createElement("rect",{width:24,height:24}),t.createElement("rect",{width:24,height:24})),t.createElement("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"}),t.createElement("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"}))});ue.displayName="Mic";
1var fe=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("rect",{width:24,height:24,fill:"none"}),t.createElement("path",{d:"M8 19c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2v10c0 1.1.9 2 2 2zm6-12v10c0 1.1.9 2 2 2s2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2z"}))});fe.displayName="Pause";var pe=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("rect",{width:24,height:24,fill:"none"}),t.createElement("path",{d:"M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18a1 1 0 000-1.69L9.54 5.98A.998.998 0 008 6.82z"}))});pe.displayName="PlayArrow";var me=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),t.createElement("path",{d:"M17.65 6.35a7.95 7.95 0 00-6.48-2.31c-3.67.37-6.69 3.35-7.1 7.02C3.52 15.91 7.27 20 12 20a7.98 7.98 0 007.21-4.56c.32-.67-.16-1.44-.9-1.44-.37 0-.72.2-.88.53a5.994 5.994 0 01-6.8 3.31c-2.22-.49-4.01-2.3-4.48-4.52A6.002 6.002 0 0112 6c1.66 0 3.14.69 4.22 1.78l-1.51 1.51c-.63.63-.19 1.71.7 1.71H19c.55 0 1-.45 1-1V6.41c0-.89-1.08-1.34-1.71-.71l-.64.65z"}))});me.displayName="Refresh";
1var ge=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("g",{fill:"none"},t.createElement("rect",{width:24,height:24}),t.createElement("rect",{width:24,height:24})),t.createElement("path",{fillRule:"evenodd",d:"M9 16h6c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z"}))});ge.displayName="StopCircle";const Qe=(e,r)=>{const{enforceDownloadInNewTab:o=!1}=t.useContext(Te);return t.useCallback(()=>{if(!e)return;const l=Ge({enforceDownloadInNewTab:o,url:e,filename:r});l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l)},[e,o,r])},H=({widgetMgr:e,id:r,formId:o,key:c,defaultValue:l})=>{t.useEffect(()=>{const s=e.getElementState(r,c);de(s)&&P(l)&&e.setElementState(r,c,l)},[e,r,c,l]);const[S,u]=t.useState(e.getElementState(r,c)??l),h=t.useCallback(s=>{e.setElementState(r,c,s),u(s)},[e,r,c]),y=t.useMemo(()=>({formId:o||""}),[o]),b=t.useCallback(()=>h(l),[l,h]);return _e({element:y,widgetMgr:e,onFormCleared:b}),[S,h]},Ye=async({files:e,uploadClient:r,widgetMgr:o,widgetInfo:c,fragmentId:l,signal:S})=>{let u=[];try{u=await r.fetchFileURLs(e)}catch(s){return{successfulUploads:[],failedUploads:e.map(i=>({file:i,error:ie(s)}))}}const h=Le(e,u),y=[],b=[];return await Promise.all(h.map(async([s,i])=>{if(!s||!i?.uploadUrl||!i.fileId)return{file:s,fileUrl:i,error:new Error("No upload URL found")};try{await r.uploadFile({id:i.fileId,formId:c.formId||""},i.uploadUrl,s,void 0,S),y.push({fileUrl:i,file:s})}catch(N){const f=ie(N);b.push({file:s,error:f})}})),o.setFileUploaderStateValue(c,new De({uploadedFileInfo:y.map(({file:s,fileUrl:i})=>new Be({fileId:i.fileId,fileUrls:i,name:s.webkitRelativePath||s.name,size:s.size}))}),{fromUi:!0},l),{successfulUploads:y,failedUploads:b}},et=d("div",{target:"e3q8yfp0"})(),se=d("div",{target:"e3q8yfp1"})(({theme:e,disabled:r})=>({height:e.sizes.largestElementHeight,width:"100%",background:e.colors.secondaryBg,borderRadius:e.radii.default,marginBottom:e.spacing.twoXS,display:"flex",alignItems:"center",position:"relative",paddingLeft:e.spacing.xs,paddingRight:e.spacing.sm,border:e.colors.widgetBorderColor?`${e.sizes.borderWidth} solid ${e.colors.widgetBorderColor}`:void 0,cursor:r?"not-allowed":"auto",overflow:"hidden"})),tt=d("div",{target:"e3q8yfp2"})({flex:1}),rt=d("div",{target:"e3q8yfp3"})(({show:e,theme:r})=>({display:e?"block":"none",position:"relative",height:r.sizes.largestElementHeight,"& > div":{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center"}})),ot=d("span",{target:"e3q8yfp4"})(({theme:e,isPlayingOrRecording:r,disabled:o})=>({margin:e.spacing.sm,fontFamily:e.fonts.monospace,color:o?e.colors.fadedText40:r?e.colors.bodyText:e.colors.fadedText60,backgroundColor:e.colors.secondaryBg,fontSize:e.fontSizes.sm})),he=d("div",{target:"e3q8yfp5"})({width:"100%",textAlign:"center",overflow:"hidden"}),ye=d("span",{target:"e3q8yfp6"})(({theme:e})=>({color:e.colors.bodyText})),nt=d("a",{target:"e3q8yfp7"})(({theme:e})=>({color:e.colors.link,textDecoration:e.linkUnderline?"underline":"none"})),at=d("div",{target:"e3q8yfp8"})(({theme:e})=>({flex:1,height:e.sizes.largestElementHeight,display:"flex",justifyContent:"center",alignItems:"center"})),lt=d("div",{target:"e3q8yfp9"})(({theme:e})=>{const r="0.625em";return{opacity:.2,width:"100%",height:r,backgroundSize:r,backgroundImage:`radial-gradient(${e.colors.fadedText10} 40%, transparent 40%)`,backgroundRepeat:"repeat"}}),it=d("span",{target:"e3q8yfp10"})(({theme:e})=>({"& > button":{color:e.colors.primary,padding:e.spacing.threeXS},"& > button:hover, & > button:focus":{color:e.colors.redColor}})),ct=d("span",{target:"e3q8yfp11"})(({theme:e})=>({"& > button":{padding:e.spacing.threeXS,color:e.colors.fadedText60},"& > button:hover, & > button:focus":{color:e.colors.bodyText}})),be=d("span",{target:"e3q8yfp12"})(({theme:e})=>({"& >
1 button":{padding:e.spacing.threeXS,color:e.colors.fadedText60},"& > button:hover, & > button:focus":{color:e.colors.bodyText}})),$=d("div",{target:"e3q8yfp13"})(({theme:e})=>({display:"flex",justifyContent:"center",alignItems:"center",flexGrow:0,flexShrink:1,padding:e.spacing.xs,gap:e.spacing.twoXS,marginRight:e.spacing.twoXS})),st=d("div",{target:"e3q8yfp14"})(({theme:e})=>({marginLeft:e.spacing.sm})),T=({onClick:e,disabled:r,ariaLabel:o,iconContent:c})=>n(Me,{kind:We.BORDERLESS_ICON,onClick:e,disabled:r,"aria-label":o,containerWidth:!0,"data-testid":"stAudioInputActionButton",children:n(ze,{content:c,size:"lg",color:"inherit"})}),dt=({disabled:e,stopRecording:r})=>n(it,{children:n(T,{onClick:r,disabled:e,ariaLabel:"Stop recording",iconContent:ge})}),ut=({disabled:e,isPlaying:r,onClickPlayPause:o})=>n(be,{children:r?n(T,{onClick:o,disabled:e,ariaLabel:"Pause",iconContent:fe}):n(T,{onClick:o,disabled:e,ariaLabel:"Play",iconContent:pe})}),ft=({disabled:e,startRecording:r})=>n(ct,{children:n(T,{onClick:r,disabled:e,ariaLabel:"Record",iconContent:ue})}),pt=({onClick:e})=>n(be,{children:n(T,{disabled:!1,onClick:e,ariaLabel:"Reset",iconContent:me})}),mt=({disabled:e,isRecording:r,isPlaying:o,isUploading:c,isError:l,recordingUrlExists:S,startRecording:u,stopRecording:h,onClickPlayPause:y,onClear:b})=>l?n($,{children:n(pt,{onClick:b})}):c?n($,{children:n(Ve,{size:"base",iconValue:"spinner"})}):F($,{children:[r?n(dt,{disabled:e,stopRecording:h}):n(ft,{disabled:e,startRecording:u}),S&&n(ut,{disabled:e,isPlaying:o,onClickPlayPause:y})]}),gt=t.memo(mt),ht=()=>n(he,{children:n(ye,{children:"An error has occurred, please try again."})}),yt=t.memo(ht),R="00:00",k=e=>{const r=Math.floor(e/1e3),o=Math.floor(r/60),c=Math.floor(o/60),l=r%60,S=o%60,u=l.toString().padStart(2,"0"),h=S.toString().padStart(2,"0"),y=c.toString().padStart(2,"0");return o<60?`${h}:${u}`:`${y}:${h}:${u}`},bt=()=>F(he,{children:[n(ye,{children:"This app would like to use your microphone."})," ",n(nt,{href:Ke,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]}),vt=t.memo(bt),St=()=>n(at,{children:n(lt,{})}),wt=t.memo(St),Ct=({element:e,uploadClient:r,widgetMgr:o,fragmentId:c,disabled:l})=>{const S=t.useRef(null),[u,h]=t.useState(!1),[y,b]=t.useState(!1),[s,i]=t.useState(!1),[N,f]=t.useState(R),[B,V]=H({widgetMgr:o,id:e.id,key:"deleteFileUrl",defaultValue:null}),[g,W]=H({widgetMgr:o,id:e.id,key:"recordingUrl",defaultValue:null}),[q,A]=H({widgetMgr:o,id:e.id,formId:e.formId,key:"recordingTime",defaultValue:R}),U=t.useRef(null),w=t.useRef(null),p=t.useRef(null),j=e.id,C=e.formId,ve=t.useCallback(async a=>{U.current&&U.current.abort();const v=new AbortController;U.current=v;try{if(b(!0),P(C)&&o.setFormsWithUploadsInProgress(new Set([C])),v.signal.aborted)return;let m;try{m=URL.createObjectURL(a),w.current&&w.current!==m&&URL.revokeObjectURL(w.current),w.current=m}catch{i(!0),b(!1),P(C)&&o.setFormsWithUploadsInProgress(new Set);return}if(v.signal.aborted){URL.revokeObjectURL(m),w.current=null;return}W(m);const Ie=new Date().toISOString().slice(0,16).replace(/:/g,"-"),Pe=new File([a],`${Ie}_audio.wav`,{type:a.type});try{const{successfulUploads:Fe,failedUploads:xe}=await Ye({files:[Pe],uploadClient:r,widgetMgr:o,widgetInfo:{id:j,formId:C},fragmentId:c,signal:v.signal});if(v.signal.aborted)return;if(xe.length>0){i(!0);return}i(!1);const le=Fe[0];le?.fileUrl?.deleteUrl&&V(le.fileUrl.deleteUrl)}catch{v.signal.aborted||i(!0)}finally{P(C)&&o.setFormsWithUploadsInProgress(new Set),v.signal.aborted||b(!1)}}catch{v.signal.aborted||(i(!0),b(!1)),P(C)&&o.setFormsWithUploadsInProgress(new Set)}},[r,o,j,C,c,V,W]),z=t.useRef(null),_=$e({containerRef:S,sampleRate:e.sampleRate??void 0,waveformPadding:4,events:{onPermissionDenied:()=>{h(!0)},onError:()=>{i(!0)},onRecordStart:()=>{A(R),f(R)},onRecordReady:()=>{const a=k(z.current?.playback.getDurationMs()??0);A(a),f(a)},onApprove:ve,onCancel:()=>{A(R),f(R)},onProgressMs:a=>{A(k(a))},onPlaybackPause:()=>{f(k(z.current?.playback.getCurrentTimeMs()??0))},onPlaybackFinish:()=>{f(k(z.current?.playback.getDurationMs()??0))}}});z.current=_;const{state:M,isPlaybackPlaying:I,start:X,stop:G,approve:K,cancel:Z,playback:{play:J,pause:Q,load:Y,getCurrentTimeMs:x,getDurationMs:ee}}=_,E=t.useCallback(async({updateWidgetManager:a,deleteFile:v})=>{const m=g;if(m&&w.current===m&&(URL.revokeObjectURL(m),w.current=null),p.current&&(cancelAnimationFrame(p.current),p.current=null),W(null),V(null),f(R),A(R),Z(),a&&o.setFileUploaderStateValue(e,{},{fromUi:!0},c),v&&B)try{await r.deleteFile(B)}catch{}P(m)&&URL.revokeObjectURL(m)},[B,g,r,Z,e,o,c,A,V,W]);t.useEffect(()=>{const a=()=>
1{I&&(f(k(x())),p.current=requestAnimationFrame(a))};return I?p.current=requestAnimationFrame(a):p.current&&(cancelAnimationFrame(p.current),p.current=null),()=>{p.current&&(cancelAnimationFrame(p.current),p.current=null)}},[I,x]),t.useEffect(()=>{if(!g)return;let a=!1;return f(q),(async()=>{try{if(await Y(g),a)return;const m=ee();m>0&&f(k(m))}catch{a||i(!0)}})(),()=>{a=!0}},[g,q,Y,ee]),t.useEffect(()=>{if(de(C))return;const a=new Xe;return a.manageFormClearListener(o,C,()=>{E({updateWidgetManager:!0,deleteFile:!1})}),()=>a.disconnect()},[C,E,o]),t.useEffect(()=>()=>{U.current&&(U.current.abort(),U.current=null),p.current&&(cancelAnimationFrame(p.current),p.current=null),w.current&&(URL.revokeObjectURL(w.current),w.current=null)},[]);const Se=t.useCallback(async()=>{try{if(I){const a=x();Q(),f(k(a))}else M==="idle"&&g&&(x()<=100&&f(R),await J())}catch{i(!0)}},[I,x,Q,J,g,M]),te=t.useCallback(async()=>{g&&await E({updateWidgetManager:!1,deleteFile:!0});try{f(R),await X()}catch{}},[E,g,X]),re=t.useCallback(async()=>{try{const{blob:a}=await G();await K(a)}catch{i(!0)}},[K,G]),oe=Qe(g,"recording.wav"),we=t.useCallback(()=>{te()},[te]),Ce=t.useCallback(()=>{re()},[re]),Re=t.useCallback(()=>{E({updateWidgetManager:!1,deleteFile:!0}),i(!1)},[E]),Ee=t.useCallback(()=>{oe()},[oe]),ke=t.useCallback(()=>{E({updateWidgetManager:!0,deleteFile:!0})},[E]),O=M==="recording",ne=I,Ae=O?q:N,ae=M==="idle"&&!u&&!g,Ue=u||ae||s;return F(et,{className:"stAudioInput","data-testid":"stAudioInput",children:[n(He,{label:e.label,disabled:l,labelVisibility:Ne(e.labelVisibility?.value),children:e.help&&n(st,{children:n(qe,{content:e.help,placement:Oe.TOP})})}),F(se,{disabled:l,children:[F(je,{isFullScreen:!1,disableFullscreenMode:!0,target:se,children:[g&&n(ce,{label:"Download as WAV",icon:Ze,onClick:Ee}),B&&n(ce,{label:"Clear recording",icon:Je,onClick:ke})]}),n(gt,{isRecording:O,isPlaying:ne,isUploading:y,isError:s,recordingUrlExists:!!g,startRecording:we,stopRecording:Ce,onClickPlayPause:()=>void Se(),onClear:Re,disabled:l||u}),F(tt,{children:[s&&n(yt,{}),ae&&n(wt,{}),u&&n(vt,{}),n(rt,{"data-testid":"stAudioInputWaveSurfer",ref:S,show:!Ue})]}),n(ot,{isPlayingOrRecording:O||ne,disabled:l,"data-testid":"stAudioInputWaveformTimeCode",children:Ae})]})]})},Ft=t.memo(Ct);export{Ft as default};

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.