streamlit-nightly 1.42.1.dev20250204__py2.py3-none-any.whl → 1.42.1.dev20250206__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{FileDownload.esm.CuayiK6T.js → FileDownload.esm.DwBO4CPU.js} +1 -1
- streamlit/static/static/js/{FileDropzone.CvXoxIUm.js → FileDropzone.l_rm_qyP.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.DpwWkrvV.js → FormClearHelper.LI0uGKXr.js} +1 -1
- streamlit/static/static/js/{Hooks.BQiFiHd5.js → Hooks.Dic60qKO.js} +1 -1
- streamlit/static/static/js/{InputInstructions.CypmdrYz.js → InputInstructions.BVSrSzyM.js} +1 -1
- streamlit/static/static/js/{ProgressBar.DfR4HyQR.js → ProgressBar.CiuIhn-j.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.D6u3szcn.js → RenderInPortalIfExists.DXoPwgJm.js} +1 -1
- streamlit/static/static/js/{Toolbar.D6p42Hno.js → Toolbar.Bws727nN.js} +1 -1
- streamlit/static/static/js/{base-input.B5AcLp6p.js → base-input.BG3_mR5a.js} +1 -1
- streamlit/static/static/js/{createSuper.DNzaJgi-.js → createSuper.BF6PuRKW.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.CKACfVZL.js → data-grid-overlay-editor.Bv759UXp.js} +1 -1
- streamlit/static/static/js/{downloader.D6HV3a60.js → downloader.CVHmveIJ.js} +1 -1
- streamlit/static/static/js/{es6.UQDWlCyE.js → es6.CKbvqIhx.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.DQ-TFrBp.js → iframeResizer.contentWindow.BkEeeo8L.js} +1 -1
- streamlit/static/static/js/{index.CKOdbWxq.js → index.--2AyPrU.js} +1 -1
- streamlit/static/static/js/index.B5Uxprvt.js +2 -0
- streamlit/static/static/js/{index.Epl2r08f.js → index.BImYg1mO.js} +1 -1
- streamlit/static/static/js/{index.DqZZoWyt.js → index.BKVJ1VBu.js} +1 -1
- streamlit/static/static/js/{index.BPmrb-47.js → index.BOWcB5X0.js} +1 -1
- streamlit/static/static/js/{index.BY8YeKF1.js → index.BOaiJM1y.js} +1 -1
- streamlit/static/static/js/{index.ByH1pn5_.js → index.BkPpT8KL.js} +1 -1
- streamlit/static/static/js/{index.CX9gqq2L.js → index.C07oOjJI.js} +1 -1
- streamlit/static/static/js/index.C4CvtPIA.js +1 -0
- streamlit/static/static/js/{index.BXmBj7MJ.js → index.C583HQPW.js} +1 -1
- streamlit/static/static/js/{index.ChrjN8GY.js → index.C7ShUXWu.js} +1 -1
- streamlit/static/static/js/{index.CAuJtYES.js → index.CIUGbfN-.js} +1 -1
- streamlit/static/static/js/{index.DB_dBVfZ.js → index.CLsR30iv.js} +1 -1
- streamlit/static/static/js/{index.C8zZSMvD.js → index.CYyMatnb.js} +1 -1
- streamlit/static/static/js/{index.BghvoEVe.js → index.C_i45xvQ.js} +1 -1
- streamlit/static/static/js/{index.D7BxtE4u.js → index.CfBMTPce.js} +1 -1
- streamlit/static/static/js/{index.BQEIBi4n.js → index.Cs3niYHd.js} +1 -1
- streamlit/static/static/js/{index.BPNlEjgz.js → index.D0P1HMA1.js} +1 -1
- streamlit/static/static/js/{index.CrMtUJsu.js → index.D4zWkike.js} +5 -5
- streamlit/static/static/js/{index.BUGQmWUV.js → index.DC0pyGdw.js} +1 -1
- streamlit/static/static/js/{index.ndVWhafL.js → index.DC2ac6Nk.js} +1 -1
- streamlit/static/static/js/{index.Dr6DSYcq.js → index.DCUW0b-w.js} +1 -1
- streamlit/static/static/js/{index.BiybRa0I.js → index.DET-MvNj.js} +1 -1
- streamlit/static/static/js/{index.CSgG8OVN.js → index.DI1n7tF5.js} +1 -1
- streamlit/static/static/js/{index.CEdHQ1ob.js → index.DMae4Z-0.js} +1 -1
- streamlit/static/static/js/{index.wW-pPvtW.js → index.DRYIN7K5.js} +1 -1
- streamlit/static/static/js/{index.BuyK2IsW.js → index.DZhFuLsM.js} +1 -1
- streamlit/static/static/js/{index.DkV6k6Ng.js → index.DvjJSBT_.js} +1 -1
- streamlit/static/static/js/{index.B96fHK2A.js → index.Gdr5urlE.js} +1 -1
- streamlit/static/static/js/{index.CgVoYKAP.js → index.TDbcj-aD.js} +1 -1
- streamlit/static/static/js/{index.DMKXUbO6.js → index.UxOzm9KZ.js} +1 -1
- streamlit/static/static/js/{index.BiMrOUpK.js → index.VkiSji1p.js} +1 -1
- streamlit/static/static/js/{index.D4SMJhY1.js → index.e9DSvZ6b.js} +1 -1
- streamlit/static/static/js/{index.Bm7Vkuba.js → index.ezIYG9hW.js} +1 -1
- streamlit/static/static/js/{index.2EE80u0h.js → index.gthzAzzy.js} +6 -6
- streamlit/static/static/js/{index.DaoBv396.js → index.lxFhX6K1.js} +1 -1
- streamlit/static/static/js/{index.BdVr8Tta.js → index.y9PB-mTp.js} +1 -1
- streamlit/static/static/js/{input.CxqdG-sh.js → input.ekQXAXS2.js} +1 -1
- streamlit/static/static/js/{memory.DuSk7Eex.js → memory.CzhWwr8k.js} +1 -1
- streamlit/static/static/js/{mergeWith.DrxB1Sj4.js → mergeWith.CjWtfLVK.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.DBc0yndt.js → number-overlay-editor.CFFRhwzv.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.ZdYWHeG3.js → possibleConstructorReturn.BiMrneUm.js} +1 -1
- streamlit/static/static/js/{sandbox.D3L4CYjG.js → sandbox.B1Cwdby0.js} +1 -1
- streamlit/static/static/js/{textarea.CSafh28v.js → textarea.BYQOUi7u.js} +1 -1
- streamlit/static/static/js/{timepicker.C-pwkiaT.js → timepicker.BbVkXpKf.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.DyCVskz5.js → toConsumableArray.eNZZBqsg.js} +1 -1
- streamlit/static/static/js/{uniqueId.BODM2vTk.js → uniqueId.Ci60uueL.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.DQUiM2dz.js → useBasicWidgetState.BJ0FCAzu.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.Ccjd55xn.js → useOnInputChange.xhIvlf7z.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.CneUoXNE.js → withFullScreenWrapper.CKNKx70m.js} +1 -1
- {streamlit_nightly-1.42.1.dev20250204.dist-info → streamlit_nightly-1.42.1.dev20250206.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.42.1.dev20250204.dist-info → streamlit_nightly-1.42.1.dev20250206.dist-info}/RECORD +71 -71
- streamlit/static/static/js/index.BAFGiIHm.js +0 -1
- streamlit/static/static/js/index.CJ-t5S6T.js +0 -2
- {streamlit_nightly-1.42.1.dev20250204.data → streamlit_nightly-1.42.1.dev20250206.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.42.1.dev20250204.dist-info → streamlit_nightly-1.42.1.dev20250206.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.42.1.dev20250204.dist-info → streamlit_nightly-1.42.1.dev20250206.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.42.1.dev20250204.dist-info → streamlit_nightly-1.42.1.dev20250206.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
|
|
1
|
-
import{r as y,E as _,_ as T,n as E,ay as J,z as R,j as p,bv as Q,bc as B,bq as K,b8 as Y,bp as j,bC as A,d as Z,g as ee,aN as te,y as re,bD as ie,bE as ae,al as oe,R as ne,aC as se,J as P,bm as le,bl as de,bs as ce,bF as ue,bt as fe,bu as he,F as pe}from"./index.2EE80u0h.js";import{a as V}from"./axios.upsvKRUO.js";import{F as ge}from"./FormClearHelper.DpwWkrvV.js";import{U as W}from"./UploadFileInfo.C-jY39rj.js";import{P as me,S as ve}from"./ProgressBar.DfR4HyQR.js";var z=y.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(_,T({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:l}),y.createElement("path",{d:"M.5 1c-.28 0-.5.23-.5.5v4c0 .28.23.5.5.5h5c.28 0 .5-.22.5-.5V4l1 1h1V2H7L6 3V1.5c0-.28-.22-.5-.5-.5h-5z"}))});z.displayName="Video";var N=y.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(_,T({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:l}),y.createElement("path",{d:"M1.41 0L0 1.41l.72.72L2.5 3.94.72 5.72 0 6.41l1.41 1.44.72-.72 1.81-1.81 1.78 1.81.69.72 1.44-1.44-.72-.69-1.81-1.78 1.81-1.81.72-.72L6.41 0l-.69.72L3.94 2.5 2.13.72 1.41 0z"}))});N.displayName="X";var $=y.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(_,T({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:l}),y.createElement("rect",{width:24,height:24,fill:"none"}),y.createElement("path",{d:"M20 5h-3.17l-1.24-1.35A1.99 1.99 0 0014.12 3H9.88c-.56 0-1.1.24-1.48.65L7.17 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-1.35 8.35l-2.79 2.79c-.32.32-.86.1-.86-.35v-1.75H9v1.75c0 .45-.54.67-.85.35l-2.79-2.79c-.2-.2-.2-.51 0-.71l2.79-2.79a.5.5 0 01.85.36v1.83h6v-1.83c0-.45.54-.67.85-.35l2.79 2.79c.2.19.2.51.01.7z"}))});$.displayName="SwitchCamera";var L;(function(t){t.XSMALL="xsmall",t.SMALL="small",t.MEDIUM="medium",t.LARGE="large"})(L||(L={}));function Se(t,l){switch(t){case"xsmall":return{padding:`${l.spacing.twoXS} ${l.spacing.sm}`,fontSize:l.fontSizes.sm};case"small":return{padding:`${l.spacing.twoXS} ${l.spacing.md}`};case"large":return{padding:`${l.spacing.md} ${l.spacing.md}`};default:return{padding:`${l.spacing.xs} ${l.spacing.md}`}}}const D=E("div",{target:"e47j7ja0"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),O=E("div",{target:"e47j7ja1"})(({theme:t,width:l})=>({backgroundColor:t.colors.secondaryBg,borderRadius:`${t.radii.default} ${t.radii.default} 0 0`,width:"100%",height:l*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),ye=E("p",{target:"e47j7ja2"})(({theme:t})=>({marginTop:t.spacing.sm,textAlign:"center"})),be=E("img",{target:"e47j7ja3"})(({theme:t,opacity:l})=>({borderRadius:`${t.radii.default} ${t.radii.default} 0 0`,objectFit:"contain",opacity:l})),Me=E("a",{target:"e47j7ja4"})(({theme:t})=>({color:t.colors.primary,display:"block",textDecoration:"none"})),we=E("span",{target:"e47j7ja5"})({display:"flex",alignItems:"center"}),Ce=E("div",{target:"e47j7ja6"})(({theme:t})=>({position:"absolute",top:t.spacing.lg,right:t.spacing.lg,zIndex:t.zIndices.priority,color:t.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),Ue=E("div",{target:"e47j7ja8"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),Ee=E("button",{target:"e47j7ja9"})(({theme:t})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:t.colors.lightenedBg05,border:`${t.sizes.borderWidth} solid ${t.colors.borderColor}`,borderRadius:`0 0 ${t.radii.default} ${t.radii.default}`,"&:hover":{borderColor:t.colors.primary,color:t.colors.primary},"&:active":{color:t.colors.white,borderColor:t.colors.primary,backgroundColor:t.colors.primary},"&:focus:not(:active)":{borderColor:t.colors.primary,color:t.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:t.colors.fadedText40},fontWeight:t.fontWeights.normal,padding:`${t.spacing.xs} ${t.spacing.md}`,margin:t.spacing.none,lineHeight:t.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:`0 0 0 0.2rem ${J(t.colors.primary,.5)}`},...Se("medium",t)}));function H({disabled:t,onClick:l,children:r,progress:o}){return R(Ee,{disabled:t||!1,onClick:l||(()=>{}),progress:o||null,"data-testid":"stCameraInputButton",children:[r,o&&p(Ue,{children:p(me,{value:o,size:ve.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})})]})}var F;(function(t){t.USER="user",t.ENVIRONMENT="environment"})(F||(F={}));const Ie=({switchFacingMode:t})=>p(Ce,{"data-testid":"stCameraInputSwitchButton",children:p(Q,{content:"Switch camera",placement:B.TOP_RIGHT,children:p(K,{kind:Y.MINIMAL,onClick:t,children:p(j,{content:$,size:"twoXL",color:A.white})})})});var G={exports:{}};(function(t,l){(function(o,a){t.exports=a(y)})(Z,function(r){return function(o){var a={};function n(s){if(a[s])return a[s].exports;var f=a[s]={i:s,l:!1,exports:{}};return o[s].call(f.exports,f,f.exports,n),f.l=!0,f.exports}return n.m=o,n.c=a,n.d=function(s,f,g){n.o(s,f)||Object.defineProperty(s,f,{enumerable:!0,get:g})},n.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},n.t=function(s,f){if(f&1&&(s=n(s)),f&8||f&4&&typeof s=="object"&&s&&s.__esModule)return s;var g=Object.create(null);if(n.r(g),Object.defineProperty(g,"default",{enumerable:!0,value:s}),f&2&&typeof s!="string")for(var U in s)n.d(g,U,(function(C){return s[C]}).bind(null,U));return g},n.n=function(s){var f=s&&s.__esModule?function(){return s.default}:function(){return s};return n.d(f,"a",f),f},n.o=function(s,f){return Object.prototype.hasOwnProperty.call(s,f)},n.p="",n(n.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(o,a,n){n.r(a);var s=n("react"),f=function(){var m=function(u,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,d){i.__proto__=d}||function(i,d){for(var c in d)d.hasOwnProperty(c)&&(i[c]=d[c])},m(u,e)};return function(u,e){m(u,e);function i(){this.constructor=u}u.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),g=function(){return g=Object.assign||function(m){for(var u,e=1,i=arguments.length;e<i;e++){u=arguments[e];for(var d in u)Object.prototype.hasOwnProperty.call(u,d)&&(m[d]=u[d])}return m},g.apply(this,arguments)},U=function(m,u){var e={};for(var i in m)Object.prototype.hasOwnProperty.call(m,i)&&u.indexOf(i)<0&&(e[i]=m[i]);if(m!=null&&typeof Object.getOwnPropertySymbols=="function")for(var d=0,i=Object.getOwnPropertySymbols(m);d<i.length;d++)u.indexOf(i[d])<0&&Object.prototype.propertyIsEnumerable.call(m,i[d])&&(e[i[d]]=m[i[d]]);return e};(function(){typeof window>"u"||(navigator.mediaDevices===void 0&&(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia===void 0&&(navigator.mediaDevices.getUserMedia=function(u){var e=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return e?new Promise(function(i,d){e.call(navigator,u,i,d)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function C(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var I=function(m){f(u,m);function u(e){var i=m.call(this,e)||this;return i.canvas=null,i.ctx=null,i.requestUserMediaId=0,i.unmounted=!1,i.state={hasUserMedia:!1},i}return u.prototype.componentDidMount=function(){var e=this,i=e.state,d=e.props;if(this.unmounted=!1,!C()){d.onUserMediaError("getUserMedia not supported");return}i.hasUserMedia||this.requestUserMedia(),d.children&&typeof d.children!="function"&&console.warn("children must be a function")},u.prototype.componentDidUpdate=function(e){var i=this.props;if(!C()){i.onUserMediaError("getUserMedia not supported");return}var d=JSON.stringify(e.audioConstraints)!==JSON.stringify(i.audioConstraints),c=JSON.stringify(e.videoConstraints)!==JSON.stringify(i.videoConstraints),b=e.minScreenshotWidth!==i.minScreenshotWidth,S=e.minScreenshotHeight!==i.minScreenshotHeight;(c||b||S)&&(this.canvas=null,this.ctx=null),(d||c)&&(this.stopAndCleanup(),this.requestUserMedia())},u.prototype.componentWillUnmount=function(){this.unmounted=!0,this.stopAndCleanup()},u.stopMediaStream=function(e){e&&(e.getVideoTracks&&e.getAudioTracks?(e.getVideoTracks().map(function(i){e.removeTrack(i),i.stop()}),e.getAudioTracks().map(function(i){e.removeTrack(i),i.stop()})):e.stop())},u.prototype.stopAndCleanup=function(){var e=this.state;e.hasUserMedia&&(u.stopMediaStream(this.stream),e.src&&window.URL.revokeObjectURL(e.src))},u.prototype.getScreenshot=function(e){var i=this,d=i.state,c=i.props;if(!d.hasUserMedia)return null;var b=this.getCanvas(e);return b&&b.toDataURL(c.screenshotFormat,c.screenshotQuality)},u.prototype.getCanvas=function(e){var i=this,d=i.state,c=i.props;if(!this.video||!d.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var b=this.video.videoWidth,S=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var h=b/S;b=c.minScreenshotWidth||this.video.clientWidth,S=b/h,c.minScreenshotHeight&&S<c.minScreenshotHeight&&(S=c.minScreenshotHeight,b=S*h)}this.canvas=document.createElement("canvas"),this.canvas.width=(e==null?void 0:e.width)||b,this.canvas.height=(e==null?void 0:e.height)||S,this.ctx=this.canvas.getContext("2d")}var w=this,M=w.ctx,v=w.canvas;return M&&v&&(v.width=(e==null?void 0:e.width)||v.width,v.height=(e==null?void 0:e.height)||v.height,c.mirrored&&(M.translate(v.width,0),M.scale(-1,1)),M.imageSmoothingEnabled=c.imageSmoothing,M.drawImage(this.video,0,0,(e==null?void 0:e.width)||v.width,(e==null?void 0:e.height)||v.height),c.mirrored&&(M.scale(-1,1),M.translate(-v.width,0))),v},u.prototype.requestUserMedia=function(){var e=this,i=this.props,d=function(S,h){var w={video:typeof h<"u"?h:!0};i.audio&&(w.audio=typeof S<"u"?S:!0),e.requestUserMediaId++;var M=e.requestUserMediaId;navigator.mediaDevices.getUserMedia(w).then(function(v){e.unmounted||M!==e.requestUserMediaId?u.stopMediaStream(v):e.handleUserMedia(null,v)}).catch(function(v){e.handleUserMedia(v)})};if("mediaDevices"in navigator)d(i.audioConstraints,i.videoConstraints);else{var c=function(S){return{optional:[{sourceId:S}]}},b=function(S){var h=S.deviceId;return typeof h=="string"?h:Array.isArray(h)&&h.length>0?h[0]:typeof h=="object"&&h.ideal?h.ideal:null};MediaStreamTrack.getSources(function(S){var h=null,w=null;S.forEach(function(x){x.kind==="audio"?h=x.id:x.kind==="video"&&(w=x.id)});var M=b(i.audioConstraints);M&&(h=M);var v=b(i.videoConstraints);v&&(w=v),d(c(h),c(w))})}},u.prototype.handleUserMedia=function(e,i){var d=this.props;if(e||!i){this.setState({hasUserMedia:!1}),d.onUserMediaError(e);return}this.stream=i;try{this.video&&(this.video.srcObject=i),this.setState({hasUserMedia:!0})}catch{this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(i)})}d.onUserMedia(i)},u.prototype.render=function(){var e=this,i=this,d=i.state,c=i.props,b=c.audio;c.forceScreenshotSourceSize,c.onUserMedia,c.onUserMediaError,c.screenshotFormat,c.screenshotQuality,c.minScreenshotWidth,c.minScreenshotHeight,c.audioConstraints,c.videoConstraints,c.imageSmoothing;var S=c.mirrored,h=c.style,w=h===void 0?{}:h,M=c.children,v=U(c,["audio","forceScreenshotSourceSize","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),x=S?g(g({},w),{transform:(w.transform||"")+" scaleX(-1)"}):w,q={getScreenshot:this.getScreenshot.bind(this)};return s.createElement(s.Fragment,null,s.createElement("video",g({autoPlay:!0,src:d.src,muted:!b,playsInline:!0,ref:function(X){e.video=X},style:x},v)),M&&M(q))},u.defaultProps={audio:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},u}(s.Component);a.default=I},react:function(o,a){o.exports=r}}).default})})(G);var Fe=G.exports;const Re=ee(Fe);var k;(function(t){t.PENDING="pending",t.SUCCESS="success",t.ERROR="error"})(k||(k={}));const xe=({width:t})=>R(O,{width:t,children:[p(j,{size:"threeXL",color:A.gray60,content:z}),R(ye,{children:["This app would like to use your camera.",p(Me,{href:ae,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),Pe=({handleCapture:t,width:l,disabled:r,clearPhotoInProgress:o,setClearPhotoInProgress:a,facingMode:n,setFacingMode:s,testOverride:f})=>{const[g,U]=y.useState(f||"pending"),C=y.useRef(null),[I,m]=y.useState(l),u=y.useCallback(te(1e3,m),[]);y.useEffect(()=>{u(l)},[l,u]);function e(){if(C.current!==null){const d=C.current.getScreenshot();t(d)}}const i=re();return R(D,{"data-testid":"stCameraInputWebcamComponent",children:[g!=="success"&&!r&&!o?p(xe,{width:I}):ie&&p(Ie,{switchFacingMode:s}),p(O,{"data-testid":"stCameraInputWebcamStyledBox",hidden:g!=="success"&&!r&&!o,width:I,children:!r&&p(Re,{audio:!1,ref:C,screenshotFormat:"image/jpeg",screenshotQuality:1,width:I,height:I*9/16,style:{borderRadius:`${i.radii.default} ${i.radii.default} 0 0`},onUserMediaError:()=>{U("error")},onUserMedia:()=>{U("success"),a(!1)},videoConstraints:{width:{ideal:I},facingMode:n}})}),p(H,{onClick:e,disabled:g!=="success"||r||o,children:"Take Photo"})]})},_e=150,Te=oe.getLogger("CameraInput");class Be extends ne.PureComponent{constructor(l){super(l),this.localFileIdCounter=1,this.RESTORED_FROM_WIDGET_STRING="RESTORED_FROM_WIDGET",this.formClearHelper=new ge,this.getProgress=()=>{if(this.state.files.length>0&&this.state.files[this.state.files.length-1].status.type==="uploading")return this.state.files[this.state.files.length-1].status.progress},this.setClearPhotoInProgress=r=>{this.setState({clearPhotoInProgress:r})},this.setFacingMode=()=>{this.setState(r=>({facingMode:r.facingMode===F.USER?F.ENVIRONMENT:F.USER}))},this.handleCapture=r=>{if(r===null)return Promise.resolve();this.setState({imgSrc:r,shutter:!0,minShutterEffectPassed:!1});const o=a=>new Promise(n=>setTimeout(n,a));return je(r,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(a=>this.props.uploadClient.fetchFileURLs([a]).then(n=>({file:a,fileUrls:n[0]}))).then(({file:a,fileUrls:n})=>this.uploadFile(n,a)).then(()=>o(_e)).then(()=>{this.setState((a,n)=>({imgSrc:r,shutter:a.shutter,minShutterEffectPassed:!0}))}).catch(a=>{Te.error(a)})},this.removeCapture=()=>{this.state.files.length!==0&&(this.state.files.forEach(r=>this.deleteFile(r.id)),this.setState({imgSrc:null,clearPhotoInProgress:!0}))},this.componentDidUpdate=()=>{if(this.status!=="ready")return;const r=this.createWidgetValue(),{element:o,widgetMgr:a,fragmentId:n}=this.props,s=a.getFileUploaderStateValue(o);se(r,s)||a.setFileUploaderStateValue(o,r,{fromUi:!0},n)},this.onFormCleared=()=>{this.setState({files:[]},()=>{const r=this.createWidgetValue();if(P(r))return;this.setState({imgSrc:null});const{widgetMgr:o,element:a,fragmentId:n}=this.props;o.setFileUploaderStateValue(a,r,{fromUi:!0},n)})},this.deleteFile=r=>{const o=this.getFile(r);P(o)||(o.status.type==="uploading"&&o.status.cancelToken.cancel(),o.status.type==="uploaded"&&o.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(o.status.fileUrls.deleteUrl),this.removeFile(r))},this.addFile=r=>{this.setState(o=>({files:[...o.files,r]}))},this.removeFile=r=>{this.setState(o=>({files:o.files.filter(a=>a.id!==r)}))},this.getFile=r=>this.state.files.find(o=>o.id===r),this.updateFile=(r,o)=>{this.setState(a=>({files:a.files.map(n=>n.id===r?o:n)}))},this.onUploadComplete=(r,o)=>{this.setState(()=>({shutter:!1}));const a=this.getFile(r);P(a)||a.status.type!=="uploading"||this.updateFile(a.id,a.setStatus({type:"uploaded",fileId:o.fileId,fileUrls:o}))},this.onUploadProgress=(r,o)=>{const a=this.getFile(o);if(P(a)||a.status.type!=="uploading")return;const n=Math.round(r.loaded*100/r.total);a.status.progress!==n&&this.updateFile(o,a.setStatus({type:"uploading",cancelToken:a.status.cancelToken,progress:n}))},this.reset=()=>{this.setState({files:[],imgSrc:null})},this.uploadFile=(r,o)=>{const a=V.CancelToken.source(),n=new W(o.name,o.size,this.nextLocalFileId(),{type:"uploading",cancelToken:a,progress:1});this.addFile(n),this.props.uploadClient.uploadFile(this.props.element,r.uploadUrl,o,s=>this.onUploadProgress(s,n.id),a.token).then(()=>this.onUploadComplete(n.id,r)).catch(s=>{V.isCancel(s)||this.updateFile(n.id,n.setStatus({type:"error",errorMessage:s?s.toString():"Unknown error"}))})},this.state=this.initialValue}get initialValue(){const l={files:[],imgSrc:null,shutter:!1,minShutterEffectPassed:!0,clearPhotoInProgress:!1,facingMode:F.USER},{widgetMgr:r,element:o}=this.props,a=r.getFileUploaderStateValue(o);if(P(a))return l;const{uploadedFileInfo:n}=a;return P(n)||n.length===0?l:{files:n.map(s=>{const f=s.name,g=s.size,U=s.fileId,C=s.fileUrls;return new W(f,g,this.nextLocalFileId(),{type:"uploaded",fileId:U,fileUrls:C})}),imgSrc:n.length===0?"":this.RESTORED_FROM_WIDGET_STRING,shutter:!1,minShutterEffectPassed:!1,clearPhotoInProgress:!1,facingMode:F.USER}}componentWillUnmount(){this.formClearHelper.disconnect()}get status(){const l=r=>r.status.type==="uploading";return this.state.files.some(l)?"updating":"ready"}componentDidMount(){const l=this.createWidgetValue(),{element:r,widgetMgr:o,fragmentId:a}=this.props;o.getFileUploaderStateValue(r)===void 0&&o.setFileUploaderStateValue(r,l,{fromUi:!1},a)}createWidgetValue(){const l=this.state.files.filter(r=>r.status.type==="uploaded").map(r=>{const{name:o,size:a,status:n}=r;return new le({fileId:n.fileId,fileUrls:n.fileUrls,name:o,size:a})});return new de({uploadedFileInfo:l})}render(){var n;const{element:l,widgetMgr:r,disabled:o,width:a}=this.props;return this.formClearHelper.manageFormClearListener(r,l.formId,this.onFormCleared),R(D,{className:"stCameraInput","data-testid":"stCameraInput",children:[p(he,{label:l.label,disabled:o,labelVisibility:ce((n=l.labelVisibility)==null?void 0:n.value),children:l.help&&p(ue,{children:p(fe,{content:l.help,placement:B.TOP_RIGHT})})}),this.state.imgSrc?R(pe,{children:[p(O,{width:a,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&p(be,{src:this.state.imgSrc,alt:"Snapshot",opacity:this.state.shutter||!this.state.minShutterEffectPassed?"50%":"100%",width:a,height:a*9/16})}),p(H,{onClick:this.removeCapture,progress:this.getProgress(),disabled:!!this.getProgress()||o,children:this.getProgress()?"Uploading...":R(we,{children:[p(j,{content:N,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):p(Pe,{handleCapture:this.handleCapture,width:a,disabled:o,clearPhotoInProgress:this.state.clearPhotoInProgress,setClearPhotoInProgress:this.setClearPhotoInProgress,facingMode:this.state.facingMode,setFacingMode:this.setFacingMode,testOverride:this.props.testOverride})]})}nextLocalFileId(){return this.localFileIdCounter++}}function je(t,l){return fetch(t).then(r=>r.arrayBuffer()).then(r=>new File([r],l,{type:"image/jpeg"}))}export{Be as default};
|
1
|
+
import{r as y,E as _,_ as T,n as E,ay as J,z as R,j as p,bv as Q,bc as B,bq as K,b8 as Y,bp as j,bC as A,d as Z,g as ee,aN as te,y as re,bD as ie,bE as ae,al as oe,R as ne,aC as se,J as P,bm as le,bl as de,bs as ce,bF as ue,bt as fe,bu as he,F as pe}from"./index.gthzAzzy.js";import{a as V}from"./axios.upsvKRUO.js";import{F as ge}from"./FormClearHelper.LI0uGKXr.js";import{U as W}from"./UploadFileInfo.C-jY39rj.js";import{P as me,S as ve}from"./ProgressBar.CiuIhn-j.js";var z=y.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(_,T({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:l}),y.createElement("path",{d:"M.5 1c-.28 0-.5.23-.5.5v4c0 .28.23.5.5.5h5c.28 0 .5-.22.5-.5V4l1 1h1V2H7L6 3V1.5c0-.28-.22-.5-.5-.5h-5z"}))});z.displayName="Video";var N=y.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(_,T({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:l}),y.createElement("path",{d:"M1.41 0L0 1.41l.72.72L2.5 3.94.72 5.72 0 6.41l1.41 1.44.72-.72 1.81-1.81 1.78 1.81.69.72 1.44-1.44-.72-.69-1.81-1.78 1.81-1.81.72-.72L6.41 0l-.69.72L3.94 2.5 2.13.72 1.41 0z"}))});N.displayName="X";var $=y.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(_,T({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:l}),y.createElement("rect",{width:24,height:24,fill:"none"}),y.createElement("path",{d:"M20 5h-3.17l-1.24-1.35A1.99 1.99 0 0014.12 3H9.88c-.56 0-1.1.24-1.48.65L7.17 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-1.35 8.35l-2.79 2.79c-.32.32-.86.1-.86-.35v-1.75H9v1.75c0 .45-.54.67-.85.35l-2.79-2.79c-.2-.2-.2-.51 0-.71l2.79-2.79a.5.5 0 01.85.36v1.83h6v-1.83c0-.45.54-.67.85-.35l2.79 2.79c.2.19.2.51.01.7z"}))});$.displayName="SwitchCamera";var L;(function(t){t.XSMALL="xsmall",t.SMALL="small",t.MEDIUM="medium",t.LARGE="large"})(L||(L={}));function Se(t,l){switch(t){case"xsmall":return{padding:`${l.spacing.twoXS} ${l.spacing.sm}`,fontSize:l.fontSizes.sm};case"small":return{padding:`${l.spacing.twoXS} ${l.spacing.md}`};case"large":return{padding:`${l.spacing.md} ${l.spacing.md}`};default:return{padding:`${l.spacing.xs} ${l.spacing.md}`}}}const D=E("div",{target:"e47j7ja0"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),O=E("div",{target:"e47j7ja1"})(({theme:t,width:l})=>({backgroundColor:t.colors.secondaryBg,borderRadius:`${t.radii.default} ${t.radii.default} 0 0`,width:"100%",height:l*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),ye=E("p",{target:"e47j7ja2"})(({theme:t})=>({marginTop:t.spacing.sm,textAlign:"center"})),be=E("img",{target:"e47j7ja3"})(({theme:t,opacity:l})=>({borderRadius:`${t.radii.default} ${t.radii.default} 0 0`,objectFit:"contain",opacity:l})),Me=E("a",{target:"e47j7ja4"})(({theme:t})=>({color:t.colors.primary,display:"block",textDecoration:"none"})),we=E("span",{target:"e47j7ja5"})({display:"flex",alignItems:"center"}),Ce=E("div",{target:"e47j7ja6"})(({theme:t})=>({position:"absolute",top:t.spacing.lg,right:t.spacing.lg,zIndex:t.zIndices.priority,color:t.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),Ue=E("div",{target:"e47j7ja8"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),Ee=E("button",{target:"e47j7ja9"})(({theme:t})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:t.colors.lightenedBg05,border:`${t.sizes.borderWidth} solid ${t.colors.borderColor}`,borderRadius:`0 0 ${t.radii.default} ${t.radii.default}`,"&:hover":{borderColor:t.colors.primary,color:t.colors.primary},"&:active":{color:t.colors.white,borderColor:t.colors.primary,backgroundColor:t.colors.primary},"&:focus:not(:active)":{borderColor:t.colors.primary,color:t.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:t.colors.fadedText40},fontWeight:t.fontWeights.normal,padding:`${t.spacing.xs} ${t.spacing.md}`,margin:t.spacing.none,lineHeight:t.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:`0 0 0 0.2rem ${J(t.colors.primary,.5)}`},...Se("medium",t)}));function H({disabled:t,onClick:l,children:r,progress:o}){return R(Ee,{disabled:t||!1,onClick:l||(()=>{}),progress:o||null,"data-testid":"stCameraInputButton",children:[r,o&&p(Ue,{children:p(me,{value:o,size:ve.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})})]})}var F;(function(t){t.USER="user",t.ENVIRONMENT="environment"})(F||(F={}));const Ie=({switchFacingMode:t})=>p(Ce,{"data-testid":"stCameraInputSwitchButton",children:p(Q,{content:"Switch camera",placement:B.TOP_RIGHT,children:p(K,{kind:Y.MINIMAL,onClick:t,children:p(j,{content:$,size:"twoXL",color:A.white})})})});var G={exports:{}};(function(t,l){(function(o,a){t.exports=a(y)})(Z,function(r){return function(o){var a={};function n(s){if(a[s])return a[s].exports;var f=a[s]={i:s,l:!1,exports:{}};return o[s].call(f.exports,f,f.exports,n),f.l=!0,f.exports}return n.m=o,n.c=a,n.d=function(s,f,g){n.o(s,f)||Object.defineProperty(s,f,{enumerable:!0,get:g})},n.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},n.t=function(s,f){if(f&1&&(s=n(s)),f&8||f&4&&typeof s=="object"&&s&&s.__esModule)return s;var g=Object.create(null);if(n.r(g),Object.defineProperty(g,"default",{enumerable:!0,value:s}),f&2&&typeof s!="string")for(var U in s)n.d(g,U,(function(C){return s[C]}).bind(null,U));return g},n.n=function(s){var f=s&&s.__esModule?function(){return s.default}:function(){return s};return n.d(f,"a",f),f},n.o=function(s,f){return Object.prototype.hasOwnProperty.call(s,f)},n.p="",n(n.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(o,a,n){n.r(a);var s=n("react"),f=function(){var m=function(u,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,d){i.__proto__=d}||function(i,d){for(var c in d)d.hasOwnProperty(c)&&(i[c]=d[c])},m(u,e)};return function(u,e){m(u,e);function i(){this.constructor=u}u.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),g=function(){return g=Object.assign||function(m){for(var u,e=1,i=arguments.length;e<i;e++){u=arguments[e];for(var d in u)Object.prototype.hasOwnProperty.call(u,d)&&(m[d]=u[d])}return m},g.apply(this,arguments)},U=function(m,u){var e={};for(var i in m)Object.prototype.hasOwnProperty.call(m,i)&&u.indexOf(i)<0&&(e[i]=m[i]);if(m!=null&&typeof Object.getOwnPropertySymbols=="function")for(var d=0,i=Object.getOwnPropertySymbols(m);d<i.length;d++)u.indexOf(i[d])<0&&Object.prototype.propertyIsEnumerable.call(m,i[d])&&(e[i[d]]=m[i[d]]);return e};(function(){typeof window>"u"||(navigator.mediaDevices===void 0&&(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia===void 0&&(navigator.mediaDevices.getUserMedia=function(u){var e=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return e?new Promise(function(i,d){e.call(navigator,u,i,d)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function C(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var I=function(m){f(u,m);function u(e){var i=m.call(this,e)||this;return i.canvas=null,i.ctx=null,i.requestUserMediaId=0,i.unmounted=!1,i.state={hasUserMedia:!1},i}return u.prototype.componentDidMount=function(){var e=this,i=e.state,d=e.props;if(this.unmounted=!1,!C()){d.onUserMediaError("getUserMedia not supported");return}i.hasUserMedia||this.requestUserMedia(),d.children&&typeof d.children!="function"&&console.warn("children must be a function")},u.prototype.componentDidUpdate=function(e){var i=this.props;if(!C()){i.onUserMediaError("getUserMedia not supported");return}var d=JSON.stringify(e.audioConstraints)!==JSON.stringify(i.audioConstraints),c=JSON.stringify(e.videoConstraints)!==JSON.stringify(i.videoConstraints),b=e.minScreenshotWidth!==i.minScreenshotWidth,S=e.minScreenshotHeight!==i.minScreenshotHeight;(c||b||S)&&(this.canvas=null,this.ctx=null),(d||c)&&(this.stopAndCleanup(),this.requestUserMedia())},u.prototype.componentWillUnmount=function(){this.unmounted=!0,this.stopAndCleanup()},u.stopMediaStream=function(e){e&&(e.getVideoTracks&&e.getAudioTracks?(e.getVideoTracks().map(function(i){e.removeTrack(i),i.stop()}),e.getAudioTracks().map(function(i){e.removeTrack(i),i.stop()})):e.stop())},u.prototype.stopAndCleanup=function(){var e=this.state;e.hasUserMedia&&(u.stopMediaStream(this.stream),e.src&&window.URL.revokeObjectURL(e.src))},u.prototype.getScreenshot=function(e){var i=this,d=i.state,c=i.props;if(!d.hasUserMedia)return null;var b=this.getCanvas(e);return b&&b.toDataURL(c.screenshotFormat,c.screenshotQuality)},u.prototype.getCanvas=function(e){var i=this,d=i.state,c=i.props;if(!this.video||!d.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var b=this.video.videoWidth,S=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var h=b/S;b=c.minScreenshotWidth||this.video.clientWidth,S=b/h,c.minScreenshotHeight&&S<c.minScreenshotHeight&&(S=c.minScreenshotHeight,b=S*h)}this.canvas=document.createElement("canvas"),this.canvas.width=(e==null?void 0:e.width)||b,this.canvas.height=(e==null?void 0:e.height)||S,this.ctx=this.canvas.getContext("2d")}var w=this,M=w.ctx,v=w.canvas;return M&&v&&(v.width=(e==null?void 0:e.width)||v.width,v.height=(e==null?void 0:e.height)||v.height,c.mirrored&&(M.translate(v.width,0),M.scale(-1,1)),M.imageSmoothingEnabled=c.imageSmoothing,M.drawImage(this.video,0,0,(e==null?void 0:e.width)||v.width,(e==null?void 0:e.height)||v.height),c.mirrored&&(M.scale(-1,1),M.translate(-v.width,0))),v},u.prototype.requestUserMedia=function(){var e=this,i=this.props,d=function(S,h){var w={video:typeof h<"u"?h:!0};i.audio&&(w.audio=typeof S<"u"?S:!0),e.requestUserMediaId++;var M=e.requestUserMediaId;navigator.mediaDevices.getUserMedia(w).then(function(v){e.unmounted||M!==e.requestUserMediaId?u.stopMediaStream(v):e.handleUserMedia(null,v)}).catch(function(v){e.handleUserMedia(v)})};if("mediaDevices"in navigator)d(i.audioConstraints,i.videoConstraints);else{var c=function(S){return{optional:[{sourceId:S}]}},b=function(S){var h=S.deviceId;return typeof h=="string"?h:Array.isArray(h)&&h.length>0?h[0]:typeof h=="object"&&h.ideal?h.ideal:null};MediaStreamTrack.getSources(function(S){var h=null,w=null;S.forEach(function(x){x.kind==="audio"?h=x.id:x.kind==="video"&&(w=x.id)});var M=b(i.audioConstraints);M&&(h=M);var v=b(i.videoConstraints);v&&(w=v),d(c(h),c(w))})}},u.prototype.handleUserMedia=function(e,i){var d=this.props;if(e||!i){this.setState({hasUserMedia:!1}),d.onUserMediaError(e);return}this.stream=i;try{this.video&&(this.video.srcObject=i),this.setState({hasUserMedia:!0})}catch{this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(i)})}d.onUserMedia(i)},u.prototype.render=function(){var e=this,i=this,d=i.state,c=i.props,b=c.audio;c.forceScreenshotSourceSize,c.onUserMedia,c.onUserMediaError,c.screenshotFormat,c.screenshotQuality,c.minScreenshotWidth,c.minScreenshotHeight,c.audioConstraints,c.videoConstraints,c.imageSmoothing;var S=c.mirrored,h=c.style,w=h===void 0?{}:h,M=c.children,v=U(c,["audio","forceScreenshotSourceSize","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),x=S?g(g({},w),{transform:(w.transform||"")+" scaleX(-1)"}):w,q={getScreenshot:this.getScreenshot.bind(this)};return s.createElement(s.Fragment,null,s.createElement("video",g({autoPlay:!0,src:d.src,muted:!b,playsInline:!0,ref:function(X){e.video=X},style:x},v)),M&&M(q))},u.defaultProps={audio:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},u}(s.Component);a.default=I},react:function(o,a){o.exports=r}}).default})})(G);var Fe=G.exports;const Re=ee(Fe);var k;(function(t){t.PENDING="pending",t.SUCCESS="success",t.ERROR="error"})(k||(k={}));const xe=({width:t})=>R(O,{width:t,children:[p(j,{size:"threeXL",color:A.gray60,content:z}),R(ye,{children:["This app would like to use your camera.",p(Me,{href:ae,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),Pe=({handleCapture:t,width:l,disabled:r,clearPhotoInProgress:o,setClearPhotoInProgress:a,facingMode:n,setFacingMode:s,testOverride:f})=>{const[g,U]=y.useState(f||"pending"),C=y.useRef(null),[I,m]=y.useState(l),u=y.useCallback(te(1e3,m),[]);y.useEffect(()=>{u(l)},[l,u]);function e(){if(C.current!==null){const d=C.current.getScreenshot();t(d)}}const i=re();return R(D,{"data-testid":"stCameraInputWebcamComponent",children:[g!=="success"&&!r&&!o?p(xe,{width:I}):ie&&p(Ie,{switchFacingMode:s}),p(O,{"data-testid":"stCameraInputWebcamStyledBox",hidden:g!=="success"&&!r&&!o,width:I,children:!r&&p(Re,{audio:!1,ref:C,screenshotFormat:"image/jpeg",screenshotQuality:1,width:I,height:I*9/16,style:{borderRadius:`${i.radii.default} ${i.radii.default} 0 0`},onUserMediaError:()=>{U("error")},onUserMedia:()=>{U("success"),a(!1)},videoConstraints:{width:{ideal:I},facingMode:n}})}),p(H,{onClick:e,disabled:g!=="success"||r||o,children:"Take Photo"})]})},_e=150,Te=oe.getLogger("CameraInput");class Be extends ne.PureComponent{constructor(l){super(l),this.localFileIdCounter=1,this.RESTORED_FROM_WIDGET_STRING="RESTORED_FROM_WIDGET",this.formClearHelper=new ge,this.getProgress=()=>{if(this.state.files.length>0&&this.state.files[this.state.files.length-1].status.type==="uploading")return this.state.files[this.state.files.length-1].status.progress},this.setClearPhotoInProgress=r=>{this.setState({clearPhotoInProgress:r})},this.setFacingMode=()=>{this.setState(r=>({facingMode:r.facingMode===F.USER?F.ENVIRONMENT:F.USER}))},this.handleCapture=r=>{if(r===null)return Promise.resolve();this.setState({imgSrc:r,shutter:!0,minShutterEffectPassed:!1});const o=a=>new Promise(n=>setTimeout(n,a));return je(r,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(a=>this.props.uploadClient.fetchFileURLs([a]).then(n=>({file:a,fileUrls:n[0]}))).then(({file:a,fileUrls:n})=>this.uploadFile(n,a)).then(()=>o(_e)).then(()=>{this.setState((a,n)=>({imgSrc:r,shutter:a.shutter,minShutterEffectPassed:!0}))}).catch(a=>{Te.error(a)})},this.removeCapture=()=>{this.state.files.length!==0&&(this.state.files.forEach(r=>this.deleteFile(r.id)),this.setState({imgSrc:null,clearPhotoInProgress:!0}))},this.componentDidUpdate=()=>{if(this.status!=="ready")return;const r=this.createWidgetValue(),{element:o,widgetMgr:a,fragmentId:n}=this.props,s=a.getFileUploaderStateValue(o);se(r,s)||a.setFileUploaderStateValue(o,r,{fromUi:!0},n)},this.onFormCleared=()=>{this.setState({files:[]},()=>{const r=this.createWidgetValue();if(P(r))return;this.setState({imgSrc:null});const{widgetMgr:o,element:a,fragmentId:n}=this.props;o.setFileUploaderStateValue(a,r,{fromUi:!0},n)})},this.deleteFile=r=>{const o=this.getFile(r);P(o)||(o.status.type==="uploading"&&o.status.cancelToken.cancel(),o.status.type==="uploaded"&&o.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(o.status.fileUrls.deleteUrl),this.removeFile(r))},this.addFile=r=>{this.setState(o=>({files:[...o.files,r]}))},this.removeFile=r=>{this.setState(o=>({files:o.files.filter(a=>a.id!==r)}))},this.getFile=r=>this.state.files.find(o=>o.id===r),this.updateFile=(r,o)=>{this.setState(a=>({files:a.files.map(n=>n.id===r?o:n)}))},this.onUploadComplete=(r,o)=>{this.setState(()=>({shutter:!1}));const a=this.getFile(r);P(a)||a.status.type!=="uploading"||this.updateFile(a.id,a.setStatus({type:"uploaded",fileId:o.fileId,fileUrls:o}))},this.onUploadProgress=(r,o)=>{const a=this.getFile(o);if(P(a)||a.status.type!=="uploading")return;const n=Math.round(r.loaded*100/r.total);a.status.progress!==n&&this.updateFile(o,a.setStatus({type:"uploading",cancelToken:a.status.cancelToken,progress:n}))},this.reset=()=>{this.setState({files:[],imgSrc:null})},this.uploadFile=(r,o)=>{const a=V.CancelToken.source(),n=new W(o.name,o.size,this.nextLocalFileId(),{type:"uploading",cancelToken:a,progress:1});this.addFile(n),this.props.uploadClient.uploadFile(this.props.element,r.uploadUrl,o,s=>this.onUploadProgress(s,n.id),a.token).then(()=>this.onUploadComplete(n.id,r)).catch(s=>{V.isCancel(s)||this.updateFile(n.id,n.setStatus({type:"error",errorMessage:s?s.toString():"Unknown error"}))})},this.state=this.initialValue}get initialValue(){const l={files:[],imgSrc:null,shutter:!1,minShutterEffectPassed:!0,clearPhotoInProgress:!1,facingMode:F.USER},{widgetMgr:r,element:o}=this.props,a=r.getFileUploaderStateValue(o);if(P(a))return l;const{uploadedFileInfo:n}=a;return P(n)||n.length===0?l:{files:n.map(s=>{const f=s.name,g=s.size,U=s.fileId,C=s.fileUrls;return new W(f,g,this.nextLocalFileId(),{type:"uploaded",fileId:U,fileUrls:C})}),imgSrc:n.length===0?"":this.RESTORED_FROM_WIDGET_STRING,shutter:!1,minShutterEffectPassed:!1,clearPhotoInProgress:!1,facingMode:F.USER}}componentWillUnmount(){this.formClearHelper.disconnect()}get status(){const l=r=>r.status.type==="uploading";return this.state.files.some(l)?"updating":"ready"}componentDidMount(){const l=this.createWidgetValue(),{element:r,widgetMgr:o,fragmentId:a}=this.props;o.getFileUploaderStateValue(r)===void 0&&o.setFileUploaderStateValue(r,l,{fromUi:!1},a)}createWidgetValue(){const l=this.state.files.filter(r=>r.status.type==="uploaded").map(r=>{const{name:o,size:a,status:n}=r;return new le({fileId:n.fileId,fileUrls:n.fileUrls,name:o,size:a})});return new de({uploadedFileInfo:l})}render(){var n;const{element:l,widgetMgr:r,disabled:o,width:a}=this.props;return this.formClearHelper.manageFormClearListener(r,l.formId,this.onFormCleared),R(D,{className:"stCameraInput","data-testid":"stCameraInput",children:[p(he,{label:l.label,disabled:o,labelVisibility:ce((n=l.labelVisibility)==null?void 0:n.value),children:l.help&&p(ue,{children:p(fe,{content:l.help,placement:B.TOP_RIGHT})})}),this.state.imgSrc?R(pe,{children:[p(O,{width:a,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&p(be,{src:this.state.imgSrc,alt:"Snapshot",opacity:this.state.shutter||!this.state.minShutterEffectPassed?"50%":"100%",width:a,height:a*9/16})}),p(H,{onClick:this.removeCapture,progress:this.getProgress(),disabled:!!this.getProgress()||o,children:this.getProgress()?"Uploading...":R(we,{children:[p(j,{content:N,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):p(Pe,{handleCapture:this.handleCapture,width:a,disabled:o,clearPhotoInProgress:this.state.clearPhotoInProgress,setClearPhotoInProgress:this.setClearPhotoInProgress,facingMode:this.state.facingMode,setFacingMode:this.setFacingMode,testOverride:this.props.testOverride})]})}nextLocalFileId(){return this.localFileIdCounter++}}function je(t,l){return fetch(t).then(r=>r.arrayBuffer()).then(r=>new File([r],l,{type:"image/jpeg"}))}export{Be as default};
|