Dot_Files/.config/raycast/extensions/0cd446d7-5a99-4510-81dd-ddf72296859d/commandSearchStackOverflow.js

7 lines
162 KiB
JavaScript
Raw Normal View History

var yo=Object.create;var mu=Object.defineProperty;var Co=Object.getOwnPropertyDescriptor;var Eo=Object.getOwnPropertyNames;var wo=Object.getPrototypeOf,Bo=Object.prototype.hasOwnProperty;var Dn=n=>mu(n,"__esModule",{value:!0});var hu=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),So=(n,t)=>{for(var o in t)mu(n,o,{get:t[o],enumerable:!0})},An=(n,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of Eo(t))!Bo.call(n,l)&&(o||l!=="default")&&mu(n,l,{get:()=>t[l],enumerable:!(i=Co(t,l))||i.enumerable});return n},ge=(n,t)=>An(Dn(mu(n!=null?yo(wo(n)):{},"default",!t&&n&&n.__esModule?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n),vo=(n=>(t,o)=>n&&n.get(t)||(o=An(Dn({}),t,1),n&&n.set(t,o),o))(typeof WeakMap!="undefined"?new WeakMap:0);var yn=(n,t,o)=>{if(!t.has(n))throw TypeError("Cannot "+o)};var He=(n,t,o)=>(yn(n,t,"read from private field"),o?o.call(n):t.get(n)),bu=(n,t,o)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,o)},tr=(n,t,o,i)=>(yn(n,t,"write to private field"),i?i.call(n,o):t.set(n,o),o);var En=hu((Wo,Cn)=>{"use strict";function _o(n){if(!/^data:/i.test(n))throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');n=n.replace(/\r?\n/g,"");let t=n.indexOf(",");if(t===-1||t<=4)throw new TypeError("malformed data: URI");let o=n.substring(5,t).split(";"),i="",l=!1,p=o[0]||"text/plain",m=p;for(let k=1;k<o.length;k++)o[k]==="base64"?l=!0:(m+=`;${o[k]}`,o[k].indexOf("charset=")===0&&(i=o[k].substring(8)));!o[0]&&!i.length&&(m+=";charset=US-ASCII",i="US-ASCII");let b=l?"base64":"ascii",g=unescape(n.substring(t+1)),P=Buffer.from(g,b);return P.type=p,P.typeFull=m,P.charset=i,P}Cn.exports=_o});var Bn=hu((gu,wn)=>{(function(n,t){typeof gu=="object"&&typeof wn!="undefined"?t(gu):typeof define=="function"&&define.amd?define(["exports"],t):(n=typeof globalThis!="undefined"?globalThis:n||self,t(n.WebStreamsPolyfill={}))})(gu,function(n){"use strict";let t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol:e=>`Symbol(${e})`;function o(){}function i(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global}let l=i();function p(e){return typeof e=="object"&&e!==null||typeof e=="function"}let m=o,b=Promise,g=Promise.prototype.then,P=Promise.resolve.bind(b),k=Promise.reject.bind(b);function E(e){return new b(e)}function A(e){return P(e)}function d(e){return k(e)}function v(e,r,u){return g.call(e,r,u)}function S(e,r,u){v(v(e,r,u),void 0,m)}function U(e,r){S(e,r)}function re(e,r){S(e,void 0,r)}function ue(e,r,u){return v(e,r,u)}function ae(e){v(e,void 0,m)}let J=(()=>{let e=l&&l.queueMicrotask;if(typeof e=="function")return e;let r=A(void 0);return u=>v(r,u)})();function j(e,r,u){if(typeof e!="function")throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,r,u)}function he(e,r,u){try{return A(j(e,r,u))}catch(a){return d(a)}}let lr=16384;class H{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(r){let u=this._back,a=u;u._elements.length===lr-1&&(a={_elements:[],_next:void 0}),u._elements.push(r),a!==u&&(this._back=a,u._next=a),++this._size}shift(){let r=this._front,u=r,a=this._cursor,s=a+1,c=r._elements,f=c[a];return s===lr&&(u=r._next,s=0),--this._size,this._cursor=s,r!==u&&(this._front=u),c[a]=void 0,f}forEach(r){let u=this._cursor,a=this._front,s=a._elements;for(;(u!==s.length||a._next!==void 0)&&!(u===s.length&&(a=a._next,s=a._elements,u=0,s.length===0));)r(s[u]),++u}peek(){let r=this._front,u=this._cursor;return r._elements[u]}}function Pr(e,r){e._ownerReadableStream=r,r._reader=e,r._state==="readable"?ye(e):r._state==="closed"?Ce(e):Lr(e,r._storedError)}function cr(e,r){let u=e._ownerReadableStream;return ie(u,r)}function L(e){e._ownerReadableStream._state==="readable"?Pe(e,new TypeError("Reader was released and can no longer be used to monitor the stream'
`,nexist:"\u2204",nexists:"\u2204",nfr:"\u{1D52B}",Nfr:"\u{1D511}",nge:"\u2271",ngE:"\u2267\u0338",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",ngt:"\u226F",nGt:"\u226B\u20D2",ngtr:"\u226F",nGtv:"\u226B\u0338",nharr:"\u21AE",nhArr:"\u21CE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",njcy:"\u045A",NJcy:"\u040A",nlarr:"\u219A",nlArr:"\u21CD",nldr:"\u2025",nle:"\u2270",nlE:"\u2266\u0338",nleftarrow:"\u219A",nLeftarrow:"\u21CD",nleftrightarrow:"\u21AE",nLeftrightarrow:"\u21CE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nlt:"\u226E",nLt:"\u226A\u20D2",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",nopf:"\u{1D55F}",Nopf:"\u2115",not:"\xAC",Not:"\u2AEC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrarr:"\u219B",nrArr:"\u21CF",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nrightarrow:"\u219B",nRightarrow:"\u21CF",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",nscr:"\u{1D4C3}",Nscr:"\u{1D4A9}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsube:"\u2288",nsubE:"\u2AC5\u0338",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupe:"\u2289",nsupE:"\u2AC6\u0338",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",ntilde:"\xF1",Ntilde:"\xD1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",nu:"\u03BD",Nu:"\u039D",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nvdash:"\u22AC",nvDash:"\u22AD",nVdash:"\u22AE",nVDash:"\u22AF",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwarr:"\u2196",nwArr:"\u21D6",nwarrow:"\u2196",nwnear:"\u2927",oacute:"\xF3",Oacute:"\xD3",oast:"\u229B",ocir:"\u229A",ocirc:"\xF4",Ocirc:"\xD4",ocy:"\u043E",Ocy:"\u041E",odash:"\u229D",odblac:"\u0151",Odblac:"\u0150",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",oelig:"\u0153",OElig:"\u01
`,nt="-".repeat(2),Ro=Buffer.byteLength(or),xn=n=>`${nt}${n}${nt}${or.repeat(2)}`;function Tn(n,t,o){let i="";return i+=`${nt}${n}${or}`,i+=`Content-Disposition: form-data; name="${t}"`,me(o)&&(i+=`; filename="${o.name}"${or}`,i+=`Content-Type: ${o.type||"application/octet-stream"}`),`${i}${or.repeat(2)}`}var kn=()=>(0,Rn.randomBytes)(8).toString("hex");async function*Pn(n,t){for(let[o,i]of n)yield Tn(t,o,i),me(i)?yield*i.stream():yield i,yield or;yield xn(t)}function Ln(n,t){let o=0;for(let[i,l]of n)o+=Buffer.byteLength(Tn(t,i,l)),o+=me(l)?l.size:Buffer.byteLength(String(l)),o+=Ro;return o+=Buffer.byteLength(xn(t)),o}var Z=Symbol("Body internals"),Ge=class{constructor(t,{size:o=0}={}){let i=null;t===null?t=null:tt(t)?t=Buffer.from(t.toString()):me(t)||Buffer.isBuffer(t)||(at.types.isAnyArrayBuffer(t)?t=Buffer.from(t):ArrayBuffer.isView(t)?t=Buffer.from(t.buffer,t.byteOffset,t.byteLength):t instanceof ne.default||(Du(t)?(i=`NodeFetchFormDataBoundary${kn()}`,t=ne.default.Readable.from(Pn(t,i))):t=Buffer.from(String(t)))),this[Z]={body:t,boundary:i,disturbed:!1,error:null},this.size=o,t instanceof ne.default&&t.on("error",l=>{let p=l instanceof Te?l:new te(`Invalid response body while trying to fetch ${this.url}: ${l.message}`,"system",l);this[Z].error=p})}get body(){return this[Z].body}get bodyUsed(){return this[Z].disturbed}async arrayBuffer(){let{buffer:t,byteOffset:o,byteLength:i}=await Au(this);return t.slice(o,o+i)}async blob(){let t=this.headers&&this.headers.get("content-type")||this[Z].body&&this[Z].body.type||"",o=await this.buffer();return new Fn([o],{type:t})}async json(){let t=await Au(this);return JSON.parse(t.toString())}async text(){return(await Au(this)).toString()}buffer(){return Au(this)}};Object.defineProperties(Ge.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}});async function Au(n){if(n[Z].disturbed)throw new TypeError(`body used already for: ${n.url}`);if(n[Z].disturbed=!0,n[Z].error)throw n[Z].error;let{body:t}=n;if(t===null)return Buffer.alloc(0);if(me(t)&&(t=ne.default.Readable.from(t.stream())),Buffer.isBuffer(t))return t;if(!(t instanceof ne.default))return Buffer.alloc(0);let o=[],i=0;try{for await(let l of t){if(n.size>0&&i+l.length>n.size){let p=new te(`content size at ${n.url} over limit: ${n.size}`,"max-size");throw t.destroy(p),p}i+=l.length,o.push(l)}}catch(l){throw l instanceof Te?l:new te(`Invalid response body while trying to fetch ${n.url}: ${l.message}`,"system",l)}if(t.readableEnded===!0||t._readableState.ended===!0)try{return o.every(l=>typeof l=="string")?Buffer.from(o.join("")):Buffer.concat(o,i)}catch(l){throw new te(`Could not create Buffer from response body for ${n.url}: ${l.message}`,"system",l)}else throw new te(`Premature close of server response while trying to fetch ${n.url}`)}var yu=(n,t)=>{let o,i,{body:l}=n;if(n.bodyUsed)throw new Error("cannot clone body after it is used");return l instanceof ne.default&&typeof l.getBoundary!="function"&&(o=new ne.PassThrough({highWaterMark:t}),i=new ne.PassThrough({highWaterMark:t}),l.pipe(o),l.pipe(i),n[Z].body=o,l=i),l},Cu=(n,t)=>n===null?null:typeof n=="string"?"text/plain;charset=UTF-8":tt(n)?"application/x-www-form-urlencoded;charset=UTF-8":me(n)?n.type||null:Buffer.isBuffer(n)||at.types.isAnyArrayBuffer(n)||ArrayBuffer.isView(n)?null:n&&typeof n.getBoundary=="function"?`multipart/form-data;boundary=${n.getBoundary()}`:Du(n)?`multipart/form-data; boundary=${t[Z].boundary}`:n instanceof ne.default?null:"text/plain;charset=UTF-8",On=n=>{let{body:t}=n;return t===null?0:me(t)?t.size:Buffer.isBuffer(t)?t.length:t&&typeof t.getLengthSync=="function"?t.hasKnownLength&&t.hasKnownLength()?t.getLengthSync():null:Du(t)?Ln(n[Z].boundary):null},In=(n,{body:t})=>{t===null?n.end():me(t)?ne.default.Readable.from(t.stream()).pipe(n):Buffer.isBuffer(t)?(n.write(t),n.end()):t.pipe(n)};var ot=require("util"),Rr=ge(require("http"),1),Eu=typeof Rr.default.validateHeaderName=="function"?Rr.default.validateHeaderName:n=>{if(!/^[\^`\-\w!#$%&'*+.|~]+$/.
\r
`),i=!1,l=!1,p;n.on("response",m=>{let{headers:b}=m;i=b["transfer-encoding"]==="chunked"&&!b["content-length"]}),n.on("socket",m=>{let b=()=>{if(i&&!l){let g=new Error("Premature close");g.code="ERR_STREAM_PREMATURE_CLOSE",t(g)}};m.prependListener("close",b),n.on("abort",()=>{m.removeListener("close",b)}),m.on("data",g=>{l=Buffer.compare(g.slice(-5),o)===0,!l&&p&&(l=Buffer.compare(p.slice(-3),o.slice(0,3))===0&&Buffer.compare(g.slice(-2),o.slice(3))===0),p=g})})}function Su(n,t){if(!n||typeof n[t]!="number")throw new Error(`no ${t} found`)}function xr(n,t){if(!n||typeof n[t]!="string")throw new Error(`no ${t} found`)}function Tr(n,t){if(!n||!Array.isArray(n[t]))throw new Error(`no ${t} found`)}var lt=ge(Gn()),Po=n=>(Su(n,"question_id"),xr(n,"title"),Su(n,"answer_count"),Su(n,"view_count"),xr(n,"link"),Tr(n,"tags"),{id:`${n.question_id}`,title:`${lt.default.decode(n.title)}`,subtitle:`${lt.default.decode(n.tags.join(" "))}`,url:`${n.link}`,accessoryTitle:`${n.answer_count} Answers`,icon:"so.png",view_count:parseInt(`${n.view_count}`,0),answer_count:parseInt(`${n.answer_count}`,0)}),Lo=n=>{let t=n.split(" "),o=t.filter(m=>!m.startsWith(".")),i=t.filter(m=>m.startsWith(".")),l="";o.length&&(l=o.join(" "));let p="";return i.length&&(p=i.map(m=>encodeURIComponent(m.substring(1))).join(";")),{qss:l,tss:p}},Mn=async n=>{let t={method:"GET",headers:{"Content-Type":"application/json","Accept-Encoding":"gzip, deflate, br"}},{qss:o,tss:i}=Lo(n),l=`https://api.stackexchange.com/2.3/search/advanced?key=U4DMV*8nvpm3EOpvf69Rxw((&site=stackoverflow&page=1&pagesize=20&order=desc&sort=relevance&q=${encodeURIComponent(o)}&tagged=${i}&filter=default`,p=await sr(l,t);if(p.status!==200){let b=await p.json();throw new Error(`${b?.message||"Not OK"}`)}let m=await p.json();return Tr(m,"items"),m.items.map(Po).sort(function(b,g){return g.answer_count-b.answer_count||g.view_count-b.view_count})};var $n=require("react"),_u=require("@raycast/api"),Qn=(n,t,o)=>{let[i,l]=(0,$n.useState)(()=>({queryResults:Array(n.length).fill([]),queryIsLoading:!!o,clearResults:()=>{l(p=>({...p,queryResults:Array(n.length).fill([])}))},runQuery:async p=>{l(m=>({...m,queryIsLoading:!0}));try{let m=await Promise.all(n.map(b=>t(b,p)));l(b=>({...b,queryResults:m}))}catch(m){console.log("runQuery error",m),(0,_u.showToast)(_u.ToastStyle.Failure,"Failed to query",String(m))}finally{l(m=>({...m,queryIsLoading:!1}))}}}));return i};var V=require("@raycast/api");var Fu=require("@raycast/api"),qu=require("react"),Yn="visited_urls_1",Oo=async()=>{let n=await(0,Fu.getLocalStorageItem)(Yn);try{if(typeof n=="string"){let t=JSON.parse(n);if(Array.isArray(t)&&t.every(o=>typeof o=="string"))return t}}catch(t){console.error("failed to parse visitedUrls",t)}return[]},Io=async n=>{await(0,Fu.setLocalStorageItem)(Yn,JSON.stringify(n))},Jn=()=>{let[n,t]=(0,qu.useState)([]);return(0,qu.useEffect)(()=>{Oo().then(t)},[]),[n,i=>{let l=[i,...n.filter(p=>p!==i)].slice(0,1e3);t(l),Io(l)}]};var ee=require("@raycast/api"),ir=require("react");function Zn(n){let{markdown:t,error:o,isLoading:i}=No(n.quid),{pop:l}=(0,ee.useNavigation)();return o&&(0,ee.showToast)(ee.ToastStyle.Failure,"Cannot search Pipelines",o),_jsx(ee.Detail,{isLoading:i,navigationTitle:n.title,markdown:t},_jsx(ee.ActionPanel,{title:"Open"},_jsx(ee.ActionPanel.Item,{title:"Pop Back",icon:ee.Icon.Binoculars,onAction:l})))}function No(n){let[t,o]=(0,ir.useState)("## Question is Loading..."),[i,l]=(0,ir.useState)(),[p,m]=(0,ir.useState)(!1),b=!1;return(0,ir.useEffect)(()=>{async function g(){if(!(n===null||b)){m(!0),l(void 0);try{let P={method:"GET",headers:{"Content-Type":"application/json","Accept-Encoding":"gzip, deflate, br"}},k=`https://api.stackexchange.com/2.3/questions/${n}?order=desc&sort=activity&site=stackoverflow&filter=!6VvPDzPz(ezQY`,E=await sr(k,P);if(E.status!==200){let d=await E.json();throw new Error(`${d?.message||"Not OK"}`)}let A=await E.json();if(!b){Tr(A,"items");let d=A.items[0];xr(d,"body_markdown"),o(d.body_markdown)}}catch(P){b||l(P.message)}finally{b||m(!1)}}}return g(),()=>{b=!0}},[n]),{markdown:t,error:i,i
/*! https://mths.be/he v1.2.0 by @mathias | MIT license */