@poovit-banton/speech-recognition-sdk 1.0.0 → 1.0.1
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.
- package/dist/lib/speech-recognition-sdk.cjs.js +2 -7
- package/dist/lib/speech-recognition-sdk.cjs.js.map +1 -1
- package/dist/lib/speech-recognition-sdk.es.js +341 -600
- package/dist/lib/speech-recognition-sdk.es.js.map +1 -1
- package/dist/lib/speech-recognition-sdk.umd.js +2 -7
- package/dist/lib/speech-recognition-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
(function(h,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],i):(h=typeof globalThis<"u"?globalThis:h||self,i(h.SpeechRecognitionSDK={},h.React))})(this,(function(h,i){"use strict";function q(){return typeof window>"u"?!1:!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function $(){return typeof window>"u"?null:window.SpeechRecognition||window.webkitSpeechRecognition||null}async function ee(){try{return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(s=>s.stop()),!0}catch{return!1}}async function fe(){try{return(await navigator.mediaDevices.enumerateDevices()).some(s=>s.kind==="audioinput")}catch{return!1}}function he(){return["th-TH","en-US","en-GB","en-AU","zh-CN","zh-TW","ja-JP","ko-KR","vi-VN","id-ID","ms-MY","fr-FR","de-DE","es-ES","pt-BR","ru-RU","ar-SA","hi-IN"]}function ge(r){return`${Math.round(r*100)}%`}const xe={language:"th-TH",continuous:!0,interimResults:!0,maxAlternatives:1};function J(r={}){const{config:s={},callbacks:p={}}=r,[a,l]=i.useState(!1),[u,y]=i.useState(""),[b,c]=i.useState(""),[T,v]=i.useState(""),[R,w]=i.useState(null),[_,k]=i.useState(!0),g=i.useRef(null),n=i.useRef(p);i.useEffect(()=>{n.current=p},[p]);const j=q(),U=i.useCallback(async M=>{if(!j){w("Speech recognition is not supported in this browser");return}if(!await ee()){w("Microphone permission denied"),k(!1);return}g.current&&g.current.abort();const V=$();if(!V)return;const S=new V,C={...xe,...s,...M};S.lang=C.language||"th-TH",S.continuous=C.continuous??!0,S.interimResults=C.interimResults??!0,S.maxAlternatives=C.maxAlternatives??1,S.onstart=()=>{l(!0),w(null),n.current.onStart?.()},S.onend=()=>{l(!1),n.current.onEnd?.()},S.onerror=A=>{const F=me(A.error);w(F),l(!1),n.current.onError?.(F)},S.onresult=A=>{let F="",H="";for(let D=A.resultIndex;D<A.results.length;D++){const O=A.results[D],B=O[0].transcript;O.isFinal?(H+=B,n.current.onResult?.({transcript:B,confidence:O[0].confidence,isFinal:!0})):F+=B}c(F),v(D=>{const O=D+H,B=O+F;return y(B),n.current.onTranscriptChange?.(B),O})},g.current=S,S.start()},[j,s]),E=i.useCallback(()=>{g.current&&g.current.stop()},[]),I=i.useCallback(()=>{g.current&&g.current.abort(),l(!1)},[]),L=i.useCallback(()=>{y(""),c(""),v("")},[]);return i.useEffect(()=>()=>{g.current&&g.current.abort()},[]),{isListening:a,transcript:u,interimTranscript:b,finalTranscript:T,isSupported:j,isMicrophoneAvailable:_,error:R,startListening:U,stopListening:E,abortListening:I,resetTranscript:L}}function me(r){return{"not-allowed":"Microphone permission was denied","no-speech":"No speech was detected","audio-capture":"No microphone was found",network:"Network error occurred",aborted:"Speech recognition was aborted","language-not-supported":"Language is not supported","service-not-allowed":"Speech recognition service is not allowed"}[r]||`Speech recognition error: ${r}`}var W={exports:{}},z={};var te;function ye(){if(te)return z;te=1;var r=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function p(a,l,u){var y=null;if(u!==void 0&&(y=""+u),l.key!==void 0&&(y=""+l.key),"key"in l){u={};for(var b in l)b!=="key"&&(u[b]=l[b])}else u=l;return l=u.ref,{$$typeof:r,type:a,key:y,ref:l!==void 0?l:null,props:u}}return z.Fragment=s,z.jsx=p,z.jsxs=p,z}var N={};var re;function _e(){return re||(re=1,process.env.NODE_ENV!=="production"&&(function(){function r(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case n:return"Fragment";case U:return"Profiler";case j:return"StrictMode";case M:return"Suspense";case Y:return"SuspenseList";case C:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case g:return"Portal";case I:return e.displayName||"Context";case E:return(e._context.displayName||"Context")+".Consumer";case L:var o=e.render;return e=e.displayName,e||(e=o.displayName||o.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return o=e.displayName||null,o!==null?o:r(e.type)||"Memo";case S:o=e._payload,e=e._init;try{return r(e(o))}catch{}}return null}function s(e){return""+e}function p(e){try{s(e);var o=!1}catch{o=!0}if(o){o=console;var f=o.error,x=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return f.call(o,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",x),s(e)}}function a(e){if(e===n)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===S)return"<...>";try{var o=r(e);return o?"<"+o+">":"<...>"}catch{return"<...>"}}function l(){var e=F.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function y(e){if(H.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function b(e,o){function f(){B||(B=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",o))}f.isReactWarning=!0,Object.defineProperty(e,"key",{get:f,configurable:!0})}function c(){var e=r(this.type);return ce[e]||(ce[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function T(e,o,f,x,Z,Q){var m=f.ref;return e={$$typeof:k,type:e,key:o,props:f,_owner:x},(m!==void 0?m:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:c}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function v(e,o,f,x,Z,Q){var m=o.children;if(m!==void 0)if(x)if(D(m)){for(x=0;x<m.length;x++)R(m[x]);Object.freeze&&Object.freeze(m)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else R(m);if(H.call(o,"key")){m=r(e);var G=Object.keys(o).filter(function(Me){return Me!=="key"});x=0<G.length?"{key: someKey, "+G.join(": ..., ")+": ...}":"{key: someKey}",ue[m+x]||(G=0<G.length?"{"+G.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
-
let props = %s;
|
|
3
|
-
<%s {...props} />
|
|
4
|
-
React keys must be passed directly to JSX without using spread:
|
|
5
|
-
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,x,m,G,m),ue[m+x]=!0)}if(m=null,f!==void 0&&(p(f),m=""+f),y(o)&&(p(o.key),m=""+o.key),"key"in o){f={};for(var K in o)K!=="key"&&(f[K]=o[K])}else f=o;return m&&b(f,typeof e=="function"?e.displayName||e.name||"Unknown":e),T(e,m,f,l(),Z,Q)}function R(e){w(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===S&&(e._payload.status==="fulfilled"?w(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function w(e){return typeof e=="object"&&e!==null&&e.$$typeof===k}var _=i,k=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),I=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),A=Symbol.for("react.client.reference"),F=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=Object.prototype.hasOwnProperty,D=Array.isArray,O=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(e){return e()}};var B,ce={},de=_.react_stack_bottom_frame.bind(_,u)(),pe=O(a(u)),ue={};N.Fragment=n,N.jsx=function(e,o,f){var x=1e4>F.recentlyCreatedOwnerStacks++;return v(e,o,f,!1,x?Error("react-stack-top-frame"):de,x?O(a(e)):pe)},N.jsxs=function(e,o,f){var x=1e4>F.recentlyCreatedOwnerStacks++;return v(e,o,f,!0,x?Error("react-stack-top-frame"):de,x?O(a(e)):pe)}})()),N}var oe;function be(){return oe||(oe=1,process.env.NODE_ENV==="production"?W.exports=ye():W.exports=_e()),W.exports}var t=be();const X="data:image/svg+xml,%3csvg%20width='117'%20height='120'%20viewBox='0%200%20117%20120'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='%23FF8800'%20/%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='url(%23paint0_radial_6015_131977)'%20/%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='url(%23paint1_radial_6015_131977)'%20fill-opacity='0.4'%20/%3e%3crect%20x='0.909091'%20y='0.909091'%20width='114.545'%20height='114.545'%20rx='57.2727'%20fill='%23FF8800'%20/%3e%3crect%20x='0.909091'%20y='0.909091'%20width='114.545'%20height='114.545'%20rx='57.2727'%20fill='url(%23paint2_radial_6015_131977)'%20/%3e%3crect%20x='0.909091'%20y='0.909091'%20width='114.545'%20height='114.545'%20rx='57.2727'%20fill='url(%23paint3_radial_6015_131977)'%20/%3e%3crect%20x='0.909091'%20y='0.909091'%20width='114.545'%20height='114.545'%20rx='57.2727'%20fill='url(%23paint4_radial_6015_131977)'%20fill-opacity='0.3'%20/%3e%3crect%20x='0.909091'%20y='0.909091'%20width='114.545'%20height='114.545'%20rx='57.2727'%20stroke='url(%23paint5_linear_6015_131977)'%20stroke-width='1.81818'%20/%3e%3cg%20opacity='0.4'%3e%3cpath%20d='M27.2731%20104.474C27.0272%2082.1726%209.92689%2079.0823%203.63672%2079.4341C25.2722%2077.2252%2027.1558%2041.2543%2027.2731%2031.9004C27.4055%2041.4094%2029.3496%2077.2327%2050.9094%2079.4379C44.6231%2079.0861%2027.5341%2082.2028%2027.2731%20104.478V104.474Z'%20fill='url(%23paint6_radial_6015_131977)'%20/%3e%3c/g%3e%3cg%20opacity='0.4'%3e%3cg%20clip-path='url(%23clip0_6015_131977)'%3e%3cpath%20d='M87.2716%2014.546C87.4985%2035.1318%20103.284%2037.9843%20109.09%2037.6596C89.1186%2039.6987%2087.3798%2072.9027%2087.2716%2081.5371C87.1494%2072.7595%2085.3547%2039.6917%2065.4533%2037.6561C71.2561%2037.9809%2087.0306%2035.1039%2087.2716%2014.5425L87.2716%2014.546Z'%20fill='url(%23paint7_radial_6015_131977)'%20/%3e%3c/g%3e%3c/g%3e%3cg%20clip-path='url(%23clip1_6015_131977)'%20filter='url(%23filter0_i_6015_131977)'%20%3e%3cpath%20d='M77.1274%2060.0186C77.1274%2058.8913%2076.2654%2058.0293%2075.1381%2058.0293C74.0108%2058.0293%2073.1488%2058.8913%2073.1488%2060.0186C73.1488%2067.7769%2066.8493%2074.0764%2059.0911%2074.0764C51.3328%2074.0764%2045.0333%2067.7769%2045.0333%2060.0186C45.0333%2058.8913%2044.1713%2058.0293%2043.044%2058.0293C41.9167%2058.0293%2041.0547%2058.8913%2041.0547%2060.0186C41.0547%2069.2357%2047.9509%2076.994%2057.1017%2077.9887V83.2935H49.8739C48.7467%2083.2935%2047.8846%2084.1555%2047.8846%2085.2828C47.8846%2086.41%2048.7467%2087.2721%2049.8739%2087.2721H68.3082C69.4354%2087.2721%2070.2975%2086.41%2070.2975%2085.2828C70.2975%2084.1555%2069.4354%2083.2935%2068.3082%2083.2935H61.0804V77.9887C70.2312%2076.994%2077.1274%2069.2357%2077.1274%2060.0186Z'%20fill='white'%20/%3e%3cpath%20d='M59.0933%2030.9082C52.9928%2030.9082%2048.0195%2035.8815%2048.0195%2041.982V59.9521C48.0195%2066.1189%2052.9928%2071.0259%2059.0933%2071.0922C65.1939%2071.0922%2070.1671%2066.1189%2070.1671%2060.0184V41.982C70.1671%2035.8815%2065.1939%2030.9082%2059.0933%2030.9082Z'%20fill='white'%20/%3e%3c/g%3e%3cdefs%3e%3cfilter%20id='filter0_i_6015_131977'%20x='30.9102'%20y='30.9082'%20width='56.3633'%20height='58.1815'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%20%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'%20/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='BackgroundImageFix'%20result='shape'%20/%3e%3cfeColorMatrix%20in='SourceAlpha'%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%20127%200'%20result='hardAlpha'%20/%3e%3cfeOffset%20dy='1.81818'%20/%3e%3cfeGaussianBlur%20stdDeviation='0.909091'%20/%3e%3cfeComposite%20in2='hardAlpha'%20operator='arithmetic'%20k2='-1'%20k3='1'%20/%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%200.937087%200%200%200%200%200.449802%200%200%200%200%200%200%200%200%201%200'%20/%3e%3cfeBlend%20mode='normal'%20in2='shape'%20result='effect1_innerShadow_6015_131977'%20/%3e%3c/filter%3e%3cradialGradient%20id='paint0_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(-107.107%20232.727%20-57.2274%20-199.178%20110.413%20-150.909)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20offset='0.67589'%20stop-color='%23FF7A00'%20/%3e%3cstop%20offset='1'%20stop-color='%23DBFF00'%20stop-opacity='0.38'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint1_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(25.124%20-134.545%2037.8392%2053.435%2043.6364%20120)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20stop-opacity='0.73'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0.12'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint2_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(-107.107%20232.727%20-57.2274%20-199.178%20110.413%20-154.545)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20offset='0.67589'%20stop-color='%23FF7A00'%20/%3e%3cstop%20offset='1'%20stop-color='%23FFC700'%20stop-opacity='0.38'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint3_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(45.6198%20-45.4545%2027.7487%20210.613%206.61157%20116.364)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='%23F6FB22'%20stop-opacity='0.51'%20/%3e%3cstop%20offset='1'%20stop-color='%23FF9E45'%20stop-opacity='0'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint4_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(-36.3636%2036.3636%20-36.3636%20-275%20112.397%2036.3637)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0'%20/%3e%3c/radialGradient%3e%3clinearGradient%20id='paint5_linear_6015_131977'%20x1='58.1818'%20y1='0'%20x2='58.1818'%20y2='116.364'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='%23FF7A00'%20/%3e%3cstop%20offset='1'%20stop-color='%23FF7A00'%20stop-opacity='0'%20/%3e%3c/linearGradient%3e%3cradialGradient%20id='paint6_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(10.2066%20-83.9173%2015.3722%2033.328%2021.364%20104.478)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0.2'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint7_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(-9.42152%2077.4625%20-14.1898%20-30.7644%2092.7261%2014.5425)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0.1'%20/%3e%3c/radialGradient%3e%3cclipPath%20id='clip0_6015_131977'%3e%3crect%20width='43.6366'%20height='66.9911'%20fill='white'%20transform='translate(109.09%2081.5371)%20rotate(180)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clip1_6015_131977'%3e%3crect%20width='56.3636'%20height='56.3636'%20fill='white'%20transform='translate(30.9102%2030.9082)'%20/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",ne="data:image/svg+xml,%3csvg%20width='117'%20height='120'%20viewBox='0%200%20117%20120'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20%3e%3cg%20filter='url(%23filter0_i_6104_131024)'%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='%23FF8800'%20/%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='url(%23paint0_radial_6104_131024)'%20/%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='url(%23paint1_radial_6104_131024)'%20fill-opacity='0.4'%20/%3e%3c/g%3e%3crect%20x='1.08067'%20y='1.08067'%20width='114.202'%20height='114.202'%20rx='57.1011'%20fill='white'%20stroke='url(%23paint2_linear_6104_131024)'%20stroke-width='2.16135'%20/%3e%3cg%20filter='url(%23filter1_d_6104_131024)'%3e%3cpath%20d='M49.7119%2041.0605C52.0993%2041.0605%2054.0352%2042.9964%2054.0352%2045.3838V75.6426C54.0351%2078.0299%2052.0992%2079.9648%2049.7119%2079.9648H41.0664C38.6793%2079.9646%2036.7442%2078.0297%2036.7441%2075.6426V45.3838C36.7441%2042.9966%2038.6793%2041.0608%2041.0664%2041.0605H49.7119ZM75.6484%2041.0605C78.0358%2041.0605%2079.9707%2042.9964%2079.9707%2045.3838V75.6426C79.9706%2078.0299%2078.0357%2079.9648%2075.6484%2079.9648H67.0029C64.6157%2079.9648%2062.6808%2078.0298%2062.6807%2075.6426V45.3838C62.6807%2042.9965%2064.6156%2041.0606%2067.0029%2041.0605H75.6484Z'%20fill='%23FBEDD9'%20/%3e%3cpath%20d='M49.7119%2041.0605C52.0993%2041.0605%2054.0352%2042.9964%2054.0352%2045.3838V75.6426C54.0351%2078.0299%2052.0992%2079.9648%2049.7119%2079.9648H41.0664C38.6793%2079.9646%2036.7442%2078.0297%2036.7441%2075.6426V45.3838C36.7441%2042.9966%2038.6793%2041.0608%2041.0664%2041.0605H49.7119ZM75.6484%2041.0605C78.0358%2041.0605%2079.9707%2042.9964%2079.9707%2045.3838V75.6426C79.9706%2078.0299%2078.0357%2079.9648%2075.6484%2079.9648H67.0029C64.6157%2079.9648%2062.6808%2078.0298%2062.6807%2075.6426V45.3838C62.6807%2042.9965%2064.6156%2041.0606%2067.0029%2041.0605H75.6484Z'%20fill='%23FF7A00'%20/%3e%3cpath%20d='M49.7119%2041.0605C52.0993%2041.0605%2054.0352%2042.9964%2054.0352%2045.3838V75.6426C54.0351%2078.0299%2052.0992%2079.9648%2049.7119%2079.9648H41.0664C38.6793%2079.9646%2036.7442%2078.0297%2036.7441%2075.6426V45.3838C36.7441%2042.9966%2038.6793%2041.0608%2041.0664%2041.0605H49.7119ZM75.6484%2041.0605C78.0358%2041.0605%2079.9707%2042.9964%2079.9707%2045.3838V75.6426C79.9706%2078.0299%2078.0357%2079.9648%2075.6484%2079.9648H67.0029C64.6157%2079.9648%2062.6808%2078.0298%2062.6807%2075.6426V45.3838C62.6807%2042.9965%2064.6156%2041.0606%2067.0029%2041.0605H75.6484Z'%20fill='url(%23paint3_radial_6104_131024)'%20fill-opacity='0.4'%20/%3e%3c/g%3e%3cdefs%3e%3cfilter%20id='filter0_i_6104_131024'%20x='0'%20y='3.63672'%20width='116.363'%20height='116.363'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%20%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'%20/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='BackgroundImageFix'%20result='shape'%20/%3e%3cfeColorMatrix%20in='SourceAlpha'%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%20127%200'%20result='hardAlpha'%20/%3e%3cfeOffset%20/%3e%3cfeGaussianBlur%20stdDeviation='3.63636'%20/%3e%3cfeComposite%20in2='hardAlpha'%20operator='arithmetic'%20k2='-1'%20k3='1'%20/%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%201%200%200%200%200%201%200%200%200%200%201%200%200%200%201%200'%20/%3e%3cfeBlend%20mode='normal'%20in2='shape'%20result='effect1_innerShadow_6104_131024'%20/%3e%3c/filter%3e%3cfilter%20id='filter1_d_6104_131024'%20x='34.5828'%20y='38.8992'%20width='47.5493'%20height='43.227'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%20%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'%20/%3e%3cfeColorMatrix%20in='SourceAlpha'%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%20127%200'%20result='hardAlpha'%20/%3e%3cfeOffset%20/%3e%3cfeGaussianBlur%20stdDeviation='1.08067'%20/%3e%3cfeComposite%20in2='hardAlpha'%20operator='out'%20/%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%201%200%200%200%200%200.565%200%200%200%200%200%200%200%200%201%200'%20/%3e%3cfeBlend%20mode='normal'%20in2='BackgroundImageFix'%20result='effect1_dropShadow_6104_131024'%20/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='effect1_dropShadow_6104_131024'%20result='shape'%20/%3e%3c/filter%3e%3cradialGradient%20id='paint0_radial_6104_131024'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(-107.107%20232.727%20-57.2274%20-199.178%20110.413%20-150.909)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20offset='0.67589'%20stop-color='%23FF7A00'%20/%3e%3cstop%20offset='1'%20stop-color='%23DBFF00'%20stop-opacity='0.38'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint1_radial_6104_131024'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(25.124%20-134.545%2037.8392%2053.435%2043.6364%20120)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20stop-opacity='0.73'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0.12'%20/%3e%3c/radialGradient%3e%3clinearGradient%20id='paint2_linear_6104_131024'%20x1='58.1818'%20y1='0'%20x2='58.1818'%20y2='116.364'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='%23FF7A00'%20/%3e%3cstop%20offset='0.515'%20stop-color='%23FCEAD2'%20/%3e%3cstop%20offset='1'%20stop-color='%23FF7A00'%20/%3e%3c/linearGradient%3e%3cradialGradient%20id='paint3_radial_6104_131024'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(9.33301%20-44.9831%2014.0564%2017.8651%2052.9541%2079.9648)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20stop-opacity='0.73'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0.12'%20/%3e%3c/radialGradient%3e%3c/defs%3e%3c/svg%3e",we="data:image/svg+xml,%3csvg%20width='640'%20height='640'%20viewBox='0%200%20640%20640'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20filter='url(%23filter0_f_5207_91652)'%3e%3cg%20filter='url(%23filter1_f_5207_91652)'%3e%3crect%20x='45'%20y='45'%20width='550'%20height='550'%20rx='275'%20fill='url(%23paint0_linear_5207_91652)'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3cfilter%20id='filter0_f_5207_91652'%20x='-32'%20y='-32'%20width='704'%20height='704'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='BackgroundImageFix'%20result='shape'/%3e%3cfeGaussianBlur%20stdDeviation='16'%20result='effect1_foregroundBlur_5207_91652'/%3e%3c/filter%3e%3cfilter%20id='filter1_f_5207_91652'%20x='41.4052'%20y='41.4052'%20width='557.19'%20height='557.19'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='BackgroundImageFix'%20result='shape'/%3e%3cfeGaussianBlur%20stdDeviation='1.79739'%20result='effect1_foregroundBlur_5207_91652'/%3e%3c/filter%3e%3clinearGradient%20id='paint0_linear_5207_91652'%20x1='320'%20y1='45'%20x2='326.74'%20y2='605.784'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0.177383'%20stop-color='%23EBDDFF'/%3e%3cstop%20offset='0.755511'%20stop-color='%23FEBB63'/%3e%3cstop%20offset='1'%20stop-color='%23FF7A00'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",d={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"20px"},modal:{backgroundColor:"#ffffff",borderRadius:"32px",padding:"40px",width:"100%",maxWidth:"480px",maxHeight:"90vh",overflow:"auto",boxShadow:"0 25px 80px rgba(0, 0, 0, 0.15)",position:"relative"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"32px"},title:{fontSize:"18px",fontWeight:600,color:"#1f2937",margin:0,display:"flex",alignItems:"center",gap:"8px"},closeButton:{background:"transparent",border:"none",color:"#9ca3af",cursor:"pointer",padding:"8px",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"},micSection:{display:"flex",flexDirection:"column",alignItems:"center",gap:"24px",marginBottom:"32px",position:"relative"},bgCircle:{position:"absolute",width:"280px",height:"280px",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:0,opacity:.8,transition:"opacity 0.3s ease"},micButton:{width:"120px",height:"120px",borderRadius:"50%",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",padding:0,position:"relative",zIndex:1,transition:"transform 0.2s ease"},micImage:{width:"100%",height:"100%",objectFit:"contain"},statusText:{fontSize:"16px",fontWeight:500,color:"#6b7280",textAlign:"center",position:"relative",zIndex:1},statusTextActive:{color:"#FF7A00",fontWeight:600},transcriptBox:{background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:"16px",padding:"20px",minHeight:"100px",maxHeight:"160px",overflow:"auto",marginBottom:"24px"},transcriptText:{fontSize:"15px",lineHeight:1.7,color:"#1f2937",margin:0,wordWrap:"break-word"},placeholderText:{fontSize:"14px",color:"#9ca3af",textAlign:"center",margin:0,padding:"16px 0"},actions:{display:"flex",justifyContent:"center"},generateButton:{padding:"14px 48px",borderRadius:"100px",border:"2px solid #9333ea",background:"transparent",color:"#9333ea",fontSize:"15px",fontWeight:600,cursor:"pointer",transition:"all 0.2s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},generateButtonDisabled:{opacity:.4,cursor:"not-allowed",borderColor:"#d1d5db",color:"#9ca3af"},loadingOverlay:{position:"absolute",inset:0,background:"rgba(255, 255, 255, 0.95)",borderRadius:"32px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"24px",zIndex:10},loadingBars:{display:"flex",flexDirection:"column",gap:"12px",width:"200px"},loadingBar:{height:"12px",borderRadius:"6px",background:"linear-gradient(90deg, #e5e7eb 0%, #d1d5db 50%, #e5e7eb 100%)",backgroundSize:"200% 100%",animation:"shimmer 1.5s ease-in-out infinite"},loadingText:{fontSize:"16px",fontWeight:600,color:"#6b7280",display:"flex",alignItems:"center",gap:"8px"},sparkleIcon:{color:"#9333ea"},footer:{marginTop:"24px",textAlign:"center",fontSize:"12px",color:"#9ca3af"}},Se=`
|
|
1
|
+
(function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.SpeechRecognitionSDK={},c.React,c.ReactJSXRuntime))})(this,(function(c,o,e){"use strict";function E(){return typeof window>"u"?!1:!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function V(){return typeof window>"u"?null:window.SpeechRecognition||window.webkitSpeechRecognition||null}async function L(){try{return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(a=>a.stop()),!0}catch{return!1}}async function J(){try{return(await navigator.mediaDevices.enumerateDevices()).some(a=>a.kind==="audioinput")}catch{return!1}}function K(){return["th-TH","en-US","en-GB","en-AU","zh-CN","zh-TW","ja-JP","ko-KR","vi-VN","id-ID","ms-MY","fr-FR","de-DE","es-ES","pt-BR","ru-RU","ar-SA","hi-IN"]}function Y(t){return`${Math.round(t*100)}%`}const X={language:"th-TH",continuous:!0,interimResults:!0,maxAlternatives:1};function G(t={}){const{config:a={},callbacks:s={}}=t,[l,d]=o.useState(!1),[f,x]=o.useState(""),[_,n]=o.useState(""),[S,y]=o.useState(""),[C,h]=o.useState(null),[u,m]=o.useState(!0),p=o.useRef(null),r=o.useRef(s);o.useEffect(()=>{r.current=s},[s]);const w=E(),U=o.useCallback(async M=>{if(!w){h("Speech recognition is not supported in this browser");return}if(!await L()){h("Microphone permission denied"),m(!1);return}p.current&&p.current.abort();const H=V();if(!H)return;const b=new H,g={...X,...a,...M};b.lang=g.language||"th-TH",b.continuous=g.continuous??!0,b.interimResults=g.interimResults??!0,b.maxAlternatives=g.maxAlternatives??1,b.onstart=()=>{d(!0),h(null),r.current.onStart?.()},b.onend=()=>{d(!1),r.current.onEnd?.()},b.onerror=k=>{const T=Q(k.error);h(T),d(!1),r.current.onError?.(T)},b.onresult=k=>{let T="",$="";for(let O=k.resultIndex;O<k.results.length;O++){const I=k.results[O],A=I[0].transcript;I.isFinal?($+=A,r.current.onResult?.({transcript:A,confidence:I[0].confidence,isFinal:!0})):T+=A}n(T),y(O=>{const I=O+$,A=I+T;return x(A),r.current.onTranscriptChange?.(A),I})},p.current=b,b.start()},[w,a]),v=o.useCallback(()=>{p.current&&p.current.stop()},[]),F=o.useCallback(()=>{p.current&&p.current.abort(),d(!1)},[]),z=o.useCallback(()=>{x(""),n(""),y("")},[]);return o.useEffect(()=>()=>{p.current&&p.current.abort()},[]),{isListening:l,transcript:f,interimTranscript:_,finalTranscript:S,isSupported:w,isMicrophoneAvailable:u,error:C,startListening:U,stopListening:v,abortListening:F,resetTranscript:z}}function Q(t){return{"not-allowed":"Microphone permission was denied","no-speech":"No speech was detected","audio-capture":"No microphone was found",network:"Network error occurred",aborted:"Speech recognition was aborted","language-not-supported":"Language is not supported","service-not-allowed":"Speech recognition service is not allowed"}[t]||`Speech recognition error: ${t}`}const D="data:image/svg+xml,%3csvg%20width='117'%20height='120'%20viewBox='0%200%20117%20120'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='%23FF8800'%20/%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='url(%23paint0_radial_6015_131977)'%20/%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='url(%23paint1_radial_6015_131977)'%20fill-opacity='0.4'%20/%3e%3crect%20x='0.909091'%20y='0.909091'%20width='114.545'%20height='114.545'%20rx='57.2727'%20fill='%23FF8800'%20/%3e%3crect%20x='0.909091'%20y='0.909091'%20width='114.545'%20height='114.545'%20rx='57.2727'%20fill='url(%23paint2_radial_6015_131977)'%20/%3e%3crect%20x='0.909091'%20y='0.909091'%20width='114.545'%20height='114.545'%20rx='57.2727'%20fill='url(%23paint3_radial_6015_131977)'%20/%3e%3crect%20x='0.909091'%20y='0.909091'%20width='114.545'%20height='114.545'%20rx='57.2727'%20fill='url(%23paint4_radial_6015_131977)'%20fill-opacity='0.3'%20/%3e%3crect%20x='0.909091'%20y='0.909091'%20width='114.545'%20height='114.545'%20rx='57.2727'%20stroke='url(%23paint5_linear_6015_131977)'%20stroke-width='1.81818'%20/%3e%3cg%20opacity='0.4'%3e%3cpath%20d='M27.2731%20104.474C27.0272%2082.1726%209.92689%2079.0823%203.63672%2079.4341C25.2722%2077.2252%2027.1558%2041.2543%2027.2731%2031.9004C27.4055%2041.4094%2029.3496%2077.2327%2050.9094%2079.4379C44.6231%2079.0861%2027.5341%2082.2028%2027.2731%20104.478V104.474Z'%20fill='url(%23paint6_radial_6015_131977)'%20/%3e%3c/g%3e%3cg%20opacity='0.4'%3e%3cg%20clip-path='url(%23clip0_6015_131977)'%3e%3cpath%20d='M87.2716%2014.546C87.4985%2035.1318%20103.284%2037.9843%20109.09%2037.6596C89.1186%2039.6987%2087.3798%2072.9027%2087.2716%2081.5371C87.1494%2072.7595%2085.3547%2039.6917%2065.4533%2037.6561C71.2561%2037.9809%2087.0306%2035.1039%2087.2716%2014.5425L87.2716%2014.546Z'%20fill='url(%23paint7_radial_6015_131977)'%20/%3e%3c/g%3e%3c/g%3e%3cg%20clip-path='url(%23clip1_6015_131977)'%20filter='url(%23filter0_i_6015_131977)'%20%3e%3cpath%20d='M77.1274%2060.0186C77.1274%2058.8913%2076.2654%2058.0293%2075.1381%2058.0293C74.0108%2058.0293%2073.1488%2058.8913%2073.1488%2060.0186C73.1488%2067.7769%2066.8493%2074.0764%2059.0911%2074.0764C51.3328%2074.0764%2045.0333%2067.7769%2045.0333%2060.0186C45.0333%2058.8913%2044.1713%2058.0293%2043.044%2058.0293C41.9167%2058.0293%2041.0547%2058.8913%2041.0547%2060.0186C41.0547%2069.2357%2047.9509%2076.994%2057.1017%2077.9887V83.2935H49.8739C48.7467%2083.2935%2047.8846%2084.1555%2047.8846%2085.2828C47.8846%2086.41%2048.7467%2087.2721%2049.8739%2087.2721H68.3082C69.4354%2087.2721%2070.2975%2086.41%2070.2975%2085.2828C70.2975%2084.1555%2069.4354%2083.2935%2068.3082%2083.2935H61.0804V77.9887C70.2312%2076.994%2077.1274%2069.2357%2077.1274%2060.0186Z'%20fill='white'%20/%3e%3cpath%20d='M59.0933%2030.9082C52.9928%2030.9082%2048.0195%2035.8815%2048.0195%2041.982V59.9521C48.0195%2066.1189%2052.9928%2071.0259%2059.0933%2071.0922C65.1939%2071.0922%2070.1671%2066.1189%2070.1671%2060.0184V41.982C70.1671%2035.8815%2065.1939%2030.9082%2059.0933%2030.9082Z'%20fill='white'%20/%3e%3c/g%3e%3cdefs%3e%3cfilter%20id='filter0_i_6015_131977'%20x='30.9102'%20y='30.9082'%20width='56.3633'%20height='58.1815'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%20%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'%20/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='BackgroundImageFix'%20result='shape'%20/%3e%3cfeColorMatrix%20in='SourceAlpha'%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%20127%200'%20result='hardAlpha'%20/%3e%3cfeOffset%20dy='1.81818'%20/%3e%3cfeGaussianBlur%20stdDeviation='0.909091'%20/%3e%3cfeComposite%20in2='hardAlpha'%20operator='arithmetic'%20k2='-1'%20k3='1'%20/%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%200.937087%200%200%200%200%200.449802%200%200%200%200%200%200%200%200%201%200'%20/%3e%3cfeBlend%20mode='normal'%20in2='shape'%20result='effect1_innerShadow_6015_131977'%20/%3e%3c/filter%3e%3cradialGradient%20id='paint0_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(-107.107%20232.727%20-57.2274%20-199.178%20110.413%20-150.909)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20offset='0.67589'%20stop-color='%23FF7A00'%20/%3e%3cstop%20offset='1'%20stop-color='%23DBFF00'%20stop-opacity='0.38'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint1_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(25.124%20-134.545%2037.8392%2053.435%2043.6364%20120)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20stop-opacity='0.73'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0.12'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint2_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(-107.107%20232.727%20-57.2274%20-199.178%20110.413%20-154.545)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20offset='0.67589'%20stop-color='%23FF7A00'%20/%3e%3cstop%20offset='1'%20stop-color='%23FFC700'%20stop-opacity='0.38'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint3_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(45.6198%20-45.4545%2027.7487%20210.613%206.61157%20116.364)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='%23F6FB22'%20stop-opacity='0.51'%20/%3e%3cstop%20offset='1'%20stop-color='%23FF9E45'%20stop-opacity='0'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint4_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(-36.3636%2036.3636%20-36.3636%20-275%20112.397%2036.3637)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0'%20/%3e%3c/radialGradient%3e%3clinearGradient%20id='paint5_linear_6015_131977'%20x1='58.1818'%20y1='0'%20x2='58.1818'%20y2='116.364'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='%23FF7A00'%20/%3e%3cstop%20offset='1'%20stop-color='%23FF7A00'%20stop-opacity='0'%20/%3e%3c/linearGradient%3e%3cradialGradient%20id='paint6_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(10.2066%20-83.9173%2015.3722%2033.328%2021.364%20104.478)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0.2'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint7_radial_6015_131977'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(-9.42152%2077.4625%20-14.1898%20-30.7644%2092.7261%2014.5425)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0.1'%20/%3e%3c/radialGradient%3e%3cclipPath%20id='clip0_6015_131977'%3e%3crect%20width='43.6366'%20height='66.9911'%20fill='white'%20transform='translate(109.09%2081.5371)%20rotate(180)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clip1_6015_131977'%3e%3crect%20width='56.3636'%20height='56.3636'%20fill='white'%20transform='translate(30.9102%2030.9082)'%20/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",P="data:image/svg+xml,%3csvg%20width='117'%20height='120'%20viewBox='0%200%20117%20120'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20%3e%3cg%20filter='url(%23filter0_i_6104_131024)'%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='%23FF8800'%20/%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='url(%23paint0_radial_6104_131024)'%20/%3e%3crect%20y='3.63672'%20width='116.364'%20height='116.364'%20rx='58.1818'%20fill='url(%23paint1_radial_6104_131024)'%20fill-opacity='0.4'%20/%3e%3c/g%3e%3crect%20x='1.08067'%20y='1.08067'%20width='114.202'%20height='114.202'%20rx='57.1011'%20fill='white'%20stroke='url(%23paint2_linear_6104_131024)'%20stroke-width='2.16135'%20/%3e%3cg%20filter='url(%23filter1_d_6104_131024)'%3e%3cpath%20d='M49.7119%2041.0605C52.0993%2041.0605%2054.0352%2042.9964%2054.0352%2045.3838V75.6426C54.0351%2078.0299%2052.0992%2079.9648%2049.7119%2079.9648H41.0664C38.6793%2079.9646%2036.7442%2078.0297%2036.7441%2075.6426V45.3838C36.7441%2042.9966%2038.6793%2041.0608%2041.0664%2041.0605H49.7119ZM75.6484%2041.0605C78.0358%2041.0605%2079.9707%2042.9964%2079.9707%2045.3838V75.6426C79.9706%2078.0299%2078.0357%2079.9648%2075.6484%2079.9648H67.0029C64.6157%2079.9648%2062.6808%2078.0298%2062.6807%2075.6426V45.3838C62.6807%2042.9965%2064.6156%2041.0606%2067.0029%2041.0605H75.6484Z'%20fill='%23FBEDD9'%20/%3e%3cpath%20d='M49.7119%2041.0605C52.0993%2041.0605%2054.0352%2042.9964%2054.0352%2045.3838V75.6426C54.0351%2078.0299%2052.0992%2079.9648%2049.7119%2079.9648H41.0664C38.6793%2079.9646%2036.7442%2078.0297%2036.7441%2075.6426V45.3838C36.7441%2042.9966%2038.6793%2041.0608%2041.0664%2041.0605H49.7119ZM75.6484%2041.0605C78.0358%2041.0605%2079.9707%2042.9964%2079.9707%2045.3838V75.6426C79.9706%2078.0299%2078.0357%2079.9648%2075.6484%2079.9648H67.0029C64.6157%2079.9648%2062.6808%2078.0298%2062.6807%2075.6426V45.3838C62.6807%2042.9965%2064.6156%2041.0606%2067.0029%2041.0605H75.6484Z'%20fill='%23FF7A00'%20/%3e%3cpath%20d='M49.7119%2041.0605C52.0993%2041.0605%2054.0352%2042.9964%2054.0352%2045.3838V75.6426C54.0351%2078.0299%2052.0992%2079.9648%2049.7119%2079.9648H41.0664C38.6793%2079.9646%2036.7442%2078.0297%2036.7441%2075.6426V45.3838C36.7441%2042.9966%2038.6793%2041.0608%2041.0664%2041.0605H49.7119ZM75.6484%2041.0605C78.0358%2041.0605%2079.9707%2042.9964%2079.9707%2045.3838V75.6426C79.9706%2078.0299%2078.0357%2079.9648%2075.6484%2079.9648H67.0029C64.6157%2079.9648%2062.6808%2078.0298%2062.6807%2075.6426V45.3838C62.6807%2042.9965%2064.6156%2041.0606%2067.0029%2041.0605H75.6484Z'%20fill='url(%23paint3_radial_6104_131024)'%20fill-opacity='0.4'%20/%3e%3c/g%3e%3cdefs%3e%3cfilter%20id='filter0_i_6104_131024'%20x='0'%20y='3.63672'%20width='116.363'%20height='116.363'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%20%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'%20/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='BackgroundImageFix'%20result='shape'%20/%3e%3cfeColorMatrix%20in='SourceAlpha'%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%20127%200'%20result='hardAlpha'%20/%3e%3cfeOffset%20/%3e%3cfeGaussianBlur%20stdDeviation='3.63636'%20/%3e%3cfeComposite%20in2='hardAlpha'%20operator='arithmetic'%20k2='-1'%20k3='1'%20/%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%201%200%200%200%200%201%200%200%200%200%201%200%200%200%201%200'%20/%3e%3cfeBlend%20mode='normal'%20in2='shape'%20result='effect1_innerShadow_6104_131024'%20/%3e%3c/filter%3e%3cfilter%20id='filter1_d_6104_131024'%20x='34.5828'%20y='38.8992'%20width='47.5493'%20height='43.227'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%20%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'%20/%3e%3cfeColorMatrix%20in='SourceAlpha'%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%20127%200'%20result='hardAlpha'%20/%3e%3cfeOffset%20/%3e%3cfeGaussianBlur%20stdDeviation='1.08067'%20/%3e%3cfeComposite%20in2='hardAlpha'%20operator='out'%20/%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%201%200%200%200%200%200.565%200%200%200%200%200%200%200%200%201%200'%20/%3e%3cfeBlend%20mode='normal'%20in2='BackgroundImageFix'%20result='effect1_dropShadow_6104_131024'%20/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='effect1_dropShadow_6104_131024'%20result='shape'%20/%3e%3c/filter%3e%3cradialGradient%20id='paint0_radial_6104_131024'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(-107.107%20232.727%20-57.2274%20-199.178%20110.413%20-150.909)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20offset='0.67589'%20stop-color='%23FF7A00'%20/%3e%3cstop%20offset='1'%20stop-color='%23DBFF00'%20stop-opacity='0.38'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint1_radial_6104_131024'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(25.124%20-134.545%2037.8392%2053.435%2043.6364%20120)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20stop-opacity='0.73'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0.12'%20/%3e%3c/radialGradient%3e%3clinearGradient%20id='paint2_linear_6104_131024'%20x1='58.1818'%20y1='0'%20x2='58.1818'%20y2='116.364'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='%23FF7A00'%20/%3e%3cstop%20offset='0.515'%20stop-color='%23FCEAD2'%20/%3e%3cstop%20offset='1'%20stop-color='%23FF7A00'%20/%3e%3c/linearGradient%3e%3cradialGradient%20id='paint3_radial_6104_131024'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='matrix(9.33301%20-44.9831%2014.0564%2017.8651%2052.9541%2079.9648)'%20gradientUnits='userSpaceOnUse'%20%3e%3cstop%20stop-color='white'%20stop-opacity='0.73'%20/%3e%3cstop%20offset='1'%20stop-color='white'%20stop-opacity='0.12'%20/%3e%3c/radialGradient%3e%3c/defs%3e%3c/svg%3e",R="data:image/svg+xml,%3csvg%20width='640'%20height='640'%20viewBox='0%200%20640%20640'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20filter='url(%23filter0_f_5207_91652)'%3e%3cg%20filter='url(%23filter1_f_5207_91652)'%3e%3crect%20x='45'%20y='45'%20width='550'%20height='550'%20rx='275'%20fill='url(%23paint0_linear_5207_91652)'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3cfilter%20id='filter0_f_5207_91652'%20x='-32'%20y='-32'%20width='704'%20height='704'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='BackgroundImageFix'%20result='shape'/%3e%3cfeGaussianBlur%20stdDeviation='16'%20result='effect1_foregroundBlur_5207_91652'/%3e%3c/filter%3e%3cfilter%20id='filter1_f_5207_91652'%20x='41.4052'%20y='41.4052'%20width='557.19'%20height='557.19'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='BackgroundImageFix'%20result='shape'/%3e%3cfeGaussianBlur%20stdDeviation='1.79739'%20result='effect1_foregroundBlur_5207_91652'/%3e%3c/filter%3e%3clinearGradient%20id='paint0_linear_5207_91652'%20x1='320'%20y1='45'%20x2='326.74'%20y2='605.784'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0.177383'%20stop-color='%23EBDDFF'/%3e%3cstop%20offset='0.755511'%20stop-color='%23FEBB63'/%3e%3cstop%20offset='1'%20stop-color='%23FF7A00'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",i={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"20px"},modal:{backgroundColor:"#ffffff",borderRadius:"32px",padding:"40px",width:"100%",maxWidth:"480px",maxHeight:"90vh",overflow:"auto",boxShadow:"0 25px 80px rgba(0, 0, 0, 0.15)",position:"relative"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"32px"},title:{fontSize:"18px",fontWeight:600,color:"#1f2937",margin:0,display:"flex",alignItems:"center",gap:"8px"},closeButton:{background:"transparent",border:"none",color:"#9ca3af",cursor:"pointer",padding:"8px",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"},micSection:{display:"flex",flexDirection:"column",alignItems:"center",gap:"24px",marginBottom:"32px",position:"relative"},bgCircle:{position:"absolute",width:"280px",height:"280px",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:0,opacity:.8,transition:"opacity 0.3s ease"},micButton:{width:"120px",height:"120px",borderRadius:"50%",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",padding:0,position:"relative",zIndex:1,transition:"transform 0.2s ease"},micImage:{width:"100%",height:"100%",objectFit:"contain"},statusText:{fontSize:"16px",fontWeight:500,color:"#6b7280",textAlign:"center",position:"relative",zIndex:1},statusTextActive:{color:"#FF7A00",fontWeight:600},transcriptBox:{background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:"16px",padding:"20px",minHeight:"100px",maxHeight:"160px",overflow:"auto",marginBottom:"24px"},transcriptText:{fontSize:"15px",lineHeight:1.7,color:"#1f2937",margin:0,wordWrap:"break-word"},placeholderText:{fontSize:"14px",color:"#9ca3af",textAlign:"center",margin:0,padding:"16px 0"},actions:{display:"flex",justifyContent:"center"},generateButton:{padding:"14px 48px",borderRadius:"100px",border:"2px solid #9333ea",background:"transparent",color:"#9333ea",fontSize:"15px",fontWeight:600,cursor:"pointer",transition:"all 0.2s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},generateButtonDisabled:{opacity:.4,cursor:"not-allowed",borderColor:"#d1d5db",color:"#9ca3af"},loadingOverlay:{position:"absolute",inset:0,background:"rgba(255, 255, 255, 0.95)",borderRadius:"32px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"24px",zIndex:10},loadingBars:{display:"flex",flexDirection:"column",gap:"12px",width:"200px"},loadingBar:{height:"12px",borderRadius:"6px",background:"linear-gradient(90deg, #e5e7eb 0%, #d1d5db 50%, #e5e7eb 100%)",backgroundSize:"200% 100%",animation:"shimmer 1.5s ease-in-out infinite"},loadingText:{fontSize:"16px",fontWeight:600,color:"#6b7280",display:"flex",alignItems:"center",gap:"8px"},sparkleIcon:{color:"#9333ea"},footer:{marginTop:"24px",textAlign:"center",fontSize:"12px",color:"#9ca3af"}},e0=`
|
|
7
2
|
@keyframes shimmer {
|
|
8
3
|
0% { background-position: 200% 0; }
|
|
9
4
|
100% { background-position: -200% 0; }
|
|
@@ -16,5 +11,5 @@ React keys must be passed directly to JSX without using spread:
|
|
|
16
11
|
0%, 100% { opacity: 0.8; transform: translate(-50%, -50%) scale(1); }
|
|
17
12
|
50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
|
|
18
13
|
}
|
|
19
|
-
`,ve=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"24",height:"24",children:t.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})}),Ce=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:t.jsx("path",{d:"M12 2L9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2z"})}),ke=()=>t.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("path",{d:"M12 2L10.5 8.5L4 10L10.5 11.5L12 18L13.5 11.5L20 10L13.5 8.5L12 2Z",fill:"#9333ea"}),t.jsx("path",{d:"M5 14L4 17L7 16L5 14Z",fill:"#9333ea",opacity:"0.6"}),t.jsx("path",{d:"M19 14L20 17L17 16L19 14Z",fill:"#9333ea",opacity:"0.6"})]});function ie({isOpen:r,onClose:s,isListening:p,transcript:a,onStartListening:l,onStopListening:u,onResetTranscript:y,onGenerate:b,isGenerating:c=!1,title:T="AI Speech-to-Data",generateButtonText:v="Generate",placeholder:R="Click the microphone and start speaking..."}){const w=i.useRef(null);i.useEffect(()=>{const n=j=>{j.key==="Escape"&&r&&!c&&s()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[r,s,c]);const _=n=>{n.target===n.currentTarget&&!c&&s()};if(!r)return null;const k=()=>{c||(p?u():(y(),l()))},g=()=>{a&&!c&&b(a)};return t.jsxs(t.Fragment,{children:[t.jsx("style",{children:Se}),t.jsx("div",{style:d.overlay,onClick:_,children:t.jsxs("div",{ref:w,style:{...d.modal,animation:"fadeIn 0.25s ease-out"},onClick:n=>n.stopPropagation(),children:[c&&t.jsxs("div",{style:d.loadingOverlay,children:[t.jsx(ke,{}),t.jsxs("div",{style:d.loadingBars,children:[t.jsx("div",{style:{...d.loadingBar,width:"100%"}}),t.jsx("div",{style:{...d.loadingBar,width:"80%"}}),t.jsx("div",{style:{...d.loadingBar,width:"90%"}}),t.jsx("div",{style:{...d.loadingBar,width:"70%"}})]}),t.jsxs("span",{style:d.loadingText,children:[t.jsx("span",{style:d.sparkleIcon,children:"✨"}),"AI Analyzing"]})]}),t.jsxs("div",{style:d.header,children:[t.jsxs("h2",{style:d.title,children:[t.jsx("span",{style:{fontSize:"20px"},children:"✨"}),T]}),t.jsx("button",{style:d.closeButton,onClick:s,disabled:c,onMouseOver:n=>{c||(n.currentTarget.style.background="#f3f4f6")},onMouseOut:n=>{n.currentTarget.style.background="transparent"},children:t.jsx(ve,{})})]}),t.jsxs("div",{style:d.micSection,children:[t.jsx("img",{src:we,alt:"",style:{...d.bgCircle,opacity:p?1:.6,animation:p?"pulse-glow 2s ease-in-out infinite":"none"}}),t.jsx("button",{style:d.micButton,onClick:k,disabled:c,onMouseOver:n=>{c||(n.currentTarget.style.transform="scale(1.05)")},onMouseOut:n=>{n.currentTarget.style.transform="scale(1)"},children:t.jsx("img",{src:p?ne:X,alt:p?"Stop":"Start recording",style:d.micImage})}),t.jsx("p",{style:{...d.statusText,...p?d.statusTextActive:{}},children:p?"AI is listening.":"Generate result"})]}),(a||!p)&&!c&&t.jsx("div",{style:d.transcriptBox,children:a?t.jsx("p",{style:d.transcriptText,children:a}):t.jsx("p",{style:d.placeholderText,children:R})}),!c&&t.jsx("div",{style:d.actions,children:t.jsxs("button",{style:{...d.generateButton,...a?{}:d.generateButtonDisabled},onClick:g,disabled:!a||c,onMouseOver:n=>{a&&!c&&(n.currentTarget.style.background="#9333ea",n.currentTarget.style.color="white")},onMouseOut:n=>{n.currentTarget.style.background="transparent",n.currentTarget.style.color=a?"#9333ea":"#9ca3af"},children:[t.jsx(Ce,{}),v]})}),t.jsx("div",{style:d.footer,children:t.jsxs("span",{children:["Powered by ",t.jsx("strong",{children:"DFM"})]})})]})})]})}const je=r=>{if(typeof r=="object")return{top:r.top,right:r.right,bottom:r.bottom,left:r.left};const s={"bottom-left":{bottom:"24px",left:"24px"},"bottom-right":{bottom:"24px",right:"24px"},"top-left":{top:"24px",left:"24px"},"top-right":{top:"24px",right:"24px"}};return s[r]||s["bottom-left"]};function ae({enabled:r=!0,position:s="bottom-left",config:p={language:"th-TH",continuous:!0},onGenerate:a,onGenerateComplete:l,onGenerateError:u,modalTitle:y="AI Speech-to-Data",generateButtonText:b="Generate",buttonContent:c,buttonSize:T=64,buttonStyle:v,zIndex:R=9998}){const[w,_]=i.useState(!1),[k,g]=i.useState(!1),{transcript:n,isListening:j,startListening:U,stopListening:E,resetTranscript:I}=J({config:p}),L=i.useCallback(()=>{_(!0)},[]),M=i.useCallback(()=>{_(!1),j&&E()},[j,E]),Y=i.useCallback(async C=>{if(!a){l?.(C),M(),I();return}g(!0);try{const A=await a(C);l?.(A),M(),I()}catch(A){u?.(A)}finally{g(!1)}},[a,l,u,M,I]);if(!r)return null;const S={position:"fixed",...je(s),zIndex:R,width:T,height:T,borderRadius:"50%",border:"none",cursor:"pointer",background:"transparent",padding:0,transition:"all 0.3s ease",filter:"drop-shadow(0 4px 12px rgba(255, 122, 0, 0.4))",...v};return t.jsxs(t.Fragment,{children:[t.jsx("button",{style:S,onClick:L,"aria-label":"Open voice input",onMouseOver:C=>{C.currentTarget.style.transform="scale(1.1)",C.currentTarget.style.filter="drop-shadow(0 6px 20px rgba(255, 122, 0, 0.5))"},onMouseOut:C=>{C.currentTarget.style.transform="scale(1)",C.currentTarget.style.filter="drop-shadow(0 4px 12px rgba(255, 122, 0, 0.4))"},children:c||t.jsx("img",{src:X,alt:"Voice input",style:{width:"100%",height:"100%"}})}),t.jsx(ie,{isOpen:w,onClose:M,isListening:j,transcript:n,onStartListening:U,onStopListening:E,onResetTranscript:I,onGenerate:Y,isGenerating:k,title:y,generateButtonText:b})]})}const se=i.createContext(null);function Te({children:r,config:s,callbacks:p,showWidget:a=!1,widgetEnabled:l=!0,widgetPosition:u="bottom-left",widgetButtonSize:y=60,widgetZIndex:b=9998,modalTitle:c,generateButtonText:T,onGenerate:v,onGenerateComplete:R,onGenerateError:w}){const[_,k]=i.useState(l),g=J({config:s,callbacks:p}),n=i.useCallback(E=>{k(E)},[]),j=i.useCallback(()=>{k(E=>!E)},[]),U=i.useMemo(()=>({...g,isWidgetEnabled:_,setWidgetEnabled:n,toggleWidget:j}),[g,_,n,j]);return t.jsxs(se.Provider,{value:U,children:[r,a&&t.jsx(ae,{enabled:_,position:u,config:s,buttonSize:y,zIndex:b,modalTitle:c,generateButtonText:T,onGenerate:v,onGenerateComplete:R,onGenerateError:w})]})}function Re(){const r=i.useContext(se);if(!r)throw new Error("useSpeechContext must be used within a SpeechProvider");return r}const Ee={sm:60,md:100,lg:140},le={button:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",border:"none",borderRadius:"50%",cursor:"pointer",transition:"all 0.2s ease",background:"transparent",padding:0},disabled:{opacity:.5,cursor:"not-allowed"}},Ae=()=>t.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"32",height:"32",children:[t.jsx("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm-1-9c0-.55.45-1 1-1s1 .45 1 1v6c0 .55-.45 1-1 1s-1-.45-1-1V5z"}),t.jsx("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"})]}),Fe=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"32",height:"32",children:t.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})});function Oe({isListening:r,onStart:s,onStop:p,disabled:a=!1,className:l,style:u,startIcon:y,stopIcon:b,startLabel:c,stopLabel:T,size:v="md",useAssets:R=!0}){const w=()=>{a||(r?p():s())},_=Ee[v],k={...le.button,width:_,height:_,...a&&le.disabled,filter:R?"drop-shadow(0 4px 12px rgba(255, 122, 0, 0.4))":void 0,...u};return R?t.jsx("button",{type:"button",onClick:w,disabled:a,className:l,style:k,"aria-label":r?"Stop recording":"Start recording",children:t.jsx("img",{src:r?ne:X,alt:r?"Stop":"Start",style:{width:"100%",height:"100%"}})}):t.jsx("button",{type:"button",onClick:w,disabled:a,className:l,style:{...k,background:r?"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)":"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"white",boxShadow:r?"0 10px 40px rgba(239, 68, 68, 0.4)":"0 10px 40px rgba(102, 126, 234, 0.4)"},"aria-label":r?"Stop recording":"Start recording",children:t.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[r?b||t.jsx(Fe,{}):y||t.jsx(Ae,{}),(c||T)&&t.jsx("span",{style:{fontSize:v==="sm"?"10px":v==="md"?"12px":"14px"},children:r?T||"Stop":c||"Start"})]})})}const P={container:{width:"100%"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},title:{fontSize:"18px",fontWeight:600,margin:0},resetButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"8px 16px",borderRadius:"8px",border:"1px solid #374151",background:"transparent",color:"#9ca3af",fontSize:"14px",cursor:"pointer"},box:{background:"rgba(255, 255, 255, 0.03)",border:"1px solid #374151",borderRadius:"16px",padding:"24px",minHeight:"150px",overflowY:"auto"},text:{fontSize:"18px",lineHeight:1.75,margin:0,wordWrap:"break-word"},placeholder:{color:"#6b7280",fontSize:"16px",textAlign:"center",margin:0,padding:"32px 0"}},Be=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:t.jsx("path",{d:"M17.65 6.35A7.958 7.958 0 0012 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0112 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"})});function Ie({transcript:r,placeholder:s="Click the microphone to start speaking...",isListening:p=!1,className:a,style:l,onReset:u,showResetButton:y=!0,maxHeight:b="300px"}){const c={...P.box,maxHeight:b,...l};return t.jsxs("div",{className:a,style:P.container,children:[t.jsxs("div",{style:P.header,children:[t.jsx("h2",{style:P.title,children:"📝 Transcript"}),y&&u&&t.jsxs("button",{type:"button",onClick:u,disabled:!r,style:{...P.resetButton,opacity:r?1:.5,cursor:r?"pointer":"not-allowed"},children:[t.jsx(Be,{}),"Clear"]})]}),t.jsx("div",{style:c,children:r?t.jsx("p",{style:P.text,children:r}):t.jsx("p",{style:P.placeholder,children:p?"🎧 Listening... Speak now!":s})})]})}h.SpeechButton=Oe,h.SpeechModal=ie,h.SpeechProvider=Te,h.SpeechWidget=ae,h.TranscriptDisplay=Ie,h.formatConfidence=ge,h.getSpeechRecognition=$,h.getSupportedLanguages=he,h.isMicrophoneAvailable=fe,h.isSpeechRecognitionSupported=q,h.requestMicrophonePermission=ee,h.useSpeechContext=Re,h.useSpeechRecognition=J,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
|
14
|
+
`,t0=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"24",height:"24",children:e.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})}),r0=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:e.jsx("path",{d:"M12 2L9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2z"})}),o0=()=>e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M12 2L10.5 8.5L4 10L10.5 11.5L12 18L13.5 11.5L20 10L13.5 8.5L12 2Z",fill:"#9333ea"}),e.jsx("path",{d:"M5 14L4 17L7 16L5 14Z",fill:"#9333ea",opacity:"0.6"}),e.jsx("path",{d:"M19 14L20 17L17 16L19 14Z",fill:"#9333ea",opacity:"0.6"})]});function W({isOpen:t,onClose:a,isListening:s,transcript:l,onStartListening:d,onStopListening:f,onResetTranscript:x,onGenerate:_,isGenerating:n=!1,title:S="AI Speech-to-Data",generateButtonText:y="Generate",placeholder:C="Click the microphone and start speaking..."}){const h=o.useRef(null);o.useEffect(()=>{const r=w=>{w.key==="Escape"&&t&&!n&&a()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t,a,n]);const u=r=>{r.target===r.currentTarget&&!n&&a()};if(!t)return null;const m=()=>{n||(s?f():(x(),d()))},p=()=>{l&&!n&&_(l)};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:e0}),e.jsx("div",{style:i.overlay,onClick:u,children:e.jsxs("div",{ref:h,style:{...i.modal,animation:"fadeIn 0.25s ease-out"},onClick:r=>r.stopPropagation(),children:[n&&e.jsxs("div",{style:i.loadingOverlay,children:[e.jsx(o0,{}),e.jsxs("div",{style:i.loadingBars,children:[e.jsx("div",{style:{...i.loadingBar,width:"100%"}}),e.jsx("div",{style:{...i.loadingBar,width:"80%"}}),e.jsx("div",{style:{...i.loadingBar,width:"90%"}}),e.jsx("div",{style:{...i.loadingBar,width:"70%"}})]}),e.jsxs("span",{style:i.loadingText,children:[e.jsx("span",{style:i.sparkleIcon,children:"✨"}),"AI Analyzing"]})]}),e.jsxs("div",{style:i.header,children:[e.jsxs("h2",{style:i.title,children:[e.jsx("span",{style:{fontSize:"20px"},children:"✨"}),S]}),e.jsx("button",{style:i.closeButton,onClick:a,disabled:n,onMouseOver:r=>{n||(r.currentTarget.style.background="#f3f4f6")},onMouseOut:r=>{r.currentTarget.style.background="transparent"},children:e.jsx(t0,{})})]}),e.jsxs("div",{style:i.micSection,children:[e.jsx("img",{src:R,alt:"",style:{...i.bgCircle,opacity:s?1:.6,animation:s?"pulse-glow 2s ease-in-out infinite":"none"}}),e.jsx("button",{style:i.micButton,onClick:m,disabled:n,onMouseOver:r=>{n||(r.currentTarget.style.transform="scale(1.05)")},onMouseOut:r=>{r.currentTarget.style.transform="scale(1)"},children:e.jsx("img",{src:s?P:D,alt:s?"Stop":"Start recording",style:i.micImage})}),e.jsx("p",{style:{...i.statusText,...s?i.statusTextActive:{}},children:s?"AI is listening.":"Generate result"})]}),(l||!s)&&!n&&e.jsx("div",{style:i.transcriptBox,children:l?e.jsx("p",{style:i.transcriptText,children:l}):e.jsx("p",{style:i.placeholderText,children:C})}),!n&&e.jsx("div",{style:i.actions,children:e.jsxs("button",{style:{...i.generateButton,...l?{}:i.generateButtonDisabled},onClick:p,disabled:!l||n,onMouseOver:r=>{l&&!n&&(r.currentTarget.style.background="#9333ea",r.currentTarget.style.color="white")},onMouseOut:r=>{r.currentTarget.style.background="transparent",r.currentTarget.style.color=l?"#9333ea":"#9ca3af"},children:[e.jsx(r0,{}),y]})}),e.jsx("div",{style:i.footer,children:e.jsxs("span",{children:["Powered by ",e.jsx("strong",{children:"DFM"})]})})]})})]})}const i0=t=>{if(typeof t=="object")return{top:t.top,right:t.right,bottom:t.bottom,left:t.left};const a={"bottom-left":{bottom:"24px",left:"24px"},"bottom-right":{bottom:"24px",right:"24px"},"top-left":{top:"24px",left:"24px"},"top-right":{top:"24px",right:"24px"}};return a[t]||a["bottom-left"]};function j({enabled:t=!0,position:a="bottom-left",config:s={language:"th-TH",continuous:!0},onGenerate:l,onGenerateComplete:d,onGenerateError:f,modalTitle:x="AI Speech-to-Data",generateButtonText:_="Generate",buttonContent:n,buttonSize:S=64,buttonStyle:y,zIndex:C=9998}){const[h,u]=o.useState(!1),[m,p]=o.useState(!1),{transcript:r,isListening:w,startListening:U,stopListening:v,resetTranscript:F}=G({config:s}),z=o.useCallback(()=>{u(!0)},[]),M=o.useCallback(()=>{u(!1),w&&v()},[w,v]),q=o.useCallback(async g=>{if(!l){d?.(g),M(),F();return}p(!0);try{const k=await l(g);d?.(k),M(),F()}catch(k){f?.(k)}finally{p(!1)}},[l,d,f,M,F]);if(!t)return null;const b={position:"fixed",...i0(a),zIndex:C,width:S,height:S,borderRadius:"50%",border:"none",cursor:"pointer",background:"transparent",padding:0,transition:"all 0.3s ease",filter:"drop-shadow(0 4px 12px rgba(255, 122, 0, 0.4))",...y};return e.jsxs(e.Fragment,{children:[e.jsx("button",{style:b,onClick:z,"aria-label":"Open voice input",onMouseOver:g=>{g.currentTarget.style.transform="scale(1.1)",g.currentTarget.style.filter="drop-shadow(0 6px 20px rgba(255, 122, 0, 0.5))"},onMouseOut:g=>{g.currentTarget.style.transform="scale(1)",g.currentTarget.style.filter="drop-shadow(0 4px 12px rgba(255, 122, 0, 0.4))"},children:n||e.jsx("img",{src:D,alt:"Voice input",style:{width:"100%",height:"100%"}})}),e.jsx(W,{isOpen:h,onClose:M,isListening:w,transcript:r,onStartListening:U,onStopListening:v,onResetTranscript:F,onGenerate:q,isGenerating:m,title:x,generateButtonText:_})]})}const Z=o.createContext(null);function n0({children:t,config:a,callbacks:s,showWidget:l=!1,widgetEnabled:d=!0,widgetPosition:f="bottom-left",widgetButtonSize:x=60,widgetZIndex:_=9998,modalTitle:n,generateButtonText:S,onGenerate:y,onGenerateComplete:C,onGenerateError:h}){const[u,m]=o.useState(d),p=G({config:a,callbacks:s}),r=o.useCallback(v=>{m(v)},[]),w=o.useCallback(()=>{m(v=>!v)},[]),U=o.useMemo(()=>({...p,isWidgetEnabled:u,setWidgetEnabled:r,toggleWidget:w}),[p,u,r,w]);return e.jsxs(Z.Provider,{value:U,children:[t,l&&e.jsx(j,{enabled:u,position:f,config:a,buttonSize:x,zIndex:_,modalTitle:n,generateButtonText:S,onGenerate:y,onGenerateComplete:C,onGenerateError:h})]})}function a0(){const t=o.useContext(Z);if(!t)throw new Error("useSpeechContext must be used within a SpeechProvider");return t}const l0={sm:60,md:100,lg:140},N={button:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",border:"none",borderRadius:"50%",cursor:"pointer",transition:"all 0.2s ease",background:"transparent",padding:0},disabled:{opacity:.5,cursor:"not-allowed"}},c0=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"32",height:"32",children:[e.jsx("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm-1-9c0-.55.45-1 1-1s1 .45 1 1v6c0 .55-.45 1-1 1s-1-.45-1-1V5z"}),e.jsx("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"})]}),s0=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"32",height:"32",children:e.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})});function d0({isListening:t,onStart:a,onStop:s,disabled:l=!1,className:d,style:f,startIcon:x,stopIcon:_,startLabel:n,stopLabel:S,size:y="md",useAssets:C=!0}){const h=()=>{l||(t?s():a())},u=l0[y],m={...N.button,width:u,height:u,...l&&N.disabled,filter:C?"drop-shadow(0 4px 12px rgba(255, 122, 0, 0.4))":void 0,...f};return C?e.jsx("button",{type:"button",onClick:h,disabled:l,className:d,style:m,"aria-label":t?"Stop recording":"Start recording",children:e.jsx("img",{src:t?P:D,alt:t?"Stop":"Start",style:{width:"100%",height:"100%"}})}):e.jsx("button",{type:"button",onClick:h,disabled:l,className:d,style:{...m,background:t?"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)":"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"white",boxShadow:t?"0 10px 40px rgba(239, 68, 68, 0.4)":"0 10px 40px rgba(102, 126, 234, 0.4)"},"aria-label":t?"Stop recording":"Start recording",children:e.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[t?_||e.jsx(s0,{}):x||e.jsx(c0,{}),(n||S)&&e.jsx("span",{style:{fontSize:y==="sm"?"10px":y==="md"?"12px":"14px"},children:t?S||"Stop":n||"Start"})]})})}const B={container:{width:"100%"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},title:{fontSize:"18px",fontWeight:600,margin:0},resetButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"8px 16px",borderRadius:"8px",border:"1px solid #374151",background:"transparent",color:"#9ca3af",fontSize:"14px",cursor:"pointer"},box:{background:"rgba(255, 255, 255, 0.03)",border:"1px solid #374151",borderRadius:"16px",padding:"24px",minHeight:"150px",overflowY:"auto"},text:{fontSize:"18px",lineHeight:1.75,margin:0,wordWrap:"break-word"},placeholder:{color:"#6b7280",fontSize:"16px",textAlign:"center",margin:0,padding:"32px 0"}},p0=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:e.jsx("path",{d:"M17.65 6.35A7.958 7.958 0 0012 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0112 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"})});function f0({transcript:t,placeholder:a="Click the microphone to start speaking...",isListening:s=!1,className:l,style:d,onReset:f,showResetButton:x=!0,maxHeight:_="300px"}){const n={...B.box,maxHeight:_,...d};return e.jsxs("div",{className:l,style:B.container,children:[e.jsxs("div",{style:B.header,children:[e.jsx("h2",{style:B.title,children:"📝 Transcript"}),x&&f&&e.jsxs("button",{type:"button",onClick:f,disabled:!t,style:{...B.resetButton,opacity:t?1:.5,cursor:t?"pointer":"not-allowed"},children:[e.jsx(p0,{}),"Clear"]})]}),e.jsx("div",{style:n,children:t?e.jsx("p",{style:B.text,children:t}):e.jsx("p",{style:B.placeholder,children:s?"🎧 Listening... Speak now!":a})})]})}c.SpeechButton=d0,c.SpeechModal=W,c.SpeechProvider=n0,c.SpeechWidget=j,c.TranscriptDisplay=f0,c.formatConfidence=Y,c.getSpeechRecognition=V,c.getSupportedLanguages=K,c.isMicrophoneAvailable=J,c.isSpeechRecognitionSupported=E,c.requestMicrophonePermission=L,c.useSpeechContext=a0,c.useSpeechRecognition=G,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
|
20
15
|
//# sourceMappingURL=speech-recognition-sdk.umd.js.map
|