streamlit-nightly 1.45.2.dev20250614__py3-none-any.whl → 1.45.2.dev20250616__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.
Files changed (79) hide show
  1. streamlit/config.py +11 -0
  2. streamlit/elements/code.py +6 -4
  3. streamlit/elements/form.py +1 -2
  4. streamlit/runtime/credentials.py +3 -1
  5. streamlit/static/index.html +1 -1
  6. streamlit/static/manifest.json +218 -218
  7. streamlit/static/static/js/{ErrorOutline.esm.DeqDGwEO.js → ErrorOutline.esm.BBFVdWjb.js} +1 -1
  8. streamlit/static/static/js/{FileDownload.esm.--sYVXOa.js → FileDownload.esm.DvdwDAxp.js} +1 -1
  9. streamlit/static/static/js/{FileHelper.bloGbv2W.js → FileHelper.CjU1Ef50.js} +1 -1
  10. streamlit/static/static/js/{FormClearHelper.CYKg4prI.js → FormClearHelper.CIb6LGNE.js} +1 -1
  11. streamlit/static/static/js/{Hooks.B16qdpVx.js → Hooks.GJR4p5ub.js} +1 -1
  12. streamlit/static/static/js/{InputInstructions.DMO4B42t.js → InputInstructions.nsoutNDU.js} +1 -1
  13. streamlit/static/static/js/{ProgressBar.BH1ZwSEk.js → ProgressBar.DqtkCWgY.js} +1 -1
  14. streamlit/static/static/js/{RenderInPortalIfExists.IgdXklou.js → RenderInPortalIfExists.CocQHyjY.js} +1 -1
  15. streamlit/static/static/js/{Toolbar.DkIytKhC.js → Toolbar.UeCiz5bZ.js} +1 -1
  16. streamlit/static/static/js/{base-input.CAahP9oF.js → base-input.ChMOqefY.js} +1 -1
  17. streamlit/static/static/js/{checkbox.k1RuPBbZ.js → checkbox.mFAkcYlJ.js} +1 -1
  18. streamlit/static/static/js/{createSuper.ButEKFwQ.js → createSuper.CWlw4uuT.js} +1 -1
  19. streamlit/static/static/js/{data-grid-overlay-editor.7XGvfjSS.js → data-grid-overlay-editor.BRuPFGVT.js} +1 -1
  20. streamlit/static/static/js/{downloader.DSilreQW.js → downloader.D-JZV5KC.js} +1 -1
  21. streamlit/static/static/js/{es6.yDFTfvZI.js → es6.8aYd2mZD.js} +2 -2
  22. streamlit/static/static/js/{iframeResizer.contentWindow.BSskBUmQ.js → iframeResizer.contentWindow.jbTJNegv.js} +1 -1
  23. streamlit/static/static/js/{index.C0xV4csm.js → index.2vhUbWYE.js} +1 -1
  24. streamlit/static/static/js/{index.D6veSOdZ.js → index.45n3hxWl.js} +1 -1
  25. streamlit/static/static/js/{index.RQlZs06L.js → index.5VmqWrFJ.js} +1 -1
  26. streamlit/static/static/js/index.B5CU57Qf.js +783 -0
  27. streamlit/static/static/js/{index.ChhNrUVT.js → index.BSBLj6fd.js} +1 -1
  28. streamlit/static/static/js/{index.BsCehkC8.js → index.B_IVL8xE.js} +1 -1
  29. streamlit/static/static/js/{index.tnjDy4iv.js → index.B_K-sbDk.js} +1 -1
  30. streamlit/static/static/js/{index.Iveq4NZV.js → index.Bll2-rP6.js} +1 -1
  31. streamlit/static/static/js/{index.DqbaNLFW.js → index.BrZrTW9I.js} +1 -1
  32. streamlit/static/static/js/{index.DLBGcvEx.js → index.BuwwBXlt.js} +1 -1
  33. streamlit/static/static/js/{index.CKJtZooB.js → index.C-qKPIAc.js} +1 -1
  34. streamlit/static/static/js/{index.DNTQOI5W.js → index.C5Jk6yHy.js} +1 -1
  35. streamlit/static/static/js/{index.BG8RaQ8E.js → index.CBxfNa4S.js} +1 -1
  36. streamlit/static/static/js/{index.EgFq4OeP.js → index.CQG85lDO.js} +1 -1
  37. streamlit/static/static/js/{index.ClCtylIR.js → index.CeJjESM2.js} +1 -1
  38. streamlit/static/static/js/{index.DSpbUJvK.js → index.Cf2Ujw1i.js} +1 -1
  39. streamlit/static/static/js/{index.CIXRC_j_.js → index.CmYORNI1.js} +1 -1
  40. streamlit/static/static/js/{index.CzY5--PW.js → index.CrLOSpGd.js} +1 -1
  41. streamlit/static/static/js/{index.BZqoA_aJ.js → index.CwtQIKUg.js} +1 -1
  42. streamlit/static/static/js/{index.CWeNa-FP.js → index.D2DTU1aY.js} +1 -1
  43. streamlit/static/static/js/{index.D9muCjoC.js → index.D6aDPgRk.js} +1 -1
  44. streamlit/static/static/js/{index.BcW5X6V5.js → index.D7n0aj1W.js} +1 -1
  45. streamlit/static/static/js/{index.Cdi_Zw1a.js → index.D9LSzO5n.js} +1 -1
  46. streamlit/static/static/js/{index.Bo1tG5CG.js → index.Dat8JgZf.js} +5 -5
  47. streamlit/static/static/js/{index.BAXqDnQ9.js → index.DcylHZOn.js} +1 -1
  48. streamlit/static/static/js/{index.9VWuu9bJ.js → index.Ddznlirl.js} +1 -1
  49. streamlit/static/static/js/{index.BoHCDi97.js → index.DiKxaWW9.js} +1 -1
  50. streamlit/static/static/js/{index.ClCMQ4iK.js → index.DlBss_D9.js} +1 -1
  51. streamlit/static/static/js/{index.DslKxDZN.js → index.DwGCBH5W.js} +1 -1
  52. streamlit/static/static/js/{index.FC1jA29Z.js → index.EmgmixKr.js} +1 -1
  53. streamlit/static/static/js/{index.bQ9PFxvm.js → index.MuhC3L76.js} +1 -1
  54. streamlit/static/static/js/{index.BY47W7LH.js → index.RqdD1cln.js} +1 -1
  55. streamlit/static/static/js/{index.ChBsbacw.js → index.TEOqOk4H.js} +1 -1
  56. streamlit/static/static/js/{index.DGrpmtEI.js → index.ZJ-p6xZJ.js} +1 -1
  57. streamlit/static/static/js/{index.O4EQwJsZ.js → index._beSUPH2.js} +1 -1
  58. streamlit/static/static/js/{index.y-bXsZ3U.js → index.g86WIJtm.js} +1 -1
  59. streamlit/static/static/js/{index.80yI-jzZ.js → index.gcWbHnPE.js} +1 -1
  60. streamlit/static/static/js/{input.5dpw-Sqs.js → input.DXa_gBzj.js} +1 -1
  61. streamlit/static/static/js/{memory.8YWsO_82.js → memory.D5rOUj2Y.js} +1 -1
  62. streamlit/static/static/js/{mergeWith.1afHaDFE.js → mergeWith.DSXoP_ea.js} +1 -1
  63. streamlit/static/static/js/{number-overlay-editor.CrclsoQd.js → number-overlay-editor.DOlAMQ4z.js} +1 -1
  64. streamlit/static/static/js/{possibleConstructorReturn.Dq7g1SWn.js → possibleConstructorReturn.C8PlFdhp.js} +1 -1
  65. streamlit/static/static/js/{sandbox.ZlQ0WZlh.js → sandbox.Cbgzd0RE.js} +1 -1
  66. streamlit/static/static/js/{textarea.CY5cwdtO.js → textarea.CwmJHkZd.js} +1 -1
  67. streamlit/static/static/js/{timepicker.DMqTkd3V.js → timepicker.D-HemJVg.js} +1 -1
  68. streamlit/static/static/js/{toConsumableArray.Bm0yYM5M.js → toConsumableArray.K58gdyL6.js} +1 -1
  69. streamlit/static/static/js/{uniqueId.kDXXTYvS.js → uniqueId.D6CfbZfn.js} +1 -1
  70. streamlit/static/static/js/{useBasicWidgetState.ClCgm0D-.js → useBasicWidgetState.t6CdhaX9.js} +1 -1
  71. streamlit/static/static/js/{useOnInputChange.Cwcz7NJx.js → useOnInputChange.D_GNOmUw.js} +1 -1
  72. streamlit/static/static/js/{withFullScreenWrapper.CRbf9QMV.js → withFullScreenWrapper.DILaf-7C.js} +1 -1
  73. {streamlit_nightly-1.45.2.dev20250614.dist-info → streamlit_nightly-1.45.2.dev20250616.dist-info}/METADATA +1 -1
  74. {streamlit_nightly-1.45.2.dev20250614.dist-info → streamlit_nightly-1.45.2.dev20250616.dist-info}/RECORD +78 -78
  75. streamlit/static/static/js/index.VE3QHoXq.js +0 -783
  76. {streamlit_nightly-1.45.2.dev20250614.data → streamlit_nightly-1.45.2.dev20250616.data}/scripts/streamlit.cmd +0 -0
  77. {streamlit_nightly-1.45.2.dev20250614.dist-info → streamlit_nightly-1.45.2.dev20250616.dist-info}/WHEEL +0 -0
  78. {streamlit_nightly-1.45.2.dev20250614.dist-info → streamlit_nightly-1.45.2.dev20250616.dist-info}/entry_points.txt +0 -0
  79. {streamlit_nightly-1.45.2.dev20250614.dist-info → streamlit_nightly-1.45.2.dev20250616.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
1
- import{r as y,E as T,_ as O,n as I,J,C as F,j as f,bs as Q,b7 as L,bn as K,b2 as Y,bm as W,bz as z,d as Z,g as ee,aM as te,z as re,bA as ie,bB as oe,bC as ne,l as ae,aA as se,M as x,bj as le,bi as de,bp as ce,bD as ue,bq as he,br as pe,F as fe}from"./index.VE3QHoXq.js";import{a as j,U as k}from"./UploadFileInfo.0DCkpDDf.js";import{F as ge}from"./FormClearHelper.CYKg4prI.js";import{P as me,S as ve}from"./ProgressBar.BH1ZwSEk.js";var $=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},i,{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"}))});$.displayName="Video";var A=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},i,{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"}))});A.displayName="X";var N=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},i,{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"}))});N.displayName="SwitchCamera";function Se(i,l){switch(i){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 H=I("div",{target:"e14dwhi20"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),V=I("div",{target:"e14dwhi21"})(({theme:i,width:l})=>({backgroundColor:i.colors.secondaryBg,borderRadius:`${i.radii.default} ${i.radii.default} 0 0`,width:"100%",height:l*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),ye=I("p",{target:"e14dwhi22"})(({theme:i})=>({marginTop:i.spacing.sm,textAlign:"center"})),be=I("img",{target:"e14dwhi23"})(({theme:i,opacity:l})=>({borderRadius:`${i.radii.default} ${i.radii.default} 0 0`,objectFit:"contain",opacity:l})),we=I("a",{target:"e14dwhi24"})(({theme:i})=>({color:i.colors.primary,display:"block",textDecoration:"none"})),Me=I("span",{target:"e14dwhi25"})({display:"flex",alignItems:"center"}),Ce=I("div",{target:"e14dwhi26"})(({theme:i})=>({position:"absolute",top:i.spacing.lg,right:i.spacing.lg,zIndex:i.zIndices.priority,color:i.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),Ue=I("div",{target:"e14dwhi28"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),Ie=I("button",{target:"e14dwhi29"})(({theme:i})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:i.colors.lightenedBg05,border:`${i.sizes.borderWidth} solid ${i.colors.borderColor}`,borderRadius:`0 0 ${i.radii.default} ${i.radii.default}`,"&:hover":{borderColor:i.colors.primary,color:i.colors.primary},"&:active":{color:i.colors.white,borderColor:i.colors.primary,backgroundColor:i.colors.primary},"&:focus:not(:active)":{borderColor:i.colors.primary,color:i.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:i.colors.fadedText40,borderColor:i.colors.borderColor,backgroundColor:i.colors.lightenedBg05,cursor:"not-allowed"},fontWeight:i.fontWeights.normal,padding:`${i.spacing.xs} ${i.spacing.md}`,margin:i.spacing.none,lineHeight:i.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:`0 0 0 0.2rem ${J(i.colors.primary,.5)}`},...Se("medium",i)}));function Ee({disabled:i,onClick:l,children:t,progress:n}){return F(Ie,{disabled:i||!1,onClick:l||(()=>{}),progress:n||null,"data-testid":"stCameraInputButton",children:[t,n?f(Ue,{children:f(me,{value:n,size:ve.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})}):null]})}const D=y.memo(Ee);var R=function(i){return i.USER="user",i.ENVIRONMENT="environment",i}({});const Fe=({switchFacingMode:i})=>f(Ce,{"data-testid":"stCameraInputSwitchButton",children:f(Q,{content:"Switch camera",placement:L.TOP_RIGHT,children:f(K,{kind:Y.MINIMAL,onClick:i,children:f(W,{content:N,size:"twoXL",color:z.white})})})}),Pe=y.memo(Fe);var _={exports:{}},xe=_.exports,B;function Re(){return B||(B=1,function(i,l){(function(n,o){i.exports=o(Z())})(xe,function(t){return function(n){var o={};function a(s){if(o[s])return o[s].exports;var h=o[s]={i:s,l:!1,exports:{}};return n[s].call(h.exports,h,h.exports,a),h.l=!0,h.exports}return a.m=n,a.c=o,a.d=function(s,h,g){a.o(s,h)||Object.defineProperty(s,h,{enumerable:!0,get:g})},a.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},a.t=function(s,h){if(h&1&&(s=a(s)),h&8||h&4&&typeof s=="object"&&s&&s.__esModule)return s;var g=Object.create(null);if(a.r(g),Object.defineProperty(g,"default",{enumerable:!0,value:s}),h&2&&typeof s!="string")for(var U in s)a.d(g,U,(function(C){return s[C]}).bind(null,U));return g},a.n=function(s){var h=s&&s.__esModule?function(){return s.default}:function(){return s};return a.d(h,"a",h),h},a.o=function(s,h){return Object.prototype.hasOwnProperty.call(s,h)},a.p="",a(a.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(n,o,a){a.r(o);var s=a("react"),h=function(){var m=function(u,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,d){r.__proto__=d}||function(r,d){for(var c in d)d.hasOwnProperty(c)&&(r[c]=d[c])},m(u,e)};return function(u,e){m(u,e);function r(){this.constructor=u}u.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}}(),g=function(){return g=Object.assign||function(m){for(var u,e=1,r=arguments.length;e<r;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 r in m)Object.prototype.hasOwnProperty.call(m,r)&&u.indexOf(r)<0&&(e[r]=m[r]);if(m!=null&&typeof Object.getOwnPropertySymbols=="function")for(var d=0,r=Object.getOwnPropertySymbols(m);d<r.length;d++)u.indexOf(r[d])<0&&Object.prototype.propertyIsEnumerable.call(m,r[d])&&(e[r[d]]=m[r[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(r,d){e.call(navigator,u,r,d)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function C(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var E=function(m){h(u,m);function u(e){var r=m.call(this,e)||this;return r.canvas=null,r.ctx=null,r.requestUserMediaId=0,r.unmounted=!1,r.state={hasUserMedia:!1},r}return u.prototype.componentDidMount=function(){var e=this,r=e.state,d=e.props;if(this.unmounted=!1,!C()){d.onUserMediaError("getUserMedia not supported");return}r.hasUserMedia||this.requestUserMedia(),d.children&&typeof d.children!="function"&&console.warn("children must be a function")},u.prototype.componentDidUpdate=function(e){var r=this.props;if(!C()){r.onUserMediaError("getUserMedia not supported");return}var d=JSON.stringify(e.audioConstraints)!==JSON.stringify(r.audioConstraints),c=JSON.stringify(e.videoConstraints)!==JSON.stringify(r.videoConstraints),w=e.minScreenshotWidth!==r.minScreenshotWidth,S=e.minScreenshotHeight!==r.minScreenshotHeight;(c||w||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(r){e.removeTrack(r),r.stop()}),e.getAudioTracks().map(function(r){e.removeTrack(r),r.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 r=this,d=r.state,c=r.props;if(!d.hasUserMedia)return null;var w=this.getCanvas(e);return w&&w.toDataURL(c.screenshotFormat,c.screenshotQuality)},u.prototype.getCanvas=function(e){var r=this,d=r.state,c=r.props;if(!this.video||!d.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var w=this.video.videoWidth,S=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var v=w/S;w=c.minScreenshotWidth||this.video.clientWidth,S=w/v,c.minScreenshotHeight&&S<c.minScreenshotHeight&&(S=c.minScreenshotHeight,w=S*v)}this.canvas=document.createElement("canvas"),this.canvas.width=(e==null?void 0:e.width)||w,this.canvas.height=(e==null?void 0:e.height)||S,this.ctx=this.canvas.getContext("2d")}var M=this,b=M.ctx,p=M.canvas;return b&&p&&(p.width=(e==null?void 0:e.width)||p.width,p.height=(e==null?void 0:e.height)||p.height,c.mirrored&&(b.translate(p.width,0),b.scale(-1,1)),b.imageSmoothingEnabled=c.imageSmoothing,b.drawImage(this.video,0,0,(e==null?void 0:e.width)||p.width,(e==null?void 0:e.height)||p.height),c.mirrored&&(b.scale(-1,1),b.translate(-p.width,0))),p},u.prototype.requestUserMedia=function(){var e=this,r=this.props,d=function(S,v){var M={video:typeof v<"u"?v:!0};r.audio&&(M.audio=typeof S<"u"?S:!0),e.requestUserMediaId++;var b=e.requestUserMediaId;navigator.mediaDevices.getUserMedia(M).then(function(p){e.unmounted||b!==e.requestUserMediaId?u.stopMediaStream(p):e.handleUserMedia(null,p)}).catch(function(p){e.handleUserMedia(p)})};if("mediaDevices"in navigator)d(r.audioConstraints,r.videoConstraints);else{var c=function(S){return{optional:[{sourceId:S}]}},w=function(S){var v=S.deviceId;return typeof v=="string"?v:Array.isArray(v)&&v.length>0?v[0]:typeof v=="object"&&v.ideal?v.ideal:null};MediaStreamTrack.getSources(function(S){var v=null,M=null;S.forEach(function(P){P.kind==="audio"?v=P.id:P.kind==="video"&&(M=P.id)});var b=w(r.audioConstraints);b&&(v=b);var p=w(r.videoConstraints);p&&(M=p),d(c(v),c(M))})}},u.prototype.handleUserMedia=function(e,r){var d=this.props;if(e||!r){this.setState({hasUserMedia:!1}),d.onUserMediaError(e);return}this.stream=r;try{this.video&&(this.video.srcObject=r),this.setState({hasUserMedia:!0})}catch{this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(r)})}d.onUserMedia(r)},u.prototype.render=function(){var e=this,r=this,d=r.state,c=r.props,w=c.audio;c.forceScreenshotSourceSize;var S=c.disablePictureInPicture;c.onUserMedia,c.onUserMediaError,c.screenshotFormat,c.screenshotQuality,c.minScreenshotWidth,c.minScreenshotHeight,c.audioConstraints,c.videoConstraints,c.imageSmoothing;var v=c.mirrored,M=c.style,b=M===void 0?{}:M,p=c.children,P=U(c,["audio","forceScreenshotSourceSize","disablePictureInPicture","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),G=v?g(g({},b),{transform:(b.transform||"")+" scaleX(-1)"}):b,q={getScreenshot:this.getScreenshot.bind(this)};return s.createElement(s.Fragment,null,s.createElement("video",g({autoPlay:!0,disablePictureInPicture:S,src:d.src,muted:!w,playsInline:!0,ref:function(X){e.video=X},style:G},P)),p&&p(q))},u.defaultProps={audio:!1,disablePictureInPicture:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},u}(s.Component);o.default=E},react:function(n,o){n.exports=t}}).default})}(_)),_.exports}var _e=Re();const Te=ee(_e),Oe=({width:i})=>F(V,{width:i,children:[f(W,{size:"threeXL",color:z.gray60,content:$}),F(ye,{children:["This app would like to use your camera.",f(we,{href:oe,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),We=({handleCapture:i,width:l,disabled:t,clearPhotoInProgress:n,setClearPhotoInProgress:o,facingMode:a,setFacingMode:s,testOverride:h})=>{const[g,U]=y.useState(h||"pending"),C=y.useRef(null),[E,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();i(d)}}const r=re();return F(H,{"data-testid":"stCameraInputWebcamComponent",children:[g!=="success"&&!t&&!n?f(Oe,{width:E}):ie.isMobile&&f(Pe,{switchFacingMode:s}),f(V,{"data-testid":"stCameraInputWebcamStyledBox",hidden:g!=="success"&&!t&&!n,width:E,children:!t&&f(Te,{audio:!1,ref:C,screenshotFormat:"image/jpeg",screenshotQuality:1,width:E,height:E*9/16,style:{borderRadius:`${r.radii.default} ${r.radii.default} 0 0`},onUserMediaError:()=>{U("error")},onUserMedia:()=>{U("success"),o(!1)},videoConstraints:{width:{ideal:E},facingMode:a}})}),f(D,{onClick:e,disabled:g!=="success"||t||n,children:"Take Photo"})]})},Ve=y.memo(We),je=150,ke=ae.getLogger("CameraInput");class Be extends y.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=t=>{this.setState({clearPhotoInProgress:t})},this.setFacingMode=()=>{this.setState(t=>({facingMode:t.facingMode===R.USER?R.ENVIRONMENT:R.USER}))},this.handleCapture=t=>{if(t===null)return Promise.resolve();this.setState({imgSrc:t,shutter:!0,minShutterEffectPassed:!1});const n=o=>new Promise(a=>setTimeout(a,o));return Le(t,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(o=>this.props.uploadClient.fetchFileURLs([o]).then(a=>({file:o,fileUrls:a[0]}))).then(({file:o,fileUrls:a})=>this.uploadFile(a,o)).then(()=>n(je)).then(()=>{this.setState((o,a)=>({imgSrc:t,shutter:o.shutter,minShutterEffectPassed:!0}))}).catch(o=>{ke.error(o)})},this.removeCapture=()=>{this.state.files.length!==0&&(this.state.files.forEach(t=>this.deleteFile(t.id)),this.setState({imgSrc:null,clearPhotoInProgress:!0}))},this.componentDidUpdate=()=>{if(this.status!=="ready")return;const t=this.createWidgetValue(),{element:n,widgetMgr:o,fragmentId:a}=this.props,s=o.getFileUploaderStateValue(n);se(t,s)||o.setFileUploaderStateValue(n,t,{fromUi:!0},a)},this.onFormCleared=()=>{this.setState({files:[]},()=>{const t=this.createWidgetValue();if(x(t))return;this.setState({imgSrc:null});const{widgetMgr:n,element:o,fragmentId:a}=this.props;n.setFileUploaderStateValue(o,t,{fromUi:!0},a)})},this.deleteFile=t=>{const n=this.getFile(t);x(n)||(n.status.type==="uploading"&&n.status.cancelToken.cancel(),n.status.type==="uploaded"&&n.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(n.status.fileUrls.deleteUrl),this.removeFile(t))},this.addFile=t=>{this.setState(n=>({files:[...n.files,t]}))},this.removeFile=t=>{this.setState(n=>({files:n.files.filter(o=>o.id!==t)}))},this.getFile=t=>this.state.files.find(n=>n.id===t),this.updateFile=(t,n)=>{this.setState(o=>({files:o.files.map(a=>a.id===t?n:a)}))},this.onUploadComplete=(t,n)=>{this.setState(()=>({shutter:!1}));const o=this.getFile(t);x(o)||o.status.type!=="uploading"||this.updateFile(o.id,o.setStatus({type:"uploaded",fileId:n.fileId,fileUrls:n}))},this.onUploadProgress=(t,n)=>{const o=this.getFile(n);if(x(o)||o.status.type!=="uploading")return;const a=Math.round(t.loaded*100/t.total);o.status.progress!==a&&this.updateFile(n,o.setStatus({type:"uploading",cancelToken:o.status.cancelToken,progress:a}))},this.reset=()=>{this.setState({files:[],imgSrc:null})},this.uploadFile=(t,n)=>{const o=j.CancelToken.source(),a=new k(n.name,n.size,this.nextLocalFileId(),{type:"uploading",cancelToken:o,progress:1});this.addFile(a),this.props.uploadClient.uploadFile(this.props.element,t.uploadUrl,n,s=>this.onUploadProgress(s,a.id),o.token).then(()=>this.onUploadComplete(a.id,t)).catch(s=>{j.isCancel(s)||this.updateFile(a.id,a.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:R.USER},{widgetMgr:t,element:n}=this.props,o=t.getFileUploaderStateValue(n);if(x(o))return l;const{uploadedFileInfo:a}=o;return x(a)||a.length===0?l:{files:a.map(s=>{const h=s.name,g=s.size,U=s.fileId,C=s.fileUrls;return new k(h,g,this.nextLocalFileId(),{type:"uploaded",fileId:U,fileUrls:C})}),imgSrc:a.length===0?"":this.RESTORED_FROM_WIDGET_STRING,shutter:!1,minShutterEffectPassed:!1,clearPhotoInProgress:!1,facingMode:R.USER}}componentWillUnmount(){this.formClearHelper.disconnect()}get status(){const l=t=>t.status.type==="uploading";return this.state.files.some(l)?"updating":"ready"}componentDidMount(){const l=this.createWidgetValue(),{element:t,widgetMgr:n,fragmentId:o}=this.props;n.getFileUploaderStateValue(t)===void 0&&n.setFileUploaderStateValue(t,l,{fromUi:!1},o)}createWidgetValue(){const l=this.state.files.filter(t=>t.status.type==="uploaded").map(t=>{const{name:n,size:o,status:a}=t;return new le({fileId:a.fileId,fileUrls:a.fileUrls,name:n,size:o})});return new de({uploadedFileInfo:l})}render(){var a;const{element:l,widgetMgr:t,disabled:n,width:o}=this.props;return this.formClearHelper.manageFormClearListener(t,l.formId,this.onFormCleared),F(H,{className:"stCameraInput","data-testid":"stCameraInput",children:[f(pe,{label:l.label,disabled:n,labelVisibility:ce((a=l.labelVisibility)==null?void 0:a.value),children:l.help&&f(ue,{children:f(he,{content:l.help,placement:L.TOP_RIGHT})})}),this.state.imgSrc?F(fe,{children:[f(V,{width:o,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&f(be,{src:this.state.imgSrc,alt:"Snapshot",opacity:this.state.shutter||!this.state.minShutterEffectPassed?"50%":"100%",width:o,height:o*9/16})}),f(D,{onClick:this.removeCapture,progress:this.getProgress(),disabled:!!this.getProgress()||n,children:this.getProgress()?"Uploading...":F(Me,{children:[f(W,{content:A,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):f(Ve,{handleCapture:this.handleCapture,width:o,disabled:n,clearPhotoInProgress:this.state.clearPhotoInProgress,setClearPhotoInProgress:this.setClearPhotoInProgress,facingMode:this.state.facingMode,setFacingMode:this.setFacingMode,testOverride:this.props.testOverride})]})}nextLocalFileId(){return this.localFileIdCounter++}}function Le(i,l){return fetch(i).then(t=>t.arrayBuffer()).then(t=>new File([t],l,{type:"image/jpeg"}))}const He=ne(Be);export{He as default};
1
+ import{r as y,E as T,_ as O,n as I,J,C as F,j as f,bs as Q,b7 as L,bn as K,b2 as Y,bm as W,bz as z,d as Z,g as ee,aM as te,z as re,bA as ie,bB as oe,bC as ne,l as ae,aA as se,M as x,bj as le,bi as de,bp as ce,bD as ue,bq as he,br as pe,F as fe}from"./index.B5CU57Qf.js";import{a as j,U as k}from"./UploadFileInfo.0DCkpDDf.js";import{F as ge}from"./FormClearHelper.CIb6LGNE.js";import{P as me,S as ve}from"./ProgressBar.DqtkCWgY.js";var $=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},i,{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"}))});$.displayName="Video";var A=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},i,{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"}))});A.displayName="X";var N=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},i,{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"}))});N.displayName="SwitchCamera";function Se(i,l){switch(i){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 H=I("div",{target:"e14dwhi20"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),V=I("div",{target:"e14dwhi21"})(({theme:i,width:l})=>({backgroundColor:i.colors.secondaryBg,borderRadius:`${i.radii.default} ${i.radii.default} 0 0`,width:"100%",height:l*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),ye=I("p",{target:"e14dwhi22"})(({theme:i})=>({marginTop:i.spacing.sm,textAlign:"center"})),be=I("img",{target:"e14dwhi23"})(({theme:i,opacity:l})=>({borderRadius:`${i.radii.default} ${i.radii.default} 0 0`,objectFit:"contain",opacity:l})),we=I("a",{target:"e14dwhi24"})(({theme:i})=>({color:i.colors.primary,display:"block",textDecoration:"none"})),Me=I("span",{target:"e14dwhi25"})({display:"flex",alignItems:"center"}),Ce=I("div",{target:"e14dwhi26"})(({theme:i})=>({position:"absolute",top:i.spacing.lg,right:i.spacing.lg,zIndex:i.zIndices.priority,color:i.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),Ue=I("div",{target:"e14dwhi28"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),Ie=I("button",{target:"e14dwhi29"})(({theme:i})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:i.colors.lightenedBg05,border:`${i.sizes.borderWidth} solid ${i.colors.borderColor}`,borderRadius:`0 0 ${i.radii.default} ${i.radii.default}`,"&:hover":{borderColor:i.colors.primary,color:i.colors.primary},"&:active":{color:i.colors.white,borderColor:i.colors.primary,backgroundColor:i.colors.primary},"&:focus:not(:active)":{borderColor:i.colors.primary,color:i.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:i.colors.fadedText40,borderColor:i.colors.borderColor,backgroundColor:i.colors.lightenedBg05,cursor:"not-allowed"},fontWeight:i.fontWeights.normal,padding:`${i.spacing.xs} ${i.spacing.md}`,margin:i.spacing.none,lineHeight:i.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:`0 0 0 0.2rem ${J(i.colors.primary,.5)}`},...Se("medium",i)}));function Ee({disabled:i,onClick:l,children:t,progress:n}){return F(Ie,{disabled:i||!1,onClick:l||(()=>{}),progress:n||null,"data-testid":"stCameraInputButton",children:[t,n?f(Ue,{children:f(me,{value:n,size:ve.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})}):null]})}const D=y.memo(Ee);var R=function(i){return i.USER="user",i.ENVIRONMENT="environment",i}({});const Fe=({switchFacingMode:i})=>f(Ce,{"data-testid":"stCameraInputSwitchButton",children:f(Q,{content:"Switch camera",placement:L.TOP_RIGHT,children:f(K,{kind:Y.MINIMAL,onClick:i,children:f(W,{content:N,size:"twoXL",color:z.white})})})}),Pe=y.memo(Fe);var _={exports:{}},xe=_.exports,B;function Re(){return B||(B=1,function(i,l){(function(n,o){i.exports=o(Z())})(xe,function(t){return function(n){var o={};function a(s){if(o[s])return o[s].exports;var h=o[s]={i:s,l:!1,exports:{}};return n[s].call(h.exports,h,h.exports,a),h.l=!0,h.exports}return a.m=n,a.c=o,a.d=function(s,h,g){a.o(s,h)||Object.defineProperty(s,h,{enumerable:!0,get:g})},a.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},a.t=function(s,h){if(h&1&&(s=a(s)),h&8||h&4&&typeof s=="object"&&s&&s.__esModule)return s;var g=Object.create(null);if(a.r(g),Object.defineProperty(g,"default",{enumerable:!0,value:s}),h&2&&typeof s!="string")for(var U in s)a.d(g,U,(function(C){return s[C]}).bind(null,U));return g},a.n=function(s){var h=s&&s.__esModule?function(){return s.default}:function(){return s};return a.d(h,"a",h),h},a.o=function(s,h){return Object.prototype.hasOwnProperty.call(s,h)},a.p="",a(a.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(n,o,a){a.r(o);var s=a("react"),h=function(){var m=function(u,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,d){r.__proto__=d}||function(r,d){for(var c in d)d.hasOwnProperty(c)&&(r[c]=d[c])},m(u,e)};return function(u,e){m(u,e);function r(){this.constructor=u}u.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}}(),g=function(){return g=Object.assign||function(m){for(var u,e=1,r=arguments.length;e<r;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 r in m)Object.prototype.hasOwnProperty.call(m,r)&&u.indexOf(r)<0&&(e[r]=m[r]);if(m!=null&&typeof Object.getOwnPropertySymbols=="function")for(var d=0,r=Object.getOwnPropertySymbols(m);d<r.length;d++)u.indexOf(r[d])<0&&Object.prototype.propertyIsEnumerable.call(m,r[d])&&(e[r[d]]=m[r[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(r,d){e.call(navigator,u,r,d)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function C(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var E=function(m){h(u,m);function u(e){var r=m.call(this,e)||this;return r.canvas=null,r.ctx=null,r.requestUserMediaId=0,r.unmounted=!1,r.state={hasUserMedia:!1},r}return u.prototype.componentDidMount=function(){var e=this,r=e.state,d=e.props;if(this.unmounted=!1,!C()){d.onUserMediaError("getUserMedia not supported");return}r.hasUserMedia||this.requestUserMedia(),d.children&&typeof d.children!="function"&&console.warn("children must be a function")},u.prototype.componentDidUpdate=function(e){var r=this.props;if(!C()){r.onUserMediaError("getUserMedia not supported");return}var d=JSON.stringify(e.audioConstraints)!==JSON.stringify(r.audioConstraints),c=JSON.stringify(e.videoConstraints)!==JSON.stringify(r.videoConstraints),w=e.minScreenshotWidth!==r.minScreenshotWidth,S=e.minScreenshotHeight!==r.minScreenshotHeight;(c||w||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(r){e.removeTrack(r),r.stop()}),e.getAudioTracks().map(function(r){e.removeTrack(r),r.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 r=this,d=r.state,c=r.props;if(!d.hasUserMedia)return null;var w=this.getCanvas(e);return w&&w.toDataURL(c.screenshotFormat,c.screenshotQuality)},u.prototype.getCanvas=function(e){var r=this,d=r.state,c=r.props;if(!this.video||!d.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var w=this.video.videoWidth,S=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var v=w/S;w=c.minScreenshotWidth||this.video.clientWidth,S=w/v,c.minScreenshotHeight&&S<c.minScreenshotHeight&&(S=c.minScreenshotHeight,w=S*v)}this.canvas=document.createElement("canvas"),this.canvas.width=(e==null?void 0:e.width)||w,this.canvas.height=(e==null?void 0:e.height)||S,this.ctx=this.canvas.getContext("2d")}var M=this,b=M.ctx,p=M.canvas;return b&&p&&(p.width=(e==null?void 0:e.width)||p.width,p.height=(e==null?void 0:e.height)||p.height,c.mirrored&&(b.translate(p.width,0),b.scale(-1,1)),b.imageSmoothingEnabled=c.imageSmoothing,b.drawImage(this.video,0,0,(e==null?void 0:e.width)||p.width,(e==null?void 0:e.height)||p.height),c.mirrored&&(b.scale(-1,1),b.translate(-p.width,0))),p},u.prototype.requestUserMedia=function(){var e=this,r=this.props,d=function(S,v){var M={video:typeof v<"u"?v:!0};r.audio&&(M.audio=typeof S<"u"?S:!0),e.requestUserMediaId++;var b=e.requestUserMediaId;navigator.mediaDevices.getUserMedia(M).then(function(p){e.unmounted||b!==e.requestUserMediaId?u.stopMediaStream(p):e.handleUserMedia(null,p)}).catch(function(p){e.handleUserMedia(p)})};if("mediaDevices"in navigator)d(r.audioConstraints,r.videoConstraints);else{var c=function(S){return{optional:[{sourceId:S}]}},w=function(S){var v=S.deviceId;return typeof v=="string"?v:Array.isArray(v)&&v.length>0?v[0]:typeof v=="object"&&v.ideal?v.ideal:null};MediaStreamTrack.getSources(function(S){var v=null,M=null;S.forEach(function(P){P.kind==="audio"?v=P.id:P.kind==="video"&&(M=P.id)});var b=w(r.audioConstraints);b&&(v=b);var p=w(r.videoConstraints);p&&(M=p),d(c(v),c(M))})}},u.prototype.handleUserMedia=function(e,r){var d=this.props;if(e||!r){this.setState({hasUserMedia:!1}),d.onUserMediaError(e);return}this.stream=r;try{this.video&&(this.video.srcObject=r),this.setState({hasUserMedia:!0})}catch{this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(r)})}d.onUserMedia(r)},u.prototype.render=function(){var e=this,r=this,d=r.state,c=r.props,w=c.audio;c.forceScreenshotSourceSize;var S=c.disablePictureInPicture;c.onUserMedia,c.onUserMediaError,c.screenshotFormat,c.screenshotQuality,c.minScreenshotWidth,c.minScreenshotHeight,c.audioConstraints,c.videoConstraints,c.imageSmoothing;var v=c.mirrored,M=c.style,b=M===void 0?{}:M,p=c.children,P=U(c,["audio","forceScreenshotSourceSize","disablePictureInPicture","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),G=v?g(g({},b),{transform:(b.transform||"")+" scaleX(-1)"}):b,q={getScreenshot:this.getScreenshot.bind(this)};return s.createElement(s.Fragment,null,s.createElement("video",g({autoPlay:!0,disablePictureInPicture:S,src:d.src,muted:!w,playsInline:!0,ref:function(X){e.video=X},style:G},P)),p&&p(q))},u.defaultProps={audio:!1,disablePictureInPicture:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},u}(s.Component);o.default=E},react:function(n,o){n.exports=t}}).default})}(_)),_.exports}var _e=Re();const Te=ee(_e),Oe=({width:i})=>F(V,{width:i,children:[f(W,{size:"threeXL",color:z.gray60,content:$}),F(ye,{children:["This app would like to use your camera.",f(we,{href:oe,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),We=({handleCapture:i,width:l,disabled:t,clearPhotoInProgress:n,setClearPhotoInProgress:o,facingMode:a,setFacingMode:s,testOverride:h})=>{const[g,U]=y.useState(h||"pending"),C=y.useRef(null),[E,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();i(d)}}const r=re();return F(H,{"data-testid":"stCameraInputWebcamComponent",children:[g!=="success"&&!t&&!n?f(Oe,{width:E}):ie.isMobile&&f(Pe,{switchFacingMode:s}),f(V,{"data-testid":"stCameraInputWebcamStyledBox",hidden:g!=="success"&&!t&&!n,width:E,children:!t&&f(Te,{audio:!1,ref:C,screenshotFormat:"image/jpeg",screenshotQuality:1,width:E,height:E*9/16,style:{borderRadius:`${r.radii.default} ${r.radii.default} 0 0`},onUserMediaError:()=>{U("error")},onUserMedia:()=>{U("success"),o(!1)},videoConstraints:{width:{ideal:E},facingMode:a}})}),f(D,{onClick:e,disabled:g!=="success"||t||n,children:"Take Photo"})]})},Ve=y.memo(We),je=150,ke=ae.getLogger("CameraInput");class Be extends y.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=t=>{this.setState({clearPhotoInProgress:t})},this.setFacingMode=()=>{this.setState(t=>({facingMode:t.facingMode===R.USER?R.ENVIRONMENT:R.USER}))},this.handleCapture=t=>{if(t===null)return Promise.resolve();this.setState({imgSrc:t,shutter:!0,minShutterEffectPassed:!1});const n=o=>new Promise(a=>setTimeout(a,o));return Le(t,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(o=>this.props.uploadClient.fetchFileURLs([o]).then(a=>({file:o,fileUrls:a[0]}))).then(({file:o,fileUrls:a})=>this.uploadFile(a,o)).then(()=>n(je)).then(()=>{this.setState((o,a)=>({imgSrc:t,shutter:o.shutter,minShutterEffectPassed:!0}))}).catch(o=>{ke.error(o)})},this.removeCapture=()=>{this.state.files.length!==0&&(this.state.files.forEach(t=>this.deleteFile(t.id)),this.setState({imgSrc:null,clearPhotoInProgress:!0}))},this.componentDidUpdate=()=>{if(this.status!=="ready")return;const t=this.createWidgetValue(),{element:n,widgetMgr:o,fragmentId:a}=this.props,s=o.getFileUploaderStateValue(n);se(t,s)||o.setFileUploaderStateValue(n,t,{fromUi:!0},a)},this.onFormCleared=()=>{this.setState({files:[]},()=>{const t=this.createWidgetValue();if(x(t))return;this.setState({imgSrc:null});const{widgetMgr:n,element:o,fragmentId:a}=this.props;n.setFileUploaderStateValue(o,t,{fromUi:!0},a)})},this.deleteFile=t=>{const n=this.getFile(t);x(n)||(n.status.type==="uploading"&&n.status.cancelToken.cancel(),n.status.type==="uploaded"&&n.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(n.status.fileUrls.deleteUrl),this.removeFile(t))},this.addFile=t=>{this.setState(n=>({files:[...n.files,t]}))},this.removeFile=t=>{this.setState(n=>({files:n.files.filter(o=>o.id!==t)}))},this.getFile=t=>this.state.files.find(n=>n.id===t),this.updateFile=(t,n)=>{this.setState(o=>({files:o.files.map(a=>a.id===t?n:a)}))},this.onUploadComplete=(t,n)=>{this.setState(()=>({shutter:!1}));const o=this.getFile(t);x(o)||o.status.type!=="uploading"||this.updateFile(o.id,o.setStatus({type:"uploaded",fileId:n.fileId,fileUrls:n}))},this.onUploadProgress=(t,n)=>{const o=this.getFile(n);if(x(o)||o.status.type!=="uploading")return;const a=Math.round(t.loaded*100/t.total);o.status.progress!==a&&this.updateFile(n,o.setStatus({type:"uploading",cancelToken:o.status.cancelToken,progress:a}))},this.reset=()=>{this.setState({files:[],imgSrc:null})},this.uploadFile=(t,n)=>{const o=j.CancelToken.source(),a=new k(n.name,n.size,this.nextLocalFileId(),{type:"uploading",cancelToken:o,progress:1});this.addFile(a),this.props.uploadClient.uploadFile(this.props.element,t.uploadUrl,n,s=>this.onUploadProgress(s,a.id),o.token).then(()=>this.onUploadComplete(a.id,t)).catch(s=>{j.isCancel(s)||this.updateFile(a.id,a.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:R.USER},{widgetMgr:t,element:n}=this.props,o=t.getFileUploaderStateValue(n);if(x(o))return l;const{uploadedFileInfo:a}=o;return x(a)||a.length===0?l:{files:a.map(s=>{const h=s.name,g=s.size,U=s.fileId,C=s.fileUrls;return new k(h,g,this.nextLocalFileId(),{type:"uploaded",fileId:U,fileUrls:C})}),imgSrc:a.length===0?"":this.RESTORED_FROM_WIDGET_STRING,shutter:!1,minShutterEffectPassed:!1,clearPhotoInProgress:!1,facingMode:R.USER}}componentWillUnmount(){this.formClearHelper.disconnect()}get status(){const l=t=>t.status.type==="uploading";return this.state.files.some(l)?"updating":"ready"}componentDidMount(){const l=this.createWidgetValue(),{element:t,widgetMgr:n,fragmentId:o}=this.props;n.getFileUploaderStateValue(t)===void 0&&n.setFileUploaderStateValue(t,l,{fromUi:!1},o)}createWidgetValue(){const l=this.state.files.filter(t=>t.status.type==="uploaded").map(t=>{const{name:n,size:o,status:a}=t;return new le({fileId:a.fileId,fileUrls:a.fileUrls,name:n,size:o})});return new de({uploadedFileInfo:l})}render(){var a;const{element:l,widgetMgr:t,disabled:n,width:o}=this.props;return this.formClearHelper.manageFormClearListener(t,l.formId,this.onFormCleared),F(H,{className:"stCameraInput","data-testid":"stCameraInput",children:[f(pe,{label:l.label,disabled:n,labelVisibility:ce((a=l.labelVisibility)==null?void 0:a.value),children:l.help&&f(ue,{children:f(he,{content:l.help,placement:L.TOP_RIGHT})})}),this.state.imgSrc?F(fe,{children:[f(V,{width:o,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&f(be,{src:this.state.imgSrc,alt:"Snapshot",opacity:this.state.shutter||!this.state.minShutterEffectPassed?"50%":"100%",width:o,height:o*9/16})}),f(D,{onClick:this.removeCapture,progress:this.getProgress(),disabled:!!this.getProgress()||n,children:this.getProgress()?"Uploading...":F(Me,{children:[f(W,{content:A,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):f(Ve,{handleCapture:this.handleCapture,width:o,disabled:n,clearPhotoInProgress:this.state.clearPhotoInProgress,setClearPhotoInProgress:this.setClearPhotoInProgress,facingMode:this.state.facingMode,setFacingMode:this.setFacingMode,testOverride:this.props.testOverride})]})}nextLocalFileId(){return this.localFileIdCounter++}}function Le(i,l){return fetch(i).then(t=>t.arrayBuffer()).then(t=>new File([t],l,{type:"image/jpeg"}))}const He=ne(Be);export{He as default};
@@ -1 +1 @@
1
- import{n as c,r as C,aD as S,C as p,j as i,aC as E,l as y}from"./index.VE3QHoXq.js";import{w as L,E as W}from"./withFullScreenWrapper.CRbf9QMV.js";import{S as h,T as v}from"./Toolbar.DkIytKhC.js";const b=c("div",{target:"evl31sl0"})(({theme:e})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:e.spacing.lg,maxWidth:"100%",width:"fit-content"})),T=c("div",{target:"evl31sl1"})(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"stretch",width:"auto",flexGrow:0,">img":{borderRadius:e.radii.default}})),F=c("div",{target:"evl31sl2"})(({theme:e})=>({textAlign:"center",marginTop:e.spacing.xs,wordWrap:"break-word",padding:e.spacing.threeXS})),j=y.getLogger("ImageList");function D({element:e,endpoints:g,disableFullscreenMode:u}){const{expanded:s,width:w,height:l,expand:x,collapse:f}=S(W),m=w||0;let o;const r=e.width;if([-1,-3,-4].includes(r))o=void 0;else if([-2,-5].includes(r))o=m;else if(r>0)o=r;else throw Error(`Invalid image width: ${r}`);const t={};l&&s?(t.maxHeight=l,t.objectFit="contain",t.width="100%"):(t.width=o??"100%",t.maxWidth="100%");const I=n=>{const a=n.currentTarget.src;j.error(`Client Error: Image source error - ${a}`),g.sendClientErrorToHost("Image","Image source failed to load","onerror triggered",a)};return p(h,{width:m,height:l,useContainerWidth:s,topCentered:!0,children:[i(v,{target:h,isFullScreen:s,onExpand:x,onCollapse:f,disableFullscreenMode:u}),i(b,{className:"stImage","data-testid":"stImage",children:e.imgs.map((n,a)=>{const d=n;return p(T,{"data-testid":"stImageContainer",children:[i("img",{style:t,src:g.buildMediaURL(d.url),alt:a.toString(),onError:I}),d.caption&&i(F,{"data-testid":"stImageCaption",style:t,children:i(E,{source:d.caption,allowHTML:!1,isCaption:!0,isLabel:!0})})]},a)})})]})}const G=L(D),$=C.memo(G);export{$ as default};
1
+ import{n as c,r as C,aD as S,C as p,j as i,aC as E,l as y}from"./index.B5CU57Qf.js";import{w as L,E as W}from"./withFullScreenWrapper.DILaf-7C.js";import{S as h,T as v}from"./Toolbar.UeCiz5bZ.js";const b=c("div",{target:"evl31sl0"})(({theme:e})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:e.spacing.lg,maxWidth:"100%",width:"fit-content"})),T=c("div",{target:"evl31sl1"})(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"stretch",width:"auto",flexGrow:0,">img":{borderRadius:e.radii.default}})),F=c("div",{target:"evl31sl2"})(({theme:e})=>({textAlign:"center",marginTop:e.spacing.xs,wordWrap:"break-word",padding:e.spacing.threeXS})),j=y.getLogger("ImageList");function D({element:e,endpoints:g,disableFullscreenMode:u}){const{expanded:s,width:w,height:l,expand:x,collapse:f}=S(W),m=w||0;let o;const r=e.width;if([-1,-3,-4].includes(r))o=void 0;else if([-2,-5].includes(r))o=m;else if(r>0)o=r;else throw Error(`Invalid image width: ${r}`);const t={};l&&s?(t.maxHeight=l,t.objectFit="contain",t.width="100%"):(t.width=o??"100%",t.maxWidth="100%");const I=n=>{const a=n.currentTarget.src;j.error(`Client Error: Image source error - ${a}`),g.sendClientErrorToHost("Image","Image source failed to load","onerror triggered",a)};return p(h,{width:m,height:l,useContainerWidth:s,topCentered:!0,children:[i(v,{target:h,isFullScreen:s,onExpand:x,onCollapse:f,disableFullscreenMode:u}),i(b,{className:"stImage","data-testid":"stImage",children:e.imgs.map((n,a)=>{const d=n;return p(T,{"data-testid":"stImageContainer",children:[i("img",{style:t,src:g.buildMediaURL(d.url),alt:a.toString(),onError:I}),d.caption&&i(F,{"data-testid":"stImageCaption",style:t,children:i(E,{source:d.caption,allowHTML:!1,isCaption:!0,isLabel:!0})})]},a)})})]})}const G=L(D),$=C.memo(G);export{$ as default};