-
Notifications
You must be signed in to change notification settings - Fork 159
chore: merge to 0.81-stable merge base #2733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary: Pull Request resolved: facebook#52161 Changelog: [Internal] Add missing lib react_nativemodule_mutationobserver Reviewed By: christophpurrer Differential Revision: D77035742 fbshipit-source-id: f900024f0ad4f4e4596c4fa5730463277ee17242
Summary: Pull Request resolved: facebook#52162 Changelog: [Internal] Add cmake library react_nativemodule_webperformance Reviewed By: christophpurrer Differential Revision: D77035999 fbshipit-source-id: da267ddf10d9a9de315038142f7764d81190131a
Summary: Pull Request resolved: facebook#52163 Changelog: [Internal] Add cmake library react_renderer_observers_intersection Reviewed By: christophpurrer Differential Revision: D77036086 fbshipit-source-id: 9f7c2c9574c09f7775362a6155433fa194111f0b
Summary: Pull Request resolved: facebook#52164 Changelog: [Internal] Add cmake library react_renderer_observers_mutation Reviewed By: christophpurrer Differential Revision: D77036195 fbshipit-source-id: 6661b6aecab83b1fd254dd7f7fca1c906538aee5
Summary: Pull Request resolved: facebook#52165 Changelog: [Internal] Add cmake lib react_cxx_platform_react_coremodules Reviewed By: christophpurrer Differential Revision: D77036283 fbshipit-source-id: 54141d32f61d1025ae40c60335a6831ec038217e
Summary: Pull Request resolved: facebook#52166 Changelog: [Internal] Add cmake lib react_cxx_platform_react_devsupport Reviewed By: christophpurrer Differential Revision: D77037372 fbshipit-source-id: e6ed42492f29abfb93fe22b0c01a5d3a2ca7cf53
Summary: Pull Request resolved: facebook#52167 Changelog: [Internal] Add cmake lib react_cxx_platform_react_http Reviewed By: christophpurrer Differential Revision: D77037486 fbshipit-source-id: 7e90ed26cefa407a1e64ebdad8ac5835803c2c49
Summary: Pull Request resolved: facebook#52169 Changelog: [Internal] Add cmake lib react_cxx_platform_react_io Reviewed By: christophpurrer Differential Revision: D77037593 fbshipit-source-id: 849c2b0b0de14b9a583b997f3137763df59b4af1
Summary: Pull Request resolved: facebook#52170 Changelog: [Internal] Add cmake lib react_cxx_platform_react_logging Reviewed By: christophpurrer Differential Revision: D77037715 fbshipit-source-id: ea21160473d876c0014dcfc2d17323b2e0c4c0b2
Summary: Pull Request resolved: facebook#52171 Changelog: [Internal] Add cmake lib react_cxx_platform_react_nativemodule Reviewed By: christophpurrer Differential Revision: D77037835 fbshipit-source-id: 09346824c5e39ca9c41edeb22462d65408d95f18
Summary: Pull Request resolved: facebook#52172 Changelog: [Internal] Add cmake lib react_cxx_platform_react_profiling Reviewed By: christophpurrer Differential Revision: D77037934 fbshipit-source-id: 555a00cc59d48fd167810ba29075fb4cb3e53d62
Summary: Pull Request resolved: facebook#52173 Changelog: [Internal] Add cmake lib react_cxx_platform_react_renderer_animated Reviewed By: christophpurrer Differential Revision: D77038030 fbshipit-source-id: 6ca45f0251c74dc49b5c1d72c42575b80248eb2a
Summary: Pull Request resolved: facebook#52174 Changelog: [Internal] Add cmake lib react_cxx_platform_react_renderer_scheduler Reviewed By: christophpurrer Differential Revision: D77038129 fbshipit-source-id: f843c719d08f42f379042484542f4f4e5b94a2c6
Summary: Pull Request resolved: facebook#52175 Changelog: [Internal] Add cmake lib react_cxx_platform_react_renderer_uimanager Reviewed By: christophpurrer Differential Revision: D77038183 fbshipit-source-id: 736651e170884f69313711f744c40194f259bfa1
Summary: Pull Request resolved: facebook#52178 Changelog: [Internal] Add cmake lib react_cxx_platform_react_runtime Reviewed By: christophpurrer Differential Revision: D77038450 fbshipit-source-id: 54515f1aff84632c8a86abd8970107a1bd8ca043
Summary: Pull Request resolved: facebook#52176 Changelog: [Internal] Add cmake lib react_cxx_platform_react_threading Reviewed By: christophpurrer Differential Revision: D77038544 fbshipit-source-id: 950e28af49c5de3870e11e03d5123f22a0f04a6b
Summary: Pull Request resolved: facebook#52177 Changelog: [Internal] Add cmake lib react_cxx_platform_react_utils Reviewed By: christophpurrer Differential Revision: D77038580 fbshipit-source-id: 7cdd8defd57629342095587bd3e1819e04af50bd
Summary: Pull Request resolved: facebook#51971 Changelog: [Internal] Reviewed By: huntie Differential Revision: D76502294 fbshipit-source-id: ed98c5e6d9ef5fd6a4d1adbd6a88ce8cda52b969
Summary: Pull Request resolved: facebook#52085 Changelog: [Internal] Reviewed By: huntie Differential Revision: D76814453 fbshipit-source-id: fffbf585d63e282443830c08397ae5e4d745785a
Differential Revision: D76814453 Original commit changeset: fffbf585d63e Original Phabricator Diff: D76814453 fbshipit-source-id: 418ae90fb49c8c05f077bca7e434c039ad49c7ba
Summary: Pull Request resolved: facebook#52147 Simplify some of the nullability / checkNotNull behaviour Changelog: [Internal] Reviewed By: cortinico Differential Revision: D76334294 fbshipit-source-id: 32c2d0ab50713789ddf6af5e40083bae2161c91f
Summary: Pull Request resolved: facebook#52148 Address some Android Studio lint suggestions Changelog: [Internal] Reviewed By: cortinico Differential Revision: D77017839 fbshipit-source-id: c0e025ee7eaae74560cfc8ff6ecc45a893e0dda1
Summary: Pull Request resolved: facebook#52186 Changelog: [Internal] Minor fixes to spacing in cmake files and naming inconsistency Reviewed By: cortinico Differential Revision: D77141854 fbshipit-source-id: d1e12e571dbc0f7630d9d38faad7b22d0833dd2f
Summary: Splitting the CHANGELOG as it's getting too big to handle. Changelog: [Internal] [Changed] - bypass-github-export-checks Reviewed By: cipolleschi Differential Revision: D77025333 fbshipit-source-id: cf2d54f2096f9c8c6a3fadb354d0c3065370440d
Summary: Pull Request resolved: facebook#52185 It seems like one of the activity on the stack is not properly implementing `DefaultHardwareBackBtnHandler`. This will make the crash more clear as it will be clear which activity is the one responsible for the crash. Changelog: [Internal] [Changed] - Reviewed By: javache Differential Revision: D77142320 fbshipit-source-id: 1913976d1ad5d3ceafcfc0569f3b74dad9e919ae
…book#52195) Summary: Pull Request resolved: facebook#52195 RNTester is currently instacrashing on release due to use minifying the `ReactModalHostView`. In that class there is a static method that is accessed by JNI so we should annotated this class as `DoNotStrip` as otherwise we won't be able to access it. Changelog: [Internal] [Changed] - Reviewed By: cipolleschi Differential Revision: D77148010 fbshipit-source-id: c5b2758fa2919bc1f5885433202a45b4c3f8ff99
Summary: Pull Request resolved: facebook#52150 This is another class moving from Java to Kotlin. Changelog: [Internal] [Changed] - Reviewed By: javache Differential Revision: D77021952 fbshipit-source-id: 0b04a10bcbe65b7dc14ddd2821f80d90a43f8610
Summary: Pull Request resolved: facebook#52154 I wasn't able to find any meaningful usage of `EventDispatcherImpl` in OSS, therefore I'm making this class internal. Changelog: [Internal] [Changed] - Reviewed By: javache Differential Revision: D77024759 fbshipit-source-id: e1ff3329cedf96a8c75edb9b9ccc1ce21adfab11
…ebook#52198) Summary: Pull Request resolved: facebook#52198 # Changelog: [Internal] - This provides an implementation of what was the RnCxx ImageLoaderModule stub inside ReactCxxPlatform, allowing the clients use dependency injection to provide the actual platform specific image loading functionality. Reviewed By: javache Differential Revision: D77015269 fbshipit-source-id: 7355dd75692c1f564de8c3daffd6c8a79182dc09
Summary: Introduce rncore.rb to manage the prebuilds of RNCore. ## Context This PR introduces the first working version of building React Native apps on iOS using prebuilt RNCore and cocoapods. - Added React-Core-prebuilt.podspec for installing/consuming XCFrameworks - Added logic in react_native_pods.rb for switching between build from source and using prebuilts - Added rncore.rb - utilities for the ReactCore prebuilts - Updated rndependencies with some extra error handling modelled after rncode.rb - Added support for hard linking headers and modules in each inner framework in the XCFramework in xcframework.js ## Swift: To enable support for the objective-c types from swift, the swift compiler uses a module map to gather exports from the framework (module.modulemap). This file basically points to an umbrella header file that exports the valid objective-c types (non c++) to Swift. In addition these files are read from the DerivedData and not the project source - so it is a bit hard to control everyting. I was initially not able to use cocoapods own module definitions (module_name, module_file props) to use a custom module map. I finally found that these files are expected in the deriveddata (build folder) where only the active inner framework is copied - so then I had to hard link both module map and header files for each arch. bypass-github-export-checks ## Changelog: [INTERNAL] - Added script to handle React Core prebuilds Pull Request resolved: facebook#52109 Test Plan: Run with RN Tester. We need to remove all extra pods from RNTester pod file since none of them are yet compatible with prebuilt (they reference non-prebuilt pods) Rollback Plan: Reviewed By: cortinico, rshest Differential Revision: D76979549 Pulled By: cipolleschi fbshipit-source-id: 7a2b1809bf58b600293cc33ca2dcff0060f3fab0
…ative-github/packages/react-native/ReactCommon/react/utils (facebook#52444) Summary: Pull Request resolved: facebook#52444 Reviewed By: dtolnay Differential Revision: D77782134 fbshipit-source-id: 99989d45926a0eabcc6e19e12dce396a473e14ce
Summary: Pull Request resolved: facebook#52388 Changelog: [Internal] Similar to `AsyncCallback<>` (the foundation of `AsyncPromise`) we should allow `void` Promise types in C++ such as `AsyncPromise<>` Reviewed By: rbergerjr Differential Revision: D77712020 fbshipit-source-id: d7360df5cc1b77f1e03e5fb73b0b468f6e3a415b
Summary: Pull Request resolved: facebook#52407 Changelog: [Internal] The sample is from an outdated approach of enabling C++ Modules in RN which is not recommended anymore. Prefer C++ Turbo Modules if you need to expose / access C or C++ APIs in RN apps: https://reactnative.dev/docs/the-new-architecture/pure-cxx-modules Reviewed By: javache Differential Revision: D77765443 fbshipit-source-id: 112fef4c1a7e1c567f3c1d471728a1dfc926adc6
Summary: Pull Request resolved: facebook#52389 Changelog: [Internal] Reviewed By: philIip Differential Revision: D77706943 fbshipit-source-id: b8662737699ec0857845cfded49302ee9e93b78e
Summary: Pull Request resolved: facebook#52411 Changelog: [Internal] Reviewed By: javache, cortinico Differential Revision: D77770244 fbshipit-source-id: a300e377f8c6e52256ae04813c1372799cf5af59
Summary: Pull Request resolved: facebook#52412 Changelog: [Internal] The sample is from an outdated approach of enabling C++ Modules in RN which is not recommended anymore. Prefer C++ Turbo Modules if you need to expose / access C or C++ APIs in RN apps: https://reactnative.dev/docs/the-new-architecture/pure-cxx-modules It is not included in any RNTester app at this time Reviewed By: cortinico Differential Revision: D77770455 fbshipit-source-id: 987c9f2b9ab4145a2f6a724aad12d8473957dbe8
Summary: Pull Request resolved: facebook#52374 Precursor to removing `BugReporting` from React Native's internals. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D77014724 fbshipit-source-id: 91cd38fe6c39656573fecdeff18162073df2fb42
Summary: Pull Request resolved: facebook#52425 Changelog: [General][Breaking] - All `react-native/Libraries/BugReporting` APIs have been removed Reviewed By: javache Differential Revision: D77014767 fbshipit-source-id: a074fb952948a58259be66033e1f85e04bacf2de
…pha (facebook#52460) Summary: Upgrade `react-native-community/cli` to version 20. ## Changelog: [INTERNAL] [CHANGED] - Upgrade react-native-community/cli to v20 Pull Request resolved: facebook#52460 Test Plan: n/a Reviewed By: huntie Differential Revision: D77860027 Pulled By: cortinico fbshipit-source-id: 3eb3942b38091b4216628b94cdf1449838daa8d3
…ared_ptr<const ShadowNode>> (facebook#52402) Summary: Pull Request resolved: facebook#52402 changelog: [internal] Mark ShadowNode::ListOfShared as deprecated and replace most usages throughout the React Native renderer codebase with the explicit std::vector<std::shared_ptr<const ShadowNode>> type. This improves code clarity by making the container type explicit rather than relying on a type alias. Reviewed By: christophpurrer Differential Revision: D77651676 fbshipit-source-id: 8c4bd9b8cbbe467384b947ef9e7a4524f2053e36
| @@ -1 +1 @@ | |||
| function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,a,s){if(i<=o)return;const l=function(t,r,n,o,i){const a=t[i];e(t,o,i);let s=n;for(let i=n;i<o;++i)r(t[i],a)<0&&(e(t,s,i),++s);return e(t,o,s),s}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);a<l&&t(r,n,o,l-1,a,s),l<s&&t(r,n,l+1,i,a,s)}function r(e,t,r,n){const o=[];let i=0,a=0;for(;i<e.length&&a<t.length;){const s=r(e[i],t[a]);!n&&s||o.push(s<=0?e[i]:t[a]),s<=0&&i++,s>=0&&a++}if(n){for(;i<e.length;)o.push(e[i++]);for(;a<t.length;)o.push(t[a++])}return o}function n(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>0?i=n+1:a=n}return a}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,a=0,s=!1,l=!1,u=0;do{u=o+(i-o)/2,a=n?Math.ceil(u):Math.floor(u),s=t(e[a]),l=s===n,l?o=Math.min(i,a+(o===a?1:0)):i=Math.max(o,a+(i===a?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,a){return 0===n&&o===e.length-1&&0===i&&a>=o?e.sort(r):t(e,r,n,o,i,a),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>=0?i=n+1:a=n}return a},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),a=Object.freeze({__proto__:null});var s=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var l=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,a,s=0,l=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,s=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,s=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,s=0)}if(o&&"forward"!==o&&"both"!==o)a=e,l=t;else{let o=e;for(;o;){if(o===n){a||(a=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){a=o,l=n;break}}if(a)break;o=o.traverseNextNode(n)}a||(a=n,l=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,s),u.setEnd(a,l),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class h{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}keys(){return this.map.keys()}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var p=Object.freeze({__proto__:null,inverse:function(e){const t=new h;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:h,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const d=new Set(["application/ecmascript","application/javascript","application/json","application/json+protobuf","application/vnd.dart","application/xml","application/x-aspx","application/x-javascript","application/x-jsp","application/x-httpd-php"]);function g(e,t,r=0){for(let n=r;n<e.length;n++)if(t.includes(e[n]))return n;return-1}function m(e,t,r=0){for(let n=r;n<e.length;n++)if(!t.includes(e[n]))return n;return-1}var b=Object.freeze({__proto__:null,isTextType:function(e){return e.startsWith("text/")||e.endsWith("+json")||e.endsWith("+xml")||d.has(e)},parseContentType:function(e){if("*/*"===e)return{mimeType:null,charset:null};const{mimeType:t,params:r}=function(e){e=e.trim();let t=g(e," \t;(");t<0&&(t=e.length);const r=e.indexOf("/");if(r<0||r>t)return{mimeType:null,params:new Map};const n=e.substring(0,t).toLowerCase(),o=new Map;let i=e.indexOf(";",t);for(;i>=0&&i<e.length;){if(++i,i=m(e," \t",i),i<0)continue;const t=i;if(i=g(e,";=",i),i<0||";"===e[i])continue;const r=e.substring(t,i).toLowerCase();++i,i=m(e," \t",i);let n="";if(!(i<0||";"===e[i])){if('"'!==e[i]){const t=i;i=e.indexOf(";",i);const r=i>=0?i:e.length;n=e.substring(t,r).trimEnd()}else{for(++i;i<e.length&&'"'!==e[i];)"\\"===e[i]&&i+1<e.length&&++i,n+=e[i],++i;i=e.indexOf(";",i)}o.has(r)||o.set(r,n)}}return{mimeType:n,params:o}}(e);return{mimeType:t,charset:r.get("charset")?.toLowerCase().trim()??null}}});const w=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},x=new Map([["8∶5","16∶10"]]);var _=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:w,aspectRatio:(e,t)=>{const r=w(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return x.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var E=Object.freeze({__proto__:null,promiseWithResolvers:function(){let e,t;return{promise:new Promise(((r,n)=>{e=r,t=n})),resolve:e,reject:t}}});const O=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},N=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),y=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),A=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},v=/^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/,S="^[]{}()\\.^$*+?|-,",C=function(){return S},T=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!==C().indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};const U=/[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\b|_)|[A-Za-z][0-9]+[a-z]?|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g,M=function(e){return e.match?.(U)?.map((e=>e.toLowerCase())).join("-").replaceAll("-.-",".")||e};var R=Object.freeze({__proto__:null,escapeCharacters:O,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(y.has(r))return y.get(r);return"\\x"+N(r.charCodeAt(0),2)}if(n){return"\\u"+N(n.charCodeAt(0),4)}return t?y.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let a=Number(t[r++]);return isNaN(a)&&(a=0),"d"===i?String(Math.floor(a)).padStart(Number(o),"0"):void 0!==o?a.toFixed(Number(o)):String(a)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let a=0;for(let e=0;e<n;e++)o=e%3,a|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),t(63&a)),a=0);return 0===o?i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),61)),i},findIndexesOfSubString:A,findLineEndingIndexes:e=>{const t=A(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),isExtendedKebabCase:e=>v.test(e),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:C,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!==S.indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r,n=!1){const o=t?"g":"gi";let i;if(r)try{i=new RegExp(e,o)}catch(e){}return i||(i=T(e,o)),n&&i&&(i=new RegExp(`\\b${i.source}\\b`,o)),i},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>O(e,S),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,a;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),a=!Number.isNaN(Number(o)),i&&!a)return-1;if(a&&!i)return 1;if(i&&a){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},countUnmatchedLeftParentheses:e=>{let t=0;for(const r of e)"("===r?t++:")"===r&&t>0&&t--;return t},createPlainTextSearchRegex:T,toLowerCaseString:function(e){return e.toLowerCase()},toKebabCase:M,toKebabCaseKeys:function(e){const t={};for(const[r,n]of Object.entries(e))t[M(r)]=n;return t},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r},concatBase64:function(e,t){if(0===e.length||!e.endsWith("="))return e+t;const r=e.substring(0,e.length-4),n=e.substring(e.length-4);return r+window.btoa(window.atob(n)+window.atob(t))}});var z=Object.freeze({__proto__:null,secondsToMilliSeconds:function(e){return 1e3*e},milliSecondsToSeconds:function(e){return e/1e3},microSecondsToMilliSeconds:function(e){return e/1e3}});class L extends Uint32Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){return this}asArrayOrFail(){throw new Error("Not an array")}}class j{#e;#t;length;constructor(e,t){this.#e=[],this.length=e;let r=1;for(;;){r*=2,this.#t=Math.ceil(e/r);try{if(void 0!==t&&this.#t>t)throw new RangeError;for(let e=0;e<r;++e)this.#e[e]=new Uint32Array(this.#t);return}catch(e){if(this.#t<1e6)throw e}}}getValue(e){if(e>=0&&e<this.length){const t=this.#t;return this.#e[Math.floor(e/t)][e%t]}return this.#e[0][-1]}setValue(e,t){if(e>=0&&e<this.length){const r=this.#t;this.#e[Math.floor(e/r)][e%r]=t}}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){throw new Error("Not an array")}}class F extends Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){return this}}class $ extends Uint8Array{constructor(e){super(Math.ceil(e/8))}getBit(e){return 0!==(this[e>>3]&1<<(7&e))}setBit(e){this[e>>3]|=1<<(7&e)}clearBit(e){this[e>>3]&=~(1<<(7&e))}previous(e){for(;e!==e>>3<<3;)if(--e,this.getBit(e))return e;let t;for(t=(e>>3)-1;t>=0&&0===this[t];--t);if(t<0)return-1;for(e=7+(t<<3);e>=t<<3;--e)if(this.getBit(e))return e;throw new Error("Unreachable")}}var B=Object.freeze({__proto__:null,createExpandableBigUint32Array:function(){return new F},createFixedBigUint32Array:function(e,t){try{if(void 0!==t&&e>t)throw new RangeError;return new L(e)}catch{return new j(e,t)}},createBitVector:function(e){return new $(e)}});function k(e,t){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}${t?`\n${t}`:""}`)}function V(e,t){throw new Error(t)}function D(e){return e}var I=Object.freeze({__proto__:null,assertNotNullOrUndefined:k,assertNever:V,assertUnhandled:D});var W=Object.freeze({__proto__:null,LocalizedEmptyString:""});class K extends Error{message;constructor(e){super(e),this.message=e}}var P=Object.freeze({__proto__:null,UserVisibleError:K,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof K}});export{i as ArrayUtilities,a as Brand,u as DOMUtilities,s as DateUtilities,l as DevToolsPath,f as KeyboardUtilities,p as MapUtilities,b as MimeType,_ as NumberUtilities,E as PromiseUtilities,R as StringUtilities,z as Timing,I as TypeScriptUtilities,B as TypedArrayUtilities,W as UIString,P as UserVisibleError,V as assertNever,k as assertNotNullOrUndefined,D as assertUnhandled}; | |||
| function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,a,s){if(i<=o)return;const l=function(t,r,n,o,i){const a=t[i];e(t,o,i);let s=n;for(let i=n;i<o;++i)r(t[i],a)<0&&(e(t,s,i),++s);return e(t,o,s),s}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);a<l&&t(r,n,o,l-1,a,s),l<s&&t(r,n,l+1,i,a,s)}function r(e,t,r,n){const o=[];let i=0,a=0;for(;i<e.length&&a<t.length;){const s=r(e[i],t[a]);!n&&s||o.push(s<=0?e[i]:t[a]),s<=0&&i++,s>=0&&a++}if(n){for(;i<e.length;)o.push(e[i++]);for(;a<t.length;)o.push(t[a++])}return o}function n(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>0?i=n+1:a=n}return a}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,a=0,s=!1,l=!1,u=0;do{u=o+(i-o)/2,a=n?Math.ceil(u):Math.floor(u),s=t(e[a]),l=s===n,l?o=Math.min(i,a+(o===a?1:0)):i=Math.max(o,a+(i===a?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),lowerBound:n,mergeOrdered:(e,t,n)=>r(e,t,n,!0),nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,a){return 0===n&&o===e.length-1&&0===i&&a>=o?e.sort(r):t(e,r,n,o,i,a),e},upperBound:function(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>=0?i=n+1:a=n}return a}}),a=Object.freeze({__proto__:null}),s=Object.freeze({__proto__:null});var l=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var u=Object.freeze({__proto__:null,EmptyEncodedPathString:"",EmptyRawPathString:"",EmptyUrlString:"",urlString:(e,...t)=>String.raw({raw:e},...t)});var c=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,a,s=0,l=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,s=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,s=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,s=0)}if(o&&"forward"!==o&&"both"!==o)a=e,l=t;else{let o=e;for(;o;){if(o===n){a||(a=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){a=o,l=n;break}}if(a)break;o=o.traverseNextNode(n)}a||(a=n,l=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,s),u.setEnd(a,l),u}});const f=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var h=Object.freeze({__proto__:null,ARROW_KEYS:f,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key},isEscKey:function(e){return"Escape"===e.key},keyIsArrowKey:function(e){return f.has(e)}});class p{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}keys(){return this.map.keys()}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var g=Object.freeze({__proto__:null,Multimap:p,getWithDefault:function(e,t,r){let n=e.get(t);return null==n&&(n=r(t),e.set(t,n)),n},inverse:function(e){const t=new p;for(const[r,n]of e.entries())t.set(n,r);return t}});const d=new Set(["application/ecmascript","application/javascript","application/json","application/json+protobuf","application/mpegurl","application/vnd.apple.mpegurl","application/vnd.dart","application/xml","application/x-aspx","application/x-javascript","application/x-jsp","application/x-httpd-php","application/x-mpegurl","audio/mpegurl","audio/x-mpegurl"]);function m(e,t,r=0){for(let n=r;n<e.length;n++)if(t.includes(e[n]))return n;return-1}function b(e,t,r=0){for(let n=r;n<e.length;n++)if(!t.includes(e[n]))return n;return-1}var w=Object.freeze({__proto__:null,isTextType:function(e){return e.startsWith("text/")||e.startsWith("multipart/")||e.includes("+json")||e.endsWith("+xml")||d.has(e)},parseContentType:function(e){if("*/*"===e)return{mimeType:null,charset:null};const{mimeType:t,params:r}=function(e){e=e.trim();let t=m(e," \t;(");t<0&&(t=e.length);const r=e.indexOf("/");if(r<0||r>t)return{mimeType:null,params:new Map};const n=e.substring(0,t).toLowerCase(),o=new Map;let i=e.indexOf(";",t);for(;i>=0&&i<e.length;){if(++i,i=b(e," \t",i),i<0)continue;const t=i;if(i=m(e,";=",i),i<0||";"===e[i])continue;const r=e.substring(t,i).toLowerCase();++i,i=b(e," \t",i);let n="";if(!(i<0||";"===e[i])){if('"'!==e[i]){const t=i;i=e.indexOf(";",i);const r=i>=0?i:e.length;n=e.substring(t,r).trimEnd()}else{for(++i;i<e.length&&'"'!==e[i];)"\\"===e[i]&&i+1<e.length&&++i,n+=e[i],++i;i=e.indexOf(";",i)}o.has(r)||o.set(r,n)}}return{mimeType:n,params:o}}(e);return{mimeType:t,charset:r.get("charset")?.toLowerCase().trim()??null}}});const _=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},x=new Map([["8∶5","16∶10"]]);var E=Object.freeze({__proto__:null,aspectRatio:(e,t)=>{const r=_(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return x.get(n)||n},clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},floor:(e,t=0)=>{if(t>0&&t<1)return t=1/t,Math.floor(e/t)*t;const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:_,mod:(e,t)=>(e%t+t)%t,toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});const O=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},N=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),y=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),A=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},S=/^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/,v="^[]{}()\\.^$*+?|-,",C=function(){return v},T=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!==C().indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};const U=/[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\b|_)|[A-Za-z][0-9]+[a-z]?|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g,z=function(e){return e.match?.(U)?.map((e=>e.toLowerCase())).join("-").replaceAll("-.-",".")||e};var L=Object.freeze({__proto__:null,DOUBLE_QUOTE:'"',SINGLE_QUOTE:"'",base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),compare:(e,t)=>e>t?1:e<t?-1:0,concatBase64:function(e,t){if(0===e.length||!e.endsWith("="))return e+t;const r=e.substring(0,e.length-4),n=e.substring(e.length-4);return r+window.btoa(window.atob(n)+window.atob(t))},countUnmatchedLeftParentheses:e=>{let t=0;for(const r of e)"("===r?t++:")"===r&&t>0&&t--;return t},countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},createPlainTextSearchRegex:T,createSearchRegex:function(e,t,r,n=!1){const o=t?"g":"gi";let i;if(r)try{i=new RegExp(e,o)}catch{}return i||(i=T(e,o)),n&&i&&(i=new RegExp(`\\b${i.source}\\b`,o)),i},escapeCharacters:O,escapeForRegExp:e=>O(e,v),filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!==v.indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},findIndexesOfSubString:A,findLineEndingIndexes:e=>{const t=A(e,"\n");return t.push(e.length),t},findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(y.has(r))return y.get(r);return"\\x"+N(r.charCodeAt(0),2)}if(n){return"\\u"+N(n.charCodeAt(0),4)}return t?y.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},isExtendedKebabCase:e=>S.test(e),isWhitespace:e=>/^\s*$/.test(e),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,a;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),a=!Number.isNaN(Number(o)),i&&!a)return-1;if(a&&!i)return 1;if(i&&a){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},regexSpecialCharacters:C,removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},reverse:e=>e.split("").reverse().join(""),sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let a=Number(t[r++]);return isNaN(a)&&(a=0),"d"===i?String(Math.floor(a)).padStart(Number(o),"0"):void 0!==o?a.toFixed(Number(o)):String(a)}))},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let a=0;for(let e=0;e<n;e++)o=e%3,a|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),t(63&a)),a=0);return 0===o?i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),61)),i},toKebabCase:z,toKebabCaseKeys:function(e){const t={};for(const[r,n]of Object.entries(e))t[z(r)]=n;return t},toLowerCaseString:function(e){return e.toLowerCase()},toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r}});var M=Object.freeze({__proto__:null,microSecondsToMilliSeconds:function(e){return e/1e3},milliSecondsToSeconds:function(e){return e/1e3}});class R extends Uint32Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){return this}asArrayOrFail(){throw new Error("Not an array")}}class j{#e;#t;length;constructor(e,t){this.#e=[],this.length=e;let r=1;for(;;){r*=2,this.#t=Math.ceil(e/r);try{if(void 0!==t&&this.#t>t)throw new RangeError;for(let e=0;e<r;++e)this.#e[e]=new Uint32Array(this.#t);return}catch(e){if(this.#t<1e6)throw e}}}getValue(e){if(e>=0&&e<this.length){const t=this.#t;return this.#e[Math.floor(e/t)][e%t]}return this.#e[0][-1]}setValue(e,t){if(e>=0&&e<this.length){const r=this.#t;this.#e[Math.floor(e/r)][e%r]=t}}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){throw new Error("Not an array")}}class F extends Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){return this}}class $ extends Uint8Array{constructor(e){super("number"==typeof e?Math.ceil(e/8):e)}getBit(e){return 0!==(this[e>>3]&1<<(7&e))}setBit(e){this[e>>3]|=1<<(7&e)}clearBit(e){this[e>>3]&=~(1<<(7&e))}previous(e){for(;e!==e>>3<<3;)if(--e,this.getBit(e))return e;let t=(e>>3)-1;for(;t>=0&&0===this[t];)--t;if(t<0)return-1;for(e=7+(t<<3);e>=t<<3;--e)if(this.getBit(e))return e;throw new Error("Unreachable")}}var B=Object.freeze({__proto__:null,createBitVector:function(e){return new $(e)},createExpandableBigUint32Array:function(){return new F},createFixedBigUint32Array:function(e,t){try{if(void 0!==t&&e>t)throw new RangeError;return new R(e)}catch{return new j(e,t)}}});function V(e,t){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}${t?`\n${t}`:""}`)}function k(e,t){throw new Error(t)}function D(e){return e}var I=Object.freeze({__proto__:null,assertNever:k,assertNotNullOrUndefined:V,assertUnhandled:D});var W=Object.freeze({__proto__:null,LocalizedEmptyString:""});class K extends Error{message;constructor(e){super(e),this.message=e}}var P=Object.freeze({__proto__:null,UserVisibleError:K,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof K}});export{i as ArrayUtilities,a as Brand,s as Constructor,c as DOMUtilities,l as DateUtilities,u as DevToolsPath,h as KeyboardUtilities,g as MapUtilities,w as MimeType,E as NumberUtilities,L as StringUtilities,M as Timing,I as TypeScriptUtilities,B as TypedArrayUtilities,W as UIString,P as UserVisibleError,k as assertNever,V as assertNotNullOrUndefined,D as assertUnhandled}; | |||
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High library
<!--
| @@ -1 +1 @@ | |||
| function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,a,s){if(i<=o)return;const l=function(t,r,n,o,i){const a=t[i];e(t,o,i);let s=n;for(let i=n;i<o;++i)r(t[i],a)<0&&(e(t,s,i),++s);return e(t,o,s),s}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);a<l&&t(r,n,o,l-1,a,s),l<s&&t(r,n,l+1,i,a,s)}function r(e,t,r,n){const o=[];let i=0,a=0;for(;i<e.length&&a<t.length;){const s=r(e[i],t[a]);!n&&s||o.push(s<=0?e[i]:t[a]),s<=0&&i++,s>=0&&a++}if(n){for(;i<e.length;)o.push(e[i++]);for(;a<t.length;)o.push(t[a++])}return o}function n(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>0?i=n+1:a=n}return a}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,a=0,s=!1,l=!1,u=0;do{u=o+(i-o)/2,a=n?Math.ceil(u):Math.floor(u),s=t(e[a]),l=s===n,l?o=Math.min(i,a+(o===a?1:0)):i=Math.max(o,a+(i===a?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,a){return 0===n&&o===e.length-1&&0===i&&a>=o?e.sort(r):t(e,r,n,o,i,a),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>=0?i=n+1:a=n}return a},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),a=Object.freeze({__proto__:null});var s=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var l=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,a,s=0,l=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,s=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,s=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,s=0)}if(o&&"forward"!==o&&"both"!==o)a=e,l=t;else{let o=e;for(;o;){if(o===n){a||(a=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){a=o,l=n;break}}if(a)break;o=o.traverseNextNode(n)}a||(a=n,l=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,s),u.setEnd(a,l),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class h{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}keys(){return this.map.keys()}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var p=Object.freeze({__proto__:null,inverse:function(e){const t=new h;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:h,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const d=new Set(["application/ecmascript","application/javascript","application/json","application/json+protobuf","application/vnd.dart","application/xml","application/x-aspx","application/x-javascript","application/x-jsp","application/x-httpd-php"]);function g(e,t,r=0){for(let n=r;n<e.length;n++)if(t.includes(e[n]))return n;return-1}function m(e,t,r=0){for(let n=r;n<e.length;n++)if(!t.includes(e[n]))return n;return-1}var b=Object.freeze({__proto__:null,isTextType:function(e){return e.startsWith("text/")||e.endsWith("+json")||e.endsWith("+xml")||d.has(e)},parseContentType:function(e){if("*/*"===e)return{mimeType:null,charset:null};const{mimeType:t,params:r}=function(e){e=e.trim();let t=g(e," \t;(");t<0&&(t=e.length);const r=e.indexOf("/");if(r<0||r>t)return{mimeType:null,params:new Map};const n=e.substring(0,t).toLowerCase(),o=new Map;let i=e.indexOf(";",t);for(;i>=0&&i<e.length;){if(++i,i=m(e," \t",i),i<0)continue;const t=i;if(i=g(e,";=",i),i<0||";"===e[i])continue;const r=e.substring(t,i).toLowerCase();++i,i=m(e," \t",i);let n="";if(!(i<0||";"===e[i])){if('"'!==e[i]){const t=i;i=e.indexOf(";",i);const r=i>=0?i:e.length;n=e.substring(t,r).trimEnd()}else{for(++i;i<e.length&&'"'!==e[i];)"\\"===e[i]&&i+1<e.length&&++i,n+=e[i],++i;i=e.indexOf(";",i)}o.has(r)||o.set(r,n)}}return{mimeType:n,params:o}}(e);return{mimeType:t,charset:r.get("charset")?.toLowerCase().trim()??null}}});const w=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},x=new Map([["8∶5","16∶10"]]);var _=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:w,aspectRatio:(e,t)=>{const r=w(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return x.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var E=Object.freeze({__proto__:null,promiseWithResolvers:function(){let e,t;return{promise:new Promise(((r,n)=>{e=r,t=n})),resolve:e,reject:t}}});const O=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},N=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),y=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),A=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},v=/^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/,S="^[]{}()\\.^$*+?|-,",C=function(){return S},T=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!==C().indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};const U=/[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\b|_)|[A-Za-z][0-9]+[a-z]?|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g,M=function(e){return e.match?.(U)?.map((e=>e.toLowerCase())).join("-").replaceAll("-.-",".")||e};var R=Object.freeze({__proto__:null,escapeCharacters:O,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(y.has(r))return y.get(r);return"\\x"+N(r.charCodeAt(0),2)}if(n){return"\\u"+N(n.charCodeAt(0),4)}return t?y.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let a=Number(t[r++]);return isNaN(a)&&(a=0),"d"===i?String(Math.floor(a)).padStart(Number(o),"0"):void 0!==o?a.toFixed(Number(o)):String(a)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let a=0;for(let e=0;e<n;e++)o=e%3,a|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),t(63&a)),a=0);return 0===o?i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),61)),i},findIndexesOfSubString:A,findLineEndingIndexes:e=>{const t=A(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),isExtendedKebabCase:e=>v.test(e),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:C,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!==S.indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r,n=!1){const o=t?"g":"gi";let i;if(r)try{i=new RegExp(e,o)}catch(e){}return i||(i=T(e,o)),n&&i&&(i=new RegExp(`\\b${i.source}\\b`,o)),i},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>O(e,S),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,a;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),a=!Number.isNaN(Number(o)),i&&!a)return-1;if(a&&!i)return 1;if(i&&a){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},countUnmatchedLeftParentheses:e=>{let t=0;for(const r of e)"("===r?t++:")"===r&&t>0&&t--;return t},createPlainTextSearchRegex:T,toLowerCaseString:function(e){return e.toLowerCase()},toKebabCase:M,toKebabCaseKeys:function(e){const t={};for(const[r,n]of Object.entries(e))t[M(r)]=n;return t},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r},concatBase64:function(e,t){if(0===e.length||!e.endsWith("="))return e+t;const r=e.substring(0,e.length-4),n=e.substring(e.length-4);return r+window.btoa(window.atob(n)+window.atob(t))}});var z=Object.freeze({__proto__:null,secondsToMilliSeconds:function(e){return 1e3*e},milliSecondsToSeconds:function(e){return e/1e3},microSecondsToMilliSeconds:function(e){return e/1e3}});class L extends Uint32Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){return this}asArrayOrFail(){throw new Error("Not an array")}}class j{#e;#t;length;constructor(e,t){this.#e=[],this.length=e;let r=1;for(;;){r*=2,this.#t=Math.ceil(e/r);try{if(void 0!==t&&this.#t>t)throw new RangeError;for(let e=0;e<r;++e)this.#e[e]=new Uint32Array(this.#t);return}catch(e){if(this.#t<1e6)throw e}}}getValue(e){if(e>=0&&e<this.length){const t=this.#t;return this.#e[Math.floor(e/t)][e%t]}return this.#e[0][-1]}setValue(e,t){if(e>=0&&e<this.length){const r=this.#t;this.#e[Math.floor(e/r)][e%r]=t}}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){throw new Error("Not an array")}}class F extends Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){return this}}class $ extends Uint8Array{constructor(e){super(Math.ceil(e/8))}getBit(e){return 0!==(this[e>>3]&1<<(7&e))}setBit(e){this[e>>3]|=1<<(7&e)}clearBit(e){this[e>>3]&=~(1<<(7&e))}previous(e){for(;e!==e>>3<<3;)if(--e,this.getBit(e))return e;let t;for(t=(e>>3)-1;t>=0&&0===this[t];--t);if(t<0)return-1;for(e=7+(t<<3);e>=t<<3;--e)if(this.getBit(e))return e;throw new Error("Unreachable")}}var B=Object.freeze({__proto__:null,createExpandableBigUint32Array:function(){return new F},createFixedBigUint32Array:function(e,t){try{if(void 0!==t&&e>t)throw new RangeError;return new L(e)}catch{return new j(e,t)}},createBitVector:function(e){return new $(e)}});function k(e,t){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}${t?`\n${t}`:""}`)}function V(e,t){throw new Error(t)}function D(e){return e}var I=Object.freeze({__proto__:null,assertNotNullOrUndefined:k,assertNever:V,assertUnhandled:D});var W=Object.freeze({__proto__:null,LocalizedEmptyString:""});class K extends Error{message;constructor(e){super(e),this.message=e}}var P=Object.freeze({__proto__:null,UserVisibleError:K,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof K}});export{i as ArrayUtilities,a as Brand,u as DOMUtilities,s as DateUtilities,l as DevToolsPath,f as KeyboardUtilities,p as MapUtilities,b as MimeType,_ as NumberUtilities,E as PromiseUtilities,R as StringUtilities,z as Timing,I as TypeScriptUtilities,B as TypedArrayUtilities,W as UIString,P as UserVisibleError,V as assertNever,k as assertNotNullOrUndefined,D as assertUnhandled}; | |||
| function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,a,s){if(i<=o)return;const l=function(t,r,n,o,i){const a=t[i];e(t,o,i);let s=n;for(let i=n;i<o;++i)r(t[i],a)<0&&(e(t,s,i),++s);return e(t,o,s),s}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);a<l&&t(r,n,o,l-1,a,s),l<s&&t(r,n,l+1,i,a,s)}function r(e,t,r,n){const o=[];let i=0,a=0;for(;i<e.length&&a<t.length;){const s=r(e[i],t[a]);!n&&s||o.push(s<=0?e[i]:t[a]),s<=0&&i++,s>=0&&a++}if(n){for(;i<e.length;)o.push(e[i++]);for(;a<t.length;)o.push(t[a++])}return o}function n(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>0?i=n+1:a=n}return a}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,a=0,s=!1,l=!1,u=0;do{u=o+(i-o)/2,a=n?Math.ceil(u):Math.floor(u),s=t(e[a]),l=s===n,l?o=Math.min(i,a+(o===a?1:0)):i=Math.max(o,a+(i===a?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),lowerBound:n,mergeOrdered:(e,t,n)=>r(e,t,n,!0),nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,a){return 0===n&&o===e.length-1&&0===i&&a>=o?e.sort(r):t(e,r,n,o,i,a),e},upperBound:function(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>=0?i=n+1:a=n}return a}}),a=Object.freeze({__proto__:null}),s=Object.freeze({__proto__:null});var l=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var u=Object.freeze({__proto__:null,EmptyEncodedPathString:"",EmptyRawPathString:"",EmptyUrlString:"",urlString:(e,...t)=>String.raw({raw:e},...t)});var c=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,a,s=0,l=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,s=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,s=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,s=0)}if(o&&"forward"!==o&&"both"!==o)a=e,l=t;else{let o=e;for(;o;){if(o===n){a||(a=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){a=o,l=n;break}}if(a)break;o=o.traverseNextNode(n)}a||(a=n,l=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,s),u.setEnd(a,l),u}});const f=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var h=Object.freeze({__proto__:null,ARROW_KEYS:f,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key},isEscKey:function(e){return"Escape"===e.key},keyIsArrowKey:function(e){return f.has(e)}});class p{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}keys(){return this.map.keys()}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var g=Object.freeze({__proto__:null,Multimap:p,getWithDefault:function(e,t,r){let n=e.get(t);return null==n&&(n=r(t),e.set(t,n)),n},inverse:function(e){const t=new p;for(const[r,n]of e.entries())t.set(n,r);return t}});const d=new Set(["application/ecmascript","application/javascript","application/json","application/json+protobuf","application/mpegurl","application/vnd.apple.mpegurl","application/vnd.dart","application/xml","application/x-aspx","application/x-javascript","application/x-jsp","application/x-httpd-php","application/x-mpegurl","audio/mpegurl","audio/x-mpegurl"]);function m(e,t,r=0){for(let n=r;n<e.length;n++)if(t.includes(e[n]))return n;return-1}function b(e,t,r=0){for(let n=r;n<e.length;n++)if(!t.includes(e[n]))return n;return-1}var w=Object.freeze({__proto__:null,isTextType:function(e){return e.startsWith("text/")||e.startsWith("multipart/")||e.includes("+json")||e.endsWith("+xml")||d.has(e)},parseContentType:function(e){if("*/*"===e)return{mimeType:null,charset:null};const{mimeType:t,params:r}=function(e){e=e.trim();let t=m(e," \t;(");t<0&&(t=e.length);const r=e.indexOf("/");if(r<0||r>t)return{mimeType:null,params:new Map};const n=e.substring(0,t).toLowerCase(),o=new Map;let i=e.indexOf(";",t);for(;i>=0&&i<e.length;){if(++i,i=b(e," \t",i),i<0)continue;const t=i;if(i=m(e,";=",i),i<0||";"===e[i])continue;const r=e.substring(t,i).toLowerCase();++i,i=b(e," \t",i);let n="";if(!(i<0||";"===e[i])){if('"'!==e[i]){const t=i;i=e.indexOf(";",i);const r=i>=0?i:e.length;n=e.substring(t,r).trimEnd()}else{for(++i;i<e.length&&'"'!==e[i];)"\\"===e[i]&&i+1<e.length&&++i,n+=e[i],++i;i=e.indexOf(";",i)}o.has(r)||o.set(r,n)}}return{mimeType:n,params:o}}(e);return{mimeType:t,charset:r.get("charset")?.toLowerCase().trim()??null}}});const _=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},x=new Map([["8∶5","16∶10"]]);var E=Object.freeze({__proto__:null,aspectRatio:(e,t)=>{const r=_(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return x.get(n)||n},clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},floor:(e,t=0)=>{if(t>0&&t<1)return t=1/t,Math.floor(e/t)*t;const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:_,mod:(e,t)=>(e%t+t)%t,toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});const O=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},N=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),y=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),A=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},S=/^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/,v="^[]{}()\\.^$*+?|-,",C=function(){return v},T=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!==C().indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};const U=/[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\b|_)|[A-Za-z][0-9]+[a-z]?|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g,z=function(e){return e.match?.(U)?.map((e=>e.toLowerCase())).join("-").replaceAll("-.-",".")||e};var L=Object.freeze({__proto__:null,DOUBLE_QUOTE:'"',SINGLE_QUOTE:"'",base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),compare:(e,t)=>e>t?1:e<t?-1:0,concatBase64:function(e,t){if(0===e.length||!e.endsWith("="))return e+t;const r=e.substring(0,e.length-4),n=e.substring(e.length-4);return r+window.btoa(window.atob(n)+window.atob(t))},countUnmatchedLeftParentheses:e=>{let t=0;for(const r of e)"("===r?t++:")"===r&&t>0&&t--;return t},countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},createPlainTextSearchRegex:T,createSearchRegex:function(e,t,r,n=!1){const o=t?"g":"gi";let i;if(r)try{i=new RegExp(e,o)}catch{}return i||(i=T(e,o)),n&&i&&(i=new RegExp(`\\b${i.source}\\b`,o)),i},escapeCharacters:O,escapeForRegExp:e=>O(e,v),filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!==v.indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},findIndexesOfSubString:A,findLineEndingIndexes:e=>{const t=A(e,"\n");return t.push(e.length),t},findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(y.has(r))return y.get(r);return"\\x"+N(r.charCodeAt(0),2)}if(n){return"\\u"+N(n.charCodeAt(0),4)}return t?y.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},isExtendedKebabCase:e=>S.test(e),isWhitespace:e=>/^\s*$/.test(e),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,a;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),a=!Number.isNaN(Number(o)),i&&!a)return-1;if(a&&!i)return 1;if(i&&a){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},regexSpecialCharacters:C,removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},reverse:e=>e.split("").reverse().join(""),sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let a=Number(t[r++]);return isNaN(a)&&(a=0),"d"===i?String(Math.floor(a)).padStart(Number(o),"0"):void 0!==o?a.toFixed(Number(o)):String(a)}))},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let a=0;for(let e=0;e<n;e++)o=e%3,a|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),t(63&a)),a=0);return 0===o?i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),61)),i},toKebabCase:z,toKebabCaseKeys:function(e){const t={};for(const[r,n]of Object.entries(e))t[z(r)]=n;return t},toLowerCaseString:function(e){return e.toLowerCase()},toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r}});var M=Object.freeze({__proto__:null,microSecondsToMilliSeconds:function(e){return e/1e3},milliSecondsToSeconds:function(e){return e/1e3}});class R extends Uint32Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){return this}asArrayOrFail(){throw new Error("Not an array")}}class j{#e;#t;length;constructor(e,t){this.#e=[],this.length=e;let r=1;for(;;){r*=2,this.#t=Math.ceil(e/r);try{if(void 0!==t&&this.#t>t)throw new RangeError;for(let e=0;e<r;++e)this.#e[e]=new Uint32Array(this.#t);return}catch(e){if(this.#t<1e6)throw e}}}getValue(e){if(e>=0&&e<this.length){const t=this.#t;return this.#e[Math.floor(e/t)][e%t]}return this.#e[0][-1]}setValue(e,t){if(e>=0&&e<this.length){const r=this.#t;this.#e[Math.floor(e/r)][e%r]=t}}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){throw new Error("Not an array")}}class F extends Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){return this}}class $ extends Uint8Array{constructor(e){super("number"==typeof e?Math.ceil(e/8):e)}getBit(e){return 0!==(this[e>>3]&1<<(7&e))}setBit(e){this[e>>3]|=1<<(7&e)}clearBit(e){this[e>>3]&=~(1<<(7&e))}previous(e){for(;e!==e>>3<<3;)if(--e,this.getBit(e))return e;let t=(e>>3)-1;for(;t>=0&&0===this[t];)--t;if(t<0)return-1;for(e=7+(t<<3);e>=t<<3;--e)if(this.getBit(e))return e;throw new Error("Unreachable")}}var B=Object.freeze({__proto__:null,createBitVector:function(e){return new $(e)},createExpandableBigUint32Array:function(){return new F},createFixedBigUint32Array:function(e,t){try{if(void 0!==t&&e>t)throw new RangeError;return new R(e)}catch{return new j(e,t)}}});function V(e,t){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}${t?`\n${t}`:""}`)}function k(e,t){throw new Error(t)}function D(e){return e}var I=Object.freeze({__proto__:null,assertNever:k,assertNotNullOrUndefined:V,assertUnhandled:D});var W=Object.freeze({__proto__:null,LocalizedEmptyString:""});class K extends Error{message;constructor(e){super(e),this.message=e}}var P=Object.freeze({__proto__:null,UserVisibleError:K,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof K}});export{i as ArrayUtilities,a as Brand,s as Constructor,c as DOMUtilities,l as DateUtilities,u as DevToolsPath,h as KeyboardUtilities,g as MapUtilities,w as MimeType,E as NumberUtilities,L as StringUtilities,M as Timing,I as TypeScriptUtilities,B as TypedArrayUtilities,W as UIString,P as UserVisibleError,k as assertNever,V as assertNotNullOrUndefined,D as assertUnhandled}; | |||
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High library
<!--
| @@ -1 +1 @@ | |||
| function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,a,s){if(i<=o)return;const l=function(t,r,n,o,i){const a=t[i];e(t,o,i);let s=n;for(let i=n;i<o;++i)r(t[i],a)<0&&(e(t,s,i),++s);return e(t,o,s),s}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);a<l&&t(r,n,o,l-1,a,s),l<s&&t(r,n,l+1,i,a,s)}function r(e,t,r,n){const o=[];let i=0,a=0;for(;i<e.length&&a<t.length;){const s=r(e[i],t[a]);!n&&s||o.push(s<=0?e[i]:t[a]),s<=0&&i++,s>=0&&a++}if(n){for(;i<e.length;)o.push(e[i++]);for(;a<t.length;)o.push(t[a++])}return o}function n(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>0?i=n+1:a=n}return a}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,a=0,s=!1,l=!1,u=0;do{u=o+(i-o)/2,a=n?Math.ceil(u):Math.floor(u),s=t(e[a]),l=s===n,l?o=Math.min(i,a+(o===a?1:0)):i=Math.max(o,a+(i===a?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,a){return 0===n&&o===e.length-1&&0===i&&a>=o?e.sort(r):t(e,r,n,o,i,a),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>=0?i=n+1:a=n}return a},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),a=Object.freeze({__proto__:null});var s=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var l=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,a,s=0,l=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,s=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,s=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,s=0)}if(o&&"forward"!==o&&"both"!==o)a=e,l=t;else{let o=e;for(;o;){if(o===n){a||(a=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){a=o,l=n;break}}if(a)break;o=o.traverseNextNode(n)}a||(a=n,l=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,s),u.setEnd(a,l),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class h{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}keys(){return this.map.keys()}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var p=Object.freeze({__proto__:null,inverse:function(e){const t=new h;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:h,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const d=new Set(["application/ecmascript","application/javascript","application/json","application/json+protobuf","application/vnd.dart","application/xml","application/x-aspx","application/x-javascript","application/x-jsp","application/x-httpd-php"]);function g(e,t,r=0){for(let n=r;n<e.length;n++)if(t.includes(e[n]))return n;return-1}function m(e,t,r=0){for(let n=r;n<e.length;n++)if(!t.includes(e[n]))return n;return-1}var b=Object.freeze({__proto__:null,isTextType:function(e){return e.startsWith("text/")||e.endsWith("+json")||e.endsWith("+xml")||d.has(e)},parseContentType:function(e){if("*/*"===e)return{mimeType:null,charset:null};const{mimeType:t,params:r}=function(e){e=e.trim();let t=g(e," \t;(");t<0&&(t=e.length);const r=e.indexOf("/");if(r<0||r>t)return{mimeType:null,params:new Map};const n=e.substring(0,t).toLowerCase(),o=new Map;let i=e.indexOf(";",t);for(;i>=0&&i<e.length;){if(++i,i=m(e," \t",i),i<0)continue;const t=i;if(i=g(e,";=",i),i<0||";"===e[i])continue;const r=e.substring(t,i).toLowerCase();++i,i=m(e," \t",i);let n="";if(!(i<0||";"===e[i])){if('"'!==e[i]){const t=i;i=e.indexOf(";",i);const r=i>=0?i:e.length;n=e.substring(t,r).trimEnd()}else{for(++i;i<e.length&&'"'!==e[i];)"\\"===e[i]&&i+1<e.length&&++i,n+=e[i],++i;i=e.indexOf(";",i)}o.has(r)||o.set(r,n)}}return{mimeType:n,params:o}}(e);return{mimeType:t,charset:r.get("charset")?.toLowerCase().trim()??null}}});const w=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},x=new Map([["8∶5","16∶10"]]);var _=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:w,aspectRatio:(e,t)=>{const r=w(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return x.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var E=Object.freeze({__proto__:null,promiseWithResolvers:function(){let e,t;return{promise:new Promise(((r,n)=>{e=r,t=n})),resolve:e,reject:t}}});const O=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},N=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),y=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),A=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},v=/^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/,S="^[]{}()\\.^$*+?|-,",C=function(){return S},T=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!==C().indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};const U=/[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\b|_)|[A-Za-z][0-9]+[a-z]?|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g,M=function(e){return e.match?.(U)?.map((e=>e.toLowerCase())).join("-").replaceAll("-.-",".")||e};var R=Object.freeze({__proto__:null,escapeCharacters:O,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(y.has(r))return y.get(r);return"\\x"+N(r.charCodeAt(0),2)}if(n){return"\\u"+N(n.charCodeAt(0),4)}return t?y.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let a=Number(t[r++]);return isNaN(a)&&(a=0),"d"===i?String(Math.floor(a)).padStart(Number(o),"0"):void 0!==o?a.toFixed(Number(o)):String(a)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let a=0;for(let e=0;e<n;e++)o=e%3,a|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),t(63&a)),a=0);return 0===o?i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),61)),i},findIndexesOfSubString:A,findLineEndingIndexes:e=>{const t=A(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),isExtendedKebabCase:e=>v.test(e),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:C,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!==S.indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r,n=!1){const o=t?"g":"gi";let i;if(r)try{i=new RegExp(e,o)}catch(e){}return i||(i=T(e,o)),n&&i&&(i=new RegExp(`\\b${i.source}\\b`,o)),i},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>O(e,S),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,a;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),a=!Number.isNaN(Number(o)),i&&!a)return-1;if(a&&!i)return 1;if(i&&a){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},countUnmatchedLeftParentheses:e=>{let t=0;for(const r of e)"("===r?t++:")"===r&&t>0&&t--;return t},createPlainTextSearchRegex:T,toLowerCaseString:function(e){return e.toLowerCase()},toKebabCase:M,toKebabCaseKeys:function(e){const t={};for(const[r,n]of Object.entries(e))t[M(r)]=n;return t},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r},concatBase64:function(e,t){if(0===e.length||!e.endsWith("="))return e+t;const r=e.substring(0,e.length-4),n=e.substring(e.length-4);return r+window.btoa(window.atob(n)+window.atob(t))}});var z=Object.freeze({__proto__:null,secondsToMilliSeconds:function(e){return 1e3*e},milliSecondsToSeconds:function(e){return e/1e3},microSecondsToMilliSeconds:function(e){return e/1e3}});class L extends Uint32Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){return this}asArrayOrFail(){throw new Error("Not an array")}}class j{#e;#t;length;constructor(e,t){this.#e=[],this.length=e;let r=1;for(;;){r*=2,this.#t=Math.ceil(e/r);try{if(void 0!==t&&this.#t>t)throw new RangeError;for(let e=0;e<r;++e)this.#e[e]=new Uint32Array(this.#t);return}catch(e){if(this.#t<1e6)throw e}}}getValue(e){if(e>=0&&e<this.length){const t=this.#t;return this.#e[Math.floor(e/t)][e%t]}return this.#e[0][-1]}setValue(e,t){if(e>=0&&e<this.length){const r=this.#t;this.#e[Math.floor(e/r)][e%r]=t}}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){throw new Error("Not an array")}}class F extends Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){return this}}class $ extends Uint8Array{constructor(e){super(Math.ceil(e/8))}getBit(e){return 0!==(this[e>>3]&1<<(7&e))}setBit(e){this[e>>3]|=1<<(7&e)}clearBit(e){this[e>>3]&=~(1<<(7&e))}previous(e){for(;e!==e>>3<<3;)if(--e,this.getBit(e))return e;let t;for(t=(e>>3)-1;t>=0&&0===this[t];--t);if(t<0)return-1;for(e=7+(t<<3);e>=t<<3;--e)if(this.getBit(e))return e;throw new Error("Unreachable")}}var B=Object.freeze({__proto__:null,createExpandableBigUint32Array:function(){return new F},createFixedBigUint32Array:function(e,t){try{if(void 0!==t&&e>t)throw new RangeError;return new L(e)}catch{return new j(e,t)}},createBitVector:function(e){return new $(e)}});function k(e,t){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}${t?`\n${t}`:""}`)}function V(e,t){throw new Error(t)}function D(e){return e}var I=Object.freeze({__proto__:null,assertNotNullOrUndefined:k,assertNever:V,assertUnhandled:D});var W=Object.freeze({__proto__:null,LocalizedEmptyString:""});class K extends Error{message;constructor(e){super(e),this.message=e}}var P=Object.freeze({__proto__:null,UserVisibleError:K,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof K}});export{i as ArrayUtilities,a as Brand,u as DOMUtilities,s as DateUtilities,l as DevToolsPath,f as KeyboardUtilities,p as MapUtilities,b as MimeType,_ as NumberUtilities,E as PromiseUtilities,R as StringUtilities,z as Timing,I as TypeScriptUtilities,B as TypedArrayUtilities,W as UIString,P as UserVisibleError,V as assertNever,k as assertNotNullOrUndefined,D as assertUnhandled}; | |||
| function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,a,s){if(i<=o)return;const l=function(t,r,n,o,i){const a=t[i];e(t,o,i);let s=n;for(let i=n;i<o;++i)r(t[i],a)<0&&(e(t,s,i),++s);return e(t,o,s),s}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);a<l&&t(r,n,o,l-1,a,s),l<s&&t(r,n,l+1,i,a,s)}function r(e,t,r,n){const o=[];let i=0,a=0;for(;i<e.length&&a<t.length;){const s=r(e[i],t[a]);!n&&s||o.push(s<=0?e[i]:t[a]),s<=0&&i++,s>=0&&a++}if(n){for(;i<e.length;)o.push(e[i++]);for(;a<t.length;)o.push(t[a++])}return o}function n(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>0?i=n+1:a=n}return a}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,a=0,s=!1,l=!1,u=0;do{u=o+(i-o)/2,a=n?Math.ceil(u):Math.floor(u),s=t(e[a]),l=s===n,l?o=Math.min(i,a+(o===a?1:0)):i=Math.max(o,a+(i===a?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),lowerBound:n,mergeOrdered:(e,t,n)=>r(e,t,n,!0),nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,a){return 0===n&&o===e.length-1&&0===i&&a>=o?e.sort(r):t(e,r,n,o,i,a),e},upperBound:function(e,t,r,n,o){let i=n||0,a=void 0!==o?o:e.length;for(;i<a;){const n=i+a>>1;r(t,e[n])>=0?i=n+1:a=n}return a}}),a=Object.freeze({__proto__:null}),s=Object.freeze({__proto__:null});var l=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var u=Object.freeze({__proto__:null,EmptyEncodedPathString:"",EmptyRawPathString:"",EmptyUrlString:"",urlString:(e,...t)=>String.raw({raw:e},...t)});var c=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,a,s=0,l=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,s=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,s=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,s=0)}if(o&&"forward"!==o&&"both"!==o)a=e,l=t;else{let o=e;for(;o;){if(o===n){a||(a=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){a=o,l=n;break}}if(a)break;o=o.traverseNextNode(n)}a||(a=n,l=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,s),u.setEnd(a,l),u}});const f=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var h=Object.freeze({__proto__:null,ARROW_KEYS:f,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key},isEscKey:function(e){return"Escape"===e.key},keyIsArrowKey:function(e){return f.has(e)}});class p{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}keys(){return this.map.keys()}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var g=Object.freeze({__proto__:null,Multimap:p,getWithDefault:function(e,t,r){let n=e.get(t);return null==n&&(n=r(t),e.set(t,n)),n},inverse:function(e){const t=new p;for(const[r,n]of e.entries())t.set(n,r);return t}});const d=new Set(["application/ecmascript","application/javascript","application/json","application/json+protobuf","application/mpegurl","application/vnd.apple.mpegurl","application/vnd.dart","application/xml","application/x-aspx","application/x-javascript","application/x-jsp","application/x-httpd-php","application/x-mpegurl","audio/mpegurl","audio/x-mpegurl"]);function m(e,t,r=0){for(let n=r;n<e.length;n++)if(t.includes(e[n]))return n;return-1}function b(e,t,r=0){for(let n=r;n<e.length;n++)if(!t.includes(e[n]))return n;return-1}var w=Object.freeze({__proto__:null,isTextType:function(e){return e.startsWith("text/")||e.startsWith("multipart/")||e.includes("+json")||e.endsWith("+xml")||d.has(e)},parseContentType:function(e){if("*/*"===e)return{mimeType:null,charset:null};const{mimeType:t,params:r}=function(e){e=e.trim();let t=m(e," \t;(");t<0&&(t=e.length);const r=e.indexOf("/");if(r<0||r>t)return{mimeType:null,params:new Map};const n=e.substring(0,t).toLowerCase(),o=new Map;let i=e.indexOf(";",t);for(;i>=0&&i<e.length;){if(++i,i=b(e," \t",i),i<0)continue;const t=i;if(i=m(e,";=",i),i<0||";"===e[i])continue;const r=e.substring(t,i).toLowerCase();++i,i=b(e," \t",i);let n="";if(!(i<0||";"===e[i])){if('"'!==e[i]){const t=i;i=e.indexOf(";",i);const r=i>=0?i:e.length;n=e.substring(t,r).trimEnd()}else{for(++i;i<e.length&&'"'!==e[i];)"\\"===e[i]&&i+1<e.length&&++i,n+=e[i],++i;i=e.indexOf(";",i)}o.has(r)||o.set(r,n)}}return{mimeType:n,params:o}}(e);return{mimeType:t,charset:r.get("charset")?.toLowerCase().trim()??null}}});const _=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},x=new Map([["8∶5","16∶10"]]);var E=Object.freeze({__proto__:null,aspectRatio:(e,t)=>{const r=_(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return x.get(n)||n},clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},floor:(e,t=0)=>{if(t>0&&t<1)return t=1/t,Math.floor(e/t)*t;const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:_,mod:(e,t)=>(e%t+t)%t,toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});const O=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},N=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),y=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),A=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},S=/^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/,v="^[]{}()\\.^$*+?|-,",C=function(){return v},T=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!==C().indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};const U=/[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\b|_)|[A-Za-z][0-9]+[a-z]?|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g,z=function(e){return e.match?.(U)?.map((e=>e.toLowerCase())).join("-").replaceAll("-.-",".")||e};var L=Object.freeze({__proto__:null,DOUBLE_QUOTE:'"',SINGLE_QUOTE:"'",base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),compare:(e,t)=>e>t?1:e<t?-1:0,concatBase64:function(e,t){if(0===e.length||!e.endsWith("="))return e+t;const r=e.substring(0,e.length-4),n=e.substring(e.length-4);return r+window.btoa(window.atob(n)+window.atob(t))},countUnmatchedLeftParentheses:e=>{let t=0;for(const r of e)"("===r?t++:")"===r&&t>0&&t--;return t},countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},createPlainTextSearchRegex:T,createSearchRegex:function(e,t,r,n=!1){const o=t?"g":"gi";let i;if(r)try{i=new RegExp(e,o)}catch{}return i||(i=T(e,o)),n&&i&&(i=new RegExp(`\\b${i.source}\\b`,o)),i},escapeCharacters:O,escapeForRegExp:e=>O(e,v),filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!==v.indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},findIndexesOfSubString:A,findLineEndingIndexes:e=>{const t=A(e,"\n");return t.push(e.length),t},findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(y.has(r))return y.get(r);return"\\x"+N(r.charCodeAt(0),2)}if(n){return"\\u"+N(n.charCodeAt(0),4)}return t?y.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},isExtendedKebabCase:e=>S.test(e),isWhitespace:e=>/^\s*$/.test(e),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,a;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),a=!Number.isNaN(Number(o)),i&&!a)return-1;if(a&&!i)return 1;if(i&&a){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},regexSpecialCharacters:C,removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},reverse:e=>e.split("").reverse().join(""),sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let a=Number(t[r++]);return isNaN(a)&&(a=0),"d"===i?String(Math.floor(a)).padStart(Number(o),"0"):void 0!==o?a.toFixed(Number(o)):String(a)}))},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let a=0;for(let e=0;e<n;e++)o=e%3,a|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),t(63&a)),a=0);return 0===o?i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(a>>>18&63),t(a>>>12&63),t(a>>>6&63),61)),i},toKebabCase:z,toKebabCaseKeys:function(e){const t={};for(const[r,n]of Object.entries(e))t[z(r)]=n;return t},toLowerCaseString:function(e){return e.toLowerCase()},toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r}});var M=Object.freeze({__proto__:null,microSecondsToMilliSeconds:function(e){return e/1e3},milliSecondsToSeconds:function(e){return e/1e3}});class R extends Uint32Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){return this}asArrayOrFail(){throw new Error("Not an array")}}class j{#e;#t;length;constructor(e,t){this.#e=[],this.length=e;let r=1;for(;;){r*=2,this.#t=Math.ceil(e/r);try{if(void 0!==t&&this.#t>t)throw new RangeError;for(let e=0;e<r;++e)this.#e[e]=new Uint32Array(this.#t);return}catch(e){if(this.#t<1e6)throw e}}}getValue(e){if(e>=0&&e<this.length){const t=this.#t;return this.#e[Math.floor(e/t)][e%t]}return this.#e[0][-1]}setValue(e,t){if(e>=0&&e<this.length){const r=this.#t;this.#e[Math.floor(e/r)][e%r]=t}}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){throw new Error("Not an array")}}class F extends Array{getValue(e){return this[e]}setValue(e,t){this[e]=t}asUint32ArrayOrFail(){throw new Error("Not a Uint32Array")}asArrayOrFail(){return this}}class $ extends Uint8Array{constructor(e){super("number"==typeof e?Math.ceil(e/8):e)}getBit(e){return 0!==(this[e>>3]&1<<(7&e))}setBit(e){this[e>>3]|=1<<(7&e)}clearBit(e){this[e>>3]&=~(1<<(7&e))}previous(e){for(;e!==e>>3<<3;)if(--e,this.getBit(e))return e;let t=(e>>3)-1;for(;t>=0&&0===this[t];)--t;if(t<0)return-1;for(e=7+(t<<3);e>=t<<3;--e)if(this.getBit(e))return e;throw new Error("Unreachable")}}var B=Object.freeze({__proto__:null,createBitVector:function(e){return new $(e)},createExpandableBigUint32Array:function(){return new F},createFixedBigUint32Array:function(e,t){try{if(void 0!==t&&e>t)throw new RangeError;return new R(e)}catch{return new j(e,t)}}});function V(e,t){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}${t?`\n${t}`:""}`)}function k(e,t){throw new Error(t)}function D(e){return e}var I=Object.freeze({__proto__:null,assertNever:k,assertNotNullOrUndefined:V,assertUnhandled:D});var W=Object.freeze({__proto__:null,LocalizedEmptyString:""});class K extends Error{message;constructor(e){super(e),this.message=e}}var P=Object.freeze({__proto__:null,UserVisibleError:K,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof K}});export{i as ArrayUtilities,a as Brand,s as Constructor,c as DOMUtilities,l as DateUtilities,u as DevToolsPath,h as KeyboardUtilities,g as MapUtilities,w as MimeType,E as NumberUtilities,L as StringUtilities,M as Timing,I as TypeScriptUtilities,B as TypedArrayUtilities,W as UIString,P as UserVisibleError,k as assertNever,V as assertNotNullOrUndefined,D as assertUnhandled}; | |||
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High library
<!--
| @@ -1 +1 @@ | |||
| var e,t,n;!function(e){e.CSS="css",e.ARIA="aria",e.Text="text",e.XPath="xpath",e.Pierce="pierce"}(e||(e={})),function(e){e.Change="change",e.Click="click",e.Close="close",e.CustomStep="customStep",e.DoubleClick="doubleClick",e.EmulateNetworkConditions="emulateNetworkConditions",e.Hover="hover",e.KeyDown="keyDown",e.KeyUp="keyUp",e.Navigate="navigate",e.Scroll="scroll",e.SetViewport="setViewport",e.WaitForElement="waitForElement",e.WaitForExpression="waitForExpression"}(t||(t={})),function(e){e.Navigation="navigation"}(n||(n={}));var r=Object.freeze({__proto__:null,get AssertedEventType(){return n},get SelectorType(){return e},get StepType(){return t}});function i(e){throw new Error(`Unknown step type: ${e.type}`)}const a=new Set(["textarea","text","url","tel","search","password","number","email"]),o=new Set(["mouse","pen","touch"]),s=new Map([["primary","left"],["auxiliary","middle"],["secondary","right"],["back","back"],["forward","forward"]]);function p(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return!1;return void 0!==e[t]}function l(e){return"object"==typeof e&&null!==e}function c(e){return"string"==typeof e}function u(e){return"number"==typeof e}function f(e){return Array.isArray(e)}function d(e){if(p(e,"target")&&c(e.target))return e.target}function w(e){if(p(e,"frame")){if(f(t=e.frame)&&t.every((e=>Number.isInteger(e))))return e.frame;throw new Error("Step `frame` is not an integer array")}var t}function h(e,t){if(p(e,t)){const n=e[t];if(u(n))return n}throw new Error(`Step.${t} is not a number`)}function m(e,t){if(p(e,t)){const n=e[t];if("boolean"==typeof n)return n}throw new Error(`Step.${t} is not a boolean`)}function g(e,t){if(p(e,t))return h(e,t)}function y(e,t){if(p(e,t))return S(e,t)}function b(e,t){if(p(e,t))return m(e,t)}function S(e,t){if(p(e,t)){const n=e[t];if(c(n))return n}throw new Error(`Step.${t} is not a string`)}function E(e){if(!p(e,"selectors"))throw new Error("Step does not have required selectors");if(!f(e.selectors))throw new Error("Step selectors are not an array");if(0===e.selectors.length)throw new Error("Step does not have required selectors");return e.selectors.map((e=>{if(!c(e)&&!f(e))throw new Error("Selector is not an array or string");return f(e)?e.map((e=>{if(!c(e))throw new Error("Selector element is not a string");return e})):e}))}function v(e){if(p(e,"selectors"))return E(e)}function L(e){if(!l(e))throw new Error("Asserted event is not an object");if(!p(e,"type"))throw new Error("Asserted event is missing type");if(e.type===n.Navigation)return{type:n.Navigation,url:y(e,"url"),title:y(e,"title")};throw new Error("Unknown assertedEvent type")}function k(e){if(f(e))return e.map(L)}function F(e,t){if(p(t,"timeout")&&u(t.timeout)&&!j(t.timeout))throw new Error(R);return{type:e,assertedEvents:p(t,"assertedEvents")?k(t.assertedEvents):void 0,timeout:p(t,"timeout")&&u(t.timeout)?t.timeout:void 0}}function A(e,t){return{...F(e,t),target:d(t)}}function x(e,t){return{...A(e,t),frame:w(t)}}function C(e,t){return{...x(e,t),selectors:E(t)}}function T(e){const t={offsetX:h(e,"offsetX"),offsetY:h(e,"offsetY"),duration:g(e,"duration")},n=y(e,"deviceType");if(n){if("string"!=typeof(r=n)||!o.has(r))throw new Error(`'deviceType' for click steps must be one of the following: ${[...o].join(", ")}`);t.deviceType=n}var r;const i=y(e,"button");if(i){if(!function(e){return"string"==typeof e&&s.has(e)}(i))throw new Error(`'button' for click steps must be one of the following: ${[...s.keys()].join(", ")}`);t.button=i}return t}function $(e,n){if(!l(e))throw new Error(n?`Step ${n} is not an object`:"Step is not an object");if(!p(e,"type"))throw new Error(n?`Step ${n} does not have a type`:"Step does not have a type");if(!c(e.type))throw new Error(n?`Type of the step ${n} is not a string`:"Type of the step is not a string");switch(e.type){case t.Click:return function(e){return{...C(t.Click,e),...T(e),type:t.Click}}(e);case t.DoubleClick:return function(e){return{...C(t.DoubleClick,e),...T(e),type:t.DoubleClick}}(e);case t.Hover:return function(e){return{...C(t.Hover,e),type:t.Hover}}(e);case t.Change:return function(e){return{...C(t.Change,e),type:t.Change,value:S(e,"value")}}(e);case t.KeyDown:return function(e){return{...A(t.KeyDown,e),type:t.KeyDown,key:S(e,"key")}}(e);case t.KeyUp:return function(e){return{...A(t.KeyUp,e),type:t.KeyUp,key:S(e,"key")}}(e);case t.EmulateNetworkConditions:return function(e){return{...A(t.EmulateNetworkConditions,e),type:t.EmulateNetworkConditions,download:h(e,"download"),upload:h(e,"upload"),latency:h(e,"latency")}}(e);case t.Close:return function(e){return{...A(t.Close,e),type:t.Close}}(e);case t.SetViewport:return function(e){return{...A(t.SetViewport,e),type:t.SetViewport,width:h(e,"width"),height:h(e,"height"),deviceScaleFactor:h(e,"deviceScaleFactor"),isMobile:m(e,"isMobile"),hasTouch:m(e,"hasTouch"),isLandscape:m(e,"isLandscape")}}(e);case t.Scroll:return function(e){return{...x(t.Scroll,e),type:t.Scroll,x:g(e,"x"),y:g(e,"y"),selectors:v(e)}}(e);case t.Navigate:return function(e){return{...A(t.Navigate,e),type:t.Navigate,target:d(e),url:S(e,"url")}}(e);case t.CustomStep:return function(e){if(!p(e,"name"))throw new Error("customStep is missing name");if(!c(e.name))throw new Error("customStep's name is not a string");return{...x(t.CustomStep,e),type:t.CustomStep,name:e.name,parameters:p(e,"parameters")?e.parameters:void 0}}(e);case t.WaitForElement:return function(e){const n=y(e,"operator");if(n&&">="!==n&&"=="!==n&&"<="!==n)throw new Error("WaitForElement step's operator is not one of '>=','==','<='");if(p(e,"attributes")&&(!l(e.attributes)||Object.values(e.attributes).some((e=>"string"!=typeof e))))throw new Error("WaitForElement step's attribute is not a dictionary of strings");if(p(e,"properties")&&!l(e.properties))throw new Error("WaitForElement step's attribute is not an object");return{...C(t.WaitForElement,e),type:t.WaitForElement,operator:n,count:g(e,"count"),visible:b(e,"visible"),attributes:p(e,"attributes")?e.attributes:void 0,properties:p(e,"properties")?e.properties:void 0}}(e);case t.WaitForExpression:return function(e){if(!p(e,"expression"))throw new Error("waitForExpression step is missing `expression`");return{...x(t.WaitForExpression,e),type:t.WaitForExpression,expression:S(e,"expression")}}(e);default:throw new Error(`Step type ${e.type} is not supported`)}}function N(e){const t=[];if(!f(e))throw new Error("Recording `steps` is not an array");for(const[n,r]of e.entries())t.push($(r,n));return t}const P=1,I=3e4,R=`Timeout is not between ${P} and ${I} milliseconds`;function j(e){return e>=P&&e<=I}function W(e){if(!l(e))throw new Error("Recording is not an object");if(!p(e,"title"))throw new Error("Recording is missing `title`");if(!c(e.title))throw new Error("Recording `title` is not a string");if(p(e,"timeout")&&!u(e.timeout))throw new Error("Recording `timeout` is not a number");if(!p(e,"steps"))throw new Error("Recording is missing `steps`");if(p(e,"timeout")&&u(e.timeout)&&!j(e.timeout))throw new Error(R);return t={title:e.title,timeout:p(e,"timeout")&&u(e.timeout)?e.timeout:void 0,selectorAttribute:p(e,"selectorAttribute")&&c(e.selectorAttribute)?e.selectorAttribute:void 0,steps:N(e.steps)},JSON.parse(JSON.stringify(t));var t}function B(t){for(const n of Object.values(e))if(t.startsWith(`${n}/`))return n;return e.CSS}function O(t){function n(e){return e.replace(/['"()]/g,"\\$&")}Array.isArray(t)||(t=[t]);return t.map((t=>{switch(B(t)){case e.ARIA:return`::-p-aria(${n(t.substring(e.ARIA.length+1))})`;case e.CSS:return t;case e.XPath:return`::-p-xpath(${n(t.substring(e.XPath.length+1))})`;case e.Pierce:return`:scope >>> ${t.substring(e.Pierce.length+1)}`;case e.Text:return`::-p-text(${n(t.substring(e.Text.length+1))})`}})).join(" >>>> ")}class D{async beforeAllSteps(e,t){}async afterAllSteps(e,t){}async beforeEachStep(e,t,n){}async stringifyStep(e,t,n){}async afterEachStep(e,t,n){}}class H extends D{async beforeAllSteps(e,t){const n={...t,steps:void 0},r=JSON.stringify(n,null,e.getIndent()).split("\n");r.pop(),r[r.length-1]+=",",r.push(e.getIndent()+'"steps": ['),e.appendLine(r.join("\n")).startBlock().startBlock()}async afterAllSteps(e){e.endBlock().endBlock().appendLine(e.getIndent()+"]").appendLine("}")}async stringifyStep(e,t,n){const r=JSON.stringify(t,null,e.getIndent());if(!n)return void e.appendLine(r);const i=n.steps.lastIndexOf(t)===n.steps.length-1?"":",";e.appendLine(r+i)}}class K{#e;#t=0;#n=[];constructor(e){this.#e=e}appendLine(e){const t=e.split("\n").map((e=>e?this.#e.repeat(this.#t)+e.trimEnd():""));return this.#n.push(...t),this}startBlock(){return this.#t++,this}endBlock(){if(this.#t--,this.#t<0)throw new Error("Extra endBlock");return this}toString(){return this.#n.join("\n")+"\n"}getIndent(){return this.#e}getSize(){return this.#n.length}}function V(e,t){const n=[];return U(e,n,1,t),n.join("")}function U(e,t=[],n=1,r=" "){switch(typeof e){case"bigint":case"symbol":case"function":case"undefined":throw new Error("Invalid JSON");case"number":case"boolean":t.push(String(e));break;case"string":t.push(X(e));break;case"object":if(null===e)t.push("null");else if(Array.isArray(e)){t.push("[\n");for(let i=0;i<e.length;i++)t.push(r.repeat(n)),U(e[i],t,n+1,r),i!==e.length-1&&t.push(","),t.push("\n");t.push(r.repeat(n-1)+"]")}else{t.push("{\n");const i=Object.keys(e);for(let a=0;a<i.length;a++){const o=i[a],s=e[o];void 0!==s&&(t.push(r.repeat(n)),t.push(o),t.push(": "),U(s,t,n+1,r),a!==i.length-1&&t.push(","),t.push("\n"))}t.push(r.repeat(n-1)+"}")}break;default:throw new Error("Unknown object type")}return t}const q=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),M=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),X=e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=(e,t,n,r)=>{if(n){if(M.has(n))return M.get(n);return"\\x"+q(n.charCodeAt(0),2)}if(r){return"\\u"+q(r.charCodeAt(0),4)}return t?M.get(t)||"":e};let i="",a="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(a="'",i=e.replace(n,r)):(a="`",i=e.replace(t,r)):(a='"',i=e.replace(t,r)):(a="'",i=e.replace(t,r)),`${a}${i}${a}`};class J extends D{#r=!1;async beforeAllSteps(e,t){e.appendLine("const puppeteer = require('puppeteer'); // v22.0.0 or later"),e.appendLine(""),e.appendLine("(async () => {").startBlock(),e.appendLine("const browser = await puppeteer.launch();"),e.appendLine("const page = await browser.newPage();"),e.appendLine(`const timeout = ${t.timeout||Y};`),e.appendLine("page.setDefaultTimeout(timeout);"),e.appendLine(""),this.#r=!1}async afterAllSteps(e,t){if(e.appendLine(""),e.appendLine("await browser.close();"),e.appendLine(""),this.#r)for(const t of _.split("\n"))e.appendLine(t);e.endBlock().appendLine("})().catch(err => {").startBlock(),e.appendLine("console.error(err);"),e.appendLine("process.exit(1);"),e.endBlock().appendLine("});")}async stringifyStep(e,t,r){if(e.appendLine("{").startBlock(),void 0!==t.timeout&&e.appendLine(`const timeout = ${t.timeout};`),this.#i(e,t),t.assertedEvents){e.appendLine("const promises = [];"),e.appendLine("const startWaitingForEvents = () => {").startBlock();for(const r of t.assertedEvents){if(r.type!==n.Navigation)throw new Error(`Event type ${r.type} is not supported`);e.appendLine(`promises.push(${"frame"in t&&t.frame?"frame":"targetPage"}.waitForNavigation());`)}e.endBlock().appendLine("}")}this.#a(e,t),t.assertedEvents&&e.appendLine("await Promise.all(promises);"),e.endBlock().appendLine("}")}#o(e,t){"main"===t?e.appendLine("const targetPage = page;"):(e.appendLine(`const target = await browser.waitForTarget(t => t.url() === ${V(t,e.getIndent())}, { timeout });`),e.appendLine("const targetPage = await target.page();"),e.appendLine("targetPage.setDefaultTimeout(timeout);"))}#s(e,t){e.appendLine("let frame = targetPage.mainFrame();");for(const n of t)e.appendLine(`frame = frame.childFrames()[${n}];`)}#i(e,t){this.#o(e,t.target||"main"),t.frame&&this.#s(e,t.frame)}#p(e,t,n){e.appendLine("await puppeteer.Locator.race([").startBlock(),e.appendLine(t.selectors.map((n=>`${t.frame?"frame":"targetPage"}.locator(${V(O(n),e.getIndent())})`)).join(",\n")),e.endBlock().appendLine("])"),e.startBlock().appendLine(".setTimeout(timeout)"),t.assertedEvents?.length&&e.appendLine(".on('action', () => startWaitingForEvents())"),n(),e.endBlock()}#l(e,t){this.#p(e,t,(()=>{e.appendLine(".click({"),t.duration&&e.appendLine(` delay: ${t.duration},`),t.button&&e.appendLine(` button: '${s.get(t.button)}',`),e.appendLine(" offset: {"),e.appendLine(` x: ${t.offsetX},`),e.appendLine(` y: ${t.offsetY},`),e.appendLine(" },"),e.appendLine("});")}))}#c(e,t){this.#p(e,t,(()=>{e.appendLine(".click({"),e.appendLine(" count: 2,"),t.duration&&e.appendLine(` delay: ${t.duration},`),t.button&&e.appendLine(` button: '${s.get(t.button)}',`),e.appendLine(" offset: {"),e.appendLine(` x: ${t.offsetX},`),e.appendLine(` y: ${t.offsetY},`),e.appendLine(" },"),e.appendLine("});")}))}#u(e,t){this.#p(e,t,(()=>{e.appendLine(".hover();")}))}#f(e,t){this.#p(e,t,(()=>{e.appendLine(`.fill(${V(t.value,e.getIndent())});`)}))}#d(e,t){e.appendLine("await targetPage.emulateNetworkConditions({"),e.appendLine(` offline: ${!t.download&&!t.upload},`),e.appendLine(` downloadThroughput: ${t.download},`),e.appendLine(` uploadThroughput: ${t.upload},`),e.appendLine(` latency: ${t.latency},`),e.appendLine("});")}#w(e,t){e.appendLine(`await targetPage.keyboard.down(${V(t.key,e.getIndent())});`)}#h(e,t){e.appendLine(`await targetPage.keyboard.up(${V(t.key,e.getIndent())});`)}#m(e,t){e.appendLine("await targetPage.close()")}#g(e,t){e.appendLine(`await targetPage.setViewport(${V({width:t.width,height:t.height},e.getIndent())})`)}#y(e,t){"selectors"in t?this.#p(e,t,(()=>{e.appendLine(`.scroll({ scrollTop: ${t.y}, scrollLeft: ${t.x}});`)})):e.appendLine(`await targetPage.evaluate((x, y) => { window.scroll(x, y); }, ${t.x}, ${t.y})`)}#a(e,n){switch(n.type){case t.Click:return this.#l(e,n);case t.DoubleClick:return this.#c(e,n);case t.Hover:return this.#u(e,n);case t.Change:return this.#f(e,n);case t.EmulateNetworkConditions:return this.#d(e,n);case t.KeyDown:return this.#w(e,n);case t.KeyUp:return this.#h(e,n);case t.Close:return this.#m(e,n);case t.SetViewport:return this.#g(e,n);case t.Scroll:return this.#y(e,n);case t.Navigate:return this.#b(e,n);case t.WaitForElement:return this.#S(e,n);case t.WaitForExpression:return this.#E(e,n);case t.CustomStep:return;default:return i(n)}}#b(e,t){t.assertedEvents?.length&&e.appendLine("startWaitingForEvents();"),e.appendLine(`await targetPage.goto(${V(t.url,e.getIndent())});`)}#E(e,t){e.appendLine(`await ${t.frame?"frame":"targetPage"}.waitForFunction(${V(t.expression,e.getIndent())}, { timeout });`)}#S(e,t){this.#r=!0,e.appendLine(`await waitForElement(${V(t,e.getIndent())}, ${t.frame?"frame":"targetPage"}, timeout);`)}}const Y=5e3,_="async function waitForElement(step, frame, timeout) {\n const {\n count = 1,\n operator = '>=',\n visible = true,\n properties,\n attributes,\n } = step;\n const compFn = {\n '==': (a, b) => a === b,\n '>=': (a, b) => a >= b,\n '<=': (a, b) => a <= b,\n }[operator];\n await waitForFunction(async () => {\n const elements = await querySelectorsAll(step.selectors, frame);\n let result = compFn(elements.length, count);\n const elementsHandle = await frame.evaluateHandle((...elements) => {\n return elements;\n }, ...elements);\n await Promise.all(elements.map((element) => element.dispose()));\n if (result && (properties || attributes)) {\n result = await elementsHandle.evaluate(\n (elements, properties, attributes) => {\n for (const element of elements) {\n if (attributes) {\n for (const [name, value] of Object.entries(attributes)) {\n if (element.getAttribute(name) !== value) {\n return false;\n }\n }\n }\n if (properties) {\n if (!isDeepMatch(properties, element)) {\n return false;\n }\n }\n }\n return true;\n\n function isDeepMatch(a, b) {\n if (a === b) {\n return true;\n }\n if ((a && !b) || (!a && b)) {\n return false;\n }\n if (!(a instanceof Object) || !(b instanceof Object)) {\n return false;\n }\n for (const [key, value] of Object.entries(a)) {\n if (!isDeepMatch(value, b[key])) {\n return false;\n }\n }\n return true;\n }\n },\n properties,\n attributes\n );\n }\n await elementsHandle.dispose();\n return result === visible;\n }, timeout);\n}\n\nasync function querySelectorsAll(selectors, frame) {\n for (const selector of selectors) {\n const result = await querySelectorAll(selector, frame);\n if (result.length) {\n return result;\n }\n }\n return [];\n}\n\nasync function querySelectorAll(selector, frame) {\n if (!Array.isArray(selector)) {\n selector = [selector];\n }\n if (!selector.length) {\n throw new Error('Empty selector provided to querySelectorAll');\n }\n let elements = [];\n for (let i = 0; i < selector.length; i++) {\n const part = selector[i];\n if (i === 0) {\n elements = await frame.$$(part);\n } else {\n const tmpElements = elements;\n elements = [];\n for (const el of tmpElements) {\n elements.push(...(await el.$$(part)));\n }\n }\n if (elements.length === 0) {\n return [];\n }\n if (i < selector.length - 1) {\n const tmpElements = [];\n for (const el of elements) {\n const newEl = (await el.evaluateHandle(el => el.shadowRoot ? el.shadowRoot : el)).asElement();\n if (newEl) {\n tmpElements.push(newEl);\n }\n }\n elements = tmpElements;\n }\n }\n return elements;\n}\n\nasync function waitForFunction(fn, timeout) {\n let isActive = true;\n const timeoutId = setTimeout(() => {\n isActive = false;\n }, timeout);\n while (isActive) {\n const result = await fn();\n if (result) {\n clearTimeout(timeoutId);\n return;\n }\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n throw new Error('Timed out');\n}",z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",G=z.split("").reduce(((e,t,n)=>(e.set(t,n),e)),new Map),Q=31,Z=32,ee=2147483647;function te(e){if(e<0)throw new Error("Only postive integers and zero are supported");if(e>ee)throw new Error("Only integers between 0 and "+ee+" are supported");const t=[];do{let n=e&Q;(e>>>=5)>0&&(n|=Z),t.push(z[n])}while(0!==e);return t.join("")}function ne(e){const t=[],n=e.split("");let r=0,i=0;for(const e of n){const n=G.get(e);r|=(n&Q)<<i,i+=5;n&Z||(t.push(r),r=0,i=0)}return t}const re="//# recorderSourceMap=";async function ie(e,t){t||(t={});const n=t.extension??new J,r=t.writer??new K(t.indentation??" ");await(n.beforeAllSteps?.(r,e));const i=[1];for(const t of e.steps){const a=r.getSize();await(n.beforeEachStep?.(r,t,e)),await n.stringifyStep(r,t,e),await(n.afterEachStep?.(r,t,e));const o=r.getSize();i.push(a,o-a)}return await(n.afterAllSteps?.(r,e)),r.appendLine(re+function(e){const t=[];for(const n of e)t.push(te(n));return t.join("")}(i)),r.toString()}async function ae(e,t){t||(t={});let n=t.extension;n||(n=new J),t.indentation||(t.indentation=" ");const r=t.writer??new K(t.indentation??" ");return await(n.beforeEachStep?.(r,e)),await n.stringifyStep(r,e),await(n.afterEachStep?.(r,e)),r.toString()}function oe(e){return e.trim().startsWith(re)}function se(e){const t=e.split("\n");for(let e=t.length-1;e>=0;e--){const n=t[e];if(oe(n))return ne(n.trim().substring(re.length))}}function pe(e){return e.split("\n").filter((e=>!oe(e))).join("\n")}class le{async beforeAllSteps(e){}async afterAllSteps(e){}async beforeEachStep(e,t){}async runStep(e,t){}async afterEachStep(e,t){}}const ce={"==":(e,t)=>e===t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t};function ue(e){return new Promise((t=>{setTimeout(t,e)}))}class fe extends le{browser;page;timeout;constructor(e,t,n){super(),this.browser=e,this.page=t,this.timeout=n?.timeout||5e3}async#v(e){try{await e._client().send("Emulation.setAutomationOverride",{enabled:!0})}catch{}}#L(e,t){return e.timeout||t?.timeout||this.timeout}async runStep(e,t){const n=this.#L(e,t),r=this.page,i=this.browser,a=await async function(e,t,n,r){if(!n.target||"main"===n.target)return t;const i=await e.waitForTarget((e=>e.url()===n.target),{timeout:r}),a=await i.page();if(!a)return null;return a.setDefaultTimeout(r),a}(i,r,e,n);let o=null;if(!a&&e.target){const t=r.frames();for(const n of t)if(n.isOOPFrame()&&n.url()===e.target){o=n;break}o||(o=await r.waitForFrame(e.target,{timeout:n}))}const s=o||a;if(!s)throw new Error("Target is not found for step: "+JSON.stringify(e));await this.#v(s);const p=await async function(e,t){let n="mainFrame"in e?e.mainFrame():e;if("frame"in t&&t.frame)for(const e of t.frame)n=n.childFrames()[e];return n}(s,e);await this.runStepInFrame(e,r,s,p,n)}async runStepInFrame(e,r,a,o,p){let l=null;const c=()=>{l=async function(e,t,r){const i=[];if(t.assertedEvents)for(const a of t.assertedEvents){if(a.type!==n.Navigation)throw new Error(`Event type ${a.type} is not supported`);i.push(e.waitForNavigation({timeout:r}))}await Promise.all(i)}(o,e,p)},u=this.page.locatorRace;switch(e.type){case t.DoubleClick:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).click({count:2,button:e.button&&s.get(e.button),delay:e.duration,offset:{x:e.offsetX,y:e.offsetY}});break;case t.Click:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).click({delay:e.duration,button:e.button&&s.get(e.button),offset:{x:e.offsetX,y:e.offsetY}});break;case t.Hover:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).hover();break;case t.EmulateNetworkConditions:c(),await r.emulateNetworkConditions(e);break;case t.KeyDown:c(),await r.keyboard.down(e.key),await ue(100);break;case t.KeyUp:c(),await r.keyboard.up(e.key),await ue(100);break;case t.Close:"close"in a&&(c(),await a.close());break;case t.Change:await u(e.selectors.map((e=>o.locator(O(e))))).on("action",(()=>c())).setTimeout(p).fill(e.value);break;case t.SetViewport:"setViewport"in a&&(c(),await a.setViewport(e));break;case t.Scroll:"selectors"in e?await u(e.selectors.map((e=>o.locator(O(e))))).on("action",(()=>c())).setTimeout(p).scroll({scrollLeft:e.x||0,scrollTop:e.y||0}):(c(),await o.evaluate(((e,t)=>{window.scroll(e,t)}),e.x||0,e.y||0));break;case t.Navigate:c(),await o.goto(e.url);break;case t.WaitForElement:try{c(),await async function(e,t,n){const{count:r=1,operator:i=">=",visible:a=!0,properties:o,attributes:s}=e,p=ce[i];await async function(e,t){let n=!0;const r=setTimeout((()=>{n=!1}),t);for(;n;){if(await e())return void clearTimeout(r);await new Promise((e=>setTimeout(e,100)))}throw new Error("Timed out")}((async()=>{const n=await async function(e,t){for(const n of e){const e=await we(n,t);if(e.length)return e}return[]}(e.selectors,t);let i=p(n.length,r);const l=await t.evaluateHandle(((...e)=>e),...n);return await Promise.all(n.map((e=>e.dispose()))),i&&(o||s)&&(i=await l.evaluate(((e,t,n)=>{if(n)for(const t of e)for(const[e,r]of Object.entries(n))if(t.getAttribute(e)!==r)return!1;if(t)for(const n of e)if(!r(t,n))return!1;return!0;function r(e,t){if(e===t)return!0;if(e&&!t||!e&&t)return!1;if(!(e instanceof Object&&t instanceof Object))return!1;for(const[n,i]of Object.entries(e))if(!r(i,t[n]))return!1;return!0}}),o,s)),await l.dispose(),i===a}),n)}(e,o,p)}catch(e){throw"Timed out"===e.message?new Error("waitForElement timed out. The element(s) could not be found."):e}break;case t.WaitForExpression:c(),await o.waitForFunction(e.expression,{timeout:p});break;case t.CustomStep:break;default:i(e)}await l}}class de extends fe{async afterAllSteps(){await this.browser.close()}}async function we(e,t){if(Array.isArray(e)||(e=[e]),!e.length)throw new Error("Empty selector provided to querySelectorAll");let n=await t.$$(e[0]);if(!n.length)return[];for(const t of e.slice(1,e.length))if(n=(await Promise.all(n.map((async e=>{const n=await e.evaluateHandle((e=>e.shadowRoot?e.shadowRoot:e)),r=await n.$$(t);return n.dispose(),e.dispose(),r})))).flat(),!n.length)return[];return n}async function he(e,t,n){await(e.beforeEachStep?.(t,n)),await e.runStep(t,n),await(e.afterEachStep?.(t,n))}class me{#k;#F;#A=!1;constructor(e){this.#F=e}abort(){this.#A=!0}set flow(e){this.#k=e}async runBeforeAllSteps(e){await(this.#F.beforeAllSteps?.(e))}async runAfterAllSteps(e){await(this.#F.afterAllSteps?.(e))}async runStep(e){await he(this.#F,e)}async run(){if(!this.#k)throw new Error("Set the flow on the runner instance before calling `run`.");const e=this.#k;if(this.#A=!1,await(this.#F.beforeAllSteps?.(e)),this.#A)return!1;for(const t of e.steps){if(this.#A)return await(this.#F.afterAllSteps?.(e)),!1;await he(this.#F,t,e)}return await(this.#F.afterAllSteps?.(e)),!0}}async function ge(e,t){const n=e instanceof le?void 0:e,r=new me((e instanceof le?e:t)??await async function(){const{default:e}=await import("puppeteer"),t=await e.launch(),n=await t.newPage();return new de(t,n)}());return n&&(r.flow=n),r}class ye extends D{async beforeAllSteps(e){e.appendLine("import url from 'url';"),e.appendLine("import { createRunner } from '@puppeteer/replay';"),e.appendLine(""),e.appendLine("export async function run(extension) {").startBlock(),e.appendLine("const runner = await createRunner(extension);"),e.appendLine(""),e.appendLine("await runner.runBeforeAllSteps();"),e.appendLine("")}async afterAllSteps(e){e.appendLine(""),e.appendLine("await runner.runAfterAllSteps();").endBlock().appendLine("}"),e.appendLine(""),e.appendLine("if (process && import.meta.url === url.pathToFileURL(process.argv[1]).href) {").startBlock().appendLine("run()").endBlock().appendLine("}")}async stringifyStep(e,t){e.appendLine(`await runner.runStep(${V(t,e.getIndent())});`)}}function be(e){return Boolean(e.type===t.Navigate||e.assertedEvents?.some((e=>e.type===n.Navigation)))}function Se(e){for(const n of e.steps)if(n.type===t.SetViewport)return n.isMobile;return!1}class Ee extends J{#x=!1;async beforeAllSteps(e,t){e.appendLine("const fs = require('fs');"),await super.beforeAllSteps(e,t),e.appendLine("const lhApi = await import('lighthouse'); // v10.0.0 or later");e.appendLine(`const flags = ${V({screenEmulation:{disabled:!0}},e.getIndent())}`),Se(t)?e.appendLine("const config = undefined;"):e.appendLine("const config = lhApi.desktopConfig;"),e.appendLine(`const lhFlow = await lhApi.startFlow(page, {name: ${V(t.title,e.getIndent())}, config, flags});`)}async stringifyStep(e,n,r){if(n.type===t.SetViewport)return void await super.stringifyStep(e,n,r);const i=be(n);i?(this.#x&&(e.appendLine("await lhFlow.endTimespan();"),this.#x=!1),e.appendLine("await lhFlow.startNavigation();")):this.#x||(e.appendLine("await lhFlow.startTimespan();"),this.#x=!0),await super.stringifyStep(e,n,r),i&&e.appendLine("await lhFlow.endNavigation();")}async afterAllSteps(e,t){this.#x&&e.appendLine("await lhFlow.endTimespan();"),e.appendLine("const lhFlowReport = await lhFlow.generateReport();"),e.appendLine("fs.writeFileSync(__dirname + '/flow.report.html', lhFlowReport)"),await super.afterAllSteps(e,t)}}class ve extends fe{#C=!1;#T=!1;#$;async createFlowResult(){if(!this.#$)throw new Error("Cannot get flow result before running the flow");return this.#$.createFlowResult()}async beforeAllSteps(e){await(super.beforeAllSteps?.(e));const{startFlow:t,desktopConfig:n}=await import("lighthouse");let r;Se(e)||(r=n),this.#$=await t(this.page,{config:r,flags:{screenEmulation:{disabled:!0}},name:e.title})}async beforeEachStep(e,n){await(super.beforeEachStep?.(e,n)),e.type!==t.SetViewport&&(be(e)?(this.#C&&(await this.#$.endTimespan(),this.#C=!1),await this.#$.startNavigation(),this.#T=!0):this.#C||(await this.#$.startTimespan(),this.#C=!0))}async afterEachStep(e,t){this.#T&&(await this.#$.endNavigation(),this.#T=!1),await(super.afterEachStep?.(e,t))}async afterAllSteps(e){this.#C&&await this.#$.endTimespan(),await(super.afterAllSteps?.(e))}}export{n as AssertedEventType,H as JSONStringifyExtension,ve as LighthouseRunnerExtension,Ee as LighthouseStringifyExtension,ye as PuppeteerReplayStringifyExtension,fe as PuppeteerRunnerExtension,de as PuppeteerRunnerOwningBrowserExtension,J as PuppeteerStringifyExtension,me as Runner,le as RunnerExtension,r as Schema,e as SelectorType,t as StepType,D as StringifyExtension,i as assertAllStepTypesAreHandled,ge as createRunner,X as formatAsJSLiteral,V as formatJSONAsJS,B as getSelectorType,I as maxTimeout,P as minTimeout,s as mouseButtonMap,W as parse,se as parseSourceMap,$ as parseStep,o as pointerDeviceTypes,O as selectorToPElementSelector,ie as stringify,ae as stringifyStep,pe as stripSourceMap,a as typeableInputTypes,j as validTimeout}; | |||
| var e,t,n;!function(e){e.CSS="css",e.ARIA="aria",e.Text="text",e.XPath="xpath",e.Pierce="pierce"}(e||(e={})),function(e){e.Change="change",e.Click="click",e.Close="close",e.CustomStep="customStep",e.DoubleClick="doubleClick",e.EmulateNetworkConditions="emulateNetworkConditions",e.Hover="hover",e.KeyDown="keyDown",e.KeyUp="keyUp",e.Navigate="navigate",e.Scroll="scroll",e.SetViewport="setViewport",e.WaitForElement="waitForElement",e.WaitForExpression="waitForExpression"}(t||(t={})),function(e){e.Navigation="navigation"}(n||(n={}));var r=Object.freeze({__proto__:null,get AssertedEventType(){return n},get SelectorType(){return e},get StepType(){return t}});function i(e){throw new Error(`Unknown step type: ${e.type}`)}const a=new Set(["textarea","text","url","tel","search","password","number","email"]),o=new Set(["mouse","pen","touch"]),s=new Map([["primary","left"],["auxiliary","middle"],["secondary","right"],["back","back"],["forward","forward"]]);function p(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return!1;return void 0!==e[t]}function l(e){return"object"==typeof e&&null!==e}function c(e){return"string"==typeof e}function u(e){return"number"==typeof e}function f(e){return Array.isArray(e)}function d(e){if(p(e,"target")&&c(e.target))return e.target}function w(e){if(p(e,"frame")){if(f(t=e.frame)&&t.every((e=>Number.isInteger(e))))return e.frame;throw new Error("Step `frame` is not an integer array")}var t}function h(e,t){if(p(e,t)){const n=e[t];if(u(n))return n}throw new Error(`Step.${t} is not a number`)}function m(e,t){if(p(e,t)){const n=e[t];if("boolean"==typeof n)return n}throw new Error(`Step.${t} is not a boolean`)}function g(e,t){if(p(e,t))return h(e,t)}function y(e,t){if(p(e,t))return S(e,t)}function b(e,t){if(p(e,t))return m(e,t)}function S(e,t){if(p(e,t)){const n=e[t];if(c(n))return n}throw new Error(`Step.${t} is not a string`)}function E(e){if(!p(e,"selectors"))throw new Error("Step does not have required selectors");if(!f(e.selectors))throw new Error("Step selectors are not an array");if(0===e.selectors.length)throw new Error("Step does not have required selectors");return e.selectors.map((e=>{if(!c(e)&&!f(e))throw new Error("Selector is not an array or string");return f(e)?e.map((e=>{if(!c(e))throw new Error("Selector element is not a string");return e})):e}))}function v(e){if(p(e,"selectors"))return E(e)}function L(e){if(!l(e))throw new Error("Asserted event is not an object");if(!p(e,"type"))throw new Error("Asserted event is missing type");if(e.type===n.Navigation)return{type:n.Navigation,url:y(e,"url"),title:y(e,"title")};throw new Error("Unknown assertedEvent type")}function k(e){if(f(e))return e.map(L)}function F(e,t){if(p(t,"timeout")&&u(t.timeout)&&!j(t.timeout))throw new Error(R);return{type:e,assertedEvents:p(t,"assertedEvents")?k(t.assertedEvents):void 0,timeout:p(t,"timeout")&&u(t.timeout)?t.timeout:void 0}}function A(e,t){return{...F(e,t),target:d(t)}}function x(e,t){return{...A(e,t),frame:w(t)}}function C(e,t){return{...x(e,t),selectors:E(t)}}function T(e){const t={offsetX:h(e,"offsetX"),offsetY:h(e,"offsetY"),duration:g(e,"duration")},n=y(e,"deviceType");if(n){if("string"!=typeof(r=n)||!o.has(r))throw new Error(`'deviceType' for click steps must be one of the following: ${[...o].join(", ")}`);t.deviceType=n}var r;const i=y(e,"button");if(i){if(!function(e){return"string"==typeof e&&s.has(e)}(i))throw new Error(`'button' for click steps must be one of the following: ${[...s.keys()].join(", ")}`);t.button=i}return t}function $(e,n){if(!l(e))throw new Error(n?`Step ${n} is not an object`:"Step is not an object");if(!p(e,"type"))throw new Error(n?`Step ${n} does not have a type`:"Step does not have a type");if(!c(e.type))throw new Error(n?`Type of the step ${n} is not a string`:"Type of the step is not a string");switch(e.type){case t.Click:return function(e){return{...C(t.Click,e),...T(e),type:t.Click}}(e);case t.DoubleClick:return function(e){return{...C(t.DoubleClick,e),...T(e),type:t.DoubleClick}}(e);case t.Hover:return function(e){return{...C(t.Hover,e),type:t.Hover}}(e);case t.Change:return function(e){return{...C(t.Change,e),type:t.Change,value:S(e,"value")}}(e);case t.KeyDown:return function(e){return{...A(t.KeyDown,e),type:t.KeyDown,key:S(e,"key")}}(e);case t.KeyUp:return function(e){return{...A(t.KeyUp,e),type:t.KeyUp,key:S(e,"key")}}(e);case t.EmulateNetworkConditions:return function(e){return{...A(t.EmulateNetworkConditions,e),type:t.EmulateNetworkConditions,download:h(e,"download"),upload:h(e,"upload"),latency:h(e,"latency")}}(e);case t.Close:return function(e){return{...A(t.Close,e),type:t.Close}}(e);case t.SetViewport:return function(e){return{...A(t.SetViewport,e),type:t.SetViewport,width:h(e,"width"),height:h(e,"height"),deviceScaleFactor:h(e,"deviceScaleFactor"),isMobile:m(e,"isMobile"),hasTouch:m(e,"hasTouch"),isLandscape:m(e,"isLandscape")}}(e);case t.Scroll:return function(e){return{...x(t.Scroll,e),type:t.Scroll,x:g(e,"x"),y:g(e,"y"),selectors:v(e)}}(e);case t.Navigate:return function(e){return{...A(t.Navigate,e),type:t.Navigate,target:d(e),url:S(e,"url")}}(e);case t.CustomStep:return function(e){if(!p(e,"name"))throw new Error("customStep is missing name");if(!c(e.name))throw new Error("customStep's name is not a string");return{...x(t.CustomStep,e),type:t.CustomStep,name:e.name,parameters:p(e,"parameters")?e.parameters:void 0}}(e);case t.WaitForElement:return function(e){const n=y(e,"operator");if(n&&">="!==n&&"=="!==n&&"<="!==n)throw new Error("WaitForElement step's operator is not one of '>=','==','<='");if(p(e,"attributes")&&(!l(e.attributes)||Object.values(e.attributes).some((e=>"string"!=typeof e))))throw new Error("WaitForElement step's attribute is not a dictionary of strings");if(p(e,"properties")&&!l(e.properties))throw new Error("WaitForElement step's attribute is not an object");return{...C(t.WaitForElement,e),type:t.WaitForElement,operator:n,count:g(e,"count"),visible:b(e,"visible"),attributes:p(e,"attributes")?e.attributes:void 0,properties:p(e,"properties")?e.properties:void 0}}(e);case t.WaitForExpression:return function(e){if(!p(e,"expression"))throw new Error("waitForExpression step is missing `expression`");return{...x(t.WaitForExpression,e),type:t.WaitForExpression,expression:S(e,"expression")}}(e);default:throw new Error(`Step type ${e.type} is not supported`)}}function N(e){const t=[];if(!f(e))throw new Error("Recording `steps` is not an array");for(const[n,r]of e.entries())t.push($(r,n));return t}const P=1,I=3e4,R=`Timeout is not between ${P} and ${I} milliseconds`;function j(e){return e>=P&&e<=I}function B(e){if(!l(e))throw new Error("Recording is not an object");if(!p(e,"title"))throw new Error("Recording is missing `title`");if(!c(e.title))throw new Error("Recording `title` is not a string");if(p(e,"timeout")&&!u(e.timeout))throw new Error("Recording `timeout` is not a number");if(!p(e,"steps"))throw new Error("Recording is missing `steps`");if(p(e,"timeout")&&u(e.timeout)&&!j(e.timeout))throw new Error(R);return t={title:e.title,timeout:p(e,"timeout")&&u(e.timeout)?e.timeout:void 0,selectorAttribute:p(e,"selectorAttribute")&&c(e.selectorAttribute)?e.selectorAttribute:void 0,steps:N(e.steps)},JSON.parse(JSON.stringify(t));var t}function W(t){for(const n of Object.values(e))if(t.startsWith(`${n}/`))return n;return e.CSS}function O(t){function n(e){return e.replace(/['"()]/g,"\\$&")}Array.isArray(t)||(t=[t]);return t.map((t=>{switch(W(t)){case e.ARIA:return`::-p-aria(${n(t.substring(e.ARIA.length+1))})`;case e.CSS:return t;case e.XPath:return`::-p-xpath(${n(t.substring(e.XPath.length+1))})`;case e.Pierce:return`:scope >>> ${t.substring(e.Pierce.length+1)}`;case e.Text:return`::-p-text(${n(t.substring(e.Text.length+1))})`}})).join(" >>>> ")}class D{async beforeAllSteps(e,t){}async afterAllSteps(e,t){}async beforeEachStep(e,t,n){}async stringifyStep(e,t,n){}async afterEachStep(e,t,n){}}class H extends D{async beforeAllSteps(e,t){const n={...t,steps:void 0},r=JSON.stringify(n,null,e.getIndent()).split("\n");r.pop(),r[r.length-1]+=",",r.push(e.getIndent()+'"steps": ['),e.appendLine(r.join("\n")).startBlock().startBlock()}async afterAllSteps(e){e.endBlock().endBlock().appendLine(e.getIndent()+"]").appendLine("}")}async stringifyStep(e,t,n){const r=JSON.stringify(t,null,e.getIndent());if(!n)return void e.appendLine(r);const i=n.steps.lastIndexOf(t)===n.steps.length-1?"":",";e.appendLine(r+i)}}class K{#e;#t=0;#n=[];constructor(e){this.#e=e}appendLine(e){const t=e.split("\n").map((e=>e?this.#e.repeat(this.#t)+e.trimEnd():""));return this.#n.push(...t),this}startBlock(){return this.#t++,this}endBlock(){if(this.#t--,this.#t<0)throw new Error("Extra endBlock");return this}toString(){return this.#n.join("\n")+"\n"}getIndent(){return this.#e}getSize(){return this.#n.length}}function V(e,t){const n=[];return U(e,n,1,t),n.join("")}function U(e,t=[],n=1,r=" "){switch(typeof e){case"bigint":case"symbol":case"function":case"undefined":throw new Error("Invalid JSON");case"number":case"boolean":t.push(String(e));break;case"string":t.push(X(e));break;case"object":if(null===e)t.push("null");else if(Array.isArray(e)){t.push("[\n");for(let i=0;i<e.length;i++)t.push(r.repeat(n)),U(e[i],t,n+1,r),i!==e.length-1&&t.push(","),t.push("\n");t.push(r.repeat(n-1)+"]")}else{t.push("{\n");const i=Object.keys(e);for(let a=0;a<i.length;a++){const o=i[a],s=e[o];void 0!==s&&(t.push(r.repeat(n)),t.push(o),t.push(": "),U(s,t,n+1,r),a!==i.length-1&&t.push(","),t.push("\n"))}t.push(r.repeat(n-1)+"}")}break;default:throw new Error("Unknown object type")}return t}const q=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),M=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),X=e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=(e,t,n,r)=>{if(n){if(M.has(n))return M.get(n);return"\\x"+q(n.charCodeAt(0),2)}if(r){return"\\u"+q(r.charCodeAt(0),4)}return t?M.get(t)||"":e};let i="",a="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(a="'",i=e.replace(n,r)):(a="`",i=e.replace(t,r)):(a='"',i=e.replace(t,r)):(a="'",i=e.replace(t,r)),`${a}${i}${a}`};class J extends D{#r=!1;#i;constructor(e="chrome"){super(),this.#i=e}async beforeAllSteps(e,t){e.appendLine("const puppeteer = require('puppeteer'); // v23.0.0 or later"),e.appendLine(""),e.appendLine("(async () => {").startBlock(),"firefox"===this.#i?e.appendLine("const browser = await puppeteer.launch({browser: 'firefox'});"):e.appendLine("const browser = await puppeteer.launch();"),e.appendLine("const page = await browser.newPage();"),e.appendLine(`const timeout = ${t.timeout||Y};`),e.appendLine("page.setDefaultTimeout(timeout);"),e.appendLine(""),this.#r=!1}async afterAllSteps(e,t){if(e.appendLine(""),e.appendLine("await browser.close();"),e.appendLine(""),this.#r)for(const t of _.split("\n"))e.appendLine(t);e.endBlock().appendLine("})().catch(err => {").startBlock(),e.appendLine("console.error(err);"),e.appendLine("process.exit(1);"),e.endBlock().appendLine("});")}async stringifyStep(e,r,i){e.appendLine("{").startBlock(),void 0!==r.timeout&&e.appendLine(`const timeout = ${r.timeout};`),this.#a(e,r);const a=r.assertedEvents&&r.type!==t.Navigate;if(a){e.appendLine("const promises = [];"),e.appendLine("const startWaitingForEvents = () => {").startBlock();for(const t of r.assertedEvents){if(t.type!==n.Navigation)throw new Error(`Event type ${t.type} is not supported`);e.appendLine(`promises.push(${"frame"in r&&r.frame?"frame":"targetPage"}.waitForNavigation());`)}e.endBlock().appendLine("}")}this.#o(e,r),a&&e.appendLine("await Promise.all(promises);"),e.endBlock().appendLine("}")}#s(e,t){"main"===t?e.appendLine("const targetPage = page;"):(e.appendLine(`const target = await browser.waitForTarget(t => t.url() === ${V(t,e.getIndent())}, { timeout });`),e.appendLine("const targetPage = await target.page();"),e.appendLine("targetPage.setDefaultTimeout(timeout);"))}#p(e,t){e.appendLine("let frame = targetPage.mainFrame();");for(const n of t)e.appendLine(`frame = frame.childFrames()[${n}];`)}#a(e,t){this.#s(e,t.target||"main"),t.frame&&this.#p(e,t.frame)}#l(e,t,n){e.appendLine("await puppeteer.Locator.race([").startBlock(),e.appendLine(t.selectors.map((n=>`${t.frame?"frame":"targetPage"}.locator(${V(O(n),e.getIndent())})`)).join(",\n")),e.endBlock().appendLine("])"),e.startBlock().appendLine(".setTimeout(timeout)"),t.assertedEvents?.length&&e.appendLine(".on('action', () => startWaitingForEvents())"),n(),e.endBlock()}#c(e,t){this.#l(e,t,(()=>{e.appendLine(".click({"),t.duration&&e.appendLine(` delay: ${t.duration},`),t.button&&e.appendLine(` button: '${s.get(t.button)}',`),e.appendLine(" offset: {"),e.appendLine(` x: ${t.offsetX},`),e.appendLine(` y: ${t.offsetY},`),e.appendLine(" },"),e.appendLine("});")}))}#u(e,t){this.#l(e,t,(()=>{e.appendLine(".click({"),e.appendLine(" count: 2,"),t.duration&&e.appendLine(` delay: ${t.duration},`),t.button&&e.appendLine(` button: '${s.get(t.button)}',`),e.appendLine(" offset: {"),e.appendLine(` x: ${t.offsetX},`),e.appendLine(` y: ${t.offsetY},`),e.appendLine(" },"),e.appendLine("});")}))}#f(e,t){this.#l(e,t,(()=>{e.appendLine(".hover();")}))}#d(e,t){this.#l(e,t,(()=>{e.appendLine(`.fill(${V(t.value,e.getIndent())});`)}))}#w(e,t){e.appendLine("await targetPage.emulateNetworkConditions({"),e.appendLine(` offline: ${!t.download&&!t.upload},`),e.appendLine(` downloadThroughput: ${t.download},`),e.appendLine(` uploadThroughput: ${t.upload},`),e.appendLine(` latency: ${t.latency},`),e.appendLine("});")}#h(e,t){e.appendLine(`await targetPage.keyboard.down(${V(t.key,e.getIndent())});`)}#m(e,t){e.appendLine(`await targetPage.keyboard.up(${V(t.key,e.getIndent())});`)}#g(e,t){e.appendLine("await targetPage.close()")}#y(e,t){e.appendLine(`await targetPage.setViewport(${V({width:t.width,height:t.height},e.getIndent())})`)}#b(e,t){"selectors"in t?this.#l(e,t,(()=>{e.appendLine(`.scroll({ scrollTop: ${t.y}, scrollLeft: ${t.x}});`)})):e.appendLine(`await targetPage.evaluate((x, y) => { window.scroll(x, y); }, ${t.x}, ${t.y})`)}#o(e,n){switch(n.type){case t.Click:return this.#c(e,n);case t.DoubleClick:return this.#u(e,n);case t.Hover:return this.#f(e,n);case t.Change:return this.#d(e,n);case t.EmulateNetworkConditions:return this.#w(e,n);case t.KeyDown:return this.#h(e,n);case t.KeyUp:return this.#m(e,n);case t.Close:return this.#g(e,n);case t.SetViewport:return this.#y(e,n);case t.Scroll:return this.#b(e,n);case t.Navigate:return this.#S(e,n);case t.WaitForElement:return this.#E(e,n);case t.WaitForExpression:return this.#v(e,n);case t.CustomStep:return;default:return i(n)}}#S(e,t){e.appendLine(`await targetPage.goto(${V(t.url,e.getIndent())});`)}#v(e,t){e.appendLine(`await ${t.frame?"frame":"targetPage"}.waitForFunction(${V(t.expression,e.getIndent())}, { timeout });`)}#E(e,t){this.#r=!0,e.appendLine(`await waitForElement(${V(t,e.getIndent())}, ${t.frame?"frame":"targetPage"}, timeout);`)}}const Y=5e3,_="async function waitForElement(step, frame, timeout) {\n const {\n count = 1,\n operator = '>=',\n visible = true,\n properties,\n attributes,\n } = step;\n const compFn = {\n '==': (a, b) => a === b,\n '>=': (a, b) => a >= b,\n '<=': (a, b) => a <= b,\n }[operator];\n await waitForFunction(async () => {\n const elements = await querySelectorsAll(step.selectors, frame);\n let result = compFn(elements.length, count);\n const elementsHandle = await frame.evaluateHandle((...elements) => {\n return elements;\n }, ...elements);\n await Promise.all(elements.map((element) => element.dispose()));\n if (result && (properties || attributes)) {\n result = await elementsHandle.evaluate(\n (elements, properties, attributes) => {\n for (const element of elements) {\n if (attributes) {\n for (const [name, value] of Object.entries(attributes)) {\n if (element.getAttribute(name) !== value) {\n return false;\n }\n }\n }\n if (properties) {\n if (!isDeepMatch(properties, element)) {\n return false;\n }\n }\n }\n return true;\n\n function isDeepMatch(a, b) {\n if (a === b) {\n return true;\n }\n if ((a && !b) || (!a && b)) {\n return false;\n }\n if (!(a instanceof Object) || !(b instanceof Object)) {\n return false;\n }\n for (const [key, value] of Object.entries(a)) {\n if (!isDeepMatch(value, b[key])) {\n return false;\n }\n }\n return true;\n }\n },\n properties,\n attributes\n );\n }\n await elementsHandle.dispose();\n return result === visible;\n }, timeout);\n}\n\nasync function querySelectorsAll(selectors, frame) {\n for (const selector of selectors) {\n const result = await querySelectorAll(selector, frame);\n if (result.length) {\n return result;\n }\n }\n return [];\n}\n\nasync function querySelectorAll(selector, frame) {\n if (!Array.isArray(selector)) {\n selector = [selector];\n }\n if (!selector.length) {\n throw new Error('Empty selector provided to querySelectorAll');\n }\n let elements = [];\n for (let i = 0; i < selector.length; i++) {\n const part = selector[i];\n if (i === 0) {\n elements = await frame.$$(part);\n } else {\n const tmpElements = elements;\n elements = [];\n for (const el of tmpElements) {\n elements.push(...(await el.$$(part)));\n }\n }\n if (elements.length === 0) {\n return [];\n }\n if (i < selector.length - 1) {\n const tmpElements = [];\n for (const el of elements) {\n const newEl = (await el.evaluateHandle(el => el.shadowRoot ? el.shadowRoot : el)).asElement();\n if (newEl) {\n tmpElements.push(newEl);\n }\n }\n elements = tmpElements;\n }\n }\n return elements;\n}\n\nasync function waitForFunction(fn, timeout) {\n let isActive = true;\n const timeoutId = setTimeout(() => {\n isActive = false;\n }, timeout);\n while (isActive) {\n const result = await fn();\n if (result) {\n clearTimeout(timeoutId);\n return;\n }\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n throw new Error('Timed out');\n}",z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",G=z.split("").reduce(((e,t,n)=>(e.set(t,n),e)),new Map),Q=2147483647;function Z(e){if(e<0)throw new Error("Only postive integers and zero are supported");if(e>Q)throw new Error("Only integers between 0 and "+Q+" are supported");const t=[];do{let n=31&e;(e>>>=5)>0&&(n|=32),t.push(z[n])}while(0!==e);return t.join("")}function ee(e){const t=[],n=e.split("");let r=0,i=0;for(const e of n){const n=G.get(e);r|=(31&n)<<i,i+=5;32&n||(t.push(r),r=0,i=0)}return t}const te="//# recorderSourceMap=";async function ne(e,t){t||(t={});const n=t.extension??new J,r=t.writer??new K(t.indentation??" ");await(n.beforeAllSteps?.(r,e));const i=[1];for(const t of e.steps){const a=r.getSize();await(n.beforeEachStep?.(r,t,e)),await n.stringifyStep(r,t,e),await(n.afterEachStep?.(r,t,e));const o=r.getSize();i.push(a,o-a)}return await(n.afterAllSteps?.(r,e)),r.appendLine(te+function(e){const t=[];for(const n of e)t.push(Z(n));return t.join("")}(i)),r.toString()}async function re(e,t){t||(t={});let n=t.extension;n||(n=new J),t.indentation||(t.indentation=" ");const r=t.writer??new K(t.indentation??" ");return await(n.beforeEachStep?.(r,e)),await n.stringifyStep(r,e),await(n.afterEachStep?.(r,e)),r.toString()}function ie(e){return e.trim().startsWith(te)}function ae(e){const t=e.split("\n");for(let e=t.length-1;e>=0;e--){const n=t[e];if(ie(n))return ee(n.trim().substring(22))}}function oe(e){return e.split("\n").filter((e=>!ie(e))).join("\n")}class se{async beforeAllSteps(e){}async afterAllSteps(e){}async beforeEachStep(e,t){}async runStep(e,t){}async afterEachStep(e,t){}}const pe={"==":(e,t)=>e===t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t};function le(e){return new Promise((t=>{setTimeout(t,e)}))}class ce extends se{browser;page;timeout;constructor(e,t,n){super(),this.browser=e,this.page=t,this.timeout=n?.timeout||5e3}async#L(e){try{await e._client().send("Emulation.setAutomationOverride",{enabled:!0})}catch{}}#k(e,t){return e.timeout||t?.timeout||this.timeout}async runStep(e,t){const n=this.#k(e,t),r=this.page,i=this.browser,a=await async function(e,t,n,r){if(!n.target||"main"===n.target)return t;const i=await e.waitForTarget((e=>e.url()===n.target),{timeout:r}),a=await i.page();if(!a)return null;return a.setDefaultTimeout(r),a}(i,r,e,n);let o=null;!a&&e.target&&(o=await r.waitForFrame(e.target,{timeout:n}));const s=o||a;if(!s)throw new Error("Target is not found for step: "+JSON.stringify(e));await this.#L(s);const p=await async function(e,t){let n="mainFrame"in e?e.mainFrame():e;if("frame"in t&&t.frame)for(const e of t.frame)n=n.childFrames()[e];return n}(s,e);await this.runStepInFrame(e,r,s,p,n)}async runStepInFrame(e,r,a,o,p){let l=null;const c=()=>{l=async function(e,t,r){const i=[];if(t.assertedEvents)for(const a of t.assertedEvents){if(a.type!==n.Navigation)throw new Error(`Event type ${a.type} is not supported`);i.push(e.waitForNavigation({timeout:r}))}await Promise.all(i)}(o,e,p)},u=this.page.locatorRace;switch(e.type){case t.DoubleClick:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).click({count:2,button:e.button&&s.get(e.button),delay:e.duration,offset:{x:e.offsetX,y:e.offsetY}});break;case t.Click:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).click({delay:e.duration,button:e.button&&s.get(e.button),offset:{x:e.offsetX,y:e.offsetY}});break;case t.Hover:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).hover();break;case t.EmulateNetworkConditions:c(),await r.emulateNetworkConditions(e);break;case t.KeyDown:c(),await r.keyboard.down(e.key),await le(100);break;case t.KeyUp:c(),await r.keyboard.up(e.key),await le(100);break;case t.Close:"close"in a&&(c(),await a.close());break;case t.Change:await u(e.selectors.map((e=>o.locator(O(e))))).on("action",(()=>c())).setTimeout(p).fill(e.value);break;case t.SetViewport:"setViewport"in a&&(c(),await a.setViewport(e));break;case t.Scroll:"selectors"in e?await u(e.selectors.map((e=>o.locator(O(e))))).on("action",(()=>c())).setTimeout(p).scroll({scrollLeft:e.x||0,scrollTop:e.y||0}):(c(),await o.evaluate(((e,t)=>{window.scroll(e,t)}),e.x||0,e.y||0));break;case t.Navigate:c(),await o.goto(e.url);break;case t.WaitForElement:try{c(),await async function(e,t,n){const{count:r=1,operator:i=">=",visible:a=!0,properties:o,attributes:s}=e,p=pe[i];await async function(e,t){let n=!0;const r=setTimeout((()=>{n=!1}),t);for(;n;){if(await e())return void clearTimeout(r);await new Promise((e=>setTimeout(e,100)))}throw new Error("Timed out")}((async()=>{const n=await async function(e,t){for(const n of e){const e=await fe(n,t);if(e.length)return e}return[]}(e.selectors,t);let i=p(n.length,r);const l=await t.evaluateHandle(((...e)=>e),...n);return await Promise.all(n.map((e=>e.dispose()))),i&&(o||s)&&(i=await l.evaluate(((e,t,n)=>{if(n)for(const t of e)for(const[e,r]of Object.entries(n))if(t.getAttribute(e)!==r)return!1;if(t)for(const n of e)if(!r(t,n))return!1;return!0;function r(e,t){if(e===t)return!0;if(e&&!t||!e&&t)return!1;if(!(e instanceof Object&&t instanceof Object))return!1;for(const[n,i]of Object.entries(e))if(!r(i,t[n]))return!1;return!0}}),o,s)),await l.dispose(),i===a}),n)}(e,o,p)}catch(e){throw"Timed out"===e.message?new Error("waitForElement timed out. The element(s) could not be found."):e}break;case t.WaitForExpression:c(),await o.waitForFunction(e.expression,{timeout:p});break;case t.CustomStep:break;default:i(e)}await l}}class ue extends ce{async afterAllSteps(){await this.browser.close()}}async function fe(e,t){if(Array.isArray(e)||(e=[e]),!e.length)throw new Error("Empty selector provided to querySelectorAll");let n=await t.$$(e[0]);if(!n.length)return[];for(const t of e.slice(1,e.length))if(n=(await Promise.all(n.map((async e=>{const n=await e.evaluateHandle((e=>e.shadowRoot?e.shadowRoot:e)),r=await n.$$(t);return n.dispose(),e.dispose(),r})))).flat(),!n.length)return[];return n}async function de(e,t,n){await(e.beforeEachStep?.(t,n)),await e.runStep(t,n),await(e.afterEachStep?.(t,n))}class we{#F;#A;#x=!1;constructor(e){this.#A=e}abort(){this.#x=!0}set flow(e){this.#F=e}async runBeforeAllSteps(e){await(this.#A.beforeAllSteps?.(e))}async runAfterAllSteps(e){await(this.#A.afterAllSteps?.(e))}async runStep(e){await de(this.#A,e)}async run(){if(!this.#F)throw new Error("Set the flow on the runner instance before calling `run`.");const e=this.#F;if(this.#x=!1,await(this.#A.beforeAllSteps?.(e)),this.#x)return!1;for(const t of e.steps){if(this.#x)return await(this.#A.afterAllSteps?.(e)),!1;await de(this.#A,t,e)}return await(this.#A.afterAllSteps?.(e)),!0}}async function he(e,t){const n=e instanceof se?void 0:e,r=new we((e instanceof se?e:t)??await async function(){const{default:e}=await import("puppeteer"),t=await e.launch(),n=await t.newPage();return new ue(t,n)}());return n&&(r.flow=n),r}class me extends D{async beforeAllSteps(e){e.appendLine("import url from 'url';"),e.appendLine("import { createRunner } from '@puppeteer/replay';"),e.appendLine(""),e.appendLine("export async function run(extension) {").startBlock(),e.appendLine("const runner = await createRunner(extension);"),e.appendLine(""),e.appendLine("await runner.runBeforeAllSteps();"),e.appendLine("")}async afterAllSteps(e){e.appendLine(""),e.appendLine("await runner.runAfterAllSteps();").endBlock().appendLine("}"),e.appendLine(""),e.appendLine("if (process && import.meta.url === url.pathToFileURL(process.argv[1]).href) {").startBlock().appendLine("run()").endBlock().appendLine("}")}async stringifyStep(e,t){e.appendLine(`await runner.runStep(${V(t,e.getIndent())});`)}}function ge(e){return Boolean(e.type===t.Navigate||e.assertedEvents?.some((e=>e.type===n.Navigation)))}function ye(e){for(const n of e.steps)if(n.type===t.SetViewport)return n.isMobile;return!1}class be extends J{#C=!1;async beforeAllSteps(e,t){e.appendLine("const fs = require('fs');"),await super.beforeAllSteps(e,t),e.appendLine("const lhApi = await import('lighthouse'); // v10.0.0 or later");e.appendLine(`const flags = ${V({screenEmulation:{disabled:!0}},e.getIndent())}`),ye(t)?e.appendLine("const config = undefined;"):e.appendLine("const config = lhApi.desktopConfig;"),e.appendLine(`const lhFlow = await lhApi.startFlow(page, {name: ${V(t.title,e.getIndent())}, config, flags});`)}async stringifyStep(e,n,r){if(n.type===t.SetViewport)return void await super.stringifyStep(e,n,r);const i=ge(n);i?(this.#C&&(e.appendLine("await lhFlow.endTimespan();"),this.#C=!1),e.appendLine("await lhFlow.startNavigation();")):this.#C||(e.appendLine("await lhFlow.startTimespan();"),this.#C=!0),await super.stringifyStep(e,n,r),i&&e.appendLine("await lhFlow.endNavigation();")}async afterAllSteps(e,t){this.#C&&e.appendLine("await lhFlow.endTimespan();"),e.appendLine("const lhFlowReport = await lhFlow.generateReport();"),e.appendLine("fs.writeFileSync(__dirname + '/flow.report.html', lhFlowReport)"),await super.afterAllSteps(e,t)}}class Se extends ce{#T=!1;#$=!1;#N;async createFlowResult(){if(!this.#N)throw new Error("Cannot get flow result before running the flow");return this.#N.createFlowResult()}async beforeAllSteps(e){await(super.beforeAllSteps?.(e));const{startFlow:t,desktopConfig:n}=await import("lighthouse");let r;ye(e)||(r=n),this.#N=await t(this.page,{config:r,flags:{screenEmulation:{disabled:!0}},name:e.title})}async beforeEachStep(e,n){await(super.beforeEachStep?.(e,n)),e.type!==t.SetViewport&&(ge(e)?(this.#T&&(await this.#N.endTimespan(),this.#T=!1),await this.#N.startNavigation(),this.#$=!0):this.#T||(await this.#N.startTimespan(),this.#T=!0))}async afterEachStep(e,t){this.#$&&(await this.#N.endNavigation(),this.#$=!1),await(super.afterEachStep?.(e,t))}async afterAllSteps(e){this.#T&&await this.#N.endTimespan(),await(super.afterAllSteps?.(e))}}export{n as AssertedEventType,H as JSONStringifyExtension,Se as LighthouseRunnerExtension,be as LighthouseStringifyExtension,me as PuppeteerReplayStringifyExtension,ce as PuppeteerRunnerExtension,ue as PuppeteerRunnerOwningBrowserExtension,J as PuppeteerStringifyExtension,we as Runner,se as RunnerExtension,r as Schema,e as SelectorType,t as StepType,D as StringifyExtension,i as assertAllStepTypesAreHandled,he as createRunner,X as formatAsJSLiteral,V as formatJSONAsJS,W as getSelectorType,I as maxTimeout,P as minTimeout,s as mouseButtonMap,B as parse,ae as parseSourceMap,$ as parseStep,o as pointerDeviceTypes,O as selectorToPElementSelector,ne as stringify,re as stringifyStep,oe as stripSourceMap,a as typeableInputTypes,j as validTimeout}; | |||
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High library
<!--
| @@ -1 +1 @@ | |||
| var e,t,n;!function(e){e.CSS="css",e.ARIA="aria",e.Text="text",e.XPath="xpath",e.Pierce="pierce"}(e||(e={})),function(e){e.Change="change",e.Click="click",e.Close="close",e.CustomStep="customStep",e.DoubleClick="doubleClick",e.EmulateNetworkConditions="emulateNetworkConditions",e.Hover="hover",e.KeyDown="keyDown",e.KeyUp="keyUp",e.Navigate="navigate",e.Scroll="scroll",e.SetViewport="setViewport",e.WaitForElement="waitForElement",e.WaitForExpression="waitForExpression"}(t||(t={})),function(e){e.Navigation="navigation"}(n||(n={}));var r=Object.freeze({__proto__:null,get AssertedEventType(){return n},get SelectorType(){return e},get StepType(){return t}});function i(e){throw new Error(`Unknown step type: ${e.type}`)}const a=new Set(["textarea","text","url","tel","search","password","number","email"]),o=new Set(["mouse","pen","touch"]),s=new Map([["primary","left"],["auxiliary","middle"],["secondary","right"],["back","back"],["forward","forward"]]);function p(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return!1;return void 0!==e[t]}function l(e){return"object"==typeof e&&null!==e}function c(e){return"string"==typeof e}function u(e){return"number"==typeof e}function f(e){return Array.isArray(e)}function d(e){if(p(e,"target")&&c(e.target))return e.target}function w(e){if(p(e,"frame")){if(f(t=e.frame)&&t.every((e=>Number.isInteger(e))))return e.frame;throw new Error("Step `frame` is not an integer array")}var t}function h(e,t){if(p(e,t)){const n=e[t];if(u(n))return n}throw new Error(`Step.${t} is not a number`)}function m(e,t){if(p(e,t)){const n=e[t];if("boolean"==typeof n)return n}throw new Error(`Step.${t} is not a boolean`)}function g(e,t){if(p(e,t))return h(e,t)}function y(e,t){if(p(e,t))return S(e,t)}function b(e,t){if(p(e,t))return m(e,t)}function S(e,t){if(p(e,t)){const n=e[t];if(c(n))return n}throw new Error(`Step.${t} is not a string`)}function E(e){if(!p(e,"selectors"))throw new Error("Step does not have required selectors");if(!f(e.selectors))throw new Error("Step selectors are not an array");if(0===e.selectors.length)throw new Error("Step does not have required selectors");return e.selectors.map((e=>{if(!c(e)&&!f(e))throw new Error("Selector is not an array or string");return f(e)?e.map((e=>{if(!c(e))throw new Error("Selector element is not a string");return e})):e}))}function v(e){if(p(e,"selectors"))return E(e)}function L(e){if(!l(e))throw new Error("Asserted event is not an object");if(!p(e,"type"))throw new Error("Asserted event is missing type");if(e.type===n.Navigation)return{type:n.Navigation,url:y(e,"url"),title:y(e,"title")};throw new Error("Unknown assertedEvent type")}function k(e){if(f(e))return e.map(L)}function F(e,t){if(p(t,"timeout")&&u(t.timeout)&&!j(t.timeout))throw new Error(R);return{type:e,assertedEvents:p(t,"assertedEvents")?k(t.assertedEvents):void 0,timeout:p(t,"timeout")&&u(t.timeout)?t.timeout:void 0}}function A(e,t){return{...F(e,t),target:d(t)}}function x(e,t){return{...A(e,t),frame:w(t)}}function C(e,t){return{...x(e,t),selectors:E(t)}}function T(e){const t={offsetX:h(e,"offsetX"),offsetY:h(e,"offsetY"),duration:g(e,"duration")},n=y(e,"deviceType");if(n){if("string"!=typeof(r=n)||!o.has(r))throw new Error(`'deviceType' for click steps must be one of the following: ${[...o].join(", ")}`);t.deviceType=n}var r;const i=y(e,"button");if(i){if(!function(e){return"string"==typeof e&&s.has(e)}(i))throw new Error(`'button' for click steps must be one of the following: ${[...s.keys()].join(", ")}`);t.button=i}return t}function $(e,n){if(!l(e))throw new Error(n?`Step ${n} is not an object`:"Step is not an object");if(!p(e,"type"))throw new Error(n?`Step ${n} does not have a type`:"Step does not have a type");if(!c(e.type))throw new Error(n?`Type of the step ${n} is not a string`:"Type of the step is not a string");switch(e.type){case t.Click:return function(e){return{...C(t.Click,e),...T(e),type:t.Click}}(e);case t.DoubleClick:return function(e){return{...C(t.DoubleClick,e),...T(e),type:t.DoubleClick}}(e);case t.Hover:return function(e){return{...C(t.Hover,e),type:t.Hover}}(e);case t.Change:return function(e){return{...C(t.Change,e),type:t.Change,value:S(e,"value")}}(e);case t.KeyDown:return function(e){return{...A(t.KeyDown,e),type:t.KeyDown,key:S(e,"key")}}(e);case t.KeyUp:return function(e){return{...A(t.KeyUp,e),type:t.KeyUp,key:S(e,"key")}}(e);case t.EmulateNetworkConditions:return function(e){return{...A(t.EmulateNetworkConditions,e),type:t.EmulateNetworkConditions,download:h(e,"download"),upload:h(e,"upload"),latency:h(e,"latency")}}(e);case t.Close:return function(e){return{...A(t.Close,e),type:t.Close}}(e);case t.SetViewport:return function(e){return{...A(t.SetViewport,e),type:t.SetViewport,width:h(e,"width"),height:h(e,"height"),deviceScaleFactor:h(e,"deviceScaleFactor"),isMobile:m(e,"isMobile"),hasTouch:m(e,"hasTouch"),isLandscape:m(e,"isLandscape")}}(e);case t.Scroll:return function(e){return{...x(t.Scroll,e),type:t.Scroll,x:g(e,"x"),y:g(e,"y"),selectors:v(e)}}(e);case t.Navigate:return function(e){return{...A(t.Navigate,e),type:t.Navigate,target:d(e),url:S(e,"url")}}(e);case t.CustomStep:return function(e){if(!p(e,"name"))throw new Error("customStep is missing name");if(!c(e.name))throw new Error("customStep's name is not a string");return{...x(t.CustomStep,e),type:t.CustomStep,name:e.name,parameters:p(e,"parameters")?e.parameters:void 0}}(e);case t.WaitForElement:return function(e){const n=y(e,"operator");if(n&&">="!==n&&"=="!==n&&"<="!==n)throw new Error("WaitForElement step's operator is not one of '>=','==','<='");if(p(e,"attributes")&&(!l(e.attributes)||Object.values(e.attributes).some((e=>"string"!=typeof e))))throw new Error("WaitForElement step's attribute is not a dictionary of strings");if(p(e,"properties")&&!l(e.properties))throw new Error("WaitForElement step's attribute is not an object");return{...C(t.WaitForElement,e),type:t.WaitForElement,operator:n,count:g(e,"count"),visible:b(e,"visible"),attributes:p(e,"attributes")?e.attributes:void 0,properties:p(e,"properties")?e.properties:void 0}}(e);case t.WaitForExpression:return function(e){if(!p(e,"expression"))throw new Error("waitForExpression step is missing `expression`");return{...x(t.WaitForExpression,e),type:t.WaitForExpression,expression:S(e,"expression")}}(e);default:throw new Error(`Step type ${e.type} is not supported`)}}function N(e){const t=[];if(!f(e))throw new Error("Recording `steps` is not an array");for(const[n,r]of e.entries())t.push($(r,n));return t}const P=1,I=3e4,R=`Timeout is not between ${P} and ${I} milliseconds`;function j(e){return e>=P&&e<=I}function W(e){if(!l(e))throw new Error("Recording is not an object");if(!p(e,"title"))throw new Error("Recording is missing `title`");if(!c(e.title))throw new Error("Recording `title` is not a string");if(p(e,"timeout")&&!u(e.timeout))throw new Error("Recording `timeout` is not a number");if(!p(e,"steps"))throw new Error("Recording is missing `steps`");if(p(e,"timeout")&&u(e.timeout)&&!j(e.timeout))throw new Error(R);return t={title:e.title,timeout:p(e,"timeout")&&u(e.timeout)?e.timeout:void 0,selectorAttribute:p(e,"selectorAttribute")&&c(e.selectorAttribute)?e.selectorAttribute:void 0,steps:N(e.steps)},JSON.parse(JSON.stringify(t));var t}function B(t){for(const n of Object.values(e))if(t.startsWith(`${n}/`))return n;return e.CSS}function O(t){function n(e){return e.replace(/['"()]/g,"\\$&")}Array.isArray(t)||(t=[t]);return t.map((t=>{switch(B(t)){case e.ARIA:return`::-p-aria(${n(t.substring(e.ARIA.length+1))})`;case e.CSS:return t;case e.XPath:return`::-p-xpath(${n(t.substring(e.XPath.length+1))})`;case e.Pierce:return`:scope >>> ${t.substring(e.Pierce.length+1)}`;case e.Text:return`::-p-text(${n(t.substring(e.Text.length+1))})`}})).join(" >>>> ")}class D{async beforeAllSteps(e,t){}async afterAllSteps(e,t){}async beforeEachStep(e,t,n){}async stringifyStep(e,t,n){}async afterEachStep(e,t,n){}}class H extends D{async beforeAllSteps(e,t){const n={...t,steps:void 0},r=JSON.stringify(n,null,e.getIndent()).split("\n");r.pop(),r[r.length-1]+=",",r.push(e.getIndent()+'"steps": ['),e.appendLine(r.join("\n")).startBlock().startBlock()}async afterAllSteps(e){e.endBlock().endBlock().appendLine(e.getIndent()+"]").appendLine("}")}async stringifyStep(e,t,n){const r=JSON.stringify(t,null,e.getIndent());if(!n)return void e.appendLine(r);const i=n.steps.lastIndexOf(t)===n.steps.length-1?"":",";e.appendLine(r+i)}}class K{#e;#t=0;#n=[];constructor(e){this.#e=e}appendLine(e){const t=e.split("\n").map((e=>e?this.#e.repeat(this.#t)+e.trimEnd():""));return this.#n.push(...t),this}startBlock(){return this.#t++,this}endBlock(){if(this.#t--,this.#t<0)throw new Error("Extra endBlock");return this}toString(){return this.#n.join("\n")+"\n"}getIndent(){return this.#e}getSize(){return this.#n.length}}function V(e,t){const n=[];return U(e,n,1,t),n.join("")}function U(e,t=[],n=1,r=" "){switch(typeof e){case"bigint":case"symbol":case"function":case"undefined":throw new Error("Invalid JSON");case"number":case"boolean":t.push(String(e));break;case"string":t.push(X(e));break;case"object":if(null===e)t.push("null");else if(Array.isArray(e)){t.push("[\n");for(let i=0;i<e.length;i++)t.push(r.repeat(n)),U(e[i],t,n+1,r),i!==e.length-1&&t.push(","),t.push("\n");t.push(r.repeat(n-1)+"]")}else{t.push("{\n");const i=Object.keys(e);for(let a=0;a<i.length;a++){const o=i[a],s=e[o];void 0!==s&&(t.push(r.repeat(n)),t.push(o),t.push(": "),U(s,t,n+1,r),a!==i.length-1&&t.push(","),t.push("\n"))}t.push(r.repeat(n-1)+"}")}break;default:throw new Error("Unknown object type")}return t}const q=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),M=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),X=e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=(e,t,n,r)=>{if(n){if(M.has(n))return M.get(n);return"\\x"+q(n.charCodeAt(0),2)}if(r){return"\\u"+q(r.charCodeAt(0),4)}return t?M.get(t)||"":e};let i="",a="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(a="'",i=e.replace(n,r)):(a="`",i=e.replace(t,r)):(a='"',i=e.replace(t,r)):(a="'",i=e.replace(t,r)),`${a}${i}${a}`};class J extends D{#r=!1;async beforeAllSteps(e,t){e.appendLine("const puppeteer = require('puppeteer'); // v22.0.0 or later"),e.appendLine(""),e.appendLine("(async () => {").startBlock(),e.appendLine("const browser = await puppeteer.launch();"),e.appendLine("const page = await browser.newPage();"),e.appendLine(`const timeout = ${t.timeout||Y};`),e.appendLine("page.setDefaultTimeout(timeout);"),e.appendLine(""),this.#r=!1}async afterAllSteps(e,t){if(e.appendLine(""),e.appendLine("await browser.close();"),e.appendLine(""),this.#r)for(const t of _.split("\n"))e.appendLine(t);e.endBlock().appendLine("})().catch(err => {").startBlock(),e.appendLine("console.error(err);"),e.appendLine("process.exit(1);"),e.endBlock().appendLine("});")}async stringifyStep(e,t,r){if(e.appendLine("{").startBlock(),void 0!==t.timeout&&e.appendLine(`const timeout = ${t.timeout};`),this.#i(e,t),t.assertedEvents){e.appendLine("const promises = [];"),e.appendLine("const startWaitingForEvents = () => {").startBlock();for(const r of t.assertedEvents){if(r.type!==n.Navigation)throw new Error(`Event type ${r.type} is not supported`);e.appendLine(`promises.push(${"frame"in t&&t.frame?"frame":"targetPage"}.waitForNavigation());`)}e.endBlock().appendLine("}")}this.#a(e,t),t.assertedEvents&&e.appendLine("await Promise.all(promises);"),e.endBlock().appendLine("}")}#o(e,t){"main"===t?e.appendLine("const targetPage = page;"):(e.appendLine(`const target = await browser.waitForTarget(t => t.url() === ${V(t,e.getIndent())}, { timeout });`),e.appendLine("const targetPage = await target.page();"),e.appendLine("targetPage.setDefaultTimeout(timeout);"))}#s(e,t){e.appendLine("let frame = targetPage.mainFrame();");for(const n of t)e.appendLine(`frame = frame.childFrames()[${n}];`)}#i(e,t){this.#o(e,t.target||"main"),t.frame&&this.#s(e,t.frame)}#p(e,t,n){e.appendLine("await puppeteer.Locator.race([").startBlock(),e.appendLine(t.selectors.map((n=>`${t.frame?"frame":"targetPage"}.locator(${V(O(n),e.getIndent())})`)).join(",\n")),e.endBlock().appendLine("])"),e.startBlock().appendLine(".setTimeout(timeout)"),t.assertedEvents?.length&&e.appendLine(".on('action', () => startWaitingForEvents())"),n(),e.endBlock()}#l(e,t){this.#p(e,t,(()=>{e.appendLine(".click({"),t.duration&&e.appendLine(` delay: ${t.duration},`),t.button&&e.appendLine(` button: '${s.get(t.button)}',`),e.appendLine(" offset: {"),e.appendLine(` x: ${t.offsetX},`),e.appendLine(` y: ${t.offsetY},`),e.appendLine(" },"),e.appendLine("});")}))}#c(e,t){this.#p(e,t,(()=>{e.appendLine(".click({"),e.appendLine(" count: 2,"),t.duration&&e.appendLine(` delay: ${t.duration},`),t.button&&e.appendLine(` button: '${s.get(t.button)}',`),e.appendLine(" offset: {"),e.appendLine(` x: ${t.offsetX},`),e.appendLine(` y: ${t.offsetY},`),e.appendLine(" },"),e.appendLine("});")}))}#u(e,t){this.#p(e,t,(()=>{e.appendLine(".hover();")}))}#f(e,t){this.#p(e,t,(()=>{e.appendLine(`.fill(${V(t.value,e.getIndent())});`)}))}#d(e,t){e.appendLine("await targetPage.emulateNetworkConditions({"),e.appendLine(` offline: ${!t.download&&!t.upload},`),e.appendLine(` downloadThroughput: ${t.download},`),e.appendLine(` uploadThroughput: ${t.upload},`),e.appendLine(` latency: ${t.latency},`),e.appendLine("});")}#w(e,t){e.appendLine(`await targetPage.keyboard.down(${V(t.key,e.getIndent())});`)}#h(e,t){e.appendLine(`await targetPage.keyboard.up(${V(t.key,e.getIndent())});`)}#m(e,t){e.appendLine("await targetPage.close()")}#g(e,t){e.appendLine(`await targetPage.setViewport(${V({width:t.width,height:t.height},e.getIndent())})`)}#y(e,t){"selectors"in t?this.#p(e,t,(()=>{e.appendLine(`.scroll({ scrollTop: ${t.y}, scrollLeft: ${t.x}});`)})):e.appendLine(`await targetPage.evaluate((x, y) => { window.scroll(x, y); }, ${t.x}, ${t.y})`)}#a(e,n){switch(n.type){case t.Click:return this.#l(e,n);case t.DoubleClick:return this.#c(e,n);case t.Hover:return this.#u(e,n);case t.Change:return this.#f(e,n);case t.EmulateNetworkConditions:return this.#d(e,n);case t.KeyDown:return this.#w(e,n);case t.KeyUp:return this.#h(e,n);case t.Close:return this.#m(e,n);case t.SetViewport:return this.#g(e,n);case t.Scroll:return this.#y(e,n);case t.Navigate:return this.#b(e,n);case t.WaitForElement:return this.#S(e,n);case t.WaitForExpression:return this.#E(e,n);case t.CustomStep:return;default:return i(n)}}#b(e,t){t.assertedEvents?.length&&e.appendLine("startWaitingForEvents();"),e.appendLine(`await targetPage.goto(${V(t.url,e.getIndent())});`)}#E(e,t){e.appendLine(`await ${t.frame?"frame":"targetPage"}.waitForFunction(${V(t.expression,e.getIndent())}, { timeout });`)}#S(e,t){this.#r=!0,e.appendLine(`await waitForElement(${V(t,e.getIndent())}, ${t.frame?"frame":"targetPage"}, timeout);`)}}const Y=5e3,_="async function waitForElement(step, frame, timeout) {\n const {\n count = 1,\n operator = '>=',\n visible = true,\n properties,\n attributes,\n } = step;\n const compFn = {\n '==': (a, b) => a === b,\n '>=': (a, b) => a >= b,\n '<=': (a, b) => a <= b,\n }[operator];\n await waitForFunction(async () => {\n const elements = await querySelectorsAll(step.selectors, frame);\n let result = compFn(elements.length, count);\n const elementsHandle = await frame.evaluateHandle((...elements) => {\n return elements;\n }, ...elements);\n await Promise.all(elements.map((element) => element.dispose()));\n if (result && (properties || attributes)) {\n result = await elementsHandle.evaluate(\n (elements, properties, attributes) => {\n for (const element of elements) {\n if (attributes) {\n for (const [name, value] of Object.entries(attributes)) {\n if (element.getAttribute(name) !== value) {\n return false;\n }\n }\n }\n if (properties) {\n if (!isDeepMatch(properties, element)) {\n return false;\n }\n }\n }\n return true;\n\n function isDeepMatch(a, b) {\n if (a === b) {\n return true;\n }\n if ((a && !b) || (!a && b)) {\n return false;\n }\n if (!(a instanceof Object) || !(b instanceof Object)) {\n return false;\n }\n for (const [key, value] of Object.entries(a)) {\n if (!isDeepMatch(value, b[key])) {\n return false;\n }\n }\n return true;\n }\n },\n properties,\n attributes\n );\n }\n await elementsHandle.dispose();\n return result === visible;\n }, timeout);\n}\n\nasync function querySelectorsAll(selectors, frame) {\n for (const selector of selectors) {\n const result = await querySelectorAll(selector, frame);\n if (result.length) {\n return result;\n }\n }\n return [];\n}\n\nasync function querySelectorAll(selector, frame) {\n if (!Array.isArray(selector)) {\n selector = [selector];\n }\n if (!selector.length) {\n throw new Error('Empty selector provided to querySelectorAll');\n }\n let elements = [];\n for (let i = 0; i < selector.length; i++) {\n const part = selector[i];\n if (i === 0) {\n elements = await frame.$$(part);\n } else {\n const tmpElements = elements;\n elements = [];\n for (const el of tmpElements) {\n elements.push(...(await el.$$(part)));\n }\n }\n if (elements.length === 0) {\n return [];\n }\n if (i < selector.length - 1) {\n const tmpElements = [];\n for (const el of elements) {\n const newEl = (await el.evaluateHandle(el => el.shadowRoot ? el.shadowRoot : el)).asElement();\n if (newEl) {\n tmpElements.push(newEl);\n }\n }\n elements = tmpElements;\n }\n }\n return elements;\n}\n\nasync function waitForFunction(fn, timeout) {\n let isActive = true;\n const timeoutId = setTimeout(() => {\n isActive = false;\n }, timeout);\n while (isActive) {\n const result = await fn();\n if (result) {\n clearTimeout(timeoutId);\n return;\n }\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n throw new Error('Timed out');\n}",z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",G=z.split("").reduce(((e,t,n)=>(e.set(t,n),e)),new Map),Q=31,Z=32,ee=2147483647;function te(e){if(e<0)throw new Error("Only postive integers and zero are supported");if(e>ee)throw new Error("Only integers between 0 and "+ee+" are supported");const t=[];do{let n=e&Q;(e>>>=5)>0&&(n|=Z),t.push(z[n])}while(0!==e);return t.join("")}function ne(e){const t=[],n=e.split("");let r=0,i=0;for(const e of n){const n=G.get(e);r|=(n&Q)<<i,i+=5;n&Z||(t.push(r),r=0,i=0)}return t}const re="//# recorderSourceMap=";async function ie(e,t){t||(t={});const n=t.extension??new J,r=t.writer??new K(t.indentation??" ");await(n.beforeAllSteps?.(r,e));const i=[1];for(const t of e.steps){const a=r.getSize();await(n.beforeEachStep?.(r,t,e)),await n.stringifyStep(r,t,e),await(n.afterEachStep?.(r,t,e));const o=r.getSize();i.push(a,o-a)}return await(n.afterAllSteps?.(r,e)),r.appendLine(re+function(e){const t=[];for(const n of e)t.push(te(n));return t.join("")}(i)),r.toString()}async function ae(e,t){t||(t={});let n=t.extension;n||(n=new J),t.indentation||(t.indentation=" ");const r=t.writer??new K(t.indentation??" ");return await(n.beforeEachStep?.(r,e)),await n.stringifyStep(r,e),await(n.afterEachStep?.(r,e)),r.toString()}function oe(e){return e.trim().startsWith(re)}function se(e){const t=e.split("\n");for(let e=t.length-1;e>=0;e--){const n=t[e];if(oe(n))return ne(n.trim().substring(re.length))}}function pe(e){return e.split("\n").filter((e=>!oe(e))).join("\n")}class le{async beforeAllSteps(e){}async afterAllSteps(e){}async beforeEachStep(e,t){}async runStep(e,t){}async afterEachStep(e,t){}}const ce={"==":(e,t)=>e===t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t};function ue(e){return new Promise((t=>{setTimeout(t,e)}))}class fe extends le{browser;page;timeout;constructor(e,t,n){super(),this.browser=e,this.page=t,this.timeout=n?.timeout||5e3}async#v(e){try{await e._client().send("Emulation.setAutomationOverride",{enabled:!0})}catch{}}#L(e,t){return e.timeout||t?.timeout||this.timeout}async runStep(e,t){const n=this.#L(e,t),r=this.page,i=this.browser,a=await async function(e,t,n,r){if(!n.target||"main"===n.target)return t;const i=await e.waitForTarget((e=>e.url()===n.target),{timeout:r}),a=await i.page();if(!a)return null;return a.setDefaultTimeout(r),a}(i,r,e,n);let o=null;if(!a&&e.target){const t=r.frames();for(const n of t)if(n.isOOPFrame()&&n.url()===e.target){o=n;break}o||(o=await r.waitForFrame(e.target,{timeout:n}))}const s=o||a;if(!s)throw new Error("Target is not found for step: "+JSON.stringify(e));await this.#v(s);const p=await async function(e,t){let n="mainFrame"in e?e.mainFrame():e;if("frame"in t&&t.frame)for(const e of t.frame)n=n.childFrames()[e];return n}(s,e);await this.runStepInFrame(e,r,s,p,n)}async runStepInFrame(e,r,a,o,p){let l=null;const c=()=>{l=async function(e,t,r){const i=[];if(t.assertedEvents)for(const a of t.assertedEvents){if(a.type!==n.Navigation)throw new Error(`Event type ${a.type} is not supported`);i.push(e.waitForNavigation({timeout:r}))}await Promise.all(i)}(o,e,p)},u=this.page.locatorRace;switch(e.type){case t.DoubleClick:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).click({count:2,button:e.button&&s.get(e.button),delay:e.duration,offset:{x:e.offsetX,y:e.offsetY}});break;case t.Click:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).click({delay:e.duration,button:e.button&&s.get(e.button),offset:{x:e.offsetX,y:e.offsetY}});break;case t.Hover:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).hover();break;case t.EmulateNetworkConditions:c(),await r.emulateNetworkConditions(e);break;case t.KeyDown:c(),await r.keyboard.down(e.key),await ue(100);break;case t.KeyUp:c(),await r.keyboard.up(e.key),await ue(100);break;case t.Close:"close"in a&&(c(),await a.close());break;case t.Change:await u(e.selectors.map((e=>o.locator(O(e))))).on("action",(()=>c())).setTimeout(p).fill(e.value);break;case t.SetViewport:"setViewport"in a&&(c(),await a.setViewport(e));break;case t.Scroll:"selectors"in e?await u(e.selectors.map((e=>o.locator(O(e))))).on("action",(()=>c())).setTimeout(p).scroll({scrollLeft:e.x||0,scrollTop:e.y||0}):(c(),await o.evaluate(((e,t)=>{window.scroll(e,t)}),e.x||0,e.y||0));break;case t.Navigate:c(),await o.goto(e.url);break;case t.WaitForElement:try{c(),await async function(e,t,n){const{count:r=1,operator:i=">=",visible:a=!0,properties:o,attributes:s}=e,p=ce[i];await async function(e,t){let n=!0;const r=setTimeout((()=>{n=!1}),t);for(;n;){if(await e())return void clearTimeout(r);await new Promise((e=>setTimeout(e,100)))}throw new Error("Timed out")}((async()=>{const n=await async function(e,t){for(const n of e){const e=await we(n,t);if(e.length)return e}return[]}(e.selectors,t);let i=p(n.length,r);const l=await t.evaluateHandle(((...e)=>e),...n);return await Promise.all(n.map((e=>e.dispose()))),i&&(o||s)&&(i=await l.evaluate(((e,t,n)=>{if(n)for(const t of e)for(const[e,r]of Object.entries(n))if(t.getAttribute(e)!==r)return!1;if(t)for(const n of e)if(!r(t,n))return!1;return!0;function r(e,t){if(e===t)return!0;if(e&&!t||!e&&t)return!1;if(!(e instanceof Object&&t instanceof Object))return!1;for(const[n,i]of Object.entries(e))if(!r(i,t[n]))return!1;return!0}}),o,s)),await l.dispose(),i===a}),n)}(e,o,p)}catch(e){throw"Timed out"===e.message?new Error("waitForElement timed out. The element(s) could not be found."):e}break;case t.WaitForExpression:c(),await o.waitForFunction(e.expression,{timeout:p});break;case t.CustomStep:break;default:i(e)}await l}}class de extends fe{async afterAllSteps(){await this.browser.close()}}async function we(e,t){if(Array.isArray(e)||(e=[e]),!e.length)throw new Error("Empty selector provided to querySelectorAll");let n=await t.$$(e[0]);if(!n.length)return[];for(const t of e.slice(1,e.length))if(n=(await Promise.all(n.map((async e=>{const n=await e.evaluateHandle((e=>e.shadowRoot?e.shadowRoot:e)),r=await n.$$(t);return n.dispose(),e.dispose(),r})))).flat(),!n.length)return[];return n}async function he(e,t,n){await(e.beforeEachStep?.(t,n)),await e.runStep(t,n),await(e.afterEachStep?.(t,n))}class me{#k;#F;#A=!1;constructor(e){this.#F=e}abort(){this.#A=!0}set flow(e){this.#k=e}async runBeforeAllSteps(e){await(this.#F.beforeAllSteps?.(e))}async runAfterAllSteps(e){await(this.#F.afterAllSteps?.(e))}async runStep(e){await he(this.#F,e)}async run(){if(!this.#k)throw new Error("Set the flow on the runner instance before calling `run`.");const e=this.#k;if(this.#A=!1,await(this.#F.beforeAllSteps?.(e)),this.#A)return!1;for(const t of e.steps){if(this.#A)return await(this.#F.afterAllSteps?.(e)),!1;await he(this.#F,t,e)}return await(this.#F.afterAllSteps?.(e)),!0}}async function ge(e,t){const n=e instanceof le?void 0:e,r=new me((e instanceof le?e:t)??await async function(){const{default:e}=await import("puppeteer"),t=await e.launch(),n=await t.newPage();return new de(t,n)}());return n&&(r.flow=n),r}class ye extends D{async beforeAllSteps(e){e.appendLine("import url from 'url';"),e.appendLine("import { createRunner } from '@puppeteer/replay';"),e.appendLine(""),e.appendLine("export async function run(extension) {").startBlock(),e.appendLine("const runner = await createRunner(extension);"),e.appendLine(""),e.appendLine("await runner.runBeforeAllSteps();"),e.appendLine("")}async afterAllSteps(e){e.appendLine(""),e.appendLine("await runner.runAfterAllSteps();").endBlock().appendLine("}"),e.appendLine(""),e.appendLine("if (process && import.meta.url === url.pathToFileURL(process.argv[1]).href) {").startBlock().appendLine("run()").endBlock().appendLine("}")}async stringifyStep(e,t){e.appendLine(`await runner.runStep(${V(t,e.getIndent())});`)}}function be(e){return Boolean(e.type===t.Navigate||e.assertedEvents?.some((e=>e.type===n.Navigation)))}function Se(e){for(const n of e.steps)if(n.type===t.SetViewport)return n.isMobile;return!1}class Ee extends J{#x=!1;async beforeAllSteps(e,t){e.appendLine("const fs = require('fs');"),await super.beforeAllSteps(e,t),e.appendLine("const lhApi = await import('lighthouse'); // v10.0.0 or later");e.appendLine(`const flags = ${V({screenEmulation:{disabled:!0}},e.getIndent())}`),Se(t)?e.appendLine("const config = undefined;"):e.appendLine("const config = lhApi.desktopConfig;"),e.appendLine(`const lhFlow = await lhApi.startFlow(page, {name: ${V(t.title,e.getIndent())}, config, flags});`)}async stringifyStep(e,n,r){if(n.type===t.SetViewport)return void await super.stringifyStep(e,n,r);const i=be(n);i?(this.#x&&(e.appendLine("await lhFlow.endTimespan();"),this.#x=!1),e.appendLine("await lhFlow.startNavigation();")):this.#x||(e.appendLine("await lhFlow.startTimespan();"),this.#x=!0),await super.stringifyStep(e,n,r),i&&e.appendLine("await lhFlow.endNavigation();")}async afterAllSteps(e,t){this.#x&&e.appendLine("await lhFlow.endTimespan();"),e.appendLine("const lhFlowReport = await lhFlow.generateReport();"),e.appendLine("fs.writeFileSync(__dirname + '/flow.report.html', lhFlowReport)"),await super.afterAllSteps(e,t)}}class ve extends fe{#C=!1;#T=!1;#$;async createFlowResult(){if(!this.#$)throw new Error("Cannot get flow result before running the flow");return this.#$.createFlowResult()}async beforeAllSteps(e){await(super.beforeAllSteps?.(e));const{startFlow:t,desktopConfig:n}=await import("lighthouse");let r;Se(e)||(r=n),this.#$=await t(this.page,{config:r,flags:{screenEmulation:{disabled:!0}},name:e.title})}async beforeEachStep(e,n){await(super.beforeEachStep?.(e,n)),e.type!==t.SetViewport&&(be(e)?(this.#C&&(await this.#$.endTimespan(),this.#C=!1),await this.#$.startNavigation(),this.#T=!0):this.#C||(await this.#$.startTimespan(),this.#C=!0))}async afterEachStep(e,t){this.#T&&(await this.#$.endNavigation(),this.#T=!1),await(super.afterEachStep?.(e,t))}async afterAllSteps(e){this.#C&&await this.#$.endTimespan(),await(super.afterAllSteps?.(e))}}export{n as AssertedEventType,H as JSONStringifyExtension,ve as LighthouseRunnerExtension,Ee as LighthouseStringifyExtension,ye as PuppeteerReplayStringifyExtension,fe as PuppeteerRunnerExtension,de as PuppeteerRunnerOwningBrowserExtension,J as PuppeteerStringifyExtension,me as Runner,le as RunnerExtension,r as Schema,e as SelectorType,t as StepType,D as StringifyExtension,i as assertAllStepTypesAreHandled,ge as createRunner,X as formatAsJSLiteral,V as formatJSONAsJS,B as getSelectorType,I as maxTimeout,P as minTimeout,s as mouseButtonMap,W as parse,se as parseSourceMap,$ as parseStep,o as pointerDeviceTypes,O as selectorToPElementSelector,ie as stringify,ae as stringifyStep,pe as stripSourceMap,a as typeableInputTypes,j as validTimeout}; | |||
| var e,t,n;!function(e){e.CSS="css",e.ARIA="aria",e.Text="text",e.XPath="xpath",e.Pierce="pierce"}(e||(e={})),function(e){e.Change="change",e.Click="click",e.Close="close",e.CustomStep="customStep",e.DoubleClick="doubleClick",e.EmulateNetworkConditions="emulateNetworkConditions",e.Hover="hover",e.KeyDown="keyDown",e.KeyUp="keyUp",e.Navigate="navigate",e.Scroll="scroll",e.SetViewport="setViewport",e.WaitForElement="waitForElement",e.WaitForExpression="waitForExpression"}(t||(t={})),function(e){e.Navigation="navigation"}(n||(n={}));var r=Object.freeze({__proto__:null,get AssertedEventType(){return n},get SelectorType(){return e},get StepType(){return t}});function i(e){throw new Error(`Unknown step type: ${e.type}`)}const a=new Set(["textarea","text","url","tel","search","password","number","email"]),o=new Set(["mouse","pen","touch"]),s=new Map([["primary","left"],["auxiliary","middle"],["secondary","right"],["back","back"],["forward","forward"]]);function p(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return!1;return void 0!==e[t]}function l(e){return"object"==typeof e&&null!==e}function c(e){return"string"==typeof e}function u(e){return"number"==typeof e}function f(e){return Array.isArray(e)}function d(e){if(p(e,"target")&&c(e.target))return e.target}function w(e){if(p(e,"frame")){if(f(t=e.frame)&&t.every((e=>Number.isInteger(e))))return e.frame;throw new Error("Step `frame` is not an integer array")}var t}function h(e,t){if(p(e,t)){const n=e[t];if(u(n))return n}throw new Error(`Step.${t} is not a number`)}function m(e,t){if(p(e,t)){const n=e[t];if("boolean"==typeof n)return n}throw new Error(`Step.${t} is not a boolean`)}function g(e,t){if(p(e,t))return h(e,t)}function y(e,t){if(p(e,t))return S(e,t)}function b(e,t){if(p(e,t))return m(e,t)}function S(e,t){if(p(e,t)){const n=e[t];if(c(n))return n}throw new Error(`Step.${t} is not a string`)}function E(e){if(!p(e,"selectors"))throw new Error("Step does not have required selectors");if(!f(e.selectors))throw new Error("Step selectors are not an array");if(0===e.selectors.length)throw new Error("Step does not have required selectors");return e.selectors.map((e=>{if(!c(e)&&!f(e))throw new Error("Selector is not an array or string");return f(e)?e.map((e=>{if(!c(e))throw new Error("Selector element is not a string");return e})):e}))}function v(e){if(p(e,"selectors"))return E(e)}function L(e){if(!l(e))throw new Error("Asserted event is not an object");if(!p(e,"type"))throw new Error("Asserted event is missing type");if(e.type===n.Navigation)return{type:n.Navigation,url:y(e,"url"),title:y(e,"title")};throw new Error("Unknown assertedEvent type")}function k(e){if(f(e))return e.map(L)}function F(e,t){if(p(t,"timeout")&&u(t.timeout)&&!j(t.timeout))throw new Error(R);return{type:e,assertedEvents:p(t,"assertedEvents")?k(t.assertedEvents):void 0,timeout:p(t,"timeout")&&u(t.timeout)?t.timeout:void 0}}function A(e,t){return{...F(e,t),target:d(t)}}function x(e,t){return{...A(e,t),frame:w(t)}}function C(e,t){return{...x(e,t),selectors:E(t)}}function T(e){const t={offsetX:h(e,"offsetX"),offsetY:h(e,"offsetY"),duration:g(e,"duration")},n=y(e,"deviceType");if(n){if("string"!=typeof(r=n)||!o.has(r))throw new Error(`'deviceType' for click steps must be one of the following: ${[...o].join(", ")}`);t.deviceType=n}var r;const i=y(e,"button");if(i){if(!function(e){return"string"==typeof e&&s.has(e)}(i))throw new Error(`'button' for click steps must be one of the following: ${[...s.keys()].join(", ")}`);t.button=i}return t}function $(e,n){if(!l(e))throw new Error(n?`Step ${n} is not an object`:"Step is not an object");if(!p(e,"type"))throw new Error(n?`Step ${n} does not have a type`:"Step does not have a type");if(!c(e.type))throw new Error(n?`Type of the step ${n} is not a string`:"Type of the step is not a string");switch(e.type){case t.Click:return function(e){return{...C(t.Click,e),...T(e),type:t.Click}}(e);case t.DoubleClick:return function(e){return{...C(t.DoubleClick,e),...T(e),type:t.DoubleClick}}(e);case t.Hover:return function(e){return{...C(t.Hover,e),type:t.Hover}}(e);case t.Change:return function(e){return{...C(t.Change,e),type:t.Change,value:S(e,"value")}}(e);case t.KeyDown:return function(e){return{...A(t.KeyDown,e),type:t.KeyDown,key:S(e,"key")}}(e);case t.KeyUp:return function(e){return{...A(t.KeyUp,e),type:t.KeyUp,key:S(e,"key")}}(e);case t.EmulateNetworkConditions:return function(e){return{...A(t.EmulateNetworkConditions,e),type:t.EmulateNetworkConditions,download:h(e,"download"),upload:h(e,"upload"),latency:h(e,"latency")}}(e);case t.Close:return function(e){return{...A(t.Close,e),type:t.Close}}(e);case t.SetViewport:return function(e){return{...A(t.SetViewport,e),type:t.SetViewport,width:h(e,"width"),height:h(e,"height"),deviceScaleFactor:h(e,"deviceScaleFactor"),isMobile:m(e,"isMobile"),hasTouch:m(e,"hasTouch"),isLandscape:m(e,"isLandscape")}}(e);case t.Scroll:return function(e){return{...x(t.Scroll,e),type:t.Scroll,x:g(e,"x"),y:g(e,"y"),selectors:v(e)}}(e);case t.Navigate:return function(e){return{...A(t.Navigate,e),type:t.Navigate,target:d(e),url:S(e,"url")}}(e);case t.CustomStep:return function(e){if(!p(e,"name"))throw new Error("customStep is missing name");if(!c(e.name))throw new Error("customStep's name is not a string");return{...x(t.CustomStep,e),type:t.CustomStep,name:e.name,parameters:p(e,"parameters")?e.parameters:void 0}}(e);case t.WaitForElement:return function(e){const n=y(e,"operator");if(n&&">="!==n&&"=="!==n&&"<="!==n)throw new Error("WaitForElement step's operator is not one of '>=','==','<='");if(p(e,"attributes")&&(!l(e.attributes)||Object.values(e.attributes).some((e=>"string"!=typeof e))))throw new Error("WaitForElement step's attribute is not a dictionary of strings");if(p(e,"properties")&&!l(e.properties))throw new Error("WaitForElement step's attribute is not an object");return{...C(t.WaitForElement,e),type:t.WaitForElement,operator:n,count:g(e,"count"),visible:b(e,"visible"),attributes:p(e,"attributes")?e.attributes:void 0,properties:p(e,"properties")?e.properties:void 0}}(e);case t.WaitForExpression:return function(e){if(!p(e,"expression"))throw new Error("waitForExpression step is missing `expression`");return{...x(t.WaitForExpression,e),type:t.WaitForExpression,expression:S(e,"expression")}}(e);default:throw new Error(`Step type ${e.type} is not supported`)}}function N(e){const t=[];if(!f(e))throw new Error("Recording `steps` is not an array");for(const[n,r]of e.entries())t.push($(r,n));return t}const P=1,I=3e4,R=`Timeout is not between ${P} and ${I} milliseconds`;function j(e){return e>=P&&e<=I}function B(e){if(!l(e))throw new Error("Recording is not an object");if(!p(e,"title"))throw new Error("Recording is missing `title`");if(!c(e.title))throw new Error("Recording `title` is not a string");if(p(e,"timeout")&&!u(e.timeout))throw new Error("Recording `timeout` is not a number");if(!p(e,"steps"))throw new Error("Recording is missing `steps`");if(p(e,"timeout")&&u(e.timeout)&&!j(e.timeout))throw new Error(R);return t={title:e.title,timeout:p(e,"timeout")&&u(e.timeout)?e.timeout:void 0,selectorAttribute:p(e,"selectorAttribute")&&c(e.selectorAttribute)?e.selectorAttribute:void 0,steps:N(e.steps)},JSON.parse(JSON.stringify(t));var t}function W(t){for(const n of Object.values(e))if(t.startsWith(`${n}/`))return n;return e.CSS}function O(t){function n(e){return e.replace(/['"()]/g,"\\$&")}Array.isArray(t)||(t=[t]);return t.map((t=>{switch(W(t)){case e.ARIA:return`::-p-aria(${n(t.substring(e.ARIA.length+1))})`;case e.CSS:return t;case e.XPath:return`::-p-xpath(${n(t.substring(e.XPath.length+1))})`;case e.Pierce:return`:scope >>> ${t.substring(e.Pierce.length+1)}`;case e.Text:return`::-p-text(${n(t.substring(e.Text.length+1))})`}})).join(" >>>> ")}class D{async beforeAllSteps(e,t){}async afterAllSteps(e,t){}async beforeEachStep(e,t,n){}async stringifyStep(e,t,n){}async afterEachStep(e,t,n){}}class H extends D{async beforeAllSteps(e,t){const n={...t,steps:void 0},r=JSON.stringify(n,null,e.getIndent()).split("\n");r.pop(),r[r.length-1]+=",",r.push(e.getIndent()+'"steps": ['),e.appendLine(r.join("\n")).startBlock().startBlock()}async afterAllSteps(e){e.endBlock().endBlock().appendLine(e.getIndent()+"]").appendLine("}")}async stringifyStep(e,t,n){const r=JSON.stringify(t,null,e.getIndent());if(!n)return void e.appendLine(r);const i=n.steps.lastIndexOf(t)===n.steps.length-1?"":",";e.appendLine(r+i)}}class K{#e;#t=0;#n=[];constructor(e){this.#e=e}appendLine(e){const t=e.split("\n").map((e=>e?this.#e.repeat(this.#t)+e.trimEnd():""));return this.#n.push(...t),this}startBlock(){return this.#t++,this}endBlock(){if(this.#t--,this.#t<0)throw new Error("Extra endBlock");return this}toString(){return this.#n.join("\n")+"\n"}getIndent(){return this.#e}getSize(){return this.#n.length}}function V(e,t){const n=[];return U(e,n,1,t),n.join("")}function U(e,t=[],n=1,r=" "){switch(typeof e){case"bigint":case"symbol":case"function":case"undefined":throw new Error("Invalid JSON");case"number":case"boolean":t.push(String(e));break;case"string":t.push(X(e));break;case"object":if(null===e)t.push("null");else if(Array.isArray(e)){t.push("[\n");for(let i=0;i<e.length;i++)t.push(r.repeat(n)),U(e[i],t,n+1,r),i!==e.length-1&&t.push(","),t.push("\n");t.push(r.repeat(n-1)+"]")}else{t.push("{\n");const i=Object.keys(e);for(let a=0;a<i.length;a++){const o=i[a],s=e[o];void 0!==s&&(t.push(r.repeat(n)),t.push(o),t.push(": "),U(s,t,n+1,r),a!==i.length-1&&t.push(","),t.push("\n"))}t.push(r.repeat(n-1)+"}")}break;default:throw new Error("Unknown object type")}return t}const q=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),M=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),X=e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=(e,t,n,r)=>{if(n){if(M.has(n))return M.get(n);return"\\x"+q(n.charCodeAt(0),2)}if(r){return"\\u"+q(r.charCodeAt(0),4)}return t?M.get(t)||"":e};let i="",a="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(a="'",i=e.replace(n,r)):(a="`",i=e.replace(t,r)):(a='"',i=e.replace(t,r)):(a="'",i=e.replace(t,r)),`${a}${i}${a}`};class J extends D{#r=!1;#i;constructor(e="chrome"){super(),this.#i=e}async beforeAllSteps(e,t){e.appendLine("const puppeteer = require('puppeteer'); // v23.0.0 or later"),e.appendLine(""),e.appendLine("(async () => {").startBlock(),"firefox"===this.#i?e.appendLine("const browser = await puppeteer.launch({browser: 'firefox'});"):e.appendLine("const browser = await puppeteer.launch();"),e.appendLine("const page = await browser.newPage();"),e.appendLine(`const timeout = ${t.timeout||Y};`),e.appendLine("page.setDefaultTimeout(timeout);"),e.appendLine(""),this.#r=!1}async afterAllSteps(e,t){if(e.appendLine(""),e.appendLine("await browser.close();"),e.appendLine(""),this.#r)for(const t of _.split("\n"))e.appendLine(t);e.endBlock().appendLine("})().catch(err => {").startBlock(),e.appendLine("console.error(err);"),e.appendLine("process.exit(1);"),e.endBlock().appendLine("});")}async stringifyStep(e,r,i){e.appendLine("{").startBlock(),void 0!==r.timeout&&e.appendLine(`const timeout = ${r.timeout};`),this.#a(e,r);const a=r.assertedEvents&&r.type!==t.Navigate;if(a){e.appendLine("const promises = [];"),e.appendLine("const startWaitingForEvents = () => {").startBlock();for(const t of r.assertedEvents){if(t.type!==n.Navigation)throw new Error(`Event type ${t.type} is not supported`);e.appendLine(`promises.push(${"frame"in r&&r.frame?"frame":"targetPage"}.waitForNavigation());`)}e.endBlock().appendLine("}")}this.#o(e,r),a&&e.appendLine("await Promise.all(promises);"),e.endBlock().appendLine("}")}#s(e,t){"main"===t?e.appendLine("const targetPage = page;"):(e.appendLine(`const target = await browser.waitForTarget(t => t.url() === ${V(t,e.getIndent())}, { timeout });`),e.appendLine("const targetPage = await target.page();"),e.appendLine("targetPage.setDefaultTimeout(timeout);"))}#p(e,t){e.appendLine("let frame = targetPage.mainFrame();");for(const n of t)e.appendLine(`frame = frame.childFrames()[${n}];`)}#a(e,t){this.#s(e,t.target||"main"),t.frame&&this.#p(e,t.frame)}#l(e,t,n){e.appendLine("await puppeteer.Locator.race([").startBlock(),e.appendLine(t.selectors.map((n=>`${t.frame?"frame":"targetPage"}.locator(${V(O(n),e.getIndent())})`)).join(",\n")),e.endBlock().appendLine("])"),e.startBlock().appendLine(".setTimeout(timeout)"),t.assertedEvents?.length&&e.appendLine(".on('action', () => startWaitingForEvents())"),n(),e.endBlock()}#c(e,t){this.#l(e,t,(()=>{e.appendLine(".click({"),t.duration&&e.appendLine(` delay: ${t.duration},`),t.button&&e.appendLine(` button: '${s.get(t.button)}',`),e.appendLine(" offset: {"),e.appendLine(` x: ${t.offsetX},`),e.appendLine(` y: ${t.offsetY},`),e.appendLine(" },"),e.appendLine("});")}))}#u(e,t){this.#l(e,t,(()=>{e.appendLine(".click({"),e.appendLine(" count: 2,"),t.duration&&e.appendLine(` delay: ${t.duration},`),t.button&&e.appendLine(` button: '${s.get(t.button)}',`),e.appendLine(" offset: {"),e.appendLine(` x: ${t.offsetX},`),e.appendLine(` y: ${t.offsetY},`),e.appendLine(" },"),e.appendLine("});")}))}#f(e,t){this.#l(e,t,(()=>{e.appendLine(".hover();")}))}#d(e,t){this.#l(e,t,(()=>{e.appendLine(`.fill(${V(t.value,e.getIndent())});`)}))}#w(e,t){e.appendLine("await targetPage.emulateNetworkConditions({"),e.appendLine(` offline: ${!t.download&&!t.upload},`),e.appendLine(` downloadThroughput: ${t.download},`),e.appendLine(` uploadThroughput: ${t.upload},`),e.appendLine(` latency: ${t.latency},`),e.appendLine("});")}#h(e,t){e.appendLine(`await targetPage.keyboard.down(${V(t.key,e.getIndent())});`)}#m(e,t){e.appendLine(`await targetPage.keyboard.up(${V(t.key,e.getIndent())});`)}#g(e,t){e.appendLine("await targetPage.close()")}#y(e,t){e.appendLine(`await targetPage.setViewport(${V({width:t.width,height:t.height},e.getIndent())})`)}#b(e,t){"selectors"in t?this.#l(e,t,(()=>{e.appendLine(`.scroll({ scrollTop: ${t.y}, scrollLeft: ${t.x}});`)})):e.appendLine(`await targetPage.evaluate((x, y) => { window.scroll(x, y); }, ${t.x}, ${t.y})`)}#o(e,n){switch(n.type){case t.Click:return this.#c(e,n);case t.DoubleClick:return this.#u(e,n);case t.Hover:return this.#f(e,n);case t.Change:return this.#d(e,n);case t.EmulateNetworkConditions:return this.#w(e,n);case t.KeyDown:return this.#h(e,n);case t.KeyUp:return this.#m(e,n);case t.Close:return this.#g(e,n);case t.SetViewport:return this.#y(e,n);case t.Scroll:return this.#b(e,n);case t.Navigate:return this.#S(e,n);case t.WaitForElement:return this.#E(e,n);case t.WaitForExpression:return this.#v(e,n);case t.CustomStep:return;default:return i(n)}}#S(e,t){e.appendLine(`await targetPage.goto(${V(t.url,e.getIndent())});`)}#v(e,t){e.appendLine(`await ${t.frame?"frame":"targetPage"}.waitForFunction(${V(t.expression,e.getIndent())}, { timeout });`)}#E(e,t){this.#r=!0,e.appendLine(`await waitForElement(${V(t,e.getIndent())}, ${t.frame?"frame":"targetPage"}, timeout);`)}}const Y=5e3,_="async function waitForElement(step, frame, timeout) {\n const {\n count = 1,\n operator = '>=',\n visible = true,\n properties,\n attributes,\n } = step;\n const compFn = {\n '==': (a, b) => a === b,\n '>=': (a, b) => a >= b,\n '<=': (a, b) => a <= b,\n }[operator];\n await waitForFunction(async () => {\n const elements = await querySelectorsAll(step.selectors, frame);\n let result = compFn(elements.length, count);\n const elementsHandle = await frame.evaluateHandle((...elements) => {\n return elements;\n }, ...elements);\n await Promise.all(elements.map((element) => element.dispose()));\n if (result && (properties || attributes)) {\n result = await elementsHandle.evaluate(\n (elements, properties, attributes) => {\n for (const element of elements) {\n if (attributes) {\n for (const [name, value] of Object.entries(attributes)) {\n if (element.getAttribute(name) !== value) {\n return false;\n }\n }\n }\n if (properties) {\n if (!isDeepMatch(properties, element)) {\n return false;\n }\n }\n }\n return true;\n\n function isDeepMatch(a, b) {\n if (a === b) {\n return true;\n }\n if ((a && !b) || (!a && b)) {\n return false;\n }\n if (!(a instanceof Object) || !(b instanceof Object)) {\n return false;\n }\n for (const [key, value] of Object.entries(a)) {\n if (!isDeepMatch(value, b[key])) {\n return false;\n }\n }\n return true;\n }\n },\n properties,\n attributes\n );\n }\n await elementsHandle.dispose();\n return result === visible;\n }, timeout);\n}\n\nasync function querySelectorsAll(selectors, frame) {\n for (const selector of selectors) {\n const result = await querySelectorAll(selector, frame);\n if (result.length) {\n return result;\n }\n }\n return [];\n}\n\nasync function querySelectorAll(selector, frame) {\n if (!Array.isArray(selector)) {\n selector = [selector];\n }\n if (!selector.length) {\n throw new Error('Empty selector provided to querySelectorAll');\n }\n let elements = [];\n for (let i = 0; i < selector.length; i++) {\n const part = selector[i];\n if (i === 0) {\n elements = await frame.$$(part);\n } else {\n const tmpElements = elements;\n elements = [];\n for (const el of tmpElements) {\n elements.push(...(await el.$$(part)));\n }\n }\n if (elements.length === 0) {\n return [];\n }\n if (i < selector.length - 1) {\n const tmpElements = [];\n for (const el of elements) {\n const newEl = (await el.evaluateHandle(el => el.shadowRoot ? el.shadowRoot : el)).asElement();\n if (newEl) {\n tmpElements.push(newEl);\n }\n }\n elements = tmpElements;\n }\n }\n return elements;\n}\n\nasync function waitForFunction(fn, timeout) {\n let isActive = true;\n const timeoutId = setTimeout(() => {\n isActive = false;\n }, timeout);\n while (isActive) {\n const result = await fn();\n if (result) {\n clearTimeout(timeoutId);\n return;\n }\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n throw new Error('Timed out');\n}",z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",G=z.split("").reduce(((e,t,n)=>(e.set(t,n),e)),new Map),Q=2147483647;function Z(e){if(e<0)throw new Error("Only postive integers and zero are supported");if(e>Q)throw new Error("Only integers between 0 and "+Q+" are supported");const t=[];do{let n=31&e;(e>>>=5)>0&&(n|=32),t.push(z[n])}while(0!==e);return t.join("")}function ee(e){const t=[],n=e.split("");let r=0,i=0;for(const e of n){const n=G.get(e);r|=(31&n)<<i,i+=5;32&n||(t.push(r),r=0,i=0)}return t}const te="//# recorderSourceMap=";async function ne(e,t){t||(t={});const n=t.extension??new J,r=t.writer??new K(t.indentation??" ");await(n.beforeAllSteps?.(r,e));const i=[1];for(const t of e.steps){const a=r.getSize();await(n.beforeEachStep?.(r,t,e)),await n.stringifyStep(r,t,e),await(n.afterEachStep?.(r,t,e));const o=r.getSize();i.push(a,o-a)}return await(n.afterAllSteps?.(r,e)),r.appendLine(te+function(e){const t=[];for(const n of e)t.push(Z(n));return t.join("")}(i)),r.toString()}async function re(e,t){t||(t={});let n=t.extension;n||(n=new J),t.indentation||(t.indentation=" ");const r=t.writer??new K(t.indentation??" ");return await(n.beforeEachStep?.(r,e)),await n.stringifyStep(r,e),await(n.afterEachStep?.(r,e)),r.toString()}function ie(e){return e.trim().startsWith(te)}function ae(e){const t=e.split("\n");for(let e=t.length-1;e>=0;e--){const n=t[e];if(ie(n))return ee(n.trim().substring(22))}}function oe(e){return e.split("\n").filter((e=>!ie(e))).join("\n")}class se{async beforeAllSteps(e){}async afterAllSteps(e){}async beforeEachStep(e,t){}async runStep(e,t){}async afterEachStep(e,t){}}const pe={"==":(e,t)=>e===t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t};function le(e){return new Promise((t=>{setTimeout(t,e)}))}class ce extends se{browser;page;timeout;constructor(e,t,n){super(),this.browser=e,this.page=t,this.timeout=n?.timeout||5e3}async#L(e){try{await e._client().send("Emulation.setAutomationOverride",{enabled:!0})}catch{}}#k(e,t){return e.timeout||t?.timeout||this.timeout}async runStep(e,t){const n=this.#k(e,t),r=this.page,i=this.browser,a=await async function(e,t,n,r){if(!n.target||"main"===n.target)return t;const i=await e.waitForTarget((e=>e.url()===n.target),{timeout:r}),a=await i.page();if(!a)return null;return a.setDefaultTimeout(r),a}(i,r,e,n);let o=null;!a&&e.target&&(o=await r.waitForFrame(e.target,{timeout:n}));const s=o||a;if(!s)throw new Error("Target is not found for step: "+JSON.stringify(e));await this.#L(s);const p=await async function(e,t){let n="mainFrame"in e?e.mainFrame():e;if("frame"in t&&t.frame)for(const e of t.frame)n=n.childFrames()[e];return n}(s,e);await this.runStepInFrame(e,r,s,p,n)}async runStepInFrame(e,r,a,o,p){let l=null;const c=()=>{l=async function(e,t,r){const i=[];if(t.assertedEvents)for(const a of t.assertedEvents){if(a.type!==n.Navigation)throw new Error(`Event type ${a.type} is not supported`);i.push(e.waitForNavigation({timeout:r}))}await Promise.all(i)}(o,e,p)},u=this.page.locatorRace;switch(e.type){case t.DoubleClick:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).click({count:2,button:e.button&&s.get(e.button),delay:e.duration,offset:{x:e.offsetX,y:e.offsetY}});break;case t.Click:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).click({delay:e.duration,button:e.button&&s.get(e.button),offset:{x:e.offsetX,y:e.offsetY}});break;case t.Hover:await u(e.selectors.map((e=>o.locator(O(e))))).setTimeout(p).on("action",(()=>c())).hover();break;case t.EmulateNetworkConditions:c(),await r.emulateNetworkConditions(e);break;case t.KeyDown:c(),await r.keyboard.down(e.key),await le(100);break;case t.KeyUp:c(),await r.keyboard.up(e.key),await le(100);break;case t.Close:"close"in a&&(c(),await a.close());break;case t.Change:await u(e.selectors.map((e=>o.locator(O(e))))).on("action",(()=>c())).setTimeout(p).fill(e.value);break;case t.SetViewport:"setViewport"in a&&(c(),await a.setViewport(e));break;case t.Scroll:"selectors"in e?await u(e.selectors.map((e=>o.locator(O(e))))).on("action",(()=>c())).setTimeout(p).scroll({scrollLeft:e.x||0,scrollTop:e.y||0}):(c(),await o.evaluate(((e,t)=>{window.scroll(e,t)}),e.x||0,e.y||0));break;case t.Navigate:c(),await o.goto(e.url);break;case t.WaitForElement:try{c(),await async function(e,t,n){const{count:r=1,operator:i=">=",visible:a=!0,properties:o,attributes:s}=e,p=pe[i];await async function(e,t){let n=!0;const r=setTimeout((()=>{n=!1}),t);for(;n;){if(await e())return void clearTimeout(r);await new Promise((e=>setTimeout(e,100)))}throw new Error("Timed out")}((async()=>{const n=await async function(e,t){for(const n of e){const e=await fe(n,t);if(e.length)return e}return[]}(e.selectors,t);let i=p(n.length,r);const l=await t.evaluateHandle(((...e)=>e),...n);return await Promise.all(n.map((e=>e.dispose()))),i&&(o||s)&&(i=await l.evaluate(((e,t,n)=>{if(n)for(const t of e)for(const[e,r]of Object.entries(n))if(t.getAttribute(e)!==r)return!1;if(t)for(const n of e)if(!r(t,n))return!1;return!0;function r(e,t){if(e===t)return!0;if(e&&!t||!e&&t)return!1;if(!(e instanceof Object&&t instanceof Object))return!1;for(const[n,i]of Object.entries(e))if(!r(i,t[n]))return!1;return!0}}),o,s)),await l.dispose(),i===a}),n)}(e,o,p)}catch(e){throw"Timed out"===e.message?new Error("waitForElement timed out. The element(s) could not be found."):e}break;case t.WaitForExpression:c(),await o.waitForFunction(e.expression,{timeout:p});break;case t.CustomStep:break;default:i(e)}await l}}class ue extends ce{async afterAllSteps(){await this.browser.close()}}async function fe(e,t){if(Array.isArray(e)||(e=[e]),!e.length)throw new Error("Empty selector provided to querySelectorAll");let n=await t.$$(e[0]);if(!n.length)return[];for(const t of e.slice(1,e.length))if(n=(await Promise.all(n.map((async e=>{const n=await e.evaluateHandle((e=>e.shadowRoot?e.shadowRoot:e)),r=await n.$$(t);return n.dispose(),e.dispose(),r})))).flat(),!n.length)return[];return n}async function de(e,t,n){await(e.beforeEachStep?.(t,n)),await e.runStep(t,n),await(e.afterEachStep?.(t,n))}class we{#F;#A;#x=!1;constructor(e){this.#A=e}abort(){this.#x=!0}set flow(e){this.#F=e}async runBeforeAllSteps(e){await(this.#A.beforeAllSteps?.(e))}async runAfterAllSteps(e){await(this.#A.afterAllSteps?.(e))}async runStep(e){await de(this.#A,e)}async run(){if(!this.#F)throw new Error("Set the flow on the runner instance before calling `run`.");const e=this.#F;if(this.#x=!1,await(this.#A.beforeAllSteps?.(e)),this.#x)return!1;for(const t of e.steps){if(this.#x)return await(this.#A.afterAllSteps?.(e)),!1;await de(this.#A,t,e)}return await(this.#A.afterAllSteps?.(e)),!0}}async function he(e,t){const n=e instanceof se?void 0:e,r=new we((e instanceof se?e:t)??await async function(){const{default:e}=await import("puppeteer"),t=await e.launch(),n=await t.newPage();return new ue(t,n)}());return n&&(r.flow=n),r}class me extends D{async beforeAllSteps(e){e.appendLine("import url from 'url';"),e.appendLine("import { createRunner } from '@puppeteer/replay';"),e.appendLine(""),e.appendLine("export async function run(extension) {").startBlock(),e.appendLine("const runner = await createRunner(extension);"),e.appendLine(""),e.appendLine("await runner.runBeforeAllSteps();"),e.appendLine("")}async afterAllSteps(e){e.appendLine(""),e.appendLine("await runner.runAfterAllSteps();").endBlock().appendLine("}"),e.appendLine(""),e.appendLine("if (process && import.meta.url === url.pathToFileURL(process.argv[1]).href) {").startBlock().appendLine("run()").endBlock().appendLine("}")}async stringifyStep(e,t){e.appendLine(`await runner.runStep(${V(t,e.getIndent())});`)}}function ge(e){return Boolean(e.type===t.Navigate||e.assertedEvents?.some((e=>e.type===n.Navigation)))}function ye(e){for(const n of e.steps)if(n.type===t.SetViewport)return n.isMobile;return!1}class be extends J{#C=!1;async beforeAllSteps(e,t){e.appendLine("const fs = require('fs');"),await super.beforeAllSteps(e,t),e.appendLine("const lhApi = await import('lighthouse'); // v10.0.0 or later");e.appendLine(`const flags = ${V({screenEmulation:{disabled:!0}},e.getIndent())}`),ye(t)?e.appendLine("const config = undefined;"):e.appendLine("const config = lhApi.desktopConfig;"),e.appendLine(`const lhFlow = await lhApi.startFlow(page, {name: ${V(t.title,e.getIndent())}, config, flags});`)}async stringifyStep(e,n,r){if(n.type===t.SetViewport)return void await super.stringifyStep(e,n,r);const i=ge(n);i?(this.#C&&(e.appendLine("await lhFlow.endTimespan();"),this.#C=!1),e.appendLine("await lhFlow.startNavigation();")):this.#C||(e.appendLine("await lhFlow.startTimespan();"),this.#C=!0),await super.stringifyStep(e,n,r),i&&e.appendLine("await lhFlow.endNavigation();")}async afterAllSteps(e,t){this.#C&&e.appendLine("await lhFlow.endTimespan();"),e.appendLine("const lhFlowReport = await lhFlow.generateReport();"),e.appendLine("fs.writeFileSync(__dirname + '/flow.report.html', lhFlowReport)"),await super.afterAllSteps(e,t)}}class Se extends ce{#T=!1;#$=!1;#N;async createFlowResult(){if(!this.#N)throw new Error("Cannot get flow result before running the flow");return this.#N.createFlowResult()}async beforeAllSteps(e){await(super.beforeAllSteps?.(e));const{startFlow:t,desktopConfig:n}=await import("lighthouse");let r;ye(e)||(r=n),this.#N=await t(this.page,{config:r,flags:{screenEmulation:{disabled:!0}},name:e.title})}async beforeEachStep(e,n){await(super.beforeEachStep?.(e,n)),e.type!==t.SetViewport&&(ge(e)?(this.#T&&(await this.#N.endTimespan(),this.#T=!1),await this.#N.startNavigation(),this.#$=!0):this.#T||(await this.#N.startTimespan(),this.#T=!0))}async afterEachStep(e,t){this.#$&&(await this.#N.endNavigation(),this.#$=!1),await(super.afterEachStep?.(e,t))}async afterAllSteps(e){this.#T&&await this.#N.endTimespan(),await(super.afterAllSteps?.(e))}}export{n as AssertedEventType,H as JSONStringifyExtension,Se as LighthouseRunnerExtension,be as LighthouseStringifyExtension,me as PuppeteerReplayStringifyExtension,ce as PuppeteerRunnerExtension,ue as PuppeteerRunnerOwningBrowserExtension,J as PuppeteerStringifyExtension,we as Runner,se as RunnerExtension,r as Schema,e as SelectorType,t as StepType,D as StringifyExtension,i as assertAllStepTypesAreHandled,he as createRunner,X as formatAsJSLiteral,V as formatJSONAsJS,W as getSelectorType,I as maxTimeout,P as minTimeout,s as mouseButtonMap,B as parse,ae as parseSourceMap,$ as parseStep,o as pointerDeviceTypes,O as selectorToPElementSelector,ne as stringify,re as stringifyStep,oe as stripSourceMap,a as typeableInputTypes,j as validTimeout}; | |||
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High library
<!--
...ebugger-frontend/dist/third-party/front_end/third_party/puppeteer-replay/puppeteer-replay.js
Dismissed
Show dismissed
Hide dismissed
| import*as e from"../code_highlighter/code_highlighter.js";import*as t from"../../lit-html/lit-html.js";import*as o from"../../visual_logging/visual_logging.js";const s=new CSSStyleSheet;s.replaceSync(".token-variable{color:var(--sys-color-token-variable)}.token-property{color:var(--sys-color-token-property)}.token-type{color:var(--sys-color-token-type)}.token-variable-special{color:var(--sys-color-token-variable-special)}.token-definition{color:var(--sys-color-token-definition)}.token-builtin{color:var(--sys-color-token-builtin)}.token-number{color:var(--sys-color-token-number)}.token-string{color:var(--sys-color-token-string)}.token-string-special{color:var(--sys-color-token-string-special)}.token-atom{color:var(--sys-color-token-atom)}.token-keyword{color:var(--sys-color-token-keyword)}.token-comment{color:var(--sys-color-token-comment)}.token-meta{color:var(--sys-color-token-meta)}.token-invalid{color:var(--sys-color-error)}.token-tag{color:var(--sys-color-token-tag)}.token-attribute{color:var(--sys-color-token-attribute)}.token-attribute-value{color:var(--sys-color-token-attribute-value)}.token-inserted{color:var(--sys-color-token-inserted)}.token-deleted{color:var(--sys-color-token-deleted)}.token-heading{color:var(--sys-color-token-variable-special);font-weight:bold}.token-link{color:var(--sys-color-token-variable-special);text-decoration:underline}.token-strikethrough{text-decoration:strike-through}.token-strong{font-weight:bold}.token-emphasis{font-style:italic}\n/*# sourceURL=codeHighlighter.css */\n");const i=new CSSStyleSheet;i.replaceSync('*{box-sizing:border-box;font-size:inherit;margin:0;padding:0}:host{position:relative}devtools-editable-content{background:transparent;border:none;color:var(--override-color-recorder-input,var(--sys-color-on-surface));cursor:text;display:inline-block;line-height:18px;min-height:18px;min-width:0.5em;outline:none;overflow-wrap:anywhere}devtools-editable-content:hover,\ndevtools-editable-content:focus{box-shadow:0 0 0 1px var(--sys-color-divider);border-radius:2px}devtools-editable-content[placeholder]:empty::before{content:attr(placeholder);color:var(--sys-color-on-surface);opacity:50%}devtools-editable-content[placeholder]:empty:focus::before{content:""}devtools-suggestion-box{position:absolute;display:none}devtools-editable-content:focus ~ devtools-suggestion-box{display:block}.suggestions{background-color:var(--sys-color-cdt-base-container);box-shadow:var(--drop-shadow);min-height:1em;min-width:150px;overflow-x:hidden;overflow-y:auto;position:relative;z-index:100;max-height:350px}.suggestions > li{padding:1px;border:1px solid transparent;white-space:nowrap;font-family:var(--source-code-font-family);font-size:var(--source-code-font-size);color:var(--sys-color-on-surface)}.suggestions > li:hover{background-color:var(--sys-color-state-hover-on-subtle)}.suggestions > li.selected{background-color:var(--sys-color-primary);color:var(--sys-color-cdt-base-container)}.strikethrough{text-decoration:line-through}\n/*# sourceURL=suggestionInput.css */\n');var n=self&&self.__decorate||function(e,t,o,s){var i,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,o):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,s);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(r=(n<3?i(r):n>3?i(t,o,r):i(t,o))||r);return n>3&&r&&Object.defineProperty(t,o,r),r};function r(e,t="Assertion failed!"){if(!e)throw new Error(t)}const{html:l,Decorators:a,Directives:c,LitElement:h}=t,{customElement:d,property:u,state:g}=a,{classMap:p}=c,v={hasChanged:(e,t)=>JSON.stringify(e)!==JSON.stringify(t)};let y=class extends HTMLElement{static get observedAttributes(){return["disabled","placeholder"]}set disabled(e){this.contentEditable=String(!e)}get disabled(){return"true"!==this.contentEditable}set value(e){this.innerText=e,this.#e()}get value(){return this.innerText}set mimeType(e){this.#t=e,this.#e()}get mimeType(){return this.#t}#t="";constructor(){super(),this.contentEditable="true",this.tabIndex=0,this.addEventListener("focus",(()=>{this.innerHTML=this.innerText})),this.addEventListener("blur",this.#e.bind(this))}#e(){this.#t&&e.CodeHighlighter.highlightNode(this,this.#t)}attributeChangedCallback(e,t,o){if("disabled"===e)this.disabled=null!==o}};y=n([d("devtools-editable-content")],y);class b extends Event{static eventName="suggest";constructor(e){super(b.eventName),this.suggestion=e}}class m extends Event{static eventName="suggestioninit";listeners;constructor(e){super(m.eventName),this.listeners=e}}const k=(e,t)=>e.toLowerCase().startsWith(t.toLowerCase());let f=class extends h{static styles=[i];#o=[];constructor(){super(),this.options=[],this.expression="",this.cursor=0}#s=e=>{if(r(e instanceof KeyboardEvent,"Bound to the wrong event."),this.#o.length>0)switch(e.key){case"ArrowDown":e.stopPropagation(),e.preventDefault(),this.#i(1);break;case"ArrowUp":e.stopPropagation(),e.preventDefault(),this.#i(-1)}if("Enter"===e.key)this.#o[this.cursor]&&this.#n(this.#o[this.cursor]),e.preventDefault()};#i(e){var t,o;this.cursor=(t=this.cursor+e,o=this.#o.length,(t%o+o)%o)}#n(e){this.dispatchEvent(new b(e))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new m([["keydown",this.#s]]))}willUpdate(e){e.has("options")&&(this.options=Object.freeze([...this.options].sort())),(e.has("expression")||e.has("options"))&&(this.cursor=0,this.#o=this.options.filter((e=>(this.suggestionFilter||k)(e,this.expression))))}render(){if(0!==this.#o.length)return l`<ul class="suggestions"> | ||
| ${this.#o.map(((e,t)=>l`<li | ||
| class=${p({selected:t===this.cursor})} | ||
| import*as e from"../code_highlighter/code_highlighter.js";import*as t from"../../lit/lit.js";import*as o from"../../visual_logging/visual_logging.js";var s={cssText:`.token-variable{color:var(--sys-color-token-variable)}.token-property{color:var(--sys-color-token-property)}.token-type{color:var(--sys-color-token-type)}.token-variable-special{color:var(--sys-color-token-variable-special)}.token-definition{color:var(--sys-color-token-definition)}.token-builtin{color:var(--sys-color-token-builtin)}.token-number{color:var(--sys-color-token-number)}.token-string{color:var(--sys-color-token-string)}.token-string-special{color:var(--sys-color-token-string-special)}.token-atom{color:var(--sys-color-token-atom)}.token-keyword{color:var(--sys-color-token-keyword)}.token-comment{color:var(--sys-color-token-comment)}.token-meta{color:var(--sys-color-token-meta)}.token-invalid{color:var(--sys-color-error)}.token-tag{color:var(--sys-color-token-tag)}.token-attribute{color:var(--sys-color-token-attribute)}.token-attribute-value{color:var(--sys-color-token-attribute-value)}.token-inserted{color:var(--sys-color-token-inserted)}.token-deleted{color:var(--sys-color-token-deleted)}.token-heading{color:var(--sys-color-token-variable-special);font-weight:bold}.token-link{color:var(--sys-color-token-variable-special);text-decoration:underline}.token-strikethrough{text-decoration:line-through}.token-strong{font-weight:bold}.token-emphasis{font-style:italic}\n/*# sourceURL=${import.meta.resolve("./codeHighlighter.css")} */\n`},i={cssText:`*{box-sizing:border-box;font-size:inherit;margin:0;padding:0}:host{position:relative}devtools-editable-content{background:transparent;border:none;color:var(--override-color-recorder-input,var(--sys-color-on-surface));cursor:text;display:inline-block;line-height:18px;min-height:18px;min-width:0.5em;outline:none;overflow-wrap:anywhere}devtools-editable-content:hover,\ndevtools-editable-content:focus{box-shadow:0 0 0 1px var(--sys-color-divider);border-radius:2px}devtools-editable-content[placeholder]:empty::before{content:attr(placeholder);color:var(--sys-color-on-surface);opacity:50%}devtools-editable-content[placeholder]:empty:focus::before{content:""}devtools-suggestion-box{position:absolute;display:none}devtools-editable-content:focus ~ devtools-suggestion-box{display:block}.suggestions{background-color:var(--sys-color-cdt-base-container);box-shadow:var(--drop-shadow);min-height:1em;min-width:150px;overflow:hidden auto;position:relative;z-index:100;max-height:350px}.suggestions > li{padding:1px;border:1px solid transparent;white-space:nowrap;font-family:var(--source-code-font-family);font-size:var(--source-code-font-size);color:var(--sys-color-on-surface)}.suggestions > li:hover{background-color:var(--sys-color-state-hover-on-subtle)}.suggestions > li.selected{background-color:var(--sys-color-primary);color:var(--sys-color-cdt-base-container)}.strikethrough{text-decoration:line-through}\n/*# sourceURL=${import.meta.resolve("./suggestionInput.css")} */\n`},n=self&&self.__decorate||function(e,t,o,s){var i,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,o):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,s);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(r=(n<3?i(r):n>3?i(t,o,r):i(t,o))||r);return n>3&&r&&Object.defineProperty(t,o,r),r};const r=new CSSStyleSheet;r.replaceSync(s.cssText);const l=new CSSStyleSheet;l.replaceSync(i.cssText);function a(e,t="Assertion failed!"){if(!e)throw new Error(t)}const{html:c,Decorators:h,Directives:d,LitElement:u}=t,{customElement:g,property:p,state:v}=h,{classMap:y}=d,b={hasChanged:(e,t)=>JSON.stringify(e)!==JSON.stringify(t),attribute:!1};let m=class extends HTMLElement{static get observedAttributes(){return["disabled","placeholder"]}set disabled(e){this.contentEditable=String(!e)}get disabled(){return"true"!==this.contentEditable}set value(e){this.innerText=e,this.#e()}get value(){return this.innerText}set mimeType(e){this.#t=e,this.#e()}get mimeType(){return this.#t}#t="";constructor(){super(),this.contentEditable="true",this.tabIndex=0,this.addEventListener("focus",(()=>{this.innerHTML=this.innerText})),this.addEventListener("blur",this.#e.bind(this))}#e(){this.#t&&e.CodeHighlighter.highlightNode(this,this.#t)}attributeChangedCallback(e,t,o){if("disabled"===e)this.disabled=null!==o}};m=n([g("devtools-editable-content")],m);class k extends Event{static eventName="suggest";constructor(e){super(k.eventName),this.suggestion=e}}class f extends Event{static eventName="suggestioninit";listeners;constructor(e){super(f.eventName),this.listeners=e}}const x=(e,t)=>e.toLowerCase().startsWith(t.toLowerCase());let w=class extends u{static styles=[l];#o=[];constructor(){super(),this.options=[],this.expression="",this.cursor=0}#s=e=>{if(a(e instanceof KeyboardEvent,"Bound to the wrong event."),this.#o.length>0)switch(e.key){case"ArrowDown":e.stopPropagation(),e.preventDefault(),this.#i(1);break;case"ArrowUp":e.stopPropagation(),e.preventDefault(),this.#i(-1)}if("Enter"===e.key)this.#o[this.cursor]&&this.#n(this.#o[this.cursor]),e.preventDefault()};#i(e){var t,o;this.cursor=(t=this.cursor+e,o=this.#o.length,(t%o+o)%o)}#n(e){this.dispatchEvent(new k(e))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new f([["keydown",this.#s]]))}willUpdate(e){e.has("options")&&(this.options=Object.freeze([...this.options].sort())),(e.has("expression")||e.has("options"))&&(this.cursor=0,this.#o=this.options.filter((e=>(this.suggestionFilter||x)(e,this.expression))))}render(){if(0!==this.#o.length)return c`<ul class="suggestions"> |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium library
Summary:
Merge up to where
0.81-stableforked from main, determined by runninggit merge-base main 0.81-stableon the upstream React Native repoTest Plan:
CI should pass. Local pass of affected areas
Notes
1c51d66
RCTMaxCachableImageCountmaybe?