import{f as cr}from"./index-BJMTVygn.js";import{O as ur}from"./OdysseyStorybookThemeDecorator-BuDiOG2V.js";import{f as m}from"./fieldComponentPropsMetaData-BqbNLw6V.js";import{u as S,h as d,K as rr}from"./OdysseyThemeProvider-Bh0Bu-2o.js";import{r as o}from"./index-NdkWRN8K.js";import{M as $}from"./Button-BEA5U6Tg.js";import{M as mr}from"./Field-DH3L8v09.js";import{d as gr}from"./Typography-Cz6D417Y.js";import{j as t}from"./jsx-runtime-CnH95YSl.js";import{M as hr}from"./MuiPropsContext-DhRylJZk.js";import{M as fr}from"./Tooltip-CsVWtVfL.js";import{I as br}from"./IconButton-5qShmnSr.js";import{M as xr,a as B}from"./Upload-CfzP_Muq.js";import"./index-BJTM6NaI.js";import"./OdysseyProvider-qIn9QVYS.js";import"./_commonjsHelpers-gnU0ypJ3.js";import"./BaseButton-DYZHKnV3.js";import"./Button-BzIwUmSM.js";import"./ButtonBase-BNqa2TMD.js";import"./useIsFocusVisible-DH0qxT5e.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-CJ6Ie9dp.js";import"./TransitionGroupContext-DAL84N7p.js";import"./Box-1mvP3NLW.js";import"./Box-BcMTQ_R2.js";import"./createBox-Dxawkfow.js";import"./List-CmjR1pNu.js";import"./ListItem-C0ExFtXb.js";import"./utils-iop7lDec.js";import"./useFormControl-BMISTZuX.js";import"./FormLabel-CiGre9wK.js";import"./isHostComponent-DVu5iVWx.js";import"./ScreenReaderText-CebALBsG.js";import"./visuallyHidden-Dan1xhjv.js";import"./FormHelperText-CsNAE1E3.js";import"./FieldHint-B3Jif_Up.js";import"./useUniqueId-Bsgqe1tm.js";import"./createUniqueId-ByTaVY63.js";import"./Typography-ClQ35Rr-.js";import"./Tooltip-Cq2rQGbD.js";import"./Grow-C8kUeGCY.js";import"./utils-kUZVaD1e.js";import"./index-B5xazMy1.js";import"./index-DieBXP3Z.js";import"./getReactElementRef-DsIevm5t.js";import"./resolveComponentProps-DXQ8X87i.js";import"./useControlled-NQulfz4l.js";import"./Popper-BARIxJrI.js";import"./popper-BVOCD5jc.js";import"./ownerDocument-DW-IO8s5.js";import"./Portal-C6D59xAE.js";/*!
 * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const Cr=d.div(({odysseyDesignTokens:r})=>({marginBlockEnd:r.Spacing3,padding:r.Spacing3,backgroundColor:r.HueNeutral50,borderRadius:"50%",svg:{display:"flex",width:r.Spacing8,height:r.Spacing8}})),Fr=()=>{const r=S();return t.jsx(Cr,{"aria-hidden":"true",odysseyDesignTokens:r,children:t.jsxs("svg",{"aria-hidden":"true",fill:"none",viewBox:"0 0 44 45",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M32.0763 11.001C29.3564 3.7855 21.6595 -0.565827 13.7765 0.726748C5.35441 2.10773 -0.676662 9.50714 0.0603005 17.8612C0.441865 22.1865 2.56458 25.9787 5.71703 28.614L8.28246 25.545C5.90122 23.5544 4.32811 20.7209 4.04483 17.5097C3.50262 11.3633 7.94433 5.73648 14.4238 4.67404C20.9164 3.60944 27.0806 7.52016 28.6895 13.5191C28.9239 14.3932 29.7162 15.001 30.6212 15.001H32.9114C36.8985 15.001 39.9997 18.0938 39.9997 21.7505C39.9997 24.3423 38.4576 26.6352 36.1259 27.7678L37.8736 31.3658C41.4737 29.6171 43.9997 25.9917 43.9997 21.7505C43.9997 15.7428 38.963 11.001 32.9114 11.001H32.0763Z",fill:r.HueNeutral200}),t.jsx("path",{d:"M23.9994 29.3277V44.5H19.9994V29.3289L14.4142 34.9141L11.5858 32.0857L19.7373 23.9342C20.9869 22.6845 23.0131 22.6845 24.2627 23.9342L32.4142 32.0857L29.5858 34.9141L23.9994 29.3277Z",fill:r.HueNeutral200})]})})},tr=o.memo(Fr);tr.displayName="FileUploadIllustration";const jr=d.div(({isDisabled:r,odysseyDesignTokens:e})=>({color:r?e.TypographyColorDisabled:"inherit",marginBlockStart:e.Spacing2,pointerEvents:r?"none":"auto"})),vr=d.div({display:"flex",justifyContent:"space-between",alignItems:"center",button:{transform:"scale(0)"},"&:hover, &:focus-within, &:focus":{button:{transform:"scale(1)"}}},({odysseyDesignTokens:r})=>({padding:`${r.Spacing1} ${r.Spacing2}`,borderRadius:r.BorderRadiusMain,transition:`background-color ${r.TransitionTimingMain}`,"&:hover, &:focus-within":{backgroundColor:r.HueNeutral100},"&:focus":{borderColor:r.FocusOutlineColorPrimary,boxShadow:`0 0 0 2px ${r.FocusOutlineColorPrimary}`,outline:`${r.FocusOutlineWidthMain} ${r.FocusOutlineStyle} transparent`}})),Ir=({name:r,onFileRemove:e})=>{const{t:s}=rr(),a=S(),p=o.useCallback(()=>{e==null||e(r)},[e,r]),c=o.useCallback(M=>t.jsx(br,{...M,"aria-label":s("fileupload.removefile.text"),onClick:p,size:"small",children:t.jsx(xr,{})}),[p,s]);return t.jsxs(vr,{odysseyDesignTokens:a,tabIndex:0,children:[r,t.jsx(fr,{ariaType:"description",placement:"top",text:s("fileupload.removefile.text"),children:t.jsx(hr.Consumer,{children:c})})]})},Sr=({fileNames:r,isDisabled:e,onFileRemove:s})=>{const a=S();return t.jsx(jr,{"data-file-preview-container":"true",isDisabled:e,odysseyDesignTokens:a,children:r==null?void 0:r.map((p,c)=>t.jsx(Ir,{name:p,onFileRemove:s},`${c}-${p}`))})},er=o.memo(Sr);er.displayName="FileUploadPreview";/*!
 * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const H=["single","multiple"],D=["button","dragAndDrop","dragAndDropWithIcon"],or=d.div({position:"relative",alignSelf:"flex-start",input:{position:"absolute",width:"100%",height:"100%",opacity:0}}),Mr=d(or)({display:"flex",alignSelf:"unset",alignItems:"center",justifyContent:"center","&:has(input:focus)":{borderStyle:"solid"}},({hasError:r,odysseyDesignTokens:e})=>({padding:`${e.Spacing6} ${e.Spacing3}`,border:r?`1px solid ${e.PaletteDangerMain}`:`1px dashed ${e.HueNeutral300}`,borderRadius:e.BorderRadiusMain,transition:`border-color ${e.TransitionTimingMain}, box-shadow ${e.TransitionTimingMain}`,"&:hover":{borderColor:e.HueNeutral700},"&:has(input:focus)":{borderColor:e.FocusOutlineColorPrimary,boxShadow:`0 0 0 1px ${e.FocusOutlineColorPrimary}`,outline:`${e.FocusOutlineWidthMain} ${e.FocusOutlineStyle} transparent`,outlineOffset:e.FocusOutlineOffsetTight},"&:has(input:disabled)":{backgroundColor:e.HueNeutral50,border:`1px solid ${e.BorderColorDisabled}`,color:e.TypographyColorDisabled,"&:hover":{borderColor:e.BorderColorDisabled}}})),Ar=d.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}),wr=d.div({textAlign:"center"}),yr=({acceptedFileTypes:r,errorMessage:e,id:s,isDisabled:a=!1,isFullWidth:p,isOptional:c,hint:M,HintLinkComponent:ar,label:nr,onChange:w,type:g,variant:h})=>{const y=S(),{t:f}=rr(),b=o.useRef(null),[n,U]=o.useState([]);o.useEffect(()=>{w(n)},[n,w]);const W=o.useCallback(i=>{const{files:l}=i.target;if(l&&l.length>0){const u=g==="multiple"?n.concat(Array.from(l)):Array.from(l).slice();U(u)}i.target.value=""},[g,n]),A=o.useCallback(()=>{var i;(i=b.current)==null||i.click()},[b]),lr=o.useCallback(i=>{const l=n.filter(u=>u.name!==i);U(l)},[n]),sr=o.useCallback(({ariaDescribedBy:i,errorMessageElementId:l,id:u,labelElementId:pr})=>{const dr=r==null?void 0:r.join(","),O=()=>t.jsx("input",{accept:dr,"aria-describedby":i,"aria-errormessage":l,"aria-labelledby":pr,disabled:a,id:u,multiple:g==="multiple",onChange:W,ref:b,title:"",type:"file"});return h==="button"?t.jsx(t.Fragment,{children:t.jsxs(or,{children:[t.jsx(O,{}),t.jsx($,{isDisabled:a,label:f("fileupload.button.text"),onClick:A,startIcon:t.jsx(B,{}),variant:"secondary"})]})}):t.jsx(t.Fragment,{children:t.jsxs(Mr,{hasError:!!e,odysseyDesignTokens:y,children:[t.jsx(O,{}),t.jsxs(Ar,{children:[h==="dragAndDropWithIcon"&&t.jsx(tr,{}),t.jsx(wr,{children:t.jsx(gr,{color:"textSecondary",children:f("fileupload.prompt.text")})}),t.jsx($,{isDisabled:a,label:f("fileupload.button.text"),onClick:A,startIcon:t.jsx(B,{}),variant:"secondary"})]})]})})},[r,e,a,b,y,A,f,g,W,h]);return t.jsxs(t.Fragment,{children:[t.jsx(mr,{errorMessage:e,fieldType:"single",hasVisibleLabel:!0,hint:M,HintLinkComponent:ar,id:s,isDisabled:a,isFullWidth:p&&h!=="button",isOptional:c,label:nr,renderFieldComponent:sr}),n.length>0&&t.jsx(er,{fileNames:n.map(i=>i.name),isDisabled:a,onFileRemove:lr})]})},ir=o.memo(yr);ir.displayName="FileUploader";/*!
 * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const At={component:ir,decorators:[ur],tags:["autodocs"],argTypes:{acceptedFileTypes:{description:"An array of file types the user is able to upload. See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept#unique_file_type_specifiers for examples",table:{type:{summary:"string[]"}}},type:{options:H,control:{type:"radio"},description:"If `multiple`, the user can upload multiple files",table:{type:{summary:H.join(" | ")}}},errorMessage:m.errorMessage,hint:m.hint,id:m.id,isDisabled:m.isDisabled,isFullWidth:m.isFullWidth,label:{control:"text",description:"The label text for the FileUploader",table:{type:{summary:"string"}},type:{required:!0,name:"string"}},onChange:{description:"Callback fired when a file is uploaded or deleted",table:{type:{summary:"(files: File[]) => void"}},type:{name:"string",required:!0}},variant:{options:D,control:{type:"radio"},description:"How the component appears visually",table:{type:{summary:D.join(" | ")}},type:{name:"string",required:!0}}},args:{hint:"Maybe some helpful text about what format to use",label:"Upload your files here",onChange:cr()}},x={args:{variant:"button"}},C={args:{type:"multiple",variant:"dragAndDropWithIcon"}},F={args:{variant:"dragAndDrop"}},j={args:{variant:"dragAndDropWithIcon"}},v={args:{type:"multiple",variant:"dragAndDropWithIcon"}},I={args:{acceptedFileTypes:[".jpg",".png"],variant:"dragAndDropWithIcon"}};var L,z,P;x.parameters={...x.parameters,docs:{...(L=x.parameters)==null?void 0:L.docs,source:{originalSource:`{
  args: {
    variant: "button"
  }
}`,...(P=(z=x.parameters)==null?void 0:z.docs)==null?void 0:P.source}}};var E,N,R;C.parameters={...C.parameters,docs:{...(E=C.parameters)==null?void 0:E.docs,source:{originalSource:`{
  args: {
    type: "multiple",
    variant: "dragAndDropWithIcon"
  }
}`,...(R=(N=C.parameters)==null?void 0:N.docs)==null?void 0:R.source}}};var _,q,T;F.parameters={...F.parameters,docs:{...(_=F.parameters)==null?void 0:_.docs,source:{originalSource:`{
  args: {
    variant: "dragAndDrop"
  }
}`,...(T=(q=F.parameters)==null?void 0:q.docs)==null?void 0:T.source}}};var V,Z,K;j.parameters={...j.parameters,docs:{...(V=j.parameters)==null?void 0:V.docs,source:{originalSource:`{
  args: {
    variant: "dragAndDropWithIcon"
  }
}`,...(K=(Z=j.parameters)==null?void 0:Z.docs)==null?void 0:K.source}}};var k,G,J;v.parameters={...v.parameters,docs:{...(k=v.parameters)==null?void 0:k.docs,source:{originalSource:`{
  args: {
    type: "multiple",
    variant: "dragAndDropWithIcon"
  }
}`,...(J=(G=v.parameters)==null?void 0:G.docs)==null?void 0:J.source}}};var Q,X,Y;I.parameters={...I.parameters,docs:{...(Q=I.parameters)==null?void 0:Q.docs,source:{originalSource:`{
  args: {
    acceptedFileTypes: [".jpg", ".png"],
    variant: "dragAndDropWithIcon"
  }
}`,...(Y=(X=I.parameters)==null?void 0:X.docs)==null?void 0:Y.source}}};const wt=["ButtonOnly","DragAndDropWithIcon","DragAndDropWithoutIcon","SingleFileAllowed","MultipleFileAllowed","SpecificFileTypes"];export{x as ButtonOnly,C as DragAndDropWithIcon,F as DragAndDropWithoutIcon,v as MultipleFileAllowed,j as SingleFileAllowed,I as SpecificFileTypes,wt as __namedExportsOrder,At as default};
