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,GAAI,CAAC;IAC9E,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAEvC,OAAO,CACN,aAAK,GAAG,EAAC,MAAM,EAAC,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC;QACxD,2BACC,OAAO,EAAE,QAAQ,CAAC,GAAG,EACrB,IAAI,EAAC,aAAa,IACd,oBAAoB,CAAC,IAAI,CAAC,qBACf,GAAG,GAAG,EAAE,mBACR,GAAG,GAAG,EAAE,mBACR,GAAG,KAAK,EAAE,oBACT,GAAG,MAAM,EAAE,EAC3B,EAAE,EAAE,QAAQ,KAEX,cAAc,CAAC,OAAO,CAAC,CACnB;QACL,UAAU,CAAC,CAAC,CAAC,cAAM,OAAO,EAAE,QAAQ,CAAC,MAAM,IAAG,MAAM,CAAQ,CAAC,CAAC,CAAC,IAAI,CAC/D,CACN,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { RenderResult } from '@dojo/framework/core/interfaces';\nimport { create, tsx } from '@dojo/framework/core/vdom';\n\nimport theme from '../middleware/theme';\nimport * as css from '../theme/default/progress.m.css';\nimport { formatAriaProperties } from '../common/util';\n\nexport interface ProgressProperties {\n\t/** Custom aria attributes */\n\taria?: { [key: string]: string | null };\n\t/** Value used to calculate percent width */\n\tmax?: number;\n\t/** Value used to calculate percent width */\n\tmin?: number;\n\t/** Toggles visibility of progress bar output */\n\tshowOutput?: boolean;\n\t/** The current value */\n\tvalue: number;\n\t/** Value used to supply a dom id to the element with role=\"progressbar\" */\n\twidgetId?: string;\n}\n\nexport interface ProgressChildren {\n\toutput?(value: number, percent: number): RenderResult;\n}\n\nconst factory = create({ theme })\n\t.properties<ProgressProperties>()\n\t.children<ProgressChildren | undefined>();\n\nexport const Progress = factory(function Progress({\n\tchildren,\n\tid,\n\tproperties,\n\tmiddleware: { theme }\n}) {\n\tconst themeCss = theme.classes(css);\n\tconst {\n\t\taria = {},\n\t\tvalue,\n\t\tshowOutput = true,\n\t\tmax = 100,\n\t\tmin = 0,\n\t\twidgetId = `progress-${id}`\n\t} = properties();\n\n\tconst _output = (value: number, percent: number) => {\n\t\tconst { output } = children()[0] || ({} as ProgressChildren);\n\t\treturn output ? output(value, percent) : `${percent}%`;\n\t};\n\n\tconst renderProgress = (percent: number) => {\n\t\treturn <div classes={themeCss.progress} styles={{ width: `${percent}%` }} />;\n\t};\n\n\tconst percent = Math.round(((value - min) / (max - min)) * 100);\n\tconst output = _output(value, percent);\n\n\treturn (\n\t\t<div key=\"root\" classes={[theme.variant(), themeCss.root]}>\n\t\t\t<div\n\t\t\t\tclasses={themeCss.bar}\n\t\t\t\trole=\"progressbar\"\n\t\t\t\t{...formatAriaProperties(aria)}\n\t\t\t\taria-valuemin={`${min}`}\n\t\t\t\taria-valuemax={`${max}`}\n\t\t\t\taria-valuenow={`${value}`}\n\t\t\t\taria-valuetext={`${output}`}\n\t\t\t\tid={widgetId}\n\t\t\t>\n\t\t\t\t{renderProgress(percent)}\n\t\t\t</div>\n\t\t\t{showOutput ? <span classes={themeCss.output}>{output}</span> : null}\n\t\t</div>\n\t);\n});\n\nexport default Progress;\n"]}